@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.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,31 +1378,46 @@ 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
|
}
|
|
1366
1399
|
puckDispatch({
|
|
1367
1400
|
type: "set",
|
|
1368
|
-
state: (previous) =>
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1401
|
+
state: (previous) => {
|
|
1402
|
+
var _a;
|
|
1403
|
+
return {
|
|
1404
|
+
ui: __spreadProps(__spreadValues({}, previous.ui), {
|
|
1405
|
+
itemSelector: null
|
|
1406
|
+
}),
|
|
1407
|
+
data: __spreadProps(__spreadValues({}, previous.data), {
|
|
1408
|
+
root: __spreadProps(__spreadValues({}, previous.data.root), {
|
|
1409
|
+
props: __spreadProps(__spreadValues({}, (_a = previous.data.root) == null ? void 0 : _a.props), {
|
|
1410
|
+
_name: name || "New Soft Component"
|
|
1411
|
+
})
|
|
1412
|
+
})
|
|
1413
|
+
// content: [{ ...selectedItem }],
|
|
1414
|
+
})
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1381
1417
|
});
|
|
1382
1418
|
const config = __spreadValues({}, get().softConfig);
|
|
1383
1419
|
const overrides = get().overrides;
|
|
1384
|
-
const buildConfig = builderConfig(config, overrides,
|
|
1420
|
+
const buildConfig = builderConfig(config, overrides, void 0, get().showVersionFields);
|
|
1385
1421
|
const editableIds = /* @__PURE__ */ new Set([selectedItem.props.id]);
|
|
1386
1422
|
const initialContent = [__spreadValues({}, selectedItem)];
|
|
1387
1423
|
walkTree3(
|
|
@@ -1414,7 +1450,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1414
1450
|
type: "replaceRoot",
|
|
1415
1451
|
root: {
|
|
1416
1452
|
title: "Soft Component Builder",
|
|
1417
|
-
_name: "New Soft Component"
|
|
1453
|
+
_name: name || "New Soft Component"
|
|
1418
1454
|
}
|
|
1419
1455
|
}),
|
|
1420
1456
|
100
|
|
@@ -1431,6 +1467,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1431
1467
|
}
|
|
1432
1468
|
const softComponentVersion = ((_a = selectedItem.props) == null ? void 0 : _a.version) || "1.0.0";
|
|
1433
1469
|
const softComponent = (_b = get().softComponents[softComponentName]) == null ? void 0 : _b.versions[softComponentVersion];
|
|
1470
|
+
const softComponentMeta = get().softComponents[softComponentName];
|
|
1434
1471
|
const versions = Object.keys(
|
|
1435
1472
|
get().softComponents[softComponentName].versions || {}
|
|
1436
1473
|
);
|
|
@@ -1451,12 +1488,12 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1451
1488
|
softComponentVersion,
|
|
1452
1489
|
versions,
|
|
1453
1490
|
selectedItem.props,
|
|
1454
|
-
get().softConfig.components
|
|
1491
|
+
get().softConfig.components,
|
|
1492
|
+
(softComponentMeta == null ? void 0 : softComponentMeta.name) || softComponentName,
|
|
1493
|
+
softComponentMeta == null ? void 0 : softComponentMeta.category
|
|
1455
1494
|
);
|
|
1456
1495
|
const config = __spreadValues({}, get().softConfig);
|
|
1457
1496
|
const overrides = get().overrides;
|
|
1458
|
-
const getStore = () => get();
|
|
1459
|
-
const getEditableIds = () => getStore().editableComponentIds;
|
|
1460
1497
|
const dependents = get().dependencyGraph.get(softComponentName) || /* @__PURE__ */ new Set();
|
|
1461
1498
|
const buildConfig = builderConfig(config, overrides, softComponentName, get().showVersionFields, dependents);
|
|
1462
1499
|
const editableIds = /* @__PURE__ */ new Set([]);
|
|
@@ -1512,19 +1549,20 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1512
1549
|
type: "replaceRoot",
|
|
1513
1550
|
root: {
|
|
1514
1551
|
title: root.props.title,
|
|
1515
|
-
_name: root.props.
|
|
1552
|
+
_name: root.props._name,
|
|
1553
|
+
_category: root.props._category
|
|
1516
1554
|
}
|
|
1517
1555
|
}),
|
|
1518
1556
|
100
|
|
1519
1557
|
);
|
|
1520
1558
|
},
|
|
1521
1559
|
complete: (appState, setHistories, getItemBySelector) => {
|
|
1522
|
-
var _a, _b;
|
|
1560
|
+
var _a, _b, _c, _d, _e;
|
|
1523
1561
|
if (get().state === "ready") {
|
|
1524
1562
|
throw new Error("Not building or remodeling a component.");
|
|
1525
1563
|
}
|
|
1526
|
-
const
|
|
1527
|
-
if (!
|
|
1564
|
+
const displayName = (_c = (_b = (_a = appState.data.root) == null ? void 0 : _a.props) == null ? void 0 : _b._name) == null ? void 0 : _c.trim();
|
|
1565
|
+
if (!displayName) {
|
|
1528
1566
|
throw new Error("Root component must have a name to compose.");
|
|
1529
1567
|
}
|
|
1530
1568
|
const itemSelector = get().itemSelector;
|
|
@@ -1537,42 +1575,73 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1537
1575
|
if (!selectedItem) {
|
|
1538
1576
|
throw new Error("Cannot find item being edited");
|
|
1539
1577
|
}
|
|
1540
|
-
const
|
|
1578
|
+
const rootCategory = (_e = (_d = appState.data.root) == null ? void 0 : _d.props) == null ? void 0 : _e._category;
|
|
1579
|
+
const componentName = createComponentKeyFromName(displayName, get().overrides, {
|
|
1580
|
+
existingKeys: Object.keys(get().softComponents),
|
|
1581
|
+
state: get().state
|
|
1582
|
+
});
|
|
1583
|
+
if (!componentName) {
|
|
1584
|
+
throw new Error("Failed to generate component key from name.");
|
|
1585
|
+
}
|
|
1586
|
+
const [newSoftComponentConfig, version] = get().builder.compose(
|
|
1587
|
+
appState,
|
|
1588
|
+
componentName,
|
|
1589
|
+
selectedItem,
|
|
1590
|
+
displayName,
|
|
1591
|
+
rootCategory
|
|
1592
|
+
) || [];
|
|
1541
1593
|
if (!newSoftComponentConfig) {
|
|
1542
1594
|
throw new Error("Failed to compose new soft component config.");
|
|
1543
1595
|
}
|
|
1544
1596
|
const storedHistories = get().originalHistory;
|
|
1545
1597
|
setHistories([...storedHistories]);
|
|
1546
1598
|
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
|
-
|
|
1599
|
+
set((s) => {
|
|
1600
|
+
var _a2, _b2;
|
|
1601
|
+
const nextComponents = __spreadProps(__spreadValues({}, Object.entries(config.components).reduce(
|
|
1602
|
+
(acc, [name, component]) => {
|
|
1603
|
+
var _a3;
|
|
1604
|
+
let tempComponent = (_a3 = config.components) == null ? void 0 : _a3[name];
|
|
1605
|
+
if (tempComponent) {
|
|
1606
|
+
acc[name] = tempComponent;
|
|
1607
|
+
acc[name].render = tempComponent.render;
|
|
1608
|
+
} else {
|
|
1609
|
+
tempComponent = __spreadValues({}, component);
|
|
1610
|
+
tempComponent == null ? true : delete tempComponent.resolvePermissions;
|
|
1611
|
+
tempComponent == null ? true : delete tempComponent.resolveData;
|
|
1612
|
+
acc[name] = tempComponent;
|
|
1613
|
+
}
|
|
1614
|
+
return acc;
|
|
1615
|
+
},
|
|
1616
|
+
{}
|
|
1617
|
+
)), {
|
|
1618
|
+
[componentName]: __spreadValues({}, newSoftComponentConfig)
|
|
1619
|
+
});
|
|
1620
|
+
const categories = get().softConfig.categories || {};
|
|
1621
|
+
const nextCategories = rootCategory ? __spreadProps(__spreadValues({}, categories), {
|
|
1622
|
+
[rootCategory]: __spreadProps(__spreadValues({}, categories[rootCategory] || {}), {
|
|
1623
|
+
title: ((_a2 = categories[rootCategory]) == null ? void 0 : _a2.title) || rootCategory,
|
|
1624
|
+
components: Array.from(
|
|
1625
|
+
/* @__PURE__ */ new Set([
|
|
1626
|
+
...((_b2 = categories[rootCategory]) == null ? void 0 : _b2.components) || [],
|
|
1627
|
+
componentName
|
|
1628
|
+
])
|
|
1629
|
+
)
|
|
1568
1630
|
})
|
|
1569
|
-
})
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1631
|
+
}) : categories;
|
|
1632
|
+
return __spreadProps(__spreadValues({}, s), {
|
|
1633
|
+
softConfig: __spreadProps(__spreadValues({}, config), {
|
|
1634
|
+
root: __spreadValues({}, initialConfig.root),
|
|
1635
|
+
components: nextComponents,
|
|
1636
|
+
categories: nextCategories
|
|
1637
|
+
}),
|
|
1638
|
+
storedConfig: void 0,
|
|
1639
|
+
state: "inspecting",
|
|
1640
|
+
originalHistory: [],
|
|
1641
|
+
editingComponentId: null,
|
|
1642
|
+
editableComponentIds: /* @__PURE__ */ new Set()
|
|
1643
|
+
});
|
|
1644
|
+
});
|
|
1576
1645
|
get().rebuildDependents(componentName, version);
|
|
1577
1646
|
return componentName;
|
|
1578
1647
|
},
|
|
@@ -1619,7 +1688,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1619
1688
|
editableComponentIds: /* @__PURE__ */ new Set()
|
|
1620
1689
|
}));
|
|
1621
1690
|
},
|
|
1622
|
-
compose: (appState, componentName, editedItem) => {
|
|
1691
|
+
compose: (appState, componentName, editedItem, displayName, category) => {
|
|
1623
1692
|
if (!componentName) {
|
|
1624
1693
|
throw new Error("Root component must have a name to compose.");
|
|
1625
1694
|
}
|
|
@@ -1629,12 +1698,21 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1629
1698
|
`Component name "${componentName}" already exists in the configuration.`
|
|
1630
1699
|
);
|
|
1631
1700
|
}
|
|
1632
|
-
const [softComponent, version] = softComponentFromAppState(
|
|
1701
|
+
const [softComponent, version] = softComponentFromAppState(
|
|
1702
|
+
appState,
|
|
1703
|
+
componentConfigs,
|
|
1704
|
+
editedItem,
|
|
1705
|
+
{
|
|
1706
|
+
name: displayName,
|
|
1707
|
+
category
|
|
1708
|
+
}
|
|
1709
|
+
);
|
|
1633
1710
|
const existingComponent = get().softComponents[componentName];
|
|
1634
1711
|
const allVersions = Object.keys((existingComponent == null ? void 0 : existingComponent.versions) || {});
|
|
1635
1712
|
const isNewVersion = !allVersions.includes(version);
|
|
1636
1713
|
const newSoftComponentConfig = createVersionedComponentConfig(
|
|
1637
1714
|
componentName,
|
|
1715
|
+
displayName,
|
|
1638
1716
|
version,
|
|
1639
1717
|
isNewVersion ? [...allVersions, version] : allVersions,
|
|
1640
1718
|
get().softConfig,
|
|
@@ -1682,6 +1760,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1682
1760
|
throw new Error("Can only switch versions during remodeling.");
|
|
1683
1761
|
}
|
|
1684
1762
|
const softComponent = (_a = get().softComponents[componentName]) == null ? void 0 : _a.versions[newVersion];
|
|
1763
|
+
const softComponentMeta = get().softComponents[componentName];
|
|
1685
1764
|
if (!softComponent) {
|
|
1686
1765
|
throw new Error(
|
|
1687
1766
|
`Soft component "${componentName}" with version "${newVersion}" not found.`
|
|
@@ -1696,7 +1775,9 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1696
1775
|
newVersion,
|
|
1697
1776
|
versions,
|
|
1698
1777
|
currentProps,
|
|
1699
|
-
get().softConfig.components
|
|
1778
|
+
get().softConfig.components,
|
|
1779
|
+
(softComponentMeta == null ? void 0 : softComponentMeta.name) || componentName,
|
|
1780
|
+
softComponentMeta == null ? void 0 : softComponentMeta.category
|
|
1700
1781
|
);
|
|
1701
1782
|
puckDispatch({
|
|
1702
1783
|
type: "setData",
|
|
@@ -1748,10 +1829,11 @@ function hydrateSoftComponentsTransforms(softComponents, hydrator) {
|
|
|
1748
1829
|
})
|
|
1749
1830
|
});
|
|
1750
1831
|
});
|
|
1751
|
-
hydrated[name] = {
|
|
1832
|
+
hydrated[name] = __spreadProps(__spreadValues({}, comp), {
|
|
1833
|
+
name: comp.name || name,
|
|
1752
1834
|
defaultVersion: comp.defaultVersion,
|
|
1753
1835
|
versions
|
|
1754
|
-
};
|
|
1836
|
+
});
|
|
1755
1837
|
});
|
|
1756
1838
|
return hydrated;
|
|
1757
1839
|
}
|
|
@@ -1871,6 +1953,7 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides, showV
|
|
|
1871
1953
|
}
|
|
1872
1954
|
const newSoftComponentConfig = createVersionedComponentConfig(
|
|
1873
1955
|
name,
|
|
1956
|
+
comp.name || name,
|
|
1874
1957
|
defaultVersion || "1.0.0",
|
|
1875
1958
|
allVersions,
|
|
1876
1959
|
buildingConfig,
|
|
@@ -1899,6 +1982,7 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides, showV
|
|
|
1899
1982
|
}
|
|
1900
1983
|
const newSoftComponentConfig = createVersionedComponentConfig(
|
|
1901
1984
|
name,
|
|
1985
|
+
comp.name || name,
|
|
1902
1986
|
defaultVersion || "1.0.0",
|
|
1903
1987
|
allVersions,
|
|
1904
1988
|
hardConfig,
|
|
@@ -1971,11 +2055,19 @@ var clearEditVisibility = (doc) => {
|
|
|
1971
2055
|
var createSoftConfigStore = (hardConfig = {
|
|
1972
2056
|
components: {}
|
|
1973
2057
|
}, softComponents = {}, overrides = {}, onActions, showVersionFields = true) => {
|
|
2058
|
+
const normalizedSoftComponents = Object.fromEntries(
|
|
2059
|
+
Object.entries(softComponents || {}).map(([key, value]) => [
|
|
2060
|
+
key,
|
|
2061
|
+
__spreadProps(__spreadValues({}, value), {
|
|
2062
|
+
name: value.name || key
|
|
2063
|
+
})
|
|
2064
|
+
])
|
|
2065
|
+
);
|
|
1974
2066
|
const iframeDocRef = { current: null };
|
|
1975
2067
|
const hydratedSoftComponents = (overrides == null ? void 0 : overrides.hydrateMapTransform) ? hydrateSoftComponentsTransforms(
|
|
1976
|
-
|
|
2068
|
+
normalizedSoftComponents,
|
|
1977
2069
|
overrides.hydrateMapTransform
|
|
1978
|
-
) :
|
|
2070
|
+
) : normalizedSoftComponents;
|
|
1979
2071
|
const initialDependencyGraph = buildReverseDependencyGraph(
|
|
1980
2072
|
hydratedSoftComponents
|
|
1981
2073
|
);
|
|
@@ -2026,19 +2118,23 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2026
2118
|
hardConfig,
|
|
2027
2119
|
hydratedSoftComponents,
|
|
2028
2120
|
overrides
|
|
2029
|
-
))
|
|
2121
|
+
)),
|
|
2122
|
+
categories: __spreadValues({}, hardConfig.categories || {})
|
|
2030
2123
|
}),
|
|
2031
2124
|
setSoftComponent: (name, version, component) => {
|
|
2125
|
+
const existing = get().softComponents[name];
|
|
2032
2126
|
set((state) => {
|
|
2033
|
-
var _a;
|
|
2127
|
+
var _a, _b;
|
|
2034
2128
|
return {
|
|
2035
2129
|
softComponents: __spreadProps(__spreadValues({}, state.softComponents), {
|
|
2036
|
-
[name]: {
|
|
2130
|
+
[name]: __spreadProps(__spreadValues({}, existing), {
|
|
2131
|
+
name: component.name || (existing == null ? void 0 : existing.name) || name,
|
|
2132
|
+
category: (_a = component.category) != null ? _a : existing == null ? void 0 : existing.category,
|
|
2037
2133
|
defaultVersion: version,
|
|
2038
|
-
versions: __spreadProps(__spreadValues({}, ((
|
|
2134
|
+
versions: __spreadProps(__spreadValues({}, ((_b = state.softComponents[name]) == null ? void 0 : _b.versions) || {}), {
|
|
2039
2135
|
[version]: component
|
|
2040
2136
|
})
|
|
2041
|
-
}
|
|
2137
|
+
})
|
|
2042
2138
|
})
|
|
2043
2139
|
};
|
|
2044
2140
|
});
|
|
@@ -2050,14 +2146,17 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2050
2146
|
Object.entries(incomingComponents).forEach(([name, data]) => {
|
|
2051
2147
|
const existing = nextSoftComponents[name];
|
|
2052
2148
|
const finalComponentData = existing ? __spreadProps(__spreadValues(__spreadValues({}, existing), data), {
|
|
2149
|
+
name: data.name || existing.name || name,
|
|
2053
2150
|
versions: __spreadValues(__spreadValues({}, existing.versions), data.versions)
|
|
2054
2151
|
}) : data;
|
|
2152
|
+
finalComponentData.name = finalComponentData.name || name;
|
|
2055
2153
|
nextSoftComponents[name] = finalComponentData;
|
|
2056
2154
|
const activeVersion = finalComponentData.defaultVersion;
|
|
2057
2155
|
const activeVersionData = finalComponentData.versions[activeVersion];
|
|
2058
2156
|
if (activeVersionData) {
|
|
2059
2157
|
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
2060
2158
|
name,
|
|
2159
|
+
finalComponentData.name || name,
|
|
2061
2160
|
activeVersion,
|
|
2062
2161
|
Object.keys(finalComponentData.versions),
|
|
2063
2162
|
state.softConfig,
|
|
@@ -2088,6 +2187,7 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2088
2187
|
if (activeVersionData) {
|
|
2089
2188
|
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
2090
2189
|
name,
|
|
2190
|
+
componentData.name || name,
|
|
2091
2191
|
activeVersion,
|
|
2092
2192
|
Object.keys(componentData.versions),
|
|
2093
2193
|
softConfig,
|
|
@@ -2105,11 +2205,12 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2105
2205
|
});
|
|
2106
2206
|
},
|
|
2107
2207
|
setSoftComponentDefaultVersion: (name, version) => {
|
|
2108
|
-
var _a, _b, _c;
|
|
2208
|
+
var _a, _b, _c, _d;
|
|
2109
2209
|
const softComponent = (_b = (_a = get().softComponents[name]) == null ? void 0 : _a.versions) == null ? void 0 : _b[version];
|
|
2110
2210
|
const allVersions = Object.keys(
|
|
2111
2211
|
((_c = get().softComponents[name]) == null ? void 0 : _c.versions) || {}
|
|
2112
2212
|
);
|
|
2213
|
+
const displayName = ((_d = get().softComponents[name]) == null ? void 0 : _d.name) || name;
|
|
2113
2214
|
if (!softComponent) {
|
|
2114
2215
|
throw new Error(
|
|
2115
2216
|
`Soft component "${name}" version "${version}" does not exist.`
|
|
@@ -2117,6 +2218,7 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2117
2218
|
}
|
|
2118
2219
|
const newSoftComponentConfig = createVersionedComponentConfig(
|
|
2119
2220
|
name,
|
|
2221
|
+
displayName,
|
|
2120
2222
|
version,
|
|
2121
2223
|
allVersions,
|
|
2122
2224
|
get().softConfig,
|
|
@@ -2170,20 +2272,20 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2170
2272
|
},
|
|
2171
2273
|
setSoftComponentConfig: (key, config, category) => {
|
|
2172
2274
|
set((state) => {
|
|
2173
|
-
var _a;
|
|
2275
|
+
var _a, _b, _c;
|
|
2174
2276
|
return {
|
|
2175
2277
|
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
2176
2278
|
components: __spreadProps(__spreadValues({}, state.softConfig.components), {
|
|
2177
2279
|
[key]: __spreadValues({}, config)
|
|
2178
2280
|
}),
|
|
2179
|
-
categories: category
|
|
2180
|
-
[category]: __spreadProps(__spreadValues({}, state.softConfig.categories[category]), {
|
|
2281
|
+
categories: category ? __spreadProps(__spreadValues({}, state.softConfig.categories || {}), {
|
|
2282
|
+
[category]: __spreadProps(__spreadValues({}, ((_a = state.softConfig.categories) == null ? void 0 : _a[category]) || {}), {
|
|
2181
2283
|
components: [
|
|
2182
|
-
...((
|
|
2284
|
+
...((_c = (_b = state.softConfig.categories) == null ? void 0 : _b[category]) == null ? void 0 : _c.components) || [],
|
|
2183
2285
|
key
|
|
2184
2286
|
]
|
|
2185
2287
|
})
|
|
2186
|
-
}) : state.softConfig.categories
|
|
2288
|
+
}) : state.softConfig.categories || {}
|
|
2187
2289
|
})
|
|
2188
2290
|
};
|
|
2189
2291
|
});
|
|
@@ -2253,6 +2355,7 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2253
2355
|
if (!versionedComponent) continue;
|
|
2254
2356
|
const newConfig = createVersionedComponentConfig(
|
|
2255
2357
|
dependentName,
|
|
2358
|
+
dependent.name || dependentName,
|
|
2256
2359
|
defaultVersion,
|
|
2257
2360
|
allVersions,
|
|
2258
2361
|
config,
|
|
@@ -2362,7 +2465,12 @@ var SoftConfigProvider = ({
|
|
|
2362
2465
|
setEditVisibility(doc, { mode: "remodel", editableIds: state.editableComponentIds });
|
|
2363
2466
|
return;
|
|
2364
2467
|
}
|
|
2365
|
-
|
|
2468
|
+
requestAnimationFrame(() => {
|
|
2469
|
+
const freshDoc = store.getState().getIframeDoc();
|
|
2470
|
+
if (freshDoc) {
|
|
2471
|
+
clearEditVisibility(freshDoc);
|
|
2472
|
+
}
|
|
2473
|
+
});
|
|
2366
2474
|
});
|
|
2367
2475
|
return () => {
|
|
2368
2476
|
unsubscribe();
|
|
@@ -2418,7 +2526,7 @@ var useActionEvent = () => {
|
|
|
2418
2526
|
|
|
2419
2527
|
// src/puck/actions/useBuild.tsx
|
|
2420
2528
|
var useCustomPuck2 = createUsePuck2();
|
|
2421
|
-
var useBuild = () => {
|
|
2529
|
+
var useBuild = (name) => {
|
|
2422
2530
|
const build = useSoftConfig((s) => s.builder.build);
|
|
2423
2531
|
const history = useCustomPuck2((s) => s.history.histories);
|
|
2424
2532
|
const selectedItem = useCustomPuck2((s) => s.selectedItem);
|
|
@@ -2432,7 +2540,7 @@ var useBuild = () => {
|
|
|
2432
2540
|
return;
|
|
2433
2541
|
}
|
|
2434
2542
|
try {
|
|
2435
|
-
build(history, selectedItem, itemSelector, dispatch);
|
|
2543
|
+
build(history, selectedItem, itemSelector, dispatch, name);
|
|
2436
2544
|
if (selectedItem == null ? void 0 : selectedItem.type) {
|
|
2437
2545
|
void triggerAction({
|
|
2438
2546
|
type: "build",
|
|
@@ -2760,7 +2868,7 @@ var useSetDefaultVersion = () => {
|
|
|
2760
2868
|
// src/puck/overrides/Header.tsx
|
|
2761
2869
|
import { Button, createUsePuck as createUsePuck10 } from "@measured/puck";
|
|
2762
2870
|
|
|
2763
|
-
// css-module:/media/
|
|
2871
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/Header.module.css#css-module
|
|
2764
2872
|
var Header_module_default = { "Header": "_Header_19oj9_1" };
|
|
2765
2873
|
|
|
2766
2874
|
// src/puck/actions/usePublish.tsx
|
|
@@ -2806,9 +2914,10 @@ var Header = ({
|
|
|
2806
2914
|
onPublish,
|
|
2807
2915
|
children
|
|
2808
2916
|
}) => {
|
|
2809
|
-
const { handleComplete,
|
|
2917
|
+
const { handleComplete, newComponent, setNewComponent } = useComplete();
|
|
2810
2918
|
const { handleCancel, canCancel } = useCancel();
|
|
2811
2919
|
const { handlePublish } = usePublish();
|
|
2920
|
+
const puck = usePuck((s) => s.config);
|
|
2812
2921
|
useInspect(newComponent);
|
|
2813
2922
|
return /* @__PURE__ */ jsx8("div", { className: getClassName2(), children: canCancel ? /* @__PURE__ */ jsxs2(Fragment3, { children: [
|
|
2814
2923
|
/* @__PURE__ */ jsx8(Button, { onClick: handleCancel, children: "Cancel" }),
|
|
@@ -2840,10 +2949,11 @@ var Header = ({
|
|
|
2840
2949
|
};
|
|
2841
2950
|
|
|
2842
2951
|
// src/puck/overrides/ActionBar.tsx
|
|
2952
|
+
import { useMemo as useMemo3 } from "react";
|
|
2843
2953
|
import { ActionBar, createUsePuck as createUsePuck11 } from "@measured/puck";
|
|
2844
2954
|
import { Combine, ComponentIcon, EditIcon } from "lucide-react";
|
|
2845
2955
|
|
|
2846
|
-
// css-module:/media/
|
|
2956
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/ActionBar.module.css#css-module
|
|
2847
2957
|
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
2958
|
|
|
2849
2959
|
// src/puck/overrides/ActionBar.tsx
|
|
@@ -2853,14 +2963,25 @@ var getClassName3 = get_class_name_factory_default("ActionBar", ActionBar_module
|
|
|
2853
2963
|
var usePuck2 = createUsePuck11();
|
|
2854
2964
|
var ActionBarOverride = (props) => {
|
|
2855
2965
|
var _a;
|
|
2856
|
-
const { handleBuild } = useBuild();
|
|
2966
|
+
const { handleBuild } = useBuild("Custom Name");
|
|
2857
2967
|
const { handleRemodel } = useRemodel();
|
|
2858
2968
|
const { handleDecompose } = useDecompose();
|
|
2969
|
+
const overrides = useSoftConfig((s) => s.overrides);
|
|
2859
2970
|
const softComponents = useSoftConfig((s) => s.softComponents, shallow);
|
|
2860
2971
|
const editableIds = useSoftConfig((s) => s.editableComponentIds);
|
|
2861
2972
|
const selectedItem = usePuck2((s) => s.selectedItem);
|
|
2862
2973
|
const status = useSoftConfig((s) => s.state);
|
|
2863
|
-
const
|
|
2974
|
+
const softKeys = Object.keys(softComponents);
|
|
2975
|
+
const key = useMemo3(() => createComponentKeyFromName(props.label || "", overrides, {
|
|
2976
|
+
existingKeys: softKeys,
|
|
2977
|
+
state: status
|
|
2978
|
+
}), [
|
|
2979
|
+
props.label,
|
|
2980
|
+
overrides,
|
|
2981
|
+
softKeys,
|
|
2982
|
+
status
|
|
2983
|
+
]);
|
|
2984
|
+
const isSoftComponent2 = softKeys.includes(key);
|
|
2864
2985
|
const selectedId = (_a = selectedItem == null ? void 0 : selectedItem.props) == null ? void 0 : _a.id;
|
|
2865
2986
|
const isEditable = Boolean(selectedId && editableIds.has(selectedId));
|
|
2866
2987
|
return /* @__PURE__ */ jsx9("div", { className: getClassName3(), children: /* @__PURE__ */ jsxs3(ActionBar, { children: [
|
|
@@ -2873,7 +2994,7 @@ var ActionBarOverride = (props) => {
|
|
|
2873
2994
|
/* @__PURE__ */ jsx9(
|
|
2874
2995
|
ActionBar.Action,
|
|
2875
2996
|
{
|
|
2876
|
-
onClick: () => handleRemodel(
|
|
2997
|
+
onClick: () => handleRemodel(key),
|
|
2877
2998
|
label: "Remodel Soft Component",
|
|
2878
2999
|
children: /* @__PURE__ */ jsx9(EditIcon, { size: 16 })
|
|
2879
3000
|
}
|
|
@@ -2899,7 +3020,7 @@ var ActionBarOverride = (props) => {
|
|
|
2899
3020
|
] }) });
|
|
2900
3021
|
};
|
|
2901
3022
|
|
|
2902
|
-
// src/puck/overrides/
|
|
3023
|
+
// src/puck/overrides/DrawerItem.tsx
|
|
2903
3024
|
import { useState as useState5 } from "react";
|
|
2904
3025
|
import { Button as Button2, IconButton, createUsePuck as createUsePuck12 } from "@measured/puck";
|
|
2905
3026
|
import { GripVertical, Check, X, Trash2, Cog } from "lucide-react";
|
|
@@ -2921,14 +3042,14 @@ var confirm = (message) => __async(null, null, function* () {
|
|
|
2921
3042
|
}
|
|
2922
3043
|
});
|
|
2923
3044
|
|
|
2924
|
-
// css-module:/media/
|
|
2925
|
-
var
|
|
3045
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/DrawerItem.module.css#css-module
|
|
3046
|
+
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" };
|
|
2926
3047
|
|
|
2927
3048
|
// src/puck/components/modal/index.tsx
|
|
2928
3049
|
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
2929
3050
|
import { createPortal } from "react-dom";
|
|
2930
3051
|
|
|
2931
|
-
// css-module:/media/
|
|
3052
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/modal/styles.module.css#css-module
|
|
2932
3053
|
var styles_module_default2 = { "Modal": "_Modal_pvj02_1", "Modal--isOpen": "_Modal--isOpen_pvj02_29", "Modal-inner": "_Modal-inner_pvj02_37" };
|
|
2933
3054
|
|
|
2934
3055
|
// src/puck/components/modal/index.tsx
|
|
@@ -2959,12 +3080,14 @@ var Modal = ({
|
|
|
2959
3080
|
);
|
|
2960
3081
|
};
|
|
2961
3082
|
|
|
2962
|
-
// src/puck/overrides/
|
|
3083
|
+
// src/puck/overrides/DrawerItem.tsx
|
|
2963
3084
|
import { shallow as shallow2 } from "zustand/shallow";
|
|
2964
3085
|
import { Fragment as Fragment5, jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2965
|
-
var getClassName5 = get_class_name_factory_default("
|
|
3086
|
+
var getClassName5 = get_class_name_factory_default("DrawerItem", DrawerItem_module_default);
|
|
2966
3087
|
var usePuck3 = createUsePuck12();
|
|
2967
|
-
var
|
|
3088
|
+
var DrawerItem = (props) => {
|
|
3089
|
+
const componentMeta = useSoftConfig((s) => s.softComponents[props.name]);
|
|
3090
|
+
const displayName = (componentMeta == null ? void 0 : componentMeta.name) || props.name;
|
|
2968
3091
|
const softComponents = new Set(
|
|
2969
3092
|
Object.keys(useSoftConfig((s) => s.softComponents, shallow2))
|
|
2970
3093
|
);
|
|
@@ -3027,7 +3150,7 @@ var ComponentItem = (props) => {
|
|
|
3027
3150
|
};
|
|
3028
3151
|
const handleDemolishClick = () => __async(null, null, function* () {
|
|
3029
3152
|
const confirmed = yield confirm(
|
|
3030
|
-
`Demolish "${
|
|
3153
|
+
`Demolish "${displayName}" entirely? This will remove all versions.`
|
|
3031
3154
|
);
|
|
3032
3155
|
if (confirmed) {
|
|
3033
3156
|
handleDemolish(props.name);
|
|
@@ -3045,7 +3168,7 @@ var ComponentItem = (props) => {
|
|
|
3045
3168
|
onMouseLeave: () => setIsHovering(false),
|
|
3046
3169
|
children: [
|
|
3047
3170
|
/* @__PURE__ */ jsxs4("div", { className: getClassName5("content"), children: [
|
|
3048
|
-
/* @__PURE__ */ jsx11("div", { className: getClassName5("name"), children:
|
|
3171
|
+
/* @__PURE__ */ jsx11("div", { className: getClassName5("name"), children: displayName }),
|
|
3049
3172
|
useVersioning && /* @__PURE__ */ jsxs4("div", { className: getClassName5("version"), children: [
|
|
3050
3173
|
"v",
|
|
3051
3174
|
defaultVersion
|
|
@@ -3072,7 +3195,7 @@ var ComponentItem = (props) => {
|
|
|
3072
3195
|
),
|
|
3073
3196
|
/* @__PURE__ */ jsx11(Modal, { isOpen: isEditing, onClose: handleCancel, children: /* @__PURE__ */ jsxs4("div", { className: getClassName5("modal"), children: [
|
|
3074
3197
|
/* @__PURE__ */ jsxs4("div", { className: getClassName5("modalHeader"), children: [
|
|
3075
|
-
/* @__PURE__ */ jsx11("h2", { className: getClassName5("modalTitle"), children:
|
|
3198
|
+
/* @__PURE__ */ jsx11("h2", { className: getClassName5("modalTitle"), children: displayName }),
|
|
3076
3199
|
/* @__PURE__ */ jsx11("p", { className: getClassName5("modalSubtitle"), children: "Component Settings" })
|
|
3077
3200
|
] }),
|
|
3078
3201
|
/* @__PURE__ */ jsx11("div", { className: getClassName5("modalBody"), children: useVersioning ? /* @__PURE__ */ jsxs4(Fragment5, { children: [
|
|
@@ -3111,6 +3234,7 @@ var ComponentItem = (props) => {
|
|
|
3111
3234
|
/* @__PURE__ */ jsx11("div", { className: getClassName5("migrationOptions"), children: /* @__PURE__ */ jsxs4(
|
|
3112
3235
|
"select",
|
|
3113
3236
|
{
|
|
3237
|
+
title: "Select migration version",
|
|
3114
3238
|
className: getClassName5("select"),
|
|
3115
3239
|
value: migrateVersionMap[Array.from(versionsToDelete)[0]] || "decompose",
|
|
3116
3240
|
onChange: (e) => {
|
|
@@ -3132,7 +3256,7 @@ var ComponentItem = (props) => {
|
|
|
3132
3256
|
] })
|
|
3133
3257
|
] }) : /* @__PURE__ */ jsx11("div", { className: getClassName5("section"), children: /* @__PURE__ */ jsxs4("p", { children: [
|
|
3134
3258
|
"Manage high-level settings for the ",
|
|
3135
|
-
/* @__PURE__ */ jsx11("strong", { children:
|
|
3259
|
+
/* @__PURE__ */ jsx11("strong", { children: displayName }),
|
|
3136
3260
|
" component."
|
|
3137
3261
|
] }) }) }),
|
|
3138
3262
|
/* @__PURE__ */ jsxs4("div", { className: getClassName5("modalFooter"), children: [
|
|
@@ -3156,6 +3280,124 @@ var ComponentItem = (props) => {
|
|
|
3156
3280
|
}
|
|
3157
3281
|
return /* @__PURE__ */ jsx11(Fragment5, { children: props.children });
|
|
3158
3282
|
};
|
|
3283
|
+
var ComponentItem = DrawerItem;
|
|
3284
|
+
|
|
3285
|
+
// src/puck/overrides/Drawer.tsx
|
|
3286
|
+
import { useState as useState6 } from "react";
|
|
3287
|
+
import { createUsePuck as createUsePuck13, Drawer as PuckDrawer } from "@measured/puck";
|
|
3288
|
+
import { ChevronDown, ChevronUp } from "lucide-react";
|
|
3289
|
+
|
|
3290
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/Drawer.module.css#css-module
|
|
3291
|
+
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" };
|
|
3292
|
+
|
|
3293
|
+
// src/puck/overrides/Drawer.tsx
|
|
3294
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
3295
|
+
var getClassName6 = get_class_name_factory_default("Drawer", Drawer_module_default);
|
|
3296
|
+
var getCategoryClassName = get_class_name_factory_default("Drawer-category", Drawer_module_default);
|
|
3297
|
+
var usePuck4 = createUsePuck13();
|
|
3298
|
+
var CategorySection = ({
|
|
3299
|
+
id,
|
|
3300
|
+
title,
|
|
3301
|
+
componentKeys,
|
|
3302
|
+
getPermissions,
|
|
3303
|
+
expanded,
|
|
3304
|
+
onToggle
|
|
3305
|
+
}) => /* @__PURE__ */ jsxs5("div", { className: getCategoryClassName({ isExpanded: expanded }), children: [
|
|
3306
|
+
title && /* @__PURE__ */ jsxs5(
|
|
3307
|
+
"button",
|
|
3308
|
+
{
|
|
3309
|
+
type: "button",
|
|
3310
|
+
className: getClassName6("categoryTitle"),
|
|
3311
|
+
onClick: () => onToggle(id),
|
|
3312
|
+
title: expanded ? `Collapse ${title}` : `Expand ${title}`,
|
|
3313
|
+
children: [
|
|
3314
|
+
/* @__PURE__ */ jsx12("span", { children: title }),
|
|
3315
|
+
/* @__PURE__ */ jsx12("span", { className: getClassName6("categoryTitleIcon"), children: expanded ? /* @__PURE__ */ jsx12(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx12(ChevronDown, { size: 12 }) })
|
|
3316
|
+
]
|
|
3317
|
+
}
|
|
3318
|
+
),
|
|
3319
|
+
/* @__PURE__ */ jsx12("div", { className: getClassName6("categoryContent"), children: /* @__PURE__ */ jsx12(PuckDrawer, { children: componentKeys.map((key) => /* @__PURE__ */ jsx12(
|
|
3320
|
+
PuckDrawer.Item,
|
|
3321
|
+
{
|
|
3322
|
+
name: key,
|
|
3323
|
+
isDragDisabled: !getPermissions({ type: key }).insert,
|
|
3324
|
+
children: DrawerItem
|
|
3325
|
+
},
|
|
3326
|
+
key
|
|
3327
|
+
)) }) })
|
|
3328
|
+
] });
|
|
3329
|
+
var Drawer = (_props) => {
|
|
3330
|
+
var _a, _b;
|
|
3331
|
+
const config = usePuck4((s) => s.config);
|
|
3332
|
+
const getPermissions = usePuck4((s) => s.getPermissions);
|
|
3333
|
+
const categories = (_a = config.categories) != null ? _a : {};
|
|
3334
|
+
const categorised = new Set(
|
|
3335
|
+
Object.values(categories).flatMap((cat) => {
|
|
3336
|
+
var _a2;
|
|
3337
|
+
return (_a2 = cat.components) != null ? _a2 : [];
|
|
3338
|
+
})
|
|
3339
|
+
);
|
|
3340
|
+
const allKeys = Object.keys(config.components);
|
|
3341
|
+
const otherKeys = allKeys.filter((k) => !categorised.has(k));
|
|
3342
|
+
const categoryEntries = Object.entries(categories).filter(
|
|
3343
|
+
([, cat]) => cat.visible !== false
|
|
3344
|
+
);
|
|
3345
|
+
const [expanded, setExpanded] = useState6(() => {
|
|
3346
|
+
const init = {};
|
|
3347
|
+
categoryEntries.forEach(([id, cat]) => {
|
|
3348
|
+
init[id] = cat.defaultExpanded !== false;
|
|
3349
|
+
});
|
|
3350
|
+
if (otherKeys.length > 0) init["__other__"] = true;
|
|
3351
|
+
return init;
|
|
3352
|
+
});
|
|
3353
|
+
const toggle = (id) => setExpanded((prev) => __spreadProps(__spreadValues({}, prev), { [id]: !prev[id] }));
|
|
3354
|
+
if (categoryEntries.length === 0) {
|
|
3355
|
+
return /* @__PURE__ */ jsx12(PuckDrawer, { children: allKeys.map((key) => /* @__PURE__ */ jsx12(
|
|
3356
|
+
PuckDrawer.Item,
|
|
3357
|
+
{
|
|
3358
|
+
name: key,
|
|
3359
|
+
isDragDisabled: !getPermissions({ type: key }).insert,
|
|
3360
|
+
children: DrawerItem
|
|
3361
|
+
},
|
|
3362
|
+
key
|
|
3363
|
+
)) });
|
|
3364
|
+
}
|
|
3365
|
+
console.log(
|
|
3366
|
+
getClassName6(),
|
|
3367
|
+
getCategoryClassName(),
|
|
3368
|
+
getCategoryClassName({ isExpanded: true })
|
|
3369
|
+
);
|
|
3370
|
+
return /* @__PURE__ */ jsxs5("div", { className: getClassName6(), children: [
|
|
3371
|
+
categoryEntries.map(([id, cat]) => {
|
|
3372
|
+
var _a2, _b2, _c;
|
|
3373
|
+
return /* @__PURE__ */ jsx12(
|
|
3374
|
+
CategorySection,
|
|
3375
|
+
{
|
|
3376
|
+
id,
|
|
3377
|
+
title: (_a2 = cat.title) != null ? _a2 : id,
|
|
3378
|
+
componentKeys: ((_b2 = cat.components) != null ? _b2 : []).filter(
|
|
3379
|
+
(k) => k in config.components
|
|
3380
|
+
),
|
|
3381
|
+
getPermissions,
|
|
3382
|
+
expanded: (_c = expanded[id]) != null ? _c : true,
|
|
3383
|
+
onToggle: toggle
|
|
3384
|
+
},
|
|
3385
|
+
id
|
|
3386
|
+
);
|
|
3387
|
+
}),
|
|
3388
|
+
otherKeys.length > 0 && /* @__PURE__ */ jsx12(
|
|
3389
|
+
CategorySection,
|
|
3390
|
+
{
|
|
3391
|
+
id: "__other__",
|
|
3392
|
+
title: "Other components",
|
|
3393
|
+
componentKeys: otherKeys,
|
|
3394
|
+
getPermissions,
|
|
3395
|
+
expanded: (_b = expanded["__other__"]) != null ? _b : true,
|
|
3396
|
+
onToggle: toggle
|
|
3397
|
+
}
|
|
3398
|
+
)
|
|
3399
|
+
] });
|
|
3400
|
+
};
|
|
3159
3401
|
|
|
3160
3402
|
// src/puck/lib/action-callback.ts
|
|
3161
3403
|
var createActionCallback = (validateAction, undo) => {
|
|
@@ -3382,6 +3624,9 @@ var resolveSoftConfig = (data, softComponents, config) => {
|
|
|
3382
3624
|
export {
|
|
3383
3625
|
ActionBarOverride as ActionBar,
|
|
3384
3626
|
ComponentItem,
|
|
3627
|
+
Drawer as ComponentList,
|
|
3628
|
+
Drawer,
|
|
3629
|
+
DrawerItem,
|
|
3385
3630
|
Header,
|
|
3386
3631
|
Modal,
|
|
3387
3632
|
SoftConfigProvider,
|