@depict-ai/ui 0.0.3 → 0.0.5

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,287 +1,14 @@
1
1
  import { Accessor, JSX, Setter, Signal } from "solid-js";
2
- import { SearchResponse } from "./typescript_schema/SearchResponse";
3
- import { SearchRequest } from "./typescript_schema/SearchRequest";
4
- import { BaseSearchRequest } from "./typescript_schema/BaseSearchRequest";
5
- import { SearchSuggestionsResponse } from "./typescript_schema/SearchSuggestionsResponse";
6
- import { SearchSuggestionsRequest } from "./typescript_schema/SearchSuggestionsRequest";
7
- import { ProductListingRequest } from "./typescript_schema/ProductListingRequest";
8
- import { ProductListingResponse, BaseCategoryDisplay } from "./typescript_schema/ProductListingResponse";
2
+ import { Display, Node_Array, Elem, Extended_RR_Options, LayoutOptions, TwoLetterMarket } from "@depict-ai/utilishared";
3
+ import { SearchResponse } from "@depict-ai/types/api/SearchResponse";
4
+ import { SearchRequest, SearchFilter } from "@depict-ai/types/api/SearchRequest";
5
+ import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
6
+ import { SearchSuggestionsResponse, CategorySuggestion } from "@depict-ai/types/api/SearchSuggestionsResponse";
7
+ import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
8
+ import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
9
+ import { ProductListingResponse, BaseCategoryDisplay } from "@depict-ai/types/api/ProductListingResponse";
9
10
  import { JSX as _JSX1 } from "solid-js/types/jsx";
