@purpur/library 9.3.0 → 9.4.0

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 (46) hide show
  1. package/CHANGELOG.json +12 -0
  2. package/CHANGELOG.md +8 -1
  3. package/dist/LICENSE.txt +1 -1
  4. package/dist/{comparison-table-Dmbjsqyg.mjs → comparison-table-8bOJmz-L.mjs} +104 -104
  5. package/dist/{comparison-table-Dmbjsqyg.mjs.map → comparison-table-8bOJmz-L.mjs.map} +1 -1
  6. package/dist/comparison-table-mKL2IHXW.js +2 -0
  7. package/dist/{comparison-table-CitEzX7h.js.map → comparison-table-mKL2IHXW.js.map} +1 -1
  8. package/dist/comparison-table.cjs.js +1 -1
  9. package/dist/comparison-table.es.js +1 -1
  10. package/dist/components/drawer/src/drawer-content.d.ts.map +1 -1
  11. package/dist/components/drawer/src/drawer.context.d.ts +1 -0
  12. package/dist/components/drawer/src/drawer.context.d.ts.map +1 -1
  13. package/dist/components/drawer/src/drawer.d.ts +6 -0
  14. package/dist/components/drawer/src/drawer.d.ts.map +1 -1
  15. package/dist/{date-picker-DwFDRL5Z.mjs → date-picker-CbUNbOhn.mjs} +2 -2
  16. package/dist/{date-picker-DwFDRL5Z.mjs.map → date-picker-CbUNbOhn.mjs.map} +1 -1
  17. package/dist/{date-picker-DVrcu2QU.js → date-picker-DYXNB5aU.js} +2 -2
  18. package/dist/{date-picker-DVrcu2QU.js.map → date-picker-DYXNB5aU.js.map} +1 -1
  19. package/dist/date-picker.cjs.js +1 -1
  20. package/dist/date-picker.es.js +1 -1
  21. package/dist/drawer-8Acg4wkV.mjs +574 -0
  22. package/dist/drawer-8Acg4wkV.mjs.map +1 -0
  23. package/dist/drawer-BLHgcEqb.js +2 -0
  24. package/dist/drawer-BLHgcEqb.js.map +1 -0
  25. package/dist/drawer.cjs.js +1 -1
  26. package/dist/drawer.es.js +1 -1
  27. package/dist/{index-CKCTy3ZL.mjs → index-3NV-ckDX.mjs} +4 -4
  28. package/dist/{index-CKCTy3ZL.mjs.map → index-3NV-ckDX.mjs.map} +1 -1
  29. package/dist/library.cjs.js +1 -1
  30. package/dist/library.es.js +5 -5
  31. package/dist/{modal-COZ1POGG.mjs → modal-fp37VbrH.mjs} +2 -2
  32. package/dist/{modal-COZ1POGG.mjs.map → modal-fp37VbrH.mjs.map} +1 -1
  33. package/dist/modal.es.js +1 -1
  34. package/dist/purpur.css +1 -1
  35. package/dist/{table-DUY8kQfE.mjs → table-D_sdSJyr.mjs} +2 -2
  36. package/dist/{table-DUY8kQfE.mjs.map → table-D_sdSJyr.mjs.map} +1 -1
  37. package/dist/{table-DRYW0yw4.js → table-gnGUejtb.js} +2 -2
  38. package/dist/{table-DRYW0yw4.js.map → table-gnGUejtb.js.map} +1 -1
  39. package/dist/table.cjs.js +1 -1
  40. package/dist/table.es.js +1 -1
  41. package/package.json +19 -19
  42. package/dist/comparison-table-CitEzX7h.js +0 -2
  43. package/dist/drawer-Db2Mujc6.mjs +0 -565
  44. package/dist/drawer-Db2Mujc6.mjs.map +0 -1
  45. package/dist/drawer-DlwagnO4.js +0 -2
  46. package/dist/drawer-DlwagnO4.js.map +0 -1
