@liquidcommerce/elements-sdk 2.1.0-beta.49

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 (201) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +1183 -0
  3. package/dist/index.esm.js +16834 -0
  4. package/dist/types/auto-initialize.d.ts +2 -0
  5. package/dist/types/constants/core.constant.d.ts +6 -0
  6. package/dist/types/constants/index.d.ts +2 -0
  7. package/dist/types/constants/z-index.constant.d.ts +24 -0
  8. package/dist/types/core/auth.service.d.ts +29 -0
  9. package/dist/types/core/base-component.service.d.ts +93 -0
  10. package/dist/types/core/client/client-action.service.d.ts +70 -0
  11. package/dist/types/core/client/client-config.service.d.ts +47 -0
  12. package/dist/types/core/command/base-command.service.d.ts +17 -0
  13. package/dist/types/core/command/command.service.d.ts +16 -0
  14. package/dist/types/core/command/common-command.service.d.ts +5 -0
  15. package/dist/types/core/component-factory.service.d.ts +27 -0
  16. package/dist/types/core/fingerprint.service.d.ts +28 -0
  17. package/dist/types/core/google-tag-manager.service.d.ts +93 -0
  18. package/dist/types/core/logger/logger-factory.d.ts +8 -0
  19. package/dist/types/core/logger/logger.service.d.ts +17 -0
  20. package/dist/types/core/pubsub/index.d.ts +2 -0
  21. package/dist/types/core/pubsub/interfaces/address.interface.d.ts +16 -0
  22. package/dist/types/core/pubsub/interfaces/cart.interface.d.ts +107 -0
  23. package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +84 -0
  24. package/dist/types/core/pubsub/interfaces/core.interface.d.ts +81 -0
  25. package/dist/types/core/pubsub/interfaces/index.d.ts +5 -0
  26. package/dist/types/core/pubsub/interfaces/product.interface.d.ts +91 -0
  27. package/dist/types/core/pubsub/pubsub.service.d.ts +12 -0
  28. package/dist/types/core/singleton-manager.service.d.ts +12 -0
  29. package/dist/types/core/store/index.d.ts +2 -0
  30. package/dist/types/core/store/interfaces/address.interface.d.ts +16 -0
  31. package/dist/types/core/store/interfaces/cart.interface.d.ts +94 -0
  32. package/dist/types/core/store/interfaces/checkout.interface.d.ts +154 -0
  33. package/dist/types/core/store/interfaces/core.interface.d.ts +40 -0
  34. package/dist/types/core/store/interfaces/index.d.ts +5 -0
  35. package/dist/types/core/store/interfaces/product.interface.d.ts +81 -0
  36. package/dist/types/core/store/store.constant.d.ts +8 -0
  37. package/dist/types/core/store/store.service.d.ts +41 -0
  38. package/dist/types/core/utils.d.ts +27 -0
  39. package/dist/types/elements-client-helper.d.ts +1 -0
  40. package/dist/types/elements-client.d.ts +2 -0
  41. package/dist/types/enums/cloud.enum.d.ts +77 -0
  42. package/dist/types/enums/core.enum.d.ts +134 -0
  43. package/dist/types/enums/index.d.ts +2 -0
  44. package/dist/types/index.d.ts +4 -0
  45. package/dist/types/index.umd.d.ts +2 -0
  46. package/dist/types/interfaces/cloud/address.interface.d.ts +36 -0
  47. package/dist/types/interfaces/cloud/cart.interface.d.ts +132 -0
  48. package/dist/types/interfaces/cloud/checkout.interface.d.ts +214 -0
  49. package/dist/types/interfaces/cloud/core.interface.d.ts +22 -0
  50. package/dist/types/interfaces/cloud/index.d.ts +6 -0
  51. package/dist/types/interfaces/cloud/product.interface.d.ts +156 -0
  52. package/dist/types/interfaces/cloud/retailer.interface.d.ts +66 -0
  53. package/dist/types/interfaces/cloud/user.interface.d.ts +100 -0
  54. package/dist/types/interfaces/configs/address.interface.d.ts +8 -0
  55. package/dist/types/interfaces/configs/cart.interface.d.ts +15 -0
  56. package/dist/types/interfaces/configs/checkout.interface.d.ts +34 -0
  57. package/dist/types/interfaces/configs/configurations.interface.d.ts +13 -0
  58. package/dist/types/interfaces/configs/global.interface.d.ts +46 -0
  59. package/dist/types/interfaces/configs/index.d.ts +6 -0
  60. package/dist/types/interfaces/configs/product.interface.d.ts +25 -0
  61. package/dist/types/interfaces/core.interface.d.ts +81 -0
  62. package/dist/types/modules/address/address-display.component.d.ts +13 -0
  63. package/dist/types/modules/address/address-input.component.d.ts +40 -0
  64. package/dist/types/modules/address/address.command.d.ts +15 -0
  65. package/dist/types/modules/address/address.component.d.ts +12 -0
  66. package/dist/types/modules/address/address.interface.d.ts +10 -0
  67. package/dist/types/modules/address/index.d.ts +4 -0
  68. package/dist/types/modules/api-client/api-client.interface.d.ts +21 -0
  69. package/dist/types/modules/api-client/api-client.service.d.ts +28 -0
  70. package/dist/types/modules/api-client/index.d.ts +2 -0
  71. package/dist/types/modules/cart/cart.commands.d.ts +36 -0
  72. package/dist/types/modules/cart/cart.commands.helper.d.ts +8 -0
  73. package/dist/types/modules/cart/cart.component.d.ts +11 -0
  74. package/dist/types/modules/cart/components/cart-body.component.d.ts +24 -0
  75. package/dist/types/modules/cart/components/cart-footer.component.d.ts +21 -0
  76. package/dist/types/modules/cart/components/cart-fulfillment.component.d.ts +26 -0
  77. package/dist/types/modules/cart/components/cart-header.component.d.ts +6 -0
  78. package/dist/types/modules/cart/components/cart-item-quantity-price.component.d.ts +21 -0
  79. package/dist/types/modules/cart/components/cart-item.component.d.ts +13 -0
  80. package/dist/types/modules/cart/components/cart-promo-code.component.d.ts +17 -0
  81. package/dist/types/modules/cart/components/cart-retailer-subtotal.component.d.ts +10 -0
  82. package/dist/types/modules/cart/components/cart-retailer.component.d.ts +23 -0
  83. package/dist/types/modules/cart/components/index.d.ts +8 -0
  84. package/dist/types/modules/cart/index.d.ts +1 -0
  85. package/dist/types/modules/checkout/checkout.commands.d.ts +50 -0
  86. package/dist/types/modules/checkout/checkout.commands.helper.d.ts +13 -0
  87. package/dist/types/modules/checkout/checkout.component.d.ts +11 -0
  88. package/dist/types/modules/checkout/components/checkout-header.component.d.ts +9 -0
  89. package/dist/types/modules/checkout/components/checkout-information-section.component.d.ts +12 -0
  90. package/dist/types/modules/checkout/components/checkout-presale-countdown.component.d.ts +26 -0
  91. package/dist/types/modules/checkout/components/checkout-summary-section.component.d.ts +12 -0
  92. package/dist/types/modules/checkout/components/checkout.type.d.ts +4 -0
  93. package/dist/types/modules/checkout/components/index.d.ts +20 -0
  94. package/dist/types/modules/checkout/components/information/checkout-billing-form.component.d.ts +18 -0
  95. package/dist/types/modules/checkout/components/information/checkout-buyer-information-form.component.d.ts +12 -0
  96. package/dist/types/modules/checkout/components/information/checkout-delivery-information-form.component.d.ts +17 -0
  97. package/dist/types/modules/checkout/components/information/checkout-payment-form.component.d.ts +21 -0
  98. package/dist/types/modules/checkout/components/information/checkout-stripe-form.component.d.ts +52 -0
  99. package/dist/types/modules/checkout/components/summary/checkout-amounts.component.d.ts +7 -0
  100. package/dist/types/modules/checkout/components/summary/checkout-completed.component.d.ts +12 -0
  101. package/dist/types/modules/checkout/components/summary/checkout-gift-cards.component.d.ts +14 -0
  102. package/dist/types/modules/checkout/components/summary/checkout-item-quantity.component.d.ts +19 -0
  103. package/dist/types/modules/checkout/components/summary/checkout-item.component.d.ts +21 -0
  104. package/dist/types/modules/checkout/components/summary/checkout-items.component.d.ts +16 -0
  105. package/dist/types/modules/checkout/components/summary/checkout-place-order-button.component.d.ts +23 -0
  106. package/dist/types/modules/checkout/components/summary/checkout-presale-expired.component.d.ts +16 -0
  107. package/dist/types/modules/checkout/components/summary/checkout-promo-code.component.d.ts +17 -0
  108. package/dist/types/modules/checkout/components/summary/checkout-tips.component.d.ts +19 -0
  109. package/dist/types/modules/checkout/components/summary/promo-pc-gc.component.d.ts +16 -0
  110. package/dist/types/modules/checkout/constant.d.ts +32 -0
  111. package/dist/types/modules/checkout/index.d.ts +1 -0
  112. package/dist/types/modules/product/components/components.d.ts +20 -0
  113. package/dist/types/modules/product/components/index.d.ts +13 -0
  114. package/dist/types/modules/product/components/product-add-to-cart-section.component.d.ts +26 -0
  115. package/dist/types/modules/product/components/product-description.component.d.ts +9 -0
  116. package/dist/types/modules/product/components/product-drawer.component.d.ts +19 -0
  117. package/dist/types/modules/product/components/product-image-carousel.component.d.ts +36 -0
  118. package/dist/types/modules/product/components/product-interactions.component.d.ts +14 -0
  119. package/dist/types/modules/product/components/product-options.component.d.ts +12 -0
  120. package/dist/types/modules/product/components/product-price.component.d.ts +11 -0
  121. package/dist/types/modules/product/components/product-retailers-carousel.component.d.ts +32 -0
  122. package/dist/types/modules/product/components/product-retailers-popup-list.component.d.ts +13 -0
  123. package/dist/types/modules/product/components/product-retailers-popup.component.d.ts +11 -0
  124. package/dist/types/modules/product/components/product-retailers.component.d.ts +11 -0
  125. package/dist/types/modules/product/constant.d.ts +2 -0
  126. package/dist/types/modules/product/index.d.ts +1 -0
  127. package/dist/types/modules/product/product.commands.d.ts +29 -0
  128. package/dist/types/modules/product/product.component.d.ts +13 -0
  129. package/dist/types/modules/product/utils/helpers.d.ts +10 -0
  130. package/dist/types/modules/product/utils/index.d.ts +2 -0
  131. package/dist/types/modules/product/utils/retailer-hours.d.ts +9 -0
  132. package/dist/types/modules/theme-provider/constants/component-groupings.d.ts +7 -0
  133. package/dist/types/modules/theme-provider/constants/css-variable-mappings.d.ts +2 -0
  134. package/dist/types/modules/theme-provider/index.d.ts +2 -0
  135. package/dist/types/modules/theme-provider/services/css-variable-processor.service.d.ts +20 -0
  136. package/dist/types/modules/theme-provider/services/font-manager.service.d.ts +9 -0
  137. package/dist/types/modules/theme-provider/services/stylesheet-generator.service.d.ts +13 -0
  138. package/dist/types/modules/theme-provider/styles/address/address.style.d.ts +1 -0
  139. package/dist/types/modules/theme-provider/styles/address/index.d.ts +1 -0
  140. package/dist/types/modules/theme-provider/styles/cart/cart.style.d.ts +1 -0
  141. package/dist/types/modules/theme-provider/styles/cart/index.d.ts +1 -0
  142. package/dist/types/modules/theme-provider/styles/checkout/checkout.style.d.ts +1 -0
  143. package/dist/types/modules/theme-provider/styles/checkout/index.d.ts +1 -0
  144. package/dist/types/modules/theme-provider/styles/global.style.d.ts +1 -0
  145. package/dist/types/modules/theme-provider/styles/product/image-carousel.style.d.ts +1 -0
  146. package/dist/types/modules/theme-provider/styles/product/index.d.ts +3 -0
  147. package/dist/types/modules/theme-provider/styles/product/product.style.d.ts +1 -0
  148. package/dist/types/modules/theme-provider/styles/product/retailers.style.d.ts +1 -0
  149. package/dist/types/modules/theme-provider/styles/ui/drawer.style.d.ts +1 -0
  150. package/dist/types/modules/theme-provider/styles/ui/index.d.ts +3 -0
  151. package/dist/types/modules/theme-provider/styles/ui/loading.style.d.ts +1 -0
  152. package/dist/types/modules/theme-provider/styles/ui/promo-code-ticker.style.d.ts +1 -0
  153. package/dist/types/modules/theme-provider/theme-provider.service.d.ts +22 -0
  154. package/dist/types/modules/ui-components/alert/alert.component.d.ts +24 -0
  155. package/dist/types/modules/ui-components/alert/index.d.ts +1 -0
  156. package/dist/types/modules/ui-components/buttons/buttons-open-cart.component.d.ts +11 -0
  157. package/dist/types/modules/ui-components/buttons/index.d.ts +1 -0
  158. package/dist/types/modules/ui-components/drawer/drawer.component.d.ts +23 -0
  159. package/dist/types/modules/ui-components/drawer/index.d.ts +1 -0
  160. package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +24 -0
  161. package/dist/types/modules/ui-components/engraving/engraving-view.component.d.ts +19 -0
  162. package/dist/types/modules/ui-components/engraving/index.d.ts +2 -0
  163. package/dist/types/modules/ui-components/error-view/error-view.d.ts +9 -0
  164. package/dist/types/modules/ui-components/error-view/index.d.ts +1 -0
  165. package/dist/types/modules/ui-components/input/birthdate-input.component.d.ts +51 -0
  166. package/dist/types/modules/ui-components/input/index.d.ts +2 -0
  167. package/dist/types/modules/ui-components/input/input.component.d.ts +46 -0
  168. package/dist/types/modules/ui-components/lce-element/index.d.ts +1 -0
  169. package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +11 -0
  170. package/dist/types/modules/ui-components/loading/index.d.ts +1 -0
  171. package/dist/types/modules/ui-components/loading/product-loading.component.d.ts +6 -0
  172. package/dist/types/modules/ui-components/powered-by/index.d.ts +1 -0
  173. package/dist/types/modules/ui-components/powered-by/powered-by.component.d.ts +13 -0
  174. package/dist/types/modules/ui-components/promo-code-ticker/index.d.ts +1 -0
  175. package/dist/types/modules/ui-components/promo-code-ticker/promo-code-ticker.component.d.ts +17 -0
  176. package/dist/types/modules/ui-components/purchase-min-alert/helpers.d.ts +8 -0
  177. package/dist/types/modules/ui-components/purchase-min-alert/index.d.ts +2 -0
  178. package/dist/types/modules/ui-components/purchase-min-alert/purchase-min-alert.component.d.ts +16 -0
  179. package/dist/types/modules/ui-components/ui.commands.d.ts +7 -0
  180. package/dist/types/static/icon/arrow-right.icon.d.ts +2 -0
  181. package/dist/types/static/icon/bag.icon.d.ts +2 -0
  182. package/dist/types/static/icon/checkbox.icon.d.ts +2 -0
  183. package/dist/types/static/icon/chevron-down.icon.d.ts +2 -0
  184. package/dist/types/static/icon/chevron-left.icon.d.ts +2 -0
  185. package/dist/types/static/icon/close.icon.d.ts +2 -0
  186. package/dist/types/static/icon/completed.icon.d.ts +2 -0
  187. package/dist/types/static/icon/error-info.icon.d.ts +2 -0
  188. package/dist/types/static/icon/icon.types.d.ts +6 -0
  189. package/dist/types/static/icon/index.d.ts +15 -0
  190. package/dist/types/static/icon/info.icon.d.ts +2 -0
  191. package/dist/types/static/icon/loading-spinner.icon.d.ts +2 -0
  192. package/dist/types/static/icon/search.icon.d.ts +2 -0
  193. package/dist/types/static/icon/success.icon.d.ts +2 -0
  194. package/dist/types/static/icon/trash.icon.d.ts +2 -0
  195. package/dist/types/static/icon/warning.icon.d.ts +2 -0
  196. package/dist/types/utils/dom-polyfills.d.ts +10 -0
  197. package/dist/types/utils/format.d.ts +23 -0
  198. package/dist/types/utils/helper.d.ts +27 -0
  199. package/dist/types/utils/html-sanitizer.d.ts +2 -0
  200. package/package.json +110 -0
  201. package/umd/elements.js +1 -0
