@xmachines/json-render-svelte 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/ElementRenderer.svelte +17 -5
- package/dist/ElementRenderer.svelte.d.ts.map +1 -1
- package/dist/RepeatChildren.svelte +55 -10
- package/dist/RepeatChildren.svelte.d.ts +3 -1
- package/dist/RepeatChildren.svelte.d.ts.map +1 -1
- package/dist/contexts/ActionProvider.svelte +4 -6
- package/dist/contexts/ActionProvider.svelte.d.ts.map +1 -1
- package/dist/contexts/ValidationProvider.svelte +41 -1
- package/dist/contexts/ValidationProvider.svelte.d.ts +7 -0
- package/dist/contexts/ValidationProvider.svelte.d.ts.map +1 -1
- package/dist/contexts/actions.test.js +32 -0
- package/dist/renderer.test.js +32 -0
- package/dist/repeat-filter.test.js +147 -0
- package/dist/schema.d.ts +11 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +5 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -148,6 +148,8 @@ const chat = createChatUI({ endpoint: "/api/chat" });
|
|
|
148
148
|
|
|
149
149
|
## Documentation
|
|
150
150
|
|
|
151
|
+
Nested lists can set `repeat.statePath` to `{ "$item": "field" }` to iterate an array on the enclosing repeat item.
|
|
152
|
+
|
|
151
153
|
Full API reference: [json-render.dev/docs/api/svelte](https://json-render.dev/docs/api/svelte).
|
|
152
154
|
|
|
153
155
|
## License
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
isDevtoolsActive,
|
|
9
9
|
subscribeDevtoolsActive,
|
|
10
10
|
type PropResolutionContext,
|
|
11
|
+
splitRepeatVisibility,
|
|
11
12
|
} from "@xmachines/json-render-core";
|
|
12
13
|
import { onDestroy } from "svelte";
|
|
13
14
|
import type { ComponentRegistry, ComponentRenderer } from "./renderer.js";
|
|
@@ -66,11 +67,20 @@
|
|
|
66
67
|
: { stateModel: stateCtx.state, functions, directives },
|
|
67
68
|
);
|
|
68
69
|
|
|
69
|
-
// Evaluate visibility
|
|
70
|
+
// Evaluate visibility. A `visible` condition on a repeat CONTAINER is split
|
|
71
|
+
// (upstream #300): $item/$index conjuncts become the item filter handed to
|
|
72
|
+
// RepeatChildren, while $state conjuncts still gate the container shell.
|
|
73
|
+
// Inside an existing repeat scope the element is a row, so its condition is
|
|
74
|
+
// evaluated as-is against the enclosing item.
|
|
75
|
+
let repeatVisibility = $derived(
|
|
76
|
+
element.repeat !== undefined && !repeatScope
|
|
77
|
+
? splitRepeatVisibility(element.visible)
|
|
78
|
+
: { container: element.visible, itemFilter: undefined },
|
|
79
|
+
);
|
|
70
80
|
let isVisible = $derived(
|
|
71
|
-
|
|
81
|
+
repeatVisibility.container === undefined
|
|
72
82
|
? true
|
|
73
|
-
: evaluateVisibility(
|
|
83
|
+
: evaluateVisibility(repeatVisibility.container, fullCtx),
|
|
74
84
|
);
|
|
75
85
|
|
|
76
86
|
// Resolve props and bindings
|
|
@@ -155,7 +165,8 @@
|
|
|
155
165
|
{spec}
|
|
156
166
|
{registry}
|
|
157
167
|
{loading}
|
|
158
|
-
{fallback}
|
|
168
|
+
{fallback}
|
|
169
|
+
itemFilter={repeatVisibility.itemFilter} />
|
|
159
170
|
{:else if resolvedElement.children}
|
|
160
171
|
{#each resolvedElement.children as childKey (childKey)}
|
|
161
172
|
{#if spec.elements[childKey]}
|
|
@@ -188,7 +199,8 @@
|
|
|
188
199
|
{spec}
|
|
189
200
|
{registry}
|
|
190
201
|
{loading}
|
|
191
|
-
{fallback}
|
|
202
|
+
{fallback}
|
|
203
|
+
itemFilter={repeatVisibility.itemFilter} />
|
|
192
204
|
{:else if resolvedElement.children}
|
|
193
205
|
{#each resolvedElement.children as childKey (childKey)}
|
|
194
206
|
{#if spec.elements[childKey]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementRenderer.svelte.d.ts","sourceRoot":"","sources":["../src/ElementRenderer.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAsB,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ElementRenderer.svelte.d.ts","sourceRoot":"","sources":["../src/ElementRenderer.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAsB,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAY7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAWxE,UAAU,KAAK;IACb,OAAO,EAAE,SAAS,CAAC;IACnB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAiLH,QAAA,MAAM,eAAe,2CAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { Spec, UIElement } from "@xmachines/json-render-core";
|
|
3
|
-
import {
|
|
2
|
+
import type { Spec, UIElement, VisibilityCondition } from "@xmachines/json-render-core";
|
|
3
|
+
import {
|
|
4
|
+
evaluateVisibility,
|
|
5
|
+
getByPath,
|
|
6
|
+
resolveRepeatItemStatePath,
|
|
7
|
+
resolveRepeatStatePath,
|
|
8
|
+
} from "@xmachines/json-render-core";
|
|
4
9
|
import type { ComponentRegistry, ComponentRenderer } from "./renderer.js";
|
|
5
10
|
import { getStateContext } from "./contexts/StateProvider.svelte";
|
|
6
|
-
import RepeatScopeProvider
|
|
11
|
+
import RepeatScopeProvider, {
|
|
12
|
+
getRepeatScope,
|
|
13
|
+
} from "./contexts/RepeatScopeProvider.svelte";
|
|
7
14
|
import ElementRenderer from "./ElementRenderer.svelte";
|
|
8
15
|
|
|
9
16
|
interface Props {
|
|
@@ -12,22 +19,60 @@
|
|
|
12
19
|
registry: ComponentRegistry;
|
|
13
20
|
loading?: boolean;
|
|
14
21
|
fallback?: ComponentRenderer;
|
|
22
|
+
/** $item/$index conjuncts split off the container's `visible` — filters items. */
|
|
23
|
+
itemFilter?: VisibilityCondition | undefined;
|
|
15
24
|
}
|
|
16
25
|
|
|
17
|
-
let {
|
|
26
|
+
let {
|
|
27
|
+
element,
|
|
28
|
+
spec,
|
|
29
|
+
registry,
|
|
30
|
+
loading = false,
|
|
31
|
+
fallback,
|
|
32
|
+
itemFilter = undefined,
|
|
33
|
+
}: Props = $props();
|
|
18
34
|
|
|
19
35
|
const stateCtx = getStateContext();
|
|
36
|
+
const parentScope = getRepeatScope();
|
|
37
|
+
|
|
38
|
+
let statePath = $derived.by(() => {
|
|
39
|
+
const resolved = resolveRepeatStatePath(
|
|
40
|
+
element.repeat!.statePath,
|
|
41
|
+
parentScope?.basePath,
|
|
42
|
+
);
|
|
43
|
+
if (resolved === undefined) {
|
|
44
|
+
console.warn(
|
|
45
|
+
"[json-render/svelte] $item in repeat.statePath used outside of a repeat scope",
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return resolved;
|
|
49
|
+
});
|
|
20
50
|
|
|
21
|
-
// Get items from state
|
|
22
51
|
let items = $derived(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
| undefined) ?? [],
|
|
52
|
+
statePath === undefined
|
|
53
|
+
? []
|
|
54
|
+
: ((getByPath(stateCtx.state, statePath) as unknown[] | undefined) ?? []),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// Filter with the ORIGINAL indexes preserved so per-item actions ($index,
|
|
58
|
+
// $bindItem paths) still address the right array entry.
|
|
59
|
+
let entries = $derived(
|
|
60
|
+
items
|
|
61
|
+
.map((itemValue, index) => ({ itemValue, index }))
|
|
62
|
+
.filter(
|
|
63
|
+
({ itemValue, index }) =>
|
|
64
|
+
itemFilter === undefined ||
|
|
65
|
+
evaluateVisibility(itemFilter, {
|
|
66
|
+
stateModel: stateCtx.state,
|
|
67
|
+
repeatItem: itemValue,
|
|
68
|
+
repeatIndex: index,
|
|
69
|
+
}),
|
|
70
|
+
),
|
|
26
71
|
);
|
|
27
72
|
</script>
|
|
28
73
|
|
|
29
|
-
{#each
|
|
30
|
-
{@const basePath =
|
|
74
|
+
{#each entries as { itemValue, index } (element.repeat?.key && typeof itemValue === "object" && itemValue !== null ? String((itemValue as any)[element.repeat.key] ?? index) : String(index))}
|
|
75
|
+
{@const basePath = resolveRepeatItemStatePath(statePath!, index)}
|
|
31
76
|
|
|
32
77
|
{#if element.children}
|
|
33
78
|
<RepeatScopeProvider item={itemValue} {index} {basePath}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Spec, UIElement } from "@xmachines/json-render-core";
|
|
1
|
+
import type { Spec, UIElement, VisibilityCondition } from "@xmachines/json-render-core";
|
|
2
2
|
import type { ComponentRegistry, ComponentRenderer } from "./renderer.js";
|
|
3
3
|
interface Props {
|
|
4
4
|
element: UIElement;
|
|
@@ -6,6 +6,8 @@ interface Props {
|
|
|
6
6
|
registry: ComponentRegistry;
|
|
7
7
|
loading?: boolean;
|
|
8
8
|
fallback?: ComponentRenderer;
|
|
9
|
+
/** $item/$index conjuncts split off the container's `visible` — filters items. */
|
|
10
|
+
itemFilter?: VisibilityCondition | undefined;
|
|
9
11
|
}
|
|
10
12
|
declare const RepeatChildren: import("svelte").Component<Props, {}, "">;
|
|
11
13
|
type RepeatChildren = ReturnType<typeof RepeatChildren>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepeatChildren.svelte.d.ts","sourceRoot":"","sources":["../src/RepeatChildren.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"RepeatChildren.svelte.d.ts","sourceRoot":"","sources":["../src/RepeatChildren.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAO9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAQxE,UAAU,KAAK;IACb,OAAO,EAAE,SAAS,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,kFAAkF;IAClF,UAAU,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CAC9C;AA8EH,QAAA,MAAM,cAAc,2CAAwC,CAAC;AAC7D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,eAAe,cAAc,CAAC"}
|
|
@@ -304,9 +304,8 @@
|
|
|
304
304
|
handler,
|
|
305
305
|
setState: stateCtx.set,
|
|
306
306
|
navigate,
|
|
307
|
-
executeAction: async (
|
|
308
|
-
|
|
309
|
-
await execute(subBinding);
|
|
307
|
+
executeAction: async (binding) => {
|
|
308
|
+
await execute(binding);
|
|
310
309
|
},
|
|
311
310
|
});
|
|
312
311
|
} finally {
|
|
@@ -322,9 +321,8 @@
|
|
|
322
321
|
handler,
|
|
323
322
|
setState: stateCtx.set,
|
|
324
323
|
navigate,
|
|
325
|
-
executeAction: async (
|
|
326
|
-
|
|
327
|
-
await execute(subBinding);
|
|
324
|
+
executeAction: async (binding) => {
|
|
325
|
+
await execute(binding);
|
|
328
326
|
},
|
|
329
327
|
});
|
|
330
328
|
} finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionProvider.svelte.d.ts","sourceRoot":"","sources":["../../src/contexts/ActionProvider.svelte.ts"],"names":[],"mappings":"AAIE,OAAO,KAAK,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,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;CACjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAQhD;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,GACX,YAAY,CAAC,aAAa,GAAG,SAAS,CAAC,CAOzC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,OAAO,EAAE,aAAa,CAAC;IACvB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAuDH,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAOH,KAAK,aAAa,IAAI,iBAAiB,EACxC,MAAM,mBAAmB,CAAC;AAM3B,UAAU,KAAK;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAqOH,QAAA,MAAM,cAAc,2CAAwC,CAAC;AAC7D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,eAAe,cAAc,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
import { getContext, hasContext } from "svelte";
|
|
2
|
+
import { getContext, hasContext, onDestroy } from "svelte";
|
|
3
3
|
import type {
|
|
4
4
|
ValidationConfig,
|
|
5
5
|
ValidationFunction,
|
|
@@ -35,6 +35,13 @@
|
|
|
35
35
|
validateAll: () => boolean;
|
|
36
36
|
/** Register field config */
|
|
37
37
|
registerField: (path: string, config: ValidationConfig) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Release one registration for the path; the config (and its stale field
|
|
40
|
+
* state) is dropped when the last registration is released. Without this,
|
|
41
|
+
* fields registered on one screen would keep failing validateAll() on
|
|
42
|
+
* every later screen (their bound state no longer exists there).
|
|
43
|
+
*/
|
|
44
|
+
unregisterField: (path: string) => void;
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
/**
|
|
@@ -74,6 +81,16 @@
|
|
|
74
81
|
errors: string[];
|
|
75
82
|
isValid: boolean;
|
|
76
83
|
} {
|
|
84
|
+
// Register the field so validateAll()/the validateForm built-in sees it,
|
|
85
|
+
// and release the registration when the calling component is destroyed so
|
|
86
|
+
// a field left behind by a previous screen cannot fail validateAll()
|
|
87
|
+
// forever. getFieldValidation runs during component init, so onDestroy
|
|
88
|
+
// attaches to the calling component.
|
|
89
|
+
if (path && config) {
|
|
90
|
+
ctx.registerField(path, config);
|
|
91
|
+
onDestroy(() => ctx.unregisterField(path));
|
|
92
|
+
}
|
|
93
|
+
|
|
77
94
|
const state = ctx.fieldStates[path] ?? {
|
|
78
95
|
touched: false,
|
|
79
96
|
validated: false,
|
|
@@ -174,10 +191,32 @@
|
|
|
174
191
|
return allValid;
|
|
175
192
|
};
|
|
176
193
|
|
|
194
|
+
// One count per path: re-registrations must not let a destroy from an
|
|
195
|
+
// earlier component instance drop a live registration.
|
|
196
|
+
const registrationCounts: Record<string, number> = {};
|
|
197
|
+
|
|
177
198
|
const registerField = (path: string, config: CoreValidationConfig): void => {
|
|
199
|
+
registrationCounts[path] = (registrationCounts[path] ?? 0) + 1;
|
|
178
200
|
fieldConfigs = { ...fieldConfigs, [path]: config };
|
|
179
201
|
};
|
|
180
202
|
|
|
203
|
+
const unregisterField = (path: string): void => {
|
|
204
|
+
const next = (registrationCounts[path] ?? 0) - 1;
|
|
205
|
+
if (next > 0) {
|
|
206
|
+
registrationCounts[path] = next;
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
delete registrationCounts[path];
|
|
210
|
+
if (path in fieldConfigs) {
|
|
211
|
+
const { [path]: _removed, ...rest } = fieldConfigs;
|
|
212
|
+
fieldConfigs = rest;
|
|
213
|
+
}
|
|
214
|
+
if (path in fieldStates) {
|
|
215
|
+
const { [path]: _removedState, ...restStates } = fieldStates;
|
|
216
|
+
fieldStates = restStates;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
181
220
|
const ctx: ValidationContext = {
|
|
182
221
|
get customFunctions() {
|
|
183
222
|
return customFunctions;
|
|
@@ -190,6 +229,7 @@
|
|
|
190
229
|
clear,
|
|
191
230
|
validateAll,
|
|
192
231
|
registerField,
|
|
232
|
+
unregisterField,
|
|
193
233
|
};
|
|
194
234
|
|
|
195
235
|
setContext(VALIDATION_KEY, ctx);
|
|
@@ -25,6 +25,13 @@ export interface ValidationContext {
|
|
|
25
25
|
validateAll: () => boolean;
|
|
26
26
|
/** Register field config */
|
|
27
27
|
registerField: (path: string, config: ValidationConfig) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Release one registration for the path; the config (and its stale field
|
|
30
|
+
* state) is dropped when the last registration is released. Without this,
|
|
31
|
+
* fields registered on one screen would keep failing validateAll() on
|
|
32
|
+
* every later screen (their bound state no longer exists there).
|
|
33
|
+
*/
|
|
34
|
+
unregisterField: (path: string) => void;
|
|
28
35
|
}
|
|
29
36
|
/**
|
|
30
37
|
* Get the validation context from component tree
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationProvider.svelte.d.ts","sourceRoot":"","sources":["../../src/contexts/ValidationProvider.svelte.ts"],"names":[],"mappings":"AAIE,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAI3B;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,eA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ActionContext", () => {
|
|
|
101
101
|
expect(customHandler).toHaveBeenCalledWith({ foo: "bar" });
|
|
102
102
|
}, { handlers: { myAction: customHandler } });
|
|
103
103
|
})());
|
|
104
|
+
it("forwards params to a named onSuccess action (#301)", (() => {
|
|
105
|
+
const toast = vi.fn().mockResolvedValue(undefined);
|
|
106
|
+
return component(async () => {
|
|
107
|
+
const actionCtx = getActionContext();
|
|
108
|
+
await actionCtx.execute({
|
|
109
|
+
action: "save",
|
|
110
|
+
onSuccess: { action: "toast", params: { message: "Saved" } },
|
|
111
|
+
});
|
|
112
|
+
expect(toast).toHaveBeenCalledWith({ message: "Saved" });
|
|
113
|
+
}, {
|
|
114
|
+
handlers: {
|
|
115
|
+
save: vi.fn().mockResolvedValue(undefined),
|
|
116
|
+
toast,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
})());
|
|
120
|
+
it("forwards params to a named onError action (#301)", (() => {
|
|
121
|
+
const toast = vi.fn().mockResolvedValue(undefined);
|
|
122
|
+
return component(async () => {
|
|
123
|
+
const actionCtx = getActionContext();
|
|
124
|
+
await actionCtx.execute({
|
|
125
|
+
action: "save",
|
|
126
|
+
onError: { action: "toast", params: { message: "Failed" } },
|
|
127
|
+
});
|
|
128
|
+
expect(toast).toHaveBeenCalledWith({ message: "Failed" });
|
|
129
|
+
}, {
|
|
130
|
+
handlers: {
|
|
131
|
+
save: vi.fn().mockRejectedValue(new Error("boom")),
|
|
132
|
+
toast,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
})());
|
|
104
136
|
it("warns when no handler registered", component(async () => {
|
|
105
137
|
const actionCtx = getActionContext();
|
|
106
138
|
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => { });
|
package/dist/renderer.test.js
CHANGED
|
@@ -165,4 +165,36 @@ describe("Renderer", () => {
|
|
|
165
165
|
expect(texts).toHaveLength(1);
|
|
166
166
|
expect(texts[0]?.textContent).toBe("I exist");
|
|
167
167
|
});
|
|
168
|
+
it("renders nested repeats from the enclosing item", () => {
|
|
169
|
+
const spec = {
|
|
170
|
+
root: "groups",
|
|
171
|
+
state: {
|
|
172
|
+
groups: [
|
|
173
|
+
{ subitems: [{ label: "a1" }, { label: "a2" }] },
|
|
174
|
+
{ subitems: [{ label: "b1" }] },
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
elements: {
|
|
178
|
+
groups: {
|
|
179
|
+
type: "Container",
|
|
180
|
+
props: {},
|
|
181
|
+
repeat: { statePath: "/groups" },
|
|
182
|
+
children: ["subitems"],
|
|
183
|
+
},
|
|
184
|
+
subitems: {
|
|
185
|
+
type: "Container",
|
|
186
|
+
props: {},
|
|
187
|
+
repeat: { statePath: { $item: "/subitems" } },
|
|
188
|
+
children: ["label"],
|
|
189
|
+
},
|
|
190
|
+
label: {
|
|
191
|
+
type: "Text",
|
|
192
|
+
props: { text: { $item: "label" } },
|
|
193
|
+
children: [],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
const { container } = mountRenderer(spec);
|
|
198
|
+
expect(Array.from(container.querySelectorAll(".test-text")).map((element) => element.textContent)).toEqual(["a1", "a2", "b1"]);
|
|
199
|
+
});
|
|
168
200
|
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repeat containers with an $item `visible` condition — parity with the react
|
|
3
|
+
* renderer (upstream #300, `splitRepeatVisibility`).
|
|
4
|
+
*
|
|
5
|
+
* Mirrors packages/react/src/repeat-filter.test.tsx.
|
|
6
|
+
*/
|
|
7
|
+
import { describe, it, expect, afterEach } from "vitest";
|
|
8
|
+
import { render, cleanup } from "@testing-library/svelte";
|
|
9
|
+
import RendererWithProvider from "./RendererWithProvider.test.svelte";
|
|
10
|
+
import TestContainer from "./TestContainer.svelte";
|
|
11
|
+
import TestText from "./TestText.svelte";
|
|
12
|
+
import { defineRegistry } from "./renderer.js";
|
|
13
|
+
const { registry } = defineRegistry(null, {
|
|
14
|
+
components: {
|
|
15
|
+
Stack: TestContainer,
|
|
16
|
+
Text: TestText,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
const tasks = [
|
|
20
|
+
{ id: "1", title: "Auth flow", status: "todo" },
|
|
21
|
+
{ id: "2", title: "Push notifications", status: "in-progress" },
|
|
22
|
+
{ id: "3", title: "Dark mode", status: "todo" },
|
|
23
|
+
{ id: "4", title: "App icon", status: "done" },
|
|
24
|
+
];
|
|
25
|
+
function mountSpec(spec) {
|
|
26
|
+
return render(RendererWithProvider, {
|
|
27
|
+
props: { spec, registry, initialState: spec.state ?? {} },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const texts = (container) => [...container.querySelectorAll(".test-text")].map((node) => node.textContent ?? "");
|
|
31
|
+
afterEach(() => cleanup());
|
|
32
|
+
describe("repeat with $item visible on the container (filtered list)", () => {
|
|
33
|
+
it("renders only the items matching the filter", () => {
|
|
34
|
+
const { container } = mountSpec({
|
|
35
|
+
root: "column",
|
|
36
|
+
state: { tasks },
|
|
37
|
+
elements: {
|
|
38
|
+
column: {
|
|
39
|
+
type: "Stack",
|
|
40
|
+
props: {},
|
|
41
|
+
repeat: { statePath: "/tasks", key: "id" },
|
|
42
|
+
visible: { $item: "status", eq: "todo" },
|
|
43
|
+
children: ["card"],
|
|
44
|
+
},
|
|
45
|
+
card: {
|
|
46
|
+
type: "Text",
|
|
47
|
+
props: { text: { $item: "title" } },
|
|
48
|
+
children: [],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
expect(texts(container)).toEqual(["Auth flow", "Dark mode"]);
|
|
53
|
+
});
|
|
54
|
+
it("renders every item without a filter", () => {
|
|
55
|
+
const { container } = mountSpec({
|
|
56
|
+
root: "column",
|
|
57
|
+
state: { tasks },
|
|
58
|
+
elements: {
|
|
59
|
+
column: {
|
|
60
|
+
type: "Stack",
|
|
61
|
+
props: {},
|
|
62
|
+
repeat: { statePath: "/tasks", key: "id" },
|
|
63
|
+
children: ["card"],
|
|
64
|
+
},
|
|
65
|
+
card: {
|
|
66
|
+
type: "Text",
|
|
67
|
+
props: { text: { $item: "title" } },
|
|
68
|
+
children: [],
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
expect(texts(container)).toHaveLength(4);
|
|
73
|
+
});
|
|
74
|
+
it("still hides the whole list for a container-level $state condition", () => {
|
|
75
|
+
const { container } = mountSpec({
|
|
76
|
+
root: "column",
|
|
77
|
+
state: { tasks, showTasks: false },
|
|
78
|
+
elements: {
|
|
79
|
+
column: {
|
|
80
|
+
type: "Stack",
|
|
81
|
+
props: {},
|
|
82
|
+
repeat: { statePath: "/tasks", key: "id" },
|
|
83
|
+
visible: { $state: "/showTasks", eq: true },
|
|
84
|
+
children: ["card"],
|
|
85
|
+
},
|
|
86
|
+
card: {
|
|
87
|
+
type: "Text",
|
|
88
|
+
props: { text: { $item: "title" } },
|
|
89
|
+
children: [],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
expect(texts(container)).toHaveLength(0);
|
|
94
|
+
});
|
|
95
|
+
it("keeps per-child $item visible working inside the repeat scope", () => {
|
|
96
|
+
const { container } = mountSpec({
|
|
97
|
+
root: "column",
|
|
98
|
+
state: { tasks },
|
|
99
|
+
elements: {
|
|
100
|
+
column: {
|
|
101
|
+
type: "Stack",
|
|
102
|
+
props: {},
|
|
103
|
+
repeat: { statePath: "/tasks", key: "id" },
|
|
104
|
+
children: ["card"],
|
|
105
|
+
},
|
|
106
|
+
card: {
|
|
107
|
+
type: "Text",
|
|
108
|
+
props: { text: { $item: "title" } },
|
|
109
|
+
visible: { $item: "status", eq: "done" },
|
|
110
|
+
children: [],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
expect(texts(container)).toEqual(["App icon"]);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
describe("mixed container/item visibility on repeat containers", () => {
|
|
118
|
+
const mixedSpec = (showTasks) => ({
|
|
119
|
+
root: "column",
|
|
120
|
+
state: { tasks, showTasks },
|
|
121
|
+
elements: {
|
|
122
|
+
column: {
|
|
123
|
+
type: "Stack",
|
|
124
|
+
props: {},
|
|
125
|
+
repeat: { statePath: "/tasks", key: "id" },
|
|
126
|
+
visible: {
|
|
127
|
+
$and: [
|
|
128
|
+
{ $state: "/showTasks", eq: true },
|
|
129
|
+
{ $item: "status", eq: "todo" },
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
children: ["card"],
|
|
133
|
+
},
|
|
134
|
+
card: { type: "Text", props: { text: { $item: "title" } }, children: [] },
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
it("hides the container shell when the $state gate is false", () => {
|
|
138
|
+
const { container } = mountSpec(mixedSpec(false));
|
|
139
|
+
expect(container.querySelectorAll(".test-container")).toHaveLength(0);
|
|
140
|
+
expect(texts(container)).toHaveLength(0);
|
|
141
|
+
});
|
|
142
|
+
it("filters items when the $state gate is true", () => {
|
|
143
|
+
const { container } = mountSpec(mixedSpec(true));
|
|
144
|
+
expect(container.querySelectorAll(".test-container")).toHaveLength(1);
|
|
145
|
+
expect(texts(container)).toEqual(["Auth flow", "Dark mode"]);
|
|
146
|
+
});
|
|
147
|
+
});
|
package/dist/schema.d.ts
CHANGED
|
@@ -18,7 +18,17 @@ export declare const schema: import("@xmachines/json-render-core").Schema<{
|
|
|
18
18
|
/** Child element keys (flat reference) */
|
|
19
19
|
children: import("@xmachines/json-render-core").SchemaType<"array", import("@xmachines/json-render-core").SchemaType<"string", unknown>>;
|
|
20
20
|
/** Visibility condition */
|
|
21
|
-
visible:
|
|
21
|
+
visible: {
|
|
22
|
+
optional: true;
|
|
23
|
+
kind: "any";
|
|
24
|
+
inner?: unknown;
|
|
25
|
+
};
|
|
26
|
+
/** Repeat children from a state array */
|
|
27
|
+
repeat: {
|
|
28
|
+
optional: true;
|
|
29
|
+
kind: "any";
|
|
30
|
+
inner?: unknown;
|
|
31
|
+
};
|
|
22
32
|
}>>;
|
|
23
33
|
}>;
|
|
24
34
|
catalog: import("@xmachines/json-render-core").SchemaType<"object", {
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,MAAM;;QAIb,uBAAuB;;QAEvB,kCAAkC;;YAG9B,kCAAkC;;YAElC,sBAAsB;;YAEtB,0CAA0C;;YAE1C,2BAA2B
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,MAAM;;QAIb,uBAAuB;;QAEvB,kCAAkC;;YAG9B,kCAAkC;;YAElC,sBAAsB;;YAEtB,0CAA0C;;YAE1C,2BAA2B;;;;;;YAE3B,yCAAyC;;;;;;;;;QAQ7C,4BAA4B;;YAE1B,qCAAqC;;YAErC,uGAAuG;;YAEvG,0CAA0C;;YAE1C,8FAA8F;;;QAGhG,oCAAoC;;YAElC,mCAAmC;;YAEnC,0CAA0C;;;;EAgDjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,MAAM,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,QAAQ,IAAI,OAAO,MAAM,SAAS;IACvD,aAAa,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK;QAAE,SAAS,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;CAC9D,GACG,CAAC,GACD,KAAK,CAAC"}
|
package/dist/schema.js
CHANGED
|
@@ -20,7 +20,9 @@ export const schema = defineSchema((s) => ({
|
|
|
20
20
|
/** Child element keys (flat reference) */
|
|
21
21
|
children: s.array(s.string()),
|
|
22
22
|
/** Visibility condition */
|
|
23
|
-
visible: s.any(),
|
|
23
|
+
visible: { ...s.any(), ...s.optional() },
|
|
24
|
+
/** Repeat children from a state array */
|
|
25
|
+
repeat: { ...s.any(), ...s.optional() },
|
|
24
26
|
})),
|
|
25
27
|
}),
|
|
26
28
|
// What the CATALOG must provide
|
|
@@ -67,12 +69,13 @@ export const schema = defineSchema((s) => ({
|
|
|
67
69
|
// Element integrity
|
|
68
70
|
"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.",
|
|
69
71
|
"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.",
|
|
72
|
+
'REQUIRED FIELDS: Every element MUST include a "children" array. Leaf elements (text, badges, inputs, images) use an empty array: "children": []. Omitting "children" fails validation.',
|
|
70
73
|
// Field placement
|
|
71
74
|
'CRITICAL: The "visible" field goes on the ELEMENT object, NOT inside "props". Correct: {"type":"<ComponentName>","props":{},"visible":{"$state":"/tab","eq":"home"},"children":[...]}.',
|
|
72
75
|
'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.',
|
|
73
76
|
// State and data
|
|
74
77
|
"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).",
|
|
75
|
-
'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.',
|
|
78
|
+
'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.',
|
|
76
79
|
// Design quality
|
|
77
80
|
"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.",
|
|
78
81
|
"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.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmachines/json-render-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0-xm.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Svelte 5 renderer for @xmachines/json-render-core. JSON becomes Svelte components.",
|
|
6
6
|
"keywords": [
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
],
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "git+https://
|
|
21
|
+
"url": "git+https://gitlab.com/xmachin-es/json-render.git",
|
|
22
22
|
"directory": "packages/svelte"
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://json-render.dev",
|
|
25
25
|
"bugs": {
|
|
26
|
-
"url": "https://
|
|
26
|
+
"url": "https://gitlab.com/xmachin-es/json-render/-/issues"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"dist"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@xmachines/json-render-core": "0.
|
|
52
|
+
"@xmachines/json-render-core": "0.20.0-xm.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@sveltejs/package": "^2.3.0",
|
|
@@ -68,4 +68,4 @@
|
|
|
68
68
|
"dev": "svelte-package -i src -o dist --watch",
|
|
69
69
|
"typecheck": "svelte-check --tsconfig ./tsconfig.json"
|
|
70
70
|
}
|
|
71
|
-
}
|
|
71
|
+
}
|