@measured/puck 0.20.0-canary.2b50fb19 → 0.20.0-canary.2ce4c22c

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>;
@@ -285,6 +292,8 @@ type ArrayState = {
285
292
  type UiState = {
286
293
  leftSideBarVisible: boolean;
287
294
  rightSideBarVisible: boolean;
295
+ leftSideBarWidth?: number | null;
296
+ rightSideBarWidth?: number | null;
288
297
  itemSelector: ItemSelector | null;
289
298
  arrayState: Record<string, ArrayState | undefined>;
290
299
  previewMode: "interactive" | "edit";
@@ -341,12 +350,29 @@ type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (inf
341
350
  [K in keyof T]: WithDeepSlots<T[K], SlotType>;
342
351
  } : T;
343
352
 
353
+ type MapFnParams<ThisField = Field> = {
354
+ value: any;
355
+ parentId: string;
356
+ propName: string;
357
+ field: ThisField;
358
+ propPath: string;
359
+ };
360
+
361
+ type FieldTransformFnParams<T> = Omit<MapFnParams<T>, "parentId"> & {
362
+ isReadOnly: boolean;
363
+ componentId: string;
364
+ };
365
+ type FieldTransformFn<T = any> = (params: FieldTransformFnParams<T>) => any;
366
+ type FieldTransforms = Partial<{
367
+ [FieldType in Field["type"]]: FieldTransformFn<ExtractField<FieldType>>;
368
+ }>;
369
+
344
370
  type RenderFunc<Props extends {
345
371
  [key: string]: any;
346
372
  } = {
347
373
  children: ReactNode;
348
374
  }> = (props: Props) => ReactElement;
349
- declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
375
+ declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
350
376
  type OverrideKey = (typeof overrideKeys)[number];
351
377
  type OverridesGeneric<Shape extends {
352
378
  [key in OverrideKey]: any;
@@ -384,11 +410,23 @@ type Overrides = OverridesGeneric<{
384
410
  children: ReactNode;
385
411
  name: string;
386
412
  }>;
413
+ drawer: RenderFunc;
414
+ drawerItem: RenderFunc<{
415
+ children: ReactNode;
416
+ name: string;
417
+ }>;
387
418
  iframe: RenderFunc<{
388
419
  children: ReactNode;
389
420
  document?: Document;
390
421
  }>;
391
422
  outline: RenderFunc;
423
+ componentOverlay: RenderFunc<{
424
+ children: ReactNode;
425
+ hover: boolean;
426
+ isSelected: boolean;
427
+ componentId: string;
428
+ componentType: string;
429
+ }>;
392
430
  puck: RenderFunc;
393
431
  }>;
394
432
  type FieldRenderFunctions = Omit<{
@@ -430,7 +468,8 @@ type IframeConfig = {
430
468
  };
431
469
  type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
432
470
  type Plugin = {
433
- overrides: Partial<Overrides>;
471
+ overrides?: Partial<Overrides>;
472
+ fieldTransforms?: FieldTransforms;
434
473
  };
435
474
  type History<D = any> = {
436
475
  state: D;
@@ -548,4 +587,4 @@ type WalkTreeOptions = {
548
587
  };
549
588
  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
589
 
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 };
590
+ 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.2b50fb19",
3
+ "version": "0.20.0-canary.2ce4c22c",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",
@@ -1,95 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __objRest = (source, exclude) => {
25
- var target = {};
26
- for (var prop in source)
27
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
- target[prop] = source[prop];
29
- if (source != null && __getOwnPropSymbols)
30
- for (var prop of __getOwnPropSymbols(source)) {
31
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
- target[prop] = source[prop];
33
- }
34
- return target;
35
- };
36
- var __esm = (fn, res) => function __init() {
37
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
38
- };
39
- var __commonJS = (cb, mod) => function __require() {
40
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
41
- };
42
- var __copyProps = (to, from, except, desc) => {
43
- if (from && typeof from === "object" || typeof from === "function") {
44
- for (let key of __getOwnPropNames(from))
45
- if (!__hasOwnProp.call(to, key) && key !== except)
46
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
47
- }
48
- return to;
49
- };
50
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
51
- // If the importer is in node compatibility mode or this is not an ESM
52
- // file that has been converted to a CommonJS file using a Babel-
53
- // compatible transform (i.e. "__esModule" has not been set), then set
54
- // "default" to the CommonJS "module.exports" for node compatibility.
55
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
56
- mod
57
- ));
58
- var __async = (__this, __arguments, generator) => {
59
- return new Promise((resolve, reject) => {
60
- var fulfilled = (value) => {
61
- try {
62
- step(generator.next(value));
63
- } catch (e) {
64
- reject(e);
65
- }
66
- };
67
- var rejected = (value) => {
68
- try {
69
- step(generator.throw(value));
70
- } catch (e) {
71
- reject(e);
72
- }
73
- };
74
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
75
- step((generator = generator.apply(__this, __arguments)).next());
76
- });
77
- };
78
-
79
- // ../tsup-config/react-import.js
80
- import React from "react";
81
- var init_react_import = __esm({
82
- "../tsup-config/react-import.js"() {
83
- "use strict";
84
- }
85
- });
86
-
87
- export {
88
- __spreadValues,
89
- __spreadProps,
90
- __objRest,
91
- __commonJS,
92
- __toESM,
93
- __async,
94
- init_react_import
95
- };