@sitecore-feaas/clientside 0.3.11-alpha.0 → 0.3.11-alpha.1
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/build/ui/FEAASExternal.js +2 -2
- package/build/ui/FEAASExternal.js.map +1 -1
- package/build/ui/react.js +16 -6
- package/build/ui/react.js.map +1 -1
- package/dist/browser/react.cjs +6 -6
- package/dist/browser/react.cjs.map +3 -3
- package/dist/browser/react.esm.js +6 -6
- package/dist/browser/react.esm.js.map +1 -1
- package/dist/node/react.cjs +4 -4
- package/dist/node/react.cjs.map +3 -3
- package/dist/node/react.esm.js +4 -4
- package/dist/node/react.esm.js.map +3 -3
- package/package.json +1 -1
- package/react.cjs +6 -6
- package/react.cjs.map +3 -3
- package/react.js +6 -6
- package/react.js.map +3 -3
- package/src/ui/FEAASExternal.tsx +6 -2
- package/src/ui/react.tsx +22 -5
- package/types/ui/FEAASExternal.d.ts +4 -0
- package/types/ui/FEAASExternal.d.ts.map +1 -1
- package/types/ui/react.d.ts +4 -2
- package/types/ui/react.d.ts.map +1 -1
- package/types/ui/tsbuildinfo +1 -1
package/src/ui/FEAASExternal.tsx
CHANGED
|
@@ -124,7 +124,7 @@ export default class FEAASExternal extends FEAASElement<FEAASExternalProps, Reac
|
|
|
124
124
|
update() {
|
|
125
125
|
const { dataExternalId: id } = this.props
|
|
126
126
|
const Component = FEAASExternal.registered[id]?.component
|
|
127
|
-
if (!Component && this.
|
|
127
|
+
if (!Component && this.getAttribute('hydrate') == 'false') return
|
|
128
128
|
return super.update()
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -132,7 +132,7 @@ export default class FEAASExternal extends FEAASElement<FEAASExternalProps, Reac
|
|
|
132
132
|
const { dataExternalId: id } = props
|
|
133
133
|
const Component = FEAASExternal.registered[id]?.component
|
|
134
134
|
if (!Component) {
|
|
135
|
-
console.warn(
|
|
135
|
+
console.warn(`FEAASExternal: \`${id}\` is not registered`)
|
|
136
136
|
}
|
|
137
137
|
return <>{Component && <Component {...props} />}</>
|
|
138
138
|
}
|
|
@@ -278,6 +278,10 @@ declare global {
|
|
|
278
278
|
dangerouslySetInnerHTML?: { __html: string }
|
|
279
279
|
[key: string]: any
|
|
280
280
|
}
|
|
281
|
+
'feaas-registration': {
|
|
282
|
+
suppressHydrationWarning?: boolean
|
|
283
|
+
components: string
|
|
284
|
+
}
|
|
281
285
|
}
|
|
282
286
|
}
|
|
283
287
|
}
|
package/src/ui/react.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import React from 'react'
|
|
11
11
|
import { renderHTMLContent, HTMLNode, parseHTMLContent } from '../dom/html.js'
|
|
12
12
|
import { DataSettings } from '../utils/settings.js'
|
|
13
|
-
import { FEAASExternalPropsObject, getComponent, objectKeysToKebabCase } from './FEAASExternal.js'
|
|
13
|
+
import { External, FEAASExternalPropsObject, getComponent, objectKeysToKebabCase } from './FEAASExternal.js'
|
|
14
14
|
import { reverseKebabCase } from '../utils/string.js'
|
|
15
15
|
export { renderHTMLContent }
|
|
16
16
|
export { External, linkComponents, registerComponent, getComponent, FEAASExternalPropsObject } from './FEAASExternal.js'
|
|
@@ -58,7 +58,7 @@ export function FEAASReactComponent({ data, ...props }: FEAASReactComponentProps
|
|
|
58
58
|
const key = prop == 'data-external-id' ? 'componentName' : reverseKebabCase(prop)
|
|
59
59
|
camelized[key] = attributes[prop]
|
|
60
60
|
}
|
|
61
|
-
return [
|
|
61
|
+
return [FEAASExternalComponent, camelized]
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
index
|
|
@@ -94,7 +94,12 @@ export function FEAASReactComponent({ data, ...props }: FEAASReactComponentProps
|
|
|
94
94
|
export function FEAASReactExternalComponent(props: FEAASReactExternalComponentProps) {
|
|
95
95
|
const { componentName, fallback, ...attributes } = props
|
|
96
96
|
const Component = getComponent(componentName)?.component
|
|
97
|
-
if (!Component && fallback)
|
|
97
|
+
if ((!Component && fallback) || !componentName)
|
|
98
|
+
return (
|
|
99
|
+
<feaas-external data-external-id={componentName} suppressHydrationWarning hydrate={'false'}>
|
|
100
|
+
{fallback}
|
|
101
|
+
</feaas-external>
|
|
102
|
+
)
|
|
98
103
|
const parsed = FEAASExternalPropsObject(componentName, attributes)
|
|
99
104
|
delete parsed['suppressHydrationWarning']
|
|
100
105
|
// execute component as a function to supress hydration errors inside
|
|
@@ -104,7 +109,7 @@ export function FEAASReactExternalComponent(props: FEAASReactExternalComponentPr
|
|
|
104
109
|
{...objectKeysToKebabCase(parsed)}
|
|
105
110
|
data-external-id={componentName}
|
|
106
111
|
suppressHydrationWarning
|
|
107
|
-
hydrate={
|
|
112
|
+
hydrate={'false'}
|
|
108
113
|
>
|
|
109
114
|
{Component == null ? null : <Component {...parsed} />}
|
|
110
115
|
</feaas-external>
|
|
@@ -176,7 +181,19 @@ export function enableNextClientsideComponents(dynamic: any, component: any) {
|
|
|
176
181
|
return component
|
|
177
182
|
}
|
|
178
183
|
|
|
179
|
-
export
|
|
184
|
+
export function FEAASExternalComponent(props: FEAASReactExternalComponentProps) {
|
|
185
|
+
if (Object.keys(props).length == 0) {
|
|
186
|
+
// Serializing server-side registrations to clientside
|
|
187
|
+
return (
|
|
188
|
+
<feaas-registration components={JSON.stringify(Object.values(External.registered))} suppressHydrationWarning />
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
if (NextDynamicFunction) return FEAASNextExternalComponent(props)
|
|
192
|
+
return FEAASReactExternalComponent(props)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export const ExternalComponent = FEAASExternalComponent
|
|
196
|
+
export const ReactExternalComponent = FEAASReactExternalComponent
|
|
180
197
|
export const NextExternalComponent = FEAASNextExternalComponent
|
|
181
198
|
export const Component = FEAASReactComponent
|
|
182
199
|
export const ServerComponent = FEAASReactServerComponent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FEAASExternal.d.ts","sourceRoot":"","sources":["../../src/ui/FEAASExternal.tsx"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AAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,EAClF,OAAO,EAAE,wBAAwB;IAsBnC,MAAM,CAAC,uBAAuB;IAsC9B,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE;IAMzE,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,GAAG;IAI5D,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM;CAG/B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,gBAAgB,EAAE;gBAChB,kBAAkB,EAAE,MAAM,CAAA;gBAC1B,QAAQ,CAAC,EAAE,GAAG,CAAA;gBACd,uBAAuB,CAAC,EAAE;oBAAE,MAAM,EAAE,MAAM,CAAA;iBAAE,CAAA;gBAC5C,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;aACnB,CAAA;YACD,oBAAoB,EAAE;gBACpB,wBAAwB,CAAC,EAAE,OAAO,CAAA;gBAClC,UAAU,EAAE,MAAM,CAAA;aACnB,CAAA;SACF;KACF;CACF;AAKD,eAAO,MAAQ,YAAY,qCAAE,cAAc,uCAAE,iBAAiB,wCAAkB,CAAA;AAChF,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,CAAA"}
|
package/types/ui/react.d.ts
CHANGED
|
@@ -17,12 +17,14 @@ export type FEAASReactComponentProps = FEAASComponentProps & {
|
|
|
17
17
|
export declare const FEAASReactStylesheet: (props: FEAASStylesheetProps) => JSX.Element;
|
|
18
18
|
export declare const FEAASReactServerComponent: ({ ...props }: FEAASReactComponentProps) => Promise<JSX.Element>;
|
|
19
19
|
export declare function FEAASReactComponent({ data, ...props }: FEAASReactComponentProps): JSX.Element;
|
|
20
|
-
export declare function FEAASReactExternalComponent(props: FEAASReactExternalComponentProps):
|
|
20
|
+
export declare function FEAASReactExternalComponent(props: FEAASReactExternalComponentProps): JSX.Element;
|
|
21
21
|
/** Turn HTMLNode into React tree. It accepts callback to customize the behavior */
|
|
22
22
|
export declare function HTMLNodeToReact(node: HTMLNode, callback?: (node: HTMLNode, attributes: Record<string, any>) => [tagName: any, attributes: Record<string, any>], key?: any): React.ReactNode;
|
|
23
23
|
export declare function FEAASNextExternalComponent(props: FEAASReactExternalComponentProps): JSX.Element;
|
|
24
24
|
export declare function enableNextClientsideComponents(dynamic: any, component: any): any;
|
|
25
|
-
export declare
|
|
25
|
+
export declare function FEAASExternalComponent(props: FEAASReactExternalComponentProps): JSX.Element;
|
|
26
|
+
export declare const ExternalComponent: typeof FEAASExternalComponent;
|
|
27
|
+
export declare const ReactExternalComponent: typeof FEAASReactExternalComponent;
|
|
26
28
|
export declare const NextExternalComponent: typeof FEAASNextExternalComponent;
|
|
27
29
|
export declare const Component: typeof FEAASReactComponent;
|
|
28
30
|
export declare const ServerComponent: ({ ...props }: FEAASReactComponentProps) => Promise<JSX.Element>;
|
package/types/ui/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/ui/react.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAMnB,oBAAoB,EACrB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAoB,MAAM,gBAAgB,CAAA;AAI9E,OAAO,EAAE,iBAAiB,EAAE,CAAA;AAC5B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AACxH,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAE9B,MAAM,MAAM,gCAAgC,GAAG;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,Q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