@netlisian/softconfig 0.1.0 → 0.1.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/dist/puck/index.css +5 -5
- package/dist/puck/index.d.mts +24 -5
- package/dist/puck/index.d.ts +24 -5
- package/dist/puck/index.js +210 -90
- package/dist/puck/index.mjs +201 -81
- package/package.json +1 -1
package/dist/puck/index.mjs
CHANGED
|
@@ -309,13 +309,27 @@ var updateVersion = (version, increment) => {
|
|
|
309
309
|
};
|
|
310
310
|
var builderRootConfig = (config, overrides, editingComponent, showVersionFields = true) => ({
|
|
311
311
|
fields: {
|
|
312
|
-
|
|
313
|
-
// type: "slot",
|
|
314
|
-
// },
|
|
315
|
-
_name: {
|
|
312
|
+
_name: overrides.name || {
|
|
316
313
|
type: "text",
|
|
317
314
|
label: "Soft Component Name"
|
|
318
315
|
},
|
|
316
|
+
_category: overrides.categories || {
|
|
317
|
+
type: "select",
|
|
318
|
+
label: "Category",
|
|
319
|
+
options: [
|
|
320
|
+
...Object.keys(config.categories || {}).map((cat) => {
|
|
321
|
+
var _a;
|
|
322
|
+
return {
|
|
323
|
+
label: ((_a = config.categories) == null ? void 0 : _a[cat].title) || cat,
|
|
324
|
+
value: cat
|
|
325
|
+
};
|
|
326
|
+
}) || [],
|
|
327
|
+
{
|
|
328
|
+
label: Object.keys(config.categories || {}).length ? "Other" : "Uncategorized",
|
|
329
|
+
value: void 0
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
},
|
|
319
333
|
_fields: {
|
|
320
334
|
type: "array",
|
|
321
335
|
label: "Fields",
|
|
@@ -385,7 +399,9 @@ var builderRootConfig = (config, overrides, editingComponent, showVersionFields
|
|
|
385
399
|
}
|
|
386
400
|
return fields;
|
|
387
401
|
},
|
|
388
|
-
resolveData: (props) => {
|
|
402
|
+
resolveData: (props, params) => {
|
|
403
|
+
if (overrides.onRootsDataChange)
|
|
404
|
+
overrides.onRootsDataChange(props, params);
|
|
389
405
|
return {
|
|
390
406
|
props,
|
|
391
407
|
readOnly: Boolean(editingComponent) ? {
|
|
@@ -556,7 +572,7 @@ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (op
|
|
|
556
572
|
};
|
|
557
573
|
var get_class_name_factory_default = getClassNameFactory;
|
|
558
574
|
|
|
559
|
-
// css-module:/media/
|
|
575
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/error-boundary/styles.module.css#css-module
|
|
560
576
|
var styles_module_default = { "ErrorBoundary": "_ErrorBoundary_1xl05_5", "ErrorBoundary-title": "_ErrorBoundary-title_1xl05_21", "ErrorBoundary-details": "_ErrorBoundary-details_1xl05_31", "ErrorBoundary-button": "_ErrorBoundary-button_1xl05_39" };
|
|
561
577
|
|
|
562
578
|
// src/puck/components/error-boundary/index.tsx
|
|
@@ -765,7 +781,8 @@ var builderConfig = (config, overrides, editingComponent, showVersionFields = tr
|
|
|
765
781
|
return acc;
|
|
766
782
|
},
|
|
767
783
|
{}
|
|
768
|
-
)
|
|
784
|
+
),
|
|
785
|
+
categories: config.categories || {}
|
|
769
786
|
});
|
|
770
787
|
|
|
771
788
|
// src/puck/lib/strip-id.ts
|
|
@@ -891,7 +908,7 @@ var softFieldsToPuckFields = (fields, fieldSettings) => {
|
|
|
891
908
|
{}
|
|
892
909
|
)) || {};
|
|
893
910
|
};
|
|
894
|
-
var softComponentFromAppState = (appState, configComponents, editedItem) => {
|
|
911
|
+
var softComponentFromAppState = (appState, configComponents, editedItem, metadata) => {
|
|
895
912
|
var _a;
|
|
896
913
|
const rootProps = ((_a = appState.data.root) == null ? void 0 : _a.props) || {};
|
|
897
914
|
const fields = rootProps._fields || [];
|
|
@@ -912,6 +929,8 @@ var softComponentFromAppState = (appState, configComponents, editedItem) => {
|
|
|
912
929
|
)), slots);
|
|
913
930
|
return [
|
|
914
931
|
{
|
|
932
|
+
name: metadata.name,
|
|
933
|
+
category: metadata.category,
|
|
915
934
|
fields: __spreadValues(__spreadValues({}, softFieldsToPuckFields(fields, field_settings)), Object.keys(slots).reduce((acc, slot) => {
|
|
916
935
|
acc[slot] = { type: "slot", label: slot };
|
|
917
936
|
return acc;
|
|
@@ -1047,7 +1066,7 @@ var reconstructComponents = (subComponents, componentConfigs, softComponentProps
|
|
|
1047
1066
|
return componentData;
|
|
1048
1067
|
});
|
|
1049
1068
|
};
|
|
1050
|
-
var softComponentToAppState = (softComponent, componentName, version, versions, componentProps, componentConfigs) => {
|
|
1069
|
+
var softComponentToAppState = (softComponent, componentName, version, versions, componentProps, componentConfigs, displayName, category) => {
|
|
1051
1070
|
const slots = new Set(Object.keys(softComponent.slots));
|
|
1052
1071
|
const { fields, fieldSettings } = puckFieldsToSoftFields(
|
|
1053
1072
|
softComponent.fields,
|
|
@@ -1059,7 +1078,8 @@ var softComponentToAppState = (softComponent, componentName, version, versions,
|
|
|
1059
1078
|
}
|
|
1060
1079
|
});
|
|
1061
1080
|
const rootProps = {
|
|
1062
|
-
_name: componentName,
|
|
1081
|
+
_name: displayName || componentName,
|
|
1082
|
+
_category: category,
|
|
1063
1083
|
_version: version,
|
|
1064
1084
|
_versions: versions,
|
|
1065
1085
|
_fields: fields,
|
|
@@ -1208,10 +1228,11 @@ function SoftRender({
|
|
|
1208
1228
|
|
|
1209
1229
|
// src/puck/lib/create-versioned-component-config.tsx
|
|
1210
1230
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1211
|
-
var createVersionedComponentConfig = (componentName, version, allVersions, config, softComponents, defaultProps, showVersioning = true) => {
|
|
1231
|
+
var createVersionedComponentConfig = (componentName, displayName, version, allVersions, config, softComponents, defaultProps, showVersioning = true) => {
|
|
1212
1232
|
var _a, _b;
|
|
1213
1233
|
const softConfig = config;
|
|
1214
1234
|
return {
|
|
1235
|
+
label: displayName,
|
|
1215
1236
|
fields: Object.fromEntries(
|
|
1216
1237
|
(Object.entries(
|
|
1217
1238
|
(_b = (_a = softComponents[componentName].versions) == null ? void 0 : _a[version]) == null ? void 0 : _b.fields
|
|
@@ -1357,9 +1378,21 @@ function demolishSoftComponent(componentName, data, config, softComponents) {
|
|
|
1357
1378
|
};
|
|
1358
1379
|
}
|
|
1359
1380
|
|
|
1381
|
+
// src/puck/lib/component-key.ts
|
|
1382
|
+
var defaultToCamelCase = (value) => {
|
|
1383
|
+
const tokens = value.trim().replace(/[^a-zA-Z0-9\s_-]/g, " ").split(/[\s_-]+/).filter(Boolean);
|
|
1384
|
+
if (tokens.length === 0) return "";
|
|
1385
|
+
const [first, ...rest] = tokens;
|
|
1386
|
+
return `${first.toLowerCase()}${rest.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase()).join("")}`;
|
|
1387
|
+
};
|
|
1388
|
+
var createComponentKeyFromName = (displayName, overrides, context) => {
|
|
1389
|
+
const key = overrides.componentNameToKey ? overrides.componentNameToKey(displayName, context) : defaultToCamelCase(displayName);
|
|
1390
|
+
return key.trim();
|
|
1391
|
+
};
|
|
1392
|
+
|
|
1360
1393
|
// src/puck/store/slices/builder.tsx
|
|
1361
1394
|
var createBuildersSlice = (set, get, initialConfig) => ({
|
|
1362
|
-
build: (history, selectedItem, itemSelector, puckDispatch) => {
|
|
1395
|
+
build: (history, selectedItem, itemSelector, puckDispatch, name) => {
|
|
1363
1396
|
if (!selectedItem || !itemSelector) {
|
|
1364
1397
|
throw new Error("No item selected to build from.");
|
|
1365
1398
|
}
|
|
@@ -1372,7 +1405,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1372
1405
|
data: __spreadProps(__spreadValues({}, previous.data), {
|
|
1373
1406
|
root: {
|
|
1374
1407
|
props: {
|
|
1375
|
-
_name: "New Soft Component"
|
|
1408
|
+
_name: name || "New Soft Component"
|
|
1376
1409
|
}
|
|
1377
1410
|
}
|
|
1378
1411
|
// content: [{ ...selectedItem }],
|
|
@@ -1381,7 +1414,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1381
1414
|
});
|
|
1382
1415
|
const config = __spreadValues({}, get().softConfig);
|
|
1383
1416
|
const overrides = get().overrides;
|
|
1384
|
-
const buildConfig = builderConfig(config, overrides,
|
|
1417
|
+
const buildConfig = builderConfig(config, overrides, void 0, get().showVersionFields);
|
|
1385
1418
|
const editableIds = /* @__PURE__ */ new Set([selectedItem.props.id]);
|
|
1386
1419
|
const initialContent = [__spreadValues({}, selectedItem)];
|
|
1387
1420
|
walkTree3(
|
|
@@ -1414,7 +1447,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1414
1447
|
type: "replaceRoot",
|
|
1415
1448
|
root: {
|
|
1416
1449
|
title: "Soft Component Builder",
|
|
1417
|
-
_name: "New Soft Component"
|
|
1450
|
+
_name: name || "New Soft Component"
|
|
1418
1451
|
}
|
|
1419
1452
|
}),
|
|
1420
1453
|
100
|
|
@@ -1431,6 +1464,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1431
1464
|
}
|
|
1432
1465
|
const softComponentVersion = ((_a = selectedItem.props) == null ? void 0 : _a.version) || "1.0.0";
|
|
1433
1466
|
const softComponent = (_b = get().softComponents[softComponentName]) == null ? void 0 : _b.versions[softComponentVersion];
|
|
1467
|
+
const softComponentMeta = get().softComponents[softComponentName];
|
|
1434
1468
|
const versions = Object.keys(
|
|
1435
1469
|
get().softComponents[softComponentName].versions || {}
|
|
1436
1470
|
);
|
|
@@ -1451,12 +1485,12 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1451
1485
|
softComponentVersion,
|
|
1452
1486
|
versions,
|
|
1453
1487
|
selectedItem.props,
|
|
1454
|
-
get().softConfig.components
|
|
1488
|
+
get().softConfig.components,
|
|
1489
|
+
(softComponentMeta == null ? void 0 : softComponentMeta.name) || softComponentName,
|
|
1490
|
+
softComponentMeta == null ? void 0 : softComponentMeta.category
|
|
1455
1491
|
);
|
|
1456
1492
|
const config = __spreadValues({}, get().softConfig);
|
|
1457
1493
|
const overrides = get().overrides;
|
|
1458
|
-
const getStore = () => get();
|
|
1459
|
-
const getEditableIds = () => getStore().editableComponentIds;
|
|
1460
1494
|
const dependents = get().dependencyGraph.get(softComponentName) || /* @__PURE__ */ new Set();
|
|
1461
1495
|
const buildConfig = builderConfig(config, overrides, softComponentName, get().showVersionFields, dependents);
|
|
1462
1496
|
const editableIds = /* @__PURE__ */ new Set([]);
|
|
@@ -1512,19 +1546,20 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1512
1546
|
type: "replaceRoot",
|
|
1513
1547
|
root: {
|
|
1514
1548
|
title: root.props.title,
|
|
1515
|
-
_name: root.props.
|
|
1549
|
+
_name: root.props._name,
|
|
1550
|
+
_category: root.props._category
|
|
1516
1551
|
}
|
|
1517
1552
|
}),
|
|
1518
1553
|
100
|
|
1519
1554
|
);
|
|
1520
1555
|
},
|
|
1521
1556
|
complete: (appState, setHistories, getItemBySelector) => {
|
|
1522
|
-
var _a, _b;
|
|
1557
|
+
var _a, _b, _c, _d, _e;
|
|
1523
1558
|
if (get().state === "ready") {
|
|
1524
1559
|
throw new Error("Not building or remodeling a component.");
|
|
1525
1560
|
}
|
|
1526
|
-
const
|
|
1527
|
-
if (!
|
|
1561
|
+
const displayName = (_c = (_b = (_a = appState.data.root) == null ? void 0 : _a.props) == null ? void 0 : _b._name) == null ? void 0 : _c.trim();
|
|
1562
|
+
if (!displayName) {
|
|
1528
1563
|
throw new Error("Root component must have a name to compose.");
|
|
1529
1564
|
}
|
|
1530
1565
|
const itemSelector = get().itemSelector;
|
|
@@ -1537,42 +1572,73 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1537
1572
|
if (!selectedItem) {
|
|
1538
1573
|
throw new Error("Cannot find item being edited");
|
|
1539
1574
|
}
|
|
1540
|
-
const
|
|
1575
|
+
const rootCategory = (_e = (_d = appState.data.root) == null ? void 0 : _d.props) == null ? void 0 : _e._category;
|
|
1576
|
+
const componentName = createComponentKeyFromName(displayName, get().overrides, {
|
|
1577
|
+
existingKeys: Object.keys(get().softComponents),
|
|
1578
|
+
state: get().state
|
|
1579
|
+
});
|
|
1580
|
+
if (!componentName) {
|
|
1581
|
+
throw new Error("Failed to generate component key from name.");
|
|
1582
|
+
}
|
|
1583
|
+
const [newSoftComponentConfig, version] = get().builder.compose(
|
|
1584
|
+
appState,
|
|
1585
|
+
componentName,
|
|
1586
|
+
selectedItem,
|
|
1587
|
+
displayName,
|
|
1588
|
+
rootCategory
|
|
1589
|
+
) || [];
|
|
1541
1590
|
if (!newSoftComponentConfig) {
|
|
1542
1591
|
throw new Error("Failed to compose new soft component config.");
|
|
1543
1592
|
}
|
|
1544
1593
|
const storedHistories = get().originalHistory;
|
|
1545
1594
|
setHistories([...storedHistories]);
|
|
1546
1595
|
const config = __spreadValues({}, get().softConfig || initialConfig);
|
|
1547
|
-
set((s) =>
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1596
|
+
set((s) => {
|
|
1597
|
+
var _a2, _b2;
|
|
1598
|
+
const nextComponents = __spreadProps(__spreadValues({}, Object.entries(config.components).reduce(
|
|
1599
|
+
(acc, [name, component]) => {
|
|
1600
|
+
var _a3;
|
|
1601
|
+
let tempComponent = (_a3 = config.components) == null ? void 0 : _a3[name];
|
|
1602
|
+
if (tempComponent) {
|
|
1603
|
+
acc[name] = tempComponent;
|
|
1604
|
+
acc[name].render = tempComponent.render;
|
|
1605
|
+
} else {
|
|
1606
|
+
tempComponent = __spreadValues({}, component);
|
|
1607
|
+
tempComponent == null ? true : delete tempComponent.resolvePermissions;
|
|
1608
|
+
tempComponent == null ? true : delete tempComponent.resolveData;
|
|
1609
|
+
acc[name] = tempComponent;
|
|
1610
|
+
}
|
|
1611
|
+
return acc;
|
|
1612
|
+
},
|
|
1613
|
+
{}
|
|
1614
|
+
)), {
|
|
1615
|
+
[componentName]: __spreadValues({}, newSoftComponentConfig)
|
|
1616
|
+
});
|
|
1617
|
+
const categories = get().softConfig.categories || {};
|
|
1618
|
+
const nextCategories = rootCategory ? __spreadProps(__spreadValues({}, categories), {
|
|
1619
|
+
[rootCategory]: __spreadProps(__spreadValues({}, categories[rootCategory] || {}), {
|
|
1620
|
+
title: ((_a2 = categories[rootCategory]) == null ? void 0 : _a2.title) || rootCategory,
|
|
1621
|
+
components: Array.from(
|
|
1622
|
+
/* @__PURE__ */ new Set([
|
|
1623
|
+
...((_b2 = categories[rootCategory]) == null ? void 0 : _b2.components) || [],
|
|
1624
|
+
componentName
|
|
1625
|
+
])
|
|
1626
|
+
)
|
|
1568
1627
|
})
|
|
1569
|
-
})
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1628
|
+
}) : categories;
|
|
1629
|
+
return __spreadProps(__spreadValues({}, s), {
|
|
1630
|
+
softConfig: __spreadProps(__spreadValues({}, config), {
|
|
1631
|
+
root: __spreadValues({}, initialConfig.root),
|
|
1632
|
+
components: nextComponents,
|
|
1633
|
+
categories: nextCategories
|
|
1634
|
+
}),
|
|
1635
|
+
storedConfig: void 0,
|
|
1636
|
+
state: "inspecting",
|
|
1637
|
+
originalHistory: [],
|
|
1638
|
+
editingComponentId: null,
|
|
1639
|
+
editableComponentIds: /* @__PURE__ */ new Set()
|
|
1640
|
+
});
|
|
1641
|
+
});
|
|
1576
1642
|
get().rebuildDependents(componentName, version);
|
|
1577
1643
|
return componentName;
|
|
1578
1644
|
},
|
|
@@ -1619,7 +1685,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1619
1685
|
editableComponentIds: /* @__PURE__ */ new Set()
|
|
1620
1686
|
}));
|
|
1621
1687
|
},
|
|
1622
|
-
compose: (appState, componentName, editedItem) => {
|
|
1688
|
+
compose: (appState, componentName, editedItem, displayName, category) => {
|
|
1623
1689
|
if (!componentName) {
|
|
1624
1690
|
throw new Error("Root component must have a name to compose.");
|
|
1625
1691
|
}
|
|
@@ -1629,12 +1695,21 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1629
1695
|
`Component name "${componentName}" already exists in the configuration.`
|
|
1630
1696
|
);
|
|
1631
1697
|
}
|
|
1632
|
-
const [softComponent, version] = softComponentFromAppState(
|
|
1698
|
+
const [softComponent, version] = softComponentFromAppState(
|
|
1699
|
+
appState,
|
|
1700
|
+
componentConfigs,
|
|
1701
|
+
editedItem,
|
|
1702
|
+
{
|
|
1703
|
+
name: displayName,
|
|
1704
|
+
category
|
|
1705
|
+
}
|
|
1706
|
+
);
|
|
1633
1707
|
const existingComponent = get().softComponents[componentName];
|
|
1634
1708
|
const allVersions = Object.keys((existingComponent == null ? void 0 : existingComponent.versions) || {});
|
|
1635
1709
|
const isNewVersion = !allVersions.includes(version);
|
|
1636
1710
|
const newSoftComponentConfig = createVersionedComponentConfig(
|
|
1637
1711
|
componentName,
|
|
1712
|
+
displayName,
|
|
1638
1713
|
version,
|
|
1639
1714
|
isNewVersion ? [...allVersions, version] : allVersions,
|
|
1640
1715
|
get().softConfig,
|
|
@@ -1682,6 +1757,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1682
1757
|
throw new Error("Can only switch versions during remodeling.");
|
|
1683
1758
|
}
|
|
1684
1759
|
const softComponent = (_a = get().softComponents[componentName]) == null ? void 0 : _a.versions[newVersion];
|
|
1760
|
+
const softComponentMeta = get().softComponents[componentName];
|
|
1685
1761
|
if (!softComponent) {
|
|
1686
1762
|
throw new Error(
|
|
1687
1763
|
`Soft component "${componentName}" with version "${newVersion}" not found.`
|
|
@@ -1696,7 +1772,9 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1696
1772
|
newVersion,
|
|
1697
1773
|
versions,
|
|
1698
1774
|
currentProps,
|
|
1699
|
-
get().softConfig.components
|
|
1775
|
+
get().softConfig.components,
|
|
1776
|
+
(softComponentMeta == null ? void 0 : softComponentMeta.name) || componentName,
|
|
1777
|
+
softComponentMeta == null ? void 0 : softComponentMeta.category
|
|
1700
1778
|
);
|
|
1701
1779
|
puckDispatch({
|
|
1702
1780
|
type: "setData",
|
|
@@ -1748,10 +1826,11 @@ function hydrateSoftComponentsTransforms(softComponents, hydrator) {
|
|
|
1748
1826
|
})
|
|
1749
1827
|
});
|
|
1750
1828
|
});
|
|
1751
|
-
hydrated[name] = {
|
|
1829
|
+
hydrated[name] = __spreadProps(__spreadValues({}, comp), {
|
|
1830
|
+
name: comp.name || name,
|
|
1752
1831
|
defaultVersion: comp.defaultVersion,
|
|
1753
1832
|
versions
|
|
1754
|
-
};
|
|
1833
|
+
});
|
|
1755
1834
|
});
|
|
1756
1835
|
return hydrated;
|
|
1757
1836
|
}
|
|
@@ -1871,6 +1950,7 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides, showV
|
|
|
1871
1950
|
}
|
|
1872
1951
|
const newSoftComponentConfig = createVersionedComponentConfig(
|
|
1873
1952
|
name,
|
|
1953
|
+
comp.name || name,
|
|
1874
1954
|
defaultVersion || "1.0.0",
|
|
1875
1955
|
allVersions,
|
|
1876
1956
|
buildingConfig,
|
|
@@ -1899,6 +1979,7 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides, showV
|
|
|
1899
1979
|
}
|
|
1900
1980
|
const newSoftComponentConfig = createVersionedComponentConfig(
|
|
1901
1981
|
name,
|
|
1982
|
+
comp.name || name,
|
|
1902
1983
|
defaultVersion || "1.0.0",
|
|
1903
1984
|
allVersions,
|
|
1904
1985
|
hardConfig,
|
|
@@ -1971,11 +2052,19 @@ var clearEditVisibility = (doc) => {
|
|
|
1971
2052
|
var createSoftConfigStore = (hardConfig = {
|
|
1972
2053
|
components: {}
|
|
1973
2054
|
}, softComponents = {}, overrides = {}, onActions, showVersionFields = true) => {
|
|
2055
|
+
const normalizedSoftComponents = Object.fromEntries(
|
|
2056
|
+
Object.entries(softComponents || {}).map(([key, value]) => [
|
|
2057
|
+
key,
|
|
2058
|
+
__spreadProps(__spreadValues({}, value), {
|
|
2059
|
+
name: value.name || key
|
|
2060
|
+
})
|
|
2061
|
+
])
|
|
2062
|
+
);
|
|
1974
2063
|
const iframeDocRef = { current: null };
|
|
1975
2064
|
const hydratedSoftComponents = (overrides == null ? void 0 : overrides.hydrateMapTransform) ? hydrateSoftComponentsTransforms(
|
|
1976
|
-
|
|
2065
|
+
normalizedSoftComponents,
|
|
1977
2066
|
overrides.hydrateMapTransform
|
|
1978
|
-
) :
|
|
2067
|
+
) : normalizedSoftComponents;
|
|
1979
2068
|
const initialDependencyGraph = buildReverseDependencyGraph(
|
|
1980
2069
|
hydratedSoftComponents
|
|
1981
2070
|
);
|
|
@@ -2026,19 +2115,23 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2026
2115
|
hardConfig,
|
|
2027
2116
|
hydratedSoftComponents,
|
|
2028
2117
|
overrides
|
|
2029
|
-
))
|
|
2118
|
+
)),
|
|
2119
|
+
categories: __spreadValues({}, hardConfig.categories || {})
|
|
2030
2120
|
}),
|
|
2031
2121
|
setSoftComponent: (name, version, component) => {
|
|
2122
|
+
const existing = get().softComponents[name];
|
|
2032
2123
|
set((state) => {
|
|
2033
|
-
var _a;
|
|
2124
|
+
var _a, _b;
|
|
2034
2125
|
return {
|
|
2035
2126
|
softComponents: __spreadProps(__spreadValues({}, state.softComponents), {
|
|
2036
|
-
[name]: {
|
|
2127
|
+
[name]: __spreadProps(__spreadValues({}, existing), {
|
|
2128
|
+
name: component.name || (existing == null ? void 0 : existing.name) || name,
|
|
2129
|
+
category: (_a = component.category) != null ? _a : existing == null ? void 0 : existing.category,
|
|
2037
2130
|
defaultVersion: version,
|
|
2038
|
-
versions: __spreadProps(__spreadValues({}, ((
|
|
2131
|
+
versions: __spreadProps(__spreadValues({}, ((_b = state.softComponents[name]) == null ? void 0 : _b.versions) || {}), {
|
|
2039
2132
|
[version]: component
|
|
2040
2133
|
})
|
|
2041
|
-
}
|
|
2134
|
+
})
|
|
2042
2135
|
})
|
|
2043
2136
|
};
|
|
2044
2137
|
});
|
|
@@ -2050,14 +2143,17 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2050
2143
|
Object.entries(incomingComponents).forEach(([name, data]) => {
|
|
2051
2144
|
const existing = nextSoftComponents[name];
|
|
2052
2145
|
const finalComponentData = existing ? __spreadProps(__spreadValues(__spreadValues({}, existing), data), {
|
|
2146
|
+
name: data.name || existing.name || name,
|
|
2053
2147
|
versions: __spreadValues(__spreadValues({}, existing.versions), data.versions)
|
|
2054
2148
|
}) : data;
|
|
2149
|
+
finalComponentData.name = finalComponentData.name || name;
|
|
2055
2150
|
nextSoftComponents[name] = finalComponentData;
|
|
2056
2151
|
const activeVersion = finalComponentData.defaultVersion;
|
|
2057
2152
|
const activeVersionData = finalComponentData.versions[activeVersion];
|
|
2058
2153
|
if (activeVersionData) {
|
|
2059
2154
|
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
2060
2155
|
name,
|
|
2156
|
+
finalComponentData.name || name,
|
|
2061
2157
|
activeVersion,
|
|
2062
2158
|
Object.keys(finalComponentData.versions),
|
|
2063
2159
|
state.softConfig,
|
|
@@ -2088,6 +2184,7 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2088
2184
|
if (activeVersionData) {
|
|
2089
2185
|
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
2090
2186
|
name,
|
|
2187
|
+
componentData.name || name,
|
|
2091
2188
|
activeVersion,
|
|
2092
2189
|
Object.keys(componentData.versions),
|
|
2093
2190
|
softConfig,
|
|
@@ -2105,11 +2202,12 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2105
2202
|
});
|
|
2106
2203
|
},
|
|
2107
2204
|
setSoftComponentDefaultVersion: (name, version) => {
|
|
2108
|
-
var _a, _b, _c;
|
|
2205
|
+
var _a, _b, _c, _d;
|
|
2109
2206
|
const softComponent = (_b = (_a = get().softComponents[name]) == null ? void 0 : _a.versions) == null ? void 0 : _b[version];
|
|
2110
2207
|
const allVersions = Object.keys(
|
|
2111
2208
|
((_c = get().softComponents[name]) == null ? void 0 : _c.versions) || {}
|
|
2112
2209
|
);
|
|
2210
|
+
const displayName = ((_d = get().softComponents[name]) == null ? void 0 : _d.name) || name;
|
|
2113
2211
|
if (!softComponent) {
|
|
2114
2212
|
throw new Error(
|
|
2115
2213
|
`Soft component "${name}" version "${version}" does not exist.`
|
|
@@ -2117,6 +2215,7 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2117
2215
|
}
|
|
2118
2216
|
const newSoftComponentConfig = createVersionedComponentConfig(
|
|
2119
2217
|
name,
|
|
2218
|
+
displayName,
|
|
2120
2219
|
version,
|
|
2121
2220
|
allVersions,
|
|
2122
2221
|
get().softConfig,
|
|
@@ -2170,20 +2269,20 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2170
2269
|
},
|
|
2171
2270
|
setSoftComponentConfig: (key, config, category) => {
|
|
2172
2271
|
set((state) => {
|
|
2173
|
-
var _a;
|
|
2272
|
+
var _a, _b, _c;
|
|
2174
2273
|
return {
|
|
2175
2274
|
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
2176
2275
|
components: __spreadProps(__spreadValues({}, state.softConfig.components), {
|
|
2177
2276
|
[key]: __spreadValues({}, config)
|
|
2178
2277
|
}),
|
|
2179
|
-
categories: category
|
|
2180
|
-
[category]: __spreadProps(__spreadValues({}, state.softConfig.categories[category]), {
|
|
2278
|
+
categories: category ? __spreadProps(__spreadValues({}, state.softConfig.categories || {}), {
|
|
2279
|
+
[category]: __spreadProps(__spreadValues({}, ((_a = state.softConfig.categories) == null ? void 0 : _a[category]) || {}), {
|
|
2181
2280
|
components: [
|
|
2182
|
-
...((
|
|
2281
|
+
...((_c = (_b = state.softConfig.categories) == null ? void 0 : _b[category]) == null ? void 0 : _c.components) || [],
|
|
2183
2282
|
key
|
|
2184
2283
|
]
|
|
2185
2284
|
})
|
|
2186
|
-
}) : state.softConfig.categories
|
|
2285
|
+
}) : state.softConfig.categories || {}
|
|
2187
2286
|
})
|
|
2188
2287
|
};
|
|
2189
2288
|
});
|
|
@@ -2253,6 +2352,7 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2253
2352
|
if (!versionedComponent) continue;
|
|
2254
2353
|
const newConfig = createVersionedComponentConfig(
|
|
2255
2354
|
dependentName,
|
|
2355
|
+
dependent.name || dependentName,
|
|
2256
2356
|
defaultVersion,
|
|
2257
2357
|
allVersions,
|
|
2258
2358
|
config,
|
|
@@ -2362,7 +2462,12 @@ var SoftConfigProvider = ({
|
|
|
2362
2462
|
setEditVisibility(doc, { mode: "remodel", editableIds: state.editableComponentIds });
|
|
2363
2463
|
return;
|
|
2364
2464
|
}
|
|
2365
|
-
|
|
2465
|
+
requestAnimationFrame(() => {
|
|
2466
|
+
const freshDoc = store.getState().getIframeDoc();
|
|
2467
|
+
if (freshDoc) {
|
|
2468
|
+
clearEditVisibility(freshDoc);
|
|
2469
|
+
}
|
|
2470
|
+
});
|
|
2366
2471
|
});
|
|
2367
2472
|
return () => {
|
|
2368
2473
|
unsubscribe();
|
|
@@ -2760,7 +2865,7 @@ var useSetDefaultVersion = () => {
|
|
|
2760
2865
|
// src/puck/overrides/Header.tsx
|
|
2761
2866
|
import { Button, createUsePuck as createUsePuck10 } from "@measured/puck";
|
|
2762
2867
|
|
|
2763
|
-
// css-module:/media/
|
|
2868
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/Header.module.css#css-module
|
|
2764
2869
|
var Header_module_default = { "Header": "_Header_19oj9_1" };
|
|
2765
2870
|
|
|
2766
2871
|
// src/puck/actions/usePublish.tsx
|
|
@@ -2806,9 +2911,10 @@ var Header = ({
|
|
|
2806
2911
|
onPublish,
|
|
2807
2912
|
children
|
|
2808
2913
|
}) => {
|
|
2809
|
-
const { handleComplete,
|
|
2914
|
+
const { handleComplete, newComponent, setNewComponent } = useComplete();
|
|
2810
2915
|
const { handleCancel, canCancel } = useCancel();
|
|
2811
2916
|
const { handlePublish } = usePublish();
|
|
2917
|
+
const puck = usePuck((s) => s.config);
|
|
2812
2918
|
useInspect(newComponent);
|
|
2813
2919
|
return /* @__PURE__ */ jsx8("div", { className: getClassName2(), children: canCancel ? /* @__PURE__ */ jsxs2(Fragment3, { children: [
|
|
2814
2920
|
/* @__PURE__ */ jsx8(Button, { onClick: handleCancel, children: "Cancel" }),
|
|
@@ -2840,10 +2946,11 @@ var Header = ({
|
|
|
2840
2946
|
};
|
|
2841
2947
|
|
|
2842
2948
|
// src/puck/overrides/ActionBar.tsx
|
|
2949
|
+
import { useMemo as useMemo3 } from "react";
|
|
2843
2950
|
import { ActionBar, createUsePuck as createUsePuck11 } from "@measured/puck";
|
|
2844
2951
|
import { Combine, ComponentIcon, EditIcon } from "lucide-react";
|
|
2845
2952
|
|
|
2846
|
-
// css-module:/media/
|
|
2953
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/ActionBar.module.css#css-module
|
|
2847
2954
|
var ActionBar_module_default = { "ActionBar": "_ActionBar_pvuie_5", "ActionBar-label": "_ActionBar-label_pvuie_39", "ActionBar-action": "_ActionBar-action_pvuie_63", "ActionBar-group": "_ActionBar-group_pvuie_79" };
|
|
2848
2955
|
|
|
2849
2956
|
// src/puck/overrides/ActionBar.tsx
|
|
@@ -2856,11 +2963,22 @@ var ActionBarOverride = (props) => {
|
|
|
2856
2963
|
const { handleBuild } = useBuild();
|
|
2857
2964
|
const { handleRemodel } = useRemodel();
|
|
2858
2965
|
const { handleDecompose } = useDecompose();
|
|
2966
|
+
const overrides = useSoftConfig((s) => s.overrides);
|
|
2859
2967
|
const softComponents = useSoftConfig((s) => s.softComponents, shallow);
|
|
2860
2968
|
const editableIds = useSoftConfig((s) => s.editableComponentIds);
|
|
2861
2969
|
const selectedItem = usePuck2((s) => s.selectedItem);
|
|
2862
2970
|
const status = useSoftConfig((s) => s.state);
|
|
2863
|
-
const
|
|
2971
|
+
const softKeys = Object.keys(softComponents);
|
|
2972
|
+
const key = useMemo3(() => createComponentKeyFromName(props.label || "", overrides, {
|
|
2973
|
+
existingKeys: softKeys,
|
|
2974
|
+
state: status
|
|
2975
|
+
}), [
|
|
2976
|
+
props.label,
|
|
2977
|
+
overrides,
|
|
2978
|
+
softKeys,
|
|
2979
|
+
status
|
|
2980
|
+
]);
|
|
2981
|
+
const isSoftComponent2 = softKeys.includes(key);
|
|
2864
2982
|
const selectedId = (_a = selectedItem == null ? void 0 : selectedItem.props) == null ? void 0 : _a.id;
|
|
2865
2983
|
const isEditable = Boolean(selectedId && editableIds.has(selectedId));
|
|
2866
2984
|
return /* @__PURE__ */ jsx9("div", { className: getClassName3(), children: /* @__PURE__ */ jsxs3(ActionBar, { children: [
|
|
@@ -2873,7 +2991,7 @@ var ActionBarOverride = (props) => {
|
|
|
2873
2991
|
/* @__PURE__ */ jsx9(
|
|
2874
2992
|
ActionBar.Action,
|
|
2875
2993
|
{
|
|
2876
|
-
onClick: () => handleRemodel(
|
|
2994
|
+
onClick: () => handleRemodel(key),
|
|
2877
2995
|
label: "Remodel Soft Component",
|
|
2878
2996
|
children: /* @__PURE__ */ jsx9(EditIcon, { size: 16 })
|
|
2879
2997
|
}
|
|
@@ -2921,14 +3039,14 @@ var confirm = (message) => __async(null, null, function* () {
|
|
|
2921
3039
|
}
|
|
2922
3040
|
});
|
|
2923
3041
|
|
|
2924
|
-
// css-module:/media/
|
|
3042
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/ComponentItem.module.css#css-module
|
|
2925
3043
|
var ComponentItem_module_default = { "ComponentItem": "_ComponentItem_1kbi2_1", "ComponentItem--insertDisabled": "_ComponentItem--insertDisabled_1kbi2_14", "ComponentItem-content": "_ComponentItem-content_1kbi2_21", "ComponentItem-name": "_ComponentItem-name_1kbi2_31", "ComponentItem-version": "_ComponentItem-version_1kbi2_35", "ComponentItem-actions": "_ComponentItem-actions_1kbi2_40", "ComponentItem-settingsButton": "_ComponentItem-settingsButton_1kbi2_46", "ComponentItem-grip": "_ComponentItem-grip_1kbi2_56", "ComponentItem-modal": "_ComponentItem-modal_1kbi2_63", "ComponentItem-modalHeader": "_ComponentItem-modalHeader_1kbi2_70", "ComponentItem-modalTitle": "_ComponentItem-modalTitle_1kbi2_75", "ComponentItem-modalSubtitle": "_ComponentItem-modalSubtitle_1kbi2_82", "ComponentItem-modalBody": "_ComponentItem-modalBody_1kbi2_88", "ComponentItem-section": "_ComponentItem-section_1kbi2_97", "ComponentItem-sectionTitle": "_ComponentItem-sectionTitle_1kbi2_103", "ComponentItem-sectionDescription": "_ComponentItem-sectionDescription_1kbi2_110", "ComponentItem-versionList": "_ComponentItem-versionList_1kbi2_116", "ComponentItem-versionRow": "_ComponentItem-versionRow_1kbi2_122", "ComponentItem-versionRow--isDefault": "_ComponentItem-versionRow--isDefault_1kbi2_133", "ComponentItem-versionRow--isMarkedForDeletion": "_ComponentItem-versionRow--isMarkedForDeletion_1kbi2_138", "ComponentItem-versionInfo": "_ComponentItem-versionInfo_1kbi2_143", "ComponentItem-versionNumber": "_ComponentItem-versionNumber_1kbi2_150", "ComponentItem-defaultBadge": "_ComponentItem-defaultBadge_1kbi2_156", "ComponentItem-deleteBadge": "_ComponentItem-deleteBadge_1kbi2_167", "ComponentItem-versionActions": "_ComponentItem-versionActions_1kbi2_178", "ComponentItem-migrationOptions": "_ComponentItem-migrationOptions_1kbi2_184", "ComponentItem-select": "_ComponentItem-select_1kbi2_188", "ComponentItem-modalFooter": "_ComponentItem-modalFooter_1kbi2_209", "ComponentItem-footerLeft": "_ComponentItem-footerLeft_1kbi2_218", "ComponentItem-footerRight": "_ComponentItem-footerRight_1kbi2_223" };
|
|
2926
3044
|
|
|
2927
3045
|
// src/puck/components/modal/index.tsx
|
|
2928
3046
|
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
2929
3047
|
import { createPortal } from "react-dom";
|
|
2930
3048
|
|
|
2931
|
-
// css-module:/media/
|
|
3049
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/modal/styles.module.css#css-module
|
|
2932
3050
|
var styles_module_default2 = { "Modal": "_Modal_pvj02_1", "Modal--isOpen": "_Modal--isOpen_pvj02_29", "Modal-inner": "_Modal-inner_pvj02_37" };
|
|
2933
3051
|
|
|
2934
3052
|
// src/puck/components/modal/index.tsx
|
|
@@ -2965,6 +3083,8 @@ import { Fragment as Fragment5, jsx as jsx11, jsxs as jsxs4 } from "react/jsx-ru
|
|
|
2965
3083
|
var getClassName5 = get_class_name_factory_default("ComponentItem", ComponentItem_module_default);
|
|
2966
3084
|
var usePuck3 = createUsePuck12();
|
|
2967
3085
|
var ComponentItem = (props) => {
|
|
3086
|
+
const componentMeta = useSoftConfig((s) => s.softComponents[props.name]);
|
|
3087
|
+
const displayName = (componentMeta == null ? void 0 : componentMeta.name) || props.name;
|
|
2968
3088
|
const softComponents = new Set(
|
|
2969
3089
|
Object.keys(useSoftConfig((s) => s.softComponents, shallow2))
|
|
2970
3090
|
);
|
|
@@ -3027,7 +3147,7 @@ var ComponentItem = (props) => {
|
|
|
3027
3147
|
};
|
|
3028
3148
|
const handleDemolishClick = () => __async(null, null, function* () {
|
|
3029
3149
|
const confirmed = yield confirm(
|
|
3030
|
-
`Demolish "${
|
|
3150
|
+
`Demolish "${displayName}" entirely? This will remove all versions.`
|
|
3031
3151
|
);
|
|
3032
3152
|
if (confirmed) {
|
|
3033
3153
|
handleDemolish(props.name);
|
|
@@ -3045,7 +3165,7 @@ var ComponentItem = (props) => {
|
|
|
3045
3165
|
onMouseLeave: () => setIsHovering(false),
|
|
3046
3166
|
children: [
|
|
3047
3167
|
/* @__PURE__ */ jsxs4("div", { className: getClassName5("content"), children: [
|
|
3048
|
-
/* @__PURE__ */ jsx11("div", { className: getClassName5("name"), children:
|
|
3168
|
+
/* @__PURE__ */ jsx11("div", { className: getClassName5("name"), children: displayName }),
|
|
3049
3169
|
useVersioning && /* @__PURE__ */ jsxs4("div", { className: getClassName5("version"), children: [
|
|
3050
3170
|
"v",
|
|
3051
3171
|
defaultVersion
|
|
@@ -3072,7 +3192,7 @@ var ComponentItem = (props) => {
|
|
|
3072
3192
|
),
|
|
3073
3193
|
/* @__PURE__ */ jsx11(Modal, { isOpen: isEditing, onClose: handleCancel, children: /* @__PURE__ */ jsxs4("div", { className: getClassName5("modal"), children: [
|
|
3074
3194
|
/* @__PURE__ */ jsxs4("div", { className: getClassName5("modalHeader"), children: [
|
|
3075
|
-
/* @__PURE__ */ jsx11("h2", { className: getClassName5("modalTitle"), children:
|
|
3195
|
+
/* @__PURE__ */ jsx11("h2", { className: getClassName5("modalTitle"), children: displayName }),
|
|
3076
3196
|
/* @__PURE__ */ jsx11("p", { className: getClassName5("modalSubtitle"), children: "Component Settings" })
|
|
3077
3197
|
] }),
|
|
3078
3198
|
/* @__PURE__ */ jsx11("div", { className: getClassName5("modalBody"), children: useVersioning ? /* @__PURE__ */ jsxs4(Fragment5, { children: [
|
|
@@ -3132,7 +3252,7 @@ var ComponentItem = (props) => {
|
|
|
3132
3252
|
] })
|
|
3133
3253
|
] }) : /* @__PURE__ */ jsx11("div", { className: getClassName5("section"), children: /* @__PURE__ */ jsxs4("p", { children: [
|
|
3134
3254
|
"Manage high-level settings for the ",
|
|
3135
|
-
/* @__PURE__ */ jsx11("strong", { children:
|
|
3255
|
+
/* @__PURE__ */ jsx11("strong", { children: displayName }),
|
|
3136
3256
|
" component."
|
|
3137
3257
|
] }) }) }),
|
|
3138
3258
|
/* @__PURE__ */ jsxs4("div", { className: getClassName5("modalFooter"), children: [
|