@measured/puck 0.14.0-canary.cc7d391 → 0.14.0-canary.deff7a7

Sign up to get free protection for your applications and to get access to all the features.
@@ -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';
@@ -275,10 +275,34 @@ declare const resolveAllData: (data: Data, config: Config<any, any, any>, onReso
275
275
  zones: Record<string, MappedItem[]>;
276
276
  }>;
277
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
+
278
301
  declare const usePuck: () => {
279
302
  appState: AppState;
280
303
  config: Config<any, any, any>;
281
304
  dispatch: (action: PuckAction) => void;
305
+ history: Partial<PuckHistory>;
282
306
  };
283
307
 
284
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
@@ -31346,6 +31346,7 @@ var ArrayField = ({
31346
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)(
31347
31347
  IconButton,
31348
31348
  {
31349
+ disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
31349
31350
  onClick: (e) => {
31350
31351
  e.stopPropagation();
31351
31352
  const existingValue = [
@@ -31410,6 +31411,7 @@ var ArrayField = ({
31410
31411
  "button",
31411
31412
  {
31412
31413
  className: getClassName10("addButton"),
31414
+ disabled: field.max !== void 0 && localState.arrayState.items.length >= field.max,
31413
31415
  onClick: () => {
31414
31416
  const existingValue = value || [];
31415
31417
  const newValue = [
@@ -31419,7 +31421,7 @@ var ArrayField = ({
31419
31421
  const newArrayState = regenerateArrayState(newValue);
31420
31422
  onChange(newValue, mapArrayStateToUi(newArrayState));
31421
31423
  },
31422
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Plus, { size: "21" })
31424
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Plus, { size: 21 })
31423
31425
  }
31424
31426
  )
31425
31427
  ]
@@ -33228,8 +33230,8 @@ var resolveAllData = (data, config, onResolveStart, onResolveEnd) => __async(voi
33228
33230
  // lib/use-puck.ts
33229
33231
  init_react_import();
33230
33232
  var usePuck = () => {
33231
- const { state: appState, config, dispatch } = useAppContext();
33232
- return { appState, config, dispatch };
33233
+ const { state: appState, config, history, dispatch } = useAppContext();
33234
+ return { appState, config, dispatch, history };
33233
33235
  };
33234
33236
  // Annotate the CommonJS export names for ESM import in node:
33235
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.cc7d391",
3
+ "version": "0.14.0-canary.deff7a7",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",