@netlisian/softconfig 0.1.6 → 0.1.8

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.
@@ -1,4 +1,4 @@
1
- /* css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/error-boundary/styles.module.css/#css-module-data */
1
+ /* css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/components/error-boundary/styles.module.css/#css-module-data */
2
2
  ._ErrorBoundary_1xl05_5 {
3
3
  padding: 20px;
4
4
  border: 1px solid #ff5858;
@@ -26,7 +26,7 @@
26
26
  background-color: #b71c1c;
27
27
  }
28
28
 
29
- /* css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/Header.module.css/#css-module-data */
29
+ /* css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/overrides/Header.module.css/#css-module-data */
30
30
  ._Header_19oj9_1 {
31
31
  display: flex;
32
32
  justify-content: space-between;
@@ -35,7 +35,7 @@
35
35
  flex-wrap: wrap;
36
36
  }
37
37
 
38
- /* css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/ActionBar.module.css/#css-module-data */
38
+ /* css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/overrides/ActionBar.module.css/#css-module-data */
39
39
  ._ActionBar_pvuie_5 {
40
40
  align-items: center;
41
41
  cursor: default;
@@ -119,7 +119,7 @@
119
119
  margin: 0;
120
120
  }
121
121
 
122
- /* css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/DrawerItem.module.css/#css-module-data */
122
+ /* css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/overrides/DrawerItem.module.css/#css-module-data */
123
123
  ._DrawerItem_182aj_1 {
124
124
  background: var(--puck-color-white);
125
125
  cursor: grab;
@@ -343,7 +343,7 @@
343
343
  gap: 12px;
344
344
  }
345
345
 
346
- /* css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/modal/styles.module.css/#css-module-data */
346
+ /* css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/components/modal/styles.module.css/#css-module-data */
347
347
  ._Modal_1t9ot_1 {
348
348
  background: color-mix(in srgb, var(--puck-color-black) 75%, transparent);
349
349
  display: none;
@@ -372,7 +372,7 @@
372
372
  min-height: 0;
373
373
  }
374
374
 
