@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.mjs
CHANGED
|
@@ -372,7 +372,7 @@ var builderRootConfig = (config, overrides, editingComponent, showVersionFields
|
|
|
372
372
|
)
|
|
373
373
|
};
|
|
374
374
|
else delete fields._fieldSettings;
|
|
375
|
-
if (showVersionFields && ((_b = data == null ? void 0 : data._versions) == null ? void 0 : _b.length)
|
|
375
|
+
if (showVersionFields && ((_b = data == null ? void 0 : data._versions) == null ? void 0 : _b.length)) {
|
|
376
376
|
const latestVersion = data._versions[data._versions.length - 1] || "1.0.0";
|
|
377
377
|
delete fields._version;
|
|
378
378
|
fields._version = {
|
|
@@ -1398,19 +1398,22 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1398
1398
|
}
|
|
1399
1399
|
puckDispatch({
|
|
1400
1400
|
type: "set",
|
|
1401
|
-
state: (previous) =>
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
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
|
+
}
|
|
1414
1417
|
});
|
|
1415
1418
|
const config = __spreadValues({}, get().softConfig);
|
|
1416
1419
|
const overrides = get().overrides;
|
|
@@ -1554,7 +1557,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1554
1557
|
);
|
|
1555
1558
|
},
|
|
1556
1559
|
complete: (appState, setHistories, getItemBySelector) => {
|
|
1557
|
-
var _a, _b, _c, _d, _e;
|
|
1560
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1558
1561
|
if (get().state === "ready") {
|
|
1559
1562
|
throw new Error("Not building or remodeling a component.");
|
|
1560
1563
|
}
|
|
@@ -1639,8 +1642,21 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1639
1642
|
editableComponentIds: /* @__PURE__ */ new Set()
|
|
1640
1643
|
});
|
|
1641
1644
|
});
|
|
1645
|
+
if (!version) {
|
|
1646
|
+
throw new Error("Failed to resolve completed component version.");
|
|
1647
|
+
}
|
|
1648
|
+
const completedSoftComponent = (_f = get().softComponents[componentName]) == null ? void 0 : _f.versions[version];
|
|
1649
|
+
if (!completedSoftComponent) {
|
|
1650
|
+
throw new Error(
|
|
1651
|
+
`Completed soft component "${componentName}" version "${version}" not found.`
|
|
1652
|
+
);
|
|
1653
|
+
}
|
|
1642
1654
|
get().rebuildDependents(componentName, version);
|
|
1643
|
-
return
|
|
1655
|
+
return {
|
|
1656
|
+
id: componentName,
|
|
1657
|
+
version,
|
|
1658
|
+
softComponent: completedSoftComponent
|
|
1659
|
+
};
|
|
1644
1660
|
},
|
|
1645
1661
|
inspect: (componentName, puckDispatch) => {
|
|
1646
1662
|
if (get().state !== "inspecting") {
|
|
@@ -2523,7 +2539,7 @@ var useActionEvent = () => {
|
|
|
2523
2539
|
|
|
2524
2540
|
// src/puck/actions/useBuild.tsx
|
|
2525
2541
|
var useCustomPuck2 = createUsePuck2();
|
|
2526
|
-
var useBuild = () => {
|
|
2542
|
+
var useBuild = (name) => {
|
|
2527
2543
|
const build = useSoftConfig((s) => s.builder.build);
|
|
2528
2544
|
const history = useCustomPuck2((s) => s.history.histories);
|
|
2529
2545
|
const selectedItem = useCustomPuck2((s) => s.selectedItem);
|
|
@@ -2537,7 +2553,7 @@ var useBuild = () => {
|
|
|
2537
2553
|
return;
|
|
2538
2554
|
}
|
|
2539
2555
|
try {
|
|
2540
|
-
build(history, selectedItem, itemSelector, dispatch);
|
|
2556
|
+
build(history, selectedItem, itemSelector, dispatch, name);
|
|
2541
2557
|
if (selectedItem == null ? void 0 : selectedItem.type) {
|
|
2542
2558
|
void triggerAction({
|
|
2543
2559
|
type: "build",
|
|
@@ -2570,28 +2586,42 @@ var useRemodel = () => {
|
|
|
2570
2586
|
const refreshPermissions = useCustomPuck3((s) => s.refreshPermissions);
|
|
2571
2587
|
const { triggerAction } = useActionEvent();
|
|
2572
2588
|
const handleRemodel = (componentName) => {
|
|
2589
|
+
var _a, _b, _c;
|
|
2573
2590
|
if (status !== "ready") {
|
|
2574
2591
|
notify.error("Can only remodel when in ready state.");
|
|
2575
|
-
return;
|
|
2592
|
+
return null;
|
|
2576
2593
|
}
|
|
2577
2594
|
const name = componentName || (selectedItem == null ? void 0 : selectedItem.type);
|
|
2578
2595
|
if (!name || !Object.keys(softComponents).includes(name)) {
|
|
2579
2596
|
notify.error("Selected component is not a soft component.");
|
|
2580
|
-
return;
|
|
2597
|
+
return null;
|
|
2581
2598
|
}
|
|
2599
|
+
const selectedVersion = ((_a = selectedItem == null ? void 0 : selectedItem.props) == null ? void 0 : _a.version) || ((_b = softComponents[name]) == null ? void 0 : _b.defaultVersion);
|
|
2600
|
+
const selectedSoftComponent = selectedVersion ? (_c = softComponents[name]) == null ? void 0 : _c.versions[selectedVersion] : void 0;
|
|
2582
2601
|
try {
|
|
2583
2602
|
remodel(history, selectedItem, itemSelector, dispatch, refreshPermissions);
|
|
2584
2603
|
void triggerAction({
|
|
2585
2604
|
type: "remodel",
|
|
2586
2605
|
payload: {
|
|
2587
|
-
id: name
|
|
2606
|
+
id: name,
|
|
2607
|
+
version: selectedVersion,
|
|
2608
|
+
softComponent: selectedSoftComponent
|
|
2588
2609
|
}
|
|
2589
2610
|
});
|
|
2611
|
+
if (selectedVersion && selectedSoftComponent) {
|
|
2612
|
+
return {
|
|
2613
|
+
id: name,
|
|
2614
|
+
version: selectedVersion,
|
|
2615
|
+
softComponent: selectedSoftComponent
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
return { id: name, version: selectedVersion };
|
|
2590
2619
|
} catch (error) {
|
|
2591
2620
|
console.error("Failed to remodel:", error);
|
|
2592
2621
|
notify.error(
|
|
2593
2622
|
"Failed to remodel: " + (error instanceof Error ? error.message : String(error))
|
|
2594
2623
|
);
|
|
2624
|
+
return null;
|
|
2595
2625
|
}
|
|
2596
2626
|
};
|
|
2597
2627
|
const canRemodel = (componentName) => {
|
|
@@ -2611,31 +2641,29 @@ var useComplete = () => {
|
|
|
2611
2641
|
const setHistories = useCustomPuck4((s) => s.history.setHistories);
|
|
2612
2642
|
const getItemBySelector = useCustomPuck4((s) => s.getItemBySelector);
|
|
2613
2643
|
const status = useSoftConfig((s) => s.state);
|
|
2614
|
-
const softComponents = useSoftConfig((s) => s.softComponents);
|
|
2615
2644
|
const [newComponent, setNewComponent] = useState3(null);
|
|
2616
2645
|
const { triggerAction } = useActionEvent();
|
|
2617
2646
|
const handleComplete = useCallback2(() => {
|
|
2618
|
-
var _a, _b;
|
|
2619
2647
|
if (status === "ready") {
|
|
2620
2648
|
notify.error("Not building or remodeling a component.");
|
|
2621
2649
|
return null;
|
|
2622
2650
|
}
|
|
2623
2651
|
try {
|
|
2624
|
-
const
|
|
2625
|
-
setNewComponent(
|
|
2652
|
+
const completedComponent = complete(appState, setHistories, getItemBySelector);
|
|
2653
|
+
setNewComponent(completedComponent);
|
|
2626
2654
|
const componentData = appState.data.root;
|
|
2627
|
-
|
|
2628
|
-
if (softComponent && componentData) {
|
|
2655
|
+
if (componentData) {
|
|
2629
2656
|
void triggerAction({
|
|
2630
2657
|
type: "complete",
|
|
2631
2658
|
payload: {
|
|
2632
|
-
id:
|
|
2659
|
+
id: completedComponent.id,
|
|
2660
|
+
version: completedComponent.version,
|
|
2633
2661
|
componentData,
|
|
2634
|
-
softComponent
|
|
2662
|
+
softComponent: completedComponent.softComponent
|
|
2635
2663
|
}
|
|
2636
2664
|
});
|
|
2637
2665
|
}
|
|
2638
|
-
return
|
|
2666
|
+
return completedComponent;
|
|
2639
2667
|
} catch (error) {
|
|
2640
2668
|
console.error("Failed to complete:", error);
|
|
2641
2669
|
notify.error(
|
|
@@ -2643,7 +2671,7 @@ var useComplete = () => {
|
|
|
2643
2671
|
);
|
|
2644
2672
|
return null;
|
|
2645
2673
|
}
|
|
2646
|
-
}, [complete, appState, setHistories, status,
|
|
2674
|
+
}, [complete, appState, setHistories, status, triggerAction, getItemBySelector]);
|
|
2647
2675
|
const canComplete = status === "building" || status === "remodeling";
|
|
2648
2676
|
return { handleComplete, canComplete, newComponent, setNewComponent };
|
|
2649
2677
|
};
|
|
@@ -2682,23 +2710,25 @@ var useCancel = () => {
|
|
|
2682
2710
|
import { createUsePuck as createUsePuck6 } from "@measured/puck";
|
|
2683
2711
|
import { useEffect as useEffect3 } from "react";
|
|
2684
2712
|
var useCustomPuck6 = createUsePuck6();
|
|
2685
|
-
var useInspect = (
|
|
2713
|
+
var useInspect = (component) => {
|
|
2686
2714
|
const inspect = useSoftConfig((s) => s.builder.inspect);
|
|
2687
2715
|
const dispatch = useCustomPuck6((s) => s.dispatch);
|
|
2688
2716
|
const status = useSoftConfig((s) => s.state);
|
|
2689
2717
|
const { triggerAction } = useActionEvent();
|
|
2690
2718
|
useEffect3(() => {
|
|
2691
2719
|
if (status !== "inspecting") return;
|
|
2692
|
-
if (!
|
|
2720
|
+
if (!component) {
|
|
2693
2721
|
notify.error("No component to inspect.");
|
|
2694
2722
|
return;
|
|
2695
2723
|
}
|
|
2696
2724
|
try {
|
|
2697
|
-
inspect(
|
|
2725
|
+
inspect(component.id, dispatch);
|
|
2698
2726
|
void triggerAction({
|
|
2699
2727
|
type: "inspect",
|
|
2700
2728
|
payload: {
|
|
2701
|
-
id:
|
|
2729
|
+
id: component.id,
|
|
2730
|
+
version: component.version,
|
|
2731
|
+
softComponent: component.softComponent
|
|
2702
2732
|
}
|
|
2703
2733
|
});
|
|
2704
2734
|
} catch (error) {
|
|
@@ -2707,7 +2737,7 @@ var useInspect = (componentName) => {
|
|
|
2707
2737
|
"Failed to inspect: " + (error instanceof Error ? error.message : String(error))
|
|
2708
2738
|
);
|
|
2709
2739
|
}
|
|
2710
|
-
}, [status,
|
|
2740
|
+
}, [status, component, inspect, dispatch, triggerAction]);
|
|
2711
2741
|
};
|
|
2712
2742
|
|
|
2713
2743
|
// src/puck/actions/useDecompose.tsx
|
|
@@ -2923,9 +2953,9 @@ var Header = ({
|
|
|
2923
2953
|
{
|
|
2924
2954
|
variant: "primary",
|
|
2925
2955
|
onClick: () => {
|
|
2926
|
-
const
|
|
2927
|
-
if (
|
|
2928
|
-
setNewComponent(
|
|
2956
|
+
const completedComponent = handleComplete();
|
|
2957
|
+
if (completedComponent) {
|
|
2958
|
+
setNewComponent(completedComponent);
|
|
2929
2959
|
}
|
|
2930
2960
|
},
|
|
2931
2961
|
children: "Complete"
|
|
@@ -2960,7 +2990,7 @@ var getClassName3 = get_class_name_factory_default("ActionBar", ActionBar_module
|
|
|
2960
2990
|
var usePuck2 = createUsePuck11();
|
|
2961
2991
|
var ActionBarOverride = (props) => {
|
|
2962
2992
|
var _a;
|
|
2963
|
-
const { handleBuild } = useBuild();
|
|
2993
|
+
const { handleBuild } = useBuild("Custom Name");
|
|
2964
2994
|
const { handleRemodel } = useRemodel();
|
|
2965
2995
|
const { handleDecompose } = useDecompose();
|
|
2966
2996
|
const overrides = useSoftConfig((s) => s.overrides);
|
|
@@ -3017,7 +3047,7 @@ var ActionBarOverride = (props) => {
|
|
|
3017
3047
|
] }) });
|
|
3018
3048
|
};
|
|
3019
3049
|
|
|
3020
|
-
// src/puck/overrides/
|
|
3050
|
+
// src/puck/overrides/DrawerItem.tsx
|
|
3021
3051
|
import { useState as useState5 } from "react";
|
|
3022
3052
|
import { Button as Button2, IconButton, createUsePuck as createUsePuck12 } from "@measured/puck";
|
|
3023
3053
|
import { GripVertical, Check, X, Trash2, Cog } from "lucide-react";
|
|
@@ -3039,15 +3069,15 @@ var confirm = (message) => __async(null, null, function* () {
|
|
|
3039
3069
|
}
|
|
3040
3070
|
});
|
|
3041
3071
|
|
|
3042
|
-
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/
|
|
3043
|
-
var
|
|
3072
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/DrawerItem.module.css#css-module
|
|
3073
|
+
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" };
|
|
3044
3074
|
|
|
3045
3075
|
// src/puck/components/modal/index.tsx
|
|
3046
3076
|
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
3047
3077
|
import { createPortal } from "react-dom";
|
|
3048
3078
|
|
|
3049
3079
|
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/modal/styles.module.css#css-module
|
|
3050
|
-
var styles_module_default2 = { "Modal": "
|
|
3080
|
+
var styles_module_default2 = { "Modal": "_Modal_1t9ot_1", "Modal--isOpen": "_Modal--isOpen_1t9ot_29", "Modal-inner": "_Modal-inner_1t9ot_37" };
|
|
3051
3081
|
|
|
3052
3082
|
// src/puck/components/modal/index.tsx
|
|
3053
3083
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
@@ -3061,28 +3091,53 @@ var Modal = ({
|
|
|
3061
3091
|
useEffect4(() => {
|
|
3062
3092
|
setRootEl(document.getElementById("puck-portal-root"));
|
|
3063
3093
|
}, []);
|
|
3094
|
+
useEffect4(() => {
|
|
3095
|
+
if (!isOpen) {
|
|
3096
|
+
return;
|
|
3097
|
+
}
|
|
3098
|
+
const handleEscape = (event) => {
|
|
3099
|
+
if (event.key === "Escape") {
|
|
3100
|
+
onClose();
|
|
3101
|
+
}
|
|
3102
|
+
};
|
|
3103
|
+
document.addEventListener("keydown", handleEscape);
|
|
3104
|
+
return () => document.removeEventListener("keydown", handleEscape);
|
|
3105
|
+
}, [isOpen, onClose]);
|
|
3064
3106
|
if (!rootEl) {
|
|
3065
3107
|
return /* @__PURE__ */ jsx10("div", {});
|
|
3066
3108
|
}
|
|
3067
3109
|
return createPortal(
|
|
3068
|
-
/* @__PURE__ */ jsx10(
|
|
3110
|
+
/* @__PURE__ */ jsx10(
|
|
3069
3111
|
"div",
|
|
3070
3112
|
{
|
|
3071
|
-
className: getClassName4(
|
|
3072
|
-
onClick: (
|
|
3073
|
-
|
|
3113
|
+
className: getClassName4({ isOpen }),
|
|
3114
|
+
onClick: (event) => {
|
|
3115
|
+
if (event.target === event.currentTarget) {
|
|
3116
|
+
onClose();
|
|
3117
|
+
}
|
|
3118
|
+
},
|
|
3119
|
+
children: /* @__PURE__ */ jsx10(
|
|
3120
|
+
"div",
|
|
3121
|
+
{
|
|
3122
|
+
className: getClassName4("inner"),
|
|
3123
|
+
role: "dialog",
|
|
3124
|
+
"aria-modal": "true",
|
|
3125
|
+
onClick: (e) => e.stopPropagation(),
|
|
3126
|
+
children
|
|
3127
|
+
}
|
|
3128
|
+
)
|
|
3074
3129
|
}
|
|
3075
|
-
)
|
|
3130
|
+
),
|
|
3076
3131
|
rootEl
|
|
3077
3132
|
);
|
|
3078
3133
|
};
|
|
3079
3134
|
|
|
3080
|
-
// src/puck/overrides/
|
|
3135
|
+
// src/puck/overrides/DrawerItem.tsx
|
|
3081
3136
|
import { shallow as shallow2 } from "zustand/shallow";
|
|
3082
3137
|
import { Fragment as Fragment5, jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
3083
|
-
var getClassName5 = get_class_name_factory_default("
|
|
3138
|
+
var getClassName5 = get_class_name_factory_default("DrawerItem", DrawerItem_module_default);
|
|
3084
3139
|
var usePuck3 = createUsePuck12();
|
|
3085
|
-
var
|
|
3140
|
+
var DrawerItem = (props) => {
|
|
3086
3141
|
const componentMeta = useSoftConfig((s) => s.softComponents[props.name]);
|
|
3087
3142
|
const displayName = (componentMeta == null ? void 0 : componentMeta.name) || props.name;
|
|
3088
3143
|
const softComponents = new Set(
|
|
@@ -3095,13 +3150,14 @@ var ComponentItem = (props) => {
|
|
|
3095
3150
|
);
|
|
3096
3151
|
const { handleDemolish } = useDemolish();
|
|
3097
3152
|
const { handleSetDefaultVersion, getVersions, getDefaultVersion } = useSetDefaultVersion();
|
|
3153
|
+
const { triggerAction } = useActionEvent();
|
|
3098
3154
|
const [isEditing, setIsEditing] = useState5(false);
|
|
3099
3155
|
const [isHovering, setIsHovering] = useState5(false);
|
|
3100
3156
|
const [selectedVersion, setSelectedVersion] = useState5("");
|
|
3101
3157
|
const [versionsToDelete, setVersionsToDelete] = useState5(
|
|
3102
3158
|
/* @__PURE__ */ new Set()
|
|
3103
3159
|
);
|
|
3104
|
-
const [
|
|
3160
|
+
const [migrationTarget, setMigrationTarget] = useState5("decompose");
|
|
3105
3161
|
const useVersioning = useSoftConfig((s) => s.showVersionFields);
|
|
3106
3162
|
const versions = getVersions(props.name);
|
|
3107
3163
|
const defaultVersion = getDefaultVersion(props.name);
|
|
@@ -3122,19 +3178,27 @@ var ComponentItem = (props) => {
|
|
|
3122
3178
|
break;
|
|
3123
3179
|
} else {
|
|
3124
3180
|
removeSoftComponentVersion(props.name, version);
|
|
3181
|
+
void triggerAction({
|
|
3182
|
+
type: "deleteVersion",
|
|
3183
|
+
payload: {
|
|
3184
|
+
id: props.name,
|
|
3185
|
+
version,
|
|
3186
|
+
migrateToVersion: migrationTarget
|
|
3187
|
+
}
|
|
3188
|
+
});
|
|
3125
3189
|
}
|
|
3126
3190
|
}
|
|
3127
3191
|
}
|
|
3128
3192
|
setIsEditing(false);
|
|
3129
3193
|
setSelectedVersion("");
|
|
3130
3194
|
setVersionsToDelete(/* @__PURE__ */ new Set());
|
|
3131
|
-
|
|
3195
|
+
setMigrationTarget("decompose");
|
|
3132
3196
|
});
|
|
3133
3197
|
const handleCancel = () => {
|
|
3134
3198
|
setIsEditing(false);
|
|
3135
3199
|
setSelectedVersion("");
|
|
3136
3200
|
setVersionsToDelete(/* @__PURE__ */ new Set());
|
|
3137
|
-
|
|
3201
|
+
setMigrationTarget("decompose");
|
|
3138
3202
|
};
|
|
3139
3203
|
const toggleVersionForDeletion = (version) => {
|
|
3140
3204
|
const newSet = new Set(versionsToDelete);
|
|
@@ -3156,6 +3220,13 @@ var ComponentItem = (props) => {
|
|
|
3156
3220
|
});
|
|
3157
3221
|
if (softComponents.has(props.name)) {
|
|
3158
3222
|
const availableVersions = versions.filter((v) => !versionsToDelete.has(v));
|
|
3223
|
+
const migrationTargets = [
|
|
3224
|
+
{ value: "decompose", label: "Decompose to basic elements" },
|
|
3225
|
+
...availableVersions.map((version) => ({
|
|
3226
|
+
value: version,
|
|
3227
|
+
label: `Migrate to Version ${version}`
|
|
3228
|
+
}))
|
|
3229
|
+
];
|
|
3159
3230
|
return /* @__PURE__ */ jsxs4(Fragment5, { children: [
|
|
3160
3231
|
/* @__PURE__ */ jsxs4(
|
|
3161
3232
|
"div",
|
|
@@ -3226,29 +3297,35 @@ var ComponentItem = (props) => {
|
|
|
3226
3297
|
] }, version);
|
|
3227
3298
|
}) })
|
|
3228
3299
|
] }),
|
|
3229
|
-
versionsToDelete.size > 0 &&
|
|
3300
|
+
versionsToDelete.size > 0 && /* @__PURE__ */ jsxs4("div", { className: getClassName5("section"), children: [
|
|
3230
3301
|
/* @__PURE__ */ jsx11("h3", { className: getClassName5("sectionTitle"), children: "Migration Settings" }),
|
|
3231
|
-
/* @__PURE__ */ jsx11("div", { className: getClassName5("migrationOptions"), children: /* @__PURE__ */
|
|
3232
|
-
"
|
|
3302
|
+
/* @__PURE__ */ jsx11("div", { className: getClassName5("migrationOptions"), children: /* @__PURE__ */ jsx11(
|
|
3303
|
+
"div",
|
|
3233
3304
|
{
|
|
3234
|
-
className: getClassName5("
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3305
|
+
className: getClassName5("migrationList"),
|
|
3306
|
+
role: "radiogroup",
|
|
3307
|
+
"aria-label": "Migration target",
|
|
3308
|
+
children: migrationTargets.map((target) => {
|
|
3309
|
+
const isSelected = migrationTarget === target.value;
|
|
3310
|
+
return /* @__PURE__ */ jsxs4(
|
|
3311
|
+
"button",
|
|
3312
|
+
{
|
|
3313
|
+
type: "button",
|
|
3314
|
+
role: "radio",
|
|
3315
|
+
"aria-checked": isSelected,
|
|
3316
|
+
className: `${getClassName5("migrationOption")} ${isSelected ? getClassName5("migrationOption--isSelected") : ""}`,
|
|
3317
|
+
onClick: () => setMigrationTarget(target.value),
|
|
3318
|
+
children: [
|
|
3319
|
+
/* @__PURE__ */ jsx11("span", { className: getClassName5("migrationOptionLabel"), children: target.label }),
|
|
3320
|
+
isSelected && /* @__PURE__ */ jsx11(Check, { size: 14 })
|
|
3321
|
+
]
|
|
3322
|
+
},
|
|
3323
|
+
target.value
|
|
3324
|
+
);
|
|
3325
|
+
})
|
|
3250
3326
|
}
|
|
3251
|
-
) })
|
|
3327
|
+
) }),
|
|
3328
|
+
/* @__PURE__ */ jsx11("p", { className: getClassName5("helpText"), children: "Choose where to move existing instances of the deleted versions." })
|
|
3252
3329
|
] })
|
|
3253
3330
|
] }) : /* @__PURE__ */ jsx11("div", { className: getClassName5("section"), children: /* @__PURE__ */ jsxs4("p", { children: [
|
|
3254
3331
|
"Manage high-level settings for the ",
|
|
@@ -3276,6 +3353,119 @@ var ComponentItem = (props) => {
|
|
|
3276
3353
|
}
|
|
3277
3354
|
return /* @__PURE__ */ jsx11(Fragment5, { children: props.children });
|
|
3278
3355
|
};
|
|
3356
|
+
var ComponentItem = DrawerItem;
|
|
3357
|
+
|
|
3358
|
+
// src/puck/overrides/Drawer.tsx
|
|
3359
|
+
import { useState as useState6 } from "react";
|
|
3360
|
+
import { createUsePuck as createUsePuck13, Drawer as PuckDrawer } from "@measured/puck";
|
|
3361
|
+
import { ChevronDown, ChevronUp } from "lucide-react";
|
|
3362
|
+
|
|
3363
|
+
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/Drawer.module.css#css-module
|
|
3364
|
+
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" };
|
|
3365
|
+
|
|
3366
|
+
// src/puck/overrides/Drawer.tsx
|
|
3367
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
3368
|
+
var getClassName6 = get_class_name_factory_default("Drawer", Drawer_module_default);
|
|
3369
|
+
var getCategoryClassName = get_class_name_factory_default("Drawer-category", Drawer_module_default);
|
|
3370
|
+
var usePuck4 = createUsePuck13();
|
|
3371
|
+
var CategorySection = ({
|
|
3372
|
+
id,
|
|
3373
|
+
title,
|
|
3374
|
+
componentKeys,
|
|
3375
|
+
getPermissions,
|
|
3376
|
+
expanded,
|
|
3377
|
+
onToggle
|
|
3378
|
+
}) => /* @__PURE__ */ jsxs5("div", { className: getCategoryClassName({ isExpanded: expanded }), children: [
|
|
3379
|
+
title && /* @__PURE__ */ jsxs5(
|
|
3380
|
+
"button",
|
|
3381
|
+
{
|
|
3382
|
+
type: "button",
|
|
3383
|
+
className: getClassName6("categoryTitle"),
|
|
3384
|
+
onClick: () => onToggle(id),
|
|
3385
|
+
title: expanded ? `Collapse ${title}` : `Expand ${title}`,
|
|
3386
|
+
children: [
|
|
3387
|
+
/* @__PURE__ */ jsx12("span", { children: title }),
|
|
3388
|
+
/* @__PURE__ */ jsx12("span", { className: getClassName6("categoryTitleIcon"), children: expanded ? /* @__PURE__ */ jsx12(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx12(ChevronDown, { size: 12 }) })
|
|
3389
|
+
]
|
|
3390
|
+
}
|
|
3391
|
+
),
|
|
3392
|
+
/* @__PURE__ */ jsx12("div", { className: getClassName6("categoryContent"), children: /* @__PURE__ */ jsx12(PuckDrawer, { children: componentKeys.map((key) => /* @__PURE__ */ jsx12(
|
|
3393
|
+
PuckDrawer.Item,
|
|
3394
|
+
{
|
|
3395
|
+
name: key,
|
|
3396
|
+
isDragDisabled: !getPermissions({ type: key }).insert,
|
|
3397
|
+
children: DrawerItem
|
|
3398
|
+
},
|
|
3399
|
+
key
|
|
3400
|
+
)) }) })
|
|
3401
|
+
] });
|
|
3402
|
+
var Drawer = (_props) => {
|
|
3403
|
+
var _a, _b;
|
|
3404
|
+
const config = usePuck4((s) => s.config);
|
|
3405
|
+
const getPermissions = usePuck4((s) => s.getPermissions);
|
|
3406
|
+
const categories = (_a = config.categories) != null ? _a : {};
|
|
3407
|
+
const categorised = new Set(
|
|
3408
|
+
Object.values(categories).flatMap((cat) => {
|
|
3409
|
+
var _a2;
|
|
3410
|
+
return (_a2 = cat.components) != null ? _a2 : [];
|
|
3411
|
+
})
|
|
3412
|
+
);
|
|
3413
|
+
const allKeys = Object.keys(config.components);
|
|
3414
|
+
const otherKeys = allKeys.filter((k) => !categorised.has(k));
|
|
3415
|
+
const categoryEntries = Object.entries(categories).filter(
|
|
3416
|
+
([, cat]) => cat.visible !== false
|
|
3417
|
+
);
|
|
3418
|
+
const [expanded, setExpanded] = useState6(() => {
|
|
3419
|
+
const init = {};
|
|
3420
|
+
categoryEntries.forEach(([id, cat]) => {
|
|
3421
|
+
init[id] = cat.defaultExpanded !== false;
|
|
3422
|
+
});
|
|
3423
|
+
if (otherKeys.length > 0) init["__other__"] = true;
|
|
3424
|
+
return init;
|
|
3425
|
+
});
|
|
3426
|
+
const toggle = (id) => setExpanded((prev) => __spreadProps(__spreadValues({}, prev), { [id]: !prev[id] }));
|
|
3427
|
+
if (categoryEntries.length === 0) {
|
|
3428
|
+
return /* @__PURE__ */ jsx12(PuckDrawer, { children: allKeys.map((key) => /* @__PURE__ */ jsx12(
|
|
3429
|
+
PuckDrawer.Item,
|
|
3430
|
+
{
|
|
3431
|
+
name: key,
|
|
3432
|
+
isDragDisabled: !getPermissions({ type: key }).insert,
|
|
3433
|
+
children: DrawerItem
|
|
3434
|
+
},
|
|
3435
|
+
key
|
|
3436
|
+
)) });
|
|
3437
|
+
}
|
|
3438
|
+
return /* @__PURE__ */ jsxs5("div", { className: getClassName6(), children: [
|
|
3439
|
+
categoryEntries.map(([id, cat]) => {
|
|
3440
|
+
var _a2, _b2, _c;
|
|
3441
|
+
return /* @__PURE__ */ jsx12(
|
|
3442
|
+
CategorySection,
|
|
3443
|
+
{
|
|
3444
|
+
id,
|
|
3445
|
+
title: (_a2 = cat.title) != null ? _a2 : id,
|
|
3446
|
+
componentKeys: ((_b2 = cat.components) != null ? _b2 : []).filter(
|
|
3447
|
+
(k) => k in config.components
|
|
3448
|
+
),
|
|
3449
|
+
getPermissions,
|
|
3450
|
+
expanded: (_c = expanded[id]) != null ? _c : true,
|
|
3451
|
+
onToggle: toggle
|
|
3452
|
+
},
|
|
3453
|
+
id
|
|
3454
|
+
);
|
|
3455
|
+
}),
|
|
3456
|
+
otherKeys.length > 0 && /* @__PURE__ */ jsx12(
|
|
3457
|
+
CategorySection,
|
|
3458
|
+
{
|
|
3459
|
+
id: "__other__",
|
|
3460
|
+
title: "Other components",
|
|
3461
|
+
componentKeys: otherKeys,
|
|
3462
|
+
getPermissions,
|
|
3463
|
+
expanded: (_b = expanded["__other__"]) != null ? _b : true,
|
|
3464
|
+
onToggle: toggle
|
|
3465
|
+
}
|
|
3466
|
+
)
|
|
3467
|
+
] });
|
|
3468
|
+
};
|
|
3279
3469
|
|
|
3280
3470
|
// src/puck/lib/action-callback.ts
|
|
3281
3471
|
var createActionCallback = (validateAction, undo) => {
|
|
@@ -3502,6 +3692,9 @@ var resolveSoftConfig = (data, softComponents, config) => {
|
|
|
3502
3692
|
export {
|
|
3503
3693
|
ActionBarOverride as ActionBar,
|
|
3504
3694
|
ComponentItem,
|
|
3695
|
+
Drawer as ComponentList,
|
|
3696
|
+
Drawer,
|
|
3697
|
+
DrawerItem,
|
|
3505
3698
|
Header,
|
|
3506
3699
|
Modal,
|
|
3507
3700
|
SoftConfigProvider,
|