10
- import { SearchFilter } from "./typescript_schema/SearchRequest";
11
- import { CategorySuggestion } from "./typescript_schema/SearchSuggestionsResponse";
12
- declare function dlog(...args: any[]): void;
13
- type IPNS<T> = ((...values: T[]) => void) & AsyncIterable<T> & {
14
- exit: () => void;
15
- state: T | undefined;
16
- latest_call_value: T | undefined;
17
- };
18
- declare const Sentry: {
19
- captureException: (...args: any[]) => void;
20
- captureMessage: (...args: any[]) => void;
21
- withScope: (...args: any[]) => void;
22
- };
23
- declare global {
24
- interface Window {
25
- Cookiebot?: {
26
- name: string;
27
- consented: boolean;
28
- declined: boolean;
29
- changed: boolean;
30
- hasResponse: boolean;
31
- consentID: string;
32
- consent: Consent;
33
- isOutsideEU: boolean;
34
- isOutOfRegion: boolean;
35
- host: string;
36
- domain: string;
37
- currentPath: string;
38
- doNotTrack: boolean;
39
- consentLevel: string;
40
- isRenewal: boolean;
41
- forceShow: boolean;
42
- dialog: null;
43
- responseMode: string;
44
- serial: string;
45
- scriptId: string;
46
- scriptElement: ScriptElement;
47
- whitelist: any[];
48
- cookieList: CookieList;
49
- pathlist: any[];
50
- userIsInPath: boolean;
51
- cookieEnabled: boolean;
52
- versionChecked: boolean;
53
- versionRequested: boolean;
54
- version: number;
55
- latestVersion: number;
56
- isNewVersion: boolean;
57
- CDN: string;
58
- source: string;
59
- retryCounter: number;
60
- frameRetryCounter: number;
61
- bulkConsentFrameRetryCounter: number;
62
- setOnloadFrameRetryCounter: number;
63
- optOutLifetime: number;
64
- consentLifetime: null;
65
- framework: string;
66
- hasFramework: boolean;
67
- frameworkBlocked: boolean;
68
- frameworkLoaded: boolean;
69
- iframeReady: boolean;
70
- iframe: Iframe;
71
- bulkconsent: null;
72
- bulkresetdomains: any[];
73
- bulkconsentsubmitted: boolean;
74
- isbulkrenewal: boolean;
75
- wipe: Wipe;
76
- consentUTC: Date;
77
- IABConsentString: string;
78
- GACMConsentString: string;
79
- dataLayerName: string;
80
- loaded: boolean;
81
- autoblock: boolean;
82
- mutationObserver: null;
83
- mutationCounter: number;
84
- mutationFallback: boolean;
85
- mutationFallbackDocAttributes: any[];
86
- mutationHandlerFallbackCharsetLoaded: boolean;
87
- mutationAppName: string;
88
- mutationEventListeners: any[];
89
- mutationOnloadEventListeners: any[];
90
- mutateEventListeners: boolean;
91
- mutationHandlerFirstScript: null;
92
- postPonedMutations: any[];
93
- nonAsyncMutations: any[];
94
- deferMutations: any[];
95
- geoRegions: any[];
96
- userCountry: string;
97
- userCulture: string;
98
- windowOnloadTriggered: boolean;
99
- botDetectionDisabled: boolean;
100
- regulations: Regulations;
101
- regulationRegions: RegulationRegions;
102
- commonTrackers: CommonTrackers;
103
- configuration: Configuration;
104
- inlineConfiguration: null;
105
- processLinkClickCounter: number;
106
- performanceEntriesCounter: number;
107
- OverrideEventListenersOnloadFired: any[];
108
- OverrideEventListenersOnloadToFire: any[];
109
- fallbackScriptNodes: any[];
110
- fallbackDeferNodes: any[];
111
- };
112
- }
113
- }
114
- declare global {
115
- interface Document {
116
- depictwashere: boolean;
117
- }
118
- }
119
- type IdType = string | undefined | Promise<string | undefined>;
120
- interface Tenant<ProductId extends IdType> {
121
- TENANT: string;
122
- tenant: string;
123
- MARKET: TwoLetterMarket;
124
- market: TwoLetterMarket;
125
- TYPE: string;
126
- type: string;
127
- GA_ID: string;
128
- gaid: string;
129
- get_product_id: (url?: string) => ProductId extends string | undefined ? string : Promise<string>;
130
- product_id: (url?: string) => string | Promise<string>;
131
- dataset: DOMStringMap;
132
- modify: boolean;
133
- is_debug: boolean;
134
- debug: boolean;
135
- dlog: typeof dlog;
136
- Sentry: typeof Sentry;
137
- catchify: <T extends Function>(fn: T) => T;
138
- err: (...errors: any[]) => undefined;
139
- }
140
- /**
141
- * Tenant class. This describes which site/customer one is on, in which market, and some more information. It also sends the page_view event if not already done and highlights elements with a `.depict` class if `localStorage['highlight-depict']` is `"true"`
142
- * @param options A object with constructor options
143
- */
144
- declare class Tenant<ProductId extends IdType = IdType> {
145
- constructor(options: {
146
- TENANT?: string;
147
- TYPE?: string;
148
- MARKET: TwoLetterMarket;
149
- GA_ID: string;
150
- get_product_id: (url?: string) => ProductId;
151
- current_script_override?: HTMLScriptElement;
152
- pageview_tracking?: boolean;
153
- });
154
- }
155
- /**
156
- * This is a list of alpha-2 country codes plus some two letter combinations commonly used to describe markets
157
- */
158
- type TwoLetterMarket = "af" | "al" | "dz" | "as" | "ad" | "ao" | "ai" | "aq" | "ag" | "ar" | "am" | "aw" | "au" | "at" | "az" | "bs" | "bh" | "bd" | "bb" | "by" | "be" | "bz" | "bj" | "bm" | "bt" | "bo" | "bq" | "ba" | "bw" | "bv" | "br" | "io" | "bn" | "bg" | "bf" | "bi" | "cv" | "kh" | "cm" | "ca" | "ky" | "cf" | "td" | "cl" | "cn" | "cx" | "cc" | "co" | "km" | "cd" | "cg" | "ck" | "cr" | "hr" | "cu" | "cw" | "cy" | "cz" | "ci" | "dk" | "dj" | "dm" | "do" | "ec" | "eg" | "sv" | "gq" | "er" | "ee" | "sz" | "et" | "fk" | "fo" | "fj" | "fi" | "fr" | "gf" | "pf" | "tf" | "ga" | "gm" | "ge" | "de" | "gh" | "gi" | "gr" | "gl" | "gd" | "gp" | "gu" | "gt" | "gg" | "gn" | "gw" | "gy" | "ht" | "hm" | "va" | "hn" | "hk" | "hu" | "is" | "in" | "id" | "ir" | "iq" | "ie" | "im" | "il" | "it" | "jm" | "jp" | "je" | "jo" | "kz" | "ke" | "ki" | "kp" | "kr" | "kw" | "kg" | "la" | "lv" | "lb" | "ls" | "lr" | "ly" | "li" | "lt" | "lu" | "mo" | "mg" | "mw" | "my" | "mv" | "ml" | "mt" | "mh" | "mq" | "mr" | "mu" | "yt" | "mx" | "fm" | "md" | "mc" | "mn" | "me" | "ms" | "ma" | "mz" | "mm" | "na" | "nr" | "np" | "nl" | "nc" | "nz" | "ni" | "ne" | "ng" | "nu" | "nf" | "mp" | "no" | "om" | "pk" | "pw" | "ps" | "pa" | "pg" | "py" | "pe" | "ph" | "pn" | "pl" | "pt" | "pr" | "qa" | "mk" | "ro" | "ru" | "rw" | "re" | "bl" | "sh" | "kn" | "lc" | "mf" | "pm" | "vc" | "ws" | "sm" | "st" | "sa" | "sn" | "rs" | "sc" | "sl" | "sg" | "sx" | "sk" | "si" | "sb" | "so" | "za" | "gs" | "ss" | "es" | "lk" | "sd" | "sr" | "sj" | "se" | "ch" | "sy" | "tw" | "tj" | "tz" | "th" | "tl" | "tg" | "tk" | "to" | "tt" | "tn" | "tr" | "tm" | "tc" | "tv" | "ug" | "ua" | "ae" | "gb" | "um" | "us" | "uy" | "uz" | "vu" | "ve" | "vn" | "vg" | "vi" | "wf" | "eh" | "ye" | "zm" | "zw" | "ax" | "uk" | "en" | "da" | "eu" | "sv" | "oc" | "nb" | "sq";
159
- type ExclusiveId = {
160
- category_id: string;
161
- product_id?: undefined;
162
- product_ids?: undefined;
163
- } | {
164
- category_id?: undefined;
165
- product_id: string;
166
- product_ids?: undefined;
167
- } | {
168
- category_id?: undefined;
169
- product_id?: undefined;
170
- product_ids: string[];
171
- } | {
172
- category_id?: undefined;
173
- product_id?: undefined;
174
- product_ids?: undefined;
175
- };
176
- type FetchRecsOptions = {
177
- type: string;
178
- } & ExclusiveId;
179
- declare class InfoForProcessing {
180
- constructor(t: Tenant, rendering_options: RR_Options, displays: Display[], index?: number, remove_display?: () => void, event_listeners?: [
181
- type: keyof HTMLElementEventMap,
182
- listener: (this: HTMLElement, ev: HTMLElementEventMap[keyof HTMLElementEventMap]) => any,
183
- options?: boolean | AddEventListenerOptions
184
- ][]);
185
- }
186
- type RegisterEventListener = (type: keyof HTMLElementEventMap, listener: (this: HTMLElement, ev: HTMLElementEventMap[keyof HTMLElementEventMap]) => any, options?: boolean | AddEventListenerOptions) => void;
187
- interface InfoForProcessing {
188
- t: Tenant;
189
- rendering_options: RR_Options;
190
- displays: Display[];
191
- index: number;
192
- remove_display?: () => void;
193
- register_event_listener: RegisterEventListener;
194
- event_listeners?: [
195
- type: keyof HTMLElementEventMap,
196
- listener: (this: HTMLElement, ev: HTMLElementEventMap[keyof HTMLElementEventMap]) => any,
197
- options?: boolean | AddEventListenerOptions
198
- ][];
199
- extras?: {
200
- [key: string]: any;
201
- };
202
- }
203
- type RR_PreProcessor = (display: Display, info: InfoForProcessing) => Promise<Display> | Display;
204
- type RR_PostProcessor = (elements: NodeListOf<ChildNode> | Node_Array, display: Display, info: InfoForProcessing) => Promise<NodeListOf<ChildNode> | Node_Array> | NodeListOf<ChildNode> | Node_Array;
205
- type RR_Options = {
206
- template: string | ((arg0: Display, info: InfoForProcessing) => Promise<string | Node_Array> | string | Node_Array);
207
- recs?: Display[] | undefined | Promise<Display[] | undefined>;
208
- type: string;
209
- min_items_to_report?: number;
210
- min_items_to_run?: number;
211
- max_items?: number;
212
- extra_api_options?: {
213
- [key: string]: any;
214
- };
215
- pre_processors?: RR_PreProcessor[];
216
- post_processors?: RR_PostProcessor[];
217
- headers?: HeadersInit;
218
- } & FetchRecsOptions;
219
- interface Display {
220
- page_url: string;
221
- image_url: string;
222
- sale_price: number;
223
- original_price: number;
224
- product_id: string;
225
- ga_product_id?: string;
226
- ga_product_ids?: string[];
227
- variant_ids?: string[];
228
- recommendation_id: string;
229
- title: string;
230
- search_result_id?: string;
231
- [key: string]: any;
232
- }
233
- type Node_Array = (Element | Text | Comment)[];
234
- type Extended_RR_Options = {
235
- view_tracking?: RR_PostProcessor[];
236
- click_tracking?: RR_PostProcessor[];
237
- } & RR_Options;
238
- declare global {
239
- interface HTMLImageElementWithLoaded extends HTMLImageElement {
240
- loaded?: boolean;
241
- }
242
- interface HTMLSourceElementWithLoaded extends HTMLSourceElement {
243
- loaded?: boolean;
244
- }
245
- }
246
- declare global {
247
- interface Document {
248
- _depict_modify: boolean | undefined;
249
- }
250
- }
251
- type Elem = Node | string;
252
- /** Overrides that can specify a different amount of columns for certain rows
253
- * @param key The row (starts at 1) that you're "selecting" to override
254
- * @param value The amount of columns that your selected row should have
255
- */
256
- type Override = {
257
- overrides: Record</* Row: */ number, /* Column: */ number>;
258
- };
259
- type ColAtSize = /** [ <number of columns>, <max-width>, <min-width>, <spacing> ] */ readonly [number, null, string, string | null] | readonly [number, string, string, null, Override] | readonly [number, string, null, string | null] | readonly [number, string, string, string | null] | readonly [number, string, null] | readonly [number, string, string] | readonly [number, null, string] | readonly [number, string];
260
- type ColsAtSize = readonly ColAtSize[];
261
- type LayoutOptions = {
262
- container_element: Element;
263
- cols_at_size: ColsAtSize;
264
- grid_spacing: string;
265
- rows: {
266
- start_rows?: number;
267
- rows_per_click?: number;
268
- ipns?: IPNS<number>;
269
- max_rows?: number;
270
- button?: HTMLElement;
271
- } | "all";
272
- layout: "slider" | "grid";
273
- disable_partial_rows?: boolean;
274
- override_vertical_spacing?: string;
275
- };
276
- declare global {
277
- interface Window {
278
- ShopifyAnalytics: {
279
- meta?: {
280
- product?: ShopifyMetaProduct;
281
- };
282
- };
283
- }
284
- }
11
+ import { InfoForProcessing } from "@depict-ai/utilishared/src";
285
12
  export const CategoryTitle: ({ category_title_, product_count_, }: {
286
13
  category_title_: Accessor<string | undefined>;
287
14
  product_count_: JSX.Element;
@@ -1449,7 +1176,6 @@ export interface category_i18n extends plp_shared_i18n {
1449
1176
  quicklinks_aria_label_: Accessor<string>;
1450
1177
  breadcrumbs_separator_: Accessor<string>;
1451
1178
  }
1452
- type AlternativeQuerySubmitterForSPAs = (search_param_name: string, new_search_query: string, url_transformer?: (url_object: URL) => unknown) => unknown;
1453
1179
  export type WithRequired<T, K extends keyof T> = T & {
1454
1180
  [P in K]-?: T[P];
1455
1181
  };
@@ -1471,6 +1197,9 @@ type ConstructorOptions = {
1471
1197
  rr_options_: Omit<Extended_RR_Options, "type" | "recs" | "category_id" | "product_id" | "product_ids">;
1472
1198
  get_product_id_: (url?: string) => string | Promise<string>;
1473
1199
  };
1200
+ /**
1201
+ * TODO: this is not yet the SDK, we still have to change this to conform to the SDK docs
1202
+ */
1474
1203
  export class Category {
1475
1204
  #private;
1476
1205
  constructor(opts: ConstructorOptions);
@@ -1496,72 +1225,59 @@ export type RenderCategorySuggestion = (category_suggestion: Accessor<CategorySu
1496
1225
  op: WithRequired<SearchFilter, "op">["op"];
1497
1226
  data: WithRequired<SearchFilter, "data">["data"];
1498
1227
  }[]>) => JSX.Element;
1499
- declare function QueryInput({ search_field_value_, input_field_ref_, submit_query_, override_on_enter_, clear_filters_, disabled_, on_back_, i18n_, }: {
1500
- search_query_: Signal<string>;
1501
- search_field_value_: Signal<string>;
1502
- input_field_ref_?: (el: HTMLInputElement) => any;
1503
- disabled_?: boolean;
1504
- override_on_enter_?: (e: KeyboardEvent) => true | false | undefined;
1505
- submit_query_: VoidFunction;
1506
- clear_filters_: VoidFunction;
1507
- on_back_?: VoidFunction;
1508
- i18n_: search_i18n;
1509
- }): HTMLDivElement;
1228
+ type SDKColsAtSize = [number, number?][];
1510
1229
  type _ConstructorOptions1 = {
1511
- search_page_: {
1512
- append_instead_of_replace_?: boolean;
1513
- include_input_field_?: boolean | {
1514
- on_open_?: VoidFunction;
1515
- on_close_?: VoidFunction;
1516
- };
1517
- page_title_?: string;
1518
- is_search_page_: (url: URL) => boolean;
1519
- slider_arrow_button_: SVGElement | HTMLElement;
1520
- search_query_param_name_?: string;
1521
- selector_for_page_to_replace_: string;
1522
- make_category_suggestion_card_: RenderCategorySuggestion | false;
1523
- wrap_search_page_?: (search_page_elements: Node_Array) => Node_Array;
1524
- rr_options_: Omit<Extended_RR_Options, "type" | "recs" | "category_id" | "product_id" | "product_ids">;
1525
- recommendations_rr_options_?: _ConstructorOptions1["search_page_"]["rr_options_"];
1526
- layout_options_: Omit<LayoutOptions, "container_element" | "layout" | "rows">;
1527
- recommendations_layout_options_?: _ConstructorOptions1["search_page_"]["layout_options_"];
1528
- search_recs_view_more_?: boolean;
1529
- get_product_id_: (url?: string) => string | Promise<string>;
1530
- };
1531
- page_replacer_ref_: (pr: PageReplacer) => void;
1532
- depict_api_: DepictAPI;
1533
- url_transformer_: ((url_object: URL) => unknown) | undefined;
1534
- alternative_query_submitter_for_spas_?: AlternativeQuerySubmitterForSPAs;
1535
- modal_options_: {
1536
- render_instant_card_: (display: Accessor<Display>, index: number, get_fake_rendering_options: Accessor<RR_Options>, i18n_: search_i18n) => _JSX1.Element;
1537
- render_instant_card_placeholder_: () => HTMLElement;
1538
- bottom_distance_under_modal_?: Accessor<number | undefined>;
1539
- disable_scrolling_?: boolean;
1230
+ search_query_url_param_name?: string;
1231
+ market: string;
1232
+ merchant: string;
1233
+ localization: {
1234
+ [K in keyof search_i18n]: ReturnType<search_i18n[K]>;
1540
1235
  };
1541
- /** Should category suggestions be included in SearchModal and SearchPage? Defaults to true */
1542
- enable_category_suggestions_?: boolean;
1236
+ on_navigation?: (href: string) => unknown;
1237
+ url_transformer?: (url_object: URL) => unknown;
1238
+ enable_category_suggestions?: boolean;
1543
1239
  };
1544
- export class Search {
1240
+ type OpenModalArguments = [
1241
+ options_for_modal?: {
1242
+ style_props_?: Signal<_JSX1.CSSProperties>;
1243
+ closing_animation_?: () => Promise<any>;
1244
+ class_list_?: Accessor<Record<string, boolean>>;
1245
+ },
1246
+ on_dispose?: VoidFunction
1247
+ ];
1248
+ type SDKGridSpacing = string | {
1249
+ horizontal: string;
1250
+ vertical: string;
1251
+ };
1252
+ export const get_search_query_updating_blocked_signal: (depict_search: DepictSearch) => Signal<boolean> | undefined;
1253
+ export class DepictSearch {
1545
1254
  #private;
1546
- constructor(opts: _ConstructorOptions1);
1547
- get locale_(): {
1255
+ constructor({ search_query_url_param_name, url_transformer, on_navigation, enable_category_suggestions, ...props_on_class }: _ConstructorOptions1);
1256
+ get localization(): {
1548
1257
  [K in keyof search_i18n]: ReturnType<search_i18n[K]>;
1549
1258
  };
1550
- set locale_(locale_obj: {
1259
+ set localization(locale_obj: {
1551
1260
  [K in keyof search_i18n]: ReturnType<search_i18n[K]>;
1552
1261
  });
1553
- get readonly_modal_open_(): boolean;
1554
- get tenant_(): string;
1555
- set tenant_(tenant: string);
1556
- get market_(): TwoLetterMarket;
1557
- set market_(market: TwoLetterMarket);
1558
- get boot_(): () => Promise<{
1559
- readonly close_modal_: VoidFunction;
1560
- readonly open_modal_: (arg0: {
1561
- style_props_?: Signal<_JSX1.CSSProperties> | undefined;
1562
- closing_animation_?: (() => Promise<any>) | undefined;
1563
- class_list_?: Accessor<Record<string, boolean>> | undefined;
1564
- }, on_dispose?: VoidFunction | undefined) => void;
1565
- }>;
1566
- get get_query_input(): (opts?: Omit<Partial<Parameters<typeof QueryInput>[0]>, "clear_filters_" | "search_query_" | "submit_query_" | "i18n_" | "search_field_value_">) => HTMLDivElement;
1262
+ get modal_open(): OpenModalArguments | boolean;
1263
+ set modal_open(new_state: OpenModalArguments | boolean);
1264
+ get merchant(): string;
1265
+ set merchant(tenant: string);
1266
+ get market(): string;
1267
+ set market(market: string);
1567
1268
  }
1269
+ export function SearchPage({ depict_search, include_input_field, grid_spacing, cols_at_size, product_card_template, get_product_id, }: {
1270
+ depict_search: DepictSearch;
1271
+ include_input_field?: boolean | {
1272
+ on_open_?: VoidFunction;
1273
+ on_close_?: VoidFunction;
1274
+ };
1275
+ grid_spacing: SDKGridSpacing;
1276
+ cols_at_size: SDKColsAtSize;
1277
+ product_card_template: (display: Display, info: InfoForProcessing) => Promise<Node_Array> | Node_Array;
1278
+ get_product_id: (url?: string) => string | Promise<string>;
1279
+ }): Node_Array;
1280
+ export function SearchField({ depict_search, modal_dispose_handler, }: {
1281
+ depict_search: DepictSearch;
1282
+ modal_dispose_handler?: VoidFunction;
1283
+ }): Node_Array;