@measured/puck 0.19.4-canary.fde74e8a → 0.20.0-canary.3da831b0
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 +30 -29
- package/dist/{chunk-IM42S4YL.mjs → chunk-H6KSTNLT.mjs} +49 -7
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +60 -17
- package/dist/index.mjs +12 -11
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +49 -7
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-DrJNb8b-.d.mts → walk-tree-DhtH8sAC.d.mts} +6 -1
- package/dist/{walk-tree-DrJNb8b-.d.ts → walk-tree-DhtH8sAC.d.ts} +6 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
<br /><br /><br />
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
<a href="https://puckeditor.com">
|
|
6
|
+
<picture>
|
|
7
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://res.cloudinary.com/die3nptcg/image/upload/Puck_Logo_White_RGB_j2rwgg.svg" height="100px" aria-label="Puck logo">
|
|
8
|
+
<img src="https://res.cloudinary.com/die3nptcg/image/upload/Puck_Logo_Black_RGB_dqsjag.svg" height="100px" aria-label="Puck logo">
|
|
9
|
+
</picture>
|
|
10
|
+
</a>
|
|
11
|
+
|
|
12
|
+
_The visual editor for React_
|
|
13
|
+
|
|
14
|
+
[Documentation](https://puckeditor.com/docs) • [Demo](https://demo.puckeditor.com/edit) • [Discord](https://discord.gg/V9mDAhuxyZ) • [Contributing](https://github.com/puckeditor/puck/blob/main/CONTRIBUTING.md)
|
|
15
|
+
|
|
16
|
+
⭐️ Enjoying Puck? Please [leave a star](https://github.com/puckeditor/puck)!
|
|
17
|
+
|
|
18
|
+
<br />
|
|
19
|
+
|
|
20
|
+
[](https://demo.puckeditor.com/edit)
|
|
21
|
+
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
## What is Puck?
|
|
25
|
+
|
|
26
|
+
Puck is a modular, open-source visual editor for React.js. You can use Puck to build custom drag-and-drop experiences with your own application and React components.
|
|
27
|
+
|
|
28
|
+
Because Puck is just a React component, it plays well with all React.js environments, including Next.js. You own your data and there’s no vendor lock-in.
|
|
29
|
+
|
|
30
|
+
Puck is also [licensed under MIT](https://github.com/puckeditor/puck?tab=MIT-1-ov-file#readme), making it suitable for both internal systems and commercial applications.
|
|
30
31
|
|
|
31
32
|
## Quick start
|
|
32
33
|
|
|
@@ -871,8 +871,8 @@ var migrations = [
|
|
|
871
871
|
return data;
|
|
872
872
|
},
|
|
873
873
|
// Migrate zones to slots
|
|
874
|
-
(data, config) => {
|
|
875
|
-
var _a;
|
|
874
|
+
(data, config, migrationOptions) => {
|
|
875
|
+
var _a, _b;
|
|
876
876
|
if (!config) return data;
|
|
877
877
|
console.log("Migrating DropZones to slots...");
|
|
878
878
|
const updatedItems = {};
|
|
@@ -880,13 +880,13 @@ var migrations = [
|
|
|
880
880
|
const { indexes } = walkAppState(appState, config);
|
|
881
881
|
const deletedCompounds = [];
|
|
882
882
|
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
883
|
-
var _a2,
|
|
883
|
+
var _a2, _b2, _c;
|
|
884
884
|
if (zoneType === "dropzone") {
|
|
885
885
|
const [id, slotName] = zoneCompound.split(":");
|
|
886
886
|
const nodeData = indexes.nodes[id].data;
|
|
887
887
|
const componentType = nodeData.type;
|
|
888
888
|
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
889
|
-
if (((
|
|
889
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
890
890
|
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
891
891
|
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
892
892
|
[slotName]: content
|
|
@@ -915,7 +915,49 @@ var migrations = [
|
|
|
915
915
|
);
|
|
916
916
|
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
917
917
|
});
|
|
918
|
-
|
|
918
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
919
|
+
const unmigratedZonesGrouped = {};
|
|
920
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
921
|
+
var _a2;
|
|
922
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
923
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
924
|
+
if (!content) {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
928
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
929
|
+
}
|
|
930
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
931
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
935
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
936
|
+
return content.map((child) => {
|
|
937
|
+
var _a2;
|
|
938
|
+
if (child.props.id !== componentId) {
|
|
939
|
+
return child;
|
|
940
|
+
}
|
|
941
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
942
|
+
if (!migrateFn) {
|
|
943
|
+
return child;
|
|
944
|
+
}
|
|
945
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
946
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
947
|
+
Object.keys(zones).forEach((propName) => {
|
|
948
|
+
var _a3;
|
|
949
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
950
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
951
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
952
|
+
});
|
|
953
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
954
|
+
props: migratedProps
|
|
955
|
+
});
|
|
956
|
+
});
|
|
957
|
+
});
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
919
961
|
const [_, propName] = zoneCompound.split(":");
|
|
920
962
|
throw new Error(
|
|
921
963
|
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
@@ -925,9 +967,9 @@ var migrations = [
|
|
|
925
967
|
return updated.data;
|
|
926
968
|
}
|
|
927
969
|
];
|
|
928
|
-
function migrate(data, config) {
|
|
970
|
+
function migrate(data, config, migrationOptions) {
|
|
929
971
|
return migrations == null ? void 0 : migrations.reduce(
|
|
930
|
-
(acc, migration) => migration(acc, config),
|
|
972
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
931
973
|
data
|
|
932
974
|
);
|
|
933
975
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as History, P as Permissions, C as ComponentData, a 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 Field, h as FieldProps, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory, l as ItemSelector } from './walk-tree-
|
|
2
|
-
export { _ as Adaptor, Y as ArrayField, t as ArrayState, ab as AsFieldProps, B as BaseData, K as BaseField, G as ComponentDataMap, z as ComponentDataOptionalId, J as Content, a2 as CustomField, a1 as CustomFieldRender, a8 as DefaultComponentProps, a5 as DefaultRootFieldProps, a7 as DefaultRootProps, a6 as DefaultRootRenderProps, m as Direction, n as DragAxis, a0 as ExternalField, $ as ExternalFieldWithAdaptor, ad as ExtractPropsFromConfig, ae as ExtractRootPropsFromConfig, r as FieldRenderFunctions, s as ItemWithId, E as MappedItem, N as NumberField, Z as ObjectField, q as OverrideKey, u as PuckComponent, a4 as PuckContext, X as RadioField, v as RootConfig, y as RootData, x as RootDataWithoutProps, Q as SelectField, S as Slot, a3 as SlotField, T as TextField, L as TextareaField, o as Viewport, ac as WithChildren, a9 as WithId, aa as WithPuckProps, W as WithSlotProps, af as migrate, p as overrideKeys, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-
|
|
1
|
+
import { H as History, P as Permissions, C as ComponentData, a 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 Field, h as FieldProps, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory, l as ItemSelector } from './walk-tree-DhtH8sAC.mjs';
|
|
2
|
+
export { _ as Adaptor, Y as ArrayField, t as ArrayState, ab as AsFieldProps, B as BaseData, K as BaseField, G as ComponentDataMap, z as ComponentDataOptionalId, J as Content, a2 as CustomField, a1 as CustomFieldRender, a8 as DefaultComponentProps, a5 as DefaultRootFieldProps, a7 as DefaultRootProps, a6 as DefaultRootRenderProps, m as Direction, n as DragAxis, a0 as ExternalField, $ as ExternalFieldWithAdaptor, ad as ExtractPropsFromConfig, ae as ExtractRootPropsFromConfig, r as FieldRenderFunctions, s as ItemWithId, E as MappedItem, N as NumberField, Z as ObjectField, q as OverrideKey, u as PuckComponent, a4 as PuckContext, X as RadioField, v as RootConfig, y as RootData, x as RootDataWithoutProps, Q as SelectField, S as Slot, a3 as SlotField, T as TextField, L as TextareaField, o as Viewport, ac as WithChildren, a9 as WithId, aa as WithPuckProps, W as WithSlotProps, af as migrate, p as overrideKeys, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DhtH8sAC.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';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as History, P as Permissions, C as ComponentData, a 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 Field, h as FieldProps, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory, l as ItemSelector } from './walk-tree-
|
|
2
|
-
export { _ as Adaptor, Y as ArrayField, t as ArrayState, ab as AsFieldProps, B as BaseData, K as BaseField, G as ComponentDataMap, z as ComponentDataOptionalId, J as Content, a2 as CustomField, a1 as CustomFieldRender, a8 as DefaultComponentProps, a5 as DefaultRootFieldProps, a7 as DefaultRootProps, a6 as DefaultRootRenderProps, m as Direction, n as DragAxis, a0 as ExternalField, $ as ExternalFieldWithAdaptor, ad as ExtractPropsFromConfig, ae as ExtractRootPropsFromConfig, r as FieldRenderFunctions, s as ItemWithId, E as MappedItem, N as NumberField, Z as ObjectField, q as OverrideKey, u as PuckComponent, a4 as PuckContext, X as RadioField, v as RootConfig, y as RootData, x as RootDataWithoutProps, Q as SelectField, S as Slot, a3 as SlotField, T as TextField, L as TextareaField, o as Viewport, ac as WithChildren, a9 as WithId, aa as WithPuckProps, W as WithSlotProps, af as migrate, p as overrideKeys, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-
|
|
1
|
+
import { H as History, P as Permissions, C as ComponentData, a 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 Field, h as FieldProps, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory, l as ItemSelector } from './walk-tree-DhtH8sAC.js';
|
|
2
|
+
export { _ as Adaptor, Y as ArrayField, t as ArrayState, ab as AsFieldProps, B as BaseData, K as BaseField, G as ComponentDataMap, z as ComponentDataOptionalId, J as Content, a2 as CustomField, a1 as CustomFieldRender, a8 as DefaultComponentProps, a5 as DefaultRootFieldProps, a7 as DefaultRootProps, a6 as DefaultRootRenderProps, m as Direction, n as DragAxis, a0 as ExternalField, $ as ExternalFieldWithAdaptor, ad as ExtractPropsFromConfig, ae as ExtractRootPropsFromConfig, r as FieldRenderFunctions, s as ItemWithId, E as MappedItem, N as NumberField, Z as ObjectField, q as OverrideKey, u as PuckComponent, a4 as PuckContext, X as RadioField, v as RootConfig, y as RootData, x as RootDataWithoutProps, Q as SelectField, S as Slot, a3 as SlotField, T as TextField, L as TextareaField, o as Viewport, ac as WithChildren, a9 as WithId, aa as WithPuckProps, W as WithSlotProps, af as migrate, p as overrideKeys, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DhtH8sAC.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';
|
package/dist/index.js
CHANGED
|
@@ -1627,8 +1627,8 @@ var migrations = [
|
|
|
1627
1627
|
return data;
|
|
1628
1628
|
},
|
|
1629
1629
|
// Migrate zones to slots
|
|
1630
|
-
(data, config) => {
|
|
1631
|
-
var _a;
|
|
1630
|
+
(data, config, migrationOptions) => {
|
|
1631
|
+
var _a, _b;
|
|
1632
1632
|
if (!config) return data;
|
|
1633
1633
|
console.log("Migrating DropZones to slots...");
|
|
1634
1634
|
const updatedItems = {};
|
|
@@ -1636,13 +1636,13 @@ var migrations = [
|
|
|
1636
1636
|
const { indexes } = walkAppState(appState, config);
|
|
1637
1637
|
const deletedCompounds = [];
|
|
1638
1638
|
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
1639
|
-
var _a2,
|
|
1639
|
+
var _a2, _b2, _c;
|
|
1640
1640
|
if (zoneType === "dropzone") {
|
|
1641
1641
|
const [id, slotName] = zoneCompound.split(":");
|
|
1642
1642
|
const nodeData = indexes.nodes[id].data;
|
|
1643
1643
|
const componentType = nodeData.type;
|
|
1644
1644
|
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
1645
|
-
if (((
|
|
1645
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
1646
1646
|
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
1647
1647
|
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
1648
1648
|
[slotName]: content
|
|
@@ -1671,7 +1671,49 @@ var migrations = [
|
|
|
1671
1671
|
);
|
|
1672
1672
|
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
1673
1673
|
});
|
|
1674
|
-
|
|
1674
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
1675
|
+
const unmigratedZonesGrouped = {};
|
|
1676
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
1677
|
+
var _a2;
|
|
1678
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
1679
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
1680
|
+
if (!content) {
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
1684
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
1685
|
+
}
|
|
1686
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
1687
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
1688
|
+
}
|
|
1689
|
+
});
|
|
1690
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
1691
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
1692
|
+
return content.map((child) => {
|
|
1693
|
+
var _a2;
|
|
1694
|
+
if (child.props.id !== componentId) {
|
|
1695
|
+
return child;
|
|
1696
|
+
}
|
|
1697
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
1698
|
+
if (!migrateFn) {
|
|
1699
|
+
return child;
|
|
1700
|
+
}
|
|
1701
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
1702
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
1703
|
+
Object.keys(zones).forEach((propName) => {
|
|
1704
|
+
var _a3;
|
|
1705
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
1706
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
1707
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
1708
|
+
});
|
|
1709
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
1710
|
+
props: migratedProps
|
|
1711
|
+
});
|
|
1712
|
+
});
|
|
1713
|
+
});
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
1675
1717
|
const [_, propName] = zoneCompound.split(":");
|
|
1676
1718
|
throw new Error(
|
|
1677
1719
|
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
@@ -1681,9 +1723,9 @@ var migrations = [
|
|
|
1681
1723
|
return updated.data;
|
|
1682
1724
|
}
|
|
1683
1725
|
];
|
|
1684
|
-
function migrate(data, config) {
|
|
1726
|
+
function migrate(data, config, migrationOptions) {
|
|
1685
1727
|
return migrations == null ? void 0 : migrations.reduce(
|
|
1686
|
-
(acc, migration) => migration(acc, config),
|
|
1728
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
1687
1729
|
data
|
|
1688
1730
|
);
|
|
1689
1731
|
}
|
|
@@ -4319,9 +4361,8 @@ var ObjectField = ({
|
|
|
4319
4361
|
readOnly,
|
|
4320
4362
|
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
|
4321
4363
|
const subField = field.objectFields[subName];
|
|
4322
|
-
const subPath = `${
|
|
4323
|
-
const
|
|
4324
|
-
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
|
4364
|
+
const subPath = `${localName}.${subName}`;
|
|
4365
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[subPath];
|
|
4325
4366
|
const label2 = subField.label || subName;
|
|
4326
4367
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4327
4368
|
NestedFieldProvider,
|
|
@@ -4420,7 +4461,7 @@ var FieldLabelInternal = ({
|
|
|
4420
4461
|
);
|
|
4421
4462
|
};
|
|
4422
4463
|
function AutoFieldInternal(props) {
|
|
4423
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4464
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
4424
4465
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4425
4466
|
const overrides = useAppStore((s) => s.overrides);
|
|
4426
4467
|
const readOnly = useAppStore((s) => {
|
|
@@ -4492,21 +4533,23 @@ function AutoFieldInternal(props) {
|
|
|
4492
4533
|
if (field.type === "slot") {
|
|
4493
4534
|
return null;
|
|
4494
4535
|
}
|
|
4536
|
+
let children = null;
|
|
4537
|
+
let FieldComponent;
|
|
4495
4538
|
if (field.type === "custom") {
|
|
4496
4539
|
if (!field.render) {
|
|
4497
4540
|
return null;
|
|
4498
4541
|
}
|
|
4499
|
-
|
|
4500
|
-
|
|
4542
|
+
FieldComponent = field.render;
|
|
4543
|
+
} else {
|
|
4544
|
+
children = defaultFields[field.type](mergedProps);
|
|
4545
|
+
FieldComponent = render[field.type];
|
|
4501
4546
|
}
|
|
4502
|
-
const children = defaultFields[field.type](mergedProps);
|
|
4503
|
-
const Render3 = render[field.type];
|
|
4504
4547
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4505
4548
|
NestedFieldContext.Provider,
|
|
4506
4549
|
{
|
|
4507
4550
|
value: {
|
|
4508
4551
|
readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
|
|
4509
|
-
localName: nestedFieldContext.localName
|
|
4552
|
+
localName: (_i = nestedFieldContext.localName) != null ? _i : mergedProps.name
|
|
4510
4553
|
},
|
|
4511
4554
|
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4512
4555
|
"div",
|
|
@@ -4517,7 +4560,7 @@ function AutoFieldInternal(props) {
|
|
|
4517
4560
|
onClick: (e) => {
|
|
4518
4561
|
e.stopPropagation();
|
|
4519
4562
|
},
|
|
4520
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4563
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
|
4521
4564
|
}
|
|
4522
4565
|
)
|
|
4523
4566
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
walkAppState,
|
|
26
26
|
walkField,
|
|
27
27
|
walkTree
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-H6KSTNLT.mjs";
|
|
29
29
|
|
|
30
30
|
// ../../node_modules/classnames/index.js
|
|
31
31
|
var require_classnames = __commonJS({
|
|
@@ -3442,9 +3442,8 @@ var ObjectField = ({
|
|
|
3442
3442
|
readOnly,
|
|
3443
3443
|
children: /* @__PURE__ */ jsx17("div", { className: getClassName14(), children: /* @__PURE__ */ jsx17("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
|
3444
3444
|
const subField = field.objectFields[subName];
|
|
3445
|
-
const subPath = `${
|
|
3446
|
-
const
|
|
3447
|
-
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
|
3445
|
+
const subPath = `${localName}.${subName}`;
|
|
3446
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[subPath];
|
|
3448
3447
|
const label2 = subField.label || subName;
|
|
3449
3448
|
return /* @__PURE__ */ jsx17(
|
|
3450
3449
|
NestedFieldProvider,
|
|
@@ -3543,7 +3542,7 @@ var FieldLabelInternal = ({
|
|
|
3543
3542
|
);
|
|
3544
3543
|
};
|
|
3545
3544
|
function AutoFieldInternal(props) {
|
|
3546
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3545
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3547
3546
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
3548
3547
|
const overrides = useAppStore((s) => s.overrides);
|
|
3549
3548
|
const readOnly = useAppStore((s) => {
|
|
@@ -3615,21 +3614,23 @@ function AutoFieldInternal(props) {
|
|
|
3615
3614
|
if (field.type === "slot") {
|
|
3616
3615
|
return null;
|
|
3617
3616
|
}
|
|
3617
|
+
let children = null;
|
|
3618
|
+
let FieldComponent;
|
|
3618
3619
|
if (field.type === "custom") {
|
|
3619
3620
|
if (!field.render) {
|
|
3620
3621
|
return null;
|
|
3621
3622
|
}
|
|
3622
|
-
|
|
3623
|
-
|
|
3623
|
+
FieldComponent = field.render;
|
|
3624
|
+
} else {
|
|
3625
|
+
children = defaultFields[field.type](mergedProps);
|
|
3626
|
+
FieldComponent = render[field.type];
|
|
3624
3627
|
}
|
|
3625
|
-
const children = defaultFields[field.type](mergedProps);
|
|
3626
|
-
const Render2 = render[field.type];
|
|
3627
3628
|
return /* @__PURE__ */ jsx18(
|
|
3628
3629
|
NestedFieldContext.Provider,
|
|
3629
3630
|
{
|
|
3630
3631
|
value: {
|
|
3631
3632
|
readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
|
|
3632
|
-
localName: nestedFieldContext.localName
|
|
3633
|
+
localName: (_i = nestedFieldContext.localName) != null ? _i : mergedProps.name
|
|
3633
3634
|
},
|
|
3634
3635
|
children: /* @__PURE__ */ jsx18(
|
|
3635
3636
|
"div",
|
|
@@ -3640,7 +3641,7 @@ function AutoFieldInternal(props) {
|
|
|
3640
3641
|
onClick: (e) => {
|
|
3641
3642
|
e.stopPropagation();
|
|
3642
3643
|
},
|
|
3643
|
-
children: /* @__PURE__ */ jsx18(
|
|
3644
|
+
children: /* @__PURE__ */ jsx18(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
|
3644
3645
|
}
|
|
3645
3646
|
)
|
|
3646
3647
|
}
|
package/dist/rsc.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-
|
|
3
|
-
export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-
|
|
2
|
+
import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-DhtH8sAC.mjs';
|
|
3
|
+
export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DhtH8sAC.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 { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-
|
|
3
|
-
export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-
|
|
2
|
+
import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-DhtH8sAC.js';
|
|
3
|
+
export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DhtH8sAC.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
|
@@ -816,8 +816,8 @@ var migrations = [
|
|
|
816
816
|
return data;
|
|
817
817
|
},
|
|
818
818
|
// Migrate zones to slots
|
|
819
|
-
(data, config) => {
|
|
820
|
-
var _a;
|
|
819
|
+
(data, config, migrationOptions) => {
|
|
820
|
+
var _a, _b;
|
|
821
821
|
if (!config) return data;
|
|
822
822
|
console.log("Migrating DropZones to slots...");
|
|
823
823
|
const updatedItems = {};
|
|
@@ -825,13 +825,13 @@ var migrations = [
|
|
|
825
825
|
const { indexes } = walkAppState(appState, config);
|
|
826
826
|
const deletedCompounds = [];
|
|
827
827
|
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
828
|
-
var _a2,
|
|
828
|
+
var _a2, _b2, _c;
|
|
829
829
|
if (zoneType === "dropzone") {
|
|
830
830
|
const [id, slotName] = zoneCompound.split(":");
|
|
831
831
|
const nodeData = indexes.nodes[id].data;
|
|
832
832
|
const componentType = nodeData.type;
|
|
833
833
|
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
834
|
-
if (((
|
|
834
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
835
835
|
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
836
836
|
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
837
837
|
[slotName]: content
|
|
@@ -860,7 +860,49 @@ var migrations = [
|
|
|
860
860
|
);
|
|
861
861
|
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
862
862
|
});
|
|
863
|
-
|
|
863
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
864
|
+
const unmigratedZonesGrouped = {};
|
|
865
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
866
|
+
var _a2;
|
|
867
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
868
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
869
|
+
if (!content) {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
873
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
874
|
+
}
|
|
875
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
876
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
880
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
881
|
+
return content.map((child) => {
|
|
882
|
+
var _a2;
|
|
883
|
+
if (child.props.id !== componentId) {
|
|
884
|
+
return child;
|
|
885
|
+
}
|
|
886
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
887
|
+
if (!migrateFn) {
|
|
888
|
+
return child;
|
|
889
|
+
}
|
|
890
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
891
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
892
|
+
Object.keys(zones).forEach((propName) => {
|
|
893
|
+
var _a3;
|
|
894
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
895
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
896
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
897
|
+
});
|
|
898
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
899
|
+
props: migratedProps
|
|
900
|
+
});
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
864
906
|
const [_, propName] = zoneCompound.split(":");
|
|
865
907
|
throw new Error(
|
|
866
908
|
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
@@ -870,9 +912,9 @@ var migrations = [
|
|
|
870
912
|
return updated.data;
|
|
871
913
|
}
|
|
872
914
|
];
|
|
873
|
-
function migrate(data, config) {
|
|
915
|
+
function migrate(data, config, migrationOptions) {
|
|
874
916
|
return migrations == null ? void 0 : migrations.reduce(
|
|
875
|
-
(acc, migration) => migration(acc, config),
|
|
917
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
876
918
|
data
|
|
877
919
|
);
|
|
878
920
|
}
|
package/dist/rsc.mjs
CHANGED
|
@@ -535,7 +535,12 @@ type PuckAction = {
|
|
|
535
535
|
recordHistory?: boolean;
|
|
536
536
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
537
537
|
|
|
538
|
-
|
|
538
|
+
type MigrationOptions<UserConfig extends Config> = {
|
|
539
|
+
migrateDynamicZonesForComponent?: {
|
|
540
|
+
[ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
|
|
541
|
+
};
|
|
542
|
+
};
|
|
543
|
+
declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
|
|
539
544
|
|
|
540
545
|
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
|
541
546
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
|
@@ -535,7 +535,12 @@ type PuckAction = {
|
|
|
535
535
|
recordHistory?: boolean;
|
|
536
536
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
537
537
|
|
|
538
|
-
|
|
538
|
+
type MigrationOptions<UserConfig extends Config> = {
|
|
539
|
+
migrateDynamicZonesForComponent?: {
|
|
540
|
+
[ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
|
|
541
|
+
};
|
|
542
|
+
};
|
|
543
|
+
declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
|
|
539
544
|
|
|
540
545
|
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
|
541
546
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
package/package.json
CHANGED