@liquidcommerce/elements-sdk 2.7.0 → 2.7.2

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 (81) hide show
  1. package/README.md +83 -2750
  2. package/dist/index.checkout.esm.js +6898 -6837
  3. package/dist/index.esm.js +11463 -10993
  4. package/dist/types/auto-initialize/shared-utils.d.ts +5 -0
  5. package/dist/types/constants/core.constant.d.ts +0 -4
  6. package/dist/types/core/base-component.service.d.ts +2 -1
  7. package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +1 -0
  8. package/dist/types/enums/core.enum.d.ts +11 -0
  9. package/dist/types/interfaces/configs/product-list.interface.d.ts +2 -2
  10. package/dist/types/interfaces/core.interface.d.ts +5 -4
  11. package/dist/types/modules/address/address-input.component.d.ts +11 -0
  12. package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
  13. package/dist/types/modules/product-list/components/card-components/index.d.ts +3 -0
  14. package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +8 -0
  15. package/dist/types/modules/product-list/components/card-components/product-fulfillments.d.ts +2 -0
  16. package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +13 -0
  17. package/dist/types/modules/product-list/components/card-components/product-title.d.ts +6 -0
  18. package/dist/types/modules/product-list/components/index.d.ts +1 -0
  19. package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +5 -1
  20. package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +28 -0
  21. package/dist/types/modules/product-list/components/product-list-retailers.component.d.ts +10 -2
  22. package/dist/types/modules/product-list/product-list-card.component.d.ts +0 -5
  23. package/dist/types/modules/product-list/product-list.commands.d.ts +11 -2
  24. package/dist/types/modules/product-list/product-list.interface.d.ts +1 -0
  25. package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +11 -2
  26. package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
  27. package/dist/types/utils/dom-compat.d.ts +2 -0
  28. package/docs/gitbook/actions.md +964 -0
  29. package/docs/gitbook/address.md +48 -0
  30. package/docs/gitbook/cart.md +65 -0
  31. package/docs/gitbook/checkout.md +131 -0
  32. package/docs/gitbook/events.md +1765 -0
  33. package/docs/gitbook/overview.md +166 -0
  34. package/docs/gitbook/product.md +64 -0
  35. package/docs/gitbook/quick-start-guide.md +393 -0
  36. package/docs/v1/README.md +210 -0
  37. package/docs/v1/api/actions/address-actions.md +281 -0
  38. package/docs/v1/api/actions/cart-actions.md +337 -0
  39. package/docs/v1/api/actions/checkout-actions.md +387 -0
  40. package/docs/v1/api/actions/product-actions.md +115 -0
  41. package/docs/v1/api/client.md +482 -0
  42. package/docs/v1/api/configuration.md +1 -0
  43. package/docs/v1/api/injection-methods.md +247 -0
  44. package/docs/v1/api/typescript-types.md +1 -0
  45. package/docs/v1/api/ui-helpers.md +200 -0
  46. package/docs/v1/examples/advanced-patterns.md +96 -0
  47. package/docs/v1/examples/checkout-flow.md +91 -0
  48. package/docs/v1/examples/custom-theming.md +63 -0
  49. package/docs/v1/examples/multi-product-page.md +90 -0
  50. package/docs/v1/examples/simple-product-page.md +89 -0
  51. package/docs/v1/getting-started/concepts.md +507 -0
  52. package/docs/v1/getting-started/installation.md +328 -0
  53. package/docs/v1/getting-started/quick-start.md +405 -0
  54. package/docs/v1/guides/address-component.md +431 -0
  55. package/docs/v1/guides/best-practices.md +324 -0
  56. package/docs/v1/guides/cart-component.md +737 -0
  57. package/docs/v1/guides/checkout-component.md +672 -0
  58. package/docs/v1/guides/events.md +926 -0
  59. package/docs/v1/guides/product-component.md +686 -0
  60. package/docs/v1/guides/product-list-component.md +598 -0
  61. package/docs/v1/guides/theming.md +216 -0
  62. package/docs/v1/integration/angular.md +39 -0
  63. package/docs/v1/integration/laravel.md +41 -0
  64. package/docs/v1/integration/nextjs.md +60 -0
  65. package/docs/v1/integration/proxy-setup.md +89 -0
  66. package/docs/v1/integration/react.md +64 -0
  67. package/docs/v1/integration/vanilla-js.md +84 -0
  68. package/docs/v1/integration/vue.md +34 -0
  69. package/docs/v1/reference/browser-support.md +44 -0
  70. package/docs/v1/reference/error-handling.md +70 -0
  71. package/docs/v1/reference/performance.md +54 -0
  72. package/docs/v1/reference/troubleshooting.md +64 -0
  73. package/package.json +1 -1
  74. package/docs/ACTIONS.md +0 -1301
  75. package/docs/BROWSER_SUPPORT.md +0 -279
  76. package/docs/CONFIGURATION.md +0 -997
  77. package/docs/DOCUMENTATION_INDEX.md +0 -319
  78. package/docs/EVENTS.md +0 -798
  79. package/docs/PROXY.md +0 -228
  80. package/docs/THEMING.md +0 -681
  81. package/docs/TROUBLESHOOTING.md +0 -793
