@depict-ai/ui 1.4.4 → 1.4.6

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.
@@ -1,13 +1,13 @@
1
1
  import { JSX, Signal, Accessor, Setter } from "solid-js";
2
2
  import { Elem, Display, ColsAtSize, ModernDisplay, Node_Array } from "@depict-ai/utilishared/latest";
3
3
  import { SearchFilter, SearchRequest } from "@depict-ai/types/api/SearchRequest";
4
- import { SearchFilter as _SearchFilter1, SearchResponse } from "@depict-ai/types/api/SearchResponse";
4
+ import { SearchFilter as _SearchFilter1, ContentLink, SearchResponse } from "@depict-ai/types/api/SearchResponse";
5
5
  import { BaseCategoryDisplay, ProductListingResponse } from "@depict-ai/types/api/ProductListingResponse";
6
6
  import { CategorySuggestion, SearchSuggestionsResponse } from "@depict-ai/types/api/SearchSuggestionsResponse";
7
7
  import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
8
8
  import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
9
9
  import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
10
- export const version = "1.4.4";
10
+ export const version = "1.4.6";
11
11
  export function ExpandingDetails(props: {
12
12
  details_: HTMLDetailsElement;
13
13
  summary_: HTMLElement;
@@ -76,11 +76,13 @@ interface search_i18n extends plp_shared_i18n {
76
76
  placeholder_text_: string;
77
77
  show_n_results_: (number_of_results: HTMLElement) => Elem[];
78
78
  no_results_text_: string;
79
+ no_products_: string;
79
80
  search_recs_title_: string;
80
81
  clear_filters_query_sorting_after_submit_: string;
81
82
  modal_view_all_results_: (number_of_results: HTMLElement) => Elem[];
82
83
  modal_discover_more_: string;
83
- get_showing_results_for_: (query: HTMLElement, number_of_results: HTMLElement) => Elem[];
84
+ get_showing_results_for_: (query: HTMLElement, number_of_results_element: HTMLElement, has_query: boolean, number_of_results: number | undefined) => Elem[];
85
+ get_showing_pages_for_: (query: HTMLElement, number_of_results_element: HTMLElement, has_query: boolean, number_of_results: number | undefined) => Elem[];
84
86
  previous_searches_text_: string;
85
87
  category_: string;
86
88
  brand_: string;
@@ -88,6 +90,7 @@ interface search_i18n extends plp_shared_i18n {
88
90
  search_submit_button_aria_label_: string;
89
91
  search_field_field_aria_label_: string;
90
92
  previous_searches_delete_entry_from_history_: string;
93
+ content_: string;
91
94
  }
92
95
  /**
93
96
  * Category internationalisation
@@ -240,6 +243,7 @@ export type SolidLayoutOptions = {
240
243
  currently_visible?: Signal<number>;
241
244
  max_rows?: number;
242
245
  button?: JSX.Element;
246
+ view_less_button?: JSX.Element;
243
247
  } | "all";
244
248
  layout: "slider" | "grid";
245
249
  disable_partial_rows?: boolean;
@@ -257,6 +261,47 @@ export type SolidLayoutOptions = {
257
261
  * @return An accessor containing a CSS string
258
262
  */
259
263
  export function SolidLayout(props: SolidLayoutOptions): JSX.Element;
264
+ type DisplayTransformerAlwaysThereData = {
265
+ merchant: string;
266
+ market: string;
267
+ };
268
+ type CanBePromiseWrapped<T> = T | Promise<T>;
269
+ export type ModernDisplayWithPageUrl<T extends ModernDisplay> = { [K in keyof T]: K extends "variant_displays" ? (T[K][number] & {
270
+ page_url: string;
271
+ })[] : T[K] };
272
+ /**
273
+ * DisplayTransformers supersede pageURLCreator
274
+ * DisplayTransformers are functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
275
+ */
276
+ export type DisplayTransformers<InputDisplay extends ModernDisplay, OutputDisplay extends ModernDisplay | never> = {
277
+ products?: (options: DisplayTransformerAlwaysThereData & {
278
+ displays: InputDisplay[];
279
+ }) => CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
280
+ categories?: (options: DisplayTransformerAlwaysThereData & {
281
+ data: (BaseCategoryDisplay | CategorySuggestion)[];
282
+ }) => CanBePromiseWrapped<{
283
+ page_url: string;
284
+ }[]>;
285
+ contentResults?: (options: DisplayTransformerAlwaysThereData & {
286
+ data: ContentLink[];
287
+ }) => CanBePromiseWrapped<ContentLink[]>;
288
+ };
289
+ export type SomethingTakingAPageURLCreatorOrDisplayTransformers<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
290
+ page_url_creator?: PageURLCreator<InputDisplay, OutputDisplay>;
291
+ display_transformers?: never;
292
+ } | {
293
+ page_url_creator?: never;
294
+ display_transformers: DisplayTransformers<InputDisplay, OutputDisplay>;
295
+ } : {
296
+ page_url_creator: PageURLCreator<InputDisplay, OutputDisplay>;
297
+ display_transformers?: never;
298
+ } | {
299
+ display_transformers: DisplayTransformers<InputDisplay, OutputDisplay>;
300
+ page_url_creator?: never;
301
+ } : {
302
+ page_url_creator?: never;
303
+ display_transformers?: never;
304
+ };
260
305
  type PageURLCreatorAlwaysThereData = {
261
306
  merchant: string;
262
307
  market: string;
@@ -269,12 +314,9 @@ type PageURLCreatorProductData<T extends ModernDisplay> = {
269
314
  displays: T[];
270
315
  type: "products";
271
316
  };
272
- type CanBePromiseWrapped<T> = T | Promise<T>;
273
- export type ModernDisplayWithPageUrl<T extends ModernDisplay> = { [K in keyof T]: K extends "variant_displays" ? (T[K][number] & {
274
- page_url: string;
275
- })[] : T[K] };
276
317
  type PageURLCreatorOptions<InputDisplay extends ModernDisplay> = PageURLCreatorAlwaysThereData & (PageURLCreatorCategoryData | PageURLCreatorProductData<InputDisplay>);
277
318
  /**
319
+ * @deprecated use DisplayTransformers instead
278
320
  * PageUrlCreator is, in its most basic form, a function that takes in a list of categories or products and returns a list of page_urls for the provided categories or products.
279
321
  * It's main use case is to allow for the creation of links to the product or category pages on the merchant's site.
280
322
  * It can also be used for the depict customers which already have links to change those links (i.e. for staging sites).
@@ -285,13 +327,6 @@ export type PageURLCreator<InputDisplay extends ModernDisplay, OutputDisplay ext
285
327
  }[]> : CanBePromiseWrapped<{
286
328
  page_url: string;
287
329
  }[]> | CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
288
- export type SomethingTakingAPageURLCreator<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
289
- page_url_creator?: PageURLCreator<InputDisplay, OutputDisplay>;
290
- } : {
291
- page_url_creator: PageURLCreator<InputDisplay, OutputDisplay>;
292
- } : {
293
- page_url_creator?: never;
294
- };
295
330
  /**
296
331
  * Basically allows you to use SearchModal
297
332
  * So the idea is to have a modal. It should either be rendered and exist, in which case it is in the foreground and open, or it's completely gone. This makes things easier.
@@ -412,7 +447,7 @@ type DepictAPIConstructorOptions<InputDisplay extends Display, OutputDisplay ext
412
447
  } | undefined>;
413
448
  get_user_id?: () => string | undefined;
414
449
  get_session_id?: () => string | undefined;
415
- } & SomethingTakingAPageURLCreator<InputDisplay, OutputDisplay>;
450
+ } & SomethingTakingAPageURLCreatorOrDisplayTransformers<InputDisplay, OutputDisplay>;
416
451
  /**
417
452
  * Class that handles all communication done in PLP code with the Depict API. (Notably not for recommendations currently).
418
453
  * It handles caching, retries and errors and is the only place that should be making requests to the Depict API.
@@ -420,6 +455,7 @@ type DepictAPIConstructorOptions<InputDisplay extends Display, OutputDisplay ext
420
455
  export class DepictAPI<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> {
421
456
  #private;
422
457
  page_url_creator: PageURLCreator<ModernDisplay, OutputDisplay> | undefined;
458
+ display_transformers: DisplayTransformers<ModernDisplay, OutputDisplay> | undefined;
423
459
  constructor(options: DepictAPIConstructorOptions<InputDisplay, OutputDisplay>);
424
460
  suggest(input_req: SearchSuggestionsRequest): Promise<SearchSuggestionsResponseAfterURLCreator & {
425
461
  failed?: true;
@@ -494,16 +530,11 @@ type CategoryConstructorOptionsWithApi<InputDisplay extends Display, OutputDispl
494
530
  api: DepictAPI<InputDisplay, OutputDisplay>;
495
531
  } & {
496
532
  page_url_creator?: never;
533
+ display_transformers?: never;
497
534
  };
498
535
  type CategoryConstructorOptionsWithoutApi<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralCategoryListingOptions & {
499
536
  api?: never;
500
- } & (InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
501
- page_url_creator?: PageURLCreator<InputDisplay, OutputDisplay>;
502
- } : {
503
- page_url_creator: PageURLCreator<InputDisplay, OutputDisplay>;
504
- } : {
505
- page_url_creator?: never;
506
- });
537
+ } & SomethingTakingAPageURLCreatorOrDisplayTransformers<InputDisplay, OutputDisplay>;
507
538
  type DepictCategoryConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay> = CategoryConstructorOptionsWithApi<InputDisplay, OutputDisplay> | CategoryConstructorOptionsWithoutApi<InputDisplay, OutputDisplay>;
508
539
  export class DepictCategory<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> {
509
540
  #private;
@@ -523,6 +554,7 @@ export class DepictCategory<InputDisplay extends Display, OutputDisplay extends
523
554
  api,
524
555
  on_navigation,
525
556
  page_url_creator,
557
+ display_transformers,
526
558
  unique_instance_key_for_state,
527
559
  query_id_state_key,
528
560
  ...props_on_class
@@ -608,6 +640,7 @@ type GeneralConstructorOptions<InputDisplay extends Display, OutputDisplay exten
608
640
  on_navigation?: OnNavigation;
609
641
  url_transformer?: (url_object: URL) => unknown;
610
642
  enable_category_suggestions?: boolean;
643
+ enable_content_search?: boolean;
611
644
  unique_instance_key_for_state?: string;
612
645
  disable_scrolling_during_modal?: boolean;
613
646
  bottom_distance_under_modal?: Accessor<number | undefined>;
@@ -617,10 +650,11 @@ type ConstructorOptionsWithApi<InputDisplay extends Display, OutputDisplay exten
617
650
  api: DepictAPI<InputDisplay, OutputDisplay>;
618
651
  } & {
619
652
  page_url_creator?: never;
653
+ display_transformers?: never;
620
654
  };
621
655
  type ConstructorOptionsWithoutAPI<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralConstructorOptions<InputDisplay, OutputDisplay> & {
622
656
  api?: never;
623
- } & SomethingTakingAPageURLCreator<InputDisplay, OutputDisplay>;
657
+ } & SomethingTakingAPageURLCreatorOrDisplayTransformers<InputDisplay, OutputDisplay>;
624
658
  type ConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay> = ConstructorOptionsWithApi<InputDisplay, OutputDisplay> | ConstructorOptionsWithoutAPI<InputDisplay, OutputDisplay>;
625
659
  export type OpenModalArguments = [options_for_modal?: {
626
660
  style_props_?: Signal<JSX.CSSProperties>;
@@ -639,12 +673,15 @@ export class DepictSearch<InputDisplay extends Display, OutputDisplay extends Mo
639
673
  on_navigation,
640
674
  enable_category_suggestions,
641
675
  page_url_creator,
642
- disable_scrolling_during_modal,
676
+ display_transformers,
643
677
  api,
678
+ disable_scrolling_during_modal,
644
679
  bottom_distance_under_modal,
645
680
  render_instant_card,
646
681
  ...props_on_class
647
682
  }: ConstructorOptions<InputDisplay, OutputDisplay>);
683
+ get enable_content_search(): boolean | undefined;
684
+ set enable_content_search(new_state: boolean | undefined);
648
685
  get on_navigation(): OnNavigation;
649
686
  set on_navigation(new_function: OnNavigation);
650
687
  get localization(): search_i18n;
@@ -708,11 +745,50 @@ export type BaseProviderConfig<InputDisplay extends Display, PossibleTransformed
708
745
  */
709
746
  uniqueInstanceKeyForState?: string;
710
747
  } & (InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
748
+ /**
749
+ * @deprecated use displayTransformers instead
750
+ */
711
751
  pageURLCreator?: PageURLCreator<InputDisplay, PossibleTransformedDisplay>;
752
+ /**
753
+ * Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
754
+ */
755
+ displayTransformers?: never;
756
+ } | {
757
+ /**
758
+ * @deprecated use displayTransformers instead
759
+ */
760
+ pageURLCreator?: never;
761
+ /**
762
+ * Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
763
+ */
764
+ displayTransformers: DisplayTransformers<InputDisplay, PossibleTransformedDisplay>;
712
765
  } : {
766
+ /**
767
+ * @deprecated use displayTransformers instead
768
+ */
713
769
  pageURLCreator: PageURLCreator<InputDisplay, PossibleTransformedDisplay>;
770
+ /**
771
+ * Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
772
+ */
773
+ displayTransformers?: never;
774
+ } | {
775
+ /**
776
+ * Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
777
+ */
778
+ displayTransformers: DisplayTransformers<InputDisplay, PossibleTransformedDisplay>;
779
+ /**
780
+ * @deprecated use displayTransformers instead
781
+ */
782
+ pageURLCreator?: never;
714
783
  } : {
784
+ /**
785
+ * @deprecated use displayTransformers instead
786
+ */
715
787
  pageURLCreator?: never;
788
+ /**
789
+ * Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
790
+ */
791
+ displayTransformers?: never;
716
792
  });
717
793
  export type BaseSearchProviderConfig = {
718
794
  /**
@@ -731,6 +807,11 @@ export type BaseSearchProviderConfig = {
731
807
  * @default false
732
808
  */
733
809
  enableCategorySuggestions?: boolean;
810
+ /**
811
+ * Whether to enable content search in the search modal and search page.
812
+ * @default false
813
+ */
814
+ enableContentSearch?: boolean;
734
815
  };
735
816
  export interface BaseProductListingConfig {
736
817
  /**