@swishapp/sdk 0.105.1 → 0.106.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.
@@ -52,7 +52,7 @@ export interface Cart {
52
52
  cart_level_discount_applications: any[];
53
53
  }
54
54
  export interface AddToCartItem {
55
- id: string;
55
+ id: string | number;
56
56
  quantity: number;
57
57
  }
58
58
  export interface AddToCartRequest {
@@ -0,0 +1,114 @@
1
+ import { SwishApp } from "../swish";
2
+ import { CreateElementLocatorArgs } from "./dom-utils";
3
+ export declare function createPlacement<TDomElement extends HTMLElement = HTMLElement, TElementName extends ElementName = ElementName>(swish: SwishApp, spec: PlacementSpec<TDomElement, TElementName>): {
4
+ mount(): void;
5
+ unmount(): void;
6
+ };
7
+ /** --------------------------------------------
8
+ * Types
9
+ * -------------------------------------------- */
10
+ export type BreakpointsSpec = {
11
+ sm?: number;
12
+ lg?: number;
13
+ } | Record<string, number>;
14
+ export type ResponsiveValue<T> = T | {
15
+ base?: T;
16
+ [breakpoint: string]: T | undefined;
17
+ };
18
+ type ElementName = "save-button" | "home-button";
19
+ export type SaveButtonDesignSpec = {
20
+ background?: ResponsiveValue<string>;
21
+ savedBackground?: ResponsiveValue<string>;
22
+ color?: ResponsiveValue<string>;
23
+ savedColor?: ResponsiveValue<string>;
24
+ height?: ResponsiveValue<string | number>;
25
+ radius?: ResponsiveValue<string | number>;
26
+ };
27
+ export type HomeButtonDesignSpec = {
28
+ background?: ResponsiveValue<string>;
29
+ color?: ResponsiveValue<string>;
30
+ height?: ResponsiveValue<string | number>;
31
+ radius?: ResponsiveValue<string | number>;
32
+ };
33
+ type DesignSpecMap = {
34
+ "save-button": SaveButtonDesignSpec;
35
+ "home-button": HomeButtonDesignSpec;
36
+ };
37
+ export type DesignSpecForElementName<TName extends ElementName = ElementName> = TName extends keyof DesignSpecMap ? DesignSpecMap[TName] : never;
38
+ export type MountMode = "before" | "after" | "append" | "prepend" | "replace";
39
+ export type MountAt = "target" | {
40
+ closest: string;
41
+ } | {
42
+ query: string;
43
+ } | {
44
+ withinClosest: {
45
+ root: string;
46
+ selector: string;
47
+ };
48
+ };
49
+ export type ContainerSpec = {
50
+ tag?: keyof HTMLElementTagNameMap;
51
+ classNames?: string[];
52
+ };
53
+ export type OverlayAnchor = "top-left" | "top-right" | "bottom-left" | "bottom-right";
54
+ export type ElementSpec<TName extends string = ElementName> = {
55
+ name: TName;
56
+ props?: Record<string, unknown>;
57
+ classNames?: string[];
58
+ };
59
+ export type OffsetSpec = {
60
+ x?: number;
61
+ y?: number;
62
+ };
63
+ export type OverlayLayoutSpec = {
64
+ type: "overlay";
65
+ anchor?: OverlayAnchor;
66
+ zIndex?: number | string;
67
+ offset?: OffsetSpec | ResponsiveValue<OffsetSpec>;
68
+ };
69
+ export type InlineLayoutSpec = {
70
+ type: "inline";
71
+ rowSelector?: string;
72
+ };
73
+ export type PlacementLayoutSpec = OverlayLayoutSpec | InlineLayoutSpec;
74
+ export type PlacementSpec<TDomElement extends HTMLElement = HTMLElement, TElementName extends ElementName = ElementName> = {
75
+ id: string;
76
+ target: Omit<CreateElementLocatorArgs, "onElementFound">;
77
+ mount: {
78
+ at?: MountAt;
79
+ mode: MountMode;
80
+ };
81
+ layout?: PlacementLayoutSpec;
82
+ breakpoints?: BreakpointsSpec;
83
+ container?: ContainerSpec;
84
+ element?: ElementSpec<TElementName> | RenderFn;
85
+ /** Design tokens (typed when element name is known). */
86
+ design?: DesignSpecForElementName<TElementName>;
87
+ /** Custom CSS appended after defaults (one stylesheet per placement). */
88
+ css?: string;
89
+ onMount?: (ctx: MountContext<TDomElement>) => void;
90
+ onUnmount?: (ctx: UnmountContext<TDomElement>) => void;
91
+ };
92
+ export type MountContext<T extends HTMLElement> = {
93
+ id: string;
94
+ targetEl: Element;
95
+ renderTargetEl: Element;
96
+ mountEl: T;
97
+ containerEl?: HTMLElement;
98
+ rowEl?: HTMLElement;
99
+ cleanup: (fn: () => void) => void;
100
+ };
101
+ export type UnmountContext<T extends HTMLElement> = Omit<MountContext<T>, "cleanup">;
102
+ export type MountedElement<T extends HTMLElement> = {
103
+ targetEl: HTMLElement;
104
+ renderTargetEl: HTMLElement;
105
+ mountEl: T;
106
+ containerEl?: HTMLElement;
107
+ rowEl?: HTMLElement;
108
+ rowWasCreated?: boolean;
109
+ rowInlineAttrPrevValue?: string | null;
110
+ cleanupFns: Array<() => void>;
111
+ ownsNode: boolean;
112
+ };
113
+ export type RenderFn = (spec: PlacementSpec<any, any>) => HTMLElement | Promise<HTMLElement>;
114
+ export {};
@@ -3,8 +3,9 @@ export interface CreateElementLocatorArgs {
3
3
  onElementFound: (element: Element) => void;
4
4
  selector: string;
5
5
  observerOptions?: IntersectionObserverInit;
6
+ mustMatch?: (element: Element) => boolean;
6
7
  }
7
- export declare function createElementLocator({ onElementFound, selector, observerOptions, }: CreateElementLocatorArgs): MutationObserver;
8
+ export declare function createElementLocator({ onElementFound, selector, observerOptions, mustMatch, }: CreateElementLocatorArgs): MutationObserver;
8
9
  export interface CreateLocationObserverArgs {
9
10
  onLocationChange: (location: Location) => void;
10
11
  fireOnInit?: boolean;
@@ -0,0 +1,21 @@
1
+ import * as v from "valibot";
2
+ import type { AddToCartResponse } from "../../ajax-api/ajax-api-client";
3
+ import { IntentHandler } from "../intent-handler";
4
+ import { IntentResponse, SuccessIntentResponse } from "../types";
5
+ export declare const CreateCartLineIntentDataSchema: v.UnionSchema<[v.ObjectSchema<{
6
+ readonly variantId: v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string>]>, v.NumberSchema<undefined>], undefined>, v.TransformAction<string | number, number>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>]>;
7
+ readonly quantity: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, 1>;
8
+ }, undefined>, v.ObjectSchema<{
9
+ readonly items: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
10
+ readonly variantId: v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string>]>, v.NumberSchema<undefined>], undefined>, v.TransformAction<string | number, number>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>]>;
11
+ readonly quantity: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, 1>;
12
+ }, undefined>, undefined>, v.MinLengthAction<{
13
+ variantId: number;
14
+ quantity: number;
15
+ }[], 1, undefined>]>;
16
+ }, undefined>], undefined>;
17
+ export type CreateCartLineIntentData = v.InferInput<typeof CreateCartLineIntentDataSchema>;
18
+ export type CreateCartLineSuccessResponse = SuccessIntentResponse<AddToCartResponse>;
19
+ export declare class CreateCartLineHandler extends IntentHandler<"create:cart-line"> {
20
+ invoke(data: CreateCartLineIntentData): Promise<IntentResponse<"create:cart-line">>;
21
+ }
@@ -14,6 +14,6 @@ export type EditItemListsSuccessResponse = SuccessIntentResponse<{
14
14
  variant: GetSaveIntentDataWithVariantQuery["variant"];
15
15
  }>;
