@afosto/checkout-ui 0.0.1-alpha.5 → 0.0.1-alpha.7

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 (75) hide show
  1. package/dist/CheckoutAddressBlock/CheckoutAddressBlock.d.ts +1 -1
  2. package/dist/CheckoutAddressBlock/CheckoutAddressBlock.d.ts.map +1 -1
  3. package/dist/CheckoutAddressCard/CheckoutAddressCard.d.ts +2 -2
  4. package/dist/CheckoutAddressCard/CheckoutAddressCard.d.ts.map +1 -1
  5. package/dist/CheckoutAddressFields/CheckoutAddressFields.d.ts +2 -2
  6. package/dist/CheckoutAddressFields/CheckoutAddressFields.d.ts.map +1 -1
  7. package/dist/CheckoutAddressFields/CheckoutAddressFields.js +8 -8
  8. package/dist/CheckoutAgreementSummaryCard/CheckoutAgreementSummaryCard.d.ts +2 -2
  9. package/dist/CheckoutAgreementSummaryCard/CheckoutAgreementSummaryCard.d.ts.map +1 -1
  10. package/dist/CheckoutCartProvider/CheckoutCartProvider.d.ts.map +1 -1
  11. package/dist/CheckoutCartProvider/CheckoutCartProvider.js +45 -42
  12. package/dist/CheckoutContactInformationSection/CheckoutContactInformationSection.d.ts +1 -0
  13. package/dist/CheckoutContactInformationSection/CheckoutContactInformationSection.d.ts.map +1 -1
  14. package/dist/CheckoutContactInformationSection/CheckoutContactInformationSection.js +50 -40
  15. package/dist/CheckoutForm/CheckoutForm.d.ts +6 -6
  16. package/dist/CheckoutForm/CheckoutForm.d.ts.map +1 -1
  17. package/dist/CheckoutForm/CheckoutForm.js +142 -120
  18. package/dist/CheckoutOrderProvider/CheckoutOrderProvider.d.ts.map +1 -1
  19. package/dist/CheckoutOrderProvider/CheckoutOrderProvider.js +41 -38
  20. package/dist/CheckoutProvider/components/CheckoutThemeProvider/CheckoutThemeProvider.d.ts.map +1 -1
  21. package/dist/CheckoutProvider/components/CheckoutThemeProvider/CheckoutThemeProvider.js +35 -36
  22. package/dist/CheckoutSummary/components/CheckoutSummaryFees/CheckoutSummaryFees.d.ts.map +1 -1
  23. package/dist/CheckoutSummary/components/CheckoutSummaryFees/CheckoutSummaryFees.js +24 -24
  24. package/dist/CheckoutSummary/components/CheckoutSummaryPaymentFees/CheckoutSummaryPaymentFees.d.ts.map +1 -1
  25. package/dist/CheckoutSummary/components/CheckoutSummaryPaymentFees/CheckoutSummaryPaymentFees.js +28 -20
  26. package/dist/CheckoutSummary/components/CheckoutSummaryShippingFees/CheckoutSummaryShippingFees.d.ts.map +1 -1
  27. package/dist/CheckoutSummary/components/CheckoutSummaryShippingFees/CheckoutSummaryShippingFees.js +34 -24
  28. package/dist/CheckoutSummary/components/CheckoutSummaryTotalBreakdown/CheckoutSummaryTotalBreakdown.d.ts.map +1 -1
  29. package/dist/CheckoutSummary/components/CheckoutSummaryTotalBreakdown/CheckoutSummaryTotalBreakdown.js +54 -53
  30. package/dist/constants/analyticsEvents.d.ts +65 -21
  31. package/dist/constants/analyticsEvents.d.ts.map +1 -1
  32. package/dist/constants/analyticsEvents.js +153 -3
  33. package/dist/fragments/CoreCartProjectionFields.d.ts +1 -1
  34. package/dist/fragments/CoreCartProjectionFields.d.ts.map +1 -1
  35. package/dist/hooks/useCheckoutAddressOptions.d.ts.map +1 -1
  36. package/dist/hooks/useCheckoutAnalytics.d.ts.map +1 -1
  37. package/dist/hooks/useCheckoutAnalytics.js +23 -18
  38. package/dist/hooks/useCheckoutAuth.d.ts +2 -0
  39. package/dist/hooks/useCheckoutAuth.d.ts.map +1 -1
  40. package/dist/hooks/useCheckoutAuth.js +40 -39
  41. package/dist/hooks/useCheckoutCart.d.ts +12 -0
  42. package/dist/hooks/useCheckoutCart.d.ts.map +1 -1
  43. package/dist/hooks/useCheckoutCart.js +128 -123
  44. package/dist/hooks/useCheckoutForm.d.ts +2 -0
  45. package/dist/hooks/useCheckoutForm.d.ts.map +1 -1
  46. package/dist/hooks/useCheckoutForm.js +55 -44
  47. package/dist/hooks/useCheckoutOrder.d.ts +12 -0
  48. package/dist/hooks/useCheckoutOrder.d.ts.map +1 -1
  49. package/dist/hooks/useCheckoutOrder.js +81 -72
  50. package/dist/mutations/addShippingMethodToCart.d.ts +10 -0
  51. package/dist/mutations/addShippingMethodToCart.d.ts.map +1 -1
  52. package/dist/mutations/addShippingMethodToCart.js +12 -2
  53. package/dist/mutations/addShippingMethodToOrder.d.ts +10 -0
  54. package/dist/mutations/addShippingMethodToOrder.d.ts.map +1 -1
  55. package/dist/mutations/addShippingMethodToOrder.js +15 -5
  56. package/dist/operations/authOperations.d.ts.map +1 -1
  57. package/dist/operations/authOperations.js +10 -2
  58. package/dist/operations/cartOperations.d.ts.map +1 -1
  59. package/dist/operations/cartOperations.js +130 -117
  60. package/dist/steps/informationStep.d.ts +1 -0
  61. package/dist/steps/informationStep.d.ts.map +1 -1
  62. package/dist/steps/informationStep.js +96 -94
  63. package/dist/steps/paymentStep.js +1 -1
  64. package/dist/steps/shippingStep.js +1 -1
  65. package/dist/types.d.ts +26 -2
  66. package/dist/types.d.ts.map +1 -1
  67. package/dist/utils/colorManipulator.d.ts +15 -15
  68. package/dist/utils/colorManipulator.d.ts.map +1 -1
  69. package/dist/utils/colorManipulator.js +86 -75
  70. package/dist/utils/formatEcommerceDataLayerItems.d.ts +11 -0
  71. package/dist/utils/formatEcommerceDataLayerItems.d.ts.map +1 -0
  72. package/dist/utils/formatEcommerceDataLayerItems.js +26 -0
  73. package/dist/utils/getAutocompletedAddress.d.ts +1 -1
  74. package/dist/utils/getAutocompletedAddress.d.ts.map +1 -1
  75. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  export interface DecomposedColor {
2
2
  type: string;
3
- colorSpace: string;
3
+ colorSpace?: string;
4
4
  values: number[];
5
5
  }
