xmlui 0.9.87 → 0.9.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/lib/{index-D0LUEbCn.mjs → index-Bs4hp2dn.mjs} +4825 -4810
  2. package/dist/lib/index.css +1 -1
  3. package/dist/lib/{initMock-BW2s2XBp.mjs → initMock-DwAYhsKb.mjs} +1 -1
  4. package/dist/lib/language-server-web-worker.mjs +1 -1
  5. package/dist/lib/language-server.mjs +1 -1
  6. package/dist/lib/{metadata-utils-Bes0jMw3.mjs → metadata-utils-DJhOKFL6.mjs} +1 -1
  7. package/dist/lib/{server-common-LUcdzTQs.mjs → server-common-CIqrGYx-.mjs} +5172 -4715
  8. package/dist/lib/{transform-C_5kSXBN.mjs → transform-bUuxPyao.mjs} +419 -388
  9. package/dist/lib/xmlui-parser.d.ts +24 -6
  10. package/dist/lib/xmlui-parser.mjs +2 -2
  11. package/dist/lib/{xmlui-serializer-jEIItW8v.mjs → xmlui-serializer-BLFl30t9.mjs} +1 -1
  12. package/dist/lib/xmlui.d.ts +3 -0
  13. package/dist/lib/xmlui.mjs +2 -2
  14. package/dist/metadata/{collectedComponentMetadata-BoCXx9Ig.mjs → collectedComponentMetadata-fh2ak2QN.mjs} +6034 -5990
  15. package/dist/metadata/{initMock-CMaV1kVp.mjs → initMock-8hLEm7iV.mjs} +1 -1
  16. package/dist/metadata/style.css +1 -1
  17. package/dist/metadata/xmlui-metadata.mjs +1 -1
  18. package/dist/metadata/xmlui-metadata.umd.js +62 -62
  19. package/dist/scripts/package.json +1 -2
  20. package/dist/scripts/src/components/Backdrop/Backdrop.js +5 -3
  21. package/dist/scripts/src/components/Backdrop/BackdropNative.js +2 -6
  22. package/dist/scripts/src/components/CodeBlock/highlight-code.js +21 -10
  23. package/dist/scripts/src/components/Form/FormContext.js +5 -0
  24. package/dist/scripts/src/components/Markdown/parse-binding-expr.js +15 -27
  25. package/dist/scripts/src/components/Select/SelectNative.js +10 -3
  26. package/dist/scripts/src/components/Switch/Switch.js +1 -2
  27. package/dist/scripts/src/components/TextBox/TextBoxNative.js +1 -1
  28. package/dist/scripts/src/parsers/xmlui-parser/diagnostics.js +29 -7
  29. package/dist/scripts/src/parsers/xmlui-parser/parser.js +17 -10
  30. package/dist/standalone/xmlui-standalone.es.d.ts +3 -0
  31. package/dist/standalone/xmlui-standalone.umd.js +214 -214
  32. package/package.json +1 -2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmlui",
3
- "version": "0.9.87",
3
+ "version": "0.9.90",
4
4
  "sideEffects": false,
5
5
  "scripts": {
6
6
  "start-test-bed": "cd src/testing/infrastructure && xmlui start",
@@ -104,7 +104,6 @@
104
104
  "remark-gfm": "^4.0.1",
105
105
  "sass": "1.55.0",
106
106
  "scroll-into-view-if-needed": "^3.1.0",
107
- "shiki": "^1.14.1",
108
107
  "ts-node": "10.9.1",
109
108
  "turndown": "^7.2.0",
110
109
  "unist-util-visit": "^5.0.0",
@@ -22,17 +22,19 @@ exports.BackdropMd = (0, metadata_helpers_1.createMetadata)({
22
22
  backgroundColor: {
23
23
  description: "The background color of the backdrop.",
24
24
  valueType: "string",
25
- defaultValue: BackdropNative_1.defaultProps.backgroundColor,
26
25
  },
27
26
  opacity: {
28
27
  description: "The opacity of the backdrop.",
29
28
  valueType: "string",
30
- defaultValue: BackdropNative_1.defaultProps.opacity,
31
29
  },
32
30
  },
33
31
  themeVars: (0, themeVars_1.parseScssVar)(Backdrop_module_scss_1.default.themeVars),
32
+ defaultThemeVars: {
33
+ [`backgroundColor-${COMP}`]: "black",
34
+ [`opacity-${COMP}`]: "0.1",
35
+ }
34
36
  });
