@measured/puck 0.14.0-canary.b365418 → 0.14.0-canary.ca6bd5f

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.
@@ -55,6 +55,8 @@ type ArrayField<Props extends {
55
55
  };
56
56
  defaultItemProps?: Props[0];
57
57
  getItemSummary?: (item: Props[0], index?: number) => string;
58
+ max?: number;
59
+ min?: number;
58
60
  };
59
61
  type ObjectField<Props extends {
60
62
  [key: string]: any;
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-ab049d49.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-ab049d49.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-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';
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';
@@ -125,6 +125,7 @@ declare const Drawer: {
125
125
  name: string;
126
126
  children?: ((props: {
127
127
  children: ReactNode;
128
+ name: string;
128
129
  }) => ReactElement) | undefined;
129
130
  id?: string | undefined;
130
131
  index: number;
@@ -167,7 +168,7 @@ type RenderFunc<Props extends {
167
168
  [key: string]: any;
168
169
  } = {
169
170
  children: ReactNode;
170
- }> = React.FunctionComponent<Props>;
171
+ }> = (props: Props) => ReactElement;
171
172
  declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
172
173
  type OverrideKey = (typeof overrideKeys)[number];
173
174
  type OverridesGeneric<Shape extends {
@@ -197,7 +198,10 @@ type Overrides = OverridesGeneric<{
197
198
  className?: string;
198
199
  }>;
199
200
  components: RenderFunc;
200
- componentItem: RenderFunc;
201
+ componentItem: RenderFunc<{
202
+ children: ReactNode;
203
+ name: string;
204
+ }>;
201
205
  outline: RenderFunc;
202
206
  puck: RenderFunc;
203
207
  }>;
@@ -271,10 +275,34 @@ declare const resolveAllData: (data: Data, config: Config<any, any, any>, onReso
271
275
  zones: Record<string, MappedItem[]>;
272
276
  }>;
273
277
 
278
+ type History<D = any> = {
279
+ id: string;
280
+ data: D;
281
+ };
282
+ type HistoryStore<D = any> = {
283
+ index: number;
284
+ currentHistory: History;
285
+ hasPast: boolean;
286
+ hasFuture: boolean;
287
+ record: (data: D) => void;
288
+ back: VoidFunction;
289
+ forward: VoidFunction;
290
+ nextHistory: History<D> | null;
291
+ prevHistory: History<D> | null;
292
+ histories: History<D>[];
293
+ };
294
+
295
+ type PuckHistory = {
296
+ back: VoidFunction;
297
+ forward: VoidFunction;
298
+ historyStore: HistoryStore;
299
+ };
300
+
274
301
  declare const usePuck: () => {
275
302
  appState: AppState;
276
303
  config: Config<any, any, any>;
277
304
  dispatch: (action: PuckAction) => void;
305
+ history: Partial<PuckHistory>;
278
306
  };
279
307
 
280
308
  export { AppState, Button, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZoneProvider, Field, FieldLabel, IconButton, MappedItem, Puck, PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
package/dist/index.js CHANGED
@@ -29387,10 +29387,10 @@ var DrawerItem = ({
29387
29387
  const ctx = (0, import_react3.useContext)(drawerContext);
29388
29388
  const resolvedId = `${ctx.droppableId}::${id || name}`;
29389
29389
  const CustomInner = (0, import_react3.useMemo)(
29390
- () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("default"), children: children2 })),
29390
+ () => children || (({ children: children2, name: name2 }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("default"), children: children2 })),
29391
29391
  [children]
29392
29392
  );
29393
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DrawerDraggable, { id: resolvedId, index, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CustomInner, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: getClassNameItem("draggable"), children: [
29393
+ 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
29394
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("name"), children: name }),
29395
29395
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DragIcon, {}) })
29396
29396
  ] }) }) }) });
@@ -31011,7 +31011,10 @@ var useResolvedData = (appState, config, dispatch) => {
31011
31011
  );
31012
31012
  const runResolvers = () => __async(void 0, null, function* () {
31013
31013
  const newData = newAppState.data;
31014
- const flatContent = Object.keys(newData.zones || {}).reduce((acc, zone) => [...acc, ...newData.zones[zone]], newData.content).filter((item) => !!config.components[item.type].resolveData);
31014
+ const flatContent = Object.keys(newData.zones || {}).reduce((acc, zone) => [...acc, ...newData.zones[zone]], newData.content).filter((item) => {
31015
+ var _a;
31016
+ return !!((_a = config.components[item.type]) == null ? void 0 : _a.resolveData);
31017
+ });
31015
31018
  const applyIfChange = (dynamicDataMap, dynamicRoot) => {
31016
31019
  const processed = applyDynamicProps(
31017
31020
  appState.data,
@@ -31343,6 +31346,7 @@ var ArrayField = ({
31343
31346
  !readOnly && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameItem2("actions"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameItem2("action"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
31344
31347
  IconButton,
31345
31348
  {
31349
+ disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
31346
31350
  onClick: (e) => {
31347
31351
  e.stopPropagation();
31348
31352
  const existingValue = [
@@ -31407,6 +31411,7 @@ var ArrayField = ({
31407
31411
  "button",
31408
31412
  {
31409
31413
  className: getClassName10("addButton"),
31414
+ disabled: field.max !== void 0 && localState.arrayState.items.length >= field.max,
31410
31415
  onClick: () => {
31411
31416
  const existingValue = value || [];
31412
31417
  const newValue = [
@@ -31416,7 +31421,7 @@ var ArrayField = ({
31416
31421
  const newArrayState = regenerateArrayState(newValue);
31417
31422
  onChange(newValue, mapArrayStateToUi(newArrayState));
31418
31423
  },
31419
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Plus, { size: "21" })
31424
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Plus, { size: 21 })
31420
31425
  }
31421
31426
  )
31422
31427
  ]
@@ -33225,8 +33230,8 @@ var resolveAllData = (data, config, onResolveStart, onResolveEnd) => __async(voi
33225
33230
  // lib/use-puck.ts
33226
33231
  init_react_import();
33227
33232
  var usePuck = () => {
33228
- const { state: appState, config, dispatch } = useAppContext();
33229
- return { appState, config, dispatch };
33233
+ const { state: appState, config, history, dispatch } = useAppContext();
33234
+ return { appState, config, dispatch, history };
33230
33235
  };
33231
33236
  // Annotate the CommonJS export names for ESM import in node:
33232
33237
  0 && (module.exports = {
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-ab049d49.js';
2
+ import { C as Config, D as Data } from './Config-0bf39037.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.b365418",
3
+ "version": "0.14.0-canary.ca6bd5f",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",