@contentstack/studio-registry 2.0.1 → 2.1.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 +670 -11
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/common/global-store.js.map +1 -1
- package/dist/esm/component-registry/built-in-components-loader.js +36 -0
- package/dist/esm/component-registry/built-in-components-loader.js.map +1 -0
- package/dist/esm/component-registry/registry.constant.js +3 -0
- package/dist/esm/component-registry/registry.constant.js.map +1 -1
- package/dist/esm/component-registry/registry.js +6 -0
- package/dist/esm/component-registry/registry.js.map +1 -1
- package/dist/esm/data-binder/first-of-type.js +86 -0
- package/dist/esm/data-binder/first-of-type.js.map +1 -0
- package/dist/esm/data-binder/handle-binding-map.util.js +3 -0
- package/dist/esm/data-binder/handle-binding-map.util.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.js +54 -8
- package/dist/esm/data-binder/retrieve-data.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.util.js +11 -2
- package/dist/esm/data-binder/retrieve-data.util.js.map +1 -1
- package/dist/esm/data-binder/section-exposed-bindings.js +98 -0
- package/dist/esm/data-binder/section-exposed-bindings.js.map +1 -0
- package/dist/esm/data-binder/section-exposed-design-props.js +243 -0
- package/dist/esm/data-binder/section-exposed-design-props.js.map +1 -0
- package/dist/esm/data-binder/state-binding.util.js +50 -1
- package/dist/esm/data-binder/state-binding.util.js.map +1 -1
- package/dist/esm/design-registry/design-registry.js +44 -1
- package/dist/esm/design-registry/design-registry.js.map +1 -1
- package/dist/esm/index.d.ts +313 -9
- package/dist/esm/index.js +6 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +5 -5
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodePropType, NodePropTypes, Node, BindingType, NodePropStaticValueTypes, BindableNodePropType, NodePropsWithSlot } from '@contentstack/studio-internal';
|
|
1
|
+
import { NodePropType, NodePropTypes, Node, BindingType, NodePropStaticValueTypes, BindableNodePropType, NodePropsWithSlot, NodeStyles } from '@contentstack/studio-internal';
|
|
2
2
|
import { Properties } from 'csstype';
|
|
3
3
|
import { IJsonToHtmlOptions } from '@contentstack/json-rte-serializer';
|
|
4
4
|
import * as React from 'react';
|
|
@@ -276,6 +276,7 @@ declare const INTERNAL_COMPONENTS_NAMES: {
|
|
|
276
276
|
readonly SECTION_SLOT: "section-slot";
|
|
277
277
|
readonly HTML_ELEMENT: "html-element";
|
|
278
278
|
readonly STYLE_SHEET: "style-sheet";
|
|
279
|
+
readonly RESOLUTION_FAILURE: "studio-resolution-failure";
|
|
279
280
|
};
|
|
280
281
|
/**
|
|
281
282
|
* System components are protected components that are not intended to be modified or removed.
|
|
@@ -314,13 +315,18 @@ interface RegisterComponentSchemaInput<C = unknown> {
|
|
|
314
315
|
component: C;
|
|
315
316
|
props?: Props;
|
|
316
317
|
/**
|
|
317
|
-
*
|
|
318
|
-
* You must pass the `StudioAttributes` to your component to
|
|
319
|
-
* handle the editing of the component in the builder.
|
|
318
|
+
* Which element carries Studio's attributes (selection, outline, edit tags).
|
|
320
319
|
*
|
|
321
|
-
*
|
|
320
|
+
* - `true` (default): Studio wraps the component in a `<div>` that carries them.
|
|
321
|
+
* - A tag name, such as `"li"` or `"article"`: Studio wraps it in that tag instead.
|
|
322
|
+
* - `false`: no wrapper. Studio passes `studioAttributes`, which the component
|
|
323
|
+
* must spread on its root element.
|
|
322
324
|
*
|
|
323
|
-
*
|
|
325
|
+
* Use `false` when the root is one element you control, and always for
|
|
326
|
+
* components placed in a grid or flex container: a wrapper is a real element
|
|
327
|
+
* that the container lays out instead of the component.
|
|
328
|
+
*
|
|
329
|
+
* @default true
|
|
324
330
|
*/
|
|
325
331
|
wrap?: boolean | string;
|
|
326
332
|
/**
|
|
@@ -658,6 +664,12 @@ interface GlobalStudioStore {
|
|
|
658
664
|
breakpointManager: unknown | null;
|
|
659
665
|
stateStore: unknown | null;
|
|
660
666
|
functionRegistry: unknown | null;
|
|
667
|
+
/**
|
|
668
|
+
* Registers the built-in components when called (see
|
|
669
|
+
* `component-registry/built-in-components-loader.ts`). Optional: a slot an
|
|
670
|
+
* older SDK copy created has no such field.
|
|
671
|
+
*/
|
|
672
|
+
builtInComponentsLoader?: (() => unknown) | null;
|
|
661
673
|
}
|
|
662
674
|
/**
|
|
663
675
|
* Returns the SDK's versioned slot on globalThis, creating it on first call.
|
|
@@ -739,6 +751,30 @@ declare function resetComponentRegistryInstance(graph?: StudioGraph): void;
|
|
|
739
751
|
*/
|
|
740
752
|
declare function hasComponentRegistryInstance(graph?: StudioGraph): boolean;
|
|
741
753
|
|
|
754
|
+
/**
|
|
755
|
+
* How code that reads the registry before anything has rendered gets the
|
|
756
|
+
* built-in components registered.
|
|
757
|
+
*
|
|
758
|
+
* `@contentstack/studio-react` used to register the built-ins when it was
|
|
759
|
+
* imported. That made every import of it — one hook in a component file — carry
|
|
760
|
+
* the registry, every built-in and the client SDK. It now registers them when
|
|
761
|
+
* they are first needed: the renderer and `registerComponents` do it directly,
|
|
762
|
+
* and for everything else the package root leaves a loader here.
|
|
763
|
+
*
|
|
764
|
+
* The one caller that needs the loader is the composition fetch in the browser,
|
|
765
|
+
* which checks the registry for every component a composition uses and can run
|
|
766
|
+
* before the renderer has loaded. It lives in `studio-client`, which cannot
|
|
767
|
+
* import `studio-react`; this slot is how the two meet.
|
|
768
|
+
*/
|
|
769
|
+
declare function setBuiltInComponentsLoader(loader: () => unknown): void;
|
|
770
|
+
/**
|
|
771
|
+
* Runs the loader the renderer package left, if any.
|
|
772
|
+
*
|
|
773
|
+
* @returns whether a loader ran. `false` means no renderer package is present
|
|
774
|
+
* to provide built-ins, which is worth reporting as such.
|
|
775
|
+
*/
|
|
776
|
+
declare function loadBuiltInComponents(): Promise<boolean>;
|
|
777
|
+
|
|
742
778
|
type DesignTokensInput = Partial<SectionDesignTokens> & Partial<GlobalDesignTokens>;
|
|
743
779
|
type DesignTokensInputKeys = keyof DesignTokensInput;
|
|
744
780
|
type GlobalDesignTokens = {
|
|
@@ -878,6 +914,17 @@ interface CssVariablesToDesignTokens {
|
|
|
878
914
|
type: "preset" | "token";
|
|
879
915
|
};
|
|
880
916
|
}
|
|
917
|
+
/**
|
|
918
|
+
* Where a registered token comes from: `default` is the SDK's own default,
|
|
919
|
+
* left as shipped; `overridden` is a default the app redefines; `app` is a
|
|
920
|
+
* token only the app defines. Studio's design-system sync uses it so it
|
|
921
|
+
* never has to guess against its own copy of the defaults, which can belong
|
|
922
|
+
* to a different SDK version.
|
|
923
|
+
*/
|
|
924
|
+
type DesignTokenOrigin = "default" | "overridden" | "app";
|
|
925
|
+
interface CssVariablesToOrigin {
|
|
926
|
+
[cssVariable: string]: DesignTokenOrigin;
|
|
927
|
+
}
|
|
881
928
|
interface DesignTokens<T extends DesignTokensInput = Record<string, any>> {
|
|
882
929
|
size: {
|
|
883
930
|
width: ExtractDesignTokenNames<DeepNonNullable<T>["size"]["tokens"], DesignTokenCssVariable> & ExtractDesignTokenNames<DeepNonNullable<T>["size"]["width"], DesignTokenCssVariable>;
|
|
@@ -990,6 +1037,7 @@ declare class DesignRegistry {
|
|
|
990
1037
|
private classes;
|
|
991
1038
|
private tokens;
|
|
992
1039
|
private cssVariables;
|
|
1040
|
+
private tokenOrigins;
|
|
993
1041
|
private options;
|
|
994
1042
|
cssVariablesToDesignTokens: CssVariablesToDesignTokens;
|
|
995
1043
|
constructor();
|
|
@@ -998,12 +1046,17 @@ declare class DesignRegistry {
|
|
|
998
1046
|
getDesignTokenOptions(): DesignTokensOptions;
|
|
999
1047
|
getDesignTokenCssVariables(): CssVariablesToValue;
|
|
1000
1048
|
getCssVariablesToDesignTokens(): CssVariablesToDesignTokens;
|
|
1049
|
+
/** Where each registered token comes from; see {@link CssVariablesToOrigin}. */
|
|
1050
|
+
getDesignTokenOrigins(): CssVariablesToOrigin;
|
|
1001
1051
|
/**
|
|
1002
1052
|
* If the design tokens are already processed, we can use this method to update the design tokens
|
|
1003
1053
|
* without processing them again.
|
|
1004
1054
|
* @param tokens The processed design tokens
|
|
1055
|
+
* @param cssVariables The token values. Without them the registry keeps
|
|
1056
|
+
* answering {@link getDesignTokenCssVariables} with the defaults' values.
|
|
1057
|
+
* @param tokenOrigins Where each token comes from, when the sender knows.
|
|
1005
1058
|
*/
|
|
1006
|
-
updateDesignTokens(tokens: DesignTokens, cssVariablesToDesignTokens: CssVariablesToDesignTokens, options: DesignTokensOptions): void;
|
|
1059
|
+
updateDesignTokens(tokens: DesignTokens, cssVariablesToDesignTokens: CssVariablesToDesignTokens, options: DesignTokensOptions, cssVariables?: CssVariablesToValue, tokenOrigins?: CssVariablesToOrigin): void;
|
|
1007
1060
|
clearDesignTokens(): void;
|
|
1008
1061
|
registerClasses<C extends DesignClassesInput[]>(classes: C): DesignClassesNames<C>;
|
|
1009
1062
|
getClasses(): DesignClasses[];
|
|
@@ -1577,6 +1630,11 @@ declare function getSlotData<T>({ nodeProps, field, node, getSlots, }: GetSlotDa
|
|
|
1577
1630
|
declare function getPlaceHolderComponent<T>(placeholders: PlaceHolders<T>, prop: PropInput, type: BindableNodePropType): any;
|
|
1578
1631
|
|
|
1579
1632
|
declare const getBindingString: (binding: BindingType) => string;
|
|
1633
|
+
/**
|
|
1634
|
+
* The binding's data path with any first-of-type segment resolved against
|
|
1635
|
+
* `data` (see `first-of-type.ts`): the path every value read and edit tag uses.
|
|
1636
|
+
*/
|
|
1637
|
+
declare const getResolvedBindingString: (binding: BindingType, data: unknown) => string;
|
|
1580
1638
|
declare const convertBindingPath: (bindingType: string, path: string) => string | string[];
|
|
1581
1639
|
declare const getFlattenedData: (data: any) => any;
|
|
1582
1640
|
/**
|
|
@@ -1603,11 +1661,69 @@ declare const getCslpTag: ({ bindedField, data, }: {
|
|
|
1603
1661
|
data: ComposableStudioData;
|
|
1604
1662
|
}) => any;
|
|
1605
1663
|
|
|
1664
|
+
/**
|
|
1665
|
+
* First-of-type binding (COMS-2484).
|
|
1666
|
+
*
|
|
1667
|
+
* A binding path segment `$first:<type>` stands where a list index would: it
|
|
1668
|
+
* means "the first element of this list whose type is <type>". Studio writes
|
|
1669
|
+
* it for a pick under a block type or content type the preview data has no
|
|
1670
|
+
* element of, so the binding reads that type's first element once one exists.
|
|
1671
|
+
*
|
|
1672
|
+
* - Modular blocks: `modular_blocks.$first:block2.block2.caption` — the type
|
|
1673
|
+
* is the block's key. The block key stays after the segment, as it does
|
|
1674
|
+
* after an index.
|
|
1675
|
+
* - References: `reference.$first:blog.title` — the type is the entry's
|
|
1676
|
+
* `_content_type_uid`.
|
|
1677
|
+
*
|
|
1678
|
+
* Before a path is read, `resolveFirstOfTypePath` swaps every such segment for
|
|
1679
|
+
* the index of the first matching element in `data`. Everything downstream
|
|
1680
|
+
* (lodash `get`, edit tags, type checks) then sees an ordinary path. With no
|
|
1681
|
+
* matching element the path is returned as it is: it reads as missing.
|
|
1682
|
+
*/
|
|
1683
|
+
declare const FIRST_OF_TYPE_PREFIX = "$first:";
|
|
1684
|
+
/** The type uid a `$first:<type>` segment names, or undefined for any other segment. */
|
|
1685
|
+
declare const parseFirstOfTypeSegment: (segment: string) => string | undefined;
|
|
1686
|
+
/** Whether `path` holds a `$first:<type>` segment. */
|
|
1687
|
+
declare const hasFirstOfTypeSegment: (path: unknown) => path is string;
|
|
1688
|
+
/**
|
|
1689
|
+
* A list element's type: a reference entry's `_content_type_uid`, or a
|
|
1690
|
+
* modular block element's single block key (edit tags and metadata aside).
|
|
1691
|
+
*/
|
|
1692
|
+
declare const getListElementType: (element: unknown) => string | undefined;
|
|
1693
|
+
/**
|
|
1694
|
+
* `path` with every `$first:<type>` segment swapped for the index of the first
|
|
1695
|
+
* element of that type in `data`, or `path` unchanged when it has none or no
|
|
1696
|
+
* element matches.
|
|
1697
|
+
*/
|
|
1698
|
+
declare function resolveFirstOfTypePath(data: unknown, path: string): string;
|
|
1699
|
+
/** A path for reading schemas or fetch fields: `$first:<type>` segments dropped, as indexes are. */
|
|
1700
|
+
declare const withoutFirstOfTypeSegments: (path: string) => string;
|
|
1701
|
+
|
|
1606
1702
|
declare function collectStateBindingKeys(node: (Pick<Node, "props"> & {
|
|
1607
1703
|
metadata?: {
|
|
1608
1704
|
bindings?: Record<string, unknown>;
|
|
1609
1705
|
};
|
|
1610
1706
|
}) | undefined | null): string[];
|
|
1707
|
+
/**
|
|
1708
|
+
* The keys a node binds as Studio state (`source: "state"`, written when the
|
|
1709
|
+
* author picks a State Variable) that are not declared in this process yet.
|
|
1710
|
+
* Only tagged bindings count: an untagged `component_props` key may as well be
|
|
1711
|
+
* a function the app registers later, or plain data.
|
|
1712
|
+
*/
|
|
1713
|
+
declare function getUndeclaredStateBindingKeys(node: (Pick<Node, "props"> & {
|
|
1714
|
+
metadata?: {
|
|
1715
|
+
bindings?: Record<string, unknown>;
|
|
1716
|
+
};
|
|
1717
|
+
}) | undefined | null): string[];
|
|
1718
|
+
/**
|
|
1719
|
+
* Development aid, for server renders: warns once per key when a node bound to
|
|
1720
|
+
* a Studio state variable renders before the app declared that variable. The
|
|
1721
|
+
* server then renders the binding's fallback, and when the browser declares
|
|
1722
|
+
* the variable before hydrating, hydration finds the declared default instead
|
|
1723
|
+
* and reports a mismatch. Fix: declare state where every render sees it first
|
|
1724
|
+
* — `registerGlobalStateVariables` in a module the layout imports.
|
|
1725
|
+
*/
|
|
1726
|
+
declare function warnUndeclaredStateBindings(node: Parameters<typeof getUndeclaredStateBindingKeys>[0]): void;
|
|
1611
1727
|
/**
|
|
1612
1728
|
* Snapshot of the given declared state keys — `{ key: currentValue }` —
|
|
1613
1729
|
* merged by the renderer into `data.component_props` before prop resolution
|
|
@@ -1648,6 +1764,187 @@ declare function getNodeBoundFunctionName(node: (Pick<Node, "props"> & {
|
|
|
1648
1764
|
};
|
|
1649
1765
|
}) | undefined | null): string | undefined;
|
|
1650
1766
|
|
|
1767
|
+
/**
|
|
1768
|
+
* Returns true when a section exposed prop's expose-time binding can only be
|
|
1769
|
+
* resolved INSIDE the section's own render scope — i.e. the per-iteration
|
|
1770
|
+
* Repeater item context (`dataSources.repeater.<uid>.context...`).
|
|
1771
|
+
*
|
|
1772
|
+
* Such bindings cannot be resolved at the page level, where the exposed-prop
|
|
1773
|
+
* OVERRIDE value is computed (the page data context has no `dataSources.repeater`
|
|
1774
|
+
* — that slice is injected at render time by the Repeater component, one entry
|
|
1775
|
+
* per iteration). An exposed prop bound this way is therefore NOT page-
|
|
1776
|
+
* overridable: it represents a different value for every repeater item, which a
|
|
1777
|
+
* single page-level override could never express.
|
|
1778
|
+
*
|
|
1779
|
+
* The exposed-prop override mechanism makes the page node's binding the SOLE
|
|
1780
|
+
* source of truth and applies it by KEY PRESENCE (so a cleared prop renders
|
|
1781
|
+
* empty instead of falling back to the section's authored binding). For a
|
|
1782
|
+
* repeater-context prop that rule backfires: the page-level override resolves to
|
|
1783
|
+
* `undefined`, and applying it blanks the field instead of letting the internal
|
|
1784
|
+
* Repeater binding resolve. Callers use this guard to SKIP such props from the
|
|
1785
|
+
* overrides map so retrievePropValue falls through to the node's own binding.
|
|
1786
|
+
*/
|
|
1787
|
+
declare function isSectionInternalExposedBinding(bindingAtExposeTime: unknown): boolean;
|
|
1788
|
+
/**
|
|
1789
|
+
* The `repeaterUID` a `repeater` binding reads (`binding.value.repeaterUID`), or
|
|
1790
|
+
* undefined for any other binding / malformed input. Never throws.
|
|
1791
|
+
*/
|
|
1792
|
+
declare function getRepeaterBindingUID(binding: unknown): string | undefined;
|
|
1793
|
+
/**
|
|
1794
|
+
* Decides whether an exposed prop's page-level override should be SKIPPED (so
|
|
1795
|
+
* retrievePropValue falls through to the internal node's own binding) given its
|
|
1796
|
+
* expose-time binding and the page composer's LIVE binding for it (its type and,
|
|
1797
|
+
* for a `repeater` binding, the Repeater it reads).
|
|
1798
|
+
*
|
|
1799
|
+
* Shared by every renderer (client SectionComposition / SectionCompositionProvider
|
|
1800
|
+
* and the RSC entry) so server and client make the same call.
|
|
1801
|
+
*
|
|
1802
|
+
* The override VALUE can't drive this decision for repeater-context props: at
|
|
1803
|
+
* page level a repeater binding resolves to a placeholder (not undefined), so an
|
|
1804
|
+
* untouched seed looks identical to a real value. The live binding can:
|
|
1805
|
+
*
|
|
1806
|
+
* - auto-seeded → untouched; SKIP so the section's own binding wins.
|
|
1807
|
+
* - no live binding → nothing to override with; SKIP.
|
|
1808
|
+
* - expose-time NOT repeater → never skip (apply-by-key-presence preserved, so a
|
|
1809
|
+
* cleared template/contentstack/static prop still renders empty).
|
|
1810
|
+
* - expose-time repeater + live type page-resolvable (template/contentstack/…) →
|
|
1811
|
+
* the composer rebound it; APPLY the override.
|
|
1812
|
+
* - expose-time repeater + live `repeater` binding → decided by WHICH Repeater it
|
|
1813
|
+
* reads. An untouched pre-`autoSeeded` copy of the expose-time binding reads
|
|
1814
|
+
* the Repeater INSIDE the section (same `repeaterUID`) → SKIP. A real override
|
|
1815
|
+
* bound to a Repeater on the page/Template around the placed section reads a
|
|
1816
|
+
* different `repeaterUID` → APPLY. When either `repeaterUID` is unknown the
|
|
1817
|
+
* data can't tell them apart, so keep the old type-only behaviour (SKIP).
|
|
1818
|
+
*/
|
|
1819
|
+
declare function shouldSkipExposedOverride(bindingAtExposeTime: unknown, liveBindingType: string | undefined, autoSeeded: boolean | undefined, liveRepeaterUID?: string): boolean;
|
|
1820
|
+
|
|
1821
|
+
/**
|
|
1822
|
+
* Exposed design props (docs/adr/0004). A Section can expose a Design prop
|
|
1823
|
+
* (ADR 0003) of one of its inner nodes so each Template placement sets its own
|
|
1824
|
+
* per-breakpoint values. The placement stores them in the PLACED node's
|
|
1825
|
+
* `styles`, under a group keyed by the exposed prop's uid, with the real CSS
|
|
1826
|
+
* property as the declaration key:
|
|
1827
|
+
*
|
|
1828
|
+
* placed.styles[ep.uid].responsiveStyles[bp][ep.propKey] = <css value>
|
|
1829
|
+
*
|
|
1830
|
+
* The renderers turn that into a per-inner-node override map carried on
|
|
1831
|
+
* `dataSources[SECTION_EXPOSED_STYLE_OVERRIDES_KEY]` (next to
|
|
1832
|
+
* `section_exposed_overrides`), and merge it per breakpoint into a CLONE of the
|
|
1833
|
+
* inner node's styles right before `handleNodeStyles`. Every helper here is
|
|
1834
|
+
* shared by the client renderer, the RSC entry, the editor canvas and SSR style
|
|
1835
|
+
* extraction, so they all make the same call.
|
|
1836
|
+
*/
|
|
1837
|
+
/** dataSources key carrying {@link SectionExposedStyleOverrides} into a section subtree. */
|
|
1838
|
+
declare const SECTION_EXPOSED_STYLE_OVERRIDES_KEY = "section_exposed_style_overrides";
|
|
1839
|
+
/**
|
|
1840
|
+
* Internal prop a renderer hands a placed section's wrapper component: the
|
|
1841
|
+
* placed node's resolved style groups other than `default` (the raw material
|
|
1842
|
+
* the wrapper builds {@link SectionExposedStyleOverrides} from). Never a DOM
|
|
1843
|
+
* attribute.
|
|
1844
|
+
*/
|
|
1845
|
+
declare const SECTION_EXPOSED_STYLES_PROP = "section_exposed_styles";
|
|
1846
|
+
/** A `sectionExposedProps[]` entry in a Section's `ui.metadata`. */
|
|
1847
|
+
interface SectionExposedPropDefinition {
|
|
1848
|
+
uid: string;
|
|
1849
|
+
nodeUid: string;
|
|
1850
|
+
propKey: string;
|
|
1851
|
+
displayName?: string;
|
|
1852
|
+
propType?: string;
|
|
1853
|
+
bindingAtExposeTime?: unknown;
|
|
1854
|
+
/**
|
|
1855
|
+
* Hint written by Studio: the exposed prop is a Design prop. The inner
|
|
1856
|
+
* component's registration is the truth; this flag is only read when that
|
|
1857
|
+
* registration can't be found.
|
|
1858
|
+
*/
|
|
1859
|
+
design?: boolean;
|
|
1860
|
+
}
|
|
1861
|
+
/** Per-breakpoint declarations for one design prop: `{ [bp]: { [cssKey]: value } }`. */
|
|
1862
|
+
type ExposedStyleBreakpoints = Record<string, Record<string, unknown>>;
|
|
1863
|
+
/** `{ [innerNodeUid]: { [propKey]: ExposedStyleBreakpoints } }` */
|
|
1864
|
+
type SectionExposedStyleOverrides = Record<string, Record<string, ExposedStyleBreakpoints>>;
|
|
1865
|
+
/** The part of a component registry the helpers need. */
|
|
1866
|
+
interface ExposedPropRegistryLike {
|
|
1867
|
+
getComponentByNode(node: Node, suppressError?: boolean): {
|
|
1868
|
+
props?: Record<string, unknown>;
|
|
1869
|
+
metadata?: {
|
|
1870
|
+
type?: string;
|
|
1871
|
+
} | Record<string, unknown>;
|
|
1872
|
+
} | undefined;
|
|
1873
|
+
}
|
|
1874
|
+
/** Reads `sectionExposedProps` from a section's ui (tolerates a missing/encoded ui). */
|
|
1875
|
+
declare function getSectionExposedPropDefinitions(sectionUi: unknown): SectionExposedPropDefinition[];
|
|
1876
|
+
/** Indexes every node of a section's ui tree (through all slots) by uid. */
|
|
1877
|
+
declare function indexSectionNodes(sectionUi: unknown): Map<string, Node>;
|
|
1878
|
+
/**
|
|
1879
|
+
* Is this exposed prop a Design prop? The inner component's registration is
|
|
1880
|
+
* the truth: `propKey` registered with `design: true` on the component at
|
|
1881
|
+
* `nodeUid`. Only when that registration can't be found (no node, no
|
|
1882
|
+
* registry, component or prop not registered) does the entry's `design` flag
|
|
1883
|
+
* decide — so a legacy entry written without the flag still counts as design.
|
|
1884
|
+
*/
|
|
1885
|
+
declare function isExposedDesignProp(ep: SectionExposedPropDefinition, innerNode: Node | undefined, registry: ExposedPropRegistryLike | undefined): boolean;
|
|
1886
|
+
/**
|
|
1887
|
+
* Splits a section's exposed props into ordinary props (`propDefs`, which ride
|
|
1888
|
+
* `section_exposed_overrides`) and design props (`designDefs`, which ride
|
|
1889
|
+
* {@link SECTION_EXPOSED_STYLE_OVERRIDES_KEY}). One walk of the section ui.
|
|
1890
|
+
*/
|
|
1891
|
+
declare function partitionSectionExposedProps<T extends SectionExposedPropDefinition>(defs: T[], sectionUi: unknown, registry: ExposedPropRegistryLike | undefined): {
|
|
1892
|
+
propDefs: T[];
|
|
1893
|
+
designDefs: T[];
|
|
1894
|
+
};
|
|
1895
|
+
/** A placed section node (by node type, or by its registration's metadata). */
|
|
1896
|
+
declare function isSectionCompositionNode(node: Pick<Node, "type"> | undefined, componentOptions?: {
|
|
1897
|
+
metadata?: {
|
|
1898
|
+
type?: string;
|
|
1899
|
+
} | Record<string, unknown>;
|
|
1900
|
+
}): boolean;
|
|
1901
|
+
/**
|
|
1902
|
+
* A placed section's own styles as they may become classes: the `default`
|
|
1903
|
+
* group only. Its other groups are exposed-design-prop values for the inner
|
|
1904
|
+
* nodes and must never reach the wrapper as class props or DOM attributes.
|
|
1905
|
+
*/
|
|
1906
|
+
declare function getSectionCompositionOwnStyles(styles: NodeStyles | undefined): NodeStyles;
|
|
1907
|
+
/**
|
|
1908
|
+
* Snapshot of a placed section's non-`default` style groups' responsive
|
|
1909
|
+
* styles (copied per breakpoint, so a later in-place binding resolution on the
|
|
1910
|
+
* node can't change a value a memo already compared). `undefined` when none.
|
|
1911
|
+
*/
|
|
1912
|
+
declare function getSectionExposedStyleGroups(styles: NodeStyles | undefined): Record<string, ExposedStyleBreakpoints> | undefined;
|
|
1913
|
+
/**
|
|
1914
|
+
* Builds `{ [nodeUid]: { [propKey]: { [bp]: { [propKey]: value } } } }` from a
|
|
1915
|
+
* placed section's style groups (keyed by exposed uid, as returned by
|
|
1916
|
+
* {@link getSectionExposedStyleGroups}). Only design
|
|
1917
|
+
* exposures count, and only the declaration under the exposure's real CSS key
|
|
1918
|
+
* (`ep.propKey`) — anything else in the group (e.g. the legacy uid-keyed
|
|
1919
|
+
* declaration) is ignored. A breakpoint whose value is empty/unresolved is
|
|
1920
|
+
* left out, so it keeps the Section's own value.
|
|
1921
|
+
*/
|
|
1922
|
+
declare function buildSectionExposedStyleOverrides(designDefs: SectionExposedPropDefinition[], placedGroups: Record<string, ExposedStyleBreakpoints> | undefined | null): SectionExposedStyleOverrides | null;
|
|
1923
|
+
/**
|
|
1924
|
+
* Merges one inner node's exposed-design-prop overrides into a CLONE of its
|
|
1925
|
+
* styles: per breakpoint, the placement's declarations replace the Section's
|
|
1926
|
+
* at that breakpoint id; every other breakpoint keeps the Section's value. A
|
|
1927
|
+
* group the Section never set is created. The input is never mutated (inner
|
|
1928
|
+
* nodes are shared by every placement of the Section).
|
|
1929
|
+
*/
|
|
1930
|
+
declare function applyExposedStyleOverrides(styles: NodeStyles | undefined, overridesForNode: Record<string, ExposedStyleBreakpoints> | undefined): NodeStyles;
|
|
1931
|
+
/** The style override map in scope, read from a data context's dataSources. */
|
|
1932
|
+
declare function getSectionExposedStyleOverrides(dataSources: unknown): SectionExposedStyleOverrides | undefined;
|
|
1933
|
+
/**
|
|
1934
|
+
* The styles a renderer hands `handleNodeStyles` for a node:
|
|
1935
|
+
* - a placed section → its `default` group only;
|
|
1936
|
+
* - an inner node with exposed-design-prop overrides in scope → a merged clone;
|
|
1937
|
+
* - anything else → its own styles, untouched.
|
|
1938
|
+
*/
|
|
1939
|
+
declare function getNodeRenderStyles(node: Pick<Node, "uid" | "styles" | "type">, dataSources: unknown, isSectionComposition?: boolean): NodeStyles;
|
|
1940
|
+
/**
|
|
1941
|
+
* Returns `dataSources` scoped to ONE placement's style overrides: `overrides`
|
|
1942
|
+
* replaces whatever map was inherited (an enclosing section's map is never
|
|
1943
|
+
* meant for this section's nodes), and `null` removes it. Returns the input
|
|
1944
|
+
* unchanged when there is nothing to add or remove.
|
|
1945
|
+
*/
|
|
1946
|
+
declare function withSectionExposedStyleOverrides<T extends object>(dataSources: T, overrides: SectionExposedStyleOverrides | null | undefined): T;
|
|
1947
|
+
|
|
1651
1948
|
interface Breakpoint {
|
|
1652
1949
|
id: string;
|
|
1653
1950
|
displayName: string;
|
|
@@ -1656,7 +1953,14 @@ interface Breakpoint {
|
|
|
1656
1953
|
width: number;
|
|
1657
1954
|
height: number;
|
|
1658
1955
|
};
|
|
1956
|
+
/**
|
|
1957
|
+
* Set only on `register-breakpoints` events: `default` is one of the SDK's
|
|
1958
|
+
* own breakpoints as shipped, `overridden` an SDK default the app changes,
|
|
1959
|
+
* `app` a breakpoint only the app defines.
|
|
1960
|
+
*/
|
|
1961
|
+
origin?: BreakpointOrigin;
|
|
1659
1962
|
}
|
|
1963
|
+
type BreakpointOrigin = "default" | "overridden" | "app";
|
|
1660
1964
|
type PreProcessedBreakpoint = Omit<Breakpoint, "displayName"> & {
|
|
1661
1965
|
displayName?: string;
|
|
1662
1966
|
};
|
|
@@ -2037,5 +2341,5 @@ declare function resetStudioFunctions(): void;
|
|
|
2037
2341
|
*/
|
|
2038
2342
|
declare function wrapActionProps<T extends Record<string, unknown>>(componentProps: Props | undefined, resolvedProps: T): T;
|
|
2039
2343
|
|
|
2040
|
-
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, getServerComponentRegistryInstance, getSlotData, getStateDefaultsFor, getStateStoreInstance, getStateValuesFor, getStudioFunctionNames, getStudioStateSnapshot, hasComponentRegistryInstance, hasDesignRegistryInstance, isClientReferenceComponent, isDataMatchingPropType, isKnownType, normalizeSingleSelectChoiceValue, registerComponentStateVariable, registerGlobalStateVariables, registerStudioFunctions, resetComponentRegistryInstance, resetDesignRegistryInstance, resetGlobalStudioStore, resetStateStoreInstance, resetStudioFunctions, resolveMetadataBindings, retrievePropValue, studioState, subscribeStudioFunctionsChanged, subscribeStudioStateVariablesChanged, warnOnNonCssBoundValue, wrapActionProps };
|
|
2041
|
-
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, StudioGraph, StudioSpecData, StudioStateConfig, StudioStateStorage, StyleGroupOptions, StyleSectionCategoriesOptions, StyleSectionOptions, StyleSections, TemplateBindingValue };
|
|
2344
|
+
export { ALLOWED_DESIGN_VALUES_LEVELS, BUILT_IN_COMPONENTS, BreakpointRegistry, ComponentRegistry, DATA_SOURCES, DATA_SOURCES_PREFIX, DEFAULT_DESIGN_TOKENS, DesignRegistry, FIRST_OF_TYPE_PREFIX, INTERNAL_COMPONENTS_NAMES, INTERNAL_COMPONENT_SECTIONS, INTERNAL_SECTIONS, JSONRTERegistry, SECTION_EXPOSED_STYLES_PROP, SECTION_EXPOSED_STYLE_OVERRIDES_KEY, STYLE_SECTIONS_OPTIONS, STYLE_SECTION_CATEGORIES, SYSTEM_COMPONENTS, StudioStateStore, applyExposedStyleOverrides, buildSectionExposedStyleOverrides, callStudioFunction, clearReportedBindingErrorsForNode, collectStateBindingKeys, convertBindingPath, getBindingString, getComponentRegistryInstance, getCslpPath, getCslpTag, getDataType, getDefaultPropStaticValue, getDesignClassesNames, getDesignRegistryInstance, getFlattenedData, getGlobalStudioStore, getListElementType, getNodeBoundFunctionName, getNodeRenderStyles, getPlaceHolderComponent, getRepeaterBinding, getRepeaterBindingUID, getRepeaterContextPath, getResolvedBindingString, getSectionCompositionOwnStyles, getSectionExposedPropDefinitions, getSectionExposedStyleGroups, getSectionExposedStyleOverrides, getSectionUIDFromNode, getServerComponentRegistryInstance, getSlotData, getStateDefaultsFor, getStateStoreInstance, getStateValuesFor, getStudioFunctionNames, getStudioStateSnapshot, getUndeclaredStateBindingKeys, hasComponentRegistryInstance, hasDesignRegistryInstance, hasFirstOfTypeSegment, indexSectionNodes, isClientReferenceComponent, isDataMatchingPropType, isExposedDesignProp, isKnownType, isSectionCompositionNode, isSectionInternalExposedBinding, loadBuiltInComponents, normalizeSingleSelectChoiceValue, parseFirstOfTypeSegment, partitionSectionExposedProps, registerComponentStateVariable, registerGlobalStateVariables, registerStudioFunctions, resetComponentRegistryInstance, resetDesignRegistryInstance, resetGlobalStudioStore, resetStateStoreInstance, resetStudioFunctions, resolveFirstOfTypePath, resolveMetadataBindings, retrievePropValue, setBuiltInComponentsLoader, shouldSkipExposedOverride, studioState, subscribeStudioFunctionsChanged, subscribeStudioStateVariablesChanged, warnOnNonCssBoundValue, warnUndeclaredStateBindings, withSectionExposedStyleOverrides, withoutFirstOfTypeSegments, wrapActionProps };
|
|
2345
|
+
export type { ActionProp, AllowedDesignValues, AllowedDesignValuesLevel, AnyProp, ArrayProp, BooleanProp, Breakpoint, BreakpointInput, BreakpointOrigin, CSBindingPath, CSDataSources, ChoiceProp, ComponentRegistryOptions, ComponentType, ComposableStudioData, ContentstackBindingValue, CssVariablesToDesignTokens, CssVariablesToOrigin, CssVariablesToValue, DataSourceItem, DataSources, DateStringProp, DefaultBreakpoint, DesignClassValue, DesignClasses, DesignClassesInput, DesignClassesNames, DesignTokenCssVariable, DesignTokenOrigin, DesignTokens, DesignTokensInput, DesignTokensInputKeys, DesignTokensOptions, DesignTokensOptionsInput, ExposedPropRegistryLike, ExposedStyleBreakpoints, 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, SectionExposedPropDefinition, SectionExposedStyleOverrides, SectionScopedDataSources, SingleChoiceProp, SlotProp, StateUnsubscribe, StateUpdater, StateVariableDef, StateVariableTier, StateVariableType, StaticValue, StaticValueItem, StaticValueUid, StringProp, StudioFunction, StudioFunctionCtx, StudioGraph, StudioSpecData, StudioStateConfig, StudioStateStorage, StyleGroupOptions, StyleSectionCategoriesOptions, StyleSectionOptions, StyleSections, TemplateBindingValue };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
export { ComponentRegistry, isClientReferenceComponent } from './component-registry/registry.js';
|
|
2
2
|
export { BUILT_IN_COMPONENTS, DATA_SOURCES, DATA_SOURCES_PREFIX, INTERNAL_COMPONENTS_NAMES, INTERNAL_COMPONENT_SECTIONS, INTERNAL_SECTIONS, STYLE_SECTIONS_OPTIONS, STYLE_SECTION_CATEGORIES, SYSTEM_COMPONENTS } from './component-registry/registry.constant.js';
|
|
3
3
|
export { getComponentRegistryInstance, getServerComponentRegistryInstance, hasComponentRegistryInstance, resetComponentRegistryInstance } from './component-registry/singleton.js';
|
|
4
|
+
export { loadBuiltInComponents, setBuiltInComponentsLoader } from './component-registry/built-in-components-loader.js';
|
|
4
5
|
export { DesignRegistry } from './design-registry/design-registry.js';
|
|
5
6
|
export { getDesignRegistryInstance, hasDesignRegistryInstance, resetDesignRegistryInstance } from './design-registry/singleton.js';
|
|
6
7
|
export { getDesignClassesNames } from './design-registry/design-classes.js';
|
|
7
8
|
export { ALLOWED_DESIGN_VALUES_LEVELS, DEFAULT_DESIGN_TOKENS } from './design-registry/constants.js';
|
|
8
9
|
export { JSONRTERegistry } from './json-rte-registry/index.js';
|
|
9
10
|
export { clearReportedBindingErrorsForNode, retrievePropValue } from './data-binder/retrieve-data.js';
|
|
10
|
-
export { convertBindingPath, getBindingString, getDataType, getDefaultPropStaticValue, getFlattenedData, getPlaceHolderComponent, getRepeaterContextPath, getSlotData, isDataMatchingPropType, isKnownType, normalizeSingleSelectChoiceValue, resolveMetadataBindings, warnOnNonCssBoundValue } from './data-binder/retrieve-data.util.js';
|
|
11
|
+
export { convertBindingPath, getBindingString, getDataType, getDefaultPropStaticValue, getFlattenedData, getPlaceHolderComponent, getRepeaterContextPath, getResolvedBindingString, getSlotData, isDataMatchingPropType, isKnownType, normalizeSingleSelectChoiceValue, resolveMetadataBindings, warnOnNonCssBoundValue } from './data-binder/retrieve-data.util.js';
|
|
11
12
|
export { getCslpPath, getCslpTag, getRepeaterBinding } from './data-binder/cslp.js';
|
|
12
|
-
export {
|
|
13
|
+
export { FIRST_OF_TYPE_PREFIX, getListElementType, hasFirstOfTypeSegment, parseFirstOfTypeSegment, resolveFirstOfTypePath, withoutFirstOfTypeSegments } from './data-binder/first-of-type.js';
|
|
14
|
+
export { collectStateBindingKeys, getNodeBoundFunctionName, getStateDefaultsFor, getStateValuesFor, getUndeclaredStateBindingKeys, warnUndeclaredStateBindings } from './data-binder/state-binding.util.js';
|
|
15
|
+
export { getRepeaterBindingUID, isSectionInternalExposedBinding, shouldSkipExposedOverride } from './data-binder/section-exposed-bindings.js';
|
|
16
|
+
export { SECTION_EXPOSED_STYLES_PROP, SECTION_EXPOSED_STYLE_OVERRIDES_KEY, applyExposedStyleOverrides, buildSectionExposedStyleOverrides, getNodeRenderStyles, getSectionCompositionOwnStyles, getSectionExposedPropDefinitions, getSectionExposedStyleGroups, getSectionExposedStyleOverrides, indexSectionNodes, isExposedDesignProp, isSectionCompositionNode, partitionSectionExposedProps, withSectionExposedStyleOverrides } from './data-binder/section-exposed-design-props.js';
|
|
13
17
|
export { BreakpointRegistry } from './breakpoint-registry/index.js';
|
|
14
18
|
export { getSectionUIDFromNode } from './utils/sections.js';
|
|
15
19
|
export { StudioStateStore } from './state-store/state-store.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/studio-registry",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "This package houses all the registry related to the visual builder",
|
|
5
5
|
"main": "dist/cjs/index.cjs",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@contentstack/common-config": "^1.2.
|
|
22
|
-
"@contentstack/studio-internal": "^1.
|
|
21
|
+
"@contentstack/common-config": "^1.2.7",
|
|
22
|
+
"@contentstack/studio-internal": "^1.9.0",
|
|
23
23
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
24
24
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
25
25
|
"@rollup/plugin-terser": "^1.0.0",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"license": "MIT",
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@contentstack/json-rte-serializer": "^3.1.0",
|
|
65
|
-
"@contentstack/studio-message-types": "^2.
|
|
66
|
-
"@contentstack/studio-messenger": "^3.
|
|
65
|
+
"@contentstack/studio-message-types": "^2.2.0",
|
|
66
|
+
"@contentstack/studio-messenger": "^3.3.0",
|
|
67
67
|
"csstype": "^3.1.3",
|
|
68
68
|
"lodash-es": "^4.18.1"
|
|
69
69
|
},
|