xmlui 0.9.63 → 0.9.65

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 (44) hide show
  1. package/dist/lib/{apiInterceptorWorker-DYPN1T0q.mjs → apiInterceptorWorker-COjte0L0.mjs} +1 -1
  2. package/dist/lib/{index-BcEgj7aN.mjs → index-E-Ytu3U3.mjs} +27231 -16682
  3. package/dist/lib/index.css +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-DJM8orNd.mjs → metadata-utils-CeJek2aP.mjs} +1 -1
  7. package/dist/lib/{server-common-D0VA8gIv.mjs → server-common-Dtnes4sR.mjs} +79 -54
  8. package/dist/lib/{transform-BdB0APqE.mjs → transform--lQ60cbR.mjs} +61 -88
  9. package/dist/lib/xmlui-parser.d.ts +50 -2
  10. package/dist/lib/xmlui-parser.mjs +2 -2
  11. package/dist/lib/{xmlui-serializer-COAfRndx.mjs → xmlui-serializer-B1QY_Hg9.mjs} +11 -3
  12. package/dist/lib/xmlui.d.ts +52 -3
  13. package/dist/lib/xmlui.mjs +2 -2
  14. package/dist/metadata/{apiInterceptorWorker-PHZNbofw.mjs → apiInterceptorWorker-BK3aQR7T.mjs} +1 -1
  15. package/dist/metadata/{collectedComponentMetadata-BGIWhaXW.mjs → collectedComponentMetadata-yjl6u0V8.mjs} +25697 -16431
  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 +149 -120
  19. package/dist/scripts/package.json +6 -1
  20. package/dist/scripts/src/components/Charts/BarChart/BarChartNative.js +6 -1
  21. package/dist/scripts/src/components/Charts/LineChart/LineChartNative.js +6 -1
  22. package/dist/scripts/src/components/CodeBlock/highlight-code.js +34 -13
  23. package/dist/scripts/src/components/ComponentProvider.js +4 -0
  24. package/dist/scripts/src/components/FormItem/FormItem.js +1 -0
  25. package/dist/scripts/src/components/FormSection/FormSection.js +42 -2
  26. package/dist/scripts/src/components/Icon/TableDeleteColumnIcon.js +7 -0
  27. package/dist/scripts/src/components/Icon/TableDeleteRowIcon.js +7 -0
  28. package/dist/scripts/src/components/Icon/TableInsertColumnIcon.js +7 -0
  29. package/dist/scripts/src/components/Icon/TableInsertRowIcon.js +7 -0
  30. package/dist/scripts/src/components/IconProvider.js +11 -0
  31. package/dist/scripts/src/components/Markdown/MarkdownNative.js +3 -3
  32. package/dist/scripts/src/components/Markdown/utils.js +13 -8
  33. package/dist/scripts/src/components/NavPanel/NavPanelNative.js +4 -0
  34. package/dist/scripts/src/components/NestedApp/AppWithCodeViewNative.js +3 -3
  35. package/dist/scripts/src/components/NestedApp/NestedAppNative.js +4 -3
  36. package/dist/scripts/src/components/NestedApp/defaultProps.js +1 -0
  37. package/dist/scripts/src/components/RadioGroup/RadioGroup.js +4 -6
  38. package/dist/scripts/src/components/TableEditor/TableEditor.js +183 -0
  39. package/dist/scripts/src/components/TableEditor/TableEditorNative.js +8 -0
  40. package/dist/scripts/src/parsers/xmlui-parser/transform.js +0 -31
  41. package/dist/standalone/xmlui-standalone.es.d.ts +52 -3
  42. package/dist/standalone/xmlui-standalone.umd.js +269 -237
  43. package/package.json +6 -1
  44. package/dist/scripts/src/components-core/theming/themes/solid.js +0 -16
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.editorComponentRenderer = exports.TableEditorMd = void 0;
40
+ const jsx_runtime_1 = require("react/jsx-runtime");
41
+ const react_1 = __importStar(require("react"));
42
+ const react_2 = require("@tiptap/react");
43
+ const starter_kit_1 = __importDefault(require("@tiptap/starter-kit"));
44
+ const extension_table_1 = __importDefault(require("@tiptap/extension-table"));
45
+ const extension_table_row_1 = __importDefault(require("@tiptap/extension-table-row"));
46
+ const extension_table_cell_1 = __importDefault(require("@tiptap/extension-table-cell"));
47
+ const extension_table_header_1 = __importDefault(require("@tiptap/extension-table-header"));
48
+ const ButtonNative_1 = require("../Button/ButtonNative");
49
+ const StackNative_1 = require("../Stack/StackNative");
50
+ const TableEditorNative_1 = require("./TableEditorNative");
51
+ const turndown_1 = __importDefault(require("turndown"));
52
+ const metadata_helpers_1 = require("../metadata-helpers");
53
+ const renderers_1 = require("../../components-core/renderers");
54
+ const abstractions_1 = require("../abstractions");
55
+ const IconNative_1 = __importDefault(require("../Icon/IconNative"));
56
+ const TableEditor_module_scss_1 = __importDefault(require("./TableEditor.module.scss"));
57
+ const themeVars_1 = require("../../components-core/theming/themeVars");
58
+ const TableEditor = (0, react_1.forwardRef)(function TableEditor({ registerComponentApi, themeColor = "primary", variant = "solid", size = "sm", onDidChange = () => { }, }, ref) {
59
+ const editor = (0, react_2.useEditor)({
60
+ extensions: [
61
+ starter_kit_1.default,
62
+ extension_table_1.default.configure({ resizable: true }),
63
+ extension_table_row_1.default,
64
+ extension_table_header_1.default,
65
+ extension_table_cell_1.default,
66
+ ],
67
+ content: `
68
+ <table>
69
+ <thead>
70
+ <tr>
71
+ <th>Fruit</th>
72
+ <th>Color</th>
73
+ </tr>
74
+ </thead>
75
+ <tbody>
76
+ <tr>
77
+ <td>Apple</td>
78
+ <td>Red</td>
79
+ </tr>
80
+ <tr>
81
+ <td>Banana</td>
82
+ <td>Yellow</td>
83
+ </tr>
84
+ </tbody>
85
+ </table>
86
+ `,
87
+ });
88
+ const turndownService = new turndown_1.default();
89
+ turndownService.addRule("table", {
90
+ filter: "table",
91
+ replacement: function (content, node) {
92
+ let rows = [];
93
+ for (let row of node.querySelectorAll("tr")) {
94
+ let cells = Array.from(row.children).map((cell) => { var _a, _b; return (_b = (_a = cell.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : ""; });
95
+ rows.push("| " + cells.join(" | ") + " |");
96
+ }
97
+ if (rows.length > 1) {
98
+ // Add a separator after the header row
99
+ const headerSep = "| " +
100
+ rows[0]
101
+ .split("|")
102
+ .slice(1, -1)
103
+ .map(() => "---")
104
+ .join(" | ") +
105
+ " |";
106
+ rows.splice(1, 0, headerSep);
107
+ }
108
+ return rows.join("\n") + "\n";
109
+ },
110
+ });
111
+ (0, react_1.useImperativeHandle)(ref, () => ({
112
+ getMarkdownSource: () => { var _a, _b; return turndownService.turndown((_b = (_a = editor === null || editor === void 0 ? void 0 : editor.getHTML) === null || _a === void 0 ? void 0 : _a.call(editor)) !== null && _b !== void 0 ? _b : ""); },
113
+ getHtmlSource: () => { var _a, _b; return (_b = (_a = editor === null || editor === void 0 ? void 0 : editor.getHTML) === null || _a === void 0 ? void 0 : _a.call(editor)) !== null && _b !== void 0 ? _b : ""; },
114
+ }), [editor]);
115
+ react_1.default.useEffect(() => {
116
+ if (registerComponentApi && editor) {
117
+ registerComponentApi({
118
+ getHtmlSource: () => editor.getHTML(),
119
+ getMarkdownSource: () => turndownService.turndown(editor.getHTML()),
120
+ });
121
+ }
122
+ }, [registerComponentApi, editor]);
123
+ // Emit onDidChange whenever the editor content changes
124
+ react_1.default.useEffect(() => {
125
+ if (!editor)
126
+ return;
127
+ const handler = () => {
128
+ const html = editor.getHTML();
129
+ const markdown = turndownService.turndown(html);
130
+ //console.log("[TableEditor] onDidChange about to fire", { html, markdown, onDidChange });
131
+ onDidChange({ html, markdown });
132
+ };
133
+ editor.on("update", handler);
134
+ // Emit once on mount
135
+ handler();
136
+ return () => {
137
+ editor.off("update", handler);
138
+ };
139
+ }, [editor, onDidChange]);
140
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "table-editor-root", children: [(0, jsx_runtime_1.jsx)("div", { className: "button-stack", children: (0, jsx_runtime_1.jsxs)(StackNative_1.Stack, { orientation: "horizontal", children: [(0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => editor && editor.commands.addRowAfter(), disabled: !editor, themeColor: themeColor, variant: variant, size: size, orientation: "horizontal", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "table-insert-row", "aria-hidden": true }), children: "Insert Row" }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => editor && editor.commands.deleteRow(), disabled: !editor, themeColor: themeColor, variant: variant, size: size, orientation: "horizontal", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "table-delete-row", "aria-hidden": true }), children: "Delete Row" }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => editor && editor.commands.addColumnAfter(), disabled: !editor, themeColor: themeColor, variant: variant, size: size, orientation: "horizontal", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "table-insert-column", "aria-hidden": true }), children: "Insert Column" }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => editor && editor.commands.deleteColumn(), disabled: !editor, themeColor: themeColor, variant: variant, size: size, orientation: "horizontal", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "table-delete-column", "aria-hidden": true }), children: "Delete Column" })] }) }), (0, jsx_runtime_1.jsx)(TableEditorNative_1.TableEditorNative, { editor: editor, className: TableEditor_module_scss_1.default.editor })] }));
141
+ });
142
+ exports.default = TableEditor;
143
+ // Create metadata for TableEditor that defines allowed props
144
+ exports.TableEditorMd = (0, metadata_helpers_1.createMetadata)({
145
+ description: "`TableEditor` provides an interactive table editing interface with controls for adding and deleting rows and columns. It supports theme customization and exports table data in HTML and Markdown formats.",
146
+ status: "stable",
147
+ props: {
148
+ themeColor: {
149
+ description: "Sets the color scheme for all editor buttons.",
150
+ isRequired: false,
151
+ type: "string",
152
+ availableValues: abstractions_1.buttonThemeMd,
153
+ defaultValue: "primary",
154
+ },
155
+ variant: {
156
+ description: "Sets the visual style for all editor buttons.",
157
+ isRequired: false,
158
+ type: "string",
159
+ availableValues: abstractions_1.buttonVariantMd,
160
+ defaultValue: "solid",
161
+ },
162
+ size: {
163
+ description: "Sets the size for all editor buttons.",
164
+ isRequired: false,
165
+ type: "string",
166
+ availableValues: abstractions_1.sizeMd,
167
+ defaultValue: "sm",
168
+ },
169
+ },
170
+ events: {
171
+ didChange: {
172
+ description: "Fired whenever the table content changes. Payload: { html, markdown }.",
173
+ isRequired: false,
174
+ type: "function",
175
+ },
176
+ },
177
+ themeVars: (0, themeVars_1.parseScssVar)(TableEditor_module_scss_1.default.themeVars),
178
+ });
179
+ exports.editorComponentRenderer = (0, renderers_1.createComponentRenderer)("TableEditor", exports.TableEditorMd, ({ node, extractValue, registerComponentApi, lookupEventHandler }) => {
180
+ const handler = lookupEventHandler === null || lookupEventHandler === void 0 ? void 0 : lookupEventHandler("didChange");
181
+ //console.log("[TableEditor renderer] didChange handler:", handler);
182
+ return ((0, jsx_runtime_1.jsx)(TableEditor, { themeColor: extractValue.asOptionalString(node.props.themeColor), variant: extractValue.asOptionalString(node.props.variant), size: extractValue.asOptionalString(node.props.size), registerComponentApi: registerComponentApi, onDidChange: handler }));
183
+ });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TableEditorNative = TableEditorNative;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@tiptap/react");
6
+ function TableEditorNative({ editor, className }) {
7
+ return ((0, jsx_runtime_1.jsx)("div", { className: className, children: (0, jsx_runtime_1.jsx)(react_1.EditorContent, { editor: editor }) }));
8
+ }
@@ -48,13 +48,6 @@ function nodeToComponentDef(node, originalGetText, fileId) {
48
48
  }
