@coveo/atomic 3.31.2-pre.da74c43571 → 3.31.2-pre.dbdab38fe6
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/dist/atomic/_atomic.esm.js +1 -1
- package/dist/atomic/components/analytics-config.js +299 -235
- package/dist/atomic/components/analytics-config.js.map +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-interface/atomic-commerce-interface.js +26 -15
- package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.js +35 -16
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.js +0 -3
- package/dist/atomic/components/components/common/interface/interface-common.js +95 -0
- package/dist/atomic/components/global/environment.js +1 -1
- package/dist/atomic/{p-ef45ff5c.entry.js → p-062ba992.entry.js} +2 -2
- package/dist/atomic/p-1226244c.js +2 -0
- package/dist/atomic/p-1226244c.js.map +1 -0
- package/dist/atomic/{p-7db6d666.entry.js → p-30a955cc.entry.js} +2 -2
- package/dist/atomic/{p-6c412aa0.entry.js → p-739a1a93.entry.js} +2 -2
- package/dist/cjs/{analytics-config-e18c57f7.js → analytics-config-ebc13649.js} +300 -236
- package/dist/cjs/analytics-config-ebc13649.js.map +1 -0
- package/dist/cjs/atomic-insight-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-recs-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-search-interface.cjs.entry.js +1 -1
- package/dist/cjs/version.cjs.js +2 -2
- package/dist/esm/{analytics-config-b8b6bdbb.js → analytics-config-3ce0ea6f.js} +300 -236
- package/dist/esm/analytics-config-3ce0ea6f.js.map +1 -0
- package/dist/esm/atomic-insight-interface.entry.js +1 -1
- package/dist/esm/atomic-recs-interface.entry.js +1 -1
- package/dist/esm/atomic-search-interface.entry.js +1 -1
- package/dist/esm/version.js +2 -2
- package/dist/types/components/commerce/atomic-commerce-interface/atomic-commerce-interface.d.ts +4 -3
- package/dist/types/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.d.ts +6 -5
- package/dist/types/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.d.ts +0 -3
- package/dist/types/components/common/interface/i18n.d.ts +1 -1
- package/dist/types/components/common/interface/{interface-controller.d.ts → interface-common.d.ts} +11 -14
- package/docs/atomic-docs.json +38 -33
- package/package.json +5 -5
- package/dist/atomic/components/components/common/interface/interface-controller.js +0 -89
- package/dist/atomic/p-d99e359b.js +0 -2
- package/dist/atomic/p-d99e359b.js.map +0 -1
- package/dist/cjs/analytics-config-e18c57f7.js.map +0 -1
- package/dist/esm/analytics-config-b8b6bdbb.js.map +0 -1
- /package/dist/atomic/{p-ef45ff5c.entry.js.map → p-062ba992.entry.js.map} +0 -0
- /package/dist/atomic/{p-7db6d666.entry.js.map → p-30a955cc.entry.js.map} +0 -0
- /package/dist/atomic/{p-6c412aa0.entry.js.map → p-739a1a93.entry.js.map} +0 -0
|
@@ -9,15 +9,13 @@ import { provide } from '@lit/context';
|
|
|
9
9
|
import i18next from 'i18next';
|
|
10
10
|
import { html, LitElement, unsafeCSS } from 'lit';
|
|
11
11
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
12
|
-
import { booleanConverter } from "../../../converters/boolean-converter";
|
|
13
|
-
import { errorGuard } from "../../../decorators/error-guard";
|
|
14
12
|
import { watch } from "../../../decorators/watch";
|
|
15
13
|
import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js";
|
|
16
14
|
import { markParentAsReady } from "../../../utils/init-queue";
|
|
17
15
|
import { SafeStorage, StorageItems, } from "../../../utils/local-storage-utils";
|
|
18
16
|
import { ChildrenUpdateCompleteMixin } from '../../../mixins/children-update-complete-mixin';
|
|
19
17
|
import { augmentAnalyticsConfigWithAtomicVersion } from '../../common/interface/analytics-config';
|
|
20
|
-
import {
|
|
18
|
+
import { CommonAtomicInterfaceHelper, } from '../../common/interface/interface-common';
|
|
21
19
|
import { bindingsContext } from '../../context/bindings-context';
|
|
22
20
|
import { createCommerceStore, } from '../atomic-commerce-interface/store';
|
|
23
21
|
import { errorSelector, firstSearchExecutedSelector, noProductsSelector, } from '../atomic-commerce-layout/commerce-layout';
|
|
@@ -37,7 +35,6 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
37
35
|
constructor() {
|
|
38
36
|
super();
|
|
39
37
|
this.initialized = false;
|
|
40
|
-
this.interfaceController = new InterfaceController(this, 'CoveoAtomic');
|
|
41
38
|
/**
|
|
42
39
|
* The type of the interface.
|
|
43
40
|
* - 'search': Indicates that the interface is used for Search.
|
|
@@ -71,12 +68,13 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
71
68
|
*/
|
|
72
69
|
this.iconAssetsPath = './assets';
|
|
73
70
|
this.handleInitialization = (event) => {
|
|
74
|
-
this.
|
|
71
|
+
this.commonInterfaceHelper.onComponentInitializing(event);
|
|
75
72
|
};
|
|
76
73
|
this.bindings = {};
|
|
77
74
|
this.onHashChange = () => {
|
|
78
75
|
this.urlManager.synchronize(this.fragment);
|
|
79
76
|
};
|
|
77
|
+
this.commonInterfaceHelper = new CommonAtomicInterfaceHelper(this, 'CoveoAtomic');
|
|
80
78
|
this.store = createCommerceStore(this.type);
|
|
81
79
|
const { promise, resolve } = Promise.withResolvers();
|
|
82
80
|
this.i18Initialized = promise;
|
|
@@ -90,16 +88,16 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
90
88
|
this.addEventListener('atomic/scrollToTop', this.scrollToTop);
|
|
91
89
|
}
|
|
92
90
|
toggleAnalytics() {
|
|
93
|
-
this.
|
|
91
|
+
this.commonInterfaceHelper.onAnalyticsChange();
|
|
94
92
|
}
|
|
95
93
|
updateLanguage() {
|
|
96
|
-
if (!this.
|
|
94
|
+
if (!this.commonInterfaceHelper.engineIsCreated(this.engine) ||
|
|
97
95
|
!this.language ||
|
|
98
96
|
!this.context) {
|
|
99
97
|
return;
|
|
100
98
|
}
|
|
101
99
|
this.context.setLanguage(this.language);
|
|
102
|
-
return this.
|
|
100
|
+
return this.commonInterfaceHelper.onLanguageChange();
|
|
103
101
|
}
|
|
104
102
|
updateIconAssetsPath() {
|
|
105
103
|
this.store.state.iconAssetsPath = this.iconAssetsPath;
|
|
@@ -117,6 +115,10 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
117
115
|
window.removeEventListener('hashchange', this.onHashChange);
|
|
118
116
|
this.removeEventListener('atomic/initializeComponent', this.handleInitialization);
|
|
119
117
|
this.removeEventListener('atomic/scrollToTop', this.scrollToTop);
|
|
118
|
+
const ariaLive = this.querySelector('atomic-aria-live');
|
|
119
|
+
if (ariaLive) {
|
|
120
|
+
ariaLive.remove();
|
|
121
|
+
}
|
|
120
122
|
}
|
|
121
123
|
updateMobileBreakpoint() {
|
|
122
124
|
const breakpoint = this.querySelector('atomic-commerce-layout')?.mobileBreakpoint;
|
|
@@ -156,7 +158,7 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
156
158
|
* Executes the first request after initializing connection to the headless commerce engine.
|
|
157
159
|
*/
|
|
158
160
|
async executeFirstRequest() {
|
|
159
|
-
if (!this.
|
|
161
|
+
if (!this.commonInterfaceHelper.engineIsCreated(this.engine)) {
|
|
160
162
|
return;
|
|
161
163
|
}
|
|
162
164
|
if (!this.initialized) {
|
|
@@ -181,9 +183,10 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
181
183
|
}
|
|
182
184
|
async internalInitialization(initEngine) {
|
|
183
185
|
await Promise.all([
|
|
184
|
-
this.
|
|
186
|
+
this.commonInterfaceHelper.onInitialization(initEngine),
|
|
185
187
|
this.i18Initialized,
|
|
186
188
|
]);
|
|
189
|
+
this.initAriaLive();
|
|
187
190
|
this.initContext();
|
|
188
191
|
this.updateLanguage();
|
|
189
192
|
this.bindings = this.getBindings();
|
|
@@ -224,6 +227,13 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
224
227
|
get fragment() {
|
|
225
228
|
return window.location.hash.slice(1);
|
|
226
229
|
}
|
|
230
|
+
initAriaLive() {
|
|
231
|
+
if (Array.from(this.children).some((element) => element.tagName === 'ATOMIC-ARIA-LIVE')) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const ariaLive = document.createElement('atomic-aria-live');
|
|
235
|
+
this.prepend(ariaLive);
|
|
236
|
+
}
|
|
227
237
|
initUrlManager() {
|
|
228
238
|
if (!this.reflectStateInUrl) {
|
|
229
239
|
return;
|
|
@@ -287,7 +297,9 @@ __decorate([
|
|
|
287
297
|
__decorate([
|
|
288
298
|
property({
|
|
289
299
|
type: Boolean,
|
|
290
|
-
converter:
|
|
300
|
+
converter: {
|
|
301
|
+
fromAttribute: (value) => value !== 'false',
|
|
302
|
+
},
|
|
291
303
|
reflect: true,
|
|
292
304
|
})
|
|
293
305
|
], AtomicCommerceInterface.prototype, "analytics", void 0);
|
|
@@ -308,7 +320,9 @@ __decorate([
|
|
|
308
320
|
type: Boolean,
|
|
309
321
|
attribute: 'reflect-state-in-url',
|
|
310
322
|
reflect: true,
|
|
311
|
-
converter:
|
|
323
|
+
converter: {
|
|
324
|
+
fromAttribute: (value) => value !== 'false',
|
|
325
|
+
},
|
|
312
326
|
})
|
|
313
327
|
], AtomicCommerceInterface.prototype, "reflectStateInUrl", void 0);
|
|
314
328
|
__decorate([
|
|
@@ -333,9 +347,6 @@ __decorate([
|
|
|
333
347
|
state(),
|
|
334
348
|
provide({ context: bindingsContext })
|
|
335
349
|
], AtomicCommerceInterface.prototype, "bindings", void 0);
|
|
336
|
-
__decorate([
|
|
337
|
-
errorGuard()
|
|
338
|
-
], AtomicCommerceInterface.prototype, "render", null);
|
|
339
350
|
AtomicCommerceInterface = __decorate([
|
|
340
351
|
customElement('atomic-commerce-interface'),
|
|
341
352
|
withTailwindStyles
|
|
@@ -9,14 +9,12 @@ import { provide } from '@lit/context';
|
|
|
9
9
|
import i18next from 'i18next';
|
|
10
10
|
import { html, LitElement, unsafeCSS } from 'lit';
|
|
11
11
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
12
|
-
import { booleanConverter } from "../../../converters/boolean-converter.js";
|
|
13
|
-
import { errorGuard } from "../../../decorators/error-guard.js";
|
|
14
12
|
import { watch } from "../../../decorators/watch";
|
|
15
13
|
import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js";
|
|
16
14
|
import { ChildrenUpdateCompleteMixin } from "../../../mixins/children-update-complete-mixin.js";
|
|
17
15
|
import { markParentAsReady } from "../../../utils/init-queue";
|
|
18
16
|
import { augmentAnalyticsConfigWithAtomicVersion } from '../../common/interface/analytics-config.js';
|
|
19
|
-
import {
|
|
17
|
+
import { CommonAtomicInterfaceHelper, } from '../../common/interface/interface-common.js';
|
|
20
18
|
import { bindingsContext } from '../../context/bindings-context.js';
|
|
21
19
|
import styles from './atomic-commerce-recommendation-interface.tw.css';
|
|
22
20
|
import { createCommerceRecommendationStore, } from './store.js';
|
|
@@ -30,7 +28,6 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
30
28
|
constructor() {
|
|
31
29
|
super();
|
|
32
30
|
this.bindings = {};
|
|
33
|
-
this.interfaceController = new InterfaceController(this, 'CoveoAtomic');
|
|
34
31
|
/**
|
|
35
32
|
* The CSS selector for the container the interface will scroll back to.
|
|
36
33
|
*/
|
|
@@ -54,8 +51,9 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
54
51
|
*/
|
|
55
52
|
this.analytics = true;
|
|
56
53
|
this.handleInitialization = (event) => {
|
|
57
|
-
this.
|
|
54
|
+
this.commonInterfaceHelper.onComponentInitializing(event);
|
|
58
55
|
};
|
|
56
|
+
this.commonInterfaceHelper = new CommonAtomicInterfaceHelper(this, 'CoveoAtomic');
|
|
59
57
|
this.store = createCommerceRecommendationStore();
|
|
60
58
|
const { promise, resolve } = Promise.withResolvers();
|
|
61
59
|
this.i18Initialized = promise;
|
|
@@ -98,11 +96,11 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
98
96
|
* ```
|
|
99
97
|
*/
|
|
100
98
|
updateLocale(language, country, currency) {
|
|
101
|
-
if (!this.
|
|
99
|
+
if (!this.commonInterfaceHelper.engineIsCreated(this.engine) ||
|
|
102
100
|
!this.context) {
|
|
103
101
|
return;
|
|
104
102
|
}
|
|
105
|
-
language && this.
|
|
103
|
+
language && this.commonInterfaceHelper.onLanguageChange(language);
|
|
106
104
|
const { setContext } = loadContextActions(this.engine);
|
|
107
105
|
this.engine.dispatch(setContext({
|
|
108
106
|
...this.context.state,
|
|
@@ -112,25 +110,29 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
112
110
|
}));
|
|
113
111
|
}
|
|
114
112
|
toggleAnalytics() {
|
|
115
|
-
this.
|
|
113
|
+
this.commonInterfaceHelper.onAnalyticsChange();
|
|
116
114
|
}
|
|
117
115
|
updateIconAssetsPath() {
|
|
118
116
|
this.store.state.iconAssetsPath = this.iconAssetsPath;
|
|
119
117
|
}
|
|
120
118
|
async updateLanguage() {
|
|
121
|
-
if (!this.
|
|
119
|
+
if (!this.commonInterfaceHelper.engineIsCreated(this.engine) ||
|
|
122
120
|
!this.language ||
|
|
123
121
|
!this.context) {
|
|
124
122
|
return;
|
|
125
123
|
}
|
|
126
124
|
this.engine.logger.warn('The `language` property will be removed in the next major version of Atomic (v4). Rather than using this property, set the initial language through the engine configuration when calling `initializeWithEngine`, and update the language as needed using the `updateLocale` method.');
|
|
127
125
|
this.context.setLanguage(this.language);
|
|
128
|
-
return this.
|
|
126
|
+
return this.commonInterfaceHelper.onLanguageChange();
|
|
129
127
|
}
|
|
130
128
|
disconnectedCallback() {
|
|
131
129
|
super.disconnectedCallback();
|
|
132
130
|
this.removeEventListener('atomic/initializeComponent', this.handleInitialization);
|
|
133
131
|
this.removeEventListener('atomic/scrollToTop', this.scrollToTop);
|
|
132
|
+
const ariaLive = this.querySelector('atomic-aria-live');
|
|
133
|
+
if (ariaLive) {
|
|
134
|
+
ariaLive.remove();
|
|
135
|
+
}
|
|
134
136
|
}
|
|
135
137
|
render() {
|
|
136
138
|
return html `<slot></slot>`;
|
|
@@ -145,15 +147,23 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
145
147
|
}
|
|
146
148
|
async internalInitialization(initEngine) {
|
|
147
149
|
await Promise.all([
|
|
148
|
-
this.
|
|
150
|
+
this.commonInterfaceHelper.onInitialization(initEngine),
|
|
149
151
|
this.i18Initialized,
|
|
150
152
|
]);
|
|
153
|
+
this.initAriaLive();
|
|
151
154
|
this.initContext();
|
|
152
155
|
this.language && this.updateLanguage();
|
|
153
156
|
this.bindings = this.getBindings();
|
|
154
157
|
markParentAsReady(this);
|
|
155
158
|
this.initLanguage();
|
|
156
159
|
}
|
|
160
|
+
initAriaLive() {
|
|
161
|
+
if (Array.from(this.children).some((element) => element.tagName === 'ATOMIC-ARIA-LIVE')) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const ariaLive = document.createElement('atomic-aria-live');
|
|
165
|
+
this.prepend(ariaLive);
|
|
166
|
+
}
|
|
157
167
|
initContext() {
|
|
158
168
|
this.context = buildContext(this.engine);
|
|
159
169
|
}
|
|
@@ -163,11 +173,21 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
163
173
|
i18n: this.i18n,
|
|
164
174
|
store: this.store,
|
|
165
175
|
interfaceElement: this,
|
|
176
|
+
addAdoptedStyleSheets: (stylesheet) => {
|
|
177
|
+
const parent = this.getRootNode();
|
|
178
|
+
const styleSheet = stylesheet;
|
|
179
|
+
const isDocumentOrShadowRoot = parent instanceof Document || parent instanceof ShadowRoot;
|
|
180
|
+
if (styleSheet &&
|
|
181
|
+
isDocumentOrShadowRoot &&
|
|
182
|
+
!parent.adoptedStyleSheets.includes(styleSheet)) {
|
|
183
|
+
parent.adoptedStyleSheets.push(styleSheet);
|
|
184
|
+
}
|
|
185
|
+
},
|
|
166
186
|
};
|
|
167
187
|
}
|
|
168
188
|
initLanguage() {
|
|
169
189
|
if (!this.language) {
|
|
170
|
-
this.
|
|
190
|
+
this.commonInterfaceHelper.onLanguageChange(this.context.state.language);
|
|
171
191
|
}
|
|
172
192
|
}
|
|
173
193
|
};
|
|
@@ -200,7 +220,9 @@ __decorate([
|
|
|
200
220
|
__decorate([
|
|
201
221
|
property({
|
|
202
222
|
type: Boolean,
|
|
203
|
-
converter:
|
|
223
|
+
converter: {
|
|
224
|
+
fromAttribute: (value) => value !== 'false',
|
|
225
|
+
},
|
|
204
226
|
reflect: true,
|
|
205
227
|
})
|
|
206
228
|
], AtomicCommerceRecommendationInterface.prototype, "analytics", void 0);
|
|
@@ -213,9 +235,6 @@ __decorate([
|
|
|
213
235
|
__decorate([
|
|
214
236
|
watch('language')
|
|
215
237
|
], AtomicCommerceRecommendationInterface.prototype, "updateLanguage", null);
|
|
216
|
-
__decorate([
|
|
217
|
-
errorGuard()
|
|
218
|
-
], AtomicCommerceRecommendationInterface.prototype, "render", null);
|
|
219
238
|
AtomicCommerceRecommendationInterface = __decorate([
|
|
220
239
|
customElement('atomic-commerce-recommendation-interface'),
|
|
221
240
|
withTailwindStyles
|
|
@@ -27,9 +27,6 @@ import { renderSubmitButton } from '../../common/search-box/submit-button';
|
|
|
27
27
|
import { SuggestionManager } from '../../common/suggestions/suggestion-manager';
|
|
28
28
|
import { elementHasQuery, } from '../../common/suggestions/suggestions-common';
|
|
29
29
|
import styles from './atomic-commerce-search-box.tw.css';
|
|
30
|
-
import '../atomic-commerce-search-box-instant-products/atomic-commerce-search-box-instant-products';
|
|
31
|
-
import '../atomic-commerce-search-box-query-suggestions/atomic-commerce-search-box-query-suggestions';
|
|
32
|
-
import '../atomic-commerce-search-box-recent-queries/atomic-commerce-search-box-recent-queries';
|
|
33
30
|
/**
|
|
34
31
|
* The `atomic-commerce-search-box` component enables users to perform product searches with built-in query suggestions and optional redirection to a search results page.
|
|
35
32
|
*
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import "../atomic-component-error/atomic-component-error.js";
|
|
2
|
+
import Backend from 'i18next-http-backend';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import { i18nBackendOptions, i18nTranslationNamespace, init18n, } from "./i18n.js";
|
|
5
|
+
import { setCoveoGlobal } from "../../../global/environment.js";
|
|
6
|
+
import { loadDayjsLocale } from "../../../utils/dayjs-locales.js";
|
|
7
|
+
export const mismatchedInterfaceAndEnginePropError = (interfaceKind, configurationName) => `A ${configurationName} is configured on the ${interfaceKind} interface element, but the ${interfaceKind} interface was initialized with an engine. You should only configure the ${configurationName} in the target engine.`;
|
|
8
|
+
export class CommonAtomicInterfaceHelper {
|
|
9
|
+
constructor(atomicInterface, globalVariableName) {
|
|
10
|
+
this.atomicInterface = atomicInterface;
|
|
11
|
+
this.hangingComponentsInitialization = [];
|
|
12
|
+
setCoveoGlobal(globalVariableName);
|
|
13
|
+
if ('connectedCallback' in atomicInterface && 'render' in atomicInterface) {
|
|
14
|
+
const { connectedCallback: originalConnectedCallback, render: originalRender, } = atomicInterface;
|
|
15
|
+
atomicInterface.connectedCallback = () => {
|
|
16
|
+
this.i18nPromise = init18n(atomicInterface);
|
|
17
|
+
if (typeof originalConnectedCallback === 'function') {
|
|
18
|
+
return originalConnectedCallback.call(atomicInterface);
|
|
19
|
+
}
|
|
20
|
+
return;
|
|
21
|
+
};
|
|
22
|
+
atomicInterface.render = () => {
|
|
23
|
+
if (atomicInterface.error) {
|
|
24
|
+
return html `<atomic-component-error
|
|
25
|
+
.element=${atomicInterface}
|
|
26
|
+
.error=${atomicInterface.error}
|
|
27
|
+
></atomic-component-error>`;
|
|
28
|
+
}
|
|
29
|
+
return typeof originalRender === 'function'
|
|
30
|
+
? originalRender.call(atomicInterface)
|
|
31
|
+
: null;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.i18nPromise = init18n(atomicInterface);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
onComponentInitializing(event) {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
event.stopPropagation();
|
|
41
|
+
if (this.atomicInterface.engine) {
|
|
42
|
+
event.detail(this.atomicInterface.bindings);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.hangingComponentsInitialization.push(event);
|
|
46
|
+
}
|
|
47
|
+
async onInitialization(initEngine) {
|
|
48
|
+
if (this.atomicInterface.engine) {
|
|
49
|
+
this.atomicInterface.engine.logger.warn(`The ${this.interfaceTagname} component "initialize" has already been called.`, this.atomicInterface);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.atomicInterface.updateIconAssetsPath();
|
|
53
|
+
initEngine();
|
|
54
|
+
if (this.atomicInterface.registerFieldsToInclude) {
|
|
55
|
+
this.atomicInterface.registerFieldsToInclude();
|
|
56
|
+
}
|
|
57
|
+
loadDayjsLocale(this.atomicInterface.language || 'en');
|
|
58
|
+
await this.i18nPromise;
|
|
59
|
+
this.initComponents();
|
|
60
|
+
}
|
|
61
|
+
onAnalyticsChange() {
|
|
62
|
+
const { engine, analytics } = this.atomicInterface;
|
|
63
|
+
if (!this.engineIsCreated(engine)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!analytics) {
|
|
67
|
+
engine.disableAnalytics();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
engine.enableAnalytics();
|
|
71
|
+
}
|
|
72
|
+
onLanguageChange(newLanguage) {
|
|
73
|
+
const language = newLanguage ?? this.atomicInterface.language;
|
|
74
|
+
const languageWithFallback = language ?? 'en';
|
|
75
|
+
const { i18n } = this.atomicInterface;
|
|
76
|
+
loadDayjsLocale(languageWithFallback);
|
|
77
|
+
new Backend(i18n.services, i18nBackendOptions(this.atomicInterface)).read(languageWithFallback.split('-')[0], i18nTranslationNamespace, (_, data) => {
|
|
78
|
+
i18n.addResourceBundle(languageWithFallback.split('-')[0], i18nTranslationNamespace, data, true, false);
|
|
79
|
+
i18n.changeLanguage(language);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
engineIsCreated(engine) {
|
|
83
|
+
if (!engine) {
|
|
84
|
+
console.error(`You have to call "initialize" on the ${this.interfaceTagname} component before modifying the props or calling other public methods.`, this.atomicInterface);
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
get interfaceTagname() {
|
|
90
|
+
return this.atomicInterface.tagName.toLowerCase();
|
|
91
|
+
}
|
|
92
|
+
initComponents() {
|
|
93
|
+
this.hangingComponentsInitialization.forEach((event) => event.detail(this.atomicInterface.bindings));
|
|
94
|
+
}
|
|
95
|
+
}
|