375
- /* css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/Drawer.module.css/#css-module-data */
375
+ /* css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/overrides/Drawer.module.css/#css-module-data */
376
376
  ._Drawer_12zq5_1 {
377
377
  display: flex;
378
378
  flex-direction: column;
@@ -1,7 +1,7 @@
1
1
  import * as zustand from 'zustand';
2
2
  import { StoreApi } from 'zustand';
3
3
  import * as _measured_puck from '@measured/puck';
4
- import { Field, Fields, Config, DefaultComponentProps, History, AppState, PuckApi, ComponentData, ComponentConfig, RootData, AsFieldProps, WithChildren, Metadata, ResolveDataTrigger, PuckAction, Data } from '@measured/puck';
4
+ import { Field, Fields, Config, DefaultComponentProps, History, AppState, PuckApi, ComponentData, ComponentConfig, RootData, AsFieldProps, WithChildren, Metadata, ResolveDataTrigger, PuckAction, Data, Overrides as Overrides$1 } from '@measured/puck';
5
5
  import * as React$1 from 'react';
6
6
  import React__default, { ReactNode, ReactElement } from 'react';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -304,12 +304,12 @@ type RenderFunc<Props extends Record<string, unknown> = {
304
304
  children: ReactNode;
305
305
  }> = (props: Props) => ReactElement;
306
306
  type Overrides = {
307
- componentNameToKey?: (displayName: string, context: Partial<BuilderRootConfig> & {
307
+ componentLabelToName?: (label: string, context: Partial<BuilderRootConfig> & {
308
308
  existingKeys: string[];
309
309
  state: "building" | "remodeling" | "ready" | "inspecting";
310
310
  }) => string;
311
- componentKeyToName?: (key: string) => string;
312
- onRemodel?: (key: string) => Record<string, unknown>;
311
+ componentNameToLabel?: (name: string) => string;
312
+ onRemodel?: (name: string) => Record<string, unknown>;
313
313
  additionalRootFields?: Record<string, Field>;
314
314
  map?: RenderFunc<{
315
315
  rootProps: BuilderRootConfig;
@@ -342,90 +342,164 @@ type Overrides = {
342
342
  props: RootData<AsFieldProps<WithChildren<BuilderRootConfig>>> | Promise<RootData<AsFieldProps<WithChildren<BuilderRootConfig>>>>;
343
343
  readOnly: Readonly<Record<string, boolean>> | undefined;
344
344
  };
345
- mapComponentConfig?: (componentName: string, defaultConfig: ComponentConfig) => Partial<ComponentConfig>;
345
+ mapComponentConfig?: (componentName: string, defaultConfig: ComponentConfig, rootProps: BuilderRootConfig & RootData) => ComponentConfig;
346
346
  };
347
347
 
348
+ /** Represents the current editing mode of the Puck editor. */
348
349
  type Status = "building" | "remodeling" | "ready" | "inspecting";
349
350
  type AppStore = {
351
+ /** The current merged Puck config (hard + soft components). Rebuilt on soft component changes. */
350
352
  softConfig: Config;
353
+ /** Flat map of all registered soft components, keyed by component name. */
351
354
  softComponents: SoftComponents;
355
+ /**
356
+ * Soft components after `hydrateMapTransform` has been applied.
357
+ * Only populated when `overrides.hydrateMapTransform` is provided.
358
+ */
352
359
  hydratedSoftComponents?: SoftComponents;
360
+ /** The current editing mode. Controls which components can be mutated. */
353
361
  state: Status;
362
+ /** Snapshot of Puck history entries saved before an editing session starts. */
354
363
  originalHistory: History[];
364
+ /** A stored copy of the Puck config, used for rollback scenarios. */
355
365
  storedConfig?: Config;
366
+ /** Lifecycle and rendering overrides forwarded from the SoftConfigProvider. */
356
367
  overrides: Overrides;
368
+ /** Custom field definitions to extend the built-in Puck field types. */
357
369
  customFields: CustomFields;
370
+ /**
371
+ * Callback fired on every Puck action dispatch.
372
+ * Gives consumers a hook to react to drag-and-drop, insert, remove, etc.
373
+ */
358
374
  onActions?: OnActionsCallback;
375
+ /** The currently selected component in the Puck canvas, or null if none. */
359
376
  itemSelector: {
360
377
  index: number;
361
378
  zone: string;
362
379
  } | null;
380
+ /** Update or clear the active item selection. */
363
381
  setItemSelector: (selector: {
364
382
  index: number;
365
383
  zone: string;
366
384
  } | null) => void;
385
+ /** Snapshot of the selected component's props before any edits began. Used for cancel/rollback. */
367
386
  originalItem: DefaultComponentProps | null;
387
+ /** Persist the pre-edit props snapshot for the active item. */
368
388
  setOriginalItem: (item: DefaultComponentProps | null) => void;
389
+ /** Persist the full Puck history stack (called when entering an editing session). */
369
390
  storeHistory: (history: History[]) => void;
391
+ /** Clear the stored history (called when an editing session completes or cancels). */
370
392
  removeHistory: () => void;
393
+ /**
394
+ * Register or update a single soft component's Puck config.
395
+ * Optionally assigns the component to a Puck category.
396
+ */
371
397
  setSoftComponentConfig: (key: string, config: ComponentConfig, category?: string) => void;
398
+ /** Remove a soft component's Puck config entry by key. */
372
399
  removeSoftComponentConfig: (key: string) => void;
400
+ /**
401
+ * Delete a specific version of a soft component.
402
+ * If the deleted version was the default, promotes the most recent remaining version.
403
+ */
373
404
  removeSoftComponentVersion: (key: string, version: string) => void;
405
+ /** Register or update a Puck category (visibility, expansion, membership). */
374
406
  setSoftCategoryConfig: (key: string, category: {
375
407
  components?: string[];
376
408
  visible?: boolean;
377
409
  defaultExpanded?: boolean;
378
410
  title?: string;
379
411
  }) => void;
412
+ /** Remove a Puck category entry by key. */
380
413
  removeSoftCategoryConfig: (key: string) => void;
414
+ /** Builder sub-slice — handles multi-step build/remodel workflows. */
381
415
  builder: BuildersSlice;
416
+ /**
417
+ * Upsert a single version of a soft component.
418
+ * Creates the component entry if it doesn't already exist.
419
+ */
382
420
  setSoftComponent: (key: string, version: string, component: SoftComponent) => void;
421
+ /**
422
+ * Batch-upsert multiple soft components at once.
423
+ * Merges incoming versions with any existing versions for each component.
424
+ */
383
425
  setSoftComponents: (components: SoftComponents) => void;
426
+ /**
427
+ * Re-apply `overrides.hydrateMapTransform` to the current soft components.
428
+ * Call this when the transform function or its dependencies change at runtime.
429
+ */
384
430
  hydrateTransforms: () => void;
431
+ /**
432
+ * Promote a specific version of a soft component to be the active/default version.
433
+ * Rebuilds the Puck config entry for that component.
434
+ */
385
435
  setSoftComponentDefaultVersion: (key: string, version: string) => void;
436
+ /** Completely remove a soft component and all its versions from the store. */
386
437
  removeSoftComponent: (key: string) => void;
438
+ /** Name of the component type currently being edited (e.g. "Hero"), or null. */
387
439
  editingComponent: string | null;
440
+ /** Instance ID of the component currently being edited in the Puck canvas, or null. */
388
441
  editingComponentId: string | null;
442
+ /**
443
+ * Set of component instance IDs the user is allowed to mutate in the current session.
444
+ * Populated when entering "building" or "remodeling" state.
445
+ */
389
446
  editableComponentIds: Set<string>;
447
+ /** Overwrite the entire set of editable component IDs. */
390
448
  setEditableComponentIds: (ids: Set<string>) => void;
449
+ /** Append a single component instance ID to the editable set. */
391
450
  addEditableComponentId: (id: string) => void;
451
+ /** Reset editing state: clears editingComponentId and editableComponentIds. */
392
452
  clearEditingState: () => void;
393
453
  /**
394
- * Reverse dependency graph: componentName -> Set of components that depend on it
395
- * Used to efficiently rebuild dependent components when a soft component is updated
454
+ * Reverse dependency graph: componentName Set of component names that depend on it.
455
+ * Built once on store creation and updated when components change.
456
+ * Used to efficiently cascade Puck config rebuilds to affected dependents.
396
457
  */
397
458
  dependencyGraph: Map<string, Set<string>>;
398
459
  /**
399
- * Rebuild all dependent components after a soft component is updated
400
- * Only rebuilds components that depend on the changed component
460
+ * Rebuild the Puck config entries for every component that depends on the given one.
461
+ * Should be called after a soft component's render or schema changes.
401
462
  *
402
- * @param componentName - The component that was updated
403
- * @param version - The version that was updated
463
+ * @param componentName - The component that was updated.
464
+ * @param version - The version that changed (for future granular diffing).
404
465
  */
405
466
  rebuildDependents: (componentName: string, version: string) => void;
406
467
  /**
407
- * Iframe document reference for applying styling and edit visibility
408
- * Stored as a mutable ref to avoid triggering store updates.
468
+ * Mutable ref holding the Puck iframe's Document.
469
+ * Stored as a ref object to mutate without triggering Zustand subscribers.
409
470
  */
410
- iframeDocRef: {
411
- current: Document | null;
412
- };
413
- /**
414
- * Get the current iframe document reference
415
- */
416
- getIframeDoc: () => Document | null;
471
+ iframeDoc: Document | null;
417
472
  /**
418
- * Set the iframe document reference without causing re-renders
473
+ * Point the store at a new iframe Document.
474
+ * Immediately applies or clears edit-visibility CSS based on the current state.
419
475
  */
420
476
  setIframeDoc: (doc: Document | null) => void;
421
477
  /**
422
- * Flag to control visibility of version config fields
478
+ * When true, version-selection fields are shown in the Puck sidebar.
479
+ * Defaults to true; set to false to hide version controls from end users.
423
480
  */
424
481
  showVersionFields: boolean;
482
+ /** Toggle the visibility of version-selection fields in the Puck sidebar. */
483
+ setShowVersionFields: (show: boolean) => void;
425
484
  /**
426
- * Toggle the visibility of version config fields
485
+ * Reference to Puck's `history.back` function, injected by the UndoSync
486
+ * component that lives inside the ActionBar override.
487
+ * Null until the Puck editor mounts and ActionBar renders.
427
488
  */
428
- setShowVersionFields: (show: boolean) => void;
489
+ undoFn: (() => void) | null;
490
+ /**
491
+ * Called by UndoSync (inside the Puck tree) to register the live undo function.
492
+ * Must be called once per editor mount so `validateAction` can trigger rollbacks.
493
+ */
494
+ setUndoFn: (fn: () => void) => void;
495
+ /**
496
+ * Guard function passed to Puck's `onAction` via `createActionCallback`.
497
+ * Returns false for any action that targets a component outside the current
498
+ * editable set, which causes `createActionCallback` to immediately undo it.
499
+ *
500
+ * Always returns true when `state === "ready"` (no restrictions apply).
501
+ */
502
+ validateAction: (action: PuckAction, previousAction?: PuckAction) => boolean;
429
503
  };
430
504
  type AppStoreApi = StoreApi<AppStore>;
431
505
  declare const createSoftConfigStore: (hardConfig?: Config, softComponents?: SoftComponents, overrides?: Overrides, onActions?: OnActionsCallback, showVersionFields?: boolean, customFields?: CustomFields) => zustand.UseBoundStore<Omit<StoreApi<AppStore>, "subscribe"> & {
@@ -438,10 +512,27 @@ declare const createSoftConfigStore: (hardConfig?: Config, softComponents?: Soft
438
512
  };
439
513
  }>;
440
514
 
515
+ /**
516
+ * SoftConfigProvider is responsible for providing the soft config context to the Puck editor.
517
+ *
518
+ * @param props - The component props.
519
+ * @param props.children - A render prop that receives the following arguments:
520
+ * - `softConfig`: The current soft configuration object.
521
+ * - `softComponents`: The current mapping of soft components.
522
+ * - `setIframeDoc`: Function to set the iframe document reference in the store. Used to apply edit visibility styles on the iframe.
523
+ * - `validateAction`: Function to validate actions based on current state and editable component IDs. Used to disallow editing components that are not in the editable list during "building" or "remodeling" states.
524
+ * @param props.hardConfig - Initial Puck Config.
525
+ * @param props.softComponents - Initial soft components.
526
+ * @param props.customFields - Custom field to allow additional field types.
527
+ * @param props.overrides - Soft Config overrides.
528
+ * @param props.value - Optional external store API.
529
+ * @param props.onActions - Callback triggered on Puck actions.
530
+ * @param props.useVersioning - Flag to enable or disable versioning (defaults to false).
531
+ */
441
532
  declare const SoftConfigProvider: ({ children, hardConfig, softComponents, customFields, overrides, value, onActions, useVersioning, }: {
442
- children: (softConfig: Config, softComponents: SoftComponents, iframeDoc: AppStore["setIframeDoc"], validateAction: (action: PuckAction) => boolean) => ReactNode;
533
+ children: (softConfig: Config) => ReactNode;
443
534
  hardConfig: Config;
444
- softComponents: SoftComponents;
535
+ softComponents?: SoftComponents;
445
536
  customFields?: CustomFields;
446
537
  overrides?: Overrides;
447
538
  value?: StoreApi<AppStore>;
@@ -451,6 +542,10 @@ declare const SoftConfigProvider: ({ children, hardConfig, softComponents, custo
451
542
 
452
543
  declare const createUseSoftConfig: () => <T>(selector: (state: AppStore) => T, equalityFn?: (a: T, b: T) => boolean) => T;
453
544
  declare const useSoftConfig: <T>(selector: (state: AppStore) => T, equalityFn?: (a: T, b: T) => boolean) => T;
545
+ /**
546
+ * Access the soft config store instance without subscribing to state changes.
547
+ */
548
+ declare const useSoftConfigStore: () => StoreApi<AppStore>;
454
549
 
455
550
  declare const useBuild: (name?: string) => {
456
551
  handleBuild: () => void;
@@ -491,6 +586,10 @@ declare const useCancel: () => {
491
586
  canCancel: boolean;
492
587
  };
493
588
 
589
+ /** * Custom hook to handle inspecting a completed component in the Puck editor.
590
+ * @deprecated This hook is deprecated
591
+ * @param component - The completed component result to inspect. Should be set after completing a component.
592
+ */
494
593
  declare const useInspect: (component: CompletedComponentResult | null) => void;
495
594
 
496
595
  declare const useDecompose: () => {
@@ -550,6 +649,8 @@ declare const Drawer: (_props: {
550
649
  children?: React__default.ReactNode;
551
650
  }) => react_jsx_runtime.JSX.Element;
552
651
 
652
+ declare const HeaderActions: Overrides$1["headerActions"];
653
+
553
654
  type NotificationHandler = (message: string, type: "error" | "success") => void;
554
655
  declare const setNotificationHandler: (handler: NotificationHandler) => void;
555
656
  declare const notify: {
@@ -577,7 +678,7 @@ declare const confirm: (message: string) => Promise<boolean>;
577
678
  * @param undo Function to undo the last action (from Puck's history)
578
679
  * @returns Action handler function
579
680
  */
580
- declare const createActionCallback: (validateAction: (action: PuckAction) => boolean, undo: PuckApi["history"]["back"]) => (action: PuckAction) => void;
681
+ declare const createActionCallback: (validateAction: (action: PuckAction) => boolean, undo: PuckApi["history"]["back"] | null) => (action: PuckAction) => void;
581
682
 
582
683
  /**
583
684
  * Resolves soft components in data by dissolving them to hard components only.
@@ -645,4 +746,4 @@ declare const isArrayMappingPath: (path: string) => boolean;
645
746
  declare const getArrayBasePath: (arrayPath: string) => string | null;
646
747
  declare const getArrayItemSubPath: (arrayPath: string) => string | null;
647
748
 
648
- export { ActionBarOverride as ActionBar, type ActionEventPayload, type AppStore, type AppStoreApi, type ApplyMappingOptions, type ApplyMappingResult, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Drawer as ComponentList, type CustomFieldDefinition, type CustomFieldReturnType, type CustomFields, Drawer, DrawerItem, type FieldSettings, Header, type MapEntry, Modal, type OnActionsCallback, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, type SoftFieldDefinition, type SoftFieldSettings, type VersionedSoftComponent, applyMapping, confirm, createActionCallback, createSoftConfigStore, createUseSoftConfig, filterToOptionsForFrom, getArrayBasePath, getArrayItemSubPath, isArrayMappingPath, notify, resolveSoftConfig, resolveValueByPath, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
749
+ export { ActionBarOverride as ActionBar, type ActionEventPayload, type AppStore, type AppStoreApi, type ApplyMappingOptions, type ApplyMappingResult, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Drawer as ComponentList, type CustomFieldDefinition, type CustomFieldReturnType, type CustomFields, Drawer, DrawerItem, type FieldSettings, Header, HeaderActions, type MapEntry, Modal, type OnActionsCallback, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, type SoftFieldDefinition, type SoftFieldSettings, type VersionedSoftComponent, applyMapping, confirm, createActionCallback, createSoftConfigStore, createUseSoftConfig, filterToOptionsForFrom, getArrayBasePath, getArrayItemSubPath, isArrayMappingPath, notify, resolveSoftConfig, resolveValueByPath, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig, useSoftConfigStore };
@@ -1,7 +1,7 @@
1
1
  import * as zustand from 'zustand';
2
2
  import { StoreApi } from 'zustand';
3
3
  import * as _measured_puck from '@measured/puck';
4
- import { Field, Fields, Config, DefaultComponentProps, History, AppState, PuckApi, ComponentData, ComponentConfig, RootData, AsFieldProps, WithChildren, Metadata, ResolveDataTrigger, PuckAction, Data } from '@measured/puck';
4
+ import { Field, Fields, Config, DefaultComponentProps, History, AppState, PuckApi, ComponentData, ComponentConfig, RootData, AsFieldProps, WithChildren, Metadata, ResolveDataTrigger, PuckAction, Data, Overrides as Overrides$1 } from '@measured/puck';
5
5
  import * as React$1 from 'react';
6
6
  import React__default, { ReactNode, ReactElement } from 'react';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -304,12 +304,12 @@ type RenderFunc<Props extends Record<string, unknown> = {
304
304
  children: ReactNode;
305
305
  }> = (props: Props) => ReactElement;
306
306
  type Overrides = {
307
- componentNameToKey?: (displayName: string, context: Partial<BuilderRootConfig> & {
307
+ componentLabelToName?: (label: string, context: Partial<BuilderRootConfig> & {
308
308
  existingKeys: string[];
309
309
  state: "building" | "remodeling" | "ready" | "inspecting";
310
310
  }) => string;
311
- componentKeyToName?: (key: string) => string;
312
- onRemodel?: (key: string) => Record<string, unknown>;
311
+ componentNameToLabel?: (name: string) => string;
312
+ onRemodel?: (name: string) => Record<string, unknown>;
313
313
  additionalRootFields?: Record<string, Field>;
314
314
  map?: RenderFunc<{
315
315
  rootProps: BuilderRootConfig;
@@ -342,90 +342,164 @@ type Overrides = {
342
342
  props: RootData<AsFieldProps<WithChildren<BuilderRootConfig>>> | Promise<RootData<AsFieldProps<WithChildren<BuilderRootConfig>>>>;
343
343
  readOnly: Readonly<Record<string, boolean>> | undefined;
344
344
  };
345
- mapComponentConfig?: (componentName: string, defaultConfig: ComponentConfig) => Partial<ComponentConfig>;
345
+ mapComponentConfig?: (componentName: string, defaultConfig: ComponentConfig, rootProps: BuilderRootConfig & RootData) => ComponentConfig;
346
346
  };
347
347
 
348
+ /** Represents the current editing mode of the Puck editor. */
348
349
  type Status = "building" | "remodeling" | "ready" | "inspecting";
349
350
  type AppStore = {
351
+ /** The current merged Puck config (hard + soft components). Rebuilt on soft component changes. */
350
352
  softConfig: Config;
353
+ /** Flat map of all registered soft components, keyed by component name. */
351
354
  softComponents: SoftComponents;
355
+ /**
356
+ * Soft components after `hydrateMapTransform` has been applied.
357
+ * Only populated when `overrides.hydrateMapTransform` is provided.
358
+ */
352
359
  hydratedSoftComponents?: SoftComponents;
360
+ /** The current editing mode. Controls which components can be mutated. */
353
361
  state: Status;
362
+ /** Snapshot of Puck history entries saved before an editing session starts. */
354
363
  originalHistory: History[];
364
+ /** A stored copy of the Puck config, used for rollback scenarios. */
355
365
  storedConfig?: Config;
366
+ /** Lifecycle and rendering overrides forwarded from the SoftConfigProvider. */
356
367
  overrides: Overrides;
368
+ /** Custom field definitions to extend the built-in Puck field types. */
357
369
  customFields: CustomFields;
370
+ /**
371
+ * Callback fired on every Puck action dispatch.
372
+ * Gives consumers a hook to react to drag-and-drop, insert, remove, etc.
373
+ */
358
374
  onActions?: OnActionsCallback;
375
+ /** The currently selected component in the Puck canvas, or null if none. */
359
376
  itemSelector: {
360
377
  index: number;
361
378
  zone: string;
362
379
  } | null;
380
+ /** Update or clear the active item selection. */
363
381
  setItemSelector: (selector: {
364
382
  index: number;
365
383
  zone: string;
366
384
  } | null) => void;
385
+ /** Snapshot of the selected component's props before any edits began. Used for cancel/rollback. */
367
386
  originalItem: DefaultComponentProps | null;
387
+ /** Persist the pre-edit props snapshot for the active item. */
368
388
  setOriginalItem: (item: DefaultComponentProps | null) => void;
389
+ /** Persist the full Puck history stack (called when entering an editing session). */
369
390
  storeHistory: (history: History[]) => void;
391
+ /** Clear the stored history (called when an editing session completes or cancels). */
370
392
  removeHistory: () => void;
393
+ /**
394
+ * Register or update a single soft component's Puck config.
395
+ * Optionally assigns the component to a Puck category.
396
+ */
371
397
  setSoftComponentConfig: (key: string, config: ComponentConfig, category?: string) => void;
398
+ /** Remove a soft component's Puck config entry by key. */
372
399
  removeSoftComponentConfig: (key: string) => void;
400
+ /**
401
+ * Delete a specific version of a soft component.
402
+ * If the deleted version was the default, promotes the most recent remaining version.
403
+ */
373
404
  removeSoftComponentVersion: (key: string, version: string) => void;
405
+ /** Register or update a Puck category (visibility, expansion, membership). */
374
406
  setSoftCategoryConfig: (key: string, category: {
375
407
  components?: string[];
376
408
  visible?: boolean;
377
409
  defaultExpanded?: boolean;
378
410
  title?: string;
379
411
  }) => void;
412
+ /** Remove a Puck category entry by key. */
380
413
  removeSoftCategoryConfig: (key: string) => void;
414
+ /** Builder sub-slice — handles multi-step build/remodel workflows. */
381
415
  builder: BuildersSlice;
416
+ /**
417
+ * Upsert a single version of a soft component.
418
+ * Creates the component entry if it doesn't already exist.
419
+ */
382
420
  setSoftComponent: (key: string, version: string, component: SoftComponent) => void;
421
+ /**
422
+ * Batch-upsert multiple soft components at once.
423
+ * Merges incoming versions with any existing versions for each component.
424
+ */
383
425
  setSoftComponents: (components: SoftComponents) => void;
426
+ /**
427
+ * Re-apply `overrides.hydrateMapTransform` to the current soft components.
428
+ * Call this when the transform function or its dependencies change at runtime.
429
+ */
384
430
  hydrateTransforms: () => void;
431
+ /**
432
+ * Promote a specific version of a soft component to be the active/default version.
433
+ * Rebuilds the Puck config entry for that component.
434
+ */
385
435
  setSoftComponentDefaultVersion: (key: string, version: string) => void;
436
+ /** Completely remove a soft component and all its versions from the store. */
386
437
  removeSoftComponent: (key: string) => void;
438
+ /** Name of the component type currently being edited (e.g. "Hero"), or null. */
387
439
  editingComponent: string | null;
440
+ /** Instance ID of the component currently being edited in the Puck canvas, or null. */
388
441
  editingComponentId: string | null;
442
+ /**
443
+ * Set of component instance IDs the user is allowed to mutate in the current session.
444
+ * Populated when entering "building" or "remodeling" state.
445
+ */
389
446
  editableComponentIds: Set<string>;
447
+ /** Overwrite the entire set of editable component IDs. */
390
448
  setEditableComponentIds: (ids: Set<string>) => void;
449
+ /** Append a single component instance ID to the editable set. */
391
450
  addEditableComponentId: (id: string) => void;
451
+ /** Reset editing state: clears editingComponentId and editableComponentIds. */
392
452
  clearEditingState: () => void;
393
453
  /**
394
- * Reverse dependency graph: componentName -> Set of components that depend on it
395
- * Used to efficiently rebuild dependent components when a soft component is updated
454
+ * Reverse dependency graph: componentName Set of component names that depend on it.
455
+ * Built once on store creation and updated when components change.
456
+ * Used to efficiently cascade Puck config rebuilds to affected dependents.
396
457
  */
397
458
  dependencyGraph: Map<string, Set<string>>;
398
459
  /**
399
- * Rebuild all dependent components after a soft component is updated
400
- * Only rebuilds components that depend on the changed component
460
+ * Rebuild the Puck config entries for every component that depends on the given one.
461
+ * Should be called after a soft component's render or schema changes.
401
462
  *
402
- * @param componentName - The component that was updated
403
- * @param version - The version that was updated
463
+ * @param componentName - The component that was updated.
464
+ * @param version - The version that changed (for future granular diffing).
404
465
  */
405
466
  rebuildDependents: (componentName: string, version: string) => void;
406
467
  /**
407
- * Iframe document reference for applying styling and edit visibility
408
- * Stored as a mutable ref to avoid triggering store updates.
468
+ * Mutable ref holding the Puck iframe's Document.
469
+ * Stored as a ref object to mutate without triggering Zustand subscribers.
409
470
  */
410
- iframeDocRef: {
411
- current: Document | null;
412
- };
413
- /**
414
- * Get the current iframe document reference
415
- */
416
- getIframeDoc: () => Document | null;
471
+ iframeDoc: Document | null;
417
472
  /**
418
- * Set the iframe document reference without causing re-renders
473
+ * Point the store at a new iframe Document.
474
+ * Immediately applies or clears edit-visibility CSS based on the current state.
419
475
  */
420
476
  setIframeDoc: (doc: Document | null) => void;
421
477
  /**
422
- * Flag to control visibility of version config fields
478
+ * When true, version-selection fields are shown in the Puck sidebar.
479
+ * Defaults to true; set to false to hide version controls from end users.
423
480
  */
424
481
  showVersionFields: boolean;
482
+ /** Toggle the visibility of version-selection fields in the Puck sidebar. */
483
+ setShowVersionFields: (show: boolean) => void;
425
484
  /**
426
- * Toggle the visibility of version config fields
485
+ * Reference to Puck's `history.back` function, injected by the UndoSync
486
+ * component that lives inside the ActionBar override.
487
+ * Null until the Puck editor mounts and ActionBar renders.
427
488
  */
428
- setShowVersionFields: (show: boolean) => void;
489
+ undoFn: (() => void) | null;
490
+ /**
491
+ * Called by UndoSync (inside the Puck tree) to register the live undo function.
492
+ * Must be called once per editor mount so `validateAction` can trigger rollbacks.
493
+ */
494
+ setUndoFn: (fn: () => void) => void;
495
+ /**
496
+ * Guard function passed to Puck's `onAction` via `createActionCallback`.
497
+ * Returns false for any action that targets a component outside the current
498
+ * editable set, which causes `createActionCallback` to immediately undo it.
499
+ *
500
+ * Always returns true when `state === "ready"` (no restrictions apply).
501
+ */
502
+ validateAction: (action: PuckAction, previousAction?: PuckAction) => boolean;
429
503
  };
430
504
  type AppStoreApi = StoreApi<AppStore>;
431
505
  declare const createSoftConfigStore: (hardConfig?: Config, softComponents?: SoftComponents, overrides?: Overrides, onActions?: OnActionsCallback, showVersionFields?: boolean, customFields?: CustomFields) => zustand.UseBoundStore<Omit<StoreApi<AppStore>, "subscribe"> & {
@@ -438,10 +512,27 @@ declare const createSoftConfigStore: (hardConfig?: Config, softComponents?: Soft
438
512
  };
439
513
  }>;
440
514
 
515
+ /**
516
+ * SoftConfigProvider is responsible for providing the soft config context to the Puck editor.
517
+ *
518
+ * @param props - The component props.
519
+ * @param props.children - A render prop that receives the following arguments:
520
+ * - `softConfig`: The current soft configuration object.
521
+ * - `softComponents`: The current mapping of soft components.
522
+ * - `setIframeDoc`: Function to set the iframe document reference in the store. Used to apply edit visibility styles on the iframe.
523
+ * - `validateAction`: Function to validate actions based on current state and editable component IDs. Used to disallow editing components that are not in the editable list during "building" or "remodeling" states.
524
+ * @param props.hardConfig - Initial Puck Config.
525
+ * @param props.softComponents - Initial soft components.
526
+ * @param props.customFields - Custom field to allow additional field types.
527
+ * @param props.overrides - Soft Config overrides.
528
+ * @param props.value - Optional external store API.
529
+ * @param props.onActions - Callback triggered on Puck actions.
530
+ * @param props.useVersioning - Flag to enable or disable versioning (defaults to false).
531
+ */
441
532
  declare const SoftConfigProvider: ({ children, hardConfig, softComponents, customFields, overrides, value, onActions, useVersioning, }: {
442
- children: (softConfig: Config, softComponents: SoftComponents, iframeDoc: AppStore["setIframeDoc"], validateAction: (action: PuckAction) => boolean) => ReactNode;
533
+ children: (softConfig: Config) => ReactNode;
443
534
  hardConfig: Config;
444
- softComponents: SoftComponents;
535
+ softComponents?: SoftComponents;
445
536
  customFields?: CustomFields;
446
537
  overrides?: Overrides;
447
538
  value?: StoreApi<AppStore>;
@@ -451,6 +542,10 @@ declare const SoftConfigProvider: ({ children, hardConfig, softComponents, custo
451
542
 
452
543
  declare const createUseSoftConfig: () => <T>(selector: (state: AppStore) => T, equalityFn?: (a: T, b: T) => boolean) => T;
453
544
  declare const useSoftConfig: <T>(selector: (state: AppStore) => T, equalityFn?: (a: T, b: T) => boolean) => T;
545
+ /**
546
+ * Access the soft config store instance without subscribing to state changes.
547
+ */
548
+ declare const useSoftConfigStore: () => StoreApi<AppStore>;
454
549
 
455
550
  declare const useBuild: (name?: string) => {
456
551
  handleBuild: () => void;
@@ -491,6 +586,10 @@ declare const useCancel: () => {
491
586
  canCancel: boolean;
492
587
  };
493
588
 
589
+ /** * Custom hook to handle inspecting a completed component in the Puck editor.
590
+ * @deprecated This hook is deprecated
591
+ * @param component - The completed component result to inspect. Should be set after completing a component.
592
+ */
494
593
  declare const useInspect: (component: CompletedComponentResult | null) => void;
495
594
 
496
595
  declare const useDecompose: () => {
@@ -550,6 +649,8 @@ declare const Drawer: (_props: {
550
649
  children?: React__default.ReactNode;
551
650
  }) => react_jsx_runtime.JSX.Element;
552
651
 
652
+ declare const HeaderActions: Overrides$1["headerActions"];
653
+
553
654
  type NotificationHandler = (message: string, type: "error" | "success") => void;
554
655
  declare const setNotificationHandler: (handler: NotificationHandler) => void;
555
656
  declare const notify: {
@@ -577,7 +678,7 @@ declare const confirm: (message: string) => Promise<boolean>;
577
678
  * @param undo Function to undo the last action (from Puck's history)
578
679
  * @returns Action handler function
579
680
  */
580
- declare const createActionCallback: (validateAction: (action: PuckAction) => boolean, undo: PuckApi["history"]["back"]) => (action: PuckAction) => void;
681
+ declare const createActionCallback: (validateAction: (action: PuckAction) => boolean, undo: PuckApi["history"]["back"] | null) => (action: PuckAction) => void;
581
682
 
582
683
  /**
583
684
  * Resolves soft components in data by dissolving them to hard components only.
@@ -645,4 +746,4 @@ declare const isArrayMappingPath: (path: string) => boolean;
645
746
  declare const getArrayBasePath: (arrayPath: string) => string | null;
646
747
  declare const getArrayItemSubPath: (arrayPath: string) => string | null;
647
748
 
648
- export { ActionBarOverride as ActionBar, type ActionEventPayload, type AppStore, type AppStoreApi, type ApplyMappingOptions, type ApplyMappingResult, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Drawer as ComponentList, type CustomFieldDefinition, type CustomFieldReturnType, type CustomFields, Drawer, DrawerItem, type FieldSettings, Header, type MapEntry, Modal, type OnActionsCallback, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, type SoftFieldDefinition, type SoftFieldSettings, type VersionedSoftComponent, applyMapping, confirm, createActionCallback, createSoftConfigStore, createUseSoftConfig, filterToOptionsForFrom, getArrayBasePath, getArrayItemSubPath, isArrayMappingPath, notify, resolveSoftConfig, resolveValueByPath, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
749
+ export { ActionBarOverride as ActionBar, type ActionEventPayload, type AppStore, type AppStoreApi, type ApplyMappingOptions, type ApplyMappingResult, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Drawer as ComponentList, type CustomFieldDefinition, type CustomFieldReturnType, type CustomFields, Drawer, DrawerItem, type FieldSettings, Header, HeaderActions, type MapEntry, Modal, type OnActionsCallback, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, type SoftFieldDefinition, type SoftFieldSettings, type VersionedSoftComponent, applyMapping, confirm, createActionCallback, createSoftConfigStore, createUseSoftConfig, filterToOptionsForFrom, getArrayBasePath, getArrayItemSubPath, isArrayMappingPath, notify, resolveSoftConfig, resolveValueByPath, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig, useSoftConfigStore };