@liquidcommerce/elements-sdk 2.2.0-beta.30 → 2.2.0-beta.31
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.
- package/README.md +71 -13
- package/dist/index.esm.js +8845 -8392
- package/dist/types/core/client/client-action.service.d.ts +1 -0
- package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +2 -0
- package/dist/types/elements-client-helper.d.ts +3 -0
- package/dist/types/interfaces/configs/checkout.interface.d.ts +1 -1
- package/dist/types/interfaces/core.interface.d.ts +15 -9
- package/dist/types/modules/theme-provider/services/font-manager.service.d.ts +1 -0
- package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -0
- package/docs/ACTIONS.md +37 -1
- package/docs/TROUBLESHOOTING.md +18 -1
- package/package.json +1 -1
- package/umd/elements.js +1 -1
package/README.md
CHANGED
|
@@ -392,7 +392,7 @@ pnpm add @liquidcommerce/elements-sdk
|
|
|
392
392
|
});
|
|
393
393
|
|
|
394
394
|
// Inject components
|
|
395
|
-
await client.injectProductElement([
|
|
395
|
+
const components = await client.injectProductElement([
|
|
396
396
|
{ containerId: 'pdp-1', identifier: '00619947000020' }
|
|
397
397
|
]);
|
|
398
398
|
|
|
@@ -559,15 +559,20 @@ promoTicker: [
|
|
|
559
559
|
|
|
560
560
|
### Component Injection
|
|
561
561
|
|
|
562
|
-
Inject SDK components into your page containers.
|
|
562
|
+
Inject SDK components into your page containers. All injection methods return wrapper objects that provide component control.
|
|
563
563
|
|
|
564
564
|
#### Products
|
|
565
565
|
|
|
566
566
|
```js
|
|
567
|
-
await client.injectProductElement([
|
|
567
|
+
const components = await client.injectProductElement([
|
|
568
568
|
{ containerId: 'pdp-1', identifier: '00619947000020' },
|
|
569
569
|
{ containerId: 'pdp-2', identifier: '00832889005513' }
|
|
570
570
|
]);
|
|
571
|
+
|
|
572
|
+
// Returns: IInjectedComponent[] - Array of component wrappers
|
|
573
|
+
// components[0].rerender() - Rerender the first component
|
|
574
|
+
// components[0].getElement() - Get the container element
|
|
575
|
+
// components[0].getType() - Get component type
|
|
571
576
|
```
|
|
572
577
|
|
|
573
578
|
**Identifier types:** UPC, product ID, or Salsify grouping ID
|
|
@@ -575,7 +580,12 @@ await client.injectProductElement([
|
|
|
575
580
|
#### Cart
|
|
576
581
|
|
|
577
582
|
```js
|
|
578
|
-
await client.injectCartElement('cart-container');
|
|
583
|
+
const component = await client.injectCartElement('cart-container');
|
|
584
|
+
|
|
585
|
+
// Returns: IInjectedComponent | null - Component wrapper or null if failed
|
|
586
|
+
// component.rerender() - Rerender the component
|
|
587
|
+
// component.getElement() - Get the container element
|
|
588
|
+
// component.getType() - Get component type
|
|
579
589
|
```
|
|
580
590
|
|
|
581
591
|
**Use case:** Dedicated cart page
|
|
@@ -583,7 +593,12 @@ await client.injectCartElement('cart-container');
|
|
|
583
593
|
#### Checkout
|
|
584
594
|
|
|
585
595
|
```js
|
|
586
|
-
await client.injectCheckoutElement('checkout-container');
|
|
596
|
+
const component = await client.injectCheckoutElement('checkout-container');
|
|
597
|
+
|
|
598
|
+
// Returns: IInjectedComponent | null - Component wrapper or null if failed
|
|
599
|
+
// component.rerender() - Rerender the component
|
|
600
|
+
// component.getElement() - Get the container element
|
|
601
|
+
// component.getType() - Get component type
|
|
587
602
|
```
|
|
588
603
|
|
|
589
604
|
**Use case:** Dedicated checkout page
|
|
@@ -591,11 +606,51 @@ await client.injectCheckoutElement('checkout-container');
|
|
|
591
606
|
#### Address
|
|
592
607
|
|
|
593
608
|
```js
|
|
594
|
-
await client.injectAddressElement('address-container');
|
|
609
|
+
const component = await client.injectAddressElement('address-container');
|
|
610
|
+
|
|
611
|
+
// Returns: IInjectedComponent | null - Component wrapper or null if failed
|
|
612
|
+
// component.rerender() - Rerender the component
|
|
613
|
+
// component.getElement() - Get the container element
|
|
614
|
+
// component.getType() - Get component type
|
|
595
615
|
```
|
|
596
616
|
|
|
597
617
|
**Use case:** Shipping address collection page
|
|
598
618
|
|
|
619
|
+
#### Access All Injected Components
|
|
620
|
+
|
|
621
|
+
```js
|
|
622
|
+
// Get all injected components
|
|
623
|
+
const injectedComponents = client.getInjectedComponents();
|
|
624
|
+
|
|
625
|
+
// Access specific components by container ID
|
|
626
|
+
const productComponent = injectedComponents.get('product-container-1');
|
|
627
|
+
const cartComponent = injectedComponents.get('cart-container');
|
|
628
|
+
|
|
629
|
+
// Iterate through all components
|
|
630
|
+
injectedComponents.forEach((component, containerId) => {
|
|
631
|
+
console.log(`Container: ${containerId}, Type: ${component.getType()}`);
|
|
632
|
+
|
|
633
|
+
// Rerender specific components
|
|
634
|
+
if (component.getType() === 'product') {
|
|
635
|
+
component.rerender();
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
// Get all components of a specific type
|
|
640
|
+
const productComponents = Array.from(injectedComponents.values())
|
|
641
|
+
.filter(component => component.getType() === 'product');
|
|
642
|
+
|
|
643
|
+
// Rerender all components of a type
|
|
644
|
+
productComponents.forEach(component => component.rerender());
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
**Returns:** `Map<string, IInjectedComponent>` - Map of container IDs to component wrappers
|
|
648
|
+
|
|
649
|
+
**Use cases:**
|
|
650
|
+
- Debugging and inspecting injected components
|
|
651
|
+
- Bulk operations on multiple components
|
|
652
|
+
- Component management and cleanup
|
|
653
|
+
|
|
599
654
|
### UI Helpers
|
|
600
655
|
|
|
601
656
|
Create standalone UI elements that integrate with the SDK.
|
|
@@ -661,10 +716,12 @@ client.builder.updateCheckoutComponent(checkoutTheme);
|
|
|
661
716
|
client.builder.updateAddressComponent(addressTheme);
|
|
662
717
|
|
|
663
718
|
// Builder injection methods (same as regular methods)
|
|
664
|
-
await client.builder.injectProductElement(params);
|
|
665
|
-
await client.builder.injectCartElement(containerId);
|
|
666
|
-
await client.builder.injectCheckoutElement(containerId);
|
|
667
|
-
await client.builder.injectAddressElement(containerId);
|
|
719
|
+
const components = await client.builder.injectProductElement(params);
|
|
720
|
+
const component = await client.builder.injectCartElement(containerId);
|
|
721
|
+
const checkoutComponent = await client.builder.injectCheckoutElement(containerId);
|
|
722
|
+
const addressComponent = await client.builder.injectAddressElement(containerId);
|
|
723
|
+
|
|
724
|
+
// All return IInjectedComponent wrapper objects with rerender(), getElement(), getType() methods
|
|
668
725
|
```
|
|
669
726
|
|
|
670
727
|
## 🎬 Actions
|
|
@@ -1583,9 +1640,10 @@ Components are created on-demand using a factory pattern:
|
|
|
1583
1640
|
|
|
1584
1641
|
```js
|
|
1585
1642
|
// When you call:
|
|
1586
|
-
await client.injectProductElement([
|
|
1643
|
+
const components = await client.injectProductElement([
|
|
1587
1644
|
{ containerId: 'pdp-1', identifier: 'product-123' }
|
|
1588
1645
|
]);
|
|
1646
|
+
// Returns: IInjectedComponent[] - Array of component wrappers
|
|
1589
1647
|
|
|
1590
1648
|
// The SDK:
|
|
1591
1649
|
// 1. Creates a ProductComponent instance
|
|
@@ -1717,7 +1775,7 @@ export default function ProductPage({ productId }: { productId: string }) {
|
|
|
1717
1775
|
env: 'production'
|
|
1718
1776
|
});
|
|
1719
1777
|
|
|
1720
|
-
await client.injectProductElement([
|
|
1778
|
+
const components = await client.injectProductElement([
|
|
1721
1779
|
{ containerId: 'product-container', identifier: productId }
|
|
1722
1780
|
]);
|
|
1723
1781
|
|
|
@@ -1789,7 +1847,7 @@ await client.injectProductElement([
|
|
|
1789
1847
|
|
|
1790
1848
|
// cart-page.js
|
|
1791
1849
|
const client = await getElementsClient();
|
|
1792
|
-
await client.injectCartElement('cart-container');
|
|
1850
|
+
const cartComponent = await client.injectCartElement('cart-container');
|
|
1793
1851
|
```
|
|
1794
1852
|
|
|
1795
1853
|
---
|