@measured/puck 0.12.0-canary.e38b98f → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +21 -456
- package/dist/{Config-60a50493.d.ts → Config-35e6eaae.d.ts} +2 -1
- package/dist/index.css +390 -158
- package/dist/index.d.ts +41 -41
- package/dist/index.js +647 -560
- package/dist/rsc.d.ts +1 -1
- package/package.json +22 -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 Fragment14 = 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 = Fragment14;
|
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 = getClassName20(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 getClassName20(propValue) {
|
1016
1016
|
if (!propValue.constructor || !propValue.constructor.name) {
|
1017
1017
|
return ANONYMOUS;
|
1018
1018
|
}
|
@@ -9040,7 +9040,7 @@ var require_react_dom_development = __commonJS({
|
|
9040
9040
|
var HostPortal = 4;
|
9041
9041
|
var HostComponent = 5;
|
9042
9042
|
var HostText = 6;
|
9043
|
-
var
|
9043
|
+
var Fragment14 = 7;
|
9044
9044
|
var Mode = 8;
|
9045
9045
|
var ContextConsumer = 9;
|
9046
9046
|
var ContextProvider = 10;
|
@@ -10196,7 +10196,7 @@ var require_react_dom_development = __commonJS({
|
|
10196
10196
|
return "DehydratedFragment";
|
10197
10197
|
case ForwardRef:
|
10198
10198
|
return getWrappedName$1(type, type.render, "ForwardRef");
|
10199
|
-
case
|
10199
|
+
case Fragment14:
|
10200
10200
|
return "Fragment";
|
10201
10201
|
case HostComponent:
|
10202
10202
|
return type;
|
@@ -14313,7 +14313,7 @@ var require_react_dom_development = __commonJS({
|
|
14313
14313
|
defaultPrevented: 0,
|
14314
14314
|
isTrusted: 0
|
14315
14315
|
};
|
14316
|
-
var
|
14316
|
+
var SyntheticEvent3 = createSyntheticEvent(EventInterface);
|
14317
14317
|
var UIEventInterface = assign({}, EventInterface, {
|
14318
14318
|
view: 0,
|
14319
14319
|
detail: 0
|
@@ -14789,7 +14789,7 @@ var require_react_dom_development = __commonJS({
|
|
14789
14789
|
enqueueStateRestore(target);
|
14790
14790
|
var listeners = accumulateTwoPhaseListeners(inst, "onChange");
|
14791
14791
|
if (listeners.length > 0) {
|
14792
|
-
var event = new
|
14792
|
+
var event = new SyntheticEvent3("onChange", "change", null, nativeEvent, target);
|
14793
14793
|
dispatchQueue.push({
|
14794
14794
|
event,
|
14795
14795
|
listeners
|
@@ -15293,7 +15293,7 @@ var require_react_dom_development = __commonJS({
|
|
15293
15293
|
lastSelection = currentSelection;
|
15294
15294
|
var listeners = accumulateTwoPhaseListeners(activeElementInst$1, "onSelect");
|
15295
15295
|
if (listeners.length > 0) {
|
15296
|
-
var event = new
|
15296
|
+
var event = new SyntheticEvent3("onSelect", "select", null, nativeEvent, nativeEventTarget);
|
15297
15297
|
dispatchQueue.push({
|
15298
15298
|
event,
|
15299
15299
|
listeners
|
@@ -15405,7 +15405,7 @@ var require_react_dom_development = __commonJS({
|
|
15405
15405
|
if (reactName === void 0) {
|
15406
15406
|
return;
|
15407
15407
|
}
|
15408
|
-
var SyntheticEventCtor =
|
15408
|
+
var SyntheticEventCtor = SyntheticEvent3;
|
15409
15409
|
var reactEventType = domEventName;
|
15410
15410
|
switch (domEventName) {
|
15411
15411
|
case "keypress":
|
@@ -19867,7 +19867,7 @@ var require_react_dom_development = __commonJS({
|
|
19867
19867
|
}
|
19868
19868
|
}
|
19869
19869
|
function updateFragment2(returnFiber, current2, fragment, lanes, key) {
|
19870
|
-
if (current2 === null || current2.tag !==
|
19870
|
+
if (current2 === null || current2.tag !== Fragment14) {
|
19871
19871
|
var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);
|
19872
19872
|
created.return = returnFiber;
|
19873
19873
|
return created;
|
@@ -20270,7 +20270,7 @@ var require_react_dom_development = __commonJS({
|
|
20270
20270
|
if (child.key === key) {
|
20271
20271
|
var elementType = element.type;
|
20272
20272
|
if (elementType === REACT_FRAGMENT_TYPE) {
|
20273
|
-
if (child.tag ===
|
20273
|
+
if (child.tag === Fragment14) {
|
20274
20274
|
deleteRemainingChildren(returnFiber, child.sibling);
|
20275
20275
|
var existing = useFiber(child, element.props.children);
|
20276
20276
|
existing.return = returnFiber;
|
@@ -24445,7 +24445,7 @@ var require_react_dom_development = __commonJS({
|
|
24445
24445
|
var _resolvedProps2 = workInProgress2.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
|
24446
24446
|
return updateForwardRef(current2, workInProgress2, type, _resolvedProps2, renderLanes2);
|
24447
24447
|
}
|
24448
|
-
case
|
24448
|
+
case Fragment14:
|
24449
24449
|
return updateFragment(current2, workInProgress2, renderLanes2);
|
24450
24450
|
case Mode:
|
24451
24451
|
return updateMode(current2, workInProgress2, renderLanes2);
|
@@ -24718,7 +24718,7 @@ var require_react_dom_development = __commonJS({
|
|
24718
24718
|
case SimpleMemoComponent:
|
24719
24719
|
case FunctionComponent:
|
24720
24720
|
case ForwardRef:
|
24721
|
-
case
|
24721
|
+
case Fragment14:
|
24722
24722
|
case Mode:
|
24723
24723
|
case Profiler:
|
24724
24724
|
case ContextConsumer:
|
@@ -28977,7 +28977,7 @@ var require_react_dom_development = __commonJS({
|
|
28977
28977
|
return fiber;
|
28978
28978
|
}
|
28979
28979
|
function createFiberFromFragment(elements, mode, lanes, key) {
|
28980
|
-
var fiber = createFiber(
|
28980
|
+
var fiber = createFiber(Fragment14, elements, key, mode);
|
28981
28981
|
fiber.lanes = lanes;
|
28982
28982
|
return fiber;
|
28983
28983
|
}
|
@@ -30125,7 +30125,7 @@ var import_react2 = require("react");
|
|
30125
30125
|
|
30126
30126
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
30127
30127
|
init_react_import();
|
30128
|
-
var Button_module_default = { "Button": "
|
30128
|
+
var Button_module_default = { "Button": "_Button_1brfa_1", "Button--medium": "_Button--medium_1brfa_22", "Button--large": "_Button--large_1brfa_29", "Button-icon": "_Button-icon_1brfa_36", "Button--primary": "_Button--primary_1brfa_44", "Button--secondary": "_Button--secondary_1brfa_53", "Button--flush": "_Button--flush_1brfa_64", "Button--disabled": "_Button--disabled_1brfa_68", "Button--fullWidth": "_Button--fullWidth_1brfa_78" };
|
30129
30129
|
|
30130
30130
|
// lib/get-class-name-factory.ts
|
30131
30131
|
init_react_import();
|
@@ -31974,6 +31974,7 @@ var defaultAppState = {
|
|
31974
31974
|
data: { content: [], root: { title: "" } },
|
31975
31975
|
ui: {
|
31976
31976
|
leftSideBarVisible: true,
|
31977
|
+
rightSideBarVisible: true,
|
31977
31978
|
arrayState: {},
|
31978
31979
|
itemSelector: null,
|
31979
31980
|
componentList: {}
|
@@ -32301,7 +32302,7 @@ var import_react26 = require("react");
|
|
32301
32302
|
|
32302
32303
|
// css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
|
32303
32304
|
init_react_import();
|
32304
|
-
var IconButton_module_default = { "IconButton": "
|
32305
|
+
var IconButton_module_default = { "IconButton": "_IconButton_38xdr_1", "IconButton-title": "_IconButton-title_38xdr_18" };
|
32305
32306
|
|
32306
32307
|
// components/IconButton/IconButton.tsx
|
32307
32308
|
var import_react_spinners3 = require("react-spinners");
|
@@ -32346,10 +32347,11 @@ var IconButton = ({
|
|
32346
32347
|
href,
|
32347
32348
|
title,
|
32348
32349
|
children: [
|
32350
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: getClassName4("title"), children: title }),
|
32349
32351
|
children,
|
32350
32352
|
loading && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
32351
32353
|
"\xA0\xA0",
|
32352
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_spinners3.ClipLoader, { color: "inherit", size: "14px" })
|
32354
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_spinners3.ClipLoader, { "aria-label": "Loading", color: "inherit", size: "14px" })
|
32353
32355
|
] })
|
32354
32356
|
]
|
32355
32357
|
}
|
@@ -32359,7 +32361,7 @@ var IconButton = ({
|
|
32359
32361
|
|
32360
32362
|
// components/Puck/index.tsx
|
32361
32363
|
init_react_import();
|
32362
|
-
var
|
32364
|
+
var import_react39 = require("react");
|
32363
32365
|
var import_dnd7 = require("@hello-pangea/dnd");
|
32364
32366
|
|
32365
32367
|
// components/InputOrGroup/index.tsx
|
@@ -32367,10 +32369,10 @@ init_react_import();
|
|
32367
32369
|
|
32368
32370
|
// css-module:/home/runner/work/puck/puck/packages/core/components/InputOrGroup/styles.module.css#css-module
|
32369
32371
|
init_react_import();
|
32370
|
-
var styles_module_default3 = { "Input": "
|
32372
|
+
var styles_module_default3 = { "Input": "_Input_1jyrm_1", "Input-label": "_Input-label_1jyrm_27", "Input-labelIcon": "_Input-labelIcon_1jyrm_35", "Input-disabledIcon": "_Input-disabledIcon_1jyrm_41", "Input-input": "_Input-input_1jyrm_46", "Input--readOnly": "_Input--readOnly_1jyrm_69", "Input-radioGroupItems": "_Input-radioGroupItems_1jyrm_87", "Input-radio": "_Input-radio_1jyrm_87", "Input-radioInner": "_Input-radioInner_1jyrm_104", "Input-radioInput": "_Input-radioInput_1jyrm_126" };
|
32371
32373
|
|
32372
32374
|
// components/InputOrGroup/index.tsx
|
32373
|
-
var
|
32375
|
+
var import_react31 = require("react");
|
32374
32376
|
|
32375
32377
|
// components/InputOrGroup/fields/index.tsx
|
32376
32378
|
init_react_import();
|
@@ -32380,7 +32382,7 @@ init_react_import();
|
|
32380
32382
|
|
32381
32383
|
// css-module:/home/runner/work/puck/puck/packages/core/components/InputOrGroup/fields/ArrayField/styles.module.css#css-module
|
32382
32384
|
init_react_import();
|
32383
|
-
var styles_module_default4 = { "ArrayField": "
|
32385
|
+
var styles_module_default4 = { "ArrayField": "_ArrayField_1auyc_5", "ArrayField--isDraggingFrom": "_ArrayField--isDraggingFrom_1auyc_13", "ArrayField-addButton": "_ArrayField-addButton_1auyc_17", "ArrayField--hasItems": "_ArrayField--hasItems_1auyc_31", "ArrayFieldItem": "_ArrayFieldItem_1auyc_45", "ArrayFieldItem--isDragging": "_ArrayFieldItem--isDragging_1auyc_53", "ArrayFieldItem--isExpanded": "_ArrayFieldItem--isExpanded_1auyc_58", "ArrayFieldItem-summary": "_ArrayFieldItem-summary_1auyc_73", "ArrayFieldItem--readOnly": "_ArrayFieldItem--readOnly_1auyc_86", "ArrayFieldItem-body": "_ArrayFieldItem-body_1auyc_107", "ArrayFieldItem-fieldset": "_ArrayFieldItem-fieldset_1auyc_115", "ArrayFieldItem-rhs": "_ArrayFieldItem-rhs_1auyc_122", "ArrayFieldItem-actions": "_ArrayFieldItem-actions_1auyc_128", "ArrayFieldItem-action": "_ArrayFieldItem-action_1auyc_128" };
|
32384
32386
|
|
32385
32387
|
// components/InputOrGroup/fields/ArrayField/index.tsx
|
32386
32388
|
var import_dnd4 = require("@hello-pangea/dnd");
|
@@ -32434,11 +32436,6 @@ var Draggable2 = ({
|
|
32434
32436
|
);
|
32435
32437
|
};
|
32436
32438
|
|
32437
|
-
// lib/generate-id.ts
|
32438
|
-
init_react_import();
|
32439
|
-
var import_crypto = require("crypto");
|
32440
|
-
var generateId = (type) => `${type}-${(0, import_crypto.randomBytes)(20).toString("hex")}`;
|
32441
|
-
|
32442
32439
|
// components/InputOrGroup/fields/ArrayField/index.tsx
|
32443
32440
|
var import_react27 = require("react");
|
32444
32441
|
|
@@ -32465,40 +32462,59 @@ var ArrayField = ({
|
|
32465
32462
|
name,
|
32466
32463
|
label,
|
32467
32464
|
readOnly,
|
32468
|
-
readOnlyFields = {}
|
32465
|
+
readOnlyFields = {},
|
32466
|
+
id
|
32469
32467
|
}) => {
|
32470
|
-
const [arrayFieldId] = (0, import_react27.useState)(generateId("ArrayField"));
|
32471
32468
|
const { state, setUi } = useAppContext();
|
32472
|
-
const arrayState = state.ui.arrayState[
|
32473
|
-
items: Array.from(value || []).map((
|
32474
|
-
|
32475
|
-
|
32476
|
-
|
32469
|
+
const arrayState = state.ui.arrayState[id] || {
|
32470
|
+
items: Array.from(value || []).map((item, idx) => {
|
32471
|
+
return {
|
32472
|
+
_originalIndex: idx,
|
32473
|
+
_arrayId: `${id}-${idx}`,
|
32474
|
+
data: item
|
32475
|
+
};
|
32476
|
+
}),
|
32477
32477
|
openId: ""
|
32478
32478
|
};
|
32479
|
-
const
|
32480
|
-
|
32481
|
-
|
32482
|
-
|
32483
|
-
|
32484
|
-
|
32485
|
-
|
32486
|
-
},
|
32487
|
-
|
32488
|
-
|
32479
|
+
const [localState, setLocalState] = (0, import_react27.useState)({ arrayState, value });
|
32480
|
+
(0, import_react27.useEffect)(() => {
|
32481
|
+
setLocalState({ arrayState, value });
|
32482
|
+
}, [value, state.ui.arrayState[id]]);
|
32483
|
+
const mapArrayStateToUi = (0, import_react27.useCallback)(
|
32484
|
+
(partialArrayState) => {
|
32485
|
+
return {
|
32486
|
+
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
32487
|
+
[id]: __spreadValues(__spreadValues({}, arrayState), partialArrayState)
|
32488
|
+
})
|
32489
|
+
};
|
32490
|
+
},
|
32491
|
+
[arrayState]
|
32492
|
+
);
|
32493
|
+
const getHighestIndex = (0, import_react27.useCallback)(() => {
|
32494
|
+
return arrayState.items.reduce(
|
32495
|
+
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
32496
|
+
-1
|
32497
|
+
);
|
32498
|
+
}, [arrayState]);
|
32499
|
+
const regenerateArrayState = (0, import_react27.useCallback)(
|
32500
|
+
(value2) => {
|
32501
|
+
let highestIndex = getHighestIndex();
|
32502
|
+
const newItems = Array.from(value2 || []).map((item, idx) => {
|
32503
|
+
var _a;
|
32504
|
+
const arrayStateItem = arrayState.items[idx];
|
32505
|
+
return {
|
32506
|
+
_originalIndex: typeof (arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) !== "undefined" ? arrayStateItem._originalIndex : ++highestIndex,
|
32507
|
+
_arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || `${id}-${highestIndex}`,
|
32508
|
+
data: item
|
32509
|
+
};
|
32510
|
+
});
|
32511
|
+
return __spreadProps(__spreadValues({}, arrayState), { items: newItems });
|
32489
32512
|
},
|
32490
32513
|
[arrayState]
|
32491
32514
|
);
|
32492
32515
|
(0, import_react27.useEffect)(() => {
|
32493
|
-
|
32494
|
-
|
32495
|
-
return {
|
32496
|
-
_arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || generateId("ArrayItem"),
|
32497
|
-
data: item
|
32498
|
-
};
|
32499
|
-
});
|
32500
|
-
setArrayState({ items: newItems });
|
32501
|
-
}, [value]);
|
32516
|
+
setUi(mapArrayStateToUi(arrayState));
|
32517
|
+
}, []);
|
32502
32518
|
if (field.type !== "array" || !field.arrayFields) {
|
32503
32519
|
return null;
|
32504
32520
|
}
|
@@ -32513,15 +32529,27 @@ var ArrayField = ({
|
|
32513
32529
|
import_dnd5.DragDropContext,
|
32514
32530
|
{
|
32515
32531
|
onDragEnd: (event) => {
|
32516
|
-
var _a;
|
32532
|
+
var _a, _b;
|
32517
32533
|
if (event.destination) {
|
32518
32534
|
const newValue = reorder(
|
32519
|
-
|
32535
|
+
value,
|
32520
32536
|
event.source.index,
|
32521
32537
|
(_a = event.destination) == null ? void 0 : _a.index
|
32522
32538
|
);
|
32523
|
-
|
32524
|
-
|
32539
|
+
const newArrayStateItems = reorder(
|
32540
|
+
arrayState.items,
|
32541
|
+
event.source.index,
|
32542
|
+
(_b = event.destination) == null ? void 0 : _b.index
|
32543
|
+
);
|
32544
|
+
onChange(newValue, {
|
32545
|
+
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
32546
|
+
[id]: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
32547
|
+
})
|
32548
|
+
});
|
32549
|
+
setLocalState({
|
32550
|
+
value: newValue,
|
32551
|
+
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
32552
|
+
});
|
32525
32553
|
}
|
32526
32554
|
},
|
32527
32555
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dnd4.Droppable, { droppableId: "array", isDropDisabled: readOnly, children: (provided, snapshot) => {
|
@@ -32534,97 +32562,104 @@ var ArrayField = ({
|
|
32534
32562
|
hasItems: Array.isArray(value) && value.length > 0
|
32535
32563
|
}),
|
32536
32564
|
children: [
|
32537
|
-
|
32538
|
-
|
32539
|
-
|
32540
|
-
|
32541
|
-
|
32542
|
-
|
32543
|
-
|
32544
|
-
|
32545
|
-
|
32546
|
-
|
32547
|
-
|
32548
|
-
|
32549
|
-
|
32550
|
-
|
32551
|
-
|
32552
|
-
|
32553
|
-
|
32554
|
-
|
32555
|
-
|
32556
|
-
|
32557
|
-
|
32558
|
-
|
32559
|
-
|
32560
|
-
|
32561
|
-
|
32562
|
-
|
32563
|
-
|
32564
|
-
|
32565
|
-
|
32566
|
-
|
32567
|
-
|
32568
|
-
|
32569
|
-
|
32570
|
-
|
32571
|
-
|
32572
|
-
|
32573
|
-
|
32574
|
-
|
32575
|
-
|
32576
|
-
|
32577
|
-
|
32578
|
-
|
32579
|
-
|
32580
|
-
|
32581
|
-
|
32582
|
-
|
32583
|
-
|
32584
|
-
|
32585
|
-
|
32586
|
-
|
32587
|
-
|
32588
|
-
|
32589
|
-
|
32590
|
-
|
32591
|
-
|
32592
|
-
|
32593
|
-
|
32594
|
-
|
32595
|
-
|
32596
|
-
|
32597
|
-
|
32598
|
-
|
32599
|
-
|
32600
|
-
|
32601
|
-
|
32602
|
-
|
32603
|
-
|
32604
|
-
|
32605
|
-
|
32606
|
-
|
32607
|
-
|
32608
|
-
|
32609
|
-
|
32610
|
-
|
32611
|
-
|
32612
|
-
|
32565
|
+
localState.arrayState.items.map((item, i) => {
|
32566
|
+
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
32567
|
+
const data = Array.from(localState.value || [])[i];
|
32568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
32569
|
+
Draggable2,
|
32570
|
+
{
|
32571
|
+
id: _arrayId,
|
32572
|
+
index: i,
|
32573
|
+
className: (_, snapshot2) => getClassNameItem({
|
32574
|
+
isExpanded: arrayState.openId === _arrayId,
|
32575
|
+
isDragging: snapshot2 == null ? void 0 : snapshot2.isDragging,
|
32576
|
+
readOnly
|
32577
|
+
}),
|
32578
|
+
isDragDisabled: readOnly,
|
32579
|
+
children: () => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
32580
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
32581
|
+
"div",
|
32582
|
+
{
|
32583
|
+
onClick: () => {
|
32584
|
+
if (arrayState.openId === _arrayId) {
|
32585
|
+
setUi(
|
32586
|
+
mapArrayStateToUi({
|
32587
|
+
openId: ""
|
32588
|
+
})
|
32589
|
+
);
|
32590
|
+
} else {
|
32591
|
+
setUi(
|
32592
|
+
mapArrayStateToUi({
|
32593
|
+
openId: _arrayId
|
32594
|
+
})
|
32595
|
+
);
|
32596
|
+
}
|
32597
|
+
},
|
32598
|
+
className: getClassNameItem("summary"),
|
32599
|
+
children: [
|
32600
|
+
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
32601
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
32602
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("actions"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
32603
|
+
IconButton,
|
32604
|
+
{
|
32605
|
+
onClick: (e) => {
|
32606
|
+
e.stopPropagation();
|
32607
|
+
const existingValue = [
|
32608
|
+
...value || []
|
32609
|
+
];
|
32610
|
+
const existingItems = [
|
32611
|
+
...arrayState.items || []
|
32612
|
+
];
|
32613
|
+
existingValue.splice(i, 1);
|
32614
|
+
existingItems.splice(i, 1);
|
32615
|
+
onChange(
|
32616
|
+
existingValue,
|
32617
|
+
mapArrayStateToUi({
|
32618
|
+
items: existingItems
|
32619
|
+
})
|
32620
|
+
);
|
32621
|
+
},
|
32622
|
+
title: "Delete",
|
32623
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(trash_default, { size: 16 })
|
32624
|
+
}
|
32625
|
+
) }) }),
|
32626
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DragIcon, {}) })
|
32627
|
+
] })
|
32628
|
+
]
|
32629
|
+
}
|
32630
|
+
),
|
32631
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map(
|
32632
|
+
(fieldName) => {
|
32633
|
+
const subField = field.arrayFields[fieldName];
|
32634
|
+
const subFieldName = `${name}[${i}].${fieldName}`;
|
32635
|
+
const wildcardFieldName = `${name}[*].${fieldName}`;
|
32636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
32637
|
+
InputOrGroup,
|
32638
|
+
{
|
32639
|
+
name: subFieldName,
|
32640
|
+
label: subField.label || fieldName,
|
32641
|
+
id: `${id}_${fieldName}`,
|
32642
|
+
readOnly: typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName],
|
32643
|
+
readOnlyFields,
|
32644
|
+
field: subField,
|
32645
|
+
value: data[fieldName],
|
32646
|
+
onChange: (val) => {
|
32647
|
+
onChange(
|
32613
32648
|
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
32614
32649
|
[fieldName]: val
|
32615
32650
|
}))
|
32616
|
-
)
|
32617
|
-
}
|
32618
|
-
|
32619
|
-
|
32620
|
-
|
32621
|
-
|
32622
|
-
}
|
32623
|
-
|
32624
|
-
|
32625
|
-
|
32626
|
-
|
32627
|
-
)
|
32651
|
+
);
|
32652
|
+
}
|
32653
|
+
},
|
32654
|
+
subFieldName
|
32655
|
+
);
|
32656
|
+
}
|
32657
|
+
) }) })
|
32658
|
+
] })
|
32659
|
+
},
|
32660
|
+
_arrayId
|
32661
|
+
);
|
32662
|
+
}),
|
32628
32663
|
provided.placeholder,
|
32629
32664
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
32630
32665
|
"button",
|
@@ -32632,7 +32667,12 @@ var ArrayField = ({
|
|
32632
32667
|
className: getClassName6("addButton"),
|
32633
32668
|
onClick: () => {
|
32634
32669
|
const existingValue = value || [];
|
32635
|
-
|
32670
|
+
const newValue = [
|
32671
|
+
...existingValue,
|
32672
|
+
field.defaultItemProps || {}
|
32673
|
+
];
|
32674
|
+
const newArrayState = regenerateArrayState(newValue);
|
32675
|
+
onChange(newValue, mapArrayStateToUi(newArrayState));
|
32636
32676
|
},
|
32637
32677
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(plus_default, { size: "21" })
|
32638
32678
|
}
|
@@ -32657,7 +32697,8 @@ var DefaultField = ({
|
|
32657
32697
|
readOnly,
|
32658
32698
|
value,
|
32659
32699
|
name,
|
32660
|
-
label
|
32700
|
+
label,
|
32701
|
+
id
|
32661
32702
|
}) => {
|
32662
32703
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
32663
32704
|
FieldLabelInternal,
|
@@ -32683,7 +32724,8 @@ var DefaultField = ({
|
|
32683
32724
|
onChange(e.currentTarget.value);
|
32684
32725
|
}
|
32685
32726
|
},
|
32686
|
-
readOnly
|
32727
|
+
readOnly,
|
32728
|
+
id
|
32687
32729
|
}
|
32688
32730
|
)
|
32689
32731
|
}
|
@@ -32692,18 +32734,19 @@ var DefaultField = ({
|
|
32692
32734
|
|
32693
32735
|
// components/InputOrGroup/fields/ExternalField/index.tsx
|
32694
32736
|
init_react_import();
|
32695
|
-
var
|
32737
|
+
var import_react30 = require("react");
|
32696
32738
|
|
32697
32739
|
// components/ExternalInput/index.tsx
|
32698
32740
|
init_react_import();
|
32699
|
-
var
|
32741
|
+
var import_react29 = require("react");
|
32700
32742
|
|
32701
32743
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
32702
32744
|
init_react_import();
|
32703
|
-
var styles_module_default6 = { "ExternalInput": "
|
32745
|
+
var styles_module_default6 = { "ExternalInput": "_ExternalInput_157li_1", "ExternalInput-actions": "_ExternalInput-actions_157li_5", "ExternalInput-button": "_ExternalInput-button_157li_9", "ExternalInput-detachButton": "_ExternalInput-detachButton_157li_28", "ExternalInput--dataSelected": "_ExternalInput--dataSelected_157li_35", "ExternalInputModal": "_ExternalInputModal_157li_56", "ExternalInputModal-masthead": "_ExternalInputModal-masthead_157li_63", "ExternalInputModal-tableWrapper": "_ExternalInputModal-tableWrapper_157li_68", "ExternalInputModal-table": "_ExternalInputModal-table_157li_68", "ExternalInputModal-thead": "_ExternalInputModal-thead_157li_83", "ExternalInputModal-th": "_ExternalInputModal-th_157li_83", "ExternalInputModal-td": "_ExternalInputModal-td_157li_97", "ExternalInputModal-tr": "_ExternalInputModal-tr_157li_102", "ExternalInputModal-tbody": "_ExternalInputModal-tbody_157li_114", "ExternalInputModal--hasData": "_ExternalInputModal--hasData_157li_133", "ExternalInputModal-loadingBanner": "_ExternalInputModal-loadingBanner_157li_137", "ExternalInputModal--isLoading": "_ExternalInputModal--isLoading_157li_145", "ExternalInputModal-noContentBanner": "_ExternalInputModal-noContentBanner_157li_149", "ExternalInputModal--loaded": "_ExternalInputModal--loaded_157li_153" };
|
32704
32746
|
|
32705
32747
|
// components/Modal/index.tsx
|
32706
32748
|
init_react_import();
|
32749
|
+
var import_react28 = require("react");
|
32707
32750
|
|
32708
32751
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
32709
32752
|
init_react_import();
|
@@ -32718,7 +32761,10 @@ var Modal = ({
|
|
32718
32761
|
onClose,
|
32719
32762
|
isOpen
|
32720
32763
|
}) => {
|
32721
|
-
const rootEl =
|
32764
|
+
const [rootEl, setRootEl] = (0, import_react28.useState)(null);
|
32765
|
+
(0, import_react28.useEffect)(() => {
|
32766
|
+
setRootEl(document.getElementById("puck-portal-root"));
|
32767
|
+
}, []);
|
32722
32768
|
if (!rootEl) {
|
32723
32769
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {});
|
32724
32770
|
}
|
@@ -32768,13 +32814,14 @@ var ExternalInput = ({
|
|
32768
32814
|
field,
|
32769
32815
|
onChange,
|
32770
32816
|
value = null,
|
32771
|
-
name
|
32817
|
+
name,
|
32818
|
+
id
|
32772
32819
|
}) => {
|
32773
32820
|
const { mapProp = (val) => val } = field || {};
|
32774
|
-
const [data, setData] = (0,
|
32775
|
-
const [isOpen, setOpen] = (0,
|
32776
|
-
const [isLoading, setIsLoading] = (0,
|
32777
|
-
const keys = (0,
|
32821
|
+
const [data, setData] = (0, import_react29.useState)([]);
|
32822
|
+
const [isOpen, setOpen] = (0, import_react29.useState)(false);
|
32823
|
+
const [isLoading, setIsLoading] = (0, import_react29.useState)(true);
|
32824
|
+
const keys = (0, import_react29.useMemo)(() => {
|
32778
32825
|
const validKeys = /* @__PURE__ */ new Set();
|
32779
32826
|
for (const item of data) {
|
32780
32827
|
for (const key of Object.keys(item)) {
|
@@ -32785,7 +32832,7 @@ var ExternalInput = ({
|
|
32785
32832
|
}
|
32786
32833
|
return Array.from(validKeys);
|
32787
32834
|
}, [data]);
|
32788
|
-
(0,
|
32835
|
+
(0, import_react29.useEffect)(() => {
|
32789
32836
|
(() => __async(void 0, null, function* () {
|
32790
32837
|
const listData = dataCache[name] || (yield field.fetchList());
|
32791
32838
|
if (listData) {
|
@@ -32802,6 +32849,7 @@ var ExternalInput = ({
|
|
32802
32849
|
dataSelected: !!value,
|
32803
32850
|
modalVisible: isOpen
|
32804
32851
|
}),
|
32852
|
+
id,
|
32805
32853
|
children: [
|
32806
32854
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName10("actions"), children: [
|
32807
32855
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
@@ -32879,12 +32927,13 @@ var ExternalField = ({
|
|
32879
32927
|
onChange,
|
32880
32928
|
value,
|
32881
32929
|
name,
|
32882
|
-
label
|
32930
|
+
label,
|
32931
|
+
id
|
32883
32932
|
}) => {
|
32884
32933
|
var _a, _b, _c;
|
32885
32934
|
const validField = field;
|
32886
32935
|
const deprecatedField = field;
|
32887
|
-
(0,
|
32936
|
+
(0, import_react30.useEffect)(() => {
|
32888
32937
|
if (deprecatedField.adaptor) {
|
32889
32938
|
console.error(
|
32890
32939
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
@@ -32906,7 +32955,7 @@ var ExternalField = ({
|
|
32906
32955
|
name,
|
32907
32956
|
field: __spreadProps(__spreadValues({}, validField), {
|
32908
32957
|
// DEPRECATED
|
32909
|
-
placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder,
|
32958
|
+
placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
|
32910
32959
|
mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
|
32911
32960
|
fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(void 0, null, function* () {
|
32912
32961
|
return yield deprecatedField.adaptor.fetchList(
|
@@ -32915,7 +32964,8 @@ var ExternalField = ({
|
|
32915
32964
|
}) : validField.fetchList
|
32916
32965
|
}),
|
32917
32966
|
onChange,
|
32918
|
-
value
|
32967
|
+
value,
|
32968
|
+
id
|
32919
32969
|
}
|
32920
32970
|
)
|
32921
32971
|
}
|
@@ -32931,7 +32981,8 @@ var RadioField = ({
|
|
32931
32981
|
onChange,
|
32932
32982
|
readOnly,
|
32933
32983
|
value,
|
32934
|
-
name
|
32984
|
+
name,
|
32985
|
+
id
|
32935
32986
|
}) => {
|
32936
32987
|
if (field.type !== "radio" || !field.options) {
|
32937
32988
|
return null;
|
@@ -32943,7 +32994,7 @@ var RadioField = ({
|
|
32943
32994
|
label: field.label || name,
|
32944
32995
|
readOnly,
|
32945
32996
|
el: "div",
|
32946
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
32997
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
32947
32998
|
"label",
|
32948
32999
|
{
|
32949
33000
|
className: getClassName11("radio"),
|
@@ -32985,7 +33036,8 @@ var SelectField = ({
|
|
32985
33036
|
label,
|
32986
33037
|
value,
|
32987
33038
|
name,
|
32988
|
-
readOnly
|
33039
|
+
readOnly,
|
33040
|
+
id
|
32989
33041
|
}) => {
|
32990
33042
|
if (field.type !== "select" || !field.options) {
|
32991
33043
|
return null;
|
@@ -32999,6 +33051,7 @@ var SelectField = ({
|
|
32999
33051
|
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
33000
33052
|
"select",
|
33001
33053
|
{
|
33054
|
+
id,
|
33002
33055
|
className: getClassName12("input"),
|
33003
33056
|
disabled: readOnly,
|
33004
33057
|
onChange: (e) => {
|
@@ -33032,7 +33085,8 @@ var TextareaField = ({
|
|
33032
33085
|
readOnly,
|
33033
33086
|
value,
|
33034
33087
|
name,
|
33035
|
-
label
|
33088
|
+
label,
|
33089
|
+
id
|
33036
33090
|
}) => {
|
33037
33091
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
33038
33092
|
FieldLabelInternal,
|
@@ -33043,6 +33097,7 @@ var TextareaField = ({
|
|
33043
33097
|
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
33044
33098
|
"textarea",
|
33045
33099
|
{
|
33100
|
+
id,
|
33046
33101
|
className: getClassName13("input"),
|
33047
33102
|
autoComplete: "off",
|
33048
33103
|
name,
|
@@ -33085,7 +33140,6 @@ var FieldLabelInternal = ({
|
|
33085
33140
|
el = "label",
|
33086
33141
|
readOnly
|
33087
33142
|
}) => {
|
33088
|
-
const El = el;
|
33089
33143
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
33090
33144
|
FieldLabel,
|
33091
33145
|
{
|
@@ -33101,17 +33155,19 @@ var FieldLabelInternal = ({
|
|
33101
33155
|
var InputOrGroup = (_a) => {
|
33102
33156
|
var _b = _a, { onChange } = _b, props = __objRest(_b, ["onChange"]);
|
33103
33157
|
const { name, field, value, readOnly } = props;
|
33104
|
-
const [localValue, setLocalValue] = (0,
|
33105
|
-
const
|
33106
|
-
|
33107
|
-
|
33108
|
-
|
33109
|
-
|
33110
|
-
|
33111
|
-
|
33158
|
+
const [localValue, setLocalValue] = (0, import_react31.useState)(value);
|
33159
|
+
const onChangeDb = (0, import_use_debounce2.useDebouncedCallback)(
|
33160
|
+
(val, ui) => {
|
33161
|
+
onChange(val, ui);
|
33162
|
+
},
|
33163
|
+
50,
|
33164
|
+
{ leading: true }
|
33165
|
+
);
|
33166
|
+
const onChangeLocal = (0, import_react31.useCallback)((val, ui) => {
|
33112
33167
|
setLocalValue(val);
|
33168
|
+
onChangeDb(val, ui);
|
33113
33169
|
}, []);
|
33114
|
-
(0,
|
33170
|
+
(0, import_react31.useEffect)(() => {
|
33115
33171
|
setLocalValue(value);
|
33116
33172
|
}, [value]);
|
33117
33173
|
const localProps = {
|
@@ -33152,7 +33208,7 @@ var import_dnd6 = require("@hello-pangea/dnd");
|
|
33152
33208
|
|
33153
33209
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
33154
33210
|
init_react_import();
|
33155
|
-
var styles_module_default9 = { "ComponentList": "
|
33211
|
+
var styles_module_default9 = { "ComponentList": "_ComponentList_1m8r5_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1m8r5_6", "ComponentList-content": "_ComponentList-content_1m8r5_10", "ComponentList-title": "_ComponentList-title_1m8r5_18", "ComponentList-titleIcon": "_ComponentList-titleIcon_1m8r5_39", "ComponentListItem": "_ComponentListItem_1m8r5_43", "ComponentListItem-draggable": "_ComponentListItem-draggable_1m8r5_43", "ComponentListItem-name": "_ComponentListItem-name_1m8r5_60", "ComponentList--isDraggingFrom": "_ComponentList--isDraggingFrom_1m8r5_66" };
|
33156
33212
|
|
33157
33213
|
// components/ComponentList/index.tsx
|
33158
33214
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
@@ -33172,7 +33228,7 @@ var ComponentListItem = ({
|
|
33172
33228
|
disableAnimations: true,
|
33173
33229
|
className: () => getClassNameItem2("draggable"),
|
33174
33230
|
children: () => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
33175
|
-
component,
|
33231
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassNameItem2("name"), children: component }),
|
33176
33232
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DragIcon, {}) })
|
33177
33233
|
] })
|
33178
33234
|
},
|
@@ -33241,10 +33297,10 @@ ComponentList.Item = ComponentListItem;
|
|
33241
33297
|
|
33242
33298
|
// lib/use-placeholder-style.ts
|
33243
33299
|
init_react_import();
|
33244
|
-
var
|
33300
|
+
var import_react32 = require("react");
|
33245
33301
|
var usePlaceholderStyle = () => {
|
33246
33302
|
const queryAttr = "data-rfd-drag-handle-draggable-id";
|
33247
|
-
const [placeholderStyle, setPlaceholderStyle] = (0,
|
33303
|
+
const [placeholderStyle, setPlaceholderStyle] = (0, import_react32.useState)();
|
33248
33304
|
const onDragStartOrUpdate = (draggedItem) => {
|
33249
33305
|
var _a;
|
33250
33306
|
const draggableId = draggedItem.draggableId;
|
@@ -33292,11 +33348,11 @@ init_react_import();
|
|
33292
33348
|
|
33293
33349
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
33294
33350
|
init_react_import();
|
33295
|
-
var styles_module_default10 = { "SidebarSection": "
|
33351
|
+
var styles_module_default10 = { "SidebarSection": "_SidebarSection_1uyg2_1", "SidebarSection-title": "_SidebarSection-title_1uyg2_12", "SidebarSection-content": "_SidebarSection-content_1uyg2_19", "SidebarSection--noPadding": "_SidebarSection--noPadding_1uyg2_24", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_1uyg2_37", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_1uyg2_48", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_1uyg2_37", "SidebarSection-heading": "_SidebarSection-heading_1uyg2_60", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_1uyg2_64" };
|
33296
33352
|
|
33297
33353
|
// lib/use-breadcrumbs.ts
|
33298
33354
|
init_react_import();
|
33299
|
-
var
|
33355
|
+
var import_react33 = require("react");
|
33300
33356
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
33301
33357
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
33302
33358
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -33346,8 +33402,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
33346
33402
|
state: { data },
|
33347
33403
|
selectedItem
|
33348
33404
|
} = useAppContext();
|
33349
|
-
const dzContext = (0,
|
33350
|
-
return (0,
|
33405
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
33406
|
+
return (0, import_react33.useMemo)(() => {
|
33351
33407
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
33352
33408
|
selectedItem,
|
33353
33409
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -33399,15 +33455,22 @@ init_react_import();
|
|
33399
33455
|
|
33400
33456
|
// lib/use-puck-history.ts
|
33401
33457
|
init_react_import();
|
33402
|
-
var
|
33458
|
+
var import_react35 = require("react");
|
33403
33459
|
|
33404
33460
|
// lib/use-action-history.ts
|
33405
33461
|
init_react_import();
|
33406
|
-
var
|
33462
|
+
var import_react34 = require("react");
|
33463
|
+
|
33464
|
+
// lib/generate-id.ts
|
33465
|
+
init_react_import();
|
33466
|
+
var import_crypto = require("crypto");
|
33467
|
+
var generateId = (type) => `${type}-${(0, import_crypto.randomBytes)(20).toString("hex")}`;
|
33468
|
+
|
33469
|
+
// lib/use-action-history.ts
|
33407
33470
|
var EMPTY_HISTORY_INDEX = -1;
|
33408
33471
|
function useActionHistory() {
|
33409
|
-
const [histories, setHistories] = (0,
|
33410
|
-
const [currentHistoryIndex, setCurrentHistoryIndex] = (0,
|
33472
|
+
const [histories, setHistories] = (0, import_react34.useState)([]);
|
33473
|
+
const [currentHistoryIndex, setCurrentHistoryIndex] = (0, import_react34.useState)(EMPTY_HISTORY_INDEX);
|
33411
33474
|
const currentHistory = histories[currentHistoryIndex];
|
33412
33475
|
const canRewind = currentHistoryIndex > EMPTY_HISTORY_INDEX;
|
33413
33476
|
const canForward = currentHistoryIndex < histories.length - 1;
|
@@ -33486,7 +33549,7 @@ function usePuckHistory({
|
|
33486
33549
|
dispatch
|
33487
33550
|
});
|
33488
33551
|
}, DEBOUNCE_TIME);
|
33489
|
-
(0,
|
33552
|
+
(0, import_react35.useEffect)(() => {
|
33490
33553
|
historyEmitter.on(RECORD_DIFF, handleRecordDiff);
|
33491
33554
|
return () => {
|
33492
33555
|
historyEmitter.off(RECORD_DIFF, handleRecordDiff);
|
@@ -33812,13 +33875,19 @@ var storeInterceptor = (reducer) => {
|
|
33812
33875
|
return newAppState;
|
33813
33876
|
};
|
33814
33877
|
};
|
33878
|
+
var setAction = (state, action) => {
|
33879
|
+
if (typeof action.state === "object") {
|
33880
|
+
return __spreadValues(__spreadValues({}, state), action.state);
|
33881
|
+
}
|
33882
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
33883
|
+
};
|
33815
33884
|
var createReducer = ({
|
33816
33885
|
config
|
33817
33886
|
}) => storeInterceptor((state, action) => {
|
33818
33887
|
const data = reduceData(state.data, action, config);
|
33819
33888
|
const ui = reduceUi(state.ui, action);
|
33820
33889
|
if (action.type === "set") {
|
33821
|
-
return
|
33890
|
+
return setAction(state, action);
|
33822
33891
|
}
|
33823
33892
|
return { data, ui };
|
33824
33893
|
});
|
@@ -33828,7 +33897,7 @@ init_react_import();
|
|
33828
33897
|
|
33829
33898
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
33830
33899
|
init_react_import();
|
33831
|
-
var styles_module_default11 = { "LayerTree": "
|
33900
|
+
var styles_module_default11 = { "LayerTree": "_LayerTree_o89yt_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_o89yt_11", "LayerTree-helper": "_LayerTree-helper_o89yt_17", "Layer": "_Layer_o89yt_1", "Layer-inner": "_Layer-inner_o89yt_29", "Layer--containsZone": "_Layer--containsZone_o89yt_35", "Layer-clickable": "_Layer-clickable_o89yt_39", "Layer--isSelected": "_Layer--isSelected_o89yt_48", "Layer--isHovering": "_Layer--isHovering_o89yt_49", "Layer-chevron": "_Layer-chevron_o89yt_65", "Layer--childIsSelected": "_Layer--childIsSelected_o89yt_66", "Layer-zones": "_Layer-zones_o89yt_70", "Layer-title": "_Layer-title_o89yt_84", "Layer-name": "_Layer-name_o89yt_93", "Layer-icon": "_Layer-icon_o89yt_99", "Layer-zoneIcon": "_Layer-zoneIcon_o89yt_104" };
|
33832
33901
|
|
33833
33902
|
// lib/scroll-into-view.ts
|
33834
33903
|
init_react_import();
|
@@ -33842,7 +33911,7 @@ var scrollIntoView = (el) => {
|
|
33842
33911
|
};
|
33843
33912
|
|
33844
33913
|
// components/LayerTree/index.tsx
|
33845
|
-
var
|
33914
|
+
var import_react36 = require("react");
|
33846
33915
|
|
33847
33916
|
// lib/find-zones-for-area.ts
|
33848
33917
|
init_react_import();
|
@@ -33880,7 +33949,7 @@ var LayerTree = ({
|
|
33880
33949
|
label
|
33881
33950
|
}) => {
|
33882
33951
|
const zones = data.zones || {};
|
33883
|
-
const ctx = (0,
|
33952
|
+
const ctx = (0, import_react36.useContext)(dropZoneContext);
|
33884
33953
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
33885
33954
|
label && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: getClassName17("zoneTitle"), children: [
|
33886
33955
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName17("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(layers_default, { size: "16" }) }),
|
@@ -33954,7 +34023,7 @@ var LayerTree = ({
|
|
33954
34023
|
),
|
33955
34024
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
33956
34025
|
/* @__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" }) }),
|
33957
|
-
item.type
|
34026
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassNameLayer("name"), children: item.type })
|
33958
34027
|
] })
|
33959
34028
|
]
|
33960
34029
|
}
|
@@ -34005,11 +34074,11 @@ var flushZones = (appState) => {
|
|
34005
34074
|
|
34006
34075
|
// lib/use-component-list.tsx
|
34007
34076
|
init_react_import();
|
34008
|
-
var
|
34077
|
+
var import_react37 = require("react");
|
34009
34078
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
34010
34079
|
var useComponentList = (config, ui) => {
|
34011
|
-
const [componentList, setComponentList] = (0,
|
34012
|
-
(0,
|
34080
|
+
const [componentList, setComponentList] = (0, import_react37.useState)();
|
34081
|
+
(0, import_react37.useEffect)(() => {
|
34013
34082
|
var _a, _b, _c;
|
34014
34083
|
if (Object.keys(ui.componentList).length > 0) {
|
34015
34084
|
const matchedComponents = [];
|
@@ -34075,7 +34144,7 @@ var useComponentList = (config, ui) => {
|
|
34075
34144
|
|
34076
34145
|
// lib/use-resolved-data.ts
|
34077
34146
|
init_react_import();
|
34078
|
-
var
|
34147
|
+
var import_react38 = require("react");
|
34079
34148
|
|
34080
34149
|
// lib/resolve-component-data.ts
|
34081
34150
|
init_react_import();
|
@@ -34189,20 +34258,20 @@ var resolveRootData = (data, config) => __async(void 0, null, function* () {
|
|
34189
34258
|
});
|
34190
34259
|
|
34191
34260
|
// lib/use-resolved-data.ts
|
34192
|
-
var useResolvedData = (
|
34193
|
-
const [{ resolverKey,
|
34261
|
+
var useResolvedData = (appState, config, dispatch) => {
|
34262
|
+
const [{ resolverKey, newAppState }, setResolverState] = (0, import_react38.useState)({
|
34194
34263
|
resolverKey: 0,
|
34195
|
-
|
34264
|
+
newAppState: appState
|
34196
34265
|
});
|
34197
|
-
const [componentState, setComponentState] = (0,
|
34266
|
+
const [componentState, setComponentState] = (0, import_react38.useState)({});
|
34198
34267
|
const deferredSetStates = {};
|
34199
|
-
const setComponentLoading = (0,
|
34268
|
+
const setComponentLoading = (0, import_react38.useCallback)(
|
34200
34269
|
(id, loading, defer = 0) => {
|
34201
34270
|
if (deferredSetStates[id]) {
|
34202
34271
|
clearTimeout(deferredSetStates[id]);
|
34203
34272
|
delete deferredSetStates[id];
|
34204
34273
|
}
|
34205
|
-
|
34274
|
+
deferredSetStates[id] = setTimeout(() => {
|
34206
34275
|
setComponentState((prev) => __spreadProps(__spreadValues({}, prev), {
|
34207
34276
|
[id]: __spreadProps(__spreadValues({}, prev[id]), { loading })
|
34208
34277
|
}));
|
@@ -34212,14 +34281,23 @@ var useResolvedData = (data, config, dispatch) => {
|
|
34212
34281
|
[]
|
34213
34282
|
);
|
34214
34283
|
const runResolvers = () => __async(void 0, null, function* () {
|
34284
|
+
const newData = newAppState.data;
|
34215
34285
|
const flatContent = Object.keys(newData.zones || {}).reduce((acc, zone) => [...acc, ...newData.zones[zone]], newData.content).filter((item) => !!config.components[item.type].resolveData);
|
34216
34286
|
const applyIfChange = (dynamicDataMap, dynamicRoot) => {
|
34217
|
-
const processed = applyDynamicProps(
|
34218
|
-
|
34287
|
+
const processed = applyDynamicProps(
|
34288
|
+
appState.data,
|
34289
|
+
dynamicDataMap,
|
34290
|
+
dynamicRoot
|
34291
|
+
);
|
34292
|
+
const processedAppState = __spreadProps(__spreadValues({}, appState), { data: processed });
|
34293
|
+
const containsChanges = JSON.stringify(appState) !== JSON.stringify(processedAppState);
|
34219
34294
|
if (containsChanges) {
|
34220
34295
|
dispatch({
|
34221
|
-
type: "
|
34222
|
-
|
34296
|
+
type: "set",
|
34297
|
+
state: (prev) => __spreadProps(__spreadValues({}, prev), {
|
34298
|
+
data: applyDynamicProps(prev.data, dynamicDataMap, dynamicRoot),
|
34299
|
+
ui: __spreadValues(__spreadValues({}, prev.ui), newAppState.ui)
|
34300
|
+
}),
|
34223
34301
|
recordHistory: resolverKey > 0
|
34224
34302
|
});
|
34225
34303
|
}
|
@@ -34254,13 +34332,13 @@ var useResolvedData = (data, config, dispatch) => {
|
|
34254
34332
|
});
|
34255
34333
|
yield Promise.all(promises);
|
34256
34334
|
});
|
34257
|
-
(0,
|
34335
|
+
(0, import_react38.useEffect)(() => {
|
34258
34336
|
runResolvers();
|
34259
34337
|
}, [resolverKey]);
|
34260
|
-
const resolveData = (0,
|
34338
|
+
const resolveData = (0, import_react38.useCallback)((newAppState2 = appState) => {
|
34261
34339
|
setResolverState((curr) => ({
|
34262
34340
|
resolverKey: curr.resolverKey + 1,
|
34263
|
-
|
34341
|
+
newAppState: newAppState2
|
34264
34342
|
}));
|
34265
34343
|
}, []);
|
34266
34344
|
return {
|
@@ -34269,8 +34347,86 @@ var useResolvedData = (data, config, dispatch) => {
|
|
34269
34347
|
};
|
34270
34348
|
};
|
34271
34349
|
|
34272
|
-
// components/
|
34350
|
+
// components/MenuBar/index.tsx
|
34351
|
+
init_react_import();
|
34352
|
+
|
34353
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
34354
|
+
init_react_import();
|
34355
|
+
var styles_module_default12 = { "MenuBar": "_MenuBar_12sp7_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_12sp7_14", "MenuBar-inner": "_MenuBar-inner_12sp7_29", "MenuBar-history": "_MenuBar-history_12sp7_45" };
|
34356
|
+
|
34357
|
+
// components/MenuBar/index.tsx
|
34273
34358
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
34359
|
+
var getClassName18 = get_class_name_factory_default("MenuBar", styles_module_default12);
|
34360
|
+
var MenuBar = ({
|
34361
|
+
appState,
|
34362
|
+
data = { content: [], root: { props: { title: "" } } },
|
34363
|
+
dispatch,
|
34364
|
+
menuOpen = false,
|
34365
|
+
onPublish,
|
34366
|
+
renderHeaderActions,
|
34367
|
+
setMenuOpen
|
34368
|
+
}) => {
|
34369
|
+
const { canForward, canRewind, rewind, forward } = usePuckHistory({
|
34370
|
+
appState,
|
34371
|
+
dispatch
|
34372
|
+
});
|
34373
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
34374
|
+
"div",
|
34375
|
+
{
|
34376
|
+
className: getClassName18({ menuOpen }),
|
34377
|
+
onClick: (event) => {
|
34378
|
+
var _a;
|
34379
|
+
const element = event.target;
|
34380
|
+
if (window.matchMedia("(min-width: 638px)").matches) {
|
34381
|
+
return;
|
34382
|
+
}
|
34383
|
+
if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
|
34384
|
+
setMenuOpen(false);
|
34385
|
+
}
|
34386
|
+
},
|
34387
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: getClassName18("inner"), children: [
|
34388
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: getClassName18("history"), children: [
|
34389
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(IconButton, { title: "undo", disabled: !canRewind, onClick: rewind, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
34390
|
+
chevron_left_default,
|
34391
|
+
{
|
34392
|
+
size: 21,
|
34393
|
+
stroke: canRewind ? "var(--puck-color-black)" : "var(--puck-color-grey-7)"
|
34394
|
+
}
|
34395
|
+
) }),
|
34396
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(IconButton, { title: "redo", disabled: !canForward, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
34397
|
+
chevron_right_default,
|
34398
|
+
{
|
34399
|
+
size: 21,
|
34400
|
+
stroke: canForward ? "var(--puck-color-black)" : "var(--puck-color-grey-7)"
|
34401
|
+
}
|
34402
|
+
) })
|
34403
|
+
] }),
|
34404
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: renderHeaderActions && renderHeaderActions({
|
34405
|
+
state: appState,
|
34406
|
+
dispatch
|
34407
|
+
}) }),
|
34408
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
34409
|
+
Button,
|
34410
|
+
{
|
34411
|
+
onClick: () => {
|
34412
|
+
onPublish(data);
|
34413
|
+
},
|
34414
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(globe_default, { size: "14px" }),
|
34415
|
+
children: "Publish"
|
34416
|
+
}
|
34417
|
+
) })
|
34418
|
+
] })
|
34419
|
+
}
|
34420
|
+
);
|
34421
|
+
};
|
34422
|
+
|
34423
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
34424
|
+
init_react_import();
|
34425
|
+
var styles_module_default13 = { "Puck": "_Puck_103k9_19", "Puck--leftSideBarVisible": "_Puck--leftSideBarVisible_103k9_35", "Puck--rightSideBarVisible": "_Puck--rightSideBarVisible_103k9_41", "Puck-header": "_Puck-header_103k9_95", "Puck-headerInner": "_Puck-headerInner_103k9_104", "Puck-headerToggle": "_Puck-headerToggle_103k9_114", "Puck-rightSideBarToggle": "_Puck-rightSideBarToggle_103k9_121", "Puck-leftSideBarToggle": "_Puck-leftSideBarToggle_103k9_126", "Puck-headerTitle": "_Puck-headerTitle_103k9_130", "Puck-headerPath": "_Puck-headerPath_103k9_134", "Puck-headerTools": "_Puck-headerTools_103k9_141", "Puck-menuButton": "_Puck-menuButton_103k9_147", "Puck--menuOpen": "_Puck--menuOpen_103k9_152", "Puck-leftSideBar": "_Puck-leftSideBar_103k9_126", "Puck-frame": "_Puck-frame_103k9_171", "Puck-root": "_Puck-root_103k9_179", "Puck-page": "_Puck-page_103k9_192", "Puck-rightSideBar": "_Puck-rightSideBar_103k9_121" };
|
34426
|
+
|
34427
|
+
// components/Puck/index.tsx
|
34428
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
34429
|
+
var getClassName19 = get_class_name_factory_default("Puck", styles_module_default13);
|
34274
34430
|
var defaultPageFields = {
|
34275
34431
|
title: { type: "text" }
|
34276
34432
|
};
|
@@ -34282,7 +34438,7 @@ var PluginRenderer = ({
|
|
34282
34438
|
renderMethod
|
34283
34439
|
}) => {
|
34284
34440
|
return plugins.filter((item) => item[renderMethod]).map((item) => item[renderMethod]).reduce(
|
34285
|
-
(accChildren, Item) => /* @__PURE__ */ (0,
|
34441
|
+
(accChildren, Item) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Item, { dispatch, state, children: accChildren }),
|
34286
34442
|
children
|
34287
34443
|
);
|
34288
34444
|
};
|
@@ -34299,8 +34455,8 @@ function Puck({
|
|
34299
34455
|
headerPath
|
34300
34456
|
}) {
|
34301
34457
|
var _a, _b;
|
34302
|
-
const [reducer] = (0,
|
34303
|
-
const initialAppState = __spreadProps(__spreadValues({}, defaultAppState), {
|
34458
|
+
const [reducer] = (0, import_react39.useState)(() => createReducer({ config }));
|
34459
|
+
const [initialAppState] = (0, import_react39.useState)(__spreadProps(__spreadValues({}, defaultAppState), {
|
34304
34460
|
data: initialData,
|
34305
34461
|
ui: __spreadProps(__spreadValues({}, defaultAppState.ui), {
|
34306
34462
|
// Store categories under componentList on state to allow render functions and plugins to modify
|
@@ -34318,23 +34474,20 @@ function Puck({
|
|
34318
34474
|
{}
|
34319
34475
|
) : {}
|
34320
34476
|
})
|
34321
|
-
});
|
34322
|
-
const [appState, dispatch] = (0,
|
34477
|
+
}));
|
34478
|
+
const [appState, dispatch] = (0, import_react39.useReducer)(
|
34323
34479
|
reducer,
|
34324
34480
|
flushZones(initialAppState)
|
34325
34481
|
);
|
34326
34482
|
const { data, ui } = appState;
|
34327
34483
|
const { resolveData, componentState } = useResolvedData(
|
34328
|
-
|
34484
|
+
appState,
|
34329
34485
|
config,
|
34330
34486
|
dispatch
|
34331
34487
|
);
|
34332
|
-
const
|
34333
|
-
|
34334
|
-
|
34335
|
-
});
|
34336
|
-
const { itemSelector, leftSideBarVisible } = ui;
|
34337
|
-
const setItemSelector = (0, import_react38.useCallback)(
|
34488
|
+
const [menuOpen, setMenuOpen] = (0, import_react39.useState)(false);
|
34489
|
+
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
34490
|
+
const setItemSelector = (0, import_react39.useCallback)(
|
34338
34491
|
(newItemSelector) => {
|
34339
34492
|
dispatch({
|
34340
34493
|
type: "setUi",
|
@@ -34344,10 +34497,10 @@ function Puck({
|
|
34344
34497
|
[]
|
34345
34498
|
);
|
34346
34499
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
34347
|
-
const Page = (0,
|
34500
|
+
const Page = (0, import_react39.useCallback)(
|
34348
34501
|
(pageProps) => {
|
34349
34502
|
var _a2, _b2;
|
34350
|
-
return /* @__PURE__ */ (0,
|
34503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34351
34504
|
PluginRenderer,
|
34352
34505
|
{
|
34353
34506
|
plugins,
|
@@ -34360,8 +34513,8 @@ function Puck({
|
|
34360
34513
|
},
|
34361
34514
|
[config.root]
|
34362
34515
|
);
|
34363
|
-
const PageFieldWrapper = (0,
|
34364
|
-
(props) => /* @__PURE__ */ (0,
|
34516
|
+
const PageFieldWrapper = (0, import_react39.useCallback)(
|
34517
|
+
(props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34365
34518
|
PluginRenderer,
|
34366
34519
|
{
|
34367
34520
|
plugins,
|
@@ -34373,8 +34526,8 @@ function Puck({
|
|
34373
34526
|
),
|
34374
34527
|
[]
|
34375
34528
|
);
|
34376
|
-
const ComponentFieldWrapper = (0,
|
34377
|
-
(props) => /* @__PURE__ */ (0,
|
34529
|
+
const ComponentFieldWrapper = (0, import_react39.useCallback)(
|
34530
|
+
(props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34378
34531
|
PluginRenderer,
|
34379
34532
|
{
|
34380
34533
|
plugins,
|
@@ -34386,8 +34539,8 @@ function Puck({
|
|
34386
34539
|
),
|
34387
34540
|
[]
|
34388
34541
|
);
|
34389
|
-
const ComponentListWrapper = (0,
|
34390
|
-
const children = /* @__PURE__ */ (0,
|
34542
|
+
const ComponentListWrapper = (0, import_react39.useCallback)((props) => {
|
34543
|
+
const children = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34391
34544
|
PluginRenderer,
|
34392
34545
|
{
|
34393
34546
|
plugins,
|
@@ -34406,27 +34559,64 @@ function Puck({
|
|
34406
34559
|
const FieldWrapper = itemSelector ? ComponentFieldWrapper : PageFieldWrapper;
|
34407
34560
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
34408
34561
|
let fields = selectedItem ? ((_b = config.components[selectedItem.type]) == null ? void 0 : _b.fields) || {} : rootFields;
|
34409
|
-
(0,
|
34562
|
+
(0, import_react39.useEffect)(() => {
|
34410
34563
|
if (onChange)
|
34411
34564
|
onChange(data);
|
34412
34565
|
}, [data]);
|
34413
34566
|
const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
|
34414
|
-
const [draggedItem, setDraggedItem] = (0,
|
34567
|
+
const [draggedItem, setDraggedItem] = (0, import_react39.useState)();
|
34415
34568
|
const componentList = useComponentList(config, appState.ui);
|
34416
34569
|
const rootProps = data.root.props || data.root;
|
34417
|
-
(0,
|
34570
|
+
(0, import_react39.useEffect)(() => {
|
34418
34571
|
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
34419
34572
|
console.error(
|
34420
34573
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`. This will be a breaking change in a future release."
|
34421
34574
|
);
|
34422
34575
|
}
|
34423
34576
|
}, []);
|
34424
|
-
|
34425
|
-
|
34577
|
+
const toggleSidebars = (0, import_react39.useCallback)(
|
34578
|
+
(sidebar) => {
|
34579
|
+
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
34580
|
+
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
34581
|
+
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
34582
|
+
dispatch({
|
34583
|
+
type: "setUi",
|
34584
|
+
ui: __spreadValues({
|
34585
|
+
[`${sidebar}SideBarVisible`]: !sideBarVisible
|
34586
|
+
}, !widerViewport ? { [oppositeSideBar]: false } : {})
|
34587
|
+
});
|
34588
|
+
},
|
34589
|
+
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
34590
|
+
);
|
34591
|
+
(0, import_react39.useEffect)(() => {
|
34592
|
+
if (!window.matchMedia("(min-width: 638px)").matches) {
|
34593
|
+
dispatch({
|
34594
|
+
type: "setUi",
|
34595
|
+
ui: {
|
34596
|
+
leftSideBarVisible: false,
|
34597
|
+
rightSideBarVisible: false
|
34598
|
+
}
|
34599
|
+
});
|
34600
|
+
}
|
34601
|
+
const handleResize = () => {
|
34602
|
+
if (!window.matchMedia("(min-width: 638px)").matches) {
|
34603
|
+
dispatch({
|
34604
|
+
type: "setUi",
|
34605
|
+
ui: (ui2) => __spreadValues(__spreadValues({}, ui2), ui2.rightSideBarVisible ? { leftSideBarVisible: false } : {})
|
34606
|
+
});
|
34607
|
+
}
|
34608
|
+
};
|
34609
|
+
window.addEventListener("resize", handleResize);
|
34610
|
+
return () => {
|
34611
|
+
window.removeEventListener("resize", handleResize);
|
34612
|
+
};
|
34613
|
+
}, []);
|
34614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { children: [
|
34615
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34426
34616
|
AppProvider,
|
34427
34617
|
{
|
34428
34618
|
value: { state: appState, dispatch, config, componentState },
|
34429
|
-
children: /* @__PURE__ */ (0,
|
34619
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34430
34620
|
import_dnd7.DragDropContext,
|
34431
34621
|
{
|
34432
34622
|
onDragUpdate: (update) => {
|
@@ -34479,7 +34669,7 @@ function Puck({
|
|
34479
34669
|
});
|
34480
34670
|
}
|
34481
34671
|
},
|
34482
|
-
children: /* @__PURE__ */ (0,
|
34672
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34483
34673
|
DropZoneProvider,
|
34484
34674
|
{
|
34485
34675
|
value: {
|
@@ -34493,248 +34683,133 @@ function Puck({
|
|
34493
34683
|
mode: "edit",
|
34494
34684
|
areaId: "root"
|
34495
34685
|
},
|
34496
|
-
children: /* @__PURE__ */ (0,
|
34686
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(dropZoneContext.Consumer, { children: (ctx) => {
|
34497
34687
|
var _a2, _b2;
|
34498
|
-
return /* @__PURE__ */ (0,
|
34688
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
34499
34689
|
"div",
|
34500
34690
|
{
|
34501
|
-
|
34502
|
-
|
34503
|
-
|
34504
|
-
|
34505
|
-
|
34506
|
-
height: "100vh",
|
34507
|
-
position: "fixed",
|
34508
|
-
top: 0,
|
34509
|
-
bottom: 0,
|
34510
|
-
left: 0,
|
34511
|
-
right: 0
|
34512
|
-
},
|
34691
|
+
className: getClassName19({
|
34692
|
+
leftSideBarVisible,
|
34693
|
+
menuOpen,
|
34694
|
+
rightSideBarVisible
|
34695
|
+
}),
|
34513
34696
|
children: [
|
34514
|
-
/* @__PURE__ */ (0,
|
34515
|
-
|
34516
|
-
|
34517
|
-
|
34518
|
-
|
34519
|
-
|
34520
|
-
|
34521
|
-
|
34522
|
-
|
34523
|
-
|
34524
|
-
|
34525
|
-
|
34526
|
-
|
34527
|
-
|
34528
|
-
|
34529
|
-
|
34530
|
-
|
34531
|
-
children: "Publish"
|
34532
|
-
}
|
34533
|
-
),
|
34534
|
-
dispatch,
|
34535
|
-
state: appState
|
34536
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
34537
|
-
"div",
|
34697
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("header", { className: getClassName19("header"), children: renderHeader ? renderHeader({
|
34698
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34699
|
+
Button,
|
34700
|
+
{
|
34701
|
+
onClick: () => {
|
34702
|
+
onPublish(data);
|
34703
|
+
},
|
34704
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(globe_default, { size: "14px" }),
|
34705
|
+
children: "Publish"
|
34706
|
+
}
|
34707
|
+
),
|
34708
|
+
dispatch,
|
34709
|
+
state: appState
|
34710
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: getClassName19("headerInner"), children: [
|
34711
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: getClassName19("headerToggle"), children: [
|
34712
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34713
|
+
IconButton,
|
34538
34714
|
{
|
34539
|
-
|
34540
|
-
|
34541
|
-
padding: 16,
|
34542
|
-
gridTemplateAreas: '"left middle right"',
|
34543
|
-
gridTemplateColumns: "344px auto 344px",
|
34544
|
-
gridTemplateRows: "auto"
|
34715
|
+
onClick: () => {
|
34716
|
+
toggleSidebars("left");
|
34545
34717
|
},
|
34546
|
-
|
34547
|
-
|
34548
|
-
|
34549
|
-
|
34550
|
-
|
34551
|
-
|
34552
|
-
|
34553
|
-
|
34554
|
-
|
34555
|
-
|
34556
|
-
|
34557
|
-
|
34558
|
-
|
34559
|
-
|
34560
|
-
|
34561
|
-
|
34562
|
-
|
34563
|
-
|
34564
|
-
|
34565
|
-
|
34566
|
-
|
34567
|
-
|
34568
|
-
|
34569
|
-
|
34570
|
-
|
34571
|
-
|
34572
|
-
|
34573
|
-
|
34574
|
-
|
34575
|
-
|
34576
|
-
|
34577
|
-
|
34578
|
-
|
34579
|
-
|
34580
|
-
|
34581
|
-
|
34582
|
-
|
34583
|
-
|
34584
|
-
|
34585
|
-
|
34586
|
-
|
34587
|
-
|
34588
|
-
|
34589
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
34590
|
-
"div",
|
34591
|
-
{
|
34592
|
-
style: {
|
34593
|
-
display: "flex",
|
34594
|
-
gap: 16,
|
34595
|
-
justifyContent: "flex-end"
|
34596
|
-
},
|
34597
|
-
children: [
|
34598
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { display: "flex" }, children: [
|
34599
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
34600
|
-
IconButton,
|
34601
|
-
{
|
34602
|
-
title: "undo",
|
34603
|
-
disabled: !canRewind,
|
34604
|
-
onClick: rewind,
|
34605
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
34606
|
-
chevron_left_default,
|
34607
|
-
{
|
34608
|
-
size: 21,
|
34609
|
-
stroke: canRewind ? "var(--puck-color-black)" : "var(--puck-color-grey-7)"
|
34610
|
-
}
|
34611
|
-
)
|
34612
|
-
}
|
34613
|
-
),
|
34614
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
34615
|
-
IconButton,
|
34616
|
-
{
|
34617
|
-
title: "redo",
|
34618
|
-
disabled: !canForward,
|
34619
|
-
onClick: forward,
|
34620
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
34621
|
-
chevron_right_default,
|
34622
|
-
{
|
34623
|
-
size: 21,
|
34624
|
-
stroke: canForward ? "var(--puck-color-black)" : "var(--puck-color-grey-7)"
|
34625
|
-
}
|
34626
|
-
)
|
34627
|
-
}
|
34628
|
-
)
|
34629
|
-
] }),
|
34630
|
-
renderHeaderActions && renderHeaderActions({
|
34631
|
-
state: appState,
|
34632
|
-
dispatch
|
34633
|
-
}),
|
34634
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
34635
|
-
Button,
|
34636
|
-
{
|
34637
|
-
onClick: () => {
|
34638
|
-
onPublish(data);
|
34639
|
-
},
|
34640
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(globe_default, { size: "14px" }),
|
34641
|
-
children: "Publish"
|
34642
|
-
}
|
34643
|
-
)
|
34644
|
-
]
|
34645
|
-
}
|
34646
|
-
)
|
34647
|
-
]
|
34718
|
+
title: "Toggle left sidebar",
|
34719
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(sidebar_default, { focusable: "false" })
|
34720
|
+
}
|
34721
|
+
) }),
|
34722
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34723
|
+
IconButton,
|
34724
|
+
{
|
34725
|
+
onClick: () => {
|
34726
|
+
toggleSidebars("right");
|
34727
|
+
},
|
34728
|
+
title: "Toggle right sidebar",
|
34729
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(sidebar_default, { focusable: "false" })
|
34730
|
+
}
|
34731
|
+
) })
|
34732
|
+
] }),
|
34733
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Heading, { rank: 2, size: "xs", children: [
|
34734
|
+
headerTitle || rootProps.title || "Page",
|
34735
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
34736
|
+
" ",
|
34737
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("code", { className: getClassName19("headerPath"), children: headerPath })
|
34738
|
+
] })
|
34739
|
+
] }) }),
|
34740
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: getClassName19("headerTools"), children: [
|
34741
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34742
|
+
IconButton,
|
34743
|
+
{
|
34744
|
+
onClick: () => {
|
34745
|
+
return setMenuOpen(!menuOpen);
|
34746
|
+
},
|
34747
|
+
title: "Toggle menu bar",
|
34748
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(chevron_up_default, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(chevron_down_default, { focusable: "false" })
|
34749
|
+
}
|
34750
|
+
) }),
|
34751
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34752
|
+
MenuBar,
|
34753
|
+
{
|
34754
|
+
appState,
|
34755
|
+
data,
|
34756
|
+
dispatch,
|
34757
|
+
onPublish,
|
34758
|
+
menuOpen,
|
34759
|
+
renderHeaderActions,
|
34760
|
+
setMenuOpen
|
34648
34761
|
}
|
34649
34762
|
)
|
34650
|
-
}
|
34651
|
-
),
|
34652
|
-
/* @__PURE__ */ (0,
|
34653
|
-
"
|
34654
|
-
{
|
34655
|
-
|
34656
|
-
|
34657
|
-
|
34658
|
-
|
34659
|
-
|
34660
|
-
|
34661
|
-
|
34662
|
-
|
34663
|
-
|
34664
|
-
|
34665
|
-
|
34666
|
-
|
34763
|
+
] })
|
34764
|
+
] }) }),
|
34765
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: getClassName19("leftSideBar"), children: [
|
34766
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SidebarSection, { title: "Components", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ComponentListWrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ComponentList, { id: "all" }) }) }),
|
34767
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(SidebarSection, { title: "Outline", children: [
|
34768
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34769
|
+
LayerTree,
|
34770
|
+
{
|
34771
|
+
data,
|
34772
|
+
label: areaContainsZones(data, "root") ? rootDroppableId : "",
|
34773
|
+
zoneContent: data.content,
|
34774
|
+
setItemSelector,
|
34775
|
+
itemSelector
|
34776
|
+
}
|
34777
|
+
),
|
34778
|
+
Object.entries(findZonesForArea(data, "root")).map(
|
34779
|
+
([zoneKey, zone]) => {
|
34780
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34667
34781
|
LayerTree,
|
34668
34782
|
{
|
34669
34783
|
data,
|
34670
|
-
label:
|
34671
|
-
|
34784
|
+
label: zoneKey,
|
34785
|
+
zone: zoneKey,
|
34786
|
+
zoneContent: zone,
|
34672
34787
|
setItemSelector,
|
34673
34788
|
itemSelector
|
34674
|
-
}
|
34675
|
-
|
34676
|
-
|
34677
|
-
|
34678
|
-
|
34679
|
-
|
34680
|
-
|
34681
|
-
|
34682
|
-
label: zoneKey,
|
34683
|
-
zone: zoneKey,
|
34684
|
-
zoneContent: zone,
|
34685
|
-
setItemSelector,
|
34686
|
-
itemSelector
|
34687
|
-
},
|
34688
|
-
zoneKey
|
34689
|
-
);
|
34690
|
-
}
|
34691
|
-
)
|
34692
|
-
] })
|
34693
|
-
]
|
34694
|
-
}
|
34695
|
-
),
|
34696
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
34789
|
+
},
|
34790
|
+
zoneKey
|
34791
|
+
);
|
34792
|
+
}
|
34793
|
+
)
|
34794
|
+
] })
|
34795
|
+
] }),
|
34796
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
34697
34797
|
"div",
|
34698
34798
|
{
|
34699
|
-
|
34700
|
-
overflowY: "auto",
|
34701
|
-
gridArea: "editor",
|
34702
|
-
position: "relative",
|
34703
|
-
display: "flex",
|
34704
|
-
flexDirection: "column"
|
34705
|
-
},
|
34799
|
+
className: getClassName19("frame"),
|
34706
34800
|
onClick: () => setItemSelector(null),
|
34707
34801
|
id: "puck-frame",
|
34708
34802
|
children: [
|
34709
|
-
/* @__PURE__ */ (0,
|
34710
|
-
|
34711
|
-
{
|
34712
|
-
|
34713
|
-
|
34714
|
-
|
34715
|
-
|
34716
|
-
|
34717
|
-
|
34718
|
-
|
34719
|
-
"div",
|
34720
|
-
{
|
34721
|
-
style: {
|
34722
|
-
border: "1px solid var(--puck-color-grey-8)"
|
34723
|
-
},
|
34724
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
34725
|
-
Page,
|
34726
|
-
__spreadProps(__spreadValues({
|
34727
|
-
dispatch,
|
34728
|
-
state: appState
|
34729
|
-
}, data.root), {
|
34730
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, { zone: rootDroppableId })
|
34731
|
-
})
|
34732
|
-
)
|
34733
|
-
}
|
34734
|
-
)
|
34735
|
-
}
|
34736
|
-
),
|
34737
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
34803
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("root"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("page"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34804
|
+
Page,
|
34805
|
+
__spreadProps(__spreadValues({
|
34806
|
+
dispatch,
|
34807
|
+
state: appState
|
34808
|
+
}, rootProps), {
|
34809
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZone, { zone: rootDroppableId })
|
34810
|
+
})
|
34811
|
+
) }) }),
|
34812
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34738
34813
|
"div",
|
34739
34814
|
{
|
34740
34815
|
style: {
|
@@ -34747,106 +34822,118 @@ function Puck({
|
|
34747
34822
|
]
|
34748
34823
|
}
|
34749
34824
|
),
|
34750
|
-
/* @__PURE__ */ (0,
|
34751
|
-
|
34825
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(FieldWrapper, { dispatch, state: appState, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34826
|
+
SidebarSection,
|
34752
34827
|
{
|
34753
|
-
|
34754
|
-
|
34755
|
-
|
34756
|
-
|
34757
|
-
|
34758
|
-
|
34759
|
-
|
34760
|
-
|
34761
|
-
|
34762
|
-
|
34763
|
-
|
34764
|
-
|
34765
|
-
|
34766
|
-
|
34767
|
-
|
34768
|
-
|
34769
|
-
|
34770
|
-
|
34771
|
-
const
|
34772
|
-
|
34773
|
-
|
34774
|
-
|
34775
|
-
|
34776
|
-
|
34777
|
-
|
34778
|
-
|
34779
|
-
|
34780
|
-
|
34781
|
-
|
34782
|
-
|
34783
|
-
|
34784
|
-
|
34785
|
-
|
34786
|
-
destinationZone: itemSelector.zone || rootDroppableId,
|
34787
|
-
data: __spreadProps(__spreadValues({}, selectedItem), { props: newProps })
|
34788
|
-
};
|
34789
|
-
if ((_a3 = config.components[selectedItem.type]) == null ? void 0 : _a3.resolveData) {
|
34790
|
-
resolveData(replaceAction(data, action));
|
34791
|
-
} else {
|
34792
|
-
dispatch(action);
|
34793
|
-
}
|
34794
|
-
} else {
|
34795
|
-
if (data.root.props) {
|
34796
|
-
if ((_b3 = config.root) == null ? void 0 : _b3.resolveData) {
|
34797
|
-
resolveData(__spreadProps(__spreadValues({}, data), {
|
34798
|
-
root: { props: { newProps } }
|
34799
|
-
}));
|
34800
|
-
} else {
|
34801
|
-
dispatch({
|
34802
|
-
type: "setData",
|
34803
|
-
data: { root: { props: { newProps } } }
|
34804
|
-
});
|
34805
|
-
}
|
34806
|
-
} else {
|
34807
|
-
dispatch({
|
34808
|
-
type: "setData",
|
34809
|
-
data: { root: newProps }
|
34810
|
-
});
|
34811
|
-
}
|
34828
|
+
noPadding: true,
|
34829
|
+
showBreadcrumbs: true,
|
34830
|
+
title: selectedItem ? selectedItem.type : "Page",
|
34831
|
+
isLoading: selectedItem ? (_a2 = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a2.loading : (_b2 = componentState["puck-root"]) == null ? void 0 : _b2.loading,
|
34832
|
+
children: Object.keys(fields).map((fieldName) => {
|
34833
|
+
const field = fields[fieldName];
|
34834
|
+
const onChange2 = (value, updatedUi) => {
|
34835
|
+
var _a3, _b3;
|
34836
|
+
let currentProps;
|
34837
|
+
if (selectedItem) {
|
34838
|
+
currentProps = selectedItem.props;
|
34839
|
+
} else {
|
34840
|
+
currentProps = rootProps;
|
34841
|
+
}
|
34842
|
+
const newProps = __spreadProps(__spreadValues({}, currentProps), {
|
34843
|
+
[fieldName]: value
|
34844
|
+
});
|
34845
|
+
if (itemSelector) {
|
34846
|
+
const replaceActionData = {
|
34847
|
+
type: "replace",
|
34848
|
+
destinationIndex: itemSelector.index,
|
34849
|
+
destinationZone: itemSelector.zone || rootDroppableId,
|
34850
|
+
data: __spreadProps(__spreadValues({}, selectedItem), { props: newProps })
|
34851
|
+
};
|
34852
|
+
const replacedData = replaceAction(
|
34853
|
+
data,
|
34854
|
+
replaceActionData
|
34855
|
+
);
|
34856
|
+
const setActionData = {
|
34857
|
+
type: "set",
|
34858
|
+
state: {
|
34859
|
+
data: __spreadValues(__spreadValues({}, data), replacedData),
|
34860
|
+
ui: __spreadValues(__spreadValues({}, ui), updatedUi)
|
34812
34861
|
}
|
34813
34862
|
};
|
34814
|
-
if (selectedItem
|
34815
|
-
|
34816
|
-
|
34817
|
-
InputOrGroup,
|
34818
|
-
{
|
34819
|
-
field,
|
34820
|
-
name: fieldName,
|
34821
|
-
label: field.label,
|
34822
|
-
readOnly: readOnly[fieldName],
|
34823
|
-
readOnlyFields: readOnly,
|
34824
|
-
value: selectedItem.props[fieldName],
|
34825
|
-
onChange: onChange2
|
34826
|
-
},
|
34827
|
-
`${selectedItem.props.id}_${fieldName}`
|
34863
|
+
if ((_a3 = config.components[selectedItem.type]) == null ? void 0 : _a3.resolveData) {
|
34864
|
+
resolveData(
|
34865
|
+
setAction(appState, setActionData)
|
34828
34866
|
);
|
34829
34867
|
} else {
|
34830
|
-
|
34831
|
-
|
34832
|
-
|
34833
|
-
{
|
34834
|
-
field,
|
34835
|
-
name: fieldName,
|
34836
|
-
label: field.label,
|
34837
|
-
readOnly: readOnly[fieldName],
|
34838
|
-
readOnlyFields: readOnly,
|
34839
|
-
value: rootProps[fieldName],
|
34840
|
-
onChange: onChange2
|
34841
|
-
},
|
34842
|
-
`page_${fieldName}`
|
34843
|
-
);
|
34868
|
+
dispatch(__spreadProps(__spreadValues({}, setActionData), {
|
34869
|
+
recordHistory: true
|
34870
|
+
}));
|
34844
34871
|
}
|
34845
|
-
}
|
34872
|
+
} else {
|
34873
|
+
if (data.root.props) {
|
34874
|
+
if ((_b3 = config.root) == null ? void 0 : _b3.resolveData) {
|
34875
|
+
resolveData({
|
34876
|
+
ui: __spreadValues(__spreadValues({}, ui), updatedUi),
|
34877
|
+
data: __spreadProps(__spreadValues({}, data), {
|
34878
|
+
root: { props: newProps }
|
34879
|
+
})
|
34880
|
+
});
|
34881
|
+
} else {
|
34882
|
+
dispatch({
|
34883
|
+
type: "set",
|
34884
|
+
state: {
|
34885
|
+
ui: __spreadValues(__spreadValues({}, ui), updatedUi),
|
34886
|
+
data: __spreadProps(__spreadValues({}, data), {
|
34887
|
+
root: { props: newProps }
|
34888
|
+
})
|
34889
|
+
},
|
34890
|
+
recordHistory: true
|
34891
|
+
});
|
34892
|
+
}
|
34893
|
+
} else {
|
34894
|
+
dispatch({
|
34895
|
+
type: "setData",
|
34896
|
+
data: { root: newProps }
|
34897
|
+
});
|
34898
|
+
}
|
34899
|
+
}
|
34900
|
+
};
|
34901
|
+
if (selectedItem && itemSelector) {
|
34902
|
+
const { readOnly = {} } = selectedItem;
|
34903
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34904
|
+
InputOrGroup,
|
34905
|
+
{
|
34906
|
+
field,
|
34907
|
+
name: fieldName,
|
34908
|
+
id: `${selectedItem.props.id}_${fieldName}`,
|
34909
|
+
label: field.label,
|
34910
|
+
readOnly: readOnly[fieldName],
|
34911
|
+
readOnlyFields: readOnly,
|
34912
|
+
value: selectedItem.props[fieldName],
|
34913
|
+
onChange: onChange2
|
34914
|
+
},
|
34915
|
+
`${selectedItem.props.id}_${fieldName}`
|
34916
|
+
);
|
34917
|
+
} else {
|
34918
|
+
const { readOnly = {} } = data.root;
|
34919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
34920
|
+
InputOrGroup,
|
34921
|
+
{
|
34922
|
+
field,
|
34923
|
+
name: fieldName,
|
34924
|
+
id: `root_${fieldName}`,
|
34925
|
+
label: field.label,
|
34926
|
+
readOnly: readOnly[fieldName],
|
34927
|
+
readOnlyFields: readOnly,
|
34928
|
+
value: rootProps[fieldName],
|
34929
|
+
onChange: onChange2
|
34930
|
+
},
|
34931
|
+
`page_${fieldName}`
|
34932
|
+
);
|
34846
34933
|
}
|
34847
|
-
|
34934
|
+
})
|
34848
34935
|
}
|
34849
|
-
)
|
34936
|
+
) }) })
|
34850
34937
|
]
|
34851
34938
|
}
|
34852
34939
|
);
|
@@ -34857,19 +34944,19 @@ function Puck({
|
|
34857
34944
|
)
|
34858
34945
|
}
|
34859
34946
|
),
|
34860
|
-
/* @__PURE__ */ (0,
|
34947
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id: "puck-portal-root" })
|
34861
34948
|
] });
|
34862
34949
|
}
|
34863
34950
|
|
34864
34951
|
// components/Render/index.tsx
|
34865
34952
|
init_react_import();
|
34866
|
-
var
|
34953
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
34867
34954
|
function Render({ config, data }) {
|
34868
34955
|
var _a;
|
34869
34956
|
const rootProps = data.root.props || data.root;
|
34870
34957
|
const title = rootProps.title || "";
|
34871
34958
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
34872
|
-
return /* @__PURE__ */ (0,
|
34959
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
34873
34960
|
config.root.render,
|
34874
34961
|
__spreadProps(__spreadValues({}, rootProps), {
|
34875
34962
|
puck: {
|
@@ -34878,11 +34965,11 @@ function Render({ config, data }) {
|
|
34878
34965
|
title,
|
34879
34966
|
editMode: false,
|
34880
34967
|
id: "puck-root",
|
34881
|
-
children: /* @__PURE__ */ (0,
|
34968
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZone, { zone: rootDroppableId })
|
34882
34969
|
})
|
34883
34970
|
) });
|
34884
34971
|
}
|
34885
|
-
return /* @__PURE__ */ (0,
|
34972
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZone, { zone: rootDroppableId }) });
|
34886
34973
|
}
|
34887
34974
|
|
34888
34975
|
// lib/resolve-all-data.ts
|