@sitecore-content-sdk/react 2.2.1 → 2.3.0-beta.atoms.20260721120640

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.
Files changed (77) hide show
  1. package/dist/cjs/atoms/catalog-serializer.js +43 -0
  2. package/dist/cjs/atoms/create-ncc.js +75 -0
  3. package/dist/cjs/atoms/define-atoms-catalog.js +44 -0
  4. package/dist/cjs/atoms/define-atoms-registry.js +36 -0
  5. package/dist/cjs/atoms/field-schemas.js +88 -0
  6. package/dist/cjs/atoms/index.js +35 -0
  7. package/dist/cjs/atoms/re-exports.js +24 -0
  8. package/dist/cjs/atoms/schema-utils.js +19 -0
  9. package/dist/cjs/atoms/types.js +2 -0
  10. package/dist/cjs/components/DesignLibrary/DesignLibrary.js +8 -2
  11. package/dist/cjs/components/DesignLibrary/DesignLibraryLowCodeComponent.js +109 -0
  12. package/dist/cjs/components/DesignLibrary/StudioComponentServerWrapper.js +93 -0
  13. package/dist/cjs/components/DesignLibrary/StudioComponentWrapper.js +62 -0
  14. package/dist/cjs/components/DesignLibrary/index.js +3 -1
  15. package/dist/cjs/components/Placeholder/placeholder-utils.js +14 -3
  16. package/dist/cjs/components/SitecoreProvider.js +4 -2
  17. package/dist/cjs/index.js +14 -2
  18. package/dist/esm/atoms/catalog-serializer.js +40 -0
  19. package/dist/esm/atoms/create-ncc.js +39 -0
  20. package/dist/esm/atoms/define-atoms-catalog.js +41 -0
  21. package/dist/esm/atoms/define-atoms-registry.js +33 -0
  22. package/dist/esm/atoms/field-schemas.js +79 -0
  23. package/dist/esm/atoms/index.js +7 -0
  24. package/dist/esm/atoms/re-exports.js +21 -0
  25. package/dist/esm/atoms/schema-utils.js +16 -0
  26. package/dist/esm/atoms/types.js +1 -0
  27. package/dist/esm/components/DesignLibrary/DesignLibrary.js +8 -2
  28. package/dist/esm/components/DesignLibrary/DesignLibraryLowCodeComponent.js +71 -0
  29. package/dist/esm/components/DesignLibrary/StudioComponentServerWrapper.js +86 -0
  30. package/dist/esm/components/DesignLibrary/StudioComponentWrapper.js +25 -0
  31. package/dist/esm/components/DesignLibrary/index.js +1 -0
  32. package/dist/esm/components/Image.js +1 -1
  33. package/dist/esm/components/Link.js +1 -1
  34. package/dist/esm/components/Placeholder/placeholder-utils.js +14 -3
  35. package/dist/esm/components/SitecoreProvider.js +4 -2
  36. package/dist/esm/index.js +3 -2
  37. package/package.json +9 -7
  38. package/types/atoms/catalog-serializer.d.ts +11 -0
  39. package/types/atoms/catalog-serializer.d.ts.map +1 -0
  40. package/types/atoms/create-ncc.d.ts +24 -0
  41. package/types/atoms/create-ncc.d.ts.map +1 -0
  42. package/types/atoms/define-atoms-catalog.d.ts +65 -0
  43. package/types/atoms/define-atoms-catalog.d.ts.map +1 -0
  44. package/types/atoms/define-atoms-registry.d.ts +33 -0
  45. package/types/atoms/define-atoms-registry.d.ts.map +1 -0
  46. package/types/atoms/field-schemas.d.ts +120 -0
  47. package/types/atoms/field-schemas.d.ts.map +1 -0
  48. package/types/atoms/index.d.ts +9 -0
  49. package/types/atoms/index.d.ts.map +1 -0
  50. package/types/atoms/re-exports.d.ts +22 -0
  51. package/types/atoms/re-exports.d.ts.map +1 -0
  52. package/types/atoms/schema-utils.d.ts +20 -0
  53. package/types/atoms/schema-utils.d.ts.map +1 -0
  54. package/types/atoms/types.d.ts +78 -0
  55. package/types/atoms/types.d.ts.map +1 -0
  56. package/types/components/DesignLibrary/DesignLibrary.d.ts.map +1 -1
  57. package/types/components/DesignLibrary/DesignLibraryLowCodeComponent.d.ts +13 -0
  58. package/types/components/DesignLibrary/DesignLibraryLowCodeComponent.d.ts.map +1 -0
  59. package/types/components/DesignLibrary/StudioComponentServerWrapper.d.ts +33 -0
  60. package/types/components/DesignLibrary/StudioComponentServerWrapper.d.ts.map +1 -0
  61. package/types/components/DesignLibrary/StudioComponentWrapper.d.ts +25 -0
  62. package/types/components/DesignLibrary/StudioComponentWrapper.d.ts.map +1 -0
  63. package/types/components/DesignLibrary/index.d.ts +1 -0
  64. package/types/components/DesignLibrary/index.d.ts.map +1 -1
  65. package/types/components/Image.d.ts +37 -1
  66. package/types/components/Image.d.ts.map +1 -1
  67. package/types/components/Link.d.ts +24 -1
  68. package/types/components/Link.d.ts.map +1 -1
  69. package/types/components/Placeholder/placeholder-utils.d.ts.map +1 -1
  70. package/types/components/RichText.d.ts +8 -1
  71. package/types/components/RichText.d.ts.map +1 -1
  72. package/types/components/SitecoreProvider.d.ts +11 -0
  73. package/types/components/SitecoreProvider.d.ts.map +1 -1
  74. package/types/components/Text.d.ts +8 -1
  75. package/types/components/Text.d.ts.map +1 -1
  76. package/types/index.d.ts +7 -6
  77. package/types/index.d.ts.map +1 -1