35
37
  exports.backdropComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.BackdropMd, ({ node, extractValue, renderChild, layoutCss }) => {
36
38
  var _a;
37
- return ((0, jsx_runtime_1.jsx)(BackdropNative_1.Backdrop, { style: layoutCss, overlayTemplate: renderChild((_a = node.props) === null || _a === void 0 ? void 0 : _a.overlayTemplate), backgroundColor: extractValue.asOptionalString(node.props.backgroundColor), opacity: extractValue.asString(node.props.opacity), children: renderChild(node.children) }));
39
+ return ((0, jsx_runtime_1.jsx)(BackdropNative_1.Backdrop, { style: layoutCss, overlayTemplate: renderChild((_a = node.props) === null || _a === void 0 ? void 0 : _a.overlayTemplate), backgroundColor: extractValue.asOptionalString(node.props.backgroundColor, undefined), opacity: extractValue.asOptionalString(node.props.opacity, undefined), children: renderChild(node.children) }));
38
40
  });
@@ -3,15 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Backdrop = exports.defaultProps = void 0;
6
+ exports.Backdrop = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const react_1 = require("react");
9
9
  const Backdrop_module_scss_1 = __importDefault(require("./Backdrop.module.scss"));
10
- exports.defaultProps = {
11
- backgroundColor: "black",
12
- opacity: "0.1",
13
- };
14
- exports.Backdrop = (0, react_1.forwardRef)(function Backdrop({ style, children, overlayTemplate, backgroundColor = exports.defaultProps.backgroundColor, opacity = exports.defaultProps.opacity, }, forwardedRef) {
10
+ exports.Backdrop = (0, react_1.forwardRef)(function Backdrop({ style, children, overlayTemplate, backgroundColor, opacity, }, forwardedRef) {
15
11
  var _a;
16
12
  const styleWithoutDims = Object.assign(Object.assign({}, style), { width: undefined });
17
13
  return ((0, jsx_runtime_1.jsxs)("div", { className: Backdrop_module_scss_1.default.backdropContainer, style: { width: (_a = style.width) !== null && _a !== void 0 ? _a : "fit-content" }, ref: forwardedRef, children: [children, (0, jsx_runtime_1.jsx)("div", { className: Backdrop_module_scss_1.default.backdrop, style: Object.assign(Object.assign({}, styleWithoutDims), { backgroundColor, opacity }) }), overlayTemplate && (0, jsx_runtime_1.jsx)("div", { className: Backdrop_module_scss_1.default.overlay, children: overlayTemplate })] }));
@@ -68,16 +68,27 @@ function parseMetaAndHighlightCode(node, codeHighlighter, themeTone) {
68
68
  const { language } = meta, restMeta = __rest(meta, ["language"]);
69
69
  if (language && codeHighlighter.availableLangs.includes(language)) {
70
70
  // NOTE: Keep in mind, at this point, we are working with the markdown text
71
- const htmlCodeStr = codeHighlighter.highlight(codeStr, language, restMeta, themeTone);
72
- const match = htmlCodeStr.match(/<pre\b[^>]*\bclass\s*=\s*["']([^"']*)["'][^>]*>/i);
73
- const classNames = match ? match[1] : null;
74
- // NOTE: Why remove the <pre>?
75
- // Shiki appends <pre> tags to the highlighted code,
76
- // so we would get <pre><pre><code>...</code></pre></pre>
77
- let cleanedHtmlStr = htmlCodeStr.replace(/<pre\b[^>]*>|<\/pre>/gi, "");
78
- const numberedRowClass = meta.rowNumbers ? "numbered" : "";
79
- cleanedHtmlStr = cleanedHtmlStr.replaceAll(/<span class="line"/g, `<span class="line ${numberedRowClass}"`);
80
- return { classNames, cleanedHtmlStr, codeStr, meta };
71
+ try {
72
+ const htmlCodeStr = codeHighlighter.highlight(codeStr, language, restMeta, themeTone);
73
+ const match = htmlCodeStr.match(/<pre\b[^>]*\bclass\s*=\s*["']([^"']*)["'][^>]*>/i);
74
+ const classNames = match ? match[1] : null;
75
+ // NOTE: Why remove the <pre>?
76
+ // Shiki appends <pre> tags to the highlighted code,
77
+ // so we would get <pre><pre><code>...</code></pre></pre>
78
+ let cleanedHtmlStr = htmlCodeStr.replace(/<pre\b[^>]*>|<\/pre>/gi, "");
79
+ const numberedRowClass = meta.rowNumbers ? "numbered" : "";
80
+ cleanedHtmlStr = cleanedHtmlStr.replaceAll(/<span class="line"/g, `<span class="line ${numberedRowClass}"`);
81
+ return { classNames, cleanedHtmlStr, codeStr, meta };
82
+ }
83
+ catch (e) {
84
+ // this could happen in safari after the optimized build (some regexp issues, could be remix/vite/shiki related, TBD)
85
+ return {
86
+ meta,
87
+ codeStr,
88
+ cleanedHtmlStr: codeStr,
89
+ classNames: null
90
+ };
91
+ }
81
92
  }
82
93
  return null;
83
94
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formControlTypesMd = exports.formControlTypes = exports.FormContext = exports.validationModeMd = exports.defaultValidationMode = exports.validationModeValues = exports.validationSeverityMd = exports.validationSeverityValues = void 0;
4
4
  exports.useFormContextPart = useFormContextPart;
5
+ exports.useIsInsideForm = useIsInsideForm;
5
6
  const use_context_selector_1 = require("use-context-selector");
6
7
  exports.validationSeverityValues = ["error", "warning", "valid", "none"];
7
8
  exports.validationSeverityMd = [
@@ -30,6 +31,10 @@ exports.FormContext = (0, use_context_selector_1.createContext)(undefined);
30
31
  function useFormContextPart(selector) {
31
32
  return (0, use_context_selector_1.useContextSelector)(exports.FormContext, selector);
32
33
  }
34
+ function useIsInsideForm() {
35
+ const contextPart = useFormContextPart((value) => value === null || value === void 0 ? void 0 : value.dispatch);
36
+ return contextPart !== undefined;
37
+ }
33
38
  exports.formControlTypes = [
34
39
  "text",
35
40
  "password",
@@ -10,33 +10,21 @@ const ScriptingSourceTree_1 = require("../../components-core/script-runner/Scrip
10
10
  * @returns the parsed text with resolved binding expressions
11
11
  */
12
12
  function parseBindingExpression(text, extractValue) {
13
- // Remove empty @{} expressions first - Safari/Edge compatible version
14
- text = text.replaceAll(/(^|[^\\])\@\{\s*\}/g, "$1");
15
- // Safari/Edge compatible iterative processing to handle adjacent bindings
16
- // Process content bindings one at a time to avoid position conflicts
17
- let previousText = "";
18
- let iterations = 0;
19
- while (text !== previousText && iterations < 100) { // Safety limit
20
- previousText = text;
21
- iterations++;
22
- // Match first non-escaped @{...} with nested braces support
23
- const match = text.match(/(^|[^\\])(\@\{((?:[^{}]|\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\})*)\})/);
24
- if (match) {
25
- const fullMatch = match[0];
26
- const prefix = match[1];
27
- const expr = match[3];
28
- const extracted = extractValue(`{${expr}}`);
29
- const resultExpr = mapByType(extracted);
30
- const replacement = typeof resultExpr === "object" && resultExpr !== null
31
- ? JSON.stringify(resultExpr)
32
- : resultExpr;
33
- text = text.replace(fullMatch, prefix + replacement);
34
- }
35
- else {
36
- break; // No more matches
37
- }
38
- }
39
- return text;
13
+ // Remove empty @{} expressions first
14
+ text = text.replaceAll(/(?<!\\)\@\{\s*\}/g, "");
15
+ // The (?<!\\) is a "negative lookbehind" in regex that ensures that
16
+ // if escaping the @{...} expression like this: \@{...}, we don't match it
17
+ const regex = /(?<!\\)\@\{((?:[^{}]|\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\})*)\}/g;
18
+ const result = text.replace(regex, (_, expr) => {
19
+ const extracted = extractValue(`{${expr}}`);
20
+ const resultExpr = mapByType(extracted);
21
+ // The result expression might be an object, in that case we stringify it here,
22
+ // at the last step, so that there are no unnecessary apostrophes
23
+ return typeof resultExpr === "object" && resultExpr !== null
24
+ ? JSON.stringify(resultExpr)
25
+ : resultExpr;
26
+ });
27
+ return result;
40
28
  // ---
41
29
  function mapByType(extracted) {
42
30
  if (extracted === null) {
@@ -55,6 +55,7 @@ const OptionTypeProvider_1 = __importDefault(require("../Option/OptionTypeProvid
55
55
  const OptionContext_1 = require("./OptionContext");
56
56
  const ItemWithLabel_1 = require("../FormItem/ItemWithLabel");
57
57
  const HiddenOption_1 = require("./HiddenOption");
58
+ const FormContext_1 = require("../Form/FormContext");
58
59
  exports.defaultProps = {
59
60
  enabled: true,
60
61
  placeholder: "",
@@ -69,13 +70,15 @@ exports.defaultProps = {
69
70
  labelBreak: false,
70
71
  };
71
72
  const SimpleSelect = (0, react_1.forwardRef)(function SimpleSelect(props, forwardedRef) {
72
- var _a;
73
73
  const { root } = (0, ThemeContext_1.useTheme)();
74
74
  const { enabled, onBlur, autoFocus, onValueChange, validationStatus, value, height, style, placeholder, id, triggerRef, onFocus, options, children, readOnly, } = props;
75
75
  const ref = forwardedRef ? (0, react_compose_refs_1.composeRefs)(triggerRef, forwardedRef) : triggerRef;
76
76
  const stringValue = (0, react_1.useMemo)(() => {
77
77
  return value != undefined ? value + "" : undefined;
78
78
  }, [value]);
79
+ const selectedOption = (0, react_1.useMemo)(() => {
80
+ return Array.from(options).find((o) => `${o.value}` === stringValue);
81
+ }, [options, stringValue]);
79
82
  const onValChange = (0, react_1.useCallback)((val) => {
80
83
  var _a;
81
84
  if (readOnly) {
@@ -88,7 +91,10 @@ const SimpleSelect = (0, react_1.forwardRef)(function SimpleSelect(props, forwar
88
91
  [Select_module_scss_1.default.error]: validationStatus === "error",
89
92
  [Select_module_scss_1.default.warning]: validationStatus === "warning",
90
93
  [Select_module_scss_1.default.valid]: validationStatus === "valid",
91
- }), ref: ref, autoFocus: autoFocus, children: [(0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectValue, children: readOnly ? (((_a = Array.from(options).find((o) => `${o.value}` === stringValue)) === null || _a === void 0 ? void 0 : _a.label) || ((0, jsx_runtime_1.jsx)("span", { "aria-placeholder": placeholder, children: placeholder }))) : ((0, jsx_runtime_1.jsx)(react_select_1.Value, { "aria-placeholder": placeholder, placeholder: placeholder })) }), (0, jsx_runtime_1.jsx)(react_select_1.Icon, { asChild: true, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }), (0, jsx_runtime_1.jsx)(react_select_1.Portal, { container: root, children: (0, jsx_runtime_1.jsxs)(react_select_1.Content, { className: Select_module_scss_1.default.selectContent, position: "popper", style: { height: height }, children: [(0, jsx_runtime_1.jsx)(react_select_1.ScrollUpButton, { className: Select_module_scss_1.default.selectScrollUpButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevronup" }) }), (0, jsx_runtime_1.jsx)(react_select_1.SelectViewport, { className: Select_module_scss_1.default.selectViewport, role: "listbox", children: children }), (0, jsx_runtime_1.jsx)(react_select_1.ScrollDownButton, { className: Select_module_scss_1.default.selectScrollDownButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }) })] }));
94
+ }), ref: ref, autoFocus: autoFocus, children: [(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(Select_module_scss_1.default.selectValue, {
95
+ [Select_module_scss_1.default.selectValue]: selectedOption !== undefined,
96
+ [Select_module_scss_1.default.placeholder]: selectedOption === undefined,
97
+ }), children: selectedOption ? selectedOption.label : readOnly ? "" : placeholder }), (0, jsx_runtime_1.jsx)(react_select_1.Icon, { asChild: true, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }), (0, jsx_runtime_1.jsx)(react_select_1.Portal, { container: root, children: (0, jsx_runtime_1.jsxs)(react_select_1.Content, { className: Select_module_scss_1.default.selectContent, position: "popper", style: { height: height }, children: [(0, jsx_runtime_1.jsx)(react_select_1.ScrollUpButton, { className: Select_module_scss_1.default.selectScrollUpButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevronup" }) }), (0, jsx_runtime_1.jsx)(react_select_1.SelectViewport, { className: Select_module_scss_1.default.selectViewport, role: "listbox", children: children }), (0, jsx_runtime_1.jsx)(react_select_1.ScrollDownButton, { className: Select_module_scss_1.default.selectScrollDownButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }) })] }));
92
98
  });
93
99
  exports.Select = (0, react_1.forwardRef)(function Select({ id, initialValue, value, enabled = exports.defaultProps.enabled, placeholder = exports.defaultProps.placeholder, updateState = constants_1.noop, validationStatus = exports.defaultProps.validationStatus, onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, registerComponentApi, emptyListTemplate, optionLabelRenderer, optionRenderer, valueRenderer, style, dropdownHeight, children, autoFocus = exports.defaultProps.autoFocus, searchable = exports.defaultProps.searchable, multiSelect = exports.defaultProps.multiSelect, label, labelPosition, labelWidth, labelBreak = exports.defaultProps.labelBreak, required = exports.defaultProps.required, inProgress = exports.defaultProps.inProgress, inProgressNotificationMessage = exports.defaultProps.inProgressNotificationMessage, readOnly = false, }, ref) {
94
100
  var _a;
@@ -100,6 +106,7 @@ exports.Select = (0, react_1.forwardRef)(function Select({ id, initialValue, val
100
106
  const [options, setOptions] = (0, react_1.useState)(new Set());
101
107
  const generatedId = (0, react_1.useId)();
102
108
  const inputId = id || generatedId;
109
+ const isInForm = (0, FormContext_1.useIsInsideForm)();
103
110
  // Set initial state based on the initialValue prop
104
111
  (0, react_1.useEffect)(() => {
105
112
  if (initialValue !== undefined) {
@@ -213,7 +220,7 @@ exports.Select = (0, react_1.forwardRef)(function Select({ id, initialValue, val
213
220
  return 0;
214
221
  }, children: [searchable ? ((0, jsx_runtime_1.jsxs)("div", { className: Select_module_scss_1.default.commandInputContainer, children: [(0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "search" }), (0, jsx_runtime_1.jsx)(cmdk_1.CommandInput, { className: (0, classnames_1.default)(Select_module_scss_1.default.commandInput), placeholder: "Search..." })] })) : (
215
222
  // https://github.com/pacocoursey/cmdk/issues/322#issuecomment-2444703817
216
- (0, jsx_runtime_1.jsx)("button", { autoFocus: true, "aria-hidden": "true", className: Select_module_scss_1.default.srOnly })), (0, jsx_runtime_1.jsxs)(cmdk_1.CommandList, { className: Select_module_scss_1.default.commandList, children: [inProgress && ((0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.loading, children: inProgressNotificationMessage })), Array.from(options).map(({ value, label, enabled, keywords }) => ((0, jsx_runtime_1.jsx)(exports.ComboboxOption, { readOnly: readOnly, value: value, label: label, enabled: enabled, keywords: keywords }, value))), !inProgress && (0, jsx_runtime_1.jsx)(cmdk_1.CommandEmpty, { children: emptyListNode })] })] }) }) }) }))] })) : ((0, jsx_runtime_1.jsx)(SimpleSelect, { readOnly: !!readOnly, ref: ref, value: value, options: options, onValueChange: toggleOption, id: inputId, style: style, onFocus: onFocus, onBlur: onBlur, enabled: enabled, validationStatus: validationStatus, triggerRef: setReferenceElement, autoFocus: autoFocus, placeholder: placeholder, height: dropdownHeight, children: renderOptionsOrDefault(options, emptyListNode) })) }), children] }) }) }));
223
+ (0, jsx_runtime_1.jsx)("button", { autoFocus: true, "aria-hidden": "true", className: Select_module_scss_1.default.srOnly })), (0, jsx_runtime_1.jsxs)(cmdk_1.CommandList, { className: Select_module_scss_1.default.commandList, children: [inProgress && ((0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.loading, children: inProgressNotificationMessage })), Array.from(options).map(({ value, label, enabled, keywords }) => ((0, jsx_runtime_1.jsx)(exports.ComboboxOption, { readOnly: readOnly, value: value, label: label, enabled: enabled, keywords: keywords }, value))), !inProgress && (0, jsx_runtime_1.jsx)(cmdk_1.CommandEmpty, { children: emptyListNode })] })] }) }) }) }))] })) : ((0, jsx_runtime_1.jsx)(SimpleSelect, { readOnly: !!readOnly, ref: ref, value: value, options: options, onValueChange: toggleOption, id: inputId, style: style, onFocus: onFocus, onBlur: onBlur, enabled: enabled, validationStatus: validationStatus, triggerRef: setReferenceElement, autoFocus: autoFocus, placeholder: placeholder, height: dropdownHeight, children: renderOptionsOrDefault(options, emptyListNode) }, isInForm ? (value ? `status-${value}` : "status-initial") : undefined)) }), children] }) }) }));
217
224
  });
