@measured/puck 0.20.0-canary.2b50fb19 → 0.20.0-canary.2ce4c22c
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-ANWTLGCS.mjs +9040 -0
- package/dist/{chunk-IAEXMHQX.mjs → chunk-HUKJ36SA.mjs} +223 -75
- package/dist/index.css +155 -74
- package/dist/index.d.mts +17 -8
- package/dist/index.d.ts +17 -8
- package/dist/index.js +1715 -1096
- package/dist/index.mjs +29 -8460
- package/dist/no-external.css +1831 -0
- package/dist/no-external.d.mts +4 -2
- package/dist/no-external.d.ts +4 -2
- package/dist/no-external.js +9949 -1
- package/dist/no-external.mjs +52 -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 +2 -4
- package/dist/{walk-tree-6p9XnDIV.d.mts → walk-tree-B57SgEEc.d.mts} +44 -5
- package/dist/{walk-tree-6p9XnDIV.d.ts → walk-tree-B57SgEEc.d.ts} +44 -5
- package/package.json +1 -1
- package/dist/chunk-M6W7YEVX.mjs +0 -95
package/dist/index.js
CHANGED
|
@@ -171,8 +171,10 @@ __export(bundle_exports, {
|
|
|
171
171
|
createUsePuck: () => createUsePuck,
|
|
172
172
|
migrate: () => migrate,
|
|
173
173
|
overrideKeys: () => overrideKeys,
|
|
174
|
+
registerOverlayPortal: () => registerOverlayPortal,
|
|
174
175
|
renderContext: () => renderContext,
|
|
175
176
|
resolveAllData: () => resolveAllData,
|
|
177
|
+
setDeep: () => setDeep,
|
|
176
178
|
transformProps: () => transformProps,
|
|
177
179
|
useGetPuck: () => useGetPuck,
|
|
178
180
|
usePuck: () => usePuck,
|
|
@@ -193,6 +195,9 @@ init_react_import();
|
|
|
193
195
|
// types/API/Viewports.ts
|
|
194
196
|
init_react_import();
|
|
195
197
|
|
|
198
|
+
// types/API/FieldTransforms.ts
|
|
199
|
+
init_react_import();
|
|
200
|
+
|
|
196
201
|
// types/index.ts
|
|
197
202
|
init_react_import();
|
|
198
203
|
|
|
@@ -203,8 +208,9 @@ var overrideKeys = [
|
|
|
203
208
|
"headerActions",
|
|
204
209
|
"fields",
|
|
205
210
|
"fieldLabel",
|
|
206
|
-
"
|
|
207
|
-
"
|
|
211
|
+
"drawer",
|
|
212
|
+
"drawerItem",
|
|
213
|
+
"componentOverlay",
|
|
208
214
|
"outline",
|
|
209
215
|
"puck",
|
|
210
216
|
"preview"
|
|
@@ -306,10 +312,10 @@ init_react_import();
|
|
|
306
312
|
|
|
307
313
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
|
308
314
|
init_react_import();
|
|
309
|
-
var styles_module_default2 = { "InputWrapper": "
|
|
315
|
+
var styles_module_default2 = { "InputWrapper": "_InputWrapper_bsxfo_1", "Input-label": "_Input-label_bsxfo_5", "Input-labelIcon": "_Input-labelIcon_bsxfo_14", "Input-disabledIcon": "_Input-disabledIcon_bsxfo_21", "Input-input": "_Input-input_bsxfo_26", "Input": "_Input_bsxfo_1", "Input--readOnly": "_Input--readOnly_bsxfo_82", "Input-radioGroupItems": "_Input-radioGroupItems_bsxfo_93", "Input-radio": "_Input-radio_bsxfo_93", "Input-radioInner": "_Input-radioInner_bsxfo_110", "Input-radioInput": "_Input-radioInput_bsxfo_155" };
|
|
310
316
|
|
|
311
317
|
// components/AutoField/index.tsx
|
|
312
|
-
var
|
|
318
|
+
var import_react20 = require("react");
|
|
313
319
|
|
|
314
320
|
// components/AutoField/fields/index.tsx
|
|
315
321
|
init_react_import();
|
|
@@ -653,7 +659,7 @@ init_react_import();
|
|
|
653
659
|
|
|
654
660
|
// components/IconButton/IconButton.tsx
|
|
655
661
|
init_react_import();
|
|
656
|
-
var
|
|
662
|
+
var import_react9 = require("react");
|
|
657
663
|
|
|
658
664
|
// css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
|
|
659
665
|
init_react_import();
|
|
@@ -686,102 +692,8 @@ var replace = (list, index, newItem) => {
|
|
|
686
692
|
return result;
|
|
687
693
|
};
|
|
688
694
|
|
|
689
|
-
//
|
|
690
|
-
init_react_import();
|
|
691
|
-
var styles_module_default4 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
|
692
|
-
|
|
693
|
-
// components/Loader/index.tsx
|
|
694
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
695
|
-
var getClassName2 = get_class_name_factory_default("Loader", styles_module_default4);
|
|
696
|
-
var Loader = (_a) => {
|
|
697
|
-
var _b = _a, {
|
|
698
|
-
color,
|
|
699
|
-
size = 16
|
|
700
|
-
} = _b, props = __objRest(_b, [
|
|
701
|
-
"color",
|
|
702
|
-
"size"
|
|
703
|
-
]);
|
|
704
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
705
|
-
"span",
|
|
706
|
-
__spreadValues({
|
|
707
|
-
className: getClassName2(),
|
|
708
|
-
style: {
|
|
709
|
-
width: size,
|
|
710
|
-
height: size,
|
|
711
|
-
color
|
|
712
|
-
},
|
|
713
|
-
"aria-label": "loading"
|
|
714
|
-
}, props)
|
|
715
|
-
);
|
|
716
|
-
};
|
|
717
|
-
|
|
718
|
-
// components/IconButton/IconButton.tsx
|
|
719
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
720
|
-
var getClassName3 = get_class_name_factory_default("IconButton", IconButton_module_default);
|
|
721
|
-
var IconButton = ({
|
|
722
|
-
children,
|
|
723
|
-
href,
|
|
724
|
-
onClick,
|
|
725
|
-
variant = "primary",
|
|
726
|
-
type,
|
|
727
|
-
disabled,
|
|
728
|
-
tabIndex,
|
|
729
|
-
newTab,
|
|
730
|
-
fullWidth,
|
|
731
|
-
title
|
|
732
|
-
}) => {
|
|
733
|
-
const [loading, setLoading] = (0, import_react4.useState)(false);
|
|
734
|
-
const ElementType = href ? "a" : "button";
|
|
735
|
-
const el = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
736
|
-
ElementType,
|
|
737
|
-
{
|
|
738
|
-
className: getClassName3({
|
|
739
|
-
primary: variant === "primary",
|
|
740
|
-
secondary: variant === "secondary",
|
|
741
|
-
disabled,
|
|
742
|
-
fullWidth
|
|
743
|
-
}),
|
|
744
|
-
onClick: (e) => {
|
|
745
|
-
if (!onClick) return;
|
|
746
|
-
setLoading(true);
|
|
747
|
-
Promise.resolve(onClick(e)).then(() => {
|
|
748
|
-
setLoading(false);
|
|
749
|
-
});
|
|
750
|
-
},
|
|
751
|
-
type,
|
|
752
|
-
disabled: disabled || loading,
|
|
753
|
-
tabIndex,
|
|
754
|
-
target: newTab ? "_blank" : void 0,
|
|
755
|
-
rel: newTab ? "noreferrer" : void 0,
|
|
756
|
-
href,
|
|
757
|
-
title,
|
|
758
|
-
children: [
|
|
759
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: getClassName3("title"), children: title }),
|
|
760
|
-
children,
|
|
761
|
-
loading && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
762
|
-
"\xA0\xA0",
|
|
763
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Loader, { size: 14 })
|
|
764
|
-
] })
|
|
765
|
-
]
|
|
766
|
-
}
|
|
767
|
-
);
|
|
768
|
-
return el;
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
// components/AutoField/fields/ArrayField/index.tsx
|
|
772
|
-
var import_react14 = require("react");
|
|
773
|
-
|
|
774
|
-
// components/DragIcon/index.tsx
|
|
775
|
-
init_react_import();
|
|
776
|
-
|
|
777
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/DragIcon/styles.module.css#css-module
|
|
695
|
+
// lib/use-reset-auto-zoom.ts
|
|
778
696
|
init_react_import();
|
|
779
|
-
var styles_module_default5 = { "DragIcon": "_DragIcon_17p8x_1", "DragIcon--disabled": "_DragIcon--disabled_17p8x_8" };
|
|
780
|
-
|
|
781
|
-
// components/DragIcon/index.tsx
|
|
782
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
783
|
-
var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_default5);
|
|
784
|
-
var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName4({ disabled: isDragDisabled }), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { viewBox: "0 0 20 20", width: "12", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }) }) });
|
|
785
697
|
|
|
786
698
|
// store/index.ts
|
|
787
699
|
init_react_import();
|
|
@@ -828,7 +740,7 @@ function forRelatedZones(item, data, cb, path = []) {
|
|
|
828
740
|
});
|
|
829
741
|
}
|
|
830
742
|
|
|
831
|
-
// lib/data/map-
|
|
743
|
+
// lib/data/map-fields.ts
|
|
832
744
|
init_react_import();
|
|
833
745
|
|
|
834
746
|
// lib/data/default-slots.ts
|
|
@@ -838,14 +750,14 @@ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
|
|
|
838
750
|
value
|
|
839
751
|
);
|
|
840
752
|
|
|
841
|
-
// lib/data/map-
|
|
753
|
+
// lib/data/map-fields.ts
|
|
842
754
|
var isPromise = (v) => !!v && typeof v.then === "function";
|
|
843
755
|
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
|
844
756
|
var containsPromise = (arr) => arr.some(isPromise);
|
|
845
757
|
var walkField = ({
|
|
846
758
|
value,
|
|
847
759
|
fields,
|
|
848
|
-
|
|
760
|
+
mappers,
|
|
849
761
|
propKey = "",
|
|
850
762
|
propPath = "",
|
|
851
763
|
id = "",
|
|
@@ -853,7 +765,9 @@ var walkField = ({
|
|
|
853
765
|
recurseSlots = false
|
|
854
766
|
}) => {
|
|
855
767
|
var _a, _b, _c;
|
|
856
|
-
|
|
768
|
+
const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
|
|
769
|
+
const map = mappers[fieldType];
|
|
770
|
+
if (map && fieldType === "slot") {
|
|
857
771
|
const content = value || [];
|
|
858
772
|
const mappedContent = recurseSlots ? content.map((el) => {
|
|
859
773
|
var _a2;
|
|
@@ -865,7 +779,7 @@ var walkField = ({
|
|
|
865
779
|
return walkField({
|
|
866
780
|
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
|
867
781
|
fields: fields2,
|
|
868
|
-
|
|
782
|
+
mappers,
|
|
869
783
|
id: el.props.id,
|
|
870
784
|
config,
|
|
871
785
|
recurseSlots
|
|
@@ -874,7 +788,21 @@ var walkField = ({
|
|
|
874
788
|
if (containsPromise(mappedContent)) {
|
|
875
789
|
return Promise.all(mappedContent);
|
|
876
790
|
}
|
|
877
|
-
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
|
+
});
|
|
878
806
|
}
|
|
879
807
|
if (value && typeof value === "object") {
|
|
880
808
|
if (Array.isArray(value)) {
|
|
@@ -884,7 +812,7 @@ var walkField = ({
|
|
|
884
812
|
(el, idx) => walkField({
|
|
885
813
|
value: el,
|
|
886
814
|
fields: arrayFields,
|
|
887
|
-
|
|
815
|
+
mappers,
|
|
888
816
|
propKey,
|
|
889
817
|
propPath: `${propPath}[${idx}]`,
|
|
890
818
|
id,
|
|
@@ -903,7 +831,7 @@ var walkField = ({
|
|
|
903
831
|
return walkObject({
|
|
904
832
|
value,
|
|
905
833
|
fields: objectFields,
|
|
906
|
-
|
|
834
|
+
mappers,
|
|
907
835
|
id,
|
|
908
836
|
getPropPath: (k) => `${propPath}.${k}`,
|
|
909
837
|
config,
|
|
@@ -916,7 +844,7 @@ var walkField = ({
|
|
|
916
844
|
var walkObject = ({
|
|
917
845
|
value,
|
|
918
846
|
fields,
|
|
919
|
-
|
|
847
|
+
mappers,
|
|
920
848
|
id,
|
|
921
849
|
getPropPath,
|
|
922
850
|
config,
|
|
@@ -926,7 +854,7 @@ var walkObject = ({
|
|
|
926
854
|
const opts = {
|
|
927
855
|
value: v,
|
|
928
856
|
fields,
|
|
929
|
-
|
|
857
|
+
mappers,
|
|
930
858
|
propKey: k,
|
|
931
859
|
propPath: getPropPath(k),
|
|
932
860
|
id,
|
|
@@ -948,14 +876,14 @@ var walkObject = ({
|
|
|
948
876
|
}
|
|
949
877
|
return flatten(newProps);
|
|
950
878
|
};
|
|
951
|
-
function
|
|
879
|
+
function mapFields(item, mappers, config, recurseSlots = false) {
|
|
952
880
|
var _a, _b, _c, _d, _e;
|
|
953
881
|
const itemType = "type" in item ? item.type : "root";
|
|
954
882
|
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
|
955
883
|
const newProps = walkObject({
|
|
956
884
|
value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
|
|
957
885
|
fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
|
|
958
|
-
|
|
886
|
+
mappers,
|
|
959
887
|
id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
|
|
960
888
|
getPropPath: (k) => k,
|
|
961
889
|
config,
|
|
@@ -978,7 +906,7 @@ var import_flat = __toESM(require("flat"));
|
|
|
978
906
|
// lib/data/strip-slots.ts
|
|
979
907
|
init_react_import();
|
|
980
908
|
var stripSlots = (data, config) => {
|
|
981
|
-
return
|
|
909
|
+
return mapFields(data, { slot: () => null }, config);
|
|
982
910
|
};
|
|
983
911
|
|
|
984
912
|
// lib/data/flatten-node.ts
|
|
@@ -1037,18 +965,21 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
|
1037
965
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
|
1038
966
|
if (!mappedItem) return item;
|
|
1039
967
|
const id = mappedItem.props.id;
|
|
1040
|
-
const newProps = __spreadProps(__spreadValues({},
|
|
968
|
+
const newProps = __spreadProps(__spreadValues({}, mapFields(
|
|
1041
969
|
mappedItem,
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
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
|
+
}
|
|
1052
983
|
},
|
|
1053
984
|
config
|
|
1054
985
|
).props), {
|
|
@@ -1166,11 +1097,14 @@ init_react_import();
|
|
|
1166
1097
|
function walkTree(data, config, callbackFn) {
|
|
1167
1098
|
var _a, _b;
|
|
1168
1099
|
const walkItem = (item) => {
|
|
1169
|
-
return
|
|
1100
|
+
return mapFields(
|
|
1170
1101
|
item,
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1102
|
+
{
|
|
1103
|
+
slot: ({ value, parentId, propName }) => {
|
|
1104
|
+
var _a2;
|
|
1105
|
+
const content = value;
|
|
1106
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
|
1107
|
+
}
|
|
1174
1108
|
},
|
|
1175
1109
|
config,
|
|
1176
1110
|
true
|
|
@@ -1684,15 +1618,15 @@ var defaultViewports = [
|
|
|
1684
1618
|
// store/index.ts
|
|
1685
1619
|
var import_zustand2 = require("zustand");
|
|
1686
1620
|
var import_middleware2 = require("zustand/middleware");
|
|
1687
|
-
var
|
|
1621
|
+
var import_react8 = require("react");
|
|
1688
1622
|
|
|
1689
1623
|
// store/slices/history.ts
|
|
1690
1624
|
init_react_import();
|
|
1691
|
-
var
|
|
1625
|
+
var import_react5 = require("react");
|
|
1692
1626
|
|
|
1693
1627
|
// lib/use-hotkey.ts
|
|
1694
1628
|
init_react_import();
|
|
1695
|
-
var
|
|
1629
|
+
var import_react4 = require("react");
|
|
1696
1630
|
var import_zustand = require("zustand");
|
|
1697
1631
|
var import_middleware = require("zustand/middleware");
|
|
1698
1632
|
var keyCodeMap = {
|
|
@@ -1785,10 +1719,10 @@ var monitorHotkeys = (doc) => {
|
|
|
1785
1719
|
};
|
|
1786
1720
|
};
|
|
1787
1721
|
var useMonitorHotkeys = () => {
|
|
1788
|
-
(0,
|
|
1722
|
+
(0, import_react4.useEffect)(() => monitorHotkeys(document), []);
|
|
1789
1723
|
};
|
|
1790
1724
|
var useHotkey = (combo, cb) => {
|
|
1791
|
-
(0,
|
|
1725
|
+
(0, import_react4.useEffect)(
|
|
1792
1726
|
() => useHotkeyStore.setState((s) => ({
|
|
1793
1727
|
triggers: __spreadProps(__spreadValues({}, s.triggers), {
|
|
1794
1728
|
[`${Object.keys(combo).join("+")}`]: { combo, cb }
|
|
@@ -1897,7 +1831,7 @@ function useRegisterHistorySlice(appStore, {
|
|
|
1897
1831
|
index,
|
|
1898
1832
|
initialAppState
|
|
1899
1833
|
}) {
|
|
1900
|
-
(0,
|
|
1834
|
+
(0, import_react5.useEffect)(
|
|
1901
1835
|
() => appStore.setState({
|
|
1902
1836
|
history: __spreadProps(__spreadValues({}, appStore.getState().history), {
|
|
1903
1837
|
histories,
|
|
@@ -1964,7 +1898,7 @@ var createNodesSlice = (set, get) => ({
|
|
|
1964
1898
|
|
|
1965
1899
|
// store/slices/permissions.ts
|
|
1966
1900
|
init_react_import();
|
|
1967
|
-
var
|
|
1901
|
+
var import_react6 = require("react");
|
|
1968
1902
|
|
|
1969
1903
|
// lib/data/flatten-data.ts
|
|
1970
1904
|
init_react_import();
|
|
@@ -2101,7 +2035,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2101
2035
|
};
|
|
2102
2036
|
};
|
|
2103
2037
|
var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
2104
|
-
(0,
|
|
2038
|
+
(0, import_react6.useEffect)(() => {
|
|
2105
2039
|
const { permissions } = appStore.getState();
|
|
2106
2040
|
const { globalPermissions: existingGlobalPermissions } = permissions;
|
|
2107
2041
|
appStore.setState({
|
|
@@ -2111,7 +2045,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2111
2045
|
});
|
|
2112
2046
|
permissions.resolvePermissions();
|
|
2113
2047
|
}, [globalPermissions]);
|
|
2114
|
-
(0,
|
|
2048
|
+
(0, import_react6.useEffect)(() => {
|
|
2115
2049
|
return appStore.subscribe(
|
|
2116
2050
|
(s) => s.state.data,
|
|
2117
2051
|
() => {
|
|
@@ -2119,7 +2053,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2119
2053
|
}
|
|
2120
2054
|
);
|
|
2121
2055
|
}, []);
|
|
2122
|
-
(0,
|
|
2056
|
+
(0, import_react6.useEffect)(() => {
|
|
2123
2057
|
return appStore.subscribe(
|
|
2124
2058
|
(s) => s.config,
|
|
2125
2059
|
() => {
|
|
@@ -2131,7 +2065,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2131
2065
|
|
|
2132
2066
|
// store/slices/fields.ts
|
|
2133
2067
|
init_react_import();
|
|
2134
|
-
var
|
|
2068
|
+
var import_react7 = require("react");
|
|
2135
2069
|
var createFieldsSlice = (_set, _get) => {
|
|
2136
2070
|
return {
|
|
2137
2071
|
fields: {},
|
|
@@ -2141,7 +2075,7 @@ var createFieldsSlice = (_set, _get) => {
|
|
|
2141
2075
|
};
|
|
2142
2076
|
};
|
|
2143
2077
|
var useRegisterFieldsSlice = (appStore, id) => {
|
|
2144
|
-
const resolveFields = (0,
|
|
2078
|
+
const resolveFields = (0, import_react7.useCallback)(
|
|
2145
2079
|
(reset) => __async(void 0, null, function* () {
|
|
2146
2080
|
var _a, _b;
|
|
2147
2081
|
const { fields, lastResolvedData } = appStore.getState().fields;
|
|
@@ -2198,7 +2132,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2198
2132
|
}),
|
|
2199
2133
|
[id]
|
|
2200
2134
|
);
|
|
2201
|
-
(0,
|
|
2135
|
+
(0, import_react7.useEffect)(() => {
|
|
2202
2136
|
resolveFields(true);
|
|
2203
2137
|
return appStore.subscribe(
|
|
2204
2138
|
(s) => s.state.indexes.nodes[id || "root"],
|
|
@@ -2236,24 +2170,27 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
|
2236
2170
|
resolvedItem.readOnly = readOnly;
|
|
2237
2171
|
}
|
|
2238
2172
|
}
|
|
2239
|
-
let itemWithResolvedChildren = yield
|
|
2173
|
+
let itemWithResolvedChildren = yield mapFields(
|
|
2240
2174
|
resolvedItem,
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
content
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
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
|
+
},
|
|
2257
2194
|
config
|
|
2258
2195
|
);
|
|
2259
2196
|
if (shouldRunResolver && onResolveEnd) {
|
|
@@ -2335,7 +2272,8 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
|
2335
2272
|
},
|
|
2336
2273
|
status: "LOADING",
|
|
2337
2274
|
iframe: {},
|
|
2338
|
-
metadata: {}
|
|
2275
|
+
metadata: {},
|
|
2276
|
+
fieldTransforms: {}
|
|
2339
2277
|
}, initialAppStore), {
|
|
2340
2278
|
fields: createFieldsSlice(set, get),
|
|
2341
2279
|
history: createHistorySlice(set, get),
|
|
@@ -2490,108 +2428,372 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
|
2490
2428
|
});
|
|
2491
2429
|
})
|
|
2492
2430
|
);
|
|
2493
|
-
var appStoreContext = (0,
|
|
2431
|
+
var appStoreContext = (0, import_react8.createContext)(createAppStore());
|
|
2494
2432
|
function useAppStore(selector) {
|
|
2495
|
-
const context = (0,
|
|
2433
|
+
const context = (0, import_react8.useContext)(appStoreContext);
|
|
2496
2434
|
return (0, import_zustand2.useStore)(context, selector);
|
|
2497
2435
|
}
|
|
2498
2436
|
function useAppStoreApi() {
|
|
2499
|
-
return (0,
|
|
2437
|
+
return (0, import_react8.useContext)(appStoreContext);
|
|
2500
2438
|
}
|
|
2501
2439
|
|
|
2502
|
-
//
|
|
2503
|
-
init_react_import();
|
|
2504
|
-
var import_react12 = require("@dnd-kit/react");
|
|
2505
|
-
|
|
2506
|
-
// lib/dnd/use-sensors.ts
|
|
2440
|
+
// lib/get-zoom-config.ts
|
|
2507
2441
|
init_react_import();
|
|
2508
|
-
var import_react10 = require("react");
|
|
2509
|
-
var import_react11 = require("@dnd-kit/react");
|
|
2510
|
-
var import_utilities = require("@dnd-kit/dom/utilities");
|
|
2511
|
-
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
|
2512
|
-
var otherDefault = {
|
|
2513
|
-
delay: { value: 200, tolerance: 10 },
|
|
2514
|
-
distance: { value: 5 }
|
|
2515
|
-
};
|
|
2516
|
-
var useSensors = ({
|
|
2517
|
-
other = otherDefault,
|
|
2518
|
-
mouse,
|
|
2519
|
-
touch = touchDefault
|
|
2520
|
-
} = {
|
|
2521
|
-
touch: touchDefault,
|
|
2522
|
-
other: otherDefault
|
|
2523
|
-
}) => {
|
|
2524
|
-
const [sensors] = (0, import_react10.useState)(() => [
|
|
2525
|
-
import_react11.PointerSensor.configure({
|
|
2526
|
-
activationConstraints(event, source) {
|
|
2527
|
-
var _a;
|
|
2528
|
-
const { pointerType, target } = event;
|
|
2529
|
-
if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
|
2530
|
-
return mouse;
|
|
2531
|
-
}
|
|
2532
|
-
if (pointerType === "touch") {
|
|
2533
|
-
return touch;
|
|
2534
|
-
}
|
|
2535
|
-
return other;
|
|
2536
|
-
}
|
|
2537
|
-
})
|
|
2538
|
-
]);
|
|
2539
|
-
return sensors;
|
|
2540
|
-
};
|
|
2541
2442
|
|
|
2542
|
-
//
|
|
2443
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
2543
2444
|
init_react_import();
|
|
2544
|
-
var import_abstract8 = require("@dnd-kit/abstract");
|
|
2545
2445
|
|
|
2546
|
-
//
|
|
2446
|
+
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
2547
2447
|
init_react_import();
|
|
2548
|
-
var
|
|
2448
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
2449
|
+
var prefix = "Invariant failed";
|
|
2450
|
+
function invariant(condition, message) {
|
|
2451
|
+
if (condition) {
|
|
2452
|
+
return;
|
|
2453
|
+
}
|
|
2454
|
+
if (isProduction) {
|
|
2455
|
+
throw new Error(prefix);
|
|
2456
|
+
}
|
|
2457
|
+
var provided = typeof message === "function" ? message() : message;
|
|
2458
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
2459
|
+
throw new Error(value);
|
|
2460
|
+
}
|
|
2549
2461
|
|
|
2550
|
-
//
|
|
2551
|
-
|
|
2552
|
-
var
|
|
2553
|
-
var
|
|
2554
|
-
var
|
|
2555
|
-
var
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
const existingEl = debugElements[debugId];
|
|
2568
|
-
let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
|
|
2569
|
-
let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
|
|
2570
|
-
if (!existingEl) {
|
|
2571
|
-
const svgNs = "http://www.w3.org/2000/svg";
|
|
2572
|
-
const svg = document.createElementNS(svgNs, "svg");
|
|
2573
|
-
line = document.createElementNS(svgNs, "line");
|
|
2574
|
-
text = document.createElementNS(svgNs, "text");
|
|
2575
|
-
svg.setAttribute("id", debugId);
|
|
2576
|
-
svg.setAttribute(
|
|
2577
|
-
"style",
|
|
2578
|
-
"position: fixed; height: 100%; width: 100%; pointer-events: none; top: 0px; left: 0px;"
|
|
2579
|
-
);
|
|
2580
|
-
svg.appendChild(line);
|
|
2581
|
-
svg.appendChild(text);
|
|
2582
|
-
text.setAttribute("fill", `black`);
|
|
2583
|
-
document.body.appendChild(svg);
|
|
2584
|
-
debugElements[debugId] = { svg, line, text };
|
|
2462
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
2463
|
+
var getRect = function getRect2(_ref) {
|
|
2464
|
+
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
|
2465
|
+
var width = right - left;
|
|
2466
|
+
var height = bottom - top;
|
|
2467
|
+
var rect = {
|
|
2468
|
+
top,
|
|
2469
|
+
right,
|
|
2470
|
+
bottom,
|
|
2471
|
+
left,
|
|
2472
|
+
width,
|
|
2473
|
+
height,
|
|
2474
|
+
x: left,
|
|
2475
|
+
y: top,
|
|
2476
|
+
center: {
|
|
2477
|
+
x: (right + left) / 2,
|
|
2478
|
+
y: (bottom + top) / 2
|
|
2585
2479
|
}
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2480
|
+
};
|
|
2481
|
+
return rect;
|
|
2482
|
+
};
|
|
2483
|
+
var expand = function expand2(target, expandBy) {
|
|
2484
|
+
return {
|
|
2485
|
+
top: target.top - expandBy.top,
|
|
2486
|
+
left: target.left - expandBy.left,
|
|
2487
|
+
bottom: target.bottom + expandBy.bottom,
|
|
2488
|
+
right: target.right + expandBy.right
|
|
2489
|
+
};
|
|
2490
|
+
};
|
|
2491
|
+
var shrink = function shrink2(target, shrinkBy) {
|
|
2492
|
+
return {
|
|
2493
|
+
top: target.top + shrinkBy.top,
|
|
2494
|
+
left: target.left + shrinkBy.left,
|
|
2495
|
+
bottom: target.bottom - shrinkBy.bottom,
|
|
2496
|
+
right: target.right - shrinkBy.right
|
|
2497
|
+
};
|
|
2498
|
+
};
|
|
2499
|
+
var noSpacing = {
|
|
2500
|
+
top: 0,
|
|
2501
|
+
right: 0,
|
|
2502
|
+
bottom: 0,
|
|
2503
|
+
left: 0
|
|
2504
|
+
};
|
|
2505
|
+
var createBox = function createBox2(_ref2) {
|
|
2506
|
+
var borderBox = _ref2.borderBox, _ref2$margin = _ref2.margin, margin = _ref2$margin === void 0 ? noSpacing : _ref2$margin, _ref2$border = _ref2.border, border = _ref2$border === void 0 ? noSpacing : _ref2$border, _ref2$padding = _ref2.padding, padding = _ref2$padding === void 0 ? noSpacing : _ref2$padding;
|
|
2507
|
+
var marginBox = getRect(expand(borderBox, margin));
|
|
2508
|
+
var paddingBox = getRect(shrink(borderBox, border));
|
|
2509
|
+
var contentBox = getRect(shrink(paddingBox, padding));
|
|
2510
|
+
return {
|
|
2511
|
+
marginBox,
|
|
2512
|
+
borderBox: getRect(borderBox),
|
|
2513
|
+
paddingBox,
|
|
2514
|
+
contentBox,
|
|
2515
|
+
margin,
|
|
2516
|
+
border,
|
|
2517
|
+
padding
|
|
2518
|
+
};
|
|
2519
|
+
};
|
|
2520
|
+
var parse = function parse2(raw) {
|
|
2521
|
+
var value = raw.slice(0, -2);
|
|
2522
|
+
var suffix = raw.slice(-2);
|
|
2523
|
+
if (suffix !== "px") {
|
|
2524
|
+
return 0;
|
|
2525
|
+
}
|
|
2526
|
+
var result = Number(value);
|
|
2527
|
+
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
|
2528
|
+
return result;
|
|
2529
|
+
};
|
|
2530
|
+
var calculateBox = function calculateBox2(borderBox, styles2) {
|
|
2531
|
+
var margin = {
|
|
2532
|
+
top: parse(styles2.marginTop),
|
|
2533
|
+
right: parse(styles2.marginRight),
|
|
2534
|
+
bottom: parse(styles2.marginBottom),
|
|
2535
|
+
left: parse(styles2.marginLeft)
|
|
2536
|
+
};
|
|
2537
|
+
var padding = {
|
|
2538
|
+
top: parse(styles2.paddingTop),
|
|
2539
|
+
right: parse(styles2.paddingRight),
|
|
2540
|
+
bottom: parse(styles2.paddingBottom),
|
|
2541
|
+
left: parse(styles2.paddingLeft)
|
|
2542
|
+
};
|
|
2543
|
+
var border = {
|
|
2544
|
+
top: parse(styles2.borderTopWidth),
|
|
2545
|
+
right: parse(styles2.borderRightWidth),
|
|
2546
|
+
bottom: parse(styles2.borderBottomWidth),
|
|
2547
|
+
left: parse(styles2.borderLeftWidth)
|
|
2548
|
+
};
|
|
2549
|
+
return createBox({
|
|
2550
|
+
borderBox,
|
|
2551
|
+
margin,
|
|
2552
|
+
padding,
|
|
2553
|
+
border
|
|
2554
|
+
});
|
|
2555
|
+
};
|
|
2556
|
+
var getBox = function getBox2(el) {
|
|
2557
|
+
var borderBox = el.getBoundingClientRect();
|
|
2558
|
+
var styles2 = window.getComputedStyle(el);
|
|
2559
|
+
return calculateBox(borderBox, styles2);
|
|
2560
|
+
};
|
|
2561
|
+
|
|
2562
|
+
// lib/get-zoom-config.ts
|
|
2563
|
+
var RESET_ZOOM_SMALLER_THAN_FRAME = true;
|
|
2564
|
+
var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
2565
|
+
const box = getBox(frame);
|
|
2566
|
+
const { width: frameWidth, height: frameHeight } = box.contentBox;
|
|
2567
|
+
const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
|
|
2568
|
+
let rootHeight = 0;
|
|
2569
|
+
let autoZoom = 1;
|
|
2570
|
+
if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
|
|
2571
|
+
const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
|
|
2572
|
+
const heightZoom = Math.min(frameHeight / viewportHeight, 1);
|
|
2573
|
+
zoom = widthZoom;
|
|
2574
|
+
if (widthZoom < heightZoom) {
|
|
2575
|
+
rootHeight = viewportHeight / zoom;
|
|
2576
|
+
} else {
|
|
2577
|
+
rootHeight = viewportHeight;
|
|
2578
|
+
zoom = heightZoom;
|
|
2579
|
+
}
|
|
2580
|
+
autoZoom = zoom;
|
|
2581
|
+
} else {
|
|
2582
|
+
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
|
2583
|
+
autoZoom = 1;
|
|
2584
|
+
zoom = 1;
|
|
2585
|
+
rootHeight = viewportHeight;
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
return { autoZoom, rootHeight, zoom };
|
|
2589
|
+
};
|
|
2590
|
+
|
|
2591
|
+
// lib/use-reset-auto-zoom.ts
|
|
2592
|
+
var useResetAutoZoom = (frameRef) => {
|
|
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
|
+
};
|
|
2604
|
+
return resetAutoZoom;
|
|
2605
|
+
};
|
|
2606
|
+
|
|
2607
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
|
2608
|
+
init_react_import();
|
|
2609
|
+
var styles_module_default4 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
|
2610
|
+
|
|
2611
|
+
// components/Loader/index.tsx
|
|
2612
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2613
|
+
var getClassName2 = get_class_name_factory_default("Loader", styles_module_default4);
|
|
2614
|
+
var Loader = (_a) => {
|
|
2615
|
+
var _b = _a, {
|
|
2616
|
+
color,
|
|
2617
|
+
size = 16
|
|
2618
|
+
} = _b, props = __objRest(_b, [
|
|
2619
|
+
"color",
|
|
2620
|
+
"size"
|
|
2621
|
+
]);
|
|
2622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2623
|
+
"span",
|
|
2624
|
+
__spreadValues({
|
|
2625
|
+
className: getClassName2(),
|
|
2626
|
+
style: {
|
|
2627
|
+
width: size,
|
|
2628
|
+
height: size,
|
|
2629
|
+
color
|
|
2630
|
+
},
|
|
2631
|
+
"aria-label": "loading"
|
|
2632
|
+
}, props)
|
|
2633
|
+
);
|
|
2634
|
+
};
|
|
2635
|
+
|
|
2636
|
+
// components/IconButton/IconButton.tsx
|
|
2637
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2638
|
+
var getClassName3 = get_class_name_factory_default("IconButton", IconButton_module_default);
|
|
2639
|
+
var IconButton = ({
|
|
2640
|
+
children,
|
|
2641
|
+
href,
|
|
2642
|
+
onClick,
|
|
2643
|
+
variant = "primary",
|
|
2644
|
+
type,
|
|
2645
|
+
disabled,
|
|
2646
|
+
tabIndex,
|
|
2647
|
+
newTab,
|
|
2648
|
+
fullWidth,
|
|
2649
|
+
title
|
|
2650
|
+
}) => {
|
|
2651
|
+
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
2652
|
+
const ElementType = href ? "a" : "button";
|
|
2653
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2654
|
+
ElementType,
|
|
2655
|
+
{
|
|
2656
|
+
className: getClassName3({
|
|
2657
|
+
primary: variant === "primary",
|
|
2658
|
+
secondary: variant === "secondary",
|
|
2659
|
+
disabled,
|
|
2660
|
+
fullWidth
|
|
2661
|
+
}),
|
|
2662
|
+
onClick: (e) => {
|
|
2663
|
+
if (!onClick) return;
|
|
2664
|
+
setLoading(true);
|
|
2665
|
+
Promise.resolve(onClick(e)).then(() => {
|
|
2666
|
+
setLoading(false);
|
|
2667
|
+
});
|
|
2668
|
+
},
|
|
2669
|
+
type,
|
|
2670
|
+
disabled: disabled || loading,
|
|
2671
|
+
tabIndex,
|
|
2672
|
+
target: newTab ? "_blank" : void 0,
|
|
2673
|
+
rel: newTab ? "noreferrer" : void 0,
|
|
2674
|
+
href,
|
|
2675
|
+
title,
|
|
2676
|
+
children: [
|
|
2677
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: getClassName3("title"), children: title }),
|
|
2678
|
+
children,
|
|
2679
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2680
|
+
"\xA0\xA0",
|
|
2681
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Loader, { size: 14 })
|
|
2682
|
+
] })
|
|
2683
|
+
]
|
|
2684
|
+
}
|
|
2685
|
+
);
|
|
2686
|
+
return el;
|
|
2687
|
+
};
|
|
2688
|
+
|
|
2689
|
+
// components/AutoField/fields/ArrayField/index.tsx
|
|
2690
|
+
var import_react14 = require("react");
|
|
2691
|
+
|
|
2692
|
+
// components/DragIcon/index.tsx
|
|
2693
|
+
init_react_import();
|
|
2694
|
+
|
|
2695
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/DragIcon/styles.module.css#css-module
|
|
2696
|
+
init_react_import();
|
|
2697
|
+
var styles_module_default5 = { "DragIcon": "_DragIcon_17p8x_1", "DragIcon--disabled": "_DragIcon--disabled_17p8x_8" };
|
|
2698
|
+
|
|
2699
|
+
// components/DragIcon/index.tsx
|
|
2700
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2701
|
+
var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_default5);
|
|
2702
|
+
var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName4({ disabled: isDragDisabled }), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { viewBox: "0 0 20 20", width: "12", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }) }) });
|
|
2703
|
+
|
|
2704
|
+
// components/Sortable/index.tsx
|
|
2705
|
+
init_react_import();
|
|
2706
|
+
var import_react12 = require("@dnd-kit/react");
|
|
2707
|
+
|
|
2708
|
+
// lib/dnd/use-sensors.ts
|
|
2709
|
+
init_react_import();
|
|
2710
|
+
var import_react10 = require("react");
|
|
2711
|
+
var import_react11 = require("@dnd-kit/react");
|
|
2712
|
+
var import_utilities = require("@dnd-kit/dom/utilities");
|
|
2713
|
+
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
|
2714
|
+
var otherDefault = {
|
|
2715
|
+
delay: { value: 200, tolerance: 10 },
|
|
2716
|
+
distance: { value: 5 }
|
|
2717
|
+
};
|
|
2718
|
+
var useSensors = ({
|
|
2719
|
+
other = otherDefault,
|
|
2720
|
+
mouse,
|
|
2721
|
+
touch = touchDefault
|
|
2722
|
+
} = {
|
|
2723
|
+
touch: touchDefault,
|
|
2724
|
+
other: otherDefault
|
|
2725
|
+
}) => {
|
|
2726
|
+
const [sensors] = (0, import_react10.useState)(() => [
|
|
2727
|
+
import_react11.PointerSensor.configure({
|
|
2728
|
+
activationConstraints(event, source) {
|
|
2729
|
+
var _a;
|
|
2730
|
+
const { pointerType, target } = event;
|
|
2731
|
+
if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
|
2732
|
+
return mouse;
|
|
2733
|
+
}
|
|
2734
|
+
if (pointerType === "touch") {
|
|
2735
|
+
return touch;
|
|
2736
|
+
}
|
|
2737
|
+
return other;
|
|
2738
|
+
}
|
|
2739
|
+
})
|
|
2740
|
+
]);
|
|
2741
|
+
return sensors;
|
|
2742
|
+
};
|
|
2743
|
+
|
|
2744
|
+
// lib/dnd/collision/dynamic/index.ts
|
|
2745
|
+
init_react_import();
|
|
2746
|
+
var import_abstract8 = require("@dnd-kit/abstract");
|
|
2747
|
+
|
|
2748
|
+
// lib/dnd/collision/directional/index.ts
|
|
2749
|
+
init_react_import();
|
|
2750
|
+
var import_abstract = require("@dnd-kit/abstract");
|
|
2751
|
+
|
|
2752
|
+
// lib/dnd/collision/collision-debug.ts
|
|
2753
|
+
init_react_import();
|
|
2754
|
+
var DEBUG = false;
|
|
2755
|
+
var debugElements = {};
|
|
2756
|
+
var timeout;
|
|
2757
|
+
var collisionDebug = (a, b, id, color, label) => {
|
|
2758
|
+
if (!DEBUG) return;
|
|
2759
|
+
const debugId = `${id}-debug`;
|
|
2760
|
+
clearTimeout(timeout);
|
|
2761
|
+
timeout = setTimeout(() => {
|
|
2762
|
+
Object.entries(debugElements).forEach(([id2, { svg }]) => {
|
|
2763
|
+
svg.remove();
|
|
2764
|
+
delete debugElements[id2];
|
|
2765
|
+
});
|
|
2766
|
+
}, 1e3);
|
|
2767
|
+
requestAnimationFrame(() => {
|
|
2768
|
+
var _a, _b;
|
|
2769
|
+
const existingEl = debugElements[debugId];
|
|
2770
|
+
let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
|
|
2771
|
+
let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
|
|
2772
|
+
if (!existingEl) {
|
|
2773
|
+
const svgNs = "http://www.w3.org/2000/svg";
|
|
2774
|
+
const svg = document.createElementNS(svgNs, "svg");
|
|
2775
|
+
line = document.createElementNS(svgNs, "line");
|
|
2776
|
+
text = document.createElementNS(svgNs, "text");
|
|
2777
|
+
svg.setAttribute("id", debugId);
|
|
2778
|
+
svg.setAttribute(
|
|
2779
|
+
"style",
|
|
2780
|
+
"position: fixed; height: 100%; width: 100%; pointer-events: none; top: 0px; left: 0px;"
|
|
2781
|
+
);
|
|
2782
|
+
svg.appendChild(line);
|
|
2783
|
+
svg.appendChild(text);
|
|
2784
|
+
text.setAttribute("fill", `black`);
|
|
2785
|
+
document.body.appendChild(svg);
|
|
2786
|
+
debugElements[debugId] = { svg, line, text };
|
|
2787
|
+
}
|
|
2788
|
+
line.setAttribute("x1", a.x.toString());
|
|
2789
|
+
line.setAttribute("x2", b.x.toString());
|
|
2790
|
+
line.setAttribute("y1", a.y.toString());
|
|
2791
|
+
line.setAttribute("y2", b.y.toString());
|
|
2792
|
+
line.setAttribute("style", `stroke:${color};stroke-width:2`);
|
|
2793
|
+
text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
|
|
2794
|
+
text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
|
|
2795
|
+
if (label) {
|
|
2796
|
+
text.innerHTML = label;
|
|
2595
2797
|
}
|
|
2596
2798
|
});
|
|
2597
2799
|
};
|
|
@@ -3065,7 +3267,12 @@ var ArrayField = ({
|
|
|
3065
3267
|
return walkField({
|
|
3066
3268
|
value: val,
|
|
3067
3269
|
fields: field.arrayFields,
|
|
3068
|
-
|
|
3270
|
+
mappers: {
|
|
3271
|
+
slot: ({ value: value2 }) => {
|
|
3272
|
+
const content = value2;
|
|
3273
|
+
return content.map((item) => populateIds(item, config, true));
|
|
3274
|
+
}
|
|
3275
|
+
},
|
|
3069
3276
|
config
|
|
3070
3277
|
});
|
|
3071
3278
|
},
|
|
@@ -3220,49 +3427,51 @@ var ArrayField = ({
|
|
|
3220
3427
|
]
|
|
3221
3428
|
}
|
|
3222
3429
|
),
|
|
3223
|
-
/* @__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(
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
onChange(
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
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
|
+
}
|
|
3259
3468
|
}
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3469
|
+
)
|
|
3470
|
+
},
|
|
3471
|
+
subPath
|
|
3472
|
+
);
|
|
3473
|
+
}
|
|
3474
|
+
) }) })
|
|
3266
3475
|
]
|
|
3267
3476
|
}
|
|
3268
3477
|
)
|
|
@@ -3802,20 +4011,6 @@ var ExternalField = ({
|
|
|
3802
4011
|
|
|
3803
4012
|
// components/AutoField/fields/RadioField/index.tsx
|
|
3804
4013
|
init_react_import();
|
|
3805
|
-
var import_react19 = require("react");
|
|
3806
|
-
|
|
3807
|
-
// lib/safe-json-parse.ts
|
|
3808
|
-
init_react_import();
|
|
3809
|
-
var safeJsonParse = (str) => {
|
|
3810
|
-
try {
|
|
3811
|
-
const jsonValue = JSON.parse(str);
|
|
3812
|
-
return jsonValue;
|
|
3813
|
-
} catch (e) {
|
|
3814
|
-
return str;
|
|
3815
|
-
}
|
|
3816
|
-
};
|
|
3817
|
-
|
|
3818
|
-
// components/AutoField/fields/RadioField/index.tsx
|
|
3819
4014
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3820
4015
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
|
3821
4016
|
var RadioField = ({
|
|
@@ -3829,10 +4024,6 @@ var RadioField = ({
|
|
|
3829
4024
|
labelIcon,
|
|
3830
4025
|
Label: Label2
|
|
3831
4026
|
}) => {
|
|
3832
|
-
const flatOptions = (0, import_react19.useMemo)(
|
|
3833
|
-
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
3834
|
-
[field]
|
|
3835
|
-
);
|
|
3836
4027
|
if (field.type !== "radio" || !field.options) {
|
|
3837
4028
|
return null;
|
|
3838
4029
|
}
|
|
@@ -3843,43 +4034,39 @@ var RadioField = ({
|
|
|
3843
4034
|
label: label || name,
|
|
3844
4035
|
readOnly,
|
|
3845
4036
|
el: "div",
|
|
3846
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) =>
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
},
|
|
3874
|
-
option.label + option.value
|
|
3875
|
-
)) })
|
|
4037
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => {
|
|
4038
|
+
var _a;
|
|
4039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
4040
|
+
"label",
|
|
4041
|
+
{
|
|
4042
|
+
className: getClassName11("radio"),
|
|
4043
|
+
children: [
|
|
4044
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4045
|
+
"input",
|
|
4046
|
+
{
|
|
4047
|
+
type: "radio",
|
|
4048
|
+
className: getClassName11("radioInput"),
|
|
4049
|
+
value: JSON.stringify({ value: option.value }),
|
|
4050
|
+
name,
|
|
4051
|
+
onChange: (e) => {
|
|
4052
|
+
onChange(JSON.parse(e.target.value).value);
|
|
4053
|
+
},
|
|
4054
|
+
disabled: readOnly,
|
|
4055
|
+
checked: value === option.value
|
|
4056
|
+
}
|
|
4057
|
+
),
|
|
4058
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioInner"), children: option.label || ((_a = option.value) == null ? void 0 : _a.toString()) })
|
|
4059
|
+
]
|
|
4060
|
+
},
|
|
4061
|
+
option.label + option.value
|
|
4062
|
+
);
|
|
4063
|
+
}) })
|
|
3876
4064
|
}
|
|
3877
4065
|
);
|
|
3878
4066
|
};
|
|
3879
4067
|
|
|
3880
4068
|
// components/AutoField/fields/SelectField/index.tsx
|
|
3881
4069
|
init_react_import();
|
|
3882
|
-
var import_react20 = require("react");
|
|
3883
4070
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3884
4071
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
|
3885
4072
|
var SelectField = ({
|
|
@@ -3893,10 +4080,6 @@ var SelectField = ({
|
|
|
3893
4080
|
readOnly,
|
|
3894
4081
|
id
|
|
3895
4082
|
}) => {
|
|
3896
|
-
const flatOptions = (0, import_react20.useMemo)(
|
|
3897
|
-
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
3898
|
-
[field]
|
|
3899
|
-
);
|
|
3900
4083
|
if (field.type !== "select" || !field.options) {
|
|
3901
4084
|
return null;
|
|
3902
4085
|
}
|
|
@@ -3914,22 +4097,16 @@ var SelectField = ({
|
|
|
3914
4097
|
className: getClassName12("input"),
|
|
3915
4098
|
disabled: readOnly,
|
|
3916
4099
|
onChange: (e) => {
|
|
3917
|
-
|
|
3918
|
-
const jsonValue = (_a = safeJsonParse(e.target.value)) != null ? _a : e.target.value;
|
|
3919
|
-
if (flatOptions.indexOf(jsonValue) > -1) {
|
|
3920
|
-
onChange(jsonValue);
|
|
3921
|
-
} else {
|
|
3922
|
-
onChange(e.target.value);
|
|
3923
|
-
}
|
|
4100
|
+
onChange(JSON.parse(e.target.value).value);
|
|
3924
4101
|
},
|
|
3925
|
-
value,
|
|
4102
|
+
value: JSON.stringify({ value }),
|
|
3926
4103
|
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3927
4104
|
"option",
|
|
3928
4105
|
{
|
|
3929
4106
|
label: option.label,
|
|
3930
|
-
value: option.value
|
|
4107
|
+
value: JSON.stringify({ value: option.value })
|
|
3931
4108
|
},
|
|
3932
|
-
option.label + option.value
|
|
4109
|
+
option.label + JSON.stringify(option.value)
|
|
3933
4110
|
))
|
|
3934
4111
|
}
|
|
3935
4112
|
)
|
|
@@ -4053,12 +4230,12 @@ var ObjectField = ({
|
|
|
4053
4230
|
|
|
4054
4231
|
// lib/use-safe-id.ts
|
|
4055
4232
|
init_react_import();
|
|
4056
|
-
var
|
|
4233
|
+
var import_react19 = __toESM(require("react"));
|
|
4057
4234
|
var useSafeId = () => {
|
|
4058
|
-
if (typeof
|
|
4059
|
-
return
|
|
4235
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
|
4236
|
+
return import_react19.default.useId();
|
|
4060
4237
|
}
|
|
4061
|
-
const [id] = (0,
|
|
4238
|
+
const [id] = (0, import_react19.useState)(generateId());
|
|
4062
4239
|
return id;
|
|
4063
4240
|
};
|
|
4064
4241
|
|
|
@@ -4092,7 +4269,7 @@ var FieldLabelInternal = ({
|
|
|
4092
4269
|
readOnly
|
|
4093
4270
|
}) => {
|
|
4094
4271
|
const overrides = useAppStore((s) => s.overrides);
|
|
4095
|
-
const Wrapper = (0,
|
|
4272
|
+
const Wrapper = (0, import_react20.useMemo)(
|
|
4096
4273
|
() => overrides.fieldLabel || FieldLabel,
|
|
4097
4274
|
[overrides]
|
|
4098
4275
|
);
|
|
@@ -4119,7 +4296,7 @@ function AutoFieldInternal(props) {
|
|
|
4119
4296
|
var _a2;
|
|
4120
4297
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
|
4121
4298
|
});
|
|
4122
|
-
const nestedFieldContext = (0,
|
|
4299
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
|
4123
4300
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
|
4124
4301
|
const field = props.field;
|
|
4125
4302
|
const label = field.label;
|
|
@@ -4153,7 +4330,7 @@ function AutoFieldInternal(props) {
|
|
|
4153
4330
|
Label: Label2,
|
|
4154
4331
|
id: resolvedId
|
|
4155
4332
|
});
|
|
4156
|
-
const onFocus = (0,
|
|
4333
|
+
const onFocus = (0, import_react20.useCallback)(
|
|
4157
4334
|
(e) => {
|
|
4158
4335
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
4159
4336
|
e.stopPropagation();
|
|
@@ -4167,7 +4344,7 @@ function AutoFieldInternal(props) {
|
|
|
4167
4344
|
},
|
|
4168
4345
|
[mergedProps.name]
|
|
4169
4346
|
);
|
|
4170
|
-
const onBlur = (0,
|
|
4347
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
|
4171
4348
|
if ("name" in e.target) {
|
|
4172
4349
|
dispatch({
|
|
4173
4350
|
type: "setUi",
|
|
@@ -4220,20 +4397,20 @@ function AutoFieldInternal(props) {
|
|
|
4220
4397
|
function AutoFieldPrivate(props) {
|
|
4221
4398
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
|
4222
4399
|
const { value, onChange } = props;
|
|
4223
|
-
const [localValue, setLocalValue] = (0,
|
|
4224
|
-
const onChangeLocal = (0,
|
|
4400
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
|
4401
|
+
const onChangeLocal = (0, import_react20.useCallback)(
|
|
4225
4402
|
(val, ui) => {
|
|
4226
4403
|
setLocalValue(val);
|
|
4227
4404
|
onChange(val, ui);
|
|
4228
4405
|
},
|
|
4229
4406
|
[onChange]
|
|
4230
4407
|
);
|
|
4231
|
-
(0,
|
|
4408
|
+
(0, import_react20.useEffect)(() => {
|
|
4232
4409
|
if (!isFocused) {
|
|
4233
4410
|
setLocalValue(value);
|
|
4234
4411
|
}
|
|
4235
4412
|
}, [value]);
|
|
4236
|
-
(0,
|
|
4413
|
+
(0, import_react20.useEffect)(() => {
|
|
4237
4414
|
if (!isFocused) {
|
|
4238
4415
|
if (value !== localValue) {
|
|
4239
4416
|
setLocalValue(value);
|
|
@@ -4247,7 +4424,7 @@ function AutoFieldPrivate(props) {
|
|
|
4247
4424
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
|
4248
4425
|
}
|
|
4249
4426
|
function AutoField(props) {
|
|
4250
|
-
const DefaultLabel = (0,
|
|
4427
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
|
4251
4428
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4252
4429
|
"div",
|
|
4253
4430
|
__spreadProps(__spreadValues({}, labelProps), {
|
|
@@ -4270,25 +4447,25 @@ init_react_import();
|
|
|
4270
4447
|
var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
|
|
4271
4448
|
|
|
4272
4449
|
// components/Drawer/index.tsx
|
|
4273
|
-
var
|
|
4450
|
+
var import_react38 = require("react");
|
|
4274
4451
|
|
|
4275
4452
|
// components/DragDropContext/index.tsx
|
|
4276
4453
|
init_react_import();
|
|
4277
|
-
var
|
|
4278
|
-
var
|
|
4454
|
+
var import_react36 = require("@dnd-kit/react");
|
|
4455
|
+
var import_react37 = require("react");
|
|
4279
4456
|
var import_dom = require("@dnd-kit/dom");
|
|
4280
4457
|
|
|
4281
4458
|
// components/DropZone/index.tsx
|
|
4282
4459
|
init_react_import();
|
|
4283
|
-
var
|
|
4460
|
+
var import_react34 = require("react");
|
|
4284
4461
|
|
|
4285
4462
|
// components/DraggableComponent/index.tsx
|
|
4286
4463
|
init_react_import();
|
|
4287
|
-
var
|
|
4464
|
+
var import_react24 = require("react");
|
|
4288
4465
|
|
|
4289
4466
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4290
4467
|
init_react_import();
|
|
4291
|
-
var styles_module_default11 = { "DraggableComponent": "
|
|
4468
|
+
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1vaqy_1", "DraggableComponent-overlayWrapper": "_DraggableComponent-overlayWrapper_1vaqy_12", "DraggableComponent-overlay": "_DraggableComponent-overlay_1vaqy_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1vaqy_34", "DraggableComponent--hover": "_DraggableComponent--hover_1vaqy_50", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1vaqy_57", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1vaqy_71", "DraggableComponent-actions": "_DraggableComponent-actions_1vaqy_71" };
|
|
4292
4469
|
|
|
4293
4470
|
// components/DraggableComponent/index.tsx
|
|
4294
4471
|
var import_react_dom2 = require("react-dom");
|
|
@@ -4314,11 +4491,11 @@ function getDeepScrollPosition(element) {
|
|
|
4314
4491
|
|
|
4315
4492
|
// components/DropZone/context.tsx
|
|
4316
4493
|
init_react_import();
|
|
4317
|
-
var
|
|
4494
|
+
var import_react21 = require("react");
|
|
4318
4495
|
var import_zustand3 = require("zustand");
|
|
4319
4496
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4320
|
-
var dropZoneContext = (0,
|
|
4321
|
-
var ZoneStoreContext = (0,
|
|
4497
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
|
4498
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
|
4322
4499
|
(0, import_zustand3.createStore)(() => ({
|
|
4323
4500
|
zoneDepthIndex: {},
|
|
4324
4501
|
nextZoneDepthIndex: {},
|
|
@@ -4341,7 +4518,7 @@ var DropZoneProvider = ({
|
|
|
4341
4518
|
value
|
|
4342
4519
|
}) => {
|
|
4343
4520
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4344
|
-
const registerZone = (0,
|
|
4521
|
+
const registerZone = (0, import_react21.useCallback)(
|
|
4345
4522
|
(zoneCompound) => {
|
|
4346
4523
|
dispatch({
|
|
4347
4524
|
type: "registerZone",
|
|
@@ -4350,19 +4527,9 @@ var DropZoneProvider = ({
|
|
|
4350
4527
|
},
|
|
4351
4528
|
[dispatch]
|
|
4352
4529
|
);
|
|
4353
|
-
const
|
|
4354
|
-
(zoneCompound) => {
|
|
4355
|
-
dispatch({
|
|
4356
|
-
type: "unregisterZone",
|
|
4357
|
-
zone: zoneCompound
|
|
4358
|
-
});
|
|
4359
|
-
},
|
|
4360
|
-
[dispatch]
|
|
4361
|
-
);
|
|
4362
|
-
const memoValue = (0, import_react23.useMemo)(
|
|
4530
|
+
const memoValue = (0, import_react21.useMemo)(
|
|
4363
4531
|
() => __spreadValues({
|
|
4364
|
-
registerZone
|
|
4365
|
-
unregisterZone
|
|
4532
|
+
registerZone
|
|
4366
4533
|
}, value),
|
|
4367
4534
|
[value]
|
|
4368
4535
|
);
|
|
@@ -4390,11 +4557,11 @@ function accumulateTransform(el) {
|
|
|
4390
4557
|
|
|
4391
4558
|
// lib/use-context-store.ts
|
|
4392
4559
|
init_react_import();
|
|
4393
|
-
var
|
|
4560
|
+
var import_react22 = require("react");
|
|
4394
4561
|
var import_zustand4 = require("zustand");
|
|
4395
4562
|
var import_shallow = require("zustand/react/shallow");
|
|
4396
4563
|
function useContextStore(context, selector) {
|
|
4397
|
-
const store = (0,
|
|
4564
|
+
const store = (0, import_react22.useContext)(context);
|
|
4398
4565
|
if (!store) {
|
|
4399
4566
|
throw new Error("useContextStore must be used inside context");
|
|
4400
4567
|
}
|
|
@@ -4403,10 +4570,10 @@ function useContextStore(context, selector) {
|
|
|
4403
4570
|
|
|
4404
4571
|
// lib/dnd/use-on-drag-finished.ts
|
|
4405
4572
|
init_react_import();
|
|
4406
|
-
var
|
|
4573
|
+
var import_react23 = require("react");
|
|
4407
4574
|
var useOnDragFinished = (cb, deps = []) => {
|
|
4408
4575
|
const appStore = useAppStoreApi();
|
|
4409
|
-
return (0,
|
|
4576
|
+
return (0, import_react23.useCallback)(() => {
|
|
4410
4577
|
let dispose = () => {
|
|
4411
4578
|
};
|
|
4412
4579
|
const processDragging = (isDragging2) => {
|
|
@@ -4452,6 +4619,9 @@ var DefaultActionBar = ({
|
|
|
4452
4619
|
] }),
|
|
4453
4620
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
|
|
4454
4621
|
] });
|
|
4622
|
+
var DefaultOverlay = ({
|
|
4623
|
+
children
|
|
4624
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children });
|
|
4455
4625
|
var DraggableComponent = ({
|
|
4456
4626
|
children,
|
|
4457
4627
|
depth,
|
|
@@ -4476,9 +4646,9 @@ var DraggableComponent = ({
|
|
|
4476
4646
|
const overrides = useAppStore((s) => s.overrides);
|
|
4477
4647
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4478
4648
|
const iframe = useAppStore((s) => s.iframe);
|
|
4479
|
-
const ctx = (0,
|
|
4480
|
-
const [localZones, setLocalZones] = (0,
|
|
4481
|
-
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)(
|
|
4482
4652
|
(zoneCompound2, active) => {
|
|
4483
4653
|
var _a;
|
|
4484
4654
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
|
@@ -4488,7 +4658,7 @@ var DraggableComponent = ({
|
|
|
4488
4658
|
},
|
|
4489
4659
|
[setLocalZones]
|
|
4490
4660
|
);
|
|
4491
|
-
const unregisterLocalZone = (0,
|
|
4661
|
+
const unregisterLocalZone = (0, import_react24.useCallback)(
|
|
4492
4662
|
(zoneCompound2) => {
|
|
4493
4663
|
var _a;
|
|
4494
4664
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
|
@@ -4511,9 +4681,9 @@ var DraggableComponent = ({
|
|
|
4511
4681
|
return s.permissions.getPermissions({ item });
|
|
4512
4682
|
})
|
|
4513
4683
|
);
|
|
4514
|
-
const zoneStore = (0,
|
|
4515
|
-
const [dragAxis, setDragAxis] = (0,
|
|
4516
|
-
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)(
|
|
4517
4687
|
() => createDynamicCollisionDetector(dragAxis),
|
|
4518
4688
|
[dragAxis]
|
|
4519
4689
|
);
|
|
@@ -4545,7 +4715,7 @@ var DraggableComponent = ({
|
|
|
4545
4715
|
},
|
|
4546
4716
|
feedback: "clone"
|
|
4547
4717
|
});
|
|
4548
|
-
(0,
|
|
4718
|
+
(0, import_react24.useEffect)(() => {
|
|
4549
4719
|
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
|
4550
4720
|
sortable.droppable.disabled = !isEnabled;
|
|
4551
4721
|
sortable.draggable.disabled = !permissions.drag;
|
|
@@ -4562,8 +4732,8 @@ var DraggableComponent = ({
|
|
|
4562
4732
|
}
|
|
4563
4733
|
return cleanup;
|
|
4564
4734
|
}, [permissions.drag, zoneCompound]);
|
|
4565
|
-
const ref = (0,
|
|
4566
|
-
const refSetter = (0,
|
|
4735
|
+
const ref = (0, import_react24.useRef)(null);
|
|
4736
|
+
const refSetter = (0, import_react24.useCallback)(
|
|
4567
4737
|
(el) => {
|
|
4568
4738
|
sortableRef(el);
|
|
4569
4739
|
if (el) {
|
|
@@ -4572,14 +4742,14 @@ var DraggableComponent = ({
|
|
|
4572
4742
|
},
|
|
4573
4743
|
[sortableRef]
|
|
4574
4744
|
);
|
|
4575
|
-
const [portalEl, setPortalEl] = (0,
|
|
4576
|
-
(0,
|
|
4745
|
+
const [portalEl, setPortalEl] = (0, import_react24.useState)();
|
|
4746
|
+
(0, import_react24.useEffect)(() => {
|
|
4577
4747
|
var _a, _b, _c;
|
|
4578
4748
|
setPortalEl(
|
|
4579
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
|
|
4580
4750
|
);
|
|
4581
4751
|
}, [iframe.enabled, ref.current]);
|
|
4582
|
-
const getStyle = (0,
|
|
4752
|
+
const getStyle = (0, import_react24.useCallback)(() => {
|
|
4583
4753
|
var _a, _b, _c;
|
|
4584
4754
|
if (!ref.current) return;
|
|
4585
4755
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4604,11 +4774,11 @@ var DraggableComponent = ({
|
|
|
4604
4774
|
};
|
|
4605
4775
|
return style2;
|
|
4606
4776
|
}, [ref.current]);
|
|
4607
|
-
const [style, setStyle] = (0,
|
|
4608
|
-
const sync = (0,
|
|
4777
|
+
const [style, setStyle] = (0, import_react24.useState)();
|
|
4778
|
+
const sync = (0, import_react24.useCallback)(() => {
|
|
4609
4779
|
setStyle(getStyle());
|
|
4610
4780
|
}, [ref.current, iframe]);
|
|
4611
|
-
(0,
|
|
4781
|
+
(0, import_react24.useEffect)(() => {
|
|
4612
4782
|
if (ref.current) {
|
|
4613
4783
|
const observer = new ResizeObserver(sync);
|
|
4614
4784
|
observer.observe(ref.current);
|
|
@@ -4618,13 +4788,13 @@ var DraggableComponent = ({
|
|
|
4618
4788
|
}
|
|
4619
4789
|
}, [ref.current]);
|
|
4620
4790
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
|
4621
|
-
const hideOverlay = (0,
|
|
4791
|
+
const hideOverlay = (0, import_react24.useCallback)(() => {
|
|
4622
4792
|
setIsVisible(false);
|
|
4623
4793
|
}, []);
|
|
4624
|
-
const showOverlay = (0,
|
|
4794
|
+
const showOverlay = (0, import_react24.useCallback)(() => {
|
|
4625
4795
|
setIsVisible(true);
|
|
4626
4796
|
}, []);
|
|
4627
|
-
(0,
|
|
4797
|
+
(0, import_react24.useEffect)(() => {
|
|
4628
4798
|
var _a;
|
|
4629
4799
|
registerNode(id, {
|
|
4630
4800
|
methods: { sync, showOverlay, hideOverlay },
|
|
@@ -4641,13 +4811,20 @@ var DraggableComponent = ({
|
|
|
4641
4811
|
});
|
|
4642
4812
|
};
|
|
4643
4813
|
}, [id, zoneCompound, index, componentType, sync]);
|
|
4644
|
-
const CustomActionBar = (0,
|
|
4814
|
+
const CustomActionBar = (0, import_react24.useMemo)(
|
|
4645
4815
|
() => overrides.actionBar || DefaultActionBar,
|
|
4646
4816
|
[overrides.actionBar]
|
|
4647
4817
|
);
|
|
4648
|
-
const
|
|
4818
|
+
const CustomOverlay = (0, import_react24.useMemo)(
|
|
4819
|
+
() => overrides.componentOverlay || DefaultOverlay,
|
|
4820
|
+
[overrides.componentOverlay]
|
|
4821
|
+
);
|
|
4822
|
+
const onClick = (0, import_react24.useCallback)(
|
|
4649
4823
|
(e) => {
|
|
4650
|
-
e.
|
|
4824
|
+
const el = e.target;
|
|
4825
|
+
if (!el.closest("[data-puck-overlay-portal]")) {
|
|
4826
|
+
e.stopPropagation();
|
|
4827
|
+
}
|
|
4651
4828
|
dispatch({
|
|
4652
4829
|
type: "setUi",
|
|
4653
4830
|
ui: {
|
|
@@ -4658,7 +4835,7 @@ var DraggableComponent = ({
|
|
|
4658
4835
|
[index, zoneCompound, id]
|
|
4659
4836
|
);
|
|
4660
4837
|
const appStore = useAppStoreApi();
|
|
4661
|
-
const onSelectParent = (0,
|
|
4838
|
+
const onSelectParent = (0, import_react24.useCallback)(() => {
|
|
4662
4839
|
const { nodes, zones } = appStore.getState().state.indexes;
|
|
4663
4840
|
const node = nodes[id];
|
|
4664
4841
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
|
@@ -4679,26 +4856,26 @@ var DraggableComponent = ({
|
|
|
4679
4856
|
}
|
|
4680
4857
|
});
|
|
4681
4858
|
}, [ctx, path]);
|
|
4682
|
-
const onDuplicate = (0,
|
|
4859
|
+
const onDuplicate = (0, import_react24.useCallback)(() => {
|
|
4683
4860
|
dispatch({
|
|
4684
4861
|
type: "duplicate",
|
|
4685
4862
|
sourceIndex: index,
|
|
4686
4863
|
sourceZone: zoneCompound
|
|
4687
4864
|
});
|
|
4688
4865
|
}, [index, zoneCompound]);
|
|
4689
|
-
const onDelete = (0,
|
|
4866
|
+
const onDelete = (0, import_react24.useCallback)(() => {
|
|
4690
4867
|
dispatch({
|
|
4691
4868
|
type: "remove",
|
|
4692
4869
|
index,
|
|
4693
4870
|
zone: zoneCompound
|
|
4694
4871
|
});
|
|
4695
4872
|
}, [index, zoneCompound]);
|
|
4696
|
-
const [hover, setHover] = (0,
|
|
4873
|
+
const [hover, setHover] = (0, import_react24.useState)(false);
|
|
4697
4874
|
const indicativeHover = useContextStore(
|
|
4698
4875
|
ZoneStoreContext,
|
|
4699
4876
|
(s) => s.hoveringComponent === id
|
|
4700
4877
|
);
|
|
4701
|
-
(0,
|
|
4878
|
+
(0, import_react24.useEffect)(() => {
|
|
4702
4879
|
if (!ref.current) {
|
|
4703
4880
|
return;
|
|
4704
4881
|
}
|
|
@@ -4734,7 +4911,8 @@ var DraggableComponent = ({
|
|
|
4734
4911
|
el.removeEventListener("mouseout", _onMouseOut);
|
|
4735
4912
|
};
|
|
4736
4913
|
}, [
|
|
4737
|
-
ref,
|
|
4914
|
+
ref.current,
|
|
4915
|
+
// Remount attributes if the element changes
|
|
4738
4916
|
onClick,
|
|
4739
4917
|
containsActiveZone,
|
|
4740
4918
|
zoneCompound,
|
|
@@ -4742,10 +4920,10 @@ var DraggableComponent = ({
|
|
|
4742
4920
|
thisIsDragging,
|
|
4743
4921
|
inDroppableZone
|
|
4744
4922
|
]);
|
|
4745
|
-
const [isVisible, setIsVisible] = (0,
|
|
4746
|
-
const [dragFinished, setDragFinished] = (0,
|
|
4747
|
-
const [_, startTransition] = (0,
|
|
4748
|
-
(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)(() => {
|
|
4749
4927
|
startTransition(() => {
|
|
4750
4928
|
if (hover || indicativeHover || isSelected) {
|
|
4751
4929
|
sync();
|
|
@@ -4756,7 +4934,7 @@ var DraggableComponent = ({
|
|
|
4756
4934
|
}
|
|
4757
4935
|
});
|
|
4758
4936
|
}, [hover, indicativeHover, isSelected, iframe]);
|
|
4759
|
-
const [thisWasDragging, setThisWasDragging] = (0,
|
|
4937
|
+
const [thisWasDragging, setThisWasDragging] = (0, import_react24.useState)(false);
|
|
4760
4938
|
const onDragFinished = useOnDragFinished((finished) => {
|
|
4761
4939
|
if (finished) {
|
|
4762
4940
|
startTransition(() => {
|
|
@@ -4767,15 +4945,15 @@ var DraggableComponent = ({
|
|
|
4767
4945
|
setDragFinished(false);
|
|
4768
4946
|
}
|
|
4769
4947
|
});
|
|
4770
|
-
(0,
|
|
4948
|
+
(0, import_react24.useEffect)(() => {
|
|
4771
4949
|
if (thisIsDragging) {
|
|
4772
4950
|
setThisWasDragging(true);
|
|
4773
4951
|
}
|
|
4774
4952
|
}, [thisIsDragging]);
|
|
4775
|
-
(0,
|
|
4953
|
+
(0, import_react24.useEffect)(() => {
|
|
4776
4954
|
if (thisWasDragging) return onDragFinished();
|
|
4777
4955
|
}, [thisWasDragging, onDragFinished]);
|
|
4778
|
-
const syncActionsPosition = (0,
|
|
4956
|
+
const syncActionsPosition = (0, import_react24.useCallback)(
|
|
4779
4957
|
(el) => {
|
|
4780
4958
|
if (el) {
|
|
4781
4959
|
const view = el.ownerDocument.defaultView;
|
|
@@ -4800,7 +4978,7 @@ var DraggableComponent = ({
|
|
|
4800
4978
|
},
|
|
4801
4979
|
[zoom]
|
|
4802
4980
|
);
|
|
4803
|
-
(0,
|
|
4981
|
+
(0, import_react24.useEffect)(() => {
|
|
4804
4982
|
if (userDragAxis) {
|
|
4805
4983
|
setDragAxis(userDragAxis);
|
|
4806
4984
|
return;
|
|
@@ -4814,11 +4992,11 @@ var DraggableComponent = ({
|
|
|
4814
4992
|
}
|
|
4815
4993
|
setDragAxis(autoDragAxis);
|
|
4816
4994
|
}, [ref, userDragAxis, autoDragAxis]);
|
|
4817
|
-
const parentAction = (0,
|
|
4995
|
+
const parentAction = (0, import_react24.useMemo)(
|
|
4818
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 }) }),
|
|
4819
4997
|
[ctx == null ? void 0 : ctx.areaId]
|
|
4820
4998
|
);
|
|
4821
|
-
const nextContextValue = (0,
|
|
4999
|
+
const nextContextValue = (0, import_react24.useMemo)(
|
|
4822
5000
|
() => __spreadProps(__spreadValues({}, ctx), {
|
|
4823
5001
|
areaId: id,
|
|
4824
5002
|
zoneCompound,
|
|
@@ -4886,7 +5064,16 @@ var DraggableComponent = ({
|
|
|
4886
5064
|
)
|
|
4887
5065
|
}
|
|
4888
5066
|
),
|
|
4889
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("
|
|
5067
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlayWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5068
|
+
CustomOverlay,
|
|
5069
|
+
{
|
|
5070
|
+
componentId: id,
|
|
5071
|
+
componentType,
|
|
5072
|
+
hover,
|
|
5073
|
+
isSelected,
|
|
5074
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
|
5075
|
+
}
|
|
5076
|
+
) })
|
|
4890
5077
|
]
|
|
4891
5078
|
}
|
|
4892
5079
|
),
|
|
@@ -4901,11 +5088,11 @@ init_react_import();
|
|
|
4901
5088
|
var styles_module_default12 = { "DropZone": "_DropZone_1i2sv_1", "DropZone--hasChildren": "_DropZone--hasChildren_1i2sv_11", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1i2sv_24", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1i2sv_25", "DropZone--isRootZone": "_DropZone--isRootZone_1i2sv_25", "DropZone--isDestination": "_DropZone--isDestination_1i2sv_35", "DropZone-item": "_DropZone-item_1i2sv_47", "DropZone-hitbox": "_DropZone-hitbox_1i2sv_51", "DropZone--isEnabled": "_DropZone--isEnabled_1i2sv_59", "DropZone--isAnimating": "_DropZone--isAnimating_1i2sv_68" };
|
|
4902
5089
|
|
|
4903
5090
|
// components/DropZone/index.tsx
|
|
4904
|
-
var
|
|
5091
|
+
var import_react35 = require("@dnd-kit/react");
|
|
4905
5092
|
|
|
4906
5093
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
4907
5094
|
init_react_import();
|
|
4908
|
-
var
|
|
5095
|
+
var import_react25 = require("react");
|
|
4909
5096
|
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
|
4910
5097
|
var useMinEmptyHeight = ({
|
|
4911
5098
|
zoneCompound,
|
|
@@ -4913,8 +5100,8 @@ var useMinEmptyHeight = ({
|
|
|
4913
5100
|
ref
|
|
4914
5101
|
}) => {
|
|
4915
5102
|
const appStore = useAppStoreApi();
|
|
4916
|
-
const [prevHeight, setPrevHeight] = (0,
|
|
4917
|
-
const [isAnimating, setIsAnimating] = (0,
|
|
5103
|
+
const [prevHeight, setPrevHeight] = (0, import_react25.useState)(0);
|
|
5104
|
+
const [isAnimating, setIsAnimating] = (0, import_react25.useState)(false);
|
|
4918
5105
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
|
4919
5106
|
var _a, _b;
|
|
4920
5107
|
return {
|
|
@@ -4922,7 +5109,7 @@ var useMinEmptyHeight = ({
|
|
|
4922
5109
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
|
4923
5110
|
};
|
|
4924
5111
|
});
|
|
4925
|
-
const numItems = (0,
|
|
5112
|
+
const numItems = (0, import_react25.useRef)(0);
|
|
4926
5113
|
const onDragFinished = useOnDragFinished(
|
|
4927
5114
|
(finished) => {
|
|
4928
5115
|
var _a;
|
|
@@ -4957,7 +5144,7 @@ var useMinEmptyHeight = ({
|
|
|
4957
5144
|
},
|
|
4958
5145
|
[appStore, prevHeight, zoneCompound]
|
|
4959
5146
|
);
|
|
4960
|
-
(0,
|
|
5147
|
+
(0, import_react25.useEffect)(() => {
|
|
4961
5148
|
if (draggedItem && ref.current) {
|
|
4962
5149
|
if (isZone) {
|
|
4963
5150
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4988,15 +5175,15 @@ function assignRefs(refs, node) {
|
|
|
4988
5175
|
|
|
4989
5176
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
4990
5177
|
init_react_import();
|
|
4991
|
-
var
|
|
5178
|
+
var import_react28 = require("react");
|
|
4992
5179
|
|
|
4993
5180
|
// lib/dnd/use-rendered-callback.ts
|
|
4994
5181
|
init_react_import();
|
|
4995
|
-
var
|
|
4996
|
-
var
|
|
5182
|
+
var import_react26 = require("@dnd-kit/react");
|
|
5183
|
+
var import_react27 = require("react");
|
|
4997
5184
|
function useRenderedCallback(callback, deps) {
|
|
4998
|
-
const manager = (0,
|
|
4999
|
-
return (0,
|
|
5185
|
+
const manager = (0, import_react26.useDragDropManager)();
|
|
5186
|
+
return (0, import_react27.useCallback)(
|
|
5000
5187
|
(...args) => __async(this, null, function* () {
|
|
5001
5188
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
|
5002
5189
|
return callback(...args);
|
|
@@ -5007,14 +5194,14 @@ function useRenderedCallback(callback, deps) {
|
|
|
5007
5194
|
|
|
5008
5195
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5009
5196
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
5010
|
-
const zoneStore = (0,
|
|
5197
|
+
const zoneStore = (0, import_react28.useContext)(ZoneStoreContext);
|
|
5011
5198
|
const preview = useContextStore(
|
|
5012
5199
|
ZoneStoreContext,
|
|
5013
5200
|
(s) => s.previewIndex[zoneCompound]
|
|
5014
5201
|
);
|
|
5015
5202
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
|
5016
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
|
5017
|
-
const [localPreview, setLocalPreview] = (0,
|
|
5203
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react28.useState)(contentIds);
|
|
5204
|
+
const [localPreview, setLocalPreview] = (0, import_react28.useState)(
|
|
5018
5205
|
preview
|
|
5019
5206
|
);
|
|
5020
5207
|
const updateContent = useRenderedCallback(
|
|
@@ -5049,7 +5236,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5049
5236
|
},
|
|
5050
5237
|
[]
|
|
5051
5238
|
);
|
|
5052
|
-
(0,
|
|
5239
|
+
(0, import_react28.useEffect)(() => {
|
|
5053
5240
|
var _a;
|
|
5054
5241
|
const s = zoneStore.getState();
|
|
5055
5242
|
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
|
@@ -5067,16 +5254,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5067
5254
|
|
|
5068
5255
|
// components/DropZone/lib/use-drag-axis.ts
|
|
5069
5256
|
init_react_import();
|
|
5070
|
-
var
|
|
5257
|
+
var import_react29 = require("react");
|
|
5071
5258
|
var GRID_DRAG_AXIS = "dynamic";
|
|
5072
5259
|
var FLEX_ROW_DRAG_AXIS = "x";
|
|
5073
5260
|
var DEFAULT_DRAG_AXIS = "y";
|
|
5074
5261
|
var useDragAxis = (ref, collisionAxis) => {
|
|
5075
5262
|
const status = useAppStore((s) => s.status);
|
|
5076
|
-
const [dragAxis, setDragAxis] = (0,
|
|
5263
|
+
const [dragAxis, setDragAxis] = (0, import_react29.useState)(
|
|
5077
5264
|
collisionAxis || DEFAULT_DRAG_AXIS
|
|
5078
5265
|
);
|
|
5079
|
-
const calculateDragAxis = (0,
|
|
5266
|
+
const calculateDragAxis = (0, import_react29.useCallback)(() => {
|
|
5080
5267
|
if (ref.current) {
|
|
5081
5268
|
const computedStyle = window.getComputedStyle(ref.current);
|
|
5082
5269
|
if (computedStyle.display === "grid") {
|
|
@@ -5088,7 +5275,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5088
5275
|
}
|
|
5089
5276
|
}
|
|
5090
5277
|
}, [ref.current]);
|
|
5091
|
-
(0,
|
|
5278
|
+
(0, import_react29.useEffect)(() => {
|
|
5092
5279
|
const onViewportChange = () => {
|
|
5093
5280
|
calculateDragAxis();
|
|
5094
5281
|
};
|
|
@@ -5097,7 +5284,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5097
5284
|
window.removeEventListener("viewportchange", onViewportChange);
|
|
5098
5285
|
};
|
|
5099
5286
|
}, []);
|
|
5100
|
-
(0,
|
|
5287
|
+
(0, import_react29.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
|
5101
5288
|
return [dragAxis, calculateDragAxis];
|
|
5102
5289
|
};
|
|
5103
5290
|
|
|
@@ -5109,37 +5296,72 @@ init_react_import();
|
|
|
5109
5296
|
|
|
5110
5297
|
// lib/use-slots.tsx
|
|
5111
5298
|
init_react_import();
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
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;
|
|
5132
5327
|
return mapped;
|
|
5133
|
-
}, [config, item,
|
|
5134
|
-
const mergedProps = (0,
|
|
5135
|
-
() => __spreadValues(__spreadValues({}, item.props),
|
|
5136
|
-
[item.props,
|
|
5328
|
+
}, [config, item, mappers]);
|
|
5329
|
+
const mergedProps = (0, import_react30.useMemo)(
|
|
5330
|
+
() => __spreadValues(__spreadValues({}, item.props), transformedProps),
|
|
5331
|
+
[item.props, transformedProps]
|
|
5137
5332
|
);
|
|
5138
5333
|
return mergedProps;
|
|
5139
5334
|
}
|
|
5140
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
|
+
|
|
5141
5363
|
// components/Render/index.tsx
|
|
5142
|
-
var
|
|
5364
|
+
var import_react32 = __toESM(require("react"));
|
|
5143
5365
|
|
|
5144
5366
|
// components/SlotRender/index.tsx
|
|
5145
5367
|
init_react_import();
|
|
@@ -5147,7 +5369,7 @@ var import_shallow3 = require("zustand/react/shallow");
|
|
|
5147
5369
|
|
|
5148
5370
|
// components/SlotRender/server.tsx
|
|
5149
5371
|
init_react_import();
|
|
5150
|
-
var
|
|
5372
|
+
var import_react31 = require("react");
|
|
5151
5373
|
|
|
5152
5374
|
// components/ServerRender/index.tsx
|
|
5153
5375
|
init_react_import();
|
|
@@ -5216,7 +5438,7 @@ var Item = ({
|
|
|
5216
5438
|
})
|
|
5217
5439
|
);
|
|
5218
5440
|
};
|
|
5219
|
-
var SlotRender = (0,
|
|
5441
|
+
var SlotRender = (0, import_react31.forwardRef)(
|
|
5220
5442
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5221
5443
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5222
5444
|
if (!config.components[item.type]) {
|
|
@@ -5264,7 +5486,7 @@ var ContextSlotRender = ({
|
|
|
5264
5486
|
|
|
5265
5487
|
// components/Render/index.tsx
|
|
5266
5488
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
5267
|
-
var renderContext =
|
|
5489
|
+
var renderContext = import_react32.default.createContext({
|
|
5268
5490
|
config: { components: {} },
|
|
5269
5491
|
data: { root: {}, content: [] },
|
|
5270
5492
|
metadata: {}
|
|
@@ -5297,7 +5519,7 @@ function Render({
|
|
|
5297
5519
|
{ type: "root", props: pageProps },
|
|
5298
5520
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
|
5299
5521
|
);
|
|
5300
|
-
const nextContextValue = (0,
|
|
5522
|
+
const nextContextValue = (0, import_react32.useMemo)(
|
|
5301
5523
|
() => ({
|
|
5302
5524
|
mode: "render",
|
|
5303
5525
|
depth: 0
|
|
@@ -5307,15 +5529,242 @@ function Render({
|
|
|
5307
5529
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
|
5308
5530
|
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)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneRenderPure, { zone: rootZone }) })) }) });
|
|
5309
5531
|
}
|
|
5310
|
-
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 }) }) });
|
|
5311
|
-
}
|
|
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 }) }) });
|
|
5533
|
+
}
|
|
5534
|
+
|
|
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
|
|
5629
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
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
|
+
});
|
|
5312
5761
|
|
|
5313
5762
|
// components/DropZone/index.tsx
|
|
5314
|
-
var
|
|
5315
|
-
var
|
|
5763
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
5764
|
+
var getClassName18 = get_class_name_factory_default("DropZone", styles_module_default12);
|
|
5316
5765
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
|
5317
5766
|
var RENDER_DEBUG = false;
|
|
5318
|
-
var DropZoneEditPure = (props) => /* @__PURE__ */ (0,
|
|
5767
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneEdit, __spreadValues({}, props));
|
|
5319
5768
|
var DropZoneChild = ({
|
|
5320
5769
|
zoneCompound,
|
|
5321
5770
|
componentId,
|
|
@@ -5326,9 +5775,9 @@ var DropZoneChild = ({
|
|
|
5326
5775
|
}) => {
|
|
5327
5776
|
var _a, _b;
|
|
5328
5777
|
const metadata = useAppStore((s) => s.metadata);
|
|
5329
|
-
const ctx = (0,
|
|
5778
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5330
5779
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
5331
|
-
const zoneStore = (0,
|
|
5780
|
+
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
5332
5781
|
const nodeProps = useAppStore(
|
|
5333
5782
|
(0, import_shallow4.useShallow)((s) => {
|
|
5334
5783
|
var _a2;
|
|
@@ -5348,7 +5797,7 @@ var DropZoneChild = ({
|
|
|
5348
5797
|
})
|
|
5349
5798
|
);
|
|
5350
5799
|
const appStore = useAppStoreApi();
|
|
5351
|
-
const item = (0,
|
|
5800
|
+
const item = (0, import_react34.useMemo)(() => {
|
|
5352
5801
|
if (nodeProps) {
|
|
5353
5802
|
const expanded = expandNode({
|
|
5354
5803
|
type: nodeType,
|
|
@@ -5361,7 +5810,8 @@ var DropZoneChild = ({
|
|
|
5361
5810
|
return {
|
|
5362
5811
|
type: preview.componentType,
|
|
5363
5812
|
props: preview.props,
|
|
5364
|
-
previewType: preview.type
|
|
5813
|
+
previewType: preview.type,
|
|
5814
|
+
element: preview.element
|
|
5365
5815
|
};
|
|
5366
5816
|
}
|
|
5367
5817
|
return null;
|
|
@@ -5369,7 +5819,7 @@ var DropZoneChild = ({
|
|
|
5369
5819
|
const componentConfig = useAppStore(
|
|
5370
5820
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
|
5371
5821
|
);
|
|
5372
|
-
const puckProps = (0,
|
|
5822
|
+
const puckProps = (0, import_react34.useMemo)(
|
|
5373
5823
|
() => ({
|
|
5374
5824
|
renderDropZone: DropZoneEditPure,
|
|
5375
5825
|
isEditing: true,
|
|
@@ -5392,13 +5842,20 @@ var DropZoneChild = ({
|
|
|
5392
5842
|
}
|
|
5393
5843
|
);
|
|
5394
5844
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
|
5395
|
-
const renderPreview = (0,
|
|
5845
|
+
const renderPreview = (0, import_react34.useMemo)(
|
|
5396
5846
|
() => function Preview3() {
|
|
5397
|
-
|
|
5847
|
+
var _a2;
|
|
5848
|
+
if (item && "element" in item && item.element) {
|
|
5849
|
+
return (
|
|
5850
|
+
// Safe to use this since the HTML is set by the user
|
|
5851
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
5852
|
+
);
|
|
5853
|
+
}
|
|
5854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name: label, children: (_a2 = overrides.componentItem) != null ? _a2 : overrides.drawerItem });
|
|
5398
5855
|
},
|
|
5399
5856
|
[componentId, label, overrides]
|
|
5400
5857
|
);
|
|
5401
|
-
const defaultsProps = (0,
|
|
5858
|
+
const defaultsProps = (0, import_react34.useMemo)(
|
|
5402
5859
|
() => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
|
|
5403
5860
|
puck: puckProps,
|
|
5404
5861
|
editMode: true
|
|
@@ -5406,7 +5863,7 @@ var DropZoneChild = ({
|
|
|
5406
5863
|
}),
|
|
5407
5864
|
[componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
|
|
5408
5865
|
);
|
|
5409
|
-
const defaultedNode = (0,
|
|
5866
|
+
const defaultedNode = (0, import_react34.useMemo)(
|
|
5410
5867
|
() => {
|
|
5411
5868
|
var _a2;
|
|
5412
5869
|
return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
|
|
@@ -5414,16 +5871,24 @@ var DropZoneChild = ({
|
|
|
5414
5871
|
[item == null ? void 0 : item.type, nodeType, defaultsProps]
|
|
5415
5872
|
);
|
|
5416
5873
|
const config = useAppStore((s) => s.config);
|
|
5417
|
-
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(
|
|
5418
5884
|
config,
|
|
5419
5885
|
defaultedNode,
|
|
5420
|
-
|
|
5421
|
-
(slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
|
5886
|
+
combinedFieldTransforms,
|
|
5422
5887
|
nodeReadOnly,
|
|
5423
5888
|
isLoading
|
|
5424
5889
|
);
|
|
5425
5890
|
if (!item) return;
|
|
5426
|
-
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: [
|
|
5427
5892
|
"No configuration for ",
|
|
5428
5893
|
item.type
|
|
5429
5894
|
] });
|
|
@@ -5432,7 +5897,7 @@ var DropZoneChild = ({
|
|
|
5432
5897
|
if (isInserting) {
|
|
5433
5898
|
Render2 = renderPreview;
|
|
5434
5899
|
}
|
|
5435
|
-
return /* @__PURE__ */ (0,
|
|
5900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5436
5901
|
DraggableComponent,
|
|
5437
5902
|
{
|
|
5438
5903
|
id: componentId,
|
|
@@ -5446,19 +5911,19 @@ var DropZoneChild = ({
|
|
|
5446
5911
|
autoDragAxis: dragAxis,
|
|
5447
5912
|
userDragAxis: collisionAxis,
|
|
5448
5913
|
inDroppableZone,
|
|
5449
|
-
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)(
|
|
5450
5915
|
Render2,
|
|
5451
|
-
__spreadProps(__spreadValues({},
|
|
5452
|
-
puck: __spreadProps(__spreadValues({},
|
|
5916
|
+
__spreadProps(__spreadValues({}, transformedProps), {
|
|
5917
|
+
puck: __spreadProps(__spreadValues({}, transformedProps.puck), {
|
|
5453
5918
|
dragRef
|
|
5454
5919
|
})
|
|
5455
5920
|
})
|
|
5456
|
-
) }) : /* @__PURE__ */ (0,
|
|
5921
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Render2, __spreadValues({}, transformedProps)) })
|
|
5457
5922
|
}
|
|
5458
5923
|
);
|
|
5459
5924
|
};
|
|
5460
|
-
var DropZoneChildMemo = (0,
|
|
5461
|
-
var DropZoneEdit = (0,
|
|
5925
|
+
var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
|
|
5926
|
+
var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5462
5927
|
function DropZoneEditInternal({
|
|
5463
5928
|
zone,
|
|
5464
5929
|
allow,
|
|
@@ -5468,7 +5933,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5468
5933
|
minEmptyHeight: userMinEmptyHeight = 128,
|
|
5469
5934
|
collisionAxis
|
|
5470
5935
|
}, userRef) {
|
|
5471
|
-
const ctx = (0,
|
|
5936
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5937
|
+
const appStoreApi = useAppStoreApi();
|
|
5472
5938
|
const {
|
|
5473
5939
|
// These all need setting via context
|
|
5474
5940
|
areaId,
|
|
@@ -5505,19 +5971,14 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5505
5971
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
5506
5972
|
})
|
|
5507
5973
|
);
|
|
5508
|
-
(0,
|
|
5974
|
+
(0, import_react34.useEffect)(() => {
|
|
5509
5975
|
if (!zoneType || zoneType === "dropzone") {
|
|
5510
5976
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5511
5977
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5512
5978
|
}
|
|
5513
|
-
return () => {
|
|
5514
|
-
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
|
5515
|
-
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
|
5516
|
-
}
|
|
5517
|
-
};
|
|
5518
5979
|
}
|
|
5519
|
-
}, [zoneType]);
|
|
5520
|
-
(0,
|
|
5980
|
+
}, [zoneType, appStoreApi]);
|
|
5981
|
+
(0, import_react34.useEffect)(() => {
|
|
5521
5982
|
if (zoneType === "dropzone") {
|
|
5522
5983
|
if (zoneCompound !== rootDroppableId) {
|
|
5523
5984
|
console.warn(
|
|
@@ -5526,11 +5987,11 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5526
5987
|
}
|
|
5527
5988
|
}
|
|
5528
5989
|
}, [zoneType]);
|
|
5529
|
-
const contentIds = (0,
|
|
5990
|
+
const contentIds = (0, import_react34.useMemo)(() => {
|
|
5530
5991
|
return zoneContentIds || [];
|
|
5531
5992
|
}, [zoneContentIds]);
|
|
5532
|
-
const ref = (0,
|
|
5533
|
-
const acceptsTarget = (0,
|
|
5993
|
+
const ref = (0, import_react34.useRef)(null);
|
|
5994
|
+
const acceptsTarget = (0, import_react34.useCallback)(
|
|
5534
5995
|
(componentType) => {
|
|
5535
5996
|
if (!componentType) {
|
|
5536
5997
|
return true;
|
|
@@ -5568,7 +6029,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5568
6029
|
}
|
|
5569
6030
|
return _isEnabled;
|
|
5570
6031
|
});
|
|
5571
|
-
(0,
|
|
6032
|
+
(0, import_react34.useEffect)(() => {
|
|
5572
6033
|
if (registerLocalZone) {
|
|
5573
6034
|
registerLocalZone(zoneCompound, targetAccepted || isEnabled);
|
|
5574
6035
|
}
|
|
@@ -5583,8 +6044,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5583
6044
|
zoneCompound
|
|
5584
6045
|
);
|
|
5585
6046
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
|
5586
|
-
const zoneStore = (0,
|
|
5587
|
-
(0,
|
|
6047
|
+
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
6048
|
+
(0, import_react34.useEffect)(() => {
|
|
5588
6049
|
const { enabledIndex } = zoneStore.getState();
|
|
5589
6050
|
zoneStore.setState({
|
|
5590
6051
|
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
|
@@ -5603,7 +6064,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5603
6064
|
path: path || []
|
|
5604
6065
|
}
|
|
5605
6066
|
};
|
|
5606
|
-
const { ref: dropRef } = (0,
|
|
6067
|
+
const { ref: dropRef } = (0, import_react35.useDroppable)(droppableConfig);
|
|
5607
6068
|
const isAreaSelected = useAppStore(
|
|
5608
6069
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
|
5609
6070
|
);
|
|
@@ -5613,10 +6074,10 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5613
6074
|
userMinEmptyHeight,
|
|
5614
6075
|
ref
|
|
5615
6076
|
});
|
|
5616
|
-
return /* @__PURE__ */ (0,
|
|
6077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5617
6078
|
"div",
|
|
5618
6079
|
{
|
|
5619
|
-
className: `${
|
|
6080
|
+
className: `${getClassName18({
|
|
5620
6081
|
isRootZone,
|
|
5621
6082
|
hoveringOverArea,
|
|
5622
6083
|
isEnabled,
|
|
@@ -5634,7 +6095,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5634
6095
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
|
5635
6096
|
}),
|
|
5636
6097
|
children: contentIdsWithPreview.map((componentId, i) => {
|
|
5637
|
-
return /* @__PURE__ */ (0,
|
|
6098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5638
6099
|
DropZoneChildMemo,
|
|
5639
6100
|
{
|
|
5640
6101
|
zoneCompound,
|
|
@@ -5657,15 +6118,15 @@ var DropZoneRenderItem = ({
|
|
|
5657
6118
|
metadata
|
|
5658
6119
|
}) => {
|
|
5659
6120
|
const Component = config.components[item.type];
|
|
5660
|
-
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0,
|
|
5661
|
-
const nextContextValue = (0,
|
|
6121
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
6122
|
+
const nextContextValue = (0, import_react34.useMemo)(
|
|
5662
6123
|
() => ({
|
|
5663
6124
|
areaId: props.id,
|
|
5664
6125
|
depth: 1
|
|
5665
6126
|
}),
|
|
5666
6127
|
[props]
|
|
5667
6128
|
);
|
|
5668
|
-
return /* @__PURE__ */ (0,
|
|
6129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5669
6130
|
Component.render,
|
|
5670
6131
|
__spreadProps(__spreadValues({}, props), {
|
|
5671
6132
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
@@ -5675,24 +6136,19 @@ var DropZoneRenderItem = ({
|
|
|
5675
6136
|
})
|
|
5676
6137
|
) }, props.id);
|
|
5677
6138
|
};
|
|
5678
|
-
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0,
|
|
5679
|
-
var DropZoneRender2 = (0,
|
|
6139
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneRender2, __spreadValues({}, props));
|
|
6140
|
+
var DropZoneRender2 = (0, import_react34.forwardRef)(
|
|
5680
6141
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
5681
|
-
const ctx = (0,
|
|
6142
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5682
6143
|
const { areaId = "root" } = ctx || {};
|
|
5683
|
-
const { config, data, metadata } = (0,
|
|
6144
|
+
const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
|
|
5684
6145
|
let zoneCompound = `${areaId}:${zone}`;
|
|
5685
6146
|
let content = (data == null ? void 0 : data.content) || [];
|
|
5686
|
-
(0,
|
|
6147
|
+
(0, import_react34.useEffect)(() => {
|
|
5687
6148
|
if (!content) {
|
|
5688
6149
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5689
6150
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5690
6151
|
}
|
|
5691
|
-
return () => {
|
|
5692
|
-
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
|
5693
|
-
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
|
5694
|
-
}
|
|
5695
|
-
};
|
|
5696
6152
|
}
|
|
5697
6153
|
}, [content]);
|
|
5698
6154
|
if (!data || !config) {
|
|
@@ -5701,10 +6157,10 @@ var DropZoneRender2 = (0, import_react35.forwardRef)(
|
|
|
5701
6157
|
if (zoneCompound !== rootDroppableId) {
|
|
5702
6158
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
5703
6159
|
}
|
|
5704
|
-
return /* @__PURE__ */ (0,
|
|
6160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5705
6161
|
const Component = config.components[item.type];
|
|
5706
6162
|
if (Component) {
|
|
5707
|
-
return /* @__PURE__ */ (0,
|
|
6163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5708
6164
|
DropZoneRenderItem,
|
|
5709
6165
|
{
|
|
5710
6166
|
config,
|
|
@@ -5718,14 +6174,14 @@ var DropZoneRender2 = (0, import_react35.forwardRef)(
|
|
|
5718
6174
|
}) });
|
|
5719
6175
|
}
|
|
5720
6176
|
);
|
|
5721
|
-
var DropZonePure = (props) => /* @__PURE__ */ (0,
|
|
5722
|
-
var DropZone = (0,
|
|
6177
|
+
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZone, __spreadValues({}, props));
|
|
6178
|
+
var DropZone = (0, import_react34.forwardRef)(
|
|
5723
6179
|
function DropZone2(props, ref) {
|
|
5724
|
-
const ctx = (0,
|
|
6180
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5725
6181
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
5726
|
-
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 })) });
|
|
5727
6183
|
}
|
|
5728
|
-
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 })) });
|
|
5729
6185
|
}
|
|
5730
6186
|
);
|
|
5731
6187
|
|
|
@@ -5953,6 +6409,7 @@ var findDeepestCandidate = (position, manager) => {
|
|
|
5953
6409
|
});
|
|
5954
6410
|
filteredCandidates.reverse();
|
|
5955
6411
|
const primaryCandidate = filteredCandidates[0];
|
|
6412
|
+
if (!primaryCandidate) return { zone: null, area: null };
|
|
5956
6413
|
const primaryCandidateData = primaryCandidate.data;
|
|
5957
6414
|
const primaryCandidateIsComponent = "containsActiveZone" in primaryCandidateData;
|
|
5958
6415
|
const zone = getZoneId2(primaryCandidate);
|
|
@@ -6060,14 +6517,14 @@ function getDeepDir(el) {
|
|
|
6060
6517
|
|
|
6061
6518
|
// components/DragDropContext/index.tsx
|
|
6062
6519
|
var import_state = require("@dnd-kit/state");
|
|
6063
|
-
var
|
|
6520
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
6064
6521
|
var DEBUG3 = false;
|
|
6065
|
-
var dragListenerContext = (0,
|
|
6522
|
+
var dragListenerContext = (0, import_react37.createContext)({
|
|
6066
6523
|
dragListeners: {}
|
|
6067
6524
|
});
|
|
6068
6525
|
function useDragListener(type, fn, deps = []) {
|
|
6069
|
-
const { setDragListeners } = (0,
|
|
6070
|
-
(0,
|
|
6526
|
+
const { setDragListeners } = (0, import_react37.useContext)(dragListenerContext);
|
|
6527
|
+
(0, import_react37.useEffect)(() => {
|
|
6071
6528
|
if (setDragListeners) {
|
|
6072
6529
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
|
6073
6530
|
[type]: [...old[type] || [], fn]
|
|
@@ -6077,8 +6534,8 @@ function useDragListener(type, fn, deps = []) {
|
|
|
6077
6534
|
}
|
|
6078
6535
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
|
6079
6536
|
var useTempDisableFallback = (timeout3) => {
|
|
6080
|
-
const lastFallbackDisable = (0,
|
|
6081
|
-
return (0,
|
|
6537
|
+
const lastFallbackDisable = (0, import_react37.useRef)(null);
|
|
6538
|
+
return (0, import_react37.useCallback)((manager) => {
|
|
6082
6539
|
collisionStore.setState({ fallbackEnabled: false });
|
|
6083
6540
|
const fallbackId = generateId();
|
|
6084
6541
|
lastFallbackDisable.current = fallbackId;
|
|
@@ -6097,9 +6554,9 @@ var DragDropContextClient = ({
|
|
|
6097
6554
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
6098
6555
|
const appStore = useAppStoreApi();
|
|
6099
6556
|
const id = useSafeId();
|
|
6100
|
-
const debouncedParamsRef = (0,
|
|
6557
|
+
const debouncedParamsRef = (0, import_react37.useRef)(null);
|
|
6101
6558
|
const tempDisableFallback = useTempDisableFallback(100);
|
|
6102
|
-
const [zoneStore] = (0,
|
|
6559
|
+
const [zoneStore] = (0, import_react37.useState)(
|
|
6103
6560
|
() => (0, import_zustand5.createStore)(() => ({
|
|
6104
6561
|
zoneDepthIndex: {},
|
|
6105
6562
|
nextZoneDepthIndex: {},
|
|
@@ -6111,7 +6568,7 @@ var DragDropContextClient = ({
|
|
|
6111
6568
|
hoveringComponent: null
|
|
6112
6569
|
}))
|
|
6113
6570
|
);
|
|
6114
|
-
const getChanged2 = (0,
|
|
6571
|
+
const getChanged2 = (0, import_react37.useCallback)(
|
|
6115
6572
|
(params, id2) => {
|
|
6116
6573
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
6117
6574
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
@@ -6132,7 +6589,7 @@ var DragDropContextClient = ({
|
|
|
6132
6589
|
},
|
|
6133
6590
|
[zoneStore]
|
|
6134
6591
|
);
|
|
6135
|
-
const setDeepestAndCollide = (0,
|
|
6592
|
+
const setDeepestAndCollide = (0, import_react37.useCallback)(
|
|
6136
6593
|
(params, manager) => {
|
|
6137
6594
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
|
6138
6595
|
if (!zoneChanged && !areaChanged) return;
|
|
@@ -6156,7 +6613,7 @@ var DragDropContextClient = ({
|
|
|
6156
6613
|
setDeepestDb.cancel();
|
|
6157
6614
|
debouncedParamsRef.current = null;
|
|
6158
6615
|
};
|
|
6159
|
-
(0,
|
|
6616
|
+
(0, import_react37.useEffect)(() => {
|
|
6160
6617
|
if (DEBUG3) {
|
|
6161
6618
|
zoneStore.subscribe(
|
|
6162
6619
|
(s) => {
|
|
@@ -6170,7 +6627,7 @@ var DragDropContextClient = ({
|
|
|
6170
6627
|
);
|
|
6171
6628
|
}
|
|
6172
6629
|
}, []);
|
|
6173
|
-
const [plugins] = (0,
|
|
6630
|
+
const [plugins] = (0, import_react37.useState)(() => [
|
|
6174
6631
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
|
6175
6632
|
createNestedDroppablePlugin(
|
|
6176
6633
|
{
|
|
@@ -6218,10 +6675,10 @@ var DragDropContextClient = ({
|
|
|
6218
6675
|
)
|
|
6219
6676
|
]);
|
|
6220
6677
|
const sensors = useSensors();
|
|
6221
|
-
const [dragListeners, setDragListeners] = (0,
|
|
6222
|
-
const dragMode = (0,
|
|
6223
|
-
const initialSelector = (0,
|
|
6224
|
-
const nextContextValue = (0,
|
|
6678
|
+
const [dragListeners, setDragListeners] = (0, import_react37.useState)({});
|
|
6679
|
+
const dragMode = (0, import_react37.useRef)(null);
|
|
6680
|
+
const initialSelector = (0, import_react37.useRef)(void 0);
|
|
6681
|
+
const nextContextValue = (0, import_react37.useMemo)(
|
|
6225
6682
|
() => ({
|
|
6226
6683
|
mode: "edit",
|
|
6227
6684
|
areaId: "root",
|
|
@@ -6229,15 +6686,15 @@ var DragDropContextClient = ({
|
|
|
6229
6686
|
}),
|
|
6230
6687
|
[]
|
|
6231
6688
|
);
|
|
6232
|
-
return /* @__PURE__ */ (0,
|
|
6689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6233
6690
|
dragListenerContext.Provider,
|
|
6234
6691
|
{
|
|
6235
6692
|
value: {
|
|
6236
6693
|
dragListeners,
|
|
6237
6694
|
setDragListeners
|
|
6238
6695
|
},
|
|
6239
|
-
children: /* @__PURE__ */ (0,
|
|
6240
|
-
|
|
6696
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6697
|
+
import_react36.DragDropProvider,
|
|
6241
6698
|
{
|
|
6242
6699
|
plugins,
|
|
6243
6700
|
sensors,
|
|
@@ -6357,6 +6814,7 @@ var DragDropContextClient = ({
|
|
|
6357
6814
|
type: "insert",
|
|
6358
6815
|
index: targetIndex,
|
|
6359
6816
|
zone: targetZone,
|
|
6817
|
+
element: source.element,
|
|
6360
6818
|
props: {
|
|
6361
6819
|
id: source.id.toString()
|
|
6362
6820
|
}
|
|
@@ -6382,7 +6840,8 @@ var DragDropContextClient = ({
|
|
|
6382
6840
|
type: "move",
|
|
6383
6841
|
index: targetIndex,
|
|
6384
6842
|
zone: targetZone,
|
|
6385
|
-
props: item.props
|
|
6843
|
+
props: item.props,
|
|
6844
|
+
element: source.element
|
|
6386
6845
|
}
|
|
6387
6846
|
}
|
|
6388
6847
|
});
|
|
@@ -6412,7 +6871,8 @@ var DragDropContextClient = ({
|
|
|
6412
6871
|
type: "move",
|
|
6413
6872
|
index: sourceData.index,
|
|
6414
6873
|
zone: sourceData.zone,
|
|
6415
|
-
props: item.props
|
|
6874
|
+
props: item.props,
|
|
6875
|
+
element: source.element
|
|
6416
6876
|
}
|
|
6417
6877
|
}
|
|
6418
6878
|
});
|
|
@@ -6449,7 +6909,7 @@ var DragDropContextClient = ({
|
|
|
6449
6909
|
const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
|
|
6450
6910
|
entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
|
|
6451
6911
|
},
|
|
6452
|
-
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 }) })
|
|
6453
6913
|
}
|
|
6454
6914
|
)
|
|
6455
6915
|
}
|
|
@@ -6463,13 +6923,13 @@ var DragDropContext = ({
|
|
|
6463
6923
|
if (status === "LOADING") {
|
|
6464
6924
|
return children;
|
|
6465
6925
|
}
|
|
6466
|
-
return /* @__PURE__ */ (0,
|
|
6926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
|
6467
6927
|
};
|
|
6468
6928
|
|
|
6469
6929
|
// components/Drawer/index.tsx
|
|
6470
|
-
var
|
|
6471
|
-
var
|
|
6472
|
-
var
|
|
6930
|
+
var import_react39 = require("@dnd-kit/react");
|
|
6931
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
6932
|
+
var getClassName19 = get_class_name_factory_default("Drawer", styles_module_default10);
|
|
6473
6933
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
|
6474
6934
|
var DrawerItemInner = ({
|
|
6475
6935
|
children,
|
|
@@ -6478,11 +6938,11 @@ var DrawerItemInner = ({
|
|
|
6478
6938
|
dragRef,
|
|
6479
6939
|
isDragDisabled
|
|
6480
6940
|
}) => {
|
|
6481
|
-
const CustomInner = (0,
|
|
6482
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
|
6941
|
+
const CustomInner = (0, import_react38.useMemo)(
|
|
6942
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
|
6483
6943
|
[children]
|
|
6484
6944
|
);
|
|
6485
|
-
return /* @__PURE__ */ (0,
|
|
6945
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6486
6946
|
"div",
|
|
6487
6947
|
{
|
|
6488
6948
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
|
@@ -6490,9 +6950,9 @@ var DrawerItemInner = ({
|
|
|
6490
6950
|
onMouseDown: (e) => e.preventDefault(),
|
|
6491
6951
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
|
6492
6952
|
"data-puck-drawer-item": true,
|
|
6493
|
-
children: /* @__PURE__ */ (0,
|
|
6494
|
-
/* @__PURE__ */ (0,
|
|
6495
|
-
/* @__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, {}) })
|
|
6496
6956
|
] }) }) })
|
|
6497
6957
|
}
|
|
6498
6958
|
);
|
|
@@ -6504,15 +6964,15 @@ var DrawerItemDraggable = ({
|
|
|
6504
6964
|
id,
|
|
6505
6965
|
isDragDisabled
|
|
6506
6966
|
}) => {
|
|
6507
|
-
const { ref } = (0,
|
|
6967
|
+
const { ref } = (0, import_react39.useDraggable)({
|
|
6508
6968
|
id,
|
|
6509
6969
|
data: { componentType: name },
|
|
6510
6970
|
disabled: isDragDisabled,
|
|
6511
6971
|
type: "drawer"
|
|
6512
6972
|
});
|
|
6513
|
-
return /* @__PURE__ */ (0,
|
|
6514
|
-
/* @__PURE__ */ (0,
|
|
6515
|
-
/* @__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)(
|
|
6516
6976
|
DrawerItemInner,
|
|
6517
6977
|
{
|
|
6518
6978
|
name,
|
|
@@ -6533,7 +6993,7 @@ var DrawerItem = ({
|
|
|
6533
6993
|
isDragDisabled
|
|
6534
6994
|
}) => {
|
|
6535
6995
|
const resolvedId = id || name;
|
|
6536
|
-
const [dynamicId, setDynamicId] = (0,
|
|
6996
|
+
const [dynamicId, setDynamicId] = (0, import_react38.useState)(generateId(resolvedId));
|
|
6537
6997
|
if (typeof index !== "undefined") {
|
|
6538
6998
|
console.error(
|
|
6539
6999
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
|
@@ -6546,7 +7006,7 @@ var DrawerItem = ({
|
|
|
6546
7006
|
},
|
|
6547
7007
|
[resolvedId]
|
|
6548
7008
|
);
|
|
6549
|
-
return /* @__PURE__ */ (0,
|
|
7009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6550
7010
|
DrawerItemDraggable,
|
|
6551
7011
|
{
|
|
6552
7012
|
name,
|
|
@@ -6573,16 +7033,16 @@ var Drawer = ({
|
|
|
6573
7033
|
);
|
|
6574
7034
|
}
|
|
6575
7035
|
const id = useSafeId();
|
|
6576
|
-
const { ref } = (0,
|
|
7036
|
+
const { ref } = (0, import_react39.useDroppable)({
|
|
6577
7037
|
id,
|
|
6578
7038
|
type: "void",
|
|
6579
7039
|
collisionPriority: 0
|
|
6580
7040
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
|
6581
7041
|
});
|
|
6582
|
-
return /* @__PURE__ */ (0,
|
|
7042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6583
7043
|
"div",
|
|
6584
7044
|
{
|
|
6585
|
-
className:
|
|
7045
|
+
className: getClassName19(),
|
|
6586
7046
|
ref,
|
|
6587
7047
|
"data-puck-dnd": id,
|
|
6588
7048
|
"data-puck-drawer": true,
|
|
@@ -6595,18 +7055,18 @@ Drawer.Item = DrawerItem;
|
|
|
6595
7055
|
|
|
6596
7056
|
// components/Puck/index.tsx
|
|
6597
7057
|
init_react_import();
|
|
6598
|
-
var
|
|
7058
|
+
var import_react59 = require("react");
|
|
6599
7059
|
|
|
6600
7060
|
// components/SidebarSection/index.tsx
|
|
6601
7061
|
init_react_import();
|
|
6602
7062
|
|
|
6603
7063
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
6604
7064
|
init_react_import();
|
|
6605
|
-
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" };
|
|
6606
7066
|
|
|
6607
7067
|
// lib/use-breadcrumbs.ts
|
|
6608
7068
|
init_react_import();
|
|
6609
|
-
var
|
|
7069
|
+
var import_react40 = require("react");
|
|
6610
7070
|
var useBreadcrumbs = (renderCount) => {
|
|
6611
7071
|
const selectedId = useAppStore((s) => {
|
|
6612
7072
|
var _a;
|
|
@@ -6618,7 +7078,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6618
7078
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
6619
7079
|
});
|
|
6620
7080
|
const appStore = useAppStoreApi();
|
|
6621
|
-
return (0,
|
|
7081
|
+
return (0, import_react40.useMemo)(() => {
|
|
6622
7082
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
6623
7083
|
var _a, _b, _c;
|
|
6624
7084
|
const [componentId] = zoneCompound.split(":");
|
|
@@ -6649,8 +7109,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6649
7109
|
};
|
|
6650
7110
|
|
|
6651
7111
|
// components/SidebarSection/index.tsx
|
|
6652
|
-
var
|
|
6653
|
-
var
|
|
7112
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
7113
|
+
var getClassName20 = get_class_name_factory_default("SidebarSection", styles_module_default14);
|
|
6654
7114
|
var SidebarSection = ({
|
|
6655
7115
|
children,
|
|
6656
7116
|
title,
|
|
@@ -6662,29 +7122,29 @@ var SidebarSection = ({
|
|
|
6662
7122
|
}) => {
|
|
6663
7123
|
const setUi = useAppStore((s) => s.setUi);
|
|
6664
7124
|
const breadcrumbs = useBreadcrumbs(1);
|
|
6665
|
-
return /* @__PURE__ */ (0,
|
|
7125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
6666
7126
|
"div",
|
|
6667
7127
|
{
|
|
6668
|
-
className:
|
|
7128
|
+
className: getClassName20({ noBorderTop, noPadding }),
|
|
6669
7129
|
style: { background },
|
|
6670
7130
|
children: [
|
|
6671
|
-
/* @__PURE__ */ (0,
|
|
6672
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
|
6673
|
-
/* @__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)(
|
|
6674
7134
|
"button",
|
|
6675
7135
|
{
|
|
6676
7136
|
type: "button",
|
|
6677
|
-
className:
|
|
7137
|
+
className: getClassName20("breadcrumbLabel"),
|
|
6678
7138
|
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
|
6679
7139
|
children: breadcrumb.label
|
|
6680
7140
|
}
|
|
6681
7141
|
),
|
|
6682
|
-
/* @__PURE__ */ (0,
|
|
7142
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronRight, { size: 16 })
|
|
6683
7143
|
] }, i)) : null,
|
|
6684
|
-
/* @__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 }) })
|
|
6685
7145
|
] }) }),
|
|
6686
|
-
/* @__PURE__ */ (0,
|
|
6687
|
-
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 }) })
|
|
6688
7148
|
]
|
|
6689
7149
|
}
|
|
6690
7150
|
);
|
|
@@ -6692,24 +7152,24 @@ var SidebarSection = ({
|
|
|
6692
7152
|
|
|
6693
7153
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
|
6694
7154
|
init_react_import();
|
|
6695
|
-
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" };
|
|
6696
7156
|
|
|
6697
7157
|
// components/Puck/components/Fields/index.tsx
|
|
6698
7158
|
init_react_import();
|
|
6699
7159
|
|
|
6700
7160
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
|
6701
7161
|
init_react_import();
|
|
6702
|
-
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" };
|
|
6703
7163
|
|
|
6704
7164
|
// components/Puck/components/Fields/index.tsx
|
|
6705
|
-
var
|
|
7165
|
+
var import_react41 = require("react");
|
|
6706
7166
|
var import_shallow5 = require("zustand/react/shallow");
|
|
6707
|
-
var
|
|
6708
|
-
var
|
|
7167
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
7168
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
|
6709
7169
|
var DefaultFields = ({
|
|
6710
7170
|
children
|
|
6711
7171
|
}) => {
|
|
6712
|
-
return /* @__PURE__ */ (0,
|
|
7172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
|
6713
7173
|
};
|
|
6714
7174
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
|
6715
7175
|
let currentProps;
|
|
@@ -6775,13 +7235,13 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6775
7235
|
})
|
|
6776
7236
|
);
|
|
6777
7237
|
const appStore = useAppStoreApi();
|
|
6778
|
-
const onChange = (0,
|
|
7238
|
+
const onChange = (0, import_react41.useCallback)(createOnChange(fieldName, appStore), [
|
|
6779
7239
|
fieldName
|
|
6780
7240
|
]);
|
|
6781
7241
|
const { visible = true } = field != null ? field : {};
|
|
6782
7242
|
if (!field || !id || !visible) return null;
|
|
6783
7243
|
if (field.type === "slot") return null;
|
|
6784
|
-
return /* @__PURE__ */ (0,
|
|
7244
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6785
7245
|
AutoFieldPrivate,
|
|
6786
7246
|
{
|
|
6787
7247
|
field,
|
|
@@ -6793,7 +7253,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6793
7253
|
}
|
|
6794
7254
|
) }, id);
|
|
6795
7255
|
};
|
|
6796
|
-
var FieldsChildMemo = (0,
|
|
7256
|
+
var FieldsChildMemo = (0, import_react41.memo)(FieldsChild);
|
|
6797
7257
|
var FieldsInternal = ({ wrapFields = true }) => {
|
|
6798
7258
|
const overrides = useAppStore((s) => s.overrides);
|
|
6799
7259
|
const componentResolving = useAppStore((s) => {
|
|
@@ -6818,22 +7278,22 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6818
7278
|
})
|
|
6819
7279
|
);
|
|
6820
7280
|
const isLoading = fieldsLoading || componentResolving;
|
|
6821
|
-
const Wrapper = (0,
|
|
6822
|
-
return /* @__PURE__ */ (0,
|
|
7281
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
7282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
6823
7283
|
"form",
|
|
6824
7284
|
{
|
|
6825
|
-
className:
|
|
7285
|
+
className: getClassName21({ wrapFields }),
|
|
6826
7286
|
onSubmit: (e) => {
|
|
6827
7287
|
e.preventDefault();
|
|
6828
7288
|
},
|
|
6829
7289
|
children: [
|
|
6830
|
-
/* @__PURE__ */ (0,
|
|
6831
|
-
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 }) }) })
|
|
6832
7292
|
]
|
|
6833
7293
|
}
|
|
6834
7294
|
);
|
|
6835
7295
|
};
|
|
6836
|
-
var Fields = (0,
|
|
7296
|
+
var Fields = (0, import_react41.memo)(FieldsInternal);
|
|
6837
7297
|
|
|
6838
7298
|
// components/Puck/components/Components/index.tsx
|
|
6839
7299
|
init_react_import();
|
|
@@ -6847,22 +7307,31 @@ init_react_import();
|
|
|
6847
7307
|
|
|
6848
7308
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
|
6849
7309
|
init_react_import();
|
|
6850
|
-
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" };
|
|
6851
7311
|
|
|
6852
7312
|
// components/ComponentList/index.tsx
|
|
6853
|
-
var
|
|
6854
|
-
var
|
|
7313
|
+
var import_react42 = require("react");
|
|
7314
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
7315
|
+
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
|
6855
7316
|
var ComponentListItem = ({
|
|
6856
7317
|
name,
|
|
6857
7318
|
label
|
|
6858
7319
|
}) => {
|
|
7320
|
+
var _a;
|
|
6859
7321
|
const overrides = useAppStore((s) => s.overrides);
|
|
6860
7322
|
const canInsert = useAppStore(
|
|
6861
7323
|
(s) => s.permissions.getPermissions({
|
|
6862
7324
|
type: name
|
|
6863
7325
|
}).insert
|
|
6864
7326
|
);
|
|
6865
|
-
|
|
7327
|
+
(0, import_react42.useEffect)(() => {
|
|
7328
|
+
if (overrides.componentItem) {
|
|
7329
|
+
console.warn(
|
|
7330
|
+
"The `componentItem` override has been deprecated and renamed to `drawerItem`"
|
|
7331
|
+
);
|
|
7332
|
+
}
|
|
7333
|
+
}, [overrides]);
|
|
7334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
|
|
6866
7335
|
};
|
|
6867
7336
|
var ComponentList = ({
|
|
6868
7337
|
children,
|
|
@@ -6873,12 +7342,12 @@ var ComponentList = ({
|
|
|
6873
7342
|
const setUi = useAppStore((s) => s.setUi);
|
|
6874
7343
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
|
6875
7344
|
const { expanded = true } = componentList[id] || {};
|
|
6876
|
-
return /* @__PURE__ */ (0,
|
|
6877
|
-
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)(
|
|
6878
7347
|
"button",
|
|
6879
7348
|
{
|
|
6880
7349
|
type: "button",
|
|
6881
|
-
className:
|
|
7350
|
+
className: getClassName22("title"),
|
|
6882
7351
|
onClick: () => setUi({
|
|
6883
7352
|
componentList: __spreadProps(__spreadValues({}, componentList), {
|
|
6884
7353
|
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
|
@@ -6888,14 +7357,14 @@ var ComponentList = ({
|
|
|
6888
7357
|
}),
|
|
6889
7358
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
|
6890
7359
|
children: [
|
|
6891
|
-
/* @__PURE__ */ (0,
|
|
6892
|
-
/* @__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 }) })
|
|
6893
7362
|
]
|
|
6894
7363
|
}
|
|
6895
7364
|
),
|
|
6896
|
-
/* @__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) => {
|
|
6897
7366
|
var _a;
|
|
6898
|
-
return /* @__PURE__ */ (0,
|
|
7367
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6899
7368
|
ComponentListItem,
|
|
6900
7369
|
{
|
|
6901
7370
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
|
@@ -6909,7 +7378,7 @@ var ComponentList = ({
|
|
|
6909
7378
|
ComponentList.Item = ComponentListItem;
|
|
6910
7379
|
|
|
6911
7380
|
// lib/use-component-list.tsx
|
|
6912
|
-
var
|
|
7381
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6913
7382
|
var useComponentList = () => {
|
|
6914
7383
|
const [componentList, setComponentList] = (0, import_react43.useState)();
|
|
6915
7384
|
const config = useAppStore((s) => s.config);
|
|
@@ -6924,7 +7393,7 @@ var useComponentList = () => {
|
|
|
6924
7393
|
if (category.visible === false || !category.components) {
|
|
6925
7394
|
return null;
|
|
6926
7395
|
}
|
|
6927
|
-
return /* @__PURE__ */ (0,
|
|
7396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6928
7397
|
ComponentList,
|
|
6929
7398
|
{
|
|
6930
7399
|
id: categoryKey,
|
|
@@ -6933,7 +7402,7 @@ var useComponentList = () => {
|
|
|
6933
7402
|
var _a2;
|
|
6934
7403
|
matchedComponents.push(componentName);
|
|
6935
7404
|
const componentConf = config.components[componentName] || {};
|
|
6936
|
-
return /* @__PURE__ */ (0,
|
|
7405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6937
7406
|
ComponentList.Item,
|
|
6938
7407
|
{
|
|
6939
7408
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
|
@@ -6953,7 +7422,7 @@ var useComponentList = () => {
|
|
|
6953
7422
|
);
|
|
6954
7423
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
|
6955
7424
|
_componentList.push(
|
|
6956
|
-
/* @__PURE__ */ (0,
|
|
7425
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6957
7426
|
ComponentList,
|
|
6958
7427
|
{
|
|
6959
7428
|
id: "other",
|
|
@@ -6961,7 +7430,7 @@ var useComponentList = () => {
|
|
|
6961
7430
|
children: remainingComponents.map((componentName, i) => {
|
|
6962
7431
|
var _a2;
|
|
6963
7432
|
const componentConf = config.components[componentName] || {};
|
|
6964
|
-
return /* @__PURE__ */ (0,
|
|
7433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6965
7434
|
ComponentList.Item,
|
|
6966
7435
|
{
|
|
6967
7436
|
name: componentName,
|
|
@@ -6984,12 +7453,19 @@ var useComponentList = () => {
|
|
|
6984
7453
|
|
|
6985
7454
|
// components/Puck/components/Components/index.tsx
|
|
6986
7455
|
var import_react44 = require("react");
|
|
6987
|
-
var
|
|
7456
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
6988
7457
|
var Components = () => {
|
|
6989
7458
|
const overrides = useAppStore((s) => s.overrides);
|
|
6990
7459
|
const componentList = useComponentList();
|
|
6991
|
-
const Wrapper = (0, import_react44.useMemo)(() =>
|
|
6992
|
-
|
|
7460
|
+
const Wrapper = (0, import_react44.useMemo)(() => {
|
|
7461
|
+
if (overrides.components) {
|
|
7462
|
+
console.warn(
|
|
7463
|
+
"The `components` override has been deprecated and renamed to `drawer`"
|
|
7464
|
+
);
|
|
7465
|
+
}
|
|
7466
|
+
return overrides.components || overrides.drawer || "div";
|
|
7467
|
+
}, [overrides]);
|
|
7468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComponentList, { id: "all" }) });
|
|
6993
7469
|
};
|
|
6994
7470
|
|
|
6995
7471
|
// components/Puck/components/Preview/index.tsx
|
|
@@ -7001,7 +7477,7 @@ init_react_import();
|
|
|
7001
7477
|
var import_react45 = require("react");
|
|
7002
7478
|
var import_object_hash = __toESM(require("object-hash"));
|
|
7003
7479
|
var import_react_dom3 = require("react-dom");
|
|
7004
|
-
var
|
|
7480
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
7005
7481
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
|
7006
7482
|
var collectStyles = (doc) => {
|
|
7007
7483
|
const collected = [];
|
|
@@ -7208,7 +7684,7 @@ var CopyHostStyles = ({
|
|
|
7208
7684
|
observer.disconnect();
|
|
7209
7685
|
};
|
|
7210
7686
|
}, []);
|
|
7211
|
-
return /* @__PURE__ */ (0,
|
|
7687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children });
|
|
7212
7688
|
};
|
|
7213
7689
|
var autoFrameContext = (0, import_react45.createContext)({});
|
|
7214
7690
|
var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
|
|
@@ -7255,7 +7731,7 @@ function AutoFrame(_a) {
|
|
|
7255
7731
|
}
|
|
7256
7732
|
}
|
|
7257
7733
|
}, [frameRef, loaded, stylesLoaded]);
|
|
7258
|
-
return /* @__PURE__ */ (0,
|
|
7734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7259
7735
|
"iframe",
|
|
7260
7736
|
__spreadProps(__spreadValues({}, props), {
|
|
7261
7737
|
className,
|
|
@@ -7265,7 +7741,7 @@ function AutoFrame(_a) {
|
|
|
7265
7741
|
onLoad: () => {
|
|
7266
7742
|
setLoaded(true);
|
|
7267
7743
|
},
|
|
7268
|
-
children: /* @__PURE__ */ (0,
|
|
7744
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7269
7745
|
CopyHostStyles,
|
|
7270
7746
|
{
|
|
7271
7747
|
debug,
|
|
@@ -7281,11 +7757,11 @@ var AutoFrame_default = AutoFrame;
|
|
|
7281
7757
|
|
|
7282
7758
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
|
7283
7759
|
init_react_import();
|
|
7284
|
-
var
|
|
7760
|
+
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
|
7285
7761
|
|
|
7286
7762
|
// components/Puck/components/Preview/index.tsx
|
|
7287
|
-
var
|
|
7288
|
-
var
|
|
7763
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7764
|
+
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
|
7289
7765
|
var useBubbleIframeEvents = (ref) => {
|
|
7290
7766
|
const status = useAppStore((s) => s.status);
|
|
7291
7767
|
(0, import_react46.useEffect)(() => {
|
|
@@ -7347,7 +7823,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7347
7823
|
);
|
|
7348
7824
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
7349
7825
|
id: "puck-root"
|
|
7350
|
-
}, propsWithSlots)) : /* @__PURE__ */ (0,
|
|
7826
|
+
}, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children: propsWithSlots.children });
|
|
7351
7827
|
},
|
|
7352
7828
|
[config]
|
|
7353
7829
|
);
|
|
@@ -7355,7 +7831,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7355
7831
|
const rootProps = root.props || root;
|
|
7356
7832
|
const ref = (0, import_react46.useRef)(null);
|
|
7357
7833
|
useBubbleIframeEvents(ref);
|
|
7358
|
-
const inner = !renderData ? /* @__PURE__ */ (0,
|
|
7834
|
+
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7359
7835
|
Page,
|
|
7360
7836
|
__spreadProps(__spreadValues({}, rootProps), {
|
|
7361
7837
|
puck: {
|
|
@@ -7365,28 +7841,31 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7365
7841
|
metadata
|
|
7366
7842
|
},
|
|
7367
7843
|
editMode: true,
|
|
7368
|
-
children: /* @__PURE__ */ (0,
|
|
7844
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7369
7845
|
})
|
|
7370
|
-
) : /* @__PURE__ */ (0,
|
|
7846
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Render, { data: renderData, config, metadata });
|
|
7371
7847
|
(0, import_react46.useEffect)(() => {
|
|
7372
7848
|
if (!iframe.enabled) {
|
|
7373
7849
|
setStatus("READY");
|
|
7374
7850
|
}
|
|
7375
7851
|
}, [iframe.enabled]);
|
|
7376
|
-
return /* @__PURE__ */ (0,
|
|
7852
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7377
7853
|
"div",
|
|
7378
7854
|
{
|
|
7379
|
-
className:
|
|
7855
|
+
className: getClassName23(),
|
|
7380
7856
|
id,
|
|
7381
7857
|
"data-puck-preview": true,
|
|
7382
|
-
onClick: () => {
|
|
7383
|
-
|
|
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
|
+
}
|
|
7384
7863
|
},
|
|
7385
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
|
7864
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7386
7865
|
AutoFrame_default,
|
|
7387
7866
|
{
|
|
7388
7867
|
id: "preview-frame",
|
|
7389
|
-
className:
|
|
7868
|
+
className: getClassName23("frame"),
|
|
7390
7869
|
"data-rfd-iframe": true,
|
|
7391
7870
|
onReady: () => {
|
|
7392
7871
|
setStatus("READY");
|
|
@@ -7395,18 +7874,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7395
7874
|
setStatus("MOUNTED");
|
|
7396
7875
|
},
|
|
7397
7876
|
frameRef: ref,
|
|
7398
|
-
children: /* @__PURE__ */ (0,
|
|
7877
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
|
7399
7878
|
if (Frame) {
|
|
7400
|
-
return /* @__PURE__ */ (0,
|
|
7879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Frame, { document: document2, children: inner });
|
|
7401
7880
|
}
|
|
7402
7881
|
return inner;
|
|
7403
7882
|
} })
|
|
7404
7883
|
}
|
|
7405
|
-
) : /* @__PURE__ */ (0,
|
|
7884
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7406
7885
|
"div",
|
|
7407
7886
|
{
|
|
7408
7887
|
id: "preview-frame",
|
|
7409
|
-
className:
|
|
7888
|
+
className: getClassName23("frame"),
|
|
7410
7889
|
ref,
|
|
7411
7890
|
"data-puck-entry": true,
|
|
7412
7891
|
children: inner
|
|
@@ -7424,7 +7903,7 @@ init_react_import();
|
|
|
7424
7903
|
|
|
7425
7904
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
|
7426
7905
|
init_react_import();
|
|
7427
|
-
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" };
|
|
7428
7907
|
|
|
7429
7908
|
// lib/scroll-into-view.ts
|
|
7430
7909
|
init_react_import();
|
|
@@ -7461,9 +7940,9 @@ var onScrollEnd = (frame, cb) => {
|
|
|
7461
7940
|
|
|
7462
7941
|
// components/LayerTree/index.tsx
|
|
7463
7942
|
var import_shallow6 = require("zustand/react/shallow");
|
|
7464
|
-
var
|
|
7465
|
-
var
|
|
7466
|
-
var getClassNameLayer = get_class_name_factory_default("Layer",
|
|
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);
|
|
7467
7946
|
var Layer = ({
|
|
7468
7947
|
index,
|
|
7469
7948
|
itemId,
|
|
@@ -7508,7 +7987,7 @@ var Layer = ({
|
|
|
7508
7987
|
});
|
|
7509
7988
|
const componentConfig = config.components[nodeData.data.type];
|
|
7510
7989
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
|
7511
|
-
return /* @__PURE__ */ (0,
|
|
7990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
7512
7991
|
"li",
|
|
7513
7992
|
{
|
|
7514
7993
|
className: getClassNameLayer({
|
|
@@ -7518,7 +7997,7 @@ var Layer = ({
|
|
|
7518
7997
|
childIsSelected
|
|
7519
7998
|
}),
|
|
7520
7999
|
children: [
|
|
7521
|
-
/* @__PURE__ */ (0,
|
|
8000
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
7522
8001
|
"button",
|
|
7523
8002
|
{
|
|
7524
8003
|
type: "button",
|
|
@@ -7555,224 +8034,103 @@ var Layer = ({
|
|
|
7555
8034
|
e.stopPropagation();
|
|
7556
8035
|
zoneStore.setState({ hoveringComponent: null });
|
|
7557
8036
|
},
|
|
7558
|
-
children: [
|
|
7559
|
-
containsZone && /* @__PURE__ */ (0,
|
|
7560
|
-
"div",
|
|
7561
|
-
{
|
|
7562
|
-
className: getClassNameLayer("chevron"),
|
|
7563
|
-
title: isSelected ? "Collapse" : "Expand",
|
|
7564
|
-
children: /* @__PURE__ */ (0,
|
|
7565
|
-
}
|
|
7566
|
-
),
|
|
7567
|
-
/* @__PURE__ */ (0,
|
|
7568
|
-
/* @__PURE__ */ (0,
|
|
7569
|
-
/* @__PURE__ */ (0,
|
|
7570
|
-
] })
|
|
7571
|
-
]
|
|
7572
|
-
}
|
|
7573
|
-
) }),
|
|
7574
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0,
|
|
7575
|
-
]
|
|
7576
|
-
}
|
|
7577
|
-
);
|
|
7578
|
-
};
|
|
7579
|
-
var LayerTree = ({
|
|
7580
|
-
label: _label,
|
|
7581
|
-
zoneCompound
|
|
7582
|
-
}) => {
|
|
7583
|
-
const label = useAppStore((s) => {
|
|
7584
|
-
var _a, _b, _c, _d;
|
|
7585
|
-
if (_label) return _label;
|
|
7586
|
-
if (zoneCompound === rootDroppableId) return;
|
|
7587
|
-
const [componentId, slotId] = zoneCompound.split(":");
|
|
7588
|
-
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
7589
|
-
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
7590
|
-
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7591
|
-
});
|
|
7592
|
-
const contentIds = useAppStore(
|
|
7593
|
-
(0, import_shallow6.useShallow)(
|
|
7594
|
-
(s) => {
|
|
7595
|
-
var _a, _b;
|
|
7596
|
-
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
7597
|
-
}
|
|
7598
|
-
)
|
|
7599
|
-
);
|
|
7600
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
7601
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
|
|
7602
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
|
|
7603
|
-
label
|
|
7604
|
-
] }),
|
|
7605
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
|
|
7606
|
-
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
|
|
7607
|
-
contentIds.map((itemId, i) => {
|
|
7608
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7609
|
-
Layer,
|
|
7610
|
-
{
|
|
7611
|
-
index: i,
|
|
7612
|
-
itemId,
|
|
7613
|
-
zoneCompound
|
|
7614
|
-
},
|
|
7615
|
-
itemId
|
|
7616
|
-
);
|
|
7617
|
-
})
|
|
7618
|
-
] })
|
|
7619
|
-
] });
|
|
7620
|
-
};
|
|
7621
|
-
|
|
7622
|
-
// components/Puck/components/Outline/index.tsx
|
|
7623
|
-
var import_react48 = require("react");
|
|
7624
|
-
|
|
7625
|
-
// lib/data/find-zones-for-area.ts
|
|
7626
|
-
init_react_import();
|
|
7627
|
-
var findZonesForArea = (state, area) => {
|
|
7628
|
-
return Object.keys(state.indexes.zones).filter(
|
|
7629
|
-
(zone) => zone.split(":")[0] === area
|
|
7630
|
-
);
|
|
7631
|
-
};
|
|
7632
|
-
|
|
7633
|
-
// components/Puck/components/Outline/index.tsx
|
|
7634
|
-
var import_shallow7 = require("zustand/react/shallow");
|
|
7635
|
-
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7636
|
-
var Outline = () => {
|
|
7637
|
-
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
7638
|
-
const rootZones = useAppStore(
|
|
7639
|
-
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7640
|
-
);
|
|
7641
|
-
const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7642
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7643
|
-
LayerTree,
|
|
7644
|
-
{
|
|
7645
|
-
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
7646
|
-
zoneCompound
|
|
7647
|
-
},
|
|
7648
|
-
zoneCompound
|
|
7649
|
-
)) });
|
|
7650
|
-
};
|
|
7651
|
-
|
|
7652
|
-
// components/Puck/components/Canvas/index.tsx
|
|
7653
|
-
init_react_import();
|
|
7654
|
-
|
|
7655
|
-
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7656
|
-
init_react_import();
|
|
7657
|
-
|
|
7658
|
-
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
7659
|
-
init_react_import();
|
|
7660
|
-
var isProduction = process.env.NODE_ENV === "production";
|
|
7661
|
-
var prefix = "Invariant failed";
|
|
7662
|
-
function invariant(condition, message) {
|
|
7663
|
-
if (condition) {
|
|
7664
|
-
return;
|
|
7665
|
-
}
|
|
7666
|
-
if (isProduction) {
|
|
7667
|
-
throw new Error(prefix);
|
|
7668
|
-
}
|
|
7669
|
-
var provided = typeof message === "function" ? message() : message;
|
|
7670
|
-
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
7671
|
-
throw new Error(value);
|
|
7672
|
-
}
|
|
7673
|
-
|
|
7674
|
-
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7675
|
-
var getRect = function getRect2(_ref) {
|
|
7676
|
-
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
|
7677
|
-
var width = right - left;
|
|
7678
|
-
var height = bottom - top;
|
|
7679
|
-
var rect = {
|
|
7680
|
-
top,
|
|
7681
|
-
right,
|
|
7682
|
-
bottom,
|
|
7683
|
-
left,
|
|
7684
|
-
width,
|
|
7685
|
-
height,
|
|
7686
|
-
x: left,
|
|
7687
|
-
y: top,
|
|
7688
|
-
center: {
|
|
7689
|
-
x: (right + left) / 2,
|
|
7690
|
-
y: (bottom + top) / 2
|
|
7691
|
-
}
|
|
7692
|
-
};
|
|
7693
|
-
return rect;
|
|
7694
|
-
};
|
|
7695
|
-
var expand = function expand2(target, expandBy) {
|
|
7696
|
-
return {
|
|
7697
|
-
top: target.top - expandBy.top,
|
|
7698
|
-
left: target.left - expandBy.left,
|
|
7699
|
-
bottom: target.bottom + expandBy.bottom,
|
|
7700
|
-
right: target.right + expandBy.right
|
|
7701
|
-
};
|
|
7702
|
-
};
|
|
7703
|
-
var shrink = function shrink2(target, shrinkBy) {
|
|
7704
|
-
return {
|
|
7705
|
-
top: target.top + shrinkBy.top,
|
|
7706
|
-
left: target.left + shrinkBy.left,
|
|
7707
|
-
bottom: target.bottom - shrinkBy.bottom,
|
|
7708
|
-
right: target.right - shrinkBy.right
|
|
7709
|
-
};
|
|
7710
|
-
};
|
|
7711
|
-
var noSpacing = {
|
|
7712
|
-
top: 0,
|
|
7713
|
-
right: 0,
|
|
7714
|
-
bottom: 0,
|
|
7715
|
-
left: 0
|
|
7716
|
-
};
|
|
7717
|
-
var createBox = function createBox2(_ref2) {
|
|
7718
|
-
var borderBox = _ref2.borderBox, _ref2$margin = _ref2.margin, margin = _ref2$margin === void 0 ? noSpacing : _ref2$margin, _ref2$border = _ref2.border, border = _ref2$border === void 0 ? noSpacing : _ref2$border, _ref2$padding = _ref2.padding, padding = _ref2$padding === void 0 ? noSpacing : _ref2$padding;
|
|
7719
|
-
var marginBox = getRect(expand(borderBox, margin));
|
|
7720
|
-
var paddingBox = getRect(shrink(borderBox, border));
|
|
7721
|
-
var contentBox = getRect(shrink(paddingBox, padding));
|
|
7722
|
-
return {
|
|
7723
|
-
marginBox,
|
|
7724
|
-
borderBox: getRect(borderBox),
|
|
7725
|
-
paddingBox,
|
|
7726
|
-
contentBox,
|
|
7727
|
-
margin,
|
|
7728
|
-
border,
|
|
7729
|
-
padding
|
|
7730
|
-
};
|
|
7731
|
-
};
|
|
7732
|
-
var parse = function parse2(raw) {
|
|
7733
|
-
var value = raw.slice(0, -2);
|
|
7734
|
-
var suffix = raw.slice(-2);
|
|
7735
|
-
if (suffix !== "px") {
|
|
7736
|
-
return 0;
|
|
7737
|
-
}
|
|
7738
|
-
var result = Number(value);
|
|
7739
|
-
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
|
7740
|
-
return result;
|
|
7741
|
-
};
|
|
7742
|
-
var calculateBox = function calculateBox2(borderBox, styles2) {
|
|
7743
|
-
var margin = {
|
|
7744
|
-
top: parse(styles2.marginTop),
|
|
7745
|
-
right: parse(styles2.marginRight),
|
|
7746
|
-
bottom: parse(styles2.marginBottom),
|
|
7747
|
-
left: parse(styles2.marginLeft)
|
|
7748
|
-
};
|
|
7749
|
-
var padding = {
|
|
7750
|
-
top: parse(styles2.paddingTop),
|
|
7751
|
-
right: parse(styles2.paddingRight),
|
|
7752
|
-
bottom: parse(styles2.paddingBottom),
|
|
7753
|
-
left: parse(styles2.paddingLeft)
|
|
7754
|
-
};
|
|
7755
|
-
var border = {
|
|
7756
|
-
top: parse(styles2.borderTopWidth),
|
|
7757
|
-
right: parse(styles2.borderRightWidth),
|
|
7758
|
-
bottom: parse(styles2.borderBottomWidth),
|
|
7759
|
-
left: parse(styles2.borderLeftWidth)
|
|
7760
|
-
};
|
|
7761
|
-
return createBox({
|
|
7762
|
-
borderBox,
|
|
7763
|
-
margin,
|
|
7764
|
-
padding,
|
|
7765
|
-
border
|
|
8037
|
+
children: [
|
|
8038
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
8039
|
+
"div",
|
|
8040
|
+
{
|
|
8041
|
+
className: getClassNameLayer("chevron"),
|
|
8042
|
+
title: isSelected ? "Collapse" : "Expand",
|
|
8043
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ChevronDown, { size: "12" })
|
|
8044
|
+
}
|
|
8045
|
+
),
|
|
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 })
|
|
8049
|
+
] })
|
|
8050
|
+
]
|
|
8051
|
+
}
|
|
8052
|
+
) }),
|
|
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))
|
|
8054
|
+
]
|
|
8055
|
+
}
|
|
8056
|
+
);
|
|
8057
|
+
};
|
|
8058
|
+
var LayerTree = ({
|
|
8059
|
+
label: _label,
|
|
8060
|
+
zoneCompound
|
|
8061
|
+
}) => {
|
|
8062
|
+
const label = useAppStore((s) => {
|
|
8063
|
+
var _a, _b, _c, _d;
|
|
8064
|
+
if (_label) return _label;
|
|
8065
|
+
if (zoneCompound === rootDroppableId) return;
|
|
8066
|
+
const [componentId, slotId] = zoneCompound.split(":");
|
|
8067
|
+
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
8068
|
+
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
8069
|
+
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7766
8070
|
});
|
|
8071
|
+
const contentIds = useAppStore(
|
|
8072
|
+
(0, import_shallow6.useShallow)(
|
|
8073
|
+
(s) => {
|
|
8074
|
+
var _a, _b;
|
|
8075
|
+
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
8076
|
+
}
|
|
8077
|
+
)
|
|
8078
|
+
);
|
|
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" }) }),
|
|
8082
|
+
label
|
|
8083
|
+
] }),
|
|
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" }),
|
|
8086
|
+
contentIds.map((itemId, i) => {
|
|
8087
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
8088
|
+
Layer,
|
|
8089
|
+
{
|
|
8090
|
+
index: i,
|
|
8091
|
+
itemId,
|
|
8092
|
+
zoneCompound
|
|
8093
|
+
},
|
|
8094
|
+
itemId
|
|
8095
|
+
);
|
|
8096
|
+
})
|
|
8097
|
+
] })
|
|
8098
|
+
] });
|
|
7767
8099
|
};
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
8100
|
+
|
|
8101
|
+
// components/Puck/components/Outline/index.tsx
|
|
8102
|
+
var import_react48 = require("react");
|
|
8103
|
+
|
|
8104
|
+
// lib/data/find-zones-for-area.ts
|
|
8105
|
+
init_react_import();
|
|
8106
|
+
var findZonesForArea = (state, area) => {
|
|
8107
|
+
return Object.keys(state.indexes.zones).filter(
|
|
8108
|
+
(zone) => zone.split(":")[0] === area
|
|
8109
|
+
);
|
|
8110
|
+
};
|
|
8111
|
+
|
|
8112
|
+
// components/Puck/components/Outline/index.tsx
|
|
8113
|
+
var import_shallow7 = require("zustand/react/shallow");
|
|
8114
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
8115
|
+
var Outline = () => {
|
|
8116
|
+
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
8117
|
+
const rootZones = useAppStore(
|
|
8118
|
+
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
8119
|
+
);
|
|
8120
|
+
const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
8121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
8122
|
+
LayerTree,
|
|
8123
|
+
{
|
|
8124
|
+
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
8125
|
+
zoneCompound
|
|
8126
|
+
},
|
|
8127
|
+
zoneCompound
|
|
8128
|
+
)) });
|
|
7772
8129
|
};
|
|
7773
8130
|
|
|
7774
8131
|
// components/Puck/components/Canvas/index.tsx
|
|
7775
|
-
|
|
8132
|
+
init_react_import();
|
|
8133
|
+
var import_react51 = require("react");
|
|
7776
8134
|
|
|
7777
8135
|
// components/ViewportControls/index.tsx
|
|
7778
8136
|
init_react_import();
|
|
@@ -7780,17 +8138,17 @@ var import_react49 = require("react");
|
|
|
7780
8138
|
|
|
7781
8139
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
7782
8140
|
init_react_import();
|
|
7783
|
-
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" };
|
|
7784
8142
|
|
|
7785
8143
|
// components/ViewportControls/index.tsx
|
|
7786
|
-
var
|
|
8144
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
7787
8145
|
var icons = {
|
|
7788
|
-
Smartphone: /* @__PURE__ */ (0,
|
|
7789
|
-
Tablet: /* @__PURE__ */ (0,
|
|
7790
|
-
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 })
|
|
7791
8149
|
};
|
|
7792
|
-
var
|
|
7793
|
-
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);
|
|
7794
8152
|
var ViewportButton = ({
|
|
7795
8153
|
children,
|
|
7796
8154
|
height = "auto",
|
|
@@ -7803,7 +8161,7 @@ var ViewportButton = ({
|
|
|
7803
8161
|
(0, import_react49.useEffect)(() => {
|
|
7804
8162
|
setIsActive(width === viewports.current.width);
|
|
7805
8163
|
}, [width, viewports.current.width]);
|
|
7806
|
-
return /* @__PURE__ */ (0,
|
|
8164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7807
8165
|
IconButton,
|
|
7808
8166
|
{
|
|
7809
8167
|
type: "button",
|
|
@@ -7813,7 +8171,7 @@ var ViewportButton = ({
|
|
|
7813
8171
|
e.stopPropagation();
|
|
7814
8172
|
onClick({ width, height });
|
|
7815
8173
|
},
|
|
7816
|
-
children: /* @__PURE__ */ (0,
|
|
8174
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: getClassNameButton("inner"), children })
|
|
7817
8175
|
}
|
|
7818
8176
|
) });
|
|
7819
8177
|
};
|
|
@@ -7849,8 +8207,8 @@ var ViewportControls = ({
|
|
|
7849
8207
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
|
7850
8208
|
[autoZoom]
|
|
7851
8209
|
);
|
|
7852
|
-
return /* @__PURE__ */ (0,
|
|
7853
|
-
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)(
|
|
7854
8212
|
ViewportButton,
|
|
7855
8213
|
{
|
|
7856
8214
|
height: viewport.height,
|
|
@@ -7861,8 +8219,8 @@ var ViewportControls = ({
|
|
|
7861
8219
|
},
|
|
7862
8220
|
i
|
|
7863
8221
|
)),
|
|
7864
|
-
/* @__PURE__ */ (0,
|
|
7865
|
-
/* @__PURE__ */ (0,
|
|
8222
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("divider") }),
|
|
8223
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7866
8224
|
IconButton,
|
|
7867
8225
|
{
|
|
7868
8226
|
type: "button",
|
|
@@ -7877,10 +8235,10 @@ var ViewportControls = ({
|
|
|
7877
8235
|
)].value
|
|
7878
8236
|
);
|
|
7879
8237
|
},
|
|
7880
|
-
children: /* @__PURE__ */ (0,
|
|
8238
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ZoomOut, { size: 16 })
|
|
7881
8239
|
}
|
|
7882
8240
|
),
|
|
7883
|
-
/* @__PURE__ */ (0,
|
|
8241
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7884
8242
|
IconButton,
|
|
7885
8243
|
{
|
|
7886
8244
|
type: "button",
|
|
@@ -7895,19 +8253,19 @@ var ViewportControls = ({
|
|
|
7895
8253
|
)].value
|
|
7896
8254
|
);
|
|
7897
8255
|
},
|
|
7898
|
-
children: /* @__PURE__ */ (0,
|
|
8256
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ZoomIn, { size: 16 })
|
|
7899
8257
|
}
|
|
7900
8258
|
),
|
|
7901
|
-
/* @__PURE__ */ (0,
|
|
7902
|
-
/* @__PURE__ */ (0,
|
|
8259
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("divider") }),
|
|
8260
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7903
8261
|
"select",
|
|
7904
8262
|
{
|
|
7905
|
-
className:
|
|
8263
|
+
className: getClassName25("zoomSelect"),
|
|
7906
8264
|
value: zoom.toString(),
|
|
7907
8265
|
onChange: (e) => {
|
|
7908
8266
|
onZoom(parseFloat(e.currentTarget.value));
|
|
7909
8267
|
},
|
|
7910
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
|
8268
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7911
8269
|
"option",
|
|
7912
8270
|
{
|
|
7913
8271
|
value: option.value,
|
|
@@ -7922,44 +8280,44 @@ var ViewportControls = ({
|
|
|
7922
8280
|
|
|
7923
8281
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
7924
8282
|
init_react_import();
|
|
7925
|
-
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" };
|
|
7926
8284
|
|
|
7927
|
-
//
|
|
8285
|
+
// components/Puck/components/Canvas/index.tsx
|
|
8286
|
+
var import_shallow8 = require("zustand/react/shallow");
|
|
8287
|
+
|
|
8288
|
+
// lib/frame-context.tsx
|
|
7928
8289
|
init_react_import();
|
|
7929
|
-
var
|
|
7930
|
-
var
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
|
7949
|
-
autoZoom = 1;
|
|
7950
|
-
zoom = 1;
|
|
7951
|
-
rootHeight = viewportHeight;
|
|
7952
|
-
}
|
|
8290
|
+
var import_react50 = require("react");
|
|
8291
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
8292
|
+
var FrameContext = (0, import_react50.createContext)(null);
|
|
8293
|
+
var FrameProvider = ({
|
|
8294
|
+
children
|
|
8295
|
+
}) => {
|
|
8296
|
+
const frameRef = (0, import_react50.useRef)(null);
|
|
8297
|
+
const value = (0, import_react50.useMemo)(
|
|
8298
|
+
() => ({
|
|
8299
|
+
frameRef
|
|
8300
|
+
}),
|
|
8301
|
+
[]
|
|
8302
|
+
);
|
|
8303
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(FrameContext.Provider, { value, children });
|
|
8304
|
+
};
|
|
8305
|
+
var useCanvasFrame = () => {
|
|
8306
|
+
const context = (0, import_react50.useContext)(FrameContext);
|
|
8307
|
+
if (context === null) {
|
|
8308
|
+
throw new Error("useCanvasFrame must be used within a FrameProvider");
|
|
7953
8309
|
}
|
|
7954
|
-
return
|
|
8310
|
+
return context;
|
|
7955
8311
|
};
|
|
7956
8312
|
|
|
7957
8313
|
// components/Puck/components/Canvas/index.tsx
|
|
7958
|
-
var
|
|
7959
|
-
var
|
|
7960
|
-
var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
|
|
8314
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
8315
|
+
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
|
7961
8316
|
var ZOOM_ON_CHANGE = true;
|
|
8317
|
+
var TRANSITION_DURATION = 150;
|
|
7962
8318
|
var Canvas = () => {
|
|
8319
|
+
const { frameRef } = useCanvasFrame();
|
|
8320
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
7963
8321
|
const {
|
|
7964
8322
|
dispatch,
|
|
7965
8323
|
overrides,
|
|
@@ -7979,24 +8337,32 @@ var Canvas = () => {
|
|
|
7979
8337
|
iframe: s.iframe
|
|
7980
8338
|
}))
|
|
7981
8339
|
);
|
|
7982
|
-
const {
|
|
8340
|
+
const {
|
|
8341
|
+
leftSideBarVisible,
|
|
8342
|
+
rightSideBarVisible,
|
|
8343
|
+
leftSideBarWidth,
|
|
8344
|
+
rightSideBarWidth,
|
|
8345
|
+
viewports
|
|
8346
|
+
} = useAppStore(
|
|
7983
8347
|
(0, import_shallow8.useShallow)((s) => ({
|
|
7984
8348
|
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
7985
8349
|
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
8350
|
+
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
8351
|
+
rightSideBarWidth: s.state.ui.rightSideBarWidth,
|
|
7986
8352
|
viewports: s.state.ui.viewports
|
|
7987
8353
|
}))
|
|
7988
8354
|
);
|
|
7989
|
-
const
|
|
7990
|
-
const
|
|
7991
|
-
const defaultRender = (0,
|
|
7992
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
|
8355
|
+
const [showTransition, setShowTransition] = (0, import_react51.useState)(false);
|
|
8356
|
+
const isResizingRef = (0, import_react51.useRef)(false);
|
|
8357
|
+
const defaultRender = (0, import_react51.useMemo)(() => {
|
|
8358
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children });
|
|
7993
8359
|
return PuckDefault;
|
|
7994
8360
|
}, []);
|
|
7995
|
-
const CustomPreview = (0,
|
|
8361
|
+
const CustomPreview = (0, import_react51.useMemo)(
|
|
7996
8362
|
() => overrides.preview || defaultRender,
|
|
7997
8363
|
[overrides]
|
|
7998
8364
|
);
|
|
7999
|
-
const getFrameDimensions = (0,
|
|
8365
|
+
const getFrameDimensions = (0, import_react51.useCallback)(() => {
|
|
8000
8366
|
if (frameRef.current) {
|
|
8001
8367
|
const frame = frameRef.current;
|
|
8002
8368
|
const box = getBox(frame);
|
|
@@ -8004,74 +8370,73 @@ var Canvas = () => {
|
|
|
8004
8370
|
}
|
|
8005
8371
|
return { width: 0, height: 0 };
|
|
8006
8372
|
}, [frameRef]);
|
|
8007
|
-
|
|
8008
|
-
(
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
},
|
|
8019
|
-
[frameRef, zoomConfig, viewports]
|
|
8020
|
-
);
|
|
8021
|
-
(0, import_react50.useEffect)(() => {
|
|
8022
|
-
setShowTransition(false);
|
|
8023
|
-
resetAutoZoom(viewports);
|
|
8024
|
-
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
|
8025
|
-
(0, import_react50.useEffect)(() => {
|
|
8373
|
+
(0, import_react51.useEffect)(() => {
|
|
8374
|
+
resetAutoZoom();
|
|
8375
|
+
}, [
|
|
8376
|
+
frameRef,
|
|
8377
|
+
leftSideBarVisible,
|
|
8378
|
+
rightSideBarVisible,
|
|
8379
|
+
leftSideBarWidth,
|
|
8380
|
+
rightSideBarWidth,
|
|
8381
|
+
viewports
|
|
8382
|
+
]);
|
|
8383
|
+
(0, import_react51.useEffect)(() => {
|
|
8026
8384
|
const { height: frameHeight } = getFrameDimensions();
|
|
8027
8385
|
if (viewports.current.height === "auto") {
|
|
8028
8386
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
8029
8387
|
rootHeight: frameHeight / zoomConfig.zoom
|
|
8030
8388
|
}));
|
|
8031
8389
|
}
|
|
8032
|
-
}, [zoomConfig.zoom]);
|
|
8033
|
-
(0,
|
|
8390
|
+
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
8391
|
+
(0, import_react51.useEffect)(() => {
|
|
8034
8392
|
if (ZOOM_ON_CHANGE) {
|
|
8035
|
-
setShowTransition(true);
|
|
8036
|
-
resetAutoZoom(viewports);
|
|
8037
|
-
}
|
|
8038
|
-
}, [viewports.current.width]);
|
|
8039
|
-
(0, import_react50.useEffect)(() => {
|
|
8040
|
-
const cb = () => {
|
|
8041
|
-
setShowTransition(false);
|
|
8042
8393
|
resetAutoZoom();
|
|
8043
|
-
}
|
|
8044
|
-
|
|
8394
|
+
}
|
|
8395
|
+
}, [viewports.current.width, viewports]);
|
|
8396
|
+
(0, import_react51.useEffect)(() => {
|
|
8397
|
+
if (!frameRef.current) return;
|
|
8398
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
8399
|
+
if (!isResizingRef.current) {
|
|
8400
|
+
resetAutoZoom();
|
|
8401
|
+
}
|
|
8402
|
+
});
|
|
8403
|
+
resizeObserver.observe(frameRef.current);
|
|
8045
8404
|
return () => {
|
|
8046
|
-
|
|
8405
|
+
resizeObserver.disconnect();
|
|
8047
8406
|
};
|
|
8048
|
-
}, []);
|
|
8049
|
-
const [showLoader, setShowLoader] = (0,
|
|
8050
|
-
(0,
|
|
8407
|
+
}, [frameRef.current]);
|
|
8408
|
+
const [showLoader, setShowLoader] = (0, import_react51.useState)(false);
|
|
8409
|
+
(0, import_react51.useEffect)(() => {
|
|
8051
8410
|
setTimeout(() => {
|
|
8052
8411
|
setShowLoader(true);
|
|
8053
8412
|
}, 500);
|
|
8054
8413
|
}, []);
|
|
8055
|
-
return /* @__PURE__ */ (0,
|
|
8414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
8056
8415
|
"div",
|
|
8057
8416
|
{
|
|
8058
|
-
className:
|
|
8417
|
+
className: getClassName26({
|
|
8059
8418
|
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
|
8060
8419
|
showLoader
|
|
8061
8420
|
}),
|
|
8062
|
-
onClick: () =>
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
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
|
+
},
|
|
8067
8431
|
children: [
|
|
8068
|
-
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)(
|
|
8069
8433
|
ViewportControls,
|
|
8070
8434
|
{
|
|
8071
8435
|
autoZoom: zoomConfig.autoZoom,
|
|
8072
8436
|
zoom: zoomConfig.zoom,
|
|
8073
8437
|
onViewportChange: (viewport) => {
|
|
8074
8438
|
setShowTransition(true);
|
|
8439
|
+
isResizingRef.current = true;
|
|
8075
8440
|
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
|
8076
8441
|
height: viewport.height || "auto",
|
|
8077
8442
|
zoom: zoomConfig.zoom
|
|
@@ -8082,41 +8447,40 @@ var Canvas = () => {
|
|
|
8082
8447
|
};
|
|
8083
8448
|
setUi(newUi);
|
|
8084
8449
|
if (ZOOM_ON_CHANGE) {
|
|
8085
|
-
resetAutoZoom(
|
|
8450
|
+
resetAutoZoom({
|
|
8451
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
8452
|
+
});
|
|
8086
8453
|
}
|
|
8087
8454
|
},
|
|
8088
8455
|
onZoom: (zoom) => {
|
|
8089
8456
|
setShowTransition(true);
|
|
8457
|
+
isResizingRef.current = true;
|
|
8090
8458
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
|
8091
8459
|
}
|
|
8092
8460
|
}
|
|
8093
8461
|
) }),
|
|
8094
|
-
/* @__PURE__ */ (0,
|
|
8095
|
-
/* @__PURE__ */ (0,
|
|
8462
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
|
8463
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8096
8464
|
"div",
|
|
8097
8465
|
{
|
|
8098
|
-
className:
|
|
8466
|
+
className: getClassName26("root"),
|
|
8099
8467
|
style: {
|
|
8100
8468
|
width: iframe.enabled ? viewports.current.width : "100%",
|
|
8101
8469
|
height: zoomConfig.rootHeight,
|
|
8102
8470
|
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
|
8103
|
-
transition: showTransition ?
|
|
8471
|
+
transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, height ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : "",
|
|
8104
8472
|
overflow: iframe.enabled ? void 0 : "auto"
|
|
8105
8473
|
},
|
|
8106
8474
|
suppressHydrationWarning: true,
|
|
8107
8475
|
id: "puck-canvas-root",
|
|
8108
8476
|
onTransitionEnd: () => {
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
bubbles: true,
|
|
8112
|
-
cancelable: false
|
|
8113
|
-
})
|
|
8114
|
-
);
|
|
8477
|
+
setShowTransition(false);
|
|
8478
|
+
isResizingRef.current = false;
|
|
8115
8479
|
},
|
|
8116
|
-
children: /* @__PURE__ */ (0,
|
|
8480
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Preview2, {}) })
|
|
8117
8481
|
}
|
|
8118
8482
|
),
|
|
8119
|
-
/* @__PURE__ */ (0,
|
|
8483
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Loader, { size: 24 }) })
|
|
8120
8484
|
] })
|
|
8121
8485
|
]
|
|
8122
8486
|
}
|
|
@@ -8125,7 +8489,7 @@ var Canvas = () => {
|
|
|
8125
8489
|
|
|
8126
8490
|
// lib/use-loaded-overrides.ts
|
|
8127
8491
|
init_react_import();
|
|
8128
|
-
var
|
|
8492
|
+
var import_react52 = require("react");
|
|
8129
8493
|
|
|
8130
8494
|
// lib/load-overrides.ts
|
|
8131
8495
|
init_react_import();
|
|
@@ -8135,8 +8499,11 @@ var loadOverrides = ({
|
|
|
8135
8499
|
}) => {
|
|
8136
8500
|
const collected = __spreadValues({}, overrides);
|
|
8137
8501
|
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
8502
|
+
if (!plugin.overrides) return;
|
|
8138
8503
|
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
|
8504
|
+
var _a;
|
|
8139
8505
|
const overridesType = _overridesType;
|
|
8506
|
+
if (!((_a = plugin.overrides) == null ? void 0 : _a[overridesType])) return;
|
|
8140
8507
|
if (overridesType === "fieldTypes") {
|
|
8141
8508
|
const fieldTypes = plugin.overrides.fieldTypes;
|
|
8142
8509
|
Object.keys(fieldTypes).forEach((fieldType) => {
|
|
@@ -8164,26 +8531,26 @@ var useLoadedOverrides = ({
|
|
|
8164
8531
|
overrides,
|
|
8165
8532
|
plugins
|
|
8166
8533
|
}) => {
|
|
8167
|
-
return (0,
|
|
8534
|
+
return (0, import_react52.useMemo)(() => {
|
|
8168
8535
|
return loadOverrides({ overrides, plugins });
|
|
8169
8536
|
}, [plugins, overrides]);
|
|
8170
8537
|
};
|
|
8171
8538
|
|
|
8172
8539
|
// components/DefaultOverride/index.tsx
|
|
8173
8540
|
init_react_import();
|
|
8174
|
-
var
|
|
8175
|
-
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 });
|
|
8176
8543
|
|
|
8177
8544
|
// lib/use-inject-css.ts
|
|
8178
8545
|
init_react_import();
|
|
8179
|
-
var
|
|
8546
|
+
var import_react53 = require("react");
|
|
8180
8547
|
var styles = ``;
|
|
8181
8548
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
8182
|
-
const [el, setEl] = (0,
|
|
8183
|
-
(0,
|
|
8549
|
+
const [el, setEl] = (0, import_react53.useState)();
|
|
8550
|
+
(0, import_react53.useEffect)(() => {
|
|
8184
8551
|
setEl(document.createElement("style"));
|
|
8185
8552
|
}, []);
|
|
8186
|
-
(0,
|
|
8553
|
+
(0, import_react53.useEffect)(() => {
|
|
8187
8554
|
var _a;
|
|
8188
8555
|
if (!el || typeof window === "undefined") {
|
|
8189
8556
|
return;
|
|
@@ -8203,10 +8570,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
8203
8570
|
|
|
8204
8571
|
// lib/use-preview-mode-hotkeys.ts
|
|
8205
8572
|
init_react_import();
|
|
8206
|
-
var
|
|
8573
|
+
var import_react54 = require("react");
|
|
8207
8574
|
var usePreviewModeHotkeys = () => {
|
|
8208
8575
|
const appStore = useAppStoreApi();
|
|
8209
|
-
const toggleInteractive = (0,
|
|
8576
|
+
const toggleInteractive = (0, import_react54.useCallback)(() => {
|
|
8210
8577
|
const dispatch = appStore.getState().dispatch;
|
|
8211
8578
|
dispatch({
|
|
8212
8579
|
type: "setUi",
|
|
@@ -8221,7 +8588,7 @@ var usePreviewModeHotkeys = () => {
|
|
|
8221
8588
|
|
|
8222
8589
|
// lib/use-puck.ts
|
|
8223
8590
|
init_react_import();
|
|
8224
|
-
var
|
|
8591
|
+
var import_react55 = require("react");
|
|
8225
8592
|
var import_zustand6 = require("zustand");
|
|
8226
8593
|
var generateUsePuck = (store) => {
|
|
8227
8594
|
const history = {
|
|
@@ -8252,10 +8619,9 @@ var generateUsePuck = (store) => {
|
|
|
8252
8619
|
return { zone: zoneCompound, index };
|
|
8253
8620
|
}
|
|
8254
8621
|
};
|
|
8255
|
-
|
|
8256
|
-
return __spreadProps(__spreadValues({}, storeData), { get });
|
|
8622
|
+
return storeData;
|
|
8257
8623
|
};
|
|
8258
|
-
var UsePuckStoreContext = (0,
|
|
8624
|
+
var UsePuckStoreContext = (0, import_react55.createContext)(
|
|
8259
8625
|
null
|
|
8260
8626
|
);
|
|
8261
8627
|
var convertToPickedStore = (store) => {
|
|
@@ -8269,12 +8635,12 @@ var convertToPickedStore = (store) => {
|
|
|
8269
8635
|
};
|
|
8270
8636
|
};
|
|
8271
8637
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8272
|
-
const [usePuckStore] = (0,
|
|
8638
|
+
const [usePuckStore] = (0, import_react55.useState)(
|
|
8273
8639
|
() => (0, import_zustand6.createStore)(
|
|
8274
8640
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8275
8641
|
)
|
|
8276
8642
|
);
|
|
8277
|
-
(0,
|
|
8643
|
+
(0, import_react55.useEffect)(() => {
|
|
8278
8644
|
return appStore.subscribe(
|
|
8279
8645
|
(store) => convertToPickedStore(store),
|
|
8280
8646
|
(pickedStore) => {
|
|
@@ -8286,7 +8652,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8286
8652
|
};
|
|
8287
8653
|
function createUsePuck() {
|
|
8288
8654
|
return function usePuck2(selector) {
|
|
8289
|
-
const usePuckApi = (0,
|
|
8655
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8290
8656
|
if (!usePuckApi) {
|
|
8291
8657
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8292
8658
|
}
|
|
@@ -8298,7 +8664,7 @@ function createUsePuck() {
|
|
|
8298
8664
|
};
|
|
8299
8665
|
}
|
|
8300
8666
|
function usePuck() {
|
|
8301
|
-
(0,
|
|
8667
|
+
(0, import_react55.useEffect)(() => {
|
|
8302
8668
|
console.warn(
|
|
8303
8669
|
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
|
8304
8670
|
);
|
|
@@ -8306,7 +8672,7 @@ function usePuck() {
|
|
|
8306
8672
|
return createUsePuck()((s) => s);
|
|
8307
8673
|
}
|
|
8308
8674
|
function useGetPuck() {
|
|
8309
|
-
const usePuckApi = (0,
|
|
8675
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8310
8676
|
if (!usePuckApi) {
|
|
8311
8677
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8312
8678
|
}
|
|
@@ -8318,18 +8684,18 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8318
8684
|
|
|
8319
8685
|
// components/Puck/components/Header/index.tsx
|
|
8320
8686
|
init_react_import();
|
|
8321
|
-
var
|
|
8687
|
+
var import_react56 = require("react");
|
|
8322
8688
|
|
|
8323
8689
|
// components/MenuBar/index.tsx
|
|
8324
8690
|
init_react_import();
|
|
8325
8691
|
|
|
8326
8692
|
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
|
8327
8693
|
init_react_import();
|
|
8328
|
-
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" };
|
|
8329
8695
|
|
|
8330
8696
|
// components/MenuBar/index.tsx
|
|
8331
|
-
var
|
|
8332
|
-
var
|
|
8697
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
8698
|
+
var getClassName27 = get_class_name_factory_default("MenuBar", styles_module_default22);
|
|
8333
8699
|
function MenuBar({
|
|
8334
8700
|
menuOpen = false,
|
|
8335
8701
|
renderHeaderActions,
|
|
@@ -8339,10 +8705,10 @@ function MenuBar({
|
|
|
8339
8705
|
const forward = useAppStore((s) => s.history.forward);
|
|
8340
8706
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
8341
8707
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
8342
|
-
return /* @__PURE__ */ (0,
|
|
8708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8343
8709
|
"div",
|
|
8344
8710
|
{
|
|
8345
|
-
className:
|
|
8711
|
+
className: getClassName27({ menuOpen }),
|
|
8346
8712
|
onClick: (event) => {
|
|
8347
8713
|
var _a;
|
|
8348
8714
|
const element = event.target;
|
|
@@ -8353,30 +8719,30 @@ function MenuBar({
|
|
|
8353
8719
|
setMenuOpen(false);
|
|
8354
8720
|
}
|
|
8355
8721
|
},
|
|
8356
|
-
children: /* @__PURE__ */ (0,
|
|
8357
|
-
/* @__PURE__ */ (0,
|
|
8358
|
-
/* @__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)(
|
|
8359
8725
|
IconButton,
|
|
8360
8726
|
{
|
|
8361
8727
|
type: "button",
|
|
8362
8728
|
title: "undo",
|
|
8363
8729
|
disabled: !hasPast,
|
|
8364
8730
|
onClick: back,
|
|
8365
|
-
children: /* @__PURE__ */ (0,
|
|
8731
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Undo2, { size: 21 })
|
|
8366
8732
|
}
|
|
8367
8733
|
),
|
|
8368
|
-
/* @__PURE__ */ (0,
|
|
8734
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8369
8735
|
IconButton,
|
|
8370
8736
|
{
|
|
8371
8737
|
type: "button",
|
|
8372
8738
|
title: "redo",
|
|
8373
8739
|
disabled: !hasFuture,
|
|
8374
8740
|
onClick: forward,
|
|
8375
|
-
children: /* @__PURE__ */ (0,
|
|
8741
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Redo2, { size: 21 })
|
|
8376
8742
|
}
|
|
8377
8743
|
)
|
|
8378
8744
|
] }),
|
|
8379
|
-
/* @__PURE__ */ (0,
|
|
8745
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_jsx_runtime43.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
|
8380
8746
|
] })
|
|
8381
8747
|
}
|
|
8382
8748
|
);
|
|
@@ -8384,11 +8750,11 @@ function MenuBar({
|
|
|
8384
8750
|
|
|
8385
8751
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
|
8386
8752
|
init_react_import();
|
|
8387
|
-
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" };
|
|
8388
8754
|
|
|
8389
8755
|
// components/Puck/components/Header/index.tsx
|
|
8390
|
-
var
|
|
8391
|
-
var
|
|
8756
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8757
|
+
var getClassName28 = get_class_name_factory_default("PuckHeader", styles_module_default23);
|
|
8392
8758
|
var HeaderInner = () => {
|
|
8393
8759
|
const {
|
|
8394
8760
|
onPublish,
|
|
@@ -8400,7 +8766,7 @@ var HeaderInner = () => {
|
|
|
8400
8766
|
} = usePropsContext();
|
|
8401
8767
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8402
8768
|
const appStore = useAppStoreApi();
|
|
8403
|
-
const defaultHeaderRender = (0,
|
|
8769
|
+
const defaultHeaderRender = (0, import_react56.useMemo)(() => {
|
|
8404
8770
|
if (renderHeader) {
|
|
8405
8771
|
console.warn(
|
|
8406
8772
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8409,13 +8775,13 @@ var HeaderInner = () => {
|
|
|
8409
8775
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
8410
8776
|
const Comp = renderHeader;
|
|
8411
8777
|
const appState = useAppStore((s) => s.state);
|
|
8412
|
-
return /* @__PURE__ */ (0,
|
|
8778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
8413
8779
|
};
|
|
8414
8780
|
return RenderHeader;
|
|
8415
8781
|
}
|
|
8416
8782
|
return DefaultOverride;
|
|
8417
8783
|
}, [renderHeader]);
|
|
8418
|
-
const defaultHeaderActionsRender = (0,
|
|
8784
|
+
const defaultHeaderActionsRender = (0, import_react56.useMemo)(() => {
|
|
8419
8785
|
if (renderHeaderActions) {
|
|
8420
8786
|
console.warn(
|
|
8421
8787
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8423,7 +8789,7 @@ var HeaderInner = () => {
|
|
|
8423
8789
|
const RenderHeader = (props) => {
|
|
8424
8790
|
const Comp = renderHeaderActions;
|
|
8425
8791
|
const appState = useAppStore((s) => s.state);
|
|
8426
|
-
return /* @__PURE__ */ (0,
|
|
8792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
8427
8793
|
};
|
|
8428
8794
|
return RenderHeader;
|
|
8429
8795
|
}
|
|
@@ -8435,7 +8801,7 @@ var HeaderInner = () => {
|
|
|
8435
8801
|
const CustomHeaderActions = useAppStore(
|
|
8436
8802
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8437
8803
|
);
|
|
8438
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8804
|
+
const [menuOpen, setMenuOpen] = (0, import_react56.useState)(false);
|
|
8439
8805
|
const rootTitle = useAppStore((s) => {
|
|
8440
8806
|
var _a, _b;
|
|
8441
8807
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8445,7 +8811,7 @@ var HeaderInner = () => {
|
|
|
8445
8811
|
const rightSideBarVisible = useAppStore(
|
|
8446
8812
|
(s) => s.state.ui.rightSideBarVisible
|
|
8447
8813
|
);
|
|
8448
|
-
const toggleSidebars = (0,
|
|
8814
|
+
const toggleSidebars = (0, import_react56.useCallback)(
|
|
8449
8815
|
(sidebar) => {
|
|
8450
8816
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8451
8817
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8459,27 +8825,27 @@ var HeaderInner = () => {
|
|
|
8459
8825
|
},
|
|
8460
8826
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
8461
8827
|
);
|
|
8462
|
-
return /* @__PURE__ */ (0,
|
|
8828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8463
8829
|
CustomHeader,
|
|
8464
8830
|
{
|
|
8465
|
-
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)(
|
|
8466
8832
|
Button,
|
|
8467
8833
|
{
|
|
8468
8834
|
onClick: () => {
|
|
8469
8835
|
const data = appStore.getState().state.data;
|
|
8470
8836
|
onPublish && onPublish(data);
|
|
8471
8837
|
},
|
|
8472
|
-
icon: /* @__PURE__ */ (0,
|
|
8838
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Globe, { size: "14px" }),
|
|
8473
8839
|
children: "Publish"
|
|
8474
8840
|
}
|
|
8475
8841
|
) }) }),
|
|
8476
|
-
children: /* @__PURE__ */ (0,
|
|
8842
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8477
8843
|
"header",
|
|
8478
8844
|
{
|
|
8479
|
-
className:
|
|
8480
|
-
children: /* @__PURE__ */ (0,
|
|
8481
|
-
/* @__PURE__ */ (0,
|
|
8482
|
-
/* @__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)(
|
|
8483
8849
|
IconButton,
|
|
8484
8850
|
{
|
|
8485
8851
|
type: "button",
|
|
@@ -8487,10 +8853,10 @@ var HeaderInner = () => {
|
|
|
8487
8853
|
toggleSidebars("left");
|
|
8488
8854
|
},
|
|
8489
8855
|
title: "Toggle left sidebar",
|
|
8490
|
-
children: /* @__PURE__ */ (0,
|
|
8856
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PanelLeft, { focusable: "false" })
|
|
8491
8857
|
}
|
|
8492
8858
|
) }),
|
|
8493
|
-
/* @__PURE__ */ (0,
|
|
8859
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName28("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8494
8860
|
IconButton,
|
|
8495
8861
|
{
|
|
8496
8862
|
type: "button",
|
|
@@ -8498,19 +8864,19 @@ var HeaderInner = () => {
|
|
|
8498
8864
|
toggleSidebars("right");
|
|
8499
8865
|
},
|
|
8500
8866
|
title: "Toggle right sidebar",
|
|
8501
|
-
children: /* @__PURE__ */ (0,
|
|
8867
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PanelRight, { focusable: "false" })
|
|
8502
8868
|
}
|
|
8503
8869
|
) })
|
|
8504
8870
|
] }),
|
|
8505
|
-
/* @__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: [
|
|
8506
8872
|
headerTitle || rootTitle || "Page",
|
|
8507
|
-
headerPath && /* @__PURE__ */ (0,
|
|
8873
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
|
|
8508
8874
|
" ",
|
|
8509
|
-
/* @__PURE__ */ (0,
|
|
8875
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("code", { className: getClassName28("path"), children: headerPath })
|
|
8510
8876
|
] })
|
|
8511
8877
|
] }) }),
|
|
8512
|
-
/* @__PURE__ */ (0,
|
|
8513
|
-
/* @__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)(
|
|
8514
8880
|
IconButton,
|
|
8515
8881
|
{
|
|
8516
8882
|
type: "button",
|
|
@@ -8518,23 +8884,23 @@ var HeaderInner = () => {
|
|
|
8518
8884
|
return setMenuOpen(!menuOpen);
|
|
8519
8885
|
},
|
|
8520
8886
|
title: "Toggle menu bar",
|
|
8521
|
-
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" })
|
|
8522
8888
|
}
|
|
8523
8889
|
) }),
|
|
8524
|
-
/* @__PURE__ */ (0,
|
|
8890
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8525
8891
|
MenuBar,
|
|
8526
8892
|
{
|
|
8527
8893
|
dispatch,
|
|
8528
8894
|
onPublish,
|
|
8529
8895
|
menuOpen,
|
|
8530
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
|
8896
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8531
8897
|
Button,
|
|
8532
8898
|
{
|
|
8533
8899
|
onClick: () => {
|
|
8534
8900
|
const data = appStore.getState().state.data;
|
|
8535
8901
|
onPublish && onPublish(data);
|
|
8536
8902
|
},
|
|
8537
|
-
icon: /* @__PURE__ */ (0,
|
|
8903
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Globe, { size: "14px" }),
|
|
8538
8904
|
children: "Publish"
|
|
8539
8905
|
}
|
|
8540
8906
|
) }),
|
|
@@ -8548,12 +8914,205 @@ var HeaderInner = () => {
|
|
|
8548
8914
|
}
|
|
8549
8915
|
);
|
|
8550
8916
|
};
|
|
8551
|
-
var Header = (0,
|
|
8917
|
+
var Header = (0, import_react56.memo)(HeaderInner);
|
|
8918
|
+
|
|
8919
|
+
// components/Puck/components/Sidebar/index.tsx
|
|
8920
|
+
init_react_import();
|
|
8921
|
+
|
|
8922
|
+
// components/Puck/components/ResizeHandle/index.tsx
|
|
8923
|
+
init_react_import();
|
|
8924
|
+
var import_react57 = require("react");
|
|
8925
|
+
|
|
8926
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
8927
|
+
init_react_import();
|
|
8928
|
+
var styles_module_default24 = { "ResizeHandle": "_ResizeHandle_144bf_2", "ResizeHandle--left": "_ResizeHandle--left_144bf_16", "ResizeHandle--right": "_ResizeHandle--right_144bf_20" };
|
|
8929
|
+
|
|
8930
|
+
// components/Puck/components/ResizeHandle/index.tsx
|
|
8931
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
8932
|
+
var getClassName29 = get_class_name_factory_default("ResizeHandle", styles_module_default24);
|
|
8933
|
+
var ResizeHandle = ({
|
|
8934
|
+
position,
|
|
8935
|
+
sidebarRef,
|
|
8936
|
+
onResize,
|
|
8937
|
+
onResizeEnd
|
|
8938
|
+
}) => {
|
|
8939
|
+
const { frameRef } = useCanvasFrame();
|
|
8940
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
8941
|
+
const handleRef = (0, import_react57.useRef)(null);
|
|
8942
|
+
const isDragging = (0, import_react57.useRef)(false);
|
|
8943
|
+
const startX = (0, import_react57.useRef)(0);
|
|
8944
|
+
const startWidth = (0, import_react57.useRef)(0);
|
|
8945
|
+
const handleMouseMove = (0, import_react57.useCallback)(
|
|
8946
|
+
(e) => {
|
|
8947
|
+
if (!isDragging.current) return;
|
|
8948
|
+
const delta = e.clientX - startX.current;
|
|
8949
|
+
const newWidth = position === "left" ? startWidth.current + delta : startWidth.current - delta;
|
|
8950
|
+
const width = Math.max(192, newWidth);
|
|
8951
|
+
onResize(width);
|
|
8952
|
+
e.preventDefault();
|
|
8953
|
+
},
|
|
8954
|
+
[onResize, position]
|
|
8955
|
+
);
|
|
8956
|
+
const handleMouseUp = (0, import_react57.useCallback)(() => {
|
|
8957
|
+
var _a;
|
|
8958
|
+
if (!isDragging.current) return;
|
|
8959
|
+
isDragging.current = false;
|
|
8960
|
+
document.body.style.cursor = "";
|
|
8961
|
+
document.body.style.userSelect = "";
|
|
8962
|
+
const overlay = document.getElementById("resize-overlay");
|
|
8963
|
+
if (overlay) {
|
|
8964
|
+
document.body.removeChild(overlay);
|
|
8965
|
+
}
|
|
8966
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
8967
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
8968
|
+
const finalWidth = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
8969
|
+
onResizeEnd(finalWidth);
|
|
8970
|
+
resetAutoZoom();
|
|
8971
|
+
}, [onResizeEnd]);
|
|
8972
|
+
const handleMouseDown = (0, import_react57.useCallback)(
|
|
8973
|
+
(e) => {
|
|
8974
|
+
var _a;
|
|
8975
|
+
isDragging.current = true;
|
|
8976
|
+
startX.current = e.clientX;
|
|
8977
|
+
startWidth.current = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
8978
|
+
document.body.style.cursor = "col-resize";
|
|
8979
|
+
document.body.style.userSelect = "none";
|
|
8980
|
+
const overlay = document.createElement("div");
|
|
8981
|
+
overlay.id = "resize-overlay";
|
|
8982
|
+
overlay.setAttribute("data-resize-overlay", "");
|
|
8983
|
+
document.body.appendChild(overlay);
|
|
8984
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
8985
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
8986
|
+
e.preventDefault();
|
|
8987
|
+
},
|
|
8988
|
+
[position, handleMouseMove, handleMouseUp]
|
|
8989
|
+
);
|
|
8990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
8991
|
+
"div",
|
|
8992
|
+
{
|
|
8993
|
+
ref: handleRef,
|
|
8994
|
+
className: getClassName29({ [position]: true }),
|
|
8995
|
+
onMouseDown: handleMouseDown
|
|
8996
|
+
}
|
|
8997
|
+
);
|
|
8998
|
+
};
|
|
8999
|
+
|
|
9000
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Sidebar/styles.module.css#css-module
|
|
9001
|
+
init_react_import();
|
|
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" };
|
|
9003
|
+
|
|
9004
|
+
// components/Puck/components/Sidebar/index.tsx
|
|
9005
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
9006
|
+
var getClassName30 = get_class_name_factory_default("Sidebar", styles_module_default25);
|
|
9007
|
+
var Sidebar = ({
|
|
9008
|
+
position,
|
|
9009
|
+
sidebarRef,
|
|
9010
|
+
isVisible,
|
|
9011
|
+
width,
|
|
9012
|
+
onResize,
|
|
9013
|
+
onResizeEnd,
|
|
9014
|
+
children
|
|
9015
|
+
}) => {
|
|
9016
|
+
if (!isVisible) return null;
|
|
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)(
|
|
9020
|
+
ResizeHandle,
|
|
9021
|
+
{
|
|
9022
|
+
position,
|
|
9023
|
+
sidebarRef,
|
|
9024
|
+
onResize,
|
|
9025
|
+
onResizeEnd
|
|
9026
|
+
}
|
|
9027
|
+
) })
|
|
9028
|
+
] });
|
|
9029
|
+
};
|
|
9030
|
+
|
|
9031
|
+
// lib/use-sidebar-resize.ts
|
|
9032
|
+
init_react_import();
|
|
9033
|
+
var import_react58 = require("react");
|
|
9034
|
+
function useSidebarResize(position, dispatch) {
|
|
9035
|
+
const [width, setWidth] = (0, import_react58.useState)(null);
|
|
9036
|
+
const sidebarRef = (0, import_react58.useRef)(null);
|
|
9037
|
+
const storeWidth = useAppStore(
|
|
9038
|
+
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
9039
|
+
);
|
|
9040
|
+
(0, import_react58.useEffect)(() => {
|
|
9041
|
+
if (typeof window !== "undefined" && !storeWidth) {
|
|
9042
|
+
try {
|
|
9043
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
9044
|
+
if (savedWidths) {
|
|
9045
|
+
const widths = JSON.parse(savedWidths);
|
|
9046
|
+
const savedWidth = widths[position];
|
|
9047
|
+
const key = position === "left" ? "leftSideBarWidth" : "rightSideBarWidth";
|
|
9048
|
+
if (savedWidth) {
|
|
9049
|
+
dispatch({
|
|
9050
|
+
type: "setUi",
|
|
9051
|
+
ui: {
|
|
9052
|
+
[key]: savedWidth
|
|
9053
|
+
}
|
|
9054
|
+
});
|
|
9055
|
+
}
|
|
9056
|
+
}
|
|
9057
|
+
} catch (error) {
|
|
9058
|
+
console.error(
|
|
9059
|
+
`Failed to load ${position} sidebar width from localStorage`,
|
|
9060
|
+
error
|
|
9061
|
+
);
|
|
9062
|
+
}
|
|
9063
|
+
}
|
|
9064
|
+
}, [dispatch, position, storeWidth]);
|
|
9065
|
+
(0, import_react58.useEffect)(() => {
|
|
9066
|
+
if (storeWidth !== void 0) {
|
|
9067
|
+
setWidth(storeWidth);
|
|
9068
|
+
}
|
|
9069
|
+
}, [storeWidth]);
|
|
9070
|
+
const handleResizeEnd = (0, import_react58.useCallback)(
|
|
9071
|
+
(width2) => {
|
|
9072
|
+
dispatch({
|
|
9073
|
+
type: "setUi",
|
|
9074
|
+
ui: {
|
|
9075
|
+
[position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: width2
|
|
9076
|
+
}
|
|
9077
|
+
});
|
|
9078
|
+
let widths = {};
|
|
9079
|
+
try {
|
|
9080
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
9081
|
+
widths = savedWidths ? JSON.parse(savedWidths) : {};
|
|
9082
|
+
} catch (error) {
|
|
9083
|
+
console.error(
|
|
9084
|
+
`Failed to save ${position} sidebar width to localStorage`,
|
|
9085
|
+
error
|
|
9086
|
+
);
|
|
9087
|
+
} finally {
|
|
9088
|
+
localStorage.setItem(
|
|
9089
|
+
"puck-sidebar-widths",
|
|
9090
|
+
JSON.stringify(__spreadProps(__spreadValues({}, widths), {
|
|
9091
|
+
[position]: width2
|
|
9092
|
+
}))
|
|
9093
|
+
);
|
|
9094
|
+
}
|
|
9095
|
+
window.dispatchEvent(
|
|
9096
|
+
new CustomEvent("viewportchange", {
|
|
9097
|
+
bubbles: true,
|
|
9098
|
+
cancelable: false
|
|
9099
|
+
})
|
|
9100
|
+
);
|
|
9101
|
+
},
|
|
9102
|
+
[dispatch, position]
|
|
9103
|
+
);
|
|
9104
|
+
return {
|
|
9105
|
+
width,
|
|
9106
|
+
setWidth,
|
|
9107
|
+
sidebarRef,
|
|
9108
|
+
handleResizeEnd
|
|
9109
|
+
};
|
|
9110
|
+
}
|
|
8552
9111
|
|
|
8553
9112
|
// components/Puck/index.tsx
|
|
8554
|
-
var
|
|
8555
|
-
var
|
|
8556
|
-
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);
|
|
8557
9116
|
var FieldSideBar = () => {
|
|
8558
9117
|
const title = useAppStore(
|
|
8559
9118
|
(s) => {
|
|
@@ -8561,13 +9120,13 @@ var FieldSideBar = () => {
|
|
|
8561
9120
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
8562
9121
|
}
|
|
8563
9122
|
);
|
|
8564
|
-
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, {}) });
|
|
8565
9124
|
};
|
|
8566
|
-
var propsContext = (0,
|
|
9125
|
+
var propsContext = (0, import_react59.createContext)({});
|
|
8567
9126
|
function PropsProvider(props) {
|
|
8568
|
-
return /* @__PURE__ */ (0,
|
|
9127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
8569
9128
|
}
|
|
8570
|
-
var usePropsContext = () => (0,
|
|
9129
|
+
var usePropsContext = () => (0, import_react59.useContext)(propsContext);
|
|
8571
9130
|
function PuckProvider({ children }) {
|
|
8572
9131
|
const {
|
|
8573
9132
|
config,
|
|
@@ -8581,16 +9140,17 @@ function PuckProvider({ children }) {
|
|
|
8581
9140
|
iframe: _iframe,
|
|
8582
9141
|
initialHistory: _initialHistory,
|
|
8583
9142
|
metadata,
|
|
8584
|
-
onAction
|
|
9143
|
+
onAction,
|
|
9144
|
+
fieldTransforms
|
|
8585
9145
|
} = usePropsContext();
|
|
8586
|
-
const iframe = (0,
|
|
9146
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8587
9147
|
() => __spreadValues({
|
|
8588
9148
|
enabled: true,
|
|
8589
9149
|
waitForStyles: true
|
|
8590
9150
|
}, _iframe),
|
|
8591
9151
|
[_iframe]
|
|
8592
9152
|
);
|
|
8593
|
-
const [generatedAppState] = (0,
|
|
9153
|
+
const [generatedAppState] = (0, import_react59.useState)(() => {
|
|
8594
9154
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8595
9155
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8596
9156
|
let clientUiState = {};
|
|
@@ -8619,7 +9179,7 @@ function PuckProvider({ children }) {
|
|
|
8619
9179
|
}
|
|
8620
9180
|
}
|
|
8621
9181
|
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_g = initialData == null ? void 0 : initialData.root) == null ? void 0 : _g.props)) {
|
|
8622
|
-
console.
|
|
9182
|
+
console.warn(
|
|
8623
9183
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
|
8624
9184
|
);
|
|
8625
9185
|
}
|
|
@@ -8650,7 +9210,7 @@ function PuckProvider({ children }) {
|
|
|
8650
9210
|
return walkAppState(newAppState, config);
|
|
8651
9211
|
});
|
|
8652
9212
|
const { appendData = true } = _initialHistory || {};
|
|
8653
|
-
const [blendedHistories] = (0,
|
|
9213
|
+
const [blendedHistories] = (0, import_react59.useState)(
|
|
8654
9214
|
[
|
|
8655
9215
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8656
9216
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8670,7 +9230,15 @@ function PuckProvider({ children }) {
|
|
|
8670
9230
|
overrides,
|
|
8671
9231
|
plugins
|
|
8672
9232
|
});
|
|
8673
|
-
const
|
|
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]);
|
|
9241
|
+
const generateAppStore = (0, import_react59.useCallback)(
|
|
8674
9242
|
(state) => {
|
|
8675
9243
|
return {
|
|
8676
9244
|
state,
|
|
@@ -8680,7 +9248,8 @@ function PuckProvider({ children }) {
|
|
|
8680
9248
|
viewports,
|
|
8681
9249
|
iframe,
|
|
8682
9250
|
onAction,
|
|
8683
|
-
metadata
|
|
9251
|
+
metadata,
|
|
9252
|
+
fieldTransforms: loadedFieldTransforms
|
|
8684
9253
|
};
|
|
8685
9254
|
},
|
|
8686
9255
|
[
|
|
@@ -8691,18 +9260,19 @@ function PuckProvider({ children }) {
|
|
|
8691
9260
|
viewports,
|
|
8692
9261
|
iframe,
|
|
8693
9262
|
onAction,
|
|
8694
|
-
metadata
|
|
9263
|
+
metadata,
|
|
9264
|
+
loadedFieldTransforms
|
|
8695
9265
|
]
|
|
8696
9266
|
);
|
|
8697
|
-
const [appStore] = (0,
|
|
9267
|
+
const [appStore] = (0, import_react59.useState)(
|
|
8698
9268
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8699
9269
|
);
|
|
8700
|
-
(0,
|
|
9270
|
+
(0, import_react59.useEffect)(() => {
|
|
8701
9271
|
if (process.env.NODE_ENV !== "production") {
|
|
8702
9272
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8703
9273
|
}
|
|
8704
9274
|
}, [appStore]);
|
|
8705
|
-
(0,
|
|
9275
|
+
(0, import_react59.useEffect)(() => {
|
|
8706
9276
|
const state = appStore.getState().state;
|
|
8707
9277
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8708
9278
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8711,8 +9281,8 @@ function PuckProvider({ children }) {
|
|
|
8711
9281
|
index: initialHistoryIndex,
|
|
8712
9282
|
initialAppState
|
|
8713
9283
|
});
|
|
8714
|
-
const previousData = (0,
|
|
8715
|
-
(0,
|
|
9284
|
+
const previousData = (0, import_react59.useRef)(null);
|
|
9285
|
+
(0, import_react59.useEffect)(() => {
|
|
8716
9286
|
appStore.subscribe(
|
|
8717
9287
|
(s) => s.state.data,
|
|
8718
9288
|
(data) => {
|
|
@@ -8726,11 +9296,11 @@ function PuckProvider({ children }) {
|
|
|
8726
9296
|
}, []);
|
|
8727
9297
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8728
9298
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8729
|
-
(0,
|
|
9299
|
+
(0, import_react59.useEffect)(() => {
|
|
8730
9300
|
const { resolveAndCommitData } = appStore.getState();
|
|
8731
9301
|
resolveAndCommitData();
|
|
8732
9302
|
}, []);
|
|
8733
|
-
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 }) });
|
|
8734
9304
|
}
|
|
8735
9305
|
function PuckLayout({ children }) {
|
|
8736
9306
|
const {
|
|
@@ -8738,7 +9308,7 @@ function PuckLayout({ children }) {
|
|
|
8738
9308
|
dnd,
|
|
8739
9309
|
initialHistory: _initialHistory
|
|
8740
9310
|
} = usePropsContext();
|
|
8741
|
-
const iframe = (0,
|
|
9311
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8742
9312
|
() => __spreadValues({
|
|
8743
9313
|
enabled: true,
|
|
8744
9314
|
waitForStyles: true
|
|
@@ -8746,12 +9316,24 @@ function PuckLayout({ children }) {
|
|
|
8746
9316
|
[_iframe]
|
|
8747
9317
|
);
|
|
8748
9318
|
useInjectGlobalCss(iframe.enabled);
|
|
9319
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
8749
9320
|
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
8750
9321
|
const rightSideBarVisible = useAppStore(
|
|
8751
9322
|
(s) => s.state.ui.rightSideBarVisible
|
|
8752
9323
|
);
|
|
8753
|
-
const
|
|
8754
|
-
|
|
9324
|
+
const {
|
|
9325
|
+
width: leftWidth,
|
|
9326
|
+
setWidth: setLeftWidth,
|
|
9327
|
+
sidebarRef: leftSidebarRef,
|
|
9328
|
+
handleResizeEnd: handleLeftSidebarResizeEnd
|
|
9329
|
+
} = useSidebarResize("left", dispatch);
|
|
9330
|
+
const {
|
|
9331
|
+
width: rightWidth,
|
|
9332
|
+
setWidth: setRightWidth,
|
|
9333
|
+
sidebarRef: rightSidebarRef,
|
|
9334
|
+
handleResizeEnd: handleRightSidebarResizeEnd
|
|
9335
|
+
} = useSidebarResize("right", dispatch);
|
|
9336
|
+
(0, import_react59.useEffect)(() => {
|
|
8755
9337
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8756
9338
|
dispatch({
|
|
8757
9339
|
type: "setUi",
|
|
@@ -8775,17 +9357,17 @@ function PuckLayout({ children }) {
|
|
|
8775
9357
|
};
|
|
8776
9358
|
}, []);
|
|
8777
9359
|
const overrides = useAppStore((s) => s.overrides);
|
|
8778
|
-
const CustomPuck = (0,
|
|
9360
|
+
const CustomPuck = (0, import_react59.useMemo)(
|
|
8779
9361
|
() => overrides.puck || DefaultOverride,
|
|
8780
9362
|
[overrides]
|
|
8781
9363
|
);
|
|
8782
|
-
const [mounted, setMounted] = (0,
|
|
8783
|
-
(0,
|
|
9364
|
+
const [mounted, setMounted] = (0, import_react59.useState)(false);
|
|
9365
|
+
(0, import_react59.useEffect)(() => {
|
|
8784
9366
|
setMounted(true);
|
|
8785
9367
|
}, []);
|
|
8786
9368
|
const ready = useAppStore((s) => s.status === "READY");
|
|
8787
9369
|
useMonitorHotkeys();
|
|
8788
|
-
(0,
|
|
9370
|
+
(0, import_react59.useEffect)(() => {
|
|
8789
9371
|
if (ready && iframe.enabled) {
|
|
8790
9372
|
const frameDoc = getFrame();
|
|
8791
9373
|
if (frameDoc) {
|
|
@@ -8794,8 +9376,8 @@ function PuckLayout({ children }) {
|
|
|
8794
9376
|
}
|
|
8795
9377
|
}, [ready, iframe.enabled]);
|
|
8796
9378
|
usePreviewModeHotkeys();
|
|
8797
|
-
return /* @__PURE__ */ (0,
|
|
8798
|
-
/* @__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)(
|
|
8799
9381
|
"div",
|
|
8800
9382
|
{
|
|
8801
9383
|
className: getLayoutClassName({
|
|
@@ -8803,22 +9385,57 @@ function PuckLayout({ children }) {
|
|
|
8803
9385
|
mounted,
|
|
8804
9386
|
rightSideBarVisible
|
|
8805
9387
|
}),
|
|
8806
|
-
children: /* @__PURE__ */ (0,
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
9388
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9389
|
+
"div",
|
|
9390
|
+
{
|
|
9391
|
+
className: getLayoutClassName("inner"),
|
|
9392
|
+
style: {
|
|
9393
|
+
gridTemplateColumns: `
|
|
9394
|
+
${leftSideBarVisible ? leftWidth ? `${leftWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
9395
|
+
var(--puck-frame-width)
|
|
9396
|
+
${rightSideBarVisible ? rightWidth ? `${rightWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
9397
|
+
`
|
|
9398
|
+
},
|
|
9399
|
+
children: [
|
|
9400
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Header, {}),
|
|
9401
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9402
|
+
Sidebar,
|
|
9403
|
+
{
|
|
9404
|
+
position: "left",
|
|
9405
|
+
sidebarRef: leftSidebarRef,
|
|
9406
|
+
isVisible: leftSideBarVisible,
|
|
9407
|
+
width: leftWidth,
|
|
9408
|
+
onResize: setLeftWidth,
|
|
9409
|
+
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
9410
|
+
children: [
|
|
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, {}) })
|
|
9413
|
+
]
|
|
9414
|
+
}
|
|
9415
|
+
),
|
|
9416
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Canvas, {}),
|
|
9417
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9418
|
+
Sidebar,
|
|
9419
|
+
{
|
|
9420
|
+
position: "right",
|
|
9421
|
+
sidebarRef: rightSidebarRef,
|
|
9422
|
+
isVisible: rightSideBarVisible,
|
|
9423
|
+
width: rightWidth,
|
|
9424
|
+
onResize: setRightWidth,
|
|
9425
|
+
onResizeEnd: handleRightSidebarResizeEnd,
|
|
9426
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(FieldSideBar, {})
|
|
9427
|
+
}
|
|
9428
|
+
)
|
|
9429
|
+
]
|
|
9430
|
+
}
|
|
9431
|
+
)
|
|
8815
9432
|
}
|
|
8816
|
-
) }) }),
|
|
8817
|
-
/* @__PURE__ */ (0,
|
|
9433
|
+
) }) }) }),
|
|
9434
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { id: "puck-portal-root", className: getClassName31("portal") })
|
|
8818
9435
|
] });
|
|
8819
9436
|
}
|
|
8820
9437
|
function Puck(props) {
|
|
8821
|
-
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)) })) }));
|
|
8822
9439
|
}
|
|
8823
9440
|
Puck.Components = Components;
|
|
8824
9441
|
Puck.Fields = Fields;
|
|
@@ -9017,9 +9634,9 @@ function resolveAllData(_0, _1) {
|
|
|
9017
9634
|
},
|
|
9018
9635
|
"force"
|
|
9019
9636
|
)).node;
|
|
9020
|
-
const resolvedDeep = yield
|
|
9637
|
+
const resolvedDeep = yield mapFields(
|
|
9021
9638
|
resolved,
|
|
9022
|
-
processContent,
|
|
9639
|
+
{ slot: ({ value }) => processContent(value) },
|
|
9023
9640
|
config
|
|
9024
9641
|
);
|
|
9025
9642
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
@@ -9065,8 +9682,10 @@ function resolveAllData(_0, _1) {
|
|
|
9065
9682
|
createUsePuck,
|
|
9066
9683
|
migrate,
|
|
9067
9684
|
overrideKeys,
|
|
9685
|
+
registerOverlayPortal,
|
|
9068
9686
|
renderContext,
|
|
9069
9687
|
resolveAllData,
|
|
9688
|
+
setDeep,
|
|
9070
9689
|
transformProps,
|
|
9071
9690
|
useGetPuck,
|
|
9072
9691
|
usePuck,
|