@liquidcommerce/elements-sdk 2.7.1 → 2.7.3

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 (110) hide show
  1. package/README.md +1 -1
  2. package/dist/index.checkout.esm.js +6788 -6890
  3. package/dist/index.esm.js +10440 -10643
  4. package/dist/ssr-stub.checkout.esm.js +18 -0
  5. package/dist/ssr-stub.esm.js +270 -0
  6. package/dist/types/auto-initialize/shared-utils.d.ts +3 -1
  7. package/dist/types/clients/base.d.ts +6 -4
  8. package/dist/types/clients/builder.d.ts +2 -1
  9. package/dist/types/clients/checkout.d.ts +2 -10
  10. package/dist/types/clients/main.d.ts +2 -1
  11. package/dist/types/constants/core.constant.d.ts +0 -5
  12. package/dist/types/core/api/api-client.service.d.ts +16 -15
  13. package/dist/types/core/api/api-result.d.ts +19 -0
  14. package/dist/types/core/api/auth-client.service.d.ts +13 -5
  15. package/dist/types/core/base-component.service.d.ts +2 -1
  16. package/dist/types/core/client/client-action.service.d.ts +1 -1
  17. package/dist/types/core/client/client-config.service.d.ts +1 -1
  18. package/dist/types/core/pubsub/pubsub.service.d.ts +0 -2
  19. package/dist/types/core/singleton-manager.service.d.ts +12 -8
  20. package/dist/types/core/store/interfaces/core.interface.d.ts +7 -11
  21. package/dist/types/core/store/interfaces/product-list.interface.d.ts +12 -28
  22. package/dist/types/core/store/store.service.d.ts +1 -0
  23. package/dist/types/core/telemetry/telemetry.service.d.ts +1 -0
  24. package/dist/types/enums/core.enum.d.ts +5 -4
  25. package/dist/types/index.checkout.d.ts +3 -2
  26. package/dist/types/index.checkout.umd.d.ts +1 -1
  27. package/dist/types/index.d.ts +4 -1
  28. package/dist/types/interfaces/client.interface.d.ts +72 -0
  29. package/dist/types/interfaces/component.interface.d.ts +7 -0
  30. package/dist/types/interfaces/config.interface.d.ts +46 -0
  31. package/dist/types/interfaces/configs/address.interface.d.ts +1 -1
  32. package/dist/types/interfaces/configs/cart.interface.d.ts +1 -1
  33. package/dist/types/interfaces/configs/checkout.interface.d.ts +1 -1
  34. package/dist/types/interfaces/configs/global.interface.d.ts +1 -1
  35. package/dist/types/interfaces/configs/product-list.interface.d.ts +1 -1
  36. package/dist/types/interfaces/configs/product.interface.d.ts +1 -1
  37. package/dist/types/interfaces/injection.interface.d.ts +44 -0
  38. package/dist/types/modules/address/address-input.component.d.ts +0 -11
  39. package/dist/types/modules/address/address.command.d.ts +1 -1
  40. package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +1 -0
  41. package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
  42. package/dist/types/modules/product/components/product-image-carousel.component.d.ts +3 -0
  43. package/dist/types/modules/product/components/product-retailers-carousel.component.d.ts +3 -0
  44. package/dist/types/modules/product/components/product-retailers-popup-list.component.d.ts +3 -2
  45. package/dist/types/modules/product/product.commands.d.ts +1 -3
  46. package/dist/types/modules/product-list/components/card-components/index.d.ts +0 -2
  47. package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +1 -0
  48. package/dist/types/modules/product-list/components/card-components/product-sizes-list.d.ts +9 -3
  49. package/dist/types/modules/product-list/components/index.d.ts +1 -1
  50. package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +2 -5
  51. package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +3 -3
  52. package/dist/types/modules/product-list/components/product-list-product-engraving-lines.component.d.ts +21 -0
  53. package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +30 -14
  54. package/dist/types/modules/product-list/components/product-list-search.component.d.ts +0 -2
  55. package/dist/types/modules/product-list/product-list-card.component.d.ts +18 -16
  56. package/dist/types/modules/product-list/product-list-filter.utils.d.ts +8 -0
  57. package/dist/types/modules/product-list/product-list.commands.d.ts +7 -54
  58. package/dist/types/modules/product-list/product-list.component.d.ts +2 -11
  59. package/dist/types/modules/product-list/product-list.interface.d.ts +0 -30
  60. package/dist/types/modules/ui-components/drawer/drawer.component.d.ts +1 -0
  61. package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +1 -10
  62. package/dist/types/modules/ui-components/engraving/engraving-view.component.d.ts +4 -1
  63. package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
  64. package/dist/types/modules/ui-components/promo-code-ticker/promo-code-ticker.component.d.ts +1 -1
  65. package/dist/types/modules/ui-components/ui.commands.d.ts +6 -4
  66. package/dist/types/ssr/stub.checkout.d.ts +6 -0
  67. package/dist/types/ssr/stub.d.ts +10 -0
  68. package/dist/types/utils/dom-compat.d.ts +2 -0
  69. package/dist/types/utils/product-selection.d.ts +16 -0
  70. package/dist/types/utils/product.d.ts +10 -0
  71. package/docs/v1/README.md +2 -2
  72. package/docs/v1/api/actions/address-actions.md +11 -11
  73. package/docs/v1/api/actions/cart-actions.md +13 -13
  74. package/docs/v1/api/actions/checkout-actions.md +23 -23
  75. package/docs/v1/api/actions/product-actions.md +6 -6
  76. package/docs/v1/api/client.md +11 -11
  77. package/docs/v1/api/ui-helpers.md +11 -11
  78. package/docs/v1/examples/advanced-patterns.md +1 -1
  79. package/docs/v1/examples/checkout-flow.md +1 -1
  80. package/docs/v1/getting-started/concepts.md +7 -7
  81. package/docs/v1/getting-started/installation.md +2 -2
  82. package/docs/v1/getting-started/quick-start.md +3 -3
  83. package/docs/v1/guides/address-component.md +11 -11
  84. package/docs/v1/guides/best-practices.md +14 -14
  85. package/docs/v1/guides/cart-component.md +23 -23
  86. package/docs/v1/guides/checkout-component.md +24 -24
  87. package/docs/v1/guides/events.md +812 -77
  88. package/docs/v1/guides/product-component.md +5 -5
  89. package/docs/v1/integration/nextjs.md +11 -2
  90. package/docs/v1/integration/react.md +3 -3
  91. package/docs/v1/integration/vanilla-js.md +1 -1
  92. package/docs/v1/integration/vue.md +24 -0
  93. package/docs/v1/reference/browser-support.md +9 -0
  94. package/docs/v1/reference/error-handling.md +2 -2
  95. package/docs/v1/reference/troubleshooting.md +10 -2
  96. package/package.json +17 -13
  97. package/dist/types/interfaces/core.interface.d.ts +0 -139
  98. package/dist/types/modules/product-list/components/card-components/product-fulfillments.d.ts +0 -12
  99. package/dist/types/modules/product-list/components/card-components/product-title.d.ts +0 -6
  100. package/dist/types/modules/product-list/components/product-list-retailers.component.d.ts +0 -26
  101. package/dist/types/modules/ui-components/modal/modal.component.d.ts +0 -23
  102. package/dist/types/modules/ui-components/styles/modal.style.d.ts +0 -1
  103. package/docs/gitbook/actions.md +0 -160
  104. package/docs/gitbook/address.md +0 -48
  105. package/docs/gitbook/cart.md +0 -65
  106. package/docs/gitbook/checkout.md +0 -131
  107. package/docs/gitbook/events.md +0 -137
  108. package/docs/gitbook/overview.md +0 -166
  109. package/docs/gitbook/product.md +0 -64
  110. package/docs/gitbook/quick-start-guide.md +0 -393
