@measured/puck 0.21.0-canary.5c9698fb → 0.21.0-canary.8db6528d
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-TRQBUMQH.mjs → chunk-6B7427RN.mjs} +275 -144
- package/dist/{chunk-XYKLHT4R.mjs → chunk-Z3QSQFNS.mjs} +29 -24
- package/dist/index.css +4 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +325 -189
- package/dist/index.mjs +2 -2
- package/dist/no-external.css +4 -3
- package/dist/no-external.d.mts +1 -1
- package/dist/no-external.d.ts +1 -1
- package/dist/no-external.js +325 -189
- package/dist/no-external.mjs +2 -2
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +29 -24
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-C0rGZzWO.d.mts → walk-tree-Cvtjzg9C.d.mts} +3 -2
- package/dist/{walk-tree-C0rGZzWO.d.ts → walk-tree-Cvtjzg9C.d.ts} +3 -2
- package/package.json +2 -2
package/dist/no-external.js
CHANGED
|
@@ -153,6 +153,42 @@ var require_classnames = __commonJS({
|
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
+
// ../../node_modules/fast-deep-equal/index.js
|
|
157
|
+
var require_fast_deep_equal = __commonJS({
|
|
158
|
+
"../../node_modules/fast-deep-equal/index.js"(exports2, module2) {
|
|
159
|
+
"use strict";
|
|
160
|
+
init_react_import();
|
|
161
|
+
module2.exports = function equal(a, b) {
|
|
162
|
+
if (a === b) return true;
|
|
163
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
164
|
+
if (a.constructor !== b.constructor) return false;
|
|
165
|
+
var length, i, keys;
|
|
166
|
+
if (Array.isArray(a)) {
|
|
167
|
+
length = a.length;
|
|
168
|
+
if (length != b.length) return false;
|
|
169
|
+
for (i = length; i-- !== 0; )
|
|
170
|
+
if (!equal(a[i], b[i])) return false;
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
174
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
175
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
176
|
+
keys = Object.keys(a);
|
|
177
|
+
length = keys.length;
|
|
178
|
+
if (length !== Object.keys(b).length) return false;
|
|
179
|
+
for (i = length; i-- !== 0; )
|
|
180
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
181
|
+
for (i = length; i-- !== 0; ) {
|
|
182
|
+
var key = keys[i];
|
|
183
|
+
if (!equal(a[key], b[key])) return false;
|
|
184
|
+
}
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
return a !== a && b !== b;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
156
192
|
// bundle/no-external.ts
|
|
157
193
|
var no_external_exports = {};
|
|
158
194
|
__export(no_external_exports, {
|
|
@@ -832,34 +868,39 @@ var walkField = ({
|
|
|
832
868
|
config,
|
|
833
869
|
recurseSlots = false
|
|
834
870
|
}) => {
|
|
835
|
-
var _a, _b, _c;
|
|
871
|
+
var _a, _b, _c, _d;
|
|
836
872
|
const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
|
|
837
873
|
const map = mappers[fieldType];
|
|
838
874
|
if (map && fieldType === "slot") {
|
|
839
875
|
const content = value || [];
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
876
|
+
let mappedContent = content;
|
|
877
|
+
if (recurseSlots) {
|
|
878
|
+
for (let i = 0; i < content.length; i++) {
|
|
879
|
+
const el = content[i];
|
|
880
|
+
const componentConfig = config.components[el.type];
|
|
881
|
+
if (!componentConfig || !el.props) {
|
|
882
|
+
continue;
|
|
883
|
+
}
|
|
884
|
+
const fields2 = (_b = componentConfig.fields) != null ? _b : {};
|
|
885
|
+
mappedContent.push(
|
|
886
|
+
walkField({
|
|
887
|
+
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
|
888
|
+
fields: fields2,
|
|
889
|
+
mappers,
|
|
890
|
+
id: el.props.id,
|
|
891
|
+
config,
|
|
892
|
+
recurseSlots
|
|
893
|
+
})
|
|
894
|
+
);
|
|
845
895
|
}
|
|
846
|
-
|
|
847
|
-
return walkField({
|
|
848
|
-
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
|
849
|
-
fields: fields2,
|
|
850
|
-
mappers,
|
|
851
|
-
id: el.props.id,
|
|
852
|
-
config,
|
|
853
|
-
recurseSlots
|
|
854
|
-
});
|
|
855
|
-
}) : content;
|
|
896
|
+
}
|
|
856
897
|
if (containsPromise(mappedContent)) {
|
|
857
898
|
return Promise.all(mappedContent);
|
|
858
899
|
}
|
|
859
900
|
return map({
|
|
860
901
|
value: mappedContent,
|
|
861
902
|
parentId: id,
|
|
862
|
-
propName:
|
|
903
|
+
propName: propPath,
|
|
863
904
|
field: fields[propKey],
|
|
864
905
|
propPath
|
|
865
906
|
});
|
|
@@ -874,7 +915,7 @@ var walkField = ({
|
|
|
874
915
|
}
|
|
875
916
|
if (value && typeof value === "object") {
|
|
876
917
|
if (Array.isArray(value)) {
|
|
877
|
-
const arrayFields = ((
|
|
918
|
+
const arrayFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "array" ? fields[propKey].arrayFields : null;
|
|
878
919
|
if (!arrayFields) return value;
|
|
879
920
|
const newValue = value.map(
|
|
880
921
|
(el, idx) => walkField({
|
|
@@ -895,7 +936,7 @@ var walkField = ({
|
|
|
895
936
|
} else if ("$$typeof" in value) {
|
|
896
937
|
return value;
|
|
897
938
|
} else {
|
|
898
|
-
const objectFields = ((
|
|
939
|
+
const objectFields = ((_d = fields[propKey]) == null ? void 0 : _d.type) === "object" ? fields[propKey].objectFields : fields;
|
|
899
940
|
return walkObject({
|
|
900
941
|
value,
|
|
901
942
|
fields: objectFields,
|
|
@@ -1730,7 +1771,9 @@ var keyCodeMap = {
|
|
|
1730
1771
|
KeyW: "w",
|
|
1731
1772
|
KeyX: "x",
|
|
1732
1773
|
KeyY: "y",
|
|
1733
|
-
KeyZ: "z"
|
|
1774
|
+
KeyZ: "z",
|
|
1775
|
+
Delete: "delete",
|
|
1776
|
+
Backspace: "backspace"
|
|
1734
1777
|
};
|
|
1735
1778
|
var useHotkeyStore = (0, import_zustand.create)()(
|
|
1736
1779
|
(0, import_middleware.subscribeWithSelector)((set) => ({
|
|
@@ -1754,8 +1797,10 @@ var monitorHotkeys = (doc) => {
|
|
|
1754
1797
|
([key2, value]) => value === !!combo[key2]
|
|
1755
1798
|
);
|
|
1756
1799
|
if (conditionMet) {
|
|
1757
|
-
e
|
|
1758
|
-
|
|
1800
|
+
const handled = cb(e);
|
|
1801
|
+
if (handled !== false) {
|
|
1802
|
+
e.preventDefault();
|
|
1803
|
+
}
|
|
1759
1804
|
}
|
|
1760
1805
|
});
|
|
1761
1806
|
if (key !== "meta" && key !== "ctrl" && key !== "shift") {
|
|
@@ -1979,7 +2024,7 @@ var flattenData = (state, config) => {
|
|
|
1979
2024
|
(content) => content,
|
|
1980
2025
|
(item) => {
|
|
1981
2026
|
data.push(item);
|
|
1982
|
-
return
|
|
2027
|
+
return item;
|
|
1983
2028
|
}
|
|
1984
2029
|
);
|
|
1985
2030
|
return data;
|
|
@@ -1987,13 +2032,13 @@ var flattenData = (state, config) => {
|
|
|
1987
2032
|
|
|
1988
2033
|
// lib/get-changed.ts
|
|
1989
2034
|
init_react_import();
|
|
1990
|
-
var
|
|
2035
|
+
var import_fast_equals = require("fast-equals");
|
|
1991
2036
|
var getChanged = (newItem, oldItem) => {
|
|
1992
2037
|
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
1993
2038
|
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
1994
2039
|
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
1995
2040
|
return __spreadProps(__spreadValues({}, acc), {
|
|
1996
|
-
[item]: !(0,
|
|
2041
|
+
[item]: !(0, import_fast_equals.deepEqual)(oldItemProps[item], newItemProps[item])
|
|
1997
2042
|
});
|
|
1998
2043
|
}, {}) : {};
|
|
1999
2044
|
};
|
|
@@ -2148,6 +2193,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2148
2193
|
(reset) => __async(void 0, null, function* () {
|
|
2149
2194
|
var _a, _b;
|
|
2150
2195
|
const { fields, lastResolvedData } = appStore.getState().fields;
|
|
2196
|
+
const metadata = appStore.getState().metadata;
|
|
2151
2197
|
const nodes = appStore.getState().state.indexes.nodes;
|
|
2152
2198
|
const node = nodes[id || "root"];
|
|
2153
2199
|
const componentData = node == null ? void 0 : node.data;
|
|
@@ -2177,6 +2223,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2177
2223
|
changed,
|
|
2178
2224
|
fields: defaultFields2,
|
|
2179
2225
|
lastFields,
|
|
2226
|
+
metadata: __spreadValues(__spreadValues({}, metadata), componentConfig.metadata),
|
|
2180
2227
|
lastData,
|
|
2181
2228
|
appState: makeStatePublic(state),
|
|
2182
2229
|
parent
|
|
@@ -2212,7 +2259,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2212
2259
|
|
|
2213
2260
|
// lib/resolve-component-data.ts
|
|
2214
2261
|
init_react_import();
|
|
2215
|
-
var
|
|
2262
|
+
var import_fast_equals2 = require("fast-equals");
|
|
2216
2263
|
var cache = { lastChange: {} };
|
|
2217
2264
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
2218
2265
|
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
@@ -2221,7 +2268,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
|
2221
2268
|
const id = "id" in item.props ? item.props.id : "root";
|
|
2222
2269
|
if (shouldRunResolver) {
|
|
2223
2270
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
|
2224
|
-
if (item && (0,
|
|
2271
|
+
if (trigger !== "force" && item && (0, import_fast_equals2.deepEqual)(item, oldItem)) {
|
|
2225
2272
|
return { node: resolved, didChange: false };
|
|
2226
2273
|
}
|
|
2227
2274
|
const changed = getChanged(item, oldItem);
|
|
@@ -2271,7 +2318,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
|
2271
2318
|
};
|
|
2272
2319
|
return {
|
|
2273
2320
|
node: itemWithResolvedChildren,
|
|
2274
|
-
didChange: !(0,
|
|
2321
|
+
didChange: !(0, import_fast_equals2.deepEqual)(item, itemWithResolvedChildren)
|
|
2275
2322
|
};
|
|
2276
2323
|
});
|
|
2277
2324
|
|
|
@@ -3219,8 +3266,7 @@ var NestedFieldProvider = ({
|
|
|
3219
3266
|
name,
|
|
3220
3267
|
subName,
|
|
3221
3268
|
wildcardName = name,
|
|
3222
|
-
readOnlyFields
|
|
3223
|
-
value
|
|
3269
|
+
readOnlyFields
|
|
3224
3270
|
}) => {
|
|
3225
3271
|
const subPath = `${name}.${subName}`;
|
|
3226
3272
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
|
@@ -3243,7 +3289,7 @@ var NestedFieldProvider = ({
|
|
|
3243
3289
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3244
3290
|
NestedFieldContext.Provider,
|
|
3245
3291
|
{
|
|
3246
|
-
value: { readOnlyFields: subReadOnlyFields, localName: subName
|
|
3292
|
+
value: { readOnlyFields: subReadOnlyFields, localName: subName },
|
|
3247
3293
|
children
|
|
3248
3294
|
}
|
|
3249
3295
|
);
|
|
@@ -3276,15 +3322,16 @@ var SubFieldInternal = ({
|
|
|
3276
3322
|
subName,
|
|
3277
3323
|
localName,
|
|
3278
3324
|
onChange,
|
|
3279
|
-
forceReadOnly
|
|
3325
|
+
forceReadOnly,
|
|
3326
|
+
value
|
|
3280
3327
|
}) => {
|
|
3281
3328
|
const indexName = typeof index !== "undefined" ? `${name}[${index}]` : name;
|
|
3282
|
-
const subPath = `${indexName}.${subName}
|
|
3329
|
+
const subPath = name ? `${indexName}.${subName}` : subName;
|
|
3283
3330
|
const localIndexName = typeof index !== "undefined" ? `${localName}[${index}]` : localName != null ? localName : subName;
|
|
3284
3331
|
const localWildcardName = typeof index !== "undefined" ? `${localName}[*]` : localName;
|
|
3285
3332
|
const localSubPath = `${localIndexName}.${subName}`;
|
|
3286
3333
|
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
|
3287
|
-
const { readOnlyFields
|
|
3334
|
+
const { readOnlyFields } = useNestedFieldContext();
|
|
3288
3335
|
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
|
3289
3336
|
const label = field.label || subName;
|
|
3290
3337
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
@@ -3308,7 +3355,6 @@ var SubFieldInternal = ({
|
|
|
3308
3355
|
onChange: (val, ui) => {
|
|
3309
3356
|
onChange(val, ui, subName);
|
|
3310
3357
|
},
|
|
3311
|
-
provideValue: typeof value !== "undefined",
|
|
3312
3358
|
value: typeof value !== "undefined" ? getDeep(value, subPath) : void 0
|
|
3313
3359
|
}
|
|
3314
3360
|
)
|
|
@@ -3319,7 +3365,7 @@ var SubFieldInternal = ({
|
|
|
3319
3365
|
var SubField = (0, import_react14.memo)(SubFieldInternal);
|
|
3320
3366
|
|
|
3321
3367
|
// components/AutoField/fields/ArrayField/index.tsx
|
|
3322
|
-
var
|
|
3368
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
|
3323
3369
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3324
3370
|
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
|
3325
3371
|
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
|
@@ -3336,14 +3382,15 @@ var ArrayFieldItemInternal = ({
|
|
|
3336
3382
|
actions,
|
|
3337
3383
|
name,
|
|
3338
3384
|
localName,
|
|
3339
|
-
getValue
|
|
3385
|
+
getValue,
|
|
3386
|
+
value
|
|
3340
3387
|
}) => {
|
|
3341
3388
|
const isExpanded = useAppStore((s) => {
|
|
3342
3389
|
var _a;
|
|
3343
3390
|
return ((_a = s.state.ui.arrayState[arrayId]) == null ? void 0 : _a.openId) === id;
|
|
3344
3391
|
});
|
|
3345
3392
|
const itemSummary = useAppStore(() => {
|
|
3346
|
-
const data = getValue();
|
|
3393
|
+
const data = value != null ? value : getValue();
|
|
3347
3394
|
if (data && field.getItemSummary) {
|
|
3348
3395
|
return field.getItemSummary(data, index);
|
|
3349
3396
|
}
|
|
@@ -3394,7 +3441,8 @@ var ArrayFieldItemInternal = ({
|
|
|
3394
3441
|
index,
|
|
3395
3442
|
field: subField,
|
|
3396
3443
|
onChange,
|
|
3397
|
-
forceReadOnly: !canEdit
|
|
3444
|
+
forceReadOnly: !canEdit,
|
|
3445
|
+
value: value == null ? void 0 : value[index]
|
|
3398
3446
|
},
|
|
3399
3447
|
subName
|
|
3400
3448
|
);
|
|
@@ -3419,16 +3467,19 @@ var ArrayField = ({
|
|
|
3419
3467
|
const appStoreApi = useAppStoreApi();
|
|
3420
3468
|
const { localName = name } = useNestedFieldContext();
|
|
3421
3469
|
const getValue = (0, import_react15.useCallback)(() => {
|
|
3422
|
-
var _a;
|
|
3470
|
+
var _a, _b;
|
|
3423
3471
|
if (typeof value !== "undefined") return value;
|
|
3424
3472
|
const { selectedItem } = appStoreApi.getState();
|
|
3425
3473
|
const props = (_a = name ? selectedItem == null ? void 0 : selectedItem.props : {}) != null ? _a : {};
|
|
3426
|
-
return name ? getDeep(props, name) : [];
|
|
3474
|
+
return name ? (_b = getDeep(props, name)) != null ? _b : [] : [];
|
|
3427
3475
|
}, [appStoreApi, name, value]);
|
|
3428
3476
|
const getArrayState = (0, import_react15.useCallback)(() => {
|
|
3477
|
+
var _a;
|
|
3429
3478
|
const { state } = appStoreApi.getState();
|
|
3479
|
+
const thisState = state.ui.arrayState[id];
|
|
3480
|
+
if ((_a = thisState == null ? void 0 : thisState.items) == null ? void 0 : _a.length) return thisState;
|
|
3430
3481
|
const value2 = getValue();
|
|
3431
|
-
return
|
|
3482
|
+
return {
|
|
3432
3483
|
items: Array.from(value2 || []).map((item, idx) => {
|
|
3433
3484
|
return {
|
|
3434
3485
|
_originalIndex: idx,
|
|
@@ -3438,11 +3489,12 @@ var ArrayField = ({
|
|
|
3438
3489
|
}),
|
|
3439
3490
|
openId: ""
|
|
3440
3491
|
};
|
|
3441
|
-
}, [appStoreApi]);
|
|
3492
|
+
}, [appStoreApi, id, getValue]);
|
|
3442
3493
|
const numItems = useAppStore((s) => {
|
|
3443
3494
|
var _a, _b;
|
|
3444
|
-
const
|
|
3445
|
-
|
|
3495
|
+
const { selectedItem } = s;
|
|
3496
|
+
const props = (_a = name ? selectedItem == null ? void 0 : selectedItem.props : {}) != null ? _a : {};
|
|
3497
|
+
return (name ? (_b = getDeep(props, name)) != null ? _b : [] : []).length;
|
|
3446
3498
|
});
|
|
3447
3499
|
const [mirror, setLocalState] = (0, import_react15.useState)(getArrayState());
|
|
3448
3500
|
const appStore = useAppStoreApi();
|
|
@@ -3530,7 +3582,25 @@ var ArrayField = ({
|
|
|
3530
3582
|
},
|
|
3531
3583
|
[regenerateArrayState, setUi, mapArrayStateToUi, onChange, setLocalState]
|
|
3532
3584
|
);
|
|
3585
|
+
const reset = (0, import_react15.useCallback)(
|
|
3586
|
+
(value2) => {
|
|
3587
|
+
valueRef.current = value2;
|
|
3588
|
+
const newArrayState = regenerateArrayState(valueRef.current);
|
|
3589
|
+
if (!(0, import_fast_deep_equal.default)(newArrayState, getArrayState())) {
|
|
3590
|
+
setUi(mapArrayStateToUi(newArrayState), false);
|
|
3591
|
+
setLocalState(newArrayState);
|
|
3592
|
+
}
|
|
3593
|
+
},
|
|
3594
|
+
[
|
|
3595
|
+
regenerateArrayState,
|
|
3596
|
+
mapArrayStateToUi,
|
|
3597
|
+
setUi,
|
|
3598
|
+
setLocalState,
|
|
3599
|
+
getArrayState
|
|
3600
|
+
]
|
|
3601
|
+
);
|
|
3533
3602
|
(0, import_react15.useEffect)(() => {
|
|
3603
|
+
if (value) return;
|
|
3534
3604
|
return appStoreApi.subscribe(
|
|
3535
3605
|
({ selectedItem }) => {
|
|
3536
3606
|
var _a;
|
|
@@ -3538,15 +3608,15 @@ var ArrayField = ({
|
|
|
3538
3608
|
return name ? getDeep(props, name) : [];
|
|
3539
3609
|
},
|
|
3540
3610
|
(val) => {
|
|
3541
|
-
if (!(0,
|
|
3542
|
-
|
|
3543
|
-
const newArrayState = regenerateArrayState(valueRef.current);
|
|
3544
|
-
setUi(mapArrayStateToUi(newArrayState), false);
|
|
3545
|
-
setLocalState(newArrayState);
|
|
3611
|
+
if (!(0, import_fast_deep_equal.default)(val, valueRef.current)) {
|
|
3612
|
+
reset(val);
|
|
3546
3613
|
}
|
|
3547
3614
|
}
|
|
3548
3615
|
);
|
|
3549
|
-
}, [appStoreApi]);
|
|
3616
|
+
}, [appStoreApi, name, value]);
|
|
3617
|
+
(0, import_react15.useEffect)(() => {
|
|
3618
|
+
reset(getValue());
|
|
3619
|
+
}, [reset, getValue, name]);
|
|
3550
3620
|
if (field.type !== "array" || !field.arrayFields) {
|
|
3551
3621
|
return null;
|
|
3552
3622
|
}
|
|
@@ -3620,6 +3690,7 @@ var ArrayField = ({
|
|
|
3620
3690
|
field,
|
|
3621
3691
|
name,
|
|
3622
3692
|
localName,
|
|
3693
|
+
value,
|
|
3623
3694
|
getValue: () => {
|
|
3624
3695
|
const value2 = getValue();
|
|
3625
3696
|
return value2[_currentIndex];
|
|
@@ -4108,7 +4179,6 @@ var ExternalInput = ({
|
|
|
4108
4179
|
id: `external_field_${fieldName}_filter`,
|
|
4109
4180
|
label: filterField.label || fieldName,
|
|
4110
4181
|
value: filters[fieldName],
|
|
4111
|
-
provideValue: true,
|
|
4112
4182
|
onChange: (value2) => {
|
|
4113
4183
|
setFilters((filters2) => {
|
|
4114
4184
|
const newFilters = __spreadProps(__spreadValues({}, filters2), {
|
|
@@ -4397,7 +4467,7 @@ var ObjectField = ({
|
|
|
4397
4467
|
if (typeof value !== "undefined") return value;
|
|
4398
4468
|
const { selectedItem } = appStoreApi.getState();
|
|
4399
4469
|
const props = (_a = name ? selectedItem == null ? void 0 : selectedItem.props : {}) != null ? _a : {};
|
|
4400
|
-
return name ? getDeep(props, name) :
|
|
4470
|
+
return name ? getDeep(props, name) : {};
|
|
4401
4471
|
}, [appStoreApi, name, value]);
|
|
4402
4472
|
if (field.type !== "object" || !field.objectFields) {
|
|
4403
4473
|
return null;
|
|
@@ -4421,11 +4491,10 @@ var ObjectField = ({
|
|
|
4421
4491
|
localName,
|
|
4422
4492
|
field: subField,
|
|
4423
4493
|
forceReadOnly: !canEdit,
|
|
4494
|
+
value,
|
|
4424
4495
|
onChange: (subValue, ui, subName2) => {
|
|
4425
4496
|
const value2 = getValue();
|
|
4426
|
-
|
|
4427
|
-
onChange(__spreadProps(__spreadValues({}, value2), { [subName2]: subValue }), ui);
|
|
4428
|
-
}
|
|
4497
|
+
onChange(__spreadProps(__spreadValues({}, value2), { [subName2]: subValue }), ui);
|
|
4429
4498
|
}
|
|
4430
4499
|
},
|
|
4431
4500
|
subPath
|
|
@@ -4506,18 +4575,13 @@ var defaultFields = {
|
|
|
4506
4575
|
text: DefaultField,
|
|
4507
4576
|
number: DefaultField
|
|
4508
4577
|
};
|
|
4509
|
-
function AutoFieldInternal(
|
|
4510
|
-
var
|
|
4511
|
-
provideValue
|
|
4512
|
-
} = _b, props = __objRest(_b, [
|
|
4513
|
-
"provideValue"
|
|
4514
|
-
]);
|
|
4515
|
-
var _a2;
|
|
4578
|
+
function AutoFieldInternal(props) {
|
|
4579
|
+
var _a;
|
|
4516
4580
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4517
4581
|
const overrides = useAppStore((s) => s.overrides);
|
|
4518
4582
|
const readOnly = useAppStore((0, import_shallow.useShallow)((s) => {
|
|
4519
|
-
var
|
|
4520
|
-
return (
|
|
4583
|
+
var _a2;
|
|
4584
|
+
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
|
4521
4585
|
}));
|
|
4522
4586
|
const nestedFieldContext = (0, import_react22.useContext)(NestedFieldContext);
|
|
4523
4587
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
|
@@ -4528,10 +4592,10 @@ function AutoFieldInternal(_a) {
|
|
|
4528
4592
|
const resolvedId = id || defaultId;
|
|
4529
4593
|
const render = (0, import_react22.useMemo)(
|
|
4530
4594
|
() => {
|
|
4531
|
-
var
|
|
4595
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
4532
4596
|
return __spreadProps(__spreadValues({}, overrides.fieldTypes), {
|
|
4533
|
-
array: ((
|
|
4534
|
-
external: ((
|
|
4597
|
+
array: ((_a2 = overrides.fieldTypes) == null ? void 0 : _a2.array) || defaultFields.array,
|
|
4598
|
+
external: ((_b = overrides.fieldTypes) == null ? void 0 : _b.external) || defaultFields.external,
|
|
4535
4599
|
object: ((_c = overrides.fieldTypes) == null ? void 0 : _c.object) || defaultFields.object,
|
|
4536
4600
|
select: ((_d = overrides.fieldTypes) == null ? void 0 : _d.select) || defaultFields.select,
|
|
4537
4601
|
textarea: ((_e = overrides.fieldTypes) == null ? void 0 : _e.textarea) || defaultFields.textarea,
|
|
@@ -4607,9 +4671,7 @@ function AutoFieldInternal(_a) {
|
|
|
4607
4671
|
{
|
|
4608
4672
|
value: {
|
|
4609
4673
|
readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
|
|
4610
|
-
localName: (
|
|
4611
|
-
value: provideValue && mergedProps.name ? { [mergedProps.name]: mergedProps.value } : void 0
|
|
4612
|
-
// Optionally provide value if this is used outside of app fields (i.e. external field filters)
|
|
4674
|
+
localName: (_a = nestedFieldContext.localName) != null ? _a : mergedProps.name
|
|
4613
4675
|
},
|
|
4614
4676
|
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4615
4677
|
"div",
|
|
@@ -4688,13 +4750,7 @@ function AutoField(props) {
|
|
|
4688
4750
|
if (props.field.type === "slot") {
|
|
4689
4751
|
return null;
|
|
4690
4752
|
}
|
|
4691
|
-
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4692
|
-
AutoFieldInternal,
|
|
4693
|
-
__spreadProps(__spreadValues({}, props), {
|
|
4694
|
-
Label: DefaultLabel,
|
|
4695
|
-
provideValue: true
|
|
4696
|
-
})
|
|
4697
|
-
);
|
|
4753
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
|
4698
4754
|
}
|
|
4699
4755
|
|
|
4700
4756
|
// components/Drawer/index.tsx
|
|
@@ -5806,7 +5862,7 @@ var registerOverlayPortal = (el, opts = {}) => {
|
|
|
5806
5862
|
|
|
5807
5863
|
// css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css#css-module
|
|
5808
5864
|
init_react_import();
|
|
5809
|
-
var styles_module_default13 = { "InlineTextField": "
|
|
5865
|
+
var styles_module_default13 = { "InlineTextField": "_InlineTextField_1xph6_1" };
|
|
5810
5866
|
|
|
5811
5867
|
// lib/data/set-deep.ts
|
|
5812
5868
|
init_react_import();
|
|
@@ -5888,7 +5944,11 @@ var InlineTextFieldInternal = ({
|
|
|
5888
5944
|
const index = (_a2 = appStore2.state.indexes.zones[zoneCompound]) == null ? void 0 : _a2.contentIds.indexOf(
|
|
5889
5945
|
componentId
|
|
5890
5946
|
);
|
|
5891
|
-
|
|
5947
|
+
let value2 = e.target.innerText;
|
|
5948
|
+
if (disableLineBreaks) {
|
|
5949
|
+
value2 = value2.replaceAll(/\n/gm, "");
|
|
5950
|
+
}
|
|
5951
|
+
const newProps = setDeep(node.data.props, propPath, value2);
|
|
5892
5952
|
const resolvedData = yield appStore2.resolveComponentData(
|
|
5893
5953
|
__spreadProps(__spreadValues({}, node.data), { props: newProps }),
|
|
5894
5954
|
"replace"
|
|
@@ -5907,7 +5967,7 @@ var InlineTextFieldInternal = ({
|
|
|
5907
5967
|
cleanupPortal == null ? void 0 : cleanupPortal();
|
|
5908
5968
|
};
|
|
5909
5969
|
}
|
|
5910
|
-
}, [appStoreApi, ref.current, value]);
|
|
5970
|
+
}, [appStoreApi, ref.current, value, disableLineBreaks]);
|
|
5911
5971
|
const [isHovering, setIsHovering] = (0, import_react35.useState)(false);
|
|
5912
5972
|
const [isFocused, setIsFocused] = (0, import_react35.useState)(false);
|
|
5913
5973
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
@@ -7292,7 +7352,7 @@ Drawer.Item = DrawerItem;
|
|
|
7292
7352
|
|
|
7293
7353
|
// components/Puck/index.tsx
|
|
7294
7354
|
init_react_import();
|
|
7295
|
-
var
|
|
7355
|
+
var import_react63 = require("react");
|
|
7296
7356
|
|
|
7297
7357
|
// components/Puck/components/Fields/index.tsx
|
|
7298
7358
|
init_react_import();
|
|
@@ -7525,7 +7585,13 @@ var useComponentList = () => {
|
|
|
7525
7585
|
let _componentList;
|
|
7526
7586
|
_componentList = Object.entries(uiComponentList).map(
|
|
7527
7587
|
([categoryKey, category]) => {
|
|
7528
|
-
if (
|
|
7588
|
+
if (!category.components) {
|
|
7589
|
+
return null;
|
|
7590
|
+
}
|
|
7591
|
+
category.components.forEach((componentName) => {
|
|
7592
|
+
matchedComponents.push(componentName);
|
|
7593
|
+
});
|
|
7594
|
+
if (category.visible === false) {
|
|
7529
7595
|
return null;
|
|
7530
7596
|
}
|
|
7531
7597
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
@@ -7535,7 +7601,6 @@ var useComponentList = () => {
|
|
|
7535
7601
|
title: category.title || categoryKey,
|
|
7536
7602
|
children: category.components.map((componentName, i) => {
|
|
7537
7603
|
var _a2;
|
|
7538
|
-
matchedComponents.push(componentName);
|
|
7539
7604
|
const componentConf = config.components[componentName] || {};
|
|
7540
7605
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
7541
7606
|
ComponentList.Item,
|
|
@@ -8414,11 +8479,11 @@ function useGetPuck() {
|
|
|
8414
8479
|
}
|
|
8415
8480
|
|
|
8416
8481
|
// components/Puck/index.tsx
|
|
8417
|
-
var
|
|
8482
|
+
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
|
8418
8483
|
|
|
8419
8484
|
// components/Puck/components/Layout/index.tsx
|
|
8420
8485
|
init_react_import();
|
|
8421
|
-
var
|
|
8486
|
+
var import_react62 = require("react");
|
|
8422
8487
|
|
|
8423
8488
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Layout/styles.module.css#css-module
|
|
8424
8489
|
init_react_import();
|
|
@@ -8902,88 +8967,98 @@ var ViewportControls = ({
|
|
|
8902
8967
|
setActiveViewport(uiViewports.current.width);
|
|
8903
8968
|
}, [uiViewports.current]);
|
|
8904
8969
|
const [isExpanded, setIsExpanded] = (0, import_react56.useState)(false);
|
|
8905
|
-
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
ActionButton,
|
|
8923
|
-
{
|
|
8924
|
-
title: "Zoom viewport out",
|
|
8925
|
-
disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
|
|
8926
|
-
onClick: (e) => {
|
|
8927
|
-
e.stopPropagation();
|
|
8928
|
-
onZoom(
|
|
8929
|
-
zoomOptions[Math.max(
|
|
8930
|
-
zoomOptions.findIndex((option) => option.value === zoom) - 1,
|
|
8931
|
-
0
|
|
8932
|
-
)].value
|
|
8933
|
-
);
|
|
8934
|
-
},
|
|
8935
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ZoomOut, { size: 16 })
|
|
8936
|
-
}
|
|
8937
|
-
),
|
|
8938
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8939
|
-
ActionButton,
|
|
8940
|
-
{
|
|
8941
|
-
title: "Zoom viewport in",
|
|
8942
|
-
disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
|
|
8943
|
-
onClick: (e) => {
|
|
8944
|
-
e.stopPropagation();
|
|
8945
|
-
onZoom(
|
|
8946
|
-
zoomOptions[Math.min(
|
|
8947
|
-
zoomOptions.findIndex((option) => option.value === zoom) + 1,
|
|
8948
|
-
zoomOptions.length - 1
|
|
8949
|
-
)].value
|
|
8950
|
-
);
|
|
8951
|
-
},
|
|
8952
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ZoomIn, { size: 16 })
|
|
8953
|
-
}
|
|
8954
|
-
),
|
|
8955
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName30("zoom"), children: [
|
|
8956
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName30("divider") }),
|
|
8957
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8958
|
-
"select",
|
|
8959
|
-
{
|
|
8960
|
-
className: getClassName30("zoomSelect"),
|
|
8961
|
-
value: zoom.toString(),
|
|
8962
|
-
onChange: (e) => {
|
|
8963
|
-
onZoom(parseFloat(e.currentTarget.value));
|
|
8970
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
8971
|
+
"div",
|
|
8972
|
+
{
|
|
8973
|
+
className: getClassName30({ isExpanded, fullScreen }),
|
|
8974
|
+
suppressHydrationWarning: true,
|
|
8975
|
+
children: [
|
|
8976
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName30("actions"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName30("actionsInner"), children: [
|
|
8977
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8978
|
+
ActionButton,
|
|
8979
|
+
{
|
|
8980
|
+
title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
|
|
8981
|
+
onClick: () => {
|
|
8982
|
+
setActiveViewport(viewport.width);
|
|
8983
|
+
onViewportChange(viewport);
|
|
8984
|
+
},
|
|
8985
|
+
isActive: activeViewport === viewport.width,
|
|
8986
|
+
children: typeof viewport.icon === "string" ? icons[viewport.icon] || viewport.icon : viewport.icon || icons.Smartphone
|
|
8964
8987
|
},
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8988
|
+
i
|
|
8989
|
+
)),
|
|
8990
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName30("divider") }),
|
|
8991
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8992
|
+
ActionButton,
|
|
8993
|
+
{
|
|
8994
|
+
title: "Zoom viewport out",
|
|
8995
|
+
disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
|
|
8996
|
+
onClick: (e) => {
|
|
8997
|
+
e.stopPropagation();
|
|
8998
|
+
onZoom(
|
|
8999
|
+
zoomOptions[Math.max(
|
|
9000
|
+
zoomOptions.findIndex((option) => option.value === zoom) - 1,
|
|
9001
|
+
0
|
|
9002
|
+
)].value
|
|
9003
|
+
);
|
|
9004
|
+
},
|
|
9005
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ZoomOut, { size: 16 })
|
|
9006
|
+
}
|
|
9007
|
+
),
|
|
9008
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
9009
|
+
ActionButton,
|
|
9010
|
+
{
|
|
9011
|
+
title: "Zoom viewport in",
|
|
9012
|
+
disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
|
|
9013
|
+
onClick: (e) => {
|
|
9014
|
+
e.stopPropagation();
|
|
9015
|
+
onZoom(
|
|
9016
|
+
zoomOptions[Math.min(
|
|
9017
|
+
zoomOptions.findIndex((option) => option.value === zoom) + 1,
|
|
9018
|
+
zoomOptions.length - 1
|
|
9019
|
+
)].value
|
|
9020
|
+
);
|
|
8970
9021
|
},
|
|
8971
|
-
|
|
8972
|
-
|
|
9022
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ZoomIn, { size: 16 })
|
|
9023
|
+
}
|
|
9024
|
+
),
|
|
9025
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName30("zoom"), children: [
|
|
9026
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName30("divider") }),
|
|
9027
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
9028
|
+
"select",
|
|
9029
|
+
{
|
|
9030
|
+
className: getClassName30("zoomSelect"),
|
|
9031
|
+
value: zoom.toString(),
|
|
9032
|
+
onClick: (e) => {
|
|
9033
|
+
e.stopPropagation();
|
|
9034
|
+
},
|
|
9035
|
+
onChange: (e) => {
|
|
9036
|
+
onZoom(parseFloat(e.currentTarget.value));
|
|
9037
|
+
},
|
|
9038
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
9039
|
+
"option",
|
|
9040
|
+
{
|
|
9041
|
+
value: option.value,
|
|
9042
|
+
label: option.label
|
|
9043
|
+
},
|
|
9044
|
+
option.label
|
|
9045
|
+
))
|
|
9046
|
+
}
|
|
9047
|
+
)
|
|
9048
|
+
] })
|
|
9049
|
+
] }) }),
|
|
9050
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
9051
|
+
"button",
|
|
9052
|
+
{
|
|
9053
|
+
className: getClassName30("toggleButton"),
|
|
9054
|
+
title: "Toggle viewport menu",
|
|
9055
|
+
onClick: () => setIsExpanded((s) => !s),
|
|
9056
|
+
children: isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(X, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Monitor, { size: 16 })
|
|
8973
9057
|
}
|
|
8974
9058
|
)
|
|
8975
|
-
]
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
"button",
|
|
8979
|
-
{
|
|
8980
|
-
className: getClassName30("toggleButton"),
|
|
8981
|
-
title: "Toggle viewport menu",
|
|
8982
|
-
onClick: () => setIsExpanded((s) => !s),
|
|
8983
|
-
children: isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(X, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Monitor, { size: 16 })
|
|
8984
|
-
}
|
|
8985
|
-
)
|
|
8986
|
-
] });
|
|
9059
|
+
]
|
|
9060
|
+
}
|
|
9061
|
+
);
|
|
8987
9062
|
};
|
|
8988
9063
|
|
|
8989
9064
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
@@ -9153,8 +9228,7 @@ var Canvas = () => {
|
|
|
9153
9228
|
zoom: zoomConfig.zoom
|
|
9154
9229
|
});
|
|
9155
9230
|
const newUi = {
|
|
9156
|
-
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
9157
|
-
itemSelector: null
|
|
9231
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
9158
9232
|
};
|
|
9159
9233
|
setUi(newUi);
|
|
9160
9234
|
if (ZOOM_ON_CHANGE) {
|
|
@@ -9396,6 +9470,67 @@ var Sidebar = ({
|
|
|
9396
9470
|
] });
|
|
9397
9471
|
};
|
|
9398
9472
|
|
|
9473
|
+
// lib/use-delete-hotkeys.ts
|
|
9474
|
+
init_react_import();
|
|
9475
|
+
var import_react61 = require("react");
|
|
9476
|
+
var isElementVisible = (element) => {
|
|
9477
|
+
let current = element;
|
|
9478
|
+
while (current && current !== document.body) {
|
|
9479
|
+
const style = window.getComputedStyle(current);
|
|
9480
|
+
if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || current.getAttribute("aria-hidden") === "true" || current.hasAttribute("hidden")) {
|
|
9481
|
+
return false;
|
|
9482
|
+
}
|
|
9483
|
+
current = current.parentElement;
|
|
9484
|
+
}
|
|
9485
|
+
return true;
|
|
9486
|
+
};
|
|
9487
|
+
var shouldBlockDeleteHotkey = (e) => {
|
|
9488
|
+
var _a;
|
|
9489
|
+
if (e == null ? void 0 : e.defaultPrevented) return true;
|
|
9490
|
+
const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
|
|
9491
|
+
if (origin instanceof HTMLElement) {
|
|
9492
|
+
const tag = origin.tagName.toLowerCase();
|
|
9493
|
+
if (tag === "input" || tag === "textarea" || tag === "select") return true;
|
|
9494
|
+
if (origin.isContentEditable) return true;
|
|
9495
|
+
const role = origin.getAttribute("role");
|
|
9496
|
+
if (role === "textbox" || role === "combobox" || role === "searchbox" || role === "listbox" || role === "grid") {
|
|
9497
|
+
return true;
|
|
9498
|
+
}
|
|
9499
|
+
}
|
|
9500
|
+
const modal = document.querySelector(
|
|
9501
|
+
'dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]'
|
|
9502
|
+
);
|
|
9503
|
+
if (modal && isElementVisible(modal)) {
|
|
9504
|
+
return true;
|
|
9505
|
+
}
|
|
9506
|
+
return false;
|
|
9507
|
+
};
|
|
9508
|
+
var useDeleteHotkeys = () => {
|
|
9509
|
+
const appStore = useAppStoreApi();
|
|
9510
|
+
const deleteSelectedComponent = (0, import_react61.useCallback)(
|
|
9511
|
+
(e) => {
|
|
9512
|
+
var _a;
|
|
9513
|
+
if (shouldBlockDeleteHotkey(e)) {
|
|
9514
|
+
return false;
|
|
9515
|
+
}
|
|
9516
|
+
const { state, dispatch, permissions, selectedItem } = appStore.getState();
|
|
9517
|
+
const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
|
|
9518
|
+
if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return true;
|
|
9519
|
+
if (!permissions.getPermissions({ item: selectedItem }).delete)
|
|
9520
|
+
return true;
|
|
9521
|
+
dispatch({
|
|
9522
|
+
type: "remove",
|
|
9523
|
+
index: sel.index,
|
|
9524
|
+
zone: sel.zone
|
|
9525
|
+
});
|
|
9526
|
+
return true;
|
|
9527
|
+
},
|
|
9528
|
+
[appStore]
|
|
9529
|
+
);
|
|
9530
|
+
useHotkey({ delete: true }, deleteSelectedComponent);
|
|
9531
|
+
useHotkey({ backspace: true }, deleteSelectedComponent);
|
|
9532
|
+
};
|
|
9533
|
+
|
|
9399
9534
|
// components/Puck/components/Nav/index.tsx
|
|
9400
9535
|
init_react_import();
|
|
9401
9536
|
|
|
@@ -9507,7 +9642,7 @@ var Layout = ({ children }) => {
|
|
|
9507
9642
|
plugins,
|
|
9508
9643
|
height = "100dvh"
|
|
9509
9644
|
} = usePropsContext();
|
|
9510
|
-
const iframe = (0,
|
|
9645
|
+
const iframe = (0, import_react62.useMemo)(
|
|
9511
9646
|
() => __spreadValues({
|
|
9512
9647
|
enabled: true,
|
|
9513
9648
|
waitForStyles: true
|
|
@@ -9533,7 +9668,7 @@ var Layout = ({ children }) => {
|
|
|
9533
9668
|
sidebarRef: rightSidebarRef,
|
|
9534
9669
|
handleResizeEnd: handleRightSidebarResizeEnd
|
|
9535
9670
|
} = useSidebarResize("right", dispatch);
|
|
9536
|
-
(0,
|
|
9671
|
+
(0, import_react62.useEffect)(() => {
|
|
9537
9672
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
9538
9673
|
dispatch({
|
|
9539
9674
|
type: "setUi",
|
|
@@ -9557,17 +9692,17 @@ var Layout = ({ children }) => {
|
|
|
9557
9692
|
};
|
|
9558
9693
|
}, []);
|
|
9559
9694
|
const overrides = useAppStore((s) => s.overrides);
|
|
9560
|
-
const CustomPuck = (0,
|
|
9695
|
+
const CustomPuck = (0, import_react62.useMemo)(
|
|
9561
9696
|
() => overrides.puck || DefaultOverride,
|
|
9562
9697
|
[overrides]
|
|
9563
9698
|
);
|
|
9564
|
-
const [mounted, setMounted] = (0,
|
|
9565
|
-
(0,
|
|
9699
|
+
const [mounted, setMounted] = (0, import_react62.useState)(false);
|
|
9700
|
+
(0, import_react62.useEffect)(() => {
|
|
9566
9701
|
setMounted(true);
|
|
9567
9702
|
}, []);
|
|
9568
9703
|
const ready = useAppStore((s) => s.status === "READY");
|
|
9569
9704
|
useMonitorHotkeys();
|
|
9570
|
-
(0,
|
|
9705
|
+
(0, import_react62.useEffect)(() => {
|
|
9571
9706
|
if (ready && iframe.enabled) {
|
|
9572
9707
|
const frameDoc = getFrame();
|
|
9573
9708
|
if (frameDoc) {
|
|
@@ -9576,6 +9711,7 @@ var Layout = ({ children }) => {
|
|
|
9576
9711
|
}
|
|
9577
9712
|
}, [ready, iframe.enabled]);
|
|
9578
9713
|
usePreviewModeHotkeys();
|
|
9714
|
+
useDeleteHotkeys();
|
|
9579
9715
|
const layoutOptions = {};
|
|
9580
9716
|
if (leftWidth) {
|
|
9581
9717
|
layoutOptions["--puck-user-left-side-bar-width"] = `${leftWidth}px`;
|
|
@@ -9589,8 +9725,8 @@ var Layout = ({ children }) => {
|
|
|
9589
9725
|
return (_a = s.state.ui.plugin) == null ? void 0 : _a.current;
|
|
9590
9726
|
});
|
|
9591
9727
|
const appStoreApi = useAppStoreApi();
|
|
9592
|
-
const [mobilePanelHeightMode, setMobilePanelHeightMode] = (0,
|
|
9593
|
-
const pluginItems = (0,
|
|
9728
|
+
const [mobilePanelHeightMode, setMobilePanelHeightMode] = (0, import_react62.useState)("toggle");
|
|
9729
|
+
const pluginItems = (0, import_react62.useMemo)(() => {
|
|
9594
9730
|
const details = {};
|
|
9595
9731
|
const defaultPlugins = [blocksPlugin(), outlinePlugin()];
|
|
9596
9732
|
const combinedPlugins = [
|
|
@@ -9635,7 +9771,7 @@ var Layout = ({ children }) => {
|
|
|
9635
9771
|
});
|
|
9636
9772
|
return details;
|
|
9637
9773
|
}, [plugins, currentPlugin, appStoreApi, leftSideBarVisible]);
|
|
9638
|
-
(0,
|
|
9774
|
+
(0, import_react62.useEffect)(() => {
|
|
9639
9775
|
if (!currentPlugin) {
|
|
9640
9776
|
const names = Object.keys(pluginItems);
|
|
9641
9777
|
setUi({ plugin: { current: names[0] } });
|
|
@@ -9738,11 +9874,11 @@ var Layout = ({ children }) => {
|
|
|
9738
9874
|
|
|
9739
9875
|
// components/Puck/index.tsx
|
|
9740
9876
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
9741
|
-
var propsContext = (0,
|
|
9877
|
+
var propsContext = (0, import_react63.createContext)({});
|
|
9742
9878
|
function PropsProvider(props) {
|
|
9743
9879
|
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
9744
9880
|
}
|
|
9745
|
-
var usePropsContext = () => (0,
|
|
9881
|
+
var usePropsContext = () => (0, import_react63.useContext)(propsContext);
|
|
9746
9882
|
function PuckProvider({ children }) {
|
|
9747
9883
|
const {
|
|
9748
9884
|
config,
|
|
@@ -9759,14 +9895,14 @@ function PuckProvider({ children }) {
|
|
|
9759
9895
|
onAction,
|
|
9760
9896
|
fieldTransforms
|
|
9761
9897
|
} = usePropsContext();
|
|
9762
|
-
const iframe = (0,
|
|
9898
|
+
const iframe = (0, import_react63.useMemo)(
|
|
9763
9899
|
() => __spreadValues({
|
|
9764
9900
|
enabled: true,
|
|
9765
9901
|
waitForStyles: true
|
|
9766
9902
|
}, _iframe),
|
|
9767
9903
|
[_iframe]
|
|
9768
9904
|
);
|
|
9769
|
-
const [generatedAppState] = (0,
|
|
9905
|
+
const [generatedAppState] = (0, import_react63.useState)(() => {
|
|
9770
9906
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
9771
9907
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
9772
9908
|
let clientUiState = {};
|
|
@@ -9836,7 +9972,7 @@ function PuckProvider({ children }) {
|
|
|
9836
9972
|
return walkAppState(newAppState, config);
|
|
9837
9973
|
});
|
|
9838
9974
|
const { appendData = true } = _initialHistory || {};
|
|
9839
|
-
const [blendedHistories] = (0,
|
|
9975
|
+
const [blendedHistories] = (0, import_react63.useState)(
|
|
9840
9976
|
[
|
|
9841
9977
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
9842
9978
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -9856,7 +9992,7 @@ function PuckProvider({ children }) {
|
|
|
9856
9992
|
overrides,
|
|
9857
9993
|
plugins
|
|
9858
9994
|
});
|
|
9859
|
-
const loadedFieldTransforms = (0,
|
|
9995
|
+
const loadedFieldTransforms = (0, import_react63.useMemo)(() => {
|
|
9860
9996
|
const _plugins = plugins || [];
|
|
9861
9997
|
const pluginFieldTransforms = _plugins.reduce(
|
|
9862
9998
|
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
@@ -9865,7 +10001,7 @@ function PuckProvider({ children }) {
|
|
|
9865
10001
|
return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
|
|
9866
10002
|
}, [fieldTransforms, plugins]);
|
|
9867
10003
|
const instanceId = useSafeId();
|
|
9868
|
-
const generateAppStore = (0,
|
|
10004
|
+
const generateAppStore = (0, import_react63.useCallback)(
|
|
9869
10005
|
(state) => {
|
|
9870
10006
|
return {
|
|
9871
10007
|
instanceId,
|
|
@@ -9893,15 +10029,15 @@ function PuckProvider({ children }) {
|
|
|
9893
10029
|
loadedFieldTransforms
|
|
9894
10030
|
]
|
|
9895
10031
|
);
|
|
9896
|
-
const [appStore] = (0,
|
|
10032
|
+
const [appStore] = (0, import_react63.useState)(
|
|
9897
10033
|
() => createAppStore(generateAppStore(initialAppState))
|
|
9898
10034
|
);
|
|
9899
|
-
(0,
|
|
10035
|
+
(0, import_react63.useEffect)(() => {
|
|
9900
10036
|
if (process.env.NODE_ENV !== "production") {
|
|
9901
10037
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
9902
10038
|
}
|
|
9903
10039
|
}, [appStore]);
|
|
9904
|
-
(0,
|
|
10040
|
+
(0, import_react63.useEffect)(() => {
|
|
9905
10041
|
const state = appStore.getState().state;
|
|
9906
10042
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
9907
10043
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -9910,13 +10046,13 @@ function PuckProvider({ children }) {
|
|
|
9910
10046
|
index: initialHistoryIndex,
|
|
9911
10047
|
initialAppState
|
|
9912
10048
|
});
|
|
9913
|
-
const previousData = (0,
|
|
9914
|
-
(0,
|
|
10049
|
+
const previousData = (0, import_react63.useRef)(null);
|
|
10050
|
+
(0, import_react63.useEffect)(() => {
|
|
9915
10051
|
appStore.subscribe(
|
|
9916
10052
|
(s) => s.state.data,
|
|
9917
10053
|
(data) => {
|
|
9918
10054
|
if (onChange) {
|
|
9919
|
-
if ((0,
|
|
10055
|
+
if ((0, import_fast_deep_equal2.default)(data, previousData.current)) return;
|
|
9920
10056
|
onChange(data);
|
|
9921
10057
|
previousData.current = data;
|
|
9922
10058
|
}
|
|
@@ -9925,7 +10061,7 @@ function PuckProvider({ children }) {
|
|
|
9925
10061
|
}, []);
|
|
9926
10062
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
9927
10063
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
9928
|
-
(0,
|
|
10064
|
+
(0, import_react63.useEffect)(() => {
|
|
9929
10065
|
const { resolveAndCommitData } = appStore.getState();
|
|
9930
10066
|
resolveAndCommitData();
|
|
9931
10067
|
}, []);
|