@netlisian/softconfig 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/dist/puck/index.css +127 -40
- package/dist/puck/index.d.mts +145 -89
- package/dist/puck/index.d.ts +145 -89
- package/dist/puck/index.js +271 -75
- package/dist/puck/index.mjs +268 -75
- 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,
|
|
@@ -421,7 +424,7 @@ var builderRootConfig = (config, overrides, editingComponent, showVersionFields
|
|
|
421
424
|
)
|
|
422
425
|
};
|
|
423
426
|
else delete fields._fieldSettings;
|
|
424
|
-
if (showVersionFields && ((_b = data == null ? void 0 : data._versions) == null ? void 0 : _b.length)
|
|
427
|
+
if (showVersionFields && ((_b = data == null ? void 0 : data._versions) == null ? void 0 : _b.length)) {
|
|
425
428
|
const latestVersion = data._versions[data._versions.length - 1] || "1.0.0";
|
|
426
429
|
delete fields._version;
|
|
427
430
|
fields._version = {
|
|
@@ -1447,19 +1450,22 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1447
1450
|
}
|
|
1448
1451
|
puckDispatch({
|
|
1449
1452
|
type: "set",
|
|
1450
|
-
state: (previous) =>
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
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
|
+
}
|
|
1463
1469
|
});
|
|
1464
1470
|
const config = __spreadValues({}, get().softConfig);
|
|
1465
1471
|
const overrides = get().overrides;
|
|
@@ -1603,7 +1609,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1603
1609
|
);
|
|
1604
1610
|
},
|
|
1605
1611
|
complete: (appState, setHistories, getItemBySelector) => {
|
|
1606
|
-
var _a, _b, _c, _d, _e;
|
|
1612
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1607
1613
|
if (get().state === "ready") {
|
|
1608
1614
|
throw new Error("Not building or remodeling a component.");
|
|
1609
1615
|
}
|
|
@@ -1688,8 +1694,21 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1688
1694
|
editableComponentIds: /* @__PURE__ */ new Set()
|
|
1689
1695
|
});
|
|
1690
1696
|
});
|
|
1697
|
+
if (!version) {
|
|
1698
|
+
throw new Error("Failed to resolve completed component version.");
|
|
1699
|
+
}
|
|
1700
|
+
const completedSoftComponent = (_f = get().softComponents[componentName]) == null ? void 0 : _f.versions[version];
|
|
1701
|
+
if (!completedSoftComponent) {
|
|
1702
|
+
throw new Error(
|
|
1703
|
+
`Completed soft component "${componentName}" version "${version}" not found.`
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1691
1706
|
get().rebuildDependents(componentName, version);
|
|
1692
|
-
return
|
|
1707
|
+
return {
|
|
1708
|
+
id: componentName,
|
|
1709
|
+
version,
|
|
1710
|
+
softComponent: completedSoftComponent
|
|
1711
|
+
};
|
|
1693
1712
|
},
|
|
1694
1713
|
inspect: (componentName, puckDispatch) => {
|
|
1695
1714
|
if (get().state !== "inspecting") {
|
|
@@ -2572,7 +2591,7 @@ var useActionEvent = () => {
|
|
|
2572
2591
|
|
|
2573
2592
|
// src/puck/actions/useBuild.tsx
|
|
2574
2593
|
var useCustomPuck2 = (0, import_puck5.createUsePuck)();
|
|
2575
|
-
var useBuild = () => {
|
|
2594
|
+
var useBuild = (name) => {
|
|
2576
2595
|
const build = useSoftConfig((s) => s.builder.build);
|
|
2577
2596
|
const history = useCustomPuck2((s) => s.history.histories);
|
|
2578
2597
|
const selectedItem = useCustomPuck2((s) => s.selectedItem);
|
|
@@ -2586,7 +2605,7 @@ var useBuild = () => {
|
|
|
2586
2605
|
return;
|
|
2587
2606
|
}
|
|
2588
2607
|
try {
|
|
2589
|
-
build(history, selectedItem, itemSelector, dispatch);
|
|
2608
|
+
build(history, selectedItem, itemSelector, dispatch, name);
|
|
2590
2609
|
if (selectedItem == null ? void 0 : selectedItem.type) {
|
|
2591
2610
|
void triggerAction({
|
|
2592
2611
|
type: "build",
|
|
@@ -2619,28 +2638,42 @@ var useRemodel = () => {
|
|
|
2619
2638
|
const refreshPermissions = useCustomPuck3((s) => s.refreshPermissions);
|
|
2620
2639
|
const { triggerAction } = useActionEvent();
|
|
2621
2640
|
const handleRemodel = (componentName) => {
|
|
2641
|
+
var _a, _b, _c;
|
|
2622
2642
|
if (status !== "ready") {
|
|
2623
2643
|
notify.error("Can only remodel when in ready state.");
|
|
2624
|
-
return;
|
|
2644
|
+
return null;
|
|
2625
2645
|
}
|
|
2626
2646
|
const name = componentName || (selectedItem == null ? void 0 : selectedItem.type);
|
|
2627
2647
|
if (!name || !Object.keys(softComponents).includes(name)) {
|
|
2628
2648
|
notify.error("Selected component is not a soft component.");
|
|
2629
|
-
return;
|
|
2649
|
+
return null;
|
|
2630
2650
|
}
|
|
2651
|
+
const selectedVersion = ((_a = selectedItem == null ? void 0 : selectedItem.props) == null ? void 0 : _a.version) || ((_b = softComponents[name]) == null ? void 0 : _b.defaultVersion);
|
|
2652
|
+
const selectedSoftComponent = selectedVersion ? (_c = softComponents[name]) == null ? void 0 : _c.versions[selectedVersion] : void 0;
|
|
2631
2653
|
try {
|
|
2632
2654
|
remodel(history, selectedItem, itemSelector, dispatch, refreshPermissions);
|
|
2633
2655
|
void triggerAction({
|
|
2634
2656
|
type: "remodel",
|
|
2635
2657
|
payload: {
|
|
2636
|
-
id: name
|
|
2658
|
+
id: name,
|
|
2659
|
+
version: selectedVersion,
|
|
2660
|
+
softComponent: selectedSoftComponent
|
|
2637
2661
|
}
|
|
2638
2662
|
});
|
|
2663
|
+
if (selectedVersion && selectedSoftComponent) {
|
|
2664
|
+
return {
|
|
2665
|
+
id: name,
|
|
2666
|
+
version: selectedVersion,
|
|
2667
|
+
softComponent: selectedSoftComponent
|
|
2668
|
+
};
|
|
2669
|
+
}
|
|
2670
|
+
return { id: name, version: selectedVersion };
|
|
2639
2671
|
} catch (error) {
|
|
2640
2672
|
console.error("Failed to remodel:", error);
|
|
2641
2673
|
notify.error(
|
|
2642
2674
|
"Failed to remodel: " + (error instanceof Error ? error.message : String(error))
|
|
2643
2675
|
);
|
|
2676
|
+
return null;
|
|
2644
2677
|
}
|
|
2645
2678
|
};
|
|
2646
2679
|
const canRemodel = (componentName) => {
|
|
@@ -2660,31 +2693,29 @@ var useComplete = () => {
|
|
|
2660
2693
|
const setHistories = useCustomPuck4((s) => s.history.setHistories);
|
|
2661
2694
|
const getItemBySelector = useCustomPuck4((s) => s.getItemBySelector);
|
|
2662
2695
|
const status = useSoftConfig((s) => s.state);
|
|
2663
|
-
const softComponents = useSoftConfig((s) => s.softComponents);
|
|
2664
2696
|
const [newComponent, setNewComponent] = (0, import_react7.useState)(null);
|
|
2665
2697
|
const { triggerAction } = useActionEvent();
|
|
2666
2698
|
const handleComplete = (0, import_react7.useCallback)(() => {
|
|
2667
|
-
var _a, _b;
|
|
2668
2699
|
if (status === "ready") {
|
|
2669
2700
|
notify.error("Not building or remodeling a component.");
|
|
2670
2701
|
return null;
|
|
2671
2702
|
}
|
|
2672
2703
|
try {
|
|
2673
|
-
const
|
|
2674
|
-
setNewComponent(
|
|
2704
|
+
const completedComponent = complete(appState, setHistories, getItemBySelector);
|
|
2705
|
+
setNewComponent(completedComponent);
|
|
2675
2706
|
const componentData = appState.data.root;
|
|
2676
|
-
|
|
2677
|
-
if (softComponent && componentData) {
|
|
2707
|
+
if (componentData) {
|
|
2678
2708
|
void triggerAction({
|
|
2679
2709
|
type: "complete",
|
|
2680
2710
|
payload: {
|
|
2681
|
-
id:
|
|
2711
|
+
id: completedComponent.id,
|
|
2712
|
+
version: completedComponent.version,
|
|
2682
2713
|
componentData,
|
|
2683
|
-
softComponent
|
|
2714
|
+
softComponent: completedComponent.softComponent
|
|
2684
2715
|
}
|
|
2685
2716
|
});
|
|
2686
2717
|
}
|
|
2687
|
-
return
|
|
2718
|
+
return completedComponent;
|
|
2688
2719
|
} catch (error) {
|
|
2689
2720
|
console.error("Failed to complete:", error);
|
|
2690
2721
|
notify.error(
|
|
@@ -2692,7 +2723,7 @@ var useComplete = () => {
|
|
|
2692
2723
|
);
|
|
2693
2724
|
return null;
|
|
2694
2725
|
}
|
|
2695
|
-
}, [complete, appState, setHistories, status,
|
|
2726
|
+
}, [complete, appState, setHistories, status, triggerAction, getItemBySelector]);
|
|
2696
2727
|
const canComplete = status === "building" || status === "remodeling";
|
|
2697
2728
|
return { handleComplete, canComplete, newComponent, setNewComponent };
|
|
2698
2729
|
};
|
|
@@ -2731,23 +2762,25 @@ var useCancel = () => {
|
|
|
2731
2762
|
var import_puck9 = require("@measured/puck");
|
|
2732
2763
|
var import_react8 = require("react");
|
|
2733
2764
|
var useCustomPuck6 = (0, import_puck9.createUsePuck)();
|
|
2734
|
-
var useInspect = (
|
|
2765
|
+
var useInspect = (component) => {
|
|
2735
2766
|
const inspect = useSoftConfig((s) => s.builder.inspect);
|
|
2736
2767
|
const dispatch = useCustomPuck6((s) => s.dispatch);
|
|
2737
2768
|
const status = useSoftConfig((s) => s.state);
|
|
2738
2769
|
const { triggerAction } = useActionEvent();
|
|
2739
2770
|
(0, import_react8.useEffect)(() => {
|
|
2740
2771
|
if (status !== "inspecting") return;
|
|
2741
|
-
if (!
|
|
2772
|
+
if (!component) {
|
|
2742
2773
|
notify.error("No component to inspect.");
|
|
2743
2774
|
return;
|
|
2744
2775
|
}
|
|
2745
2776
|
try {
|
|
2746
|
-
inspect(
|
|
2777
|
+
inspect(component.id, dispatch);
|
|
2747
2778
|
void triggerAction({
|
|
2748
2779
|
type: "inspect",
|
|
2749
2780
|
payload: {
|
|
2750
|
-
id:
|
|
2781
|
+
id: component.id,
|
|
2782
|
+
version: component.version,
|
|
2783
|
+
softComponent: component.softComponent
|
|
2751
2784
|
}
|
|
2752
2785
|
});
|
|
2753
2786
|
} catch (error) {
|
|
@@ -2756,7 +2789,7 @@ var useInspect = (componentName) => {
|
|
|
2756
2789
|
"Failed to inspect: " + (error instanceof Error ? error.message : String(error))
|
|
2757
2790
|
);
|
|
2758
2791
|
}
|
|
2759
|
-
}, [status,
|
|
2792
|
+
}, [status, component, inspect, dispatch, triggerAction]);
|
|
2760
2793
|
};
|
|
2761
2794
|
|
|
2762
2795
|
// src/puck/actions/useDecompose.tsx
|
|
@@ -2972,9 +3005,9 @@ var Header = ({
|
|
|
2972
3005
|
{
|
|
2973
3006
|
variant: "primary",
|
|
2974
3007
|
onClick: () => {
|
|
2975
|
-
const
|
|
2976
|
-
if (
|
|
2977
|
-
setNewComponent(
|
|
3008
|
+
const completedComponent = handleComplete();
|
|
3009
|
+
if (completedComponent) {
|
|
3010
|
+
setNewComponent(completedComponent);
|
|
2978
3011
|
}
|
|
2979
3012
|
},
|
|
2980
3013
|
children: "Complete"
|
|
@@ -3009,7 +3042,7 @@ var getClassName3 = get_class_name_factory_default("ActionBar", ActionBar_module
|
|
|
3009
3042
|
var usePuck2 = (0, import_puck14.createUsePuck)();
|
|
3010
3043
|
var ActionBarOverride = (props) => {
|
|
3011
3044
|
var _a;
|
|
3012
|
-
const { handleBuild } = useBuild();
|
|
3045
|
+
const { handleBuild } = useBuild("Custom Name");
|
|
3013
3046
|
const { handleRemodel } = useRemodel();
|
|
3014
3047
|
const { handleDecompose } = useDecompose();
|
|
3015
3048
|
const overrides = useSoftConfig((s) => s.overrides);
|
|
@@ -3066,7 +3099,7 @@ var ActionBarOverride = (props) => {
|
|
|
3066
3099
|
] }) });
|
|
3067
3100
|
};
|
|
3068
3101
|
|
|
3069
|
-
// src/puck/overrides/
|
|
3102
|
+
// src/puck/overrides/DrawerItem.tsx
|
|
3070
3103
|
var import_react11 = require("react");
|
|
3071
3104
|
var import_puck15 = require("@measured/puck");
|
|
3072
3105
|
var import_lucide_react2 = require("lucide-react");
|
|
@@ -3088,15 +3121,15 @@ var confirm = (message) => __async(null, null, function* () {
|
|
|
3088
3121
|
}
|
|
3089
3122
|
});
|
|
3090
3123
|
|
|
3091
|
-
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/
|
|
3092
|
-
var
|
|
3124
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/DrawerItem.module.css#css-module
|
|
3125
|
+
var DrawerItem_module_default = { "DrawerItem": "_DrawerItem_182aj_1", "DrawerItem--insertDisabled": "_DrawerItem--insertDisabled_182aj_14", "DrawerItem-content": "_DrawerItem-content_182aj_21", "DrawerItem-name": "_DrawerItem-name_182aj_31", "DrawerItem-version": "_DrawerItem-version_182aj_35", "DrawerItem-actions": "_DrawerItem-actions_182aj_40", "DrawerItem-settingsButton": "_DrawerItem-settingsButton_182aj_46", "DrawerItem-grip": "_DrawerItem-grip_182aj_56", "DrawerItem-modal": "_DrawerItem-modal_182aj_63", "DrawerItem-modalHeader": "_DrawerItem-modalHeader_182aj_71", "DrawerItem-modalTitle": "_DrawerItem-modalTitle_182aj_77", "DrawerItem-modalSubtitle": "_DrawerItem-modalSubtitle_182aj_84", "DrawerItem-modalBody": "_DrawerItem-modalBody_182aj_90", "DrawerItem-section": "_DrawerItem-section_182aj_100", "DrawerItem-sectionTitle": "_DrawerItem-sectionTitle_182aj_106", "DrawerItem-sectionDescription": "_DrawerItem-sectionDescription_182aj_113", "DrawerItem-versionList": "_DrawerItem-versionList_182aj_119", "DrawerItem-versionRow": "_DrawerItem-versionRow_182aj_125", "DrawerItem-versionRow--isDefault": "_DrawerItem-versionRow--isDefault_182aj_136", "DrawerItem-versionRow--isMarkedForDeletion": "_DrawerItem-versionRow--isMarkedForDeletion_182aj_141", "DrawerItem-versionInfo": "_DrawerItem-versionInfo_182aj_146", "DrawerItem-versionNumber": "_DrawerItem-versionNumber_182aj_153", "DrawerItem-defaultBadge": "_DrawerItem-defaultBadge_182aj_159", "DrawerItem-deleteBadge": "_DrawerItem-deleteBadge_182aj_170", "DrawerItem-versionActions": "_DrawerItem-versionActions_182aj_181", "DrawerItem-migrationOptions": "_DrawerItem-migrationOptions_182aj_187", "DrawerItem-migrationList": "_DrawerItem-migrationList_182aj_191", "DrawerItem-migrationOption": "_DrawerItem-migrationOption_182aj_187", "DrawerItem-migrationOption--isSelected": "_DrawerItem-migrationOption--isSelected_182aj_229", "DrawerItem-migrationOptionLabel": "_DrawerItem-migrationOptionLabel_182aj_234", "DrawerItem-modalFooter": "_DrawerItem-modalFooter_182aj_240", "DrawerItem-footerLeft": "_DrawerItem-footerLeft_182aj_250", "DrawerItem-footerRight": "_DrawerItem-footerRight_182aj_255" };
|
|
3093
3126
|
|
|
3094
3127
|
// src/puck/components/modal/index.tsx
|
|
3095
3128
|
var import_react10 = require("react");
|
|
3096
3129
|
var import_react_dom = require("react-dom");
|
|
3097
3130
|
|
|
3098
3131
|
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/modal/styles.module.css#css-module
|
|
3099
|
-
var styles_module_default2 = { "Modal": "
|
|
3132
|
+
var styles_module_default2 = { "Modal": "_Modal_1t9ot_1", "Modal--isOpen": "_Modal--isOpen_1t9ot_29", "Modal-inner": "_Modal-inner_1t9ot_37" };
|
|
3100
3133
|
|
|
3101
3134
|
// src/puck/components/modal/index.tsx
|
|
3102
3135
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
@@ -3110,28 +3143,53 @@ var Modal = ({
|
|
|
3110
3143
|
(0, import_react10.useEffect)(() => {
|
|
3111
3144
|
setRootEl(document.getElementById("puck-portal-root"));
|
|
3112
3145
|
}, []);
|
|
3146
|
+
(0, import_react10.useEffect)(() => {
|
|
3147
|
+
if (!isOpen) {
|
|
3148
|
+
return;
|
|
3149
|
+
}
|
|
3150
|
+
const handleEscape = (event) => {
|
|
3151
|
+
if (event.key === "Escape") {
|
|
3152
|
+
onClose();
|
|
3153
|
+
}
|
|
3154
|
+
};
|
|
3155
|
+
document.addEventListener("keydown", handleEscape);
|
|
3156
|
+
return () => document.removeEventListener("keydown", handleEscape);
|
|
3157
|
+
}, [isOpen, onClose]);
|
|
3113
3158
|
if (!rootEl) {
|
|
3114
3159
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {});
|
|
3115
3160
|
}
|
|
3116
3161
|
return (0, import_react_dom.createPortal)(
|
|
3117
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3162
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3118
3163
|
"div",
|
|
3119
3164
|
{
|
|
3120
|
-
className: getClassName4(
|
|
3121
|
-
onClick: (
|
|
3122
|
-
|
|
3165
|
+
className: getClassName4({ isOpen }),
|
|
3166
|
+
onClick: (event) => {
|
|
3167
|
+
if (event.target === event.currentTarget) {
|
|
3168
|
+
onClose();
|
|
3169
|
+
}
|
|
3170
|
+
},
|
|
3171
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3172
|
+
"div",
|
|
3173
|
+
{
|
|
3174
|
+
className: getClassName4("inner"),
|
|
3175
|
+
role: "dialog",
|
|
3176
|
+
"aria-modal": "true",
|
|
3177
|
+
onClick: (e) => e.stopPropagation(),
|
|
3178
|
+
children
|
|
3179
|
+
}
|
|
3180
|
+
)
|
|
3123
3181
|
}
|
|
3124
|
-
)
|
|
3182
|
+
),
|
|
3125
3183
|
rootEl
|
|
3126
3184
|
);
|
|
3127
3185
|
};
|
|
3128
3186
|
|
|
3129
|
-
// src/puck/overrides/
|
|
3187
|
+
// src/puck/overrides/DrawerItem.tsx
|
|
3130
3188
|
var import_shallow2 = require("zustand/shallow");
|
|
3131
3189
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3132
|
-
var getClassName5 = get_class_name_factory_default("
|
|
3190
|
+
var getClassName5 = get_class_name_factory_default("DrawerItem", DrawerItem_module_default);
|
|
3133
3191
|
var usePuck3 = (0, import_puck15.createUsePuck)();
|
|
3134
|
-
var
|
|
3192
|
+
var DrawerItem = (props) => {
|
|
3135
3193
|
const componentMeta = useSoftConfig((s) => s.softComponents[props.name]);
|
|
3136
3194
|
const displayName = (componentMeta == null ? void 0 : componentMeta.name) || props.name;
|
|
3137
3195
|
const softComponents = new Set(
|
|
@@ -3144,13 +3202,14 @@ var ComponentItem = (props) => {
|
|
|
3144
3202
|
);
|
|
3145
3203
|
const { handleDemolish } = useDemolish();
|
|
3146
3204
|
const { handleSetDefaultVersion, getVersions, getDefaultVersion } = useSetDefaultVersion();
|
|
3205
|
+
const { triggerAction } = useActionEvent();
|
|
3147
3206
|
const [isEditing, setIsEditing] = (0, import_react11.useState)(false);
|
|
3148
3207
|
const [isHovering, setIsHovering] = (0, import_react11.useState)(false);
|
|
3149
3208
|
const [selectedVersion, setSelectedVersion] = (0, import_react11.useState)("");
|
|
3150
3209
|
const [versionsToDelete, setVersionsToDelete] = (0, import_react11.useState)(
|
|
3151
3210
|
/* @__PURE__ */ new Set()
|
|
3152
3211
|
);
|
|
3153
|
-
const [
|
|
3212
|
+
const [migrationTarget, setMigrationTarget] = (0, import_react11.useState)("decompose");
|
|
3154
3213
|
const useVersioning = useSoftConfig((s) => s.showVersionFields);
|
|
3155
3214
|
const versions = getVersions(props.name);
|
|
3156
3215
|
const defaultVersion = getDefaultVersion(props.name);
|
|
@@ -3171,19 +3230,27 @@ var ComponentItem = (props) => {
|
|
|
3171
3230
|
break;
|
|
3172
3231
|
} else {
|
|
3173
3232
|
removeSoftComponentVersion(props.name, version);
|
|
3233
|
+
void triggerAction({
|
|
3234
|
+
type: "deleteVersion",
|
|
3235
|
+
payload: {
|
|
3236
|
+
id: props.name,
|
|
3237
|
+
version,
|
|
3238
|
+
migrateToVersion: migrationTarget
|
|
3239
|
+
}
|
|
3240
|
+
});
|
|
3174
3241
|
}
|
|
3175
3242
|
}
|
|
3176
3243
|
}
|
|
3177
3244
|
setIsEditing(false);
|
|
3178
3245
|
setSelectedVersion("");
|
|
3179
3246
|
setVersionsToDelete(/* @__PURE__ */ new Set());
|
|
3180
|
-
|
|
3247
|
+
setMigrationTarget("decompose");
|
|
3181
3248
|
});
|
|
3182
3249
|
const handleCancel = () => {
|
|
3183
3250
|
setIsEditing(false);
|
|
3184
3251
|
setSelectedVersion("");
|
|
3185
3252
|
setVersionsToDelete(/* @__PURE__ */ new Set());
|
|
3186
|
-
|
|
3253
|
+
setMigrationTarget("decompose");
|
|
3187
3254
|
};
|
|
3188
3255
|
const toggleVersionForDeletion = (version) => {
|
|
3189
3256
|
const newSet = new Set(versionsToDelete);
|
|
@@ -3205,6 +3272,13 @@ var ComponentItem = (props) => {
|
|
|
3205
3272
|
});
|
|
3206
3273
|
if (softComponents.has(props.name)) {
|
|
3207
3274
|
const availableVersions = versions.filter((v) => !versionsToDelete.has(v));
|
|
3275
|
+
const migrationTargets = [
|
|
3276
|
+
{ value: "decompose", label: "Decompose to basic elements" },
|
|
3277
|
+
...availableVersions.map((version) => ({
|
|
3278
|
+
value: version,
|
|
3279
|
+
label: `Migrate to Version ${version}`
|
|
3280
|
+
}))
|
|
3281
|
+
];
|
|
3208
3282
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
3209
3283
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
3210
3284
|
"div",
|
|
@@ -3275,29 +3349,35 @@ var ComponentItem = (props) => {
|
|
|
3275
3349
|
] }, version);
|
|
3276
3350
|
}) })
|
|
3277
3351
|
] }),
|
|
3278
|
-
versionsToDelete.size > 0 &&
|
|
3352
|
+
versionsToDelete.size > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("section"), children: [
|
|
3279
3353
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { className: getClassName5("sectionTitle"), children: "Migration Settings" }),
|
|
3280
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("migrationOptions"), children: /* @__PURE__ */ (0, import_jsx_runtime11.
|
|
3281
|
-
"
|
|
3354
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("migrationOptions"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3355
|
+
"div",
|
|
3282
3356
|
{
|
|
3283
|
-
className: getClassName5("
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3357
|
+
className: getClassName5("migrationList"),
|
|
3358
|
+
role: "radiogroup",
|
|
3359
|
+
"aria-label": "Migration target",
|
|
3360
|
+
children: migrationTargets.map((target) => {
|
|
3361
|
+
const isSelected = migrationTarget === target.value;
|
|
3362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
3363
|
+
"button",
|
|
3364
|
+
{
|
|
3365
|
+
type: "button",
|
|
3366
|
+
role: "radio",
|
|
3367
|
+
"aria-checked": isSelected,
|
|
3368
|
+
className: `${getClassName5("migrationOption")} ${isSelected ? getClassName5("migrationOption--isSelected") : ""}`,
|
|
3369
|
+
onClick: () => setMigrationTarget(target.value),
|
|
3370
|
+
children: [
|
|
3371
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: getClassName5("migrationOptionLabel"), children: target.label }),
|
|
3372
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Check, { size: 14 })
|
|
3373
|
+
]
|
|
3374
|
+
},
|
|
3375
|
+
target.value
|
|
3376
|
+
);
|
|
3377
|
+
})
|
|
3299
3378
|
}
|
|
3300
|
-
) })
|
|
3379
|
+
) }),
|
|
3380
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: getClassName5("helpText"), children: "Choose where to move existing instances of the deleted versions." })
|
|
3301
3381
|
] })
|
|
3302
3382
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("section"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
|
|
3303
3383
|
"Manage high-level settings for the ",
|
|
@@ -3325,6 +3405,119 @@ var ComponentItem = (props) => {
|
|
|
3325
3405
|
}
|
|
3326
3406
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: props.children });
|
|
3327
3407
|
};
|
|
3408
|
+
var ComponentItem = DrawerItem;
|
|
3409
|
+
|
|
3410
|
+
// src/puck/overrides/Drawer.tsx
|
|
3411
|
+
var import_react12 = require("react");
|
|
3412
|
+
var import_puck16 = require("@measured/puck");
|
|
3413
|
+
var import_lucide_react3 = require("lucide-react");
|
|
3414
|
+
|
|
3415
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/Drawer.module.css#css-module
|
|
3416
|
+
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" };
|
|
3417
|
+
|
|
3418
|
+
// src/puck/overrides/Drawer.tsx
|
|
3419
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3420
|
+
var getClassName6 = get_class_name_factory_default("Drawer", Drawer_module_default);
|
|
3421
|
+
var getCategoryClassName = get_class_name_factory_default("Drawer-category", Drawer_module_default);
|
|
3422
|
+
var usePuck4 = (0, import_puck16.createUsePuck)();
|
|
3423
|
+
var CategorySection = ({
|
|
3424
|
+
id,
|
|
3425
|
+
title,
|
|
3426
|
+
componentKeys,
|
|
3427
|
+
getPermissions,
|
|
3428
|
+
expanded,
|
|
3429
|
+
onToggle
|
|
3430
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getCategoryClassName({ isExpanded: expanded }), children: [
|
|
3431
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3432
|
+
"button",
|
|
3433
|
+
{
|
|
3434
|
+
type: "button",
|
|
3435
|
+
className: getClassName6("categoryTitle"),
|
|
3436
|
+
onClick: () => onToggle(id),
|
|
3437
|
+
title: expanded ? `Collapse ${title}` : `Expand ${title}`,
|
|
3438
|
+
children: [
|
|
3439
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: title }),
|
|
3440
|
+
/* @__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 }) })
|
|
3441
|
+
]
|
|
3442
|
+
}
|
|
3443
|
+
),
|
|
3444
|
+
/* @__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)(
|
|
3445
|
+
import_puck16.Drawer.Item,
|
|
3446
|
+
{
|
|
3447
|
+
name: key,
|
|
3448
|
+
isDragDisabled: !getPermissions({ type: key }).insert,
|
|
3449
|
+
children: DrawerItem
|
|
3450
|
+
},
|
|
3451
|
+
key
|
|
3452
|
+
)) }) })
|
|
3453
|
+
] });
|
|
3454
|
+
var Drawer = (_props) => {
|
|
3455
|
+
var _a, _b;
|
|
3456
|
+
const config = usePuck4((s) => s.config);
|
|
3457
|
+
const getPermissions = usePuck4((s) => s.getPermissions);
|
|
3458
|
+
const categories = (_a = config.categories) != null ? _a : {};
|
|
3459
|
+
const categorised = new Set(
|
|
3460
|
+
Object.values(categories).flatMap((cat) => {
|
|
3461
|
+
var _a2;
|
|
3462
|
+
return (_a2 = cat.components) != null ? _a2 : [];
|
|
3463
|
+
})
|
|
3464
|
+
);
|
|
3465
|
+
const allKeys = Object.keys(config.components);
|
|
3466
|
+
const otherKeys = allKeys.filter((k) => !categorised.has(k));
|
|
3467
|
+
const categoryEntries = Object.entries(categories).filter(
|
|
3468
|
+
([, cat]) => cat.visible !== false
|
|
3469
|
+
);
|
|
3470
|
+
const [expanded, setExpanded] = (0, import_react12.useState)(() => {
|
|
3471
|
+
const init = {};
|
|
3472
|
+
categoryEntries.forEach(([id, cat]) => {
|
|
3473
|
+
init[id] = cat.defaultExpanded !== false;
|
|
3474
|
+
});
|
|
3475
|
+
if (otherKeys.length > 0) init["__other__"] = true;
|
|
3476
|
+
return init;
|
|
3477
|
+
});
|
|
3478
|
+
const toggle = (id) => setExpanded((prev) => __spreadProps(__spreadValues({}, prev), { [id]: !prev[id] }));
|
|
3479
|
+
if (categoryEntries.length === 0) {
|
|
3480
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_puck16.Drawer, { children: allKeys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3481
|
+
import_puck16.Drawer.Item,
|
|
3482
|
+
{
|
|
3483
|
+
name: key,
|
|
3484
|
+
isDragDisabled: !getPermissions({ type: key }).insert,
|
|
3485
|
+
children: DrawerItem
|
|
3486
|
+
},
|
|
3487
|
+
key
|
|
3488
|
+
)) });
|
|
3489
|
+
}
|
|
3490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName6(), children: [
|
|
3491
|
+
categoryEntries.map(([id, cat]) => {
|
|
3492
|
+
var _a2, _b2, _c;
|
|
3493
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3494
|
+
CategorySection,
|
|
3495
|
+
{
|
|
3496
|
+
id,
|
|
3497
|
+
title: (_a2 = cat.title) != null ? _a2 : id,
|
|
3498
|
+
componentKeys: ((_b2 = cat.components) != null ? _b2 : []).filter(
|
|
3499
|
+
(k) => k in config.components
|
|
3500
|
+
),
|
|
3501
|
+
getPermissions,
|
|
3502
|
+
expanded: (_c = expanded[id]) != null ? _c : true,
|
|
3503
|
+
onToggle: toggle
|
|
3504
|
+
},
|
|
3505
|
+
id
|
|
3506
|
+
);
|
|
3507
|
+
}),
|
|
3508
|
+
otherKeys.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3509
|
+
CategorySection,
|
|
3510
|
+
{
|
|
3511
|
+
id: "__other__",
|
|
3512
|
+
title: "Other components",
|
|
3513
|
+
componentKeys: otherKeys,
|
|
3514
|
+
getPermissions,
|
|
3515
|
+
expanded: (_b = expanded["__other__"]) != null ? _b : true,
|
|
3516
|
+
onToggle: toggle
|
|
3517
|
+
}
|
|
3518
|
+
)
|
|
3519
|
+
] });
|
|
3520
|
+
};
|
|
3328
3521
|
|
|
3329
3522
|
// src/puck/lib/action-callback.ts
|
|
3330
3523
|
var createActionCallback = (validateAction, undo) => {
|
|
@@ -3552,6 +3745,9 @@ var resolveSoftConfig = (data, softComponents, config) => {
|
|
|
3552
3745
|
0 && (module.exports = {
|
|
3553
3746
|
ActionBar,
|
|
3554
3747
|
ComponentItem,
|
|
3748
|
+
ComponentList,
|
|
3749
|
+
Drawer,
|
|
3750
|
+
DrawerItem,
|
|
3555
3751
|
Header,
|
|
3556
3752
|
Modal,
|
|
3557
3753
|
SoftConfigProvider,
|