@liquidcommerce/elements-sdk 2.6.0-beta.1 → 2.6.0-beta.100

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 (274) hide show
  1. package/README.md +99 -2517
  2. package/dist/index.checkout.esm.js +17794 -0
  3. package/dist/index.esm.js +26010 -20601
  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 +13 -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 +23 -22
  21. package/dist/types/core/api/api-result.d.ts +19 -0
  22. package/dist/types/core/api/auth-client.service.d.ts +39 -26
  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 -67
  31. package/dist/types/core/client/client-config.service.d.ts +9 -5
  32. package/dist/types/core/command/base-command.service.d.ts +2 -2
  33. package/dist/types/core/command/common-command.service.d.ts +2 -1
  34. package/dist/types/core/google-tag-manager.service.d.ts +15 -11
  35. package/dist/types/core/logger/logger.service.d.ts +1 -1
  36. package/dist/types/core/pubsub/interfaces/address.interface.d.ts +6 -12
  37. package/dist/types/core/pubsub/interfaces/cart.interface.d.ts +27 -64
  38. package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +45 -50
  39. package/dist/types/core/pubsub/interfaces/core.interface.d.ts +11 -6
  40. package/dist/types/core/pubsub/interfaces/product.interface.d.ts +16 -81
  41. package/dist/types/core/pubsub/pubsub.service.d.ts +1 -2
  42. package/dist/types/core/singleton-manager.service.d.ts +12 -8
  43. package/dist/types/core/store/interfaces/address.interface.d.ts +3 -12
  44. package/dist/types/core/store/interfaces/cart.interface.d.ts +16 -55
  45. package/dist/types/core/store/interfaces/checkout.interface.d.ts +18 -108
  46. package/dist/types/core/store/interfaces/core.interface.d.ts +16 -5
  47. package/dist/types/core/store/interfaces/metadata.interface.d.ts +11 -0
  48. package/dist/types/core/store/interfaces/product-list.interface.d.ts +30 -0
  49. package/dist/types/core/store/interfaces/product.interface.d.ts +13 -66
  50. package/dist/types/core/store/store.constant.d.ts +6 -1
  51. package/dist/types/core/store/store.service.d.ts +1 -0
  52. package/dist/types/core/telemetry/telemetry.interface.d.ts +0 -1
  53. package/dist/types/core/telemetry/telemetry.service.d.ts +1 -0
  54. package/dist/types/enums/core.enum.d.ts +40 -1
  55. package/dist/types/enums/index.d.ts +0 -1
  56. package/dist/types/index.checkout.d.ts +8 -0
  57. package/dist/types/index.checkout.umd.d.ts +4 -0
  58. package/dist/types/index.d.ts +8 -3
  59. package/dist/types/interfaces/api/address.interface.d.ts +28 -0
  60. package/dist/types/interfaces/api/cart.interface.d.ts +96 -0
  61. package/dist/types/interfaces/api/checkout.interface.d.ts +239 -0
  62. package/dist/types/interfaces/{cloud → api}/index.d.ts +1 -3
  63. package/dist/types/interfaces/api/product-list.interface.d.ts +39 -0
  64. package/dist/types/interfaces/api/product.interface.d.ts +112 -0
  65. package/dist/types/interfaces/client.interface.d.ts +72 -0
  66. package/dist/types/interfaces/component.interface.d.ts +7 -0
  67. package/dist/types/interfaces/config.interface.d.ts +40 -0
  68. package/dist/types/interfaces/configs/address.interface.d.ts +1 -1
  69. package/dist/types/interfaces/configs/cart.interface.d.ts +1 -1
  70. package/dist/types/interfaces/configs/checkout.interface.d.ts +2 -1
  71. package/dist/types/interfaces/configs/configurations.interface.d.ts +5 -5
  72. package/dist/types/interfaces/configs/global.interface.d.ts +10 -3
  73. package/dist/types/interfaces/configs/index.d.ts +1 -0
  74. package/dist/types/interfaces/configs/product-list.interface.d.ts +49 -0
  75. package/dist/types/interfaces/configs/product.interface.d.ts +4 -1
  76. package/dist/types/interfaces/injection.interface.d.ts +49 -0
  77. package/dist/types/modules/address/address-display.component.d.ts +3 -1
  78. package/dist/types/modules/address/address-input.component.d.ts +10 -1
  79. package/dist/types/modules/address/address.command.d.ts +4 -4
  80. package/dist/types/modules/address/address.interface.d.ts +0 -7
  81. package/dist/types/modules/address/styles/register-styles.d.ts +1 -0
  82. package/dist/types/modules/cart/cart.commands.d.ts +4 -5
  83. package/dist/types/modules/cart/components/cart-body.component.d.ts +3 -1
  84. package/dist/types/modules/cart/components/cart-footer.component.d.ts +0 -1
  85. package/dist/types/modules/cart/components/cart-fulfillment.component.d.ts +0 -2
  86. package/dist/types/modules/cart/components/cart-item-quantity-price.component.d.ts +5 -0
  87. package/dist/types/modules/cart/components/cart-item.component.d.ts +6 -0
  88. package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
  89. package/dist/types/modules/checkout/checkout.commands.d.ts +27 -10
  90. package/dist/types/modules/checkout/checkout.component.d.ts +2 -0
  91. package/dist/types/modules/checkout/components/checkout-billing.component.d.ts +2 -2
  92. package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +5 -0
  93. package/dist/types/modules/checkout/components/checkout-header.component.d.ts +1 -0
  94. package/dist/types/modules/checkout/components/checkout-item-quantity.component.d.ts +4 -0
  95. package/dist/types/modules/checkout/components/checkout-items.component.d.ts +4 -3
  96. package/dist/types/modules/checkout/components/checkout-payment.component.d.ts +2 -1
  97. package/dist/types/modules/checkout/components/checkout-place-order-button.component.d.ts +2 -0
  98. package/dist/types/modules/checkout/components/checkout-presale-countdown.component.d.ts +14 -1
  99. package/dist/types/modules/checkout/components/checkout-presale-expired.component.d.ts +7 -1
  100. package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
  101. package/dist/types/modules/checkout/components/checkout-tips.component.d.ts +2 -2
  102. package/dist/types/modules/checkout/components/promo-pc-gc.component.d.ts +0 -2
  103. package/dist/types/modules/checkout/constant.d.ts +3 -0
  104. package/dist/types/modules/checkout/styles/register-styles.d.ts +1 -0
  105. package/dist/types/modules/product/components/components.d.ts +7 -4
  106. package/dist/types/modules/product/components/product-add-to-cart-section.component.d.ts +7 -1
  107. package/dist/types/modules/product/components/product-description.component.d.ts +1 -0
  108. package/dist/types/modules/product/components/product-drawer.component.d.ts +6 -0
  109. package/dist/types/modules/product/components/product-image-carousel.component.d.ts +5 -0
  110. package/dist/types/modules/product/components/product-options.component.d.ts +2 -1
  111. package/dist/types/modules/product/components/product-retailers-carousel.component.d.ts +4 -0
  112. package/dist/types/modules/product/components/product-retailers-popup-list.component.d.ts +10 -2
  113. package/dist/types/modules/product/product.commands.d.ts +7 -7
  114. package/dist/types/modules/product/styles/register-styles.d.ts +1 -0
  115. package/dist/types/modules/product-list/components/card-components/index.d.ts +5 -0
  116. package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +9 -0
  117. package/dist/types/modules/product-list/components/card-components/product-button.d.ts +11 -0
  118. package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +14 -0
  119. package/dist/types/modules/product-list/components/card-components/product-quantity-selector.d.ts +11 -0
  120. package/dist/types/modules/product-list/components/card-components/product-sizes-list.d.ts +14 -0
  121. package/dist/types/modules/product-list/components/filter-components/index.d.ts +7 -0
  122. package/dist/types/modules/product-list/components/filter-components/product-list-apply-filter-button.d.ts +1 -0
  123. package/dist/types/modules/product-list/components/filter-components/product-list-checkbox-filter.d.ts +7 -0
  124. package/dist/types/modules/product-list/components/filter-components/product-list-chip.d.ts +5 -0
  125. package/dist/types/modules/product-list/components/filter-components/product-list-filters-chips.d.ts +13 -0
  126. package/dist/types/modules/product-list/components/filter-components/product-list-fulfillment-filter.d.ts +15 -0
  127. package/dist/types/modules/product-list/components/filter-components/product-list-price-filter.d.ts +22 -0
  128. package/dist/types/modules/product-list/components/filter-components/product-list-toggle-filters.d.ts +7 -0
  129. package/dist/types/modules/product-list/components/index.d.ts +6 -0
  130. package/dist/types/modules/product-list/components/product-list-card-loading.component.d.ts +3 -1
  131. package/dist/types/modules/product-list/components/product-list-card.component.d.ts +36 -30
  132. package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +12 -0
  133. package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +56 -14
  134. package/dist/types/modules/product-list/components/product-list-product-engraving-lines.component.d.ts +22 -0
  135. package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +53 -0
  136. package/dist/types/modules/product-list/components/product-list-search.component.d.ts +25 -0
  137. package/dist/types/modules/product-list/product-list-filter.utils.d.ts +8 -0
  138. package/dist/types/modules/product-list/product-list-query-params.utils.d.ts +3 -0
  139. package/dist/types/modules/product-list/product-list.commands.d.ts +23 -7
  140. package/dist/types/modules/product-list/product-list.component.d.ts +17 -39
  141. package/dist/types/modules/product-list/product-list.constants.d.ts +38 -0
  142. package/dist/types/modules/product-list/product-list.interface.d.ts +65 -0
  143. package/dist/types/modules/product-list/styles/product-list-card.style.d.ts +1 -0
  144. package/dist/types/modules/product-list/styles/product-list-filters.style.d.ts +1 -0
  145. package/dist/types/modules/product-list/styles/register-styles.d.ts +1 -0
  146. package/dist/types/modules/theme-provider/constants/component-groupings.d.ts +1 -0
  147. package/dist/types/modules/theme-provider/constants/css-variable-mappings.d.ts +1 -1
  148. package/dist/types/modules/theme-provider/services/style-registry.service.d.ts +16 -0
  149. package/dist/types/modules/theme-provider/services/stylesheet-generator.service.d.ts +0 -1
  150. package/dist/types/modules/theme-provider/styles/register-styles.d.ts +1 -0
  151. package/dist/types/modules/theme-provider/theme-provider.service.d.ts +2 -2
  152. package/dist/types/modules/ui-components/alert/alert.component.d.ts +1 -1
  153. package/dist/types/modules/ui-components/buttons/buttons-open-cart.component.d.ts +5 -0
  154. package/dist/types/modules/ui-components/drawer/drawer.component.d.ts +15 -0
  155. package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +8 -1
  156. package/dist/types/modules/ui-components/engraving/engraving-view.component.d.ts +7 -1
  157. package/dist/types/modules/ui-components/input/index.d.ts +0 -1
  158. package/dist/types/modules/ui-components/input/input.component.d.ts +14 -1
  159. package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
  160. package/dist/types/modules/ui-components/promo-code-ticker/promo-code-ticker.component.d.ts +1 -1
  161. package/dist/types/modules/ui-components/purchase-min-alert/index.d.ts +0 -1
  162. package/dist/types/modules/ui-components/ui.commands.d.ts +7 -1
  163. package/dist/types/ssr/stub.checkout.d.ts +6 -0
  164. package/dist/types/ssr/stub.d.ts +10 -0
  165. package/dist/types/static/icon/arrow-right.icon.d.ts +1 -1
  166. package/dist/types/static/icon/bag.icon.d.ts +1 -1
  167. package/dist/types/static/icon/check.icon.d.ts +2 -0
  168. package/dist/types/static/icon/checkbox.icon.d.ts +1 -1
  169. package/dist/types/static/icon/chevron-down.icon.d.ts +1 -1
  170. package/dist/types/static/icon/chevron-left.icon.d.ts +1 -1
  171. package/dist/types/static/icon/chevron-up.icon.d.ts +2 -0
  172. package/dist/types/static/icon/close.icon.d.ts +1 -1
  173. package/dist/types/static/icon/error-info.icon.d.ts +1 -1
  174. package/dist/types/static/icon/filter.icon.d.ts +2 -0
  175. package/dist/types/static/icon/icon.a11y.d.ts +1 -0
  176. package/dist/types/static/icon/icon.types.d.ts +1 -0
  177. package/dist/types/static/icon/index.d.ts +3 -0
  178. package/dist/types/static/icon/info.icon.d.ts +1 -1
  179. package/dist/types/static/icon/loading-spinner.icon.d.ts +1 -1
  180. package/dist/types/static/icon/search.icon.d.ts +1 -1
  181. package/dist/types/static/icon/success.icon.d.ts +1 -1
  182. package/dist/types/static/icon/trash.icon.d.ts +1 -1
  183. package/dist/types/static/icon/warning.icon.d.ts +1 -1
  184. package/dist/types/utils/dom-compat.d.ts +2 -0
  185. package/dist/types/utils/format.d.ts +4 -14
  186. package/dist/types/utils/image-bg-removal.d.ts +3 -0
  187. package/dist/types/utils/product-selection.d.ts +16 -0
  188. package/dist/types/utils/product.d.ts +15 -0
  189. package/docs/v1/README.md +213 -0
  190. package/docs/v1/api/actions/address-actions.md +286 -0
  191. package/docs/v1/api/actions/cart-actions.md +364 -0
  192. package/docs/v1/api/actions/checkout-actions.md +527 -0
  193. package/docs/v1/api/actions/product-actions.md +204 -0
  194. package/docs/v1/api/client.md +596 -0
  195. package/docs/v1/api/configuration.md +555 -0
  196. package/docs/v1/api/injection-methods.md +292 -0
  197. package/docs/v1/api/typescript-types.md +423 -0
  198. package/docs/v1/api/ui-helpers.md +200 -0
  199. package/docs/v1/examples/advanced-patterns.md +199 -0
  200. package/docs/v1/examples/checkout-flow.md +90 -0
  201. package/docs/v1/examples/custom-theming.md +63 -0
  202. package/docs/v1/examples/multi-product-page.md +90 -0
  203. package/docs/v1/examples/simple-product-page.md +89 -0
  204. package/docs/v1/getting-started/concepts.md +521 -0
  205. package/docs/v1/getting-started/installation.md +349 -0
  206. package/docs/v1/getting-started/quick-start.md +410 -0
  207. package/docs/v1/guides/accessibility.md +173 -0
  208. package/docs/v1/guides/address-component.md +435 -0
  209. package/docs/v1/guides/best-practices.md +365 -0
  210. package/docs/v1/guides/cart-component.md +757 -0
  211. package/docs/v1/guides/checkout-component.md +670 -0
  212. package/docs/v1/guides/events.md +939 -0
  213. package/docs/v1/guides/product-component.md +735 -0
  214. package/docs/v1/guides/product-list-component.md +630 -0
  215. package/docs/v1/guides/theming.md +228 -0
  216. package/docs/v1/integration/angular.md +39 -0
  217. package/docs/v1/integration/laravel.md +41 -0
  218. package/docs/v1/integration/nextjs.md +69 -0
  219. package/docs/v1/integration/proxy-setup.md +106 -0
  220. package/docs/v1/integration/react.md +64 -0
  221. package/docs/v1/integration/vanilla-js.md +84 -0
  222. package/docs/v1/integration/vue.md +58 -0
  223. package/docs/v1/reference/analytics.md +108 -0
  224. package/docs/v1/reference/browser-support.md +47 -0
  225. package/docs/v1/reference/error-handling.md +83 -0
  226. package/docs/v1/reference/performance.md +52 -0
  227. package/docs/v1/reference/telemetry.md +85 -0
  228. package/docs/v1/reference/troubleshooting.md +135 -0
  229. package/package.json +69 -45
  230. package/dist/types/elements-builder-client.d.ts +0 -2
  231. package/dist/types/elements-client.d.ts +0 -2
  232. package/dist/types/enums/cloud.enum.d.ts +0 -77
  233. package/dist/types/interfaces/cloud/address.interface.d.ts +0 -36
  234. package/dist/types/interfaces/cloud/cart.interface.d.ts +0 -132
  235. package/dist/types/interfaces/cloud/catalog.interface.d.ts +0 -43
  236. package/dist/types/interfaces/cloud/checkout.interface.d.ts +0 -214
  237. package/dist/types/interfaces/cloud/core.interface.d.ts +0 -22
  238. package/dist/types/interfaces/cloud/product.interface.d.ts +0 -158
  239. package/dist/types/interfaces/cloud/retailer.interface.d.ts +0 -67
  240. package/dist/types/interfaces/cloud/user.interface.d.ts +0 -100
  241. package/dist/types/interfaces/core.interface.d.ts +0 -111
  242. package/dist/types/modules/cart/cart.commands.helper.d.ts +0 -9
  243. package/dist/types/modules/checkout/components/checkout.type.d.ts +0 -4
  244. package/dist/types/modules/product/utils/helpers.d.ts +0 -3
  245. package/dist/types/modules/product/utils/retailer-hours.d.ts +0 -9
  246. package/dist/types/modules/theme-provider/styles/address/index.d.ts +0 -1
  247. package/dist/types/modules/theme-provider/styles/cart/index.d.ts +0 -1
  248. package/dist/types/modules/theme-provider/styles/checkout/index.d.ts +0 -1
  249. package/dist/types/modules/theme-provider/styles/product/index.d.ts +0 -3
  250. package/dist/types/modules/theme-provider/styles/product-list/index.d.ts +0 -1
  251. package/dist/types/modules/theme-provider/styles/ui/index.d.ts +0 -3
  252. package/dist/types/modules/ui-components/input/birthdate-input.component.d.ts +0 -53
  253. package/dist/types/modules/ui-components/purchase-min-alert/helpers.d.ts +0 -7
  254. package/dist/types/utils/helper.d.ts +0 -27
  255. package/docs/ACTIONS.md +0 -1300
  256. package/docs/BROWSER_SUPPORT.md +0 -279
  257. package/docs/CONFIGURATION.md +0 -853
  258. package/docs/DOCUMENTATION_INDEX.md +0 -311
  259. package/docs/EVENTS.md +0 -798
  260. package/docs/PROXY.md +0 -228
  261. package/docs/THEMING.md +0 -589
  262. package/docs/TROUBLESHOOTING.md +0 -793
  263. package/umd/elements.js +0 -1
  264. /package/dist/types/{auto-initialize.d.ts → auto-initialize/main.d.ts} +0 -0
  265. /package/dist/types/modules/{theme-provider/styles/address → address/styles}/address.style.d.ts +0 -0
  266. /package/dist/types/modules/{theme-provider/styles/cart → cart/styles}/cart.style.d.ts +0 -0
  267. /package/dist/types/modules/{theme-provider/styles/checkout → checkout/styles}/checkout.style.d.ts +0 -0
  268. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/image-carousel.style.d.ts +0 -0
  269. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/product.style.d.ts +0 -0
  270. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/retailers.style.d.ts +0 -0
  271. /package/dist/types/modules/{theme-provider/styles/product-list → product-list/styles}/product-list.style.d.ts +0 -0
  272. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/drawer.style.d.ts +0 -0
  273. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/loading.style.d.ts +0 -0
  274. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/promo-code-ticker.style.d.ts +0 -0
