@measured/puck 0.14.0-canary.53b7937 → 0.14.0-canary.712fb8e

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.
@@ -65,7 +65,7 @@ type ObjectField<Props extends {
65
65
  }> = BaseField & {
66
66
  type: "object";
67
67
  objectFields: {
68
- [SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
68
+ [SubPropName in keyof Props]: Field<Props[SubPropName]>;
69
69
  };
70
70
  };
71
71
  type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
@@ -146,6 +146,7 @@ type PuckContext = {
146
146
  };
147
147
  type ComponentConfig<ComponentProps extends DefaultComponentProps = DefaultComponentProps, DefaultProps = ComponentProps, DataShape = ComponentData<ComponentProps>> = {
148
148
  render: PuckComponent<ComponentProps>;
149
+ label?: string;
149
150
  defaultProps?: DefaultProps;
150
151
  fields?: Fields<ComponentProps>;
151
152
  resolveData?: (data: DataShape, params: {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as Config, D as Data, I as ItemSelector, U as UiState, A as AppState, F as Field, a as DefaultComponentProps, b as DefaultRootProps, M as MappedItem, R as RootDataWithProps, c as RootData } from './Config-0bf39037.js';
2
- export { g as Adaptor, f as ArrayField, r as ArrayState, n as BaseData, B as BaseField, m as ComponentConfig, o as ComponentData, k as Content, i as CustomField, s as DropZone, h as ExternalField, E as ExternalFieldWithAdaptor, j as Fields, q as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, l as PuckContext, e as RadioField, p as RootDataWithoutProps, S as SelectField, T as TextField, d as TextareaField } from './Config-0bf39037.js';
1
+ import { C as Config, D as Data, I as ItemSelector, U as UiState, A as AppState, F as Field, a as DefaultComponentProps, b as DefaultRootProps, M as MappedItem, R as RootDataWithProps, c as RootData } from './Config-487c2755.js';
2
+ export { g as Adaptor, f as ArrayField, r as ArrayState, n as BaseData, B as BaseField, m as ComponentConfig, o as ComponentData, k as Content, i as CustomField, s as DropZone, h as ExternalField, E as ExternalFieldWithAdaptor, j as Fields, q as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, l as PuckContext, e as RadioField, p as RootDataWithoutProps, S as SelectField, T as TextField, d as TextareaField } from './Config-487c2755.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import { ReactNode, CSSProperties, ReactElement, SyntheticEvent } from 'react';
@@ -121,13 +121,14 @@ declare const Drawer: {
121
121
  droppableId?: string | undefined;
122
122
  direction?: "horizontal" | "vertical" | undefined;
123
123
  }): react_jsx_runtime.JSX.Element;
124
- Item: ({ name, children, id, index, }: {
124
+ Item: ({ name, children, id, label, index, }: {
125
125
  name: string;
126
126
  children?: ((props: {
127
127
  children: ReactNode;
128
128
  name: string;
129
129
  }) => ReactElement) | undefined;
130
130
  id?: string | undefined;
131
+ label?: string | undefined;
131
132
  index: number;
132
133
  }) => react_jsx_runtime.JSX.Element;
133
134
  };
package/dist/index.js CHANGED
@@ -29382,6 +29382,7 @@ var DrawerItem = ({
29382
29382
  name,
29383
29383
  children,
29384
29384
  id,
29385
+ label,
29385
29386
  index
29386
29387
  }) => {
29387
29388
  const ctx = (0, import_react3.useContext)(drawerContext);
@@ -29391,7 +29392,7 @@ var DrawerItem = ({
29391
29392
  [children]
29392
29393
  );
29393
29394
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DrawerDraggable, { id: resolvedId, index, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: getClassNameItem("draggable"), children: [
29394
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("name"), children: name }),
29395
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("name"), children: label != null ? label : name }),
29395
29396
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DragIcon, {}) })
29396
29397
  ] }) }) }) });
29397
29398
  };
@@ -30074,7 +30075,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
30074
30075
  },
