@measured/puck 0.16.0-canary.6d43ba0 → 0.16.0-canary.72b8720
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Config-XUGMjfT5.d.mts → actions-9pHbVtMU.d.mts} +217 -55
- package/dist/{Config-XUGMjfT5.d.ts → actions-9pHbVtMU.d.ts} +217 -55
- package/dist/{chunk-TM7CT64S.mjs → chunk-LM7YWFFF.mjs} +3 -2
- package/dist/index.css +96 -77
- package/dist/index.d.mts +51 -190
- package/dist/index.d.ts +51 -190
- package/dist/index.js +885 -697
- package/dist/index.mjs +855 -670
- package/dist/rsc.d.mts +1 -1
- package/dist/rsc.d.ts +1 -1
- package/dist/rsc.js +3 -2
- package/dist/rsc.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -156,11 +156,13 @@ __export(core_exports, {
|
|
156
156
|
DropZoneProvider: () => DropZoneProvider,
|
157
157
|
FieldLabel: () => FieldLabel,
|
158
158
|
FieldLabelInternal: () => FieldLabelInternal2,
|
159
|
+
Group: () => Group,
|
159
160
|
IconButton: () => IconButton,
|
160
161
|
Puck: () => Puck,
|
161
162
|
Render: () => Render,
|
162
163
|
dropZoneContext: () => dropZoneContext,
|
163
164
|
migrate: () => migrate,
|
165
|
+
overrideKeys: () => overrideKeys,
|
164
166
|
resolveAllData: () => resolveAllData,
|
165
167
|
transformProps: () => transformProps,
|
166
168
|
usePuck: () => usePuck
|
@@ -168,15 +170,47 @@ __export(core_exports, {
|
|
168
170
|
module.exports = __toCommonJS(core_exports);
|
169
171
|
init_react_import();
|
170
172
|
|
173
|
+
// types/API/index.ts
|
174
|
+
init_react_import();
|
175
|
+
|
176
|
+
// types/API/Viewports.ts
|
177
|
+
init_react_import();
|
178
|
+
|
179
|
+
// types/index.ts
|
180
|
+
init_react_import();
|
181
|
+
|
182
|
+
// types/API/Overrides.ts
|
183
|
+
init_react_import();
|
184
|
+
var overrideKeys = [
|
185
|
+
"header",
|
186
|
+
"headerActions",
|
187
|
+
"fields",
|
188
|
+
"fieldLabel",
|
189
|
+
"components",
|
190
|
+
"componentItem",
|
191
|
+
"outline",
|
192
|
+
"puck",
|
193
|
+
"preview"
|
194
|
+
];
|
195
|
+
|
196
|
+
// types/AppState.tsx
|
197
|
+
init_react_import();
|
198
|
+
|
171
199
|
// types/Config.tsx
|
172
200
|
init_react_import();
|
173
201
|
|
174
|
-
// types/
|
202
|
+
// types/Data.tsx
|
175
203
|
init_react_import();
|
176
204
|
|
177
205
|
// types/Fields.ts
|
178
206
|
init_react_import();
|
179
207
|
|
208
|
+
// types/Props.tsx
|
209
|
+
init_react_import();
|
210
|
+
|
211
|
+
// types/Utils.tsx
|
212
|
+
init_react_import();
|
213
|
+
|
180
214
|
// components/ActionBar/index.tsx
|
181
215
|
init_react_import();
|
182
216
|
|
@@ -209,11 +243,11 @@ var get_class_name_factory_default = getClassNameFactory;
|
|
209
243
|
|
210
244
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
|
211
245
|
init_react_import();
|
212
|
-
var styles_module_default = { "
|
246
|
+
var styles_module_default = { "ActionBar": "_ActionBar_fp58q_1", "ActionBar-actionsLabel": "_ActionBar-actionsLabel_fp58q_16", "ActionBar-group": "_ActionBar-group_fp58q_29", "ActionBar-action": "_ActionBar-action_fp58q_16" };
|
213
247
|
|
214
248
|
// components/ActionBar/index.tsx
|
215
249
|
var import_jsx_runtime = require("react/jsx-runtime");
|
216
|
-
var getClassName = get_class_name_factory_default("
|
250
|
+
var getClassName = get_class_name_factory_default("ActionBar", styles_module_default);
|
217
251
|
var ActionBar = ({
|
218
252
|
label,
|
219
253
|
children
|
@@ -225,8 +259,19 @@ var Action = ({
|
|
225
259
|
children,
|
226
260
|
label,
|
227
261
|
onClick
|
228
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
262
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
263
|
+
"button",
|
264
|
+
{
|
265
|
+
type: "button",
|
266
|
+
className: getClassName("action"),
|
267
|
+
onClick,
|
268
|
+
title: label,
|
269
|
+
children
|
270
|
+
}
|
271
|
+
);
|
272
|
+
var Group = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: getClassName("group"), children });
|
229
273
|
ActionBar.Action = Action;
|
274
|
+
ActionBar.Group = Group;
|
230
275
|
|
231
276
|
// components/AutoField/index.tsx
|
232
277
|
init_react_import();
|
@@ -236,7 +281,7 @@ init_react_import();
|
|
236
281
|
var styles_module_default2 = { "Input": "_Input_3pq3z_1", "Input-label": "_Input-label_3pq3z_26", "Input-labelIcon": "_Input-labelIcon_3pq3z_35", "Input-disabledIcon": "_Input-disabledIcon_3pq3z_42", "Input-input": "_Input-input_3pq3z_47", "Input--readOnly": "_Input--readOnly_3pq3z_91", "Input-radioGroupItems": "_Input-radioGroupItems_3pq3z_102", "Input-radio": "_Input-radio_3pq3z_102", "Input-radioInner": "_Input-radioInner_3pq3z_119", "Input-radioInput": "_Input-radioInput_3pq3z_164" };
|
237
282
|
|
238
283
|
// components/AutoField/index.tsx
|
239
|
-
var
|
284
|
+
var import_react13 = require("react");
|
240
285
|
|
241
286
|
// components/AutoField/fields/index.tsx
|
242
287
|
init_react_import();
|
@@ -644,7 +689,7 @@ var import_dnd = require("@measured/dnd");
|
|
644
689
|
|
645
690
|
// components/Puck/context.tsx
|
646
691
|
init_react_import();
|
647
|
-
var
|
692
|
+
var import_react6 = require("react");
|
648
693
|
|
649
694
|
// lib/get-item.ts
|
650
695
|
init_react_import();
|
@@ -659,21 +704,22 @@ var setupZone = (data, zoneKey) => {
|
|
659
704
|
if (zoneKey === rootDroppableId) {
|
660
705
|
return data;
|
661
706
|
}
|
662
|
-
const newData = __spreadValues({}, data)
|
663
|
-
|
707
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
708
|
+
zones: data.zones || {}
|
709
|
+
});
|
664
710
|
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
665
711
|
return newData;
|
666
712
|
};
|
667
713
|
|
668
714
|
// lib/get-item.ts
|
669
|
-
|
715
|
+
function getItem(selector, data, dynamicProps = {}) {
|
670
716
|
if (!selector.zone || selector.zone === rootDroppableId) {
|
671
717
|
const item2 = data.content[selector.index];
|
672
718
|
return (item2 == null ? void 0 : item2.props) ? __spreadProps(__spreadValues({}, item2), { props: dynamicProps[item2.props.id] || item2.props }) : void 0;
|
673
719
|
}
|
674
720
|
const item = setupZone(data, selector.zone).zones[selector.zone][selector.index];
|
675
721
|
return (item == null ? void 0 : item.props) ? __spreadProps(__spreadValues({}, item), { props: dynamicProps[item.props.id] || item.props }) : void 0;
|
676
|
-
}
|
722
|
+
}
|
677
723
|
|
678
724
|
// components/ViewportControls/default-viewports.ts
|
679
725
|
init_react_import();
|
@@ -685,6 +731,332 @@ var defaultViewports = [
|
|
685
731
|
|
686
732
|
// components/Puck/context.tsx
|
687
733
|
var import_ua_parser_js = require("ua-parser-js");
|
734
|
+
|
735
|
+
// lib/use-resolved-permissions.ts
|
736
|
+
init_react_import();
|
737
|
+
var import_react4 = require("react");
|
738
|
+
|
739
|
+
// lib/flatten-data.ts
|
740
|
+
init_react_import();
|
741
|
+
var flattenData = (data) => {
|
742
|
+
return Object.keys(data.zones || {}).reduce(
|
743
|
+
(acc, zone) => [...acc, ...data.zones[zone]],
|
744
|
+
data.content
|
745
|
+
);
|
746
|
+
};
|
747
|
+
|
748
|
+
// lib/get-changed.ts
|
749
|
+
init_react_import();
|
750
|
+
var getChanged = (newItem, oldItem) => {
|
751
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
752
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
753
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
754
|
+
return __spreadProps(__spreadValues({}, acc), {
|
755
|
+
[item]: oldItemProps[item] !== newItemProps[item]
|
756
|
+
});
|
757
|
+
}, {}) : {};
|
758
|
+
};
|
759
|
+
|
760
|
+
// lib/use-resolved-permissions.ts
|
761
|
+
var useResolvedPermissions = (config, appState, globalPermissions, setComponentLoading, unsetComponentLoading) => {
|
762
|
+
const [cache3, setCache] = (0, import_react4.useState)({});
|
763
|
+
const [resolvedPermissions, setResolvedPermissions] = (0, import_react4.useState)({});
|
764
|
+
const resolveDataForItem = (0, import_react4.useCallback)(
|
765
|
+
(item, force = false) => __async(void 0, null, function* () {
|
766
|
+
var _a, _b, _c;
|
767
|
+
setComponentLoading == null ? void 0 : setComponentLoading(item.props.id);
|
768
|
+
const componentConfig = item.type === "root" ? config.root : config.components[item.type];
|
769
|
+
if (!componentConfig) {
|
770
|
+
unsetComponentLoading == null ? void 0 : unsetComponentLoading(item.props.id);
|
771
|
+
return;
|
772
|
+
}
|
773
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
774
|
+
if (componentConfig.resolvePermissions) {
|
775
|
+
const changed = getChanged(item, (_a = cache3[item.props.id]) == null ? void 0 : _a.lastData);
|
776
|
+
if (Object.values(changed).some((el) => el === true) || force) {
|
777
|
+
const resolvedPermissions2 = yield componentConfig.resolvePermissions(
|
778
|
+
item,
|
779
|
+
{
|
780
|
+
changed,
|
781
|
+
lastPermissions: ((_b = cache3[item.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
782
|
+
permissions: initialPermissions,
|
783
|
+
appState,
|
784
|
+
lastData: ((_c = cache3[item.props.id]) == null ? void 0 : _c.lastData) || null
|
785
|
+
}
|
786
|
+
);
|
787
|
+
setCache((_cache) => __spreadProps(__spreadValues({}, _cache), {
|
788
|
+
[item.props.id]: {
|
789
|
+
lastData: item,
|
790
|
+
lastPermissions: resolvedPermissions2
|
791
|
+
}
|
792
|
+
}));
|
793
|
+
setResolvedPermissions((p) => __spreadProps(__spreadValues({}, p), {
|
794
|
+
[item.props.id]: resolvedPermissions2
|
795
|
+
}));
|
796
|
+
}
|
797
|
+
}
|
798
|
+
unsetComponentLoading == null ? void 0 : unsetComponentLoading(item.props.id);
|
799
|
+
}),
|
800
|
+
[config, globalPermissions, appState, cache3]
|
801
|
+
);
|
802
|
+
const resolveDataForRoot = (force = false) => {
|
803
|
+
resolveDataForItem(
|
804
|
+
// Shim the root data in by conforming to component data shape
|
805
|
+
{
|
806
|
+
type: "root",
|
807
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "puck-root" })
|
808
|
+
},
|
809
|
+
force
|
810
|
+
);
|
811
|
+
};
|
812
|
+
const resolvePermissions = (0, import_react4.useCallback)(
|
813
|
+
(..._0) => __async(void 0, [..._0], function* ({ item, type, root } = {}, force = false) {
|
814
|
+
if (item) {
|
815
|
+
yield resolveDataForItem(item, force);
|
816
|
+
} else if (type) {
|
817
|
+
flattenData(appState.data).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
|
818
|
+
yield resolveDataForItem(item2, force);
|
819
|
+
}));
|
820
|
+
} else if (root) {
|
821
|
+
resolveDataForRoot(force);
|
822
|
+
} else {
|
823
|
+
resolveDataForRoot(force);
|
824
|
+
flattenData(appState.data).map((item2) => __async(void 0, null, function* () {
|
825
|
+
yield resolveDataForItem(item2, force);
|
826
|
+
}));
|
827
|
+
}
|
828
|
+
}),
|
829
|
+
[config, appState]
|
830
|
+
);
|
831
|
+
const refreshPermissions = (0, import_react4.useCallback)(
|
832
|
+
(params) => __async(void 0, null, function* () {
|
833
|
+
resolvePermissions(params, true);
|
834
|
+
}),
|
835
|
+
[config, appState]
|
836
|
+
);
|
837
|
+
(0, import_react4.useEffect)(() => {
|
838
|
+
resolvePermissions();
|
839
|
+
}, [config, appState.data]);
|
840
|
+
const getPermissions = (0, import_react4.useCallback)(
|
841
|
+
({ item, type, root } = {}) => {
|
842
|
+
if (item) {
|
843
|
+
const componentConfig = config.components[item.type];
|
844
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
845
|
+
const resolvedForItem = resolvedPermissions[item.props.id];
|
846
|
+
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
847
|
+
} else if (type) {
|
848
|
+
const componentConfig = config.components[type];
|
849
|
+
return __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
850
|
+
} else if (root) {
|
851
|
+
const rootConfig = config.root;
|
852
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
853
|
+
const resolvedForItem = resolvedPermissions["puck-root"];
|
854
|
+
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
855
|
+
}
|
856
|
+
return globalPermissions;
|
857
|
+
},
|
858
|
+
[config, resolvedPermissions]
|
859
|
+
);
|
860
|
+
return {
|
861
|
+
getPermissions,
|
862
|
+
refreshPermissions
|
863
|
+
};
|
864
|
+
};
|
865
|
+
|
866
|
+
// lib/use-resolved-data.ts
|
867
|
+
init_react_import();
|
868
|
+
var import_react5 = require("react");
|
869
|
+
|
870
|
+
// lib/resolve-component-data.ts
|
871
|
+
init_react_import();
|
872
|
+
var cache = { lastChange: {} };
|
873
|
+
var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
874
|
+
return yield Promise.all(
|
875
|
+
content.map((item) => __async(void 0, null, function* () {
|
876
|
+
return yield resolveComponentData(
|
877
|
+
item,
|
878
|
+
config,
|
879
|
+
onResolveStart,
|
880
|
+
onResolveEnd
|
881
|
+
);
|
882
|
+
}))
|
883
|
+
);
|
884
|
+
});
|
885
|
+
var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
886
|
+
const configForItem = config.components[item.type];
|
887
|
+
if (configForItem.resolveData) {
|
888
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
889
|
+
if (item && item === oldItem) {
|
890
|
+
return resolved;
|
891
|
+
}
|
892
|
+
const changed = getChanged(item, oldItem);
|
893
|
+
if (onResolveStart) {
|
894
|
+
onResolveStart(item);
|
895
|
+
}
|
896
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
|
897
|
+
const { readOnly: existingReadOnly = {} } = item || {};
|
898
|
+
const newReadOnly = __spreadValues(__spreadValues({}, existingReadOnly), readOnly);
|
899
|
+
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
900
|
+
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
901
|
+
});
|
902
|
+
if (Object.keys(newReadOnly).length) {
|
903
|
+
resolvedItem.readOnly = newReadOnly;
|
904
|
+
}
|
905
|
+
cache.lastChange[item.props.id] = {
|
906
|
+
item,
|
907
|
+
resolved: resolvedItem
|
908
|
+
};
|
909
|
+
if (onResolveEnd) {
|
910
|
+
onResolveEnd(resolvedItem);
|
911
|
+
}
|
912
|
+
return resolvedItem;
|
913
|
+
}
|
914
|
+
return item;
|
915
|
+
});
|
916
|
+
|
917
|
+
// lib/apply-dynamic-props.ts
|
918
|
+
init_react_import();
|
919
|
+
var applyDynamicProps = (data, dynamicProps, rootData) => {
|
920
|
+
return __spreadProps(__spreadValues({}, data), {
|
921
|
+
root: __spreadValues(__spreadValues({}, data.root), rootData ? rootData : {}),
|
922
|
+
content: data.content.map((item) => {
|
923
|
+
return dynamicProps[item.props.id] ? __spreadValues(__spreadValues({}, item), dynamicProps[item.props.id]) : item;
|
924
|
+
}),
|
925
|
+
zones: Object.keys(data.zones || {}).reduce((acc, zoneKey) => {
|
926
|
+
return __spreadProps(__spreadValues({}, acc), {
|
927
|
+
[zoneKey]: data.zones[zoneKey].map((item) => {
|
928
|
+
return dynamicProps[item.props.id] ? __spreadValues(__spreadValues({}, item), dynamicProps[item.props.id]) : item;
|
929
|
+
})
|
930
|
+
});
|
931
|
+
}, {})
|
932
|
+
});
|
933
|
+
};
|
934
|
+
|
935
|
+
// lib/resolve-root-data.ts
|
936
|
+
init_react_import();
|
937
|
+
var cache2 = {};
|
938
|
+
function resolveRootData(data, config) {
|
939
|
+
return __async(this, null, function* () {
|
940
|
+
var _a, _b, _c, _d, _e;
|
941
|
+
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
942
|
+
if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
|
943
|
+
return cache2.lastChange.resolved;
|
944
|
+
}
|
945
|
+
const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
|
946
|
+
const rootWithProps = data.root;
|
947
|
+
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
948
|
+
changed,
|
949
|
+
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
|
950
|
+
});
|
951
|
+
cache2.lastChange = {
|
952
|
+
original: data.root,
|
953
|
+
resolved: resolvedRoot
|
954
|
+
};
|
955
|
+
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
956
|
+
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
957
|
+
});
|
958
|
+
}
|
959
|
+
return data.root;
|
960
|
+
});
|
961
|
+
}
|
962
|
+
|
963
|
+
// lib/use-resolved-data.ts
|
964
|
+
var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetComponentLoading, refreshPermissions) => {
|
965
|
+
const [{ resolverKey, newAppState }, setResolverState] = (0, import_react5.useState)({
|
966
|
+
resolverKey: 0,
|
967
|
+
newAppState: appState
|
968
|
+
});
|
969
|
+
const deferredSetStates = {};
|
970
|
+
const _setComponentLoading = (0, import_react5.useCallback)(
|
971
|
+
(id, loading, defer2 = 0) => {
|
972
|
+
if (deferredSetStates[id]) {
|
973
|
+
clearTimeout(deferredSetStates[id]);
|
974
|
+
delete deferredSetStates[id];
|
975
|
+
}
|
976
|
+
deferredSetStates[id] = setTimeout(() => {
|
977
|
+
if (loading) {
|
978
|
+
setComponentLoading(id);
|
979
|
+
} else {
|
980
|
+
unsetComponentLoading(id);
|
981
|
+
}
|
982
|
+
delete deferredSetStates[id];
|
983
|
+
}, defer2);
|
984
|
+
},
|
985
|
+
[]
|
986
|
+
);
|
987
|
+
const runResolvers = () => __async(void 0, null, function* () {
|
988
|
+
const newData = newAppState.data;
|
989
|
+
const flatContent = flattenData(newData).filter(
|
990
|
+
(item) => {
|
991
|
+
var _a;
|
992
|
+
return !!((_a = config.components[item.type]) == null ? void 0 : _a.resolveData);
|
993
|
+
}
|
994
|
+
);
|
995
|
+
const applyIfChange = (dynamicDataMap, dynamicRoot) => {
|
996
|
+
const processed = applyDynamicProps(
|
997
|
+
appState.data,
|
998
|
+
dynamicDataMap,
|
999
|
+
dynamicRoot
|
1000
|
+
);
|
1001
|
+
const processedAppState = __spreadProps(__spreadValues({}, appState), { data: processed });
|
1002
|
+
const containsChanges = JSON.stringify(appState) !== JSON.stringify(processedAppState);
|
1003
|
+
if (containsChanges) {
|
1004
|
+
dispatch({
|
1005
|
+
type: "set",
|
1006
|
+
state: (prev) => __spreadProps(__spreadValues({}, prev), {
|
1007
|
+
data: applyDynamicProps(prev.data, dynamicDataMap, dynamicRoot),
|
1008
|
+
ui: resolverKey > 0 ? __spreadValues(__spreadValues({}, prev.ui), newAppState.ui) : prev.ui
|
1009
|
+
}),
|
1010
|
+
recordHistory: resolverKey > 0
|
1011
|
+
});
|
1012
|
+
}
|
1013
|
+
};
|
1014
|
+
const promises = [];
|
1015
|
+
promises.push(
|
1016
|
+
(() => __async(void 0, null, function* () {
|
1017
|
+
_setComponentLoading("puck-root", true, 50);
|
1018
|
+
const dynamicRoot = yield resolveRootData(newData, config);
|
1019
|
+
applyIfChange({}, dynamicRoot);
|
1020
|
+
_setComponentLoading("puck-root", false);
|
1021
|
+
}))()
|
1022
|
+
);
|
1023
|
+
flatContent.forEach((item) => {
|
1024
|
+
promises.push(
|
1025
|
+
(() => __async(void 0, null, function* () {
|
1026
|
+
refreshPermissions({ item });
|
1027
|
+
const dynamicData = yield resolveComponentData(
|
1028
|
+
item,
|
1029
|
+
config,
|
1030
|
+
(item2) => {
|
1031
|
+
_setComponentLoading(item2.props.id, true, 50);
|
1032
|
+
},
|
1033
|
+
(item2) => {
|
1034
|
+
deferredSetStates[item2.props.id];
|
1035
|
+
_setComponentLoading(item2.props.id, false);
|
1036
|
+
}
|
1037
|
+
);
|
1038
|
+
const dynamicDataMap = { [item.props.id]: dynamicData };
|
1039
|
+
applyIfChange(dynamicDataMap);
|
1040
|
+
}))()
|
1041
|
+
);
|
1042
|
+
});
|
1043
|
+
yield Promise.all(promises);
|
1044
|
+
});
|
1045
|
+
(0, import_react5.useEffect)(() => {
|
1046
|
+
runResolvers();
|
1047
|
+
}, [resolverKey]);
|
1048
|
+
const resolveData = (0, import_react5.useCallback)((newAppState2 = appState) => {
|
1049
|
+
setResolverState((curr) => ({
|
1050
|
+
resolverKey: curr.resolverKey + 1,
|
1051
|
+
newAppState: newAppState2
|
1052
|
+
}));
|
1053
|
+
}, []);
|
1054
|
+
return {
|
1055
|
+
resolveData
|
1056
|
+
};
|
1057
|
+
};
|
1058
|
+
|
1059
|
+
// components/Puck/context.tsx
|
688
1060
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
689
1061
|
var defaultAppState = {
|
690
1062
|
data: { content: [], root: {} },
|
@@ -710,6 +1082,8 @@ var defaultContext = {
|
|
710
1082
|
dispatch: () => null,
|
711
1083
|
config: { components: {} },
|
712
1084
|
componentState: {},
|
1085
|
+
setComponentState: () => {
|
1086
|
+
},
|
713
1087
|
resolveData: () => {
|
714
1088
|
},
|
715
1089
|
plugins: [],
|
@@ -726,20 +1100,22 @@ var defaultContext = {
|
|
726
1100
|
setStatus: () => null,
|
727
1101
|
iframe: {},
|
728
1102
|
safariFallbackMode: false,
|
729
|
-
globalPermissions: {}
|
1103
|
+
globalPermissions: {},
|
1104
|
+
getPermissions: () => ({}),
|
1105
|
+
refreshPermissions: () => null
|
730
1106
|
};
|
731
|
-
var appContext = (0,
|
1107
|
+
var appContext = (0, import_react6.createContext)(defaultContext);
|
732
1108
|
var AppProvider = ({
|
733
1109
|
children,
|
734
1110
|
value
|
735
1111
|
}) => {
|
736
|
-
const [zoomConfig, setZoomConfig] = (0,
|
737
|
-
const [status, setStatus] = (0,
|
738
|
-
(0,
|
1112
|
+
const [zoomConfig, setZoomConfig] = (0, import_react6.useState)(defaultContext.zoomConfig);
|
1113
|
+
const [status, setStatus] = (0, import_react6.useState)("LOADING");
|
1114
|
+
(0, import_react6.useEffect)(() => {
|
739
1115
|
setStatus("MOUNTED");
|
740
1116
|
}, []);
|
741
|
-
const [safariFallbackMode, setSafariFallbackMode] = (0,
|
742
|
-
(0,
|
1117
|
+
const [safariFallbackMode, setSafariFallbackMode] = (0, import_react6.useState)(false);
|
1118
|
+
(0, import_react6.useEffect)(() => {
|
743
1119
|
var _a, _b, _c;
|
744
1120
|
const ua = new import_ua_parser_js.UAParser(navigator.userAgent);
|
745
1121
|
const { browser } = ua.getResult();
|
@@ -756,26 +1132,67 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
756
1132
|
setSafariFallbackMode(true);
|
757
1133
|
}
|
758
1134
|
}, []);
|
1135
|
+
const selectedItem = value.state.ui.itemSelector ? getItem(value.state.ui.itemSelector, value.state.data) : void 0;
|
1136
|
+
const [componentState, setComponentState] = (0, import_react6.useState)({});
|
1137
|
+
const setComponentLoading = (id) => {
|
1138
|
+
setComponentState((prev) => {
|
1139
|
+
var _a;
|
1140
|
+
return __spreadProps(__spreadValues({}, prev), {
|
1141
|
+
[id]: __spreadProps(__spreadValues({}, prev[id]), {
|
1142
|
+
loadingCount: (((_a = prev[id]) == null ? void 0 : _a.loadingCount) || 0) + 1
|
1143
|
+
})
|
1144
|
+
});
|
1145
|
+
});
|
1146
|
+
};
|
1147
|
+
const unsetComponentLoading = (id) => {
|
1148
|
+
setComponentState((prev) => {
|
1149
|
+
var _a;
|
1150
|
+
return __spreadProps(__spreadValues({}, prev), {
|
1151
|
+
[id]: __spreadProps(__spreadValues({}, prev[id]), {
|
1152
|
+
loadingCount: Math.max((((_a = prev[id]) == null ? void 0 : _a.loadingCount) || 0) - 1, 0)
|
1153
|
+
})
|
1154
|
+
});
|
1155
|
+
});
|
1156
|
+
};
|
1157
|
+
const { getPermissions, refreshPermissions } = useResolvedPermissions(
|
1158
|
+
value.config,
|
1159
|
+
value.state,
|
1160
|
+
value.globalPermissions || {},
|
1161
|
+
setComponentLoading,
|
1162
|
+
unsetComponentLoading
|
1163
|
+
);
|
1164
|
+
const { resolveData } = useResolvedData(
|
1165
|
+
value.state,
|
1166
|
+
value.config,
|
1167
|
+
value.dispatch,
|
1168
|
+
setComponentLoading,
|
1169
|
+
unsetComponentLoading,
|
1170
|
+
refreshPermissions
|
1171
|
+
);
|
759
1172
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
760
1173
|
appContext.Provider,
|
761
1174
|
{
|
762
1175
|
value: __spreadProps(__spreadValues({}, value), {
|
1176
|
+
selectedItem,
|
763
1177
|
zoomConfig,
|
764
1178
|
setZoomConfig,
|
765
1179
|
status,
|
766
1180
|
setStatus,
|
767
|
-
safariFallbackMode
|
1181
|
+
safariFallbackMode,
|
1182
|
+
getPermissions,
|
1183
|
+
refreshPermissions,
|
1184
|
+
componentState,
|
1185
|
+
setComponentState,
|
1186
|
+
resolveData
|
768
1187
|
}),
|
769
1188
|
children
|
770
1189
|
}
|
771
1190
|
);
|
772
1191
|
};
|
773
1192
|
function useAppContext() {
|
774
|
-
const mainContext = (0,
|
775
|
-
const selectedItem = mainContext.state.ui.itemSelector ? getItem(mainContext.state.ui.itemSelector, mainContext.state.data) : void 0;
|
1193
|
+
const mainContext = (0, import_react6.useContext)(appContext);
|
776
1194
|
return __spreadProps(__spreadValues({}, mainContext), {
|
777
1195
|
// Helpers
|
778
|
-
selectedItem,
|
779
1196
|
setUi: (ui, recordHistory) => {
|
780
1197
|
return mainContext.dispatch({
|
781
1198
|
type: "setUi",
|
@@ -877,7 +1294,7 @@ var Draggable = ({
|
|
877
1294
|
};
|
878
1295
|
|
879
1296
|
// components/AutoField/fields/ArrayField/index.tsx
|
880
|
-
var
|
1297
|
+
var import_react7 = require("react");
|
881
1298
|
|
882
1299
|
// components/DragIcon/index.tsx
|
883
1300
|
init_react_import();
|
@@ -916,7 +1333,7 @@ var ArrayField = ({
|
|
916
1333
|
id,
|
917
1334
|
Label = (props) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", __spreadValues({}, props))
|
918
1335
|
}) => {
|
919
|
-
const { state, setUi, selectedItem } = useAppContext();
|
1336
|
+
const { state, setUi, selectedItem, getPermissions } = useAppContext();
|
920
1337
|
const readOnlyFields = (selectedItem == null ? void 0 : selectedItem.readOnly) || {};
|
921
1338
|
const value = _value;
|
922
1339
|
const arrayState = state.ui.arrayState[id] || {
|
@@ -928,11 +1345,11 @@ var ArrayField = ({
|
|
928
1345
|
}),
|
929
1346
|
openId: ""
|
930
1347
|
};
|
931
|
-
const [localState, setLocalState] = (0,
|
932
|
-
(0,
|
1348
|
+
const [localState, setLocalState] = (0, import_react7.useState)({ arrayState, value });
|
1349
|
+
(0, import_react7.useEffect)(() => {
|
933
1350
|
setLocalState({ arrayState, value });
|
934
1351
|
}, [value, state.ui.arrayState[id]]);
|
935
|
-
const mapArrayStateToUi = (0,
|
1352
|
+
const mapArrayStateToUi = (0, import_react7.useCallback)(
|
936
1353
|
(partialArrayState) => {
|
937
1354
|
return {
|
938
1355
|
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
@@ -942,13 +1359,13 @@ var ArrayField = ({
|
|
942
1359
|
},
|
943
1360
|
[arrayState]
|
944
1361
|
);
|
945
|
-
const getHighestIndex = (0,
|
1362
|
+
const getHighestIndex = (0, import_react7.useCallback)(() => {
|
946
1363
|
return arrayState.items.reduce(
|
947
1364
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
948
1365
|
-1
|
949
1366
|
);
|
950
1367
|
}, [arrayState]);
|
951
|
-
const regenerateArrayState = (0,
|
1368
|
+
const regenerateArrayState = (0, import_react7.useCallback)(
|
952
1369
|
(value2) => {
|
953
1370
|
let highestIndex = getHighestIndex();
|
954
1371
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
@@ -967,12 +1384,13 @@ var ArrayField = ({
|
|
967
1384
|
},
|
968
1385
|
[arrayState]
|
969
1386
|
);
|
970
|
-
(0,
|
1387
|
+
(0, import_react7.useEffect)(() => {
|
971
1388
|
if (arrayState.items.length > 0) {
|
972
1389
|
setUi(mapArrayStateToUi(arrayState));
|
973
1390
|
}
|
974
1391
|
}, []);
|
975
|
-
const [hovering, setHovering] = (0,
|
1392
|
+
const [hovering, setHovering] = (0, import_react7.useState)(false);
|
1393
|
+
const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
|
976
1394
|
if (field.type !== "array" || !field.arrayFields) {
|
977
1395
|
return null;
|
978
1396
|
}
|
@@ -1103,13 +1521,14 @@ var ArrayField = ({
|
|
1103
1521
|
const subField = field.arrayFields[fieldName];
|
1104
1522
|
const subFieldName = `${name}[${i}].${fieldName}`;
|
1105
1523
|
const wildcardFieldName = `${name}[*].${fieldName}`;
|
1524
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
|
1106
1525
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
1107
1526
|
AutoFieldPrivate,
|
1108
1527
|
{
|
1109
1528
|
name: subFieldName,
|
1110
1529
|
label: subField.label || fieldName,
|
1111
1530
|
id: `${_arrayId}_${fieldName}`,
|
1112
|
-
readOnly:
|
1531
|
+
readOnly: subReadOnly,
|
1113
1532
|
field: subField,
|
1114
1533
|
value: data[fieldName],
|
1115
1534
|
onChange: (val, ui) => {
|
@@ -1209,19 +1628,19 @@ var DefaultField = ({
|
|
1209
1628
|
|
1210
1629
|
// components/AutoField/fields/ExternalField/index.tsx
|
1211
1630
|
init_react_import();
|
1212
|
-
var
|
1631
|
+
var import_react11 = require("react");
|
1213
1632
|
|
1214
1633
|
// components/ExternalInput/index.tsx
|
1215
1634
|
init_react_import();
|
1216
|
-
var
|
1635
|
+
var import_react10 = require("react");
|
1217
1636
|
|
1218
1637
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
1219
1638
|
init_react_import();
|
1220
|
-
var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-
|
1639
|
+
var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_wprq3_1", "ExternalInput-button": "_ExternalInput-button_wprq3_5", "ExternalInput--dataSelected": "_ExternalInput--dataSelected_wprq3_24", "ExternalInput--readOnly": "_ExternalInput--readOnly_wprq3_31", "ExternalInput-detachButton": "_ExternalInput-detachButton_wprq3_35", "ExternalInput": "_ExternalInput_wprq3_1", "ExternalInputModal": "_ExternalInputModal_wprq3_79", "ExternalInputModal-grid": "_ExternalInputModal-grid_wprq3_89", "ExternalInputModal--filtersToggled": "_ExternalInputModal--filtersToggled_wprq3_100", "ExternalInputModal-filters": "_ExternalInputModal-filters_wprq3_105", "ExternalInputModal-masthead": "_ExternalInputModal-masthead_wprq3_124", "ExternalInputModal-tableWrapper": "_ExternalInputModal-tableWrapper_wprq3_133", "ExternalInputModal-table": "_ExternalInputModal-table_wprq3_133", "ExternalInputModal-thead": "_ExternalInputModal-thead_wprq3_149", "ExternalInputModal-th": "_ExternalInputModal-th_wprq3_149", "ExternalInputModal-td": "_ExternalInputModal-td_wprq3_164", "ExternalInputModal-tr": "_ExternalInputModal-tr_wprq3_169", "ExternalInputModal-tbody": "_ExternalInputModal-tbody_wprq3_176", "ExternalInputModal--hasData": "_ExternalInputModal--hasData_wprq3_202", "ExternalInputModal-loadingBanner": "_ExternalInputModal-loadingBanner_wprq3_206", "ExternalInputModal--isLoading": "_ExternalInputModal--isLoading_wprq3_223", "ExternalInputModal-searchForm": "_ExternalInputModal-searchForm_wprq3_227", "ExternalInputModal-search": "_ExternalInputModal-search_wprq3_227", "ExternalInputModal-searchIcon": "_ExternalInputModal-searchIcon_wprq3_264", "ExternalInputModal-searchIconText": "_ExternalInputModal-searchIconText_wprq3_289", "ExternalInputModal-searchInput": "_ExternalInputModal-searchInput_wprq3_299", "ExternalInputModal-searchActions": "_ExternalInputModal-searchActions_wprq3_313", "ExternalInputModal-searchActionIcon": "_ExternalInputModal-searchActionIcon_wprq3_326", "ExternalInputModal-footer": "_ExternalInputModal-footer_wprq3_330" };
|
1221
1640
|
|
1222
1641
|
// components/Modal/index.tsx
|
1223
1642
|
init_react_import();
|
1224
|
-
var
|
1643
|
+
var import_react8 = require("react");
|
1225
1644
|
|
1226
1645
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
1227
1646
|
init_react_import();
|
@@ -1236,8 +1655,8 @@ var Modal = ({
|
|
1236
1655
|
onClose,
|
1237
1656
|
isOpen
|
1238
1657
|
}) => {
|
1239
|
-
const [rootEl, setRootEl] = (0,
|
1240
|
-
(0,
|
1658
|
+
const [rootEl, setRootEl] = (0, import_react8.useState)(null);
|
1659
|
+
(0, import_react8.useEffect)(() => {
|
1241
1660
|
setRootEl(document.getElementById("puck-portal-root"));
|
1242
1661
|
}, []);
|
1243
1662
|
if (!rootEl) {
|
@@ -1284,7 +1703,7 @@ init_react_import();
|
|
1284
1703
|
|
1285
1704
|
// components/Button/Button.tsx
|
1286
1705
|
init_react_import();
|
1287
|
-
var
|
1706
|
+
var import_react9 = require("react");
|
1288
1707
|
|
1289
1708
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
1290
1709
|
init_react_import();
|
@@ -1307,8 +1726,8 @@ var Button = ({
|
|
1307
1726
|
size = "medium",
|
1308
1727
|
loading: loadingProp = false
|
1309
1728
|
}) => {
|
1310
|
-
const [loading, setLoading] = (0,
|
1311
|
-
(0,
|
1729
|
+
const [loading, setLoading] = (0, import_react9.useState)(loadingProp);
|
1730
|
+
(0, import_react9.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
1312
1731
|
const ElementType = href ? "a" : type ? "button" : "span";
|
1313
1732
|
const el = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
1314
1733
|
ElementType,
|
@@ -1353,23 +1772,24 @@ var ExternalInput = ({
|
|
1353
1772
|
onChange,
|
1354
1773
|
value = null,
|
1355
1774
|
name,
|
1356
|
-
id
|
1775
|
+
id,
|
1776
|
+
readOnly
|
1357
1777
|
}) => {
|
1358
1778
|
const {
|
1359
1779
|
mapProp = (val) => val,
|
1360
1780
|
mapRow = (val) => val,
|
1361
1781
|
filterFields
|
1362
1782
|
} = field || {};
|
1363
|
-
const [data, setData] = (0,
|
1364
|
-
const [isOpen, setOpen] = (0,
|
1365
|
-
const [isLoading, setIsLoading] = (0,
|
1783
|
+
const [data, setData] = (0, import_react10.useState)([]);
|
1784
|
+
const [isOpen, setOpen] = (0, import_react10.useState)(false);
|
1785
|
+
const [isLoading, setIsLoading] = (0, import_react10.useState)(true);
|
1366
1786
|
const hasFilterFields = !!filterFields;
|
1367
|
-
const [filters, setFilters] = (0,
|
1368
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
1369
|
-
const mappedData = (0,
|
1787
|
+
const [filters, setFilters] = (0, import_react10.useState)(field.initialFilters || {});
|
1788
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react10.useState)(hasFilterFields);
|
1789
|
+
const mappedData = (0, import_react10.useMemo)(() => {
|
1370
1790
|
return data.map(mapRow);
|
1371
1791
|
}, [data]);
|
1372
|
-
const keys = (0,
|
1792
|
+
const keys = (0, import_react10.useMemo)(() => {
|
1373
1793
|
const validKeys = /* @__PURE__ */ new Set();
|
1374
1794
|
for (const item of mappedData) {
|
1375
1795
|
for (const key of Object.keys(item)) {
|
@@ -1380,8 +1800,8 @@ var ExternalInput = ({
|
|
1380
1800
|
}
|
1381
1801
|
return Array.from(validKeys);
|
1382
1802
|
}, [mappedData]);
|
1383
|
-
const [searchQuery, setSearchQuery] = (0,
|
1384
|
-
const search = (0,
|
1803
|
+
const [searchQuery, setSearchQuery] = (0, import_react10.useState)(field.initialQuery || "");
|
1804
|
+
const search = (0, import_react10.useCallback)(
|
1385
1805
|
(query, filters2) => __async(void 0, null, function* () {
|
1386
1806
|
setIsLoading(true);
|
1387
1807
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -1394,7 +1814,7 @@ var ExternalInput = ({
|
|
1394
1814
|
}),
|
1395
1815
|
[id, field]
|
1396
1816
|
);
|
1397
|
-
(0,
|
1817
|
+
(0, import_react10.useEffect)(() => {
|
1398
1818
|
search(searchQuery, filters);
|
1399
1819
|
}, []);
|
1400
1820
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
@@ -1402,7 +1822,8 @@ var ExternalInput = ({
|
|
1402
1822
|
{
|
1403
1823
|
className: getClassName10({
|
1404
1824
|
dataSelected: !!value,
|
1405
|
-
modalVisible: isOpen
|
1825
|
+
modalVisible: isOpen,
|
1826
|
+
readOnly
|
1406
1827
|
}),
|
1407
1828
|
id,
|
1408
1829
|
children: [
|
@@ -1413,6 +1834,7 @@ var ExternalInput = ({
|
|
1413
1834
|
type: "button",
|
1414
1835
|
onClick: () => setOpen(true),
|
1415
1836
|
className: getClassName10("button"),
|
1837
|
+
disabled: readOnly,
|
1416
1838
|
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
1417
1839
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Link, { size: "16" }),
|
1418
1840
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: field.placeholder })
|
@@ -1422,10 +1844,12 @@ var ExternalInput = ({
|
|
1422
1844
|
value && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
1423
1845
|
"button",
|
1424
1846
|
{
|
1847
|
+
type: "button",
|
1425
1848
|
className: getClassName10("detachButton"),
|
1426
1849
|
onClick: () => {
|
1427
1850
|
onChange(null);
|
1428
1851
|
},
|
1852
|
+
disabled: readOnly,
|
1429
1853
|
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Unlock, { size: 16 })
|
1430
1854
|
}
|
1431
1855
|
)
|
@@ -1551,12 +1975,13 @@ var ExternalField = ({
|
|
1551
1975
|
name,
|
1552
1976
|
label,
|
1553
1977
|
Label,
|
1554
|
-
id
|
1978
|
+
id,
|
1979
|
+
readOnly
|
1555
1980
|
}) => {
|
1556
1981
|
var _a, _b, _c;
|
1557
1982
|
const validField = field;
|
1558
1983
|
const deprecatedField = field;
|
1559
|
-
(0,
|
1984
|
+
(0, import_react11.useEffect)(() => {
|
1560
1985
|
if (deprecatedField.adaptor) {
|
1561
1986
|
console.error(
|
1562
1987
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
@@ -1583,7 +2008,8 @@ var ExternalField = ({
|
|
1583
2008
|
}),
|
1584
2009
|
onChange,
|
1585
2010
|
value,
|
1586
|
-
id
|
2011
|
+
id,
|
2012
|
+
readOnly
|
1587
2013
|
}
|
1588
2014
|
) });
|
1589
2015
|
};
|
@@ -1764,13 +2190,14 @@ var ObjectField = ({
|
|
1764
2190
|
const subField = field.objectFields[fieldName];
|
1765
2191
|
const subFieldName = `${name}.${fieldName}`;
|
1766
2192
|
const wildcardFieldName = `${name}.${fieldName}`;
|
2193
|
+
const subReadOnly = readOnly ? readOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
|
1767
2194
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
1768
2195
|
AutoFieldPrivate,
|
1769
2196
|
{
|
1770
2197
|
name: subFieldName,
|
1771
2198
|
label: subField.label || fieldName,
|
1772
2199
|
id: `${id}_${fieldName}`,
|
1773
|
-
readOnly:
|
2200
|
+
readOnly: subReadOnly,
|
1774
2201
|
field: subField,
|
1775
2202
|
value: data[fieldName],
|
1776
2203
|
onChange: (val, ui) => {
|
@@ -1791,7 +2218,7 @@ var ObjectField = ({
|
|
1791
2218
|
|
1792
2219
|
// lib/use-safe-id.ts
|
1793
2220
|
init_react_import();
|
1794
|
-
var
|
2221
|
+
var import_react12 = __toESM(require("react"));
|
1795
2222
|
|
1796
2223
|
// lib/generate-id.ts
|
1797
2224
|
init_react_import();
|
@@ -1800,10 +2227,10 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
1800
2227
|
|
1801
2228
|
// lib/use-safe-id.ts
|
1802
2229
|
var useSafeId = () => {
|
1803
|
-
if (typeof
|
1804
|
-
return
|
2230
|
+
if (typeof import_react12.default.useId !== "undefined") {
|
2231
|
+
return import_react12.default.useId();
|
1805
2232
|
}
|
1806
|
-
const [id] = (0,
|
2233
|
+
const [id] = (0, import_react12.useState)(generateId());
|
1807
2234
|
return id;
|
1808
2235
|
};
|
1809
2236
|
|
@@ -1836,7 +2263,7 @@ var FieldLabelInternal2 = ({
|
|
1836
2263
|
readOnly
|
1837
2264
|
}) => {
|
1838
2265
|
const { overrides } = useAppContext();
|
1839
|
-
const Wrapper = (0,
|
2266
|
+
const Wrapper = (0, import_react13.useMemo)(
|
1840
2267
|
() => overrides.fieldLabel || FieldLabel,
|
1841
2268
|
[overrides]
|
1842
2269
|
);
|
@@ -1900,7 +2327,7 @@ function AutoFieldInternal(props) {
|
|
1900
2327
|
}
|
1901
2328
|
function AutoFieldPrivate(props) {
|
1902
2329
|
const { value, onChange } = props;
|
1903
|
-
const [localValue, setLocalValue] = (0,
|
2330
|
+
const [localValue, setLocalValue] = (0, import_react13.useState)(value);
|
1904
2331
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
1905
2332
|
(val, ui) => {
|
1906
2333
|
onChange(val, ui);
|
@@ -1908,11 +2335,11 @@ function AutoFieldPrivate(props) {
|
|
1908
2335
|
50,
|
1909
2336
|
{ leading: true }
|
1910
2337
|
);
|
1911
|
-
const onChangeLocal = (0,
|
2338
|
+
const onChangeLocal = (0, import_react13.useCallback)((val, ui) => {
|
1912
2339
|
setLocalValue(val);
|
1913
2340
|
onChangeDb(val, ui);
|
1914
2341
|
}, []);
|
1915
|
-
(0,
|
2342
|
+
(0, import_react13.useEffect)(() => {
|
1916
2343
|
setLocalValue(value);
|
1917
2344
|
}, [value]);
|
1918
2345
|
const localProps = {
|
@@ -1931,14 +2358,14 @@ init_react_import();
|
|
1931
2358
|
|
1932
2359
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
|
1933
2360
|
init_react_import();
|
1934
|
-
var styles_module_default10 = { "Drawer": "
|
2361
|
+
var styles_module_default10 = { "Drawer": "_Drawer_1oa7v_1", "DrawerItem--disabled": "_DrawerItem--disabled_1oa7v_5", "DrawerItem-draggable": "_DrawerItem-draggable_1oa7v_5", "DrawerItem-default": "_DrawerItem-default_1oa7v_11", "DrawerItem-draggableWrapper": "_DrawerItem-draggableWrapper_1oa7v_11", "DrawerItem": "_DrawerItem_1oa7v_5", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_1oa7v_36", "DrawerItem-name": "_DrawerItem-name_1oa7v_54" };
|
1935
2362
|
|
1936
2363
|
// components/Drawer/index.tsx
|
1937
|
-
var
|
2364
|
+
var import_react14 = require("react");
|
1938
2365
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
1939
2366
|
var getClassName16 = get_class_name_factory_default("Drawer", styles_module_default10);
|
1940
2367
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
1941
|
-
var drawerContext = (0,
|
2368
|
+
var drawerContext = (0, import_react14.createContext)({
|
1942
2369
|
droppableId: ""
|
1943
2370
|
});
|
1944
2371
|
var DrawerDraggable = ({
|
@@ -1969,9 +2396,9 @@ var DrawerItem = ({
|
|
1969
2396
|
index,
|
1970
2397
|
isDragDisabled
|
1971
2398
|
}) => {
|
1972
|
-
const ctx = (0,
|
2399
|
+
const ctx = (0, import_react14.useContext)(drawerContext);
|
1973
2400
|
const resolvedId = `${ctx.droppableId}::${id || name}`;
|
1974
|
-
const CustomInner = (0,
|
2401
|
+
const CustomInner = (0, import_react14.useMemo)(
|
1975
2402
|
() => children || (({ children: children2, name: name2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
1976
2403
|
[children]
|
1977
2404
|
);
|
@@ -2012,11 +2439,11 @@ Drawer.Item = DrawerItem;
|
|
2012
2439
|
|
2013
2440
|
// components/DropZone/index.tsx
|
2014
2441
|
init_react_import();
|
2015
|
-
var
|
2442
|
+
var import_react18 = require("react");
|
2016
2443
|
|
2017
2444
|
// components/DraggableComponent/index.tsx
|
2018
2445
|
init_react_import();
|
2019
|
-
var
|
2446
|
+
var import_react16 = require("react");
|
2020
2447
|
var import_dnd4 = require("@measured/dnd");
|
2021
2448
|
|
2022
2449
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
@@ -2025,10 +2452,10 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1bhad
|
|
2025
2452
|
|
2026
2453
|
// lib/use-modifier-held.ts
|
2027
2454
|
init_react_import();
|
2028
|
-
var
|
2455
|
+
var import_react15 = require("react");
|
2029
2456
|
var useModifierHeld = (modifier) => {
|
2030
|
-
const [modifierHeld, setModifierHeld] = (0,
|
2031
|
-
(0,
|
2457
|
+
const [modifierHeld, setModifierHeld] = (0, import_react15.useState)(false);
|
2458
|
+
(0, import_react15.useEffect)(() => {
|
2032
2459
|
function downHandler({ key }) {
|
2033
2460
|
if (key === modifier) {
|
2034
2461
|
setModifierHeld(true);
|
@@ -2066,90 +2493,6 @@ init_react_import();
|
|
2066
2493
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
2067
2494
|
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children });
|
2068
2495
|
|
2069
|
-
// lib/get-permissions.ts
|
2070
|
-
init_react_import();
|
2071
|
-
|
2072
|
-
// lib/get-changed.ts
|
2073
|
-
init_react_import();
|
2074
|
-
var getChanged = (newItem, oldItem) => {
|
2075
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
2076
|
-
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
2077
|
-
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
2078
|
-
return __spreadProps(__spreadValues({}, acc), {
|
2079
|
-
[item]: oldItemProps[item] !== newItemProps[item]
|
2080
|
-
});
|
2081
|
-
}, {}) : {};
|
2082
|
-
};
|
2083
|
-
|
2084
|
-
// lib/resolve-permissions.ts
|
2085
|
-
init_react_import();
|
2086
|
-
var resolvePermissions = ({
|
2087
|
-
selectedItem,
|
2088
|
-
config,
|
2089
|
-
changed,
|
2090
|
-
lastPermissions,
|
2091
|
-
initialPermissions,
|
2092
|
-
appState
|
2093
|
-
}) => {
|
2094
|
-
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
2095
|
-
if (selectedItem && (componentConfig == null ? void 0 : componentConfig.resolvePermissions)) {
|
2096
|
-
return componentConfig.resolvePermissions(selectedItem, {
|
2097
|
-
changed,
|
2098
|
-
lastPermissions,
|
2099
|
-
initialPermissions,
|
2100
|
-
appState
|
2101
|
-
});
|
2102
|
-
}
|
2103
|
-
return {};
|
2104
|
-
};
|
2105
|
-
|
2106
|
-
// lib/get-permissions.ts
|
2107
|
-
var cache = { lastPermissions: {}, lastSelected: {} };
|
2108
|
-
var getPermissions = ({
|
2109
|
-
selectedItem,
|
2110
|
-
type,
|
2111
|
-
globalPermissions,
|
2112
|
-
config,
|
2113
|
-
appState
|
2114
|
-
}) => {
|
2115
|
-
const componentType = type || selectedItem && selectedItem.type || "";
|
2116
|
-
const componentId = selectedItem && selectedItem.props.id || "";
|
2117
|
-
let componentPermissions = getInitialPermissions({
|
2118
|
-
componentType,
|
2119
|
-
config,
|
2120
|
-
globalPermissions
|
2121
|
-
});
|
2122
|
-
const changed = getChanged(selectedItem, cache.lastSelected);
|
2123
|
-
if (Object.values(changed).some((el) => el === true)) {
|
2124
|
-
const resolvedPermissions = resolvePermissions({
|
2125
|
-
selectedItem,
|
2126
|
-
config,
|
2127
|
-
changed,
|
2128
|
-
lastPermissions: cache.lastPermissions[componentId] || componentPermissions,
|
2129
|
-
initialPermissions: componentPermissions,
|
2130
|
-
appState
|
2131
|
-
});
|
2132
|
-
if (resolvedPermissions !== void 0) {
|
2133
|
-
componentPermissions = __spreadValues(__spreadValues({}, componentPermissions), resolvedPermissions);
|
2134
|
-
}
|
2135
|
-
cache.lastSelected = selectedItem;
|
2136
|
-
cache.lastPermissions[componentId] = componentPermissions;
|
2137
|
-
return componentPermissions;
|
2138
|
-
}
|
2139
|
-
if (Object.keys(componentId && cache.lastPermissions[componentId]).length !== 0) {
|
2140
|
-
componentPermissions = cache.lastPermissions[componentId];
|
2141
|
-
}
|
2142
|
-
return componentPermissions;
|
2143
|
-
};
|
2144
|
-
var getInitialPermissions = ({
|
2145
|
-
componentType,
|
2146
|
-
globalPermissions,
|
2147
|
-
config
|
2148
|
-
}) => {
|
2149
|
-
var _a;
|
2150
|
-
return __spreadValues(__spreadValues({}, globalPermissions), (_a = config.components[componentType]) == null ? void 0 : _a.permissions);
|
2151
|
-
};
|
2152
|
-
|
2153
2496
|
// components/DraggableComponent/index.tsx
|
2154
2497
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
2155
2498
|
var getClassName17 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
@@ -2160,7 +2503,7 @@ var actionsRight = space;
|
|
2160
2503
|
var DefaultActionBar = ({
|
2161
2504
|
label,
|
2162
2505
|
children
|
2163
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ActionBar, { label, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DefaultOverride, { children }) });
|
2506
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ActionBar, { label, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ActionBar.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DefaultOverride, { children }) }) });
|
2164
2507
|
var DraggableComponent = ({
|
2165
2508
|
children,
|
2166
2509
|
id,
|
@@ -2183,34 +2526,22 @@ var DraggableComponent = ({
|
|
2183
2526
|
indicativeHover = false,
|
2184
2527
|
style
|
2185
2528
|
}) => {
|
2186
|
-
const {
|
2187
|
-
zoomConfig,
|
2188
|
-
status,
|
2189
|
-
overrides,
|
2190
|
-
plugins,
|
2191
|
-
selectedItem,
|
2192
|
-
config,
|
2193
|
-
globalPermissions,
|
2194
|
-
state
|
2195
|
-
} = useAppContext();
|
2529
|
+
const { zoomConfig, status, overrides, selectedItem, getPermissions } = useAppContext();
|
2196
2530
|
const isModifierHeld = useModifierHeld("Alt");
|
2197
2531
|
const El = status !== "LOADING" ? import_dnd4.Draggable : DefaultDraggable;
|
2198
|
-
(0,
|
2199
|
-
const [disableSecondaryAnimation, setDisableSecondaryAnimation] = (0,
|
2200
|
-
(0,
|
2532
|
+
(0, import_react16.useEffect)(onMount, []);
|
2533
|
+
const [disableSecondaryAnimation, setDisableSecondaryAnimation] = (0, import_react16.useState)(false);
|
2534
|
+
(0, import_react16.useEffect)(() => {
|
2201
2535
|
if (isIos()) {
|
2202
2536
|
setDisableSecondaryAnimation(true);
|
2203
2537
|
}
|
2204
2538
|
}, []);
|
2205
|
-
const CustomActionBar = (0,
|
2539
|
+
const CustomActionBar = (0, import_react16.useMemo)(
|
2206
2540
|
() => overrides.actionBar || DefaultActionBar,
|
2207
2541
|
[overrides.actionBar]
|
2208
2542
|
);
|
2209
|
-
const permissions =
|
2210
|
-
selectedItem
|
2211
|
-
globalPermissions: globalPermissions || {},
|
2212
|
-
config,
|
2213
|
-
appState: state
|
2543
|
+
const permissions = getPermissions({
|
2544
|
+
item: selectedItem
|
2214
2545
|
});
|
2215
2546
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
2216
2547
|
El,
|
@@ -2233,7 +2564,7 @@ var DraggableComponent = ({
|
|
2233
2564
|
indicativeHover
|
2234
2565
|
}),
|
2235
2566
|
style: __spreadProps(__spreadValues(__spreadValues({}, style), provided.draggableProps.style), {
|
2236
|
-
cursor: isModifierHeld || isDragDisabled ? "
|
2567
|
+
cursor: isModifierHeld || isDragDisabled ? "pointer" : "grab"
|
2237
2568
|
}),
|
2238
2569
|
onMouseOver,
|
2239
2570
|
onMouseOut,
|
@@ -2260,8 +2591,8 @@ var DraggableComponent = ({
|
|
2260
2591
|
right: actionsRight / zoomConfig.zoom
|
2261
2592
|
},
|
2262
2593
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(CustomActionBar, { label, children: [
|
2263
|
-
permissions
|
2264
|
-
permissions
|
2594
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Copy, { size: 16 }) }),
|
2595
|
+
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Trash, { size: 16 }) })
|
2265
2596
|
] })
|
2266
2597
|
}
|
2267
2598
|
)
|
@@ -2283,7 +2614,7 @@ var styles_module_default12 = { "DropZone": "_DropZone_djoti_1", "DropZone-conte
|
|
2283
2614
|
|
2284
2615
|
// components/DropZone/context.tsx
|
2285
2616
|
init_react_import();
|
2286
|
-
var
|
2617
|
+
var import_react17 = require("react");
|
2287
2618
|
var import_use_debounce2 = require("use-debounce");
|
2288
2619
|
|
2289
2620
|
// lib/get-zone-id.ts
|
@@ -2300,29 +2631,29 @@ var getZoneId = (zoneCompound) => {
|
|
2300
2631
|
|
2301
2632
|
// components/DropZone/context.tsx
|
2302
2633
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
2303
|
-
var dropZoneContext = (0,
|
2634
|
+
var dropZoneContext = (0, import_react17.createContext)(null);
|
2304
2635
|
var DropZoneProvider = ({
|
2305
2636
|
children,
|
2306
2637
|
value
|
2307
2638
|
}) => {
|
2308
|
-
const [hoveringArea, setHoveringArea] = (0,
|
2309
|
-
const [hoveringZone, setHoveringZone] = (0,
|
2639
|
+
const [hoveringArea, setHoveringArea] = (0, import_react17.useState)(null);
|
2640
|
+
const [hoveringZone, setHoveringZone] = (0, import_react17.useState)(
|
2310
2641
|
rootDroppableId
|
2311
2642
|
);
|
2312
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
2643
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react17.useState)();
|
2313
2644
|
const [hoveringAreaDb] = (0, import_use_debounce2.useDebounce)(hoveringArea, 75, { leading: false });
|
2314
|
-
const [areasWithZones, setAreasWithZones] = (0,
|
2645
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react17.useState)(
|
2315
2646
|
{}
|
2316
2647
|
);
|
2317
|
-
const [activeZones, setActiveZones] = (0,
|
2648
|
+
const [activeZones, setActiveZones] = (0, import_react17.useState)({});
|
2318
2649
|
const { dispatch = null } = value ? value : {};
|
2319
|
-
const registerZoneArea = (0,
|
2650
|
+
const registerZoneArea = (0, import_react17.useCallback)(
|
2320
2651
|
(area) => {
|
2321
2652
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
2322
2653
|
},
|
2323
2654
|
[setAreasWithZones]
|
2324
2655
|
);
|
2325
|
-
const registerZone = (0,
|
2656
|
+
const registerZone = (0, import_react17.useCallback)(
|
2326
2657
|
(zoneCompound) => {
|
2327
2658
|
if (!dispatch) {
|
2328
2659
|
return;
|
@@ -2335,7 +2666,7 @@ var DropZoneProvider = ({
|
|
2335
2666
|
},
|
2336
2667
|
[setActiveZones, dispatch]
|
2337
2668
|
);
|
2338
|
-
const unregisterZone = (0,
|
2669
|
+
const unregisterZone = (0, import_react17.useCallback)(
|
2339
2670
|
(zoneCompound) => {
|
2340
2671
|
if (!dispatch) {
|
2341
2672
|
return;
|
@@ -2350,8 +2681,8 @@ var DropZoneProvider = ({
|
|
2350
2681
|
},
|
2351
2682
|
[setActiveZones, dispatch]
|
2352
2683
|
);
|
2353
|
-
const [pathData, setPathData] = (0,
|
2354
|
-
const registerPath = (0,
|
2684
|
+
const [pathData, setPathData] = (0, import_react17.useState)();
|
2685
|
+
const registerPath = (0, import_react17.useCallback)(
|
2355
2686
|
(selector) => {
|
2356
2687
|
if (!(value == null ? void 0 : value.data)) {
|
2357
2688
|
return;
|
@@ -2376,7 +2707,7 @@ var DropZoneProvider = ({
|
|
2376
2707
|
},
|
2377
2708
|
[value, setPathData]
|
2378
2709
|
);
|
2379
|
-
const [zoneWillDrag, setZoneWillDrag] = (0,
|
2710
|
+
const [zoneWillDrag, setZoneWillDrag] = (0, import_react17.useState)("");
|
2380
2711
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: value && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
2381
2712
|
dropZoneContext.Provider,
|
2382
2713
|
{
|
@@ -2408,7 +2739,7 @@ var getClassName18 = get_class_name_factory_default("DropZone", styles_module_de
|
|
2408
2739
|
function DropZoneEdit({ zone, allow, disallow, style }) {
|
2409
2740
|
var _a;
|
2410
2741
|
const appContext2 = useAppContext();
|
2411
|
-
const ctx = (0,
|
2742
|
+
const ctx = (0, import_react18.useContext)(dropZoneContext);
|
2412
2743
|
const {
|
2413
2744
|
// These all need setting via context
|
2414
2745
|
data,
|
@@ -2427,12 +2758,12 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2427
2758
|
} = ctx || {};
|
2428
2759
|
let content = data.content || [];
|
2429
2760
|
let zoneCompound = rootDroppableId;
|
2430
|
-
(0,
|
2761
|
+
(0, import_react18.useEffect)(() => {
|
2431
2762
|
if (areaId && registerZoneArea) {
|
2432
2763
|
registerZoneArea(areaId);
|
2433
2764
|
}
|
2434
2765
|
}, [areaId]);
|
2435
|
-
(0,
|
2766
|
+
(0, import_react18.useEffect)(() => {
|
2436
2767
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
2437
2768
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
2438
2769
|
}
|
@@ -2559,14 +2890,11 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2559
2890
|
] });
|
2560
2891
|
const componentConfig = config.components[item.type];
|
2561
2892
|
const label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
2562
|
-
const canDrag = getPermissions({
|
2563
|
-
|
2893
|
+
const canDrag = appContext2.getPermissions({
|
2894
|
+
item: getItem(
|
2564
2895
|
{ index: i, zone: zoneCompound },
|
2565
2896
|
appContext2.state.data
|
2566
|
-
)
|
2567
|
-
config: appContext2.config,
|
2568
|
-
globalPermissions: appContext2.globalPermissions || {},
|
2569
|
-
appState: appContext2.state
|
2897
|
+
)
|
2570
2898
|
}).drag;
|
2571
2899
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
2572
2900
|
"div",
|
@@ -2591,7 +2919,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2591
2919
|
forceHover: hoveringComponent === componentId && !userIsDragging,
|
2592
2920
|
isDragDisabled: !canDrag,
|
2593
2921
|
indicativeHover: userIsDragging && containsZone && hoveringArea === componentId,
|
2594
|
-
isLoading: (_c = appContext2.componentState[componentId]) == null ? void 0 : _c.
|
2922
|
+
isLoading: ((_c = appContext2.componentState[componentId]) == null ? void 0 : _c.loadingCount) > 0,
|
2595
2923
|
onMount: () => {
|
2596
2924
|
ctx.registerPath({
|
2597
2925
|
index: i,
|
@@ -2691,7 +3019,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2691
3019
|
);
|
2692
3020
|
}
|
2693
3021
|
function DropZoneRender({ zone }) {
|
2694
|
-
const ctx = (0,
|
3022
|
+
const ctx = (0, import_react18.useContext)(dropZoneContext);
|
2695
3023
|
const { data, areaId = "root", config } = ctx || {};
|
2696
3024
|
let zoneCompound = rootDroppableId;
|
2697
3025
|
let content = (data == null ? void 0 : data.content) || [];
|
@@ -2723,7 +3051,7 @@ function DropZoneRender({ zone }) {
|
|
2723
3051
|
}) });
|
2724
3052
|
}
|
2725
3053
|
function DropZone(props) {
|
2726
|
-
const ctx = (0,
|
3054
|
+
const ctx = (0, import_react18.useContext)(dropZoneContext);
|
2727
3055
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
2728
3056
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadValues({}, props));
|
2729
3057
|
}
|
@@ -2732,11 +3060,11 @@ function DropZone(props) {
|
|
2732
3060
|
|
2733
3061
|
// components/Puck/index.tsx
|
2734
3062
|
init_react_import();
|
2735
|
-
var
|
3063
|
+
var import_react32 = require("react");
|
2736
3064
|
|
2737
3065
|
// lib/use-placeholder-style.ts
|
2738
3066
|
init_react_import();
|
2739
|
-
var
|
3067
|
+
var import_react19 = require("react");
|
2740
3068
|
|
2741
3069
|
// lib/get-frame.ts
|
2742
3070
|
init_react_import();
|
@@ -2751,7 +3079,7 @@ var getFrame = () => {
|
|
2751
3079
|
// lib/use-placeholder-style.ts
|
2752
3080
|
var usePlaceholderStyle = () => {
|
2753
3081
|
const queryAttr = "data-rfd-drag-handle-draggable-id";
|
2754
|
-
const [placeholderStyle, setPlaceholderStyle] = (0,
|
3082
|
+
const [placeholderStyle, setPlaceholderStyle] = (0, import_react19.useState)();
|
2755
3083
|
const onDragStartOrUpdate = (draggedItem) => {
|
2756
3084
|
var _a;
|
2757
3085
|
const draggableId = draggedItem.draggableId;
|
@@ -2804,7 +3132,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
2804
3132
|
|
2805
3133
|
// lib/use-breadcrumbs.ts
|
2806
3134
|
init_react_import();
|
2807
|
-
var
|
3135
|
+
var import_react20 = require("react");
|
2808
3136
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
2809
3137
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
2810
3138
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -2854,8 +3182,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
2854
3182
|
state: { data },
|
2855
3183
|
selectedItem
|
2856
3184
|
} = useAppContext();
|
2857
|
-
const dzContext = (0,
|
2858
|
-
return (0,
|
3185
|
+
const dzContext = (0, import_react20.useContext)(dropZoneContext);
|
3186
|
+
return (0, import_react20.useMemo)(() => {
|
2859
3187
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
2860
3188
|
selectedItem,
|
2861
3189
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -2893,6 +3221,7 @@ var SidebarSection = ({
|
|
2893
3221
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
2894
3222
|
"button",
|
2895
3223
|
{
|
3224
|
+
type: "button",
|
2896
3225
|
className: getClassName19("breadcrumbLabel"),
|
2897
3226
|
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
2898
3227
|
children: breadcrumb.label
|
@@ -2933,7 +3262,7 @@ var remove = (list, index) => {
|
|
2933
3262
|
|
2934
3263
|
// lib/reduce-related-zones.ts
|
2935
3264
|
init_react_import();
|
2936
|
-
|
3265
|
+
function reduceRelatedZones(item, data, fn) {
|
2937
3266
|
return __spreadProps(__spreadValues({}, data), {
|
2938
3267
|
zones: Object.keys(data.zones || {}).reduce(
|
2939
3268
|
(acc, key) => {
|
@@ -2947,7 +3276,7 @@ var reduceRelatedZones = (item, data, fn) => {
|
|
2947
3276
|
{}
|
2948
3277
|
)
|
2949
3278
|
});
|
2950
|
-
}
|
3279
|
+
}
|
2951
3280
|
var findRelatedByZoneId = (zoneId, data) => {
|
2952
3281
|
const [zoneParentId] = getZoneId(zoneId);
|
2953
3282
|
return (data.zones[zoneId] || []).reduce(
|
@@ -2984,7 +3313,7 @@ var removeRelatedZones = (item, data) => {
|
|
2984
3313
|
});
|
2985
3314
|
return newData;
|
2986
3315
|
};
|
2987
|
-
|
3316
|
+
function duplicateRelatedZones(item, data, newId) {
|
2988
3317
|
return reduceRelatedZones(item, data, (acc, key, zone) => {
|
2989
3318
|
const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
|
2990
3319
|
props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
|
@@ -2999,7 +3328,7 @@ var duplicateRelatedZones = (item, data, newId) => {
|
|
2999
3328
|
[`${newId}:${zoneId}`]: dupedZone
|
3000
3329
|
});
|
3001
3330
|
});
|
3002
|
-
}
|
3331
|
+
}
|
3003
3332
|
|
3004
3333
|
// reducer/data.ts
|
3005
3334
|
var zoneCache = {};
|
@@ -3023,7 +3352,7 @@ var replaceAction = (data, action) => {
|
|
3023
3352
|
})
|
3024
3353
|
});
|
3025
3354
|
};
|
3026
|
-
|
3355
|
+
function insertAction(data, action, config) {
|
3027
3356
|
const emptyComponentData = {
|
3028
3357
|
type: action.componentType,
|
3029
3358
|
props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
|
@@ -3049,8 +3378,8 @@ var insertAction = (data, action, config) => {
|
|
3049
3378
|
)
|
3050
3379
|
})
|
3051
3380
|
});
|
3052
|
-
}
|
3053
|
-
|
3381
|
+
}
|
3382
|
+
function reduceData(data, action, config) {
|
3054
3383
|
if (action.type === "insert") {
|
3055
3384
|
return insertAction(data, action, config);
|
3056
3385
|
}
|
@@ -3193,277 +3522,87 @@ var reduceData = (data, action, config) => {
|
|
3193
3522
|
return __spreadProps(__spreadValues({}, data), { zones: _zones });
|
3194
3523
|
}
|
3195
3524
|
if (action.type === "setData") {
|
3196
|
-
if (typeof action.data === "object") {
|
3197
|
-
return __spreadValues(__spreadValues({}, data), action.data);
|
3198
|
-
}
|
3199
|
-
return __spreadValues(__spreadValues({}, data), action.data(data));
|
3200
|
-
}
|
3201
|
-
return data;
|
3202
|
-
}
|
3203
|
-
|
3204
|
-
// reducer/state.ts
|
3205
|
-
init_react_import();
|
3206
|
-
var reduceUi = (ui, action) => {
|
3207
|
-
if (action.type === "setUi") {
|
3208
|
-
if (typeof action.ui === "object") {
|
3209
|
-
return __spreadValues(__spreadValues({}, ui), action.ui);
|
3210
|
-
}
|
3211
|
-
return __spreadValues(__spreadValues({}, ui), action.ui(ui));
|
3212
|
-
}
|
3213
|
-
return ui;
|
3214
|
-
};
|
3215
|
-
|
3216
|
-
// reducer/actions.tsx
|
3217
|
-
init_react_import();
|
3218
|
-
|
3219
|
-
// reducer/index.ts
|
3220
|
-
var storeInterceptor = (reducer, record, onAction) => {
|
3221
|
-
return (state, action) => {
|
3222
|
-
const newAppState = reducer(state, action);
|
3223
|
-
const isValidType = ![
|
3224
|
-
"registerZone",
|
3225
|
-
"unregisterZone",
|
3226
|
-
"setData",
|
3227
|
-
"setUi",
|
3228
|
-
"set"
|
3229
|
-
].includes(action.type);
|
3230
|
-
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
3231
|
-
if (record) record(newAppState);
|
3232
|
-
}
|
3233
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
3234
|
-
return newAppState;
|
3235
|
-
};
|
3236
|
-
};
|
3237
|
-
var setAction = (state, action) => {
|
3238
|
-
if (typeof action.state === "object") {
|
3239
|
-
return __spreadValues(__spreadValues({}, state), action.state);
|
3240
|
-
}
|
3241
|
-
return __spreadValues(__spreadValues({}, state), action.state(state));
|
3242
|
-
};
|
3243
|
-
function createReducer({
|
3244
|
-
config,
|
3245
|
-
record,
|
3246
|
-
onAction
|
3247
|
-
}) {
|
3248
|
-
return storeInterceptor(
|
3249
|
-
(state, action) => {
|
3250
|
-
const data = reduceData(state.data, action, config);
|
3251
|
-
const ui = reduceUi(state.ui, action);
|
3252
|
-
if (action.type === "set") {
|
3253
|
-
return setAction(state, action);
|
3254
|
-
}
|
3255
|
-
return { data, ui };
|
3256
|
-
},
|
3257
|
-
record,
|
3258
|
-
onAction
|
3259
|
-
);
|
3260
|
-
}
|
3261
|
-
|
3262
|
-
// lib/flush-zones.ts
|
3263
|
-
init_react_import();
|
3264
|
-
var flushZones = (appState) => {
|
3265
|
-
const containsZones = typeof appState.data.zones !== "undefined";
|
3266
|
-
if (containsZones) {
|
3267
|
-
Object.keys(appState.data.zones || {}).forEach((zone) => {
|
3268
|
-
addToZoneCache(zone, appState.data.zones[zone]);
|
3269
|
-
});
|
3270
|
-
return __spreadProps(__spreadValues({}, appState), {
|
3271
|
-
data: __spreadProps(__spreadValues({}, appState.data), {
|
3272
|
-
zones: {}
|
3273
|
-
})
|
3274
|
-
});
|
3275
|
-
}
|
3276
|
-
return appState;
|
3277
|
-
};
|
3278
|
-
|
3279
|
-
// lib/use-resolved-data.ts
|
3280
|
-
init_react_import();
|
3281
|
-
var import_react19 = require("react");
|
3282
|
-
|
3283
|
-
// lib/resolve-component-data.ts
|
3284
|
-
init_react_import();
|
3285
|
-
var cache2 = { lastChange: {} };
|
3286
|
-
var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
3287
|
-
return yield Promise.all(
|
3288
|
-
content.map((item) => __async(void 0, null, function* () {
|
3289
|
-
return yield resolveComponentData(
|
3290
|
-
item,
|
3291
|
-
config,
|
3292
|
-
onResolveStart,
|
3293
|
-
onResolveEnd
|
3294
|
-
);
|
3295
|
-
}))
|
3296
|
-
);
|
3297
|
-
});
|
3298
|
-
var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
3299
|
-
const configForItem = config.components[item.type];
|
3300
|
-
if (configForItem.resolveData) {
|
3301
|
-
const { item: oldItem = {}, resolved = {} } = cache2.lastChange[item.props.id] || {};
|
3302
|
-
if (item && item === oldItem) {
|
3303
|
-
return resolved;
|
3304
|
-
}
|
3305
|
-
const changed = getChanged(item, oldItem);
|
3306
|
-
if (onResolveStart) {
|
3307
|
-
onResolveStart(item);
|
3308
|
-
}
|
3309
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
|
3310
|
-
const { readOnly: existingReadOnly = {} } = item || {};
|
3311
|
-
const newReadOnly = __spreadValues(__spreadValues({}, existingReadOnly), readOnly);
|
3312
|
-
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
3313
|
-
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
3314
|
-
});
|
3315
|
-
if (Object.keys(newReadOnly).length) {
|
3316
|
-
resolvedItem.readOnly = newReadOnly;
|
3317
|
-
}
|
3318
|
-
cache2.lastChange[item.props.id] = {
|
3319
|
-
item,
|
3320
|
-
resolved: resolvedItem
|
3321
|
-
};
|
3322
|
-
if (onResolveEnd) {
|
3323
|
-
onResolveEnd(resolvedItem);
|
3324
|
-
}
|
3325
|
-
return resolvedItem;
|
3326
|
-
}
|
3327
|
-
return item;
|
3328
|
-
});
|
3329
|
-
|
3330
|
-
// lib/apply-dynamic-props.ts
|
3331
|
-
init_react_import();
|
3332
|
-
var applyDynamicProps = (data, dynamicProps, rootData) => {
|
3333
|
-
return __spreadProps(__spreadValues({}, data), {
|
3334
|
-
root: __spreadValues(__spreadValues({}, data.root), rootData ? rootData : {}),
|
3335
|
-
content: data.content.map((item) => {
|
3336
|
-
return dynamicProps[item.props.id] ? __spreadValues(__spreadValues({}, item), dynamicProps[item.props.id]) : item;
|
3337
|
-
}),
|
3338
|
-
zones: Object.keys(data.zones || {}).reduce((acc, zoneKey) => {
|
3339
|
-
return __spreadProps(__spreadValues({}, acc), {
|
3340
|
-
[zoneKey]: data.zones[zoneKey].map((item) => {
|
3341
|
-
return dynamicProps[item.props.id] ? __spreadValues(__spreadValues({}, item), dynamicProps[item.props.id]) : item;
|
3342
|
-
})
|
3343
|
-
});
|
3344
|
-
}, {})
|
3345
|
-
});
|
3525
|
+
if (typeof action.data === "object") {
|
3526
|
+
return __spreadValues(__spreadValues({}, data), action.data);
|
3527
|
+
}
|
3528
|
+
return __spreadValues(__spreadValues({}, data), action.data(data));
|
3529
|
+
}
|
3530
|
+
return data;
|
3531
|
+
}
|
3532
|
+
|
3533
|
+
// reducer/state.ts
|
3534
|
+
init_react_import();
|
3535
|
+
var reduceUi = (ui, action) => {
|
3536
|
+
if (action.type === "setUi") {
|
3537
|
+
if (typeof action.ui === "object") {
|
3538
|
+
return __spreadValues(__spreadValues({}, ui), action.ui);
|
3539
|
+
}
|
3540
|
+
return __spreadValues(__spreadValues({}, ui), action.ui(ui));
|
3541
|
+
}
|
3542
|
+
return ui;
|
3346
3543
|
};
|
3347
3544
|
|
3348
|
-
//
|
3545
|
+
// reducer/actions.tsx
|
3349
3546
|
init_react_import();
|
3350
|
-
|
3351
|
-
|
3352
|
-
|
3353
|
-
|
3354
|
-
|
3355
|
-
|
3356
|
-
|
3357
|
-
|
3358
|
-
|
3359
|
-
|
3360
|
-
|
3361
|
-
|
3362
|
-
|
3363
|
-
|
3364
|
-
cache3.lastChange = {
|
3365
|
-
original: data.root,
|
3366
|
-
resolved: resolvedRoot
|
3367
|
-
};
|
3368
|
-
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
3369
|
-
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
3370
|
-
});
|
3547
|
+
|
3548
|
+
// reducer/index.ts
|
3549
|
+
function storeInterceptor(reducer, record, onAction) {
|
3550
|
+
return (state, action) => {
|
3551
|
+
const newAppState = reducer(state, action);
|
3552
|
+
const isValidType = ![
|
3553
|
+
"registerZone",
|
3554
|
+
"unregisterZone",
|
3555
|
+
"setData",
|
3556
|
+
"setUi",
|
3557
|
+
"set"
|
3558
|
+
].includes(action.type);
|
3559
|
+
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
3560
|
+
if (record) record(newAppState);
|
3371
3561
|
}
|
3372
|
-
|
3373
|
-
|
3562
|
+
onAction == null ? void 0 : onAction(action, newAppState, state);
|
3563
|
+
return newAppState;
|
3564
|
+
};
|
3374
3565
|
}
|
3375
|
-
|
3376
|
-
|
3377
|
-
|
3378
|
-
|
3379
|
-
|
3380
|
-
|
3381
|
-
|
3382
|
-
|
3383
|
-
|
3384
|
-
|
3385
|
-
|
3386
|
-
|
3387
|
-
|
3388
|
-
|
3566
|
+
var setAction = (state, action) => {
|
3567
|
+
if (typeof action.state === "object") {
|
3568
|
+
return __spreadValues(__spreadValues({}, state), action.state);
|
3569
|
+
}
|
3570
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
3571
|
+
};
|
3572
|
+
function createReducer({
|
3573
|
+
config,
|
3574
|
+
record,
|
3575
|
+
onAction
|
3576
|
+
}) {
|
3577
|
+
return storeInterceptor(
|
3578
|
+
(state, action) => {
|
3579
|
+
const data = reduceData(state.data, action, config);
|
3580
|
+
const ui = reduceUi(state.ui, action);
|
3581
|
+
if (action.type === "set") {
|
3582
|
+
return setAction(state, action);
|
3389
3583
|
}
|
3390
|
-
|
3391
|
-
setComponentState((prev) => __spreadProps(__spreadValues({}, prev), {
|
3392
|
-
[id]: __spreadProps(__spreadValues({}, prev[id]), { loading })
|
3393
|
-
}));
|
3394
|
-
delete deferredSetStates[id];
|
3395
|
-
}, defer2);
|
3584
|
+
return { data, ui };
|
3396
3585
|
},
|
3397
|
-
|
3586
|
+
record,
|
3587
|
+
onAction
|
3398
3588
|
);
|
3399
|
-
|
3400
|
-
|
3401
|
-
|
3402
|
-
|
3403
|
-
|
3589
|
+
}
|
3590
|
+
|
3591
|
+
// lib/flush-zones.ts
|
3592
|
+
init_react_import();
|
3593
|
+
var flushZones = (appState) => {
|
3594
|
+
const containsZones = typeof appState.data.zones !== "undefined";
|
3595
|
+
if (containsZones) {
|
3596
|
+
Object.keys(appState.data.zones || {}).forEach((zone) => {
|
3597
|
+
addToZoneCache(zone, appState.data.zones[zone]);
|
3404
3598
|
});
|
3405
|
-
|
3406
|
-
|
3407
|
-
|
3408
|
-
|
3409
|
-
dynamicRoot
|
3410
|
-
);
|
3411
|
-
const processedAppState = __spreadProps(__spreadValues({}, appState), { data: processed });
|
3412
|
-
const containsChanges = JSON.stringify(appState) !== JSON.stringify(processedAppState);
|
3413
|
-
if (containsChanges) {
|
3414
|
-
dispatch({
|
3415
|
-
type: "set",
|
3416
|
-
state: (prev) => __spreadProps(__spreadValues({}, prev), {
|
3417
|
-
data: applyDynamicProps(prev.data, dynamicDataMap, dynamicRoot),
|
3418
|
-
ui: resolverKey > 0 ? __spreadValues(__spreadValues({}, prev.ui), newAppState.ui) : prev.ui
|
3419
|
-
}),
|
3420
|
-
recordHistory: resolverKey > 0
|
3421
|
-
});
|
3422
|
-
}
|
3423
|
-
};
|
3424
|
-
const promises = [];
|
3425
|
-
promises.push(
|
3426
|
-
(() => __async(void 0, null, function* () {
|
3427
|
-
setComponentLoading("puck-root", true, 50);
|
3428
|
-
const dynamicRoot = yield resolveRootData(newData, config);
|
3429
|
-
applyIfChange({}, dynamicRoot);
|
3430
|
-
setComponentLoading("puck-root", false);
|
3431
|
-
}))()
|
3432
|
-
);
|
3433
|
-
flatContent.forEach((item) => {
|
3434
|
-
promises.push(
|
3435
|
-
(() => __async(void 0, null, function* () {
|
3436
|
-
const dynamicData = yield resolveComponentData(
|
3437
|
-
item,
|
3438
|
-
config,
|
3439
|
-
(item2) => {
|
3440
|
-
setComponentLoading(item2.props.id, true, 50);
|
3441
|
-
},
|
3442
|
-
(item2) => {
|
3443
|
-
deferredSetStates[item2.props.id];
|
3444
|
-
setComponentLoading(item2.props.id, false);
|
3445
|
-
}
|
3446
|
-
);
|
3447
|
-
const dynamicDataMap = { [item.props.id]: dynamicData };
|
3448
|
-
applyIfChange(dynamicDataMap);
|
3449
|
-
}))()
|
3450
|
-
);
|
3599
|
+
return __spreadProps(__spreadValues({}, appState), {
|
3600
|
+
data: __spreadProps(__spreadValues({}, appState.data), {
|
3601
|
+
zones: {}
|
3602
|
+
})
|
3451
3603
|
});
|
3452
|
-
|
3453
|
-
|
3454
|
-
(0, import_react19.useEffect)(() => {
|
3455
|
-
runResolvers();
|
3456
|
-
}, [resolverKey]);
|
3457
|
-
const resolveData = (0, import_react19.useCallback)((newAppState2 = appState) => {
|
3458
|
-
setResolverState((curr) => ({
|
3459
|
-
resolverKey: curr.resolverKey + 1,
|
3460
|
-
newAppState: newAppState2
|
3461
|
-
}));
|
3462
|
-
}, []);
|
3463
|
-
return {
|
3464
|
-
resolveData,
|
3465
|
-
componentState
|
3466
|
-
};
|
3604
|
+
}
|
3605
|
+
return appState;
|
3467
3606
|
};
|
3468
3607
|
|
3469
3608
|
// components/MenuBar/index.tsx
|
@@ -3476,15 +3615,14 @@ var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpe
|
|
3476
3615
|
// components/MenuBar/index.tsx
|
3477
3616
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
3478
3617
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
3479
|
-
|
3618
|
+
function MenuBar({
|
3480
3619
|
appState,
|
3481
|
-
data = { content: [], root: {} },
|
3482
3620
|
dispatch,
|
3483
3621
|
menuOpen = false,
|
3484
3622
|
onPublish,
|
3485
3623
|
renderHeaderActions,
|
3486
3624
|
setMenuOpen
|
3487
|
-
})
|
3625
|
+
}) {
|
3488
3626
|
const {
|
3489
3627
|
history: { back, forward, historyStore }
|
3490
3628
|
} = useAppContext();
|
@@ -3515,7 +3653,7 @@ var MenuBar = ({
|
|
3515
3653
|
] })
|
3516
3654
|
}
|
3517
3655
|
);
|
3518
|
-
}
|
3656
|
+
}
|
3519
3657
|
|
3520
3658
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
3521
3659
|
init_react_import();
|
@@ -3529,7 +3667,7 @@ init_react_import();
|
|
3529
3667
|
var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
|
3530
3668
|
|
3531
3669
|
// components/Puck/components/Fields/index.tsx
|
3532
|
-
var
|
3670
|
+
var import_react21 = require("react");
|
3533
3671
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
3534
3672
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
3535
3673
|
var defaultPageFields = {
|
@@ -3548,15 +3686,15 @@ var useResolvedFields = () => {
|
|
3548
3686
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
3549
3687
|
const defaultFields = selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields;
|
3550
3688
|
const rootProps = data.root.props || data.root;
|
3551
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
3552
|
-
const [resolvedFields, setResolvedFields] = (0,
|
3553
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
3689
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react21.useState)({});
|
3690
|
+
const [resolvedFields, setResolvedFields] = (0, import_react21.useState)(defaultFields || {});
|
3691
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react21.useState)(false);
|
3554
3692
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
3555
3693
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
3556
|
-
const resolveFields = (0,
|
3694
|
+
const resolveFields = (0, import_react21.useCallback)(
|
3557
3695
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
3558
3696
|
var _a2, _b, _c;
|
3559
|
-
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData :
|
3697
|
+
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
3560
3698
|
const changed = getChanged(componentData, lastData);
|
3561
3699
|
setLastSelectedData(componentData);
|
3562
3700
|
if (selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields)) {
|
@@ -3589,13 +3727,13 @@ var useResolvedFields = () => {
|
|
3589
3727
|
}),
|
3590
3728
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
3591
3729
|
);
|
3592
|
-
(0,
|
3730
|
+
(0, import_react21.useEffect)(() => {
|
3593
3731
|
setFieldsLoading(true);
|
3594
3732
|
resolveFields(defaultFields).then((fields) => {
|
3595
3733
|
setResolvedFields(fields || {});
|
3596
3734
|
setFieldsLoading(false);
|
3597
3735
|
});
|
3598
|
-
}, [data, defaultFields]);
|
3736
|
+
}, [data, defaultFields, state.ui.itemSelector]);
|
3599
3737
|
return [resolvedFields, fieldsLoading];
|
3600
3738
|
};
|
3601
3739
|
var Fields = () => {
|
@@ -3607,16 +3745,16 @@ var Fields = () => {
|
|
3607
3745
|
config,
|
3608
3746
|
resolveData,
|
3609
3747
|
componentState,
|
3610
|
-
overrides
|
3611
|
-
globalPermissions
|
3748
|
+
overrides
|
3612
3749
|
} = useAppContext();
|
3613
3750
|
const { data, ui } = state;
|
3614
3751
|
const { itemSelector } = ui;
|
3615
3752
|
const [fields, fieldsResolving] = useResolvedFields();
|
3616
|
-
const
|
3753
|
+
const { getPermissions } = useAppContext();
|
3754
|
+
const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
|
3617
3755
|
const isLoading = fieldsResolving || componentResolving;
|
3618
3756
|
const rootProps = data.root.props || data.root;
|
3619
|
-
const Wrapper = (0,
|
3757
|
+
const Wrapper = (0, import_react21.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
3620
3758
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
3621
3759
|
"form",
|
3622
3760
|
{
|
@@ -3693,10 +3831,7 @@ var Fields = () => {
|
|
3693
3831
|
if (selectedItem && itemSelector) {
|
3694
3832
|
const { readOnly = {} } = selectedItem;
|
3695
3833
|
const { edit } = getPermissions({
|
3696
|
-
selectedItem
|
3697
|
-
config,
|
3698
|
-
globalPermissions: globalPermissions || {},
|
3699
|
-
appState: state
|
3834
|
+
item: selectedItem
|
3700
3835
|
});
|
3701
3836
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
3702
3837
|
AutoFieldPrivate,
|
@@ -3712,13 +3847,16 @@ var Fields = () => {
|
|
3712
3847
|
);
|
3713
3848
|
} else {
|
3714
3849
|
const readOnly = data.root.readOnly || {};
|
3850
|
+
const { edit } = getPermissions({
|
3851
|
+
root: true
|
3852
|
+
});
|
3715
3853
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
3716
3854
|
AutoFieldPrivate,
|
3717
3855
|
{
|
3718
3856
|
field,
|
3719
3857
|
name: fieldName,
|
3720
3858
|
id: `root_${fieldName}`,
|
3721
|
-
readOnly: readOnly[fieldName],
|
3859
|
+
readOnly: !edit || readOnly[fieldName],
|
3722
3860
|
value: rootProps[fieldName],
|
3723
3861
|
onChange
|
3724
3862
|
},
|
@@ -3737,7 +3875,7 @@ init_react_import();
|
|
3737
3875
|
|
3738
3876
|
// lib/use-component-list.tsx
|
3739
3877
|
init_react_import();
|
3740
|
-
var
|
3878
|
+
var import_react22 = require("react");
|
3741
3879
|
|
3742
3880
|
// components/ComponentList/index.tsx
|
3743
3881
|
init_react_import();
|
@@ -3754,12 +3892,9 @@ var ComponentListItem = ({
|
|
3754
3892
|
label,
|
3755
3893
|
index
|
3756
3894
|
}) => {
|
3757
|
-
const { overrides,
|
3895
|
+
const { overrides, getPermissions } = useAppContext();
|
3758
3896
|
const canInsert = getPermissions({
|
3759
|
-
type: name
|
3760
|
-
config,
|
3761
|
-
globalPermissions: globalPermissions || {},
|
3762
|
-
appState: state
|
3897
|
+
type: name
|
3763
3898
|
}).insert;
|
3764
3899
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
3765
3900
|
Drawer.Item,
|
@@ -3783,6 +3918,7 @@ var ComponentList = ({
|
|
3783
3918
|
title && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
3784
3919
|
"button",
|
3785
3920
|
{
|
3921
|
+
type: "button",
|
3786
3922
|
className: getClassName22("title"),
|
3787
3923
|
onClick: () => setUi({
|
3788
3924
|
componentList: __spreadProps(__spreadValues({}, state.ui.componentList), {
|
@@ -3817,8 +3953,8 @@ ComponentList.Item = ComponentListItem;
|
|
3817
3953
|
// lib/use-component-list.tsx
|
3818
3954
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
3819
3955
|
var useComponentList = (config, ui) => {
|
3820
|
-
const [componentList, setComponentList] = (0,
|
3821
|
-
(0,
|
3956
|
+
const [componentList, setComponentList] = (0, import_react22.useState)();
|
3957
|
+
(0, import_react22.useEffect)(() => {
|
3822
3958
|
var _a, _b, _c;
|
3823
3959
|
if (Object.keys(ui.componentList).length > 0) {
|
3824
3960
|
const matchedComponents = [];
|
@@ -3887,22 +4023,22 @@ var useComponentList = (config, ui) => {
|
|
3887
4023
|
};
|
3888
4024
|
|
3889
4025
|
// components/Puck/components/Components/index.tsx
|
3890
|
-
var
|
4026
|
+
var import_react23 = require("react");
|
3891
4027
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
3892
4028
|
var Components = () => {
|
3893
4029
|
const { config, state, overrides } = useAppContext();
|
3894
4030
|
const componentList = useComponentList(config, state.ui);
|
3895
|
-
const Wrapper = (0,
|
4031
|
+
const Wrapper = (0, import_react23.useMemo)(() => overrides.components || "div", [overrides]);
|
3896
4032
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ComponentList, { id: "all" }) });
|
3897
4033
|
};
|
3898
4034
|
|
3899
4035
|
// components/Puck/components/Preview/index.tsx
|
3900
4036
|
init_react_import();
|
3901
|
-
var
|
4037
|
+
var import_react25 = require("react");
|
3902
4038
|
|
3903
4039
|
// components/AutoFrame/index.tsx
|
3904
4040
|
init_react_import();
|
3905
|
-
var
|
4041
|
+
var import_react24 = require("react");
|
3906
4042
|
var import_object_hash = __toESM(require("object-hash"));
|
3907
4043
|
var import_react_dom2 = require("react-dom");
|
3908
4044
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
@@ -3948,7 +4084,7 @@ var CopyHostStyles = ({
|
|
3948
4084
|
onStylesLoaded = () => null
|
3949
4085
|
}) => {
|
3950
4086
|
const { document: doc, window: win } = useFrame();
|
3951
|
-
(0,
|
4087
|
+
(0, import_react24.useEffect)(() => {
|
3952
4088
|
if (!win || !doc) {
|
3953
4089
|
return () => {
|
3954
4090
|
};
|
@@ -4107,8 +4243,8 @@ var CopyHostStyles = ({
|
|
4107
4243
|
}, []);
|
4108
4244
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children });
|
4109
4245
|
};
|
4110
|
-
var autoFrameContext = (0,
|
4111
|
-
var useFrame = () => (0,
|
4246
|
+
var autoFrameContext = (0, import_react24.createContext)({});
|
4247
|
+
var useFrame = () => (0, import_react24.useContext)(autoFrameContext);
|
4112
4248
|
function AutoFrame(_a) {
|
4113
4249
|
var _b = _a, {
|
4114
4250
|
children,
|
@@ -4123,11 +4259,11 @@ function AutoFrame(_a) {
|
|
4123
4259
|
"id",
|
4124
4260
|
"onStylesLoaded"
|
4125
4261
|
]);
|
4126
|
-
const [loaded, setLoaded] = (0,
|
4127
|
-
const [ctx, setCtx] = (0,
|
4128
|
-
const ref = (0,
|
4129
|
-
const [mountTarget, setMountTarget] = (0,
|
4130
|
-
(0,
|
4262
|
+
const [loaded, setLoaded] = (0, import_react24.useState)(false);
|
4263
|
+
const [ctx, setCtx] = (0, import_react24.useState)({});
|
4264
|
+
const ref = (0, import_react24.useRef)(null);
|
4265
|
+
const [mountTarget, setMountTarget] = (0, import_react24.useState)();
|
4266
|
+
(0, import_react24.useEffect)(() => {
|
4131
4267
|
var _a2;
|
4132
4268
|
if (ref.current) {
|
4133
4269
|
setCtx({
|
@@ -4163,7 +4299,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
4163
4299
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
4164
4300
|
var Preview = ({ id = "puck-preview" }) => {
|
4165
4301
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
4166
|
-
const Page = (0,
|
4302
|
+
const Page = (0, import_react25.useCallback)(
|
4167
4303
|
(pageProps) => {
|
4168
4304
|
var _a, _b;
|
4169
4305
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -4172,7 +4308,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4172
4308
|
},
|
4173
4309
|
[config.root]
|
4174
4310
|
);
|
4175
|
-
const Frame = (0,
|
4311
|
+
const Frame = (0, import_react25.useMemo)(() => overrides.iframe, [overrides]);
|
4176
4312
|
const rootProps = state.data.root.props || state.data.root;
|
4177
4313
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4178
4314
|
"div",
|
@@ -4261,7 +4397,7 @@ var scrollIntoView = (el) => {
|
|
4261
4397
|
};
|
4262
4398
|
|
4263
4399
|
// components/LayerTree/index.tsx
|
4264
|
-
var
|
4400
|
+
var import_react26 = require("react");
|
4265
4401
|
|
4266
4402
|
// lib/is-child-of-zone.ts
|
4267
4403
|
init_react_import();
|
@@ -4288,7 +4424,7 @@ var LayerTree = ({
|
|
4288
4424
|
label
|
4289
4425
|
}) => {
|
4290
4426
|
const zones = data.zones || {};
|
4291
|
-
const ctx = (0,
|
4427
|
+
const ctx = (0, import_react26.useContext)(dropZoneContext);
|
4292
4428
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
4293
4429
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
4294
4430
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
@@ -4327,6 +4463,7 @@ var LayerTree = ({
|
|
4327
4463
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
4328
4464
|
"button",
|
4329
4465
|
{
|
4466
|
+
type: "button",
|
4330
4467
|
className: getClassNameLayer("clickable"),
|
4331
4468
|
onClick: () => {
|
4332
4469
|
if (isSelected) {
|
@@ -4393,13 +4530,13 @@ var LayerTree = ({
|
|
4393
4530
|
};
|
4394
4531
|
|
4395
4532
|
// components/Puck/components/Outline/index.tsx
|
4396
|
-
var
|
4533
|
+
var import_react27 = require("react");
|
4397
4534
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
4398
4535
|
var Outline = () => {
|
4399
4536
|
const { dispatch, state, overrides, config } = useAppContext();
|
4400
4537
|
const { data, ui } = state;
|
4401
4538
|
const { itemSelector } = ui;
|
4402
|
-
const setItemSelector = (0,
|
4539
|
+
const setItemSelector = (0, import_react27.useCallback)(
|
4403
4540
|
(newItemSelector) => {
|
4404
4541
|
dispatch({
|
4405
4542
|
type: "setUi",
|
@@ -4408,7 +4545,7 @@ var Outline = () => {
|
|
4408
4545
|
},
|
4409
4546
|
[]
|
4410
4547
|
);
|
4411
|
-
const Wrapper = (0,
|
4548
|
+
const Wrapper = (0, import_react27.useMemo)(() => overrides.outline || "div", [overrides]);
|
4412
4549
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
4413
4550
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
4414
4551
|
LayerTree,
|
@@ -4454,14 +4591,14 @@ function usePuckHistory({
|
|
4454
4591
|
if (historyStore.hasPast) {
|
4455
4592
|
dispatch({
|
4456
4593
|
type: "set",
|
4457
|
-
state: ((_a = historyStore.prevHistory) == null ? void 0 : _a.
|
4594
|
+
state: ((_a = historyStore.prevHistory) == null ? void 0 : _a.state) || initialAppState
|
4458
4595
|
});
|
4459
4596
|
historyStore.back();
|
4460
4597
|
}
|
4461
4598
|
};
|
4462
4599
|
const forward = () => {
|
4463
4600
|
if (historyStore.nextHistory) {
|
4464
|
-
dispatch({ type: "set", state: historyStore.nextHistory.
|
4601
|
+
dispatch({ type: "set", state: historyStore.nextHistory.state });
|
4465
4602
|
historyStore.forward();
|
4466
4603
|
}
|
4467
4604
|
};
|
@@ -4469,7 +4606,7 @@ function usePuckHistory({
|
|
4469
4606
|
var _a;
|
4470
4607
|
dispatch({
|
4471
4608
|
type: "set",
|
4472
|
-
state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.
|
4609
|
+
state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || initialAppState
|
4473
4610
|
});
|
4474
4611
|
historyStore.setHistories(histories);
|
4475
4612
|
};
|
@@ -4478,7 +4615,7 @@ function usePuckHistory({
|
|
4478
4615
|
if (historyStore.histories.length > index) {
|
4479
4616
|
dispatch({
|
4480
4617
|
type: "set",
|
4481
|
-
state: ((_a = historyStore.histories[index]) == null ? void 0 : _a.
|
4618
|
+
state: ((_a = historyStore.histories[index]) == null ? void 0 : _a.state) || initialAppState
|
4482
4619
|
});
|
4483
4620
|
historyStore.setHistoryIndex(index);
|
4484
4621
|
}
|
@@ -4497,19 +4634,19 @@ function usePuckHistory({
|
|
4497
4634
|
|
4498
4635
|
// lib/use-history-store.ts
|
4499
4636
|
init_react_import();
|
4500
|
-
var
|
4637
|
+
var import_react28 = require("react");
|
4501
4638
|
var import_use_debounce3 = require("use-debounce");
|
4502
|
-
var EMPTY_HISTORY_INDEX =
|
4639
|
+
var EMPTY_HISTORY_INDEX = 0;
|
4503
4640
|
function useHistoryStore(initialHistory) {
|
4504
4641
|
var _a, _b;
|
4505
|
-
const [histories, setHistories] = (0,
|
4642
|
+
const [histories, setHistories] = (0, import_react28.useState)(
|
4506
4643
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
4507
4644
|
);
|
4508
4645
|
const updateHistories = (histories2) => {
|
4509
4646
|
setHistories(histories2);
|
4510
4647
|
setIndex(histories2.length - 1);
|
4511
4648
|
};
|
4512
|
-
const [index, setIndex] = (0,
|
4649
|
+
const [index, setIndex] = (0, import_react28.useState)(
|
4513
4650
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
4514
4651
|
);
|
4515
4652
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -4517,9 +4654,9 @@ function useHistoryStore(initialHistory) {
|
|
4517
4654
|
const currentHistory = histories[index];
|
4518
4655
|
const nextHistory = hasFuture ? histories[index + 1] : null;
|
4519
4656
|
const prevHistory = hasPast ? histories[index - 1] : null;
|
4520
|
-
const record = (0, import_use_debounce3.useDebouncedCallback)((
|
4657
|
+
const record = (0, import_use_debounce3.useDebouncedCallback)((state) => {
|
4521
4658
|
const history = {
|
4522
|
-
|
4659
|
+
state,
|
4523
4660
|
id: generateId("history")
|
4524
4661
|
};
|
4525
4662
|
updateHistories([...histories.slice(0, index + 1), history]);
|
@@ -4669,11 +4806,11 @@ var getBox = function getBox2(el) {
|
|
4669
4806
|
};
|
4670
4807
|
|
4671
4808
|
// components/Puck/components/Canvas/index.tsx
|
4672
|
-
var
|
4809
|
+
var import_react30 = require("react");
|
4673
4810
|
|
4674
4811
|
// components/ViewportControls/index.tsx
|
4675
4812
|
init_react_import();
|
4676
|
-
var
|
4813
|
+
var import_react29 = require("react");
|
4677
4814
|
|
4678
4815
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
4679
4816
|
init_react_import();
|
@@ -4696,8 +4833,8 @@ var ViewportButton = ({
|
|
4696
4833
|
onClick
|
4697
4834
|
}) => {
|
4698
4835
|
const { state } = useAppContext();
|
4699
|
-
const [isActive, setIsActive] = (0,
|
4700
|
-
(0,
|
4836
|
+
const [isActive, setIsActive] = (0, import_react29.useState)(false);
|
4837
|
+
(0, import_react29.useEffect)(() => {
|
4701
4838
|
setIsActive(width === state.ui.viewports.current.width);
|
4702
4839
|
}, [width, state.ui.viewports.current.width]);
|
4703
4840
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -4733,7 +4870,7 @@ var ViewportControls = ({
|
|
4733
4870
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
4734
4871
|
(option) => option.value === autoZoom
|
4735
4872
|
);
|
4736
|
-
const zoomOptions = (0,
|
4873
|
+
const zoomOptions = (0, import_react29.useMemo)(
|
4737
4874
|
() => [
|
4738
4875
|
...defaultZoomOptions,
|
4739
4876
|
...defaultsContainAutoZoom ? [] : [
|
@@ -4816,7 +4953,7 @@ var ViewportControls = ({
|
|
4816
4953
|
|
4817
4954
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
4818
4955
|
init_react_import();
|
4819
|
-
var styles_module_default21 = { "PuckCanvas": "
|
4956
|
+
var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_esbg1_1", "PuckCanvas-controls": "_PuckCanvas-controls_esbg1_16", "PuckCanvas-inner": "_PuckCanvas-inner_esbg1_21", "PuckCanvas-root": "_PuckCanvas-root_esbg1_32", "PuckCanvas--ready": "_PuckCanvas--ready_esbg1_56", "PuckCanvas-loader": "_PuckCanvas-loader_esbg1_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_esbg1_70" };
|
4820
4957
|
|
4821
4958
|
// lib/get-zoom-config.ts
|
4822
4959
|
init_react_import();
|
@@ -4856,17 +4993,17 @@ var Canvas = () => {
|
|
4856
4993
|
const { status, iframe } = useAppContext();
|
4857
4994
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
4858
4995
|
const { ui } = state;
|
4859
|
-
const frameRef = (0,
|
4860
|
-
const [showTransition, setShowTransition] = (0,
|
4861
|
-
const defaultRender = (0,
|
4996
|
+
const frameRef = (0, import_react30.useRef)(null);
|
4997
|
+
const [showTransition, setShowTransition] = (0, import_react30.useState)(false);
|
4998
|
+
const defaultRender = (0, import_react30.useMemo)(() => {
|
4862
4999
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
4863
5000
|
return PuckDefault;
|
4864
5001
|
}, []);
|
4865
|
-
const CustomPreview = (0,
|
5002
|
+
const CustomPreview = (0, import_react30.useMemo)(
|
4866
5003
|
() => overrides.preview || defaultRender,
|
4867
5004
|
[overrides]
|
4868
5005
|
);
|
4869
|
-
const getFrameDimensions = (0,
|
5006
|
+
const getFrameDimensions = (0, import_react30.useCallback)(() => {
|
4870
5007
|
if (frameRef.current) {
|
4871
5008
|
const frame = frameRef.current;
|
4872
5009
|
const box = getBox(frame);
|
@@ -4874,7 +5011,7 @@ var Canvas = () => {
|
|
4874
5011
|
}
|
4875
5012
|
return { width: 0, height: 0 };
|
4876
5013
|
}, [frameRef]);
|
4877
|
-
const resetAutoZoom = (0,
|
5014
|
+
const resetAutoZoom = (0, import_react30.useCallback)(
|
4878
5015
|
(ui2 = state.ui) => {
|
4879
5016
|
if (frameRef.current) {
|
4880
5017
|
setZoomConfig(
|
@@ -4884,11 +5021,11 @@ var Canvas = () => {
|
|
4884
5021
|
},
|
4885
5022
|
[frameRef, zoomConfig, state.ui]
|
4886
5023
|
);
|
4887
|
-
(0,
|
5024
|
+
(0, import_react30.useEffect)(() => {
|
4888
5025
|
setShowTransition(false);
|
4889
5026
|
resetAutoZoom();
|
4890
5027
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
4891
|
-
(0,
|
5028
|
+
(0, import_react30.useEffect)(() => {
|
4892
5029
|
const { height: frameHeight } = getFrameDimensions();
|
4893
5030
|
if (ui.viewports.current.height === "auto") {
|
4894
5031
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -4896,7 +5033,13 @@ var Canvas = () => {
|
|
4896
5033
|
}));
|
4897
5034
|
}
|
4898
5035
|
}, [zoomConfig.zoom]);
|
4899
|
-
(0,
|
5036
|
+
(0, import_react30.useEffect)(() => {
|
5037
|
+
if (ZOOM_ON_CHANGE) {
|
5038
|
+
setShowTransition(true);
|
5039
|
+
resetAutoZoom(ui);
|
5040
|
+
}
|
5041
|
+
}, [ui.viewports.current.width]);
|
5042
|
+
(0, import_react30.useEffect)(() => {
|
4900
5043
|
const observer = new ResizeObserver(() => {
|
4901
5044
|
setShowTransition(false);
|
4902
5045
|
resetAutoZoom();
|
@@ -4908,11 +5051,18 @@ var Canvas = () => {
|
|
4908
5051
|
observer.disconnect();
|
4909
5052
|
};
|
4910
5053
|
}, []);
|
5054
|
+
const [showLoader, setShowLoader] = (0, import_react30.useState)(false);
|
5055
|
+
(0, import_react30.useEffect)(() => {
|
5056
|
+
setTimeout(() => {
|
5057
|
+
setShowLoader(true);
|
5058
|
+
}, 500);
|
5059
|
+
}, []);
|
4911
5060
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
4912
5061
|
"div",
|
4913
5062
|
{
|
4914
5063
|
className: getClassName26({
|
4915
|
-
ready: status === "READY" || !iframe.enabled
|
5064
|
+
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
5065
|
+
showLoader
|
4916
5066
|
}),
|
4917
5067
|
onClick: () => dispatch({
|
4918
5068
|
type: "setUi",
|
@@ -4945,21 +5095,24 @@ var Canvas = () => {
|
|
4945
5095
|
}
|
4946
5096
|
}
|
4947
5097
|
) }),
|
4948
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.
|
4949
|
-
|
4950
|
-
|
4951
|
-
|
4952
|
-
|
4953
|
-
|
4954
|
-
|
4955
|
-
|
4956
|
-
|
4957
|
-
|
4958
|
-
|
4959
|
-
|
4960
|
-
|
4961
|
-
|
4962
|
-
|
5098
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
5099
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
5100
|
+
"div",
|
5101
|
+
{
|
5102
|
+
className: getClassName26("root"),
|
5103
|
+
style: {
|
5104
|
+
width: iframe.enabled ? ui.viewports.current.width : "100%",
|
5105
|
+
height: zoomConfig.rootHeight,
|
5106
|
+
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
5107
|
+
transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
|
5108
|
+
overflow: iframe.enabled ? void 0 : "auto"
|
5109
|
+
},
|
5110
|
+
suppressHydrationWarning: true,
|
5111
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview, {}) })
|
5112
|
+
}
|
5113
|
+
),
|
5114
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
|
5115
|
+
] })
|
4963
5116
|
]
|
4964
5117
|
}
|
4965
5118
|
);
|
@@ -4984,7 +5137,10 @@ var insertComponent = (componentType, zone, index, {
|
|
4984
5137
|
const insertedData = insertAction(state.data, insertActionData, config);
|
4985
5138
|
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
4986
5139
|
// Dispatch insert rather set, as user's may rely on this via onAction
|
4987
|
-
|
5140
|
+
// We must always record history here so the insert is added to user history
|
5141
|
+
// If the user has defined a resolveData method, they will end up with 2 history
|
5142
|
+
// entries on insert - one for the initial insert, and one when the data resolves
|
5143
|
+
recordHistory: true
|
4988
5144
|
}));
|
4989
5145
|
const itemSelector = {
|
4990
5146
|
index,
|
@@ -4999,7 +5155,7 @@ var insertComponent = (componentType, zone, index, {
|
|
4999
5155
|
|
5000
5156
|
// lib/use-loaded-overrides.ts
|
5001
5157
|
init_react_import();
|
5002
|
-
var
|
5158
|
+
var import_react31 = require("react");
|
5003
5159
|
|
5004
5160
|
// lib/load-overrides.ts
|
5005
5161
|
init_react_import();
|
@@ -5038,7 +5194,7 @@ var useLoadedOverrides = ({
|
|
5038
5194
|
overrides,
|
5039
5195
|
plugins
|
5040
5196
|
}) => {
|
5041
|
-
return (0,
|
5197
|
+
return (0, import_react31.useMemo)(() => {
|
5042
5198
|
return loadOverrides({ overrides, plugins });
|
5043
5199
|
}, [plugins, overrides]);
|
5044
5200
|
};
|
@@ -5050,7 +5206,7 @@ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_mod
|
|
5050
5206
|
function Puck({
|
5051
5207
|
children,
|
5052
5208
|
config,
|
5053
|
-
data: initialData
|
5209
|
+
data: initialData,
|
5054
5210
|
ui: initialUi,
|
5055
5211
|
onChange,
|
5056
5212
|
onPublish,
|
@@ -5063,18 +5219,16 @@ function Puck({
|
|
5063
5219
|
headerTitle,
|
5064
5220
|
headerPath,
|
5065
5221
|
viewports = defaultViewports,
|
5066
|
-
iframe
|
5067
|
-
enabled: true
|
5068
|
-
},
|
5222
|
+
iframe: _iframe,
|
5069
5223
|
dnd,
|
5070
|
-
initialHistory
|
5224
|
+
initialHistory: _initialHistory
|
5071
5225
|
}) {
|
5072
5226
|
var _a;
|
5073
|
-
const
|
5074
|
-
|
5075
|
-
|
5076
|
-
);
|
5077
|
-
const [
|
5227
|
+
const iframe = __spreadValues({
|
5228
|
+
enabled: true,
|
5229
|
+
waitForStyles: true
|
5230
|
+
}, _iframe);
|
5231
|
+
const [generatedAppState] = (0, import_react32.useState)(() => {
|
5078
5232
|
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
5079
5233
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
5080
5234
|
let clientUiState = {};
|
@@ -5092,14 +5246,14 @@ function Puck({
|
|
5092
5246
|
})).sort((a, b) => a.diff > b.diff ? 1 : -1);
|
5093
5247
|
const closestViewport = viewportDifferences[0].key;
|
5094
5248
|
if (iframe.enabled) {
|
5095
|
-
clientUiState = {
|
5249
|
+
clientUiState = __spreadProps(__spreadValues({}, clientUiState), {
|
5096
5250
|
viewports: __spreadProps(__spreadValues({}, initial.viewports), {
|
5097
5251
|
current: __spreadProps(__spreadValues({}, initial.viewports.current), {
|
5098
5252
|
height: ((_b = (_a2 = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a2.current) == null ? void 0 : _b.height) || ((_c = viewports[closestViewport]) == null ? void 0 : _c.height) || "auto",
|
5099
5253
|
width: ((_e = (_d = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _d.current) == null ? void 0 : _e.width) || ((_f = viewports[closestViewport]) == null ? void 0 : _f.width)
|
5100
5254
|
})
|
5101
5255
|
})
|
5102
|
-
};
|
5256
|
+
});
|
5103
5257
|
}
|
5104
5258
|
}
|
5105
5259
|
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_g = initialData == null ? void 0 : initialData.root) == null ? void 0 : _g.props)) {
|
@@ -5132,20 +5286,36 @@ function Puck({
|
|
5132
5286
|
})
|
5133
5287
|
});
|
5134
5288
|
});
|
5135
|
-
const
|
5289
|
+
const { appendData = true } = _initialHistory || {};
|
5290
|
+
const histories = [
|
5291
|
+
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
5292
|
+
...appendData ? [{ state: generatedAppState }] : []
|
5293
|
+
].map((history2) => __spreadProps(__spreadValues({}, history2), {
|
5294
|
+
// Inject default data to enable partial history injections
|
5295
|
+
state: __spreadValues(__spreadValues({}, generatedAppState), history2.state)
|
5296
|
+
}));
|
5297
|
+
const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || histories.length - 1;
|
5298
|
+
const initialAppState = histories[initialHistoryIndex].state;
|
5299
|
+
const historyStore = useHistoryStore({
|
5300
|
+
histories,
|
5301
|
+
index: initialHistoryIndex
|
5302
|
+
});
|
5303
|
+
const [reducer] = (0, import_react32.useState)(
|
5304
|
+
() => createReducer({
|
5305
|
+
config,
|
5306
|
+
record: historyStore.record,
|
5307
|
+
onAction
|
5308
|
+
})
|
5309
|
+
);
|
5310
|
+
const [appState, dispatch] = (0, import_react32.useReducer)(
|
5136
5311
|
reducer,
|
5137
5312
|
flushZones(initialAppState)
|
5138
5313
|
);
|
5139
5314
|
const { data, ui } = appState;
|
5140
5315
|
const history = usePuckHistory({ dispatch, initialAppState, historyStore });
|
5141
|
-
const
|
5142
|
-
appState,
|
5143
|
-
config,
|
5144
|
-
dispatch
|
5145
|
-
);
|
5146
|
-
const [menuOpen, setMenuOpen] = (0, import_react31.useState)(false);
|
5316
|
+
const [menuOpen, setMenuOpen] = (0, import_react32.useState)(false);
|
5147
5317
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
5148
|
-
const setItemSelector = (0,
|
5318
|
+
const setItemSelector = (0, import_react32.useCallback)(
|
5149
5319
|
(newItemSelector) => {
|
5150
5320
|
if (newItemSelector === itemSelector) return;
|
5151
5321
|
dispatch({
|
@@ -5157,13 +5327,13 @@ function Puck({
|
|
5157
5327
|
[itemSelector]
|
5158
5328
|
);
|
5159
5329
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
5160
|
-
(0,
|
5330
|
+
(0, import_react32.useEffect)(() => {
|
5161
5331
|
if (onChange) onChange(data);
|
5162
5332
|
}, [data]);
|
5163
5333
|
const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
|
5164
|
-
const [draggedItem, setDraggedItem] = (0,
|
5334
|
+
const [draggedItem, setDraggedItem] = (0, import_react32.useState)();
|
5165
5335
|
const rootProps = data.root.props || data.root;
|
5166
|
-
const toggleSidebars = (0,
|
5336
|
+
const toggleSidebars = (0, import_react32.useCallback)(
|
5167
5337
|
(sidebar) => {
|
5168
5338
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
5169
5339
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -5177,7 +5347,7 @@ function Puck({
|
|
5177
5347
|
},
|
5178
5348
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
5179
5349
|
);
|
5180
|
-
(0,
|
5350
|
+
(0, import_react32.useEffect)(() => {
|
5181
5351
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
5182
5352
|
dispatch({
|
5183
5353
|
type: "setUi",
|
@@ -5200,7 +5370,7 @@ function Puck({
|
|
5200
5370
|
window.removeEventListener("resize", handleResize);
|
5201
5371
|
};
|
5202
5372
|
}, []);
|
5203
|
-
const defaultHeaderRender = (0,
|
5373
|
+
const defaultHeaderRender = (0, import_react32.useMemo)(() => {
|
5204
5374
|
if (renderHeader) {
|
5205
5375
|
console.warn(
|
5206
5376
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -5214,7 +5384,7 @@ function Puck({
|
|
5214
5384
|
}
|
5215
5385
|
return DefaultOverride;
|
5216
5386
|
}, [renderHeader]);
|
5217
|
-
const defaultHeaderActionsRender = (0,
|
5387
|
+
const defaultHeaderActionsRender = (0, import_react32.useMemo)(() => {
|
5218
5388
|
if (renderHeaderActions) {
|
5219
5389
|
console.warn(
|
5220
5390
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -5231,20 +5401,20 @@ function Puck({
|
|
5231
5401
|
overrides,
|
5232
5402
|
plugins
|
5233
5403
|
});
|
5234
|
-
const CustomPuck = (0,
|
5404
|
+
const CustomPuck = (0, import_react32.useMemo)(
|
5235
5405
|
() => loadedOverrides.puck || DefaultOverride,
|
5236
5406
|
[loadedOverrides]
|
5237
5407
|
);
|
5238
|
-
const CustomHeader = (0,
|
5408
|
+
const CustomHeader = (0, import_react32.useMemo)(
|
5239
5409
|
() => loadedOverrides.header || defaultHeaderRender,
|
5240
5410
|
[loadedOverrides]
|
5241
5411
|
);
|
5242
|
-
const CustomHeaderActions = (0,
|
5412
|
+
const CustomHeaderActions = (0, import_react32.useMemo)(
|
5243
5413
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
5244
5414
|
[loadedOverrides]
|
5245
5415
|
);
|
5246
|
-
const [mounted, setMounted] = (0,
|
5247
|
-
(0,
|
5416
|
+
const [mounted, setMounted] = (0, import_react32.useState)(false);
|
5417
|
+
(0, import_react32.useEffect)(() => {
|
5248
5418
|
setMounted(true);
|
5249
5419
|
}, []);
|
5250
5420
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
@@ -5257,8 +5427,6 @@ function Puck({
|
|
5257
5427
|
state: appState,
|
5258
5428
|
dispatch,
|
5259
5429
|
config,
|
5260
|
-
componentState,
|
5261
|
-
resolveData,
|
5262
5430
|
plugins: plugins || [],
|
5263
5431
|
overrides: loadedOverrides,
|
5264
5432
|
history,
|
@@ -5270,9 +5438,11 @@ function Puck({
|
|
5270
5438
|
duplicate: true,
|
5271
5439
|
insert: true,
|
5272
5440
|
edit: true
|
5273
|
-
}, permissions)
|
5441
|
+
}, permissions),
|
5442
|
+
getPermissions: () => ({}),
|
5443
|
+
refreshPermissions: () => null
|
5274
5444
|
},
|
5275
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5445
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(appContext.Consumer, { children: ({ resolveData }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5276
5446
|
DragDropContext,
|
5277
5447
|
{
|
5278
5448
|
autoScrollerOptions: { disabled: dnd == null ? void 0 : dnd.disableAutoScroll },
|
@@ -5362,90 +5532,115 @@ function Puck({
|
|
5362
5532
|
}
|
5363
5533
|
) }) }),
|
5364
5534
|
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
5365
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
5366
|
-
|
5367
|
-
|
5368
|
-
|
5369
|
-
|
5370
|
-
|
5371
|
-
|
5372
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5373
|
-
IconButton,
|
5535
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
5536
|
+
"div",
|
5537
|
+
{
|
5538
|
+
className: getLayoutClassName("headerToggle"),
|
5539
|
+
children: [
|
5540
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5541
|
+
"div",
|
5374
5542
|
{
|
5375
|
-
|
5376
|
-
|
5377
|
-
|
5378
|
-
|
5379
|
-
|
5543
|
+
className: getLayoutClassName(
|
5544
|
+
"leftSideBarToggle"
|
5545
|
+
),
|
5546
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5547
|
+
IconButton,
|
5548
|
+
{
|
5549
|
+
onClick: () => {
|
5550
|
+
toggleSidebars("left");
|
5551
|
+
},
|
5552
|
+
title: "Toggle left sidebar",
|
5553
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(PanelLeft, { focusable: "false" })
|
5554
|
+
}
|
5555
|
+
)
|
5380
5556
|
}
|
5381
|
-
)
|
5382
|
-
}
|
5383
|
-
),
|
5384
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5385
|
-
"div",
|
5386
|
-
{
|
5387
|
-
className: getLayoutClassName(
|
5388
|
-
"rightSideBarToggle"
|
5389
5557
|
),
|
5390
|
-
|
5391
|
-
|
5558
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5559
|
+
"div",
|
5392
5560
|
{
|
5393
|
-
|
5394
|
-
|
5395
|
-
|
5396
|
-
|
5397
|
-
|
5561
|
+
className: getLayoutClassName(
|
5562
|
+
"rightSideBarToggle"
|
5563
|
+
),
|
5564
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5565
|
+
IconButton,
|
5566
|
+
{
|
5567
|
+
onClick: () => {
|
5568
|
+
toggleSidebars("right");
|
5569
|
+
},
|
5570
|
+
title: "Toggle right sidebar",
|
5571
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(PanelRight, { focusable: "false" })
|
5572
|
+
}
|
5573
|
+
)
|
5398
5574
|
}
|
5399
5575
|
)
|
5400
|
-
|
5401
|
-
|
5402
|
-
|
5403
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5404
|
-
|
5405
|
-
|
5406
|
-
|
5407
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.
|
5408
|
-
"
|
5409
|
-
{
|
5410
|
-
|
5411
|
-
|
5412
|
-
|
5413
|
-
|
5414
|
-
|
5415
|
-
|
5416
|
-
|
5417
|
-
|
5418
|
-
|
5419
|
-
|
5420
|
-
|
5421
|
-
|
5422
|
-
|
5423
|
-
|
5424
|
-
|
5425
|
-
|
5426
|
-
|
5427
|
-
|
5428
|
-
|
5429
|
-
|
5430
|
-
|
5431
|
-
data,
|
5432
|
-
dispatch,
|
5433
|
-
onPublish,
|
5434
|
-
menuOpen,
|
5435
|
-
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5436
|
-
Button,
|
5576
|
+
]
|
5577
|
+
}
|
5578
|
+
),
|
5579
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5580
|
+
"div",
|
5581
|
+
{
|
5582
|
+
className: getLayoutClassName("headerTitle"),
|
5583
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
5584
|
+
headerTitle || rootProps.title || "Page",
|
5585
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
|
5586
|
+
" ",
|
5587
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5588
|
+
"code",
|
5589
|
+
{
|
5590
|
+
className: getLayoutClassName(
|
5591
|
+
"headerPath"
|
5592
|
+
),
|
5593
|
+
children: headerPath
|
5594
|
+
}
|
5595
|
+
)
|
5596
|
+
] })
|
5597
|
+
] })
|
5598
|
+
}
|
5599
|
+
),
|
5600
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
5601
|
+
"div",
|
5602
|
+
{
|
5603
|
+
className: getLayoutClassName("headerTools"),
|
5604
|
+
children: [
|
5605
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5606
|
+
"div",
|
5437
5607
|
{
|
5438
|
-
|
5439
|
-
|
5440
|
-
|
5441
|
-
|
5442
|
-
|
5608
|
+
className: getLayoutClassName("menuButton"),
|
5609
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5610
|
+
IconButton,
|
5611
|
+
{
|
5612
|
+
onClick: () => {
|
5613
|
+
return setMenuOpen(!menuOpen);
|
5614
|
+
},
|
5615
|
+
title: "Toggle menu bar",
|
5616
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ChevronDown, { focusable: "false" })
|
5617
|
+
}
|
5618
|
+
)
|
5443
5619
|
}
|
5444
|
-
)
|
5445
|
-
|
5446
|
-
|
5447
|
-
|
5448
|
-
|
5620
|
+
),
|
5621
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5622
|
+
MenuBar,
|
5623
|
+
{
|
5624
|
+
appState,
|
5625
|
+
dispatch,
|
5626
|
+
onPublish,
|
5627
|
+
menuOpen,
|
5628
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
5629
|
+
Button,
|
5630
|
+
{
|
5631
|
+
onClick: () => {
|
5632
|
+
onPublish && onPublish(data);
|
5633
|
+
},
|
5634
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Globe, { size: "14px" }),
|
5635
|
+
children: "Publish"
|
5636
|
+
}
|
5637
|
+
) }),
|
5638
|
+
setMenuOpen
|
5639
|
+
}
|
5640
|
+
)
|
5641
|
+
]
|
5642
|
+
}
|
5643
|
+
)
|
5449
5644
|
] }) })
|
5450
5645
|
}
|
5451
5646
|
),
|
@@ -5470,7 +5665,7 @@ function Puck({
|
|
5470
5665
|
}
|
5471
5666
|
)
|
5472
5667
|
}
|
5473
|
-
)
|
5668
|
+
) })
|
5474
5669
|
}
|
5475
5670
|
),
|
5476
5671
|
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
@@ -5619,24 +5814,15 @@ var usePuck = () => {
|
|
5619
5814
|
history,
|
5620
5815
|
dispatch,
|
5621
5816
|
selectedItem: currentItem,
|
5622
|
-
|
5817
|
+
getPermissions,
|
5818
|
+
refreshPermissions
|
5623
5819
|
} = useAppContext();
|
5624
5820
|
return {
|
5625
5821
|
appState,
|
5626
5822
|
config,
|
5627
5823
|
dispatch,
|
5628
|
-
getPermissions
|
5629
|
-
|
5630
|
-
type
|
5631
|
-
} = {}) => {
|
5632
|
-
return getPermissions({
|
5633
|
-
selectedItem: item || currentItem,
|
5634
|
-
type,
|
5635
|
-
globalPermissions: globalPermissions || {},
|
5636
|
-
config,
|
5637
|
-
appState
|
5638
|
-
});
|
5639
|
-
},
|
5824
|
+
getPermissions,
|
5825
|
+
refreshPermissions,
|
5640
5826
|
history: {
|
5641
5827
|
back: history.back,
|
5642
5828
|
forward: history.forward,
|
@@ -5663,11 +5849,13 @@ var usePuck = () => {
|
|
5663
5849
|
DropZoneProvider,
|
5664
5850
|
FieldLabel,
|
5665
5851
|
FieldLabelInternal,
|
5852
|
+
Group,
|
5666
5853
|
IconButton,
|
5667
5854
|
Puck,
|
5668
5855
|
Render,
|
5669
5856
|
dropZoneContext,
|
5670
5857
|
migrate,
|
5858
|
+
overrideKeys,
|
5671
5859
|
resolveAllData,
|
5672
5860
|
transformProps,
|
5673
5861
|
usePuck
|