@liquidcommerce/elements-sdk 2.7.12 → 2.7.14
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/dist/index.checkout.esm.js +7030 -6903
- package/dist/index.esm.js +11168 -11015
- package/dist/types/core/client/actions/base-action.service.d.ts +7 -0
- package/dist/types/core/client/actions/client-cart-action.service.d.ts +1 -0
- package/dist/types/interfaces/injection.interface.d.ts +1 -0
- package/dist/types/modules/checkout/components/checkout-item-quantity.component.d.ts +3 -0
- package/dist/types/modules/product/product.commands.d.ts +1 -0
- package/dist/types/modules/product-list/components/card-components/product-button.d.ts +6 -4
- package/dist/types/modules/product-list/components/card-components/product-quantity-selector.d.ts +2 -1
- package/dist/types/modules/product-list/components/product-list-card.component.d.ts +2 -0
- package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +2 -1
- package/dist/types/modules/product-list/components/product-list-search.component.d.ts +2 -0
- package/dist/types/modules/product-list/product-list.component.d.ts +2 -1
- package/docs/v1/api/actions/cart-actions.md +21 -0
- package/docs/v1/api/actions/checkout-actions.md +12 -0
- package/package.json +5 -5
|
@@ -3,6 +3,7 @@ import { LoggerFactory } from '@/core/logger/logger-factory';
|
|
|
3
3
|
import { PubSubService } from '@/core/pubsub/pubsub.service';
|
|
4
4
|
import { StoreService } from '@/core/store/store.service';
|
|
5
5
|
import type { ILocation } from '@/interfaces/api/address.interface';
|
|
6
|
+
import type { IProductSizeEngraving, IProductVariant } from '@/interfaces/api/product.interface';
|
|
6
7
|
import { ThemeProviderService } from '@/modules/theme-provider/theme-provider.service';
|
|
7
8
|
export declare abstract class BaseActionService {
|
|
8
9
|
protected readonly pubSub: PubSubService;
|
|
@@ -12,4 +13,10 @@ export declare abstract class BaseActionService {
|
|
|
12
13
|
protected readonly logger: ReturnType<typeof LoggerFactory.get>;
|
|
13
14
|
constructor(loggerName: string);
|
|
14
15
|
protected getLocation(): ILocation | undefined;
|
|
16
|
+
protected sanitizeEngravingInput(rawLines: string[] | undefined, identifier: string): string[] | undefined;
|
|
17
|
+
protected clampEngravingToSizeLimits(requestedLines: string[], sizeEngraving: IProductSizeEngraving | undefined, identifier: string): string[] | undefined;
|
|
18
|
+
protected findVariantForFulfillment(variants: (IProductVariant | undefined)[], wantsEngraving: boolean): {
|
|
19
|
+
variant: IProductVariant | null;
|
|
20
|
+
engravingDropped: boolean;
|
|
21
|
+
};
|
|
15
22
|
}
|
|
@@ -9,6 +9,9 @@ export declare class CheckoutItemQuantityComponent extends BaseComponent<IChecko
|
|
|
9
9
|
get hostClasses(): string[];
|
|
10
10
|
constructor();
|
|
11
11
|
onStoreWatch(changes: IOnStoreChanged[]): void;
|
|
12
|
+
private getCheckoutItemStore;
|
|
13
|
+
private getCartItemStore;
|
|
14
|
+
private getProductStoreByLiquidId;
|
|
12
15
|
private getAvailableQuantity;
|
|
13
16
|
private calculateQuantityLimits;
|
|
14
17
|
private updateButtonStates;
|
|
@@ -13,6 +13,7 @@ export declare class ProductCommands extends BaseCommand {
|
|
|
13
13
|
createProductInstance(productId: string, firstTime?: boolean): Promise<void>;
|
|
14
14
|
loadMultipleProducts(productIds: string[]): Promise<void>;
|
|
15
15
|
loadProduct(productId: string, customProductData?: IProductAvailabilityResponse | null): Promise<void>;
|
|
16
|
+
cacheProductFromApiData(identifier: string, apiData: IProductAvailabilityResponse): void;
|
|
16
17
|
selectSize(productId: string, sizeId: string): Promise<void>;
|
|
17
18
|
selectFulfillment(productId: string, selectedFulfillmentId: string): Promise<void>;
|
|
18
19
|
updateQuantity(productId: string, delta: number): Promise<void>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface IAddToCartButtonState {
|
|
2
2
|
isPresale: boolean;
|
|
3
3
|
hasAvailability: boolean;
|
|
4
|
-
state: string;
|
|
5
|
-
disabled?: boolean;
|
|
6
4
|
hasAddress: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface IAddToCartButtonParams extends IAddToCartButtonState {
|
|
7
8
|
onClick?: (e: MouseEvent) => void | Promise<void>;
|
|
8
9
|
}
|
|
9
|
-
export declare const
|
|
10
|
+
export declare const applyAddToCartButtonState: (button: HTMLButtonElement, state: IAddToCartButtonState) => void;
|
|
11
|
+
export declare const createAddToCartButton: ({ isPresale, hasAvailability, disabled, hasAddress, onClick, }: IAddToCartButtonParams) => HTMLButtonElement;
|
package/dist/types/modules/product-list/components/card-components/product-quantity-selector.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface IQuantitySelectorParams {
|
|
|
4
4
|
minQuantity: number;
|
|
5
5
|
maxQuantity: number;
|
|
6
6
|
cardStyle: PLCCardStyle;
|
|
7
|
+
disabled?: boolean;
|
|
7
8
|
onChange: (quantity: number) => void;
|
|
8
9
|
}
|
|
9
|
-
export declare const createQuantitySelector: ({ initialQuantity, minQuantity, maxQuantity, cardStyle, onChange }: IQuantitySelectorParams) => HTMLElement;
|
|
10
|
+
export declare const createQuantitySelector: ({ initialQuantity, minQuantity, maxQuantity, cardStyle, disabled, onChange, }: IQuantitySelectorParams) => HTMLElement;
|
|
@@ -16,9 +16,11 @@ export declare class ProductListCardComponent extends BaseComponent<IProductList
|
|
|
16
16
|
constructor();
|
|
17
17
|
private getListConfig;
|
|
18
18
|
get hostClasses(): string[];
|
|
19
|
+
protected beforeConnected(): void;
|
|
19
20
|
protected disconnected?(): void;
|
|
20
21
|
onStoreWatch(changes: IOnStoreChanged[]): void;
|
|
21
22
|
private getSelectedSize;
|
|
23
|
+
private getDisplayPrice;
|
|
22
24
|
protected template(): HTMLElement[];
|
|
23
25
|
private updatePriceDisplay;
|
|
24
26
|
private updateFulfillmentText;
|
package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare class ProductListProductPreCartComponent extends BaseComponent<IP
|
|
|
17
17
|
private previousSelectedFulfillmentId;
|
|
18
18
|
constructor();
|
|
19
19
|
private getListConfig;
|
|
20
|
-
protected
|
|
20
|
+
protected connected?(): void;
|
|
21
21
|
private handleRetailersBack;
|
|
22
22
|
private handleEngravingBack;
|
|
23
23
|
private handleEngravingEdit;
|
|
@@ -30,6 +30,7 @@ export declare class ProductListProductPreCartComponent extends BaseComponent<IP
|
|
|
30
30
|
private updatePersonalizeVisibility;
|
|
31
31
|
private updateAddToCartButton;
|
|
32
32
|
private getEngravingFee;
|
|
33
|
+
protected beforeConnected(): void;
|
|
33
34
|
protected template(): HTMLElement[];
|
|
34
35
|
private createAnimatedContentElement;
|
|
35
36
|
private buildLayout;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BaseComponent } from '@/core/base-component.service';
|
|
2
|
+
import type { ProductListFilterType } from '@/interfaces/injection.interface';
|
|
2
3
|
export interface IProductListSearchParams {
|
|
3
4
|
slug: string;
|
|
5
|
+
filters?: ProductListFilterType[];
|
|
4
6
|
}
|
|
5
7
|
export declare class ProductListSearchComponent extends BaseComponent<IProductListSearchParams> {
|
|
6
8
|
private searchInput?;
|
|
@@ -19,7 +19,8 @@ export declare class ProductListComponent extends BaseComponent<IProductListComp
|
|
|
19
19
|
private unsubscribeFromState?;
|
|
20
20
|
get hostClasses(): string[];
|
|
21
21
|
constructor();
|
|
22
|
-
protected
|
|
22
|
+
protected beforeConnected(): void;
|
|
23
|
+
protected afterRender(): void;
|
|
23
24
|
disconnected(): void;
|
|
24
25
|
private initializeComponent;
|
|
25
26
|
private toProductArray;
|
|
@@ -81,9 +81,20 @@ interface IAddProductParams {
|
|
|
81
81
|
identifier: string; // Product UPC, SKU, or ID
|
|
82
82
|
fulfillmentType: FulfillmentType; // 'shipping' or 'onDemand'
|
|
83
83
|
quantity: number; // Number of items
|
|
84
|
+
engravingLines?: string[]; // Optional engraving (see below)
|
|
84
85
|
}
|
|
85
86
|
```
|
|
86
87
|
|
|
88
|
+
#### `engravingLines` (optional)
|
|
89
|
+
|
|
90
|
+
Pre-fills an engraving for the added item. The SDK enforces the product's engraving rules and degrades silently rather than failing the call:
|
|
91
|
+
|
|
92
|
+
- Non-string-array input is ignored (warning logged).
|
|
93
|
+
- Blank/whitespace-only entries are stripped; an empty result is treated as no engraving.
|
|
94
|
+
- If the product/size doesn't support engraving, lines are dropped.
|
|
95
|
+
- Lines beyond `maxLines` are sliced off; any line longer than `maxCharsPerLine` is truncated.
|
|
96
|
+
- If no engravable variant is available for the chosen fulfillment, lines are dropped and the item is still added.
|
|
97
|
+
|
|
87
98
|
### Example
|
|
88
99
|
|
|
89
100
|
```javascript
|
|
@@ -109,6 +120,16 @@ await window.LiquidCommerce.elements.actions.cart.addProduct([
|
|
|
109
120
|
quantity: 1
|
|
110
121
|
}
|
|
111
122
|
]);
|
|
123
|
+
|
|
124
|
+
// Add a product with engraving
|
|
125
|
+
await window.LiquidCommerce.elements.actions.cart.addProduct([
|
|
126
|
+
{
|
|
127
|
+
identifier: '00619947000020',
|
|
128
|
+
fulfillmentType: 'shipping',
|
|
129
|
+
quantity: 1,
|
|
130
|
+
engravingLines: ['Happy Birthday', 'Love, Sam']
|
|
131
|
+
}
|
|
132
|
+
], true);
|
|
112
133
|
```
|
|
113
134
|
|
|
114
135
|
### Address Requirement
|
|
@@ -62,6 +62,8 @@ addProduct(params: IAddProductParams[], openCheckout?: boolean): Promise<void>
|
|
|
62
62
|
|
|
63
63
|
Add products directly to checkout, bypassing the cart.
|
|
64
64
|
|
|
65
|
+
`IAddProductParams.engravingLines?: string[]` — optional engraving. Same rules as [`actions.cart.addProduct()`](./cart-actions.md#actionscartaddproduct): invalid input is ignored, blanks stripped, lines clamped to the product's `maxLines` / `maxCharsPerLine`, and engraving is dropped (without failing) when the product, variant, or fulfillment doesn't support it.
|
|
66
|
+
|
|
65
67
|
```javascript
|
|
66
68
|
await window.LiquidCommerce.elements.actions.checkout.addProduct([
|
|
67
69
|
{
|
|
@@ -70,6 +72,16 @@ await window.LiquidCommerce.elements.actions.checkout.addProduct([
|
|
|
70
72
|
quantity: 1
|
|
71
73
|
}
|
|
72
74
|
], true); // Open checkout after adding
|
|
75
|
+
|
|
76
|
+
// With engraving
|
|
77
|
+
await window.LiquidCommerce.elements.actions.checkout.addProduct([
|
|
78
|
+
{
|
|
79
|
+
identifier: '00619947000020',
|
|
80
|
+
fulfillmentType: 'shipping',
|
|
81
|
+
quantity: 1,
|
|
82
|
+
engravingLines: ['For Dad']
|
|
83
|
+
}
|
|
84
|
+
], true);
|
|
73
85
|
```
|
|
74
86
|
|
|
75
87
|
### actions.checkout.addAnonymousProduct()
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "LiquidCommerce Elements SDK",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "LiquidCommerce Team",
|
|
6
|
-
"version": "2.7.
|
|
6
|
+
"version": "2.7.14",
|
|
7
7
|
"homepage": "https://docs.liquidcommerce.co/elements-sdk",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
"embeddable commerce"
|
|
78
78
|
],
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@biomejs/biome": "^2.4.
|
|
81
|
-
"@commitlint/cli": "^20.5.
|
|
82
|
-
"@commitlint/config-conventional": "^20.5.
|
|
80
|
+
"@biomejs/biome": "^2.4.13",
|
|
81
|
+
"@commitlint/cli": "^20.5.3",
|
|
82
|
+
"@commitlint/config-conventional": "^20.5.3",
|
|
83
83
|
"@rollup/plugin-alias": "^6.0.0",
|
|
84
84
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
85
85
|
"@rollup/plugin-json": "^6.1.0",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"conventional-changelog": "^7.2.0",
|
|
98
98
|
"husky": "^9.1.7",
|
|
99
99
|
"process": "^0.11.10",
|
|
100
|
-
"rollup": "^4.60.
|
|
100
|
+
"rollup": "^4.60.2",
|
|
101
101
|
"rollup-obfuscator": "^4.1.1",
|
|
102
102
|
"rollup-plugin-typescript2": "^0.37.0",
|
|
103
103
|
"semantic-release": "^25.0.3",
|