@remkoj/optimizely-cms-react 6.0.0-pre9 → 6.0.0-rc.3

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 (53) hide show
  1. package/AGENTS.md +168 -0
  2. package/README.md +3 -4
  3. package/dist/components/client.js.map +1 -1
  4. package/dist/components/cms-content/get-content-type.js +1 -1
  5. package/dist/components/cms-content/get-content-type.js.map +1 -1
  6. package/dist/components/cms-content/get-content.js +1 -1
  7. package/dist/components/cms-content/get-content.js.map +1 -1
  8. package/dist/components/cms-content/resolve-component.js +3 -9
  9. package/dist/components/cms-content/resolve-component.js.map +1 -1
  10. package/dist/components/cms-content/resolve-content-type.js.map +1 -1
  11. package/dist/components/cms-content/types.d.ts +38 -2
  12. package/dist/components/cms-content-area/types.d.ts +51 -10
  13. package/dist/components/cms-editable/index.d.ts +82 -19
  14. package/dist/components/cms-editable/index.js +10 -6
  15. package/dist/components/cms-editable/index.js.map +1 -1
  16. package/dist/components/cms-styles/index.js.map +1 -1
  17. package/dist/components/rich-text/components.d.ts +1 -1
  18. package/dist/components/rich-text/index.d.ts +2 -1
  19. package/dist/components/rich-text/index.js +6 -3
  20. package/dist/components/rich-text/index.js.map +1 -1
  21. package/dist/components/rich-text/utils.js.map +1 -1
  22. package/dist/components/rsc-components.d.ts +154 -5
  23. package/dist/components/rsc-components.js +153 -5
  24. package/dist/components/rsc-components.js.map +1 -1
  25. package/dist/components/visual-builder/functions.js +7 -14
  26. package/dist/components/visual-builder/functions.js.map +1 -1
  27. package/dist/components/visual-builder/index.d.ts +3 -1
  28. package/dist/components/visual-builder/index.js +15 -16
  29. package/dist/components/visual-builder/index.js.map +1 -1
  30. package/dist/context/client.d.ts +12 -12
  31. package/dist/context/client.js +8 -0
  32. package/dist/context/client.js.map +1 -1
  33. package/dist/context/rsc.js +6 -1
  34. package/dist/context/rsc.js.map +1 -1
  35. package/dist/data/queries.js.map +1 -1
  36. package/dist/errors.js +1 -0
  37. package/dist/errors.js.map +1 -1
  38. package/dist/factory/default.d.ts +20 -3
  39. package/dist/factory/default.js +45 -25
  40. package/dist/factory/default.js.map +1 -1
  41. package/dist/factory/index.js.map +1 -1
  42. package/dist/factory/types.d.ts +24 -4
  43. package/dist/factory/undef.d.ts +7 -5
  44. package/dist/factory/undef.js +10 -4
  45. package/dist/factory/undef.js.map +1 -1
  46. package/dist/rsc-utilities.js.map +1 -1
  47. package/dist/rsc.d.ts +24 -0
  48. package/dist/rsc.js +24 -0
  49. package/dist/rsc.js.map +1 -1
  50. package/dist/utilities.d.ts +2 -2
  51. package/dist/utilities.js +12 -7
  52. package/dist/utilities.js.map +1 -1
  53. package/package.json +22 -15
