ui.shipaid.com 0.2.7 → 0.2.10

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.
@@ -0,0 +1,3 @@
1
+ export declare const CheckmarkIcon: import("lit").TemplateResult<1>;
2
+ export declare const ShipAidLogo: import("lit").TemplateResult<1>;
3
+ export declare const ShipAidLogoText: import("lit").TemplateResult<1>;
@@ -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,85 +1,85 @@
1
- import { LitElement } from 'lit';
2
- import type { ShopifyCart } from '../types/shopify';
3
- /**
4
- * ShipAid Widget.
5
- *
6
- * @description When the <shipaid-widget> element is added to page, it will render this element,
7
- * allowing a customer to add ShipAid protection to cart (and remove).
8
- *
9
- */
10
- export declare class ShipAidWidget extends LitElement {
11
- static styles: import("lit").CSSResult;
12
- disablePolling: boolean;
13
- pollingInterval: number;
14
- disableRefresh: boolean;
15
- /** API Proxy pathname */
16
- private _apiEndpoint;
17
- /** The current store domain */
18
- private _storeDomain;
19
- /** The current store data object from the ShipAid API */
20
- private _store;
21
- /** The current cart data object from the Shopify API */
22
- private _cart;
23
- /** When the cart was last updated */
24
- private _cartLastUpdated;
25
- /** Whether we have finished the initial setup */
26
- private _hasFinishedSetup;
27
- /** Can be used to hide all widget content */
28
- private _shouldShowWidget;
29
- /** Whether the ShipAid protection product is currently added to the cart */
30
- private _hasProtectionInCart;
31
- /** The last action a user took */
32
- private _lastAction;
33
- /** The protection item from the Shopify cart */
34
- private _protectionCartItem;
35
- /** The protection variant that will be used */
36
- private _protectionVariant;
37
- /**
38
- * Internal state
39
- */
40
- private _state;
41
- /**
42
- * Internal popup state
43
- */
44
- private _popup;
45
- /** Getter to check if we should refresh the page or not */
46
- get shouldRefreshOnUpdate(): boolean;
47
- /** Getter to check whether to show the widget or not */
48
- get planActive(): boolean;
49
- private _currencyFormat;
50
- /** Emit events */
51
- private _dispatchEvent;
52
- /** Handle cart or page refreshes */
53
- private _handleRefresh;
54
- /** Given the current order, it calculates the protection total according to the store protection settings. */
55
- calculateProtectionTotal(cart?: ShopifyCart): Promise<number>;
56
- /**
57
- * Given the current order, it finds the relevant protection product variant, and adds it to cart.
58
- * This should be run whenever the cart updates, or it is manually triggered.
59
- */
60
- private _findProtectionVariant;
61
- /** Update State */
62
- private _setState;
63
- /** Updates the current protection status, calling the relevant add/remove function. */
64
- private _updateProtection;
65
- /** General fetch function, which handles error responses, and returns JSON responses. */
66
- private _fetch;
67
- /** Fetches store info from the ShipAid public API. */
68
- private _fetchShipAidData;
69
- /** Fetch current cart from the Shopify ajax API */
70
- private _fetchCart;
71
- /** Whether the cart currently contains Shipping protection from ShipAid. */
72
- hasProtection(): boolean;
73
- /** Update the internal cart, which will trigger any protection fee updates */
74
- updateCart(cart?: ShopifyCart): Promise<void>;
75
- /** Add ShipAid shipping protection. */
76
- addProtection(): Promise<void>;
77
- /** Remove ShipAid shipping protection. */
78
- removeProtection(): Promise<void>;
79
- render(): import("lit").TemplateResult<1>;
80
- }
81
- declare global {
82
- interface HTMLElementTagNameMap {
83
- 'shipaid-widget': ShipAidWidget;
84
- }
85
- }
1
+ import { LitElement } from 'lit';
2
+ import type { ShopifyCart } from '../types/shopify';
3
+ /**
4
+ * ShipAid Widget.
5
+ *
6
+ * @description When the <shipaid-widget> element is added to page, it will render this element,
7
+ * allowing a customer to add ShipAid protection to cart (and remove).
8
+ *
9
+ */
10
+ export declare class ShipAidWidget extends LitElement {
11
+ static styles: import("lit").CSSResult;
12
+ disablePolling: boolean;
13
+ pollingInterval: number;
14
+ disableRefresh: boolean;
15
+ /** API Proxy pathname */
16
+ private _apiEndpoint;
17
+ /** The current store domain */
18
+ private _storeDomain;
19
+ /** The current store data object from the ShipAid API */
20
+ private _store;
21
+ /** The current cart data object from the Shopify API */
22
+ private _cart;
23
+ /** When the cart was last updated */
24
+ private _cartLastUpdated;
25
+ /** Whether we have finished the initial setup */
26
+ private _hasFinishedSetup;
27
+ /** Can be used to hide all widget content */
28
+ private _shouldShowWidget;
29
+ /** Whether the ShipAid protection product is currently added to the cart */
30
+ private _hasProtectionInCart;
31
+ /** The last action a user took */
32
+ private _lastAction;
33
+ /** The protection item from the Shopify cart */
34
+ private _protectionCartItem;
35
+ /** The protection variant that will be used */
36
+ private _protectionVariant;
37
+ /**
38
+ * Internal state
39
+ */
40
+ private _state;
41
+ /**
42
+ * Internal popup state
43
+ */
44
+ private _popup;
45
+ /** Getter to check if we should refresh the page or not */
46
+ get shouldRefreshOnUpdate(): boolean;
47
+ /** Getter to check whether to show the widget or not */
48
+ get planActive(): boolean;
49
+ private _currencyFormat;
50
+ /** Emit events */
51
+ private _dispatchEvent;
52
+ /** Handle cart or page refreshes */
53
+ private _handleRefresh;
54
+ /** Given the current order, it calculates the protection total according to the store protection settings. */
55
+ calculateProtectionTotal(cart?: ShopifyCart): Promise<number>;
56
+ /**
57
+ * Given the current order, it finds the relevant protection product variant, and adds it to cart.
58
+ * This should be run whenever the cart updates, or it is manually triggered.
59
+ */
60
+ private _findProtectionVariant;
61
+ /** Update State */
62
+ private _setState;
63
+ /** Updates the current protection status, calling the relevant add/remove function. */
64
+ private _updateProtection;
65
+ /** General fetch function, which handles error responses, and returns JSON responses. */
66
+ private _fetch;
67
+ /** Fetches store info from the ShipAid public API. */
68
+ private _fetchShipAidData;
69
+ /** Fetch current cart from the Shopify ajax API */
70
+ private _fetchCart;
71
+ /** Whether the cart currently contains Shipping protection from ShipAid. */
72
+ hasProtection(): boolean;
73
+ /** Update the internal cart, which will trigger any protection fee updates */
74
+ updateCart(cart?: ShopifyCart): Promise<void>;
75
+ /** Add ShipAid shipping protection. */
76
+ addProtection(): Promise<void>;
77
+ /** Remove ShipAid shipping protection. */
78
+ removeProtection(): Promise<void>;
79
+ render(): import("lit").TemplateResult<1>;
80
+ }
81
+ declare global {
82
+ interface HTMLElementTagNameMap {
83
+ 'shipaid-widget': ShipAidWidget;
84
+ }
85
+ }
@@ -1,57 +1,57 @@
1
- export interface ProtectionSettingsProductVariant {
2
- id?: string;
3
- sku?: string;
4
- price?: string;
5
- title?: string;
6
- selectedOptions?: {
7
- name?: string;
8
- value?: string;
9
- }[];
10
- }
11
- export interface ProtectionSettingsProduct {
12
- id?: string;
13
- title?: string;
14
- options?: {
15
- name: string;
16
- value: string;
17
- }[];
18
- variants?: {
19
- edges?: {
20
- node?: ProtectionSettingsProductVariant;
21
- }[];
22
- };
23
- }
24
- export interface ProtectionSettings {
25
- product?: ProtectionSettingsProduct;
26
- }
27
- export interface ProtectionSettingsPercentage extends ProtectionSettings {
28
- protectionType: 'PERCENTAGE';
29
- percentage: number;
30
- minimumFee: number;
31
- }
32
- export interface ProtectionSettingsFixed extends ProtectionSettings {
33
- protectionType: 'FIXED';
34
- defaultFee?: number;
35
- rules?: {
36
- fee?: number;
37
- rangeLower?: number;
38
- rangeUpper?: number;
39
- }[];
40
- }
41
- export interface ShipAidStore {
42
- store: string;
43
- currency: string;
44
- widgetAutoOptIn?: boolean;
45
- widgetShowCart?: boolean;
46
- excludedProductSkus?: string[];
47
- planActive: boolean;
48
- protectionSettings: ProtectionSettingsFixed | ProtectionSettingsPercentage;
49
- }
50
- export interface ShipAidStoreQuery {
51
- data: null | {
52
- store: ShipAidStore;
53
- };
54
- errors?: {
55
- message: string;
56
- }[];
57
- }
1
+ export interface ProtectionSettingsProductVariant {
2
+ id?: string;
3
+ sku?: string;
4
+ price?: string;
5
+ title?: string;
6
+ selectedOptions?: {
7
+ name?: string;
8
+ value?: string;
9
+ }[];
10
+ }
11
+ export interface ProtectionSettingsProduct {
12
+ id?: string;
13
+ title?: string;
14
+ options?: {
15
+ name: string;
16
+ value: string;
17
+ }[];
18
+ variants?: {
19
+ edges?: {
20
+ node?: ProtectionSettingsProductVariant;
21
+ }[];
22
+ };
23
+ }
24
+ export interface ProtectionSettings {
25
+ product?: ProtectionSettingsProduct;
26
+ }
27
+ export interface ProtectionSettingsPercentage extends ProtectionSettings {
28
+ protectionType: 'PERCENTAGE';
29
+ percentage: number;
30
+ minimumFee: number;
31
+ }
32
+ export interface ProtectionSettingsFixed extends ProtectionSettings {
33
+ protectionType: 'FIXED';
34
+ defaultFee?: number;
35
+ rules?: {
36
+ fee?: number;
37
+ rangeLower?: number;
38
+ rangeUpper?: number;
39
+ }[];
40
+ }
41
+ export interface ShipAidStore {
42
+ store: string;
43
+ currency: string;
44
+ widgetAutoOptIn?: boolean;
45
+ widgetShowCart?: boolean;
46
+ excludedProductSkus?: string[];
47
+ planActive: boolean;
48
+ protectionSettings: ProtectionSettingsFixed | ProtectionSettingsPercentage;
49
+ }
50
+ export interface ShipAidStoreQuery {
51
+ data: null | {
52
+ store: ShipAidStore;
53
+ };
54
+ errors?: {
55
+ message: string;
56
+ }[];
57
+ }
@@ -1,84 +1,84 @@
1
- declare global {
2
- interface Window {
3
- Shopify?: {
4
- shop?: string;
5
- locale?: string;
6
- designMode?: boolean;
7
- currency?: {
8
- active?: string;
9
- };
10
- Checkout?: Record<string, string>;
11
- };
12
- }
13
- }
14
- export interface ShopifyCart {
15
- token: string;
16
- note?: null;
17
- original_total_price: number;
18
- total_price: number;
19
- total_discount: number;
20
- total_weight: number;
21
- item_count: number;
22
- items?: ShopifyCartItem[];
23
- requires_shipping: boolean;
24
- currency: string;
25
- items_subtotal_price: number;
26
- cart_level_discount_applications?: (null)[] | null;
27
- sections?: Record<string, string>;
28
- }
29
- export interface ShopifyCartItem {
30
- id: number;
31
- index: number;
32
- position: number;
33
- properties?: null;
34
- quantity: number;
35
- variant_id: number;
36
- key: string;
37
- title: string;
38
- price: number;
39
- original_price: number;
40
- discounted_price: number;
41
- line_price: number;
42
- original_line_price: number;
43
- total_discount: number;
44
- discounts?: (null)[] | null;
45
- sku: string;
46
- grams: number;
47
- vendor: string;
48
- taxable: boolean;
49
- product_id: number;
50
- product_has_only_default_variant: boolean;
51
- gift_card: boolean;
52
- final_price: number;
53
- final_line_price: number;
54
- url: string;
55
- featured_image: FeaturedImage;
56
- image: string;
57
- handle: string;
58
- requires_shipping: boolean;
59
- product_type: string;
60
- product_title: string;
61
- product_description: string;
62
- variant_title?: null;
63
- variant_options?: (string)[] | null;
64
- options_with_values?: (OptionsWithValuesEntity)[] | null;
65
- line_level_discount_allocations?: (null)[] | null;
66
- line_level_total_discount: number;
67
- sections?: Record<string, string>;
68
- }
69
- export interface FeaturedImage {
70
- aspect_ratio: number;
71
- alt: string;
72
- height: number;
73
- url: string;
74
- width: number;
75
- }
76
- export interface OptionsWithValuesEntity {
77
- name: string;
78
- value: string;
79
- }
80
- export interface ShopifyCartAddPayload {
81
- id: number | string;
82
- quantity?: number;
83
- sections?: string;
84
- }
1
+ declare global {
2
+ interface Window {
3
+ Shopify?: {
4
+ shop?: string;
5
+ locale?: string;
6
+ designMode?: boolean;
7
+ currency?: {
8
+ active?: string;
9
+ };
10
+ Checkout?: Record<string, string>;
11
+ };
12
+ }
13
+ }
14
+ export interface ShopifyCart {
15
+ token: string;
16
+ note?: null;
17
+ original_total_price: number;
18
+ total_price: number;
19
+ total_discount: number;
20
+ total_weight: number;
21
+ item_count: number;
22
+ items?: ShopifyCartItem[];
23
+ requires_shipping: boolean;
24
+ currency: string;
25
+ items_subtotal_price: number;
26
+ cart_level_discount_applications?: (null)[] | null;
27
+ sections?: Record<string, string>;
28
+ }
29
+ export interface ShopifyCartItem {
30
+ id: number;
31
+ index: number;
32
+ position: number;
33
+ properties?: null;
34
+ quantity: number;
35
+ variant_id: number;
36
+ key: string;
37
+ title: string;
38
+ price: number;
39
+ original_price: number;
40
+ discounted_price: number;
41
+ line_price: number;
42
+ original_line_price: number;
43
+ total_discount: number;
44
+ discounts?: (null)[] | null;
45
+ sku: string;
46
+ grams: number;
47
+ vendor: string;
48
+ taxable: boolean;
49
+ product_id: number;
50
+ product_has_only_default_variant: boolean;
51
+ gift_card: boolean;
52
+ final_price: number;
53
+ final_line_price: number;
54
+ url: string;
55
+ featured_image: FeaturedImage;
56
+ image: string;
57
+ handle: string;
58
+ requires_shipping: boolean;
59
+ product_type: string;
60
+ product_title: string;
61
+ product_description: string;
62
+ variant_title?: null;
63
+ variant_options?: (string)[] | null;
64
+ options_with_values?: (OptionsWithValuesEntity)[] | null;
65
+ line_level_discount_allocations?: (null)[] | null;
66
+ line_level_total_discount: number;
67
+ sections?: Record<string, string>;
68
+ }
69
+ export interface FeaturedImage {
70
+ aspect_ratio: number;
71
+ alt: string;
72
+ height: number;
73
+ url: string;
74
+ width: number;
75
+ }
76
+ export interface OptionsWithValuesEntity {
77
+ name: string;
78
+ value: string;
79
+ }
80
+ export interface ShopifyCartAddPayload {
81
+ id: number | string;
82
+ quantity?: number;
83
+ sections?: string;
84
+ }
@@ -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,41 +1,42 @@
1
- {
2
- "name": "ui.shipaid.com",
3
- "private": false,
4
- "version": "0.2.7",
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
- },
22
- "dependencies": {
23
- "@lit-labs/task": "^1.1.3",
24
- "lit": "^2.3.1",
25
- "lit-element-effect": "^1.0.2"
26
- },
27
- "devDependencies": {
28
- "@typescript-eslint/eslint-plugin": "^5.35.1",
29
- "@typescript-eslint/parser": "^5.35.1",
30
- "eslint": "^8.23.0",
31
- "eslint-config-standard": "^17.0.0",
32
- "eslint-plugin-html": "^7.1.0",
33
- "eslint-plugin-import": "^2.26.0",
34
- "eslint-plugin-lit": "^1.6.1",
35
- "eslint-plugin-lit-a11y": "^2.2.2",
36
- "eslint-plugin-n": "^15.2.5",
37
- "eslint-plugin-promise": "^6.0.1",
38
- "typescript": "^4.8.2",
39
- "vite": "^2.9.15"
40
- }
41
- }
1
+ {
2
+ "name": "ui.shipaid.com",
3
+ "private": false,
4
+ "version": "0.2.10",
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
+ },
22
+ "dependencies": {
23
+ "@lit-labs/task": "^1.1.3",
24
+ "lit": "^2.3.1",
25
+ "lit-element-effect": "^1.0.2"
26
+ },
27
+ "devDependencies": {
28
+ "@typescript-eslint/eslint-plugin": "^5.38.1",
29
+ "@typescript-eslint/parser": "^5.38.1",
30
+ "eslint": "^8.24.0",
31
+ "eslint-config-standard": "^17.0.0",
32
+ "eslint-plugin-html": "^7.1.0",
33
+ "eslint-plugin-import": "^2.26.0",
34
+ "eslint-plugin-lit": "^1.6.1",
35
+ "eslint-plugin-lit-a11y": "^2.2.2",
36
+ "eslint-plugin-n": "^15.3.0",
37
+ "eslint-plugin-promise": "^6.0.1",
38
+ "terser": "^5.15.0",
39
+ "typescript": "^4.8.4",
40
+ "vite": "^3.1.4"
41
+ }
42
+ }