@measured/puck 0.20.0-canary.8c56aa8b → 0.20.0-canary.b2d0f01a

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/rsc.mjs CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  resolveAllData,
6
6
  transformProps,
7
7
  walkTree
8
- } from "./chunk-32MJ3X3H.mjs";
8
+ } from "./chunk-IP64IXIP.mjs";
9
9
 
10
10
  // bundle/rsc.tsx
11
11
  init_react_import();
@@ -29,6 +29,7 @@ type BaseField = {
29
29
  type TextField = BaseField & {
30
30
  type: "text";
31
31
  placeholder?: string;
32
+ contentEditable?: boolean;
32
33
  };
33
34
  type NumberField = BaseField & {
34
35
  type: "number";
@@ -40,6 +41,7 @@ type NumberField = BaseField & {
40
41
  type TextareaField = BaseField & {
41
42
  type: "textarea";
42
43
  placeholder?: string;
44
+ contentEditable?: boolean;
43
45
  };
44
46
  type SelectField = BaseField & {
45
47
  type: "select";
@@ -117,6 +119,7 @@ type CustomFieldRender<Value extends any> = (props: {
117
119
  type CustomField<Value extends any> = BaseField & {
118
120
  type: "custom";
119
121
  render: CustomFieldRender<Value>;
122
+ contentEditable?: boolean;
120
123
  };
121
124
  type SlotField = BaseField & {
122
125
  type: "slot";
@@ -218,6 +221,9 @@ type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractP
218
221
  UserPublicAppState: UserPublicAppState;
219
222
  UserComponentData: UserComponentData;
220
223
  };
224
+ type ExtractField<T extends Field["type"]> = Extract<Field, {
225
+ type: T;
226
+ }>;
221
227
 
222
228
  type PuckContext = {
223
229
  renderDropZone: React.FC<DropZoneProps>;
@@ -278,6 +284,7 @@ type Metadata = {
278
284
  type ItemWithId = {
279
285
  _arrayId: string;
280
286
  _originalIndex: number;
287
+ _currentIndex: number;
281
288
  };
282
289
  type ArrayState = {
283
290
  items: ItemWithId[];
@@ -343,12 +350,29 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
343
350
  type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (infer U)[] ? Array<WithDeepSlots<U, SlotType>> : T extends (infer U)[] ? WithDeepSlots<U, SlotType>[] : T extends BuiltinTypes ? T : T extends object ? {
344
351
  [K in keyof T]: WithDeepSlots<T[K], SlotType>;
345
352
  } : T;
346
-
347
353
  type RenderFunc<Props extends {
348
354
  [key: string]: any;
349
355
  } = {
350
356
  children: ReactNode;
351
357
  }> = (props: Props) => ReactElement;
358
+
359
+ type MapFnParams<ThisField = Field> = {
360
+ value: any;
361
+ parentId: string;
362
+ propName: string;
363
+ field: ThisField;
364
+ propPath: string;
365
+ };
366
+
367
+ type FieldTransformFnParams<T> = Omit<MapFnParams<T>, "parentId"> & {
368
+ isReadOnly: boolean;
369
+ componentId: string;
370
+ };
371
+ type FieldTransformFn<T = any> = (params: FieldTransformFnParams<T>) => any;
372
+ type FieldTransforms = Partial<{
373
+ [FieldType in Field["type"]]: FieldTransformFn<ExtractField<FieldType>>;
374
+ }>;
375
+
352
376
  declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
353
377
  type OverrideKey = (typeof overrideKeys)[number];
354
378
  type OverridesGeneric<Shape extends {
@@ -445,7 +469,12 @@ type IframeConfig = {
445
469
  };
446
470
  type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
447
471
  type Plugin = {
448
- overrides: Partial<Overrides>;
472
+ name?: string;
473
+ label?: string;
474
+ icon?: ReactNode;
475
+ render?: () => ReactElement;
476
+ overrides?: Partial<Overrides>;
477
+ fieldTransforms?: FieldTransforms;
449
478
  };
450
479
  type History<D = any> = {
451
480
  state: D;
@@ -563,4 +592,4 @@ type WalkTreeOptions = {
563
592
  };
564
593
  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;
565
594
 
566
- export { type RadioField as $, type AppState as A, type RootConfig as B, type Config as C, type DropZoneProps as D, type BaseData as E, type Fields as F, type RootDataWithoutProps as G, type History as H, type IframeConfig as I, type RootData as J, type ComponentDataOptionalId as K, type MappedItem as L, type Metadata as M, type ComponentDataMap as N, type Overrides as O, type Permissions as P, type Content as Q, type RootDataWithProps as R, type Slot as S, type BaseField as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type TextField as X, type NumberField as Y, type TextareaField as Z, type SelectField as _, type ComponentData as a, type ArrayField as a0, type ObjectField as a1, type Adaptor as a2, type ExternalFieldWithAdaptor as a3, type ExternalField as a4, type CustomFieldRender as a5, type CustomField as a6, type SlotField as a7, type PuckContext as a8, type DefaultRootFieldProps as a9, type DefaultRootRenderProps as aa, type DefaultRootProps as ab, type DefaultComponentProps as ac, type WithId as ad, type WithPuckProps as ae, type AsFieldProps as af, type WithChildren as ag, type ExtractPropsFromConfig as ah, type ExtractRootPropsFromConfig as ai, 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 SlotComponent as y, type PuckComponent as z };
595
+ export { type NumberField as $, type AppState as A, type ArrayState as B, type Config as C, type DropZoneProps as D, type SlotComponent as E, type Fields as F, type PuckComponent as G, type History as H, type IframeConfig as I, type RootConfig as J, type BaseData as K, type RootDataWithoutProps as L, type Metadata as M, type RootData as N, type Overrides as O, type Permissions as P, type ComponentDataOptionalId as Q, type RootDataWithProps as R, type Slot as S, type MappedItem as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ComponentDataMap as X, type Content as Y, type BaseField as Z, type TextField as _, type ComponentData as a, type TextareaField as a0, type SelectField as a1, type RadioField as a2, type ArrayField as a3, type ObjectField as a4, type Adaptor as a5, type ExternalFieldWithAdaptor as a6, type ExternalField as a7, type CustomFieldRender as a8, type CustomField as a9, type SlotField as aa, type PuckContext as ab, type DefaultRootFieldProps as ac, type DefaultRootRenderProps as ad, type DefaultRootProps as ae, type DefaultComponentProps as af, type WithId as ag, type WithPuckProps as ah, type AsFieldProps as ai, type WithChildren as aj, type ExtractPropsFromConfig as ak, type ExtractRootPropsFromConfig as al, type ExtractField as am, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type FieldTransforms as g, type Field as h, type FieldProps as i, type Data as j, type OnAction as k, type InitialHistory as l, migrate as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, resolveAllData as r, type FieldTransformFnParams as s, transformProps as t, type FieldTransformFn as u, overrideKeys as v, walkTree as w, type OverrideKey as x, type FieldRenderFunctions as y, type ItemWithId as z };
@@ -29,6 +29,7 @@ type BaseField = {
29
29
  type TextField = BaseField & {
30
30
  type: "text";
31
31
  placeholder?: string;
32
+ contentEditable?: boolean;
32
33
  };
33
34
  type NumberField = BaseField & {
34
35
  type: "number";
@@ -40,6 +41,7 @@ type NumberField = BaseField & {
40
41
  type TextareaField = BaseField & {
41
42
  type: "textarea";
42
43
  placeholder?: string;
44
+ contentEditable?: boolean;
43
45
  };
44
46
  type SelectField = BaseField & {
45
47
  type: "select";
@@ -117,6 +119,7 @@ type CustomFieldRender<Value extends any> = (props: {
117
119
  type CustomField<Value extends any> = BaseField & {
118
120
  type: "custom";
119
121
  render: CustomFieldRender<Value>;
122
+ contentEditable?: boolean;
120
123
  };
121
124
  type SlotField = BaseField & {
122
125
  type: "slot";
@@ -218,6 +221,9 @@ type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractP
218
221
  UserPublicAppState: UserPublicAppState;
219
222
  UserComponentData: UserComponentData;
220
223
  };
224
+ type ExtractField<T extends Field["type"]> = Extract<Field, {
225
+ type: T;
226
+ }>;
221
227
 
222
228
  type PuckContext = {
223
229
  renderDropZone: React.FC<DropZoneProps>;
@@ -278,6 +284,7 @@ type Metadata = {
278
284
  type ItemWithId = {
279
285
  _arrayId: string;
280
286
  _originalIndex: number;
287
+ _currentIndex: number;
281
288
  };
282
289
  type ArrayState = {
283
290
  items: ItemWithId[];
@@ -343,12 +350,29 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
343
350
  type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (infer U)[] ? Array<WithDeepSlots<U, SlotType>> : T extends (infer U)[] ? WithDeepSlots<U, SlotType>[] : T extends BuiltinTypes ? T : T extends object ? {
344
351
  [K in keyof T]: WithDeepSlots<T[K], SlotType>;
345
352
  } : T;
346
-
347
353
  type RenderFunc<Props extends {
348
354
  [key: string]: any;
349
355
  } = {
350
356
  children: ReactNode;
351
357
  }> = (props: Props) => ReactElement;
358
+
359
+ type MapFnParams<ThisField = Field> = {
360
+ value: any;
361
+ parentId: string;
362
+ propName: string;
363
+ field: ThisField;
364
+ propPath: string;
365
+ };
366
+
367
+ type FieldTransformFnParams<T> = Omit<MapFnParams<T>, "parentId"> & {
368
+ isReadOnly: boolean;
369
+ componentId: string;
370
+ };
371
+ type FieldTransformFn<T = any> = (params: FieldTransformFnParams<T>) => any;
372
+ type FieldTransforms = Partial<{
373
+ [FieldType in Field["type"]]: FieldTransformFn<ExtractField<FieldType>>;
374
+ }>;
375
+
352
376
  declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
353
377
  type OverrideKey = (typeof overrideKeys)[number];
354
378
  type OverridesGeneric<Shape extends {
@@ -445,7 +469,12 @@ type IframeConfig = {
445
469
  };
446
470
  type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
447
471
  type Plugin = {
448
- overrides: Partial<Overrides>;
472
+ name?: string;
473
+ label?: string;
474
+ icon?: ReactNode;
475
+ render?: () => ReactElement;
476
+ overrides?: Partial<Overrides>;
477
+ fieldTransforms?: FieldTransforms;
449
478
  };
450
479
  type History<D = any> = {
451
480
  state: D;
@@ -563,4 +592,4 @@ type WalkTreeOptions = {
563
592
  };
564
593
  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;
565
594
 
566
- export { type RadioField as $, type AppState as A, type RootConfig as B, type Config as C, type DropZoneProps as D, type BaseData as E, type Fields as F, type RootDataWithoutProps as G, type History as H, type IframeConfig as I, type RootData as J, type ComponentDataOptionalId as K, type MappedItem as L, type Metadata as M, type ComponentDataMap as N, type Overrides as O, type Permissions as P, type Content as Q, type RootDataWithProps as R, type Slot as S, type BaseField as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type TextField as X, type NumberField as Y, type TextareaField as Z, type SelectField as _, type ComponentData as a, type ArrayField as a0, type ObjectField as a1, type Adaptor as a2, type ExternalFieldWithAdaptor as a3, type ExternalField as a4, type CustomFieldRender as a5, type CustomField as a6, type SlotField as a7, type PuckContext as a8, type DefaultRootFieldProps as a9, type DefaultRootRenderProps as aa, type DefaultRootProps as ab, type DefaultComponentProps as ac, type WithId as ad, type WithPuckProps as ae, type AsFieldProps as af, type WithChildren as ag, type ExtractPropsFromConfig as ah, type ExtractRootPropsFromConfig as ai, 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 SlotComponent as y, type PuckComponent as z };
595
+ export { type NumberField as $, type AppState as A, type ArrayState as B, type Config as C, type DropZoneProps as D, type SlotComponent as E, type Fields as F, type PuckComponent as G, type History as H, type IframeConfig as I, type RootConfig as J, type BaseData as K, type RootDataWithoutProps as L, type Metadata as M, type RootData as N, type Overrides as O, type Permissions as P, type ComponentDataOptionalId as Q, type RootDataWithProps as R, type Slot as S, type MappedItem as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ComponentDataMap as X, type Content as Y, type BaseField as Z, type TextField as _, type ComponentData as a, type TextareaField as a0, type SelectField as a1, type RadioField as a2, type ArrayField as a3, type ObjectField as a4, type Adaptor as a5, type ExternalFieldWithAdaptor as a6, type ExternalField as a7, type CustomFieldRender as a8, type CustomField as a9, type SlotField as aa, type PuckContext as ab, type DefaultRootFieldProps as ac, type DefaultRootRenderProps as ad, type DefaultRootProps as ae, type DefaultComponentProps as af, type WithId as ag, type WithPuckProps as ah, type AsFieldProps as ai, type WithChildren as aj, type ExtractPropsFromConfig as ak, type ExtractRootPropsFromConfig as al, type ExtractField as am, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type FieldTransforms as g, type Field as h, type FieldProps as i, type Data as j, type OnAction as k, type InitialHistory as l, migrate as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, resolveAllData as r, type FieldTransformFnParams as s, transformProps as t, type FieldTransformFn as u, overrideKeys as v, walkTree as w, type OverrideKey as x, type FieldRenderFunctions as y, type ItemWithId as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.20.0-canary.8c56aa8b",
3
+ "version": "0.20.0-canary.b2d0f01a",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",