@remkoj/optimizely-cms-react 4.0.0-rc1 → 4.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/components/client.d.ts +8 -6
- package/dist/components/client.js +7 -6
- package/dist/components/client.js.map +1 -1
- package/dist/components/rich-text/components.d.ts +15 -0
- package/dist/components/rich-text/components.js +31 -8
- package/dist/components/rich-text/components.js.map +1 -1
- package/dist/components/rich-text/index.d.ts +2 -1
- package/dist/components/rich-text/index.js +23 -11
- package/dist/components/rich-text/index.js.map +1 -1
- package/dist/components/rich-text/types.d.ts +18 -1
- package/dist/components/rich-text/utils.d.ts +3 -2
- package/dist/components/rich-text/utils.js +9 -6
- package/dist/components/rich-text/utils.js.map +1 -1
- package/dist/components/rsc.d.ts +5 -2
- package/dist/components/rsc.js +7 -4
- package/dist/components/rsc.js.map +1 -1
- package/dist/components.d.ts +4 -2
- package/dist/components.js +6 -2
- package/dist/components.js.map +1 -1
- package/dist/factory/default.d.ts +1 -0
- package/dist/factory/default.js +10 -5
- package/dist/factory/default.js.map +1 -1
- package/dist/factory/types.d.ts +13 -2
- package/package.json +8 -10
|
@@ -6,9 +6,15 @@ import { type CmsContentComponent } from './cms-content/client.js';
|
|
|
6
6
|
import { type OptimizelyCompositionComponent } from './visual-builder/index.js';
|
|
7
7
|
import { type RichTextComponent } from './rich-text/index.js';
|
|
8
8
|
export type { BaseStyleDefinition, ElementStyleDefinition, LayoutProps, LayoutPropsSetting, LayoutPropsSettingChoices, LayoutPropsSettingKeys, LayoutPropsSettingValues, NodeStyleDefinition, StyleDefinition, StyleSetting } from "./cms-styles/index.js";
|
|
9
|
+
export { isNode, isElementNode, isComponentNode, isComponentNodeOfType, isStructureNode } from "./visual-builder/functions.js";
|
|
9
10
|
export { extractSettings, readSetting } from "./cms-styles/index.js";
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Client side renderer for Rich Text
|
|
13
|
+
*/
|
|
14
|
+
export declare const RichText: RichTextComponent;
|
|
15
|
+
export type { RichTextComponent, RichTextProps, RichTextNode, StringNode, TypedNode, NodeInput } from "./rich-text/index.js";
|
|
16
|
+
export { DefaultComponents as RichTextComponentDictionary, createHtmlComponent } from './rich-text/components.js';
|
|
17
|
+
export { isNodeInput, isNonEmptyString, isRichTextNode, isStringNode, isText, isTypedNode } from "./rich-text/utils.js";
|
|
12
18
|
/**
|
|
13
19
|
* Wrapper function to turn context dependant components into easy to use
|
|
14
20
|
* client components
|
|
@@ -39,7 +45,3 @@ export type { CmsContentAreaClassMapper, CmsContentAreaComponent, CmsContentArea
|
|
|
39
45
|
* dictionary.
|
|
40
46
|
*/
|
|
41
47
|
export declare const OptimizelyComposition: OptimizelyCompositionComponent;
|
|
42
|
-
/**
|
|
43
|
-
* Client side renderer for Rich Text
|
|
44
|
-
*/
|
|
45
|
-
export declare const RichText: RichTextComponent;
|
|
@@ -7,9 +7,14 @@ import { CmsEditable as BaseEditable } from './cms-editable/index.js'; // Both R
|
|
|
7
7
|
import { CmsContent as BaseCmsContent } from './cms-content/client.js'; // Different components for RSC & Client
|
|
8
8
|
import { OptimizelyComposition as BaseOptimizelyComposition } from './visual-builder/index.js'; // Both RSC & Client capable
|
|
9
9
|
import { RichText as BaseRichText } from './rich-text/index.js';
|
|
10
|
+
export { isNode, isElementNode, isComponentNode, isComponentNodeOfType, isStructureNode } from "./visual-builder/functions.js";
|
|
10
11
|
export { extractSettings, readSetting } from "./cms-styles/index.js";
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Client side renderer for Rich Text
|
|
14
|
+
*/
|
|
15
|
+
export const RichText = clientContextAware(BaseRichText);
|
|
16
|
+
export { DefaultComponents as RichTextComponentDictionary, createHtmlComponent } from './rich-text/components.js';
|
|
17
|
+
export { isNodeInput, isNonEmptyString, isRichTextNode, isStringNode, isText, isTypedNode } from "./rich-text/utils.js";
|
|
13
18
|
/**
|
|
14
19
|
* Wrapper function to turn context dependant components into easy to use
|
|
15
20
|
* client components
|
|
@@ -45,8 +50,4 @@ export const CmsContentArea = cmsContentAware(clientContextAware(BaseContentArea
|
|
|
45
50
|
* dictionary.
|
|
46
51
|
*/
|
|
47
52
|
export const OptimizelyComposition = cmsContentAware(clientContextAware(BaseOptimizelyComposition), CmsContent);
|
|
48
|
-
/**
|
|
49
|
-
* Client side renderer for Rich Text
|
|
50
|
-
*/
|
|
51
|
-
export const RichText = BaseRichText;
|
|
52
53
|
//# sourceMappingURL=client.js.map
|
|
@@ -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,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEpE,
|
|
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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C,MAAM,UAAU,GAAG,kBAAkB,CAAC,cAAc,CAAwB,CAAA;AAGnF;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,UAAU,CAA4B,CAAA;AAGzH;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC,kBAAkB,CAAC,yBAAyB,CAAC,EAAE,UAAU,CAAmC,CAAA"}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { type FunctionComponent, type PropsWithChildren } from "react";
|
|
2
2
|
import { ComponentTypeDictionary } from "../../factory/types.js";
|
|
3
3
|
import type { TextNode, TypedNode } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Create a React Component to render an element within a Rich-Text area.
|
|
6
|
+
* The generated React Component contains the logic to transform the attributes
|
|
7
|
+
* provided by the Rich Text structured data to the appropriate React
|
|
8
|
+
* attributes for rendering.
|
|
9
|
+
*
|
|
10
|
+
* @param element The HTML element
|
|
11
|
+
* @param ignoreChildren If set to `true`, it will output a self-closing
|
|
12
|
+
* element and fully ignoring the children
|
|
13
|
+
* @param defaultProps Override the default attributes that should always
|
|
14
|
+
* be applied, the CSS Classess (defined by the
|
|
15
|
+
* `className` property) will be merged
|
|
16
|
+
*
|
|
17
|
+
* @returns The React Component
|
|
18
|
+
*/
|
|
4
19
|
export declare function createHtmlComponent<E extends keyof JSX.IntrinsicElements>(element: E, ignoreChildren?: boolean, defaultProps?: JSX.IntrinsicElements[E] & Record<string, string>): ({ children, node, ...props }: PropsWithChildren<JSX.IntrinsicElements[E] & {
|
|
5
20
|
node: TypedNode;
|
|
6
21
|
}>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,20 +1,40 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { decodeHTML } from 'entities';
|
|
3
|
+
// Global constants
|
|
4
|
+
const reservedProps = ['url', 'class', 'children', 'type', 'internal', 'base'];
|
|
3
5
|
//#region HTML Components
|
|
6
|
+
/**
|
|
7
|
+
* Create a React Component to render an element within a Rich-Text area.
|
|
8
|
+
* The generated React Component contains the logic to transform the attributes
|
|
9
|
+
* provided by the Rich Text structured data to the appropriate React
|
|
10
|
+
* attributes for rendering.
|
|
11
|
+
*
|
|
12
|
+
* @param element The HTML element
|
|
13
|
+
* @param ignoreChildren If set to `true`, it will output a self-closing
|
|
14
|
+
* element and fully ignoring the children
|
|
15
|
+
* @param defaultProps Override the default attributes that should always
|
|
16
|
+
* be applied, the CSS Classess (defined by the
|
|
17
|
+
* `className` property) will be merged
|
|
18
|
+
*
|
|
19
|
+
* @returns The React Component
|
|
20
|
+
*/
|
|
4
21
|
export function createHtmlComponent(element, ignoreChildren = false, defaultProps) {
|
|
5
22
|
const HtmlElement = element;
|
|
6
|
-
const reservedProps = ['url', 'class', 'children', 'type'];
|
|
7
23
|
const component = ({ children, node, ...props }) => {
|
|
8
24
|
const nodeProps = {};
|
|
9
25
|
const renderProps = Object.getOwnPropertyNames(node);
|
|
26
|
+
// Copy over non-reserved Props
|
|
10
27
|
renderProps.filter(x => !reservedProps.includes(x)).forEach(x => nodeProps[x] = node[x]);
|
|
28
|
+
// Move CSS Class definition into React property name
|
|
11
29
|
if (renderProps.includes('class'))
|
|
12
30
|
nodeProps['className'] = node['class'];
|
|
31
|
+
// Handle URLs
|
|
13
32
|
if (renderProps.includes('url')) {
|
|
14
33
|
switch (node.type) {
|
|
15
34
|
case 'link':
|
|
16
35
|
nodeProps['href'] = node['url'];
|
|
17
36
|
break;
|
|
37
|
+
case 'video':
|
|
18
38
|
case 'image':
|
|
19
39
|
nodeProps['src'] = node['url'];
|
|
20
40
|
break;
|
|
@@ -23,7 +43,10 @@ export function createHtmlComponent(element, ignoreChildren = false, defaultProp
|
|
|
23
43
|
break;
|
|
24
44
|
}
|
|
25
45
|
}
|
|
26
|
-
|
|
46
|
+
// Render element
|
|
47
|
+
return ignoreChildren ?
|
|
48
|
+
_jsx(HtmlElement, { ...defaultProps, ...nodeProps, ...props }) :
|
|
49
|
+
_jsx(HtmlElement, { ...defaultProps, ...nodeProps, ...props, children: children });
|
|
27
50
|
};
|
|
28
51
|
return component;
|
|
29
52
|
}
|
|
@@ -42,10 +65,11 @@ export const DefaultTextNode = ({ node }) => {
|
|
|
42
65
|
* into React, using the component library shared across the react SDK.
|
|
43
66
|
*/
|
|
44
67
|
export const DefaultComponents = [
|
|
68
|
+
// System types
|
|
45
69
|
{ type: 'RichText/richText', component: createHtmlComponent("div", false, { className: "cms:rich-text" }) },
|
|
70
|
+
{ type: 'RichText/text', component: DefaultTextNode },
|
|
71
|
+
// Aliased tags
|
|
46
72
|
{ type: 'RichText/paragraph', component: createHtmlComponent("p") },
|
|
47
|
-
{ type: 'RichText/span', component: createHtmlComponent("span") },
|
|
48
|
-
{ type: 'RichText/div', component: createHtmlComponent("div") },
|
|
49
73
|
{ type: 'RichText/heading-one', component: createHtmlComponent("h1") },
|
|
50
74
|
{ type: 'RichText/heading-two', component: createHtmlComponent("h2") },
|
|
51
75
|
{ type: 'RichText/heading-three', component: createHtmlComponent("h3") },
|
|
@@ -53,12 +77,11 @@ export const DefaultComponents = [
|
|
|
53
77
|
{ type: 'RichText/heading-five', component: createHtmlComponent("h5") },
|
|
54
78
|
{ type: 'RichText/heading-six', component: createHtmlComponent("h6") },
|
|
55
79
|
{ type: 'RichText/link', component: createHtmlComponent("a") },
|
|
56
|
-
{ type: 'RichText/image', component: createHtmlComponent("img", true) },
|
|
57
|
-
{ type: 'RichText/text', component: DefaultTextNode },
|
|
58
|
-
{ type: 'RichText/br', component: createHtmlComponent("br", true) },
|
|
59
80
|
{ type: 'RichText/bulleted-list', component: createHtmlComponent("ul") },
|
|
60
81
|
{ type: 'RichText/numbered-list', component: createHtmlComponent("ol") },
|
|
61
82
|
{ type: 'RichText/list-item', component: createHtmlComponent("li") },
|
|
62
|
-
{ type: 'RichText/
|
|
83
|
+
{ type: 'RichText/image', component: createHtmlComponent("img", true) },
|
|
84
|
+
// Self-closing tags
|
|
85
|
+
{ type: 'RichText/br', component: createHtmlComponent("br", true) },
|
|
63
86
|
];
|
|
64
87
|
//# sourceMappingURL=components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../src/components/rich-text/components.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,yBAAyB;AACzB,MAAM,UAAU,mBAAmB,CAAwC,OAAU,EAAE,iBAA0B,KAAK,EAAE,YAA+D;IAEnL,MAAM,WAAW,GAAG,OAAiB,CAAA;IACrC,MAAM,
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../src/components/rich-text/components.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,mBAAmB;AACnB,MAAM,aAAa,GAAG,CAAC,KAAK,EAAC,OAAO,EAAC,UAAU,EAAC,MAAM,EAAC,UAAU,EAAC,MAAM,CAAC,CAAA;AAEzE,yBAAyB;AACzB;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,mBAAmB,CAAwC,OAAU,EAAE,iBAA0B,KAAK,EAAE,YAA+D;IAEnL,MAAM,WAAW,GAAG,OAAiB,CAAA;IACrC,MAAM,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,KAAK,EAAsE,EAAE,EAAE;QACnH,MAAM,SAAS,GAA8C,EAAE,CAAA;QAC/D,MAAM,WAAW,GAAG,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAA2B,CAAA;QAE9E,+BAA+B;QAC/B,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC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,EAAE,wBAAwB,EAAE,SAAS,EAAE,mBAAmB,CAAC,IAAI,CAAC,EAAC;IACvE,EAAE,IAAI,EAAE,wBAAwB,EAAE,SAAS,EAAE,mBAAmB,CAAC,IAAI,CAAC,EAAC;IACvE,EAAE,IAAI,EAAE,oBAAoB,EAAE,SAAS,EAAE,mBAAmB,CAAC,IAAI,CAAC,EAAC;IACnE,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,EAAC;IAEtE,oBAAoB;IACpB,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAC;CACrE,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type FunctionComponent } from "react";
|
|
2
2
|
import type { RichTextProps } from "./types.js";
|
|
3
|
+
import { type PropsWithContext } from "../../context/types.js";
|
|
3
4
|
export * from "./types.js";
|
|
4
|
-
export declare const RichText: FunctionComponent<RichTextProps
|
|
5
|
+
export declare const RichText: FunctionComponent<PropsWithContext<RichTextProps>>;
|
|
@@ -2,17 +2,23 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import * as Utils from './utils.js';
|
|
3
3
|
import { DefaultComponentFactory } from "../../factory/default.js";
|
|
4
4
|
import { DefaultComponents, DefaultTextNode, createHtmlComponent } from "./components.js";
|
|
5
|
+
import { CmsEditable } from "../cms-editable/index.js";
|
|
5
6
|
export * from "./types.js";
|
|
6
|
-
export const RichText = ({ factory, text = "{ \"type\": \"richText\" }", className = 'rich-text', as: Wrapper = "div", debug = false, noWrapper = false, ...props }) => {
|
|
7
|
+
export const RichText = ({ factory, text = "{ \"type\": \"richText\" }", className = 'rich-text', as: Wrapper = "div", debug = false, noWrapper = false, cmsFieldName = null, cmsId = null, ctx, ...props }) => {
|
|
7
8
|
const id = Utils.getRandomId("rich-text");
|
|
8
|
-
const richTextFactory = factory ?? new DefaultComponentFactory(DefaultComponents);
|
|
9
|
+
const richTextFactory = factory ?? ctx.factory ?? new DefaultComponentFactory(DefaultComponents);
|
|
10
|
+
const { inEditMode } = ctx;
|
|
9
11
|
try {
|
|
10
12
|
const data = Utils.processNodeInput(text);
|
|
11
13
|
const textContent = (data?.children || []).map((child, idx) => {
|
|
12
14
|
const elementId = id + '::' + idx;
|
|
13
15
|
return _jsx(RichTextElement, { factory: richTextFactory, node: child, idPrefix: elementId + '::' }, elementId);
|
|
14
16
|
});
|
|
15
|
-
|
|
17
|
+
if (noWrapper)
|
|
18
|
+
return _jsx(_Fragment, { children: textContent });
|
|
19
|
+
if (inEditMode && (cmsId || cmsFieldName))
|
|
20
|
+
return _jsx(CmsEditable, { as: Wrapper, className: className, cmsId: cmsId || undefined, cmsFieldName: cmsFieldName || undefined, ctx: ctx, ...props, children: textContent });
|
|
21
|
+
return _jsx(Wrapper, { className: className, ...props, children: textContent });
|
|
16
22
|
}
|
|
17
23
|
catch {
|
|
18
24
|
if (debug)
|
|
@@ -22,27 +28,33 @@ export const RichText = ({ factory, text = "{ \"type\": \"richText\" }", classNa
|
|
|
22
28
|
};
|
|
23
29
|
//#region Supportive React components
|
|
24
30
|
const RichTextElement = ({ factory, node, idPrefix, debug }) => {
|
|
31
|
+
// Render text
|
|
25
32
|
if (Utils.isText(node)) {
|
|
26
33
|
if (node.text.length == 0)
|
|
27
34
|
return null;
|
|
28
35
|
const TextComponent = factory?.resolve(`RichText/text`) ?? DefaultTextNode;
|
|
29
36
|
return _jsx(TextComponent, { node: node });
|
|
30
37
|
}
|
|
38
|
+
// Ignore incorrect data
|
|
31
39
|
if (!Utils.isTypedNode(node)) {
|
|
32
40
|
if (debug)
|
|
33
41
|
console.warn('🟠 [Rich Text] Invalid rich text element data received:', node);
|
|
34
42
|
return null;
|
|
35
43
|
}
|
|
36
|
-
|
|
44
|
+
// Process children
|
|
45
|
+
const childData = node.children && (node.children.length > 0) ? node.children.map((child, idx) => {
|
|
37
46
|
const elementId = idPrefix + idx;
|
|
38
47
|
return _jsx(RichTextElement, { factory: factory, node: child, idPrefix: elementId + '::' }, elementId);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
}) : undefined;
|
|
49
|
+
// Resolve component (and add to factory if not yet present)
|
|
50
|
+
let Component = factory?.resolve(`RichText/${node.type}`);
|
|
51
|
+
if (!Component) {
|
|
52
|
+
if (debug)
|
|
53
|
+
console.warn(`🟠 [Rich Text] No renderer for node type, using and registering HtmlComponent for "${node.type}": RichText/${node.type}`);
|
|
54
|
+
Component = createHtmlComponent(node.type);
|
|
55
|
+
factory?.register(`RichText/${node.type}`, Component);
|
|
44
56
|
}
|
|
45
|
-
|
|
46
|
-
return _jsx(Component, { node: node, children: childData });
|
|
57
|
+
// Return component
|
|
58
|
+
return _jsx(Component, { node: node, children: childData && (childData.length > 0) ? childData : undefined });
|
|
47
59
|
};
|
|
48
60
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/rich-text/index.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAEzF,cAAc,YAAY,CAAA;AAE1B,MAAM,CAAC,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/rich-text/index.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAEzF,OAA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AQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC7F,MAAM,SAAS,GAAG,QAAQ,GAAC,GAAG,CAAC;QAC/B,OAAO,KAAC,eAAe,IAAmB,OAAO,EAAG,OAAO,EAAG,IAAI,EAAG,KAAK,EAAG,QAAQ,EAAG,SAAS,GAAG,IAAI,IAA1E,SAAS,CAAqE,CAAA;IAChH,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEf,4DAA4D;IAC5D,IAAI,SAAS,GAAG,OAAO,EAAE,OAAO,CAAC,YAAa,IAAI,CAAC,IAAK,EAAE,CAAC,CAAA;IAC3D,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,IAAI,KAAK;YACL,OAAO,CAAC,IAAI,CAAC,sFAAuF,IAAI,CAAC,IAAK,eAAgB,IAAI,CAAC,IAAK,EAAE,CAAC,CAAA;QAC/I,SAAS,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAmC,CAAC,CAAA;QACzE,OAAO,EAAE,QAAQ,CAAC,YAAa,IAAI,CAAC,IAAK,EAAE,EAAE,SAAS,CAAC,CAAA;IAC3D,CAAC;IAED,mBAAmB;IACnB,OAAO,KAAC,SAAS,IAAC,IAAI,EAAG,IAAI,YAAK,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,GAAc,CAAA;AAC/G,CAAC,CAAA"}
|
|
@@ -3,6 +3,8 @@ import type { ComponentFactory, ComponentType } from "../../factory/types.js";
|
|
|
3
3
|
export type RichTextProps = {
|
|
4
4
|
/**
|
|
5
5
|
* The component factory used for this rich text content
|
|
6
|
+
*
|
|
7
|
+
* @deprecated The factory from the context will be used
|
|
6
8
|
*/
|
|
7
9
|
factory?: ComponentFactory;
|
|
8
10
|
/**
|
|
@@ -55,19 +57,30 @@ export type RichTextElementProps = Readonly<{
|
|
|
55
57
|
idPrefix: string;
|
|
56
58
|
}>;
|
|
57
59
|
export type Node = {};
|
|
60
|
+
/**
|
|
61
|
+
* Structured HTML node type for text data
|
|
62
|
+
*/
|
|
58
63
|
export type TextNode = Node & {
|
|
59
64
|
text: string;
|
|
60
65
|
} & Record<string, string | number | boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Structured HTML root node
|
|
68
|
+
*/
|
|
61
69
|
export type RichTextNode = Node & {
|
|
62
70
|
type: "richText";
|
|
63
71
|
children: Array<Node>;
|
|
64
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Structured HTML node for structured
|
|
75
|
+
* text
|
|
76
|
+
*/
|
|
65
77
|
export type StringNode = Node & {
|
|
66
78
|
type: "string";
|
|
67
79
|
children: Array<Node>;
|
|
68
80
|
};
|
|
69
81
|
/**
|
|
70
|
-
*
|
|
82
|
+
* Structured HTML node type with a specific
|
|
83
|
+
* type defined
|
|
71
84
|
*/
|
|
72
85
|
export type TypedNode = NodeWithChildren<Node & {
|
|
73
86
|
type: string;
|
|
@@ -75,4 +88,8 @@ export type TypedNode = NodeWithChildren<Node & {
|
|
|
75
88
|
export type NodeWithChildren<T extends Node> = T & {
|
|
76
89
|
children?: Array<Node>;
|
|
77
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* Allowable data type to provide to the RichText
|
|
93
|
+
* component
|
|
94
|
+
*/
|
|
78
95
|
export type NodeInput = string | RichTextNode | StringNode;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { TextNode, TypedNode, Node, NodeInput, RichTextNode, StringNode } from './types.js';
|
|
2
2
|
export declare function isText(toTest: Node | null | undefined): toTest is TextNode;
|
|
3
3
|
export declare function isTypedNode(toTest: Node | null | undefined): toTest is TypedNode;
|
|
4
|
-
export declare function processNodeInput(input: NodeInput | null | undefined): RichTextNode | StringNode | undefined;
|
|
5
|
-
export declare function getRandomId(scope?: string): string;
|
|
6
4
|
export declare function isRichTextNode(toTest: any): toTest is RichTextNode;
|
|
7
5
|
export declare function isStringNode(toTest: any): toTest is StringNode;
|
|
6
|
+
export declare function isNonEmptyString(toTest: any): toTest is string;
|
|
7
|
+
export declare function processNodeInput(input: NodeInput | null | undefined): RichTextNode | StringNode | undefined;
|
|
8
|
+
export declare function getRandomId(scope?: string): string;
|
|
8
9
|
/**
|
|
9
10
|
* Test if the provided value is a valid output of the XHTML field-type within
|
|
10
11
|
* Optimizely CMS
|
|
@@ -10,6 +10,15 @@ export function isTypedNode(toTest) {
|
|
|
10
10
|
(typeof toTest.type) == 'string' &&
|
|
11
11
|
toTest.type.length > 0);
|
|
12
12
|
}
|
|
13
|
+
export function isRichTextNode(toTest) {
|
|
14
|
+
return isTypedNode(toTest) && toTest.type == 'richText';
|
|
15
|
+
}
|
|
16
|
+
export function isStringNode(toTest) {
|
|
17
|
+
return isTypedNode(toTest) && toTest.type == 'string';
|
|
18
|
+
}
|
|
19
|
+
export function isNonEmptyString(toTest) {
|
|
20
|
+
return typeof (toTest) == 'string' && toTest.length > 0;
|
|
21
|
+
}
|
|
13
22
|
export function processNodeInput(input) {
|
|
14
23
|
if (!input)
|
|
15
24
|
return undefined;
|
|
@@ -21,12 +30,6 @@ export function processNodeInput(input) {
|
|
|
21
30
|
export function getRandomId(scope = "richText") {
|
|
22
31
|
return `${scope}::${Math.round(Math.random() * 100000)}`;
|
|
23
32
|
}
|
|
24
|
-
export function isRichTextNode(toTest) {
|
|
25
|
-
return isTypedNode(toTest) && toTest.type == 'richText';
|
|
26
|
-
}
|
|
27
|
-
export function isStringNode(toTest) {
|
|
28
|
-
return isTypedNode(toTest) && toTest.type == 'string';
|
|
29
|
-
}
|
|
30
33
|
/**
|
|
31
34
|
* Test if the provided value is a valid output of the XHTML field-type within
|
|
32
35
|
* Optimizely CMS
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/rich-text/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,MAAM,CAAC,MAA+B;IAElD,OAAO,CACH,OAA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C;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,MAAW;IAEnC,OAAO,cAAc,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,CAAA;AACzD,CAAC"}
|
package/dist/components/rsc.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ import { type CmsEditableComponent } from './cms-editable/index.js';
|
|
|
6
6
|
import { type CmsContentComponent } from './cms-content/rsc.js';
|
|
7
7
|
import { type OptimizelyCompositionComponent } from './visual-builder/index.js';
|
|
8
8
|
import { type RichTextComponent } from './rich-text/index.js';
|
|
9
|
+
export type { BaseStyleDefinition, ElementStyleDefinition, LayoutProps, LayoutPropsSetting, LayoutPropsSettingChoices, LayoutPropsSettingKeys, LayoutPropsSettingValues, NodeStyleDefinition, StyleDefinition, StyleSetting } from "./cms-styles/index.js";
|
|
10
|
+
export { extractSettings, readSetting } from "./cms-styles/index.js";
|
|
9
11
|
export * from "./cms-styles/index.js";
|
|
10
12
|
export { isNode, isComponentNode, isComponentNodeOfType, isStructureNode, isElementNode } from "./visual-builder/functions.js";
|
|
11
|
-
export { DefaultComponents as RichTextComponentDictionary } from './rich-text/components.js';
|
|
12
|
-
export type { TypedNode, RichTextNode, StringNode, NodeInput } from "./rich-text/index.js";
|
|
13
13
|
/**
|
|
14
14
|
* Fallback while RSC hasn't been moved from Canary to Main
|
|
15
15
|
*/
|
|
@@ -48,3 +48,6 @@ export declare const OptimizelyComposition: OptimizelyCompositionComponent;
|
|
|
48
48
|
* Client side renderer for Rich Text
|
|
49
49
|
*/
|
|
50
50
|
export declare const RichText: RichTextComponent;
|
|
51
|
+
export type { RichTextComponent, RichTextProps, RichTextNode, StringNode, TypedNode, NodeInput } from "./rich-text/index.js";
|
|
52
|
+
export { DefaultComponents as RichTextComponentDictionary, createHtmlComponent } from './rich-text/components.js';
|
|
53
|
+
export { isNodeInput, isNonEmptyString, isRichTextNode, isStringNode, isText, isTypedNode } from "./rich-text/utils.js";
|
package/dist/components/rsc.js
CHANGED
|
@@ -7,11 +7,10 @@ import { CmsEditable as BaseEditable } from './cms-editable/index.js'; // Both R
|
|
|
7
7
|
import { CmsContent as BaseCmsContent } from './cms-content/rsc.js'; // Different components for RSC & Client
|
|
8
8
|
import { OptimizelyComposition as BaseOptimizelyComposition } from './visual-builder/index.js'; // Both RSC & Client capable
|
|
9
9
|
import { RichText as BaseRichText } from './rich-text/index.js';
|
|
10
|
-
|
|
10
|
+
export { extractSettings, readSetting } from "./cms-styles/index.js";
|
|
11
11
|
export * from "./cms-styles/index.js";
|
|
12
|
+
// Visual Builder items
|
|
12
13
|
export { isNode, isComponentNode, isComponentNodeOfType, isStructureNode, isElementNode } from "./visual-builder/functions.js";
|
|
13
|
-
// Export dictionary & pass through RichText Types
|
|
14
|
-
export { DefaultComponents as RichTextComponentDictionary } from './rich-text/components.js';
|
|
15
14
|
/**
|
|
16
15
|
* Wrapper function to turn context dependant components into easy to use
|
|
17
16
|
* server components
|
|
@@ -23,6 +22,8 @@ export function serverContextAware(component) {
|
|
|
23
22
|
const BaseComponent = component;
|
|
24
23
|
const ServerContextInjector = (props) => {
|
|
25
24
|
const ctx = getServerContext();
|
|
25
|
+
if (!ctx)
|
|
26
|
+
console.log(`🔴 [ServerContextAware] Context for context aware component ${BaseComponent.displayName ?? BaseComponent.name ?? '[ANONYMOUS]'} is not defined!`, ctx);
|
|
26
27
|
return _jsx(BaseComponent, { ctx: ctx, ...props });
|
|
27
28
|
};
|
|
28
29
|
ServerContextInjector.displayName = "Server Context Injector";
|
|
@@ -51,5 +52,7 @@ export const OptimizelyComposition = cmsContentAware(serverContextAware(BaseOpti
|
|
|
51
52
|
/**
|
|
52
53
|
* Client side renderer for Rich Text
|
|
53
54
|
*/
|
|
54
|
-
export const RichText = BaseRichText;
|
|
55
|
+
export const RichText = serverContextAware(BaseRichText);
|
|
56
|
+
export { DefaultComponents as RichTextComponentDictionary, createHtmlComponent } from './rich-text/components.js';
|
|
57
|
+
export { isNodeInput, isNonEmptyString, isRichTextNode, isStringNode, isText, isTypedNode } from "./rich-text/utils.js";
|
|
55
58
|
//# sourceMappingURL=rsc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../../src/components/rsc.tsx"],"names":[],"mappings":";AAAA,OAAO,aAAa,CAAA;AAGpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,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,EAA0D,MAAM,sBAAsB,CAAA,CAAC,wCAAwC;AACpK,OAAO,EAAE,qBAAqB,IAAI,yBAAyB,EAAuC,MAAM,2BAA2B,CAAA,CAAC,4BAA4B;AAChK,OAAO,EAAE,QAAQ,IAAI,YAAY,EAA0B,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../../src/components/rsc.tsx"],"names":[],"mappings":";AAAA,OAAO,aAAa,CAAA;AAGpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,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,EAA0D,MAAM,sBAAsB,CAAA,CAAC,wCAAwC;AACpK,OAAO,EAAE,qBAAqB,IAAI,yBAAyB,EAAuC,MAAM,2BAA2B,CAAA,CAAC,4BAA4B;AAChK,OAAO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,kBAAkB,CAAC,YAAY,CAAsB,CAAA;AAE7E,OAAO,EAAE,iBAAiB,IAAI,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AACjH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAG,MAAM,sBAAsB,CAAA"}
|
package/dist/components.d.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been
|
|
5
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been
|
|
6
|
+
* deprecated, use either `@remkoj/optimizely-cms-react` or
|
|
7
|
+
* `@remkoj/optimizely-cms-react/rsc`, dependingn on your context
|
|
6
8
|
*/
|
|
7
|
-
export
|
|
9
|
+
export declare const RichText: import("react").ComponentType<import("./rsc.js").RichTextProps>;
|
|
8
10
|
/**
|
|
9
11
|
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
10
12
|
*/
|
package/dist/components.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
3
3
|
*/
|
|
4
|
+
import { RichText as BaseRichText } from "./components/rich-text/index.js";
|
|
5
|
+
import { serverContextAware } from "./rsc.js";
|
|
4
6
|
/**
|
|
5
|
-
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been
|
|
7
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been
|
|
8
|
+
* deprecated, use either `@remkoj/optimizely-cms-react` or
|
|
9
|
+
* `@remkoj/optimizely-cms-react/rsc`, dependingn on your context
|
|
6
10
|
*/
|
|
7
|
-
export
|
|
11
|
+
export const RichText = serverContextAware(BaseRichText);
|
|
8
12
|
/**
|
|
9
13
|
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
10
14
|
*/
|
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAA;AACxD;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AAC9G;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,iCAAiC,CAAA;AASxD;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA"}
|
|
@@ -20,4 +20,5 @@ export declare class DefaultComponentFactory implements ComponentFactory {
|
|
|
20
20
|
has(type: ComponentTypeHandle): boolean;
|
|
21
21
|
resolve(type: ComponentTypeHandle): undefined | ComponentType;
|
|
22
22
|
extract(): ComponentTypeDictionary;
|
|
23
|
+
remove(type: ComponentTypeHandle): boolean;
|
|
23
24
|
}
|
package/dist/factory/default.js
CHANGED
|
@@ -64,13 +64,18 @@ export class DefaultComponentFactory {
|
|
|
64
64
|
return Suspended;
|
|
65
65
|
}
|
|
66
66
|
extract() {
|
|
67
|
-
return Array.from(this.registry.entries()).map(
|
|
68
|
-
return {
|
|
69
|
-
...e[1],
|
|
70
|
-
type: e[0]
|
|
71
|
-
};
|
|
67
|
+
return Array.from(this.registry.entries()).map(([key, entry]) => {
|
|
68
|
+
return { ...entry, type: key };
|
|
72
69
|
});
|
|
73
70
|
}
|
|
71
|
+
remove(type) {
|
|
72
|
+
const registryKey = processComponentTypeHandle(type);
|
|
73
|
+
if (this.dbg)
|
|
74
|
+
console.log(`🔎 [DefaultComponentFactory] Removing ${registryKey}`);
|
|
75
|
+
if (!this.registry.has(registryKey))
|
|
76
|
+
return true;
|
|
77
|
+
return this.registry.delete(registryKey);
|
|
78
|
+
}
|
|
74
79
|
}
|
|
75
80
|
function processComponentTypeHandle(handle) {
|
|
76
81
|
if (typeof (handle) == 'string')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/factory/default.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAE/B,MAAM,CAAC,MAAM,oBAAoB,GAAI,cAAc,CAAA;AAEnD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAIhC;;;;;OAKG;IACH,YAAmB,iBAA2C;QATtD,aAAQ,GAAG,IAAI,GAAG,EAAwC,CAAA;QAW9D,qBAAqB;QACrB,IAAI,CAAC;YACD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,GAAG,CAAA;QAClD,CAAC;QAAC,MAAM,CAAC;YACL,IAAI,CAAC,GAAG,GAAG,KAAK,CAAA;QACpB,CAAC;QAED,kCAAkC;QAClC,IAAI,iBAAiB;YACjB,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAA;IAC3C,CAAC;IAED,QAAQ,CAAC,IAAyB,EAAE,SAAwB,EAAE,cAAuB,KAAK,EAAE,MAAsB;QAE9G,MAAM,WAAW,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAA;QACpD,IAAI,IAAI,CAAC,GAAG;YAAE,OAAO,CAAC,GAAG,CAAC,sCAAuC,WAAY,EAAE,CAAC,CAAA;QAChF,IAAI,CAAC,QAAQ,CAAC,GAA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AC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAG,iCAAiC;aACpF,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,SAAS,CAAC,CAAU,iCAAiC;aACpF,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAO,0BAA0B;aAC7E,IAAI,CAAC,YAAY,CAAC,CAAA,CAAiC,kCAAkC;IAC9F,MAAM,IAAI,KAAK,CAAC,kCAAmC,OAAM,CAAC,MAAM,CAAE,EAAE,CAAC,CAAA;AACzE,CAAC"}
|
package/dist/factory/types.d.ts
CHANGED
|
@@ -38,7 +38,8 @@ export interface ComponentFactory {
|
|
|
38
38
|
*/
|
|
39
39
|
has(type: ComponentTypeHandle): boolean;
|
|
40
40
|
/**
|
|
41
|
-
* Register an individual component
|
|
41
|
+
* Register an individual component. When the component type has already
|
|
42
|
+
* been registered it will be updated.
|
|
42
43
|
*
|
|
43
44
|
* @param type The component type to register
|
|
44
45
|
* @param component The component to bind to the type
|
|
@@ -47,11 +48,21 @@ export interface ComponentFactory {
|
|
|
47
48
|
*/
|
|
48
49
|
register(type: ComponentTypeHandle, component: ComponentType, useSuspense?: boolean, loader?: ComponentType): void;
|
|
49
50
|
/**
|
|
50
|
-
* Register all components provided through the dictionary
|
|
51
|
+
* Register all components provided through the dictionary. When the
|
|
52
|
+
* component type has already been registered it will be updated.
|
|
51
53
|
*
|
|
52
54
|
* @param components The components to register
|
|
53
55
|
*/
|
|
54
56
|
registerAll(components: ComponentTypeDictionary): void;
|
|
57
|
+
/**
|
|
58
|
+
* Allows removing of a component type from the factory, but only when
|
|
59
|
+
* the implemenation supports it.
|
|
60
|
+
*
|
|
61
|
+
* @param type The component type to remove
|
|
62
|
+
* @returns `true` If the component was not found or removed, `false`
|
|
63
|
+
* otherwise
|
|
64
|
+
*/
|
|
65
|
+
remove?: (type: ComponentTypeHandle) => boolean;
|
|
55
66
|
/**
|
|
56
67
|
* Resolve a component type
|
|
57
68
|
*
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remkoj/optimizely-cms-react",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "4.
|
|
5
|
-
"packageManager": "yarn@4.1.1",
|
|
4
|
+
"version": "4.1.0",
|
|
6
5
|
"repository": "https://github.com/remkoj/optimizely-dxp-clients.git",
|
|
7
6
|
"author": "Remko Jantzen <693172+remkoj@users.noreply.github.com>",
|
|
8
|
-
"homepage": "https://github.com/remkoj/optimizely-dxp-clients",
|
|
7
|
+
"homepage": "https://github.com/remkoj/optimizely-dxp-clients/tree/main/packages/optimizely-cms-react",
|
|
9
8
|
"type": "module",
|
|
10
9
|
"main": "./dist/index.js",
|
|
11
10
|
"types": "./dist/index.d.ts",
|
|
@@ -28,13 +27,13 @@
|
|
|
28
27
|
}
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
31
|
-
"@remkoj/optimizely-graph-client": "4.
|
|
30
|
+
"@remkoj/optimizely-graph-client": "4.1.0",
|
|
32
31
|
"@types/crypto-js": "^4.2.2",
|
|
33
|
-
"@types/node": "^22.10.
|
|
34
|
-
"@types/react": "^18.3.
|
|
35
|
-
"@types/react-dom": "18.3.
|
|
32
|
+
"@types/node": "^22.10.2",
|
|
33
|
+
"@types/react": "^18.3.17",
|
|
34
|
+
"@types/react-dom": "18.3.5",
|
|
36
35
|
"entities": "^5.0.0",
|
|
37
|
-
"graphql": "^16.
|
|
36
|
+
"graphql": "^16.10.0",
|
|
38
37
|
"graphql-request": "^6.1.0",
|
|
39
38
|
"prop-types": "^15.8.1",
|
|
40
39
|
"react": "^18.3.1",
|
|
@@ -59,6 +58,5 @@
|
|
|
59
58
|
"prepare": "yarn tsc --build --force",
|
|
60
59
|
"watch": "tsc --watch",
|
|
61
60
|
"recompile": "tsc --build --clean && tsc --build --force"
|
|
62
|
-
}
|
|
63
|
-
"stableVersion": "3.2.3"
|
|
61
|
+
}
|
|
64
62
|
}
|