@swishapp/sdk 0.133.0 → 0.134.0

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.
@@ -51,6 +51,16 @@ export interface Cart {
51
51
  items_subtotal_price: number;
52
52
  cart_level_discount_applications: any[];
53
53
  }
54
+ export interface AjaxProduct {
55
+ id: number;
56
+ handle: string;
57
+ options: AjaxProductOption[];
58
+ }
59
+ export interface AjaxProductOption {
60
+ name: string;
61
+ position: number;
62
+ values: string[];
63
+ }
54
64
  export interface AddToCartItem {
55
65
  id: string | number;
56
66
  quantity: number;
@@ -99,6 +109,7 @@ export declare class AjaxApiClient {
99
109
  fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
100
110
  private request;
101
111
  fetchCart(): Promise<Cart>;
112
+ fetchProduct(handle: string): Promise<AjaxProduct>;
102
113
  addToCart(request: AddToCartRequest): Promise<AddToCartResponse>;
103
114
  clearCache(): Promise<void>;
104
115
  }
@@ -0,0 +1 @@
1
+ export { isCustomiserMounted, isCustomiserRequested, mountCustomiser, mountCustomiserIfRequested, unmountCustomiser, type CustomiserMountOptions, } from "./mount";
@@ -0,0 +1,13 @@
1
+ export type CustomiserMountOptions = {
2
+ /** CDN root, e.g. `https://swish.app/cdn`. The customiser bundle is loaded
3
+ * from `${baseUrl}/customiser/`. Defaults to the production CDN. */
4
+ baseUrl?: string;
5
+ /** Shop identifier passed to the customiser as part of the context message
6
+ * (scopes its persistence). Typically `context.myshopifyDomain`. */
7
+ shop?: string;
8
+ };
9
+ export declare const isCustomiserRequested: () => boolean;
10
+ export declare const mountCustomiserIfRequested: (opts?: CustomiserMountOptions) => void;
11
+ export declare const mountCustomiser: (url: string, shop?: string, themeId?: string) => void;
12
+ export declare const unmountCustomiser: () => void;
13
+ export declare const isCustomiserMounted: () => boolean;
@@ -16,7 +16,7 @@ export type ResponsiveValue<T> = T | {
16
16
  base?: T;
17
17
  [breakpoint: string]: T | undefined;
18
18
  };
19
- type ElementName = "save-button" | "home-button";
19
+ type ElementName = "save-button" | "header-button";
20
20
  export type SaveButtonDesignSpec = {
21
21
  background?: ResponsiveValue<string>;
22
22
  savedBackground?: ResponsiveValue<string>;
@@ -33,7 +33,7 @@ export type HomeButtonDesignSpec = {
33
33
  };
34
34
  type DesignSpecMap = {
35
35
  "save-button": SaveButtonDesignSpec;
36
- "home-button": HomeButtonDesignSpec;
36
+ "header-button": HomeButtonDesignSpec;
37
37
  };
38
38
  export type DesignSpecForElementName<TName extends ElementName = ElementName> = TName extends keyof DesignSpecMap ? DesignSpecMap[TName] : never;
39
39
  export type MountMode = "before" | "after" | "append" | "prepend" | "replace";
@@ -0,0 +1,7 @@
1
+ export type PageType = "pdp" | "collection" | "cart" | "home" | "other";
2
+ export type PageInfo = {
3
+ type: PageType;
4
+ productHandle?: string;
5
+ collectionHandle?: string;
6
+ };
7
+ export declare const getPageInfo: (loc?: URL | Location | string) => PageInfo;
@@ -1,6 +1,6 @@
1
1
  declare const BaseElement: typeof HTMLElement;
2
2
  export declare class SwishSaveElement extends BaseElement {
3
- static get observedAttributes(): ("product" | "variant" | "match" | "context")[];
3
+ static get observedAttributes(): ("product" | "variant" | "context" | "match")[];
4
4
  private disposers;
5
5
  private state;
6
6
  private deferredReady;
@@ -1,4 +1,4 @@
1
- export type EventName = "cart-add" | "cart-update" | "cart-change" | "cart-clear" | "item-create" | "item-update" | "item-delete" | "item-lists-update" | "list-create" | "list-update" | "list-delete" | "notification-update" | "notification-delete" | "auth-cache-clear" | "token-update";
1
+ export type EventName = "cart-add" | "cart-update" | "cart-change" | "cart-clear" | "item-create" | "item-update" | "item-delete" | "item-lists-update" | "list-create" | "list-update" | "list-delete" | "notification-update" | "notification-delete" | "auth-cache-clear" | "token-update" | "drawer-state-change" | "placement-warning";
2
2
  export declare class EventBus {
3
3
  private readonly eventBus;
4
4
  subscribe(type: EventName | EventName[], callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): () => void;
@@ -1,6 +1,34 @@
1
1
  import { SwishApp } from "../swish";
2
2
  import { SwishUi } from "../swish-ui/swish-ui";
3
- import type { Product, ProductVariant } from "../types";
3
+ import type { PreviewOptions, Product, ProductVariant } from "../types";
4
+ import { CreateCartLineHandler } from "./handlers/create-cart-line-handler";
5
+ import { CreateListHandler } from "./handlers/create-list-handler";
6
+ import { DeleteListHandler } from "./handlers/delete-list-handler";
7
+ import { EditItemListsHandler } from "./handlers/edit-item-lists-handler";
8
+ import { EditItemVariantHandler } from "./handlers/edit-item-variant-handler";
9
+ import { EditListAccessHandler } from "./handlers/edit-list-access-handler";
10
+ import { EditListHandler } from "./handlers/edit-list-handler";
11
+ import { InitiateCheckoutHandler } from "./handlers/initiate-checkout-handler";
12
+ import { InitiateQuickBuyHandler } from "./handlers/initiate-quick-buy-handler";
13
+ import { InitiateSignInHandler } from "./handlers/initiate-sign-in-handler";
14
+ import { InitiateSignOutHandler } from "./handlers/initiate-sign-out-handler";
15
+ import { SaveCartLineHandler } from "./handlers/save-cart-line-handler";
16
+ import { SaveItemHandler } from "./handlers/save-item-handler";
17
+ import { ShareListHandler } from "./handlers/share-list-handler";
18
+ import { ShowToastHandler } from "./handlers/show-toast-handler";
19
+ import { UnsaveItemHandler } from "./handlers/unsave-item-handler";
20
+ import { ViewHomeHandler } from "./handlers/view-home-handler";
21
+ import { ViewListDetailPageMenuHandler } from "./handlers/view-list-detail-page-menu-handler";
22
+ import { ViewListHandler } from "./handlers/view-list-handler";
23
+ import { ViewListMenuHandler } from "./handlers/view-list-menu-handler";
24
+ import { ViewListsHandler } from "./handlers/view-lists-handler";
25
+ import { ViewNotificationsHandler } from "./handlers/view-notifications-handler";
26
+ import { ViewOrderHandler } from "./handlers/view-order-handler";
27
+ import { ViewOrderMenuHandler } from "./handlers/view-order-menu-handler";
28
+ import { ViewOrdersHandler } from "./handlers/view-orders-handler";
29
+ import { ViewProductHandler } from "./handlers/view-product-handler";
30
+ import { ViewProfileHandler } from "./handlers/view-profile-handler";
31
+ import { ViewSavesHandler } from "./handlers/view-saves-handler";
4
32
  import { Intent, IntentActivity, IntentQueryWithParams, IntentResponse, IntentToData } from "./types";
5
33
  export interface IntentOptions {
6
34
  saveProduct: {
@@ -40,10 +68,41 @@ export declare class Intents {
40
68
  private readonly swish;
41
69
  private readonly ui;
42
70
  private readonly eventBus;
43
- private readonly options;
44
- private readonly handlers;
71
+ private options;
72
+ private handlers;
45
73
  private _invoking;
46
74
  constructor(swish: SwishApp, ui: SwishUi);
75
+ applyPreview(preview: PreviewOptions["intents"]): void;
76
+ initHandlers(): {
77
+ "create:cart-line": CreateCartLineHandler;
78
+ "initiate:checkout": InitiateCheckoutHandler;
79
+ "save:item": SaveItemHandler;
80
+ "save:cart-line": SaveCartLineHandler;
81
+ "unsave:item": UnsaveItemHandler;
82
+ "edit:item-variant": EditItemVariantHandler;
83
+ "edit:item-lists": EditItemListsHandler;
84
+ "create:list": CreateListHandler;
85
+ "edit:list": EditListHandler;
86
+ "edit:list-access": EditListAccessHandler;
87
+ "delete:list": DeleteListHandler;
88
+ "view:home": ViewHomeHandler;
89
+ "initiate:share": ShareListHandler;
90
+ "view:list": ViewListHandler;
91
+ "view:lists": ViewListsHandler;
92
+ "view:orders": ViewOrdersHandler;
93
+ "view:order": ViewOrderHandler;
94
+ "view:saves": ViewSavesHandler;
95
+ "view:notifications": ViewNotificationsHandler;
96
+ "view:profile": ViewProfileHandler;
97
+ "view:product": ViewProductHandler;
98
+ "view:list-menu": ViewListMenuHandler;
99
+ "view:order-menu": ViewOrderMenuHandler;
100
+ "view:list-detail-page-menu": ViewListDetailPageMenuHandler;
101
+ "initiate:sign-in": InitiateSignInHandler;
102
+ "initiate:sign-out": InitiateSignOutHandler;
103
+ "initiate:quick-buy": InitiateQuickBuyHandler;
104
+ "show:toast": ShowToastHandler;
105
+ };
47
106
  publishAnalyticsEvent(event: string, data: Record<string, any>): void;
48
107
  invoke<I extends Intent>(intent: I, ...args: IntentToData<I> extends void ? [] | [undefined] : [IntentToData<I>]): Promise<IntentActivity<I, IntentToData<I>>>;
49
108
  listen<I extends Intent>(intent: I, callback: (response: IntentResponse<I>) => void): () => void;
@@ -152,15 +152,21 @@ export declare const SavesSectionSchema: v.VariantSchema<"type", [v.ObjectSchema
152
152
  readonly options: v.OptionalSchema<v.ObjectSchema<{
153
153
  readonly showSaveButton: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
154
154
  readonly showQuickBuyButton: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
155
+ readonly showBuyButton: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
155
156
  readonly showVariantTitle: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
156
157
  readonly enableVariantChange: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
157
158
  readonly showVariantOptionNames: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
159
+ readonly hideCompareAtPrice: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
160
+ readonly linkToProductPage: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
158
161
  }, undefined>, {
159
162
  readonly showSaveButton: true;
160
163
  readonly showQuickBuyButton: true;
164
+ readonly showBuyButton: false;
161
165
  readonly showVariantTitle: true;
162
166
  readonly enableVariantChange: false;
163
167
  readonly showVariantOptionNames: true;
168
+ readonly hideCompareAtPrice: false;
169
+ readonly linkToProductPage: false;
164
170
  }>;
165
171
  }, undefined>], undefined>;
166
172
  export declare const ListsSectionSchema: v.ObjectSchema<{
@@ -180,13 +186,19 @@ export declare const ListDetailPageSectionSchema: v.ObjectSchema<{
180
186
  readonly options: v.OptionalSchema<v.ObjectSchema<{
181
187
  readonly desktopColumns: v.OptionalSchema<v.NumberSchema<undefined>, 4>;
182
188
  readonly showBuyButton: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
189
+ readonly showVariantTitle: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
183
190
  readonly showVariantOptionNames: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
184
191
  readonly enableVariantChange: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
192
+ readonly hideCompareAtPrice: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
193
+ readonly linkToProductPage: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
185
194
  }, undefined>, {
186
195
  readonly desktopColumns: 4;
187
196
  readonly showBuyButton: true;
197
+ readonly showVariantTitle: true;
188
198
  readonly showVariantOptionNames: false;
189
199
  readonly enableVariantChange: true;
200
+ readonly hideCompareAtPrice: false;
201
+ readonly linkToProductPage: true;
190
202
  }>;
191
203
  }, undefined>;
192
204
  export declare const ListDetailSectionSchema: v.ObjectSchema<{
@@ -194,11 +206,19 @@ export declare const ListDetailSectionSchema: v.ObjectSchema<{
194
206
  readonly hidden: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
195
207
  readonly design: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, {}>;
196
208
  readonly options: v.OptionalSchema<v.ObjectSchema<{
209
+ readonly showBuyButton: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
210
+ readonly showVariantTitle: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
197
211
  readonly showVariantOptionNames: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
198
212
  readonly enableVariantChange: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
213
+ readonly hideCompareAtPrice: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
214
+ readonly linkToProductPage: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
199
215
  }, undefined>, {
216
+ readonly showBuyButton: false;
217
+ readonly showVariantTitle: true;
200
218
  readonly showVariantOptionNames: false;
201
219
  readonly enableVariantChange: false;
220
+ readonly hideCompareAtPrice: false;
221
+ readonly linkToProductPage: false;
202
222
  }>;
203
223
  }, undefined>;
204
224
  export declare const OrdersSectionSchema: v.ObjectSchema<{
@@ -578,15 +598,21 @@ export declare const SavesViewSchema: v.ObjectSchema<{
578
598
  readonly options: v.OptionalSchema<v.ObjectSchema<{
579
599
  readonly showSaveButton: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
580
600
  readonly showQuickBuyButton: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
601
+ readonly showBuyButton: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
581
602
  readonly showVariantTitle: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
582
603
  readonly enableVariantChange: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
583
604
  readonly showVariantOptionNames: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
605
+ readonly hideCompareAtPrice: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
606
+ readonly linkToProductPage: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
584
607
  }, undefined>, {
585
608
  readonly showSaveButton: true;
586
609
  readonly showQuickBuyButton: true;
610
+ readonly showBuyButton: false;
587
611
  readonly showVariantTitle: true;
588
612
  readonly enableVariantChange: false;
589
613
  readonly showVariantOptionNames: true;
614
+ readonly hideCompareAtPrice: false;
615
+ readonly linkToProductPage: false;
590
616
  }>;
591
617
  }, undefined>], undefined>, undefined>, readonly [{
592
618
  readonly type: "lists-section";
@@ -624,13 +650,19 @@ export declare const ListDetailPageViewSchema: v.ObjectSchema<{
624
650
  readonly options: v.OptionalSchema<v.ObjectSchema<{
625
651
  readonly desktopColumns: v.OptionalSchema<v.NumberSchema<undefined>, 4>;
626
652
  readonly showBuyButton: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
653
+ readonly showVariantTitle: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
627
654
  readonly showVariantOptionNames: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
628
655
  readonly enableVariantChange: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
656
+ readonly hideCompareAtPrice: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
657
+ readonly linkToProductPage: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
629
658
  }, undefined>, {
630
659
  readonly desktopColumns: 4;
631
660
  readonly showBuyButton: true;
661
+ readonly showVariantTitle: true;
632
662
  readonly showVariantOptionNames: false;
633
663
  readonly enableVariantChange: true;
664
+ readonly hideCompareAtPrice: false;
665
+ readonly linkToProductPage: true;
634
666
  }>;
635
667
  }, undefined>, undefined>, readonly [{
636
668
  readonly type: "list-items-grid";
@@ -642,11 +674,19 @@ export declare const ListDetailViewSchema: v.ObjectSchema<{
642
674
  readonly hidden: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
643
675
  readonly design: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, {}>;
644
676
  readonly options: v.OptionalSchema<v.ObjectSchema<{
677
+ readonly showBuyButton: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
678
+ readonly showVariantTitle: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
645
679
  readonly showVariantOptionNames: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
646
680
  readonly enableVariantChange: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
681
+ readonly hideCompareAtPrice: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
682
+ readonly linkToProductPage: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
647
683
  }, undefined>, {
684
+ readonly showBuyButton: false;
685
+ readonly showVariantTitle: true;
648
686
  readonly showVariantOptionNames: false;
649
687
  readonly enableVariantChange: false;
688
+ readonly hideCompareAtPrice: false;
689
+ readonly linkToProductPage: false;
650
690
  }>;
651
691
  }, undefined>, undefined>, readonly [{
652
692
  readonly type: "list-items-grid";
@@ -1078,15 +1118,21 @@ export declare const UiSchema: v.ObjectSchema<{
1078
1118
  readonly options: v.OptionalSchema<v.ObjectSchema<{
1079
1119
  readonly showSaveButton: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
1080
1120
  readonly showQuickBuyButton: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
1121
+ readonly showBuyButton: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1081
1122
  readonly showVariantTitle: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
1082
1123
  readonly enableVariantChange: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1083
1124
  readonly showVariantOptionNames: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
1125
+ readonly hideCompareAtPrice: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1126
+ readonly linkToProductPage: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1084
1127
  }, undefined>, {
1085
1128
  readonly showSaveButton: true;
1086
1129
  readonly showQuickBuyButton: true;
1130
+ readonly showBuyButton: false;
1087
1131
  readonly showVariantTitle: true;
1088
1132
  readonly enableVariantChange: false;
1089
1133
  readonly showVariantOptionNames: true;
1134
+ readonly hideCompareAtPrice: false;
1135
+ readonly linkToProductPage: false;
1090
1136
  }>;
1091
1137
  }, undefined>], undefined>, undefined>, readonly [{
1092
1138
  readonly type: "lists-section";
@@ -1122,11 +1168,19 @@ export declare const UiSchema: v.ObjectSchema<{
1122
1168
  readonly hidden: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1123
1169
  readonly design: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, {}>;
1124
1170
  readonly options: v.OptionalSchema<v.ObjectSchema<{
1171
+ readonly showBuyButton: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1172
+ readonly showVariantTitle: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
1125
1173
  readonly showVariantOptionNames: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1126
1174
  readonly enableVariantChange: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1175
+ readonly hideCompareAtPrice: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1176
+ readonly linkToProductPage: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1127
1177
  }, undefined>, {
1178
+ readonly showBuyButton: false;
1179
+ readonly showVariantTitle: true;
1128
1180
  readonly showVariantOptionNames: false;
1129
1181
  readonly enableVariantChange: false;
1182
+ readonly hideCompareAtPrice: false;
1183
+ readonly linkToProductPage: false;
1130
1184
  }>;
1131
1185
  }, undefined>, undefined>, readonly [{
1132
1186
  readonly type: "list-items-grid";
@@ -1140,13 +1194,19 @@ export declare const UiSchema: v.ObjectSchema<{
1140
1194
  readonly options: v.OptionalSchema<v.ObjectSchema<{
1141
1195
  readonly desktopColumns: v.OptionalSchema<v.NumberSchema<undefined>, 4>;
1142
1196
  readonly showBuyButton: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
1197
+ readonly showVariantTitle: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
1143
1198
  readonly showVariantOptionNames: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1144
1199
  readonly enableVariantChange: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
1200
+ readonly hideCompareAtPrice: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1201
+ readonly linkToProductPage: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
1145
1202
  }, undefined>, {
1146
1203
  readonly desktopColumns: 4;
1147
1204
  readonly showBuyButton: true;
1205
+ readonly showVariantTitle: true;
1148
1206
  readonly showVariantOptionNames: false;
1149
1207
  readonly enableVariantChange: true;
1208
+ readonly hideCompareAtPrice: false;
1209
+ readonly linkToProductPage: true;
1150
1210
  }>;
1151
1211
  }, undefined>, undefined>, readonly [{
1152
1212
  readonly type: "list-items-grid";
@@ -13,6 +13,9 @@ export type SwishOptionsInput = {
13
13
  intents?: Partial<IntentOptions>;
14
14
  placements?: PlacementSpec[];
15
15
  ui?: Partial<UiOptions>;
16
+ customiser?: {
17
+ baseUrl?: string;
18
+ };
16
19
  };
17
20
  interface UiOptions {
18
21
  baseUrl?: string;
@@ -75,6 +75,13 @@ export interface TransformOptions {
75
75
  option: NonNullable<Product>["options"][number];
76
76
  optionValues: NonNullable<Product>["options"][number]["optionValues"];
77
77
  }) => NonNullable<Product>["options"][number]["optionValues"];
78
+ combinedListingParent?: (args: {
79
+ product: Product;
80
+ }) => boolean | string;
81
+ hideOption?: (args: {
82
+ option: NonNullable<Product>["options"][number];
83
+ product: Product;
84
+ }) => boolean;
78
85
  }
79
86
  export type TransformOptionsResolved = Required<TransformOptions>;
80
87
  export type UiOptions = UiOptionsParsed;
@@ -1,4 +1,5 @@
1
1
  export { signal, effect, computed } from "@preact/signals-core";
2
+ export type { Signal, ReadonlySignal } from "@preact/signals-core";
2
3
  export * from "./item-context-signal";
3
4
  export * from "./item-state-signal";
4
5
  export * from "./item-count-signal";
@@ -0,0 +1,11 @@
1
+ import { StorefrontApiClient, StorefrontApiResponse } from "./storefront-api-client";
2
+ import type { GetProductHandleByIdQuery } from "./types/storefront.generated";
3
+ export type LoadProductHandleResponse = StorefrontApiResponse<GetProductHandleByIdQuery>;
4
+ export type { GetProductHandleByIdQueryVariables } from "./types/storefront.generated";
5
+ export interface LoadProductHandleArgs {
6
+ productId?: string | number;
7
+ }
8
+ export declare const loadProductHandle: (client: StorefrontApiClient, { productId }: LoadProductHandleArgs) => Promise<{
9
+ data: GetProductHandleByIdQuery | undefined;
10
+ errors: import("@shopify/graphql-client").ResponseErrors | null;
11
+ }>;
@@ -15,7 +15,7 @@ export interface LoadProductImagesArgs {
15
15
  language: LanguageCode;
16
16
  }
17
17
  export declare const loadProductImages: (client: StorefrontApiClient, { items, country, language }: LoadProductImagesArgs) => Promise<{
18
- data: (Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash"> | undefined)[];
18
+ data: (Pick<import("./types/storefront.types").Image, "id" | "url" | "altText" | "thumbhash"> | undefined)[];
19
19
  errors: null;
20
20
  } | {
21
21
  data: null;
@@ -21,56 +21,8 @@ export interface LoadProductArgs {
21
21
  }
22
22
  export declare const loadProduct: (client: StorefrontApiClient, { productId, productHandle, variantId, selectedOptions, productMetafields, variantMetafields, country, language, }: LoadProductArgs) => Promise<{
23
23
  data: {
24
- product: (Pick<import("./types/storefront.types").Product, "title" | "id" | "handle" | "availableForSale" | "description" | "descriptionHtml" | "encodedVariantAvailability" | "encodedVariantExistence" | "isGiftCard" | "onlineStoreUrl" | "productType" | "tags"> & {
25
- variant?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").ProductVariant, "id" | "availableForSale" | "currentlyNotInStock" | "sku" | "title"> & {
26
- compareAtPrice?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">>;
27
- image?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
28
- price: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
29
- selectedOptions: Array<Pick<import("./types/storefront.types").SelectedOption, "name" | "value">>;
30
- metafields: Array<import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Metafield, "key" | "namespace" | "value">>>;
31
- }>;
32
- category?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").TaxonomyCategory, "id" | "name">>;
33
- compareAtPriceRange: {
34
- maxVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
35
- minVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
36
- };
37
- featuredImage?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
38
- images: {
39
- nodes: Array<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
40
- };
41
- metafields: Array<import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Metafield, "key" | "namespace" | "value">>>;
42
- selectedOrFirstAvailableVariant?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").ProductVariant, "id" | "availableForSale" | "currentlyNotInStock" | "sku" | "title"> & {
43
- compareAtPrice?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">>;
44
- image?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
45
- price: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
46
- selectedOptions: Array<Pick<import("./types/storefront.types").SelectedOption, "name" | "value">>;
47
- metafields: Array<import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Metafield, "key" | "namespace" | "value">>>;
48
- }>;
49
- options: Array<Pick<import("./types/storefront.types").ProductOption, "id" | "name"> & {
50
- optionValues: Array<Pick<import("./types/storefront.types").ProductOptionValue, "name"> & {
51
- swatch?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").ProductOptionValueSwatch, "color"> & {
52
- image?: import("./types/storefront.types").Maybe<{
53
- previewImage?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "url">>;
54
- }>;
55
- }>;
56
- firstSelectableVariant?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").ProductVariant, "id"> & {
57
- image?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
58
- }>;
59
- }>;
60
- }>;
61
- priceRange: {
62
- maxVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
63
- minVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
64
- };
65
- variantsCount?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Count, "count" | "precision">>;
66
- }) | null;
67
- variant: (Pick<import("./types/storefront.types").ProductVariant, "title" | "id" | "availableForSale" | "currentlyNotInStock" | "sku"> & {
68
- compareAtPrice?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">>;
69
- image?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
70
- price: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
71
- selectedOptions: Array<Pick<import("./types/storefront.types").SelectedOption, "name" | "value">>;
72
- metafields: Array<import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Metafield, "key" | "namespace" | "value">>>;
73
- }) | null;
24
+ product: Product | null;
25
+ variant: ProductVariant | null;
74
26
  };
75
27
  errors: import("@shopify/graphql-client").ResponseErrors | null;
76
28
  }>;
@@ -1,3 +1,3 @@
1
1
  export declare const PRODUCT_IMAGE_FIELDS = "\n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n";
2
2
  export declare const PRODUCT_FIELDS = "\n fragment productFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n description\n descriptionHtml\n encodedVariantAvailability\n encodedVariantExistence\n featuredImage {\n ...productImageFields\n }\n handle\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n isGiftCard\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n onlineStoreUrl\n selectedOrFirstAvailableVariant(selectedOptions: $selectedOptions) {\n ...productVariantDataFields\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n precision\n }\n # totalInventory\n }\n";
3
- export declare const PRODUCT_VARIANT_DATA_FIELDS = "\n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n";
3
+ export declare const PRODUCT_VARIANT_DATA_FIELDS = "\n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n product {\n id\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n";
@@ -1,7 +1,8 @@
1
- export declare const GET_PRODUCT_BY_ID = "\n query GetProduct(\n $productId: ID!\n $variantId: ID!\n $selectedOptions: [SelectedOptionInput!]!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $variantMetafields: [HasMetafieldsIdentifier!]!\n $includeVariantById: Boolean!\n $includeVariantBySelectedOptions: Boolean!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productFields\n variant: variantBySelectedOptions(selectedOptions: $selectedOptions)\n @include(if: $includeVariantBySelectedOptions) {\n ...productVariantDataFields\n }\n }\n variantNode: node(id: $variantId) @include(if: $includeVariantById) {\n ... on ProductVariant {\n ...productVariantDataFields\n }\n }\n }\n \n fragment productFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n description\n descriptionHtml\n encodedVariantAvailability\n encodedVariantExistence\n featuredImage {\n ...productImageFields\n }\n handle\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n isGiftCard\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n onlineStoreUrl\n selectedOrFirstAvailableVariant(selectedOptions: $selectedOptions) {\n ...productVariantDataFields\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n precision\n }\n # totalInventory\n }\n\n \n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
2
- export declare const GET_PRODUCT_BY_HANDLE = "\n query GetProductByHandle(\n $handle: String!\n $variantId: ID!\n $selectedOptions: [SelectedOptionInput!]!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $variantMetafields: [HasMetafieldsIdentifier!]!\n $includeVariantById: Boolean!\n $includeVariantBySelectedOptions: Boolean!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...productFields\n variant: variantBySelectedOptions(selectedOptions: $selectedOptions)\n @include(if: $includeVariantBySelectedOptions) {\n ...productVariantDataFields\n }\n }\n variantNode: node(id: $variantId) @include(if: $includeVariantById) {\n ... on ProductVariant {\n ...productVariantDataFields\n }\n }\n }\n \n fragment productFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n description\n descriptionHtml\n encodedVariantAvailability\n encodedVariantExistence\n featuredImage {\n ...productImageFields\n }\n handle\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n isGiftCard\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n onlineStoreUrl\n selectedOrFirstAvailableVariant(selectedOptions: $selectedOptions) {\n ...productVariantDataFields\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n precision\n }\n # totalInventory\n }\n\n \n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
1
+ export declare const GET_PRODUCT_BY_ID = "\n query GetProduct(\n $productId: ID!\n $variantId: ID!\n $selectedOptions: [SelectedOptionInput!]!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $variantMetafields: [HasMetafieldsIdentifier!]!\n $includeVariantById: Boolean!\n $includeVariantBySelectedOptions: Boolean!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productFields\n variant: variantBySelectedOptions(selectedOptions: $selectedOptions)\n @include(if: $includeVariantBySelectedOptions) {\n ...productVariantDataFields\n }\n }\n variantNode: node(id: $variantId) @include(if: $includeVariantById) {\n ... on ProductVariant {\n ...productVariantDataFields\n }\n }\n }\n \n fragment productFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n description\n descriptionHtml\n encodedVariantAvailability\n encodedVariantExistence\n featuredImage {\n ...productImageFields\n }\n handle\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n isGiftCard\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n onlineStoreUrl\n selectedOrFirstAvailableVariant(selectedOptions: $selectedOptions) {\n ...productVariantDataFields\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n precision\n }\n # totalInventory\n }\n\n \n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n product {\n id\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
2
+ export declare const GET_PRODUCT_BY_HANDLE = "\n query GetProductByHandle(\n $handle: String!\n $variantId: ID!\n $selectedOptions: [SelectedOptionInput!]!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $variantMetafields: [HasMetafieldsIdentifier!]!\n $includeVariantById: Boolean!\n $includeVariantBySelectedOptions: Boolean!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...productFields\n variant: variantBySelectedOptions(selectedOptions: $selectedOptions)\n @include(if: $includeVariantBySelectedOptions) {\n ...productVariantDataFields\n }\n }\n variantNode: node(id: $variantId) @include(if: $includeVariantById) {\n ... on ProductVariant {\n ...productVariantDataFields\n }\n }\n }\n \n fragment productFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n description\n descriptionHtml\n encodedVariantAvailability\n encodedVariantExistence\n featuredImage {\n ...productImageFields\n }\n handle\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n isGiftCard\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n onlineStoreUrl\n selectedOrFirstAvailableVariant(selectedOptions: $selectedOptions) {\n ...productVariantDataFields\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n precision\n }\n # totalInventory\n }\n\n \n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n product {\n id\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
3
3
  export declare const GET_PRODUCT_IMAGES_BY_ID = "\n query GetProductImagesById(\n $ids: [ID!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n nodes(ids: $ids) {\n ... on Product {\n featuredImage {\n ...productImageFields\n }\n }\n ... on ProductVariant {\n image {\n ...productImageFields\n }\n product {\n featuredImage {\n ...productImageFields\n }\n }\n }\n }\n }\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
4
4
  export declare const GET_PRODUCT_RECOMMENDATIONS_BY_ID = "\n query GetProductRecommendationsById(\n $productId: ID!\n $intent: ProductRecommendationIntent\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n productRecommendations(productId: $productId, intent: $intent) {\n id\n }\n }\n";
5
5
  export declare const GET_PRODUCT_RECOMMENDATIONS_BY_HANDLE = "\n query GetProductRecommendationsByHandle(\n $handle: String!\n $intent: ProductRecommendationIntent\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n productRecommendations(productHandle: $handle, intent: $intent) {\n id\n }\n }\n";
6
6
  export declare const GET_PRODUCT_ID_BY_HANDLE = "\n query GetProductIdByHandle($handle: String!) {\n product(handle: $handle) {\n id\n }\n }\n";
7
+ export declare const GET_PRODUCT_HANDLE_BY_ID = "\n query GetProductHandleById($productId: ID!) {\n product(id: $productId) {\n handle\n }\n }\n";
7
8
  export declare const GET_COLLECTION_PRODUCTS = "\n query GetCollectionProducts(\n $handle: String!\n $first: Int!\n $after: String\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n collection(handle: $handle) {\n title\n handle\n onlineStoreUrl\n products(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n endCursor\n }\n nodes {\n id\n }\n }\n }\n }\n";