@azzas/azzas-tracker-web 2.0.1 → 2.0.2-preview.1

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/dist/mod.d.cts CHANGED
@@ -1455,7 +1455,7 @@ type ProductAdditionalProperty = {
1455
1455
  type ProductSkuVariants = {
1456
1456
  activeVariations?: unknown | null;
1457
1457
  slugsMap?: unknown | null;
1458
- availableVariations?: unknown | null;
1458
+ availableVariations?: Record<string, Array<Record<string, string>>>;
1459
1459
  allVariantProducts?: Array<{
1460
1460
  name: string;
1461
1461
  productID: string;
package/dist/mod.d.ts CHANGED
@@ -1455,7 +1455,7 @@ type ProductAdditionalProperty = {
1455
1455
  type ProductSkuVariants = {
1456
1456
  activeVariations?: unknown | null;
1457
1457
  slugsMap?: unknown | null;
1458
- availableVariations?: unknown | null;
1458
+ availableVariations?: Record<string, Array<Record<string, string>>>;
1459
1459
  allVariantProducts?: Array<{
1460
1460
  name: string;
1461
1461
  productID: string;
@@ -987,8 +987,8 @@ var AzzasTracker = (() => {
987
987
  return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
988
988
  };
989
989
  var SIZE_ORDER = {
990
- alfabetico: ["PP", "P", "M", "G", "GG", "XG", "XGG", "EG", "EGG", "3G", "4G", "5G"],
991
- infantil: ["RN", "0-3M", "3-6M", "6-9M", "9-12M", "12-18M", "18-24M", "P", "M", "G", "GG"]
990
+ alfabetico: ["PP", "P", "M", "G", "GG", "GGG", "XG", "XGG", "EG", "EGG", "3G", "4G", "5G"],
991
+ infantil: ["RN", "0-3M", "3-6M", "6-9M", "9-12M", "12-18M", "18-24M", "P", "M", "G", "GG", "GGG"]
992
992
  };
993
993
  var detectSizeType = (sizes) => {
994
994
  if (sizes.every((s) => /^\d+([.,]\d+)?$/.test(s))) return "numerico";
@@ -1656,19 +1656,19 @@ var AzzasTracker = (() => {
1656
1656
  return null;
1657
1657
  },
1658
1658
  available_grid: (context) => {
1659
+ var _a;
1659
1660
  if (context == null ? void 0 : context.available_grid) return context.available_grid;
1660
- if (context == null ? void 0 : context.products) {
1661
- const sizes = context.products.filter((product) => {
1662
- var _a, _b;
1663
- return (_b = (_a = product.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b.some((o) => o.availability === "https://schema.org/InStock");
1664
- }).map((product) => {
1665
- var _a;
1666
- return (_a = product.name) == null ? void 0 : _a.split(" - ")[1];
1667
- }).filter((name) => Boolean(name));
1668
- const result = sortSizes(sizes).join(",").trim();
1669
- return result || null;
1670
- }
1671
- return null;
1661
+ if (!((_a = context == null ? void 0 : context.products) == null ? void 0 : _a.length)) return null;
1662
+ const sizes = context.products.flatMap((p) => {
1663
+ var _a2, _b, _c, _d;
1664
+ const { productGroupID, skuVariants } = (_a2 = p == null ? void 0 : p.isVariantOf) != null ? _a2 : {};
1665
+ const currentColor = (_b = p == null ? void 0 : p.similarItems) == null ? void 0 : _b.find((i) => (i == null ? void 0 : i.productId) === productGroupID);
1666
+ const variantIDs = (_c = skuVariants == null ? void 0 : skuVariants.allVariantProducts) == null ? void 0 : _c.map((v) => v == null ? void 0 : v.productID);
1667
+ return ((_d = currentColor == null ? void 0 : currentColor.sizes) != null ? _d : []).flatMap(
1668
+ (entry) => (entry == null ? void 0 : entry.isAvailable) && (entry == null ? void 0 : entry.size) && (!(variantIDs == null ? void 0 : variantIDs.length) || variantIDs.includes(entry.skuId)) ? [entry.size] : []
1669
+ );
1670
+ });
1671
+ return sortSizes(sizes).join(",").trim() || null;
1672
1672
  }
1673
1673
  };
1674
1674