diff --git a/packages/atomic/src/components.d.ts b/packages/atomic/src/components.d.ts index b6fd650f5dd..59cfb6db51e 100644 --- a/packages/atomic/src/components.d.ts +++ b/packages/atomic/src/components.d.ts @@ -23,11 +23,10 @@ import { NumberInputType } from "./components/common/facets/facet-number-input/n import { NumericFilter, NumericFilterState, RelativeDateUnit } from "./components/common/types"; import { InsightEngine, FacetSortCriterion as InsightFacetSortCriterion, FoldedResult as InsightFoldedResult, InteractiveResult as InsightInteractiveResult, LogLevel as InsightLogLevel, RangeFacetRangeAlgorithm as InsightRangeFacetRangeAlgorithm, RangeFacetSortCriterion as InsightRangeFacetSortCriterion, Result as InsightResult, ResultTemplate as InsightResultTemplate, ResultTemplateCondition as InsightResultTemplateCondition, UserAction as IUserAction } from "./components/insight"; import { InsightInitializationOptions } from "./components/insight/atomic-insight-interface/atomic-insight-interface"; -import { AtomicInsightStore } from "./components/insight/atomic-insight-interface/store"; +import { InsightStore } from "./components/insight/atomic-insight-interface/store"; import { InsightResultActionClickedEvent } from "./components/insight/atomic-insight-result-action/atomic-insight-result-action"; import { InsightResultAttachToCaseEvent } from "./components/insight/atomic-insight-result-attach-to-case-action/atomic-insight-result-attach-to-case-action"; import { Section } from "./components/common/atomic-layout-section/sections"; -import { AtomicCommonStore, AtomicCommonStoreData } from "./components/common/interface/store"; import { CommerceStore } from "./components/commerce/atomic-commerce-interface/store"; import { CommerceRecommendationStore } from "./components/commerce/atomic-commerce-recommendation-interface/store"; import { SelectChildProductEventArgs } from "./components/commerce/product-template-components/atomic-product-children/atomic-product-children"; @@ -35,8 +34,9 @@ import { TruncateAfter } from "./components/common/expandable-text/expandable-te import { RecommendationEngine } from "@coveo/headless/recommendation"; import { InteractiveResult as RecsInteractiveResult, LogLevel as RecsLogLevel, Result as RecsResult, ResultTemplate as RecsResultTemplate, ResultTemplateCondition as RecsResultTemplateCondition } from "./components/recommendations"; import { RecsInitializationOptions } from "./components/recommendations/atomic-recs-interface/atomic-recs-interface"; -import { AtomicRecsStore } from "./components/recommendations/atomic-recs-interface/store"; +import { RecsStore } from "./components/recommendations/atomic-recs-interface/store"; import { Bindings as Bindings1 } from "./components/search/atomic-search-interface/atomic-search-interface"; +import { SearchStore } from "./components/search/atomic-search-interface/store"; import { AriaLabelGenerator as AriaLabelGenerator1 } from "./components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results"; import { InitializationOptions } from "./components/search/atomic-search-interface/atomic-search-interface"; export { AutomaticFacet, CategoryFacetSortCriterion, DateFilterRange, DateRangeRequest, FacetResultsMustMatch, FacetSortCriterion, FoldedResult, GeneratedAnswer, GeneratedAnswerCitation, InlineLink, InteractiveCitation, InteractiveResult, LogLevel as LogLevel1, RangeFacetRangeAlgorithm, RangeFacetSortCriterion, Result, ResultTemplate, ResultTemplateCondition, SearchEngine, SearchStatus } from "@coveo/headless"; @@ -57,11 +57,10 @@ export { NumberInputType } from "./components/common/facets/facet-number-input/n export { NumericFilter, NumericFilterState, RelativeDateUnit } from "./components/common/types"; export { InsightEngine, FacetSortCriterion as InsightFacetSortCriterion, FoldedResult as InsightFoldedResult, InteractiveResult as InsightInteractiveResult, LogLevel as InsightLogLevel, RangeFacetRangeAlgorithm as InsightRangeFacetRangeAlgorithm, RangeFacetSortCriterion as InsightRangeFacetSortCriterion, Result as InsightResult, ResultTemplate as InsightResultTemplate, ResultTemplateCondition as InsightResultTemplateCondition, UserAction as IUserAction } from "./components/insight"; export { InsightInitializationOptions } from "./components/insight/atomic-insight-interface/atomic-insight-interface"; -export { AtomicInsightStore } from "./components/insight/atomic-insight-interface/store"; +export { InsightStore } from "./components/insight/atomic-insight-interface/store"; export { InsightResultActionClickedEvent } from "./components/insight/atomic-insight-result-action/atomic-insight-result-action"; export { InsightResultAttachToCaseEvent } from "./components/insight/atomic-insight-result-attach-to-case-action/atomic-insight-result-attach-to-case-action"; export { Section } from "./components/common/atomic-layout-section/sections"; -export { AtomicCommonStore, AtomicCommonStoreData } from "./components/common/interface/store"; export { CommerceStore } from "./components/commerce/atomic-commerce-interface/store"; export { CommerceRecommendationStore } from "./components/commerce/atomic-commerce-recommendation-interface/store"; export { SelectChildProductEventArgs } from "./components/commerce/product-template-components/atomic-product-children/atomic-product-children"; @@ -69,8 +68,9 @@ export { TruncateAfter } from "./components/common/expandable-text/expandable-te export { RecommendationEngine } from "@coveo/headless/recommendation"; export { InteractiveResult as RecsInteractiveResult, LogLevel as RecsLogLevel, Result as RecsResult, ResultTemplate as RecsResultTemplate, ResultTemplateCondition as RecsResultTemplateCondition } from "./components/recommendations"; export { RecsInitializationOptions } from "./components/recommendations/atomic-recs-interface/atomic-recs-interface"; -export { AtomicRecsStore } from "./components/recommendations/atomic-recs-interface/store"; +export { RecsStore } from "./components/recommendations/atomic-recs-interface/store"; export { Bindings as Bindings1 } from "./components/search/atomic-search-interface/atomic-search-interface"; +export { SearchStore } from "./components/search/atomic-search-interface/store"; export { AriaLabelGenerator as AriaLabelGenerator1 } from "./components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results"; export { InitializationOptions } from "./components/search/atomic-search-interface/atomic-search-interface"; export namespace Components { @@ -1413,7 +1413,7 @@ export namespace Components { /** * Global Atomic state. */ - "store"?: AtomicInsightStore; + "store"?: InsightStore; } interface AtomicInsightResultAction { /** @@ -2056,9 +2056,7 @@ export namespace Components { * Global Atomic state. * @alpha */ - "store"?: | AtomicCommonStore - | CommerceStore - | CommerceRecommendationStore; + "store"?: CommerceStore | CommerceRecommendationStore; } /** * @alpha The `atomic-product-children` component renders a section that allows the user to select a nested product (e.g., a color variant of a given product). @@ -2702,7 +2700,7 @@ export namespace Components { /** * Global Atomic state. */ - "store"?: AtomicRecsStore; + "store"?: RecsStore; } /** * A [result template](https://docs.coveo.com/en/atomic/latest/usage/displaying-results#defining-a-result-template) determines the format of the query results, depending on the conditions that are defined for each template. @@ -2824,7 +2822,7 @@ export namespace Components { /** * Global Atomic state. */ - "store"?: AtomicCommonStore; + "store"?: SearchStore; } /** * The `atomic-result-badge` element renders a badge to highlight special features of a result. @@ -7573,7 +7571,7 @@ declare namespace LocalJSX { /** * Global Atomic state. */ - "store"?: AtomicInsightStore; + "store"?: InsightStore; } interface AtomicInsightResultAction { /** @@ -8191,9 +8189,7 @@ declare namespace LocalJSX { * Global Atomic state. * @alpha */ - "store"?: | AtomicCommonStore - | CommerceStore - | CommerceRecommendationStore; + "store"?: CommerceStore | CommerceRecommendationStore; } /** * @alpha The `atomic-product-children` component renders a section that allows the user to select a nested product (e.g., a color variant of a given product). @@ -8797,7 +8793,7 @@ declare namespace LocalJSX { /** * Global Atomic state. */ - "store"?: AtomicRecsStore; + "store"?: RecsStore; } /** * A [result template](https://docs.coveo.com/en/atomic/latest/usage/displaying-results#defining-a-result-template) determines the format of the query results, depending on the conditions that are defined for each template. @@ -8916,7 +8912,7 @@ declare namespace LocalJSX { /** * Global Atomic state. */ - "store"?: AtomicCommonStore; + "store"?: SearchStore; } /** * The `atomic-result-badge` element renders a badge to highlight special features of a result. diff --git a/packages/atomic/src/components/commerce/atomic-commerce-interface/store.ts b/packages/atomic/src/components/commerce/atomic-commerce-interface/store.ts index 1d0ab42717b..4881572b6ba 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-interface/store.ts +++ b/packages/atomic/src/components/commerce/atomic-commerce-interface/store.ts @@ -9,23 +9,19 @@ import {CommonStore, ResultListInfo} from '../../common/interface/store'; import {makeDesktopQuery} from '../../search/atomic-layout/search-layout'; interface Data { - //IMPORTANT does mobileBreakpoint work in commerce-layout ?? it does not get updated... mobileBreakpoint: string; activeProductChild: ChildProduct | undefined; - // why is this undefined I don't like resultList?: ResultListInfo; iconAssetsPath: string; loadingFlags: string[]; } export type CommerceStore = CommonStore & { - hasLoadingFlag(loadingFlag: string): boolean; unsetLoadingFlag(loadingFlag: string): void; setLoadingFlag(flag: string): void; isAppLoaded(): boolean; isMobile(): boolean; getUniqueIDFromEngine(engine: CommerceEngine): string; - registerResultList(data: ResultListInfo): void; }; export function createCommerceStore( @@ -41,10 +37,6 @@ export function createCommerceStore( return { ...store, - hasLoadingFlag(loadingFlag: string) { - return store.state.loadingFlags.indexOf(loadingFlag) !== -1; - }, - unsetLoadingFlag(loadingFlag: string) { const flags = store.state.loadingFlags; store.state.loadingFlags = flags.filter((value) => value !== loadingFlag); @@ -76,10 +68,5 @@ export function createCommerceStore( ); } }, - - // This is not necessary, we could just do store.state.resultList = data; - registerResultList(data: ResultListInfo) { - store.state.resultList = data; - }, }; } diff --git a/packages/atomic/src/components/commerce/atomic-commerce-recommendation-interface/store.ts b/packages/atomic/src/components/commerce/atomic-commerce-recommendation-interface/store.ts index 1cde834e143..e3468bbbec4 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-recommendation-interface/store.ts +++ b/packages/atomic/src/components/commerce/atomic-commerce-recommendation-interface/store.ts @@ -11,7 +11,6 @@ export type CommerceRecommendationStore = CommonStore & { isAppLoaded(): boolean; unsetLoadingFlag(loadingFlag: string): void; setLoadingFlag(flag: string): void; - registerResultList(data: ResultListInfo): void; // getUniqueIDFromEngine(engine: CommerceEngine): string; }; @@ -38,11 +37,6 @@ export function createCommerceRecommendationStore(): CommerceRecommendationStore store.state.loadingFlags = flags.concat(loadingFlag); }, - // This is not necessary, we could just do store.state.resultList = data; - registerResultList(data: ResultListInfo) { - store.state.resultList = data; - }, - // getUniqueIDFromEngine(engine: CommerceEngine): string { // return null; // }, diff --git a/packages/atomic/src/components/common/item-list/item-list-common.tsx b/packages/atomic/src/components/common/item-list/item-list-common.tsx index 7e55a743810..9fa0267ffca 100644 --- a/packages/atomic/src/components/common/item-list/item-list-common.tsx +++ b/packages/atomic/src/components/common/item-list/item-list-common.tsx @@ -47,7 +47,7 @@ export class ItemListCommon { constructor(private props: ItemListCommonProps) { this.props.store.setLoadingFlag(this.props.loadingFlag); - this.props.store.registerResultList(this); + this.props.store.state.resultList = this; this.updateBreakpointsOnce = once(() => updateBreakpoints(this.props.host)); } diff --git a/packages/atomic/src/components/common/refine-modal/modal.tsx b/packages/atomic/src/components/common/refine-modal/modal.tsx index 3d8e80a0667..517aef0ce95 100644 --- a/packages/atomic/src/components/common/refine-modal/modal.tsx +++ b/packages/atomic/src/components/common/refine-modal/modal.tsx @@ -1,10 +1,10 @@ import {FunctionalComponent, h} from '@stencil/core'; import {i18n} from 'i18next'; import CloseIcon from '../../../images/close.svg'; +import {isRefineModalFacet} from '../../search/atomic-search-interface/store'; import {Button} from '../button'; import {BaseFacetElement} from '../facets/facet-common'; import {popoverClass} from '../facets/popover/popover-type'; -import {isRefineModalFacet} from '../interface/store'; interface RefineModalProps { host: HTMLElement; diff --git a/packages/atomic/src/components/insight/atomic-insight-interface/store.ts b/packages/atomic/src/components/insight/atomic-insight-interface/store.ts index 784833fd853..4fb19ffcaf8 100644 --- a/packages/atomic/src/components/insight/atomic-insight-interface/store.ts +++ b/packages/atomic/src/components/insight/atomic-insight-interface/store.ts @@ -34,7 +34,6 @@ export type InsightStore = CommonStore & { isAppLoaded(): boolean; getFacetElements(): HTMLElement[]; waitUntilAppLoaded(callback: () => void): void; - registerResultList(data: ResultListInfo): void; getUniqueIDFromEngine(engine: InsightEngine): string; }; @@ -109,10 +108,6 @@ export function createInsightStore(): InsightStore { } }, - registerResultList(data: ResultListInfo) { - store.state.resultList = data; - }, - getUniqueIDFromEngine(engine: InsightEngine): string { return engine.state.search.searchResponseId; }, diff --git a/packages/atomic/src/components/recommendations/atomic-recs-interface/store.ts b/packages/atomic/src/components/recommendations/atomic-recs-interface/store.ts index 40662e80b6a..f1daa75ef34 100644 --- a/packages/atomic/src/components/recommendations/atomic-recs-interface/store.ts +++ b/packages/atomic/src/components/recommendations/atomic-recs-interface/store.ts @@ -3,24 +3,16 @@ import {DEFAULT_MOBILE_BREAKPOINT} from '../../../utils/replace-breakpoint'; import {CommonStore, ResultListInfo} from '../../common/interface/store'; interface Data { - //IMPORTANT does mobileBreakpoint work in commerce-layout ?? it does not get updated... mobileBreakpoint: string; loadingFlags: string[]; - // activeProductChild: ChildProduct | undefined; - // why is this undefined I don't like - // resultList?: ResultListInfo; iconAssetsPath: string; resultList?: ResultListInfo; - - // loadingFlags: string[]; } export type RecsStore = CommonStore & { - // hasLoadingFlag(loadingFlag: string): boolean; unsetLoadingFlag(loadingFlag: string): void; setLoadingFlag(flag: string): void; isAppLoaded(): boolean; - registerResultList(data: ResultListInfo): void; }; export function createRecsStore(): RecsStore { @@ -46,10 +38,5 @@ export function createRecsStore(): RecsStore { isAppLoaded() { return !store.state.loadingFlags.length; }, - - // This is not necessary, we could just do store.state.resultList = data; - registerResultList(data: ResultListInfo) { - store.state.resultList = data; - }, }; } diff --git a/packages/atomic/src/components/search/atomic-search-interface/store.ts b/packages/atomic/src/components/search/atomic-search-interface/store.ts index 4ce348fbe6e..f89399afb4d 100644 --- a/packages/atomic/src/components/search/atomic-search-interface/store.ts +++ b/packages/atomic/src/components/search/atomic-search-interface/store.ts @@ -16,7 +16,6 @@ import { import {CommonStore, ResultListInfo} from '../../common/interface/store'; import {makeDesktopQuery} from '../atomic-layout/search-layout'; -// what does this have to do with store... export interface SortDropdownOption { tabs: {included: string[] | string; excluded: string[] | string}; expression: string; diff --git a/packages/atomic/src/utils/accessibility-utils.tsx b/packages/atomic/src/utils/accessibility-utils.tsx index 543cdbeaeab..a4df742a25d 100644 --- a/packages/atomic/src/utils/accessibility-utils.tsx +++ b/packages/atomic/src/utils/accessibility-utils.tsx @@ -91,7 +91,7 @@ export class FocusTargetController { public disableForCurrentSearch() { if ( - //@ts-expect-error normal for now, should go away + //@ts-expect-error to fix this.bindings.store.getUniqueIDFromEngine(this.bindings.engine) !== this.lastSearchId ) { @@ -110,7 +110,7 @@ export class FocusTargetController { } if ( this.doFocusAfterSearch && - //@ts-expect-error normal for now, should go away + //@ts-expect-error to fix this.bindings.store.getUniqueIDFromEngine(this.bindings.engine) !== this.lastSearchId ) {