@contentstack/studio-registry 1.8.0 → 1.9.0
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/dist/cjs/index.cjs +998 -201
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/common/global-store.js +2 -0
- package/dist/esm/common/global-store.js.map +1 -1
- package/dist/esm/component-registry/registry-options-processor.js +1 -0
- package/dist/esm/component-registry/registry-options-processor.js.map +1 -1
- package/dist/esm/component-registry/registry.constant.js +0 -3
- package/dist/esm/component-registry/registry.constant.js.map +1 -1
- package/dist/esm/component-registry/registry.js +1 -27
- package/dist/esm/component-registry/registry.js.map +1 -1
- package/dist/esm/data-binder/cslp.js +8 -1
- package/dist/esm/data-binder/cslp.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.js +11 -32
- package/dist/esm/data-binder/retrieve-data.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.util.js +7 -4
- package/dist/esm/data-binder/retrieve-data.util.js.map +1 -1
- package/dist/esm/data-binder/state-binding.util.js +158 -0
- package/dist/esm/data-binder/state-binding.util.js.map +1 -0
- package/dist/esm/design-registry/design-token.js +5 -2
- package/dist/esm/design-registry/design-token.js.map +1 -1
- package/dist/esm/index.d.ts +468 -26
- package/dist/esm/index.js +6 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/state-store/action-props.util.js +42 -0
- package/dist/esm/state-store/action-props.util.js.map +1 -0
- package/dist/esm/state-store/function-registry.js +128 -0
- package/dist/esm/state-store/function-registry.js.map +1 -0
- package/dist/esm/state-store/public-api.js +109 -0
- package/dist/esm/state-store/public-api.js.map +1 -0
- package/dist/esm/state-store/singleton.js +27 -0
- package/dist/esm/state-store/singleton.js.map +1 -0
- package/dist/esm/state-store/state-store.js +384 -0
- package/dist/esm/state-store/state-store.js.map +1 -0
- package/package.json +6 -6
- package/dist/esm/utils/symbols.js +0 -12
- package/dist/esm/utils/symbols.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-token.js","sources":["../../../src/design-registry/design-token.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAcM,SAAU,kBAAkB,CAChC,MAAA,GAA4B,EAAE,EAAA;AAE9B,IAAA,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,MAAM,CAAC;AACzD,IAAA,MAAM,YAAY,GAAG,sBAAsB,EAAE;AAC7C,IAAA,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,kBAAkB,CAAC;;IAGxE,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAA2B,EAAE;QACzE,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,IAAI,EAAE;AAEhD,QAAA,IAAI,OAAO,KAAK,MAAM,EAAE;AACtB,YAAA,qBAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE;gBACnD,IAAI,EAAG,MAAc,CAAC,MAAM;AAC7B,aAAA,CAAC;QACJ;AAAO,aAAA,IAAI,OAAO,KAAK,SAAS,EAAE;AAChC,YAAA,qBAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE;AACnD,gBAAA,IAAI,EAAE;oBACJ,GAAG,kBAAkB,CAAC,WAAW;oBACjC,GAAI,MAAc,CAAC,MAAM;AAC1B,iBAAA;AACF,aAAA,CAAC;QACJ;aAAO,IACL,OAAO,KAAK,UAAU;AACtB,YAAA,OAAO,KAAK,YAAY;AACxB,YAAA,OAAO,KAAK,SAAS;AACrB,YAAA,OAAO,KAAK,WAAW;YACvB,OAAO,KAAK,UAAU,EACtB;AACA,YAAA,qBAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC;QACtD;AAAO,aAAA,IAAI,OAAO,KAAK,QAAQ,EAAE;AAC/B,YAAA,qBAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE;gBACnD,GAAG,EAAE,kBAAkB,CAAC,WAAW;AACpC,aAAA,CAAC;QACJ;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G,6BAA6B,EAAE;AAEtD,IAAA,cAAc,CAAC,wBAAwB;AACrC,QAAA,OAAO,EAAE,wBAAwB;YACjC,cAAc,CAAC,wBAAwB;AAEzC,IAAA,cAAc,CAAC,kBAAkB,GAAG,OAAO,EAAE;AAC3C,UAAE,0BAA0B,CAAC,OAAO,CAAC,kBAAkB;AACvD,UAAE,cAAc,CAAC,kBAAkB;AAErC,IAAA,OAAO,cAAc;AACvB;AAEA,SAAS,0BAA0B,CACjC,aAA6D,EAAA
|
|
1
|
+
{"version":3,"file":"design-token.js","sources":["../../../src/design-registry/design-token.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAcM,SAAU,kBAAkB,CAChC,MAAA,GAA4B,EAAE,EAAA;AAE9B,IAAA,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,MAAM,CAAC;AACzD,IAAA,MAAM,YAAY,GAAG,sBAAsB,EAAE;AAC7C,IAAA,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,kBAAkB,CAAC;;IAGxE,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAA2B,EAAE;QACzE,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,IAAI,EAAE;AAEhD,QAAA,IAAI,OAAO,KAAK,MAAM,EAAE;AACtB,YAAA,qBAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE;gBACnD,IAAI,EAAG,MAAc,CAAC,MAAM;AAC7B,aAAA,CAAC;QACJ;AAAO,aAAA,IAAI,OAAO,KAAK,SAAS,EAAE;AAChC,YAAA,qBAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE;AACnD,gBAAA,IAAI,EAAE;oBACJ,GAAG,kBAAkB,CAAC,WAAW;oBACjC,GAAI,MAAc,CAAC,MAAM;AAC1B,iBAAA;AACF,aAAA,CAAC;QACJ;aAAO,IACL,OAAO,KAAK,UAAU;AACtB,YAAA,OAAO,KAAK,YAAY;AACxB,YAAA,OAAO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E;AACf,QAAA,WAAW,EAAE,EAAE;KAChB;AACH;;;;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -102,6 +102,27 @@ type ObjectInput = PropBase<NodePropTypes["object"], Record<string, unknown>> &
|
|
|
102
102
|
properties?: unknown;
|
|
103
103
|
};
|
|
104
104
|
type AnyProp = PropBase<NodePropTypes["any"], any>;
|
|
105
|
+
/**
|
|
106
|
+
* A registered Studio function reference — lets ANY component expose a
|
|
107
|
+
* behavior slot the user wires up in the Studio props panel.
|
|
108
|
+
*
|
|
109
|
+
* The Studio UI renders a dropdown of the app's `registerStudioFunctions`
|
|
110
|
+
* names; the chosen NAME is saved (static value). At render time the SDK
|
|
111
|
+
* swaps the name for a callable `(...args) => callStudioFunction(name, ...args)`,
|
|
112
|
+
* so the component simply invokes its prop:
|
|
113
|
+
*
|
|
114
|
+
* ```tsx
|
|
115
|
+
* registerComponent(Banner, {
|
|
116
|
+
* type: "promo-banner",
|
|
117
|
+
* props: { onCtaClick: { type: "action", displayName: "CTA Click Function" } },
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* function Banner({ onCtaClick }: { onCtaClick?: (...args: unknown[]) => unknown }) {
|
|
121
|
+
* return <button onClick={() => onCtaClick?.()}>Claim</button>;
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
type ActionProp = PropBase<NodePropTypes["action"], string>;
|
|
105
126
|
/**
|
|
106
127
|
* Use `json_rte` for props bound to a **Contentstack JSON Rich-Text Editor field**.
|
|
107
128
|
*
|
|
@@ -150,8 +171,8 @@ type PlainTextProp = PropBase<NodePropTypes["plaintext"], string> & {
|
|
|
150
171
|
control?: "default" | "large";
|
|
151
172
|
placeholder?: string;
|
|
152
173
|
};
|
|
153
|
-
type PropsWithNoOptionsRequired = StringProp | BooleanProp | NumberProp | DateStringProp | HrefProp | ImageUrlProp | ObjectProp | ArrayProp | SlotProp;
|
|
154
|
-
type PropInput = StringProp | BooleanProp | NumberProp | DateStringProp | HrefProp | ImageUrlProp | ObjectProp | ArrayProp | SlotProp | ChoiceProp | AnyProp | JsonRTEProp | PlainTextProp;
|
|
174
|
+
type PropsWithNoOptionsRequired = StringProp | BooleanProp | NumberProp | DateStringProp | HrefProp | ImageUrlProp | ObjectProp | ArrayProp | SlotProp | ActionProp;
|
|
175
|
+
type PropInput = StringProp | BooleanProp | NumberProp | DateStringProp | HrefProp | ImageUrlProp | ObjectProp | ArrayProp | SlotProp | ChoiceProp | AnyProp | JsonRTEProp | PlainTextProp | ActionProp;
|
|
155
176
|
type PropTypeOfNoOptionsRequired = PropsWithNoOptionsRequired["type"];
|
|
156
177
|
type PropType = PropInput["type"];
|
|
157
178
|
type Props = {
|
|
@@ -177,7 +198,6 @@ declare const DATA_SOURCES: {
|
|
|
177
198
|
readonly CONTENTSTACK: "contentstack";
|
|
178
199
|
readonly REPEATER: "repeater";
|
|
179
200
|
readonly QUERY: "contentstack_queries";
|
|
180
|
-
readonly SYMBOL_PROPS: "symbol_props";
|
|
181
201
|
};
|
|
182
202
|
declare const INTERNAL_COMPONENT_SECTIONS: {
|
|
183
203
|
readonly BASIC: "Basic";
|
|
@@ -187,10 +207,9 @@ declare const INTERNAL_COMPONENT_SECTIONS: {
|
|
|
187
207
|
readonly ADVANCED: "Advanced";
|
|
188
208
|
readonly REGISTERED_COMPONENTS: "Registered Components";
|
|
189
209
|
readonly HTML_ELEMENT: "HTML Elements";
|
|
190
|
-
readonly SYMBOL: "Symbols";
|
|
191
210
|
readonly SECTION_COMPOSITION: "Sections";
|
|
192
211
|
};
|
|
193
|
-
declare const INTERNAL_SECTIONS: ("Basic" | "Media" | "Container" | "Smart Containers" | "Advanced" | "Registered Components" | "HTML Elements" | "
|
|
212
|
+
declare const INTERNAL_SECTIONS: ("Basic" | "Media" | "Container" | "Smart Containers" | "Advanced" | "Registered Components" | "HTML Elements" | "Sections")[];
|
|
194
213
|
declare const STYLE_SECTIONS_OPTIONS: readonly ["class", "size", "spacing", "position", "visibility", "layout", "typography", "transform", "media", "background", "shadow", "effect", "overflow", "border", "responsive"];
|
|
195
214
|
/**
|
|
196
215
|
* The style group is the group of the style sections options.
|
|
@@ -222,7 +241,6 @@ declare const INTERNAL_COMPONENTS_NAMES: {
|
|
|
222
241
|
readonly ROWS: "vstack";
|
|
223
242
|
readonly REPEATER: "repeater";
|
|
224
243
|
readonly CONDITION_BLOCK: "condition-block";
|
|
225
|
-
readonly SYMBOL: "symbol";
|
|
226
244
|
readonly FRAGMENT: "fragment";
|
|
227
245
|
readonly SECTION_SLOT: "section-slot";
|
|
228
246
|
readonly HTML_ELEMENT: "html-element";
|
|
@@ -292,11 +310,41 @@ interface RegisterComponentSchemaInput<C = unknown> {
|
|
|
292
310
|
*/
|
|
293
311
|
thumbnailUrl?: string;
|
|
294
312
|
/**
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
313
|
+
* Declares the style groups Studio offers for this component. Each key is one
|
|
314
|
+
* group, shown as its own entry in the Design panel.
|
|
315
|
+
*
|
|
316
|
+
* Every group is compiled at render time into a single CSS class string, and
|
|
317
|
+
* delivered to the component as a prop:
|
|
318
|
+
*
|
|
319
|
+
* - the `default` group arrives as `className`
|
|
320
|
+
* - every other group arrives as a prop named exactly like the group key
|
|
321
|
+
*
|
|
322
|
+
* The component has to apply what it is given. A group whose class never
|
|
323
|
+
* reaches the DOM cannot be styled — the Design panel edits are stored on the
|
|
324
|
+
* node, but nothing renders.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```tsx
|
|
328
|
+
* registerComponent({
|
|
329
|
+
* type: "card",
|
|
330
|
+
* component: Card,
|
|
331
|
+
* styles: {
|
|
332
|
+
* default: { styleSections: ["block"] },
|
|
333
|
+
* title: { displayName: "Title", styleSections: ["text"] },
|
|
334
|
+
* },
|
|
335
|
+
* });
|
|
336
|
+
*
|
|
337
|
+
* function Card({ className, title, heading }) {
|
|
338
|
+
* return (
|
|
339
|
+
* <div className={className}>
|
|
340
|
+
* <h2 className={title}>{heading}</h2>
|
|
341
|
+
* </div>
|
|
342
|
+
* );
|
|
343
|
+
* }
|
|
344
|
+
* ```
|
|
345
|
+
*
|
|
346
|
+
* Do not name a group after a registered prop — props are applied last and
|
|
347
|
+
* would overwrite the group's classes.
|
|
300
348
|
*/
|
|
301
349
|
styles?: {
|
|
302
350
|
[section: string]: StyleGroupOptions;
|
|
@@ -323,7 +371,7 @@ interface RegisterComponentSchemaInput<C = unknown> {
|
|
|
323
371
|
*/
|
|
324
372
|
layerIcon?: LayerIcon;
|
|
325
373
|
/**
|
|
326
|
-
* This can be used to store extra metadata for components. For eg for
|
|
374
|
+
* This can be used to store extra metadata for components. For eg for sections we can store uid here.
|
|
327
375
|
*/
|
|
328
376
|
metadata?: Record<string, unknown>;
|
|
329
377
|
}
|
|
@@ -344,7 +392,7 @@ interface RegisterComponentSchema<C> extends Required<Omit<RegisterComponentSche
|
|
|
344
392
|
[key: string]: PropInput;
|
|
345
393
|
};
|
|
346
394
|
}
|
|
347
|
-
type Registry = "internal" | "user-defined" | "
|
|
395
|
+
type Registry = "internal" | "user-defined" | "sections";
|
|
348
396
|
type RegisterComponentOptionsInput<C = unknown> = Omit<RegisterComponentSchemaInput<C>, "icon">;
|
|
349
397
|
type RegisterInternalComponentOptionsInput<C = unknown> = RegisterComponentSchemaInput<C>;
|
|
350
398
|
type InternalComponentRegistryOptions = {
|
|
@@ -355,11 +403,14 @@ type StyleSectionCategoriesOptions = keyof typeof STYLE_SECTION_CATEGORIES;
|
|
|
355
403
|
type StyleSections = (StyleSectionOptions | StyleSectionCategoriesOptions)[] | "all" | "none";
|
|
356
404
|
interface StyleGroupOptions {
|
|
357
405
|
/**
|
|
358
|
-
*
|
|
406
|
+
* Classes this group always carries. They are merged into the class string
|
|
407
|
+
* the group delivers to the component.
|
|
359
408
|
*/
|
|
360
409
|
defaultClasses?: DesignClassValue[];
|
|
361
410
|
/**
|
|
362
|
-
*
|
|
411
|
+
* The styles this group starts with. Studio writes them onto the node when
|
|
412
|
+
* the component is added, so authors can then change them from the Design
|
|
413
|
+
* panel.
|
|
363
414
|
*/
|
|
364
415
|
defaultStyles?: Properties;
|
|
365
416
|
/**
|
|
@@ -419,11 +470,6 @@ declare class ComponentRegistry<C> {
|
|
|
419
470
|
* @throws {Error} If a component name is missing.
|
|
420
471
|
*/
|
|
421
472
|
registerInternalComponent(componentConfigs: RegisterInternalComponentOptionsInput<C>[], options?: InternalComponentRegistryOptions): void;
|
|
422
|
-
/**
|
|
423
|
-
* Registers list of symbol components in the component registry
|
|
424
|
-
* @param componentsConfigs
|
|
425
|
-
*/
|
|
426
|
-
registerSymbolComponent(componentsConfigs: RegisterInternalComponentOptionsInput<C>[]): void;
|
|
427
473
|
registerSectionComponent(componentsConfigs: RegisterInternalComponentOptionsInput<C>[]): void;
|
|
428
474
|
/**
|
|
429
475
|
* Registers one or more components in the component registry.
|
|
@@ -1310,12 +1356,12 @@ interface SectionScopedDataSources {
|
|
|
1310
1356
|
parentRepeaterUID?: string | null;
|
|
1311
1357
|
selectedField?: string;
|
|
1312
1358
|
uidRemapping?: Record<string, string>;
|
|
1359
|
+
cardinality?: "collection" | "single";
|
|
1313
1360
|
componentPropsFallback?: Record<string, unknown>;
|
|
1314
1361
|
}
|
|
1315
1362
|
interface StudioSpecData {
|
|
1316
1363
|
dataSources: DataSources;
|
|
1317
1364
|
static_value: StaticValue;
|
|
1318
|
-
symbol_props?: Record<string, any>;
|
|
1319
1365
|
component_props?: Record<string, any>;
|
|
1320
1366
|
section_scoped_data?: Record<string, SectionScopedDataSources>;
|
|
1321
1367
|
}
|
|
@@ -1462,6 +1508,51 @@ declare const getCslpTag: ({ bindedField, data, }: {
|
|
|
1462
1508
|
data: ComposableStudioData;
|
|
1463
1509
|
}) => any;
|
|
1464
1510
|
|
|
1511
|
+
declare function collectStateBindingKeys(node: (Pick<Node, "props"> & {
|
|
1512
|
+
metadata?: {
|
|
1513
|
+
bindings?: Record<string, unknown>;
|
|
1514
|
+
};
|
|
1515
|
+
}) | undefined | null): string[];
|
|
1516
|
+
/**
|
|
1517
|
+
* Snapshot of the given declared state keys — `{ key: currentValue }` —
|
|
1518
|
+
* merged by the renderer into `data.component_props` before prop resolution
|
|
1519
|
+
* so the existing `component_props` path machinery (fallbacks, type
|
|
1520
|
+
* validation, editor error badges) resolves state values unchanged.
|
|
1521
|
+
*
|
|
1522
|
+
* Keys whose current value is `undefined` (declared but unset, no default) are
|
|
1523
|
+
* OMITTED — spreading `{key: undefined}` over `component_props` would wipe an
|
|
1524
|
+
* external/authored value of the same name, silently losing server content.
|
|
1525
|
+
*/
|
|
1526
|
+
declare function getStateValuesFor(keys: readonly string[]): Record<string, unknown>;
|
|
1527
|
+
/**
|
|
1528
|
+
* Like getStateValuesFor but reads ONLY the declared defaults, never the live
|
|
1529
|
+
* backend value. Used as the server / hydration baseline so SSR and the client
|
|
1530
|
+
* hydration render agree (a persisted local/session value read on the client
|
|
1531
|
+
* but not the server would otherwise be a hydration mismatch). Undefined
|
|
1532
|
+
* defaults are omitted for the same reason as getStateValuesFor.
|
|
1533
|
+
*/
|
|
1534
|
+
declare function getStateDefaultsFor(keys: readonly string[]): Record<string, unknown>;
|
|
1535
|
+
/**
|
|
1536
|
+
* The registered studio FUNCTION a node is bound to, if any.
|
|
1537
|
+
*
|
|
1538
|
+
* Authors assign behavior from the Data Picker's Component Props section
|
|
1539
|
+
* (functions are listed under the state variables): the picker writes an
|
|
1540
|
+
* ordinary `component_props` binding — on an attribute (`metadata.bindings`,
|
|
1541
|
+
* e.g. `attrs.id`) or a prop — whose key is a registered function NAME.
|
|
1542
|
+
* Because functions and data share the source, "is it a function?" is decided
|
|
1543
|
+
* right here: key ∈ function registry → behavior, otherwise it stays a plain
|
|
1544
|
+
* data binding and is ignored by this helper.
|
|
1545
|
+
*
|
|
1546
|
+
* The renderer attaches the returned name as the node's click handler
|
|
1547
|
+
* (`callStudioFunction(name)`), which is what makes assignment work for ANY
|
|
1548
|
+
* component with zero prop declarations.
|
|
1549
|
+
*/
|
|
1550
|
+
declare function getNodeBoundFunctionName(node: (Pick<Node, "props"> & {
|
|
1551
|
+
metadata?: {
|
|
1552
|
+
bindings?: Record<string, unknown>;
|
|
1553
|
+
};
|
|
1554
|
+
}) | undefined | null): string | undefined;
|
|
1555
|
+
|
|
1465
1556
|
interface Breakpoint {
|
|
1466
1557
|
id: string;
|
|
1467
1558
|
displayName: string;
|
|
@@ -1490,9 +1581,6 @@ declare class BreakpointRegistry {
|
|
|
1490
1581
|
processBreakpoints(breakpoints: BreakpointInput): Breakpoint[];
|
|
1491
1582
|
}
|
|
1492
1583
|
|
|
1493
|
-
declare const getSymbolUIDFromNode: (symbol: Node) => string;
|
|
1494
|
-
declare const getSymbolUIDFromUID: (uid: string) => string;
|
|
1495
|
-
|
|
1496
1584
|
/**
|
|
1497
1585
|
* Extracts the composition UID from a section-composition node's metadata.
|
|
1498
1586
|
* Used to resolve section references to their actual composition identifiers.
|
|
@@ -1502,6 +1590,358 @@ declare const getSymbolUIDFromUID: (uid: string) => string;
|
|
|
1502
1590
|
*/
|
|
1503
1591
|
declare const getSectionUIDFromNode: (section: Node) => any;
|
|
1504
1592
|
|
|
1593
|
+
/**
|
|
1594
|
+
* Type of a declared state variable. Mirrors the bindable prop types the
|
|
1595
|
+
* Data Picker understands so a declared variable can be offered for binding
|
|
1596
|
+
* inside the existing "External Data" (component_props) source.
|
|
1597
|
+
*/
|
|
1598
|
+
type StateVariableType = "string" | "number" | "boolean" | "choice" | "array" | "object";
|
|
1599
|
+
/**
|
|
1600
|
+
* A state variable declared either globally (SDK init `state.variables`) or
|
|
1601
|
+
* at module scope via `registerComponentStateVariable`. Declared variables are the ONLY
|
|
1602
|
+
* ones surfaced to authors for binding; ad-hoc keys used with
|
|
1603
|
+
* `useStudioState("some_key")` remain code-only.
|
|
1604
|
+
*/
|
|
1605
|
+
interface StateVariableDef {
|
|
1606
|
+
type: StateVariableType;
|
|
1607
|
+
defaultValue?: unknown;
|
|
1608
|
+
/** For `type: "choice"` — the allowed values. */
|
|
1609
|
+
options?: string[];
|
|
1610
|
+
}
|
|
1611
|
+
/**
|
|
1612
|
+
* WHERE shared state is persisted:
|
|
1613
|
+
* - `"session"` — built-in sessionStorage store (DEFAULT when `state` is
|
|
1614
|
+
* configured without `storage` and without custom functions): survives
|
|
1615
|
+
* reloads and hard navigations within the tab, cleared when it closes.
|
|
1616
|
+
* - `"local"` — built-in localStorage store: also survives across visits.
|
|
1617
|
+
* - `"custom"` — Bring Your Own Store: `getState`/`setState` required.
|
|
1618
|
+
*/
|
|
1619
|
+
type StudioStateStorage = "local" | "session" | "custom";
|
|
1620
|
+
/**
|
|
1621
|
+
* User-supplied state integration — the "Bring Your Own State" contract.
|
|
1622
|
+
*
|
|
1623
|
+
* Pick a storage option via `storage` — `"local"` / `"session"` use built-in
|
|
1624
|
+
* web-storage stores (no functions needed); `"custom"` delegates to the
|
|
1625
|
+
* user's own store (Redux, Zustand, signals, a plain object…) via
|
|
1626
|
+
* `getState`/`setState`. Omitting `storage`: custom when the functions are
|
|
1627
|
+
* provided, otherwise the built-in SESSION store. Omitting `state` entirely
|
|
1628
|
+
* keeps the SDK's internal in-memory Map (fully backward compatible).
|
|
1629
|
+
*/
|
|
1630
|
+
interface StudioStateConfig {
|
|
1631
|
+
/** Storage option — see StudioStateStorage. */
|
|
1632
|
+
storage?: StudioStateStorage;
|
|
1633
|
+
/** Web-storage key for the built-in stores. Default: "cs-studio:state". */
|
|
1634
|
+
storageKey?: string;
|
|
1635
|
+
/** Read a value from the user's store. Required for `storage: "custom"`. */
|
|
1636
|
+
getState?: (key: string) => unknown;
|
|
1637
|
+
/** Write a value to the user's store. Required for `storage: "custom"`. */
|
|
1638
|
+
setState?: (key: string, value: unknown) => void;
|
|
1639
|
+
/**
|
|
1640
|
+
* Optional per-key change notification from the user's store. Lets
|
|
1641
|
+
* mutations that happen OUTSIDE Studio (e.g. a Redux dispatch elsewhere in
|
|
1642
|
+
* the app) propagate into Studio-bound components. Returns an unsubscribe.
|
|
1643
|
+
*/
|
|
1644
|
+
subscribe?: (key: string, listener: () => void) => (() => void) | void;
|
|
1645
|
+
/** Author-bindable state variables declared at init. */
|
|
1646
|
+
variables?: Record<string, StateVariableDef>;
|
|
1647
|
+
}
|
|
1648
|
+
/**
|
|
1649
|
+
* WHERE a variable declaration came from — its priority tier.
|
|
1650
|
+
* `component` (registerComponentStateVariable at component module scope) deliberately
|
|
1651
|
+
* OVERRIDES `init` (SDK init `state.variables`), deterministically and
|
|
1652
|
+
* regardless of module evaluation order. Same-tier re-declarations keep the
|
|
1653
|
+
* first definition. Runtime `set` values always beat declared defaults.
|
|
1654
|
+
*/
|
|
1655
|
+
type StateVariableTier = "init" | "component";
|
|
1656
|
+
type StateUnsubscribe = () => void;
|
|
1657
|
+
type StateUpdater<T = unknown> = T | ((prev: T | undefined) => T);
|
|
1658
|
+
|
|
1659
|
+
/**
|
|
1660
|
+
* Page-global shared state store — the "Bring Your Own State" (BYOS) core.
|
|
1661
|
+
*
|
|
1662
|
+
* Delegates reads/writes to the user's `getState`/`setState` when configured
|
|
1663
|
+
* (Redux, Zustand, plain object, anything), otherwise falls back to an
|
|
1664
|
+
* internal Map. Reactivity is per-key: `set("cart")` notifies ONLY listeners
|
|
1665
|
+
* subscribed to `"cart"`, so unrelated components never re-render.
|
|
1666
|
+
*
|
|
1667
|
+
* One instance per JS runtime via the globalThis registry slot (see
|
|
1668
|
+
* `singleton.ts`) — every surface (components, sections, templates, custom
|
|
1669
|
+
* code) reads and writes the same store.
|
|
1670
|
+
*
|
|
1671
|
+
* SSR: `set` is a no-op with a dev warning (a mutable process-wide store
|
|
1672
|
+
* would leak state across requests); `get` still delegates so a
|
|
1673
|
+
* server-appropriate `getState` (e.g. request-scoped values) works, falling
|
|
1674
|
+
* back to declared defaults.
|
|
1675
|
+
*/
|
|
1676
|
+
declare class StudioStateStore {
|
|
1677
|
+
private userConfig;
|
|
1678
|
+
private internal;
|
|
1679
|
+
private listeners;
|
|
1680
|
+
private variables;
|
|
1681
|
+
/** Priority tier each declaration came from (see StateVariableTier). */
|
|
1682
|
+
private variableTiers;
|
|
1683
|
+
/** Fired when the DECLARED variable set changes (declare/configure/reset). */
|
|
1684
|
+
private variableListeners;
|
|
1685
|
+
/** One bridge subscription per key into the user's own store. */
|
|
1686
|
+
private externalUnsubs;
|
|
1687
|
+
private warnedServerSet;
|
|
1688
|
+
/**
|
|
1689
|
+
* Wire the state backend + init-declared variables. Called once from SDK
|
|
1690
|
+
* init; calling again replaces the config (HMR-safe — variables merge,
|
|
1691
|
+
* they don't reset).
|
|
1692
|
+
*
|
|
1693
|
+
* Storage resolution (see StudioStateStorage):
|
|
1694
|
+
* - `storage: "custom"` → user's getState/setState (required).
|
|
1695
|
+
* - `storage: "local"` → built-in localStorage store.
|
|
1696
|
+
* - `storage: "session"` → built-in sessionStorage store.
|
|
1697
|
+
* - omitted → custom when getState+setState are provided,
|
|
1698
|
+
* otherwise the built-in SESSION store.
|
|
1699
|
+
*/
|
|
1700
|
+
configure(config: StudioStateConfig): void;
|
|
1701
|
+
/**
|
|
1702
|
+
* Open a single bridge subscription from the user's own store into this
|
|
1703
|
+
* store's per-key listeners, so mutations made OUTSIDE Studio propagate in.
|
|
1704
|
+
* Idempotent and safe to call from both `subscribe` (first listener) and
|
|
1705
|
+
* `configure` (backend arrived/changed after listeners already existed).
|
|
1706
|
+
*/
|
|
1707
|
+
private ensureExternalBridge;
|
|
1708
|
+
isConfigured(): boolean;
|
|
1709
|
+
/**
|
|
1710
|
+
* Register an author-bindable variable.
|
|
1711
|
+
*
|
|
1712
|
+
* Priority: a `component`-tier declaration (registerComponentStateVariable at component
|
|
1713
|
+
* module scope) OVERRIDES an `init`-tier one (SDK init `state.variables`)
|
|
1714
|
+
* for the same key — deterministically, whichever loads first. An init
|
|
1715
|
+
* declaration never overrides a component one; it only fills keys no
|
|
1716
|
+
* component declared. Same-tier re-declarations (module reload, repeated
|
|
1717
|
+
* imports) keep the first definition and dev-warn only when the type
|
|
1718
|
+
* conflicts. Runtime `set` values always beat declared defaults.
|
|
1719
|
+
*/
|
|
1720
|
+
declareVariable(key: string, def: StateVariableDef, tier?: StateVariableTier): void;
|
|
1721
|
+
/** All declared (author-bindable) variables. */
|
|
1722
|
+
getVariables(): Record<string, StateVariableDef>;
|
|
1723
|
+
/**
|
|
1724
|
+
* Subscribe to declared-variable-set changes. The SDK's Studio bridge uses
|
|
1725
|
+
* this to push the fresh values snapshot to the Data Picker — apps declare
|
|
1726
|
+
* variables from lazily-imported init code, typically AFTER the component
|
|
1727
|
+
* registry synced, so a one-shot pull at sync time reads an empty set.
|
|
1728
|
+
*/
|
|
1729
|
+
subscribeVariablesChanged(listener: () => void): StateUnsubscribe;
|
|
1730
|
+
private notifyVariablesChanged;
|
|
1731
|
+
isDeclared(key: string): boolean;
|
|
1732
|
+
/**
|
|
1733
|
+
* The declared default for a key, ignoring any live backend value. This is
|
|
1734
|
+
* the server / hydration baseline: SSR and the client's hydration render
|
|
1735
|
+
* must agree, so state-bound content renders the default on both and only
|
|
1736
|
+
* switches to a persisted/live value AFTER hydration.
|
|
1737
|
+
*/
|
|
1738
|
+
getDeclaredDefault<T = unknown>(key: string): T | undefined;
|
|
1739
|
+
/** Raw backing value with NO declared-default fallback (undefined if unset). */
|
|
1740
|
+
private readRaw;
|
|
1741
|
+
get<T = unknown>(key: string): T | undefined;
|
|
1742
|
+
set<T = unknown>(key: string, next: StateUpdater<T>): void;
|
|
1743
|
+
/**
|
|
1744
|
+
* Per-key subscription. Returns an unsubscribe. When the user supplied
|
|
1745
|
+
* their own `subscribe`, a single bridge per key is also registered so
|
|
1746
|
+
* store mutations made OUTSIDE Studio propagate into Studio listeners.
|
|
1747
|
+
*/
|
|
1748
|
+
subscribe(key: string, listener: () => void): StateUnsubscribe;
|
|
1749
|
+
private notify;
|
|
1750
|
+
/**
|
|
1751
|
+
* Soft reset for hosts that want per-page state on a client-side route
|
|
1752
|
+
* change (this is what the public `studioState.reset()` calls). Clears the
|
|
1753
|
+
* SDK-owned internal values and wakes every subscriber to re-read — but
|
|
1754
|
+
* deliberately KEEPS the wired backend, the declared variables, and all live
|
|
1755
|
+
* subscriptions. Tearing those down here (the previous behavior) disconnected
|
|
1756
|
+
* a configured custom store, wiped every declaration, and froze every still-
|
|
1757
|
+
* mounted `useStudioState`. For a full teardown (tests / HMR) use `resetAll`.
|
|
1758
|
+
*
|
|
1759
|
+
* A configured custom or web-storage backend owns its own values and is left
|
|
1760
|
+
* intact — the host resets its own store if it wants those cleared too.
|
|
1761
|
+
*/
|
|
1762
|
+
reset(): void;
|
|
1763
|
+
/**
|
|
1764
|
+
* Full teardown — internal values, declarations, config, listeners, and
|
|
1765
|
+
* external bridges. For tests and HMR (the singleton drop), NOT for
|
|
1766
|
+
* route-change resets (see `reset`).
|
|
1767
|
+
*/
|
|
1768
|
+
resetAll(): void;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
/**
|
|
1772
|
+
* Lazily create (or reuse) the page-global StudioStateStore in the SDK's
|
|
1773
|
+
* versioned globalThis slot. Same pattern as the component/design registries
|
|
1774
|
+
* — survives Next.js RSC/client module-graph splits so every surface talks
|
|
1775
|
+
* to the same store instance.
|
|
1776
|
+
*/
|
|
1777
|
+
declare function getStateStoreInstance(): StudioStateStore;
|
|
1778
|
+
/** Test-only: drop the singleton so the next access builds a fresh store. */
|
|
1779
|
+
declare function resetStateStoreInstance(): void;
|
|
1780
|
+
|
|
1781
|
+
/**
|
|
1782
|
+
* Declare an author-bindable state variable at component/section module
|
|
1783
|
+
* scope — the "component-declared" tier. Call at module load time (top of
|
|
1784
|
+
* the file, next to the component definition):
|
|
1785
|
+
*
|
|
1786
|
+
* ```ts
|
|
1787
|
+
* registerComponentStateVariable("cart:filter", { type: "string", defaultValue: "" });
|
|
1788
|
+
*
|
|
1789
|
+
* export function CartFilter() {
|
|
1790
|
+
* const [filter, setFilter] = useStudioState<string>("cart:filter");
|
|
1791
|
+
* ...
|
|
1792
|
+
* }
|
|
1793
|
+
* ```
|
|
1794
|
+
*
|
|
1795
|
+
* Declared variables appear for binding inside the existing External Data
|
|
1796
|
+
* source; undeclared keys stay code-only (ad-hoc tier).
|
|
1797
|
+
*
|
|
1798
|
+
* Priority: component-level declarations WIN over the same key declared
|
|
1799
|
+
* globally at init (`state.variables`) — deterministically, regardless of
|
|
1800
|
+
* which module evaluated first. The global declaration is used only for keys
|
|
1801
|
+
* no component declared. Runtime `set` values always beat declared defaults.
|
|
1802
|
+
*/
|
|
1803
|
+
declare function registerComponentStateVariable(key: string, options: StateVariableDef): void;
|
|
1804
|
+
/**
|
|
1805
|
+
* Imperative access to the shared state store — for custom user code outside
|
|
1806
|
+
* React (event handlers, analytics glue, business logic):
|
|
1807
|
+
*
|
|
1808
|
+
* ```ts
|
|
1809
|
+
* import { studioState } from "@contentstack/studio-react";
|
|
1810
|
+
*
|
|
1811
|
+
* studioState.set("cart:count", (prev) => (prev ?? 0) + 1);
|
|
1812
|
+
* const count = studioState.get<number>("cart:count");
|
|
1813
|
+
* const stop = studioState.subscribe("cart:count", () => console.log("changed"));
|
|
1814
|
+
* ```
|
|
1815
|
+
*
|
|
1816
|
+
* Same store instance the `useStudioState` hook and author bindings use —
|
|
1817
|
+
* one source of truth across components, sections, templates, and code.
|
|
1818
|
+
*/
|
|
1819
|
+
/**
|
|
1820
|
+
* Snapshot of every DECLARED state variable with its CURRENT value —
|
|
1821
|
+
* `[{ key, value }]`. This is what the Studio Data Picker lists under
|
|
1822
|
+
* Component Props so authors can bind the values the app made available
|
|
1823
|
+
* (init `state.variables`, `registerComponentStateVariable`) — e.g. `price → 2999`.
|
|
1824
|
+
*
|
|
1825
|
+
* Only declared variables are enumerable: BYOS user stores expose key-based
|
|
1826
|
+
* `getState` with no key listing, so ad-hoc (code-only) keys can't be swept.
|
|
1827
|
+
*/
|
|
1828
|
+
declare function getStudioStateSnapshot(): Array<{
|
|
1829
|
+
key: string;
|
|
1830
|
+
value: unknown;
|
|
1831
|
+
}>;
|
|
1832
|
+
/**
|
|
1833
|
+
* Subscribe to declared-variable-set changes on the page-global store —
|
|
1834
|
+
* passthrough for the Studio bridge (see StudioStateStore.subscribeVariablesChanged).
|
|
1835
|
+
*/
|
|
1836
|
+
declare function subscribeStudioStateVariablesChanged(listener: () => void): StateUnsubscribe;
|
|
1837
|
+
declare const studioState: {
|
|
1838
|
+
get<T = unknown>(key: string): T | undefined;
|
|
1839
|
+
set<T = unknown>(key: string, next: StateUpdater<T>): void;
|
|
1840
|
+
subscribe(key: string, listener: () => void): StateUnsubscribe;
|
|
1841
|
+
/** Clear all state — call on client-side route change if you want per-page state. */
|
|
1842
|
+
reset(): void;
|
|
1843
|
+
};
|
|
1844
|
+
/**
|
|
1845
|
+
* Declare a SET of variables at the INIT tier — same priority as SDK init
|
|
1846
|
+
* `state.variables`, so later component-level `registerComponentStateVariable` calls
|
|
1847
|
+
* still override them.
|
|
1848
|
+
*
|
|
1849
|
+
* Purpose: SSR hydration alignment. The server declares variables at module
|
|
1850
|
+
* scope (server init file), but apps typically run the CLIENT init from a
|
|
1851
|
+
* lazily-imported module — AFTER hydration. State-bound nodes then hydrate
|
|
1852
|
+
* against undeclared keys and mismatch the server HTML. Import a tiny module
|
|
1853
|
+
* that calls this at module scope (e.g. from _app) so declarations exist on
|
|
1854
|
+
* the client BEFORE hydration:
|
|
1855
|
+
*
|
|
1856
|
+
* ```ts
|
|
1857
|
+
* // lib/register-state-variables.ts — imported statically by _app
|
|
1858
|
+
* registerGlobalStateVariables(studioStateConfig.variables ?? {});
|
|
1859
|
+
* ```
|
|
1860
|
+
*/
|
|
1861
|
+
declare function registerGlobalStateVariables(variables: Record<string, StateVariableDef>): void;
|
|
1862
|
+
|
|
1863
|
+
/**
|
|
1864
|
+
* Context handed to every registered studio function — the same shared state
|
|
1865
|
+
* the `useStudioState` hook and author bindings use. Functions communicate
|
|
1866
|
+
* with components exclusively through this state: a `ctx.set` re-renders
|
|
1867
|
+
* every component bound to that key, wherever it lives.
|
|
1868
|
+
*/
|
|
1869
|
+
interface StudioFunctionCtx {
|
|
1870
|
+
get<T = unknown>(key: string): T | undefined;
|
|
1871
|
+
set<T = unknown>(key: string, next: StateUpdater<T>): void;
|
|
1872
|
+
subscribe(key: string, listener: () => void): StateUnsubscribe;
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* A user-registered custom function. `args` is the primary payload the caller
|
|
1876
|
+
* passed to `callStudioFunction` (e.g. `{ sku: "X1" }` from a button click).
|
|
1877
|
+
* Additional positional arguments — e.g. an action-prop callback invoked as
|
|
1878
|
+
* `onSelect(id, meta)` — are forwarded verbatim as `rest`, so nothing is
|
|
1879
|
+
* dropped between the component call and the function.
|
|
1880
|
+
*/
|
|
1881
|
+
type StudioFunction = (ctx: StudioFunctionCtx, args?: Record<string, unknown>, ...rest: unknown[]) => unknown | Promise<unknown>;
|
|
1882
|
+
/**
|
|
1883
|
+
* Subscribe to registry changes (functions added / reset). Used by the SDK's
|
|
1884
|
+
* Studio bridge to push the fresh name list to the Studio props panel whenever
|
|
1885
|
+
* the app registers functions — regardless of whether that happens before or
|
|
1886
|
+
* after the component registry sync.
|
|
1887
|
+
*/
|
|
1888
|
+
declare function subscribeStudioFunctionsChanged(listener: () => void): () => void;
|
|
1889
|
+
/**
|
|
1890
|
+
* Register named custom functions — the app's business logic that components
|
|
1891
|
+
* invoke by NAME. Call as many times as you like (e.g. one call per feature
|
|
1892
|
+
* module); registrations MERGE. Re-registering an existing name overwrites it
|
|
1893
|
+
* with a dev warning (supports HMR).
|
|
1894
|
+
*
|
|
1895
|
+
* ```ts
|
|
1896
|
+
* registerStudioFunctions({
|
|
1897
|
+
* "cart:add": (ctx, args) => {
|
|
1898
|
+
* ctx.set("cart:count", (prev) => (prev ?? 0) + 1);
|
|
1899
|
+
* ctx.set("cart:last_added", args?.sku ?? "");
|
|
1900
|
+
* },
|
|
1901
|
+
* "coupon:apply": (ctx, args) => {
|
|
1902
|
+
* const discounts = { SAVE10: 10, SAVE20: 20 };
|
|
1903
|
+
* ctx.set("checkout:discount", discounts[args?.code] ?? 0);
|
|
1904
|
+
* },
|
|
1905
|
+
* });
|
|
1906
|
+
* ```
|
|
1907
|
+
*/
|
|
1908
|
+
declare function registerStudioFunctions(functions: Record<string, StudioFunction>): void;
|
|
1909
|
+
/** Names of every registered function — for debugging / future picker UI. */
|
|
1910
|
+
declare function getStudioFunctionNames(): string[];
|
|
1911
|
+
/**
|
|
1912
|
+
* Invoke a registered function by name from ANY component or code.
|
|
1913
|
+
*
|
|
1914
|
+
* ```ts
|
|
1915
|
+
* <button onClick={() => callStudioFunction("cart:add", { sku })}>Add</button>
|
|
1916
|
+
* ```
|
|
1917
|
+
*
|
|
1918
|
+
* Never throws into the UI: a missing name warns and returns undefined; sync
|
|
1919
|
+
* throws and async rejections are caught and logged. The function receives
|
|
1920
|
+
* the shared-state ctx as its first argument.
|
|
1921
|
+
*/
|
|
1922
|
+
declare function callStudioFunction(name: string, ...args: unknown[]): unknown;
|
|
1923
|
+
/** Test-only: clear all registered functions. */
|
|
1924
|
+
declare function resetStudioFunctions(): void;
|
|
1925
|
+
|
|
1926
|
+
/**
|
|
1927
|
+
* Swap resolved `action` props (registered function NAMES saved from the
|
|
1928
|
+
* Studio props panel) for real callables before the props reach the
|
|
1929
|
+
* component. Runs in both renderers (live + canvas) right after
|
|
1930
|
+
* `retrievePropValue`, so ANY component — SDK basic or app-registered —
|
|
1931
|
+
* that declares a `{ type: "action" }` prop receives an invokable function:
|
|
1932
|
+
*
|
|
1933
|
+
* ```tsx
|
|
1934
|
+
* function Card({ onBuy }: { onBuy?: (...args: unknown[]) => unknown }) {
|
|
1935
|
+
* return <button onClick={() => onBuy?.({ sku: "X1" })}>Buy</button>;
|
|
1936
|
+
* }
|
|
1937
|
+
* ```
|
|
1938
|
+
*
|
|
1939
|
+
* An unset/empty selection resolves to `undefined` (component can feature-
|
|
1940
|
+
* detect); a missing function name is contained inside `callStudioFunction`
|
|
1941
|
+
* (warn, no crash). Non-action props pass through untouched.
|
|
1942
|
+
*/
|
|
1943
|
+
declare function wrapActionProps<T extends Record<string, unknown>>(componentProps: Props | undefined, resolvedProps: T): T;
|
|
1944
|
+
|
|
1505
1945
|
/**
|
|
1506
1946
|
* Shape of the slot we own on globalThis. Each field is lazily initialized by
|
|
1507
1947
|
* the corresponding `get*Instance()` helper; storing `null` keeps the slot
|
|
@@ -1511,6 +1951,8 @@ interface GlobalStudioStore {
|
|
|
1511
1951
|
componentRegistry: unknown | null;
|
|
1512
1952
|
designRegistry: unknown | null;
|
|
1513
1953
|
breakpointManager: unknown | null;
|
|
1954
|
+
stateStore: unknown | null;
|
|
1955
|
+
functionRegistry: unknown | null;
|
|
1514
1956
|
}
|
|
1515
1957
|
/**
|
|
1516
1958
|
* Returns the SDK's versioned slot on globalThis, creating it on first call.
|
|
@@ -1528,5 +1970,5 @@ declare function getGlobalStudioStore(): GlobalStudioStore;
|
|
|
1528
1970
|
*/
|
|
1529
1971
|
declare function resetGlobalStudioStore(): void;
|
|
1530
1972
|
|
|
1531
|
-
export { ALLOWED_DESIGN_VALUES_LEVELS, BUILT_IN_COMPONENTS, BreakpointRegistry, ComponentRegistry, DATA_SOURCES, DATA_SOURCES_PREFIX, DEFAULT_DESIGN_TOKENS, DesignRegistry, INTERNAL_COMPONENTS_NAMES, INTERNAL_COMPONENT_SECTIONS, INTERNAL_SECTIONS, JSONRTERegistry, STYLE_SECTIONS_OPTIONS, STYLE_SECTION_CATEGORIES, SYSTEM_COMPONENTS, clearReportedBindingErrorsForNode, convertBindingPath, getBindingString, getComponentRegistryInstance, getCslpPath, getCslpTag, getDataType, getDefaultPropStaticValue, getDesignClassesNames, getDesignRegistryInstance, getFlattenedData, getGlobalStudioStore, getPlaceHolderComponent, getRepeaterBinding, getRepeaterContextPath, getSectionUIDFromNode, getSlotData,
|
|
1532
|
-
export type { AllowedDesignValues, AllowedDesignValuesLevel, AnyProp, ArrayProp, BooleanProp, Breakpoint, BreakpointInput, CSBindingPath, CSDataSources, ChoiceProp, ComponentRegistryOptions, ComponentType, ComposableStudioData, ContentstackBindingValue, CssVariablesToDesignTokens, CssVariablesToValue, DataSourceItem, DataSources, DateStringProp, DefaultBreakpoint, DesignClassValue, DesignClasses, DesignClassesInput, DesignClassesNames, DesignTokenCssVariable, DesignTokens, DesignTokensInput, DesignTokensInputKeys, DesignTokensOptions, DesignTokensOptionsInput, GetSlots, GetSlotsParams, GlobalDesignTokens, GlobalStudioStore, HrefProp, ICSEntryReference, ImageUrlProp, InternalComponentRegistryOptions, JSONRTERegistryOptions, JsonRTEProp, LayerIcon, LengthToken, MultiChoiceProp, NodeProps, NumberProp, ObjectInput, ObjectProp, PlaceHolders, PlainTextProp, PreProcessedBreakpoint, PreProcessedDesignTokenInput, PropBase, PropInput, PropType, PropTypeOfNoOptionsRequired, PropValidator, Props, PropsWithNoOptionsRequired, RawStaticValue, RegisterComponentOptionsInput, RegisterComponentSchema, RegisterComponentSchemaInput, RegisterInternalComponentOptionsInput, Registry, RepeaterBindingValue, SectionDesignTokens, SectionScopedDataSources, SingleChoiceProp, SlotProp, StaticValue, StaticValueItem, StaticValueUid, StringProp, StudioSpecData, StyleGroupOptions, StyleSectionCategoriesOptions, StyleSectionOptions, StyleSections, TemplateBindingValue };
|
|
1973
|
+
export { ALLOWED_DESIGN_VALUES_LEVELS, BUILT_IN_COMPONENTS, BreakpointRegistry, ComponentRegistry, DATA_SOURCES, DATA_SOURCES_PREFIX, DEFAULT_DESIGN_TOKENS, DesignRegistry, INTERNAL_COMPONENTS_NAMES, INTERNAL_COMPONENT_SECTIONS, INTERNAL_SECTIONS, JSONRTERegistry, STYLE_SECTIONS_OPTIONS, STYLE_SECTION_CATEGORIES, SYSTEM_COMPONENTS, StudioStateStore, callStudioFunction, clearReportedBindingErrorsForNode, collectStateBindingKeys, convertBindingPath, getBindingString, getComponentRegistryInstance, getCslpPath, getCslpTag, getDataType, getDefaultPropStaticValue, getDesignClassesNames, getDesignRegistryInstance, getFlattenedData, getGlobalStudioStore, getNodeBoundFunctionName, getPlaceHolderComponent, getRepeaterBinding, getRepeaterContextPath, getSectionUIDFromNode, getSlotData, getStateDefaultsFor, getStateStoreInstance, getStateValuesFor, getStudioFunctionNames, getStudioStateSnapshot, hasComponentRegistryInstance, hasDesignRegistryInstance, isDataMatchingPropType, isKnownType, normalizeSingleSelectChoiceValue, registerComponentStateVariable, registerGlobalStateVariables, registerStudioFunctions, resetComponentRegistryInstance, resetDesignRegistryInstance, resetGlobalStudioStore, resetStateStoreInstance, resetStudioFunctions, resolveMetadataBindings, retrievePropValue, studioState, subscribeStudioFunctionsChanged, subscribeStudioStateVariablesChanged, wrapActionProps };
|
|
1974
|
+
export type { ActionProp, AllowedDesignValues, AllowedDesignValuesLevel, AnyProp, ArrayProp, BooleanProp, Breakpoint, BreakpointInput, CSBindingPath, CSDataSources, ChoiceProp, ComponentRegistryOptions, ComponentType, ComposableStudioData, ContentstackBindingValue, CssVariablesToDesignTokens, CssVariablesToValue, DataSourceItem, DataSources, DateStringProp, DefaultBreakpoint, DesignClassValue, DesignClasses, DesignClassesInput, DesignClassesNames, DesignTokenCssVariable, DesignTokens, DesignTokensInput, DesignTokensInputKeys, DesignTokensOptions, DesignTokensOptionsInput, GetSlots, GetSlotsParams, GlobalDesignTokens, GlobalStudioStore, HrefProp, ICSEntryReference, ImageUrlProp, InternalComponentRegistryOptions, JSONRTERegistryOptions, JsonRTEProp, LayerIcon, LengthToken, MultiChoiceProp, NodeProps, NumberProp, ObjectInput, ObjectProp, PlaceHolders, PlainTextProp, PreProcessedBreakpoint, PreProcessedDesignTokenInput, PropBase, PropInput, PropType, PropTypeOfNoOptionsRequired, PropValidator, Props, PropsWithNoOptionsRequired, RawStaticValue, RegisterComponentOptionsInput, RegisterComponentSchema, RegisterComponentSchemaInput, RegisterInternalComponentOptionsInput, Registry, RepeaterBindingValue, SectionDesignTokens, SectionScopedDataSources, SingleChoiceProp, SlotProp, StateUnsubscribe, StateUpdater, StateVariableDef, StateVariableTier, StateVariableType, StaticValue, StaticValueItem, StaticValueUid, StringProp, StudioFunction, StudioFunctionCtx, StudioSpecData, StudioStateConfig, StudioStateStorage, StyleGroupOptions, StyleSectionCategoriesOptions, StyleSectionOptions, StyleSections, TemplateBindingValue };
|