@measured/puck 0.20.0-canary.68dd73b8 → 0.20.0-canary.6aefde61

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.
@@ -17,7 +17,7 @@ type DropZoneProps = {
17
17
 
18
18
  type FieldOption = {
19
19
  label: string;
20
- value: string | number | boolean;
20
+ value: string | number | boolean | undefined | null | object;
21
21
  };
22
22
  type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
23
23
  type BaseField = {
@@ -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";
@@ -209,14 +212,18 @@ type WithChildren<Props> = Props & {
209
212
  };
210
213
  type ExtractPropsFromConfig<UserConfig> = UserConfig extends Config<infer P, any, any> ? P : never;
211
214
  type ExtractRootPropsFromConfig<UserConfig> = UserConfig extends Config<any, infer P, any> ? P : never;
212
- type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractPropsFromConfig<UserConfig> = ExtractPropsFromConfig<UserConfig>, UserRootProps extends ExtractRootPropsFromConfig<UserConfig> = ExtractRootPropsFromConfig<UserConfig>, UserData extends Data<UserProps, UserRootProps> | Data = Data<UserProps, UserRootProps>, UserAppState extends PrivateAppState<UserData> = PrivateAppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
215
+ type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractPropsFromConfig<UserConfig> = ExtractPropsFromConfig<UserConfig>, UserRootProps extends ExtractRootPropsFromConfig<UserConfig> = ExtractRootPropsFromConfig<UserConfig>, UserData extends Data<UserProps, UserRootProps> | Data = Data<UserProps, UserRootProps>, UserAppState extends PrivateAppState<UserData> = PrivateAppState<UserData>, UserPublicAppState extends AppState<UserData> = AppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
213
216
  UserConfig: UserConfig;
214
217
  UserProps: UserProps;
215
218
  UserRootProps: UserRootProps;
216
219
  UserData: UserData;
217
220
  UserAppState: UserAppState;
221
+ UserPublicAppState: UserPublicAppState;
218
222
  UserComponentData: UserComponentData;
219
223
  };
224
+ type ExtractField<T extends Field["type"]> = Extract<Field, {
225
+ type: T;
226
+ }>;
220
227
 
221
228
  type PuckContext = {
222
229
  renderDropZone: React.FC<DropZoneProps>;
@@ -277,6 +284,7 @@ type Metadata = {
277
284
  type ItemWithId = {
278
285
  _arrayId: string;
279
286
  _originalIndex: number;
287
+ _currentIndex: number;
280
288
  };
281
289
  type ArrayState = {
282
290
  items: ItemWithId[];
@@ -285,6 +293,8 @@ type ArrayState = {
285
293
  type UiState = {
286
294
  leftSideBarVisible: boolean;
287
295
  rightSideBarVisible: boolean;
296
+ leftSideBarWidth?: number | null;
297
+ rightSideBarWidth?: number | null;
288
298
  itemSelector: ItemSelector | null;
289
299
  arrayState: Record<string, ArrayState | undefined>;
290
300
  previewMode: "interactive" | "edit";
@@ -306,6 +316,9 @@ type UiState = {
306
316
  field: {
307
317
  focus?: string | null;
308
318
  };
319
+ plugin: {
320
+ current: string | null;
321
+ };
309
322
  };
310
323
  type AppState<UserData extends Data = Data> = {
311
324
  data: UserData;
@@ -340,13 +353,33 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
340
353
  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 ? {
341
354
  [K in keyof T]: WithDeepSlots<T[K], SlotType>;
342
355
  } : T;
343
-
344
356
  type RenderFunc<Props extends {
345
357
  [key: string]: any;
346
358
  } = {
347
359
  children: ReactNode;
348
360
  }> = (props: Props) => ReactElement;
349
- declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
361
+ type PluginInternal = Plugin & {
362
+ mobileOnly?: boolean;
363
+ };
364
+
365
+ type MapFnParams<ThisField = Field> = {
366
+ value: any;
367
+ parentId: string;
368
+ propName: string;
369
+ field: ThisField;
370
+ propPath: string;
371
+ };
372
+
373
+ type FieldTransformFnParams<T> = Omit<MapFnParams<T>, "parentId"> & {
374
+ isReadOnly: boolean;
375
+ componentId: string;
376
+ };
377
+ type FieldTransformFn<T = any> = (params: FieldTransformFnParams<T>) => any;
378
+ type FieldTransforms = Partial<{
379
+ [FieldType in Field["type"]]: FieldTransformFn<ExtractField<FieldType>>;
380
+ }>;
381
+
382
+ declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
350
383
  type OverrideKey = (typeof overrideKeys)[number];
351
384
  type OverridesGeneric<Shape extends {
352
385
  [key in OverrideKey]: any;
@@ -384,11 +417,23 @@ type Overrides = OverridesGeneric<{
384
417
  children: ReactNode;
385
418
  name: string;
386
419
  }>;
420
+ drawer: RenderFunc;
421
+ drawerItem: RenderFunc<{
422
+ children: ReactNode;
423
+ name: string;
424
+ }>;
387
425
  iframe: RenderFunc<{
388
426
  children: ReactNode;
389
427
  document?: Document;
390
428
  }>;
391
429
  outline: RenderFunc;
430
+ componentOverlay: RenderFunc<{
431
+ children: ReactNode;
432
+ hover: boolean;
433
+ isSelected: boolean;
434
+ componentId: string;
435
+ componentType: string;
436
+ }>;
392
437
  puck: RenderFunc;
393
438
  }>;
394
439
  type FieldRenderFunctions = Omit<{
@@ -430,7 +475,12 @@ type IframeConfig = {
430
475
  };
431
476
  type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
432
477
  type Plugin = {
433
- overrides: Partial<Overrides>;
478
+ name?: string;
479
+ label?: string;
480
+ icon?: ReactNode;
481
+ render?: () => ReactElement;
482
+ overrides?: Partial<Overrides>;
483
+ fieldTransforms?: FieldTransforms;
434
484
  };
435
485
  type History<D = any> = {
436
486
  state: D;
@@ -548,4 +598,4 @@ type WalkTreeOptions = {
548
598
  };
549
599
  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;
550
600
 
551
- 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 };
601
+ export { type TextField as $, type AppState as A, type ItemWithId as B, type Config as C, type DropZoneProps as D, type ArrayState as E, type Fields as F, type SlotComponent as G, type History as H, type IframeConfig as I, type PuckComponent as J, type RootConfig as K, type BaseData as L, type Metadata as M, type RootDataWithoutProps as N, type Overrides as O, type Permissions as P, type RootData as Q, type RootDataWithProps as R, type Slot as S, type ComponentDataOptionalId as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type MappedItem as X, type ComponentDataMap as Y, type Content as Z, type BaseField as _, type ComponentData as a, type NumberField as a0, type TextareaField as a1, type SelectField as a2, type RadioField as a3, type ArrayField as a4, type ObjectField as a5, type Adaptor as a6, type ExternalFieldWithAdaptor as a7, type ExternalField as a8, type CustomFieldRender as a9, type CustomField as aa, type SlotField as ab, type PuckContext as ac, type DefaultRootFieldProps as ad, type DefaultRootRenderProps as ae, type DefaultRootProps as af, type DefaultComponentProps as ag, type WithId as ah, type WithPuckProps as ai, type AsFieldProps as aj, type WithChildren as ak, type ExtractPropsFromConfig as al, type ExtractRootPropsFromConfig as am, type ExtractField as an, 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 PluginInternal as o, type Direction as p, type DragAxis as q, resolveAllData as r, type Viewport as s, transformProps as t, type FieldTransformFnParams as u, type FieldTransformFn as v, walkTree as w, overrideKeys as x, type OverrideKey as y, type FieldRenderFunctions as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.20.0-canary.68dd73b8",
3
+ "version": "0.20.0-canary.6aefde61",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",
@@ -27,6 +27,7 @@
27
27
  "require": "./dist/rsc.js"
28
28
  },
29
29
  "./puck.css": "./dist/index.css",
30
+ "./no-external.css": "./dist/no-external.css",
30
31
  "./dist/index.css": "./dist/index.css",
31
32
  "./package.json": "./package.json"
32
33
  },
@@ -40,7 +41,7 @@
40
41
  "license": "MIT",
41
42
  "scripts": {
42
43
  "lint": "eslint \"**/*.ts*\"",
43
- "build": "rm -rf dist && tsup index.ts rsc.tsx",
44
+ "build": "rm -rf dist && tsup bundle/index.ts bundle/rsc.tsx bundle/no-external.ts",
44
45
  "test": "jest",
45
46
  "prepare": "cp ../../README.md . && yarn build",
46
47
  "postpublish": "rm README.md"