@netlisian/softconfig 0.1.5 → 0.1.7
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.
- package/README.md +62 -122
- package/dist/puck/index.css +6 -6
- package/dist/puck/index.d.mts +125 -27
- package/dist/puck/index.d.ts +125 -27
- package/dist/puck/index.js +520 -529
- package/dist/puck/index.mjs +519 -529
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,122 +1,62 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
##
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
## Action Lifecycle Events
|
|
65
|
-
|
|
66
|
-
`SoftConfigProvider` supports `onActions` for lifecycle callbacks:
|
|
67
|
-
|
|
68
|
-
- `build` → when build mode starts
|
|
69
|
-
- `remodel` → when remodel mode starts
|
|
70
|
-
- `complete` → when a build/remodel is finalized
|
|
71
|
-
- `inspect` → when inspect is requested
|
|
72
|
-
- `demolish` → when a soft component is deleted
|
|
73
|
-
- `setDefaultVersion`, `decompose`, `cancel`, `publish`
|
|
74
|
-
|
|
75
|
-
Version-aware payloads are included for build finalization and inspection flows:
|
|
76
|
-
|
|
77
|
-
```ts
|
|
78
|
-
type ActionEventPayload =
|
|
79
|
-
| {
|
|
80
|
-
type: "remodel";
|
|
81
|
-
payload: {
|
|
82
|
-
id: string;
|
|
83
|
-
version?: string;
|
|
84
|
-
softComponent?: VersionedSoftComponent["versions"][string];
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
| {
|
|
88
|
-
type: "complete";
|
|
89
|
-
payload: {
|
|
90
|
-
id: string;
|
|
91
|
-
version: string;
|
|
92
|
-
componentData: Record<string, any>;
|
|
93
|
-
softComponent: VersionedSoftComponent["versions"][string];
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
| {
|
|
97
|
-
type: "inspect";
|
|
98
|
-
payload: {
|
|
99
|
-
id: string;
|
|
100
|
-
version?: string;
|
|
101
|
-
softComponent?: VersionedSoftComponent["versions"][string];
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
| {
|
|
105
|
-
type: "demolish";
|
|
106
|
-
payload: {
|
|
107
|
-
id: string;
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
This contract allows downstream consumers (for example, save/sync bridges) to persist using exact version metadata without relying on inferred/default versions.
|
|
113
|
-
|
|
114
|
-
## Development
|
|
115
|
-
|
|
116
|
-
- Build: `pnpm --filter @netlisian/softconfig build`
|
|
117
|
-
- Dev (watch): `pnpm --filter @netlisian/softconfig dev`
|
|
118
|
-
- Lint: `pnpm --filter @netlisian/softconfig lint`
|
|
119
|
-
|
|
120
|
-
## License
|
|
121
|
-
|
|
122
|
-
MIT
|
|
1
|
+
# @netlisian/soft-config
|
|
2
|
+
|
|
3
|
+
The core library for building and managing **Soft Components** within the Netlisian ecosystem. It provides type-safe field definitions, recursive mapping logic, and state management for the Puck editor.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @netlisian/soft-config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Soft Component Builder**: Easy-to-use interface for creating versioned components.
|
|
14
|
+
- **Dynamic Field Options**: Automatically generates dot-notated mapping paths for nested objects and arrays.
|
|
15
|
+
- **Custom Field Support**: Extend the editor with custom UI while maintaining return type safety.
|
|
16
|
+
- **Puck Overrides**: Pre-built component overrides (ActionBar, Header, ComponentList) to seamlessly integrate Soft Components into the Puck editor.
|
|
17
|
+
|
|
18
|
+
## Key Concepts
|
|
19
|
+
|
|
20
|
+
### Soft Component Definitions
|
|
21
|
+
|
|
22
|
+
A Soft Component consists of fields, default props, and typed components.
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { SoftFieldDefinition } from "@netlisian/soft-config";
|
|
26
|
+
|
|
27
|
+
const galleryField: SoftFieldDefinition = {
|
|
28
|
+
name: "gallery",
|
|
29
|
+
type: "array",
|
|
30
|
+
subFields: [
|
|
31
|
+
{ name: "src", type: "text" },
|
|
32
|
+
{ name: "alt", type: "text" }
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Custom Field Extensibility
|
|
38
|
+
|
|
39
|
+
Define custom field types with specified return types (`string`, `number`, `boolean`, `object`, `array`).
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { CustomFields } from "@netlisian/soft-config";
|
|
43
|
+
|
|
44
|
+
export const myCustomFields: CustomFields = {
|
|
45
|
+
"my-color": {
|
|
46
|
+
field: { type: "custom", render: () => <div>Color Picker</div> },
|
|
47
|
+
returnType: "string"
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Field Mapping
|
|
53
|
+
|
|
54
|
+
The library handles the logic for mapping configuration data to component props, including recursive array iteration using `[]` syntax (e.g., `features[].title`).
|
|
55
|
+
|
|
56
|
+
## Documentation
|
|
57
|
+
|
|
58
|
+
For detailed guides and API references, check the [Netlisian Docs](https://docs.netlisian.com).
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
MIT
|
package/dist/puck/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* css-module:/
|
|
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:/
|
|
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:/
|
|
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:/
|
|
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:/
|
|
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:/
|
|
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;
|
package/dist/puck/index.d.mts
CHANGED
|
@@ -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
|
-
|
|
307
|
+
componentLabelToName?: (label: string, context: Partial<BuilderRootConfig> & {
|
|
308
308
|
existingKeys: string[];
|
|
309
309
|
state: "building" | "remodeling" | "ready" | "inspecting";
|
|
310
310
|
}) => string;
|
|
311
|
-
|
|
312
|
-
onRemodel?: (
|
|
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,89 +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, rootProps: BuilderRootConfig & RootData) => ComponentConfig;
|
|
345
346
|
};
|
|
346
347
|
|
|
348
|
+
/** Represents the current editing mode of the Puck editor. */
|
|
347
349
|
type Status = "building" | "remodeling" | "ready" | "inspecting";
|
|
348
350
|
type AppStore = {
|
|
351
|
+
/** The current merged Puck config (hard + soft components). Rebuilt on soft component changes. */
|
|
349
352
|
softConfig: Config;
|
|
353
|
+
/** Flat map of all registered soft components, keyed by component name. */
|
|
350
354
|
softComponents: SoftComponents;
|
|
355
|
+
/**
|
|
356
|
+
* Soft components after `hydrateMapTransform` has been applied.
|
|
357
|
+
* Only populated when `overrides.hydrateMapTransform` is provided.
|
|
358
|
+
*/
|
|
351
359
|
hydratedSoftComponents?: SoftComponents;
|
|
360
|
+
/** The current editing mode. Controls which components can be mutated. */
|
|
352
361
|
state: Status;
|
|
362
|
+
/** Snapshot of Puck history entries saved before an editing session starts. */
|
|
353
363
|
originalHistory: History[];
|
|
364
|
+
/** A stored copy of the Puck config, used for rollback scenarios. */
|
|
354
365
|
storedConfig?: Config;
|
|
366
|
+
/** Lifecycle and rendering overrides forwarded from the SoftConfigProvider. */
|
|
355
367
|
overrides: Overrides;
|
|
368
|
+
/** Custom field definitions to extend the built-in Puck field types. */
|
|
356
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
|
+
*/
|
|
357
374
|
onActions?: OnActionsCallback;
|
|
375
|
+
/** The currently selected component in the Puck canvas, or null if none. */
|
|
358
376
|
itemSelector: {
|
|
359
377
|
index: number;
|
|
360
378
|
zone: string;
|
|
361
379
|
} | null;
|
|
380
|
+
/** Update or clear the active item selection. */
|
|
362
381
|
setItemSelector: (selector: {
|
|
363
382
|
index: number;
|
|
364
383
|
zone: string;
|
|
365
384
|
} | null) => void;
|
|
385
|
+
/** Snapshot of the selected component's props before any edits began. Used for cancel/rollback. */
|
|
366
386
|
originalItem: DefaultComponentProps | null;
|
|
387
|
+
/** Persist the pre-edit props snapshot for the active item. */
|
|
367
388
|
setOriginalItem: (item: DefaultComponentProps | null) => void;
|
|
389
|
+
/** Persist the full Puck history stack (called when entering an editing session). */
|
|
368
390
|
storeHistory: (history: History[]) => void;
|
|
391
|
+
/** Clear the stored history (called when an editing session completes or cancels). */
|
|
369
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
|
+
*/
|
|
370
397
|
setSoftComponentConfig: (key: string, config: ComponentConfig, category?: string) => void;
|
|
398
|
+
/** Remove a soft component's Puck config entry by key. */
|
|
371
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
|
+
*/
|
|
372
404
|
removeSoftComponentVersion: (key: string, version: string) => void;
|
|
405
|
+
/** Register or update a Puck category (visibility, expansion, membership). */
|
|
373
406
|
setSoftCategoryConfig: (key: string, category: {
|
|
374
407
|
components?: string[];
|
|
375
408
|
visible?: boolean;
|
|
376
409
|
defaultExpanded?: boolean;
|
|
377
410
|
title?: string;
|
|
378
411
|
}) => void;
|
|
412
|
+
/** Remove a Puck category entry by key. */
|
|
379
413
|
removeSoftCategoryConfig: (key: string) => void;
|
|
414
|
+
/** Builder sub-slice — handles multi-step build/remodel workflows. */
|
|
380
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
|
+
*/
|
|
381
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
|
+
*/
|
|
382
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
|
+
*/
|
|
383
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
|
+
*/
|
|
384
435
|
setSoftComponentDefaultVersion: (key: string, version: string) => void;
|
|
436
|
+
/** Completely remove a soft component and all its versions from the store. */
|
|
385
437
|
removeSoftComponent: (key: string) => void;
|
|
438
|
+
/** Name of the component type currently being edited (e.g. "Hero"), or null. */
|
|
386
439
|
editingComponent: string | null;
|
|
440
|
+
/** Instance ID of the component currently being edited in the Puck canvas, or null. */
|
|
387
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
|
+
*/
|
|
388
446
|
editableComponentIds: Set<string>;
|
|
447
|
+
/** Overwrite the entire set of editable component IDs. */
|
|
389
448
|
setEditableComponentIds: (ids: Set<string>) => void;
|
|
449
|
+
/** Append a single component instance ID to the editable set. */
|
|
390
450
|
addEditableComponentId: (id: string) => void;
|
|
451
|
+
/** Reset editing state: clears editingComponentId and editableComponentIds. */
|
|
391
452
|
clearEditingState: () => void;
|
|
392
453
|
/**
|
|
393
|
-
* Reverse dependency graph: componentName
|
|
394
|
-
*
|
|
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.
|
|
395
457
|
*/
|
|
396
458
|
dependencyGraph: Map<string, Set<string>>;
|
|
397
459
|
/**
|
|
398
|
-
* Rebuild
|
|
399
|
-
*
|
|
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.
|
|
400
462
|
*
|
|
401
|
-
* @param componentName - The component that was updated
|
|
402
|
-
* @param version - The version that
|
|
463
|
+
* @param componentName - The component that was updated.
|
|
464
|
+
* @param version - The version that changed (for future granular diffing).
|
|
403
465
|
*/
|
|
404
466
|
rebuildDependents: (componentName: string, version: string) => void;
|
|
405
467
|
/**
|
|
406
|
-
*
|
|
407
|
-
* Stored as a
|
|
468
|
+
* Mutable ref holding the Puck iframe's Document.
|
|
469
|
+
* Stored as a ref object to mutate without triggering Zustand subscribers.
|
|
408
470
|
*/
|
|
409
|
-
|
|
410
|
-
current: Document | null;
|
|
411
|
-
};
|
|
471
|
+
iframeDoc: Document | null;
|
|
412
472
|
/**
|
|
413
|
-
*
|
|
414
|
-
|
|
415
|
-
getIframeDoc: () => Document | null;
|
|
416
|
-
/**
|
|
417
|
-
* 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.
|
|
418
475
|
*/
|
|
419
476
|
setIframeDoc: (doc: Document | null) => void;
|
|
420
477
|
/**
|
|
421
|
-
*
|
|
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.
|
|
422
480
|
*/
|
|
423
481
|
showVersionFields: boolean;
|
|
482
|
+
/** Toggle the visibility of version-selection fields in the Puck sidebar. */
|
|
483
|
+
setShowVersionFields: (show: boolean) => void;
|
|
424
484
|
/**
|
|
425
|
-
*
|
|
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.
|
|
426
488
|
*/
|
|
427
|
-
|
|
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;
|
|
428
503
|
};
|
|
429
504
|
type AppStoreApi = StoreApi<AppStore>;
|
|
430
505
|
declare const createSoftConfigStore: (hardConfig?: Config, softComponents?: SoftComponents, overrides?: Overrides, onActions?: OnActionsCallback, showVersionFields?: boolean, customFields?: CustomFields) => zustand.UseBoundStore<Omit<StoreApi<AppStore>, "subscribe"> & {
|
|
@@ -437,10 +512,27 @@ declare const createSoftConfigStore: (hardConfig?: Config, softComponents?: Soft
|
|
|
437
512
|
};
|
|
438
513
|
}>;
|
|
439
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
|
+
*/
|
|
440
532
|
declare const SoftConfigProvider: ({ children, hardConfig, softComponents, customFields, overrides, value, onActions, useVersioning, }: {
|
|
441
|
-
children: (softConfig: Config, softComponents: SoftComponents,
|
|
533
|
+
children: (softConfig: Config, softComponents: SoftComponents, actionGuard: (action: PuckAction) => void) => ReactNode;
|
|
442
534
|
hardConfig: Config;
|
|
443
|
-
softComponents
|
|
535
|
+
softComponents?: SoftComponents;
|
|
444
536
|
customFields?: CustomFields;
|
|
445
537
|
overrides?: Overrides;
|
|
446
538
|
value?: StoreApi<AppStore>;
|
|
@@ -490,6 +582,10 @@ declare const useCancel: () => {
|
|
|
490
582
|
canCancel: boolean;
|
|
491
583
|
};
|
|
492
584
|
|
|
585
|
+
/** * Custom hook to handle inspecting a completed component in the Puck editor.
|
|
586
|
+
* @deprecated This hook is deprecated
|
|
587
|
+
* @param component - The completed component result to inspect. Should be set after completing a component.
|
|
588
|
+
*/
|
|
493
589
|
declare const useInspect: (component: CompletedComponentResult | null) => void;
|
|
494
590
|
|
|
495
591
|
declare const useDecompose: () => {
|
|
@@ -549,6 +645,8 @@ declare const Drawer: (_props: {
|
|
|
549
645
|
children?: React__default.ReactNode;
|
|
550
646
|
}) => react_jsx_runtime.JSX.Element;
|
|
551
647
|
|
|
648
|
+
declare const HeaderActions: Overrides$1["headerActions"];
|
|
649
|
+
|
|
552
650
|
type NotificationHandler = (message: string, type: "error" | "success") => void;
|
|
553
651
|
declare const setNotificationHandler: (handler: NotificationHandler) => void;
|
|
554
652
|
declare const notify: {
|
|
@@ -576,7 +674,7 @@ declare const confirm: (message: string) => Promise<boolean>;
|
|
|
576
674
|
* @param undo Function to undo the last action (from Puck's history)
|
|
577
675
|
* @returns Action handler function
|
|
578
676
|
*/
|
|
579
|
-
declare const createActionCallback: (validateAction: (action: PuckAction) => boolean, undo: PuckApi["history"]["back"]) => (action: PuckAction) => void;
|
|
677
|
+
declare const createActionCallback: (validateAction: (action: PuckAction) => boolean, undo: PuckApi["history"]["back"] | null) => (action: PuckAction) => void;
|
|
580
678
|
|
|
581
679
|
/**
|
|
582
680
|
* Resolves soft components in data by dissolving them to hard components only.
|
|
@@ -644,4 +742,4 @@ declare const isArrayMappingPath: (path: string) => boolean;
|
|
|
644
742
|
declare const getArrayBasePath: (arrayPath: string) => string | null;
|
|
645
743
|
declare const getArrayItemSubPath: (arrayPath: string) => string | null;
|
|
646
744
|
|
|
647
|
-
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 };
|
|
745
|
+
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 };
|