@@ -212,7 +212,7 @@ Programmatically interact with products:
212
212
  Retrieve product information:
213
213
 
214
214
  ```javascript
215
- const productData = window.elements.actions.product.getDetails('00619947000020');
215
+ const productData = window.LiquidCommerce.elements.actions.product.getDetails('00619947000020');
216
216
 
217
217
  console.log(productData);
218
218
  // {
@@ -388,10 +388,10 @@ Set address programmatically to skip prompting:
388
388
 
389
389
  ```javascript
390
390
  // Using Google Places ID
391
- await window.elements.actions.address.setAddressByPlacesId('ChIJ...');
391
+ await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId('ChIJ...');
392
392
 
393
393
  // Or manually
394
- await window.elements.actions.address.setAddressManually(
394
+ await window.LiquidCommerce.elements.actions.address.setAddressManually(
395
395
  {
396
396
  one: '123 Main St',
397
397
  two: 'Apt 4',
@@ -423,7 +423,7 @@ Presale products are handled automatically; no special configuration needed.
423
423
  Force a product to reload and rerender:
424
424
 
425
425
  ```javascript
426
- const components = window.elements.getInjectedComponents();
426
+ const components = window.LiquidCommerce.elements.getInjectedComponents();
427
427
  const productComponent = components.get('product-1');
428
428
 
429
429
  if (productComponent) {
@@ -656,7 +656,7 @@ document.querySelectorAll('.product-placeholder').forEach(el => {
656
656
  1. Check browser console for errors
657
657
  2. Verify container ID exists in the DOM
658
658
  3. Confirm product identifier is valid
659
- 4. Check that SDK is initialized (`window.elements` exists)
659
+ 4. Check that SDK is initialized (`window.LiquidCommerce.elements` exists)
660
660
 
661
661
  ### Wrong Pricing
662
662
 
@@ -1,6 +1,6 @@
1
1
  # Next.js Integration
2
2
 
3
- Use a client component (App Router) or `useEffect` in a client-only page (Pages Router). Initialize the SDK on the client.
3
+ The SDK is SSR-safe out of the box. When imported on the server, a lightweight stub is resolved automatically via the `node` export condition no dynamic imports or special configuration required. The real SDK activates on the client.
4
4
 
5
5
  ## App Router (Client Component)
6
6
 
@@ -48,9 +48,18 @@ export default function ProductPage() {
48
48
  }
49
49
  ```
50
50
 
51
+ ## SSR Behavior
52
+
53
+ When the module is evaluated during SSR (server components, `getServerSideProps`, middleware, etc.):
54
+
55
+ - All **types and enums** are available — TypeScript works identically.
56
+ - `Elements()` and `ElementsBuilder()` return `null` and log a warning.
57
+ - No browser APIs (`window`, `document`, `navigator`) are accessed.
58
+
59
+ You do **not** need `next/dynamic`, conditional `import()`, or `typeof window` guards in your own code.
60
+
51
61
  ## Notes
52
62
 
53
- - Do not initialize server-side (Window/Document required).
54
63
  - For ad blocker mitigation, configure the proxy (see [Proxy Setup](./proxy-setup.md)).
55
64
 
56
65
  ## Related Docs
@@ -44,8 +44,8 @@ import { useEffect } from 'react';
44
44
 
45
45
  export default function CartButton() {
46
46
  useEffect(() => {
47
- if (!window.elements) return;
48
- window.elements.ui.cartButton('header-cart', true);
47
+ if (!window.LiquidCommerce.elements) return;
48
+ window.LiquidCommerce.elements.ui.cartButton('header-cart', true);
49
49
  }, []);
50
50
 
51
51
  return <div id="header-cart"></div>;
@@ -54,7 +54,7 @@ export default function CartButton() {
54
54
 
55
55
  ## Notes
56
56
 
57
- - Initialize only on the client; the SDK uses browser APIs.
57
+ - The SDK is SSR-safe — importing it on the server resolves a no-op stub automatically. Initialize in `useEffect` to get the real client.
58
58
  - For multiple products, call `injectProductElement` with multiple entries.
59
59
 
60
60
  ## Related Docs
@@ -51,7 +51,7 @@ Use the CDN build for the fastest setup, or use NPM if you have a build step.
51
51
 
52
52
  <script>
53
53
  window.addEventListener('lce:actions.client_ready', async () => {
54
- const client = window.elements;
54
+ const client = window.LiquidCommerce.elements;
55
55
  await client.injectProductElement([
56
56
  { containerId: 'product', identifier: '00619947000020' }
57
57
  ]);
@@ -28,6 +28,30 @@ onMounted(async () => {
28
28
  </script>
29
29
  ```
30
30
 
31
+ ## Nuxt 3
32
+
33
+ The SDK is SSR-safe out of the box. When Nuxt evaluates the import on the server, a lightweight stub is resolved automatically — no `<ClientOnly>`, `process.client` checks, or dynamic imports required.
34
+
35
+ ```vue
36
+ <template>
37
+ <div id="product"></div>
38
+ </template>
39
+
40
+ <script setup>
41
+ import { onMounted } from 'vue';
42
+ import { Elements } from '@liquidcommerce/elements-sdk';
43
+
44
+ onMounted(async () => {
45
+ const client = await Elements('YOUR_API_KEY', { env: 'production' });
46
+ await client.injectProductElement([
47
+ { containerId: 'product', identifier: '00619947000020' }
48
+ ]);
49
+ });
50
+ </script>
51
+ ```
52
+
53
+ During SSR, `Elements()` returns `null` and logs a warning. All types and enums remain available for TypeScript.
54
+
31
55
  ## Related Docs
32
56
 
33
57
  - [Product Component](../guides/product-component.md)
@@ -17,6 +17,15 @@ The Elements SDK requires modern browser features (Web Components + Shadow DOM).
17
17
  - Fetch API
18
18
  - LocalStorage
19
19
 
20
+ ## Server-Side Rendering (SSR)
21
+
22
+ The SDK is browser-only, but it is safe to import in SSR frameworks (Next.js, Remix, Nuxt).
23
+ In non-browser environments, initialization is skipped. If you call the SDK on the server,
24
+ it returns `null` and logs a warning instead of throwing.
25
+
26
+ Call `Elements`, `ElementsCheckout`, or `ElementsBuilder` from client-only code (e.g., after mount)
27
+ to render components.
28
+
20
29
  ## Polyfills (Legacy Browsers)
21
30
 
22
31
  ```html
@@ -19,7 +19,7 @@ class SDKError extends Error {
19
19
 
20
20
  ```javascript
21
21
  try {
22
- await window.elements.injectProductElement([
22
+ await window.LiquidCommerce.elements.injectProductElement([
23
23
  { containerId: 'product', identifier: 'invalid_id' }
24
24
  ]);
25
25
  } catch (error) {
@@ -34,7 +34,7 @@ try {
34
34
  The SDK catches and contains its own errors so your app keeps running:
35
35
 
36
36
  ```javascript
37
- window.elements.actions.cart.addProduct([/* invalid */]);
37
+ window.LiquidCommerce.elements.actions.cart.addProduct([/* invalid */]);
38
38
  console.log('App still working');
39
39
  ```
40
40
 
@@ -4,7 +4,7 @@ Common setup issues and how to resolve them.
4
4
 
5
5
  ## SDK Script Not Loading
6
6
 
7
- **Symptoms:** 404/CORS in Network tab, `window.elements` is undefined.
7
+ **Symptoms:** 404/CORS in Network tab, `window.LiquidCommerce.elements` is undefined.
8
8
 
9
9
  **Fixes:**
10
10
  - Verify the script URL and that the tag includes `data-liquid-commerce-elements`.
@@ -36,7 +36,7 @@ Common setup issues and how to resolve them.
36
36
  **Symptoms:** Add to cart works but cart stays closed.
37
37
 
38
38
  **Fixes:**
39
- - Ensure a cart button is configured or call `window.elements.actions.cart.openCart()`.
39
+ - Ensure a cart button is configured or call `window.LiquidCommerce.elements.actions.cart.openCart()`.
40
40
  - Check for JavaScript errors in the console.
41
41
 
42
42
  ## Checkout Issues
@@ -56,6 +56,14 @@ Common setup issues and how to resolve them.
56
56
  - Make sure the address is set and valid.
57
57
  - Listen for `lce:actions.address_failed` to surface errors.
58
58
 
59
+ ## SSR / Server-Side Rendering
60
+
61
+ **Symptoms:** Console warning "This SDK is designed for the browser. Calls made during SSR return null."
62
+
63
+ This is expected behavior. The SDK ships an SSR stub that is automatically resolved when bundled for Node.js (via the `node` export condition in `package.json`). The stub exports all types and enums for TypeScript compatibility and returns `null` from factory functions (`Elements`, `ElementsBuilder`, `ElementsCheckout`).
64
+
65
+ **No action required** — initialize the SDK in a client-only lifecycle hook (`useEffect`, `onMounted`, etc.) and the real client will activate in the browser.
66
+
59
67
  ## Related Docs
60
68
 
61
69
  - [Installation](../getting-started/installation.md)
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.1",
6
+ "version": "2.7.3",
7
7
  "homepage": "https://docs.liquidcommerce.co/elements-sdk",
8
8
  "repository": {
9
9
  "type": "git",
@@ -18,11 +18,15 @@
18
18
  "exports": {
19
19
  ".": {
20
20
  "types": "./dist/types/index.d.ts",
21
+ "node": "./dist/ssr-stub.esm.js",
22
+ "browser": "./dist/index.esm.js",
21
23
  "import": "./dist/index.esm.js",
22
24
  "default": "./dist/index.esm.js"
23
25
  },
24
26
  "./checkout": {
25
27
  "types": "./dist/types/index.checkout.d.ts",
28
+ "node": "./dist/ssr-stub.checkout.esm.js",
29
+ "browser": "./dist/index.checkout.esm.js",
26
30
  "import": "./dist/index.checkout.esm.js",
27
31
  "default": "./dist/index.checkout.esm.js"
28
32
  },
@@ -30,7 +34,7 @@
30
34
  },
31
35
  "files": [
32
36
  "dist",
33
- "docs",
37
+ "docs/v1",
34
38
  "README.md",
35
39
  "LICENSE"
36
40
  ],
@@ -52,15 +56,15 @@
52
56
  "scripts": {
53
57
  "build": "rollup -c",
54
58
  "build:checkout": "rollup -c rollup.config.checkout.mjs",
55
- "build:dev": "rollup -c --environment NODE_ENV:development",
59
+ "build:all": "pnpm build && pnpm build:checkout",
56
60
  "dev": "rollup -c -w",
57
61
  "type-check": "tsc --noEmit",
58
62
  "lint": "pnpm biome lint --write",
59
63
  "format": "biome format --write",
60
64
  "check": "pnpm biome check --write .",
61
- "fl": "pnpm check && pnpm build && pnpm build:checkout",
65
+ "fl": "pnpm check && pnpm tsc --noEmit",
62
66
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
63
- "clean": "rm -rf dist umd node_modules && pnpm install && pnpm build && pnpm build:checkout",
67
+ "clean": "rm -rf dist umd node_modules && pnpm install && pnpm build:all",
64
68
  "prepublishOnly": "pnpm run build",
65
69
  "deprecate:old": "npm deprecate @liquidcommerceteam/elements-sdk@\"*\" \"Package moved to @liquidcommerce/elements-sdk\"",
66
70
  "prepare": "husky"
@@ -77,9 +81,9 @@
77
81
  "embeddable commerce"
78
82
  ],
79
83
  "devDependencies": {
80
- "@biomejs/biome": "2.3.12",
81
- "@commitlint/cli": "^20.3.1",
82
- "@commitlint/config-conventional": "^20.3.1",
84
+ "@biomejs/biome": "^2.3.14",
85
+ "@commitlint/cli": "^20.4.1",
86
+ "@commitlint/config-conventional": "^20.4.1",
83
87
  "@rollup/plugin-alias": "^6.0.0",
84
88
  "@rollup/plugin-commonjs": "^29.0.0",
85
89
  "@rollup/plugin-json": "^6.1.0",
@@ -89,18 +93,18 @@
89
93
  "@semantic-release/changelog": "^6.0.3",
90
94
  "@semantic-release/commit-analyzer": "^13.0.1",
91
95
  "@semantic-release/git": "^10.0.1",
92
- "@semantic-release/github": "^12.0.2",
93
- "@semantic-release/npm": "^13.1.3",
96
+ "@semantic-release/github": "^12.0.5",
97
+ "@semantic-release/npm": "^13.1.4",
94
98
  "@semantic-release/release-notes-generator": "^14.1.0",
95
99
  "@types/core-js": "^2.5.8",
96
- "@types/node": "^25.0.10",
100
+ "@types/node": "^25.2.2",
97
101
  "conventional-changelog-cli": "^5.0.0",
98
102
  "husky": "^9.1.7",
99
103
  "process": "^0.11.10",
100
- "rollup": "^4.56.0",
104
+ "rollup": "^4.57.1",
101
105
  "rollup-obfuscator": "^4.1.1",
102
106
  "rollup-plugin-typescript2": "^0.36.0",
103
- "semantic-release": "^25.0.2",
107
+ "semantic-release": "^25.0.3",
104
108
  "ts-node": "^10.9.2",
105
109
  "typescript": "^5.9.3"
106
110
  },
@@ -1,139 +0,0 @@
1
- import type { PRODUCT_LIST_FILTER_TYPES } from '@/constants';
2
- import type { IAddressActions } from '@/core/client/actions/client-address-action.service';
3
- import type { ICartActions } from '@/core/client/actions/client-cart-action.service';
4
- import type { ICheckoutActions } from '@/core/client/actions/client-checkout-action.service';
5
- import type { IProductActions } from '@/core/client/actions/client-product-action.service';
6
- import type { IClientConfigs } from '@/core/client/client-config.service';
7
- import type { ComponentType, DebugMode, ElementsEnv } from '@/enums';
8
- import type { IAddressOptions } from '@/modules/address/address.interface';
9
- import type { IPromoTicker, UpdateAddressComponent, UpdateCartComponent, UpdateCheckoutComponent, UpdateComponentGlobalConfigs, UpdateProductComponent } from './configs';
10
- export type DeepPartial<T> = {
11
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
12
- };
13
- export interface IElementsProxyConfig {
14
- baseUrl: string;
15
- headers?: Record<string, string>;
16
- }
17
- export interface ILiquidCommerceElementsDevelopmentConfig {
18
- customApiUrl?: string;
19
- paymentMethodId?: string;
20
- openShadowDom?: boolean;
21
- }
22
- export interface IClientCustomThemeConfig {
23
- global?: UpdateComponentGlobalConfigs;
24
- product?: UpdateProductComponent;
25
- address?: UpdateAddressComponent;
26
- cart?: UpdateCartComponent;
27
- checkout?: UpdateCheckoutComponent;
28
- }
29
- export interface ILiquidCommerceElementsCheckoutConfig {
30
- pageUrl: string;
31
- }
32
- export interface ILiquidCommerceElementsBaseConfig {
33
- env?: ElementsEnv;
34
- promoTicker?: IPromoTicker[];
35
- customTheme?: IClientCustomThemeConfig;
36
- debugMode?: DebugMode;
37
- checkout?: ILiquidCommerceElementsCheckoutConfig;
38
- }
39
- export interface ILiquidCommerceElementsBuilderConfig extends ILiquidCommerceElementsBaseConfig {
40
- }
41
- export interface ILiquidCommerceElementsConfig extends ILiquidCommerceElementsBaseConfig {
42
- proxy?: IElementsProxyConfig;
43
- development?: ILiquidCommerceElementsDevelopmentConfig;
44
- }
45
- export interface ILiquidCommerceElementsCheckoutClientConfig {
46
- env?: ElementsEnv;
47
- customTheme?: IClientCustomThemeConfig;
48
- debugMode?: DebugMode;
49
- checkout?: ILiquidCommerceElementsCheckoutConfig;
50
- proxy?: IElementsProxyConfig;
51
- development?: ILiquidCommerceElementsDevelopmentConfig;
52
- }
53
- export interface IInjectProductElement {
54
- containerId: string;
55
- identifier: string;
56
- }
57
- export type ProductListFilterType = (typeof PRODUCT_LIST_FILTER_TYPES)[keyof typeof PRODUCT_LIST_FILTER_TYPES];
58
- export interface IInjectProductListParams {
59
- containerId: string;
60
- rows?: number;
61
- columns?: number;
62
- filters?: ProductListFilterType[];
63
- productUrl?: string;
64
- }
65
- export interface IInjectProductListSearchParams {
66
- containerId: string;
67
- }
68
- export interface IInjectProductListFiltersParams {
69
- containerId: string;
70
- filters: ProductListFilterType[];
71
- }
72
- export interface IBuilderInjectElementParams {
73
- type: ComponentType;
74
- containerId: string;
75
- [key: string]: any;
76
- }
77
- export interface IInjectedComponent {
78
- getType(): ComponentType;
79
- getElement(): HTMLElement;
80
- rerender(): void;
81
- }
82
- export interface IProcessInjectElementParams {
83
- type: ComponentType;
84
- containerId: string;
85
- identifier?: string;
86
- options?: IAddressOptions;
87
- checkoutId?: string;
88
- hideHeader?: boolean;
89
- }
90
- export interface IInjectCheckoutParams {
91
- containerId: string;
92
- checkoutId?: string;
93
- hideHeader?: boolean;
94
- }
95
- export interface ILiquidCommerceElementsUIMethod {
96
- cartButton(containerId: string, showItemsCount?: boolean): void;
97
- floatingCartButton(showItemsCount?: boolean): void;
98
- cartSubtotal(elementId: string): void;
99
- cartItemsCount(elementId: string, options?: {
100
- hideZero: boolean;
101
- }): void;
102
- }
103
- export interface ILiquidCommerceElementsActions {
104
- product: IProductActions;
105
- address: IAddressActions;
106
- cart: ICartActions;
107
- checkout: ICheckoutActions;
108
- }
109
- export interface ILiquidCommerceElementsBuilderClient {
110
- updateComponentGlobalConfigs(configs: UpdateComponentGlobalConfigs): Promise<void>;
111
- updateProductComponent(configs: UpdateProductComponent): Promise<void>;
112
- updateAddressComponent(configs: UpdateAddressComponent): void;
113
- updateCartComponent(configs: UpdateCartComponent): void;
114
- updateCheckoutComponent(configs: UpdateCheckoutComponent): void;
115
- injectElement(params: IBuilderInjectElementParams): Promise<IInjectedComponent | null>;
116
- injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
117
- injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
118
- injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
119
- injectCheckoutElement(containerId: string, options?: {
120
- simulatePresale?: boolean;
121
- presaleExpiresInMinutes?: number;
122
- }): Promise<IInjectedComponent | null>;
123
- injectProductList(params: IInjectProductListParams): Promise<void>;
124
- actions: ILiquidCommerceElementsActions;
125
- }
126
- export interface ILiquidCommerceElementsClient {
127
- injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
128
- injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
129
- injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
130
- injectCheckoutElement(params: IInjectCheckoutParams): Promise<IInjectedComponent | null>;
131
- injectProductList(params: IInjectProductListParams): Promise<void>;
132
- injectProductListSearch(params: IInjectProductListSearchParams): Promise<void>;
133
- injectProductListFilters(params: IInjectProductListFiltersParams): Promise<void>;
134
- ui: ILiquidCommerceElementsUIMethod;
135
- actions: ILiquidCommerceElementsActions;
136
- getInjectedComponents(): Map<string, IInjectedComponent>;
137
- }
138
- export type LiquidCommerceElementsClientConstructor = new (clientConfigs: IClientConfigs) => ILiquidCommerceElementsClient;
139
- export type LiquidCommerceElementsBuilderClientConstructor = new (clientConfigs: IClientConfigs) => ILiquidCommerceElementsBuilderClient;
@@ -1,12 +0,0 @@
1
- import type { IProductFulfillmentStore } from 'core/store/interfaces/product.interface';
2
- import { type NavigationSourceType } from 'enums';
3
- export interface IFulfillmentSectionParams {
4
- shippingVariants: Record<string, IProductFulfillmentStore>;
5
- onDemandVariants: Record<string, IProductFulfillmentStore>;
6
- enableShippingFulfillment: boolean;
7
- enableOnDemandFulfillment: boolean;
8
- productId: string;
9
- navigationSource?: NavigationSourceType;
10
- onDeliveryOptionsClick: (productId: string) => void | Promise<void>;
11
- }
12
- export declare const createFulfillmentSection: (params: IFulfillmentSectionParams) => HTMLElement;
@@ -1,6 +0,0 @@
1
- export interface ITitleSectionParams {
2
- name: string;
3
- productUrl?: string | null;
4
- onTitleClick?: () => void;
5
- }
6
- export declare const createProductTitle: ({ name, productUrl, onTitleClick }: ITitleSectionParams) => HTMLElement;
@@ -1,26 +0,0 @@
1
- import type { IProductListProduct } from 'core/store/interfaces/product-list.interface';
2
- import { type DisplayModeType, type NavigationSourceType } from 'enums';
3
- import type { IFulfillment } from 'interfaces/api/product.interface';
4
- import type { IProductListComponent } from 'interfaces/configs';
5
- import { BaseComponent } from '@/core/base-component.service';
6
- export interface IProductListRetailersParams {
7
- product?: IProductListProduct;
8
- productId: string;
9
- config?: IProductListComponent;
10
- displayMode?: DisplayModeType;
11
- navigationSource?: NavigationSourceType;
12
- shippingFulfillment?: IFulfillment | null;
13
- onDemandFulfillment?: IFulfillment | null;
14
- }
15
- export declare class ProductListRetailersComponent extends BaseComponent<IProductListRetailersParams, IProductListComponent> {
16
- get hostClasses(): string[];
17
- constructor();
18
- private getProductId;
19
- protected template(): HTMLElement[];
20
- private extractFulfillments;
21
- private onFulfillmentTabClick;
22
- private onRetailerCardClick;
23
- private reopenAddToCartDrawer;
24
- private createHeader;
25
- private createNoAvailabilityMessage;
26
- }
@@ -1,23 +0,0 @@
1
- import { BaseComponent, type IOnStoreChanged } from '@/core/base-component.service';
2
- export declare class ModalComponent extends BaseComponent {
3
- private isOpen;
4
- private wrapperElement;
5
- private modalElement;
6
- private backdropElement;
7
- private contentContainer;
8
- private currentContentType;
9
- private readonly boundHandleKeydown;
10
- constructor();
11
- disconnected(): void;
12
- onStoreChanged(changes: IOnStoreChanged[]): boolean;
13
- private openWithContent;
14
- private open;
15
- private close;
16
- private cleanupCurrentContent;
17
- private handleBackdropClick;
18
- private handleKeydown;
19
- private updateModalContentTypeClass;
20
- private updateModalState;
21
- private isElementsEnabled;
22
- protected template(): HTMLElement;
23
- }
@@ -1 +0,0 @@
1
- export declare function getModalStyles(): string;
@@ -1,160 +0,0 @@
1
- # Actions
2
-
3
- Actions let you control Elements programmatically after the SDK initializes. All actions live under `window.elements.actions.*`.
4
-
5
- ## Quick start
6
- ```js
7
- window.addEventListener('lce:actions.client_ready', () => {
8
- window.elements.actions.cart.openCart();
9
- });
10
- ```
11
-
12
- ## Product actions
13
- - `actions.product.getDetails(identifier)`
14
- Returns the current loaded product data (price, size, fulfillment, retailer, quantity, images, etc.). The product must already be injected and loaded.
15
-
16
- ```js
17
- const product = window.elements.actions.product.getDetails('00619947000020');
18
- console.log(product.name, product.price);
19
- ```
20
-
21
- ## Cart actions
22
- - `actions.cart.openCart()`
23
- Opens the cart drawer.
24
- - `actions.cart.closeCart()`
25
- Closes the cart drawer.
26
- - `actions.cart.toggleCart()`
27
- Toggles the cart drawer open/closed.
28
- - `actions.cart.addProduct(params[], openCart?)`
29
- Adds one or more products to the cart. If no address is set, the SDK prompts for one and retries automatically.
30
- - `actions.cart.applyPromoCode(promoCode)`
31
- Applies a promo code (replaces any existing code).
32
- - `actions.cart.removePromoCode()`
33
- Removes the active promo code.
34
- - `actions.cart.resetCart()`
35
- Clears all cart items (no undo).
36
- - `actions.cart.getDetails()`
37
- Returns current cart data (items, totals, promo, retailers, etc.).
38
-
39
- ```js
40
- await window.elements.actions.cart.addProduct([
41
- { identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }
42
- ], true);
43
-
44
- await window.elements.actions.cart.applyPromoCode('SUMMER20');
45
- await window.elements.actions.cart.removePromoCode();
46
- await window.elements.actions.cart.resetCart();
47
-
48
- const cart = window.elements.actions.cart.getDetails();
49
- ```
50
-
51
- ## Checkout actions
52
- - `actions.checkout.openCheckout()`
53
- Opens the checkout drawer.
54
- - `actions.checkout.closeCheckout()`
55
- Closes the checkout drawer.
56
- - `actions.checkout.toggleCheckout()`
57
- Toggles the checkout drawer open/closed.
58
- - `actions.checkout.exitCheckout()`
59
- Navigates away from checkout (requires `exitUrl` config).
60
- - `actions.checkout.addProduct(params[], openCheckout?)`
61
- Adds products directly to checkout (bypasses cart).
62
- - `actions.checkout.applyPromoCode(promoCode)`
63
- Applies a promo code in checkout.
64
- - `actions.checkout.removePromoCode()`
65
- Removes the active promo code.
66
- - `actions.checkout.applyGiftCard(code)`
67
- Applies a gift card.
68
- - `actions.checkout.removeGiftCard(code)`
69
- Removes a gift card.
70
- - `actions.checkout.toggleIsGift(active?)`
71
- Enables/disables gift mode (or toggles when omitted).
72
- - `actions.checkout.toggleBillingSameAsShipping(active?)`
73
- Sets billing address to match shipping.
74
- - `actions.checkout.toggleMarketingPreferences(field, active)`
75
- Sets marketing opt-in (`canEmail` or `canSms`).
76
- - `actions.checkout.updateCustomerInfo(fields)`
77
- Prefills customer info (name, email, phone, birthdate, etc.).
78
- - `actions.checkout.updateBillingInfo(fields)`
79
- Prefills billing address fields.
80
- - `actions.checkout.updateGiftInfo(fields)`
81
- Prefills gift recipient information.
82
-
83
- ```js
84
- window.elements.actions.checkout.openCheckout();
85
- window.elements.actions.checkout.closeCheckout();
86
- window.elements.actions.checkout.toggleCheckout();
87
-
88
- await window.elements.actions.checkout.addProduct([
89
- { identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }
90
- ], true);
91
-
92
- await window.elements.actions.checkout.applyPromoCode('WELCOME10');
93
- await window.elements.actions.checkout.applyGiftCard('GIFT-1234-5678');
94
-
95
- await window.elements.actions.checkout.toggleIsGift(true);
96
- await window.elements.actions.checkout.toggleBillingSameAsShipping(false);
97
- await window.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
98
-
99
- window.elements.actions.checkout.updateCustomerInfo({
100
- firstName: 'John',
101
- lastName: 'Doe',
102
- email: 'john@example.com'
103
- });
104
-
105
- window.elements.actions.checkout.updateBillingInfo({
106
- firstName: 'John',
107
- lastName: 'Doe',
108
- addressOne: '789 Elm St',
109
- city: 'Chicago',
110
- state: 'IL',
111
- zipCode: '60601'
112
- });
113
-
114
- window.elements.actions.checkout.updateGiftInfo({
115
- firstName: 'Jane',
116
- lastName: 'Smith',
117
- message: 'Happy Birthday!'
118
- });
119
- ```
120
-
121
- ## Address actions
122
- - `actions.address.setAddressByPlacesId(placesId)`
123
- Sets address using a Google Places ID (recommended).
124
- - `actions.address.setAddressManually(address, coordinates)`
125
- Sets address with your own address + lat/long data.
126
- - `actions.address.getDetails()`
127
- Returns the current address (or null if not set).
128
- - `actions.address.clear()`
129
- Removes the stored address and resets availability.
130
-
131
- ```js
132
- await window.elements.actions.address.setAddressByPlacesId('ChIJOwg_06VPwokRYv534QaPC8g');
133
-
134
- await window.elements.actions.address.setAddressManually(
135
- { one: '123 Main Street', city: 'New York', state: 'NY', zip: '10001' },
136
- { latitude: 40.7128, longitude: -74.0060 }
137
- );
138
-
139
- const address = window.elements.actions.address.getDetails();
140
- await window.elements.actions.address.clear();
141
- ```
142
-
143
- ## UI helpers (non-actions)
144
- These helpers live under `window.elements.ui.*` and are commonly used with actions.
145
-
146
- - `ui.cartButton(containerId, showItemsCount?)`
147
- Renders a cart button inside the given container.
148
- - `ui.floatingCartButton(showItemsCount?)`
149
- Renders a floating cart button (bottom-right).
150
- - `ui.cartSubtotal(elementId)`
151
- Keeps an element updated with cart subtotal.
152
- - `ui.cartItemsCount(elementId, { hideZero })`
153
- Keeps an element updated with cart item count.
154
-
155
- ```js
156
- window.elements.ui.cartButton('header-cart', true);
157
- window.elements.ui.floatingCartButton(true);
158
- window.elements.ui.cartSubtotal('cart-total');
159
- window.elements.ui.cartItemsCount('items-count', { hideZero: true });
160
- ```