@netlisian/softconfig 0.1.5 → 0.1.7
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 +62 -122
- package/dist/puck/index.css +6 -6
- package/dist/puck/index.d.mts +125 -27
- package/dist/puck/index.d.ts +125 -27
- package/dist/puck/index.js +520 -529
- package/dist/puck/index.mjs +519 -529
- package/package.json +1 -1
package/dist/puck/index.js
CHANGED
|
@@ -74,6 +74,7 @@ __export(puck_exports, {
|
|
|
74
74
|
Drawer: () => Drawer,
|
|
75
75
|
DrawerItem: () => DrawerItem,
|
|
76
76
|
Header: () => Header,
|
|
77
|
+
HeaderActions: () => HeaderActions,
|
|
77
78
|
Modal: () => Modal,
|
|
78
79
|
SoftConfigProvider: () => SoftConfigProvider,
|
|
79
80
|
applyMapping: () => applyMapping,
|
|
@@ -1121,7 +1122,7 @@ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (op
|
|
|
1121
1122
|
};
|
|
1122
1123
|
var get_class_name_factory_default = getClassNameFactory;
|
|
1123
1124
|
|
|
1124
|
-
// css-module:/
|
|
1125
|
+
// css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/components/error-boundary/styles.module.css#css-module
|
|
1125
1126
|
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" };
|
|
1126
1127
|
|
|
1127
1128
|
// src/puck/components/error-boundary/index.tsx
|
|
@@ -1644,21 +1645,21 @@ var import_uuid = require("uuid");
|
|
|
1644
1645
|
var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, import_uuid.v4)();
|
|
1645
1646
|
|
|
1646
1647
|
// src/puck/lib/component-key.ts
|
|
1647
|
-
var
|
|
1648
|
-
|
|
1649
|
-
if (tokens.length === 0) return "";
|
|
1650
|
-
const [first, ...rest] = tokens;
|
|
1651
|
-
return `${first.toLowerCase()}${rest.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase()).join("")}`;
|
|
1648
|
+
var toSlug = (value) => {
|
|
1649
|
+
return value.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
|
|
1652
1650
|
};
|
|
1653
|
-
var
|
|
1654
|
-
|
|
1651
|
+
var slugTolabel = (name) => {
|
|
1652
|
+
return name.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
1653
|
+
};
|
|
1654
|
+
var componentNameFromLabel = (label, overrides, context) => {
|
|
1655
|
+
const key = overrides.componentLabelToName ? overrides.componentLabelToName(label, context) : toSlug(label);
|
|
1655
1656
|
return key.trim();
|
|
1656
1657
|
};
|
|
1657
|
-
var
|
|
1658
|
-
if (overrides == null ? void 0 : overrides.
|
|
1659
|
-
return overrides.
|
|
1658
|
+
var componentLabelFromName = (name, overrides) => {
|
|
1659
|
+
if (overrides == null ? void 0 : overrides.componentNameToLabel) {
|
|
1660
|
+
return overrides.componentNameToLabel(name);
|
|
1660
1661
|
}
|
|
1661
|
-
return
|
|
1662
|
+
return slugTolabel(name);
|
|
1662
1663
|
};
|
|
1663
1664
|
|
|
1664
1665
|
// src/puck/lib/soft-component-to-appstate.ts
|
|
@@ -1854,7 +1855,7 @@ var softComponentToAppState = (softComponent, componentName, version, versions,
|
|
|
1854
1855
|
mergedFieldSettings[field.name] = settings;
|
|
1855
1856
|
});
|
|
1856
1857
|
let rootProps = __spreadValues({
|
|
1857
|
-
_name: displayName ||
|
|
1858
|
+
_name: displayName || componentLabelFromName(componentName, overrides),
|
|
1858
1859
|
_category: category,
|
|
1859
1860
|
_version: version,
|
|
1860
1861
|
_versions: versions,
|
|
@@ -2057,17 +2058,14 @@ var hydrateCustomField = (fieldName, field, fieldSettings, customFields) => {
|
|
|
2057
2058
|
label: field.label || customField.field.label || fieldName
|
|
2058
2059
|
});
|
|
2059
2060
|
};
|
|
2060
|
-
var createVersionedComponentConfig = (componentName, displayName, version, allVersions, config, softComponents, defaultProps, showVersioning = true, customFields) => {
|
|
2061
|
+
var createVersionedComponentConfig = (componentName, displayName, version, allVersions, config, softComponents, defaultProps, showVersioning = true, customFields, overrides) => {
|
|
2061
2062
|
var _a, _b;
|
|
2062
|
-
const softConfig = config;
|
|
2063
2063
|
return {
|
|
2064
2064
|
label: displayName,
|
|
2065
2065
|
fields: Object.fromEntries(
|
|
2066
2066
|
(Object.entries(
|
|
2067
2067
|
(_b = (_a = softComponents[componentName].versions) == null ? void 0 : _a[version]) == null ? void 0 : _b.fields
|
|
2068
|
-
) || []).filter(
|
|
2069
|
-
([key, field]) => field.type === "slot"
|
|
2070
|
-
).map(([key, field]) => [key, __spreadValues({}, field)])
|
|
2068
|
+
) || []).filter(([key, field]) => field.type === "slot").map(([key, field]) => [key, __spreadValues({}, field)])
|
|
2071
2069
|
),
|
|
2072
2070
|
defaultProps: __spreadProps(__spreadValues({}, defaultProps), {
|
|
2073
2071
|
version
|
|
@@ -2104,7 +2102,7 @@ var createVersionedComponentConfig = (componentName, displayName, version, allVe
|
|
|
2104
2102
|
softComponentFields: versionedComponent.fields,
|
|
2105
2103
|
softComponentFieldSettings: versionedComponent.fieldSettings,
|
|
2106
2104
|
softSubComponent: versionedComponent.components,
|
|
2107
|
-
configComponents:
|
|
2105
|
+
configComponents: config.components,
|
|
2108
2106
|
props
|
|
2109
2107
|
}
|
|
2110
2108
|
);
|
|
@@ -2230,6 +2228,61 @@ function demolishSoftComponent(componentName, data, config, softComponents) {
|
|
|
2230
2228
|
};
|
|
2231
2229
|
}
|
|
2232
2230
|
|
|
2231
|
+
// src/puck/lib/edit-visibility-utils.ts
|
|
2232
|
+
var setEditVisibility = (doc, context) => {
|
|
2233
|
+
if (!doc) return;
|
|
2234
|
+
try {
|
|
2235
|
+
const root = doc.documentElement;
|
|
2236
|
+
if (context.mode === "none") {
|
|
2237
|
+
root.removeAttribute("data-edit-mode");
|
|
2238
|
+
root.classList.remove("edit-visibility-mode");
|
|
2239
|
+
doc.querySelectorAll("[data-puck-component]").forEach((el) => {
|
|
2240
|
+
el.removeAttribute("data-edit-visibility");
|
|
2241
|
+
el.classList.remove("edit-visibility-greyed", "edit-visibility-editable", "edit-visibility-dependency");
|
|
2242
|
+
});
|
|
2243
|
+
} else {
|
|
2244
|
+
root.setAttribute("data-edit-mode", context.mode);
|
|
2245
|
+
root.classList.add("edit-visibility-mode");
|
|
2246
|
+
doc.querySelectorAll("[data-puck-component]").forEach((el) => {
|
|
2247
|
+
var _a;
|
|
2248
|
+
const id = el.getAttribute("data-puck-component");
|
|
2249
|
+
if (!id) return;
|
|
2250
|
+
const isEditable = context.editableIds.has(id);
|
|
2251
|
+
const isDependency = (_a = context.highlightDependencyIds) == null ? void 0 : _a.has(id);
|
|
2252
|
+
if (isEditable) {
|
|
2253
|
+
el.setAttribute("data-edit-visibility", "editable");
|
|
2254
|
+
el.classList.remove("edit-visibility-greyed", "edit-visibility-dependency");
|
|
2255
|
+
el.classList.add("edit-visibility-editable");
|
|
2256
|
+
} else if (isDependency) {
|
|
2257
|
+
el.setAttribute("data-edit-visibility", "dependency");
|
|
2258
|
+
el.classList.remove("edit-visibility-greyed", "edit-visibility-editable");
|
|
2259
|
+
el.classList.add("edit-visibility-dependency");
|
|
2260
|
+
} else {
|
|
2261
|
+
el.setAttribute("data-edit-visibility", "greyed");
|
|
2262
|
+
el.classList.remove("edit-visibility-editable", "edit-visibility-dependency");
|
|
2263
|
+
el.classList.add("edit-visibility-greyed");
|
|
2264
|
+
}
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
} catch (error) {
|
|
2268
|
+
console.warn(`Failed to set edit visibility:`, error);
|
|
2269
|
+
}
|
|
2270
|
+
};
|
|
2271
|
+
var clearEditVisibility = (doc) => {
|
|
2272
|
+
if (!doc) return;
|
|
2273
|
+
try {
|
|
2274
|
+
const root = doc.documentElement;
|
|
2275
|
+
root.removeAttribute("data-edit-mode");
|
|
2276
|
+
root.classList.remove("edit-visibility-mode");
|
|
2277
|
+
doc.querySelectorAll("[data-puck-component]").forEach((el) => {
|
|
2278
|
+
el.removeAttribute("data-edit-visibility");
|
|
2279
|
+
el.classList.remove("edit-visibility-greyed", "edit-visibility-editable", "edit-visibility-dependency");
|
|
2280
|
+
});
|
|
2281
|
+
} catch (error) {
|
|
2282
|
+
console.warn(`Failed to clear edit visibility:`, error);
|
|
2283
|
+
}
|
|
2284
|
+
};
|
|
2285
|
+
|
|
2233
2286
|
// src/puck/store/slices/builder.tsx
|
|
2234
2287
|
var createBuildersSlice = (set, get, initialConfig) => ({
|
|
2235
2288
|
build: (history, selectedItem, itemSelector, puckDispatch, name) => {
|
|
@@ -2280,6 +2333,12 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
2280
2333
|
return components;
|
|
2281
2334
|
}
|
|
2282
2335
|
);
|
|
2336
|
+
requestAnimationFrame(
|
|
2337
|
+
() => setEditVisibility(get().iframeDoc, {
|
|
2338
|
+
mode: "build",
|
|
2339
|
+
editableIds
|
|
2340
|
+
})
|
|
2341
|
+
);
|
|
2283
2342
|
set((s) => __spreadProps(__spreadValues({}, s), {
|
|
2284
2343
|
softConfig: buildConfig,
|
|
2285
2344
|
storedConfig: config,
|
|
@@ -2292,15 +2351,14 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
2292
2351
|
editableComponentIds: editableIds,
|
|
2293
2352
|
state: "building"
|
|
2294
2353
|
}));
|
|
2295
|
-
|
|
2354
|
+
requestAnimationFrame(
|
|
2296
2355
|
() => puckDispatch({
|
|
2297
2356
|
type: "replaceRoot",
|
|
2298
2357
|
root: {
|
|
2299
2358
|
title: "Soft Component Builder",
|
|
2300
2359
|
_name: name || "New Soft Component"
|
|
2301
2360
|
}
|
|
2302
|
-
})
|
|
2303
|
-
100
|
|
2361
|
+
})
|
|
2304
2362
|
);
|
|
2305
2363
|
},
|
|
2306
2364
|
remodel: (history, selectedItem, itemSelector, puckDispatch) => {
|
|
@@ -2388,6 +2446,12 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
2388
2446
|
}).content
|
|
2389
2447
|
})
|
|
2390
2448
|
});
|
|
2449
|
+
requestAnimationFrame(
|
|
2450
|
+
() => setEditVisibility(get().iframeDoc, {
|
|
2451
|
+
mode: "remodel",
|
|
2452
|
+
editableIds
|
|
2453
|
+
})
|
|
2454
|
+
);
|
|
2391
2455
|
set((s) => __spreadProps(__spreadValues({}, s), {
|
|
2392
2456
|
storedConfig: config,
|
|
2393
2457
|
softConfig: buildConfig,
|
|
@@ -2401,7 +2465,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
2401
2465
|
editableComponentIds: editableIds,
|
|
2402
2466
|
state: "remodeling"
|
|
2403
2467
|
}));
|
|
2404
|
-
|
|
2468
|
+
requestAnimationFrame(
|
|
2405
2469
|
() => puckDispatch({
|
|
2406
2470
|
type: "replaceRoot",
|
|
2407
2471
|
root: {
|
|
@@ -2409,8 +2473,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
2409
2473
|
_name: root.props._name,
|
|
2410
2474
|
_category: root.props._category
|
|
2411
2475
|
}
|
|
2412
|
-
})
|
|
2413
|
-
100
|
|
2476
|
+
})
|
|
2414
2477
|
);
|
|
2415
2478
|
},
|
|
2416
2479
|
complete: (appState, setHistories, getItemBySelector) => {
|
|
@@ -2426,34 +2489,34 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
2426
2489
|
if (!itemSelector) {
|
|
2427
2490
|
throw new Error("No item selector found for completed component.");
|
|
2428
2491
|
}
|
|
2429
|
-
const selectedItem = getItemBySelector(
|
|
2430
|
-
itemSelector
|
|
2431
|
-
);
|
|
2492
|
+
const selectedItem = getItemBySelector(itemSelector);
|
|
2432
2493
|
if (!selectedItem) {
|
|
2433
2494
|
throw new Error("Cannot find item being edited");
|
|
2434
2495
|
}
|
|
2435
2496
|
const rootCategory = (_e = (_d = appState.data.root) == null ? void 0 : _d.props) == null ? void 0 : _e._category;
|
|
2436
2497
|
const rootProps = (_f = appState.data.root) == null ? void 0 : _f.props;
|
|
2437
|
-
const componentName =
|
|
2498
|
+
const componentName = componentNameFromLabel(displayName, get().overrides, __spreadProps(__spreadValues({}, rootProps || {}), {
|
|
2438
2499
|
existingKeys: Object.keys(get().softComponents),
|
|
2439
2500
|
state: get().state
|
|
2440
2501
|
}));
|
|
2441
2502
|
if (!componentName) {
|
|
2442
2503
|
throw new Error("Failed to generate component key from name.");
|
|
2443
2504
|
}
|
|
2444
|
-
const [
|
|
2505
|
+
const [defaultSoftComponentConfig, version] = get().builder.compose(
|
|
2445
2506
|
appState,
|
|
2446
2507
|
componentName,
|
|
2447
2508
|
selectedItem,
|
|
2448
2509
|
displayName,
|
|
2449
2510
|
rootCategory
|
|
2450
2511
|
) || [];
|
|
2451
|
-
if (!
|
|
2512
|
+
if (!defaultSoftComponentConfig) {
|
|
2452
2513
|
throw new Error("Failed to compose new soft component config.");
|
|
2453
2514
|
}
|
|
2454
2515
|
const storedHistories = get().originalHistory;
|
|
2455
2516
|
setHistories([...storedHistories]);
|
|
2456
2517
|
const config = __spreadValues({}, get().softConfig || initialConfig);
|
|
2518
|
+
const mapComponentConfig = get().overrides.mapComponentConfig;
|
|
2519
|
+
const newSoftComponentConfig = mapComponentConfig ? mapComponentConfig(componentName, defaultSoftComponentConfig, rootProps) : defaultSoftComponentConfig;
|
|
2457
2520
|
set((s) => {
|
|
2458
2521
|
var _a2, _b2;
|
|
2459
2522
|
const nextComponents = __spreadProps(__spreadValues({}, Object.entries(config.components).reduce(
|
|
@@ -2495,10 +2558,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
2495
2558
|
}),
|
|
2496
2559
|
storedConfig: void 0,
|
|
2497
2560
|
state: "inspecting",
|
|
2498
|
-
originalHistory: []
|
|
2499
|
-
editingComponent: null,
|
|
2500
|
-
editingComponentId: null,
|
|
2501
|
-
editableComponentIds: /* @__PURE__ */ new Set()
|
|
2561
|
+
originalHistory: []
|
|
2502
2562
|
});
|
|
2503
2563
|
});
|
|
2504
2564
|
if (!version) {
|
|
@@ -2525,30 +2585,44 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
2525
2585
|
if ((selector == null ? void 0 : selector.index) === void 0 || !(selector == null ? void 0 : selector.zone)) {
|
|
2526
2586
|
throw new Error("No selector found for last item.");
|
|
2527
2587
|
}
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2588
|
+
const editableComponentId = get().editingComponentId;
|
|
2589
|
+
requestAnimationFrame(() => {
|
|
2590
|
+
const config = get().softConfig;
|
|
2591
|
+
const newComponent = config.components[componentName];
|
|
2592
|
+
const reconstructedTree = (data) => (0, import_puck4.walkTree)(data, config, (components) => {
|
|
2593
|
+
return components.map((comp) => {
|
|
2594
|
+
if (comp.props.id === editableComponentId) {
|
|
2595
|
+
return {
|
|
2596
|
+
type: componentName,
|
|
2597
|
+
props: __spreadProps(__spreadValues({}, newComponent.defaultProps), {
|
|
2598
|
+
id: generateId(componentName)
|
|
2599
|
+
})
|
|
2600
|
+
};
|
|
2601
|
+
}
|
|
2602
|
+
return comp;
|
|
2603
|
+
});
|
|
2533
2604
|
});
|
|
2534
2605
|
puckDispatch({
|
|
2535
|
-
type: "
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2606
|
+
type: "setData",
|
|
2607
|
+
data: (data) => {
|
|
2608
|
+
return reconstructedTree(data);
|
|
2609
|
+
}
|
|
2539
2610
|
});
|
|
2540
|
-
}
|
|
2611
|
+
});
|
|
2612
|
+
requestAnimationFrame(() => clearEditVisibility(get().iframeDoc));
|
|
2541
2613
|
set((s) => __spreadProps(__spreadValues({}, s), {
|
|
2542
2614
|
state: "ready",
|
|
2543
2615
|
setItemSelector: void 0,
|
|
2544
2616
|
setOriginalItem: void 0,
|
|
2617
|
+
editingComponent: null,
|
|
2545
2618
|
editingComponentId: null,
|
|
2546
2619
|
editableComponentIds: /* @__PURE__ */ new Set()
|
|
2547
2620
|
}));
|
|
2548
2621
|
},
|
|
2549
2622
|
cancel: (setHistories) => {
|
|
2550
2623
|
const storedHistories = get().originalHistory;
|
|
2551
|
-
|
|
2624
|
+
requestAnimationFrame(() => setHistories([...storedHistories]));
|
|
2625
|
+
requestAnimationFrame(() => clearEditVisibility(get().iframeDoc));
|
|
2552
2626
|
set((s) => __spreadProps(__spreadValues({}, s), {
|
|
2553
2627
|
softConfig: get().storedConfig || initialConfig,
|
|
2554
2628
|
storedConfig: void 0,
|
|
@@ -2838,7 +2912,8 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides, showV
|
|
|
2838
2912
|
hydratedSoftComponents,
|
|
2839
2913
|
versionedComponent.defaultProps,
|
|
2840
2914
|
showVersioning,
|
|
2841
|
-
customFields
|
|
2915
|
+
customFields,
|
|
2916
|
+
overrides
|
|
2842
2917
|
);
|
|
2843
2918
|
componentConfigs[name] = newSoftComponentConfig;
|
|
2844
2919
|
buildingConfig.components[name] = newSoftComponentConfig;
|
|
@@ -2867,7 +2942,8 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides, showV
|
|
|
2867
2942
|
hydratedSoftComponents,
|
|
2868
2943
|
versionedComponent.defaultProps,
|
|
2869
2944
|
showVersioning,
|
|
2870
|
-
customFields
|
|
2945
|
+
customFields,
|
|
2946
|
+
overrides
|
|
2871
2947
|
);
|
|
2872
2948
|
componentConfigs[name] = newSoftComponentConfig;
|
|
2873
2949
|
}
|
|
@@ -2875,74 +2951,12 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides, showV
|
|
|
2875
2951
|
}
|
|
2876
2952
|
}
|
|
2877
2953
|
|
|
2878
|
-
// src/puck/lib/edit-visibility-utils.ts
|
|
2879
|
-
var setEditVisibility = (doc, context) => {
|
|
2880
|
-
if (!doc) return;
|
|
2881
|
-
try {
|
|
2882
|
-
const root = doc.documentElement;
|
|
2883
|
-
if (context.mode === "none") {
|
|
2884
|
-
root.removeAttribute("data-edit-mode");
|
|
2885
|
-
root.classList.remove("edit-visibility-mode");
|
|
2886
|
-
doc.querySelectorAll("[data-puck-component]").forEach((el) => {
|
|
2887
|
-
el.removeAttribute("data-edit-visibility");
|
|
2888
|
-
el.classList.remove("edit-visibility-greyed", "edit-visibility-editable", "edit-visibility-dependency");
|
|
2889
|
-
});
|
|
2890
|
-
} else {
|
|
2891
|
-
root.setAttribute("data-edit-mode", context.mode);
|
|
2892
|
-
root.classList.add("edit-visibility-mode");
|
|
2893
|
-
doc.querySelectorAll("[data-puck-component]").forEach((el) => {
|
|
2894
|
-
var _a;
|
|
2895
|
-
const id = el.getAttribute("data-puck-component");
|
|
2896
|
-
if (!id) return;
|
|
2897
|
-
const isEditable = context.editableIds.has(id);
|
|
2898
|
-
const isDependency = (_a = context.highlightDependencyIds) == null ? void 0 : _a.has(id);
|
|
2899
|
-
if (isEditable) {
|
|
2900
|
-
el.setAttribute("data-edit-visibility", "editable");
|
|
2901
|
-
el.classList.remove("edit-visibility-greyed", "edit-visibility-dependency");
|
|
2902
|
-
el.classList.add("edit-visibility-editable");
|
|
2903
|
-
} else if (isDependency) {
|
|
2904
|
-
el.setAttribute("data-edit-visibility", "dependency");
|
|
2905
|
-
el.classList.remove("edit-visibility-greyed", "edit-visibility-editable");
|
|
2906
|
-
el.classList.add("edit-visibility-dependency");
|
|
2907
|
-
} else {
|
|
2908
|
-
el.setAttribute("data-edit-visibility", "greyed");
|
|
2909
|
-
el.classList.remove("edit-visibility-editable", "edit-visibility-dependency");
|
|
2910
|
-
el.classList.add("edit-visibility-greyed");
|
|
2911
|
-
}
|
|
2912
|
-
});
|
|
2913
|
-
}
|
|
2914
|
-
} catch (error) {
|
|
2915
|
-
console.warn(`Failed to set edit visibility:`, error);
|
|
2916
|
-
}
|
|
2917
|
-
};
|
|
2918
|
-
var clearEditVisibility = (doc) => {
|
|
2919
|
-
if (!doc) return;
|
|
2920
|
-
try {
|
|
2921
|
-
const root = doc.documentElement;
|
|
2922
|
-
root.removeAttribute("data-edit-mode");
|
|
2923
|
-
root.classList.remove("edit-visibility-mode");
|
|
2924
|
-
doc.querySelectorAll("[data-puck-component]").forEach((el) => {
|
|
2925
|
-
el.removeAttribute("data-edit-visibility");
|
|
2926
|
-
el.classList.remove("edit-visibility-greyed", "edit-visibility-editable", "edit-visibility-dependency");
|
|
2927
|
-
});
|
|
2928
|
-
} catch (error) {
|
|
2929
|
-
console.warn(`Failed to clear edit visibility:`, error);
|
|
2930
|
-
}
|
|
2931
|
-
};
|
|
2932
|
-
|
|
2933
2954
|
// src/puck/store/index.tsx
|
|
2934
|
-
var createSoftConfigStore = (hardConfig = {
|
|
2935
|
-
components: {}
|
|
2936
|
-
}, softComponents = {}, overrides = {}, onActions, showVersionFields = true, customFields = {}) => {
|
|
2955
|
+
var createSoftConfigStore = (hardConfig = { components: {} }, softComponents = {}, overrides = {}, onActions, showVersionFields = true, customFields = {}) => {
|
|
2937
2956
|
const normalizedSoftComponents = Object.fromEntries(
|
|
2938
|
-
Object.entries(softComponents || {}).filter(([key]) => !hardConfig.components || !hardConfig.components[key]).map(([key, value]) => [
|
|
2939
|
-
key,
|
|
2940
|
-
__spreadProps(__spreadValues({}, value), {
|
|
2941
|
-
name: value.name || key
|
|
2942
|
-
})
|
|
2943
|
-
])
|
|
2957
|
+
Object.entries(softComponents || {}).filter(([key]) => !hardConfig.components || !hardConfig.components[key]).map(([key, value]) => [key, __spreadProps(__spreadValues({}, value), { name: value.name || key })])
|
|
2944
2958
|
);
|
|
2945
|
-
const
|
|
2959
|
+
const iframeDoc = null;
|
|
2946
2960
|
const hydratedSoftComponents = (overrides == null ? void 0 : overrides.hydrateMapTransform) ? hydrateSoftComponentsTransforms(
|
|
2947
2961
|
normalizedSoftComponents,
|
|
2948
2962
|
overrides.hydrateMapTransform
|
|
@@ -2951,323 +2965,369 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2951
2965
|
hydratedSoftComponents
|
|
2952
2966
|
);
|
|
2953
2967
|
return (0, import_zustand2.create)()(
|
|
2954
|
-
(0, import_middleware.subscribeWithSelector)(
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2968
|
+
(0, import_middleware.subscribeWithSelector)((set, get) => ({
|
|
2969
|
+
// ─── Initial State ──────────────────────────────────────────────────────
|
|
2970
|
+
state: "ready",
|
|
2971
|
+
originalHistory: [],
|
|
2972
|
+
overrides,
|
|
2973
|
+
customFields,
|
|
2974
|
+
onActions,
|
|
2975
|
+
iframeDoc,
|
|
2976
|
+
editingComponent: null,
|
|
2977
|
+
editingComponentId: null,
|
|
2978
|
+
editableComponentIds: /* @__PURE__ */ new Set(),
|
|
2979
|
+
itemSelector: null,
|
|
2980
|
+
originalItem: null,
|
|
2981
|
+
hydratedSoftComponents,
|
|
2982
|
+
softComponents: hydratedSoftComponents,
|
|
2983
|
+
dependencyGraph: initialDependencyGraph,
|
|
2984
|
+
showVersionFields,
|
|
2985
|
+
// ─── Initial softConfig ─────────────────────────────────────────────────
|
|
2986
|
+
softConfig: __spreadProps(__spreadValues({}, hardConfig), {
|
|
2987
|
+
components: __spreadValues(__spreadValues({}, hardConfig.components), buildInitialSoftComponents(
|
|
2988
|
+
hardConfig,
|
|
2989
|
+
hydratedSoftComponents,
|
|
2990
|
+
overrides,
|
|
2991
|
+
showVersionFields,
|
|
2992
|
+
customFields
|
|
2993
|
+
)),
|
|
2994
|
+
categories: __spreadValues({}, hardConfig.categories || {})
|
|
2995
|
+
}),
|
|
2996
|
+
// ─── UI Flags ───────────────────────────────────────────────────────────
|
|
2997
|
+
setShowVersionFields: (show) => set({ showVersionFields: show }),
|
|
2998
|
+
// ─── Iframe ─────────────────────────────────────────────────────────────
|
|
2999
|
+
setIframeDoc: (doc) => set({
|
|
3000
|
+
iframeDoc: doc
|
|
3001
|
+
}),
|
|
3002
|
+
// ─── History ────────────────────────────────────────────────────────────
|
|
3003
|
+
storeHistory: (history) => set({ originalHistory: history }),
|
|
3004
|
+
removeHistory: () => set({ originalHistory: [] }),
|
|
3005
|
+
// ─── Item Selection ─────────────────────────────────────────────────────
|
|
3006
|
+
setItemSelector: (selector) => set({ itemSelector: selector }),
|
|
3007
|
+
setOriginalItem: (item) => set({ originalItem: item }),
|
|
3008
|
+
// ─── Editing State ──────────────────────────────────────────────────────
|
|
3009
|
+
setEditableComponentIds: (ids) => set({ editableComponentIds: ids }),
|
|
3010
|
+
addEditableComponentId: (id) => set((state) => {
|
|
3011
|
+
const newIds = new Set(state.editableComponentIds);
|
|
3012
|
+
newIds.add(id);
|
|
3013
|
+
return { editableComponentIds: newIds };
|
|
3014
|
+
}),
|
|
3015
|
+
clearEditingState: () => set({ editingComponentId: null, editableComponentIds: /* @__PURE__ */ new Set() }),
|
|
3016
|
+
// ─── Action Validation ──────────────────────────────────────────────────
|
|
3017
|
+
undoFn: null,
|
|
3018
|
+
setUndoFn: (fn) => set({ undoFn: fn }),
|
|
3019
|
+
validateAction: (action, previousAction) => {
|
|
3020
|
+
var _a;
|
|
3021
|
+
const { state, editableComponentIds, addEditableComponentId } = get();
|
|
3022
|
+
if (state === "ready") return true;
|
|
3023
|
+
if (action.type === "replace") {
|
|
3024
|
+
if ((previousAction == null ? void 0 : previousAction.type) === "insert" && (previousAction == null ? void 0 : previousAction.id) === action.data.props.id) {
|
|
3025
|
+
return true;
|
|
2970
3026
|
}
|
|
2971
|
-
const
|
|
2972
|
-
if (
|
|
2973
|
-
|
|
2974
|
-
mode: "build",
|
|
2975
|
-
editableIds: editableComponentIds
|
|
2976
|
-
});
|
|
2977
|
-
return;
|
|
3027
|
+
const parentId = (_a = action.destinationZone) == null ? void 0 : _a.split(":")[0];
|
|
3028
|
+
if (action.data.props.id && editableComponentIds.has(action.data.props.id)) {
|
|
3029
|
+
return true;
|
|
2978
3030
|
}
|
|
2979
|
-
if (
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
editableIds: editableComponentIds
|
|
2983
|
-
});
|
|
2984
|
-
return;
|
|
3031
|
+
if (parentId && editableComponentIds.has(parentId)) {
|
|
3032
|
+
addEditableComponentId(action.data.props.id);
|
|
3033
|
+
return true;
|
|
2985
3034
|
}
|
|
2986
|
-
|
|
2987
|
-
}
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
softComponents: hydratedSoftComponents,
|
|
2996
|
-
dependencyGraph: initialDependencyGraph,
|
|
2997
|
-
softConfig: __spreadProps(__spreadValues({}, hardConfig), {
|
|
2998
|
-
components: __spreadValues(__spreadValues({}, hardConfig.components), buildInitialSoftComponents(
|
|
2999
|
-
hardConfig,
|
|
3000
|
-
hydratedSoftComponents,
|
|
3001
|
-
overrides,
|
|
3002
|
-
showVersionFields,
|
|
3003
|
-
customFields
|
|
3004
|
-
)),
|
|
3005
|
-
categories: __spreadValues({}, hardConfig.categories || {})
|
|
3006
|
-
}),
|
|
3007
|
-
setSoftComponent: (name, version, component) => {
|
|
3008
|
-
if (hardConfig.components && hardConfig.components[name]) {
|
|
3009
|
-
console.warn(`Cannot set soft component "${name}" because it conflicts with a base hardConfig component.`);
|
|
3010
|
-
return;
|
|
3035
|
+
return false;
|
|
3036
|
+
}
|
|
3037
|
+
if (action.type === "insert" || action.type === "duplicate") {
|
|
3038
|
+
const zone = action.type === "insert" ? action.destinationZone : action.sourceZone;
|
|
3039
|
+
const parentId = zone == null ? void 0 : zone.split(":")[0];
|
|
3040
|
+
const isEditable = parentId && editableComponentIds.has(parentId);
|
|
3041
|
+
if (!isEditable && action.type === "duplicate") return false;
|
|
3042
|
+
if (action.type === "insert" && action.id && isEditable) {
|
|
3043
|
+
addEditableComponentId(action.id);
|
|
3011
3044
|
}
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3045
|
+
}
|
|
3046
|
+
if (action.type === "remove" || action.type === "move" || action.type === "reorder") {
|
|
3047
|
+
const zone = action.type === "remove" ? action.zone : action.destinationZone;
|
|
3048
|
+
const parentId = zone == null ? void 0 : zone.split(":")[0];
|
|
3049
|
+
if (parentId && !editableComponentIds.has(parentId)) return false;
|
|
3050
|
+
return true;
|
|
3051
|
+
}
|
|
3052
|
+
return true;
|
|
3053
|
+
},
|
|
3054
|
+
// ─── Soft Component CRUD ─────────────────────────────────────────────────
|
|
3055
|
+
setSoftComponent: (name, version, component) => {
|
|
3056
|
+
var _a;
|
|
3057
|
+
if ((_a = hardConfig.components) == null ? void 0 : _a[name]) {
|
|
3058
|
+
console.warn(
|
|
3059
|
+
`Cannot set soft component "${name}" because it conflicts with a hardConfig component.`
|
|
3060
|
+
);
|
|
3061
|
+
return;
|
|
3062
|
+
}
|
|
3063
|
+
const existing = get().softComponents[name];
|
|
3064
|
+
set((state) => {
|
|
3065
|
+
var _a2, _b;
|
|
3066
|
+
return {
|
|
3067
|
+
softComponents: __spreadProps(__spreadValues({}, state.softComponents), {
|
|
3068
|
+
[name]: __spreadProps(__spreadValues({}, existing), {
|
|
3069
|
+
name: component.name || (existing == null ? void 0 : existing.name) || name,
|
|
3070
|
+
category: (_a2 = component.category) != null ? _a2 : existing == null ? void 0 : existing.category,
|
|
3071
|
+
defaultVersion: version,
|
|
3072
|
+
versions: __spreadProps(__spreadValues({}, ((_b = state.softComponents[name]) == null ? void 0 : _b.versions) || {}), {
|
|
3073
|
+
[version]: component
|
|
3024
3074
|
})
|
|
3025
3075
|
})
|
|
3026
|
-
};
|
|
3027
|
-
});
|
|
3028
|
-
},
|
|
3029
|
-
setSoftComponents: (incomingComponents) => {
|
|
3030
|
-
const state = get();
|
|
3031
|
-
const nextSoftComponents = __spreadValues({}, state.softComponents);
|
|
3032
|
-
const nextConfigComponents = __spreadValues({}, state.softConfig.components);
|
|
3033
|
-
Object.entries(incomingComponents).forEach(([name, data]) => {
|
|
3034
|
-
if (hardConfig.components && hardConfig.components[name]) {
|
|
3035
|
-
return;
|
|
3036
|
-
}
|
|
3037
|
-
const existing = nextSoftComponents[name];
|
|
3038
|
-
const finalComponentData = existing ? __spreadProps(__spreadValues(__spreadValues({}, existing), data), {
|
|
3039
|
-
name: data.name || existing.name || name,
|
|
3040
|
-
versions: __spreadValues(__spreadValues({}, existing.versions), data.versions)
|
|
3041
|
-
}) : data;
|
|
3042
|
-
finalComponentData.name = finalComponentData.name || name;
|
|
3043
|
-
nextSoftComponents[name] = finalComponentData;
|
|
3044
|
-
const activeVersion = finalComponentData.defaultVersion;
|
|
3045
|
-
const activeVersionData = finalComponentData.versions[activeVersion];
|
|
3046
|
-
if (activeVersionData) {
|
|
3047
|
-
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
3048
|
-
name,
|
|
3049
|
-
finalComponentData.name || name,
|
|
3050
|
-
activeVersion,
|
|
3051
|
-
Object.keys(finalComponentData.versions),
|
|
3052
|
-
state.softConfig,
|
|
3053
|
-
nextSoftComponents,
|
|
3054
|
-
activeVersionData.defaultProps,
|
|
3055
|
-
state.showVersionFields,
|
|
3056
|
-
state.customFields
|
|
3057
|
-
);
|
|
3058
|
-
}
|
|
3059
|
-
});
|
|
3060
|
-
set({
|
|
3061
|
-
softComponents: nextSoftComponents,
|
|
3062
|
-
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
3063
|
-
components: nextConfigComponents
|
|
3064
3076
|
})
|
|
3065
|
-
}
|
|
3066
|
-
}
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
)
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
components: nextConfigComponents
|
|
3096
|
-
})
|
|
3097
|
-
});
|
|
3098
|
-
},
|
|
3099
|
-
setSoftComponentDefaultVersion: (name, version) => {
|
|
3100
|
-
var _a, _b, _c, _d;
|
|
3101
|
-
const softComponent = (_b = (_a = get().softComponents[name]) == null ? void 0 : _a.versions) == null ? void 0 : _b[version];
|
|
3102
|
-
const allVersions = Object.keys(
|
|
3103
|
-
((_c = get().softComponents[name]) == null ? void 0 : _c.versions) || {}
|
|
3104
|
-
);
|
|
3105
|
-
const displayName = ((_d = get().softComponents[name]) == null ? void 0 : _d.name) || name;
|
|
3106
|
-
if (!softComponent) {
|
|
3107
|
-
throw new Error(
|
|
3108
|
-
`Soft component "${name}" version "${version}" does not exist.`
|
|
3077
|
+
};
|
|
3078
|
+
});
|
|
3079
|
+
},
|
|
3080
|
+
setSoftComponents: (incomingComponents) => {
|
|
3081
|
+
const state = get();
|
|
3082
|
+
const nextSoftComponents = __spreadValues({}, state.softComponents);
|
|
3083
|
+
const nextConfigComponents = __spreadValues({}, state.softConfig.components);
|
|
3084
|
+
Object.entries(incomingComponents).forEach(([name, data]) => {
|
|
3085
|
+
var _a;
|
|
3086
|
+
if ((_a = hardConfig.components) == null ? void 0 : _a[name]) return;
|
|
3087
|
+
const existing = nextSoftComponents[name];
|
|
3088
|
+
const merged = existing ? __spreadProps(__spreadValues(__spreadValues({}, existing), data), {
|
|
3089
|
+
name: data.name || existing.name || name,
|
|
3090
|
+
versions: __spreadValues(__spreadValues({}, existing.versions), data.versions)
|
|
3091
|
+
}) : data;
|
|
3092
|
+
merged.name = merged.name || name;
|
|
3093
|
+
nextSoftComponents[name] = merged;
|
|
3094
|
+
const activeVersion = merged.defaultVersion;
|
|
3095
|
+
const activeVersionData = merged.versions[activeVersion];
|
|
3096
|
+
if (activeVersionData) {
|
|
3097
|
+
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
3098
|
+
name,
|
|
3099
|
+
merged.name,
|
|
3100
|
+
activeVersion,
|
|
3101
|
+
Object.keys(merged.versions),
|
|
3102
|
+
state.softConfig,
|
|
3103
|
+
nextSoftComponents,
|
|
3104
|
+
activeVersionData.defaultProps,
|
|
3105
|
+
state.showVersionFields,
|
|
3106
|
+
state.customFields
|
|
3109
3107
|
);
|
|
3110
3108
|
}
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3109
|
+
});
|
|
3110
|
+
set({
|
|
3111
|
+
softComponents: nextSoftComponents,
|
|
3112
|
+
softConfig: __spreadProps(__spreadValues({}, state.softConfig), { components: nextConfigComponents })
|
|
3113
|
+
});
|
|
3114
|
+
},
|
|
3115
|
+
hydrateTransforms: () => {
|
|
3116
|
+
const { overrides: overrides2, softComponents: softComponents2, softConfig } = get();
|
|
3117
|
+
if (!(overrides2 == null ? void 0 : overrides2.hydrateMapTransform)) return;
|
|
3118
|
+
const hydratedComponents = hydrateSoftComponentsTransforms(
|
|
3119
|
+
softComponents2,
|
|
3120
|
+
overrides2.hydrateMapTransform
|
|
3121
|
+
);
|
|
3122
|
+
const nextConfigComponents = __spreadValues({}, softConfig.components);
|
|
3123
|
+
Object.entries(hydratedComponents).forEach(([name, componentData]) => {
|
|
3124
|
+
const activeVersion = componentData.defaultVersion;
|
|
3125
|
+
const activeVersionData = componentData.versions[activeVersion];
|
|
3126
|
+
if (activeVersionData) {
|
|
3127
|
+
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
3128
|
+
name,
|
|
3129
|
+
componentData.name || name,
|
|
3130
|
+
activeVersion,
|
|
3131
|
+
Object.keys(componentData.versions),
|
|
3132
|
+
softConfig,
|
|
3133
|
+
hydratedComponents,
|
|
3134
|
+
activeVersionData.defaultProps,
|
|
3135
|
+
get().showVersionFields,
|
|
3136
|
+
get().customFields
|
|
3137
|
+
);
|
|
3138
|
+
}
|
|
3139
|
+
});
|
|
3140
|
+
set({
|
|
3141
|
+
softComponents: hydratedComponents,
|
|
3142
|
+
softConfig: __spreadProps(__spreadValues({}, softConfig), { components: nextConfigComponents })
|
|
3143
|
+
});
|
|
3144
|
+
},
|
|
3145
|
+
setSoftComponentDefaultVersion: (name, version) => {
|
|
3146
|
+
var _a, _b, _c, _d;
|
|
3147
|
+
const state = get();
|
|
3148
|
+
const softComponent = (_b = (_a = state.softComponents[name]) == null ? void 0 : _a.versions) == null ? void 0 : _b[version];
|
|
3149
|
+
if (!softComponent) {
|
|
3150
|
+
throw new Error(
|
|
3151
|
+
`Soft component "${name}" version "${version}" does not exist.`
|
|
3121
3152
|
);
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3153
|
+
}
|
|
3154
|
+
const allVersions = Object.keys(
|
|
3155
|
+
((_c = state.softComponents[name]) == null ? void 0 : _c.versions) || {}
|
|
3156
|
+
);
|
|
3157
|
+
const displayName = ((_d = state.softComponents[name]) == null ? void 0 : _d.name) || name;
|
|
3158
|
+
const newConfig = createVersionedComponentConfig(
|
|
3159
|
+
name,
|
|
3160
|
+
displayName,
|
|
3161
|
+
version,
|
|
3162
|
+
allVersions,
|
|
3163
|
+
state.softConfig,
|
|
3164
|
+
state.softComponents,
|
|
3165
|
+
softComponent.defaultProps,
|
|
3166
|
+
state.showVersionFields,
|
|
3167
|
+
state.customFields
|
|
3168
|
+
);
|
|
3169
|
+
set((s) => ({
|
|
3170
|
+
softConfig: __spreadProps(__spreadValues({}, s.softConfig), {
|
|
3171
|
+
components: __spreadProps(__spreadValues({}, s.softConfig.components), { [name]: newConfig })
|
|
3172
|
+
}),
|
|
3173
|
+
softComponents: __spreadProps(__spreadValues({}, s.softComponents), {
|
|
3174
|
+
[name]: __spreadProps(__spreadValues({}, s.softComponents[name]), { defaultVersion: version })
|
|
3175
|
+
})
|
|
3176
|
+
}));
|
|
3177
|
+
},
|
|
3178
|
+
removeSoftComponentVersion: (key, version) => {
|
|
3179
|
+
set((state) => {
|
|
3180
|
+
const component = state.softComponents[key];
|
|
3181
|
+
if (!component) return {};
|
|
3182
|
+
const newVersions = Object.fromEntries(
|
|
3183
|
+
Object.entries(component.versions || {}).filter(
|
|
3184
|
+
([k]) => k !== version
|
|
3185
|
+
)
|
|
3186
|
+
);
|
|
3187
|
+
let newDefaultVersion = component.defaultVersion;
|
|
3188
|
+
if (component.defaultVersion === version) {
|
|
3189
|
+
const versionKeys = Object.keys(newVersions);
|
|
3190
|
+
newDefaultVersion = versionKeys.length > 0 ? versionKeys[versionKeys.length - 1] : "";
|
|
3191
|
+
}
|
|
3192
|
+
return {
|
|
3128
3193
|
softComponents: __spreadProps(__spreadValues({}, state.softComponents), {
|
|
3129
|
-
[
|
|
3130
|
-
|
|
3194
|
+
[key]: __spreadProps(__spreadValues({}, component), {
|
|
3195
|
+
versions: newVersions,
|
|
3196
|
+
defaultVersion: newDefaultVersion
|
|
3131
3197
|
})
|
|
3132
3198
|
})
|
|
3133
|
-
}
|
|
3134
|
-
}
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
if (component.defaultVersion === version) {
|
|
3146
|
-
const versionKeys = Object.keys(newVersions);
|
|
3147
|
-
newDefaultVersion = versionKeys.length > 0 ? versionKeys[versionKeys.length - 1] : "";
|
|
3148
|
-
}
|
|
3149
|
-
return {
|
|
3150
|
-
softComponents: __spreadProps(__spreadValues({}, state.softComponents), {
|
|
3151
|
-
[key]: __spreadProps(__spreadValues({}, component), {
|
|
3152
|
-
versions: newVersions,
|
|
3153
|
-
defaultVersion: newDefaultVersion
|
|
3154
|
-
})
|
|
3155
|
-
})
|
|
3156
|
-
};
|
|
3157
|
-
});
|
|
3158
|
-
},
|
|
3159
|
-
removeSoftComponent: (key) => {
|
|
3160
|
-
set((state) => ({
|
|
3161
|
-
softComponents: Object.fromEntries(
|
|
3162
|
-
Object.entries(state.softComponents).filter(([k, _]) => k !== key)
|
|
3163
|
-
)
|
|
3164
|
-
}));
|
|
3165
|
-
},
|
|
3166
|
-
setSoftComponentConfig: (key, config, category) => {
|
|
3167
|
-
set((state) => {
|
|
3168
|
-
var _a, _b, _c;
|
|
3169
|
-
return {
|
|
3170
|
-
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
3171
|
-
components: __spreadProps(__spreadValues({}, state.softConfig.components), {
|
|
3172
|
-
[key]: __spreadValues({}, config)
|
|
3173
|
-
}),
|
|
3174
|
-
categories: category ? __spreadProps(__spreadValues({}, state.softConfig.categories || {}), {
|
|
3175
|
-
[category]: __spreadProps(__spreadValues({}, ((_a = state.softConfig.categories) == null ? void 0 : _a[category]) || {}), {
|
|
3176
|
-
components: [
|
|
3177
|
-
...((_c = (_b = state.softConfig.categories) == null ? void 0 : _b[category]) == null ? void 0 : _c.components) || [],
|
|
3178
|
-
key
|
|
3179
|
-
]
|
|
3180
|
-
})
|
|
3181
|
-
}) : state.softConfig.categories || {}
|
|
3182
|
-
})
|
|
3183
|
-
};
|
|
3184
|
-
});
|
|
3185
|
-
},
|
|
3186
|
-
removeSoftComponentConfig: (key) => {
|
|
3187
|
-
set((state) => ({
|
|
3199
|
+
};
|
|
3200
|
+
});
|
|
3201
|
+
},
|
|
3202
|
+
removeSoftComponent: (key) => set((state) => ({
|
|
3203
|
+
softComponents: Object.fromEntries(
|
|
3204
|
+
Object.entries(state.softComponents).filter(([k]) => k !== key)
|
|
3205
|
+
)
|
|
3206
|
+
})),
|
|
3207
|
+
setSoftComponentConfig: (key, config, category) => {
|
|
3208
|
+
set((state) => {
|
|
3209
|
+
var _a, _b, _c;
|
|
3210
|
+
return {
|
|
3188
3211
|
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
3189
|
-
components:
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
set((state) => {
|
|
3199
|
-
var _a;
|
|
3200
|
-
return {
|
|
3201
|
-
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
3202
|
-
categories: __spreadProps(__spreadValues({}, state.softConfig.categories), {
|
|
3203
|
-
[key]: __spreadValues(__spreadValues({}, (_a = state.softConfig.categories) == null ? void 0 : _a[key]), category)
|
|
3212
|
+
components: __spreadProps(__spreadValues({}, state.softConfig.components), {
|
|
3213
|
+
[key]: __spreadValues({}, config)
|
|
3214
|
+
}),
|
|
3215
|
+
categories: category ? __spreadProps(__spreadValues({}, state.softConfig.categories || {}), {
|
|
3216
|
+
[category]: __spreadProps(__spreadValues({}, ((_a = state.softConfig.categories) == null ? void 0 : _a[category]) || {}), {
|
|
3217
|
+
components: [
|
|
3218
|
+
...((_c = (_b = state.softConfig.categories) == null ? void 0 : _b[category]) == null ? void 0 : _c.components) || [],
|
|
3219
|
+
key
|
|
3220
|
+
]
|
|
3204
3221
|
})
|
|
3205
|
-
})
|
|
3206
|
-
};
|
|
3207
|
-
});
|
|
3208
|
-
},
|
|
3209
|
-
removeSoftCategoryConfig: (key) => {
|
|
3210
|
-
set((state) => ({
|
|
3211
|
-
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
3212
|
-
categories: Object.fromEntries(
|
|
3213
|
-
Object.entries(state.softConfig.categories || {}).filter(
|
|
3214
|
-
([k, _]) => k !== key
|
|
3215
|
-
)
|
|
3216
|
-
)
|
|
3222
|
+
}) : state.softConfig.categories || {}
|
|
3217
3223
|
})
|
|
3218
|
-
}
|
|
3219
|
-
}
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3224
|
+
};
|
|
3225
|
+
});
|
|
3226
|
+
},
|
|
3227
|
+
removeSoftComponentConfig: (key) => set((state) => ({
|
|
3228
|
+
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
3229
|
+
components: Object.fromEntries(
|
|
3230
|
+
Object.entries(state.softConfig.components).filter(
|
|
3231
|
+
([k]) => k !== key
|
|
3232
|
+
)
|
|
3233
|
+
)
|
|
3234
|
+
})
|
|
3235
|
+
})),
|
|
3236
|
+
setSoftCategoryConfig: (key, category) => set((state) => {
|
|
3237
|
+
var _a;
|
|
3238
|
+
return {
|
|
3239
|
+
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
3240
|
+
categories: __spreadProps(__spreadValues({}, state.softConfig.categories), {
|
|
3241
|
+
[key]: __spreadValues(__spreadValues({}, (_a = state.softConfig.categories) == null ? void 0 : _a[key]), category)
|
|
3242
|
+
})
|
|
3243
|
+
})
|
|
3244
|
+
};
|
|
3245
|
+
}),
|
|
3246
|
+
removeSoftCategoryConfig: (key) => set((state) => ({
|
|
3247
|
+
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
3248
|
+
categories: Object.fromEntries(
|
|
3249
|
+
Object.entries(state.softConfig.categories || {}).filter(
|
|
3250
|
+
([k]) => k !== key
|
|
3251
|
+
)
|
|
3252
|
+
)
|
|
3253
|
+
})
|
|
3254
|
+
})),
|
|
3255
|
+
// ─── Builder Slice ────────────────────────────────────────────────────────
|
|
3256
|
+
builder: createBuildersSlice(set, get, hardConfig),
|
|
3257
|
+
// ─── Dependency Graph ─────────────────────────────────────────────────────
|
|
3258
|
+
rebuildDependents: (componentName) => {
|
|
3259
|
+
const state = get();
|
|
3260
|
+
const dependents = state.dependencyGraph.get(componentName) || /* @__PURE__ */ new Set();
|
|
3261
|
+
if (dependents.size === 0) return;
|
|
3262
|
+
const nextConfig = __spreadValues({}, state.softConfig);
|
|
3263
|
+
const { softComponents: softComponents2 } = state;
|
|
3264
|
+
for (const dependentName of Array.from(dependents)) {
|
|
3265
|
+
const dependent = softComponents2[dependentName];
|
|
3266
|
+
const defaultVersion = dependent.defaultVersion || Object.keys(dependent.versions || {}).pop();
|
|
3267
|
+
if (!defaultVersion) continue;
|
|
3268
|
+
const versionedComponent = dependent.versions[defaultVersion];
|
|
3269
|
+
if (!versionedComponent) continue;
|
|
3270
|
+
nextConfig.components[dependentName] = createVersionedComponentConfig(
|
|
3271
|
+
dependentName,
|
|
3272
|
+
dependent.name || dependentName,
|
|
3273
|
+
defaultVersion,
|
|
3274
|
+
Object.keys(dependent.versions || {}),
|
|
3275
|
+
nextConfig,
|
|
3276
|
+
softComponents2,
|
|
3277
|
+
versionedComponent.defaultProps,
|
|
3278
|
+
state.showVersionFields,
|
|
3279
|
+
state.customFields
|
|
3280
|
+
);
|
|
3263
3281
|
}
|
|
3264
|
-
|
|
3265
|
-
|
|
3282
|
+
set((s) => __spreadProps(__spreadValues({}, s), { softConfig: nextConfig }));
|
|
3283
|
+
}
|
|
3284
|
+
}))
|
|
3266
3285
|
);
|
|
3267
3286
|
};
|
|
3268
3287
|
|
|
3269
3288
|
// src/puck/context/storeProvider.tsx
|
|
3270
3289
|
var import_react5 = require("react");
|
|
3290
|
+
|
|
3291
|
+
// src/puck/lib/notify.ts
|
|
3292
|
+
var customHandler = null;
|
|
3293
|
+
var defaultHandler = (message, type) => {
|
|
3294
|
+
if (type === "error") {
|
|
3295
|
+
console.error(`[Error] ${message}`);
|
|
3296
|
+
} else {
|
|
3297
|
+
console.log(`[Success] ${message}`);
|
|
3298
|
+
}
|
|
3299
|
+
};
|
|
3300
|
+
var setNotificationHandler = (handler) => {
|
|
3301
|
+
customHandler = handler;
|
|
3302
|
+
};
|
|
3303
|
+
var notify = {
|
|
3304
|
+
error: (message) => {
|
|
3305
|
+
const handler = customHandler || defaultHandler;
|
|
3306
|
+
handler(message, "error");
|
|
3307
|
+
},
|
|
3308
|
+
success: (message) => {
|
|
3309
|
+
const handler = customHandler || defaultHandler;
|
|
3310
|
+
handler(message, "success");
|
|
3311
|
+
}
|
|
3312
|
+
};
|
|
3313
|
+
|
|
3314
|
+
// src/puck/lib/action-callback.ts
|
|
3315
|
+
var createActionCallback = (validateAction, undo) => {
|
|
3316
|
+
return (action) => {
|
|
3317
|
+
if (!undo) {
|
|
3318
|
+
return;
|
|
3319
|
+
}
|
|
3320
|
+
const isValid = validateAction(action);
|
|
3321
|
+
if (!isValid) {
|
|
3322
|
+
notify.error(
|
|
3323
|
+
"Editing outside the soft component is not allowed when you are editing component definition."
|
|
3324
|
+
);
|
|
3325
|
+
requestAnimationFrame(() => undo());
|
|
3326
|
+
}
|
|
3327
|
+
};
|
|
3328
|
+
};
|
|
3329
|
+
|
|
3330
|
+
// src/puck/context/storeProvider.tsx
|
|
3271
3331
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3272
3332
|
var SoftConfigProvider = ({
|
|
3273
3333
|
children,
|
|
@@ -3303,57 +3363,8 @@ var SoftConfigProvider = ({
|
|
|
3303
3363
|
const [internalSoftComponents, setSoftComponents] = (0, import_react5.useState)(
|
|
3304
3364
|
() => store.getState().softComponents
|
|
3305
3365
|
);
|
|
3306
|
-
const
|
|
3307
|
-
() =>
|
|
3308
|
-
[store]
|
|
3309
|
-
);
|
|
3310
|
-
const validateAction = (0, import_react5.useMemo)(
|
|
3311
|
-
() => (action) => {
|
|
3312
|
-
var _a;
|
|
3313
|
-
const currentState = store.getState();
|
|
3314
|
-
if (currentState.state === "ready") {
|
|
3315
|
-
return true;
|
|
3316
|
-
}
|
|
3317
|
-
const editableIds = currentState.editableComponentIds;
|
|
3318
|
-
if (action.type === "replace") {
|
|
3319
|
-
const parentId = (_a = action.destinationZone) == null ? void 0 : _a.split(":")[0];
|
|
3320
|
-
if (action.data.props.id && editableIds.has(action.data.props.id)) {
|
|
3321
|
-
return true;
|
|
3322
|
-
} else if (parentId && editableIds.has(parentId)) {
|
|
3323
|
-
currentState.addEditableComponentId(action.data.props.id);
|
|
3324
|
-
return true;
|
|
3325
|
-
}
|
|
3326
|
-
return false;
|
|
3327
|
-
}
|
|
3328
|
-
if (action.type === "insert" || action.type === "duplicate") {
|
|
3329
|
-
const zone = action.type === "insert" ? action.destinationZone : action.sourceZone;
|
|
3330
|
-
const parentId = zone == null ? void 0 : zone.split(":")[0];
|
|
3331
|
-
if (parentId && !editableIds.has(parentId)) {
|
|
3332
|
-
return false;
|
|
3333
|
-
}
|
|
3334
|
-
if (action.type === "insert") {
|
|
3335
|
-
const childId = action.id;
|
|
3336
|
-
if (childId) {
|
|
3337
|
-
currentState.addEditableComponentId(childId);
|
|
3338
|
-
}
|
|
3339
|
-
}
|
|
3340
|
-
return true;
|
|
3341
|
-
}
|
|
3342
|
-
if (action.type === "remove" || action.type === "move" || action.type === "reorder") {
|
|
3343
|
-
let parentId;
|
|
3344
|
-
if (action.type === "remove") {
|
|
3345
|
-
parentId = action.zone.split(":")[0];
|
|
3346
|
-
} else if (action.type === "move" || action.type === "reorder") {
|
|
3347
|
-
parentId = action.destinationZone.split(":")[0];
|
|
3348
|
-
}
|
|
3349
|
-
if (parentId && !editableIds.has(parentId)) {
|
|
3350
|
-
return false;
|
|
3351
|
-
}
|
|
3352
|
-
return true;
|
|
3353
|
-
}
|
|
3354
|
-
return true;
|
|
3355
|
-
},
|
|
3356
|
-
[store]
|
|
3366
|
+
const [actionGuard, setActionGuard] = (0, import_react5.useState)(
|
|
3367
|
+
(action) => null
|
|
3357
3368
|
);
|
|
3358
3369
|
(0, import_react5.useEffect)(() => {
|
|
3359
3370
|
const unsubscribe = store.subscribe(() => {
|
|
@@ -3366,59 +3377,26 @@ var SoftConfigProvider = ({
|
|
|
3366
3377
|
}, [store]);
|
|
3367
3378
|
(0, import_react5.useEffect)(() => {
|
|
3368
3379
|
const unsubscribe = store.subscribe((state, prevState) => {
|
|
3369
|
-
if (prevState &&
|
|
3370
|
-
return;
|
|
3371
|
-
}
|
|
3372
|
-
const doc = store.getState().getIframeDoc();
|
|
3373
|
-
if (!doc) return;
|
|
3374
|
-
if (state.state === "building") {
|
|
3375
|
-
setEditVisibility(doc, { mode: "build", editableIds: state.editableComponentIds });
|
|
3380
|
+
if (prevState && prevState.undoFn === state.undoFn) {
|
|
3376
3381
|
return;
|
|
3377
3382
|
}
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
if (freshDoc) {
|
|
3385
|
-
clearEditVisibility(freshDoc);
|
|
3386
|
-
}
|
|
3387
|
-
});
|
|
3383
|
+
setActionGuard(
|
|
3384
|
+
() => createActionCallback(
|
|
3385
|
+
state.validateAction,
|
|
3386
|
+
state.undoFn
|
|
3387
|
+
)
|
|
3388
|
+
);
|
|
3388
3389
|
});
|
|
3389
3390
|
return () => {
|
|
3390
3391
|
unsubscribe();
|
|
3391
3392
|
};
|
|
3392
|
-
}, [store]);
|
|
3393
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(appStoreContext.Provider, { value: store, children: children(softConfig, internalSoftComponents,
|
|
3393
|
+
}, [store.getState().undoFn]);
|
|
3394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(appStoreContext.Provider, { value: store, children: children(softConfig, internalSoftComponents, actionGuard) });
|
|
3394
3395
|
};
|
|
3395
3396
|
|
|
3396
3397
|
// src/puck/actions/useBuild.tsx
|
|
3397
3398
|
var import_puck5 = require("@measured/puck");
|
|
3398
3399
|
|
|
3399
|
-
// src/puck/lib/notify.ts
|
|
3400
|
-
var customHandler = null;
|
|
3401
|
-
var defaultHandler = (message, type) => {
|
|
3402
|
-
if (type === "error") {
|
|
3403
|
-
console.error(`[Error] ${message}`);
|
|
3404
|
-
} else {
|
|
3405
|
-
console.log(`[Success] ${message}`);
|
|
3406
|
-
}
|
|
3407
|
-
};
|
|
3408
|
-
var setNotificationHandler = (handler) => {
|
|
3409
|
-
customHandler = handler;
|
|
3410
|
-
};
|
|
3411
|
-
var notify = {
|
|
3412
|
-
error: (message) => {
|
|
3413
|
-
const handler = customHandler || defaultHandler;
|
|
3414
|
-
handler(message, "error");
|
|
3415
|
-
},
|
|
3416
|
-
success: (message) => {
|
|
3417
|
-
const handler = customHandler || defaultHandler;
|
|
3418
|
-
handler(message, "success");
|
|
3419
|
-
}
|
|
3420
|
-
};
|
|
3421
|
-
|
|
3422
3400
|
// src/puck/hooks/useActionEvent.ts
|
|
3423
3401
|
var import_react6 = require("react");
|
|
3424
3402
|
var useActionEvent = () => {
|
|
@@ -3796,7 +3774,7 @@ var useSetDefaultVersion = () => {
|
|
|
3796
3774
|
// src/puck/overrides/Header.tsx
|
|
3797
3775
|
var import_puck13 = require("@measured/puck");
|
|
3798
3776
|
|
|
3799
|
-
// css-module:/
|
|
3777
|
+
// css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/overrides/Header.module.css#css-module
|
|
3800
3778
|
var Header_module_default = { "Header": "_Header_19oj9_1" };
|
|
3801
3779
|
|
|
3802
3780
|
// src/puck/actions/usePublish.tsx
|
|
@@ -3845,7 +3823,6 @@ var Header = ({
|
|
|
3845
3823
|
const { handleComplete, newComponent, setNewComponent } = useComplete();
|
|
3846
3824
|
const { handleCancel, canCancel } = useCancel();
|
|
3847
3825
|
const { handlePublish } = usePublish();
|
|
3848
|
-
const puck = usePuck((s) => s.config);
|
|
3849
3826
|
useInspect(newComponent);
|
|
3850
3827
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName2(), children: canCancel ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3851
3828
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_puck13.Button, { onClick: handleCancel, children: "Cancel" }),
|
|
@@ -3881,7 +3858,7 @@ var import_react9 = require("react");
|
|
|
3881
3858
|
var import_puck14 = require("@measured/puck");
|
|
3882
3859
|
var import_lucide_react = require("lucide-react");
|
|
3883
3860
|
|
|
3884
|
-
// css-module:/
|
|
3861
|
+
// css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/overrides/ActionBar.module.css#css-module
|
|
3885
3862
|
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" };
|
|
3886
3863
|
|
|
3887
3864
|
// src/puck/overrides/ActionBar.tsx
|
|
@@ -3907,7 +3884,7 @@ var ActionBarOverride = (props) => {
|
|
|
3907
3884
|
if (selectedType && softKeys.includes(selectedType)) {
|
|
3908
3885
|
return selectedType;
|
|
3909
3886
|
}
|
|
3910
|
-
return
|
|
3887
|
+
return componentNameFromLabel(props.label || "", overrides, __spreadProps(__spreadValues({}, rootProps || {}), {
|
|
3911
3888
|
existingKeys: softKeys,
|
|
3912
3889
|
state: status
|
|
3913
3890
|
}));
|
|
@@ -3923,17 +3900,17 @@ var ActionBarOverride = (props) => {
|
|
|
3923
3900
|
const selectedId = (_a = selectedItem == null ? void 0 : selectedItem.props) == null ? void 0 : _a.id;
|
|
3924
3901
|
const parentId = (_b = itemSelector == null ? void 0 : itemSelector.zone) == null ? void 0 : _b.split(":")[0];
|
|
3925
3902
|
const isEditable = Boolean(selectedId && (editableIds.has(selectedId) || parentId && editableIds.has(parentId)));
|
|
3926
|
-
const
|
|
3903
|
+
const label = (0, import_react9.useMemo)(() => {
|
|
3927
3904
|
var _a2;
|
|
3928
3905
|
if (isSoftComponent2) {
|
|
3929
|
-
return ((_a2 = softComponents[key]) == null ? void 0 : _a2.name) ||
|
|
3906
|
+
return ((_a2 = softComponents[key]) == null ? void 0 : _a2.name) || componentLabelFromName(key, overrides);
|
|
3930
3907
|
}
|
|
3931
3908
|
return props.label || "";
|
|
3932
3909
|
}, [isSoftComponent2, key, props.label, overrides, softComponents]);
|
|
3933
3910
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName3(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck14.ActionBar, { children: [
|
|
3934
3911
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck14.ActionBar.Group, { children: [
|
|
3935
3912
|
props.parentAction,
|
|
3936
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_puck14.ActionBar.Label, { label
|
|
3913
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_puck14.ActionBar.Label, { label })
|
|
3937
3914
|
] }),
|
|
3938
3915
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck14.ActionBar.Group, { children: [
|
|
3939
3916
|
status === "ready" ? isSoftComponent2 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
@@ -3988,14 +3965,14 @@ var confirm = (message) => __async(null, null, function* () {
|
|
|
3988
3965
|
}
|
|
3989
3966
|
});
|
|
3990
3967
|
|
|
3991
|
-
// css-module:/
|
|
3968
|
+
// css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/overrides/DrawerItem.module.css#css-module
|
|
3992
3969
|
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" };
|
|
3993
3970
|
|
|
3994
3971
|
// src/puck/components/modal/index.tsx
|
|
3995
3972
|
var import_react10 = require("react");
|
|
3996
3973
|
var import_react_dom = require("react-dom");
|
|
3997
3974
|
|
|
3998
|
-
// css-module:/
|
|
3975
|
+
// css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/components/modal/styles.module.css#css-module
|
|
3999
3976
|
var styles_module_default2 = { "Modal": "_Modal_1t9ot_1", "Modal--isOpen": "_Modal--isOpen_1t9ot_29", "Modal-inner": "_Modal-inner_1t9ot_37" };
|
|
4000
3977
|
|
|
4001
3978
|
// src/puck/components/modal/index.tsx
|
|
@@ -4230,6 +4207,7 @@ var DrawerItem = (props) => {
|
|
|
4230
4207
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
4231
4208
|
"button",
|
|
4232
4209
|
{
|
|
4210
|
+
"aria-label": target.label,
|
|
4233
4211
|
type: "button",
|
|
4234
4212
|
role: "radio",
|
|
4235
4213
|
"aria-checked": isSelected,
|
|
@@ -4280,7 +4258,7 @@ var import_react12 = require("react");
|
|
|
4280
4258
|
var import_puck16 = require("@measured/puck");
|
|
4281
4259
|
var import_lucide_react3 = require("lucide-react");
|
|
4282
4260
|
|
|
4283
|
-
// css-module:/
|
|
4261
|
+
// css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/overrides/Drawer.module.css#css-module
|
|
4284
4262
|
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" };
|
|
4285
4263
|
|
|
4286
4264
|
// src/puck/overrides/Drawer.tsx
|
|
@@ -4392,25 +4370,37 @@ var Drawer = (_props) => {
|
|
|
4392
4370
|
] });
|
|
4393
4371
|
};
|
|
4394
4372
|
|
|
4395
|
-
// src/puck/
|
|
4396
|
-
var
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4373
|
+
// src/puck/overrides/HeaderActions.tsx
|
|
4374
|
+
var import_puck17 = require("@measured/puck");
|
|
4375
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
4376
|
+
var usePuck5 = (0, import_puck17.createUsePuck)();
|
|
4377
|
+
var HeaderActions = ({ children }) => {
|
|
4378
|
+
const { handleComplete } = useComplete();
|
|
4379
|
+
const { handleCancel, canCancel } = useCancel();
|
|
4380
|
+
const dispatch = usePuck5((s) => s.dispatch);
|
|
4381
|
+
const inspect = useSoftConfig((s) => s.builder.inspect);
|
|
4382
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: canCancel ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
4383
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_puck17.Button, { onClick: handleCancel, children: "Cancel" }),
|
|
4384
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
4385
|
+
import_puck17.Button,
|
|
4386
|
+
{
|
|
4387
|
+
variant: "primary",
|
|
4388
|
+
onClick: () => {
|
|
4389
|
+
const completedComponent = handleComplete();
|
|
4390
|
+
if (completedComponent) {
|
|
4391
|
+
try {
|
|
4392
|
+
inspect(completedComponent.id, dispatch);
|
|
4393
|
+
} catch (error) {
|
|
4394
|
+
notify.error(
|
|
4395
|
+
"Failed to inspect after completion: " + (error instanceof Error ? error.message : String(error))
|
|
4396
|
+
);
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4399
|
+
},
|
|
4400
|
+
children: "Complete"
|
|
4411
4401
|
}
|
|
4412
|
-
|
|
4413
|
-
};
|
|
4402
|
+
)
|
|
4403
|
+
] }) : children });
|
|
4414
4404
|
};
|
|
4415
4405
|
|
|
4416
4406
|
// src/puck/lib/dissolve-all-soft-components.ts
|
|
@@ -4622,6 +4612,7 @@ var resolveSoftConfig = (data, softComponents, config) => {
|
|
|
4622
4612
|
Drawer,
|
|
4623
4613
|
DrawerItem,
|
|
4624
4614
|
Header,
|
|
4615
|
+
HeaderActions,
|
|
4625
4616
|
Modal,
|
|
4626
4617
|
SoftConfigProvider,
|
|
4627
4618
|
applyMapping,
|