@depict-ai/ui 0.0.25 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
+ import { Accessor, JSX, Setter, Signal } from "solid-js";
1
2
  import { Elem, Display, InfoForProcessing, Node_Array, RR_PostProcessor, RR_PreProcessor } from "@depict-ai/utilishared";
3
+ import { search_i18n as _search_i18n1 } from "../../../locales";
2
4
  import { SearchResponse } from "@depict-ai/types/api/SearchResponse";
3
5
  import { SearchRequest, SearchFilter } from "@depict-ai/types/api/SearchRequest";
4
6
  import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
@@ -6,9 +8,21 @@ import { SearchSuggestionsResponse, CategorySuggestion } from "@depict-ai/types/
6
8
  import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
7
9
  import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
8
10
  import { ProductListingResponse, BaseCategoryDisplay } from "@depict-ai/types/api/ProductListingResponse";
9
- import { Accessor, JSX, Setter, Signal } from "solid-js";
10
11
  import { JSX as _JSX1 } from "solid-js/types/jsx";
11
- export const version = "0.0.25";
12
+ export const version = "0.0.27";
13
+ /**
14
+ * Like standard_price_format except that the price and the formatting are reactive accessors
15
+ */
16
+ export function solid_format_price({ price_, price_formatting_, }: {
17
+ price_: Accessor<number>;
18
+ price_formatting_: Accessor<{
19
+ pre_: string;
20
+ post_: string;
21
+ decimal_places_delimiter_: string;
22
+ thousands_delimiter_: string;
23
+ places_after_comma_: number | "auto";
24
+ }>;
25
+ }): Accessor<string>;
12
26
  /**
13
27
  * PLP internationalisation shared between search and category listing
14
28
  */