package/AGENTS.md ADDED
@@ -0,0 +1,168 @@
1
+ # @remkoj/optimizely-cms-react — usage
2
+
3
+ React and React Server Component (RSC) integration library for Optimizely CMS.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @remkoj/optimizely-cms-react
9
+ ```
10
+
11
+ ## Subpath exports
12
+
13
+ | Import path | Contents |
14
+ | --- | --- |
15
+ | `@remkoj/optimizely-cms-react` | Client components, factory, core types |
16
+ | `@remkoj/optimizely-cms-react/rsc` | Server Components: `CmsContent`, `CmsContentArea`, `CmsEditable`, `ServerContext`, `OptimizelyComposition`, node helpers |
17
+ | `@remkoj/optimizely-cms-react/utils` | Shared utilities |
18
+
19
+ ## Key types
20
+
21
+ ```typescript
22
+ import type { CmsComponent, CmsComponentProps, ContentType, ComponentTypeDictionary } from '@remkoj/optimizely-cms-react'
23
+
24
+ // A CMS-aware React component
25
+ type CmsComponent<TData, TLayoutProps = Record<string, any>> =
26
+ React.ComponentType<CmsComponentProps<TData, TLayoutProps>>
27
+
28
+ // Props injected into every CMS component
29
+ type CmsComponentProps<TData, TLayoutProps> = {
30
+ contentLink: ContentLinkWithLocale
31
+ data: TData
32
+ inEditMode?: boolean // true when rendering inside On-Page Editor
33
+ layoutProps?: TLayoutProps
34
+ editProps?: ComponentCmsEditableProps
35
+ ctx?: GenericContext
36
+ }
37
+
38
+ // For Section/layout components that receive child nodes from Visual Builder
39
+ // children is also available on CmsComponentProps
40
+ ```
41
+
42
+ ## Component factory
43
+
44
+ ```typescript
45
+ import { DefaultComponentFactory, RichTextComponentDictionary } from '@remkoj/optimizely-cms-react/rsc'
46
+ import type { ComponentTypeDictionary } from '@remkoj/optimizely-cms-react'
47
+
48
+ // Build a flat dictionary to pass to registerAll
49
+ export const myComponents: ComponentTypeDictionary = [
50
+ { type: 'HeroBlock', component: HeroBlockComponent },
51
+ // ...
52
+ ]
53
+
54
+ // Create and populate the factory (server-only — wrap in 'server-only' import)
55
+ const factory = new DefaultComponentFactory()
56
+ factory.registerAll(RichTextComponentDictionary) // register built-in rich text nodes
57
+ factory.registerAll(myComponents)
58
+ ```
59
+
60
+ ## RSC components (import from `./rsc`)
61
+
62
+ ```typescript
63
+ import {
64
+ CmsContent,
65
+ CmsContentArea,
66
+ CmsEditable,
67
+ RichText,
68
+ ServerContext,
69
+ OptimizelyComposition,
70
+ isNode,
71
+ isComponentNode,
72
+ isStructureNode,
73
+ } from '@remkoj/optimizely-cms-react/rsc'
74
+
75
+ // Render a single content item by content link
76
+ <CmsContent contentLink={{ key: content._metadata.key, locale: 'en' }} ctx={ctx} />
77
+
78
+ // Render a content area (list of content items)
79
+ <CmsContentArea fieldName="MainContentArea" items={content.MainContentArea} ctx={ctx} />
80
+
81
+ // Wrap editable regions in OPE — cmsId marks the content item, cmsFieldName marks individual fields
82
+ <CmsEditable as="section" cmsId={contentLink.key} ctx={ctx}>...</CmsEditable>
83
+ <CmsEditable as="h1" cmsFieldName="Heading" ctx={ctx}>{heading}</CmsEditable>
84
+
85
+ // Render Visual Builder experience compositions
86
+ const composition = getFragmentData(ExperienceDataFragmentDoc, data).composition
87
+ if (composition && isNode(composition))
88
+ return <OptimizelyComposition node={composition} ctx={ctx} />
89
+ ```
90
+
91
+ ## ServerContext
92
+
93
+ Create once per request (e.g. in the root layout) and pass as `ctx` to all CMS components.
94
+
95
+ ```typescript
96
+ import 'server-only'
97
+ import { ServerContext } from '@remkoj/optimizely-cms-react/rsc'
98
+ import { createClient } from '@remkoj/optimizely-graph-client'
99
+
100
+ const client = createClient(undefined, undefined, { nextJsFetchDirectives: true, cache: true, queryCache: true })
101
+ const ctx = new ServerContext({ locale: 'en', factory, client })
102
+ ```
103
+
104
+ `ServerContext` exposes `client`, `factory`, `locale`, `inEditMode`, `inPreviewMode`, `isDevelopment`, `isDebug`.
105
+
106
+ ## Component patterns
107
+
108
+ ### Block / Component
109
+
110
+ ```typescript
111
+ import { type CmsComponent } from '@remkoj/optimizely-cms-react'
112
+ import { CmsEditable } from '@remkoj/optimizely-cms-react/rsc'
113
+ import { MyBlockDataFragmentDoc, type MyBlockDataFragment } from '@/gql/graphql'
114
+
115
+ export const MyBlock: CmsComponent<MyBlockDataFragment> = ({ data, contentLink, inEditMode, ctx }) => {
116
+ return <CmsEditable as="section" cmsId={contentLink.key} ctx={ctx}>...</CmsEditable>
117
+ }
118
+ MyBlock.displayName = 'My Block (Component/MyBlock)'
119
+ MyBlock.getDataFragment = () => ['MyBlockData', MyBlockDataFragmentDoc]
120
+ ```
121
+
122
+ ### Page
123
+
124
+ ```typescript
125
+ import { type OptimizelyNextPage } from '@remkoj/optimizely-cms-nextjs'
126
+ import { MyPageDataFragmentDoc, type MyPageDataFragment } from '@/gql/graphql'
127
+
128
+ export const MyPage: OptimizelyNextPage<MyPageDataFragment> = ({ data, ctx }) => { ... }
129
+ MyPage.getDataFragment = () => ['MyPageData', MyPageDataFragmentDoc]
130
+ MyPage.getMetaData = async (contentLink, locale, client) => ({ title: '...' })
131
+ ```
132
+
133
+ ### Section (Visual Builder layout node)
134
+
135
+ Section components receive `children` (rendered child nodes) and `layoutProps` (display template data).
136
+
137
+ ```typescript
138
+ import { type CmsComponent } from '@remkoj/optimizely-cms-react'
139
+ import { CmsEditable } from '@remkoj/optimizely-cms-react/rsc'
140
+
141
+ export const MySection: CmsComponent<MySectionDataFragment, MyLayoutProps> = ({ contentLink, layoutProps, children, ctx }) => {
142
+ return <CmsEditable as="div" cmsId={contentLink.key} ctx={ctx}>{children}</CmsEditable>
143
+ }
144
+ MySection.getDataFragment = () => ['MySectionData', MySectionDataFragmentDoc]
145
+ ```
146
+
147
+ ### Experience
148
+
149
+ ```typescript
150
+ if (ctx) ctx.editableContentIsExperience = true
151
+ const composition = getFragmentData(ExperienceDataFragmentDoc, data).composition
152
+ return <div>{composition && isNode(composition) && <OptimizelyComposition node={composition} ctx={ctx} />}</div>
153
+ ```
154
+
155
+ ## Utilities (import from `./utils`)
156
+
157
+ ```typescript
158
+ import { Utils } from '@remkoj/optimizely-cms-react'
159
+ // or
160
+ import { isNonEmptyString, slugify } from '@remkoj/optimizely-cms-react/utils'
161
+ ```
162
+
163
+ ## Constraints
164
+
165
+ - RSC components (`./rsc`) are server-only; do not import in client components.
166
+ - Always pass `ctx` down from layout to leaf components; components warn at runtime when `ctx` is missing.
167
+ - `ContentLink` and `ContentLinkWithLocale` are re-exported from `@remkoj/optimizely-graph-client` (direct import preferred).
168
+ - `RichTextComponentDictionary` must be registered on the factory before passing it to `ServerContext`.
package/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Optimizely SaaS CMS React Components
2
+
2
3
  > [!WARNING]
3
- > This documentation is for V3 and up. This version introduced a number of breaking changes - most notably it significantly simplified the exports.
4
- >
5
- > For some of the commonly used old exports it still contains placeholders, however those are deprecated and will be removed in a future version
4
+ > There'll be an update of Optimizely SaaS CMS that is incompatible with all SDK versions prior to 5.1.6. If you don't upgrade, you will see empty pages (main website) and "Component not found" messages (preview).
6
5
 
7
6
  This package provides two main entry points, depending on your build environment:
8
7
  - `@remkoj/optimizely-cms-react` This export contains the library, whith React components that use a client side context
@@ -46,4 +45,4 @@ An entry within the factory consists of the following fields:
46
45
  - ***type:*** The identifier of the content type, can either be an array of strings or a string. The implementation *should* normalize the type. The `DefaultComponentFactory` normalized to a string, using `/` as item separator.
47
46
  - ***component:*** The component to do the actual rendering of the data. *The factory is indifferent to the actual type, so this could be the output of `next/dynamic` to trigger bundle splitting in Next.js.*
48
47
  - ***useSuspense:*** When set to `true` the component will be wrapped in the `<Suspense></Suspense>` from React. Optional, the default value is `false`.
49
- - ***loader:*** The component to show while Suspense is awaiting the actual component. This component is given to the `fallback` property of `<Suspense>`. Optional, the default value is `undefined`.
48
+ - ***loader:*** The component to show while Suspense is awaiting the actual component. This component is given to the `fallback` property of `<Suspense>`. Optional, the default value is `undefined`.
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/components/client.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAGZ,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EAAE,cAAc,IAAI,eAAe,EAAgC,MAAM,6BAA6B,CAAA,CAAC,4BAA4B;AAC1I,OAAO,EAAE,WAAW,IAAI,YAAY,EAA6B,MAAM,yBAAyB,CAAA,CAAC,4BAA4B;AAC7H,OAAO,EAAE,UAAU,IAAI,cAAc,EAA4B,MAAM,yBAAyB,CAAA,CAAC,wCAAwC;AACzI,OAAO,EAAE,qBAAqB,IAAI,yBAAyB,EAAuC,MAAM,2BAA2B,CAAA,CAAC,4BAA4B;AAChK,OAAO,EAAE,QAAQ,IAAI,YAAY,EAA0B,MAAM,sBAAsB,CAAA;AAIvF,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC9H,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEpE;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,YAAY,CAAsB,CAAA;AAE7E,OAAO,EAAE,iBAAiB,IAAI,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,2BAA2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;AAGzH;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC,kBAAkB,CAAC,yBAAyB,CAAC,EAAE,UAAU,CAAmC,CAAA"}
@@ -34,7 +34,7 @@ export async function getContentType(link, gqlClient) {
34
34
  console.error(`🔴 [CmsContent][getContentType] Expected exactly one type, received ${gqlResponse.Content?.total ?? 0} types for`, gqlQueryVars);
35
35
  return undefined;
36
36
  }
37
- const contentType = normalizeContentType(gqlResponse.Content?.item?._metadata?.types);
37
+ const contentType = normalizeContentType(gqlResponse.Content?.item?.metadata?.types);
38
38
  if (!contentType) {
39
39
  console.error(`🔴 [CmsContent][getContentType] The item did not contain type information! (${contentLinkToString(link)})`);
40
40
  throw new Error("The item did not contain type information");
@@ -1 +1 @@
1
- {"version":3,"file":"get-content-type.js","sourceRoot":"","sources":["../../../src/components/cms-content/get-content-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,mBAAmB,EAAmE,MAAM,iCAAiC,CAAA;AAE1K,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAIxF,MAAM,UAAU,kBAAkB,CAAI,KAAQ;IAC5C,MAAM,EAAE,GAAmB;QACzB,IAAI,EAAE,CAAe,WAAiF,EAAE,EAAE;YACxG,IAAI,CAAC,WAAW;gBACd,OAAO,KAAyC,CAAA;YAClD,OAAO,WAAW,CAAC,KAAK,CAA0B,CAAA;QACpD,CAAC;KACF,CAAA;IACD,OAAO,EAAE,CAAA;AACX,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAqC,EAAE,SAA2B;IACrG,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,4GAA4G,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,CAA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I,SAAS,CAAC,KAAK;YACjB,OAAO,CAAC,KAAK,CAAC,uEAAuE,WAAW,CAAC,OAAO,EAAE,KAAK,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;QACjJ,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,WAAW,GAAG,oBAAoB,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;IACpF,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,CAAC,KAAK,CAAC,+EAA+E,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC1H,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;IAC9D,CAAC;IAED,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,eAAe,cAAc,CAAA;AAa7B,MAAM,mBAAmB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;EAe7B,CAAA"}
@@ -17,7 +17,7 @@ export function getContent(client, contentLink, Component, fragmentData, noDataL
17
17
  }
18
18
  else if (client?.isPreviewEnabled() && isContentLink(contentLink) && !isInlineContentLink(contentLink)) {
19
19
  if (debug)
20
- console.warn("🔴 [CmsContent][getContent] Rendering shared instance, while in preview mode, falling back to loading for ", componentLabel);
20
+ console.warn(`🔴 [CmsContent][getContent] Rendering shared instance (${JSON.stringify(contentLink)}), while in preview mode, falling back to loading for ${componentLabel}`);
21
21
  contentLink.version = null;
22
22
  // Default mode, use fragment
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-content.js","sourceRoot":"","sources":["../../../src/components/cms-content/get-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,MAAM,SAAS,CAAA;AAExC,OAAO,EAAmE,aAAa,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErK,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,6BA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MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,QAA0B,EAAE,EAAE,CAAC,8UAA8U,IAAI,SAAS,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAA;AAC7d,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,QAA0B,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;;WAkB3D,IAAI;;;;EAIb,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAA"}
@@ -24,22 +24,16 @@ export function resolveComponent(contentType, prefix, variant, ctx) {
24
24
  console.error(`🔴 [CmsContent][resolveComponent] No content type factory registered in the context`);
25
25
  throw new Error('Empty factory on the context');
26
26
  }
27
- // Optimizely Graph stores the type in Most Significant first order, we need least significant first, also we're stripping out the common "Content" item from it
28
- const myContentType = prefix
29
- ? Utils.normalizeAndPrefixContentType(Array.isArray(contentType) ? [...contentType].reverse() : contentType, prefix)
30
- : Utils.normalizeContentType(Array.isArray(contentType) ? [...contentType].reverse() : contentType, true);
27
+ // Make sure that we normalize the input from graph into a string array
28
+ const myContentType = Utils.normalizeContentType(contentType, false);
31
29
  // Validate that we have a value to ask the factory a component for
32
30
  if (!myContentType || myContentType.length == 0) {
33
31
  if (isDebug)
34
32
  console.error(`🔴 [CmsContent][resolveComponent] The content type ${JSON.stringify(contentType)}, with prefix ${JSON.stringify(prefix)} yielded an empty normalized type`);
35
33
  throw new Error(`The content type ${JSON.stringify(contentType)}, with prefix ${JSON.stringify(prefix)} yielded an empty normalized type`);
36
34
  }
37
- /*if (isDebug)
38
- console.log(
39
- `⚪ [CmsContent][resolveComponent] Normalized content type ${JSON.stringify(contentType)} to ${myContentType}`
40
- )*/
41
35
  // Resolve component
42
- const Component = Utils.resolveComponentType(factory, myContentType, variant ? [variant] : []);
36
+ const Component = Utils.resolveComponentType(factory, myContentType, [variant, prefix].filter(Utils.isNotNullOrUndefined));
43
37
  // Handle component not found in factory
44
38
  if (!Component) {
45
39
  const contentTypeDisplay = Array.isArray(myContentType)
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-component.js","sourceRoot":"","sources":["../../../src/components/cms-content/resolve-component.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAS3C,MAAM,UAAU,iBAAiB,CAAC,iBAAwC;IACxE,IAAI,CAAC,iBAAiB;QAAE,OAAO,KAAK,CAAA;IACpC,IAAI,iBAAiB,CAAC,WAAW;QAAE,OAAO,iBAAiB,CAAC,WAAW,CAAA;IACvE,IAAI,OAAO,iBAAiB,IAAI,UAAU,IAAI,iBAAiB,CAAC,IAAI;QAClE,OAAO,iBAAiB,CAAC,IAAI,CAAA;IAC/B,OAAO,iBAAiB,CAAC,QAAQ,EAAE,CAAA;AACrC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,WAAmD,EACnD,MAAiC,EACjC,OAAkC,EAClC,GAAmB;IAEnB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;IAE5C,sFAAsF;IACtF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CACX,qFAAqF,CACtF,CAAA;QACD,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;IACjD,CAAC;IAED,gKAAgK;IAChK,MAAM,aAAa,GAAG,MAAM;QAC1B,CAAC,CAAC,KAAK,CAAC,6BAA6B,CACjC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,EACrE,MAAM,CACP;QACH,CAAC,CAAC,KAAK,CAAC,oBAAoB,CACxB,KAAK,CAAC,OA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AAE,IACxD,EACL,QAAQ,IACR,CACJ,CAAA;YACD,cAAc,CAAC,WAAW,GAAG,wBAAwB,CAAA;YACrD,OAAO,cAAc,CAAA;QACvB,CAAC;QACD,MAAM,cAAc,GAA8B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAA;QAC3E,cAAc,CAAC,WAAW,GAAG,wBAAwB,CAAA;QACrD,OAAO,cAAc,CAAA;IACvB,CAAC;IAED,uBAAuB;IACvB;;;;SAIK;IACL,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,eAAe,gBAAgB,CAAA;AAQ/B,MAAM,UAAU,2BAA2B,CACzC,MAA6C;IAE7C,OAAO,MAAM,EAAE,WAAW,IAAI,wBAAwB,CAAA;AACxD,CAAC"}
1
+ {"version":3,"file":"resolve-component.js","sourceRoot":"","sources":["../../../src/components/cms-content/resolve-component.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAS3C,MAAM,UAAU,iBAAiB,CAAC,iBAAwC;IACxE,IAAI,CAAC,iBAAiB;QAAE,OAAO,KAAK,CAAA;IACpC,IAAI,iBAAiB,CAAC,WAAW;QAAE,OAAO,iBAAiB,CAAC,WAAW,CAAA;IACvE,IAAI,OAAO,iBAAiB,IAAI,UAAU,IAAI,iBAAiB,CAAC,IAAI;QAClE,OAAO,iBAAiB,CAAC,IAAI,CAAA;IAC/B,OAAO,iBAAiB,CAAC,QAAQ,EAAE,CAAA;AACrC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,WAAmD,EACnD,MAAiC,EACjC,OAAkC,EAClC,GAAmB;IAEnB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;IAE5C,sFAAsF;IACtF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CACX,qFAAqF,CACtF,CAAA;QACD,MAAM,IAAI,KAAK,CAAC,8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D,EACL,QAAQ,IACR,CACJ,CAAA;YACD,cAAc,CAAC,WAAW,GAAG,wBAAwB,CAAA;YACrD,OAAO,cAAc,CAAA;QACvB,CAAC;QACD,MAAM,cAAc,GAA8B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAA;QAC3E,cAAc,CAAC,WAAW,GAAG,wBAAwB,CAAA;QACrD,OAAO,cAAc,CAAA;IACvB,CAAC;IAED,uBAAuB;IACvB;;;;SAIK;IACL,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,eAAe,gBAAgB,CAAA;AAQ/B,MAAM,UAAU,2BAA2B,CACzC,MAA6C;IAE7C,OAAO,MAAM,EAAE,WAAW,IAAI,wBAAwB,CAAA;AACxD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-content-type.js","sourceRoot":"","sources":["../../../src/components/cms-content/resolve-content-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAA0D,EAAE,YAAyC;IAEpI,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;QACrD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;YACnB,OAAO,QAAQ,CAAA;IACvB,CAAC;SAAM,IAAI,OAAM,CAAC,WAAW,CAAC,IAAI,QAAQ,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAChE,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAEjC,IAAI,YAAY,EAAE,CAAC;QACf,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,EAAE,KAAK,CAAA;QAC/C,IAAI,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YACrC,OAAO,kBAAkB,CAAC,SAAS,CAAC,CAAA;IAC5C,CAAC;IAED,OAAO,SAAS,CAAA;AACpB,CAAC;AAED,eAAe,kBAAkB,CAAA"}
1
+ {"version":3,"file":"resolve-content-type.js","sourceRoot":"","sources":["../../../src/components/cms-content/resolve-content-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAA0D,EAAE,YAAyC;IAEtI,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;QACrD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;YACrB,OAAO,QAAQ,CAAA;IACnB,CAAC;SAAM,IAAI,OAAM,CAAC,WAAW,CAAC,IAAI,QAAQ,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAClE,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE/B,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,EAAE,KAAK,CAAA;QAC/C,IAAI,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YACvC,OAAO,kBAAkB,CAAC,SAAS,CAAC,CAAA;IACxC,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,eAAe,kBAAkB,CAAA"}
@@ -2,6 +2,42 @@ import { type PropsWithChildren, type ComponentType, type ComponentProps, type R
2
2
  import type { CmsComponent } from '../../types.js';
3
3
  import type { PropsWithContext, PropsWithOptionalContext } from "../../context/types.js";
4
4
  import type { ContentLinkWithLocale, InlineContentLinkWithLocale } from "@remkoj/optimizely-graph-client";
5
+ /**
6
+ * Properties for `CmsContent`.
7
+ *
8
+ * `CmsContent` resolves and renders a CMS template component for the item
9
+ * identified by `contentLink`.
10
+ *
11
+ * Property overview:
12
+ * - `contentLink` (required): content identity (`key` + optional locale).
13
+ * - `contentType`: explicit content type array; skips content-type lookup when set.
14
+ * - `contentTypePrefix`: template prefix (for example `Page`, `Component`).
15
+ * - `variant`: template variant suffix.
16
+ * - `fragmentData`: preloaded data for rendering.
17
+ * - `noDataLoad`: skip loading data from Graph.
18
+ * - `layoutProps`: layout metadata forwarded to resolved component.
19
+ * - `editorComponentId`: explicit editor id override for `editProps.cmsId`.
20
+ * - `ctx`: explicit CMS context override.
21
+ * - `children`: nested content passed through to resolved component.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * <CmsContent
26
+ * contentLink={{ key: 'b9f76fd06f5d4e2e8d2cc3f010f7abf9', locale: 'en' }}
27
+ * contentTypePrefix="Page"
28
+ * />
29
+ * ```
30
+ *
31
+ * @example
32
+ * ```tsx
33
+ * <CmsContent
34
+ * contentLink={{ key: '4f9ac0f95ed147b6956c9f6bd4151f38' }}
35
+ * contentType={["Component", "HeroBlock"]}
36
+ * fragmentData={heroData}
37
+ * noDataLoad
38
+ * />
39
+ * ```
40
+ */
5
41
  export type CmsContentProps<LocalesType = string> = PropsWithChildren<PropsWithOptionalContext<{
6
42
  /**
7
43
  * The content type to render
@@ -31,7 +67,7 @@ export type CmsContentProps<LocalesType = string> = PropsWithChildren<PropsWithO
31
67
  [fieldname: string]: any;
32
68
  };
33
69
  /**
34
- * The native key to use when the element is part of an array
70
+ * React key to use when the component is rendered in a list.
35
71
  */
36
72
  key?: string;
37
73
  /**
@@ -46,7 +82,7 @@ export type CmsContentProps<LocalesType = string> = PropsWithChildren<PropsWithO
46
82
  */
47
83
  variant?: string;
48
84
  /**
49
- * Any layout properties inferred from the context
85
+ * Additional layout properties forwarded to the resolved CMS template.
50
86
  */
51
87
  layoutProps?: Record<string, any>;
52
88
  /**
@@ -53,31 +53,31 @@ export type ItemsProperty<T extends ElementType> = "children" extends ElementChi
53
53
  export type PassthroughProps<T extends ElementType, ParentKeys extends string | number | symbol> = Omit<ElementProps<T>, ParentKeys | ReservedKeys | ElementChildrenProps<T>>;
54
54
  export type CmsContentAreaCoreProps = PropsWithOptionalContext<{
55
55
  /**
56
- * The content area items to be rendered
56
+ * Content area items to render.
57
+ *
58
+ * Each item should contain `_metadata` with at least a key and content type data.
57
59
  */
58
60
  items: (ContentAreaItemDefinition | null | undefined)[] | undefined | null;
59
61
  /**
60
- * Whether or not a suspense must be applied around each item of the
61
- * ContentArea to allow dynamic content within the ContentArea items.
62
+ * Whether a suspense boundary is applied around each rendered content area item.
62
63
  */
63
64
  useSuspense?: boolean;
64
65
  /**
65
- * The fallback component to use as suspense boundary
66
+ * Fallback UI rendered while suspense-wrapped items are loading.
66
67
  */
67
68
  fallback?: SuspenseProps['fallback'];
68
69
  /**
69
- * The fieldname of this content area, provide this to allow in-context
70
- * editing
70
+ * Name of the CMS field represented by this content area.
71
+ *
72
+ * Set this to enable in-context edit markers for the content area container.
71
73
  */
72
74
  fieldName?: string;
73
75
  /**
74
- * If set to true, there will be no wrapping element around the
75
- * items in the Content Area. Setting this to `true` ignores
76
+ * If `true`, no container wrapper is rendered around the full list of items.
76
77
  */
77
78
  noWrapper?: boolean;
78
79
  /**
79
- * Allows requesting of specific template variant, to accomodate different
80
- * renditions, without changing the main path of the component.
80
+ * Optional template variant forwarded to each `CmsContent` item render.
81
81
  */
82
82
  variant?: string;
83
83
  }>;
