@json-render/vue 0.20.0 → 0.21.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 +38 -5
- package/dist/{chunk-F4CKBTOP.mjs → chunk-34A2QV2X.mjs} +4 -1
- 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 +47 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -12
- package/dist/index.mjs.map +1 -1
- package/dist/schema.d.mts +6 -0
- package/dist/schema.d.ts +6 -0
- package/dist/schema.js +3 -0
- package/dist/schema.js.map +1 -1
- package/dist/schema.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-F4CKBTOP.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 {
|
|
@@ -1276,6 +1276,7 @@ import {
|
|
|
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",
|
|
@@ -1764,7 +1788,7 @@ var JSONUIProvider = defineComponent6({
|
|
|
1764
1788
|
);
|
|
1765
1789
|
}
|
|
1766
1790
|
});
|
|
1767
|
-
function defineRegistry(
|
|
1791
|
+
function defineRegistry(catalog, options) {
|
|
1768
1792
|
const registry = {};
|
|
1769
1793
|
if (options.components) {
|
|
1770
1794
|
for (const [name, componentFn] of Object.entries(options.components)) {
|
|
@@ -1796,6 +1820,7 @@ function defineRegistry(_catalog, options) {
|
|
|
1796
1820
|
return () => componentFn({
|
|
1797
1821
|
props: registryProps.element.props,
|
|
1798
1822
|
children: slots.default?.(),
|
|
1823
|
+
slots,
|
|
1799
1824
|
emit: registryProps.emit,
|
|
1800
1825
|
on: registryProps.on,
|
|
1801
1826
|
bindings: registryProps.bindings,
|
|
@@ -1805,6 +1830,10 @@ function defineRegistry(_catalog, options) {
|
|
|
1805
1830
|
});
|
|
1806
1831
|
}
|
|
1807
1832
|
}
|
|
1833
|
+
const catalogComponents = catalog.data?.components;
|
|
1834
|
+
if (catalogComponents) {
|
|
1835
|
+
registryMetadata.set(registry, catalogComponents);
|
|
1836
|
+
}
|
|
1808
1837
|
const actionMap = options.actions ? Object.entries(options.actions) : [];
|
|
1809
1838
|
const handlers = (getSetState, getState) => {
|
|
1810
1839
|
const result = {};
|
|
@@ -1831,6 +1860,10 @@ function defineRegistry(_catalog, options) {
|
|
|
1831
1860
|
}
|
|
1832
1861
|
function createRenderer(catalog, components) {
|
|
1833
1862
|
const registry = components;
|
|
1863
|
+
const catalogComponents = catalog.data.components;
|
|
1864
|
+
if (catalogComponents) {
|
|
1865
|
+
registryMetadata.set(registry, catalogComponents);
|
|
1866
|
+
}
|
|
1834
1867
|
return defineComponent6({
|
|
1835
1868
|
name: "CatalogRenderer",
|
|
1836
1869
|
props: {
|