@liquidcommerce/elements-sdk 2.6.0-beta.10 → 2.6.0-beta.101

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 (262) hide show
  1. package/README.md +99 -2518
  2. package/dist/index.checkout.esm.js +17850 -0
  3. package/dist/index.esm.js +25821 -20795
  4. package/dist/ssr-stub.checkout.esm.js +18 -0
  5. package/dist/ssr-stub.esm.js +270 -0
  6. package/dist/types/auto-initialize/checkout.d.ts +2 -0
  7. package/dist/types/auto-initialize/shared-utils.d.ts +50 -0
  8. package/dist/types/{elements-base-client.d.ts → clients/base.d.ts} +15 -2
  9. package/dist/types/clients/builder.d.ts +3 -0
  10. package/dist/types/clients/checkout.d.ts +6 -0
  11. package/dist/types/{elements-client-helper.d.ts → clients/helpers.d.ts} +2 -1
  12. package/dist/types/clients/main.d.ts +3 -0
  13. package/dist/types/constants/core.constant.d.ts +2 -6
  14. package/dist/types/core/a11y/announcer.service.d.ts +16 -0
  15. package/dist/types/core/a11y/focus-manager.service.d.ts +21 -0
  16. package/dist/types/core/a11y/focusable.d.ts +5 -0
  17. package/dist/types/core/a11y/glyph-button.d.ts +8 -0
  18. package/dist/types/core/a11y/index.d.ts +5 -0
  19. package/dist/types/core/a11y/single-select.d.ts +16 -0
  20. package/dist/types/core/api/api-client.service.d.ts +19 -18
  21. package/dist/types/core/api/api-result.d.ts +19 -0
  22. package/dist/types/core/api/auth-client.service.d.ts +37 -13
  23. package/dist/types/core/api/http-client.service.d.ts +0 -8
  24. package/dist/types/core/base-component.service.d.ts +4 -1
  25. package/dist/types/core/client/actions/base-action.service.d.ts +22 -0
  26. package/dist/types/core/client/actions/client-address-action.service.d.ts +18 -0
  27. package/dist/types/core/client/actions/client-cart-action.service.d.ts +38 -0
  28. package/dist/types/core/client/actions/client-checkout-action.service.d.ts +69 -0
  29. package/dist/types/core/client/actions/client-product-action.service.d.ts +15 -0
  30. package/dist/types/core/client/client-action.service.d.ts +6 -74
  31. package/dist/types/core/client/client-config.service.d.ts +8 -5
  32. package/dist/types/core/google-tag-manager.service.d.ts +3 -1
  33. package/dist/types/core/logger/logger.service.d.ts +1 -1
  34. package/dist/types/core/pubsub/interfaces/address.interface.d.ts +3 -0
  35. package/dist/types/core/pubsub/interfaces/cart.interface.d.ts +1 -1
  36. package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +36 -51
  37. package/dist/types/core/pubsub/interfaces/core.interface.d.ts +11 -6
  38. package/dist/types/core/pubsub/pubsub.service.d.ts +1 -2
  39. package/dist/types/core/singleton-manager.service.d.ts +12 -8
  40. package/dist/types/core/store/interfaces/cart.interface.d.ts +2 -3
  41. package/dist/types/core/store/interfaces/checkout.interface.d.ts +18 -108
  42. package/dist/types/core/store/interfaces/core.interface.d.ts +12 -2
  43. package/dist/types/core/store/interfaces/metadata.interface.d.ts +11 -0
  44. package/dist/types/core/store/interfaces/product-list.interface.d.ts +30 -0
  45. package/dist/types/core/store/interfaces/product.interface.d.ts +1 -0
  46. package/dist/types/core/store/store.constant.d.ts +5 -0
  47. package/dist/types/core/store/store.service.d.ts +1 -0
  48. package/dist/types/core/telemetry/telemetry.service.d.ts +1 -0
  49. package/dist/types/enums/core.enum.d.ts +39 -1
  50. package/dist/types/enums/index.d.ts +0 -1
  51. package/dist/types/index.checkout.d.ts +8 -0
  52. package/dist/types/index.checkout.umd.d.ts +4 -0
  53. package/dist/types/index.d.ts +8 -3
  54. package/dist/types/interfaces/api/cart.interface.d.ts +12 -7
  55. package/dist/types/interfaces/api/checkout.interface.d.ts +239 -0
  56. package/dist/types/interfaces/api/index.d.ts +5 -0
  57. package/dist/types/interfaces/api/product-list.interface.d.ts +14 -5
  58. package/dist/types/interfaces/api/product.interface.d.ts +10 -4
  59. package/dist/types/interfaces/client.interface.d.ts +72 -0
  60. package/dist/types/interfaces/component.interface.d.ts +7 -0
  61. package/dist/types/interfaces/config.interface.d.ts +40 -0
  62. package/dist/types/interfaces/configs/address.interface.d.ts +1 -1
  63. package/dist/types/interfaces/configs/cart.interface.d.ts +1 -1
  64. package/dist/types/interfaces/configs/checkout.interface.d.ts +2 -1
  65. package/dist/types/interfaces/configs/global.interface.d.ts +9 -3
  66. package/dist/types/interfaces/configs/index.d.ts +1 -0
  67. package/dist/types/interfaces/configs/product-list.interface.d.ts +49 -0
  68. package/dist/types/interfaces/configs/product.interface.d.ts +3 -1
  69. package/dist/types/interfaces/injection.interface.d.ts +49 -0
  70. package/dist/types/modules/address/address-display.component.d.ts +3 -1
  71. package/dist/types/modules/address/address-input.component.d.ts +10 -1
  72. package/dist/types/modules/address/address.command.d.ts +2 -1
  73. package/dist/types/modules/address/styles/register-styles.d.ts +1 -0
  74. package/dist/types/modules/cart/cart.commands.d.ts +4 -4
  75. package/dist/types/modules/cart/components/cart-body.component.d.ts +1 -0
  76. package/dist/types/modules/cart/components/cart-item-quantity-price.component.d.ts +5 -0
  77. package/dist/types/modules/cart/components/cart-item.component.d.ts +6 -0
  78. package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
  79. package/dist/types/modules/checkout/checkout.commands.d.ts +27 -10
  80. package/dist/types/modules/checkout/checkout.component.d.ts +2 -0
  81. package/dist/types/modules/checkout/components/checkout-billing.component.d.ts +2 -2
  82. package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +5 -0
  83. package/dist/types/modules/checkout/components/checkout-header.component.d.ts +1 -0
  84. package/dist/types/modules/checkout/components/checkout-item-quantity.component.d.ts +4 -0
  85. package/dist/types/modules/checkout/components/checkout-items.component.d.ts +4 -3
  86. package/dist/types/modules/checkout/components/checkout-payment.component.d.ts +2 -1
  87. package/dist/types/modules/checkout/components/checkout-place-order-button.component.d.ts +2 -0
  88. package/dist/types/modules/checkout/components/checkout-presale-countdown.component.d.ts +15 -1
  89. package/dist/types/modules/checkout/components/checkout-presale-expired.component.d.ts +7 -1
  90. package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
  91. package/dist/types/modules/checkout/components/checkout-tips.component.d.ts +2 -2
  92. package/dist/types/modules/checkout/components/promo-pc-gc.component.d.ts +0 -2
  93. package/dist/types/modules/checkout/constant.d.ts +3 -0
  94. package/dist/types/modules/checkout/styles/register-styles.d.ts +1 -0
  95. package/dist/types/modules/product/components/components.d.ts +6 -1
  96. package/dist/types/modules/product/components/product-add-to-cart-section.component.d.ts +7 -1
  97. package/dist/types/modules/product/components/product-description.component.d.ts +1 -0
  98. package/dist/types/modules/product/components/product-drawer.component.d.ts +6 -0
  99. package/dist/types/modules/product/components/product-image-carousel.component.d.ts +5 -0
  100. package/dist/types/modules/product/components/product-options.component.d.ts +2 -1
  101. package/dist/types/modules/product/components/product-retailers-carousel.component.d.ts +4 -0
  102. package/dist/types/modules/product/components/product-retailers-popup-list.component.d.ts +10 -2
  103. package/dist/types/modules/product/product.commands.d.ts +5 -5
  104. package/dist/types/modules/product/styles/register-styles.d.ts +1 -0
  105. package/dist/types/modules/product-list/components/card-components/index.d.ts +5 -0
  106. package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +9 -0
  107. package/dist/types/modules/product-list/components/card-components/product-button.d.ts +11 -0
  108. package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +14 -0
  109. package/dist/types/modules/product-list/components/card-components/product-quantity-selector.d.ts +11 -0
  110. package/dist/types/modules/product-list/components/card-components/product-sizes-list.d.ts +14 -0
  111. package/dist/types/modules/product-list/components/filter-components/index.d.ts +7 -0
  112. package/dist/types/modules/product-list/components/filter-components/product-list-apply-filter-button.d.ts +1 -0
  113. package/dist/types/modules/product-list/components/filter-components/product-list-chip.d.ts +5 -0
  114. package/dist/types/modules/product-list/components/filter-components/product-list-filters-chips.d.ts +13 -0
  115. package/dist/types/modules/product-list/components/filter-components/product-list-fulfillment-filter.d.ts +15 -0
  116. package/dist/types/modules/product-list/components/{product-list-filters-subcomponents/product-list-price-filter.components.d.ts → filter-components/product-list-price-filter.d.ts} +1 -1
  117. package/dist/types/modules/product-list/components/filter-components/product-list-toggle-filters.d.ts +7 -0
  118. package/dist/types/modules/product-list/components/index.d.ts +6 -2
  119. package/dist/types/modules/product-list/components/product-list-card-loading.component.d.ts +3 -1
  120. package/dist/types/modules/product-list/components/product-list-card.component.d.ts +36 -31
  121. package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +12 -0
  122. package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +56 -36
  123. package/dist/types/modules/product-list/components/product-list-product-engraving-lines.component.d.ts +22 -0
  124. package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +53 -0
  125. package/dist/types/modules/product-list/components/product-list-search.component.d.ts +25 -0
  126. package/dist/types/modules/product-list/product-list-filter.utils.d.ts +8 -0
  127. package/dist/types/modules/product-list/product-list-query-params.utils.d.ts +3 -0
  128. package/dist/types/modules/product-list/product-list.commands.d.ts +22 -7
  129. package/dist/types/modules/product-list/product-list.component.d.ts +17 -47
  130. package/dist/types/modules/product-list/product-list.constants.d.ts +38 -0
  131. package/dist/types/modules/product-list/product-list.interface.d.ts +16 -28
  132. package/dist/types/modules/product-list/styles/product-list-card.style.d.ts +1 -0
  133. package/dist/types/modules/product-list/styles/product-list-filters.style.d.ts +1 -0
  134. package/dist/types/modules/product-list/styles/register-styles.d.ts +1 -0
  135. package/dist/types/modules/theme-provider/constants/component-groupings.d.ts +1 -0
  136. package/dist/types/modules/theme-provider/constants/css-variable-mappings.d.ts +1 -1
  137. package/dist/types/modules/theme-provider/services/style-registry.service.d.ts +16 -0
  138. package/dist/types/modules/theme-provider/services/stylesheet-generator.service.d.ts +0 -1
  139. package/dist/types/modules/theme-provider/styles/register-styles.d.ts +1 -0
  140. package/dist/types/modules/theme-provider/theme-provider.service.d.ts +2 -2
  141. package/dist/types/modules/ui-components/alert/alert.component.d.ts +1 -1
  142. package/dist/types/modules/ui-components/buttons/buttons-open-cart.component.d.ts +5 -0
  143. package/dist/types/modules/ui-components/drawer/drawer.component.d.ts +15 -0
  144. package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +8 -1
  145. package/dist/types/modules/ui-components/engraving/engraving-view.component.d.ts +7 -1
  146. package/dist/types/modules/ui-components/input/index.d.ts +0 -1
  147. package/dist/types/modules/ui-components/input/input.component.d.ts +14 -1
  148. package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
  149. package/dist/types/modules/ui-components/promo-code-ticker/promo-code-ticker.component.d.ts +1 -1
  150. package/dist/types/modules/ui-components/ui.commands.d.ts +7 -1
  151. package/dist/types/ssr/stub.checkout.d.ts +6 -0
  152. package/dist/types/ssr/stub.d.ts +10 -0
  153. package/dist/types/static/icon/arrow-right.icon.d.ts +1 -1
  154. package/dist/types/static/icon/bag.icon.d.ts +1 -1
  155. package/dist/types/static/icon/check.icon.d.ts +2 -0
  156. package/dist/types/static/icon/checkbox.icon.d.ts +1 -1
  157. package/dist/types/static/icon/chevron-down.icon.d.ts +1 -1
  158. package/dist/types/static/icon/chevron-left.icon.d.ts +1 -1
  159. package/dist/types/static/icon/chevron-up.icon.d.ts +1 -1
  160. package/dist/types/static/icon/close.icon.d.ts +1 -1
  161. package/dist/types/static/icon/error-info.icon.d.ts +1 -1
  162. package/dist/types/static/icon/filter.icon.d.ts +1 -1
  163. package/dist/types/static/icon/icon.a11y.d.ts +1 -0
  164. package/dist/types/static/icon/icon.types.d.ts +1 -0
  165. package/dist/types/static/icon/index.d.ts +2 -0
  166. package/dist/types/static/icon/info.icon.d.ts +1 -1
  167. package/dist/types/static/icon/loading-spinner.icon.d.ts +1 -1
  168. package/dist/types/static/icon/search.icon.d.ts +1 -1
  169. package/dist/types/static/icon/success.icon.d.ts +1 -1
  170. package/dist/types/static/icon/trash.icon.d.ts +1 -1
  171. package/dist/types/static/icon/warning.icon.d.ts +1 -1
  172. package/dist/types/utils/dom-compat.d.ts +2 -0
  173. package/dist/types/utils/format.d.ts +5 -14
  174. package/dist/types/utils/image-bg-removal.d.ts +3 -0
  175. package/dist/types/utils/product-selection.d.ts +16 -0
  176. package/dist/types/utils/product.d.ts +15 -0
  177. package/dist/types/utils/timezone.d.ts +6 -0
  178. package/docs/v1/README.md +213 -0
  179. package/docs/v1/api/actions/address-actions.md +286 -0
  180. package/docs/v1/api/actions/cart-actions.md +364 -0
  181. package/docs/v1/api/actions/checkout-actions.md +527 -0
  182. package/docs/v1/api/actions/product-actions.md +204 -0
  183. package/docs/v1/api/client.md +596 -0
  184. package/docs/v1/api/configuration.md +555 -0
  185. package/docs/v1/api/injection-methods.md +292 -0
  186. package/docs/v1/api/typescript-types.md +423 -0
  187. package/docs/v1/api/ui-helpers.md +200 -0
  188. package/docs/v1/examples/advanced-patterns.md +199 -0
  189. package/docs/v1/examples/checkout-flow.md +90 -0
  190. package/docs/v1/examples/custom-theming.md +63 -0
  191. package/docs/v1/examples/multi-product-page.md +90 -0
  192. package/docs/v1/examples/simple-product-page.md +89 -0
  193. package/docs/v1/getting-started/concepts.md +521 -0
  194. package/docs/v1/getting-started/installation.md +349 -0
  195. package/docs/v1/getting-started/quick-start.md +410 -0
  196. package/docs/v1/guides/accessibility.md +173 -0
  197. package/docs/v1/guides/address-component.md +435 -0
  198. package/docs/v1/guides/best-practices.md +365 -0
  199. package/docs/v1/guides/cart-component.md +757 -0
  200. package/docs/v1/guides/checkout-component.md +670 -0
  201. package/docs/v1/guides/events.md +939 -0
  202. package/docs/v1/guides/product-component.md +735 -0
  203. package/docs/v1/guides/product-list-component.md +630 -0
  204. package/docs/v1/guides/theming.md +228 -0
  205. package/docs/v1/integration/angular.md +39 -0
  206. package/docs/v1/integration/laravel.md +41 -0
  207. package/docs/v1/integration/nextjs.md +69 -0
  208. package/docs/v1/integration/proxy-setup.md +106 -0
  209. package/docs/v1/integration/react.md +64 -0
  210. package/docs/v1/integration/vanilla-js.md +84 -0
  211. package/docs/v1/integration/vue.md +58 -0
  212. package/docs/v1/reference/analytics.md +108 -0
  213. package/docs/v1/reference/browser-support.md +47 -0
  214. package/docs/v1/reference/error-handling.md +83 -0
  215. package/docs/v1/reference/performance.md +52 -0
  216. package/docs/v1/reference/telemetry.md +85 -0
  217. package/docs/v1/reference/troubleshooting.md +135 -0
  218. package/package.json +69 -44
  219. package/dist/types/elements-builder-client.d.ts +0 -2
  220. package/dist/types/elements-client.d.ts +0 -2
  221. package/dist/types/enums/cloud.enum.d.ts +0 -97
  222. package/dist/types/interfaces/cloud/checkout.interface.d.ts +0 -218
  223. package/dist/types/interfaces/cloud/core.interface.d.ts +0 -22
  224. package/dist/types/interfaces/cloud/index.d.ts +0 -3
  225. package/dist/types/interfaces/cloud/retailer.interface.d.ts +0 -67
  226. package/dist/types/interfaces/cloud/user.interface.d.ts +0 -100
  227. package/dist/types/interfaces/core.interface.d.ts +0 -111
  228. package/dist/types/modules/checkout/components/checkout.type.d.ts +0 -4
  229. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/index.d.ts +0 -6
  230. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-apply-filter-button.component.d.ts +0 -1
  231. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-delivery-options-filter.components.d.ts +0 -16
  232. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-search.component.d.ts +0 -16
  233. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-toggle-filters.components.d.ts +0 -18
  234. package/dist/types/modules/theme-provider/styles/address/index.d.ts +0 -1
  235. package/dist/types/modules/theme-provider/styles/cart/index.d.ts +0 -1
  236. package/dist/types/modules/theme-provider/styles/checkout/index.d.ts +0 -1
  237. package/dist/types/modules/theme-provider/styles/product/index.d.ts +0 -3
  238. package/dist/types/modules/theme-provider/styles/product-list/index.d.ts +0 -1
  239. package/dist/types/modules/theme-provider/styles/ui/index.d.ts +0 -3
  240. package/dist/types/modules/ui-components/input/birthdate-input.component.d.ts +0 -53
  241. package/dist/types/utils/helper.d.ts +0 -28
  242. package/docs/ACTIONS.md +0 -1300
  243. package/docs/BROWSER_SUPPORT.md +0 -279
  244. package/docs/CONFIGURATION.md +0 -853
  245. package/docs/DOCUMENTATION_INDEX.md +0 -311
  246. package/docs/EVENTS.md +0 -798
  247. package/docs/PROXY.md +0 -228
  248. package/docs/THEMING.md +0 -592
  249. package/docs/TROUBLESHOOTING.md +0 -793
  250. package/umd/elements.js +0 -1
  251. /package/dist/types/{auto-initialize.d.ts → auto-initialize/main.d.ts} +0 -0
  252. /package/dist/types/modules/{theme-provider/styles/address → address/styles}/address.style.d.ts +0 -0
  253. /package/dist/types/modules/{theme-provider/styles/cart → cart/styles}/cart.style.d.ts +0 -0
  254. /package/dist/types/modules/{theme-provider/styles/checkout → checkout/styles}/checkout.style.d.ts +0 -0
  255. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/image-carousel.style.d.ts +0 -0
  256. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/product.style.d.ts +0 -0
  257. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/retailers.style.d.ts +0 -0
  258. /package/dist/types/modules/product-list/components/{product-list-filters-subcomponents/product-list-checkbox-filter.components.d.ts → filter-components/product-list-checkbox-filter.d.ts} +0 -0
  259. /package/dist/types/modules/{theme-provider/styles/product-list → product-list/styles}/product-list.style.d.ts +0 -0
  260. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/drawer.style.d.ts +0 -0
  261. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/loading.style.d.ts +0 -0
  262. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/promo-code-ticker.style.d.ts +0 -0