@@ -0,0 +1,86 @@
1
+ import React from 'react';
2
+ import { StudioComponentWrapper } from './StudioComponentWrapper';
3
+ import { NativeDataFetcher } from '@sitecore-content-sdk/core';
4
+ import { debug } from '@sitecore-content-sdk/content';
5
+ import { resolveEdgeUrl } from '@sitecore-content-sdk/core/tools';
6
+ /**
7
+ * Server component for Studio (NCC) components. Fetches the component layout
8
+ * `Document` from MMS server-side and renders the client `StudioComponentWrapper`.
9
+ * @param {StudioComponentServerWrapperProps} props incoming props
10
+ * @returns rendered `StudioComponentWrapper`
11
+ * @internal
12
+ */
13
+ export const StudioComponentServerWrapper = async (props) => {
14
+ const componentRef = props.componentRef || '';
15
+ if (!componentRef)
16
+ return null;
17
+ const path = extractVariantPathFromComponentRef(componentRef, props.fieldNames);
18
+ if (!path)
19
+ return null;
20
+ const document = await fetchDocument(path);
21
+ if (!document)
22
+ return null;
23
+ return React.createElement(StudioComponentWrapper, { document: document, fields: props.fields, params: props.params });
24
+ };
25
+ /**
26
+ * Extracts the variant path from a component reference.
27
+ * @param {string} componentRef The component reference string.
28
+ * @param {string} fieldNames The field names to extract the variant path for.
29
+ * @returns {string} The variant path.
30
+ * @internal
31
+ */
32
+ function extractVariantPathFromComponentRef(componentRef, fieldNames = 'default') {
33
+ const paths = componentRef.split('|').reduce((acc, part) => {
34
+ const path = part.trim();
35
+ const segments = path.split('/');
36
+ const variant = segments[segments.length - 1];
37
+ acc.set(variant, path);
38
+ return acc;
39
+ }, new Map());
40
+ const path = paths.get(fieldNames) || paths.get('default') || null;
41
+ if (!path) {
42
+ console.warn(`StudioComponentServerWrapper: failed to extract path from ComponentRef "${componentRef}" with fieldNames "${fieldNames}". ` +
43
+ 'Ensure the ComponentRef is in the expected format and that the correct fieldNames are provided.');
44
+ }
45
+ return path;
46
+ }
47
+ /**
48
+ * Prefix for MMS component paths in componentRef. The final URL will be resolved as `${host}/${MMS_COMPONENT_PATH_PREFIX}/${path}`.
49
+ */
50
+ const MMS_COMPONENT_PATH_PREFIX = 'mms';
51
+ /**
52
+ * Fetch a Studio component layout `Document` by reference.
53
+ * @param {string} path extracted component reference (path) from `params.ComponentRef`
54
+ * @returns {Promise<Document | null>} the resolved component layout, or `null` on missing path, fetch failure, or un-parseable body.
55
+ */
56
+ async function fetchDocument(path) {
57
+ let url;
58
+ try {
59
+ const pathWithMmsPrefix = path.startsWith('/')
60
+ ? `/${MMS_COMPONENT_PATH_PREFIX}${path}`
61
+ : `/${MMS_COMPONENT_PATH_PREFIX}/${path}`;
62
+ const hostURL = resolveEdgeUrl();
63
+ url = new URL(pathWithMmsPrefix, hostURL).toString();
64
+ }
65
+ catch (err) {
66
+ console.error(`StudioComponentServerWrapper: failed to resolve component from "${path}"`, err);
67
+ return null;
68
+ }
69
+ let response;
70
+ try {
71
+ const fetcher = new NativeDataFetcher({ debugger: debug.layout });
72
+ response = await fetcher.get(url);
73
+ }
74
+ catch (error) {
75
+ console.error(`StudioComponentServerWrapper: failed to fetch component layout from ${url}`, error);
76
+ return null;
77
+ }
78
+ try {
79
+ const document = JSON.parse(response.data);
80
+ return document;
81
+ }
82
+ catch (err) {
83
+ console.error(`StudioComponentServerWrapper: failed to parse component layout response from ${url}`, err);
84
+ return null;
85
+ }
86
+ }
@@ -0,0 +1,25 @@
1
+ 'use client';
2
+ import React, { useMemo } from 'react';
3
+ import { createNCC } from '../../atoms';
4
+ import { useSitecore } from '../SitecoreProvider';
5
+ /**
6
+ * Client component that renders a pre-fetched Studio (NCC) component layout.
7
+ *
8
+ * Expects `document` to be provided (fetched server-side by
9
+ * `StudioComponentServerWrapper`, from Design Library document updates, or any other
10
+ * preview path that supplies a layout `Document`). Renders `null` when no layout
11
+ * is available.
12
+ * @param {StudioComponentWrapperProps} props component props
13
+ * @internal
14
+ */
15
+ export const StudioComponentWrapper = ({ document, fields, params, }) => {
16
+ const { atomsConfig } = useSitecore();
17
+ const NCComponent = useMemo(() => {
18
+ if (!document || !atomsConfig)
19
+ return null;
20
+ return createNCC(document, atomsConfig.registry);
21
+ }, [document, atomsConfig]);
22
+ if (!NCComponent)
23
+ return null;
24
+ return React.createElement(NCComponent, { fields: fields, params: params });
25
+ };
@@ -1,3 +1,4 @@
1
1
  export { DesignLibrary } from './DesignLibrary';