package/CHANGELOG.json CHANGED
@@ -1,6 +1,18 @@
1
1
  {
2
2
  "name": "@purpur/library",
3
3
  "entries": [
4
+ {
5
+ "version": "9.4.0",
6
+ "tag": "@purpur/library_v9.4.0",
7
+ "date": "Mon, 11 May 2026 13:20:15 GMT",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "comment": "Drawer: Added modal prop, to allow for setting modal=false when loading Components that uses Portals inside the drawer."
12
+ }
13
+ ]
14
+ }
15
+ },
4
16
  {
5
17
  "version": "9.3.0",
6
18
  "tag": "@purpur/library_v9.3.0",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Change Log - @purpur/library
2
2
 
3
- This log was last generated on Mon, 11 May 2026 08:07:05 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 11 May 2026 13:20:15 GMT and should not be manually modified.
4
+
5
+ ## 9.4.0
6
+ Mon, 11 May 2026 13:20:15 GMT
7
+
8
+ ### Updates
9
+
10
+ - Drawer: Added modal prop, to allow for setting modal=false when loading Components that uses Portals inside the drawer.
4
11
 
5
12
  ## 9.3.0
6
13
  Mon, 11 May 2026 08:07:05 GMT
package/dist/LICENSE.txt CHANGED
@@ -473,7 +473,7 @@ Private: false
473
473
  ---
474
474
 
475
475
  Name: @purpur/chat-field
476
- Version: 9.2.3
476
+ Version: 9.3.0
477
477
  License: AGPL-3.0-only
478
478
  Private: false
479
479
 
@@ -1,4 +1,4 @@
1
- import { jsx as o, jsxs as u } from "react/jsx-runtime";
1
+ import { jsx as o, jsxs as _ } from "react/jsx-runtime";
2
2
  import { isValidElement as q, useState as L, useCallback as E, useEffect as R, useId as B, useRef as F, createElement as H } from "react";
3
3
  import { c as z } from "./bind-CU-R61T-.mjs";
4
4
  import { a as K } from "./checkmark.es-DdgIZN2R.mjs";
@@ -23,125 +23,125 @@ const X = {
23
23
  "purpur-comparison-table-cell--check": "_purpur-comparison-table-cell--check_117pb_16",
24
24
  "purpur-comparison-table-cell--minus": "_purpur-comparison-table-cell--minus_117pb_19",
25
25
  "purpur-comparison-table-cell__icon": "_purpur-comparison-table-cell__icon_117pb_22"
26
- }, A = z.bind(Y), D = "purpur-comparison-table-cell", Z = ({ value: a }) => {
27
- const s = q(a) || ["string", "number"].includes(typeof a), m = A(D, [s ? "" : `${D}--${a ? "check" : "minus"}`]), c = a ? K : W;
28
- return /* @__PURE__ */ o("span", { className: A(m), children: s ? a : /* @__PURE__ */ o(c, { size: "xs", className: A(`${D}__icon`) }) });
26
+ }, A = z.bind(Y), D = "purpur-comparison-table-cell", Z = ({ value: e }) => {
27
+ const s = q(e) || ["string", "number"].includes(typeof e), m = A(D, [s ? "" : `${D}--${e ? "check" : "minus"}`]), c = e ? K : W;
28
+ return /* @__PURE__ */ o("span", { className: A(m), children: s ? e : /* @__PURE__ */ o(c, { size: "xs", className: A(`${D}__icon`) }) });
29
29
  }, rr = {
30
30
  "purpur-comparison-table-lead-cell": "_purpur-comparison-table-lead-cell_1vild_1",
31
31
  "purpur-comparison-table-lead-cell__description": "_purpur-comparison-table-lead-cell__description_1vild_5",
32
32
  "purpur-comparison-table-lead-cell__summary": "_purpur-comparison-table-lead-cell__summary_1vild_40",
33
33
  "purpur-comparison-table-lead-cell__summary-title": "_purpur-comparison-table-lead-cell__summary-title_1vild_48",
34
34
  "purpur-comparison-table-lead-cell__summary-icon": "_purpur-comparison-table-lead-cell__summary-icon_1vild_51"
35
- }, k = z.bind(rr), S = "purpur-comparison-table-lead-cell", or = ({ title: a, description: s }) => {
36
- const p = typeof s == "string", m = k(S);
37
- return /* @__PURE__ */ u("details", { className: m, "data-is-expandable": p, children: [
38
- /* @__PURE__ */ u("summary", { className: k(`${S}__summary`), tabIndex: p ? 0 : -1, children: [
39
- /* @__PURE__ */ o(j, { className: k(`${S}__summary-title`), variant: "paragraph-100-bold", children: a }),
35
+ }, k = z.bind(rr), S = "purpur-comparison-table-lead-cell", or = ({ title: e, description: s }) => {
36
+ const l = typeof s == "string", m = k(S);
37
+ return /* @__PURE__ */ _("details", { className: m, "data-is-expandable": l, children: [
38
+ /* @__PURE__ */ _("summary", { className: k(`${S}__summary`), tabIndex: l ? 0 : -1, children: [
39
+ /* @__PURE__ */ o(j, { className: k(`${S}__summary-title`), variant: "paragraph-100-bold", children: e }),
40
40
  /* @__PURE__ */ o(O, { className: k(`${S}__summary-icon`), size: "sm" })
41
41
  ] }),
42
42
  s && /* @__PURE__ */ o(j, { variant: "paragraph-100", className: k(`${S}__description`), children: s })
43
43
  ] });
44
- }, ar = {
45
- "purpur-comparison-table-option-card": "_purpur-comparison-table-option-card_1papu_1",
46
- "purpur-comparison-table-option-card--highlighted": "_purpur-comparison-table-option-card--highlighted_1papu_11",
47
- "purpur-comparison-table-option-card__badge": "_purpur-comparison-table-option-card__badge_1papu_14",
48
- "purpur-comparison-table-option-card__main-content": "_purpur-comparison-table-option-card__main-content_1papu_19",
49
- "purpur-comparison-table-option-card__image": "_purpur-comparison-table-option-card__image_1papu_25",
50
- "purpur-comparison-table-option-card__body": "_purpur-comparison-table-option-card__body_1papu_31",
51
- "purpur-comparison-table-option-card__description": "_purpur-comparison-table-option-card__description_1papu_36",
52
- "purpur-comparison-table-option-card__description-text": "_purpur-comparison-table-option-card__description-text_1papu_41",
53
- "purpur-comparison-table-option-card__read-more": "_purpur-comparison-table-option-card__read-more_1papu_50",
54
- "purpur-comparison-table-option-card__read-more-icon": "_purpur-comparison-table-option-card__read-more-icon_1papu_54",
55
- "purpur-comparison-table-option-card__footer": "_purpur-comparison-table-option-card__footer_1papu_62",
56
- "purpur-comparison-table-option-card__price": "_purpur-comparison-table-option-card__price_1papu_67",
57
- "purpur-comparison-table-option-card--show-full-descriptions": "_purpur-comparison-table-option-card--show-full-descriptions_1papu_74",
58
- "purpur-comparison-table-option-card--first-card": "_purpur-comparison-table-option-card--first-card_1papu_107"
59
- }, _ = z.bind(ar), l = "purpur-comparison-table-option-card", er = ({
60
- id: a,
44
+ }, er = {
45
+ "purpur-comparison-table-option-card": "_purpur-comparison-table-option-card_15113_1",
46
+ "purpur-comparison-table-option-card--highlighted": "_purpur-comparison-table-option-card--highlighted_15113_11",
47
+ "purpur-comparison-table-option-card__badge": "_purpur-comparison-table-option-card__badge_15113_14",
48
+ "purpur-comparison-table-option-card__main-content": "_purpur-comparison-table-option-card__main-content_15113_19",
49
+ "purpur-comparison-table-option-card__image": "_purpur-comparison-table-option-card__image_15113_25",
50
+ "purpur-comparison-table-option-card__body": "_purpur-comparison-table-option-card__body_15113_31",
51
+ "purpur-comparison-table-option-card__description": "_purpur-comparison-table-option-card__description_15113_36",
52
+ "purpur-comparison-table-option-card__description-text": "_purpur-comparison-table-option-card__description-text_15113_41",
53
+ "purpur-comparison-table-option-card__read-more": "_purpur-comparison-table-option-card__read-more_15113_50",
54
+ "purpur-comparison-table-option-card__read-more-icon": "_purpur-comparison-table-option-card__read-more-icon_15113_54",
55
+ "purpur-comparison-table-option-card__footer": "_purpur-comparison-table-option-card__footer_15113_62",
56
+ "purpur-comparison-table-option-card__price": "_purpur-comparison-table-option-card__price_15113_67",
57
+ "purpur-comparison-table-option-card--show-full-descriptions": "_purpur-comparison-table-option-card--show-full-descriptions_15113_74",
58
+ "purpur-comparison-table-option-card--first-card": "_purpur-comparison-table-option-card--first-card_15113_107"
59
+ }, u = z.bind(er), p = "purpur-comparison-table-option-card", ar = ({
60
+ id: e,
61
61
  description: s,
62
- variablePriceText: p,
62
+ variablePriceText: l,
63
63
  price: m,
64
64
  isHighlighted: c,
65
65
  ariaLabels: f,
66
66
  badge: h,
67
67
  actions: g,
68
- isFirstCard: N,
68
+ isFirstCard: v,
69
69
  image: $,
70
70
  title: C,
71
71
  showFullDescriptions: r,
72
72
  toggleShowFullDescriptions: i
73
73
  }) => {
74
- const d = _(l, {
75
- [`${l}--highlighted`]: c,
76
- [`${l}--first-card`]: N,
77
- [`${l}--show-full-descriptions`]: r
74
+ const d = u(p, {
75
+ [`${p}--highlighted`]: c,
76
+ [`${p}--first-card`]: v,
77
+ [`${p}--show-full-descriptions`]: r
78
78
  }), b = () => {
79
79
  if (!s) return null;
80
80
  const n = s.length > 50;
81
- return /* @__PURE__ */ u("div", { className: _(`${l}__description`), children: [
82
- /* @__PURE__ */ o(j, { variant: "paragraph-100", className: _(`${l}__description-text`), children: s }),
83
- n && /* @__PURE__ */ u(
81
+ return /* @__PURE__ */ _("div", { className: u(`${p}__description`), children: [
82
+ /* @__PURE__ */ o(j, { variant: "paragraph-100", className: u(`${p}__description-text`), children: s }),
83
+ n && /* @__PURE__ */ _(
84
84
  M,
85
85
  {
86
86
  variant: "text",
87
87
  size: "xs",
88
- className: _(`${l}__read-more`),
88
+ className: u(`${p}__read-more`),
89
89
  onClick: i,
90
90
  children: [
91
- /* @__PURE__ */ o("span", { className: _(`${l}__read-more-text`), children: r ? f.readLess : f.readMore }),
92
- /* @__PURE__ */ o(O, { className: _(`${l}__read-more-icon`), size: "xs" })
91
+ /* @__PURE__ */ o("span", { className: u(`${p}__read-more-text`), children: r ? f.readLess : f.readMore }),
92
+ /* @__PURE__ */ o(O, { className: u(`${p}__read-more-icon`), size: "xs" })
93
93
  ]
94
94
  }
95
95
  )
96
96
  ] });
97
97
  };
98
- return /* @__PURE__ */ u("article", { className: d, "data-card-id": a, children: [
99
- h && /* @__PURE__ */ o(G, { ...h, className: _(`${l}__badge`) }),
100
- /* @__PURE__ */ u("section", { className: _(`${l}__main-content`), children: [
101
- /* @__PURE__ */ o("img", { src: $.src, alt: $.alt, className: _(`${l}__image`) }),
102
- /* @__PURE__ */ u("div", { className: _(`${l}__body`), children: [
103
- /* @__PURE__ */ o(J, { tag: "h3", variant: "title-200", className: _(`${l}__title`), children: C }),
98
+ return /* @__PURE__ */ _("article", { className: d, "data-card-id": e, children: [
99
+ h && /* @__PURE__ */ o(G, { ...h, className: u(`${p}__badge`) }),
100
+ /* @__PURE__ */ _("section", { className: u(`${p}__main-content`), children: [
101
+ /* @__PURE__ */ o("img", { src: $.src, alt: $.alt, className: u(`${p}__image`) }),
102
+ /* @__PURE__ */ _("div", { className: u(`${p}__body`), children: [
103
+ /* @__PURE__ */ o(J, { tag: "h3", variant: "title-200", className: u(`${p}__title`), children: C }),
104
104
  b()
105
105
  ] })
106
106
  ] }),
107
- /* @__PURE__ */ u("footer", { className: _(`${l}__footer`), children: [
108
- /* @__PURE__ */ u("span", { className: _(`${l}__price`), id: a, children: [
109
- /* @__PURE__ */ o(j, { variant: "paragraph-100", children: p }),
107
+ /* @__PURE__ */ _("footer", { className: u(`${p}__footer`), children: [
108
+ /* @__PURE__ */ _("span", { className: u(`${p}__price`), id: e, children: [
109
+ /* @__PURE__ */ o(j, { variant: "paragraph-100", children: l }),
110
110
  /* @__PURE__ */ o(j, { variant: "paragraph-100-bold", children: m })
111
111
  ] }),
112
112
  g
113
113
  ] })
114
114
  ] });
115
- }, tr = "_active_1v9i8_44", sr = {
116
- "purpur-comparison-table-scroll-progress": "_purpur-comparison-table-scroll-progress_1v9i8_1",
117
- "purpur-comparison-table-scroll-progress__indicators": "_purpur-comparison-table-scroll-progress__indicators_1v9i8_15",
118
- "purpur-comparison-table-scroll-progress__indicator": "_purpur-comparison-table-scroll-progress__indicator_1v9i8_15",
115
+ }, tr = "_active_ybbe8_44", sr = {
116
+ "purpur-comparison-table-scroll-progress": "_purpur-comparison-table-scroll-progress_ybbe8_1",
117
+ "purpur-comparison-table-scroll-progress__indicators": "_purpur-comparison-table-scroll-progress__indicators_ybbe8_15",
118
+ "purpur-comparison-table-scroll-progress__indicator": "_purpur-comparison-table-scroll-progress__indicator_ybbe8_15",
119
119
  active: tr,
120
- "purpur-comparison-table-scroll-progress__buttons": "_purpur-comparison-table-scroll-progress__buttons_1v9i8_48",
121
- "purpur-comparison-table-scroll-progress__button": "_purpur-comparison-table-scroll-progress__button_1v9i8_48",
122
- "purpur-comparison-table-scroll-progress__button-icon": "_purpur-comparison-table-scroll-progress__button-icon_1v9i8_57"
123
- }, y = z.bind(sr), v = "purpur-comparison-table-scroll-progress", cr = ({ items: a, container: s, parentId: p, ariaLabels: m }) => {
120
+ "purpur-comparison-table-scroll-progress__buttons": "_purpur-comparison-table-scroll-progress__buttons_ybbe8_48",
121
+ "purpur-comparison-table-scroll-progress__button": "_purpur-comparison-table-scroll-progress__button_ybbe8_48",
122
+ "purpur-comparison-table-scroll-progress__button-icon": "_purpur-comparison-table-scroll-progress__button-icon_ybbe8_57"
123
+ }, y = z.bind(sr), N = "purpur-comparison-table-scroll-progress", cr = ({ items: e, container: s, parentId: l, ariaLabels: m }) => {
124
124
  const [c, f] = L(/* @__PURE__ */ new Set()), h = E(
125
125
  (r) => {
126
126
  const i = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
127
127
  document.querySelector(
128
- `[data-card-id="${r}-${p}"]`
128
+ `[data-card-id="${r}-${l}"]`
129
129
  )?.scrollIntoView({ behavior: i ? "instant" : "smooth", block: "nearest" });
130
130
  },
131
- [p]
131
+ [l]
132
132
  ), g = E(() => {
133
133
  if (c.size === 0) return;
134
134
  const i = Math.min(...Array.from(c)) - 1;
135
135
  i < 0 || h(i);
136
- }, [c, h]), N = E(() => {
136
+ }, [c, h]), v = E(() => {
137
137
  if (c.size === 0) return;
138
138
  const i = Math.max(...Array.from(c)) + 1;
139
- i >= a.length || h(i);
140
- }, [c, a.length, h]), $ = E(
139
+ i >= e.length || h(i);
140
+ }, [c, e.length, h]), $ = E(
141
141
  (r) => {
142
- (r.key === "ArrowRight" || r.key === "ArrowLeft") && (r.preventDefault(), r.key === "ArrowRight" ? N() : r.key === "ArrowLeft" && g());
142
+ (r.key === "ArrowRight" || r.key === "ArrowLeft") && (r.preventDefault(), r.key === "ArrowRight" ? v() : r.key === "ArrowLeft" && g());
143
143
  },
144
- [N, g]
144
+ [v, g]
145
145
  );
146
146
  R(() => {
147
147
  const r = s.current;
@@ -149,52 +149,52 @@ const X = {
149
149
  const i = new IntersectionObserver(
150
150
  (d) => {
151
151
  f((b) => {
152
- const e = new Set(b);
152
+ const a = new Set(b);
153
153
  return d.forEach((n) => {
154
- let t = n.target.getAttribute("data-card-id")?.match(new RegExp(`(\\d+)-${p}`))?.[1];
155
- t && (t = parseInt(t, 10), n.isIntersecting ? e.add(t) : e.delete(t));
156
- }), e;
154
+ let t = n.target.getAttribute("data-card-id")?.match(new RegExp(`(\\d+)-${l}`))?.[1];
155
+ t && (t = parseInt(t, 10), n.isIntersecting ? a.add(t) : a.delete(t));
156
+ }), a;
157
157
  });
158
158
  },
159
159
  { root: r, threshold: 0.5 }
160
160
  );
161
- return a.forEach((d, b) => {
162
- const e = document.querySelector(
163
- `[data-card-id="${b}-${p}"]`
161
+ return e.forEach((d, b) => {
162
+ const a = document.querySelector(
163
+ `[data-card-id="${b}-${l}"]`
164
164
  );
165
- e && i.observe(e);
165
+ a && i.observe(a);
166
166
  }), () => i.disconnect();
167
- }, [s, a, p]), R(() => {
167
+ }, [s, e, l]), R(() => {
168
168
  const r = s.current;
169
169
  if (r)
170
170
  return r.addEventListener("keydown", $), () => r.removeEventListener("keydown", $);
171
171
  }, [s, $]);
172
172
  const C = () => {
173
173
  if (c.size === 0) return;
174
- const r = [], i = c.size, d = Math.min(...Array.from(c)), b = a.slice(0, d).length, e = a.slice(d + i).length;
174
+ const r = [], i = c.size, d = Math.min(...Array.from(c)), b = e.slice(0, d).length, a = e.slice(d + i).length;
175
175
  let n = 0;
176
- for (let t = 0; t < a.length; t++) {
177
- if (b + 1 !== t && b <= t && t < a.length - e) continue;
176
+ for (let t = 0; t < e.length; t++) {
177
+ if (b + 1 !== t && b <= t && t < e.length - a) continue;
178
178
  let x = "active";
179
- (t < b || t > a.length - 1 - e) && (x = ""), r.push(
180
- /* @__PURE__ */ o("li", { className: y(`${v}__indicator`, x) }, `indicator-${n++}`)
179
+ (t < b || t > e.length - 1 - a) && (x = ""), r.push(
180
+ /* @__PURE__ */ o("li", { className: y(`${N}__indicator`, x) }, `indicator-${n++}`)
181
181
  );
182
182
  }
183
183
  return r.length < 2 ? null : r;
184
184
  };
185
- return /* @__PURE__ */ u("li", { className: y(v), children: [
186
- /* @__PURE__ */ o("ul", { className: y(`${v}__indicators`), children: C() }),
187
- /* @__PURE__ */ u("div", { className: y(`${v}__buttons`), children: [
185
+ return /* @__PURE__ */ _("li", { className: y(N), children: [
186
+ /* @__PURE__ */ o("ul", { className: y(`${N}__indicators`), children: C() }),
187
+ /* @__PURE__ */ _("div", { className: y(`${N}__buttons`), children: [
188
188
  /* @__PURE__ */ o(
189
189
  M,
190
190
  {
191
191
  "aria-label": m.previous,
192
192
  variant: "secondary",
193
193
  iconOnly: !0,
194
- className: y(`${v}__button`),
194
+ className: y(`${N}__button`),
195
195
  disabled: c.has(0),
196
196
  onClick: g,
197
- children: /* @__PURE__ */ o(Q, { className: y(`${v}__button-icon`), size: "xs" })
197
+ children: /* @__PURE__ */ o(Q, { className: y(`${N}__button-icon`), size: "xs" })
198
198
  }
199
199
  ),
200
200
  /* @__PURE__ */ o(
@@ -203,30 +203,30 @@ const X = {
203
203
  "aria-label": m.next,
204
204
  variant: "secondary",
205
205
  iconOnly: !0,
206
- className: y(`${v}__button`),
207
- disabled: c.has(a.length - 1),
208
- onClick: N,
209
- children: /* @__PURE__ */ o(U, { className: y(`${v}__button-icon`), size: "xs" })
206
+ className: y(`${N}__button`),
207
+ disabled: c.has(e.length - 1),
208
+ onClick: v,
209
+ children: /* @__PURE__ */ o(U, { className: y(`${N}__button-icon`), size: "xs" })
210
210
  }
211
211
  )
212
212
  ] })
213
213
  ] });
214
214
  }, I = z.bind(X), w = "purpur-comparison-table", nr = ({
215
- classname: a,
215
+ classname: e,
216
216
  features: s,
217
- items: p,
217
+ items: l,
218
218
  ariaLabels: m,
219
219
  variant: c = "primary"
220
220
  }) => {
221
- const f = B(), h = I(a, w, `${w}--${c}`), g = F(null), [N, $] = L(!1), C = E(() => {
222
- $((e) => !e);
223
- }, []), r = () => /* @__PURE__ */ u("li", { className: I(`${w}__cards`), children: [
221
+ const f = B(), h = I(e, w, `${w}--${c}`), g = F(null), [v, $] = L(!1), C = E(() => {
222
+ $((a) => !a);
223
+ }, []), r = () => /* @__PURE__ */ _("li", { className: I(`${w}__cards`), children: [
224
224
  /* @__PURE__ */ o("div", { className: I(`${w}__separator`) }),
225
- p.map((e, n) => /* @__PURE__ */ H(
226
- er,
225
+ l.map((a, n) => /* @__PURE__ */ H(
226
+ ar,
227
227
  {
228
- ...e,
229
- showFullDescriptions: N,
228
+ ...a,
229
+ showFullDescriptions: v,
230
230
  toggleShowFullDescriptions: C,
231
231
  key: n,
232
232
  isFirstCard: n === 0,
@@ -234,14 +234,14 @@ const X = {
234
234
  id: `${n}-${f}`
235
235
  }
236
236
  ))
237
- ] }), i = () => Object.entries(s).map(([e, n], t) => /* @__PURE__ */ u("li", { className: I(`${w}__feature-row`), children: [
238
- /* @__PURE__ */ o(or, { title: e, description: n }),
239
- p.map((x, T) => /* @__PURE__ */ o(Z, { value: x.features[e] ?? !1 }, T))
240
- ] }, t)), d = F(0), b = (e) => {
241
- const n = e.currentTarget, t = n.querySelector("[data-card-id]")?.clientWidth ?? 0, x = Math.round(n.scrollLeft / t), T = x * t + x, P = e.timeStamp - d.current, V = Math.abs(n.scrollLeft - T);
242
- d.current && P < 200 || V < 10 || (d.current = e.timeStamp, n.scrollTo({ left: T, behavior: "smooth" }));
237
+ ] }), i = () => Object.entries(s).map(([a, n], t) => /* @__PURE__ */ _("li", { className: I(`${w}__feature-row`), children: [
238
+ /* @__PURE__ */ o(or, { title: a, description: n }),
239
+ l.map((x, T) => /* @__PURE__ */ o(Z, { value: x.features[a] ?? !1 }, T))
240
+ ] }, t)), d = F(0), b = (a) => {
241
+ const n = a.currentTarget, t = n.querySelector("[data-card-id]")?.clientWidth ?? 0, x = Math.round(n.scrollLeft / t), T = x * t + x, P = a.timeStamp - d.current, V = Math.abs(n.scrollLeft - T);
242
+ d.current && P < 200 || V < 10 || (d.current = a.timeStamp, n.scrollTo({ left: T, behavior: "smooth" }));
243
243
  };
244
- return /* @__PURE__ */ o("div", { className: I(w + "__wrapper"), children: /* @__PURE__ */ u(
244
+ return /* @__PURE__ */ o("div", { className: I(w + "__wrapper"), children: /* @__PURE__ */ _(
245
245
  "ul",
246
246
  {
247
247
  id: w + `-${f}`,
@@ -250,13 +250,13 @@ const X = {
250
250
  onScrollEnd: b,
251
251
  style: {
252
252
  // @ts-expect-error | Typescript doesn't recognize the CSS variable, but it works as intended
253
- "--initial-columns": p.length + 1
253
+ "--initial-columns": l.length + 1
254
254
  },
255
255
  children: [
256
256
  /* @__PURE__ */ o(
257
257
  cr,
258
258
  {
259
- items: p,
259
+ items: l,
260
260
  container: g,
261
261
  ariaLabels: m,
262
262
  parentId: CSS.escape(f)
@@ -272,4 +272,4 @@ nr.displayName = "ComparisonTable";
272
272
  export {
273
273
  nr as C
274
274
  };
275
- //# sourceMappingURL=comparison-table-Dmbjsqyg.mjs.map
275
+ //# sourceMappingURL=comparison-table-8bOJmz-L.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"comparison-table-Dmbjsqyg.mjs","sources":["../../../components/comparison-table/src/components/Cell/cell.tsx","../../../components/comparison-table/src/components/LeadCell/lead-cell.tsx","../../../components/comparison-table/src/components/OptionCard/option-card.tsx","../../../components/comparison-table/src/components/ScrollProgress/scroll-progress.tsx","../../../components/comparison-table/src/comparison-table.tsx"],"sourcesContent":["import React, { isValidElement, type ReactNode } from \"react\";\nimport { IconCheckmark } from \"@purpur/icon/checkmark\";\nimport { IconMinus } from \"@purpur/icon/minus\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./cell.module.scss\";\n\ntype CellProps = {\n value: boolean | ReactNode;\n};\n\nconst cx = c.bind(styles);\n\nconst rootClassName = \"purpur-comparison-table-cell\";\n\nexport const Cell = ({ value }: CellProps) => {\n const isReactNode = isValidElement(value) || [\"string\", \"number\"].includes(typeof value);\n\n const getClassName = () => {\n if (isReactNode) return \"\";\n return `${rootClassName}--${value ? \"check\" : \"minus\"}`;\n };\n\n const classes = cx(rootClassName, [getClassName()]);\n\n const Icon = value ? IconCheckmark : IconMinus;\n\n return (\n <span className={cx(classes)}>\n {isReactNode ? value : <Icon size=\"xs\" className={cx(`${rootClassName}__icon`)} />}\n </span>\n );\n};\n","import React, { type ReactNode } from \"react\";\nimport { IconChevronDown } from \"@purpur/icon/chevron-down\";\nimport { Paragraph } from \"@purpur/paragraph\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./lead-cell.module.scss\";\n\ntype LeadCellProps = {\n title: string;\n description?: ReactNode;\n};\n\nconst cx = c.bind(styles);\n\nconst rootClassName = \"purpur-comparison-table-lead-cell\";\n\nexport const LeadCell = ({ title, description }: LeadCellProps) => {\n const isExpandable = typeof description === \"string\";\n const classes = cx(rootClassName);\n\n return (\n <details className={classes} data-is-expandable={isExpandable}>\n <summary className={cx(`${rootClassName}__summary`)} tabIndex={isExpandable ? 0 : -1}>\n <Paragraph className={cx(`${rootClassName}__summary-title`)} variant=\"paragraph-100-bold\">\n {title}\n </Paragraph>\n <IconChevronDown className={cx(`${rootClassName}__summary-icon`)} size=\"sm\" />\n </summary>\n {description && (\n <Paragraph variant=\"paragraph-100\" className={cx(`${rootClassName}__description`)}>\n {description}\n </Paragraph>\n )}\n </details>\n );\n};\n","import React, { type ReactNode } from \"react\";\nimport { Badge, type BadgeProps } from \"@purpur/badge\";\nimport { Button } from \"@purpur/button\";\nimport { Heading } from \"@purpur/heading\";\nimport { IconChevronDown } from \"@purpur/icon/chevron-down\";\nimport { Paragraph } from \"@purpur/paragraph\";\nimport c from \"classnames/bind\";\n\nimport { type ComparisonTableProps } from \"../../comparison-table\";\nimport styles from \"./option-card.module.scss\";\n\nconst cx = c.bind(styles);\n\nconst rootClassName = \"purpur-comparison-table-option-card\";\n\nexport type OptionCardProps = {\n image: {\n src: string;\n alt: string;\n };\n\n title: string;\n description: string;\n variablePriceText: string;\n price: string;\n\n actions: ReactNode;\n\n badge?: BadgeProps;\n isHighlighted?: boolean;\n};\n\ntype OptionCardPropsAdditions = {\n id: string;\n isFirstCard: boolean;\n ariaLabels: ComparisonTableProps[\"ariaLabels\"];\n\n showFullDescriptions: boolean;\n toggleShowFullDescriptions: () => void;\n};\n\nexport const OptionCard = ({\n id,\n description,\n variablePriceText,\n price,\n isHighlighted,\n ariaLabels,\n badge,\n actions,\n isFirstCard,\n image,\n title,\n showFullDescriptions,\n toggleShowFullDescriptions,\n}: OptionCardProps & OptionCardPropsAdditions) => {\n const classes = cx(rootClassName, {\n [`${rootClassName}--highlighted`]: isHighlighted,\n [`${rootClassName}--first-card`]: isFirstCard,\n [`${rootClassName}--show-full-descriptions`]: showFullDescriptions,\n });\n\n const renderDescription = () => {\n if (!description) return null;\n\n const longThreshold = 50;\n const longDescription = description.length > longThreshold;\n\n return (\n <div className={cx(`${rootClassName}__description`)}>\n <Paragraph variant=\"paragraph-100\" className={cx(`${rootClassName}__description-text`)}>\n {description}\n </Paragraph>\n {longDescription && (\n <Button\n variant=\"text\"\n size=\"xs\"\n className={cx(`${rootClassName}__read-more`)}\n onClick={toggleShowFullDescriptions}\n >\n <span className={cx(`${rootClassName}__read-more-text`)}>\n {showFullDescriptions ? ariaLabels.readLess : ariaLabels.readMore}\n </span>\n <IconChevronDown className={cx(`${rootClassName}__read-more-icon`)} size=\"xs\" />\n </Button>\n )}\n </div>\n );\n };\n\n return (\n <article className={classes} data-card-id={id}>\n {badge && <Badge {...badge} className={cx(`${rootClassName}__badge`)} />}\n\n <section className={cx(`${rootClassName}__main-content`)}>\n <img src={image.src} alt={image.alt} className={cx(`${rootClassName}__image`)} />\n\n <div className={cx(`${rootClassName}__body`)}>\n <Heading tag=\"h3\" variant=\"title-200\" className={cx(`${rootClassName}__title`)}>\n {title}\n </Heading>\n {renderDescription()}\n </div>\n </section>\n\n <footer className={cx(`${rootClassName}__footer`)}>\n <span className={cx(`${rootClassName}__price`)} id={id}>\n <Paragraph variant=\"paragraph-100\">{variablePriceText}</Paragraph>\n <Paragraph variant=\"paragraph-100-bold\">{price}</Paragraph>\n </span>\n\n {actions}\n </footer>\n </article>\n );\n};\n","import React, { type RefObject, useCallback, useEffect, useState } from \"react\";\nimport { Button } from \"@purpur/button\";\nimport { IconArrowLeft } from \"@purpur/icon/arrow-left\";\nimport { IconArrowRight } from \"@purpur/icon/arrow-right\";\nimport c from \"classnames/bind\";\n\nimport { type ComparisonTableProps, type Features, type Item } from \"../../comparison-table\";\nimport styles from \"./scroll-progress.module.scss\";\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-comparison-table-scroll-progress\";\n\ntype ScrollProgressProps = {\n items: Array<Item<Features>>;\n container: RefObject<HTMLUListElement | null>;\n parentId: string;\n ariaLabels: ComparisonTableProps[\"ariaLabels\"];\n};\n\nexport const ScrollProgress = ({ items, container, parentId, ariaLabels }: ScrollProgressProps) => {\n const [inViewSet, setInViewSet] = useState<Set<number>>(new Set());\n\n const scrollToCard = useCallback(\n (index: number) => {\n const reduceMotion = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\n const card = document.querySelector(\n `[data-card-id=\"${index}-${parentId}\"]`\n ) as HTMLElement | null;\n card?.scrollIntoView({ behavior: reduceMotion ? \"instant\" : \"smooth\", block: \"nearest\" });\n },\n [parentId]\n );\n\n const previousCard = useCallback(() => {\n if (inViewSet.size === 0) return;\n\n const leftmostactiveIndex = Math.min(...Array.from(inViewSet));\n const targetIndex = leftmostactiveIndex - 1;\n\n if (targetIndex < 0) return;\n\n scrollToCard(targetIndex);\n }, [inViewSet, scrollToCard]);\n\n const nextCard = useCallback(() => {\n if (inViewSet.size === 0) return;\n\n const rightmostactiveIndex = Math.max(...Array.from(inViewSet));\n const targetIndex = rightmostactiveIndex + 1;\n\n if (targetIndex >= items.length) return;\n\n scrollToCard(targetIndex);\n }, [inViewSet, items.length, scrollToCard]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (e.key === \"ArrowRight\" || e.key === \"ArrowLeft\") {\n e.preventDefault();\n\n if (e.key === \"ArrowRight\") nextCard();\n else if (e.key === \"ArrowLeft\") previousCard();\n }\n },\n [nextCard, previousCard]\n );\n\n useEffect(() => {\n const root = container.current;\n\n if (!root) return;\n\n const observer = new IntersectionObserver(\n (entries) => {\n setInViewSet((prev) => {\n const next = new Set(prev);\n\n entries.forEach((entry) => {\n let index: number | string | undefined = entry.target\n .getAttribute(\"data-card-id\")\n ?.match(new RegExp(`(\\\\d+)-${parentId}`))?.[1];\n\n if (!index) return;\n\n index = parseInt(index, 10);\n\n if (entry.isIntersecting) {\n next.add(index);\n } else {\n next.delete(index);\n }\n });\n return next;\n });\n },\n { root, threshold: 0.5 }\n );\n\n items.forEach((_, index) => {\n const card = document.querySelector(\n `[data-card-id=\"${index}-${parentId}\"]`\n ) as HTMLElement | null;\n\n if (card) observer.observe(card);\n });\n\n return () => observer.disconnect();\n }, [container, items, parentId]);\n\n useEffect(() => {\n const root = container.current;\n\n if (!root) return;\n\n root.addEventListener(\"keydown\", handleKeyDown);\n\n return () => root.removeEventListener(\"keydown\", handleKeyDown);\n }, [container, handleKeyDown]);\n\n const renderIndicators = () => {\n if (inViewSet.size === 0) return;\n\n const indicators = [];\n const viewCapacity = inViewSet.size;\n const leftmostActiveIndex = Math.min(...Array.from(inViewSet));\n const head = items.slice(0, leftmostActiveIndex).length;\n const trail = items.slice(leftmostActiveIndex + viewCapacity).length;\n\n let key = 0;\n\n for (let i = 0; i < items.length; i++) {\n if (head + 1 !== i && head <= i && i < items.length - trail) continue;\n\n let status = \"active\";\n\n if (i < head || i > items.length - 1 - trail) status = \"\";\n\n indicators.push(\n <li key={`indicator-${key++}`} className={cx(`${rootClassName}__indicator`, status)} />\n );\n }\n\n if (indicators.length < 2) return null;\n\n return indicators;\n };\n\n return (\n <li className={cx(rootClassName)}>\n <ul className={cx(`${rootClassName}__indicators`)}>{renderIndicators()}</ul>\n\n <div className={cx(`${rootClassName}__buttons`)}>\n <Button\n aria-label={ariaLabels.previous}\n variant=\"secondary\"\n iconOnly\n className={cx(`${rootClassName}__button`)}\n disabled={inViewSet.has(0)}\n onClick={previousCard}\n >\n <IconArrowLeft className={cx(`${rootClassName}__button-icon`)} size=\"xs\" />\n </Button>\n <Button\n aria-label={ariaLabels.next}\n variant=\"secondary\"\n iconOnly\n className={cx(`${rootClassName}__button`)}\n disabled={inViewSet.has(items.length - 1)}\n onClick={nextCard}\n >\n <IconArrowRight className={cx(`${rootClassName}__button-icon`)} size=\"xs\" />\n </Button>\n </div>\n </li>\n );\n};\n","import React, { type ReactNode, type UIEvent, useCallback, useId, useRef, useState } from \"react\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./comparison-table.module.scss\";\nimport { Cell } from \"./components/Cell/cell\";\nimport { LeadCell } from \"./components/LeadCell/lead-cell\";\nimport { OptionCard, type OptionCardProps } from \"./components/OptionCard/option-card\";\nimport { ScrollProgress } from \"./components/ScrollProgress/scroll-progress\";\n\nconst cx = c.bind(styles);\n\nconst rootClassName = \"purpur-comparison-table\";\n\nexport type Features = Record<string, ReactNode | null>;\n\nexport type Item<TFeatures extends Features = Features> = OptionCardProps & {\n features: Partial<Record<keyof TFeatures, ReactNode | string | boolean>>;\n};\n\nexport type ComparisonTableProps<TFeatures extends Features = Features> = {\n /** List of features that can be supported by the comparison table\n *\n * string = description of the feature that can be viewed by expanding cell.\n *\n * null = no description\n *\n {\n [featureName]: ReactNode | null\n }\n */\n features: TFeatures;\n\n /** List of items to be displayed in the comparison table\n *\n *\n Item = {\n image: {\n src: string;\n alt: string;\n };\n\n title: string;\n description: string;\n variablePriceText: string;\n price: string;\n actions: ReactNode;\n badge?: BadgeProps;\n isHighlighted?: boolean;\n\n features: {\n [featureName in keyof Features]?: string | boolean;\n };\n }\n */\n items: Array<Item<TFeatures>>;\n\n /** Aria labels for the comparison table and various components\n *\n {\n previous: string;\n next: string;\n readMore: string;\n readLess: string;\n }\n */\n ariaLabels: {\n previous: string;\n next: string;\n readMore: string;\n readLess: string;\n };\n variant?: \"primary\" | \"secondary\";\n classname?: string;\n};\n\nexport const ComparisonTable = <TFeatures extends Features>({\n classname,\n features,\n items,\n ariaLabels,\n variant = \"primary\",\n}: ComparisonTableProps<TFeatures>) => {\n const id = useId();\n const classes = cx(classname, rootClassName, `${rootClassName}--${variant}`);\n const containerRef = useRef<HTMLUListElement>(null);\n const [showFullDescriptions, setShowFullDescriptions] = useState(false);\n\n const handleToggleShowFullDescriptions = useCallback(() => {\n setShowFullDescriptions((prev) => !prev);\n }, []);\n\n const renderCards = () => {\n return (\n <li className={cx(`${rootClassName}__cards`)}>\n <div className={cx(`${rootClassName}__separator`)} />\n {items.map((item, index) => (\n <OptionCard\n {...item}\n showFullDescriptions={showFullDescriptions}\n toggleShowFullDescriptions={handleToggleShowFullDescriptions}\n key={index}\n isFirstCard={index === 0}\n ariaLabels={ariaLabels}\n id={`${index}-${id}`}\n />\n ))}\n </li>\n );\n };\n\n const renderFeatures = () => {\n return Object.entries(features).map(([title, description], i) => (\n <li key={i} className={cx(`${rootClassName}__feature-row`)}>\n <LeadCell title={title} description={description} />\n {items.map((item, index) => (\n <Cell key={index} value={item.features[title as keyof TFeatures] ?? false} />\n ))}\n </li>\n ));\n };\n\n const deltaTime = useRef(0);\n\n const handleScrollEnd = (e: UIEvent<HTMLUListElement>) => {\n /**\n * This function makes sure that the scroll position is never stuck between two cards, since scroll snap is not fully reliable.\n */\n\n const target = e.currentTarget;\n const cardwidth = target.querySelector(\"[data-card-id]\")?.clientWidth ?? 0;\n const cardPos = Math.round(target.scrollLeft / cardwidth);\n const scrollTarget = cardPos * cardwidth + cardPos;\n const timeDiff = e.timeStamp - deltaTime.current;\n const scrollDiff = Math.abs(target.scrollLeft - scrollTarget);\n\n if (deltaTime.current && timeDiff < 200) return;\n if (scrollDiff < 10) return;\n\n deltaTime.current = e.timeStamp;\n\n target.scrollTo({ left: scrollTarget, behavior: \"smooth\" });\n };\n\n return (\n <div className={cx(rootClassName + \"__wrapper\")}>\n <ul\n id={rootClassName + `-${id}`}\n ref={containerRef}\n className={classes}\n // eslint-disable-next-line react/no-unknown-property\n onScrollEnd={handleScrollEnd}\n style={{\n // @ts-expect-error | Typescript doesn't recognize the CSS variable, but it works as intended\n [\"--initial-columns\"]: items.length + 1,\n }}\n >\n <ScrollProgress\n items={items}\n container={containerRef}\n ariaLabels={ariaLabels}\n parentId={CSS.escape(id)}\n />\n {renderCards()}\n {renderFeatures()}\n </ul>\n </div>\n );\n};\n\nComparisonTable.displayName = \"ComparisonTable\";\n"],"names":["cx","c","styles","rootClassName","Cell","value","isReactNode","isValidElement","classes","Icon","IconCheckmark","IconMinus","jsx","LeadCell","title","description","isExpandable","jsxs","Paragraph","IconChevronDown","OptionCard","id","variablePriceText","price","isHighlighted","ariaLabels","badge","actions","isFirstCard","image","showFullDescriptions","toggleShowFullDescriptions","renderDescription","longDescription","Button","Badge","Heading","ScrollProgress","items","container","parentId","inViewSet","setInViewSet","useState","scrollToCard","useCallback","index","reduceMotion","previousCard","targetIndex","nextCard","handleKeyDown","e","useEffect","root","observer","entries","prev","next","entry","_","card","renderIndicators","indicators","viewCapacity","leftmostActiveIndex","head","trail","key","i","status","IconArrowLeft","IconArrowRight","ComparisonTable","classname","features","variant","useId","containerRef","useRef","setShowFullDescriptions","handleToggleShowFullDescriptions","renderCards","item","createElement","renderFeatures","deltaTime","handleScrollEnd","target","cardwidth","cardPos","scrollTarget","timeDiff","scrollDiff"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;GAWMA,IAAKC,EAAE,KAAKC,CAAM,GAElBC,IAAgB,gCAETC,IAAO,CAAC,EAAE,OAAAC,QAAuB;AAC5C,QAAMC,IAAcC,EAAeF,CAAK,KAAK,CAAC,UAAU,QAAQ,EAAE,SAAS,OAAOA,CAAK,GAOjFG,IAAUR,EAAGG,GAAe,CAJ5BG,IAAoB,KACjB,GAAGH,CAAa,KAAKE,IAAQ,UAAU,OAAO,EAGN,CAAC,GAE5CI,IAAOJ,IAAQK,IAAgBC;AAErC,2BACG,QAAA,EAAK,WAAWX,EAAGQ,CAAO,GACxB,cAAcH,IAAQ,gBAAAO,EAACH,GAAA,EAAK,MAAK,MAAK,WAAWT,EAAG,GAAGG,CAAa,QAAQ,GAAG,GAClF;AAEJ;;;;;;GCpBMH,IAAKC,EAAE,KAAKC,EAAM,GAElBC,IAAgB,qCAETU,KAAW,CAAC,EAAE,OAAAC,GAAO,aAAAC,QAAiC;AACjE,QAAMC,IAAe,OAAOD,KAAgB,UACtCP,IAAUR,EAAGG,CAAa;AAEhC,SACE,gBAAAc,EAAC,WAAA,EAAQ,WAAWT,GAAS,sBAAoBQ,GAC/C,UAAA;AAAA,IAAA,gBAAAC,EAAC,WAAA,EAAQ,WAAWjB,EAAG,GAAGG,CAAa,WAAW,GAAG,UAAUa,IAAe,IAAI,IAChF,UAAA;AAAA,MAAA,gBAAAJ,EAACM,GAAA,EAAU,WAAWlB,EAAG,GAAGG,CAAa,iBAAiB,GAAG,SAAQ,sBAClE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QAExB6D,EAAA;AAAA,QACAG,EAAA;AAAA,MAAe;AAAA,IAAA;AAAA,EAAA,GAEpB;AAEJ;AAEAZ,GAAgB,cAAc;"}
1
+ {"version":3,"file":"comparison-table-8bOJmz-L.mjs","sources":["../../../components/comparison-table/src/components/Cell/cell.tsx","../../../components/comparison-table/src/components/LeadCell/lead-cell.tsx","../../../components/comparison-table/src/components/OptionCard/option-card.tsx","../../../components/comparison-table/src/components/ScrollProgress/scroll-progress.tsx","../../../components/comparison-table/src/comparison-table.tsx"],"sourcesContent":["import React, { isValidElement, type ReactNode } from \"react\";\nimport { IconCheckmark } from \"@purpur/icon/checkmark\";\nimport { IconMinus } from \"@purpur/icon/minus\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./cell.module.scss\";\n\ntype CellProps = {\n value: boolean | ReactNode;\n};\n\nconst cx = c.bind(styles);\n\nconst rootClassName = \"purpur-comparison-table-cell\";\n\nexport const Cell = ({ value }: CellProps) => {\n const isReactNode = isValidElement(value) || [\"string\", \"number\"].includes(typeof value);\n\n const getClassName = () => {\n if (isReactNode) return \"\";\n return `${rootClassName}--${value ? \"check\" : \"minus\"}`;\n };\n\n const classes = cx(rootClassName, [getClassName()]);\n\n const Icon = value ? IconCheckmark : IconMinus;\n\n return (\n <span className={cx(classes)}>\n {isReactNode ? value : <Icon size=\"xs\" className={cx(`${rootClassName}__icon`)} />}\n </span>\n );\n};\n","import React, { type ReactNode } from \"react\";\nimport { IconChevronDown } from \"@purpur/icon/chevron-down\";\nimport { Paragraph } from \"@purpur/paragraph\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./lead-cell.module.scss\";\n\ntype LeadCellProps = {\n title: string;\n description?: ReactNode;\n};\n\nconst cx = c.bind(styles);\n\nconst rootClassName = \"purpur-comparison-table-lead-cell\";\n\nexport const LeadCell = ({ title, description }: LeadCellProps) => {\n const isExpandable = typeof description === \"string\";\n const classes = cx(rootClassName);\n\n return (\n <details className={classes} data-is-expandable={isExpandable}>\n <summary className={cx(`${rootClassName}__summary`)} tabIndex={isExpandable ? 0 : -1}>\n <Paragraph className={cx(`${rootClassName}__summary-title`)} variant=\"paragraph-100-bold\">\n {title}\n </Paragraph>\n <IconChevronDown className={cx(`${rootClassName}__summary-icon`)} size=\"sm\" />\n </summary>\n {description && (\n <Paragraph variant=\"paragraph-100\" className={cx(`${rootClassName}__description`)}>\n {description}\n </Paragraph>\n )}\n </details>\n );\n};\n","import React, { type ReactNode } from \"react\";\nimport { Badge, type BadgeProps } from \"@purpur/badge\";\nimport { Button } from \"@purpur/button\";\nimport { Heading } from \"@purpur/heading\";\nimport { IconChevronDown } from \"@purpur/icon/chevron-down\";\nimport { Paragraph } from \"@purpur/paragraph\";\nimport c from \"classnames/bind\";\n\nimport { type ComparisonTableProps } from \"../../comparison-table\";\nimport styles from \"./option-card.module.scss\";\n\nconst cx = c.bind(styles);\n\nconst rootClassName = \"purpur-comparison-table-option-card\";\n\nexport type OptionCardProps = {\n image: {\n src: string;\n alt: string;\n };\n\n title: string;\n description: string;\n variablePriceText: string;\n price: string;\n\n actions: ReactNode;\n\n badge?: BadgeProps;\n isHighlighted?: boolean;\n};\n\ntype OptionCardPropsAdditions = {\n id: string;\n isFirstCard: boolean;\n ariaLabels: ComparisonTableProps[\"ariaLabels\"];\n\n showFullDescriptions: boolean;\n toggleShowFullDescriptions: () => void;\n};\n\nexport const OptionCard = ({\n id,\n description,\n variablePriceText,\n price,\n isHighlighted,\n ariaLabels,\n badge,\n actions,\n isFirstCard,\n image,\n title,\n showFullDescriptions,\n toggleShowFullDescriptions,\n}: OptionCardProps & OptionCardPropsAdditions) => {\n const classes = cx(rootClassName, {\n [`${rootClassName}--highlighted`]: isHighlighted,\n [`${rootClassName}--first-card`]: isFirstCard,\n [`${rootClassName}--show-full-descriptions`]: showFullDescriptions,\n });\n\n const renderDescription = () => {\n if (!description) return null;\n\n const longThreshold = 50;\n const longDescription = description.length > longThreshold;\n\n return (\n <div className={cx(`${rootClassName}__description`)}>\n <Paragraph variant=\"paragraph-100\" className={cx(`${rootClassName}__description-text`)}>\n {description}\n </Paragraph>\n {longDescription && (\n <Button\n variant=\"text\"\n size=\"xs\"\n className={cx(`${rootClassName}__read-more`)}\n onClick={toggleShowFullDescriptions}\n >\n <span className={cx(`${rootClassName}__read-more-text`)}>\n {showFullDescriptions ? ariaLabels.readLess : ariaLabels.readMore}\n </span>\n <IconChevronDown className={cx(`${rootClassName}__read-more-icon`)} size=\"xs\" />\n </Button>\n )}\n </div>\n );\n };\n\n return (\n <article className={classes} data-card-id={id}>\n {badge && <Badge {...badge} className={cx(`${rootClassName}__badge`)} />}\n\n <section className={cx(`${rootClassName}__main-content`)}>\n <img src={image.src} alt={image.alt} className={cx(`${rootClassName}__image`)} />\n\n <div className={cx(`${rootClassName}__body`)}>\n <Heading tag=\"h3\" variant=\"title-200\" className={cx(`${rootClassName}__title`)}>\n {title}\n </Heading>\n {renderDescription()}\n </div>\n </section>\n\n <footer className={cx(`${rootClassName}__footer`)}>\n <span className={cx(`${rootClassName}__price`)} id={id}>\n <Paragraph variant=\"paragraph-100\">{variablePriceText}</Paragraph>\n <Paragraph variant=\"paragraph-100-bold\">{price}</Paragraph>\n </span>\n\n {actions}\n </footer>\n </article>\n );\n};\n","import React, { type RefObject, useCallback, useEffect, useState } from \"react\";\nimport { Button } from \"@purpur/button\";\nimport { IconArrowLeft } from \"@purpur/icon/arrow-left\";\nimport { IconArrowRight } from \"@purpur/icon/arrow-right\";\nimport c from \"classnames/bind\";\n\nimport { type ComparisonTableProps, type Features, type Item } from \"../../comparison-table\";\nimport styles from \"./scroll-progress.module.scss\";\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-comparison-table-scroll-progress\";\n\ntype ScrollProgressProps = {\n items: Array<Item<Features>>;\n container: RefObject<HTMLUListElement | null>;\n parentId: string;\n ariaLabels: ComparisonTableProps[\"ariaLabels\"];\n};\n\nexport const ScrollProgress = ({ items, container, parentId, ariaLabels }: ScrollProgressProps) => {\n const [inViewSet, setInViewSet] = useState<Set<number>>(new Set());\n\n const scrollToCard = useCallback(\n (index: number) => {\n const reduceMotion = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\n const card = document.querySelector(\n `[data-card-id=\"${index}-${parentId}\"]`\n ) as HTMLElement | null;\n card?.scrollIntoView({ behavior: reduceMotion ? \"instant\" : \"smooth\", block: \"nearest\" });\n },\n [parentId]\n );\n\n const previousCard = useCallback(() => {\n if (inViewSet.size === 0) return;\n\n const leftmostactiveIndex = Math.min(...Array.from(inViewSet));\n const targetIndex = leftmostactiveIndex - 1;\n\n if (targetIndex < 0) return;\n\n scrollToCard(targetIndex);\n }, [inViewSet, scrollToCard]);\n\n const nextCard = useCallback(() => {\n if (inViewSet.size === 0) return;\n\n const rightmostactiveIndex = Math.max(...Array.from(inViewSet));\n const targetIndex = rightmostactiveIndex + 1;\n\n if (targetIndex >= items.length) return;\n\n scrollToCard(targetIndex);\n }, [inViewSet, items.length, scrollToCard]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (e.key === \"ArrowRight\" || e.key === \"ArrowLeft\") {\n e.preventDefault();\n\n if (e.key === \"ArrowRight\") nextCard();\n else if (e.key === \"ArrowLeft\") previousCard();\n }\n },\n [nextCard, previousCard]\n );\n\n useEffect(() => {\n const root = container.current;\n\n if (!root) return;\n\n const observer = new IntersectionObserver(\n (entries) => {\n setInViewSet((prev) => {\n const next = new Set(prev);\n\n entries.forEach((entry) => {\n let index: number | string | undefined = entry.target\n .getAttribute(\"data-card-id\")\n ?.match(new RegExp(`(\\\\d+)-${parentId}`))?.[1];\n\n if (!index) return;\n\n index = parseInt(index, 10);\n\n if (entry.isIntersecting) {\n next.add(index);\n } else {\n next.delete(index);\n }\n });\n return next;\n });\n },\n { root, threshold: 0.5 }\n );\n\n items.forEach((_, index) => {\n const card = document.querySelector(\n `[data-card-id=\"${index}-${parentId}\"]`\n ) as HTMLElement | null;\n\n if (card) observer.observe(card);\n });\n\n return () => observer.disconnect();\n }, [container, items, parentId]);\n\n useEffect(() => {\n const root = container.current;\n\n if (!root) return;\n\n root.addEventListener(\"keydown\", handleKeyDown);\n\n return () => root.removeEventListener(\"keydown\", handleKeyDown);\n }, [container, handleKeyDown]);\n\n const renderIndicators = () => {\n if (inViewSet.size === 0) return;\n\n const indicators = [];\n const viewCapacity = inViewSet.size;\n const leftmostActiveIndex = Math.min(...Array.from(inViewSet));\n const head = items.slice(0, leftmostActiveIndex).length;\n const trail = items.slice(leftmostActiveIndex + viewCapacity).length;\n\n let key = 0;\n\n for (let i = 0; i < items.length; i++) {\n if (head + 1 !== i && head <= i && i < items.length - trail) continue;\n\n let status = \"active\";\n\n if (i < head || i > items.length - 1 - trail) status = \"\";\n\n indicators.push(\n <li key={`indicator-${key++}`} className={cx(`${rootClassName}__indicator`, status)} />\n );\n }\n\n if (indicators.length < 2) return null;\n\n return indicators;\n };\n\n return (\n <li className={cx(rootClassName)}>\n <ul className={cx(`${rootClassName}__indicators`)}>{renderIndicators()}</ul>\n\n <div className={cx(`${rootClassName}__buttons`)}>\n <Button\n aria-label={ariaLabels.previous}\n variant=\"secondary\"\n iconOnly\n className={cx(`${rootClassName}__button`)}\n disabled={inViewSet.has(0)}\n onClick={previousCard}\n >\n <IconArrowLeft className={cx(`${rootClassName}__button-icon`)} size=\"xs\" />\n </Button>\n <Button\n aria-label={ariaLabels.next}\n variant=\"secondary\"\n iconOnly\n className={cx(`${rootClassName}__button`)}\n disabled={inViewSet.has(items.length - 1)}\n onClick={nextCard}\n >\n <IconArrowRight className={cx(`${rootClassName}__button-icon`)} size=\"xs\" />\n </Button>\n </div>\n </li>\n );\n};\n","import React, { type ReactNode, type UIEvent, useCallback, useId, useRef, useState } from \"react\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./comparison-table.module.scss\";\nimport { Cell } from \"./components/Cell/cell\";\nimport { LeadCell } from \"./components/LeadCell/lead-cell\";\nimport { OptionCard, type OptionCardProps } from \"./components/OptionCard/option-card\";\nimport { ScrollProgress } from \"./components/ScrollProgress/scroll-progress\";\n\nconst cx = c.bind(styles);\n\nconst rootClassName = \"purpur-comparison-table\";\n\nexport type Features = Record<string, ReactNode | null>;\n\nexport type Item<TFeatures extends Features = Features> = OptionCardProps & {\n features: Partial<Record<keyof TFeatures, ReactNode | string | boolean>>;\n};\n\nexport type ComparisonTableProps<TFeatures extends Features = Features> = {\n /** List of features that can be supported by the comparison table\n *\n * string = description of the feature that can be viewed by expanding cell.\n *\n * null = no description\n *\n {\n [featureName]: ReactNode | null\n }\n */\n features: TFeatures;\n\n /** List of items to be displayed in the comparison table\n *\n *\n Item = {\n image: {\n src: string;\n alt: string;\n };\n\n title: string;\n description: string;\n variablePriceText: string;\n price: string;\n actions: ReactNode;\n badge?: BadgeProps;\n isHighlighted?: boolean;\n\n features: {\n [featureName in keyof Features]?: string | boolean;\n };\n }\n */\n items: Array<Item<TFeatures>>;\n\n /** Aria labels for the comparison table and various components\n *\n {\n previous: string;\n next: string;\n readMore: string;\n readLess: string;\n }\n */\n ariaLabels: {\n previous: string;\n next: string;\n readMore: string;\n readLess: string;\n };\n variant?: \"primary\" | \"secondary\";\n classname?: string;\n};\n\nexport const ComparisonTable = <TFeatures extends Features>({\n classname,\n features,\n items,\n ariaLabels,\n variant = \"primary\",\n}: ComparisonTableProps<TFeatures>) => {\n const id = useId();\n const classes = cx(classname, rootClassName, `${rootClassName}--${variant}`);\n const containerRef = useRef<HTMLUListElement>(null);\n const [showFullDescriptions, setShowFullDescriptions] = useState(false);\n\n const handleToggleShowFullDescriptions = useCallback(() => {\n setShowFullDescriptions((prev) => !prev);\n }, []);\n\n const renderCards = () => {\n return (\n <li className={cx(`${rootClassName}__cards`)}>\n <div className={cx(`${rootClassName}__separator`)} />\n {items.map((item, index) => (\n <OptionCard\n {...item}\n showFullDescriptions={showFullDescriptions}\n toggleShowFullDescriptions={handleToggleShowFullDescriptions}\n key={index}\n isFirstCard={index === 0}\n ariaLabels={ariaLabels}\n id={`${index}-${id}`}\n />\n ))}\n </li>\n );\n };\n\n const renderFeatures = () => {\n return Object.entries(features).map(([title, description], i) => (\n <li key={i} className={cx(`${rootClassName}__feature-row`)}>\n <LeadCell title={title} description={description} />\n {items.map((item, index) => (\n <Cell key={index} value={item.features[title as keyof TFeatures] ?? false} />\n ))}\n </li>\n ));\n };\n\n const deltaTime = useRef(0);\n\n const handleScrollEnd = (e: UIEvent<HTMLUListElement>) => {\n /**\n * This function makes sure that the scroll position is never stuck between two cards, since scroll snap is not fully reliable.\n */\n\n const target = e.currentTarget;\n const cardwidth = target.querySelector(\"[data-card-id]\")?.clientWidth ?? 0;\n const cardPos = Math.round(target.scrollLeft / cardwidth);\n const scrollTarget = cardPos * cardwidth + cardPos;\n const timeDiff = e.timeStamp - deltaTime.current;\n const scrollDiff = Math.abs(target.scrollLeft - scrollTarget);\n\n if (deltaTime.current && timeDiff < 200) return;\n if (scrollDiff < 10) return;\n\n deltaTime.current = e.timeStamp;\n\n target.scrollTo({ left: scrollTarget, behavior: \"smooth\" });\n };\n\n return (\n <div className={cx(rootClassName + \"__wrapper\")}>\n <ul\n id={rootClassName + `-${id}`}\n ref={containerRef}\n className={classes}\n // eslint-disable-next-line react/no-unknown-property\n onScrollEnd={handleScrollEnd}\n style={{\n // @ts-expect-error | Typescript doesn't recognize the CSS variable, but it works as intended\n [\"--initial-columns\"]: items.length + 1,\n }}\n >\n <ScrollProgress\n items={items}\n container={containerRef}\n ariaLabels={ariaLabels}\n parentId={CSS.escape(id)}\n />\n {renderCards()}\n {renderFeatures()}\n </ul>\n </div>\n );\n};\n\nComparisonTable.displayName = \"ComparisonTable\";\n"],"names":["cx","c","styles","rootClassName","Cell","value","isReactNode","isValidElement","classes","Icon","IconCheckmark","IconMinus","jsx","LeadCell","title","description","isExpandable","jsxs","Paragraph","IconChevronDown","OptionCard","id","variablePriceText","price","isHighlighted","ariaLabels","badge","actions","isFirstCard","image","showFullDescriptions","toggleShowFullDescriptions","renderDescription","longDescription","Button","Badge","Heading","ScrollProgress","items","container","parentId","inViewSet","setInViewSet","useState","scrollToCard","useCallback","index","reduceMotion","previousCard","targetIndex","nextCard","handleKeyDown","e","useEffect","root","observer","entries","prev","next","entry","_","card","renderIndicators","indicators","viewCapacity","leftmostActiveIndex","head","trail","key","i","status","IconArrowLeft","IconArrowRight","ComparisonTable","classname","features","variant","useId","containerRef","useRef","setShowFullDescriptions","handleToggleShowFullDescriptions","renderCards","item","createElement","renderFeatures","deltaTime","handleScrollEnd","target","cardwidth","cardPos","scrollTarget","timeDiff","scrollDiff"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;GAWMA,IAAKC,EAAE,KAAKC,CAAM,GAElBC,IAAgB,gCAETC,IAAO,CAAC,EAAE,OAAAC,QAAuB;AAC5C,QAAMC,IAAcC,EAAeF,CAAK,KAAK,CAAC,UAAU,QAAQ,EAAE,SAAS,OAAOA,CAAK,GAOjFG,IAAUR,EAAGG,GAAe,CAJ5BG,IAAoB,KACjB,GAAGH,CAAa,KAAKE,IAAQ,UAAU,OAAO,EAGN,CAAC,GAE5CI,IAAOJ,IAAQK,IAAgBC;AAErC,2BACG,QAAA,EAAK,WAAWX,EAAGQ,CAAO,GACxB,cAAcH,IAAQ,gBAAAO,EAACH,GAAA,EAAK,MAAK,MAAK,WAAWT,EAAG,GAAGG,CAAa,QAAQ,GAAG,GAClF;AAEJ;;;;;;GCpBMH,IAAKC,EAAE,KAAKC,EAAM,GAElBC,IAAgB,qCAETU,KAAW,CAAC,EAAE,OAAAC,GAAO,aAAAC,QAAiC;AACjE,QAAMC,IAAe,OAAOD,KAAgB,UACtCP,IAAUR,EAAGG,CAAa;AAEhC,SACE,gBAAAc,EAAC,WAAA,EAAQ,WAAWT,GAAS,sBAAoBQ,GAC/C,UAAA;AAAA,IAAA,gBAAAC,EAAC,WAAA,EAAQ,WAAWjB,EAAG,GAAGG,CAAa,WAAW,GAAG,UAAUa,IAAe,IAAI,IAChF,UAAA;AAAA,MAAA,gBAAAJ,EAACM,GAAA,EAAU,W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AAA,YACA,UAAU,IAAI,OAAOJ,CAAE;AAAA,UAAA;AAAA,QAAA;AAAA,QAExB6D,EAAA;AAAA,QACAG,EAAA;AAAA,MAAe;AAAA,IAAA;AAAA,EAAA,GAEpB;AAEJ;AAEAZ,GAAgB,cAAc;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const r=require("react/jsx-runtime"),u=require("react"),I=require("./bind-DeUYJ6m9.js"),L=require("./checkmark.es-lYntWFA3.js"),F=require("./minus.es-DtXArdKK.js"),R=require("./chevron-down.es-BMjgiS3F.js"),q=require("./paragraph-By4jMjnH.js"),O=require("./badge-CQ0SS_t8.js"),D=require("./button-DmybVApa.js"),B=require("./heading-drD5ugCC.js"),V=require("./arrow-left.es-CCWJyrcQ.js"),H=require("./arrow-right.es-eH-IgGi9.js"),K={"purpur-comparison-table__wrapper":"_purpur-comparison-table__wrapper_1udkj_1","purpur-comparison-table":"_purpur-comparison-table_1udkj_1","purpur-comparison-table--primary":"_purpur-comparison-table--primary_1udkj_11","purpur-comparison-table--secondary":"_purpur-comparison-table--secondary_1udkj_15","purpur-comparison-table__feature-row":"_purpur-comparison-table__feature-row_1udkj_32","purpur-comparison-table__cards":"_purpur-comparison-table__cards_1udkj_32","purpur-comparison-table__separator":"_purpur-comparison-table__separator_1udkj_49"},W={"purpur-comparison-table-cell":"_purpur-comparison-table-cell_117pb_1","purpur-comparison-table-cell--check":"_purpur-comparison-table-cell--check_117pb_16","purpur-comparison-table-cell--minus":"_purpur-comparison-table-cell--minus_117pb_19","purpur-comparison-table-cell__icon":"_purpur-comparison-table-cell__icon_117pb_22"},T=I.c.bind(W),z="purpur-comparison-table-cell",G=({value:a})=>{const t=u.isValidElement(a)||["string","number"].includes(typeof a),m=T(z,[t?"":`${z}--${a?"check":"minus"}`]),c=a?L.a:F.e;return r.jsx("span",{className:T(m),children:t?a:r.jsx(c,{size:"xs",className:T(`${z}__icon`)})})},J={"purpur-comparison-table-lead-cell":"_purpur-comparison-table-lead-cell_1vild_1","purpur-comparison-table-lead-cell__description":"_purpur-comparison-table-lead-cell__description_1vild_5","purpur-comparison-table-lead-cell__summary":"_purpur-comparison-table-lead-cell__summary_1vild_40","purpur-comparison-table-lead-cell__summary-title":"_purpur-comparison-table-lead-cell__summary-title_1vild_48","purpur-comparison-table-lead-cell__summary-icon":"_purpur-comparison-table-lead-cell__summary-icon_1vild_51"},k=I.c.bind(J),C="purpur-comparison-table-lead-cell",Q=({title:a,description:t})=>{const l=typeof t=="string",m=k(C);return r.jsxs("details",{className:m,"data-is-expandable":l,children:[r.jsxs("summary",{className:k(`${C}__summary`),tabIndex:l?0:-1,children:[r.jsx(q.Paragraph,{className:k(`${C}__summary-title`),variant:"paragraph-100-bold",children:a}),r.jsx(R.l,{className:k(`${C}__summary-icon`),size:"sm"})]}),t&&r.jsx(q.Paragraph,{variant:"paragraph-100",className:k(`${C}__description`),children:t})]})},U={"purpur-comparison-table-option-card":"_purpur-comparison-table-option-card_15113_1","purpur-comparison-table-option-card--highlighted":"_purpur-comparison-table-option-card--highlighted_15113_11","purpur-comparison-table-option-card__badge":"_purpur-comparison-table-option-card__badge_15113_14","purpur-comparison-table-option-card__main-content":"_purpur-comparison-table-option-card__main-content_15113_19","purpur-comparison-table-option-card__image":"_purpur-comparison-table-option-card__image_15113_25","purpur-comparison-table-option-card__body":"_purpur-comparison-table-option-card__body_15113_31","purpur-comparison-table-option-card__description":"_purpur-comparison-table-option-card__description_15113_36","purpur-comparison-table-option-card__description-text":"_purpur-comparison-table-option-card__description-text_15113_41","purpur-comparison-table-option-card__read-more":"_purpur-comparison-table-option-card__read-more_15113_50","purpur-comparison-table-option-card__read-more-icon":"_purpur-comparison-table-option-card__read-more-icon_15113_54","purpur-comparison-table-option-card__footer":"_purpur-comparison-table-option-card__footer_15113_62","purpur-comparison-table-option-card__price":"_purpur-comparison-table-option-card__price_15113_67","purpur-comparison-table-option-card--show-full-descriptions":"_purpur-comparison-table-option-card--show-full-descriptions_15113_74","purpur-comparison-table-option-card--first-card":"_purpur-comparison-table-option-card--first-card_15113_107"},_=I.c.bind(U),p="purpur-comparison-table-option-card",X=({id:a,description:t,variablePriceText:l,price:m,isHighlighted:c,ariaLabels:g,badge:h,actions:x,isFirstCard:j,image:f,title:w,showFullDescriptions:e,toggleShowFullDescriptions:i})=>{const d=_(p,{[`${p}--highlighted`]:c,[`${p}--first-card`]:j,[`${p}--show-full-descriptions`]:e}),b=()=>{if(!t)return null;const n=t.length>50;return r.jsxs("div",{className:_(`${p}__description`),children:[r.jsx(q.Paragraph,{variant:"paragraph-100",className:_(`${p}__description-text`),children:t}),n&&r.jsxs(D.Button,{variant:"text",size:"xs",className:_(`${p}__read-more`),onClick:i,children:[r.jsx("span",{className:_(`${p}__read-more-text`),children:e?g.readLess:g.readMore}),r.jsx(R.l,{className:_(`${p}__read-more-icon`),size:"xs"})]})]})};return r.jsxs("article",{className:d,"data-card-id":a,children:[h&&r.jsx(O.Badge,{...h,className:_(`${p}__badge`)}),r.jsxs("section",{className:_(`${p}__main-content`),children:[r.jsx("img",{src:f.src,alt:f.alt,className:_(`${p}__image`)}),r.jsxs("div",{className:_(`${p}__body`),children:[r.jsx(B.Heading,{tag:"h3",variant:"title-200",className:_(`${p}__title`),children:w}),b()]})]}),r.jsxs("footer",{className:_(`${p}__footer`),children:[r.jsxs("span",{className:_(`${p}__price`),id:a,children:[r.jsx(q.Paragraph,{variant:"paragraph-100",children:l}),r.jsx(q.Paragraph,{variant:"paragraph-100-bold",children:m})]}),x]})]})},Y="_active_ybbe8_44",Z={"purpur-comparison-table-scroll-progress":"_purpur-comparison-table-scroll-progress_ybbe8_1","purpur-comparison-table-scroll-progress__indicators":"_purpur-comparison-table-scroll-progress__indicators_ybbe8_15","purpur-comparison-table-scroll-progress__indicator":"_purpur-comparison-table-scroll-progress__indicator_ybbe8_15",active:Y,"purpur-comparison-table-scroll-progress__buttons":"_purpur-comparison-table-scroll-progress__buttons_ybbe8_48","purpur-comparison-table-scroll-progress__button":"_purpur-comparison-table-scroll-progress__button_ybbe8_48","purpur-comparison-table-scroll-progress__button-icon":"_purpur-comparison-table-scroll-progress__button-icon_ybbe8_57"},$=I.c.bind(Z),y="purpur-comparison-table-scroll-progress",rr=({items:a,container:t,parentId:l,ariaLabels:m})=>{const[c,g]=u.useState(new Set),h=u.useCallback(e=>{const i=window.matchMedia("(prefers-reduced-motion: reduce)").matches;document.querySelector(`[data-card-id="${e}-${l}"]`)?.scrollIntoView({behavior:i?"instant":"smooth",block:"nearest"})},[l]),x=u.useCallback(()=>{if(c.size===0)return;const i=Math.min(...Array.from(c))-1;i<0||h(i)},[c,h]),j=u.useCallback(()=>{if(c.size===0)return;const i=Math.max(...Array.from(c))+1;i>=a.length||h(i)},[c,a.length,h]),f=u.useCallback(e=>{(e.key==="ArrowRight"||e.key==="ArrowLeft")&&(e.preventDefault(),e.key==="ArrowRight"?j():e.key==="ArrowLeft"&&x())},[j,x]);u.useEffect(()=>{const e=t.current;if(!e)return;const i=new IntersectionObserver(d=>{g(b=>{const o=new Set(b);return d.forEach(n=>{let s=n.target.getAttribute("data-card-id")?.match(new RegExp(`(\\d+)-${l}`))?.[1];s&&(s=parseInt(s,10),n.isIntersecting?o.add(s):o.delete(s))}),o})},{root:e,threshold:.5});return a.forEach((d,b)=>{const o=document.querySelector(`[data-card-id="${b}-${l}"]`);o&&i.observe(o)}),()=>i.disconnect()},[t,a,l]),u.useEffect(()=>{const e=t.current;if(e)return e.addEventListener("keydown",f),()=>e.removeEventListener("keydown",f)},[t,f]);const w=()=>{if(c.size===0)return;const e=[],i=c.size,d=Math.min(...Array.from(c)),b=a.slice(0,d).length,o=a.slice(d+i).length;let n=0;for(let s=0;s<a.length;s++){if(b+1!==s&&b<=s&&s<a.length-o)continue;let N="active";(s<b||s>a.length-1-o)&&(N=""),e.push(r.jsx("li",{className:$(`${y}__indicator`,N)},`indicator-${n++}`))}return e.length<2?null:e};return r.jsxs("li",{className:$(y),children:[r.jsx("ul",{className:$(`${y}__indicators`),children:w()}),r.jsxs("div",{className:$(`${y}__buttons`),children:[r.jsx(D.Button,{"aria-label":m.previous,variant:"secondary",iconOnly:!0,className:$(`${y}__button`),disabled:c.has(0),onClick:x,children:r.jsx(V.l,{className:$(`${y}__button-icon`),size:"xs"})}),r.jsx(D.Button,{"aria-label":m.next,variant:"secondary",iconOnly:!0,className:$(`${y}__button`),disabled:c.has(a.length-1),onClick:j,children:r.jsx(H.i,{className:$(`${y}__button-icon`),size:"xs"})})]})]})},S=I.c.bind(K),v="purpur-comparison-table",A=({classname:a,features:t,items:l,ariaLabels:m,variant:c="primary"})=>{const g=u.useId(),h=S(a,v,`${v}--${c}`),x=u.useRef(null),[j,f]=u.useState(!1),w=u.useCallback(()=>{f(o=>!o)},[]),e=()=>r.jsxs("li",{className:S(`${v}__cards`),children:[r.jsx("div",{className:S(`${v}__separator`)}),l.map((o,n)=>u.createElement(X,{...o,showFullDescriptions:j,toggleShowFullDescriptions:w,key:n,isFirstCard:n===0,ariaLabels:m,id:`${n}-${g}`}))]}),i=()=>Object.entries(t).map(([o,n],s)=>r.jsxs("li",{className:S(`${v}__feature-row`),children:[r.jsx(Q,{title:o,description:n}),l.map((N,E)=>r.jsx(G,{value:N.features[o]??!1},E))]},s)),d=u.useRef(0),b=o=>{const n=o.currentTarget,s=n.querySelector("[data-card-id]")?.clientWidth??0,N=Math.round(n.scrollLeft/s),E=N*s+N,M=o.timeStamp-d.current,P=Math.abs(n.scrollLeft-E);d.current&&M<200||P<10||(d.current=o.timeStamp,n.scrollTo({left:E,behavior:"smooth"}))};return r.jsx("div",{className:S(v+"__wrapper"),children:r.jsxs("ul",{id:v+`-${g}`,ref:x,className:h,onScrollEnd:b,style:{"--initial-columns":l.length+1},children:[r.jsx(rr,{items:l,container:x,ariaLabels:m,parentId:CSS.escape(g)}),e(),i()]})})};A.displayName="ComparisonTable";exports.ComparisonTable=A;
2
+ //# sourceMappingURL=comparison-table-mKL2IHXW.js.map