@measured/puck 0.20.0-canary.274fe3d9 → 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-4KAREQPB.mjs → chunk-ANWTLGCS.mjs} +2830 -2226
- package/dist/{chunk-32MJ3X3H.mjs → chunk-HUKJ36SA.mjs} +131 -69
- package/dist/index.css +155 -74
- package/dist/index.d.mts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +1609 -950
- package/dist/index.mjs +6 -2
- package/dist/no-external.css +155 -74
- package/dist/no-external.d.mts +2 -2
- package/dist/no-external.d.ts +2 -2
- package/dist/no-external.js +1609 -950
- package/dist/no-external.mjs +6 -2
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +138 -70
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-DrNRq2FV.d.mts → walk-tree-B57SgEEc.d.mts} +41 -3
- package/dist/{walk-tree-DrNRq2FV.d.ts → walk-tree-B57SgEEc.d.ts} +41 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -171,8 +171,10 @@ __export(bundle_exports, {
|
|
|
171
171
|
createUsePuck: () => createUsePuck,
|
|
172
172
|
migrate: () => migrate,
|
|
173
173
|
overrideKeys: () => overrideKeys,
|
|
174
|
+
registerOverlayPortal: () => registerOverlayPortal,
|
|
174
175
|
renderContext: () => renderContext,
|
|
175
176
|
resolveAllData: () => resolveAllData,
|
|
177
|
+
setDeep: () => setDeep,
|
|
176
178
|
transformProps: () => transformProps,
|
|
177
179
|
useGetPuck: () => useGetPuck,
|
|
178
180
|
usePuck: () => usePuck,
|
|
@@ -193,6 +195,9 @@ init_react_import();
|
|
|
193
195
|
// types/API/Viewports.ts
|
|
194
196
|
init_react_import();
|
|
195
197
|
|
|
198
|
+
// types/API/FieldTransforms.ts
|
|
199
|
+
init_react_import();
|
|
200
|
+
|
|
196
201
|
// types/index.ts
|
|
197
202
|
init_react_import();
|
|
198
203
|
|
|
@@ -203,8 +208,9 @@ var overrideKeys = [
|
|
|
203
208
|
"headerActions",
|
|
204
209
|
"fields",
|
|
205
210
|
"fieldLabel",
|
|
206
|
-
"
|
|
207
|
-
"
|
|
211
|
+
"drawer",
|
|
212
|
+
"drawerItem",
|
|
213
|
+
"componentOverlay",
|
|
208
214
|
"outline",
|
|
209
215
|
"puck",
|
|
210
216
|
"preview"
|
|
@@ -306,7 +312,7 @@ 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
318
|
var import_react20 = require("react");
|
|
@@ -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,110 +2428,374 @@ 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 };
|
|
2585
|
-
}
|
|
2586
|
-
line.setAttribute("x1", a.x.toString());
|
|
2587
|
-
line.setAttribute("x2", b.x.toString());
|
|
2588
|
-
line.setAttribute("y1", a.y.toString());
|
|
2589
|
-
line.setAttribute("y2", b.y.toString());
|
|
2590
|
-
line.setAttribute("style", `stroke:${color};stroke-width:2`);
|
|
2591
|
-
text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
|
|
2592
|
-
text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
|
|
2593
|
-
if (label) {
|
|
2594
|
-
text.innerHTML = label;
|
|
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
|
|
2595
2479
|
}
|
|
2596
|
-
}
|
|
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;
|
|
2797
|
+
}
|
|
2798
|
+
});
|
|
2597
2799
|
};
|
|
2598
2800
|
|
|
2599
2801
|
// lib/dnd/collision/directional/index.ts
|
|
@@ -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
|
)
|
|
@@ -4238,17 +4447,17 @@ init_react_import();
|
|
|
4238
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" };
|
|
4239
4448
|
|
|
4240
4449
|
// components/Drawer/index.tsx
|
|
4241
|
-
var
|
|
4450
|
+
var import_react38 = require("react");
|
|
4242
4451
|
|
|
4243
4452
|
// components/DragDropContext/index.tsx
|
|
4244
4453
|
init_react_import();
|
|
4245
|
-
var
|
|
4246
|
-
var
|
|
4454
|
+
var import_react36 = require("@dnd-kit/react");
|
|
4455
|
+
var import_react37 = require("react");
|
|
4247
4456
|
var import_dom = require("@dnd-kit/dom");
|
|
4248
4457
|
|
|
4249
4458
|
// components/DropZone/index.tsx
|
|
4250
4459
|
init_react_import();
|
|
4251
|
-
var
|
|
4460
|
+
var import_react34 = require("react");
|
|
4252
4461
|
|
|
4253
4462
|
// components/DraggableComponent/index.tsx
|
|
4254
4463
|
init_react_import();
|
|
@@ -4256,7 +4465,7 @@ var import_react24 = require("react");
|
|
|
4256
4465
|
|
|
4257
4466
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4258
4467
|
init_react_import();
|
|
4259
|
-
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" };
|
|
4260
4469
|
|
|
4261
4470
|
// components/DraggableComponent/index.tsx
|
|
4262
4471
|
var import_react_dom2 = require("react-dom");
|
|
@@ -4410,6 +4619,9 @@ var DefaultActionBar = ({
|
|
|
4410
4619
|
] }),
|
|
4411
4620
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
|
|
4412
4621
|
] });
|
|
4622
|
+
var DefaultOverlay = ({
|
|
4623
|
+
children
|
|
4624
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children });
|
|
4413
4625
|
var DraggableComponent = ({
|
|
4414
4626
|
children,
|
|
4415
4627
|
depth,
|
|
@@ -4603,9 +4815,16 @@ var DraggableComponent = ({
|
|
|
4603
4815
|
() => overrides.actionBar || DefaultActionBar,
|
|
4604
4816
|
[overrides.actionBar]
|
|
4605
4817
|
);
|
|
4818
|
+
const CustomOverlay = (0, import_react24.useMemo)(
|
|
4819
|
+
() => overrides.componentOverlay || DefaultOverlay,
|
|
4820
|
+
[overrides.componentOverlay]
|
|
4821
|
+
);
|
|
4606
4822
|
const onClick = (0, import_react24.useCallback)(
|
|
4607
4823
|
(e) => {
|
|
4608
|
-
e.
|
|
4824
|
+
const el = e.target;
|
|
4825
|
+
if (!el.closest("[data-puck-overlay-portal]")) {
|
|
4826
|
+
e.stopPropagation();
|
|
4827
|
+
}
|
|
4609
4828
|
dispatch({
|
|
4610
4829
|
type: "setUi",
|
|
4611
4830
|
ui: {
|
|
@@ -4845,7 +5064,16 @@ var DraggableComponent = ({
|
|
|
4845
5064
|
)
|
|
4846
5065
|
}
|
|
4847
5066
|
),
|
|
4848
|
-
/* @__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
|
+
) })
|
|
4849
5077
|
]
|
|
4850
5078
|
}
|
|
4851
5079
|
),
|
|
@@ -4860,7 +5088,7 @@ init_react_import();
|
|
|
4860
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" };
|
|
4861
5089
|
|
|
4862
5090
|
// components/DropZone/index.tsx
|
|
4863
|
-
var
|
|
5091
|
+
var import_react35 = require("@dnd-kit/react");
|
|
4864
5092
|
|
|
4865
5093
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
4866
5094
|
init_react_import();
|
|
@@ -5068,35 +5296,70 @@ init_react_import();
|
|
|
5068
5296
|
|
|
5069
5297
|
// lib/use-slots.tsx
|
|
5070
5298
|
init_react_import();
|
|
5299
|
+
|
|
5300
|
+
// lib/field-transforms/use-field-transforms.tsx
|
|
5301
|
+
init_react_import();
|
|
5071
5302
|
var import_react30 = require("react");
|
|
5072
|
-
function
|
|
5073
|
-
const
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
(
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
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;
|
|
5091
5327
|
return mapped;
|
|
5092
|
-
}, [config, item,
|
|
5328
|
+
}, [config, item, mappers]);
|
|
5093
5329
|
const mergedProps = (0, import_react30.useMemo)(
|
|
5094
|
-
() => __spreadValues(__spreadValues({}, item.props),
|
|
5095
|
-
[item.props,
|
|
5330
|
+
() => __spreadValues(__spreadValues({}, item.props), transformedProps),
|
|
5331
|
+
[item.props, transformedProps]
|
|
5096
5332
|
);
|
|
5097
5333
|
return mergedProps;
|
|
5098
5334
|
}
|
|
5099
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
|
+
|
|
5100
5363
|
// components/Render/index.tsx
|
|
5101
5364
|
var import_react32 = __toESM(require("react"));
|
|
5102
5365
|
|
|
@@ -5266,15 +5529,242 @@ function Render({
|
|
|
5266
5529
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
|
5267
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 }) })) }) });
|
|
5268
5531
|
}
|
|
5269
|
-
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 }) }) });
|
|
5270
|
-
}
|
|
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
|
+
});
|
|
5271
5761
|
|
|
5272
5762
|
// components/DropZone/index.tsx
|
|
5273
|
-
var
|
|
5274
|
-
var
|
|
5763
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
5764
|
+
var getClassName18 = get_class_name_factory_default("DropZone", styles_module_default12);
|
|
5275
5765
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
|
5276
5766
|
var RENDER_DEBUG = false;
|
|
5277
|
-
var DropZoneEditPure = (props) => /* @__PURE__ */ (0,
|
|
5767
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneEdit, __spreadValues({}, props));
|
|
5278
5768
|
var DropZoneChild = ({
|
|
5279
5769
|
zoneCompound,
|
|
5280
5770
|
componentId,
|
|
@@ -5285,9 +5775,9 @@ var DropZoneChild = ({
|
|
|
5285
5775
|
}) => {
|
|
5286
5776
|
var _a, _b;
|
|
5287
5777
|
const metadata = useAppStore((s) => s.metadata);
|
|
5288
|
-
const ctx = (0,
|
|
5778
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5289
5779
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
5290
|
-
const zoneStore = (0,
|
|
5780
|
+
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
5291
5781
|
const nodeProps = useAppStore(
|
|
5292
5782
|
(0, import_shallow4.useShallow)((s) => {
|
|
5293
5783
|
var _a2;
|
|
@@ -5307,7 +5797,7 @@ var DropZoneChild = ({
|
|
|
5307
5797
|
})
|
|
5308
5798
|
);
|
|
5309
5799
|
const appStore = useAppStoreApi();
|
|
5310
|
-
const item = (0,
|
|
5800
|
+
const item = (0, import_react34.useMemo)(() => {
|
|
5311
5801
|
if (nodeProps) {
|
|
5312
5802
|
const expanded = expandNode({
|
|
5313
5803
|
type: nodeType,
|
|
@@ -5329,7 +5819,7 @@ var DropZoneChild = ({
|
|
|
5329
5819
|
const componentConfig = useAppStore(
|
|
5330
5820
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
|
5331
5821
|
);
|
|
5332
|
-
const puckProps = (0,
|
|
5822
|
+
const puckProps = (0, import_react34.useMemo)(
|
|
5333
5823
|
() => ({
|
|
5334
5824
|
renderDropZone: DropZoneEditPure,
|
|
5335
5825
|
isEditing: true,
|
|
@@ -5352,19 +5842,20 @@ var DropZoneChild = ({
|
|
|
5352
5842
|
}
|
|
5353
5843
|
);
|
|
5354
5844
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
|
5355
|
-
const renderPreview = (0,
|
|
5845
|
+
const renderPreview = (0, import_react34.useMemo)(
|
|
5356
5846
|
() => function Preview3() {
|
|
5847
|
+
var _a2;
|
|
5357
5848
|
if (item && "element" in item && item.element) {
|
|
5358
5849
|
return (
|
|
5359
5850
|
// Safe to use this since the HTML is set by the user
|
|
5360
|
-
/* @__PURE__ */ (0,
|
|
5851
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
5361
5852
|
);
|
|
5362
5853
|
}
|
|
5363
|
-
return /* @__PURE__ */ (0,
|
|
5854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name: label, children: (_a2 = overrides.componentItem) != null ? _a2 : overrides.drawerItem });
|
|
5364
5855
|
},
|
|
5365
5856
|
[componentId, label, overrides]
|
|
5366
5857
|
);
|
|
5367
|
-
const defaultsProps = (0,
|
|
5858
|
+
const defaultsProps = (0, import_react34.useMemo)(
|
|
5368
5859
|
() => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
|
|
5369
5860
|
puck: puckProps,
|
|
5370
5861
|
editMode: true
|
|
@@ -5372,7 +5863,7 @@ var DropZoneChild = ({
|
|
|
5372
5863
|
}),
|
|
5373
5864
|
[componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
|
|
5374
5865
|
);
|
|
5375
|
-
const defaultedNode = (0,
|
|
5866
|
+
const defaultedNode = (0, import_react34.useMemo)(
|
|
5376
5867
|
() => {
|
|
5377
5868
|
var _a2;
|
|
5378
5869
|
return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
|
|
@@ -5380,16 +5871,24 @@ var DropZoneChild = ({
|
|
|
5380
5871
|
[item == null ? void 0 : item.type, nodeType, defaultsProps]
|
|
5381
5872
|
);
|
|
5382
5873
|
const config = useAppStore((s) => s.config);
|
|
5383
|
-
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(
|
|
5384
5884
|
config,
|
|
5385
5885
|
defaultedNode,
|
|
5386
|
-
|
|
5387
|
-
(slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
|
5886
|
+
combinedFieldTransforms,
|
|
5388
5887
|
nodeReadOnly,
|
|
5389
5888
|
isLoading
|
|
5390
5889
|
);
|
|
5391
5890
|
if (!item) return;
|
|
5392
|
-
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: [
|
|
5393
5892
|
"No configuration for ",
|
|
5394
5893
|
item.type
|
|
5395
5894
|
] });
|
|
@@ -5398,7 +5897,7 @@ var DropZoneChild = ({
|
|
|
5398
5897
|
if (isInserting) {
|
|
5399
5898
|
Render2 = renderPreview;
|
|
5400
5899
|
}
|
|
5401
|
-
return /* @__PURE__ */ (0,
|
|
5900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5402
5901
|
DraggableComponent,
|
|
5403
5902
|
{
|
|
5404
5903
|
id: componentId,
|
|
@@ -5412,19 +5911,19 @@ var DropZoneChild = ({
|
|
|
5412
5911
|
autoDragAxis: dragAxis,
|
|
5413
5912
|
userDragAxis: collisionAxis,
|
|
5414
5913
|
inDroppableZone,
|
|
5415
|
-
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)(
|
|
5416
5915
|
Render2,
|
|
5417
|
-
__spreadProps(__spreadValues({},
|
|
5418
|
-
puck: __spreadProps(__spreadValues({},
|
|
5916
|
+
__spreadProps(__spreadValues({}, transformedProps), {
|
|
5917
|
+
puck: __spreadProps(__spreadValues({}, transformedProps.puck), {
|
|
5419
5918
|
dragRef
|
|
5420
5919
|
})
|
|
5421
5920
|
})
|
|
5422
|
-
) }) : /* @__PURE__ */ (0,
|
|
5921
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Render2, __spreadValues({}, transformedProps)) })
|
|
5423
5922
|
}
|
|
5424
5923
|
);
|
|
5425
5924
|
};
|
|
5426
|
-
var DropZoneChildMemo = (0,
|
|
5427
|
-
var DropZoneEdit = (0,
|
|
5925
|
+
var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
|
|
5926
|
+
var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5428
5927
|
function DropZoneEditInternal({
|
|
5429
5928
|
zone,
|
|
5430
5929
|
allow,
|
|
@@ -5434,7 +5933,7 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5434
5933
|
minEmptyHeight: userMinEmptyHeight = 128,
|
|
5435
5934
|
collisionAxis
|
|
5436
5935
|
}, userRef) {
|
|
5437
|
-
const ctx = (0,
|
|
5936
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5438
5937
|
const appStoreApi = useAppStoreApi();
|
|
5439
5938
|
const {
|
|
5440
5939
|
// These all need setting via context
|
|
@@ -5472,14 +5971,14 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5472
5971
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
5473
5972
|
})
|
|
5474
5973
|
);
|
|
5475
|
-
(0,
|
|
5974
|
+
(0, import_react34.useEffect)(() => {
|
|
5476
5975
|
if (!zoneType || zoneType === "dropzone") {
|
|
5477
5976
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5478
5977
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5479
5978
|
}
|
|
5480
5979
|
}
|
|
5481
5980
|
}, [zoneType, appStoreApi]);
|
|
5482
|
-
(0,
|
|
5981
|
+
(0, import_react34.useEffect)(() => {
|
|
5483
5982
|
if (zoneType === "dropzone") {
|
|
5484
5983
|
if (zoneCompound !== rootDroppableId) {
|
|
5485
5984
|
console.warn(
|
|
@@ -5488,11 +5987,11 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5488
5987
|
}
|
|
5489
5988
|
}
|
|
5490
5989
|
}, [zoneType]);
|
|
5491
|
-
const contentIds = (0,
|
|
5990
|
+
const contentIds = (0, import_react34.useMemo)(() => {
|
|
5492
5991
|
return zoneContentIds || [];
|
|
5493
5992
|
}, [zoneContentIds]);
|
|
5494
|
-
const ref = (0,
|
|
5495
|
-
const acceptsTarget = (0,
|
|
5993
|
+
const ref = (0, import_react34.useRef)(null);
|
|
5994
|
+
const acceptsTarget = (0, import_react34.useCallback)(
|
|
5496
5995
|
(componentType) => {
|
|
5497
5996
|
if (!componentType) {
|
|
5498
5997
|
return true;
|
|
@@ -5530,7 +6029,7 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5530
6029
|
}
|
|
5531
6030
|
return _isEnabled;
|
|
5532
6031
|
});
|
|
5533
|
-
(0,
|
|
6032
|
+
(0, import_react34.useEffect)(() => {
|
|
5534
6033
|
if (registerLocalZone) {
|
|
5535
6034
|
registerLocalZone(zoneCompound, targetAccepted || isEnabled);
|
|
5536
6035
|
}
|
|
@@ -5545,8 +6044,8 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5545
6044
|
zoneCompound
|
|
5546
6045
|
);
|
|
5547
6046
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
|
5548
|
-
const zoneStore = (0,
|
|
5549
|
-
(0,
|
|
6047
|
+
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
6048
|
+
(0, import_react34.useEffect)(() => {
|
|
5550
6049
|
const { enabledIndex } = zoneStore.getState();
|
|
5551
6050
|
zoneStore.setState({
|
|
5552
6051
|
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
|
@@ -5565,7 +6064,7 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5565
6064
|
path: path || []
|
|
5566
6065
|
}
|
|
5567
6066
|
};
|
|
5568
|
-
const { ref: dropRef } = (0,
|
|
6067
|
+
const { ref: dropRef } = (0, import_react35.useDroppable)(droppableConfig);
|
|
5569
6068
|
const isAreaSelected = useAppStore(
|
|
5570
6069
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
|
5571
6070
|
);
|
|
@@ -5575,10 +6074,10 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5575
6074
|
userMinEmptyHeight,
|
|
5576
6075
|
ref
|
|
5577
6076
|
});
|
|
5578
|
-
return /* @__PURE__ */ (0,
|
|
6077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5579
6078
|
"div",
|
|
5580
6079
|
{
|
|
5581
|
-
className: `${
|
|
6080
|
+
className: `${getClassName18({
|
|
5582
6081
|
isRootZone,
|
|
5583
6082
|
hoveringOverArea,
|
|
5584
6083
|
isEnabled,
|
|
@@ -5596,7 +6095,7 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5596
6095
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
|
5597
6096
|
}),
|
|
5598
6097
|
children: contentIdsWithPreview.map((componentId, i) => {
|
|
5599
|
-
return /* @__PURE__ */ (0,
|
|
6098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5600
6099
|
DropZoneChildMemo,
|
|
5601
6100
|
{
|
|
5602
6101
|
zoneCompound,
|
|
@@ -5619,15 +6118,15 @@ var DropZoneRenderItem = ({
|
|
|
5619
6118
|
metadata
|
|
5620
6119
|
}) => {
|
|
5621
6120
|
const Component = config.components[item.type];
|
|
5622
|
-
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0,
|
|
5623
|
-
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)(
|
|
5624
6123
|
() => ({
|
|
5625
6124
|
areaId: props.id,
|
|
5626
6125
|
depth: 1
|
|
5627
6126
|
}),
|
|
5628
6127
|
[props]
|
|
5629
6128
|
);
|
|
5630
|
-
return /* @__PURE__ */ (0,
|
|
6129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5631
6130
|
Component.render,
|
|
5632
6131
|
__spreadProps(__spreadValues({}, props), {
|
|
5633
6132
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
@@ -5637,15 +6136,15 @@ var DropZoneRenderItem = ({
|
|
|
5637
6136
|
})
|
|
5638
6137
|
) }, props.id);
|
|
5639
6138
|
};
|
|
5640
|
-
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0,
|
|
5641
|
-
var DropZoneRender2 = (0,
|
|
6139
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneRender2, __spreadValues({}, props));
|
|
6140
|
+
var DropZoneRender2 = (0, import_react34.forwardRef)(
|
|
5642
6141
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
5643
|
-
const ctx = (0,
|
|
6142
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5644
6143
|
const { areaId = "root" } = ctx || {};
|
|
5645
|
-
const { config, data, metadata } = (0,
|
|
6144
|
+
const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
|
|
5646
6145
|
let zoneCompound = `${areaId}:${zone}`;
|
|
5647
6146
|
let content = (data == null ? void 0 : data.content) || [];
|
|
5648
|
-
(0,
|
|
6147
|
+
(0, import_react34.useEffect)(() => {
|
|
5649
6148
|
if (!content) {
|
|
5650
6149
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5651
6150
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
@@ -5658,10 +6157,10 @@ var DropZoneRender2 = (0, import_react33.forwardRef)(
|
|
|
5658
6157
|
if (zoneCompound !== rootDroppableId) {
|
|
5659
6158
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
5660
6159
|
}
|
|
5661
|
-
return /* @__PURE__ */ (0,
|
|
6160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5662
6161
|
const Component = config.components[item.type];
|
|
5663
6162
|
if (Component) {
|
|
5664
|
-
return /* @__PURE__ */ (0,
|
|
6163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5665
6164
|
DropZoneRenderItem,
|
|
5666
6165
|
{
|
|
5667
6166
|
config,
|
|
@@ -5675,14 +6174,14 @@ var DropZoneRender2 = (0, import_react33.forwardRef)(
|
|
|
5675
6174
|
}) });
|
|
5676
6175
|
}
|
|
5677
6176
|
);
|
|
5678
|
-
var DropZonePure = (props) => /* @__PURE__ */ (0,
|
|
5679
|
-
var DropZone = (0,
|
|
6177
|
+
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZone, __spreadValues({}, props));
|
|
6178
|
+
var DropZone = (0, import_react34.forwardRef)(
|
|
5680
6179
|
function DropZone2(props, ref) {
|
|
5681
|
-
const ctx = (0,
|
|
6180
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5682
6181
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
5683
|
-
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 })) });
|
|
5684
6183
|
}
|
|
5685
|
-
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 })) });
|
|
5686
6185
|
}
|
|
5687
6186
|
);
|
|
5688
6187
|
|
|
@@ -6018,14 +6517,14 @@ function getDeepDir(el) {
|
|
|
6018
6517
|
|
|
6019
6518
|
// components/DragDropContext/index.tsx
|
|
6020
6519
|
var import_state = require("@dnd-kit/state");
|
|
6021
|
-
var
|
|
6520
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
6022
6521
|
var DEBUG3 = false;
|
|
6023
|
-
var dragListenerContext = (0,
|
|
6522
|
+
var dragListenerContext = (0, import_react37.createContext)({
|
|
6024
6523
|
dragListeners: {}
|
|
6025
6524
|
});
|
|
6026
6525
|
function useDragListener(type, fn, deps = []) {
|
|
6027
|
-
const { setDragListeners } = (0,
|
|
6028
|
-
(0,
|
|
6526
|
+
const { setDragListeners } = (0, import_react37.useContext)(dragListenerContext);
|
|
6527
|
+
(0, import_react37.useEffect)(() => {
|
|
6029
6528
|
if (setDragListeners) {
|
|
6030
6529
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
|
6031
6530
|
[type]: [...old[type] || [], fn]
|
|
@@ -6035,8 +6534,8 @@ function useDragListener(type, fn, deps = []) {
|
|
|
6035
6534
|
}
|
|
6036
6535
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
|
6037
6536
|
var useTempDisableFallback = (timeout3) => {
|
|
6038
|
-
const lastFallbackDisable = (0,
|
|
6039
|
-
return (0,
|
|
6537
|
+
const lastFallbackDisable = (0, import_react37.useRef)(null);
|
|
6538
|
+
return (0, import_react37.useCallback)((manager) => {
|
|
6040
6539
|
collisionStore.setState({ fallbackEnabled: false });
|
|
6041
6540
|
const fallbackId = generateId();
|
|
6042
6541
|
lastFallbackDisable.current = fallbackId;
|
|
@@ -6055,9 +6554,9 @@ var DragDropContextClient = ({
|
|
|
6055
6554
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
6056
6555
|
const appStore = useAppStoreApi();
|
|
6057
6556
|
const id = useSafeId();
|
|
6058
|
-
const debouncedParamsRef = (0,
|
|
6557
|
+
const debouncedParamsRef = (0, import_react37.useRef)(null);
|
|
6059
6558
|
const tempDisableFallback = useTempDisableFallback(100);
|
|
6060
|
-
const [zoneStore] = (0,
|
|
6559
|
+
const [zoneStore] = (0, import_react37.useState)(
|
|
6061
6560
|
() => (0, import_zustand5.createStore)(() => ({
|
|
6062
6561
|
zoneDepthIndex: {},
|
|
6063
6562
|
nextZoneDepthIndex: {},
|
|
@@ -6069,7 +6568,7 @@ var DragDropContextClient = ({
|
|
|
6069
6568
|
hoveringComponent: null
|
|
6070
6569
|
}))
|
|
6071
6570
|
);
|
|
6072
|
-
const getChanged2 = (0,
|
|
6571
|
+
const getChanged2 = (0, import_react37.useCallback)(
|
|
6073
6572
|
(params, id2) => {
|
|
6074
6573
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
6075
6574
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
@@ -6090,7 +6589,7 @@ var DragDropContextClient = ({
|
|
|
6090
6589
|
},
|
|
6091
6590
|
[zoneStore]
|
|
6092
6591
|
);
|
|
6093
|
-
const setDeepestAndCollide = (0,
|
|
6592
|
+
const setDeepestAndCollide = (0, import_react37.useCallback)(
|
|
6094
6593
|
(params, manager) => {
|
|
6095
6594
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
|
6096
6595
|
if (!zoneChanged && !areaChanged) return;
|
|
@@ -6114,7 +6613,7 @@ var DragDropContextClient = ({
|
|
|
6114
6613
|
setDeepestDb.cancel();
|
|
6115
6614
|
debouncedParamsRef.current = null;
|
|
6116
6615
|
};
|
|
6117
|
-
(0,
|
|
6616
|
+
(0, import_react37.useEffect)(() => {
|
|
6118
6617
|
if (DEBUG3) {
|
|
6119
6618
|
zoneStore.subscribe(
|
|
6120
6619
|
(s) => {
|
|
@@ -6128,7 +6627,7 @@ var DragDropContextClient = ({
|
|
|
6128
6627
|
);
|
|
6129
6628
|
}
|
|
6130
6629
|
}, []);
|
|
6131
|
-
const [plugins] = (0,
|
|
6630
|
+
const [plugins] = (0, import_react37.useState)(() => [
|
|
6132
6631
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
|
6133
6632
|
createNestedDroppablePlugin(
|
|
6134
6633
|
{
|
|
@@ -6176,10 +6675,10 @@ var DragDropContextClient = ({
|
|
|
6176
6675
|
)
|
|
6177
6676
|
]);
|
|
6178
6677
|
const sensors = useSensors();
|
|
6179
|
-
const [dragListeners, setDragListeners] = (0,
|
|
6180
|
-
const dragMode = (0,
|
|
6181
|
-
const initialSelector = (0,
|
|
6182
|
-
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)(
|
|
6183
6682
|
() => ({
|
|
6184
6683
|
mode: "edit",
|
|
6185
6684
|
areaId: "root",
|
|
@@ -6187,15 +6686,15 @@ var DragDropContextClient = ({
|
|
|
6187
6686
|
}),
|
|
6188
6687
|
[]
|
|
6189
6688
|
);
|
|
6190
|
-
return /* @__PURE__ */ (0,
|
|
6689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6191
6690
|
dragListenerContext.Provider,
|
|
6192
6691
|
{
|
|
6193
6692
|
value: {
|
|
6194
6693
|
dragListeners,
|
|
6195
6694
|
setDragListeners
|
|
6196
6695
|
},
|
|
6197
|
-
children: /* @__PURE__ */ (0,
|
|
6198
|
-
|
|
6696
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6697
|
+
import_react36.DragDropProvider,
|
|
6199
6698
|
{
|
|
6200
6699
|
plugins,
|
|
6201
6700
|
sensors,
|
|
@@ -6410,7 +6909,7 @@ var DragDropContextClient = ({
|
|
|
6410
6909
|
const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
|
|
6411
6910
|
entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
|
|
6412
6911
|
},
|
|
6413
|
-
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 }) })
|
|
6414
6913
|
}
|
|
6415
6914
|
)
|
|
6416
6915
|
}
|
|
@@ -6424,13 +6923,13 @@ var DragDropContext = ({
|
|
|
6424
6923
|
if (status === "LOADING") {
|
|
6425
6924
|
return children;
|
|
6426
6925
|
}
|
|
6427
|
-
return /* @__PURE__ */ (0,
|
|
6926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
|
6428
6927
|
};
|
|
6429
6928
|
|
|
6430
6929
|
// components/Drawer/index.tsx
|
|
6431
|
-
var
|
|
6432
|
-
var
|
|
6433
|
-
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);
|
|
6434
6933
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
|
6435
6934
|
var DrawerItemInner = ({
|
|
6436
6935
|
children,
|
|
@@ -6439,11 +6938,11 @@ var DrawerItemInner = ({
|
|
|
6439
6938
|
dragRef,
|
|
6440
6939
|
isDragDisabled
|
|
6441
6940
|
}) => {
|
|
6442
|
-
const CustomInner = (0,
|
|
6443
|
-
() => 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 })),
|
|
6444
6943
|
[children]
|
|
6445
6944
|
);
|
|
6446
|
-
return /* @__PURE__ */ (0,
|
|
6945
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6447
6946
|
"div",
|
|
6448
6947
|
{
|
|
6449
6948
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
|
@@ -6451,9 +6950,9 @@ var DrawerItemInner = ({
|
|
|
6451
6950
|
onMouseDown: (e) => e.preventDefault(),
|
|
6452
6951
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
|
6453
6952
|
"data-puck-drawer-item": true,
|
|
6454
|
-
children: /* @__PURE__ */ (0,
|
|
6455
|
-
/* @__PURE__ */ (0,
|
|
6456
|
-
/* @__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, {}) })
|
|
6457
6956
|
] }) }) })
|
|
6458
6957
|
}
|
|
6459
6958
|
);
|
|
@@ -6465,15 +6964,15 @@ var DrawerItemDraggable = ({
|
|
|
6465
6964
|
id,
|
|
6466
6965
|
isDragDisabled
|
|
6467
6966
|
}) => {
|
|
6468
|
-
const { ref } = (0,
|
|
6967
|
+
const { ref } = (0, import_react39.useDraggable)({
|
|
6469
6968
|
id,
|
|
6470
6969
|
data: { componentType: name },
|
|
6471
6970
|
disabled: isDragDisabled,
|
|
6472
6971
|
type: "drawer"
|
|
6473
6972
|
});
|
|
6474
|
-
return /* @__PURE__ */ (0,
|
|
6475
|
-
/* @__PURE__ */ (0,
|
|
6476
|
-
/* @__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)(
|
|
6477
6976
|
DrawerItemInner,
|
|
6478
6977
|
{
|
|
6479
6978
|
name,
|
|
@@ -6494,7 +6993,7 @@ var DrawerItem = ({
|
|
|
6494
6993
|
isDragDisabled
|
|
6495
6994
|
}) => {
|
|
6496
6995
|
const resolvedId = id || name;
|
|
6497
|
-
const [dynamicId, setDynamicId] = (0,
|
|
6996
|
+
const [dynamicId, setDynamicId] = (0, import_react38.useState)(generateId(resolvedId));
|
|
6498
6997
|
if (typeof index !== "undefined") {
|
|
6499
6998
|
console.error(
|
|
6500
6999
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
|
@@ -6507,7 +7006,7 @@ var DrawerItem = ({
|
|
|
6507
7006
|
},
|
|
6508
7007
|
[resolvedId]
|
|
6509
7008
|
);
|
|
6510
|
-
return /* @__PURE__ */ (0,
|
|
7009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6511
7010
|
DrawerItemDraggable,
|
|
6512
7011
|
{
|
|
6513
7012
|
name,
|
|
@@ -6534,16 +7033,16 @@ var Drawer = ({
|
|
|
6534
7033
|
);
|
|
6535
7034
|
}
|
|
6536
7035
|
const id = useSafeId();
|
|
6537
|
-
const { ref } = (0,
|
|
7036
|
+
const { ref } = (0, import_react39.useDroppable)({
|
|
6538
7037
|
id,
|
|
6539
7038
|
type: "void",
|
|
6540
7039
|
collisionPriority: 0
|
|
6541
7040
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
|
6542
7041
|
});
|
|
6543
|
-
return /* @__PURE__ */ (0,
|
|
7042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6544
7043
|
"div",
|
|
6545
7044
|
{
|
|
6546
|
-
className:
|
|
7045
|
+
className: getClassName19(),
|
|
6547
7046
|
ref,
|
|
6548
7047
|
"data-puck-dnd": id,
|
|
6549
7048
|
"data-puck-drawer": true,
|
|
@@ -6556,18 +7055,18 @@ Drawer.Item = DrawerItem;
|
|
|
6556
7055
|
|
|
6557
7056
|
// components/Puck/index.tsx
|
|
6558
7057
|
init_react_import();
|
|
6559
|
-
var
|
|
7058
|
+
var import_react59 = require("react");
|
|
6560
7059
|
|
|
6561
7060
|
// components/SidebarSection/index.tsx
|
|
6562
7061
|
init_react_import();
|
|
6563
7062
|
|
|
6564
7063
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
6565
7064
|
init_react_import();
|
|
6566
|
-
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" };
|
|
6567
7066
|
|
|
6568
7067
|
// lib/use-breadcrumbs.ts
|
|
6569
7068
|
init_react_import();
|
|
6570
|
-
var
|
|
7069
|
+
var import_react40 = require("react");
|
|
6571
7070
|
var useBreadcrumbs = (renderCount) => {
|
|
6572
7071
|
const selectedId = useAppStore((s) => {
|
|
6573
7072
|
var _a;
|
|
@@ -6579,7 +7078,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6579
7078
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
6580
7079
|
});
|
|
6581
7080
|
const appStore = useAppStoreApi();
|
|
6582
|
-
return (0,
|
|
7081
|
+
return (0, import_react40.useMemo)(() => {
|
|
6583
7082
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
6584
7083
|
var _a, _b, _c;
|
|
6585
7084
|
const [componentId] = zoneCompound.split(":");
|
|
@@ -6610,8 +7109,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6610
7109
|
};
|
|
6611
7110
|
|
|
6612
7111
|
// components/SidebarSection/index.tsx
|
|
6613
|
-
var
|
|
6614
|
-
var
|
|
7112
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
7113
|
+
var getClassName20 = get_class_name_factory_default("SidebarSection", styles_module_default14);
|
|
6615
7114
|
var SidebarSection = ({
|
|
6616
7115
|
children,
|
|
6617
7116
|
title,
|
|
@@ -6623,29 +7122,29 @@ var SidebarSection = ({
|
|
|
6623
7122
|
}) => {
|
|
6624
7123
|
const setUi = useAppStore((s) => s.setUi);
|
|
6625
7124
|
const breadcrumbs = useBreadcrumbs(1);
|
|
6626
|
-
return /* @__PURE__ */ (0,
|
|
7125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
6627
7126
|
"div",
|
|
6628
7127
|
{
|
|
6629
|
-
className:
|
|
7128
|
+
className: getClassName20({ noBorderTop, noPadding }),
|
|
6630
7129
|
style: { background },
|
|
6631
7130
|
children: [
|
|
6632
|
-
/* @__PURE__ */ (0,
|
|
6633
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
|
6634
|
-
/* @__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)(
|
|
6635
7134
|
"button",
|
|
6636
7135
|
{
|
|
6637
7136
|
type: "button",
|
|
6638
|
-
className:
|
|
7137
|
+
className: getClassName20("breadcrumbLabel"),
|
|
6639
7138
|
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
|
6640
7139
|
children: breadcrumb.label
|
|
6641
7140
|
}
|
|
6642
7141
|
),
|
|
6643
|
-
/* @__PURE__ */ (0,
|
|
7142
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronRight, { size: 16 })
|
|
6644
7143
|
] }, i)) : null,
|
|
6645
|
-
/* @__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 }) })
|
|
6646
7145
|
] }) }),
|
|
6647
|
-
/* @__PURE__ */ (0,
|
|
6648
|
-
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 }) })
|
|
6649
7148
|
]
|
|
6650
7149
|
}
|
|
6651
7150
|
);
|
|
@@ -6653,24 +7152,24 @@ var SidebarSection = ({
|
|
|
6653
7152
|
|
|
6654
7153
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
|
6655
7154
|
init_react_import();
|
|
6656
|
-
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" };
|
|
6657
7156
|
|
|
6658
7157
|
// components/Puck/components/Fields/index.tsx
|
|
6659
7158
|
init_react_import();
|
|
6660
7159
|
|
|
6661
7160
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
|
6662
7161
|
init_react_import();
|
|
6663
|
-
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" };
|
|
6664
7163
|
|
|
6665
7164
|
// components/Puck/components/Fields/index.tsx
|
|
6666
|
-
var
|
|
7165
|
+
var import_react41 = require("react");
|
|
6667
7166
|
var import_shallow5 = require("zustand/react/shallow");
|
|
6668
|
-
var
|
|
6669
|
-
var
|
|
7167
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
7168
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
|
6670
7169
|
var DefaultFields = ({
|
|
6671
7170
|
children
|
|
6672
7171
|
}) => {
|
|
6673
|
-
return /* @__PURE__ */ (0,
|
|
7172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
|
6674
7173
|
};
|
|
6675
7174
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
|
6676
7175
|
let currentProps;
|
|
@@ -6736,13 +7235,13 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6736
7235
|
})
|
|
6737
7236
|
);
|
|
6738
7237
|
const appStore = useAppStoreApi();
|
|
6739
|
-
const onChange = (0,
|
|
7238
|
+
const onChange = (0, import_react41.useCallback)(createOnChange(fieldName, appStore), [
|
|
6740
7239
|
fieldName
|
|
6741
7240
|
]);
|
|
6742
7241
|
const { visible = true } = field != null ? field : {};
|
|
6743
7242
|
if (!field || !id || !visible) return null;
|
|
6744
7243
|
if (field.type === "slot") return null;
|
|
6745
|
-
return /* @__PURE__ */ (0,
|
|
7244
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6746
7245
|
AutoFieldPrivate,
|
|
6747
7246
|
{
|
|
6748
7247
|
field,
|
|
@@ -6754,7 +7253,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6754
7253
|
}
|
|
6755
7254
|
) }, id);
|
|
6756
7255
|
};
|
|
6757
|
-
var FieldsChildMemo = (0,
|
|
7256
|
+
var FieldsChildMemo = (0, import_react41.memo)(FieldsChild);
|
|
6758
7257
|
var FieldsInternal = ({ wrapFields = true }) => {
|
|
6759
7258
|
const overrides = useAppStore((s) => s.overrides);
|
|
6760
7259
|
const componentResolving = useAppStore((s) => {
|
|
@@ -6779,51 +7278,60 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6779
7278
|
})
|
|
6780
7279
|
);
|
|
6781
7280
|
const isLoading = fieldsLoading || componentResolving;
|
|
6782
|
-
const Wrapper = (0,
|
|
6783
|
-
return /* @__PURE__ */ (0,
|
|
7281
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
7282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
6784
7283
|
"form",
|
|
6785
7284
|
{
|
|
6786
|
-
className:
|
|
7285
|
+
className: getClassName21({ wrapFields }),
|
|
6787
7286
|
onSubmit: (e) => {
|
|
6788
7287
|
e.preventDefault();
|
|
6789
7288
|
},
|
|
6790
7289
|
children: [
|
|
6791
|
-
/* @__PURE__ */ (0,
|
|
6792
|
-
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 }) }) })
|
|
6793
7292
|
]
|
|
6794
7293
|
}
|
|
6795
7294
|
);
|
|
6796
7295
|
};
|
|
6797
|
-
var Fields = (0,
|
|
7296
|
+
var Fields = (0, import_react41.memo)(FieldsInternal);
|
|
6798
7297
|
|
|
6799
7298
|
// components/Puck/components/Components/index.tsx
|
|
6800
7299
|
init_react_import();
|
|
6801
7300
|
|
|
6802
7301
|
// lib/use-component-list.tsx
|
|
6803
7302
|
init_react_import();
|
|
6804
|
-
var
|
|
7303
|
+
var import_react43 = require("react");
|
|
6805
7304
|
|
|
6806
7305
|
// components/ComponentList/index.tsx
|
|
6807
7306
|
init_react_import();
|
|
6808
7307
|
|
|
6809
7308
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
|
6810
7309
|
init_react_import();
|
|
6811
|
-
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" };
|
|
6812
7311
|
|
|
6813
7312
|
// components/ComponentList/index.tsx
|
|
6814
|
-
var
|
|
6815
|
-
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);
|
|
6816
7316
|
var ComponentListItem = ({
|
|
6817
7317
|
name,
|
|
6818
7318
|
label
|
|
6819
7319
|
}) => {
|
|
7320
|
+
var _a;
|
|
6820
7321
|
const overrides = useAppStore((s) => s.overrides);
|
|
6821
7322
|
const canInsert = useAppStore(
|
|
6822
7323
|
(s) => s.permissions.getPermissions({
|
|
6823
7324
|
type: name
|
|
6824
7325
|
}).insert
|
|
6825
7326
|
);
|
|
6826
|
-
|
|
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 });
|
|
6827
7335
|
};
|
|
6828
7336
|
var ComponentList = ({
|
|
6829
7337
|
children,
|
|
@@ -6834,12 +7342,12 @@ var ComponentList = ({
|
|
|
6834
7342
|
const setUi = useAppStore((s) => s.setUi);
|
|
6835
7343
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
|
6836
7344
|
const { expanded = true } = componentList[id] || {};
|
|
6837
|
-
return /* @__PURE__ */ (0,
|
|
6838
|
-
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)(
|
|
6839
7347
|
"button",
|
|
6840
7348
|
{
|
|
6841
7349
|
type: "button",
|
|
6842
|
-
className:
|
|
7350
|
+
className: getClassName22("title"),
|
|
6843
7351
|
onClick: () => setUi({
|
|
6844
7352
|
componentList: __spreadProps(__spreadValues({}, componentList), {
|
|
6845
7353
|
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
|
@@ -6849,14 +7357,14 @@ var ComponentList = ({
|
|
|
6849
7357
|
}),
|
|
6850
7358
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
|
6851
7359
|
children: [
|
|
6852
|
-
/* @__PURE__ */ (0,
|
|
6853
|
-
/* @__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 }) })
|
|
6854
7362
|
]
|
|
6855
7363
|
}
|
|
6856
7364
|
),
|
|
6857
|
-
/* @__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) => {
|
|
6858
7366
|
var _a;
|
|
6859
|
-
return /* @__PURE__ */ (0,
|
|
7367
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6860
7368
|
ComponentListItem,
|
|
6861
7369
|
{
|
|
6862
7370
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
|
@@ -6870,12 +7378,12 @@ var ComponentList = ({
|
|
|
6870
7378
|
ComponentList.Item = ComponentListItem;
|
|
6871
7379
|
|
|
6872
7380
|
// lib/use-component-list.tsx
|
|
6873
|
-
var
|
|
7381
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6874
7382
|
var useComponentList = () => {
|
|
6875
|
-
const [componentList, setComponentList] = (0,
|
|
7383
|
+
const [componentList, setComponentList] = (0, import_react43.useState)();
|
|
6876
7384
|
const config = useAppStore((s) => s.config);
|
|
6877
7385
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
|
6878
|
-
(0,
|
|
7386
|
+
(0, import_react43.useEffect)(() => {
|
|
6879
7387
|
var _a, _b, _c;
|
|
6880
7388
|
if (Object.keys(uiComponentList).length > 0) {
|
|
6881
7389
|
const matchedComponents = [];
|
|
@@ -6885,7 +7393,7 @@ var useComponentList = () => {
|
|
|
6885
7393
|
if (category.visible === false || !category.components) {
|
|
6886
7394
|
return null;
|
|
6887
7395
|
}
|
|
6888
|
-
return /* @__PURE__ */ (0,
|
|
7396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6889
7397
|
ComponentList,
|
|
6890
7398
|
{
|
|
6891
7399
|
id: categoryKey,
|
|
@@ -6894,7 +7402,7 @@ var useComponentList = () => {
|
|
|
6894
7402
|
var _a2;
|
|
6895
7403
|
matchedComponents.push(componentName);
|
|
6896
7404
|
const componentConf = config.components[componentName] || {};
|
|
6897
|
-
return /* @__PURE__ */ (0,
|
|
7405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6898
7406
|
ComponentList.Item,
|
|
6899
7407
|
{
|
|
6900
7408
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
|
@@ -6914,7 +7422,7 @@ var useComponentList = () => {
|
|
|
6914
7422
|
);
|
|
6915
7423
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
|
6916
7424
|
_componentList.push(
|
|
6917
|
-
/* @__PURE__ */ (0,
|
|
7425
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6918
7426
|
ComponentList,
|
|
6919
7427
|
{
|
|
6920
7428
|
id: "other",
|
|
@@ -6922,7 +7430,7 @@ var useComponentList = () => {
|
|
|
6922
7430
|
children: remainingComponents.map((componentName, i) => {
|
|
6923
7431
|
var _a2;
|
|
6924
7432
|
const componentConf = config.components[componentName] || {};
|
|
6925
|
-
return /* @__PURE__ */ (0,
|
|
7433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6926
7434
|
ComponentList.Item,
|
|
6927
7435
|
{
|
|
6928
7436
|
name: componentName,
|
|
@@ -6944,25 +7452,32 @@ var useComponentList = () => {
|
|
|
6944
7452
|
};
|
|
6945
7453
|
|
|
6946
7454
|
// components/Puck/components/Components/index.tsx
|
|
6947
|
-
var
|
|
6948
|
-
var
|
|
7455
|
+
var import_react44 = require("react");
|
|
7456
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
6949
7457
|
var Components = () => {
|
|
6950
7458
|
const overrides = useAppStore((s) => s.overrides);
|
|
6951
7459
|
const componentList = useComponentList();
|
|
6952
|
-
const Wrapper = (0,
|
|
6953
|
-
|
|
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" }) });
|
|
6954
7469
|
};
|
|
6955
7470
|
|
|
6956
7471
|
// components/Puck/components/Preview/index.tsx
|
|
6957
7472
|
init_react_import();
|
|
6958
|
-
var
|
|
7473
|
+
var import_react46 = require("react");
|
|
6959
7474
|
|
|
6960
7475
|
// components/AutoFrame/index.tsx
|
|
6961
7476
|
init_react_import();
|
|
6962
|
-
var
|
|
7477
|
+
var import_react45 = require("react");
|
|
6963
7478
|
var import_object_hash = __toESM(require("object-hash"));
|
|
6964
7479
|
var import_react_dom3 = require("react-dom");
|
|
6965
|
-
var
|
|
7480
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
6966
7481
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
|
6967
7482
|
var collectStyles = (doc) => {
|
|
6968
7483
|
const collected = [];
|
|
@@ -7012,7 +7527,7 @@ var CopyHostStyles = ({
|
|
|
7012
7527
|
onStylesLoaded = () => null
|
|
7013
7528
|
}) => {
|
|
7014
7529
|
const { document: doc, window: win } = useFrame();
|
|
7015
|
-
(0,
|
|
7530
|
+
(0, import_react45.useEffect)(() => {
|
|
7016
7531
|
if (!win || !doc) {
|
|
7017
7532
|
return () => {
|
|
7018
7533
|
};
|
|
@@ -7169,10 +7684,10 @@ var CopyHostStyles = ({
|
|
|
7169
7684
|
observer.disconnect();
|
|
7170
7685
|
};
|
|
7171
7686
|
}, []);
|
|
7172
|
-
return /* @__PURE__ */ (0,
|
|
7687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children });
|
|
7173
7688
|
};
|
|
7174
|
-
var autoFrameContext = (0,
|
|
7175
|
-
var useFrame = () => (0,
|
|
7689
|
+
var autoFrameContext = (0, import_react45.createContext)({});
|
|
7690
|
+
var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
|
|
7176
7691
|
function AutoFrame(_a) {
|
|
7177
7692
|
var _b = _a, {
|
|
7178
7693
|
children,
|
|
@@ -7193,11 +7708,11 @@ function AutoFrame(_a) {
|
|
|
7193
7708
|
"onNotReady",
|
|
7194
7709
|
"frameRef"
|
|
7195
7710
|
]);
|
|
7196
|
-
const [loaded, setLoaded] = (0,
|
|
7197
|
-
const [ctx, setCtx] = (0,
|
|
7198
|
-
const [mountTarget, setMountTarget] = (0,
|
|
7199
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
|
7200
|
-
(0,
|
|
7711
|
+
const [loaded, setLoaded] = (0, import_react45.useState)(false);
|
|
7712
|
+
const [ctx, setCtx] = (0, import_react45.useState)({});
|
|
7713
|
+
const [mountTarget, setMountTarget] = (0, import_react45.useState)();
|
|
7714
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react45.useState)(false);
|
|
7715
|
+
(0, import_react45.useEffect)(() => {
|
|
7201
7716
|
var _a2;
|
|
7202
7717
|
if (frameRef.current) {
|
|
7203
7718
|
const doc = frameRef.current.contentDocument;
|
|
@@ -7216,7 +7731,7 @@ function AutoFrame(_a) {
|
|
|
7216
7731
|
}
|
|
7217
7732
|
}
|
|
7218
7733
|
}, [frameRef, loaded, stylesLoaded]);
|
|
7219
|
-
return /* @__PURE__ */ (0,
|
|
7734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7220
7735
|
"iframe",
|
|
7221
7736
|
__spreadProps(__spreadValues({}, props), {
|
|
7222
7737
|
className,
|
|
@@ -7226,7 +7741,7 @@ function AutoFrame(_a) {
|
|
|
7226
7741
|
onLoad: () => {
|
|
7227
7742
|
setLoaded(true);
|
|
7228
7743
|
},
|
|
7229
|
-
children: /* @__PURE__ */ (0,
|
|
7744
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7230
7745
|
CopyHostStyles,
|
|
7231
7746
|
{
|
|
7232
7747
|
debug,
|
|
@@ -7242,14 +7757,14 @@ var AutoFrame_default = AutoFrame;
|
|
|
7242
7757
|
|
|
7243
7758
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
|
7244
7759
|
init_react_import();
|
|
7245
|
-
var
|
|
7760
|
+
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
|
7246
7761
|
|
|
7247
7762
|
// components/Puck/components/Preview/index.tsx
|
|
7248
|
-
var
|
|
7249
|
-
var
|
|
7763
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7764
|
+
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
|
7250
7765
|
var useBubbleIframeEvents = (ref) => {
|
|
7251
7766
|
const status = useAppStore((s) => s.status);
|
|
7252
|
-
(0,
|
|
7767
|
+
(0, import_react46.useEffect)(() => {
|
|
7253
7768
|
if (ref.current && status === "READY") {
|
|
7254
7769
|
const iframe = ref.current;
|
|
7255
7770
|
const handlePointerMove = (event) => {
|
|
@@ -7298,7 +7813,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7298
7813
|
const renderData = useAppStore(
|
|
7299
7814
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
7300
7815
|
);
|
|
7301
|
-
const Page = (0,
|
|
7816
|
+
const Page = (0, import_react46.useCallback)(
|
|
7302
7817
|
(pageProps) => {
|
|
7303
7818
|
var _a, _b;
|
|
7304
7819
|
const propsWithSlots = useSlots(
|
|
@@ -7308,15 +7823,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7308
7823
|
);
|
|
7309
7824
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
7310
7825
|
id: "puck-root"
|
|
7311
|
-
}, propsWithSlots)) : /* @__PURE__ */ (0,
|
|
7826
|
+
}, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children: propsWithSlots.children });
|
|
7312
7827
|
},
|
|
7313
7828
|
[config]
|
|
7314
7829
|
);
|
|
7315
|
-
const Frame = (0,
|
|
7830
|
+
const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
|
|
7316
7831
|
const rootProps = root.props || root;
|
|
7317
|
-
const ref = (0,
|
|
7832
|
+
const ref = (0, import_react46.useRef)(null);
|
|
7318
7833
|
useBubbleIframeEvents(ref);
|
|
7319
|
-
const inner = !renderData ? /* @__PURE__ */ (0,
|
|
7834
|
+
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7320
7835
|
Page,
|
|
7321
7836
|
__spreadProps(__spreadValues({}, rootProps), {
|
|
7322
7837
|
puck: {
|
|
@@ -7326,28 +7841,31 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7326
7841
|
metadata
|
|
7327
7842
|
},
|
|
7328
7843
|
editMode: true,
|
|
7329
|
-
children: /* @__PURE__ */ (0,
|
|
7844
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7330
7845
|
})
|
|
7331
|
-
) : /* @__PURE__ */ (0,
|
|
7332
|
-
(0,
|
|
7846
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Render, { data: renderData, config, metadata });
|
|
7847
|
+
(0, import_react46.useEffect)(() => {
|
|
7333
7848
|
if (!iframe.enabled) {
|
|
7334
7849
|
setStatus("READY");
|
|
7335
7850
|
}
|
|
7336
7851
|
}, [iframe.enabled]);
|
|
7337
|
-
return /* @__PURE__ */ (0,
|
|
7852
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7338
7853
|
"div",
|
|
7339
7854
|
{
|
|
7340
|
-
className:
|
|
7855
|
+
className: getClassName23(),
|
|
7341
7856
|
id,
|
|
7342
7857
|
"data-puck-preview": true,
|
|
7343
|
-
onClick: () => {
|
|
7344
|
-
|
|
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
|
+
}
|
|
7345
7863
|
},
|
|
7346
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
|
7864
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7347
7865
|
AutoFrame_default,
|
|
7348
7866
|
{
|
|
7349
7867
|
id: "preview-frame",
|
|
7350
|
-
className:
|
|
7868
|
+
className: getClassName23("frame"),
|
|
7351
7869
|
"data-rfd-iframe": true,
|
|
7352
7870
|
onReady: () => {
|
|
7353
7871
|
setStatus("READY");
|
|
@@ -7356,18 +7874,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7356
7874
|
setStatus("MOUNTED");
|
|
7357
7875
|
},
|
|
7358
7876
|
frameRef: ref,
|
|
7359
|
-
children: /* @__PURE__ */ (0,
|
|
7877
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
|
7360
7878
|
if (Frame) {
|
|
7361
|
-
return /* @__PURE__ */ (0,
|
|
7879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Frame, { document: document2, children: inner });
|
|
7362
7880
|
}
|
|
7363
7881
|
return inner;
|
|
7364
7882
|
} })
|
|
7365
7883
|
}
|
|
7366
|
-
) : /* @__PURE__ */ (0,
|
|
7884
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7367
7885
|
"div",
|
|
7368
7886
|
{
|
|
7369
7887
|
id: "preview-frame",
|
|
7370
|
-
className:
|
|
7888
|
+
className: getClassName23("frame"),
|
|
7371
7889
|
ref,
|
|
7372
7890
|
"data-puck-entry": true,
|
|
7373
7891
|
children: inner
|
|
@@ -7385,7 +7903,7 @@ init_react_import();
|
|
|
7385
7903
|
|
|
7386
7904
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
|
7387
7905
|
init_react_import();
|
|
7388
|
-
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" };
|
|
7389
7907
|
|
|
7390
7908
|
// lib/scroll-into-view.ts
|
|
7391
7909
|
init_react_import();
|
|
@@ -7399,7 +7917,7 @@ var scrollIntoView = (el) => {
|
|
|
7399
7917
|
};
|
|
7400
7918
|
|
|
7401
7919
|
// components/LayerTree/index.tsx
|
|
7402
|
-
var
|
|
7920
|
+
var import_react47 = require("react");
|
|
7403
7921
|
|
|
7404
7922
|
// lib/on-scroll-end.ts
|
|
7405
7923
|
init_react_import();
|
|
@@ -7422,9 +7940,9 @@ var onScrollEnd = (frame, cb) => {
|
|
|
7422
7940
|
|
|
7423
7941
|
// components/LayerTree/index.tsx
|
|
7424
7942
|
var import_shallow6 = require("zustand/react/shallow");
|
|
7425
|
-
var
|
|
7426
|
-
var
|
|
7427
|
-
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);
|
|
7428
7946
|
var Layer = ({
|
|
7429
7947
|
index,
|
|
7430
7948
|
itemId,
|
|
@@ -7434,7 +7952,7 @@ var Layer = ({
|
|
|
7434
7952
|
const config = useAppStore((s) => s.config);
|
|
7435
7953
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
7436
7954
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
7437
|
-
const setItemSelector = (0,
|
|
7955
|
+
const setItemSelector = (0, import_react47.useCallback)(
|
|
7438
7956
|
(itemSelector2) => {
|
|
7439
7957
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
7440
7958
|
},
|
|
@@ -7454,7 +7972,7 @@ var Layer = ({
|
|
|
7454
7972
|
)
|
|
7455
7973
|
);
|
|
7456
7974
|
const containsZone = zonesForItem.length > 0;
|
|
7457
|
-
const zoneStore = (0,
|
|
7975
|
+
const zoneStore = (0, import_react47.useContext)(ZoneStoreContext);
|
|
7458
7976
|
const isHovering = useContextStore(
|
|
7459
7977
|
ZoneStoreContext,
|
|
7460
7978
|
(s) => s.hoveringComponent === itemId
|
|
@@ -7469,7 +7987,7 @@ var Layer = ({
|
|
|
7469
7987
|
});
|
|
7470
7988
|
const componentConfig = config.components[nodeData.data.type];
|
|
7471
7989
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
|
7472
|
-
return /* @__PURE__ */ (0,
|
|
7990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
7473
7991
|
"li",
|
|
7474
7992
|
{
|
|
7475
7993
|
className: getClassNameLayer({
|
|
@@ -7479,7 +7997,7 @@ var Layer = ({
|
|
|
7479
7997
|
childIsSelected
|
|
7480
7998
|
}),
|
|
7481
7999
|
children: [
|
|
7482
|
-
/* @__PURE__ */ (0,
|
|
8000
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
7483
8001
|
"button",
|
|
7484
8002
|
{
|
|
7485
8003
|
type: "button",
|
|
@@ -7513,245 +8031,124 @@ var Layer = ({
|
|
|
7513
8031
|
zoneStore.setState({ hoveringComponent: itemId });
|
|
7514
8032
|
},
|
|
7515
8033
|
onMouseLeave: (e) => {
|
|
7516
|
-
e.stopPropagation();
|
|
7517
|
-
zoneStore.setState({ hoveringComponent: null });
|
|
7518
|
-
},
|
|
7519
|
-
children: [
|
|
7520
|
-
containsZone && /* @__PURE__ */ (0,
|
|
7521
|
-
"div",
|
|
7522
|
-
{
|
|
7523
|
-
className: getClassNameLayer("chevron"),
|
|
7524
|
-
title: isSelected ? "Collapse" : "Expand",
|
|
7525
|
-
children: /* @__PURE__ */ (0,
|
|
7526
|
-
}
|
|
7527
|
-
),
|
|
7528
|
-
/* @__PURE__ */ (0,
|
|
7529
|
-
/* @__PURE__ */ (0,
|
|
7530
|
-
/* @__PURE__ */ (0,
|
|
7531
|
-
] })
|
|
7532
|
-
]
|
|
7533
|
-
}
|
|
7534
|
-
) }),
|
|
7535
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0,
|
|
7536
|
-
]
|
|
7537
|
-
}
|
|
7538
|
-
);
|
|
7539
|
-
};
|
|
7540
|
-
var LayerTree = ({
|
|
7541
|
-
label: _label,
|
|
7542
|
-
zoneCompound
|
|
7543
|
-
}) => {
|
|
7544
|
-
const label = useAppStore((s) => {
|
|
7545
|
-
var _a, _b, _c, _d;
|
|
7546
|
-
if (_label) return _label;
|
|
7547
|
-
if (zoneCompound === rootDroppableId) return;
|
|
7548
|
-
const [componentId, slotId] = zoneCompound.split(":");
|
|
7549
|
-
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
7550
|
-
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
7551
|
-
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7552
|
-
});
|
|
7553
|
-
const contentIds = useAppStore(
|
|
7554
|
-
(0, import_shallow6.useShallow)(
|
|
7555
|
-
(s) => {
|
|
7556
|
-
var _a, _b;
|
|
7557
|
-
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
7558
|
-
}
|
|
7559
|
-
)
|
|
7560
|
-
);
|
|
7561
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
7562
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
|
|
7563
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
|
|
7564
|
-
label
|
|
7565
|
-
] }),
|
|
7566
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
|
|
7567
|
-
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
|
|
7568
|
-
contentIds.map((itemId, i) => {
|
|
7569
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7570
|
-
Layer,
|
|
7571
|
-
{
|
|
7572
|
-
index: i,
|
|
7573
|
-
itemId,
|
|
7574
|
-
zoneCompound
|
|
7575
|
-
},
|
|
7576
|
-
itemId
|
|
7577
|
-
);
|
|
7578
|
-
})
|
|
7579
|
-
] })
|
|
7580
|
-
] });
|
|
7581
|
-
};
|
|
7582
|
-
|
|
7583
|
-
// components/Puck/components/Outline/index.tsx
|
|
7584
|
-
var import_react46 = require("react");
|
|
7585
|
-
|
|
7586
|
-
// lib/data/find-zones-for-area.ts
|
|
7587
|
-
init_react_import();
|
|
7588
|
-
var findZonesForArea = (state, area) => {
|
|
7589
|
-
return Object.keys(state.indexes.zones).filter(
|
|
7590
|
-
(zone) => zone.split(":")[0] === area
|
|
7591
|
-
);
|
|
7592
|
-
};
|
|
7593
|
-
|
|
7594
|
-
// components/Puck/components/Outline/index.tsx
|
|
7595
|
-
var import_shallow7 = require("zustand/react/shallow");
|
|
7596
|
-
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7597
|
-
var Outline = () => {
|
|
7598
|
-
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
7599
|
-
const rootZones = useAppStore(
|
|
7600
|
-
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7601
|
-
);
|
|
7602
|
-
const Wrapper = (0, import_react46.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7603
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7604
|
-
LayerTree,
|
|
7605
|
-
{
|
|
7606
|
-
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
7607
|
-
zoneCompound
|
|
7608
|
-
},
|
|
7609
|
-
zoneCompound
|
|
7610
|
-
)) });
|
|
7611
|
-
};
|
|
7612
|
-
|
|
7613
|
-
// components/Puck/components/Canvas/index.tsx
|
|
7614
|
-
init_react_import();
|
|
7615
|
-
|
|
7616
|
-
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7617
|
-
init_react_import();
|
|
7618
|
-
|
|
7619
|
-
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
7620
|
-
init_react_import();
|
|
7621
|
-
var isProduction = process.env.NODE_ENV === "production";
|
|
7622
|
-
var prefix = "Invariant failed";
|
|
7623
|
-
function invariant(condition, message) {
|
|
7624
|
-
if (condition) {
|
|
7625
|
-
return;
|
|
7626
|
-
}
|
|
7627
|
-
if (isProduction) {
|
|
7628
|
-
throw new Error(prefix);
|
|
7629
|
-
}
|
|
7630
|
-
var provided = typeof message === "function" ? message() : message;
|
|
7631
|
-
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
7632
|
-
throw new Error(value);
|
|
7633
|
-
}
|
|
7634
|
-
|
|
7635
|
-
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7636
|
-
var getRect = function getRect2(_ref) {
|
|
7637
|
-
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
|
7638
|
-
var width = right - left;
|
|
7639
|
-
var height = bottom - top;
|
|
7640
|
-
var rect = {
|
|
7641
|
-
top,
|
|
7642
|
-
right,
|
|
7643
|
-
bottom,
|
|
7644
|
-
left,
|
|
7645
|
-
width,
|
|
7646
|
-
height,
|
|
7647
|
-
x: left,
|
|
7648
|
-
y: top,
|
|
7649
|
-
center: {
|
|
7650
|
-
x: (right + left) / 2,
|
|
7651
|
-
y: (bottom + top) / 2
|
|
7652
|
-
}
|
|
7653
|
-
};
|
|
7654
|
-
return rect;
|
|
7655
|
-
};
|
|
7656
|
-
var expand = function expand2(target, expandBy) {
|
|
7657
|
-
return {
|
|
7658
|
-
top: target.top - expandBy.top,
|
|
7659
|
-
left: target.left - expandBy.left,
|
|
7660
|
-
bottom: target.bottom + expandBy.bottom,
|
|
7661
|
-
right: target.right + expandBy.right
|
|
7662
|
-
};
|
|
7663
|
-
};
|
|
7664
|
-
var shrink = function shrink2(target, shrinkBy) {
|
|
7665
|
-
return {
|
|
7666
|
-
top: target.top + shrinkBy.top,
|
|
7667
|
-
left: target.left + shrinkBy.left,
|
|
7668
|
-
bottom: target.bottom - shrinkBy.bottom,
|
|
7669
|
-
right: target.right - shrinkBy.right
|
|
7670
|
-
};
|
|
7671
|
-
};
|
|
7672
|
-
var noSpacing = {
|
|
7673
|
-
top: 0,
|
|
7674
|
-
right: 0,
|
|
7675
|
-
bottom: 0,
|
|
7676
|
-
left: 0
|
|
7677
|
-
};
|
|
7678
|
-
var createBox = function createBox2(_ref2) {
|
|
7679
|
-
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;
|
|
7680
|
-
var marginBox = getRect(expand(borderBox, margin));
|
|
7681
|
-
var paddingBox = getRect(shrink(borderBox, border));
|
|
7682
|
-
var contentBox = getRect(shrink(paddingBox, padding));
|
|
7683
|
-
return {
|
|
7684
|
-
marginBox,
|
|
7685
|
-
borderBox: getRect(borderBox),
|
|
7686
|
-
paddingBox,
|
|
7687
|
-
contentBox,
|
|
7688
|
-
margin,
|
|
7689
|
-
border,
|
|
7690
|
-
padding
|
|
7691
|
-
};
|
|
7692
|
-
};
|
|
7693
|
-
var parse = function parse2(raw) {
|
|
7694
|
-
var value = raw.slice(0, -2);
|
|
7695
|
-
var suffix = raw.slice(-2);
|
|
7696
|
-
if (suffix !== "px") {
|
|
7697
|
-
return 0;
|
|
7698
|
-
}
|
|
7699
|
-
var result = Number(value);
|
|
7700
|
-
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
|
7701
|
-
return result;
|
|
7702
|
-
};
|
|
7703
|
-
var calculateBox = function calculateBox2(borderBox, styles2) {
|
|
7704
|
-
var margin = {
|
|
7705
|
-
top: parse(styles2.marginTop),
|
|
7706
|
-
right: parse(styles2.marginRight),
|
|
7707
|
-
bottom: parse(styles2.marginBottom),
|
|
7708
|
-
left: parse(styles2.marginLeft)
|
|
7709
|
-
};
|
|
7710
|
-
var padding = {
|
|
7711
|
-
top: parse(styles2.paddingTop),
|
|
7712
|
-
right: parse(styles2.paddingRight),
|
|
7713
|
-
bottom: parse(styles2.paddingBottom),
|
|
7714
|
-
left: parse(styles2.paddingLeft)
|
|
7715
|
-
};
|
|
7716
|
-
var border = {
|
|
7717
|
-
top: parse(styles2.borderTopWidth),
|
|
7718
|
-
right: parse(styles2.borderRightWidth),
|
|
7719
|
-
bottom: parse(styles2.borderBottomWidth),
|
|
7720
|
-
left: parse(styles2.borderLeftWidth)
|
|
7721
|
-
};
|
|
7722
|
-
return createBox({
|
|
7723
|
-
borderBox,
|
|
7724
|
-
margin,
|
|
7725
|
-
padding,
|
|
7726
|
-
border
|
|
8034
|
+
e.stopPropagation();
|
|
8035
|
+
zoneStore.setState({ hoveringComponent: null });
|
|
8036
|
+
},
|
|
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;
|
|
7727
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
|
+
] });
|
|
7728
8099
|
};
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
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
|
+
)) });
|
|
7733
8129
|
};
|
|
7734
8130
|
|
|
7735
8131
|
// components/Puck/components/Canvas/index.tsx
|
|
7736
|
-
|
|
8132
|
+
init_react_import();
|
|
8133
|
+
var import_react51 = require("react");
|
|
7737
8134
|
|
|
7738
8135
|
// components/ViewportControls/index.tsx
|
|
7739
8136
|
init_react_import();
|
|
7740
|
-
var
|
|
8137
|
+
var import_react49 = require("react");
|
|
7741
8138
|
|
|
7742
8139
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
7743
8140
|
init_react_import();
|
|
7744
|
-
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" };
|
|
7745
8142
|
|
|
7746
8143
|
// components/ViewportControls/index.tsx
|
|
7747
|
-
var
|
|
8144
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
7748
8145
|
var icons = {
|
|
7749
|
-
Smartphone: /* @__PURE__ */ (0,
|
|
7750
|
-
Tablet: /* @__PURE__ */ (0,
|
|
7751
|
-
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 })
|
|
7752
8149
|
};
|
|
7753
|
-
var
|
|
7754
|
-
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);
|
|
7755
8152
|
var ViewportButton = ({
|
|
7756
8153
|
children,
|
|
7757
8154
|
height = "auto",
|
|
@@ -7760,11 +8157,11 @@ var ViewportButton = ({
|
|
|
7760
8157
|
onClick
|
|
7761
8158
|
}) => {
|
|
7762
8159
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
|
7763
|
-
const [isActive, setIsActive] = (0,
|
|
7764
|
-
(0,
|
|
8160
|
+
const [isActive, setIsActive] = (0, import_react49.useState)(false);
|
|
8161
|
+
(0, import_react49.useEffect)(() => {
|
|
7765
8162
|
setIsActive(width === viewports.current.width);
|
|
7766
8163
|
}, [width, viewports.current.width]);
|
|
7767
|
-
return /* @__PURE__ */ (0,
|
|
8164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7768
8165
|
IconButton,
|
|
7769
8166
|
{
|
|
7770
8167
|
type: "button",
|
|
@@ -7774,7 +8171,7 @@ var ViewportButton = ({
|
|
|
7774
8171
|
e.stopPropagation();
|
|
7775
8172
|
onClick({ width, height });
|
|
7776
8173
|
},
|
|
7777
|
-
children: /* @__PURE__ */ (0,
|
|
8174
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: getClassNameButton("inner"), children })
|
|
7778
8175
|
}
|
|
7779
8176
|
) });
|
|
7780
8177
|
};
|
|
@@ -7798,7 +8195,7 @@ var ViewportControls = ({
|
|
|
7798
8195
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
7799
8196
|
(option) => option.value === autoZoom
|
|
7800
8197
|
);
|
|
7801
|
-
const zoomOptions = (0,
|
|
8198
|
+
const zoomOptions = (0, import_react49.useMemo)(
|
|
7802
8199
|
() => [
|
|
7803
8200
|
...defaultZoomOptions,
|
|
7804
8201
|
...defaultsContainAutoZoom ? [] : [
|
|
@@ -7810,8 +8207,8 @@ var ViewportControls = ({
|
|
|
7810
8207
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
|
7811
8208
|
[autoZoom]
|
|
7812
8209
|
);
|
|
7813
|
-
return /* @__PURE__ */ (0,
|
|
7814
|
-
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)(
|
|
7815
8212
|
ViewportButton,
|
|
7816
8213
|
{
|
|
7817
8214
|
height: viewport.height,
|
|
@@ -7822,8 +8219,8 @@ var ViewportControls = ({
|
|
|
7822
8219
|
},
|
|
7823
8220
|
i
|
|
7824
8221
|
)),
|
|
7825
|
-
/* @__PURE__ */ (0,
|
|
7826
|
-
/* @__PURE__ */ (0,
|
|
8222
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("divider") }),
|
|
8223
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7827
8224
|
IconButton,
|
|
7828
8225
|
{
|
|
7829
8226
|
type: "button",
|
|
@@ -7838,10 +8235,10 @@ var ViewportControls = ({
|
|
|
7838
8235
|
)].value
|
|
7839
8236
|
);
|
|
7840
8237
|
},
|
|
7841
|
-
children: /* @__PURE__ */ (0,
|
|
8238
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ZoomOut, { size: 16 })
|
|
7842
8239
|
}
|
|
7843
8240
|
),
|
|
7844
|
-
/* @__PURE__ */ (0,
|
|
8241
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7845
8242
|
IconButton,
|
|
7846
8243
|
{
|
|
7847
8244
|
type: "button",
|
|
@@ -7856,19 +8253,19 @@ var ViewportControls = ({
|
|
|
7856
8253
|
)].value
|
|
7857
8254
|
);
|
|
7858
8255
|
},
|
|
7859
|
-
children: /* @__PURE__ */ (0,
|
|
8256
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ZoomIn, { size: 16 })
|
|
7860
8257
|
}
|
|
7861
8258
|
),
|
|
7862
|
-
/* @__PURE__ */ (0,
|
|
7863
|
-
/* @__PURE__ */ (0,
|
|
8259
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("divider") }),
|
|
8260
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7864
8261
|
"select",
|
|
7865
8262
|
{
|
|
7866
|
-
className:
|
|
8263
|
+
className: getClassName25("zoomSelect"),
|
|
7867
8264
|
value: zoom.toString(),
|
|
7868
8265
|
onChange: (e) => {
|
|
7869
8266
|
onZoom(parseFloat(e.currentTarget.value));
|
|
7870
8267
|
},
|
|
7871
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
|
8268
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7872
8269
|
"option",
|
|
7873
8270
|
{
|
|
7874
8271
|
value: option.value,
|
|
@@ -7883,44 +8280,44 @@ var ViewportControls = ({
|
|
|
7883
8280
|
|
|
7884
8281
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
7885
8282
|
init_react_import();
|
|
7886
|
-
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" };
|
|
7887
8284
|
|
|
7888
|
-
//
|
|
8285
|
+
// components/Puck/components/Canvas/index.tsx
|
|
8286
|
+
var import_shallow8 = require("zustand/react/shallow");
|
|
8287
|
+
|
|
8288
|
+
// lib/frame-context.tsx
|
|
7889
8289
|
init_react_import();
|
|
7890
|
-
var
|
|
7891
|
-
var
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
|
7910
|
-
autoZoom = 1;
|
|
7911
|
-
zoom = 1;
|
|
7912
|
-
rootHeight = viewportHeight;
|
|
7913
|
-
}
|
|
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");
|
|
7914
8309
|
}
|
|
7915
|
-
return
|
|
8310
|
+
return context;
|
|
7916
8311
|
};
|
|
7917
8312
|
|
|
7918
8313
|
// components/Puck/components/Canvas/index.tsx
|
|
7919
|
-
var
|
|
7920
|
-
var
|
|
7921
|
-
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);
|
|
7922
8316
|
var ZOOM_ON_CHANGE = true;
|
|
8317
|
+
var TRANSITION_DURATION = 150;
|
|
7923
8318
|
var Canvas = () => {
|
|
8319
|
+
const { frameRef } = useCanvasFrame();
|
|
8320
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
7924
8321
|
const {
|
|
7925
8322
|
dispatch,
|
|
7926
8323
|
overrides,
|
|
@@ -7940,24 +8337,32 @@ var Canvas = () => {
|
|
|
7940
8337
|
iframe: s.iframe
|
|
7941
8338
|
}))
|
|
7942
8339
|
);
|
|
7943
|
-
const {
|
|
8340
|
+
const {
|
|
8341
|
+
leftSideBarVisible,
|
|
8342
|
+
rightSideBarVisible,
|
|
8343
|
+
leftSideBarWidth,
|
|
8344
|
+
rightSideBarWidth,
|
|
8345
|
+
viewports
|
|
8346
|
+
} = useAppStore(
|
|
7944
8347
|
(0, import_shallow8.useShallow)((s) => ({
|
|
7945
8348
|
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
7946
8349
|
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
8350
|
+
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
8351
|
+
rightSideBarWidth: s.state.ui.rightSideBarWidth,
|
|
7947
8352
|
viewports: s.state.ui.viewports
|
|
7948
8353
|
}))
|
|
7949
8354
|
);
|
|
7950
|
-
const
|
|
7951
|
-
const
|
|
7952
|
-
const defaultRender = (0,
|
|
7953
|
-
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 });
|
|
7954
8359
|
return PuckDefault;
|
|
7955
8360
|
}, []);
|
|
7956
|
-
const CustomPreview = (0,
|
|
8361
|
+
const CustomPreview = (0, import_react51.useMemo)(
|
|
7957
8362
|
() => overrides.preview || defaultRender,
|
|
7958
8363
|
[overrides]
|
|
7959
8364
|
);
|
|
7960
|
-
const getFrameDimensions = (0,
|
|
8365
|
+
const getFrameDimensions = (0, import_react51.useCallback)(() => {
|
|
7961
8366
|
if (frameRef.current) {
|
|
7962
8367
|
const frame = frameRef.current;
|
|
7963
8368
|
const box = getBox(frame);
|
|
@@ -7965,74 +8370,73 @@ var Canvas = () => {
|
|
|
7965
8370
|
}
|
|
7966
8371
|
return { width: 0, height: 0 };
|
|
7967
8372
|
}, [frameRef]);
|
|
7968
|
-
|
|
7969
|
-
(
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
},
|
|
7980
|
-
[frameRef, zoomConfig, viewports]
|
|
7981
|
-
);
|
|
7982
|
-
(0, import_react48.useEffect)(() => {
|
|
7983
|
-
setShowTransition(false);
|
|
7984
|
-
resetAutoZoom(viewports);
|
|
7985
|
-
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
|
7986
|
-
(0, import_react48.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)(() => {
|
|
7987
8384
|
const { height: frameHeight } = getFrameDimensions();
|
|
7988
8385
|
if (viewports.current.height === "auto") {
|
|
7989
8386
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
7990
8387
|
rootHeight: frameHeight / zoomConfig.zoom
|
|
7991
8388
|
}));
|
|
7992
8389
|
}
|
|
7993
|
-
}, [zoomConfig.zoom]);
|
|
7994
|
-
(0,
|
|
8390
|
+
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
8391
|
+
(0, import_react51.useEffect)(() => {
|
|
7995
8392
|
if (ZOOM_ON_CHANGE) {
|
|
7996
|
-
setShowTransition(true);
|
|
7997
|
-
resetAutoZoom(viewports);
|
|
7998
|
-
}
|
|
7999
|
-
}, [viewports.current.width]);
|
|
8000
|
-
(0, import_react48.useEffect)(() => {
|
|
8001
|
-
const cb = () => {
|
|
8002
|
-
setShowTransition(false);
|
|
8003
8393
|
resetAutoZoom();
|
|
8004
|
-
}
|
|
8005
|
-
|
|
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);
|
|
8006
8404
|
return () => {
|
|
8007
|
-
|
|
8405
|
+
resizeObserver.disconnect();
|
|
8008
8406
|
};
|
|
8009
|
-
}, []);
|
|
8010
|
-
const [showLoader, setShowLoader] = (0,
|
|
8011
|
-
(0,
|
|
8407
|
+
}, [frameRef.current]);
|
|
8408
|
+
const [showLoader, setShowLoader] = (0, import_react51.useState)(false);
|
|
8409
|
+
(0, import_react51.useEffect)(() => {
|
|
8012
8410
|
setTimeout(() => {
|
|
8013
8411
|
setShowLoader(true);
|
|
8014
8412
|
}, 500);
|
|
8015
8413
|
}, []);
|
|
8016
|
-
return /* @__PURE__ */ (0,
|
|
8414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
8017
8415
|
"div",
|
|
8018
8416
|
{
|
|
8019
|
-
className:
|
|
8417
|
+
className: getClassName26({
|
|
8020
8418
|
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
|
8021
8419
|
showLoader
|
|
8022
8420
|
}),
|
|
8023
|
-
onClick: () =>
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
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
|
+
},
|
|
8028
8431
|
children: [
|
|
8029
|
-
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)(
|
|
8030
8433
|
ViewportControls,
|
|
8031
8434
|
{
|
|
8032
8435
|
autoZoom: zoomConfig.autoZoom,
|
|
8033
8436
|
zoom: zoomConfig.zoom,
|
|
8034
8437
|
onViewportChange: (viewport) => {
|
|
8035
8438
|
setShowTransition(true);
|
|
8439
|
+
isResizingRef.current = true;
|
|
8036
8440
|
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
|
8037
8441
|
height: viewport.height || "auto",
|
|
8038
8442
|
zoom: zoomConfig.zoom
|
|
@@ -8043,41 +8447,40 @@ var Canvas = () => {
|
|
|
8043
8447
|
};
|
|
8044
8448
|
setUi(newUi);
|
|
8045
8449
|
if (ZOOM_ON_CHANGE) {
|
|
8046
|
-
resetAutoZoom(
|
|
8450
|
+
resetAutoZoom({
|
|
8451
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
8452
|
+
});
|
|
8047
8453
|
}
|
|
8048
8454
|
},
|
|
8049
8455
|
onZoom: (zoom) => {
|
|
8050
8456
|
setShowTransition(true);
|
|
8457
|
+
isResizingRef.current = true;
|
|
8051
8458
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
|
8052
8459
|
}
|
|
8053
8460
|
}
|
|
8054
8461
|
) }),
|
|
8055
|
-
/* @__PURE__ */ (0,
|
|
8056
|
-
/* @__PURE__ */ (0,
|
|
8462
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
|
8463
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8057
8464
|
"div",
|
|
8058
8465
|
{
|
|
8059
|
-
className:
|
|
8466
|
+
className: getClassName26("root"),
|
|
8060
8467
|
style: {
|
|
8061
8468
|
width: iframe.enabled ? viewports.current.width : "100%",
|
|
8062
8469
|
height: zoomConfig.rootHeight,
|
|
8063
8470
|
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
|
8064
|
-
transition: showTransition ?
|
|
8471
|
+
transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, height ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : "",
|
|
8065
8472
|
overflow: iframe.enabled ? void 0 : "auto"
|
|
8066
8473
|
},
|
|
8067
8474
|
suppressHydrationWarning: true,
|
|
8068
8475
|
id: "puck-canvas-root",
|
|
8069
8476
|
onTransitionEnd: () => {
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
bubbles: true,
|
|
8073
|
-
cancelable: false
|
|
8074
|
-
})
|
|
8075
|
-
);
|
|
8477
|
+
setShowTransition(false);
|
|
8478
|
+
isResizingRef.current = false;
|
|
8076
8479
|
},
|
|
8077
|
-
children: /* @__PURE__ */ (0,
|
|
8480
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Preview2, {}) })
|
|
8078
8481
|
}
|
|
8079
8482
|
),
|
|
8080
|
-
/* @__PURE__ */ (0,
|
|
8483
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Loader, { size: 24 }) })
|
|
8081
8484
|
] })
|
|
8082
8485
|
]
|
|
8083
8486
|
}
|
|
@@ -8086,7 +8489,7 @@ var Canvas = () => {
|
|
|
8086
8489
|
|
|
8087
8490
|
// lib/use-loaded-overrides.ts
|
|
8088
8491
|
init_react_import();
|
|
8089
|
-
var
|
|
8492
|
+
var import_react52 = require("react");
|
|
8090
8493
|
|
|
8091
8494
|
// lib/load-overrides.ts
|
|
8092
8495
|
init_react_import();
|
|
@@ -8096,8 +8499,11 @@ var loadOverrides = ({
|
|
|
8096
8499
|
}) => {
|
|
8097
8500
|
const collected = __spreadValues({}, overrides);
|
|
8098
8501
|
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
8502
|
+
if (!plugin.overrides) return;
|
|
8099
8503
|
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
|
8504
|
+
var _a;
|
|
8100
8505
|
const overridesType = _overridesType;
|
|
8506
|
+
if (!((_a = plugin.overrides) == null ? void 0 : _a[overridesType])) return;
|
|
8101
8507
|
if (overridesType === "fieldTypes") {
|
|
8102
8508
|
const fieldTypes = plugin.overrides.fieldTypes;
|
|
8103
8509
|
Object.keys(fieldTypes).forEach((fieldType) => {
|
|
@@ -8125,26 +8531,26 @@ var useLoadedOverrides = ({
|
|
|
8125
8531
|
overrides,
|
|
8126
8532
|
plugins
|
|
8127
8533
|
}) => {
|
|
8128
|
-
return (0,
|
|
8534
|
+
return (0, import_react52.useMemo)(() => {
|
|
8129
8535
|
return loadOverrides({ overrides, plugins });
|
|
8130
8536
|
}, [plugins, overrides]);
|
|
8131
8537
|
};
|
|
8132
8538
|
|
|
8133
8539
|
// components/DefaultOverride/index.tsx
|
|
8134
8540
|
init_react_import();
|
|
8135
|
-
var
|
|
8136
|
-
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 });
|
|
8137
8543
|
|
|
8138
8544
|
// lib/use-inject-css.ts
|
|
8139
8545
|
init_react_import();
|
|
8140
|
-
var
|
|
8546
|
+
var import_react53 = require("react");
|
|
8141
8547
|
var styles = ``;
|
|
8142
8548
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
8143
|
-
const [el, setEl] = (0,
|
|
8144
|
-
(0,
|
|
8549
|
+
const [el, setEl] = (0, import_react53.useState)();
|
|
8550
|
+
(0, import_react53.useEffect)(() => {
|
|
8145
8551
|
setEl(document.createElement("style"));
|
|
8146
8552
|
}, []);
|
|
8147
|
-
(0,
|
|
8553
|
+
(0, import_react53.useEffect)(() => {
|
|
8148
8554
|
var _a;
|
|
8149
8555
|
if (!el || typeof window === "undefined") {
|
|
8150
8556
|
return;
|
|
@@ -8164,10 +8570,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
8164
8570
|
|
|
8165
8571
|
// lib/use-preview-mode-hotkeys.ts
|
|
8166
8572
|
init_react_import();
|
|
8167
|
-
var
|
|
8573
|
+
var import_react54 = require("react");
|
|
8168
8574
|
var usePreviewModeHotkeys = () => {
|
|
8169
8575
|
const appStore = useAppStoreApi();
|
|
8170
|
-
const toggleInteractive = (0,
|
|
8576
|
+
const toggleInteractive = (0, import_react54.useCallback)(() => {
|
|
8171
8577
|
const dispatch = appStore.getState().dispatch;
|
|
8172
8578
|
dispatch({
|
|
8173
8579
|
type: "setUi",
|
|
@@ -8182,7 +8588,7 @@ var usePreviewModeHotkeys = () => {
|
|
|
8182
8588
|
|
|
8183
8589
|
// lib/use-puck.ts
|
|
8184
8590
|
init_react_import();
|
|
8185
|
-
var
|
|
8591
|
+
var import_react55 = require("react");
|
|
8186
8592
|
var import_zustand6 = require("zustand");
|
|
8187
8593
|
var generateUsePuck = (store) => {
|
|
8188
8594
|
const history = {
|
|
@@ -8215,7 +8621,7 @@ var generateUsePuck = (store) => {
|
|
|
8215
8621
|
};
|
|
8216
8622
|
return storeData;
|
|
8217
8623
|
};
|
|
8218
|
-
var UsePuckStoreContext = (0,
|
|
8624
|
+
var UsePuckStoreContext = (0, import_react55.createContext)(
|
|
8219
8625
|
null
|
|
8220
8626
|
);
|
|
8221
8627
|
var convertToPickedStore = (store) => {
|
|
@@ -8229,12 +8635,12 @@ var convertToPickedStore = (store) => {
|
|
|
8229
8635
|
};
|
|
8230
8636
|
};
|
|
8231
8637
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8232
|
-
const [usePuckStore] = (0,
|
|
8638
|
+
const [usePuckStore] = (0, import_react55.useState)(
|
|
8233
8639
|
() => (0, import_zustand6.createStore)(
|
|
8234
8640
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8235
8641
|
)
|
|
8236
8642
|
);
|
|
8237
|
-
(0,
|
|
8643
|
+
(0, import_react55.useEffect)(() => {
|
|
8238
8644
|
return appStore.subscribe(
|
|
8239
8645
|
(store) => convertToPickedStore(store),
|
|
8240
8646
|
(pickedStore) => {
|
|
@@ -8246,7 +8652,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8246
8652
|
};
|
|
8247
8653
|
function createUsePuck() {
|
|
8248
8654
|
return function usePuck2(selector) {
|
|
8249
|
-
const usePuckApi = (0,
|
|
8655
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8250
8656
|
if (!usePuckApi) {
|
|
8251
8657
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8252
8658
|
}
|
|
@@ -8258,7 +8664,7 @@ function createUsePuck() {
|
|
|
8258
8664
|
};
|
|
8259
8665
|
}
|
|
8260
8666
|
function usePuck() {
|
|
8261
|
-
(0,
|
|
8667
|
+
(0, import_react55.useEffect)(() => {
|
|
8262
8668
|
console.warn(
|
|
8263
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."
|
|
8264
8670
|
);
|
|
@@ -8266,7 +8672,7 @@ function usePuck() {
|
|
|
8266
8672
|
return createUsePuck()((s) => s);
|
|
8267
8673
|
}
|
|
8268
8674
|
function useGetPuck() {
|
|
8269
|
-
const usePuckApi = (0,
|
|
8675
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8270
8676
|
if (!usePuckApi) {
|
|
8271
8677
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8272
8678
|
}
|
|
@@ -8278,18 +8684,18 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8278
8684
|
|
|
8279
8685
|
// components/Puck/components/Header/index.tsx
|
|
8280
8686
|
init_react_import();
|
|
8281
|
-
var
|
|
8687
|
+
var import_react56 = require("react");
|
|
8282
8688
|
|
|
8283
8689
|
// components/MenuBar/index.tsx
|
|
8284
8690
|
init_react_import();
|
|
8285
8691
|
|
|
8286
8692
|
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
|
8287
8693
|
init_react_import();
|
|
8288
|
-
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" };
|
|
8289
8695
|
|
|
8290
8696
|
// components/MenuBar/index.tsx
|
|
8291
|
-
var
|
|
8292
|
-
var
|
|
8697
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
8698
|
+
var getClassName27 = get_class_name_factory_default("MenuBar", styles_module_default22);
|
|
8293
8699
|
function MenuBar({
|
|
8294
8700
|
menuOpen = false,
|
|
8295
8701
|
renderHeaderActions,
|
|
@@ -8299,10 +8705,10 @@ function MenuBar({
|
|
|
8299
8705
|
const forward = useAppStore((s) => s.history.forward);
|
|
8300
8706
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
8301
8707
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
8302
|
-
return /* @__PURE__ */ (0,
|
|
8708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8303
8709
|
"div",
|
|
8304
8710
|
{
|
|
8305
|
-
className:
|
|
8711
|
+
className: getClassName27({ menuOpen }),
|
|
8306
8712
|
onClick: (event) => {
|
|
8307
8713
|
var _a;
|
|
8308
8714
|
const element = event.target;
|
|
@@ -8313,30 +8719,30 @@ function MenuBar({
|
|
|
8313
8719
|
setMenuOpen(false);
|
|
8314
8720
|
}
|
|
8315
8721
|
},
|
|
8316
|
-
children: /* @__PURE__ */ (0,
|
|
8317
|
-
/* @__PURE__ */ (0,
|
|
8318
|
-
/* @__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)(
|
|
8319
8725
|
IconButton,
|
|
8320
8726
|
{
|
|
8321
8727
|
type: "button",
|
|
8322
8728
|
title: "undo",
|
|
8323
8729
|
disabled: !hasPast,
|
|
8324
8730
|
onClick: back,
|
|
8325
|
-
children: /* @__PURE__ */ (0,
|
|
8731
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Undo2, { size: 21 })
|
|
8326
8732
|
}
|
|
8327
8733
|
),
|
|
8328
|
-
/* @__PURE__ */ (0,
|
|
8734
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8329
8735
|
IconButton,
|
|
8330
8736
|
{
|
|
8331
8737
|
type: "button",
|
|
8332
8738
|
title: "redo",
|
|
8333
8739
|
disabled: !hasFuture,
|
|
8334
8740
|
onClick: forward,
|
|
8335
|
-
children: /* @__PURE__ */ (0,
|
|
8741
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Redo2, { size: 21 })
|
|
8336
8742
|
}
|
|
8337
8743
|
)
|
|
8338
8744
|
] }),
|
|
8339
|
-
/* @__PURE__ */ (0,
|
|
8745
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_jsx_runtime43.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
|
8340
8746
|
] })
|
|
8341
8747
|
}
|
|
8342
8748
|
);
|
|
@@ -8344,11 +8750,11 @@ function MenuBar({
|
|
|
8344
8750
|
|
|
8345
8751
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
|
8346
8752
|
init_react_import();
|
|
8347
|
-
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" };
|
|
8348
8754
|
|
|
8349
8755
|
// components/Puck/components/Header/index.tsx
|
|
8350
|
-
var
|
|
8351
|
-
var
|
|
8756
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8757
|
+
var getClassName28 = get_class_name_factory_default("PuckHeader", styles_module_default23);
|
|
8352
8758
|
var HeaderInner = () => {
|
|
8353
8759
|
const {
|
|
8354
8760
|
onPublish,
|
|
@@ -8360,7 +8766,7 @@ var HeaderInner = () => {
|
|
|
8360
8766
|
} = usePropsContext();
|
|
8361
8767
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8362
8768
|
const appStore = useAppStoreApi();
|
|
8363
|
-
const defaultHeaderRender = (0,
|
|
8769
|
+
const defaultHeaderRender = (0, import_react56.useMemo)(() => {
|
|
8364
8770
|
if (renderHeader) {
|
|
8365
8771
|
console.warn(
|
|
8366
8772
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8369,13 +8775,13 @@ var HeaderInner = () => {
|
|
|
8369
8775
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
8370
8776
|
const Comp = renderHeader;
|
|
8371
8777
|
const appState = useAppStore((s) => s.state);
|
|
8372
|
-
return /* @__PURE__ */ (0,
|
|
8778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
8373
8779
|
};
|
|
8374
8780
|
return RenderHeader;
|
|
8375
8781
|
}
|
|
8376
8782
|
return DefaultOverride;
|
|
8377
8783
|
}, [renderHeader]);
|
|
8378
|
-
const defaultHeaderActionsRender = (0,
|
|
8784
|
+
const defaultHeaderActionsRender = (0, import_react56.useMemo)(() => {
|
|
8379
8785
|
if (renderHeaderActions) {
|
|
8380
8786
|
console.warn(
|
|
8381
8787
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8383,7 +8789,7 @@ var HeaderInner = () => {
|
|
|
8383
8789
|
const RenderHeader = (props) => {
|
|
8384
8790
|
const Comp = renderHeaderActions;
|
|
8385
8791
|
const appState = useAppStore((s) => s.state);
|
|
8386
|
-
return /* @__PURE__ */ (0,
|
|
8792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
8387
8793
|
};
|
|
8388
8794
|
return RenderHeader;
|
|
8389
8795
|
}
|
|
@@ -8395,7 +8801,7 @@ var HeaderInner = () => {
|
|
|
8395
8801
|
const CustomHeaderActions = useAppStore(
|
|
8396
8802
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8397
8803
|
);
|
|
8398
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8804
|
+
const [menuOpen, setMenuOpen] = (0, import_react56.useState)(false);
|
|
8399
8805
|
const rootTitle = useAppStore((s) => {
|
|
8400
8806
|
var _a, _b;
|
|
8401
8807
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8405,7 +8811,7 @@ var HeaderInner = () => {
|
|
|
8405
8811
|
const rightSideBarVisible = useAppStore(
|
|
8406
8812
|
(s) => s.state.ui.rightSideBarVisible
|
|
8407
8813
|
);
|
|
8408
|
-
const toggleSidebars = (0,
|
|
8814
|
+
const toggleSidebars = (0, import_react56.useCallback)(
|
|
8409
8815
|
(sidebar) => {
|
|
8410
8816
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8411
8817
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8419,27 +8825,27 @@ var HeaderInner = () => {
|
|
|
8419
8825
|
},
|
|
8420
8826
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
8421
8827
|
);
|
|
8422
|
-
return /* @__PURE__ */ (0,
|
|
8828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8423
8829
|
CustomHeader,
|
|
8424
8830
|
{
|
|
8425
|
-
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)(
|
|
8426
8832
|
Button,
|
|
8427
8833
|
{
|
|
8428
8834
|
onClick: () => {
|
|
8429
8835
|
const data = appStore.getState().state.data;
|
|
8430
8836
|
onPublish && onPublish(data);
|
|
8431
8837
|
},
|
|
8432
|
-
icon: /* @__PURE__ */ (0,
|
|
8838
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Globe, { size: "14px" }),
|
|
8433
8839
|
children: "Publish"
|
|
8434
8840
|
}
|
|
8435
8841
|
) }) }),
|
|
8436
|
-
children: /* @__PURE__ */ (0,
|
|
8842
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8437
8843
|
"header",
|
|
8438
8844
|
{
|
|
8439
|
-
className:
|
|
8440
|
-
children: /* @__PURE__ */ (0,
|
|
8441
|
-
/* @__PURE__ */ (0,
|
|
8442
|
-
/* @__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)(
|
|
8443
8849
|
IconButton,
|
|
8444
8850
|
{
|
|
8445
8851
|
type: "button",
|
|
@@ -8447,10 +8853,10 @@ var HeaderInner = () => {
|
|
|
8447
8853
|
toggleSidebars("left");
|
|
8448
8854
|
},
|
|
8449
8855
|
title: "Toggle left sidebar",
|
|
8450
|
-
children: /* @__PURE__ */ (0,
|
|
8856
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PanelLeft, { focusable: "false" })
|
|
8451
8857
|
}
|
|
8452
8858
|
) }),
|
|
8453
|
-
/* @__PURE__ */ (0,
|
|
8859
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName28("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8454
8860
|
IconButton,
|
|
8455
8861
|
{
|
|
8456
8862
|
type: "button",
|
|
@@ -8458,19 +8864,19 @@ var HeaderInner = () => {
|
|
|
8458
8864
|
toggleSidebars("right");
|
|
8459
8865
|
},
|
|
8460
8866
|
title: "Toggle right sidebar",
|
|
8461
|
-
children: /* @__PURE__ */ (0,
|
|
8867
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PanelRight, { focusable: "false" })
|
|
8462
8868
|
}
|
|
8463
8869
|
) })
|
|
8464
8870
|
] }),
|
|
8465
|
-
/* @__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: [
|
|
8466
8872
|
headerTitle || rootTitle || "Page",
|
|
8467
|
-
headerPath && /* @__PURE__ */ (0,
|
|
8873
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
|
|
8468
8874
|
" ",
|
|
8469
|
-
/* @__PURE__ */ (0,
|
|
8875
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("code", { className: getClassName28("path"), children: headerPath })
|
|
8470
8876
|
] })
|
|
8471
8877
|
] }) }),
|
|
8472
|
-
/* @__PURE__ */ (0,
|
|
8473
|
-
/* @__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)(
|
|
8474
8880
|
IconButton,
|
|
8475
8881
|
{
|
|
8476
8882
|
type: "button",
|
|
@@ -8478,23 +8884,23 @@ var HeaderInner = () => {
|
|
|
8478
8884
|
return setMenuOpen(!menuOpen);
|
|
8479
8885
|
},
|
|
8480
8886
|
title: "Toggle menu bar",
|
|
8481
|
-
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" })
|
|
8482
8888
|
}
|
|
8483
8889
|
) }),
|
|
8484
|
-
/* @__PURE__ */ (0,
|
|
8890
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8485
8891
|
MenuBar,
|
|
8486
8892
|
{
|
|
8487
8893
|
dispatch,
|
|
8488
8894
|
onPublish,
|
|
8489
8895
|
menuOpen,
|
|
8490
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
|
8896
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8491
8897
|
Button,
|
|
8492
8898
|
{
|
|
8493
8899
|
onClick: () => {
|
|
8494
8900
|
const data = appStore.getState().state.data;
|
|
8495
8901
|
onPublish && onPublish(data);
|
|
8496
8902
|
},
|
|
8497
|
-
icon: /* @__PURE__ */ (0,
|
|
8903
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Globe, { size: "14px" }),
|
|
8498
8904
|
children: "Publish"
|
|
8499
8905
|
}
|
|
8500
8906
|
) }),
|
|
@@ -8508,12 +8914,205 @@ var HeaderInner = () => {
|
|
|
8508
8914
|
}
|
|
8509
8915
|
);
|
|
8510
8916
|
};
|
|
8511
|
-
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
|
+
}
|
|
8512
9111
|
|
|
8513
9112
|
// components/Puck/index.tsx
|
|
8514
|
-
var
|
|
8515
|
-
var
|
|
8516
|
-
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);
|
|
8517
9116
|
var FieldSideBar = () => {
|
|
8518
9117
|
const title = useAppStore(
|
|
8519
9118
|
(s) => {
|
|
@@ -8521,13 +9120,13 @@ var FieldSideBar = () => {
|
|
|
8521
9120
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
8522
9121
|
}
|
|
8523
9122
|
);
|
|
8524
|
-
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, {}) });
|
|
8525
9124
|
};
|
|
8526
|
-
var propsContext = (0,
|
|
9125
|
+
var propsContext = (0, import_react59.createContext)({});
|
|
8527
9126
|
function PropsProvider(props) {
|
|
8528
|
-
return /* @__PURE__ */ (0,
|
|
9127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
8529
9128
|
}
|
|
8530
|
-
var usePropsContext = () => (0,
|
|
9129
|
+
var usePropsContext = () => (0, import_react59.useContext)(propsContext);
|
|
8531
9130
|
function PuckProvider({ children }) {
|
|
8532
9131
|
const {
|
|
8533
9132
|
config,
|
|
@@ -8541,16 +9140,17 @@ function PuckProvider({ children }) {
|
|
|
8541
9140
|
iframe: _iframe,
|
|
8542
9141
|
initialHistory: _initialHistory,
|
|
8543
9142
|
metadata,
|
|
8544
|
-
onAction
|
|
9143
|
+
onAction,
|
|
9144
|
+
fieldTransforms
|
|
8545
9145
|
} = usePropsContext();
|
|
8546
|
-
const iframe = (0,
|
|
9146
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8547
9147
|
() => __spreadValues({
|
|
8548
9148
|
enabled: true,
|
|
8549
9149
|
waitForStyles: true
|
|
8550
9150
|
}, _iframe),
|
|
8551
9151
|
[_iframe]
|
|
8552
9152
|
);
|
|
8553
|
-
const [generatedAppState] = (0,
|
|
9153
|
+
const [generatedAppState] = (0, import_react59.useState)(() => {
|
|
8554
9154
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8555
9155
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8556
9156
|
let clientUiState = {};
|
|
@@ -8579,7 +9179,7 @@ function PuckProvider({ children }) {
|
|
|
8579
9179
|
}
|
|
8580
9180
|
}
|
|
8581
9181
|
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_g = initialData == null ? void 0 : initialData.root) == null ? void 0 : _g.props)) {
|
|
8582
|
-
console.
|
|
9182
|
+
console.warn(
|
|
8583
9183
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
|
8584
9184
|
);
|
|
8585
9185
|
}
|
|
@@ -8610,7 +9210,7 @@ function PuckProvider({ children }) {
|
|
|
8610
9210
|
return walkAppState(newAppState, config);
|
|
8611
9211
|
});
|
|
8612
9212
|
const { appendData = true } = _initialHistory || {};
|
|
8613
|
-
const [blendedHistories] = (0,
|
|
9213
|
+
const [blendedHistories] = (0, import_react59.useState)(
|
|
8614
9214
|
[
|
|
8615
9215
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8616
9216
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8630,7 +9230,15 @@ function PuckProvider({ children }) {
|
|
|
8630
9230
|
overrides,
|
|
8631
9231
|
plugins
|
|
8632
9232
|
});
|
|
8633
|
-
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)(
|
|
8634
9242
|
(state) => {
|
|
8635
9243
|
return {
|
|
8636
9244
|
state,
|
|
@@ -8640,7 +9248,8 @@ function PuckProvider({ children }) {
|
|
|
8640
9248
|
viewports,
|
|
8641
9249
|
iframe,
|
|
8642
9250
|
onAction,
|
|
8643
|
-
metadata
|
|
9251
|
+
metadata,
|
|
9252
|
+
fieldTransforms: loadedFieldTransforms
|
|
8644
9253
|
};
|
|
8645
9254
|
},
|
|
8646
9255
|
[
|
|
@@ -8651,18 +9260,19 @@ function PuckProvider({ children }) {
|
|
|
8651
9260
|
viewports,
|
|
8652
9261
|
iframe,
|
|
8653
9262
|
onAction,
|
|
8654
|
-
metadata
|
|
9263
|
+
metadata,
|
|
9264
|
+
loadedFieldTransforms
|
|
8655
9265
|
]
|
|
8656
9266
|
);
|
|
8657
|
-
const [appStore] = (0,
|
|
9267
|
+
const [appStore] = (0, import_react59.useState)(
|
|
8658
9268
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8659
9269
|
);
|
|
8660
|
-
(0,
|
|
9270
|
+
(0, import_react59.useEffect)(() => {
|
|
8661
9271
|
if (process.env.NODE_ENV !== "production") {
|
|
8662
9272
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8663
9273
|
}
|
|
8664
9274
|
}, [appStore]);
|
|
8665
|
-
(0,
|
|
9275
|
+
(0, import_react59.useEffect)(() => {
|
|
8666
9276
|
const state = appStore.getState().state;
|
|
8667
9277
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8668
9278
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8671,8 +9281,8 @@ function PuckProvider({ children }) {
|
|
|
8671
9281
|
index: initialHistoryIndex,
|
|
8672
9282
|
initialAppState
|
|
8673
9283
|
});
|
|
8674
|
-
const previousData = (0,
|
|
8675
|
-
(0,
|
|
9284
|
+
const previousData = (0, import_react59.useRef)(null);
|
|
9285
|
+
(0, import_react59.useEffect)(() => {
|
|
8676
9286
|
appStore.subscribe(
|
|
8677
9287
|
(s) => s.state.data,
|
|
8678
9288
|
(data) => {
|
|
@@ -8686,11 +9296,11 @@ function PuckProvider({ children }) {
|
|
|
8686
9296
|
}, []);
|
|
8687
9297
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8688
9298
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8689
|
-
(0,
|
|
9299
|
+
(0, import_react59.useEffect)(() => {
|
|
8690
9300
|
const { resolveAndCommitData } = appStore.getState();
|
|
8691
9301
|
resolveAndCommitData();
|
|
8692
9302
|
}, []);
|
|
8693
|
-
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 }) });
|
|
8694
9304
|
}
|
|
8695
9305
|
function PuckLayout({ children }) {
|
|
8696
9306
|
const {
|
|
@@ -8698,7 +9308,7 @@ function PuckLayout({ children }) {
|
|
|
8698
9308
|
dnd,
|
|
8699
9309
|
initialHistory: _initialHistory
|
|
8700
9310
|
} = usePropsContext();
|
|
8701
|
-
const iframe = (0,
|
|
9311
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8702
9312
|
() => __spreadValues({
|
|
8703
9313
|
enabled: true,
|
|
8704
9314
|
waitForStyles: true
|
|
@@ -8706,12 +9316,24 @@ function PuckLayout({ children }) {
|
|
|
8706
9316
|
[_iframe]
|
|
8707
9317
|
);
|
|
8708
9318
|
useInjectGlobalCss(iframe.enabled);
|
|
9319
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
8709
9320
|
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
8710
9321
|
const rightSideBarVisible = useAppStore(
|
|
8711
9322
|
(s) => s.state.ui.rightSideBarVisible
|
|
8712
9323
|
);
|
|
8713
|
-
const
|
|
8714
|
-
|
|
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)(() => {
|
|
8715
9337
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8716
9338
|
dispatch({
|
|
8717
9339
|
type: "setUi",
|
|
@@ -8735,17 +9357,17 @@ function PuckLayout({ children }) {
|
|
|
8735
9357
|
};
|
|
8736
9358
|
}, []);
|
|
8737
9359
|
const overrides = useAppStore((s) => s.overrides);
|
|
8738
|
-
const CustomPuck = (0,
|
|
9360
|
+
const CustomPuck = (0, import_react59.useMemo)(
|
|
8739
9361
|
() => overrides.puck || DefaultOverride,
|
|
8740
9362
|
[overrides]
|
|
8741
9363
|
);
|
|
8742
|
-
const [mounted, setMounted] = (0,
|
|
8743
|
-
(0,
|
|
9364
|
+
const [mounted, setMounted] = (0, import_react59.useState)(false);
|
|
9365
|
+
(0, import_react59.useEffect)(() => {
|
|
8744
9366
|
setMounted(true);
|
|
8745
9367
|
}, []);
|
|
8746
9368
|
const ready = useAppStore((s) => s.status === "READY");
|
|
8747
9369
|
useMonitorHotkeys();
|
|
8748
|
-
(0,
|
|
9370
|
+
(0, import_react59.useEffect)(() => {
|
|
8749
9371
|
if (ready && iframe.enabled) {
|
|
8750
9372
|
const frameDoc = getFrame();
|
|
8751
9373
|
if (frameDoc) {
|
|
@@ -8754,8 +9376,8 @@ function PuckLayout({ children }) {
|
|
|
8754
9376
|
}
|
|
8755
9377
|
}, [ready, iframe.enabled]);
|
|
8756
9378
|
usePreviewModeHotkeys();
|
|
8757
|
-
return /* @__PURE__ */ (0,
|
|
8758
|
-
/* @__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)(
|
|
8759
9381
|
"div",
|
|
8760
9382
|
{
|
|
8761
9383
|
className: getLayoutClassName({
|
|
@@ -8763,22 +9385,57 @@ function PuckLayout({ children }) {
|
|
|
8763
9385
|
mounted,
|
|
8764
9386
|
rightSideBarVisible
|
|
8765
9387
|
}),
|
|
8766
|
-
children: /* @__PURE__ */ (0,
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
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
|
+
)
|
|
8775
9432
|
}
|
|
8776
|
-
) }) }),
|
|
8777
|
-
/* @__PURE__ */ (0,
|
|
9433
|
+
) }) }) }),
|
|
9434
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { id: "puck-portal-root", className: getClassName31("portal") })
|
|
8778
9435
|
] });
|
|
8779
9436
|
}
|
|
8780
9437
|
function Puck(props) {
|
|
8781
|
-
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)) })) }));
|
|
8782
9439
|
}
|
|
8783
9440
|
Puck.Components = Components;
|
|
8784
9441
|
Puck.Fields = Fields;
|
|
@@ -8977,9 +9634,9 @@ function resolveAllData(_0, _1) {
|
|
|
8977
9634
|
},
|
|
8978
9635
|
"force"
|
|
8979
9636
|
)).node;
|
|
8980
|
-
const resolvedDeep = yield
|
|
9637
|
+
const resolvedDeep = yield mapFields(
|
|
8981
9638
|
resolved,
|
|
8982
|
-
processContent,
|
|
9639
|
+
{ slot: ({ value }) => processContent(value) },
|
|
8983
9640
|
config
|
|
8984
9641
|
);
|
|
8985
9642
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
@@ -9025,8 +9682,10 @@ function resolveAllData(_0, _1) {
|
|
|
9025
9682
|
createUsePuck,
|
|
9026
9683
|
migrate,
|
|
9027
9684
|
overrideKeys,
|
|
9685
|
+
registerOverlayPortal,
|
|
9028
9686
|
renderContext,
|
|
9029
9687
|
resolveAllData,
|
|
9688
|
+
setDeep,
|
|
9030
9689
|
transformProps,
|
|
9031
9690
|
useGetPuck,
|
|
9032
9691
|
usePuck,
|