@swishapp/sdk 0.132.0 → 0.133.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.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Toggles `hidden` on descendants of `host` with `data-swish-when` based on
3
+ * the current state. The attribute value may be a single state or a
4
+ * comma-separated list (e.g. `"saved,saving"`) - the child is shown when
5
+ * the current state matches any entry. Re-applies whenever the bound
6
+ * signal changes.
7
+ */
8
+ export declare function bindWhen(host: HTMLElement, getState: () => string): () => void;
9
+ /**
10
+ * Sets `textContent` on descendants of `host` matching
11
+ * `[data-swish-bind="<key>"]` to the resolved value.
12
+ */
13
+ export declare function bindValue(host: HTMLElement, key: string, getValue: () => string | number): () => void;
@@ -0,0 +1,3 @@
1
+ export { getSwish, initElements } from "./init";
2
+ export { SwishDrawerElement } from "./swish-drawer-element";
3
+ export { SwishSaveElement } from "./swish-save-element";
@@ -0,0 +1,3 @@
1
+ import type { SwishApp } from "../swish";
2
+ export declare function initElements(swish: SwishApp): void;
3
+ export declare function getSwish(): SwishApp | null;
@@ -0,0 +1,13 @@
1
+ declare const BaseElement: typeof HTMLElement;
2
+ export declare class SwishDrawerElement extends BaseElement {
3
+ static get observedAttributes(): "view"[];
4
+ private disposers;
5
+ private deferredReady;
6
+ private clickHandler;
7
+ connectedCallback(): void;
8
+ disconnectedCallback(): void;
9
+ private bind;
10
+ private dispose;
11
+ private resolveView;
12
+ }
13
+ export {};
@@ -0,0 +1,16 @@
1
+ declare const BaseElement: typeof HTMLElement;
2
+ export declare class SwishSaveElement extends BaseElement {
3
+ static get observedAttributes(): ("product" | "variant" | "match" | "context")[];
4
+ private disposers;
5
+ private state;
6
+ private deferredReady;
7
+ private clickHandler;
8
+ connectedCallback(): void;
9
+ attributeChangedCallback(_name: string, prev: string | null, next: string | null): void;
10
+ disconnectedCallback(): void;
11
+ private bind;
12
+ private rebind;
13
+ private dispose;
14
+ private resolveContext;
15
+ }
16
+ export {};
@@ -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" | "url" | "altText" | "thumbhash"> | undefined)[];
18
+ data: (Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash"> | undefined)[];
19
19
  errors: null;
20
20
  } | {
21
21
  data: null;
@@ -21,7 +21,7 @@ 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" | "availableForSale" | "description" | "descriptionHtml" | "encodedVariantAvailability" | "encodedVariantExistence" | "handle" | "isGiftCard" | "onlineStoreUrl" | "productType" | "tags"> & {
24
+ product: (Pick<import("./types/storefront.types").Product, "title" | "id" | "handle" | "availableForSale" | "description" | "descriptionHtml" | "encodedVariantAvailability" | "encodedVariantExistence" | "isGiftCard" | "onlineStoreUrl" | "productType" | "tags"> & {
25
25
  variant?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").ProductVariant, "id" | "availableForSale" | "currentlyNotInStock" | "sku" | "title"> & {
26
26
  compareAtPrice?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">>;
27
27
  image?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
@@ -34,7 +34,7 @@ export declare class StorefrontApiClient {
34
34
  }>;
35
35
  loadProduct: (args: ArgsWithoutDefaults<LoadProductArgs>) => Promise<{
36
36
  data: {
37
- product: (Pick<import("./types/storefront.types").Product, "title" | "id" | "availableForSale" | "description" | "descriptionHtml" | "encodedVariantAvailability" | "encodedVariantExistence" | "handle" | "isGiftCard" | "onlineStoreUrl" | "productType" | "tags"> & {
37
+ product: (Pick<import("./types/storefront.types").Product, "title" | "id" | "handle" | "availableForSale" | "description" | "descriptionHtml" | "encodedVariantAvailability" | "encodedVariantExistence" | "isGiftCard" | "onlineStoreUrl" | "productType" | "tags"> & {
38
38
  variant?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").ProductVariant, "id" | "availableForSale" | "currentlyNotInStock" | "sku" | "title"> & {
39
39
  compareAtPrice?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">>;
40
40
  image?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
@@ -88,7 +88,7 @@ export declare class StorefrontApiClient {
88
88
  errors: ResponseErrors | null;
89
89
  }>;
90
90
  loadProductImages: (args: ArgsWithoutDefaults<LoadProductImagesArgs>) => Promise<{
91
- data: (Pick<import("./types/storefront.types").Image, "id" | "url" | "altText" | "thumbhash"> | undefined)[];
91
+ data: (Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash"> | undefined)[];
92
92
  errors: null;
93
93
  } | {
94
94
  data: null;
package/dist/swish.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type SwishI18n } from "@swishapp/i18n";
2
2
  import { AjaxApiClient } from "./ajax-api/ajax-api-client";
3
3
  import { PlacementSpec } from "./dom/create-placement";
4
- import { createElementLocator, createLocationObserver } from "./dom/dom-utils";
4
+ import { createLocationObserver } from "./dom/dom-utils";
5
5
  import { EventBus } from "./events/event-bus";
6
6
  import { Intents } from "./intents/intents";
7
7
  import { SwishOptionsInput } from "./options/swish-options";
@@ -38,7 +38,6 @@ declare class SwishApp {
38
38
  get i18n(): SwishI18n;
39
39
  get shopUrl(): string;
40
40
  get dom(): {
41
- createElementLocator: typeof createElementLocator;
42
41
  createLocationObserver: typeof createLocationObserver;
43
42
  createPlacement: (spec: PlacementSpec) => {
44
43
  mount(): void;