@coveo/atomic-react 3.11.45 → 3.11.47
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/cjs/atomic-react.cjs +289 -180
- package/dist/cjs/atomic-react.cjs.map +1 -1
- package/dist/cjs/commerce/atomic-react.cjs +324 -161
- package/dist/cjs/commerce/atomic-react.cjs.map +1 -1
- package/dist/cjs/recommendation/atomic-react.cjs +289 -180
- package/dist/cjs/recommendation/atomic-react.cjs.map +1 -1
- package/dist/lang/cs.json +1 -1
- package/dist/lang/da.json +1 -1
- package/dist/lang/de.json +1 -1
- package/dist/lang/el.json +1 -1
- package/dist/lang/es.json +1 -1
- package/dist/lang/fi.json +1 -1
- package/dist/lang/hu.json +1 -1
- package/dist/lang/id.json +1 -1
- package/dist/lang/it.json +1 -1
- package/dist/lang/ja.json +1 -1
- package/dist/lang/ko.json +1 -1
- package/dist/lang/nl.json +1 -1
- package/dist/lang/no.json +1 -1
- package/dist/lang/pl.json +1 -1
- package/dist/lang/pt-BR.json +1 -1
- package/dist/lang/pt.json +1 -1
- package/dist/lang/ru.json +1 -1
- package/dist/lang/sv.json +1 -1
- package/dist/lang/th.json +1 -1
- package/dist/lang/tr.json +1 -1
- package/dist/lang/zh-CN.json +1 -1
- package/dist/lang/zh-TW.json +1 -1
- package/dist/lang/zh.json +1 -1
- package/package.json +3 -3
|
@@ -4987,6 +4987,46 @@ const booleanConverter = {
|
|
|
4987
4987
|
}
|
|
4988
4988
|
};
|
|
4989
4989
|
|
|
4990
|
+
const renderFacetValueLabelHighlight = ({ props })=>{
|
|
4991
|
+
const classNames = tw({
|
|
4992
|
+
'value-label peer-hover:text-error truncate': true,
|
|
4993
|
+
'font-bold': props.isSelected || !!props.isExcluded
|
|
4994
|
+
});
|
|
4995
|
+
return lit.html`<span
|
|
4996
|
+
title=${props.displayValue}
|
|
4997
|
+
part="value-label"
|
|
4998
|
+
class=${multiClassMap(classNames)}
|
|
4999
|
+
.innerHTML=${highlightSearchResult(props.displayValue, props.searchQuery)}
|
|
5000
|
+
></span>`;
|
|
5001
|
+
};
|
|
5002
|
+
|
|
5003
|
+
const renderCategoryFacetActiveValue = ({ props: { displayValue, numberOfResults, i18n, searchQuery, isLeafValue, setRef } })=>(children)=>{
|
|
5004
|
+
const count = numberOfResults.toLocaleString(i18n.language);
|
|
5005
|
+
return lit.html`${keyed_js.keyed(displayValue, lit.html`<li class="contents">
|
|
5006
|
+
<span
|
|
5007
|
+
part="active-parent ${isLeafValue ? 'leaf-value' : 'node-value'}"
|
|
5008
|
+
class="text-primary flex w-full items-center truncate px-2 py-2.5 text-left"
|
|
5009
|
+
aria-current="true"
|
|
5010
|
+
tabindex="-1"
|
|
5011
|
+
${ref_js.ref(setRef)}
|
|
5012
|
+
>
|
|
5013
|
+
${renderFacetValueLabelHighlight({
|
|
5014
|
+
props: {
|
|
5015
|
+
displayValue,
|
|
5016
|
+
searchQuery,
|
|
5017
|
+
isSelected: true
|
|
5018
|
+
}
|
|
5019
|
+
})}
|
|
5020
|
+
<span part="value-count" class="value-count">
|
|
5021
|
+
${i18n.t('between-parentheses', {
|
|
5022
|
+
text: count
|
|
5023
|
+
})}
|
|
5024
|
+
</span>
|
|
5025
|
+
</span>
|
|
5026
|
+
${children}
|
|
5027
|
+
</li>`)}`;
|
|
5028
|
+
};
|
|
5029
|
+
|
|
4990
5030
|
var arrow_left_rounded = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"m11.5 4.8-4.3 4.5c-.3.4-.3.9 0 1.3l4.3 4.6c.3.4.9.4 1.2 0s.3-.9 0-1.3l-3.7-4 3.7-3.9c.3-.4.3-.9 0-1.3-.3-.3-.9-.3-1.2.1z\"/></svg>";
|
|
4991
5031
|
|
|
4992
5032
|
const getAllCategoriesLocalizedLabel = ({ facetId, field, i18n })=>{
|
|
@@ -5047,91 +5087,6 @@ const renderCategoryFacetParentButton = ({ props })=>{
|
|
|
5047
5087
|
`);
|
|
5048
5088
|
};
|
|
5049
5089
|
|
|
5050
|
-
const renderFacetValueLabelHighlight = ({ props })=>{
|
|
5051
|
-
const classNames = tw({
|
|
5052
|
-
'value-label peer-hover:text-error truncate': true,
|
|
5053
|
-
'font-bold': props.isSelected || !!props.isExcluded
|
|
5054
|
-
});
|
|
5055
|
-
return lit.html`<span
|
|
5056
|
-
title=${props.displayValue}
|
|
5057
|
-
part="value-label"
|
|
5058
|
-
class=${multiClassMap(classNames)}
|
|
5059
|
-
.innerHTML=${highlightSearchResult(props.displayValue, props.searchQuery)}
|
|
5060
|
-
></span>`;
|
|
5061
|
-
};
|
|
5062
|
-
|
|
5063
|
-
const renderFacetValueLink = ({ props })=>(children)=>{
|
|
5064
|
-
const count = props.numberOfResults.toLocaleString(props.i18n.language);
|
|
5065
|
-
const ariaLabel = props.i18n.t('facet-value', {
|
|
5066
|
-
value: props.displayValue,
|
|
5067
|
-
count: props.numberOfResults,
|
|
5068
|
-
formattedCount: count,
|
|
5069
|
-
interpolation: {
|
|
5070
|
-
escapeValue: false
|
|
5071
|
-
}
|
|
5072
|
-
});
|
|
5073
|
-
let part = props.part ?? `value-link${props.isSelected ? ' value-link-selected' : ''}`;
|
|
5074
|
-
if (props.additionalPart) part += ` ${props.additionalPart}`;
|
|
5075
|
-
return lit.html`
|
|
5076
|
-
${keyed_js.keyed(props.displayValue, lit.html`<li class=${ifDefined_js.ifDefined(props.class)}>
|
|
5077
|
-
${renderButton({
|
|
5078
|
-
props: {
|
|
5079
|
-
style: 'text-neutral',
|
|
5080
|
-
part,
|
|
5081
|
-
onClick: ()=>props.onClick(),
|
|
5082
|
-
class: 'group flex w-full items-center truncate px-2 py-2.5 text-left focus-visible:outline-none',
|
|
5083
|
-
ariaPressed: props.isSelected ? 'true' : 'false',
|
|
5084
|
-
ariaLabel,
|
|
5085
|
-
ref: props.buttonRef
|
|
5086
|
-
}
|
|
5087
|
-
})(lit.html`${children}<span part="value-count" class="value-count">
|
|
5088
|
-
${props.i18n.t('between-parentheses', {
|
|
5089
|
-
text: count
|
|
5090
|
-
})}
|
|
5091
|
-
</span>`)}
|
|
5092
|
-
${props.subList}
|
|
5093
|
-
</li>`)}
|
|
5094
|
-
`;
|
|
5095
|
-
};
|
|
5096
|
-
|
|
5097
|
-
const renderCategoryFacetValueLink = ({ props: { displayValue, numberOfResults, i18n, onClick, isParent, isSelected, searchQuery, isLeafValue, setRef } })=>(children)=>{
|
|
5098
|
-
const partNames = [];
|
|
5099
|
-
if (isParent) partNames.push('active-parent');
|
|
5100
|
-
else partNames.push(`value-link${isSelected ? ' value-link-selected' : ''}`);
|
|
5101
|
-
if (isLeafValue) partNames.push('leaf-value');
|
|
5102
|
-
else partNames.push('node-value');
|
|
5103
|
-
return lit.html`${renderFacetValueLink({
|
|
5104
|
-
props: {
|
|
5105
|
-
displayValue,
|
|
5106
|
-
numberOfResults,
|
|
5107
|
-
i18n,
|
|
5108
|
-
onClick,
|
|
5109
|
-
isSelected,
|
|
5110
|
-
searchQuery,
|
|
5111
|
-
part: partNames.join(' '),
|
|
5112
|
-
class: 'contents',
|
|
5113
|
-
buttonRef: (element)=>{
|
|
5114
|
-
setRef?.(element);
|
|
5115
|
-
},
|
|
5116
|
-
subList: children
|
|
5117
|
-
}
|
|
5118
|
-
})(renderFacetValueLabelHighlight({
|
|
5119
|
-
props: {
|
|
5120
|
-
displayValue,
|
|
5121
|
-
searchQuery,
|
|
5122
|
-
isSelected
|
|
5123
|
-
}
|
|
5124
|
-
}))}`;
|
|
5125
|
-
};
|
|
5126
|
-
|
|
5127
|
-
const renderCategoryFacetParentValueLink = ({ props })=>renderCategoryFacetValueLink({
|
|
5128
|
-
props: {
|
|
5129
|
-
...props,
|
|
5130
|
-
isParent: true,
|
|
5131
|
-
isSelected: true
|
|
5132
|
-
}
|
|
5133
|
-
});
|
|
5134
|
-
|
|
5135
5090
|
const renderCategoryFacetSearchResultsContainer = ()=>(children)=>lit.html`<ul part="search-results" class="mt-3">
|
|
5136
5091
|
${children}
|
|
5137
5092
|
</ul>`;
|
|
@@ -5226,8 +5181,97 @@ const renderCategoryFacetSearchValue = ({ props })=>{
|
|
|
5226
5181
|
</li>`;
|
|
5227
5182
|
};
|
|
5228
5183
|
|
|
5184
|
+
const renderCategoryFacetSelectedValue = ({ props: { displayValue, label, i18n, onClearFilters } })=>lit.html`<div part="selected-value" class="mt-3 flex items-center justify-between gap-2">
|
|
5185
|
+
<span
|
|
5186
|
+
part="selected-value-pill"
|
|
5187
|
+
title=${displayValue}
|
|
5188
|
+
class="bg-neutral-light truncate rounded-md px-2 py-1 text-sm"
|
|
5189
|
+
>${displayValue}</span
|
|
5190
|
+
>
|
|
5191
|
+
${renderButton({
|
|
5192
|
+
props: {
|
|
5193
|
+
part: 'selected-value-clear-button',
|
|
5194
|
+
style: 'text-primary',
|
|
5195
|
+
class: 'flex shrink-0 items-center p-1 text-sm',
|
|
5196
|
+
ariaLabel: i18n.t('clear-filters-for-facet', {
|
|
5197
|
+
count: 1,
|
|
5198
|
+
label: i18n.t(label)
|
|
5199
|
+
}),
|
|
5200
|
+
onClick: onClearFilters
|
|
5201
|
+
}
|
|
5202
|
+
})(lit.html`<atomic-icon
|
|
5203
|
+
part="selected-value-clear-button-icon"
|
|
5204
|
+
class="mr-1 h-2 w-2"
|
|
5205
|
+
.icon=${images_close}
|
|
5206
|
+
></atomic-icon>
|
|
5207
|
+
<span>${i18n.t('clear')}</span>`)}
|
|
5208
|
+
</div>`;
|
|
5209
|
+
|
|
5229
5210
|
const renderCategoryFacetTreeValueContainer = ()=>(children)=>lit.html`<li class="contents">${children}</li>`;
|
|
5230
5211
|
|
|
5212
|
+
const renderFacetValueLink = ({ props })=>(children)=>{
|
|
5213
|
+
const count = props.numberOfResults.toLocaleString(props.i18n.language);
|
|
5214
|
+
const ariaLabel = props.i18n.t('facet-value', {
|
|
5215
|
+
value: props.displayValue,
|
|
5216
|
+
count: props.numberOfResults,
|
|
5217
|
+
formattedCount: count,
|
|
5218
|
+
interpolation: {
|
|
5219
|
+
escapeValue: false
|
|
5220
|
+
}
|
|
5221
|
+
});
|
|
5222
|
+
let part = props.part ?? `value-link${props.isSelected ? ' value-link-selected' : ''}`;
|
|
5223
|
+
if (props.additionalPart) part += ` ${props.additionalPart}`;
|
|
5224
|
+
return lit.html`
|
|
5225
|
+
${keyed_js.keyed(props.displayValue, lit.html`<li class=${ifDefined_js.ifDefined(props.class)}>
|
|
5226
|
+
${renderButton({
|
|
5227
|
+
props: {
|
|
5228
|
+
style: 'text-neutral',
|
|
5229
|
+
part,
|
|
5230
|
+
onClick: ()=>props.onClick(),
|
|
5231
|
+
class: 'group flex w-full items-center truncate px-2 py-2.5 text-left focus-visible:outline-none',
|
|
5232
|
+
ariaPressed: props.isSelected ? 'true' : 'false',
|
|
5233
|
+
ariaLabel,
|
|
5234
|
+
ref: props.buttonRef
|
|
5235
|
+
}
|
|
5236
|
+
})(lit.html`${children}<span part="value-count" class="value-count">
|
|
5237
|
+
${props.i18n.t('between-parentheses', {
|
|
5238
|
+
text: count
|
|
5239
|
+
})}
|
|
5240
|
+
</span>`)}
|
|
5241
|
+
${props.subList}
|
|
5242
|
+
</li>`)}
|
|
5243
|
+
`;
|
|
5244
|
+
};
|
|
5245
|
+
|
|
5246
|
+
const renderCategoryFacetValueLink = ({ props: { displayValue, numberOfResults, i18n, onClick, isSelected, searchQuery, isLeafValue, setRef } })=>(children)=>{
|
|
5247
|
+
const partNames = [
|
|
5248
|
+
`value-link${isSelected ? ' value-link-selected' : ''}`,
|
|
5249
|
+
isLeafValue ? 'leaf-value' : 'node-value'
|
|
5250
|
+
];
|
|
5251
|
+
return lit.html`${renderFacetValueLink({
|
|
5252
|
+
props: {
|
|
5253
|
+
displayValue,
|
|
5254
|
+
numberOfResults,
|
|
5255
|
+
i18n,
|
|
5256
|
+
onClick,
|
|
5257
|
+
isSelected,
|
|
5258
|
+
searchQuery,
|
|
5259
|
+
part: partNames.join(' '),
|
|
5260
|
+
class: 'contents',
|
|
5261
|
+
buttonRef: (element)=>{
|
|
5262
|
+
setRef?.(element);
|
|
5263
|
+
},
|
|
5264
|
+
subList: children
|
|
5265
|
+
}
|
|
5266
|
+
})(renderFacetValueLabelHighlight({
|
|
5267
|
+
props: {
|
|
5268
|
+
displayValue,
|
|
5269
|
+
searchQuery,
|
|
5270
|
+
isSelected
|
|
5271
|
+
}
|
|
5272
|
+
}))}`;
|
|
5273
|
+
};
|
|
5274
|
+
|
|
5231
5275
|
const styles$e = lit.css`/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}.value-count{margin-left:calc(var(--spacing,.25rem)*1.5);color:var(--atomic-neutral-dark)}[part=value-exclude-button]+.value-count{margin-right:calc(var(--spacing,.25rem)*2)}:host(:state(hidden)){display:none}:host(.popover-nested){min-width:var(--container-2xs,18rem)}:host(.popover-nested)::part(label-button){display:none}:host(.popover-nested)::part(facet){--tw-shadow:0px 2px 8px var(--tw-shadow-color,#e5e8e8bf);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}:host(.popover-nested)::part(values){max-height:calc(var(--spacing,.25rem)*96);margin-top:0;overflow-y:auto}:host(.popover-nested)::part(search-wrapper){margin-bottom:calc(var(--spacing,.25rem)*2)}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}`;
|
|
5232
5276
|
const facet_common_tw_css = styles$e;
|
|
5233
5277
|
|
|
@@ -5298,6 +5342,21 @@ let AtomicCommerceCategoryFacet$1 = class AtomicCommerceCategoryFacet extends li
|
|
|
5298
5342
|
}
|
|
5299
5343
|
});
|
|
5300
5344
|
}
|
|
5345
|
+
renderSelectedValue() {
|
|
5346
|
+
const activeValue = this.facetState.selectedValueAncestry?.at(-1);
|
|
5347
|
+
if (!activeValue) return lit.nothing;
|
|
5348
|
+
return renderCategoryFacetSelectedValue({
|
|
5349
|
+
props: {
|
|
5350
|
+
displayValue: getFieldValueCaption(this.facetState.field, activeValue.value, this.bindings.i18n),
|
|
5351
|
+
label: this.displayName,
|
|
5352
|
+
i18n: this.bindings.i18n,
|
|
5353
|
+
onClearFilters: ()=>{
|
|
5354
|
+
this.focusTargets.activeValueFocus.focusAfterSearch();
|
|
5355
|
+
this.facet.deselectAll();
|
|
5356
|
+
}
|
|
5357
|
+
}
|
|
5358
|
+
});
|
|
5359
|
+
}
|
|
5301
5360
|
renderValuesTree(parents, isRoot) {
|
|
5302
5361
|
if (!this.hasParents) return this.renderChildren();
|
|
5303
5362
|
if (isRoot) return renderCategoryFacetTreeValueContainer()(lit.html`
|
|
@@ -5342,16 +5401,12 @@ let AtomicCommerceCategoryFacet$1 = class AtomicCommerceCategoryFacet extends li
|
|
|
5342
5401
|
const activeParent = parents[0];
|
|
5343
5402
|
const activeParentDisplayValue = getFieldValueCaption(this.facetState?.field, activeParent.value, this.bindings.i18n);
|
|
5344
5403
|
return lit.html`
|
|
5345
|
-
${
|
|
5404
|
+
${renderCategoryFacetActiveValue({
|
|
5346
5405
|
props: {
|
|
5347
5406
|
displayValue: activeParentDisplayValue,
|
|
5348
5407
|
numberOfResults: activeParent.numberOfResults,
|
|
5349
5408
|
i18n: this.bindings.i18n,
|
|
5350
5409
|
isLeafValue: activeParent.isLeafValue,
|
|
5351
|
-
onClick: ()=>{
|
|
5352
|
-
this.focusTargets.activeValueFocus.focusAfterSearch();
|
|
5353
|
-
this.facet.deselectAll();
|
|
5354
|
-
},
|
|
5355
5410
|
searchQuery: this.facetState.facetSearch.query,
|
|
5356
5411
|
setRef: (el)=>{
|
|
5357
5412
|
this.focusTargets.activeValueFocus.setTarget(el);
|
|
@@ -5376,7 +5431,6 @@ let AtomicCommerceCategoryFacet$1 = class AtomicCommerceCategoryFacet extends li
|
|
|
5376
5431
|
this.focusTargets.activeValueFocus.focusAfterSearch();
|
|
5377
5432
|
this.facet.toggleSelect(facetValue);
|
|
5378
5433
|
},
|
|
5379
|
-
isParent: false,
|
|
5380
5434
|
isSelected,
|
|
5381
5435
|
searchQuery: this.facetState.facetSearch.query,
|
|
5382
5436
|
isLeafValue: facetValue.isLeafValue,
|
|
@@ -5451,6 +5505,7 @@ let AtomicCommerceCategoryFacet$1 = class AtomicCommerceCategoryFacet extends li
|
|
|
5451
5505
|
onClear: ()=>this.facet.facetSearch.clear()
|
|
5452
5506
|
}
|
|
5453
5507
|
})}
|
|
5508
|
+
${this.renderSelectedValue()}
|
|
5454
5509
|
${when_js.when(shouldDisplaySearchResults(facetSearch), ()=>lit.html`
|
|
5455
5510
|
${when_js.when(facetSearch.values.length > 0, ()=>renderFacetValuesGroup({
|
|
5456
5511
|
props: {
|
|
@@ -9781,7 +9836,7 @@ function getWindow() {
|
|
|
9781
9836
|
}
|
|
9782
9837
|
function getAtomicEnvironment(headlessVersion) {
|
|
9783
9838
|
return {
|
|
9784
|
-
version: "3.
|
|
9839
|
+
version: "3.63.0",
|
|
9785
9840
|
headlessVersion
|
|
9786
9841
|
};
|
|
9787
9842
|
}
|
|
@@ -9805,20 +9860,20 @@ function augmentAnalyticsConfigWithAtomicVersion() {
|
|
|
9805
9860
|
const locales = {
|
|
9806
9861
|
af: ()=>Promise.resolve().then(function () { return af$1; }),
|
|
9807
9862
|
am: ()=>Promise.resolve().then(function () { return am$1; }),
|
|
9808
|
-
'ar-
|
|
9809
|
-
'ar-
|
|
9810
|
-
'ar-
|
|
9811
|
-
'ar-
|
|
9812
|
-
'ar-
|
|
9813
|
-
'ar-
|
|
9814
|
-
'ar-
|
|
9863
|
+
'ar-iq': ()=>Promise.resolve().then(function () { return arIq$1; }),
|
|
9864
|
+
'ar-dz': ()=>Promise.resolve().then(function () { return arDz$1; }),
|
|
9865
|
+
'ar-kw': ()=>Promise.resolve().then(function () { return arKw$1; }),
|
|
9866
|
+
'ar-ly': ()=>Promise.resolve().then(function () { return arLy$1; }),
|
|
9867
|
+
'ar-ma': ()=>Promise.resolve().then(function () { return arMa$1; }),
|
|
9868
|
+
'ar-sa': ()=>Promise.resolve().then(function () { return arSa$1; }),
|
|
9869
|
+
'ar-tn': ()=>Promise.resolve().then(function () { return arTn$1; }),
|
|
9815
9870
|
ar: ()=>Promise.resolve().then(function () { return ar$1; }),
|
|
9816
9871
|
az: ()=>Promise.resolve().then(function () { return az$1; }),
|
|
9817
9872
|
be: ()=>Promise.resolve().then(function () { return be$1; }),
|
|
9818
9873
|
bg: ()=>Promise.resolve().then(function () { return bg$1; }),
|
|
9819
9874
|
bi: ()=>Promise.resolve().then(function () { return bi$1; }),
|
|
9820
9875
|
bm: ()=>Promise.resolve().then(function () { return bm$1; }),
|
|
9821
|
-
'bn-
|
|
9876
|
+
'bn-bd': ()=>Promise.resolve().then(function () { return bnBd$1; }),
|
|
9822
9877
|
bn: ()=>Promise.resolve().then(function () { return bn$1; }),
|
|
9823
9878
|
bo: ()=>Promise.resolve().then(function () { return bo$1; }),
|
|
9824
9879
|
br: ()=>Promise.resolve().then(function () { return br$1; }),
|
|
@@ -9828,49 +9883,49 @@ const locales = {
|
|
|
9828
9883
|
cv: ()=>Promise.resolve().then(function () { return cv$1; }),
|
|
9829
9884
|
cy: ()=>Promise.resolve().then(function () { return cy$1; }),
|
|
9830
9885
|
da: ()=>Promise.resolve().then(function () { return da$1; }),
|
|
9831
|
-
'de-
|
|
9832
|
-
'de-
|
|
9886
|
+
'de-at': ()=>Promise.resolve().then(function () { return deAt$1; }),
|
|
9887
|
+
'de-ch': ()=>Promise.resolve().then(function () { return deCh$1; }),
|
|
9833
9888
|
de: ()=>Promise.resolve().then(function () { return de$1; }),
|
|
9834
9889
|
dv: ()=>Promise.resolve().then(function () { return dv$1; }),
|
|
9835
|
-
'en-
|
|
9890
|
+
'en-au': ()=>Promise.resolve().then(function () { return enAu$1; }),
|
|
9836
9891
|
el: ()=>Promise.resolve().then(function () { return el$1; }),
|
|
9837
|
-
'en-
|
|
9838
|
-
'en-
|
|
9839
|
-
'en-
|
|
9840
|
-
'en-
|
|
9841
|
-
'en-
|
|
9842
|
-
'en-
|
|
9843
|
-
'en-
|
|
9844
|
-
'en-
|
|
9892
|
+
'en-gb': ()=>Promise.resolve().then(function () { return enGb$1; }),
|
|
9893
|
+
'en-ie': ()=>Promise.resolve().then(function () { return enIe$1; }),
|
|
9894
|
+
'en-il': ()=>Promise.resolve().then(function () { return enIl$1; }),
|
|
9895
|
+
'en-in': ()=>Promise.resolve().then(function () { return enIn$1; }),
|
|
9896
|
+
'en-nz': ()=>Promise.resolve().then(function () { return enNz$1; }),
|
|
9897
|
+
'en-sg': ()=>Promise.resolve().then(function () { return enSg$1; }),
|
|
9898
|
+
'en-tt': ()=>Promise.resolve().then(function () { return enTt$1; }),
|
|
9899
|
+
'en-ca': ()=>Promise.resolve().then(function () { return enCa$1; }),
|
|
9845
9900
|
en: ()=>Promise.resolve().then(function () { return en$1; }),
|
|
9846
9901
|
eo: ()=>Promise.resolve().then(function () { return eo$1; }),
|
|
9847
|
-
'es-
|
|
9848
|
-
'es-
|
|
9849
|
-
'es-
|
|
9850
|
-
'es-
|
|
9902
|
+
'es-mx': ()=>Promise.resolve().then(function () { return esMx$1; }),
|
|
9903
|
+
'es-pr': ()=>Promise.resolve().then(function () { return esPr$1; }),
|
|
9904
|
+
'es-us': ()=>Promise.resolve().then(function () { return esUs$1; }),
|
|
9905
|
+
'es-do': ()=>Promise.resolve().then(function () { return esDo$1; }),
|
|
9851
9906
|
et: ()=>Promise.resolve().then(function () { return et$1; }),
|
|
9852
9907
|
eu: ()=>Promise.resolve().then(function () { return eu$1; }),
|
|
9853
9908
|
fa: ()=>Promise.resolve().then(function () { return fa$1; }),
|
|
9854
9909
|
fi: ()=>Promise.resolve().then(function () { return fi$1; }),
|
|
9855
|
-
'fr-
|
|
9856
|
-
'fr-
|
|
9910
|
+
'fr-ca': ()=>Promise.resolve().then(function () { return frCa$1; }),
|
|
9911
|
+
'fr-ch': ()=>Promise.resolve().then(function () { return frCh$1; }),
|
|
9857
9912
|
fr: ()=>Promise.resolve().then(function () { return fr$1; }),
|
|
9858
9913
|
fo: ()=>Promise.resolve().then(function () { return fo$1; }),
|
|
9859
9914
|
fy: ()=>Promise.resolve().then(function () { return fy$1; }),
|
|
9860
9915
|
ga: ()=>Promise.resolve().then(function () { return ga$1; }),
|
|
9861
9916
|
gd: ()=>Promise.resolve().then(function () { return gd$1; }),
|
|
9862
9917
|
gl: ()=>Promise.resolve().then(function () { return gl$1; }),
|
|
9863
|
-
'gom-
|
|
9918
|
+
'gom-latn': ()=>Promise.resolve().then(function () { return gomLatn$1; }),
|
|
9864
9919
|
gu: ()=>Promise.resolve().then(function () { return gu$1; }),
|
|
9865
9920
|
he: ()=>Promise.resolve().then(function () { return he$1; }),
|
|
9866
9921
|
hi: ()=>Promise.resolve().then(function () { return hi$1; }),
|
|
9867
9922
|
hr: ()=>Promise.resolve().then(function () { return hr$1; }),
|
|
9868
9923
|
ht: ()=>Promise.resolve().then(function () { return ht$1; }),
|
|
9869
9924
|
hu: ()=>Promise.resolve().then(function () { return hu$1; }),
|
|
9870
|
-
'hy-
|
|
9925
|
+
'hy-am': ()=>Promise.resolve().then(function () { return hyAm$1; }),
|
|
9871
9926
|
id: ()=>Promise.resolve().then(function () { return id$1; }),
|
|
9872
9927
|
is: ()=>Promise.resolve().then(function () { return is$1; }),
|
|
9873
|
-
'it-
|
|
9928
|
+
'it-ch': ()=>Promise.resolve().then(function () { return itCh$1; }),
|
|
9874
9929
|
it: ()=>Promise.resolve().then(function () { return it$1; }),
|
|
9875
9930
|
jv: ()=>Promise.resolve().then(function () { return jv$1; }),
|
|
9876
9931
|
ka: ()=>Promise.resolve().then(function () { return ka$1; }),
|
|
@@ -9890,7 +9945,7 @@ const locales = {
|
|
|
9890
9945
|
ml: ()=>Promise.resolve().then(function () { return ml$1; }),
|
|
9891
9946
|
mn: ()=>Promise.resolve().then(function () { return mn$1; }),
|
|
9892
9947
|
mr: ()=>Promise.resolve().then(function () { return mr$1; }),
|
|
9893
|
-
'ms-
|
|
9948
|
+
'ms-my': ()=>Promise.resolve().then(function () { return msMy$1; }),
|
|
9894
9949
|
ms: ()=>Promise.resolve().then(function () { return ms$1; }),
|
|
9895
9950
|
mt: ()=>Promise.resolve().then(function () { return mt$1; }),
|
|
9896
9951
|
lo: ()=>Promise.resolve().then(function () { return lo$1; }),
|
|
@@ -9898,11 +9953,11 @@ const locales = {
|
|
|
9898
9953
|
nb: ()=>Promise.resolve().then(function () { return nb$1; }),
|
|
9899
9954
|
ne: ()=>Promise.resolve().then(function () { return ne$1; }),
|
|
9900
9955
|
nl: ()=>Promise.resolve().then(function () { return nl$1; }),
|
|
9901
|
-
'nl-
|
|
9956
|
+
'nl-be': ()=>Promise.resolve().then(function () { return nlBe$1; }),
|
|
9902
9957
|
nn: ()=>Promise.resolve().then(function () { return nn$1; }),
|
|
9903
|
-
'pa-
|
|
9958
|
+
'pa-in': ()=>Promise.resolve().then(function () { return paIn$1; }),
|
|
9904
9959
|
pl: ()=>Promise.resolve().then(function () { return pl$1; }),
|
|
9905
|
-
'pt-
|
|
9960
|
+
'pt-br': ()=>Promise.resolve().then(function () { return ptBr$1; }),
|
|
9906
9961
|
pt: ()=>Promise.resolve().then(function () { return pt$1; }),
|
|
9907
9962
|
rn: ()=>Promise.resolve().then(function () { return rn$1; }),
|
|
9908
9963
|
ro: ()=>Promise.resolve().then(function () { return ro$1; }),
|
|
@@ -9914,12 +9969,12 @@ const locales = {
|
|
|
9914
9969
|
si: ()=>Promise.resolve().then(function () { return si$1; }),
|
|
9915
9970
|
sk: ()=>Promise.resolve().then(function () { return sk$1; }),
|
|
9916
9971
|
sl: ()=>Promise.resolve().then(function () { return sl$1; }),
|
|
9917
|
-
'oc-
|
|
9972
|
+
'oc-lnc': ()=>Promise.resolve().then(function () { return ocLnc$1; }),
|
|
9918
9973
|
sq: ()=>Promise.resolve().then(function () { return sq$1; }),
|
|
9919
|
-
'sr-
|
|
9974
|
+
'sr-cyrl': ()=>Promise.resolve().then(function () { return srCyrl$1; }),
|
|
9920
9975
|
sr: ()=>Promise.resolve().then(function () { return sr$1; }),
|
|
9921
9976
|
ss: ()=>Promise.resolve().then(function () { return ss$1; }),
|
|
9922
|
-
'sv-
|
|
9977
|
+
'sv-fi': ()=>Promise.resolve().then(function () { return svFi$1; }),
|
|
9923
9978
|
sv: ()=>Promise.resolve().then(function () { return sv$1; }),
|
|
9924
9979
|
sw: ()=>Promise.resolve().then(function () { return sw$1; }),
|
|
9925
9980
|
ta: ()=>Promise.resolve().then(function () { return ta$1; }),
|
|
@@ -9927,42 +9982,56 @@ const locales = {
|
|
|
9927
9982
|
tet: ()=>Promise.resolve().then(function () { return tet$1; }),
|
|
9928
9983
|
tg: ()=>Promise.resolve().then(function () { return tg$1; }),
|
|
9929
9984
|
th: ()=>Promise.resolve().then(function () { return th$1; }),
|
|
9930
|
-
'tl-
|
|
9985
|
+
'tl-ph': ()=>Promise.resolve().then(function () { return tlPh$1; }),
|
|
9931
9986
|
tlh: ()=>Promise.resolve().then(function () { return tlh$1; }),
|
|
9932
9987
|
tr: ()=>Promise.resolve().then(function () { return tr$1; }),
|
|
9933
9988
|
tzl: ()=>Promise.resolve().then(function () { return tzl$1; }),
|
|
9934
9989
|
tzm: ()=>Promise.resolve().then(function () { return tzm$1; }),
|
|
9935
|
-
'ug-
|
|
9990
|
+
'ug-cn': ()=>Promise.resolve().then(function () { return ugCn$1; }),
|
|
9936
9991
|
uk: ()=>Promise.resolve().then(function () { return uk$1; }),
|
|
9937
9992
|
tk: ()=>Promise.resolve().then(function () { return tk$1; }),
|
|
9938
9993
|
ur: ()=>Promise.resolve().then(function () { return ur$1; }),
|
|
9939
|
-
'uz-
|
|
9994
|
+
'uz-latn': ()=>Promise.resolve().then(function () { return uzLatn$1; }),
|
|
9940
9995
|
uz: ()=>Promise.resolve().then(function () { return uz$1; }),
|
|
9941
9996
|
vi: ()=>Promise.resolve().then(function () { return vi$1; }),
|
|
9942
|
-
'x-
|
|
9943
|
-
'tzm-
|
|
9997
|
+
'x-pseudo': ()=>Promise.resolve().then(function () { return xPseudo$1; }),
|
|
9998
|
+
'tzm-latn': ()=>Promise.resolve().then(function () { return tzmLatn$1; }),
|
|
9944
9999
|
yo: ()=>Promise.resolve().then(function () { return yo$1; }),
|
|
9945
|
-
'zh-
|
|
9946
|
-
'zh-
|
|
9947
|
-
'zh-
|
|
10000
|
+
'zh-cn': ()=>Promise.resolve().then(function () { return zhCn$1; }),
|
|
10001
|
+
'zh-hk': ()=>Promise.resolve().then(function () { return zhHk$1; }),
|
|
10002
|
+
'zh-tw': ()=>Promise.resolve().then(function () { return zhTw$1; }),
|
|
9948
10003
|
zh: ()=>Promise.resolve().then(function () { return zh$1; })
|
|
9949
10004
|
};
|
|
9950
10005
|
|
|
9951
10006
|
const warn = (language)=>console.warn(`Cannot load dayjs locale file for "${language}"`);
|
|
9952
|
-
const
|
|
9953
|
-
|
|
9954
|
-
|
|
9955
|
-
|
|
9956
|
-
|
|
10007
|
+
const getCandidateLocales = (languageInput)=>{
|
|
10008
|
+
try {
|
|
10009
|
+
const { language, script, region } = new Intl.Locale(languageInput);
|
|
10010
|
+
return [
|
|
10011
|
+
languageInput,
|
|
10012
|
+
...region ? [
|
|
10013
|
+
`${language}-${region}`
|
|
10014
|
+
] : [],
|
|
10015
|
+
...script ? [
|
|
10016
|
+
`${language}-${script}`
|
|
10017
|
+
] : [],
|
|
10018
|
+
language
|
|
10019
|
+
];
|
|
10020
|
+
} catch {
|
|
10021
|
+
return [
|
|
10022
|
+
languageInput,
|
|
10023
|
+
languageInput.split('-')[0]
|
|
10024
|
+
];
|
|
9957
10025
|
}
|
|
9958
|
-
return languageInput;
|
|
9959
10026
|
};
|
|
9960
|
-
|
|
10027
|
+
const resolveLanguage = (languageInput)=>getCandidateLocales(languageInput).map((locale)=>locale.toLowerCase()).find((locale)=>Object.hasOwn(locales, locale)) ?? languageInput;
|
|
10028
|
+
async function loadDayjsLocale(languageInput) {
|
|
9961
10029
|
const language = resolveLanguage(languageInput);
|
|
9962
10030
|
if (!locales[language]) return void warn(language);
|
|
9963
10031
|
try {
|
|
9964
|
-
locales[language]()
|
|
9965
|
-
|
|
10032
|
+
await locales[language]();
|
|
10033
|
+
dayjs.locale(language);
|
|
10034
|
+
} catch {
|
|
9966
10035
|
warn(language);
|
|
9967
10036
|
}
|
|
9968
10037
|
}
|
|
@@ -10349,9 +10418,13 @@ function i18nBackendOptions(atomicInterface) {
|
|
|
10349
10418
|
}
|
|
10350
10419
|
};
|
|
10351
10420
|
}
|
|
10352
|
-
function loadTranslations(atomicInterface, language) {
|
|
10421
|
+
async function loadTranslations(atomicInterface, language) {
|
|
10422
|
+
const { languageUtils } = atomicInterface.i18n.services;
|
|
10423
|
+
const languages = languageUtils.toResolveHierarchy(languageUtils.formatLanguageCode(language), false);
|
|
10424
|
+
await Promise.all(languages.filter(isI18nLocaleAvailable).map((lng)=>loadTranslationBundle(atomicInterface, lng)));
|
|
10425
|
+
}
|
|
10426
|
+
function loadTranslationBundle(atomicInterface, lng) {
|
|
10353
10427
|
const { i18n } = atomicInterface;
|
|
10354
|
-
const lng = language.split('-')[0];
|
|
10355
10428
|
return new Promise((resolve)=>{
|
|
10356
10429
|
new Backend(i18n.services, i18nBackendOptions(atomicInterface)).read(lng, i18nTranslationNamespace, (_error, data)=>{
|
|
10357
10430
|
if (data) i18n.addResourceBundle(lng, i18nTranslationNamespace, data, true, false);
|
|
@@ -10566,8 +10639,10 @@ class InterfaceController {
|
|
|
10566
10639
|
this.host.updateIconAssetsPath();
|
|
10567
10640
|
initEngine();
|
|
10568
10641
|
if (this.host.registerFieldsToInclude) this.host.registerFieldsToInclude();
|
|
10569
|
-
|
|
10570
|
-
|
|
10642
|
+
await Promise.all([
|
|
10643
|
+
this.i18nPromise,
|
|
10644
|
+
loadDayjsLocale(this.host.language || 'en')
|
|
10645
|
+
]);
|
|
10571
10646
|
this.initComponents();
|
|
10572
10647
|
}
|
|
10573
10648
|
onAnalyticsChange() {
|
|
@@ -10580,8 +10655,10 @@ class InterfaceController {
|
|
|
10580
10655
|
const language = newLanguage ?? this.host.language;
|
|
10581
10656
|
const languageWithFallback = language ?? 'en';
|
|
10582
10657
|
const { i18n } = this.host;
|
|
10583
|
-
|
|
10584
|
-
|
|
10658
|
+
Promise.all([
|
|
10659
|
+
loadDayjsLocale(languageWithFallback),
|
|
10660
|
+
loadTranslations(this.host, languageWithFallback)
|
|
10661
|
+
]).then(()=>{
|
|
10585
10662
|
i18n.changeLanguage(language);
|
|
10586
10663
|
});
|
|
10587
10664
|
}
|
|
@@ -10709,6 +10786,18 @@ class SafeStorage {
|
|
|
10709
10786
|
}
|
|
10710
10787
|
}
|
|
10711
10788
|
|
|
10789
|
+
function withCountry(language, country) {
|
|
10790
|
+
if (!country) return language;
|
|
10791
|
+
try {
|
|
10792
|
+
if (new Intl.Locale(language).region) return language;
|
|
10793
|
+
return new Intl.Locale(language, {
|
|
10794
|
+
region: country
|
|
10795
|
+
}).toString();
|
|
10796
|
+
} catch {
|
|
10797
|
+
return language;
|
|
10798
|
+
}
|
|
10799
|
+
}
|
|
10800
|
+
|
|
10712
10801
|
function getAnalyticsConfig(commerceEngineConfig, enabled) {
|
|
10713
10802
|
return {
|
|
10714
10803
|
enabled,
|
|
@@ -10834,7 +10923,7 @@ let AtomicCommerceInterface$1 = class AtomicCommerceInterface extends ChildrenUp
|
|
|
10834
10923
|
}
|
|
10835
10924
|
updateLocale(language, country, currency) {
|
|
10836
10925
|
if (!this.interfaceController.engineIsCreated(this.engine) || !this.context) return;
|
|
10837
|
-
language && this.interfaceController.onLanguageChange(language);
|
|
10926
|
+
if (language || country && this.localizeWithCountry) this.interfaceController.onLanguageChange(this.getLocale(language || this.context.state.language, country || this.context.state.country));
|
|
10838
10927
|
if (this.isNewLocale(language, country, currency)) {
|
|
10839
10928
|
const { setContext } = commerce.loadContextActions(this.engine);
|
|
10840
10929
|
this.engine.dispatch(setContext({
|
|
@@ -10859,7 +10948,11 @@ let AtomicCommerceInterface$1 = class AtomicCommerceInterface extends ChildrenUp
|
|
|
10859
10948
|
if (!this.interfaceController.engineIsCreated(this.engine) || !this.language || !this.context) return;
|
|
10860
10949
|
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 `initialize` or `initializeWithEngine`, and update the language as needed using the `updateLocale` method.');
|
|
10861
10950
|
this.context.setLanguage(this.language);
|
|
10862
|
-
return this.interfaceController.onLanguageChange();
|
|
10951
|
+
return this.interfaceController.onLanguageChange(this.getLocale(this.language, this.context.state.country));
|
|
10952
|
+
}
|
|
10953
|
+
toggleLocalizeWithCountry() {
|
|
10954
|
+
if (!this.context) return;
|
|
10955
|
+
this.interfaceController.onLanguageChange(this.getLocale(this.context.state.language, this.context.state.country));
|
|
10863
10956
|
}
|
|
10864
10957
|
updateIconAssetsPath() {
|
|
10865
10958
|
this.store.state.iconAssetsPath = this.iconAssetsPath;
|
|
@@ -10900,7 +10993,10 @@ let AtomicCommerceInterface$1 = class AtomicCommerceInterface extends ChildrenUp
|
|
|
10900
10993
|
}
|
|
10901
10994
|
initLanguage() {
|
|
10902
10995
|
if (!this.context || this.language) return;
|
|
10903
|
-
this.interfaceController.onLanguageChange(this.context.state.language);
|
|
10996
|
+
this.interfaceController.onLanguageChange(this.getLocale(this.context.state.language, this.context.state.country));
|
|
10997
|
+
}
|
|
10998
|
+
getLocale(language, country) {
|
|
10999
|
+
return this.localizeWithCountry ? withCountry(language, country) : language;
|
|
10904
11000
|
}
|
|
10905
11001
|
initRequestStatus() {
|
|
10906
11002
|
this.searchOrListing = 'product-listing' === this.type ? commerce.buildProductListing(this.engine) : commerce.buildSearch(this.engine);
|
|
@@ -10964,7 +11060,7 @@ let AtomicCommerceInterface$1 = class AtomicCommerceInterface extends ChildrenUp
|
|
|
10964
11060
|
this.bindings.engine.logger.info(`History pushState #${newFragment}`);
|
|
10965
11061
|
}
|
|
10966
11062
|
constructor(){
|
|
10967
|
-
super(), this.bindings = {}, this.unsubscribeUrlManager = ()=>{}, this.unsubscribeSummary = ()=>{}, this.initialized = false, this.interfaceController = new InterfaceController(this, 'CoveoAtomic', commerce.VERSION), this.type = 'search', this.analytics = true, this.reflectStateInUrl = true, this.disableStateReflectionInUrl = false, this.scrollContainer = 'atomic-commerce-interface', this.languageAssetsPath = './lang', this.iconAssetsPath = './assets', this.handleInitialization = (event)=>{
|
|
11063
|
+
super(), this.bindings = {}, this.unsubscribeUrlManager = ()=>{}, this.unsubscribeSummary = ()=>{}, this.initialized = false, this.interfaceController = new InterfaceController(this, 'CoveoAtomic', commerce.VERSION), this.type = 'search', this.analytics = true, this.localizeWithCountry = false, this.reflectStateInUrl = true, this.disableStateReflectionInUrl = false, this.scrollContainer = 'atomic-commerce-interface', this.languageAssetsPath = './lang', this.iconAssetsPath = './assets', this.handleInitialization = (event)=>{
|
|
10968
11064
|
this.interfaceController.onComponentInitializing(event);
|
|
10969
11065
|
}, this.onHashChange = ()=>{
|
|
10970
11066
|
this.urlManager.synchronize(this.fragment);
|
|
@@ -11026,6 +11122,13 @@ _ts_decorate$T([
|
|
|
11026
11122
|
}),
|
|
11027
11123
|
_ts_metadata$G("design:type", String)
|
|
11028
11124
|
], AtomicCommerceInterface$1.prototype, "language", void 0);
|
|
11125
|
+
_ts_decorate$T([
|
|
11126
|
+
decorators_js.property({
|
|
11127
|
+
type: Boolean,
|
|
11128
|
+
attribute: 'localize-with-country',
|
|
11129
|
+
reflect: true
|
|
11130
|
+
})
|
|
11131
|
+
], AtomicCommerceInterface$1.prototype, "localizeWithCountry", void 0);
|
|
11029
11132
|
_ts_decorate$T([
|
|
11030
11133
|
decorators_js.property({
|
|
11031
11134
|
type: Object,
|
|
@@ -11081,6 +11184,12 @@ _ts_decorate$T([
|
|
|
11081
11184
|
_ts_metadata$G("design:paramtypes", []),
|
|
11082
11185
|
_ts_metadata$G("design:returntype", void 0)
|
|
11083
11186
|
], AtomicCommerceInterface$1.prototype, "updateLanguage", null);
|
|
11187
|
+
_ts_decorate$T([
|
|
11188
|
+
watch('localizeWithCountry'),
|
|
11189
|
+
_ts_metadata$G("design:type", Function),
|
|
11190
|
+
_ts_metadata$G("design:paramtypes", []),
|
|
11191
|
+
_ts_metadata$G("design:returntype", void 0)
|
|
11192
|
+
], AtomicCommerceInterface$1.prototype, "toggleLocalizeWithCountry", null);
|
|
11084
11193
|
_ts_decorate$T([
|
|
11085
11194
|
watch('iconAssetsPath'),
|
|
11086
11195
|
_ts_metadata$G("design:type", Function),
|
|
@@ -11504,6 +11613,40 @@ const renderPagerNavigation = ({ props })=>(children)=>lit.html`<nav aria-label=
|
|
|
11504
11613
|
<div part="buttons" class="flex flex-wrap gap-2">${children}</div>
|
|
11505
11614
|
</nav>`;
|
|
11506
11615
|
|
|
11616
|
+
class PagerFitController {
|
|
11617
|
+
hostConnected() {
|
|
11618
|
+
this.resizeObserver = new ResizeObserver(()=>requestAnimationFrame(()=>this.reset()));
|
|
11619
|
+
this.resizeObserver.observe(document.documentElement);
|
|
11620
|
+
if (this.host.parentElement) this.resizeObserver.observe(this.host.parentElement);
|
|
11621
|
+
}
|
|
11622
|
+
hostDisconnected() {
|
|
11623
|
+
this.resizeObserver?.disconnect();
|
|
11624
|
+
}
|
|
11625
|
+
hostUpdated() {
|
|
11626
|
+
const root = this.host.shadowRoot;
|
|
11627
|
+
const previousButton = root?.querySelector('[part="previous-button"]');
|
|
11628
|
+
const nextButton = root?.querySelector('[part="next-button"]');
|
|
11629
|
+
const pageButtonCount = root?.querySelectorAll('[part~="page-button"]').length ?? 0;
|
|
11630
|
+
const isWrapping = !!previousButton && !!nextButton && nextButton.offsetTop > previousButton.offsetTop;
|
|
11631
|
+
if (isWrapping && pageButtonCount > 1) {
|
|
11632
|
+
this.maxPages = pageButtonCount - 1;
|
|
11633
|
+
queueMicrotask(()=>this.host.requestUpdate());
|
|
11634
|
+
}
|
|
11635
|
+
}
|
|
11636
|
+
getNumberOfPagesToDisplay(numberOfPages) {
|
|
11637
|
+
return Math.min(numberOfPages, this.maxPages);
|
|
11638
|
+
}
|
|
11639
|
+
reset() {
|
|
11640
|
+
this.maxPages = 1 / 0;
|
|
11641
|
+
this.host.requestUpdate();
|
|
11642
|
+
}
|
|
11643
|
+
constructor(host){
|
|
11644
|
+
this.host = host;
|
|
11645
|
+
this.maxPages = 1 / 0;
|
|
11646
|
+
host.addController(this);
|
|
11647
|
+
}
|
|
11648
|
+
}
|
|
11649
|
+
|
|
11507
11650
|
const minimumPage = 0;
|
|
11508
11651
|
function getCurrentPagesRange(page, desiredNumberOfPages, maxPage) {
|
|
11509
11652
|
let range = buildRange(page, desiredNumberOfPages);
|
|
@@ -11568,7 +11711,7 @@ let AtomicCommercePager$1 = class AtomicCommercePager extends lit.LitElement {
|
|
|
11568
11711
|
});
|
|
11569
11712
|
}
|
|
11570
11713
|
render() {
|
|
11571
|
-
const pagesRange = getCurrentPagesRange(this.pagerState.page, this.numberOfPages, this.pagerState.totalPages - 1);
|
|
11714
|
+
const pagesRange = getCurrentPagesRange(this.pagerState.page, this.pagerFit.getNumberOfPagesToDisplay(this.numberOfPages), this.pagerState.totalPages - 1);
|
|
11572
11715
|
return lit.html`
|
|
11573
11716
|
${when_js.when(this.pagerState.totalPages > 1 && this.isAppLoaded, ()=>lit.html`
|
|
11574
11717
|
${renderPagerNavigation({
|
|
@@ -11638,7 +11781,7 @@ let AtomicCommercePager$1 = class AtomicCommercePager extends lit.LitElement {
|
|
|
11638
11781
|
});
|
|
11639
11782
|
}
|
|
11640
11783
|
constructor(){
|
|
11641
|
-
super(), this.isAppLoaded = false, this.numberOfPages = 5, this.previousButtonIcon = arrow_left_rounded, this.nextButtonIcon = arrow_right_rounded, this.ariaMessage = new AriaLiveRegionController(this, 'atomic-pager');
|
|
11784
|
+
super(), this.isAppLoaded = false, this.numberOfPages = 5, this.previousButtonIcon = arrow_left_rounded, this.nextButtonIcon = arrow_right_rounded, this.ariaMessage = new AriaLiveRegionController(this, 'atomic-pager'), this.pagerFit = new PagerFitController(this);
|
|
11642
11785
|
new ValidatePropsController(this, ()=>({
|
|
11643
11786
|
numberOfPages: this.numberOfPages
|
|
11644
11787
|
}), AtomicCommercePager.propsSchema);
|
|
@@ -14443,7 +14586,7 @@ let AtomicCommerceProductsPerPage$1 = class AtomicCommerceProductsPerPage extend
|
|
|
14443
14586
|
render() {
|
|
14444
14587
|
return lit.html`
|
|
14445
14588
|
${when_js.when(!this.summaryState.hasError && this.summaryState.hasProducts && this.isAppLoaded, ()=>lit.html`
|
|
14446
|
-
<div class="flex items-center">
|
|
14589
|
+
<div class="flex flex-wrap items-center">
|
|
14447
14590
|
${renderLabel()(lit.html`${this.label}`)}
|
|
14448
14591
|
${renderFieldsetGroup({
|
|
14449
14592
|
props: {
|
|
@@ -14940,7 +15083,7 @@ let AtomicCommerceRecommendationInterface$1 = class AtomicCommerceRecommendation
|
|
|
14940
15083
|
}
|
|
14941
15084
|
updateLocale(language, country, currency) {
|
|
14942
15085
|
if (!this.interfaceController.engineIsCreated(this.engine) || !this.context) return;
|
|
14943
|
-
language && this.interfaceController.onLanguageChange(language);
|
|
15086
|
+
if (language || country && this.localizeWithCountry) this.interfaceController.onLanguageChange(this.getLocale(language || this.context.state.language, country || this.context.state.country));
|
|
14944
15087
|
if (this.isNewLocale(language, country, currency)) {
|
|
14945
15088
|
const { setContext } = commerce.loadContextActions(this.engine);
|
|
14946
15089
|
this.engine.dispatch(setContext({
|
|
@@ -14963,11 +15106,15 @@ let AtomicCommerceRecommendationInterface$1 = class AtomicCommerceRecommendation
|
|
|
14963
15106
|
updateIconAssetsPath() {
|
|
14964
15107
|
this.store.state.iconAssetsPath = this.iconAssetsPath;
|
|
14965
15108
|
}
|
|
15109
|
+
toggleLocalizeWithCountry() {
|
|
15110
|
+
if (!this.context) return;
|
|
15111
|
+
this.interfaceController.onLanguageChange(this.getLocale(this.context.state.language, this.context.state.country));
|
|
15112
|
+
}
|
|
14966
15113
|
async updateLanguage() {
|
|
14967
15114
|
if (!this.interfaceController.engineIsCreated(this.engine) || !this.language || !this.context) return;
|
|
14968
15115
|
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.');
|
|
14969
15116
|
this.context.setLanguage(this.language);
|
|
14970
|
-
return this.interfaceController.onLanguageChange();
|
|
15117
|
+
return this.interfaceController.onLanguageChange(this.getLocale(this.language, this.context.state.country));
|
|
14971
15118
|
}
|
|
14972
15119
|
disconnectedCallback() {
|
|
14973
15120
|
super.disconnectedCallback();
|
|
@@ -15008,14 +15155,17 @@ let AtomicCommerceRecommendationInterface$1 = class AtomicCommerceRecommendation
|
|
|
15008
15155
|
}
|
|
15009
15156
|
initLanguage() {
|
|
15010
15157
|
if (!this.context || this.language) return;
|
|
15011
|
-
this.interfaceController.onLanguageChange(this.context.state.language);
|
|
15158
|
+
this.interfaceController.onLanguageChange(this.getLocale(this.context.state.language, this.context.state.country));
|
|
15159
|
+
}
|
|
15160
|
+
getLocale(language, country) {
|
|
15161
|
+
return this.localizeWithCountry ? withCountry(language, country) : language;
|
|
15012
15162
|
}
|
|
15013
15163
|
isNewLocale(language, country, currency) {
|
|
15014
15164
|
if (!this.context) return false;
|
|
15015
15165
|
return language && language !== this.context.state.language || country && country !== this.context.state.country || currency && currency !== this.context.state.currency;
|
|
15016
15166
|
}
|
|
15017
15167
|
constructor(){
|
|
15018
|
-
super(), this.bindings = {}, this.interfaceController = new InterfaceController(this, 'CoveoAtomic', commerce.VERSION), this.scrollContainer = 'atomic-commerce-recommendation-interface', this.languageAssetsPath = './lang', this.iconAssetsPath = './assets', this.analytics = true, this.handleInitialization = (event)=>{
|
|
15168
|
+
super(), this.bindings = {}, this.interfaceController = new InterfaceController(this, 'CoveoAtomic', commerce.VERSION), this.scrollContainer = 'atomic-commerce-recommendation-interface', this.languageAssetsPath = './lang', this.iconAssetsPath = './assets', this.localizeWithCountry = false, this.analytics = true, this.handleInitialization = (event)=>{
|
|
15019
15169
|
this.interfaceController.onComponentInitializing(event);
|
|
15020
15170
|
};
|
|
15021
15171
|
this.store = createCommerceRecommendationStore();
|
|
@@ -15083,6 +15233,13 @@ _ts_decorate$v([
|
|
|
15083
15233
|
}),
|
|
15084
15234
|
_ts_metadata$n("design:type", String)
|
|
15085
15235
|
], AtomicCommerceRecommendationInterface$1.prototype, "language", void 0);
|
|
15236
|
+
_ts_decorate$v([
|
|
15237
|
+
decorators_js.property({
|
|
15238
|
+
type: Boolean,
|
|
15239
|
+
attribute: 'localize-with-country',
|
|
15240
|
+
reflect: true
|
|
15241
|
+
})
|
|
15242
|
+
], AtomicCommerceRecommendationInterface$1.prototype, "localizeWithCountry", void 0);
|
|
15086
15243
|
_ts_decorate$v([
|
|
15087
15244
|
decorators_js.property({
|
|
15088
15245
|
type: Boolean,
|
|
@@ -15103,6 +15260,12 @@ _ts_decorate$v([
|
|
|
15103
15260
|
_ts_metadata$n("design:paramtypes", []),
|
|
15104
15261
|
_ts_metadata$n("design:returntype", void 0)
|
|
15105
15262
|
], AtomicCommerceRecommendationInterface$1.prototype, "updateIconAssetsPath", null);
|
|
15263
|
+
_ts_decorate$v([
|
|
15264
|
+
watch('localizeWithCountry'),
|
|
15265
|
+
_ts_metadata$n("design:type", Function),
|
|
15266
|
+
_ts_metadata$n("design:paramtypes", []),
|
|
15267
|
+
_ts_metadata$n("design:returntype", void 0)
|
|
15268
|
+
], AtomicCommerceRecommendationInterface$1.prototype, "toggleLocalizeWithCountry", null);
|
|
15106
15269
|
_ts_decorate$v([
|
|
15107
15270
|
watch('language'),
|
|
15108
15271
|
_ts_metadata$n("design:type", Function),
|