@coveo/atomic 3.31.0 → 3.31.1-pre.4862ba88ca
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 +1 -1
- package/dist/atomic/components/analytics-config.js.map +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-interface/atomic-commerce-interface.js +15 -26
- package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.js +16 -35
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.js +3 -0
- package/dist/atomic/components/components/common/interface/interface-controller.js +89 -0
- package/dist/atomic/components/global/environment.js +1 -1
- package/dist/atomic/{p-6cf521a3.entry.js → p-49323e5f.entry.js} +2 -2
- package/dist/atomic/{p-76489bf6.entry.js → p-72313200.entry.js} +2 -2
- package/dist/atomic/{p-be5e8359.js → p-c03cb4a0.js} +2 -2
- package/dist/atomic/{p-be5e8359.js.map → p-c03cb4a0.js.map} +1 -1
- package/dist/atomic/{p-e0169a14.entry.js → p-e22d721c.entry.js} +2 -2
- package/dist/cjs/{analytics-config-d10e762b.js → analytics-config-df48e87a.js} +2 -2
- package/dist/cjs/analytics-config-df48e87a.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-e2c4641d.js → analytics-config-daf979cf.js} +2 -2
- package/dist/esm/analytics-config-daf979cf.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 +3 -4
- package/dist/types/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.d.ts +5 -6
- package/dist/types/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.d.ts +3 -0
- package/dist/types/components/common/interface/i18n.d.ts +1 -1
- package/dist/types/components/common/interface/{interface-common.d.ts → interface-controller.d.ts} +14 -11
- package/docs/atomic-docs.json +31 -31
- package/package.json +5 -5
- package/dist/atomic/components/components/common/interface/interface-common.js +0 -95
- package/dist/cjs/analytics-config-d10e762b.js.map +0 -1
- package/dist/esm/analytics-config-e2c4641d.js.map +0 -1
- /package/dist/atomic/{p-6cf521a3.entry.js.map → p-49323e5f.entry.js.map} +0 -0
- /package/dist/atomic/{p-76489bf6.entry.js.map → p-72313200.entry.js.map} +0 -0
- /package/dist/atomic/{p-e0169a14.entry.js.map → p-e22d721c.entry.js.map} +0 -0
|
@@ -9,12 +9,14 @@ 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";
|
|
12
14
|
import { watch } from "../../../decorators/watch";
|
|
13
15
|
import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js";
|
|
14
16
|
import { markParentAsReady } from "../../../utils/init-queue";
|
|
15
17
|
import { SafeStorage, StorageItems, } from "../../../utils/local-storage-utils";
|
|
16
18
|
import { ChildrenUpdateCompleteMixin } from '../../../mixins/children-update-complete-mixin';
|
|
17
|
-
import {
|
|
19
|
+
import { InterfaceController, } from '../../common/interface/interface-controller';
|
|
18
20
|
import { bindingsContext } from '../../context/bindings-context';
|
|
19
21
|
import { createCommerceStore, } from '../atomic-commerce-interface/store';
|
|
20
22
|
import { errorSelector, firstSearchExecutedSelector, noProductsSelector, } from '../atomic-commerce-layout/commerce-layout';
|
|
@@ -34,6 +36,7 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
34
36
|
constructor() {
|
|
35
37
|
super();
|
|
36
38
|
this.initialized = false;
|
|
39
|
+
this.interfaceController = new InterfaceController(this, 'CoveoAtomic');
|
|
37
40
|
/**
|
|
38
41
|
* The type of the interface.
|
|
39
42
|
* - 'search': Indicates that the interface is used for Search.
|
|
@@ -67,13 +70,12 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
67
70
|
*/
|
|
68
71
|
this.iconAssetsPath = './assets';
|
|
69
72
|
this.handleInitialization = (event) => {
|
|
70
|
-
this.
|
|
73
|
+
this.interfaceController.onComponentInitializing(event);
|
|
71
74
|
};
|
|
72
75
|
this.bindings = {};
|
|
73
76
|
this.onHashChange = () => {
|
|
74
77
|
this.urlManager.synchronize(this.fragment);
|
|
75
78
|
};
|
|
76
|
-
this.commonInterfaceHelper = new CommonAtomicInterfaceHelper(this, 'CoveoAtomic');
|
|
77
79
|
this.store = createCommerceStore(this.type);
|
|
78
80
|
const { promise, resolve } = Promise.withResolvers();
|
|
79
81
|
this.i18Initialized = promise;
|
|
@@ -87,16 +89,16 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
87
89
|
this.addEventListener('atomic/scrollToTop', this.scrollToTop);
|
|
88
90
|
}
|
|
89
91
|
toggleAnalytics() {
|
|
90
|
-
this.
|
|
92
|
+
this.interfaceController.onAnalyticsChange();
|
|
91
93
|
}
|
|
92
94
|
updateLanguage() {
|
|
93
|
-
if (!this.
|
|
95
|
+
if (!this.interfaceController.engineIsCreated(this.engine) ||
|
|
94
96
|
!this.language ||
|
|
95
97
|
!this.context) {
|
|
96
98
|
return;
|
|
97
99
|
}
|
|
98
100
|
this.context.setLanguage(this.language);
|
|
99
|
-
return this.
|
|
101
|
+
return this.interfaceController.onLanguageChange();
|
|
100
102
|
}
|
|
101
103
|
updateIconAssetsPath() {
|
|
102
104
|
this.store.state.iconAssetsPath = this.iconAssetsPath;
|
|
@@ -114,10 +116,6 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
114
116
|
window.removeEventListener('hashchange', this.onHashChange);
|
|
115
117
|
this.removeEventListener('atomic/initializeComponent', this.handleInitialization);
|
|
116
118
|
this.removeEventListener('atomic/scrollToTop', this.scrollToTop);
|
|
117
|
-
const ariaLive = this.querySelector('atomic-aria-live');
|
|
118
|
-
if (ariaLive) {
|
|
119
|
-
ariaLive.remove();
|
|
120
|
-
}
|
|
121
119
|
}
|
|
122
120
|
updateMobileBreakpoint() {
|
|
123
121
|
const breakpoint = this.querySelector('atomic-commerce-layout')?.mobileBreakpoint;
|
|
@@ -153,7 +151,7 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
153
151
|
* Executes the first request after initializing connection to the headless commerce engine.
|
|
154
152
|
*/
|
|
155
153
|
async executeFirstRequest() {
|
|
156
|
-
if (!this.
|
|
154
|
+
if (!this.interfaceController.engineIsCreated(this.engine)) {
|
|
157
155
|
return;
|
|
158
156
|
}
|
|
159
157
|
if (!this.initialized) {
|
|
@@ -178,10 +176,9 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
178
176
|
}
|
|
179
177
|
async internalInitialization(initEngine) {
|
|
180
178
|
await Promise.all([
|
|
181
|
-
this.
|
|
179
|
+
this.interfaceController.onInitialization(initEngine),
|
|
182
180
|
this.i18Initialized,
|
|
183
181
|
]);
|
|
184
|
-
this.initAriaLive();
|
|
185
182
|
this.initContext();
|
|
186
183
|
this.updateLanguage();
|
|
187
184
|
this.bindings = this.getBindings();
|
|
@@ -222,13 +219,6 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
222
219
|
get fragment() {
|
|
223
220
|
return window.location.hash.slice(1);
|
|
224
221
|
}
|
|
225
|
-
initAriaLive() {
|
|
226
|
-
if (Array.from(this.children).some((element) => element.tagName === 'ATOMIC-ARIA-LIVE')) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
const ariaLive = document.createElement('atomic-aria-live');
|
|
230
|
-
this.prepend(ariaLive);
|
|
231
|
-
}
|
|
232
222
|
initUrlManager() {
|
|
233
223
|
if (!this.reflectStateInUrl) {
|
|
234
224
|
return;
|
|
@@ -292,9 +282,7 @@ __decorate([
|
|
|
292
282
|
__decorate([
|
|
293
283
|
property({
|
|
294
284
|
type: Boolean,
|
|
295
|
-
converter:
|
|
296
|
-
fromAttribute: (value) => value !== 'false',
|
|
297
|
-
},
|
|
285
|
+
converter: booleanConverter,
|
|
298
286
|
reflect: true,
|
|
299
287
|
})
|
|
300
288
|
], AtomicCommerceInterface.prototype, "analytics", void 0);
|
|
@@ -315,9 +303,7 @@ __decorate([
|
|
|
315
303
|
type: Boolean,
|
|
316
304
|
attribute: 'reflect-state-in-url',
|
|
317
305
|
reflect: true,
|
|
318
|
-
converter:
|
|
319
|
-
fromAttribute: (value) => value !== 'false',
|
|
320
|
-
},
|
|
306
|
+
converter: booleanConverter,
|
|
321
307
|
})
|
|
322
308
|
], AtomicCommerceInterface.prototype, "reflectStateInUrl", void 0);
|
|
323
309
|
__decorate([
|
|
@@ -342,6 +328,9 @@ __decorate([
|
|
|
342
328
|
state(),
|
|
343
329
|
provide({ context: bindingsContext })
|
|
344
330
|
], AtomicCommerceInterface.prototype, "bindings", void 0);
|
|
331
|
+
__decorate([
|
|
332
|
+
errorGuard()
|
|
333
|
+
], AtomicCommerceInterface.prototype, "render", null);
|
|
345
334
|
AtomicCommerceInterface = __decorate([
|
|
346
335
|
customElement('atomic-commerce-interface'),
|
|
347
336
|
withTailwindStyles
|
|
@@ -9,11 +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.js";
|
|
13
|
+
import { errorGuard } from "../../../decorators/error-guard.js";
|
|
12
14
|
import { watch } from "../../../decorators/watch";
|
|
13
15
|
import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js";
|
|
14
16
|
import { ChildrenUpdateCompleteMixin } from "../../../mixins/children-update-complete-mixin.js";
|
|
15
17
|
import { markParentAsReady } from "../../../utils/init-queue";
|
|
16
|
-
import {
|
|
18
|
+
import { InterfaceController, } from '../../common/interface/interface-controller.js';
|
|
17
19
|
import { bindingsContext } from '../../context/bindings-context.js';
|
|
18
20
|
import styles from './atomic-commerce-recommendation-interface.tw.css';
|
|
19
21
|
import { createCommerceRecommendationStore, } from './store.js';
|
|
@@ -27,6 +29,7 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
27
29
|
constructor() {
|
|
28
30
|
super();
|
|
29
31
|
this.bindings = {};
|
|
32
|
+
this.interfaceController = new InterfaceController(this, 'CoveoAtomic');
|
|
30
33
|
/**
|
|
31
34
|
* The CSS selector for the container the interface will scroll back to.
|
|
32
35
|
*/
|
|
@@ -50,9 +53,8 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
50
53
|
*/
|
|
51
54
|
this.analytics = true;
|
|
52
55
|
this.handleInitialization = (event) => {
|
|
53
|
-
this.
|
|
56
|
+
this.interfaceController.onComponentInitializing(event);
|
|
54
57
|
};
|
|
55
|
-
this.commonInterfaceHelper = new CommonAtomicInterfaceHelper(this, 'CoveoAtomic');
|
|
56
58
|
this.store = createCommerceRecommendationStore();
|
|
57
59
|
const { promise, resolve } = Promise.withResolvers();
|
|
58
60
|
this.i18Initialized = promise;
|
|
@@ -91,11 +93,11 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
91
93
|
* ```
|
|
92
94
|
*/
|
|
93
95
|
updateLocale(language, country, currency) {
|
|
94
|
-
if (!this.
|
|
96
|
+
if (!this.interfaceController.engineIsCreated(this.engine) ||
|
|
95
97
|
!this.context) {
|
|
96
98
|
return;
|
|
97
99
|
}
|
|
98
|
-
language && this.
|
|
100
|
+
language && this.interfaceController.onLanguageChange(language);
|
|
99
101
|
const { setContext } = loadContextActions(this.engine);
|
|
100
102
|
this.engine.dispatch(setContext({
|
|
101
103
|
...this.context.state,
|
|
@@ -105,29 +107,25 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
105
107
|
}));
|
|
106
108
|
}
|
|
107
109
|
toggleAnalytics() {
|
|
108
|
-
this.
|
|
110
|
+
this.interfaceController.onAnalyticsChange();
|
|
109
111
|
}
|
|
110
112
|
updateIconAssetsPath() {
|
|
111
113
|
this.store.state.iconAssetsPath = this.iconAssetsPath;
|
|
112
114
|
}
|
|
113
115
|
async updateLanguage() {
|
|
114
|
-
if (!this.
|
|
116
|
+
if (!this.interfaceController.engineIsCreated(this.engine) ||
|
|
115
117
|
!this.language ||
|
|
116
118
|
!this.context) {
|
|
117
119
|
return;
|
|
118
120
|
}
|
|
119
121
|
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.');
|
|
120
122
|
this.context.setLanguage(this.language);
|
|
121
|
-
return this.
|
|
123
|
+
return this.interfaceController.onLanguageChange();
|
|
122
124
|
}
|
|
123
125
|
disconnectedCallback() {
|
|
124
126
|
super.disconnectedCallback();
|
|
125
127
|
this.removeEventListener('atomic/initializeComponent', this.handleInitialization);
|
|
126
128
|
this.removeEventListener('atomic/scrollToTop', this.scrollToTop);
|
|
127
|
-
const ariaLive = this.querySelector('atomic-aria-live');
|
|
128
|
-
if (ariaLive) {
|
|
129
|
-
ariaLive.remove();
|
|
130
|
-
}
|
|
131
129
|
}
|
|
132
130
|
render() {
|
|
133
131
|
return html `<slot></slot>`;
|
|
@@ -142,23 +140,15 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
142
140
|
}
|
|
143
141
|
async internalInitialization(initEngine) {
|
|
144
142
|
await Promise.all([
|
|
145
|
-
this.
|
|
143
|
+
this.interfaceController.onInitialization(initEngine),
|
|
146
144
|
this.i18Initialized,
|
|
147
145
|
]);
|
|
148
|
-
this.initAriaLive();
|
|
149
146
|
this.initContext();
|
|
150
147
|
this.language && this.updateLanguage();
|
|
151
148
|
this.bindings = this.getBindings();
|
|
152
149
|
markParentAsReady(this);
|
|
153
150
|
this.initLanguage();
|
|
154
151
|
}
|
|
155
|
-
initAriaLive() {
|
|
156
|
-
if (Array.from(this.children).some((element) => element.tagName === 'ATOMIC-ARIA-LIVE')) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
const ariaLive = document.createElement('atomic-aria-live');
|
|
160
|
-
this.prepend(ariaLive);
|
|
161
|
-
}
|
|
162
152
|
initContext() {
|
|
163
153
|
this.context = buildContext(this.engine);
|
|
164
154
|
}
|
|
@@ -168,21 +158,11 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
168
158
|
i18n: this.i18n,
|
|
169
159
|
store: this.store,
|
|
170
160
|
interfaceElement: this,
|
|
171
|
-
addAdoptedStyleSheets: (stylesheet) => {
|
|
172
|
-
const parent = this.getRootNode();
|
|
173
|
-
const styleSheet = stylesheet;
|
|
174
|
-
const isDocumentOrShadowRoot = parent instanceof Document || parent instanceof ShadowRoot;
|
|
175
|
-
if (styleSheet &&
|
|
176
|
-
isDocumentOrShadowRoot &&
|
|
177
|
-
!parent.adoptedStyleSheets.includes(styleSheet)) {
|
|
178
|
-
parent.adoptedStyleSheets.push(styleSheet);
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
161
|
};
|
|
182
162
|
}
|
|
183
163
|
initLanguage() {
|
|
184
164
|
if (!this.language) {
|
|
185
|
-
this.
|
|
165
|
+
this.interfaceController.onLanguageChange(this.context.state.language);
|
|
186
166
|
}
|
|
187
167
|
}
|
|
188
168
|
};
|
|
@@ -215,9 +195,7 @@ __decorate([
|
|
|
215
195
|
__decorate([
|
|
216
196
|
property({
|
|
217
197
|
type: Boolean,
|
|
218
|
-
converter:
|
|
219
|
-
fromAttribute: (value) => value !== 'false',
|
|
220
|
-
},
|
|
198
|
+
converter: booleanConverter,
|
|
221
199
|
reflect: true,
|
|
222
200
|
})
|
|
223
201
|
], AtomicCommerceRecommendationInterface.prototype, "analytics", void 0);
|
|
@@ -230,6 +208,9 @@ __decorate([
|
|
|
230
208
|
__decorate([
|
|
231
209
|
watch('language')
|
|
232
210
|
], AtomicCommerceRecommendationInterface.prototype, "updateLanguage", null);
|
|
211
|
+
__decorate([
|
|
212
|
+
errorGuard()
|
|
213
|
+
], AtomicCommerceRecommendationInterface.prototype, "render", null);
|
|
233
214
|
AtomicCommerceRecommendationInterface = __decorate([
|
|
234
215
|
customElement('atomic-commerce-recommendation-interface'),
|
|
235
216
|
withTailwindStyles
|
|
@@ -27,6 +27,9 @@ 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';
|
|
30
33
|
/**
|
|
31
34
|
* 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.
|
|
32
35
|
*
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import Backend from 'i18next-http-backend';
|
|
2
|
+
import { setCoveoGlobal } from "../../../global/environment";
|
|
3
|
+
import { loadDayjsLocale } from "../../../utils/dayjs-locales";
|
|
4
|
+
import { i18nBackendOptions, i18nTranslationNamespace, init18n } from './i18n';
|
|
5
|
+
export class InterfaceController {
|
|
6
|
+
constructor(host, globalVariableName) {
|
|
7
|
+
this.hangingComponentsInitialization = [];
|
|
8
|
+
this.host = host;
|
|
9
|
+
this.host.addController(this);
|
|
10
|
+
setCoveoGlobal(globalVariableName);
|
|
11
|
+
}
|
|
12
|
+
hostConnected() {
|
|
13
|
+
this.i18nPromise = init18n(this.host);
|
|
14
|
+
this.initAriaLive();
|
|
15
|
+
}
|
|
16
|
+
hostDisconnected() {
|
|
17
|
+
this.removeAriaLive();
|
|
18
|
+
}
|
|
19
|
+
onComponentInitializing(event) {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
event.stopPropagation();
|
|
22
|
+
if (this.host.engine) {
|
|
23
|
+
event.detail(this.host.bindings);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.hangingComponentsInitialization.push(event);
|
|
27
|
+
}
|
|
28
|
+
async onInitialization(initEngine) {
|
|
29
|
+
if (this.host.engine) {
|
|
30
|
+
this.host.engine.logger.warn(`The ${this.interfaceTagname} component "initialize" has already been called.`, this.host);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.host.updateIconAssetsPath();
|
|
34
|
+
initEngine();
|
|
35
|
+
if (this.host.registerFieldsToInclude) {
|
|
36
|
+
this.host.registerFieldsToInclude();
|
|
37
|
+
}
|
|
38
|
+
loadDayjsLocale(this.host.language || 'en');
|
|
39
|
+
await this.i18nPromise;
|
|
40
|
+
this.initComponents();
|
|
41
|
+
}
|
|
42
|
+
onAnalyticsChange() {
|
|
43
|
+
const { engine, analytics } = this.host;
|
|
44
|
+
if (!this.engineIsCreated(engine)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!analytics) {
|
|
48
|
+
engine.disableAnalytics();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
engine.enableAnalytics();
|
|
52
|
+
}
|
|
53
|
+
onLanguageChange(newLanguage) {
|
|
54
|
+
const language = newLanguage ?? this.host.language;
|
|
55
|
+
const languageWithFallback = language ?? 'en';
|
|
56
|
+
const { i18n } = this.host;
|
|
57
|
+
loadDayjsLocale(languageWithFallback);
|
|
58
|
+
new Backend(i18n.services, i18nBackendOptions(this.host)).read(languageWithFallback.split('-')[0], i18nTranslationNamespace, (_, data) => {
|
|
59
|
+
i18n.addResourceBundle(languageWithFallback.split('-')[0], i18nTranslationNamespace, data, true, false);
|
|
60
|
+
i18n.changeLanguage(language);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
engineIsCreated(engine) {
|
|
64
|
+
if (!engine) {
|
|
65
|
+
console.error(`You have to call "initialize" on the ${this.interfaceTagname} component before modifying the props or calling other public methods.`, this.host);
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
get interfaceTagname() {
|
|
71
|
+
return this.host.tagName.toLowerCase();
|
|
72
|
+
}
|
|
73
|
+
initComponents() {
|
|
74
|
+
this.hangingComponentsInitialization.forEach((event) => event.detail(this.host.bindings));
|
|
75
|
+
}
|
|
76
|
+
initAriaLive() {
|
|
77
|
+
if (Array.from(this.host.children).some((element) => element.tagName === 'ATOMIC-ARIA-LIVE')) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const ariaLive = document.createElement('atomic-aria-live');
|
|
81
|
+
this.host.prepend(ariaLive);
|
|
82
|
+
}
|
|
83
|
+
removeAriaLive() {
|
|
84
|
+
const ariaLive = this.host.querySelector('atomic-aria-live');
|
|
85
|
+
if (ariaLive) {
|
|
86
|
+
ariaLive.remove();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|