-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import {$e} from '../utils/templateUtils.js'; | ||
|
||
/** | ||
* @type {import('../types.js').TypeObject} | ||
*/ | ||
const catchType = { | ||
option: ['Catch'], | ||
stringRegex: /^catch\((.*)\)$/u, | ||
// Todo: Fix all the following methods up to `editUI` to work with children | ||
toValue (s) { | ||
return {value: s.slice(6, -1)}; | ||
}, | ||
getInput ({root}) { | ||
return /** @type {HTMLTextAreaElement} */ ($e(root, 'input')); | ||
}, | ||
setValue ({root, value}) { | ||
this.getInput({root}).value = value; | ||
}, | ||
getValue ({root}) { | ||
return this.getInput({root}).value; | ||
}, | ||
viewUI ({value}) { | ||
return ['span', {dataset: {type: 'catch'}}, [value]]; | ||
}, | ||
editUI ({ | ||
format, type, buildTypeChoices, specificSchemaObject, | ||
topRoot, schemaContent, typeNamespace | ||
}) { | ||
const schemaName = | ||
// @ts-expect-error Waiting for Zodex update | ||
/** @type {import('zodex').SzCatch} */ ( | ||
specificSchemaObject | ||
)?.name; | ||
return ['div', {dataset: {type: 'catch'}}, [ | ||
['label', [ | ||
['b', ['Name']], | ||
' ', | ||
['input', { | ||
disabled: Boolean(schemaName), | ||
value: schemaName ?? '' | ||
}] | ||
]], | ||
['br'], | ||
['label', [ | ||
['b', ['Value']], | ||
' ', | ||
...(/** @type {import('../typeChoices.js').BuildTypeChoices} */ ( | ||
buildTypeChoices | ||
)({ | ||
// resultType, | ||
// eslint-disable-next-line object-shorthand -- TS | ||
topRoot: /** @type {HTMLDivElement} */ (topRoot), | ||
// eslint-disable-next-line object-shorthand -- TS | ||
format: /** @type {import('../formats.js').AvailableFormat} */ ( | ||
format | ||
), | ||
schemaOriginal: schemaContent, | ||
// @ts-expect-error Waiting for Zodex update | ||
schemaContent: /** @type {import('zodex').SzCatch} */ ( | ||
specificSchemaObject | ||
)?.innerType ?? {type: 'any'}, | ||
// schemaState, | ||
state: type, | ||
// itemIndex, | ||
typeNamespace | ||
}).domArray) | ||
]] | ||
]]; | ||
} | ||
}; | ||
|
||
export default catchType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters