@sitecore-feaas/clientside 0.5.11 → 0.5.13-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/components/FEAASComponent.js +1 -0
- package/build/components/FEAASComponent.js.map +1 -1
- package/build/ui/react.js +13 -0
- package/build/ui/react.js.map +1 -1
- package/dist/browser/headless.cjs +1 -1
- package/dist/browser/headless.cjs.map +2 -2
- package/dist/browser/headless.esm.js +1 -1
- package/dist/browser/headless.esm.js.map +1 -1
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.cjs.map +2 -2
- package/dist/browser/index.esm.js +1 -1
- package/dist/browser/index.esm.js.map +1 -1
- package/dist/browser/react.cjs +7 -7
- package/dist/browser/react.cjs.map +3 -3
- package/dist/browser/react.esm.js +7 -7
- package/dist/browser/react.esm.js.map +1 -1
- package/dist/node/headless.cjs +1 -1
- package/dist/node/headless.cjs.map +2 -2
- package/dist/node/headless.esm.js +1 -1
- package/dist/node/headless.esm.js.map +2 -2
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.cjs.map +2 -2
- package/dist/node/index.esm.js +1 -1
- package/dist/node/index.esm.js.map +2 -2
- package/dist/node/react.cjs +5 -5
- package/dist/node/react.cjs.map +3 -3
- package/dist/node/react.esm.js +5 -5
- package/dist/node/react.esm.js.map +3 -3
- package/headless.cjs +1 -1
- package/headless.cjs.map +2 -2
- package/headless.js +1 -1
- package/headless.js.map +2 -2
- package/package.json +1 -1
- package/react.cjs +7 -7
- package/react.cjs.map +3 -3
- package/react.js +7 -7
- package/react.js.map +3 -3
- package/src/components/FEAASComponent.tsx +1 -0
- package/src/ui/react.tsx +15 -1
- package/test/FEAASComponent.react.test.tsx +32 -5
- package/test/FEAASComponent.test.tsx +21 -21
- package/test/tsconfig.json +1 -1
- package/types/components/FEAASComponent.d.ts.map +1 -1
- package/types/components/FEAASElement.d.ts +1 -1
- package/types/ui/FEAASContext.d.ts +1 -1
- package/types/ui/FEAASExternal.d.ts +1 -1
- package/types/ui/FEAASPicker.d.ts +1 -1
- package/types/ui/react.d.ts +11 -5
- package/types/ui/react.d.ts.map +1 -1
- /package/test/{FEAASComponentData.test.tsx → FEAASComponent.data.test.tsx} +0 -0
|
@@ -236,6 +236,7 @@ export class FEAASComponent extends FEAASElement<FEAASComponentsProps, string> {
|
|
|
236
236
|
this.needsToFetchTemplate = false
|
|
237
237
|
var templatePromise = fetchAndRevalidateComponent(this.props, (html) => {
|
|
238
238
|
this.payload = html
|
|
239
|
+
this.needsRefresh = true
|
|
239
240
|
advanceIfEverythingIsReady()
|
|
240
241
|
})
|
|
241
242
|
} else {
|
package/src/ui/react.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { ReactComponentElement } from 'react'
|
|
2
2
|
import * as BYOC from '@sitecore/byoc/react'
|
|
3
3
|
import { HTMLNode, parseHTMLContent, renderHTMLContent } from '../dom/html.js'
|
|
4
4
|
import { DataSettings } from '../utils/settings.js'
|
|
@@ -18,6 +18,16 @@ export { External, FEAASExternalPropsObject, getComponent, linkComponents, regis
|
|
|
18
18
|
export * from './index.js'
|
|
19
19
|
export { renderHTMLContent }
|
|
20
20
|
|
|
21
|
+
var ReactElementComponents: Record<string, React.Component | React.FC> = {}
|
|
22
|
+
/**
|
|
23
|
+
* Set custom implementation for a HTML tag name. Useful for Next.js Image component, handling image optimization.
|
|
24
|
+
*
|
|
25
|
+
* @param Component
|
|
26
|
+
*/
|
|
27
|
+
export function setElementImplementation(tagName: string, Component: React.Component | React.FC) {
|
|
28
|
+
ReactElementComponents[tagName] = Component
|
|
29
|
+
}
|
|
30
|
+
|
|
21
31
|
type FEEASReactComponentFetch = string[] | string | null | undefined | boolean
|
|
22
32
|
export function normalizeFetchAttribute(fetch: FEEASReactComponentFetch) {
|
|
23
33
|
if (fetch == null || fetch === true) {
|
|
@@ -96,6 +106,10 @@ export function FEAASReactComponent({
|
|
|
96
106
|
HTMLNodeToReact(
|
|
97
107
|
node,
|
|
98
108
|
(node, attributes) => {
|
|
109
|
+
// Override rendering of html tag if user provided
|
|
110
|
+
if (ReactElementComponents[node.localName]) {
|
|
111
|
+
return [ReactElementComponents[node.localName], attributes]
|
|
112
|
+
}
|
|
99
113
|
if (node.localName == 'feaas-external') {
|
|
100
114
|
const camelized = {} as any
|
|
101
115
|
for (var prop in attributes) {
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
import ReactDOM from 'react-dom'
|
|
3
|
-
import { describe, expect, it,
|
|
4
|
-
import {
|
|
3
|
+
import { describe, expect, it, beforeEach, vi } from 'vitest'
|
|
4
|
+
import {
|
|
5
|
+
Component,
|
|
6
|
+
ExternalComponent,
|
|
7
|
+
FEAASElement,
|
|
8
|
+
registerComponent,
|
|
9
|
+
setElementImplementation
|
|
10
|
+
} from '../src/ui/react.js'
|
|
11
|
+
import { afterEach } from 'node:test'
|
|
5
12
|
|
|
6
13
|
function Hello(props: { firstName: string; telephone: string }) {
|
|
7
14
|
const context = useContext(DataContext)
|
|
@@ -88,7 +95,7 @@ describe('React', () => {
|
|
|
88
95
|
it('render react component', async () => {
|
|
89
96
|
await validate(
|
|
90
97
|
<section>
|
|
91
|
-
<Component src='library/test'
|
|
98
|
+
<Component src='library/test' />
|
|
92
99
|
</section>,
|
|
93
100
|
'<section><feaas-component class="-feaas" library="library" component="test" src="library/test"></feaas-component></section>'
|
|
94
101
|
)
|
|
@@ -283,8 +290,8 @@ Typeof superobject object, {"a":1,"b":2})</div></feaas-external></feaas-componen
|
|
|
283
290
|
'<section><feaas-component class="-feaas" library="a" component="b" src="a/b" fetch="template" data="{"_":{"telephone":321,"superobject":{"1":2}}}"></feaas-component></section>'
|
|
284
291
|
)
|
|
285
292
|
|
|
286
|
-
await document.querySelector('feaas-component')?.whenRendered
|
|
287
|
-
await document.querySelector('feaas-external')?.whenRendered
|
|
293
|
+
await (document.querySelector('feaas-component') as FEAASElement)?.whenRendered
|
|
294
|
+
await (document.querySelector('feaas-external') as FEAASElement)?.whenRendered
|
|
288
295
|
|
|
289
296
|
expect(document.querySelector('feaas-component').outerHTML).toEqual(
|
|
290
297
|
'<feaas-component class="-feaas" library="a" component="b" src="a/b" fetch="template" data="{"_":{"telephone":321,"superobject":{"1":2}}}"><feaas-external data-external-id="MyTestDataComponent" first-name="Yarik" data-path-attributes="_" telephone="321" superobject="{"1":2}" data-attributes-keys="telephone,superobject" datasources="{"_":{"telephone":321,"superobject":{"1":2}}}"><div>\n' +
|
|
@@ -312,4 +319,24 @@ Typeof superobject object, {"a":1,"b":2})</div></feaas-external></feaas-componen
|
|
|
312
319
|
'And context value is INHERITED</div></feaas-external></feaas-component></section>'
|
|
313
320
|
)
|
|
314
321
|
})
|
|
322
|
+
|
|
323
|
+
describe('setImageComponent', () => {
|
|
324
|
+
afterEach(() => {
|
|
325
|
+
setElementImplementation('img', null)
|
|
326
|
+
})
|
|
327
|
+
it('allow component customization', async () => {
|
|
328
|
+
const ImageComponent = (props: any) => React.createElement('x-img', props)
|
|
329
|
+
setElementImplementation('img', ImageComponent)
|
|
330
|
+
await validate(
|
|
331
|
+
<section>
|
|
332
|
+
<Component
|
|
333
|
+
src='library/test'
|
|
334
|
+
template={'<img data-path-src="abc" alt="test">'}
|
|
335
|
+
data={{ abc: 321 }}
|
|
336
|
+
></Component>
|
|
337
|
+
</section>,
|
|
338
|
+
'<section><feaas-component class="-feaas" library="library" component="test" src="library/test" data="{"abc":321}"><x-img data-path-src="abc" alt="test" src="321"></x-img></feaas-component></section>'
|
|
339
|
+
)
|
|
340
|
+
})
|
|
341
|
+
})
|
|
315
342
|
})
|
|
@@ -25,7 +25,7 @@ describe('Components', () => {
|
|
|
25
25
|
const spy = vi.spyOn(global, 'fetch')
|
|
26
26
|
spy.mockImplementation(async (url: string, options: Parameters<typeof fetch>[1] = {}) => {
|
|
27
27
|
if (url.match('CDN/components/L/C/V/R')) {
|
|
28
|
-
return new Response('FRESH', {
|
|
28
|
+
return new Response('<p>FRESH</p>', {
|
|
29
29
|
headers: {
|
|
30
30
|
date: now.toUTCString(),
|
|
31
31
|
'last-modified': earlier.toUTCString()
|
|
@@ -43,7 +43,7 @@ describe('Components', () => {
|
|
|
43
43
|
await expect(component.whenRendered).resolves.toEqual(component)
|
|
44
44
|
expect(spy).toHaveBeenCalledTimes(1)
|
|
45
45
|
|
|
46
|
-
expect(component.innerHTML).toContain('FRESH')
|
|
46
|
+
expect(component.innerHTML).toContain('<p>FRESH</p>')
|
|
47
47
|
})
|
|
48
48
|
|
|
49
49
|
describe('fetch control', () => {
|
|
@@ -116,7 +116,7 @@ describe('Components', () => {
|
|
|
116
116
|
const spy = vi.spyOn(global, 'fetch')
|
|
117
117
|
spy.mockImplementation(async (url: string, options: Parameters<typeof fetch>[1] = {}) => {
|
|
118
118
|
if (url.match('CDN/components/L/C/V/R')) {
|
|
119
|
-
return new Response('FRESH', {
|
|
119
|
+
return new Response('<p>FRESH</p>', {
|
|
120
120
|
headers: {
|
|
121
121
|
date: now.toUTCString(),
|
|
122
122
|
'last-modified': earlier.toUTCString()
|
|
@@ -139,7 +139,7 @@ describe('Components', () => {
|
|
|
139
139
|
|
|
140
140
|
await expect(component.whenRendered).resolves.toEqual(component)
|
|
141
141
|
expect(spy).toHaveBeenCalledTimes(2)
|
|
142
|
-
expect(component.innerHTML).toBe('FRESH')
|
|
142
|
+
expect(component.innerHTML).toBe('<p>FRESH</p>')
|
|
143
143
|
expect(document.head.querySelectorAll('style').length).toEqual(1)
|
|
144
144
|
})
|
|
145
145
|
it('should make data/css requests when fetch="stylesheet data"', async () => {
|
|
@@ -208,7 +208,7 @@ describe('Components', () => {
|
|
|
208
208
|
const spy = vi.spyOn(global, 'fetch')
|
|
209
209
|
spy.mockImplementation(async (url: string, options: Parameters<typeof fetch>[1] = {}) => {
|
|
210
210
|
if (url.match('http://a/components/b/c/d/1.html')) {
|
|
211
|
-
return new Response('FRESH', {
|
|
211
|
+
return new Response('<p>FRESH</p>', {
|
|
212
212
|
headers: {
|
|
213
213
|
date: now.toUTCString(),
|
|
214
214
|
'last-modified': earlier.toUTCString()
|
|
@@ -226,7 +226,7 @@ describe('Components', () => {
|
|
|
226
226
|
expect(spy).toHaveBeenCalledTimes(1)
|
|
227
227
|
|
|
228
228
|
expect(component.outerHTML).toBe(
|
|
229
|
-
`<feaas-component fetch="template data" src="http://a/components/b/c/d/1.html" cdn="http://a" library="b" component="c" version="d" revision="1" class="-feaas">FRESH</feaas-component>`
|
|
229
|
+
`<feaas-component fetch="template data" src="http://a/components/b/c/d/1.html" cdn="http://a" library="b" component="c" version="d" revision="1" class="-feaas"><p>FRESH</p></feaas-component>`
|
|
230
230
|
)
|
|
231
231
|
})
|
|
232
232
|
|
|
@@ -234,7 +234,7 @@ describe('Components', () => {
|
|
|
234
234
|
const spy = vi.spyOn(global, 'fetch')
|
|
235
235
|
spy.mockImplementation(async (url: string, options: Parameters<typeof fetch>[1] = {}) => {
|
|
236
236
|
if (url.match('http://a/components/b/c/d/1.html')) {
|
|
237
|
-
return new Response('FRESH', {
|
|
237
|
+
return new Response('<p>FRESH</p>', {
|
|
238
238
|
headers: {
|
|
239
239
|
date: now.toUTCString(),
|
|
240
240
|
'last-modified': earlier.toUTCString()
|
|
@@ -264,14 +264,14 @@ describe('Components', () => {
|
|
|
264
264
|
const spy = vi.spyOn(global, 'fetch')
|
|
265
265
|
spy.mockImplementation(async (url: string, options: Parameters<typeof fetch>[1] = {}) => {
|
|
266
266
|
if (url.match('http://a/components/b/c/d/1.html')) {
|
|
267
|
-
return new Response('FRESH', {
|
|
267
|
+
return new Response('<p>FRESH</p>', {
|
|
268
268
|
headers: {
|
|
269
269
|
date: now.toUTCString(),
|
|
270
270
|
'last-modified': earlier.toUTCString()
|
|
271
271
|
}
|
|
272
272
|
})
|
|
273
273
|
} else if (url.match('.css')) {
|
|
274
|
-
return new Response('FRESH', {
|
|
274
|
+
return new Response('<p>FRESH</p>', {
|
|
275
275
|
headers: {
|
|
276
276
|
date: /*String(options?.method).toLowerCase() == 'head' ? */ now.toUTCString(),
|
|
277
277
|
'last-modified': earlier.toUTCString()
|
|
@@ -293,7 +293,7 @@ describe('Components', () => {
|
|
|
293
293
|
const spy = vi.spyOn(global, 'fetch')
|
|
294
294
|
spy.mockImplementation(async (url: string, options: Parameters<typeof fetch>[1] = {}) => {
|
|
295
295
|
if (url.match('http://a/components/b/c/d/1.html')) {
|
|
296
|
-
return new Response('FRESH', {
|
|
296
|
+
return new Response('<p>FRESH</p>', {
|
|
297
297
|
headers: {
|
|
298
298
|
date: now.toUTCString(),
|
|
299
299
|
'last-modified': earlier.toUTCString()
|
|
@@ -337,7 +337,7 @@ describe('Components', () => {
|
|
|
337
337
|
const spy = vi.spyOn(global, 'fetch')
|
|
338
338
|
spy.mockImplementation(async (url: string, options: Parameters<typeof fetch>[1] = {}) => {
|
|
339
339
|
if (url.match('http://a/components/b/c/d/1.html')) {
|
|
340
|
-
return new Response('FRESH', {
|
|
340
|
+
return new Response('<p>FRESH</p>', {
|
|
341
341
|
headers: {
|
|
342
342
|
date: now.toUTCString(),
|
|
343
343
|
'last-modified': earlier.toUTCString()
|
|
@@ -355,7 +355,7 @@ describe('Components', () => {
|
|
|
355
355
|
} else {
|
|
356
356
|
if (String(options?.method).toLowerCase() == 'head') await new Promise((r) => setTimeout(r, 50))
|
|
357
357
|
// respond with up to date
|
|
358
|
-
return new Response('FRESH', {
|
|
358
|
+
return new Response('<p>FRESH</p>', {
|
|
359
359
|
headers: {
|
|
360
360
|
date: now.toUTCString(),
|
|
361
361
|
'last-modified': now.toUTCString()
|
|
@@ -416,7 +416,7 @@ describe('Components', () => {
|
|
|
416
416
|
spy.mockImplementation(async (url: string, options: Parameters<typeof fetch>[1] = {}) => {
|
|
417
417
|
if (options.method != 'HEAD' && options['cache'] != 'reload') {
|
|
418
418
|
// Here's cached component
|
|
419
|
-
return new Response('YESTERDAY', {
|
|
419
|
+
return new Response('<p>YESTERDAY</p>', {
|
|
420
420
|
headers: {
|
|
421
421
|
date: earlier.toUTCString(),
|
|
422
422
|
'last-modified': earliest.toUTCString()
|
|
@@ -432,7 +432,7 @@ describe('Components', () => {
|
|
|
432
432
|
})
|
|
433
433
|
} else {
|
|
434
434
|
// Up to date version
|
|
435
|
-
return new Response('FRESH', {
|
|
435
|
+
return new Response('<p>FRESH</p>', {
|
|
436
436
|
headers: {
|
|
437
437
|
date: now.toUTCString(),
|
|
438
438
|
'last-modified': earlier.toUTCString()
|
|
@@ -447,13 +447,13 @@ describe('Components', () => {
|
|
|
447
447
|
const component = document.body.firstElementChild as FEAASComponent
|
|
448
448
|
// Renders cached version initially
|
|
449
449
|
await expect(component.whenRendered).resolves.toEqual(component)
|
|
450
|
-
expect(component.innerHTML).toContain('YESTERDAY')
|
|
450
|
+
expect(component.innerHTML).toContain('<p>YESTERDAY</p>')
|
|
451
451
|
expect(spy).toHaveBeenCalledTimes(2)
|
|
452
452
|
|
|
453
453
|
// whenLoaded only fires when ensures that up-to-date version is loaded
|
|
454
454
|
await expect(component.whenLoaded).resolves.toBeTruthy()
|
|
455
455
|
expect(spy).toHaveBeenCalledTimes(3)
|
|
456
|
-
expect(component.innerHTML).toContain('FRESH')
|
|
456
|
+
expect(component.innerHTML).toContain('<p>FRESH</p>')
|
|
457
457
|
})
|
|
458
458
|
|
|
459
459
|
it('should re-fetch component when attributes change', async () => {
|
|
@@ -525,7 +525,7 @@ describe('Components', () => {
|
|
|
525
525
|
} else {
|
|
526
526
|
if (options.method != 'HEAD' && options['cache'] != 'reload') {
|
|
527
527
|
// Here's cached component
|
|
528
|
-
return new Response('YESTERDAY', {
|
|
528
|
+
return new Response('<p>YESTERDAY</p>', {
|
|
529
529
|
headers: {
|
|
530
530
|
date: earlier.toUTCString(),
|
|
531
531
|
'last-modified': earliest.toUTCString()
|
|
@@ -542,7 +542,7 @@ describe('Components', () => {
|
|
|
542
542
|
} else {
|
|
543
543
|
// Latest
|
|
544
544
|
await new Promise((resolve) => setTimeout(resolve, 100))
|
|
545
|
-
return new Response('FRESH', {
|
|
545
|
+
return new Response('<p>FRESH</p>', {
|
|
546
546
|
headers: {
|
|
547
547
|
date: now.toUTCString(),
|
|
548
548
|
'last-modified': earlier.toUTCString()
|
|
@@ -562,11 +562,11 @@ describe('Components', () => {
|
|
|
562
562
|
await expect(component.whenRendered).resolves.toEqual(component)
|
|
563
563
|
const stylesheet = document.head.querySelector('style') as HTMLStyleElement
|
|
564
564
|
expect(stylesheet.innerHTML).toEqual('YESTERDAY {}')
|
|
565
|
-
expect(component.innerHTML).toEqual('YESTERDAY')
|
|
565
|
+
expect(component.innerHTML).toEqual('<p>YESTERDAY</p>')
|
|
566
566
|
// Component will update itself with stale cached stylesheet
|
|
567
|
-
await expect(component.whenLoaded).resolves.toEqual('FRESH')
|
|
567
|
+
await expect(component.whenLoaded).resolves.toEqual('<p>FRESH</p>')
|
|
568
568
|
expect(stylesheet.innerHTML).toEqual('YESTERDAY {}')
|
|
569
|
-
expect(component.innerHTML).toEqual('FRESH')
|
|
569
|
+
expect(component.innerHTML).toEqual('<p>FRESH</p>')
|
|
570
570
|
await new Promise((resolve) => setTimeout(resolve, 200))
|
|
571
571
|
// Stylesheet will update later
|
|
572
572
|
expect(stylesheet.innerHTML).toEqual('FRESH {}')
|
package/test/tsconfig.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FEAASComponent.d.ts","sourceRoot":"","sources":["../../src/components/FEAASComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAgB,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY;;;;;;;;;;;;;;EAwCzD;AAED,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA;A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CAAA;gBACZ,OAAO,EAAE,MAAM,CAAA;gBACf,SAAS,EAAE,MAAM,CAAA;gBACjB,OAAO,CAAC,EAAE,MAAM,CAAA;gBAChB,QAAQ,CAAC,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAA;aAC5C,GACD;gBAAE,GAAG,EAAE,MAAM,CAAA;aAAE,GACf;gBAAE,QAAQ,EAAE,MAAM,CAAA;aAAE,CACvB,CAAA;SACF;KACF;CACF;AAGD,OAAO,EAAE,cAAc,IAAI,SAAS,EAAE,oBAAoB,IAAI,cAAc,EAAE,CAAA"}
|
|
@@ -281,7 +281,7 @@ export declare class FEAASElement<Props = any, Payload = any> extends WebCompone
|
|
|
281
281
|
};
|
|
282
282
|
contextType?: React.Context<any>;
|
|
283
283
|
};
|
|
284
|
-
getReactElement(target?: FEAASElement, props?: any): JSX.Element;
|
|
284
|
+
getReactElement(target?: FEAASElement, props?: any): React.JSX.Element;
|
|
285
285
|
getReactWrapper(target?: FEAASElement, displayName?: string): React.FunctionComponent<{}>;
|
|
286
286
|
uid: string;
|
|
287
287
|
getUID(): string;
|
|
@@ -54,7 +54,7 @@ export declare class FEAASContext extends FEAASElement<FEAASContextProps, typeof
|
|
|
54
54
|
onStatusChange: FEAASContextImports.SDKStatusCallback;
|
|
55
55
|
whenSDKReady: ControlledPromise<FEAASContextImports.SDK>;
|
|
56
56
|
getPortalRoot(): HTMLElement | ShadowRoot | FEAASElement<any, any>;
|
|
57
|
-
render({ children, library }: React.PropsWithChildren<FEAASContextProps>, { AppContext, Chakra: { Button, Tooltip }, React }: typeof this.payload): JSX.Element;
|
|
57
|
+
render({ children, library }: React.PropsWithChildren<FEAASContextProps>, { AppContext, Chakra: { Button, Tooltip }, React }: typeof this.payload): FEAASContextImports.React.JSX.Element;
|
|
58
58
|
}
|
|
59
59
|
declare global {
|
|
60
60
|
namespace JSX {
|
|
@@ -23,7 +23,7 @@ export default class FEAASExternal extends FEAASElement<FEAASExternalProps, Reac
|
|
|
23
23
|
getProps(): FEAASExternalProps;
|
|
24
24
|
static Preview(props: Partial<FEAASComponentProps<any>> & {
|
|
25
25
|
src: string;
|
|
26
|
-
}): JSX.Element;
|
|
26
|
+
}): React.JSX.Element;
|
|
27
27
|
static linkComponents(components: Promise<any>[]): () => any;
|
|
28
28
|
static registered: BYOC.RegisteredComponents;
|
|
29
29
|
static registerComponent: typeof BYOC.registerComponent;
|
|
@@ -51,7 +51,7 @@ export declare class FEAASPicker extends FEAASElement<FEAASPickerProps, typeof F
|
|
|
51
51
|
};
|
|
52
52
|
load(): Promise<typeof FEAASPickerImports>;
|
|
53
53
|
connectedCallback(): void;
|
|
54
|
-
render({ placeholder, context, mode, dialog, children, variant }: React.PropsWithChildren<FEAASPickerProps>, { Picker, React, useContext, EnvironmentContext, useLibrary, useSDK, BYOC }: typeof FEAASPickerImports): JSX.Element;
|
|
54
|
+
render({ placeholder, context, mode, dialog, children, variant }: React.PropsWithChildren<FEAASPickerProps>, { Picker, React, useContext, EnvironmentContext, useLibrary, useSDK, BYOC }: typeof FEAASPickerImports): FEAASPickerImports.React.JSX.Element;
|
|
55
55
|
}
|
|
56
56
|
declare global {
|
|
57
57
|
namespace JSX {
|
package/types/ui/react.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ export * from '../headless.js';
|
|
|
6
6
|
export { External, FEAASExternalPropsObject, getComponent, linkComponents, registerComponent } from './FEAASExternal.js';
|
|
7
7
|
export * from './index.js';
|
|
8
8
|
export { renderHTMLContent };
|
|
9
|
+
/**
|
|
10
|
+
* Set custom implementation for a HTML tag name. Useful for Next.js Image component, handling image optimization.
|
|
11
|
+
*
|
|
12
|
+
* @param Component
|
|
13
|
+
*/
|
|
14
|
+
export declare function setElementImplementation(tagName: string, Component: React.Component | React.FC): void;
|
|
9
15
|
type FEEASReactComponentFetch = string[] | string | null | undefined | boolean;
|
|
10
16
|
export declare function normalizeFetchAttribute(fetch: FEEASReactComponentFetch): any[];
|
|
11
17
|
export type FEAASReactComponentProps = FEAASComponentProps & {
|
|
@@ -20,7 +26,7 @@ export type FEAASReactComponentProps = FEAASComponentProps & {
|
|
|
20
26
|
* @param {FEAASCDNStylesheetParams | FEAASCDNStylesheetSource} props - The properties for including the stylesheet.
|
|
21
27
|
* @returns {JSX.Element} The <link> element for the stylesheet.
|
|
22
28
|
*/
|
|
23
|
-
export declare const FEAASReactStylesheet: (props: FEAASCDNStylesheetParams | FEAASCDNStylesheetSource) => JSX.Element;
|
|
29
|
+
export declare const FEAASReactStylesheet: (props: FEAASCDNStylesheetParams | FEAASCDNStylesheetSource) => React.JSX.Element;
|
|
24
30
|
/**
|
|
25
31
|
* An asynchronous wrapper over FEAAS.Component for use in React, especially suited for Next.js.
|
|
26
32
|
* This component fetches HTML and data asynchronously for server-side rendering with data mapping.
|
|
@@ -28,7 +34,7 @@ export declare const FEAASReactStylesheet: (props: FEAASCDNStylesheetParams | FE
|
|
|
28
34
|
* @param {FEAASReactComponentProps} props - The properties for the component.
|
|
29
35
|
* @returns {Promise<JSX.Element>} The JSX element representing the component.
|
|
30
36
|
*/
|
|
31
|
-
export declare const FEAASReactServerComponent: ({ data, fetch, ...props }: FEAASReactComponentProps) => Promise<JSX.Element>;
|
|
37
|
+
export declare const FEAASReactServerComponent: ({ data, fetch, ...props }: FEAASReactComponentProps) => Promise<React.JSX.Element>;
|
|
32
38
|
/**
|
|
33
39
|
* A wrapper over FEAAS.Component for use in React. It converts a passed template HTML into React,
|
|
34
40
|
* allowing external components in the render tree. Data can be provided in JSON format.
|
|
@@ -38,7 +44,7 @@ export declare const FEAASReactServerComponent: ({ data, fetch, ...props }: FEAA
|
|
|
38
44
|
*/
|
|
39
45
|
export declare function FEAASReactComponent({ data, lastModified, fetchedData, ...props }: FEAASReactComponentProps & {
|
|
40
46
|
fetchedData?: any;
|
|
41
|
-
}): JSX.Element;
|
|
47
|
+
}): React.JSX.Element;
|
|
42
48
|
/**
|
|
43
49
|
* Converts an HTMLNode into a React tree, ensuring proper context access for external components.
|
|
44
50
|
*
|
|
@@ -57,6 +63,6 @@ export declare const ExternalComponent: typeof BYOC.Component;
|
|
|
57
63
|
export declare const ReactExternalComponent: typeof BYOC.RegularComponent;
|
|
58
64
|
export declare const NextExternalComponent: typeof BYOC.NextComponent;
|
|
59
65
|
export declare const Component: typeof FEAASReactComponent;
|
|
60
|
-
export declare const ServerComponent: ({ data, fetch, ...props }: FEAASReactComponentProps) => Promise<JSX.Element>;
|
|
61
|
-
export declare const Stylesheet: (props: FEAASCDNStylesheetParams | FEAASCDNStylesheetSource) => JSX.Element;
|
|
66
|
+
export declare const ServerComponent: ({ data, fetch, ...props }: FEAASReactComponentProps) => Promise<React.JSX.Element>;
|
|
67
|
+
export declare const Stylesheet: (props: FEAASCDNStylesheetParams | FEAASCDNStylesheetSource) => React.JSX.Element;
|
|
62
68
|
//# sourceMappingURL=react.d.ts.map
|
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,
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/ui/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAA;AACpD,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAoB,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAE9E,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EAOpB,MAAM,YAAY,CAAA;AACnB,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACxH,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,iBAAiB,EAAE,CAAA;AAG5B;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,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