package/README.md ADDED
@@ -0,0 +1,1183 @@
1
+ <div align="center">
2
+ <h1>
3
+ <img src="https://assets.liquidcommerce.co/liquid-commerce-logo/liquid-commerce-light-logo-icon.svg" height="32" width="32" align="top">
4
+ Elements SDK
5
+ </h1>
6
+ </div>
7
+
8
+ <div align="center">
9
+
10
+ [![JavaScript](https://img.shields.io/badge/JavaScript-ES6+-F7DF1E?style=for-the-badge&logo=javascript&logoColor=black)](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
11
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5+-3178C6?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
12
+ [![npm](https://img.shields.io/badge/npm-10+-CB3837?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/)
13
+ [![pnpm](https://img.shields.io/badge/pnpm-8+-F69220?style=for-the-badge&logo=pnpm&logoColor=white)](https://pnpm.io/)
14
+ [![Rollup](https://img.shields.io/badge/Rollup-4+-EC4A3F?style=for-the-badge&logo=rollup.js&logoColor=white)](https://rollupjs.org/)
15
+
16
+ [![License: UNLICENSED](https://img.shields.io/badge/License-UNLICENSED-red.svg)](LICENSE)
17
+ [![Bundle Size](https://img.shields.io/badge/Bundle%20Size-~150KB-blue)](./umd)
18
+ [![Zero Dependencies](https://img.shields.io/badge/Dependencies-Zero-brightgreen)](./package.json)
19
+ [![Browser Support](https://img.shields.io/badge/Browsers-2018+-4285F4?logo=googlechrome&logoColor=white)](./docs/BROWSER_SUPPORT.md)
20
+
21
+ **Add product, cart, and checkout experiences to any website with a few lines of code**
22
+
23
+ </div>
24
+
25
+ ## 📋 Table of Contents
26
+
27
+ <details>
28
+ <summary>Click to expand</summary>
29
+
30
+ - [Overview](#-overview)
31
+ - [Latest Features](#-latest-features)
32
+ - [Key Features](#-key-features)
33
+ - [Architecture](#-architecture)
34
+ - [System Architecture](#system-architecture)
35
+ - [Component Architecture](#component-architecture)
36
+ - [Event Flow](#event-flow)
37
+ - [Features](#-features)
38
+ - [Installation](#-installation)
39
+ - [CDN Usage](#option-a--use-the-cdn)
40
+ - [NPM Installation](#option-b--install-from-npm)
41
+ - [Browser Support](#-browser-support)
42
+ - [Quick Start](#-quick-start)
43
+ - [Auto-initialization](#step-1--auto-initialization-easiest)
44
+ - [Product Mapping](#step-2--map-products-to-containers)
45
+ - [Programmatic Control](#step-3--programmatic-control-advanced)
46
+ - [SDK Methods & API](#-sdk-methods--api)
47
+ - [Core Client Methods](#core-client-methods)
48
+ - [UI Methods](#ui-methods)
49
+ - [Builder Methods](#builder-methods-development-mode)
50
+ - [Actions](#-actions)
51
+ - [Product Actions](#product-actions)
52
+ - [Address Actions](#address-actions)
53
+ - [Cart Actions](#cart-actions)
54
+ - [Checkout Actions](#checkout-actions)
55
+ - [Events](#-events)
56
+ - [Event Listening](#event-listening)
57
+ - [Available Events](#available-events)
58
+ - [Configuration](#-configuration)
59
+ - [Module Options](#module-options)
60
+ - [Environment Options](#environment-options)
61
+ - [Auto-init Attributes](#auto-init-data-attributes)
62
+ - [Themes & Customization](#-themes--customization)
63
+ - [Theme Configuration](#theme-configuration)
64
+ - [Dynamic Updates](#dynamic-theme-updates)
65
+ - [Proxy Configuration](#-proxy-configuration)
66
+ - [Demo Pages](#-demo-pages)
67
+ - [Simple Demo](#simple-demo-demosimplehtml)
68
+ - [Advanced Demo](#advanced-demo-demoadvancedhtml)
69
+ - [Development Scripts](#-development-scripts)
70
+ - [Build Commands](#build-commands)
71
+ - [Code Quality](#code-quality-commands)
72
+ - [Maintenance](#maintenance-commands)
73
+ - [Documentation](#-documentation)
74
+ - [Versioning](#-versioning)
75
+ - [Support](#-support)
76
+
77
+ </details>
78
+
79
+ ## 🎯 Overview
80
+
81
+ The LiquidCommerce Elements SDK is a **production-ready JavaScript library** that enables partners to seamlessly integrate product displays, shopping carts, and checkout flows into any website. Built with performance and developer experience in mind.
82
+
83
+ ### 🆕 Latest Features
84
+
85
+ - **Builder Mode**: Dynamic theme customization for development environments
86
+ - **Action Feedback Events**: All actions now emit success/failure events for better UX
87
+ - **Proxy Support**: Route API requests through your server to avoid ad blockers
88
+ - **Enhanced CLI**: Improved development scripts with parallel builds and better error handling
89
+ - **TypeScript Support**: Full TypeScript definitions for better IDE experience
90
+
91
+ ### ✨ Key Features
92
+
93
+ <table>
94
+ <tr>
95
+ <td width="50%">
96
+
97
+ **🚀 Quick Integration**
98
+ - Auto-initialization with data attributes
99
+ - Zero configuration setup
100
+ - CDN or NPM installation
101
+ - Works with any framework or vanilla JS
102
+
103
+ </td>
104
+ <td width="50%">
105
+
106
+ **🛍️ Complete E-commerce**
107
+ - Product display components
108
+ - Shopping cart with real-time updates
109
+ - Full checkout flow
110
+ - Address management
111
+
112
+ </td>
113
+ </tr>
114
+ <tr>
115
+ <td width="50%">
116
+
117
+ **🎨 Customizable UI**
118
+ - Comprehensive theme system
119
+ - Component-level styling
120
+ - Responsive design
121
+ - Modern, accessible components
122
+
123
+ </td>
124
+ <td width="50%">
125
+
126
+ **⚡ Performance First**
127
+ - ~150KB bundle size
128
+ - Zero runtime dependencies
129
+ - Lazy loading support
130
+ - Optimized for Core Web Vitals
131
+
132
+ </td>
133
+ </tr>
134
+ </table>
135
+
136
+ ## 🏗️ Architecture
137
+
138
+ ### System Architecture
139
+
140
+ ```mermaid
141
+ graph TB
142
+ subgraph "Your Website"
143
+ HTML[HTML Page]
144
+ JS[JavaScript]
145
+ INIT[Elements SDK]
146
+ end
147
+
148
+ subgraph "Elements SDK Core"
149
+ CLIENT[Elements Client]
150
+
151
+ subgraph "Components"
152
+ PROD[Product Component]
153
+ CART[Cart Component]
154
+ CHECK[Checkout Component]
155
+ ADDR[Address Component]
156
+ end
157
+
158
+ subgraph "Services"
159
+ ACT[Actions Service]
160
+ EVT[Events Service]
161
+ API[API Client]
162
+ THEME[Theme Provider]
163
+ end
164
+
165
+ subgraph "UI Layer"
166
+ BTN[Cart Button]
167
+ FLOAT[Floating Cart]
168
+ DISP[Live Displays]
169
+ end
170
+ end
171
+
172
+ subgraph "LiquidCommerce API"
173
+ PAPI[Products API]
174
+ CAPI[Cart API]
175
+ OAPI[Orders API]
176
+ AAPI[Address API]
177
+ end
178
+
179
+ HTML --> INIT
180
+ JS --> CLIENT
181
+
182
+ CLIENT --> PROD
183
+ CLIENT --> CART
184
+ CLIENT --> CHECK
185
+ CLIENT --> ADDR
186
+
187
+ PROD --> API
188
+ CART --> API
189
+ CHECK --> API
190
+ ADDR --> API
191
+
192
+ API --> PAPI
193
+ API --> CAPI
194
+ API --> OAPI
195
+ API --> AAPI
196
+
197
+ ACT --> EVT
198
+ CLIENT --> ACT
199
+ CLIENT --> THEME
200
+ ```
201
+
202
+ ### Component Architecture
203
+
204
+ ```mermaid
205
+ graph LR
206
+ subgraph "Product Component"
207
+ PD[Product Display]
208
+ PS[Size Selector]
209
+ PQ[Quantity Control]
210
+ PA[Add to Cart]
211
+ end
212
+
213
+ subgraph "Cart Component"
214
+ CI[Cart Items]
215
+ CQ[Quantity Update]
216
+ CP[Promo Code]
217
+ CT[Cart Total]
218
+ end
219
+
220
+ subgraph "Checkout Component"
221
+ CS[Shipping Info]
222
+ CB[Billing Info]
223
+ PM[Payment Method]
224
+ OS[Order Summary]
225
+ end
226
+
227
+ PD --> PS
228
+ PS --> PQ
229
+ PQ --> PA
230
+
231
+ CI --> CQ
232
+ CQ --> CT
233
+ CP --> CT
234
+
235
+ CS --> CB
236
+ CB --> PM
237
+ PM --> OS
238
+ ```
239
+
240
+ ### Event Flow
241
+
242
+ ```mermaid
243
+ sequenceDiagram
244
+ participant User
245
+ participant SDK
246
+ participant Actions
247
+ participant Events
248
+ participant API
249
+ participant Website
250
+
251
+ User->>SDK: Add to Cart
252
+ SDK->>Actions: cart.addProduct()
253
+ Actions->>API: POST /cart/items
254
+ API-->>Actions: Response
255
+ Actions->>Events: Emit Success/Failure
256
+ Events->>Website: lce:actions.cart_product_add_success
257
+ Website->>User: Show Feedback
258
+ ```
259
+
260
+ ## 🚀 Features
261
+
262
+ - **🎯 Auto-initialization**: Single script tag with data attributes
263
+ - **📦 Zero Dependencies**: Everything bundled, no peer dependencies
264
+ - **🌐 CDN Ready**: No build step required for basic usage
265
+ - **⚡ Lightweight**: ~150KB minified bundle size
266
+ - **🔧 Framework Agnostic**: Works with React, Vue, Angular, or vanilla JS
267
+ - **📱 Responsive**: Mobile-first design approach
268
+ - **♿ Accessible**: WCAG 2.1 AA compliant components
269
+ - **🎨 Themeable**: Comprehensive customization system
270
+ - **🔐 Secure**: PCI compliant checkout flow
271
+ - **📊 Analytics Ready**: Built-in event system for tracking
272
+ - **🌍 Multi-environment**: Support for dev, staging, and production
273
+ - **🧪 Well Tested**: Comprehensive test coverage
274
+
275
+ ## 📦 Installation
276
+
277
+ ### Choose how to include the SDK
278
+
279
+ - **Use our CDN** (no build step required)
280
+ - **Install from NPM** (for bundlers like Vite, Webpack, etc.)
281
+
282
+ ### Option A — Use the CDN
283
+
284
+ Include the script on your page. Use the production or beta URL:
285
+
286
+ ```html
287
+ <!-- Production (latest) -->
288
+ <script src="https://assets-elements.liquidcommerce.us/all/elements.js"></script>
289
+
290
+ <!-- Beta (latest) -->
291
+ <script src="https://assets-elements.liquidcommerce.us/all/beta/elements.js"></script>
292
+ ```
293
+
294
+ You can also pin to a specific version:
295
+
296
+ ```html
297
+ <script src="https://assets-elements.liquidcommerce.us/all/1.2.3/elements.js"></script>
298
+ ```
299
+
300
+ ### Option B — Install from NPM
301
+
302
+ ```bash
303
+ npm install @liquidcommerceteam/elements-sdk
304
+ # or
305
+ pnpm add @liquidcommerceteam/elements-sdk
306
+ ```
307
+
308
+ Then import and initialize in your app code:
309
+
310
+ ```js
311
+ import { Elements } from '@liquidcommerceteam/elements-sdk';
312
+
313
+ const client = await Elements('YOUR_API_KEY', {
314
+ env: 'production',
315
+ });
316
+ ```
317
+
318
+ ## 🌐 Browser Support
319
+
320
+ ⚠️ **Important**: This SDK is designed for browser environments only. It will not work in server-side rendering, Node.js, or other non-browser environments. The SDK includes built-in safety measures to prevent errors when accidentally imported in these environments.
321
+
322
+ ### Supported Browsers
323
+
324
+ The SDK supports **2018+ browsers** with comprehensive polyfills:
325
+
326
+ | Browser | Minimum Version | Released |
327
+ |---------|----------------|----------|
328
+ | Chrome | 66+ | April 2018 |
329
+ | Firefox | 60+ | May 2018 |
330
+ | Safari | 12+ | September 2018 |
331
+ | Edge | 79+ (Chromium) | January 2020 |
332
+ | Samsung Internet | 7.2+ | June 2018 |
333
+
334
+ 📖 See [`docs/BROWSER_SUPPORT.md`](docs/BROWSER_SUPPORT.md) for detailed version compatibility and polyfill information.
335
+
336
+ ## 🚀 Quick Start
337
+
338
+ ### Step 1 — Auto-initialization (Easiest)
339
+
340
+ This single script both loads the SDK and initializes it automatically. Place it:
341
+ - At the end of the `<body>` (recommended), or
342
+ - In the `<head>` with `defer` so it doesn't block rendering.
343
+
344
+ ```html
345
+ <!-- Body footer (recommended) -->
346
+ <script
347
+ data-liquid-commerce-elements
348
+ data-token="YOUR_API_KEY"
349
+ data-env="production"
350
+ data-cart-id="buttons-container"
351
+ data-show-cart-items
352
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
353
+ ></script>
354
+
355
+ <!-- OR: Head with defer -->
356
+ <script
357
+ defer
358
+ data-liquid-commerce-elements
359
+ data-token="YOUR_API_KEY"
360
+ data-env="production"
361
+ data-cart-id="buttons-container"
362
+ data-show-cart-items
363
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
364
+ ></script>
365
+ ```
366
+
367
+ **Available data attributes:**
368
+ - `data-token="YOUR_API_KEY"` - Your API key (required)
369
+ - `data-env="production|development"` - Environment (default: production)
370
+ - `data-cart-id="container-id"` - ID for cart button container (optional, creates floating button if omitted)
371
+ - `data-show-cart-items` - Show items count badge on cart button (optional)
372
+ - `data-enable-debugging` - Enable debug logging in development (optional)
373
+
374
+ Add containers where you want elements to render:
375
+
376
+ ```html
377
+ <div id="buttons-container"></div>
378
+ <div id="pdp-1"></div>
379
+ <div id="pdp-2"></div>
380
+ ```
381
+
382
+ ### Step 2 — Map products to containers
383
+
384
+ Choose one or combine multiple methods:
385
+
386
+ #### 1) Attribute pairs on the main script
387
+
388
+ ```html
389
+ <script
390
+ data-liquid-commerce-elements
391
+ data-token="YOUR_API_KEY"
392
+ data-env="production"
393
+ data-container-1="pdp-1"
394
+ data-product-1="00619947000020"
395
+ data-container-2="pdp-2"
396
+ data-product-2="00832889005513"
397
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
398
+ ></script>
399
+ ```
400
+
401
+ #### 2) JSON configuration script
402
+
403
+ ```html
404
+ <script data-liquid-commerce-elements-products type="application/json">
405
+ [
406
+ { "containerId": "pdp-1", "identifier": "00619947000020" },
407
+ { "containerId": "pdp-2", "identifier": "00832889005513" }
408
+ ]
409
+ </script>
410
+ ```
411
+
412
+ #### 3) Annotated elements
413
+
414
+ ```html
415
+ <div data-lce-product="00619947000020"></div>
416
+ <div data-lce-product="00832889005513"></div>
417
+ ```
418
+
419
+ ### Step 3 — Programmatic Control (Advanced)
420
+
421
+ Initialize the SDK yourself for full control:
422
+
423
+ ```html
424
+ <script src="https://assets-elements.liquidcommerce.us/all/elements.js"></script>
425
+ <script>
426
+ (async () => {
427
+ const client = await window.Elements('YOUR_API_KEY', {
428
+ env: 'production',
429
+ enableDebugging: false, // only for development
430
+ customTheme: { /* optional theming overrides */ }
431
+ });
432
+
433
+ // Your implementation here...
434
+ })();
435
+ </script>
436
+ ```
437
+
438
+ ## 📖 SDK Methods & API
439
+
440
+ ### Core Client Methods
441
+
442
+ Once initialized, the client provides these core methods:
443
+
444
+ #### Product Injection
445
+
446
+ **`injectProductElement(params: IInjectProductElement[]): Promise<void>`**
447
+
448
+ Inject product components into containers:
449
+
450
+ ```js
451
+ await client.injectProductElement([
452
+ { containerId: 'pdp-1', identifier: '00619947000020' },
453
+ { containerId: 'pdp-2', identifier: '00832889005513' }
454
+ ]);
455
+ ```
456
+
457
+ #### Cart Injection
458
+
459
+ **`injectCartElement(containerId: string): Promise<void>`**
460
+
461
+ Inject a cart component:
462
+
463
+ ```js
464
+ await client.injectCartElement('cart-container');
465
+ ```
466
+
467
+ #### Checkout Injection
468
+
469
+ **`injectCheckoutElement(containerId: string): Promise<void>`**
470
+
471
+ Inject a checkout component:
472
+
473
+ ```js
474
+ await client.injectCheckoutElement('checkout-container');
475
+ ```
476
+
477
+ #### Address Injection
478
+
479
+ **`injectAddressElement(containerId: string): Promise<void>`**
480
+
481
+ Inject an address form component:
482
+
483
+ ```js
484
+ await client.injectAddressElement('address-container');
485
+ ```
486
+
487
+ ### UI Methods
488
+
489
+ #### Cart Buttons
490
+
491
+ **`ui.cartButton(containerId: string, showItemsCount?: boolean): void`**
492
+
493
+ Create an "open cart" button in a specific container:
494
+
495
+ ```js
496
+ client.ui.cartButton('buttons-container');
497
+
498
+ // With items count badge
499
+ client.ui.cartButton('buttons-container', true);
500
+ ```
501
+
502
+ **`ui.floatingCartButton(showItemsCount?: boolean): void`**
503
+
504
+ Automatically inject a floating cart button:
505
+
506
+ ```js
507
+ client.ui.floatingCartButton();
508
+
509
+ // With items count badge
510
+ client.ui.floatingCartButton(true);
511
+ ```
512
+
513
+ #### Live Cart Display
514
+
515
+ **`ui.cartTotal(elementId: string): void`**
516
+
517
+ Bind an element to display the live cart total (automatically updates when cart changes):
518
+
519
+ ```js
520
+ client.ui.cartTotal('cart-total-display');
521
+ ```
522
+
523
+ **`ui.cartItemsCount(elementId: string): void`**
524
+
525
+ Bind an element to display the live cart items count (automatically updates when cart changes):
526
+
527
+ ```js
528
+ client.ui.cartItemsCount('cart-items-badge');
529
+ ```
530
+
531
+ ### Builder Methods (Development Mode)
532
+
533
+ When `isBuilder: true` is set, additional methods are available for theme customization:
534
+
535
+ ```js
536
+ const client = await Elements('YOUR_API_KEY', {
537
+ env: 'development',
538
+ isBuilder: true
539
+ });
540
+
541
+ // Update component themes
542
+ await client.builder.updateComponentGlobalConfigs(globalTheme);
543
+ await client.builder.updateProductComponent(productTheme);
544
+ client.builder.updateCartComponent(cartTheme);
545
+ client.builder.updateCheckoutComponent(checkoutTheme);
546
+ client.builder.updateAddressComponent(addressTheme);
547
+
548
+ // Builder injection methods (same as regular methods)
549
+ await client.builder.injectProductElement(params);
550
+ await client.builder.injectCartElement(containerId);
551
+ await client.builder.injectCheckoutElement(containerId);
552
+ await client.builder.injectAddressElement(containerId);
553
+ ```
554
+
555
+ ## 🎬 Actions
556
+
557
+ Actions provide programmatic control over SDK components. Access them via `client.actions` or `window.elements.actions`:
558
+
559
+ ```js
560
+ // Available after client initialization
561
+ const actions = client.actions;
562
+ // OR globally
563
+ const actions = window.elements.actions;
564
+ ```
565
+
566
+ ### Product Actions
567
+
568
+ ```js
569
+ // Get product details
570
+ const product = actions.product.getDetails('product-123');
571
+ console.log(product.productName, product.price, product.isAvailable);
572
+ ```
573
+
574
+ ### Address Actions
575
+
576
+ ```js
577
+ // Set address using Google Places ID
578
+ await actions.address.setAddressByPlacesId('ChIJ0SRjyK5ZwokRp1TwT8dJSv8');
579
+
580
+ // Set address manually without Google Places (perfect for custom address forms)
581
+ await actions.address.setAddressManually(
582
+ {
583
+ one: '123 Main St',
584
+ two: 'Apt 4B', // Optional apartment/suite
585
+ city: 'New York',
586
+ state: 'NY',
587
+ zip: '10001',
588
+ country: 'United States' // Optional, will be included in formatted address
589
+ },
590
+ {
591
+ lat: 40.7505045,
592
+ long: -73.9934387
593
+ }
594
+ );
595
+
596
+ // Listen for success/failure via events
597
+ window.addEventListener('lce:actions.address_updated', function(event) {
598
+ const address = event.detail.data;
599
+ console.log('✅ Address set!', address.formattedAddress);
600
+ updateShippingOptions(address.coordinates);
601
+ });
602
+
603
+ window.addEventListener('lce:actions.address_failed', function(event) {
604
+ const error = event.detail.data;
605
+ console.log('❌ Address failed:', error.message);
606
+ showAddressForm();
607
+ });
608
+
609
+ // Get current address
610
+ const address = actions.address.getDetails();
611
+
612
+ // Clear saved address
613
+ actions.address.clear();
614
+ ```
615
+
616
+ **Notes**:
617
+ - To find Google Places IDs for the `setAddressByPlacesId` action, use the [Google Places ID Finder](https://developers.google.com/maps/documentation/places/web-service/place-id#find-id)
618
+ - The `setAddressManually` action automatically generates a Google Places API-formatted address string from the provided components
619
+ - Manual addresses have an empty Places ID (as they don't come from Google Places API)
620
+
621
+ **Action Feedback**: All actions provide feedback through events. Listen for success/failure events to handle results and provide user feedback.
622
+
623
+ ### Cart Actions
624
+
625
+ ```js
626
+ // Control cart visibility
627
+ actions.cart.openCart();
628
+ actions.cart.closeCart();
629
+ actions.cart.toggleCart();
630
+
631
+ // Add products to cart
632
+ await actions.cart.addProduct([{
633
+ identifier: 'product-123',
634
+ fulfillmentType: 'shipping', // or 'onDemand'
635
+ quantity: 2
636
+ }]);
637
+
638
+ // Listen for add product feedback
639
+ window.addEventListener('lce:actions.cart_product_add_success', function(event) {
640
+ const { itemsAdded, identifiers } = event.detail.data;
641
+ console.log(`✅ Added ${itemsAdded} products to cart:`, identifiers);
642
+ showSuccessMessage('Products added to cart!');
643
+ });
644
+
645
+ window.addEventListener('lce:actions.cart_product_add_failed', function(event) {
646
+ const { identifiers, error } = event.detail.data;
647
+ console.log(`❌ Failed to add products:`, error);
648
+ showErrorMessage('Could not add products. Please try again.');
649
+ });
650
+
651
+ // Apply promo codes
652
+ await actions.cart.applyPromoCode('WELCOME10');
653
+
654
+ // Listen for promo code feedback
655
+ window.addEventListener('lce:actions.cart_promo_code_applied', function(event) {
656
+ const { applied, discountAmount, newTotal } = event.detail.data;
657
+ console.log(`✅ Promo applied! Discount: $${discountAmount}, New total: $${newTotal}`);
658
+ showSavingsMessage(discountAmount);
659
+ });
660
+
661
+ window.addEventListener('lce:actions.cart_promo_code_failed', function(event) {
662
+ const { attempted, error } = event.detail.data;
663
+ console.log(`❌ Promo failed:`, error);
664
+ showErrorMessage('Promo code could not be applied');
665
+ });
666
+
667
+ // Remove promo codes
668
+ await actions.cart.removePromoCode();
669
+
670
+ // Get cart details
671
+ const cart = actions.cart.getDetails();
672
+ console.log(cart.total, cart.items.length);
673
+
674
+ // Reset cart
675
+ await actions.cart.resetCart();
676
+ ```
677
+
678
+ ### Checkout Actions
679
+
680
+ ```js
681
+ // Control checkout visibility
682
+ actions.checkout.openCheckout();
683
+ actions.checkout.closeCheckout();
684
+ actions.checkout.toggleCheckout();
685
+
686
+ // Pre-fill customer information
687
+ actions.checkout.updateCustomerInfo({
688
+ firstName: 'John',
689
+ lastName: 'Doe',
690
+ email: 'john@example.com',
691
+ phone: '+1234567890'
692
+ });
693
+
694
+ // Pre-fill billing information
695
+ actions.checkout.updateBillingInfo({
696
+ firstName: 'John',
697
+ lastName: 'Doe',
698
+ street1: '123 Main St',
699
+ city: 'Anytown',
700
+ state: 'CA',
701
+ zipCode: '12345'
702
+ });
703
+
704
+ // Manage gift options
705
+ await actions.checkout.toggleIsGift(true);
706
+ actions.checkout.updateGiftInfo({
707
+ giftMessage: 'Happy Birthday!',
708
+ giftFrom: 'Your Friend'
709
+ });
710
+
711
+ // Apply discounts and gift cards
712
+ await actions.checkout.applyPromoCode('SAVE20');
713
+ await actions.checkout.applyGiftCard('GIFT123');
714
+
715
+ // Listen for checkout promo code feedback
716
+ window.addEventListener('lce:actions.checkout_promo_code_applied', function(event) {
717
+ const { applied, discountAmount, newTotal } = event.detail.data;
718
+ console.log(`✅ Checkout promo applied! Saved: $${discountAmount}`);
719
+ updateCheckoutTotal(newTotal);
720
+ });
721
+
722
+ window.addEventListener('lce:actions.checkout_promo_code_failed', function(event) {
723
+ const { attempted, error } = event.detail.data;
724
+ console.log(`❌ Checkout promo failed:`, error);
725
+ showCheckoutError('Promo code could not be applied');
726
+ });
727
+
728
+ // Listen for gift card feedback
729
+ window.addEventListener('lce:actions.checkout_gift_card_applied', function(event) {
730
+ const { applied, newTotal } = event.detail.data;
731
+ console.log('✅ Gift card applied successfully!');
732
+ updateCheckoutTotal(newTotal);
733
+ showSuccessMessage('Gift card applied to your order');
734
+ });
735
+
736
+ window.addEventListener('lce:actions.checkout_gift_card_failed', function(event) {
737
+ const { attempted, error } = event.detail.data;
738
+ console.log(`❌ Gift card failed:`, error);
739
+ showCheckoutError('Gift card could not be applied');
740
+ });
741
+
742
+ // Get checkout details (safe, non-sensitive data only)
743
+ const checkout = actions.checkout.getDetails();
744
+ console.log('Total:', checkout.amounts.total);
745
+ console.log('Items:', checkout.itemCount);
746
+ console.log('Is gift:', checkout.isGift);
747
+ console.log('Has age verification:', checkout.hasAgeVerify);
748
+ console.log('Has promo code:', checkout.hasPromoCode);
749
+ console.log('Has gift cards:', checkout.hasGiftCards);
750
+
751
+ // Configure checkout options
752
+ await actions.checkout.toggleBillingSameAsShipping(true);
753
+ actions.checkout.toggleMarketingPreferences('canEmail', true);
754
+ ```
755
+
756
+ See [`docs/ACTIONS.md`](docs/ACTIONS.md) for complete action reference with business use cases.
757
+
758
+ ## 📡 Events
759
+
760
+ The SDK emits real-time events for all user interactions. Listen to these events to trigger custom behavior:
761
+
762
+ ```js
763
+ // Listen for specific events
764
+ window.addEventListener('lce:actions.product_add_to_cart', function(event) {
765
+ const product = event.detail.data;
766
+ console.log('Added to cart:', product.productName);
767
+
768
+ // Your custom logic here
769
+ analytics.track('Product Added', {
770
+ product: product.productName,
771
+ price: product.price
772
+ });
773
+ });
774
+
775
+ // Or use the helper methods (available after initialization)
776
+ window.elements.onAllForms((data, metadata) => {
777
+ console.log('Form Event', { data, metadata });
778
+ });
779
+
780
+ window.elements.onAllActions((data, metadata) => {
781
+ console.log('Action Event', { data, metadata });
782
+ });
783
+ ```
784
+
785
+ ### Available Events
786
+
787
+ #### Product Events
788
+ - `lce:actions.product_loaded` - Product component loaded
789
+ - `lce:actions.product_add_to_cart` - Item added to cart
790
+ - `lce:actions.product_quantity_increase` - Quantity increased
791
+ - `lce:actions.product_quantity_decrease` - Quantity decreased
792
+ - `lce:actions.product_size_changed` - Product size/variant changed
793
+ - `lce:actions.product_fulfillment_type_changed` - Delivery method changed
794
+
795
+ #### Cart Events
796
+ - `lce:actions.cart_opened` - Cart displayed
797
+ - `lce:actions.cart_closed` - Cart hidden
798
+ - `lce:actions.cart_updated` - Cart contents changed
799
+ - `lce:actions.cart_item_added` - Item added
800
+ - `lce:actions.cart_item_removed` - Item removed
801
+ - `lce:actions.cart_reset` - Cart cleared
802
+
803
+ #### Checkout Events
804
+ - `lce:actions.checkout_opened` - Checkout started
805
+ - `lce:actions.checkout_closed` - Checkout abandoned
806
+ - `lce:actions.checkout_submit_started` - Order submission began
807
+ - `lce:actions.checkout_submit_completed` - Order completed successfully
808
+ - `lce:actions.checkout_submit_failed` - Order failed
809
+ - `lce:actions.checkout_customer_information_updated` - Customer info entered
810
+ - `lce:actions.checkout_billing_information_updated` - Billing info entered
811
+
812
+ #### Address Events
813
+ - `lce:actions.address_updated` - Address information changed
814
+ - `lce:actions.address_cleared` - Address removed
815
+
816
+ See [`docs/EVENTS.md`](docs/EVENTS.md) for complete event reference with implementation examples.
817
+
818
+ ## ⚙️ Configuration
819
+
820
+ Configure the SDK when initializing:
821
+
822
+ ```js
823
+ const client = await Elements('YOUR_API_KEY', {
824
+ env: 'production', // 'local' | 'development' | 'staging' | 'production'
825
+ enableDebugging: false, // Enable console logging (development only)
826
+ isBuilder: false, // Enable builder methods (development only)
827
+ customTheme: { /* theme overrides */ },
828
+ proxy: { /* proxy configuration */ }
829
+ });
830
+ ```
831
+
832
+ ### Environment Options
833
+
834
+ - **`production`**: Live environment for customer-facing sites
835
+ - **`staging`**: Pre-production testing environment
836
+ - **`development`**: Development environment with additional debugging
837
+ - **`local`**: Local development environment
838
+
839
+ ### Auto-init Data Attributes
840
+
841
+ When using auto-initialization, configure via data attributes:
842
+
843
+ - `data-liquid-commerce-elements`: Required flag to enable auto-init
844
+ - `data-token`: Your API key (required)
845
+ - `data-env`: Environment (defaults to production)
846
+ - `data-cart-id`: Container ID for cart button
847
+ - `data-enable-debugging`: Enable debugging mode
848
+ - `data-container-X` / `data-product-X`: Product mapping pairs
849
+
850
+ ## 🎨 Themes & Customization
851
+
852
+ Customize the appearance of SDK components using the theme system:
853
+
854
+ ```js
855
+ const client = await Elements('YOUR_API_KEY', {
856
+ env: 'production',
857
+ customTheme: {
858
+ global: {
859
+ colors: {
860
+ primary: '#007bff',
861
+ secondary: '#6c757d'
862
+ },
863
+ typography: {
864
+ fontFamily: 'Roboto, sans-serif',
865
+ fontSize: '16px'
866
+ }
867
+ },
868
+ product: {
869
+ layout: {
870
+ imagePosition: 'left',
871
+ showDescription: true
872
+ },
873
+ colors: {
874
+ price: '#28a745',
875
+ sale: '#dc3545'
876
+ }
877
+ },
878
+ cart: {
879
+ layout: {
880
+ showRetailerLogos: true,
881
+ compactMode: false
882
+ }
883
+ },
884
+ checkout: {
885
+ layout: {
886
+ singlePage: true,
887
+ showOrderSummary: true
888
+ }
889
+ }
890
+ }
891
+ });
892
+ ```
893
+
894
+ In builder mode, themes can be updated dynamically:
895
+
896
+ ```js
897
+ // Update themes in real-time (builder mode only)
898
+ await client.builder.updateComponentGlobalConfigs({
899
+ colors: { primary: '#ff6b6b' }
900
+ });
901
+
902
+ await client.builder.updateProductComponent({
903
+ layout: { imagePosition: 'right' }
904
+ });
905
+ ```
906
+
907
+ ## 🔒 Proxy Configuration
908
+
909
+ Route API requests through your server to avoid ad blockers:
910
+
911
+ ```js
912
+ const client = await Elements('YOUR_API_KEY', {
913
+ env: 'production',
914
+ proxy: {
915
+ baseUrl: 'https://yourdomain.com/api/liquidcommerce',
916
+ headers: {
917
+ 'X-Custom-Header': 'value'
918
+ }
919
+ }
920
+ });
921
+ ```
922
+
923
+ The SDK automatically handles routing and required headers. See [`docs/PROXY.md`](docs/PROXY.md) for complete proxy setup guide with Next.js examples.
924
+
925
+ ## 📚 Documentation
926
+
927
+ For detailed guides and advanced usage:
928
+
929
+ - [`docs/ACTIONS.md`](docs/ACTIONS.md) - Complete actions reference with business use cases
930
+ - [`docs/EVENTS.md`](docs/EVENTS.md) - Events guide with implementation examples
931
+ - [`docs/BROWSER_SUPPORT.md`](docs/BROWSER_SUPPORT.md) - Detailed browser compatibility
932
+ - [`docs/PROXY.md`](docs/PROXY.md) - Proxy configuration for ad blocker avoidance
933
+
934
+ ## 🏷️ Versioning
935
+
936
+ This project uses Semantic Versioning. The SDK is available in two environments:
937
+
938
+ ### Beta Environment
939
+ - Branch: `beta`
940
+ - Base URL: `https://assets-elements.liquidcommerce.us/all/beta/`
941
+ - Purpose: Testing and pre-release features
942
+
943
+ ### Production Environment
944
+ - Branch: `main`
945
+ - Base URL: `https://assets-elements.liquidcommerce.us/all/`
946
+ - Purpose: Stable releases for production use
947
+
948
+ ### CDN Path Structure
949
+
950
+ ```
951
+ elements-sdk/
952
+ └── all/
953
+ ├── beta/
954
+ │ ├── 1.2.3/elements.js
955
+ │ ├── 1.2.4/elements.js
956
+ │ └── elements.js (beta latest)
957
+ ├── 1.2.2/elements.js (production)
958
+ ├── 1.2.3/elements.js (production)
959
+ └── elements.js (production latest)
960
+ ```
961
+
962
+ ## 🎭 Demo Pages
963
+
964
+ The SDK includes ready-to-use demo pages in the `demo/` folder that showcase different implementation approaches:
965
+
966
+ ### Simple Demo (`demo/simple.html`)
967
+
968
+ Demonstrates **auto-initialization** using data attributes - the easiest way to get started:
969
+
970
+ ```html
971
+ <!-- Auto-init with data attributes -->
972
+ <script
973
+ data-liquid-commerce-elements
974
+ data-token="YOUR_API_KEY"
975
+ data-env="development"
976
+ data-enable-debugging
977
+ src="../umd/elements.js"
978
+ ></script>
979
+ ```
980
+
981
+ **Features shown:**
982
+ - Auto-initialization with data attributes
983
+ - Multiple product mapping methods (data attributes, JSON script, annotated elements)
984
+ - Event listening for actions and forms
985
+ - Basic container setup for products, cart, and checkout
986
+
987
+ **Best for:** Quick prototyping, simple integrations, getting familiar with the SDK
988
+
989
+ ### Advanced Demo (`demo/advanced.html`)
990
+
991
+ Demonstrates **programmatic initialization** for full control:
992
+
993
+ ```javascript
994
+ const client = await window.Elements(API_KEY, {
995
+ env: "development",
996
+ enableDebugging: true,
997
+ customTheme: { /* theme config */ }
998
+ });
999
+
1000
+ // Programmatic component injection
1001
+ client.buttons.openCart("buttons-container");
1002
+ await client.injectProductElement([
1003
+ { containerId: "pdp-container", identifier: '00619947000020' }
1004
+ ]);
1005
+ await client.injectCheckoutElement("checkout-container");
1006
+ ```
1007
+
1008
+ **Features shown:**
1009
+ - Manual client initialization with full configuration
1010
+ - Programmatic component injection
1011
+ - Builder methods for theme updates (commented examples)
1012
+ - Advanced event handling
1013
+ - Dynamic theme updates
1014
+
1015
+ **Best for:** Complex integrations, custom workflows, theme customization, production implementations
1016
+
1017
+ ### Running the Demos
1018
+
1019
+ 1. **Clone the repository**
1020
+ 2. **Open demo files** in your browser
1021
+ 3. **Update API keys** with your own credentials
1022
+ 4. **Modify environment** settings as needed (`development`, `staging`, `production`)
1023
+
1024
+ The demos use local UMD builds (`../umd/elements.js`) but can be easily switched to CDN URLs for testing.
1025
+
1026
+ ## 🛠️ Development Scripts
1027
+
1028
+ For SDK development and maintenance, the following npm/pnpm scripts are available:
1029
+
1030
+ ### Build Commands
1031
+
1032
+ **`build`** - Production build
1033
+ ```bash
1034
+ pnpm run build
1035
+ ```
1036
+ - Creates optimized ESM and UMD bundles for production
1037
+ - Generates TypeScript declarations
1038
+ - Enables minification and compression
1039
+ - Removes console logs and debugging code
1040
+ - **Output:** `dist/index.esm.js` (ESM) + `umd/elements.js` (UMD)
1041
+
1042
+ **`build:dev`** - Development build
1043
+ ```bash
1044
+ pnpm run build:dev
1045
+ ```
1046
+ - Creates unminified bundles with source maps
1047
+ - Preserves console logs and debugging code
1048
+ - Faster build times for development
1049
+ - **Output:** Same as build but with debugging enabled
1050
+
1051
+ **`dev`** - Development with watch mode
1052
+ ```bash
1053
+ pnpm run dev
1054
+ ```
1055
+ - Same as `build:dev` but watches for file changes
1056
+ - Automatically rebuilds on source code changes
1057
+ - **Best for:** Active development
1058
+
1059
+ ### Code Quality Commands
1060
+
1061
+ **`lint`** - Lint and auto-fix code
1062
+ ```bash
1063
+ pnpm run lint
1064
+ ```
1065
+ - Uses Biome to lint TypeScript/JavaScript files
1066
+ - Automatically fixes fixable issues
1067
+ - Enforces code style and catches common errors
1068
+
1069
+ **`format`** - Format code
1070
+ ```bash
1071
+ pnpm run format
1072
+ ```
1073
+ - Uses Biome to format all source files
1074
+ - Ensures consistent code formatting
1075
+ - Applies formatting rules defined in `biome.json`
1076
+
1077
+ **`check`** - Combined linting and formatting
1078
+ ```bash
1079
+ pnpm run check
1080
+ ```
1081
+ - Runs both linting and formatting in one command
1082
+ - Auto-fixes issues and formats code
1083
+ - **Recommended before commits**
1084
+
1085
+ **`fl`** - Format, lint, and build (Fast Loop)
1086
+ ```bash
1087
+ pnpm run fl
1088
+ ```
1089
+ - Combines `check` + `build:dev`
1090
+ - Complete code quality check + development build
1091
+ - **Perfect for:** Pre-commit workflow
1092
+
1093
+ ### Maintenance Commands
1094
+
1095
+ **`clean`** - Clean build outputs
1096
+ ```bash
1097
+ pnpm run clean
1098
+ ```
1099
+ - Removes `dist/` and `umd/` directories
1100
+ - **Use when:** Build artifacts are corrupted
1101
+
1102
+ **`clean:hard`** - Complete reset
1103
+ ```bash
1104
+ pnpm run clean:hard
1105
+ ```
1106
+ - Removes build outputs AND `node_modules/`
1107
+ - Reinstalls all dependencies with `pnpm install`
1108
+ - Runs a fresh production build
1109
+ - **Use when:** Dependency issues or major updates
1110
+
1111
+ **`changelog`** - Generate changelog
1112
+ ```bash
1113
+ pnpm run changelog
1114
+ ```
1115
+ - Generates `CHANGELOG.md` from conventional commits
1116
+ - Uses Angular commit convention
1117
+ - **Use when:** Preparing releases
1118
+
1119
+ ### Build Configuration
1120
+
1121
+ The build system uses **Rollup** with different configurations:
1122
+
1123
+ #### ESM Build (`dist/index.esm.js`)
1124
+ - **Target:** Modern bundlers (Vite, Webpack, etc.)
1125
+ - **Format:** ES Modules
1126
+ - **Optimizations:** Tree shaking, modern syntax
1127
+ - **Use case:** NPM package imports
1128
+
1129
+ #### UMD Build (`umd/elements.js`)
1130
+ - **Target:** Direct browser usage
1131
+ - **Format:** Universal Module Definition
1132
+ - **Global:** `window.LiquidCommerceElements`
1133
+ - **Optimizations:** Maximum browser compatibility
1134
+ - **Use case:** CDN distribution, `<script>` tags
1135
+
1136
+ #### Development vs Production
1137
+ - **Development:** Source maps, preserved logging, faster builds
1138
+ - **Production:** Minified, compressed, optimized for size
1139
+
1140
+ ### Recommended Workflows
1141
+
1142
+ **Development Workflow:**
1143
+ ```bash
1144
+ # Start development
1145
+ pnpm run dev
1146
+
1147
+ # Before committing
1148
+ pnpm run fl
1149
+ ```
1150
+
1151
+ **Release Workflow:**
1152
+ ```bash
1153
+ # Clean and build for release
1154
+ pnpm run clean:hard
1155
+
1156
+ # Generate changelog
1157
+ pnpm run changelog
1158
+
1159
+ # Build is run automatically on publish
1160
+ ```
1161
+
1162
+ **Troubleshooting:**
1163
+ ```bash
1164
+ # If builds are failing
1165
+ pnpm run clean:hard
1166
+
1167
+ # For code quality issues
1168
+ pnpm run check
1169
+ ```
1170
+
1171
+ ## 💬 Support
1172
+
1173
+ If you need help with your API key, environment selection, or implementation, contact your LiquidCommerce representative.
1174
+
1175
+ ---
1176
+
1177
+ <div align="center">
1178
+
1179
+ **Built with ❤️ by the LiquidCommerce Team**
1180
+
1181
+ [Actions Reference](docs/ACTIONS.md) • [Events Guide](docs/EVENTS.md) • [Browser Support](docs/BROWSER_SUPPORT.md) • [Proxy Setup](docs/PROXY.md)
1182
+
1183
+ </div>