ui.shipaid.com 0.3.66 → 0.3.67

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.
Files changed (28) hide show
  1. package/README.md +200 -200
  2. package/dist/widget.es.js +2 -2
  3. package/dist/widget.iife.js +2 -2
  4. package/dist/widget.umd.js +2 -2
  5. package/dist-types/common/shopify/index.d.ts +6 -6
  6. package/dist-types/common/shopify/protection.d.ts +7 -7
  7. package/dist-types/common/shopify/types/ShopifyCart.d.ts +29 -29
  8. package/dist-types/common/shopify/types/ShopifyProduct.d.ts +12 -12
  9. package/dist-types/common/types/ShipAid.d.ts +82 -82
  10. package/dist-types/widget/src/assets/confirmation-styles.d.ts +2 -2
  11. package/dist-types/widget/src/assets/icons.d.ts +9 -9
  12. package/dist-types/widget/src/assets/learn-more-styles.d.ts +2 -2
  13. package/dist-types/widget/src/assets/styles.d.ts +2 -2
  14. package/dist-types/widget/src/components/checkout-package-protection.d.ts +13 -13
  15. package/dist-types/widget/src/components/confirmation-popup.d.ts +9 -9
  16. package/dist-types/widget/src/components/learn-more-popup.d.ts +8 -8
  17. package/dist-types/widget/src/components/product-add-confirmation.d.ts +13 -0
  18. package/dist-types/widget/src/components/shipaid-cart-confirmation.d.ts +15 -15
  19. package/dist-types/widget/src/shipaid-widget.d.ts +145 -145
  20. package/dist-types/widget/src/utils/fetch_interceptor.d.ts +3 -3
  21. package/dist-types/widget/src/utils/fetch_interceptor.test.d.ts +1 -1
  22. package/dist-types/widget/types/shipaid.d.ts +10 -10
  23. package/dist-types/widget/types/shopify.d.ts +29 -29
  24. package/dist-types/widget/types/widget.d.ts +13 -13
  25. package/package.json +48 -48
  26. package/dist-types/widget/src/components/checkout-button.d.ts +0 -7
  27. package/dist-types/widget/src/components/checkoutButton.d.ts +0 -13
  28. package/dist-types/widget/src/components/content-loader.d.ts +0 -6