16
16
  export type EditItemListsIntentDataValidated = v.InferInput<typeof EditItemListsIntentDataSchema>;
17
- export declare class EditItemListsHandler extends IntentHandler<"edit:item-lists" | "delete:item"> {
18
- invoke(data: EditItemListsIntentData): Promise<IntentResponse<"edit:item-lists" | "delete:item">>;
17
+ export declare class EditItemListsHandler extends IntentHandler<"edit:item-lists" | "unsave:item"> {
18
+ invoke(data: EditItemListsIntentData): Promise<IntentResponse<"edit:item-lists" | "unsave:item">>;
19
19
  }
@@ -0,0 +1,15 @@
1
+ import { List } from "@swishapp/api-client";
2
+ import * as v from "valibot";
3
+ import { IntentHandler } from "../intent-handler";
4
+ import { IntentResponse, SuccessIntentResponse } from "../types";
5
+ export declare const EditListAccessIntentDataSchema: v.ObjectSchema<{
6
+ readonly listId: v.StringSchema<undefined>;
7
+ readonly access: v.PicklistSchema<["public", "private"], undefined>;
8
+ }, undefined>;
9
+ export type EditListAccessIntentData = v.InferInput<typeof EditListAccessIntentDataSchema>;
10
+ export type EditListAccessSuccessResponse = SuccessIntentResponse<{
11
+ list: List;
12
+ }>;
13
+ export declare class EditListAccessHandler extends IntentHandler<"edit:list-access"> {
14
+ invoke(data: EditListAccessIntentData): Promise<IntentResponse<"edit:list-access">>;
15
+ }
@@ -1,13 +1,15 @@
1
1
  import * as v from "valibot";
2
2
  import { IntentHandler } from "../intent-handler";
3
3
  import { IntentResponse } from "../types";
4
- import { EditListSuccessResponse } from "./edit-list-handler";
5
4
  import { DeleteListSuccessResponse } from "./delete-list-handler";
5
+ import { EditListAccessSuccessResponse } from "./edit-list-access-handler";
6
+ import { EditListSuccessResponse } from "./edit-list-handler";
7
+ import { ShareListSuccessResponse } from "./share-list-handler";
6
8
  export declare const OpenListMenuIntentDataSchema: v.ObjectSchema<{
7
9
  readonly listId: v.StringSchema<undefined>;
8
10
  }, undefined>;
9
11
  export type OpenListMenuIntentData = v.InferInput<typeof OpenListMenuIntentDataSchema>;
10
- export type OpenListMenuSuccessResponse = EditListSuccessResponse | DeleteListSuccessResponse;
11
- export declare class OpenListMenuHandler extends IntentHandler<"open:list-menu" | "edit:list" | "delete:list"> {
12
- invoke(data: OpenListMenuIntentData): Promise<IntentResponse<"open:list-menu" | "edit:list" | "delete:list">>;
12
+ export type OpenListMenuSuccessResponse = EditListSuccessResponse | DeleteListSuccessResponse | EditListAccessSuccessResponse | ShareListSuccessResponse;
13
+ export declare class OpenListMenuHandler extends IntentHandler<"open:list-menu" | "edit:list" | "delete:list" | "edit:list-access" | "share:list"> {
14
+ invoke(data: OpenListMenuIntentData): Promise<IntentResponse<"open:list-menu" | "edit:list" | "delete:list" | "edit:list-access" | "share:list">>;
13
15
  }
@@ -0,0 +1,16 @@
1
+ import * as v from "valibot";
2
+ import { IntentHandler } from "../intent-handler";
3
+ import { IntentResponse, SuccessIntentResponse } from "../types";
4
+ export declare const ShareListIntentDataSchema: v.ObjectSchema<{
5
+ readonly listId: v.StringSchema<undefined>;
6
+ }, undefined>;
7
+ export type ShareListIntentData = v.InferInput<typeof ShareListIntentDataSchema>;
8
+ export type ShareListSuccessResponse = SuccessIntentResponse<{
9
+ listId: string;
10
+ url: string;
11
+ method: "native" | "clipboard";
12
+ publicListId?: string;
13
+ }>;
14
+ export declare class ShareListHandler extends IntentHandler<"share:list"> {
15
+ invoke(data: ShareListIntentData): Promise<IntentResponse<"share:list">>;
16
+ }
@@ -9,6 +9,8 @@ export declare const ToastIntentDataSchema: v.ObjectSchema<{
9
9
  readonly label: v.StringSchema<undefined>;
10
10
  readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
11
11
  }, undefined>, undefined>;
12
+ readonly variant: v.OptionalSchema<v.PicklistSchema<["compact", "full"], undefined>, undefined>;
13
+ readonly icon: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
12
14
  }, undefined>;
13
15
  export type ToastIntentData = v.InferInput<typeof ToastIntentDataSchema>;
14
16
  export type ToastSuccessResponse = SuccessIntentResponse<void>;
@@ -0,0 +1,14 @@
1
+ import * as v from "valibot";
2
+ import { IntentHandler } from "../intent-handler";
3
+ import { IntentResponse, SuccessIntentResponse } from "../types";
4
+ export declare const UnsaveItemIntentDataSchema: v.ObjectSchema<{
5
+ readonly itemId: v.StringSchema<undefined>;
6
+ readonly delete: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
7
+ }, undefined>;
8
+ export type UnsaveItemIntentData = v.InferInput<typeof UnsaveItemIntentDataSchema>;
9
+ export type UnsaveItemSuccessResponse = SuccessIntentResponse<{
10
+ itemId: string;
11
+ }>;
12
+ export declare class UnsaveItemHandler extends IntentHandler<"unsave:item" | "edit:item-lists"> {
13
+ invoke(data: UnsaveItemIntentData): Promise<IntentResponse<"unsave:item" | "edit:item-lists">>;
14
+ }
@@ -0,0 +1,5 @@
1
+ import { IntentHook } from "../intent-hook";
2
+ import { IntentResponse } from "../types";
3
+ export declare class AfterEditListAccessHook extends IntentHook<"edit:list-access"> {
4
+ invoke(response: IntentResponse<"edit:list-access">): Promise<void>;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { IntentHook } from "../intent-hook";
2
+ import { IntentResponse } from "../types";
3
+ export declare class AfterShareListHook extends IntentHook<"share:list"> {
4
+ invoke(response: IntentResponse<"share:list">): Promise<void>;
5
+ }
@@ -1,20 +1,20 @@
1
1
  import { SwishApp } from "../swish";
2
- import { Intent, IntentActivity, IntentQueryWithParams, IntentResponse, IntentToData } from "./types";
3
2
  import { SwishUi } from "../swish-ui/swish-ui";
3
+ import { Intent, IntentActivity, IntentQueryWithParams, IntentResponse, IntentToData } from "./types";
4
4
  export interface IntentOptions {
5
- save: {
6
- requireVariant: boolean;
7
- requireVariantConfirmation: boolean;
8
- showToast: boolean;
5
+ saveProduct: {
6
+ promptVariantIfMissing: boolean;
7
+ promptVariantIfPresent: boolean;
8
+ showFeedback: boolean;
9
9
  };
10
- edit: {
11
- requireVariantConfirmation: boolean;
12
- showToast: boolean;
10
+ unsaveProduct: {
11
+ selectList: boolean;
12
+ confirm: boolean;
13
+ showFeedback: boolean;
13
14
  };
14
- unsave: {
15
- requireConfirmation: boolean;
16
- openEditor: boolean;
17
- showToast: boolean;
15
+ editSavedProduct: {
16
+ promptVariantChange: boolean;
17
+ showFeedback: boolean;
18
18
  };
19
19
  }
20
20
  export declare class Intents {
@@ -1,27 +1,30 @@
1
- import type { SaveItemIntentData, SaveItemSuccessResponse } from "./handlers/save-item-handler";
2
- import type { DeleteItemIntentData, DeleteItemSuccessResponse } from "./handlers/delete-item-handler";
3
- import type { EditItemVariantIntentData, EditItemVariantSuccessResponse } from "./handlers/edit-item-variant-handler";
1
+ import type { CreateListIntentData, CreateListSuccessResponse } from "./handlers/create-list-handler";
2
+ import type { CreateCartLineIntentData, CreateCartLineSuccessResponse } from "./handlers/create-cart-line-handler";
3
+ import type { DeleteListIntentData, DeleteListSuccessResponse } from "./handlers/delete-list-handler";
4
4
  import type { EditItemListsIntentData, EditItemListsSuccessResponse } from "./handlers/edit-item-lists-handler";
5
+ import type { EditItemVariantIntentData, EditItemVariantSuccessResponse } from "./handlers/edit-item-variant-handler";
6
+ import type { EditListAccessIntentData, EditListAccessSuccessResponse } from "./handlers/edit-list-access-handler";
5
7
  import type { EditListIntentData, EditListSuccessResponse } from "./handlers/edit-list-handler";
6
- import type { DeleteListIntentData, DeleteListSuccessResponse } from "./handlers/delete-list-handler";
7
- import type { CreateListIntentData, CreateListSuccessResponse } from "./handlers/create-list-handler";
8
8
  import type { OpenHomeSuccessResponse } from "./handlers/open-home-handler";
9
- import type { OpenListMenuIntentData, OpenListMenuSuccessResponse } from "./handlers/open-list-menu-handler";
10
- import type { OpenSignInIntentData, OpenSignInSuccessResponse } from "./handlers/open-sign-in-handler";
11
- import type { OpenQuickBuyIntentData, OpenQuickBuySuccessResponse } from "./handlers/open-quick-buy-handler";
12
9
  import type { OpenListDetailPageMenuIntentData, OpenListDetailPageMenuSuccessResponse } from "./handlers/open-list-detail-page-menu-handler";
13
- import { ToastIntentData, ToastSuccessResponse } from "./handlers/show-toast-handler";
10
+ import { OpenListIntentData, OpenListSuccessResponse } from "./handlers/open-list-handler";
11
+ import type { OpenListMenuIntentData, OpenListMenuSuccessResponse } from "./handlers/open-list-menu-handler";
14
12
  import { OpenListsSuccessResponse } from "./handlers/open-lists-handler";
15
- import { OpenOrdersSuccessResponse } from "./handlers/open-orders-handler";
16
- import { OpenSavesSuccessResponse } from "./handlers/open-saves-handler";
17
13
  import { OpenNotificationsSuccessResponse } from "./handlers/open-notifications-handler";
18
- import { OpenProfileSuccessResponse } from "./handlers/open-profile-handler";
19
- import { OpenListIntentData, OpenListSuccessResponse } from "./handlers/open-list-handler";
20
- import { OpenProductIntentData, OpenProductSuccessResponse } from "./handlers/open-product-handler";
21
14
  import { OpenOrderIntentData, OpenOrderSuccessResponse } from "./handlers/open-order-handler";
22
15
  import type { OpenOrderMenuIntentData, OpenOrderMenuSuccessResponse } from "./handlers/open-order-menu-handler";
23
- export type { DeleteItemSuccessResponse, EditItemVariantSuccessResponse, EditItemListsSuccessResponse, SaveItemSuccessResponse, EditListSuccessResponse, DeleteListSuccessResponse, CreateListSuccessResponse, ToastSuccessResponse, };
24
- export type Intent = "save:item" | "edit:item-variant" | "edit:item-lists" | "delete:item" | "edit:list" | "delete:list" | "create:list" | "open:home" | "open:list" | "open:lists" | "open:orders" | "open:order" | "open:saves" | "open:notifications" | "open:profile" | "open:product" | "open:list-menu" | "open:order-menu" | "open:list-detail-page-menu" | "open:sign-in" | "open:quick-buy" | "show:toast";
16
+ import { OpenOrdersSuccessResponse } from "./handlers/open-orders-handler";
17
+ import { OpenProductIntentData, OpenProductSuccessResponse } from "./handlers/open-product-handler";
18
+ import { OpenProfileSuccessResponse } from "./handlers/open-profile-handler";
19
+ import type { OpenQuickBuyIntentData, OpenQuickBuySuccessResponse } from "./handlers/open-quick-buy-handler";
20
+ import { OpenSavesSuccessResponse } from "./handlers/open-saves-handler";
21
+ import type { OpenSignInIntentData, OpenSignInSuccessResponse } from "./handlers/open-sign-in-handler";
22
+ import type { SaveItemIntentData, SaveItemSuccessResponse } from "./handlers/save-item-handler";
23
+ import type { ShareListIntentData, ShareListSuccessResponse } from "./handlers/share-list-handler";
24
+ import { ToastIntentData, ToastSuccessResponse } from "./handlers/show-toast-handler";
25
+ import type { UnsaveItemIntentData, UnsaveItemSuccessResponse } from "./handlers/unsave-item-handler";
26
+ export type { CreateCartLineSuccessResponse, CreateListSuccessResponse, DeleteListSuccessResponse, EditItemListsSuccessResponse, EditItemVariantSuccessResponse, EditListAccessSuccessResponse, EditListSuccessResponse, SaveItemSuccessResponse, ShareListSuccessResponse, ToastSuccessResponse, UnsaveItemSuccessResponse, };
27
+ export type Intent = "create:cart-line" | "save:item" | "edit:item-variant" | "edit:item-lists" | "unsave:item" | "edit:list" | "edit:list-access" | "delete:list" | "create:list" | "share:list" | "open:home" | "open:list" | "open:lists" | "open:orders" | "open:order" | "open:saves" | "open:notifications" | "open:profile" | "open:product" | "open:list-menu" | "open:order-menu" | "open:list-detail-page-menu" | "open:sign-in" | "open:quick-buy" | "show:toast";
25
28
  export type IntentQueryParam = `${string}=${string}`;
26
29
  export type IntentQueryWithParams = `${Intent},${IntentQueryParam}`;
27
30
  export type IntentResponse<I extends Intent = Intent> = ClosedIntentResponse<I> | ErrorIntentResponse<I> | IntentToSuccessResponse<I>;
@@ -48,13 +51,16 @@ export interface SuccessIntentResponse<T, I extends Intent = Intent> extends Int
48
51
  data: T;
49
52
  }
50
53
  interface IntentDataMap {
54
+ "create:cart-line": CreateCartLineIntentData;
51
55
  "save:item": SaveItemIntentData;
52
56
  "edit:item-variant": EditItemVariantIntentData;
53
57
  "edit:item-lists": EditItemListsIntentData;
54
- "delete:item": DeleteItemIntentData;
58
+ "unsave:item": UnsaveItemIntentData;
55
59
  "edit:list": EditListIntentData;
60
+ "edit:list-access": EditListAccessIntentData;
56
61
  "delete:list": DeleteListIntentData;
57
62
  "create:list": CreateListIntentData;
63
+ "share:list": ShareListIntentData;
58
64
  "open:home": void;
59
65
  "open:list": OpenListIntentData;
60
66
  "open:lists": void;
@@ -72,13 +78,16 @@ interface IntentDataMap {
72
78
  "show:toast": ToastIntentData;
73
79
  }
74
80
  interface IntentSuccessResponseMap {
81
+ "create:cart-line": CreateCartLineSuccessResponse;
75
82
  "save:item": SaveItemSuccessResponse;
76
83
  "edit:item-variant": EditItemVariantSuccessResponse;
77
- "edit:item-lists": EditItemListsSuccessResponse | DeleteItemSuccessResponse;
78
- "delete:item": DeleteItemSuccessResponse;
84
+ "edit:item-lists": EditItemListsSuccessResponse | UnsaveItemSuccessResponse;
85
+ "unsave:item": UnsaveItemSuccessResponse;
79
86
  "edit:list": EditListSuccessResponse;
87
+ "edit:list-access": EditListAccessSuccessResponse;
80
88
  "delete:list": DeleteListSuccessResponse;
81
89
  "create:list": CreateListSuccessResponse;
90
+ "share:list": ShareListSuccessResponse;
82
91
  "open:home": OpenHomeSuccessResponse;
83
92
  "open:list": OpenListSuccessResponse;
84
93
  "open:lists": OpenListsSuccessResponse;
@@ -1,13 +1,16 @@
1
+ import { IntentOptions } from "../intents/intents";
1
2
  import { StorefrontApiOptions, SwishClientConfig } from "../swish";
2
- import { StorefrontContext, SwishBadgeOptions, SwishMetafieldOptions, SwishOptions, SwishUiOptions } from "./types";
3
+ import { StorefrontContext, SwishBadgeOptions, SwishFeaturesOptions, SwishMetafieldOptions, SwishOptions, SwishUiOptions } from "./types";
3
4
  export type SwishOptionsInput = {
4
5
  storefrontApi: StorefrontApiOptions;
5
6
  storefrontContext: StorefrontContext;
6
- badges?: SwishBadgeOptions;
7
- metafields?: SwishMetafieldOptions;
8
7
  swishApi?: SwishClientConfig & {
9
8
  version: string;
10
9
  };
11
10
  swishUi?: SwishUiOptions;
11
+ badges?: SwishBadgeOptions;
12
+ metafields?: SwishMetafieldOptions;
13
+ features?: SwishFeaturesOptions;
14
+ intents?: IntentOptions;
12
15
  };
13
16
  export declare const createSwishOptions: (options: SwishOptionsInput) => SwishOptions;
@@ -5,12 +5,14 @@ import { Badge } from "../utils/shopify-badge-utils";
5
5
  export interface SwishOptions {
6
6
  storefrontApi: StorefrontApiOptions;
7
7
  storefrontContext: StorefrontContext;
8
- badges: SwishBadgeOptions;
9
- metafields: SwishMetafieldOptions;
10
8
  swishApi: SwishClientConfig & {
11
9
  version: string;
12
10
  };
13
11
  swishUi: SwishUiOptions;
12
+ features: SwishFeaturesOptions;
13
+ intents: IntentOptions;
14
+ metafields: SwishMetafieldOptions;
15
+ badges: SwishBadgeOptions;
14
16
  }
15
17
  export interface SwishMetafieldOptions {
16
18
  product: `${string}.${string}`[];
@@ -23,14 +25,82 @@ export interface SwishBadgeOptions {
23
25
  defaultBadges: string[];
24
26
  }) => (string | Badge)[];
25
27
  }
28
+ export interface SwishUiDesignOptions {
29
+ appearance?: {
30
+ iconThickness?: number | string;
31
+ };
32
+ sizes?: {
33
+ buttonHeight?: number | string;
34
+ iconButtonSize?: number | string;
35
+ formInputHeight?: number | string;
36
+ iconSize?: number | string;
37
+ imageCardAspectRatio?: string;
38
+ imageSliderAspectRatio?: string;
39
+ };
40
+ rounding?: {
41
+ borderRadiusScale?: number | string;
42
+ badgeBorderRadius?: string;
43
+ buttonBorderRadius?: string;
44
+ dialogBorderRadius?: string;
45
+ formInputBorderRadius?: string;
46
+ imageCardBorderRadius?: string;
47
+ imageSliderBorderRadius?: string;
48
+ thumbnailBorderRadius?: string;
49
+ };
50
+ colors?: {
51
+ backgroundRgb?: string;
52
+ textColorRgb?: string;
53
+ textColorDangerRgb?: string;
54
+ headingColorRgb?: string;
55
+ primaryButtonBackgroundRgb?: string;
56
+ primaryButtonColorRgb?: string;
57
+ secondaryButtonBackgroundRgb?: string;
58
+ secondaryButtonColorRgb?: string;
59
+ dangerButtonColorRgb?: string;
60
+ statusDotBackgroundRgb?: string;
61
+ badgeBackgroundRgb?: string;
62
+ badgeColorRgb?: string;
63
+ };
64
+ typography?: {
65
+ headingFontFamily?: string;
66
+ headingTextTransform?: string;
67
+ headingFontSize?: number | string;
68
+ headingLetterSpacing?: string;
69
+ headingLineHeight?: number | string;
70
+ headingFontWeight?: number | string;
71
+ textFontFamily?: string;
72
+ textFontSize?: number | string;
73
+ textLetterSpacing?: string;
74
+ textLineHeight?: number | string;
75
+ textLineHeightParagraph?: number | string;
76
+ textFontWeight?: number | string;
77
+ buttonFontFamily?: string;
78
+ buttonTextTransform?: string;
79
+ buttonFontSize?: number | string;
80
+ buttonLetterSpacing?: string;
81
+ buttonLineHeight?: number | string;
82
+ buttonFontWeight?: number | string;
83
+ badgeFontFamily?: string;
84
+ badgeTextTransform?: string;
85
+ badgeFontSize?: number | string;
86
+ badgeLetterSpacing?: string;
87
+ badgeLineHeight?: number | string;
88
+ badgeFontWeight?: number | string;
89
+ };
90
+ }
26
91
  export interface SwishUiOptions {
27
92
  baseUrl: string;
28
93
  components: SwishComponentOptions;
29
94
  css: (string | URL)[];
30
- intents: IntentOptions;
31
- theme: Record<string, string>;
95
+ design: SwishUiDesignOptions;
32
96
  version: string;
33
97
  }
98
+ export interface SwishFeaturesOptions {
99
+ accounts: boolean;
100
+ lists: boolean;
101
+ orders: boolean;
102
+ notifications: boolean;
103
+ }
34
104
  export interface StorefrontContext {
35
105
  customer: {
36
106
  id: string | null;
@@ -45,10 +115,13 @@ export interface StorefrontContext {
45
115
  market: string;
46
116
  };
47
117
  myshopifyDomain: string;
48
- newCustomAccounts: boolean;
118
+ capabilities: {
119
+ newCustomerAccounts: boolean;
120
+ };
49
121
  routes: {
50
122
  accountUrl: string;
51
123
  rootUrl: string;
124
+ listDetailPagePath: string;
52
125
  };
53
126
  }
54
127
  export interface SwishComponentOptions {
@@ -96,6 +169,7 @@ export interface SwishDrawerNavigationItem {
96
169
  intent: Intent;
97
170
  }
98
171
  export interface SwishDrawerNavigationOptions {
172
+ enabled: boolean;
99
173
  variant: SwishDrawerNavigationVariant;
100
174
  items: SwishDrawerNavigationItem[];
101
175
  }
@@ -104,6 +178,7 @@ export interface SwishDrawerMiniMenuItem {
104
178
  url: string;
105
179
  }
106
180
  export interface SwishDrawerMiniMenuOptions {
181
+ enabled: boolean;
107
182
  items: SwishDrawerMiniMenuItem[];
108
183
  }
109
184
  export interface SwishDrawerListDetailViewOptions {
@@ -120,4 +195,8 @@ export interface SwishDrawerOptions {
120
195
  navigation: SwishDrawerNavigationOptions;
121
196
  miniMenu: SwishDrawerMiniMenuOptions;
122
197
  listDetailView: SwishDrawerListDetailViewOptions;
198
+ emptyCallout: SwishDrawerEmptyCalloutOptions;
199
+ }
200
+ export interface SwishDrawerEmptyCalloutOptions {
201
+ shoppingCalloutUrl: string;
123
202
  }
@@ -23,6 +23,7 @@ export declare class SwishApi {
23
23
  count: () => Promise<ApiResponse<ItemCount>>;
24
24
  list: (query?: ItemControllerFindData["query"], options?: {
25
25
  batch?: boolean;
26
+ shared?: boolean;
26
27
  }) => Promise<PaginatedApiResponse<Item>>;
27
28
  findById: (itemId: string) => Promise<ApiResponse<ItemDetail>>;
28
29
  create: (items: import("@swishapp/api-client").CreateItemInput) => Promise<ApiResponse<Item>>;
@@ -33,7 +34,9 @@ export declare class SwishApi {
33
34
  };
34
35
  get lists(): {
35
36
  list: (query?: ListControllerFindData["query"]) => Promise<PaginatedApiResponse<ListDetail>>;
36
- findById: (listId: string) => Promise<ApiResponse<ListDetail>>;
37
+ findById: (listId: string, options?: {
38
+ shared?: boolean;
39
+ }) => Promise<ApiResponse<ListDetail>>;
37
40
  create: (list: import("@swishapp/api-client").CreateListInput) => Promise<ApiResponse<import("@swishapp/api-client").List>>;
38
41
  updateById: (listId: string, body: import("@swishapp/api-client").UpdateListInput) => Promise<ApiResponse<import("@swishapp/api-client").List>>;
39
42
  deleteById: (listId: string) => Promise<ApiResponse<unknown>>;
@@ -4,6 +4,7 @@ export interface Ref<T> {
4
4
  declare const BaseElement: typeof HTMLElement;
5
5
  export declare class SwishUiElement extends BaseElement {
6
6
  constructor();
7
+ connectedCallback(): void;
7
8
  private componentRef;
8
9
  getComponentRef: <TComponent = unknown>() => Ref<TComponent>;
9
10
  setComponentRef: <TComponent = unknown>(ref: Ref<TComponent>) => void;
@@ -1,11 +1,11 @@
1
1
  import { StorefrontContext, SwishUiOptions } from "../options/types";
2
- import type { SwishUiElement } from "./swish-ui-element";
3
- import { DeleteListAlertOptions, DrawerOptions, ListDetailPageOptions, ListDetailPageMenuOptions, ListEditorOptions, ListEditorSubmitData, ListMenuOptions, ListMenuResponse, ListSelectOptions, ListSelectResponse, OrderMenuOptions, OrderMenuResponse, QuickBuyOptions, QuickBuySubmitData, RequireUiComponentOptions, SignInOptions, Toast, UiResponse, UnsaveAlertOptions, UnsaveAlertSubmitData, VariantSelectOptions, VariantSelectSubmitData } from "./types";
2
+ import type { Ref, SwishUiElement } from "./swish-ui-element";
3
+ import { ConfirmDialogOptions, DeleteListAlertOptions, DrawerOptions, ListDetailPageMenuOptions, ListDetailPageOptions, ListEditorOptions, ListEditorSubmitData, ListMenuOptions, ListMenuResponse, ListSelectOptions, ListSelectResponse, OrderMenuOptions, OrderMenuResponse, QuickBuyOptions, QuickBuySubmitData, RequireUiComponentOptions, SignInOptions, Toast, UiResponse, UnsaveAlertOptions, UnsaveAlertSubmitData, VariantSelectOptions, VariantSelectSubmitData } from "./types";
4
4
  export declare class SwishUi {
5
- private storefrontContext;
6
- private swishUiOptions;
7
- private inflightModals;
8
- private modalsWithScrollLock;
5
+ private readonly storefrontContext;
6
+ private readonly swishUiOptions;
7
+ private readonly inflightModals;
8
+ private readonly modalsWithScrollLock;
9
9
  private scrollLockStyleSheet;
10
10
  private scrollLockRefCount;
11
11
  private scrollPositionBeforeLock;
@@ -16,6 +16,7 @@ export declare class SwishUi {
16
16
  showSignIn(options?: SignInOptions): Promise<UiResponse<void>>;
17
17
  showUnsaveAlert(options: UnsaveAlertOptions): Promise<UiResponse<UnsaveAlertSubmitData>>;
18
18
  showDeleteListAlert(options: DeleteListAlertOptions): Promise<UiResponse<void>>;
19
+ showConfirmDialog(options: ConfirmDialogOptions): Promise<UiResponse<void>>;
19
20
  showDrawer(options?: DrawerOptions): Promise<UiResponse<void>>;
20
21
  showListMenu(options: ListMenuOptions): Promise<ListMenuResponse>;
21
22
  showOrderMenu(options: OrderMenuOptions): Promise<OrderMenuResponse>;
@@ -27,7 +28,13 @@ export declare class SwishUi {
27
28
  showVariantSelect(options?: VariantSelectOptions): Promise<UiResponse<VariantSelectSubmitData>>;
28
29
  showQuickBuy(options?: QuickBuyOptions): Promise<UiResponse<QuickBuySubmitData>>;
29
30
  showListEditor(options?: ListEditorOptions): Promise<UiResponse<ListEditorSubmitData>>;
31
+ createElement<T extends SwishUiElement>(name: string, options?: RequireUiComponentOptions<T>): Promise<T>;
32
+ hydrateElement<T extends SwishUiElement>(name: string, element: T, onHydrated?: (ref: Ref<T>) => void): Promise<void>;
30
33
  requireUiComponent<TComponent = unknown>(name: string, options?: RequireUiComponentOptions<TComponent>): Promise<SwishUiElement>;
34
+ private _templatePromises;
35
+ loadTemplate(name: string): Promise<string>;
36
+ private _importPromises;
37
+ importScript(name: string): Promise<any>;
31
38
  private _loadCricalResourcesPromise;
32
39
  loadCricalResources(): Promise<{
33
40
  themeVariablesStylesheet: CSSStyleSheet;
@@ -37,9 +44,8 @@ export declare class SwishUi {
37
44
  bundleCssStylesheet: CSSStyleSheet;
38
45
  customCssStylesheets: CSSStyleSheet[];
39
46
  }>;
40
- insertComponent<T extends HTMLElement = SwishUiElement>({ name, instance, template, position, refElement, }: {
47
+ insertComponent<T extends HTMLElement = SwishUiElement>({ name, template, position, refElement, }: {
41
48
  name: string;
42
- instance?: string;
43
49
  template: string;
44
50
  position: InsertPosition;
45
51
  refElement: HTMLElement;