2
+ export { DesignLibraryLowCodeComponent } from './DesignLibraryLowCodeComponent';
2
3
  export { DesignLibraryErrorBoundary } from './DesignLibraryErrorBoundary';
3
4
  export { noopLoadImportMap } from './loadImportMap';
@@ -15,7 +15,7 @@ import { addClassName } from '../utils';
15
15
  import { withFieldMetadata } from '../enhancers/withFieldMetadata';
16
16
  import { withEmptyFieldEditingComponent } from '../enhancers/withEmptyFieldEditingComponent';
17
17
  import { DefaultEmptyFieldEditingComponentImage } from './DefaultEmptyFieldEditingComponents';
18
- import { isFieldValueEmpty, } from '@sitecore-content-sdk/content/layout';
18
+ import { isFieldValueEmpty } from '@sitecore-content-sdk/content/layout';
19
19
  const getImageAttrs = (_a, imageParams, mediaUrlPrefix) => {
20
20
  var { src, srcSet } = _a, otherAttrs = __rest(_a, ["src", "srcSet"]);
21
21
  if (!src) {
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  return t;
12
12
  };
13
13
  import React from 'react';
14
- import { isFieldValueEmpty, } from '@sitecore-content-sdk/content/layout';
14
+ import { isFieldValueEmpty } from '@sitecore-content-sdk/content/layout';
15
15
  import { withFieldMetadata } from '../enhancers/withFieldMetadata';
16
16
  import { withEmptyFieldEditingComponent } from '../enhancers/withEmptyFieldEditingComponent';
17
17
  import { DefaultEmptyFieldEditingComponentText } from './DefaultEmptyFieldEditingComponents';
@@ -5,6 +5,7 @@ import { isDynamicPlaceholder, getDynamicPlaceholderPattern, getRenderingParamSt
5
5
  import { HIDDEN_RENDERING_NAME } from '@sitecore-content-sdk/content';
6
6
  import { HiddenRendering } from '../HiddenRendering';
7
7
  import { FEaaSComponent, FEaaSWrapper, BYOCComponent, BYOCWrapper, BYOC_COMPONENT_RENDERING_NAME, BYOC_WRAPPER_RENDERING_NAME, FEAAS_COMPONENT_RENDERING_NAME, FEAAS_WRAPPER_RENDERING_NAME, } from '../FEaaS';
8
+ import { StudioComponentServerWrapper } from '../DesignLibrary/StudioComponentServerWrapper';
8
9
  /**
9
10
  * Get the renderings for the specified placeholder from the rendering layout data.
10
11
  * @param {ComponentRendering | RouteData } rendering rendering data
@@ -99,7 +100,7 @@ export function getChildComponentProps(placeholderProps, componentRendering) {
99
100
  * @returns {ContentSDKComponet | null} component implementation or null if no component map is provided
100
101
  */
101
102
  export const getComponentForRendering = (renderingDefinition, placeholderName, componentMap, hiddenRenderingComponent, missingComponentComponent) => {
102
- var _a, _b;
103
+ var _a, _b, _c;
103
104
  const logUnknownComponentError = (variant) => {
104
105
  console.error(`Placeholder ${placeholderName} contains unknown component ${renderingDefinition.componentName}${variant ? ` (${variant})` : ''}. Ensure that a React component exists for it, and that it is registered in your component-map file.`);
105
106
  };
@@ -117,6 +118,16 @@ export const getComponentForRendering = (renderingDefinition, placeholderName, c
117
118
  componentType: 'universal',
118
119
  };
119
120
  }
121
+ if ((_a = renderingDefinition.params) === null || _a === void 0 ? void 0 : _a.ComponentRef) {
122
+ return {
123
+ component: (props) => {
124
+ var _a;
125
+ return (React.createElement(StudioComponentServerWrapper, { componentRef: props.rendering.params.ComponentRef, fieldNames: (_a = props.rendering.params) === null || _a === void 0 ? void 0 : _a.fieldNames, fields: props.fields, params: props.params }));
126
+ },
127
+ isEmpty: false,
128
+ componentType: 'server',
129
+ };
130
+ }
120
131
  let component = null;
121
132
  if (!componentMap || componentMap.size === 0) {
122
133
  console.warn(`No components were available in component map to service request for component ${renderingDefinition}`);
@@ -165,7 +176,7 @@ export const getComponentForRendering = (renderingDefinition, placeholderName, c
165
176
  };
166
177
  }
167
178
  // Render SXA Rendering Variant if available
168
- const exportName = (_a = renderingDefinition.params) === null || _a === void 0 ? void 0 : _a.FieldNames;
179
+ const exportName = (_b = renderingDefinition.params) === null || _b === void 0 ? void 0 : _b.FieldNames;
169
180
  const renderedComponent = exportName && exportName !== DEFAULT_EXPORT_NAME
170
181
  ? component[exportName]
171
182
  : component.default ||
@@ -179,7 +190,7 @@ export const getComponentForRendering = (renderingDefinition, placeholderName, c
179
190
  componentType: 'universal',
180
191
  };
181
192
  }
182
- const dynamic = !!((_b = renderedComponent.render) === null || _b === void 0 ? void 0 : _b.preload) ||
193
+ const dynamic = !!((_c = renderedComponent.render) === null || _c === void 0 ? void 0 : _c.preload) ||
183
194
  renderingDefinition.componentName === BYOC_WRAPPER_RENDERING_NAME;
184
195
  // all dynamic elements will have a separate render prop
185
196
  return {
@@ -16,12 +16,13 @@ export const ImportMapReactContext = React.createContext(undefined);
16
16
  * @param {SitecoreProviderProps['page']} props.page - The page data.
17
17
  * @param {SitecoreProviderProps['componentMap']} props.componentMap - The component map.
18
18
  * @param {SitecoreProviderProps['loadImportMap']} props.loadImportMap - Optional function to load the import map for Design Library variant generation. When omitted, an empty import map is used (ex: code generation is disabled).
19
+ * @param {SitecoreProviderProps['atomsConfig']} props.atomsConfig - Atoms config (catalog + registry) for rendering low-code components.
19
20
  * @param {React.ReactNode} props.children - The children to render.
20
21
  * @returns {React.ReactNode} The SitecoreProvider component.
21
22
  * @public
22
23
  */
23
24
  export const SitecoreProvider = (props) => {
24
- const { api, page: propsPage, componentMap, loadImportMap = noopLoadImportMap, children } = props;
25
+ const { api, page: propsPage, componentMap, loadImportMap = noopLoadImportMap, atomsConfig, children, } = props;
25
26
  const [page, setPageInternal] = useState(propsPage);
26
27
  // Memoize setPage callback
27
28
  const setPage = useCallback((value) => {
@@ -40,7 +41,8 @@ export const SitecoreProvider = (props) => {
40
41
  api,
41
42
  componentMap,
42
43
  loadImportMap,
43
- }), [page, setPage, api, componentMap, loadImportMap]);
44
+ atomsConfig,
45
+ }), [page, setPage, api, componentMap, loadImportMap, atomsConfig]);
44
46
  return (React.createElement(SitecoreProviderReactContext.Provider, { value: contextValue }, children));
