Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprudhomme committed Dec 23, 2024
1 parent 0a56686 commit c486e23
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 60 deletions.
32 changes: 14 additions & 18 deletions packages/atomic/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ 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";
import { TruncateAfter } from "./components/common/expandable-text/expandable-text";
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";
Expand All @@ -57,20 +57,20 @@ 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";
export { TruncateAfter } from "./components/common/expandable-text/expandable-text";
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 {
Expand Down Expand Up @@ -1413,7 +1413,7 @@ export namespace Components {
/**
* Global Atomic state.
*/
"store"?: AtomicInsightStore;
"store"?: InsightStore;
}
interface AtomicInsightResultAction {
/**
Expand Down Expand Up @@ -2056,9 +2056,7 @@ export namespace Components {
* Global Atomic state.
* @alpha
*/
"store"?: | AtomicCommonStore<AtomicCommonStoreData>
| 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).
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -2824,7 +2822,7 @@ export namespace Components {
/**
* Global Atomic state.
*/
"store"?: AtomicCommonStore<AtomicCommonStoreData>;
"store"?: SearchStore;
}
/**
* The `atomic-result-badge` element renders a badge to highlight special features of a result.
Expand Down Expand Up @@ -7573,7 +7571,7 @@ declare namespace LocalJSX {
/**
* Global Atomic state.
*/
"store"?: AtomicInsightStore;
"store"?: InsightStore;
}
interface AtomicInsightResultAction {
/**
Expand Down Expand Up @@ -8191,9 +8189,7 @@ declare namespace LocalJSX {
* Global Atomic state.
* @alpha
*/
"store"?: | AtomicCommonStore<AtomicCommonStoreData>
| 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).
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -8916,7 +8912,7 @@ declare namespace LocalJSX {
/**
* Global Atomic state.
*/
"store"?: AtomicCommonStore<AtomicCommonStoreData>;
"store"?: SearchStore;
}
/**
* The `atomic-result-badge` element renders a badge to highlight special features of a result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Data> & {
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(
Expand All @@ -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);
Expand Down Expand Up @@ -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;
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export type CommerceRecommendationStore = CommonStore<Data> & {
isAppLoaded(): boolean;
unsetLoadingFlag(loadingFlag: string): void;
setLoadingFlag(flag: string): void;
registerResultList(data: ResultListInfo): void;
// getUniqueIDFromEngine(engine: CommerceEngine): string;
};

Expand All @@ -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;
// },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export type InsightStore = CommonStore<Data> & {
isAppLoaded(): boolean;
getFacetElements(): HTMLElement[];
waitUntilAppLoaded(callback: () => void): void;
registerResultList(data: ResultListInfo): void;
getUniqueIDFromEngine(engine: InsightEngine): string;
};

Expand Down Expand Up @@ -109,10 +108,6 @@ export function createInsightStore(): InsightStore {
}
},

registerResultList(data: ResultListInfo) {
store.state.resultList = data;
},

getUniqueIDFromEngine(engine: InsightEngine): string {
return engine.state.search.searchResponseId;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Data> & {
// hasLoadingFlag(loadingFlag: string): boolean;
unsetLoadingFlag(loadingFlag: string): void;
setLoadingFlag(flag: string): void;
isAppLoaded(): boolean;
registerResultList(data: ResultListInfo): void;
};

export function createRecsStore(): RecsStore {
Expand All @@ -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;
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/atomic/src/utils/accessibility-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand All @@ -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
) {
Expand Down

0 comments on commit c486e23

Please sign in to comment.