@swishapp/sdk 0.105.0 → 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.
@@ -1,5 +1,5 @@
1
- import type { DeleteItemSuccessResponse, EditItemListsSuccessResponse, EditItemVariantSuccessResponse, EditListSuccessResponse } from "../intents/types";
2
- import { Ref } from "../swish";
1
+ import type { UnsaveItemSuccessResponse, EditItemListsSuccessResponse, EditItemVariantSuccessResponse, EditListSuccessResponse } from "../intents/types";
2
+ import { Ref, SwishUiElement } from "../swish";
3
3
  type ExtractSuccessData<T> = T extends {
4
4
  code: "ok";
5
5
  data: infer D;
@@ -27,6 +27,8 @@ export interface Toast {
27
27
  action?: {
28
28
  label: string;
29
29
  };
30
+ variant?: "compact" | "full";
31
+ icon?: string;
30
32
  }
31
33
  export interface SignInOptions {
32
34
  returnTo?: string;
@@ -34,10 +36,17 @@ export interface SignInOptions {
34
36
  export interface UnsaveAlertOptions {
35
37
  itemId: string;
36
38
  }
37
- export type UnsaveAlertSubmitData = ExtractSuccessData<DeleteItemSuccessResponse>;
39
+ export type UnsaveAlertSubmitData = ExtractSuccessData<UnsaveItemSuccessResponse>;
38
40
  export interface DeleteListAlertOptions {
39
41
  listId: string;
40
42
  }
43
+ export interface ConfirmDialogOptions {
44
+ titleKey?: string;
45
+ descriptionKey?: string;
46
+ confirmLabelKey?: string;
47
+ cancelLabelKey?: string;
48
+ danger?: boolean;
49
+ }
41
50
  export interface DrawerOptions {
42
51
  view?: "home" | "list" | "lists" | "saves" | "order" | "orders" | "notifications" | "profile" | "product";
43
52
  listId?: string;
@@ -52,11 +61,19 @@ export interface OrderMenuOptions {
52
61
  orderId: string;
53
62
  }
54
63
  export type ListEditorSubmitData = ExtractSuccessData<EditListSuccessResponse>;
64
+ export interface ListMenuEditAccessData {
65
+ currentListAccess: "public" | "private";
66
+ }
55
67
  export type ListMenuResponse = UiResponse<{
56
68
  action: "edit";
57
69
  data: ListEditorSubmitData;
58
70
  } | {
59
71
  action: "delete";
72
+ } | {
73
+ action: "edit-access";
74
+ data?: ListMenuEditAccessData;
75
+ } | {
76
+ action: "share";
60
77
  }>;
61
78
  export type OrderMenuResponse = UiResponse<void>;
62
79
  export interface ListDetailPageMenuOptions {
@@ -95,8 +112,7 @@ export interface QuickBuySubmitData {
95
112
  export interface ListEditorOptions {
96
113
  listId?: string;
97
114
  }
98
- export interface RequireUiComponentOptions<TComponent> {
99
- instance?: string;
115
+ export interface RequireUiComponentOptions<TComponent = SwishUiElement> {
100
116
  onHydrated?: (ref: Ref<TComponent>) => void;
101
117
  refElement?: HTMLElement;
102
118
  }
package/dist/swish.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AjaxApiClient } from "./ajax-api/ajax-api-client";
2
+ import { PlacementSpec } from "./dom/create-placement";
2
3
  import { createElementLocator, createLocationObserver } from "./dom/dom-utils";
3
4
  import { EventBus } from "./events/event-bus";
4
5
  import { Intents } from "./intents/intents";
@@ -7,6 +8,9 @@ import { SwishOptions } from "./options/types";
7
8
  import { computed, effect, signal } from "./state";
8
9
  import { StorefrontApiClient } from "./storefront-api/storefront-api-client";
9
10
  import { SwishApi } from "./swish-api/swish-api-client";
11
+ import { SwishUiElement } from "./swish-ui/swish-ui-element";
12
+ import { copyToClipboard } from "./utils/copy-to-clipboard";
13
+ import { RequireUiComponentOptions } from "./swish-ui/types";
10
14
  import { ShopifyBadgesUtils } from "./utils/shopify-badge-utils";
11
15
  export declare const VERSION: string;
12
16
  export declare const swishSdkUrl: string;
@@ -32,7 +36,20 @@ declare class SwishApp {
32
36
  get shopUrl(): string;
33
37
  readonly dom: {
34
38
  createElementLocator: typeof createElementLocator;
35
- createQueryParamsObserver: typeof createLocationObserver;
39
+ createLocationObserver: typeof createLocationObserver;
40
+ createPlacement: (spec: PlacementSpec) => {
41
+ mount(): void;
42
+ unmount(): void;
43
+ };
44
+ };
45
+ readonly ui: {
46
+ createElement: (name: string, options?: RequireUiComponentOptions) => Promise<SwishUiElement>;
47
+ };
48
+ readonly utils: {
49
+ copyToClipboard: typeof copyToClipboard;
50
+ createShareUrl: (args: {
51
+ publicListId: string;
52
+ }) => URL;
36
53
  };
37
54
  readonly state: {
38
55
  itemContext: (source?: HTMLElement) => import("@preact/signals-core").Signal<import("./state").ItemContext>;
@@ -82,6 +99,8 @@ export type * from "./options/types";
82
99
  export type * from "./storefront-api/storefront-api-client";
83
100
  export type { Ref, SwishUiElement } from "./swish-ui/swish-ui-element";
84
101
  export type { ListSelectOptions, ListSelectSubmitData, QuickBuyOptions, QuickBuySubmitData, Toast, ToastManager, UnsaveAlertOptions, UnsaveAlertSubmitData, VariantSelectOptions, VariantSelectSubmitData, } from "./swish-ui/types";
102
+ export { copyToClipboard } from "./utils/copy-to-clipboard";
103
+ export { buildShareListUrl } from "./utils/build-share-list-url";
85
104
  export type * from "./types";
86
105
  export type { SwishApp };
87
106
  declare global {