@@ -83,6 +97,12 @@ interface category_i18n extends plp_shared_i18n {
83
97
  */
84
98
  export interface Locale extends category_i18n, search_i18n {
85
99
  }
100
+ export type InstantCard = (display: unknown, context: {
101
+ index: number;
102
+ i18n: _search_i18n1;
103
+ merchant: string;
104
+ market: string;
105
+ }) => JSX.Element;
86
106
  export function add_to_version_info(stuff_to_add: {
87
107
  [key: string]: string;
88
108
  }): void;
@@ -111,19 +131,6 @@ export function media_query_to_accessor(media_query: string): import("solid-js")
111
131
  export type WithRequired<T, K extends keyof T> = T & {
112
132
  [P in K]-?: T[P];
113
133
  };
114
- /**
115
- * Like standard_price_format except that the price and the formatting are reactive accessors
116
- */
117
- export function solid_format_price({ price_, price_formatting_, }: {
118
- price_: Accessor<number>;
119
- price_formatting_: Accessor<{
120
- pre_: string;
121
- post_: string;
122
- decimal_places_delimiter_: string;
123
- thousands_delimiter_: string;
124
- places_after_comma_: number | "auto";
125
- }>;
126
- }): Accessor<string>;
127
134
  export function show_toast({ children, on_close_, close_after_, ...more_attributes }: {
128
135
  children?: JSX.Element;
129
136
  close_after_: number;
@@ -202,12 +209,6 @@ export function QuickLinks({ depict_category }: {
202
209
  depict_category: DepictCategory;
203
210
  }): HTMLElement;
204
211
  export function get_categories(tenant: string, market: string): Promise<string[]>;
205
- type InstantCard = (display: unknown, context: {
206
- index: number;
207
- i18n: search_i18n;
208
- merchant: string;
209
- market: string;
210
- }) => JSX.Element;
211
212
  export function DefaultInstantCardPlaceholder(): HTMLDivElement;
212
213
  /**
213
214
  * Useful for aligning the search modal to an element, like an existing input field
package/dist/main.js CHANGED
@@ -31,7 +31,7 @@ $parcel$export(module.exports, "solid_format_price", () => $5fc9fc23df1591db$exp
31
31
  $parcel$export(module.exports, "PageReplacer", () => $37e96a5ebc768cc7$export$3ccaa27d81dd8556);
32
32
  $parcel$export(module.exports, "version", () => $ae93561d5649a847$export$83d89fbfd8236492);
33
33
  /*! Depict.ai search and product listing SDK */
34
- const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.25";
34
+ const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.27";
35
35
 
36
36
 
37
37
 
@@ -4903,7 +4903,7 @@ function $b5bcdaaacb8b81f2$var$get_shared_properties(depict_category) {
4903
4903
 
4904
4904
 
4905
4905
 
4906
- const $853f821e60bd06ea$var$_tmpl$ = /*#__PURE__*/ (0, $46MJV$solidjsweb.template)(`<div class="category-title"><span class="title"></span><span class="explanation"> — </span></div>`, 6);
4906
+ const $853f821e60bd06ea$var$_tmpl$ = /*#__PURE__*/ (0, $46MJV$solidjsweb.template)(`<div class="category-title"><h2 class="title"></h2><span class="explanation"> — </span></div>`, 6);
4907
4907
  const $853f821e60bd06ea$export$b91cec6bdc6b32a1 = /*@__PURE__*/ (()=>{
4908
4908
  const actual_function = ({ category_title_: category_title_ , product_count_: product_count_ })=>{
4909
4909
  return (()=>{
@@ -5120,7 +5120,10 @@ function $67892c03cd3dfa66$export$d757d54550ebfb3d({ category_suggestion_: categ
5120
5120
  (0, $46MJV$solidjsweb.addEventListener)(_el$, "click", (0, $46MJV$depictaiutilishared.catchify)((e)=>{
5121
5121
  if (e.button || e.metaKey || e.ctrlKey) // Not single page navigating because button is not 0 or ctrl/command click
5122
5122
  return;
5123
- return on_navigation_?.(category_suggestion_().page_url);
5123
+ if (on_navigation_) {
5124
+ e.preventDefault();
5125
+ return on_navigation_(category_suggestion_().page_url);
5126
+ }
5124
5127
  }), true);
5125
5128
  (0, $46MJV$solidjsweb.insert)(_el$2, ()=>category_suggestion_().title);
5126
5129
  (0, $46MJV$solidjsweb.insert)(_el$, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
@@ -5592,10 +5595,18 @@ function $690220645373c65e$export$2542ffb77b620b02(params_to_default_value) {
5592
5595
 
5593
5596
  const $1bf0125991f2d39b$var$_tmpl$ = /*#__PURE__*/ (0, $46MJV$solidjsweb.template)(`<span class="orig price"></span>`, 2), $1bf0125991f2d39b$var$_tmpl$2 = /*#__PURE__*/ (0, $46MJV$solidjsweb.template)(`<a class="instant-card"><div class="img-part"></div><div class="right-part"><div class="title-brand-tagline"><span class="brand"></span><span class="title"></span></div><div class="price-container"><span class="price"></span></div></div></a>`, 16), $1bf0125991f2d39b$var$_tmpl$3 = /*#__PURE__*/ (0, $46MJV$solidjsweb.template)(`<div class="tagline"></div>`, 2);
5594
5597
  const $1bf0125991f2d39b$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n })=>{
5595
- // Support for Spendrups displays, should probably be in the Spendrups script
5596
5598
  const display = (0, $46MJV$solidjs.createMemo)(()=>{
5597
5599
  const display = display_or_variant_container();
5600
+ // Support for backend's new display format
5601
+ if ("variant_displays" in display && typeof display?.variant_index === "number") {
5602
+ const actual_display = display.variant_displays[display.variant_index];
5603
+ return {
5604
+ image_url: actual_display.image_urls?.[0],
5605
+ ...actual_display
5606
+ };
5607
+ }
5598
5608
  if (display.page_url) return display;
5609
+ // Support for Spendrups displays, should probably be in the Spendrups script
5599
5610
  if (!display?.variants?.length) return;
5600
5611
  return display.variants.filter((v)=>v.product_id == display.product_id)[0];
5601
5612
  });
@@ -5603,6 +5614,7 @@ const $1bf0125991f2d39b$export$b05c0ae390cf3e06 = (display_or_variant_container,
5603
5614
  const contained_image = (0, $46MJV$solidjs.createMemo)(()=>(0, $46MJV$depictaiutilishared.ContainedImage)({
5604
5615
  aspect_ratio: 1,
5605
5616
  alt: "",
5617
+ rendering_options: {},
5606
5618
  // @ts-ignore
5607
5619
  "data-src": image_url(),
5608
5620
  srcset_opts: {
package/dist/module.js CHANGED
@@ -3,7 +3,7 @@ import {template as $g9l4l$template, insert as $g9l4l$insert, effect as $g9l4l$e
3
3
  import {createSignal as $g9l4l$createSignal, onCleanup as $g9l4l$onCleanup, createComputed as $g9l4l$createComputed, createEffect as $g9l4l$createEffect, untrack as $g9l4l$untrack, batch as $g9l4l$batch, createResource as $g9l4l$createResource, createMemo as $g9l4l$createMemo, Show as $g9l4l$Show, createRenderEffect as $g9l4l$createRenderEffect, runWithOwner as $g9l4l$runWithOwner, createRoot as $g9l4l$createRoot, getOwner as $g9l4l$getOwner, on as $g9l4l$on, Index as $g9l4l$Index, For as $g9l4l$For, ErrorBoundary as $g9l4l$ErrorBoundary} from "solid-js";
4
4
 
5
5
  /*! Depict.ai search and product listing SDK */
6
- const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.25";
6
+ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.27";
7
7
 
8
8
 
9
9
 
@@ -4875,7 +4875,7 @@ function $a45c51e5e7aeb7f1$var$get_shared_properties(depict_category) {
4875
4875
 
4876
4876
 
4877
4877
 
4878
- const $6340962f8bafd049$var$_tmpl$ = /*#__PURE__*/ (0, $g9l4l$template)(`<div class="category-title"><span class="title"></span><span class="explanation"> — </span></div>`, 6);
4878
+ const $6340962f8bafd049$var$_tmpl$ = /*#__PURE__*/ (0, $g9l4l$template)(`<div class="category-title"><h2 class="title"></h2><span class="explanation"> — </span></div>`, 6);
4879
4879
  const $6340962f8bafd049$export$b91cec6bdc6b32a1 = /*@__PURE__*/ (()=>{
4880
4880
  const actual_function = ({ category_title_: category_title_ , product_count_: product_count_ })=>{
4881
4881
  return (()=>{
@@ -5092,7 +5092,10 @@ function $7a7079d66c12b788$export$d757d54550ebfb3d({ category_suggestion_: categ
5092
5092
  (0, $g9l4l$addEventListener)(_el$, "click", (0, $g9l4l$catchify)((e)=>{
5093
5093
  if (e.button || e.metaKey || e.ctrlKey) // Not single page navigating because button is not 0 or ctrl/command click
5094
5094
  return;
5095
- return on_navigation_?.(category_suggestion_().page_url);
5095
+ if (on_navigation_) {
5096
+ e.preventDefault();
5097
+ return on_navigation_(category_suggestion_().page_url);
5098
+ }
5096
5099
  }), true);
5097
5100
  (0, $g9l4l$insert)(_el$2, ()=>category_suggestion_().title);
5098
5101
  (0, $g9l4l$insert)(_el$, (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
@@ -5564,10 +5567,18 @@ function $4ad18a8b237ff7f6$export$2542ffb77b620b02(params_to_default_value) {
5564
5567
 
5565
5568
  const $d3c0043bb23a833f$var$_tmpl$ = /*#__PURE__*/ (0, $g9l4l$template)(`<span class="orig price"></span>`, 2), $d3c0043bb23a833f$var$_tmpl$2 = /*#__PURE__*/ (0, $g9l4l$template)(`<a class="instant-card"><div class="img-part"></div><div class="right-part"><div class="title-brand-tagline"><span class="brand"></span><span class="title"></span></div><div class="price-container"><span class="price"></span></div></div></a>`, 16), $d3c0043bb23a833f$var$_tmpl$3 = /*#__PURE__*/ (0, $g9l4l$template)(`<div class="tagline"></div>`, 2);
5566
5569
  const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n })=>{
5567
- // Support for Spendrups displays, should probably be in the Spendrups script
5568
5570
  const display = (0, $g9l4l$createMemo)(()=>{
5569
5571
  const display = display_or_variant_container();
5572
+ // Support for backend's new display format
5573
+ if ("variant_displays" in display && typeof display?.variant_index === "number") {
5574
+ const actual_display = display.variant_displays[display.variant_index];
5575
+ return {
5576
+ image_url: actual_display.image_urls?.[0],
5577
+ ...actual_display
5578
+ };
5579
+ }
5570
5580
  if (display.page_url) return display;
5581
+ // Support for Spendrups displays, should probably be in the Spendrups script
5571
5582
  if (!display?.variants?.length) return;
5572
5583
  return display.variants.filter((v)=>v.product_id == display.product_id)[0];
5573
5584
  });
@@ -5575,6 +5586,7 @@ const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container,
5575
5586
  const contained_image = (0, $g9l4l$createMemo)(()=>(0, $g9l4l$ContainedImage)({
5576
5587
  aspect_ratio: 1,
5577
5588
  alt: "",
5589
+ rendering_options: {},
5578
5590
  // @ts-ignore
5579
5591
  "data-src": image_url(),
5580
5592
  srcset_opts: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/ui",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "packageManager": "yarn@3.2.2",
5
5
  "source": [
6
6
  "src/index.ts",
@@ -65,7 +65,7 @@
65
65
  }
66
66
  },
67
67
  "dependencies": {
68
- "@depict-ai/utilishared": "^0.0.23",
68
+ "@depict-ai/utilishared": "^0.0.25",
69
69
  "solid-js": "^1.6.2"
70
70
  },
71
71
  "devDependencies": {
@@ -1,88 +0,0 @@
1
- import { Elem } from "@depict-ai/utilishared";
2
- /**
3
- * PLP internationalisation shared between search and category listing
4
- */
5
- type plp_shared_i18n = {
6
- scroll_to_top_: string;
7
- back_: string;
8
- open_sorting_: string;
9
- close_sorting_: string;
10
- open_filters_: string;
11
- close_filters_: string;
12
- close_: string;
13
- ok_: string;
14
- filters_cleared_: string;
15
- we_cleared_your_filters_: string;
16
- restore_: string;
17
- sorting_text_: string;
18
- filter_text_: string;
19
- selected_filters_title_: string;
20
- filters_: string;
21
- view_less_: string;
22
- view_more_: string;
23
- clear_all_from_filter_crumbs_: string;
24
- clear_individual_filter_: string;
25
- of_: string;
26
- clear_all_filters_from_big_button_: string;
27
- try_without_filters_: string;
28
- range_filter_low_point_aria_label_: string;
29
- range_filter_high_point_aria_label_: string;
30
- morphing_sign_expanded_aria_label_: string;
31
- morphing_sign_collapsed_aria_label_: string;
32
- price_formatting_: {
33
- pre_: string;
34
- post_: string;
35
- decimal_places_delimiter_: string;
36
- thousands_delimiter_: string;
37
- places_after_comma_: number | "auto";
38
- };
39
- };
40
- /**
41
- * Search internationalisation
42
- */
43
- interface search_i18n extends plp_shared_i18n {
44
- placeholder_text_: string;
45
- show_n_results_: (number_of_results: HTMLElement) => Elem[];
46
- no_results_text_: string;
47
- search_recs_title_: string;
48
- clear_filters_query_sorting_after_submit_: string;
49
- modal_view_all_results_: (number_of_results: HTMLElement) => Elem[];
50
- modal_discover_more_: string;
51
- get_showing_results_for_: (query: HTMLElement, number_of_results: HTMLElement) => Elem[];
52
- previous_searches_text_: string;
53
- category_: string;
54
- suggestions_: string;
55
- search_submit_button_aria_label_: string;
56
- query_input_field_aria_label_: string;
57
- previous_searches_delete_entry_from_history_: string;
58
- }
59
- /**
60
- * Category internationalisation
61
- */
62
- interface category_i18n extends plp_shared_i18n {
63
- show_n_products_: (number_of_results: HTMLElement) => Elem[];
64
- no_products_text_: string;
65
- product_: string;
66
- products_: string;
67
- breadcrumbs_aria_label_: string;
68
- quicklinks_aria_label_: string;
69
- breadcrumbs_separator_: string;
70
- }
71
- /**
72
- * Depict UI internationalisation
73
- */
74
- interface Locale extends category_i18n, search_i18n {
75
- }
76
- export const cz: Locale;
77
- export const da: Locale;
78
- export const nl: Locale;
79
- export const en: Locale;
80
- export const fi: Locale;
81
- export const fr: Locale;
82
- export const de: Locale;
83
- export const it: Locale;
84
- export const no: Locale;
85
- export const pl: Locale;
86
- export const pt: Locale;
87
- export const es: Locale;
88
- export const sv: Locale;