@measured/puck 0.20.0-canary.def0ecb5 → 0.20.0-canary.e25949a6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-VATSTM62.mjs → chunk-FYXJ5FPS.mjs} +725 -501
- package/dist/{chunk-32MJ3X3H.mjs → chunk-HUKJ36SA.mjs} +131 -69
- package/dist/index.css +79 -45
- package/dist/index.d.mts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +875 -591
- package/dist/index.mjs +6 -2
- package/dist/no-external.css +79 -45
- package/dist/no-external.d.mts +2 -2
- package/dist/no-external.d.ts +2 -2
- package/dist/no-external.js +875 -591
- 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-mCPqBAls.d.mts → walk-tree-B57SgEEc.d.mts} +26 -2
- package/dist/{walk-tree-mCPqBAls.d.ts → walk-tree-B57SgEEc.d.ts} +26 -2
- 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
|
|
|
@@ -307,10 +312,10 @@ init_react_import();
|
|
|
307
312
|
|
|
308
313
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
|
309
314
|
init_react_import();
|
|
310
|
-
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" };
|
|
311
316
|
|
|
312
317
|
// components/AutoField/index.tsx
|
|
313
|
-
var
|
|
318
|
+
var import_react20 = require("react");
|
|
314
319
|
|
|
315
320
|
// components/AutoField/fields/index.tsx
|
|
316
321
|
init_react_import();
|
|
@@ -654,7 +659,7 @@ init_react_import();
|
|
|
654
659
|
|
|
655
660
|
// components/IconButton/IconButton.tsx
|
|
656
661
|
init_react_import();
|
|
657
|
-
var
|
|
662
|
+
var import_react9 = require("react");
|
|
658
663
|
|
|
659
664
|
// css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
|
|
660
665
|
init_react_import();
|
|
@@ -689,7 +694,6 @@ var replace = (list, index, newItem) => {
|
|
|
689
694
|
|
|
690
695
|
// lib/use-reset-auto-zoom.ts
|
|
691
696
|
init_react_import();
|
|
692
|
-
var import_react9 = require("react");
|
|
693
697
|
|
|
694
698
|
// store/index.ts
|
|
695
699
|
init_react_import();
|
|
@@ -736,7 +740,7 @@ function forRelatedZones(item, data, cb, path = []) {
|
|
|
736
740
|
});
|
|
737
741
|
}
|
|
738
742
|
|
|
739
|
-
// lib/data/map-
|
|
743
|
+
// lib/data/map-fields.ts
|
|
740
744
|
init_react_import();
|
|
741
745
|
|
|
742
746
|
// lib/data/default-slots.ts
|
|
@@ -746,14 +750,14 @@ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
|
|
|
746
750
|
value
|
|
747
751
|
);
|
|
748
752
|
|
|
749
|
-
// lib/data/map-
|
|
753
|
+
// lib/data/map-fields.ts
|
|
750
754
|
var isPromise = (v) => !!v && typeof v.then === "function";
|
|
751
755
|
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
|
752
756
|
var containsPromise = (arr) => arr.some(isPromise);
|
|
753
757
|
var walkField = ({
|
|
754
758
|
value,
|
|
755
759
|
fields,
|
|
756
|
-
|
|
760
|
+
mappers,
|
|
757
761
|
propKey = "",
|
|
758
762
|
propPath = "",
|
|
759
763
|
id = "",
|
|
@@ -761,7 +765,9 @@ var walkField = ({
|
|
|
761
765
|
recurseSlots = false
|
|
762
766
|
}) => {
|
|
763
767
|
var _a, _b, _c;
|
|
764
|
-
|
|
768
|
+
const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
|
|
769
|
+
const map = mappers[fieldType];
|
|
770
|
+
if (map && fieldType === "slot") {
|
|
765
771
|
const content = value || [];
|
|
766
772
|
const mappedContent = recurseSlots ? content.map((el) => {
|
|
767
773
|
var _a2;
|
|
@@ -773,7 +779,7 @@ var walkField = ({
|
|
|
773
779
|
return walkField({
|
|
774
780
|
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
|
775
781
|
fields: fields2,
|
|
776
|
-
|
|
782
|
+
mappers,
|
|
777
783
|
id: el.props.id,
|
|
778
784
|
config,
|
|
779
785
|
recurseSlots
|
|
@@ -782,7 +788,21 @@ var walkField = ({
|
|
|
782
788
|
if (containsPromise(mappedContent)) {
|
|
783
789
|
return Promise.all(mappedContent);
|
|
784
790
|
}
|
|
785
|
-
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
|
+
});
|
|
786
806
|
}
|
|
787
807
|
if (value && typeof value === "object") {
|
|
788
808
|
if (Array.isArray(value)) {
|
|
@@ -792,7 +812,7 @@ var walkField = ({
|
|
|
792
812
|
(el, idx) => walkField({
|
|
793
813
|
value: el,
|
|
794
814
|
fields: arrayFields,
|
|
795
|
-
|
|
815
|
+
mappers,
|
|
796
816
|
propKey,
|
|
797
817
|
propPath: `${propPath}[${idx}]`,
|
|
798
818
|
id,
|
|
@@ -811,7 +831,7 @@ var walkField = ({
|
|
|
811
831
|
return walkObject({
|
|
812
832
|
value,
|
|
813
833
|
fields: objectFields,
|
|
814
|
-
|
|
834
|
+
mappers,
|
|
815
835
|
id,
|
|
816
836
|
getPropPath: (k) => `${propPath}.${k}`,
|
|
817
837
|
config,
|
|
@@ -824,7 +844,7 @@ var walkField = ({
|
|
|
824
844
|
var walkObject = ({
|
|
825
845
|
value,
|
|
826
846
|
fields,
|
|
827
|
-
|
|
847
|
+
mappers,
|
|
828
848
|
id,
|
|
829
849
|
getPropPath,
|
|
830
850
|
config,
|
|
@@ -834,7 +854,7 @@ var walkObject = ({
|
|
|
834
854
|
const opts = {
|
|
835
855
|
value: v,
|
|
836
856
|
fields,
|
|
837
|
-
|
|
857
|
+
mappers,
|
|
838
858
|
propKey: k,
|
|
839
859
|
propPath: getPropPath(k),
|
|
840
860
|
id,
|
|
@@ -856,14 +876,14 @@ var walkObject = ({
|
|
|
856
876
|
}
|
|
857
877
|
return flatten(newProps);
|
|
858
878
|
};
|
|
859
|
-
function
|
|
879
|
+
function mapFields(item, mappers, config, recurseSlots = false) {
|
|
860
880
|
var _a, _b, _c, _d, _e;
|
|
861
881
|
const itemType = "type" in item ? item.type : "root";
|
|
862
882
|
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
|
863
883
|
const newProps = walkObject({
|
|
864
884
|
value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
|
|
865
885
|
fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
|
|
866
|
-
|
|
886
|
+
mappers,
|
|
867
887
|
id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
|
|
868
888
|
getPropPath: (k) => k,
|
|
869
889
|
config,
|
|
@@ -886,7 +906,7 @@ var import_flat = __toESM(require("flat"));
|
|
|
886
906
|
// lib/data/strip-slots.ts
|
|
887
907
|
init_react_import();
|
|
888
908
|
var stripSlots = (data, config) => {
|
|
889
|
-
return
|
|
909
|
+
return mapFields(data, { slot: () => null }, config);
|
|
890
910
|
};
|
|
891
911
|
|
|
892
912
|
// lib/data/flatten-node.ts
|
|
@@ -945,18 +965,21 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
|
945
965
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
|
946
966
|
if (!mappedItem) return item;
|
|
947
967
|
const id = mappedItem.props.id;
|
|
948
|
-
const newProps = __spreadProps(__spreadValues({},
|
|
968
|
+
const newProps = __spreadProps(__spreadValues({}, mapFields(
|
|
949
969
|
mappedItem,
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
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
|
+
}
|
|
960
983
|
},
|
|
961
984
|
config
|
|
962
985
|
).props), {
|
|
@@ -1074,11 +1097,14 @@ init_react_import();
|
|
|
1074
1097
|
function walkTree(data, config, callbackFn) {
|
|
1075
1098
|
var _a, _b;
|
|
1076
1099
|
const walkItem = (item) => {
|
|
1077
|
-
return
|
|
1100
|
+
return mapFields(
|
|
1078
1101
|
item,
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1102
|
+
{
|
|
1103
|
+
slot: ({ value, parentId, propName }) => {
|
|
1104
|
+
var _a2;
|
|
1105
|
+
const content = value;
|
|
1106
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
|
1107
|
+
}
|
|
1082
1108
|
},
|
|
1083
1109
|
config,
|
|
1084
1110
|
true
|
|
@@ -2144,24 +2170,27 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
|
2144
2170
|
resolvedItem.readOnly = readOnly;
|
|
2145
2171
|
}
|
|
2146
2172
|
}
|
|
2147
|
-
let itemWithResolvedChildren = yield
|
|
2173
|
+
let itemWithResolvedChildren = yield mapFields(
|
|
2148
2174
|
resolvedItem,
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
content
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
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
|
+
},
|
|
2165
2194
|
config
|
|
2166
2195
|
);
|
|
2167
2196
|
if (shouldRunResolver && onResolveEnd) {
|
|
@@ -2243,7 +2272,8 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
|
2243
2272
|
},
|
|
2244
2273
|
status: "LOADING",
|
|
2245
2274
|
iframe: {},
|
|
2246
|
-
metadata: {}
|
|
2275
|
+
metadata: {},
|
|
2276
|
+
fieldTransforms: {}
|
|
2247
2277
|
}, initialAppStore), {
|
|
2248
2278
|
fields: createFieldsSlice(set, get),
|
|
2249
2279
|
history: createHistorySlice(set, get),
|
|
@@ -2559,56 +2589,18 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
|
2559
2589
|
};
|
|
2560
2590
|
|
|
2561
2591
|
// lib/use-reset-auto-zoom.ts
|
|
2562
|
-
var import_shallow = require("zustand/react/shallow");
|
|
2563
2592
|
var useResetAutoZoom = (frameRef) => {
|
|
2564
|
-
const
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
if (frameRef.current) {
|
|
2576
|
-
setZoomConfig(
|
|
2577
|
-
getZoomConfig(
|
|
2578
|
-
newViewports == null ? void 0 : newViewports.current,
|
|
2579
|
-
frameRef.current,
|
|
2580
|
-
zoomConfig.zoom
|
|
2581
|
-
)
|
|
2582
|
-
);
|
|
2583
|
-
}
|
|
2584
|
-
return;
|
|
2585
|
-
}
|
|
2586
|
-
const {
|
|
2587
|
-
isResettingRef,
|
|
2588
|
-
setShowTransition,
|
|
2589
|
-
showTransition = false
|
|
2590
|
-
} = options;
|
|
2591
|
-
if (!isResettingRef.current) {
|
|
2592
|
-
isResettingRef.current = true;
|
|
2593
|
-
if (setShowTransition) {
|
|
2594
|
-
setShowTransition(showTransition);
|
|
2595
|
-
}
|
|
2596
|
-
if (frameRef.current) {
|
|
2597
|
-
setZoomConfig(
|
|
2598
|
-
getZoomConfig(
|
|
2599
|
-
newViewports == null ? void 0 : newViewports.current,
|
|
2600
|
-
frameRef.current,
|
|
2601
|
-
zoomConfig.zoom
|
|
2602
|
-
)
|
|
2603
|
-
);
|
|
2604
|
-
}
|
|
2605
|
-
setTimeout(() => {
|
|
2606
|
-
isResettingRef.current = false;
|
|
2607
|
-
}, 0);
|
|
2608
|
-
}
|
|
2609
|
-
},
|
|
2610
|
-
[frameRef, zoomConfig, viewports, setZoomConfig]
|
|
2611
|
-
);
|
|
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
|
+
};
|
|
2612
2604
|
return resetAutoZoom;
|
|
2613
2605
|
};
|
|
2614
2606
|
|
|
@@ -2656,7 +2648,7 @@ var IconButton = ({
|
|
|
2656
2648
|
fullWidth,
|
|
2657
2649
|
title
|
|
2658
2650
|
}) => {
|
|
2659
|
-
const [loading, setLoading] = (0,
|
|
2651
|
+
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
2660
2652
|
const ElementType = href ? "a" : "button";
|
|
2661
2653
|
const el = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2662
2654
|
ElementType,
|
|
@@ -2695,7 +2687,7 @@ var IconButton = ({
|
|
|
2695
2687
|
};
|
|
2696
2688
|
|
|
2697
2689
|
// components/AutoField/fields/ArrayField/index.tsx
|
|
2698
|
-
var
|
|
2690
|
+
var import_react14 = require("react");
|
|
2699
2691
|
|
|
2700
2692
|
// components/DragIcon/index.tsx
|
|
2701
2693
|
init_react_import();
|
|
@@ -2711,12 +2703,12 @@ var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ (0, import_jsx_runtime4.j
|
|
|
2711
2703
|
|
|
2712
2704
|
// components/Sortable/index.tsx
|
|
2713
2705
|
init_react_import();
|
|
2714
|
-
var
|
|
2706
|
+
var import_react12 = require("@dnd-kit/react");
|
|
2715
2707
|
|
|
2716
2708
|
// lib/dnd/use-sensors.ts
|
|
2717
2709
|
init_react_import();
|
|
2718
|
-
var
|
|
2719
|
-
var
|
|
2710
|
+
var import_react10 = require("react");
|
|
2711
|
+
var import_react11 = require("@dnd-kit/react");
|
|
2720
2712
|
var import_utilities = require("@dnd-kit/dom/utilities");
|
|
2721
2713
|
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
|
2722
2714
|
var otherDefault = {
|
|
@@ -2731,8 +2723,8 @@ var useSensors = ({
|
|
|
2731
2723
|
touch: touchDefault,
|
|
2732
2724
|
other: otherDefault
|
|
2733
2725
|
}) => {
|
|
2734
|
-
const [sensors] = (0,
|
|
2735
|
-
|
|
2726
|
+
const [sensors] = (0, import_react10.useState)(() => [
|
|
2727
|
+
import_react11.PointerSensor.configure({
|
|
2736
2728
|
activationConstraints(event, source) {
|
|
2737
2729
|
var _a;
|
|
2738
2730
|
const { pointerType, target } = event;
|
|
@@ -3078,7 +3070,7 @@ var SortableProvider = ({
|
|
|
3078
3070
|
mouse: { distance: { value: 5 } }
|
|
3079
3071
|
});
|
|
3080
3072
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3081
|
-
|
|
3073
|
+
import_react12.DragDropProvider,
|
|
3082
3074
|
{
|
|
3083
3075
|
sensors,
|
|
3084
3076
|
onDragStart: (event) => {
|
|
@@ -3142,11 +3134,11 @@ var Sortable = ({
|
|
|
3142
3134
|
|
|
3143
3135
|
// components/AutoField/context.tsx
|
|
3144
3136
|
init_react_import();
|
|
3145
|
-
var
|
|
3137
|
+
var import_react13 = require("react");
|
|
3146
3138
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3147
|
-
var NestedFieldContext = (0,
|
|
3139
|
+
var NestedFieldContext = (0, import_react13.createContext)({});
|
|
3148
3140
|
var useNestedFieldContext = () => {
|
|
3149
|
-
const context = (0,
|
|
3141
|
+
const context = (0, import_react13.useContext)(NestedFieldContext);
|
|
3150
3142
|
return __spreadProps(__spreadValues({}, context), {
|
|
3151
3143
|
readOnlyFields: context.readOnlyFields || {}
|
|
3152
3144
|
});
|
|
@@ -3160,7 +3152,7 @@ var NestedFieldProvider = ({
|
|
|
3160
3152
|
}) => {
|
|
3161
3153
|
const subPath = `${name}.${subName}`;
|
|
3162
3154
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
|
3163
|
-
const subReadOnlyFields = (0,
|
|
3155
|
+
const subReadOnlyFields = (0, import_react13.useMemo)(
|
|
3164
3156
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
|
3165
3157
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
|
3166
3158
|
if (isLocal) {
|
|
@@ -3213,14 +3205,14 @@ var ArrayField = ({
|
|
|
3213
3205
|
}),
|
|
3214
3206
|
openId: ""
|
|
3215
3207
|
};
|
|
3216
|
-
const [localState, setLocalState] = (0,
|
|
3217
|
-
(0,
|
|
3208
|
+
const [localState, setLocalState] = (0, import_react14.useState)({ arrayState, value });
|
|
3209
|
+
(0, import_react14.useEffect)(() => {
|
|
3218
3210
|
var _a;
|
|
3219
3211
|
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
|
3220
3212
|
setLocalState({ arrayState: _arrayState, value });
|
|
3221
3213
|
}, [value]);
|
|
3222
3214
|
const appStore = useAppStoreApi();
|
|
3223
|
-
const mapArrayStateToUi = (0,
|
|
3215
|
+
const mapArrayStateToUi = (0, import_react14.useCallback)(
|
|
3224
3216
|
(partialArrayState) => {
|
|
3225
3217
|
const state = appStore.getState().state;
|
|
3226
3218
|
return {
|
|
@@ -3231,13 +3223,13 @@ var ArrayField = ({
|
|
|
3231
3223
|
},
|
|
3232
3224
|
[arrayState, appStore]
|
|
3233
3225
|
);
|
|
3234
|
-
const getHighestIndex = (0,
|
|
3226
|
+
const getHighestIndex = (0, import_react14.useCallback)(() => {
|
|
3235
3227
|
return arrayState.items.reduce(
|
|
3236
3228
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
|
3237
3229
|
-1
|
|
3238
3230
|
);
|
|
3239
3231
|
}, [arrayState]);
|
|
3240
|
-
const regenerateArrayState = (0,
|
|
3232
|
+
const regenerateArrayState = (0, import_react14.useCallback)(
|
|
3241
3233
|
(value2) => {
|
|
3242
3234
|
let highestIndex = getHighestIndex();
|
|
3243
3235
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
|
@@ -3256,26 +3248,31 @@ var ArrayField = ({
|
|
|
3256
3248
|
},
|
|
3257
3249
|
[arrayState]
|
|
3258
3250
|
);
|
|
3259
|
-
(0,
|
|
3251
|
+
(0, import_react14.useEffect)(() => {
|
|
3260
3252
|
if (arrayState.items.length > 0) {
|
|
3261
3253
|
setUi(mapArrayStateToUi(arrayState));
|
|
3262
3254
|
}
|
|
3263
3255
|
}, []);
|
|
3264
|
-
const [draggedItem, setDraggedItem] = (0,
|
|
3256
|
+
const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
|
|
3265
3257
|
const isDraggingAny = !!draggedItem;
|
|
3266
3258
|
const canEdit = useAppStore(
|
|
3267
3259
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
|
3268
3260
|
);
|
|
3269
3261
|
const forceReadOnly = !canEdit;
|
|
3270
|
-
const valueRef = (0,
|
|
3271
|
-
const uniqifyItem = (0,
|
|
3262
|
+
const valueRef = (0, import_react14.useRef)(value);
|
|
3263
|
+
const uniqifyItem = (0, import_react14.useCallback)(
|
|
3272
3264
|
(val) => {
|
|
3273
3265
|
if (field.type !== "array" || !field.arrayFields) return;
|
|
3274
3266
|
const config = appStore.getState().config;
|
|
3275
3267
|
return walkField({
|
|
3276
3268
|
value: val,
|
|
3277
3269
|
fields: field.arrayFields,
|
|
3278
|
-
|
|
3270
|
+
mappers: {
|
|
3271
|
+
slot: ({ value: value2 }) => {
|
|
3272
|
+
const content = value2;
|
|
3273
|
+
return content.map((item) => populateIds(item, config, true));
|
|
3274
|
+
}
|
|
3275
|
+
},
|
|
3279
3276
|
config
|
|
3280
3277
|
});
|
|
3281
3278
|
},
|
|
@@ -3430,49 +3427,51 @@ var ArrayField = ({
|
|
|
3430
3427
|
]
|
|
3431
3428
|
}
|
|
3432
3429
|
),
|
|
3433
|
-
/* @__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(
|
|
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
|
-
|
|
3463
|
-
onChange(
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
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
|
+
}
|
|
3469
3468
|
}
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3469
|
+
)
|
|
3470
|
+
},
|
|
3471
|
+
subPath
|
|
3472
|
+
);
|
|
3473
|
+
}
|
|
3474
|
+
) }) })
|
|
3476
3475
|
]
|
|
3477
3476
|
}
|
|
3478
3477
|
)
|
|
@@ -3573,11 +3572,11 @@ var DefaultField = ({
|
|
|
3573
3572
|
|
|
3574
3573
|
// components/AutoField/fields/ExternalField/index.tsx
|
|
3575
3574
|
init_react_import();
|
|
3576
|
-
var
|
|
3575
|
+
var import_react18 = require("react");
|
|
3577
3576
|
|
|
3578
3577
|
// components/ExternalInput/index.tsx
|
|
3579
3578
|
init_react_import();
|
|
3580
|
-
var
|
|
3579
|
+
var import_react17 = require("react");
|
|
3581
3580
|
|
|
3582
3581
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
|
3583
3582
|
init_react_import();
|
|
@@ -3585,7 +3584,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
|
3585
3584
|
|
|
3586
3585
|
// components/Modal/index.tsx
|
|
3587
3586
|
init_react_import();
|
|
3588
|
-
var
|
|
3587
|
+
var import_react15 = require("react");
|
|
3589
3588
|
|
|
3590
3589
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
|
3591
3590
|
init_react_import();
|
|
@@ -3600,8 +3599,8 @@ var Modal = ({
|
|
|
3600
3599
|
onClose,
|
|
3601
3600
|
isOpen
|
|
3602
3601
|
}) => {
|
|
3603
|
-
const [rootEl, setRootEl] = (0,
|
|
3604
|
-
(0,
|
|
3602
|
+
const [rootEl, setRootEl] = (0, import_react15.useState)(null);
|
|
3603
|
+
(0, import_react15.useEffect)(() => {
|
|
3605
3604
|
setRootEl(document.getElementById("puck-portal-root"));
|
|
3606
3605
|
}, []);
|
|
3607
3606
|
if (!rootEl) {
|
|
@@ -3648,7 +3647,7 @@ init_react_import();
|
|
|
3648
3647
|
|
|
3649
3648
|
// components/Button/Button.tsx
|
|
3650
3649
|
init_react_import();
|
|
3651
|
-
var
|
|
3650
|
+
var import_react16 = require("react");
|
|
3652
3651
|
|
|
3653
3652
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
|
3654
3653
|
init_react_import();
|
|
@@ -3698,8 +3697,8 @@ var Button = (_a) => {
|
|
|
3698
3697
|
"size",
|
|
3699
3698
|
"loading"
|
|
3700
3699
|
]);
|
|
3701
|
-
const [loading, setLoading] = (0,
|
|
3702
|
-
(0,
|
|
3700
|
+
const [loading, setLoading] = (0, import_react16.useState)(loadingProp);
|
|
3701
|
+
(0, import_react16.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
|
3703
3702
|
const ElementType = href ? "a" : type ? "button" : "span";
|
|
3704
3703
|
const dataAttrs = filterDataAttrs(props);
|
|
3705
3704
|
const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
@@ -3754,28 +3753,28 @@ var ExternalInput = ({
|
|
|
3754
3753
|
mapRow = (val) => val,
|
|
3755
3754
|
filterFields
|
|
3756
3755
|
} = field || {};
|
|
3757
|
-
const [data, setData] = (0,
|
|
3758
|
-
const [isOpen, setOpen] = (0,
|
|
3759
|
-
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);
|
|
3760
3759
|
const hasFilterFields = !!filterFields;
|
|
3761
|
-
const [filters, setFilters] = (0,
|
|
3762
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
|
3763
|
-
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)(() => {
|
|
3764
3763
|
return data.map(mapRow);
|
|
3765
3764
|
}, [data]);
|
|
3766
|
-
const keys = (0,
|
|
3765
|
+
const keys = (0, import_react17.useMemo)(() => {
|
|
3767
3766
|
const validKeys = /* @__PURE__ */ new Set();
|
|
3768
3767
|
for (const item of mappedData) {
|
|
3769
3768
|
for (const key of Object.keys(item)) {
|
|
3770
|
-
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])) {
|
|
3771
3770
|
validKeys.add(key);
|
|
3772
3771
|
}
|
|
3773
3772
|
}
|
|
3774
3773
|
}
|
|
3775
3774
|
return Array.from(validKeys);
|
|
3776
3775
|
}, [mappedData]);
|
|
3777
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
3778
|
-
const search = (0,
|
|
3776
|
+
const [searchQuery, setSearchQuery] = (0, import_react17.useState)(field.initialQuery || "");
|
|
3777
|
+
const search = (0, import_react17.useCallback)(
|
|
3779
3778
|
(query, filters2) => __async(void 0, null, function* () {
|
|
3780
3779
|
setIsLoading(true);
|
|
3781
3780
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
|
@@ -3788,7 +3787,7 @@ var ExternalInput = ({
|
|
|
3788
3787
|
}),
|
|
3789
3788
|
[id, field]
|
|
3790
3789
|
);
|
|
3791
|
-
const Footer = (0,
|
|
3790
|
+
const Footer = (0, import_react17.useCallback)(
|
|
3792
3791
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
|
3793
3792
|
props.items.length,
|
|
3794
3793
|
" result",
|
|
@@ -3796,7 +3795,7 @@ var ExternalInput = ({
|
|
|
3796
3795
|
] }),
|
|
3797
3796
|
[field.renderFooter]
|
|
3798
3797
|
);
|
|
3799
|
-
(0,
|
|
3798
|
+
(0, import_react17.useEffect)(() => {
|
|
3800
3799
|
search(searchQuery, filters);
|
|
3801
3800
|
}, []);
|
|
3802
3801
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -3969,7 +3968,7 @@ var ExternalField = ({
|
|
|
3969
3968
|
var _a, _b, _c;
|
|
3970
3969
|
const validField = field;
|
|
3971
3970
|
const deprecatedField = field;
|
|
3972
|
-
(0,
|
|
3971
|
+
(0, import_react18.useEffect)(() => {
|
|
3973
3972
|
if (deprecatedField.adaptor) {
|
|
3974
3973
|
console.error(
|
|
3975
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."
|
|
@@ -4231,12 +4230,12 @@ var ObjectField = ({
|
|
|
4231
4230
|
|
|
4232
4231
|
// lib/use-safe-id.ts
|
|
4233
4232
|
init_react_import();
|
|
4234
|
-
var
|
|
4233
|
+
var import_react19 = __toESM(require("react"));
|
|
4235
4234
|
var useSafeId = () => {
|
|
4236
|
-
if (typeof
|
|
4237
|
-
return
|
|
4235
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
|
4236
|
+
return import_react19.default.useId();
|
|
4238
4237
|
}
|
|
4239
|
-
const [id] = (0,
|
|
4238
|
+
const [id] = (0, import_react19.useState)(generateId());
|
|
4240
4239
|
return id;
|
|
4241
4240
|
};
|
|
4242
4241
|
|
|
@@ -4270,7 +4269,7 @@ var FieldLabelInternal = ({
|
|
|
4270
4269
|
readOnly
|
|
4271
4270
|
}) => {
|
|
4272
4271
|
const overrides = useAppStore((s) => s.overrides);
|
|
4273
|
-
const Wrapper = (0,
|
|
4272
|
+
const Wrapper = (0, import_react20.useMemo)(
|
|
4274
4273
|
() => overrides.fieldLabel || FieldLabel,
|
|
4275
4274
|
[overrides]
|
|
4276
4275
|
);
|
|
@@ -4297,7 +4296,7 @@ function AutoFieldInternal(props) {
|
|
|
4297
4296
|
var _a2;
|
|
4298
4297
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
|
4299
4298
|
});
|
|
4300
|
-
const nestedFieldContext = (0,
|
|
4299
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
|
4301
4300
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
|
4302
4301
|
const field = props.field;
|
|
4303
4302
|
const label = field.label;
|
|
@@ -4331,7 +4330,7 @@ function AutoFieldInternal(props) {
|
|
|
4331
4330
|
Label: Label2,
|
|
4332
4331
|
id: resolvedId
|
|
4333
4332
|
});
|
|
4334
|
-
const onFocus = (0,
|
|
4333
|
+
const onFocus = (0, import_react20.useCallback)(
|
|
4335
4334
|
(e) => {
|
|
4336
4335
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
4337
4336
|
e.stopPropagation();
|
|
@@ -4345,7 +4344,7 @@ function AutoFieldInternal(props) {
|
|
|
4345
4344
|
},
|
|
4346
4345
|
[mergedProps.name]
|
|
4347
4346
|
);
|
|
4348
|
-
const onBlur = (0,
|
|
4347
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
|
4349
4348
|
if ("name" in e.target) {
|
|
4350
4349
|
dispatch({
|
|
4351
4350
|
type: "setUi",
|
|
@@ -4398,20 +4397,20 @@ function AutoFieldInternal(props) {
|
|
|
4398
4397
|
function AutoFieldPrivate(props) {
|
|
4399
4398
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
|
4400
4399
|
const { value, onChange } = props;
|
|
4401
|
-
const [localValue, setLocalValue] = (0,
|
|
4402
|
-
const onChangeLocal = (0,
|
|
4400
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
|
4401
|
+
const onChangeLocal = (0, import_react20.useCallback)(
|
|
4403
4402
|
(val, ui) => {
|
|
4404
4403
|
setLocalValue(val);
|
|
4405
4404
|
onChange(val, ui);
|
|
4406
4405
|
},
|
|
4407
4406
|
[onChange]
|
|
4408
4407
|
);
|
|
4409
|
-
(0,
|
|
4408
|
+
(0, import_react20.useEffect)(() => {
|
|
4410
4409
|
if (!isFocused) {
|
|
4411
4410
|
setLocalValue(value);
|
|
4412
4411
|
}
|
|
4413
4412
|
}, [value]);
|
|
4414
|
-
(0,
|
|
4413
|
+
(0, import_react20.useEffect)(() => {
|
|
4415
4414
|
if (!isFocused) {
|
|
4416
4415
|
if (value !== localValue) {
|
|
4417
4416
|
setLocalValue(value);
|
|
@@ -4425,7 +4424,7 @@ function AutoFieldPrivate(props) {
|
|
|
4425
4424
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
|
4426
4425
|
}
|
|
4427
4426
|
function AutoField(props) {
|
|
4428
|
-
const DefaultLabel = (0,
|
|
4427
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
|
4429
4428
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4430
4429
|
"div",
|
|
4431
4430
|
__spreadProps(__spreadValues({}, labelProps), {
|
|
@@ -4462,7 +4461,7 @@ var import_react34 = require("react");
|
|
|
4462
4461
|
|
|
4463
4462
|
// components/DraggableComponent/index.tsx
|
|
4464
4463
|
init_react_import();
|
|
4465
|
-
var
|
|
4464
|
+
var import_react24 = require("react");
|
|
4466
4465
|
|
|
4467
4466
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4468
4467
|
init_react_import();
|
|
@@ -4492,11 +4491,11 @@ function getDeepScrollPosition(element) {
|
|
|
4492
4491
|
|
|
4493
4492
|
// components/DropZone/context.tsx
|
|
4494
4493
|
init_react_import();
|
|
4495
|
-
var
|
|
4494
|
+
var import_react21 = require("react");
|
|
4496
4495
|
var import_zustand3 = require("zustand");
|
|
4497
4496
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4498
|
-
var dropZoneContext = (0,
|
|
4499
|
-
var ZoneStoreContext = (0,
|
|
4497
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
|
4498
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
|
4500
4499
|
(0, import_zustand3.createStore)(() => ({
|
|
4501
4500
|
zoneDepthIndex: {},
|
|
4502
4501
|
nextZoneDepthIndex: {},
|
|
@@ -4519,7 +4518,7 @@ var DropZoneProvider = ({
|
|
|
4519
4518
|
value
|
|
4520
4519
|
}) => {
|
|
4521
4520
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4522
|
-
const registerZone = (0,
|
|
4521
|
+
const registerZone = (0, import_react21.useCallback)(
|
|
4523
4522
|
(zoneCompound) => {
|
|
4524
4523
|
dispatch({
|
|
4525
4524
|
type: "registerZone",
|
|
@@ -4528,7 +4527,7 @@ var DropZoneProvider = ({
|
|
|
4528
4527
|
},
|
|
4529
4528
|
[dispatch]
|
|
4530
4529
|
);
|
|
4531
|
-
const memoValue = (0,
|
|
4530
|
+
const memoValue = (0, import_react21.useMemo)(
|
|
4532
4531
|
() => __spreadValues({
|
|
4533
4532
|
registerZone
|
|
4534
4533
|
}, value),
|
|
@@ -4538,7 +4537,7 @@ var DropZoneProvider = ({
|
|
|
4538
4537
|
};
|
|
4539
4538
|
|
|
4540
4539
|
// components/DraggableComponent/index.tsx
|
|
4541
|
-
var
|
|
4540
|
+
var import_shallow2 = require("zustand/react/shallow");
|
|
4542
4541
|
var import_sortable2 = require("@dnd-kit/react/sortable");
|
|
4543
4542
|
|
|
4544
4543
|
// lib/accumulate-transform.ts
|
|
@@ -4558,23 +4557,23 @@ function accumulateTransform(el) {
|
|
|
4558
4557
|
|
|
4559
4558
|
// lib/use-context-store.ts
|
|
4560
4559
|
init_react_import();
|
|
4561
|
-
var
|
|
4560
|
+
var import_react22 = require("react");
|
|
4562
4561
|
var import_zustand4 = require("zustand");
|
|
4563
|
-
var
|
|
4562
|
+
var import_shallow = require("zustand/react/shallow");
|
|
4564
4563
|
function useContextStore(context, selector) {
|
|
4565
|
-
const store = (0,
|
|
4564
|
+
const store = (0, import_react22.useContext)(context);
|
|
4566
4565
|
if (!store) {
|
|
4567
4566
|
throw new Error("useContextStore must be used inside context");
|
|
4568
4567
|
}
|
|
4569
|
-
return (0, import_zustand4.useStore)(store, (0,
|
|
4568
|
+
return (0, import_zustand4.useStore)(store, (0, import_shallow.useShallow)(selector));
|
|
4570
4569
|
}
|
|
4571
4570
|
|
|
4572
4571
|
// lib/dnd/use-on-drag-finished.ts
|
|
4573
4572
|
init_react_import();
|
|
4574
|
-
var
|
|
4573
|
+
var import_react23 = require("react");
|
|
4575
4574
|
var useOnDragFinished = (cb, deps = []) => {
|
|
4576
4575
|
const appStore = useAppStoreApi();
|
|
4577
|
-
return (0,
|
|
4576
|
+
return (0, import_react23.useCallback)(() => {
|
|
4578
4577
|
let dispose = () => {
|
|
4579
4578
|
};
|
|
4580
4579
|
const processDragging = (isDragging2) => {
|
|
@@ -4647,9 +4646,9 @@ var DraggableComponent = ({
|
|
|
4647
4646
|
const overrides = useAppStore((s) => s.overrides);
|
|
4648
4647
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4649
4648
|
const iframe = useAppStore((s) => s.iframe);
|
|
4650
|
-
const ctx = (0,
|
|
4651
|
-
const [localZones, setLocalZones] = (0,
|
|
4652
|
-
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)(
|
|
4653
4652
|
(zoneCompound2, active) => {
|
|
4654
4653
|
var _a;
|
|
4655
4654
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
|
@@ -4659,7 +4658,7 @@ var DraggableComponent = ({
|
|
|
4659
4658
|
},
|
|
4660
4659
|
[setLocalZones]
|
|
4661
4660
|
);
|
|
4662
|
-
const unregisterLocalZone = (0,
|
|
4661
|
+
const unregisterLocalZone = (0, import_react24.useCallback)(
|
|
4663
4662
|
(zoneCompound2) => {
|
|
4664
4663
|
var _a;
|
|
4665
4664
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
|
@@ -4672,19 +4671,19 @@ var DraggableComponent = ({
|
|
|
4672
4671
|
[setLocalZones]
|
|
4673
4672
|
);
|
|
4674
4673
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
|
4675
|
-
const path = useAppStore((0,
|
|
4674
|
+
const path = useAppStore((0, import_shallow2.useShallow)((s) => {
|
|
4676
4675
|
var _a;
|
|
4677
4676
|
return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
|
|
4678
4677
|
}));
|
|
4679
4678
|
const permissions = useAppStore(
|
|
4680
|
-
(0,
|
|
4679
|
+
(0, import_shallow2.useShallow)((s) => {
|
|
4681
4680
|
const item = getItem({ index, zone: zoneCompound }, s.state);
|
|
4682
4681
|
return s.permissions.getPermissions({ item });
|
|
4683
4682
|
})
|
|
4684
4683
|
);
|
|
4685
|
-
const zoneStore = (0,
|
|
4686
|
-
const [dragAxis, setDragAxis] = (0,
|
|
4687
|
-
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)(
|
|
4688
4687
|
() => createDynamicCollisionDetector(dragAxis),
|
|
4689
4688
|
[dragAxis]
|
|
4690
4689
|
);
|
|
@@ -4716,7 +4715,7 @@ var DraggableComponent = ({
|
|
|
4716
4715
|
},
|
|
4717
4716
|
feedback: "clone"
|
|
4718
4717
|
});
|
|
4719
|
-
(0,
|
|
4718
|
+
(0, import_react24.useEffect)(() => {
|
|
4720
4719
|
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
|
4721
4720
|
sortable.droppable.disabled = !isEnabled;
|
|
4722
4721
|
sortable.draggable.disabled = !permissions.drag;
|
|
@@ -4733,8 +4732,8 @@ var DraggableComponent = ({
|
|
|
4733
4732
|
}
|
|
4734
4733
|
return cleanup;
|
|
4735
4734
|
}, [permissions.drag, zoneCompound]);
|
|
4736
|
-
const ref = (0,
|
|
4737
|
-
const refSetter = (0,
|
|
4735
|
+
const ref = (0, import_react24.useRef)(null);
|
|
4736
|
+
const refSetter = (0, import_react24.useCallback)(
|
|
4738
4737
|
(el) => {
|
|
4739
4738
|
sortableRef(el);
|
|
4740
4739
|
if (el) {
|
|
@@ -4743,14 +4742,14 @@ var DraggableComponent = ({
|
|
|
4743
4742
|
},
|
|
4744
4743
|
[sortableRef]
|
|
4745
4744
|
);
|
|
4746
|
-
const [portalEl, setPortalEl] = (0,
|
|
4747
|
-
(0,
|
|
4745
|
+
const [portalEl, setPortalEl] = (0, import_react24.useState)();
|
|
4746
|
+
(0, import_react24.useEffect)(() => {
|
|
4748
4747
|
var _a, _b, _c;
|
|
4749
4748
|
setPortalEl(
|
|
4750
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
|
|
4751
4750
|
);
|
|
4752
4751
|
}, [iframe.enabled, ref.current]);
|
|
4753
|
-
const getStyle = (0,
|
|
4752
|
+
const getStyle = (0, import_react24.useCallback)(() => {
|
|
4754
4753
|
var _a, _b, _c;
|
|
4755
4754
|
if (!ref.current) return;
|
|
4756
4755
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4775,11 +4774,11 @@ var DraggableComponent = ({
|
|
|
4775
4774
|
};
|
|
4776
4775
|
return style2;
|
|
4777
4776
|
}, [ref.current]);
|
|
4778
|
-
const [style, setStyle] = (0,
|
|
4779
|
-
const sync = (0,
|
|
4777
|
+
const [style, setStyle] = (0, import_react24.useState)();
|
|
4778
|
+
const sync = (0, import_react24.useCallback)(() => {
|
|
4780
4779
|
setStyle(getStyle());
|
|
4781
4780
|
}, [ref.current, iframe]);
|
|
4782
|
-
(0,
|
|
4781
|
+
(0, import_react24.useEffect)(() => {
|
|
4783
4782
|
if (ref.current) {
|
|
4784
4783
|
const observer = new ResizeObserver(sync);
|
|
4785
4784
|
observer.observe(ref.current);
|
|
@@ -4789,13 +4788,13 @@ var DraggableComponent = ({
|
|
|
4789
4788
|
}
|
|
4790
4789
|
}, [ref.current]);
|
|
4791
4790
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
|
4792
|
-
const hideOverlay = (0,
|
|
4791
|
+
const hideOverlay = (0, import_react24.useCallback)(() => {
|
|
4793
4792
|
setIsVisible(false);
|
|
4794
4793
|
}, []);
|
|
4795
|
-
const showOverlay = (0,
|
|
4794
|
+
const showOverlay = (0, import_react24.useCallback)(() => {
|
|
4796
4795
|
setIsVisible(true);
|
|
4797
4796
|
}, []);
|
|
4798
|
-
(0,
|
|
4797
|
+
(0, import_react24.useEffect)(() => {
|
|
4799
4798
|
var _a;
|
|
4800
4799
|
registerNode(id, {
|
|
4801
4800
|
methods: { sync, showOverlay, hideOverlay },
|
|
@@ -4812,17 +4811,20 @@ var DraggableComponent = ({
|
|
|
4812
4811
|
});
|
|
4813
4812
|
};
|
|
4814
4813
|
}, [id, zoneCompound, index, componentType, sync]);
|
|
4815
|
-
const CustomActionBar = (0,
|
|
4814
|
+
const CustomActionBar = (0, import_react24.useMemo)(
|
|
4816
4815
|
() => overrides.actionBar || DefaultActionBar,
|
|
4817
4816
|
[overrides.actionBar]
|
|
4818
4817
|
);
|
|
4819
|
-
const CustomOverlay = (0,
|
|
4818
|
+
const CustomOverlay = (0, import_react24.useMemo)(
|
|
4820
4819
|
() => overrides.componentOverlay || DefaultOverlay,
|
|
4821
4820
|
[overrides.componentOverlay]
|
|
4822
4821
|
);
|
|
4823
|
-
const onClick = (0,
|
|
4822
|
+
const onClick = (0, import_react24.useCallback)(
|
|
4824
4823
|
(e) => {
|
|
4825
|
-
e.
|
|
4824
|
+
const el = e.target;
|
|
4825
|
+
if (!el.closest("[data-puck-overlay-portal]")) {
|
|
4826
|
+
e.stopPropagation();
|
|
4827
|
+
}
|
|
4826
4828
|
dispatch({
|
|
4827
4829
|
type: "setUi",
|
|
4828
4830
|
ui: {
|
|
@@ -4833,7 +4835,7 @@ var DraggableComponent = ({
|
|
|
4833
4835
|
[index, zoneCompound, id]
|
|
4834
4836
|
);
|
|
4835
4837
|
const appStore = useAppStoreApi();
|
|
4836
|
-
const onSelectParent = (0,
|
|
4838
|
+
const onSelectParent = (0, import_react24.useCallback)(() => {
|
|
4837
4839
|
const { nodes, zones } = appStore.getState().state.indexes;
|
|
4838
4840
|
const node = nodes[id];
|
|
4839
4841
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
|
@@ -4854,26 +4856,26 @@ var DraggableComponent = ({
|
|
|
4854
4856
|
}
|
|
4855
4857
|
});
|
|
4856
4858
|
}, [ctx, path]);
|
|
4857
|
-
const onDuplicate = (0,
|
|
4859
|
+
const onDuplicate = (0, import_react24.useCallback)(() => {
|
|
4858
4860
|
dispatch({
|
|
4859
4861
|
type: "duplicate",
|
|
4860
4862
|
sourceIndex: index,
|
|
4861
4863
|
sourceZone: zoneCompound
|
|
4862
4864
|
});
|
|
4863
4865
|
}, [index, zoneCompound]);
|
|
4864
|
-
const onDelete = (0,
|
|
4866
|
+
const onDelete = (0, import_react24.useCallback)(() => {
|
|
4865
4867
|
dispatch({
|
|
4866
4868
|
type: "remove",
|
|
4867
4869
|
index,
|
|
4868
4870
|
zone: zoneCompound
|
|
4869
4871
|
});
|
|
4870
4872
|
}, [index, zoneCompound]);
|
|
4871
|
-
const [hover, setHover] = (0,
|
|
4873
|
+
const [hover, setHover] = (0, import_react24.useState)(false);
|
|
4872
4874
|
const indicativeHover = useContextStore(
|
|
4873
4875
|
ZoneStoreContext,
|
|
4874
4876
|
(s) => s.hoveringComponent === id
|
|
4875
4877
|
);
|
|
4876
|
-
(0,
|
|
4878
|
+
(0, import_react24.useEffect)(() => {
|
|
4877
4879
|
if (!ref.current) {
|
|
4878
4880
|
return;
|
|
4879
4881
|
}
|
|
@@ -4918,10 +4920,10 @@ var DraggableComponent = ({
|
|
|
4918
4920
|
thisIsDragging,
|
|
4919
4921
|
inDroppableZone
|
|
4920
4922
|
]);
|
|
4921
|
-
const [isVisible, setIsVisible] = (0,
|
|
4922
|
-
const [dragFinished, setDragFinished] = (0,
|
|
4923
|
-
const [_, startTransition] = (0,
|
|
4924
|
-
(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)(() => {
|
|
4925
4927
|
startTransition(() => {
|
|
4926
4928
|
if (hover || indicativeHover || isSelected) {
|
|
4927
4929
|
sync();
|
|
@@ -4932,7 +4934,7 @@ var DraggableComponent = ({
|
|
|
4932
4934
|
}
|
|
4933
4935
|
});
|
|
4934
4936
|
}, [hover, indicativeHover, isSelected, iframe]);
|
|
4935
|
-
const [thisWasDragging, setThisWasDragging] = (0,
|
|
4937
|
+
const [thisWasDragging, setThisWasDragging] = (0, import_react24.useState)(false);
|
|
4936
4938
|
const onDragFinished = useOnDragFinished((finished) => {
|
|
4937
4939
|
if (finished) {
|
|
4938
4940
|
startTransition(() => {
|
|
@@ -4943,15 +4945,15 @@ var DraggableComponent = ({
|
|
|
4943
4945
|
setDragFinished(false);
|
|
4944
4946
|
}
|
|
4945
4947
|
});
|
|
4946
|
-
(0,
|
|
4948
|
+
(0, import_react24.useEffect)(() => {
|
|
4947
4949
|
if (thisIsDragging) {
|
|
4948
4950
|
setThisWasDragging(true);
|
|
4949
4951
|
}
|
|
4950
4952
|
}, [thisIsDragging]);
|
|
4951
|
-
(0,
|
|
4953
|
+
(0, import_react24.useEffect)(() => {
|
|
4952
4954
|
if (thisWasDragging) return onDragFinished();
|
|
4953
4955
|
}, [thisWasDragging, onDragFinished]);
|
|
4954
|
-
const syncActionsPosition = (0,
|
|
4956
|
+
const syncActionsPosition = (0, import_react24.useCallback)(
|
|
4955
4957
|
(el) => {
|
|
4956
4958
|
if (el) {
|
|
4957
4959
|
const view = el.ownerDocument.defaultView;
|
|
@@ -4976,7 +4978,7 @@ var DraggableComponent = ({
|
|
|
4976
4978
|
},
|
|
4977
4979
|
[zoom]
|
|
4978
4980
|
);
|
|
4979
|
-
(0,
|
|
4981
|
+
(0, import_react24.useEffect)(() => {
|
|
4980
4982
|
if (userDragAxis) {
|
|
4981
4983
|
setDragAxis(userDragAxis);
|
|
4982
4984
|
return;
|
|
@@ -4990,11 +4992,11 @@ var DraggableComponent = ({
|
|
|
4990
4992
|
}
|
|
4991
4993
|
setDragAxis(autoDragAxis);
|
|
4992
4994
|
}, [ref, userDragAxis, autoDragAxis]);
|
|
4993
|
-
const parentAction = (0,
|
|
4995
|
+
const parentAction = (0, import_react24.useMemo)(
|
|
4994
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 }) }),
|
|
4995
4997
|
[ctx == null ? void 0 : ctx.areaId]
|
|
4996
4998
|
);
|
|
4997
|
-
const nextContextValue = (0,
|
|
4999
|
+
const nextContextValue = (0, import_react24.useMemo)(
|
|
4998
5000
|
() => __spreadProps(__spreadValues({}, ctx), {
|
|
4999
5001
|
areaId: id,
|
|
5000
5002
|
zoneCompound,
|
|
@@ -5090,7 +5092,7 @@ var import_react35 = require("@dnd-kit/react");
|
|
|
5090
5092
|
|
|
5091
5093
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
5092
5094
|
init_react_import();
|
|
5093
|
-
var
|
|
5095
|
+
var import_react25 = require("react");
|
|
5094
5096
|
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
|
5095
5097
|
var useMinEmptyHeight = ({
|
|
5096
5098
|
zoneCompound,
|
|
@@ -5098,8 +5100,8 @@ var useMinEmptyHeight = ({
|
|
|
5098
5100
|
ref
|
|
5099
5101
|
}) => {
|
|
5100
5102
|
const appStore = useAppStoreApi();
|
|
5101
|
-
const [prevHeight, setPrevHeight] = (0,
|
|
5102
|
-
const [isAnimating, setIsAnimating] = (0,
|
|
5103
|
+
const [prevHeight, setPrevHeight] = (0, import_react25.useState)(0);
|
|
5104
|
+
const [isAnimating, setIsAnimating] = (0, import_react25.useState)(false);
|
|
5103
5105
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
|
5104
5106
|
var _a, _b;
|
|
5105
5107
|
return {
|
|
@@ -5107,7 +5109,7 @@ var useMinEmptyHeight = ({
|
|
|
5107
5109
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
|
5108
5110
|
};
|
|
5109
5111
|
});
|
|
5110
|
-
const numItems = (0,
|
|
5112
|
+
const numItems = (0, import_react25.useRef)(0);
|
|
5111
5113
|
const onDragFinished = useOnDragFinished(
|
|
5112
5114
|
(finished) => {
|
|
5113
5115
|
var _a;
|
|
@@ -5142,7 +5144,7 @@ var useMinEmptyHeight = ({
|
|
|
5142
5144
|
},
|
|
5143
5145
|
[appStore, prevHeight, zoneCompound]
|
|
5144
5146
|
);
|
|
5145
|
-
(0,
|
|
5147
|
+
(0, import_react25.useEffect)(() => {
|
|
5146
5148
|
if (draggedItem && ref.current) {
|
|
5147
5149
|
if (isZone) {
|
|
5148
5150
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -5173,15 +5175,15 @@ function assignRefs(refs, node) {
|
|
|
5173
5175
|
|
|
5174
5176
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5175
5177
|
init_react_import();
|
|
5176
|
-
var
|
|
5178
|
+
var import_react28 = require("react");
|
|
5177
5179
|
|
|
5178
5180
|
// lib/dnd/use-rendered-callback.ts
|
|
5179
5181
|
init_react_import();
|
|
5180
|
-
var
|
|
5181
|
-
var
|
|
5182
|
+
var import_react26 = require("@dnd-kit/react");
|
|
5183
|
+
var import_react27 = require("react");
|
|
5182
5184
|
function useRenderedCallback(callback, deps) {
|
|
5183
|
-
const manager = (0,
|
|
5184
|
-
return (0,
|
|
5185
|
+
const manager = (0, import_react26.useDragDropManager)();
|
|
5186
|
+
return (0, import_react27.useCallback)(
|
|
5185
5187
|
(...args) => __async(this, null, function* () {
|
|
5186
5188
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
|
5187
5189
|
return callback(...args);
|
|
@@ -5192,14 +5194,14 @@ function useRenderedCallback(callback, deps) {
|
|
|
5192
5194
|
|
|
5193
5195
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5194
5196
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
5195
|
-
const zoneStore = (0,
|
|
5197
|
+
const zoneStore = (0, import_react28.useContext)(ZoneStoreContext);
|
|
5196
5198
|
const preview = useContextStore(
|
|
5197
5199
|
ZoneStoreContext,
|
|
5198
5200
|
(s) => s.previewIndex[zoneCompound]
|
|
5199
5201
|
);
|
|
5200
5202
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
|
5201
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
|
5202
|
-
const [localPreview, setLocalPreview] = (0,
|
|
5203
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react28.useState)(contentIds);
|
|
5204
|
+
const [localPreview, setLocalPreview] = (0, import_react28.useState)(
|
|
5203
5205
|
preview
|
|
5204
5206
|
);
|
|
5205
5207
|
const updateContent = useRenderedCallback(
|
|
@@ -5234,7 +5236,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5234
5236
|
},
|
|
5235
5237
|
[]
|
|
5236
5238
|
);
|
|
5237
|
-
(0,
|
|
5239
|
+
(0, import_react28.useEffect)(() => {
|
|
5238
5240
|
var _a;
|
|
5239
5241
|
const s = zoneStore.getState();
|
|
5240
5242
|
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
|
@@ -5252,16 +5254,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5252
5254
|
|
|
5253
5255
|
// components/DropZone/lib/use-drag-axis.ts
|
|
5254
5256
|
init_react_import();
|
|
5255
|
-
var
|
|
5257
|
+
var import_react29 = require("react");
|
|
5256
5258
|
var GRID_DRAG_AXIS = "dynamic";
|
|
5257
5259
|
var FLEX_ROW_DRAG_AXIS = "x";
|
|
5258
5260
|
var DEFAULT_DRAG_AXIS = "y";
|
|
5259
5261
|
var useDragAxis = (ref, collisionAxis) => {
|
|
5260
5262
|
const status = useAppStore((s) => s.status);
|
|
5261
|
-
const [dragAxis, setDragAxis] = (0,
|
|
5263
|
+
const [dragAxis, setDragAxis] = (0, import_react29.useState)(
|
|
5262
5264
|
collisionAxis || DEFAULT_DRAG_AXIS
|
|
5263
5265
|
);
|
|
5264
|
-
const calculateDragAxis = (0,
|
|
5266
|
+
const calculateDragAxis = (0, import_react29.useCallback)(() => {
|
|
5265
5267
|
if (ref.current) {
|
|
5266
5268
|
const computedStyle = window.getComputedStyle(ref.current);
|
|
5267
5269
|
if (computedStyle.display === "grid") {
|
|
@@ -5273,7 +5275,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5273
5275
|
}
|
|
5274
5276
|
}
|
|
5275
5277
|
}, [ref.current]);
|
|
5276
|
-
(0,
|
|
5278
|
+
(0, import_react29.useEffect)(() => {
|
|
5277
5279
|
const onViewportChange = () => {
|
|
5278
5280
|
calculateDragAxis();
|
|
5279
5281
|
};
|
|
@@ -5282,57 +5284,92 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5282
5284
|
window.removeEventListener("viewportchange", onViewportChange);
|
|
5283
5285
|
};
|
|
5284
5286
|
}, []);
|
|
5285
|
-
(0,
|
|
5287
|
+
(0, import_react29.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
|
5286
5288
|
return [dragAxis, calculateDragAxis];
|
|
5287
5289
|
};
|
|
5288
5290
|
|
|
5289
5291
|
// components/DropZone/index.tsx
|
|
5290
|
-
var
|
|
5292
|
+
var import_shallow4 = require("zustand/react/shallow");
|
|
5291
5293
|
|
|
5292
5294
|
// components/Render/index.tsx
|
|
5293
5295
|
init_react_import();
|
|
5294
5296
|
|
|
5295
5297
|
// lib/use-slots.tsx
|
|
5296
5298
|
init_react_import();
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
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;
|
|
5317
5327
|
return mapped;
|
|
5318
|
-
}, [config, item,
|
|
5319
|
-
const mergedProps = (0,
|
|
5320
|
-
() => __spreadValues(__spreadValues({}, item.props),
|
|
5321
|
-
[item.props,
|
|
5328
|
+
}, [config, item, mappers]);
|
|
5329
|
+
const mergedProps = (0, import_react30.useMemo)(
|
|
5330
|
+
() => __spreadValues(__spreadValues({}, item.props), transformedProps),
|
|
5331
|
+
[item.props, transformedProps]
|
|
5322
5332
|
);
|
|
5323
5333
|
return mergedProps;
|
|
5324
5334
|
}
|
|
5325
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
|
+
|
|
5326
5363
|
// components/Render/index.tsx
|
|
5327
|
-
var
|
|
5364
|
+
var import_react32 = __toESM(require("react"));
|
|
5328
5365
|
|
|
5329
5366
|
// components/SlotRender/index.tsx
|
|
5330
5367
|
init_react_import();
|
|
5331
|
-
var
|
|
5368
|
+
var import_shallow3 = require("zustand/react/shallow");
|
|
5332
5369
|
|
|
5333
5370
|
// components/SlotRender/server.tsx
|
|
5334
5371
|
init_react_import();
|
|
5335
|
-
var
|
|
5372
|
+
var import_react31 = require("react");
|
|
5336
5373
|
|
|
5337
5374
|
// components/ServerRender/index.tsx
|
|
5338
5375
|
init_react_import();
|
|
@@ -5401,7 +5438,7 @@ var Item = ({
|
|
|
5401
5438
|
})
|
|
5402
5439
|
);
|
|
5403
5440
|
};
|
|
5404
|
-
var SlotRender = (0,
|
|
5441
|
+
var SlotRender = (0, import_react31.forwardRef)(
|
|
5405
5442
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5406
5443
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5407
5444
|
if (!config.components[item.type]) {
|
|
@@ -5429,7 +5466,7 @@ var ContextSlotRender = ({
|
|
|
5429
5466
|
const config = useAppStore((s) => s.config);
|
|
5430
5467
|
const metadata = useAppStore((s) => s.metadata);
|
|
5431
5468
|
const slotContent = useAppStore(
|
|
5432
|
-
(0,
|
|
5469
|
+
(0, import_shallow3.useShallow)((s) => {
|
|
5433
5470
|
var _a, _b;
|
|
5434
5471
|
const indexes = s.state.indexes;
|
|
5435
5472
|
const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
|
|
@@ -5449,7 +5486,7 @@ var ContextSlotRender = ({
|
|
|
5449
5486
|
|
|
5450
5487
|
// components/Render/index.tsx
|
|
5451
5488
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
5452
|
-
var renderContext =
|
|
5489
|
+
var renderContext = import_react32.default.createContext({
|
|
5453
5490
|
config: { components: {} },
|
|
5454
5491
|
data: { root: {}, content: [] },
|
|
5455
5492
|
metadata: {}
|
|
@@ -5482,7 +5519,7 @@ function Render({
|
|
|
5482
5519
|
{ type: "root", props: pageProps },
|
|
5483
5520
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
|
5484
5521
|
);
|
|
5485
|
-
const nextContextValue = (0,
|
|
5522
|
+
const nextContextValue = (0, import_react32.useMemo)(
|
|
5486
5523
|
() => ({
|
|
5487
5524
|
mode: "render",
|
|
5488
5525
|
depth: 0
|
|
@@ -5495,12 +5532,239 @@ function Render({
|
|
|
5495
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 }) }) });
|
|
5496
5533
|
}
|
|
5497
5534
|
|
|
5498
|
-
//
|
|
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
|
+
// components/InlineTextField/index.tsx
|
|
5499
5629
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
5500
|
-
var getClassName17 = get_class_name_factory_default("
|
|
5630
|
+
var getClassName17 = get_class_name_factory_default("InlineTextField", styles_module_default13);
|
|
5631
|
+
var InlineTextFieldInternal = ({
|
|
5632
|
+
propPath,
|
|
5633
|
+
componentId,
|
|
5634
|
+
value,
|
|
5635
|
+
isReadOnly,
|
|
5636
|
+
opts = {}
|
|
5637
|
+
}) => {
|
|
5638
|
+
var _a;
|
|
5639
|
+
const ref = (0, import_react33.useRef)(null);
|
|
5640
|
+
const appStoreApi = useAppStoreApi();
|
|
5641
|
+
const disableLineBreaks = (_a = opts.disableLineBreaks) != null ? _a : false;
|
|
5642
|
+
(0, import_react33.useEffect)(() => {
|
|
5643
|
+
const appStore = appStoreApi.getState();
|
|
5644
|
+
const data = appStore.state.indexes.nodes[componentId].data;
|
|
5645
|
+
const componentConfig = appStore.getComponentConfig(data.type);
|
|
5646
|
+
if (!componentConfig) {
|
|
5647
|
+
throw new Error(
|
|
5648
|
+
`InlineTextField Error: No config defined for ${data.type}`
|
|
5649
|
+
);
|
|
5650
|
+
}
|
|
5651
|
+
if (ref.current) {
|
|
5652
|
+
if (value !== ref.current.innerText) {
|
|
5653
|
+
ref.current.replaceChildren(value);
|
|
5654
|
+
}
|
|
5655
|
+
const cleanupPortal = registerOverlayPortal(ref.current);
|
|
5656
|
+
const handleInput = (e) => __async(void 0, null, function* () {
|
|
5657
|
+
var _a2;
|
|
5658
|
+
const appStore2 = appStoreApi.getState();
|
|
5659
|
+
const node = appStore2.state.indexes.nodes[componentId];
|
|
5660
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
5661
|
+
const index = (_a2 = appStore2.state.indexes.zones[zoneCompound]) == null ? void 0 : _a2.contentIds.indexOf(
|
|
5662
|
+
componentId
|
|
5663
|
+
);
|
|
5664
|
+
const newProps = setDeep(node.data.props, propPath, e.target.innerText);
|
|
5665
|
+
const resolvedData = yield appStore2.resolveComponentData(
|
|
5666
|
+
__spreadProps(__spreadValues({}, node.data), { props: newProps }),
|
|
5667
|
+
"replace"
|
|
5668
|
+
);
|
|
5669
|
+
appStore2.dispatch({
|
|
5670
|
+
type: "replace",
|
|
5671
|
+
data: resolvedData.node,
|
|
5672
|
+
destinationIndex: index,
|
|
5673
|
+
destinationZone: zoneCompound
|
|
5674
|
+
});
|
|
5675
|
+
});
|
|
5676
|
+
ref.current.addEventListener("input", handleInput);
|
|
5677
|
+
return () => {
|
|
5678
|
+
var _a2;
|
|
5679
|
+
(_a2 = ref.current) == null ? void 0 : _a2.removeEventListener("input", handleInput);
|
|
5680
|
+
cleanupPortal == null ? void 0 : cleanupPortal();
|
|
5681
|
+
};
|
|
5682
|
+
}
|
|
5683
|
+
}, [appStoreApi, ref.current, value]);
|
|
5684
|
+
const [isHovering, setIsHovering] = (0, import_react33.useState)(false);
|
|
5685
|
+
const [isFocused, setIsFocused] = (0, import_react33.useState)(false);
|
|
5686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5687
|
+
"span",
|
|
5688
|
+
{
|
|
5689
|
+
className: getClassName17(),
|
|
5690
|
+
ref,
|
|
5691
|
+
contentEditable: isHovering || isFocused ? "plaintext-only" : "false",
|
|
5692
|
+
onClick: (e) => {
|
|
5693
|
+
e.preventDefault();
|
|
5694
|
+
e.stopPropagation();
|
|
5695
|
+
},
|
|
5696
|
+
onClickCapture: (e) => {
|
|
5697
|
+
e.preventDefault();
|
|
5698
|
+
e.stopPropagation();
|
|
5699
|
+
},
|
|
5700
|
+
onKeyDown: (e) => {
|
|
5701
|
+
if (disableLineBreaks && e.key === "Enter" || isReadOnly) {
|
|
5702
|
+
e.preventDefault();
|
|
5703
|
+
}
|
|
5704
|
+
},
|
|
5705
|
+
onMouseOverCapture: () => setIsHovering(true),
|
|
5706
|
+
onMouseOutCapture: () => setIsHovering(false),
|
|
5707
|
+
onFocus: () => setIsFocused(true),
|
|
5708
|
+
onBlur: () => setIsFocused(false)
|
|
5709
|
+
}
|
|
5710
|
+
);
|
|
5711
|
+
};
|
|
5712
|
+
var InlineTextField = (0, import_react33.memo)(InlineTextFieldInternal);
|
|
5713
|
+
|
|
5714
|
+
// lib/field-transforms/default-transforms/inline-text-transform.tsx
|
|
5715
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
5716
|
+
var getInlineTextTransform = () => ({
|
|
5717
|
+
text: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5718
|
+
if (field.contentEditable) {
|
|
5719
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5720
|
+
InlineTextField,
|
|
5721
|
+
{
|
|
5722
|
+
propPath,
|
|
5723
|
+
componentId,
|
|
5724
|
+
value,
|
|
5725
|
+
opts: { disableLineBreaks: true },
|
|
5726
|
+
isReadOnly
|
|
5727
|
+
}
|
|
5728
|
+
);
|
|
5729
|
+
}
|
|
5730
|
+
return value;
|
|
5731
|
+
},
|
|
5732
|
+
textarea: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5733
|
+
if (field.contentEditable) {
|
|
5734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5735
|
+
InlineTextField,
|
|
5736
|
+
{
|
|
5737
|
+
propPath,
|
|
5738
|
+
componentId,
|
|
5739
|
+
value,
|
|
5740
|
+
isReadOnly
|
|
5741
|
+
}
|
|
5742
|
+
);
|
|
5743
|
+
}
|
|
5744
|
+
return value;
|
|
5745
|
+
},
|
|
5746
|
+
custom: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5747
|
+
if (field.contentEditable && typeof value === "string") {
|
|
5748
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5749
|
+
InlineTextField,
|
|
5750
|
+
{
|
|
5751
|
+
propPath,
|
|
5752
|
+
componentId,
|
|
5753
|
+
value,
|
|
5754
|
+
isReadOnly
|
|
5755
|
+
}
|
|
5756
|
+
);
|
|
5757
|
+
}
|
|
5758
|
+
return value;
|
|
5759
|
+
}
|
|
5760
|
+
});
|
|
5761
|
+
|
|
5762
|
+
// components/DropZone/index.tsx
|
|
5763
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
5764
|
+
var getClassName18 = get_class_name_factory_default("DropZone", styles_module_default12);
|
|
5501
5765
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
|
5502
5766
|
var RENDER_DEBUG = false;
|
|
5503
|
-
var DropZoneEditPure = (props) => /* @__PURE__ */ (0,
|
|
5767
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneEdit, __spreadValues({}, props));
|
|
5504
5768
|
var DropZoneChild = ({
|
|
5505
5769
|
zoneCompound,
|
|
5506
5770
|
componentId,
|
|
@@ -5515,7 +5779,7 @@ var DropZoneChild = ({
|
|
|
5515
5779
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
5516
5780
|
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
5517
5781
|
const nodeProps = useAppStore(
|
|
5518
|
-
(0,
|
|
5782
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5519
5783
|
var _a2;
|
|
5520
5784
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
|
|
5521
5785
|
})
|
|
@@ -5527,7 +5791,7 @@ var DropZoneChild = ({
|
|
|
5527
5791
|
}
|
|
5528
5792
|
);
|
|
5529
5793
|
const nodeReadOnly = useAppStore(
|
|
5530
|
-
(0,
|
|
5794
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5531
5795
|
var _a2;
|
|
5532
5796
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
|
5533
5797
|
})
|
|
@@ -5584,10 +5848,10 @@ var DropZoneChild = ({
|
|
|
5584
5848
|
if (item && "element" in item && item.element) {
|
|
5585
5849
|
return (
|
|
5586
5850
|
// Safe to use this since the HTML is set by the user
|
|
5587
|
-
/* @__PURE__ */ (0,
|
|
5851
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
5588
5852
|
);
|
|
5589
5853
|
}
|
|
5590
|
-
return /* @__PURE__ */ (0,
|
|
5854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name: label, children: (_a2 = overrides.componentItem) != null ? _a2 : overrides.drawerItem });
|
|
5591
5855
|
},
|
|
5592
5856
|
[componentId, label, overrides]
|
|
5593
5857
|
);
|
|
@@ -5607,16 +5871,24 @@ var DropZoneChild = ({
|
|
|
5607
5871
|
[item == null ? void 0 : item.type, nodeType, defaultsProps]
|
|
5608
5872
|
);
|
|
5609
5873
|
const config = useAppStore((s) => s.config);
|
|
5610
|
-
const
|
|
5874
|
+
const plugins = useAppStore((s) => s.plugins);
|
|
5875
|
+
const userFieldTransforms = useAppStore((s) => s.fieldTransforms);
|
|
5876
|
+
const combinedFieldTransforms = (0, import_react34.useMemo)(
|
|
5877
|
+
() => __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, getSlotTransform(DropZoneEditPure, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }))), getInlineTextTransform()), plugins.reduce(
|
|
5878
|
+
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
5879
|
+
{}
|
|
5880
|
+
)), userFieldTransforms),
|
|
5881
|
+
[plugins, userFieldTransforms]
|
|
5882
|
+
);
|
|
5883
|
+
const transformedProps = useFieldTransforms(
|
|
5611
5884
|
config,
|
|
5612
5885
|
defaultedNode,
|
|
5613
|
-
|
|
5614
|
-
(slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
|
5886
|
+
combinedFieldTransforms,
|
|
5615
5887
|
nodeReadOnly,
|
|
5616
5888
|
isLoading
|
|
5617
5889
|
);
|
|
5618
5890
|
if (!item) return;
|
|
5619
|
-
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0,
|
|
5891
|
+
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
|
5620
5892
|
"No configuration for ",
|
|
5621
5893
|
item.type
|
|
5622
5894
|
] });
|
|
@@ -5625,7 +5897,7 @@ var DropZoneChild = ({
|
|
|
5625
5897
|
if (isInserting) {
|
|
5626
5898
|
Render2 = renderPreview;
|
|
5627
5899
|
}
|
|
5628
|
-
return /* @__PURE__ */ (0,
|
|
5900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5629
5901
|
DraggableComponent,
|
|
5630
5902
|
{
|
|
5631
5903
|
id: componentId,
|
|
@@ -5639,14 +5911,14 @@ var DropZoneChild = ({
|
|
|
5639
5911
|
autoDragAxis: dragAxis,
|
|
5640
5912
|
userDragAxis: collisionAxis,
|
|
5641
5913
|
inDroppableZone,
|
|
5642
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0,
|
|
5914
|
+
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)(
|
|
5643
5915
|
Render2,
|
|
5644
|
-
__spreadProps(__spreadValues({},
|
|
5645
|
-
puck: __spreadProps(__spreadValues({},
|
|
5916
|
+
__spreadProps(__spreadValues({}, transformedProps), {
|
|
5917
|
+
puck: __spreadProps(__spreadValues({}, transformedProps.puck), {
|
|
5646
5918
|
dragRef
|
|
5647
5919
|
})
|
|
5648
5920
|
})
|
|
5649
|
-
) }) : /* @__PURE__ */ (0,
|
|
5921
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Render2, __spreadValues({}, transformedProps)) })
|
|
5650
5922
|
}
|
|
5651
5923
|
);
|
|
5652
5924
|
};
|
|
@@ -5671,7 +5943,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
5671
5943
|
unregisterLocalZone
|
|
5672
5944
|
} = ctx != null ? ctx : {};
|
|
5673
5945
|
const path = useAppStore(
|
|
5674
|
-
(0,
|
|
5946
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5675
5947
|
var _a;
|
|
5676
5948
|
return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
|
|
5677
5949
|
})
|
|
@@ -5688,13 +5960,13 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
5688
5960
|
(s) => s.nextAreaDepthIndex[areaId || ""]
|
|
5689
5961
|
);
|
|
5690
5962
|
const zoneContentIds = useAppStore(
|
|
5691
|
-
(0,
|
|
5963
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5692
5964
|
var _a;
|
|
5693
5965
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
|
|
5694
5966
|
})
|
|
5695
5967
|
);
|
|
5696
5968
|
const zoneType = useAppStore(
|
|
5697
|
-
(0,
|
|
5969
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5698
5970
|
var _a;
|
|
5699
5971
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
5700
5972
|
})
|
|
@@ -5802,10 +6074,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
5802
6074
|
userMinEmptyHeight,
|
|
5803
6075
|
ref
|
|
5804
6076
|
});
|
|
5805
|
-
return /* @__PURE__ */ (0,
|
|
6077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5806
6078
|
"div",
|
|
5807
6079
|
{
|
|
5808
|
-
className: `${
|
|
6080
|
+
className: `${getClassName18({
|
|
5809
6081
|
isRootZone,
|
|
5810
6082
|
hoveringOverArea,
|
|
5811
6083
|
isEnabled,
|
|
@@ -5823,7 +6095,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
5823
6095
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
|
5824
6096
|
}),
|
|
5825
6097
|
children: contentIdsWithPreview.map((componentId, i) => {
|
|
5826
|
-
return /* @__PURE__ */ (0,
|
|
6098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5827
6099
|
DropZoneChildMemo,
|
|
5828
6100
|
{
|
|
5829
6101
|
zoneCompound,
|
|
@@ -5846,7 +6118,7 @@ var DropZoneRenderItem = ({
|
|
|
5846
6118
|
metadata
|
|
5847
6119
|
}) => {
|
|
5848
6120
|
const Component = config.components[item.type];
|
|
5849
|
-
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0,
|
|
6121
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5850
6122
|
const nextContextValue = (0, import_react34.useMemo)(
|
|
5851
6123
|
() => ({
|
|
5852
6124
|
areaId: props.id,
|
|
@@ -5854,7 +6126,7 @@ var DropZoneRenderItem = ({
|
|
|
5854
6126
|
}),
|
|
5855
6127
|
[props]
|
|
5856
6128
|
);
|
|
5857
|
-
return /* @__PURE__ */ (0,
|
|
6129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5858
6130
|
Component.render,
|
|
5859
6131
|
__spreadProps(__spreadValues({}, props), {
|
|
5860
6132
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
@@ -5864,7 +6136,7 @@ var DropZoneRenderItem = ({
|
|
|
5864
6136
|
})
|
|
5865
6137
|
) }, props.id);
|
|
5866
6138
|
};
|
|
5867
|
-
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0,
|
|
6139
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneRender2, __spreadValues({}, props));
|
|
5868
6140
|
var DropZoneRender2 = (0, import_react34.forwardRef)(
|
|
5869
6141
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
5870
6142
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
@@ -5885,10 +6157,10 @@ var DropZoneRender2 = (0, import_react34.forwardRef)(
|
|
|
5885
6157
|
if (zoneCompound !== rootDroppableId) {
|
|
5886
6158
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
5887
6159
|
}
|
|
5888
|
-
return /* @__PURE__ */ (0,
|
|
6160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5889
6161
|
const Component = config.components[item.type];
|
|
5890
6162
|
if (Component) {
|
|
5891
|
-
return /* @__PURE__ */ (0,
|
|
6163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5892
6164
|
DropZoneRenderItem,
|
|
5893
6165
|
{
|
|
5894
6166
|
config,
|
|
@@ -5902,14 +6174,14 @@ var DropZoneRender2 = (0, import_react34.forwardRef)(
|
|
|
5902
6174
|
}) });
|
|
5903
6175
|
}
|
|
5904
6176
|
);
|
|
5905
|
-
var DropZonePure = (props) => /* @__PURE__ */ (0,
|
|
6177
|
+
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZone, __spreadValues({}, props));
|
|
5906
6178
|
var DropZone = (0, import_react34.forwardRef)(
|
|
5907
6179
|
function DropZone2(props, ref) {
|
|
5908
6180
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5909
6181
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
5910
|
-
return /* @__PURE__ */ (0,
|
|
6182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
5911
6183
|
}
|
|
5912
|
-
return /* @__PURE__ */ (0,
|
|
6184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneRender2, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
5913
6185
|
}
|
|
5914
6186
|
);
|
|
5915
6187
|
|
|
@@ -6245,7 +6517,7 @@ function getDeepDir(el) {
|
|
|
6245
6517
|
|
|
6246
6518
|
// components/DragDropContext/index.tsx
|
|
6247
6519
|
var import_state = require("@dnd-kit/state");
|
|
6248
|
-
var
|
|
6520
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
6249
6521
|
var DEBUG3 = false;
|
|
6250
6522
|
var dragListenerContext = (0, import_react37.createContext)({
|
|
6251
6523
|
dragListeners: {}
|
|
@@ -6414,14 +6686,14 @@ var DragDropContextClient = ({
|
|
|
6414
6686
|
}),
|
|
6415
6687
|
[]
|
|
6416
6688
|
);
|
|
6417
|
-
return /* @__PURE__ */ (0,
|
|
6689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6418
6690
|
dragListenerContext.Provider,
|
|
6419
6691
|
{
|
|
6420
6692
|
value: {
|
|
6421
6693
|
dragListeners,
|
|
6422
6694
|
setDragListeners
|
|
6423
6695
|
},
|
|
6424
|
-
children: /* @__PURE__ */ (0,
|
|
6696
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6425
6697
|
import_react36.DragDropProvider,
|
|
6426
6698
|
{
|
|
6427
6699
|
plugins,
|
|
@@ -6637,7 +6909,7 @@ var DragDropContextClient = ({
|
|
|
6637
6909
|
const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
|
|
6638
6910
|
entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
|
|
6639
6911
|
},
|
|
6640
|
-
children: /* @__PURE__ */ (0,
|
|
6912
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
|
|
6641
6913
|
}
|
|
6642
6914
|
)
|
|
6643
6915
|
}
|
|
@@ -6651,13 +6923,13 @@ var DragDropContext = ({
|
|
|
6651
6923
|
if (status === "LOADING") {
|
|
6652
6924
|
return children;
|
|
6653
6925
|
}
|
|
6654
|
-
return /* @__PURE__ */ (0,
|
|
6926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
|
6655
6927
|
};
|
|
6656
6928
|
|
|
6657
6929
|
// components/Drawer/index.tsx
|
|
6658
6930
|
var import_react39 = require("@dnd-kit/react");
|
|
6659
|
-
var
|
|
6660
|
-
var
|
|
6931
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
6932
|
+
var getClassName19 = get_class_name_factory_default("Drawer", styles_module_default10);
|
|
6661
6933
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
|
6662
6934
|
var DrawerItemInner = ({
|
|
6663
6935
|
children,
|
|
@@ -6667,10 +6939,10 @@ var DrawerItemInner = ({
|
|
|
6667
6939
|
isDragDisabled
|
|
6668
6940
|
}) => {
|
|
6669
6941
|
const CustomInner = (0, import_react38.useMemo)(
|
|
6670
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
|
6942
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
|
6671
6943
|
[children]
|
|
6672
6944
|
);
|
|
6673
|
-
return /* @__PURE__ */ (0,
|
|
6945
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6674
6946
|
"div",
|
|
6675
6947
|
{
|
|
6676
6948
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
|
@@ -6678,9 +6950,9 @@ var DrawerItemInner = ({
|
|
|
6678
6950
|
onMouseDown: (e) => e.preventDefault(),
|
|
6679
6951
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
|
6680
6952
|
"data-puck-drawer-item": true,
|
|
6681
|
-
children: /* @__PURE__ */ (0,
|
|
6682
|
-
/* @__PURE__ */ (0,
|
|
6683
|
-
/* @__PURE__ */ (0,
|
|
6953
|
+
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: [
|
|
6954
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
|
6955
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DragIcon, {}) })
|
|
6684
6956
|
] }) }) })
|
|
6685
6957
|
}
|
|
6686
6958
|
);
|
|
@@ -6698,9 +6970,9 @@ var DrawerItemDraggable = ({
|
|
|
6698
6970
|
disabled: isDragDisabled,
|
|
6699
6971
|
type: "drawer"
|
|
6700
6972
|
});
|
|
6701
|
-
return /* @__PURE__ */ (0,
|
|
6702
|
-
/* @__PURE__ */ (0,
|
|
6703
|
-
/* @__PURE__ */ (0,
|
|
6973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName19("draggable"), children: [
|
|
6974
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName19("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DrawerItemInner, { name, label, children }) }),
|
|
6975
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName19("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6704
6976
|
DrawerItemInner,
|
|
6705
6977
|
{
|
|
6706
6978
|
name,
|
|
@@ -6734,7 +7006,7 @@ var DrawerItem = ({
|
|
|
6734
7006
|
},
|
|
6735
7007
|
[resolvedId]
|
|
6736
7008
|
);
|
|
6737
|
-
return /* @__PURE__ */ (0,
|
|
7009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6738
7010
|
DrawerItemDraggable,
|
|
6739
7011
|
{
|
|
6740
7012
|
name,
|
|
@@ -6767,10 +7039,10 @@ var Drawer = ({
|
|
|
6767
7039
|
collisionPriority: 0
|
|
6768
7040
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
|
6769
7041
|
});
|
|
6770
|
-
return /* @__PURE__ */ (0,
|
|
7042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6771
7043
|
"div",
|
|
6772
7044
|
{
|
|
6773
|
-
className:
|
|
7045
|
+
className: getClassName19(),
|
|
6774
7046
|
ref,
|
|
6775
7047
|
"data-puck-dnd": id,
|
|
6776
7048
|
"data-puck-drawer": true,
|
|
@@ -6790,7 +7062,7 @@ init_react_import();
|
|
|
6790
7062
|
|
|
6791
7063
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
6792
7064
|
init_react_import();
|
|
6793
|
-
var
|
|
7065
|
+
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" };
|
|
6794
7066
|
|
|
6795
7067
|
// lib/use-breadcrumbs.ts
|
|
6796
7068
|
init_react_import();
|
|
@@ -6837,8 +7109,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6837
7109
|
};
|
|
6838
7110
|
|
|
6839
7111
|
// components/SidebarSection/index.tsx
|
|
6840
|
-
var
|
|
6841
|
-
var
|
|
7112
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
7113
|
+
var getClassName20 = get_class_name_factory_default("SidebarSection", styles_module_default14);
|
|
6842
7114
|
var SidebarSection = ({
|
|
6843
7115
|
children,
|
|
6844
7116
|
title,
|
|
@@ -6850,29 +7122,29 @@ var SidebarSection = ({
|
|
|
6850
7122
|
}) => {
|
|
6851
7123
|
const setUi = useAppStore((s) => s.setUi);
|
|
6852
7124
|
const breadcrumbs = useBreadcrumbs(1);
|
|
6853
|
-
return /* @__PURE__ */ (0,
|
|
7125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
6854
7126
|
"div",
|
|
6855
7127
|
{
|
|
6856
|
-
className:
|
|
7128
|
+
className: getClassName20({ noBorderTop, noPadding }),
|
|
6857
7129
|
style: { background },
|
|
6858
7130
|
children: [
|
|
6859
|
-
/* @__PURE__ */ (0,
|
|
6860
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
|
6861
|
-
/* @__PURE__ */ (0,
|
|
7131
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName20("title"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName20("breadcrumbs"), children: [
|
|
7132
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName20("breadcrumb"), children: [
|
|
7133
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
6862
7134
|
"button",
|
|
6863
7135
|
{
|
|
6864
7136
|
type: "button",
|
|
6865
|
-
className:
|
|
7137
|
+
className: getClassName20("breadcrumbLabel"),
|
|
6866
7138
|
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
|
6867
7139
|
children: breadcrumb.label
|
|
6868
7140
|
}
|
|
6869
7141
|
),
|
|
6870
|
-
/* @__PURE__ */ (0,
|
|
7142
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronRight, { size: 16 })
|
|
6871
7143
|
] }, i)) : null,
|
|
6872
|
-
/* @__PURE__ */ (0,
|
|
7144
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName20("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
|
6873
7145
|
] }) }),
|
|
6874
|
-
/* @__PURE__ */ (0,
|
|
6875
|
-
isLoading && /* @__PURE__ */ (0,
|
|
7146
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName20("content"), children }),
|
|
7147
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Loader, { size: 32 }) })
|
|
6876
7148
|
]
|
|
6877
7149
|
}
|
|
6878
7150
|
);
|
|
@@ -6880,24 +7152,24 @@ var SidebarSection = ({
|
|
|
6880
7152
|
|
|
6881
7153
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
|
6882
7154
|
init_react_import();
|
|
6883
|
-
var
|
|
7155
|
+
var styles_module_default15 = { "Puck": "_Puck_vnhjy_19", "Puck-portal": "_Puck-portal_vnhjy_31", "PuckLayout-inner": "_PuckLayout-inner_vnhjy_38", "PuckLayout--mounted": "_PuckLayout--mounted_vnhjy_50", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_vnhjy_54", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_vnhjy_60", "PuckLayout-mounted": "_PuckLayout-mounted_vnhjy_74", "PuckLayout": "_PuckLayout_vnhjy_38" };
|
|
6884
7156
|
|
|
6885
7157
|
// components/Puck/components/Fields/index.tsx
|
|
6886
7158
|
init_react_import();
|
|
6887
7159
|
|
|
6888
7160
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
|
6889
7161
|
init_react_import();
|
|
6890
|
-
var
|
|
7162
|
+
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" };
|
|
6891
7163
|
|
|
6892
7164
|
// components/Puck/components/Fields/index.tsx
|
|
6893
7165
|
var import_react41 = require("react");
|
|
6894
|
-
var
|
|
6895
|
-
var
|
|
6896
|
-
var
|
|
7166
|
+
var import_shallow5 = require("zustand/react/shallow");
|
|
7167
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
7168
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
|
6897
7169
|
var DefaultFields = ({
|
|
6898
7170
|
children
|
|
6899
7171
|
}) => {
|
|
6900
|
-
return /* @__PURE__ */ (0,
|
|
7172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
|
6901
7173
|
};
|
|
6902
7174
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
|
6903
7175
|
let currentProps;
|
|
@@ -6957,7 +7229,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6957
7229
|
return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
|
|
6958
7230
|
});
|
|
6959
7231
|
const permissions = useAppStore(
|
|
6960
|
-
(0,
|
|
7232
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
6961
7233
|
const { selectedItem, permissions: permissions2 } = s;
|
|
6962
7234
|
return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
|
|
6963
7235
|
})
|
|
@@ -6969,7 +7241,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6969
7241
|
const { visible = true } = field != null ? field : {};
|
|
6970
7242
|
if (!field || !id || !visible) return null;
|
|
6971
7243
|
if (field.type === "slot") return null;
|
|
6972
|
-
return /* @__PURE__ */ (0,
|
|
7244
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6973
7245
|
AutoFieldPrivate,
|
|
6974
7246
|
{
|
|
6975
7247
|
field,
|
|
@@ -6989,7 +7261,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6989
7261
|
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;
|
|
6990
7262
|
return (loadingCount != null ? loadingCount : 0) > 0;
|
|
6991
7263
|
});
|
|
6992
|
-
const itemSelector = useAppStore((0,
|
|
7264
|
+
const itemSelector = useAppStore((0, import_shallow5.useShallow)((s) => s.state.ui.itemSelector));
|
|
6993
7265
|
const id = useAppStore((s) => {
|
|
6994
7266
|
var _a;
|
|
6995
7267
|
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
@@ -6998,7 +7270,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6998
7270
|
useRegisterFieldsSlice(appStore, id);
|
|
6999
7271
|
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
|
7000
7272
|
const fieldNames = useAppStore(
|
|
7001
|
-
(0,
|
|
7273
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
7002
7274
|
if (s.fields.id === id) {
|
|
7003
7275
|
return Object.keys(s.fields.fields);
|
|
7004
7276
|
}
|
|
@@ -7007,16 +7279,16 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
7007
7279
|
);
|
|
7008
7280
|
const isLoading = fieldsLoading || componentResolving;
|
|
7009
7281
|
const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
7010
|
-
return /* @__PURE__ */ (0,
|
|
7282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
7011
7283
|
"form",
|
|
7012
7284
|
{
|
|
7013
|
-
className:
|
|
7285
|
+
className: getClassName21({ wrapFields }),
|
|
7014
7286
|
onSubmit: (e) => {
|
|
7015
7287
|
e.preventDefault();
|
|
7016
7288
|
},
|
|
7017
7289
|
children: [
|
|
7018
|
-
/* @__PURE__ */ (0,
|
|
7019
|
-
isLoading && /* @__PURE__ */ (0,
|
|
7290
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
|
|
7291
|
+
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 }) }) })
|
|
7020
7292
|
]
|
|
7021
7293
|
}
|
|
7022
7294
|
);
|
|
@@ -7035,12 +7307,12 @@ init_react_import();
|
|
|
7035
7307
|
|
|
7036
7308
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
|
7037
7309
|
init_react_import();
|
|
7038
|
-
var
|
|
7310
|
+
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" };
|
|
7039
7311
|
|
|
7040
7312
|
// components/ComponentList/index.tsx
|
|
7041
7313
|
var import_react42 = require("react");
|
|
7042
|
-
var
|
|
7043
|
-
var
|
|
7314
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
7315
|
+
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
|
7044
7316
|
var ComponentListItem = ({
|
|
7045
7317
|
name,
|
|
7046
7318
|
label
|
|
@@ -7059,7 +7331,7 @@ var ComponentListItem = ({
|
|
|
7059
7331
|
);
|
|
7060
7332
|
}
|
|
7061
7333
|
}, [overrides]);
|
|
7062
|
-
return /* @__PURE__ */ (0,
|
|
7334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
|
|
7063
7335
|
};
|
|
7064
7336
|
var ComponentList = ({
|
|
7065
7337
|
children,
|
|
@@ -7070,12 +7342,12 @@ var ComponentList = ({
|
|
|
7070
7342
|
const setUi = useAppStore((s) => s.setUi);
|
|
7071
7343
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
|
7072
7344
|
const { expanded = true } = componentList[id] || {};
|
|
7073
|
-
return /* @__PURE__ */ (0,
|
|
7074
|
-
title && /* @__PURE__ */ (0,
|
|
7345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
|
7346
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
7075
7347
|
"button",
|
|
7076
7348
|
{
|
|
7077
7349
|
type: "button",
|
|
7078
|
-
className:
|
|
7350
|
+
className: getClassName22("title"),
|
|
7079
7351
|
onClick: () => setUi({
|
|
7080
7352
|
componentList: __spreadProps(__spreadValues({}, componentList), {
|
|
7081
7353
|
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
|
@@ -7085,14 +7357,14 @@ var ComponentList = ({
|
|
|
7085
7357
|
}),
|
|
7086
7358
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
|
7087
7359
|
children: [
|
|
7088
|
-
/* @__PURE__ */ (0,
|
|
7089
|
-
/* @__PURE__ */ (0,
|
|
7360
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { children: title }),
|
|
7361
|
+
/* @__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 }) })
|
|
7090
7362
|
]
|
|
7091
7363
|
}
|
|
7092
7364
|
),
|
|
7093
|
-
/* @__PURE__ */ (0,
|
|
7365
|
+
/* @__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) => {
|
|
7094
7366
|
var _a;
|
|
7095
|
-
return /* @__PURE__ */ (0,
|
|
7367
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
7096
7368
|
ComponentListItem,
|
|
7097
7369
|
{
|
|
7098
7370
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
|
@@ -7106,7 +7378,7 @@ var ComponentList = ({
|
|
|
7106
7378
|
ComponentList.Item = ComponentListItem;
|
|
7107
7379
|
|
|
7108
7380
|
// lib/use-component-list.tsx
|
|
7109
|
-
var
|
|
7381
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
7110
7382
|
var useComponentList = () => {
|
|
7111
7383
|
const [componentList, setComponentList] = (0, import_react43.useState)();
|
|
7112
7384
|
const config = useAppStore((s) => s.config);
|
|
@@ -7121,7 +7393,7 @@ var useComponentList = () => {
|
|
|
7121
7393
|
if (category.visible === false || !category.components) {
|
|
7122
7394
|
return null;
|
|
7123
7395
|
}
|
|
7124
|
-
return /* @__PURE__ */ (0,
|
|
7396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7125
7397
|
ComponentList,
|
|
7126
7398
|
{
|
|
7127
7399
|
id: categoryKey,
|
|
@@ -7130,7 +7402,7 @@ var useComponentList = () => {
|
|
|
7130
7402
|
var _a2;
|
|
7131
7403
|
matchedComponents.push(componentName);
|
|
7132
7404
|
const componentConf = config.components[componentName] || {};
|
|
7133
|
-
return /* @__PURE__ */ (0,
|
|
7405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7134
7406
|
ComponentList.Item,
|
|
7135
7407
|
{
|
|
7136
7408
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
|
@@ -7150,7 +7422,7 @@ var useComponentList = () => {
|
|
|
7150
7422
|
);
|
|
7151
7423
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
|
7152
7424
|
_componentList.push(
|
|
7153
|
-
/* @__PURE__ */ (0,
|
|
7425
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7154
7426
|
ComponentList,
|
|
7155
7427
|
{
|
|
7156
7428
|
id: "other",
|
|
@@ -7158,7 +7430,7 @@ var useComponentList = () => {
|
|
|
7158
7430
|
children: remainingComponents.map((componentName, i) => {
|
|
7159
7431
|
var _a2;
|
|
7160
7432
|
const componentConf = config.components[componentName] || {};
|
|
7161
|
-
return /* @__PURE__ */ (0,
|
|
7433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7162
7434
|
ComponentList.Item,
|
|
7163
7435
|
{
|
|
7164
7436
|
name: componentName,
|
|
@@ -7181,7 +7453,7 @@ var useComponentList = () => {
|
|
|
7181
7453
|
|
|
7182
7454
|
// components/Puck/components/Components/index.tsx
|
|
7183
7455
|
var import_react44 = require("react");
|
|
7184
|
-
var
|
|
7456
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
7185
7457
|
var Components = () => {
|
|
7186
7458
|
const overrides = useAppStore((s) => s.overrides);
|
|
7187
7459
|
const componentList = useComponentList();
|
|
@@ -7193,7 +7465,7 @@ var Components = () => {
|
|
|
7193
7465
|
}
|
|
7194
7466
|
return overrides.components || overrides.drawer || "div";
|
|
7195
7467
|
}, [overrides]);
|
|
7196
|
-
return /* @__PURE__ */ (0,
|
|
7468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComponentList, { id: "all" }) });
|
|
7197
7469
|
};
|
|
7198
7470
|
|
|
7199
7471
|
// components/Puck/components/Preview/index.tsx
|
|
@@ -7205,7 +7477,7 @@ init_react_import();
|
|
|
7205
7477
|
var import_react45 = require("react");
|
|
7206
7478
|
var import_object_hash = __toESM(require("object-hash"));
|
|
7207
7479
|
var import_react_dom3 = require("react-dom");
|
|
7208
|
-
var
|
|
7480
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
7209
7481
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
|
7210
7482
|
var collectStyles = (doc) => {
|
|
7211
7483
|
const collected = [];
|
|
@@ -7412,7 +7684,7 @@ var CopyHostStyles = ({
|
|
|
7412
7684
|
observer.disconnect();
|
|
7413
7685
|
};
|
|
7414
7686
|
}, []);
|
|
7415
|
-
return /* @__PURE__ */ (0,
|
|
7687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children });
|
|
7416
7688
|
};
|
|
7417
7689
|
var autoFrameContext = (0, import_react45.createContext)({});
|
|
7418
7690
|
var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
|
|
@@ -7459,7 +7731,7 @@ function AutoFrame(_a) {
|
|
|
7459
7731
|
}
|
|
7460
7732
|
}
|
|
7461
7733
|
}, [frameRef, loaded, stylesLoaded]);
|
|
7462
|
-
return /* @__PURE__ */ (0,
|
|
7734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7463
7735
|
"iframe",
|
|
7464
7736
|
__spreadProps(__spreadValues({}, props), {
|
|
7465
7737
|
className,
|
|
@@ -7469,7 +7741,7 @@ function AutoFrame(_a) {
|
|
|
7469
7741
|
onLoad: () => {
|
|
7470
7742
|
setLoaded(true);
|
|
7471
7743
|
},
|
|
7472
|
-
children: /* @__PURE__ */ (0,
|
|
7744
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7473
7745
|
CopyHostStyles,
|
|
7474
7746
|
{
|
|
7475
7747
|
debug,
|
|
@@ -7485,11 +7757,11 @@ var AutoFrame_default = AutoFrame;
|
|
|
7485
7757
|
|
|
7486
7758
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
|
7487
7759
|
init_react_import();
|
|
7488
|
-
var
|
|
7760
|
+
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
|
7489
7761
|
|
|
7490
7762
|
// components/Puck/components/Preview/index.tsx
|
|
7491
|
-
var
|
|
7492
|
-
var
|
|
7763
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7764
|
+
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
|
7493
7765
|
var useBubbleIframeEvents = (ref) => {
|
|
7494
7766
|
const status = useAppStore((s) => s.status);
|
|
7495
7767
|
(0, import_react46.useEffect)(() => {
|
|
@@ -7551,7 +7823,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7551
7823
|
);
|
|
7552
7824
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
7553
7825
|
id: "puck-root"
|
|
7554
|
-
}, propsWithSlots)) : /* @__PURE__ */ (0,
|
|
7826
|
+
}, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children: propsWithSlots.children });
|
|
7555
7827
|
},
|
|
7556
7828
|
[config]
|
|
7557
7829
|
);
|
|
@@ -7559,7 +7831,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7559
7831
|
const rootProps = root.props || root;
|
|
7560
7832
|
const ref = (0, import_react46.useRef)(null);
|
|
7561
7833
|
useBubbleIframeEvents(ref);
|
|
7562
|
-
const inner = !renderData ? /* @__PURE__ */ (0,
|
|
7834
|
+
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7563
7835
|
Page,
|
|
7564
7836
|
__spreadProps(__spreadValues({}, rootProps), {
|
|
7565
7837
|
puck: {
|
|
@@ -7569,28 +7841,31 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7569
7841
|
metadata
|
|
7570
7842
|
},
|
|
7571
7843
|
editMode: true,
|
|
7572
|
-
children: /* @__PURE__ */ (0,
|
|
7844
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7573
7845
|
})
|
|
7574
|
-
) : /* @__PURE__ */ (0,
|
|
7846
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Render, { data: renderData, config, metadata });
|
|
7575
7847
|
(0, import_react46.useEffect)(() => {
|
|
7576
7848
|
if (!iframe.enabled) {
|
|
7577
7849
|
setStatus("READY");
|
|
7578
7850
|
}
|
|
7579
7851
|
}, [iframe.enabled]);
|
|
7580
|
-
return /* @__PURE__ */ (0,
|
|
7852
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7581
7853
|
"div",
|
|
7582
7854
|
{
|
|
7583
|
-
className:
|
|
7855
|
+
className: getClassName23(),
|
|
7584
7856
|
id,
|
|
7585
7857
|
"data-puck-preview": true,
|
|
7586
|
-
onClick: () => {
|
|
7587
|
-
|
|
7858
|
+
onClick: (e) => {
|
|
7859
|
+
const el = e.target;
|
|
7860
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
7861
|
+
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
|
7862
|
+
}
|
|
7588
7863
|
},
|
|
7589
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
|
7864
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7590
7865
|
AutoFrame_default,
|
|
7591
7866
|
{
|
|
7592
7867
|
id: "preview-frame",
|
|
7593
|
-
className:
|
|
7868
|
+
className: getClassName23("frame"),
|
|
7594
7869
|
"data-rfd-iframe": true,
|
|
7595
7870
|
onReady: () => {
|
|
7596
7871
|
setStatus("READY");
|
|
@@ -7599,18 +7874,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7599
7874
|
setStatus("MOUNTED");
|
|
7600
7875
|
},
|
|
7601
7876
|
frameRef: ref,
|
|
7602
|
-
children: /* @__PURE__ */ (0,
|
|
7877
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
|
7603
7878
|
if (Frame) {
|
|
7604
|
-
return /* @__PURE__ */ (0,
|
|
7879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Frame, { document: document2, children: inner });
|
|
7605
7880
|
}
|
|
7606
7881
|
return inner;
|
|
7607
7882
|
} })
|
|
7608
7883
|
}
|
|
7609
|
-
) : /* @__PURE__ */ (0,
|
|
7884
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7610
7885
|
"div",
|
|
7611
7886
|
{
|
|
7612
7887
|
id: "preview-frame",
|
|
7613
|
-
className:
|
|
7888
|
+
className: getClassName23("frame"),
|
|
7614
7889
|
ref,
|
|
7615
7890
|
"data-puck-entry": true,
|
|
7616
7891
|
children: inner
|
|
@@ -7628,7 +7903,7 @@ init_react_import();
|
|
|
7628
7903
|
|
|
7629
7904
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
|
7630
7905
|
init_react_import();
|
|
7631
|
-
var
|
|
7906
|
+
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" };
|
|
7632
7907
|
|
|
7633
7908
|
// lib/scroll-into-view.ts
|
|
7634
7909
|
init_react_import();
|
|
@@ -7664,10 +7939,10 @@ var onScrollEnd = (frame, cb) => {
|
|
|
7664
7939
|
};
|
|
7665
7940
|
|
|
7666
7941
|
// components/LayerTree/index.tsx
|
|
7667
|
-
var
|
|
7668
|
-
var
|
|
7669
|
-
var
|
|
7670
|
-
var getClassNameLayer = get_class_name_factory_default("Layer",
|
|
7942
|
+
var import_shallow6 = require("zustand/react/shallow");
|
|
7943
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
7944
|
+
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
|
7945
|
+
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
|
7671
7946
|
var Layer = ({
|
|
7672
7947
|
index,
|
|
7673
7948
|
itemId,
|
|
@@ -7690,7 +7965,7 @@ var Layer = ({
|
|
|
7690
7965
|
const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
|
|
7691
7966
|
const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
|
|
7692
7967
|
const zonesForItem = useAppStore(
|
|
7693
|
-
(0,
|
|
7968
|
+
(0, import_shallow6.useShallow)(
|
|
7694
7969
|
(s) => Object.keys(s.state.indexes.zones).filter(
|
|
7695
7970
|
(z) => z.split(":")[0] === itemId
|
|
7696
7971
|
)
|
|
@@ -7712,7 +7987,7 @@ var Layer = ({
|
|
|
7712
7987
|
});
|
|
7713
7988
|
const componentConfig = config.components[nodeData.data.type];
|
|
7714
7989
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
|
7715
|
-
return /* @__PURE__ */ (0,
|
|
7990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
7716
7991
|
"li",
|
|
7717
7992
|
{
|
|
7718
7993
|
className: getClassNameLayer({
|
|
@@ -7722,7 +7997,7 @@ var Layer = ({
|
|
|
7722
7997
|
childIsSelected
|
|
7723
7998
|
}),
|
|
7724
7999
|
children: [
|
|
7725
|
-
/* @__PURE__ */ (0,
|
|
8000
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
7726
8001
|
"button",
|
|
7727
8002
|
{
|
|
7728
8003
|
type: "button",
|
|
@@ -7760,22 +8035,22 @@ var Layer = ({
|
|
|
7760
8035
|
zoneStore.setState({ hoveringComponent: null });
|
|
7761
8036
|
},
|
|
7762
8037
|
children: [
|
|
7763
|
-
containsZone && /* @__PURE__ */ (0,
|
|
8038
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
7764
8039
|
"div",
|
|
7765
8040
|
{
|
|
7766
8041
|
className: getClassNameLayer("chevron"),
|
|
7767
8042
|
title: isSelected ? "Collapse" : "Expand",
|
|
7768
|
-
children: /* @__PURE__ */ (0,
|
|
8043
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ChevronDown, { size: "12" })
|
|
7769
8044
|
}
|
|
7770
8045
|
),
|
|
7771
|
-
/* @__PURE__ */ (0,
|
|
7772
|
-
/* @__PURE__ */ (0,
|
|
7773
|
-
/* @__PURE__ */ (0,
|
|
8046
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
|
8047
|
+
/* @__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" }) }),
|
|
8048
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassNameLayer("name"), children: label })
|
|
7774
8049
|
] })
|
|
7775
8050
|
]
|
|
7776
8051
|
}
|
|
7777
8052
|
) }),
|
|
7778
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0,
|
|
8053
|
+
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))
|
|
7779
8054
|
]
|
|
7780
8055
|
}
|
|
7781
8056
|
);
|
|
@@ -7794,22 +8069,22 @@ var LayerTree = ({
|
|
|
7794
8069
|
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7795
8070
|
});
|
|
7796
8071
|
const contentIds = useAppStore(
|
|
7797
|
-
(0,
|
|
8072
|
+
(0, import_shallow6.useShallow)(
|
|
7798
8073
|
(s) => {
|
|
7799
8074
|
var _a, _b;
|
|
7800
8075
|
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
7801
8076
|
}
|
|
7802
8077
|
)
|
|
7803
8078
|
);
|
|
7804
|
-
return /* @__PURE__ */ (0,
|
|
7805
|
-
label && /* @__PURE__ */ (0,
|
|
7806
|
-
/* @__PURE__ */ (0,
|
|
8079
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
|
|
8080
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
|
8081
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Layers, { size: "16" }) }),
|
|
7807
8082
|
label
|
|
7808
8083
|
] }),
|
|
7809
|
-
/* @__PURE__ */ (0,
|
|
7810
|
-
contentIds.length === 0 && /* @__PURE__ */ (0,
|
|
8084
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("ul", { className: getClassName24(), children: [
|
|
8085
|
+
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
|
7811
8086
|
contentIds.map((itemId, i) => {
|
|
7812
|
-
return /* @__PURE__ */ (0,
|
|
8087
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
7813
8088
|
Layer,
|
|
7814
8089
|
{
|
|
7815
8090
|
index: i,
|
|
@@ -7835,15 +8110,15 @@ var findZonesForArea = (state, area) => {
|
|
|
7835
8110
|
};
|
|
7836
8111
|
|
|
7837
8112
|
// components/Puck/components/Outline/index.tsx
|
|
7838
|
-
var
|
|
7839
|
-
var
|
|
8113
|
+
var import_shallow7 = require("zustand/react/shallow");
|
|
8114
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
7840
8115
|
var Outline = () => {
|
|
7841
8116
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
7842
8117
|
const rootZones = useAppStore(
|
|
7843
|
-
(0,
|
|
8118
|
+
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7844
8119
|
);
|
|
7845
8120
|
const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7846
|
-
return /* @__PURE__ */ (0,
|
|
8121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
7847
8122
|
LayerTree,
|
|
7848
8123
|
{
|
|
7849
8124
|
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
@@ -7863,17 +8138,17 @@ var import_react49 = require("react");
|
|
|
7863
8138
|
|
|
7864
8139
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
7865
8140
|
init_react_import();
|
|
7866
|
-
var
|
|
8141
|
+
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" };
|
|
7867
8142
|
|
|
7868
8143
|
// components/ViewportControls/index.tsx
|
|
7869
|
-
var
|
|
8144
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
7870
8145
|
var icons = {
|
|
7871
|
-
Smartphone: /* @__PURE__ */ (0,
|
|
7872
|
-
Tablet: /* @__PURE__ */ (0,
|
|
7873
|
-
Monitor: /* @__PURE__ */ (0,
|
|
8146
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Smartphone, { size: 16 }),
|
|
8147
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Tablet, { size: 16 }),
|
|
8148
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Monitor, { size: 16 })
|
|
7874
8149
|
};
|
|
7875
|
-
var
|
|
7876
|
-
var getClassNameButton = get_class_name_factory_default("ViewportButton",
|
|
8150
|
+
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
|
8151
|
+
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
|
7877
8152
|
var ViewportButton = ({
|
|
7878
8153
|
children,
|
|
7879
8154
|
height = "auto",
|
|
@@ -7886,7 +8161,7 @@ var ViewportButton = ({
|
|
|
7886
8161
|
(0, import_react49.useEffect)(() => {
|
|
7887
8162
|
setIsActive(width === viewports.current.width);
|
|
7888
8163
|
}, [width, viewports.current.width]);
|
|
7889
|
-
return /* @__PURE__ */ (0,
|
|
8164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7890
8165
|
IconButton,
|
|
7891
8166
|
{
|
|
7892
8167
|
type: "button",
|
|
@@ -7896,7 +8171,7 @@ var ViewportButton = ({
|
|
|
7896
8171
|
e.stopPropagation();
|
|
7897
8172
|
onClick({ width, height });
|
|
7898
8173
|
},
|
|
7899
|
-
children: /* @__PURE__ */ (0,
|
|
8174
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: getClassNameButton("inner"), children })
|
|
7900
8175
|
}
|
|
7901
8176
|
) });
|
|
7902
8177
|
};
|
|
@@ -7932,8 +8207,8 @@ var ViewportControls = ({
|
|
|
7932
8207
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
|
7933
8208
|
[autoZoom]
|
|
7934
8209
|
);
|
|
7935
|
-
return /* @__PURE__ */ (0,
|
|
7936
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
|
8210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName25(), children: [
|
|
8211
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7937
8212
|
ViewportButton,
|
|
7938
8213
|
{
|
|
7939
8214
|
height: viewport.height,
|
|
@@ -7944,8 +8219,8 @@ var ViewportControls = ({
|
|
|
7944
8219
|
},
|
|
7945
8220
|
i
|
|
7946
8221
|
)),
|
|
7947
|
-
/* @__PURE__ */ (0,
|
|
7948
|
-
/* @__PURE__ */ (0,
|
|
8222
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("divider") }),
|
|
8223
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7949
8224
|
IconButton,
|
|
7950
8225
|
{
|
|
7951
8226
|
type: "button",
|
|
@@ -7960,10 +8235,10 @@ var ViewportControls = ({
|
|
|
7960
8235
|
)].value
|
|
7961
8236
|
);
|
|
7962
8237
|
},
|
|
7963
|
-
children: /* @__PURE__ */ (0,
|
|
8238
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ZoomOut, { size: 16 })
|
|
7964
8239
|
}
|
|
7965
8240
|
),
|
|
7966
|
-
/* @__PURE__ */ (0,
|
|
8241
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7967
8242
|
IconButton,
|
|
7968
8243
|
{
|
|
7969
8244
|
type: "button",
|
|
@@ -7978,19 +8253,19 @@ var ViewportControls = ({
|
|
|
7978
8253
|
)].value
|
|
7979
8254
|
);
|
|
7980
8255
|
},
|
|
7981
|
-
children: /* @__PURE__ */ (0,
|
|
8256
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ZoomIn, { size: 16 })
|
|
7982
8257
|
}
|
|
7983
8258
|
),
|
|
7984
|
-
/* @__PURE__ */ (0,
|
|
7985
|
-
/* @__PURE__ */ (0,
|
|
8259
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("divider") }),
|
|
8260
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7986
8261
|
"select",
|
|
7987
8262
|
{
|
|
7988
|
-
className:
|
|
8263
|
+
className: getClassName25("zoomSelect"),
|
|
7989
8264
|
value: zoom.toString(),
|
|
7990
8265
|
onChange: (e) => {
|
|
7991
8266
|
onZoom(parseFloat(e.currentTarget.value));
|
|
7992
8267
|
},
|
|
7993
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
|
8268
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7994
8269
|
"option",
|
|
7995
8270
|
{
|
|
7996
8271
|
value: option.value,
|
|
@@ -8005,15 +8280,15 @@ var ViewportControls = ({
|
|
|
8005
8280
|
|
|
8006
8281
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
8007
8282
|
init_react_import();
|
|
8008
|
-
var
|
|
8283
|
+
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" };
|
|
8009
8284
|
|
|
8010
8285
|
// components/Puck/components/Canvas/index.tsx
|
|
8011
|
-
var
|
|
8286
|
+
var import_shallow8 = require("zustand/react/shallow");
|
|
8012
8287
|
|
|
8013
8288
|
// lib/frame-context.tsx
|
|
8014
8289
|
init_react_import();
|
|
8015
8290
|
var import_react50 = require("react");
|
|
8016
|
-
var
|
|
8291
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
8017
8292
|
var FrameContext = (0, import_react50.createContext)(null);
|
|
8018
8293
|
var FrameProvider = ({
|
|
8019
8294
|
children
|
|
@@ -8025,7 +8300,7 @@ var FrameProvider = ({
|
|
|
8025
8300
|
}),
|
|
8026
8301
|
[]
|
|
8027
8302
|
);
|
|
8028
|
-
return /* @__PURE__ */ (0,
|
|
8303
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(FrameContext.Provider, { value, children });
|
|
8029
8304
|
};
|
|
8030
8305
|
var useCanvasFrame = () => {
|
|
8031
8306
|
const context = (0, import_react50.useContext)(FrameContext);
|
|
@@ -8036,9 +8311,10 @@ var useCanvasFrame = () => {
|
|
|
8036
8311
|
};
|
|
8037
8312
|
|
|
8038
8313
|
// components/Puck/components/Canvas/index.tsx
|
|
8039
|
-
var
|
|
8040
|
-
var
|
|
8314
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
8315
|
+
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
|
8041
8316
|
var ZOOM_ON_CHANGE = true;
|
|
8317
|
+
var TRANSITION_DURATION = 150;
|
|
8042
8318
|
var Canvas = () => {
|
|
8043
8319
|
const { frameRef } = useCanvasFrame();
|
|
8044
8320
|
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
@@ -8051,7 +8327,7 @@ var Canvas = () => {
|
|
|
8051
8327
|
status,
|
|
8052
8328
|
iframe
|
|
8053
8329
|
} = useAppStore(
|
|
8054
|
-
(0,
|
|
8330
|
+
(0, import_shallow8.useShallow)((s) => ({
|
|
8055
8331
|
dispatch: s.dispatch,
|
|
8056
8332
|
overrides: s.overrides,
|
|
8057
8333
|
setUi: s.setUi,
|
|
@@ -8068,7 +8344,7 @@ var Canvas = () => {
|
|
|
8068
8344
|
rightSideBarWidth,
|
|
8069
8345
|
viewports
|
|
8070
8346
|
} = useAppStore(
|
|
8071
|
-
(0,
|
|
8347
|
+
(0, import_shallow8.useShallow)((s) => ({
|
|
8072
8348
|
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
8073
8349
|
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
8074
8350
|
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
@@ -8077,9 +8353,9 @@ var Canvas = () => {
|
|
|
8077
8353
|
}))
|
|
8078
8354
|
);
|
|
8079
8355
|
const [showTransition, setShowTransition] = (0, import_react51.useState)(false);
|
|
8080
|
-
const
|
|
8356
|
+
const isResizingRef = (0, import_react51.useRef)(false);
|
|
8081
8357
|
const defaultRender = (0, import_react51.useMemo)(() => {
|
|
8082
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
|
8358
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children });
|
|
8083
8359
|
return PuckDefault;
|
|
8084
8360
|
}, []);
|
|
8085
8361
|
const CustomPreview = (0, import_react51.useMemo)(
|
|
@@ -8095,19 +8371,13 @@ var Canvas = () => {
|
|
|
8095
8371
|
return { width: 0, height: 0 };
|
|
8096
8372
|
}, [frameRef]);
|
|
8097
8373
|
(0, import_react51.useEffect)(() => {
|
|
8098
|
-
resetAutoZoom(
|
|
8099
|
-
isResettingRef: isResettingZoomRef,
|
|
8100
|
-
setShowTransition,
|
|
8101
|
-
showTransition: false,
|
|
8102
|
-
viewports
|
|
8103
|
-
});
|
|
8374
|
+
resetAutoZoom();
|
|
8104
8375
|
}, [
|
|
8105
8376
|
frameRef,
|
|
8106
8377
|
leftSideBarVisible,
|
|
8107
8378
|
rightSideBarVisible,
|
|
8108
8379
|
leftSideBarWidth,
|
|
8109
8380
|
rightSideBarWidth,
|
|
8110
|
-
resetAutoZoom,
|
|
8111
8381
|
viewports
|
|
8112
8382
|
]);
|
|
8113
8383
|
(0, import_react51.useEffect)(() => {
|
|
@@ -8120,53 +8390,53 @@ var Canvas = () => {
|
|
|
8120
8390
|
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
8121
8391
|
(0, import_react51.useEffect)(() => {
|
|
8122
8392
|
if (ZOOM_ON_CHANGE) {
|
|
8123
|
-
resetAutoZoom(
|
|
8124
|
-
isResettingRef: isResettingZoomRef,
|
|
8125
|
-
setShowTransition,
|
|
8126
|
-
showTransition: true,
|
|
8127
|
-
viewports
|
|
8128
|
-
});
|
|
8393
|
+
resetAutoZoom();
|
|
8129
8394
|
}
|
|
8130
|
-
}, [viewports.current.width,
|
|
8395
|
+
}, [viewports.current.width, viewports]);
|
|
8131
8396
|
(0, import_react51.useEffect)(() => {
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
window.addEventListener("resize", cb);
|
|
8397
|
+
if (!frameRef.current) return;
|
|
8398
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
8399
|
+
if (!isResizingRef.current) {
|
|
8400
|
+
resetAutoZoom();
|
|
8401
|
+
}
|
|
8402
|
+
});
|
|
8403
|
+
resizeObserver.observe(frameRef.current);
|
|
8140
8404
|
return () => {
|
|
8141
|
-
|
|
8405
|
+
resizeObserver.disconnect();
|
|
8142
8406
|
};
|
|
8143
|
-
}, [
|
|
8407
|
+
}, [frameRef.current]);
|
|
8144
8408
|
const [showLoader, setShowLoader] = (0, import_react51.useState)(false);
|
|
8145
8409
|
(0, import_react51.useEffect)(() => {
|
|
8146
8410
|
setTimeout(() => {
|
|
8147
8411
|
setShowLoader(true);
|
|
8148
8412
|
}, 500);
|
|
8149
8413
|
}, []);
|
|
8150
|
-
return /* @__PURE__ */ (0,
|
|
8414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
8151
8415
|
"div",
|
|
8152
8416
|
{
|
|
8153
|
-
className:
|
|
8417
|
+
className: getClassName26({
|
|
8154
8418
|
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
|
8155
8419
|
showLoader
|
|
8156
8420
|
}),
|
|
8157
|
-
onClick: () =>
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8421
|
+
onClick: (e) => {
|
|
8422
|
+
const el = e.target;
|
|
8423
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
8424
|
+
dispatch({
|
|
8425
|
+
type: "setUi",
|
|
8426
|
+
ui: { itemSelector: null },
|
|
8427
|
+
recordHistory: true
|
|
8428
|
+
});
|
|
8429
|
+
}
|
|
8430
|
+
},
|
|
8162
8431
|
children: [
|
|
8163
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
|
8432
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8164
8433
|
ViewportControls,
|
|
8165
8434
|
{
|
|
8166
8435
|
autoZoom: zoomConfig.autoZoom,
|
|
8167
8436
|
zoom: zoomConfig.zoom,
|
|
8168
8437
|
onViewportChange: (viewport) => {
|
|
8169
8438
|
setShowTransition(true);
|
|
8439
|
+
isResizingRef.current = true;
|
|
8170
8440
|
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
|
8171
8441
|
height: viewport.height || "auto",
|
|
8172
8442
|
zoom: zoomConfig.zoom
|
|
@@ -8178,42 +8448,39 @@ var Canvas = () => {
|
|
|
8178
8448
|
setUi(newUi);
|
|
8179
8449
|
if (ZOOM_ON_CHANGE) {
|
|
8180
8450
|
resetAutoZoom({
|
|
8181
|
-
isResettingRef: isResettingZoomRef,
|
|
8182
|
-
setShowTransition,
|
|
8183
|
-
showTransition: true,
|
|
8184
8451
|
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
8185
8452
|
});
|
|
8186
8453
|
}
|
|
8187
8454
|
},
|
|
8188
8455
|
onZoom: (zoom) => {
|
|
8189
8456
|
setShowTransition(true);
|
|
8457
|
+
isResizingRef.current = true;
|
|
8190
8458
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
|
8191
8459
|
}
|
|
8192
8460
|
}
|
|
8193
8461
|
) }),
|
|
8194
|
-
/* @__PURE__ */ (0,
|
|
8195
|
-
/* @__PURE__ */ (0,
|
|
8462
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
|
8463
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8196
8464
|
"div",
|
|
8197
8465
|
{
|
|
8198
|
-
className:
|
|
8466
|
+
className: getClassName26("root"),
|
|
8199
8467
|
style: {
|
|
8200
8468
|
width: iframe.enabled ? viewports.current.width : "100%",
|
|
8201
8469
|
height: zoomConfig.rootHeight,
|
|
8202
8470
|
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
|
8203
|
-
transition: showTransition ?
|
|
8471
|
+
transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, height ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : "",
|
|
8204
8472
|
overflow: iframe.enabled ? void 0 : "auto"
|
|
8205
8473
|
},
|
|
8206
8474
|
suppressHydrationWarning: true,
|
|
8207
8475
|
id: "puck-canvas-root",
|
|
8208
8476
|
onTransitionEnd: () => {
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
});
|
|
8477
|
+
setShowTransition(false);
|
|
8478
|
+
isResizingRef.current = false;
|
|
8212
8479
|
},
|
|
8213
|
-
children: /* @__PURE__ */ (0,
|
|
8480
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Preview2, {}) })
|
|
8214
8481
|
}
|
|
8215
8482
|
),
|
|
8216
|
-
/* @__PURE__ */ (0,
|
|
8483
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Loader, { size: 24 }) })
|
|
8217
8484
|
] })
|
|
8218
8485
|
]
|
|
8219
8486
|
}
|
|
@@ -8232,8 +8499,11 @@ var loadOverrides = ({
|
|
|
8232
8499
|
}) => {
|
|
8233
8500
|
const collected = __spreadValues({}, overrides);
|
|
8234
8501
|
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
8502
|
+
if (!plugin.overrides) return;
|
|
8235
8503
|
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
|
8504
|
+
var _a;
|
|
8236
8505
|
const overridesType = _overridesType;
|
|
8506
|
+
if (!((_a = plugin.overrides) == null ? void 0 : _a[overridesType])) return;
|
|
8237
8507
|
if (overridesType === "fieldTypes") {
|
|
8238
8508
|
const fieldTypes = plugin.overrides.fieldTypes;
|
|
8239
8509
|
Object.keys(fieldTypes).forEach((fieldType) => {
|
|
@@ -8268,8 +8538,8 @@ var useLoadedOverrides = ({
|
|
|
8268
8538
|
|
|
8269
8539
|
// components/DefaultOverride/index.tsx
|
|
8270
8540
|
init_react_import();
|
|
8271
|
-
var
|
|
8272
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
|
8541
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
8542
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children });
|
|
8273
8543
|
|
|
8274
8544
|
// lib/use-inject-css.ts
|
|
8275
8545
|
init_react_import();
|
|
@@ -8421,11 +8691,11 @@ init_react_import();
|
|
|
8421
8691
|
|
|
8422
8692
|
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
|
8423
8693
|
init_react_import();
|
|
8424
|
-
var
|
|
8694
|
+
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" };
|
|
8425
8695
|
|
|
8426
8696
|
// components/MenuBar/index.tsx
|
|
8427
|
-
var
|
|
8428
|
-
var
|
|
8697
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
8698
|
+
var getClassName27 = get_class_name_factory_default("MenuBar", styles_module_default22);
|
|
8429
8699
|
function MenuBar({
|
|
8430
8700
|
menuOpen = false,
|
|
8431
8701
|
renderHeaderActions,
|
|
@@ -8435,10 +8705,10 @@ function MenuBar({
|
|
|
8435
8705
|
const forward = useAppStore((s) => s.history.forward);
|
|
8436
8706
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
8437
8707
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
8438
|
-
return /* @__PURE__ */ (0,
|
|
8708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8439
8709
|
"div",
|
|
8440
8710
|
{
|
|
8441
|
-
className:
|
|
8711
|
+
className: getClassName27({ menuOpen }),
|
|
8442
8712
|
onClick: (event) => {
|
|
8443
8713
|
var _a;
|
|
8444
8714
|
const element = event.target;
|
|
@@ -8449,30 +8719,30 @@ function MenuBar({
|
|
|
8449
8719
|
setMenuOpen(false);
|
|
8450
8720
|
}
|
|
8451
8721
|
},
|
|
8452
|
-
children: /* @__PURE__ */ (0,
|
|
8453
|
-
/* @__PURE__ */ (0,
|
|
8454
|
-
/* @__PURE__ */ (0,
|
|
8722
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName27("inner"), children: [
|
|
8723
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName27("history"), children: [
|
|
8724
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8455
8725
|
IconButton,
|
|
8456
8726
|
{
|
|
8457
8727
|
type: "button",
|
|
8458
8728
|
title: "undo",
|
|
8459
8729
|
disabled: !hasPast,
|
|
8460
8730
|
onClick: back,
|
|
8461
|
-
children: /* @__PURE__ */ (0,
|
|
8731
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Undo2, { size: 21 })
|
|
8462
8732
|
}
|
|
8463
8733
|
),
|
|
8464
|
-
/* @__PURE__ */ (0,
|
|
8734
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8465
8735
|
IconButton,
|
|
8466
8736
|
{
|
|
8467
8737
|
type: "button",
|
|
8468
8738
|
title: "redo",
|
|
8469
8739
|
disabled: !hasFuture,
|
|
8470
8740
|
onClick: forward,
|
|
8471
|
-
children: /* @__PURE__ */ (0,
|
|
8741
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Redo2, { size: 21 })
|
|
8472
8742
|
}
|
|
8473
8743
|
)
|
|
8474
8744
|
] }),
|
|
8475
|
-
/* @__PURE__ */ (0,
|
|
8745
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_jsx_runtime43.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
|
8476
8746
|
] })
|
|
8477
8747
|
}
|
|
8478
8748
|
);
|
|
@@ -8480,11 +8750,11 @@ function MenuBar({
|
|
|
8480
8750
|
|
|
8481
8751
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
|
8482
8752
|
init_react_import();
|
|
8483
|
-
var
|
|
8753
|
+
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" };
|
|
8484
8754
|
|
|
8485
8755
|
// components/Puck/components/Header/index.tsx
|
|
8486
|
-
var
|
|
8487
|
-
var
|
|
8756
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8757
|
+
var getClassName28 = get_class_name_factory_default("PuckHeader", styles_module_default23);
|
|
8488
8758
|
var HeaderInner = () => {
|
|
8489
8759
|
const {
|
|
8490
8760
|
onPublish,
|
|
@@ -8505,7 +8775,7 @@ var HeaderInner = () => {
|
|
|
8505
8775
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
8506
8776
|
const Comp = renderHeader;
|
|
8507
8777
|
const appState = useAppStore((s) => s.state);
|
|
8508
|
-
return /* @__PURE__ */ (0,
|
|
8778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
8509
8779
|
};
|
|
8510
8780
|
return RenderHeader;
|
|
8511
8781
|
}
|
|
@@ -8519,12 +8789,12 @@ var HeaderInner = () => {
|
|
|
8519
8789
|
const RenderHeader = (props) => {
|
|
8520
8790
|
const Comp = renderHeaderActions;
|
|
8521
8791
|
const appState = useAppStore((s) => s.state);
|
|
8522
|
-
return /* @__PURE__ */ (0,
|
|
8792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
8523
8793
|
};
|
|
8524
8794
|
return RenderHeader;
|
|
8525
8795
|
}
|
|
8526
8796
|
return DefaultOverride;
|
|
8527
|
-
}, [
|
|
8797
|
+
}, [renderHeaderActions]);
|
|
8528
8798
|
const CustomHeader = useAppStore(
|
|
8529
8799
|
(s) => s.overrides.header || defaultHeaderRender
|
|
8530
8800
|
);
|
|
@@ -8555,27 +8825,27 @@ var HeaderInner = () => {
|
|
|
8555
8825
|
},
|
|
8556
8826
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
8557
8827
|
);
|
|
8558
|
-
return /* @__PURE__ */ (0,
|
|
8828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8559
8829
|
CustomHeader,
|
|
8560
8830
|
{
|
|
8561
|
-
actions: /* @__PURE__ */ (0,
|
|
8831
|
+
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)(
|
|
8562
8832
|
Button,
|
|
8563
8833
|
{
|
|
8564
8834
|
onClick: () => {
|
|
8565
8835
|
const data = appStore.getState().state.data;
|
|
8566
8836
|
onPublish && onPublish(data);
|
|
8567
8837
|
},
|
|
8568
|
-
icon: /* @__PURE__ */ (0,
|
|
8838
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Globe, { size: "14px" }),
|
|
8569
8839
|
children: "Publish"
|
|
8570
8840
|
}
|
|
8571
8841
|
) }) }),
|
|
8572
|
-
children: /* @__PURE__ */ (0,
|
|
8842
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8573
8843
|
"header",
|
|
8574
8844
|
{
|
|
8575
|
-
className:
|
|
8576
|
-
children: /* @__PURE__ */ (0,
|
|
8577
|
-
/* @__PURE__ */ (0,
|
|
8578
|
-
/* @__PURE__ */ (0,
|
|
8845
|
+
className: getClassName28({ leftSideBarVisible, rightSideBarVisible }),
|
|
8846
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: getClassName28("inner"), children: [
|
|
8847
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: getClassName28("toggle"), children: [
|
|
8848
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName28("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8579
8849
|
IconButton,
|
|
8580
8850
|
{
|
|
8581
8851
|
type: "button",
|
|
@@ -8583,10 +8853,10 @@ var HeaderInner = () => {
|
|
|
8583
8853
|
toggleSidebars("left");
|
|
8584
8854
|
},
|
|
8585
8855
|
title: "Toggle left sidebar",
|
|
8586
|
-
children: /* @__PURE__ */ (0,
|
|
8856
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PanelLeft, { focusable: "false" })
|
|
8587
8857
|
}
|
|
8588
8858
|
) }),
|
|
8589
|
-
/* @__PURE__ */ (0,
|
|
8859
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName28("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8590
8860
|
IconButton,
|
|
8591
8861
|
{
|
|
8592
8862
|
type: "button",
|
|
@@ -8594,19 +8864,19 @@ var HeaderInner = () => {
|
|
|
8594
8864
|
toggleSidebars("right");
|
|
8595
8865
|
},
|
|
8596
8866
|
title: "Toggle right sidebar",
|
|
8597
|
-
children: /* @__PURE__ */ (0,
|
|
8867
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PanelRight, { focusable: "false" })
|
|
8598
8868
|
}
|
|
8599
8869
|
) })
|
|
8600
8870
|
] }),
|
|
8601
|
-
/* @__PURE__ */ (0,
|
|
8871
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName28("title"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
|
8602
8872
|
headerTitle || rootTitle || "Page",
|
|
8603
|
-
headerPath && /* @__PURE__ */ (0,
|
|
8873
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
|
|
8604
8874
|
" ",
|
|
8605
|
-
/* @__PURE__ */ (0,
|
|
8875
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("code", { className: getClassName28("path"), children: headerPath })
|
|
8606
8876
|
] })
|
|
8607
8877
|
] }) }),
|
|
8608
|
-
/* @__PURE__ */ (0,
|
|
8609
|
-
/* @__PURE__ */ (0,
|
|
8878
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: getClassName28("tools"), children: [
|
|
8879
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName28("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8610
8880
|
IconButton,
|
|
8611
8881
|
{
|
|
8612
8882
|
type: "button",
|
|
@@ -8614,23 +8884,23 @@ var HeaderInner = () => {
|
|
|
8614
8884
|
return setMenuOpen(!menuOpen);
|
|
8615
8885
|
},
|
|
8616
8886
|
title: "Toggle menu bar",
|
|
8617
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
|
8887
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ChevronDown, { focusable: "false" })
|
|
8618
8888
|
}
|
|
8619
8889
|
) }),
|
|
8620
|
-
/* @__PURE__ */ (0,
|
|
8890
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8621
8891
|
MenuBar,
|
|
8622
8892
|
{
|
|
8623
8893
|
dispatch,
|
|
8624
8894
|
onPublish,
|
|
8625
8895
|
menuOpen,
|
|
8626
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
|
8896
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8627
8897
|
Button,
|
|
8628
8898
|
{
|
|
8629
8899
|
onClick: () => {
|
|
8630
8900
|
const data = appStore.getState().state.data;
|
|
8631
8901
|
onPublish && onPublish(data);
|
|
8632
8902
|
},
|
|
8633
|
-
icon: /* @__PURE__ */ (0,
|
|
8903
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Globe, { size: "14px" }),
|
|
8634
8904
|
children: "Publish"
|
|
8635
8905
|
}
|
|
8636
8906
|
) }),
|
|
@@ -8655,11 +8925,11 @@ var import_react57 = require("react");
|
|
|
8655
8925
|
|
|
8656
8926
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
8657
8927
|
init_react_import();
|
|
8658
|
-
var
|
|
8928
|
+
var styles_module_default24 = { "ResizeHandle": "_ResizeHandle_144bf_2", "ResizeHandle--left": "_ResizeHandle--left_144bf_16", "ResizeHandle--right": "_ResizeHandle--right_144bf_20" };
|
|
8659
8929
|
|
|
8660
8930
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
8661
|
-
var
|
|
8662
|
-
var
|
|
8931
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
8932
|
+
var getClassName29 = get_class_name_factory_default("ResizeHandle", styles_module_default24);
|
|
8663
8933
|
var ResizeHandle = ({
|
|
8664
8934
|
position,
|
|
8665
8935
|
sidebarRef,
|
|
@@ -8698,7 +8968,7 @@ var ResizeHandle = ({
|
|
|
8698
8968
|
const finalWidth = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
8699
8969
|
onResizeEnd(finalWidth);
|
|
8700
8970
|
resetAutoZoom();
|
|
8701
|
-
}, [onResizeEnd
|
|
8971
|
+
}, [onResizeEnd]);
|
|
8702
8972
|
const handleMouseDown = (0, import_react57.useCallback)(
|
|
8703
8973
|
(e) => {
|
|
8704
8974
|
var _a;
|
|
@@ -8717,11 +8987,11 @@ var ResizeHandle = ({
|
|
|
8717
8987
|
},
|
|
8718
8988
|
[position, handleMouseMove, handleMouseUp]
|
|
8719
8989
|
);
|
|
8720
|
-
return /* @__PURE__ */ (0,
|
|
8990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
8721
8991
|
"div",
|
|
8722
8992
|
{
|
|
8723
8993
|
ref: handleRef,
|
|
8724
|
-
className:
|
|
8994
|
+
className: getClassName29({ [position]: true }),
|
|
8725
8995
|
onMouseDown: handleMouseDown
|
|
8726
8996
|
}
|
|
8727
8997
|
);
|
|
@@ -8729,11 +8999,11 @@ var ResizeHandle = ({
|
|
|
8729
8999
|
|
|
8730
9000
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Sidebar/styles.module.css#css-module
|
|
8731
9001
|
init_react_import();
|
|
8732
|
-
var
|
|
9002
|
+
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" };
|
|
8733
9003
|
|
|
8734
9004
|
// components/Puck/components/Sidebar/index.tsx
|
|
8735
|
-
var
|
|
8736
|
-
var
|
|
9005
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
9006
|
+
var getClassName30 = get_class_name_factory_default("Sidebar", styles_module_default25);
|
|
8737
9007
|
var Sidebar = ({
|
|
8738
9008
|
position,
|
|
8739
9009
|
sidebarRef,
|
|
@@ -8744,9 +9014,9 @@ var Sidebar = ({
|
|
|
8744
9014
|
children
|
|
8745
9015
|
}) => {
|
|
8746
9016
|
if (!isVisible) return null;
|
|
8747
|
-
return /* @__PURE__ */ (0,
|
|
8748
|
-
/* @__PURE__ */ (0,
|
|
8749
|
-
/* @__PURE__ */ (0,
|
|
9017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
|
|
9018
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { ref: sidebarRef, className: getClassName30({ [position]: true }), children }),
|
|
9019
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: `${getClassName30("resizeHandle")}`, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
8750
9020
|
ResizeHandle,
|
|
8751
9021
|
{
|
|
8752
9022
|
position,
|
|
@@ -8774,11 +9044,12 @@ function useSidebarResize(position, dispatch) {
|
|
|
8774
9044
|
if (savedWidths) {
|
|
8775
9045
|
const widths = JSON.parse(savedWidths);
|
|
8776
9046
|
const savedWidth = widths[position];
|
|
9047
|
+
const key = position === "left" ? "leftSideBarWidth" : "rightSideBarWidth";
|
|
8777
9048
|
if (savedWidth) {
|
|
8778
9049
|
dispatch({
|
|
8779
9050
|
type: "setUi",
|
|
8780
9051
|
ui: {
|
|
8781
|
-
[
|
|
9052
|
+
[key]: savedWidth
|
|
8782
9053
|
}
|
|
8783
9054
|
});
|
|
8784
9055
|
}
|
|
@@ -8839,9 +9110,9 @@ function useSidebarResize(position, dispatch) {
|
|
|
8839
9110
|
}
|
|
8840
9111
|
|
|
8841
9112
|
// components/Puck/index.tsx
|
|
8842
|
-
var
|
|
8843
|
-
var
|
|
8844
|
-
var getLayoutClassName = get_class_name_factory_default("PuckLayout",
|
|
9113
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
9114
|
+
var getClassName31 = get_class_name_factory_default("Puck", styles_module_default15);
|
|
9115
|
+
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
|
8845
9116
|
var FieldSideBar = () => {
|
|
8846
9117
|
const title = useAppStore(
|
|
8847
9118
|
(s) => {
|
|
@@ -8849,11 +9120,11 @@ var FieldSideBar = () => {
|
|
|
8849
9120
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
8850
9121
|
}
|
|
8851
9122
|
);
|
|
8852
|
-
return /* @__PURE__ */ (0,
|
|
9123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Fields, {}) });
|
|
8853
9124
|
};
|
|
8854
9125
|
var propsContext = (0, import_react59.createContext)({});
|
|
8855
9126
|
function PropsProvider(props) {
|
|
8856
|
-
return /* @__PURE__ */ (0,
|
|
9127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
8857
9128
|
}
|
|
8858
9129
|
var usePropsContext = () => (0, import_react59.useContext)(propsContext);
|
|
8859
9130
|
function PuckProvider({ children }) {
|
|
@@ -8869,7 +9140,8 @@ function PuckProvider({ children }) {
|
|
|
8869
9140
|
iframe: _iframe,
|
|
8870
9141
|
initialHistory: _initialHistory,
|
|
8871
9142
|
metadata,
|
|
8872
|
-
onAction
|
|
9143
|
+
onAction,
|
|
9144
|
+
fieldTransforms
|
|
8873
9145
|
} = usePropsContext();
|
|
8874
9146
|
const iframe = (0, import_react59.useMemo)(
|
|
8875
9147
|
() => __spreadValues({
|
|
@@ -8958,6 +9230,14 @@ function PuckProvider({ children }) {
|
|
|
8958
9230
|
overrides,
|
|
8959
9231
|
plugins
|
|
8960
9232
|
});
|
|
9233
|
+
const loadedFieldTransforms = (0, import_react59.useMemo)(() => {
|
|
9234
|
+
const _plugins = plugins || [];
|
|
9235
|
+
const pluginFieldTransforms = _plugins.reduce(
|
|
9236
|
+
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
9237
|
+
{}
|
|
9238
|
+
);
|
|
9239
|
+
return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
|
|
9240
|
+
}, [fieldTransforms, plugins]);
|
|
8961
9241
|
const generateAppStore = (0, import_react59.useCallback)(
|
|
8962
9242
|
(state) => {
|
|
8963
9243
|
return {
|
|
@@ -8968,7 +9248,8 @@ function PuckProvider({ children }) {
|
|
|
8968
9248
|
viewports,
|
|
8969
9249
|
iframe,
|
|
8970
9250
|
onAction,
|
|
8971
|
-
metadata
|
|
9251
|
+
metadata,
|
|
9252
|
+
fieldTransforms: loadedFieldTransforms
|
|
8972
9253
|
};
|
|
8973
9254
|
},
|
|
8974
9255
|
[
|
|
@@ -8979,7 +9260,8 @@ function PuckProvider({ children }) {
|
|
|
8979
9260
|
viewports,
|
|
8980
9261
|
iframe,
|
|
8981
9262
|
onAction,
|
|
8982
|
-
metadata
|
|
9263
|
+
metadata,
|
|
9264
|
+
loadedFieldTransforms
|
|
8983
9265
|
]
|
|
8984
9266
|
);
|
|
8985
9267
|
const [appStore] = (0, import_react59.useState)(
|
|
@@ -9018,7 +9300,7 @@ function PuckProvider({ children }) {
|
|
|
9018
9300
|
const { resolveAndCommitData } = appStore.getState();
|
|
9019
9301
|
resolveAndCommitData();
|
|
9020
9302
|
}, []);
|
|
9021
|
-
return /* @__PURE__ */ (0,
|
|
9303
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
|
9022
9304
|
}
|
|
9023
9305
|
function PuckLayout({ children }) {
|
|
9024
9306
|
const {
|
|
@@ -9094,8 +9376,8 @@ function PuckLayout({ children }) {
|
|
|
9094
9376
|
}
|
|
9095
9377
|
}, [ready, iframe.enabled]);
|
|
9096
9378
|
usePreviewModeHotkeys();
|
|
9097
|
-
return /* @__PURE__ */ (0,
|
|
9098
|
-
/* @__PURE__ */ (0,
|
|
9379
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: `Puck ${getClassName31()}`, children: [
|
|
9380
|
+
/* @__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)(
|
|
9099
9381
|
"div",
|
|
9100
9382
|
{
|
|
9101
9383
|
className: getLayoutClassName({
|
|
@@ -9103,7 +9385,7 @@ function PuckLayout({ children }) {
|
|
|
9103
9385
|
mounted,
|
|
9104
9386
|
rightSideBarVisible
|
|
9105
9387
|
}),
|
|
9106
|
-
children: /* @__PURE__ */ (0,
|
|
9388
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9107
9389
|
"div",
|
|
9108
9390
|
{
|
|
9109
9391
|
className: getLayoutClassName("inner"),
|
|
@@ -9115,8 +9397,8 @@ function PuckLayout({ children }) {
|
|
|
9115
9397
|
`
|
|
9116
9398
|
},
|
|
9117
9399
|
children: [
|
|
9118
|
-
/* @__PURE__ */ (0,
|
|
9119
|
-
/* @__PURE__ */ (0,
|
|
9400
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Header, {}),
|
|
9401
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9120
9402
|
Sidebar,
|
|
9121
9403
|
{
|
|
9122
9404
|
position: "left",
|
|
@@ -9126,13 +9408,13 @@ function PuckLayout({ children }) {
|
|
|
9126
9408
|
onResize: setLeftWidth,
|
|
9127
9409
|
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
9128
9410
|
children: [
|
|
9129
|
-
/* @__PURE__ */ (0,
|
|
9130
|
-
/* @__PURE__ */ (0,
|
|
9411
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Components, {}) }),
|
|
9412
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Outline, {}) })
|
|
9131
9413
|
]
|
|
9132
9414
|
}
|
|
9133
9415
|
),
|
|
9134
|
-
/* @__PURE__ */ (0,
|
|
9135
|
-
/* @__PURE__ */ (0,
|
|
9416
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Canvas, {}),
|
|
9417
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9136
9418
|
Sidebar,
|
|
9137
9419
|
{
|
|
9138
9420
|
position: "right",
|
|
@@ -9141,7 +9423,7 @@ function PuckLayout({ children }) {
|
|
|
9141
9423
|
width: rightWidth,
|
|
9142
9424
|
onResize: setRightWidth,
|
|
9143
9425
|
onResizeEnd: handleRightSidebarResizeEnd,
|
|
9144
|
-
children: /* @__PURE__ */ (0,
|
|
9426
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(FieldSideBar, {})
|
|
9145
9427
|
}
|
|
9146
9428
|
)
|
|
9147
9429
|
]
|
|
@@ -9149,11 +9431,11 @@ function PuckLayout({ children }) {
|
|
|
9149
9431
|
)
|
|
9150
9432
|
}
|
|
9151
9433
|
) }) }) }),
|
|
9152
|
-
/* @__PURE__ */ (0,
|
|
9434
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { id: "puck-portal-root", className: getClassName31("portal") })
|
|
9153
9435
|
] });
|
|
9154
9436
|
}
|
|
9155
9437
|
function Puck(props) {
|
|
9156
|
-
return /* @__PURE__ */ (0,
|
|
9438
|
+
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)) })) }));
|
|
9157
9439
|
}
|
|
9158
9440
|
Puck.Components = Components;
|
|
9159
9441
|
Puck.Fields = Fields;
|
|
@@ -9352,9 +9634,9 @@ function resolveAllData(_0, _1) {
|
|
|
9352
9634
|
},
|
|
9353
9635
|
"force"
|
|
9354
9636
|
)).node;
|
|
9355
|
-
const resolvedDeep = yield
|
|
9637
|
+
const resolvedDeep = yield mapFields(
|
|
9356
9638
|
resolved,
|
|
9357
|
-
processContent,
|
|
9639
|
+
{ slot: ({ value }) => processContent(value) },
|
|
9358
9640
|
config
|
|
9359
9641
|
);
|
|
9360
9642
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
@@ -9400,8 +9682,10 @@ function resolveAllData(_0, _1) {
|
|
|
9400
9682
|
createUsePuck,
|
|
9401
9683
|
migrate,
|
|
9402
9684
|
overrideKeys,
|
|
9685
|
+
registerOverlayPortal,
|
|
9403
9686
|
renderContext,
|
|
9404
9687
|
resolveAllData,
|
|
9688
|
+
setDeep,
|
|
9405
9689
|
transformProps,
|
|
9406
9690
|
useGetPuck,
|
|
9407
9691
|
usePuck,
|