@empathyco/x-components 6.0.0-alpha.20 → 6.0.0-alpha.21
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/CHANGELOG.md +9 -0
- package/design-system/deprecated-full-theme.css +2499 -2499
- package/docs/API-reference/api/x-components.installxoptions.domelement.md +1 -1
- package/docs/API-reference/api/x-components.installxoptions.md +1 -1
- package/js/x-installer/x-installer/x-installer.js +3 -3
- package/js/x-installer/x-installer/x-installer.js.map +1 -1
- package/package.json +2 -2
- package/report/x-components.api.json +19 -1
- package/report/x-components.api.md +2 -2
- package/types/x-installer/x-installer/types.d.ts +1 -1
- package/types/x-installer/x-installer/types.d.ts.map +1 -1
- package/types/x-installer/x-installer/x-installer.d.ts +4 -4
- package/types/x-installer/x-installer/x-installer.d.ts.map +1 -1
|
@@ -9,5 +9,5 @@ An Element \| string \| function to indicate the HTML element that will contain
|
|
|
9
9
|
**Signature:**
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
domElement?: Element | string | ((snippetConfig: NormalisedSnippetConfig) => Element | string);
|
|
12
|
+
domElement?: Element | ShadowRoot | string | ((snippetConfig: NormalisedSnippetConfig) => Element | ShadowRoot | string);
|
|
13
13
|
```
|
|
@@ -19,7 +19,7 @@ export interface InstallXOptions<API extends XAPI = XAPI> extends XPluginOptions
|
|
|
19
19
|
| --- | --- | --- | --- |
|
|
20
20
|
| [api?](./x-components.installxoptions.api.md) | | API \| false | _(Optional)_ The API to expose globally. If is not passed the default [BaseXAPI](./x-components.basexapi.md) will be used. If a <code>false</code> value is passed then the API is not created. |
|
|
21
21
|
| [bus?](./x-components.installxoptions.bus.md) | | XBus<[XEventsTypes](./x-components.xeventstypes.md)<!-- -->, [WireMetadata](./x-components.wiremetadata.md)<!-- -->> | _(Optional)_ The used in the [XPlugin](./x-components.xplugin.md)<!-- -->. If not passed an instance of The will be used. |
|
|
22
|
-
| [domElement?](./x-components.installxoptions.domelement.md) | | Element \| string \| ((snippetConfig: [NormalisedSnippetConfig](./x-components.normalisedsnippetconfig.md)<!-- -->) => Element \| string) | _(Optional)_ An Element \| string \| function to indicate the HTML element that will contain the Vue application. If it isn't passed, the [XInstaller](./x-components.xinstaller.md) will create the target element. |
|
|
22
|
+
| [domElement?](./x-components.installxoptions.domelement.md) | | Element \| ShadowRoot \| string \| ((snippetConfig: [NormalisedSnippetConfig](./x-components.normalisedsnippetconfig.md)<!-- -->) => Element \| ShadowRoot \| string) | _(Optional)_ An Element \| string \| function to indicate the HTML element that will contain the Vue application. If it isn't passed, the [XInstaller](./x-components.xinstaller.md) will create the target element. |
|
|
23
23
|
| [onCreateApp?](./x-components.installxoptions.oncreateapp.md) | | (app: App) => void | _(Optional)_ Callback to invoke after instantiating the app. |
|
|
24
24
|
| [plugin?](./x-components.installxoptions.plugin.md) | | Plugin<[XPluginOptions](./x-components.xpluginoptions.md)<!-- -->> | _(Optional)_ The XPlugin which will be installed. If not passed, an instance of [XPlugin](./x-components.xplugin.md) will be installed. |
|
|
25
25
|
| [rootComponent?](./x-components.installxoptions.rootcomponent.md) | | Component | _(Optional)_ The Vue component used as root of the application. If it is not passed, no Vue Application is initialized, only plugin installed. |
|
|
@@ -234,10 +234,10 @@ class XInstaller {
|
|
|
234
234
|
* returns an Element or element selector to use.
|
|
235
235
|
* If it is not present, a new <div> Element is created and appended to the body.
|
|
236
236
|
*
|
|
237
|
-
* @param domElement - {@link InstallXOptions.domElement
|
|
238
|
-
* to mount the Vue Application.
|
|
237
|
+
* @param domElement - {@link InstallXOptions.domElement} Element, ShadowRoot, string or function
|
|
238
|
+
* used to mount the Vue Application.
|
|
239
239
|
*
|
|
240
|
-
* @returns The Element to use as mounting target for the Vue Application.
|
|
240
|
+
* @returns The Element or ShadowRoot to use as mounting target for the Vue Application.
|
|
241
241
|
* @internal
|
|
242
242
|
*/
|
|
243
243
|
getMountingTarget(domElement) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"x-installer.js","sources":["../../../../src/x-installer/x-installer/x-installer.ts"],"sourcesContent":["import { forEach, isFunction } from '@empathyco/x-utils';\nimport { App, createApp, reactive, Plugin } from 'vue';\nimport { XBus } from '@empathyco/x-bus';\nimport { XPlugin } from '../../plugins/x-plugin';\nimport { XPluginOptions } from '../../plugins/x-plugin.types';\nimport { NormalisedSnippetConfig, SnippetConfig, XAPI } from '../api/api.types';\nimport { BaseXAPI } from '../api/base-api';\nimport { WireMetadata, XEventsTypes } from '../../wiring/index';\nimport { bus } from '../../plugins/x-bus';\nimport { InitWrapper, InstallXOptions } from './types';\n\ndeclare global {\n interface Window {\n InterfaceX?: XAPI;\n initX?: (() => SnippetConfig) | SnippetConfig;\n }\n}\n\n/**\n * The purpose of this class is to offer a quick way to initialize the XComponents in a setup\n * project. It allows to receive all the options in {@link InstallXOptions} which is an extension\n * of {@link XPluginOptions} with all the options for the plugin and some options more.\n *\n * This class does multiple things:\n * 1. Install the {@link XPlugin} with the {@link XPluginOptions}.\n * 2. Creates the public {@link XAPI} and add it to global window.\n * 3. Creates the Vue Application for the customer project.\n *\n * The steps 2 & 3 are optional and depends on the options passed in {@link InstallXOptions}.\n *\n * @example The way to use this class is the next:\n * 1. Create the installer passing in the {@link InstallXOptions}. This only save the options:\n *\n * ```\n * const installer = new XInstaller(installXOptions)\n * ```\n *\n * 2. Initialize passing the {@link SnippetConfig}. This installs the plugin and creates the App.\n * There are 3 different ways to do this:\n *\n * 2.1 Using the created installer:\n *\n * ```\n * installer.init(snippetConfig)\n * ```\n *\n * 2.2 If the API option is enabled (`createAPI` is `true` in {@link InstallXOptions}, or\n * is not present as the default value is `true`) then this init step can be done with\n * the Public API:\n *\n * ```\n * window.InterfaceX.init(snippetConfig)\n * ```\n *\n * 2.3 When the script of the project build is loaded it searches for a global `initX`\n * variable that the customer must have in their website. This variable can be a\n * function that returns the {@link SnippetConfig} or an object that contains the\n * {@link SnippetConfig} itself:\n *\n * ```\n * window.initX = function() {\n * return {\n * instance,\n * env,\n * scope,\n * lang,\n * uiLang,\n * currency,\n * consent,\n * documentDirection\n * };\n * };\n * ```\n *\n * ```\n * window.initX = {\n * instance,\n * env,\n * scope,\n * lang,\n * uiLang,\n * currency,\n * consent,\n * documentDirection\n * };\n * ```\n *\n * @public\n */\nexport class XInstaller {\n private app!: App;\n private api?: XAPI;\n\n /**\n * The configuration coming from the snippet {@link SnippetConfig}.\n *\n * @internal\n */\n protected snippetConfig?: NormalisedSnippetConfig;\n\n /**\n * Receives the {@link InstallXOptions} and merges it with the default fallback options. Also\n * creates the public {@link XAPI}.\n *\n * @remarks Auto initializes the Vue application if window.initX is defined as a function or\n * object specifying the {@link SnippetConfig | snippet config}.\n *\n *\n * @param options - The {@link InstallXOptions}.\n *\n * @public\n */\n public constructor(protected readonly options: InstallXOptions) {\n this.createAPI();\n }\n\n /**\n * Creates the public {@link XAPI} using the `api` option from {@link InstallXOptions}. If this\n * `api` option is not passed, then a default {@link BaseXAPI} is created. To disable the API\n * creation the value `false` must be passed in the `api` option.\n *\n * @internal\n */\n protected createAPI(): void {\n const { api } = this.options;\n if (api !== false) {\n this.api = api ?? new BaseXAPI();\n this.api.setInitCallback(this.init.bind(this));\n this.api.setSnippetConfigCallback(this.updateSnippetConfig.bind(this));\n this.api.setSnippetConfigGetter(this.getSnippetConfig.bind(this));\n window.InterfaceX = this.api;\n }\n }\n\n /**\n * Retrieves the {@link SnippetConfig | snippet config} it is defined in the window.initX.\n *\n * @returns The snippet config if it is defined or undefined otherwise.\n *\n * @internal\n */\n private retrieveSnippetConfig(): SnippetConfig | undefined {\n if (typeof window.initX === 'function') {\n return window.initX();\n } else if (typeof window.initX === 'object') {\n return window.initX;\n }\n }\n\n /**\n * Receives the {@link SnippetConfig | snippet config} or retrieves it from window.initX and\n * installs the plugin and initializes the Vue application.\n *\n * @param snippetConfig - The {@link SnippetConfig} that receives from snippet integration.\n *\n * @returns If {@link SnippetConfig | snippet config} is passed or configured in window.initX,\n * returns an object with the {@link XAPI}, the {@link @empathyco/x-bus#XBus}, the {@link XPlugin}\n * and the Vue application instance. Else, a rejected promise is returned.\n *\n * @public\n */\n init(snippetConfig: SnippetConfig): Promise<InitWrapper>;\n init(): Promise<InitWrapper | void>;\n async init(snippetConfig = this.retrieveSnippetConfig()): Promise<InitWrapper | void> {\n if (snippetConfig) {\n this.snippetConfig = reactive(this.normaliseSnippetConfig(snippetConfig));\n this.createApp();\n const bus = this.createBus();\n const pluginOptions = this.getPluginOptions();\n const plugin = this.installPlugin(pluginOptions, bus);\n await this.installExtraPlugins(bus);\n this.api?.setBus(bus);\n this.app.mount(this.getMountingTarget(this.options.domElement));\n\n return {\n api: this.api,\n app: this.app,\n bus,\n plugin\n };\n }\n\n return Promise.resolve();\n }\n\n /**\n * Creates the {@link XPluginOptions} object.\n *\n * @returns The {@link XPluginOptions} object.\n *\n * @internal\n */\n protected getPluginOptions(): XPluginOptions {\n const { adapter, store, initialXModules, xModules, __PRIVATE__xModules } = this.options;\n return {\n adapter,\n store,\n xModules,\n initialXModules,\n __PRIVATE__xModules\n };\n }\n\n /**\n * This method returns the bus instance to be used in the {@link XPlugin} and in the {@link XAPI}.\n * It returns the `bus` parameter in the {@link InstallXOptions} or if not provided, then\n * creates a new instance of {@link @empathyco/x-bus#XPriorityBus | bus}.\n *\n * @returns XBus - The bus instance.\n *\n * @internal\n */\n protected createBus(): XBus<XEventsTypes, WireMetadata> {\n return this.options.bus ?? bus;\n }\n\n /**\n * Creates and install the Vue Plugin. If `plugin` parameter is passed in the\n * {@link InstallXOptions}, then it is used. If not, then a new instance of {@link XPlugin} is\n * created and installed.\n *\n * @param pluginOptions - The {@link XPluginOptions} to passed as parameter to the install method\n * of the plugin.\n * @param bus - The {@link @empathyco/x-bus#XBus} to be used to create the XPlugin.\n *\n * @returns Plugin<XPluginOption> - The plugin instance.\n * @internal\n */\n protected installPlugin(\n pluginOptions: XPluginOptions,\n bus: XBus<XEventsTypes, WireMetadata>\n ): Plugin<XPluginOptions> {\n const plugin = this.options.plugin ?? new XPlugin(bus);\n this.app.use(plugin, pluginOptions);\n return plugin;\n }\n\n /**\n * Runs the installExtraPlugins callback defined in the {@link InstallXOptions}\n * to allow the user to install more plugins to the App.\n *\n * @param bus - The events bus used in the application.\n * @returns An empty promise.\n * @internal\n */\n protected installExtraPlugins(bus: XBus<XEventsTypes, WireMetadata>): Promise<void> {\n return Promise.resolve(\n this.options.installExtraPlugins?.({ app: this.app, snippet: this.snippetConfig!, bus })\n );\n }\n\n /**\n * In the case that the `rootComponent` parameter is present in the {@link InstallXOptions},\n * then a new Vue application is created using that component as root.\n *\n * @internal\n */\n protected createApp(): void {\n if (this.options.rootComponent !== undefined) {\n this.app = createApp(this.options.rootComponent);\n this.app.provide('snippetConfig', this.snippetConfig);\n this.options.onCreateApp?.(this.app);\n }\n }\n\n protected normaliseSnippetConfig(snippetConfig: SnippetConfig): NormalisedSnippetConfig;\n protected normaliseSnippetConfig(snippetConfig: Partial<SnippetConfig>): Partial<SnippetConfig>;\n /**\n * Transforms the snippet configuration.\n * - If `lang` is provided and `uiLang` is not, it sets `uiLang=lang`.\n *\n * @param snippetConfig - The snippet config to normalise.\n * @returns The normalised version of the given snippet config.\n * @internal\n */\n protected normaliseSnippetConfig(\n snippetConfig: SnippetConfig | Partial<SnippetConfig>\n ): NormalisedSnippetConfig | Partial<SnippetConfig> {\n if (snippetConfig.lang) {\n snippetConfig.uiLang ??= snippetConfig.lang;\n }\n return snippetConfig;\n }\n\n /**\n * It returns the HTML element to mount the Vue Application. If the `domElement` parameter in\n * the {@link InstallXOptions} is an Element or an element selector, then this will be used.\n * The `domElement` can also be a function with the {@link SnippetConfig} as parameter which\n * returns an Element or element selector to use.\n * If it is not present, a new <div> Element is created and appended to the body.\n *\n * @param domElement - {@link InstallXOptions.domElement | Element, string or function} Used\n * to mount the Vue Application.\n *\n * @returns The Element to use as mounting target for the Vue Application.\n * @internal\n */\n protected getMountingTarget(domElement?: InstallXOptions['domElement']): Element {\n if (isFunction(domElement)) {\n domElement = domElement(this.snippetConfig!);\n }\n if (typeof domElement === 'string') {\n const target = document.querySelector(domElement);\n if (!target) {\n throw Error(\n `XComponents app couldn't be mounted: Element \"${domElement}\" couldn't be found`\n );\n }\n return target;\n }\n return domElement ?? document.body.appendChild(document.createElement('div'));\n }\n\n /**\n * It updates all the provided properties from the current snippet config.\n *\n * @param newSnippetConfig - All the properties to be updated in the {@link SnippetConfig}.\n *\n * @internal\n */\n protected updateSnippetConfig(newSnippetConfig: Partial<SnippetConfig>): void {\n if (!this.snippetConfig) {\n return;\n }\n forEach(this.normaliseSnippetConfig(newSnippetConfig), (name, value) => {\n this.snippetConfig![name] = value;\n });\n }\n\n /**\n * Getter for the snippet config object.\n *\n * @returns The {@link NormalisedSnippetConfig | snippetConfig} object.\n *\n * @public\n */\n protected getSnippetConfig(): NormalisedSnippetConfig {\n return this.snippetConfig!;\n }\n}\n"],"names":[],"mappings":";;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEG;MACU,UAAU,CAAA;AAWrB;;;;;;;;;;;AAWG;AACH,IAAA,WAAA,CAAsC,OAAwB,EAAA;QAAxB,IAAO,CAAA,OAAA,GAAP,OAAO,CAAiB;QAC5D,IAAI,CAAC,SAAS,EAAE,CAAC;KAClB;AAED;;;;;;AAMG;IACO,SAAS,GAAA;AACjB,QAAA,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,GAAG,KAAK,KAAK,EAAE;YACjB,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,IAAI,QAAQ,EAAE,CAAC;AACjC,YAAA,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/C,YAAA,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC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AC,GAAG,KAAK,CAAC;AACpC,SAAC,CAAC,CAAC;KACJ;AAED;;;;;;AAMG;IACO,gBAAgB,GAAA;QACxB,OAAO,IAAI,CAAC,aAAc,CAAC;KAC5B;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"x-installer.js","sources":["../../../../src/x-installer/x-installer/x-installer.ts"],"sourcesContent":["import { forEach, isFunction } from '@empathyco/x-utils';\nimport { App, createApp, reactive, Plugin } from 'vue';\nimport { XBus } from '@empathyco/x-bus';\nimport { XPlugin } from '../../plugins/x-plugin';\nimport { XPluginOptions } from '../../plugins/x-plugin.types';\nimport { NormalisedSnippetConfig, SnippetConfig, XAPI } from '../api/api.types';\nimport { BaseXAPI } from '../api/base-api';\nimport { WireMetadata, XEventsTypes } from '../../wiring/index';\nimport { bus } from '../../plugins/x-bus';\nimport { InitWrapper, InstallXOptions } from './types';\n\ndeclare global {\n interface Window {\n InterfaceX?: XAPI;\n initX?: (() => SnippetConfig) | SnippetConfig;\n }\n}\n\n/**\n * The purpose of this class is to offer a quick way to initialize the XComponents in a setup\n * project. It allows to receive all the options in {@link InstallXOptions} which is an extension\n * of {@link XPluginOptions} with all the options for the plugin and some options more.\n *\n * This class does multiple things:\n * 1. Install the {@link XPlugin} with the {@link XPluginOptions}.\n * 2. Creates the public {@link XAPI} and add it to global window.\n * 3. Creates the Vue Application for the customer project.\n *\n * The steps 2 & 3 are optional and depends on the options passed in {@link InstallXOptions}.\n *\n * @example The way to use this class is the next:\n * 1. Create the installer passing in the {@link InstallXOptions}. This only save the options:\n *\n * ```\n * const installer = new XInstaller(installXOptions)\n * ```\n *\n * 2. Initialize passing the {@link SnippetConfig}. This installs the plugin and creates the App.\n * There are 3 different ways to do this:\n *\n * 2.1 Using the created installer:\n *\n * ```\n * installer.init(snippetConfig)\n * ```\n *\n * 2.2 If the API option is enabled (`createAPI` is `true` in {@link InstallXOptions}, or\n * is not present as the default value is `true`) then this init step can be done with\n * the Public API:\n *\n * ```\n * window.InterfaceX.init(snippetConfig)\n * ```\n *\n * 2.3 When the script of the project build is loaded it searches for a global `initX`\n * variable that the customer must have in their website. This variable can be a\n * function that returns the {@link SnippetConfig} or an object that contains the\n * {@link SnippetConfig} itself:\n *\n * ```\n * window.initX = function() {\n * return {\n * instance,\n * env,\n * scope,\n * lang,\n * uiLang,\n * currency,\n * consent,\n * documentDirection\n * };\n * };\n * ```\n *\n * ```\n * window.initX = {\n * instance,\n * env,\n * scope,\n * lang,\n * uiLang,\n * currency,\n * consent,\n * documentDirection\n * };\n * ```\n *\n * @public\n */\nexport class XInstaller {\n private app!: App;\n private api?: XAPI;\n\n /**\n * The configuration coming from the snippet {@link SnippetConfig}.\n *\n * @internal\n */\n protected snippetConfig?: NormalisedSnippetConfig;\n\n /**\n * Receives the {@link InstallXOptions} and merges it with the default fallback options. Also\n * creates the public {@link XAPI}.\n *\n * @remarks Auto initializes the Vue application if window.initX is defined as a function or\n * object specifying the {@link SnippetConfig | snippet config}.\n *\n *\n * @param options - The {@link InstallXOptions}.\n *\n * @public\n */\n public constructor(protected readonly options: InstallXOptions) {\n this.createAPI();\n }\n\n /**\n * Creates the public {@link XAPI} using the `api` option from {@link InstallXOptions}. If this\n * `api` option is not passed, then a default {@link BaseXAPI} is created. To disable the API\n * creation the value `false` must be passed in the `api` option.\n *\n * @internal\n */\n protected createAPI(): void {\n const { api } = this.options;\n if (api !== false) {\n this.api = api ?? new BaseXAPI();\n this.api.setInitCallback(this.init.bind(this));\n this.api.setSnippetConfigCallback(this.updateSnippetConfig.bind(this));\n this.api.setSnippetConfigGetter(this.getSnippetConfig.bind(this));\n window.InterfaceX = this.api;\n }\n }\n\n /**\n * Retrieves the {@link SnippetConfig | snippet config} it is defined in the window.initX.\n *\n * @returns The snippet config if it is defined or undefined otherwise.\n *\n * @internal\n */\n private retrieveSnippetConfig(): SnippetConfig | undefined {\n if (typeof window.initX === 'function') {\n return window.initX();\n } else if (typeof window.initX === 'object') {\n return window.initX;\n }\n }\n\n /**\n * Receives the {@link SnippetConfig | snippet config} or retrieves it from window.initX and\n * installs the plugin and initializes the Vue application.\n *\n * @param snippetConfig - The {@link SnippetConfig} that receives from snippet integration.\n *\n * @returns If {@link SnippetConfig | snippet config} is passed or configured in window.initX,\n * returns an object with the {@link XAPI}, the {@link @empathyco/x-bus#XBus}, the {@link XPlugin}\n * and the Vue application instance. Else, a rejected promise is returned.\n *\n * @public\n */\n init(snippetConfig: SnippetConfig): Promise<InitWrapper>;\n init(): Promise<InitWrapper | void>;\n async init(snippetConfig = this.retrieveSnippetConfig()): Promise<InitWrapper | void> {\n if (snippetConfig) {\n this.snippetConfig = reactive(this.normaliseSnippetConfig(snippetConfig));\n this.createApp();\n const bus = this.createBus();\n const pluginOptions = this.getPluginOptions();\n const plugin = this.installPlugin(pluginOptions, bus);\n await this.installExtraPlugins(bus);\n this.api?.setBus(bus);\n this.app.mount(this.getMountingTarget(this.options.domElement));\n\n return {\n api: this.api,\n app: this.app,\n bus,\n plugin\n };\n }\n\n return Promise.resolve();\n }\n\n /**\n * Creates the {@link XPluginOptions} object.\n *\n * @returns The {@link XPluginOptions} object.\n *\n * @internal\n */\n protected getPluginOptions(): XPluginOptions {\n const { adapter, store, initialXModules, xModules, __PRIVATE__xModules } = this.options;\n return {\n adapter,\n store,\n xModules,\n initialXModules,\n __PRIVATE__xModules\n };\n }\n\n /**\n * This method returns the bus instance to be used in the {@link XPlugin} and in the {@link XAPI}.\n * It returns the `bus` parameter in the {@link InstallXOptions} or if not provided, then\n * creates a new instance of {@link @empathyco/x-bus#XPriorityBus | bus}.\n *\n * @returns XBus - The bus instance.\n *\n * @internal\n */\n protected createBus(): XBus<XEventsTypes, WireMetadata> {\n return this.options.bus ?? bus;\n }\n\n /**\n * Creates and install the Vue Plugin. If `plugin` parameter is passed in the\n * {@link InstallXOptions}, then it is used. If not, then a new instance of {@link XPlugin} is\n * created and installed.\n *\n * @param pluginOptions - The {@link XPluginOptions} to passed as parameter to the install method\n * of the plugin.\n * @param bus - The {@link @empathyco/x-bus#XBus} to be used to create the XPlugin.\n *\n * @returns Plugin<XPluginOption> - The plugin instance.\n * @internal\n */\n protected installPlugin(\n pluginOptions: XPluginOptions,\n bus: XBus<XEventsTypes, WireMetadata>\n ): Plugin<XPluginOptions> {\n const plugin = this.options.plugin ?? new XPlugin(bus);\n this.app.use(plugin, pluginOptions);\n return plugin;\n }\n\n /**\n * Runs the installExtraPlugins callback defined in the {@link InstallXOptions}\n * to allow the user to install more plugins to the App.\n *\n * @param bus - The events bus used in the application.\n * @returns An empty promise.\n * @internal\n */\n protected installExtraPlugins(bus: XBus<XEventsTypes, WireMetadata>): Promise<void> {\n return Promise.resolve(\n this.options.installExtraPlugins?.({ app: this.app, snippet: this.snippetConfig!, bus })\n );\n }\n\n /**\n * In the case that the `rootComponent` parameter is present in the {@link InstallXOptions},\n * then a new Vue application is created using that component as root.\n *\n * @internal\n */\n protected createApp(): void {\n if (this.options.rootComponent !== undefined) {\n this.app = createApp(this.options.rootComponent);\n this.app.provide('snippetConfig', this.snippetConfig);\n this.options.onCreateApp?.(this.app);\n }\n }\n\n protected normaliseSnippetConfig(snippetConfig: SnippetConfig): NormalisedSnippetConfig;\n protected normaliseSnippetConfig(snippetConfig: Partial<SnippetConfig>): Partial<SnippetConfig>;\n /**\n * Transforms the snippet configuration.\n * - If `lang` is provided and `uiLang` is not, it sets `uiLang=lang`.\n *\n * @param snippetConfig - The snippet config to normalise.\n * @returns The normalised version of the given snippet config.\n * @internal\n */\n protected normaliseSnippetConfig(\n snippetConfig: SnippetConfig | Partial<SnippetConfig>\n ): NormalisedSnippetConfig | Partial<SnippetConfig> {\n if (snippetConfig.lang) {\n snippetConfig.uiLang ??= snippetConfig.lang;\n }\n return snippetConfig;\n }\n\n /**\n * It returns the HTML element to mount the Vue Application. If the `domElement` parameter in\n * the {@link InstallXOptions} is an Element or an element selector, then this will be used.\n * The `domElement` can also be a function with the {@link SnippetConfig} as parameter which\n * returns an Element or element selector to use.\n * If it is not present, a new <div> Element is created and appended to the body.\n *\n * @param domElement - {@link InstallXOptions.domElement} Element, ShadowRoot, string or function\n * used to mount the Vue Application.\n *\n * @returns The Element or ShadowRoot to use as mounting target for the Vue Application.\n * @internal\n */\n protected getMountingTarget(domElement?: InstallXOptions['domElement']): Element | ShadowRoot {\n if (isFunction(domElement)) {\n domElement = domElement(this.snippetConfig!);\n }\n if (typeof domElement === 'string') {\n const target = document.querySelector(domElement);\n if (!target) {\n throw Error(\n `XComponents app couldn't be mounted: Element \"${domElement}\" couldn't be found`\n );\n }\n return target;\n }\n return domElement ?? document.body.appendChild(document.createElement('div'));\n }\n\n /**\n * It updates all the provided properties from the current snippet config.\n *\n * @param newSnippetConfig - All the properties to be updated in the {@link SnippetConfig}.\n *\n * @internal\n */\n protected updateSnippetConfig(newSnippetConfig: Partial<SnippetConfig>): void {\n if (!this.snippetConfig) {\n return;\n }\n forEach(this.normaliseSnippetConfig(newSnippetConfig), (name, value) => {\n this.snippetConfig![name] = value;\n });\n }\n\n /**\n * Getter for the snippet config object.\n *\n * @returns The {@link NormalisedSnippetConfig | snippetConfig} object.\n *\n * @public\n */\n protected getSnippetConfig(): NormalisedSnippetConfig {\n return this.snippetConfig!;\n }\n}\n"],"names":[],"mappings":";;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEG;MACU,UAAU,CAAA;AAWrB;;;;;;;;;;;AAWG;AACH,IAAA,WAAA,CAAsC,OAAwB,EAAA;QAAxB,IAAO,CAAA,OAAA,GAAP,OAAO,CAAiB;QAC5D,IAAI,CAAC,SAAS,EAAE,CAAC;KAClB;AAED;;;;;;AAMG;IACO,SAAS,GAAA;AACjB,QAAA,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,GAAG,KAAK,KAAK,EAAE;YACjB,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,IAAI,QAAQ,EAAE,CA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AI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,OAAO;AACR,SAAA;AACD,QAAA,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAI;AACrE,YAAA,IAAI,CAAC,aAAc,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AACpC,SAAC,CAAC,CAAC;KACJ;AAED;;;;;;AAMG;IACO,gBAAgB,GAAA;QACxB,OAAO,IAAI,CAAC,aAAc,CAAC;KAC5B;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empathyco/x-components",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.21",
|
|
4
4
|
"description": "Empathy X Components",
|
|
5
5
|
"author": "Empathy Systems Corporation S.L.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -138,5 +138,5 @@
|
|
|
138
138
|
"access": "public",
|
|
139
139
|
"directory": "dist"
|
|
140
140
|
},
|
|
141
|
-
"gitHead": "
|
|
141
|
+
"gitHead": "b1075867e6d284f94ce76cec66b157f714797310"
|
|
142
142
|
}
|
|
@@ -35668,6 +35668,15 @@
|
|
|
35668
35668
|
"text": "Element",
|
|
35669
35669
|
"canonicalReference": "!Element:interface"
|
|
35670
35670
|
},
|
|
35671
|
+
{
|
|
35672
|
+
"kind": "Content",
|
|
35673
|
+
"text": " | "
|
|
35674
|
+
},
|
|
35675
|
+
{
|
|
35676
|
+
"kind": "Reference",
|
|
35677
|
+
"text": "ShadowRoot",
|
|
35678
|
+
"canonicalReference": "!ShadowRoot:interface"
|
|
35679
|
+
},
|
|
35671
35680
|
{
|
|
35672
35681
|
"kind": "Content",
|
|
35673
35682
|
"text": " | string | ((snippetConfig: "
|
|
@@ -35686,6 +35695,15 @@
|
|
|
35686
35695
|
"text": "Element",
|
|
35687
35696
|
"canonicalReference": "!Element:interface"
|
|
35688
35697
|
},
|
|
35698
|
+
{
|
|
35699
|
+
"kind": "Content",
|
|
35700
|
+
"text": " | "
|
|
35701
|
+
},
|
|
35702
|
+
{
|
|
35703
|
+
"kind": "Reference",
|
|
35704
|
+
"text": "ShadowRoot",
|
|
35705
|
+
"canonicalReference": "!ShadowRoot:interface"
|
|
35706
|
+
},
|
|
35689
35707
|
{
|
|
35690
35708
|
"kind": "Content",
|
|
35691
35709
|
"text": " | string)"
|
|
@@ -35701,7 +35719,7 @@
|
|
|
35701
35719
|
"name": "domElement",
|
|
35702
35720
|
"propertyTypeTokenRange": {
|
|
35703
35721
|
"startIndex": 1,
|
|
35704
|
-
"endIndex":
|
|
35722
|
+
"endIndex": 11
|
|
35705
35723
|
}
|
|
35706
35724
|
},
|
|
35707
35725
|
{
|
|
@@ -4017,7 +4017,7 @@ export type InputStatus = 'initial' | 'typing' | 'filled' | 'focused' | 'empty';
|
|
|
4017
4017
|
export interface InstallXOptions<API extends XAPI = XAPI> extends XPluginOptions {
|
|
4018
4018
|
api?: API | false;
|
|
4019
4019
|
bus?: XBus<XEventsTypes, WireMetadata>;
|
|
4020
|
-
domElement?: Element | string | ((snippetConfig: NormalisedSnippetConfig) => Element | string);
|
|
4020
|
+
domElement?: Element | ShadowRoot | string | ((snippetConfig: NormalisedSnippetConfig) => Element | ShadowRoot | string);
|
|
4021
4021
|
installExtraPlugins?(options: ExtraPluginsOptions): void;
|
|
4022
4022
|
onCreateApp?: (app: App_2) => void;
|
|
4023
4023
|
plugin?: Plugin_2<XPluginOptions>;
|
|
@@ -8690,7 +8690,7 @@ export class XInstaller {
|
|
|
8690
8690
|
// @internal
|
|
8691
8691
|
protected createBus(): XBus<XEventsTypes, WireMetadata>;
|
|
8692
8692
|
// @internal
|
|
8693
|
-
protected getMountingTarget(domElement?: InstallXOptions['domElement']): Element;
|
|
8693
|
+
protected getMountingTarget(domElement?: InstallXOptions['domElement']): Element | ShadowRoot;
|
|
8694
8694
|
// @internal
|
|
8695
8695
|
protected getPluginOptions(): XPluginOptions;
|
|
8696
8696
|
protected getSnippetConfig(): NormalisedSnippetConfig;
|
|
@@ -29,7 +29,7 @@ export interface InstallXOptions<API extends XAPI = XAPI> extends XPluginOptions
|
|
|
29
29
|
* An Element | string | function to indicate the HTML element that will contain the Vue
|
|
30
30
|
* application. If it isn't passed, the {@link XInstaller} will create the target element.
|
|
31
31
|
*/
|
|
32
|
-
domElement?: Element | string | ((snippetConfig: NormalisedSnippetConfig) => Element | string);
|
|
32
|
+
domElement?: Element | ShadowRoot | string | ((snippetConfig: NormalisedSnippetConfig) => Element | ShadowRoot | string);
|
|
33
33
|
/**
|
|
34
34
|
* The XPlugin which will be installed. If not passed, an instance of {@link XPlugin} will be
|
|
35
35
|
* installed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/x-installer/x-installer/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,GAAG,SAAS,IAAI,GAAG,IAAI,CAAE,SAAQ,cAAc;IAC9E;;;OAGG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;OAGG;IACH,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC;IAClB;;;OAGG;IACH,GAAG,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACvC;;;OAGG;IACH,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","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AAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,2CAA2C;IAC3C,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,qEAAqE;IACrE,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACtC,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;CAChC"}
|
|
@@ -190,13 +190,13 @@ export declare class XInstaller {
|
|
|
190
190
|
* returns an Element or element selector to use.
|
|
191
191
|
* If it is not present, a new <div> Element is created and appended to the body.
|
|
192
192
|
*
|
|
193
|
-
* @param domElement - {@link InstallXOptions.domElement
|
|
194
|
-
* to mount the Vue Application.
|
|
193
|
+
* @param domElement - {@link InstallXOptions.domElement} Element, ShadowRoot, string or function
|
|
194
|
+
* used to mount the Vue Application.
|
|
195
195
|
*
|
|
196
|
-
* @returns The Element to use as mounting target for the Vue Application.
|
|
196
|
+
* @returns The Element or ShadowRoot to use as mounting target for the Vue Application.
|
|
197
197
|
* @internal
|
|
198
198
|
*/
|
|
199
|
-
protected getMountingTarget(domElement?: InstallXOptions['domElement']): Element;
|
|
199
|
+
protected getMountingTarget(domElement?: InstallXOptions['domElement']): Element | ShadowRoot;
|
|
200
200
|
/**
|
|
201
201
|
* It updates all the provided properties from the current snippet config.
|
|
202
202
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"x-installer.d.ts","sourceRoot":"","sources":["../../../../src/x-installer/x-installer/x-installer.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,MAAM,EAAE,MAAM,KAAK,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEhF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