6
6
  /**
@@ -13,17 +13,17 @@ export declare const hexToRgb: (color: string) => string;
13
13
  * Returns an object with the type and values of a color.
14
14
  *
15
15
  * Note: Does not support rgb % values.
16
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
16
+ * @param {string|DecomposedColor} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
17
17
  * @returns {object} - A MUI color object: {type: string, values: number[]}
18
18
  */
19
- export declare const decomposeColor: (color: string) => any;
19
+ export declare const decomposeColor: (color: string | DecomposedColor) => DecomposedColor;
20
20
  /**
21
21
  * Returns a channel created from the input color.
22
22
  *
23
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
23
+ * @param {string|DecomposedColor} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
24
24
  * @returns {string} - The channel for the color, that can be used in rgba or hsla colors
25
25
  */
26
- export declare const colorChannel: (color: any) => any;
26
+ export declare const colorChannel: (color: string | DecomposedColor) => string;
27
27
  /**
28
28
  * Converts a color object with type and values to a string.
29
29
  * @param {object} color - Decomposed color
@@ -40,19 +40,19 @@ export declare const recomposeColor: (color: DecomposedColor) => string;
40
40
  export declare const rgbToHex: (color: string) => string;
41
41
  /**
42
42
  * Converts a color from hsl format to rgb format.
43
- * @param {string} color - HSL color values
43
+ * @param {string|DecomposedColor} color - HSL color values
44
44
  * @returns {string} rgb color values
45
45
  */
