@measured/puck 0.20.0-canary.3da831b0 → 0.20.0-canary.68dd73b8

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.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-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';
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-BOSl1o0G.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-BOSl1o0G.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';
@@ -249,9 +249,6 @@ declare function Render<UserConfig extends Config = Config, G extends UserGeneri
249
249
  metadata?: Metadata;
250
250
  }): react_jsx_runtime.JSX.Element;
251
251
 
252
- type WithGet<T> = T & {
253
- get: () => T;
254
- };
255
252
  type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
256
253
  appState: AppState;
257
254
  config: UserConfig;
@@ -274,7 +271,7 @@ type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<User
274
271
  };
275
272
  };
276
273
  type PuckApi<UserConfig extends Config = Config> = UsePuckData<UserConfig>;
277
- type UsePuckStore<UserConfig extends Config = Config> = WithGet<PuckApi<UserConfig>>;
274
+ type UsePuckStore<UserConfig extends Config = Config> = PuckApi<UserConfig>;
278
275
  /**
279
276
  * createUsePuck
280
277
  *
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-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';
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-BOSl1o0G.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-BOSl1o0G.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';
@@ -249,9 +249,6 @@ declare function Render<UserConfig extends Config = Config, G extends UserGeneri
249
249
  metadata?: Metadata;
250
250
  }): react_jsx_runtime.JSX.Element;
251
251
 
252
- type WithGet<T> = T & {
253
- get: () => T;
254
- };
255
252
  type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
256
253
  appState: AppState;
257
254
  config: UserConfig;
@@ -274,7 +271,7 @@ type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<User
274
271
  };
275
272
  };
276
273
  type PuckApi<UserConfig extends Config = Config> = UsePuckData<UserConfig>;
277
- type UsePuckStore<UserConfig extends Config = Config> = WithGet<PuckApi<UserConfig>>;
274
+ type UsePuckStore<UserConfig extends Config = Config> = PuckApi<UserConfig>;
278
275
  /**
279
276
  * createUsePuck
280
277
  *
package/dist/index.js CHANGED
@@ -4699,19 +4699,9 @@ var DropZoneProvider = ({
4699
4699
  },
4700
4700
  [dispatch]
4701
4701
  );
4702
- const unregisterZone = (0, import_react25.useCallback)(
4703
- (zoneCompound) => {
4704
- dispatch({
4705
- type: "unregisterZone",
4706
- zone: zoneCompound
4707
- });
4708
- },
4709
- [dispatch]
4710
- );
4711
4702
  const memoValue = (0, import_react25.useMemo)(
4712
4703
  () => __spreadValues({
4713
- registerZone,
4714
- unregisterZone
4704
+ registerZone
4715
4705
  }, value),
4716
4706
  [value]
4717
4707
  );
@@ -5693,6 +5683,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
5693
5683
  collisionAxis
5694
5684
  }, userRef) {
5695
5685
  const ctx = (0, import_react35.useContext)(dropZoneContext);
5686
+ const appStoreApi = useAppStoreApi();
5696
5687
  const {
5697
5688
  // These all need setting via context
5698
5689
  areaId,
@@ -5734,13 +5725,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
5734
5725
  if (ctx == null ? void 0 : ctx.registerZone) {
5735
5726
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5736
5727
  }
5737
- return () => {
5738
- if (ctx == null ? void 0 : ctx.unregisterZone) {
5739
- ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
5740
- }
5741
- };
5742
5728
  }
5743
- }, [zoneType]);
5729
+ }, [zoneType, appStoreApi]);
5744
5730
  (0, import_react35.useEffect)(() => {
5745
5731
  if (zoneType === "dropzone") {
5746
5732
  if (zoneCompound !== rootDroppableId) {
@@ -5912,11 +5898,6 @@ var DropZoneRender2 = (0, import_react35.forwardRef)(
5912
5898
  if (ctx == null ? void 0 : ctx.registerZone) {
5913
5899
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5914
5900
  }
5915
- return () => {
5916
- if (ctx == null ? void 0 : ctx.unregisterZone) {
5917
- ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
5918
- }
5919
- };
5920
5901
  }
5921
5902
  }, [content]);
5922
5903
  if (!data || !config) {
@@ -6177,6 +6158,7 @@ var findDeepestCandidate = (position, manager) => {
6177
6158
  });
6178
6159
  filteredCandidates.reverse();
6179
6160
  const primaryCandidate = filteredCandidates[0];
6161
+ if (!primaryCandidate) return { zone: null, area: null };
6180
6162
  const primaryCandidateData = primaryCandidate.data;
6181
6163
  const primaryCandidateIsComponent = "containsActiveZone" in primaryCandidateData;
6182
6164
  const zone = getZoneId2(primaryCandidate);
@@ -7591,7 +7573,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
7591
7573
  editMode: true,
7592
7574
  children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
7593
7575
  })
7594
- ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render2, { data: renderData, config });
7576
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render2, { data: renderData, config, metadata });
7595
7577
  (0, import_react46.useEffect)(() => {
7596
7578
  if (!iframe.enabled) {
7597
7579
  setStatus("READY");
@@ -8476,8 +8458,7 @@ var generateUsePuck = (store) => {
8476
8458
  return { zone: zoneCompound, index };
8477
8459
  }
8478
8460
  };
8479
- const get = () => storeData;
8480
- return __spreadProps(__spreadValues({}, storeData), { get });
8461
+ return storeData;
8481
8462
  };
8482
8463
  var UsePuckStoreContext = (0, import_react54.createContext)(
8483
8464
  null
package/dist/index.mjs CHANGED
@@ -3808,19 +3808,9 @@ var DropZoneProvider = ({
3808
3808
  },
3809
3809
  [dispatch]
3810
3810
  );
3811
- const unregisterZone = useCallback5(
3812
- (zoneCompound) => {
3813
- dispatch({
3814
- type: "unregisterZone",
3815
- zone: zoneCompound
3816
- });
3817
- },
3818
- [dispatch]
3819
- );
3820
3811
  const memoValue = useMemo6(
3821
3812
  () => __spreadValues({
3822
- registerZone,
3823
- unregisterZone
3813
+ registerZone
3824
3814
  }, value),
3825
3815
  [value]
3826
3816
  );
@@ -4802,6 +4792,7 @@ var DropZoneEdit = forwardRef3(
4802
4792
  collisionAxis
4803
4793
  }, userRef) {
4804
4794
  const ctx = useContext7(dropZoneContext);
4795
+ const appStoreApi = useAppStoreApi();
4805
4796
  const {
4806
4797
  // These all need setting via context
4807
4798
  areaId,
@@ -4843,13 +4834,8 @@ var DropZoneEdit = forwardRef3(
4843
4834
  if (ctx == null ? void 0 : ctx.registerZone) {
4844
4835
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
4845
4836
  }
4846
- return () => {
4847
- if (ctx == null ? void 0 : ctx.unregisterZone) {
4848
- ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
4849
- }
4850
- };
4851
4837
  }
4852
- }, [zoneType]);
4838
+ }, [zoneType, appStoreApi]);
4853
4839
  useEffect16(() => {
4854
4840
  if (zoneType === "dropzone") {
4855
4841
  if (zoneCompound !== rootDroppableId) {
@@ -5021,11 +5007,6 @@ var DropZoneRender = forwardRef3(
5021
5007
  if (ctx == null ? void 0 : ctx.registerZone) {
5022
5008
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5023
5009
  }
5024
- return () => {
5025
- if (ctx == null ? void 0 : ctx.unregisterZone) {
5026
- ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
5027
- }
5028
- };
5029
5010
  }
5030
5011
  }, [content]);
5031
5012
  if (!data || !config) {
@@ -5286,6 +5267,7 @@ var findDeepestCandidate = (position, manager) => {
5286
5267
  });
5287
5268
  filteredCandidates.reverse();
5288
5269
  const primaryCandidate = filteredCandidates[0];
5270
+ if (!primaryCandidate) return { zone: null, area: null };
5289
5271
  const primaryCandidateData = primaryCandidate.data;
5290
5272
  const primaryCandidateIsComponent = "containsActiveZone" in primaryCandidateData;
5291
5273
  const zone = getZoneId(primaryCandidate);
@@ -6713,7 +6695,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
6713
6695
  editMode: true,
6714
6696
  children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
6715
6697
  })
6716
- ) : /* @__PURE__ */ jsx32(Render, { data: renderData, config });
6698
+ ) : /* @__PURE__ */ jsx32(Render, { data: renderData, config, metadata });
6717
6699
  useEffect20(() => {
6718
6700
  if (!iframe.enabled) {
6719
6701
  setStatus("READY");
@@ -7604,8 +7586,7 @@ var generateUsePuck = (store) => {
7604
7586
  return { zone: zoneCompound, index };
7605
7587
  }
7606
7588
  };
7607
- const get = () => storeData;
7608
- return __spreadProps(__spreadValues({}, storeData), { get });
7589
+ return storeData;
7609
7590
  };
7610
7591
  var UsePuckStoreContext = createContext6(
7611
7592
  null
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-DhtH8sAC.mjs';
3
- export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DhtH8sAC.mjs';
2
+ import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-BOSl1o0G.mjs';
3
+ export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-BOSl1o0G.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-DhtH8sAC.js';
3
- export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DhtH8sAC.js';
2
+ import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-BOSl1o0G.js';
3
+ export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-BOSl1o0G.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, }: {
@@ -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
  };
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.20.0-canary.3da831b0",
3
+ "version": "0.20.0-canary.68dd73b8",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",