@coveo/atomic 3.49.0 → 3.51.0
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/custom-elements.json +2257 -369
- package/dist/atomic/_atomic.esm.js +1 -1
- package/dist/atomic/atomic.esm.js.map +1 -1
- package/dist/atomic/components/_index.d.ts +0 -10
- package/dist/atomic/components/_index.js +2 -8
- package/dist/atomic/components/atomic-insight-result-action.js +123 -6
- package/dist/atomic/components/atomic-insight-result-action.js.map +1 -1
- package/dist/atomic/components/atomic-insight-result-children-template.js +1 -2
- package/dist/atomic/components/atomic-insight-result-children-template.js.map +1 -1
- package/dist/atomic/components/atomic-insight-timeframe-facet.js +97 -7
- package/dist/atomic/components/atomic-insight-timeframe-facet.js.map +1 -1
- package/dist/atomic/components/atomic-stencil-facet-date-input.js +3 -3
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.js +4 -4
- package/dist/atomic/components/components/common/generated-answer/render-feedback-and-copy-buttons.js +4 -3
- package/dist/atomic/components/components/insight/atomic-insight-generated-answer/atomic-insight-generated-answer.js +444 -0
- package/dist/atomic/components/components/insight/atomic-insight-generated-answer/atomic-insight-generated-answer.tw.css.js +2 -0
- package/dist/atomic/components/components/insight/atomic-insight-result-attach-to-case-action/atomic-insight-result-attach-to-case-action.js +122 -0
- package/dist/atomic/components/components/insight/atomic-insight-result-children/atomic-insight-result-children.js +4 -4
- package/dist/atomic/components/components/insight/index.js +2 -0
- package/dist/atomic/components/components/insight/lazy-index.js +2 -0
- package/dist/atomic/components/components/ipx/atomic-ipx-button/atomic-ipx-button.js +1 -1
- package/dist/atomic/components/components/ipx/atomic-ipx-recs-list/atomic-ipx-recs-list.js +483 -0
- package/dist/atomic/components/components/ipx/atomic-ipx-refine-modal/atomic-ipx-refine-modal.js +202 -0
- package/dist/atomic/components/components/ipx/atomic-ipx-refine-toggle/atomic-ipx-refine-toggle.js +123 -0
- package/dist/atomic/components/components/ipx/index.js +3 -0
- package/dist/atomic/components/components/ipx/lazy-index.js +3 -0
- package/dist/atomic/components/components/recommendations/atomic-recs-result/atomic-recs-result.js +1 -0
- package/dist/atomic/components/components/search/atomic-generated-answer/atomic-generated-answer.js +7 -1
- package/dist/atomic/components/components/search/atomic-refine-modal/atomic-refine-modal.js +2 -1
- package/dist/atomic/components/components/search/atomic-search-box/atomic-search-box.js +4 -4
- package/dist/atomic/components/global/environment.js +1 -1
- package/dist/atomic/components/index.js.map +1 -1
- package/dist/atomic/components/props-utils.js +1402 -2
- package/dist/atomic/components/props-utils.js.map +1 -1
- package/dist/atomic/components/utils/custom-element-tags.js +7 -0
- package/dist/atomic/components/utils/tailwind.global.tw.css.js +4 -4
- package/dist/atomic/index.esm.js +1 -1
- package/dist/atomic/p-1df0744f.entry.js +9 -0
- package/dist/atomic/p-1df0744f.entry.js.map +1 -0
- package/dist/atomic/{p-4a32511f.js → p-2045a1b1.js} +2 -2
- package/dist/atomic/p-500bf5c4.entry.js +2 -0
- package/dist/atomic/{p-4117289b.entry.js.map → p-500bf5c4.entry.js.map} +1 -1
- package/dist/atomic/p-5226a938.js +3 -0
- package/dist/atomic/p-5226a938.js.map +1 -0
- package/dist/atomic/{p-b4cfedf1.js → p-720863c3.js} +2 -2
- package/dist/atomic/p-81336626.entry.js +2 -0
- package/dist/atomic/p-81336626.entry.js.map +1 -0
- package/dist/atomic/p-aad3b4ec.js +3 -0
- package/dist/atomic/p-aad3b4ec.js.map +1 -0
- package/dist/atomic/{p-0698ccf1.entry.js → p-b5af331b.entry.js} +2 -2
- package/dist/atomic/{p-677f9c40.js → p-b7209471.js} +2 -2
- package/dist/cjs/_index.cjs.js +2 -2
- package/dist/cjs/_loader.cjs.js +2 -2
- package/dist/cjs/atomic-insight-result-action.cjs.entry.js +22 -9
- package/dist/cjs/atomic-insight-result-action.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-insight-result-children-template.cjs.entry.js +6 -7
- package/dist/cjs/atomic-insight-result-children-template.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-insight-timeframe-facet.cjs.entry.js +106 -16
- package/dist/cjs/atomic-insight-timeframe-facet.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-stencil-facet-date-input.cjs.entry.js +5 -5
- package/dist/cjs/atomic.cjs.js +2 -2
- package/dist/cjs/{index-3532822e.js → index-122375df.js} +4 -58
- package/dist/cjs/index-122375df.js.map +1 -0
- package/dist/cjs/{initialization-utils-51a423fe.js → initialization-utils-c2821271.js} +2 -2
- package/dist/cjs/{initialization-utils-51a423fe.js.map → initialization-utils-c2821271.js.map} +1 -1
- package/dist/cjs/{utils-e845f262.js → props-utils-e4f29f1e.js} +54 -21
- package/dist/cjs/props-utils-e4f29f1e.js.map +1 -0
- package/dist/cjs/{stencil-button-f39da03e.js → stencil-button-bf22eea4.js} +2 -2
- package/dist/cjs/{stencil-button-f39da03e.js.map → stencil-button-bf22eea4.js.map} +1 -1
- package/dist/cjs/{stencil-result-template-decorators-1f099c15.js → stencil-result-template-decorators-96954751.js} +2 -2
- package/dist/cjs/{stencil-result-template-decorators-1f099c15.js.map → stencil-result-template-decorators-96954751.js.map} +1 -1
- package/dist/cjs/version.cjs.js +2 -2
- package/dist/esm/_index.js +3 -3
- package/dist/esm/_loader.js +3 -3
- package/dist/esm/atomic-insight-result-action.entry.js +20 -7
- package/dist/esm/atomic-insight-result-action.entry.js.map +1 -1
- package/dist/esm/atomic-insight-result-children-template.entry.js +2 -3
- package/dist/esm/atomic-insight-result-children-template.entry.js.map +1 -1
- package/dist/esm/atomic-insight-timeframe-facet.entry.js +100 -10
- package/dist/esm/atomic-insight-timeframe-facet.entry.js.map +1 -1
- package/dist/esm/atomic-stencil-facet-date-input.entry.js +5 -5
- package/dist/esm/atomic.js +3 -3
- package/dist/esm/{index-3eb0b28e.js → index-4d679e44.js} +5 -58
- package/dist/{cjs/index-3532822e.js.map → esm/index-4d679e44.js.map} +1 -1
- package/dist/esm/{initialization-utils-82d28c63.js → initialization-utils-9ff399ff.js} +2 -2
- package/dist/esm/{initialization-utils-82d28c63.js.map → initialization-utils-9ff399ff.js.map} +1 -1
- package/dist/esm/{utils-b5bab369.js → props-utils-76043c82.js} +54 -18
- package/dist/esm/props-utils-76043c82.js.map +1 -0
- package/dist/esm/{stencil-button-c25899df.js → stencil-button-28de709c.js} +2 -2
- package/dist/esm/{stencil-button-c25899df.js.map → stencil-button-28de709c.js.map} +1 -1
- package/dist/esm/{stencil-result-template-decorators-9cbe1e1c.js → stencil-result-template-decorators-4c2e5132.js} +2 -2
- package/dist/esm/{stencil-result-template-decorators-9cbe1e1c.js.map → stencil-result-template-decorators-4c2e5132.js.map} +1 -1
- package/dist/esm/version.js +2 -2
- package/dist/types/components/common/generated-answer/answerContent/answer-content.d.ts +49 -0
- package/dist/types/components/common/generated-answer/generated-answer-thread-item/generated-answer-thread-item.d.ts +49 -0
- package/dist/types/components/common/generated-answer/render-feedback-and-copy-buttons.d.ts +8 -2
- package/dist/types/components/common/item-list/table-layout.d.ts +1 -1
- package/dist/types/components/insight/atomic-insight-generated-answer/atomic-insight-generated-answer.d.ts +54 -35
- package/dist/types/components/insight/atomic-insight-generated-answer/atomic-insight-generated-answer.tw.css.d.ts +2 -0
- package/dist/types/components/insight/atomic-insight-result-attach-to-case-action/atomic-insight-result-attach-to-case-action.d.ts +25 -20
- package/dist/types/components/insight/index.d.ts +2 -0
- package/dist/types/components/ipx/atomic-ipx-button/atomic-ipx-button.d.ts +1 -1
- package/dist/types/components/ipx/atomic-ipx-recs-list/{atomic-recs-list/atomic-ipx-recs-list.d.ts → atomic-ipx-recs-list.d.ts} +43 -21
- package/dist/types/components/ipx/atomic-ipx-refine-modal/atomic-ipx-refine-modal.d.ts +62 -15
- package/dist/types/components/ipx/atomic-ipx-refine-toggle/atomic-ipx-refine-toggle.d.ts +26 -11
- package/dist/types/components/ipx/index.d.ts +3 -0
- package/dist/types/components/recommendations/atomic-recs-result/atomic-recs-result.d.ts +1 -0
- package/dist/types/components/search/atomic-refine-modal/atomic-refine-modal.d.ts +4 -3
- package/dist/types/components.d.ts +0 -249
- package/docs/atomic-docs.json +1 -26
- package/package.json +4 -4
- package/dist/atomic/components/arrow-top-rounded.js +0 -7
- package/dist/atomic/components/arrow-top-rounded.js.map +0 -1
- package/dist/atomic/components/atomic-insight-generated-answer.d.ts +0 -11
- package/dist/atomic/components/atomic-insight-generated-answer.js +0 -3264
- package/dist/atomic/components/atomic-insight-generated-answer.js.map +0 -1
- package/dist/atomic/components/atomic-insight-result-attach-to-case-action.d.ts +0 -11
- package/dist/atomic/components/atomic-insight-result-attach-to-case-action.js +0 -102
- package/dist/atomic/components/atomic-insight-result-attach-to-case-action.js.map +0 -1
- package/dist/atomic/components/atomic-ipx-recs-list.d.ts +0 -11
- package/dist/atomic/components/atomic-ipx-recs-list.js +0 -631
- package/dist/atomic/components/atomic-ipx-recs-list.js.map +0 -1
- package/dist/atomic/components/atomic-ipx-refine-modal.d.ts +0 -11
- package/dist/atomic/components/atomic-ipx-refine-modal.js +0 -8
- package/dist/atomic/components/atomic-ipx-refine-modal.js.map +0 -1
- package/dist/atomic/components/atomic-ipx-refine-modal2.js +0 -162
- package/dist/atomic/components/atomic-ipx-refine-modal2.js.map +0 -1
- package/dist/atomic/components/atomic-ipx-refine-toggle.d.ts +0 -11
- package/dist/atomic/components/atomic-ipx-refine-toggle.js +0 -121
- package/dist/atomic/components/atomic-ipx-refine-toggle.js.map +0 -1
- package/dist/atomic/components/attach.js +0 -115
- package/dist/atomic/components/attach.js.map +0 -1
- package/dist/atomic/components/components/common/layout/display-options.js +0 -28
- package/dist/atomic/components/popover-type.js +0 -12
- package/dist/atomic/components/popover-type.js.map +0 -1
- package/dist/atomic/components/stencil-heading.js +0 -169
- package/dist/atomic/components/stencil-heading.js.map +0 -1
- package/dist/atomic/components/stencil-iconButton.js +0 -16
- package/dist/atomic/components/stencil-iconButton.js.map +0 -1
- package/dist/atomic/components/store.js +0 -13
- package/dist/atomic/components/store.js.map +0 -1
- package/dist/atomic/components/utils.js +0 -1421
- package/dist/atomic/components/utils.js.map +0 -1
- package/dist/atomic/p-2c08a419.entry.js +0 -2
- package/dist/atomic/p-2c08a419.entry.js.map +0 -1
- package/dist/atomic/p-4117289b.entry.js +0 -2
- package/dist/atomic/p-52d14165.entry.js +0 -2
- package/dist/atomic/p-52d14165.entry.js.map +0 -1
- package/dist/atomic/p-578d761c.js +0 -2
- package/dist/atomic/p-578d761c.js.map +0 -1
- package/dist/atomic/p-64f83898.entry.js +0 -2
- package/dist/atomic/p-64f83898.entry.js.map +0 -1
- package/dist/atomic/p-70cc18a1.js +0 -2
- package/dist/atomic/p-70cc18a1.js.map +0 -1
- package/dist/atomic/p-9c5ec170.js +0 -2
- package/dist/atomic/p-9c5ec170.js.map +0 -1
- package/dist/atomic/p-9dfe5ab1.js +0 -2
- package/dist/atomic/p-9dfe5ab1.js.map +0 -1
- package/dist/atomic/p-a33748a9.js +0 -2
- package/dist/atomic/p-a33748a9.js.map +0 -1
- package/dist/atomic/p-b09433bb.js +0 -3
- package/dist/atomic/p-b09433bb.js.map +0 -1
- package/dist/atomic/p-c8452548.entry.js +0 -2
- package/dist/atomic/p-c8452548.entry.js.map +0 -1
- package/dist/atomic/p-c95ac794.entry.js +0 -2
- package/dist/atomic/p-c95ac794.entry.js.map +0 -1
- package/dist/atomic/p-d75a4630.js +0 -2
- package/dist/atomic/p-d75a4630.js.map +0 -1
- package/dist/atomic/p-d8230482.entry.js +0 -9
- package/dist/atomic/p-d8230482.entry.js.map +0 -1
- package/dist/atomic/p-e94ba0e1.entry.js +0 -2
- package/dist/atomic/p-e94ba0e1.entry.js.map +0 -1
- package/dist/atomic/p-ec1c5f46.js +0 -3
- package/dist/atomic/p-ec1c5f46.js.map +0 -1
- package/dist/atomic/p-f321aab0.js +0 -2
- package/dist/atomic/p-f321aab0.js.map +0 -1
- package/dist/cjs/arrow-top-rounded-885250ea.js +0 -10
- package/dist/cjs/arrow-top-rounded-885250ea.js.map +0 -1
- package/dist/cjs/atomic-insight-generated-answer.cjs.entry.js +0 -3238
- package/dist/cjs/atomic-insight-generated-answer.cjs.entry.js.map +0 -1
- package/dist/cjs/atomic-insight-result-attach-to-case-action.cjs.entry.js +0 -90
- package/dist/cjs/atomic-insight-result-attach-to-case-action.cjs.entry.js.map +0 -1
- package/dist/cjs/atomic-ipx-recs-list.cjs.entry.js +0 -600
- package/dist/cjs/atomic-ipx-recs-list.cjs.entry.js.map +0 -1
- package/dist/cjs/atomic-ipx-refine-modal.cjs.entry.js +0 -143
- package/dist/cjs/atomic-ipx-refine-modal.cjs.entry.js.map +0 -1
- package/dist/cjs/atomic-ipx-refine-toggle.cjs.entry.js +0 -99
- package/dist/cjs/atomic-ipx-refine-toggle.cjs.entry.js.map +0 -1
- package/dist/cjs/attach-19283bec.js +0 -10
- package/dist/cjs/attach-19283bec.js.map +0 -1
- package/dist/cjs/popover-type-22f285e1.js +0 -16
- package/dist/cjs/popover-type-22f285e1.js.map +0 -1
- package/dist/cjs/props-utils-bc5feb04.js +0 -59
- package/dist/cjs/props-utils-bc5feb04.js.map +0 -1
- package/dist/cjs/stencil-heading-ecec9ab3.js +0 -174
- package/dist/cjs/stencil-heading-ecec9ab3.js.map +0 -1
- package/dist/cjs/stencil-iconButton-f8b9fda0.js +0 -18
- package/dist/cjs/stencil-iconButton-f8b9fda0.js.map +0 -1
- package/dist/cjs/store-70fff5e6.js +0 -16
- package/dist/cjs/store-70fff5e6.js.map +0 -1
- package/dist/cjs/utils-e845f262.js.map +0 -1
- package/dist/esm/arrow-top-rounded-745b84a6.js +0 -7
- package/dist/esm/arrow-top-rounded-745b84a6.js.map +0 -1
- package/dist/esm/atomic-insight-generated-answer.entry.js +0 -3234
- package/dist/esm/atomic-insight-generated-answer.entry.js.map +0 -1
- package/dist/esm/atomic-insight-result-attach-to-case-action.entry.js +0 -86
- package/dist/esm/atomic-insight-result-attach-to-case-action.entry.js.map +0 -1
- package/dist/esm/atomic-ipx-recs-list.entry.js +0 -596
- package/dist/esm/atomic-ipx-recs-list.entry.js.map +0 -1
- package/dist/esm/atomic-ipx-refine-modal.entry.js +0 -139
- package/dist/esm/atomic-ipx-refine-modal.entry.js.map +0 -1
- package/dist/esm/atomic-ipx-refine-toggle.entry.js +0 -95
- package/dist/esm/atomic-ipx-refine-toggle.entry.js.map +0 -1
- package/dist/esm/attach-81bb8872.js +0 -8
- package/dist/esm/attach-81bb8872.js.map +0 -1
- package/dist/esm/index-3eb0b28e.js.map +0 -1
- package/dist/esm/popover-type-c85677ef.js +0 -12
- package/dist/esm/popover-type-c85677ef.js.map +0 -1
- package/dist/esm/props-utils-d343133b.js +0 -57
- package/dist/esm/props-utils-d343133b.js.map +0 -1
- package/dist/esm/stencil-heading-98a5f23f.js +0 -169
- package/dist/esm/stencil-heading-98a5f23f.js.map +0 -1
- package/dist/esm/stencil-iconButton-ed5804d3.js +0 -16
- package/dist/esm/stencil-iconButton-ed5804d3.js.map +0 -1
- package/dist/esm/store-50d170c8.js +0 -13
- package/dist/esm/store-50d170c8.js.map +0 -1
- package/dist/esm/utils-b5bab369.js.map +0 -1
- /package/dist/atomic/{p-4a32511f.js.map → p-2045a1b1.js.map} +0 -0
- /package/dist/atomic/{p-b4cfedf1.js.map → p-720863c3.js.map} +0 -0
- /package/dist/atomic/{p-0698ccf1.entry.js.map → p-b5af331b.entry.js.map} +0 -0
- /package/dist/atomic/{p-677f9c40.js.map → p-b7209471.js.map} +0 -0
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var AtomicIpxRecsList_1;
|
|
8
|
+
import { NumberValue, Schema, StringValue } from '@coveo/bueno';
|
|
9
|
+
import { loadIPXActionsHistoryActions, } from '@coveo/headless';
|
|
10
|
+
import { buildRecommendationList, buildInteractiveResult as buildRecsInteractiveResult, loadConfigurationActions, } from '@coveo/headless/recommendation';
|
|
11
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
12
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
13
|
+
import { keyed } from 'lit/directives/keyed.js';
|
|
14
|
+
import { map } from 'lit/directives/map.js';
|
|
15
|
+
import { when } from 'lit/directives/when.js';
|
|
16
|
+
import { renderItemPlaceholders } from "../../common/atomic-result-placeholder/item-placeholders";
|
|
17
|
+
import { renderCarousel } from "../../common/carousel";
|
|
18
|
+
import { renderHeading } from "../../common/heading";
|
|
19
|
+
import { createAppLoadedListener } from "../../common/interface/store";
|
|
20
|
+
import { renderDisplayWrapper } from "../../common/item-list/display-wrapper";
|
|
21
|
+
import { renderGridLayout } from "../../common/item-list/grid-layout";
|
|
22
|
+
import { ItemListCommon, } from "../../common/item-list/item-list-common";
|
|
23
|
+
import { ResultTemplateProvider } from "../../common/item-list/result-template-provider";
|
|
24
|
+
import { getItemListDisplayClasses, } from "../../common/layout/item-layout-utils";
|
|
25
|
+
import { ValidatePropsController } from "../../common/validate-props-controller/validate-props-controller";
|
|
26
|
+
import { bindStateToController } from "../../../decorators/bind-state";
|
|
27
|
+
import { bindingGuard } from "../../../decorators/binding-guard";
|
|
28
|
+
import { bindings } from "../../../decorators/bindings";
|
|
29
|
+
import { errorGuard } from "../../../decorators/error-guard";
|
|
30
|
+
import { withTailwindStyles } from "../../../decorators/with-tailwind-styles";
|
|
31
|
+
import { ChildrenUpdateCompleteMixin } from "../../../mixins/children-update-complete-mixin";
|
|
32
|
+
import { FocusTargetController } from "../../../utils/accessibility-utils";
|
|
33
|
+
import { randomID } from "../../../utils/utils";
|
|
34
|
+
import placeholderStyles from '../../common/item-list/styles/placeholders.tw.css';
|
|
35
|
+
import "../../recommendations/atomic-recs-result/atomic-recs-result";
|
|
36
|
+
/**
|
|
37
|
+
* The `atomic-ipx-recs-list` component displays recommendations by applying one or more result templates.
|
|
38
|
+
*
|
|
39
|
+
* @part result-list - The element containing the list of results.
|
|
40
|
+
* @part result-list-grid-clickable-container - The parent of the result and the clickable link encompassing it.
|
|
41
|
+
* @part outline - The outline element around a result in the grid layout.
|
|
42
|
+
* @part label - The label of the result list.
|
|
43
|
+
* @part previous-button - The previous button.
|
|
44
|
+
* @part next-button - The next button.
|
|
45
|
+
* @part previous-icon - The previous button icon.
|
|
46
|
+
* @part next-icon - The next button icon.
|
|
47
|
+
* @part carousel - The carousel container.
|
|
48
|
+
* @part indicators - The list of indicators.
|
|
49
|
+
* @part indicator - A single indicator.
|
|
50
|
+
* @part active-indicator - The active indicator.
|
|
51
|
+
*
|
|
52
|
+
* @slot default - The default slot where the result templates are defined.
|
|
53
|
+
*
|
|
54
|
+
* @cssprop --atomic-recs-number-of-columns - The number of columns in the grid.
|
|
55
|
+
*/
|
|
56
|
+
let AtomicIpxRecsList = AtomicIpxRecsList_1 = class AtomicIpxRecsList extends ChildrenUpdateCompleteMixin(LitElement) {
|
|
57
|
+
constructor() {
|
|
58
|
+
super();
|
|
59
|
+
this.loadingFlag = randomID('firstRecommendationLoaded-');
|
|
60
|
+
this.currentPage = 0;
|
|
61
|
+
this.isAppLoaded = false;
|
|
62
|
+
this.isEveryResultReady = false;
|
|
63
|
+
this.resultTemplateRegistered = false;
|
|
64
|
+
this.templateHasError = false;
|
|
65
|
+
/**
|
|
66
|
+
* The Recommendation identifier used by the Coveo platform to retrieve recommended documents.
|
|
67
|
+
* Make sure to set a different value for each atomic-ipx-recs-list in your page.
|
|
68
|
+
*/
|
|
69
|
+
this.recommendation = 'Recommendation';
|
|
70
|
+
/**
|
|
71
|
+
* The layout to apply when displaying results themselves. This does not affect the display of the surrounding list itself.
|
|
72
|
+
* To modify the number of recommendations per column, modify the --atomic-recs-number-of-columns CSS variable.
|
|
73
|
+
*/
|
|
74
|
+
this.display = 'list';
|
|
75
|
+
/**
|
|
76
|
+
* The spacing of various elements in the result list, including the gap between results, the gap between parts of a result, and the font sizes of different parts in a result.
|
|
77
|
+
*/
|
|
78
|
+
this.density = 'normal';
|
|
79
|
+
/**
|
|
80
|
+
* The expected size of the image displayed in the results.
|
|
81
|
+
*/
|
|
82
|
+
this.imageSize = 'small';
|
|
83
|
+
/**
|
|
84
|
+
* The total number of recommendations to display.
|
|
85
|
+
* This does not modify the number of recommendations per column. To do so, modify the --atomic-recs-number-of-columns CSS variable.
|
|
86
|
+
*/
|
|
87
|
+
this.numberOfRecommendations = 10;
|
|
88
|
+
/**
|
|
89
|
+
* The [heading level](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements) to use for the heading label, from 1 to 6.
|
|
90
|
+
* When set to 0, a `div` will be used instead of a Heading Element.
|
|
91
|
+
*/
|
|
92
|
+
this.headingLevel = 0;
|
|
93
|
+
new ValidatePropsController(this, () => ({
|
|
94
|
+
density: this.density,
|
|
95
|
+
display: this.display,
|
|
96
|
+
imageSize: this.imageSize,
|
|
97
|
+
}), AtomicIpxRecsList_1.propsSchema, false);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Sets a rendering function to bypass the standard HTML template mechanism for rendering results.
|
|
101
|
+
* You can use this function while working with web frameworks that don't use plain HTML syntax such as React, Angular, or Vue.
|
|
102
|
+
*
|
|
103
|
+
* Do not use this method if you integrate Atomic in a plain HTML deployment.
|
|
104
|
+
*
|
|
105
|
+
* @param resultRenderingFunction
|
|
106
|
+
*/
|
|
107
|
+
async setRenderFunction(resultRenderingFunction) {
|
|
108
|
+
this.itemRenderingFunction = resultRenderingFunction;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Moves to the previous page, when the carousel is activated.
|
|
112
|
+
*/
|
|
113
|
+
async previousPage() {
|
|
114
|
+
this.currentPage =
|
|
115
|
+
this.currentPage - 1 < 0 ? this.numberOfPages - 1 : this.currentPage - 1;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Moves to the next page, when the carousel is activated.
|
|
119
|
+
*/
|
|
120
|
+
async nextPage() {
|
|
121
|
+
this.currentPage = (this.currentPage + 1) % this.numberOfPages;
|
|
122
|
+
}
|
|
123
|
+
initialize() {
|
|
124
|
+
this.validateNumberOfRecommendationsPerPage();
|
|
125
|
+
this.validateRecommendationIdentifier();
|
|
126
|
+
this.updateOriginLevel2();
|
|
127
|
+
this.recommendationList = buildRecommendationList(this.bindings.engine, {
|
|
128
|
+
options: {
|
|
129
|
+
id: this.recommendation,
|
|
130
|
+
numberOfRecommendations: this.numberOfRecommendations,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
this.itemTemplateProvider = new ResultTemplateProvider({
|
|
134
|
+
includeDefaultTemplate: true,
|
|
135
|
+
templateElements: Array.from(this.querySelectorAll('atomic-recs-result-template')),
|
|
136
|
+
getResultTemplateRegistered: () => this.resultTemplateRegistered,
|
|
137
|
+
getTemplateHasError: () => this.templateHasError,
|
|
138
|
+
setResultTemplateRegistered: (value) => {
|
|
139
|
+
this.resultTemplateRegistered = value;
|
|
140
|
+
},
|
|
141
|
+
setTemplateHasError: (value) => {
|
|
142
|
+
this.templateHasError = value;
|
|
143
|
+
},
|
|
144
|
+
bindings: this.bindings,
|
|
145
|
+
});
|
|
146
|
+
this.itemListCommon = new ItemListCommon({
|
|
147
|
+
engineSubscribe: this.bindings.engine.subscribe,
|
|
148
|
+
getCurrentNumberOfItems: () => this.recommendationListState.recommendations.length,
|
|
149
|
+
getIsLoading: () => this.recommendationListState.isLoading,
|
|
150
|
+
host: this,
|
|
151
|
+
loadingFlag: this.loadingFlag,
|
|
152
|
+
nextNewItemTarget: this.focusTarget,
|
|
153
|
+
store: this.bindings.store,
|
|
154
|
+
});
|
|
155
|
+
this.actionsHistoryActions = loadIPXActionsHistoryActions(this.bindings.engine);
|
|
156
|
+
createAppLoadedListener(this.bindings.store, (isAppLoaded) => {
|
|
157
|
+
this.isAppLoaded = isAppLoaded;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
async willUpdate(changedProperties) {
|
|
161
|
+
super.willUpdate(changedProperties);
|
|
162
|
+
if (changedProperties.has('numberOfRecommendationsPerPage')) {
|
|
163
|
+
this.currentPage = 0;
|
|
164
|
+
}
|
|
165
|
+
if (changedProperties.has('recommendationListState')) {
|
|
166
|
+
const oldState = changedProperties.get('recommendationListState');
|
|
167
|
+
if (this.recommendationListState.searchResponseId !== '') {
|
|
168
|
+
this.bindings.store.unsetLoadingFlag(this.loadingFlag);
|
|
169
|
+
}
|
|
170
|
+
if (!oldState?.isLoading && this.recommendationListState.isLoading) {
|
|
171
|
+
this.isEveryResultReady = false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
await this.updateResultsReadyState();
|
|
175
|
+
}
|
|
176
|
+
async updateResultsReadyState() {
|
|
177
|
+
if (this.isAppLoaded &&
|
|
178
|
+
!this.isEveryResultReady &&
|
|
179
|
+
this.recommendationListState?.searchResponseId !== '' &&
|
|
180
|
+
this.recommendationListState?.recommendations?.length > 0) {
|
|
181
|
+
await this.getUpdateComplete();
|
|
182
|
+
this.isEveryResultReady = true;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
get focusTarget() {
|
|
186
|
+
if (!this.nextNewResultTarget) {
|
|
187
|
+
this.nextNewResultTarget = new FocusTargetController(this, this.bindings);
|
|
188
|
+
}
|
|
189
|
+
return this.nextNewResultTarget;
|
|
190
|
+
}
|
|
191
|
+
get recommendationListStateWithAugment() {
|
|
192
|
+
return {
|
|
193
|
+
...this.recommendationListState,
|
|
194
|
+
firstRequestExecuted: this.recommendationListState.searchResponseId !== '',
|
|
195
|
+
hasError: this.recommendationListState.error !== null,
|
|
196
|
+
hasItems: this.recommendationListState.recommendations.length !== 0,
|
|
197
|
+
results: this.subsetRecommendations,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
validateNumberOfRecommendationsPerPage() {
|
|
201
|
+
if (this.numberOfRecommendationsPerPage === undefined) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const msg = new NumberValue({
|
|
205
|
+
min: 1,
|
|
206
|
+
max: this.numberOfRecommendations - 1,
|
|
207
|
+
}).validate(this.numberOfRecommendationsPerPage);
|
|
208
|
+
if (msg) {
|
|
209
|
+
this.error = new Error(`The "numberOfRecommendationsPerPage" is invalid: ${msg}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
validateRecommendationIdentifier() {
|
|
213
|
+
const recListWithRecommendation = document.querySelectorAll(`atomic-ipx-recs-list[recommendation="${this.recommendation}"]`);
|
|
214
|
+
if (recListWithRecommendation.length > 1) {
|
|
215
|
+
this.bindings.engine.logger.warn(`There are multiple atomic-ipx-recs-list in this page with the same recommendation property "${this.recommendation}". Make sure to set a different recommendation property for each.`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
updateOriginLevel2() {
|
|
219
|
+
if (this.label) {
|
|
220
|
+
const action = loadConfigurationActions(this.bindings.engine).setOriginLevel2({
|
|
221
|
+
originLevel2: this.label,
|
|
222
|
+
});
|
|
223
|
+
this.bindings.engine.dispatch(action);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
get currentIndex() {
|
|
227
|
+
if (!this.recommendationListState.recommendations.length) {
|
|
228
|
+
return 0;
|
|
229
|
+
}
|
|
230
|
+
return Math.abs((this.currentPage * this.numberOfRecommendationsPerPage) %
|
|
231
|
+
this.recommendationListState.recommendations.length);
|
|
232
|
+
}
|
|
233
|
+
get subsetRecommendations() {
|
|
234
|
+
if (!this.numberOfRecommendationsPerPage) {
|
|
235
|
+
return this.recommendationListState.recommendations;
|
|
236
|
+
}
|
|
237
|
+
return this.recommendationListState.recommendations.slice(this.currentIndex, this.currentIndex + this.numberOfRecommendationsPerPage);
|
|
238
|
+
}
|
|
239
|
+
get numberOfPages() {
|
|
240
|
+
if (!this.numberOfRecommendationsPerPage) {
|
|
241
|
+
return 1;
|
|
242
|
+
}
|
|
243
|
+
return Math.ceil(this.recommendationListState.recommendations.length /
|
|
244
|
+
this.numberOfRecommendationsPerPage);
|
|
245
|
+
}
|
|
246
|
+
get hasPagination() {
|
|
247
|
+
return !!this.numberOfRecommendationsPerPage && this.numberOfPages > 1;
|
|
248
|
+
}
|
|
249
|
+
get shouldRenderPagination() {
|
|
250
|
+
return (this.hasPagination && this.recommendationListStateWithAugment.hasItems);
|
|
251
|
+
}
|
|
252
|
+
get hasNoResults() {
|
|
253
|
+
return (!this.recommendationListState.isLoading &&
|
|
254
|
+
this.recommendationListStateWithAugment.results.length === 0);
|
|
255
|
+
}
|
|
256
|
+
onSelect(recommendation, originalSelect) {
|
|
257
|
+
if (recommendation.raw.permanentid && this.actionsHistoryActions) {
|
|
258
|
+
const action = this.actionsHistoryActions.addPageViewEntryInActionsHistory(recommendation.raw.permanentid);
|
|
259
|
+
this.bindings.engine.dispatch(action);
|
|
260
|
+
}
|
|
261
|
+
originalSelect();
|
|
262
|
+
}
|
|
263
|
+
getPropsForAtomicRecsResult(recommendation) {
|
|
264
|
+
const interactiveResult = buildRecsInteractiveResult(this.bindings.engine, {
|
|
265
|
+
options: { result: recommendation },
|
|
266
|
+
});
|
|
267
|
+
const originalSelect = interactiveResult.select;
|
|
268
|
+
interactiveResult.select = () => {
|
|
269
|
+
this.onSelect(recommendation, originalSelect);
|
|
270
|
+
};
|
|
271
|
+
const linkContent = this.itemTemplateProvider.getLinkTemplateContent(recommendation);
|
|
272
|
+
return {
|
|
273
|
+
interactiveResult,
|
|
274
|
+
result: recommendation,
|
|
275
|
+
renderingFunction: this.itemRenderingFunction,
|
|
276
|
+
loadingFlag: this.loadingFlag,
|
|
277
|
+
key: this.itemListCommon.getResultId(recommendation.uniqueId, this.recommendationListState.searchResponseId, this.density, this.imageSize),
|
|
278
|
+
content: this.itemTemplateProvider.getTemplateContent(recommendation),
|
|
279
|
+
linkContent,
|
|
280
|
+
stopPropagation: !!linkContent,
|
|
281
|
+
store: this.bindings.store,
|
|
282
|
+
density: this.density,
|
|
283
|
+
display: this.display,
|
|
284
|
+
imageSize: this.imageSize,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
computeListDisplayClasses() {
|
|
288
|
+
const displayPlaceholders = !(this.isAppLoaded && this.isEveryResultReady);
|
|
289
|
+
return getItemListDisplayClasses('grid', this.density, this.imageSize, this.recommendationListState.isLoading, displayPlaceholders);
|
|
290
|
+
}
|
|
291
|
+
renderHeading() {
|
|
292
|
+
if (!this.label) {
|
|
293
|
+
return nothing;
|
|
294
|
+
}
|
|
295
|
+
if (this.recommendationListStateWithAugment.hasError) {
|
|
296
|
+
return nothing;
|
|
297
|
+
}
|
|
298
|
+
if (!this.isEveryResultReady && this.isAppLoaded) {
|
|
299
|
+
return html `
|
|
300
|
+
<div
|
|
301
|
+
aria-hidden="true"
|
|
302
|
+
class="bg-neutral my-2 h-8 w-60 animate-pulse rounded"
|
|
303
|
+
></div>
|
|
304
|
+
`;
|
|
305
|
+
}
|
|
306
|
+
if (this.recommendationListStateWithAugment.firstRequestExecuted &&
|
|
307
|
+
!this.recommendationListStateWithAugment.hasItems) {
|
|
308
|
+
return nothing;
|
|
309
|
+
}
|
|
310
|
+
return html `${renderHeading({
|
|
311
|
+
props: {
|
|
312
|
+
level: this.headingLevel,
|
|
313
|
+
part: 'label',
|
|
314
|
+
class: 'm-0 mb-2',
|
|
315
|
+
},
|
|
316
|
+
})(html `${this.bindings.i18n.t(this.label)}`)}`;
|
|
317
|
+
}
|
|
318
|
+
renderAsGrid() {
|
|
319
|
+
return html `${map(this.subsetRecommendations, (recommendation, index) => {
|
|
320
|
+
const props = this.getPropsForAtomicRecsResult(recommendation);
|
|
321
|
+
return renderGridLayout({
|
|
322
|
+
props: {
|
|
323
|
+
selectorForItem: 'atomic-recs-result',
|
|
324
|
+
item: {
|
|
325
|
+
...recommendation,
|
|
326
|
+
clickUri: recommendation.clickUri,
|
|
327
|
+
title: recommendation.title ?? '',
|
|
328
|
+
},
|
|
329
|
+
...props.interactiveResult,
|
|
330
|
+
setRef: (element) => {
|
|
331
|
+
element &&
|
|
332
|
+
this.itemListCommon.setNewResultRef(element, index);
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
})(html `${keyed(props.key, html `<atomic-recs-result
|
|
336
|
+
.content=${props.content}
|
|
337
|
+
.density=${props.density}
|
|
338
|
+
.display=${props.display}
|
|
339
|
+
.imageSize=${props.imageSize}
|
|
340
|
+
.linkContent=${props.linkContent}
|
|
341
|
+
.loadingFlag=${props.loadingFlag}
|
|
342
|
+
.interactiveResult=${props.interactiveResult}
|
|
343
|
+
.result=${props.result}
|
|
344
|
+
.renderingFunction=${props.renderingFunction}
|
|
345
|
+
.store=${props.store}
|
|
346
|
+
></atomic-recs-result>`)}`);
|
|
347
|
+
})}`;
|
|
348
|
+
}
|
|
349
|
+
renderRecommendationList() {
|
|
350
|
+
this.itemListCommon.updateBreakpoints();
|
|
351
|
+
const listClasses = this.computeListDisplayClasses();
|
|
352
|
+
if (!this.resultTemplateRegistered || this.error) {
|
|
353
|
+
return nothing;
|
|
354
|
+
}
|
|
355
|
+
const resultClasses = [listClasses, !this.isEveryResultReady && 'hidden']
|
|
356
|
+
.filter(Boolean)
|
|
357
|
+
.join(' ');
|
|
358
|
+
return html `
|
|
359
|
+
${when(this.isAppLoaded, () => renderDisplayWrapper({
|
|
360
|
+
props: { listClasses: resultClasses, display: 'grid' },
|
|
361
|
+
})(html `${this.renderAsGrid()}`))}
|
|
362
|
+
${when(!this.isEveryResultReady, () => renderDisplayWrapper({
|
|
363
|
+
props: { listClasses, display: 'grid' },
|
|
364
|
+
})(renderItemPlaceholders({
|
|
365
|
+
props: {
|
|
366
|
+
density: this.density,
|
|
367
|
+
display: this.display,
|
|
368
|
+
imageSize: this.imageSize,
|
|
369
|
+
numberOfPlaceholders: this.numberOfRecommendationsPerPage ??
|
|
370
|
+
this.numberOfRecommendations,
|
|
371
|
+
},
|
|
372
|
+
})))}
|
|
373
|
+
`;
|
|
374
|
+
}
|
|
375
|
+
get shouldRender() {
|
|
376
|
+
if (!this.resultTemplateRegistered || this.error) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
if (this.hasNoResults) {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
render() {
|
|
385
|
+
if (!this.shouldRender) {
|
|
386
|
+
if (this.hasNoResults) {
|
|
387
|
+
this.bindings.store.unsetLoadingFlag(this.loadingFlag);
|
|
388
|
+
}
|
|
389
|
+
return nothing;
|
|
390
|
+
}
|
|
391
|
+
return html `${when(this.templateHasError, () => html `<slot></slot>`, () => html `${this.renderHeading()}
|
|
392
|
+
${when(this.shouldRenderPagination, () => renderCarousel({
|
|
393
|
+
props: {
|
|
394
|
+
bindings: this.bindings,
|
|
395
|
+
previousPage: () => this.previousPage(),
|
|
396
|
+
nextPage: () => this.nextPage(),
|
|
397
|
+
numberOfPages: this.numberOfPages,
|
|
398
|
+
currentPage: this.currentPage,
|
|
399
|
+
ariaLabel: this.bindings.i18n.t(this.label ?? 'recommendations'),
|
|
400
|
+
},
|
|
401
|
+
})(html `<div class="px-3">${this.renderRecommendationList()}</div>`), () => this.renderRecommendationList())}`)}`;
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
AtomicIpxRecsList.styles = [
|
|
405
|
+
placeholderStyles,
|
|
406
|
+
css`/*! tailwindcss v4.1.13 | MIT License | https://tailwindcss.com */@layer properties;.list-wrapper.placeholder{.result-component,table.list-root{display:none}}.list-wrapper:not(.placeholder){atomic-result-placeholder,atomic-result-table-placeholder{display:none}}.list-root.loading{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}:host{display:block;[part~=outline][part~=result-list-grid-clickable-container]{border:1px solid transparent;border-radius:1rem;padding:1rem;position:relative;transition:all .12s ease-out;&:hover{border-color:var(--atomic-neutral);border-style:var(--tw-border-style);border-width:1px;box-shadow:0 10px 25px var(--atomic-neutral);cursor:pointer}}[part=result-list-grid-clickable]:focus-visible{border-color:var(--atomic-primary);border-radius:2px;border-style:var(--tw-border-style);border-width:2px;color:var(--atomic-primary);cursor:pointer;display:inline-block;position:absolute;text-align:center;text-decoration:underline}[part=result-list-grid-clickable]:not(:focus){clip:rect(1px,1px,1px,1px);overflow:hidden;padding:0;position:absolute}.list-wrapper{word-break:break-word}.list-root.display-grid{display:grid;justify-content:space-evenly;.result-component{box-sizing:border-box;height:100%}}.list-root{grid-column-gap:.5rem;grid-row-gap:.5rem;grid-template-columns:repeat(var(--atomic-recs-number-of-columns,1),minmax(0,1fr));[part~=outline]{border-color:var(--atomic-neutral);border-radius:1rem;border-style:var(--tw-border-style);border-width:1px;padding:1rem}atomic-result-placeholder{border-color:transparent}}[part=label]{font-family:var(--atomic-font-family);font-size:var(--atomic-text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height,1.33333));--tw-font-weight:var(--atomic-font-bold);font-weight:var(--atomic-font-bold)}atomic-result:not(.hydrated){visibility:hidden}}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@keyframes pulse{50%{opacity:.5}}@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-border-style:solid;--tw-font-weight:initial}}}`,
|
|
407
|
+
];
|
|
408
|
+
AtomicIpxRecsList.propsSchema = new Schema({
|
|
409
|
+
density: new StringValue({
|
|
410
|
+
constrainTo: ['normal', 'comfortable', 'compact'],
|
|
411
|
+
}),
|
|
412
|
+
display: new StringValue({ constrainTo: ['grid', 'list'] }),
|
|
413
|
+
imageSize: new StringValue({
|
|
414
|
+
constrainTo: ['small', 'large', 'icon', 'none'],
|
|
415
|
+
}),
|
|
416
|
+
});
|
|
417
|
+
__decorate([
|
|
418
|
+
state()
|
|
419
|
+
], AtomicIpxRecsList.prototype, "bindings", void 0);
|
|
420
|
+
__decorate([
|
|
421
|
+
state()
|
|
422
|
+
], AtomicIpxRecsList.prototype, "error", void 0);
|
|
423
|
+
__decorate([
|
|
424
|
+
state()
|
|
425
|
+
], AtomicIpxRecsList.prototype, "currentPage", void 0);
|
|
426
|
+
__decorate([
|
|
427
|
+
state()
|
|
428
|
+
], AtomicIpxRecsList.prototype, "isAppLoaded", void 0);
|
|
429
|
+
__decorate([
|
|
430
|
+
state()
|
|
431
|
+
], AtomicIpxRecsList.prototype, "isEveryResultReady", void 0);
|
|
432
|
+
__decorate([
|
|
433
|
+
state()
|
|
434
|
+
], AtomicIpxRecsList.prototype, "resultTemplateRegistered", void 0);
|
|
435
|
+
__decorate([
|
|
436
|
+
state()
|
|
437
|
+
], AtomicIpxRecsList.prototype, "templateHasError", void 0);
|
|
438
|
+
__decorate([
|
|
439
|
+
bindStateToController('recommendationList'),
|
|
440
|
+
state()
|
|
441
|
+
], AtomicIpxRecsList.prototype, "recommendationListState", void 0);
|
|
442
|
+
__decorate([
|
|
443
|
+
property({ reflect: true, type: String })
|
|
444
|
+
], AtomicIpxRecsList.prototype, "recommendation", void 0);
|
|
445
|
+
__decorate([
|
|
446
|
+
property({ reflect: true, type: String })
|
|
447
|
+
], AtomicIpxRecsList.prototype, "display", void 0);
|
|
448
|
+
__decorate([
|
|
449
|
+
property({ reflect: true, type: String })
|
|
450
|
+
], AtomicIpxRecsList.prototype, "density", void 0);
|
|
451
|
+
__decorate([
|
|
452
|
+
property({ reflect: true, attribute: 'image-size', type: String })
|
|
453
|
+
], AtomicIpxRecsList.prototype, "imageSize", void 0);
|
|
454
|
+
__decorate([
|
|
455
|
+
property({
|
|
456
|
+
reflect: true,
|
|
457
|
+
attribute: 'number-of-recommendations',
|
|
458
|
+
type: Number,
|
|
459
|
+
})
|
|
460
|
+
], AtomicIpxRecsList.prototype, "numberOfRecommendations", void 0);
|
|
461
|
+
__decorate([
|
|
462
|
+
property({
|
|
463
|
+
reflect: true,
|
|
464
|
+
attribute: 'number-of-recommendations-per-page',
|
|
465
|
+
type: Number,
|
|
466
|
+
})
|
|
467
|
+
], AtomicIpxRecsList.prototype, "numberOfRecommendationsPerPage", void 0);
|
|
468
|
+
__decorate([
|
|
469
|
+
property({ reflect: true, type: String })
|
|
470
|
+
], AtomicIpxRecsList.prototype, "label", void 0);
|
|
471
|
+
__decorate([
|
|
472
|
+
property({ reflect: true, attribute: 'heading-level', type: Number })
|
|
473
|
+
], AtomicIpxRecsList.prototype, "headingLevel", void 0);
|
|
474
|
+
__decorate([
|
|
475
|
+
bindingGuard(),
|
|
476
|
+
errorGuard()
|
|
477
|
+
], AtomicIpxRecsList.prototype, "render", null);
|
|
478
|
+
AtomicIpxRecsList = AtomicIpxRecsList_1 = __decorate([
|
|
479
|
+
customElement('atomic-ipx-recs-list'),
|
|
480
|
+
bindings(),
|
|
481
|
+
withTailwindStyles
|
|
482
|
+
], AtomicIpxRecsList);
|
|
483
|
+
export { AtomicIpxRecsList };
|
package/dist/atomic/components/components/ipx/atomic-ipx-refine-modal/atomic-ipx-refine-modal.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { buildBreadcrumbManager, buildQuerySummary, } from '@coveo/headless';
|
|
8
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
9
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
10
|
+
import { collapseFacetsAfter, } from "../../common/facets/facet-common";
|
|
11
|
+
import { popoverClass } from "../../common/facets/popover/popover-type";
|
|
12
|
+
import { isRefineModalFacet } from "../../common/interface/store";
|
|
13
|
+
import { renderRefineModalBody } from "../../common/refine-modal/body";
|
|
14
|
+
import { renderRefineModalFiltersClearButton, renderRefineModalFiltersSection, } from "../../common/refine-modal/filters";
|
|
15
|
+
import { renderRefineModal } from "../../common/refine-modal/modal";
|
|
16
|
+
import { booleanConverter } from "../../../converters/boolean-converter";
|
|
17
|
+
import { bindStateToController } from "../../../decorators/bind-state";
|
|
18
|
+
import { bindingGuard } from "../../../decorators/binding-guard";
|
|
19
|
+
import { bindings } from "../../../decorators/bindings";
|
|
20
|
+
import { errorGuard } from "../../../decorators/error-guard";
|
|
21
|
+
import { watch } from "../../../decorators/watch";
|
|
22
|
+
import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js";
|
|
23
|
+
import { sortByDocumentPosition } from "../../../utils/utils";
|
|
24
|
+
/**
|
|
25
|
+
* The `atomic-ipx-refine-modal` component is automatically created as a child of the `atomic-search-interface` when the `atomic-ipx-refine-toggle` is initialized.
|
|
26
|
+
*
|
|
27
|
+
* When the modal is opened, the class `atomic-modal-opened` is added to the interface element and the body.
|
|
28
|
+
*
|
|
29
|
+
* @slot facets - Slot for facet elements to be displayed in the modal. This slot is managed internally by the component and should not be used directly.
|
|
30
|
+
*
|
|
31
|
+
* @part title - The title of the modal.
|
|
32
|
+
* @part close-button - The button in the header that closes the modal.
|
|
33
|
+
* @part close-icon - The icon of the close button.
|
|
34
|
+
* @part content - The wrapper around the content inside the body of the modal.
|
|
35
|
+
* @part section-title - The title for each section.
|
|
36
|
+
* @part section-filters-title - The title for the filters section.
|
|
37
|
+
* @part filter-section - The section containing facets and the "filters" title.
|
|
38
|
+
* @part filter-clear-all - The button that resets all actively selected facet values.
|
|
39
|
+
* @part footer-content - The wrapper around the content inside the footer of the modal, containing the button to view results.
|
|
40
|
+
* @part footer-button - The button in the footer that closes the modal.
|
|
41
|
+
* @part footer-button-text - The text inside the button in the footer that closes the modal.
|
|
42
|
+
* @part footer-button-count - The count inside the button in the footer that closes the modal.
|
|
43
|
+
* @part footer-wrapper - The wrapper with a shadow or background color around the footer.
|
|
44
|
+
* @part footer - The footer of the modal.
|
|
45
|
+
* @part header-ruler - The horizontal ruler underneath the header.
|
|
46
|
+
* @part body-wrapper - The wrapper around the body.
|
|
47
|
+
* @part body - The body of the modal, between the header and the footer.
|
|
48
|
+
* @part header-wrapper - The wrapper around the header.
|
|
49
|
+
* @part header - The header of the modal, containing the title.
|
|
50
|
+
* @part container - The modal's outermost container.
|
|
51
|
+
* @part backdrop - The transparent backdrop hiding the content behind the modal.
|
|
52
|
+
*
|
|
53
|
+
* @cssprop --atomic-refine-modal-facet-margin - The margin between facets in the refine modal. Default is `20px`.
|
|
54
|
+
*/
|
|
55
|
+
let AtomicIpxRefineModal = class AtomicIpxRefineModal extends LitElement {
|
|
56
|
+
constructor() {
|
|
57
|
+
super(...arguments);
|
|
58
|
+
/**
|
|
59
|
+
* Whether the modal is open.
|
|
60
|
+
*/
|
|
61
|
+
this.isOpen = false;
|
|
62
|
+
/**
|
|
63
|
+
* The number of expanded facets inside the refine modal.
|
|
64
|
+
* Remaining facets are automatically collapsed.
|
|
65
|
+
*
|
|
66
|
+
* Using the value `0` collapses all facets.
|
|
67
|
+
*/
|
|
68
|
+
this.collapseFacetsAfter = 0;
|
|
69
|
+
}
|
|
70
|
+
initialize() {
|
|
71
|
+
this.breadcrumbManager = buildBreadcrumbManager(this.bindings.engine);
|
|
72
|
+
this.querySummary = buildQuerySummary(this.bindings.engine);
|
|
73
|
+
this.watchEnabled();
|
|
74
|
+
}
|
|
75
|
+
watchEnabled() {
|
|
76
|
+
if (this.isOpen) {
|
|
77
|
+
this.createFacetSlotIfAbsent();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
createFacetSlotIfAbsent() {
|
|
81
|
+
if (this.querySelector('div[slot="facets"]')) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.appendChild(this.createFacetSlot());
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* This method is necessary to ensure that the facets slot is rendered outside of the component's shadow DOM, preserving
|
|
88
|
+
* correct CSS inheritance and slot behavior. If this logic were placed in the render
|
|
89
|
+
* function, the slot would be rendered inside the shadow DOM, which would break
|
|
90
|
+
* expected CSS styling and slot distribution.
|
|
91
|
+
*/
|
|
92
|
+
createFacetSlot() {
|
|
93
|
+
const divSlot = document.createElement('div');
|
|
94
|
+
divSlot.setAttribute('slot', 'facets');
|
|
95
|
+
this.addFacetColumnStyling(divSlot);
|
|
96
|
+
const facets = this.bindings.store.getFacetElements().sort(sortByDocumentPosition);
|
|
97
|
+
const clonedFacets = this.cloneFacets(facets);
|
|
98
|
+
collapseFacetsAfter(clonedFacets, this.collapseFacetsAfter);
|
|
99
|
+
divSlot.append(...clonedFacets);
|
|
100
|
+
return divSlot;
|
|
101
|
+
}
|
|
102
|
+
cloneFacets(facets) {
|
|
103
|
+
return facets.map((facet, i) => {
|
|
104
|
+
const clone = facet.cloneNode(true);
|
|
105
|
+
clone.classList.remove(popoverClass);
|
|
106
|
+
clone.setAttribute(isRefineModalFacet, '');
|
|
107
|
+
clone.isCollapsed =
|
|
108
|
+
this.collapseFacetsAfter === -1
|
|
109
|
+
? false
|
|
110
|
+
: i + 1 > this.collapseFacetsAfter;
|
|
111
|
+
return clone;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
addFacetColumnStyling(el) {
|
|
115
|
+
el.style.display = 'flex';
|
|
116
|
+
el.style.flexDirection = 'column';
|
|
117
|
+
el.style.gap = 'var(--atomic-refine-modal-facet-margin, 20px)';
|
|
118
|
+
}
|
|
119
|
+
renderFilters() {
|
|
120
|
+
const hasFacetElements = this.bindings.store.getFacetElements().length > 0;
|
|
121
|
+
if (!hasFacetElements) {
|
|
122
|
+
return nothing;
|
|
123
|
+
}
|
|
124
|
+
const { i18n } = this.bindings;
|
|
125
|
+
return renderRefineModalFiltersSection({
|
|
126
|
+
props: {
|
|
127
|
+
i18n,
|
|
128
|
+
withFacets: hasFacetElements,
|
|
129
|
+
withAutomaticFacets: false,
|
|
130
|
+
},
|
|
131
|
+
})(this.breadcrumbManagerState.hasBreadcrumbs
|
|
132
|
+
? renderRefineModalFiltersClearButton({
|
|
133
|
+
props: {
|
|
134
|
+
i18n,
|
|
135
|
+
onClick: () => this.breadcrumbManager.deselectAll(),
|
|
136
|
+
},
|
|
137
|
+
})
|
|
138
|
+
: nothing);
|
|
139
|
+
}
|
|
140
|
+
render() {
|
|
141
|
+
return html `${renderRefineModal({
|
|
142
|
+
props: {
|
|
143
|
+
i18n: this.bindings.i18n,
|
|
144
|
+
i18nFooterButtonTextKey: 'view-results',
|
|
145
|
+
host: this,
|
|
146
|
+
isOpen: this.isOpen,
|
|
147
|
+
onClose: () => {
|
|
148
|
+
this.isOpen = false;
|
|
149
|
+
},
|
|
150
|
+
title: this.bindings.i18n.t('filters'),
|
|
151
|
+
numberOfItems: this.querySummaryState.total,
|
|
152
|
+
openButton: this.openButton,
|
|
153
|
+
boundary: 'element',
|
|
154
|
+
scope: this.bindings.interfaceElement,
|
|
155
|
+
},
|
|
156
|
+
})(renderRefineModalBody(this.bindings.i18n)(html `${this.renderFilters()}`))}`;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
AtomicIpxRefineModal.styles = [
|
|
160
|
+
css`/*! tailwindcss v4.1.13 | MIT License | https://tailwindcss.com */:host::part(container){border-radius:.25rem;max-height:calc(100vh - 4.25rem)}`,
|
|
161
|
+
];
|
|
162
|
+
__decorate([
|
|
163
|
+
state()
|
|
164
|
+
], AtomicIpxRefineModal.prototype, "bindings", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
state()
|
|
167
|
+
], AtomicIpxRefineModal.prototype, "error", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
property({ attribute: 'open-button', type: Object })
|
|
170
|
+
], AtomicIpxRefineModal.prototype, "openButton", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
property({
|
|
173
|
+
type: Boolean,
|
|
174
|
+
converter: booleanConverter,
|
|
175
|
+
reflect: true,
|
|
176
|
+
attribute: 'is-open',
|
|
177
|
+
})
|
|
178
|
+
], AtomicIpxRefineModal.prototype, "isOpen", void 0);
|
|
179
|
+
__decorate([
|
|
180
|
+
property({ type: Number, reflect: true, attribute: 'collapse-facets-after' })
|
|
181
|
+
], AtomicIpxRefineModal.prototype, "collapseFacetsAfter", void 0);
|
|
182
|
+
__decorate([
|
|
183
|
+
bindStateToController('breadcrumbManager'),
|
|
184
|
+
state()
|
|
185
|
+
], AtomicIpxRefineModal.prototype, "breadcrumbManagerState", void 0);
|
|
186
|
+
__decorate([
|
|
187
|
+
bindStateToController('querySummary'),
|
|
188
|
+
state()
|
|
189
|
+
], AtomicIpxRefineModal.prototype, "querySummaryState", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
watch('isOpen')
|
|
192
|
+
], AtomicIpxRefineModal.prototype, "watchEnabled", null);
|
|
193
|
+
__decorate([
|
|
194
|
+
bindingGuard(),
|
|
195
|
+
errorGuard()
|
|
196
|
+
], AtomicIpxRefineModal.prototype, "render", null);
|
|
197
|
+
AtomicIpxRefineModal = __decorate([
|
|
198
|
+
customElement('atomic-ipx-refine-modal'),
|
|
199
|
+
bindings(),
|
|
200
|
+
withTailwindStyles
|
|
201
|
+
], AtomicIpxRefineModal);
|
|
202
|
+
export { AtomicIpxRefineModal };
|