@measured/puck 0.19.0-canary.896a6279 → 0.19.0-canary.a6dd529f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{chunk-LT6HN46T.mjs → chunk-ZOHJNF5K.mjs} +187 -110
- package/dist/index.css +44 -38
- package/dist/index.d.mts +16 -6
- package/dist/index.d.ts +16 -6
- package/dist/index.js +221 -76
- package/dist/index.mjs +76 -7
- package/dist/{resolve-all-data-Cs8PfTrg.d.mts → resolve-all-data-BFRAghCj.d.mts} +5 -1
- package/dist/{resolve-all-data-Cs8PfTrg.d.ts → resolve-all-data-BFRAghCj.d.ts} +5 -1
- package/dist/rsc.css +12 -11
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +123 -69
- package/dist/rsc.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -176,6 +176,7 @@ __export(core_exports, {
|
|
176
176
|
Puck: () => Puck,
|
177
177
|
Render: () => Render,
|
178
178
|
createUsePuck: () => createUsePuck,
|
179
|
+
mapSlots: () => mapSlotsPublic,
|
179
180
|
migrate: () => migrate,
|
180
181
|
overrideKeys: () => overrideKeys,
|
181
182
|
renderContext: () => renderContext,
|
@@ -308,7 +309,7 @@ init_react_import();
|
|
308
309
|
|
309
310
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
310
311
|
init_react_import();
|
311
|
-
var styles_module_default2 = { "InputWrapper": "
|
312
|
+
var styles_module_default2 = { "InputWrapper": "_InputWrapper_4xor1_1", "Input-label": "_Input-label_4xor1_5", "Input-labelIcon": "_Input-labelIcon_4xor1_14", "Input-disabledIcon": "_Input-disabledIcon_4xor1_21", "Input-input": "_Input-input_4xor1_26", "Input": "_Input_4xor1_1", "Input--readOnly": "_Input--readOnly_4xor1_75", "Input-radioGroupItems": "_Input-radioGroupItems_4xor1_86", "Input-radio": "_Input-radio_4xor1_86", "Input-radioInner": "_Input-radioInner_4xor1_103", "Input-radioInput": "_Input-radioInput_4xor1_148" };
|
312
313
|
|
313
314
|
// components/AutoField/index.tsx
|
314
315
|
var import_react22 = require("react");
|
@@ -1276,7 +1277,6 @@ var reorderAction = (state, action, appStore) => {
|
|
1276
1277
|
init_react_import();
|
1277
1278
|
var removeAction = (state, action, appStore) => {
|
1278
1279
|
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1279
|
-
const [parentId] = action.zone.split(":");
|
1280
1280
|
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
1281
1281
|
(acc, [nodeId, nodeData]) => {
|
1282
1282
|
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
@@ -1295,24 +1295,17 @@ var removeAction = (state, action, appStore) => {
|
|
1295
1295
|
return remove(content, action.index);
|
1296
1296
|
}
|
1297
1297
|
return content;
|
1298
|
-
},
|
1299
|
-
(childItem, path) => {
|
1300
|
-
const parentIds = path.map((p) => p.split(":")[0]);
|
1301
|
-
if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
|
1302
|
-
return childItem;
|
1303
|
-
}
|
1304
|
-
return null;
|
1305
1298
|
}
|
1306
1299
|
);
|
1307
1300
|
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
1308
|
-
const
|
1309
|
-
if (nodesToDelete.includes(
|
1301
|
+
const parentId = zoneCompound.split(":")[0];
|
1302
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
1310
1303
|
delete newState.data.zones[zoneCompound];
|
1311
1304
|
}
|
1312
1305
|
});
|
1313
1306
|
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
1314
|
-
const
|
1315
|
-
if (nodesToDelete.includes(
|
1307
|
+
const parentId = zoneCompound.split(":")[0];
|
1308
|
+
if (nodesToDelete.includes(parentId)) {
|
1316
1309
|
delete newState.indexes.zones[zoneCompound];
|
1317
1310
|
}
|
1318
1311
|
});
|
@@ -1696,7 +1689,7 @@ var createHistorySlice = (set, get) => {
|
|
1696
1689
|
const { dispatch, history } = get();
|
1697
1690
|
dispatch({
|
1698
1691
|
type: "set",
|
1699
|
-
state: ((_a = history.histories[
|
1692
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1700
1693
|
});
|
1701
1694
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1702
1695
|
},
|
@@ -2016,7 +2009,7 @@ init_react_import();
|
|
2016
2009
|
|
2017
2010
|
// lib/data/map-slots.ts
|
2018
2011
|
init_react_import();
|
2019
|
-
function
|
2012
|
+
function mapSlotsAsync(_0, _1) {
|
2020
2013
|
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
2021
2014
|
const props = __spreadValues({}, item.props);
|
2022
2015
|
const propKeys = Object.keys(props);
|
@@ -2027,7 +2020,7 @@ function mapSlots(_0, _1) {
|
|
2027
2020
|
const content = props[propKey];
|
2028
2021
|
const mappedContent = recursive ? yield Promise.all(
|
2029
2022
|
content.map((item2) => __async(this, null, function* () {
|
2030
|
-
return yield
|
2023
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
2031
2024
|
}))
|
2032
2025
|
) : content;
|
2033
2026
|
props[propKey] = yield map(mappedContent, propKey);
|
@@ -2036,6 +2029,30 @@ function mapSlots(_0, _1) {
|
|
2036
2029
|
return __spreadProps(__spreadValues({}, item), { props });
|
2037
2030
|
});
|
2038
2031
|
}
|
2032
|
+
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
2033
|
+
const props = __spreadValues({}, item.props);
|
2034
|
+
const propKeys = Object.keys(props);
|
2035
|
+
for (let i = 0; i < propKeys.length; i++) {
|
2036
|
+
const propKey = propKeys[i];
|
2037
|
+
const itemType = "type" in item ? item.type : "root";
|
2038
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
2039
|
+
const content = props[propKey];
|
2040
|
+
const mappedContent = content.map((item2) => {
|
2041
|
+
return mapSlotsSync(item2, map, isSlot2);
|
2042
|
+
});
|
2043
|
+
props[propKey] = map(mappedContent, props.id, propKey);
|
2044
|
+
}
|
2045
|
+
}
|
2046
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
2047
|
+
}
|
2048
|
+
function mapSlotsPublic(item, config, map) {
|
2049
|
+
const isSlot2 = createIsSlotConfig(config);
|
2050
|
+
return mapSlotsSync(
|
2051
|
+
item,
|
2052
|
+
(content, parentId, propName) => map(content, { parentId, propName }),
|
2053
|
+
isSlot2
|
2054
|
+
);
|
2055
|
+
}
|
2039
2056
|
|
2040
2057
|
// lib/resolve-component-data.ts
|
2041
2058
|
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
@@ -2055,14 +2072,14 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
2055
2072
|
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
2056
2073
|
changed,
|
2057
2074
|
lastData: oldItem,
|
2058
|
-
metadata,
|
2075
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
2059
2076
|
trigger
|
2060
2077
|
});
|
2061
2078
|
let resolvedItem = __spreadProps(__spreadValues({}, item), {
|
2062
2079
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
2063
2080
|
});
|
2064
2081
|
if (recursive) {
|
2065
|
-
resolvedItem = yield
|
2082
|
+
resolvedItem = yield mapSlotsAsync(
|
2066
2083
|
resolvedItem,
|
2067
2084
|
(content) => __async(void 0, null, function* () {
|
2068
2085
|
return Promise.all(
|
@@ -4411,7 +4428,7 @@ var import_react25 = require("react");
|
|
4411
4428
|
|
4412
4429
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
4413
4430
|
init_react_import();
|
4414
|
-
var styles_module_default11 = { "DraggableComponent": "
|
4431
|
+
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_qzbgx_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_qzbgx_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_qzbgx_29", "DraggableComponent--hover": "_DraggableComponent--hover_qzbgx_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_qzbgx_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_qzbgx_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_qzbgx_66", "DraggableComponent-actions": "_DraggableComponent-actions_qzbgx_66" };
|
4415
4432
|
|
4416
4433
|
// components/DraggableComponent/index.tsx
|
4417
4434
|
var import_react_dom2 = require("react-dom");
|
@@ -5102,7 +5119,7 @@ init_react_import();
|
|
5102
5119
|
// lib/use-slots.tsx
|
5103
5120
|
init_react_import();
|
5104
5121
|
var import_react31 = require("react");
|
5105
|
-
function useSlots(config, props,
|
5122
|
+
function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
5106
5123
|
const slotProps = (0, import_react31.useMemo)(() => {
|
5107
5124
|
if (!(config == null ? void 0 : config.fields)) return props;
|
5108
5125
|
const slotProps2 = {};
|
@@ -5112,7 +5129,11 @@ function useSlots(config, props, renderSlot) {
|
|
5112
5129
|
const field = config.fields[fieldKey];
|
5113
5130
|
if ((field == null ? void 0 : field.type) === "slot") {
|
5114
5131
|
const content = props[fieldKey] || [];
|
5115
|
-
const
|
5132
|
+
const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
|
5133
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
5134
|
+
allow: field.allow,
|
5135
|
+
disallow: field.disallow
|
5136
|
+
}, dzProps), {
|
5116
5137
|
zone: fieldKey,
|
5117
5138
|
content
|
5118
5139
|
}));
|
@@ -5120,7 +5141,7 @@ function useSlots(config, props, renderSlot) {
|
|
5120
5141
|
}
|
5121
5142
|
}
|
5122
5143
|
return slotProps2;
|
5123
|
-
}, [config]);
|
5144
|
+
}, [config, readOnly, forceReadOnly]);
|
5124
5145
|
return __spreadValues(__spreadValues({}, props), slotProps);
|
5125
5146
|
}
|
5126
5147
|
|
@@ -5132,30 +5153,60 @@ init_react_import();
|
|
5132
5153
|
var import_react32 = require("react");
|
5133
5154
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
5134
5155
|
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRender, __spreadValues({}, props));
|
5156
|
+
var ContextSlotRender = ({
|
5157
|
+
componentId,
|
5158
|
+
zone
|
5159
|
+
}) => {
|
5160
|
+
const config = useAppStore((s) => s.config);
|
5161
|
+
const metadata = useAppStore((s) => s.metadata);
|
5162
|
+
const slotContent = useAppStore(
|
5163
|
+
(s) => {
|
5164
|
+
var _a, _b;
|
5165
|
+
return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
|
5166
|
+
}
|
5167
|
+
);
|
5168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5169
|
+
SlotRenderPure,
|
5170
|
+
{
|
5171
|
+
content: slotContent,
|
5172
|
+
zone,
|
5173
|
+
config,
|
5174
|
+
metadata
|
5175
|
+
}
|
5176
|
+
);
|
5177
|
+
};
|
5178
|
+
var Item = ({
|
5179
|
+
config,
|
5180
|
+
item,
|
5181
|
+
metadata
|
5182
|
+
}) => {
|
5183
|
+
const Component = config.components[item.type];
|
5184
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5185
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5186
|
+
Component.render,
|
5187
|
+
__spreadProps(__spreadValues({}, props), {
|
5188
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
5189
|
+
renderDropZone: DropZoneRenderPure,
|
5190
|
+
metadata: metadata || {}
|
5191
|
+
})
|
5192
|
+
})
|
5193
|
+
);
|
5194
|
+
};
|
5135
5195
|
var SlotRender = (0, import_react32.forwardRef)(
|
5136
5196
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
5137
5197
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className, style, ref, children: content.map((item) => {
|
5138
|
-
|
5139
|
-
|
5140
|
-
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5141
|
-
SlotRenderPure,
|
5142
|
-
__spreadProps(__spreadValues({}, slotProps), {
|
5143
|
-
config,
|
5144
|
-
metadata
|
5145
|
-
})
|
5146
|
-
));
|
5147
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5148
|
-
Component.render,
|
5149
|
-
__spreadProps(__spreadValues({}, props), {
|
5150
|
-
puck: {
|
5151
|
-
renderDropZone: DropZoneRenderPure,
|
5152
|
-
metadata: metadata || {}
|
5153
|
-
}
|
5154
|
-
}),
|
5155
|
-
props.id
|
5156
|
-
);
|
5198
|
+
if (!config.components[item.type]) {
|
5199
|
+
return null;
|
5157
5200
|
}
|
5158
|
-
return
|
5201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5202
|
+
Item,
|
5203
|
+
{
|
5204
|
+
config,
|
5205
|
+
item,
|
5206
|
+
metadata
|
5207
|
+
},
|
5208
|
+
item.props.id
|
5209
|
+
);
|
5159
5210
|
}) });
|
5160
5211
|
}
|
5161
5212
|
);
|
@@ -5222,12 +5273,6 @@ var DropZoneChild = ({
|
|
5222
5273
|
}) => {
|
5223
5274
|
var _a, _b;
|
5224
5275
|
const metadata = useAppStore((s) => s.metadata);
|
5225
|
-
const puckProps = {
|
5226
|
-
renderDropZone: DropZoneEditPure,
|
5227
|
-
isEditing: true,
|
5228
|
-
dragRef: null,
|
5229
|
-
metadata
|
5230
|
-
};
|
5231
5276
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
5232
5277
|
const { depth = 1 } = ctx != null ? ctx : {};
|
5233
5278
|
const nodeProps = useAppStore(
|
@@ -5242,11 +5287,23 @@ var DropZoneChild = ({
|
|
5242
5287
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.type;
|
5243
5288
|
}
|
5244
5289
|
);
|
5290
|
+
const nodeReadOnly = useAppStore(
|
5291
|
+
(0, import_shallow3.useShallow)((s) => {
|
5292
|
+
var _a2;
|
5293
|
+
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
5294
|
+
})
|
5295
|
+
);
|
5245
5296
|
const node = { type: nodeType, props: nodeProps };
|
5246
5297
|
const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
|
5247
5298
|
const componentConfig = useAppStore(
|
5248
5299
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
5249
5300
|
);
|
5301
|
+
const puckProps = {
|
5302
|
+
renderDropZone: DropZoneEditPure,
|
5303
|
+
isEditing: true,
|
5304
|
+
dragRef: null,
|
5305
|
+
metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
|
5306
|
+
};
|
5250
5307
|
const overrides = useAppStore((s) => s.overrides);
|
5251
5308
|
const isLoading = useAppStore(
|
5252
5309
|
(s) => {
|
@@ -5278,7 +5335,10 @@ var DropZoneChild = ({
|
|
5278
5335
|
const defaultedPropsWithSlots = useSlots(
|
5279
5336
|
componentConfig,
|
5280
5337
|
defaultsProps,
|
5281
|
-
DropZoneEditPure
|
5338
|
+
DropZoneEditPure,
|
5339
|
+
(slotProps) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
5340
|
+
nodeReadOnly,
|
5341
|
+
isLoading
|
5282
5342
|
);
|
5283
5343
|
if (!item) return;
|
5284
5344
|
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
@@ -5376,6 +5436,11 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5376
5436
|
);
|
5377
5437
|
(0, import_react34.useEffect)(() => {
|
5378
5438
|
if (!zoneType || zoneType === "dropzone") {
|
5439
|
+
if (zoneCompound !== rootDroppableId) {
|
5440
|
+
console.warn(
|
5441
|
+
"DropZones have been deprecated in favor of slot fields and will be removed in a future version of Puck. Please see the migration guide: https://www.puckeditor.com/docs/guides/migrations/dropzones-to-slots"
|
5442
|
+
);
|
5443
|
+
}
|
5379
5444
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5380
5445
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5381
5446
|
}
|
@@ -5499,6 +5564,30 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5499
5564
|
);
|
5500
5565
|
}
|
5501
5566
|
);
|
5567
|
+
var DropZoneRenderItem = ({
|
5568
|
+
config,
|
5569
|
+
item,
|
5570
|
+
metadata
|
5571
|
+
}) => {
|
5572
|
+
const Component = config.components[item.type];
|
5573
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5574
|
+
const nextContextValue = (0, import_react34.useMemo)(
|
5575
|
+
() => ({
|
5576
|
+
areaId: props.id,
|
5577
|
+
depth: 1
|
5578
|
+
}),
|
5579
|
+
[props]
|
5580
|
+
);
|
5581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5582
|
+
Component.render,
|
5583
|
+
__spreadProps(__spreadValues({}, props), {
|
5584
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
5585
|
+
renderDropZone: DropZoneRenderPure,
|
5586
|
+
metadata: __spreadValues(__spreadValues({}, metadata), Component.metadata)
|
5587
|
+
})
|
5588
|
+
})
|
5589
|
+
) }, props.id);
|
5590
|
+
};
|
5502
5591
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneRender, __spreadValues({}, props));
|
5503
5592
|
var DropZoneRender = (0, import_react34.forwardRef)(
|
5504
5593
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
@@ -5529,29 +5618,15 @@ var DropZoneRender = (0, import_react34.forwardRef)(
|
|
5529
5618
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className, style, ref, children: content.map((item) => {
|
5530
5619
|
const Component = config.components[item.type];
|
5531
5620
|
if (Component) {
|
5532
|
-
|
5533
|
-
|
5534
|
-
|
5621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5622
|
+
DropZoneRenderItem,
|
5623
|
+
{
|
5535
5624
|
config,
|
5625
|
+
item,
|
5536
5626
|
metadata
|
5537
|
-
}
|
5538
|
-
|
5539
|
-
const nextContextValue = (0, import_react34.useMemo)(
|
5540
|
-
() => ({
|
5541
|
-
areaId: props.id,
|
5542
|
-
depth: 1
|
5543
|
-
}),
|
5544
|
-
[props]
|
5627
|
+
},
|
5628
|
+
item.props.id
|
5545
5629
|
);
|
5546
|
-
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5547
|
-
Component.render,
|
5548
|
-
__spreadProps(__spreadValues({}, props), {
|
5549
|
-
puck: {
|
5550
|
-
renderDropZone: DropZoneRenderPure,
|
5551
|
-
metadata: metadata || {}
|
5552
|
-
}
|
5553
|
-
})
|
5554
|
-
) }, props.id);
|
5555
5630
|
}
|
5556
5631
|
return null;
|
5557
5632
|
}) });
|
@@ -6090,7 +6165,6 @@ var DragDropContextClient = ({
|
|
6090
6165
|
}
|
6091
6166
|
if (thisPreview) {
|
6092
6167
|
zoneStore.setState({ previewIndex: {} });
|
6093
|
-
const state = appStore.getState().state;
|
6094
6168
|
if (thisPreview.type === "insert") {
|
6095
6169
|
insertComponent(
|
6096
6170
|
thisPreview.componentType,
|
@@ -8041,13 +8115,22 @@ var generateUsePuck = (store) => {
|
|
8041
8115
|
index: store.history.index
|
8042
8116
|
};
|
8043
8117
|
const storeData = {
|
8044
|
-
appState: store.state,
|
8118
|
+
appState: makeStatePublic(store.state),
|
8045
8119
|
config: store.config,
|
8046
8120
|
dispatch: store.dispatch,
|
8047
8121
|
getPermissions: store.permissions.getPermissions,
|
8048
8122
|
refreshPermissions: store.permissions.refreshPermissions,
|
8049
8123
|
history,
|
8050
|
-
selectedItem: store.selectedItem || null
|
8124
|
+
selectedItem: store.selectedItem || null,
|
8125
|
+
getItemBySelector: (selector) => getItem(selector, store.state),
|
8126
|
+
getItemById: (id) => store.state.indexes.nodes[id].data,
|
8127
|
+
getSelectorForId: (id) => {
|
8128
|
+
const node = store.state.indexes.nodes[id];
|
8129
|
+
if (!node) return;
|
8130
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
8131
|
+
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
8132
|
+
return { zone: zoneCompound, index };
|
8133
|
+
}
|
8051
8134
|
};
|
8052
8135
|
const get = () => storeData;
|
8053
8136
|
return __spreadProps(__spreadValues({}, storeData), { get });
|
@@ -8057,7 +8140,7 @@ var UsePuckStoreContext = (0, import_react51.createContext)(
|
|
8057
8140
|
);
|
8058
8141
|
var convertToPickedStore = (store) => {
|
8059
8142
|
return {
|
8060
|
-
state:
|
8143
|
+
state: store.state,
|
8061
8144
|
config: store.config,
|
8062
8145
|
dispatch: store.dispatch,
|
8063
8146
|
permissions: store.permissions,
|
@@ -8540,10 +8623,67 @@ var migrations = [
|
|
8540
8623
|
});
|
8541
8624
|
}
|
8542
8625
|
return data;
|
8626
|
+
},
|
8627
|
+
// Migrate zones to slots
|
8628
|
+
(data, config) => {
|
8629
|
+
var _a;
|
8630
|
+
if (!config) return data;
|
8631
|
+
console.log("Migrating DropZones to slots...");
|
8632
|
+
const updatedItems = {};
|
8633
|
+
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
8634
|
+
const { indexes } = walkTree(appState, config);
|
8635
|
+
const deletedCompounds = [];
|
8636
|
+
walkTree(appState, config, (content, zoneCompound, zoneType) => {
|
8637
|
+
var _a2, _b;
|
8638
|
+
if (zoneType === "dropzone") {
|
8639
|
+
const [id, slotName] = zoneCompound.split(":");
|
8640
|
+
const nodeData = indexes.nodes[id].data;
|
8641
|
+
const componentType = nodeData.type;
|
8642
|
+
const configForComponent = config.components[componentType];
|
8643
|
+
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
8644
|
+
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
8645
|
+
props: __spreadProps(__spreadValues({}, nodeData.props), {
|
8646
|
+
[slotName]: content
|
8647
|
+
})
|
8648
|
+
});
|
8649
|
+
deletedCompounds.push(zoneCompound);
|
8650
|
+
}
|
8651
|
+
return content;
|
8652
|
+
}
|
8653
|
+
return content;
|
8654
|
+
});
|
8655
|
+
const updated = walkTree(
|
8656
|
+
appState,
|
8657
|
+
config,
|
8658
|
+
(content) => content,
|
8659
|
+
(item) => {
|
8660
|
+
var _a2;
|
8661
|
+
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
8662
|
+
}
|
8663
|
+
);
|
8664
|
+
deletedCompounds.forEach((zoneCompound) => {
|
8665
|
+
var _a2;
|
8666
|
+
const [_, propName] = zoneCompound.split(":");
|
8667
|
+
console.log(
|
8668
|
+
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
8669
|
+
);
|
8670
|
+
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
8671
|
+
});
|
8672
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
8673
|
+
const [_, propName] = zoneCompound.split(":");
|
8674
|
+
throw new Error(
|
8675
|
+
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
8676
|
+
);
|
8677
|
+
});
|
8678
|
+
delete updated.data.zones;
|
8679
|
+
return updated.data;
|
8543
8680
|
}
|
8544
8681
|
];
|
8545
|
-
function migrate(data) {
|
8546
|
-
return migrations == null ? void 0 : migrations.reduce(
|
8682
|
+
function migrate(data, config) {
|
8683
|
+
return migrations == null ? void 0 : migrations.reduce(
|
8684
|
+
(acc, migration) => migration(acc, config),
|
8685
|
+
data
|
8686
|
+
);
|
8547
8687
|
}
|
8548
8688
|
|
8549
8689
|
// lib/transform-props.ts
|
@@ -8620,7 +8760,11 @@ function resolveAllData(_0, _1) {
|
|
8620
8760
|
"force",
|
8621
8761
|
false
|
8622
8762
|
)).node;
|
8623
|
-
const resolvedDeep = yield
|
8763
|
+
const resolvedDeep = yield mapSlotsAsync(
|
8764
|
+
resolved,
|
8765
|
+
processContent,
|
8766
|
+
false
|
8767
|
+
);
|
8624
8768
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
8625
8769
|
return resolvedDeep;
|
8626
8770
|
});
|
@@ -8662,6 +8806,7 @@ function resolveAllData(_0, _1) {
|
|
8662
8806
|
Puck,
|
8663
8807
|
Render,
|
8664
8808
|
createUsePuck,
|
8809
|
+
mapSlots,
|
8665
8810
|
migrate,
|
8666
8811
|
overrideKeys,
|
8667
8812
|
renderContext,
|
package/dist/index.mjs
CHANGED
@@ -51,9 +51,11 @@ import {
|
|
51
51
|
defaultViewports,
|
52
52
|
dropZoneContext,
|
53
53
|
getFrame,
|
54
|
+
getItem,
|
54
55
|
get_class_name_factory_default,
|
55
56
|
init_react_import,
|
56
57
|
makeStatePublic,
|
58
|
+
mapSlotsPublic,
|
57
59
|
monitorHotkeys,
|
58
60
|
renderContext,
|
59
61
|
reorder,
|
@@ -73,7 +75,7 @@ import {
|
|
73
75
|
useSlots,
|
74
76
|
useSortableSafe,
|
75
77
|
walkTree
|
76
|
-
} from "./chunk-
|
78
|
+
} from "./chunk-ZOHJNF5K.mjs";
|
77
79
|
|
78
80
|
// index.ts
|
79
81
|
init_react_import();
|
@@ -127,7 +129,7 @@ init_react_import();
|
|
127
129
|
|
128
130
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
129
131
|
init_react_import();
|
130
|
-
var styles_module_default = { "InputWrapper": "
|
132
|
+
var styles_module_default = { "InputWrapper": "_InputWrapper_4xor1_1", "Input-label": "_Input-label_4xor1_5", "Input-labelIcon": "_Input-labelIcon_4xor1_14", "Input-disabledIcon": "_Input-disabledIcon_4xor1_21", "Input-input": "_Input-input_4xor1_26", "Input": "_Input_4xor1_1", "Input--readOnly": "_Input--readOnly_4xor1_75", "Input-radioGroupItems": "_Input-radioGroupItems_4xor1_86", "Input-radio": "_Input-radio_4xor1_86", "Input-radioInner": "_Input-radioInner_4xor1_103", "Input-radioInput": "_Input-radioInput_4xor1_148" };
|
131
133
|
|
132
134
|
// components/AutoField/index.tsx
|
133
135
|
import {
|
@@ -3268,13 +3270,22 @@ var generateUsePuck = (store) => {
|
|
3268
3270
|
index: store.history.index
|
3269
3271
|
};
|
3270
3272
|
const storeData = {
|
3271
|
-
appState: store.state,
|
3273
|
+
appState: makeStatePublic(store.state),
|
3272
3274
|
config: store.config,
|
3273
3275
|
dispatch: store.dispatch,
|
3274
3276
|
getPermissions: store.permissions.getPermissions,
|
3275
3277
|
refreshPermissions: store.permissions.refreshPermissions,
|
3276
3278
|
history,
|
3277
|
-
selectedItem: store.selectedItem || null
|
3279
|
+
selectedItem: store.selectedItem || null,
|
3280
|
+
getItemBySelector: (selector) => getItem(selector, store.state),
|
3281
|
+
getItemById: (id) => store.state.indexes.nodes[id].data,
|
3282
|
+
getSelectorForId: (id) => {
|
3283
|
+
const node = store.state.indexes.nodes[id];
|
3284
|
+
if (!node) return;
|
3285
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
3286
|
+
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
3287
|
+
return { zone: zoneCompound, index };
|
3288
|
+
}
|
3278
3289
|
};
|
3279
3290
|
const get = () => storeData;
|
3280
3291
|
return __spreadProps(__spreadValues({}, storeData), { get });
|
@@ -3284,7 +3295,7 @@ var UsePuckStoreContext = createContext3(
|
|
3284
3295
|
);
|
3285
3296
|
var convertToPickedStore = (store) => {
|
3286
3297
|
return {
|
3287
|
-
state:
|
3298
|
+
state: store.state,
|
3288
3299
|
config: store.config,
|
3289
3300
|
dispatch: store.dispatch,
|
3290
3301
|
permissions: store.permissions,
|
@@ -3767,10 +3778,67 @@ var migrations = [
|
|
3767
3778
|
});
|
3768
3779
|
}
|
3769
3780
|
return data;
|
3781
|
+
},
|
3782
|
+
// Migrate zones to slots
|
3783
|
+
(data, config) => {
|
3784
|
+
var _a;
|
3785
|
+
if (!config) return data;
|
3786
|
+
console.log("Migrating DropZones to slots...");
|
3787
|
+
const updatedItems = {};
|
3788
|
+
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
3789
|
+
const { indexes } = walkTree(appState, config);
|
3790
|
+
const deletedCompounds = [];
|
3791
|
+
walkTree(appState, config, (content, zoneCompound, zoneType) => {
|
3792
|
+
var _a2, _b;
|
3793
|
+
if (zoneType === "dropzone") {
|
3794
|
+
const [id, slotName] = zoneCompound.split(":");
|
3795
|
+
const nodeData = indexes.nodes[id].data;
|
3796
|
+
const componentType = nodeData.type;
|
3797
|
+
const configForComponent = config.components[componentType];
|
3798
|
+
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
3799
|
+
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
3800
|
+
props: __spreadProps(__spreadValues({}, nodeData.props), {
|
3801
|
+
[slotName]: content
|
3802
|
+
})
|
3803
|
+
});
|
3804
|
+
deletedCompounds.push(zoneCompound);
|
3805
|
+
}
|
3806
|
+
return content;
|
3807
|
+
}
|
3808
|
+
return content;
|
3809
|
+
});
|
3810
|
+
const updated = walkTree(
|
3811
|
+
appState,
|
3812
|
+
config,
|
3813
|
+
(content) => content,
|
3814
|
+
(item) => {
|
3815
|
+
var _a2;
|
3816
|
+
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
3817
|
+
}
|
3818
|
+
);
|
3819
|
+
deletedCompounds.forEach((zoneCompound) => {
|
3820
|
+
var _a2;
|
3821
|
+
const [_, propName] = zoneCompound.split(":");
|
3822
|
+
console.log(
|
3823
|
+
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
3824
|
+
);
|
3825
|
+
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
3826
|
+
});
|
3827
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
3828
|
+
const [_, propName] = zoneCompound.split(":");
|
3829
|
+
throw new Error(
|
3830
|
+
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
3831
|
+
);
|
3832
|
+
});
|
3833
|
+
delete updated.data.zones;
|
3834
|
+
return updated.data;
|
3770
3835
|
}
|
3771
3836
|
];
|
3772
|
-
function migrate(data) {
|
3773
|
-
return migrations == null ? void 0 : migrations.reduce(
|
3837
|
+
function migrate(data, config) {
|
3838
|
+
return migrations == null ? void 0 : migrations.reduce(
|
3839
|
+
(acc, migration) => migration(acc, config),
|
3840
|
+
data
|
3841
|
+
);
|
3774
3842
|
}
|
3775
3843
|
export {
|
3776
3844
|
Action,
|
@@ -3786,6 +3854,7 @@ export {
|
|
3786
3854
|
Puck,
|
3787
3855
|
Render,
|
3788
3856
|
createUsePuck,
|
3857
|
+
mapSlotsPublic as mapSlots,
|
3789
3858
|
migrate,
|
3790
3859
|
overrideKeys,
|
3791
3860
|
renderContext,
|
@@ -23,6 +23,7 @@ type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
|
23
23
|
type BaseField = {
|
24
24
|
label?: string;
|
25
25
|
labelIcon?: ReactElement;
|
26
|
+
metadata?: Metadata;
|
26
27
|
};
|
27
28
|
type TextField = BaseField & {
|
28
29
|
type: "text";
|
@@ -122,6 +123,8 @@ type CustomField<Props extends any = {}> = BaseField & {
|
|
122
123
|
};
|
123
124
|
type SlotField = BaseField & {
|
124
125
|
type: "slot";
|
126
|
+
allow?: string[];
|
127
|
+
disallow?: string[];
|
125
128
|
};
|
126
129
|
type Field<Props extends any = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props extends {
|
127
130
|
[key: string]: any;
|
@@ -187,6 +190,7 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
|
|
187
190
|
appState: AppState;
|
188
191
|
lastData: DataShape | null;
|
189
192
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
193
|
+
metadata?: Metadata;
|
190
194
|
};
|
191
195
|
type RootConfig<RootProps extends DefaultComponentProps = any> = Partial<ComponentConfig<WithChildren<RootProps>, AsFieldProps<RootProps>, RootData<AsFieldProps<RootProps>>>>;
|
192
196
|
type Category<ComponentName> = {
|
@@ -522,4 +526,4 @@ declare function transformProps<Props extends DefaultComponentProps = DefaultCom
|
|
522
526
|
|
523
527
|
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
524
528
|
|
525
|
-
export { type
|
529
|
+
export { type SlotField as $, type AppState as A, type BaseData as B, type ComponentData as C, type DropZoneProps as D, type ComponentDataMap as E, type Fields as F, type BaseField as G, type History as H, type IframeConfig as I, type TextareaField as J, type SelectField as K, type RadioField as L, type Metadata as M, type NumberField as N, type Overrides as O, type Permissions as P, type ArrayField as Q, type RootDataWithProps as R, type Slot as S, type TextField as T, type UserGenerics as U, type Viewports as V, type ObjectField as W, type Adaptor as X, type ExternalFieldWithAdaptor as Y, type ExternalField as Z, type CustomField as _, type Config as a, type PuckContext as a0, type DefaultRootFieldProps as a1, type DefaultRootRenderProps as a2, type DefaultRootProps as a3, type DefaultComponentProps as a4, type WithId as a5, type WithPuckProps as a6, type AsFieldProps as a7, type WithChildren as a8, type ExtractPropsFromConfig as a9, type ExtractRootPropsFromConfig as aa, transformProps as ab, resolveAllData as ac, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type Field as g, type FieldProps as h, type Data as i, type OnAction as j, type InitialHistory as k, type RootData as l, type Content as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, overrideKeys as r, type OverrideKey as s, type FieldRenderFunctions as t, type ItemWithId as u, type ArrayState as v, type PuckComponent as w, type RootConfig as x, type RootDataWithoutProps as y, type MappedItem as z };
|