@measured/puck 0.20.0-canary.d405985b → 0.20.0-canary.e25949a6

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.
@@ -13,17 +13,19 @@ import {
13
13
  Render,
14
14
  createUsePuck,
15
15
  overrideKeys,
16
+ registerOverlayPortal,
16
17
  renderContext,
18
+ setDeep,
17
19
  useGetPuck,
18
20
  usePuck
19
- } from "./chunk-DBSNJT3R.mjs";
21
+ } from "./chunk-FYXJ5FPS.mjs";
20
22
  import {
21
23
  init_react_import,
22
24
  migrate,
23
25
  resolveAllData,
24
26
  transformProps,
25
27
  walkTree
26
- } from "./chunk-32MJ3X3H.mjs";
28
+ } from "./chunk-HUKJ36SA.mjs";
27
29
 
28
30
  // bundle/no-external.ts
29
31
  init_react_import();
@@ -43,8 +45,10 @@ export {
43
45
  createUsePuck,
44
46
  migrate,
45
47
  overrideKeys,
48
+ registerOverlayPortal,
46
49
  renderContext,
47
50
  resolveAllData,
51
+ setDeep,
48
52
  transformProps,
49
53
  useGetPuck,
50
54
  usePuck,
package/dist/rsc.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-Bp8tnkJS.mjs';
3
- export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Bp8tnkJS.mjs';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-B57SgEEc.mjs';
3
+ export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-B57SgEEc.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 { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-Bp8tnkJS.js';
3
- export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Bp8tnkJS.js';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-B57SgEEc.js';
3
+ export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-B57SgEEc.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
@@ -22,6 +22,18 @@ var __spreadValues = (a, b) => {
22
22
  return a;
23
23
  };
24
24
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
25
37
  var __export = (target, all) => {
26
38
  for (var name in all)
27
39
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -95,7 +107,7 @@ var setupZone = (data, zoneKey) => {
95
107
  return newData;
96
108
  };
97
109
 
98
- // lib/use-slots.tsx
110
+ // lib/field-transforms/use-field-transforms.tsx
99
111
  var import_react2 = require("react");
100
112
 
101
113
  // lib/data/default-slots.ts
@@ -104,14 +116,14 @@ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
104
116
  value
105
117
  );
106
118
 
107
- // lib/data/map-slots.ts
119
+ // lib/data/map-fields.ts
108
120
  var isPromise = (v) => !!v && typeof v.then === "function";
109
121
  var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
110
122
  var containsPromise = (arr) => arr.some(isPromise);
111
123
  var walkField = ({
112
124
  value,
113
125
  fields,
114
- map,
126
+ mappers,
115
127
  propKey = "",
116
128
  propPath = "",
117
129
  id = "",
@@ -119,7 +131,9 @@ var walkField = ({
119
131
  recurseSlots = false
120
132
  }) => {
121
133
  var _a, _b, _c;
122
- if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
134
+ const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
135
+ const map = mappers[fieldType];
136
+ if (map && fieldType === "slot") {
123
137
  const content = value || [];
124
138
  const mappedContent = recurseSlots ? content.map((el) => {
125
139
  var _a2;
@@ -131,7 +145,7 @@ var walkField = ({
131
145
  return walkField({
132
146
  value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
133
147
  fields: fields2,
134
- map,
148
+ mappers,
135
149
  id: el.props.id,
136
150
  config,
137
151
  recurseSlots
@@ -140,7 +154,21 @@ var walkField = ({
140
154
  if (containsPromise(mappedContent)) {
141
155
  return Promise.all(mappedContent);
142
156
  }
143
- return map(mappedContent, id, propPath, fields[propKey], propPath);
157
+ return map({
158
+ value: mappedContent,
159
+ parentId: id,
160
+ propName: propKey,
161
+ field: fields[propKey],
162
+ propPath
163
+ });
164
+ } else if (map && fields[propKey]) {
165
+ return map({
166
+ value,
167
+ parentId: id,
168
+ propName: propKey,
169
+ field: fields[propKey],
170
+ propPath
171
+ });
144
172
  }
145
173
  if (value && typeof value === "object") {
146
174
  if (Array.isArray(value)) {
@@ -150,7 +178,7 @@ var walkField = ({
150
178
  (el, idx) => walkField({
151
179
  value: el,
152
180
  fields: arrayFields,
153
- map,
181
+ mappers,
154
182
  propKey,
155
183
  propPath: `${propPath}[${idx}]`,
156
184
  id,
@@ -169,7 +197,7 @@ var walkField = ({
169
197
  return walkObject({
170
198
  value,
171
199
  fields: objectFields,
172
- map,
200
+ mappers,
173
201
  id,
174
202
  getPropPath: (k) => `${propPath}.${k}`,
175
203
  config,
@@ -182,7 +210,7 @@ var walkField = ({
182
210
  var walkObject = ({
183
211
  value,
184
212
  fields,
185
- map,
213
+ mappers,
186
214
  id,
187
215
  getPropPath,
188
216
  config,
@@ -192,7 +220,7 @@ var walkObject = ({
192
220
  const opts = {
193
221
  value: v,
194
222
  fields,
195
- map,
223
+ mappers,
196
224
  propKey: k,
197
225
  propPath: getPropPath(k),
198
226
  id,
@@ -214,14 +242,14 @@ var walkObject = ({
214
242
  }
215
243
  return flatten(newProps);
216
244
  };
217
- function mapSlots(item, map, config, recurseSlots = false) {
245
+ function mapFields(item, mappers, config, recurseSlots = false) {
218
246
  var _a, _b, _c, _d, _e;
219
247
  const itemType = "type" in item ? item.type : "root";
220
248
  const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
221
249
  const newProps = walkObject({
222
250
  value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
223
251
  fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
224
- map,
252
+ mappers,
225
253
  id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
226
254
  getPropPath: (k) => k,
227
255
  config,
@@ -237,35 +265,66 @@ function mapSlots(item, map, config, recurseSlots = false) {
237
265
  });
238
266
  }
239
267
 
240
- // lib/use-slots.tsx
241
- function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
242
- const slotProps = (0, import_react2.useMemo)(() => {
243
- const mapped = mapSlots(
244
- item,
245
- (content, _parentId, propName, field, propPath) => {
246
- const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
247
- const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
248
- const render = isReadOnly ? renderSlotRender : renderSlotEdit;
249
- const Slot = (dzProps) => render(__spreadProps(__spreadValues({
250
- allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
251
- disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
252
- }, dzProps), {
253
- zone: propName,
254
- content
255
- }));
256
- return Slot;
257
- },
258
- config
259
- ).props;
268
+ // lib/field-transforms/use-field-transforms.tsx
269
+ function useFieldTransforms(config, item, transforms, readOnly, forceReadOnly) {
270
+ const mappers = (0, import_react2.useMemo)(() => {
271
+ return Object.keys(transforms).reduce((acc, _fieldType) => {
272
+ const fieldType = _fieldType;
273
+ return __spreadProps(__spreadValues({}, acc), {
274
+ [fieldType]: (_a) => {
275
+ var _b = _a, {
276
+ parentId
277
+ } = _b, params = __objRest(_b, [
278
+ "parentId"
279
+ ]);
280
+ const wildcardPath = params.propPath.replace(/\[\d+\]/g, "[*]");
281
+ const isReadOnly = (readOnly == null ? void 0 : readOnly[params.propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly || false;
282
+ const fn = transforms[fieldType];
283
+ return fn == null ? void 0 : fn(__spreadProps(__spreadValues({}, params), {
284
+ isReadOnly,
285
+ componentId: parentId
286
+ }));
287
+ }
288
+ });
289
+ }, {});
290
+ }, [transforms, readOnly, forceReadOnly]);
291
+ const transformedProps = (0, import_react2.useMemo)(() => {
292
+ const mapped = mapFields(item, mappers, config).props;
260
293
  return mapped;
261
- }, [config, item, readOnly, forceReadOnly]);
294
+ }, [config, item, mappers]);
262
295
  const mergedProps = (0, import_react2.useMemo)(
263
- () => __spreadValues(__spreadValues({}, item.props), slotProps),
264
- [item.props, slotProps]
296
+ () => __spreadValues(__spreadValues({}, item.props), transformedProps),
297
+ [item.props, transformedProps]
265
298
  );
266
299
  return mergedProps;
267
300
  }
268
301
 
302
+ // lib/field-transforms/default-transforms/slot-transform.tsx
303
+ var getSlotTransform = (renderSlotEdit, renderSlotRender = renderSlotEdit) => ({
304
+ slot: ({ value: content, propName, field, isReadOnly }) => {
305
+ const render = isReadOnly ? renderSlotRender : renderSlotEdit;
306
+ const Slot = (dzProps) => render(__spreadProps(__spreadValues({
307
+ allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
308
+ disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
309
+ }, dzProps), {
310
+ zone: propName,
311
+ content
312
+ }));
313
+ return Slot;
314
+ }
315
+ });
316
+
317
+ // lib/use-slots.tsx
318
+ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
319
+ return useFieldTransforms(
320
+ config,
321
+ item,
322
+ getSlotTransform(renderSlotEdit, renderSlotRender),
323
+ readOnly,
324
+ forceReadOnly
325
+ );
326
+ }
327
+
269
328
  // components/SlotRender/server.tsx
270
329
  var import_react3 = require("react");
271
330
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -441,24 +500,27 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
441
500
  resolvedItem.readOnly = readOnly;
442
501
  }
443
502
  }
444
- let itemWithResolvedChildren = yield mapSlots(
503
+ let itemWithResolvedChildren = yield mapFields(
445
504
  resolvedItem,
446
- (content) => __async(void 0, null, function* () {
447
- return yield Promise.all(
448
- content.map(
449
- (childItem) => __async(void 0, null, function* () {
450
- return (yield resolveComponentData(
451
- childItem,
452
- config,
453
- metadata,
454
- onResolveStart,
455
- onResolveEnd,
456
- trigger
457
- )).node;
458
- })
459
- )
460
- );
461
- }),
505
+ {
506
+ slot: (_02) => __async(void 0, [_02], function* ({ value }) {
507
+ const content = value;
508
+ return yield Promise.all(
509
+ content.map(
510
+ (childItem) => __async(void 0, null, function* () {
511
+ return (yield resolveComponentData(
512
+ childItem,
513
+ config,
514
+ metadata,
515
+ onResolveStart,
516
+ onResolveEnd,
517
+ trigger
518
+ )).node;
519
+ })
520
+ )
521
+ );
522
+ })
523
+ },
462
524
  config
463
525
  );
464
526
  if (shouldRunResolver && onResolveEnd) {
@@ -506,9 +568,9 @@ function resolveAllData(_0, _1) {
506
568
  },
507
569
  "force"
508
570
  )).node;
509
- const resolvedDeep = yield mapSlots(
571
+ const resolvedDeep = yield mapFields(
510
572
  resolved,
511
- processContent,
573
+ { slot: ({ value }) => processContent(value) },
512
574
  config
513
575
  );
514
576
  onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
@@ -542,11 +604,14 @@ function resolveAllData(_0, _1) {
542
604
  function walkTree(data, config, callbackFn) {
543
605
  var _a, _b;
544
606
  const walkItem = (item) => {
545
- return mapSlots(
607
+ return mapFields(
546
608
  item,
547
- (content, parentId, propName) => {
548
- var _a2;
549
- return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
609
+ {
610
+ slot: ({ value, parentId, propName }) => {
611
+ var _a2;
612
+ const content = value;
613
+ return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
614
+ }
550
615
  },
551
616
  config,
552
617
  true
@@ -663,7 +728,7 @@ var import_flat = __toESM(require("flat"));
663
728
 
664
729
  // lib/data/strip-slots.ts
665
730
  var stripSlots = (data, config) => {
666
- return mapSlots(data, () => null, config);
731
+ return mapFields(data, { slot: () => null }, config);
667
732
  };
668
733
 
669
734
  // lib/data/flatten-node.ts
@@ -716,18 +781,21 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
716
781
  const mappedItem = mapNodeOrSkip(item, path, index);
717
782
  if (!mappedItem) return item;
718
783
  const id = mappedItem.props.id;
719
- const newProps = __spreadProps(__spreadValues({}, mapSlots(
784
+ const newProps = __spreadProps(__spreadValues({}, mapFields(
720
785
  mappedItem,
721
- (content, parentId2, slotId) => {
722
- const zoneCompound = `${parentId2}:${slotId}`;
723
- const [_2, newContent2] = processContent(
724
- path,
725
- zoneCompound,
726
- content,
727
- "slot",
728
- parentId2
729
- );
730
- return newContent2;
786
+ {
787
+ slot: ({ value, parentId: parentId2, propPath }) => {
788
+ const content = value;
789
+ const zoneCompound = `${parentId2}:${propPath}`;
790
+ const [_2, newContent2] = processContent(
791
+ path,
792
+ zoneCompound,
793
+ content,
794
+ "slot",
795
+ parentId2
796
+ );
797
+ return newContent2;
798
+ }
731
799
  },
732
800
  config
733
801
  ).props), {
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-HUKJ36SA.mjs";
9
9
 
10
10
  // bundle/rsc.tsx
11
11
  init_react_import();
@@ -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";
@@ -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>;
@@ -286,6 +292,8 @@ type ArrayState = {
286
292
  type UiState = {
287
293
  leftSideBarVisible: boolean;
288
294
  rightSideBarVisible: boolean;
295
+ leftSideBarWidth?: number | null;
296
+ rightSideBarWidth?: number | null;
289
297
  itemSelector: ItemSelector | null;
290
298
  arrayState: Record<string, ArrayState | undefined>;
291
299
  previewMode: "interactive" | "edit";
@@ -342,12 +350,29 @@ type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (inf
342
350
  [K in keyof T]: WithDeepSlots<T[K], SlotType>;
343
351
  } : T;
344
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
+
345
370
  type RenderFunc<Props extends {
346
371
  [key: string]: any;
347
372
  } = {
348
373
  children: ReactNode;
349
374
  }> = (props: Props) => ReactElement;
350
- 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"];
351
376
  type OverrideKey = (typeof overrideKeys)[number];
352
377
  type OverridesGeneric<Shape extends {
353
378
  [key in OverrideKey]: any;
@@ -385,11 +410,23 @@ type Overrides = OverridesGeneric<{
385
410
  children: ReactNode;
386
411
  name: string;
387
412
  }>;
413
+ drawer: RenderFunc;
414
+ drawerItem: RenderFunc<{
415
+ children: ReactNode;
416
+ name: string;
417
+ }>;
388
418
  iframe: RenderFunc<{
389
419
  children: ReactNode;
390
420
  document?: Document;
391
421
  }>;
392
422
  outline: RenderFunc;
423
+ componentOverlay: RenderFunc<{
424
+ children: ReactNode;
425
+ hover: boolean;
426
+ isSelected: boolean;
427
+ componentId: string;
428
+ componentType: string;
429
+ }>;
393
430
  puck: RenderFunc;
394
431
  }>;
395
432
  type FieldRenderFunctions = Omit<{
@@ -431,7 +468,8 @@ type IframeConfig = {
431
468
  };
432
469
  type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
433
470
  type Plugin = {
434
- overrides: Partial<Overrides>;
471
+ overrides?: Partial<Overrides>;
472
+ fieldTransforms?: FieldTransforms;
435
473
  };
436
474
  type History<D = any> = {
437
475
  state: D;
@@ -549,4 +587,4 @@ type WalkTreeOptions = {
549
587
  };
550
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;
551
589
 
552
- 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 };
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 };
@@ -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";
@@ -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>;
@@ -286,6 +292,8 @@ type ArrayState = {
286
292
  type UiState = {
287
293
  leftSideBarVisible: boolean;
288
294
  rightSideBarVisible: boolean;
295
+ leftSideBarWidth?: number | null;
296
+ rightSideBarWidth?: number | null;
289
297
  itemSelector: ItemSelector | null;
290
298
  arrayState: Record<string, ArrayState | undefined>;
291
299
  previewMode: "interactive" | "edit";
@@ -342,12 +350,29 @@ type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (inf
342
350
  [K in keyof T]: WithDeepSlots<T[K], SlotType>;
343
351
  } : T;
344
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
+
345
370
  type RenderFunc<Props extends {
346
371
  [key: string]: any;
347
372
  } = {
348
373
  children: ReactNode;
349
374
  }> = (props: Props) => ReactElement;
350
- 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"];
351
376
  type OverrideKey = (typeof overrideKeys)[number];
352
377
  type OverridesGeneric<Shape extends {
353
378
  [key in OverrideKey]: any;
@@ -385,11 +410,23 @@ type Overrides = OverridesGeneric<{
385
410
  children: ReactNode;
386
411
  name: string;
387
412
  }>;
413
+ drawer: RenderFunc;
414
+ drawerItem: RenderFunc<{
415
+ children: ReactNode;
416
+ name: string;
417
+ }>;
388
418
  iframe: RenderFunc<{
389
419
  children: ReactNode;
390
420
  document?: Document;
391
421
  }>;
392
422
  outline: RenderFunc;
423
+ componentOverlay: RenderFunc<{
424
+ children: ReactNode;
425
+ hover: boolean;
426
+ isSelected: boolean;
427
+ componentId: string;
428
+ componentType: string;
429
+ }>;
393
430
  puck: RenderFunc;
394
431
  }>;
395
432
  type FieldRenderFunctions = Omit<{
@@ -431,7 +468,8 @@ type IframeConfig = {
431
468
  };
432
469
  type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
433
470
  type Plugin = {
434
- overrides: Partial<Overrides>;
471
+ overrides?: Partial<Overrides>;
472
+ fieldTransforms?: FieldTransforms;
435
473
  };
436
474
  type History<D = any> = {
437
475
  state: D;
@@ -549,4 +587,4 @@ type WalkTreeOptions = {
549
587
  };
550
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;
551
589
 
552
- 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 };
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.d405985b",
3
+ "version": "0.20.0-canary.e25949a6",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",