@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,210 @@
1
+ # Elements SDK v1 Documentation
2
+
3
+ Welcome to the comprehensive documentation for the LiquidCommerce Elements SDK v1.
4
+
5
+ ## What is Elements SDK?
6
+
7
+ The Elements SDK is a Web Components-based e-commerce SDK that allows you to add product displays, shopping carts, and checkout flows to any website with minimal code.
8
+
9
+ ## Quick Links
10
+
11
+ - **[Installation](./getting-started/installation.md)** - Get started in minutes
12
+ - **[Quick Start](./getting-started/quick-start.md)** - Build your first product page
13
+ - **[API Reference](./api/client.md)** - Complete API documentation
14
+
15
+ ## Documentation Sections
16
+
17
+ ### Getting Started
18
+
19
+ Essential guides for new users:
20
+
21
+ - **[Installation](./getting-started/installation.md)** - CDN, NPM, and framework integration
22
+ - **[Quick Start](./getting-started/quick-start.md)** - Your first product page in 5 minutes
23
+ - **[Core Concepts](./getting-started/concepts.md)** - Understand how the SDK works
24
+
25
+ ### Component Guides
26
+
27
+ In-depth guides for each major component:
28
+
29
+ - **[Product Component](./guides/product-component.md)** - Display products with add-to-cart functionality
30
+ - **[Cart Component](./guides/cart-component.md)** - Shopping cart and item management
31
+ - **[Checkout Component](./guides/checkout-component.md)** - Complete purchase flow
32
+ - **[Address Component](./guides/address-component.md)** - Delivery location management
33
+ - **[Product List Component](./guides/product-list-component.md)** - Filterable product catalogs
34
+ - **[Theming](./guides/theming.md)** - Customize appearance and branding
35
+ - **[Events](./guides/events.md)** - Event system and subscriptions
36
+ - **[Best Practices](./guides/best-practices.md)** - Patterns, tips, and recommendations
37
+
38
+ ### API Reference
39
+
40
+ Complete API documentation:
41
+
42
+ **Core API:**
43
+ - **[Client API](./api/client.md)** - Main SDK client interface
44
+ - **[Injection Methods](./api/injection-methods.md)** - Component injection
45
+ - **[UI Helpers](./api/ui-helpers.md)** - Cart buttons and UI elements
46
+ - **[Configuration](./api/configuration.md)** - All configuration options
47
+ - **[TypeScript Types](./api/typescript-types.md)** - Type definitions
48
+
49
+ **Actions API:**
50
+ - **[Product Actions](./api/actions/product-actions.md)** - `actions.product.*`
51
+ - **[Address Actions](./api/actions/address-actions.md)** - `actions.address.*`
52
+ - **[Cart Actions](./api/actions/cart-actions.md)** - `actions.cart.*`
53
+ - **[Checkout Actions](./api/actions/checkout-actions.md)** - `actions.checkout.*`
54
+
55
+ ### Architecture (To Be Done In Future Versions)
56
+
57
+ Deep dive into SDK internals:
58
+
59
+ - **[Overview](./architecture/overview.md)** - System architecture
60
+ - **[Initialization](./architecture/initialization.md)** - Phased initialization process
61
+ - **[State Management](./architecture/state-management.md)** - Store service and persistence
62
+ - **[Event System](./architecture/event-system.md)** - PubSub architecture
63
+ - **[Web Components](./architecture/web-components.md)** - Component factory and Shadow DOM
64
+ - **[Build System](./architecture/build-system.md)** - Bundles and tree-shaking
65
+
66
+ ### Framework Integration
67
+
68
+ Integration guides for popular frameworks:
69
+
70
+ - **[React](./integration/react.md)** - React integration patterns and hooks
71
+ - **[Next.js](./integration/nextjs.md)** - Next.js setup with SSR considerations
72
+ - **[Vue](./integration/vue.md)** - Vue component integration
73
+ - **[Angular](./integration/angular.md)** - Angular client-only setup
74
+ - **[Laravel](./integration/laravel.md)** - Blade + CDN integration
75
+ - **[Vanilla JavaScript](./integration/vanilla-js.md)** - Pure JavaScript integration
76
+ - **[Proxy Setup](./integration/proxy-setup.md)** - Ad blocker avoidance
77
+
78
+ ### Reference
79
+
80
+ Technical reference and troubleshooting:
81
+
82
+ - **[Browser Support](./reference/browser-support.md)** - Compatibility matrix
83
+ - **[Troubleshooting](./reference/troubleshooting.md)** - Common issues and solutions
84
+ - **[Error Handling](./reference/error-handling.md)** - Error types and debugging
85
+ - **[Performance](./reference/performance.md)** - Optimization tips and best practices
86
+
87
+ ### Examples
88
+
89
+ Practical examples with working code:
90
+
91
+ - **[Simple Product Page](./examples/simple-product-page.md)** - Basic PDP implementation
92
+ - **[Multi-Product Page](./examples/multi-product-page.md)** - Multiple products on one page
93
+ - **[Complete Checkout Flow](./examples/checkout-flow.md)** - Full e-commerce flow
94
+ - **[Custom Theming](./examples/custom-theming.md)** - Brand customization examples
95
+ - **[Advanced Patterns](./examples/advanced-patterns.md)** - Complex integration scenarios
96
+
97
+ ## Common Tasks
98
+
99
+ ### Adding a Product
100
+
101
+ **Declarative (HTML):**
102
+ ```html
103
+ <script
104
+ defer
105
+ data-liquid-commerce-elements
106
+ data-token="YOUR_API_KEY"
107
+ data-env="production"
108
+ data-container-1="product"
109
+ data-product-1="00619947000020"
110
+ type="text/javascript"
111
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
112
+ ></script>
113
+
114
+ <div id="product"></div>
115
+ ```
116
+
117
+ **Programmatic (JavaScript):**
118
+ ```javascript
119
+ const client = await Elements('YOUR_API_KEY', { env: 'production' });
120
+ await client.injectProductElement([
121
+ { containerId: 'product', identifier: '00619947000020' }
122
+ ]);
123
+ ```
124
+
125
+ ### Opening the Cart
126
+
127
+ ```javascript
128
+ window.elements.actions.cart.openCart();
129
+ ```
130
+
131
+ ### Adding to Cart Programmatically
132
+
133
+ ```javascript
134
+ await window.elements.actions.cart.addProduct([
135
+ {
136
+ identifier: '00619947000020',
137
+ fulfillmentType: 'shipping',
138
+ quantity: 1
139
+ }
140
+ ], true); // true = open cart after adding
141
+ ```
142
+
143
+ ### Listening for Events
144
+
145
+ ```javascript
146
+ window.addEventListener('lce:actions.cart_item_added', (event) => {
147
+ console.log('Item added to cart:', event.detail.data);
148
+ });
149
+ ```
150
+
151
+ ### Customizing Theme
152
+
153
+ ```javascript
154
+ const client = await Elements('YOUR_API_KEY', {
155
+ env: 'production',
156
+ customTheme: {
157
+ global: {
158
+ theme: {
159
+ primaryColor: '#007bff',
160
+ buttonCornerRadius: '8px'
161
+ }
162
+ }
163
+ }
164
+ });
165
+ ```
166
+
167
+ ## Key Concepts
168
+
169
+ ### Web Components
170
+ The SDK uses native Web Components for framework-agnostic integration and style encapsulation.
171
+
172
+ ### Shadow DOM
173
+ Components use Shadow DOM to prevent CSS conflicts and ensure consistent styling.
174
+
175
+ ### Auto-Initialization
176
+ When using the CDN, the SDK automatically initializes based on HTML data attributes.
177
+
178
+ ### Event-Driven
179
+ The SDK publishes events for all user interactions, allowing you to react to changes.
180
+
181
+ ### State Persistence
182
+ Cart and address data persist across sessions using localStorage with API fallback.
183
+
184
+ ## Browser Requirements
185
+
186
+ - Chrome 66+ (March 2018)
187
+ - Firefox 60+ (May 2018)
188
+ - Safari 12+ (September 2018)
189
+ - Edge 79+ (January 2020)
190
+
191
+ Requires Web Components and Shadow DOM support.
192
+
193
+ ## Support
194
+
195
+ For assistance, contact your LiquidCommerce representative.
196
+
197
+ ## Version History
198
+
199
+ This is the v1 documentation. Future versions will be documented in separate directories (`v2/`, `v3/`, etc.).
200
+
201
+ ## Contributing
202
+
203
+ Found an issue in the documentation? Contact your LiquidCommerce representative with suggestions.
204
+
205
+ ---
206
+
207
+ ## Navigation
208
+
209
+ - [← Back to Repository](../)
210
+ - [Getting Started →](./getting-started/installation.md)
@@ -0,0 +1,281 @@
1
+ # Address Actions API
2
+
3
+ Address actions allow you to programmatically manage the delivery location.
4
+
5
+ ## actions.address.setAddressByPlacesId()
6
+
7
+ Set address using a Google Places ID.
8
+
9
+ ### Signature
10
+
11
+ ```typescript
12
+ setAddressByPlacesId(placesId: string): Promise<void>
13
+ ```
14
+
15
+ ### Parameters
16
+
17
+ | Parameter | Type | Required | Description |
18
+ |-----------|------|----------|-------------|
19
+ | `placesId` | string | Yes | Google Places ID |
20
+
21
+ ### Example
22
+
23
+ ```javascript
24
+ await window.elements.actions.address.setAddressByPlacesId(
25
+ 'ChIJOwg_06VPwokRYv534QaPC8g'
26
+ );
27
+ ```
28
+
29
+ ### How to Get Places ID
30
+
31
+ Visit [Google Place IDs](https://developers.google.com/maps/documentation/places/web-service/place-id#find-id) for details on obtaining a Places ID.
32
+
33
+ ---
34
+
35
+ ## actions.address.setAddressManually()
36
+
37
+ Set address manually without Google Places.
38
+
39
+ ### Signature
40
+
41
+ ```typescript
42
+ setAddressManually(
43
+ address: IAddressAddress,
44
+ coordinates: IAddressCoordinates
45
+ ): Promise<void>
46
+ ```
47
+
48
+ ### Parameters
49
+
50
+ ```typescript
51
+ interface IAddressAddress {
52
+ one: string; // Street address
53
+ two?: string; // Apt, suite, etc. (optional)
54
+ city: string; // City name
55
+ state: string; // Two-letter state code
56
+ zip: string; // ZIP/postal code
57
+ }
58
+
59
+ interface IAddressCoordinates {
60
+ latitude: number; // -90 to 90
61
+ longitude: number; // -180 to 180
62
+ }
63
+ ```
64
+
65
+ ### Example
66
+
67
+ ```javascript
68
+ await window.elements.actions.address.setAddressManually(
69
+ {
70
+ one: '123 Main Street',
71
+ two: 'Apt 4',
72
+ city: 'New York',
73
+ state: 'NY',
74
+ zip: '10001'
75
+ },
76
+ {
77
+ latitude: 40.7128,
78
+ longitude: -74.0060
79
+ }
80
+ );
81
+ ```
82
+
83
+ ### Validation
84
+
85
+ The SDK validates:
86
+ - All required fields are present
87
+ - State is 2-letter code
88
+ - Latitude is between -90 and 90
89
+ - Longitude is between -180 and 180
90
+
91
+ ### Errors
92
+
93
+ **Throws `SDKError` if:**
94
+ - Required fields are missing
95
+ - Coordinates are out of range
96
+ - Address format is invalid
97
+
98
+ ---
99
+
100
+ ## actions.address.clear()
101
+
102
+ Remove the current address.
103
+
104
+ ### Signature
105
+
106
+ ```typescript
107
+ clear(): Promise<void>
108
+ ```
109
+
110
+ ### Example
111
+
112
+ ```javascript
113
+ await window.elements.actions.address.clear();
114
+ ```
115
+
116
+ ### Effects
117
+
118
+ - Clears stored address
119
+ - Products will prompt for address on next add-to-cart
120
+ - Cart/checkout require re-entering address
121
+
122
+ ---
123
+
124
+ ## actions.address.getDetails()
125
+
126
+ Retrieve the current address.
127
+
128
+ ### Signature
129
+
130
+ ```typescript
131
+ getDetails(): IAddressData | null
132
+ ```
133
+
134
+ ### Returns
135
+
136
+ ```typescript
137
+ interface IAddressData {
138
+ id: string; // Google Places ID or generated ID
139
+ address: {
140
+ one: string;
141
+ two?: string;
142
+ city: string;
143
+ state: string;
144
+ zip: string;
145
+ };
146
+ coordinates: {
147
+ latitude: number;
148
+ longitude: number;
149
+ };
150
+ formattedAddress: string;
151
+ }
152
+ ```
153
+
154
+ Returns `null` if no address is set.
155
+
156
+ ### Example
157
+
158
+ ```javascript
159
+ const address = window.elements.actions.address.getDetails();
160
+
161
+ if (address) {
162
+ console.log('Current address:', address.formattedAddress);
163
+ console.log('Coordinates:', address.coordinates);
164
+ } else {
165
+ console.log('No address set');
166
+ }
167
+ ```
168
+
169
+ ### Use Cases
170
+
171
+ #### Check if Address is Set
172
+
173
+ ```javascript
174
+ if (!window.elements.actions.address.getDetails()) {
175
+ // Prompt user to set address
176
+ showAddressPrompt();
177
+ }
178
+ ```
179
+
180
+ #### Display Current Address
181
+
182
+ ```javascript
183
+ const address = window.elements.actions.address.getDetails();
184
+
185
+ if (address) {
186
+ document.getElementById('current-address').textContent =
187
+ address.formattedAddress;
188
+ }
189
+ ```
190
+ ## Events
191
+
192
+ Address actions trigger events:
193
+
194
+ ```javascript
195
+ // Address updated
196
+ window.addEventListener('lce:actions.address_updated', (event) => {
197
+ const { address, coordinates, formattedAddress } = event.detail.data;
198
+ console.log('Address set:', formattedAddress);
199
+ });
200
+
201
+ // Address cleared
202
+ window.addEventListener('lce:actions.address_cleared', () => {
203
+ console.log('Address cleared');
204
+ });
205
+
206
+ // Address failed
207
+ window.addEventListener('lce:actions.address_failed', (event) => {
208
+ console.error('Address error:', event.detail.data.error);
209
+ });
210
+ ```
211
+
212
+ ## Best Practices
213
+
214
+ ### Use Places ID When Available
215
+
216
+ Google Places provides accurate geocoding:
217
+
218
+ ```javascript
219
+ // Good - accurate and validated
220
+ await window.elements.actions.address.setAddressByPlacesId(placesId);
221
+
222
+ // Less ideal - requires manual geocoding
223
+ await window.elements.actions.address.setAddressManually(address, coords);
224
+ ```
225
+
226
+ ### Validate Manual Addresses
227
+
228
+ When using manual address entry:
229
+
230
+ ```javascript
231
+ async function setManualAddress(address, coords) {
232
+ // Validate format
233
+ if (!address.one || !address.city || !address.state || !address.zip) {
234
+ throw new Error('Missing required fields');
235
+ }
236
+
237
+ // Validate state
238
+ if (!/^[A-Z]{2}$/.test(address.state)) {
239
+ throw new Error('State must be 2-letter code');
240
+ }
241
+
242
+ // Validate ZIP
243
+ if (!/^\d{5}(-\d{4})?$/.test(address.zip)) {
244
+ throw new Error('Invalid ZIP code');
245
+ }
246
+
247
+ await window.elements.actions.address.setAddressManually(address, coords);
248
+ }
249
+ ```
250
+
251
+ ### Handle Errors
252
+
253
+ ```javascript
254
+ try {
255
+ await window.elements.actions.address.setAddressByPlacesId(placesId);
256
+ showSuccess('Address saved!');
257
+ } catch (error) {
258
+ console.error('Failed to set address:', error);
259
+ showError('Unable to set that address. Please try again.');
260
+ }
261
+ ```
262
+
263
+ ### Set Address Early
264
+
265
+ Set address as soon as possible in user flow:
266
+
267
+ ```javascript
268
+ window.addEventListener('lce:actions.client_ready', () => {
269
+ if (!window.elements.actions.address.getDetails()) {
270
+ // Prompt for address on first visit
271
+ showAddressModal();
272
+ }
273
+ });
274
+ ```
275
+
276
+ ## See Also
277
+
278
+ - [Address Component Guide](../../guides/address-component.md)
279
+ - [Address Events](../../guides/events.md#address-events)
280
+ - [Product Component](../../guides/product-component.md#address-requirement)
281
+ - [Cart Component](../../guides/cart-component.md#address-requirement)