45
47
  };
46
48
  SitecoreProvider.displayName = 'SitecoreProvider';
package/dist/esm/index.js CHANGED
@@ -6,14 +6,14 @@ export { DefaultRetryStrategy, GraphQLRequestClient, ErrorPage, } from '@sitecor
6
6
  export { mediaApi } from '@sitecore-content-sdk/content/media';
7
7
  export { Form } from './components/Form';
8
8
  export { Placeholder, AppPlaceholder, PlaceholderMetadata, renderEmptyPlaceholder, } from './components/Placeholder';
9
- export { Image } from './components/Image';
9
+ export { Image, } from './components/Image';
10
10
  export { RichText } from './components/RichText';
11
11
  export { Text } from './components/Text';
12
12
  export { DateField } from './components/Date';
13
13
  export { FEaaSComponent, fetchFEaaSComponentServerProps, BYOCComponent, fetchBYOCComponentServerProps,
14
14
  // leaving original names for backward compatibility
15
15
  BYOCWrapper, BYOCWrapper as BYOCClientWrapper, FEaaSWrapper, FEaaSWrapper as FEaaSClientWrapper, FEaaSServerWrapper, BYOCServerWrapper, } from './components/FEaaS';
16
- export { DesignLibrary, DesignLibraryErrorBoundary, noopLoadImportMap, } from './components/DesignLibrary';
16
+ export { DesignLibrary, DesignLibraryLowCodeComponent, DesignLibraryErrorBoundary, noopLoadImportMap, } from './components/DesignLibrary';
17
17
  export { Link } from './components/Link';
18
18
  export { File } from './components/File';
19
19
  export { SitecoreProvider, SitecoreProviderReactContext, useSitecore, } from './components/SitecoreProvider';
@@ -29,3 +29,4 @@ export { EditingScripts } from './components/EditingScripts';
29
29
  export { DefaultEmptyFieldEditingComponentText, DefaultEmptyFieldEditingComponentImage, } from './components/DefaultEmptyFieldEditingComponents';
30
30
  export { ClientEditingChromesUpdate } from './components/ClientEditingChromesUpdate';
31
31
  export { SitePathService } from '@sitecore-content-sdk/content/site';
32
+ export { useBoundProp, defineAtomsCatalog, defineAtomsRegistry, withPropMeta, textFieldSchema, richTextFieldSchema, dateFieldSchema, linkFieldSchema, imageFieldSchema, fileFieldSchema, } from './atoms';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-content-sdk/react",
3
- "version": "2.2.1",
3
+ "version": "2.3.0-beta.atoms.20260721120640",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -32,7 +32,7 @@
32
32
  "url": "https://github.com/sitecore/content-sdk/issues"
