@measured/puck 0.20.0-canary.274fe3d9 → 0.20.0-canary.29cd4d52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/dist/{chunk-4KAREQPB.mjs → chunk-DCZ7BU3G.mjs} +2908 -2275
- package/dist/{chunk-32MJ3X3H.mjs → chunk-NFK5JVZW.mjs} +199 -237
- package/dist/index.css +160 -77
- package/dist/index.d.mts +19 -7
- package/dist/index.d.ts +19 -7
- package/dist/index.js +1695 -1057
- package/dist/index.mjs +6 -2
- package/dist/no-external.css +160 -77
- package/dist/no-external.d.mts +2 -2
- package/dist/no-external.d.ts +2 -2
- package/dist/no-external.js +1695 -1057
- 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 -71
- package/dist/rsc.mjs +105 -2
- package/dist/{walk-tree-DrNRq2FV.d.mts → walk-tree-CiAkCQEp.d.mts} +180 -99
- package/dist/{walk-tree-DrNRq2FV.d.ts → walk-tree-CiAkCQEp.d.ts} +180 -99
- package/package.json +1 -1
package/dist/no-external.js
CHANGED
|
@@ -171,8 +171,10 @@ __export(no_external_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;
|
|
@@ -2153,14 +2087,14 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2153
2087
|
const { getComponentConfig, state } = appStore.getState();
|
|
2154
2088
|
const componentConfig = getComponentConfig(componentData == null ? void 0 : componentData.type);
|
|
2155
2089
|
if (!componentData || !componentConfig) return;
|
|
2156
|
-
const
|
|
2090
|
+
const defaultFields2 = componentConfig.fields || {};
|
|
2157
2091
|
const resolver = componentConfig.resolveFields;
|
|
2158
2092
|
let lastFields = fields;
|
|
2159
2093
|
if (reset) {
|
|
2160
2094
|
appStore.setState((s) => ({
|
|
2161
|
-
fields: __spreadProps(__spreadValues({}, s.fields), { fields:
|
|
2095
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields2, id })
|
|
2162
2096
|
}));
|
|
2163
|
-
lastFields =
|
|
2097
|
+
lastFields = defaultFields2;
|
|
2164
2098
|
}
|
|
2165
2099
|
if (resolver) {
|
|
2166
2100
|
const timeout3 = setTimeout(() => {
|
|
@@ -2172,7 +2106,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2172
2106
|
const changed = getChanged(componentData, lastData);
|
|
2173
2107
|
const newFields = yield resolver(componentData, {
|
|
2174
2108
|
changed,
|
|
2175
|
-
fields:
|
|
2109
|
+
fields: defaultFields2,
|
|
2176
2110
|
lastFields,
|
|
2177
2111
|
lastData,
|
|
2178
2112
|
appState: makeStatePublic(state),
|
|
@@ -2192,13 +2126,13 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2192
2126
|
});
|
|
2193
2127
|
} else {
|
|
2194
2128
|
appStore.setState((s) => ({
|
|
2195
|
-
fields: __spreadProps(__spreadValues({}, s.fields), { fields:
|
|
2129
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields2, id })
|
|
2196
2130
|
}));
|
|
2197
2131
|
}
|
|
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
|
)
|
|
@@ -4079,8 +4288,18 @@ var FieldLabelInternal = ({
|
|
|
4079
4288
|
}
|
|
4080
4289
|
);
|
|
4081
4290
|
};
|
|
4291
|
+
var defaultFields = {
|
|
4292
|
+
array: ArrayField,
|
|
4293
|
+
external: ExternalField,
|
|
4294
|
+
object: ObjectField,
|
|
4295
|
+
select: SelectField,
|
|
4296
|
+
textarea: TextareaField,
|
|
4297
|
+
radio: RadioField,
|
|
4298
|
+
text: DefaultField,
|
|
4299
|
+
number: DefaultField
|
|
4300
|
+
};
|
|
4082
4301
|
function AutoFieldInternal(props) {
|
|
4083
|
-
var _a
|
|
4302
|
+
var _a;
|
|
4084
4303
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4085
4304
|
const overrides = useAppStore((s) => s.overrides);
|
|
4086
4305
|
const readOnly = useAppStore((s) => {
|
|
@@ -4094,33 +4313,32 @@ function AutoFieldInternal(props) {
|
|
|
4094
4313
|
const labelIcon = field.labelIcon;
|
|
4095
4314
|
const defaultId = useSafeId();
|
|
4096
4315
|
const resolvedId = id || defaultId;
|
|
4097
|
-
const
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
});
|
|
4316
|
+
const render = (0, import_react20.useMemo)(
|
|
4317
|
+
() => {
|
|
4318
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
4319
|
+
return __spreadProps(__spreadValues({}, overrides.fieldTypes), {
|
|
4320
|
+
array: ((_a2 = overrides.fieldTypes) == null ? void 0 : _a2.array) || defaultFields.array,
|
|
4321
|
+
external: ((_b = overrides.fieldTypes) == null ? void 0 : _b.external) || defaultFields.external,
|
|
4322
|
+
object: ((_c = overrides.fieldTypes) == null ? void 0 : _c.object) || defaultFields.object,
|
|
4323
|
+
select: ((_d = overrides.fieldTypes) == null ? void 0 : _d.select) || defaultFields.select,
|
|
4324
|
+
textarea: ((_e = overrides.fieldTypes) == null ? void 0 : _e.textarea) || defaultFields.textarea,
|
|
4325
|
+
radio: ((_f = overrides.fieldTypes) == null ? void 0 : _f.radio) || defaultFields.radio,
|
|
4326
|
+
text: ((_g = overrides.fieldTypes) == null ? void 0 : _g.text) || defaultFields.text,
|
|
4327
|
+
number: ((_h = overrides.fieldTypes) == null ? void 0 : _h.number) || defaultFields.number
|
|
4328
|
+
});
|
|
4329
|
+
},
|
|
4330
|
+
[overrides]
|
|
4331
|
+
);
|
|
4332
|
+
const mergedProps = (0, import_react20.useMemo)(
|
|
4333
|
+
() => __spreadProps(__spreadValues({}, props), {
|
|
4334
|
+
field,
|
|
4335
|
+
label,
|
|
4336
|
+
labelIcon,
|
|
4337
|
+
Label: Label2,
|
|
4338
|
+
id: resolvedId
|
|
4339
|
+
}),
|
|
4340
|
+
[props, field, label, labelIcon, Label2, resolvedId]
|
|
4341
|
+
);
|
|
4124
4342
|
const onFocus = (0, import_react20.useCallback)(
|
|
4125
4343
|
(e) => {
|
|
4126
4344
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
@@ -4145,6 +4363,22 @@ function AutoFieldInternal(props) {
|
|
|
4145
4363
|
});
|
|
4146
4364
|
}
|
|
4147
4365
|
}, []);
|
|
4366
|
+
let Children = (0, import_react20.useMemo)(() => {
|
|
4367
|
+
if (field.type !== "custom" && field.type !== "slot") {
|
|
4368
|
+
return defaultFields[field.type];
|
|
4369
|
+
}
|
|
4370
|
+
return (_props) => null;
|
|
4371
|
+
}, [field.type]);
|
|
4372
|
+
let FieldComponent = (0, import_react20.useMemo)(() => {
|
|
4373
|
+
if (field.type === "custom") {
|
|
4374
|
+
if (!field.render) {
|
|
4375
|
+
return null;
|
|
4376
|
+
}
|
|
4377
|
+
return field.render;
|
|
4378
|
+
} else if (field.type !== "slot") {
|
|
4379
|
+
return render[field.type];
|
|
4380
|
+
}
|
|
4381
|
+
}, [field.type, render]);
|
|
4148
4382
|
const { visible = true } = props.field;
|
|
4149
4383
|
if (!visible) {
|
|
4150
4384
|
return null;
|
|
@@ -4152,23 +4386,15 @@ function AutoFieldInternal(props) {
|
|
|
4152
4386
|
if (field.type === "slot") {
|
|
4153
4387
|
return null;
|
|
4154
4388
|
}
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
if (field.type === "custom") {
|
|
4158
|
-
if (!field.render) {
|
|
4159
|
-
return null;
|
|
4160
|
-
}
|
|
4161
|
-
FieldComponent = field.render;
|
|
4162
|
-
} else {
|
|
4163
|
-
children = defaultFields[field.type](mergedProps);
|
|
4164
|
-
FieldComponent = render[field.type];
|
|
4389
|
+
if (!FieldComponent) {
|
|
4390
|
+
throw new Error(`Field type for ${field.type} did not exist.`);
|
|
4165
4391
|
}
|
|
4166
4392
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4167
4393
|
NestedFieldContext.Provider,
|
|
4168
4394
|
{
|
|
4169
4395
|
value: {
|
|
4170
4396
|
readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
|
|
4171
|
-
localName: (
|
|
4397
|
+
localName: (_a = nestedFieldContext.localName) != null ? _a : mergedProps.name
|
|
4172
4398
|
},
|
|
4173
4399
|
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4174
4400
|
"div",
|
|
@@ -4179,7 +4405,7 @@ function AutoFieldInternal(props) {
|
|
|
4179
4405
|
onClick: (e) => {
|
|
4180
4406
|
e.stopPropagation();
|
|
4181
4407
|
},
|
|
4182
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
|
4408
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Children, __spreadValues({}, mergedProps)) }))
|
|
4183
4409
|
}
|
|
4184
4410
|
)
|
|
4185
4411
|
}
|
|
@@ -4238,17 +4464,17 @@ init_react_import();
|
|
|
4238
4464
|
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
4465
|
|
|
4240
4466
|
// components/Drawer/index.tsx
|
|
4241
|
-
var
|
|
4467
|
+
var import_react38 = require("react");
|
|
4242
4468
|
|
|
4243
4469
|
// components/DragDropContext/index.tsx
|
|
4244
4470
|
init_react_import();
|
|
4245
|
-
var
|
|
4246
|
-
var
|
|
4471
|
+
var import_react36 = require("@dnd-kit/react");
|
|
4472
|
+
var import_react37 = require("react");
|
|
4247
4473
|
var import_dom = require("@dnd-kit/dom");
|
|
4248
4474
|
|
|
4249
4475
|
// components/DropZone/index.tsx
|
|
4250
4476
|
init_react_import();
|
|
4251
|
-
var
|
|
4477
|
+
var import_react34 = require("react");
|
|
4252
4478
|
|
|
4253
4479
|
// components/DraggableComponent/index.tsx
|
|
4254
4480
|
init_react_import();
|
|
@@ -4256,7 +4482,7 @@ var import_react24 = require("react");
|
|
|
4256
4482
|
|
|
4257
4483
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4258
4484
|
init_react_import();
|
|
4259
|
-
var styles_module_default11 = { "DraggableComponent": "
|
|
4485
|
+
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
4486
|
|
|
4261
4487
|
// components/DraggableComponent/index.tsx
|
|
4262
4488
|
var import_react_dom2 = require("react-dom");
|
|
@@ -4410,6 +4636,9 @@ var DefaultActionBar = ({
|
|
|
4410
4636
|
] }),
|
|
4411
4637
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
|
|
4412
4638
|
] });
|
|
4639
|
+
var DefaultOverlay = ({
|
|
4640
|
+
children
|
|
4641
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children });
|
|
4413
4642
|
var DraggableComponent = ({
|
|
4414
4643
|
children,
|
|
4415
4644
|
depth,
|
|
@@ -4603,9 +4832,16 @@ var DraggableComponent = ({
|
|
|
4603
4832
|
() => overrides.actionBar || DefaultActionBar,
|
|
4604
4833
|
[overrides.actionBar]
|
|
4605
4834
|
);
|
|
4835
|
+
const CustomOverlay = (0, import_react24.useMemo)(
|
|
4836
|
+
() => overrides.componentOverlay || DefaultOverlay,
|
|
4837
|
+
[overrides.componentOverlay]
|
|
4838
|
+
);
|
|
4606
4839
|
const onClick = (0, import_react24.useCallback)(
|
|
4607
4840
|
(e) => {
|
|
4608
|
-
e.
|
|
4841
|
+
const el = e.target;
|
|
4842
|
+
if (!el.closest("[data-puck-overlay-portal]")) {
|
|
4843
|
+
e.stopPropagation();
|
|
4844
|
+
}
|
|
4609
4845
|
dispatch({
|
|
4610
4846
|
type: "setUi",
|
|
4611
4847
|
ui: {
|
|
@@ -4845,7 +5081,16 @@ var DraggableComponent = ({
|
|
|
4845
5081
|
)
|
|
4846
5082
|
}
|
|
4847
5083
|
),
|
|
4848
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("
|
|
5084
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlayWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5085
|
+
CustomOverlay,
|
|
5086
|
+
{
|
|
5087
|
+
componentId: id,
|
|
5088
|
+
componentType,
|
|
5089
|
+
hover,
|
|
5090
|
+
isSelected,
|
|
5091
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
|
5092
|
+
}
|
|
5093
|
+
) })
|
|
4849
5094
|
]
|
|
4850
5095
|
}
|
|
4851
5096
|
),
|
|
@@ -4860,7 +5105,7 @@ init_react_import();
|
|
|
4860
5105
|
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
5106
|
|
|
4862
5107
|
// components/DropZone/index.tsx
|
|
4863
|
-
var
|
|
5108
|
+
var import_react35 = require("@dnd-kit/react");
|
|
4864
5109
|
|
|
4865
5110
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
4866
5111
|
init_react_import();
|
|
@@ -5068,35 +5313,70 @@ init_react_import();
|
|
|
5068
5313
|
|
|
5069
5314
|
// lib/use-slots.tsx
|
|
5070
5315
|
init_react_import();
|
|
5316
|
+
|
|
5317
|
+
// lib/field-transforms/use-field-transforms.tsx
|
|
5318
|
+
init_react_import();
|
|
5071
5319
|
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
|
-
|
|
5320
|
+
function useFieldTransforms(config, item, transforms, readOnly, forceReadOnly) {
|
|
5321
|
+
const mappers = (0, import_react30.useMemo)(() => {
|
|
5322
|
+
return Object.keys(transforms).reduce((acc, _fieldType) => {
|
|
5323
|
+
const fieldType = _fieldType;
|
|
5324
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
5325
|
+
[fieldType]: (_a) => {
|
|
5326
|
+
var _b = _a, {
|
|
5327
|
+
parentId
|
|
5328
|
+
} = _b, params = __objRest(_b, [
|
|
5329
|
+
"parentId"
|
|
5330
|
+
]);
|
|
5331
|
+
const wildcardPath = params.propPath.replace(/\[\d+\]/g, "[*]");
|
|
5332
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[params.propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly || false;
|
|
5333
|
+
const fn = transforms[fieldType];
|
|
5334
|
+
return fn == null ? void 0 : fn(__spreadProps(__spreadValues({}, params), {
|
|
5335
|
+
isReadOnly,
|
|
5336
|
+
componentId: parentId
|
|
5337
|
+
}));
|
|
5338
|
+
}
|
|
5339
|
+
});
|
|
5340
|
+
}, {});
|
|
5341
|
+
}, [transforms, readOnly, forceReadOnly]);
|
|
5342
|
+
const transformedProps = (0, import_react30.useMemo)(() => {
|
|
5343
|
+
const mapped = mapFields(item, mappers, config).props;
|
|
5091
5344
|
return mapped;
|
|
5092
|
-
}, [config, item,
|
|
5345
|
+
}, [config, item, mappers]);
|
|
5093
5346
|
const mergedProps = (0, import_react30.useMemo)(
|
|
5094
|
-
() => __spreadValues(__spreadValues({}, item.props),
|
|
5095
|
-
[item.props,
|
|
5347
|
+
() => __spreadValues(__spreadValues({}, item.props), transformedProps),
|
|
5348
|
+
[item.props, transformedProps]
|
|
5096
5349
|
);
|
|
5097
5350
|
return mergedProps;
|
|
5098
5351
|
}
|
|
5099
5352
|
|
|
5353
|
+
// lib/field-transforms/default-transforms/slot-transform.tsx
|
|
5354
|
+
init_react_import();
|
|
5355
|
+
var getSlotTransform = (renderSlotEdit, renderSlotRender = renderSlotEdit) => ({
|
|
5356
|
+
slot: ({ value: content, propName, field, isReadOnly }) => {
|
|
5357
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
|
5358
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
|
5359
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
|
5360
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
5361
|
+
}, dzProps), {
|
|
5362
|
+
zone: propName,
|
|
5363
|
+
content
|
|
5364
|
+
}));
|
|
5365
|
+
return Slot;
|
|
5366
|
+
}
|
|
5367
|
+
});
|
|
5368
|
+
|
|
5369
|
+
// lib/use-slots.tsx
|
|
5370
|
+
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
5371
|
+
return useFieldTransforms(
|
|
5372
|
+
config,
|
|
5373
|
+
item,
|
|
5374
|
+
getSlotTransform(renderSlotEdit, renderSlotRender),
|
|
5375
|
+
readOnly,
|
|
5376
|
+
forceReadOnly
|
|
5377
|
+
);
|
|
5378
|
+
}
|
|
5379
|
+
|
|
5100
5380
|
// components/Render/index.tsx
|
|
5101
5381
|
var import_react32 = __toESM(require("react"));
|
|
5102
5382
|
|
|
@@ -5107,69 +5387,19 @@ var import_shallow3 = require("zustand/react/shallow");
|
|
|
5107
5387
|
// components/SlotRender/server.tsx
|
|
5108
5388
|
init_react_import();
|
|
5109
5389
|
var import_react31 = require("react");
|
|
5110
|
-
|
|
5111
|
-
// components/ServerRender/index.tsx
|
|
5112
|
-
init_react_import();
|
|
5113
5390
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
5114
|
-
|
|
5115
|
-
zone,
|
|
5116
|
-
data,
|
|
5117
|
-
areaId = "root",
|
|
5118
|
-
config,
|
|
5119
|
-
metadata = {}
|
|
5120
|
-
}) {
|
|
5121
|
-
let zoneCompound = rootDroppableId;
|
|
5122
|
-
let content = (data == null ? void 0 : data.content) || [];
|
|
5123
|
-
if (!data || !config) {
|
|
5124
|
-
return null;
|
|
5125
|
-
}
|
|
5126
|
-
if (areaId !== rootAreaId && zone !== rootZone) {
|
|
5127
|
-
zoneCompound = `${areaId}:${zone}`;
|
|
5128
|
-
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
5129
|
-
}
|
|
5130
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content.map((item) => {
|
|
5131
|
-
const Component = config.components[item.type];
|
|
5132
|
-
const props = __spreadProps(__spreadValues({}, item.props), {
|
|
5133
|
-
puck: {
|
|
5134
|
-
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5135
|
-
DropZoneRender,
|
|
5136
|
-
{
|
|
5137
|
-
zone: zone2,
|
|
5138
|
-
data,
|
|
5139
|
-
areaId: item.props.id,
|
|
5140
|
-
config,
|
|
5141
|
-
metadata
|
|
5142
|
-
}
|
|
5143
|
-
),
|
|
5144
|
-
metadata,
|
|
5145
|
-
dragRef: null,
|
|
5146
|
-
isEditing: false
|
|
5147
|
-
}
|
|
5148
|
-
});
|
|
5149
|
-
const renderItem = __spreadProps(__spreadValues({}, item), { props });
|
|
5150
|
-
const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
|
5151
|
-
if (Component) {
|
|
5152
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
|
|
5153
|
-
}
|
|
5154
|
-
return null;
|
|
5155
|
-
}) });
|
|
5156
|
-
}
|
|
5157
|
-
|
|
5158
|
-
// components/SlotRender/server.tsx
|
|
5159
|
-
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
5160
|
-
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadValues({}, props));
|
|
5391
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRender, __spreadValues({}, props));
|
|
5161
5392
|
var Item = ({
|
|
5162
5393
|
config,
|
|
5163
5394
|
item,
|
|
5164
5395
|
metadata
|
|
5165
5396
|
}) => {
|
|
5166
5397
|
const Component = config.components[item.type];
|
|
5167
|
-
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0,
|
|
5168
|
-
return /* @__PURE__ */ (0,
|
|
5398
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5169
5400
|
Component.render,
|
|
5170
5401
|
__spreadProps(__spreadValues({}, props), {
|
|
5171
5402
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
5172
|
-
renderDropZone: DropZoneRender,
|
|
5173
5403
|
metadata: metadata || {}
|
|
5174
5404
|
})
|
|
5175
5405
|
})
|
|
@@ -5177,11 +5407,11 @@ var Item = ({
|
|
|
5177
5407
|
};
|
|
5178
5408
|
var SlotRender = (0, import_react31.forwardRef)(
|
|
5179
5409
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5180
|
-
return /* @__PURE__ */ (0,
|
|
5410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5181
5411
|
if (!config.components[item.type]) {
|
|
5182
5412
|
return null;
|
|
5183
5413
|
}
|
|
5184
|
-
return /* @__PURE__ */ (0,
|
|
5414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5185
5415
|
Item,
|
|
5186
5416
|
{
|
|
5187
5417
|
config,
|
|
@@ -5195,7 +5425,7 @@ var SlotRender = (0, import_react31.forwardRef)(
|
|
|
5195
5425
|
);
|
|
5196
5426
|
|
|
5197
5427
|
// components/SlotRender/index.tsx
|
|
5198
|
-
var
|
|
5428
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
5199
5429
|
var ContextSlotRender = ({
|
|
5200
5430
|
componentId,
|
|
5201
5431
|
zone
|
|
@@ -5210,7 +5440,7 @@ var ContextSlotRender = ({
|
|
|
5210
5440
|
return contentIds.map((contentId) => indexes.nodes[contentId].flatData);
|
|
5211
5441
|
})
|
|
5212
5442
|
);
|
|
5213
|
-
return /* @__PURE__ */ (0,
|
|
5443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
5214
5444
|
SlotRenderPure,
|
|
5215
5445
|
{
|
|
5216
5446
|
content: slotContent,
|
|
@@ -5222,7 +5452,7 @@ var ContextSlotRender = ({
|
|
|
5222
5452
|
};
|
|
5223
5453
|
|
|
5224
5454
|
// components/Render/index.tsx
|
|
5225
|
-
var
|
|
5455
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
5226
5456
|
var renderContext = import_react32.default.createContext({
|
|
5227
5457
|
config: { components: {} },
|
|
5228
5458
|
data: { root: {}, content: [] },
|
|
@@ -5254,7 +5484,7 @@ function Render({
|
|
|
5254
5484
|
const propsWithSlots = useSlots(
|
|
5255
5485
|
config,
|
|
5256
5486
|
{ type: "root", props: pageProps },
|
|
5257
|
-
(props) => /* @__PURE__ */ (0,
|
|
5487
|
+
(props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
|
5258
5488
|
);
|
|
5259
5489
|
const nextContextValue = (0, import_react32.useMemo)(
|
|
5260
5490
|
() => ({
|
|
@@ -5264,17 +5494,264 @@ function Render({
|
|
|
5264
5494
|
[]
|
|
5265
5495
|
);
|
|
5266
5496
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
|
5267
|
-
return /* @__PURE__ */ (0,
|
|
5497
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneRenderPure, { zone: rootZone }) })) }) });
|
|
5498
|
+
}
|
|
5499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneRenderPure, { zone: rootZone }) }) });
|
|
5500
|
+
}
|
|
5501
|
+
|
|
5502
|
+
// lib/field-transforms/default-transforms/inline-text-transform.tsx
|
|
5503
|
+
init_react_import();
|
|
5504
|
+
|
|
5505
|
+
// components/InlineTextField/index.tsx
|
|
5506
|
+
init_react_import();
|
|
5507
|
+
var import_react33 = require("react");
|
|
5508
|
+
|
|
5509
|
+
// lib/overlay-portal/index.tsx
|
|
5510
|
+
init_react_import();
|
|
5511
|
+
var registerOverlayPortal = (el, opts = {}) => {
|
|
5512
|
+
if (!el) return;
|
|
5513
|
+
const { disableDrag = false, disableDragOnFocus = true } = opts;
|
|
5514
|
+
const stopPropagation = (e) => {
|
|
5515
|
+
e.stopPropagation();
|
|
5516
|
+
};
|
|
5517
|
+
el.addEventListener("mouseover", stopPropagation, {
|
|
5518
|
+
capture: true
|
|
5519
|
+
});
|
|
5520
|
+
const onFocus = () => {
|
|
5521
|
+
setTimeout(() => {
|
|
5522
|
+
el.addEventListener("pointerdown", stopPropagation, {
|
|
5523
|
+
capture: true
|
|
5524
|
+
});
|
|
5525
|
+
}, 200);
|
|
5526
|
+
};
|
|
5527
|
+
const onBlur = () => {
|
|
5528
|
+
el.removeEventListener("pointerdown", stopPropagation, {
|
|
5529
|
+
capture: true
|
|
5530
|
+
});
|
|
5531
|
+
};
|
|
5532
|
+
if (disableDragOnFocus) {
|
|
5533
|
+
el.addEventListener("focus", onFocus, { capture: true });
|
|
5534
|
+
el.addEventListener("blur", onBlur, { capture: true });
|
|
5535
|
+
} else if (disableDrag) {
|
|
5536
|
+
el.addEventListener("pointerdown", stopPropagation, {
|
|
5537
|
+
capture: true
|
|
5538
|
+
});
|
|
5539
|
+
}
|
|
5540
|
+
el.setAttribute("data-puck-overlay-portal", "true");
|
|
5541
|
+
return () => {
|
|
5542
|
+
el.removeEventListener("mouseover", stopPropagation, {
|
|
5543
|
+
capture: true
|
|
5544
|
+
});
|
|
5545
|
+
if (disableDragOnFocus) {
|
|
5546
|
+
el.removeEventListener("focus", onFocus, { capture: true });
|
|
5547
|
+
el.removeEventListener("blur", onFocus, { capture: true });
|
|
5548
|
+
} else if (disableDrag) {
|
|
5549
|
+
el.removeEventListener("pointerdown", stopPropagation, {
|
|
5550
|
+
capture: true
|
|
5551
|
+
});
|
|
5552
|
+
}
|
|
5553
|
+
el.removeAttribute("data-puck-overlay-portal");
|
|
5554
|
+
};
|
|
5555
|
+
};
|
|
5556
|
+
|
|
5557
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css#css-module
|
|
5558
|
+
init_react_import();
|
|
5559
|
+
var styles_module_default13 = { "InlineTextField": "_InlineTextField_ilw2a_1" };
|
|
5560
|
+
|
|
5561
|
+
// lib/data/set-deep.ts
|
|
5562
|
+
init_react_import();
|
|
5563
|
+
function setDeep(node, path, newVal) {
|
|
5564
|
+
const parts = path.split(".");
|
|
5565
|
+
const newNode = __spreadValues({}, node);
|
|
5566
|
+
let cur = newNode;
|
|
5567
|
+
for (let i = 0; i < parts.length; i++) {
|
|
5568
|
+
const [prop, idxStr] = parts[i].replace("]", "").split("[");
|
|
5569
|
+
const isLast = i === parts.length - 1;
|
|
5570
|
+
if (idxStr !== void 0) {
|
|
5571
|
+
if (!Array.isArray(cur[prop])) {
|
|
5572
|
+
cur[prop] = [];
|
|
5573
|
+
}
|
|
5574
|
+
const idx = Number(idxStr);
|
|
5575
|
+
if (isLast) {
|
|
5576
|
+
cur[prop][idx] = newVal;
|
|
5577
|
+
continue;
|
|
5578
|
+
}
|
|
5579
|
+
if (cur[prop][idx] === void 0) cur[prop][idx] = {};
|
|
5580
|
+
cur = cur[prop][idx];
|
|
5581
|
+
continue;
|
|
5582
|
+
}
|
|
5583
|
+
if (isLast) {
|
|
5584
|
+
cur[prop] = newVal;
|
|
5585
|
+
continue;
|
|
5586
|
+
}
|
|
5587
|
+
if (cur[prop] === void 0) {
|
|
5588
|
+
cur[prop] = {};
|
|
5589
|
+
}
|
|
5590
|
+
cur = cur[prop];
|
|
5591
|
+
}
|
|
5592
|
+
return __spreadValues(__spreadValues({}, node), newNode);
|
|
5593
|
+
}
|
|
5594
|
+
|
|
5595
|
+
// lib/get-selector-for-id.ts
|
|
5596
|
+
init_react_import();
|
|
5597
|
+
var getSelectorForId = (state, id) => {
|
|
5598
|
+
const node = state.indexes.nodes[id];
|
|
5599
|
+
if (!node) return;
|
|
5600
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
5601
|
+
const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
|
5602
|
+
return { zone: zoneCompound, index };
|
|
5603
|
+
};
|
|
5604
|
+
|
|
5605
|
+
// components/InlineTextField/index.tsx
|
|
5606
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
5607
|
+
var getClassName17 = get_class_name_factory_default("InlineTextField", styles_module_default13);
|
|
5608
|
+
var InlineTextFieldInternal = ({
|
|
5609
|
+
propPath,
|
|
5610
|
+
componentId,
|
|
5611
|
+
value,
|
|
5612
|
+
isReadOnly,
|
|
5613
|
+
opts = {}
|
|
5614
|
+
}) => {
|
|
5615
|
+
var _a;
|
|
5616
|
+
const ref = (0, import_react33.useRef)(null);
|
|
5617
|
+
const appStoreApi = useAppStoreApi();
|
|
5618
|
+
const disableLineBreaks = (_a = opts.disableLineBreaks) != null ? _a : false;
|
|
5619
|
+
(0, import_react33.useEffect)(() => {
|
|
5620
|
+
const appStore = appStoreApi.getState();
|
|
5621
|
+
const data = appStore.state.indexes.nodes[componentId].data;
|
|
5622
|
+
const componentConfig = appStore.getComponentConfig(data.type);
|
|
5623
|
+
if (!componentConfig) {
|
|
5624
|
+
throw new Error(
|
|
5625
|
+
`InlineTextField Error: No config defined for ${data.type}`
|
|
5626
|
+
);
|
|
5627
|
+
}
|
|
5628
|
+
if (ref.current) {
|
|
5629
|
+
if (value !== ref.current.innerText) {
|
|
5630
|
+
ref.current.replaceChildren(value);
|
|
5631
|
+
}
|
|
5632
|
+
const cleanupPortal = registerOverlayPortal(ref.current);
|
|
5633
|
+
const handleInput = (e) => __async(void 0, null, function* () {
|
|
5634
|
+
var _a2;
|
|
5635
|
+
const appStore2 = appStoreApi.getState();
|
|
5636
|
+
const node = appStore2.state.indexes.nodes[componentId];
|
|
5637
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
5638
|
+
const index = (_a2 = appStore2.state.indexes.zones[zoneCompound]) == null ? void 0 : _a2.contentIds.indexOf(
|
|
5639
|
+
componentId
|
|
5640
|
+
);
|
|
5641
|
+
const newProps = setDeep(node.data.props, propPath, e.target.innerText);
|
|
5642
|
+
const resolvedData = yield appStore2.resolveComponentData(
|
|
5643
|
+
__spreadProps(__spreadValues({}, node.data), { props: newProps }),
|
|
5644
|
+
"replace"
|
|
5645
|
+
);
|
|
5646
|
+
appStore2.dispatch({
|
|
5647
|
+
type: "replace",
|
|
5648
|
+
data: resolvedData.node,
|
|
5649
|
+
destinationIndex: index,
|
|
5650
|
+
destinationZone: zoneCompound
|
|
5651
|
+
});
|
|
5652
|
+
});
|
|
5653
|
+
ref.current.addEventListener("input", handleInput);
|
|
5654
|
+
return () => {
|
|
5655
|
+
var _a2;
|
|
5656
|
+
(_a2 = ref.current) == null ? void 0 : _a2.removeEventListener("input", handleInput);
|
|
5657
|
+
cleanupPortal == null ? void 0 : cleanupPortal();
|
|
5658
|
+
};
|
|
5659
|
+
}
|
|
5660
|
+
}, [appStoreApi, ref.current, value]);
|
|
5661
|
+
const [isHovering, setIsHovering] = (0, import_react33.useState)(false);
|
|
5662
|
+
const [isFocused, setIsFocused] = (0, import_react33.useState)(false);
|
|
5663
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
5664
|
+
"span",
|
|
5665
|
+
{
|
|
5666
|
+
className: getClassName17(),
|
|
5667
|
+
ref,
|
|
5668
|
+
contentEditable: isHovering || isFocused ? "plaintext-only" : "false",
|
|
5669
|
+
onClick: (e) => {
|
|
5670
|
+
e.preventDefault();
|
|
5671
|
+
e.stopPropagation();
|
|
5672
|
+
},
|
|
5673
|
+
onClickCapture: (e) => {
|
|
5674
|
+
e.preventDefault();
|
|
5675
|
+
e.stopPropagation();
|
|
5676
|
+
const itemSelector = getSelectorForId(
|
|
5677
|
+
appStoreApi.getState().state,
|
|
5678
|
+
componentId
|
|
5679
|
+
);
|
|
5680
|
+
appStoreApi.getState().setUi({ itemSelector });
|
|
5681
|
+
},
|
|
5682
|
+
onKeyDown: (e) => {
|
|
5683
|
+
e.stopPropagation();
|
|
5684
|
+
if (disableLineBreaks && e.key === "Enter" || isReadOnly) {
|
|
5685
|
+
e.preventDefault();
|
|
5686
|
+
}
|
|
5687
|
+
},
|
|
5688
|
+
onKeyUp: (e) => {
|
|
5689
|
+
e.stopPropagation();
|
|
5690
|
+
e.preventDefault();
|
|
5691
|
+
},
|
|
5692
|
+
onMouseOverCapture: () => setIsHovering(true),
|
|
5693
|
+
onMouseOutCapture: () => setIsHovering(false),
|
|
5694
|
+
onFocus: () => setIsFocused(true),
|
|
5695
|
+
onBlur: () => setIsFocused(false)
|
|
5696
|
+
}
|
|
5697
|
+
);
|
|
5698
|
+
};
|
|
5699
|
+
var InlineTextField = (0, import_react33.memo)(InlineTextFieldInternal);
|
|
5700
|
+
|
|
5701
|
+
// lib/field-transforms/default-transforms/inline-text-transform.tsx
|
|
5702
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
5703
|
+
var getInlineTextTransform = () => ({
|
|
5704
|
+
text: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5705
|
+
if (field.contentEditable) {
|
|
5706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5707
|
+
InlineTextField,
|
|
5708
|
+
{
|
|
5709
|
+
propPath,
|
|
5710
|
+
componentId,
|
|
5711
|
+
value,
|
|
5712
|
+
opts: { disableLineBreaks: true },
|
|
5713
|
+
isReadOnly
|
|
5714
|
+
}
|
|
5715
|
+
);
|
|
5716
|
+
}
|
|
5717
|
+
return value;
|
|
5718
|
+
},
|
|
5719
|
+
textarea: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5720
|
+
if (field.contentEditable) {
|
|
5721
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5722
|
+
InlineTextField,
|
|
5723
|
+
{
|
|
5724
|
+
propPath,
|
|
5725
|
+
componentId,
|
|
5726
|
+
value,
|
|
5727
|
+
isReadOnly
|
|
5728
|
+
}
|
|
5729
|
+
);
|
|
5730
|
+
}
|
|
5731
|
+
return value;
|
|
5732
|
+
},
|
|
5733
|
+
custom: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5734
|
+
if (field.contentEditable && typeof value === "string") {
|
|
5735
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5736
|
+
InlineTextField,
|
|
5737
|
+
{
|
|
5738
|
+
propPath,
|
|
5739
|
+
componentId,
|
|
5740
|
+
value,
|
|
5741
|
+
isReadOnly
|
|
5742
|
+
}
|
|
5743
|
+
);
|
|
5744
|
+
}
|
|
5745
|
+
return value;
|
|
5268
5746
|
}
|
|
5269
|
-
|
|
5270
|
-
}
|
|
5747
|
+
});
|
|
5271
5748
|
|
|
5272
5749
|
// components/DropZone/index.tsx
|
|
5273
|
-
var
|
|
5274
|
-
var
|
|
5750
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
5751
|
+
var getClassName18 = get_class_name_factory_default("DropZone", styles_module_default12);
|
|
5275
5752
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
|
5276
5753
|
var RENDER_DEBUG = false;
|
|
5277
|
-
var DropZoneEditPure = (props) => /* @__PURE__ */ (0,
|
|
5754
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneEdit, __spreadValues({}, props));
|
|
5278
5755
|
var DropZoneChild = ({
|
|
5279
5756
|
zoneCompound,
|
|
5280
5757
|
componentId,
|
|
@@ -5285,9 +5762,9 @@ var DropZoneChild = ({
|
|
|
5285
5762
|
}) => {
|
|
5286
5763
|
var _a, _b;
|
|
5287
5764
|
const metadata = useAppStore((s) => s.metadata);
|
|
5288
|
-
const ctx = (0,
|
|
5765
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5289
5766
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
5290
|
-
const zoneStore = (0,
|
|
5767
|
+
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
5291
5768
|
const nodeProps = useAppStore(
|
|
5292
5769
|
(0, import_shallow4.useShallow)((s) => {
|
|
5293
5770
|
var _a2;
|
|
@@ -5307,7 +5784,7 @@ var DropZoneChild = ({
|
|
|
5307
5784
|
})
|
|
5308
5785
|
);
|
|
5309
5786
|
const appStore = useAppStoreApi();
|
|
5310
|
-
const item = (0,
|
|
5787
|
+
const item = (0, import_react34.useMemo)(() => {
|
|
5311
5788
|
if (nodeProps) {
|
|
5312
5789
|
const expanded = expandNode({
|
|
5313
5790
|
type: nodeType,
|
|
@@ -5329,7 +5806,7 @@ var DropZoneChild = ({
|
|
|
5329
5806
|
const componentConfig = useAppStore(
|
|
5330
5807
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
|
5331
5808
|
);
|
|
5332
|
-
const puckProps = (0,
|
|
5809
|
+
const puckProps = (0, import_react34.useMemo)(
|
|
5333
5810
|
() => ({
|
|
5334
5811
|
renderDropZone: DropZoneEditPure,
|
|
5335
5812
|
isEditing: true,
|
|
@@ -5352,19 +5829,20 @@ var DropZoneChild = ({
|
|
|
5352
5829
|
}
|
|
5353
5830
|
);
|
|
5354
5831
|
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,
|
|
5832
|
+
const renderPreview = (0, import_react34.useMemo)(
|
|
5356
5833
|
() => function Preview3() {
|
|
5834
|
+
var _a2;
|
|
5357
5835
|
if (item && "element" in item && item.element) {
|
|
5358
5836
|
return (
|
|
5359
5837
|
// Safe to use this since the HTML is set by the user
|
|
5360
|
-
/* @__PURE__ */ (0,
|
|
5838
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
5361
5839
|
);
|
|
5362
5840
|
}
|
|
5363
|
-
return /* @__PURE__ */ (0,
|
|
5841
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DrawerItemInner, { name: label, children: (_a2 = overrides.componentItem) != null ? _a2 : overrides.drawerItem });
|
|
5364
5842
|
},
|
|
5365
5843
|
[componentId, label, overrides]
|
|
5366
5844
|
);
|
|
5367
|
-
const defaultsProps = (0,
|
|
5845
|
+
const defaultsProps = (0, import_react34.useMemo)(
|
|
5368
5846
|
() => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
|
|
5369
5847
|
puck: puckProps,
|
|
5370
5848
|
editMode: true
|
|
@@ -5372,7 +5850,7 @@ var DropZoneChild = ({
|
|
|
5372
5850
|
}),
|
|
5373
5851
|
[componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
|
|
5374
5852
|
);
|
|
5375
|
-
const defaultedNode = (0,
|
|
5853
|
+
const defaultedNode = (0, import_react34.useMemo)(
|
|
5376
5854
|
() => {
|
|
5377
5855
|
var _a2;
|
|
5378
5856
|
return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
|
|
@@ -5380,16 +5858,24 @@ var DropZoneChild = ({
|
|
|
5380
5858
|
[item == null ? void 0 : item.type, nodeType, defaultsProps]
|
|
5381
5859
|
);
|
|
5382
5860
|
const config = useAppStore((s) => s.config);
|
|
5383
|
-
const
|
|
5861
|
+
const plugins = useAppStore((s) => s.plugins);
|
|
5862
|
+
const userFieldTransforms = useAppStore((s) => s.fieldTransforms);
|
|
5863
|
+
const combinedFieldTransforms = (0, import_react34.useMemo)(
|
|
5864
|
+
() => __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, getSlotTransform(DropZoneEditPure, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }))), getInlineTextTransform()), plugins.reduce(
|
|
5865
|
+
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
5866
|
+
{}
|
|
5867
|
+
)), userFieldTransforms),
|
|
5868
|
+
[plugins, userFieldTransforms]
|
|
5869
|
+
);
|
|
5870
|
+
const transformedProps = useFieldTransforms(
|
|
5384
5871
|
config,
|
|
5385
5872
|
defaultedNode,
|
|
5386
|
-
|
|
5387
|
-
(slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
|
5873
|
+
combinedFieldTransforms,
|
|
5388
5874
|
nodeReadOnly,
|
|
5389
5875
|
isLoading
|
|
5390
5876
|
);
|
|
5391
5877
|
if (!item) return;
|
|
5392
|
-
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0,
|
|
5878
|
+
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
|
5393
5879
|
"No configuration for ",
|
|
5394
5880
|
item.type
|
|
5395
5881
|
] });
|
|
@@ -5398,7 +5884,7 @@ var DropZoneChild = ({
|
|
|
5398
5884
|
if (isInserting) {
|
|
5399
5885
|
Render2 = renderPreview;
|
|
5400
5886
|
}
|
|
5401
|
-
return /* @__PURE__ */ (0,
|
|
5887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5402
5888
|
DraggableComponent,
|
|
5403
5889
|
{
|
|
5404
5890
|
id: componentId,
|
|
@@ -5412,19 +5898,19 @@ var DropZoneChild = ({
|
|
|
5412
5898
|
autoDragAxis: dragAxis,
|
|
5413
5899
|
userDragAxis: collisionAxis,
|
|
5414
5900
|
inDroppableZone,
|
|
5415
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0,
|
|
5901
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5416
5902
|
Render2,
|
|
5417
|
-
__spreadProps(__spreadValues({},
|
|
5418
|
-
puck: __spreadProps(__spreadValues({},
|
|
5903
|
+
__spreadProps(__spreadValues({}, transformedProps), {
|
|
5904
|
+
puck: __spreadProps(__spreadValues({}, transformedProps.puck), {
|
|
5419
5905
|
dragRef
|
|
5420
5906
|
})
|
|
5421
5907
|
})
|
|
5422
|
-
) }) : /* @__PURE__ */ (0,
|
|
5908
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Render2, __spreadValues({}, transformedProps)) })
|
|
5423
5909
|
}
|
|
5424
5910
|
);
|
|
5425
5911
|
};
|
|
5426
|
-
var DropZoneChildMemo = (0,
|
|
5427
|
-
var DropZoneEdit = (0,
|
|
5912
|
+
var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
|
|
5913
|
+
var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5428
5914
|
function DropZoneEditInternal({
|
|
5429
5915
|
zone,
|
|
5430
5916
|
allow,
|
|
@@ -5434,7 +5920,7 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5434
5920
|
minEmptyHeight: userMinEmptyHeight = 128,
|
|
5435
5921
|
collisionAxis
|
|
5436
5922
|
}, userRef) {
|
|
5437
|
-
const ctx = (0,
|
|
5923
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5438
5924
|
const appStoreApi = useAppStoreApi();
|
|
5439
5925
|
const {
|
|
5440
5926
|
// These all need setting via context
|
|
@@ -5472,14 +5958,14 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5472
5958
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
5473
5959
|
})
|
|
5474
5960
|
);
|
|
5475
|
-
(0,
|
|
5961
|
+
(0, import_react34.useEffect)(() => {
|
|
5476
5962
|
if (!zoneType || zoneType === "dropzone") {
|
|
5477
5963
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5478
5964
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5479
5965
|
}
|
|
5480
5966
|
}
|
|
5481
5967
|
}, [zoneType, appStoreApi]);
|
|
5482
|
-
(0,
|
|
5968
|
+
(0, import_react34.useEffect)(() => {
|
|
5483
5969
|
if (zoneType === "dropzone") {
|
|
5484
5970
|
if (zoneCompound !== rootDroppableId) {
|
|
5485
5971
|
console.warn(
|
|
@@ -5488,11 +5974,11 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5488
5974
|
}
|
|
5489
5975
|
}
|
|
5490
5976
|
}, [zoneType]);
|
|
5491
|
-
const contentIds = (0,
|
|
5977
|
+
const contentIds = (0, import_react34.useMemo)(() => {
|
|
5492
5978
|
return zoneContentIds || [];
|
|
5493
5979
|
}, [zoneContentIds]);
|
|
5494
|
-
const ref = (0,
|
|
5495
|
-
const acceptsTarget = (0,
|
|
5980
|
+
const ref = (0, import_react34.useRef)(null);
|
|
5981
|
+
const acceptsTarget = (0, import_react34.useCallback)(
|
|
5496
5982
|
(componentType) => {
|
|
5497
5983
|
if (!componentType) {
|
|
5498
5984
|
return true;
|
|
@@ -5530,7 +6016,7 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5530
6016
|
}
|
|
5531
6017
|
return _isEnabled;
|
|
5532
6018
|
});
|
|
5533
|
-
(0,
|
|
6019
|
+
(0, import_react34.useEffect)(() => {
|
|
5534
6020
|
if (registerLocalZone) {
|
|
5535
6021
|
registerLocalZone(zoneCompound, targetAccepted || isEnabled);
|
|
5536
6022
|
}
|
|
@@ -5545,8 +6031,8 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5545
6031
|
zoneCompound
|
|
5546
6032
|
);
|
|
5547
6033
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
|
5548
|
-
const zoneStore = (0,
|
|
5549
|
-
(0,
|
|
6034
|
+
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
6035
|
+
(0, import_react34.useEffect)(() => {
|
|
5550
6036
|
const { enabledIndex } = zoneStore.getState();
|
|
5551
6037
|
zoneStore.setState({
|
|
5552
6038
|
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
|
@@ -5565,7 +6051,7 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5565
6051
|
path: path || []
|
|
5566
6052
|
}
|
|
5567
6053
|
};
|
|
5568
|
-
const { ref: dropRef } = (0,
|
|
6054
|
+
const { ref: dropRef } = (0, import_react35.useDroppable)(droppableConfig);
|
|
5569
6055
|
const isAreaSelected = useAppStore(
|
|
5570
6056
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
|
5571
6057
|
);
|
|
@@ -5575,10 +6061,10 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5575
6061
|
userMinEmptyHeight,
|
|
5576
6062
|
ref
|
|
5577
6063
|
});
|
|
5578
|
-
return /* @__PURE__ */ (0,
|
|
6064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5579
6065
|
"div",
|
|
5580
6066
|
{
|
|
5581
|
-
className: `${
|
|
6067
|
+
className: `${getClassName18({
|
|
5582
6068
|
isRootZone,
|
|
5583
6069
|
hoveringOverArea,
|
|
5584
6070
|
isEnabled,
|
|
@@ -5596,7 +6082,7 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5596
6082
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
|
5597
6083
|
}),
|
|
5598
6084
|
children: contentIdsWithPreview.map((componentId, i) => {
|
|
5599
|
-
return /* @__PURE__ */ (0,
|
|
6085
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5600
6086
|
DropZoneChildMemo,
|
|
5601
6087
|
{
|
|
5602
6088
|
zoneCompound,
|
|
@@ -5619,15 +6105,15 @@ var DropZoneRenderItem = ({
|
|
|
5619
6105
|
metadata
|
|
5620
6106
|
}) => {
|
|
5621
6107
|
const Component = config.components[item.type];
|
|
5622
|
-
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0,
|
|
5623
|
-
const nextContextValue = (0,
|
|
6108
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
6109
|
+
const nextContextValue = (0, import_react34.useMemo)(
|
|
5624
6110
|
() => ({
|
|
5625
6111
|
areaId: props.id,
|
|
5626
6112
|
depth: 1
|
|
5627
6113
|
}),
|
|
5628
6114
|
[props]
|
|
5629
6115
|
);
|
|
5630
|
-
return /* @__PURE__ */ (0,
|
|
6116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5631
6117
|
Component.render,
|
|
5632
6118
|
__spreadProps(__spreadValues({}, props), {
|
|
5633
6119
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
@@ -5637,15 +6123,15 @@ var DropZoneRenderItem = ({
|
|
|
5637
6123
|
})
|
|
5638
6124
|
) }, props.id);
|
|
5639
6125
|
};
|
|
5640
|
-
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0,
|
|
5641
|
-
var
|
|
6126
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneRender, __spreadValues({}, props));
|
|
6127
|
+
var DropZoneRender = (0, import_react34.forwardRef)(
|
|
5642
6128
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
5643
|
-
const ctx = (0,
|
|
6129
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5644
6130
|
const { areaId = "root" } = ctx || {};
|
|
5645
|
-
const { config, data, metadata } = (0,
|
|
6131
|
+
const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
|
|
5646
6132
|
let zoneCompound = `${areaId}:${zone}`;
|
|
5647
6133
|
let content = (data == null ? void 0 : data.content) || [];
|
|
5648
|
-
(0,
|
|
6134
|
+
(0, import_react34.useEffect)(() => {
|
|
5649
6135
|
if (!content) {
|
|
5650
6136
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5651
6137
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
@@ -5658,10 +6144,10 @@ var DropZoneRender2 = (0, import_react33.forwardRef)(
|
|
|
5658
6144
|
if (zoneCompound !== rootDroppableId) {
|
|
5659
6145
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
5660
6146
|
}
|
|
5661
|
-
return /* @__PURE__ */ (0,
|
|
6147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5662
6148
|
const Component = config.components[item.type];
|
|
5663
6149
|
if (Component) {
|
|
5664
|
-
return /* @__PURE__ */ (0,
|
|
6150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5665
6151
|
DropZoneRenderItem,
|
|
5666
6152
|
{
|
|
5667
6153
|
config,
|
|
@@ -5675,14 +6161,14 @@ var DropZoneRender2 = (0, import_react33.forwardRef)(
|
|
|
5675
6161
|
}) });
|
|
5676
6162
|
}
|
|
5677
6163
|
);
|
|
5678
|
-
var DropZonePure = (props) => /* @__PURE__ */ (0,
|
|
5679
|
-
var DropZone = (0,
|
|
6164
|
+
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZone, __spreadValues({}, props));
|
|
6165
|
+
var DropZone = (0, import_react34.forwardRef)(
|
|
5680
6166
|
function DropZone2(props, ref) {
|
|
5681
|
-
const ctx = (0,
|
|
6167
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5682
6168
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
5683
|
-
return /* @__PURE__ */ (0,
|
|
6169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
5684
6170
|
}
|
|
5685
|
-
return /* @__PURE__ */ (0,
|
|
6171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
5686
6172
|
}
|
|
5687
6173
|
);
|
|
5688
6174
|
|
|
@@ -6018,14 +6504,14 @@ function getDeepDir(el) {
|
|
|
6018
6504
|
|
|
6019
6505
|
// components/DragDropContext/index.tsx
|
|
6020
6506
|
var import_state = require("@dnd-kit/state");
|
|
6021
|
-
var
|
|
6507
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
6022
6508
|
var DEBUG3 = false;
|
|
6023
|
-
var dragListenerContext = (0,
|
|
6509
|
+
var dragListenerContext = (0, import_react37.createContext)({
|
|
6024
6510
|
dragListeners: {}
|
|
6025
6511
|
});
|
|
6026
6512
|
function useDragListener(type, fn, deps = []) {
|
|
6027
|
-
const { setDragListeners } = (0,
|
|
6028
|
-
(0,
|
|
6513
|
+
const { setDragListeners } = (0, import_react37.useContext)(dragListenerContext);
|
|
6514
|
+
(0, import_react37.useEffect)(() => {
|
|
6029
6515
|
if (setDragListeners) {
|
|
6030
6516
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
|
6031
6517
|
[type]: [...old[type] || [], fn]
|
|
@@ -6035,8 +6521,8 @@ function useDragListener(type, fn, deps = []) {
|
|
|
6035
6521
|
}
|
|
6036
6522
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
|
6037
6523
|
var useTempDisableFallback = (timeout3) => {
|
|
6038
|
-
const lastFallbackDisable = (0,
|
|
6039
|
-
return (0,
|
|
6524
|
+
const lastFallbackDisable = (0, import_react37.useRef)(null);
|
|
6525
|
+
return (0, import_react37.useCallback)((manager) => {
|
|
6040
6526
|
collisionStore.setState({ fallbackEnabled: false });
|
|
6041
6527
|
const fallbackId = generateId();
|
|
6042
6528
|
lastFallbackDisable.current = fallbackId;
|
|
@@ -6055,9 +6541,9 @@ var DragDropContextClient = ({
|
|
|
6055
6541
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
6056
6542
|
const appStore = useAppStoreApi();
|
|
6057
6543
|
const id = useSafeId();
|
|
6058
|
-
const debouncedParamsRef = (0,
|
|
6544
|
+
const debouncedParamsRef = (0, import_react37.useRef)(null);
|
|
6059
6545
|
const tempDisableFallback = useTempDisableFallback(100);
|
|
6060
|
-
const [zoneStore] = (0,
|
|
6546
|
+
const [zoneStore] = (0, import_react37.useState)(
|
|
6061
6547
|
() => (0, import_zustand5.createStore)(() => ({
|
|
6062
6548
|
zoneDepthIndex: {},
|
|
6063
6549
|
nextZoneDepthIndex: {},
|
|
@@ -6069,7 +6555,7 @@ var DragDropContextClient = ({
|
|
|
6069
6555
|
hoveringComponent: null
|
|
6070
6556
|
}))
|
|
6071
6557
|
);
|
|
6072
|
-
const getChanged2 = (0,
|
|
6558
|
+
const getChanged2 = (0, import_react37.useCallback)(
|
|
6073
6559
|
(params, id2) => {
|
|
6074
6560
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
6075
6561
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
@@ -6090,7 +6576,7 @@ var DragDropContextClient = ({
|
|
|
6090
6576
|
},
|
|
6091
6577
|
[zoneStore]
|
|
6092
6578
|
);
|
|
6093
|
-
const setDeepestAndCollide = (0,
|
|
6579
|
+
const setDeepestAndCollide = (0, import_react37.useCallback)(
|
|
6094
6580
|
(params, manager) => {
|
|
6095
6581
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
|
6096
6582
|
if (!zoneChanged && !areaChanged) return;
|
|
@@ -6114,7 +6600,7 @@ var DragDropContextClient = ({
|
|
|
6114
6600
|
setDeepestDb.cancel();
|
|
6115
6601
|
debouncedParamsRef.current = null;
|
|
6116
6602
|
};
|
|
6117
|
-
(0,
|
|
6603
|
+
(0, import_react37.useEffect)(() => {
|
|
6118
6604
|
if (DEBUG3) {
|
|
6119
6605
|
zoneStore.subscribe(
|
|
6120
6606
|
(s) => {
|
|
@@ -6128,7 +6614,7 @@ var DragDropContextClient = ({
|
|
|
6128
6614
|
);
|
|
6129
6615
|
}
|
|
6130
6616
|
}, []);
|
|
6131
|
-
const [plugins] = (0,
|
|
6617
|
+
const [plugins] = (0, import_react37.useState)(() => [
|
|
6132
6618
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
|
6133
6619
|
createNestedDroppablePlugin(
|
|
6134
6620
|
{
|
|
@@ -6176,10 +6662,10 @@ var DragDropContextClient = ({
|
|
|
6176
6662
|
)
|
|
6177
6663
|
]);
|
|
6178
6664
|
const sensors = useSensors();
|
|
6179
|
-
const [dragListeners, setDragListeners] = (0,
|
|
6180
|
-
const dragMode = (0,
|
|
6181
|
-
const initialSelector = (0,
|
|
6182
|
-
const nextContextValue = (0,
|
|
6665
|
+
const [dragListeners, setDragListeners] = (0, import_react37.useState)({});
|
|
6666
|
+
const dragMode = (0, import_react37.useRef)(null);
|
|
6667
|
+
const initialSelector = (0, import_react37.useRef)(void 0);
|
|
6668
|
+
const nextContextValue = (0, import_react37.useMemo)(
|
|
6183
6669
|
() => ({
|
|
6184
6670
|
mode: "edit",
|
|
6185
6671
|
areaId: "root",
|
|
@@ -6187,15 +6673,15 @@ var DragDropContextClient = ({
|
|
|
6187
6673
|
}),
|
|
6188
6674
|
[]
|
|
6189
6675
|
);
|
|
6190
|
-
return /* @__PURE__ */ (0,
|
|
6676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
6191
6677
|
dragListenerContext.Provider,
|
|
6192
6678
|
{
|
|
6193
6679
|
value: {
|
|
6194
6680
|
dragListeners,
|
|
6195
6681
|
setDragListeners
|
|
6196
6682
|
},
|
|
6197
|
-
children: /* @__PURE__ */ (0,
|
|
6198
|
-
|
|
6683
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
6684
|
+
import_react36.DragDropProvider,
|
|
6199
6685
|
{
|
|
6200
6686
|
plugins,
|
|
6201
6687
|
sensors,
|
|
@@ -6410,7 +6896,7 @@ var DragDropContextClient = ({
|
|
|
6410
6896
|
const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
|
|
6411
6897
|
entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
|
|
6412
6898
|
},
|
|
6413
|
-
children: /* @__PURE__ */ (0,
|
|
6899
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
|
|
6414
6900
|
}
|
|
6415
6901
|
)
|
|
6416
6902
|
}
|
|
@@ -6424,13 +6910,13 @@ var DragDropContext = ({
|
|
|
6424
6910
|
if (status === "LOADING") {
|
|
6425
6911
|
return children;
|
|
6426
6912
|
}
|
|
6427
|
-
return /* @__PURE__ */ (0,
|
|
6913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
|
6428
6914
|
};
|
|
6429
6915
|
|
|
6430
6916
|
// components/Drawer/index.tsx
|
|
6431
|
-
var
|
|
6432
|
-
var
|
|
6433
|
-
var
|
|
6917
|
+
var import_react39 = require("@dnd-kit/react");
|
|
6918
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
6919
|
+
var getClassName19 = get_class_name_factory_default("Drawer", styles_module_default10);
|
|
6434
6920
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
|
6435
6921
|
var DrawerItemInner = ({
|
|
6436
6922
|
children,
|
|
@@ -6439,11 +6925,11 @@ var DrawerItemInner = ({
|
|
|
6439
6925
|
dragRef,
|
|
6440
6926
|
isDragDisabled
|
|
6441
6927
|
}) => {
|
|
6442
|
-
const CustomInner = (0,
|
|
6443
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
|
6928
|
+
const CustomInner = (0, import_react38.useMemo)(
|
|
6929
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
|
6444
6930
|
[children]
|
|
6445
6931
|
);
|
|
6446
|
-
return /* @__PURE__ */ (0,
|
|
6932
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6447
6933
|
"div",
|
|
6448
6934
|
{
|
|
6449
6935
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
|
@@ -6451,9 +6937,9 @@ var DrawerItemInner = ({
|
|
|
6451
6937
|
onMouseDown: (e) => e.preventDefault(),
|
|
6452
6938
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
|
6453
6939
|
"data-puck-drawer-item": true,
|
|
6454
|
-
children: /* @__PURE__ */ (0,
|
|
6455
|
-
/* @__PURE__ */ (0,
|
|
6456
|
-
/* @__PURE__ */ (0,
|
|
6940
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassNameItem2("draggable"), children: [
|
|
6941
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
|
6942
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DragIcon, {}) })
|
|
6457
6943
|
] }) }) })
|
|
6458
6944
|
}
|
|
6459
6945
|
);
|
|
@@ -6465,15 +6951,15 @@ var DrawerItemDraggable = ({
|
|
|
6465
6951
|
id,
|
|
6466
6952
|
isDragDisabled
|
|
6467
6953
|
}) => {
|
|
6468
|
-
const { ref } = (0,
|
|
6954
|
+
const { ref } = (0, import_react39.useDraggable)({
|
|
6469
6955
|
id,
|
|
6470
6956
|
data: { componentType: name },
|
|
6471
6957
|
disabled: isDragDisabled,
|
|
6472
6958
|
type: "drawer"
|
|
6473
6959
|
});
|
|
6474
|
-
return /* @__PURE__ */ (0,
|
|
6475
|
-
/* @__PURE__ */ (0,
|
|
6476
|
-
/* @__PURE__ */ (0,
|
|
6960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("draggable"), children: [
|
|
6961
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DrawerItemInner, { name, label, children }) }),
|
|
6962
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6477
6963
|
DrawerItemInner,
|
|
6478
6964
|
{
|
|
6479
6965
|
name,
|
|
@@ -6494,7 +6980,7 @@ var DrawerItem = ({
|
|
|
6494
6980
|
isDragDisabled
|
|
6495
6981
|
}) => {
|
|
6496
6982
|
const resolvedId = id || name;
|
|
6497
|
-
const [dynamicId, setDynamicId] = (0,
|
|
6983
|
+
const [dynamicId, setDynamicId] = (0, import_react38.useState)(generateId(resolvedId));
|
|
6498
6984
|
if (typeof index !== "undefined") {
|
|
6499
6985
|
console.error(
|
|
6500
6986
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
|
@@ -6507,7 +6993,7 @@ var DrawerItem = ({
|
|
|
6507
6993
|
},
|
|
6508
6994
|
[resolvedId]
|
|
6509
6995
|
);
|
|
6510
|
-
return /* @__PURE__ */ (0,
|
|
6996
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6511
6997
|
DrawerItemDraggable,
|
|
6512
6998
|
{
|
|
6513
6999
|
name,
|
|
@@ -6534,16 +7020,16 @@ var Drawer = ({
|
|
|
6534
7020
|
);
|
|
6535
7021
|
}
|
|
6536
7022
|
const id = useSafeId();
|
|
6537
|
-
const { ref } = (0,
|
|
7023
|
+
const { ref } = (0, import_react39.useDroppable)({
|
|
6538
7024
|
id,
|
|
6539
7025
|
type: "void",
|
|
6540
7026
|
collisionPriority: 0
|
|
6541
7027
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
|
6542
7028
|
});
|
|
6543
|
-
return /* @__PURE__ */ (0,
|
|
7029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6544
7030
|
"div",
|
|
6545
7031
|
{
|
|
6546
|
-
className:
|
|
7032
|
+
className: getClassName19(),
|
|
6547
7033
|
ref,
|
|
6548
7034
|
"data-puck-dnd": id,
|
|
6549
7035
|
"data-puck-drawer": true,
|
|
@@ -6556,18 +7042,18 @@ Drawer.Item = DrawerItem;
|
|
|
6556
7042
|
|
|
6557
7043
|
// components/Puck/index.tsx
|
|
6558
7044
|
init_react_import();
|
|
6559
|
-
var
|
|
7045
|
+
var import_react59 = require("react");
|
|
6560
7046
|
|
|
6561
7047
|
// components/SidebarSection/index.tsx
|
|
6562
7048
|
init_react_import();
|
|
6563
7049
|
|
|
6564
7050
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
6565
7051
|
init_react_import();
|
|
6566
|
-
var
|
|
7052
|
+
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
7053
|
|
|
6568
7054
|
// lib/use-breadcrumbs.ts
|
|
6569
7055
|
init_react_import();
|
|
6570
|
-
var
|
|
7056
|
+
var import_react40 = require("react");
|
|
6571
7057
|
var useBreadcrumbs = (renderCount) => {
|
|
6572
7058
|
const selectedId = useAppStore((s) => {
|
|
6573
7059
|
var _a;
|
|
@@ -6579,7 +7065,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6579
7065
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
6580
7066
|
});
|
|
6581
7067
|
const appStore = useAppStoreApi();
|
|
6582
|
-
return (0,
|
|
7068
|
+
return (0, import_react40.useMemo)(() => {
|
|
6583
7069
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
6584
7070
|
var _a, _b, _c;
|
|
6585
7071
|
const [componentId] = zoneCompound.split(":");
|
|
@@ -6610,8 +7096,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6610
7096
|
};
|
|
6611
7097
|
|
|
6612
7098
|
// components/SidebarSection/index.tsx
|
|
6613
|
-
var
|
|
6614
|
-
var
|
|
7099
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
7100
|
+
var getClassName20 = get_class_name_factory_default("SidebarSection", styles_module_default14);
|
|
6615
7101
|
var SidebarSection = ({
|
|
6616
7102
|
children,
|
|
6617
7103
|
title,
|
|
@@ -6623,29 +7109,29 @@ var SidebarSection = ({
|
|
|
6623
7109
|
}) => {
|
|
6624
7110
|
const setUi = useAppStore((s) => s.setUi);
|
|
6625
7111
|
const breadcrumbs = useBreadcrumbs(1);
|
|
6626
|
-
return /* @__PURE__ */ (0,
|
|
7112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
6627
7113
|
"div",
|
|
6628
7114
|
{
|
|
6629
|
-
className:
|
|
7115
|
+
className: getClassName20({ noBorderTop, noPadding }),
|
|
6630
7116
|
style: { background },
|
|
6631
7117
|
children: [
|
|
6632
|
-
/* @__PURE__ */ (0,
|
|
6633
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
|
6634
|
-
/* @__PURE__ */ (0,
|
|
7118
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("title"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("breadcrumbs"), children: [
|
|
7119
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("breadcrumb"), children: [
|
|
7120
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6635
7121
|
"button",
|
|
6636
7122
|
{
|
|
6637
7123
|
type: "button",
|
|
6638
|
-
className:
|
|
7124
|
+
className: getClassName20("breadcrumbLabel"),
|
|
6639
7125
|
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
|
6640
7126
|
children: breadcrumb.label
|
|
6641
7127
|
}
|
|
6642
7128
|
),
|
|
6643
|
-
/* @__PURE__ */ (0,
|
|
7129
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronRight, { size: 16 })
|
|
6644
7130
|
] }, i)) : null,
|
|
6645
|
-
/* @__PURE__ */ (0,
|
|
7131
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
|
6646
7132
|
] }) }),
|
|
6647
|
-
/* @__PURE__ */ (0,
|
|
6648
|
-
isLoading && /* @__PURE__ */ (0,
|
|
7133
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("content"), children }),
|
|
7134
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 32 }) })
|
|
6649
7135
|
]
|
|
6650
7136
|
}
|
|
6651
7137
|
);
|
|
@@ -6653,24 +7139,24 @@ var SidebarSection = ({
|
|
|
6653
7139
|
|
|
6654
7140
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
|
6655
7141
|
init_react_import();
|
|
6656
|
-
var
|
|
7142
|
+
var styles_module_default15 = { "Puck": "_Puck_1yxlw_19", "Puck-portal": "_Puck-portal_1yxlw_31", "PuckLayout-inner": "_PuckLayout-inner_1yxlw_38", "PuckLayout--mounted": "_PuckLayout--mounted_1yxlw_59", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_1yxlw_63", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_1yxlw_69", "PuckLayout-mounted": "_PuckLayout-mounted_1yxlw_83", "PuckLayout": "_PuckLayout_1yxlw_38" };
|
|
6657
7143
|
|
|
6658
7144
|
// components/Puck/components/Fields/index.tsx
|
|
6659
7145
|
init_react_import();
|
|
6660
7146
|
|
|
6661
7147
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
|
6662
7148
|
init_react_import();
|
|
6663
|
-
var
|
|
7149
|
+
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
7150
|
|
|
6665
7151
|
// components/Puck/components/Fields/index.tsx
|
|
6666
|
-
var
|
|
7152
|
+
var import_react41 = require("react");
|
|
6667
7153
|
var import_shallow5 = require("zustand/react/shallow");
|
|
6668
|
-
var
|
|
6669
|
-
var
|
|
7154
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
7155
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
|
6670
7156
|
var DefaultFields = ({
|
|
6671
7157
|
children
|
|
6672
7158
|
}) => {
|
|
6673
|
-
return /* @__PURE__ */ (0,
|
|
7159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
|
|
6674
7160
|
};
|
|
6675
7161
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
|
6676
7162
|
let currentProps;
|
|
@@ -6736,13 +7222,13 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6736
7222
|
})
|
|
6737
7223
|
);
|
|
6738
7224
|
const appStore = useAppStoreApi();
|
|
6739
|
-
const onChange = (0,
|
|
7225
|
+
const onChange = (0, import_react41.useCallback)(createOnChange(fieldName, appStore), [
|
|
6740
7226
|
fieldName
|
|
6741
7227
|
]);
|
|
6742
7228
|
const { visible = true } = field != null ? field : {};
|
|
6743
7229
|
if (!field || !id || !visible) return null;
|
|
6744
7230
|
if (field.type === "slot") return null;
|
|
6745
|
-
return /* @__PURE__ */ (0,
|
|
7231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
6746
7232
|
AutoFieldPrivate,
|
|
6747
7233
|
{
|
|
6748
7234
|
field,
|
|
@@ -6754,7 +7240,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6754
7240
|
}
|
|
6755
7241
|
) }, id);
|
|
6756
7242
|
};
|
|
6757
|
-
var FieldsChildMemo = (0,
|
|
7243
|
+
var FieldsChildMemo = (0, import_react41.memo)(FieldsChild);
|
|
6758
7244
|
var FieldsInternal = ({ wrapFields = true }) => {
|
|
6759
7245
|
const overrides = useAppStore((s) => s.overrides);
|
|
6760
7246
|
const componentResolving = useAppStore((s) => {
|
|
@@ -6779,51 +7265,60 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6779
7265
|
})
|
|
6780
7266
|
);
|
|
6781
7267
|
const isLoading = fieldsLoading || componentResolving;
|
|
6782
|
-
const Wrapper = (0,
|
|
6783
|
-
return /* @__PURE__ */ (0,
|
|
7268
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
7269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
6784
7270
|
"form",
|
|
6785
7271
|
{
|
|
6786
|
-
className:
|
|
7272
|
+
className: getClassName21({ wrapFields }),
|
|
6787
7273
|
onSubmit: (e) => {
|
|
6788
7274
|
e.preventDefault();
|
|
6789
7275
|
},
|
|
6790
7276
|
children: [
|
|
6791
|
-
/* @__PURE__ */ (0,
|
|
6792
|
-
isLoading && /* @__PURE__ */ (0,
|
|
7277
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
|
|
7278
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Loader, { size: 16 }) }) })
|
|
6793
7279
|
]
|
|
6794
7280
|
}
|
|
6795
7281
|
);
|
|
6796
7282
|
};
|
|
6797
|
-
var Fields = (0,
|
|
7283
|
+
var Fields = (0, import_react41.memo)(FieldsInternal);
|
|
6798
7284
|
|
|
6799
7285
|
// components/Puck/components/Components/index.tsx
|
|
6800
7286
|
init_react_import();
|
|
6801
7287
|
|
|
6802
7288
|
// lib/use-component-list.tsx
|
|
6803
7289
|
init_react_import();
|
|
6804
|
-
var
|
|
7290
|
+
var import_react43 = require("react");
|
|
6805
7291
|
|
|
6806
7292
|
// components/ComponentList/index.tsx
|
|
6807
7293
|
init_react_import();
|
|
6808
7294
|
|
|
6809
7295
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
|
6810
7296
|
init_react_import();
|
|
6811
|
-
var
|
|
7297
|
+
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
7298
|
|
|
6813
7299
|
// components/ComponentList/index.tsx
|
|
6814
|
-
var
|
|
6815
|
-
var
|
|
7300
|
+
var import_react42 = require("react");
|
|
7301
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
7302
|
+
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
|
6816
7303
|
var ComponentListItem = ({
|
|
6817
7304
|
name,
|
|
6818
7305
|
label
|
|
6819
7306
|
}) => {
|
|
7307
|
+
var _a;
|
|
6820
7308
|
const overrides = useAppStore((s) => s.overrides);
|
|
6821
7309
|
const canInsert = useAppStore(
|
|
6822
7310
|
(s) => s.permissions.getPermissions({
|
|
6823
7311
|
type: name
|
|
6824
7312
|
}).insert
|
|
6825
7313
|
);
|
|
6826
|
-
|
|
7314
|
+
(0, import_react42.useEffect)(() => {
|
|
7315
|
+
if (overrides.componentItem) {
|
|
7316
|
+
console.warn(
|
|
7317
|
+
"The `componentItem` override has been deprecated and renamed to `drawerItem`"
|
|
7318
|
+
);
|
|
7319
|
+
}
|
|
7320
|
+
}, [overrides]);
|
|
7321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
|
|
6827
7322
|
};
|
|
6828
7323
|
var ComponentList = ({
|
|
6829
7324
|
children,
|
|
@@ -6834,12 +7329,12 @@ var ComponentList = ({
|
|
|
6834
7329
|
const setUi = useAppStore((s) => s.setUi);
|
|
6835
7330
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
|
6836
7331
|
const { expanded = true } = componentList[id] || {};
|
|
6837
|
-
return /* @__PURE__ */ (0,
|
|
6838
|
-
title && /* @__PURE__ */ (0,
|
|
7332
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
|
7333
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
6839
7334
|
"button",
|
|
6840
7335
|
{
|
|
6841
7336
|
type: "button",
|
|
6842
|
-
className:
|
|
7337
|
+
className: getClassName22("title"),
|
|
6843
7338
|
onClick: () => setUi({
|
|
6844
7339
|
componentList: __spreadProps(__spreadValues({}, componentList), {
|
|
6845
7340
|
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
|
@@ -6849,14 +7344,14 @@ var ComponentList = ({
|
|
|
6849
7344
|
}),
|
|
6850
7345
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
|
6851
7346
|
children: [
|
|
6852
|
-
/* @__PURE__ */ (0,
|
|
6853
|
-
/* @__PURE__ */ (0,
|
|
7347
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: title }),
|
|
7348
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronDown, { size: 12 }) })
|
|
6854
7349
|
]
|
|
6855
7350
|
}
|
|
6856
7351
|
),
|
|
6857
|
-
/* @__PURE__ */ (0,
|
|
7352
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
|
6858
7353
|
var _a;
|
|
6859
|
-
return /* @__PURE__ */ (0,
|
|
7354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6860
7355
|
ComponentListItem,
|
|
6861
7356
|
{
|
|
6862
7357
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
|
@@ -6870,12 +7365,12 @@ var ComponentList = ({
|
|
|
6870
7365
|
ComponentList.Item = ComponentListItem;
|
|
6871
7366
|
|
|
6872
7367
|
// lib/use-component-list.tsx
|
|
6873
|
-
var
|
|
7368
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
6874
7369
|
var useComponentList = () => {
|
|
6875
|
-
const [componentList, setComponentList] = (0,
|
|
7370
|
+
const [componentList, setComponentList] = (0, import_react43.useState)();
|
|
6876
7371
|
const config = useAppStore((s) => s.config);
|
|
6877
7372
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
|
6878
|
-
(0,
|
|
7373
|
+
(0, import_react43.useEffect)(() => {
|
|
6879
7374
|
var _a, _b, _c;
|
|
6880
7375
|
if (Object.keys(uiComponentList).length > 0) {
|
|
6881
7376
|
const matchedComponents = [];
|
|
@@ -6885,7 +7380,7 @@ var useComponentList = () => {
|
|
|
6885
7380
|
if (category.visible === false || !category.components) {
|
|
6886
7381
|
return null;
|
|
6887
7382
|
}
|
|
6888
|
-
return /* @__PURE__ */ (0,
|
|
7383
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6889
7384
|
ComponentList,
|
|
6890
7385
|
{
|
|
6891
7386
|
id: categoryKey,
|
|
@@ -6894,7 +7389,7 @@ var useComponentList = () => {
|
|
|
6894
7389
|
var _a2;
|
|
6895
7390
|
matchedComponents.push(componentName);
|
|
6896
7391
|
const componentConf = config.components[componentName] || {};
|
|
6897
|
-
return /* @__PURE__ */ (0,
|
|
7392
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6898
7393
|
ComponentList.Item,
|
|
6899
7394
|
{
|
|
6900
7395
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
|
@@ -6914,7 +7409,7 @@ var useComponentList = () => {
|
|
|
6914
7409
|
);
|
|
6915
7410
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
|
6916
7411
|
_componentList.push(
|
|
6917
|
-
/* @__PURE__ */ (0,
|
|
7412
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6918
7413
|
ComponentList,
|
|
6919
7414
|
{
|
|
6920
7415
|
id: "other",
|
|
@@ -6922,7 +7417,7 @@ var useComponentList = () => {
|
|
|
6922
7417
|
children: remainingComponents.map((componentName, i) => {
|
|
6923
7418
|
var _a2;
|
|
6924
7419
|
const componentConf = config.components[componentName] || {};
|
|
6925
|
-
return /* @__PURE__ */ (0,
|
|
7420
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6926
7421
|
ComponentList.Item,
|
|
6927
7422
|
{
|
|
6928
7423
|
name: componentName,
|
|
@@ -6944,25 +7439,32 @@ var useComponentList = () => {
|
|
|
6944
7439
|
};
|
|
6945
7440
|
|
|
6946
7441
|
// components/Puck/components/Components/index.tsx
|
|
6947
|
-
var
|
|
6948
|
-
var
|
|
7442
|
+
var import_react44 = require("react");
|
|
7443
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6949
7444
|
var Components = () => {
|
|
6950
7445
|
const overrides = useAppStore((s) => s.overrides);
|
|
6951
7446
|
const componentList = useComponentList();
|
|
6952
|
-
const Wrapper = (0,
|
|
6953
|
-
|
|
7447
|
+
const Wrapper = (0, import_react44.useMemo)(() => {
|
|
7448
|
+
if (overrides.components) {
|
|
7449
|
+
console.warn(
|
|
7450
|
+
"The `components` override has been deprecated and renamed to `drawer`"
|
|
7451
|
+
);
|
|
7452
|
+
}
|
|
7453
|
+
return overrides.components || overrides.drawer || "div";
|
|
7454
|
+
}, [overrides]);
|
|
7455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComponentList, { id: "all" }) });
|
|
6954
7456
|
};
|
|
6955
7457
|
|
|
6956
7458
|
// components/Puck/components/Preview/index.tsx
|
|
6957
7459
|
init_react_import();
|
|
6958
|
-
var
|
|
7460
|
+
var import_react46 = require("react");
|
|
6959
7461
|
|
|
6960
7462
|
// components/AutoFrame/index.tsx
|
|
6961
7463
|
init_react_import();
|
|
6962
|
-
var
|
|
7464
|
+
var import_react45 = require("react");
|
|
6963
7465
|
var import_object_hash = __toESM(require("object-hash"));
|
|
6964
7466
|
var import_react_dom3 = require("react-dom");
|
|
6965
|
-
var
|
|
7467
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
6966
7468
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
|
6967
7469
|
var collectStyles = (doc) => {
|
|
6968
7470
|
const collected = [];
|
|
@@ -7012,7 +7514,7 @@ var CopyHostStyles = ({
|
|
|
7012
7514
|
onStylesLoaded = () => null
|
|
7013
7515
|
}) => {
|
|
7014
7516
|
const { document: doc, window: win } = useFrame();
|
|
7015
|
-
(0,
|
|
7517
|
+
(0, import_react45.useEffect)(() => {
|
|
7016
7518
|
if (!win || !doc) {
|
|
7017
7519
|
return () => {
|
|
7018
7520
|
};
|
|
@@ -7169,10 +7671,10 @@ var CopyHostStyles = ({
|
|
|
7169
7671
|
observer.disconnect();
|
|
7170
7672
|
};
|
|
7171
7673
|
}, []);
|
|
7172
|
-
return /* @__PURE__ */ (0,
|
|
7674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
|
|
7173
7675
|
};
|
|
7174
|
-
var autoFrameContext = (0,
|
|
7175
|
-
var useFrame = () => (0,
|
|
7676
|
+
var autoFrameContext = (0, import_react45.createContext)({});
|
|
7677
|
+
var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
|
|
7176
7678
|
function AutoFrame(_a) {
|
|
7177
7679
|
var _b = _a, {
|
|
7178
7680
|
children,
|
|
@@ -7193,11 +7695,11 @@ function AutoFrame(_a) {
|
|
|
7193
7695
|
"onNotReady",
|
|
7194
7696
|
"frameRef"
|
|
7195
7697
|
]);
|
|
7196
|
-
const [loaded, setLoaded] = (0,
|
|
7197
|
-
const [ctx, setCtx] = (0,
|
|
7198
|
-
const [mountTarget, setMountTarget] = (0,
|
|
7199
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
|
7200
|
-
(0,
|
|
7698
|
+
const [loaded, setLoaded] = (0, import_react45.useState)(false);
|
|
7699
|
+
const [ctx, setCtx] = (0, import_react45.useState)({});
|
|
7700
|
+
const [mountTarget, setMountTarget] = (0, import_react45.useState)();
|
|
7701
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react45.useState)(false);
|
|
7702
|
+
(0, import_react45.useEffect)(() => {
|
|
7201
7703
|
var _a2;
|
|
7202
7704
|
if (frameRef.current) {
|
|
7203
7705
|
const doc = frameRef.current.contentDocument;
|
|
@@ -7216,7 +7718,7 @@ function AutoFrame(_a) {
|
|
|
7216
7718
|
}
|
|
7217
7719
|
}
|
|
7218
7720
|
}, [frameRef, loaded, stylesLoaded]);
|
|
7219
|
-
return /* @__PURE__ */ (0,
|
|
7721
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7220
7722
|
"iframe",
|
|
7221
7723
|
__spreadProps(__spreadValues({}, props), {
|
|
7222
7724
|
className,
|
|
@@ -7226,7 +7728,7 @@ function AutoFrame(_a) {
|
|
|
7226
7728
|
onLoad: () => {
|
|
7227
7729
|
setLoaded(true);
|
|
7228
7730
|
},
|
|
7229
|
-
children: /* @__PURE__ */ (0,
|
|
7731
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7230
7732
|
CopyHostStyles,
|
|
7231
7733
|
{
|
|
7232
7734
|
debug,
|
|
@@ -7242,14 +7744,14 @@ var AutoFrame_default = AutoFrame;
|
|
|
7242
7744
|
|
|
7243
7745
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
|
7244
7746
|
init_react_import();
|
|
7245
|
-
var
|
|
7747
|
+
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
|
7246
7748
|
|
|
7247
7749
|
// components/Puck/components/Preview/index.tsx
|
|
7248
|
-
var
|
|
7249
|
-
var
|
|
7750
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
7751
|
+
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
|
7250
7752
|
var useBubbleIframeEvents = (ref) => {
|
|
7251
7753
|
const status = useAppStore((s) => s.status);
|
|
7252
|
-
(0,
|
|
7754
|
+
(0, import_react46.useEffect)(() => {
|
|
7253
7755
|
if (ref.current && status === "READY") {
|
|
7254
7756
|
const iframe = ref.current;
|
|
7255
7757
|
const handlePointerMove = (event) => {
|
|
@@ -7298,7 +7800,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7298
7800
|
const renderData = useAppStore(
|
|
7299
7801
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
7300
7802
|
);
|
|
7301
|
-
const Page = (0,
|
|
7803
|
+
const Page = (0, import_react46.useCallback)(
|
|
7302
7804
|
(pageProps) => {
|
|
7303
7805
|
var _a, _b;
|
|
7304
7806
|
const propsWithSlots = useSlots(
|
|
@@ -7308,15 +7810,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7308
7810
|
);
|
|
7309
7811
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
7310
7812
|
id: "puck-root"
|
|
7311
|
-
}, propsWithSlots)) : /* @__PURE__ */ (0,
|
|
7813
|
+
}, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: propsWithSlots.children });
|
|
7312
7814
|
},
|
|
7313
7815
|
[config]
|
|
7314
7816
|
);
|
|
7315
|
-
const Frame = (0,
|
|
7817
|
+
const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
|
|
7316
7818
|
const rootProps = root.props || root;
|
|
7317
|
-
const ref = (0,
|
|
7819
|
+
const ref = (0, import_react46.useRef)(null);
|
|
7318
7820
|
useBubbleIframeEvents(ref);
|
|
7319
|
-
const inner = !renderData ? /* @__PURE__ */ (0,
|
|
7821
|
+
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7320
7822
|
Page,
|
|
7321
7823
|
__spreadProps(__spreadValues({}, rootProps), {
|
|
7322
7824
|
puck: {
|
|
@@ -7326,28 +7828,31 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7326
7828
|
metadata
|
|
7327
7829
|
},
|
|
7328
7830
|
editMode: true,
|
|
7329
|
-
children: /* @__PURE__ */ (0,
|
|
7831
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7330
7832
|
})
|
|
7331
|
-
) : /* @__PURE__ */ (0,
|
|
7332
|
-
(0,
|
|
7833
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Render, { data: renderData, config, metadata });
|
|
7834
|
+
(0, import_react46.useEffect)(() => {
|
|
7333
7835
|
if (!iframe.enabled) {
|
|
7334
7836
|
setStatus("READY");
|
|
7335
7837
|
}
|
|
7336
7838
|
}, [iframe.enabled]);
|
|
7337
|
-
return /* @__PURE__ */ (0,
|
|
7839
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7338
7840
|
"div",
|
|
7339
7841
|
{
|
|
7340
|
-
className:
|
|
7842
|
+
className: getClassName23(),
|
|
7341
7843
|
id,
|
|
7342
7844
|
"data-puck-preview": true,
|
|
7343
|
-
onClick: () => {
|
|
7344
|
-
|
|
7845
|
+
onClick: (e) => {
|
|
7846
|
+
const el = e.target;
|
|
7847
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
7848
|
+
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
|
7849
|
+
}
|
|
7345
7850
|
},
|
|
7346
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
|
7851
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7347
7852
|
AutoFrame_default,
|
|
7348
7853
|
{
|
|
7349
7854
|
id: "preview-frame",
|
|
7350
|
-
className:
|
|
7855
|
+
className: getClassName23("frame"),
|
|
7351
7856
|
"data-rfd-iframe": true,
|
|
7352
7857
|
onReady: () => {
|
|
7353
7858
|
setStatus("READY");
|
|
@@ -7356,18 +7861,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7356
7861
|
setStatus("MOUNTED");
|
|
7357
7862
|
},
|
|
7358
7863
|
frameRef: ref,
|
|
7359
|
-
children: /* @__PURE__ */ (0,
|
|
7864
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
|
7360
7865
|
if (Frame) {
|
|
7361
|
-
return /* @__PURE__ */ (0,
|
|
7866
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Frame, { document: document2, children: inner });
|
|
7362
7867
|
}
|
|
7363
7868
|
return inner;
|
|
7364
7869
|
} })
|
|
7365
7870
|
}
|
|
7366
|
-
) : /* @__PURE__ */ (0,
|
|
7871
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7367
7872
|
"div",
|
|
7368
7873
|
{
|
|
7369
7874
|
id: "preview-frame",
|
|
7370
|
-
className:
|
|
7875
|
+
className: getClassName23("frame"),
|
|
7371
7876
|
ref,
|
|
7372
7877
|
"data-puck-entry": true,
|
|
7373
7878
|
children: inner
|
|
@@ -7385,7 +7890,7 @@ init_react_import();
|
|
|
7385
7890
|
|
|
7386
7891
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
|
7387
7892
|
init_react_import();
|
|
7388
|
-
var
|
|
7893
|
+
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
7894
|
|
|
7390
7895
|
// lib/scroll-into-view.ts
|
|
7391
7896
|
init_react_import();
|
|
@@ -7399,7 +7904,7 @@ var scrollIntoView = (el) => {
|
|
|
7399
7904
|
};
|
|
7400
7905
|
|
|
7401
7906
|
// components/LayerTree/index.tsx
|
|
7402
|
-
var
|
|
7907
|
+
var import_react47 = require("react");
|
|
7403
7908
|
|
|
7404
7909
|
// lib/on-scroll-end.ts
|
|
7405
7910
|
init_react_import();
|
|
@@ -7422,9 +7927,9 @@ var onScrollEnd = (frame, cb) => {
|
|
|
7422
7927
|
|
|
7423
7928
|
// components/LayerTree/index.tsx
|
|
7424
7929
|
var import_shallow6 = require("zustand/react/shallow");
|
|
7425
|
-
var
|
|
7426
|
-
var
|
|
7427
|
-
var getClassNameLayer = get_class_name_factory_default("Layer",
|
|
7930
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7931
|
+
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
|
7932
|
+
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
|
7428
7933
|
var Layer = ({
|
|
7429
7934
|
index,
|
|
7430
7935
|
itemId,
|
|
@@ -7434,7 +7939,7 @@ var Layer = ({
|
|
|
7434
7939
|
const config = useAppStore((s) => s.config);
|
|
7435
7940
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
7436
7941
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
7437
|
-
const setItemSelector = (0,
|
|
7942
|
+
const setItemSelector = (0, import_react47.useCallback)(
|
|
7438
7943
|
(itemSelector2) => {
|
|
7439
7944
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
7440
7945
|
},
|
|
@@ -7454,7 +7959,7 @@ var Layer = ({
|
|
|
7454
7959
|
)
|
|
7455
7960
|
);
|
|
7456
7961
|
const containsZone = zonesForItem.length > 0;
|
|
7457
|
-
const zoneStore = (0,
|
|
7962
|
+
const zoneStore = (0, import_react47.useContext)(ZoneStoreContext);
|
|
7458
7963
|
const isHovering = useContextStore(
|
|
7459
7964
|
ZoneStoreContext,
|
|
7460
7965
|
(s) => s.hoveringComponent === itemId
|
|
@@ -7469,7 +7974,7 @@ var Layer = ({
|
|
|
7469
7974
|
});
|
|
7470
7975
|
const componentConfig = config.components[nodeData.data.type];
|
|
7471
7976
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
|
7472
|
-
return /* @__PURE__ */ (0,
|
|
7977
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
7473
7978
|
"li",
|
|
7474
7979
|
{
|
|
7475
7980
|
className: getClassNameLayer({
|
|
@@ -7479,7 +7984,7 @@ var Layer = ({
|
|
|
7479
7984
|
childIsSelected
|
|
7480
7985
|
}),
|
|
7481
7986
|
children: [
|
|
7482
|
-
/* @__PURE__ */ (0,
|
|
7987
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
7483
7988
|
"button",
|
|
7484
7989
|
{
|
|
7485
7990
|
type: "button",
|
|
@@ -7517,241 +8022,120 @@ var Layer = ({
|
|
|
7517
8022
|
zoneStore.setState({ hoveringComponent: null });
|
|
7518
8023
|
},
|
|
7519
8024
|
children: [
|
|
7520
|
-
containsZone && /* @__PURE__ */ (0,
|
|
8025
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7521
8026
|
"div",
|
|
7522
8027
|
{
|
|
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
|
|
8028
|
+
className: getClassNameLayer("chevron"),
|
|
8029
|
+
title: isSelected ? "Collapse" : "Expand",
|
|
8030
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, { size: "12" })
|
|
8031
|
+
}
|
|
8032
|
+
),
|
|
8033
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
|
8034
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayoutGrid, { size: "16" }) }),
|
|
8035
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("name"), children: label })
|
|
8036
|
+
] })
|
|
8037
|
+
]
|
|
8038
|
+
}
|
|
8039
|
+
) }),
|
|
8040
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
|
|
8041
|
+
]
|
|
8042
|
+
}
|
|
8043
|
+
);
|
|
8044
|
+
};
|
|
8045
|
+
var LayerTree = ({
|
|
8046
|
+
label: _label,
|
|
8047
|
+
zoneCompound
|
|
8048
|
+
}) => {
|
|
8049
|
+
const label = useAppStore((s) => {
|
|
8050
|
+
var _a, _b, _c, _d;
|
|
8051
|
+
if (_label) return _label;
|
|
8052
|
+
if (zoneCompound === rootDroppableId) return;
|
|
8053
|
+
const [componentId, slotId] = zoneCompound.split(":");
|
|
8054
|
+
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
8055
|
+
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
8056
|
+
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7727
8057
|
});
|
|
8058
|
+
const contentIds = useAppStore(
|
|
8059
|
+
(0, import_shallow6.useShallow)(
|
|
8060
|
+
(s) => {
|
|
8061
|
+
var _a, _b;
|
|
8062
|
+
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
8063
|
+
}
|
|
8064
|
+
)
|
|
8065
|
+
);
|
|
8066
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
8067
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
|
8068
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Layers, { size: "16" }) }),
|
|
8069
|
+
label
|
|
8070
|
+
] }),
|
|
8071
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("ul", { className: getClassName24(), children: [
|
|
8072
|
+
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
|
8073
|
+
contentIds.map((itemId, i) => {
|
|
8074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
8075
|
+
Layer,
|
|
8076
|
+
{
|
|
8077
|
+
index: i,
|
|
8078
|
+
itemId,
|
|
8079
|
+
zoneCompound
|
|
8080
|
+
},
|
|
8081
|
+
itemId
|
|
8082
|
+
);
|
|
8083
|
+
})
|
|
8084
|
+
] })
|
|
8085
|
+
] });
|
|
7728
8086
|
};
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
8087
|
+
|
|
8088
|
+
// components/Puck/components/Outline/index.tsx
|
|
8089
|
+
var import_react48 = require("react");
|
|
8090
|
+
|
|
8091
|
+
// lib/data/find-zones-for-area.ts
|
|
8092
|
+
init_react_import();
|
|
8093
|
+
var findZonesForArea = (state, area) => {
|
|
8094
|
+
return Object.keys(state.indexes.zones).filter(
|
|
8095
|
+
(zone) => zone.split(":")[0] === area
|
|
8096
|
+
);
|
|
8097
|
+
};
|
|
8098
|
+
|
|
8099
|
+
// components/Puck/components/Outline/index.tsx
|
|
8100
|
+
var import_shallow7 = require("zustand/react/shallow");
|
|
8101
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
8102
|
+
var Outline = () => {
|
|
8103
|
+
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
8104
|
+
const rootZones = useAppStore(
|
|
8105
|
+
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
8106
|
+
);
|
|
8107
|
+
const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
8108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
8109
|
+
LayerTree,
|
|
8110
|
+
{
|
|
8111
|
+
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
8112
|
+
zoneCompound
|
|
8113
|
+
},
|
|
8114
|
+
zoneCompound
|
|
8115
|
+
)) });
|
|
7733
8116
|
};
|
|
7734
8117
|
|
|
7735
8118
|
// components/Puck/components/Canvas/index.tsx
|
|
7736
|
-
|
|
8119
|
+
init_react_import();
|
|
8120
|
+
var import_react51 = require("react");
|
|
7737
8121
|
|
|
7738
8122
|
// components/ViewportControls/index.tsx
|
|
7739
8123
|
init_react_import();
|
|
7740
|
-
var
|
|
8124
|
+
var import_react49 = require("react");
|
|
7741
8125
|
|
|
7742
8126
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
7743
8127
|
init_react_import();
|
|
7744
|
-
var
|
|
8128
|
+
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
8129
|
|
|
7746
8130
|
// components/ViewportControls/index.tsx
|
|
7747
|
-
var
|
|
8131
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
7748
8132
|
var icons = {
|
|
7749
|
-
Smartphone: /* @__PURE__ */ (0,
|
|
7750
|
-
Tablet: /* @__PURE__ */ (0,
|
|
7751
|
-
Monitor: /* @__PURE__ */ (0,
|
|
8133
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Smartphone, { size: 16 }),
|
|
8134
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Tablet, { size: 16 }),
|
|
8135
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Monitor, { size: 16 })
|
|
7752
8136
|
};
|
|
7753
|
-
var
|
|
7754
|
-
var getClassNameButton = get_class_name_factory_default("ViewportButton",
|
|
8137
|
+
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
|
8138
|
+
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
|
7755
8139
|
var ViewportButton = ({
|
|
7756
8140
|
children,
|
|
7757
8141
|
height = "auto",
|
|
@@ -7760,11 +8144,11 @@ var ViewportButton = ({
|
|
|
7760
8144
|
onClick
|
|
7761
8145
|
}) => {
|
|
7762
8146
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
|
7763
|
-
const [isActive, setIsActive] = (0,
|
|
7764
|
-
(0,
|
|
8147
|
+
const [isActive, setIsActive] = (0, import_react49.useState)(false);
|
|
8148
|
+
(0, import_react49.useEffect)(() => {
|
|
7765
8149
|
setIsActive(width === viewports.current.width);
|
|
7766
8150
|
}, [width, viewports.current.width]);
|
|
7767
|
-
return /* @__PURE__ */ (0,
|
|
8151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
7768
8152
|
IconButton,
|
|
7769
8153
|
{
|
|
7770
8154
|
type: "button",
|
|
@@ -7774,7 +8158,7 @@ var ViewportButton = ({
|
|
|
7774
8158
|
e.stopPropagation();
|
|
7775
8159
|
onClick({ width, height });
|
|
7776
8160
|
},
|
|
7777
|
-
children: /* @__PURE__ */ (0,
|
|
8161
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton("inner"), children })
|
|
7778
8162
|
}
|
|
7779
8163
|
) });
|
|
7780
8164
|
};
|
|
@@ -7798,7 +8182,7 @@ var ViewportControls = ({
|
|
|
7798
8182
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
7799
8183
|
(option) => option.value === autoZoom
|
|
7800
8184
|
);
|
|
7801
|
-
const zoomOptions = (0,
|
|
8185
|
+
const zoomOptions = (0, import_react49.useMemo)(
|
|
7802
8186
|
() => [
|
|
7803
8187
|
...defaultZoomOptions,
|
|
7804
8188
|
...defaultsContainAutoZoom ? [] : [
|
|
@@ -7810,8 +8194,8 @@ var ViewportControls = ({
|
|
|
7810
8194
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
|
7811
8195
|
[autoZoom]
|
|
7812
8196
|
);
|
|
7813
|
-
return /* @__PURE__ */ (0,
|
|
7814
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
|
8197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25(), children: [
|
|
8198
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
7815
8199
|
ViewportButton,
|
|
7816
8200
|
{
|
|
7817
8201
|
height: viewport.height,
|
|
@@ -7822,8 +8206,8 @@ var ViewportControls = ({
|
|
|
7822
8206
|
},
|
|
7823
8207
|
i
|
|
7824
8208
|
)),
|
|
7825
|
-
/* @__PURE__ */ (0,
|
|
7826
|
-
/* @__PURE__ */ (0,
|
|
8209
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
|
|
8210
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
7827
8211
|
IconButton,
|
|
7828
8212
|
{
|
|
7829
8213
|
type: "button",
|
|
@@ -7838,10 +8222,10 @@ var ViewportControls = ({
|
|
|
7838
8222
|
)].value
|
|
7839
8223
|
);
|
|
7840
8224
|
},
|
|
7841
|
-
children: /* @__PURE__ */ (0,
|
|
8225
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomOut, { size: 16 })
|
|
7842
8226
|
}
|
|
7843
8227
|
),
|
|
7844
|
-
/* @__PURE__ */ (0,
|
|
8228
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
7845
8229
|
IconButton,
|
|
7846
8230
|
{
|
|
7847
8231
|
type: "button",
|
|
@@ -7856,19 +8240,19 @@ var ViewportControls = ({
|
|
|
7856
8240
|
)].value
|
|
7857
8241
|
);
|
|
7858
8242
|
},
|
|
7859
|
-
children: /* @__PURE__ */ (0,
|
|
8243
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomIn, { size: 16 })
|
|
7860
8244
|
}
|
|
7861
8245
|
),
|
|
7862
|
-
/* @__PURE__ */ (0,
|
|
7863
|
-
/* @__PURE__ */ (0,
|
|
8246
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
|
|
8247
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
7864
8248
|
"select",
|
|
7865
8249
|
{
|
|
7866
|
-
className:
|
|
8250
|
+
className: getClassName25("zoomSelect"),
|
|
7867
8251
|
value: zoom.toString(),
|
|
7868
8252
|
onChange: (e) => {
|
|
7869
8253
|
onZoom(parseFloat(e.currentTarget.value));
|
|
7870
8254
|
},
|
|
7871
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
|
8255
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
7872
8256
|
"option",
|
|
7873
8257
|
{
|
|
7874
8258
|
value: option.value,
|
|
@@ -7883,44 +8267,44 @@ var ViewportControls = ({
|
|
|
7883
8267
|
|
|
7884
8268
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
7885
8269
|
init_react_import();
|
|
7886
|
-
var
|
|
8270
|
+
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
8271
|
|
|
7888
|
-
//
|
|
8272
|
+
// components/Puck/components/Canvas/index.tsx
|
|
8273
|
+
var import_shallow8 = require("zustand/react/shallow");
|
|
8274
|
+
|
|
8275
|
+
// lib/frame-context.tsx
|
|
7889
8276
|
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
|
-
}
|
|
8277
|
+
var import_react50 = require("react");
|
|
8278
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
8279
|
+
var FrameContext = (0, import_react50.createContext)(null);
|
|
8280
|
+
var FrameProvider = ({
|
|
8281
|
+
children
|
|
8282
|
+
}) => {
|
|
8283
|
+
const frameRef = (0, import_react50.useRef)(null);
|
|
8284
|
+
const value = (0, import_react50.useMemo)(
|
|
8285
|
+
() => ({
|
|
8286
|
+
frameRef
|
|
8287
|
+
}),
|
|
8288
|
+
[]
|
|
8289
|
+
);
|
|
8290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(FrameContext.Provider, { value, children });
|
|
8291
|
+
};
|
|
8292
|
+
var useCanvasFrame = () => {
|
|
8293
|
+
const context = (0, import_react50.useContext)(FrameContext);
|
|
8294
|
+
if (context === null) {
|
|
8295
|
+
throw new Error("useCanvasFrame must be used within a FrameProvider");
|
|
7914
8296
|
}
|
|
7915
|
-
return
|
|
8297
|
+
return context;
|
|
7916
8298
|
};
|
|
7917
8299
|
|
|
7918
8300
|
// components/Puck/components/Canvas/index.tsx
|
|
7919
|
-
var
|
|
7920
|
-
var
|
|
7921
|
-
var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
|
|
8301
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
8302
|
+
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
|
7922
8303
|
var ZOOM_ON_CHANGE = true;
|
|
8304
|
+
var TRANSITION_DURATION = 150;
|
|
7923
8305
|
var Canvas = () => {
|
|
8306
|
+
const { frameRef } = useCanvasFrame();
|
|
8307
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
7924
8308
|
const {
|
|
7925
8309
|
dispatch,
|
|
7926
8310
|
overrides,
|
|
@@ -7940,24 +8324,32 @@ var Canvas = () => {
|
|
|
7940
8324
|
iframe: s.iframe
|
|
7941
8325
|
}))
|
|
7942
8326
|
);
|
|
7943
|
-
const {
|
|
8327
|
+
const {
|
|
8328
|
+
leftSideBarVisible,
|
|
8329
|
+
rightSideBarVisible,
|
|
8330
|
+
leftSideBarWidth,
|
|
8331
|
+
rightSideBarWidth,
|
|
8332
|
+
viewports
|
|
8333
|
+
} = useAppStore(
|
|
7944
8334
|
(0, import_shallow8.useShallow)((s) => ({
|
|
7945
8335
|
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
7946
8336
|
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
8337
|
+
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
8338
|
+
rightSideBarWidth: s.state.ui.rightSideBarWidth,
|
|
7947
8339
|
viewports: s.state.ui.viewports
|
|
7948
8340
|
}))
|
|
7949
8341
|
);
|
|
7950
|
-
const
|
|
7951
|
-
const
|
|
7952
|
-
const defaultRender = (0,
|
|
7953
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
|
8342
|
+
const [showTransition, setShowTransition] = (0, import_react51.useState)(false);
|
|
8343
|
+
const isResizingRef = (0, import_react51.useRef)(false);
|
|
8344
|
+
const defaultRender = (0, import_react51.useMemo)(() => {
|
|
8345
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
|
|
7954
8346
|
return PuckDefault;
|
|
7955
8347
|
}, []);
|
|
7956
|
-
const CustomPreview = (0,
|
|
8348
|
+
const CustomPreview = (0, import_react51.useMemo)(
|
|
7957
8349
|
() => overrides.preview || defaultRender,
|
|
7958
8350
|
[overrides]
|
|
7959
8351
|
);
|
|
7960
|
-
const getFrameDimensions = (0,
|
|
8352
|
+
const getFrameDimensions = (0, import_react51.useCallback)(() => {
|
|
7961
8353
|
if (frameRef.current) {
|
|
7962
8354
|
const frame = frameRef.current;
|
|
7963
8355
|
const box = getBox(frame);
|
|
@@ -7965,74 +8357,73 @@ var Canvas = () => {
|
|
|
7965
8357
|
}
|
|
7966
8358
|
return { width: 0, height: 0 };
|
|
7967
8359
|
}, [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)(() => {
|
|
8360
|
+
(0, import_react51.useEffect)(() => {
|
|
8361
|
+
resetAutoZoom();
|
|
8362
|
+
}, [
|
|
8363
|
+
frameRef,
|
|
8364
|
+
leftSideBarVisible,
|
|
8365
|
+
rightSideBarVisible,
|
|
8366
|
+
leftSideBarWidth,
|
|
8367
|
+
rightSideBarWidth,
|
|
8368
|
+
viewports
|
|
8369
|
+
]);
|
|
8370
|
+
(0, import_react51.useEffect)(() => {
|
|
7987
8371
|
const { height: frameHeight } = getFrameDimensions();
|
|
7988
8372
|
if (viewports.current.height === "auto") {
|
|
7989
8373
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
7990
8374
|
rootHeight: frameHeight / zoomConfig.zoom
|
|
7991
8375
|
}));
|
|
7992
8376
|
}
|
|
7993
|
-
}, [zoomConfig.zoom]);
|
|
7994
|
-
(0,
|
|
8377
|
+
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
8378
|
+
(0, import_react51.useEffect)(() => {
|
|
7995
8379
|
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
8380
|
resetAutoZoom();
|
|
8004
|
-
}
|
|
8005
|
-
|
|
8381
|
+
}
|
|
8382
|
+
}, [viewports.current.width, viewports]);
|
|
8383
|
+
(0, import_react51.useEffect)(() => {
|
|
8384
|
+
if (!frameRef.current) return;
|
|
8385
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
8386
|
+
if (!isResizingRef.current) {
|
|
8387
|
+
resetAutoZoom();
|
|
8388
|
+
}
|
|
8389
|
+
});
|
|
8390
|
+
resizeObserver.observe(frameRef.current);
|
|
8006
8391
|
return () => {
|
|
8007
|
-
|
|
8392
|
+
resizeObserver.disconnect();
|
|
8008
8393
|
};
|
|
8009
|
-
}, []);
|
|
8010
|
-
const [showLoader, setShowLoader] = (0,
|
|
8011
|
-
(0,
|
|
8394
|
+
}, [frameRef.current]);
|
|
8395
|
+
const [showLoader, setShowLoader] = (0, import_react51.useState)(false);
|
|
8396
|
+
(0, import_react51.useEffect)(() => {
|
|
8012
8397
|
setTimeout(() => {
|
|
8013
8398
|
setShowLoader(true);
|
|
8014
8399
|
}, 500);
|
|
8015
8400
|
}, []);
|
|
8016
|
-
return /* @__PURE__ */ (0,
|
|
8401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
|
|
8017
8402
|
"div",
|
|
8018
8403
|
{
|
|
8019
|
-
className:
|
|
8404
|
+
className: getClassName26({
|
|
8020
8405
|
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
|
8021
8406
|
showLoader
|
|
8022
8407
|
}),
|
|
8023
|
-
onClick: () =>
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8408
|
+
onClick: (e) => {
|
|
8409
|
+
const el = e.target;
|
|
8410
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
8411
|
+
dispatch({
|
|
8412
|
+
type: "setUi",
|
|
8413
|
+
ui: { itemSelector: null },
|
|
8414
|
+
recordHistory: true
|
|
8415
|
+
});
|
|
8416
|
+
}
|
|
8417
|
+
},
|
|
8028
8418
|
children: [
|
|
8029
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
|
8419
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
8030
8420
|
ViewportControls,
|
|
8031
8421
|
{
|
|
8032
8422
|
autoZoom: zoomConfig.autoZoom,
|
|
8033
8423
|
zoom: zoomConfig.zoom,
|
|
8034
8424
|
onViewportChange: (viewport) => {
|
|
8035
8425
|
setShowTransition(true);
|
|
8426
|
+
isResizingRef.current = true;
|
|
8036
8427
|
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
|
8037
8428
|
height: viewport.height || "auto",
|
|
8038
8429
|
zoom: zoomConfig.zoom
|
|
@@ -8043,41 +8434,40 @@ var Canvas = () => {
|
|
|
8043
8434
|
};
|
|
8044
8435
|
setUi(newUi);
|
|
8045
8436
|
if (ZOOM_ON_CHANGE) {
|
|
8046
|
-
resetAutoZoom(
|
|
8437
|
+
resetAutoZoom({
|
|
8438
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
8439
|
+
});
|
|
8047
8440
|
}
|
|
8048
8441
|
},
|
|
8049
8442
|
onZoom: (zoom) => {
|
|
8050
8443
|
setShowTransition(true);
|
|
8444
|
+
isResizingRef.current = true;
|
|
8051
8445
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
|
8052
8446
|
}
|
|
8053
8447
|
}
|
|
8054
8448
|
) }),
|
|
8055
|
-
/* @__PURE__ */ (0,
|
|
8056
|
-
/* @__PURE__ */ (0,
|
|
8449
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
|
8450
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
8057
8451
|
"div",
|
|
8058
8452
|
{
|
|
8059
|
-
className:
|
|
8453
|
+
className: getClassName26("root"),
|
|
8060
8454
|
style: {
|
|
8061
8455
|
width: iframe.enabled ? viewports.current.width : "100%",
|
|
8062
8456
|
height: zoomConfig.rootHeight,
|
|
8063
8457
|
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
|
8064
|
-
transition: showTransition ?
|
|
8458
|
+
transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, height ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : "",
|
|
8065
8459
|
overflow: iframe.enabled ? void 0 : "auto"
|
|
8066
8460
|
},
|
|
8067
8461
|
suppressHydrationWarning: true,
|
|
8068
8462
|
id: "puck-canvas-root",
|
|
8069
8463
|
onTransitionEnd: () => {
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
bubbles: true,
|
|
8073
|
-
cancelable: false
|
|
8074
|
-
})
|
|
8075
|
-
);
|
|
8464
|
+
setShowTransition(false);
|
|
8465
|
+
isResizingRef.current = false;
|
|
8076
8466
|
},
|
|
8077
|
-
children: /* @__PURE__ */ (0,
|
|
8467
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Preview2, {}) })
|
|
8078
8468
|
}
|
|
8079
8469
|
),
|
|
8080
|
-
/* @__PURE__ */ (0,
|
|
8470
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Loader, { size: 24 }) })
|
|
8081
8471
|
] })
|
|
8082
8472
|
]
|
|
8083
8473
|
}
|
|
@@ -8086,7 +8476,7 @@ var Canvas = () => {
|
|
|
8086
8476
|
|
|
8087
8477
|
// lib/use-loaded-overrides.ts
|
|
8088
8478
|
init_react_import();
|
|
8089
|
-
var
|
|
8479
|
+
var import_react52 = require("react");
|
|
8090
8480
|
|
|
8091
8481
|
// lib/load-overrides.ts
|
|
8092
8482
|
init_react_import();
|
|
@@ -8096,8 +8486,11 @@ var loadOverrides = ({
|
|
|
8096
8486
|
}) => {
|
|
8097
8487
|
const collected = __spreadValues({}, overrides);
|
|
8098
8488
|
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
8489
|
+
if (!plugin.overrides) return;
|
|
8099
8490
|
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
|
8491
|
+
var _a;
|
|
8100
8492
|
const overridesType = _overridesType;
|
|
8493
|
+
if (!((_a = plugin.overrides) == null ? void 0 : _a[overridesType])) return;
|
|
8101
8494
|
if (overridesType === "fieldTypes") {
|
|
8102
8495
|
const fieldTypes = plugin.overrides.fieldTypes;
|
|
8103
8496
|
Object.keys(fieldTypes).forEach((fieldType) => {
|
|
@@ -8125,26 +8518,26 @@ var useLoadedOverrides = ({
|
|
|
8125
8518
|
overrides,
|
|
8126
8519
|
plugins
|
|
8127
8520
|
}) => {
|
|
8128
|
-
return (0,
|
|
8521
|
+
return (0, import_react52.useMemo)(() => {
|
|
8129
8522
|
return loadOverrides({ overrides, plugins });
|
|
8130
8523
|
}, [plugins, overrides]);
|
|
8131
8524
|
};
|
|
8132
8525
|
|
|
8133
8526
|
// components/DefaultOverride/index.tsx
|
|
8134
8527
|
init_react_import();
|
|
8135
|
-
var
|
|
8136
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
|
8528
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
8529
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children });
|
|
8137
8530
|
|
|
8138
8531
|
// lib/use-inject-css.ts
|
|
8139
8532
|
init_react_import();
|
|
8140
|
-
var
|
|
8533
|
+
var import_react53 = require("react");
|
|
8141
8534
|
var styles = ``;
|
|
8142
8535
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
8143
|
-
const [el, setEl] = (0,
|
|
8144
|
-
(0,
|
|
8536
|
+
const [el, setEl] = (0, import_react53.useState)();
|
|
8537
|
+
(0, import_react53.useEffect)(() => {
|
|
8145
8538
|
setEl(document.createElement("style"));
|
|
8146
8539
|
}, []);
|
|
8147
|
-
(0,
|
|
8540
|
+
(0, import_react53.useEffect)(() => {
|
|
8148
8541
|
var _a;
|
|
8149
8542
|
if (!el || typeof window === "undefined") {
|
|
8150
8543
|
return;
|
|
@@ -8164,10 +8557,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
8164
8557
|
|
|
8165
8558
|
// lib/use-preview-mode-hotkeys.ts
|
|
8166
8559
|
init_react_import();
|
|
8167
|
-
var
|
|
8560
|
+
var import_react54 = require("react");
|
|
8168
8561
|
var usePreviewModeHotkeys = () => {
|
|
8169
8562
|
const appStore = useAppStoreApi();
|
|
8170
|
-
const toggleInteractive = (0,
|
|
8563
|
+
const toggleInteractive = (0, import_react54.useCallback)(() => {
|
|
8171
8564
|
const dispatch = appStore.getState().dispatch;
|
|
8172
8565
|
dispatch({
|
|
8173
8566
|
type: "setUi",
|
|
@@ -8182,7 +8575,7 @@ var usePreviewModeHotkeys = () => {
|
|
|
8182
8575
|
|
|
8183
8576
|
// lib/use-puck.ts
|
|
8184
8577
|
init_react_import();
|
|
8185
|
-
var
|
|
8578
|
+
var import_react55 = require("react");
|
|
8186
8579
|
var import_zustand6 = require("zustand");
|
|
8187
8580
|
var generateUsePuck = (store) => {
|
|
8188
8581
|
const history = {
|
|
@@ -8205,17 +8598,11 @@ var generateUsePuck = (store) => {
|
|
|
8205
8598
|
selectedItem: store.selectedItem || null,
|
|
8206
8599
|
getItemBySelector: (selector) => getItem(selector, store.state),
|
|
8207
8600
|
getItemById: (id) => store.state.indexes.nodes[id].data,
|
|
8208
|
-
getSelectorForId: (id) =>
|
|
8209
|
-
const node = store.state.indexes.nodes[id];
|
|
8210
|
-
if (!node) return;
|
|
8211
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
8212
|
-
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
|
8213
|
-
return { zone: zoneCompound, index };
|
|
8214
|
-
}
|
|
8601
|
+
getSelectorForId: (id) => getSelectorForId(store.state, id)
|
|
8215
8602
|
};
|
|
8216
8603
|
return storeData;
|
|
8217
8604
|
};
|
|
8218
|
-
var UsePuckStoreContext = (0,
|
|
8605
|
+
var UsePuckStoreContext = (0, import_react55.createContext)(
|
|
8219
8606
|
null
|
|
8220
8607
|
);
|
|
8221
8608
|
var convertToPickedStore = (store) => {
|
|
@@ -8229,12 +8616,12 @@ var convertToPickedStore = (store) => {
|
|
|
8229
8616
|
};
|
|
8230
8617
|
};
|
|
8231
8618
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8232
|
-
const [usePuckStore] = (0,
|
|
8619
|
+
const [usePuckStore] = (0, import_react55.useState)(
|
|
8233
8620
|
() => (0, import_zustand6.createStore)(
|
|
8234
8621
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8235
8622
|
)
|
|
8236
8623
|
);
|
|
8237
|
-
(0,
|
|
8624
|
+
(0, import_react55.useEffect)(() => {
|
|
8238
8625
|
return appStore.subscribe(
|
|
8239
8626
|
(store) => convertToPickedStore(store),
|
|
8240
8627
|
(pickedStore) => {
|
|
@@ -8246,7 +8633,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8246
8633
|
};
|
|
8247
8634
|
function createUsePuck() {
|
|
8248
8635
|
return function usePuck2(selector) {
|
|
8249
|
-
const usePuckApi = (0,
|
|
8636
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8250
8637
|
if (!usePuckApi) {
|
|
8251
8638
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8252
8639
|
}
|
|
@@ -8258,7 +8645,7 @@ function createUsePuck() {
|
|
|
8258
8645
|
};
|
|
8259
8646
|
}
|
|
8260
8647
|
function usePuck() {
|
|
8261
|
-
(0,
|
|
8648
|
+
(0, import_react55.useEffect)(() => {
|
|
8262
8649
|
console.warn(
|
|
8263
8650
|
"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
8651
|
);
|
|
@@ -8266,7 +8653,7 @@ function usePuck() {
|
|
|
8266
8653
|
return createUsePuck()((s) => s);
|
|
8267
8654
|
}
|
|
8268
8655
|
function useGetPuck() {
|
|
8269
|
-
const usePuckApi = (0,
|
|
8656
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8270
8657
|
if (!usePuckApi) {
|
|
8271
8658
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8272
8659
|
}
|
|
@@ -8278,18 +8665,18 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8278
8665
|
|
|
8279
8666
|
// components/Puck/components/Header/index.tsx
|
|
8280
8667
|
init_react_import();
|
|
8281
|
-
var
|
|
8668
|
+
var import_react56 = require("react");
|
|
8282
8669
|
|
|
8283
8670
|
// components/MenuBar/index.tsx
|
|
8284
8671
|
init_react_import();
|
|
8285
8672
|
|
|
8286
8673
|
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
|
8287
8674
|
init_react_import();
|
|
8288
|
-
var
|
|
8675
|
+
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
8676
|
|
|
8290
8677
|
// components/MenuBar/index.tsx
|
|
8291
|
-
var
|
|
8292
|
-
var
|
|
8678
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
8679
|
+
var getClassName27 = get_class_name_factory_default("MenuBar", styles_module_default22);
|
|
8293
8680
|
function MenuBar({
|
|
8294
8681
|
menuOpen = false,
|
|
8295
8682
|
renderHeaderActions,
|
|
@@ -8299,10 +8686,10 @@ function MenuBar({
|
|
|
8299
8686
|
const forward = useAppStore((s) => s.history.forward);
|
|
8300
8687
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
8301
8688
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
8302
|
-
return /* @__PURE__ */ (0,
|
|
8689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8303
8690
|
"div",
|
|
8304
8691
|
{
|
|
8305
|
-
className:
|
|
8692
|
+
className: getClassName27({ menuOpen }),
|
|
8306
8693
|
onClick: (event) => {
|
|
8307
8694
|
var _a;
|
|
8308
8695
|
const element = event.target;
|
|
@@ -8313,30 +8700,30 @@ function MenuBar({
|
|
|
8313
8700
|
setMenuOpen(false);
|
|
8314
8701
|
}
|
|
8315
8702
|
},
|
|
8316
|
-
children: /* @__PURE__ */ (0,
|
|
8317
|
-
/* @__PURE__ */ (0,
|
|
8318
|
-
/* @__PURE__ */ (0,
|
|
8703
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("inner"), children: [
|
|
8704
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("history"), children: [
|
|
8705
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8319
8706
|
IconButton,
|
|
8320
8707
|
{
|
|
8321
8708
|
type: "button",
|
|
8322
8709
|
title: "undo",
|
|
8323
8710
|
disabled: !hasPast,
|
|
8324
8711
|
onClick: back,
|
|
8325
|
-
children: /* @__PURE__ */ (0,
|
|
8712
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Undo2, { size: 21 })
|
|
8326
8713
|
}
|
|
8327
8714
|
),
|
|
8328
|
-
/* @__PURE__ */ (0,
|
|
8715
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8329
8716
|
IconButton,
|
|
8330
8717
|
{
|
|
8331
8718
|
type: "button",
|
|
8332
8719
|
title: "redo",
|
|
8333
8720
|
disabled: !hasFuture,
|
|
8334
8721
|
onClick: forward,
|
|
8335
|
-
children: /* @__PURE__ */ (0,
|
|
8722
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Redo2, { size: 21 })
|
|
8336
8723
|
}
|
|
8337
8724
|
)
|
|
8338
8725
|
] }),
|
|
8339
|
-
/* @__PURE__ */ (0,
|
|
8726
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
|
8340
8727
|
] })
|
|
8341
8728
|
}
|
|
8342
8729
|
);
|
|
@@ -8344,11 +8731,11 @@ function MenuBar({
|
|
|
8344
8731
|
|
|
8345
8732
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
|
8346
8733
|
init_react_import();
|
|
8347
|
-
var
|
|
8734
|
+
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
8735
|
|
|
8349
8736
|
// components/Puck/components/Header/index.tsx
|
|
8350
|
-
var
|
|
8351
|
-
var
|
|
8737
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
8738
|
+
var getClassName28 = get_class_name_factory_default("PuckHeader", styles_module_default23);
|
|
8352
8739
|
var HeaderInner = () => {
|
|
8353
8740
|
const {
|
|
8354
8741
|
onPublish,
|
|
@@ -8360,7 +8747,7 @@ var HeaderInner = () => {
|
|
|
8360
8747
|
} = usePropsContext();
|
|
8361
8748
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8362
8749
|
const appStore = useAppStoreApi();
|
|
8363
|
-
const defaultHeaderRender = (0,
|
|
8750
|
+
const defaultHeaderRender = (0, import_react56.useMemo)(() => {
|
|
8364
8751
|
if (renderHeader) {
|
|
8365
8752
|
console.warn(
|
|
8366
8753
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8369,13 +8756,13 @@ var HeaderInner = () => {
|
|
|
8369
8756
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
8370
8757
|
const Comp = renderHeader;
|
|
8371
8758
|
const appState = useAppStore((s) => s.state);
|
|
8372
|
-
return /* @__PURE__ */ (0,
|
|
8759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
8373
8760
|
};
|
|
8374
8761
|
return RenderHeader;
|
|
8375
8762
|
}
|
|
8376
8763
|
return DefaultOverride;
|
|
8377
8764
|
}, [renderHeader]);
|
|
8378
|
-
const defaultHeaderActionsRender = (0,
|
|
8765
|
+
const defaultHeaderActionsRender = (0, import_react56.useMemo)(() => {
|
|
8379
8766
|
if (renderHeaderActions) {
|
|
8380
8767
|
console.warn(
|
|
8381
8768
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8383,19 +8770,19 @@ var HeaderInner = () => {
|
|
|
8383
8770
|
const RenderHeader = (props) => {
|
|
8384
8771
|
const Comp = renderHeaderActions;
|
|
8385
8772
|
const appState = useAppStore((s) => s.state);
|
|
8386
|
-
return /* @__PURE__ */ (0,
|
|
8773
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
8387
8774
|
};
|
|
8388
8775
|
return RenderHeader;
|
|
8389
8776
|
}
|
|
8390
8777
|
return DefaultOverride;
|
|
8391
|
-
}, [
|
|
8778
|
+
}, [renderHeaderActions]);
|
|
8392
8779
|
const CustomHeader = useAppStore(
|
|
8393
8780
|
(s) => s.overrides.header || defaultHeaderRender
|
|
8394
8781
|
);
|
|
8395
8782
|
const CustomHeaderActions = useAppStore(
|
|
8396
8783
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8397
8784
|
);
|
|
8398
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8785
|
+
const [menuOpen, setMenuOpen] = (0, import_react56.useState)(false);
|
|
8399
8786
|
const rootTitle = useAppStore((s) => {
|
|
8400
8787
|
var _a, _b;
|
|
8401
8788
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8405,7 +8792,7 @@ var HeaderInner = () => {
|
|
|
8405
8792
|
const rightSideBarVisible = useAppStore(
|
|
8406
8793
|
(s) => s.state.ui.rightSideBarVisible
|
|
8407
8794
|
);
|
|
8408
|
-
const toggleSidebars = (0,
|
|
8795
|
+
const toggleSidebars = (0, import_react56.useCallback)(
|
|
8409
8796
|
(sidebar) => {
|
|
8410
8797
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8411
8798
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8419,27 +8806,27 @@ var HeaderInner = () => {
|
|
|
8419
8806
|
},
|
|
8420
8807
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
8421
8808
|
);
|
|
8422
|
-
return /* @__PURE__ */ (0,
|
|
8809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8423
8810
|
CustomHeader,
|
|
8424
8811
|
{
|
|
8425
|
-
actions: /* @__PURE__ */ (0,
|
|
8812
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_jsx_runtime43.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8426
8813
|
Button,
|
|
8427
8814
|
{
|
|
8428
8815
|
onClick: () => {
|
|
8429
8816
|
const data = appStore.getState().state.data;
|
|
8430
8817
|
onPublish && onPublish(data);
|
|
8431
8818
|
},
|
|
8432
|
-
icon: /* @__PURE__ */ (0,
|
|
8819
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Globe, { size: "14px" }),
|
|
8433
8820
|
children: "Publish"
|
|
8434
8821
|
}
|
|
8435
8822
|
) }) }),
|
|
8436
|
-
children: /* @__PURE__ */ (0,
|
|
8823
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8437
8824
|
"header",
|
|
8438
8825
|
{
|
|
8439
|
-
className:
|
|
8440
|
-
children: /* @__PURE__ */ (0,
|
|
8441
|
-
/* @__PURE__ */ (0,
|
|
8442
|
-
/* @__PURE__ */ (0,
|
|
8826
|
+
className: getClassName28({ leftSideBarVisible, rightSideBarVisible }),
|
|
8827
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName28("inner"), children: [
|
|
8828
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName28("toggle"), children: [
|
|
8829
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName28("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8443
8830
|
IconButton,
|
|
8444
8831
|
{
|
|
8445
8832
|
type: "button",
|
|
@@ -8447,10 +8834,10 @@ var HeaderInner = () => {
|
|
|
8447
8834
|
toggleSidebars("left");
|
|
8448
8835
|
},
|
|
8449
8836
|
title: "Toggle left sidebar",
|
|
8450
|
-
children: /* @__PURE__ */ (0,
|
|
8837
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PanelLeft, { focusable: "false" })
|
|
8451
8838
|
}
|
|
8452
8839
|
) }),
|
|
8453
|
-
/* @__PURE__ */ (0,
|
|
8840
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName28("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8454
8841
|
IconButton,
|
|
8455
8842
|
{
|
|
8456
8843
|
type: "button",
|
|
@@ -8458,19 +8845,19 @@ var HeaderInner = () => {
|
|
|
8458
8845
|
toggleSidebars("right");
|
|
8459
8846
|
},
|
|
8460
8847
|
title: "Toggle right sidebar",
|
|
8461
|
-
children: /* @__PURE__ */ (0,
|
|
8848
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PanelRight, { focusable: "false" })
|
|
8462
8849
|
}
|
|
8463
8850
|
) })
|
|
8464
8851
|
] }),
|
|
8465
|
-
/* @__PURE__ */ (0,
|
|
8852
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName28("title"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
|
8466
8853
|
headerTitle || rootTitle || "Page",
|
|
8467
|
-
headerPath && /* @__PURE__ */ (0,
|
|
8854
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
|
|
8468
8855
|
" ",
|
|
8469
|
-
/* @__PURE__ */ (0,
|
|
8856
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("code", { className: getClassName28("path"), children: headerPath })
|
|
8470
8857
|
] })
|
|
8471
8858
|
] }) }),
|
|
8472
|
-
/* @__PURE__ */ (0,
|
|
8473
|
-
/* @__PURE__ */ (0,
|
|
8859
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName28("tools"), children: [
|
|
8860
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName28("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8474
8861
|
IconButton,
|
|
8475
8862
|
{
|
|
8476
8863
|
type: "button",
|
|
@@ -8478,23 +8865,23 @@ var HeaderInner = () => {
|
|
|
8478
8865
|
return setMenuOpen(!menuOpen);
|
|
8479
8866
|
},
|
|
8480
8867
|
title: "Toggle menu bar",
|
|
8481
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
|
8868
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ChevronDown, { focusable: "false" })
|
|
8482
8869
|
}
|
|
8483
8870
|
) }),
|
|
8484
|
-
/* @__PURE__ */ (0,
|
|
8871
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8485
8872
|
MenuBar,
|
|
8486
8873
|
{
|
|
8487
8874
|
dispatch,
|
|
8488
8875
|
onPublish,
|
|
8489
8876
|
menuOpen,
|
|
8490
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
|
8877
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8491
8878
|
Button,
|
|
8492
8879
|
{
|
|
8493
8880
|
onClick: () => {
|
|
8494
8881
|
const data = appStore.getState().state.data;
|
|
8495
8882
|
onPublish && onPublish(data);
|
|
8496
8883
|
},
|
|
8497
|
-
icon: /* @__PURE__ */ (0,
|
|
8884
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Globe, { size: "14px" }),
|
|
8498
8885
|
children: "Publish"
|
|
8499
8886
|
}
|
|
8500
8887
|
) }),
|
|
@@ -8508,12 +8895,204 @@ var HeaderInner = () => {
|
|
|
8508
8895
|
}
|
|
8509
8896
|
);
|
|
8510
8897
|
};
|
|
8511
|
-
var Header = (0,
|
|
8898
|
+
var Header = (0, import_react56.memo)(HeaderInner);
|
|
8899
|
+
|
|
8900
|
+
// components/Puck/components/Sidebar/index.tsx
|
|
8901
|
+
init_react_import();
|
|
8902
|
+
|
|
8903
|
+
// components/Puck/components/ResizeHandle/index.tsx
|
|
8904
|
+
init_react_import();
|
|
8905
|
+
var import_react57 = require("react");
|
|
8906
|
+
|
|
8907
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
8908
|
+
init_react_import();
|
|
8909
|
+
var styles_module_default24 = { "ResizeHandle": "_ResizeHandle_144bf_2", "ResizeHandle--left": "_ResizeHandle--left_144bf_16", "ResizeHandle--right": "_ResizeHandle--right_144bf_20" };
|
|
8910
|
+
|
|
8911
|
+
// components/Puck/components/ResizeHandle/index.tsx
|
|
8912
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8913
|
+
var getClassName29 = get_class_name_factory_default("ResizeHandle", styles_module_default24);
|
|
8914
|
+
var ResizeHandle = ({
|
|
8915
|
+
position,
|
|
8916
|
+
sidebarRef,
|
|
8917
|
+
onResize,
|
|
8918
|
+
onResizeEnd
|
|
8919
|
+
}) => {
|
|
8920
|
+
const { frameRef } = useCanvasFrame();
|
|
8921
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
8922
|
+
const handleRef = (0, import_react57.useRef)(null);
|
|
8923
|
+
const isDragging = (0, import_react57.useRef)(false);
|
|
8924
|
+
const startX = (0, import_react57.useRef)(0);
|
|
8925
|
+
const startWidth = (0, import_react57.useRef)(0);
|
|
8926
|
+
const handleMouseMove = (0, import_react57.useCallback)(
|
|
8927
|
+
(e) => {
|
|
8928
|
+
if (!isDragging.current) return;
|
|
8929
|
+
const delta = e.clientX - startX.current;
|
|
8930
|
+
const newWidth = position === "left" ? startWidth.current + delta : startWidth.current - delta;
|
|
8931
|
+
const width = Math.max(192, newWidth);
|
|
8932
|
+
onResize(width);
|
|
8933
|
+
e.preventDefault();
|
|
8934
|
+
},
|
|
8935
|
+
[onResize, position]
|
|
8936
|
+
);
|
|
8937
|
+
const handleMouseUp = (0, import_react57.useCallback)(() => {
|
|
8938
|
+
var _a;
|
|
8939
|
+
if (!isDragging.current) return;
|
|
8940
|
+
isDragging.current = false;
|
|
8941
|
+
document.body.style.cursor = "";
|
|
8942
|
+
document.body.style.userSelect = "";
|
|
8943
|
+
const overlay = document.getElementById("resize-overlay");
|
|
8944
|
+
if (overlay) {
|
|
8945
|
+
document.body.removeChild(overlay);
|
|
8946
|
+
}
|
|
8947
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
8948
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
8949
|
+
const finalWidth = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
8950
|
+
onResizeEnd(finalWidth);
|
|
8951
|
+
resetAutoZoom();
|
|
8952
|
+
}, [onResizeEnd]);
|
|
8953
|
+
const handleMouseDown = (0, import_react57.useCallback)(
|
|
8954
|
+
(e) => {
|
|
8955
|
+
var _a;
|
|
8956
|
+
isDragging.current = true;
|
|
8957
|
+
startX.current = e.clientX;
|
|
8958
|
+
startWidth.current = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
8959
|
+
document.body.style.cursor = "col-resize";
|
|
8960
|
+
document.body.style.userSelect = "none";
|
|
8961
|
+
const overlay = document.createElement("div");
|
|
8962
|
+
overlay.id = "resize-overlay";
|
|
8963
|
+
overlay.setAttribute("data-resize-overlay", "");
|
|
8964
|
+
document.body.appendChild(overlay);
|
|
8965
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
8966
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
8967
|
+
e.preventDefault();
|
|
8968
|
+
},
|
|
8969
|
+
[position, handleMouseMove, handleMouseUp]
|
|
8970
|
+
);
|
|
8971
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8972
|
+
"div",
|
|
8973
|
+
{
|
|
8974
|
+
ref: handleRef,
|
|
8975
|
+
className: getClassName29({ [position]: true }),
|
|
8976
|
+
onMouseDown: handleMouseDown
|
|
8977
|
+
}
|
|
8978
|
+
);
|
|
8979
|
+
};
|
|
8980
|
+
|
|
8981
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Sidebar/styles.module.css#css-module
|
|
8982
|
+
init_react_import();
|
|
8983
|
+
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" };
|
|
8984
|
+
|
|
8985
|
+
// components/Puck/components/Sidebar/index.tsx
|
|
8986
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
8987
|
+
var getClassName30 = get_class_name_factory_default("Sidebar", styles_module_default25);
|
|
8988
|
+
var Sidebar = ({
|
|
8989
|
+
position,
|
|
8990
|
+
sidebarRef,
|
|
8991
|
+
isVisible,
|
|
8992
|
+
onResize,
|
|
8993
|
+
onResizeEnd,
|
|
8994
|
+
children
|
|
8995
|
+
}) => {
|
|
8996
|
+
if (!isVisible) return null;
|
|
8997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
|
|
8998
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ref: sidebarRef, className: getClassName30({ [position]: true }), children }),
|
|
8999
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: `${getClassName30("resizeHandle")}`, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
9000
|
+
ResizeHandle,
|
|
9001
|
+
{
|
|
9002
|
+
position,
|
|
9003
|
+
sidebarRef,
|
|
9004
|
+
onResize,
|
|
9005
|
+
onResizeEnd
|
|
9006
|
+
}
|
|
9007
|
+
) })
|
|
9008
|
+
] });
|
|
9009
|
+
};
|
|
9010
|
+
|
|
9011
|
+
// lib/use-sidebar-resize.ts
|
|
9012
|
+
init_react_import();
|
|
9013
|
+
var import_react58 = require("react");
|
|
9014
|
+
function useSidebarResize(position, dispatch) {
|
|
9015
|
+
const [width, setWidth] = (0, import_react58.useState)(null);
|
|
9016
|
+
const sidebarRef = (0, import_react58.useRef)(null);
|
|
9017
|
+
const storeWidth = useAppStore(
|
|
9018
|
+
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
9019
|
+
);
|
|
9020
|
+
(0, import_react58.useEffect)(() => {
|
|
9021
|
+
if (typeof window !== "undefined" && !storeWidth) {
|
|
9022
|
+
try {
|
|
9023
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
9024
|
+
if (savedWidths) {
|
|
9025
|
+
const widths = JSON.parse(savedWidths);
|
|
9026
|
+
const savedWidth = widths[position];
|
|
9027
|
+
const key = position === "left" ? "leftSideBarWidth" : "rightSideBarWidth";
|
|
9028
|
+
if (savedWidth) {
|
|
9029
|
+
dispatch({
|
|
9030
|
+
type: "setUi",
|
|
9031
|
+
ui: {
|
|
9032
|
+
[key]: savedWidth
|
|
9033
|
+
}
|
|
9034
|
+
});
|
|
9035
|
+
}
|
|
9036
|
+
}
|
|
9037
|
+
} catch (error) {
|
|
9038
|
+
console.error(
|
|
9039
|
+
`Failed to load ${position} sidebar width from localStorage`,
|
|
9040
|
+
error
|
|
9041
|
+
);
|
|
9042
|
+
}
|
|
9043
|
+
}
|
|
9044
|
+
}, [dispatch, position, storeWidth]);
|
|
9045
|
+
(0, import_react58.useEffect)(() => {
|
|
9046
|
+
if (storeWidth !== void 0) {
|
|
9047
|
+
setWidth(storeWidth);
|
|
9048
|
+
}
|
|
9049
|
+
}, [storeWidth]);
|
|
9050
|
+
const handleResizeEnd = (0, import_react58.useCallback)(
|
|
9051
|
+
(width2) => {
|
|
9052
|
+
dispatch({
|
|
9053
|
+
type: "setUi",
|
|
9054
|
+
ui: {
|
|
9055
|
+
[position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: width2
|
|
9056
|
+
}
|
|
9057
|
+
});
|
|
9058
|
+
let widths = {};
|
|
9059
|
+
try {
|
|
9060
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
9061
|
+
widths = savedWidths ? JSON.parse(savedWidths) : {};
|
|
9062
|
+
} catch (error) {
|
|
9063
|
+
console.error(
|
|
9064
|
+
`Failed to save ${position} sidebar width to localStorage`,
|
|
9065
|
+
error
|
|
9066
|
+
);
|
|
9067
|
+
} finally {
|
|
9068
|
+
localStorage.setItem(
|
|
9069
|
+
"puck-sidebar-widths",
|
|
9070
|
+
JSON.stringify(__spreadProps(__spreadValues({}, widths), {
|
|
9071
|
+
[position]: width2
|
|
9072
|
+
}))
|
|
9073
|
+
);
|
|
9074
|
+
}
|
|
9075
|
+
window.dispatchEvent(
|
|
9076
|
+
new CustomEvent("viewportchange", {
|
|
9077
|
+
bubbles: true,
|
|
9078
|
+
cancelable: false
|
|
9079
|
+
})
|
|
9080
|
+
);
|
|
9081
|
+
},
|
|
9082
|
+
[dispatch, position]
|
|
9083
|
+
);
|
|
9084
|
+
return {
|
|
9085
|
+
width,
|
|
9086
|
+
setWidth,
|
|
9087
|
+
sidebarRef,
|
|
9088
|
+
handleResizeEnd
|
|
9089
|
+
};
|
|
9090
|
+
}
|
|
8512
9091
|
|
|
8513
9092
|
// components/Puck/index.tsx
|
|
8514
|
-
var
|
|
8515
|
-
var
|
|
8516
|
-
var getLayoutClassName = get_class_name_factory_default("PuckLayout",
|
|
9093
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
9094
|
+
var getClassName31 = get_class_name_factory_default("Puck", styles_module_default15);
|
|
9095
|
+
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
|
8517
9096
|
var FieldSideBar = () => {
|
|
8518
9097
|
const title = useAppStore(
|
|
8519
9098
|
(s) => {
|
|
@@ -8521,13 +9100,13 @@ var FieldSideBar = () => {
|
|
|
8521
9100
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
8522
9101
|
}
|
|
8523
9102
|
);
|
|
8524
|
-
return /* @__PURE__ */ (0,
|
|
9103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Fields, {}) });
|
|
8525
9104
|
};
|
|
8526
|
-
var propsContext = (0,
|
|
9105
|
+
var propsContext = (0, import_react59.createContext)({});
|
|
8527
9106
|
function PropsProvider(props) {
|
|
8528
|
-
return /* @__PURE__ */ (0,
|
|
9107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
8529
9108
|
}
|
|
8530
|
-
var usePropsContext = () => (0,
|
|
9109
|
+
var usePropsContext = () => (0, import_react59.useContext)(propsContext);
|
|
8531
9110
|
function PuckProvider({ children }) {
|
|
8532
9111
|
const {
|
|
8533
9112
|
config,
|
|
@@ -8541,16 +9120,17 @@ function PuckProvider({ children }) {
|
|
|
8541
9120
|
iframe: _iframe,
|
|
8542
9121
|
initialHistory: _initialHistory,
|
|
8543
9122
|
metadata,
|
|
8544
|
-
onAction
|
|
9123
|
+
onAction,
|
|
9124
|
+
fieldTransforms
|
|
8545
9125
|
} = usePropsContext();
|
|
8546
|
-
const iframe = (0,
|
|
9126
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8547
9127
|
() => __spreadValues({
|
|
8548
9128
|
enabled: true,
|
|
8549
9129
|
waitForStyles: true
|
|
8550
9130
|
}, _iframe),
|
|
8551
9131
|
[_iframe]
|
|
8552
9132
|
);
|
|
8553
|
-
const [generatedAppState] = (0,
|
|
9133
|
+
const [generatedAppState] = (0, import_react59.useState)(() => {
|
|
8554
9134
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8555
9135
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8556
9136
|
let clientUiState = {};
|
|
@@ -8579,7 +9159,7 @@ function PuckProvider({ children }) {
|
|
|
8579
9159
|
}
|
|
8580
9160
|
}
|
|
8581
9161
|
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.
|
|
9162
|
+
console.warn(
|
|
8583
9163
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
|
8584
9164
|
);
|
|
8585
9165
|
}
|
|
@@ -8610,7 +9190,7 @@ function PuckProvider({ children }) {
|
|
|
8610
9190
|
return walkAppState(newAppState, config);
|
|
8611
9191
|
});
|
|
8612
9192
|
const { appendData = true } = _initialHistory || {};
|
|
8613
|
-
const [blendedHistories] = (0,
|
|
9193
|
+
const [blendedHistories] = (0, import_react59.useState)(
|
|
8614
9194
|
[
|
|
8615
9195
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8616
9196
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8630,7 +9210,15 @@ function PuckProvider({ children }) {
|
|
|
8630
9210
|
overrides,
|
|
8631
9211
|
plugins
|
|
8632
9212
|
});
|
|
8633
|
-
const
|
|
9213
|
+
const loadedFieldTransforms = (0, import_react59.useMemo)(() => {
|
|
9214
|
+
const _plugins = plugins || [];
|
|
9215
|
+
const pluginFieldTransforms = _plugins.reduce(
|
|
9216
|
+
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
9217
|
+
{}
|
|
9218
|
+
);
|
|
9219
|
+
return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
|
|
9220
|
+
}, [fieldTransforms, plugins]);
|
|
9221
|
+
const generateAppStore = (0, import_react59.useCallback)(
|
|
8634
9222
|
(state) => {
|
|
8635
9223
|
return {
|
|
8636
9224
|
state,
|
|
@@ -8640,7 +9228,8 @@ function PuckProvider({ children }) {
|
|
|
8640
9228
|
viewports,
|
|
8641
9229
|
iframe,
|
|
8642
9230
|
onAction,
|
|
8643
|
-
metadata
|
|
9231
|
+
metadata,
|
|
9232
|
+
fieldTransforms: loadedFieldTransforms
|
|
8644
9233
|
};
|
|
8645
9234
|
},
|
|
8646
9235
|
[
|
|
@@ -8651,18 +9240,19 @@ function PuckProvider({ children }) {
|
|
|
8651
9240
|
viewports,
|
|
8652
9241
|
iframe,
|
|
8653
9242
|
onAction,
|
|
8654
|
-
metadata
|
|
9243
|
+
metadata,
|
|
9244
|
+
loadedFieldTransforms
|
|
8655
9245
|
]
|
|
8656
9246
|
);
|
|
8657
|
-
const [appStore] = (0,
|
|
9247
|
+
const [appStore] = (0, import_react59.useState)(
|
|
8658
9248
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8659
9249
|
);
|
|
8660
|
-
(0,
|
|
9250
|
+
(0, import_react59.useEffect)(() => {
|
|
8661
9251
|
if (process.env.NODE_ENV !== "production") {
|
|
8662
9252
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8663
9253
|
}
|
|
8664
9254
|
}, [appStore]);
|
|
8665
|
-
(0,
|
|
9255
|
+
(0, import_react59.useEffect)(() => {
|
|
8666
9256
|
const state = appStore.getState().state;
|
|
8667
9257
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8668
9258
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8671,8 +9261,8 @@ function PuckProvider({ children }) {
|
|
|
8671
9261
|
index: initialHistoryIndex,
|
|
8672
9262
|
initialAppState
|
|
8673
9263
|
});
|
|
8674
|
-
const previousData = (0,
|
|
8675
|
-
(0,
|
|
9264
|
+
const previousData = (0, import_react59.useRef)(null);
|
|
9265
|
+
(0, import_react59.useEffect)(() => {
|
|
8676
9266
|
appStore.subscribe(
|
|
8677
9267
|
(s) => s.state.data,
|
|
8678
9268
|
(data) => {
|
|
@@ -8686,11 +9276,11 @@ function PuckProvider({ children }) {
|
|
|
8686
9276
|
}, []);
|
|
8687
9277
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8688
9278
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8689
|
-
(0,
|
|
9279
|
+
(0, import_react59.useEffect)(() => {
|
|
8690
9280
|
const { resolveAndCommitData } = appStore.getState();
|
|
8691
9281
|
resolveAndCommitData();
|
|
8692
9282
|
}, []);
|
|
8693
|
-
return /* @__PURE__ */ (0,
|
|
9283
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
|
8694
9284
|
}
|
|
8695
9285
|
function PuckLayout({ children }) {
|
|
8696
9286
|
const {
|
|
@@ -8698,7 +9288,7 @@ function PuckLayout({ children }) {
|
|
|
8698
9288
|
dnd,
|
|
8699
9289
|
initialHistory: _initialHistory
|
|
8700
9290
|
} = usePropsContext();
|
|
8701
|
-
const iframe = (0,
|
|
9291
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8702
9292
|
() => __spreadValues({
|
|
8703
9293
|
enabled: true,
|
|
8704
9294
|
waitForStyles: true
|
|
@@ -8706,12 +9296,24 @@ function PuckLayout({ children }) {
|
|
|
8706
9296
|
[_iframe]
|
|
8707
9297
|
);
|
|
8708
9298
|
useInjectGlobalCss(iframe.enabled);
|
|
9299
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
8709
9300
|
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
8710
9301
|
const rightSideBarVisible = useAppStore(
|
|
8711
9302
|
(s) => s.state.ui.rightSideBarVisible
|
|
8712
9303
|
);
|
|
8713
|
-
const
|
|
8714
|
-
|
|
9304
|
+
const {
|
|
9305
|
+
width: leftWidth,
|
|
9306
|
+
setWidth: setLeftWidth,
|
|
9307
|
+
sidebarRef: leftSidebarRef,
|
|
9308
|
+
handleResizeEnd: handleLeftSidebarResizeEnd
|
|
9309
|
+
} = useSidebarResize("left", dispatch);
|
|
9310
|
+
const {
|
|
9311
|
+
width: rightWidth,
|
|
9312
|
+
setWidth: setRightWidth,
|
|
9313
|
+
sidebarRef: rightSidebarRef,
|
|
9314
|
+
handleResizeEnd: handleRightSidebarResizeEnd
|
|
9315
|
+
} = useSidebarResize("right", dispatch);
|
|
9316
|
+
(0, import_react59.useEffect)(() => {
|
|
8715
9317
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8716
9318
|
dispatch({
|
|
8717
9319
|
type: "setUi",
|
|
@@ -8735,17 +9337,17 @@ function PuckLayout({ children }) {
|
|
|
8735
9337
|
};
|
|
8736
9338
|
}, []);
|
|
8737
9339
|
const overrides = useAppStore((s) => s.overrides);
|
|
8738
|
-
const CustomPuck = (0,
|
|
9340
|
+
const CustomPuck = (0, import_react59.useMemo)(
|
|
8739
9341
|
() => overrides.puck || DefaultOverride,
|
|
8740
9342
|
[overrides]
|
|
8741
9343
|
);
|
|
8742
|
-
const [mounted, setMounted] = (0,
|
|
8743
|
-
(0,
|
|
9344
|
+
const [mounted, setMounted] = (0, import_react59.useState)(false);
|
|
9345
|
+
(0, import_react59.useEffect)(() => {
|
|
8744
9346
|
setMounted(true);
|
|
8745
9347
|
}, []);
|
|
8746
9348
|
const ready = useAppStore((s) => s.status === "READY");
|
|
8747
9349
|
useMonitorHotkeys();
|
|
8748
|
-
(0,
|
|
9350
|
+
(0, import_react59.useEffect)(() => {
|
|
8749
9351
|
if (ready && iframe.enabled) {
|
|
8750
9352
|
const frameDoc = getFrame();
|
|
8751
9353
|
if (frameDoc) {
|
|
@@ -8754,8 +9356,15 @@ function PuckLayout({ children }) {
|
|
|
8754
9356
|
}
|
|
8755
9357
|
}, [ready, iframe.enabled]);
|
|
8756
9358
|
usePreviewModeHotkeys();
|
|
8757
|
-
|
|
8758
|
-
|
|
9359
|
+
const layoutOptions = {};
|
|
9360
|
+
if (leftWidth) {
|
|
9361
|
+
layoutOptions["--puck-user-left-side-bar-width"] = `${leftWidth}px`;
|
|
9362
|
+
}
|
|
9363
|
+
if (rightWidth) {
|
|
9364
|
+
layoutOptions["--puck-user-right-side-bar-width"] = `${rightWidth}px`;
|
|
9365
|
+
}
|
|
9366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: `Puck ${getClassName31()}`, children: [
|
|
9367
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(FrameProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
8759
9368
|
"div",
|
|
8760
9369
|
{
|
|
8761
9370
|
className: getLayoutClassName({
|
|
@@ -8763,22 +9372,49 @@ function PuckLayout({ children }) {
|
|
|
8763
9372
|
mounted,
|
|
8764
9373
|
rightSideBarVisible
|
|
8765
9374
|
}),
|
|
8766
|
-
children: /* @__PURE__ */ (0,
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
9375
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
9376
|
+
"div",
|
|
9377
|
+
{
|
|
9378
|
+
className: getLayoutClassName("inner"),
|
|
9379
|
+
style: layoutOptions,
|
|
9380
|
+
children: [
|
|
9381
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Header, {}),
|
|
9382
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
9383
|
+
Sidebar,
|
|
9384
|
+
{
|
|
9385
|
+
position: "left",
|
|
9386
|
+
sidebarRef: leftSidebarRef,
|
|
9387
|
+
isVisible: leftSideBarVisible,
|
|
9388
|
+
onResize: setLeftWidth,
|
|
9389
|
+
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
9390
|
+
children: [
|
|
9391
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Components, {}) }),
|
|
9392
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Outline, {}) })
|
|
9393
|
+
]
|
|
9394
|
+
}
|
|
9395
|
+
),
|
|
9396
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Canvas, {}),
|
|
9397
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
9398
|
+
Sidebar,
|
|
9399
|
+
{
|
|
9400
|
+
position: "right",
|
|
9401
|
+
sidebarRef: rightSidebarRef,
|
|
9402
|
+
isVisible: rightSideBarVisible,
|
|
9403
|
+
onResize: setRightWidth,
|
|
9404
|
+
onResizeEnd: handleRightSidebarResizeEnd,
|
|
9405
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(FieldSideBar, {})
|
|
9406
|
+
}
|
|
9407
|
+
)
|
|
9408
|
+
]
|
|
9409
|
+
}
|
|
9410
|
+
)
|
|
8775
9411
|
}
|
|
8776
|
-
) }) }),
|
|
8777
|
-
/* @__PURE__ */ (0,
|
|
9412
|
+
) }) }) }),
|
|
9413
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { id: "puck-portal-root", className: getClassName31("portal") })
|
|
8778
9414
|
] });
|
|
8779
9415
|
}
|
|
8780
9416
|
function Puck(props) {
|
|
8781
|
-
return /* @__PURE__ */ (0,
|
|
9417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
|
|
8782
9418
|
}
|
|
8783
9419
|
Puck.Components = Components;
|
|
8784
9420
|
Puck.Fields = Fields;
|
|
@@ -8977,9 +9613,9 @@ function resolveAllData(_0, _1) {
|
|
|
8977
9613
|
},
|
|
8978
9614
|
"force"
|
|
8979
9615
|
)).node;
|
|
8980
|
-
const resolvedDeep = yield
|
|
9616
|
+
const resolvedDeep = yield mapFields(
|
|
8981
9617
|
resolved,
|
|
8982
|
-
processContent,
|
|
9618
|
+
{ slot: ({ value }) => processContent(value) },
|
|
8983
9619
|
config
|
|
8984
9620
|
);
|
|
8985
9621
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
@@ -9025,8 +9661,10 @@ function resolveAllData(_0, _1) {
|
|
|
9025
9661
|
createUsePuck,
|
|
9026
9662
|
migrate,
|
|
9027
9663
|
overrideKeys,
|
|
9664
|
+
registerOverlayPortal,
|
|
9028
9665
|
renderContext,
|
|
9029
9666
|
resolveAllData,
|
|
9667
|
+
setDeep,
|
|
9030
9668
|
transformProps,
|
|
9031
9669
|
useGetPuck,
|
|
9032
9670
|
usePuck,
|