@measured/puck 0.20.0-canary.8909f8cc → 0.20.0-canary.8f2f0f46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/dist/{chunk-EMTLDPBH.mjs → chunk-5PAQR6UC.mjs} +797 -527
- package/dist/{chunk-32MJ3X3H.mjs → chunk-HUKJ36SA.mjs} +131 -69
- package/dist/index.css +116 -78
- package/dist/index.d.mts +17 -5
- package/dist/index.d.ts +17 -5
- package/dist/index.js +1042 -712
- package/dist/index.mjs +6 -2
- package/dist/no-external.css +116 -78
- package/dist/no-external.d.mts +2 -2
- package/dist/no-external.d.ts +2 -2
- package/dist/no-external.js +1042 -712
- package/dist/no-external.mjs +6 -2
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +138 -70
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-BCI5tk0w.d.mts → walk-tree-B57SgEEc.d.mts} +39 -3
- package/dist/{walk-tree-BCI5tk0w.d.ts → walk-tree-B57SgEEc.d.ts} +39 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -171,8 +171,10 @@ __export(bundle_exports, {
|
|
|
171
171
|
createUsePuck: () => createUsePuck,
|
|
172
172
|
migrate: () => migrate,
|
|
173
173
|
overrideKeys: () => overrideKeys,
|
|
174
|
+
registerOverlayPortal: () => registerOverlayPortal,
|
|
174
175
|
renderContext: () => renderContext,
|
|
175
176
|
resolveAllData: () => resolveAllData,
|
|
177
|
+
setDeep: () => setDeep,
|
|
176
178
|
transformProps: () => transformProps,
|
|
177
179
|
useGetPuck: () => useGetPuck,
|
|
178
180
|
usePuck: () => usePuck,
|
|
@@ -193,6 +195,9 @@ init_react_import();
|
|
|
193
195
|
// types/API/Viewports.ts
|
|
194
196
|
init_react_import();
|
|
195
197
|
|
|
198
|
+
// types/API/FieldTransforms.ts
|
|
199
|
+
init_react_import();
|
|
200
|
+
|
|
196
201
|
// types/index.ts
|
|
197
202
|
init_react_import();
|
|
198
203
|
|
|
@@ -203,8 +208,9 @@ var overrideKeys = [
|
|
|
203
208
|
"headerActions",
|
|
204
209
|
"fields",
|
|
205
210
|
"fieldLabel",
|
|
206
|
-
"
|
|
207
|
-
"
|
|
211
|
+
"drawer",
|
|
212
|
+
"drawerItem",
|
|
213
|
+
"componentOverlay",
|
|
208
214
|
"outline",
|
|
209
215
|
"puck",
|
|
210
216
|
"preview"
|
|
@@ -306,10 +312,10 @@ init_react_import();
|
|
|
306
312
|
|
|
307
313
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
|
308
314
|
init_react_import();
|
|
309
|
-
var styles_module_default2 = { "InputWrapper": "
|
|
315
|
+
var styles_module_default2 = { "InputWrapper": "_InputWrapper_bsxfo_1", "Input-label": "_Input-label_bsxfo_5", "Input-labelIcon": "_Input-labelIcon_bsxfo_14", "Input-disabledIcon": "_Input-disabledIcon_bsxfo_21", "Input-input": "_Input-input_bsxfo_26", "Input": "_Input_bsxfo_1", "Input--readOnly": "_Input--readOnly_bsxfo_82", "Input-radioGroupItems": "_Input-radioGroupItems_bsxfo_93", "Input-radio": "_Input-radio_bsxfo_93", "Input-radioInner": "_Input-radioInner_bsxfo_110", "Input-radioInput": "_Input-radioInput_bsxfo_155" };
|
|
310
316
|
|
|
311
317
|
// components/AutoField/index.tsx
|
|
312
|
-
var
|
|
318
|
+
var import_react20 = require("react");
|
|
313
319
|
|
|
314
320
|
// components/AutoField/fields/index.tsx
|
|
315
321
|
init_react_import();
|
|
@@ -653,7 +659,7 @@ init_react_import();
|
|
|
653
659
|
|
|
654
660
|
// components/IconButton/IconButton.tsx
|
|
655
661
|
init_react_import();
|
|
656
|
-
var
|
|
662
|
+
var import_react9 = require("react");
|
|
657
663
|
|
|
658
664
|
// css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
|
|
659
665
|
init_react_import();
|
|
@@ -688,7 +694,6 @@ var replace = (list, index, newItem) => {
|
|
|
688
694
|
|
|
689
695
|
// lib/use-reset-auto-zoom.ts
|
|
690
696
|
init_react_import();
|
|
691
|
-
var import_react9 = require("react");
|
|
692
697
|
|
|
693
698
|
// store/index.ts
|
|
694
699
|
init_react_import();
|
|
@@ -735,7 +740,7 @@ function forRelatedZones(item, data, cb, path = []) {
|
|
|
735
740
|
});
|
|
736
741
|
}
|
|
737
742
|
|
|
738
|
-
// lib/data/map-
|
|
743
|
+
// lib/data/map-fields.ts
|
|
739
744
|
init_react_import();
|
|
740
745
|
|
|
741
746
|
// lib/data/default-slots.ts
|
|
@@ -745,14 +750,14 @@ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
|
|
|
745
750
|
value
|
|
746
751
|
);
|
|
747
752
|
|
|
748
|
-
// lib/data/map-
|
|
753
|
+
// lib/data/map-fields.ts
|
|
749
754
|
var isPromise = (v) => !!v && typeof v.then === "function";
|
|
750
755
|
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
|
751
756
|
var containsPromise = (arr) => arr.some(isPromise);
|
|
752
757
|
var walkField = ({
|
|
753
758
|
value,
|
|
754
759
|
fields,
|
|
755
|
-
|
|
760
|
+
mappers,
|
|
756
761
|
propKey = "",
|
|
757
762
|
propPath = "",
|
|
758
763
|
id = "",
|
|
@@ -760,7 +765,9 @@ var walkField = ({
|
|
|
760
765
|
recurseSlots = false
|
|
761
766
|
}) => {
|
|
762
767
|
var _a, _b, _c;
|
|
763
|
-
|
|
768
|
+
const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
|
|
769
|
+
const map = mappers[fieldType];
|
|
770
|
+
if (map && fieldType === "slot") {
|
|
764
771
|
const content = value || [];
|
|
765
772
|
const mappedContent = recurseSlots ? content.map((el) => {
|
|
766
773
|
var _a2;
|
|
@@ -772,7 +779,7 @@ var walkField = ({
|
|
|
772
779
|
return walkField({
|
|
773
780
|
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
|
774
781
|
fields: fields2,
|
|
775
|
-
|
|
782
|
+
mappers,
|
|
776
783
|
id: el.props.id,
|
|
777
784
|
config,
|
|
778
785
|
recurseSlots
|
|
@@ -781,7 +788,21 @@ var walkField = ({
|
|
|
781
788
|
if (containsPromise(mappedContent)) {
|
|
782
789
|
return Promise.all(mappedContent);
|
|
783
790
|
}
|
|
784
|
-
return map(
|
|
791
|
+
return map({
|
|
792
|
+
value: mappedContent,
|
|
793
|
+
parentId: id,
|
|
794
|
+
propName: propKey,
|
|
795
|
+
field: fields[propKey],
|
|
796
|
+
propPath
|
|
797
|
+
});
|
|
798
|
+
} else if (map && fields[propKey]) {
|
|
799
|
+
return map({
|
|
800
|
+
value,
|
|
801
|
+
parentId: id,
|
|
802
|
+
propName: propKey,
|
|
803
|
+
field: fields[propKey],
|
|
804
|
+
propPath
|
|
805
|
+
});
|
|
785
806
|
}
|
|
786
807
|
if (value && typeof value === "object") {
|
|
787
808
|
if (Array.isArray(value)) {
|
|
@@ -791,7 +812,7 @@ var walkField = ({
|
|
|
791
812
|
(el, idx) => walkField({
|
|
792
813
|
value: el,
|
|
793
814
|
fields: arrayFields,
|
|
794
|
-
|
|
815
|
+
mappers,
|
|
795
816
|
propKey,
|
|
796
817
|
propPath: `${propPath}[${idx}]`,
|
|
797
818
|
id,
|
|
@@ -810,7 +831,7 @@ var walkField = ({
|
|
|
810
831
|
return walkObject({
|
|
811
832
|
value,
|
|
812
833
|
fields: objectFields,
|
|
813
|
-
|
|
834
|
+
mappers,
|
|
814
835
|
id,
|
|
815
836
|
getPropPath: (k) => `${propPath}.${k}`,
|
|
816
837
|
config,
|
|
@@ -823,7 +844,7 @@ var walkField = ({
|
|
|
823
844
|
var walkObject = ({
|
|
824
845
|
value,
|
|
825
846
|
fields,
|
|
826
|
-
|
|
847
|
+
mappers,
|
|
827
848
|
id,
|
|
828
849
|
getPropPath,
|
|
829
850
|
config,
|
|
@@ -833,7 +854,7 @@ var walkObject = ({
|
|
|
833
854
|
const opts = {
|
|
834
855
|
value: v,
|
|
835
856
|
fields,
|
|
836
|
-
|
|
857
|
+
mappers,
|
|
837
858
|
propKey: k,
|
|
838
859
|
propPath: getPropPath(k),
|
|
839
860
|
id,
|
|
@@ -855,14 +876,14 @@ var walkObject = ({
|
|
|
855
876
|
}
|
|
856
877
|
return flatten(newProps);
|
|
857
878
|
};
|
|
858
|
-
function
|
|
879
|
+
function mapFields(item, mappers, config, recurseSlots = false) {
|
|
859
880
|
var _a, _b, _c, _d, _e;
|
|
860
881
|
const itemType = "type" in item ? item.type : "root";
|
|
861
882
|
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
|
862
883
|
const newProps = walkObject({
|
|
863
884
|
value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
|
|
864
885
|
fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
|
|
865
|
-
|
|
886
|
+
mappers,
|
|
866
887
|
id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
|
|
867
888
|
getPropPath: (k) => k,
|
|
868
889
|
config,
|
|
@@ -885,7 +906,7 @@ var import_flat = __toESM(require("flat"));
|
|
|
885
906
|
// lib/data/strip-slots.ts
|
|
886
907
|
init_react_import();
|
|
887
908
|
var stripSlots = (data, config) => {
|
|
888
|
-
return
|
|
909
|
+
return mapFields(data, { slot: () => null }, config);
|
|
889
910
|
};
|
|
890
911
|
|
|
891
912
|
// lib/data/flatten-node.ts
|
|
@@ -944,18 +965,21 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
|
944
965
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
|
945
966
|
if (!mappedItem) return item;
|
|
946
967
|
const id = mappedItem.props.id;
|
|
947
|
-
const newProps = __spreadProps(__spreadValues({},
|
|
968
|
+
const newProps = __spreadProps(__spreadValues({}, mapFields(
|
|
948
969
|
mappedItem,
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
970
|
+
{
|
|
971
|
+
slot: ({ value, parentId: parentId2, propPath }) => {
|
|
972
|
+
const content = value;
|
|
973
|
+
const zoneCompound = `${parentId2}:${propPath}`;
|
|
974
|
+
const [_2, newContent2] = processContent(
|
|
975
|
+
path,
|
|
976
|
+
zoneCompound,
|
|
977
|
+
content,
|
|
978
|
+
"slot",
|
|
979
|
+
parentId2
|
|
980
|
+
);
|
|
981
|
+
return newContent2;
|
|
982
|
+
}
|
|
959
983
|
},
|
|
960
984
|
config
|
|
961
985
|
).props), {
|
|
@@ -1073,11 +1097,14 @@ init_react_import();
|
|
|
1073
1097
|
function walkTree(data, config, callbackFn) {
|
|
1074
1098
|
var _a, _b;
|
|
1075
1099
|
const walkItem = (item) => {
|
|
1076
|
-
return
|
|
1100
|
+
return mapFields(
|
|
1077
1101
|
item,
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1102
|
+
{
|
|
1103
|
+
slot: ({ value, parentId, propName }) => {
|
|
1104
|
+
var _a2;
|
|
1105
|
+
const content = value;
|
|
1106
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
|
1107
|
+
}
|
|
1081
1108
|
},
|
|
1082
1109
|
config,
|
|
1083
1110
|
true
|
|
@@ -2143,24 +2170,27 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
|
2143
2170
|
resolvedItem.readOnly = readOnly;
|
|
2144
2171
|
}
|
|
2145
2172
|
}
|
|
2146
|
-
let itemWithResolvedChildren = yield
|
|
2173
|
+
let itemWithResolvedChildren = yield mapFields(
|
|
2147
2174
|
resolvedItem,
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
content
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2175
|
+
{
|
|
2176
|
+
slot: (_02) => __async(void 0, [_02], function* ({ value }) {
|
|
2177
|
+
const content = value;
|
|
2178
|
+
return yield Promise.all(
|
|
2179
|
+
content.map(
|
|
2180
|
+
(childItem) => __async(void 0, null, function* () {
|
|
2181
|
+
return (yield resolveComponentData(
|
|
2182
|
+
childItem,
|
|
2183
|
+
config,
|
|
2184
|
+
metadata,
|
|
2185
|
+
onResolveStart,
|
|
2186
|
+
onResolveEnd,
|
|
2187
|
+
trigger
|
|
2188
|
+
)).node;
|
|
2189
|
+
})
|
|
2190
|
+
)
|
|
2191
|
+
);
|
|
2192
|
+
})
|
|
2193
|
+
},
|
|
2164
2194
|
config
|
|
2165
2195
|
);
|
|
2166
2196
|
if (shouldRunResolver && onResolveEnd) {
|
|
@@ -2242,7 +2272,8 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
|
2242
2272
|
},
|
|
2243
2273
|
status: "LOADING",
|
|
2244
2274
|
iframe: {},
|
|
2245
|
-
metadata: {}
|
|
2275
|
+
metadata: {},
|
|
2276
|
+
fieldTransforms: {}
|
|
2246
2277
|
}, initialAppStore), {
|
|
2247
2278
|
fields: createFieldsSlice(set, get),
|
|
2248
2279
|
history: createHistorySlice(set, get),
|
|
@@ -2558,56 +2589,18 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
|
2558
2589
|
};
|
|
2559
2590
|
|
|
2560
2591
|
// lib/use-reset-auto-zoom.ts
|
|
2561
|
-
var import_shallow = require("zustand/react/shallow");
|
|
2562
2592
|
var useResetAutoZoom = (frameRef) => {
|
|
2563
|
-
const
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
if (frameRef.current) {
|
|
2575
|
-
setZoomConfig(
|
|
2576
|
-
getZoomConfig(
|
|
2577
|
-
newViewports == null ? void 0 : newViewports.current,
|
|
2578
|
-
frameRef.current,
|
|
2579
|
-
zoomConfig.zoom
|
|
2580
|
-
)
|
|
2581
|
-
);
|
|
2582
|
-
}
|
|
2583
|
-
return;
|
|
2584
|
-
}
|
|
2585
|
-
const {
|
|
2586
|
-
isResettingRef,
|
|
2587
|
-
setShowTransition,
|
|
2588
|
-
showTransition = false
|
|
2589
|
-
} = options;
|
|
2590
|
-
if (!isResettingRef.current) {
|
|
2591
|
-
isResettingRef.current = true;
|
|
2592
|
-
if (setShowTransition) {
|
|
2593
|
-
setShowTransition(showTransition);
|
|
2594
|
-
}
|
|
2595
|
-
if (frameRef.current) {
|
|
2596
|
-
setZoomConfig(
|
|
2597
|
-
getZoomConfig(
|
|
2598
|
-
newViewports == null ? void 0 : newViewports.current,
|
|
2599
|
-
frameRef.current,
|
|
2600
|
-
zoomConfig.zoom
|
|
2601
|
-
)
|
|
2602
|
-
);
|
|
2603
|
-
}
|
|
2604
|
-
setTimeout(() => {
|
|
2605
|
-
isResettingRef.current = false;
|
|
2606
|
-
}, 0);
|
|
2607
|
-
}
|
|
2608
|
-
},
|
|
2609
|
-
[frameRef, zoomConfig, viewports, setZoomConfig]
|
|
2610
|
-
);
|
|
2593
|
+
const appStoreApi = useAppStoreApi();
|
|
2594
|
+
const resetAutoZoom = (options) => {
|
|
2595
|
+
const { state, zoomConfig, setZoomConfig } = appStoreApi.getState();
|
|
2596
|
+
const { viewports } = state.ui;
|
|
2597
|
+
const newViewports = (options == null ? void 0 : options.viewports) || viewports;
|
|
2598
|
+
if (frameRef.current) {
|
|
2599
|
+
setZoomConfig(
|
|
2600
|
+
getZoomConfig(newViewports == null ? void 0 : newViewports.current, frameRef.current, zoomConfig.zoom)
|
|
2601
|
+
);
|
|
2602
|
+
}
|
|
2603
|
+
};
|
|
2611
2604
|
return resetAutoZoom;
|
|
2612
2605
|
};
|
|
2613
2606
|
|
|
@@ -2655,7 +2648,7 @@ var IconButton = ({
|
|
|
2655
2648
|
fullWidth,
|
|
2656
2649
|
title
|
|
2657
2650
|
}) => {
|
|
2658
|
-
const [loading, setLoading] = (0,
|
|
2651
|
+
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
2659
2652
|
const ElementType = href ? "a" : "button";
|
|
2660
2653
|
const el = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2661
2654
|
ElementType,
|
|
@@ -2694,7 +2687,7 @@ var IconButton = ({
|
|
|
2694
2687
|
};
|
|
2695
2688
|
|
|
2696
2689
|
// components/AutoField/fields/ArrayField/index.tsx
|
|
2697
|
-
var
|
|
2690
|
+
var import_react14 = require("react");
|
|
2698
2691
|
|
|
2699
2692
|
// components/DragIcon/index.tsx
|
|
2700
2693
|
init_react_import();
|
|
@@ -2710,12 +2703,12 @@ var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ (0, import_jsx_runtime4.j
|
|
|
2710
2703
|
|
|
2711
2704
|
// components/Sortable/index.tsx
|
|
2712
2705
|
init_react_import();
|
|
2713
|
-
var
|
|
2706
|
+
var import_react12 = require("@dnd-kit/react");
|
|
2714
2707
|
|
|
2715
2708
|
// lib/dnd/use-sensors.ts
|
|
2716
2709
|
init_react_import();
|
|
2717
|
-
var
|
|
2718
|
-
var
|
|
2710
|
+
var import_react10 = require("react");
|
|
2711
|
+
var import_react11 = require("@dnd-kit/react");
|
|
2719
2712
|
var import_utilities = require("@dnd-kit/dom/utilities");
|
|
2720
2713
|
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
|
2721
2714
|
var otherDefault = {
|
|
@@ -2730,8 +2723,8 @@ var useSensors = ({
|
|
|
2730
2723
|
touch: touchDefault,
|
|
2731
2724
|
other: otherDefault
|
|
2732
2725
|
}) => {
|
|
2733
|
-
const [sensors] = (0,
|
|
2734
|
-
|
|
2726
|
+
const [sensors] = (0, import_react10.useState)(() => [
|
|
2727
|
+
import_react11.PointerSensor.configure({
|
|
2735
2728
|
activationConstraints(event, source) {
|
|
2736
2729
|
var _a;
|
|
2737
2730
|
const { pointerType, target } = event;
|
|
@@ -3077,7 +3070,7 @@ var SortableProvider = ({
|
|
|
3077
3070
|
mouse: { distance: { value: 5 } }
|
|
3078
3071
|
});
|
|
3079
3072
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3080
|
-
|
|
3073
|
+
import_react12.DragDropProvider,
|
|
3081
3074
|
{
|
|
3082
3075
|
sensors,
|
|
3083
3076
|
onDragStart: (event) => {
|
|
@@ -3141,11 +3134,11 @@ var Sortable = ({
|
|
|
3141
3134
|
|
|
3142
3135
|
// components/AutoField/context.tsx
|
|
3143
3136
|
init_react_import();
|
|
3144
|
-
var
|
|
3137
|
+
var import_react13 = require("react");
|
|
3145
3138
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3146
|
-
var NestedFieldContext = (0,
|
|
3139
|
+
var NestedFieldContext = (0, import_react13.createContext)({});
|
|
3147
3140
|
var useNestedFieldContext = () => {
|
|
3148
|
-
const context = (0,
|
|
3141
|
+
const context = (0, import_react13.useContext)(NestedFieldContext);
|
|
3149
3142
|
return __spreadProps(__spreadValues({}, context), {
|
|
3150
3143
|
readOnlyFields: context.readOnlyFields || {}
|
|
3151
3144
|
});
|
|
@@ -3159,7 +3152,7 @@ var NestedFieldProvider = ({
|
|
|
3159
3152
|
}) => {
|
|
3160
3153
|
const subPath = `${name}.${subName}`;
|
|
3161
3154
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
|
3162
|
-
const subReadOnlyFields = (0,
|
|
3155
|
+
const subReadOnlyFields = (0, import_react13.useMemo)(
|
|
3163
3156
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
|
3164
3157
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
|
3165
3158
|
if (isLocal) {
|
|
@@ -3212,14 +3205,14 @@ var ArrayField = ({
|
|
|
3212
3205
|
}),
|
|
3213
3206
|
openId: ""
|
|
3214
3207
|
};
|
|
3215
|
-
const [localState, setLocalState] = (0,
|
|
3216
|
-
(0,
|
|
3208
|
+
const [localState, setLocalState] = (0, import_react14.useState)({ arrayState, value });
|
|
3209
|
+
(0, import_react14.useEffect)(() => {
|
|
3217
3210
|
var _a;
|
|
3218
3211
|
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
|
3219
3212
|
setLocalState({ arrayState: _arrayState, value });
|
|
3220
3213
|
}, [value]);
|
|
3221
3214
|
const appStore = useAppStoreApi();
|
|
3222
|
-
const mapArrayStateToUi = (0,
|
|
3215
|
+
const mapArrayStateToUi = (0, import_react14.useCallback)(
|
|
3223
3216
|
(partialArrayState) => {
|
|
3224
3217
|
const state = appStore.getState().state;
|
|
3225
3218
|
return {
|
|
@@ -3230,13 +3223,13 @@ var ArrayField = ({
|
|
|
3230
3223
|
},
|
|
3231
3224
|
[arrayState, appStore]
|
|
3232
3225
|
);
|
|
3233
|
-
const getHighestIndex = (0,
|
|
3226
|
+
const getHighestIndex = (0, import_react14.useCallback)(() => {
|
|
3234
3227
|
return arrayState.items.reduce(
|
|
3235
3228
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
|
3236
3229
|
-1
|
|
3237
3230
|
);
|
|
3238
3231
|
}, [arrayState]);
|
|
3239
|
-
const regenerateArrayState = (0,
|
|
3232
|
+
const regenerateArrayState = (0, import_react14.useCallback)(
|
|
3240
3233
|
(value2) => {
|
|
3241
3234
|
let highestIndex = getHighestIndex();
|
|
3242
3235
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
|
@@ -3255,26 +3248,31 @@ var ArrayField = ({
|
|
|
3255
3248
|
},
|
|
3256
3249
|
[arrayState]
|
|
3257
3250
|
);
|
|
3258
|
-
(0,
|
|
3251
|
+
(0, import_react14.useEffect)(() => {
|
|
3259
3252
|
if (arrayState.items.length > 0) {
|
|
3260
3253
|
setUi(mapArrayStateToUi(arrayState));
|
|
3261
3254
|
}
|
|
3262
3255
|
}, []);
|
|
3263
|
-
const [draggedItem, setDraggedItem] = (0,
|
|
3256
|
+
const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
|
|
3264
3257
|
const isDraggingAny = !!draggedItem;
|
|
3265
3258
|
const canEdit = useAppStore(
|
|
3266
3259
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
|
3267
3260
|
);
|
|
3268
3261
|
const forceReadOnly = !canEdit;
|
|
3269
|
-
const valueRef = (0,
|
|
3270
|
-
const uniqifyItem = (0,
|
|
3262
|
+
const valueRef = (0, import_react14.useRef)(value);
|
|
3263
|
+
const uniqifyItem = (0, import_react14.useCallback)(
|
|
3271
3264
|
(val) => {
|
|
3272
3265
|
if (field.type !== "array" || !field.arrayFields) return;
|
|
3273
3266
|
const config = appStore.getState().config;
|
|
3274
3267
|
return walkField({
|
|
3275
3268
|
value: val,
|
|
3276
3269
|
fields: field.arrayFields,
|
|
3277
|
-
|
|
3270
|
+
mappers: {
|
|
3271
|
+
slot: ({ value: value2 }) => {
|
|
3272
|
+
const content = value2;
|
|
3273
|
+
return content.map((item) => populateIds(item, config, true));
|
|
3274
|
+
}
|
|
3275
|
+
},
|
|
3278
3276
|
config
|
|
3279
3277
|
});
|
|
3280
3278
|
},
|
|
@@ -3429,49 +3427,51 @@ var ArrayField = ({
|
|
|
3429
3427
|
]
|
|
3430
3428
|
}
|
|
3431
3429
|
),
|
|
3432
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map(
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
onChange(
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3430
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: arrayState.openId === _arrayId && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map(
|
|
3431
|
+
(subName) => {
|
|
3432
|
+
const subField = field.arrayFields[subName];
|
|
3433
|
+
const indexName = `${name}[${i}]`;
|
|
3434
|
+
const subPath = `${indexName}.${subName}`;
|
|
3435
|
+
const localIndexName = `${localName}[${i}]`;
|
|
3436
|
+
const localWildcardName = `${localName}[*]`;
|
|
3437
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
|
3438
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
|
3439
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
|
3440
|
+
const label2 = subField.label || subName;
|
|
3441
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3442
|
+
NestedFieldProvider,
|
|
3443
|
+
{
|
|
3444
|
+
name: localIndexName,
|
|
3445
|
+
wildcardName: localWildcardName,
|
|
3446
|
+
subName,
|
|
3447
|
+
readOnlyFields,
|
|
3448
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3449
|
+
AutoFieldPrivate,
|
|
3450
|
+
{
|
|
3451
|
+
name: subPath,
|
|
3452
|
+
label: label2,
|
|
3453
|
+
id: `${_arrayId}_${subName}`,
|
|
3454
|
+
readOnly: subReadOnly,
|
|
3455
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
|
3456
|
+
label: label2
|
|
3457
|
+
// May be used by custom fields
|
|
3458
|
+
}),
|
|
3459
|
+
value: data[subName],
|
|
3460
|
+
onChange: (val, ui) => {
|
|
3461
|
+
onChange(
|
|
3462
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
|
3463
|
+
[subName]: val
|
|
3464
|
+
})),
|
|
3465
|
+
ui
|
|
3466
|
+
);
|
|
3467
|
+
}
|
|
3468
3468
|
}
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3469
|
+
)
|
|
3470
|
+
},
|
|
3471
|
+
subPath
|
|
3472
|
+
);
|
|
3473
|
+
}
|
|
3474
|
+
) }) })
|
|
3475
3475
|
]
|
|
3476
3476
|
}
|
|
3477
3477
|
)
|
|
@@ -3572,11 +3572,11 @@ var DefaultField = ({
|
|
|
3572
3572
|
|
|
3573
3573
|
// components/AutoField/fields/ExternalField/index.tsx
|
|
3574
3574
|
init_react_import();
|
|
3575
|
-
var
|
|
3575
|
+
var import_react18 = require("react");
|
|
3576
3576
|
|
|
3577
3577
|
// components/ExternalInput/index.tsx
|
|
3578
3578
|
init_react_import();
|
|
3579
|
-
var
|
|
3579
|
+
var import_react17 = require("react");
|
|
3580
3580
|
|
|
3581
3581
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
|
3582
3582
|
init_react_import();
|
|
@@ -3584,7 +3584,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
|
3584
3584
|
|
|
3585
3585
|
// components/Modal/index.tsx
|
|
3586
3586
|
init_react_import();
|
|
3587
|
-
var
|
|
3587
|
+
var import_react15 = require("react");
|
|
3588
3588
|
|
|
3589
3589
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
|
3590
3590
|
init_react_import();
|
|
@@ -3599,8 +3599,8 @@ var Modal = ({
|
|
|
3599
3599
|
onClose,
|
|
3600
3600
|
isOpen
|
|
3601
3601
|
}) => {
|
|
3602
|
-
const [rootEl, setRootEl] = (0,
|
|
3603
|
-
(0,
|
|
3602
|
+
const [rootEl, setRootEl] = (0, import_react15.useState)(null);
|
|
3603
|
+
(0, import_react15.useEffect)(() => {
|
|
3604
3604
|
setRootEl(document.getElementById("puck-portal-root"));
|
|
3605
3605
|
}, []);
|
|
3606
3606
|
if (!rootEl) {
|
|
@@ -3647,7 +3647,7 @@ init_react_import();
|
|
|
3647
3647
|
|
|
3648
3648
|
// components/Button/Button.tsx
|
|
3649
3649
|
init_react_import();
|
|
3650
|
-
var
|
|
3650
|
+
var import_react16 = require("react");
|
|
3651
3651
|
|
|
3652
3652
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
|
3653
3653
|
init_react_import();
|
|
@@ -3697,8 +3697,8 @@ var Button = (_a) => {
|
|
|
3697
3697
|
"size",
|
|
3698
3698
|
"loading"
|
|
3699
3699
|
]);
|
|
3700
|
-
const [loading, setLoading] = (0,
|
|
3701
|
-
(0,
|
|
3700
|
+
const [loading, setLoading] = (0, import_react16.useState)(loadingProp);
|
|
3701
|
+
(0, import_react16.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
|
3702
3702
|
const ElementType = href ? "a" : type ? "button" : "span";
|
|
3703
3703
|
const dataAttrs = filterDataAttrs(props);
|
|
3704
3704
|
const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
@@ -3753,28 +3753,28 @@ var ExternalInput = ({
|
|
|
3753
3753
|
mapRow = (val) => val,
|
|
3754
3754
|
filterFields
|
|
3755
3755
|
} = field || {};
|
|
3756
|
-
const [data, setData] = (0,
|
|
3757
|
-
const [isOpen, setOpen] = (0,
|
|
3758
|
-
const [isLoading, setIsLoading] = (0,
|
|
3756
|
+
const [data, setData] = (0, import_react17.useState)([]);
|
|
3757
|
+
const [isOpen, setOpen] = (0, import_react17.useState)(false);
|
|
3758
|
+
const [isLoading, setIsLoading] = (0, import_react17.useState)(true);
|
|
3759
3759
|
const hasFilterFields = !!filterFields;
|
|
3760
|
-
const [filters, setFilters] = (0,
|
|
3761
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
|
3762
|
-
const mappedData = (0,
|
|
3760
|
+
const [filters, setFilters] = (0, import_react17.useState)(field.initialFilters || {});
|
|
3761
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react17.useState)(hasFilterFields);
|
|
3762
|
+
const mappedData = (0, import_react17.useMemo)(() => {
|
|
3763
3763
|
return data.map(mapRow);
|
|
3764
3764
|
}, [data]);
|
|
3765
|
-
const keys = (0,
|
|
3765
|
+
const keys = (0, import_react17.useMemo)(() => {
|
|
3766
3766
|
const validKeys = /* @__PURE__ */ new Set();
|
|
3767
3767
|
for (const item of mappedData) {
|
|
3768
3768
|
for (const key of Object.keys(item)) {
|
|
3769
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
|
3769
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react17.isValidElement)(item[key])) {
|
|
3770
3770
|
validKeys.add(key);
|
|
3771
3771
|
}
|
|
3772
3772
|
}
|
|
3773
3773
|
}
|
|
3774
3774
|
return Array.from(validKeys);
|
|
3775
3775
|
}, [mappedData]);
|
|
3776
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
3777
|
-
const search = (0,
|
|
3776
|
+
const [searchQuery, setSearchQuery] = (0, import_react17.useState)(field.initialQuery || "");
|
|
3777
|
+
const search = (0, import_react17.useCallback)(
|
|
3778
3778
|
(query, filters2) => __async(void 0, null, function* () {
|
|
3779
3779
|
setIsLoading(true);
|
|
3780
3780
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
|
@@ -3787,7 +3787,7 @@ var ExternalInput = ({
|
|
|
3787
3787
|
}),
|
|
3788
3788
|
[id, field]
|
|
3789
3789
|
);
|
|
3790
|
-
const Footer = (0,
|
|
3790
|
+
const Footer = (0, import_react17.useCallback)(
|
|
3791
3791
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
|
3792
3792
|
props.items.length,
|
|
3793
3793
|
" result",
|
|
@@ -3795,7 +3795,7 @@ var ExternalInput = ({
|
|
|
3795
3795
|
] }),
|
|
3796
3796
|
[field.renderFooter]
|
|
3797
3797
|
);
|
|
3798
|
-
(0,
|
|
3798
|
+
(0, import_react17.useEffect)(() => {
|
|
3799
3799
|
search(searchQuery, filters);
|
|
3800
3800
|
}, []);
|
|
3801
3801
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -3968,7 +3968,7 @@ var ExternalField = ({
|
|
|
3968
3968
|
var _a, _b, _c;
|
|
3969
3969
|
const validField = field;
|
|
3970
3970
|
const deprecatedField = field;
|
|
3971
|
-
(0,
|
|
3971
|
+
(0, import_react18.useEffect)(() => {
|
|
3972
3972
|
if (deprecatedField.adaptor) {
|
|
3973
3973
|
console.error(
|
|
3974
3974
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
|
@@ -4230,12 +4230,12 @@ var ObjectField = ({
|
|
|
4230
4230
|
|
|
4231
4231
|
// lib/use-safe-id.ts
|
|
4232
4232
|
init_react_import();
|
|
4233
|
-
var
|
|
4233
|
+
var import_react19 = __toESM(require("react"));
|
|
4234
4234
|
var useSafeId = () => {
|
|
4235
|
-
if (typeof
|
|
4236
|
-
return
|
|
4235
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
|
4236
|
+
return import_react19.default.useId();
|
|
4237
4237
|
}
|
|
4238
|
-
const [id] = (0,
|
|
4238
|
+
const [id] = (0, import_react19.useState)(generateId());
|
|
4239
4239
|
return id;
|
|
4240
4240
|
};
|
|
4241
4241
|
|
|
@@ -4269,7 +4269,7 @@ var FieldLabelInternal = ({
|
|
|
4269
4269
|
readOnly
|
|
4270
4270
|
}) => {
|
|
4271
4271
|
const overrides = useAppStore((s) => s.overrides);
|
|
4272
|
-
const Wrapper = (0,
|
|
4272
|
+
const Wrapper = (0, import_react20.useMemo)(
|
|
4273
4273
|
() => overrides.fieldLabel || FieldLabel,
|
|
4274
4274
|
[overrides]
|
|
4275
4275
|
);
|
|
@@ -4296,7 +4296,7 @@ function AutoFieldInternal(props) {
|
|
|
4296
4296
|
var _a2;
|
|
4297
4297
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
|
4298
4298
|
});
|
|
4299
|
-
const nestedFieldContext = (0,
|
|
4299
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
|
4300
4300
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
|
4301
4301
|
const field = props.field;
|
|
4302
4302
|
const label = field.label;
|
|
@@ -4330,7 +4330,7 @@ function AutoFieldInternal(props) {
|
|
|
4330
4330
|
Label: Label2,
|
|
4331
4331
|
id: resolvedId
|
|
4332
4332
|
});
|
|
4333
|
-
const onFocus = (0,
|
|
4333
|
+
const onFocus = (0, import_react20.useCallback)(
|
|
4334
4334
|
(e) => {
|
|
4335
4335
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
4336
4336
|
e.stopPropagation();
|
|
@@ -4344,7 +4344,7 @@ function AutoFieldInternal(props) {
|
|
|
4344
4344
|
},
|
|
4345
4345
|
[mergedProps.name]
|
|
4346
4346
|
);
|
|
4347
|
-
const onBlur = (0,
|
|
4347
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
|
4348
4348
|
if ("name" in e.target) {
|
|
4349
4349
|
dispatch({
|
|
4350
4350
|
type: "setUi",
|
|
@@ -4397,20 +4397,20 @@ function AutoFieldInternal(props) {
|
|
|
4397
4397
|
function AutoFieldPrivate(props) {
|
|
4398
4398
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
|
4399
4399
|
const { value, onChange } = props;
|
|
4400
|
-
const [localValue, setLocalValue] = (0,
|
|
4401
|
-
const onChangeLocal = (0,
|
|
4400
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
|
4401
|
+
const onChangeLocal = (0, import_react20.useCallback)(
|
|
4402
4402
|
(val, ui) => {
|
|
4403
4403
|
setLocalValue(val);
|
|
4404
4404
|
onChange(val, ui);
|
|
4405
4405
|
},
|
|
4406
4406
|
[onChange]
|
|
4407
4407
|
);
|
|
4408
|
-
(0,
|
|
4408
|
+
(0, import_react20.useEffect)(() => {
|
|
4409
4409
|
if (!isFocused) {
|
|
4410
4410
|
setLocalValue(value);
|
|
4411
4411
|
}
|
|
4412
4412
|
}, [value]);
|
|
4413
|
-
(0,
|
|
4413
|
+
(0, import_react20.useEffect)(() => {
|
|
4414
4414
|
if (!isFocused) {
|
|
4415
4415
|
if (value !== localValue) {
|
|
4416
4416
|
setLocalValue(value);
|
|
@@ -4424,7 +4424,7 @@ function AutoFieldPrivate(props) {
|
|
|
4424
4424
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
|
4425
4425
|
}
|
|
4426
4426
|
function AutoField(props) {
|
|
4427
|
-
const DefaultLabel = (0,
|
|
4427
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
|
4428
4428
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4429
4429
|
"div",
|
|
4430
4430
|
__spreadProps(__spreadValues({}, labelProps), {
|
|
@@ -4461,11 +4461,11 @@ var import_react34 = require("react");
|
|
|
4461
4461
|
|
|
4462
4462
|
// components/DraggableComponent/index.tsx
|
|
4463
4463
|
init_react_import();
|
|
4464
|
-
var
|
|
4464
|
+
var import_react24 = require("react");
|
|
4465
4465
|
|
|
4466
4466
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4467
4467
|
init_react_import();
|
|
4468
|
-
var styles_module_default11 = { "DraggableComponent": "
|
|
4468
|
+
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1vaqy_1", "DraggableComponent-overlayWrapper": "_DraggableComponent-overlayWrapper_1vaqy_12", "DraggableComponent-overlay": "_DraggableComponent-overlay_1vaqy_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1vaqy_34", "DraggableComponent--hover": "_DraggableComponent--hover_1vaqy_50", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1vaqy_57", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1vaqy_71", "DraggableComponent-actions": "_DraggableComponent-actions_1vaqy_71" };
|
|
4469
4469
|
|
|
4470
4470
|
// components/DraggableComponent/index.tsx
|
|
4471
4471
|
var import_react_dom2 = require("react-dom");
|
|
@@ -4491,11 +4491,11 @@ function getDeepScrollPosition(element) {
|
|
|
4491
4491
|
|
|
4492
4492
|
// components/DropZone/context.tsx
|
|
4493
4493
|
init_react_import();
|
|
4494
|
-
var
|
|
4494
|
+
var import_react21 = require("react");
|
|
4495
4495
|
var import_zustand3 = require("zustand");
|
|
4496
4496
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4497
|
-
var dropZoneContext = (0,
|
|
4498
|
-
var ZoneStoreContext = (0,
|
|
4497
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
|
4498
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
|
4499
4499
|
(0, import_zustand3.createStore)(() => ({
|
|
4500
4500
|
zoneDepthIndex: {},
|
|
4501
4501
|
nextZoneDepthIndex: {},
|
|
@@ -4518,7 +4518,7 @@ var DropZoneProvider = ({
|
|
|
4518
4518
|
value
|
|
4519
4519
|
}) => {
|
|
4520
4520
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4521
|
-
const registerZone = (0,
|
|
4521
|
+
const registerZone = (0, import_react21.useCallback)(
|
|
4522
4522
|
(zoneCompound) => {
|
|
4523
4523
|
dispatch({
|
|
4524
4524
|
type: "registerZone",
|
|
@@ -4527,7 +4527,7 @@ var DropZoneProvider = ({
|
|
|
4527
4527
|
},
|
|
4528
4528
|
[dispatch]
|
|
4529
4529
|
);
|
|
4530
|
-
const memoValue = (0,
|
|
4530
|
+
const memoValue = (0, import_react21.useMemo)(
|
|
4531
4531
|
() => __spreadValues({
|
|
4532
4532
|
registerZone
|
|
4533
4533
|
}, value),
|
|
@@ -4537,7 +4537,7 @@ var DropZoneProvider = ({
|
|
|
4537
4537
|
};
|
|
4538
4538
|
|
|
4539
4539
|
// components/DraggableComponent/index.tsx
|
|
4540
|
-
var
|
|
4540
|
+
var import_shallow2 = require("zustand/react/shallow");
|
|
4541
4541
|
var import_sortable2 = require("@dnd-kit/react/sortable");
|
|
4542
4542
|
|
|
4543
4543
|
// lib/accumulate-transform.ts
|
|
@@ -4557,23 +4557,23 @@ function accumulateTransform(el) {
|
|
|
4557
4557
|
|
|
4558
4558
|
// lib/use-context-store.ts
|
|
4559
4559
|
init_react_import();
|
|
4560
|
-
var
|
|
4560
|
+
var import_react22 = require("react");
|
|
4561
4561
|
var import_zustand4 = require("zustand");
|
|
4562
|
-
var
|
|
4562
|
+
var import_shallow = require("zustand/react/shallow");
|
|
4563
4563
|
function useContextStore(context, selector) {
|
|
4564
|
-
const store = (0,
|
|
4564
|
+
const store = (0, import_react22.useContext)(context);
|
|
4565
4565
|
if (!store) {
|
|
4566
4566
|
throw new Error("useContextStore must be used inside context");
|
|
4567
4567
|
}
|
|
4568
|
-
return (0, import_zustand4.useStore)(store, (0,
|
|
4568
|
+
return (0, import_zustand4.useStore)(store, (0, import_shallow.useShallow)(selector));
|
|
4569
4569
|
}
|
|
4570
4570
|
|
|
4571
4571
|
// lib/dnd/use-on-drag-finished.ts
|
|
4572
4572
|
init_react_import();
|
|
4573
|
-
var
|
|
4573
|
+
var import_react23 = require("react");
|
|
4574
4574
|
var useOnDragFinished = (cb, deps = []) => {
|
|
4575
4575
|
const appStore = useAppStoreApi();
|
|
4576
|
-
return (0,
|
|
4576
|
+
return (0, import_react23.useCallback)(() => {
|
|
4577
4577
|
let dispose = () => {
|
|
4578
4578
|
};
|
|
4579
4579
|
const processDragging = (isDragging2) => {
|
|
@@ -4619,6 +4619,9 @@ var DefaultActionBar = ({
|
|
|
4619
4619
|
] }),
|
|
4620
4620
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
|
|
4621
4621
|
] });
|
|
4622
|
+
var DefaultOverlay = ({
|
|
4623
|
+
children
|
|
4624
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children });
|
|
4622
4625
|
var DraggableComponent = ({
|
|
4623
4626
|
children,
|
|
4624
4627
|
depth,
|
|
@@ -4643,9 +4646,9 @@ var DraggableComponent = ({
|
|
|
4643
4646
|
const overrides = useAppStore((s) => s.overrides);
|
|
4644
4647
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4645
4648
|
const iframe = useAppStore((s) => s.iframe);
|
|
4646
|
-
const ctx = (0,
|
|
4647
|
-
const [localZones, setLocalZones] = (0,
|
|
4648
|
-
const registerLocalZone = (0,
|
|
4649
|
+
const ctx = (0, import_react24.useContext)(dropZoneContext);
|
|
4650
|
+
const [localZones, setLocalZones] = (0, import_react24.useState)({});
|
|
4651
|
+
const registerLocalZone = (0, import_react24.useCallback)(
|
|
4649
4652
|
(zoneCompound2, active) => {
|
|
4650
4653
|
var _a;
|
|
4651
4654
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
|
@@ -4655,7 +4658,7 @@ var DraggableComponent = ({
|
|
|
4655
4658
|
},
|
|
4656
4659
|
[setLocalZones]
|
|
4657
4660
|
);
|
|
4658
|
-
const unregisterLocalZone = (0,
|
|
4661
|
+
const unregisterLocalZone = (0, import_react24.useCallback)(
|
|
4659
4662
|
(zoneCompound2) => {
|
|
4660
4663
|
var _a;
|
|
4661
4664
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
|
@@ -4668,19 +4671,19 @@ var DraggableComponent = ({
|
|
|
4668
4671
|
[setLocalZones]
|
|
4669
4672
|
);
|
|
4670
4673
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
|
4671
|
-
const path = useAppStore((0,
|
|
4674
|
+
const path = useAppStore((0, import_shallow2.useShallow)((s) => {
|
|
4672
4675
|
var _a;
|
|
4673
4676
|
return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
|
|
4674
4677
|
}));
|
|
4675
4678
|
const permissions = useAppStore(
|
|
4676
|
-
(0,
|
|
4679
|
+
(0, import_shallow2.useShallow)((s) => {
|
|
4677
4680
|
const item = getItem({ index, zone: zoneCompound }, s.state);
|
|
4678
4681
|
return s.permissions.getPermissions({ item });
|
|
4679
4682
|
})
|
|
4680
4683
|
);
|
|
4681
|
-
const zoneStore = (0,
|
|
4682
|
-
const [dragAxis, setDragAxis] = (0,
|
|
4683
|
-
const dynamicCollisionDetector = (0,
|
|
4684
|
+
const zoneStore = (0, import_react24.useContext)(ZoneStoreContext);
|
|
4685
|
+
const [dragAxis, setDragAxis] = (0, import_react24.useState)(userDragAxis || autoDragAxis);
|
|
4686
|
+
const dynamicCollisionDetector = (0, import_react24.useMemo)(
|
|
4684
4687
|
() => createDynamicCollisionDetector(dragAxis),
|
|
4685
4688
|
[dragAxis]
|
|
4686
4689
|
);
|
|
@@ -4712,7 +4715,7 @@ var DraggableComponent = ({
|
|
|
4712
4715
|
},
|
|
4713
4716
|
feedback: "clone"
|
|
4714
4717
|
});
|
|
4715
|
-
(0,
|
|
4718
|
+
(0, import_react24.useEffect)(() => {
|
|
4716
4719
|
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
|
4717
4720
|
sortable.droppable.disabled = !isEnabled;
|
|
4718
4721
|
sortable.draggable.disabled = !permissions.drag;
|
|
@@ -4729,8 +4732,8 @@ var DraggableComponent = ({
|
|
|
4729
4732
|
}
|
|
4730
4733
|
return cleanup;
|
|
4731
4734
|
}, [permissions.drag, zoneCompound]);
|
|
4732
|
-
const ref = (0,
|
|
4733
|
-
const refSetter = (0,
|
|
4735
|
+
const ref = (0, import_react24.useRef)(null);
|
|
4736
|
+
const refSetter = (0, import_react24.useCallback)(
|
|
4734
4737
|
(el) => {
|
|
4735
4738
|
sortableRef(el);
|
|
4736
4739
|
if (el) {
|
|
@@ -4739,14 +4742,14 @@ var DraggableComponent = ({
|
|
|
4739
4742
|
},
|
|
4740
4743
|
[sortableRef]
|
|
4741
4744
|
);
|
|
4742
|
-
const [portalEl, setPortalEl] = (0,
|
|
4743
|
-
(0,
|
|
4745
|
+
const [portalEl, setPortalEl] = (0, import_react24.useState)();
|
|
4746
|
+
(0, import_react24.useEffect)(() => {
|
|
4744
4747
|
var _a, _b, _c;
|
|
4745
4748
|
setPortalEl(
|
|
4746
4749
|
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
|
|
4747
4750
|
);
|
|
4748
4751
|
}, [iframe.enabled, ref.current]);
|
|
4749
|
-
const getStyle = (0,
|
|
4752
|
+
const getStyle = (0, import_react24.useCallback)(() => {
|
|
4750
4753
|
var _a, _b, _c;
|
|
4751
4754
|
if (!ref.current) return;
|
|
4752
4755
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4771,11 +4774,11 @@ var DraggableComponent = ({
|
|
|
4771
4774
|
};
|
|
4772
4775
|
return style2;
|
|
4773
4776
|
}, [ref.current]);
|
|
4774
|
-
const [style, setStyle] = (0,
|
|
4775
|
-
const sync = (0,
|
|
4777
|
+
const [style, setStyle] = (0, import_react24.useState)();
|
|
4778
|
+
const sync = (0, import_react24.useCallback)(() => {
|
|
4776
4779
|
setStyle(getStyle());
|
|
4777
4780
|
}, [ref.current, iframe]);
|
|
4778
|
-
(0,
|
|
4781
|
+
(0, import_react24.useEffect)(() => {
|
|
4779
4782
|
if (ref.current) {
|
|
4780
4783
|
const observer = new ResizeObserver(sync);
|
|
4781
4784
|
observer.observe(ref.current);
|
|
@@ -4785,13 +4788,13 @@ var DraggableComponent = ({
|
|
|
4785
4788
|
}
|
|
4786
4789
|
}, [ref.current]);
|
|
4787
4790
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
|
4788
|
-
const hideOverlay = (0,
|
|
4791
|
+
const hideOverlay = (0, import_react24.useCallback)(() => {
|
|
4789
4792
|
setIsVisible(false);
|
|
4790
4793
|
}, []);
|
|
4791
|
-
const showOverlay = (0,
|
|
4794
|
+
const showOverlay = (0, import_react24.useCallback)(() => {
|
|
4792
4795
|
setIsVisible(true);
|
|
4793
4796
|
}, []);
|
|
4794
|
-
(0,
|
|
4797
|
+
(0, import_react24.useEffect)(() => {
|
|
4795
4798
|
var _a;
|
|
4796
4799
|
registerNode(id, {
|
|
4797
4800
|
methods: { sync, showOverlay, hideOverlay },
|
|
@@ -4808,13 +4811,20 @@ var DraggableComponent = ({
|
|
|
4808
4811
|
});
|
|
4809
4812
|
};
|
|
4810
4813
|
}, [id, zoneCompound, index, componentType, sync]);
|
|
4811
|
-
const CustomActionBar = (0,
|
|
4814
|
+
const CustomActionBar = (0, import_react24.useMemo)(
|
|
4812
4815
|
() => overrides.actionBar || DefaultActionBar,
|
|
4813
4816
|
[overrides.actionBar]
|
|
4814
4817
|
);
|
|
4815
|
-
const
|
|
4818
|
+
const CustomOverlay = (0, import_react24.useMemo)(
|
|
4819
|
+
() => overrides.componentOverlay || DefaultOverlay,
|
|
4820
|
+
[overrides.componentOverlay]
|
|
4821
|
+
);
|
|
4822
|
+
const onClick = (0, import_react24.useCallback)(
|
|
4816
4823
|
(e) => {
|
|
4817
|
-
e.
|
|
4824
|
+
const el = e.target;
|
|
4825
|
+
if (!el.closest("[data-puck-overlay-portal]")) {
|
|
4826
|
+
e.stopPropagation();
|
|
4827
|
+
}
|
|
4818
4828
|
dispatch({
|
|
4819
4829
|
type: "setUi",
|
|
4820
4830
|
ui: {
|
|
@@ -4825,7 +4835,7 @@ var DraggableComponent = ({
|
|
|
4825
4835
|
[index, zoneCompound, id]
|
|
4826
4836
|
);
|
|
4827
4837
|
const appStore = useAppStoreApi();
|
|
4828
|
-
const onSelectParent = (0,
|
|
4838
|
+
const onSelectParent = (0, import_react24.useCallback)(() => {
|
|
4829
4839
|
const { nodes, zones } = appStore.getState().state.indexes;
|
|
4830
4840
|
const node = nodes[id];
|
|
4831
4841
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
|
@@ -4846,26 +4856,26 @@ var DraggableComponent = ({
|
|
|
4846
4856
|
}
|
|
4847
4857
|
});
|
|
4848
4858
|
}, [ctx, path]);
|
|
4849
|
-
const onDuplicate = (0,
|
|
4859
|
+
const onDuplicate = (0, import_react24.useCallback)(() => {
|
|
4850
4860
|
dispatch({
|
|
4851
4861
|
type: "duplicate",
|
|
4852
4862
|
sourceIndex: index,
|
|
4853
4863
|
sourceZone: zoneCompound
|
|
4854
4864
|
});
|
|
4855
4865
|
}, [index, zoneCompound]);
|
|
4856
|
-
const onDelete = (0,
|
|
4866
|
+
const onDelete = (0, import_react24.useCallback)(() => {
|
|
4857
4867
|
dispatch({
|
|
4858
4868
|
type: "remove",
|
|
4859
4869
|
index,
|
|
4860
4870
|
zone: zoneCompound
|
|
4861
4871
|
});
|
|
4862
4872
|
}, [index, zoneCompound]);
|
|
4863
|
-
const [hover, setHover] = (0,
|
|
4873
|
+
const [hover, setHover] = (0, import_react24.useState)(false);
|
|
4864
4874
|
const indicativeHover = useContextStore(
|
|
4865
4875
|
ZoneStoreContext,
|
|
4866
4876
|
(s) => s.hoveringComponent === id
|
|
4867
4877
|
);
|
|
4868
|
-
(0,
|
|
4878
|
+
(0, import_react24.useEffect)(() => {
|
|
4869
4879
|
if (!ref.current) {
|
|
4870
4880
|
return;
|
|
4871
4881
|
}
|
|
@@ -4910,10 +4920,10 @@ var DraggableComponent = ({
|
|
|
4910
4920
|
thisIsDragging,
|
|
4911
4921
|
inDroppableZone
|
|
4912
4922
|
]);
|
|
4913
|
-
const [isVisible, setIsVisible] = (0,
|
|
4914
|
-
const [dragFinished, setDragFinished] = (0,
|
|
4915
|
-
const [_, startTransition] = (0,
|
|
4916
|
-
(0,
|
|
4923
|
+
const [isVisible, setIsVisible] = (0, import_react24.useState)(false);
|
|
4924
|
+
const [dragFinished, setDragFinished] = (0, import_react24.useState)(true);
|
|
4925
|
+
const [_, startTransition] = (0, import_react24.useTransition)();
|
|
4926
|
+
(0, import_react24.useEffect)(() => {
|
|
4917
4927
|
startTransition(() => {
|
|
4918
4928
|
if (hover || indicativeHover || isSelected) {
|
|
4919
4929
|
sync();
|
|
@@ -4924,7 +4934,7 @@ var DraggableComponent = ({
|
|
|
4924
4934
|
}
|
|
4925
4935
|
});
|
|
4926
4936
|
}, [hover, indicativeHover, isSelected, iframe]);
|
|
4927
|
-
const [thisWasDragging, setThisWasDragging] = (0,
|
|
4937
|
+
const [thisWasDragging, setThisWasDragging] = (0, import_react24.useState)(false);
|
|
4928
4938
|
const onDragFinished = useOnDragFinished((finished) => {
|
|
4929
4939
|
if (finished) {
|
|
4930
4940
|
startTransition(() => {
|
|
@@ -4935,15 +4945,15 @@ var DraggableComponent = ({
|
|
|
4935
4945
|
setDragFinished(false);
|
|
4936
4946
|
}
|
|
4937
4947
|
});
|
|
4938
|
-
(0,
|
|
4948
|
+
(0, import_react24.useEffect)(() => {
|
|
4939
4949
|
if (thisIsDragging) {
|
|
4940
4950
|
setThisWasDragging(true);
|
|
4941
4951
|
}
|
|
4942
4952
|
}, [thisIsDragging]);
|
|
4943
|
-
(0,
|
|
4953
|
+
(0, import_react24.useEffect)(() => {
|
|
4944
4954
|
if (thisWasDragging) return onDragFinished();
|
|
4945
4955
|
}, [thisWasDragging, onDragFinished]);
|
|
4946
|
-
const syncActionsPosition = (0,
|
|
4956
|
+
const syncActionsPosition = (0, import_react24.useCallback)(
|
|
4947
4957
|
(el) => {
|
|
4948
4958
|
if (el) {
|
|
4949
4959
|
const view = el.ownerDocument.defaultView;
|
|
@@ -4968,7 +4978,7 @@ var DraggableComponent = ({
|
|
|
4968
4978
|
},
|
|
4969
4979
|
[zoom]
|
|
4970
4980
|
);
|
|
4971
|
-
(0,
|
|
4981
|
+
(0, import_react24.useEffect)(() => {
|
|
4972
4982
|
if (userDragAxis) {
|
|
4973
4983
|
setDragAxis(userDragAxis);
|
|
4974
4984
|
return;
|
|
@@ -4982,11 +4992,11 @@ var DraggableComponent = ({
|
|
|
4982
4992
|
}
|
|
4983
4993
|
setDragAxis(autoDragAxis);
|
|
4984
4994
|
}, [ref, userDragAxis, autoDragAxis]);
|
|
4985
|
-
const parentAction = (0,
|
|
4995
|
+
const parentAction = (0, import_react24.useMemo)(
|
|
4986
4996
|
() => (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 }) }),
|
|
4987
4997
|
[ctx == null ? void 0 : ctx.areaId]
|
|
4988
4998
|
);
|
|
4989
|
-
const nextContextValue = (0,
|
|
4999
|
+
const nextContextValue = (0, import_react24.useMemo)(
|
|
4990
5000
|
() => __spreadProps(__spreadValues({}, ctx), {
|
|
4991
5001
|
areaId: id,
|
|
4992
5002
|
zoneCompound,
|
|
@@ -5054,7 +5064,16 @@ var DraggableComponent = ({
|
|
|
5054
5064
|
)
|
|
5055
5065
|
}
|
|
5056
5066
|
),
|
|
5057
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("
|
|
5067
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlayWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5068
|
+
CustomOverlay,
|
|
5069
|
+
{
|
|
5070
|
+
componentId: id,
|
|
5071
|
+
componentType,
|
|
5072
|
+
hover,
|
|
5073
|
+
isSelected,
|
|
5074
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
|
5075
|
+
}
|
|
5076
|
+
) })
|
|
5058
5077
|
]
|
|
5059
5078
|
}
|
|
5060
5079
|
),
|
|
@@ -5073,7 +5092,7 @@ var import_react35 = require("@dnd-kit/react");
|
|
|
5073
5092
|
|
|
5074
5093
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
5075
5094
|
init_react_import();
|
|
5076
|
-
var
|
|
5095
|
+
var import_react25 = require("react");
|
|
5077
5096
|
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
|
5078
5097
|
var useMinEmptyHeight = ({
|
|
5079
5098
|
zoneCompound,
|
|
@@ -5081,8 +5100,8 @@ var useMinEmptyHeight = ({
|
|
|
5081
5100
|
ref
|
|
5082
5101
|
}) => {
|
|
5083
5102
|
const appStore = useAppStoreApi();
|
|
5084
|
-
const [prevHeight, setPrevHeight] = (0,
|
|
5085
|
-
const [isAnimating, setIsAnimating] = (0,
|
|
5103
|
+
const [prevHeight, setPrevHeight] = (0, import_react25.useState)(0);
|
|
5104
|
+
const [isAnimating, setIsAnimating] = (0, import_react25.useState)(false);
|
|
5086
5105
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
|
5087
5106
|
var _a, _b;
|
|
5088
5107
|
return {
|
|
@@ -5090,7 +5109,7 @@ var useMinEmptyHeight = ({
|
|
|
5090
5109
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
|
5091
5110
|
};
|
|
5092
5111
|
});
|
|
5093
|
-
const numItems = (0,
|
|
5112
|
+
const numItems = (0, import_react25.useRef)(0);
|
|
5094
5113
|
const onDragFinished = useOnDragFinished(
|
|
5095
5114
|
(finished) => {
|
|
5096
5115
|
var _a;
|
|
@@ -5125,7 +5144,7 @@ var useMinEmptyHeight = ({
|
|
|
5125
5144
|
},
|
|
5126
5145
|
[appStore, prevHeight, zoneCompound]
|
|
5127
5146
|
);
|
|
5128
|
-
(0,
|
|
5147
|
+
(0, import_react25.useEffect)(() => {
|
|
5129
5148
|
if (draggedItem && ref.current) {
|
|
5130
5149
|
if (isZone) {
|
|
5131
5150
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -5156,15 +5175,15 @@ function assignRefs(refs, node) {
|
|
|
5156
5175
|
|
|
5157
5176
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5158
5177
|
init_react_import();
|
|
5159
|
-
var
|
|
5178
|
+
var import_react28 = require("react");
|
|
5160
5179
|
|
|
5161
5180
|
// lib/dnd/use-rendered-callback.ts
|
|
5162
5181
|
init_react_import();
|
|
5163
|
-
var
|
|
5164
|
-
var
|
|
5182
|
+
var import_react26 = require("@dnd-kit/react");
|
|
5183
|
+
var import_react27 = require("react");
|
|
5165
5184
|
function useRenderedCallback(callback, deps) {
|
|
5166
|
-
const manager = (0,
|
|
5167
|
-
return (0,
|
|
5185
|
+
const manager = (0, import_react26.useDragDropManager)();
|
|
5186
|
+
return (0, import_react27.useCallback)(
|
|
5168
5187
|
(...args) => __async(this, null, function* () {
|
|
5169
5188
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
|
5170
5189
|
return callback(...args);
|
|
@@ -5175,14 +5194,14 @@ function useRenderedCallback(callback, deps) {
|
|
|
5175
5194
|
|
|
5176
5195
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5177
5196
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
5178
|
-
const zoneStore = (0,
|
|
5197
|
+
const zoneStore = (0, import_react28.useContext)(ZoneStoreContext);
|
|
5179
5198
|
const preview = useContextStore(
|
|
5180
5199
|
ZoneStoreContext,
|
|
5181
5200
|
(s) => s.previewIndex[zoneCompound]
|
|
5182
5201
|
);
|
|
5183
5202
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
|
5184
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
|
5185
|
-
const [localPreview, setLocalPreview] = (0,
|
|
5203
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react28.useState)(contentIds);
|
|
5204
|
+
const [localPreview, setLocalPreview] = (0, import_react28.useState)(
|
|
5186
5205
|
preview
|
|
5187
5206
|
);
|
|
5188
5207
|
const updateContent = useRenderedCallback(
|
|
@@ -5217,7 +5236,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5217
5236
|
},
|
|
5218
5237
|
[]
|
|
5219
5238
|
);
|
|
5220
|
-
(0,
|
|
5239
|
+
(0, import_react28.useEffect)(() => {
|
|
5221
5240
|
var _a;
|
|
5222
5241
|
const s = zoneStore.getState();
|
|
5223
5242
|
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
|
@@ -5235,16 +5254,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5235
5254
|
|
|
5236
5255
|
// components/DropZone/lib/use-drag-axis.ts
|
|
5237
5256
|
init_react_import();
|
|
5238
|
-
var
|
|
5257
|
+
var import_react29 = require("react");
|
|
5239
5258
|
var GRID_DRAG_AXIS = "dynamic";
|
|
5240
5259
|
var FLEX_ROW_DRAG_AXIS = "x";
|
|
5241
5260
|
var DEFAULT_DRAG_AXIS = "y";
|
|
5242
5261
|
var useDragAxis = (ref, collisionAxis) => {
|
|
5243
5262
|
const status = useAppStore((s) => s.status);
|
|
5244
|
-
const [dragAxis, setDragAxis] = (0,
|
|
5263
|
+
const [dragAxis, setDragAxis] = (0, import_react29.useState)(
|
|
5245
5264
|
collisionAxis || DEFAULT_DRAG_AXIS
|
|
5246
5265
|
);
|
|
5247
|
-
const calculateDragAxis = (0,
|
|
5266
|
+
const calculateDragAxis = (0, import_react29.useCallback)(() => {
|
|
5248
5267
|
if (ref.current) {
|
|
5249
5268
|
const computedStyle = window.getComputedStyle(ref.current);
|
|
5250
5269
|
if (computedStyle.display === "grid") {
|
|
@@ -5256,7 +5275,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5256
5275
|
}
|
|
5257
5276
|
}
|
|
5258
5277
|
}, [ref.current]);
|
|
5259
|
-
(0,
|
|
5278
|
+
(0, import_react29.useEffect)(() => {
|
|
5260
5279
|
const onViewportChange = () => {
|
|
5261
5280
|
calculateDragAxis();
|
|
5262
5281
|
};
|
|
@@ -5265,57 +5284,92 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5265
5284
|
window.removeEventListener("viewportchange", onViewportChange);
|
|
5266
5285
|
};
|
|
5267
5286
|
}, []);
|
|
5268
|
-
(0,
|
|
5287
|
+
(0, import_react29.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
|
5269
5288
|
return [dragAxis, calculateDragAxis];
|
|
5270
5289
|
};
|
|
5271
5290
|
|
|
5272
5291
|
// components/DropZone/index.tsx
|
|
5273
|
-
var
|
|
5292
|
+
var import_shallow4 = require("zustand/react/shallow");
|
|
5274
5293
|
|
|
5275
5294
|
// components/Render/index.tsx
|
|
5276
5295
|
init_react_import();
|
|
5277
5296
|
|
|
5278
5297
|
// lib/use-slots.tsx
|
|
5279
5298
|
init_react_import();
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5299
|
+
|
|
5300
|
+
// lib/field-transforms/use-field-transforms.tsx
|
|
5301
|
+
init_react_import();
|
|
5302
|
+
var import_react30 = require("react");
|
|
5303
|
+
function useFieldTransforms(config, item, transforms, readOnly, forceReadOnly) {
|
|
5304
|
+
const mappers = (0, import_react30.useMemo)(() => {
|
|
5305
|
+
return Object.keys(transforms).reduce((acc, _fieldType) => {
|
|
5306
|
+
const fieldType = _fieldType;
|
|
5307
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
5308
|
+
[fieldType]: (_a) => {
|
|
5309
|
+
var _b = _a, {
|
|
5310
|
+
parentId
|
|
5311
|
+
} = _b, params = __objRest(_b, [
|
|
5312
|
+
"parentId"
|
|
5313
|
+
]);
|
|
5314
|
+
const wildcardPath = params.propPath.replace(/\[\d+\]/g, "[*]");
|
|
5315
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[params.propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly || false;
|
|
5316
|
+
const fn = transforms[fieldType];
|
|
5317
|
+
return fn == null ? void 0 : fn(__spreadProps(__spreadValues({}, params), {
|
|
5318
|
+
isReadOnly,
|
|
5319
|
+
componentId: parentId
|
|
5320
|
+
}));
|
|
5321
|
+
}
|
|
5322
|
+
});
|
|
5323
|
+
}, {});
|
|
5324
|
+
}, [transforms, readOnly, forceReadOnly]);
|
|
5325
|
+
const transformedProps = (0, import_react30.useMemo)(() => {
|
|
5326
|
+
const mapped = mapFields(item, mappers, config).props;
|
|
5300
5327
|
return mapped;
|
|
5301
|
-
}, [config, item,
|
|
5302
|
-
const mergedProps = (0,
|
|
5303
|
-
() => __spreadValues(__spreadValues({}, item.props),
|
|
5304
|
-
[item.props,
|
|
5328
|
+
}, [config, item, mappers]);
|
|
5329
|
+
const mergedProps = (0, import_react30.useMemo)(
|
|
5330
|
+
() => __spreadValues(__spreadValues({}, item.props), transformedProps),
|
|
5331
|
+
[item.props, transformedProps]
|
|
5305
5332
|
);
|
|
5306
5333
|
return mergedProps;
|
|
5307
5334
|
}
|
|
5308
5335
|
|
|
5336
|
+
// lib/field-transforms/default-transforms/slot-transform.tsx
|
|
5337
|
+
init_react_import();
|
|
5338
|
+
var getSlotTransform = (renderSlotEdit, renderSlotRender = renderSlotEdit) => ({
|
|
5339
|
+
slot: ({ value: content, propName, field, isReadOnly }) => {
|
|
5340
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
|
5341
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
|
5342
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
|
5343
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
5344
|
+
}, dzProps), {
|
|
5345
|
+
zone: propName,
|
|
5346
|
+
content
|
|
5347
|
+
}));
|
|
5348
|
+
return Slot;
|
|
5349
|
+
}
|
|
5350
|
+
});
|
|
5351
|
+
|
|
5352
|
+
// lib/use-slots.tsx
|
|
5353
|
+
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
5354
|
+
return useFieldTransforms(
|
|
5355
|
+
config,
|
|
5356
|
+
item,
|
|
5357
|
+
getSlotTransform(renderSlotEdit, renderSlotRender),
|
|
5358
|
+
readOnly,
|
|
5359
|
+
forceReadOnly
|
|
5360
|
+
);
|
|
5361
|
+
}
|
|
5362
|
+
|
|
5309
5363
|
// components/Render/index.tsx
|
|
5310
|
-
var
|
|
5364
|
+
var import_react32 = __toESM(require("react"));
|
|
5311
5365
|
|
|
5312
5366
|
// components/SlotRender/index.tsx
|
|
5313
5367
|
init_react_import();
|
|
5314
|
-
var
|
|
5368
|
+
var import_shallow3 = require("zustand/react/shallow");
|
|
5315
5369
|
|
|
5316
5370
|
// components/SlotRender/server.tsx
|
|
5317
5371
|
init_react_import();
|
|
5318
|
-
var
|
|
5372
|
+
var import_react31 = require("react");
|
|
5319
5373
|
|
|
5320
5374
|
// components/ServerRender/index.tsx
|
|
5321
5375
|
init_react_import();
|
|
@@ -5384,7 +5438,7 @@ var Item = ({
|
|
|
5384
5438
|
})
|
|
5385
5439
|
);
|
|
5386
5440
|
};
|
|
5387
|
-
var SlotRender = (0,
|
|
5441
|
+
var SlotRender = (0, import_react31.forwardRef)(
|
|
5388
5442
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5389
5443
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5390
5444
|
if (!config.components[item.type]) {
|
|
@@ -5412,7 +5466,7 @@ var ContextSlotRender = ({
|
|
|
5412
5466
|
const config = useAppStore((s) => s.config);
|
|
5413
5467
|
const metadata = useAppStore((s) => s.metadata);
|
|
5414
5468
|
const slotContent = useAppStore(
|
|
5415
|
-
(0,
|
|
5469
|
+
(0, import_shallow3.useShallow)((s) => {
|
|
5416
5470
|
var _a, _b;
|
|
5417
5471
|
const indexes = s.state.indexes;
|
|
5418
5472
|
const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
|
|
@@ -5432,7 +5486,7 @@ var ContextSlotRender = ({
|
|
|
5432
5486
|
|
|
5433
5487
|
// components/Render/index.tsx
|
|
5434
5488
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
5435
|
-
var renderContext =
|
|
5489
|
+
var renderContext = import_react32.default.createContext({
|
|
5436
5490
|
config: { components: {} },
|
|
5437
5491
|
data: { root: {}, content: [] },
|
|
5438
5492
|
metadata: {}
|
|
@@ -5465,7 +5519,7 @@ function Render({
|
|
|
5465
5519
|
{ type: "root", props: pageProps },
|
|
5466
5520
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
|
5467
5521
|
);
|
|
5468
|
-
const nextContextValue = (0,
|
|
5522
|
+
const nextContextValue = (0, import_react32.useMemo)(
|
|
5469
5523
|
() => ({
|
|
5470
5524
|
mode: "render",
|
|
5471
5525
|
depth: 0
|
|
@@ -5478,12 +5532,259 @@ function Render({
|
|
|
5478
5532
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneRenderPure, { zone: rootZone }) }) });
|
|
5479
5533
|
}
|
|
5480
5534
|
|
|
5481
|
-
//
|
|
5535
|
+
// lib/field-transforms/default-transforms/inline-text-transform.tsx
|
|
5536
|
+
init_react_import();
|
|
5537
|
+
|
|
5538
|
+
// components/InlineTextField/index.tsx
|
|
5539
|
+
init_react_import();
|
|
5540
|
+
var import_react33 = require("react");
|
|
5541
|
+
|
|
5542
|
+
// lib/overlay-portal/index.tsx
|
|
5543
|
+
init_react_import();
|
|
5544
|
+
var registerOverlayPortal = (el, opts = {}) => {
|
|
5545
|
+
if (!el) return;
|
|
5546
|
+
const { disableDrag = false, disableDragOnFocus = true } = opts;
|
|
5547
|
+
const stopPropagation = (e) => {
|
|
5548
|
+
e.stopPropagation();
|
|
5549
|
+
};
|
|
5550
|
+
el.addEventListener("mouseover", stopPropagation, {
|
|
5551
|
+
capture: true
|
|
5552
|
+
});
|
|
5553
|
+
const onFocus = () => {
|
|
5554
|
+
setTimeout(() => {
|
|
5555
|
+
el.addEventListener("pointerdown", stopPropagation, {
|
|
5556
|
+
capture: true
|
|
5557
|
+
});
|
|
5558
|
+
}, 200);
|
|
5559
|
+
};
|
|
5560
|
+
const onBlur = () => {
|
|
5561
|
+
el.removeEventListener("pointerdown", stopPropagation, {
|
|
5562
|
+
capture: true
|
|
5563
|
+
});
|
|
5564
|
+
};
|
|
5565
|
+
if (disableDragOnFocus) {
|
|
5566
|
+
el.addEventListener("focus", onFocus, { capture: true });
|
|
5567
|
+
el.addEventListener("blur", onBlur, { capture: true });
|
|
5568
|
+
} else if (disableDrag) {
|
|
5569
|
+
el.addEventListener("pointerdown", stopPropagation, {
|
|
5570
|
+
capture: true
|
|
5571
|
+
});
|
|
5572
|
+
}
|
|
5573
|
+
el.setAttribute("data-puck-overlay-portal", "true");
|
|
5574
|
+
return () => {
|
|
5575
|
+
el.removeEventListener("mouseover", stopPropagation, {
|
|
5576
|
+
capture: true
|
|
5577
|
+
});
|
|
5578
|
+
if (disableDragOnFocus) {
|
|
5579
|
+
el.removeEventListener("focus", onFocus, { capture: true });
|
|
5580
|
+
el.removeEventListener("blur", onFocus, { capture: true });
|
|
5581
|
+
} else if (disableDrag) {
|
|
5582
|
+
el.removeEventListener("pointerdown", stopPropagation, {
|
|
5583
|
+
capture: true
|
|
5584
|
+
});
|
|
5585
|
+
}
|
|
5586
|
+
el.removeAttribute("data-puck-overlay-portal");
|
|
5587
|
+
};
|
|
5588
|
+
};
|
|
5589
|
+
|
|
5590
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css#css-module
|
|
5591
|
+
init_react_import();
|
|
5592
|
+
var styles_module_default13 = { "InlineTextField": "_InlineTextField_ilw2a_1" };
|
|
5593
|
+
|
|
5594
|
+
// lib/data/set-deep.ts
|
|
5595
|
+
init_react_import();
|
|
5596
|
+
function setDeep(node, path, newVal) {
|
|
5597
|
+
const parts = path.split(".");
|
|
5598
|
+
const newNode = __spreadValues({}, node);
|
|
5599
|
+
let cur = newNode;
|
|
5600
|
+
for (let i = 0; i < parts.length; i++) {
|
|
5601
|
+
const [prop, idxStr] = parts[i].replace("]", "").split("[");
|
|
5602
|
+
const isLast = i === parts.length - 1;
|
|
5603
|
+
if (idxStr !== void 0) {
|
|
5604
|
+
if (!Array.isArray(cur[prop])) {
|
|
5605
|
+
cur[prop] = [];
|
|
5606
|
+
}
|
|
5607
|
+
const idx = Number(idxStr);
|
|
5608
|
+
if (isLast) {
|
|
5609
|
+
cur[prop][idx] = newVal;
|
|
5610
|
+
continue;
|
|
5611
|
+
}
|
|
5612
|
+
if (cur[prop][idx] === void 0) cur[prop][idx] = {};
|
|
5613
|
+
cur = cur[prop][idx];
|
|
5614
|
+
continue;
|
|
5615
|
+
}
|
|
5616
|
+
if (isLast) {
|
|
5617
|
+
cur[prop] = newVal;
|
|
5618
|
+
continue;
|
|
5619
|
+
}
|
|
5620
|
+
if (cur[prop] === void 0) {
|
|
5621
|
+
cur[prop] = {};
|
|
5622
|
+
}
|
|
5623
|
+
cur = cur[prop];
|
|
5624
|
+
}
|
|
5625
|
+
return __spreadValues(__spreadValues({}, node), newNode);
|
|
5626
|
+
}
|
|
5627
|
+
|
|
5628
|
+
// lib/get-selector-for-id.ts
|
|
5629
|
+
init_react_import();
|
|
5630
|
+
var getSelectorForId = (state, id) => {
|
|
5631
|
+
const node = state.indexes.nodes[id];
|
|
5632
|
+
if (!node) return;
|
|
5633
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
5634
|
+
const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
|
5635
|
+
return { zone: zoneCompound, index };
|
|
5636
|
+
};
|
|
5637
|
+
|
|
5638
|
+
// components/InlineTextField/index.tsx
|
|
5482
5639
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
5483
|
-
var getClassName17 = get_class_name_factory_default("
|
|
5640
|
+
var getClassName17 = get_class_name_factory_default("InlineTextField", styles_module_default13);
|
|
5641
|
+
var InlineTextFieldInternal = ({
|
|
5642
|
+
propPath,
|
|
5643
|
+
componentId,
|
|
5644
|
+
value,
|
|
5645
|
+
isReadOnly,
|
|
5646
|
+
opts = {}
|
|
5647
|
+
}) => {
|
|
5648
|
+
var _a;
|
|
5649
|
+
const ref = (0, import_react33.useRef)(null);
|
|
5650
|
+
const appStoreApi = useAppStoreApi();
|
|
5651
|
+
const disableLineBreaks = (_a = opts.disableLineBreaks) != null ? _a : false;
|
|
5652
|
+
(0, import_react33.useEffect)(() => {
|
|
5653
|
+
const appStore = appStoreApi.getState();
|
|
5654
|
+
const data = appStore.state.indexes.nodes[componentId].data;
|
|
5655
|
+
const componentConfig = appStore.getComponentConfig(data.type);
|
|
5656
|
+
if (!componentConfig) {
|
|
5657
|
+
throw new Error(
|
|
5658
|
+
`InlineTextField Error: No config defined for ${data.type}`
|
|
5659
|
+
);
|
|
5660
|
+
}
|
|
5661
|
+
if (ref.current) {
|
|
5662
|
+
if (value !== ref.current.innerText) {
|
|
5663
|
+
ref.current.replaceChildren(value);
|
|
5664
|
+
}
|
|
5665
|
+
const cleanupPortal = registerOverlayPortal(ref.current);
|
|
5666
|
+
const handleInput = (e) => __async(void 0, null, function* () {
|
|
5667
|
+
var _a2;
|
|
5668
|
+
const appStore2 = appStoreApi.getState();
|
|
5669
|
+
const node = appStore2.state.indexes.nodes[componentId];
|
|
5670
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
5671
|
+
const index = (_a2 = appStore2.state.indexes.zones[zoneCompound]) == null ? void 0 : _a2.contentIds.indexOf(
|
|
5672
|
+
componentId
|
|
5673
|
+
);
|
|
5674
|
+
const newProps = setDeep(node.data.props, propPath, e.target.innerText);
|
|
5675
|
+
const resolvedData = yield appStore2.resolveComponentData(
|
|
5676
|
+
__spreadProps(__spreadValues({}, node.data), { props: newProps }),
|
|
5677
|
+
"replace"
|
|
5678
|
+
);
|
|
5679
|
+
appStore2.dispatch({
|
|
5680
|
+
type: "replace",
|
|
5681
|
+
data: resolvedData.node,
|
|
5682
|
+
destinationIndex: index,
|
|
5683
|
+
destinationZone: zoneCompound
|
|
5684
|
+
});
|
|
5685
|
+
});
|
|
5686
|
+
ref.current.addEventListener("input", handleInput);
|
|
5687
|
+
return () => {
|
|
5688
|
+
var _a2;
|
|
5689
|
+
(_a2 = ref.current) == null ? void 0 : _a2.removeEventListener("input", handleInput);
|
|
5690
|
+
cleanupPortal == null ? void 0 : cleanupPortal();
|
|
5691
|
+
};
|
|
5692
|
+
}
|
|
5693
|
+
}, [appStoreApi, ref.current, value]);
|
|
5694
|
+
const [isHovering, setIsHovering] = (0, import_react33.useState)(false);
|
|
5695
|
+
const [isFocused, setIsFocused] = (0, import_react33.useState)(false);
|
|
5696
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5697
|
+
"span",
|
|
5698
|
+
{
|
|
5699
|
+
className: getClassName17(),
|
|
5700
|
+
ref,
|
|
5701
|
+
contentEditable: isHovering || isFocused ? "plaintext-only" : "false",
|
|
5702
|
+
onClick: (e) => {
|
|
5703
|
+
e.preventDefault();
|
|
5704
|
+
e.stopPropagation();
|
|
5705
|
+
},
|
|
5706
|
+
onClickCapture: (e) => {
|
|
5707
|
+
e.preventDefault();
|
|
5708
|
+
e.stopPropagation();
|
|
5709
|
+
const itemSelector = getSelectorForId(
|
|
5710
|
+
appStoreApi.getState().state,
|
|
5711
|
+
componentId
|
|
5712
|
+
);
|
|
5713
|
+
appStoreApi.getState().setUi({ itemSelector });
|
|
5714
|
+
},
|
|
5715
|
+
onKeyDown: (e) => {
|
|
5716
|
+
e.stopPropagation();
|
|
5717
|
+
if (disableLineBreaks && e.key === "Enter" || isReadOnly) {
|
|
5718
|
+
e.preventDefault();
|
|
5719
|
+
}
|
|
5720
|
+
},
|
|
5721
|
+
onKeyUp: (e) => {
|
|
5722
|
+
e.stopPropagation();
|
|
5723
|
+
e.preventDefault();
|
|
5724
|
+
},
|
|
5725
|
+
onMouseOverCapture: () => setIsHovering(true),
|
|
5726
|
+
onMouseOutCapture: () => setIsHovering(false),
|
|
5727
|
+
onFocus: () => setIsFocused(true),
|
|
5728
|
+
onBlur: () => setIsFocused(false)
|
|
5729
|
+
}
|
|
5730
|
+
);
|
|
5731
|
+
};
|
|
5732
|
+
var InlineTextField = (0, import_react33.memo)(InlineTextFieldInternal);
|
|
5733
|
+
|
|
5734
|
+
// lib/field-transforms/default-transforms/inline-text-transform.tsx
|
|
5735
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
5736
|
+
var getInlineTextTransform = () => ({
|
|
5737
|
+
text: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5738
|
+
if (field.contentEditable) {
|
|
5739
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5740
|
+
InlineTextField,
|
|
5741
|
+
{
|
|
5742
|
+
propPath,
|
|
5743
|
+
componentId,
|
|
5744
|
+
value,
|
|
5745
|
+
opts: { disableLineBreaks: true },
|
|
5746
|
+
isReadOnly
|
|
5747
|
+
}
|
|
5748
|
+
);
|
|
5749
|
+
}
|
|
5750
|
+
return value;
|
|
5751
|
+
},
|
|
5752
|
+
textarea: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5753
|
+
if (field.contentEditable) {
|
|
5754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5755
|
+
InlineTextField,
|
|
5756
|
+
{
|
|
5757
|
+
propPath,
|
|
5758
|
+
componentId,
|
|
5759
|
+
value,
|
|
5760
|
+
isReadOnly
|
|
5761
|
+
}
|
|
5762
|
+
);
|
|
5763
|
+
}
|
|
5764
|
+
return value;
|
|
5765
|
+
},
|
|
5766
|
+
custom: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5767
|
+
if (field.contentEditable && typeof value === "string") {
|
|
5768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5769
|
+
InlineTextField,
|
|
5770
|
+
{
|
|
5771
|
+
propPath,
|
|
5772
|
+
componentId,
|
|
5773
|
+
value,
|
|
5774
|
+
isReadOnly
|
|
5775
|
+
}
|
|
5776
|
+
);
|
|
5777
|
+
}
|
|
5778
|
+
return value;
|
|
5779
|
+
}
|
|
5780
|
+
});
|
|
5781
|
+
|
|
5782
|
+
// components/DropZone/index.tsx
|
|
5783
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
5784
|
+
var getClassName18 = get_class_name_factory_default("DropZone", styles_module_default12);
|
|
5484
5785
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
|
5485
5786
|
var RENDER_DEBUG = false;
|
|
5486
|
-
var DropZoneEditPure = (props) => /* @__PURE__ */ (0,
|
|
5787
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneEdit, __spreadValues({}, props));
|
|
5487
5788
|
var DropZoneChild = ({
|
|
5488
5789
|
zoneCompound,
|
|
5489
5790
|
componentId,
|
|
@@ -5498,7 +5799,7 @@ var DropZoneChild = ({
|
|
|
5498
5799
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
5499
5800
|
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
5500
5801
|
const nodeProps = useAppStore(
|
|
5501
|
-
(0,
|
|
5802
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5502
5803
|
var _a2;
|
|
5503
5804
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
|
|
5504
5805
|
})
|
|
@@ -5510,7 +5811,7 @@ var DropZoneChild = ({
|
|
|
5510
5811
|
}
|
|
5511
5812
|
);
|
|
5512
5813
|
const nodeReadOnly = useAppStore(
|
|
5513
|
-
(0,
|
|
5814
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5514
5815
|
var _a2;
|
|
5515
5816
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
|
5516
5817
|
})
|
|
@@ -5563,13 +5864,14 @@ var DropZoneChild = ({
|
|
|
5563
5864
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
|
5564
5865
|
const renderPreview = (0, import_react34.useMemo)(
|
|
5565
5866
|
() => function Preview3() {
|
|
5867
|
+
var _a2;
|
|
5566
5868
|
if (item && "element" in item && item.element) {
|
|
5567
5869
|
return (
|
|
5568
5870
|
// Safe to use this since the HTML is set by the user
|
|
5569
|
-
/* @__PURE__ */ (0,
|
|
5871
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
5570
5872
|
);
|
|
5571
5873
|
}
|
|
5572
|
-
return /* @__PURE__ */ (0,
|
|
5874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name: label, children: (_a2 = overrides.componentItem) != null ? _a2 : overrides.drawerItem });
|
|
5573
5875
|
},
|
|
5574
5876
|
[componentId, label, overrides]
|
|
5575
5877
|
);
|
|
@@ -5589,16 +5891,24 @@ var DropZoneChild = ({
|
|
|
5589
5891
|
[item == null ? void 0 : item.type, nodeType, defaultsProps]
|
|
5590
5892
|
);
|
|
5591
5893
|
const config = useAppStore((s) => s.config);
|
|
5592
|
-
const
|
|
5894
|
+
const plugins = useAppStore((s) => s.plugins);
|
|
5895
|
+
const userFieldTransforms = useAppStore((s) => s.fieldTransforms);
|
|
5896
|
+
const combinedFieldTransforms = (0, import_react34.useMemo)(
|
|
5897
|
+
() => __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, getSlotTransform(DropZoneEditPure, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }))), getInlineTextTransform()), plugins.reduce(
|
|
5898
|
+
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
5899
|
+
{}
|
|
5900
|
+
)), userFieldTransforms),
|
|
5901
|
+
[plugins, userFieldTransforms]
|
|
5902
|
+
);
|
|
5903
|
+
const transformedProps = useFieldTransforms(
|
|
5593
5904
|
config,
|
|
5594
5905
|
defaultedNode,
|
|
5595
|
-
|
|
5596
|
-
(slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
|
5906
|
+
combinedFieldTransforms,
|
|
5597
5907
|
nodeReadOnly,
|
|
5598
5908
|
isLoading
|
|
5599
5909
|
);
|
|
5600
5910
|
if (!item) return;
|
|
5601
|
-
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0,
|
|
5911
|
+
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
|
5602
5912
|
"No configuration for ",
|
|
5603
5913
|
item.type
|
|
5604
5914
|
] });
|
|
@@ -5607,7 +5917,7 @@ var DropZoneChild = ({
|
|
|
5607
5917
|
if (isInserting) {
|
|
5608
5918
|
Render2 = renderPreview;
|
|
5609
5919
|
}
|
|
5610
|
-
return /* @__PURE__ */ (0,
|
|
5920
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5611
5921
|
DraggableComponent,
|
|
5612
5922
|
{
|
|
5613
5923
|
id: componentId,
|
|
@@ -5621,14 +5931,14 @@ var DropZoneChild = ({
|
|
|
5621
5931
|
autoDragAxis: dragAxis,
|
|
5622
5932
|
userDragAxis: collisionAxis,
|
|
5623
5933
|
inDroppableZone,
|
|
5624
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0,
|
|
5934
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5625
5935
|
Render2,
|
|
5626
|
-
__spreadProps(__spreadValues({},
|
|
5627
|
-
puck: __spreadProps(__spreadValues({},
|
|
5936
|
+
__spreadProps(__spreadValues({}, transformedProps), {
|
|
5937
|
+
puck: __spreadProps(__spreadValues({}, transformedProps.puck), {
|
|
5628
5938
|
dragRef
|
|
5629
5939
|
})
|
|
5630
5940
|
})
|
|
5631
|
-
) }) : /* @__PURE__ */ (0,
|
|
5941
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Render2, __spreadValues({}, transformedProps)) })
|
|
5632
5942
|
}
|
|
5633
5943
|
);
|
|
5634
5944
|
};
|
|
@@ -5653,7 +5963,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
5653
5963
|
unregisterLocalZone
|
|
5654
5964
|
} = ctx != null ? ctx : {};
|
|
5655
5965
|
const path = useAppStore(
|
|
5656
|
-
(0,
|
|
5966
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5657
5967
|
var _a;
|
|
5658
5968
|
return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
|
|
5659
5969
|
})
|
|
@@ -5670,13 +5980,13 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
5670
5980
|
(s) => s.nextAreaDepthIndex[areaId || ""]
|
|
5671
5981
|
);
|
|
5672
5982
|
const zoneContentIds = useAppStore(
|
|
5673
|
-
(0,
|
|
5983
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5674
5984
|
var _a;
|
|
5675
5985
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
|
|
5676
5986
|
})
|
|
5677
5987
|
);
|
|
5678
5988
|
const zoneType = useAppStore(
|
|
5679
|
-
(0,
|
|
5989
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5680
5990
|
var _a;
|
|
5681
5991
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
5682
5992
|
})
|
|
@@ -5784,10 +6094,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
5784
6094
|
userMinEmptyHeight,
|
|
5785
6095
|
ref
|
|
5786
6096
|
});
|
|
5787
|
-
return /* @__PURE__ */ (0,
|
|
6097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5788
6098
|
"div",
|
|
5789
6099
|
{
|
|
5790
|
-
className: `${
|
|
6100
|
+
className: `${getClassName18({
|
|
5791
6101
|
isRootZone,
|
|
5792
6102
|
hoveringOverArea,
|
|
5793
6103
|
isEnabled,
|
|
@@ -5805,7 +6115,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
5805
6115
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
|
5806
6116
|
}),
|
|
5807
6117
|
children: contentIdsWithPreview.map((componentId, i) => {
|
|
5808
|
-
return /* @__PURE__ */ (0,
|
|
6118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5809
6119
|
DropZoneChildMemo,
|
|
5810
6120
|
{
|
|
5811
6121
|
zoneCompound,
|
|
@@ -5828,7 +6138,7 @@ var DropZoneRenderItem = ({
|
|
|
5828
6138
|
metadata
|
|
5829
6139
|
}) => {
|
|
5830
6140
|
const Component = config.components[item.type];
|
|
5831
|
-
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0,
|
|
6141
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5832
6142
|
const nextContextValue = (0, import_react34.useMemo)(
|
|
5833
6143
|
() => ({
|
|
5834
6144
|
areaId: props.id,
|
|
@@ -5836,7 +6146,7 @@ var DropZoneRenderItem = ({
|
|
|
5836
6146
|
}),
|
|
5837
6147
|
[props]
|
|
5838
6148
|
);
|
|
5839
|
-
return /* @__PURE__ */ (0,
|
|
6149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5840
6150
|
Component.render,
|
|
5841
6151
|
__spreadProps(__spreadValues({}, props), {
|
|
5842
6152
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
@@ -5846,7 +6156,7 @@ var DropZoneRenderItem = ({
|
|
|
5846
6156
|
})
|
|
5847
6157
|
) }, props.id);
|
|
5848
6158
|
};
|
|
5849
|
-
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0,
|
|
6159
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneRender2, __spreadValues({}, props));
|
|
5850
6160
|
var DropZoneRender2 = (0, import_react34.forwardRef)(
|
|
5851
6161
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
5852
6162
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
@@ -5867,10 +6177,10 @@ var DropZoneRender2 = (0, import_react34.forwardRef)(
|
|
|
5867
6177
|
if (zoneCompound !== rootDroppableId) {
|
|
5868
6178
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
5869
6179
|
}
|
|
5870
|
-
return /* @__PURE__ */ (0,
|
|
6180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5871
6181
|
const Component = config.components[item.type];
|
|
5872
6182
|
if (Component) {
|
|
5873
|
-
return /* @__PURE__ */ (0,
|
|
6183
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5874
6184
|
DropZoneRenderItem,
|
|
5875
6185
|
{
|
|
5876
6186
|
config,
|
|
@@ -5884,14 +6194,14 @@ var DropZoneRender2 = (0, import_react34.forwardRef)(
|
|
|
5884
6194
|
}) });
|
|
5885
6195
|
}
|
|
5886
6196
|
);
|
|
5887
|
-
var DropZonePure = (props) => /* @__PURE__ */ (0,
|
|
6197
|
+
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZone, __spreadValues({}, props));
|
|
5888
6198
|
var DropZone = (0, import_react34.forwardRef)(
|
|
5889
6199
|
function DropZone2(props, ref) {
|
|
5890
6200
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5891
6201
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
5892
|
-
return /* @__PURE__ */ (0,
|
|
6202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
5893
6203
|
}
|
|
5894
|
-
return /* @__PURE__ */ (0,
|
|
6204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneRender2, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
5895
6205
|
}
|
|
5896
6206
|
);
|
|
5897
6207
|
|
|
@@ -6227,7 +6537,7 @@ function getDeepDir(el) {
|
|
|
6227
6537
|
|
|
6228
6538
|
// components/DragDropContext/index.tsx
|
|
6229
6539
|
var import_state = require("@dnd-kit/state");
|
|
6230
|
-
var
|
|
6540
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
6231
6541
|
var DEBUG3 = false;
|
|
6232
6542
|
var dragListenerContext = (0, import_react37.createContext)({
|
|
6233
6543
|
dragListeners: {}
|
|
@@ -6396,14 +6706,14 @@ var DragDropContextClient = ({
|
|
|
6396
6706
|
}),
|
|
6397
6707
|
[]
|
|
6398
6708
|
);
|
|
6399
|
-
return /* @__PURE__ */ (0,
|
|
6709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6400
6710
|
dragListenerContext.Provider,
|
|
6401
6711
|
{
|
|
6402
6712
|
value: {
|
|
6403
6713
|
dragListeners,
|
|
6404
6714
|
setDragListeners
|
|
6405
6715
|
},
|
|
6406
|
-
children: /* @__PURE__ */ (0,
|
|
6716
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6407
6717
|
import_react36.DragDropProvider,
|
|
6408
6718
|
{
|
|
6409
6719
|
plugins,
|
|
@@ -6619,7 +6929,7 @@ var DragDropContextClient = ({
|
|
|
6619
6929
|
const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
|
|
6620
6930
|
entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
|
|
6621
6931
|
},
|
|
6622
|
-
children: /* @__PURE__ */ (0,
|
|
6932
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
|
|
6623
6933
|
}
|
|
6624
6934
|
)
|
|
6625
6935
|
}
|
|
@@ -6633,13 +6943,13 @@ var DragDropContext = ({
|
|
|
6633
6943
|
if (status === "LOADING") {
|
|
6634
6944
|
return children;
|
|
6635
6945
|
}
|
|
6636
|
-
return /* @__PURE__ */ (0,
|
|
6946
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
|
6637
6947
|
};
|
|
6638
6948
|
|
|
6639
6949
|
// components/Drawer/index.tsx
|
|
6640
6950
|
var import_react39 = require("@dnd-kit/react");
|
|
6641
|
-
var
|
|
6642
|
-
var
|
|
6951
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
6952
|
+
var getClassName19 = get_class_name_factory_default("Drawer", styles_module_default10);
|
|
6643
6953
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
|
6644
6954
|
var DrawerItemInner = ({
|
|
6645
6955
|
children,
|
|
@@ -6649,10 +6959,10 @@ var DrawerItemInner = ({
|
|
|
6649
6959
|
isDragDisabled
|
|
6650
6960
|
}) => {
|
|
6651
6961
|
const CustomInner = (0, import_react38.useMemo)(
|
|
6652
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
|
6962
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
|
6653
6963
|
[children]
|
|
6654
6964
|
);
|
|
6655
|
-
return /* @__PURE__ */ (0,
|
|
6965
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6656
6966
|
"div",
|
|
6657
6967
|
{
|
|
6658
6968
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
|
@@ -6660,9 +6970,9 @@ var DrawerItemInner = ({
|
|
|
6660
6970
|
onMouseDown: (e) => e.preventDefault(),
|
|
6661
6971
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
|
6662
6972
|
"data-puck-drawer-item": true,
|
|
6663
|
-
children: /* @__PURE__ */ (0,
|
|
6664
|
-
/* @__PURE__ */ (0,
|
|
6665
|
-
/* @__PURE__ */ (0,
|
|
6973
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassNameItem2("draggable"), children: [
|
|
6974
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
|
6975
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DragIcon, {}) })
|
|
6666
6976
|
] }) }) })
|
|
6667
6977
|
}
|
|
6668
6978
|
);
|
|
@@ -6680,9 +6990,9 @@ var DrawerItemDraggable = ({
|
|
|
6680
6990
|
disabled: isDragDisabled,
|
|
6681
6991
|
type: "drawer"
|
|
6682
6992
|
});
|
|
6683
|
-
return /* @__PURE__ */ (0,
|
|
6684
|
-
/* @__PURE__ */ (0,
|
|
6685
|
-
/* @__PURE__ */ (0,
|
|
6993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName19("draggable"), children: [
|
|
6994
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName19("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DrawerItemInner, { name, label, children }) }),
|
|
6995
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName19("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6686
6996
|
DrawerItemInner,
|
|
6687
6997
|
{
|
|
6688
6998
|
name,
|
|
@@ -6716,7 +7026,7 @@ var DrawerItem = ({
|
|
|
6716
7026
|
},
|
|
6717
7027
|
[resolvedId]
|
|
6718
7028
|
);
|
|
6719
|
-
return /* @__PURE__ */ (0,
|
|
7029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6720
7030
|
DrawerItemDraggable,
|
|
6721
7031
|
{
|
|
6722
7032
|
name,
|
|
@@ -6749,10 +7059,10 @@ var Drawer = ({
|
|
|
6749
7059
|
collisionPriority: 0
|
|
6750
7060
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
|
6751
7061
|
});
|
|
6752
|
-
return /* @__PURE__ */ (0,
|
|
7062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6753
7063
|
"div",
|
|
6754
7064
|
{
|
|
6755
|
-
className:
|
|
7065
|
+
className: getClassName19(),
|
|
6756
7066
|
ref,
|
|
6757
7067
|
"data-puck-dnd": id,
|
|
6758
7068
|
"data-puck-drawer": true,
|
|
@@ -6765,14 +7075,14 @@ Drawer.Item = DrawerItem;
|
|
|
6765
7075
|
|
|
6766
7076
|
// components/Puck/index.tsx
|
|
6767
7077
|
init_react_import();
|
|
6768
|
-
var
|
|
7078
|
+
var import_react59 = require("react");
|
|
6769
7079
|
|
|
6770
7080
|
// components/SidebarSection/index.tsx
|
|
6771
7081
|
init_react_import();
|
|
6772
7082
|
|
|
6773
7083
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
6774
7084
|
init_react_import();
|
|
6775
|
-
var
|
|
7085
|
+
var styles_module_default14 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
|
|
6776
7086
|
|
|
6777
7087
|
// lib/use-breadcrumbs.ts
|
|
6778
7088
|
init_react_import();
|
|
@@ -6819,8 +7129,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6819
7129
|
};
|
|
6820
7130
|
|
|
6821
7131
|
// components/SidebarSection/index.tsx
|
|
6822
|
-
var
|
|
6823
|
-
var
|
|
7132
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
7133
|
+
var getClassName20 = get_class_name_factory_default("SidebarSection", styles_module_default14);
|
|
6824
7134
|
var SidebarSection = ({
|
|
6825
7135
|
children,
|
|
6826
7136
|
title,
|
|
@@ -6832,29 +7142,29 @@ var SidebarSection = ({
|
|
|
6832
7142
|
}) => {
|
|
6833
7143
|
const setUi = useAppStore((s) => s.setUi);
|
|
6834
7144
|
const breadcrumbs = useBreadcrumbs(1);
|
|
6835
|
-
return /* @__PURE__ */ (0,
|
|
7145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
6836
7146
|
"div",
|
|
6837
7147
|
{
|
|
6838
|
-
className:
|
|
7148
|
+
className: getClassName20({ noBorderTop, noPadding }),
|
|
6839
7149
|
style: { background },
|
|
6840
7150
|
children: [
|
|
6841
|
-
/* @__PURE__ */ (0,
|
|
6842
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
|
6843
|
-
/* @__PURE__ */ (0,
|
|
7151
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName20("title"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName20("breadcrumbs"), children: [
|
|
7152
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName20("breadcrumb"), children: [
|
|
7153
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
6844
7154
|
"button",
|
|
6845
7155
|
{
|
|
6846
7156
|
type: "button",
|
|
6847
|
-
className:
|
|
7157
|
+
className: getClassName20("breadcrumbLabel"),
|
|
6848
7158
|
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
|
6849
7159
|
children: breadcrumb.label
|
|
6850
7160
|
}
|
|
6851
7161
|
),
|
|
6852
|
-
/* @__PURE__ */ (0,
|
|
7162
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronRight, { size: 16 })
|
|
6853
7163
|
] }, i)) : null,
|
|
6854
|
-
/* @__PURE__ */ (0,
|
|
7164
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName20("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
|
6855
7165
|
] }) }),
|
|
6856
|
-
/* @__PURE__ */ (0,
|
|
6857
|
-
isLoading && /* @__PURE__ */ (0,
|
|
7166
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName20("content"), children }),
|
|
7167
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Loader, { size: 32 }) })
|
|
6858
7168
|
]
|
|
6859
7169
|
}
|
|
6860
7170
|
);
|
|
@@ -6862,24 +7172,24 @@ var SidebarSection = ({
|
|
|
6862
7172
|
|
|
6863
7173
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
|
6864
7174
|
init_react_import();
|
|
6865
|
-
var
|
|
7175
|
+
var styles_module_default15 = { "Puck": "_Puck_1yxlw_19", "Puck-portal": "_Puck-portal_1yxlw_31", "PuckLayout-inner": "_PuckLayout-inner_1yxlw_38", "PuckLayout--mounted": "_PuckLayout--mounted_1yxlw_59", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_1yxlw_63", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_1yxlw_69", "PuckLayout-mounted": "_PuckLayout-mounted_1yxlw_83", "PuckLayout": "_PuckLayout_1yxlw_38" };
|
|
6866
7176
|
|
|
6867
7177
|
// components/Puck/components/Fields/index.tsx
|
|
6868
7178
|
init_react_import();
|
|
6869
7179
|
|
|
6870
7180
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
|
6871
7181
|
init_react_import();
|
|
6872
|
-
var
|
|
7182
|
+
var styles_module_default16 = { "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" };
|
|
6873
7183
|
|
|
6874
7184
|
// components/Puck/components/Fields/index.tsx
|
|
6875
7185
|
var import_react41 = require("react");
|
|
6876
|
-
var
|
|
6877
|
-
var
|
|
6878
|
-
var
|
|
7186
|
+
var import_shallow5 = require("zustand/react/shallow");
|
|
7187
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
7188
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
|
6879
7189
|
var DefaultFields = ({
|
|
6880
7190
|
children
|
|
6881
7191
|
}) => {
|
|
6882
|
-
return /* @__PURE__ */ (0,
|
|
7192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
|
6883
7193
|
};
|
|
6884
7194
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
|
6885
7195
|
let currentProps;
|
|
@@ -6939,7 +7249,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6939
7249
|
return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
|
|
6940
7250
|
});
|
|
6941
7251
|
const permissions = useAppStore(
|
|
6942
|
-
(0,
|
|
7252
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
6943
7253
|
const { selectedItem, permissions: permissions2 } = s;
|
|
6944
7254
|
return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
|
|
6945
7255
|
})
|
|
@@ -6951,7 +7261,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6951
7261
|
const { visible = true } = field != null ? field : {};
|
|
6952
7262
|
if (!field || !id || !visible) return null;
|
|
6953
7263
|
if (field.type === "slot") return null;
|
|
6954
|
-
return /* @__PURE__ */ (0,
|
|
7264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6955
7265
|
AutoFieldPrivate,
|
|
6956
7266
|
{
|
|
6957
7267
|
field,
|
|
@@ -6971,7 +7281,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6971
7281
|
const loadingCount = s.selectedItem ? (_a = s.componentState[s.selectedItem.props.id]) == null ? void 0 : _a.loadingCount : (_b = s.componentState["root"]) == null ? void 0 : _b.loadingCount;
|
|
6972
7282
|
return (loadingCount != null ? loadingCount : 0) > 0;
|
|
6973
7283
|
});
|
|
6974
|
-
const itemSelector = useAppStore((0,
|
|
7284
|
+
const itemSelector = useAppStore((0, import_shallow5.useShallow)((s) => s.state.ui.itemSelector));
|
|
6975
7285
|
const id = useAppStore((s) => {
|
|
6976
7286
|
var _a;
|
|
6977
7287
|
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
@@ -6980,7 +7290,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6980
7290
|
useRegisterFieldsSlice(appStore, id);
|
|
6981
7291
|
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
|
6982
7292
|
const fieldNames = useAppStore(
|
|
6983
|
-
(0,
|
|
7293
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
6984
7294
|
if (s.fields.id === id) {
|
|
6985
7295
|
return Object.keys(s.fields.fields);
|
|
6986
7296
|
}
|
|
@@ -6989,16 +7299,16 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6989
7299
|
);
|
|
6990
7300
|
const isLoading = fieldsLoading || componentResolving;
|
|
6991
7301
|
const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
6992
|
-
return /* @__PURE__ */ (0,
|
|
7302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
6993
7303
|
"form",
|
|
6994
7304
|
{
|
|
6995
|
-
className:
|
|
7305
|
+
className: getClassName21({ wrapFields }),
|
|
6996
7306
|
onSubmit: (e) => {
|
|
6997
7307
|
e.preventDefault();
|
|
6998
7308
|
},
|
|
6999
7309
|
children: [
|
|
7000
|
-
/* @__PURE__ */ (0,
|
|
7001
|
-
isLoading && /* @__PURE__ */ (0,
|
|
7310
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
|
|
7311
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Loader, { size: 16 }) }) })
|
|
7002
7312
|
]
|
|
7003
7313
|
}
|
|
7004
7314
|
);
|
|
@@ -7010,29 +7320,38 @@ init_react_import();
|
|
|
7010
7320
|
|
|
7011
7321
|
// lib/use-component-list.tsx
|
|
7012
7322
|
init_react_import();
|
|
7013
|
-
var
|
|
7323
|
+
var import_react43 = require("react");
|
|
7014
7324
|
|
|
7015
7325
|
// components/ComponentList/index.tsx
|
|
7016
7326
|
init_react_import();
|
|
7017
7327
|
|
|
7018
7328
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
|
7019
7329
|
init_react_import();
|
|
7020
|
-
var
|
|
7330
|
+
var styles_module_default17 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
|
|
7021
7331
|
|
|
7022
7332
|
// components/ComponentList/index.tsx
|
|
7023
|
-
var
|
|
7024
|
-
var
|
|
7333
|
+
var import_react42 = require("react");
|
|
7334
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
7335
|
+
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
|
7025
7336
|
var ComponentListItem = ({
|
|
7026
7337
|
name,
|
|
7027
7338
|
label
|
|
7028
7339
|
}) => {
|
|
7340
|
+
var _a;
|
|
7029
7341
|
const overrides = useAppStore((s) => s.overrides);
|
|
7030
7342
|
const canInsert = useAppStore(
|
|
7031
7343
|
(s) => s.permissions.getPermissions({
|
|
7032
7344
|
type: name
|
|
7033
7345
|
}).insert
|
|
7034
7346
|
);
|
|
7035
|
-
|
|
7347
|
+
(0, import_react42.useEffect)(() => {
|
|
7348
|
+
if (overrides.componentItem) {
|
|
7349
|
+
console.warn(
|
|
7350
|
+
"The `componentItem` override has been deprecated and renamed to `drawerItem`"
|
|
7351
|
+
);
|
|
7352
|
+
}
|
|
7353
|
+
}, [overrides]);
|
|
7354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
|
|
7036
7355
|
};
|
|
7037
7356
|
var ComponentList = ({
|
|
7038
7357
|
children,
|
|
@@ -7043,12 +7362,12 @@ var ComponentList = ({
|
|
|
7043
7362
|
const setUi = useAppStore((s) => s.setUi);
|
|
7044
7363
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
|
7045
7364
|
const { expanded = true } = componentList[id] || {};
|
|
7046
|
-
return /* @__PURE__ */ (0,
|
|
7047
|
-
title && /* @__PURE__ */ (0,
|
|
7365
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
|
7366
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
7048
7367
|
"button",
|
|
7049
7368
|
{
|
|
7050
7369
|
type: "button",
|
|
7051
|
-
className:
|
|
7370
|
+
className: getClassName22("title"),
|
|
7052
7371
|
onClick: () => setUi({
|
|
7053
7372
|
componentList: __spreadProps(__spreadValues({}, componentList), {
|
|
7054
7373
|
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
|
@@ -7058,14 +7377,14 @@ var ComponentList = ({
|
|
|
7058
7377
|
}),
|
|
7059
7378
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
|
7060
7379
|
children: [
|
|
7061
|
-
/* @__PURE__ */ (0,
|
|
7062
|
-
/* @__PURE__ */ (0,
|
|
7380
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { children: title }),
|
|
7381
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ChevronDown, { size: 12 }) })
|
|
7063
7382
|
]
|
|
7064
7383
|
}
|
|
7065
7384
|
),
|
|
7066
|
-
/* @__PURE__ */ (0,
|
|
7385
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
|
7067
7386
|
var _a;
|
|
7068
|
-
return /* @__PURE__ */ (0,
|
|
7387
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
7069
7388
|
ComponentListItem,
|
|
7070
7389
|
{
|
|
7071
7390
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
|
@@ -7079,12 +7398,12 @@ var ComponentList = ({
|
|
|
7079
7398
|
ComponentList.Item = ComponentListItem;
|
|
7080
7399
|
|
|
7081
7400
|
// lib/use-component-list.tsx
|
|
7082
|
-
var
|
|
7401
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
7083
7402
|
var useComponentList = () => {
|
|
7084
|
-
const [componentList, setComponentList] = (0,
|
|
7403
|
+
const [componentList, setComponentList] = (0, import_react43.useState)();
|
|
7085
7404
|
const config = useAppStore((s) => s.config);
|
|
7086
7405
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
|
7087
|
-
(0,
|
|
7406
|
+
(0, import_react43.useEffect)(() => {
|
|
7088
7407
|
var _a, _b, _c;
|
|
7089
7408
|
if (Object.keys(uiComponentList).length > 0) {
|
|
7090
7409
|
const matchedComponents = [];
|
|
@@ -7094,7 +7413,7 @@ var useComponentList = () => {
|
|
|
7094
7413
|
if (category.visible === false || !category.components) {
|
|
7095
7414
|
return null;
|
|
7096
7415
|
}
|
|
7097
|
-
return /* @__PURE__ */ (0,
|
|
7416
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7098
7417
|
ComponentList,
|
|
7099
7418
|
{
|
|
7100
7419
|
id: categoryKey,
|
|
@@ -7103,7 +7422,7 @@ var useComponentList = () => {
|
|
|
7103
7422
|
var _a2;
|
|
7104
7423
|
matchedComponents.push(componentName);
|
|
7105
7424
|
const componentConf = config.components[componentName] || {};
|
|
7106
|
-
return /* @__PURE__ */ (0,
|
|
7425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7107
7426
|
ComponentList.Item,
|
|
7108
7427
|
{
|
|
7109
7428
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
|
@@ -7123,7 +7442,7 @@ var useComponentList = () => {
|
|
|
7123
7442
|
);
|
|
7124
7443
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
|
7125
7444
|
_componentList.push(
|
|
7126
|
-
/* @__PURE__ */ (0,
|
|
7445
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7127
7446
|
ComponentList,
|
|
7128
7447
|
{
|
|
7129
7448
|
id: "other",
|
|
@@ -7131,7 +7450,7 @@ var useComponentList = () => {
|
|
|
7131
7450
|
children: remainingComponents.map((componentName, i) => {
|
|
7132
7451
|
var _a2;
|
|
7133
7452
|
const componentConf = config.components[componentName] || {};
|
|
7134
|
-
return /* @__PURE__ */ (0,
|
|
7453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7135
7454
|
ComponentList.Item,
|
|
7136
7455
|
{
|
|
7137
7456
|
name: componentName,
|
|
@@ -7153,25 +7472,32 @@ var useComponentList = () => {
|
|
|
7153
7472
|
};
|
|
7154
7473
|
|
|
7155
7474
|
// components/Puck/components/Components/index.tsx
|
|
7156
|
-
var
|
|
7157
|
-
var
|
|
7475
|
+
var import_react44 = require("react");
|
|
7476
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
7158
7477
|
var Components = () => {
|
|
7159
7478
|
const overrides = useAppStore((s) => s.overrides);
|
|
7160
7479
|
const componentList = useComponentList();
|
|
7161
|
-
const Wrapper = (0,
|
|
7162
|
-
|
|
7480
|
+
const Wrapper = (0, import_react44.useMemo)(() => {
|
|
7481
|
+
if (overrides.components) {
|
|
7482
|
+
console.warn(
|
|
7483
|
+
"The `components` override has been deprecated and renamed to `drawer`"
|
|
7484
|
+
);
|
|
7485
|
+
}
|
|
7486
|
+
return overrides.components || overrides.drawer || "div";
|
|
7487
|
+
}, [overrides]);
|
|
7488
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComponentList, { id: "all" }) });
|
|
7163
7489
|
};
|
|
7164
7490
|
|
|
7165
7491
|
// components/Puck/components/Preview/index.tsx
|
|
7166
7492
|
init_react_import();
|
|
7167
|
-
var
|
|
7493
|
+
var import_react46 = require("react");
|
|
7168
7494
|
|
|
7169
7495
|
// components/AutoFrame/index.tsx
|
|
7170
7496
|
init_react_import();
|
|
7171
|
-
var
|
|
7497
|
+
var import_react45 = require("react");
|
|
7172
7498
|
var import_object_hash = __toESM(require("object-hash"));
|
|
7173
7499
|
var import_react_dom3 = require("react-dom");
|
|
7174
|
-
var
|
|
7500
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
7175
7501
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
|
7176
7502
|
var collectStyles = (doc) => {
|
|
7177
7503
|
const collected = [];
|
|
@@ -7221,7 +7547,7 @@ var CopyHostStyles = ({
|
|
|
7221
7547
|
onStylesLoaded = () => null
|
|
7222
7548
|
}) => {
|
|
7223
7549
|
const { document: doc, window: win } = useFrame();
|
|
7224
|
-
(0,
|
|
7550
|
+
(0, import_react45.useEffect)(() => {
|
|
7225
7551
|
if (!win || !doc) {
|
|
7226
7552
|
return () => {
|
|
7227
7553
|
};
|
|
@@ -7378,10 +7704,10 @@ var CopyHostStyles = ({
|
|
|
7378
7704
|
observer.disconnect();
|
|
7379
7705
|
};
|
|
7380
7706
|
}, []);
|
|
7381
|
-
return /* @__PURE__ */ (0,
|
|
7707
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children });
|
|
7382
7708
|
};
|
|
7383
|
-
var autoFrameContext = (0,
|
|
7384
|
-
var useFrame = () => (0,
|
|
7709
|
+
var autoFrameContext = (0, import_react45.createContext)({});
|
|
7710
|
+
var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
|
|
7385
7711
|
function AutoFrame(_a) {
|
|
7386
7712
|
var _b = _a, {
|
|
7387
7713
|
children,
|
|
@@ -7402,11 +7728,11 @@ function AutoFrame(_a) {
|
|
|
7402
7728
|
"onNotReady",
|
|
7403
7729
|
"frameRef"
|
|
7404
7730
|
]);
|
|
7405
|
-
const [loaded, setLoaded] = (0,
|
|
7406
|
-
const [ctx, setCtx] = (0,
|
|
7407
|
-
const [mountTarget, setMountTarget] = (0,
|
|
7408
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
|
7409
|
-
(0,
|
|
7731
|
+
const [loaded, setLoaded] = (0, import_react45.useState)(false);
|
|
7732
|
+
const [ctx, setCtx] = (0, import_react45.useState)({});
|
|
7733
|
+
const [mountTarget, setMountTarget] = (0, import_react45.useState)();
|
|
7734
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react45.useState)(false);
|
|
7735
|
+
(0, import_react45.useEffect)(() => {
|
|
7410
7736
|
var _a2;
|
|
7411
7737
|
if (frameRef.current) {
|
|
7412
7738
|
const doc = frameRef.current.contentDocument;
|
|
@@ -7425,7 +7751,7 @@ function AutoFrame(_a) {
|
|
|
7425
7751
|
}
|
|
7426
7752
|
}
|
|
7427
7753
|
}, [frameRef, loaded, stylesLoaded]);
|
|
7428
|
-
return /* @__PURE__ */ (0,
|
|
7754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7429
7755
|
"iframe",
|
|
7430
7756
|
__spreadProps(__spreadValues({}, props), {
|
|
7431
7757
|
className,
|
|
@@ -7435,7 +7761,7 @@ function AutoFrame(_a) {
|
|
|
7435
7761
|
onLoad: () => {
|
|
7436
7762
|
setLoaded(true);
|
|
7437
7763
|
},
|
|
7438
|
-
children: /* @__PURE__ */ (0,
|
|
7764
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7439
7765
|
CopyHostStyles,
|
|
7440
7766
|
{
|
|
7441
7767
|
debug,
|
|
@@ -7451,14 +7777,14 @@ var AutoFrame_default = AutoFrame;
|
|
|
7451
7777
|
|
|
7452
7778
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
|
7453
7779
|
init_react_import();
|
|
7454
|
-
var
|
|
7780
|
+
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
|
7455
7781
|
|
|
7456
7782
|
// components/Puck/components/Preview/index.tsx
|
|
7457
|
-
var
|
|
7458
|
-
var
|
|
7783
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7784
|
+
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
|
7459
7785
|
var useBubbleIframeEvents = (ref) => {
|
|
7460
7786
|
const status = useAppStore((s) => s.status);
|
|
7461
|
-
(0,
|
|
7787
|
+
(0, import_react46.useEffect)(() => {
|
|
7462
7788
|
if (ref.current && status === "READY") {
|
|
7463
7789
|
const iframe = ref.current;
|
|
7464
7790
|
const handlePointerMove = (event) => {
|
|
@@ -7507,7 +7833,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7507
7833
|
const renderData = useAppStore(
|
|
7508
7834
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
7509
7835
|
);
|
|
7510
|
-
const Page = (0,
|
|
7836
|
+
const Page = (0, import_react46.useCallback)(
|
|
7511
7837
|
(pageProps) => {
|
|
7512
7838
|
var _a, _b;
|
|
7513
7839
|
const propsWithSlots = useSlots(
|
|
@@ -7517,15 +7843,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7517
7843
|
);
|
|
7518
7844
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
7519
7845
|
id: "puck-root"
|
|
7520
|
-
}, propsWithSlots)) : /* @__PURE__ */ (0,
|
|
7846
|
+
}, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children: propsWithSlots.children });
|
|
7521
7847
|
},
|
|
7522
7848
|
[config]
|
|
7523
7849
|
);
|
|
7524
|
-
const Frame = (0,
|
|
7850
|
+
const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
|
|
7525
7851
|
const rootProps = root.props || root;
|
|
7526
|
-
const ref = (0,
|
|
7852
|
+
const ref = (0, import_react46.useRef)(null);
|
|
7527
7853
|
useBubbleIframeEvents(ref);
|
|
7528
|
-
const inner = !renderData ? /* @__PURE__ */ (0,
|
|
7854
|
+
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7529
7855
|
Page,
|
|
7530
7856
|
__spreadProps(__spreadValues({}, rootProps), {
|
|
7531
7857
|
puck: {
|
|
@@ -7535,28 +7861,31 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7535
7861
|
metadata
|
|
7536
7862
|
},
|
|
7537
7863
|
editMode: true,
|
|
7538
|
-
children: /* @__PURE__ */ (0,
|
|
7864
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7539
7865
|
})
|
|
7540
|
-
) : /* @__PURE__ */ (0,
|
|
7541
|
-
(0,
|
|
7866
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Render, { data: renderData, config, metadata });
|
|
7867
|
+
(0, import_react46.useEffect)(() => {
|
|
7542
7868
|
if (!iframe.enabled) {
|
|
7543
7869
|
setStatus("READY");
|
|
7544
7870
|
}
|
|
7545
7871
|
}, [iframe.enabled]);
|
|
7546
|
-
return /* @__PURE__ */ (0,
|
|
7872
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7547
7873
|
"div",
|
|
7548
7874
|
{
|
|
7549
|
-
className:
|
|
7875
|
+
className: getClassName23(),
|
|
7550
7876
|
id,
|
|
7551
7877
|
"data-puck-preview": true,
|
|
7552
|
-
onClick: () => {
|
|
7553
|
-
|
|
7878
|
+
onClick: (e) => {
|
|
7879
|
+
const el = e.target;
|
|
7880
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
7881
|
+
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
|
7882
|
+
}
|
|
7554
7883
|
},
|
|
7555
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
|
7884
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7556
7885
|
AutoFrame_default,
|
|
7557
7886
|
{
|
|
7558
7887
|
id: "preview-frame",
|
|
7559
|
-
className:
|
|
7888
|
+
className: getClassName23("frame"),
|
|
7560
7889
|
"data-rfd-iframe": true,
|
|
7561
7890
|
onReady: () => {
|
|
7562
7891
|
setStatus("READY");
|
|
@@ -7565,18 +7894,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7565
7894
|
setStatus("MOUNTED");
|
|
7566
7895
|
},
|
|
7567
7896
|
frameRef: ref,
|
|
7568
|
-
children: /* @__PURE__ */ (0,
|
|
7897
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
|
7569
7898
|
if (Frame) {
|
|
7570
|
-
return /* @__PURE__ */ (0,
|
|
7899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Frame, { document: document2, children: inner });
|
|
7571
7900
|
}
|
|
7572
7901
|
return inner;
|
|
7573
7902
|
} })
|
|
7574
7903
|
}
|
|
7575
|
-
) : /* @__PURE__ */ (0,
|
|
7904
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7576
7905
|
"div",
|
|
7577
7906
|
{
|
|
7578
7907
|
id: "preview-frame",
|
|
7579
|
-
className:
|
|
7908
|
+
className: getClassName23("frame"),
|
|
7580
7909
|
ref,
|
|
7581
7910
|
"data-puck-entry": true,
|
|
7582
7911
|
children: inner
|
|
@@ -7594,7 +7923,7 @@ init_react_import();
|
|
|
7594
7923
|
|
|
7595
7924
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
|
7596
7925
|
init_react_import();
|
|
7597
|
-
var
|
|
7926
|
+
var styles_module_default19 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
|
|
7598
7927
|
|
|
7599
7928
|
// lib/scroll-into-view.ts
|
|
7600
7929
|
init_react_import();
|
|
@@ -7608,7 +7937,7 @@ var scrollIntoView = (el) => {
|
|
|
7608
7937
|
};
|
|
7609
7938
|
|
|
7610
7939
|
// components/LayerTree/index.tsx
|
|
7611
|
-
var
|
|
7940
|
+
var import_react47 = require("react");
|
|
7612
7941
|
|
|
7613
7942
|
// lib/on-scroll-end.ts
|
|
7614
7943
|
init_react_import();
|
|
@@ -7630,10 +7959,10 @@ var onScrollEnd = (frame, cb) => {
|
|
|
7630
7959
|
};
|
|
7631
7960
|
|
|
7632
7961
|
// components/LayerTree/index.tsx
|
|
7633
|
-
var
|
|
7634
|
-
var
|
|
7635
|
-
var
|
|
7636
|
-
var getClassNameLayer = get_class_name_factory_default("Layer",
|
|
7962
|
+
var import_shallow6 = require("zustand/react/shallow");
|
|
7963
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
7964
|
+
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
|
7965
|
+
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
|
7637
7966
|
var Layer = ({
|
|
7638
7967
|
index,
|
|
7639
7968
|
itemId,
|
|
@@ -7643,7 +7972,7 @@ var Layer = ({
|
|
|
7643
7972
|
const config = useAppStore((s) => s.config);
|
|
7644
7973
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
7645
7974
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
7646
|
-
const setItemSelector = (0,
|
|
7975
|
+
const setItemSelector = (0, import_react47.useCallback)(
|
|
7647
7976
|
(itemSelector2) => {
|
|
7648
7977
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
7649
7978
|
},
|
|
@@ -7656,14 +7985,14 @@ var Layer = ({
|
|
|
7656
7985
|
const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
|
|
7657
7986
|
const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
|
|
7658
7987
|
const zonesForItem = useAppStore(
|
|
7659
|
-
(0,
|
|
7988
|
+
(0, import_shallow6.useShallow)(
|
|
7660
7989
|
(s) => Object.keys(s.state.indexes.zones).filter(
|
|
7661
7990
|
(z) => z.split(":")[0] === itemId
|
|
7662
7991
|
)
|
|
7663
7992
|
)
|
|
7664
7993
|
);
|
|
7665
7994
|
const containsZone = zonesForItem.length > 0;
|
|
7666
|
-
const zoneStore = (0,
|
|
7995
|
+
const zoneStore = (0, import_react47.useContext)(ZoneStoreContext);
|
|
7667
7996
|
const isHovering = useContextStore(
|
|
7668
7997
|
ZoneStoreContext,
|
|
7669
7998
|
(s) => s.hoveringComponent === itemId
|
|
@@ -7678,7 +8007,7 @@ var Layer = ({
|
|
|
7678
8007
|
});
|
|
7679
8008
|
const componentConfig = config.components[nodeData.data.type];
|
|
7680
8009
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
|
7681
|
-
return /* @__PURE__ */ (0,
|
|
8010
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
7682
8011
|
"li",
|
|
7683
8012
|
{
|
|
7684
8013
|
className: getClassNameLayer({
|
|
@@ -7688,7 +8017,7 @@ var Layer = ({
|
|
|
7688
8017
|
childIsSelected
|
|
7689
8018
|
}),
|
|
7690
8019
|
children: [
|
|
7691
|
-
/* @__PURE__ */ (0,
|
|
8020
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
7692
8021
|
"button",
|
|
7693
8022
|
{
|
|
7694
8023
|
type: "button",
|
|
@@ -7726,22 +8055,22 @@ var Layer = ({
|
|
|
7726
8055
|
zoneStore.setState({ hoveringComponent: null });
|
|
7727
8056
|
},
|
|
7728
8057
|
children: [
|
|
7729
|
-
containsZone && /* @__PURE__ */ (0,
|
|
8058
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
7730
8059
|
"div",
|
|
7731
8060
|
{
|
|
7732
8061
|
className: getClassNameLayer("chevron"),
|
|
7733
8062
|
title: isSelected ? "Collapse" : "Expand",
|
|
7734
|
-
children: /* @__PURE__ */ (0,
|
|
8063
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ChevronDown, { size: "12" })
|
|
7735
8064
|
}
|
|
7736
8065
|
),
|
|
7737
|
-
/* @__PURE__ */ (0,
|
|
7738
|
-
/* @__PURE__ */ (0,
|
|
7739
|
-
/* @__PURE__ */ (0,
|
|
8066
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
|
8067
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(LayoutGrid, { size: "16" }) }),
|
|
8068
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassNameLayer("name"), children: label })
|
|
7740
8069
|
] })
|
|
7741
8070
|
]
|
|
7742
8071
|
}
|
|
7743
8072
|
) }),
|
|
7744
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0,
|
|
8073
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
|
|
7745
8074
|
]
|
|
7746
8075
|
}
|
|
7747
8076
|
);
|
|
@@ -7760,22 +8089,22 @@ var LayerTree = ({
|
|
|
7760
8089
|
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7761
8090
|
});
|
|
7762
8091
|
const contentIds = useAppStore(
|
|
7763
|
-
(0,
|
|
8092
|
+
(0, import_shallow6.useShallow)(
|
|
7764
8093
|
(s) => {
|
|
7765
8094
|
var _a, _b;
|
|
7766
8095
|
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
7767
8096
|
}
|
|
7768
8097
|
)
|
|
7769
8098
|
);
|
|
7770
|
-
return /* @__PURE__ */ (0,
|
|
7771
|
-
label && /* @__PURE__ */ (0,
|
|
7772
|
-
/* @__PURE__ */ (0,
|
|
8099
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
|
|
8100
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
|
8101
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Layers, { size: "16" }) }),
|
|
7773
8102
|
label
|
|
7774
8103
|
] }),
|
|
7775
|
-
/* @__PURE__ */ (0,
|
|
7776
|
-
contentIds.length === 0 && /* @__PURE__ */ (0,
|
|
8104
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("ul", { className: getClassName24(), children: [
|
|
8105
|
+
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
|
7777
8106
|
contentIds.map((itemId, i) => {
|
|
7778
|
-
return /* @__PURE__ */ (0,
|
|
8107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
7779
8108
|
Layer,
|
|
7780
8109
|
{
|
|
7781
8110
|
index: i,
|
|
@@ -7790,7 +8119,7 @@ var LayerTree = ({
|
|
|
7790
8119
|
};
|
|
7791
8120
|
|
|
7792
8121
|
// components/Puck/components/Outline/index.tsx
|
|
7793
|
-
var
|
|
8122
|
+
var import_react48 = require("react");
|
|
7794
8123
|
|
|
7795
8124
|
// lib/data/find-zones-for-area.ts
|
|
7796
8125
|
init_react_import();
|
|
@@ -7801,15 +8130,15 @@ var findZonesForArea = (state, area) => {
|
|
|
7801
8130
|
};
|
|
7802
8131
|
|
|
7803
8132
|
// components/Puck/components/Outline/index.tsx
|
|
7804
|
-
var
|
|
7805
|
-
var
|
|
8133
|
+
var import_shallow7 = require("zustand/react/shallow");
|
|
8134
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
7806
8135
|
var Outline = () => {
|
|
7807
8136
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
7808
8137
|
const rootZones = useAppStore(
|
|
7809
|
-
(0,
|
|
8138
|
+
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7810
8139
|
);
|
|
7811
|
-
const Wrapper = (0,
|
|
7812
|
-
return /* @__PURE__ */ (0,
|
|
8140
|
+
const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
8141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
7813
8142
|
LayerTree,
|
|
7814
8143
|
{
|
|
7815
8144
|
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
@@ -7821,25 +8150,25 @@ var Outline = () => {
|
|
|
7821
8150
|
|
|
7822
8151
|
// components/Puck/components/Canvas/index.tsx
|
|
7823
8152
|
init_react_import();
|
|
7824
|
-
var
|
|
8153
|
+
var import_react51 = require("react");
|
|
7825
8154
|
|
|
7826
8155
|
// components/ViewportControls/index.tsx
|
|
7827
8156
|
init_react_import();
|
|
7828
|
-
var
|
|
8157
|
+
var import_react49 = require("react");
|
|
7829
8158
|
|
|
7830
8159
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
7831
8160
|
init_react_import();
|
|
7832
|
-
var
|
|
8161
|
+
var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
|
|
7833
8162
|
|
|
7834
8163
|
// components/ViewportControls/index.tsx
|
|
7835
|
-
var
|
|
8164
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
7836
8165
|
var icons = {
|
|
7837
|
-
Smartphone: /* @__PURE__ */ (0,
|
|
7838
|
-
Tablet: /* @__PURE__ */ (0,
|
|
7839
|
-
Monitor: /* @__PURE__ */ (0,
|
|
8166
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Smartphone, { size: 16 }),
|
|
8167
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Tablet, { size: 16 }),
|
|
8168
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Monitor, { size: 16 })
|
|
7840
8169
|
};
|
|
7841
|
-
var
|
|
7842
|
-
var getClassNameButton = get_class_name_factory_default("ViewportButton",
|
|
8170
|
+
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
|
8171
|
+
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
|
7843
8172
|
var ViewportButton = ({
|
|
7844
8173
|
children,
|
|
7845
8174
|
height = "auto",
|
|
@@ -7848,11 +8177,11 @@ var ViewportButton = ({
|
|
|
7848
8177
|
onClick
|
|
7849
8178
|
}) => {
|
|
7850
8179
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
|
7851
|
-
const [isActive, setIsActive] = (0,
|
|
7852
|
-
(0,
|
|
8180
|
+
const [isActive, setIsActive] = (0, import_react49.useState)(false);
|
|
8181
|
+
(0, import_react49.useEffect)(() => {
|
|
7853
8182
|
setIsActive(width === viewports.current.width);
|
|
7854
8183
|
}, [width, viewports.current.width]);
|
|
7855
|
-
return /* @__PURE__ */ (0,
|
|
8184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7856
8185
|
IconButton,
|
|
7857
8186
|
{
|
|
7858
8187
|
type: "button",
|
|
@@ -7862,7 +8191,7 @@ var ViewportButton = ({
|
|
|
7862
8191
|
e.stopPropagation();
|
|
7863
8192
|
onClick({ width, height });
|
|
7864
8193
|
},
|
|
7865
|
-
children: /* @__PURE__ */ (0,
|
|
8194
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: getClassNameButton("inner"), children })
|
|
7866
8195
|
}
|
|
7867
8196
|
) });
|
|
7868
8197
|
};
|
|
@@ -7886,7 +8215,7 @@ var ViewportControls = ({
|
|
|
7886
8215
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
7887
8216
|
(option) => option.value === autoZoom
|
|
7888
8217
|
);
|
|
7889
|
-
const zoomOptions = (0,
|
|
8218
|
+
const zoomOptions = (0, import_react49.useMemo)(
|
|
7890
8219
|
() => [
|
|
7891
8220
|
...defaultZoomOptions,
|
|
7892
8221
|
...defaultsContainAutoZoom ? [] : [
|
|
@@ -7898,8 +8227,8 @@ var ViewportControls = ({
|
|
|
7898
8227
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
|
7899
8228
|
[autoZoom]
|
|
7900
8229
|
);
|
|
7901
|
-
return /* @__PURE__ */ (0,
|
|
7902
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
|
8230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName25(), children: [
|
|
8231
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7903
8232
|
ViewportButton,
|
|
7904
8233
|
{
|
|
7905
8234
|
height: viewport.height,
|
|
@@ -7910,8 +8239,8 @@ var ViewportControls = ({
|
|
|
7910
8239
|
},
|
|
7911
8240
|
i
|
|
7912
8241
|
)),
|
|
7913
|
-
/* @__PURE__ */ (0,
|
|
7914
|
-
/* @__PURE__ */ (0,
|
|
8242
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("divider") }),
|
|
8243
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7915
8244
|
IconButton,
|
|
7916
8245
|
{
|
|
7917
8246
|
type: "button",
|
|
@@ -7926,10 +8255,10 @@ var ViewportControls = ({
|
|
|
7926
8255
|
)].value
|
|
7927
8256
|
);
|
|
7928
8257
|
},
|
|
7929
|
-
children: /* @__PURE__ */ (0,
|
|
8258
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ZoomOut, { size: 16 })
|
|
7930
8259
|
}
|
|
7931
8260
|
),
|
|
7932
|
-
/* @__PURE__ */ (0,
|
|
8261
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7933
8262
|
IconButton,
|
|
7934
8263
|
{
|
|
7935
8264
|
type: "button",
|
|
@@ -7944,19 +8273,19 @@ var ViewportControls = ({
|
|
|
7944
8273
|
)].value
|
|
7945
8274
|
);
|
|
7946
8275
|
},
|
|
7947
|
-
children: /* @__PURE__ */ (0,
|
|
8276
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ZoomIn, { size: 16 })
|
|
7948
8277
|
}
|
|
7949
8278
|
),
|
|
7950
|
-
/* @__PURE__ */ (0,
|
|
7951
|
-
/* @__PURE__ */ (0,
|
|
8279
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("divider") }),
|
|
8280
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7952
8281
|
"select",
|
|
7953
8282
|
{
|
|
7954
|
-
className:
|
|
8283
|
+
className: getClassName25("zoomSelect"),
|
|
7955
8284
|
value: zoom.toString(),
|
|
7956
8285
|
onChange: (e) => {
|
|
7957
8286
|
onZoom(parseFloat(e.currentTarget.value));
|
|
7958
8287
|
},
|
|
7959
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
|
8288
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7960
8289
|
"option",
|
|
7961
8290
|
{
|
|
7962
8291
|
value: option.value,
|
|
@@ -7971,30 +8300,30 @@ var ViewportControls = ({
|
|
|
7971
8300
|
|
|
7972
8301
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
7973
8302
|
init_react_import();
|
|
7974
|
-
var
|
|
8303
|
+
var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
|
|
7975
8304
|
|
|
7976
8305
|
// components/Puck/components/Canvas/index.tsx
|
|
7977
|
-
var
|
|
8306
|
+
var import_shallow8 = require("zustand/react/shallow");
|
|
7978
8307
|
|
|
7979
8308
|
// lib/frame-context.tsx
|
|
7980
8309
|
init_react_import();
|
|
7981
|
-
var
|
|
7982
|
-
var
|
|
7983
|
-
var FrameContext = (0,
|
|
8310
|
+
var import_react50 = require("react");
|
|
8311
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
8312
|
+
var FrameContext = (0, import_react50.createContext)(null);
|
|
7984
8313
|
var FrameProvider = ({
|
|
7985
8314
|
children
|
|
7986
8315
|
}) => {
|
|
7987
|
-
const frameRef = (0,
|
|
7988
|
-
const value = (0,
|
|
8316
|
+
const frameRef = (0, import_react50.useRef)(null);
|
|
8317
|
+
const value = (0, import_react50.useMemo)(
|
|
7989
8318
|
() => ({
|
|
7990
8319
|
frameRef
|
|
7991
8320
|
}),
|
|
7992
8321
|
[]
|
|
7993
8322
|
);
|
|
7994
|
-
return /* @__PURE__ */ (0,
|
|
8323
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(FrameContext.Provider, { value, children });
|
|
7995
8324
|
};
|
|
7996
8325
|
var useCanvasFrame = () => {
|
|
7997
|
-
const context = (0,
|
|
8326
|
+
const context = (0, import_react50.useContext)(FrameContext);
|
|
7998
8327
|
if (context === null) {
|
|
7999
8328
|
throw new Error("useCanvasFrame must be used within a FrameProvider");
|
|
8000
8329
|
}
|
|
@@ -8002,9 +8331,10 @@ var useCanvasFrame = () => {
|
|
|
8002
8331
|
};
|
|
8003
8332
|
|
|
8004
8333
|
// components/Puck/components/Canvas/index.tsx
|
|
8005
|
-
var
|
|
8006
|
-
var
|
|
8334
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
8335
|
+
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
|
8007
8336
|
var ZOOM_ON_CHANGE = true;
|
|
8337
|
+
var TRANSITION_DURATION = 150;
|
|
8008
8338
|
var Canvas = () => {
|
|
8009
8339
|
const { frameRef } = useCanvasFrame();
|
|
8010
8340
|
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
@@ -8017,7 +8347,7 @@ var Canvas = () => {
|
|
|
8017
8347
|
status,
|
|
8018
8348
|
iframe
|
|
8019
8349
|
} = useAppStore(
|
|
8020
|
-
(0,
|
|
8350
|
+
(0, import_shallow8.useShallow)((s) => ({
|
|
8021
8351
|
dispatch: s.dispatch,
|
|
8022
8352
|
overrides: s.overrides,
|
|
8023
8353
|
setUi: s.setUi,
|
|
@@ -8034,7 +8364,7 @@ var Canvas = () => {
|
|
|
8034
8364
|
rightSideBarWidth,
|
|
8035
8365
|
viewports
|
|
8036
8366
|
} = useAppStore(
|
|
8037
|
-
(0,
|
|
8367
|
+
(0, import_shallow8.useShallow)((s) => ({
|
|
8038
8368
|
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
8039
8369
|
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
8040
8370
|
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
@@ -8042,17 +8372,17 @@ var Canvas = () => {
|
|
|
8042
8372
|
viewports: s.state.ui.viewports
|
|
8043
8373
|
}))
|
|
8044
8374
|
);
|
|
8045
|
-
const [showTransition, setShowTransition] = (0,
|
|
8046
|
-
const
|
|
8047
|
-
const defaultRender = (0,
|
|
8048
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
|
8375
|
+
const [showTransition, setShowTransition] = (0, import_react51.useState)(false);
|
|
8376
|
+
const isResizingRef = (0, import_react51.useRef)(false);
|
|
8377
|
+
const defaultRender = (0, import_react51.useMemo)(() => {
|
|
8378
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children });
|
|
8049
8379
|
return PuckDefault;
|
|
8050
8380
|
}, []);
|
|
8051
|
-
const CustomPreview = (0,
|
|
8381
|
+
const CustomPreview = (0, import_react51.useMemo)(
|
|
8052
8382
|
() => overrides.preview || defaultRender,
|
|
8053
8383
|
[overrides]
|
|
8054
8384
|
);
|
|
8055
|
-
const getFrameDimensions = (0,
|
|
8385
|
+
const getFrameDimensions = (0, import_react51.useCallback)(() => {
|
|
8056
8386
|
if (frameRef.current) {
|
|
8057
8387
|
const frame = frameRef.current;
|
|
8058
8388
|
const box = getBox(frame);
|
|
@@ -8060,23 +8390,17 @@ var Canvas = () => {
|
|
|
8060
8390
|
}
|
|
8061
8391
|
return { width: 0, height: 0 };
|
|
8062
8392
|
}, [frameRef]);
|
|
8063
|
-
(0,
|
|
8064
|
-
resetAutoZoom(
|
|
8065
|
-
isResettingRef: isResettingZoomRef,
|
|
8066
|
-
setShowTransition,
|
|
8067
|
-
showTransition: false,
|
|
8068
|
-
viewports
|
|
8069
|
-
});
|
|
8393
|
+
(0, import_react51.useEffect)(() => {
|
|
8394
|
+
resetAutoZoom();
|
|
8070
8395
|
}, [
|
|
8071
8396
|
frameRef,
|
|
8072
8397
|
leftSideBarVisible,
|
|
8073
8398
|
rightSideBarVisible,
|
|
8074
8399
|
leftSideBarWidth,
|
|
8075
8400
|
rightSideBarWidth,
|
|
8076
|
-
resetAutoZoom,
|
|
8077
8401
|
viewports
|
|
8078
8402
|
]);
|
|
8079
|
-
(0,
|
|
8403
|
+
(0, import_react51.useEffect)(() => {
|
|
8080
8404
|
const { height: frameHeight } = getFrameDimensions();
|
|
8081
8405
|
if (viewports.current.height === "auto") {
|
|
8082
8406
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
@@ -8084,55 +8408,55 @@ var Canvas = () => {
|
|
|
8084
8408
|
}));
|
|
8085
8409
|
}
|
|
8086
8410
|
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
8087
|
-
(0,
|
|
8411
|
+
(0, import_react51.useEffect)(() => {
|
|
8088
8412
|
if (ZOOM_ON_CHANGE) {
|
|
8089
|
-
resetAutoZoom(
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
isResettingRef: isResettingZoomRef,
|
|
8101
|
-
setShowTransition,
|
|
8102
|
-
showTransition: false
|
|
8103
|
-
});
|
|
8104
|
-
};
|
|
8105
|
-
window.addEventListener("resize", cb);
|
|
8413
|
+
resetAutoZoom();
|
|
8414
|
+
}
|
|
8415
|
+
}, [viewports.current.width, viewports]);
|
|
8416
|
+
(0, import_react51.useEffect)(() => {
|
|
8417
|
+
if (!frameRef.current) return;
|
|
8418
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
8419
|
+
if (!isResizingRef.current) {
|
|
8420
|
+
resetAutoZoom();
|
|
8421
|
+
}
|
|
8422
|
+
});
|
|
8423
|
+
resizeObserver.observe(frameRef.current);
|
|
8106
8424
|
return () => {
|
|
8107
|
-
|
|
8425
|
+
resizeObserver.disconnect();
|
|
8108
8426
|
};
|
|
8109
|
-
}, [
|
|
8110
|
-
const [showLoader, setShowLoader] = (0,
|
|
8111
|
-
(0,
|
|
8427
|
+
}, [frameRef.current]);
|
|
8428
|
+
const [showLoader, setShowLoader] = (0, import_react51.useState)(false);
|
|
8429
|
+
(0, import_react51.useEffect)(() => {
|
|
8112
8430
|
setTimeout(() => {
|
|
8113
8431
|
setShowLoader(true);
|
|
8114
8432
|
}, 500);
|
|
8115
8433
|
}, []);
|
|
8116
|
-
return /* @__PURE__ */ (0,
|
|
8434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
8117
8435
|
"div",
|
|
8118
8436
|
{
|
|
8119
|
-
className:
|
|
8437
|
+
className: getClassName26({
|
|
8120
8438
|
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
|
8121
8439
|
showLoader
|
|
8122
8440
|
}),
|
|
8123
|
-
onClick: () =>
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8441
|
+
onClick: (e) => {
|
|
8442
|
+
const el = e.target;
|
|
8443
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
8444
|
+
dispatch({
|
|
8445
|
+
type: "setUi",
|
|
8446
|
+
ui: { itemSelector: null },
|
|
8447
|
+
recordHistory: true
|
|
8448
|
+
});
|
|
8449
|
+
}
|
|
8450
|
+
},
|
|
8128
8451
|
children: [
|
|
8129
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
|
8452
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8130
8453
|
ViewportControls,
|
|
8131
8454
|
{
|
|
8132
8455
|
autoZoom: zoomConfig.autoZoom,
|
|
8133
8456
|
zoom: zoomConfig.zoom,
|
|
8134
8457
|
onViewportChange: (viewport) => {
|
|
8135
8458
|
setShowTransition(true);
|
|
8459
|
+
isResizingRef.current = true;
|
|
8136
8460
|
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
|
8137
8461
|
height: viewport.height || "auto",
|
|
8138
8462
|
zoom: zoomConfig.zoom
|
|
@@ -8144,42 +8468,39 @@ var Canvas = () => {
|
|
|
8144
8468
|
setUi(newUi);
|
|
8145
8469
|
if (ZOOM_ON_CHANGE) {
|
|
8146
8470
|
resetAutoZoom({
|
|
8147
|
-
isResettingRef: isResettingZoomRef,
|
|
8148
|
-
setShowTransition,
|
|
8149
|
-
showTransition: true,
|
|
8150
8471
|
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
8151
8472
|
});
|
|
8152
8473
|
}
|
|
8153
8474
|
},
|
|
8154
8475
|
onZoom: (zoom) => {
|
|
8155
8476
|
setShowTransition(true);
|
|
8477
|
+
isResizingRef.current = true;
|
|
8156
8478
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
|
8157
8479
|
}
|
|
8158
8480
|
}
|
|
8159
8481
|
) }),
|
|
8160
|
-
/* @__PURE__ */ (0,
|
|
8161
|
-
/* @__PURE__ */ (0,
|
|
8482
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
|
8483
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8162
8484
|
"div",
|
|
8163
8485
|
{
|
|
8164
|
-
className:
|
|
8486
|
+
className: getClassName26("root"),
|
|
8165
8487
|
style: {
|
|
8166
8488
|
width: iframe.enabled ? viewports.current.width : "100%",
|
|
8167
8489
|
height: zoomConfig.rootHeight,
|
|
8168
8490
|
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
|
8169
|
-
transition: showTransition ?
|
|
8491
|
+
transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, height ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : "",
|
|
8170
8492
|
overflow: iframe.enabled ? void 0 : "auto"
|
|
8171
8493
|
},
|
|
8172
8494
|
suppressHydrationWarning: true,
|
|
8173
8495
|
id: "puck-canvas-root",
|
|
8174
8496
|
onTransitionEnd: () => {
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
});
|
|
8497
|
+
setShowTransition(false);
|
|
8498
|
+
isResizingRef.current = false;
|
|
8178
8499
|
},
|
|
8179
|
-
children: /* @__PURE__ */ (0,
|
|
8500
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Preview2, {}) })
|
|
8180
8501
|
}
|
|
8181
8502
|
),
|
|
8182
|
-
/* @__PURE__ */ (0,
|
|
8503
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Loader, { size: 24 }) })
|
|
8183
8504
|
] })
|
|
8184
8505
|
]
|
|
8185
8506
|
}
|
|
@@ -8188,7 +8509,7 @@ var Canvas = () => {
|
|
|
8188
8509
|
|
|
8189
8510
|
// lib/use-loaded-overrides.ts
|
|
8190
8511
|
init_react_import();
|
|
8191
|
-
var
|
|
8512
|
+
var import_react52 = require("react");
|
|
8192
8513
|
|
|
8193
8514
|
// lib/load-overrides.ts
|
|
8194
8515
|
init_react_import();
|
|
@@ -8198,8 +8519,11 @@ var loadOverrides = ({
|
|
|
8198
8519
|
}) => {
|
|
8199
8520
|
const collected = __spreadValues({}, overrides);
|
|
8200
8521
|
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
8522
|
+
if (!plugin.overrides) return;
|
|
8201
8523
|
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
|
8524
|
+
var _a;
|
|
8202
8525
|
const overridesType = _overridesType;
|
|
8526
|
+
if (!((_a = plugin.overrides) == null ? void 0 : _a[overridesType])) return;
|
|
8203
8527
|
if (overridesType === "fieldTypes") {
|
|
8204
8528
|
const fieldTypes = plugin.overrides.fieldTypes;
|
|
8205
8529
|
Object.keys(fieldTypes).forEach((fieldType) => {
|
|
@@ -8227,26 +8551,26 @@ var useLoadedOverrides = ({
|
|
|
8227
8551
|
overrides,
|
|
8228
8552
|
plugins
|
|
8229
8553
|
}) => {
|
|
8230
|
-
return (0,
|
|
8554
|
+
return (0, import_react52.useMemo)(() => {
|
|
8231
8555
|
return loadOverrides({ overrides, plugins });
|
|
8232
8556
|
}, [plugins, overrides]);
|
|
8233
8557
|
};
|
|
8234
8558
|
|
|
8235
8559
|
// components/DefaultOverride/index.tsx
|
|
8236
8560
|
init_react_import();
|
|
8237
|
-
var
|
|
8238
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
|
8561
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
8562
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children });
|
|
8239
8563
|
|
|
8240
8564
|
// lib/use-inject-css.ts
|
|
8241
8565
|
init_react_import();
|
|
8242
|
-
var
|
|
8566
|
+
var import_react53 = require("react");
|
|
8243
8567
|
var styles = ``;
|
|
8244
8568
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
8245
|
-
const [el, setEl] = (0,
|
|
8246
|
-
(0,
|
|
8569
|
+
const [el, setEl] = (0, import_react53.useState)();
|
|
8570
|
+
(0, import_react53.useEffect)(() => {
|
|
8247
8571
|
setEl(document.createElement("style"));
|
|
8248
8572
|
}, []);
|
|
8249
|
-
(0,
|
|
8573
|
+
(0, import_react53.useEffect)(() => {
|
|
8250
8574
|
var _a;
|
|
8251
8575
|
if (!el || typeof window === "undefined") {
|
|
8252
8576
|
return;
|
|
@@ -8266,10 +8590,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
8266
8590
|
|
|
8267
8591
|
// lib/use-preview-mode-hotkeys.ts
|
|
8268
8592
|
init_react_import();
|
|
8269
|
-
var
|
|
8593
|
+
var import_react54 = require("react");
|
|
8270
8594
|
var usePreviewModeHotkeys = () => {
|
|
8271
8595
|
const appStore = useAppStoreApi();
|
|
8272
|
-
const toggleInteractive = (0,
|
|
8596
|
+
const toggleInteractive = (0, import_react54.useCallback)(() => {
|
|
8273
8597
|
const dispatch = appStore.getState().dispatch;
|
|
8274
8598
|
dispatch({
|
|
8275
8599
|
type: "setUi",
|
|
@@ -8284,7 +8608,7 @@ var usePreviewModeHotkeys = () => {
|
|
|
8284
8608
|
|
|
8285
8609
|
// lib/use-puck.ts
|
|
8286
8610
|
init_react_import();
|
|
8287
|
-
var
|
|
8611
|
+
var import_react55 = require("react");
|
|
8288
8612
|
var import_zustand6 = require("zustand");
|
|
8289
8613
|
var generateUsePuck = (store) => {
|
|
8290
8614
|
const history = {
|
|
@@ -8307,17 +8631,11 @@ var generateUsePuck = (store) => {
|
|
|
8307
8631
|
selectedItem: store.selectedItem || null,
|
|
8308
8632
|
getItemBySelector: (selector) => getItem(selector, store.state),
|
|
8309
8633
|
getItemById: (id) => store.state.indexes.nodes[id].data,
|
|
8310
|
-
getSelectorForId: (id) =>
|
|
8311
|
-
const node = store.state.indexes.nodes[id];
|
|
8312
|
-
if (!node) return;
|
|
8313
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
8314
|
-
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
|
8315
|
-
return { zone: zoneCompound, index };
|
|
8316
|
-
}
|
|
8634
|
+
getSelectorForId: (id) => getSelectorForId(store.state, id)
|
|
8317
8635
|
};
|
|
8318
8636
|
return storeData;
|
|
8319
8637
|
};
|
|
8320
|
-
var UsePuckStoreContext = (0,
|
|
8638
|
+
var UsePuckStoreContext = (0, import_react55.createContext)(
|
|
8321
8639
|
null
|
|
8322
8640
|
);
|
|
8323
8641
|
var convertToPickedStore = (store) => {
|
|
@@ -8331,12 +8649,12 @@ var convertToPickedStore = (store) => {
|
|
|
8331
8649
|
};
|
|
8332
8650
|
};
|
|
8333
8651
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8334
|
-
const [usePuckStore] = (0,
|
|
8652
|
+
const [usePuckStore] = (0, import_react55.useState)(
|
|
8335
8653
|
() => (0, import_zustand6.createStore)(
|
|
8336
8654
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8337
8655
|
)
|
|
8338
8656
|
);
|
|
8339
|
-
(0,
|
|
8657
|
+
(0, import_react55.useEffect)(() => {
|
|
8340
8658
|
return appStore.subscribe(
|
|
8341
8659
|
(store) => convertToPickedStore(store),
|
|
8342
8660
|
(pickedStore) => {
|
|
@@ -8348,7 +8666,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8348
8666
|
};
|
|
8349
8667
|
function createUsePuck() {
|
|
8350
8668
|
return function usePuck2(selector) {
|
|
8351
|
-
const usePuckApi = (0,
|
|
8669
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8352
8670
|
if (!usePuckApi) {
|
|
8353
8671
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8354
8672
|
}
|
|
@@ -8360,7 +8678,7 @@ function createUsePuck() {
|
|
|
8360
8678
|
};
|
|
8361
8679
|
}
|
|
8362
8680
|
function usePuck() {
|
|
8363
|
-
(0,
|
|
8681
|
+
(0, import_react55.useEffect)(() => {
|
|
8364
8682
|
console.warn(
|
|
8365
8683
|
"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."
|
|
8366
8684
|
);
|
|
@@ -8368,7 +8686,7 @@ function usePuck() {
|
|
|
8368
8686
|
return createUsePuck()((s) => s);
|
|
8369
8687
|
}
|
|
8370
8688
|
function useGetPuck() {
|
|
8371
|
-
const usePuckApi = (0,
|
|
8689
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8372
8690
|
if (!usePuckApi) {
|
|
8373
8691
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8374
8692
|
}
|
|
@@ -8380,18 +8698,18 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8380
8698
|
|
|
8381
8699
|
// components/Puck/components/Header/index.tsx
|
|
8382
8700
|
init_react_import();
|
|
8383
|
-
var
|
|
8701
|
+
var import_react56 = require("react");
|
|
8384
8702
|
|
|
8385
8703
|
// components/MenuBar/index.tsx
|
|
8386
8704
|
init_react_import();
|
|
8387
8705
|
|
|
8388
8706
|
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
|
8389
8707
|
init_react_import();
|
|
8390
|
-
var
|
|
8708
|
+
var styles_module_default22 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
|
8391
8709
|
|
|
8392
8710
|
// components/MenuBar/index.tsx
|
|
8393
|
-
var
|
|
8394
|
-
var
|
|
8711
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
8712
|
+
var getClassName27 = get_class_name_factory_default("MenuBar", styles_module_default22);
|
|
8395
8713
|
function MenuBar({
|
|
8396
8714
|
menuOpen = false,
|
|
8397
8715
|
renderHeaderActions,
|
|
@@ -8401,10 +8719,10 @@ function MenuBar({
|
|
|
8401
8719
|
const forward = useAppStore((s) => s.history.forward);
|
|
8402
8720
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
8403
8721
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
8404
|
-
return /* @__PURE__ */ (0,
|
|
8722
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8405
8723
|
"div",
|
|
8406
8724
|
{
|
|
8407
|
-
className:
|
|
8725
|
+
className: getClassName27({ menuOpen }),
|
|
8408
8726
|
onClick: (event) => {
|
|
8409
8727
|
var _a;
|
|
8410
8728
|
const element = event.target;
|
|
@@ -8415,30 +8733,30 @@ function MenuBar({
|
|
|
8415
8733
|
setMenuOpen(false);
|
|
8416
8734
|
}
|
|
8417
8735
|
},
|
|
8418
|
-
children: /* @__PURE__ */ (0,
|
|
8419
|
-
/* @__PURE__ */ (0,
|
|
8420
|
-
/* @__PURE__ */ (0,
|
|
8736
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName27("inner"), children: [
|
|
8737
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName27("history"), children: [
|
|
8738
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8421
8739
|
IconButton,
|
|
8422
8740
|
{
|
|
8423
8741
|
type: "button",
|
|
8424
8742
|
title: "undo",
|
|
8425
8743
|
disabled: !hasPast,
|
|
8426
8744
|
onClick: back,
|
|
8427
|
-
children: /* @__PURE__ */ (0,
|
|
8745
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Undo2, { size: 21 })
|
|
8428
8746
|
}
|
|
8429
8747
|
),
|
|
8430
|
-
/* @__PURE__ */ (0,
|
|
8748
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8431
8749
|
IconButton,
|
|
8432
8750
|
{
|
|
8433
8751
|
type: "button",
|
|
8434
8752
|
title: "redo",
|
|
8435
8753
|
disabled: !hasFuture,
|
|
8436
8754
|
onClick: forward,
|
|
8437
|
-
children: /* @__PURE__ */ (0,
|
|
8755
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Redo2, { size: 21 })
|
|
8438
8756
|
}
|
|
8439
8757
|
)
|
|
8440
8758
|
] }),
|
|
8441
|
-
/* @__PURE__ */ (0,
|
|
8759
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_jsx_runtime43.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
|
8442
8760
|
] })
|
|
8443
8761
|
}
|
|
8444
8762
|
);
|
|
@@ -8446,11 +8764,11 @@ function MenuBar({
|
|
|
8446
8764
|
|
|
8447
8765
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
|
8448
8766
|
init_react_import();
|
|
8449
|
-
var
|
|
8767
|
+
var styles_module_default23 = { "PuckHeader": "_PuckHeader_15xnq_1", "PuckHeader-inner": "_PuckHeader-inner_15xnq_10", "PuckHeader-toggle": "_PuckHeader-toggle_15xnq_20", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_15xnq_27", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_15xnq_27", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_15xnq_28", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_15xnq_28", "PuckHeader-title": "_PuckHeader-title_15xnq_32", "PuckHeader-path": "_PuckHeader-path_15xnq_36", "PuckHeader-tools": "_PuckHeader-tools_15xnq_43", "PuckHeader-menuButton": "_PuckHeader-menuButton_15xnq_49", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_15xnq_54" };
|
|
8450
8768
|
|
|
8451
8769
|
// components/Puck/components/Header/index.tsx
|
|
8452
|
-
var
|
|
8453
|
-
var
|
|
8770
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8771
|
+
var getClassName28 = get_class_name_factory_default("PuckHeader", styles_module_default23);
|
|
8454
8772
|
var HeaderInner = () => {
|
|
8455
8773
|
const {
|
|
8456
8774
|
onPublish,
|
|
@@ -8462,7 +8780,7 @@ var HeaderInner = () => {
|
|
|
8462
8780
|
} = usePropsContext();
|
|
8463
8781
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8464
8782
|
const appStore = useAppStoreApi();
|
|
8465
|
-
const defaultHeaderRender = (0,
|
|
8783
|
+
const defaultHeaderRender = (0, import_react56.useMemo)(() => {
|
|
8466
8784
|
if (renderHeader) {
|
|
8467
8785
|
console.warn(
|
|
8468
8786
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8471,13 +8789,13 @@ var HeaderInner = () => {
|
|
|
8471
8789
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
8472
8790
|
const Comp = renderHeader;
|
|
8473
8791
|
const appState = useAppStore((s) => s.state);
|
|
8474
|
-
return /* @__PURE__ */ (0,
|
|
8792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
8475
8793
|
};
|
|
8476
8794
|
return RenderHeader;
|
|
8477
8795
|
}
|
|
8478
8796
|
return DefaultOverride;
|
|
8479
8797
|
}, [renderHeader]);
|
|
8480
|
-
const defaultHeaderActionsRender = (0,
|
|
8798
|
+
const defaultHeaderActionsRender = (0, import_react56.useMemo)(() => {
|
|
8481
8799
|
if (renderHeaderActions) {
|
|
8482
8800
|
console.warn(
|
|
8483
8801
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8485,19 +8803,19 @@ var HeaderInner = () => {
|
|
|
8485
8803
|
const RenderHeader = (props) => {
|
|
8486
8804
|
const Comp = renderHeaderActions;
|
|
8487
8805
|
const appState = useAppStore((s) => s.state);
|
|
8488
|
-
return /* @__PURE__ */ (0,
|
|
8806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
8489
8807
|
};
|
|
8490
8808
|
return RenderHeader;
|
|
8491
8809
|
}
|
|
8492
8810
|
return DefaultOverride;
|
|
8493
|
-
}, [
|
|
8811
|
+
}, [renderHeaderActions]);
|
|
8494
8812
|
const CustomHeader = useAppStore(
|
|
8495
8813
|
(s) => s.overrides.header || defaultHeaderRender
|
|
8496
8814
|
);
|
|
8497
8815
|
const CustomHeaderActions = useAppStore(
|
|
8498
8816
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8499
8817
|
);
|
|
8500
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8818
|
+
const [menuOpen, setMenuOpen] = (0, import_react56.useState)(false);
|
|
8501
8819
|
const rootTitle = useAppStore((s) => {
|
|
8502
8820
|
var _a, _b;
|
|
8503
8821
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8507,7 +8825,7 @@ var HeaderInner = () => {
|
|
|
8507
8825
|
const rightSideBarVisible = useAppStore(
|
|
8508
8826
|
(s) => s.state.ui.rightSideBarVisible
|
|
8509
8827
|
);
|
|
8510
|
-
const toggleSidebars = (0,
|
|
8828
|
+
const toggleSidebars = (0, import_react56.useCallback)(
|
|
8511
8829
|
(sidebar) => {
|
|
8512
8830
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8513
8831
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8521,27 +8839,27 @@ var HeaderInner = () => {
|
|
|
8521
8839
|
},
|
|
8522
8840
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
8523
8841
|
);
|
|
8524
|
-
return /* @__PURE__ */ (0,
|
|
8842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8525
8843
|
CustomHeader,
|
|
8526
8844
|
{
|
|
8527
|
-
actions: /* @__PURE__ */ (0,
|
|
8845
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_jsx_runtime44.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8528
8846
|
Button,
|
|
8529
8847
|
{
|
|
8530
8848
|
onClick: () => {
|
|
8531
8849
|
const data = appStore.getState().state.data;
|
|
8532
8850
|
onPublish && onPublish(data);
|
|
8533
8851
|
},
|
|
8534
|
-
icon: /* @__PURE__ */ (0,
|
|
8852
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Globe, { size: "14px" }),
|
|
8535
8853
|
children: "Publish"
|
|
8536
8854
|
}
|
|
8537
8855
|
) }) }),
|
|
8538
|
-
children: /* @__PURE__ */ (0,
|
|
8856
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8539
8857
|
"header",
|
|
8540
8858
|
{
|
|
8541
|
-
className:
|
|
8542
|
-
children: /* @__PURE__ */ (0,
|
|
8543
|
-
/* @__PURE__ */ (0,
|
|
8544
|
-
/* @__PURE__ */ (0,
|
|
8859
|
+
className: getClassName28({ leftSideBarVisible, rightSideBarVisible }),
|
|
8860
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: getClassName28("inner"), children: [
|
|
8861
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: getClassName28("toggle"), children: [
|
|
8862
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName28("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8545
8863
|
IconButton,
|
|
8546
8864
|
{
|
|
8547
8865
|
type: "button",
|
|
@@ -8549,10 +8867,10 @@ var HeaderInner = () => {
|
|
|
8549
8867
|
toggleSidebars("left");
|
|
8550
8868
|
},
|
|
8551
8869
|
title: "Toggle left sidebar",
|
|
8552
|
-
children: /* @__PURE__ */ (0,
|
|
8870
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PanelLeft, { focusable: "false" })
|
|
8553
8871
|
}
|
|
8554
8872
|
) }),
|
|
8555
|
-
/* @__PURE__ */ (0,
|
|
8873
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName28("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8556
8874
|
IconButton,
|
|
8557
8875
|
{
|
|
8558
8876
|
type: "button",
|
|
@@ -8560,19 +8878,19 @@ var HeaderInner = () => {
|
|
|
8560
8878
|
toggleSidebars("right");
|
|
8561
8879
|
},
|
|
8562
8880
|
title: "Toggle right sidebar",
|
|
8563
|
-
children: /* @__PURE__ */ (0,
|
|
8881
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PanelRight, { focusable: "false" })
|
|
8564
8882
|
}
|
|
8565
8883
|
) })
|
|
8566
8884
|
] }),
|
|
8567
|
-
/* @__PURE__ */ (0,
|
|
8885
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName28("title"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
|
8568
8886
|
headerTitle || rootTitle || "Page",
|
|
8569
|
-
headerPath && /* @__PURE__ */ (0,
|
|
8887
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
|
|
8570
8888
|
" ",
|
|
8571
|
-
/* @__PURE__ */ (0,
|
|
8889
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("code", { className: getClassName28("path"), children: headerPath })
|
|
8572
8890
|
] })
|
|
8573
8891
|
] }) }),
|
|
8574
|
-
/* @__PURE__ */ (0,
|
|
8575
|
-
/* @__PURE__ */ (0,
|
|
8892
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: getClassName28("tools"), children: [
|
|
8893
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName28("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8576
8894
|
IconButton,
|
|
8577
8895
|
{
|
|
8578
8896
|
type: "button",
|
|
@@ -8580,23 +8898,23 @@ var HeaderInner = () => {
|
|
|
8580
8898
|
return setMenuOpen(!menuOpen);
|
|
8581
8899
|
},
|
|
8582
8900
|
title: "Toggle menu bar",
|
|
8583
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
|
8901
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ChevronDown, { focusable: "false" })
|
|
8584
8902
|
}
|
|
8585
8903
|
) }),
|
|
8586
|
-
/* @__PURE__ */ (0,
|
|
8904
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8587
8905
|
MenuBar,
|
|
8588
8906
|
{
|
|
8589
8907
|
dispatch,
|
|
8590
8908
|
onPublish,
|
|
8591
8909
|
menuOpen,
|
|
8592
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
|
8910
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8593
8911
|
Button,
|
|
8594
8912
|
{
|
|
8595
8913
|
onClick: () => {
|
|
8596
8914
|
const data = appStore.getState().state.data;
|
|
8597
8915
|
onPublish && onPublish(data);
|
|
8598
8916
|
},
|
|
8599
|
-
icon: /* @__PURE__ */ (0,
|
|
8917
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Globe, { size: "14px" }),
|
|
8600
8918
|
children: "Publish"
|
|
8601
8919
|
}
|
|
8602
8920
|
) }),
|
|
@@ -8610,22 +8928,22 @@ var HeaderInner = () => {
|
|
|
8610
8928
|
}
|
|
8611
8929
|
);
|
|
8612
8930
|
};
|
|
8613
|
-
var Header = (0,
|
|
8931
|
+
var Header = (0, import_react56.memo)(HeaderInner);
|
|
8614
8932
|
|
|
8615
8933
|
// components/Puck/components/Sidebar/index.tsx
|
|
8616
8934
|
init_react_import();
|
|
8617
8935
|
|
|
8618
8936
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
8619
8937
|
init_react_import();
|
|
8620
|
-
var
|
|
8938
|
+
var import_react57 = require("react");
|
|
8621
8939
|
|
|
8622
8940
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
8623
8941
|
init_react_import();
|
|
8624
|
-
var
|
|
8942
|
+
var styles_module_default24 = { "ResizeHandle": "_ResizeHandle_144bf_2", "ResizeHandle--left": "_ResizeHandle--left_144bf_16", "ResizeHandle--right": "_ResizeHandle--right_144bf_20" };
|
|
8625
8943
|
|
|
8626
8944
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
8627
|
-
var
|
|
8628
|
-
var
|
|
8945
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
8946
|
+
var getClassName29 = get_class_name_factory_default("ResizeHandle", styles_module_default24);
|
|
8629
8947
|
var ResizeHandle = ({
|
|
8630
8948
|
position,
|
|
8631
8949
|
sidebarRef,
|
|
@@ -8634,11 +8952,11 @@ var ResizeHandle = ({
|
|
|
8634
8952
|
}) => {
|
|
8635
8953
|
const { frameRef } = useCanvasFrame();
|
|
8636
8954
|
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
8637
|
-
const handleRef = (0,
|
|
8638
|
-
const isDragging = (0,
|
|
8639
|
-
const startX = (0,
|
|
8640
|
-
const startWidth = (0,
|
|
8641
|
-
const handleMouseMove = (0,
|
|
8955
|
+
const handleRef = (0, import_react57.useRef)(null);
|
|
8956
|
+
const isDragging = (0, import_react57.useRef)(false);
|
|
8957
|
+
const startX = (0, import_react57.useRef)(0);
|
|
8958
|
+
const startWidth = (0, import_react57.useRef)(0);
|
|
8959
|
+
const handleMouseMove = (0, import_react57.useCallback)(
|
|
8642
8960
|
(e) => {
|
|
8643
8961
|
if (!isDragging.current) return;
|
|
8644
8962
|
const delta = e.clientX - startX.current;
|
|
@@ -8649,7 +8967,7 @@ var ResizeHandle = ({
|
|
|
8649
8967
|
},
|
|
8650
8968
|
[onResize, position]
|
|
8651
8969
|
);
|
|
8652
|
-
const handleMouseUp = (0,
|
|
8970
|
+
const handleMouseUp = (0, import_react57.useCallback)(() => {
|
|
8653
8971
|
var _a;
|
|
8654
8972
|
if (!isDragging.current) return;
|
|
8655
8973
|
isDragging.current = false;
|
|
@@ -8664,8 +8982,8 @@ var ResizeHandle = ({
|
|
|
8664
8982
|
const finalWidth = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
8665
8983
|
onResizeEnd(finalWidth);
|
|
8666
8984
|
resetAutoZoom();
|
|
8667
|
-
}, [onResizeEnd
|
|
8668
|
-
const handleMouseDown = (0,
|
|
8985
|
+
}, [onResizeEnd]);
|
|
8986
|
+
const handleMouseDown = (0, import_react57.useCallback)(
|
|
8669
8987
|
(e) => {
|
|
8670
8988
|
var _a;
|
|
8671
8989
|
isDragging.current = true;
|
|
@@ -8683,11 +9001,11 @@ var ResizeHandle = ({
|
|
|
8683
9001
|
},
|
|
8684
9002
|
[position, handleMouseMove, handleMouseUp]
|
|
8685
9003
|
);
|
|
8686
|
-
return /* @__PURE__ */ (0,
|
|
9004
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
8687
9005
|
"div",
|
|
8688
9006
|
{
|
|
8689
9007
|
ref: handleRef,
|
|
8690
|
-
className:
|
|
9008
|
+
className: getClassName29({ [position]: true }),
|
|
8691
9009
|
onMouseDown: handleMouseDown
|
|
8692
9010
|
}
|
|
8693
9011
|
);
|
|
@@ -8695,24 +9013,23 @@ var ResizeHandle = ({
|
|
|
8695
9013
|
|
|
8696
9014
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Sidebar/styles.module.css#css-module
|
|
8697
9015
|
init_react_import();
|
|
8698
|
-
var
|
|
9016
|
+
var styles_module_default25 = { "Sidebar": "_Sidebar_1xksb_1", "Sidebar--left": "_Sidebar--left_1xksb_8", "Sidebar--right": "_Sidebar--right_1xksb_14", "Sidebar-resizeHandle": "_Sidebar-resizeHandle_1xksb_20" };
|
|
8699
9017
|
|
|
8700
9018
|
// components/Puck/components/Sidebar/index.tsx
|
|
8701
|
-
var
|
|
8702
|
-
var
|
|
9019
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
9020
|
+
var getClassName30 = get_class_name_factory_default("Sidebar", styles_module_default25);
|
|
8703
9021
|
var Sidebar = ({
|
|
8704
9022
|
position,
|
|
8705
9023
|
sidebarRef,
|
|
8706
9024
|
isVisible,
|
|
8707
|
-
width,
|
|
8708
9025
|
onResize,
|
|
8709
9026
|
onResizeEnd,
|
|
8710
9027
|
children
|
|
8711
9028
|
}) => {
|
|
8712
9029
|
if (!isVisible) return null;
|
|
8713
|
-
return /* @__PURE__ */ (0,
|
|
8714
|
-
/* @__PURE__ */ (0,
|
|
8715
|
-
/* @__PURE__ */ (0,
|
|
9030
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
|
|
9031
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { ref: sidebarRef, className: getClassName30({ [position]: true }), children }),
|
|
9032
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: `${getClassName30("resizeHandle")}`, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
8716
9033
|
ResizeHandle,
|
|
8717
9034
|
{
|
|
8718
9035
|
position,
|
|
@@ -8726,25 +9043,26 @@ var Sidebar = ({
|
|
|
8726
9043
|
|
|
8727
9044
|
// lib/use-sidebar-resize.ts
|
|
8728
9045
|
init_react_import();
|
|
8729
|
-
var
|
|
9046
|
+
var import_react58 = require("react");
|
|
8730
9047
|
function useSidebarResize(position, dispatch) {
|
|
8731
|
-
const [width, setWidth] = (0,
|
|
8732
|
-
const sidebarRef = (0,
|
|
9048
|
+
const [width, setWidth] = (0, import_react58.useState)(null);
|
|
9049
|
+
const sidebarRef = (0, import_react58.useRef)(null);
|
|
8733
9050
|
const storeWidth = useAppStore(
|
|
8734
9051
|
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
8735
9052
|
);
|
|
8736
|
-
(0,
|
|
9053
|
+
(0, import_react58.useEffect)(() => {
|
|
8737
9054
|
if (typeof window !== "undefined" && !storeWidth) {
|
|
8738
9055
|
try {
|
|
8739
9056
|
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
8740
9057
|
if (savedWidths) {
|
|
8741
9058
|
const widths = JSON.parse(savedWidths);
|
|
8742
9059
|
const savedWidth = widths[position];
|
|
9060
|
+
const key = position === "left" ? "leftSideBarWidth" : "rightSideBarWidth";
|
|
8743
9061
|
if (savedWidth) {
|
|
8744
9062
|
dispatch({
|
|
8745
9063
|
type: "setUi",
|
|
8746
9064
|
ui: {
|
|
8747
|
-
[
|
|
9065
|
+
[key]: savedWidth
|
|
8748
9066
|
}
|
|
8749
9067
|
});
|
|
8750
9068
|
}
|
|
@@ -8757,12 +9075,12 @@ function useSidebarResize(position, dispatch) {
|
|
|
8757
9075
|
}
|
|
8758
9076
|
}
|
|
8759
9077
|
}, [dispatch, position, storeWidth]);
|
|
8760
|
-
(0,
|
|
9078
|
+
(0, import_react58.useEffect)(() => {
|
|
8761
9079
|
if (storeWidth !== void 0) {
|
|
8762
9080
|
setWidth(storeWidth);
|
|
8763
9081
|
}
|
|
8764
9082
|
}, [storeWidth]);
|
|
8765
|
-
const handleResizeEnd = (0,
|
|
9083
|
+
const handleResizeEnd = (0, import_react58.useCallback)(
|
|
8766
9084
|
(width2) => {
|
|
8767
9085
|
dispatch({
|
|
8768
9086
|
type: "setUi",
|
|
@@ -8805,9 +9123,9 @@ function useSidebarResize(position, dispatch) {
|
|
|
8805
9123
|
}
|
|
8806
9124
|
|
|
8807
9125
|
// components/Puck/index.tsx
|
|
8808
|
-
var
|
|
8809
|
-
var
|
|
8810
|
-
var getLayoutClassName = get_class_name_factory_default("PuckLayout",
|
|
9126
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
9127
|
+
var getClassName31 = get_class_name_factory_default("Puck", styles_module_default15);
|
|
9128
|
+
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
|
8811
9129
|
var FieldSideBar = () => {
|
|
8812
9130
|
const title = useAppStore(
|
|
8813
9131
|
(s) => {
|
|
@@ -8815,13 +9133,13 @@ var FieldSideBar = () => {
|
|
|
8815
9133
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
8816
9134
|
}
|
|
8817
9135
|
);
|
|
8818
|
-
return /* @__PURE__ */ (0,
|
|
9136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Fields, {}) });
|
|
8819
9137
|
};
|
|
8820
|
-
var propsContext = (0,
|
|
9138
|
+
var propsContext = (0, import_react59.createContext)({});
|
|
8821
9139
|
function PropsProvider(props) {
|
|
8822
|
-
return /* @__PURE__ */ (0,
|
|
9140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
8823
9141
|
}
|
|
8824
|
-
var usePropsContext = () => (0,
|
|
9142
|
+
var usePropsContext = () => (0, import_react59.useContext)(propsContext);
|
|
8825
9143
|
function PuckProvider({ children }) {
|
|
8826
9144
|
const {
|
|
8827
9145
|
config,
|
|
@@ -8835,16 +9153,17 @@ function PuckProvider({ children }) {
|
|
|
8835
9153
|
iframe: _iframe,
|
|
8836
9154
|
initialHistory: _initialHistory,
|
|
8837
9155
|
metadata,
|
|
8838
|
-
onAction
|
|
9156
|
+
onAction,
|
|
9157
|
+
fieldTransforms
|
|
8839
9158
|
} = usePropsContext();
|
|
8840
|
-
const iframe = (0,
|
|
9159
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8841
9160
|
() => __spreadValues({
|
|
8842
9161
|
enabled: true,
|
|
8843
9162
|
waitForStyles: true
|
|
8844
9163
|
}, _iframe),
|
|
8845
9164
|
[_iframe]
|
|
8846
9165
|
);
|
|
8847
|
-
const [generatedAppState] = (0,
|
|
9166
|
+
const [generatedAppState] = (0, import_react59.useState)(() => {
|
|
8848
9167
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8849
9168
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8850
9169
|
let clientUiState = {};
|
|
@@ -8873,7 +9192,7 @@ function PuckProvider({ children }) {
|
|
|
8873
9192
|
}
|
|
8874
9193
|
}
|
|
8875
9194
|
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_g = initialData == null ? void 0 : initialData.root) == null ? void 0 : _g.props)) {
|
|
8876
|
-
console.
|
|
9195
|
+
console.warn(
|
|
8877
9196
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
|
8878
9197
|
);
|
|
8879
9198
|
}
|
|
@@ -8904,7 +9223,7 @@ function PuckProvider({ children }) {
|
|
|
8904
9223
|
return walkAppState(newAppState, config);
|
|
8905
9224
|
});
|
|
8906
9225
|
const { appendData = true } = _initialHistory || {};
|
|
8907
|
-
const [blendedHistories] = (0,
|
|
9226
|
+
const [blendedHistories] = (0, import_react59.useState)(
|
|
8908
9227
|
[
|
|
8909
9228
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8910
9229
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8924,7 +9243,15 @@ function PuckProvider({ children }) {
|
|
|
8924
9243
|
overrides,
|
|
8925
9244
|
plugins
|
|
8926
9245
|
});
|
|
8927
|
-
const
|
|
9246
|
+
const loadedFieldTransforms = (0, import_react59.useMemo)(() => {
|
|
9247
|
+
const _plugins = plugins || [];
|
|
9248
|
+
const pluginFieldTransforms = _plugins.reduce(
|
|
9249
|
+
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
9250
|
+
{}
|
|
9251
|
+
);
|
|
9252
|
+
return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
|
|
9253
|
+
}, [fieldTransforms, plugins]);
|
|
9254
|
+
const generateAppStore = (0, import_react59.useCallback)(
|
|
8928
9255
|
(state) => {
|
|
8929
9256
|
return {
|
|
8930
9257
|
state,
|
|
@@ -8934,7 +9261,8 @@ function PuckProvider({ children }) {
|
|
|
8934
9261
|
viewports,
|
|
8935
9262
|
iframe,
|
|
8936
9263
|
onAction,
|
|
8937
|
-
metadata
|
|
9264
|
+
metadata,
|
|
9265
|
+
fieldTransforms: loadedFieldTransforms
|
|
8938
9266
|
};
|
|
8939
9267
|
},
|
|
8940
9268
|
[
|
|
@@ -8945,18 +9273,19 @@ function PuckProvider({ children }) {
|
|
|
8945
9273
|
viewports,
|
|
8946
9274
|
iframe,
|
|
8947
9275
|
onAction,
|
|
8948
|
-
metadata
|
|
9276
|
+
metadata,
|
|
9277
|
+
loadedFieldTransforms
|
|
8949
9278
|
]
|
|
8950
9279
|
);
|
|
8951
|
-
const [appStore] = (0,
|
|
9280
|
+
const [appStore] = (0, import_react59.useState)(
|
|
8952
9281
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8953
9282
|
);
|
|
8954
|
-
(0,
|
|
9283
|
+
(0, import_react59.useEffect)(() => {
|
|
8955
9284
|
if (process.env.NODE_ENV !== "production") {
|
|
8956
9285
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8957
9286
|
}
|
|
8958
9287
|
}, [appStore]);
|
|
8959
|
-
(0,
|
|
9288
|
+
(0, import_react59.useEffect)(() => {
|
|
8960
9289
|
const state = appStore.getState().state;
|
|
8961
9290
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8962
9291
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8965,8 +9294,8 @@ function PuckProvider({ children }) {
|
|
|
8965
9294
|
index: initialHistoryIndex,
|
|
8966
9295
|
initialAppState
|
|
8967
9296
|
});
|
|
8968
|
-
const previousData = (0,
|
|
8969
|
-
(0,
|
|
9297
|
+
const previousData = (0, import_react59.useRef)(null);
|
|
9298
|
+
(0, import_react59.useEffect)(() => {
|
|
8970
9299
|
appStore.subscribe(
|
|
8971
9300
|
(s) => s.state.data,
|
|
8972
9301
|
(data) => {
|
|
@@ -8980,11 +9309,11 @@ function PuckProvider({ children }) {
|
|
|
8980
9309
|
}, []);
|
|
8981
9310
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8982
9311
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8983
|
-
(0,
|
|
9312
|
+
(0, import_react59.useEffect)(() => {
|
|
8984
9313
|
const { resolveAndCommitData } = appStore.getState();
|
|
8985
9314
|
resolveAndCommitData();
|
|
8986
9315
|
}, []);
|
|
8987
|
-
return /* @__PURE__ */ (0,
|
|
9316
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
|
8988
9317
|
}
|
|
8989
9318
|
function PuckLayout({ children }) {
|
|
8990
9319
|
const {
|
|
@@ -8992,7 +9321,7 @@ function PuckLayout({ children }) {
|
|
|
8992
9321
|
dnd,
|
|
8993
9322
|
initialHistory: _initialHistory
|
|
8994
9323
|
} = usePropsContext();
|
|
8995
|
-
const iframe = (0,
|
|
9324
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8996
9325
|
() => __spreadValues({
|
|
8997
9326
|
enabled: true,
|
|
8998
9327
|
waitForStyles: true
|
|
@@ -9017,7 +9346,7 @@ function PuckLayout({ children }) {
|
|
|
9017
9346
|
sidebarRef: rightSidebarRef,
|
|
9018
9347
|
handleResizeEnd: handleRightSidebarResizeEnd
|
|
9019
9348
|
} = useSidebarResize("right", dispatch);
|
|
9020
|
-
(0,
|
|
9349
|
+
(0, import_react59.useEffect)(() => {
|
|
9021
9350
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
9022
9351
|
dispatch({
|
|
9023
9352
|
type: "setUi",
|
|
@@ -9041,17 +9370,17 @@ function PuckLayout({ children }) {
|
|
|
9041
9370
|
};
|
|
9042
9371
|
}, []);
|
|
9043
9372
|
const overrides = useAppStore((s) => s.overrides);
|
|
9044
|
-
const CustomPuck = (0,
|
|
9373
|
+
const CustomPuck = (0, import_react59.useMemo)(
|
|
9045
9374
|
() => overrides.puck || DefaultOverride,
|
|
9046
9375
|
[overrides]
|
|
9047
9376
|
);
|
|
9048
|
-
const [mounted, setMounted] = (0,
|
|
9049
|
-
(0,
|
|
9377
|
+
const [mounted, setMounted] = (0, import_react59.useState)(false);
|
|
9378
|
+
(0, import_react59.useEffect)(() => {
|
|
9050
9379
|
setMounted(true);
|
|
9051
9380
|
}, []);
|
|
9052
9381
|
const ready = useAppStore((s) => s.status === "READY");
|
|
9053
9382
|
useMonitorHotkeys();
|
|
9054
|
-
(0,
|
|
9383
|
+
(0, import_react59.useEffect)(() => {
|
|
9055
9384
|
if (ready && iframe.enabled) {
|
|
9056
9385
|
const frameDoc = getFrame();
|
|
9057
9386
|
if (frameDoc) {
|
|
@@ -9060,8 +9389,15 @@ function PuckLayout({ children }) {
|
|
|
9060
9389
|
}
|
|
9061
9390
|
}, [ready, iframe.enabled]);
|
|
9062
9391
|
usePreviewModeHotkeys();
|
|
9063
|
-
|
|
9064
|
-
|
|
9392
|
+
const layoutOptions = {};
|
|
9393
|
+
if (leftWidth) {
|
|
9394
|
+
layoutOptions["--puck-user-left-side-bar-width"] = `${leftWidth}px`;
|
|
9395
|
+
}
|
|
9396
|
+
if (rightWidth) {
|
|
9397
|
+
layoutOptions["--puck-user-right-side-bar-width"] = `${rightWidth}px`;
|
|
9398
|
+
}
|
|
9399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: `Puck ${getClassName31()}`, children: [
|
|
9400
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(FrameProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9065
9401
|
"div",
|
|
9066
9402
|
{
|
|
9067
9403
|
className: getLayoutClassName({
|
|
@@ -9069,45 +9405,37 @@ function PuckLayout({ children }) {
|
|
|
9069
9405
|
mounted,
|
|
9070
9406
|
rightSideBarVisible
|
|
9071
9407
|
}),
|
|
9072
|
-
children: /* @__PURE__ */ (0,
|
|
9408
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9073
9409
|
"div",
|
|
9074
9410
|
{
|
|
9075
9411
|
className: getLayoutClassName("inner"),
|
|
9076
|
-
style:
|
|
9077
|
-
gridTemplateColumns: `
|
|
9078
|
-
${leftSideBarVisible ? leftWidth ? `${leftWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
9079
|
-
var(--puck-frame-width)
|
|
9080
|
-
${rightSideBarVisible ? rightWidth ? `${rightWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
9081
|
-
`
|
|
9082
|
-
},
|
|
9412
|
+
style: layoutOptions,
|
|
9083
9413
|
children: [
|
|
9084
|
-
/* @__PURE__ */ (0,
|
|
9085
|
-
/* @__PURE__ */ (0,
|
|
9414
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Header, {}),
|
|
9415
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9086
9416
|
Sidebar,
|
|
9087
9417
|
{
|
|
9088
9418
|
position: "left",
|
|
9089
9419
|
sidebarRef: leftSidebarRef,
|
|
9090
9420
|
isVisible: leftSideBarVisible,
|
|
9091
|
-
width: leftWidth,
|
|
9092
9421
|
onResize: setLeftWidth,
|
|
9093
9422
|
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
9094
9423
|
children: [
|
|
9095
|
-
/* @__PURE__ */ (0,
|
|
9096
|
-
/* @__PURE__ */ (0,
|
|
9424
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Components, {}) }),
|
|
9425
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Outline, {}) })
|
|
9097
9426
|
]
|
|
9098
9427
|
}
|
|
9099
9428
|
),
|
|
9100
|
-
/* @__PURE__ */ (0,
|
|
9101
|
-
/* @__PURE__ */ (0,
|
|
9429
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Canvas, {}),
|
|
9430
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9102
9431
|
Sidebar,
|
|
9103
9432
|
{
|
|
9104
9433
|
position: "right",
|
|
9105
9434
|
sidebarRef: rightSidebarRef,
|
|
9106
9435
|
isVisible: rightSideBarVisible,
|
|
9107
|
-
width: rightWidth,
|
|
9108
9436
|
onResize: setRightWidth,
|
|
9109
9437
|
onResizeEnd: handleRightSidebarResizeEnd,
|
|
9110
|
-
children: /* @__PURE__ */ (0,
|
|
9438
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(FieldSideBar, {})
|
|
9111
9439
|
}
|
|
9112
9440
|
)
|
|
9113
9441
|
]
|
|
@@ -9115,11 +9443,11 @@ function PuckLayout({ children }) {
|
|
|
9115
9443
|
)
|
|
9116
9444
|
}
|
|
9117
9445
|
) }) }) }),
|
|
9118
|
-
/* @__PURE__ */ (0,
|
|
9446
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { id: "puck-portal-root", className: getClassName31("portal") })
|
|
9119
9447
|
] });
|
|
9120
9448
|
}
|
|
9121
9449
|
function Puck(props) {
|
|
9122
|
-
return /* @__PURE__ */ (0,
|
|
9450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
|
|
9123
9451
|
}
|
|
9124
9452
|
Puck.Components = Components;
|
|
9125
9453
|
Puck.Fields = Fields;
|
|
@@ -9318,9 +9646,9 @@ function resolveAllData(_0, _1) {
|
|
|
9318
9646
|
},
|
|
9319
9647
|
"force"
|
|
9320
9648
|
)).node;
|
|
9321
|
-
const resolvedDeep = yield
|
|
9649
|
+
const resolvedDeep = yield mapFields(
|
|
9322
9650
|
resolved,
|
|
9323
|
-
processContent,
|
|
9651
|
+
{ slot: ({ value }) => processContent(value) },
|
|
9324
9652
|
config
|
|
9325
9653
|
);
|
|
9326
9654
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
@@ -9366,8 +9694,10 @@ function resolveAllData(_0, _1) {
|
|
|
9366
9694
|
createUsePuck,
|
|
9367
9695
|
migrate,
|
|
9368
9696
|
overrideKeys,
|
|
9697
|
+
registerOverlayPortal,
|
|
9369
9698
|
renderContext,
|
|
9370
9699
|
resolveAllData,
|
|
9700
|
+
setDeep,
|
|
9371
9701
|
transformProps,
|
|
9372
9702
|
useGetPuck,
|
|
9373
9703
|
usePuck,
|