@measured/puck 0.19.4-canary.fde74e8a → 0.20.0-canary.33cf4f0e

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/index.mjs CHANGED
@@ -1,18 +1,11 @@
1
1
  import {
2
2
  SlotRender,
3
3
  SlotRenderPure,
4
- __async,
5
- __commonJS,
6
- __objRest,
7
- __spreadProps,
8
- __spreadValues,
9
- __toESM,
10
4
  defaultAppState,
11
5
  defaultSlots,
12
6
  defaultViewports,
13
7
  expandNode,
14
8
  getChanged,
15
- init_react_import,
16
9
  migrate,
17
10
  resolveAllData,
18
11
  resolveComponentData,
@@ -25,7 +18,16 @@ import {
25
18
  walkAppState,
26
19
  walkField,
27
20
  walkTree
28
- } from "./chunk-IM42S4YL.mjs";
21
+ } from "./chunk-IAEXMHQX.mjs";
22
+ import {
23
+ __async,
24
+ __commonJS,
25
+ __objRest,
26
+ __spreadProps,
27
+ __spreadValues,
28
+ __toESM,
29
+ init_react_import
30
+ } from "./chunk-M6W7YEVX.mjs";
29
31
 
30
32
  // ../../node_modules/classnames/index.js
31
33
  var require_classnames = __commonJS({
@@ -89,7 +91,10 @@ var require_classnames = __commonJS({
89
91
  }
90
92
  });
91
93
 
92
- // index.ts
94
+ // bundle/index.ts
95
+ init_react_import();
96
+
97
+ // bundle/core.ts
93
98
  init_react_import();
94
99
 
95
100
  // types/API/index.ts
@@ -3442,9 +3447,8 @@ var ObjectField = ({
3442
3447
  readOnly,
3443
3448
  children: /* @__PURE__ */ jsx17("div", { className: getClassName14(), children: /* @__PURE__ */ jsx17("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
3444
3449
  const subField = field.objectFields[subName];
3445
- const subPath = `${name}.${subName}`;
3446
- const localSubPath = `${localName || name}.${subName}`;
3447
- const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
3450
+ const subPath = `${localName}.${subName}`;
3451
+ const subReadOnly = readOnly ? readOnly : readOnlyFields[subPath];
3448
3452
  const label2 = subField.label || subName;
3449
3453
  return /* @__PURE__ */ jsx17(
3450
3454
  NestedFieldProvider,
@@ -3543,7 +3547,7 @@ var FieldLabelInternal = ({
3543
3547
  );
3544
3548
  };
3545
3549
  function AutoFieldInternal(props) {
3546
- var _a, _b, _c, _d, _e, _f, _g, _h;
3550
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
3547
3551
  const dispatch = useAppStore((s) => s.dispatch);
3548
3552
  const overrides = useAppStore((s) => s.overrides);
3549
3553
  const readOnly = useAppStore((s) => {
@@ -3615,21 +3619,23 @@ function AutoFieldInternal(props) {
3615
3619
  if (field.type === "slot") {
3616
3620
  return null;
3617
3621
  }
3622
+ let children = null;
3623
+ let FieldComponent;
3618
3624
  if (field.type === "custom") {
3619
3625
  if (!field.render) {
3620
3626
  return null;
3621
3627
  }
3622
- const CustomField = field.render;
3623
- return /* @__PURE__ */ jsx18("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx18("div", { className: getClassName15(), children: /* @__PURE__ */ jsx18(CustomField, __spreadValues({}, mergedProps)) }) });
3628
+ FieldComponent = field.render;
3629
+ } else {
3630
+ children = defaultFields[field.type](mergedProps);
3631
+ FieldComponent = render[field.type];
3624
3632
  }
3625
- const children = defaultFields[field.type](mergedProps);
3626
- const Render2 = render[field.type];
3627
3633
  return /* @__PURE__ */ jsx18(
3628
3634
  NestedFieldContext.Provider,
3629
3635
  {
3630
3636
  value: {
3631
3637
  readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
3632
- localName: nestedFieldContext.localName
3638
+ localName: (_i = nestedFieldContext.localName) != null ? _i : mergedProps.name
3633
3639
  },
3634
3640
  children: /* @__PURE__ */ jsx18(
3635
3641
  "div",
@@ -3640,7 +3646,7 @@ function AutoFieldInternal(props) {
3640
3646
  onClick: (e) => {
3641
3647
  e.stopPropagation();
3642
3648
  },
3643
- children: /* @__PURE__ */ jsx18(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
3649
+ children: /* @__PURE__ */ jsx18(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children }))
3644
3650
  }
3645
3651
  )
3646
3652
  }
@@ -0,0 +1,145 @@
1
+ /* styles/color.css */
2
+ :root {
3
+ --puck-color-rose-01: #4a001c;
4
+ --puck-color-rose-02: #670833;
5
+ --puck-color-rose-03: #87114c;
6
+ --puck-color-rose-04: #a81a66;
7
+ --puck-color-rose-05: #bc5089;
8
+ --puck-color-rose-06: #cc7ca5;
9
+ --puck-color-rose-07: #d89aba;
10
+ --puck-color-rose-08: #e3b8cf;
11
+ --puck-color-rose-09: #efd6e3;
12
+ --puck-color-rose-10: #f6eaf1;
13
+ --puck-color-rose-11: #faf4f8;
14
+ --puck-color-rose-12: #fef8fc;
15
+ --puck-color-azure-01: #00175d;
16
+ --puck-color-azure-02: #002c77;
17
+ --puck-color-azure-03: #014292;
18
+ --puck-color-azure-04: #0158ad;
19
+ --puck-color-azure-05: #3479be;
20
+ --puck-color-azure-06: #6499cf;
21
+ --puck-color-azure-07: #88b0da;
22
+ --puck-color-azure-08: #abc7e5;
23
+ --puck-color-azure-09: #cfdff0;
24
+ --puck-color-azure-10: #e7eef7;
25
+ --puck-color-azure-11: #f3f6fb;
26
+ --puck-color-azure-12: #f7faff;
27
+ --puck-color-green-01: #002000;
28
+ --puck-color-green-02: #043604;
29
+ --puck-color-green-03: #084e08;
30
+ --puck-color-green-04: #0c680c;
31
+ --puck-color-green-05: #1d882f;
32
+ --puck-color-green-06: #2faa53;
33
+ --puck-color-green-07: #56c16f;
34
+ --puck-color-green-08: #7dd78b;
35
+ --puck-color-green-09: #b8e8bf;
36
+ --puck-color-green-10: #ddf3e0;
37
+ --puck-color-green-11: #eff8f0;
38
+ --puck-color-green-12: #f3fcf4;
39
+ --puck-color-yellow-01: #211000;
40
+ --puck-color-yellow-02: #362700;
41
+ --puck-color-yellow-03: #4c4000;
42
+ --puck-color-yellow-04: #645a00;
43
+ --puck-color-yellow-05: #877614;
44
+ --puck-color-yellow-06: #ab9429;
45
+ --puck-color-yellow-07: #bfac4e;
46
+ --puck-color-yellow-08: #d4c474;
47
+ --puck-color-yellow-09: #e6deb1;
48
+ --puck-color-yellow-10: #f3efd9;
49
+ --puck-color-yellow-11: #f9f7ed;
50
+ --puck-color-yellow-12: #fcfaf0;
51
+ --puck-color-red-01: #4c0000;
52
+ --puck-color-red-02: #6a0a10;
53
+ --puck-color-red-03: #8a1422;
54
+ --puck-color-red-04: #ac1f35;
55
+ --puck-color-red-05: #bf5366;
56
+ --puck-color-red-06: #ce7e8e;
57
+ --puck-color-red-07: #d99ca8;
58
+ --puck-color-red-08: #e4b9c2;
59
+ --puck-color-red-09: #efd7db;
60
+ --puck-color-red-10: #f6eaec;
61
+ --puck-color-red-11: #faf4f5;
62
+ --puck-color-red-12: #fff9fa;
63
+ --puck-color-grey-01: #181818;
64
+ --puck-color-grey-02: #292929;
65
+ --puck-color-grey-03: #404040;
66
+ --puck-color-grey-04: #5a5a5a;
67
+ --puck-color-grey-05: #767676;
68
+ --puck-color-grey-06: #949494;
69
+ --puck-color-grey-07: #ababab;
70
+ --puck-color-grey-08: #c3c3c3;
71
+ --puck-color-grey-09: #dcdcdc;
72
+ --puck-color-grey-10: #efefef;
73
+ --puck-color-grey-11: #f5f5f5;
74
+ --puck-color-grey-12: #fafafa;
75
+ --puck-color-black: #000000;
76
+ --puck-color-white: #ffffff;
77
+ }
78
+
79
+ /* styles/typography.css */
80
+ :root {
81
+ --puck-font-size-scale-base-unitless: 12;
82
+ --puck-font-size-xxxs-unitless: 12;
83
+ --puck-font-size-xxs-unitless: 14;
84
+ --puck-font-size-xs-unitless: 16;
85
+ --puck-font-size-s-unitless: 18;
86
+ --puck-font-size-m-unitless: 21;
87
+ --puck-font-size-l-unitless: 24;
88
+ --puck-font-size-xl-unitless: 28;
89
+ --puck-font-size-xxl-unitless: 36;
90
+ --puck-font-size-xxxl-unitless: 48;
91
+ --puck-font-size-xxxxl-unitless: 56;
92
+ --puck-font-size-xxxs: calc(1rem * var(--puck-font-size-xxxs-unitless) / 16);
93
+ --puck-font-size-xxs: calc(1rem * var(--puck-font-size-xxs-unitless) / 16);
94
+ --puck-font-size-xs: calc(1rem * var(--puck-font-size-xs-unitless) / 16);
95
+ --puck-font-size-s: calc(1rem * var(--puck-font-size-s-unitless) / 16);
96
+ --puck-font-size-m: calc(1rem * var(--puck-font-size-m-unitless) / 16);
97
+ --puck-font-size-l: calc(1rem * var(--puck-font-size-l-unitless) / 16);
98
+ --puck-font-size-xl: calc(1rem * var(--puck-font-size-xl-unitless) / 16);
99
+ --puck-font-size-xxl: calc(1rem * var(--puck-font-size-xxl-unitless) / 16);
100
+ --puck-font-size-xxxl: calc(1rem * var(--puck-font-size-xxxl-unitless) / 16);
101
+ --puck-font-size-xxxxl: calc( 1rem * var(--puck-font-size-xxxxl-unitless) / 16 );
102
+ --puck-font-size-base: var(--puck-font-size-xs);
103
+ --line-height-reset: 1;
104
+ --line-height-xs: calc( var(--space-m-unitless) / var(--puck-font-size-m-unitless) );
105
+ --line-height-s: calc( var(--space-m-unitless) / var(--puck-font-size-s-unitless) );
106
+ --line-height-m: calc( var(--space-m-unitless) / var(--puck-font-size-xs-unitless) );
107
+ --line-height-l: calc( var(--space-m-unitless) / var(--puck-font-size-xxs-unitless) );
108
+ --line-height-xl: calc( var(--space-m-unitless) / var(--puck-font-size-scale-base-unitless) );
109
+ --line-height-base: var(--line-height-m);
110
+ --fallback-font-stack:
111
+ -apple-system,
112
+ BlinkMacSystemFont,
113
+ Segoe UI,
114
+ Helvetica Neue,
115
+ sans-serif,
116
+ Apple Color Emoji,
117
+ Segoe UI Emoji,
118
+ Segoe UI Symbol;
119
+ --puck-font-family: Inter, var(--fallback-font-stack);
120
+ --puck-font-family-monospaced:
121
+ ui-monospace,
122
+ "Cascadia Code",
123
+ "Source Code Pro",
124
+ Menlo,
125
+ Consolas,
126
+ "DejaVu Sans Mono",
127
+ monospace;
128
+ }
129
+ @supports (font-variation-settings: normal) {
130
+ :root {
131
+ --puck-font-family: InterVariable, var(--fallback-font-stack);
132
+ }
133
+ }
134
+
135
+ /* bundle/core.css */
136
+ #frame-root {
137
+ height: 1px;
138
+ min-height: 100vh;
139
+ }
140
+ [data-puck-entry] {
141
+ position: relative;
142
+ z-index: 0;
143
+ }
144
+
145
+ /* bundle/no-external.css */
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+
25
+ // ../tsup-config/react-import.js
26
+ var import_react = __toESM(require("react"));
@@ -0,0 +1,6 @@
1
+ import {
2
+ init_react_import
3
+ } from "./chunk-M6W7YEVX.mjs";
4
+
5
+ // bundle/no-external.ts
6
+ 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 { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-DrJNb8b-.mjs';
3
- export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DrJNb8b-.mjs';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-6p9XnDIV.mjs';
3
+ export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-6p9XnDIV.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-DrJNb8b-.js';
3
- export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DrJNb8b-.js';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-6p9XnDIV.js';
3
+ export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-6p9XnDIV.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
@@ -64,7 +64,7 @@ var __async = (__this, __arguments, generator) => {
64
64
  });
65
65
  };
66
66
 
67
- // rsc.tsx
67
+ // bundle/rsc.tsx
68
68
  var rsc_exports = {};
69
69
  __export(rsc_exports, {
70
70
  Render: () => Render,
@@ -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, _b, _c;
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 (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
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
- Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
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
@@ -4,7 +4,13 @@ import {
4
4
  resolveAllData,
5
5
  transformProps,
6
6
  walkTree
7
- } from "./chunk-IM42S4YL.mjs";
7
+ } from "./chunk-IAEXMHQX.mjs";
8
+ import {
9
+ init_react_import
10
+ } from "./chunk-M6W7YEVX.mjs";
11
+
12
+ // bundle/rsc.tsx
13
+ init_react_import();
8
14
  export {
9
15
  Render,
10
16
  migrate,
@@ -49,11 +49,11 @@ type RadioField = BaseField & {
49
49
  type: "radio";
50
50
  options: FieldOptions;
51
51
  };
52
- type ArrayField<Props extends {
52
+ type ArrayField<Props extends any = {
53
53
  [key: string]: any;
54
- } = {
54
+ }> = Props extends {
55
55
  [key: string]: any;
56
- }> = BaseField & {
56
+ } ? BaseField & {
57
57
  type: "array";
58
58
  arrayFields: {
59
59
  [SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
@@ -62,14 +62,12 @@ type ArrayField<Props extends {
62
62
  getItemSummary?: (item: Props[0], index?: number) => string;
63
63
  max?: number;
64
64
  min?: number;
65
- };
66
- type ObjectField<Props extends {
67
- [key: string]: any;
68
- } = {
65
+ } : never;
66
+ type ObjectField<Props extends any = {
69
67
  [key: string]: any;
70
68
  }> = BaseField & {
71
69
  type: "object";
72
- objectFields: Props extends any[] ? never : {
70
+ objectFields: {
73
71
  [SubPropName in keyof Props]: Field<Props[SubPropName]>;
74
72
  };
75
73
  };
@@ -78,20 +76,17 @@ type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, Pr
78
76
  fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
79
77
  mapProp?: (value: TableShape) => PropShape;
80
78
  };
81
- type ExternalFieldWithAdaptor<Props extends {
82
- [key: string]: any;
83
- } = {
79
+ type NotUndefined<T> = T extends undefined ? Record<string, any> : T;
80
+ type ExternalFieldWithAdaptor<Props extends any = {
84
81
  [key: string]: any;
85
82
  }> = BaseField & {
86
83
  type: "external";
87
84
  placeholder?: string;
88
85
  adaptor: Adaptor<any, any, Props>;
89
86
  adaptorParams?: object;
90
- getItemSummary: (item: Props, index?: number) => string;
87
+ getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
91
88
  };
92
- type ExternalField<Props extends {
93
- [key: string]: any;
94
- } = {
89
+ type ExternalField<Props extends any = {
95
90
  [key: string]: any;
96
91
  }> = BaseField & {
97
92
  type: "external";
@@ -102,7 +97,7 @@ type ExternalField<Props extends {
102
97
  }) => Promise<any[] | null>;
103
98
  mapProp?: (value: any) => Props;
104
99
  mapRow?: (value: any) => Record<string, string | number | ReactElement>;
105
- getItemSummary?: (item: Props, index?: number) => string;
100
+ getItemSummary?: (item: NotUndefined<Props>, index?: number) => string;
106
101
  showSearch?: boolean;
107
102
  renderFooter?: (props: {
108
103
  items: any[];
@@ -128,15 +123,7 @@ type SlotField = BaseField & {
128
123
  allow?: string[];
129
124
  disallow?: string[];
130
125
  };
131
- type Field<Props extends any = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props extends {
132
- [key: string]: any;
133
- } ? Props : any> | ObjectField<Props extends {
134
- [key: string]: any;
135
- } ? Props : any> | ExternalField<Props extends {
136
- [key: string]: any;
137
- } ? Props : any> | ExternalFieldWithAdaptor<Props extends {
138
- [key: string]: any;
139
- } ? Props : any> | CustomField<Props> | SlotField;
126
+ type Field<ValueType = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType> | ObjectField<ValueType> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
140
127
  type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
141
128
  [PropName in keyof Omit<ComponentProps, "editMode">]: Field<ComponentProps[PropName]>;
142
129
  };
@@ -535,7 +522,12 @@ type PuckAction = {
535
522
  recordHistory?: boolean;
536
523
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
537
524
 
538
- declare function migrate(data: Data, config?: Config): Data;
525
+ type MigrationOptions<UserConfig extends Config> = {
526
+ migrateDynamicZonesForComponent?: {
527
+ [ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
528
+ };
529
+ };
530
+ declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
539
531
 
540
532
  type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
541
533
  [ComponentName in keyof Props]: (props: Props[ComponentName] & {
@@ -556,4 +548,4 @@ type WalkTreeOptions = {
556
548
  };
557
549
  declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
558
550
 
559
- export { type ExternalFieldWithAdaptor as $, type AppState as A, type BaseData as B, type ComponentData as C, type DropZoneProps as D, type MappedItem as E, type Fields as F, type ComponentDataMap as G, type History as H, type IframeConfig as I, type Content as J, type BaseField as K, type TextareaField as L, type Metadata as M, type NumberField as N, type Overrides as O, type Permissions as P, type SelectField as Q, type RootDataWithProps as R, type Slot as S, type TextField as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type RadioField as X, type ArrayField as Y, type ObjectField as Z, type Adaptor as _, type Config as a, type ExternalField as a0, type CustomFieldRender as a1, type CustomField as a2, type SlotField as a3, type PuckContext as a4, type DefaultRootFieldProps as a5, type DefaultRootRenderProps as a6, type DefaultRootProps as a7, type DefaultComponentProps as a8, type WithId as a9, type WithPuckProps as aa, type AsFieldProps as ab, type WithChildren as ac, type ExtractPropsFromConfig as ad, type ExtractRootPropsFromConfig as ae, migrate as af, transformProps as ag, resolveAllData as ah, 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 ItemSelector as l, type Direction as m, type DragAxis as n, type Viewport as o, overrideKeys as p, type OverrideKey as q, type FieldRenderFunctions as r, type ItemWithId as s, type ArrayState as t, type PuckComponent as u, type RootConfig as v, walkTree as w, type RootDataWithoutProps as x, type RootData as y, type ComponentDataOptionalId as z };
551
+ export { type ArrayField as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type RootDataWithoutProps as E, type Fields as F, type RootData as G, type History as H, type IframeConfig as I, type ComponentDataOptionalId as J, type MappedItem as K, type ComponentDataMap as L, type Metadata as M, type Content as N, type Overrides as O, type Permissions as P, type BaseField as Q, type RootDataWithProps as R, type Slot as S, type TextField as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type NumberField as X, type TextareaField as Y, type SelectField as Z, type RadioField as _, type ComponentData as a, type ObjectField as a0, type Adaptor as a1, type ExternalFieldWithAdaptor as a2, type ExternalField as a3, type CustomFieldRender as a4, type CustomField as a5, type SlotField as a6, type PuckContext as a7, type DefaultRootFieldProps as a8, type DefaultRootRenderProps as a9, type DefaultRootProps as aa, type DefaultComponentProps as ab, type WithId as ac, type WithPuckProps as ad, type AsFieldProps as ae, type WithChildren as af, type ExtractPropsFromConfig as ag, type ExtractRootPropsFromConfig as ah, 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 ItemSelector as l, migrate as m, type Direction as n, type DragAxis as o, type Viewport as p, overrideKeys as q, resolveAllData as r, type OverrideKey as s, transformProps as t, type FieldRenderFunctions as u, type ItemWithId as v, walkTree as w, type ArrayState as x, type PuckComponent as y, type RootConfig as z };
@@ -49,11 +49,11 @@ type RadioField = BaseField & {
49
49
  type: "radio";
50
50
  options: FieldOptions;
51
51
  };
52
- type ArrayField<Props extends {
52
+ type ArrayField<Props extends any = {
53
53
  [key: string]: any;
54
- } = {
54
+ }> = Props extends {
55
55
  [key: string]: any;
56
- }> = BaseField & {
56
+ } ? BaseField & {
57
57
  type: "array";
58
58
  arrayFields: {
59
59
  [SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
@@ -62,14 +62,12 @@ type ArrayField<Props extends {
62
62
  getItemSummary?: (item: Props[0], index?: number) => string;
63
63
  max?: number;
64
64
  min?: number;
65
- };
66
- type ObjectField<Props extends {
67
- [key: string]: any;
68
- } = {
65
+ } : never;
66
+ type ObjectField<Props extends any = {
69
67
  [key: string]: any;
70
68
  }> = BaseField & {
71
69
  type: "object";
72
- objectFields: Props extends any[] ? never : {
70
+ objectFields: {
73
71
  [SubPropName in keyof Props]: Field<Props[SubPropName]>;
74
72
  };
75
73
  };
@@ -78,20 +76,17 @@ type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, Pr
78
76
  fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
79
77
  mapProp?: (value: TableShape) => PropShape;
80
78
  };
81
- type ExternalFieldWithAdaptor<Props extends {
82
- [key: string]: any;
83
- } = {
79
+ type NotUndefined<T> = T extends undefined ? Record<string, any> : T;
80
+ type ExternalFieldWithAdaptor<Props extends any = {
84
81
  [key: string]: any;
85
82
  }> = BaseField & {
86
83
  type: "external";
87
84
  placeholder?: string;
88
85
  adaptor: Adaptor<any, any, Props>;
89
86
  adaptorParams?: object;
90
- getItemSummary: (item: Props, index?: number) => string;
87
+ getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
91
88
  };
92
- type ExternalField<Props extends {
93
- [key: string]: any;
94
- } = {
89
+ type ExternalField<Props extends any = {
95
90
  [key: string]: any;
96
91
  }> = BaseField & {
97
92
  type: "external";
@@ -102,7 +97,7 @@ type ExternalField<Props extends {
102
97
  }) => Promise<any[] | null>;
103
98
  mapProp?: (value: any) => Props;
104
99
  mapRow?: (value: any) => Record<string, string | number | ReactElement>;
105
- getItemSummary?: (item: Props, index?: number) => string;
100
+ getItemSummary?: (item: NotUndefined<Props>, index?: number) => string;
106
101
  showSearch?: boolean;
107
102
  renderFooter?: (props: {
108
103
  items: any[];
@@ -128,15 +123,7 @@ type SlotField = BaseField & {
128
123
  allow?: string[];
129
124
  disallow?: string[];
130
125
  };
131
- type Field<Props extends any = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props extends {
132
- [key: string]: any;
133
- } ? Props : any> | ObjectField<Props extends {
134
- [key: string]: any;
135
- } ? Props : any> | ExternalField<Props extends {
136
- [key: string]: any;
137
- } ? Props : any> | ExternalFieldWithAdaptor<Props extends {
138
- [key: string]: any;
139
- } ? Props : any> | CustomField<Props> | SlotField;
126
+ type Field<ValueType = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType> | ObjectField<ValueType> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
140
127
  type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
141
128
  [PropName in keyof Omit<ComponentProps, "editMode">]: Field<ComponentProps[PropName]>;
142
129
  };
@@ -535,7 +522,12 @@ type PuckAction = {
535
522
  recordHistory?: boolean;
536
523
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
537
524
 
538
- declare function migrate(data: Data, config?: Config): Data;
525
+ type MigrationOptions<UserConfig extends Config> = {
526
+ migrateDynamicZonesForComponent?: {
527
+ [ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
528
+ };
529
+ };
530
+ declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
539
531
 
540
532
  type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
541
533
  [ComponentName in keyof Props]: (props: Props[ComponentName] & {
@@ -556,4 +548,4 @@ type WalkTreeOptions = {
556
548
  };
557
549
  declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
558
550
 
559
- export { type ExternalFieldWithAdaptor as $, type AppState as A, type BaseData as B, type ComponentData as C, type DropZoneProps as D, type MappedItem as E, type Fields as F, type ComponentDataMap as G, type History as H, type IframeConfig as I, type Content as J, type BaseField as K, type TextareaField as L, type Metadata as M, type NumberField as N, type Overrides as O, type Permissions as P, type SelectField as Q, type RootDataWithProps as R, type Slot as S, type TextField as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type RadioField as X, type ArrayField as Y, type ObjectField as Z, type Adaptor as _, type Config as a, type ExternalField as a0, type CustomFieldRender as a1, type CustomField as a2, type SlotField as a3, type PuckContext as a4, type DefaultRootFieldProps as a5, type DefaultRootRenderProps as a6, type DefaultRootProps as a7, type DefaultComponentProps as a8, type WithId as a9, type WithPuckProps as aa, type AsFieldProps as ab, type WithChildren as ac, type ExtractPropsFromConfig as ad, type ExtractRootPropsFromConfig as ae, migrate as af, transformProps as ag, resolveAllData as ah, 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 ItemSelector as l, type Direction as m, type DragAxis as n, type Viewport as o, overrideKeys as p, type OverrideKey as q, type FieldRenderFunctions as r, type ItemWithId as s, type ArrayState as t, type PuckComponent as u, type RootConfig as v, walkTree as w, type RootDataWithoutProps as x, type RootData as y, type ComponentDataOptionalId as z };
551
+ export { type ArrayField as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type RootDataWithoutProps as E, type Fields as F, type RootData as G, type History as H, type IframeConfig as I, type ComponentDataOptionalId as J, type MappedItem as K, type ComponentDataMap as L, type Metadata as M, type Content as N, type Overrides as O, type Permissions as P, type BaseField as Q, type RootDataWithProps as R, type Slot as S, type TextField as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type NumberField as X, type TextareaField as Y, type SelectField as Z, type RadioField as _, type ComponentData as a, type ObjectField as a0, type Adaptor as a1, type ExternalFieldWithAdaptor as a2, type ExternalField as a3, type CustomFieldRender as a4, type CustomField as a5, type SlotField as a6, type PuckContext as a7, type DefaultRootFieldProps as a8, type DefaultRootRenderProps as a9, type DefaultRootProps as aa, type DefaultComponentProps as ab, type WithId as ac, type WithPuckProps as ad, type AsFieldProps as ae, type WithChildren as af, type ExtractPropsFromConfig as ag, type ExtractRootPropsFromConfig as ah, 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 ItemSelector as l, migrate as m, type Direction as n, type DragAxis as o, type Viewport as p, overrideKeys as q, resolveAllData as r, type OverrideKey as s, transformProps as t, type FieldRenderFunctions as u, type ItemWithId as v, walkTree as w, type ArrayState as x, type PuckComponent as y, type RootConfig as z };