218
225
  exports.ComboboxOption = (0, react_1.forwardRef)(function Combobox(option, forwardedRef) {
219
226
  const id = (0, react_1.useId)();
@@ -15,7 +15,6 @@ exports.SwitchMd = (0, metadata_helpers_1.createMetadata)({
15
15
  status: "stable",
16
16
  description: "`Switch` enables users to toggle between two states: on and off.",
17
17
  props: {
18
- indeterminate: (0, metadata_helpers_1.dIndeterminate)(Toggle_1.defaultProps.indeterminate),
19
18
  label: (0, metadata_helpers_1.dLabel)(),
20
19
  labelPosition: (0, metadata_helpers_1.dLabelPosition)("end"),
21
20
  labelWidth: (0, metadata_helpers_1.dLabelWidth)(COMP),
@@ -72,5 +71,5 @@ exports.SwitchMd = (0, metadata_helpers_1.createMetadata)({
72
71
  },
73
72
  });
74
73
  exports.switchComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.SwitchMd, ({ node, extractValue, layoutCss, updateState, state, lookupEventHandler, registerComponentApi, }) => {
75
- return ((0, jsx_runtime_1.jsx)(Toggle_1.Toggle, { enabled: extractValue.asOptionalBoolean(node.props.enabled), style: layoutCss, initialValue: extractValue.asOptionalBoolean(node.props.initialValue, Toggle_1.defaultProps.initialValue), value: state === null || state === void 0 ? void 0 : state.value, readOnly: extractValue.asOptionalBoolean(node.props.readOnly), validationStatus: extractValue(node.props.validationStatus), updateState: updateState, onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), label: extractValue(node.props.label), labelPosition: extractValue(node.props.labelPosition), labelWidth: extractValue(node.props.labelWidth), labelBreak: extractValue.asOptionalBoolean(node.props.labelBreak), required: extractValue.asOptionalBoolean(node.props.required), variant: "switch", registerComponentApi: registerComponentApi }));
74
+ return ((0, jsx_runtime_1.jsx)(Toggle_1.Toggle, { enabled: extractValue.asOptionalBoolean(node.props.enabled), style: layoutCss, initialValue: extractValue.asOptionalBoolean(node.props.initialValue, Toggle_1.defaultProps.initialValue), value: state === null || state === void 0 ? void 0 : state.value, readOnly: extractValue.asOptionalBoolean(node.props.readOnly), validationStatus: extractValue(node.props.validationStatus), updateState: updateState, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), label: extractValue(node.props.label), labelPosition: extractValue(node.props.labelPosition), labelWidth: extractValue(node.props.labelWidth), labelBreak: extractValue.asOptionalBoolean(node.props.labelBreak), required: extractValue.asOptionalBoolean(node.props.required), variant: "switch", registerComponentApi: registerComponentApi }));
76
75
  });
@@ -79,7 +79,7 @@ exports.TextBox = (0, react_1.forwardRef)(function TextBox({ id, type = exports.
79
79
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
80
80
  }, 0);
81
81
  }
82
- }, [autoFocus]);
82
+ }, [autoFocus, inputRef.current]);
83
83
  // --- NOTE: This is a workaround for the jumping caret issue.