46
- export declare const hslToRgb: (color: string) => string;
46
+ export declare const hslToRgb: (color: string | DecomposedColor) => string;
47
47
  /**
48
48
  * The relative brightness of any point in a color space,
49
49
  * normalized to 0 for darkest black and 1 for lightest white.
50
50
  *
51
51
  * Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
52
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
52
+ * @param {string|DecomposedColor} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
53
53
  * @returns {number} The relative brightness of the color in the range 0 - 1
54
54
  */
55
- export declare const getLuminance: (color: string) => number;
55
+ export declare const getLuminance: (color: string | DecomposedColor) => number;
56
56
  /**
57
57
  * Calculates the contrast ratio between two colors.
58
58
  *
@@ -65,25 +65,25 @@ export declare const getContrastRatio: (foreground: string, background: string)
65
65
  /**
66
66
  * Sets the absolute transparency of a color.
67
67
  * Any existing alpha values are overwritten.
68
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
68
+ * @param {string|DecomposedColor} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
69
69
  * @param {number} value - value to set the alpha channel to in the range 0 - 1
70
70
  * @returns {string} A CSS color string. Hex input values are returned as rgb
71
71
  */
72
- export declare const alpha: (color: string, value: number) => string;
72
+ export declare const alpha: (color: string | DecomposedColor, value: number) => string;
73
73
  /**
74
74
  * Darkens a color.
75
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
75
+ * @param {string|DecomposedColor} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
76
76
  * @param {number} coefficient - multiplier in the range 0 - 1
77
77
  * @returns {string} A CSS color string. Hex input values are returned as rgb
78
78
  */
79
- export declare const darken: (color: string, coefficient: number) => string;
79
+ export declare const darken: (color: string | DecomposedColor, coefficient: number) => string;
80
80
  /**
81
81
  * Lightens a color.
82
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
82
+ * @param {string|DecomposedColor} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
83
83
  * @param {number} coefficient - multiplier in the range 0 - 1
84
84
  * @returns {string} A CSS color string. Hex input values are returned as rgb
85
85
  */