@@ -0,0 +1,596 @@
1
+ # Client API
2
+
3
+ The Elements client is the main interface for interacting with the SDK. It provides methods for injecting components, managing UI elements, and performing actions.
4
+
5
+ ## Initialization
6
+
7
+ ### Elements()
8
+
9
+ Initialize the full SDK client.
10
+
11
+ ```typescript
12
+ function Elements(
13
+ apiKey: string,
14
+ config?: ILiquidCommerceElementsConfig
15
+ ): Promise<ILiquidCommerceElementsClient | null>
16
+ ```
17
+
18
+ **Parameters:**
19
+
20
+ | Parameter | Type | Required | Description |
21
+ |-----------|-------------------------------|----------|-----------------------------|
22
+ | `apiKey` | string | Yes | Your LiquidCommerce API key |
23
+ | `config` | ILiquidCommerceElementsConfig | No | Configuration object |
24
+
25
+ **Returns:** Promise that resolves to the client instance, or `null` if initialization fails.
26
+
27
+ **Example:**
28
+
29
+ ```javascript
30
+ import { Elements } from '@liquidcommerce/elements-sdk';
31
+
32
+ const client = await Elements('YOUR_API_KEY', {
33
+ env: 'production',
34
+ debugMode: 'console',
35
+ customTheme: { /* theme config */ }
36
+ });
37
+ ```
38
+
39
+ ### ElementsCheckout()
40
+
41
+ Initialize the checkout-only client (tree-shaken build).
42
+
43
+ ```typescript
44
+ function ElementsCheckout(
45
+ apiKey: string,
46
+ config?: ILiquidCommerceElementsCheckoutClientConfig
47
+ ): Promise<IElementsCheckoutClient | null>
48
+ ```
49
+
50
+ **Parameters:**
51
+
52
+ | Parameter | Type | Required | Description |
53
+ |-----------|---------------------------------------------|----------|-----------------------------|
54
+ | `apiKey` | string | Yes | Your LiquidCommerce API key |
55
+ | `config` | ILiquidCommerceElementsCheckoutClientConfig | No | Checkout configuration |
56
+
57
+ **Example:**
58
+
59
+ ```javascript
60
+ import { ElementsCheckout } from '@liquidcommerce/elements-sdk/checkout';
61
+
62
+ const client = await ElementsCheckout('YOUR_API_KEY', {
63
+ env: 'production'
64
+ });
65
+ ```
66
+
67
+ ### ElementsBuilder()
68
+
69
+ Initialize the builder client, which exposes manual `inject*` / `update*` methods for fully programmatic composition.
70
+
71
+ ```typescript
72
+ function ElementsBuilder(
73
+ apiKey: string,
74
+ config?: ILiquidCommerceElementsBuilderConfig
75
+ ): Promise<ILiquidCommerceElementsBuilderClient | null>
76
+ ```
77
+
78
+ **Parameters:**
79
+
80
+ | Parameter | Type | Required | Description |
81
+ |-----------|--------------------------------------|----------|-----------------------------|
82
+ | `apiKey` | string | Yes | Your LiquidCommerce API key |
83
+ | `config` | ILiquidCommerceElementsBuilderConfig | No | Builder configuration object (same shape as `ILiquidCommerceElementsConfig`) |
84
+
85
+ **Returns:** Promise that resolves to the builder client instance (`ILiquidCommerceElementsBuilderClient`), or `null` if initialization fails or it is called outside the browser.
86
+
87
+ **Example:**
88
+
89
+ ```javascript
90
+ import { ElementsBuilder } from '@liquidcommerce/elements-sdk';
91
+
92
+ const builder = await ElementsBuilder('YOUR_API_KEY', {
93
+ env: 'production'
94
+ });
95
+ ```
96
+
97
+ ## Configuration
98
+
99
+ ### ILiquidCommerceElementsConfig
100
+
101
+ Complete configuration interface for the full SDK.
102
+
103
+ ```typescript
104
+ interface ILiquidCommerceElementsConfig {
105
+ // Optional
106
+ env?: ElementsEnv; // defaults to 'production' ('development' | 'staging' | 'production')
107
+ debugMode?: DebugMode; // 'none' | 'console' | 'panel'
108
+ customTheme?: IClientCustomThemeConfig;
109
+ promoTicker?: IPromoTicker[];
110
+ proxy?: IElementsProxyConfig;
111
+ checkout?: ILiquidCommerceElementsCheckoutConfig;
112
+ development?: ILiquidCommerceElementsDevelopmentConfig;
113
+ }
114
+ ```
115
+
116
+ #### Environment
117
+
118
+ ```typescript
119
+ type ElementsEnv = 'development' | 'staging' | 'production';
120
+ ```
121
+
122
+ Determines which API environment to use.
123
+
124
+ #### Debug Mode
125
+
126
+ ```typescript
127
+ type DebugMode = 'none' | 'console' | 'panel';
128
+ ```
129
+
130
+ - `'none'`: No debug output (production default)
131
+ - `'console'`: Log debug info to browser console
132
+ - `'panel'`: Show debug panel on page
133
+
134
+ #### Custom Theme
135
+
136
+ ```typescript
137
+ interface IClientCustomThemeConfig {
138
+ global?: UpdateComponentGlobalConfigs;
139
+ product?: UpdateProductComponent;
140
+ address?: UpdateAddressComponent;
141
+ cart?: UpdateCartComponent;
142
+ checkout?: UpdateCheckoutComponent;
143
+ productList?: UpdateProductListComponent;
144
+ }
145
+ ```
146
+
147
+ See [Configuration Reference](./configuration.md) for detailed theme options.
148
+
149
+ #### Promo Ticker
150
+
151
+ ```typescript
152
+ interface IPromoTicker {
153
+ promoCode: string;
154
+ text: string[];
155
+ separator: string;
156
+ activeFrom: string; // ISO 8601 UTC format
157
+ activeUntil: string; // ISO 8601 UTC format
158
+ }
159
+ ```
160
+
161
+ **Example:**
162
+
163
+ ```javascript
164
+ promoTicker: [{
165
+ promoCode: 'SUMMER20',
166
+ text: ['20% Off Summer Sale', 'Free Shipping on $50+'],
167
+ separator: '•',
168
+ activeFrom: '2026-06-01T00:00:00Z',
169
+ activeUntil: '2026-08-31T23:59:59Z'
170
+ }]
171
+ ```
172
+
173
+ #### Proxy Configuration
174
+
175
+ ```typescript
176
+ interface IElementsProxyConfig {
177
+ baseUrl: string;
178
+ headers?: Record<string, string>;
179
+ }
180
+ ```
181
+
182
+ **Example:**
183
+
184
+ ```javascript
185
+ proxy: {
186
+ baseUrl: 'https://yoursite.com/api/elements-proxy',
187
+ headers: {
188
+ 'X-Custom-Header': 'value'
189
+ }
190
+ }
191
+ ```
192
+
193
+ See [Proxy Setup Guide](../integration/proxy-setup.md) for implementation.
194
+
195
+ #### Checkout Configuration
196
+
197
+ ```typescript
198
+ interface ILiquidCommerceElementsCheckoutConfig {
199
+ pageUrl?: string; // Optional. URL pattern with {token} placeholder
200
+ }
201
+ ```
202
+
203
+ **Example:**
204
+
205
+ ```javascript
206
+ checkout: {
207
+ pageUrl: 'https://yoursite.com/checkout?lce_checkout={token}'
208
+ }
209
+ ```
210
+
211
+ #### Development Configuration
212
+
213
+ ```typescript
214
+ interface ILiquidCommerceElementsDevelopmentConfig {
215
+ customApiUrl?: string;
216
+ openShadowDom?: boolean;
217
+ mockMode?: boolean; // enable mock data responses (sends 'X-Liquid-Api-Mock-Mode' header)
218
+ }
219
+ ```
220
+
221
+ **Example:**
222
+
223
+ ```javascript
224
+ development: {
225
+ customApiUrl: 'http://localhost:3000/api',
226
+ openShadowDom: true // Use an OPEN (inspectable) Shadow DOM instead of the default closed mode; forced off in production
227
+ }
228
+ ```
229
+
230
+ ## Global Access
231
+
232
+ After initialization, each client is available globally under the `window.LiquidCommerce` namespace:
233
+
234
+ ```javascript
235
+ window.LiquidCommerce.elements // full client (from Elements())
236
+ window.LiquidCommerce.elementsBuilder // builder client (from ElementsBuilder())
237
+ window.LiquidCommerce.elementsCheckout // checkout-only client (from ElementsCheckout())
238
+ ```
239
+
240
+ This allows access from anywhere in your application:
241
+
242
+ ```javascript
243
+ // From any script
244
+ window.LiquidCommerce.elements.actions.cart.openCart();
245
+ ```
246
+
247
+ ## Client Ready Event
248
+
249
+ Listen for client initialization:
250
+
251
+ ```javascript
252
+ window.addEventListener('lce:actions.client_ready', ( event ) => {
253
+ const { isReady, version, timestamp } = event.detail.data;
254
+
255
+ console.log(`Elements SDK v${version} ready`);
256
+
257
+ // Safe to use client
258
+ window.LiquidCommerce.elements.injectProductElement([...]);
259
+ }, { once: true });
260
+ ```
261
+
262
+ ## Client Interface
263
+
264
+ ### ILiquidCommerceElementsClient
265
+
266
+ The main client interface:
267
+
268
+ ```typescript
269
+ interface ILiquidCommerceElementsClient {
270
+ // Injection methods
271
+ injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
272
+
273
+ injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
274
+
275
+ injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
276
+
277
+ injectCheckoutElement(params: IInjectCheckoutParams): Promise<IInjectedComponent | null>;
278
+
279
+ injectProductList(params: IInjectProductListParams): Promise<void>;
280
+
281
+ injectProductListSearch(params: IInjectProductListSearchParams): Promise<void>;
282
+
283
+ injectProductListFilters(params: IInjectProductListFiltersParams): Promise<void>;
284
+
285
+ // UI methods
286
+ ui: ILiquidCommerceElementsUIMethod;
287
+
288
+ // Actions
289
+ actions: ILiquidCommerceElementsActions;
290
+
291
+ // Component management
292
+ getInjectedComponents(): Map<string, IInjectedComponent>;
293
+
294
+ // Cleanup
295
+ destroy(): void;
296
+ }
297
+ ```
298
+
299
+ ### ILiquidCommerceElementsBuilderClient
300
+
301
+ The builder client (returned by `ElementsBuilder()`) exposes the same `inject*` methods plus a set of `update*Component` methods for applying theme/layout changes at runtime:
302
+
303
+ ```typescript
304
+ interface ILiquidCommerceElementsBuilderClient {
305
+ // Runtime theme/layout updates (builder-only)
306
+ updateComponentGlobalConfigs(configs: UpdateComponentGlobalConfigs): Promise<void>;
307
+ updateProductComponent(configs: UpdateProductComponent): Promise<void>;
308
+ updateAddressComponent(configs: UpdateAddressComponent): void;
309
+ updateCartComponent(configs: UpdateCartComponent): void;
310
+ updateCheckoutComponent(configs: UpdateCheckoutComponent): void;
311
+ updateProductListComponent(configs: UpdateProductListComponent): void;
312
+
313
+ // Injection methods
314
+ injectElement(params: IBuilderInjectElementParams): Promise<IInjectedComponent | null>;
315
+ injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
316
+ injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
317
+ injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
318
+ injectCheckoutElement(params: IInjectCheckoutBuilderParams): Promise<IInjectedComponent | null>;
319
+ injectProductList(params: IInjectProductListParams): Promise<void>;
320
+
321
+ // Actions
322
+ actions: ILiquidCommerceElementsActions;
323
+
324
+ // Cleanup
325
+ destroy(): void;
326
+ }
327
+ ```
328
+
329
+ #### Runtime theme updates (`update*Component`)
330
+
331
+ These methods are **builder-only** — they exist on the client returned by `ElementsBuilder()` and are **not** available on the full `Elements()` client. Each method applies theme changes to its scope and, when the passed `configs` include a non-empty `layout`, triggers targeted rerenders of only the components affected by those layout fields.
332
+
333
+ Return types are not uniform:
334
+
335
+ - `updateComponentGlobalConfigs()` and `updateProductComponent()` return `Promise<void>` (they may await product rerenders) — `await` them.
336
+ - `updateCartComponent()`, `updateCheckoutComponent()`, `updateAddressComponent()`, and `updateProductListComponent()` return `void` (synchronous).
337
+
338
+ ```javascript
339
+ const builder = await ElementsBuilder('YOUR_API_KEY', { env: 'production' });
340
+
341
+ // Asynchronous — await these
342
+ await builder.updateComponentGlobalConfigs({
343
+ theme: { primaryColor: '#0a7d33', buttonCornerRadius: '8px' },
344
+ layout: { allowPromoCodes: true }
345
+ });
346
+ await builder.updateProductComponent({
347
+ theme: { backgroundColor: '#ffffff' },
348
+ layout: { addToCartButtonText: 'Add to bag' }
349
+ });
350
+
351
+ // Synchronous — no await needed
352
+ builder.updateCartComponent({ layout: { drawerHeaderText: 'Your bag' } });
353
+ builder.updateCheckoutComponent({ layout: { placeOrderButtonText: 'Pay now' } });
354
+ ```
355
+
356
+ #### injectCheckoutElement (builder)
357
+
358
+ The builder's `injectCheckoutElement()` accepts `IInjectCheckoutBuilderParams`, which extends `IInjectCheckoutParams` with two **preview-only** fields:
359
+
360
+ ```typescript
361
+ interface IInjectCheckoutBuilderParams extends IInjectCheckoutParams {
362
+ simulatePresale?: boolean; // simulate a presale lock in builder mode
363
+ presaleExpiresInMinutes?: number; // minutes until the simulated lock expires (defaults to 15)
364
+ }
365
+ ```
366
+
367
+ `simulatePresale` and `presaleExpiresInMinutes` only take effect in the builder preview and have no counterpart on the full `Elements()` client's `injectCheckoutElement()`.
368
+
369
+ ```javascript
370
+ await builder.injectCheckoutElement({
371
+ containerId: 'checkout',
372
+ simulatePresale: true,
373
+ presaleExpiresInMinutes: 30
374
+ });
375
+ ```
376
+
377
+ ## Methods Overview
378
+
379
+ ### Injection Methods
380
+
381
+ - `injectProductElement()` - Inject product displays
382
+ - `injectAddressElement()` - Inject address input
383
+ - `injectCartElement()` - Inject cart (rarely needed)
384
+ - `injectCheckoutElement()` - Inject checkout
385
+ - `injectProductList()` - Inject product catalog
386
+ - `injectProductListSearch()` - Inject search box
387
+ - `injectProductListFilters()` - Inject filter panel
388
+
389
+ See [Injection Methods](./injection-methods.md) for details.
390
+
391
+ ### UI Methods
392
+
393
+ - `ui.cartButton()` - Add cart button
394
+ - `ui.floatingCartButton()` - Add floating cart button
395
+ - `ui.cartSubtotal()` - Display cart subtotal
396
+ - `ui.cartItemsCount()` - Display item count
397
+
398
+ See [UI Helpers](./ui-helpers.md) for details.
399
+
400
+ ### Actions
401
+
402
+ - `actions.product.*` - Product actions
403
+ - `actions.address.*` - Address actions
404
+ - `actions.cart.*` - Cart actions
405
+ - `actions.checkout.*` - Checkout actions
406
+
407
+ See [Actions](./actions/) for details.
408
+
409
+ ### Component Management
410
+
411
+ ```javascript
412
+ // Get all injected components
413
+ const components = client.getInjectedComponents();
414
+
415
+ // Get specific component
416
+ const productComponent = components.get('product-1');
417
+
418
+ // Component methods
419
+ productComponent.getType(); // 'product'
420
+ productComponent.getElement(); // <div id="product-1">...</div>
421
+ productComponent.rerender(); // Force rerender
422
+ productComponent.destroy(); // Remove from DOM and clean up
423
+ ```
424
+
425
+ ### destroy()
426
+
427
+ Remove the client and all injected components, cleaning up event listeners and internal state.
428
+
429
+ ```javascript
430
+ client.destroy();
431
+ ```
432
+
433
+ ## Error Handling
434
+
435
+ ### SDKError
436
+
437
+ All SDK errors use the custom `SDKError` class:
438
+
439
+ ```typescript
440
+ class SDKError extends Error {
441
+ constructor(message: string, reThrow?: boolean);
442
+
443
+ name: 'SDKError';
444
+ isSdk: boolean;
445
+ reThrow: boolean;
446
+ }
447
+ ```
448
+ ### Catching Errors
449
+
450
+ ```javascript
451
+ try {
452
+ await client.injectProductElement([
453
+ { containerId: 'product', identifier: 'invalid_id' }
454
+ ]);
455
+ } catch (error) {
456
+ if (error.name === 'SDKError') {
457
+ console.error('SDK Error:', error);
458
+ }
459
+ }
460
+ ```
461
+
462
+ ### Error Isolation
463
+
464
+ The SDK catches and contains its own errors:
465
+
466
+ ```javascript
467
+ // Even if SDK throws, your app continues
468
+ window.LiquidCommerce.elements.actions.cart.addProduct([/* invalid */]);
469
+
470
+ // Your code still runs
471
+ console.log('App still working');
472
+ ```
473
+
474
+ ## TypeScript Support
475
+
476
+ ### Importing Types
477
+
478
+ ```typescript
479
+ import { Elements } from '@liquidcommerce/elements-sdk';
480
+ import type {
481
+ ILiquidCommerceElementsClient,
482
+ ILiquidCommerceElementsConfig,
483
+ IInjectProductElement,
484
+ IInjectedComponent
485
+ } from '@liquidcommerce/elements-sdk';
486
+
487
+ const config: ILiquidCommerceElementsConfig = {
488
+ env: 'production'
489
+ };
490
+
491
+ // Elements() resolves to `null` on failure, so the type is nullable.
492
+ const client: ILiquidCommerceElementsClient | null = await Elements('KEY', config);
493
+ ```
494
+
495
+ ### Type Exports
496
+
497
+ All public interfaces are exported from the main package:
498
+
499
+ ```typescript
500
+ import type {
501
+ // Client types
502
+ ILiquidCommerceElementsClient,
503
+ ILiquidCommerceElementsConfig,
504
+
505
+ // Injection types
506
+ IInjectProductElement,
507
+ IInjectCheckoutParams,
508
+ IInjectedComponent,
509
+
510
+ // Configuration types
511
+ IClientCustomThemeConfig,
512
+ IComponentGlobalConfigs,
513
+ IProductComponent,
514
+ ICartComponent,
515
+ ICheckoutComponent,
516
+ IAddressComponent,
517
+
518
+ // Enum types
519
+ ElementsEnv,
520
+ DebugMode,
521
+ FulfillmentType,
522
+ ComponentType
523
+ } from '@liquidcommerce/elements-sdk';
524
+ ```
525
+
526
+ See [TypeScript Types](./typescript-types.md) for complete type reference.
527
+
528
+ ## Best Practices
529
+
530
+ ### Single Client Instance
531
+
532
+ Create one client instance and reuse it:
533
+
534
+ ```javascript
535
+ // Good
536
+ const client = await Elements('KEY', { env: 'production' });
537
+ await client.injectProductElement([...]);
538
+ await client.injectCartElement('cart');
539
+
540
+ // Bad - creates multiple instances
541
+ await Elements('KEY', { env: 'production' });
542
+ await Elements('KEY', { env: 'production' });
543
+ ```
544
+
545
+ ### Use Global Access
546
+
547
+ After initialization, use `window.LiquidCommerce.elements`:
548
+
549
+ ```javascript
550
+ // Initialize once
551
+ await Elements('KEY', { env: 'production' });
552
+
553
+ // Use globally
554
+ window.LiquidCommerce.elements.actions.cart.openCart();
555
+ window.LiquidCommerce.elements.ui.cartButton('cart-btn');
556
+ ```
557
+
558
+ ### Check Client Ready
559
+
560
+ Wait for client ready before using:
561
+
562
+ ```javascript
563
+ if (window.LiquidCommerce?.elements) {
564
+ // Client is ready
565
+ window.LiquidCommerce.elements.actions.cart.openCart();
566
+ } else {
567
+ // Wait for client ready
568
+ window.addEventListener('lce:actions.client_ready', () => {
569
+ window.LiquidCommerce.elements.actions.cart.openCart();
570
+ }, { once: true });
571
+ }
572
+ ```
573
+
574
+ ### Handle Initialization Failures
575
+
576
+ ```javascript
577
+ const client = await Elements('KEY', { env: 'production' });
578
+
579
+ if (!client) {
580
+ console.error('Failed to initialize Elements SDK');
581
+ // Show fallback UI or error message
582
+ showErrorPage();
583
+ return;
584
+ }
585
+
586
+ // Client initialized successfully
587
+ await client.injectProductElement([...]);
588
+ ```
589
+
590
+ ## See Also
591
+
592
+ - [Injection Methods](./injection-methods.md) - Component injection API
593
+ - [UI Helpers](./ui-helpers.md) - UI helper methods
594
+ - [Actions](./actions/) - Action APIs
595
+ - [Configuration](./configuration.md) - Configuration options
596
+ - [TypeScript Types](./typescript-types.md) - Type definitions