@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,405 @@
1
+ # Quick Start
2
+
3
+ Get a product display with add-to-cart functionality working on your page in under 5 minutes.
4
+
5
+ ## What You'll Build
6
+
7
+ A fully functional product page with:
8
+ - Product images and details
9
+ - Size selection
10
+ - Fulfillment options (shipping/on-demand delivery)
11
+ - Add to cart button
12
+ - Shopping cart drawer
13
+ - Complete checkout flow
14
+
15
+ ## Prerequisites
16
+
17
+ - A LiquidCommerce API key (contact your LiquidCommerce representative)
18
+ - A product identifier
19
+ - A web page or HTML file
20
+
21
+ ## Step 1: Add the SDK Script
22
+
23
+ Add the Elements SDK script tag to your HTML `<head>`:
24
+
25
+ ```html
26
+ <!DOCTYPE html>
27
+ <html>
28
+ <head>
29
+ <title>My Product Page</title>
30
+ <script
31
+ defer
32
+ data-liquid-commerce-elements
33
+ data-token="YOUR_API_KEY"
34
+ data-env="production"
35
+ type="text/javascript"
36
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
37
+ ></script>
38
+ </head>
39
+ <body>
40
+ <!-- We'll add the product here -->
41
+ </body>
42
+ </html>
43
+ ```
44
+
45
+ **Replace `YOUR_API_KEY`** with your actual API key.
46
+
47
+ ## Step 2: Add a Product Container
48
+
49
+ Create a container where the product will be displayed:
50
+
51
+ ```html
52
+ <body>
53
+ <h1>Our Premium Whiskey</h1>
54
+
55
+ <!-- Product will be injected here -->
56
+ <div id="product-display"></div>
57
+ </body>
58
+ ```
59
+
60
+ ## Step 3: Configure the Product (Declarative)
61
+
62
+ Add product configuration using HTML data attributes on the script tag:
63
+
64
+ ```html
65
+ <script
66
+ defer
67
+ data-liquid-commerce-elements
68
+ data-token="YOUR_API_KEY"
69
+ data-env="production"
70
+ data-container-1="product-display"
71
+ data-product-1="00619947000020"
72
+ type="text/javascript"
73
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
74
+ ></script>
75
+ ```
76
+
77
+ **New attributes:**
78
+ - `data-container-1="product-display"` - Points to the container ID
79
+ - `data-product-1="00619947000020"` - The product identifier
80
+
81
+ The numbers (1) connect the container to its product. For multiple products, increment the number:
82
+ - `data-container-2` with `data-product-2`
83
+ - `data-container-3` with `data-product-3`
84
+ - etc.
85
+
86
+ ## Complete Example
87
+
88
+ Here's the complete HTML for a working product page:
89
+
90
+ ```html
91
+ <!DOCTYPE html>
92
+ <html lang="en">
93
+ <head>
94
+ <meta charset="UTF-8">
95
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
96
+ <title>Premium Whiskey - Buy Online</title>
97
+
98
+ <script
99
+ defer
100
+ data-liquid-commerce-elements
101
+ data-token="YOUR_API_KEY"
102
+ data-env="production"
103
+ data-container-1="product-display"
104
+ data-product-1="00619947000020"
105
+ type="text/javascript"
106
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
107
+ ></script>
108
+
109
+ <style>
110
+ body {
111
+ font-family: Arial, sans-serif;
112
+ max-width: 1200px;
113
+ margin: 0 auto;
114
+ padding: 20px;
115
+ }
116
+ h1 {
117
+ text-align: center;
118
+ }
119
+ </style>
120
+ </head>
121
+ <body>
122
+ <h1>Our Premium Whiskey</h1>
123
+ <div id="product-display"></div>
124
+ </body>
125
+ </html>
126
+ ```
127
+
128
+ That's it! Save the file and open it in a browser. You should see:
129
+ 1. Product images in a carousel
130
+ 2. Product name and description
131
+ 3. Size selector
132
+ 4. Fulfillment type selector (shipping/delivery)
133
+ 5. Retailer selection
134
+ 6. Add to cart button
135
+
136
+ When you click "Add to Cart," a cart drawer slides in from the right with checkout functionality.
137
+
138
+ ## Alternative: Programmatic Setup
139
+
140
+ If you prefer JavaScript over HTML attributes:
141
+
142
+ ```html
143
+ <!DOCTYPE html>
144
+ <html>
145
+ <head>
146
+ <title>My Product Page</title>
147
+ <script
148
+ defer
149
+ data-liquid-commerce-elements
150
+ data-token="YOUR_API_KEY"
151
+ data-env="production"
152
+ type="text/javascript"
153
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
154
+ ></script>
155
+
156
+ <script defer>
157
+ // Wait for SDK to be ready
158
+ window.addEventListener('lce:actions.client_ready', async (event) => {
159
+ const client = window.elements;
160
+
161
+ // Inject the product
162
+ await client.injectProductElement([
163
+ {
164
+ containerId: 'product-display',
165
+ identifier: '00619947000020'
166
+ }
167
+ ]);
168
+ });
169
+ </script>
170
+ </head>
171
+ <body>
172
+ <h1>Our Premium Whiskey</h1>
173
+ <div id="product-display"></div>
174
+ </body>
175
+ </html>
176
+ ```
177
+
178
+ Or with NPM:
179
+
180
+ ```javascript
181
+ import { Elements } from '@liquidcommerce/elements-sdk';
182
+
183
+ async function initProduct() {
184
+ const client = await Elements('YOUR_API_KEY', {
185
+ env: 'production'
186
+ });
187
+
188
+ await client.injectProductElement([
189
+ {
190
+ containerId: 'product-display',
191
+ identifier: '00619947000020'
192
+ }
193
+ ]);
194
+ }
195
+
196
+ initProduct();
197
+ ```
198
+
199
+ ## Multiple Products
200
+
201
+ To display multiple products on one page:
202
+
203
+ ```html
204
+ <script
205
+ defer
206
+ data-liquid-commerce-elements
207
+
208
+ data-token="YOUR_API_KEY"
209
+ data-env="production"
210
+
211
+ data-container-1="product-1"
212
+ data-product-1="00619947000020"
213
+ data-container-2="product-2"
214
+ data-product-2="08504405135"
215
+ data-container-3="product-3"
216
+ data-product-3="08068660001"
217
+
218
+ type="text/javascript"
219
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
220
+ ></script>
221
+
222
+ <div id="product-1"></div>
223
+ <div id="product-2"></div>
224
+ <div id="product-3"></div>
225
+ ```
226
+
227
+ Or programmatically:
228
+
229
+ ```javascript
230
+ await client.injectProductElement([
231
+ { containerId: 'product-1', identifier: '00619947000020' },
232
+ { containerId: 'product-2', identifier: '08504405135' },
233
+ { containerId: 'product-3', identifier: '08068660001' }
234
+ ]);
235
+ ```
236
+
237
+ ## What Happens Automatically
238
+
239
+ The SDK handles everything for you:
240
+
241
+ 1. **Address Collection** - If needed, prompts for delivery location
242
+ 2. **Availability Check** - Shows only available fulfillment options
243
+ 3. **Cart Management** - Maintains cart across page refreshes and tabs
244
+ 4. **Checkout Flow** - Complete payment and order processing
245
+ 5. **Error Handling** - Graceful error messages and recovery
246
+ 6. **Mobile Responsiveness** - Works on all screen sizes
247
+
248
+ ## Customization
249
+
250
+ Want to customize the look, visit the Elements Builder in our [Partner Portal](https://app.liquidcommerce.co/)? Want to manually override your theme, you can pass a `customTheme: IClientCustomThemeConfig` configuration:
251
+
252
+ ```html
253
+ <script>
254
+ window.addEventListener('lce:actions.client_ready', async () => {
255
+ const client = window.elements;
256
+
257
+ // You can customize after initialization
258
+ // See Theming Guide for more options
259
+ });
260
+ </script>
261
+ ```
262
+
263
+ Or with NPM:
264
+
265
+ ```javascript
266
+ const client = await Elements('YOUR_API_KEY', {
267
+ env: 'production',
268
+ customTheme: {
269
+ global: {
270
+ theme: {
271
+ primaryColor: '#007bff',
272
+ buttonCornerRadius: '8px',
273
+ headingFont: {
274
+ name: 'Poppins',
275
+ weights: [400, 600]
276
+ }
277
+ }
278
+ }
279
+ }
280
+ });
281
+ ```
282
+
283
+ ## Testing Different Products
284
+
285
+ To test with different products, simply change the product identifier:
286
+
287
+ ```html
288
+ <!-- Replace with your product UPC -->
289
+ data-product-1="YOUR_PRODUCT_IDENTIFIER"
290
+ ```
291
+
292
+ Contact your LiquidCommerce representative for available product identifiers.
293
+
294
+ ## Troubleshooting
295
+
296
+ ### Product Not Showing
297
+
298
+ 1. **Check the browser console** for errors
299
+ 2. **Verify your API key** is correct
300
+ 3. **Confirm the product identifier** exists in your catalog
301
+ 4. **Check the container ID** matches your HTML
302
+
303
+ ### Styling Issues
304
+
305
+ The product uses Shadow DOM for style encapsulation. To customize:
306
+
307
+ - Use the `customTheme` configuration option
308
+ - See [Theming Guide](../guides/theming.md) for detailed customization
309
+
310
+ ### Cart Not Opening
311
+
312
+ The cart should open automatically after adding a product. If it doesn't:
313
+
314
+ 1. Check browser console for JavaScript errors
315
+ 2. Verify no other scripts are conflicting
316
+ 3. Try manually opening: `window.elements.actions.cart.openCart()`
317
+
318
+ ## Next Steps
319
+
320
+ Now that you have a basic product working:
321
+
322
+ - **[Core Concepts](./concepts.md)** - Understand how the SDK works
323
+ - **[Product Component Guide](../guides/product-component.md)** - Deep dive into product features
324
+ - **[Cart Component Guide](../guides/cart-component.md)** - Learn about cart functionality
325
+ - **[Checkout Component Guide](../guides/checkout-component.md)** - Customize the checkout experience
326
+ - **[Theming Guide](../guides/theming.md)** - Make it match your brand
327
+ - **[Events](../guides/events.md)** - React to user actions
328
+ - **[API Reference](../api/client.md)** - Explore all available methods
329
+
330
+ ## Complete Working Example
331
+
332
+ Try this complete example with your API key:
333
+
334
+ ```html
335
+ <!DOCTYPE html>
336
+ <html lang="en">
337
+ <head>
338
+ <meta charset="UTF-8">
339
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
340
+ <title>Whiskey Shop</title>
341
+
342
+ <script
343
+ defer
344
+ data-liquid-commerce-elements
345
+ data-token="YOUR_API_KEY"
346
+ data-env="production"
347
+ data-container-1="product"
348
+ data-product-1="00619947000020"
349
+ type="text/javascript"
350
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
351
+ ></script>
352
+
353
+ <style>
354
+ * {
355
+ margin: 0;
356
+ padding: 0;
357
+ box-sizing: border-box;
358
+ }
359
+
360
+ body {
361
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
362
+ background: #f5f5f5;
363
+ }
364
+
365
+ header {
366
+ background: white;
367
+ padding: 20px;
368
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
369
+ margin-bottom: 40px;
370
+ }
371
+
372
+ .container {
373
+ max-width: 1200px;
374
+ margin: 0 auto;
375
+ padding: 0 20px;
376
+ }
377
+
378
+ h1 {
379
+ text-align: center;
380
+ color: #333;
381
+ }
382
+
383
+ #product {
384
+ background: white;
385
+ border-radius: 8px;
386
+ padding: 20px;
387
+ box-shadow: 0 2px 8px rgba(0,0,0,0.1);
388
+ }
389
+ </style>
390
+ </head>
391
+ <body>
392
+ <header>
393
+ <div class="container">
394
+ <h1>🥃 Premium Spirits Collection</h1>
395
+ </div>
396
+ </header>
397
+
398
+ <div class="container">
399
+ <div id="product"></div>
400
+ </div>
401
+ </body>
402
+ </html>
403
+ ```
404
+
405
+ Replace `YOUR_API_KEY` with your actual key and you're ready to go!