@netlisian/softconfig 0.1.0 → 0.1.2
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 +95 -38
- package/dist/puck/index.d.mts +54 -13
- package/dist/puck/index.d.ts +54 -13
- package/dist/puck/index.js +358 -110
- package/dist/puck/index.mjs +346 -101
- package/package.json +1 -1
package/dist/puck/index.js
CHANGED
|
@@ -82,6 +82,9 @@ var puck_exports = {};
|
|
|
82
82
|
__export(puck_exports, {
|
|
83
83
|
ActionBar: () => ActionBarOverride,
|
|
84
84
|
ComponentItem: () => ComponentItem,
|
|
85
|
+
ComponentList: () => Drawer,
|
|
86
|
+
Drawer: () => Drawer,
|
|
87
|
+
DrawerItem: () => DrawerItem,
|
|
85
88
|
Header: () => Header,
|
|
86
89
|
Modal: () => Modal,
|
|
87
90
|
SoftConfigProvider: () => SoftConfigProvider,
|
|
@@ -358,13 +361,27 @@ var updateVersion = (version, increment) => {
|
|
|
358
361
|
};
|
|
359
362
|
var builderRootConfig = (config, overrides, editingComponent, showVersionFields = true) => ({
|
|
360
363
|
fields: {
|
|
361
|
-
|
|
362
|
-
// type: "slot",
|
|
363
|
-
// },
|
|
364
|
-
_name: {
|
|
364
|
+
_name: overrides.name || {
|
|
365
365
|
type: "text",
|
|
366
366
|
label: "Soft Component Name"
|
|
367
367
|
},
|
|
368
|
+
_category: overrides.categories || {
|
|
369
|
+
type: "select",
|
|
370
|
+
label: "Category",
|
|
371
|
+
options: [
|
|
372
|
+
...Object.keys(config.categories || {}).map((cat) => {
|
|
373
|
+
var _a;
|
|
374
|
+
return {
|
|
375
|
+
label: ((_a = config.categories) == null ? void 0 : _a[cat].title) || cat,
|
|
376
|
+
value: cat
|
|
377
|
+
};
|
|
378
|
+
}) || [],
|
|
379
|
+
{
|
|
380
|
+
label: Object.keys(config.categories || {}).length ? "Other" : "Uncategorized",
|
|
381
|
+
value: void 0
|
|
382
|
+
}
|
|
383
|
+
]
|
|
384
|
+
},
|
|
368
385
|
_fields: {
|
|
369
386
|
type: "array",
|
|
370
387
|
label: "Fields",
|
|
@@ -434,7 +451,9 @@ var builderRootConfig = (config, overrides, editingComponent, showVersionFields
|
|
|
434
451
|
}
|
|
435
452
|
return fields;
|
|
436
453
|
},
|
|
437
|
-
resolveData: (props) => {
|
|
454
|
+
resolveData: (props, params) => {
|
|
455
|
+
if (overrides.onRootsDataChange)
|
|
456
|
+
overrides.onRootsDataChange(props, params);
|
|
438
457
|
return {
|
|
439
458
|
props,
|
|
440
459
|
readOnly: Boolean(editingComponent) ? {
|
|
@@ -605,7 +624,7 @@ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (op
|
|
|
605
624
|
};
|
|
606
625
|
var get_class_name_factory_default = getClassNameFactory;
|
|
607
626
|
|
|
608
|
-
// css-module:/media/
|
|
627
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/error-boundary/styles.module.css#css-module
|
|
609
628
|
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" };
|
|
610
629
|
|
|
611
630
|
// src/puck/components/error-boundary/index.tsx
|
|
@@ -814,7 +833,8 @@ var builderConfig = (config, overrides, editingComponent, showVersionFields = tr
|
|
|
814
833
|
return acc;
|
|
815
834
|
},
|
|
816
835
|
{}
|
|
817
|
-
)
|
|
836
|
+
),
|
|
837
|
+
categories: config.categories || {}
|
|
818
838
|
});
|
|
819
839
|
|
|
820
840
|
// src/puck/lib/strip-id.ts
|
|
@@ -940,7 +960,7 @@ var softFieldsToPuckFields = (fields, fieldSettings) => {
|
|
|
940
960
|
{}
|
|
941
961
|
)) || {};
|
|
942
962
|
};
|
|
943
|
-
var softComponentFromAppState = (appState, configComponents, editedItem) => {
|
|
963
|
+
var softComponentFromAppState = (appState, configComponents, editedItem, metadata) => {
|
|
944
964
|
var _a;
|
|
945
965
|
const rootProps = ((_a = appState.data.root) == null ? void 0 : _a.props) || {};
|
|
946
966
|
const fields = rootProps._fields || [];
|
|
@@ -961,6 +981,8 @@ var softComponentFromAppState = (appState, configComponents, editedItem) => {
|
|
|
961
981
|
)), slots);
|
|
962
982
|
return [
|
|
963
983
|
{
|
|
984
|
+
name: metadata.name,
|
|
985
|
+
category: metadata.category,
|
|
964
986
|
fields: __spreadValues(__spreadValues({}, softFieldsToPuckFields(fields, field_settings)), Object.keys(slots).reduce((acc, slot) => {
|
|
965
987
|
acc[slot] = { type: "slot", label: slot };
|
|
966
988
|
return acc;
|
|
@@ -1096,7 +1118,7 @@ var reconstructComponents = (subComponents, componentConfigs, softComponentProps
|
|
|
1096
1118
|
return componentData;
|
|
1097
1119
|
});
|
|
1098
1120
|
};
|
|
1099
|
-
var softComponentToAppState = (softComponent, componentName, version, versions, componentProps, componentConfigs) => {
|
|
1121
|
+
var softComponentToAppState = (softComponent, componentName, version, versions, componentProps, componentConfigs, displayName, category) => {
|
|
1100
1122
|
const slots = new Set(Object.keys(softComponent.slots));
|
|
1101
1123
|
const { fields, fieldSettings } = puckFieldsToSoftFields(
|
|
1102
1124
|
softComponent.fields,
|
|
@@ -1108,7 +1130,8 @@ var softComponentToAppState = (softComponent, componentName, version, versions,
|
|
|
1108
1130
|
}
|
|
1109
1131
|
});
|
|
1110
1132
|
const rootProps = {
|
|
1111
|
-
_name: componentName,
|
|
1133
|
+
_name: displayName || componentName,
|
|
1134
|
+
_category: category,
|
|
1112
1135
|
_version: version,
|
|
1113
1136
|
_versions: versions,
|
|
1114
1137
|
_fields: fields,
|
|
@@ -1257,10 +1280,11 @@ function SoftRender({
|
|
|
1257
1280
|
|
|
1258
1281
|
// src/puck/lib/create-versioned-component-config.tsx
|
|
1259
1282
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1260
|
-
var createVersionedComponentConfig = (componentName, version, allVersions, config, softComponents, defaultProps, showVersioning = true) => {
|
|
1283
|
+
var createVersionedComponentConfig = (componentName, displayName, version, allVersions, config, softComponents, defaultProps, showVersioning = true) => {
|
|
1261
1284
|
var _a, _b;
|
|
1262
1285
|
const softConfig = config;
|
|
1263
1286
|
return {
|
|
1287
|
+
label: displayName,
|
|
1264
1288
|
fields: Object.fromEntries(
|
|
1265
1289
|
(Object.entries(
|
|
1266
1290
|
(_b = (_a = softComponents[componentName].versions) == null ? void 0 : _a[version]) == null ? void 0 : _b.fields
|
|
@@ -1406,31 +1430,46 @@ function demolishSoftComponent(componentName, data, config, softComponents) {
|
|
|
1406
1430
|
};
|
|
1407
1431
|
}
|
|
1408
1432
|
|
|
1433
|
+
// src/puck/lib/component-key.ts
|
|
1434
|
+
var defaultToCamelCase = (value) => {
|
|
1435
|
+
const tokens = value.trim().replace(/[^a-zA-Z0-9\s_-]/g, " ").split(/[\s_-]+/).filter(Boolean);
|
|
1436
|
+
if (tokens.length === 0) return "";
|
|
1437
|
+
const [first, ...rest] = tokens;
|
|
1438
|
+
return `${first.toLowerCase()}${rest.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase()).join("")}`;
|
|
1439
|
+
};
|
|
1440
|
+
var createComponentKeyFromName = (displayName, overrides, context) => {
|
|
1441
|
+
const key = overrides.componentNameToKey ? overrides.componentNameToKey(displayName, context) : defaultToCamelCase(displayName);
|
|
1442
|
+
return key.trim();
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1409
1445
|
// src/puck/store/slices/builder.tsx
|
|
1410
1446
|
var createBuildersSlice = (set, get, initialConfig) => ({
|
|
1411
|
-
build: (history, selectedItem, itemSelector, puckDispatch) => {
|
|
1447
|
+
build: (history, selectedItem, itemSelector, puckDispatch, name) => {
|
|
1412
1448
|
if (!selectedItem || !itemSelector) {
|
|
1413
1449
|
throw new Error("No item selected to build from.");
|
|
1414
1450
|
}
|
|
1415
1451
|
puckDispatch({
|
|
1416
1452
|
type: "set",
|
|
1417
|
-
state: (previous) =>
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1453
|
+
state: (previous) => {
|
|
1454
|
+
var _a;
|
|
1455
|
+
return {
|
|
1456
|
+
ui: __spreadProps(__spreadValues({}, previous.ui), {
|
|
1457
|
+
itemSelector: null
|
|
1458
|
+
}),
|
|
1459
|
+
data: __spreadProps(__spreadValues({}, previous.data), {
|
|
1460
|
+
root: __spreadProps(__spreadValues({}, previous.data.root), {
|
|
1461
|
+
props: __spreadProps(__spreadValues({}, (_a = previous.data.root) == null ? void 0 : _a.props), {
|
|
1462
|
+
_name: name || "New Soft Component"
|
|
1463
|
+
})
|
|
1464
|
+
})
|
|
1465
|
+
// content: [{ ...selectedItem }],
|
|
1466
|
+
})
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1430
1469
|
});
|
|
1431
1470
|
const config = __spreadValues({}, get().softConfig);
|
|
1432
1471
|
const overrides = get().overrides;
|
|
1433
|
-
const buildConfig = builderConfig(config, overrides,
|
|
1472
|
+
const buildConfig = builderConfig(config, overrides, void 0, get().showVersionFields);
|
|
1434
1473
|
const editableIds = /* @__PURE__ */ new Set([selectedItem.props.id]);
|
|
1435
1474
|
const initialContent = [__spreadValues({}, selectedItem)];
|
|
1436
1475
|
(0, import_puck4.walkTree)(
|
|
@@ -1463,7 +1502,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1463
1502
|
type: "replaceRoot",
|
|
1464
1503
|
root: {
|
|
1465
1504
|
title: "Soft Component Builder",
|
|
1466
|
-
_name: "New Soft Component"
|
|
1505
|
+
_name: name || "New Soft Component"
|
|
1467
1506
|
}
|
|
1468
1507
|
}),
|
|
1469
1508
|
100
|
|
@@ -1480,6 +1519,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1480
1519
|
}
|
|
1481
1520
|
const softComponentVersion = ((_a = selectedItem.props) == null ? void 0 : _a.version) || "1.0.0";
|
|
1482
1521
|
const softComponent = (_b = get().softComponents[softComponentName]) == null ? void 0 : _b.versions[softComponentVersion];
|
|
1522
|
+
const softComponentMeta = get().softComponents[softComponentName];
|
|
1483
1523
|
const versions = Object.keys(
|
|
1484
1524
|
get().softComponents[softComponentName].versions || {}
|
|
1485
1525
|
);
|
|
@@ -1500,12 +1540,12 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1500
1540
|
softComponentVersion,
|
|
1501
1541
|
versions,
|
|
1502
1542
|
selectedItem.props,
|
|
1503
|
-
get().softConfig.components
|
|
1543
|
+
get().softConfig.components,
|
|
1544
|
+
(softComponentMeta == null ? void 0 : softComponentMeta.name) || softComponentName,
|
|
1545
|
+
softComponentMeta == null ? void 0 : softComponentMeta.category
|
|
1504
1546
|
);
|
|
1505
1547
|
const config = __spreadValues({}, get().softConfig);
|
|
1506
1548
|
const overrides = get().overrides;
|
|
1507
|
-
const getStore = () => get();
|
|
1508
|
-
const getEditableIds = () => getStore().editableComponentIds;
|
|
1509
1549
|
const dependents = get().dependencyGraph.get(softComponentName) || /* @__PURE__ */ new Set();
|
|
1510
1550
|
const buildConfig = builderConfig(config, overrides, softComponentName, get().showVersionFields, dependents);
|
|
1511
1551
|
const editableIds = /* @__PURE__ */ new Set([]);
|
|
@@ -1561,19 +1601,20 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1561
1601
|
type: "replaceRoot",
|
|
1562
1602
|
root: {
|
|
1563
1603
|
title: root.props.title,
|
|
1564
|
-
_name: root.props.
|
|
1604
|
+
_name: root.props._name,
|
|
1605
|
+
_category: root.props._category
|
|
1565
1606
|
}
|
|
1566
1607
|
}),
|
|
1567
1608
|
100
|
|
1568
1609
|
);
|
|
1569
1610
|
},
|
|
1570
1611
|
complete: (appState, setHistories, getItemBySelector) => {
|
|
1571
|
-
var _a, _b;
|
|
1612
|
+
var _a, _b, _c, _d, _e;
|
|
1572
1613
|
if (get().state === "ready") {
|
|
1573
1614
|
throw new Error("Not building or remodeling a component.");
|
|
1574
1615
|
}
|
|
1575
|
-
const
|
|
1576
|
-
if (!
|
|
1616
|
+
const displayName = (_c = (_b = (_a = appState.data.root) == null ? void 0 : _a.props) == null ? void 0 : _b._name) == null ? void 0 : _c.trim();
|
|
1617
|
+
if (!displayName) {
|
|
1577
1618
|
throw new Error("Root component must have a name to compose.");
|
|
1578
1619
|
}
|
|
1579
1620
|
const itemSelector = get().itemSelector;
|
|
@@ -1586,42 +1627,73 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1586
1627
|
if (!selectedItem) {
|
|
1587
1628
|
throw new Error("Cannot find item being edited");
|
|
1588
1629
|
}
|
|
1589
|
-
const
|
|
1630
|
+
const rootCategory = (_e = (_d = appState.data.root) == null ? void 0 : _d.props) == null ? void 0 : _e._category;
|
|
1631
|
+
const componentName = createComponentKeyFromName(displayName, get().overrides, {
|
|
1632
|
+
existingKeys: Object.keys(get().softComponents),
|
|
1633
|
+
state: get().state
|
|
1634
|
+
});
|
|
1635
|
+
if (!componentName) {
|
|
1636
|
+
throw new Error("Failed to generate component key from name.");
|
|
1637
|
+
}
|
|
1638
|
+
const [newSoftComponentConfig, version] = get().builder.compose(
|
|
1639
|
+
appState,
|
|
1640
|
+
componentName,
|
|
1641
|
+
selectedItem,
|
|
1642
|
+
displayName,
|
|
1643
|
+
rootCategory
|
|
1644
|
+
) || [];
|
|
1590
1645
|
if (!newSoftComponentConfig) {
|
|
1591
1646
|
throw new Error("Failed to compose new soft component config.");
|
|
1592
1647
|
}
|
|
1593
1648
|
const storedHistories = get().originalHistory;
|
|
1594
1649
|
setHistories([...storedHistories]);
|
|
1595
1650
|
const config = __spreadValues({}, get().softConfig || initialConfig);
|
|
1596
|
-
set((s) =>
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1651
|
+
set((s) => {
|
|
1652
|
+
var _a2, _b2;
|
|
1653
|
+
const nextComponents = __spreadProps(__spreadValues({}, Object.entries(config.components).reduce(
|
|
1654
|
+
(acc, [name, component]) => {
|
|
1655
|
+
var _a3;
|
|
1656
|
+
let tempComponent = (_a3 = config.components) == null ? void 0 : _a3[name];
|
|
1657
|
+
if (tempComponent) {
|
|
1658
|
+
acc[name] = tempComponent;
|
|
1659
|
+
acc[name].render = tempComponent.render;
|
|
1660
|
+
} else {
|
|
1661
|
+
tempComponent = __spreadValues({}, component);
|
|
1662
|
+
tempComponent == null ? true : delete tempComponent.resolvePermissions;
|
|
1663
|
+
tempComponent == null ? true : delete tempComponent.resolveData;
|
|
1664
|
+
acc[name] = tempComponent;
|
|
1665
|
+
}
|
|
1666
|
+
return acc;
|
|
1667
|
+
},
|
|
1668
|
+
{}
|
|
1669
|
+
)), {
|
|
1670
|
+
[componentName]: __spreadValues({}, newSoftComponentConfig)
|
|
1671
|
+
});
|
|
1672
|
+
const categories = get().softConfig.categories || {};
|
|
1673
|
+
const nextCategories = rootCategory ? __spreadProps(__spreadValues({}, categories), {
|
|
1674
|
+
[rootCategory]: __spreadProps(__spreadValues({}, categories[rootCategory] || {}), {
|
|
1675
|
+
title: ((_a2 = categories[rootCategory]) == null ? void 0 : _a2.title) || rootCategory,
|
|
1676
|
+
components: Array.from(
|
|
1677
|
+
/* @__PURE__ */ new Set([
|
|
1678
|
+
...((_b2 = categories[rootCategory]) == null ? void 0 : _b2.components) || [],
|
|
1679
|
+
componentName
|
|
1680
|
+
])
|
|
1681
|
+
)
|
|
1617
1682
|
})
|
|
1618
|
-
})
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1683
|
+
}) : categories;
|
|
1684
|
+
return __spreadProps(__spreadValues({}, s), {
|
|
1685
|
+
softConfig: __spreadProps(__spreadValues({}, config), {
|
|
1686
|
+
root: __spreadValues({}, initialConfig.root),
|
|
1687
|
+
components: nextComponents,
|
|
1688
|
+
categories: nextCategories
|
|
1689
|
+
}),
|
|
1690
|
+
storedConfig: void 0,
|
|
1691
|
+
state: "inspecting",
|
|
1692
|
+
originalHistory: [],
|
|
1693
|
+
editingComponentId: null,
|
|
1694
|
+
editableComponentIds: /* @__PURE__ */ new Set()
|
|
1695
|
+
});
|
|
1696
|
+
});
|
|
1625
1697
|
get().rebuildDependents(componentName, version);
|
|
1626
1698
|
return componentName;
|
|
1627
1699
|
},
|
|
@@ -1668,7 +1740,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1668
1740
|
editableComponentIds: /* @__PURE__ */ new Set()
|
|
1669
1741
|
}));
|
|
1670
1742
|
},
|
|
1671
|
-
compose: (appState, componentName, editedItem) => {
|
|
1743
|
+
compose: (appState, componentName, editedItem, displayName, category) => {
|
|
1672
1744
|
if (!componentName) {
|
|
1673
1745
|
throw new Error("Root component must have a name to compose.");
|
|
1674
1746
|
}
|
|
@@ -1678,12 +1750,21 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1678
1750
|
`Component name "${componentName}" already exists in the configuration.`
|
|
1679
1751
|
);
|
|
1680
1752
|
}
|
|
1681
|
-
const [softComponent, version] = softComponentFromAppState(
|
|
1753
|
+
const [softComponent, version] = softComponentFromAppState(
|
|
1754
|
+
appState,
|
|
1755
|
+
componentConfigs,
|
|
1756
|
+
editedItem,
|
|
1757
|
+
{
|
|
1758
|
+
name: displayName,
|
|
1759
|
+
category
|
|
1760
|
+
}
|
|
1761
|
+
);
|
|
1682
1762
|
const existingComponent = get().softComponents[componentName];
|
|
1683
1763
|
const allVersions = Object.keys((existingComponent == null ? void 0 : existingComponent.versions) || {});
|
|
1684
1764
|
const isNewVersion = !allVersions.includes(version);
|
|
1685
1765
|
const newSoftComponentConfig = createVersionedComponentConfig(
|
|
1686
1766
|
componentName,
|
|
1767
|
+
displayName,
|
|
1687
1768
|
version,
|
|
1688
1769
|
isNewVersion ? [...allVersions, version] : allVersions,
|
|
1689
1770
|
get().softConfig,
|
|
@@ -1731,6 +1812,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1731
1812
|
throw new Error("Can only switch versions during remodeling.");
|
|
1732
1813
|
}
|
|
1733
1814
|
const softComponent = (_a = get().softComponents[componentName]) == null ? void 0 : _a.versions[newVersion];
|
|
1815
|
+
const softComponentMeta = get().softComponents[componentName];
|
|
1734
1816
|
if (!softComponent) {
|
|
1735
1817
|
throw new Error(
|
|
1736
1818
|
`Soft component "${componentName}" with version "${newVersion}" not found.`
|
|
@@ -1745,7 +1827,9 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1745
1827
|
newVersion,
|
|
1746
1828
|
versions,
|
|
1747
1829
|
currentProps,
|
|
1748
|
-
get().softConfig.components
|
|
1830
|
+
get().softConfig.components,
|
|
1831
|
+
(softComponentMeta == null ? void 0 : softComponentMeta.name) || componentName,
|
|
1832
|
+
softComponentMeta == null ? void 0 : softComponentMeta.category
|
|
1749
1833
|
);
|
|
1750
1834
|
puckDispatch({
|
|
1751
1835
|
type: "setData",
|
|
@@ -1797,10 +1881,11 @@ function hydrateSoftComponentsTransforms(softComponents, hydrator) {
|
|
|
1797
1881
|
})
|
|
1798
1882
|
});
|
|
1799
1883
|
});
|
|
1800
|
-
hydrated[name] = {
|
|
1884
|
+
hydrated[name] = __spreadProps(__spreadValues({}, comp), {
|
|
1885
|
+
name: comp.name || name,
|
|
1801
1886
|
defaultVersion: comp.defaultVersion,
|
|
1802
1887
|
versions
|
|
1803
|
-
};
|
|
1888
|
+
});
|
|
1804
1889
|
});
|
|
1805
1890
|
return hydrated;
|
|
1806
1891
|
}
|
|
@@ -1920,6 +2005,7 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides, showV
|
|
|
1920
2005
|
}
|
|
1921
2006
|
const newSoftComponentConfig = createVersionedComponentConfig(
|
|
1922
2007
|
name,
|
|
2008
|
+
comp.name || name,
|
|
1923
2009
|
defaultVersion || "1.0.0",
|
|
1924
2010
|
allVersions,
|
|
1925
2011
|
buildingConfig,
|
|
@@ -1948,6 +2034,7 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides, showV
|
|
|
1948
2034
|
}
|
|
1949
2035
|
const newSoftComponentConfig = createVersionedComponentConfig(
|
|
1950
2036
|
name,
|
|
2037
|
+
comp.name || name,
|
|
1951
2038
|
defaultVersion || "1.0.0",
|
|
1952
2039
|
allVersions,
|
|
1953
2040
|
hardConfig,
|
|
@@ -2020,11 +2107,19 @@ var clearEditVisibility = (doc) => {
|
|
|
2020
2107
|
var createSoftConfigStore = (hardConfig = {
|
|
2021
2108
|
components: {}
|
|
2022
2109
|
}, softComponents = {}, overrides = {}, onActions, showVersionFields = true) => {
|
|
2110
|
+
const normalizedSoftComponents = Object.fromEntries(
|
|
2111
|
+
Object.entries(softComponents || {}).map(([key, value]) => [
|
|
2112
|
+
key,
|
|
2113
|
+
__spreadProps(__spreadValues({}, value), {
|
|
2114
|
+
name: value.name || key
|
|
2115
|
+
})
|
|
2116
|
+
])
|
|
2117
|
+
);
|
|
2023
2118
|
const iframeDocRef = { current: null };
|
|
2024
2119
|
const hydratedSoftComponents = (overrides == null ? void 0 : overrides.hydrateMapTransform) ? hydrateSoftComponentsTransforms(
|
|
2025
|
-
|
|
2120
|
+
normalizedSoftComponents,
|
|
2026
2121
|
overrides.hydrateMapTransform
|
|
2027
|
-
) :
|
|
2122
|
+
) : normalizedSoftComponents;
|
|
2028
2123
|
const initialDependencyGraph = buildReverseDependencyGraph(
|
|
2029
2124
|
hydratedSoftComponents
|
|
2030
2125
|
);
|
|
@@ -2075,19 +2170,23 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2075
2170
|
hardConfig,
|
|
2076
2171
|
hydratedSoftComponents,
|
|
2077
2172
|
overrides
|
|
2078
|
-
))
|
|
2173
|
+
)),
|
|
2174
|
+
categories: __spreadValues({}, hardConfig.categories || {})
|
|
2079
2175
|
}),
|
|
2080
2176
|
setSoftComponent: (name, version, component) => {
|
|
2177
|
+
const existing = get().softComponents[name];
|
|
2081
2178
|
set((state) => {
|
|
2082
|
-
var _a;
|
|
2179
|
+
var _a, _b;
|
|
2083
2180
|
return {
|
|
2084
2181
|
softComponents: __spreadProps(__spreadValues({}, state.softComponents), {
|
|
2085
|
-
[name]: {
|
|
2182
|
+
[name]: __spreadProps(__spreadValues({}, existing), {
|
|
2183
|
+
name: component.name || (existing == null ? void 0 : existing.name) || name,
|
|
2184
|
+
category: (_a = component.category) != null ? _a : existing == null ? void 0 : existing.category,
|
|
2086
2185
|
defaultVersion: version,
|
|
2087
|
-
versions: __spreadProps(__spreadValues({}, ((
|
|
2186
|
+
versions: __spreadProps(__spreadValues({}, ((_b = state.softComponents[name]) == null ? void 0 : _b.versions) || {}), {
|
|
2088
2187
|
[version]: component
|
|
2089
2188
|
})
|
|
2090
|
-
}
|
|
2189
|
+
})
|
|
2091
2190
|
})
|
|
2092
2191
|
};
|
|
2093
2192
|
});
|
|
@@ -2099,14 +2198,17 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2099
2198
|
Object.entries(incomingComponents).forEach(([name, data]) => {
|
|
2100
2199
|
const existing = nextSoftComponents[name];
|
|
2101
2200
|
const finalComponentData = existing ? __spreadProps(__spreadValues(__spreadValues({}, existing), data), {
|
|
2201
|
+
name: data.name || existing.name || name,
|
|
2102
2202
|
versions: __spreadValues(__spreadValues({}, existing.versions), data.versions)
|
|
2103
2203
|
}) : data;
|
|
2204
|
+
finalComponentData.name = finalComponentData.name || name;
|
|
2104
2205
|
nextSoftComponents[name] = finalComponentData;
|
|
2105
2206
|
const activeVersion = finalComponentData.defaultVersion;
|
|
2106
2207
|
const activeVersionData = finalComponentData.versions[activeVersion];
|
|
2107
2208
|
if (activeVersionData) {
|
|
2108
2209
|
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
2109
2210
|
name,
|
|
2211
|
+
finalComponentData.name || name,
|
|
2110
2212
|
activeVersion,
|
|
2111
2213
|
Object.keys(finalComponentData.versions),
|
|
2112
2214
|
state.softConfig,
|
|
@@ -2137,6 +2239,7 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2137
2239
|
if (activeVersionData) {
|
|
2138
2240
|
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
2139
2241
|
name,
|
|
2242
|
+
componentData.name || name,
|
|
2140
2243
|
activeVersion,
|
|
2141
2244
|
Object.keys(componentData.versions),
|
|
2142
2245
|
softConfig,
|
|
@@ -2154,11 +2257,12 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2154
2257
|
});
|
|
2155
2258
|
},
|
|
2156
2259
|
setSoftComponentDefaultVersion: (name, version) => {
|
|
2157
|
-
var _a, _b, _c;
|
|
2260
|
+
var _a, _b, _c, _d;
|
|
2158
2261
|
const softComponent = (_b = (_a = get().softComponents[name]) == null ? void 0 : _a.versions) == null ? void 0 : _b[version];
|
|
2159
2262
|
const allVersions = Object.keys(
|
|
2160
2263
|
((_c = get().softComponents[name]) == null ? void 0 : _c.versions) || {}
|
|
2161
2264
|
);
|
|
2265
|
+
const displayName = ((_d = get().softComponents[name]) == null ? void 0 : _d.name) || name;
|
|
2162
2266
|
if (!softComponent) {
|
|
2163
2267
|
throw new Error(
|
|
2164
2268
|
`Soft component "${name}" version "${version}" does not exist.`
|
|
@@ -2166,6 +2270,7 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2166
2270
|
}
|
|
2167
2271
|
const newSoftComponentConfig = createVersionedComponentConfig(
|
|
2168
2272
|
name,
|
|
2273
|
+
displayName,
|
|
2169
2274
|
version,
|
|
2170
2275
|
allVersions,
|
|
2171
2276
|
get().softConfig,
|
|
@@ -2219,20 +2324,20 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2219
2324
|
},
|
|
2220
2325
|
setSoftComponentConfig: (key, config, category) => {
|
|
2221
2326
|
set((state) => {
|
|
2222
|
-
var _a;
|
|
2327
|
+
var _a, _b, _c;
|
|
2223
2328
|
return {
|
|
2224
2329
|
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
2225
2330
|
components: __spreadProps(__spreadValues({}, state.softConfig.components), {
|
|
2226
2331
|
[key]: __spreadValues({}, config)
|
|
2227
2332
|
}),
|
|
2228
|
-
categories: category
|
|
2229
|
-
[category]: __spreadProps(__spreadValues({}, state.softConfig.categories[category]), {
|
|
2333
|
+
categories: category ? __spreadProps(__spreadValues({}, state.softConfig.categories || {}), {
|
|
2334
|
+
[category]: __spreadProps(__spreadValues({}, ((_a = state.softConfig.categories) == null ? void 0 : _a[category]) || {}), {
|
|
2230
2335
|
components: [
|
|
2231
|
-
...((
|
|
2336
|
+
...((_c = (_b = state.softConfig.categories) == null ? void 0 : _b[category]) == null ? void 0 : _c.components) || [],
|
|
2232
2337
|
key
|
|
2233
2338
|
]
|
|
2234
2339
|
})
|
|
2235
|
-
}) : state.softConfig.categories
|
|
2340
|
+
}) : state.softConfig.categories || {}
|
|
2236
2341
|
})
|
|
2237
2342
|
};
|
|
2238
2343
|
});
|
|
@@ -2302,6 +2407,7 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2302
2407
|
if (!versionedComponent) continue;
|
|
2303
2408
|
const newConfig = createVersionedComponentConfig(
|
|
2304
2409
|
dependentName,
|
|
2410
|
+
dependent.name || dependentName,
|
|
2305
2411
|
defaultVersion,
|
|
2306
2412
|
allVersions,
|
|
2307
2413
|
config,
|
|
@@ -2411,7 +2517,12 @@ var SoftConfigProvider = ({
|
|
|
2411
2517
|
setEditVisibility(doc, { mode: "remodel", editableIds: state.editableComponentIds });
|
|
2412
2518
|
return;
|
|
2413
2519
|
}
|
|
2414
|
-
|
|
2520
|
+
requestAnimationFrame(() => {
|
|
2521
|
+
const freshDoc = store.getState().getIframeDoc();
|
|
2522
|
+
if (freshDoc) {
|
|
2523
|
+
clearEditVisibility(freshDoc);
|
|
2524
|
+
}
|
|
2525
|
+
});
|
|
2415
2526
|
});
|
|
2416
2527
|
return () => {
|
|
2417
2528
|
unsubscribe();
|
|
@@ -2467,7 +2578,7 @@ var useActionEvent = () => {
|
|
|
2467
2578
|
|
|
2468
2579
|
// src/puck/actions/useBuild.tsx
|
|
2469
2580
|
var useCustomPuck2 = (0, import_puck5.createUsePuck)();
|
|
2470
|
-
var useBuild = () => {
|
|
2581
|
+
var useBuild = (name) => {
|
|
2471
2582
|
const build = useSoftConfig((s) => s.builder.build);
|
|
2472
2583
|
const history = useCustomPuck2((s) => s.history.histories);
|
|
2473
2584
|
const selectedItem = useCustomPuck2((s) => s.selectedItem);
|
|
@@ -2481,7 +2592,7 @@ var useBuild = () => {
|
|
|
2481
2592
|
return;
|
|
2482
2593
|
}
|
|
2483
2594
|
try {
|
|
2484
|
-
build(history, selectedItem, itemSelector, dispatch);
|
|
2595
|
+
build(history, selectedItem, itemSelector, dispatch, name);
|
|
2485
2596
|
if (selectedItem == null ? void 0 : selectedItem.type) {
|
|
2486
2597
|
void triggerAction({
|
|
2487
2598
|
type: "build",
|
|
@@ -2809,7 +2920,7 @@ var useSetDefaultVersion = () => {
|
|
|
2809
2920
|
// src/puck/overrides/Header.tsx
|
|
2810
2921
|
var import_puck13 = require("@measured/puck");
|
|
2811
2922
|
|
|
2812
|
-
// css-module:/media/
|
|
2923
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/Header.module.css#css-module
|
|
2813
2924
|
var Header_module_default = { "Header": "_Header_19oj9_1" };
|
|
2814
2925
|
|
|
2815
2926
|
// src/puck/actions/usePublish.tsx
|
|
@@ -2855,9 +2966,10 @@ var Header = ({
|
|
|
2855
2966
|
onPublish,
|
|
2856
2967
|
children
|
|
2857
2968
|
}) => {
|
|
2858
|
-
const { handleComplete,
|
|
2969
|
+
const { handleComplete, newComponent, setNewComponent } = useComplete();
|
|
2859
2970
|
const { handleCancel, canCancel } = useCancel();
|
|
2860
2971
|
const { handlePublish } = usePublish();
|
|
2972
|
+
const puck = usePuck((s) => s.config);
|
|
2861
2973
|
useInspect(newComponent);
|
|
2862
2974
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName2(), children: canCancel ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
2863
2975
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_puck13.Button, { onClick: handleCancel, children: "Cancel" }),
|
|
@@ -2889,10 +3001,11 @@ var Header = ({
|
|
|
2889
3001
|
};
|
|
2890
3002
|
|
|
2891
3003
|
// src/puck/overrides/ActionBar.tsx
|
|
3004
|
+
var import_react9 = require("react");
|
|
2892
3005
|
var import_puck14 = require("@measured/puck");
|
|
2893
3006
|
var import_lucide_react = require("lucide-react");
|
|
2894
3007
|
|
|
2895
|
-
// css-module:/media/
|
|
3008
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/ActionBar.module.css#css-module
|
|
2896
3009
|
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" };
|
|
2897
3010
|
|
|
2898
3011
|
// src/puck/overrides/ActionBar.tsx
|
|
@@ -2902,14 +3015,25 @@ var getClassName3 = get_class_name_factory_default("ActionBar", ActionBar_module
|
|
|
2902
3015
|
var usePuck2 = (0, import_puck14.createUsePuck)();
|
|
2903
3016
|
var ActionBarOverride = (props) => {
|
|
2904
3017
|
var _a;
|
|
2905
|
-
const { handleBuild } = useBuild();
|
|
3018
|
+
const { handleBuild } = useBuild("Custom Name");
|
|
2906
3019
|
const { handleRemodel } = useRemodel();
|
|
2907
3020
|
const { handleDecompose } = useDecompose();
|
|
3021
|
+
const overrides = useSoftConfig((s) => s.overrides);
|
|
2908
3022
|
const softComponents = useSoftConfig((s) => s.softComponents, import_shallow.shallow);
|
|
2909
3023
|
const editableIds = useSoftConfig((s) => s.editableComponentIds);
|
|
2910
3024
|
const selectedItem = usePuck2((s) => s.selectedItem);
|
|
2911
3025
|
const status = useSoftConfig((s) => s.state);
|
|
2912
|
-
const
|
|
3026
|
+
const softKeys = Object.keys(softComponents);
|
|
3027
|
+
const key = (0, import_react9.useMemo)(() => createComponentKeyFromName(props.label || "", overrides, {
|
|
3028
|
+
existingKeys: softKeys,
|
|
3029
|
+
state: status
|
|
3030
|
+
}), [
|
|
3031
|
+
props.label,
|
|
3032
|
+
overrides,
|
|
3033
|
+
softKeys,
|
|
3034
|
+
status
|
|
3035
|
+
]);
|
|
3036
|
+
const isSoftComponent2 = softKeys.includes(key);
|
|
2913
3037
|
const selectedId = (_a = selectedItem == null ? void 0 : selectedItem.props) == null ? void 0 : _a.id;
|
|
2914
3038
|
const isEditable = Boolean(selectedId && editableIds.has(selectedId));
|
|
2915
3039
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName3(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck14.ActionBar, { children: [
|
|
@@ -2922,7 +3046,7 @@ var ActionBarOverride = (props) => {
|
|
|
2922
3046
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2923
3047
|
import_puck14.ActionBar.Action,
|
|
2924
3048
|
{
|
|
2925
|
-
onClick: () => handleRemodel(
|
|
3049
|
+
onClick: () => handleRemodel(key),
|
|
2926
3050
|
label: "Remodel Soft Component",
|
|
2927
3051
|
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react.EditIcon, { size: 16 })
|
|
2928
3052
|
}
|
|
@@ -2948,8 +3072,8 @@ var ActionBarOverride = (props) => {
|
|
|
2948
3072
|
] }) });
|
|
2949
3073
|
};
|
|
2950
3074
|
|
|
2951
|
-
// src/puck/overrides/
|
|
2952
|
-
var
|
|
3075
|
+
// src/puck/overrides/DrawerItem.tsx
|
|
3076
|
+
var import_react11 = require("react");
|
|
2953
3077
|
var import_puck15 = require("@measured/puck");
|
|
2954
3078
|
var import_lucide_react2 = require("lucide-react");
|
|
2955
3079
|
|
|
@@ -2970,14 +3094,14 @@ var confirm = (message) => __async(null, null, function* () {
|
|
|
2970
3094
|
}
|
|
2971
3095
|
});
|
|
2972
3096
|
|
|
2973
|
-
// css-module:/media/
|
|
2974
|
-
var
|
|
3097
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/DrawerItem.module.css#css-module
|
|
3098
|
+
var DrawerItem_module_default = { "DrawerItem": "_DrawerItem_29z19_1", "DrawerItem--insertDisabled": "_DrawerItem--insertDisabled_29z19_14", "DrawerItem-content": "_DrawerItem-content_29z19_21", "DrawerItem-name": "_DrawerItem-name_29z19_31", "DrawerItem-version": "_DrawerItem-version_29z19_35", "DrawerItem-actions": "_DrawerItem-actions_29z19_40", "DrawerItem-settingsButton": "_DrawerItem-settingsButton_29z19_46", "DrawerItem-grip": "_DrawerItem-grip_29z19_56", "DrawerItem-modal": "_DrawerItem-modal_29z19_63", "DrawerItem-modalHeader": "_DrawerItem-modalHeader_29z19_70", "DrawerItem-modalTitle": "_DrawerItem-modalTitle_29z19_75", "DrawerItem-modalSubtitle": "_DrawerItem-modalSubtitle_29z19_82", "DrawerItem-modalBody": "_DrawerItem-modalBody_29z19_88", "DrawerItem-section": "_DrawerItem-section_29z19_97", "DrawerItem-sectionTitle": "_DrawerItem-sectionTitle_29z19_103", "DrawerItem-sectionDescription": "_DrawerItem-sectionDescription_29z19_110", "DrawerItem-versionList": "_DrawerItem-versionList_29z19_116", "DrawerItem-versionRow": "_DrawerItem-versionRow_29z19_122", "DrawerItem-versionRow--isDefault": "_DrawerItem-versionRow--isDefault_29z19_133", "DrawerItem-versionRow--isMarkedForDeletion": "_DrawerItem-versionRow--isMarkedForDeletion_29z19_138", "DrawerItem-versionInfo": "_DrawerItem-versionInfo_29z19_143", "DrawerItem-versionNumber": "_DrawerItem-versionNumber_29z19_150", "DrawerItem-defaultBadge": "_DrawerItem-defaultBadge_29z19_156", "DrawerItem-deleteBadge": "_DrawerItem-deleteBadge_29z19_167", "DrawerItem-versionActions": "_DrawerItem-versionActions_29z19_178", "DrawerItem-migrationOptions": "_DrawerItem-migrationOptions_29z19_184", "DrawerItem-select": "_DrawerItem-select_29z19_188", "DrawerItem-modalFooter": "_DrawerItem-modalFooter_29z19_209", "DrawerItem-footerLeft": "_DrawerItem-footerLeft_29z19_218", "DrawerItem-footerRight": "_DrawerItem-footerRight_29z19_223" };
|
|
2975
3099
|
|
|
2976
3100
|
// src/puck/components/modal/index.tsx
|
|
2977
|
-
var
|
|
3101
|
+
var import_react10 = require("react");
|
|
2978
3102
|
var import_react_dom = require("react-dom");
|
|
2979
3103
|
|
|
2980
|
-
// css-module:/media/
|
|
3104
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/modal/styles.module.css#css-module
|
|
2981
3105
|
var styles_module_default2 = { "Modal": "_Modal_pvj02_1", "Modal--isOpen": "_Modal--isOpen_pvj02_29", "Modal-inner": "_Modal-inner_pvj02_37" };
|
|
2982
3106
|
|
|
2983
3107
|
// src/puck/components/modal/index.tsx
|
|
@@ -2988,8 +3112,8 @@ var Modal = ({
|
|
|
2988
3112
|
onClose,
|
|
2989
3113
|
isOpen
|
|
2990
3114
|
}) => {
|
|
2991
|
-
const [rootEl, setRootEl] = (0,
|
|
2992
|
-
(0,
|
|
3115
|
+
const [rootEl, setRootEl] = (0, import_react10.useState)(null);
|
|
3116
|
+
(0, import_react10.useEffect)(() => {
|
|
2993
3117
|
setRootEl(document.getElementById("puck-portal-root"));
|
|
2994
3118
|
}, []);
|
|
2995
3119
|
if (!rootEl) {
|
|
@@ -3008,12 +3132,14 @@ var Modal = ({
|
|
|
3008
3132
|
);
|
|
3009
3133
|
};
|
|
3010
3134
|
|
|
3011
|
-
// src/puck/overrides/
|
|
3135
|
+
// src/puck/overrides/DrawerItem.tsx
|
|
3012
3136
|
var import_shallow2 = require("zustand/shallow");
|
|
3013
3137
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3014
|
-
var getClassName5 = get_class_name_factory_default("
|
|
3138
|
+
var getClassName5 = get_class_name_factory_default("DrawerItem", DrawerItem_module_default);
|
|
3015
3139
|
var usePuck3 = (0, import_puck15.createUsePuck)();
|
|
3016
|
-
var
|
|
3140
|
+
var DrawerItem = (props) => {
|
|
3141
|
+
const componentMeta = useSoftConfig((s) => s.softComponents[props.name]);
|
|
3142
|
+
const displayName = (componentMeta == null ? void 0 : componentMeta.name) || props.name;
|
|
3017
3143
|
const softComponents = new Set(
|
|
3018
3144
|
Object.keys(useSoftConfig((s) => s.softComponents, import_shallow2.shallow))
|
|
3019
3145
|
);
|
|
@@ -3024,13 +3150,13 @@ var ComponentItem = (props) => {
|
|
|
3024
3150
|
);
|
|
3025
3151
|
const { handleDemolish } = useDemolish();
|
|
3026
3152
|
const { handleSetDefaultVersion, getVersions, getDefaultVersion } = useSetDefaultVersion();
|
|
3027
|
-
const [isEditing, setIsEditing] = (0,
|
|
3028
|
-
const [isHovering, setIsHovering] = (0,
|
|
3029
|
-
const [selectedVersion, setSelectedVersion] = (0,
|
|
3030
|
-
const [versionsToDelete, setVersionsToDelete] = (0,
|
|
3153
|
+
const [isEditing, setIsEditing] = (0, import_react11.useState)(false);
|
|
3154
|
+
const [isHovering, setIsHovering] = (0, import_react11.useState)(false);
|
|
3155
|
+
const [selectedVersion, setSelectedVersion] = (0, import_react11.useState)("");
|
|
3156
|
+
const [versionsToDelete, setVersionsToDelete] = (0, import_react11.useState)(
|
|
3031
3157
|
/* @__PURE__ */ new Set()
|
|
3032
3158
|
);
|
|
3033
|
-
const [migrateVersionMap, setMigrateVersionMap] = (0,
|
|
3159
|
+
const [migrateVersionMap, setMigrateVersionMap] = (0, import_react11.useState)({});
|
|
3034
3160
|
const useVersioning = useSoftConfig((s) => s.showVersionFields);
|
|
3035
3161
|
const versions = getVersions(props.name);
|
|
3036
3162
|
const defaultVersion = getDefaultVersion(props.name);
|
|
@@ -3076,7 +3202,7 @@ var ComponentItem = (props) => {
|
|
|
3076
3202
|
};
|
|
3077
3203
|
const handleDemolishClick = () => __async(null, null, function* () {
|
|
3078
3204
|
const confirmed = yield confirm(
|
|
3079
|
-
`Demolish "${
|
|
3205
|
+
`Demolish "${displayName}" entirely? This will remove all versions.`
|
|
3080
3206
|
);
|
|
3081
3207
|
if (confirmed) {
|
|
3082
3208
|
handleDemolish(props.name);
|
|
@@ -3094,7 +3220,7 @@ var ComponentItem = (props) => {
|
|
|
3094
3220
|
onMouseLeave: () => setIsHovering(false),
|
|
3095
3221
|
children: [
|
|
3096
3222
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("content"), children: [
|
|
3097
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("name"), children:
|
|
3223
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("name"), children: displayName }),
|
|
3098
3224
|
useVersioning && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("version"), children: [
|
|
3099
3225
|
"v",
|
|
3100
3226
|
defaultVersion
|
|
@@ -3121,7 +3247,7 @@ var ComponentItem = (props) => {
|
|
|
3121
3247
|
),
|
|
3122
3248
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Modal, { isOpen: isEditing, onClose: handleCancel, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("modal"), children: [
|
|
3123
3249
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("modalHeader"), children: [
|
|
3124
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h2", { className: getClassName5("modalTitle"), children:
|
|
3250
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h2", { className: getClassName5("modalTitle"), children: displayName }),
|
|
3125
3251
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: getClassName5("modalSubtitle"), children: "Component Settings" })
|
|
3126
3252
|
] }),
|
|
3127
3253
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("modalBody"), children: useVersioning ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
@@ -3160,6 +3286,7 @@ var ComponentItem = (props) => {
|
|
|
3160
3286
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("migrationOptions"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
3161
3287
|
"select",
|
|
3162
3288
|
{
|
|
3289
|
+
title: "Select migration version",
|
|
3163
3290
|
className: getClassName5("select"),
|
|
3164
3291
|
value: migrateVersionMap[Array.from(versionsToDelete)[0]] || "decompose",
|
|
3165
3292
|
onChange: (e) => {
|
|
@@ -3181,7 +3308,7 @@ var ComponentItem = (props) => {
|
|
|
3181
3308
|
] })
|
|
3182
3309
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("section"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
|
|
3183
3310
|
"Manage high-level settings for the ",
|
|
3184
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("strong", { children:
|
|
3311
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("strong", { children: displayName }),
|
|
3185
3312
|
" component."
|
|
3186
3313
|
] }) }) }),
|
|
3187
3314
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("modalFooter"), children: [
|
|
@@ -3205,6 +3332,124 @@ var ComponentItem = (props) => {
|
|
|
3205
3332
|
}
|
|
3206
3333
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: props.children });
|
|
3207
3334
|
};
|
|
3335
|
+
var ComponentItem = DrawerItem;
|
|
3336
|
+
|
|
3337
|
+
// src/puck/overrides/Drawer.tsx
|
|
3338
|
+
var import_react12 = require("react");
|
|
3339
|
+
var import_puck16 = require("@measured/puck");
|
|
3340
|
+
var import_lucide_react3 = require("lucide-react");
|
|
3341
|
+
|
|
3342
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/Drawer.module.css#css-module
|
|
3343
|
+
var Drawer_module_default = { "Drawer": "_Drawer_12zq5_1", "Drawer-category": "_Drawer-category_12zq5_7", "Drawer-category--isExpanded": "_Drawer-category--isExpanded_12zq5_15", "Drawer-categoryContent": "_Drawer-categoryContent_12zq5_19", "Drawer-categoryTitle": "_Drawer-categoryTitle_12zq5_27", "Drawer-categoryTitleIcon": "_Drawer-categoryTitleIcon_12zq5_63" };
|
|
3344
|
+
|
|
3345
|
+
// src/puck/overrides/Drawer.tsx
|
|
3346
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3347
|
+
var getClassName6 = get_class_name_factory_default("Drawer", Drawer_module_default);
|
|
3348
|
+
var getCategoryClassName = get_class_name_factory_default("Drawer-category", Drawer_module_default);
|
|
3349
|
+
var usePuck4 = (0, import_puck16.createUsePuck)();
|
|
3350
|
+
var CategorySection = ({
|
|
3351
|
+
id,
|
|
3352
|
+
title,
|
|
3353
|
+
componentKeys,
|
|
3354
|
+
getPermissions,
|
|
3355
|
+
expanded,
|
|
3356
|
+
onToggle
|
|
3357
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getCategoryClassName({ isExpanded: expanded }), children: [
|
|
3358
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3359
|
+
"button",
|
|
3360
|
+
{
|
|
3361
|
+
type: "button",
|
|
3362
|
+
className: getClassName6("categoryTitle"),
|
|
3363
|
+
onClick: () => onToggle(id),
|
|
3364
|
+
title: expanded ? `Collapse ${title}` : `Expand ${title}`,
|
|
3365
|
+
children: [
|
|
3366
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: title }),
|
|
3367
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: getClassName6("categoryTitleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.ChevronDown, { size: 12 }) })
|
|
3368
|
+
]
|
|
3369
|
+
}
|
|
3370
|
+
),
|
|
3371
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName6("categoryContent"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_puck16.Drawer, { children: componentKeys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3372
|
+
import_puck16.Drawer.Item,
|
|
3373
|
+
{
|
|
3374
|
+
name: key,
|
|
3375
|
+
isDragDisabled: !getPermissions({ type: key }).insert,
|
|
3376
|
+
children: DrawerItem
|
|
3377
|
+
},
|
|
3378
|
+
key
|
|
3379
|
+
)) }) })
|
|
3380
|
+
] });
|
|
3381
|
+
var Drawer = (_props) => {
|
|
3382
|
+
var _a, _b;
|
|
3383
|
+
const config = usePuck4((s) => s.config);
|
|
3384
|
+
const getPermissions = usePuck4((s) => s.getPermissions);
|
|
3385
|
+
const categories = (_a = config.categories) != null ? _a : {};
|
|
3386
|
+
const categorised = new Set(
|
|
3387
|
+
Object.values(categories).flatMap((cat) => {
|
|
3388
|
+
var _a2;
|
|
3389
|
+
return (_a2 = cat.components) != null ? _a2 : [];
|
|
3390
|
+
})
|
|
3391
|
+
);
|
|
3392
|
+
const allKeys = Object.keys(config.components);
|
|
3393
|
+
const otherKeys = allKeys.filter((k) => !categorised.has(k));
|
|
3394
|
+
const categoryEntries = Object.entries(categories).filter(
|
|
3395
|
+
([, cat]) => cat.visible !== false
|
|
3396
|
+
);
|
|
3397
|
+
const [expanded, setExpanded] = (0, import_react12.useState)(() => {
|
|
3398
|
+
const init = {};
|
|
3399
|
+
categoryEntries.forEach(([id, cat]) => {
|
|
3400
|
+
init[id] = cat.defaultExpanded !== false;
|
|
3401
|
+
});
|
|
3402
|
+
if (otherKeys.length > 0) init["__other__"] = true;
|
|
3403
|
+
return init;
|
|
3404
|
+
});
|
|
3405
|
+
const toggle = (id) => setExpanded((prev) => __spreadProps(__spreadValues({}, prev), { [id]: !prev[id] }));
|
|
3406
|
+
if (categoryEntries.length === 0) {
|
|
3407
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_puck16.Drawer, { children: allKeys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3408
|
+
import_puck16.Drawer.Item,
|
|
3409
|
+
{
|
|
3410
|
+
name: key,
|
|
3411
|
+
isDragDisabled: !getPermissions({ type: key }).insert,
|
|
3412
|
+
children: DrawerItem
|
|
3413
|
+
},
|
|
3414
|
+
key
|
|
3415
|
+
)) });
|
|
3416
|
+
}
|
|
3417
|
+
console.log(
|
|
3418
|
+
getClassName6(),
|
|
3419
|
+
getCategoryClassName(),
|
|
3420
|
+
getCategoryClassName({ isExpanded: true })
|
|
3421
|
+
);
|
|
3422
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName6(), children: [
|
|
3423
|
+
categoryEntries.map(([id, cat]) => {
|
|
3424
|
+
var _a2, _b2, _c;
|
|
3425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3426
|
+
CategorySection,
|
|
3427
|
+
{
|
|
3428
|
+
id,
|
|
3429
|
+
title: (_a2 = cat.title) != null ? _a2 : id,
|
|
3430
|
+
componentKeys: ((_b2 = cat.components) != null ? _b2 : []).filter(
|
|
3431
|
+
(k) => k in config.components
|
|
3432
|
+
),
|
|
3433
|
+
getPermissions,
|
|
3434
|
+
expanded: (_c = expanded[id]) != null ? _c : true,
|
|
3435
|
+
onToggle: toggle
|
|
3436
|
+
},
|
|
3437
|
+
id
|
|
3438
|
+
);
|
|
3439
|
+
}),
|
|
3440
|
+
otherKeys.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3441
|
+
CategorySection,
|
|
3442
|
+
{
|
|
3443
|
+
id: "__other__",
|
|
3444
|
+
title: "Other components",
|
|
3445
|
+
componentKeys: otherKeys,
|
|
3446
|
+
getPermissions,
|
|
3447
|
+
expanded: (_b = expanded["__other__"]) != null ? _b : true,
|
|
3448
|
+
onToggle: toggle
|
|
3449
|
+
}
|
|
3450
|
+
)
|
|
3451
|
+
] });
|
|
3452
|
+
};
|
|
3208
3453
|
|
|
3209
3454
|
// src/puck/lib/action-callback.ts
|
|
3210
3455
|
var createActionCallback = (validateAction, undo) => {
|
|
@@ -3432,6 +3677,9 @@ var resolveSoftConfig = (data, softComponents, config) => {
|
|
|
3432
3677
|
0 && (module.exports = {
|
|
3433
3678
|
ActionBar,
|
|
3434
3679
|
ComponentItem,
|
|
3680
|
+
ComponentList,
|
|
3681
|
+
Drawer,
|
|
3682
|
+
DrawerItem,
|
|
3435
3683
|
Header,
|
|
3436
3684
|
Modal,
|
|
3437
3685
|
SoftConfigProvider,
|