@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.
@@ -1,4 +1,6 @@
1
+ import { Signal } from "../state";
1
2
  import { SwishApp } from "../swish";
3
+ import { PreviewOptions } from "../types";
2
4
  import type { Ref, SwishUiElement } from "./swish-ui-element";
3
5
  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
6
  export declare class SwishUi {
@@ -9,7 +11,11 @@ export declare class SwishUi {
9
11
  private scrollLockRefCount;
10
12
  private scrollPositionBeforeLock;
11
13
  private elementId;
12
- constructor(swishApp: SwishApp);
14
+ readonly isPreview: boolean;
15
+ private readonly previewCssStylesheet;
16
+ readonly icons: Signal<Record<string, string>>;
17
+ private readonly themeVariablesStylesheet;
18
+ constructor(swishApp: SwishApp, isPreview: boolean);
13
19
  showModal(element: string | HTMLElement): Promise<void>;
14
20
  hideModal(element: string | HTMLElement): Promise<void>;
15
21
  private waitForEvent;
@@ -17,6 +23,7 @@ export declare class SwishUi {
17
23
  showUnsaveAlert(options: UnsaveAlertOptions): Promise<UiResponse<UnsaveAlertSubmitData>>;
18
24
  showDeleteListAlert(options: DeleteListAlertOptions): Promise<UiResponse<void>>;
19
25
  showConfirmDialog(options: ConfirmDialogOptions): Promise<UiResponse<void>>;
26
+ hideDrawer(): void;
20
27
  showDrawer(options?: DrawerOptions): Promise<UiResponse<void>>;
21
28
  showListMenu(options: ListMenuOptions): Promise<ListMenuResponse>;
22
29
  showOrderMenu(options: OrderMenuOptions): Promise<OrderMenuResponse>;
@@ -38,9 +45,8 @@ export declare class SwishUi {
38
45
  private _loadLocalePromise;
39
46
  loadLocale(): Promise<void>;
40
47
  private _loadCricalResourcesPromise;
41
- loadCricalResources(): Promise<{
42
- themeVariablesStylesheet: CSSStyleSheet;
43
- }>;
48
+ loadCricalResources(): Promise<void>;
49
+ applyPreview({ design, css, icons }: PreviewOptions["ui"]): void;
44
50
  private _loadNonCriticalResourcesPromise;
45
51
  loadNonCriticalResources(): Promise<{
46
52
  bundleCssStylesheet: CSSStyleSheet;
package/dist/swish.d.ts CHANGED
@@ -10,9 +10,11 @@ import { SwishQuery } from "./query";
10
10
  import { computed, effect, signal } from "./state";
11
11
  import { StorefrontApiClient } from "./storefront-api/storefront-api-client";
12
12
  import { SwishApi } from "./swish-api/swish-api-client";
13
+ import { SwishUi } from "./swish-ui/swish-ui";
13
14
  import { SwishUiElement } from "./swish-ui/swish-ui-element";
14
15
  import { RequireUiComponentOptions } from "./swish-ui/types";
15
16
  import { copyToClipboard } from "./utils/copy-to-clipboard";
17
+ import { PreviewOptions } from "./types";
16
18
  export declare const VERSION: string;
17
19
  export declare const swishSdkUrl: string;
18
20
  export declare const createSwish: (optionsInput: SwishOptionsInput) => Promise<SwishApp>;
@@ -29,7 +31,8 @@ declare class SwishApp {
29
31
  readonly events: EventBus;
30
32
  readonly intents: Intents;
31
33
  readonly query: SwishQuery;
32
- constructor(options: SwishOptions);
34
+ readonly isPreview: boolean;
35
+ constructor(options: SwishOptions, isPreview: boolean);
33
36
  get options(): SwishOptions;
34
37
  get storefrontContext(): import("./swish").StorefrontContext;
35
38
  get api(): SwishApi;
@@ -49,8 +52,12 @@ declare class SwishApp {
49
52
  unmount: () => void;
50
53
  }[];
51
54
  };
55
+ applyPreview(preview: PreviewOptions): void;
56
+ get iconsSignal(): import("@preact/signals-core").Signal<Record<string, string>>;
52
57
  readonly ui: {
53
58
  createElement: (name: string, options?: RequireUiComponentOptions) => Promise<SwishUiElement>;
59
+ showDrawer: (options?: Parameters<SwishUi["showDrawer"]>[0]) => Promise<import("./swish-ui/types").ClosedUiResponse | import("./swish-ui/types").SuccessUiResponse<void>>;
60
+ hideDrawer: () => void;
54
61
  };
55
62
  readonly utils: {
56
63
  copyToClipboard: typeof copyToClipboard;
@@ -108,13 +115,14 @@ declare class SwishApp {
108
115
  export type * from "@swishapp/api-client/2026-04";
109
116
  export type { SwishI18n } from "@swishapp/i18n";
110
117
  export type * from "./ajax-api/ajax-api-client";
118
+ export { isCustomiserMounted, mountCustomiser, mountCustomiserIfRequested, unmountCustomiser, type CustomiserMountOptions, } from "./customiser";
111
119
  export type { EventName } from "./events/event-bus";
112
120
  export type * from "./intents/types";
113
121
  export type { SwishOptionsInput } from "./options/swish-options";
114
122
  export type * from "./options/types";
115
123
  export { getSwishQueryStorageKey } from "./query";
116
- export type { ItemMatch, ItemStateCallbacks, ItemStateOptions, } from "./state/item-state-signal";
117
124
  export type { ItemContext, ItemContextIds } from "./state/item-context-signal";
125
+ export type { ItemMatch, ItemStateCallbacks, ItemStateOptions, } from "./state/item-state-signal";
118
126
  export type * from "./storefront-api/storefront-api-client";
119
127
  export type { Ref, SwishUiElement } from "./swish-ui/swish-ui-element";
120
128
  export type { ListSelectOptions, ListSelectSubmitData, QuickBuyOptions, QuickBuySubmitData, Toast, ToastManager, UnsaveAlertOptions, UnsaveAlertSubmitData, VariantSelectOptions, VariantSelectSubmitData, } from "./swish-ui/types";
@@ -128,6 +136,11 @@ declare global {
128
136
  analytics?: {
129
137
  publish?: (event: string, data: Record<string, any>) => void;
130
138
  };
139
+ theme?: {
140
+ id: number;
141
+ name?: string;
142
+ role?: string;
143
+ };
131
144
  };
132
145
  _SWISH_UI_VERSION?: string;
133
146
  }