84
84
  // --- Local state can sync up values that can get set asynchronously outside the component.
85
85
  const [localValue, setLocalValue] = react_2.default.useState(value);
@@ -26,6 +26,9 @@ var ErrCodes;
26
26
  ErrCodes["expTagNameAfterNamespace"] = "U014";
27
27
  ErrCodes["expCloseStartWithName"] = "U015";
28
28
  ErrCodes["expAttrNameAfterNamespace"] = "U016";
29
+ ErrCodes["unexpectedCloseTag"] = "U017";
30
+ ErrCodes["expTagNameAfterCloseStart"] = "U019";
31
+ ErrCodes["expAttrNameBeforeEq"] = "U020";
29
32
  ErrCodes["invalidChar"] = "W001";
30
33
  ErrCodes["untermStr"] = "W002";
31
34
  ErrCodes["untermComment"] = "W007";
@@ -33,6 +36,11 @@ var ErrCodes;
33
36
  ErrCodes["untermScript"] = "W009";
34
37
  })(ErrCodes || (exports.ErrCodes = ErrCodes = {}));
35
38
  exports.DIAGS = {
39
+ unexpectedCloseTag: {
40
+ category: DiagnosticCategory.Error,
41
+ code: ErrCodes.unexpectedCloseTag,
42
+ message: "Read '</', but there's no opening tag to close. You have too many closing tags.",
43
+ },
36
44
  expCloseStartWithName: function (openTagName) {
37
45
  return {
38
46
  category: DiagnosticCategory.Error,
@@ -108,16 +116,30 @@ exports.DIAGS = {
108
116
  code: ErrCodes.expAttrName,
109
117
  message: `An attribute name expected.`,
110
118
  },
111
- expAttrNameAfterNamespace: {
119
+ expAttrNameAfterNamespace: function (namespaceName) {
120
+ return {
121
+ category: DiagnosticCategory.Error,
122
+ code: ErrCodes.expAttrNameAfterNamespace,
123
+ message: `An attribute name expected after namespace '${namespaceName}'.`,
124
+ };
125
+ },
126
+ expTagNameAfterNamespace: function (namespaceName) {
127
+ return {
128
+ category: DiagnosticCategory.Error,
129
+ code: ErrCodes.expTagNameAfterNamespace,
130
+ message: `A tag name expected after namespace '${namespaceName}'.`,
131
+ };
132
+ },
133
+ expTagNameAfterCloseStart: {
112
134
  category: DiagnosticCategory.Error,
113
- code: ErrCodes.expAttrNameAfterNamespace,
114
- message: `An attribute name expected after a namespaces.`,
135
+ code: ErrCodes.expTagNameAfterCloseStart,
136
+ message: "Expected tag name after '</'.",
115
137
  },
116
- expTagNameAfterNamespace: {
138
+ expAttrNameBeforeEq: {
117
139
  category: DiagnosticCategory.Error,
118
- code: ErrCodes.expTagNameAfterNamespace,
119
- message: `A tag name expected after a namespaces.`,
120
- }
140
+ code: ErrCodes.expAttrNameBeforeEq,
141
+ message: "Expected attribute name before '='.",
142
+ },
121
143
  };
122
144
  function diagnosticCategoryName(d, lowerCase = true) {
123
145
  const name = DiagnosticCategory[d.category];
@@ -73,7 +73,7 @@ function parseXmlUiMarkup(text) {
73
73
  break;
74
74
  default:
75
75
  const errNode = errNodeUntil(RECOVER_FILE);
76
- errorAt(diagnostics_1.DIAGS.expTagOpen, errNode.pos, errNode.end);
76
+ errorAt(diagnostics_1.DIAGS.unexpectedCloseTag, errNode.pos, errNode.end);
77
77
  break;
78
78
  }
79
79
  }
@@ -152,10 +152,11 @@ function parseXmlUiMarkup(text) {
152
152
  }
153
153
  function parseOpeningTagName() {
154
154
  startNode();
155
- bump(syntax_kind_1.SyntaxKind.Identifier);
155
+ const identNode = bump(syntax_kind_1.SyntaxKind.Identifier);
156
156
  if (eat(syntax_kind_1.SyntaxKind.Colon) && !eat(syntax_kind_1.SyntaxKind.Identifier)) {
157
157
  const nameNodeWithColon = completeNode(syntax_kind_1.SyntaxKind.TagNameNode);
158
- errorAt(diagnostics_1.DIAGS.expTagNameAfterNamespace, nameNodeWithColon.pos, nameNodeWithColon.end);
158
+ const namespaceName = getText(identNode);
159
+ errorAt(diagnostics_1.DIAGS.expTagNameAfterNamespace(namespaceName), nameNodeWithColon.pos, nameNodeWithColon.end);
159
160
  errNodeUntil([syntax_kind_1.SyntaxKind.Identifier, ...RECOVER_OPEN_TAG]);
160
161
  return { node: nameNodeWithColon, errInName: true };
161
162
  }
@@ -196,7 +197,12 @@ function parseXmlUiMarkup(text) {
196
197
  else {
197
198
  const errNode = errNodeUntil(RECOVER_ATTR);
198
199
  if (errNode) {
199
- errorAt(diagnostics_1.DIAGS.expAttrName, errNode.pos, errNode.end);
200
+ if (at(syntax_kind_1.SyntaxKind.Equal)) {
201
+ errorAt(diagnostics_1.DIAGS.expAttrNameBeforeEq, errNode.pos, errNode.end);
202
+ }
203
+ else {
204
+ errorAt(diagnostics_1.DIAGS.expAttrName, errNode.pos, errNode.end);
205
+ }
200
206
  completeNode(syntax_kind_1.SyntaxKind.AttributeNode);
201
207
  }
202
208
  else {
@@ -229,16 +235,17 @@ function parseXmlUiMarkup(text) {
229
235
  nameIdent = bump(syntax_kind_1.SyntaxKind.Identifier);
230
236
  }
231
237
  else {
238
+ const namespaceName = getText(nameIdent);
232
239
  const errNode = errNodeUntil([
233
240
  syntax_kind_1.SyntaxKind.Equal,
234
241
  syntax_kind_1.SyntaxKind.Identifier,
235
242
  ...RECOVER_OPEN_TAG,
236
243
  ]);
237
244
  if (errNode) {
238
- errorAt(diagnostics_1.DIAGS.expAttrNameAfterNamespace, errNode.pos, errNode.end);
245
+ errorAt(diagnostics_1.DIAGS.expAttrNameAfterNamespace(namespaceName), errNode.pos, errNode.end);
239
246
  }
240
247
  else {
241
- error(diagnostics_1.DIAGS.expAttrNameAfterNamespace);
248
+ error(diagnostics_1.DIAGS.expAttrNameAfterNamespace(namespaceName));
242
249
  }
243
250
  }
244
251
  }
@@ -261,10 +268,10 @@ function parseXmlUiMarkup(text) {
261
268
  else {
262
269
  const errNode = errNodeUntil(RECOVER_CLOSE_TAG);
263
270
  if (errNode) {
264
- errorAt(diagnostics_1.DIAGS.expTagName, errNode.pos, errNode.end);
271
+ errorAt(diagnostics_1.DIAGS.expTagNameAfterCloseStart, errNode.pos, errNode.end);
265
272
  }
266
273
  else {
267
- error(diagnostics_1.DIAGS.expTagName);
274
+ error(diagnostics_1.DIAGS.expTagNameAfterCloseStart);
268
275
  }
269
276
  }
270
277
  if (!eat(syntax_kind_1.SyntaxKind.NodeEnd)) {
@@ -282,10 +289,10 @@ function parseXmlUiMarkup(text) {
282
289
  }
283
290
  function parseClosingTagName() {
284
291
  startNode();
285
- bump(syntax_kind_1.SyntaxKind.Identifier);
292
+ const identNode = bump(syntax_kind_1.SyntaxKind.Identifier);
286
293
  if (eat(syntax_kind_1.SyntaxKind.Colon) && !eat(syntax_kind_1.SyntaxKind.Identifier)) {
287
294
  const nameNodeWithColon = completeNode(syntax_kind_1.SyntaxKind.TagNameNode);
288
- errorAt(diagnostics_1.DIAGS.expTagNameAfterNamespace, nameNodeWithColon.pos, nameNodeWithColon.end);
295
+ errorAt(diagnostics_1.DIAGS.expTagNameAfterNamespace(getText(identNode)), nameNodeWithColon.pos, nameNodeWithColon.end);
289
296
  errNodeUntil(RECOVER_OPEN_TAG);
290
297
  return nameNodeWithColon;
291
298
  }
@@ -621,6 +621,9 @@ declare enum ErrCodes {
621
621
  expTagNameAfterNamespace = "U014",
622
622
  expCloseStartWithName = "U015",
623
623
  expAttrNameAfterNamespace = "U016",
624
+ unexpectedCloseTag = "U017",
625
+ expTagNameAfterCloseStart = "U019",
626
+ expAttrNameBeforeEq = "U020",
624
627
  invalidChar = "W001",
625
628
  untermStr = "W002",
626
629
  untermComment = "W007",