@@ -117,6 +117,47 @@ export type CmsContentAreaItemWrapperProps<CT extends ElementType> = ({
117
117
  */
118
118
  className?: MayBeArray<PropTypeIfPropExists<CT, "className">>;
119
119
  } & ItemsProperty<CT> & PassthroughProps<CT, "as" | "noWrapper" | "className">);
120
+ /**
121
+ * Properties for `CmsContentArea`.
122
+ *
123
+ * Combines core rendering options and wrapper customization options.
124
+ *
125
+ * Property overview:
126
+ * - `items` (required): content area items to render.
127
+ * - `fieldName`: enables edit marker output for the content area.
128
+ * - `variant`: template variant for all rendered items.
129
+ * - `useSuspense` + `fallback`: per-item suspense rendering.
130
+ * - `noWrapper`: disables outer content area container.
131
+ * - `as`: outer container element/component.
132
+ * - `itemsProperty`: target prop on `as` component to inject item list.
133
+ * - `className`: classes for outer container.
134
+ * - `classMapper`: computes per-item wrapper classes from display option/type/index.
135
+ * - `itemWrapper`: configures per-item wrapper element, classes and prop target.
136
+ * - `ctx`: optional CMS context override.
137
+ *
138
+ * @example
139
+ * ```tsx
140
+ * <CmsContentArea
141
+ * items={content.MainContentArea}
142
+ * fieldName="MainContentArea"
143
+ * as="section"
144
+ * className="main-content"
145
+ * />
146
+ * ```
147
+ *
148
+ * @example
149
+ * ```tsx
150
+ * <CmsContentArea
151
+ * items={content.SidebarContentArea}
152
+ * itemWrapper={{ as: 'aside', className: 'sidebar-item' }}
153
+ * classMapper={(displayOption, contentType, index) =>
154
+ * `item-${index} display-${displayOption} type-${contentType?.join('-') ?? 'unknown'}`
155
+ * }
156
+ * useSuspense
157
+ * fallback={<div>Loading…</div>}
158
+ * />
159
+ * ```
160
+ */
120
161
  export type CmsContentAreaProps<T extends ElementType, CT extends ElementType> = CmsContentAreaCoreProps & CmsContentAreaWrapperProps<T, CT>;
