@sitecore-feaas/clientside
Advanced tools
Comparing version 0.5.16-alpha.1 to 0.5.17
@@ -71,3 +71,3 @@ import * as BYOC from '@sitecore/byoc/react'; | ||
*/ | ||
export function FEAASReactComponent({ data, lastModified, fetchedData, ...props }) { | ||
export function FEAASReactComponent({ data, lastModified, fetchedData, renderNode, ...props }) { | ||
let preload = null; | ||
@@ -77,2 +77,13 @@ let children; | ||
children = parseHTMLContent(props.template, fetchedData || data || {}).map((node, index) => HTMLNodeToReact(node, (node, attributes) => { | ||
// invoke customization of HTML node rendering | ||
if (renderNode) { | ||
const override = renderNode === null || renderNode === void 0 ? void 0 : renderNode(node, attributes); | ||
if (override != null && 'type' in override) { | ||
return [override.type, override.props]; | ||
} | ||
attributes = { | ||
...attributes, | ||
...override | ||
}; | ||
} | ||
// Override rendering of html tag if user provided | ||
@@ -112,2 +123,3 @@ if (ReactElementComponents[node.localName]) { | ||
export function HTMLNodeToReact(node, callback, key) { | ||
var _a; | ||
if (node.nodeType === 3) { | ||
@@ -145,3 +157,4 @@ return node.textContent; | ||
const reactAttributes = Object.assign({ key, suppressHydrationWarning: true }, (reactNode === null || reactNode === void 0 ? void 0 : reactNode[1]) || attributes); | ||
return React.createElement(reactName, reactAttributes, ['img', 'br', 'input', 'style'].includes(reactName) ? null : children); | ||
const reactChildren = ((_a = reactNode === null || reactNode === void 0 ? void 0 : reactNode[1]) === null || _a === void 0 ? void 0 : _a.children) || children; | ||
return React.createElement(reactName, reactAttributes, ['img', 'br', 'input', 'style'].includes(reactName) ? null : reactChildren); | ||
} | ||
@@ -148,0 +161,0 @@ export const enableNextClientsideComponents = BYOC.enableNextClientsideComponents; |
{ | ||
"name": "@sitecore-feaas/clientside", | ||
"version": "0.5.16-alpha.1", | ||
"version": "0.5.17", | ||
"scripts": { | ||
@@ -14,3 +14,3 @@ "start": "webpack serve --open", | ||
"types": "tsc --build; cd src/ui && tsc --build", | ||
"postpublish": "node ../cdn/upload-package.js clientside $npm_package_version" | ||
"postpublish": "node ../cdn/upload-package.js clientside $npm_package_version cdn" | ||
}, | ||
@@ -17,0 +17,0 @@ "license": "ISC", |
@@ -56,3 +56,3 @@ /// <reference types="@types/react" /> | ||
whenSDKReady: ControlledPromise<FEAASContextImports.SDK>; | ||
getPortalRoot(): HTMLElement | ShadowRoot | FEAASElement<any, any>; | ||
getPortalRoot(): HTMLElement | FEAASElement<any, any> | ShadowRoot; | ||
render({ children, library }: React.PropsWithChildren<FEAASContextProps>, { AppContext, Chakra: { Button, Tooltip }, React }: typeof this.payload): FEAASContextImports.React.JSX.Element; | ||
@@ -59,0 +59,0 @@ } |
@@ -15,3 +15,3 @@ /// <reference types="@types/react" /> | ||
*/ | ||
export declare function setElementImplementation(tagName: string, Component: React.Component | React.FC): void; | ||
export declare function setElementImplementation(tagName: string, Component: React.Component<Record<string, string>> | React.FC<Record<string, string>>): void; | ||
type FEEASReactComponentFetch = string[] | string | null | undefined | boolean; | ||
@@ -23,2 +23,3 @@ export declare function normalizeFetchAttribute(fetch: FEEASReactComponentFetch): any[]; | ||
lastModified?: Date | string; | ||
renderNode?: (node: HTMLNode, attributes: Record<string, any>) => JSX.Element | Record<string, any> | null; | ||
}; | ||
@@ -48,3 +49,3 @@ /** | ||
*/ | ||
export declare function FEAASReactComponent({ data, lastModified, fetchedData, ...props }: FEAASReactComponentProps & { | ||
export declare function FEAASReactComponent({ data, lastModified, fetchedData, renderNode, ...props }: FEAASReactComponentProps & { | ||
fetchedData?: any; | ||
@@ -51,0 +52,0 @@ }): React.JSX.Element; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5710605
191
18975
86