@sitecore-feaas/clientside 0.3.12 → 0.3.14

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.
@@ -4,7 +4,13 @@ import { FEAASElement, WebComponent } from '../components/FEAASElement.js'
4
4
  import { ReactJSX, ReactModules } from '../components/FEAASReactElement.js'
5
5
  import { kebabCase, reverseKebabCase } from '../utils/string.js'
6
6
  import { Component, FEAASComponentProps } from './react.js'
7
- import type { ExternalComponent, ExternalComponentOptions, JSONSchema, UISchema } from '@sitecore-feaas/sdk'
7
+ import type {
8
+ ExternalComponent,
9
+ ExternalComponentOptions,
10
+ JSONSchema,
11
+ ObjectSchema,
12
+ UISchema
13
+ } from '@sitecore-feaas/sdk'
8
14
 
9
15
  /** Checks if title exists in a property and if not, it generates it from (kebab-cased) property key */
10
16
  const addTitles = (properties: { [key: string]: any }) =>
@@ -203,7 +209,7 @@ export default class FEAASExternal extends FEAASElement<FEAASExternalProps, Reac
203
209
  )
204
210
  const id = options.name
205
211
  const { thumbnail, group, ui: uiSchema, ...schemaOptions } = options
206
- const schema = { ...schemaOptions, type: 'object' } as JSONSchema
212
+ const schema = { ...schemaOptions, type: 'object' } as ObjectSchema
207
213
  FEAASExternal.registered[id] = {
208
214
  component,
209
215
  name: id,
@@ -303,8 +309,15 @@ class FEAASExternalRegistration extends WebComponent {
303
309
  }
304
310
  }
305
311
 
306
- if (typeof window !== 'undefined' && window)
307
- Object.defineProperty(window, 'FEAASExternalComponents', { get: () => FEAASExternal.registered })
312
+ if (typeof window !== 'undefined' && window) {
313
+ if (!('FEAASExternalComponents' in window))
314
+ Object.defineProperty(window, 'FEAASExternalComponents', { get: () => FEAASExternal.registered })
315
+ else if (!location.hostname.startsWith('xmc-'))
316
+ console.error(
317
+ 'FEAAS Clientside is loaded twice into the bundle. This can lead to unexpected problems and needs to be resolved'
318
+ )
319
+ }
320
+
308
321
  FEAASExternal.register('feaas-external')
309
322
  FEAASExternal.setRegistrationCallback()
310
323
  FEAASExternalRegistration.register('feaas-registration')
@@ -48,6 +48,8 @@ export class FEAASPicker extends FEAASElement<FEAASPickerProps, typeof FEAASPick
48
48
  const datasources = useSDK('datasources')
49
49
  const rules = useLibrary('stylesheet.styles')
50
50
  const component = components.find((c) => c.id == context?.getAttribute('component'))
51
+ const componentName = context?.getAttribute('data-external-id')
52
+ const externalComponent = useSDK('externalComponents').find((c) => c.name == componentName)
51
53
  var settings = context?.getAttribute('data')
52
54
  if (settings) {
53
55
  try {
@@ -62,15 +64,18 @@ export class FEAASPicker extends FEAASElement<FEAASPickerProps, typeof FEAASPick
62
64
  themeContext={context}
63
65
  placeholder={placeholder}
64
66
  component={component}
67
+ externalComponent={externalComponent}
65
68
  datasource={datasource}
66
69
  data={settings}
67
70
  versionId={context?.getAttribute('version')}
68
- mode={mode || (component ? 'component' : null)}
71
+ mode={mode || (component ? 'component' : componentName ? 'external' : null)}
69
72
  setAttribute={(context, attribute, value) => {
70
73
  if (attribute == 'data' && value) value = JSON.stringify(value)
71
74
  this.props.setAttribute(context, attribute, value)
72
75
  forceRender()
73
76
  }}
77
+ getAttribute={(c, property) => context?.getAttribute(property)}
78
+ dialog={dialog}
74
79
  context={context}
75
80
  variant={variant}
76
81
  onModeChange={(mode, dialog) => {