121
162
  export type CmsContentAreaClassMapper = (displayOption: string, contentType: ContentType | null, index: number) => string;
122
163
  export type BaseCmsContentAreaProps<T extends ElementType, CT extends ElementType> = PropsWithCmsContent<PropsWithContext<CmsContentAreaProps<T, CT>>>;
@@ -2,51 +2,114 @@ import { PropsWithChildren, type ReactNode } from 'react';
2
2
  import { GenericContext, PropsWithContext } from '../../context/types.js';
3
3
  import type { ElementType, GenericContextProps, ElementProps } from '../type-utils.js';
4
4
  import { type ContentLink } from '@remkoj/optimizely-graph-client';
5
+ /**
6
+ * Properties for `CmsEditable`.
7
+ *
8
+ * `CmsEditable` wraps output with Optimizely edit markers so fields and blocks can be
9
+ * selected in edit mode.
10
+ *
11
+ * Quick start:
12
+ * - Provide `cmsId` for block/content identification.
13
+ * - Provide `cmsFieldName` when you want field-level editing.
14
+ * - Choose wrapper element with `as` (defaults to `div`).
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * <CmsEditable as="section" cmsId={content._metadata.key} cmsFieldName="MainBody">
19
+ * <p>{content.MainBody}</p>
20
+ * </CmsEditable>
21
+ * ```
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * <CmsEditable
26
+ * as="h2"
27
+ * cmsId={content._metadata.key}
28
+ * cmsFieldName="Heading"
29
+ * editType="inline"
30
+ * >
31
+ * {content.Heading}
32
+ * </CmsEditable>
33
+ * ```
34
+ */
5
35
  export type CmsEditableProps<FT extends ElementType> = PropsWithChildren<{
6
36
  /**
7
- * Override the component used to render, instead of wrapping the children. It allows
8
- * any valid JSX identifier (e.g. HTML Element, Component or ExoticComponent)
37
+ * Wrapper element or component used for rendering.
38
+ *
39
+ * Defaults to `div`.
40
+ * Accepts intrinsic elements (for example `"span"`, `"section"`) or custom
41
+ * React components.
9
42
  */
10
43
  as?: FT;
11
44
  /**
12
- * The identifier of the component wrapped in this CmsEditable component. This will
13
- * add the 'data-epi-block-id' property to the component.
45
+ * Identifier of the rendered CMS content item.
46
+ *
47
+ * When edit attributes are active, this is written to `data-epi-block-id` and/or
48
+ * `data-epi-content-id`.
49
+ *
50
+ * Recommended value: content key from your model metadata.
14
51
  */
15
52
  cmsId?: string | null;
16
53
  /**
17
- * The name of the component field wrapped by this CmsEditable component. This will
18
- * add the 'data-epi-property-name' property to the component.
54
+ * Field name to mark as editable (for example `"Heading"`, `"MainBody"`).
55
+ *
56
+ * In edit mode this enables field-level highlighting/editing metadata.
19
57
  */
20
58
  cmsFieldName?: string | null;
21
59
  /**
22
- * The Context to be used when determining if the page rendering happens in edit mode
23
- * or not.
60
+ * Optional CMS context override.
61
+ *
62
+ * Use this when you need to provide context explicitly; otherwise context is resolved
63
+ * by the caller/wrapper.
24
64
  */
25
65
  ctx?: GenericContext;
26
66
  /**
27
- * The default CTX paramteer is caught by this component, set this to true to pass the
28
- * `ctx` property to the 'as' Component, or set to a valid property name to pass into
29
- * that property.
67
+ * Forward `ctx` to the custom `as` component.
68
+ *
69
+ * - `true` (default): forward as prop name `ctx`.
70
+ * - `false`: do not forward context.
71
+ * - `"propName"`: forward using custom prop name.
72
+ *
73
+ * Ignored for intrinsic HTML elements.
74
+ *
75
+ * If the component passed through `as` is on the opposite rendering side,
76
+ * set this to `false` to prevent boundary issues:
77
+ * - `CmsEditable` on client + `as` server component -> use `forwardCtx={false}`
78
+ * - `CmsEditable` on server + `as` client component -> use `forwardCtx={false}`
30
79
  */
31
80
  forwardCtx?: boolean | GenericContextProps<FT>;
32
81
  /**
33
- * If set, the `data-epi-block-id` attribute will always be included when the `cmsId`
34
- * parameter is being set.
82
+ * Force adding `data-epi-block-id` when `cmsId` is present.
83
+ *
84
+ * Useful when you need block-level markers even if the default filtering logic would
85
+ * otherwise suppress them.
35
86
  */
36
87
  forceBlockId?: boolean;
37
88
  /**
38
- * If set `CmsEditable` will output both `cmsId` and `cmsFieldName` (if both are provided)
39
- * otherwise it will prioritize `cmsFieldName`.
89
+ * Reserved compatibility flag.
90
+ *
91
+ * This property is currently accepted for API compatibility but is not used by the
92
+ * current implementation.
93
+ *
94
+ * @deprecated This property is preserved for historical use and should not be used in new code.
40
95
  */
41
96
  forceId?: boolean;
42
97
  /**
43
- * If set, this will be used to test if the content item being rendered is actually
44
- * the one being edited. This allows conditional output of the edit properties. This will
45
- * only affect `cmsFieldName`, not `cmsId`.
98
+ * Content identity check used to conditionally output field-level edit markers.
99
+ *
100
+ * When provided, field attributes are added only if
101
+ * `currentContent.key === editableContent.key`.
102
+ * This condition affects field-level markers, not `cmsId` output.
46
103
  */
47
104
  currentContent?: ContentLink;
48
105
  /**
49
- * Override the value for the `data-epi-property-edittype` property
106
+ * Override edit rendering mode.
107
+ *
108
+ * - `"floating"`: floating editor UI.
109
+ * - `"inline"`: inline editor UI.
110
+ * - `null`/`undefined`: default behavior via `data-epi-edit`.
111
+ *
112
+ * @deprecated The `editType` property is deprecated and should not be used in new code. Future versions may remove support for this property.
50
113
  */
51
114
  editType?: 'floating' | 'inline' | null;
52
115
  } & Omit<ElementProps<FT>, 'as' | 'cmsId' | 'cmsFieldName' | 'ctx' | 'forwardCtx' | 'forceBlockId' | 'forceId' | 'currentContent' | 'editType'>>;