86
- export declare const lighten: (color: string, coefficient: number) => string;
86
+ export declare const lighten: (color: string | DecomposedColor, coefficient: number) => string;
87
87
  /**
88
88
  * Darken or lighten a color, depending on its luminance.
89
89
  * Light colors are darkened, dark colors are lightened.
@@ -1 +1 @@
1
- {"version":3,"file":"colorManipulator.d.ts","sourceRoot":"","sources":["../../src/utils/colorManipulator.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAqBD;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,WAmBrC,CAAC;AAOF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,QA6C3C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,UAAK,QAQjC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,eAAe,WAkBpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,WAUrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,WAuBrC,CAAC;AACF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,WAkBzC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,YAAY,MAAM,EAAE,YAAY,MAAM,WAItE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,WAcjD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,EAAE,aAAa,MAAM,WAexD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,EAAE,aAAa,MAAM,WAiBzD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,EAAE,oBAAkB,WAI1D,CAAC"}
1
+ {"version":3,"file":"colorManipulator.d.ts","sourceRoot":"","sources":["../../src/utils/colorManipulator.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAqBD;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,WAmBrC,CAAC;AAOF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,GAAG,eAAe,KAC9B,eA8CF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,GAAG,eAAe,WAQ3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,eAAe,WAqBpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,WAUrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,GAAG,eAAe,WAuBvD,CAAC;AACF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,GAAG,eAAe,WAwB3D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,YAAY,MAAM,EAAE,YAAY,MAAM,WAItE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,GAAG,eAAe,EAAE,OAAO,MAAM,WAcnE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GACjB,OAAO,MAAM,GAAG,eAAe,EAC/B,aAAa,MAAM,WAiBpB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAClB,OAAO,MAAM,GAAG,eAAe,EAC/B,aAAa,MAAM,WAwBpB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,EAAE,oBAAkB,WAI1D,CAAC"}
@@ -1,98 +1,109 @@
1
- const g = (e, t = 0, n = 1) => (process.env.NODE_ENV !== "production" && (e < t || e > n) && console.error(
2
- `MUI: The value provided ${e} is out of range [${t}, ${n}].`
3
- ), Math.min(Math.max(t, e), n)), m = (e) => {
4
- e = e.slice(1);
5
- const t = new RegExp(`.{1,${e.length >= 6 ? 2 : 1}}`, "g");
6
- let n = e.match(t);
7
- return n && n[0].length === 1 && (n = n.map((s) => s + s)), n ? `rgb${n.length === 4 ? "a" : ""}(${n.map((s, r) => r < 3 ? parseInt(s, 16) : Math.round(parseInt(s, 16) / 255 * 1e3) / 1e3).join(", ")})` : "";
8
- }, x = (e) => {
9
- const t = e.toString(16);
1
+ const h = (r, t = 0, e = 1) => (process.env.NODE_ENV !== "production" && (r < t || r > e) && console.error(
2
+ `MUI: The value provided ${r} is out of range [${t}, ${e}].`
3
+ ), Math.min(Math.max(t, r), e)), m = (r) => {
4
+ r = r.slice(1);
5
+ const t = new RegExp(`.{1,${r.length >= 6 ? 2 : 1}}`, "g");
6
+ let e = r.match(t);
7
+ return e && e[0].length === 1 && (e = e.map((s) => s + s)), e ? `rgb${e.length === 4 ? "a" : ""}(${e.map((s, o) => o < 3 ? parseInt(s, 16) : Math.round(parseInt(s, 16) / 255 * 1e3) / 1e3).join(", ")})` : "";
8
+ }, b = (r) => {
9
+ const t = r.toString(16);
10
10
  return t.length === 1 ? `0${t}` : t;
11
- }, a = (e) => {
12
- if (e.type)
13
- return e;
14
- if (e.charAt(0) === "#")
15
- return a(m(e));
16
- const t = e.indexOf("("), n = e.substring(0, t);
17
- if (["rgb", "rgba", "hsl", "hsla", "color"].indexOf(n) === -1)
11
+ }, l = (r) => {
12
+ if (typeof r != "string")
13
+ return r;
14
+ if (r.charAt(0) === "#")
15
+ return l(m(r));
16
+ const t = r.indexOf("("), e = r.substring(0, t);
17
+ if (["rgb", "rgba", "hsl", "hsla", "color"].indexOf(e) === -1)
18
18
  throw new Error(
19
19
  `MUI: Unsupported color.
20
20
  The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`
21
21
  );
22
- let s = e.substring(t + 1, e.length - 1), r;
23
- if (n === "color") {
24
- if (s = s.split(" "), r = s.shift(), s.length === 4 && s[3].charAt(0) === "/" && (s[3] = s[3].slice(1)), ["srgb", "display-p3", "a98-rgb", "prophoto-rgb", "rec-2020"].indexOf(
25
- r
22
+ const s = r.substring(t + 1, r.length - 1);
23
+ let o, a;
24
+ if (e === "color") {
25
+ const n = s.split(" ");
26
+ if (o = n.shift(), n.length === 4 && n[3].charAt(0) === "/" && (n[3] = n[3].slice(1)), ["srgb", "display-p3", "a98-rgb", "prophoto-rgb", "rec-2020"].indexOf(
27
+ o
26
28
  ) === -1)
27
29
  throw new Error(
28
30
  `MUI: unsupported color space.
29
31
  The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`
30
32
  );
33
+ a = n.map((p) => parseFloat(p));
31
34
  } else
32
- s = s.split(",");
33
- return s = s.map((p) => parseFloat(p)), { type: n, values: s, colorSpace: r };
34
- }, M = (e) => {
35
- const t = a(e);
35
+ a = s.split(",").map((n) => parseFloat(n));
36
+ return { type: e, values: a, colorSpace: o };
37
+ }, $ = (r) => {
38
+ const t = l(r);
36
39
  return t.values.slice(0, 3).map(
37
- (n, s) => t.type.indexOf("hsl") !== -1 && s !== 0 ? `${n}%` : n
40
+ (e, s) => t.type.indexOf("hsl") !== -1 && s !== 0 ? `${e}%` : e
38
41
  ).join(" ");
39
- }, i = (e) => {
40
- const { type: t, colorSpace: n } = e;
41
- let { values: s } = e;
42
- return t.indexOf("rgb") !== -1 ? s = s.map((r, p) => p < 3 ? parseInt(r, 10) : r) : t.indexOf("hsl") !== -1 && (s[1] = `${s[1]}%`, s[2] = `${s[2]}%`), t.indexOf("color") !== -1 ? s = `${n} ${s.join(" ")}` : s = `${s.join(", ")}`, `${t}(${s})`;
43
- }, O = (e) => {
44
- if (e.indexOf("#") === 0)
45
- return e;
46
- const { values: t } = a(e);
47
- return `#${t.map((n, s) => x(s === 3 ? Math.round(255 * n) : n)).join("")}`;
48
- }, y = (e) => {
49
- e = a(e);
50
- const { values: t } = e, n = t[0], s = t[1] / 100, r = t[2] / 100, p = s * Math.min(r, 1 - r), u = (b, f = (b + n / 30) % 12) => r - p * Math.max(Math.min(f - 3, 9 - f, 1), -1);
51
- let d = "rgb";
52
- const l = [
53
- Math.round(u(0) * 255),
54
- Math.round(u(8) * 255),
55
- Math.round(u(4) * 255)
42
+ }, u = (r) => {
43
+ const { type: t, colorSpace: e } = r;
44
+ let { values: s } = r;
45
+ t.indexOf("rgb") !== -1 ? s = s.map(
46
+ (a, n) => n < 3 ? parseInt(a, 10) : a
47
+ ) : t.indexOf("hsl") !== -1 && (s[1] = `${s[1]}%`, s[2] = `${s[2]}%`);
48
+ let o;
49
+ return t.indexOf("color") !== -1 ? o = `${e} ${s.join(" ")}` : o = `${s.join(", ")}`, `${t}(${o})`;
50
+ }, M = (r) => {
51
+ if (r.indexOf("#") === 0)
52
+ return r;
53
+ const { values: t } = l(r);
54
+ return `#${t.map((e, s) => b(s === 3 ? Math.round(255 * e) : e)).join("")}`;
55
+ }, x = (r) => {
56
+ const t = l(r), { values: e } = t, s = e[0], o = e[1] / 100, a = e[2] / 100, n = o * Math.min(a, 1 - a), p = (f, g = (f + s / 30) % 12) => a - n * Math.max(Math.min(g - 3, 9 - g, 1), -1);
57
+ let c = "rgb";
58
+ const d = [
59
+ Math.round(p(0) * 255),
60
+ Math.round(p(8) * 255),
61
+ Math.round(p(4) * 255)
56
62
  ];
57
- return e.type === "hsla" && (d += "a", l.push(t[3])), i({ type: d, values: l });
58
- }, h = (e) => {
59
- e = a(e);
60
- let t = e.type === "hsl" ? a(y(e)).values : e.values;
61
- return t = t.map((n) => (e.type !== "color" && (n /= 255), n <= 0.03928 ? n / 12.92 : ((n + 0.055) / 1.055) ** 2.4)), Number(
62
- (0.2126 * t[0] + 0.7152 * t[1] + 0.0722 * t[2]).toFixed(3)
63
+ return t.type === "hsla" && (c += "a", d.push(e[3])), u({ type: c, values: d });
64
+ }, i = (r) => {
65
+ const t = l(r);
66
+ let e = t.type === "hsl" ? l(x(t)).values : t.values;
67
+ return e = e.map((s) => (t.type !== "color" && (s = s / 255), s <= 0.03928 ? s / 12.92 : (s + 0.055) / 1.1371189658248801)), Number(
68
+ (0.2126 * e[0] + 0.7152 * e[1] + 0.0722 * e[2]).toFixed(3)
63
69
  );
64
- }, v = (e, t) => {
65
- const n = h(e), s = h(t);
66
- return (Math.max(n, s) + 0.05) / (Math.min(n, s) + 0.05);
67
- }, w = (e, t) => (e = a(e), t = g(t), (e.type === "rgb" || e.type === "hsl") && (e.type += "a"), e.type === "color" ? e.values[3] = `/${t}` : e.values[3] = t, i(e)), o = (e, t) => {
68
- if (e = a(e), t = g(t), e.type.indexOf("hsl") !== -1)
69
- e.values[2] *= 1 - t;
70
+ }, O = (r, t) => {
71
+ const e = i(r), s = i(t);
72
+ return (Math.max(e, s) + 0.05) / (Math.min(e, s) + 0.05);
73
+ }, w = (r, t) => {
74
+ const e = l(r);
75
+ return t = h(t), (e.type === "rgb" || e.type === "hsl") && (e.type += "a"), e.type === "color" ? e.values[3] = `/${t}` : e.values[3] = t, u(e);
76
+ }, y = (r, t) => {
77
+ const e = l(r);
78
+ if (t = h(t), e.type.indexOf("hsl") !== -1)
79
+ e.values[2] = e.values[2] * (1 - t);
70
80
  else if (e.type.indexOf("rgb") !== -1 || e.type.indexOf("color") !== -1)
71
- for (let n = 0; n < 3; n += 1)
72
- e.values[n] *= 1 - t;
73
- return i(e);
74
- }, $ = (e, t) => {
75
- if (e = a(e), t = g(t), e.type.indexOf("hsl") !== -1)
76
- e.values[2] += (100 - e.values[2]) * t;
81
+ for (let s = 0; s < 3; s += 1)
82
+ e.values[s] = e.values[s] * (1 - t);
83
+ return u(e);
84
+ }, v = (r, t) => {
85
+ const e = l(r);
86
+ if (t = h(t), e.type.indexOf("hsl") !== -1)
87
+ e.values[2] = e.values[2] + (100 - e.values[2]) * t;
77
88
  else if (e.type.indexOf("rgb") !== -1)
78
- for (let n = 0; n < 3; n += 1)
79
- e.values[n] += (255 - e.values[n]) * t;
89
+ for (let s = 0; s < 3; s += 1)
90
+ e.values[s] = e.values[s] + (255 - e.values[s]) * t;
80
91
  else if (e.type.indexOf("color") !== -1)
81
- for (let n = 0; n < 3; n += 1)
82
- e.values[n] += (1 - e.values[n]) * t;
83
- return i(e);
84
- }, T = (e, t = 0.15) => h(e) > 0.5 ? o(e, t) : $(e, t);
92
+ for (let s = 0; s < 3; s += 1)
93
+ e.values[s] = e.values[s] + (1 - e.values[s]) * t;
94
+ return u(e);
95
+ }, T = (r, t = 0.15) => i(r) > 0.5 ? y(r, t) : v(r, t);
85
96
  export {
86
97
  w as alpha,
87
- M as colorChannel,
88
- o as darken,
89
- a as decomposeColor,
98
+ $ as colorChannel,
99
+ y as darken,
100
+ l as decomposeColor,
90
101
  T as emphasize,
91
- v as getContrastRatio,
92
- h as getLuminance,
102
+ O as getContrastRatio,
103
+ i as getLuminance,
93
104
  m as hexToRgb,
94
- y as hslToRgb,
95
- $ as lighten,
96
- i as recomposeColor,
97
- O as rgbToHex
105
+ x as hslToRgb,
106
+ v as lighten,
107
+ u as recomposeColor,
108
+ M as rgbToHex
98
109
  };
@@ -0,0 +1,11 @@
1
+ import { CheckoutBaseItem } from '../types';
2
+ export declare const formatEcommerceDataLayerItems: (items: CheckoutBaseItem[]) => {
3
+ quantity: number;
4
+ price?: number | undefined;
5
+ item_brand?: string | undefined;
6
+ index: number;
7
+ discount?: number | undefined;
8
+ item_id: string;
9
+ item_name: string | undefined;
10
+ }[];
11
+ //# sourceMappingURL=formatEcommerceDataLayerItems.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatEcommerceDataLayerItems.d.ts","sourceRoot":"","sources":["../../src/utils/formatEcommerceDataLayerItems.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,eAAO,MAAM,6BAA6B,GAAI,OAAO,gBAAgB,EAAE;;;;;;;;GA+BtE,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { isDefined as e } from "@afosto/utils";
2
+ const x = (o) => o.map((r, a) => {
3
+ const {
4
+ adjustments: c = [],
5
+ brand: n = "",
6
+ details: m = [],
7
+ ids: s = [],
8
+ label: d,
9
+ quantity: u = 1
10
+ } = r, [p] = s, [l] = m, t = c.reduce(
11
+ (b, f) => b + (f.outcome?.amount || 0),
12
+ 0
13
+ ), { amount: i = 0 } = l?.pricing || {};
14
+ return {
15
+ item_id: p,
16
+ item_name: d,
17
+ ...e(t) && t !== 0 ? { discount: t / 100 } : {},
18
+ index: a,
19
+ ...e(n) ? { item_brand: n } : {},
20
+ ...e(i) ? { price: i / 100 } : {},
21
+ quantity: u
22
+ };
23
+ });
24
+ export {
25
+ x as formatEcommerceDataLayerItems
26
+ };
@@ -30,7 +30,7 @@ export interface AddressAutocompleteResponse {
30
30
  };
31
31
  };
32
32
  }
33
- export declare const getAutocompletedAddress: (countryAlpha3Code: string, address: Pick<Address, "locality" | "postalCode" | "premiseNumber" | "premiseNumberSuffix" | "thoroughfare">, { retry }?: {
33
+ export declare const getAutocompletedAddress: (countryAlpha3Code: string, address: Partial<Pick<Address, "locality" | "postalCode" | "premiseNumber" | "premiseNumberSuffix" | "thoroughfare">>, { retry }?: {
34
34
  retry?: boolean | undefined;
35
35
  }) => Promise<AddressAutocompleteResultAddress | null>;
36
36
  //# sourceMappingURL=getAutocompletedAddress.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getAutocompletedAddress.d.ts","sourceRoot":"","sources":["../../src/utils/getAutocompletedAddress.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE;QACJ,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gCAAgC;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE;QACJ,OAAO,EAAE,yBAAyB,EAAE,CAAC;QACrC,MAAM,EAAE;YACN,OAAO,CAAC,EAAE,gCAAgC,CAAC;YAC3C,UAAU,EAAE,OAAO,CAAC;YACpB,GAAG,EAAE,MAAM,CAAC;YACZ,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;CACH;AAqGD,eAAO,MAAM,uBAAuB,GAClC,mBAAmB,MAAM,EACzB,SAAS,IAAI,CACX,OAAO,EACL,UAAU,GACV,YAAY,GACZ,eAAe,GACf,qBAAqB,GACrB,cAAc,CACjB,EACD;;CAAqB,KACpB,OAAO,CAAC,gCAAgC,GAAG,IAAI,CAqCjD,CAAC"}
1
+ {"version":3,"file":"getAutocompletedAddress.d.ts","sourceRoot":"","sources":["../../src/utils/getAutocompletedAddress.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE;QACJ,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gCAAgC;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE;QACJ,OAAO,EAAE,yBAAyB,EAAE,CAAC;QACrC,MAAM,EAAE;YACN,OAAO,CAAC,EAAE,gCAAgC,CAAC;YAC3C,UAAU,EAAE,OAAO,CAAC;YACpB,GAAG,EAAE,MAAM,CAAC;YACZ,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;CACH;AAqGD,eAAO,MAAM,uBAAuB,GAClC,mBAAmB,MAAM,EACzB,SAAS,OAAO,CACd,IAAI,CACF,OAAO,EACL,UAAU,GACV,YAAY,GACZ,eAAe,GACf,qBAAqB,GACrB,cAAc,CACjB,CACF,EACD;;CAAqB,KACpB,OAAO,CAAC,gCAAgC,GAAG,IAAI,CAqCjD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afosto/checkout-ui",
3
- "version": "0.0.1-alpha.5",
3
+ "version": "0.0.1-alpha.7",
4
4
  "description": "Afosto react checkout ui components",
5
5
  "author": "Afosto",
6
6
  "license": "MIT",