30075
30076
  children: [
30076
30077
  content.map((item, i) => {
30077
- var _a2, _b;
30078
+ var _a2, _b, _c;
30078
30079
  const componentId = item.props.id;
30079
30080
  const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a2 = config.components[item.type]) == null ? void 0 : _a2.defaultProps), item.props), {
30080
30081
  puck: { renderDropZone: DropZone },
@@ -30104,14 +30105,14 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
30104
30105
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
30105
30106
  DraggableComponent,
30106
30107
  {
30107
- label: item.type.toString(),
30108
+ label: (_b = config.components[item.type]["label"]) != null ? _b : item.type.toString(),
30108
30109
  id: `draggable-${componentId}`,
30109
30110
  index: i,
30110
30111
  isSelected,
30111
30112
  isLocked: userIsDragging,
30112
30113
  forceHover: hoveringComponent === componentId && !userIsDragging,
30113
30114
  indicativeHover: userIsDragging && containsZone && hoveringArea === componentId,
30114
- isLoading: (_b = appContext2.componentState[componentId]) == null ? void 0 : _b.loading,
30115
+ isLoading: (_c = appContext2.componentState[componentId]) == null ? void 0 : _c.loading,
30115
30116
  onMount: () => {
30116
30117
  ctx.registerPath({
30117
30118
  index: i,
@@ -32260,10 +32261,11 @@ var import_jsx_runtime23 = require("react/jsx-runtime");
32260
32261
  var getClassName20 = get_class_name_factory_default("ComponentList", styles_module_default15);
32261
32262
  var ComponentListItem = ({
32262
32263
  name,
32264
+ label,
32263
32265
  index
32264
32266
  }) => {
32265
32267
  const { overrides } = useAppContext();
32266
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Drawer.Item, { name, index, children: overrides.componentItem });
32268
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Drawer.Item, { label, name, index, children: overrides.componentItem });
32267
32269
  };
32268
32270
  var ComponentList = ({
32269
32271
  children,
@@ -32292,9 +32294,11 @@ var ComponentList = ({
32292
32294
  }
32293
32295
  ),
32294
32296
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName20("content"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Drawer, { droppableId: `component-list${title ? `:${title}` : ""}`, children: children || Object.keys(config.components).map((componentKey, i) => {
32297
+ var _a;
32295
32298
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
32296
32299
  ComponentListItem,
32297
32300
  {
32301
+ label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
32298
32302
  name: componentKey,
32299
32303
  index: i
32300
32304
  },
@@ -32325,10 +32329,12 @@ var useComponentList = (config, ui) => {
32325
32329
  id: categoryKey,
32326
32330
  title: category.title || categoryKey,
32327
32331
  children: category.components.map((componentName, i) => {
32332
+ var _a2;
32328
32333
  matchedComponents.push(componentName);
32329
32334
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
32330
32335
  ComponentList.Item,
32331
32336
  {
32337
+ label: (_a2 = config.components[componentName]["label"]) != null ? _a2 : componentName,
32332
32338
  name: componentName,
32333
32339
  index: i
32334
32340
  },
@@ -32351,10 +32357,12 @@ var useComponentList = (config, ui) => {
32351
32357
  id: "other",
32352
32358
  title: ((_c = ui.componentList.other) == null ? void 0 : _c.title) || "Other",
32353
32359
  children: remainingComponents.map((componentName, i) => {
32360
+ var _a2;
32354
32361
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
32355
32362
  ComponentList.Item,
32356
32363
  {
32357
32364
  name: componentName,
32365
+ label: (_a2 = config.components[componentName]["label"]) != null ? _a2 : componentName,
32358
32366
  index: i
32359
32367
  },
32360
32368
  componentName
@@ -32367,7 +32375,7 @@ var useComponentList = (config, ui) => {
32367
32375
  }
32368
32376
  setComponentList(_componentList);
32369
32377
  }
32370
- }, [config.categories, ui.componentList]);
32378
+ }, [config.categories, config.components, ui.componentList]);
32371
32379
  return componentList;
32372
32380
  };
32373
32381
 
@@ -32471,6 +32479,7 @@ var getClassName21 = get_class_name_factory_default("LayerTree", styles_module_d
32471
32479
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default16);
32472
32480
  var LayerTree = ({
32473
32481
  data,
32482
+ config,
32474
32483
  zoneContent,
32475
32484
  itemSelector,
32476
32485
  setItemSelector,
@@ -32488,6 +32497,7 @@ var LayerTree = ({
32488
32497
  /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("ul", { className: getClassName21(), children: [
32489
32498
  zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("helper"), children: "No items" }),
32490
32499
  zoneContent.map((item, i) => {
32500
+ var _a;
32491
32501
  const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
32492
32502
  const zonesForItem = findZonesForArea(data, item.props.id);
32493
32503
  const containsZone = Object.keys(zonesForItem).length > 0;
@@ -32552,7 +32562,7 @@ var LayerTree = ({
32552
32562
  ),
32553
32563
  /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassNameLayer("title"), children: [
32554
32564
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(LayoutGrid, { size: "16" }) }),
32555
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameLayer("name"), children: item.type })
32565
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameLayer("name"), children: (_a = config.components[item.type]["label"]) != null ? _a : item.type })
32556
32566
  ] })
32557
32567
  ]
32558
32568
  }
@@ -32560,6 +32570,7 @@ var LayerTree = ({
32560
32570
  containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
32561
32571
  LayerTree,
32562
32572
  {
32573
+ config,
32563
32574
  data,
32564
32575
  zoneContent: zones[zoneKey],
32565
32576
  setItemSelector,
@@ -32581,7 +32592,7 @@ var LayerTree = ({
32581
32592
  var import_react24 = require("react");
32582
32593
  var import_jsx_runtime28 = require("react/jsx-runtime");
32583
32594
  var Outline = () => {
32584
- const { dispatch, state, overrides } = useAppContext();
32595
+ const { dispatch, state, overrides, config } = useAppContext();
32585
32596
  const { data, ui } = state;
32586
32597
  const { itemSelector } = ui;
32587
32598
  const setItemSelector = (0, import_react24.useCallback)(
@@ -32598,6 +32609,7 @@ var Outline = () => {
32598
32609
  (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
32599
32610
  LayerTree,
32600
32611
  {
32612
+ config,
32601
32613
  data,
32602
32614
  label: areaContainsZones(data, "root") ? rootDroppableId : "",
32603
32615
  zoneContent: data.content,
@@ -32610,6 +32622,7 @@ var Outline = () => {
32610
32622
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
32611
32623
  LayerTree,
32612
32624
  {
32625
+ config,
32613
32626
  data,
32614
32627
  label: zoneKey,
32615
32628
  zone: zoneKey,
@@ -32750,6 +32763,7 @@ function Puck({
32750
32763
  headerTitle,
32751
32764
  headerPath
32752
32765
  }) {
32766
+ var _a;
32753
32767
  const historyStore = useHistoryStore();
32754
32768
  const [reducer] = (0, import_react26.useState)(
32755
32769
  () => createReducer({ config, record: historyStore.record })
@@ -32859,8 +32873,8 @@ function Puck({
32859
32873
  console.warn(
32860
32874
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
32861
32875
  );
32862
- const RenderHeader = (_a) => {
32863
- var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
32876
+ const RenderHeader = (_a2) => {
32877
+ var _b = _a2, { actions } = _b, props = __objRest(_b, ["actions"]);
32864
32878
  const Comp = renderHeader;
32865
32879
  return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
32866
32880
  };
@@ -33098,7 +33112,7 @@ function Puck({
33098
33112
  noPadding: true,
33099
33113
  noBorderTop: true,
33100
33114
  showBreadcrumbs: true,
33101
- title: selectedItem ? selectedItem.type : "Page",
33115
+ title: selectedItem ? (_a = config.components[selectedItem.type]["label"]) != null ? _a : selectedItem.type : "Page",
33102
33116
  children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Fields, {})
33103
33117
  }
33104
33118
  ) })
package/dist/rsc.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Config, D as Data } from './Config-0bf39037.js';
2
+ import { C as Config, D as Data } from './Config-487c2755.js';
3
3
  import 'react';
4
4
 
5
5
  declare function Render<UserConfig extends Config<any, any, any> = Config<any, any, any>>({ config, data }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.14.0-canary.53b7937",
3
+ "version": "0.14.0-canary.712fb8e",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",