@measured/puck 0.10.0-canary.a7d9a28 → 0.10.0-canary.c276b23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +224 -171
- package/dist/index.d.ts +19 -10
- package/dist/index.js +930 -508
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -327,7 +327,7 @@ var require_react_is_development = __commonJS({
|
|
327
327
|
var ContextProvider = REACT_PROVIDER_TYPE;
|
328
328
|
var Element = REACT_ELEMENT_TYPE;
|
329
329
|
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
330
|
-
var
|
330
|
+
var Fragment11 = REACT_FRAGMENT_TYPE;
|
331
331
|
var Lazy = REACT_LAZY_TYPE;
|
332
332
|
var Memo = REACT_MEMO_TYPE;
|
333
333
|
var Portal = REACT_PORTAL_TYPE;
|
@@ -386,7 +386,7 @@ var require_react_is_development = __commonJS({
|
|
386
386
|
exports.ContextProvider = ContextProvider;
|
387
387
|
exports.Element = Element;
|
388
388
|
exports.ForwardRef = ForwardRef;
|
389
|
-
exports.Fragment =
|
389
|
+
exports.Fragment = Fragment11;
|
390
390
|
exports.Lazy = Lazy;
|
391
391
|
exports.Memo = Memo;
|
392
392
|
exports.Portal = Portal;
|
@@ -760,7 +760,7 @@ var require_factoryWithTypeCheckers = __commonJS({
|
|
760
760
|
function validate(props, propName, componentName, location, propFullName) {
|
761
761
|
if (!(props[propName] instanceof expectedClass)) {
|
762
762
|
var expectedClassName = expectedClass.name || ANONYMOUS;
|
763
|
-
var actualClassName =
|
763
|
+
var actualClassName = getClassName18(props[propName]);
|
764
764
|
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`."));
|
765
765
|
}
|
766
766
|
return null;
|
@@ -1012,7 +1012,7 @@ var require_factoryWithTypeCheckers = __commonJS({
|
|
1012
1012
|
return type;
|
1013
1013
|
}
|
1014
1014
|
}
|
1015
|
-
function
|
1015
|
+
function getClassName18(propValue) {
|
1016
1016
|
if (!propValue.constructor || !propValue.constructor.name) {
|
1017
1017
|
return ANONYMOUS;
|
1018
1018
|
}
|
@@ -1214,11 +1214,11 @@ var Button = ({
|
|
1214
1214
|
|
1215
1215
|
// components/DropZone/index.tsx
|
1216
1216
|
init_react_import();
|
1217
|
-
var
|
1217
|
+
var import_react22 = require("react");
|
1218
1218
|
|
1219
1219
|
// components/DraggableComponent/index.tsx
|
1220
1220
|
init_react_import();
|
1221
|
-
var
|
1221
|
+
var import_react19 = require("react");
|
1222
1222
|
var import_react_beautiful_dnd = require("react-beautiful-dnd");
|
1223
1223
|
|
1224
1224
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
@@ -2130,7 +2130,7 @@ List.propTypes = {
|
|
2130
2130
|
List.displayName = "List";
|
2131
2131
|
var list_default = List;
|
2132
2132
|
|
2133
|
-
// ../../node_modules/react-feather/dist/icons/
|
2133
|
+
// ../../node_modules/react-feather/dist/icons/plus.js
|
2134
2134
|
init_react_import();
|
2135
2135
|
var import_react14 = __toESM(require("react"));
|
2136
2136
|
var import_prop_types12 = __toESM(require_prop_types());
|
@@ -2180,7 +2180,7 @@ function _objectWithoutPropertiesLoose12(source, excluded) {
|
|
2180
2180
|
}
|
2181
2181
|
return target;
|
2182
2182
|
}
|
2183
|
-
var
|
2183
|
+
var Plus = (0, import_react14.forwardRef)(function(_ref, ref) {
|
2184
2184
|
var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, _ref$size = _ref.size, size = _ref$size === void 0 ? 24 : _ref$size, rest = _objectWithoutProperties12(_ref, ["color", "size"]);
|
2185
2185
|
return /* @__PURE__ */ import_react14.default.createElement("svg", _extends12({
|
2186
2186
|
ref,
|
@@ -2193,28 +2193,26 @@ var Sidebar = (0, import_react14.forwardRef)(function(_ref, ref) {
|
|
2193
2193
|
strokeWidth: "2",
|
2194
2194
|
strokeLinecap: "round",
|
2195
2195
|
strokeLinejoin: "round"
|
2196
|
-
}, rest), /* @__PURE__ */ import_react14.default.createElement("
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
rx: "2",
|
2202
|
-
ry: "2"
|
2196
|
+
}, rest), /* @__PURE__ */ import_react14.default.createElement("line", {
|
2197
|
+
x1: "12",
|
2198
|
+
y1: "5",
|
2199
|
+
x2: "12",
|
2200
|
+
y2: "19"
|
2203
2201
|
}), /* @__PURE__ */ import_react14.default.createElement("line", {
|
2204
|
-
x1: "
|
2205
|
-
y1: "
|
2206
|
-
x2: "
|
2207
|
-
y2: "
|
2202
|
+
x1: "5",
|
2203
|
+
y1: "12",
|
2204
|
+
x2: "19",
|
2205
|
+
y2: "12"
|
2208
2206
|
}));
|
2209
2207
|
});
|
2210
|
-
|
2208
|
+
Plus.propTypes = {
|
2211
2209
|
color: import_prop_types12.default.string,
|
2212
2210
|
size: import_prop_types12.default.oneOfType([import_prop_types12.default.string, import_prop_types12.default.number])
|
2213
2211
|
};
|
2214
|
-
|
2215
|
-
var
|
2212
|
+
Plus.displayName = "Plus";
|
2213
|
+
var plus_default = Plus;
|
2216
2214
|
|
2217
|
-
// ../../node_modules/react-feather/dist/icons/
|
2215
|
+
// ../../node_modules/react-feather/dist/icons/sidebar.js
|
2218
2216
|
init_react_import();
|
2219
2217
|
var import_react15 = __toESM(require("react"));
|
2220
2218
|
var import_prop_types13 = __toESM(require_prop_types());
|
@@ -2264,7 +2262,7 @@ function _objectWithoutPropertiesLoose13(source, excluded) {
|
|
2264
2262
|
}
|
2265
2263
|
return target;
|
2266
2264
|
}
|
2267
|
-
var
|
2265
|
+
var Sidebar = (0, import_react15.forwardRef)(function(_ref, ref) {
|
2268
2266
|
var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, _ref$size = _ref.size, size = _ref$size === void 0 ? 24 : _ref$size, rest = _objectWithoutProperties13(_ref, ["color", "size"]);
|
2269
2267
|
return /* @__PURE__ */ import_react15.default.createElement("svg", _extends13({
|
2270
2268
|
ref,
|
@@ -2277,20 +2275,28 @@ var Trash = (0, import_react15.forwardRef)(function(_ref, ref) {
|
|
2277
2275
|
strokeWidth: "2",
|
2278
2276
|
strokeLinecap: "round",
|
2279
2277
|
strokeLinejoin: "round"
|
2280
|
-
}, rest), /* @__PURE__ */ import_react15.default.createElement("
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2278
|
+
}, rest), /* @__PURE__ */ import_react15.default.createElement("rect", {
|
2279
|
+
x: "3",
|
2280
|
+
y: "3",
|
2281
|
+
width: "18",
|
2282
|
+
height: "18",
|
2283
|
+
rx: "2",
|
2284
|
+
ry: "2"
|
2285
|
+
}), /* @__PURE__ */ import_react15.default.createElement("line", {
|
2286
|
+
x1: "9",
|
2287
|
+
y1: "3",
|
2288
|
+
x2: "9",
|
2289
|
+
y2: "21"
|
2284
2290
|
}));
|
2285
2291
|
});
|
2286
|
-
|
2292
|
+
Sidebar.propTypes = {
|
2287
2293
|
color: import_prop_types13.default.string,
|
2288
2294
|
size: import_prop_types13.default.oneOfType([import_prop_types13.default.string, import_prop_types13.default.number])
|
2289
2295
|
};
|
2290
|
-
|
2291
|
-
var
|
2296
|
+
Sidebar.displayName = "Sidebar";
|
2297
|
+
var sidebar_default = Sidebar;
|
2292
2298
|
|
2293
|
-
// ../../node_modules/react-feather/dist/icons/
|
2299
|
+
// ../../node_modules/react-feather/dist/icons/trash.js
|
2294
2300
|
init_react_import();
|
2295
2301
|
var import_react16 = __toESM(require("react"));
|
2296
2302
|
var import_prop_types14 = __toESM(require_prop_types());
|
@@ -2340,7 +2346,7 @@ function _objectWithoutPropertiesLoose14(source, excluded) {
|
|
2340
2346
|
}
|
2341
2347
|
return target;
|
2342
2348
|
}
|
2343
|
-
var
|
2349
|
+
var Trash = (0, import_react16.forwardRef)(function(_ref, ref) {
|
2344
2350
|
var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, _ref$size = _ref.size, size = _ref$size === void 0 ? 24 : _ref$size, rest = _objectWithoutProperties14(_ref, ["color", "size"]);
|
2345
2351
|
return /* @__PURE__ */ import_react16.default.createElement("svg", _extends14({
|
2346
2352
|
ref,
|
@@ -2354,13 +2360,89 @@ var Type = (0, import_react16.forwardRef)(function(_ref, ref) {
|
|
2354
2360
|
strokeLinecap: "round",
|
2355
2361
|
strokeLinejoin: "round"
|
2356
2362
|
}, rest), /* @__PURE__ */ import_react16.default.createElement("polyline", {
|
2363
|
+
points: "3 6 5 6 21 6"
|
2364
|
+
}), /* @__PURE__ */ import_react16.default.createElement("path", {
|
2365
|
+
d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"
|
2366
|
+
}));
|
2367
|
+
});
|
2368
|
+
Trash.propTypes = {
|
2369
|
+
color: import_prop_types14.default.string,
|
2370
|
+
size: import_prop_types14.default.oneOfType([import_prop_types14.default.string, import_prop_types14.default.number])
|
2371
|
+
};
|
2372
|
+
Trash.displayName = "Trash";
|
2373
|
+
var trash_default = Trash;
|
2374
|
+
|
2375
|
+
// ../../node_modules/react-feather/dist/icons/type.js
|
2376
|
+
init_react_import();
|
2377
|
+
var import_react17 = __toESM(require("react"));
|
2378
|
+
var import_prop_types15 = __toESM(require_prop_types());
|
2379
|
+
function _extends15() {
|
2380
|
+
_extends15 = Object.assign || function(target) {
|
2381
|
+
for (var i = 1; i < arguments.length; i++) {
|
2382
|
+
var source = arguments[i];
|
2383
|
+
for (var key in source) {
|
2384
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
2385
|
+
target[key] = source[key];
|
2386
|
+
}
|
2387
|
+
}
|
2388
|
+
}
|
2389
|
+
return target;
|
2390
|
+
};
|
2391
|
+
return _extends15.apply(this, arguments);
|
2392
|
+
}
|
2393
|
+
function _objectWithoutProperties15(source, excluded) {
|
2394
|
+
if (source == null)
|
2395
|
+
return {};
|
2396
|
+
var target = _objectWithoutPropertiesLoose15(source, excluded);
|
2397
|
+
var key, i;
|
2398
|
+
if (Object.getOwnPropertySymbols) {
|
2399
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
2400
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
2401
|
+
key = sourceSymbolKeys[i];
|
2402
|
+
if (excluded.indexOf(key) >= 0)
|
2403
|
+
continue;
|
2404
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key))
|
2405
|
+
continue;
|
2406
|
+
target[key] = source[key];
|
2407
|
+
}
|
2408
|
+
}
|
2409
|
+
return target;
|
2410
|
+
}
|
2411
|
+
function _objectWithoutPropertiesLoose15(source, excluded) {
|
2412
|
+
if (source == null)
|
2413
|
+
return {};
|
2414
|
+
var target = {};
|
2415
|
+
var sourceKeys = Object.keys(source);
|
2416
|
+
var key, i;
|
2417
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
2418
|
+
key = sourceKeys[i];
|
2419
|
+
if (excluded.indexOf(key) >= 0)
|
2420
|
+
continue;
|
2421
|
+
target[key] = source[key];
|
2422
|
+
}
|
2423
|
+
return target;
|
2424
|
+
}
|
2425
|
+
var Type = (0, import_react17.forwardRef)(function(_ref, ref) {
|
2426
|
+
var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, _ref$size = _ref.size, size = _ref$size === void 0 ? 24 : _ref$size, rest = _objectWithoutProperties15(_ref, ["color", "size"]);
|
2427
|
+
return /* @__PURE__ */ import_react17.default.createElement("svg", _extends15({
|
2428
|
+
ref,
|
2429
|
+
xmlns: "http://www.w3.org/2000/svg",
|
2430
|
+
width: size,
|
2431
|
+
height: size,
|
2432
|
+
viewBox: "0 0 24 24",
|
2433
|
+
fill: "none",
|
2434
|
+
stroke: color,
|
2435
|
+
strokeWidth: "2",
|
2436
|
+
strokeLinecap: "round",
|
2437
|
+
strokeLinejoin: "round"
|
2438
|
+
}, rest), /* @__PURE__ */ import_react17.default.createElement("polyline", {
|
2357
2439
|
points: "4 7 4 4 20 4 20 7"
|
2358
|
-
}), /* @__PURE__ */
|
2440
|
+
}), /* @__PURE__ */ import_react17.default.createElement("line", {
|
2359
2441
|
x1: "9",
|
2360
2442
|
y1: "20",
|
2361
2443
|
x2: "15",
|
2362
2444
|
y2: "20"
|
2363
|
-
}), /* @__PURE__ */
|
2445
|
+
}), /* @__PURE__ */ import_react17.default.createElement("line", {
|
2364
2446
|
x1: "12",
|
2365
2447
|
y1: "4",
|
2366
2448
|
x2: "12",
|
@@ -2368,18 +2450,18 @@ var Type = (0, import_react16.forwardRef)(function(_ref, ref) {
|
|
2368
2450
|
}));
|
2369
2451
|
});
|
2370
2452
|
Type.propTypes = {
|
2371
|
-
color:
|
2372
|
-
size:
|
2453
|
+
color: import_prop_types15.default.string,
|
2454
|
+
size: import_prop_types15.default.oneOfType([import_prop_types15.default.string, import_prop_types15.default.number])
|
2373
2455
|
};
|
2374
2456
|
Type.displayName = "Type";
|
2375
2457
|
var type_default = Type;
|
2376
2458
|
|
2377
2459
|
// lib/use-modifier-held.ts
|
2378
2460
|
init_react_import();
|
2379
|
-
var
|
2461
|
+
var import_react18 = require("react");
|
2380
2462
|
var useModifierHeld = (modifier) => {
|
2381
|
-
const [modifierHeld, setModifierHeld] = (0,
|
2382
|
-
(0,
|
2463
|
+
const [modifierHeld, setModifierHeld] = (0, import_react18.useState)(false);
|
2464
|
+
(0, import_react18.useEffect)(() => {
|
2383
2465
|
function downHandler({ key }) {
|
2384
2466
|
if (key === modifier) {
|
2385
2467
|
setModifierHeld(true);
|
@@ -2423,7 +2505,7 @@ var DraggableComponent = ({
|
|
2423
2505
|
style
|
2424
2506
|
}) => {
|
2425
2507
|
const isModifierHeld = useModifierHeld("Alt");
|
2426
|
-
(0,
|
2508
|
+
(0, import_react19.useEffect)(onMount, []);
|
2427
2509
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
2428
2510
|
import_react_beautiful_dnd.Draggable,
|
2429
2511
|
{
|
@@ -2467,13 +2549,13 @@ var DraggableComponent = ({
|
|
2467
2549
|
|
2468
2550
|
// components/DroppableStrictMode/index.tsx
|
2469
2551
|
init_react_import();
|
2470
|
-
var
|
2552
|
+
var import_react20 = require("react");
|
2471
2553
|
var import_react_beautiful_dnd2 = require("react-beautiful-dnd");
|
2472
2554
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
2473
2555
|
var DroppableStrictMode = (_a) => {
|
2474
2556
|
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
2475
|
-
const [enabled, setEnabled] = (0,
|
2476
|
-
(0,
|
2557
|
+
const [enabled, setEnabled] = (0, import_react20.useState)(false);
|
2558
|
+
(0, import_react20.useEffect)(() => {
|
2477
2559
|
const animation = requestAnimationFrame(() => setEnabled(true));
|
2478
2560
|
return () => {
|
2479
2561
|
cancelAnimationFrame(animation);
|
@@ -2552,7 +2634,7 @@ var styles_module_default2 = { "DropZone": "_DropZone_ou0z5_1", "DropZone-conten
|
|
2552
2634
|
|
2553
2635
|
// components/DropZone/context.tsx
|
2554
2636
|
init_react_import();
|
2555
|
-
var
|
2637
|
+
var import_react21 = require("react");
|
2556
2638
|
var import_use_debounce = require("use-debounce");
|
2557
2639
|
|
2558
2640
|
// lib/get-zone-id.ts
|
@@ -2564,34 +2646,34 @@ var getZoneId = (zoneCompound) => {
|
|
2564
2646
|
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
2565
2647
|
return zoneCompound.split(":");
|
2566
2648
|
}
|
2567
|
-
return [
|
2649
|
+
return [rootDroppableId, zoneCompound];
|
2568
2650
|
};
|
2569
2651
|
|
2570
2652
|
// components/DropZone/context.tsx
|
2571
2653
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
2572
|
-
var dropZoneContext = (0,
|
2654
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
2573
2655
|
var DropZoneProvider = ({
|
2574
2656
|
children,
|
2575
2657
|
value
|
2576
2658
|
}) => {
|
2577
|
-
const [hoveringArea, setHoveringArea] = (0,
|
2578
|
-
const [hoveringZone, setHoveringZone] = (0,
|
2659
|
+
const [hoveringArea, setHoveringArea] = (0, import_react21.useState)(null);
|
2660
|
+
const [hoveringZone, setHoveringZone] = (0, import_react21.useState)(
|
2579
2661
|
rootDroppableId
|
2580
2662
|
);
|
2581
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
2663
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
2582
2664
|
const [hoveringAreaDb] = (0, import_use_debounce.useDebounce)(hoveringArea, 75, { leading: false });
|
2583
|
-
const [areasWithZones, setAreasWithZones] = (0,
|
2665
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
2584
2666
|
{}
|
2585
2667
|
);
|
2586
|
-
const [activeZones, setActiveZones] = (0,
|
2668
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
2587
2669
|
const { dispatch = null } = value ? value : {};
|
2588
|
-
const registerZoneArea = (0,
|
2670
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
2589
2671
|
(area) => {
|
2590
2672
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
2591
2673
|
},
|
2592
2674
|
[setAreasWithZones]
|
2593
2675
|
);
|
2594
|
-
const registerZone = (0,
|
2676
|
+
const registerZone = (0, import_react21.useCallback)(
|
2595
2677
|
(zoneCompound) => {
|
2596
2678
|
if (!dispatch) {
|
2597
2679
|
return;
|
@@ -2604,7 +2686,7 @@ var DropZoneProvider = ({
|
|
2604
2686
|
},
|
2605
2687
|
[setActiveZones, dispatch]
|
2606
2688
|
);
|
2607
|
-
const unregisterZone = (0,
|
2689
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
2608
2690
|
(zoneCompound) => {
|
2609
2691
|
if (!dispatch) {
|
2610
2692
|
return;
|
@@ -2619,8 +2701,8 @@ var DropZoneProvider = ({
|
|
2619
2701
|
},
|
2620
2702
|
[setActiveZones, dispatch]
|
2621
2703
|
);
|
2622
|
-
const [pathData, setPathData] = (0,
|
2623
|
-
const registerPath = (0,
|
2704
|
+
const [pathData, setPathData] = (0, import_react21.useState)();
|
2705
|
+
const registerPath = (0, import_react21.useCallback)(
|
2624
2706
|
(selector) => {
|
2625
2707
|
if (!(value == null ? void 0 : value.data)) {
|
2626
2708
|
return;
|
@@ -2631,15 +2713,15 @@ var DropZoneProvider = ({
|
|
2631
2713
|
}
|
2632
2714
|
const [area] = getZoneId(selector.zone);
|
2633
2715
|
setPathData((latestPathData = {}) => {
|
2634
|
-
const
|
2716
|
+
const parentPathData = latestPathData[area] || { path: [] };
|
2635
2717
|
return __spreadProps(__spreadValues({}, latestPathData), {
|
2636
|
-
[item.props.id]:
|
2637
|
-
|
2638
|
-
|
2639
|
-
selector
|
2640
|
-
|
2641
|
-
|
2642
|
-
|
2718
|
+
[item.props.id]: {
|
2719
|
+
path: [
|
2720
|
+
...parentPathData.path,
|
2721
|
+
...selector.zone ? [selector.zone] : []
|
2722
|
+
],
|
2723
|
+
label: item.type
|
2724
|
+
}
|
2643
2725
|
});
|
2644
2726
|
});
|
2645
2727
|
},
|
@@ -2673,7 +2755,7 @@ var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2673
2755
|
var getClassName3 = get_class_name_factory_default("DropZone", styles_module_default2);
|
2674
2756
|
function DropZoneEdit({ zone, style }) {
|
2675
2757
|
var _a;
|
2676
|
-
const ctx = (0,
|
2758
|
+
const ctx = (0, import_react22.useContext)(dropZoneContext);
|
2677
2759
|
const {
|
2678
2760
|
// These all need setting via context
|
2679
2761
|
data,
|
@@ -2690,12 +2772,12 @@ function DropZoneEdit({ zone, style }) {
|
|
2690
2772
|
} = ctx || {};
|
2691
2773
|
let content = data.content || [];
|
2692
2774
|
let zoneCompound = rootDroppableId;
|
2693
|
-
(0,
|
2775
|
+
(0, import_react22.useEffect)(() => {
|
2694
2776
|
if (areaId && registerZoneArea) {
|
2695
2777
|
registerZoneArea(areaId);
|
2696
2778
|
}
|
2697
2779
|
}, [areaId]);
|
2698
|
-
(0,
|
2780
|
+
(0, import_react22.useEffect)(() => {
|
2699
2781
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
2700
2782
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
2701
2783
|
}
|
@@ -2907,7 +2989,7 @@ function DropZoneEdit({ zone, style }) {
|
|
2907
2989
|
);
|
2908
2990
|
}
|
2909
2991
|
function DropZoneRender({ zone }) {
|
2910
|
-
const ctx = (0,
|
2992
|
+
const ctx = (0, import_react22.useContext)(dropZoneContext);
|
2911
2993
|
const { data, areaId = "root", config } = ctx || {};
|
2912
2994
|
let zoneCompound = rootDroppableId;
|
2913
2995
|
let content = (data == null ? void 0 : data.content) || [];
|
@@ -2934,7 +3016,7 @@ function DropZoneRender({ zone }) {
|
|
2934
3016
|
}) });
|
2935
3017
|
}
|
2936
3018
|
function DropZone(props) {
|
2937
|
-
const ctx = (0,
|
3019
|
+
const ctx = (0, import_react22.useContext)(dropZoneContext);
|
2938
3020
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
2939
3021
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DropZoneEdit, __spreadValues({}, props));
|
2940
3022
|
}
|
@@ -2946,7 +3028,7 @@ init_react_import();
|
|
2946
3028
|
|
2947
3029
|
// components/IconButton/IconButton.tsx
|
2948
3030
|
init_react_import();
|
2949
|
-
var
|
3031
|
+
var import_react23 = require("react");
|
2950
3032
|
|
2951
3033
|
// css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
|
2952
3034
|
init_react_import();
|
@@ -2968,7 +3050,7 @@ var IconButton = ({
|
|
2968
3050
|
fullWidth,
|
2969
3051
|
title
|
2970
3052
|
}) => {
|
2971
|
-
const [loading, setLoading] = (0,
|
3053
|
+
const [loading, setLoading] = (0, import_react23.useState)(false);
|
2972
3054
|
const ElementType = href ? "a" : "button";
|
2973
3055
|
const el = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
2974
3056
|
ElementType,
|
@@ -3008,38 +3090,378 @@ var IconButton = ({
|
|
3008
3090
|
|
3009
3091
|
// components/Puck/index.tsx
|
3010
3092
|
init_react_import();
|
3011
|
-
var
|
3012
|
-
var
|
3093
|
+
var import_react32 = require("react");
|
3094
|
+
var import_react_beautiful_dnd5 = require("react-beautiful-dnd");
|
3013
3095
|
|
3014
3096
|
// components/InputOrGroup/index.tsx
|
3015
3097
|
init_react_import();
|
3016
3098
|
|
3099
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/InputOrGroup/styles.module.css#css-module
|
3100
|
+
init_react_import();
|
3101
|
+
var styles_module_default3 = { "Input": "_Input_nkpu6_1", "Input-label": "_Input-label_nkpu6_27", "Input-labelIcon": "_Input-labelIcon_nkpu6_34", "Input-input": "_Input-input_nkpu6_39", "Input--readOnly": "_Input--readOnly_nkpu6_60", "Input-radioGroupItems": "_Input-radioGroupItems_nkpu6_69", "Input-radio": "_Input-radio_nkpu6_69", "Input-radioInner": "_Input-radioInner_nkpu6_86", "Input-radioInput": "_Input-radioInput_nkpu6_98" };
|
3102
|
+
|
3103
|
+
// components/InputOrGroup/fields/index.tsx
|
3104
|
+
init_react_import();
|
3105
|
+
|
3106
|
+
// components/InputOrGroup/fields/ArrayField/index.tsx
|
3107
|
+
init_react_import();
|
3108
|
+
|
3109
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/InputOrGroup/fields/ArrayField/styles.module.css#css-module
|
3110
|
+
init_react_import();
|
3111
|
+
var styles_module_default4 = { "ArrayField": "_ArrayField_zp334_5", "ArrayField--isDraggingFrom": "_ArrayField--isDraggingFrom_zp334_13", "ArrayField-addButton": "_ArrayField-addButton_zp334_17", "ArrayField--hasItems": "_ArrayField--hasItems_zp334_31", "ArrayFieldItem": "_ArrayFieldItem_zp334_45", "ArrayFieldItem--isDragging": "_ArrayFieldItem--isDragging_zp334_53", "ArrayFieldItem--isExpanded": "_ArrayFieldItem--isExpanded_zp334_58", "ArrayFieldItem-summary": "_ArrayFieldItem-summary_zp334_72", "ArrayFieldItem-body": "_ArrayFieldItem-body_zp334_104", "ArrayFieldItem-fieldset": "_ArrayFieldItem-fieldset_zp334_112", "ArrayFieldItem-rhs": "_ArrayFieldItem-rhs_zp334_119", "ArrayFieldItem-actions": "_ArrayFieldItem-actions_zp334_125", "ArrayFieldItem-action": "_ArrayFieldItem-action_zp334_125" };
|
3112
|
+
|
3113
|
+
// components/InputOrGroup/fields/ArrayField/index.tsx
|
3114
|
+
var import_react_beautiful_dnd4 = require("react-beautiful-dnd");
|
3115
|
+
|
3116
|
+
// components/Draggable/index.tsx
|
3117
|
+
init_react_import();
|
3118
|
+
var import_react_beautiful_dnd3 = require("react-beautiful-dnd");
|
3119
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
3120
|
+
var Draggable2 = ({
|
3121
|
+
className,
|
3122
|
+
children,
|
3123
|
+
id,
|
3124
|
+
index,
|
3125
|
+
showShadow,
|
3126
|
+
disableAnimations = false
|
3127
|
+
}) => {
|
3128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_beautiful_dnd3.Draggable, { draggableId: id, index, children: (provided, snapshot) => {
|
3129
|
+
var _a;
|
3130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
3131
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3132
|
+
"div",
|
3133
|
+
__spreadProps(__spreadValues(__spreadValues({
|
3134
|
+
className: className && className(provided, snapshot),
|
3135
|
+
ref: provided.innerRef
|
3136
|
+
}, provided.draggableProps), provided.dragHandleProps), {
|
3137
|
+
style: __spreadProps(__spreadValues({}, provided.draggableProps.style), {
|
3138
|
+
transform: snapshot.isDragging || !disableAnimations ? (_a = provided.draggableProps.style) == null ? void 0 : _a.transform : "translate(0px, 0px)"
|
3139
|
+
}),
|
3140
|
+
children: children(provided, snapshot)
|
3141
|
+
})
|
3142
|
+
),
|
3143
|
+
showShadow && snapshot.isDragging && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3144
|
+
"div",
|
3145
|
+
{
|
3146
|
+
className: className && className(provided, snapshot),
|
3147
|
+
style: { transform: "none !important" },
|
3148
|
+
children: children(provided, snapshot)
|
3149
|
+
}
|
3150
|
+
)
|
3151
|
+
] });
|
3152
|
+
} });
|
3153
|
+
};
|
3154
|
+
|
3155
|
+
// lib/generate-id.ts
|
3156
|
+
init_react_import();
|
3157
|
+
var import_crypto = require("crypto");
|
3158
|
+
var generateId = (type) => `${type}-${(0, import_crypto.randomBytes)(20).toString("hex")}`;
|
3159
|
+
|
3160
|
+
// components/InputOrGroup/fields/ArrayField/index.tsx
|
3161
|
+
var import_react25 = require("react");
|
3162
|
+
|
3163
|
+
// components/DragIcon/index.tsx
|
3164
|
+
init_react_import();
|
3165
|
+
|
3166
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/DragIcon/styles.module.css#css-module
|
3167
|
+
init_react_import();
|
3168
|
+
var styles_module_default5 = { "DragIcon": "_DragIcon_o29on_1" };
|
3169
|
+
|
3170
|
+
// components/DragIcon/index.tsx
|
3171
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
3172
|
+
var getClassName5 = get_class_name_factory_default("DragIcon", styles_module_default5);
|
3173
|
+
var DragIcon = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5(), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { viewBox: "0 0 20 20", width: "12", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }) }) });
|
3174
|
+
|
3175
|
+
// components/Puck/context.tsx
|
3176
|
+
init_react_import();
|
3177
|
+
var import_react24 = require("react");
|
3178
|
+
var defaultAppState = {
|
3179
|
+
data: { content: [], root: { title: "" } },
|
3180
|
+
ui: {
|
3181
|
+
leftSideBarVisible: true,
|
3182
|
+
arrayState: {},
|
3183
|
+
itemSelector: null
|
3184
|
+
}
|
3185
|
+
};
|
3186
|
+
var appContext = (0, import_react24.createContext)({
|
3187
|
+
state: defaultAppState,
|
3188
|
+
dispatch: () => null
|
3189
|
+
});
|
3190
|
+
var AppProvider = appContext.Provider;
|
3191
|
+
var useAppContext = () => {
|
3192
|
+
const mainContext = (0, import_react24.useContext)(appContext);
|
3193
|
+
const selectedItem = mainContext.state.ui.itemSelector ? getItem(mainContext.state.ui.itemSelector, mainContext.state.data) : void 0;
|
3194
|
+
return __spreadProps(__spreadValues({}, mainContext), {
|
3195
|
+
// Helpers
|
3196
|
+
selectedItem,
|
3197
|
+
setUi: (ui, recordHistory) => {
|
3198
|
+
return mainContext.dispatch({
|
3199
|
+
type: "setUi",
|
3200
|
+
ui,
|
3201
|
+
recordHistory
|
3202
|
+
});
|
3203
|
+
}
|
3204
|
+
});
|
3205
|
+
};
|
3206
|
+
|
3207
|
+
// components/InputOrGroup/fields/ArrayField/index.tsx
|
3208
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
3209
|
+
var getClassNameInput = get_class_name_factory_default("Input", styles_module_default3);
|
3210
|
+
var getClassName6 = get_class_name_factory_default("ArrayField", styles_module_default4);
|
3211
|
+
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default4);
|
3212
|
+
var ArrayField = ({
|
3213
|
+
field,
|
3214
|
+
onChange,
|
3215
|
+
value,
|
3216
|
+
name,
|
3217
|
+
label
|
3218
|
+
}) => {
|
3219
|
+
const [arrayFieldId] = (0, import_react25.useState)(generateId("ArrayField"));
|
3220
|
+
const { state, setUi } = useAppContext();
|
3221
|
+
const arrayState = state.ui.arrayState[arrayFieldId] || {
|
3222
|
+
items: Array.from(value).map((v) => ({
|
3223
|
+
_arrayId: generateId("ArrayItem"),
|
3224
|
+
data: v
|
3225
|
+
})),
|
3226
|
+
openId: ""
|
3227
|
+
};
|
3228
|
+
const setArrayState = (0, import_react25.useCallback)(
|
3229
|
+
(newArrayState, recordHistory = false) => {
|
3230
|
+
setUi(
|
3231
|
+
{
|
3232
|
+
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
3233
|
+
[arrayFieldId]: __spreadValues(__spreadValues({}, arrayState), newArrayState)
|
3234
|
+
})
|
3235
|
+
},
|
3236
|
+
recordHistory
|
3237
|
+
);
|
3238
|
+
},
|
3239
|
+
[arrayState]
|
3240
|
+
);
|
3241
|
+
(0, import_react25.useEffect)(() => {
|
3242
|
+
const newItems = Array.from(value).map((item, idx) => {
|
3243
|
+
var _a;
|
3244
|
+
return {
|
3245
|
+
_arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || generateId("ArrayItem"),
|
3246
|
+
data: item
|
3247
|
+
};
|
3248
|
+
});
|
3249
|
+
setArrayState({ items: newItems });
|
3250
|
+
}, [value]);
|
3251
|
+
if (!field.arrayFields) {
|
3252
|
+
return null;
|
3253
|
+
}
|
3254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassNameInput(), children: [
|
3255
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("b", { className: getClassNameInput("label"), children: [
|
3256
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameInput("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(list_default, { size: 16 }) }),
|
3257
|
+
label || name
|
3258
|
+
] }),
|
3259
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3260
|
+
import_react_beautiful_dnd4.DragDropContext,
|
3261
|
+
{
|
3262
|
+
onDragEnd: (event) => {
|
3263
|
+
var _a;
|
3264
|
+
if (event.destination) {
|
3265
|
+
const newValue = reorder(
|
3266
|
+
arrayState.items,
|
3267
|
+
event.source.index,
|
3268
|
+
(_a = event.destination) == null ? void 0 : _a.index
|
3269
|
+
);
|
3270
|
+
setArrayState(__spreadProps(__spreadValues({}, arrayState), { items: newValue }), false);
|
3271
|
+
onChange(newValue.map(({ data }) => data));
|
3272
|
+
}
|
3273
|
+
},
|
3274
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DroppableStrictMode_default, { droppableId: "array", children: (provided, snapshot) => {
|
3275
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
3276
|
+
"div",
|
3277
|
+
__spreadProps(__spreadValues({}, provided.droppableProps), {
|
3278
|
+
ref: provided.innerRef,
|
3279
|
+
className: getClassName6({
|
3280
|
+
isDraggingFrom: !!snapshot.draggingFromThisWith,
|
3281
|
+
hasItems: value.length > 0
|
3282
|
+
}),
|
3283
|
+
children: [
|
3284
|
+
Array.isArray(value) && value.length > 0 ? arrayState.items.map(({ _arrayId, data }, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3285
|
+
Draggable2,
|
3286
|
+
{
|
3287
|
+
id: _arrayId,
|
3288
|
+
index: i,
|
3289
|
+
className: (_, snapshot2) => getClassNameItem({
|
3290
|
+
isExpanded: arrayState.openId === _arrayId,
|
3291
|
+
isDragging: snapshot2.isDragging
|
3292
|
+
}),
|
3293
|
+
children: () => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
3294
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
3295
|
+
"div",
|
3296
|
+
{
|
3297
|
+
onClick: () => {
|
3298
|
+
if (arrayState.openId === _arrayId) {
|
3299
|
+
setArrayState({
|
3300
|
+
openId: ""
|
3301
|
+
});
|
3302
|
+
} else {
|
3303
|
+
setArrayState({
|
3304
|
+
openId: _arrayId
|
3305
|
+
});
|
3306
|
+
}
|
3307
|
+
},
|
3308
|
+
className: getClassNameItem("summary"),
|
3309
|
+
children: [
|
3310
|
+
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${i}`,
|
3311
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
3312
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("actions"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3313
|
+
IconButton,
|
3314
|
+
{
|
3315
|
+
onClick: () => {
|
3316
|
+
const existingValue = [
|
3317
|
+
...value || []
|
3318
|
+
];
|
3319
|
+
const existingItems = [
|
3320
|
+
...arrayState.items || []
|
3321
|
+
];
|
3322
|
+
existingValue.splice(i, 1);
|
3323
|
+
existingItems.splice(i, 1);
|
3324
|
+
setArrayState(
|
3325
|
+
{ items: existingItems },
|
3326
|
+
true
|
3327
|
+
);
|
3328
|
+
onChange(existingValue);
|
3329
|
+
},
|
3330
|
+
title: "Delete",
|
3331
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(trash_default, { size: 16 })
|
3332
|
+
}
|
3333
|
+
) }) }),
|
3334
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DragIcon, {}) })
|
3335
|
+
] })
|
3336
|
+
]
|
3337
|
+
}
|
3338
|
+
),
|
3339
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3340
|
+
"fieldset",
|
3341
|
+
{
|
3342
|
+
className: getClassNameItem("fieldset"),
|
3343
|
+
children: Object.keys(field.arrayFields).map(
|
3344
|
+
(fieldName) => {
|
3345
|
+
const subField = field.arrayFields[fieldName];
|
3346
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3347
|
+
InputOrGroup,
|
3348
|
+
{
|
3349
|
+
name: `${name}_${i}_${fieldName}`,
|
3350
|
+
label: subField.label || fieldName,
|
3351
|
+
field: subField,
|
3352
|
+
value: data[fieldName],
|
3353
|
+
onChange: (val) => onChange(
|
3354
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
3355
|
+
[fieldName]: val
|
3356
|
+
}))
|
3357
|
+
)
|
3358
|
+
},
|
3359
|
+
`${name}_${i}_${fieldName}`
|
3360
|
+
);
|
3361
|
+
}
|
3362
|
+
)
|
3363
|
+
}
|
3364
|
+
) })
|
3365
|
+
] })
|
3366
|
+
},
|
3367
|
+
_arrayId
|
3368
|
+
)) : null,
|
3369
|
+
provided.placeholder,
|
3370
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3371
|
+
"button",
|
3372
|
+
{
|
3373
|
+
className: getClassName6("addButton"),
|
3374
|
+
onClick: () => {
|
3375
|
+
const existingValue = value || [];
|
3376
|
+
onChange([...existingValue, field.defaultItemProps || {}]);
|
3377
|
+
},
|
3378
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(plus_default, { size: "21" })
|
3379
|
+
}
|
3380
|
+
)
|
3381
|
+
]
|
3382
|
+
})
|
3383
|
+
);
|
3384
|
+
} })
|
3385
|
+
}
|
3386
|
+
)
|
3387
|
+
] });
|
3388
|
+
};
|
3389
|
+
|
3390
|
+
// components/InputOrGroup/fields/DefaultField/index.tsx
|
3391
|
+
init_react_import();
|
3392
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
3393
|
+
var getClassName7 = get_class_name_factory_default("Input", styles_module_default3);
|
3394
|
+
var DefaultField = ({
|
3395
|
+
field,
|
3396
|
+
onChange,
|
3397
|
+
readOnly,
|
3398
|
+
value,
|
3399
|
+
name,
|
3400
|
+
label
|
3401
|
+
}) => {
|
3402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("label", { className: getClassName7({ readOnly }), children: [
|
3403
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: getClassName7("label"), children: [
|
3404
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: getClassName7("labelIcon"), children: [
|
3405
|
+
field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(type_default, { size: 16 }),
|
3406
|
+
field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(hash_default, { size: 16 })
|
3407
|
+
] }),
|
3408
|
+
label || name
|
3409
|
+
] }),
|
3410
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
3411
|
+
"input",
|
3412
|
+
{
|
3413
|
+
className: getClassName7("input"),
|
3414
|
+
autoComplete: "off",
|
3415
|
+
type: field.type,
|
3416
|
+
name,
|
3417
|
+
value: typeof value === "undefined" ? "" : value,
|
3418
|
+
onChange: (e) => {
|
3419
|
+
if (field.type === "number") {
|
3420
|
+
onChange(Number(e.currentTarget.value));
|
3421
|
+
} else {
|
3422
|
+
onChange(e.currentTarget.value);
|
3423
|
+
}
|
3424
|
+
},
|
3425
|
+
readOnly
|
3426
|
+
}
|
3427
|
+
)
|
3428
|
+
] });
|
3429
|
+
};
|
3430
|
+
|
3431
|
+
// components/InputOrGroup/fields/ExternalField/index.tsx
|
3432
|
+
init_react_import();
|
3433
|
+
|
3017
3434
|
// components/ExternalInput/index.tsx
|
3018
3435
|
init_react_import();
|
3019
|
-
var
|
3436
|
+
var import_react26 = require("react");
|
3020
3437
|
|
3021
3438
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
3022
3439
|
init_react_import();
|
3023
|
-
var
|
3440
|
+
var styles_module_default6 = { "ExternalInput": "_ExternalInput_l4bks_1", "ExternalInput-actions": "_ExternalInput-actions_l4bks_5", "ExternalInput-button": "_ExternalInput-button_l4bks_9", "ExternalInput-detachButton": "_ExternalInput-detachButton_l4bks_28", "ExternalInput--hasData": "_ExternalInput--hasData_l4bks_35", "ExternalInput-modal": "_ExternalInput-modal_l4bks_55", "ExternalInput--modalVisible": "_ExternalInput--modalVisible_l4bks_69", "ExternalInput-modalInner": "_ExternalInput-modalInner_l4bks_73", "ExternalInput-modalHeading": "_ExternalInput-modalHeading_l4bks_84", "ExternalInput-modalTableWrapper": "_ExternalInput-modalTableWrapper_l4bks_89" };
|
3024
3441
|
|
3025
3442
|
// components/ExternalInput/index.tsx
|
3026
|
-
var
|
3027
|
-
var
|
3443
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
3444
|
+
var getClassName8 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
3028
3445
|
var ExternalInput = ({
|
3029
3446
|
field,
|
3030
3447
|
onChange,
|
3031
3448
|
value = null
|
3032
3449
|
}) => {
|
3033
|
-
const [data, setData] = (0,
|
3034
|
-
const [isOpen, setOpen] = (0,
|
3035
|
-
const [selectedData, setSelectedData] = (0,
|
3036
|
-
const keys = (0,
|
3037
|
-
|
3038
|
-
|
3039
|
-
|
3040
|
-
|
3041
|
-
|
3042
|
-
|
3450
|
+
const [data, setData] = (0, import_react26.useState)([]);
|
3451
|
+
const [isOpen, setOpen] = (0, import_react26.useState)(false);
|
3452
|
+
const [selectedData, setSelectedData] = (0, import_react26.useState)(value);
|
3453
|
+
const keys = (0, import_react26.useMemo)(() => {
|
3454
|
+
const validKeys = /* @__PURE__ */ new Set();
|
3455
|
+
for (const item of data) {
|
3456
|
+
for (const key of Object.keys(item)) {
|
3457
|
+
if (typeof item[key] === "string" || typeof item[key] === "number") {
|
3458
|
+
validKeys.add(key);
|
3459
|
+
}
|
3460
|
+
}
|
3461
|
+
}
|
3462
|
+
return Array.from(validKeys);
|
3463
|
+
}, [data]);
|
3464
|
+
(0, import_react26.useEffect)(() => {
|
3043
3465
|
(() => __async(void 0, null, function* () {
|
3044
3466
|
if (field.adaptor) {
|
3045
3467
|
const listData = yield field.adaptor.fetchList(field.adaptorParams);
|
@@ -3050,35 +3472,35 @@ var ExternalInput = ({
|
|
3050
3472
|
}))();
|
3051
3473
|
}, [field.adaptor, field.adaptorParams]);
|
3052
3474
|
if (!field.adaptor) {
|
3053
|
-
return /* @__PURE__ */ (0,
|
3475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { children: "Incorrectly configured" });
|
3054
3476
|
}
|
3055
|
-
return /* @__PURE__ */ (0,
|
3477
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
3056
3478
|
"div",
|
3057
3479
|
{
|
3058
|
-
className:
|
3480
|
+
className: getClassName8({
|
3059
3481
|
hasData: !!selectedData,
|
3060
3482
|
modalVisible: isOpen
|
3061
3483
|
}),
|
3062
3484
|
children: [
|
3063
|
-
/* @__PURE__ */ (0,
|
3064
|
-
/* @__PURE__ */ (0,
|
3485
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName8("actions"), children: [
|
3486
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
3065
3487
|
"button",
|
3066
3488
|
{
|
3067
3489
|
onClick: () => setOpen(true),
|
3068
|
-
className:
|
3069
|
-
children: selectedData ? field.getItemSummary ? field.getItemSummary(selectedData) : `${field.adaptor.name} item` : /* @__PURE__ */ (0,
|
3070
|
-
/* @__PURE__ */ (0,
|
3071
|
-
/* @__PURE__ */ (0,
|
3490
|
+
className: getClassName8("button"),
|
3491
|
+
children: selectedData ? field.getItemSummary ? field.getItemSummary(selectedData) : `${field.adaptor.name} item` : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
3492
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(link_default, { size: "16" }),
|
3493
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { children: [
|
3072
3494
|
"Select from ",
|
3073
3495
|
field.adaptor.name
|
3074
3496
|
] })
|
3075
3497
|
] })
|
3076
3498
|
}
|
3077
3499
|
),
|
3078
|
-
selectedData && /* @__PURE__ */ (0,
|
3500
|
+
selectedData && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
3079
3501
|
"button",
|
3080
3502
|
{
|
3081
|
-
className:
|
3503
|
+
className: getClassName8("detachButton"),
|
3082
3504
|
onClick: () => {
|
3083
3505
|
setSelectedData(null);
|
3084
3506
|
onChange(null);
|
@@ -3087,17 +3509,17 @@ var ExternalInput = ({
|
|
3087
3509
|
}
|
3088
3510
|
)
|
3089
3511
|
] }),
|
3090
|
-
/* @__PURE__ */ (0,
|
3512
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName8("modal"), onClick: () => setOpen(false), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
3091
3513
|
"div",
|
3092
3514
|
{
|
3093
|
-
className:
|
3515
|
+
className: getClassName8("modalInner"),
|
3094
3516
|
onClick: (e) => e.stopPropagation(),
|
3095
3517
|
children: [
|
3096
|
-
/* @__PURE__ */ (0,
|
3097
|
-
data.length ? /* @__PURE__ */ (0,
|
3098
|
-
/* @__PURE__ */ (0,
|
3099
|
-
/* @__PURE__ */ (0,
|
3100
|
-
return /* @__PURE__ */ (0,
|
3518
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h2", { className: getClassName8("modalHeading"), children: "Select content" }),
|
3519
|
+
data.length ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName8("modalTableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("table", { children: [
|
3520
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tr", { children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("th", { style: { textAlign: "left" }, children: key }, key)) }) }),
|
3521
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tbody", { children: data.map((item, i) => {
|
3522
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
3101
3523
|
"tr",
|
3102
3524
|
{
|
3103
3525
|
style: { whiteSpace: "nowrap" },
|
@@ -3106,12 +3528,12 @@ var ExternalInput = ({
|
|
3106
3528
|
setOpen(false);
|
3107
3529
|
setSelectedData(item);
|
3108
3530
|
},
|
3109
|
-
children: keys.map((key) => /* @__PURE__ */ (0,
|
3531
|
+
children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("td", { children: item[key] }, key))
|
3110
3532
|
},
|
3111
3533
|
i
|
3112
3534
|
);
|
3113
3535
|
}) })
|
3114
|
-
] }) }) : /* @__PURE__ */ (0,
|
3536
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { padding: 24 }, children: "No content" })
|
3115
3537
|
]
|
3116
3538
|
}
|
3117
3539
|
) })
|
@@ -3120,204 +3542,189 @@ var ExternalInput = ({
|
|
3120
3542
|
);
|
3121
3543
|
};
|
3122
3544
|
|
3123
|
-
//
|
3545
|
+
// components/InputOrGroup/fields/ExternalField/index.tsx
|
3546
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
3547
|
+
var getClassName9 = get_class_name_factory_default("Input", styles_module_default3);
|
3548
|
+
var ExternalField = ({
|
3549
|
+
field,
|
3550
|
+
onChange,
|
3551
|
+
readOnly,
|
3552
|
+
value,
|
3553
|
+
name,
|
3554
|
+
label
|
3555
|
+
}) => {
|
3556
|
+
if (!field.adaptor) {
|
3557
|
+
return null;
|
3558
|
+
}
|
3559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName9(""), children: [
|
3560
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName9("label"), children: name === "_data" ? "External content" : label || name }),
|
3561
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ExternalInput, { field, onChange, value })
|
3562
|
+
] });
|
3563
|
+
};
|
3564
|
+
|
3565
|
+
// components/InputOrGroup/fields/RadioField/index.tsx
|
3566
|
+
init_react_import();
|
3567
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
3568
|
+
var getClassName10 = get_class_name_factory_default("Input", styles_module_default3);
|
3569
|
+
var RadioField = ({
|
3570
|
+
field,
|
3571
|
+
onChange,
|
3572
|
+
readOnly,
|
3573
|
+
value,
|
3574
|
+
name
|
3575
|
+
}) => {
|
3576
|
+
if (!field.options) {
|
3577
|
+
return null;
|
3578
|
+
}
|
3579
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassName10(), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassName10("radioGroup"), children: [
|
3580
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: getClassName10("label"), children: [
|
3581
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassName10("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(check_circle_default, { size: 16 }) }),
|
3582
|
+
field.label || name
|
3583
|
+
] }),
|
3584
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassName10("radioGroupItems"), children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
3585
|
+
"label",
|
3586
|
+
{
|
3587
|
+
className: getClassName10("radio"),
|
3588
|
+
children: [
|
3589
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
3590
|
+
"input",
|
3591
|
+
{
|
3592
|
+
type: "radio",
|
3593
|
+
className: getClassName10("radioInput"),
|
3594
|
+
value: option.value,
|
3595
|
+
name,
|
3596
|
+
onChange: (e) => {
|
3597
|
+
if (e.currentTarget.value === "true" || e.currentTarget.value === "false") {
|
3598
|
+
onChange(JSON.parse(e.currentTarget.value));
|
3599
|
+
return;
|
3600
|
+
}
|
3601
|
+
onChange(e.currentTarget.value);
|
3602
|
+
},
|
3603
|
+
readOnly,
|
3604
|
+
defaultChecked: value === option.value
|
3605
|
+
}
|
3606
|
+
),
|
3607
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassName10("radioInner"), children: option.label || option.value })
|
3608
|
+
]
|
3609
|
+
},
|
3610
|
+
option.label + option.value
|
3611
|
+
)) })
|
3612
|
+
] }) });
|
3613
|
+
};
|
3614
|
+
|
3615
|
+
// components/InputOrGroup/fields/SelectField/index.tsx
|
3124
3616
|
init_react_import();
|
3125
|
-
var
|
3617
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
3618
|
+
var getClassName11 = get_class_name_factory_default("Input", styles_module_default3);
|
3619
|
+
var SelectField = ({
|
3620
|
+
field,
|
3621
|
+
onChange,
|
3622
|
+
label,
|
3623
|
+
value,
|
3624
|
+
name
|
3625
|
+
}) => {
|
3626
|
+
if (!field.options) {
|
3627
|
+
return null;
|
3628
|
+
}
|
3629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: getClassName11(), children: [
|
3630
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassName11("label"), children: [
|
3631
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(chevron_down_default, { size: 16 }) }),
|
3632
|
+
label || name
|
3633
|
+
] }),
|
3634
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
3635
|
+
"select",
|
3636
|
+
{
|
3637
|
+
className: getClassName11("input"),
|
3638
|
+
onChange: (e) => {
|
3639
|
+
if (e.currentTarget.value === "true" || e.currentTarget.value === "false") {
|
3640
|
+
onChange(Boolean(e.currentTarget.value));
|
3641
|
+
return;
|
3642
|
+
}
|
3643
|
+
onChange(e.currentTarget.value);
|
3644
|
+
},
|
3645
|
+
value,
|
3646
|
+
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
3647
|
+
"option",
|
3648
|
+
{
|
3649
|
+
label: option.label,
|
3650
|
+
value: option.value
|
3651
|
+
},
|
3652
|
+
option.label + option.value
|
3653
|
+
))
|
3654
|
+
}
|
3655
|
+
)
|
3656
|
+
] });
|
3657
|
+
};
|
3658
|
+
|
3659
|
+
// components/InputOrGroup/fields/TextareaField/index.tsx
|
3660
|
+
init_react_import();
|
3661
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
3662
|
+
var getClassName12 = get_class_name_factory_default("Input", styles_module_default3);
|
3663
|
+
var TextareaField = ({
|
3664
|
+
onChange,
|
3665
|
+
readOnly,
|
3666
|
+
value,
|
3667
|
+
name,
|
3668
|
+
label
|
3669
|
+
}) => {
|
3670
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: getClassName12({ readOnly }), children: [
|
3671
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: getClassName12("label"), children: [
|
3672
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName12("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(type_default, { size: 16 }) }),
|
3673
|
+
label || name
|
3674
|
+
] }),
|
3675
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
3676
|
+
"textarea",
|
3677
|
+
{
|
3678
|
+
className: getClassName12("input"),
|
3679
|
+
autoComplete: "off",
|
3680
|
+
name,
|
3681
|
+
value: typeof value === "undefined" ? "" : value,
|
3682
|
+
onChange: (e) => onChange(e.currentTarget.value),
|
3683
|
+
readOnly,
|
3684
|
+
rows: 5
|
3685
|
+
}
|
3686
|
+
)
|
3687
|
+
] });
|
3688
|
+
};
|
3126
3689
|
|
3127
3690
|
// components/InputOrGroup/index.tsx
|
3128
|
-
var
|
3129
|
-
var
|
3691
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
3692
|
+
var getClassName13 = get_class_name_factory_default("Input", styles_module_default3);
|
3130
3693
|
var FieldLabel = ({
|
3131
3694
|
children,
|
3132
3695
|
icon,
|
3133
3696
|
label
|
3134
3697
|
}) => {
|
3135
|
-
return /* @__PURE__ */ (0,
|
3136
|
-
/* @__PURE__ */ (0,
|
3137
|
-
icon ? /* @__PURE__ */ (0,
|
3698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { children: [
|
3699
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: getClassName13("label"), children: [
|
3700
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: getClassName13("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, {}),
|
3138
3701
|
label
|
3139
3702
|
] }),
|
3140
3703
|
children
|
3141
3704
|
] });
|
3142
3705
|
};
|
3143
|
-
var InputOrGroup = ({
|
3144
|
-
name,
|
3145
|
-
field,
|
3146
|
-
value,
|
3147
|
-
label,
|
3148
|
-
onChange,
|
3149
|
-
readOnly
|
3150
|
-
}) => {
|
3706
|
+
var InputOrGroup = (props) => {
|
3707
|
+
const { name, field, value, onChange, readOnly } = props;
|
3151
3708
|
if (field.type === "array") {
|
3152
|
-
|
3153
|
-
return null;
|
3154
|
-
}
|
3155
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6(), children: [
|
3156
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("b", { className: getClassName6("label"), children: [
|
3157
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(list_default, { size: 16 }) }),
|
3158
|
-
label || name
|
3159
|
-
] }),
|
3160
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("array"), children: [
|
3161
|
-
Array.isArray(value) ? value.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
3162
|
-
"details",
|
3163
|
-
{
|
3164
|
-
className: getClassName6("arrayItem"),
|
3165
|
-
children: [
|
3166
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("summary", { children: [
|
3167
|
-
field.getItemSummary ? field.getItemSummary(item, i) : `Item #${i}`,
|
3168
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("arrayItemAction"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
3169
|
-
IconButton,
|
3170
|
-
{
|
3171
|
-
onClick: () => {
|
3172
|
-
const existingValue = value || [];
|
3173
|
-
existingValue.splice(i, 1);
|
3174
|
-
onChange(existingValue);
|
3175
|
-
},
|
3176
|
-
title: "Delete",
|
3177
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(trash_default, { size: 21 })
|
3178
|
-
}
|
3179
|
-
) })
|
3180
|
-
] }),
|
3181
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("fieldset", { className: getClassName6("fieldset"), children: Object.keys(field.arrayFields).map((fieldName) => {
|
3182
|
-
const subField = field.arrayFields[fieldName];
|
3183
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
3184
|
-
InputOrGroup,
|
3185
|
-
{
|
3186
|
-
name: `${name}_${i}_${fieldName}`,
|
3187
|
-
label: subField.label || fieldName,
|
3188
|
-
field: subField,
|
3189
|
-
value: item[fieldName],
|
3190
|
-
onChange: (val) => onChange(
|
3191
|
-
replace(value, i, __spreadProps(__spreadValues({}, item), { [fieldName]: val }))
|
3192
|
-
)
|
3193
|
-
},
|
3194
|
-
`${name}_${i}_${fieldName}`
|
3195
|
-
);
|
3196
|
-
}) })
|
3197
|
-
]
|
3198
|
-
},
|
3199
|
-
`${name}_${i}`
|
3200
|
-
)) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {}),
|
3201
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
3202
|
-
"button",
|
3203
|
-
{
|
3204
|
-
className: getClassName6("addButton"),
|
3205
|
-
onClick: () => {
|
3206
|
-
const existingValue = value || [];
|
3207
|
-
onChange([...existingValue, field.defaultItemProps || {}]);
|
3208
|
-
},
|
3209
|
-
children: "+ Add item"
|
3210
|
-
}
|
3211
|
-
)
|
3212
|
-
] })
|
3213
|
-
] });
|
3709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ArrayField, __spreadValues({}, props));
|
3214
3710
|
}
|
3215
3711
|
if (field.type === "external") {
|
3216
|
-
|
3217
|
-
return null;
|
3218
|
-
}
|
3219
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6(""), children: [
|
3220
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("label"), children: name === "_data" ? "External content" : label || name }),
|
3221
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ExternalInput, { field, onChange, value })
|
3222
|
-
] });
|
3712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ExternalField, __spreadValues({}, props));
|
3223
3713
|
}
|
3224
3714
|
if (field.type === "select") {
|
3225
|
-
|
3226
|
-
return null;
|
3227
|
-
}
|
3228
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: getClassName6(), children: [
|
3229
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("label"), children: [
|
3230
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(chevron_down_default, { size: 16 }) }),
|
3231
|
-
label || name
|
3232
|
-
] }),
|
3233
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
3234
|
-
"select",
|
3235
|
-
{
|
3236
|
-
className: getClassName6("input"),
|
3237
|
-
onChange: (e) => {
|
3238
|
-
if (e.currentTarget.value === "true" || e.currentTarget.value === "false") {
|
3239
|
-
onChange(Boolean(e.currentTarget.value));
|
3240
|
-
return;
|
3241
|
-
}
|
3242
|
-
onChange(e.currentTarget.value);
|
3243
|
-
},
|
3244
|
-
value,
|
3245
|
-
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
3246
|
-
"option",
|
3247
|
-
{
|
3248
|
-
label: option.label,
|
3249
|
-
value: option.value
|
3250
|
-
},
|
3251
|
-
option.label + option.value
|
3252
|
-
))
|
3253
|
-
}
|
3254
|
-
)
|
3255
|
-
] });
|
3715
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SelectField, __spreadValues({}, props));
|
3256
3716
|
}
|
3257
3717
|
if (field.type === "textarea") {
|
3258
|
-
return /* @__PURE__ */ (0,
|
3259
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("label"), children: [
|
3260
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(type_default, { size: 16 }) }),
|
3261
|
-
label || name
|
3262
|
-
] }),
|
3263
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
3264
|
-
"textarea",
|
3265
|
-
{
|
3266
|
-
className: getClassName6("input"),
|
3267
|
-
autoComplete: "off",
|
3268
|
-
name,
|
3269
|
-
value: typeof value === "undefined" ? "" : value,
|
3270
|
-
onChange: (e) => onChange(e.currentTarget.value),
|
3271
|
-
readOnly,
|
3272
|
-
rows: 5
|
3273
|
-
}
|
3274
|
-
)
|
3275
|
-
] });
|
3718
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TextareaField, __spreadValues({}, props));
|
3276
3719
|
}
|
3277
3720
|
if (field.type === "radio") {
|
3278
|
-
|
3279
|
-
return null;
|
3280
|
-
}
|
3281
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6(), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("radioGroup"), children: [
|
3282
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("label"), children: [
|
3283
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(check_circle_default, { size: 16 }) }),
|
3284
|
-
field.label || name
|
3285
|
-
] }),
|
3286
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("radioGroupItems"), children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
3287
|
-
"label",
|
3288
|
-
{
|
3289
|
-
className: getClassName6("radio"),
|
3290
|
-
children: [
|
3291
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
3292
|
-
"input",
|
3293
|
-
{
|
3294
|
-
type: "radio",
|
3295
|
-
className: getClassName6("radioInput"),
|
3296
|
-
value: option.value,
|
3297
|
-
name,
|
3298
|
-
onChange: (e) => {
|
3299
|
-
if (e.currentTarget.value === "true" || e.currentTarget.value === "false") {
|
3300
|
-
onChange(JSON.parse(e.currentTarget.value));
|
3301
|
-
return;
|
3302
|
-
}
|
3303
|
-
onChange(e.currentTarget.value);
|
3304
|
-
},
|
3305
|
-
readOnly,
|
3306
|
-
defaultChecked: value === option.value
|
3307
|
-
}
|
3308
|
-
),
|
3309
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("radioInner"), children: option.label || option.value })
|
3310
|
-
]
|
3311
|
-
},
|
3312
|
-
option.label + option.value
|
3313
|
-
)) })
|
3314
|
-
] }) });
|
3721
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(RadioField, __spreadValues({}, props));
|
3315
3722
|
}
|
3316
3723
|
if (field.type === "custom") {
|
3317
3724
|
if (!field.render) {
|
3318
3725
|
return null;
|
3319
3726
|
}
|
3320
|
-
return /* @__PURE__ */ (0,
|
3727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: getClassName13(), children: field.render({
|
3321
3728
|
field,
|
3322
3729
|
name,
|
3323
3730
|
value,
|
@@ -3325,96 +3732,46 @@ var InputOrGroup = ({
|
|
3325
3732
|
readOnly
|
3326
3733
|
}) });
|
3327
3734
|
}
|
3328
|
-
return /* @__PURE__ */ (0,
|
3329
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("label"), children: [
|
3330
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("labelIcon"), children: [
|
3331
|
-
field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(type_default, { size: 16 }),
|
3332
|
-
field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(hash_default, { size: 16 })
|
3333
|
-
] }),
|
3334
|
-
label || name
|
3335
|
-
] }),
|
3336
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
3337
|
-
"input",
|
3338
|
-
{
|
3339
|
-
className: getClassName6("input"),
|
3340
|
-
autoComplete: "off",
|
3341
|
-
type: field.type,
|
3342
|
-
name,
|
3343
|
-
value: typeof value === "undefined" ? "" : value,
|
3344
|
-
onChange: (e) => {
|
3345
|
-
if (field.type === "number") {
|
3346
|
-
onChange(Number(e.currentTarget.value));
|
3347
|
-
} else {
|
3348
|
-
onChange(e.currentTarget.value);
|
3349
|
-
}
|
3350
|
-
},
|
3351
|
-
readOnly
|
3352
|
-
}
|
3353
|
-
)
|
3354
|
-
] });
|
3735
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DefaultField, __spreadValues({}, props));
|
3355
3736
|
};
|
3356
3737
|
|
3357
3738
|
// components/ComponentList/index.tsx
|
3358
3739
|
init_react_import();
|
3359
|
-
var import_react_beautiful_dnd3 = require("react-beautiful-dnd");
|
3360
3740
|
|
3361
3741
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
3362
3742
|
init_react_import();
|
3363
|
-
var
|
3743
|
+
var styles_module_default7 = { "ComponentList": "_ComponentList_bvy0z_1", "ComponentList-item": "_ComponentList-item_bvy0z_6", "ComponentList-itemIcon": "_ComponentList-itemIcon_bvy0z_24", "ComponentList--isDraggingFrom": "_ComponentList--isDraggingFrom_bvy0z_28" };
|
3364
3744
|
|
3365
3745
|
// components/ComponentList/index.tsx
|
3366
|
-
var
|
3367
|
-
var
|
3746
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
3747
|
+
var getClassName14 = get_class_name_factory_default("ComponentList", styles_module_default7);
|
3368
3748
|
var ComponentList = ({ config }) => {
|
3369
|
-
return /* @__PURE__ */ (0,
|
3749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DroppableStrictMode_default, { droppableId: "component-list", isDropDisabled: true, children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
3370
3750
|
"div",
|
3371
3751
|
__spreadProps(__spreadValues({}, provided.droppableProps), {
|
3372
3752
|
ref: provided.innerRef,
|
3373
|
-
className:
|
3753
|
+
className: getClassName14({
|
3754
|
+
isDraggingFrom: !!snapshot.draggingFromThisWith
|
3755
|
+
}),
|
3374
3756
|
children: [
|
3375
3757
|
Object.keys(config.components).map((componentKey, i) => {
|
3376
|
-
|
3377
|
-
|
3378
|
-
import_react_beautiful_dnd3.Draggable,
|
3758
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
3759
|
+
Draggable2,
|
3379
3760
|
{
|
3380
|
-
|
3761
|
+
id: componentKey,
|
3381
3762
|
index: i,
|
3382
|
-
|
3383
|
-
|
3384
|
-
|
3385
|
-
|
3386
|
-
|
3387
|
-
|
3388
|
-
|
3389
|
-
}, provided2.draggableProps), provided2.dragHandleProps), {
|
3390
|
-
className: getClassName7("item"),
|
3391
|
-
style: __spreadProps(__spreadValues({}, provided2.draggableProps.style), {
|
3392
|
-
transform: snapshot2.isDragging ? (_a = provided2.draggableProps.style) == null ? void 0 : _a.transform : "translate(0px, 0px)"
|
3393
|
-
}),
|
3394
|
-
children: [
|
3395
|
-
componentKey,
|
3396
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName7("itemIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(grid_default, { size: 18 }) })
|
3397
|
-
]
|
3398
|
-
})
|
3399
|
-
),
|
3400
|
-
snapshot2.isDragging && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
3401
|
-
"div",
|
3402
|
-
{
|
3403
|
-
className: getClassName7("itemShadow"),
|
3404
|
-
style: { transform: "none !important" },
|
3405
|
-
children: [
|
3406
|
-
componentKey,
|
3407
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName7("itemIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(grid_default, { size: 18 }) })
|
3408
|
-
]
|
3409
|
-
}
|
3410
|
-
)
|
3411
|
-
] });
|
3412
|
-
}
|
3763
|
+
showShadow: true,
|
3764
|
+
disableAnimations: true,
|
3765
|
+
className: () => getClassName14("item"),
|
3766
|
+
children: () => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
3767
|
+
componentKey,
|
3768
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: getClassName14("itemIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DragIcon, {}) })
|
3769
|
+
] })
|
3413
3770
|
},
|
3414
3771
|
componentKey
|
3415
3772
|
);
|
3416
3773
|
}),
|
3417
|
-
/* @__PURE__ */ (0,
|
3774
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: { display: "none" }, children: provided.placeholder })
|
3418
3775
|
]
|
3419
3776
|
})
|
3420
3777
|
) });
|
@@ -3422,10 +3779,10 @@ var ComponentList = ({ config }) => {
|
|
3422
3779
|
|
3423
3780
|
// lib/use-placeholder-style.ts
|
3424
3781
|
init_react_import();
|
3425
|
-
var
|
3782
|
+
var import_react27 = require("react");
|
3426
3783
|
var usePlaceholderStyle = () => {
|
3427
3784
|
const queryAttr = "data-rbd-drag-handle-draggable-id";
|
3428
|
-
const [placeholderStyle, setPlaceholderStyle] = (0,
|
3785
|
+
const [placeholderStyle, setPlaceholderStyle] = (0, import_react27.useState)();
|
3429
3786
|
const onDragStartOrUpdate = (draggedItem) => {
|
3430
3787
|
var _a;
|
3431
3788
|
const draggableId = draggedItem.draggableId;
|
@@ -3473,24 +3830,24 @@ init_react_import();
|
|
3473
3830
|
|
3474
3831
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
3475
3832
|
init_react_import();
|
3476
|
-
var
|
3833
|
+
var styles_module_default8 = { "SidebarSection": "_SidebarSection_f1p35_1", "SidebarSection-title": "_SidebarSection-title_f1p35_12", "SidebarSection-content": "_SidebarSection-content_f1p35_19", "SidebarSection--noPadding": "_SidebarSection--noPadding_f1p35_24", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_f1p35_33", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_f1p35_44", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_f1p35_33", "SidebarSection-heading": "_SidebarSection-heading_f1p35_56" };
|
3477
3834
|
|
3478
3835
|
// components/Heading/index.tsx
|
3479
3836
|
init_react_import();
|
3480
3837
|
|
3481
3838
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Heading/styles.module.css#css-module
|
3482
3839
|
init_react_import();
|
3483
|
-
var
|
3840
|
+
var styles_module_default9 = { "Heading": "_Heading_1bvy5_1", "Heading--xxxxl": "_Heading--xxxxl_1bvy5_13", "Heading--xxxl": "_Heading--xxxl_1bvy5_19", "Heading--xxl": "_Heading--xxl_1bvy5_23", "Heading--xl": "_Heading--xl_1bvy5_27", "Heading--l": "_Heading--l_1bvy5_31", "Heading--m": "_Heading--m_1bvy5_35", "Heading--s": "_Heading--s_1bvy5_39", "Heading--xs": "_Heading--xs_1bvy5_43" };
|
3484
3841
|
|
3485
3842
|
// components/Heading/index.tsx
|
3486
|
-
var
|
3487
|
-
var
|
3843
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
3844
|
+
var getClassName15 = get_class_name_factory_default("Heading", styles_module_default9);
|
3488
3845
|
var Heading = ({ children, rank, size = "m" }) => {
|
3489
3846
|
const Tag = rank ? `h${rank}` : "span";
|
3490
|
-
return /* @__PURE__ */ (0,
|
3847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
3491
3848
|
Tag,
|
3492
3849
|
{
|
3493
|
-
className:
|
3850
|
+
className: getClassName15({
|
3494
3851
|
[size]: true
|
3495
3852
|
}),
|
3496
3853
|
children
|
@@ -3498,33 +3855,100 @@ var Heading = ({ children, rank, size = "m" }) => {
|
|
3498
3855
|
);
|
3499
3856
|
};
|
3500
3857
|
|
3858
|
+
// lib/use-breadcrumbs.ts
|
3859
|
+
init_react_import();
|
3860
|
+
var import_react28 = require("react");
|
3861
|
+
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
3862
|
+
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
3863
|
+
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
3864
|
+
if (!id) {
|
3865
|
+
return [];
|
3866
|
+
}
|
3867
|
+
return currentPathData == null ? void 0 : currentPathData.path.reduce((acc, zoneCompound) => {
|
3868
|
+
const [area] = getZoneId(zoneCompound);
|
3869
|
+
if (area === rootDroppableId) {
|
3870
|
+
return [
|
3871
|
+
{
|
3872
|
+
label: "Page",
|
3873
|
+
selector: null
|
3874
|
+
}
|
3875
|
+
];
|
3876
|
+
}
|
3877
|
+
const parentZoneCompound = acc.length > 0 ? acc[acc.length - 1].zoneCompound : rootDroppableId;
|
3878
|
+
let parentZone = data.content;
|
3879
|
+
if (parentZoneCompound && parentZoneCompound !== rootDroppableId) {
|
3880
|
+
parentZone = data.zones[parentZoneCompound];
|
3881
|
+
}
|
3882
|
+
if (!parentZone) {
|
3883
|
+
return acc;
|
3884
|
+
}
|
3885
|
+
const itemIndex = parentZone.findIndex(
|
3886
|
+
(queryItem) => queryItem.props.id === area
|
3887
|
+
);
|
3888
|
+
const item = parentZone[itemIndex];
|
3889
|
+
if (!item) {
|
3890
|
+
return acc;
|
3891
|
+
}
|
3892
|
+
return [
|
3893
|
+
...acc,
|
3894
|
+
{
|
3895
|
+
label: item.type.toString(),
|
3896
|
+
selector: {
|
3897
|
+
index: itemIndex,
|
3898
|
+
zone: parentZoneCompound
|
3899
|
+
},
|
3900
|
+
zoneCompound
|
3901
|
+
}
|
3902
|
+
];
|
3903
|
+
}, []);
|
3904
|
+
};
|
3905
|
+
var useBreadcrumbs = (renderCount) => {
|
3906
|
+
const {
|
3907
|
+
state: { data },
|
3908
|
+
selectedItem
|
3909
|
+
} = useAppContext();
|
3910
|
+
const dzContext = (0, import_react28.useContext)(dropZoneContext);
|
3911
|
+
return (0, import_react28.useMemo)(() => {
|
3912
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(
|
3913
|
+
selectedItem,
|
3914
|
+
dzContext == null ? void 0 : dzContext.pathData,
|
3915
|
+
data
|
3916
|
+
);
|
3917
|
+
if (renderCount) {
|
3918
|
+
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
3919
|
+
}
|
3920
|
+
return breadcrumbs;
|
3921
|
+
}, [selectedItem, dzContext == null ? void 0 : dzContext.pathData, renderCount]);
|
3922
|
+
};
|
3923
|
+
|
3501
3924
|
// components/SidebarSection/index.tsx
|
3502
|
-
var
|
3503
|
-
var
|
3925
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
3926
|
+
var getClassName16 = get_class_name_factory_default("SidebarSection", styles_module_default8);
|
3504
3927
|
var SidebarSection = ({
|
3505
3928
|
children,
|
3506
3929
|
title,
|
3507
3930
|
background,
|
3508
|
-
|
3509
|
-
breadcrumbClick,
|
3931
|
+
showBreadcrumbs,
|
3510
3932
|
noPadding
|
3511
3933
|
}) => {
|
3512
|
-
|
3513
|
-
|
3514
|
-
|
3515
|
-
|
3934
|
+
const { setUi } = useAppContext();
|
3935
|
+
const breadcrumbs = useBreadcrumbs(1);
|
3936
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName16({ noPadding }), style: { background }, children: [
|
3937
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName16("title"), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName16("breadcrumbs"), children: [
|
3938
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName16("breadcrumb"), children: [
|
3939
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
3516
3940
|
"div",
|
3517
3941
|
{
|
3518
|
-
className:
|
3519
|
-
onClick: () =>
|
3942
|
+
className: getClassName16("breadcrumbLabel"),
|
3943
|
+
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
3520
3944
|
children: breadcrumb.label
|
3521
3945
|
}
|
3522
3946
|
),
|
3523
|
-
/* @__PURE__ */ (0,
|
3524
|
-
] }, i)),
|
3525
|
-
/* @__PURE__ */ (0,
|
3947
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(chevron_right_default, { size: 16 })
|
3948
|
+
] }, i)) : null,
|
3949
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName16("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Heading, { rank: 2, size: "xs", children: title }) })
|
3526
3950
|
] }) }),
|
3527
|
-
/* @__PURE__ */ (0,
|
3951
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName16("content"), children })
|
3528
3952
|
] });
|
3529
3953
|
};
|
3530
3954
|
|
@@ -3533,15 +3957,15 @@ init_react_import();
|
|
3533
3957
|
|
3534
3958
|
// lib/use-puck-history.ts
|
3535
3959
|
init_react_import();
|
3536
|
-
var
|
3960
|
+
var import_react30 = require("react");
|
3537
3961
|
|
3538
3962
|
// lib/use-action-history.ts
|
3539
3963
|
init_react_import();
|
3540
|
-
var
|
3964
|
+
var import_react29 = require("react");
|
3541
3965
|
var EMPTY_HISTORY_INDEX = -1;
|
3542
3966
|
function useActionHistory() {
|
3543
|
-
const [histories, setHistories] = (0,
|
3544
|
-
const [currentHistoryIndex, setCurrentHistoryIndex] = (0,
|
3967
|
+
const [histories, setHistories] = (0, import_react29.useState)([]);
|
3968
|
+
const [currentHistoryIndex, setCurrentHistoryIndex] = (0, import_react29.useState)(EMPTY_HISTORY_INDEX);
|
3545
3969
|
const currentHistory = histories[currentHistoryIndex];
|
3546
3970
|
const canRewind = currentHistoryIndex > EMPTY_HISTORY_INDEX;
|
3547
3971
|
const canForward = currentHistoryIndex < histories.length - 1;
|
@@ -3585,35 +4009,42 @@ var import_use_debounce2 = require("use-debounce");
|
|
3585
4009
|
var DEBOUNCE_TIME = 250;
|
3586
4010
|
var RECORD_DIFF = "RECORD_DIFF";
|
3587
4011
|
var historyEmitter = (0, import_event_emitter.default)();
|
3588
|
-
var recordDiff = (
|
3589
|
-
var _recordHistory = ({
|
4012
|
+
var recordDiff = (newAppState) => historyEmitter.emit(RECORD_DIFF, newAppState);
|
4013
|
+
var _recordHistory = ({
|
4014
|
+
snapshot,
|
4015
|
+
newSnapshot,
|
4016
|
+
record,
|
4017
|
+
dispatch
|
4018
|
+
}) => {
|
4019
|
+
if (JSON.stringify(snapshot) === JSON.stringify(newSnapshot))
|
4020
|
+
return;
|
3590
4021
|
record({
|
3591
4022
|
forward: () => {
|
3592
|
-
dispatch({ type: "set",
|
4023
|
+
dispatch({ type: "set", state: newSnapshot });
|
3593
4024
|
},
|
3594
4025
|
rewind: () => {
|
3595
|
-
dispatch({ type: "set",
|
4026
|
+
dispatch({ type: "set", state: snapshot });
|
3596
4027
|
}
|
3597
4028
|
});
|
3598
4029
|
};
|
3599
4030
|
function usePuckHistory({
|
3600
|
-
|
4031
|
+
appState,
|
3601
4032
|
dispatch
|
3602
4033
|
}) {
|
3603
4034
|
const { canForward, canRewind, rewind, forward, record } = useActionHistory();
|
3604
4035
|
(0, import_react_hotkeys_hook.useHotkeys)("meta+z", rewind, { preventDefault: true });
|
3605
4036
|
(0, import_react_hotkeys_hook.useHotkeys)("meta+shift+z", forward, { preventDefault: true });
|
3606
4037
|
(0, import_react_hotkeys_hook.useHotkeys)("meta+y", forward, { preventDefault: true });
|
3607
|
-
const [snapshot] = (0, import_use_debounce2.useDebounce)(
|
3608
|
-
const handleRecordDiff = (0, import_use_debounce2.useDebouncedCallback)((
|
4038
|
+
const [snapshot] = (0, import_use_debounce2.useDebounce)(appState, DEBOUNCE_TIME);
|
4039
|
+
const handleRecordDiff = (0, import_use_debounce2.useDebouncedCallback)((newAppState) => {
|
3609
4040
|
return _recordHistory({
|
3610
4041
|
snapshot,
|
3611
|
-
newSnapshot:
|
4042
|
+
newSnapshot: newAppState,
|
3612
4043
|
record,
|
3613
4044
|
dispatch
|
3614
4045
|
});
|
3615
4046
|
}, DEBOUNCE_TIME);
|
3616
|
-
(0,
|
4047
|
+
(0, import_react30.useEffect)(() => {
|
3617
4048
|
historyEmitter.on(RECORD_DIFF, handleRecordDiff);
|
3618
4049
|
return () => {
|
3619
4050
|
historyEmitter.off(RECORD_DIFF, handleRecordDiff);
|
@@ -3648,13 +4079,6 @@ var remove = (list, index) => {
|
|
3648
4079
|
|
3649
4080
|
// lib/reduce-related-zones.ts
|
3650
4081
|
init_react_import();
|
3651
|
-
|
3652
|
-
// lib/generate-id.ts
|
3653
|
-
init_react_import();
|
3654
|
-
var import_crypto = require("crypto");
|
3655
|
-
var generateId = (type) => `${type}-${(0, import_crypto.randomBytes)(20).toString("hex")}`;
|
3656
|
-
|
3657
|
-
// lib/reduce-related-zones.ts
|
3658
4082
|
var reduceRelatedZones = (item, data, fn) => {
|
3659
4083
|
return __spreadProps(__spreadValues({}, data), {
|
3660
4084
|
zones: Object.keys(data.zones || {}).reduce(
|
@@ -3910,11 +4334,11 @@ var reduceData = (data, action, config) => {
|
|
3910
4334
|
|
3911
4335
|
// reducer/state.ts
|
3912
4336
|
init_react_import();
|
3913
|
-
var reduceState = (
|
3914
|
-
if (action.type === "
|
3915
|
-
return __spreadValues(__spreadValues({},
|
4337
|
+
var reduceState = (ui, action) => {
|
4338
|
+
if (action.type === "setUi") {
|
4339
|
+
return __spreadValues(__spreadValues({}, ui), action.ui);
|
3916
4340
|
}
|
3917
|
-
return
|
4341
|
+
return ui;
|
3918
4342
|
};
|
3919
4343
|
|
3920
4344
|
// reducer/actions.tsx
|
@@ -3922,8 +4346,8 @@ init_react_import();
|
|
3922
4346
|
|
3923
4347
|
// reducer/index.ts
|
3924
4348
|
var storeInterceptor = (reducer) => {
|
3925
|
-
return (
|
3926
|
-
const
|
4349
|
+
return (state, action) => {
|
4350
|
+
const newAppState = reducer(state, action);
|
3927
4351
|
const isValidType = ![
|
3928
4352
|
"registerZone",
|
3929
4353
|
"unregisterZone",
|
@@ -3932,18 +4356,18 @@ var storeInterceptor = (reducer) => {
|
|
3932
4356
|
"set"
|
3933
4357
|
].includes(action.type);
|
3934
4358
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
3935
|
-
recordDiff(
|
4359
|
+
recordDiff(newAppState);
|
3936
4360
|
}
|
3937
|
-
return
|
4361
|
+
return newAppState;
|
3938
4362
|
};
|
3939
4363
|
};
|
3940
|
-
var createReducer = ({ config }) => storeInterceptor((
|
3941
|
-
const data = reduceData(
|
3942
|
-
const
|
4364
|
+
var createReducer = ({ config }) => storeInterceptor((state, action) => {
|
4365
|
+
const data = reduceData(state.data, action, config);
|
4366
|
+
const ui = reduceState(state.ui, action);
|
3943
4367
|
if (action.type === "set") {
|
3944
|
-
return __spreadValues(__spreadValues({},
|
4368
|
+
return __spreadValues(__spreadValues({}, state), action.state);
|
3945
4369
|
}
|
3946
|
-
return { data,
|
4370
|
+
return { data, ui };
|
3947
4371
|
});
|
3948
4372
|
|
3949
4373
|
// components/LayerTree/index.tsx
|
@@ -3951,7 +4375,7 @@ init_react_import();
|
|
3951
4375
|
|
3952
4376
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
3953
4377
|
init_react_import();
|
3954
|
-
var
|
4378
|
+
var styles_module_default10 = { "LayerTree": "_LayerTree_1dcmd_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_1dcmd_11", "LayerTree-helper": "_LayerTree-helper_1dcmd_17", "Layer": "_Layer_1dcmd_1", "Layer-inner": "_Layer-inner_1dcmd_29", "Layer--containsZone": "_Layer--containsZone_1dcmd_35", "Layer-clickable": "_Layer-clickable_1dcmd_39", "Layer--isSelected": "_Layer--isSelected_1dcmd_48", "Layer--isHovering": "_Layer--isHovering_1dcmd_49", "Layer-chevron": "_Layer-chevron_1dcmd_65", "Layer--childIsSelected": "_Layer--childIsSelected_1dcmd_66", "Layer-zones": "_Layer-zones_1dcmd_70", "Layer-title": "_Layer-title_1dcmd_84", "Layer-icon": "_Layer-icon_1dcmd_92", "Layer-zoneIcon": "_Layer-zoneIcon_1dcmd_97" };
|
3955
4379
|
|
3956
4380
|
// lib/scroll-into-view.ts
|
3957
4381
|
init_react_import();
|
@@ -3965,7 +4389,7 @@ var scrollIntoView = (el) => {
|
|
3965
4389
|
};
|
3966
4390
|
|
3967
4391
|
// components/LayerTree/index.tsx
|
3968
|
-
var
|
4392
|
+
var import_react31 = require("react");
|
3969
4393
|
|
3970
4394
|
// lib/find-zones-for-area.ts
|
3971
4395
|
init_react_import();
|
@@ -3984,19 +4408,16 @@ init_react_import();
|
|
3984
4408
|
var isChildOfZone = (item, maybeChild, ctx) => {
|
3985
4409
|
var _a;
|
3986
4410
|
const { data, pathData = {} } = ctx || {};
|
3987
|
-
return maybeChild && data ? !!((_a = pathData[maybeChild.props.id]) == null ? void 0 : _a.find((
|
3988
|
-
|
3989
|
-
|
3990
|
-
return (pathItem == null ? void 0 : pathItem.props.id) === item.props.id;
|
3991
|
-
}
|
3992
|
-
return false;
|
4411
|
+
return maybeChild && data ? !!((_a = pathData[maybeChild.props.id]) == null ? void 0 : _a.path.find((zoneCompound) => {
|
4412
|
+
const [area] = getZoneId(zoneCompound);
|
4413
|
+
return area === item.props.id;
|
3993
4414
|
})) : false;
|
3994
4415
|
};
|
3995
4416
|
|
3996
4417
|
// components/LayerTree/index.tsx
|
3997
|
-
var
|
3998
|
-
var
|
3999
|
-
var getClassNameLayer = get_class_name_factory_default("Layer",
|
4418
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
4419
|
+
var getClassName17 = get_class_name_factory_default("LayerTree", styles_module_default10);
|
4420
|
+
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default10);
|
4000
4421
|
var LayerTree = ({
|
4001
4422
|
data,
|
4002
4423
|
zoneContent,
|
@@ -4006,15 +4427,15 @@ var LayerTree = ({
|
|
4006
4427
|
label
|
4007
4428
|
}) => {
|
4008
4429
|
const zones = data.zones || {};
|
4009
|
-
const ctx = (0,
|
4010
|
-
return /* @__PURE__ */ (0,
|
4011
|
-
label && /* @__PURE__ */ (0,
|
4012
|
-
/* @__PURE__ */ (0,
|
4430
|
+
const ctx = (0, import_react31.useContext)(dropZoneContext);
|
4431
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
4432
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: getClassName17("zoneTitle"), children: [
|
4433
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName17("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(layers_default, { size: "16" }) }),
|
4013
4434
|
" ",
|
4014
4435
|
label
|
4015
4436
|
] }),
|
4016
|
-
/* @__PURE__ */ (0,
|
4017
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
4437
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("ul", { className: getClassName17(), children: [
|
4438
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName17("helper"), children: "No items" }),
|
4018
4439
|
zoneContent.map((item, i) => {
|
4019
4440
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
4020
4441
|
const zonesForItem = findZonesForArea(data, item.props.id);
|
@@ -4029,7 +4450,7 @@ var LayerTree = ({
|
|
4029
4450
|
const selectedItem = itemSelector && data ? getItem(itemSelector, data) : null;
|
4030
4451
|
const isHovering = hoveringComponent === item.props.id;
|
4031
4452
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
4032
|
-
return /* @__PURE__ */ (0,
|
4453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
4033
4454
|
"li",
|
4034
4455
|
{
|
4035
4456
|
className: getClassNameLayer({
|
@@ -4039,7 +4460,7 @@ var LayerTree = ({
|
|
4039
4460
|
childIsSelected
|
4040
4461
|
}),
|
4041
4462
|
children: [
|
4042
|
-
/* @__PURE__ */ (0,
|
4463
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
4043
4464
|
"div",
|
4044
4465
|
{
|
4045
4466
|
className: getClassNameLayer("clickable"),
|
@@ -4070,22 +4491,22 @@ var LayerTree = ({
|
|
4070
4491
|
setHoveringComponent(null);
|
4071
4492
|
},
|
4072
4493
|
children: [
|
4073
|
-
containsZone && /* @__PURE__ */ (0,
|
4494
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
4074
4495
|
"div",
|
4075
4496
|
{
|
4076
4497
|
className: getClassNameLayer("chevron"),
|
4077
4498
|
title: isSelected ? "Collapse" : "Expand",
|
4078
|
-
children: /* @__PURE__ */ (0,
|
4499
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(chevron_down_default, { size: "12" })
|
4079
4500
|
}
|
4080
4501
|
),
|
4081
|
-
/* @__PURE__ */ (0,
|
4082
|
-
/* @__PURE__ */ (0,
|
4502
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
4503
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(type_default, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(grid_default, { size: "16" }) }),
|
4083
4504
|
item.type
|
4084
4505
|
] })
|
4085
4506
|
]
|
4086
4507
|
}
|
4087
4508
|
) }),
|
4088
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
4509
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
4089
4510
|
LayerTree,
|
4090
4511
|
{
|
4091
4512
|
data,
|
@@ -4114,23 +4535,23 @@ var areaContainsZones = (data, area) => {
|
|
4114
4535
|
|
4115
4536
|
// lib/flush-zones.ts
|
4116
4537
|
init_react_import();
|
4117
|
-
var flushZones = (
|
4118
|
-
const containsZones = typeof
|
4538
|
+
var flushZones = (appState) => {
|
4539
|
+
const containsZones = typeof appState.data.zones !== "undefined";
|
4119
4540
|
if (containsZones) {
|
4120
|
-
Object.keys(
|
4121
|
-
addToZoneCache(zone,
|
4541
|
+
Object.keys(appState.data.zones || {}).forEach((zone) => {
|
4542
|
+
addToZoneCache(zone, appState.data.zones[zone]);
|
4122
4543
|
});
|
4123
|
-
return __spreadProps(__spreadValues({},
|
4124
|
-
data: __spreadProps(__spreadValues({},
|
4544
|
+
return __spreadProps(__spreadValues({}, appState), {
|
4545
|
+
data: __spreadProps(__spreadValues({}, appState.data), {
|
4125
4546
|
zones: {}
|
4126
4547
|
})
|
4127
4548
|
});
|
4128
4549
|
}
|
4129
|
-
return
|
4550
|
+
return appState;
|
4130
4551
|
};
|
4131
4552
|
|
4132
4553
|
// components/Puck/index.tsx
|
4133
|
-
var
|
4554
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
4134
4555
|
var defaultPageFields = {
|
4135
4556
|
title: { type: "text" }
|
4136
4557
|
};
|
@@ -4141,7 +4562,7 @@ var PluginRenderer = ({
|
|
4141
4562
|
renderMethod
|
4142
4563
|
}) => {
|
4143
4564
|
return plugins.filter((item) => item[renderMethod]).map((item) => item[renderMethod]).reduce(
|
4144
|
-
(accChildren, Item) => /* @__PURE__ */ (0,
|
4565
|
+
(accChildren, Item) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Item, { data, children: accChildren }),
|
4145
4566
|
children
|
4146
4567
|
);
|
4147
4568
|
};
|
@@ -4157,35 +4578,34 @@ function Puck({
|
|
4157
4578
|
headerPath
|
4158
4579
|
}) {
|
4159
4580
|
var _a, _b;
|
4160
|
-
const [reducer] = (0,
|
4161
|
-
const
|
4162
|
-
data: initialData
|
4163
|
-
|
4164
|
-
|
4165
|
-
const [appData, dispatch] = (0, import_react28.useReducer)(
|
4581
|
+
const [reducer] = (0, import_react32.useState)(() => createReducer({ config }));
|
4582
|
+
const initialAppState = __spreadProps(__spreadValues({}, defaultAppState), {
|
4583
|
+
data: initialData
|
4584
|
+
});
|
4585
|
+
const [appState, dispatch] = (0, import_react32.useReducer)(
|
4166
4586
|
reducer,
|
4167
|
-
flushZones(
|
4587
|
+
flushZones(initialAppState)
|
4168
4588
|
);
|
4169
|
-
const { data,
|
4589
|
+
const { data, ui } = appState;
|
4170
4590
|
const { canForward, canRewind, rewind, forward } = usePuckHistory({
|
4171
|
-
|
4591
|
+
appState,
|
4172
4592
|
dispatch
|
4173
4593
|
});
|
4174
|
-
const { itemSelector, leftSideBarVisible } =
|
4175
|
-
const setItemSelector = (0,
|
4594
|
+
const { itemSelector, leftSideBarVisible } = ui;
|
4595
|
+
const setItemSelector = (0, import_react32.useCallback)(
|
4176
4596
|
(newItemSelector) => {
|
4177
4597
|
dispatch({
|
4178
|
-
type: "
|
4179
|
-
|
4598
|
+
type: "setUi",
|
4599
|
+
ui: { itemSelector: newItemSelector }
|
4180
4600
|
});
|
4181
4601
|
},
|
4182
4602
|
[]
|
4183
4603
|
);
|
4184
4604
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
4185
|
-
const Page = (0,
|
4605
|
+
const Page = (0, import_react32.useCallback)(
|
4186
4606
|
(pageProps) => {
|
4187
4607
|
var _a2, _b2;
|
4188
|
-
return /* @__PURE__ */ (0,
|
4608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4189
4609
|
PluginRenderer,
|
4190
4610
|
{
|
4191
4611
|
plugins,
|
@@ -4197,8 +4617,8 @@ function Puck({
|
|
4197
4617
|
},
|
4198
4618
|
[config.root]
|
4199
4619
|
);
|
4200
|
-
const PageFieldWrapper = (0,
|
4201
|
-
(props) => /* @__PURE__ */ (0,
|
4620
|
+
const PageFieldWrapper = (0, import_react32.useCallback)(
|
4621
|
+
(props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4202
4622
|
PluginRenderer,
|
4203
4623
|
{
|
4204
4624
|
plugins,
|
@@ -4209,8 +4629,8 @@ function Puck({
|
|
4209
4629
|
),
|
4210
4630
|
[]
|
4211
4631
|
);
|
4212
|
-
const ComponentFieldWrapper = (0,
|
4213
|
-
(props) => /* @__PURE__ */ (0,
|
4632
|
+
const ComponentFieldWrapper = (0, import_react32.useCallback)(
|
4633
|
+
(props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4214
4634
|
PluginRenderer,
|
4215
4635
|
{
|
4216
4636
|
plugins,
|
@@ -4224,14 +4644,14 @@ function Puck({
|
|
4224
4644
|
const FieldWrapper = itemSelector ? ComponentFieldWrapper : PageFieldWrapper;
|
4225
4645
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
4226
4646
|
let fields = selectedItem ? ((_b = config.components[selectedItem.type]) == null ? void 0 : _b.fields) || {} : rootFields;
|
4227
|
-
(0,
|
4647
|
+
(0, import_react32.useEffect)(() => {
|
4228
4648
|
if (onChange)
|
4229
4649
|
onChange(data);
|
4230
4650
|
}, [data]);
|
4231
4651
|
const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
|
4232
|
-
const [draggedItem, setDraggedItem] = (0,
|
4233
|
-
return /* @__PURE__ */ (0,
|
4234
|
-
|
4652
|
+
const [draggedItem, setDraggedItem] = (0, import_react32.useState)();
|
4653
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "puck", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AppProvider, { value: { state: appState, dispatch }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4654
|
+
import_react_beautiful_dnd5.DragDropContext,
|
4235
4655
|
{
|
4236
4656
|
onDragUpdate: (update) => {
|
4237
4657
|
setDraggedItem(__spreadValues(__spreadValues({}, draggedItem), update));
|
@@ -4282,7 +4702,7 @@ function Puck({
|
|
4282
4702
|
});
|
4283
4703
|
}
|
4284
4704
|
},
|
4285
|
-
children: /* @__PURE__ */ (0,
|
4705
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4286
4706
|
DropZoneProvider,
|
4287
4707
|
{
|
4288
4708
|
value: {
|
@@ -4296,13 +4716,8 @@ function Puck({
|
|
4296
4716
|
mode: "edit",
|
4297
4717
|
areaId: "root"
|
4298
4718
|
},
|
4299
|
-
children: /* @__PURE__ */ (0,
|
4300
|
-
|
4301
|
-
if (path) {
|
4302
|
-
path = [{ label: "Page", selector: null }, ...path];
|
4303
|
-
path = path.slice(path.length - 2, path.length - 1);
|
4304
|
-
}
|
4305
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
4719
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(dropZoneContext.Consumer, { children: (ctx) => {
|
4720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
4306
4721
|
"div",
|
4307
4722
|
{
|
4308
4723
|
style: {
|
@@ -4318,7 +4733,7 @@ function Puck({
|
|
4318
4733
|
right: 0
|
4319
4734
|
},
|
4320
4735
|
children: [
|
4321
|
-
/* @__PURE__ */ (0,
|
4736
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4322
4737
|
"header",
|
4323
4738
|
{
|
4324
4739
|
style: {
|
@@ -4328,19 +4743,19 @@ function Puck({
|
|
4328
4743
|
borderBottom: "1px solid var(--puck-color-grey-8)"
|
4329
4744
|
},
|
4330
4745
|
children: renderHeader ? renderHeader({
|
4331
|
-
children: /* @__PURE__ */ (0,
|
4746
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4332
4747
|
Button,
|
4333
4748
|
{
|
4334
4749
|
onClick: () => {
|
4335
4750
|
onPublish(data);
|
4336
4751
|
},
|
4337
|
-
icon: /* @__PURE__ */ (0,
|
4752
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(globe_default, { size: "14px" }),
|
4338
4753
|
children: "Publish"
|
4339
4754
|
}
|
4340
4755
|
),
|
4341
4756
|
data,
|
4342
4757
|
dispatch
|
4343
|
-
}) : /* @__PURE__ */ (0,
|
4758
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
4344
4759
|
"div",
|
4345
4760
|
{
|
4346
4761
|
style: {
|
@@ -4351,29 +4766,29 @@ function Puck({
|
|
4351
4766
|
gridTemplateRows: "auto"
|
4352
4767
|
},
|
4353
4768
|
children: [
|
4354
|
-
/* @__PURE__ */ (0,
|
4769
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4355
4770
|
"div",
|
4356
4771
|
{
|
4357
4772
|
style: {
|
4358
4773
|
display: "flex",
|
4359
4774
|
gap: 16
|
4360
4775
|
},
|
4361
|
-
children: /* @__PURE__ */ (0,
|
4776
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4362
4777
|
IconButton,
|
4363
4778
|
{
|
4364
4779
|
onClick: () => dispatch({
|
4365
|
-
type: "
|
4366
|
-
|
4780
|
+
type: "setUi",
|
4781
|
+
ui: {
|
4367
4782
|
leftSideBarVisible: !leftSideBarVisible
|
4368
4783
|
}
|
4369
4784
|
}),
|
4370
4785
|
title: "Toggle left sidebar",
|
4371
|
-
children: /* @__PURE__ */ (0,
|
4786
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(sidebar_default, {})
|
4372
4787
|
}
|
4373
4788
|
)
|
4374
4789
|
}
|
4375
4790
|
),
|
4376
|
-
/* @__PURE__ */ (0,
|
4791
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4377
4792
|
"div",
|
4378
4793
|
{
|
4379
4794
|
style: {
|
@@ -4381,13 +4796,19 @@ function Puck({
|
|
4381
4796
|
justifyContent: "center",
|
4382
4797
|
alignItems: "center"
|
4383
4798
|
},
|
4384
|
-
children: /* @__PURE__ */ (0,
|
4799
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Heading, { rank: 2, size: "xs", children: [
|
4385
4800
|
headerTitle || data.root.title || "Page",
|
4386
|
-
headerPath && /* @__PURE__ */ (0,
|
4801
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4802
|
+
"small",
|
4803
|
+
{
|
4804
|
+
style: { fontWeight: 400, marginLeft: 4 },
|
4805
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("code", { children: headerPath })
|
4806
|
+
}
|
4807
|
+
)
|
4387
4808
|
] })
|
4388
4809
|
}
|
4389
4810
|
),
|
4390
|
-
/* @__PURE__ */ (0,
|
4811
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
4391
4812
|
"div",
|
4392
4813
|
{
|
4393
4814
|
style: {
|
@@ -4396,14 +4817,14 @@ function Puck({
|
|
4396
4817
|
justifyContent: "flex-end"
|
4397
4818
|
},
|
4398
4819
|
children: [
|
4399
|
-
/* @__PURE__ */ (0,
|
4400
|
-
/* @__PURE__ */ (0,
|
4820
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex" }, children: [
|
4821
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4401
4822
|
IconButton,
|
4402
4823
|
{
|
4403
4824
|
title: "undo",
|
4404
4825
|
disabled: !canRewind,
|
4405
4826
|
onClick: rewind,
|
4406
|
-
children: /* @__PURE__ */ (0,
|
4827
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4407
4828
|
chevron_left_default,
|
4408
4829
|
{
|
4409
4830
|
size: 21,
|
@@ -4412,13 +4833,13 @@ function Puck({
|
|
4412
4833
|
)
|
4413
4834
|
}
|
4414
4835
|
),
|
4415
|
-
/* @__PURE__ */ (0,
|
4836
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4416
4837
|
IconButton,
|
4417
4838
|
{
|
4418
4839
|
title: "redo",
|
4419
4840
|
disabled: !canForward,
|
4420
4841
|
onClick: forward,
|
4421
|
-
children: /* @__PURE__ */ (0,
|
4842
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4422
4843
|
chevron_right_default,
|
4423
4844
|
{
|
4424
4845
|
size: 21,
|
@@ -4429,13 +4850,13 @@ function Puck({
|
|
4429
4850
|
)
|
4430
4851
|
] }),
|
4431
4852
|
renderHeaderActions && renderHeaderActions({ data, dispatch }),
|
4432
|
-
/* @__PURE__ */ (0,
|
4853
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4433
4854
|
Button,
|
4434
4855
|
{
|
4435
4856
|
onClick: () => {
|
4436
4857
|
onPublish(data);
|
4437
4858
|
},
|
4438
|
-
icon: /* @__PURE__ */ (0,
|
4859
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(globe_default, { size: "14px" }),
|
4439
4860
|
children: "Publish"
|
4440
4861
|
}
|
4441
4862
|
)
|
@@ -4447,7 +4868,7 @@ function Puck({
|
|
4447
4868
|
)
|
4448
4869
|
}
|
4449
4870
|
),
|
4450
|
-
/* @__PURE__ */ (0,
|
4871
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
4451
4872
|
"div",
|
4452
4873
|
{
|
4453
4874
|
style: {
|
@@ -4459,9 +4880,9 @@ function Puck({
|
|
4459
4880
|
flexDirection: "column"
|
4460
4881
|
},
|
4461
4882
|
children: [
|
4462
|
-
/* @__PURE__ */ (0,
|
4463
|
-
/* @__PURE__ */ (0,
|
4464
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
4883
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SidebarSection, { title: "Components", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ComponentList, { config }) }),
|
4884
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(SidebarSection, { title: "Outline", children: [
|
4885
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4465
4886
|
LayerTree,
|
4466
4887
|
{
|
4467
4888
|
data,
|
@@ -4473,7 +4894,7 @@ function Puck({
|
|
4473
4894
|
),
|
4474
4895
|
Object.entries(findZonesForArea(data, "root")).map(
|
4475
4896
|
([zoneKey, zone]) => {
|
4476
|
-
return /* @__PURE__ */ (0,
|
4897
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4477
4898
|
LayerTree,
|
4478
4899
|
{
|
4479
4900
|
data,
|
@@ -4491,7 +4912,7 @@ function Puck({
|
|
4491
4912
|
]
|
4492
4913
|
}
|
4493
4914
|
),
|
4494
|
-
/* @__PURE__ */ (0,
|
4915
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
4495
4916
|
"div",
|
4496
4917
|
{
|
4497
4918
|
style: {
|
@@ -4504,7 +4925,7 @@ function Puck({
|
|
4504
4925
|
onClick: () => setItemSelector(null),
|
4505
4926
|
id: "puck-frame",
|
4506
4927
|
children: [
|
4507
|
-
/* @__PURE__ */ (0,
|
4928
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4508
4929
|
"div",
|
4509
4930
|
{
|
4510
4931
|
className: "puck-root",
|
@@ -4513,18 +4934,18 @@ function Puck({
|
|
4513
4934
|
margin: 32,
|
4514
4935
|
zoom: 0.75
|
4515
4936
|
},
|
4516
|
-
children: /* @__PURE__ */ (0,
|
4937
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4517
4938
|
"div",
|
4518
4939
|
{
|
4519
4940
|
style: {
|
4520
4941
|
border: "1px solid var(--puck-color-grey-8)"
|
4521
4942
|
},
|
4522
|
-
children: /* @__PURE__ */ (0,
|
4943
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Page, __spreadProps(__spreadValues({ data }, data.root), { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DropZone, { zone: rootDroppableId }) }))
|
4523
4944
|
}
|
4524
4945
|
)
|
4525
4946
|
}
|
4526
4947
|
),
|
4527
|
-
/* @__PURE__ */ (0,
|
4948
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4528
4949
|
"div",
|
4529
4950
|
{
|
4530
4951
|
style: {
|
@@ -4537,7 +4958,7 @@ function Puck({
|
|
4537
4958
|
]
|
4538
4959
|
}
|
4539
4960
|
),
|
4540
|
-
/* @__PURE__ */ (0,
|
4961
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4541
4962
|
"div",
|
4542
4963
|
{
|
4543
4964
|
style: {
|
@@ -4549,12 +4970,11 @@ function Puck({
|
|
4549
4970
|
flexDirection: "column",
|
4550
4971
|
background: "var(--puck-color-white)"
|
4551
4972
|
},
|
4552
|
-
children: /* @__PURE__ */ (0,
|
4973
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(FieldWrapper, { data, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4553
4974
|
SidebarSection,
|
4554
4975
|
{
|
4555
4976
|
noPadding: true,
|
4556
|
-
|
4557
|
-
breadcrumbClick: (breadcrumb) => setItemSelector(breadcrumb.selector),
|
4977
|
+
showBreadcrumbs: true,
|
4558
4978
|
title: selectedItem ? selectedItem.type : "Page",
|
4559
4979
|
children: Object.keys(fields).map((fieldName) => {
|
4560
4980
|
var _a2, _b2, _c, _d;
|
@@ -4608,7 +5028,7 @@ function Puck({
|
|
4608
5028
|
}
|
4609
5029
|
};
|
4610
5030
|
if (selectedItem && itemSelector) {
|
4611
|
-
return /* @__PURE__ */ (0,
|
5031
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4612
5032
|
InputOrGroup,
|
4613
5033
|
{
|
4614
5034
|
field,
|
@@ -4624,13 +5044,15 @@ function Puck({
|
|
4624
5044
|
`${selectedItem.props.id}_${fieldName}`
|
4625
5045
|
);
|
4626
5046
|
} else {
|
4627
|
-
return /* @__PURE__ */ (0,
|
5047
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4628
5048
|
InputOrGroup,
|
4629
5049
|
{
|
4630
5050
|
field,
|
4631
5051
|
name: fieldName,
|
4632
5052
|
label: field.label,
|
4633
|
-
readOnly: ((_d = (_c = data.root._meta) == null ? void 0 : _c.locked) == null ? void 0 : _d.indexOf(
|
5053
|
+
readOnly: ((_d = (_c = data.root._meta) == null ? void 0 : _c.locked) == null ? void 0 : _d.indexOf(
|
5054
|
+
fieldName
|
5055
|
+
)) > -1,
|
4634
5056
|
value: data.root[fieldName],
|
4635
5057
|
onChange: onChange2
|
4636
5058
|
},
|
@@ -4649,17 +5071,17 @@ function Puck({
|
|
4649
5071
|
}
|
4650
5072
|
)
|
4651
5073
|
}
|
4652
|
-
) });
|
5074
|
+
) }) });
|
4653
5075
|
}
|
4654
5076
|
|
4655
5077
|
// components/Render/index.tsx
|
4656
5078
|
init_react_import();
|
4657
|
-
var
|
5079
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
4658
5080
|
function Render({ config, data }) {
|
4659
5081
|
if (config.root) {
|
4660
|
-
return /* @__PURE__ */ (0,
|
5082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(config.root.render, __spreadProps(__spreadValues({}, data.root), { editMode: false, id: "puck-root", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, { zone: rootDroppableId }) })) });
|
4661
5083
|
}
|
4662
|
-
return /* @__PURE__ */ (0,
|
5084
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, { zone: rootDroppableId }) });
|
4663
5085
|
}
|
4664
5086
|
// Annotate the CommonJS export names for ESM import in node:
|
4665
5087
|
0 && (module.exports = {
|