ui.shipaid.com 0.3.102 → 0.3.103
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.
- package/README.md +202 -202
- package/dist/widget.es.js +13 -3
- package/dist/widget.iife.js +1 -1
- package/dist/widget.umd.js +1 -1
- package/dist-types/common/shopify/index.d.ts +6 -6
- package/dist-types/common/shopify/protection.d.ts +7 -7
- package/dist-types/common/shopify/types/ShopifyCart.d.ts +29 -29
- package/dist-types/common/shopify/types/ShopifyProduct.d.ts +12 -12
- package/dist-types/common/types/ShipAid.d.ts +82 -82
- package/dist-types/widget/src/assets/confirmation-styles.d.ts +2 -2
- package/dist-types/widget/src/assets/icons.d.ts +9 -9
- package/dist-types/widget/src/assets/learn-more-styles.d.ts +2 -2
- package/dist-types/widget/src/assets/styles.d.ts +2 -2
- package/dist-types/widget/src/components/checkout-package-protection.d.ts +13 -13
- package/dist-types/widget/src/components/confirmation-popup.d.ts +9 -9
- package/dist-types/widget/src/components/learn-more-popup.d.ts +8 -8
- package/dist-types/widget/src/components/product-add-confirmation.d.ts +13 -0
- package/dist-types/widget/src/components/shipaid-cart-confirmation.d.ts +15 -15
- package/dist-types/widget/src/shipaid-widget.d.ts +150 -150
- package/dist-types/widget/src/utils/fetch_interceptor.d.ts +3 -3
- package/dist-types/widget/src/utils/fetch_interceptor.test.d.ts +1 -1
- package/dist-types/widget/types/shipaid.d.ts +10 -10
- package/dist-types/widget/types/shopify.d.ts +29 -29
- package/dist-types/widget/types/widget.d.ts +13 -13
- package/package.json +48 -48
- package/dist-types/widget/src/components/checkout-button.d.ts +0 -7
- package/dist-types/widget/src/components/checkoutButton.d.ts +0 -13
- package/dist-types/widget/src/components/content-loader.d.ts +0 -6
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
export interface ProtectionSettingsProductVariant {
|
|
2
|
-
id?: string;
|
|
3
|
-
sku?: string;
|
|
4
|
-
price?: string;
|
|
5
|
-
title?: string;
|
|
6
|
-
selectedOptions?: Array<{
|
|
7
|
-
name?: string;
|
|
8
|
-
value?: string;
|
|
9
|
-
}>;
|
|
10
|
-
}
|
|
11
|
-
export interface ProtectionSettingsProduct {
|
|
12
|
-
id?: string;
|
|
13
|
-
title?: string;
|
|
14
|
-
options?: Array<{
|
|
15
|
-
name: string;
|
|
16
|
-
value: string;
|
|
17
|
-
}>;
|
|
18
|
-
variants?: {
|
|
19
|
-
edges?: Array<{
|
|
20
|
-
node?: ProtectionSettingsProductVariant;
|
|
21
|
-
}>;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export interface ProtectionSettings {
|
|
25
|
-
product?: ProtectionSettingsProduct;
|
|
26
|
-
}
|
|
27
|
-
export interface ProtectionSettingsPercentage {
|
|
28
|
-
protectionType: 'PERCENTAGE';
|
|
29
|
-
percentage: number;
|
|
30
|
-
minimumFee: number;
|
|
31
|
-
}
|
|
32
|
-
export interface ProtectionSettingsFixed {
|
|
33
|
-
protectionType: 'FIXED';
|
|
34
|
-
defaultFee?: number;
|
|
35
|
-
rules?: Array<{
|
|
36
|
-
fee?: number;
|
|
37
|
-
rangeLower?: number;
|
|
38
|
-
rangeUpper?: number;
|
|
39
|
-
}>;
|
|
40
|
-
}
|
|
41
|
-
declare enum Deadline {
|
|
42
|
-
THIRTY_MIN = "THIRTY_MIN",
|
|
43
|
-
SIXTY_MIN = "SIXTY_MIN",
|
|
44
|
-
NINETY_MIN = "NINETY_MIN",
|
|
45
|
-
TWO_HOURS = "TWO_HOURS",
|
|
46
|
-
THREE_HOURS = "THREE_HOURS",
|
|
47
|
-
SIX_HOURS = "SIX_HOURS",
|
|
48
|
-
TWELVE_HOURS = "TWELVE_HOURS",
|
|
49
|
-
ONE_DAY = "ONE_DAY",
|
|
50
|
-
TWO_DAYS = "TWO_DAYS",
|
|
51
|
-
THREE_DAYS = "THREE_DAYS",
|
|
52
|
-
FIVE_DAYS = "FIVE_DAYS",
|
|
53
|
-
TEN_DAYS = "TEN_DAYS"
|
|
54
|
-
}
|
|
55
|
-
interface OrderSettings {
|
|
56
|
-
deadline: {
|
|
57
|
-
timing: Deadline;
|
|
58
|
-
description: string;
|
|
59
|
-
};
|
|
60
|
-
shipping: {
|
|
61
|
-
allow_customer_to_use_po_boxes: boolean;
|
|
62
|
-
allow_customer_to_edit_shipping: boolean;
|
|
63
|
-
allow_gmaps_to_verify_addresses: boolean;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
export interface ShipAidStore {
|
|
67
|
-
store: string;
|
|
68
|
-
currency: string;
|
|
69
|
-
widgetAutoOptIn?: boolean;
|
|
70
|
-
useCustomApp?: boolean;
|
|
71
|
-
widgetPollProtection?: boolean;
|
|
72
|
-
widgetShowCart?: boolean;
|
|
73
|
-
excludedProductSkus?: string[];
|
|
74
|
-
excludedProductsVariantsId?: string[];
|
|
75
|
-
excludedCustomersIdsAutoOptIn?: string[] | null;
|
|
76
|
-
planActive: boolean;
|
|
77
|
-
protectionSettings: ProtectionSettingsFixed | ProtectionSettingsPercentage;
|
|
78
|
-
widgetConfigurations: any;
|
|
79
|
-
orderSettings: OrderSettings;
|
|
80
|
-
autoOptInProbability: any;
|
|
81
|
-
}
|
|
82
|
-
export {};
|
|
1
|
+
export interface ProtectionSettingsProductVariant {
|
|
2
|
+
id?: string;
|
|
3
|
+
sku?: string;
|
|
4
|
+
price?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
selectedOptions?: Array<{
|
|
7
|
+
name?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export interface ProtectionSettingsProduct {
|
|
12
|
+
id?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
options?: Array<{
|
|
15
|
+
name: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}>;
|
|
18
|
+
variants?: {
|
|
19
|
+
edges?: Array<{
|
|
20
|
+
node?: ProtectionSettingsProductVariant;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface ProtectionSettings {
|
|
25
|
+
product?: ProtectionSettingsProduct;
|
|
26
|
+
}
|
|
27
|
+
export interface ProtectionSettingsPercentage {
|
|
28
|
+
protectionType: 'PERCENTAGE';
|
|
29
|
+
percentage: number;
|
|
30
|
+
minimumFee: number;
|
|
31
|
+
}
|
|
32
|
+
export interface ProtectionSettingsFixed {
|
|
33
|
+
protectionType: 'FIXED';
|
|
34
|
+
defaultFee?: number;
|
|
35
|
+
rules?: Array<{
|
|
36
|
+
fee?: number;
|
|
37
|
+
rangeLower?: number;
|
|
38
|
+
rangeUpper?: number;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
declare enum Deadline {
|
|
42
|
+
THIRTY_MIN = "THIRTY_MIN",
|
|
43
|
+
SIXTY_MIN = "SIXTY_MIN",
|
|
44
|
+
NINETY_MIN = "NINETY_MIN",
|
|
45
|
+
TWO_HOURS = "TWO_HOURS",
|
|
46
|
+
THREE_HOURS = "THREE_HOURS",
|
|
47
|
+
SIX_HOURS = "SIX_HOURS",
|
|
48
|
+
TWELVE_HOURS = "TWELVE_HOURS",
|
|
49
|
+
ONE_DAY = "ONE_DAY",
|
|
50
|
+
TWO_DAYS = "TWO_DAYS",
|
|
51
|
+
THREE_DAYS = "THREE_DAYS",
|
|
52
|
+
FIVE_DAYS = "FIVE_DAYS",
|
|
53
|
+
TEN_DAYS = "TEN_DAYS"
|
|
54
|
+
}
|
|
55
|
+
interface OrderSettings {
|
|
56
|
+
deadline: {
|
|
57
|
+
timing: Deadline;
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
shipping: {
|
|
61
|
+
allow_customer_to_use_po_boxes: boolean;
|
|
62
|
+
allow_customer_to_edit_shipping: boolean;
|
|
63
|
+
allow_gmaps_to_verify_addresses: boolean;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export interface ShipAidStore {
|
|
67
|
+
store: string;
|
|
68
|
+
currency: string;
|
|
69
|
+
widgetAutoOptIn?: boolean;
|
|
70
|
+
useCustomApp?: boolean;
|
|
71
|
+
widgetPollProtection?: boolean;
|
|
72
|
+
widgetShowCart?: boolean;
|
|
73
|
+
excludedProductSkus?: string[];
|
|
74
|
+
excludedProductsVariantsId?: string[];
|
|
75
|
+
excludedCustomersIdsAutoOptIn?: string[] | null;
|
|
76
|
+
planActive: boolean;
|
|
77
|
+
protectionSettings: ProtectionSettingsFixed | ProtectionSettingsPercentage;
|
|
78
|
+
widgetConfigurations: any;
|
|
79
|
+
orderSettings: OrderSettings;
|
|
80
|
+
autoOptInProbability: any;
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const styles: import("lit").CSSResult;
|
|
2
|
-
export default styles;
|
|
1
|
+
declare const styles: import("lit").CSSResult;
|
|
2
|
+
export default styles;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export declare const CheckmarkIcon: import("lit").TemplateResult<1>;
|
|
2
|
-
export declare const ShipAidLogo: import("lit").TemplateResult<1>;
|
|
3
|
-
export declare const ShipAidReducedLogo: import("lit").TemplateResult<1>;
|
|
4
|
-
export declare const ShipAidLogoText: import("lit").TemplateResult<1>;
|
|
5
|
-
export declare const ShipAidLogoPopUp: import("lit").TemplateResult<1>;
|
|
6
|
-
export declare const CheckmarkRibbon: import("lit").TemplateResult<1>;
|
|
7
|
-
export declare const MapIcon: import("lit").TemplateResult<1>;
|
|
8
|
-
export declare const BoxIcon: import("lit").TemplateResult<1>;
|
|
9
|
-
export declare const BellIcon: import("lit").TemplateResult<1>;
|
|
1
|
+
export declare const CheckmarkIcon: import("lit").TemplateResult<1>;
|
|
2
|
+
export declare const ShipAidLogo: import("lit").TemplateResult<1>;
|
|
3
|
+
export declare const ShipAidReducedLogo: import("lit").TemplateResult<1>;
|
|
4
|
+
export declare const ShipAidLogoText: import("lit").TemplateResult<1>;
|
|
5
|
+
export declare const ShipAidLogoPopUp: import("lit").TemplateResult<1>;
|
|
6
|
+
export declare const CheckmarkRibbon: import("lit").TemplateResult<1>;
|
|
7
|
+
export declare const MapIcon: import("lit").TemplateResult<1>;
|
|
8
|
+
export declare const BoxIcon: import("lit").TemplateResult<1>;
|
|
9
|
+
export declare const BellIcon: import("lit").TemplateResult<1>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const styles: import("lit").CSSResult;
|
|
2
|
-
export default styles;
|
|
1
|
+
declare const styles: import("lit").CSSResult;
|
|
2
|
+
export default styles;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("lit").CSSResult;
|
|
2
|
-
export default _default;
|
|
1
|
+
declare const _default: import("lit").CSSResult;
|
|
2
|
+
export default _default;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
declare class CheckoutPackageProtection extends LitElement {
|
|
3
|
-
createRenderRoot(): this;
|
|
4
|
-
protectionPrice: number;
|
|
5
|
-
checkoutTotal: number;
|
|
6
|
-
shipaidVariant: null;
|
|
7
|
-
logo: string;
|
|
8
|
-
originalClasses: string;
|
|
9
|
-
handleAbout(): void;
|
|
10
|
-
handleCheckoutWithoutProtection(): void;
|
|
11
|
-
render(): import("lit").TemplateResult<1>;
|
|
12
|
-
}
|
|
13
|
-
export default CheckoutPackageProtection;
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare class CheckoutPackageProtection extends LitElement {
|
|
3
|
+
createRenderRoot(): this;
|
|
4
|
+
protectionPrice: number;
|
|
5
|
+
checkoutTotal: number;
|
|
6
|
+
shipaidVariant: null;
|
|
7
|
+
logo: string;
|
|
8
|
+
originalClasses: string;
|
|
9
|
+
handleAbout(): void;
|
|
10
|
+
handleCheckoutWithoutProtection(): void;
|
|
11
|
+
render(): import("lit").TemplateResult<1>;
|
|
12
|
+
}
|
|
13
|
+
export default CheckoutPackageProtection;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
declare class ConfirmationPopup extends LitElement {
|
|
3
|
-
static styles: import("lit").CSSResult;
|
|
4
|
-
active: boolean;
|
|
5
|
-
handleClosePopup(): void;
|
|
6
|
-
handleRemoveProtection(): void;
|
|
7
|
-
render(): import("lit").TemplateResult<1>;
|
|
8
|
-
}
|
|
9
|
-
export default ConfirmationPopup;
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare class ConfirmationPopup extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult;
|
|
4
|
+
active: boolean;
|
|
5
|
+
handleClosePopup(): void;
|
|
6
|
+
handleRemoveProtection(): void;
|
|
7
|
+
render(): import("lit").TemplateResult<1>;
|
|
8
|
+
}
|
|
9
|
+
export default ConfirmationPopup;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
declare class LearnMorePopup extends LitElement {
|
|
3
|
-
static styles: import("lit").CSSResult;
|
|
4
|
-
active: boolean;
|
|
5
|
-
handleClosePopup(): void;
|
|
6
|
-
render(): import("lit").TemplateResult<1>;
|
|
7
|
-
}
|
|
8
|
-
export default LearnMorePopup;
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare class LearnMorePopup extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult;
|
|
4
|
+
active: boolean;
|
|
5
|
+
handleClosePopup(): void;
|
|
6
|
+
render(): import("lit").TemplateResult<1>;
|
|
7
|
+
}
|
|
8
|
+
export default LearnMorePopup;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LitElement } from 'lit'
|
|
2
|
+
declare class ProductAddConfirmation extends LitElement {
|
|
3
|
+
static styles: import('lit').CSSResult
|
|
4
|
+
open: boolean
|
|
5
|
+
product: null
|
|
6
|
+
imageUrl: null
|
|
7
|
+
priceOfVariant: null
|
|
8
|
+
quantity: number
|
|
9
|
+
handleDismiss(): void
|
|
10
|
+
handleConfirm(): void
|
|
11
|
+
render(): import('lit-html').TemplateResult<1>
|
|
12
|
+
}
|
|
13
|
+
export default ProductAddConfirmation
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
declare class ShipAidCartConfirmation extends LitElement {
|
|
3
|
-
static styles: import("lit").CSSResult;
|
|
4
|
-
open: boolean;
|
|
5
|
-
product: null;
|
|
6
|
-
imageUrl: null;
|
|
7
|
-
priceOfVariant: null;
|
|
8
|
-
quantity: number;
|
|
9
|
-
handleDismiss(): void;
|
|
10
|
-
handleDontShowAgain(ev: any): void;
|
|
11
|
-
handleConfirm(): void;
|
|
12
|
-
dontShowAgain: boolean;
|
|
13
|
-
render(): import("lit").TemplateResult<1>;
|
|
14
|
-
}
|
|
15
|
-
export default ShipAidCartConfirmation;
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare class ShipAidCartConfirmation extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult;
|
|
4
|
+
open: boolean;
|
|
5
|
+
product: null;
|
|
6
|
+
imageUrl: null;
|
|
7
|
+
priceOfVariant: null;
|
|
8
|
+
quantity: number;
|
|
9
|
+
handleDismiss(): void;
|
|
10
|
+
handleDontShowAgain(ev: any): void;
|
|
11
|
+
handleConfirm(): void;
|
|
12
|
+
dontShowAgain: boolean;
|
|
13
|
+
render(): import("lit").TemplateResult<1>;
|
|
14
|
+
}
|
|
15
|
+
export default ShipAidCartConfirmation;
|
|
@@ -1,150 +1,150 @@
|
|
|
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
|
-
shadowRootSelector: string;
|
|
35
|
-
useShipAidCheckout: boolean;
|
|
36
|
-
/** API Proxy pathname */
|
|
37
|
-
private _apiEndpoint;
|
|
38
|
-
/** The current store domain */
|
|
39
|
-
private _storeDomain;
|
|
40
|
-
/** The current store data object from the ShipAid API */
|
|
41
|
-
private _store;
|
|
42
|
-
/** The current cart data object from the Shopify API */
|
|
43
|
-
private _cart;
|
|
44
|
-
/** The current protection product data object from the Shopify API */
|
|
45
|
-
private _protectionProduct;
|
|
46
|
-
/** When the cart was last updated */
|
|
47
|
-
private _cartLastUpdated;
|
|
48
|
-
/** Whether we have finished the initial setup */
|
|
49
|
-
private _hasFinishedSetup;
|
|
50
|
-
/** Can be used to hide all widget content */
|
|
51
|
-
private _shouldShowWidget;
|
|
52
|
-
/** Can be used to check if page is on Cart */
|
|
53
|
-
/** Whether the ShipAid protection product is currently added to the cart */
|
|
54
|
-
private _hasProtectionInCart;
|
|
55
|
-
/** The protection item from the Shopify cart */
|
|
56
|
-
private _protectionCartItem;
|
|
57
|
-
/** The protection variant that will be used */
|
|
58
|
-
private _protectionVariant;
|
|
59
|
-
hasLoadedStrings: boolean;
|
|
60
|
-
fetchInterceptorCleanup: () => void;
|
|
61
|
-
intervalId: NodeJS.Timeout | null;
|
|
62
|
-
private _sellingPlanId?;
|
|
63
|
-
protected shouldUpdate(props: PropertyValues): boolean;
|
|
64
|
-
protected shouldPersistPopup(): "learn-more" | null;
|
|
65
|
-
protected setPopupKey(): void;
|
|
66
|
-
/**
|
|
67
|
-
* Internal state
|
|
68
|
-
*/
|
|
69
|
-
private _state;
|
|
70
|
-
/**
|
|
71
|
-
* Internal popup state
|
|
72
|
-
*/
|
|
73
|
-
private _popup;
|
|
74
|
-
get nhost(): {
|
|
75
|
-
request: (query: string, variables: Record<string, string>) => Promise<any>;
|
|
76
|
-
};
|
|
77
|
-
/** Runs a GraphQL query and returns the data
|
|
78
|
-
* @param query GraphQL query string
|
|
79
|
-
* @param variables Variables for the query
|
|
80
|
-
* @returns Query response data
|
|
81
|
-
*/
|
|
82
|
-
runStoreFrontQuery<Data>(query: string, variables: any): Promise<Data>;
|
|
83
|
-
/** Getter to check if we should refresh the page or not */
|
|
84
|
-
get shouldRefreshOnUpdate(): boolean;
|
|
85
|
-
/** Getter to check whether to show the widget or not */
|
|
86
|
-
get planActive(): boolean;
|
|
87
|
-
private _currencyFormat;
|
|
88
|
-
/** Emit events */
|
|
89
|
-
private _dispatchEvent;
|
|
90
|
-
private _handleRefreshCart;
|
|
91
|
-
/** Handle cart or page refreshes */
|
|
92
|
-
private _handleRefresh;
|
|
93
|
-
/** Given the current order, it calculates the protection total according to the store protection settings. */
|
|
94
|
-
calculateProtectionTotal(cart?: ShopifyCart): Promise<number>;
|
|
95
|
-
/**
|
|
96
|
-
* Given the current order, it finds the relevant protection product variant, and adds it to cart.
|
|
97
|
-
* This should be run whenever the cart updates, or it is manually triggered.
|
|
98
|
-
*/
|
|
99
|
-
private _findProtectionVariant;
|
|
100
|
-
/** Update State */
|
|
101
|
-
private _setState;
|
|
102
|
-
/** Trigger confirmation popup */
|
|
103
|
-
private _handleConfirmationPopup;
|
|
104
|
-
/** Updates the current protection status, calling the relevant add/remove function. */
|
|
105
|
-
private _updateProtection;
|
|
106
|
-
/** General fetch function, which handles error responses, and returns JSON responses. */
|
|
107
|
-
private _fetch;
|
|
108
|
-
/** Fetches store info from the ShipAid public API. */
|
|
109
|
-
private _fetchShipAidData;
|
|
110
|
-
private _findSellingPlanByName;
|
|
111
|
-
/** Fetches store info from the ShipAid public API. */
|
|
112
|
-
private _fetchSellingPlanFromVariant;
|
|
113
|
-
/** Fetch current cart from the Shopify ajax API */
|
|
114
|
-
private _fetchCart;
|
|
115
|
-
/** Fetch current product from the Shopify ajax API */
|
|
116
|
-
private _fetchProduct;
|
|
117
|
-
/** Whether the cart currently contains Shipping protection from ShipAid. */
|
|
118
|
-
hasProtection(): boolean;
|
|
119
|
-
/** Update the internal cart, which will trigger any protection fee updates */
|
|
120
|
-
updateCart(cart?: ShopifyCart): Promise<void>;
|
|
121
|
-
addCartProtectionVariant(): Promise<any>;
|
|
122
|
-
updateCartProtectionVariant(qty: number, protectionCartItem?: ShopifyCartItem | null): Promise<any>;
|
|
123
|
-
/** Add ShipAid shipping protection. */
|
|
124
|
-
addProtection(): Promise<void>;
|
|
125
|
-
/** Remove ShipAid shipping protection. */
|
|
126
|
-
removeProtection(): Promise<void>;
|
|
127
|
-
/** Try adding ShipAid shipping protection during polling if applicable */
|
|
128
|
-
attemptAddProtection(): Promise<void>;
|
|
129
|
-
handleMultipleProtectionVariants(): Promise<void>;
|
|
130
|
-
/** Templates */
|
|
131
|
-
learnMorePopupTemplate(): import("lit").TemplateResult<1>;
|
|
132
|
-
confirmationPopupTemplate(): import("lit").TemplateResult<1>;
|
|
133
|
-
getElementsBySelector: (selector: string | null) => never[] | NodeListOf<Element>;
|
|
134
|
-
addStylesIfNeeded: () => void;
|
|
135
|
-
contactlessCheckoutButtonTemplate(): typeof nothing | undefined;
|
|
136
|
-
createRenderRoot(): Element | ShadowRoot;
|
|
137
|
-
getSubscription(_cart: ShopifyCart | undefined): Promise<string | null | undefined>;
|
|
138
|
-
checkoutButtonTemplate(): import("lit").TemplateResult<1> | undefined;
|
|
139
|
-
renderPopups(): import("lit").TemplateResult<1> | null;
|
|
140
|
-
promptTemplate(): import("lit").TemplateResult<1> | undefined;
|
|
141
|
-
connectedCallback(): Promise<void>;
|
|
142
|
-
disconnectedCallback(): void;
|
|
143
|
-
updateProtection(): Promise<void>;
|
|
144
|
-
protected render(): import("lit").TemplateResult<1>;
|
|
145
|
-
}
|
|
146
|
-
declare global {
|
|
147
|
-
interface HTMLElementTagNameMap {
|
|
148
|
-
'shipaid-widget': ShipAidWidget;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
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
|
+
shadowRootSelector: string;
|
|
35
|
+
useShipAidCheckout: boolean;
|
|
36
|
+
/** API Proxy pathname */
|
|
37
|
+
private _apiEndpoint;
|
|
38
|
+
/** The current store domain */
|
|
39
|
+
private _storeDomain;
|
|
40
|
+
/** The current store data object from the ShipAid API */
|
|
41
|
+
private _store;
|
|
42
|
+
/** The current cart data object from the Shopify API */
|
|
43
|
+
private _cart;
|
|
44
|
+
/** The current protection product data object from the Shopify API */
|
|
45
|
+
private _protectionProduct;
|
|
46
|
+
/** When the cart was last updated */
|
|
47
|
+
private _cartLastUpdated;
|
|
48
|
+
/** Whether we have finished the initial setup */
|
|
49
|
+
private _hasFinishedSetup;
|
|
50
|
+
/** Can be used to hide all widget content */
|
|
51
|
+
private _shouldShowWidget;
|
|
52
|
+
/** Can be used to check if page is on Cart */
|
|
53
|
+
/** Whether the ShipAid protection product is currently added to the cart */
|
|
54
|
+
private _hasProtectionInCart;
|
|
55
|
+
/** The protection item from the Shopify cart */
|
|
56
|
+
private _protectionCartItem;
|
|
57
|
+
/** The protection variant that will be used */
|
|
58
|
+
private _protectionVariant;
|
|
59
|
+
hasLoadedStrings: boolean;
|
|
60
|
+
fetchInterceptorCleanup: () => void;
|
|
61
|
+
intervalId: NodeJS.Timeout | null;
|
|
62
|
+
private _sellingPlanId?;
|
|
63
|
+
protected shouldUpdate(props: PropertyValues): boolean;
|
|
64
|
+
protected shouldPersistPopup(): "learn-more" | null;
|
|
65
|
+
protected setPopupKey(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Internal state
|
|
68
|
+
*/
|
|
69
|
+
private _state;
|
|
70
|
+
/**
|
|
71
|
+
* Internal popup state
|
|
72
|
+
*/
|
|
73
|
+
private _popup;
|
|
74
|
+
get nhost(): {
|
|
75
|
+
request: (query: string, variables: Record<string, string>) => Promise<any>;
|
|
76
|
+
};
|
|
77
|
+
/** Runs a GraphQL query and returns the data
|
|
78
|
+
* @param query GraphQL query string
|
|
79
|
+
* @param variables Variables for the query
|
|
80
|
+
* @returns Query response data
|
|
81
|
+
*/
|
|
82
|
+
runStoreFrontQuery<Data>(query: string, variables: any): Promise<Data>;
|
|
83
|
+
/** Getter to check if we should refresh the page or not */
|
|
84
|
+
get shouldRefreshOnUpdate(): boolean;
|
|
85
|
+
/** Getter to check whether to show the widget or not */
|
|
86
|
+
get planActive(): boolean;
|
|
87
|
+
private _currencyFormat;
|
|
88
|
+
/** Emit events */
|
|
89
|
+
private _dispatchEvent;
|
|
90
|
+
private _handleRefreshCart;
|
|
91
|
+
/** Handle cart or page refreshes */
|
|
92
|
+
private _handleRefresh;
|
|
93
|
+
/** Given the current order, it calculates the protection total according to the store protection settings. */
|
|
94
|
+
calculateProtectionTotal(cart?: ShopifyCart): Promise<number>;
|
|
95
|
+
/**
|
|
96
|
+
* Given the current order, it finds the relevant protection product variant, and adds it to cart.
|
|
97
|
+
* This should be run whenever the cart updates, or it is manually triggered.
|
|
98
|
+
*/
|
|
99
|
+
private _findProtectionVariant;
|
|
100
|
+
/** Update State */
|
|
101
|
+
private _setState;
|
|
102
|
+
/** Trigger confirmation popup */
|
|
103
|
+
private _handleConfirmationPopup;
|
|
104
|
+
/** Updates the current protection status, calling the relevant add/remove function. */
|
|
105
|
+
private _updateProtection;
|
|
106
|
+
/** General fetch function, which handles error responses, and returns JSON responses. */
|
|
107
|
+
private _fetch;
|
|
108
|
+
/** Fetches store info from the ShipAid public API. */
|
|
109
|
+
private _fetchShipAidData;
|
|
110
|
+
private _findSellingPlanByName;
|
|
111
|
+
/** Fetches store info from the ShipAid public API. */
|
|
112
|
+
private _fetchSellingPlanFromVariant;
|
|
113
|
+
/** Fetch current cart from the Shopify ajax API */
|
|
114
|
+
private _fetchCart;
|
|
115
|
+
/** Fetch current product from the Shopify ajax API */
|
|
116
|
+
private _fetchProduct;
|
|
117
|
+
/** Whether the cart currently contains Shipping protection from ShipAid. */
|
|
118
|
+
hasProtection(): boolean;
|
|
119
|
+
/** Update the internal cart, which will trigger any protection fee updates */
|
|
120
|
+
updateCart(cart?: ShopifyCart): Promise<void>;
|
|
121
|
+
addCartProtectionVariant(): Promise<any>;
|
|
122
|
+
updateCartProtectionVariant(qty: number, protectionCartItem?: ShopifyCartItem | null): Promise<any>;
|
|
123
|
+
/** Add ShipAid shipping protection. */
|
|
124
|
+
addProtection(): Promise<void>;
|
|
125
|
+
/** Remove ShipAid shipping protection. */
|
|
126
|
+
removeProtection(): Promise<void>;
|
|
127
|
+
/** Try adding ShipAid shipping protection during polling if applicable */
|
|
128
|
+
attemptAddProtection(): Promise<void>;
|
|
129
|
+
handleMultipleProtectionVariants(): Promise<void>;
|
|
130
|
+
/** Templates */
|
|
131
|
+
learnMorePopupTemplate(): import("lit").TemplateResult<1>;
|
|
132
|
+
confirmationPopupTemplate(): import("lit").TemplateResult<1>;
|
|
133
|
+
getElementsBySelector: (selector: string | null) => never[] | NodeListOf<Element>;
|
|
134
|
+
addStylesIfNeeded: () => void;
|
|
135
|
+
contactlessCheckoutButtonTemplate(): typeof nothing | undefined;
|
|
136
|
+
createRenderRoot(): Element | ShadowRoot;
|
|
137
|
+
getSubscription(_cart: ShopifyCart | undefined): Promise<string | null | undefined>;
|
|
138
|
+
checkoutButtonTemplate(): import("lit").TemplateResult<1> | undefined;
|
|
139
|
+
renderPopups(): import("lit").TemplateResult<1> | null;
|
|
140
|
+
promptTemplate(): import("lit").TemplateResult<1> | undefined;
|
|
141
|
+
connectedCallback(): Promise<void>;
|
|
142
|
+
disconnectedCallback(): void;
|
|
143
|
+
updateProtection(): Promise<void>;
|
|
144
|
+
protected render(): import("lit").TemplateResult<1>;
|
|
145
|
+
}
|
|
146
|
+
declare global {
|
|
147
|
+
interface HTMLElementTagNameMap {
|
|
148
|
+
'shipaid-widget': ShipAidWidget;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -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 };
|