@json-render/vue 0.19.0 → 0.21.0
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 +40 -5
- package/dist/{chunk-WIPZLAF7.mjs → chunk-34A2QV2X.mjs} +9 -3
- package/dist/chunk-34A2QV2X.mjs.map +1 -0
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +73 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -20
- package/dist/index.mjs.map +1 -1
- package/dist/schema.d.mts +17 -1
- package/dist/schema.d.ts +17 -1
- package/dist/schema.js +8 -2
- package/dist/schema.js.map +1 -1
- package/dist/schema.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-WIPZLAF7.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
schema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-34A2QV2X.mjs";
|
|
4
4
|
|
|
5
5
|
// src/composables/state.ts
|
|
6
6
|
import {
|
|
@@ -534,9 +534,8 @@ var ActionProvider = defineComponent4({
|
|
|
534
534
|
handler,
|
|
535
535
|
setState: set,
|
|
536
536
|
navigate: props.navigate,
|
|
537
|
-
executeAction: async (
|
|
538
|
-
|
|
539
|
-
await execute(subBinding);
|
|
537
|
+
executeAction: async (binding2) => {
|
|
538
|
+
await execute(binding2);
|
|
540
539
|
}
|
|
541
540
|
});
|
|
542
541
|
} finally {
|
|
@@ -555,9 +554,8 @@ var ActionProvider = defineComponent4({
|
|
|
555
554
|
handler,
|
|
556
555
|
setState: set,
|
|
557
556
|
navigate: props.navigate,
|
|
558
|
-
executeAction: async (
|
|
559
|
-
|
|
560
|
-
await execute(subBinding);
|
|
557
|
+
executeAction: async (binding2) => {
|
|
558
|
+
await execute(binding2);
|
|
561
559
|
}
|
|
562
560
|
});
|
|
563
561
|
} finally {
|
|
@@ -1270,12 +1268,15 @@ import {
|
|
|
1270
1268
|
resolveElementProps,
|
|
1271
1269
|
resolveBindings,
|
|
1272
1270
|
resolveActionParam,
|
|
1271
|
+
resolveRepeatItemStatePath,
|
|
1272
|
+
resolveRepeatStatePath,
|
|
1273
1273
|
evaluateVisibility as evaluateVisibility2,
|
|
1274
1274
|
getByPath as getByPath3,
|
|
1275
1275
|
createDirectiveRegistry,
|
|
1276
1276
|
isDevtoolsActive,
|
|
1277
1277
|
subscribeDevtoolsActive
|
|
1278
1278
|
} from "@json-render/core";
|
|
1279
|
+
var registryMetadata = /* @__PURE__ */ new WeakMap();
|
|
1279
1280
|
var EMPTY_FUNCTIONS = {};
|
|
1280
1281
|
var FUNCTIONS_KEY = /* @__PURE__ */ Symbol("json-render:functions");
|
|
1281
1282
|
var FunctionsProvider = defineComponent6({
|
|
@@ -1500,18 +1501,28 @@ var ElementRenderer = defineComponent6({
|
|
|
1500
1501
|
);
|
|
1501
1502
|
return null;
|
|
1502
1503
|
}
|
|
1503
|
-
const
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1504
|
+
const metadata = registryMetadata.get(props.registry)?.[resolvedElement.type];
|
|
1505
|
+
if (resolvedElement.slots && metadata?.slots) {
|
|
1506
|
+
const availableSlots = new Set(metadata.slots);
|
|
1507
|
+
for (const slotName of Object.keys(resolvedElement.slots)) {
|
|
1508
|
+
if (slotName === "default") {
|
|
1509
|
+
console.warn(
|
|
1510
|
+
`[json-render] Component "${resolvedElement.type}" uses slots.default. Use "children" for default slot content.`
|
|
1511
|
+
);
|
|
1512
|
+
} else if (!availableSlots.has(slotName)) {
|
|
1513
|
+
console.warn(
|
|
1514
|
+
`[json-render] Unknown slot "${slotName}" on component "${resolvedElement.type}". Available slots: ${metadata.slots.join(", ")}`
|
|
1515
|
+
);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
const renderChildKeys = (childKeys, slotName) => childKeys.map((childKey) => {
|
|
1510
1520
|
const childElement = props.spec.elements[childKey];
|
|
1511
1521
|
if (!childElement) {
|
|
1512
1522
|
if (!props.loading) {
|
|
1523
|
+
const location = slotName ? `in slot "${slotName}" of "${resolvedElement.type}"` : `as child of "${resolvedElement.type}"`;
|
|
1513
1524
|
console.warn(
|
|
1514
|
-
`[json-render] Missing element "${childKey}" referenced
|
|
1525
|
+
`[json-render] Missing element "${childKey}" referenced ${location}. This element will not render.`
|
|
1515
1526
|
);
|
|
1516
1527
|
}
|
|
1517
1528
|
return null;
|
|
@@ -1525,7 +1536,20 @@ var ElementRenderer = defineComponent6({
|
|
|
1525
1536
|
loading: props.loading,
|
|
1526
1537
|
fallback: props.fallback
|
|
1527
1538
|
});
|
|
1528
|
-
}).filter((
|
|
1539
|
+
}).filter((node) => node !== null);
|
|
1540
|
+
const childrenVNodes = resolvedElement.repeat ? h2(RepeatChildren, {
|
|
1541
|
+
element: resolvedElement,
|
|
1542
|
+
spec: props.spec,
|
|
1543
|
+
registry: props.registry,
|
|
1544
|
+
loading: props.loading,
|
|
1545
|
+
fallback: props.fallback
|
|
1546
|
+
}) : resolvedElement.children ? renderChildKeys(resolvedElement.children) : void 0;
|
|
1547
|
+
const namedSlots = resolvedElement.slots ? Object.fromEntries(
|
|
1548
|
+
Object.entries(resolvedElement.slots).filter(([slotName]) => slotName !== "default").map(([slotName, childKeys]) => [
|
|
1549
|
+
slotName,
|
|
1550
|
+
() => renderChildKeys(childKeys, slotName)
|
|
1551
|
+
])
|
|
1552
|
+
) : {};
|
|
1529
1553
|
const componentVNode = h2(
|
|
1530
1554
|
Component,
|
|
1531
1555
|
{
|
|
@@ -1535,7 +1559,7 @@ var ElementRenderer = defineComponent6({
|
|
|
1535
1559
|
bindings: elementBindings,
|
|
1536
1560
|
loading: props.loading
|
|
1537
1561
|
},
|
|
1538
|
-
{ default: () => childrenVNodes }
|
|
1562
|
+
{ default: () => childrenVNodes, ...namedSlots }
|
|
1539
1563
|
);
|
|
1540
1564
|
const tagged = devtoolsActive.value && props.elementKey ? h2(
|
|
1541
1565
|
"span",
|
|
@@ -1576,10 +1600,20 @@ var RepeatChildren = defineComponent6({
|
|
|
1576
1600
|
},
|
|
1577
1601
|
setup(props) {
|
|
1578
1602
|
const { state } = useStateStore();
|
|
1603
|
+
const parentScope = useRepeatScope();
|
|
1579
1604
|
return () => {
|
|
1580
1605
|
const repeat = props.element.repeat;
|
|
1581
1606
|
if (!repeat?.statePath) return null;
|
|
1582
|
-
const statePath =
|
|
1607
|
+
const statePath = resolveRepeatStatePath(
|
|
1608
|
+
repeat.statePath,
|
|
1609
|
+
parentScope?.basePath
|
|
1610
|
+
);
|
|
1611
|
+
if (statePath === void 0) {
|
|
1612
|
+
console.warn(
|
|
1613
|
+
"[json-render/vue] $item in repeat.statePath used outside of a repeat scope"
|
|
1614
|
+
);
|
|
1615
|
+
return null;
|
|
1616
|
+
}
|
|
1583
1617
|
const raw = getByPath3(state.value, statePath);
|
|
1584
1618
|
const items = Array.isArray(raw) ? raw : [];
|
|
1585
1619
|
return items.map((itemValue, index) => {
|
|
@@ -1588,7 +1622,12 @@ var RepeatChildren = defineComponent6({
|
|
|
1588
1622
|
) : String(index);
|
|
1589
1623
|
return h2(
|
|
1590
1624
|
RepeatScopeProvider,
|
|
1591
|
-
{
|
|
1625
|
+
{
|
|
1626
|
+
key,
|
|
1627
|
+
item: itemValue,
|
|
1628
|
+
index,
|
|
1629
|
+
basePath: resolveRepeatItemStatePath(statePath, index)
|
|
1630
|
+
},
|
|
1592
1631
|
{
|
|
1593
1632
|
default: () => props.element.children?.map((childKey) => {
|
|
1594
1633
|
const childElement = props.spec.elements[childKey];
|
|
@@ -1749,7 +1788,7 @@ var JSONUIProvider = defineComponent6({
|
|
|
1749
1788
|
);
|
|
1750
1789
|
}
|
|
1751
1790
|
});
|
|
1752
|
-
function defineRegistry(
|
|
1791
|
+
function defineRegistry(catalog, options) {
|
|
1753
1792
|
const registry = {};
|
|
1754
1793
|
if (options.components) {
|
|
1755
1794
|
for (const [name, componentFn] of Object.entries(options.components)) {
|
|
@@ -1781,6 +1820,7 @@ function defineRegistry(_catalog, options) {
|
|
|
1781
1820
|
return () => componentFn({
|
|
1782
1821
|
props: registryProps.element.props,
|
|
1783
1822
|
children: slots.default?.(),
|
|
1823
|
+
slots,
|
|
1784
1824
|
emit: registryProps.emit,
|
|
1785
1825
|
on: registryProps.on,
|
|
1786
1826
|
bindings: registryProps.bindings,
|
|
@@ -1790,6 +1830,10 @@ function defineRegistry(_catalog, options) {
|
|
|
1790
1830
|
});
|
|
1791
1831
|
}
|
|
1792
1832
|
}
|
|
1833
|
+
const catalogComponents = catalog.data?.components;
|
|
1834
|
+
if (catalogComponents) {
|
|
1835
|
+
registryMetadata.set(registry, catalogComponents);
|
|
1836
|
+
}
|
|
1793
1837
|
const actionMap = options.actions ? Object.entries(options.actions) : [];
|
|
1794
1838
|
const handlers = (getSetState, getState) => {
|
|
1795
1839
|
const result = {};
|
|
@@ -1816,6 +1860,10 @@ function defineRegistry(_catalog, options) {
|
|
|
1816
1860
|
}
|
|
1817
1861
|
function createRenderer(catalog, components) {
|
|
1818
1862
|
const registry = components;
|
|
1863
|
+
const catalogComponents = catalog.data.components;
|
|
1864
|
+
if (catalogComponents) {
|
|
1865
|
+
registryMetadata.set(registry, catalogComponents);
|
|
1866
|
+
}
|
|
1819
1867
|
return defineComponent6({
|
|
1820
1868
|
name: "CatalogRenderer",
|
|
1821
1869
|
props: {
|