@@ -0,0 +1,89 @@
1
+ # Simple Product Page
2
+
3
+ A minimal, production-ready product page using the CDN build with a single Product component and the default cart drawer.
4
+
5
+ ## What You'll Build
6
+
7
+ - One product component
8
+ - Optional cart button with item count
9
+ - Default cart and checkout flow
10
+
11
+ ## Prerequisites
12
+
13
+ - LiquidCommerce API key
14
+ - One product identifier (UPC or grouping ID)
15
+
16
+ ## HTML (CDN)
17
+
18
+ ```html
19
+ <!DOCTYPE html>
20
+ <html lang="en">
21
+ <head>
22
+ <meta charset="UTF-8" />
23
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
24
+ <title>Simple Product Page</title>
25
+
26
+ <script
27
+ defer
28
+ data-liquid-commerce-elements
29
+ data-token="YOUR_API_KEY"
30
+ data-env="production"
31
+ data-container-1="product"
32
+ data-product-1="00619947000020"
33
+ data-cart-badge-button="header-cart"
34
+ type="text/javascript"
35
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
36
+ ></script>
37
+
38
+ <style>
39
+ body {
40
+ font-family: Arial, sans-serif;
41
+ margin: 0;
42
+ padding: 0;
43
+ background: #f7f7f7;
44
+ }
45
+ header {
46
+ background: #fff;
47
+ padding: 16px 24px;
48
+ box-shadow: 0 2px 6px rgba(0,0,0,0.08);
49
+ display: flex;
50
+ justify-content: space-between;
51
+ align-items: center;
52
+ }
53
+ main {
54
+ max-width: 1100px;
55
+ margin: 24px auto;
56
+ padding: 0 24px;
57
+ }
58
+ #product {
59
+ background: #fff;
60
+ border-radius: 10px;
61
+ padding: 20px;
62
+ min-height: 600px;
63
+ }
64
+ </style>
65
+ </head>
66
+ <body>
67
+ <header>
68
+ <h1>Premium Spirits</h1>
69
+ <div id="header-cart"></div>
70
+ </header>
71
+
72
+ <main>
73
+ <div id="product"></div>
74
+ </main>
75
+ </body>
76
+ </html>
77
+ ```
78
+
79
+ ## What to Tweak Next
80
+
81
+ - Change the product identifier: `data-product-1="YOUR_PRODUCT_ID"`
82
+ - Add a second product (see [Multi-Product Page](./multi-product-page.md))
83
+ - Customize styling via theming (see [Theming Guide](../guides/theming.md))
84
+
85
+ ## Related Docs
86
+
87
+ - [Product Component](../guides/product-component.md)
88
+ - [Cart Component](../guides/cart-component.md)
89
+ - [Quick Start](../getting-started/quick-start.md)
@@ -0,0 +1,521 @@
1
+ # Core Concepts
2
+
3
+ Understanding these fundamental concepts will help you work effectively with the LiquidCommerce Elements SDK.
4
+
5
+ ## Web Components Architecture
6
+
7
+ The Elements SDK is built using **Web Components**, a set of web platform APIs that allow you to create custom, reusable HTML elements.
8
+
9
+ ### What Are Web Components?
10
+
11
+ Web Components are native browser features that provide:
12
+
13
+ 1. **Custom Elements** - Define your own HTML tags
14
+ 2. **Shadow DOM** - Encapsulated styling and markup
15
+ 3. **HTML Templates** - Reusable DOM fragments
16
+
17
+ ### Why Web Components?
18
+
19
+ **Framework Agnostic**
20
+ Works with any JavaScript framework or plain HTML:
21
+ - React, Vue, Angular, Svelte
22
+ - Vanilla JavaScript
23
+ - Static HTML pages
24
+ - Server-rendered pages
25
+
26
+ **Style Encapsulation**
27
+ Shadow DOM prevents CSS conflicts:
28
+ - SDK styles don't leak into your page
29
+ - Your page styles don't affect the SDK
30
+ - Components look consistent everywhere
31
+
32
+ **Future-Proof**
33
+ Built on web standards:
34
+ - No framework lock-in
35
+ - Works in modern browsers natively
36
+ - Follows platform evolution
37
+
38
+ ### How It Works
39
+
40
+ When you inject a product:
41
+
42
+ ```javascript
43
+ await client.injectProductElement([
44
+ { containerId: 'product', identifier: '00619947000020' }
45
+ ]);
46
+ ```
47
+
48
+ The SDK:
49
+ 1. Creates a custom element (e.g., `<product-lc>`)
50
+ 2. Attaches it to your container
51
+ 3. Renders content in Shadow DOM
52
+ 4. Registers event listeners
53
+
54
+ ## Client Initialization
55
+
56
+ The SDK client is the main interface for all operations.
57
+
58
+ ### Initialization Modes
59
+
60
+ #### Auto-Initialization (CDN)
61
+
62
+ When using the CDN, the SDK auto-initializes on page load:
63
+
64
+ ```html
65
+ <script
66
+ defer
67
+ data-liquid-commerce-elements
68
+ data-token="YOUR_API_KEY"
69
+ data-env="production"
70
+ type="text/javascript"
71
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
72
+ ></script>
73
+ ```
74
+
75
+ The client becomes available globally under `window.LiquidCommerce.elements`.
76
+
77
+ #### Programmatic Initialization (NPM)
78
+
79
+ With NPM, you explicitly create the client:
80
+
81
+ ```javascript
82
+ import { Elements } from '@liquidcommerce/elements-sdk';
83
+
84
+ const client = await Elements('YOUR_API_KEY', {
85
+ env: 'production'
86
+ });
87
+ ```
88
+
89
+ ### Phased Initialization
90
+
91
+ The SDK uses a two-phase initialization strategy for optimal performance:
92
+
93
+ **Phase 1: Essential Services (Immediate)**
94
+ - Authentication
95
+ - Configuration loading
96
+ - Store initialization
97
+ - Theme setup
98
+ - Core component registration
99
+ - Telemetry / logger wiring (see [Telemetry & Privacy](../reference/telemetry.md))
100
+ - Debug panel (if enabled)
101
+
102
+ **Phase 2: Deferred Services (next macrotask, via `setTimeout(…, 0)`)**
103
+ - Analytics (Google Tag Manager — see [Analytics (GTM/GA4)](../reference/analytics.md))
104
+ - Cart pre-loading
105
+ - Heavy component registration
106
+
107
+ This ensures fast initial page loads while still providing full functionality.
108
+
109
+ ### Client Ready Event
110
+
111
+ Listen for the client ready event to know when the SDK is initialized:
112
+
113
+ ```javascript
114
+ window.addEventListener('lce:actions.client_ready', (event) => {
115
+ console.log('SDK version:', event.detail.data.version);
116
+ console.log('Ready at:', event.detail.data.timestamp);
117
+
118
+ // Safe to use client
119
+ window.LiquidCommerce.elements.actions.cart.openCart();
120
+ }, { once: true });
121
+ ```
122
+
123
+ ## Declarative vs Programmatic
124
+
125
+ The SDK offers two approaches for component injection.
126
+
127
+ ### Declarative (HTML Attributes)
128
+
129
+ Configure components using HTML data attributes:
130
+
131
+ ```html
132
+ <script
133
+ defer
134
+ data-liquid-commerce-elements
135
+ data-token="YOUR_API_KEY"
136
+ data-container-1="product"
137
+ data-product-1="00619947000020"
138
+ type="text/javascript"
139
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
140
+ ></script>
141
+
142
+ <div id="product"></div>
143
+ ```
144
+
145
+ **Advantages:**
146
+ - No JavaScript required
147
+ - Simple for static pages
148
+ - Automatic initialization
149
+
150
+ **Best for:**
151
+ - Static HTML sites
152
+ - CMS platforms (WordPress, Shopify)
153
+ - Quick prototypes
154
+
155
+ ### Programmatic (JavaScript API)
156
+
157
+ Use JavaScript methods to inject components:
158
+
159
+ ```javascript
160
+ const client = await Elements('YOUR_API_KEY', { env: 'production' });
161
+
162
+ await client.injectProductElement([
163
+ { containerId: 'product', identifier: '00619947000020' }
164
+ ]);
165
+ ```
166
+
167
+ **Advantages:**
168
+ - Dynamic product selection
169
+ - Conditional rendering
170
+ - Framework integration
171
+ - Full control over timing
172
+
173
+ **Best for:**
174
+ - Single-page applications
175
+ - Dynamic content
176
+ - React/Vue/Angular apps
177
+ - Complex interactions
178
+
179
+ ### Mixing Both Approaches
180
+
181
+ You can use declarative initialization and programmatic control:
182
+
183
+ ```html
184
+ <!-- Auto-initialize SDK -->
185
+ <script
186
+ defer
187
+ data-liquid-commerce-elements
188
+ data-token="YOUR_API_KEY"
189
+ data-env="production"
190
+ type="text/javascript"
191
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
192
+ ></script>
193
+
194
+ <script>
195
+ // Later, add products programmatically
196
+ window.addEventListener('lce:actions.client_ready', async () => {
197
+ await window.LiquidCommerce.elements.injectProductElement([
198
+ { containerId: 'dynamic-product', identifier: selectedProductId }
199
+ ]);
200
+ }, { once: true });
201
+ </script>
202
+ ```
203
+
204
+ ## State Management
205
+
206
+ The SDK maintains its own internal state for cart, checkout, and user data.
207
+
208
+ ### Store Service
209
+
210
+ The SDK uses a centralized store service that:
211
+ - Maintains reactive state (in-memory, within a single tab)
212
+ - Persists data to localStorage
213
+ - Falls back to API storage
214
+
215
+ ### State Persistence
216
+
217
+ **Cart State:**
218
+ - Saved to localStorage
219
+ - Persists across sessions
220
+ - Survives page refreshes
221
+ - Other tabs pick up the persisted cart on their next load (no live cross-tab sync)
222
+
223
+ **Address State:**
224
+ - Saved when set by user
225
+ - Used for availability checking
226
+ - Cleared when user explicitly clears it
227
+
228
+ **Checkout State:**
229
+ - Created from cart
230
+ - Exists during checkout flow
231
+ - Cleared after order completion
232
+
233
+ ### Cross-Tab Persistence
234
+
235
+ State is persisted to `localStorage` keyed by device ID. The SDK does **not** register a `storage` listener, `BroadcastChannel`, or other inter-tab subscription, so there is **no live cross-tab synchronization** — a change made in one tab is only reflected in another already-open tab after that tab reloads (which re-runs the persisted-state load and re-fetches by the persisted cart ID).
236
+
237
+ ## Component Lifecycle
238
+
239
+ Understanding how components work helps with debugging and customization.
240
+
241
+ ### Injection Lifecycle
242
+
243
+ 1. **Validation** - Verify container exists
244
+ 2. **Creation** - Create Web Component
245
+ 3. **Attachment** - Add to DOM
246
+ 4. **Data Loading** - Fetch product/cart data
247
+ 5. **Rendering** - Display content
248
+ 6. **Event Setup** - Register listeners
249
+
250
+ ### Component Rerendering
251
+
252
+ Components automatically rerender when data changes:
253
+
254
+ ```javascript
255
+ // This triggers a rerender
256
+ await window.LiquidCommerce.elements.actions.cart.addProduct([...]);
257
+ // Cart component updates automatically
258
+ ```
259
+
260
+ Manual rerendering:
261
+
262
+ ```javascript
263
+ const components = window.LiquidCommerce.elements.getInjectedComponents();
264
+ // The Map is keyed by the container ID passed to inject* (with any leading '#' stripped),
265
+ // not a '<type>-<index>' string. For a component injected into id="product":
266
+ const productComponent = components.get('product');
267
+
268
+ // Force rerender
269
+ productComponent?.rerender();
270
+ ```
271
+
272
+ ### Component Removal
273
+
274
+ Components are removed when:
275
+ - Their container is removed from DOM
276
+ - Page navigation occurs
277
+ - You explicitly remove them
278
+
279
+ To clean up manually:
280
+
281
+ ```javascript
282
+ const container = document.getElementById('product');
283
+ container.innerHTML = ''; // Removes the component
284
+ ```
285
+
286
+ ## Event System
287
+
288
+ The SDK uses a publish-subscribe pattern for events.
289
+
290
+ ### Event Namespaces
291
+
292
+ All SDK events are namespaced to prevent conflicts:
293
+
294
+ ```javascript
295
+ // Action events (user interactions)
296
+ lce:actions.cart_opened
297
+ lce:actions.product_add_to_cart
298
+
299
+ // Form events (checkout forms)
300
+ lce:forms.customer
301
+ lce:forms.billing
302
+ ```
303
+
304
+ ### Event Flow
305
+
306
+ 1. User interacts with component
307
+ 2. Component publishes event
308
+ 3. SDK updates internal state
309
+ 4. Event bubbles to window
310
+ 5. Your code can listen and react
311
+
312
+ ### Subscribing to Events
313
+
314
+ ```javascript
315
+ window.addEventListener('lce:actions.cart_item_added', (event) => {
316
+ console.log('Item added:', event.detail.data);
317
+ // event.detail is { data, metadata }; payload fields live under .data:
318
+ // { cartId, itemId, fulfillmentId, partNumber, quantity, engravingLines? }
319
+ });
320
+ ```
321
+
322
+ See [Events Guide](../guides/events.md) for all available events.
323
+
324
+ ## Error Handling
325
+
326
+ The SDK is designed to fail gracefully and not crash your site.
327
+
328
+ ### Error Isolation
329
+
330
+ Most action failures are **not** thrown. Action methods take one of three paths, so `try/catch`
331
+ alone is not enough to detect failure:
332
+
333
+ | Situation | Behaviour |
334
+ |---|---|
335
+ | Malformed argument (missing `identifier`, invalid `fulfillmentType`, `quantity < 1`) | Throws `SDKError` — `try/catch` catches it |
336
+ | Empty array or no arguments | Logs a warning and **resolves**. No event, no throw. |
337
+ | Valid input that fails at runtime (product not found, unavailable variant, API error) | Publishes `lce:actions.cart_product_add_failed` and **resolves** |
338
+
339
+ So listen for the `*_failed` event **and** wrap the call in `try/catch`:
340
+
341
+ ```javascript
342
+ window.addEventListener('lce:actions.cart_product_add_failed', (event) => {
343
+ console.log('Add to cart failed:', event.detail.data);
344
+ });
345
+
346
+ try {
347
+ // Throws only if the argument itself is malformed.
348
+ await window.LiquidCommerce.elements.actions.cart.addProduct([
349
+ { identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }
350
+ ]);
351
+ } catch (error) {
352
+ console.log('Malformed input rejected by the SDK');
353
+ }
354
+
355
+ // Either way, your page keeps working
356
+ console.log('Page still functional');
357
+ ```
358
+
359
+ See [Error Handling](../reference/error-handling.md) for the full matrix.
360
+
361
+ ### Error Types
362
+
363
+ The SDK uses a custom `SDKError` class for all errors:
364
+
365
+ ```javascript
366
+ class SDKError extends Error {
367
+ constructor(message, reThrow = false) {
368
+ super(message);
369
+ this.name = 'SDKError';
370
+ this.isSdk = true;
371
+ this.reThrow = reThrow; // Whether to re-throw to the user
372
+ }
373
+ }
374
+ ```
375
+
376
+ ### Debug Mode
377
+
378
+ Enable debug mode for detailed logging:
379
+
380
+ ```javascript
381
+ const client = await Elements('YOUR_API_KEY', {
382
+ env: 'development',
383
+ debugMode: 'console' // or 'panel'
384
+ });
385
+ ```
386
+
387
+ **Debug Modes:**
388
+ - `'none'` - No debug output (default)
389
+ - `'console'` - Log to browser console
390
+ - `'panel'` - Show debug panel on page
391
+
392
+ > **Production note:** `debugMode` has no effect when `env` is `'production'`. All debug output — console logging and the debug panel — is disabled in production regardless of the `debugMode` you pass. `'console'` and `'panel'` only take effect in non-production environments.
393
+
394
+ ## Security & API Keys
395
+
396
+ ### API Key Protection
397
+
398
+ Your API key is used for authentication but has limited privileges:
399
+
400
+ - ✅ Read product catalog
401
+ - ✅ Create carts and orders
402
+ - ✅ Process payments
403
+ - ❌ Access other merchants' data
404
+ - ❌ Modify product catalog
405
+ - ❌ Access admin functions
406
+
407
+ ### Environment Separation
408
+
409
+ Use different API keys per environment:
410
+
411
+ ```javascript
412
+ // Development
413
+ const client = await Elements('dev_key_abc123', {
414
+ env: 'development'
415
+ });
416
+
417
+ // Production
418
+ const client = await Elements('prod_key_xyz789', {
419
+ env: 'production'
420
+ });
421
+ ```
422
+
423
+ ### Proxy Configuration
424
+
425
+ To hide your API key and avoid ad blockers, use a proxy:
426
+
427
+ ```javascript
428
+ const client = await Elements('YOUR_API_KEY', {
429
+ env: 'production',
430
+ proxy: {
431
+ baseUrl: 'https://yourdomain.com/api/elements-proxy'
432
+ }
433
+ });
434
+ ```
435
+
436
+ See [Proxy Setup Guide](../integration/proxy-setup.md) for implementation details.
437
+
438
+ ## Browser Support
439
+
440
+ The SDK requires modern browser features:
441
+
442
+ **Minimum Versions:**
443
+ - Chrome 66+ (March 2018)
444
+ - Firefox 60+ (May 2018)
445
+ - Safari 12+ (September 2018)
446
+ - Edge 79+ (January 2020)
447
+
448
+ **Required Features:**
449
+ - Custom Elements (Web Components)
450
+ - Shadow DOM
451
+ - ES2018 JavaScript
452
+ - Fetch API
453
+ - LocalStorage
454
+
455
+ For older browsers, include polyfills:
456
+
457
+ ```html
458
+ <script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-bundle.js"></script>
459
+ <script data-liquid-commerce-elements ...></script>
460
+ ```
461
+
462
+ See [Browser Support](../reference/browser-support.md) for details.
463
+
464
+ ## Performance Considerations
465
+
466
+ The SDK is optimized for performance, but you can help:
467
+
468
+ ### Lazy Loading
469
+
470
+ Load the SDK script with `defer`:
471
+
472
+ ```html
473
+ <script defer data-liquid-commerce-elements ...></script>
474
+ ```
475
+
476
+ ### Tree Shaking
477
+
478
+ Use the checkout-only build when you don't need products:
479
+
480
+ ```javascript
481
+ import { ElementsCheckout } from '@liquidcommerce/elements-sdk/checkout';
482
+ ```
483
+
484
+ This reduces bundle size by ~60%.
485
+
486
+ ### Component Injection Timing
487
+
488
+ Inject components when needed, not all at once:
489
+
490
+ ```javascript
491
+ // Good: Inject visible products first
492
+ await client.injectProductElement([
493
+ { containerId: 'hero-product', identifier: '001' }
494
+ ]);
495
+
496
+ // Then inject others after a delay
497
+ setTimeout(async () => {
498
+ await client.injectProductElement([
499
+ { containerId: 'related-1', identifier: '002' },
500
+ { containerId: 'related-2', identifier: '003' }
501
+ ]);
502
+ }, 1000);
503
+ ```
504
+
505
+ ### Image Optimization
506
+
507
+ The SDK automatically:
508
+ - Lazy loads images
509
+ - Uses responsive images
510
+ - Implements carousel virtualization
511
+
512
+ ## Next Steps
513
+
514
+ Now that you understand the core concepts:
515
+
516
+ - **[Product Component](../guides/product-component.md)** - Learn about product displays
517
+ - **[Cart Component](../guides/cart-component.md)** - Understand cart functionality
518
+ - **[Checkout Component](../guides/checkout-component.md)** - Master the checkout flow
519
+ - **[Theming](../guides/theming.md)** - Customize the look and feel
520
+ - **[Events](../guides/events.md)** - React to user actions
521
+ - **[API Reference](../api/client.md)** - Explore all available methods