33
33
  },
34
34
  "devDependencies": {
35
- "@sitecore-content-sdk/analytics-core": "^2.1.1",
35
+ "@sitecore-content-sdk/analytics-core": "2.1.1-beta.atoms.20260721120640",
36
36
  "@sitecore-feaas/clientside": "^0.6.0",
37
37
  "@stylistic/eslint-plugin": "^5.2.2",
38
38
  "@testing-library/dom": "^10.4.0",
@@ -71,16 +71,18 @@
71
71
  "typescript": "~5.8.3"
72
72
  },
73
73
  "peerDependencies": {
74
- "@sitecore-content-sdk/analytics-core": "^2.1.1",
75
- "@sitecore-content-sdk/events": "^2.1.1",
74
+ "@sitecore-content-sdk/analytics-core": "2.1.1-beta.atoms.20260721120640",
75
+ "@sitecore-content-sdk/events": "2.1.1-beta.atoms.20260721120640",
76
76
  "@sitecore-feaas/clientside": "^0.6.0",
77
77
  "react": "^19.2.1",
78
78
  "react-dom": "^19.2.1"
79
79
  },
80
80
  "dependencies": {
81
- "@sitecore-content-sdk/content": "^2.2.1",
82
- "@sitecore-content-sdk/core": "^2.1.2",
83
- "@sitecore-content-sdk/search": "^0.3.0",
81
+ "@json-render/core": "0.19.0",
82
+ "@json-render/react": "0.19.0",
83
+ "@sitecore-content-sdk/content": "2.3.0-beta.atoms.20260721120640",
84
+ "@sitecore-content-sdk/core": "2.1.2-beta.atoms.20260721120640",
85
+ "@sitecore-content-sdk/search": "0.3.1-beta.atoms.20260721120640",
84
86
  "fast-deep-equal": "^3.1.3"
85
87
  },
86
88
  "description": "",