@@ -0,0 +1,328 @@
1
+ # Installation
2
+
3
+ The LiquidCommerce Elements SDK can be integrated into your website using either a CDN script tag or as an NPM package.
4
+
5
+ ## Browser Requirements
6
+
7
+ The SDK requires:
8
+ - Modern browser with Web Components support (Chrome 66+, Firefox 60+, Safari 12+, Edge 79+)
9
+ - Shadow DOM support
10
+ - JavaScript enabled
11
+
12
+ For older browsers, you'll need to include Web Components and Shadow DOM polyfills.
13
+
14
+ ## CDN Installation (Recommended)
15
+
16
+ The simplest way to get started is by adding the SDK script tag to your HTML.
17
+
18
+ ### Basic Setup
19
+
20
+ Add the following script tag to your page's `<head>` section:
21
+
22
+ ```html
23
+ <script
24
+ defer
25
+ data-liquid-commerce-elements
26
+ data-token="YOUR_API_KEY"
27
+ data-env="production"
28
+ type="text/javascript"
29
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
30
+ ></script>
31
+ ```
32
+
33
+ ### Script Attributes
34
+
35
+ | Attribute | Required | Description |
36
+ |-----------|----------|-------------|
37
+ | `data-liquid-commerce-elements` | Yes | Identifies this as the Elements SDK script |
38
+ | `data-token` | Yes | Your LiquidCommerce API key |
39
+ | `data-env` | Yes | Environment: `development`, `staging`, or `production` |
40
+ | `defer` | Recommended | Allows non-blocking script loading |
41
+
42
+ ### Where to Place the Script
43
+
44
+ While the `<head>` section is recommended, the script can be placed anywhere on your page:
45
+
46
+ ```html
47
+ <!DOCTYPE html>
48
+ <html>
49
+ <head>
50
+ <title>My Store</title>
51
+ <!-- SDK script in head (recommended) -->
52
+ <script
53
+ defer
54
+ data-liquid-commerce-elements
55
+ data-token="YOUR_API_KEY"
56
+ data-env="production"
57
+ type="text/javascript"
58
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
59
+ ></script>
60
+ </head>
61
+ <body>
62
+ <!-- Your content -->
63
+ </body>
64
+ </html>
65
+ ```
66
+
67
+ The `defer` attribute ensures the script loads asynchronously without blocking page content, keeping your site fast regardless of placement.
68
+
69
+ ### Checkout-Only Build
70
+
71
+ If you only need checkout functionality (without product displays or cart), use the lighter checkout-only build:
72
+
73
+ ```html
74
+ <script
75
+ defer
76
+ data-liquid-commerce-elements-checkout
77
+ data-token="YOUR_API_KEY"
78
+ data-env="production"
79
+ type="text/javascript"
80
+ src="https://assets-elements.liquidcommerce.us/checkout/elements.js"
81
+ ></script>
82
+ ```
83
+
84
+ This build is tree-shaken and significantly smaller, ideal for dedicated checkout pages.
85
+
86
+ ## NPM Installation
87
+
88
+ For JavaScript/TypeScript projects using a bundler (Webpack, Rollup, Vite, etc.), install via NPM:
89
+
90
+ ```bash
91
+ npm install @liquidcommerce/elements-sdk
92
+ ```
93
+
94
+ ### Basic Usage
95
+
96
+ ```javascript
97
+ import { Elements } from '@liquidcommerce/elements-sdk';
98
+
99
+ // Initialize the client
100
+ const client = await Elements('YOUR_API_KEY', {
101
+ env: 'production'
102
+ });
103
+
104
+ // Client is ready to use
105
+ console.log('Elements SDK initialized');
106
+ ```
107
+
108
+ ### Checkout-Only Import
109
+
110
+ For tree-shaking benefits in checkout-only scenarios:
111
+
112
+ ```javascript
113
+ import { ElementsCheckout } from '@liquidcommerce/elements-sdk/checkout';
114
+
115
+ const client = await ElementsCheckout('YOUR_API_KEY', {
116
+ env: 'production'
117
+ });
118
+ ```
119
+
120
+ ### TypeScript Support
121
+
122
+ The SDK includes full TypeScript definitions. Import types as needed:
123
+
124
+ ```typescript
125
+ import { Elements } from '@liquidcommerce/elements-sdk';
126
+ import type {
127
+ ILiquidCommerceElementsClient,
128
+ ILiquidCommerceElementsConfig,
129
+ IInjectProductElement
130
+ } from '@liquidcommerce/elements-sdk';
131
+
132
+ const config: ILiquidCommerceElementsConfig = {
133
+ env: 'production',
134
+ customTheme: {
135
+ global: {
136
+ theme: {
137
+ primaryColor: '#007bff'
138
+ }
139
+ }
140
+ }
141
+ };
142
+
143
+ const client: ILiquidCommerceElementsClient = await Elements('YOUR_API_KEY', config);
144
+ ```
145
+
146
+ ## Framework Integration
147
+
148
+ ### React
149
+
150
+ ```jsx
151
+ import { Elements } from '@liquidcommerce/elements-sdk';
152
+ import { useEffect, useState } from 'react';
153
+
154
+ function App() {
155
+ const [elementsClient, setElementsClient] = useState(null);
156
+
157
+ useEffect(() => {
158
+ async function initElements() {
159
+ const client = await Elements('YOUR_API_KEY', {
160
+ env: 'production'
161
+ });
162
+ setElementsClient(client);
163
+ }
164
+
165
+ initElements();
166
+ }, []);
167
+
168
+ useEffect(() => {
169
+ if (elementsClient) {
170
+ elementsClient.injectProductElement([
171
+ { containerId: 'product-1', identifier: '00619947000020' }
172
+ ]);
173
+ }
174
+ }, [elementsClient]);
175
+
176
+ return (
177
+ <div>
178
+ <div id="product-1"></div>
179
+ </div>
180
+ );
181
+ }
182
+ ```
183
+
184
+ ### Vue
185
+
186
+ ```vue
187
+ <template>
188
+ <div id="product-1"></div>
189
+ </template>
190
+
191
+ <script>
192
+ import { Elements } from '@liquidcommerce/elements-sdk';
193
+
194
+ export default {
195
+ async mounted() {
196
+ const client = await Elements('YOUR_API_KEY', {
197
+ env: 'production'
198
+ });
199
+
200
+ await client.injectProductElement([
201
+ { containerId: 'product-1', identifier: '00619947000020' }
202
+ ]);
203
+ }
204
+ }
205
+ </script>
206
+ ```
207
+
208
+ ### Next.js
209
+
210
+ In Next.js, initialize the SDK in a client component:
211
+
212
+ ```jsx
213
+ 'use client';
214
+
215
+ import { Elements } from '@liquidcommerce/elements-sdk';
216
+ import { useEffect } from 'react';
217
+
218
+ export default function ProductPage() {
219
+ useEffect(() => {
220
+ async function init() {
221
+ const client = await Elements('YOUR_API_KEY', {
222
+ env: 'production',
223
+ proxy: {
224
+ baseUrl: '/api/elements-proxy'
225
+ }
226
+ });
227
+
228
+ await client.injectProductElement([
229
+ { containerId: 'product', identifier: '00619947000020' }
230
+ ]);
231
+ }
232
+
233
+ init();
234
+ }, []);
235
+
236
+ return <div id="product"></div>;
237
+ }
238
+ ```
239
+
240
+ > **Note:** When using Next.js or other frameworks with server-side rendering, the SDK must be initialized on the client side only. The SDK requires browser APIs (Window, Document, Web Components) and cannot run server-side.
241
+
242
+ ## Configuration Options
243
+
244
+ The SDK accepts a configuration object during initialization:
245
+
246
+ ```javascript
247
+ const client = await Elements('YOUR_API_KEY', {
248
+ env: 'production', // Required: 'development' | 'staging' | 'production'
249
+ debugMode: 'console', // Optional: 'none' | 'console' | 'panel'
250
+ customTheme: { /* ... */ }, // Optional: Theme customization
251
+ promoTicker: [ /* ... */ ], // Optional: Promo ticker configuration
252
+ proxy: { /* ... */ }, // Optional: Proxy configuration
253
+ checkout: { /* ... */ }, // Optional: Checkout configuration
254
+ development: { /* ... */ } // Optional: Development/testing options
255
+ });
256
+ ```
257
+
258
+ See [Configuration Reference](../api/configuration.md) for complete configuration options.
259
+
260
+ ## Verification
261
+
262
+ After installation, verify the SDK is loaded correctly:
263
+
264
+ ### CDN Verification
265
+
266
+ Open your browser's console and check for:
267
+
268
+ ```javascript
269
+ // The client is available globally
270
+ console.log(window.elements);
271
+ // Should output: { injectProductElement: ƒ, ui: {...}, actions: {...}, ... }
272
+ ```
273
+
274
+ ### NPM Verification
275
+
276
+ ```javascript
277
+ const client = await Elements('YOUR_API_KEY', { env: 'production' });
278
+ console.log(client); // Should output the client object
279
+ ```
280
+
281
+ ## Troubleshooting Installation
282
+
283
+ ### Script Not Loading
284
+
285
+ If the SDK script fails to load:
286
+
287
+ 1. **Check the network tab** in browser DevTools for 404 or CORS errors
288
+ 2. **Verify the script URL** is correct and accessible
289
+ 3. **Check ad blockers** - they may block scripts with "commerce" in the name (see [Proxy Setup](../integration/proxy-setup.md))
290
+
291
+ ### Web Components Not Supported
292
+
293
+ If you see an error about Web Components:
294
+
295
+ ```
296
+ [LiquidCommerce Elements] SDK requires support for Web Components
297
+ ```
298
+
299
+ Include a Web Components polyfill before the SDK script:
300
+
301
+ ```html
302
+ <script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-bundle.js"></script>
303
+ <script defer data-liquid-commerce-elements ...></script>
304
+ ```
305
+
306
+ ### TypeScript Errors
307
+
308
+ If you encounter TypeScript errors:
309
+
310
+ 1. Ensure TypeScript version is 4.5 or higher
311
+ 2. Check that `@liquidcommerce/elements-sdk` is in your `dependencies` (not `devDependencies`)
312
+ 3. Verify your `tsconfig.json` includes:
313
+
314
+ ```json
315
+ {
316
+ "compilerOptions": {
317
+ "moduleResolution": "node",
318
+ "esModuleInterop": true
319
+ }
320
+ }
321
+ ```
322
+
323
+ ## Next Steps
324
+
325
+ - **Quick Start**: [Build your first product page in 5 minutes](./quick-start.md)
326
+ - **Core Concepts**: [Understand how the SDK works](./concepts.md)
327
+ - **Component Guides**: [Product](../guides/product-component.md), [Cart](../guides/cart-component.md), [Checkout](../guides/checkout-component.md)
328
+ - **API Reference**: [Full API documentation](../api/client.md)