@measured/puck 0.21.0-canary.ec77dd9f → 0.21.0-canary.ed10e2a4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-TC25DCTQ.mjs → chunk-JA7SEUEH.mjs} +3 -2
- package/dist/{chunk-NW2GGRCZ.mjs → chunk-UABEUL66.mjs} +102 -80
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +92 -71
- package/dist/index.mjs +2 -2
- package/dist/no-external.d.mts +1 -1
- package/dist/no-external.d.ts +1 -1
- package/dist/no-external.js +92 -71
- package/dist/no-external.mjs +2 -2
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +3 -2
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-CkSoNBF7.d.mts → walk-tree-CgWnYC1X.d.mts} +7 -5
- package/dist/{walk-tree-CkSoNBF7.d.ts → walk-tree-CgWnYC1X.d.ts} +7 -5
- package/package.json +1 -1
|
@@ -914,8 +914,9 @@ var Item = ({
|
|
|
914
914
|
);
|
|
915
915
|
};
|
|
916
916
|
var SlotRender = forwardRef(
|
|
917
|
-
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
918
|
-
|
|
917
|
+
function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
|
|
918
|
+
const El = as != null ? as : "div";
|
|
919
|
+
return /* @__PURE__ */ jsx(El, { className, style, ref, children: content.map((item) => {
|
|
919
920
|
if (!config.components[item.type]) {
|
|
920
921
|
return null;
|
|
921
922
|
}
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
walkAppState,
|
|
26
26
|
walkField,
|
|
27
27
|
walkTree
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-JA7SEUEH.mjs";
|
|
29
29
|
|
|
30
30
|
// ../../node_modules/classnames/index.js
|
|
31
31
|
var require_classnames = __commonJS({
|
|
@@ -1074,26 +1074,34 @@ var createPermissionsSlice = (set, get) => {
|
|
|
1074
1074
|
const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
|
|
1075
1075
|
const { state, permissions, config } = get();
|
|
1076
1076
|
const { cache, globalPermissions } = permissions;
|
|
1077
|
-
const
|
|
1078
|
-
var _a, _b
|
|
1077
|
+
const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
|
|
1078
|
+
var _a, _b;
|
|
1079
1079
|
const { config: config2, state: appState, setComponentLoading } = get();
|
|
1080
|
+
const itemCache = cache[item2.props.id];
|
|
1081
|
+
const nodes = appState.indexes.nodes;
|
|
1082
|
+
const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
|
|
1083
|
+
const parentNode = parentId ? nodes[parentId] : null;
|
|
1084
|
+
const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
|
|
1080
1085
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
|
1081
1086
|
if (!componentConfig) {
|
|
1082
1087
|
return;
|
|
1083
1088
|
}
|
|
1084
1089
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
1085
1090
|
if (componentConfig.resolvePermissions) {
|
|
1086
|
-
const changed = getChanged(item2,
|
|
1087
|
-
|
|
1091
|
+
const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
|
|
1092
|
+
const propsChanged = Object.values(changed).some((el) => el === true);
|
|
1093
|
+
const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
|
|
1094
|
+
if (propsChanged || parentChanged || force2) {
|
|
1088
1095
|
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
|
1089
1096
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
|
1090
1097
|
item2,
|
|
1091
1098
|
{
|
|
1092
1099
|
changed,
|
|
1093
|
-
lastPermissions: (
|
|
1100
|
+
lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
|
|
1094
1101
|
permissions: initialPermissions,
|
|
1095
1102
|
appState: makeStatePublic(appState),
|
|
1096
|
-
lastData: (
|
|
1103
|
+
lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
|
|
1104
|
+
parent: parentData
|
|
1097
1105
|
}
|
|
1098
1106
|
);
|
|
1099
1107
|
const latest = get().permissions;
|
|
@@ -1101,6 +1109,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
1101
1109
|
permissions: __spreadProps(__spreadValues({}, latest), {
|
|
1102
1110
|
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
|
1103
1111
|
[item2.props.id]: {
|
|
1112
|
+
lastParentId: parentId,
|
|
1104
1113
|
lastData: item2,
|
|
1105
1114
|
lastPermissions: resolvedPermissions
|
|
1106
1115
|
}
|
|
@@ -1114,9 +1123,9 @@ var createPermissionsSlice = (set, get) => {
|
|
|
1114
1123
|
}
|
|
1115
1124
|
}
|
|
1116
1125
|
});
|
|
1117
|
-
const
|
|
1126
|
+
const resolvePermissionsForRoot = (force2 = false) => {
|
|
1118
1127
|
const { state: appState } = get();
|
|
1119
|
-
|
|
1128
|
+
resolvePermissionsForItem(
|
|
1120
1129
|
// Shim the root data in by conforming to component data shape
|
|
1121
1130
|
{
|
|
1122
1131
|
type: "root",
|
|
@@ -1127,16 +1136,16 @@ var createPermissionsSlice = (set, get) => {
|
|
|
1127
1136
|
};
|
|
1128
1137
|
const { item, type, root } = params;
|
|
1129
1138
|
if (item) {
|
|
1130
|
-
yield
|
|
1139
|
+
yield resolvePermissionsForItem(item, force);
|
|
1131
1140
|
} else if (type) {
|
|
1132
1141
|
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
|
|
1133
|
-
yield
|
|
1142
|
+
yield resolvePermissionsForItem(item2, force);
|
|
1134
1143
|
}));
|
|
1135
1144
|
} else if (root) {
|
|
1136
|
-
|
|
1145
|
+
resolvePermissionsForRoot(force);
|
|
1137
1146
|
} else {
|
|
1138
1147
|
flattenData(state, config).map((item2) => __async(null, null, function* () {
|
|
1139
|
-
yield
|
|
1148
|
+
yield resolvePermissionsForItem(item2, force);
|
|
1140
1149
|
}));
|
|
1141
1150
|
}
|
|
1142
1151
|
});
|
|
@@ -4844,7 +4853,20 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
|
4844
4853
|
|
|
4845
4854
|
// lib/insert-component.ts
|
|
4846
4855
|
init_react_import();
|
|
4856
|
+
|
|
4857
|
+
// lib/get-selector-for-id.ts
|
|
4858
|
+
init_react_import();
|
|
4859
|
+
var getSelectorForId = (state, id) => {
|
|
4860
|
+
const node = state.indexes.nodes[id];
|
|
4861
|
+
if (!node) return;
|
|
4862
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
4863
|
+
const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
|
4864
|
+
return { zone: zoneCompound, index };
|
|
4865
|
+
};
|
|
4866
|
+
|
|
4867
|
+
// lib/insert-component.ts
|
|
4847
4868
|
var insertComponent = (componentType, zone, index, appStore) => __async(null, null, function* () {
|
|
4869
|
+
const { getState } = appStore;
|
|
4848
4870
|
const id = generateId(componentType);
|
|
4849
4871
|
const insertActionData = {
|
|
4850
4872
|
type: "insert",
|
|
@@ -4853,8 +4875,9 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
|
|
|
4853
4875
|
destinationZone: zone,
|
|
4854
4876
|
id
|
|
4855
4877
|
};
|
|
4856
|
-
const
|
|
4857
|
-
const insertedState = insertAction(
|
|
4878
|
+
const stateBefore = getState().state;
|
|
4879
|
+
const insertedState = insertAction(stateBefore, insertActionData, getState());
|
|
4880
|
+
const dispatch = getState().dispatch;
|
|
4858
4881
|
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
|
4859
4882
|
// Dispatch insert rather set, as user's may rely on this via onAction
|
|
4860
4883
|
// We must always record history here so the insert is added to user history
|
|
@@ -4862,23 +4885,21 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
|
|
|
4862
4885
|
// entries on insert - one for the initial insert, and one when the data resolves
|
|
4863
4886
|
recordHistory: true
|
|
4864
4887
|
}));
|
|
4865
|
-
const itemSelector = {
|
|
4866
|
-
index,
|
|
4867
|
-
zone
|
|
4868
|
-
};
|
|
4888
|
+
const itemSelector = { index, zone };
|
|
4869
4889
|
dispatch({ type: "setUi", ui: { itemSelector } });
|
|
4870
4890
|
const itemData = getItem(itemSelector, insertedState);
|
|
4871
|
-
if (itemData)
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4891
|
+
if (!itemData) return;
|
|
4892
|
+
const resolveComponentData2 = getState().resolveComponentData;
|
|
4893
|
+
const resolved = yield resolveComponentData2(itemData, "insert");
|
|
4894
|
+
if (!resolved.didChange) return;
|
|
4895
|
+
const latestItemSelector = getSelectorForId(getState().state, id);
|
|
4896
|
+
if (!latestItemSelector) return;
|
|
4897
|
+
dispatch({
|
|
4898
|
+
type: "replace",
|
|
4899
|
+
destinationZone: latestItemSelector.zone,
|
|
4900
|
+
destinationIndex: latestItemSelector.index,
|
|
4901
|
+
data: resolved.node
|
|
4902
|
+
});
|
|
4882
4903
|
});
|
|
4883
4904
|
|
|
4884
4905
|
// components/DragDropContext/index.tsx
|
|
@@ -5115,7 +5136,7 @@ var DragDropContextClient = ({
|
|
|
5115
5136
|
thisPreview.componentType,
|
|
5116
5137
|
thisPreview.zone,
|
|
5117
5138
|
thisPreview.index,
|
|
5118
|
-
appStore
|
|
5139
|
+
appStore
|
|
5119
5140
|
);
|
|
5120
5141
|
} else if (initialSelector.current) {
|
|
5121
5142
|
dispatch({
|
|
@@ -5499,7 +5520,8 @@ var useMinEmptyHeight = ({
|
|
|
5499
5520
|
}
|
|
5500
5521
|
}
|
|
5501
5522
|
}, [ref.current, draggedItem, onDragFinished]);
|
|
5502
|
-
|
|
5523
|
+
const returnedMinHeight = isNaN(Number(userMinEmptyHeight)) ? userMinEmptyHeight : `${userMinEmptyHeight}px`;
|
|
5524
|
+
return [prevHeight ? `${prevHeight}px` : returnedMinHeight, isAnimating];
|
|
5503
5525
|
};
|
|
5504
5526
|
|
|
5505
5527
|
// lib/assign-refs.ts
|
|
@@ -5757,16 +5779,6 @@ function setDeep(node, path, newVal) {
|
|
|
5757
5779
|
return __spreadValues(__spreadValues({}, node), newNode);
|
|
5758
5780
|
}
|
|
5759
5781
|
|
|
5760
|
-
// lib/get-selector-for-id.ts
|
|
5761
|
-
init_react_import();
|
|
5762
|
-
var getSelectorForId = (state, id) => {
|
|
5763
|
-
const node = state.indexes.nodes[id];
|
|
5764
|
-
if (!node) return;
|
|
5765
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
5766
|
-
const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
|
5767
|
-
return { zone: zoneCompound, index };
|
|
5768
|
-
};
|
|
5769
|
-
|
|
5770
5782
|
// components/InlineTextField/index.tsx
|
|
5771
5783
|
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
5772
5784
|
var getClassName18 = get_class_name_factory_default("InlineTextField", styles_module_default13);
|
|
@@ -6086,8 +6098,9 @@ var DropZoneEdit = forwardRef3(
|
|
|
6086
6098
|
disallow,
|
|
6087
6099
|
style,
|
|
6088
6100
|
className,
|
|
6089
|
-
minEmptyHeight: userMinEmptyHeight =
|
|
6090
|
-
collisionAxis
|
|
6101
|
+
minEmptyHeight: userMinEmptyHeight = "128px",
|
|
6102
|
+
collisionAxis,
|
|
6103
|
+
as
|
|
6091
6104
|
}, userRef) {
|
|
6092
6105
|
const ctx = useContext8(dropZoneContext);
|
|
6093
6106
|
const appStoreApi = useAppStoreApi();
|
|
@@ -6230,8 +6243,9 @@ var DropZoneEdit = forwardRef3(
|
|
|
6230
6243
|
userMinEmptyHeight,
|
|
6231
6244
|
ref
|
|
6232
6245
|
});
|
|
6246
|
+
const El = as != null ? as : "div";
|
|
6233
6247
|
return /* @__PURE__ */ jsx26(
|
|
6234
|
-
|
|
6248
|
+
El,
|
|
6235
6249
|
{
|
|
6236
6250
|
className: `${getClassName19({
|
|
6237
6251
|
isRootZone,
|
|
@@ -6247,7 +6261,7 @@ var DropZoneEdit = forwardRef3(
|
|
|
6247
6261
|
"data-testid": `dropzone:${zoneCompound}`,
|
|
6248
6262
|
"data-puck-dropzone": zoneCompound,
|
|
6249
6263
|
style: __spreadProps(__spreadValues({}, style), {
|
|
6250
|
-
"--min-empty-height":
|
|
6264
|
+
"--min-empty-height": minEmptyHeight,
|
|
6251
6265
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
|
6252
6266
|
}),
|
|
6253
6267
|
children: contentIdsWithPreview.map((componentId, i) => {
|
|
@@ -6294,7 +6308,7 @@ var DropZoneRenderItem = ({
|
|
|
6294
6308
|
};
|
|
6295
6309
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx26(DropZoneRender, __spreadValues({}, props));
|
|
6296
6310
|
var DropZoneRender = forwardRef3(
|
|
6297
|
-
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
6311
|
+
function DropZoneRenderInternal({ className, style, zone, as }, ref) {
|
|
6298
6312
|
const ctx = useContext8(dropZoneContext);
|
|
6299
6313
|
const { areaId = "root" } = ctx || {};
|
|
6300
6314
|
const { config, data, metadata } = useContext8(renderContext);
|
|
@@ -6307,13 +6321,14 @@ var DropZoneRender = forwardRef3(
|
|
|
6307
6321
|
}
|
|
6308
6322
|
}
|
|
6309
6323
|
}, [content]);
|
|
6324
|
+
const El = as != null ? as : "div";
|
|
6310
6325
|
if (!data || !config) {
|
|
6311
6326
|
return null;
|
|
6312
6327
|
}
|
|
6313
6328
|
if (zoneCompound !== rootDroppableId) {
|
|
6314
6329
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
6315
6330
|
}
|
|
6316
|
-
return /* @__PURE__ */ jsx26(
|
|
6331
|
+
return /* @__PURE__ */ jsx26(El, { className, style, ref, children: content.map((item) => {
|
|
6317
6332
|
const Component = config.components[item.type];
|
|
6318
6333
|
if (Component) {
|
|
6319
6334
|
return /* @__PURE__ */ jsx26(
|
|
@@ -6415,7 +6430,15 @@ var generateUsePuck = (store) => {
|
|
|
6415
6430
|
selectedItem: store.selectedItem || null,
|
|
6416
6431
|
getItemBySelector: (selector) => getItem(selector, store.state),
|
|
6417
6432
|
getItemById: (id) => store.state.indexes.nodes[id].data,
|
|
6418
|
-
getSelectorForId: (id) => getSelectorForId(store.state, id)
|
|
6433
|
+
getSelectorForId: (id) => getSelectorForId(store.state, id),
|
|
6434
|
+
getParentById: (id) => {
|
|
6435
|
+
const node = store.state.indexes.nodes[id];
|
|
6436
|
+
const parentId = node.parentId;
|
|
6437
|
+
if (parentId === null) return;
|
|
6438
|
+
const parentNode = store.state.indexes.nodes[parentId];
|
|
6439
|
+
if (!parentNode) return;
|
|
6440
|
+
return parentNode.data;
|
|
6441
|
+
}
|
|
6419
6442
|
};
|
|
6420
6443
|
return storeData;
|
|
6421
6444
|
};
|
|
@@ -6604,48 +6627,47 @@ var DefaultFields = ({
|
|
|
6604
6627
|
return /* @__PURE__ */ jsx29(Fragment8, { children });
|
|
6605
6628
|
};
|
|
6606
6629
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
|
|
6607
|
-
let currentProps;
|
|
6608
6630
|
const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
|
|
6609
6631
|
const { data, ui } = state;
|
|
6610
6632
|
const { itemSelector } = ui;
|
|
6611
6633
|
const rootProps = data.root.props || data.root;
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
} else {
|
|
6615
|
-
currentProps = rootProps;
|
|
6616
|
-
}
|
|
6617
|
-
const newProps = __spreadProps(__spreadValues({}, currentProps), {
|
|
6618
|
-
[fieldName]: value
|
|
6619
|
-
});
|
|
6634
|
+
const currentProps = selectedItem ? selectedItem.props : rootProps;
|
|
6635
|
+
const newProps = __spreadProps(__spreadValues({}, currentProps), { [fieldName]: value });
|
|
6620
6636
|
if (selectedItem && itemSelector) {
|
|
6637
|
+
const resolved = yield resolveComponentData2(
|
|
6638
|
+
__spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
|
|
6639
|
+
"replace"
|
|
6640
|
+
);
|
|
6641
|
+
const latestSelector = getSelectorForId(
|
|
6642
|
+
appStore.getState().state,
|
|
6643
|
+
selectedItem.props.id
|
|
6644
|
+
);
|
|
6645
|
+
if (!latestSelector) return;
|
|
6621
6646
|
dispatch({
|
|
6622
6647
|
type: "replace",
|
|
6623
|
-
destinationIndex:
|
|
6624
|
-
destinationZone:
|
|
6625
|
-
data:
|
|
6626
|
-
|
|
6648
|
+
destinationIndex: latestSelector.index,
|
|
6649
|
+
destinationZone: latestSelector.zone || rootDroppableId,
|
|
6650
|
+
data: resolved.node,
|
|
6651
|
+
ui: updatedUi
|
|
6652
|
+
});
|
|
6653
|
+
return;
|
|
6654
|
+
}
|
|
6655
|
+
if (data.root.props) {
|
|
6656
|
+
dispatch({
|
|
6657
|
+
type: "replaceRoot",
|
|
6658
|
+
root: (yield resolveComponentData2(
|
|
6659
|
+
__spreadProps(__spreadValues({}, data.root), { props: newProps }),
|
|
6627
6660
|
"replace"
|
|
6628
6661
|
)).node,
|
|
6629
|
-
ui: updatedUi
|
|
6662
|
+
ui: __spreadValues(__spreadValues({}, ui), updatedUi),
|
|
6663
|
+
recordHistory: true
|
|
6630
6664
|
});
|
|
6631
|
-
|
|
6632
|
-
if (data.root.props) {
|
|
6633
|
-
dispatch({
|
|
6634
|
-
type: "replaceRoot",
|
|
6635
|
-
root: (yield resolveComponentData2(
|
|
6636
|
-
__spreadProps(__spreadValues({}, data.root), { props: newProps }),
|
|
6637
|
-
"replace"
|
|
6638
|
-
)).node,
|
|
6639
|
-
ui: __spreadValues(__spreadValues({}, ui), updatedUi),
|
|
6640
|
-
recordHistory: true
|
|
6641
|
-
});
|
|
6642
|
-
} else {
|
|
6643
|
-
dispatch({
|
|
6644
|
-
type: "setData",
|
|
6645
|
-
data: { root: newProps }
|
|
6646
|
-
});
|
|
6647
|
-
}
|
|
6665
|
+
return;
|
|
6648
6666
|
}
|
|
6667
|
+
dispatch({
|
|
6668
|
+
type: "setData",
|
|
6669
|
+
data: { root: newProps }
|
|
6670
|
+
});
|
|
6649
6671
|
});
|
|
6650
6672
|
var FieldsChild = ({ fieldName }) => {
|
|
6651
6673
|
const field = useAppStore((s) => s.fields.fields[fieldName]);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as History, P as Permissions, a as ComponentData, C as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as FieldTransforms, h as Field, i as FieldProps, D as DropZoneProps, j as Data, k as OnAction, l as InitialHistory, n as ItemSelector } from './walk-tree-
|
|
2
|
-
export { ad as Adaptor, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, J as ComponentConfigExtensions, T as ComponentConfigParams, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, a4 as FieldMetadata, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, $ as MappedItem, a7 as NumberField, ac as ObjectField, x as OverrideKey, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, K as RootConfig, Z as RootData, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, q as Viewport, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
1
|
+
import { H as History, P as Permissions, a as ComponentData, C as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as FieldTransforms, h as Field, i as FieldProps, D as DropZoneProps, j as Data, k as OnAction, l as InitialHistory, n as ItemSelector } from './walk-tree-CgWnYC1X.mjs';
|
|
2
|
+
export { ad as Adaptor, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, J as ComponentConfigExtensions, T as ComponentConfigParams, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, a4 as FieldMetadata, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, $ as MappedItem, a7 as NumberField, ac as ObjectField, x as OverrideKey, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, K as RootConfig, Z as RootData, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, q as Viewport, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-CgWnYC1X.mjs';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import react__default, { ReactNode, SyntheticEvent, ReactElement } from 'react';
|
|
@@ -47,6 +47,7 @@ type RefreshPermissions<UserConfig extends Config = Config> = (params?: Permissi
|
|
|
47
47
|
type Cache = Record<string, {
|
|
48
48
|
lastPermissions: Partial<Permissions>;
|
|
49
49
|
lastData: ComponentData | null;
|
|
50
|
+
lastParentId: string | null;
|
|
50
51
|
}>;
|
|
51
52
|
type PermissionsSlice = {
|
|
52
53
|
cache: Cache;
|
|
@@ -271,6 +272,7 @@ type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<User
|
|
|
271
272
|
getItemBySelector: (selector: ItemSelector) => G["UserComponentData"] | undefined;
|
|
272
273
|
getItemById: (id: string) => G["UserComponentData"] | undefined;
|
|
273
274
|
getSelectorForId: (id: string) => Required<ItemSelector> | undefined;
|
|
275
|
+
getParentById: (id: string) => ComponentData | undefined;
|
|
274
276
|
history: {
|
|
275
277
|
back: HistorySlice["back"];
|
|
276
278
|
forward: HistorySlice["forward"];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as History, P as Permissions, a as ComponentData, C as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as FieldTransforms, h as Field, i as FieldProps, D as DropZoneProps, j as Data, k as OnAction, l as InitialHistory, n as ItemSelector } from './walk-tree-
|
|
2
|
-
export { ad as Adaptor, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, J as ComponentConfigExtensions, T as ComponentConfigParams, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, a4 as FieldMetadata, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, $ as MappedItem, a7 as NumberField, ac as ObjectField, x as OverrideKey, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, K as RootConfig, Z as RootData, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, q as Viewport, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
1
|
+
import { H as History, P as Permissions, a as ComponentData, C as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as FieldTransforms, h as Field, i as FieldProps, D as DropZoneProps, j as Data, k as OnAction, l as InitialHistory, n as ItemSelector } from './walk-tree-CgWnYC1X.js';
|
|
2
|
+
export { ad as Adaptor, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, J as ComponentConfigExtensions, T as ComponentConfigParams, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, a4 as FieldMetadata, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, $ as MappedItem, a7 as NumberField, ac as ObjectField, x as OverrideKey, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, K as RootConfig, Z as RootData, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, q as Viewport, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-CgWnYC1X.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import react__default, { ReactNode, SyntheticEvent, ReactElement } from 'react';
|
|
@@ -47,6 +47,7 @@ type RefreshPermissions<UserConfig extends Config = Config> = (params?: Permissi
|
|
|
47
47
|
type Cache = Record<string, {
|
|
48
48
|
lastPermissions: Partial<Permissions>;
|
|
49
49
|
lastData: ComponentData | null;
|
|
50
|
+
lastParentId: string | null;
|
|
50
51
|
}>;
|
|
51
52
|
type PermissionsSlice = {
|
|
52
53
|
cache: Cache;
|
|
@@ -271,6 +272,7 @@ type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<User
|
|
|
271
272
|
getItemBySelector: (selector: ItemSelector) => G["UserComponentData"] | undefined;
|
|
272
273
|
getItemById: (id: string) => G["UserComponentData"] | undefined;
|
|
273
274
|
getSelectorForId: (id: string) => Required<ItemSelector> | undefined;
|
|
275
|
+
getParentById: (id: string) => ComponentData | undefined;
|
|
274
276
|
history: {
|
|
275
277
|
back: HistorySlice["back"];
|
|
276
278
|
forward: HistorySlice["forward"];
|
package/dist/index.js
CHANGED
|
@@ -1979,26 +1979,34 @@ var createPermissionsSlice = (set, get) => {
|
|
|
1979
1979
|
const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
|
|
1980
1980
|
const { state, permissions, config } = get();
|
|
1981
1981
|
const { cache: cache2, globalPermissions } = permissions;
|
|
1982
|
-
const
|
|
1983
|
-
var _a, _b
|
|
1982
|
+
const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
|
|
1983
|
+
var _a, _b;
|
|
1984
1984
|
const { config: config2, state: appState, setComponentLoading } = get();
|
|
1985
|
+
const itemCache = cache2[item2.props.id];
|
|
1986
|
+
const nodes = appState.indexes.nodes;
|
|
1987
|
+
const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
|
|
1988
|
+
const parentNode = parentId ? nodes[parentId] : null;
|
|
1989
|
+
const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
|
|
1985
1990
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
|
1986
1991
|
if (!componentConfig) {
|
|
1987
1992
|
return;
|
|
1988
1993
|
}
|
|
1989
1994
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
1990
1995
|
if (componentConfig.resolvePermissions) {
|
|
1991
|
-
const changed = getChanged(item2,
|
|
1992
|
-
|
|
1996
|
+
const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
|
|
1997
|
+
const propsChanged = Object.values(changed).some((el) => el === true);
|
|
1998
|
+
const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
|
|
1999
|
+
if (propsChanged || parentChanged || force2) {
|
|
1993
2000
|
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
|
1994
2001
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
|
1995
2002
|
item2,
|
|
1996
2003
|
{
|
|
1997
2004
|
changed,
|
|
1998
|
-
lastPermissions: (
|
|
2005
|
+
lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
|
|
1999
2006
|
permissions: initialPermissions,
|
|
2000
2007
|
appState: makeStatePublic(appState),
|
|
2001
|
-
lastData: (
|
|
2008
|
+
lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
|
|
2009
|
+
parent: parentData
|
|
2002
2010
|
}
|
|
2003
2011
|
);
|
|
2004
2012
|
const latest = get().permissions;
|
|
@@ -2006,6 +2014,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2006
2014
|
permissions: __spreadProps(__spreadValues({}, latest), {
|
|
2007
2015
|
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
|
2008
2016
|
[item2.props.id]: {
|
|
2017
|
+
lastParentId: parentId,
|
|
2009
2018
|
lastData: item2,
|
|
2010
2019
|
lastPermissions: resolvedPermissions
|
|
2011
2020
|
}
|
|
@@ -2019,9 +2028,9 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2019
2028
|
}
|
|
2020
2029
|
}
|
|
2021
2030
|
});
|
|
2022
|
-
const
|
|
2031
|
+
const resolvePermissionsForRoot = (force2 = false) => {
|
|
2023
2032
|
const { state: appState } = get();
|
|
2024
|
-
|
|
2033
|
+
resolvePermissionsForItem(
|
|
2025
2034
|
// Shim the root data in by conforming to component data shape
|
|
2026
2035
|
{
|
|
2027
2036
|
type: "root",
|
|
@@ -2032,16 +2041,16 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2032
2041
|
};
|
|
2033
2042
|
const { item, type, root } = params;
|
|
2034
2043
|
if (item) {
|
|
2035
|
-
yield
|
|
2044
|
+
yield resolvePermissionsForItem(item, force);
|
|
2036
2045
|
} else if (type) {
|
|
2037
2046
|
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
|
|
2038
|
-
yield
|
|
2047
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2039
2048
|
}));
|
|
2040
2049
|
} else if (root) {
|
|
2041
|
-
|
|
2050
|
+
resolvePermissionsForRoot(force);
|
|
2042
2051
|
} else {
|
|
2043
2052
|
flattenData(state, config).map((item2) => __async(null, null, function* () {
|
|
2044
|
-
yield
|
|
2053
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2045
2054
|
}));
|
|
2046
2055
|
}
|
|
2047
2056
|
});
|
|
@@ -5233,7 +5242,8 @@ var useMinEmptyHeight = ({
|
|
|
5233
5242
|
}
|
|
5234
5243
|
}
|
|
5235
5244
|
}, [ref.current, draggedItem, onDragFinished]);
|
|
5236
|
-
|
|
5245
|
+
const returnedMinHeight = isNaN(Number(userMinEmptyHeight)) ? userMinEmptyHeight : `${userMinEmptyHeight}px`;
|
|
5246
|
+
return [prevHeight ? `${prevHeight}px` : returnedMinHeight, isAnimating];
|
|
5237
5247
|
};
|
|
5238
5248
|
|
|
5239
5249
|
// lib/assign-refs.ts
|
|
@@ -5467,8 +5477,9 @@ var Item = ({
|
|
|
5467
5477
|
);
|
|
5468
5478
|
};
|
|
5469
5479
|
var SlotRender = (0, import_react31.forwardRef)(
|
|
5470
|
-
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5471
|
-
|
|
5480
|
+
function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
|
|
5481
|
+
const El = as != null ? as : "div";
|
|
5482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(El, { className, style, ref, children: content.map((item) => {
|
|
5472
5483
|
if (!config.components[item.type]) {
|
|
5473
5484
|
return null;
|
|
5474
5485
|
}
|
|
@@ -5982,8 +5993,9 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
5982
5993
|
disallow,
|
|
5983
5994
|
style,
|
|
5984
5995
|
className,
|
|
5985
|
-
minEmptyHeight: userMinEmptyHeight =
|
|
5986
|
-
collisionAxis
|
|
5996
|
+
minEmptyHeight: userMinEmptyHeight = "128px",
|
|
5997
|
+
collisionAxis,
|
|
5998
|
+
as
|
|
5987
5999
|
}, userRef) {
|
|
5988
6000
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5989
6001
|
const appStoreApi = useAppStoreApi();
|
|
@@ -6126,8 +6138,9 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
6126
6138
|
userMinEmptyHeight,
|
|
6127
6139
|
ref
|
|
6128
6140
|
});
|
|
6141
|
+
const El = as != null ? as : "div";
|
|
6129
6142
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
6130
|
-
|
|
6143
|
+
El,
|
|
6131
6144
|
{
|
|
6132
6145
|
className: `${getClassName18({
|
|
6133
6146
|
isRootZone,
|
|
@@ -6143,7 +6156,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
6143
6156
|
"data-testid": `dropzone:${zoneCompound}`,
|
|
6144
6157
|
"data-puck-dropzone": zoneCompound,
|
|
6145
6158
|
style: __spreadProps(__spreadValues({}, style), {
|
|
6146
|
-
"--min-empty-height":
|
|
6159
|
+
"--min-empty-height": minEmptyHeight,
|
|
6147
6160
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
|
6148
6161
|
}),
|
|
6149
6162
|
children: contentIdsWithPreview.map((componentId, i) => {
|
|
@@ -6190,7 +6203,7 @@ var DropZoneRenderItem = ({
|
|
|
6190
6203
|
};
|
|
6191
6204
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneRender, __spreadValues({}, props));
|
|
6192
6205
|
var DropZoneRender = (0, import_react34.forwardRef)(
|
|
6193
|
-
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
6206
|
+
function DropZoneRenderInternal({ className, style, zone, as }, ref) {
|
|
6194
6207
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
6195
6208
|
const { areaId = "root" } = ctx || {};
|
|
6196
6209
|
const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
|
|
@@ -6203,13 +6216,14 @@ var DropZoneRender = (0, import_react34.forwardRef)(
|
|
|
6203
6216
|
}
|
|
6204
6217
|
}
|
|
6205
6218
|
}, [content]);
|
|
6219
|
+
const El = as != null ? as : "div";
|
|
6206
6220
|
if (!data || !config) {
|
|
6207
6221
|
return null;
|
|
6208
6222
|
}
|
|
6209
6223
|
if (zoneCompound !== rootDroppableId) {
|
|
6210
6224
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
6211
6225
|
}
|
|
6212
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
6226
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(El, { className, style, ref, children: content.map((item) => {
|
|
6213
6227
|
const Component = config.components[item.type];
|
|
6214
6228
|
if (Component) {
|
|
6215
6229
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
@@ -6516,6 +6530,7 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
|
6516
6530
|
// lib/insert-component.ts
|
|
6517
6531
|
init_react_import();
|
|
6518
6532
|
var insertComponent = (componentType, zone, index, appStore) => __async(null, null, function* () {
|
|
6533
|
+
const { getState } = appStore;
|
|
6519
6534
|
const id = generateId(componentType);
|
|
6520
6535
|
const insertActionData = {
|
|
6521
6536
|
type: "insert",
|
|
@@ -6524,8 +6539,9 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
|
|
|
6524
6539
|
destinationZone: zone,
|
|
6525
6540
|
id
|
|
6526
6541
|
};
|
|
6527
|
-
const
|
|
6528
|
-
const insertedState = insertAction(
|
|
6542
|
+
const stateBefore = getState().state;
|
|
6543
|
+
const insertedState = insertAction(stateBefore, insertActionData, getState());
|
|
6544
|
+
const dispatch = getState().dispatch;
|
|
6529
6545
|
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
|
6530
6546
|
// Dispatch insert rather set, as user's may rely on this via onAction
|
|
6531
6547
|
// We must always record history here so the insert is added to user history
|
|
@@ -6533,23 +6549,21 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
|
|
|
6533
6549
|
// entries on insert - one for the initial insert, and one when the data resolves
|
|
6534
6550
|
recordHistory: true
|
|
6535
6551
|
}));
|
|
6536
|
-
const itemSelector = {
|
|
6537
|
-
index,
|
|
6538
|
-
zone
|
|
6539
|
-
};
|
|
6552
|
+
const itemSelector = { index, zone };
|
|
6540
6553
|
dispatch({ type: "setUi", ui: { itemSelector } });
|
|
6541
6554
|
const itemData = getItem(itemSelector, insertedState);
|
|
6542
|
-
if (itemData)
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6555
|
+
if (!itemData) return;
|
|
6556
|
+
const resolveComponentData2 = getState().resolveComponentData;
|
|
6557
|
+
const resolved = yield resolveComponentData2(itemData, "insert");
|
|
6558
|
+
if (!resolved.didChange) return;
|
|
6559
|
+
const latestItemSelector = getSelectorForId(getState().state, id);
|
|
6560
|
+
if (!latestItemSelector) return;
|
|
6561
|
+
dispatch({
|
|
6562
|
+
type: "replace",
|
|
6563
|
+
destinationZone: latestItemSelector.zone,
|
|
6564
|
+
destinationIndex: latestItemSelector.index,
|
|
6565
|
+
data: resolved.node
|
|
6566
|
+
});
|
|
6553
6567
|
});
|
|
6554
6568
|
|
|
6555
6569
|
// components/DragDropContext/index.tsx
|
|
@@ -6786,7 +6800,7 @@ var DragDropContextClient = ({
|
|
|
6786
6800
|
thisPreview.componentType,
|
|
6787
6801
|
thisPreview.zone,
|
|
6788
6802
|
thisPreview.index,
|
|
6789
|
-
appStore
|
|
6803
|
+
appStore
|
|
6790
6804
|
);
|
|
6791
6805
|
} else if (initialSelector.current) {
|
|
6792
6806
|
dispatch({
|
|
@@ -7224,48 +7238,47 @@ var DefaultFields = ({
|
|
|
7224
7238
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
|
|
7225
7239
|
};
|
|
7226
7240
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
|
|
7227
|
-
let currentProps;
|
|
7228
7241
|
const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
|
|
7229
7242
|
const { data, ui } = state;
|
|
7230
7243
|
const { itemSelector } = ui;
|
|
7231
7244
|
const rootProps = data.root.props || data.root;
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
} else {
|
|
7235
|
-
currentProps = rootProps;
|
|
7236
|
-
}
|
|
7237
|
-
const newProps = __spreadProps(__spreadValues({}, currentProps), {
|
|
7238
|
-
[fieldName]: value
|
|
7239
|
-
});
|
|
7245
|
+
const currentProps = selectedItem ? selectedItem.props : rootProps;
|
|
7246
|
+
const newProps = __spreadProps(__spreadValues({}, currentProps), { [fieldName]: value });
|
|
7240
7247
|
if (selectedItem && itemSelector) {
|
|
7248
|
+
const resolved = yield resolveComponentData2(
|
|
7249
|
+
__spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
|
|
7250
|
+
"replace"
|
|
7251
|
+
);
|
|
7252
|
+
const latestSelector = getSelectorForId(
|
|
7253
|
+
appStore.getState().state,
|
|
7254
|
+
selectedItem.props.id
|
|
7255
|
+
);
|
|
7256
|
+
if (!latestSelector) return;
|
|
7241
7257
|
dispatch({
|
|
7242
7258
|
type: "replace",
|
|
7243
|
-
destinationIndex:
|
|
7244
|
-
destinationZone:
|
|
7245
|
-
data:
|
|
7246
|
-
|
|
7259
|
+
destinationIndex: latestSelector.index,
|
|
7260
|
+
destinationZone: latestSelector.zone || rootDroppableId,
|
|
7261
|
+
data: resolved.node,
|
|
7262
|
+
ui: updatedUi
|
|
7263
|
+
});
|
|
7264
|
+
return;
|
|
7265
|
+
}
|
|
7266
|
+
if (data.root.props) {
|
|
7267
|
+
dispatch({
|
|
7268
|
+
type: "replaceRoot",
|
|
7269
|
+
root: (yield resolveComponentData2(
|
|
7270
|
+
__spreadProps(__spreadValues({}, data.root), { props: newProps }),
|
|
7247
7271
|
"replace"
|
|
7248
7272
|
)).node,
|
|
7249
|
-
ui: updatedUi
|
|
7273
|
+
ui: __spreadValues(__spreadValues({}, ui), updatedUi),
|
|
7274
|
+
recordHistory: true
|
|
7250
7275
|
});
|
|
7251
|
-
|
|
7252
|
-
if (data.root.props) {
|
|
7253
|
-
dispatch({
|
|
7254
|
-
type: "replaceRoot",
|
|
7255
|
-
root: (yield resolveComponentData2(
|
|
7256
|
-
__spreadProps(__spreadValues({}, data.root), { props: newProps }),
|
|
7257
|
-
"replace"
|
|
7258
|
-
)).node,
|
|
7259
|
-
ui: __spreadValues(__spreadValues({}, ui), updatedUi),
|
|
7260
|
-
recordHistory: true
|
|
7261
|
-
});
|
|
7262
|
-
} else {
|
|
7263
|
-
dispatch({
|
|
7264
|
-
type: "setData",
|
|
7265
|
-
data: { root: newProps }
|
|
7266
|
-
});
|
|
7267
|
-
}
|
|
7276
|
+
return;
|
|
7268
7277
|
}
|
|
7278
|
+
dispatch({
|
|
7279
|
+
type: "setData",
|
|
7280
|
+
data: { root: newProps }
|
|
7281
|
+
});
|
|
7269
7282
|
});
|
|
7270
7283
|
var FieldsChild = ({ fieldName }) => {
|
|
7271
7284
|
const field = useAppStore((s) => s.fields.fields[fieldName]);
|
|
@@ -8731,7 +8744,15 @@ var generateUsePuck = (store) => {
|
|
|
8731
8744
|
selectedItem: store.selectedItem || null,
|
|
8732
8745
|
getItemBySelector: (selector) => getItem(selector, store.state),
|
|
8733
8746
|
getItemById: (id) => store.state.indexes.nodes[id].data,
|
|
8734
|
-
getSelectorForId: (id) => getSelectorForId(store.state, id)
|
|
8747
|
+
getSelectorForId: (id) => getSelectorForId(store.state, id),
|
|
8748
|
+
getParentById: (id) => {
|
|
8749
|
+
const node = store.state.indexes.nodes[id];
|
|
8750
|
+
const parentId = node.parentId;
|
|
8751
|
+
if (parentId === null) return;
|
|
8752
|
+
const parentNode = store.state.indexes.nodes[parentId];
|
|
8753
|
+
if (!parentNode) return;
|
|
8754
|
+
return parentNode.data;
|
|
8755
|
+
}
|
|
8735
8756
|
};
|
|
8736
8757
|
return storeData;
|
|
8737
8758
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -18,14 +18,14 @@ import {
|
|
|
18
18
|
setDeep,
|
|
19
19
|
useGetPuck,
|
|
20
20
|
usePuck
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-UABEUL66.mjs";
|
|
22
22
|
import {
|
|
23
23
|
init_react_import,
|
|
24
24
|
migrate,
|
|
25
25
|
resolveAllData,
|
|
26
26
|
transformProps,
|
|
27
27
|
walkTree
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-JA7SEUEH.mjs";
|
|
29
29
|
|
|
30
30
|
// bundle/index.ts
|
|
31
31
|
init_react_import();
|
package/dist/no-external.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ad as Adaptor, A as AppState, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, f as ComponentConfig, J as ComponentConfigExtensions, T as ComponentConfigParams, a as ComponentData, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, C as Config, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, j as Data, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, h as Field, a4 as FieldMetadata, i as FieldProps, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, g as FieldTransforms, F as Fields, H as History, I as IframeConfig, l as InitialHistory, z as ItemWithId, $ as MappedItem, M as Metadata, a7 as NumberField, ac as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, c as ResolveDataTrigger, K as RootConfig, Z as RootData, R as RootDataWithProps, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
1
|
+
export { ad as Adaptor, A as AppState, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, f as ComponentConfig, J as ComponentConfigExtensions, T as ComponentConfigParams, a as ComponentData, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, C as Config, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, j as Data, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, h as Field, a4 as FieldMetadata, i as FieldProps, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, g as FieldTransforms, F as Fields, H as History, I as IframeConfig, l as InitialHistory, z as ItemWithId, $ as MappedItem, M as Metadata, a7 as NumberField, ac as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, c as ResolveDataTrigger, K as RootConfig, Z as RootData, R as RootDataWithProps, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-CgWnYC1X.mjs';
|
|
2
2
|
export { Action, ActionBar, AutoField, Button, Drawer, DropZone, FieldLabel, Group, IconButton, Label, Puck, PuckApi, Render, UsePuckData, createUsePuck, registerOverlayPortal, renderContext, setDeep, useGetPuck, usePuck } from './index.mjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'react/jsx-runtime';
|
package/dist/no-external.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ad as Adaptor, A as AppState, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, f as ComponentConfig, J as ComponentConfigExtensions, T as ComponentConfigParams, a as ComponentData, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, C as Config, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, j as Data, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, h as Field, a4 as FieldMetadata, i as FieldProps, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, g as FieldTransforms, F as Fields, H as History, I as IframeConfig, l as InitialHistory, z as ItemWithId, $ as MappedItem, M as Metadata, a7 as NumberField, ac as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, c as ResolveDataTrigger, K as RootConfig, Z as RootData, R as RootDataWithProps, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
1
|
+
export { ad as Adaptor, A as AppState, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, f as ComponentConfig, J as ComponentConfigExtensions, T as ComponentConfigParams, a as ComponentData, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, C as Config, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, j as Data, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, h as Field, a4 as FieldMetadata, i as FieldProps, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, g as FieldTransforms, F as Fields, H as History, I as IframeConfig, l as InitialHistory, z as ItemWithId, $ as MappedItem, M as Metadata, a7 as NumberField, ac as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, c as ResolveDataTrigger, K as RootConfig, Z as RootData, R as RootDataWithProps, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-CgWnYC1X.js';
|
|
2
2
|
export { Action, ActionBar, AutoField, Button, Drawer, DropZone, FieldLabel, Group, IconButton, Label, Puck, PuckApi, Render, UsePuckData, createUsePuck, registerOverlayPortal, renderContext, setDeep, useGetPuck, usePuck } from './index.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'react/jsx-runtime';
|
package/dist/no-external.js
CHANGED
|
@@ -1979,26 +1979,34 @@ var createPermissionsSlice = (set, get) => {
|
|
|
1979
1979
|
const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
|
|
1980
1980
|
const { state, permissions, config } = get();
|
|
1981
1981
|
const { cache: cache2, globalPermissions } = permissions;
|
|
1982
|
-
const
|
|
1983
|
-
var _a, _b
|
|
1982
|
+
const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
|
|
1983
|
+
var _a, _b;
|
|
1984
1984
|
const { config: config2, state: appState, setComponentLoading } = get();
|
|
1985
|
+
const itemCache = cache2[item2.props.id];
|
|
1986
|
+
const nodes = appState.indexes.nodes;
|
|
1987
|
+
const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
|
|
1988
|
+
const parentNode = parentId ? nodes[parentId] : null;
|
|
1989
|
+
const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
|
|
1985
1990
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
|
1986
1991
|
if (!componentConfig) {
|
|
1987
1992
|
return;
|
|
1988
1993
|
}
|
|
1989
1994
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
1990
1995
|
if (componentConfig.resolvePermissions) {
|
|
1991
|
-
const changed = getChanged(item2,
|
|
1992
|
-
|
|
1996
|
+
const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
|
|
1997
|
+
const propsChanged = Object.values(changed).some((el) => el === true);
|
|
1998
|
+
const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
|
|
1999
|
+
if (propsChanged || parentChanged || force2) {
|
|
1993
2000
|
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
|
1994
2001
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
|
1995
2002
|
item2,
|
|
1996
2003
|
{
|
|
1997
2004
|
changed,
|
|
1998
|
-
lastPermissions: (
|
|
2005
|
+
lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
|
|
1999
2006
|
permissions: initialPermissions,
|
|
2000
2007
|
appState: makeStatePublic(appState),
|
|
2001
|
-
lastData: (
|
|
2008
|
+
lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
|
|
2009
|
+
parent: parentData
|
|
2002
2010
|
}
|
|
2003
2011
|
);
|
|
2004
2012
|
const latest = get().permissions;
|
|
@@ -2006,6 +2014,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2006
2014
|
permissions: __spreadProps(__spreadValues({}, latest), {
|
|
2007
2015
|
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
|
2008
2016
|
[item2.props.id]: {
|
|
2017
|
+
lastParentId: parentId,
|
|
2009
2018
|
lastData: item2,
|
|
2010
2019
|
lastPermissions: resolvedPermissions
|
|
2011
2020
|
}
|
|
@@ -2019,9 +2028,9 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2019
2028
|
}
|
|
2020
2029
|
}
|
|
2021
2030
|
});
|
|
2022
|
-
const
|
|
2031
|
+
const resolvePermissionsForRoot = (force2 = false) => {
|
|
2023
2032
|
const { state: appState } = get();
|
|
2024
|
-
|
|
2033
|
+
resolvePermissionsForItem(
|
|
2025
2034
|
// Shim the root data in by conforming to component data shape
|
|
2026
2035
|
{
|
|
2027
2036
|
type: "root",
|
|
@@ -2032,16 +2041,16 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2032
2041
|
};
|
|
2033
2042
|
const { item, type, root } = params;
|
|
2034
2043
|
if (item) {
|
|
2035
|
-
yield
|
|
2044
|
+
yield resolvePermissionsForItem(item, force);
|
|
2036
2045
|
} else if (type) {
|
|
2037
2046
|
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
|
|
2038
|
-
yield
|
|
2047
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2039
2048
|
}));
|
|
2040
2049
|
} else if (root) {
|
|
2041
|
-
|
|
2050
|
+
resolvePermissionsForRoot(force);
|
|
2042
2051
|
} else {
|
|
2043
2052
|
flattenData(state, config).map((item2) => __async(null, null, function* () {
|
|
2044
|
-
yield
|
|
2053
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2045
2054
|
}));
|
|
2046
2055
|
}
|
|
2047
2056
|
});
|
|
@@ -5233,7 +5242,8 @@ var useMinEmptyHeight = ({
|
|
|
5233
5242
|
}
|
|
5234
5243
|
}
|
|
5235
5244
|
}, [ref.current, draggedItem, onDragFinished]);
|
|
5236
|
-
|
|
5245
|
+
const returnedMinHeight = isNaN(Number(userMinEmptyHeight)) ? userMinEmptyHeight : `${userMinEmptyHeight}px`;
|
|
5246
|
+
return [prevHeight ? `${prevHeight}px` : returnedMinHeight, isAnimating];
|
|
5237
5247
|
};
|
|
5238
5248
|
|
|
5239
5249
|
// lib/assign-refs.ts
|
|
@@ -5467,8 +5477,9 @@ var Item = ({
|
|
|
5467
5477
|
);
|
|
5468
5478
|
};
|
|
5469
5479
|
var SlotRender = (0, import_react31.forwardRef)(
|
|
5470
|
-
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5471
|
-
|
|
5480
|
+
function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
|
|
5481
|
+
const El = as != null ? as : "div";
|
|
5482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(El, { className, style, ref, children: content.map((item) => {
|
|
5472
5483
|
if (!config.components[item.type]) {
|
|
5473
5484
|
return null;
|
|
5474
5485
|
}
|
|
@@ -5982,8 +5993,9 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
5982
5993
|
disallow,
|
|
5983
5994
|
style,
|
|
5984
5995
|
className,
|
|
5985
|
-
minEmptyHeight: userMinEmptyHeight =
|
|
5986
|
-
collisionAxis
|
|
5996
|
+
minEmptyHeight: userMinEmptyHeight = "128px",
|
|
5997
|
+
collisionAxis,
|
|
5998
|
+
as
|
|
5987
5999
|
}, userRef) {
|
|
5988
6000
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5989
6001
|
const appStoreApi = useAppStoreApi();
|
|
@@ -6126,8 +6138,9 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
6126
6138
|
userMinEmptyHeight,
|
|
6127
6139
|
ref
|
|
6128
6140
|
});
|
|
6141
|
+
const El = as != null ? as : "div";
|
|
6129
6142
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
6130
|
-
|
|
6143
|
+
El,
|
|
6131
6144
|
{
|
|
6132
6145
|
className: `${getClassName18({
|
|
6133
6146
|
isRootZone,
|
|
@@ -6143,7 +6156,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
|
6143
6156
|
"data-testid": `dropzone:${zoneCompound}`,
|
|
6144
6157
|
"data-puck-dropzone": zoneCompound,
|
|
6145
6158
|
style: __spreadProps(__spreadValues({}, style), {
|
|
6146
|
-
"--min-empty-height":
|
|
6159
|
+
"--min-empty-height": minEmptyHeight,
|
|
6147
6160
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
|
6148
6161
|
}),
|
|
6149
6162
|
children: contentIdsWithPreview.map((componentId, i) => {
|
|
@@ -6190,7 +6203,7 @@ var DropZoneRenderItem = ({
|
|
|
6190
6203
|
};
|
|
6191
6204
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneRender, __spreadValues({}, props));
|
|
6192
6205
|
var DropZoneRender = (0, import_react34.forwardRef)(
|
|
6193
|
-
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
6206
|
+
function DropZoneRenderInternal({ className, style, zone, as }, ref) {
|
|
6194
6207
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
6195
6208
|
const { areaId = "root" } = ctx || {};
|
|
6196
6209
|
const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
|
|
@@ -6203,13 +6216,14 @@ var DropZoneRender = (0, import_react34.forwardRef)(
|
|
|
6203
6216
|
}
|
|
6204
6217
|
}
|
|
6205
6218
|
}, [content]);
|
|
6219
|
+
const El = as != null ? as : "div";
|
|
6206
6220
|
if (!data || !config) {
|
|
6207
6221
|
return null;
|
|
6208
6222
|
}
|
|
6209
6223
|
if (zoneCompound !== rootDroppableId) {
|
|
6210
6224
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
6211
6225
|
}
|
|
6212
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
6226
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(El, { className, style, ref, children: content.map((item) => {
|
|
6213
6227
|
const Component = config.components[item.type];
|
|
6214
6228
|
if (Component) {
|
|
6215
6229
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
@@ -6516,6 +6530,7 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
|
6516
6530
|
// lib/insert-component.ts
|
|
6517
6531
|
init_react_import();
|
|
6518
6532
|
var insertComponent = (componentType, zone, index, appStore) => __async(null, null, function* () {
|
|
6533
|
+
const { getState } = appStore;
|
|
6519
6534
|
const id = generateId(componentType);
|
|
6520
6535
|
const insertActionData = {
|
|
6521
6536
|
type: "insert",
|
|
@@ -6524,8 +6539,9 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
|
|
|
6524
6539
|
destinationZone: zone,
|
|
6525
6540
|
id
|
|
6526
6541
|
};
|
|
6527
|
-
const
|
|
6528
|
-
const insertedState = insertAction(
|
|
6542
|
+
const stateBefore = getState().state;
|
|
6543
|
+
const insertedState = insertAction(stateBefore, insertActionData, getState());
|
|
6544
|
+
const dispatch = getState().dispatch;
|
|
6529
6545
|
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
|
6530
6546
|
// Dispatch insert rather set, as user's may rely on this via onAction
|
|
6531
6547
|
// We must always record history here so the insert is added to user history
|
|
@@ -6533,23 +6549,21 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
|
|
|
6533
6549
|
// entries on insert - one for the initial insert, and one when the data resolves
|
|
6534
6550
|
recordHistory: true
|
|
6535
6551
|
}));
|
|
6536
|
-
const itemSelector = {
|
|
6537
|
-
index,
|
|
6538
|
-
zone
|
|
6539
|
-
};
|
|
6552
|
+
const itemSelector = { index, zone };
|
|
6540
6553
|
dispatch({ type: "setUi", ui: { itemSelector } });
|
|
6541
6554
|
const itemData = getItem(itemSelector, insertedState);
|
|
6542
|
-
if (itemData)
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6555
|
+
if (!itemData) return;
|
|
6556
|
+
const resolveComponentData2 = getState().resolveComponentData;
|
|
6557
|
+
const resolved = yield resolveComponentData2(itemData, "insert");
|
|
6558
|
+
if (!resolved.didChange) return;
|
|
6559
|
+
const latestItemSelector = getSelectorForId(getState().state, id);
|
|
6560
|
+
if (!latestItemSelector) return;
|
|
6561
|
+
dispatch({
|
|
6562
|
+
type: "replace",
|
|
6563
|
+
destinationZone: latestItemSelector.zone,
|
|
6564
|
+
destinationIndex: latestItemSelector.index,
|
|
6565
|
+
data: resolved.node
|
|
6566
|
+
});
|
|
6553
6567
|
});
|
|
6554
6568
|
|
|
6555
6569
|
// components/DragDropContext/index.tsx
|
|
@@ -6786,7 +6800,7 @@ var DragDropContextClient = ({
|
|
|
6786
6800
|
thisPreview.componentType,
|
|
6787
6801
|
thisPreview.zone,
|
|
6788
6802
|
thisPreview.index,
|
|
6789
|
-
appStore
|
|
6803
|
+
appStore
|
|
6790
6804
|
);
|
|
6791
6805
|
} else if (initialSelector.current) {
|
|
6792
6806
|
dispatch({
|
|
@@ -7224,48 +7238,47 @@ var DefaultFields = ({
|
|
|
7224
7238
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
|
|
7225
7239
|
};
|
|
7226
7240
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
|
|
7227
|
-
let currentProps;
|
|
7228
7241
|
const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
|
|
7229
7242
|
const { data, ui } = state;
|
|
7230
7243
|
const { itemSelector } = ui;
|
|
7231
7244
|
const rootProps = data.root.props || data.root;
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
} else {
|
|
7235
|
-
currentProps = rootProps;
|
|
7236
|
-
}
|
|
7237
|
-
const newProps = __spreadProps(__spreadValues({}, currentProps), {
|
|
7238
|
-
[fieldName]: value
|
|
7239
|
-
});
|
|
7245
|
+
const currentProps = selectedItem ? selectedItem.props : rootProps;
|
|
7246
|
+
const newProps = __spreadProps(__spreadValues({}, currentProps), { [fieldName]: value });
|
|
7240
7247
|
if (selectedItem && itemSelector) {
|
|
7248
|
+
const resolved = yield resolveComponentData2(
|
|
7249
|
+
__spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
|
|
7250
|
+
"replace"
|
|
7251
|
+
);
|
|
7252
|
+
const latestSelector = getSelectorForId(
|
|
7253
|
+
appStore.getState().state,
|
|
7254
|
+
selectedItem.props.id
|
|
7255
|
+
);
|
|
7256
|
+
if (!latestSelector) return;
|
|
7241
7257
|
dispatch({
|
|
7242
7258
|
type: "replace",
|
|
7243
|
-
destinationIndex:
|
|
7244
|
-
destinationZone:
|
|
7245
|
-
data:
|
|
7246
|
-
|
|
7259
|
+
destinationIndex: latestSelector.index,
|
|
7260
|
+
destinationZone: latestSelector.zone || rootDroppableId,
|
|
7261
|
+
data: resolved.node,
|
|
7262
|
+
ui: updatedUi
|
|
7263
|
+
});
|
|
7264
|
+
return;
|
|
7265
|
+
}
|
|
7266
|
+
if (data.root.props) {
|
|
7267
|
+
dispatch({
|
|
7268
|
+
type: "replaceRoot",
|
|
7269
|
+
root: (yield resolveComponentData2(
|
|
7270
|
+
__spreadProps(__spreadValues({}, data.root), { props: newProps }),
|
|
7247
7271
|
"replace"
|
|
7248
7272
|
)).node,
|
|
7249
|
-
ui: updatedUi
|
|
7273
|
+
ui: __spreadValues(__spreadValues({}, ui), updatedUi),
|
|
7274
|
+
recordHistory: true
|
|
7250
7275
|
});
|
|
7251
|
-
|
|
7252
|
-
if (data.root.props) {
|
|
7253
|
-
dispatch({
|
|
7254
|
-
type: "replaceRoot",
|
|
7255
|
-
root: (yield resolveComponentData2(
|
|
7256
|
-
__spreadProps(__spreadValues({}, data.root), { props: newProps }),
|
|
7257
|
-
"replace"
|
|
7258
|
-
)).node,
|
|
7259
|
-
ui: __spreadValues(__spreadValues({}, ui), updatedUi),
|
|
7260
|
-
recordHistory: true
|
|
7261
|
-
});
|
|
7262
|
-
} else {
|
|
7263
|
-
dispatch({
|
|
7264
|
-
type: "setData",
|
|
7265
|
-
data: { root: newProps }
|
|
7266
|
-
});
|
|
7267
|
-
}
|
|
7276
|
+
return;
|
|
7268
7277
|
}
|
|
7278
|
+
dispatch({
|
|
7279
|
+
type: "setData",
|
|
7280
|
+
data: { root: newProps }
|
|
7281
|
+
});
|
|
7269
7282
|
});
|
|
7270
7283
|
var FieldsChild = ({ fieldName }) => {
|
|
7271
7284
|
const field = useAppStore((s) => s.fields.fields[fieldName]);
|
|
@@ -8731,7 +8744,15 @@ var generateUsePuck = (store) => {
|
|
|
8731
8744
|
selectedItem: store.selectedItem || null,
|
|
8732
8745
|
getItemBySelector: (selector) => getItem(selector, store.state),
|
|
8733
8746
|
getItemById: (id) => store.state.indexes.nodes[id].data,
|
|
8734
|
-
getSelectorForId: (id) => getSelectorForId(store.state, id)
|
|
8747
|
+
getSelectorForId: (id) => getSelectorForId(store.state, id),
|
|
8748
|
+
getParentById: (id) => {
|
|
8749
|
+
const node = store.state.indexes.nodes[id];
|
|
8750
|
+
const parentId = node.parentId;
|
|
8751
|
+
if (parentId === null) return;
|
|
8752
|
+
const parentNode = store.state.indexes.nodes[parentId];
|
|
8753
|
+
if (!parentNode) return;
|
|
8754
|
+
return parentNode.data;
|
|
8755
|
+
}
|
|
8735
8756
|
};
|
|
8736
8757
|
return storeData;
|
|
8737
8758
|
};
|
package/dist/no-external.mjs
CHANGED
|
@@ -18,14 +18,14 @@ import {
|
|
|
18
18
|
setDeep,
|
|
19
19
|
useGetPuck,
|
|
20
20
|
usePuck
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-UABEUL66.mjs";
|
|
22
22
|
import {
|
|
23
23
|
init_react_import,
|
|
24
24
|
migrate,
|
|
25
25
|
resolveAllData,
|
|
26
26
|
transformProps,
|
|
27
27
|
walkTree
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-JA7SEUEH.mjs";
|
|
29
29
|
|
|
30
30
|
// bundle/no-external.ts
|
|
31
31
|
init_react_import();
|
package/dist/rsc.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-
|
|
3
|
-
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
2
|
+
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-CgWnYC1X.mjs';
|
|
3
|
+
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-CgWnYC1X.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
package/dist/rsc.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-
|
|
3
|
-
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
2
|
+
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-CgWnYC1X.js';
|
|
3
|
+
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-CgWnYC1X.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
package/dist/rsc.js
CHANGED
|
@@ -346,8 +346,9 @@ var Item = ({
|
|
|
346
346
|
);
|
|
347
347
|
};
|
|
348
348
|
var SlotRender = (0, import_react3.forwardRef)(
|
|
349
|
-
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
350
|
-
|
|
349
|
+
function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
|
|
350
|
+
const El = as != null ? as : "div";
|
|
351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(El, { className, style, ref, children: content.map((item) => {
|
|
351
352
|
if (!config.components[item.type]) {
|
|
352
353
|
return null;
|
|
353
354
|
}
|
package/dist/rsc.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement, CSSProperties,
|
|
1
|
+
import { ReactElement, ReactNode, CSSProperties, ElementType, JSX } from 'react';
|
|
2
2
|
|
|
3
3
|
type ItemSelector = {
|
|
4
4
|
index: number;
|
|
@@ -53,7 +53,7 @@ interface ArrayField<Props extends {
|
|
|
53
53
|
} ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
|
|
54
54
|
};
|
|
55
55
|
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
56
|
-
getItemSummary?: (item: Props[0], index?: number) =>
|
|
56
|
+
getItemSummary?: (item: Props[0], index?: number) => ReactNode;
|
|
57
57
|
max?: number;
|
|
58
58
|
min?: number;
|
|
59
59
|
}
|
|
@@ -80,7 +80,7 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
80
80
|
placeholder?: string;
|
|
81
81
|
adaptor: Adaptor<any, any, Props>;
|
|
82
82
|
adaptorParams?: object;
|
|
83
|
-
getItemSummary: (item: NotUndefined<Props>, index?: number) =>
|
|
83
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
84
84
|
};
|
|
85
85
|
type CacheOpts = {
|
|
86
86
|
enabled?: boolean;
|
|
@@ -97,7 +97,7 @@ interface ExternalField<Props extends any = {
|
|
|
97
97
|
}) => Promise<any[] | null>;
|
|
98
98
|
mapProp?: (value: any) => Props;
|
|
99
99
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
100
|
-
getItemSummary?: (item: NotUndefined<Props>, index?: number) =>
|
|
100
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
101
101
|
showSearch?: boolean;
|
|
102
102
|
renderFooter?: (props: {
|
|
103
103
|
items: any[];
|
|
@@ -146,9 +146,10 @@ type DropZoneProps = {
|
|
|
146
146
|
allow?: string[];
|
|
147
147
|
disallow?: string[];
|
|
148
148
|
style?: CSSProperties;
|
|
149
|
-
minEmptyHeight?: number;
|
|
149
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
150
150
|
className?: string;
|
|
151
151
|
collisionAxis?: DragAxis;
|
|
152
|
+
as?: ElementType;
|
|
152
153
|
};
|
|
153
154
|
|
|
154
155
|
type PuckContext = {
|
|
@@ -239,6 +240,7 @@ UserField extends BaseField = {}> = {
|
|
|
239
240
|
permissions: Partial<Permissions>;
|
|
240
241
|
appState: AppState;
|
|
241
242
|
lastData: DataShape | null;
|
|
243
|
+
parent: ComponentData | null;
|
|
242
244
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
243
245
|
metadata?: ComponentMetadata;
|
|
244
246
|
} & ComponentConfigExtensions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement, CSSProperties,
|
|
1
|
+
import { ReactElement, ReactNode, CSSProperties, ElementType, JSX } from 'react';
|
|
2
2
|
|
|
3
3
|
type ItemSelector = {
|
|
4
4
|
index: number;
|
|
@@ -53,7 +53,7 @@ interface ArrayField<Props extends {
|
|
|
53
53
|
} ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
|
|
54
54
|
};
|
|
55
55
|
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
56
|
-
getItemSummary?: (item: Props[0], index?: number) =>
|
|
56
|
+
getItemSummary?: (item: Props[0], index?: number) => ReactNode;
|
|
57
57
|
max?: number;
|
|
58
58
|
min?: number;
|
|
59
59
|
}
|
|
@@ -80,7 +80,7 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
80
80
|
placeholder?: string;
|
|
81
81
|
adaptor: Adaptor<any, any, Props>;
|
|
82
82
|
adaptorParams?: object;
|
|
83
|
-
getItemSummary: (item: NotUndefined<Props>, index?: number) =>
|
|
83
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
84
84
|
};
|
|
85
85
|
type CacheOpts = {
|
|
86
86
|
enabled?: boolean;
|
|
@@ -97,7 +97,7 @@ interface ExternalField<Props extends any = {
|
|
|
97
97
|
}) => Promise<any[] | null>;
|
|
98
98
|
mapProp?: (value: any) => Props;
|
|
99
99
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
100
|
-
getItemSummary?: (item: NotUndefined<Props>, index?: number) =>
|
|
100
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
101
101
|
showSearch?: boolean;
|
|
102
102
|
renderFooter?: (props: {
|
|
103
103
|
items: any[];
|
|
@@ -146,9 +146,10 @@ type DropZoneProps = {
|
|
|
146
146
|
allow?: string[];
|
|
147
147
|
disallow?: string[];
|
|
148
148
|
style?: CSSProperties;
|
|
149
|
-
minEmptyHeight?: number;
|
|
149
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
150
150
|
className?: string;
|
|
151
151
|
collisionAxis?: DragAxis;
|
|
152
|
+
as?: ElementType;
|
|
152
153
|
};
|
|
153
154
|
|
|
154
155
|
type PuckContext = {
|
|
@@ -239,6 +240,7 @@ UserField extends BaseField = {}> = {
|
|
|
239
240
|
permissions: Partial<Permissions>;
|
|
240
241
|
appState: AppState;
|
|
241
242
|
lastData: DataShape | null;
|
|
243
|
+
parent: ComponentData | null;
|
|
242
244
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
243
245
|
metadata?: ComponentMetadata;
|
|
244
246
|
} & ComponentConfigExtensions;
|
package/package.json
CHANGED