49
49
  let component = {
50
50
  type: name,
51
- debug: {
52
- source: {
53
- start: node.start,
54
- end: node.end,
55
- fileId,
56
- },
57
- },
58
51
  };
59
52
  // --- Done
60
53
  collectTraits(usesStack, component, node);
@@ -67,13 +60,6 @@ function nodeToComponentDef(node, originalGetText, fileId) {
67
60
  }
68
61
  let component = {
69
62
  type: name,
70
- debug: {
71
- source: {
72
- start: node.start,
73
- end: node.end,
74
- fileId,
75
- },
76
- },
77
63
  };
78
64
  // --- Done
79
65
  collectTraits(usesStack, component, node);
@@ -147,13 +133,6 @@ function nodeToComponentDef(node, originalGetText, fileId) {
147
133
  const component = {
148
134
  name: compoundName.value,
149
135
  component: nestedComponent,
150
- debug: {
151
- source: {
152
- start: node.start,
153
- end: node.end,
154
- fileId,
155
- },
156
- },
157
136
  };
158
137
  if (api) {
159
138
  component.api = api;
@@ -164,13 +143,6 @@ function nodeToComponentDef(node, originalGetText, fileId) {
164
143
  if (codeBehind) {
165
144
  component.codeBehind = codeBehind.value;
166
145
  }
167
- nestedComponent.debug = {
168
- source: {
169
- start: element.start,
170
- end: element.end,
171
- fileId,
172
- },
173
- };
174
146
  const nodeClone = withNewChildNodes(node, nonVarHelperNodes);
175
147
  collectTraits(usesStack, component, nodeClone);
176
148
  return component;
@@ -1041,7 +1013,6 @@ function desugarKeyOnlyAttrs(attrs) {
1041
1013
  }
1042
1014
  }
1043
1015
  function addToNamespaces(namespaceStack, comp, nsKey, value) {
1044
- var _a;
1045
1016
  let nsCommaSeparated = value.split(":");
1046
1017
  if (nsCommaSeparated.length > 2) {
1047
1018
  return reportError("T028", value, "Namespace cannot contain multiple ':' (colon).");
@@ -1072,8 +1043,6 @@ function addToNamespaces(namespaceStack, comp, nsKey, value) {
1072
1043
  return reportError("T025", nsKey);
1073
1044
  }
1074
1045
  compNamespaces.set(nsKey, nsValue);
1075
- (_a = comp.namespaces) !== null && _a !== void 0 ? _a : (comp.namespaces = {});
1076
- comp.namespaces[nsKey] = nsValue;
1077
1046
  }
1078
1047
  function getTopLvlElement(node, getText) {
1079
1048
  // --- Check that the nodes contains exactly only a single component root element before the EoF token
@@ -326,19 +326,67 @@ declare interface ComponentDef<TMd extends ComponentMetadata = ComponentMetadata
326
326
  contextVars?: Record<keyof TMd["contextVars"], string>;
327
327
  }
328
328
 
329
+ /**
330
+ * This interface represents the core properties of a component definition
331
+ * (independent of component metadata).
332
+ */
329
333
  declare interface ComponentDefCore {
334
+ /**
335
+ * The type discriminator field of the component; it defines the unique ID of the component type.
336
+ */
330
337
  type: string;
338
+ /**
339
+ * Unique identifier of a component-like object
340
+ */
331
341
  uid?: string;
342
+ /**
343
+ * An optional identifier we use for e2e tests; it does not influence the rendering of a component.
344
+ */
332
345
  testId?: string;
333
- namespaces?: Record<string, string>;
346
+ /**
347
+ * Though components manage their state internally, the app logic may require user
348
+ * state management. Components may have user *variables*, which the UI logic uses to
349
+ * manage the application state. This property holds the variables (name and value
350
+ * pairs) associated with this component definition.
351
+ */
334
352
  vars?: Record<string, any>;
353
+ /**
354
+ * Each component may have child components to constitute a hierarchy of components.
355
+ * This property holds the definition of these nested children.
356
+ */
335
357
  children?: ComponentDef[];
358
+ /**
359
+ * Components may have slots that can be filled with other components. This property
360
+ * holds the contents of the slots.
361
+ */
336
362
  slots?: Record<string, ComponentDef[]>;
363
+ /**
364
+ * This property is evaluated to a Boolean value during run time. When this value is
365
+ * `true`, the component with its children chain is rendered; otherwise, the entire
366
+ * component hierarchy is omitted from the rendered tree.
367
+ */
337
368
  when?: string | boolean;
369
+ /**
370
+ * Some components work with data obtained asynchronously. Fetching this data requires
371
+ * some state management handling the complexity (including error handling) of data
372
+ * access. A *loader* is responsible for managing this logic. This property holds the
373
+ * loaders associated with this component definition.
374
+ */
338
375
  loaders?: ComponentDef[];
376
+ /**
377
+ * Components may have functions that are used to perform some logic. This property
378
+ * holds the functions (name and function body) associated with this component
379
+ * definition.
380
+ */
339
381
  functions?: Record<string, any>;
382
+ /**
383
+ * Components managing state through variables or loaders are wrapped with containers
384
+ * responsible for this job. Just as components, containers form a hierarchy. While
385
+ * working with this hierarchy, parent components may flow state values (key and value
386
+ * pairs) to their child containers. This property holds the name of state values to
387
+ * flow down to the direct child containers.
388
+ */
340
389
  uses?: string[];
341
- debug?: Record<string, any>;
342
390
  }
343
391
 
344
392
  declare type ComponentExtension = ComponentRendererDef | CompoundComponentDef;
@@ -881,7 +929,7 @@ declare interface NavHierarchyNode {
881
929
  lastLink?: boolean;
882
930
  }
883
931
 
884
- declare function NestedApp({ api, app, components, config, activeTheme, activeTone, title, height, allowPlaygroundPopup, popOutUrl, withFrame, style, refVersion, }: NestedAppProps): JSX_2.Element;
932
+ declare function NestedApp({ api, app, components, config, activeTheme, activeTone, title, height, allowPlaygroundPopup, popOutUrl, withFrame, noHeader, style, refVersion, }: NestedAppProps): JSX_2.Element;
885
933
 
886
934
  declare type NestedAppProps = {
887
935
  api?: any;
@@ -895,6 +943,7 @@ declare type NestedAppProps = {
895
943
  allowPlaygroundPopup?: boolean;
896
944
  popOutUrl?: string;
897
945
  withFrame?: boolean;
946
+ noHeader?: boolean;
898
947
  style?: CSSProperties;
899
948
  splitView?: boolean;
900
949
  refVersion?: number;