@xmachines/json-render-solid 0.19.0-xm.3 → 0.20.0-xm.1
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.
- package/README.md +2 -0
- package/dist/{chunk-XTSB6FIM.mjs → chunk-ZTWTJIEL.mjs} +6 -3
- package/dist/chunk-ZTWTJIEL.mjs.map +1 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +81 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -38
- package/dist/index.mjs.map +1 -1
- package/dist/schema.d.mts +22 -2
- package/dist/schema.d.ts +22 -2
- package/dist/schema.js +5 -2
- package/dist/schema.js.map +1 -1
- package/dist/schema.mjs +1 -1
- package/package.json +5 -5
- package/dist/chunk-XTSB6FIM.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -227,6 +227,8 @@ await stream.send("Build me a dashboard");
|
|
|
227
227
|
|
|
228
228
|
## Differences from `@xmachines/json-render-react`
|
|
229
229
|
|
|
230
|
+
Nested lists can set `repeat.statePath` to `{ "$item": "field" }` to iterate an array on the enclosing repeat item.
|
|
231
|
+
|
|
230
232
|
Most APIs are intentionally aligned, but there are runtime behavior differences due to Solid:
|
|
231
233
|
|
|
232
234
|
- Solid components run once, then update via signals.
|
|
@@ -16,7 +16,9 @@ var schema = defineSchema(
|
|
|
16
16
|
/** Child element keys (flat reference) */
|
|
17
17
|
children: s.array(s.string()),
|
|
18
18
|
/** Visibility condition */
|
|
19
|
-
visible: s.any()
|
|
19
|
+
visible: { ...s.any(), ...s.optional() },
|
|
20
|
+
/** Repeat children from a state array */
|
|
21
|
+
repeat: { ...s.any(), ...s.optional() }
|
|
20
22
|
})
|
|
21
23
|
)
|
|
22
24
|
}),
|
|
@@ -65,12 +67,13 @@ var schema = defineSchema(
|
|
|
65
67
|
// Element integrity
|
|
66
68
|
"CRITICAL INTEGRITY CHECK: Before outputting ANY element that references children, you MUST have already output (or will output) each child as its own element. If an element has children: ['a', 'b'], then elements 'a' and 'b' MUST exist. A missing child element causes that entire branch of the UI to be invisible.",
|
|
67
69
|
"SELF-CHECK: After generating all elements, mentally walk the tree from root. Every key in every children array must resolve to a defined element. If you find a gap, output the missing element immediately.",
|
|
70
|
+
'REQUIRED FIELDS: Every element MUST include a "children" array. Leaf elements (text, badges, inputs, images) use an empty array: "children": []. Omitting "children" fails validation.',
|
|
68
71
|
// Field placement
|
|
69
72
|
'CRITICAL: The "visible" field goes on the ELEMENT object, NOT inside "props". Correct: {"type":"<ComponentName>","props":{},"visible":{"$state":"/tab","eq":"home"},"children":[...]}.',
|
|
70
73
|
'CRITICAL: The "on" field goes on the ELEMENT object, NOT inside "props". Use on.press, on.change, on.submit etc. NEVER put action/actionParams inside props.',
|
|
71
74
|
// State and data
|
|
72
75
|
"When the user asks for a UI that displays data (e.g. blog posts, products, users), ALWAYS include a state field with realistic sample data. The state field is a top-level field on the spec (sibling of root/elements).",
|
|
73
|
-
'When building repeating content backed by a state array (e.g. posts, products, items), use the "repeat" field on a container element. Example: { "type": "<ContainerComponent>", "props": {}, "repeat": { "statePath": "/posts", "key": "id" }, "children": ["post-card"] }. Replace <ContainerComponent> with an appropriate component from the AVAILABLE COMPONENTS list. Inside repeated children, use { "$item": "field" } to read a field from the current item, and { "$index": true } for the current array index. For two-way binding to an item field use { "$bindItem": "completed" }. Do NOT hardcode individual elements for each array item.',
|
|
76
|
+
'When building repeating content backed by a state array (e.g. posts, products, items), use the "repeat" field on a container element. Example: { "type": "<ContainerComponent>", "props": {}, "repeat": { "statePath": "/posts", "key": "id" }, "children": ["post-card"] }. For a nested list stored on the enclosing item, use "repeat": { "statePath": { "$item": "comments" }, "key": "id" }. The $item statePath form is valid only inside another repeat. Replace <ContainerComponent> with an appropriate component from the AVAILABLE COMPONENTS list. Inside repeated children, use { "$item": "field" } to read a field from the current item, and { "$index": true } for the current array index. For two-way binding to an item field use { "$bindItem": "completed" }. Do NOT hardcode individual elements for each array item.',
|
|
74
77
|
// Design quality
|
|
75
78
|
"Design with visual hierarchy: use container components to group content, heading components for section titles, proper spacing, and status indicators. ONLY use components from the AVAILABLE COMPONENTS list.",
|
|
76
79
|
"For data-rich UIs, use multi-column layout components if available. For forms and single-column content, use vertical layout components. ONLY use components from the AVAILABLE COMPONENTS list.",
|
|
@@ -84,4 +87,4 @@ export {
|
|
|
84
87
|
schema,
|
|
85
88
|
elementTreeSchema
|
|
86
89
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
90
|
+
//# sourceMappingURL=chunk-ZTWTJIEL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema.ts"],"sourcesContent":["import { defineSchema } from \"@xmachines/json-render-core\";\n\n/**\n * The schema for @xmachines/json-render-solid\n *\n * Defines:\n * - Spec: A flat tree of elements with keys, types, props, and children references\n * - Catalog: Components with props schemas, and optional actions\n */\nexport const schema = defineSchema(\n (s) => ({\n // What the AI-generated SPEC looks like\n spec: s.object({\n /** Root element key */\n root: s.string(),\n /** Flat map of elements by key */\n elements: s.record(\n s.object({\n /** Component type from catalog */\n type: s.ref(\"catalog.components\"),\n /** Component props */\n props: s.propsOf(\"catalog.components\"),\n /** Child element keys (flat reference) */\n children: s.array(s.string()),\n /** Visibility condition */\n visible: { ...s.any(), ...s.optional() },\n /** Repeat children from a state array */\n repeat: { ...s.any(), ...s.optional() },\n }),\n ),\n }),\n\n // What the CATALOG must provide\n catalog: s.object({\n /** Component definitions */\n components: s.map({\n /** Zod schema for component props */\n props: s.zod(),\n /** Slots for this component. Use ['default'] for children, or named slots like ['header', 'footer'] */\n slots: s.array(s.string()),\n /** Description for AI generation hints */\n description: s.string(),\n /** Example prop values used in prompt examples (auto-generated from Zod schema if omitted) */\n example: s.any(),\n }),\n /** Action definitions (optional) */\n actions: s.map({\n /** Zod schema for action params */\n params: s.zod(),\n /** Description for AI generation hints */\n description: s.string(),\n }),\n }),\n }),\n {\n builtInActions: [\n {\n name: \"setState\",\n description:\n \"Update a value in the state model at the given statePath. Params: { statePath: string, value: any }\",\n },\n {\n name: \"pushState\",\n description:\n 'Append an item to an array in state. Params: { statePath: string, value: any, clearStatePath?: string }. Value can contain {\"$state\":\"/path\"} refs and \"$id\" for auto IDs.',\n },\n {\n name: \"removeState\",\n description:\n \"Remove an item from an array in state by index. Params: { statePath: string, index: number }\",\n },\n {\n name: \"validateForm\",\n description:\n \"Validate all registered form fields and write the result to state. Params: { statePath?: string }. Defaults to /formValidation. Result: { valid: boolean, errors: Record<string, string[]> }.\",\n },\n ],\n defaultRules: [\n // Element integrity\n \"CRITICAL INTEGRITY CHECK: Before outputting ANY element that references children, you MUST have already output (or will output) each child as its own element. If an element has children: ['a', 'b'], then elements 'a' and 'b' MUST exist. A missing child element causes that entire branch of the UI to be invisible.\",\n \"SELF-CHECK: After generating all elements, mentally walk the tree from root. Every key in every children array must resolve to a defined element. If you find a gap, output the missing element immediately.\",\n 'REQUIRED FIELDS: Every element MUST include a \"children\" array. Leaf elements (text, badges, inputs, images) use an empty array: \"children\": []. Omitting \"children\" fails validation.',\n\n // Field placement\n 'CRITICAL: The \"visible\" field goes on the ELEMENT object, NOT inside \"props\". Correct: {\"type\":\"<ComponentName>\",\"props\":{},\"visible\":{\"$state\":\"/tab\",\"eq\":\"home\"},\"children\":[...]}.',\n 'CRITICAL: The \"on\" field goes on the ELEMENT object, NOT inside \"props\". Use on.press, on.change, on.submit etc. NEVER put action/actionParams inside props.',\n\n // State and data\n \"When the user asks for a UI that displays data (e.g. blog posts, products, users), ALWAYS include a state field with realistic sample data. The state field is a top-level field on the spec (sibling of root/elements).\",\n 'When building repeating content backed by a state array (e.g. posts, products, items), use the \"repeat\" field on a container element. Example: { \"type\": \"<ContainerComponent>\", \"props\": {}, \"repeat\": { \"statePath\": \"/posts\", \"key\": \"id\" }, \"children\": [\"post-card\"] }. For a nested list stored on the enclosing item, use \"repeat\": { \"statePath\": { \"$item\": \"comments\" }, \"key\": \"id\" }. The $item statePath form is valid only inside another repeat. Replace <ContainerComponent> with an appropriate component from the AVAILABLE COMPONENTS list. Inside repeated children, use { \"$item\": \"field\" } to read a field from the current item, and { \"$index\": true } for the current array index. For two-way binding to an item field use { \"$bindItem\": \"completed\" }. Do NOT hardcode individual elements for each array item.',\n\n // Design quality\n \"Design with visual hierarchy: use container components to group content, heading components for section titles, proper spacing, and status indicators. ONLY use components from the AVAILABLE COMPONENTS list.\",\n \"For data-rich UIs, use multi-column layout components if available. For forms and single-column content, use vertical layout components. ONLY use components from the AVAILABLE COMPONENTS list.\",\n \"Always include realistic, professional-looking sample data. For blogs include 3-4 posts with varied titles, authors, dates, categories. For products include names, prices, images. Never leave data empty.\",\n ],\n },\n);\n\n/**\n * Type for the Solid schema\n */\nexport type SolidSchema = typeof schema;\n\n/**\n * Infer the spec type from a catalog\n */\nexport type SolidSpec<TCatalog> = typeof schema extends {\n createCatalog: (catalog: TCatalog) => { _specType: infer S };\n}\n ? S\n : never;\n\n// Backward compatibility aliases\n/** @deprecated Use `schema` instead */\nexport const elementTreeSchema = schema;\n/** @deprecated Use `SolidSchema` instead */\nexport type ElementTreeSchema = SolidSchema;\n/** @deprecated Use `SolidSpec` instead */\nexport type ElementTreeSpec<T> = SolidSpec<T>;\n"],"mappings":";AAAA,SAAS,oBAAoB;AAStB,IAAM,SAAS;AAAA,EACpB,CAAC,OAAO;AAAA;AAAA,IAEN,MAAM,EAAE,OAAO;AAAA;AAAA,MAEb,MAAM,EAAE,OAAO;AAAA;AAAA,MAEf,UAAU,EAAE;AAAA,QACV,EAAE,OAAO;AAAA;AAAA,UAEP,MAAM,EAAE,IAAI,oBAAoB;AAAA;AAAA,UAEhC,OAAO,EAAE,QAAQ,oBAAoB;AAAA;AAAA,UAErC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA;AAAA,UAE5B,SAAS,EAAE,GAAG,EAAE,IAAI,GAAG,GAAG,EAAE,SAAS,EAAE;AAAA;AAAA,UAEvC,QAAQ,EAAE,GAAG,EAAE,IAAI,GAAG,GAAG,EAAE,SAAS,EAAE;AAAA,QACxC,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA;AAAA,IAGD,SAAS,EAAE,OAAO;AAAA;AAAA,MAEhB,YAAY,EAAE,IAAI;AAAA;AAAA,QAEhB,OAAO,EAAE,IAAI;AAAA;AAAA,QAEb,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA;AAAA,QAEzB,aAAa,EAAE,OAAO;AAAA;AAAA,QAEtB,SAAS,EAAE,IAAI;AAAA,MACjB,CAAC;AAAA;AAAA,MAED,SAAS,EAAE,IAAI;AAAA;AAAA,QAEb,QAAQ,EAAE,IAAI;AAAA;AAAA,QAEd,aAAa,EAAE,OAAO;AAAA,MACxB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EACA;AAAA,IACE,gBAAgB;AAAA,MACd;AAAA,QACE,MAAM;AAAA,QACN,aACE;AAAA,MACJ;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,aACE;AAAA,MACJ;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,aACE;AAAA,MACJ;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,aACE;AAAA,MACJ;AAAA,IACF;AAAA,IACA,cAAc;AAAA;AAAA,MAEZ;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAGA;AAAA,MACA;AAAA;AAAA,MAGA;AAAA,MACA;AAAA;AAAA,MAGA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAkBO,IAAM,oBAAoB;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -82,6 +82,13 @@ interface ValidationContextValue {
|
|
|
82
82
|
clear: (path: string) => void;
|
|
83
83
|
validateAll: () => boolean;
|
|
84
84
|
registerField: (path: string, config: ValidationConfig) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Release one registration for the path; the config (and its stale field
|
|
87
|
+
* state) is dropped when the last registration is released. Without this,
|
|
88
|
+
* fields registered on one screen would keep failing validateAll() on every
|
|
89
|
+
* later screen (their bound state no longer exists there).
|
|
90
|
+
*/
|
|
91
|
+
unregisterField: (path: string) => void;
|
|
85
92
|
}
|
|
86
93
|
interface ValidationProviderProps {
|
|
87
94
|
customFunctions?: Record<string, ValidationFunction>;
|
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,13 @@ interface ValidationContextValue {
|
|
|
82
82
|
clear: (path: string) => void;
|
|
83
83
|
validateAll: () => boolean;
|
|
84
84
|
registerField: (path: string, config: ValidationConfig) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Release one registration for the path; the config (and its stale field
|
|
87
|
+
* state) is dropped when the last registration is released. Without this,
|
|
88
|
+
* fields registered on one screen would keep failing validateAll() on every
|
|
89
|
+
* later screen (their bound state no longer exists there).
|
|
90
|
+
*/
|
|
91
|
+
unregisterField: (path: string) => void;
|
|
85
92
|
}
|
|
86
93
|
interface ValidationProviderProps {
|
|
87
94
|
customFunctions?: Record<string, ValidationFunction>;
|
package/dist/index.js
CHANGED
|
@@ -295,7 +295,9 @@ function ValidationProvider(props) {
|
|
|
295
295
|
const [fieldStates, setFieldStates] = (0, import_solid_js3.createSignal)({});
|
|
296
296
|
let fieldStatesRef = {};
|
|
297
297
|
const [fieldConfigs, setFieldConfigs] = (0, import_solid_js3.createSignal)({});
|
|
298
|
+
const registrationCounts = {};
|
|
298
299
|
const registerField = (path, config) => {
|
|
300
|
+
registrationCounts[path] = (registrationCounts[path] ?? 0) + 1;
|
|
299
301
|
setFieldConfigs((prev) => {
|
|
300
302
|
const existing = prev[path];
|
|
301
303
|
if (existing && validationConfigEqual(existing, config)) {
|
|
@@ -307,6 +309,23 @@ function ValidationProvider(props) {
|
|
|
307
309
|
};
|
|
308
310
|
});
|
|
309
311
|
};
|
|
312
|
+
const unregisterField = (path) => {
|
|
313
|
+
const next = (registrationCounts[path] ?? 0) - 1;
|
|
314
|
+
if (next > 0) {
|
|
315
|
+
registrationCounts[path] = next;
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
delete registrationCounts[path];
|
|
319
|
+
delete fieldStatesRef[path];
|
|
320
|
+
setFieldConfigs((prev) => {
|
|
321
|
+
if (!(path in prev)) return prev;
|
|
322
|
+
const {
|
|
323
|
+
[path]: _removed,
|
|
324
|
+
...rest
|
|
325
|
+
} = prev;
|
|
326
|
+
return rest;
|
|
327
|
+
});
|
|
328
|
+
};
|
|
310
329
|
const validate = (path, config) => {
|
|
311
330
|
const currentState = getSnapshot();
|
|
312
331
|
const segments = path.split("/").filter(Boolean);
|
|
@@ -378,7 +397,8 @@ function ValidationProvider(props) {
|
|
|
378
397
|
touch,
|
|
379
398
|
clear,
|
|
380
399
|
validateAll,
|
|
381
|
-
registerField
|
|
400
|
+
registerField,
|
|
401
|
+
unregisterField
|
|
382
402
|
};
|
|
383
403
|
return (0, import_web3.createComponent)(ValidationContext.Provider, {
|
|
384
404
|
value,
|
|
@@ -402,6 +422,7 @@ function useFieldValidation(path, config) {
|
|
|
402
422
|
(0, import_solid_js3.createEffect)(() => {
|
|
403
423
|
if (path && config) {
|
|
404
424
|
validation.registerField(path, config);
|
|
425
|
+
(0, import_solid_js3.onCleanup)(() => validation.unregisterField(path));
|
|
405
426
|
}
|
|
406
427
|
});
|
|
407
428
|
const state = (0, import_solid_js3.createMemo)(() => {
|
|
@@ -598,11 +619,8 @@ function ActionProvider(props) {
|
|
|
598
619
|
handler,
|
|
599
620
|
setState: set,
|
|
600
621
|
navigate: props.navigate,
|
|
601
|
-
executeAction: async (
|
|
602
|
-
|
|
603
|
-
action: name
|
|
604
|
-
};
|
|
605
|
-
await execute(subBinding);
|
|
622
|
+
executeAction: async (binding2) => {
|
|
623
|
+
await execute(binding2);
|
|
606
624
|
}
|
|
607
625
|
});
|
|
608
626
|
} finally {
|
|
@@ -621,11 +639,8 @@ function ActionProvider(props) {
|
|
|
621
639
|
handler,
|
|
622
640
|
setState: set,
|
|
623
641
|
navigate: props.navigate,
|
|
624
|
-
executeAction: async (
|
|
625
|
-
|
|
626
|
-
action: name
|
|
627
|
-
};
|
|
628
|
-
await execute(subBinding);
|
|
642
|
+
executeAction: async (binding2) => {
|
|
643
|
+
await execute(binding2);
|
|
629
644
|
}
|
|
630
645
|
});
|
|
631
646
|
} finally {
|
|
@@ -753,7 +768,9 @@ var schema = (0, import_core5.defineSchema)(
|
|
|
753
768
|
/** Child element keys (flat reference) */
|
|
754
769
|
children: s.array(s.string()),
|
|
755
770
|
/** Visibility condition */
|
|
756
|
-
visible: s.any()
|
|
771
|
+
visible: { ...s.any(), ...s.optional() },
|
|
772
|
+
/** Repeat children from a state array */
|
|
773
|
+
repeat: { ...s.any(), ...s.optional() }
|
|
757
774
|
})
|
|
758
775
|
)
|
|
759
776
|
}),
|
|
@@ -802,12 +819,13 @@ var schema = (0, import_core5.defineSchema)(
|
|
|
802
819
|
// Element integrity
|
|
803
820
|
"CRITICAL INTEGRITY CHECK: Before outputting ANY element that references children, you MUST have already output (or will output) each child as its own element. If an element has children: ['a', 'b'], then elements 'a' and 'b' MUST exist. A missing child element causes that entire branch of the UI to be invisible.",
|
|
804
821
|
"SELF-CHECK: After generating all elements, mentally walk the tree from root. Every key in every children array must resolve to a defined element. If you find a gap, output the missing element immediately.",
|
|
822
|
+
'REQUIRED FIELDS: Every element MUST include a "children" array. Leaf elements (text, badges, inputs, images) use an empty array: "children": []. Omitting "children" fails validation.',
|
|
805
823
|
// Field placement
|
|
806
824
|
'CRITICAL: The "visible" field goes on the ELEMENT object, NOT inside "props". Correct: {"type":"<ComponentName>","props":{},"visible":{"$state":"/tab","eq":"home"},"children":[...]}.',
|
|
807
825
|
'CRITICAL: The "on" field goes on the ELEMENT object, NOT inside "props". Use on.press, on.change, on.submit etc. NEVER put action/actionParams inside props.',
|
|
808
826
|
// State and data
|
|
809
827
|
"When the user asks for a UI that displays data (e.g. blog posts, products, users), ALWAYS include a state field with realistic sample data. The state field is a top-level field on the spec (sibling of root/elements).",
|
|
810
|
-
'When building repeating content backed by a state array (e.g. posts, products, items), use the "repeat" field on a container element. Example: { "type": "<ContainerComponent>", "props": {}, "repeat": { "statePath": "/posts", "key": "id" }, "children": ["post-card"] }. Replace <ContainerComponent> with an appropriate component from the AVAILABLE COMPONENTS list. Inside repeated children, use { "$item": "field" } to read a field from the current item, and { "$index": true } for the current array index. For two-way binding to an item field use { "$bindItem": "completed" }. Do NOT hardcode individual elements for each array item.',
|
|
828
|
+
'When building repeating content backed by a state array (e.g. posts, products, items), use the "repeat" field on a container element. Example: { "type": "<ContainerComponent>", "props": {}, "repeat": { "statePath": "/posts", "key": "id" }, "children": ["post-card"] }. For a nested list stored on the enclosing item, use "repeat": { "statePath": { "$item": "comments" }, "key": "id" }. The $item statePath form is valid only inside another repeat. Replace <ContainerComponent> with an appropriate component from the AVAILABLE COMPONENTS list. Inside repeated children, use { "$item": "field" } to read a field from the current item, and { "$index": true } for the current array index. For two-way binding to an item field use { "$bindItem": "completed" }. Do NOT hardcode individual elements for each array item.',
|
|
811
829
|
// Design quality
|
|
812
830
|
"Design with visual hierarchy: use container components to group content, heading components for section titles, proper spacing, and status indicators. ONLY use components from the AVAILABLE COMPONENTS list.",
|
|
813
831
|
"For data-rich UIs, use multi-column layout components if available. For forms and single-column content, use vertical layout components. ONLY use components from the AVAILABLE COMPONENTS list.",
|
|
@@ -886,7 +904,14 @@ function ElementRenderer(props) {
|
|
|
886
904
|
directives
|
|
887
905
|
};
|
|
888
906
|
});
|
|
889
|
-
const
|
|
907
|
+
const repeatVisibility = (0, import_solid_js6.createMemo)(() => props.element.repeat !== void 0 && !repeatScope ? (0, import_core6.splitRepeatVisibility)(props.element.visible) : {
|
|
908
|
+
container: props.element.visible,
|
|
909
|
+
itemFilter: void 0
|
|
910
|
+
});
|
|
911
|
+
const isVisible = (0, import_solid_js6.createMemo)(() => {
|
|
912
|
+
const container = repeatVisibility().container;
|
|
913
|
+
return container === void 0 ? true : (0, import_core6.evaluateVisibility)(container, fullCtx());
|
|
914
|
+
});
|
|
890
915
|
const emit = async (eventName) => {
|
|
891
916
|
const onBindings = props.element.on;
|
|
892
917
|
const binding = onBindings?.[eventName];
|
|
@@ -995,6 +1020,9 @@ function ElementRenderer(props) {
|
|
|
995
1020
|
get resolvedElement() {
|
|
996
1021
|
return resolvedElement();
|
|
997
1022
|
},
|
|
1023
|
+
get itemFilter() {
|
|
1024
|
+
return repeatVisibility().itemFilter;
|
|
1025
|
+
},
|
|
998
1026
|
get elementKey() {
|
|
999
1027
|
return props.elementKey;
|
|
1000
1028
|
},
|
|
@@ -1049,6 +1077,9 @@ function ElementRendererContent(props) {
|
|
|
1049
1077
|
},
|
|
1050
1078
|
get fallback() {
|
|
1051
1079
|
return props.fallback;
|
|
1080
|
+
},
|
|
1081
|
+
get itemFilter() {
|
|
1082
|
+
return props.itemFilter;
|
|
1052
1083
|
}
|
|
1053
1084
|
}) : (0, import_web18.createComponent)(import_solid_js6.For, {
|
|
1054
1085
|
get each() {
|
|
@@ -1125,24 +1156,43 @@ function ElementRendererContent(props) {
|
|
|
1125
1156
|
function RepeatChildren(props) {
|
|
1126
1157
|
const stateStore = useStateStore();
|
|
1127
1158
|
const repeat = () => props.element.repeat;
|
|
1128
|
-
const
|
|
1129
|
-
const
|
|
1159
|
+
const parentScope = useRepeatScope();
|
|
1160
|
+
const statePath = () => {
|
|
1161
|
+
const resolved = (0, import_core6.resolveRepeatStatePath)(repeat().statePath, parentScope?.basePath);
|
|
1162
|
+
if (resolved === void 0) {
|
|
1163
|
+
console.warn("[json-render/solid] $item in repeat.statePath used outside of a repeat scope");
|
|
1164
|
+
}
|
|
1165
|
+
return resolved;
|
|
1166
|
+
};
|
|
1167
|
+
const items = () => statePath() === void 0 ? [] : (0, import_core6.getByPath)(stateStore.state, statePath()) ?? [];
|
|
1168
|
+
const entries = () => items().map((itemValue, index) => ({
|
|
1169
|
+
itemValue,
|
|
1170
|
+
index
|
|
1171
|
+
})).filter(({
|
|
1172
|
+
itemValue,
|
|
1173
|
+
index
|
|
1174
|
+
}) => props.itemFilter === void 0 || (0, import_core6.evaluateVisibility)(props.itemFilter, {
|
|
1175
|
+
stateModel: stateStore.state,
|
|
1176
|
+
repeatItem: itemValue,
|
|
1177
|
+
repeatIndex: index
|
|
1178
|
+
}));
|
|
1130
1179
|
return (0, import_web18.createComponent)(import_solid_js6.For, {
|
|
1131
1180
|
get each() {
|
|
1132
|
-
return
|
|
1181
|
+
return entries();
|
|
1133
1182
|
},
|
|
1134
|
-
children: (
|
|
1183
|
+
children: ({
|
|
1184
|
+
itemValue,
|
|
1185
|
+
index
|
|
1186
|
+
}) => {
|
|
1135
1187
|
const key = () => {
|
|
1136
1188
|
const r = repeat();
|
|
1137
|
-
return r.key && typeof itemValue === "object" && itemValue !== null ? String(itemValue[r.key] ?? index
|
|
1189
|
+
return r.key && typeof itemValue === "object" && itemValue !== null ? String(itemValue[r.key] ?? index) : String(index);
|
|
1138
1190
|
};
|
|
1139
1191
|
return (0, import_web18.createComponent)(RepeatScopeProvider, {
|
|
1140
1192
|
item: itemValue,
|
|
1141
|
-
|
|
1142
|
-
return index();
|
|
1143
|
-
},
|
|
1193
|
+
index,
|
|
1144
1194
|
get basePath() {
|
|
1145
|
-
return
|
|
1195
|
+
return (0, import_core6.resolveRepeatItemStatePath)(statePath(), index);
|
|
1146
1196
|
},
|
|
1147
1197
|
get children() {
|
|
1148
1198
|
return (0, import_web18.createComponent)(import_solid_js6.For, {
|
|
@@ -1283,21 +1333,21 @@ function JSONUIProvider(props) {
|
|
|
1283
1333
|
});
|
|
1284
1334
|
}
|
|
1285
1335
|
function ConfirmationDialogManager() {
|
|
1286
|
-
const
|
|
1287
|
-
pendingConfirmation,
|
|
1288
|
-
confirm,
|
|
1289
|
-
cancel
|
|
1290
|
-
} = useActions();
|
|
1336
|
+
const actions = useActions();
|
|
1291
1337
|
return (0, import_web18.createComponent)(import_solid_js6.Show, {
|
|
1292
1338
|
get when() {
|
|
1293
|
-
return pendingConfirmation?.action.confirm;
|
|
1339
|
+
return actions.pendingConfirmation?.action.confirm;
|
|
1294
1340
|
},
|
|
1295
1341
|
children: (confirmConfig) => (0, import_web18.createComponent)(ConfirmDialog, {
|
|
1296
1342
|
get confirm() {
|
|
1297
1343
|
return confirmConfig();
|
|
1298
1344
|
},
|
|
1299
|
-
onConfirm
|
|
1300
|
-
|
|
1345
|
+
get onConfirm() {
|
|
1346
|
+
return actions.confirm;
|
|
1347
|
+
},
|
|
1348
|
+
get onCancel() {
|
|
1349
|
+
return actions.cancel;
|
|
1350
|
+
}
|
|
1301
1351
|
})
|
|
1302
1352
|
});
|
|
1303
1353
|
}
|