@@ -0,0 +1,11 @@
1
+ import type { Catalog } from '@json-render/core';
2
+ import { AtomsCatalogInput } from './types';
3
+ import { SerializedCatalog } from '@sitecore-content-sdk/content/atoms';
4
+ /**
5
+ * Serialize a json-render Catalog into the payload shape expected by Design Studio.
6
+ * @param { Catalog<any, AtomsCatalogInput> } catalog - The json-render Catalog to serialize
7
+ * @returns Serialized catalog for the Design Library event
8
+ * @internal
9
+ */
10
+ export declare function serializeCatalog(catalog: Catalog<any, AtomsCatalogInput>): SerializedCatalog;
11
+ //# sourceMappingURL=catalog-serializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-serializer.d.ts","sourceRoot":"","sources":["../../src/atoms/catalog-serializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAGL,iBAAiB,EAClB,MAAM,qCAAqC,CAAC;AAE7C;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,iBAAiB,CAAC,GAAG,iBAAiB,CA0C5F"}
@@ -0,0 +1,24 @@
1
+ import { type FC } from 'react';
2
+ import type { DefineRegistryResult } from '@json-render/react';
3
+ import { Document } from '@sitecore-content-sdk/content/atoms';
4
+ import type { ChildComponentProps } from '../components/Placeholder/models';
5
+ /**
6
+ * Props accepted by the NCC component created by `createNCC`.
7
+ * @internal
8
+ */
9
+ type NCCProps = {
10
+ [key: string]: unknown;
11
+ fields?: ChildComponentProps['fields'];
12
+ params?: ChildComponentProps['params'];
13
+ };
14
+ /**
15
+ * Creates a React functional component that renders the given Component Layout document
16
+ * using json-render's Renderer. The document's flat element map is passed as a spec.
17
+ * @param {Document} doc - Component Layout document (flat spec format)
18
+ * @param {DefineRegistryResult} registryResult - The registry from defineAtomsRegistry
19
+ * @returns {FC<NCCProps>} FC that accepts runtime props merged into spec state
20
+ * @internal
21
+ */
22
+ export declare function createNCC(doc: Document, registryResult: DefineRegistryResult): FC<NCCProps>;
23
+ export {};
24
+ //# sourceMappingURL=create-ncc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-ncc.d.ts","sourceRoot":"","sources":["../../src/atoms/create-ncc.tsx"],"names":[],"mappings":"AACA,OAAc,EAAE,KAAK,EAAE,EAAuB,MAAM,OAAO,CAAC;AAQ5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG/D,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAE/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E;;;GAGG;AACH,KAAK,QAAQ,GAAG;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,oBAAoB,GAAG,EAAE,CAAC,QAAQ,CAAC,CAmD3F"}
@@ -0,0 +1,65 @@
1
+ import type { AtomsCatalogInput, RestrictFieldKey, Exact } from './types';
2
+ /**
3
+ * Define an atoms catalog from component and action definitions.
4
+ *
5
+ * Pass component/action definitions exactly as json-render expects them.
6
+ * The returned catalog carries full type information so `defineAtomsRegistry`
7
+ * can infer props per component.
8
+ * @param {T} input - Catalog input with `components` and optionally `actions`
9
+ * @returns A typed json-render Catalog
10
+ * @example
11
+ * ```ts
12
+ * import { z } from 'zod';
13
+ * import { defineAtomsCatalog } from '@sitecore-content-sdk/react';
14
+ *
15
+ * const catalog = defineAtomsCatalog({
16
+ * components: {
17
+ * Button: {
18
+ * props: z.object({ label: z.string(), variant: z.enum(['primary', 'secondary']) }),
19
+ * description: 'A clickable button',
20
+ * slots: ['default'],
21
+ * },
22
+ * Card: {
23
+ * props: z.object({ title: z.string() }),
24
+ * description: 'A content card',
25
+ * slots: ['default'],
26
+ * },
27
+ * },
28
+ * actions: {
29
+ * submit: {
30
+ * params: z.object({ formId: z.string() }),
31
+ * description: 'Submit a form',
32
+ * },
33
+ * },
34
+ * });
35
+ * ```
36
+ * @public
37
+ */
38
+ export declare function defineAtomsCatalog<T extends AtomsCatalogInput>(input: Exact<T, AtomsCatalogInput> & {
39
+ components: RestrictFieldKey<T['components'], 'props', 'className'>;
40
+ }): import("@json-render/core").Catalog<{
41
+ spec: import("@json-render/core").SchemaType<"object", {
42
+ root: import("@json-render/core").SchemaType<"string", unknown>;
43
+ elements: import("@json-render/core").SchemaType<"record", import("@json-render/core").SchemaType<"object", {
44
+ type: import("@json-render/core").SchemaType<"ref", string>;
45
+ props: import("@json-render/core").SchemaType<"propsOf", string>;
46
+ children: import("@json-render/core").SchemaType<"array", import("@json-render/core").SchemaType<"string", unknown>>;
47
+ visible: import("@json-render/core").SchemaType<"any", unknown>;
48
+ }>>;
49
+ }>;
50
+ catalog: import("@json-render/core").SchemaType<"object", {
51
+ components: import("@json-render/core").SchemaType<"map", {
52
+ props: import("@json-render/core").SchemaType<"zod", unknown>;
53
+ slots: import("@json-render/core").SchemaType<"array", import("@json-render/core").SchemaType<"string", unknown>>;
54
+ description: import("@json-render/core").SchemaType<"string", unknown>;
55
+ example: import("@json-render/core").SchemaType<"any", unknown>;
56
+ }>;
57
+ actions: import("@json-render/core").SchemaType<"map", {
58
+ params: import("@json-render/core").SchemaType<"zod", unknown>;
59
+ description: import("@json-render/core").SchemaType<"string", unknown>;
60
+ }>;
61
+ }>;
62
+ }, T & Record<Exclude<keyof T, "components" | "actions" | "version">, never> & {
63
+ components: RestrictFieldKey<T["components"], "props", "className">;
64
+ }>;
65
+ //# sourceMappingURL=define-atoms-catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-atoms-catalog.d.ts","sourceRoot":"","sources":["../../src/atoms/define-atoms-catalog.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,iBAAiB,EAC5D,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,GAAG;IACnC,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;CACrE;;;;;;;;;;;;;;;;;;;;;;;gBADa,gBAAgB,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC;GAItE"}
@@ -0,0 +1,33 @@
1
+ import { defineRegistry } from '@json-render/react';
2
+ /**
3
+ * Define an atoms registry that maps catalog definitions to React implementations.
4
+ *
5
+ * Each component receives `{ props, children, emit, on, bindings, loading }`
6
+ * @param catalog - The catalog created by defineAtomsCatalog
7
+ * @param options - Component and action implementations
8
+ * @returns Registry result with component registry and action handlers
9
+ * @example
10
+ *
11
+ * ```tsx
12
+ * import { defineAtomsRegistry } from '@sitecore-content-sdk/react';
13
+ *
14
+ * const { registry, handlers, executeAction } = defineAtomsRegistry(catalog, {
15
+ * components: {
16
+ * Button: ({ props, children, emit }) => (
17
+ * <button onClick={() => emit('press')}>{props.label}{children}</button>
18
+ * ),
19
+ * Card: ({ props, children }) => (
20
+ * <div className="card"><h2>{props.title}</h2>{children}</div>
21
+ * ),
22
+ * },
23
+ * actions: {
24
+ * submit: async (params) => {
25
+ * await fetch('/api/submit', { method: 'POST', body: JSON.stringify(params) });
26
+ * },
27
+ * },
28
+ * });
29
+ * ```
30
+ * @public
31
+ */
32
+ export declare const defineAtomsRegistry: typeof defineRegistry;
33
+ //# sourceMappingURL=define-atoms-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-atoms-registry.d.ts","sourceRoot":"","sources":["../../src/atoms/define-atoms-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,mBAAmB,uBAAiB,CAAC"}
@@ -0,0 +1,120 @@
1
+ /** Zod schemas for Sitecore field types, for use in defineAtomsCatalog prop definitions. */
2
+ import { z } from 'zod';
3
+ /**
4
+ * Zod schema for a Sitecore Single-Line Text.
5
+ * Mirrors the Sitecore Text component (`Text.tsx` in `@sitecore-content-sdk/react`).
6
+ * @param {z.ZodRawShape} [extra] - Optional additional shape to merge into the schema.
7
+ * @returns A ZodObject with `value?: string | number` and DS control/fieldType hints attached.
8
+ * @public
9
+ */
10
+ export declare const textFieldSchema: (extra?: z.ZodRawShape) => z.ZodObject<{
11
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
12
+ }, z.core.$strip>;
13
+ /**
14
+ * Zod schema for a Sitecore Rich Text field.
15
+ * Mirrors the Sitecore Rich Text component (`RichText.tsx` in `@sitecore-content-sdk/react`).
16
+ * @param {z.ZodRawShape} [extra] - Optional additional shape to merge into the schema.
17
+ * @returns A ZodObject with `value?: string` and DS control/fieldType hints attached.
18
+ * @public
19
+ */
20
+ export declare const richTextFieldSchema: (extra?: z.ZodRawShape) => z.ZodObject<{
21
+ value: z.ZodOptional<z.ZodString>;
22
+ }, z.core.$strip>;
23
+ /**
24
+ * Zod schema for a Sitecore Date field.
25
+ * Mirrors the field shape used in the Date component (`Date.tsx` in `@sitecore-content-sdk/react`).
26
+ * @param {z.ZodRawShape} [extra] - Optional additional shape to merge into the schema.
27
+ * @returns A ZodObject with `value?: string` and DS control/fieldType hints attached.
28
+ * @public
29
+ */
30
+ export declare const dateFieldSchema: (extra?: z.ZodRawShape) => z.ZodObject<{
31
+ value: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strip>;
33
+ /**
34
+ * Zod schema for a Sitecore Link field.
35
+ * Mirrors the Sitecore Link component (`Link.tsx` in `@sitecore-content-sdk/react`).
36
+ * The inner value object uses `z.looseObject` to allow arbitrary Sitecore-added attributes,
37
+ * matching the `[attributeName: string]: unknown` index signature on `LinkFieldValue`.
38
+ * @param {z.ZodRawShape} [extra] - Optional additional shape to merge into the outer schema.
39
+ * @returns A ZodObject with `value: LinkFieldValue` and DS control/fieldType hints attached.
40
+ * @public
41
+ */
42
+ export declare const linkFieldSchema: (extra?: z.ZodRawShape) => z.ZodObject<{
43
+ value: z.ZodObject<{
44
+ href: z.ZodOptional<z.ZodString>;
45
+ className: z.ZodOptional<z.ZodString>;
46
+ class: z.ZodOptional<z.ZodString>;
47
+ title: z.ZodOptional<z.ZodString>;
48
+ target: z.ZodOptional<z.ZodString>;
49
+ text: z.ZodOptional<z.ZodString>;
50
+ anchor: z.ZodOptional<z.ZodString>;
51
+ querystring: z.ZodOptional<z.ZodString>;
52
+ linktype: z.ZodOptional<z.ZodString>;
53
+ }, z.core.$loose>;
54
+ }, z.core.$strip>;
55
+ /**
56
+ * Zod schema for a Sitecore Image field.
57
+ * Mirrors the Sitecore Image component (`Image.tsx` in `@sitecore-content-sdk/react`).
58
+ * The inner value object uses `z.looseObject` to allow arbitrary HTML attributes,
59
+ * matching the `[attributeName: string]: unknown` index signature on `ImageFieldValue`.
60
+ * @param {z.ZodRawShape} [extra] - Optional additional shape to merge into the outer schema.
61
+ * @returns A ZodObject with `value?: ImageFieldValue` and DS control/fieldType hints attached.
62
+ * @public
63
+ */
64
+ export declare const imageFieldSchema: (extra?: z.ZodRawShape) => z.ZodObject<{
65
+ value: z.ZodOptional<z.ZodObject<{
66
+ src: z.ZodOptional<z.ZodString>;
67
+ alt: z.ZodOptional<z.ZodString>;
68
+ width: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
69
+ height: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
70
+ class: z.ZodOptional<z.ZodString>;
71
+ }, z.core.$loose>>;
72
+ }, z.core.$strip>;
73
+ /**
74
+ * Zod schema for a Sitecore File field.
75
+ * Mirrors the Sitecore File component (`File.tsx` in `@sitecore-content-sdk/react`).
76
+ * The inner value object uses `z.looseObject` to allow arbitrary extra properties,
77
+ * matching the `[propName: string]: unknown` index signature on `FileFieldValue`.
78
+ * @param {z.ZodRawShape} [extra] - Optional additional shape to merge into the outer schema.
79
+ * @returns A ZodObject with `value: FileFieldValue` and DS control/fieldType hints attached.
80
+ * @public
81
+ */
82
+ export declare const fileFieldSchema: (extra?: z.ZodRawShape) => z.ZodObject<{
83
+ value: z.ZodObject<{
84
+ src: z.ZodOptional<z.ZodString>;
85
+ title: z.ZodOptional<z.ZodString>;
86
+ displayName: z.ZodOptional<z.ZodString>;
87
+ }, z.core.$loose>;
88
+ }, z.core.$strip>;
89
+ /**
90
+ * Inferred type for a Sitecore Single-Line Text / Multi-Line Text field prop.
91
+ * Use this to type component props that accept a text field.
92
+ * @public
93
+ */
94
+ export type TextFieldSchema = z.infer<ReturnType<typeof textFieldSchema>>;
95
+ /**
96
+ * Inferred type for a Sitecore Rich Text field prop.
97
+ * @public
98
+ */
99
+ export type RichTextFieldSchema = z.infer<ReturnType<typeof richTextFieldSchema>>;
100
+ /**
101
+ * Inferred type for a Sitecore Date field prop.
102
+ * @public
103
+ */
104
+ export type DateFieldSchema = z.infer<ReturnType<typeof dateFieldSchema>>;
105
+ /**
106
+ * Inferred type for a Sitecore General Link field prop.
107
+ * @public
108
+ */
109
+ export type LinkFieldSchema = z.infer<ReturnType<typeof linkFieldSchema>>;
110
+ /**
111
+ * Inferred type for a Sitecore Image field prop.
112
+ * @public
113
+ */
114
+ export type ImageFieldSchema = z.infer<ReturnType<typeof imageFieldSchema>>;
115
+ /**
116
+ * Inferred type for a Sitecore File field prop.
117
+ * @public
118
+ */
119
+ export type FileFieldSchema = z.infer<ReturnType<typeof fileFieldSchema>>;
120
+ //# sourceMappingURL=field-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-schemas.d.ts","sourceRoot":"","sources":["../../src/atoms/field-schemas.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,CAAC,CAAC,WAAW;;iBAOlD,CAAC;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,CAAC,CAAC,WAAW;;iBAOtD,CAAC;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,CAAC,CAAC,WAAW;;iBAOlD,CAAC;AAEJ;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,CAAC,CAAC,WAAW;;;;;;;;;;;;iBAiBlD,CAAC;AAEJ;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,CAAC,CAAC,WAAW;;;;;;;;iBAenD,CAAC;AAEJ;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,CAAC,CAAC,WAAW;;;;;;iBAWlD,CAAC;AAEJ;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC;AAElF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC;AAE5E;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export type { AtomComponentDefinition, AtomActionDefinition, AtomsCatalogInput, AtomsComponentsMap, AtomActionHandler, AtomsActionsMap, AtomsConfig, Exact, } from './types';
2
+ export { defineAtomsCatalog } from './define-atoms-catalog';
3
+ export { defineAtomsRegistry } from './define-atoms-registry';
4
+ export { serializeCatalog } from './catalog-serializer';
5
+ export { withPropMeta, type PropMeta } from './schema-utils';
6
+ export { textFieldSchema, richTextFieldSchema, dateFieldSchema, linkFieldSchema, imageFieldSchema, fileFieldSchema, type TextFieldSchema, type RichTextFieldSchema, type DateFieldSchema, type LinkFieldSchema, type ImageFieldSchema, type FileFieldSchema, } from './field-schemas';
7
+ export { createNCC } from './create-ncc';
8
+ export * from './re-exports';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/atoms/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,KAAK,GACN,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { useBoundProp as useBoundPropInternal } from '@json-render/react';
2
+ /**
3
+ * Hook for two-way bound props. Returns `[value, setValue]` where:
4
+ *
5
+ * - `value` is the already-resolved prop value (passed through from render props)
6
+ * - `setValue` writes back to the bound state path (no-op if not bound)
7
+ *
8
+ * Designed to work with the `bindings` map that the renderer provides when
9
+ * a prop uses `{ $bindState: "/path" }` or `{ $bindItem: "field" }`.
10
+ * @example
11
+ * ```tsx
12
+ * import { useBoundProp } from '@sitecore-content-sdk/react';
13
+ *
14
+ * const Input: ComponentRenderer = ({ props, bindings }) => {
15
+ * const [value, setValue] = useBoundProp<string>(props.value, bindings?.value);
16
+ * return <input value={value ?? ""} onChange={(e) => setValue(e.target.value)} />;
17
+ * };
18
+ * ```
19
+ * @public
20
+ */
21
+ export declare const useBoundProp: typeof useBoundPropInternal;
22
+ //# sourceMappingURL=re-exports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"re-exports.d.ts","sourceRoot":"","sources":["../../src/atoms/re-exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1E;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,6BAAuB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /** Schema metadata for atom props/events. */
2
+ import { z } from 'zod';
3
+ /**
4
+ * Prop metadata (e.g. control hint and field type for Design Studio).
5
+ * @public
6
+ */
7
+ export type PropMeta = {
8
+ control?: string;
9
+ fieldType?: string;
10
+ };
11
+ /**
12
+ * Attach editor hint (e.g. control type, fieldType) to a prop schema. Metadata is stored under a key that
13
+ * survives JSON Schema conversion for Design Studio.
14
+ * @param {import('zod').ZodType} schema - Zod type for the prop
15
+ * @param {PropMeta} meta - Editor metadata (e.g. control, fieldType)
16
+ * @returns The same Zod type with meta attached (or schema unchanged if .meta is not callable)
17
+ * @public
18
+ */
19
+ export declare function withPropMeta<T extends z.ZodType>(schema: T, meta: PropMeta): T;
20
+ //# sourceMappingURL=schema-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-utils.d.ts","sourceRoot":"","sources":["../../src/atoms/schema-utils.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAIhE;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,GAAG,CAAC,CAM9E"}