@@ -24,17 +24,21 @@ export const CmsEditable = ({ ctx, forwardCtx = false, as, cmsId = null, cmsFiel
24
24
  }
25
25
  const addEditProps = inEditMode
26
26
  ? currentContent
27
- ? editableContent?.key == currentContent.key
27
+ ? editableContent?.key === currentContent.key
28
28
  : true
29
29
  : false;
30
30
  // If we're rendering for an experience, we don't need to inject property names, as the
31
31
  // experience editor only deals with property ids - injecting property names will cause
32
32
  // it to outline incorrect items.
33
- const dataEpiPropertyName = editableContentIsExperience
33
+ const dataEpiPropertyName = false && editableContentIsExperience
34
34
  ? undefined
35
35
  : (cmsFieldName ?? undefined);
36
- const showBlockId = cmsId && cmsId?.length != 32 && (forceBlockId || !dataEpiPropertyName);
37
- const showContentId = cmsId?.length == 32 && (forceBlockId || !dataEpiPropertyName);
36
+ const showBlockId = forceBlockId || (cmsId && editableContent?.key ?
37
+ editableContent.key !== cmsId :
38
+ true);
39
+ const showContentId = forceBlockId || (cmsId?.length == 32 && (cmsId && editableContent?.key ?
40
+ editableContent.key !== cmsId :
41
+ true));
38
42
  const itemProps = addEditProps
39
43
  ? {
40
44
  ...props,
@@ -43,9 +47,9 @@ export const CmsEditable = ({ ctx, forwardCtx = false, as, cmsId = null, cmsFiel
43
47
  // We assume GUIDs are represented as 32 char long strings
44
48
  'data-epi-content-id': showContentId ? cmsId : undefined,
45
49
  // We pass through the property name if provided
46
- 'data-epi-property-name': dataEpiPropertyName,
50
+ 'data-epi-property-name': editType ? dataEpiPropertyName : undefined,
47
51
  // We pass through the property name if provided
48
- 'data-epi-edit': dataEpiPropertyName,
52
+ 'data-epi-edit': editType ? undefined : dataEpiPropertyName,
49
53
  // Configure the rendition of the property editor
50
54
  'data-epi-property-edittype': editType ?? undefined,
51
55
  }