@@ -1,145 +1,145 @@
1
- /// <reference types="node" />
2
- import { LitElement, nothing, PropertyValues } from 'lit';
3
- import './components/learn-more-popup';
4
- import './components/confirmation-popup';
5
- import './components/shipaid-cart-confirmation';
6
- import './components/checkout-package-protection';
7
- import type { ShopifyCart, ShopifyCartItem } from '../types/shopify';
8
- /**
9
- * ShipAid Widget.
10
- *
11
- * @description When the <shipaid-widget> element is added to page, it will render this element,
12
- * allowing a customer to add ShipAid protection to cart (and remove).
13
- *
14
- */
15
- export declare class ShipAidWidget extends LitElement {
16
- static styles: import("lit").CSSResult;
17
- env: string;
18
- useCustomStoreFront: boolean;
19
- storeDomain: string;
20
- storeAccessToken: string;
21
- cartId: string;
22
- disablePolling: boolean;
23
- disableActions: boolean;
24
- pollingInterval: number;
25
- disableRefresh: boolean;
26
- refreshCart: boolean;
27
- persistPopup: boolean;
28
- defaultToggleButton: boolean;
29
- lang: string;
30
- currency: undefined;
31
- customerId: undefined;
32
- supportSubscriptions: boolean;
33
- dataSelector: string;
34
- useShipAidCheckout: boolean;
35
- /** API Proxy pathname */
36
- private _apiEndpoint;
37
- /** The current store domain */
38
- private _storeDomain;
39
- /** The current store data object from the ShipAid API */
40
- private _store;
41
- /** The current cart data object from the Shopify API */
42
- private _cart;
43
- /** The current protection product data object from the Shopify API */
44
- private _protectionProduct;
45
- /** When the cart was last updated */
46
- private _cartLastUpdated;
47
- /** Whether we have finished the initial setup */
48
- private _hasFinishedSetup;
49
- /** Can be used to hide all widget content */
50
- private _shouldShowWidget;
51
- /** Can be used to check if page is on Cart */
52
- /** Whether the ShipAid protection product is currently added to the cart */
53
- private _hasProtectionInCart;
54
- /** The protection item from the Shopify cart */
55
- private _protectionCartItem;
56
- /** The protection variant that will be used */
57
- private _protectionVariant;
58
- hasLoadedStrings: boolean;
59
- fetchInterceptorCleanup: () => void;
60
- intervalId: NodeJS.Timeout | null;
61
- protected shouldUpdate(props: PropertyValues): boolean;
62
- protected shouldPersistPopup(): "learn-more" | null;
63
- protected setPopupKey(): void;
64
- /**
65
- * Internal state
66
- */
67
- private _state;
68
- /**
69
- * Internal popup state
70
- */
71
- private _popup;
72
- get nhost(): {
73
- request: (query: string, variables: Record<string, string>) => Promise<any>;
74
- };
75
- /** Runs a GraphQL query and returns the data
76
- * @param query GraphQL query string
77
- * @param variables Variables for the query
78
- * @returns Query response data
79
- */
80
- runStoreFrontQuery<Data>(query: string, variables: any): Promise<Data>;
81
- /** Getter to check if we should refresh the page or not */
82
- get shouldRefreshOnUpdate(): boolean;
83
- /** Getter to check whether to show the widget or not */
84
- get planActive(): boolean;
85
- private _currencyFormat;
86
- /** Emit events */
87
- private _dispatchEvent;
88
- private _handleRefreshCart;
89
- /** Handle cart or page refreshes */
90
- private _handleRefresh;
91
- /** Given the current order, it calculates the protection total according to the store protection settings. */
92
- calculateProtectionTotal(cart?: ShopifyCart): Promise<number>;
93
- /**
94
- * Given the current order, it finds the relevant protection product variant, and adds it to cart.
95
- * This should be run whenever the cart updates, or it is manually triggered.
96
- */
97
- private _findProtectionVariant;
98
- /** Update State */
99
- private _setState;
100
- /** Trigger confirmation popup */
101
- private _handleConfirmationPopup;
102
- /** Updates the current protection status, calling the relevant add/remove function. */
103
- private _updateProtection;
104
- /** General fetch function, which handles error responses, and returns JSON responses. */
105
- private _fetch;
106
- /** Fetches store info from the ShipAid public API. */
107
- private _fetchShipAidData;
108
- private _findSellingPlanByName;
109
- /** Fetches store info from the ShipAid public API. */
110
- private _fetchSellingPlanFromVariant;
111
- /** Fetch current cart from the Shopify ajax API */
112
- private _fetchCart;
113
- /** Fetch current product from the Shopify ajax API */
114
- private _fetchProduct;
115
- /** Whether the cart currently contains Shipping protection from ShipAid. */
116
- hasProtection(): boolean;
117
- /** Update the internal cart, which will trigger any protection fee updates */
118
- updateCart(cart?: ShopifyCart): Promise<void>;
119
- addCartProtectionVariant(): Promise<any>;
120
- updateCartProtectionVariant(qty: number, protectionCartItem?: ShopifyCartItem | null, sellingPlanId?: string | null): Promise<any>;
121
- /** Add ShipAid shipping protection. */
122
- addProtection(): Promise<void>;
123
- /** Remove ShipAid shipping protection. */
124
- removeProtection(): Promise<void>;
125
- /** Try adding ShipAid shipping protection during polling if applicable */
126
- attemptAddProtection(): Promise<void>;
127
- handleMultipleProtectionVariants(): Promise<void>;
128
- /** Templates */
129
- learnMorePopupTemplate(): import("lit").TemplateResult<1>;
130
- confirmationPopupTemplate(): import("lit").TemplateResult<1>;
131
- contactlessCheckoutButtonTemplate(): typeof nothing | undefined;
132
- createRenderRoot(): Element | ShadowRoot;
133
- checkoutButtonTemplate(): import("lit").TemplateResult<1> | undefined;
134
- renderPopups(): import("lit").TemplateResult<1> | null;
135
- promptTemplate(): import("lit").TemplateResult<1> | undefined;
136
- connectedCallback(): Promise<void>;
137
- disconnectedCallback(): void;
138
- updateProtection(): Promise<void>;
139
- protected render(): import("lit").TemplateResult<1>;
140
- }
141
- declare global {
142
- interface HTMLElementTagNameMap {
143
- 'shipaid-widget': ShipAidWidget;
144
- }
145
- }
1
+ /// <reference types="node" />
2
+ import { LitElement, nothing, PropertyValues } from 'lit';
3
+ import './components/learn-more-popup';
4
+ import './components/confirmation-popup';
5
+ import './components/shipaid-cart-confirmation';
6
+ import './components/checkout-package-protection';
7
+ import type { ShopifyCart, ShopifyCartItem } from '../types/shopify';
8
+ /**
9
+ * ShipAid Widget.
10
+ *
11
+ * @description When the <shipaid-widget> element is added to page, it will render this element,
12
+ * allowing a customer to add ShipAid protection to cart (and remove).
13
+ *
14
+ */
15
+ export declare class ShipAidWidget extends LitElement {
16
+ static styles: import("lit").CSSResult;
17
+ env: string;
18
+ useCustomStoreFront: boolean;
19
+ storeDomain: string;
20
+ storeAccessToken: string;
21
+ cartId: string;
22
+ disablePolling: boolean;
23
+ disableActions: boolean;
24
+ pollingInterval: number;
25
+ disableRefresh: boolean;
26
+ refreshCart: boolean;
27
+ persistPopup: boolean;
28
+ defaultToggleButton: boolean;
29
+ lang: string;
30
+ currency: undefined;
31
+ customerId: undefined;
32
+ supportSubscriptions: boolean;
33
+ dataSelector: string;
34
+ useShipAidCheckout: boolean;
35
+ /** API Proxy pathname */
36
+ private _apiEndpoint;
37
+ /** The current store domain */
38
+ private _storeDomain;
39
+ /** The current store data object from the ShipAid API */
40
+ private _store;
41
+ /** The current cart data object from the Shopify API */
42
+ private _cart;
43
+ /** The current protection product data object from the Shopify API */
44
+ private _protectionProduct;
45
+ /** When the cart was last updated */
46
+ private _cartLastUpdated;
47
+ /** Whether we have finished the initial setup */
48
+ private _hasFinishedSetup;
49
+ /** Can be used to hide all widget content */
50
+ private _shouldShowWidget;
51
+ /** Can be used to check if page is on Cart */
52
+ /** Whether the ShipAid protection product is currently added to the cart */
53
+ private _hasProtectionInCart;
54
+ /** The protection item from the Shopify cart */
55
+ private _protectionCartItem;
56
+ /** The protection variant that will be used */
57
+ private _protectionVariant;
58
+ hasLoadedStrings: boolean;
59
+ fetchInterceptorCleanup: () => void;
60
+ intervalId: NodeJS.Timeout | null;
61
+ protected shouldUpdate(props: PropertyValues): boolean;
62
+ protected shouldPersistPopup(): "learn-more" | null;
63
+ protected setPopupKey(): void;
64
+ /**
65
+ * Internal state
66
+ */
67
+ private _state;
68
+ /**
69
+ * Internal popup state
70
+ */
71
+ private _popup;
72
+ get nhost(): {
73
+ request: (query: string, variables: Record<string, string>) => Promise<any>;
74
+ };
75
+ /** Runs a GraphQL query and returns the data
76
+ * @param query GraphQL query string
77
+ * @param variables Variables for the query
78
+ * @returns Query response data
79
+ */
80
+ runStoreFrontQuery<Data>(query: string, variables: any): Promise<Data>;
81
+ /** Getter to check if we should refresh the page or not */
82
+ get shouldRefreshOnUpdate(): boolean;
83
+ /** Getter to check whether to show the widget or not */
84
+ get planActive(): boolean;
85
+ private _currencyFormat;
86
+ /** Emit events */
87
+ private _dispatchEvent;
88
+ private _handleRefreshCart;
89
+ /** Handle cart or page refreshes */
90
+ private _handleRefresh;
91
+ /** Given the current order, it calculates the protection total according to the store protection settings. */
92
+ calculateProtectionTotal(cart?: ShopifyCart): Promise<number>;
93
+ /**
94
+ * Given the current order, it finds the relevant protection product variant, and adds it to cart.
95
+ * This should be run whenever the cart updates, or it is manually triggered.
96
+ */
97
+ private _findProtectionVariant;
98
+ /** Update State */
99
+ private _setState;
100
+ /** Trigger confirmation popup */
101
+ private _handleConfirmationPopup;
102
+ /** Updates the current protection status, calling the relevant add/remove function. */
103
+ private _updateProtection;
104
+ /** General fetch function, which handles error responses, and returns JSON responses. */
105
+ private _fetch;
106
+ /** Fetches store info from the ShipAid public API. */
107
+ private _fetchShipAidData;
108
+ private _findSellingPlanByName;
109
+ /** Fetches store info from the ShipAid public API. */
110
+ private _fetchSellingPlanFromVariant;
111
+ /** Fetch current cart from the Shopify ajax API */
112
+ private _fetchCart;
113
+ /** Fetch current product from the Shopify ajax API */
114
+ private _fetchProduct;
115
+ /** Whether the cart currently contains Shipping protection from ShipAid. */
116
+ hasProtection(): boolean;
117
+ /** Update the internal cart, which will trigger any protection fee updates */
118
+ updateCart(cart?: ShopifyCart): Promise<void>;
119
+ addCartProtectionVariant(): Promise<any>;
120
+ updateCartProtectionVariant(qty: number, protectionCartItem?: ShopifyCartItem | null, sellingPlanId?: string | null): Promise<any>;
121
+ /** Add ShipAid shipping protection. */
122
+ addProtection(): Promise<void>;
123
+ /** Remove ShipAid shipping protection. */
124
+ removeProtection(): Promise<void>;
125
+ /** Try adding ShipAid shipping protection during polling if applicable */
126
+ attemptAddProtection(): Promise<void>;
127
+ handleMultipleProtectionVariants(): Promise<void>;
128
+ /** Templates */
129
+ learnMorePopupTemplate(): import("lit").TemplateResult<1>;
130
+ confirmationPopupTemplate(): import("lit").TemplateResult<1>;
131
+ contactlessCheckoutButtonTemplate(): typeof nothing | undefined;
132
+ createRenderRoot(): Element | ShadowRoot;
133
+ checkoutButtonTemplate(): import("lit").TemplateResult<1> | undefined;
134
+ renderPopups(): import("lit").TemplateResult<1> | null;
135
+ promptTemplate(): import("lit").TemplateResult<1> | undefined;
136
+ connectedCallback(): Promise<void>;
137
+ disconnectedCallback(): void;
138
+ updateProtection(): Promise<void>;
139
+ protected render(): import("lit").TemplateResult<1>;
140
+ }
141
+ declare global {
142
+ interface HTMLElementTagNameMap {
143
+ 'shipaid-widget': ShipAidWidget;
144
+ }
145
+ }
@@ -1,3 +1,3 @@
1
- type FetchInterceptor = (args: any[], promise: Promise<Response>) => void | Promise<void>;
2
- export declare function interceptFetch(interceptor: FetchInterceptor): () => void;
3
- export {};
1
+ type FetchInterceptor = (args: any[], promise: Promise<Response>) => void | Promise<void>;
2
+ export declare function interceptFetch(interceptor: FetchInterceptor): () => void;
3
+ export {};
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,10 +1,10 @@
1
- import { ShipAidStore } from '../../common/types/ShipAid';
2
- export interface ShipAidStoreQuery {
3
- data: null | {
4
- store: ShipAidStore;
5
- };
6
- errors?: {
7
- message: string;
8
- }[];
9
- }
10
- export { ShipAidStore };
1
+ import { ShipAidStore } from '../../common/types/ShipAid';
2
+ export interface ShipAidStoreQuery {
3
+ data: null | {
4
+ store: ShipAidStore;
5
+ };
6
+ errors?: {
7
+ message: string;
8
+ }[];
9
+ }
10
+ export { ShipAidStore };
@@ -1,29 +1,29 @@
1
- import { ShopifyProduct } from '../../common/shopify/types/ShopifyProduct';
2
- export * from '../../common/shopify/types/ShopifyCart';
3
- export * from '../../common/shopify/types/ShopifyProduct';
4
- declare global {
5
- interface Window {
6
- Shopify?: {
7
- shop?: string;
8
- locale?: string;
9
- designMode?: boolean;
10
- currency?: {
11
- active?: string;
12
- };
13
- Checkout?: Record<string, string> & {
14
- apiHost?: string;
15
- };
16
- };
17
- }
18
- }
19
- export interface ShopifyCartAddPayload {
20
- id: number | string;
21
- quantity?: number;
22
- selling_plan?: number | string | null;
23
- }
24
- export interface ShopifyCartUpdatePayload {
25
- updates: Record<string | number, number>;
26
- }
27
- export interface ShopifyProductResponse {
28
- product: ShopifyProduct;
29
- }
1
+ import { ShopifyProduct } from '../../common/shopify/types/ShopifyProduct';
2
+ export * from '../../common/shopify/types/ShopifyCart';
3
+ export * from '../../common/shopify/types/ShopifyProduct';
4
+ declare global {
5
+ interface Window {
6
+ Shopify?: {
7
+ shop?: string;
8
+ locale?: string;
9
+ designMode?: boolean;
10
+ currency?: {
11
+ active?: string;
12
+ };
13
+ Checkout?: Record<string, string> & {
14
+ apiHost?: string;
15
+ };
16
+ };
17
+ }
18
+ }
19
+ export interface ShopifyCartAddPayload {
20
+ id: number | string;
21
+ quantity?: number;
22
+ selling_plan?: number | string | null;
23
+ }
24
+ export interface ShopifyCartUpdatePayload {
25
+ updates: Record<string | number, number>;
26
+ }
27
+ export interface ShopifyProductResponse {
28
+ product: ShopifyProduct;
29
+ }
@@ -1,13 +1,13 @@
1
- export declare enum Events {
2
- LOADED = "shipaid-loaded",
3
- STATUS_UPDATE = "shipaid-protection-status"
4
- }
5
- export interface State {
6
- loading: boolean;
7
- success: boolean | null;
8
- error: boolean | string | null;
9
- }
10
- export interface FetchHelper {
11
- get: <Data>(url: string) => Promise<Data>;
12
- post: <Data>(url: string, body: unknown) => Promise<Data>;
13
- }
1
+ export declare enum Events {
2
+ LOADED = "shipaid-loaded",
3
+ STATUS_UPDATE = "shipaid-protection-status"
4
+ }
5
+ export interface State {
6
+ loading: boolean;
7
+ success: boolean | null;
8
+ error: boolean | string | null;
9
+ }
10
+ export interface FetchHelper {
11
+ get: <Data>(url: string) => Promise<Data>;
12
+ post: <Data>(url: string, body: unknown) => Promise<Data>;
13
+ }
package/package.json CHANGED
@@ -1,49 +1,49 @@
1
- {
2
- "name": "ui.shipaid.com",
3
- "private": false,
4
- "version": "0.3.66",
5
- "type": "module",
6
- "main": "dist/widget.umd.js",
7
- "unpkg": "dist/widget.iife.js",
8
- "module": "dist/widget.es.js",
9
- "exports": {
10
- ".": "./dist/widget.es.js"
11
- },
12
- "types": "dist-types/src/shipaid-widget.d.ts",
13
- "files": [
14
- "dist-types",
15
- "dist"
16
- ],
17
- "scripts": {
18
- "develop": "vite",
19
- "build": "tsc && node build",
20
- "lint": "eslint . --ext=ts --fix",
21
- "test": "vitest"
22
- },
23
- "dependencies": {
24
- "@lit-labs/task": "^2.0.0",
25
- "lit": "^2.6.1",
26
- "lit-element-effect": "^1.0.2",
27
- "lit-translate": "^2.0.1",
28
- "@nhost/nhost-js": "^3.1.10"
29
- },
30
- "devDependencies": {
31
- "@typescript-eslint/eslint-plugin": "^5.49.0",
32
- "@typescript-eslint/parser": "^5.49.0",
33
- "@vitest/browser": "^2.1.4",
34
- "eslint": "^8.32.0",
35
- "eslint-config-standard": "^17.0.0",
36
- "eslint-plugin-html": "^7.1.0",
37
- "eslint-plugin-import": "^2.27.5",
38
- "eslint-plugin-lit": "^1.8.2",
39
- "eslint-plugin-lit-a11y": "^2.3.0",
40
- "eslint-plugin-n": "^15.6.1",
41
- "eslint-plugin-promise": "^6.1.1",
42
- "jsdom": "^25.0.1",
43
- "playwright": "^1.48.2",
44
- "terser": "^5.16.1",
45
- "typescript": "^4.9.4",
46
- "vite": "^5.4.10",
47
- "vitest": "^2.1.4"
48
- }
1
+ {
2
+ "name": "ui.shipaid.com",
3
+ "private": false,
4
+ "version": "0.3.67",
5
+ "type": "module",
6
+ "main": "dist/widget.umd.js",
7
+ "unpkg": "dist/widget.iife.js",
8
+ "module": "dist/widget.es.js",
9
+ "exports": {
10
+ ".": "./dist/widget.es.js"
11
+ },
12
+ "types": "dist-types/src/shipaid-widget.d.ts",
13
+ "files": [
14
+ "dist-types",
15
+ "dist"
16
+ ],
17
+ "dependencies": {
18
+ "@lit-labs/task": "^2.0.0",
19
+ "lit": "^2.6.1",
20
+ "lit-element-effect": "^1.0.2",
21
+ "lit-translate": "^2.0.1",
22
+ "@nhost/nhost-js": "^3.1.10"
23
+ },
24
+ "devDependencies": {
25
+ "@typescript-eslint/eslint-plugin": "^5.49.0",
26
+ "@typescript-eslint/parser": "^5.49.0",
27
+ "@vitest/browser": "^2.1.4",
28
+ "eslint": "^8.32.0",
29
+ "eslint-config-standard": "^17.0.0",
30
+ "eslint-plugin-html": "^7.1.0",
31
+ "eslint-plugin-import": "^2.27.5",
32
+ "eslint-plugin-lit": "^1.8.2",
33
+ "eslint-plugin-lit-a11y": "^2.3.0",
34
+ "eslint-plugin-n": "^15.6.1",
35
+ "eslint-plugin-promise": "^6.1.1",
36
+ "jsdom": "^25.0.1",
37
+ "playwright": "^1.48.2",
38
+ "terser": "^5.16.1",
39
+ "typescript": "^4.9.4",
40
+ "vite": "^5.4.10",
41
+ "vitest": "^2.1.4"
42
+ },
43
+ "scripts": {
44
+ "develop": "vite",
45
+ "build": "tsc && node build",
46
+ "lint": "eslint . --ext=ts --fix",
47
+ "test": "vitest"
48
+ }
49
49
  }
@@ -1,7 +0,0 @@
1
- import { LitElement } from 'lit';
2
- declare class ShipAidCheckoutButton extends LitElement {
3
- createRenderRoot(): this;
4
- buttonClasses: string;
5
- render(): import("lit").TemplateResult<1>;
6
- }
7
- export default ShipAidCheckoutButton;
@@ -1,13 +0,0 @@
1
- import { LitElement } from 'lit';
2
- export declare class CheckoutPackageProtection extends LitElement {
3
- /**
4
- * Precio de la protección
5
- */
6
- protectionPrice: number;
7
- /**
8
- * Total del checkout
9
- */
10
- checkoutTotal: number;
11
- static styles: import("lit").CSSResult;
12
- render(): import("lit").TemplateResult<1>;
13
- }
@@ -1,6 +0,0 @@
1
- import { LitElement } from 'lit';
2
- export declare class SuspenseLoader extends LitElement {
3
- loading: boolean;
4
- static styles: import("lit").CSSResult;
5
- render(): import("lit").TemplateResult<1>;
6
- }