@measured/puck 0.20.0-canary.6cf56a8a → 0.20.0-canary.6dace1cf
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/{chunk-DBSNJT3R.mjs → chunk-4KAREQPB.mjs} +79 -111
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +260 -292
- package/dist/index.mjs +1 -1
- package/dist/no-external.d.mts +1 -1
- package/dist/no-external.d.ts +1 -1
- package/dist/no-external.js +260 -292
- package/dist/no-external.mjs +1 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/{walk-tree-Bp8tnkJS.d.mts → walk-tree-DrNRq2FV.d.mts} +1 -1
- package/dist/{walk-tree-Bp8tnkJS.d.ts → walk-tree-DrNRq2FV.d.ts} +1 -1
- package/package.json +1 -1
package/dist/no-external.js
CHANGED
|
@@ -309,7 +309,7 @@ init_react_import();
|
|
|
309
309
|
var styles_module_default2 = { "InputWrapper": "_InputWrapper_py9hf_1", "Input-label": "_Input-label_py9hf_5", "Input-labelIcon": "_Input-labelIcon_py9hf_14", "Input-disabledIcon": "_Input-disabledIcon_py9hf_21", "Input-input": "_Input-input_py9hf_26", "Input": "_Input_py9hf_1", "Input--readOnly": "_Input--readOnly_py9hf_76", "Input-radioGroupItems": "_Input-radioGroupItems_py9hf_87", "Input-radio": "_Input-radio_py9hf_87", "Input-radioInner": "_Input-radioInner_py9hf_104", "Input-radioInput": "_Input-radioInput_py9hf_149" };
|
|
310
310
|
|
|
311
311
|
// components/AutoField/index.tsx
|
|
312
|
-
var
|
|
312
|
+
var import_react20 = require("react");
|
|
313
313
|
|
|
314
314
|
// components/AutoField/fields/index.tsx
|
|
315
315
|
init_react_import();
|
|
@@ -3802,20 +3802,6 @@ var ExternalField = ({
|
|
|
3802
3802
|
|
|
3803
3803
|
// components/AutoField/fields/RadioField/index.tsx
|
|
3804
3804
|
init_react_import();
|
|
3805
|
-
var import_react19 = require("react");
|
|
3806
|
-
|
|
3807
|
-
// lib/safe-json-parse.ts
|
|
3808
|
-
init_react_import();
|
|
3809
|
-
var safeJsonParse = (str) => {
|
|
3810
|
-
try {
|
|
3811
|
-
const jsonValue = JSON.parse(str);
|
|
3812
|
-
return jsonValue;
|
|
3813
|
-
} catch (e) {
|
|
3814
|
-
return str;
|
|
3815
|
-
}
|
|
3816
|
-
};
|
|
3817
|
-
|
|
3818
|
-
// components/AutoField/fields/RadioField/index.tsx
|
|
3819
3805
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3820
3806
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
|
3821
3807
|
var RadioField = ({
|
|
@@ -3829,10 +3815,6 @@ var RadioField = ({
|
|
|
3829
3815
|
labelIcon,
|
|
3830
3816
|
Label: Label2
|
|
3831
3817
|
}) => {
|
|
3832
|
-
const flatOptions = (0, import_react19.useMemo)(
|
|
3833
|
-
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
3834
|
-
[field]
|
|
3835
|
-
);
|
|
3836
3818
|
if (field.type !== "radio" || !field.options) {
|
|
3837
3819
|
return null;
|
|
3838
3820
|
}
|
|
@@ -3843,43 +3825,39 @@ var RadioField = ({
|
|
|
3843
3825
|
label: label || name,
|
|
3844
3826
|
readOnly,
|
|
3845
3827
|
el: "div",
|
|
3846
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) =>
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
},
|
|
3874
|
-
option.label + option.value
|
|
3875
|
-
)) })
|
|
3828
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => {
|
|
3829
|
+
var _a;
|
|
3830
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
3831
|
+
"label",
|
|
3832
|
+
{
|
|
3833
|
+
className: getClassName11("radio"),
|
|
3834
|
+
children: [
|
|
3835
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3836
|
+
"input",
|
|
3837
|
+
{
|
|
3838
|
+
type: "radio",
|
|
3839
|
+
className: getClassName11("radioInput"),
|
|
3840
|
+
value: JSON.stringify({ value: option.value }),
|
|
3841
|
+
name,
|
|
3842
|
+
onChange: (e) => {
|
|
3843
|
+
onChange(JSON.parse(e.target.value).value);
|
|
3844
|
+
},
|
|
3845
|
+
disabled: readOnly,
|
|
3846
|
+
checked: value === option.value
|
|
3847
|
+
}
|
|
3848
|
+
),
|
|
3849
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioInner"), children: option.label || ((_a = option.value) == null ? void 0 : _a.toString()) })
|
|
3850
|
+
]
|
|
3851
|
+
},
|
|
3852
|
+
option.label + option.value
|
|
3853
|
+
);
|
|
3854
|
+
}) })
|
|
3876
3855
|
}
|
|
3877
3856
|
);
|
|
3878
3857
|
};
|
|
3879
3858
|
|
|
3880
3859
|
// components/AutoField/fields/SelectField/index.tsx
|
|
3881
3860
|
init_react_import();
|
|
3882
|
-
var import_react20 = require("react");
|
|
3883
3861
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3884
3862
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
|
3885
3863
|
var SelectField = ({
|
|
@@ -3893,10 +3871,6 @@ var SelectField = ({
|
|
|
3893
3871
|
readOnly,
|
|
3894
3872
|
id
|
|
3895
3873
|
}) => {
|
|
3896
|
-
const flatOptions = (0, import_react20.useMemo)(
|
|
3897
|
-
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
3898
|
-
[field]
|
|
3899
|
-
);
|
|
3900
3874
|
if (field.type !== "select" || !field.options) {
|
|
3901
3875
|
return null;
|
|
3902
3876
|
}
|
|
@@ -3914,22 +3888,16 @@ var SelectField = ({
|
|
|
3914
3888
|
className: getClassName12("input"),
|
|
3915
3889
|
disabled: readOnly,
|
|
3916
3890
|
onChange: (e) => {
|
|
3917
|
-
|
|
3918
|
-
const jsonValue = (_a = safeJsonParse(e.target.value)) != null ? _a : e.target.value;
|
|
3919
|
-
if (flatOptions.indexOf(jsonValue) > -1) {
|
|
3920
|
-
onChange(jsonValue);
|
|
3921
|
-
} else {
|
|
3922
|
-
onChange(e.target.value);
|
|
3923
|
-
}
|
|
3891
|
+
onChange(JSON.parse(e.target.value).value);
|
|
3924
3892
|
},
|
|
3925
|
-
value,
|
|
3893
|
+
value: JSON.stringify({ value }),
|
|
3926
3894
|
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3927
3895
|
"option",
|
|
3928
3896
|
{
|
|
3929
3897
|
label: option.label,
|
|
3930
|
-
value: option.value
|
|
3898
|
+
value: JSON.stringify({ value: option.value })
|
|
3931
3899
|
},
|
|
3932
|
-
option.label + option.value
|
|
3900
|
+
option.label + JSON.stringify(option.value)
|
|
3933
3901
|
))
|
|
3934
3902
|
}
|
|
3935
3903
|
)
|
|
@@ -4053,12 +4021,12 @@ var ObjectField = ({
|
|
|
4053
4021
|
|
|
4054
4022
|
// lib/use-safe-id.ts
|
|
4055
4023
|
init_react_import();
|
|
4056
|
-
var
|
|
4024
|
+
var import_react19 = __toESM(require("react"));
|
|
4057
4025
|
var useSafeId = () => {
|
|
4058
|
-
if (typeof
|
|
4059
|
-
return
|
|
4026
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
|
4027
|
+
return import_react19.default.useId();
|
|
4060
4028
|
}
|
|
4061
|
-
const [id] = (0,
|
|
4029
|
+
const [id] = (0, import_react19.useState)(generateId());
|
|
4062
4030
|
return id;
|
|
4063
4031
|
};
|
|
4064
4032
|
|
|
@@ -4092,7 +4060,7 @@ var FieldLabelInternal = ({
|
|
|
4092
4060
|
readOnly
|
|
4093
4061
|
}) => {
|
|
4094
4062
|
const overrides = useAppStore((s) => s.overrides);
|
|
4095
|
-
const Wrapper = (0,
|
|
4063
|
+
const Wrapper = (0, import_react20.useMemo)(
|
|
4096
4064
|
() => overrides.fieldLabel || FieldLabel,
|
|
4097
4065
|
[overrides]
|
|
4098
4066
|
);
|
|
@@ -4119,7 +4087,7 @@ function AutoFieldInternal(props) {
|
|
|
4119
4087
|
var _a2;
|
|
4120
4088
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
|
4121
4089
|
});
|
|
4122
|
-
const nestedFieldContext = (0,
|
|
4090
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
|
4123
4091
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
|
4124
4092
|
const field = props.field;
|
|
4125
4093
|
const label = field.label;
|
|
@@ -4153,7 +4121,7 @@ function AutoFieldInternal(props) {
|
|
|
4153
4121
|
Label: Label2,
|
|
4154
4122
|
id: resolvedId
|
|
4155
4123
|
});
|
|
4156
|
-
const onFocus = (0,
|
|
4124
|
+
const onFocus = (0, import_react20.useCallback)(
|
|
4157
4125
|
(e) => {
|
|
4158
4126
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
4159
4127
|
e.stopPropagation();
|
|
@@ -4167,7 +4135,7 @@ function AutoFieldInternal(props) {
|
|
|
4167
4135
|
},
|
|
4168
4136
|
[mergedProps.name]
|
|
4169
4137
|
);
|
|
4170
|
-
const onBlur = (0,
|
|
4138
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
|
4171
4139
|
if ("name" in e.target) {
|
|
4172
4140
|
dispatch({
|
|
4173
4141
|
type: "setUi",
|
|
@@ -4220,20 +4188,20 @@ function AutoFieldInternal(props) {
|
|
|
4220
4188
|
function AutoFieldPrivate(props) {
|
|
4221
4189
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
|
4222
4190
|
const { value, onChange } = props;
|
|
4223
|
-
const [localValue, setLocalValue] = (0,
|
|
4224
|
-
const onChangeLocal = (0,
|
|
4191
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
|
4192
|
+
const onChangeLocal = (0, import_react20.useCallback)(
|
|
4225
4193
|
(val, ui) => {
|
|
4226
4194
|
setLocalValue(val);
|
|
4227
4195
|
onChange(val, ui);
|
|
4228
4196
|
},
|
|
4229
4197
|
[onChange]
|
|
4230
4198
|
);
|
|
4231
|
-
(0,
|
|
4199
|
+
(0, import_react20.useEffect)(() => {
|
|
4232
4200
|
if (!isFocused) {
|
|
4233
4201
|
setLocalValue(value);
|
|
4234
4202
|
}
|
|
4235
4203
|
}, [value]);
|
|
4236
|
-
(0,
|
|
4204
|
+
(0, import_react20.useEffect)(() => {
|
|
4237
4205
|
if (!isFocused) {
|
|
4238
4206
|
if (value !== localValue) {
|
|
4239
4207
|
setLocalValue(value);
|
|
@@ -4247,7 +4215,7 @@ function AutoFieldPrivate(props) {
|
|
|
4247
4215
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
|
4248
4216
|
}
|
|
4249
4217
|
function AutoField(props) {
|
|
4250
|
-
const DefaultLabel = (0,
|
|
4218
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
|
4251
4219
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4252
4220
|
"div",
|
|
4253
4221
|
__spreadProps(__spreadValues({}, labelProps), {
|
|
@@ -4270,21 +4238,21 @@ init_react_import();
|
|
|
4270
4238
|
var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
|
|
4271
4239
|
|
|
4272
4240
|
// components/Drawer/index.tsx
|
|
4273
|
-
var
|
|
4241
|
+
var import_react37 = require("react");
|
|
4274
4242
|
|
|
4275
4243
|
// components/DragDropContext/index.tsx
|
|
4276
4244
|
init_react_import();
|
|
4277
|
-
var
|
|
4278
|
-
var
|
|
4245
|
+
var import_react35 = require("@dnd-kit/react");
|
|
4246
|
+
var import_react36 = require("react");
|
|
4279
4247
|
var import_dom = require("@dnd-kit/dom");
|
|
4280
4248
|
|
|
4281
4249
|
// components/DropZone/index.tsx
|
|
4282
4250
|
init_react_import();
|
|
4283
|
-
var
|
|
4251
|
+
var import_react33 = require("react");
|
|
4284
4252
|
|
|
4285
4253
|
// components/DraggableComponent/index.tsx
|
|
4286
4254
|
init_react_import();
|
|
4287
|
-
var
|
|
4255
|
+
var import_react24 = require("react");
|
|
4288
4256
|
|
|
4289
4257
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4290
4258
|
init_react_import();
|
|
@@ -4314,11 +4282,11 @@ function getDeepScrollPosition(element) {
|
|
|
4314
4282
|
|
|
4315
4283
|
// components/DropZone/context.tsx
|
|
4316
4284
|
init_react_import();
|
|
4317
|
-
var
|
|
4285
|
+
var import_react21 = require("react");
|
|
4318
4286
|
var import_zustand3 = require("zustand");
|
|
4319
4287
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4320
|
-
var dropZoneContext = (0,
|
|
4321
|
-
var ZoneStoreContext = (0,
|
|
4288
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
|
4289
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
|
4322
4290
|
(0, import_zustand3.createStore)(() => ({
|
|
4323
4291
|
zoneDepthIndex: {},
|
|
4324
4292
|
nextZoneDepthIndex: {},
|
|
@@ -4341,7 +4309,7 @@ var DropZoneProvider = ({
|
|
|
4341
4309
|
value
|
|
4342
4310
|
}) => {
|
|
4343
4311
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4344
|
-
const registerZone = (0,
|
|
4312
|
+
const registerZone = (0, import_react21.useCallback)(
|
|
4345
4313
|
(zoneCompound) => {
|
|
4346
4314
|
dispatch({
|
|
4347
4315
|
type: "registerZone",
|
|
@@ -4350,7 +4318,7 @@ var DropZoneProvider = ({
|
|
|
4350
4318
|
},
|
|
4351
4319
|
[dispatch]
|
|
4352
4320
|
);
|
|
4353
|
-
const memoValue = (0,
|
|
4321
|
+
const memoValue = (0, import_react21.useMemo)(
|
|
4354
4322
|
() => __spreadValues({
|
|
4355
4323
|
registerZone
|
|
4356
4324
|
}, value),
|
|
@@ -4380,11 +4348,11 @@ function accumulateTransform(el) {
|
|
|
4380
4348
|
|
|
4381
4349
|
// lib/use-context-store.ts
|
|
4382
4350
|
init_react_import();
|
|
4383
|
-
var
|
|
4351
|
+
var import_react22 = require("react");
|
|
4384
4352
|
var import_zustand4 = require("zustand");
|
|
4385
4353
|
var import_shallow = require("zustand/react/shallow");
|
|
4386
4354
|
function useContextStore(context, selector) {
|
|
4387
|
-
const store = (0,
|
|
4355
|
+
const store = (0, import_react22.useContext)(context);
|
|
4388
4356
|
if (!store) {
|
|
4389
4357
|
throw new Error("useContextStore must be used inside context");
|
|
4390
4358
|
}
|
|
@@ -4393,10 +4361,10 @@ function useContextStore(context, selector) {
|
|
|
4393
4361
|
|
|
4394
4362
|
// lib/dnd/use-on-drag-finished.ts
|
|
4395
4363
|
init_react_import();
|
|
4396
|
-
var
|
|
4364
|
+
var import_react23 = require("react");
|
|
4397
4365
|
var useOnDragFinished = (cb, deps = []) => {
|
|
4398
4366
|
const appStore = useAppStoreApi();
|
|
4399
|
-
return (0,
|
|
4367
|
+
return (0, import_react23.useCallback)(() => {
|
|
4400
4368
|
let dispose = () => {
|
|
4401
4369
|
};
|
|
4402
4370
|
const processDragging = (isDragging2) => {
|
|
@@ -4466,9 +4434,9 @@ var DraggableComponent = ({
|
|
|
4466
4434
|
const overrides = useAppStore((s) => s.overrides);
|
|
4467
4435
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4468
4436
|
const iframe = useAppStore((s) => s.iframe);
|
|
4469
|
-
const ctx = (0,
|
|
4470
|
-
const [localZones, setLocalZones] = (0,
|
|
4471
|
-
const registerLocalZone = (0,
|
|
4437
|
+
const ctx = (0, import_react24.useContext)(dropZoneContext);
|
|
4438
|
+
const [localZones, setLocalZones] = (0, import_react24.useState)({});
|
|
4439
|
+
const registerLocalZone = (0, import_react24.useCallback)(
|
|
4472
4440
|
(zoneCompound2, active) => {
|
|
4473
4441
|
var _a;
|
|
4474
4442
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
|
@@ -4478,7 +4446,7 @@ var DraggableComponent = ({
|
|
|
4478
4446
|
},
|
|
4479
4447
|
[setLocalZones]
|
|
4480
4448
|
);
|
|
4481
|
-
const unregisterLocalZone = (0,
|
|
4449
|
+
const unregisterLocalZone = (0, import_react24.useCallback)(
|
|
4482
4450
|
(zoneCompound2) => {
|
|
4483
4451
|
var _a;
|
|
4484
4452
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
|
@@ -4501,9 +4469,9 @@ var DraggableComponent = ({
|
|
|
4501
4469
|
return s.permissions.getPermissions({ item });
|
|
4502
4470
|
})
|
|
4503
4471
|
);
|
|
4504
|
-
const zoneStore = (0,
|
|
4505
|
-
const [dragAxis, setDragAxis] = (0,
|
|
4506
|
-
const dynamicCollisionDetector = (0,
|
|
4472
|
+
const zoneStore = (0, import_react24.useContext)(ZoneStoreContext);
|
|
4473
|
+
const [dragAxis, setDragAxis] = (0, import_react24.useState)(userDragAxis || autoDragAxis);
|
|
4474
|
+
const dynamicCollisionDetector = (0, import_react24.useMemo)(
|
|
4507
4475
|
() => createDynamicCollisionDetector(dragAxis),
|
|
4508
4476
|
[dragAxis]
|
|
4509
4477
|
);
|
|
@@ -4535,7 +4503,7 @@ var DraggableComponent = ({
|
|
|
4535
4503
|
},
|
|
4536
4504
|
feedback: "clone"
|
|
4537
4505
|
});
|
|
4538
|
-
(0,
|
|
4506
|
+
(0, import_react24.useEffect)(() => {
|
|
4539
4507
|
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
|
4540
4508
|
sortable.droppable.disabled = !isEnabled;
|
|
4541
4509
|
sortable.draggable.disabled = !permissions.drag;
|
|
@@ -4552,8 +4520,8 @@ var DraggableComponent = ({
|
|
|
4552
4520
|
}
|
|
4553
4521
|
return cleanup;
|
|
4554
4522
|
}, [permissions.drag, zoneCompound]);
|
|
4555
|
-
const ref = (0,
|
|
4556
|
-
const refSetter = (0,
|
|
4523
|
+
const ref = (0, import_react24.useRef)(null);
|
|
4524
|
+
const refSetter = (0, import_react24.useCallback)(
|
|
4557
4525
|
(el) => {
|
|
4558
4526
|
sortableRef(el);
|
|
4559
4527
|
if (el) {
|
|
@@ -4562,14 +4530,14 @@ var DraggableComponent = ({
|
|
|
4562
4530
|
},
|
|
4563
4531
|
[sortableRef]
|
|
4564
4532
|
);
|
|
4565
|
-
const [portalEl, setPortalEl] = (0,
|
|
4566
|
-
(0,
|
|
4533
|
+
const [portalEl, setPortalEl] = (0, import_react24.useState)();
|
|
4534
|
+
(0, import_react24.useEffect)(() => {
|
|
4567
4535
|
var _a, _b, _c;
|
|
4568
4536
|
setPortalEl(
|
|
4569
4537
|
iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
|
|
4570
4538
|
);
|
|
4571
4539
|
}, [iframe.enabled, ref.current]);
|
|
4572
|
-
const getStyle = (0,
|
|
4540
|
+
const getStyle = (0, import_react24.useCallback)(() => {
|
|
4573
4541
|
var _a, _b, _c;
|
|
4574
4542
|
if (!ref.current) return;
|
|
4575
4543
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4594,11 +4562,11 @@ var DraggableComponent = ({
|
|
|
4594
4562
|
};
|
|
4595
4563
|
return style2;
|
|
4596
4564
|
}, [ref.current]);
|
|
4597
|
-
const [style, setStyle] = (0,
|
|
4598
|
-
const sync = (0,
|
|
4565
|
+
const [style, setStyle] = (0, import_react24.useState)();
|
|
4566
|
+
const sync = (0, import_react24.useCallback)(() => {
|
|
4599
4567
|
setStyle(getStyle());
|
|
4600
4568
|
}, [ref.current, iframe]);
|
|
4601
|
-
(0,
|
|
4569
|
+
(0, import_react24.useEffect)(() => {
|
|
4602
4570
|
if (ref.current) {
|
|
4603
4571
|
const observer = new ResizeObserver(sync);
|
|
4604
4572
|
observer.observe(ref.current);
|
|
@@ -4608,13 +4576,13 @@ var DraggableComponent = ({
|
|
|
4608
4576
|
}
|
|
4609
4577
|
}, [ref.current]);
|
|
4610
4578
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
|
4611
|
-
const hideOverlay = (0,
|
|
4579
|
+
const hideOverlay = (0, import_react24.useCallback)(() => {
|
|
4612
4580
|
setIsVisible(false);
|
|
4613
4581
|
}, []);
|
|
4614
|
-
const showOverlay = (0,
|
|
4582
|
+
const showOverlay = (0, import_react24.useCallback)(() => {
|
|
4615
4583
|
setIsVisible(true);
|
|
4616
4584
|
}, []);
|
|
4617
|
-
(0,
|
|
4585
|
+
(0, import_react24.useEffect)(() => {
|
|
4618
4586
|
var _a;
|
|
4619
4587
|
registerNode(id, {
|
|
4620
4588
|
methods: { sync, showOverlay, hideOverlay },
|
|
@@ -4631,11 +4599,11 @@ var DraggableComponent = ({
|
|
|
4631
4599
|
});
|
|
4632
4600
|
};
|
|
4633
4601
|
}, [id, zoneCompound, index, componentType, sync]);
|
|
4634
|
-
const CustomActionBar = (0,
|
|
4602
|
+
const CustomActionBar = (0, import_react24.useMemo)(
|
|
4635
4603
|
() => overrides.actionBar || DefaultActionBar,
|
|
4636
4604
|
[overrides.actionBar]
|
|
4637
4605
|
);
|
|
4638
|
-
const onClick = (0,
|
|
4606
|
+
const onClick = (0, import_react24.useCallback)(
|
|
4639
4607
|
(e) => {
|
|
4640
4608
|
e.stopPropagation();
|
|
4641
4609
|
dispatch({
|
|
@@ -4648,7 +4616,7 @@ var DraggableComponent = ({
|
|
|
4648
4616
|
[index, zoneCompound, id]
|
|
4649
4617
|
);
|
|
4650
4618
|
const appStore = useAppStoreApi();
|
|
4651
|
-
const onSelectParent = (0,
|
|
4619
|
+
const onSelectParent = (0, import_react24.useCallback)(() => {
|
|
4652
4620
|
const { nodes, zones } = appStore.getState().state.indexes;
|
|
4653
4621
|
const node = nodes[id];
|
|
4654
4622
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
|
@@ -4669,26 +4637,26 @@ var DraggableComponent = ({
|
|
|
4669
4637
|
}
|
|
4670
4638
|
});
|
|
4671
4639
|
}, [ctx, path]);
|
|
4672
|
-
const onDuplicate = (0,
|
|
4640
|
+
const onDuplicate = (0, import_react24.useCallback)(() => {
|
|
4673
4641
|
dispatch({
|
|
4674
4642
|
type: "duplicate",
|
|
4675
4643
|
sourceIndex: index,
|
|
4676
4644
|
sourceZone: zoneCompound
|
|
4677
4645
|
});
|
|
4678
4646
|
}, [index, zoneCompound]);
|
|
4679
|
-
const onDelete = (0,
|
|
4647
|
+
const onDelete = (0, import_react24.useCallback)(() => {
|
|
4680
4648
|
dispatch({
|
|
4681
4649
|
type: "remove",
|
|
4682
4650
|
index,
|
|
4683
4651
|
zone: zoneCompound
|
|
4684
4652
|
});
|
|
4685
4653
|
}, [index, zoneCompound]);
|
|
4686
|
-
const [hover, setHover] = (0,
|
|
4654
|
+
const [hover, setHover] = (0, import_react24.useState)(false);
|
|
4687
4655
|
const indicativeHover = useContextStore(
|
|
4688
4656
|
ZoneStoreContext,
|
|
4689
4657
|
(s) => s.hoveringComponent === id
|
|
4690
4658
|
);
|
|
4691
|
-
(0,
|
|
4659
|
+
(0, import_react24.useEffect)(() => {
|
|
4692
4660
|
if (!ref.current) {
|
|
4693
4661
|
return;
|
|
4694
4662
|
}
|
|
@@ -4733,10 +4701,10 @@ var DraggableComponent = ({
|
|
|
4733
4701
|
thisIsDragging,
|
|
4734
4702
|
inDroppableZone
|
|
4735
4703
|
]);
|
|
4736
|
-
const [isVisible, setIsVisible] = (0,
|
|
4737
|
-
const [dragFinished, setDragFinished] = (0,
|
|
4738
|
-
const [_, startTransition] = (0,
|
|
4739
|
-
(0,
|
|
4704
|
+
const [isVisible, setIsVisible] = (0, import_react24.useState)(false);
|
|
4705
|
+
const [dragFinished, setDragFinished] = (0, import_react24.useState)(true);
|
|
4706
|
+
const [_, startTransition] = (0, import_react24.useTransition)();
|
|
4707
|
+
(0, import_react24.useEffect)(() => {
|
|
4740
4708
|
startTransition(() => {
|
|
4741
4709
|
if (hover || indicativeHover || isSelected) {
|
|
4742
4710
|
sync();
|
|
@@ -4747,7 +4715,7 @@ var DraggableComponent = ({
|
|
|
4747
4715
|
}
|
|
4748
4716
|
});
|
|
4749
4717
|
}, [hover, indicativeHover, isSelected, iframe]);
|
|
4750
|
-
const [thisWasDragging, setThisWasDragging] = (0,
|
|
4718
|
+
const [thisWasDragging, setThisWasDragging] = (0, import_react24.useState)(false);
|
|
4751
4719
|
const onDragFinished = useOnDragFinished((finished) => {
|
|
4752
4720
|
if (finished) {
|
|
4753
4721
|
startTransition(() => {
|
|
@@ -4758,15 +4726,15 @@ var DraggableComponent = ({
|
|
|
4758
4726
|
setDragFinished(false);
|
|
4759
4727
|
}
|
|
4760
4728
|
});
|
|
4761
|
-
(0,
|
|
4729
|
+
(0, import_react24.useEffect)(() => {
|
|
4762
4730
|
if (thisIsDragging) {
|
|
4763
4731
|
setThisWasDragging(true);
|
|
4764
4732
|
}
|
|
4765
4733
|
}, [thisIsDragging]);
|
|
4766
|
-
(0,
|
|
4734
|
+
(0, import_react24.useEffect)(() => {
|
|
4767
4735
|
if (thisWasDragging) return onDragFinished();
|
|
4768
4736
|
}, [thisWasDragging, onDragFinished]);
|
|
4769
|
-
const syncActionsPosition = (0,
|
|
4737
|
+
const syncActionsPosition = (0, import_react24.useCallback)(
|
|
4770
4738
|
(el) => {
|
|
4771
4739
|
if (el) {
|
|
4772
4740
|
const view = el.ownerDocument.defaultView;
|
|
@@ -4791,7 +4759,7 @@ var DraggableComponent = ({
|
|
|
4791
4759
|
},
|
|
4792
4760
|
[zoom]
|
|
4793
4761
|
);
|
|
4794
|
-
(0,
|
|
4762
|
+
(0, import_react24.useEffect)(() => {
|
|
4795
4763
|
if (userDragAxis) {
|
|
4796
4764
|
setDragAxis(userDragAxis);
|
|
4797
4765
|
return;
|
|
@@ -4805,11 +4773,11 @@ var DraggableComponent = ({
|
|
|
4805
4773
|
}
|
|
4806
4774
|
setDragAxis(autoDragAxis);
|
|
4807
4775
|
}, [ref, userDragAxis, autoDragAxis]);
|
|
4808
|
-
const parentAction = (0,
|
|
4776
|
+
const parentAction = (0, import_react24.useMemo)(
|
|
4809
4777
|
() => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CornerLeftUp, { size: 16 }) }),
|
|
4810
4778
|
[ctx == null ? void 0 : ctx.areaId]
|
|
4811
4779
|
);
|
|
4812
|
-
const nextContextValue = (0,
|
|
4780
|
+
const nextContextValue = (0, import_react24.useMemo)(
|
|
4813
4781
|
() => __spreadProps(__spreadValues({}, ctx), {
|
|
4814
4782
|
areaId: id,
|
|
4815
4783
|
zoneCompound,
|
|
@@ -4892,11 +4860,11 @@ init_react_import();
|
|
|
4892
4860
|
var styles_module_default12 = { "DropZone": "_DropZone_1i2sv_1", "DropZone--hasChildren": "_DropZone--hasChildren_1i2sv_11", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1i2sv_24", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1i2sv_25", "DropZone--isRootZone": "_DropZone--isRootZone_1i2sv_25", "DropZone--isDestination": "_DropZone--isDestination_1i2sv_35", "DropZone-item": "_DropZone-item_1i2sv_47", "DropZone-hitbox": "_DropZone-hitbox_1i2sv_51", "DropZone--isEnabled": "_DropZone--isEnabled_1i2sv_59", "DropZone--isAnimating": "_DropZone--isAnimating_1i2sv_68" };
|
|
4893
4861
|
|
|
4894
4862
|
// components/DropZone/index.tsx
|
|
4895
|
-
var
|
|
4863
|
+
var import_react34 = require("@dnd-kit/react");
|
|
4896
4864
|
|
|
4897
4865
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
4898
4866
|
init_react_import();
|
|
4899
|
-
var
|
|
4867
|
+
var import_react25 = require("react");
|
|
4900
4868
|
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
|
4901
4869
|
var useMinEmptyHeight = ({
|
|
4902
4870
|
zoneCompound,
|
|
@@ -4904,8 +4872,8 @@ var useMinEmptyHeight = ({
|
|
|
4904
4872
|
ref
|
|
4905
4873
|
}) => {
|
|
4906
4874
|
const appStore = useAppStoreApi();
|
|
4907
|
-
const [prevHeight, setPrevHeight] = (0,
|
|
4908
|
-
const [isAnimating, setIsAnimating] = (0,
|
|
4875
|
+
const [prevHeight, setPrevHeight] = (0, import_react25.useState)(0);
|
|
4876
|
+
const [isAnimating, setIsAnimating] = (0, import_react25.useState)(false);
|
|
4909
4877
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
|
4910
4878
|
var _a, _b;
|
|
4911
4879
|
return {
|
|
@@ -4913,7 +4881,7 @@ var useMinEmptyHeight = ({
|
|
|
4913
4881
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
|
4914
4882
|
};
|
|
4915
4883
|
});
|
|
4916
|
-
const numItems = (0,
|
|
4884
|
+
const numItems = (0, import_react25.useRef)(0);
|
|
4917
4885
|
const onDragFinished = useOnDragFinished(
|
|
4918
4886
|
(finished) => {
|
|
4919
4887
|
var _a;
|
|
@@ -4948,7 +4916,7 @@ var useMinEmptyHeight = ({
|
|
|
4948
4916
|
},
|
|
4949
4917
|
[appStore, prevHeight, zoneCompound]
|
|
4950
4918
|
);
|
|
4951
|
-
(0,
|
|
4919
|
+
(0, import_react25.useEffect)(() => {
|
|
4952
4920
|
if (draggedItem && ref.current) {
|
|
4953
4921
|
if (isZone) {
|
|
4954
4922
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4979,15 +4947,15 @@ function assignRefs(refs, node) {
|
|
|
4979
4947
|
|
|
4980
4948
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
4981
4949
|
init_react_import();
|
|
4982
|
-
var
|
|
4950
|
+
var import_react28 = require("react");
|
|
4983
4951
|
|
|
4984
4952
|
// lib/dnd/use-rendered-callback.ts
|
|
4985
4953
|
init_react_import();
|
|
4986
|
-
var
|
|
4987
|
-
var
|
|
4954
|
+
var import_react26 = require("@dnd-kit/react");
|
|
4955
|
+
var import_react27 = require("react");
|
|
4988
4956
|
function useRenderedCallback(callback, deps) {
|
|
4989
|
-
const manager = (0,
|
|
4990
|
-
return (0,
|
|
4957
|
+
const manager = (0, import_react26.useDragDropManager)();
|
|
4958
|
+
return (0, import_react27.useCallback)(
|
|
4991
4959
|
(...args) => __async(this, null, function* () {
|
|
4992
4960
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
|
4993
4961
|
return callback(...args);
|
|
@@ -4998,14 +4966,14 @@ function useRenderedCallback(callback, deps) {
|
|
|
4998
4966
|
|
|
4999
4967
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5000
4968
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
5001
|
-
const zoneStore = (0,
|
|
4969
|
+
const zoneStore = (0, import_react28.useContext)(ZoneStoreContext);
|
|
5002
4970
|
const preview = useContextStore(
|
|
5003
4971
|
ZoneStoreContext,
|
|
5004
4972
|
(s) => s.previewIndex[zoneCompound]
|
|
5005
4973
|
);
|
|
5006
4974
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
|
5007
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
|
5008
|
-
const [localPreview, setLocalPreview] = (0,
|
|
4975
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react28.useState)(contentIds);
|
|
4976
|
+
const [localPreview, setLocalPreview] = (0, import_react28.useState)(
|
|
5009
4977
|
preview
|
|
5010
4978
|
);
|
|
5011
4979
|
const updateContent = useRenderedCallback(
|
|
@@ -5040,7 +5008,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5040
5008
|
},
|
|
5041
5009
|
[]
|
|
5042
5010
|
);
|
|
5043
|
-
(0,
|
|
5011
|
+
(0, import_react28.useEffect)(() => {
|
|
5044
5012
|
var _a;
|
|
5045
5013
|
const s = zoneStore.getState();
|
|
5046
5014
|
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
|
@@ -5058,16 +5026,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5058
5026
|
|
|
5059
5027
|
// components/DropZone/lib/use-drag-axis.ts
|
|
5060
5028
|
init_react_import();
|
|
5061
|
-
var
|
|
5029
|
+
var import_react29 = require("react");
|
|
5062
5030
|
var GRID_DRAG_AXIS = "dynamic";
|
|
5063
5031
|
var FLEX_ROW_DRAG_AXIS = "x";
|
|
5064
5032
|
var DEFAULT_DRAG_AXIS = "y";
|
|
5065
5033
|
var useDragAxis = (ref, collisionAxis) => {
|
|
5066
5034
|
const status = useAppStore((s) => s.status);
|
|
5067
|
-
const [dragAxis, setDragAxis] = (0,
|
|
5035
|
+
const [dragAxis, setDragAxis] = (0, import_react29.useState)(
|
|
5068
5036
|
collisionAxis || DEFAULT_DRAG_AXIS
|
|
5069
5037
|
);
|
|
5070
|
-
const calculateDragAxis = (0,
|
|
5038
|
+
const calculateDragAxis = (0, import_react29.useCallback)(() => {
|
|
5071
5039
|
if (ref.current) {
|
|
5072
5040
|
const computedStyle = window.getComputedStyle(ref.current);
|
|
5073
5041
|
if (computedStyle.display === "grid") {
|
|
@@ -5079,7 +5047,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5079
5047
|
}
|
|
5080
5048
|
}
|
|
5081
5049
|
}, [ref.current]);
|
|
5082
|
-
(0,
|
|
5050
|
+
(0, import_react29.useEffect)(() => {
|
|
5083
5051
|
const onViewportChange = () => {
|
|
5084
5052
|
calculateDragAxis();
|
|
5085
5053
|
};
|
|
@@ -5088,7 +5056,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5088
5056
|
window.removeEventListener("viewportchange", onViewportChange);
|
|
5089
5057
|
};
|
|
5090
5058
|
}, []);
|
|
5091
|
-
(0,
|
|
5059
|
+
(0, import_react29.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
|
5092
5060
|
return [dragAxis, calculateDragAxis];
|
|
5093
5061
|
};
|
|
5094
5062
|
|
|
@@ -5100,9 +5068,9 @@ init_react_import();
|
|
|
5100
5068
|
|
|
5101
5069
|
// lib/use-slots.tsx
|
|
5102
5070
|
init_react_import();
|
|
5103
|
-
var
|
|
5071
|
+
var import_react30 = require("react");
|
|
5104
5072
|
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
5105
|
-
const slotProps = (0,
|
|
5073
|
+
const slotProps = (0, import_react30.useMemo)(() => {
|
|
5106
5074
|
const mapped = mapSlots(
|
|
5107
5075
|
item,
|
|
5108
5076
|
(content, _parentId, propName, field, propPath) => {
|
|
@@ -5122,7 +5090,7 @@ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdi
|
|
|
5122
5090
|
).props;
|
|
5123
5091
|
return mapped;
|
|
5124
5092
|
}, [config, item, readOnly, forceReadOnly]);
|
|
5125
|
-
const mergedProps = (0,
|
|
5093
|
+
const mergedProps = (0, import_react30.useMemo)(
|
|
5126
5094
|
() => __spreadValues(__spreadValues({}, item.props), slotProps),
|
|
5127
5095
|
[item.props, slotProps]
|
|
5128
5096
|
);
|
|
@@ -5130,7 +5098,7 @@ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdi
|
|
|
5130
5098
|
}
|
|
5131
5099
|
|
|
5132
5100
|
// components/Render/index.tsx
|
|
5133
|
-
var
|
|
5101
|
+
var import_react32 = __toESM(require("react"));
|
|
5134
5102
|
|
|
5135
5103
|
// components/SlotRender/index.tsx
|
|
5136
5104
|
init_react_import();
|
|
@@ -5138,7 +5106,7 @@ var import_shallow3 = require("zustand/react/shallow");
|
|
|
5138
5106
|
|
|
5139
5107
|
// components/SlotRender/server.tsx
|
|
5140
5108
|
init_react_import();
|
|
5141
|
-
var
|
|
5109
|
+
var import_react31 = require("react");
|
|
5142
5110
|
|
|
5143
5111
|
// components/ServerRender/index.tsx
|
|
5144
5112
|
init_react_import();
|
|
@@ -5207,7 +5175,7 @@ var Item = ({
|
|
|
5207
5175
|
})
|
|
5208
5176
|
);
|
|
5209
5177
|
};
|
|
5210
|
-
var SlotRender = (0,
|
|
5178
|
+
var SlotRender = (0, import_react31.forwardRef)(
|
|
5211
5179
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5212
5180
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5213
5181
|
if (!config.components[item.type]) {
|
|
@@ -5255,7 +5223,7 @@ var ContextSlotRender = ({
|
|
|
5255
5223
|
|
|
5256
5224
|
// components/Render/index.tsx
|
|
5257
5225
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
5258
|
-
var renderContext =
|
|
5226
|
+
var renderContext = import_react32.default.createContext({
|
|
5259
5227
|
config: { components: {} },
|
|
5260
5228
|
data: { root: {}, content: [] },
|
|
5261
5229
|
metadata: {}
|
|
@@ -5288,7 +5256,7 @@ function Render({
|
|
|
5288
5256
|
{ type: "root", props: pageProps },
|
|
5289
5257
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
|
5290
5258
|
);
|
|
5291
|
-
const nextContextValue = (0,
|
|
5259
|
+
const nextContextValue = (0, import_react32.useMemo)(
|
|
5292
5260
|
() => ({
|
|
5293
5261
|
mode: "render",
|
|
5294
5262
|
depth: 0
|
|
@@ -5317,9 +5285,9 @@ var DropZoneChild = ({
|
|
|
5317
5285
|
}) => {
|
|
5318
5286
|
var _a, _b;
|
|
5319
5287
|
const metadata = useAppStore((s) => s.metadata);
|
|
5320
|
-
const ctx = (0,
|
|
5288
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
|
5321
5289
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
5322
|
-
const zoneStore = (0,
|
|
5290
|
+
const zoneStore = (0, import_react33.useContext)(ZoneStoreContext);
|
|
5323
5291
|
const nodeProps = useAppStore(
|
|
5324
5292
|
(0, import_shallow4.useShallow)((s) => {
|
|
5325
5293
|
var _a2;
|
|
@@ -5339,7 +5307,7 @@ var DropZoneChild = ({
|
|
|
5339
5307
|
})
|
|
5340
5308
|
);
|
|
5341
5309
|
const appStore = useAppStoreApi();
|
|
5342
|
-
const item = (0,
|
|
5310
|
+
const item = (0, import_react33.useMemo)(() => {
|
|
5343
5311
|
if (nodeProps) {
|
|
5344
5312
|
const expanded = expandNode({
|
|
5345
5313
|
type: nodeType,
|
|
@@ -5361,7 +5329,7 @@ var DropZoneChild = ({
|
|
|
5361
5329
|
const componentConfig = useAppStore(
|
|
5362
5330
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
|
5363
5331
|
);
|
|
5364
|
-
const puckProps = (0,
|
|
5332
|
+
const puckProps = (0, import_react33.useMemo)(
|
|
5365
5333
|
() => ({
|
|
5366
5334
|
renderDropZone: DropZoneEditPure,
|
|
5367
5335
|
isEditing: true,
|
|
@@ -5384,7 +5352,7 @@ var DropZoneChild = ({
|
|
|
5384
5352
|
}
|
|
5385
5353
|
);
|
|
5386
5354
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
|
5387
|
-
const renderPreview = (0,
|
|
5355
|
+
const renderPreview = (0, import_react33.useMemo)(
|
|
5388
5356
|
() => function Preview3() {
|
|
5389
5357
|
if (item && "element" in item && item.element) {
|
|
5390
5358
|
return (
|
|
@@ -5396,7 +5364,7 @@ var DropZoneChild = ({
|
|
|
5396
5364
|
},
|
|
5397
5365
|
[componentId, label, overrides]
|
|
5398
5366
|
);
|
|
5399
|
-
const defaultsProps = (0,
|
|
5367
|
+
const defaultsProps = (0, import_react33.useMemo)(
|
|
5400
5368
|
() => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
|
|
5401
5369
|
puck: puckProps,
|
|
5402
5370
|
editMode: true
|
|
@@ -5404,7 +5372,7 @@ var DropZoneChild = ({
|
|
|
5404
5372
|
}),
|
|
5405
5373
|
[componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
|
|
5406
5374
|
);
|
|
5407
|
-
const defaultedNode = (0,
|
|
5375
|
+
const defaultedNode = (0, import_react33.useMemo)(
|
|
5408
5376
|
() => {
|
|
5409
5377
|
var _a2;
|
|
5410
5378
|
return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
|
|
@@ -5455,8 +5423,8 @@ var DropZoneChild = ({
|
|
|
5455
5423
|
}
|
|
5456
5424
|
);
|
|
5457
5425
|
};
|
|
5458
|
-
var DropZoneChildMemo = (0,
|
|
5459
|
-
var DropZoneEdit = (0,
|
|
5426
|
+
var DropZoneChildMemo = (0, import_react33.memo)(DropZoneChild);
|
|
5427
|
+
var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
5460
5428
|
function DropZoneEditInternal({
|
|
5461
5429
|
zone,
|
|
5462
5430
|
allow,
|
|
@@ -5466,7 +5434,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5466
5434
|
minEmptyHeight: userMinEmptyHeight = 128,
|
|
5467
5435
|
collisionAxis
|
|
5468
5436
|
}, userRef) {
|
|
5469
|
-
const ctx = (0,
|
|
5437
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
|
5470
5438
|
const appStoreApi = useAppStoreApi();
|
|
5471
5439
|
const {
|
|
5472
5440
|
// These all need setting via context
|
|
@@ -5504,14 +5472,14 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5504
5472
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
5505
5473
|
})
|
|
5506
5474
|
);
|
|
5507
|
-
(0,
|
|
5475
|
+
(0, import_react33.useEffect)(() => {
|
|
5508
5476
|
if (!zoneType || zoneType === "dropzone") {
|
|
5509
5477
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5510
5478
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5511
5479
|
}
|
|
5512
5480
|
}
|
|
5513
5481
|
}, [zoneType, appStoreApi]);
|
|
5514
|
-
(0,
|
|
5482
|
+
(0, import_react33.useEffect)(() => {
|
|
5515
5483
|
if (zoneType === "dropzone") {
|
|
5516
5484
|
if (zoneCompound !== rootDroppableId) {
|
|
5517
5485
|
console.warn(
|
|
@@ -5520,11 +5488,11 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5520
5488
|
}
|
|
5521
5489
|
}
|
|
5522
5490
|
}, [zoneType]);
|
|
5523
|
-
const contentIds = (0,
|
|
5491
|
+
const contentIds = (0, import_react33.useMemo)(() => {
|
|
5524
5492
|
return zoneContentIds || [];
|
|
5525
5493
|
}, [zoneContentIds]);
|
|
5526
|
-
const ref = (0,
|
|
5527
|
-
const acceptsTarget = (0,
|
|
5494
|
+
const ref = (0, import_react33.useRef)(null);
|
|
5495
|
+
const acceptsTarget = (0, import_react33.useCallback)(
|
|
5528
5496
|
(componentType) => {
|
|
5529
5497
|
if (!componentType) {
|
|
5530
5498
|
return true;
|
|
@@ -5562,7 +5530,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5562
5530
|
}
|
|
5563
5531
|
return _isEnabled;
|
|
5564
5532
|
});
|
|
5565
|
-
(0,
|
|
5533
|
+
(0, import_react33.useEffect)(() => {
|
|
5566
5534
|
if (registerLocalZone) {
|
|
5567
5535
|
registerLocalZone(zoneCompound, targetAccepted || isEnabled);
|
|
5568
5536
|
}
|
|
@@ -5577,8 +5545,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5577
5545
|
zoneCompound
|
|
5578
5546
|
);
|
|
5579
5547
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
|
5580
|
-
const zoneStore = (0,
|
|
5581
|
-
(0,
|
|
5548
|
+
const zoneStore = (0, import_react33.useContext)(ZoneStoreContext);
|
|
5549
|
+
(0, import_react33.useEffect)(() => {
|
|
5582
5550
|
const { enabledIndex } = zoneStore.getState();
|
|
5583
5551
|
zoneStore.setState({
|
|
5584
5552
|
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
|
@@ -5597,7 +5565,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5597
5565
|
path: path || []
|
|
5598
5566
|
}
|
|
5599
5567
|
};
|
|
5600
|
-
const { ref: dropRef } = (0,
|
|
5568
|
+
const { ref: dropRef } = (0, import_react34.useDroppable)(droppableConfig);
|
|
5601
5569
|
const isAreaSelected = useAppStore(
|
|
5602
5570
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
|
5603
5571
|
);
|
|
@@ -5652,7 +5620,7 @@ var DropZoneRenderItem = ({
|
|
|
5652
5620
|
}) => {
|
|
5653
5621
|
const Component = config.components[item.type];
|
|
5654
5622
|
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5655
|
-
const nextContextValue = (0,
|
|
5623
|
+
const nextContextValue = (0, import_react33.useMemo)(
|
|
5656
5624
|
() => ({
|
|
5657
5625
|
areaId: props.id,
|
|
5658
5626
|
depth: 1
|
|
@@ -5670,14 +5638,14 @@ var DropZoneRenderItem = ({
|
|
|
5670
5638
|
) }, props.id);
|
|
5671
5639
|
};
|
|
5672
5640
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
|
|
5673
|
-
var DropZoneRender2 = (0,
|
|
5641
|
+
var DropZoneRender2 = (0, import_react33.forwardRef)(
|
|
5674
5642
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
5675
|
-
const ctx = (0,
|
|
5643
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
|
5676
5644
|
const { areaId = "root" } = ctx || {};
|
|
5677
|
-
const { config, data, metadata } = (0,
|
|
5645
|
+
const { config, data, metadata } = (0, import_react33.useContext)(renderContext);
|
|
5678
5646
|
let zoneCompound = `${areaId}:${zone}`;
|
|
5679
5647
|
let content = (data == null ? void 0 : data.content) || [];
|
|
5680
|
-
(0,
|
|
5648
|
+
(0, import_react33.useEffect)(() => {
|
|
5681
5649
|
if (!content) {
|
|
5682
5650
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5683
5651
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
@@ -5708,9 +5676,9 @@ var DropZoneRender2 = (0, import_react35.forwardRef)(
|
|
|
5708
5676
|
}
|
|
5709
5677
|
);
|
|
5710
5678
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
|
|
5711
|
-
var DropZone = (0,
|
|
5679
|
+
var DropZone = (0, import_react33.forwardRef)(
|
|
5712
5680
|
function DropZone2(props, ref) {
|
|
5713
|
-
const ctx = (0,
|
|
5681
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
|
5714
5682
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
5715
5683
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
5716
5684
|
}
|
|
@@ -6052,12 +6020,12 @@ function getDeepDir(el) {
|
|
|
6052
6020
|
var import_state = require("@dnd-kit/state");
|
|
6053
6021
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
6054
6022
|
var DEBUG3 = false;
|
|
6055
|
-
var dragListenerContext = (0,
|
|
6023
|
+
var dragListenerContext = (0, import_react36.createContext)({
|
|
6056
6024
|
dragListeners: {}
|
|
6057
6025
|
});
|
|
6058
6026
|
function useDragListener(type, fn, deps = []) {
|
|
6059
|
-
const { setDragListeners } = (0,
|
|
6060
|
-
(0,
|
|
6027
|
+
const { setDragListeners } = (0, import_react36.useContext)(dragListenerContext);
|
|
6028
|
+
(0, import_react36.useEffect)(() => {
|
|
6061
6029
|
if (setDragListeners) {
|
|
6062
6030
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
|
6063
6031
|
[type]: [...old[type] || [], fn]
|
|
@@ -6067,8 +6035,8 @@ function useDragListener(type, fn, deps = []) {
|
|
|
6067
6035
|
}
|
|
6068
6036
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
|
6069
6037
|
var useTempDisableFallback = (timeout3) => {
|
|
6070
|
-
const lastFallbackDisable = (0,
|
|
6071
|
-
return (0,
|
|
6038
|
+
const lastFallbackDisable = (0, import_react36.useRef)(null);
|
|
6039
|
+
return (0, import_react36.useCallback)((manager) => {
|
|
6072
6040
|
collisionStore.setState({ fallbackEnabled: false });
|
|
6073
6041
|
const fallbackId = generateId();
|
|
6074
6042
|
lastFallbackDisable.current = fallbackId;
|
|
@@ -6087,9 +6055,9 @@ var DragDropContextClient = ({
|
|
|
6087
6055
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
6088
6056
|
const appStore = useAppStoreApi();
|
|
6089
6057
|
const id = useSafeId();
|
|
6090
|
-
const debouncedParamsRef = (0,
|
|
6058
|
+
const debouncedParamsRef = (0, import_react36.useRef)(null);
|
|
6091
6059
|
const tempDisableFallback = useTempDisableFallback(100);
|
|
6092
|
-
const [zoneStore] = (0,
|
|
6060
|
+
const [zoneStore] = (0, import_react36.useState)(
|
|
6093
6061
|
() => (0, import_zustand5.createStore)(() => ({
|
|
6094
6062
|
zoneDepthIndex: {},
|
|
6095
6063
|
nextZoneDepthIndex: {},
|
|
@@ -6101,7 +6069,7 @@ var DragDropContextClient = ({
|
|
|
6101
6069
|
hoveringComponent: null
|
|
6102
6070
|
}))
|
|
6103
6071
|
);
|
|
6104
|
-
const getChanged2 = (0,
|
|
6072
|
+
const getChanged2 = (0, import_react36.useCallback)(
|
|
6105
6073
|
(params, id2) => {
|
|
6106
6074
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
6107
6075
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
@@ -6122,7 +6090,7 @@ var DragDropContextClient = ({
|
|
|
6122
6090
|
},
|
|
6123
6091
|
[zoneStore]
|
|
6124
6092
|
);
|
|
6125
|
-
const setDeepestAndCollide = (0,
|
|
6093
|
+
const setDeepestAndCollide = (0, import_react36.useCallback)(
|
|
6126
6094
|
(params, manager) => {
|
|
6127
6095
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
|
6128
6096
|
if (!zoneChanged && !areaChanged) return;
|
|
@@ -6146,7 +6114,7 @@ var DragDropContextClient = ({
|
|
|
6146
6114
|
setDeepestDb.cancel();
|
|
6147
6115
|
debouncedParamsRef.current = null;
|
|
6148
6116
|
};
|
|
6149
|
-
(0,
|
|
6117
|
+
(0, import_react36.useEffect)(() => {
|
|
6150
6118
|
if (DEBUG3) {
|
|
6151
6119
|
zoneStore.subscribe(
|
|
6152
6120
|
(s) => {
|
|
@@ -6160,7 +6128,7 @@ var DragDropContextClient = ({
|
|
|
6160
6128
|
);
|
|
6161
6129
|
}
|
|
6162
6130
|
}, []);
|
|
6163
|
-
const [plugins] = (0,
|
|
6131
|
+
const [plugins] = (0, import_react36.useState)(() => [
|
|
6164
6132
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
|
6165
6133
|
createNestedDroppablePlugin(
|
|
6166
6134
|
{
|
|
@@ -6208,10 +6176,10 @@ var DragDropContextClient = ({
|
|
|
6208
6176
|
)
|
|
6209
6177
|
]);
|
|
6210
6178
|
const sensors = useSensors();
|
|
6211
|
-
const [dragListeners, setDragListeners] = (0,
|
|
6212
|
-
const dragMode = (0,
|
|
6213
|
-
const initialSelector = (0,
|
|
6214
|
-
const nextContextValue = (0,
|
|
6179
|
+
const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
|
|
6180
|
+
const dragMode = (0, import_react36.useRef)(null);
|
|
6181
|
+
const initialSelector = (0, import_react36.useRef)(void 0);
|
|
6182
|
+
const nextContextValue = (0, import_react36.useMemo)(
|
|
6215
6183
|
() => ({
|
|
6216
6184
|
mode: "edit",
|
|
6217
6185
|
areaId: "root",
|
|
@@ -6227,7 +6195,7 @@ var DragDropContextClient = ({
|
|
|
6227
6195
|
setDragListeners
|
|
6228
6196
|
},
|
|
6229
6197
|
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
6230
|
-
|
|
6198
|
+
import_react35.DragDropProvider,
|
|
6231
6199
|
{
|
|
6232
6200
|
plugins,
|
|
6233
6201
|
sensors,
|
|
@@ -6460,7 +6428,7 @@ var DragDropContext = ({
|
|
|
6460
6428
|
};
|
|
6461
6429
|
|
|
6462
6430
|
// components/Drawer/index.tsx
|
|
6463
|
-
var
|
|
6431
|
+
var import_react38 = require("@dnd-kit/react");
|
|
6464
6432
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
6465
6433
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
|
6466
6434
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
|
@@ -6471,7 +6439,7 @@ var DrawerItemInner = ({
|
|
|
6471
6439
|
dragRef,
|
|
6472
6440
|
isDragDisabled
|
|
6473
6441
|
}) => {
|
|
6474
|
-
const CustomInner = (0,
|
|
6442
|
+
const CustomInner = (0, import_react37.useMemo)(
|
|
6475
6443
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
|
6476
6444
|
[children]
|
|
6477
6445
|
);
|
|
@@ -6497,7 +6465,7 @@ var DrawerItemDraggable = ({
|
|
|
6497
6465
|
id,
|
|
6498
6466
|
isDragDisabled
|
|
6499
6467
|
}) => {
|
|
6500
|
-
const { ref } = (0,
|
|
6468
|
+
const { ref } = (0, import_react38.useDraggable)({
|
|
6501
6469
|
id,
|
|
6502
6470
|
data: { componentType: name },
|
|
6503
6471
|
disabled: isDragDisabled,
|
|
@@ -6526,7 +6494,7 @@ var DrawerItem = ({
|
|
|
6526
6494
|
isDragDisabled
|
|
6527
6495
|
}) => {
|
|
6528
6496
|
const resolvedId = id || name;
|
|
6529
|
-
const [dynamicId, setDynamicId] = (0,
|
|
6497
|
+
const [dynamicId, setDynamicId] = (0, import_react37.useState)(generateId(resolvedId));
|
|
6530
6498
|
if (typeof index !== "undefined") {
|
|
6531
6499
|
console.error(
|
|
6532
6500
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
|
@@ -6566,7 +6534,7 @@ var Drawer = ({
|
|
|
6566
6534
|
);
|
|
6567
6535
|
}
|
|
6568
6536
|
const id = useSafeId();
|
|
6569
|
-
const { ref } = (0,
|
|
6537
|
+
const { ref } = (0, import_react38.useDroppable)({
|
|
6570
6538
|
id,
|
|
6571
6539
|
type: "void",
|
|
6572
6540
|
collisionPriority: 0
|
|
@@ -6588,7 +6556,7 @@ Drawer.Item = DrawerItem;
|
|
|
6588
6556
|
|
|
6589
6557
|
// components/Puck/index.tsx
|
|
6590
6558
|
init_react_import();
|
|
6591
|
-
var
|
|
6559
|
+
var import_react54 = require("react");
|
|
6592
6560
|
|
|
6593
6561
|
// components/SidebarSection/index.tsx
|
|
6594
6562
|
init_react_import();
|
|
@@ -6599,7 +6567,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
|
6599
6567
|
|
|
6600
6568
|
// lib/use-breadcrumbs.ts
|
|
6601
6569
|
init_react_import();
|
|
6602
|
-
var
|
|
6570
|
+
var import_react39 = require("react");
|
|
6603
6571
|
var useBreadcrumbs = (renderCount) => {
|
|
6604
6572
|
const selectedId = useAppStore((s) => {
|
|
6605
6573
|
var _a;
|
|
@@ -6611,7 +6579,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6611
6579
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
6612
6580
|
});
|
|
6613
6581
|
const appStore = useAppStoreApi();
|
|
6614
|
-
return (0,
|
|
6582
|
+
return (0, import_react39.useMemo)(() => {
|
|
6615
6583
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
6616
6584
|
var _a, _b, _c;
|
|
6617
6585
|
const [componentId] = zoneCompound.split(":");
|
|
@@ -6695,7 +6663,7 @@ init_react_import();
|
|
|
6695
6663
|
var styles_module_default15 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
|
6696
6664
|
|
|
6697
6665
|
// components/Puck/components/Fields/index.tsx
|
|
6698
|
-
var
|
|
6666
|
+
var import_react40 = require("react");
|
|
6699
6667
|
var import_shallow5 = require("zustand/react/shallow");
|
|
6700
6668
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
6701
6669
|
var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
|
|
@@ -6768,7 +6736,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6768
6736
|
})
|
|
6769
6737
|
);
|
|
6770
6738
|
const appStore = useAppStoreApi();
|
|
6771
|
-
const onChange = (0,
|
|
6739
|
+
const onChange = (0, import_react40.useCallback)(createOnChange(fieldName, appStore), [
|
|
6772
6740
|
fieldName
|
|
6773
6741
|
]);
|
|
6774
6742
|
const { visible = true } = field != null ? field : {};
|
|
@@ -6786,7 +6754,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6786
6754
|
}
|
|
6787
6755
|
) }, id);
|
|
6788
6756
|
};
|
|
6789
|
-
var FieldsChildMemo = (0,
|
|
6757
|
+
var FieldsChildMemo = (0, import_react40.memo)(FieldsChild);
|
|
6790
6758
|
var FieldsInternal = ({ wrapFields = true }) => {
|
|
6791
6759
|
const overrides = useAppStore((s) => s.overrides);
|
|
6792
6760
|
const componentResolving = useAppStore((s) => {
|
|
@@ -6811,7 +6779,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6811
6779
|
})
|
|
6812
6780
|
);
|
|
6813
6781
|
const isLoading = fieldsLoading || componentResolving;
|
|
6814
|
-
const Wrapper = (0,
|
|
6782
|
+
const Wrapper = (0, import_react40.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
6815
6783
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
6816
6784
|
"form",
|
|
6817
6785
|
{
|
|
@@ -6826,14 +6794,14 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6826
6794
|
}
|
|
6827
6795
|
);
|
|
6828
6796
|
};
|
|
6829
|
-
var Fields = (0,
|
|
6797
|
+
var Fields = (0, import_react40.memo)(FieldsInternal);
|
|
6830
6798
|
|
|
6831
6799
|
// components/Puck/components/Components/index.tsx
|
|
6832
6800
|
init_react_import();
|
|
6833
6801
|
|
|
6834
6802
|
// lib/use-component-list.tsx
|
|
6835
6803
|
init_react_import();
|
|
6836
|
-
var
|
|
6804
|
+
var import_react41 = require("react");
|
|
6837
6805
|
|
|
6838
6806
|
// components/ComponentList/index.tsx
|
|
6839
6807
|
init_react_import();
|
|
@@ -6904,10 +6872,10 @@ ComponentList.Item = ComponentListItem;
|
|
|
6904
6872
|
// lib/use-component-list.tsx
|
|
6905
6873
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
6906
6874
|
var useComponentList = () => {
|
|
6907
|
-
const [componentList, setComponentList] = (0,
|
|
6875
|
+
const [componentList, setComponentList] = (0, import_react41.useState)();
|
|
6908
6876
|
const config = useAppStore((s) => s.config);
|
|
6909
6877
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
|
6910
|
-
(0,
|
|
6878
|
+
(0, import_react41.useEffect)(() => {
|
|
6911
6879
|
var _a, _b, _c;
|
|
6912
6880
|
if (Object.keys(uiComponentList).length > 0) {
|
|
6913
6881
|
const matchedComponents = [];
|
|
@@ -6976,22 +6944,22 @@ var useComponentList = () => {
|
|
|
6976
6944
|
};
|
|
6977
6945
|
|
|
6978
6946
|
// components/Puck/components/Components/index.tsx
|
|
6979
|
-
var
|
|
6947
|
+
var import_react42 = require("react");
|
|
6980
6948
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
6981
6949
|
var Components = () => {
|
|
6982
6950
|
const overrides = useAppStore((s) => s.overrides);
|
|
6983
6951
|
const componentList = useComponentList();
|
|
6984
|
-
const Wrapper = (0,
|
|
6952
|
+
const Wrapper = (0, import_react42.useMemo)(() => overrides.components || "div", [overrides]);
|
|
6985
6953
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
|
|
6986
6954
|
};
|
|
6987
6955
|
|
|
6988
6956
|
// components/Puck/components/Preview/index.tsx
|
|
6989
6957
|
init_react_import();
|
|
6990
|
-
var
|
|
6958
|
+
var import_react44 = require("react");
|
|
6991
6959
|
|
|
6992
6960
|
// components/AutoFrame/index.tsx
|
|
6993
6961
|
init_react_import();
|
|
6994
|
-
var
|
|
6962
|
+
var import_react43 = require("react");
|
|
6995
6963
|
var import_object_hash = __toESM(require("object-hash"));
|
|
6996
6964
|
var import_react_dom3 = require("react-dom");
|
|
6997
6965
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
@@ -7044,7 +7012,7 @@ var CopyHostStyles = ({
|
|
|
7044
7012
|
onStylesLoaded = () => null
|
|
7045
7013
|
}) => {
|
|
7046
7014
|
const { document: doc, window: win } = useFrame();
|
|
7047
|
-
(0,
|
|
7015
|
+
(0, import_react43.useEffect)(() => {
|
|
7048
7016
|
if (!win || !doc) {
|
|
7049
7017
|
return () => {
|
|
7050
7018
|
};
|
|
@@ -7203,8 +7171,8 @@ var CopyHostStyles = ({
|
|
|
7203
7171
|
}, []);
|
|
7204
7172
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
|
|
7205
7173
|
};
|
|
7206
|
-
var autoFrameContext = (0,
|
|
7207
|
-
var useFrame = () => (0,
|
|
7174
|
+
var autoFrameContext = (0, import_react43.createContext)({});
|
|
7175
|
+
var useFrame = () => (0, import_react43.useContext)(autoFrameContext);
|
|
7208
7176
|
function AutoFrame(_a) {
|
|
7209
7177
|
var _b = _a, {
|
|
7210
7178
|
children,
|
|
@@ -7225,11 +7193,11 @@ function AutoFrame(_a) {
|
|
|
7225
7193
|
"onNotReady",
|
|
7226
7194
|
"frameRef"
|
|
7227
7195
|
]);
|
|
7228
|
-
const [loaded, setLoaded] = (0,
|
|
7229
|
-
const [ctx, setCtx] = (0,
|
|
7230
|
-
const [mountTarget, setMountTarget] = (0,
|
|
7231
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
|
7232
|
-
(0,
|
|
7196
|
+
const [loaded, setLoaded] = (0, import_react43.useState)(false);
|
|
7197
|
+
const [ctx, setCtx] = (0, import_react43.useState)({});
|
|
7198
|
+
const [mountTarget, setMountTarget] = (0, import_react43.useState)();
|
|
7199
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react43.useState)(false);
|
|
7200
|
+
(0, import_react43.useEffect)(() => {
|
|
7233
7201
|
var _a2;
|
|
7234
7202
|
if (frameRef.current) {
|
|
7235
7203
|
const doc = frameRef.current.contentDocument;
|
|
@@ -7281,7 +7249,7 @@ var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
|
7281
7249
|
var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
|
|
7282
7250
|
var useBubbleIframeEvents = (ref) => {
|
|
7283
7251
|
const status = useAppStore((s) => s.status);
|
|
7284
|
-
(0,
|
|
7252
|
+
(0, import_react44.useEffect)(() => {
|
|
7285
7253
|
if (ref.current && status === "READY") {
|
|
7286
7254
|
const iframe = ref.current;
|
|
7287
7255
|
const handlePointerMove = (event) => {
|
|
@@ -7330,7 +7298,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7330
7298
|
const renderData = useAppStore(
|
|
7331
7299
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
7332
7300
|
);
|
|
7333
|
-
const Page = (0,
|
|
7301
|
+
const Page = (0, import_react44.useCallback)(
|
|
7334
7302
|
(pageProps) => {
|
|
7335
7303
|
var _a, _b;
|
|
7336
7304
|
const propsWithSlots = useSlots(
|
|
@@ -7344,9 +7312,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7344
7312
|
},
|
|
7345
7313
|
[config]
|
|
7346
7314
|
);
|
|
7347
|
-
const Frame = (0,
|
|
7315
|
+
const Frame = (0, import_react44.useMemo)(() => overrides.iframe, [overrides]);
|
|
7348
7316
|
const rootProps = root.props || root;
|
|
7349
|
-
const ref = (0,
|
|
7317
|
+
const ref = (0, import_react44.useRef)(null);
|
|
7350
7318
|
useBubbleIframeEvents(ref);
|
|
7351
7319
|
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7352
7320
|
Page,
|
|
@@ -7361,7 +7329,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7361
7329
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7362
7330
|
})
|
|
7363
7331
|
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config, metadata });
|
|
7364
|
-
(0,
|
|
7332
|
+
(0, import_react44.useEffect)(() => {
|
|
7365
7333
|
if (!iframe.enabled) {
|
|
7366
7334
|
setStatus("READY");
|
|
7367
7335
|
}
|
|
@@ -7431,7 +7399,7 @@ var scrollIntoView = (el) => {
|
|
|
7431
7399
|
};
|
|
7432
7400
|
|
|
7433
7401
|
// components/LayerTree/index.tsx
|
|
7434
|
-
var
|
|
7402
|
+
var import_react45 = require("react");
|
|
7435
7403
|
|
|
7436
7404
|
// lib/on-scroll-end.ts
|
|
7437
7405
|
init_react_import();
|
|
@@ -7466,7 +7434,7 @@ var Layer = ({
|
|
|
7466
7434
|
const config = useAppStore((s) => s.config);
|
|
7467
7435
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
7468
7436
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
7469
|
-
const setItemSelector = (0,
|
|
7437
|
+
const setItemSelector = (0, import_react45.useCallback)(
|
|
7470
7438
|
(itemSelector2) => {
|
|
7471
7439
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
7472
7440
|
},
|
|
@@ -7486,7 +7454,7 @@ var Layer = ({
|
|
|
7486
7454
|
)
|
|
7487
7455
|
);
|
|
7488
7456
|
const containsZone = zonesForItem.length > 0;
|
|
7489
|
-
const zoneStore = (0,
|
|
7457
|
+
const zoneStore = (0, import_react45.useContext)(ZoneStoreContext);
|
|
7490
7458
|
const isHovering = useContextStore(
|
|
7491
7459
|
ZoneStoreContext,
|
|
7492
7460
|
(s) => s.hoveringComponent === itemId
|
|
@@ -7613,7 +7581,7 @@ var LayerTree = ({
|
|
|
7613
7581
|
};
|
|
7614
7582
|
|
|
7615
7583
|
// components/Puck/components/Outline/index.tsx
|
|
7616
|
-
var
|
|
7584
|
+
var import_react46 = require("react");
|
|
7617
7585
|
|
|
7618
7586
|
// lib/data/find-zones-for-area.ts
|
|
7619
7587
|
init_react_import();
|
|
@@ -7631,7 +7599,7 @@ var Outline = () => {
|
|
|
7631
7599
|
const rootZones = useAppStore(
|
|
7632
7600
|
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7633
7601
|
);
|
|
7634
|
-
const Wrapper = (0,
|
|
7602
|
+
const Wrapper = (0, import_react46.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7635
7603
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7636
7604
|
LayerTree,
|
|
7637
7605
|
{
|
|
@@ -7765,11 +7733,11 @@ var getBox = function getBox2(el) {
|
|
|
7765
7733
|
};
|
|
7766
7734
|
|
|
7767
7735
|
// components/Puck/components/Canvas/index.tsx
|
|
7768
|
-
var
|
|
7736
|
+
var import_react48 = require("react");
|
|
7769
7737
|
|
|
7770
7738
|
// components/ViewportControls/index.tsx
|
|
7771
7739
|
init_react_import();
|
|
7772
|
-
var
|
|
7740
|
+
var import_react47 = require("react");
|
|
7773
7741
|
|
|
7774
7742
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
7775
7743
|
init_react_import();
|
|
@@ -7792,8 +7760,8 @@ var ViewportButton = ({
|
|
|
7792
7760
|
onClick
|
|
7793
7761
|
}) => {
|
|
7794
7762
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
|
7795
|
-
const [isActive, setIsActive] = (0,
|
|
7796
|
-
(0,
|
|
7763
|
+
const [isActive, setIsActive] = (0, import_react47.useState)(false);
|
|
7764
|
+
(0, import_react47.useEffect)(() => {
|
|
7797
7765
|
setIsActive(width === viewports.current.width);
|
|
7798
7766
|
}, [width, viewports.current.width]);
|
|
7799
7767
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
@@ -7830,7 +7798,7 @@ var ViewportControls = ({
|
|
|
7830
7798
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
7831
7799
|
(option) => option.value === autoZoom
|
|
7832
7800
|
);
|
|
7833
|
-
const zoomOptions = (0,
|
|
7801
|
+
const zoomOptions = (0, import_react47.useMemo)(
|
|
7834
7802
|
() => [
|
|
7835
7803
|
...defaultZoomOptions,
|
|
7836
7804
|
...defaultsContainAutoZoom ? [] : [
|
|
@@ -7979,17 +7947,17 @@ var Canvas = () => {
|
|
|
7979
7947
|
viewports: s.state.ui.viewports
|
|
7980
7948
|
}))
|
|
7981
7949
|
);
|
|
7982
|
-
const frameRef = (0,
|
|
7983
|
-
const [showTransition, setShowTransition] = (0,
|
|
7984
|
-
const defaultRender = (0,
|
|
7950
|
+
const frameRef = (0, import_react48.useRef)(null);
|
|
7951
|
+
const [showTransition, setShowTransition] = (0, import_react48.useState)(false);
|
|
7952
|
+
const defaultRender = (0, import_react48.useMemo)(() => {
|
|
7985
7953
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
|
7986
7954
|
return PuckDefault;
|
|
7987
7955
|
}, []);
|
|
7988
|
-
const CustomPreview = (0,
|
|
7956
|
+
const CustomPreview = (0, import_react48.useMemo)(
|
|
7989
7957
|
() => overrides.preview || defaultRender,
|
|
7990
7958
|
[overrides]
|
|
7991
7959
|
);
|
|
7992
|
-
const getFrameDimensions = (0,
|
|
7960
|
+
const getFrameDimensions = (0, import_react48.useCallback)(() => {
|
|
7993
7961
|
if (frameRef.current) {
|
|
7994
7962
|
const frame = frameRef.current;
|
|
7995
7963
|
const box = getBox(frame);
|
|
@@ -7997,7 +7965,7 @@ var Canvas = () => {
|
|
|
7997
7965
|
}
|
|
7998
7966
|
return { width: 0, height: 0 };
|
|
7999
7967
|
}, [frameRef]);
|
|
8000
|
-
const resetAutoZoom = (0,
|
|
7968
|
+
const resetAutoZoom = (0, import_react48.useCallback)(
|
|
8001
7969
|
(newViewports = viewports) => {
|
|
8002
7970
|
if (frameRef.current) {
|
|
8003
7971
|
setZoomConfig(
|
|
@@ -8011,11 +7979,11 @@ var Canvas = () => {
|
|
|
8011
7979
|
},
|
|
8012
7980
|
[frameRef, zoomConfig, viewports]
|
|
8013
7981
|
);
|
|
8014
|
-
(0,
|
|
7982
|
+
(0, import_react48.useEffect)(() => {
|
|
8015
7983
|
setShowTransition(false);
|
|
8016
7984
|
resetAutoZoom(viewports);
|
|
8017
7985
|
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
|
8018
|
-
(0,
|
|
7986
|
+
(0, import_react48.useEffect)(() => {
|
|
8019
7987
|
const { height: frameHeight } = getFrameDimensions();
|
|
8020
7988
|
if (viewports.current.height === "auto") {
|
|
8021
7989
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
@@ -8023,13 +7991,13 @@ var Canvas = () => {
|
|
|
8023
7991
|
}));
|
|
8024
7992
|
}
|
|
8025
7993
|
}, [zoomConfig.zoom]);
|
|
8026
|
-
(0,
|
|
7994
|
+
(0, import_react48.useEffect)(() => {
|
|
8027
7995
|
if (ZOOM_ON_CHANGE) {
|
|
8028
7996
|
setShowTransition(true);
|
|
8029
7997
|
resetAutoZoom(viewports);
|
|
8030
7998
|
}
|
|
8031
7999
|
}, [viewports.current.width]);
|
|
8032
|
-
(0,
|
|
8000
|
+
(0, import_react48.useEffect)(() => {
|
|
8033
8001
|
const cb = () => {
|
|
8034
8002
|
setShowTransition(false);
|
|
8035
8003
|
resetAutoZoom();
|
|
@@ -8039,8 +8007,8 @@ var Canvas = () => {
|
|
|
8039
8007
|
window.removeEventListener("resize", cb);
|
|
8040
8008
|
};
|
|
8041
8009
|
}, []);
|
|
8042
|
-
const [showLoader, setShowLoader] = (0,
|
|
8043
|
-
(0,
|
|
8010
|
+
const [showLoader, setShowLoader] = (0, import_react48.useState)(false);
|
|
8011
|
+
(0, import_react48.useEffect)(() => {
|
|
8044
8012
|
setTimeout(() => {
|
|
8045
8013
|
setShowLoader(true);
|
|
8046
8014
|
}, 500);
|
|
@@ -8118,7 +8086,7 @@ var Canvas = () => {
|
|
|
8118
8086
|
|
|
8119
8087
|
// lib/use-loaded-overrides.ts
|
|
8120
8088
|
init_react_import();
|
|
8121
|
-
var
|
|
8089
|
+
var import_react49 = require("react");
|
|
8122
8090
|
|
|
8123
8091
|
// lib/load-overrides.ts
|
|
8124
8092
|
init_react_import();
|
|
@@ -8157,7 +8125,7 @@ var useLoadedOverrides = ({
|
|
|
8157
8125
|
overrides,
|
|
8158
8126
|
plugins
|
|
8159
8127
|
}) => {
|
|
8160
|
-
return (0,
|
|
8128
|
+
return (0, import_react49.useMemo)(() => {
|
|
8161
8129
|
return loadOverrides({ overrides, plugins });
|
|
8162
8130
|
}, [plugins, overrides]);
|
|
8163
8131
|
};
|
|
@@ -8169,14 +8137,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39
|
|
|
8169
8137
|
|
|
8170
8138
|
// lib/use-inject-css.ts
|
|
8171
8139
|
init_react_import();
|
|
8172
|
-
var
|
|
8140
|
+
var import_react50 = require("react");
|
|
8173
8141
|
var styles = ``;
|
|
8174
8142
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
8175
|
-
const [el, setEl] = (0,
|
|
8176
|
-
(0,
|
|
8143
|
+
const [el, setEl] = (0, import_react50.useState)();
|
|
8144
|
+
(0, import_react50.useEffect)(() => {
|
|
8177
8145
|
setEl(document.createElement("style"));
|
|
8178
8146
|
}, []);
|
|
8179
|
-
(0,
|
|
8147
|
+
(0, import_react50.useEffect)(() => {
|
|
8180
8148
|
var _a;
|
|
8181
8149
|
if (!el || typeof window === "undefined") {
|
|
8182
8150
|
return;
|
|
@@ -8196,10 +8164,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
8196
8164
|
|
|
8197
8165
|
// lib/use-preview-mode-hotkeys.ts
|
|
8198
8166
|
init_react_import();
|
|
8199
|
-
var
|
|
8167
|
+
var import_react51 = require("react");
|
|
8200
8168
|
var usePreviewModeHotkeys = () => {
|
|
8201
8169
|
const appStore = useAppStoreApi();
|
|
8202
|
-
const toggleInteractive = (0,
|
|
8170
|
+
const toggleInteractive = (0, import_react51.useCallback)(() => {
|
|
8203
8171
|
const dispatch = appStore.getState().dispatch;
|
|
8204
8172
|
dispatch({
|
|
8205
8173
|
type: "setUi",
|
|
@@ -8214,7 +8182,7 @@ var usePreviewModeHotkeys = () => {
|
|
|
8214
8182
|
|
|
8215
8183
|
// lib/use-puck.ts
|
|
8216
8184
|
init_react_import();
|
|
8217
|
-
var
|
|
8185
|
+
var import_react52 = require("react");
|
|
8218
8186
|
var import_zustand6 = require("zustand");
|
|
8219
8187
|
var generateUsePuck = (store) => {
|
|
8220
8188
|
const history = {
|
|
@@ -8247,7 +8215,7 @@ var generateUsePuck = (store) => {
|
|
|
8247
8215
|
};
|
|
8248
8216
|
return storeData;
|
|
8249
8217
|
};
|
|
8250
|
-
var UsePuckStoreContext = (0,
|
|
8218
|
+
var UsePuckStoreContext = (0, import_react52.createContext)(
|
|
8251
8219
|
null
|
|
8252
8220
|
);
|
|
8253
8221
|
var convertToPickedStore = (store) => {
|
|
@@ -8261,12 +8229,12 @@ var convertToPickedStore = (store) => {
|
|
|
8261
8229
|
};
|
|
8262
8230
|
};
|
|
8263
8231
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8264
|
-
const [usePuckStore] = (0,
|
|
8232
|
+
const [usePuckStore] = (0, import_react52.useState)(
|
|
8265
8233
|
() => (0, import_zustand6.createStore)(
|
|
8266
8234
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8267
8235
|
)
|
|
8268
8236
|
);
|
|
8269
|
-
(0,
|
|
8237
|
+
(0, import_react52.useEffect)(() => {
|
|
8270
8238
|
return appStore.subscribe(
|
|
8271
8239
|
(store) => convertToPickedStore(store),
|
|
8272
8240
|
(pickedStore) => {
|
|
@@ -8278,7 +8246,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8278
8246
|
};
|
|
8279
8247
|
function createUsePuck() {
|
|
8280
8248
|
return function usePuck2(selector) {
|
|
8281
|
-
const usePuckApi = (0,
|
|
8249
|
+
const usePuckApi = (0, import_react52.useContext)(UsePuckStoreContext);
|
|
8282
8250
|
if (!usePuckApi) {
|
|
8283
8251
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8284
8252
|
}
|
|
@@ -8290,7 +8258,7 @@ function createUsePuck() {
|
|
|
8290
8258
|
};
|
|
8291
8259
|
}
|
|
8292
8260
|
function usePuck() {
|
|
8293
|
-
(0,
|
|
8261
|
+
(0, import_react52.useEffect)(() => {
|
|
8294
8262
|
console.warn(
|
|
8295
8263
|
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
|
8296
8264
|
);
|
|
@@ -8298,7 +8266,7 @@ function usePuck() {
|
|
|
8298
8266
|
return createUsePuck()((s) => s);
|
|
8299
8267
|
}
|
|
8300
8268
|
function useGetPuck() {
|
|
8301
|
-
const usePuckApi = (0,
|
|
8269
|
+
const usePuckApi = (0, import_react52.useContext)(UsePuckStoreContext);
|
|
8302
8270
|
if (!usePuckApi) {
|
|
8303
8271
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8304
8272
|
}
|
|
@@ -8310,7 +8278,7 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8310
8278
|
|
|
8311
8279
|
// components/Puck/components/Header/index.tsx
|
|
8312
8280
|
init_react_import();
|
|
8313
|
-
var
|
|
8281
|
+
var import_react53 = require("react");
|
|
8314
8282
|
|
|
8315
8283
|
// components/MenuBar/index.tsx
|
|
8316
8284
|
init_react_import();
|
|
@@ -8392,7 +8360,7 @@ var HeaderInner = () => {
|
|
|
8392
8360
|
} = usePropsContext();
|
|
8393
8361
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8394
8362
|
const appStore = useAppStoreApi();
|
|
8395
|
-
const defaultHeaderRender = (0,
|
|
8363
|
+
const defaultHeaderRender = (0, import_react53.useMemo)(() => {
|
|
8396
8364
|
if (renderHeader) {
|
|
8397
8365
|
console.warn(
|
|
8398
8366
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8407,7 +8375,7 @@ var HeaderInner = () => {
|
|
|
8407
8375
|
}
|
|
8408
8376
|
return DefaultOverride;
|
|
8409
8377
|
}, [renderHeader]);
|
|
8410
|
-
const defaultHeaderActionsRender = (0,
|
|
8378
|
+
const defaultHeaderActionsRender = (0, import_react53.useMemo)(() => {
|
|
8411
8379
|
if (renderHeaderActions) {
|
|
8412
8380
|
console.warn(
|
|
8413
8381
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8427,7 +8395,7 @@ var HeaderInner = () => {
|
|
|
8427
8395
|
const CustomHeaderActions = useAppStore(
|
|
8428
8396
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8429
8397
|
);
|
|
8430
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8398
|
+
const [menuOpen, setMenuOpen] = (0, import_react53.useState)(false);
|
|
8431
8399
|
const rootTitle = useAppStore((s) => {
|
|
8432
8400
|
var _a, _b;
|
|
8433
8401
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8437,7 +8405,7 @@ var HeaderInner = () => {
|
|
|
8437
8405
|
const rightSideBarVisible = useAppStore(
|
|
8438
8406
|
(s) => s.state.ui.rightSideBarVisible
|
|
8439
8407
|
);
|
|
8440
|
-
const toggleSidebars = (0,
|
|
8408
|
+
const toggleSidebars = (0, import_react53.useCallback)(
|
|
8441
8409
|
(sidebar) => {
|
|
8442
8410
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8443
8411
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8540,7 +8508,7 @@ var HeaderInner = () => {
|
|
|
8540
8508
|
}
|
|
8541
8509
|
);
|
|
8542
8510
|
};
|
|
8543
|
-
var Header = (0,
|
|
8511
|
+
var Header = (0, import_react53.memo)(HeaderInner);
|
|
8544
8512
|
|
|
8545
8513
|
// components/Puck/index.tsx
|
|
8546
8514
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
@@ -8555,11 +8523,11 @@ var FieldSideBar = () => {
|
|
|
8555
8523
|
);
|
|
8556
8524
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Fields, {}) });
|
|
8557
8525
|
};
|
|
8558
|
-
var propsContext = (0,
|
|
8526
|
+
var propsContext = (0, import_react54.createContext)({});
|
|
8559
8527
|
function PropsProvider(props) {
|
|
8560
8528
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
8561
8529
|
}
|
|
8562
|
-
var usePropsContext = () => (0,
|
|
8530
|
+
var usePropsContext = () => (0, import_react54.useContext)(propsContext);
|
|
8563
8531
|
function PuckProvider({ children }) {
|
|
8564
8532
|
const {
|
|
8565
8533
|
config,
|
|
@@ -8575,14 +8543,14 @@ function PuckProvider({ children }) {
|
|
|
8575
8543
|
metadata,
|
|
8576
8544
|
onAction
|
|
8577
8545
|
} = usePropsContext();
|
|
8578
|
-
const iframe = (0,
|
|
8546
|
+
const iframe = (0, import_react54.useMemo)(
|
|
8579
8547
|
() => __spreadValues({
|
|
8580
8548
|
enabled: true,
|
|
8581
8549
|
waitForStyles: true
|
|
8582
8550
|
}, _iframe),
|
|
8583
8551
|
[_iframe]
|
|
8584
8552
|
);
|
|
8585
|
-
const [generatedAppState] = (0,
|
|
8553
|
+
const [generatedAppState] = (0, import_react54.useState)(() => {
|
|
8586
8554
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8587
8555
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8588
8556
|
let clientUiState = {};
|
|
@@ -8642,7 +8610,7 @@ function PuckProvider({ children }) {
|
|
|
8642
8610
|
return walkAppState(newAppState, config);
|
|
8643
8611
|
});
|
|
8644
8612
|
const { appendData = true } = _initialHistory || {};
|
|
8645
|
-
const [blendedHistories] = (0,
|
|
8613
|
+
const [blendedHistories] = (0, import_react54.useState)(
|
|
8646
8614
|
[
|
|
8647
8615
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8648
8616
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8662,7 +8630,7 @@ function PuckProvider({ children }) {
|
|
|
8662
8630
|
overrides,
|
|
8663
8631
|
plugins
|
|
8664
8632
|
});
|
|
8665
|
-
const generateAppStore = (0,
|
|
8633
|
+
const generateAppStore = (0, import_react54.useCallback)(
|
|
8666
8634
|
(state) => {
|
|
8667
8635
|
return {
|
|
8668
8636
|
state,
|
|
@@ -8686,15 +8654,15 @@ function PuckProvider({ children }) {
|
|
|
8686
8654
|
metadata
|
|
8687
8655
|
]
|
|
8688
8656
|
);
|
|
8689
|
-
const [appStore] = (0,
|
|
8657
|
+
const [appStore] = (0, import_react54.useState)(
|
|
8690
8658
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8691
8659
|
);
|
|
8692
|
-
(0,
|
|
8660
|
+
(0, import_react54.useEffect)(() => {
|
|
8693
8661
|
if (process.env.NODE_ENV !== "production") {
|
|
8694
8662
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8695
8663
|
}
|
|
8696
8664
|
}, [appStore]);
|
|
8697
|
-
(0,
|
|
8665
|
+
(0, import_react54.useEffect)(() => {
|
|
8698
8666
|
const state = appStore.getState().state;
|
|
8699
8667
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8700
8668
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8703,8 +8671,8 @@ function PuckProvider({ children }) {
|
|
|
8703
8671
|
index: initialHistoryIndex,
|
|
8704
8672
|
initialAppState
|
|
8705
8673
|
});
|
|
8706
|
-
const previousData = (0,
|
|
8707
|
-
(0,
|
|
8674
|
+
const previousData = (0, import_react54.useRef)(null);
|
|
8675
|
+
(0, import_react54.useEffect)(() => {
|
|
8708
8676
|
appStore.subscribe(
|
|
8709
8677
|
(s) => s.state.data,
|
|
8710
8678
|
(data) => {
|
|
@@ -8718,7 +8686,7 @@ function PuckProvider({ children }) {
|
|
|
8718
8686
|
}, []);
|
|
8719
8687
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8720
8688
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8721
|
-
(0,
|
|
8689
|
+
(0, import_react54.useEffect)(() => {
|
|
8722
8690
|
const { resolveAndCommitData } = appStore.getState();
|
|
8723
8691
|
resolveAndCommitData();
|
|
8724
8692
|
}, []);
|
|
@@ -8730,7 +8698,7 @@ function PuckLayout({ children }) {
|
|
|
8730
8698
|
dnd,
|
|
8731
8699
|
initialHistory: _initialHistory
|
|
8732
8700
|
} = usePropsContext();
|
|
8733
|
-
const iframe = (0,
|
|
8701
|
+
const iframe = (0, import_react54.useMemo)(
|
|
8734
8702
|
() => __spreadValues({
|
|
8735
8703
|
enabled: true,
|
|
8736
8704
|
waitForStyles: true
|
|
@@ -8743,7 +8711,7 @@ function PuckLayout({ children }) {
|
|
|
8743
8711
|
(s) => s.state.ui.rightSideBarVisible
|
|
8744
8712
|
);
|
|
8745
8713
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8746
|
-
(0,
|
|
8714
|
+
(0, import_react54.useEffect)(() => {
|
|
8747
8715
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8748
8716
|
dispatch({
|
|
8749
8717
|
type: "setUi",
|
|
@@ -8767,17 +8735,17 @@ function PuckLayout({ children }) {
|
|
|
8767
8735
|
};
|
|
8768
8736
|
}, []);
|
|
8769
8737
|
const overrides = useAppStore((s) => s.overrides);
|
|
8770
|
-
const CustomPuck = (0,
|
|
8738
|
+
const CustomPuck = (0, import_react54.useMemo)(
|
|
8771
8739
|
() => overrides.puck || DefaultOverride,
|
|
8772
8740
|
[overrides]
|
|
8773
8741
|
);
|
|
8774
|
-
const [mounted, setMounted] = (0,
|
|
8775
|
-
(0,
|
|
8742
|
+
const [mounted, setMounted] = (0, import_react54.useState)(false);
|
|
8743
|
+
(0, import_react54.useEffect)(() => {
|
|
8776
8744
|
setMounted(true);
|
|
8777
8745
|
}, []);
|
|
8778
8746
|
const ready = useAppStore((s) => s.status === "READY");
|
|
8779
8747
|
useMonitorHotkeys();
|
|
8780
|
-
(0,
|
|
8748
|
+
(0, import_react54.useEffect)(() => {
|
|
8781
8749
|
if (ready && iframe.enabled) {
|
|
8782
8750
|
const frameDoc = getFrame();
|
|
8783
8751
|
if (frameDoc) {
|