mcr-design-systems 1.0.210 → 1.0.211

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.
@@ -1,7 +1,7 @@
1
1
  import { jsx as r, jsxs as b, Fragment as Me } from "react/jsx-runtime";
2
2
  import * as a from "react";
3
3
  import { useMemo as Ve } from "react";
4
- import { Root as er, Trigger as rr, Portal as nr, Content as tr, Label as be, Separator as xe } from "../../node_modules/@radix-ui/react-dropdown-menu/dist/index.js";
4
+ import { Root as er, Trigger as rr, Portal as tr, Content as nr, Label as be, Separator as xe } from "../../node_modules/@radix-ui/react-dropdown-menu/dist/index.js";
5
5
  import { useVirtualizer as sr } from "../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
6
6
  import { cn as g } from "../../shared/utils/cn.js";
7
7
  import { dataTestId as ge } from "../../shared/utils/dataTestId.js";
@@ -86,18 +86,18 @@ const cr = a.forwardRef(
86
86
  if (!S || !v.trim())
87
87
  return k;
88
88
  const e = v.toLowerCase().trim();
89
- return k.map((t) => {
90
- if ("items" in t) {
91
- const l = t.items.filter(
89
+ return k.map((n) => {
90
+ if ("items" in n) {
91
+ const l = n.items.filter(
92
92
  (s) => s.label.toLowerCase().includes(e) || s.value.toLowerCase().includes(e)
93
93
  );
94
- return l.length > 0 ? { ...t, items: l } : null;
94
+ return l.length > 0 ? { ...n, items: l } : null;
95
95
  } else
96
- return t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e) ? t : null;
97
- }).filter((t) => t !== null);
96
+ return n.label.toLowerCase().includes(e) || n.value.toLowerCase().includes(e) ? n : null;
97
+ }).filter((n) => n !== null);
98
98
  }, [k, S, v]), E = a.useMemo(() => m === "separated" && L ? !1 : O !== void 0 ? O : p === void 0 ? (console.warn(
99
99
  "Dropdown is not open, virtualization will not be applied. Please ensure the dropdown is open when using virtualization."
100
- ), !1) : A.reduce((t, l) => t + ("items" in l ? l.items.length : 1), 0) > 50, [
100
+ ), !1) : A.reduce((n, l) => n + ("items" in l ? l.items.length : 1), 0) > 50, [
101
101
  O,
102
102
  A,
103
103
  p,
@@ -105,14 +105,14 @@ const cr = a.forwardRef(
105
105
  L
106
106
  ]), I = a.useMemo(() => c ? Array.isArray(c) ? c : [c] : [], [c]), f = Ve(() => c ? Array.isArray(c) ? c.length > 0 : c !== "" : !1, [c]), N = a.useRef(!1), G = a.useRef(null), me = a.useRef(f), P = a.useRef(!1);
107
107
  a.useEffect(() => {
108
- const e = me.current, t = f;
108
+ const e = me.current, n = f;
109
109
  if (e && p && d !== void 0 && u.current && !d && !N.current) {
110
110
  const l = setTimeout(() => {
111
111
  u.current && !N.current && w?.(u.current);
112
112
  }, 0);
113
113
  return () => clearTimeout(l);
114
114
  }
115
- me.current = t;
115
+ me.current = n;
116
116
  }, [f, p, d, w]), a.useEffect(() => {
117
117
  if (d !== void 0) {
118
118
  d.trim() && (P.current = !0, u.current = d);
@@ -126,33 +126,33 @@ const cr = a.forwardRef(
126
126
  }, 100);
127
127
  }
128
128
  }, [d, w, p]), a.useEffect(() => {
129
- const e = pe.current, t = p ?? !1;
130
- e && !t && d === void 0 && (!f && !re.current && !P.current && q(""), B(!1), re.current = !1, G.current = null, P.current || (u.current = ""), N.current = !1), pe.current = t;
129
+ const e = pe.current, n = p ?? !1;
130
+ e && !n && d === void 0 && (!f && !re.current && !P.current && q(""), B(!1), re.current = !1, G.current = null, P.current || (u.current = ""), N.current = !1), pe.current = n;
131
131
  }, [p, f, d, q]);
132
132
  const j = a.useMemo(() => {
133
133
  if (!E) return [];
134
- const t = f && m === "separated" ? A.map((n) => {
135
- if ("items" in n) {
136
- const i = n.items.filter(
134
+ const n = f && m === "separated" ? A.map((t) => {
135
+ if ("items" in t) {
136
+ const i = t.items.filter(
137
137
  (o) => !I.includes(o.value)
138
138
  );
139
- return i.length > 0 ? { ...n, items: i } : null;
139
+ return i.length > 0 ? { ...t, items: i } : null;
140
140
  }
141
- return I.includes(n.value) ? null : n;
142
- }).filter((n) => n !== null) : A, l = [];
141
+ return I.includes(t.value) ? null : t;
142
+ }).filter((t) => t !== null) : A, l = [];
143
143
  let s = 0;
144
- return t.forEach((n, i) => {
145
- "items" in n ? (n.label && l.push({
144
+ return n.forEach((t, i) => {
145
+ "items" in t ? (t.label && l.push({
146
146
  type: "group-label",
147
- groupLabel: n.label,
148
- groupDisabled: n.disabled,
147
+ groupLabel: t.label,
148
+ groupDisabled: t.disabled,
149
149
  index: s++,
150
150
  key: `group-label-${i}`
151
- }), n.items.forEach((o, h) => {
151
+ }), t.items.forEach((o, h) => {
152
152
  const z = {
153
153
  ...o,
154
- disabled: n.disabled || o.disabled
155
- }, Y = t.reduce(
154
+ disabled: t.disabled || o.disabled
155
+ }, Y = n.reduce(
156
156
  (J, C) => "items" in C ? [...J, ...C.items] : [...J, C],
157
157
  []
158
158
  ), ie = $ ? $(
@@ -163,18 +163,18 @@ const cr = a.forwardRef(
163
163
  l.push({
164
164
  type: "item",
165
165
  data: z,
166
- groupDisabled: n.disabled,
166
+ groupDisabled: t.disabled,
167
167
  showSeparator: ie,
168
168
  index: s++,
169
169
  key: `group-${i}-item-${h}`
170
170
  });
171
- }), i < t.length - 1 && l.push({
171
+ }), i < n.length - 1 && l.push({
172
172
  type: "separator",
173
173
  index: s++,
174
174
  key: `separator-${i}`
175
175
  })) : l.push({
176
176
  type: "item",
177
- data: n,
177
+ data: t,
178
178
  index: s++,
179
179
  key: `item-${i}`
180
180
  });
@@ -186,12 +186,12 @@ const cr = a.forwardRef(
186
186
  f,
187
187
  m,
188
188
  I
189
- ]), ne = a.useRef(null), K = sr({
189
+ ]), te = a.useRef(null), K = sr({
190
190
  count: j.length,
191
- getScrollElement: () => ne.current,
191
+ getScrollElement: () => te.current,
192
192
  estimateSize: (e) => {
193
- const t = j[e];
194
- return t ? t.type === "group-label" ? 32 : t.type === "separator" ? 1 : t.showSeparator ? Z + 16 : Z : Z;
193
+ const n = j[e];
194
+ return n ? n.type === "group-label" ? 32 : n.type === "separator" ? 1 : n.showSeparator ? Z + 16 : Z : Z;
195
195
  },
196
196
  enabled: E && j.length > 0,
197
197
  overscan: 5
@@ -200,7 +200,7 @@ const cr = a.forwardRef(
200
200
  a.useEffect(() => {
201
201
  if (p && E && j.length > 0) {
202
202
  const e = setTimeout(() => {
203
- ne.current && K.measure();
203
+ te.current && K.measure();
204
204
  }, 0);
205
205
  return () => clearTimeout(e);
206
206
  }
@@ -210,41 +210,41 @@ const cr = a.forwardRef(
210
210
  [c]
211
211
  ), he = a.useMemo(() => {
212
212
  if (!c) return [];
213
- const e = [], t = Array.isArray(c) ? c : [c], l = /* @__PURE__ */ new Set();
213
+ const e = [], n = Array.isArray(c) ? c : [c], l = /* @__PURE__ */ new Set();
214
214
  for (const s of k)
215
215
  if ("items" in s) {
216
- const n = s.items.filter((i) => {
217
- const o = t.includes(i.value), h = !l.has(i.value);
216
+ const t = s.items.filter((i) => {
217
+ const o = n.includes(i.value), h = !l.has(i.value);
218
218
  return o && h ? (l.add(i.value), !0) : !1;
219
219
  });
220
- e.push(...n);
220
+ e.push(...t);
221
221
  } else
222
- t.includes(s.value) && !l.has(s.value) && (l.add(s.value), e.push(s));
222
+ n.includes(s.value) && !l.has(s.value) && (l.add(s.value), e.push(s));
223
223
  return e;
224
- }, [c, k]), te = he[0] || null, Qe = a.useMemo(() => {
224
+ }, [c, k]), ne = he[0] || null, Qe = a.useMemo(() => {
225
225
  if (!f || m !== "separated") return !0;
226
- const e = k.reduce((t, l) => t + ("items" in l ? l.items.length : 1), 0);
226
+ const e = k.reduce((n, l) => n + ("items" in l ? l.items.length : 1), 0);
227
227
  return I.length < e;
228
228
  }, [f, m, k, I]), T = (e) => {
229
229
  if (e.disabled || !F) return;
230
- const t = v.trim();
231
- if (t && (u.current = t, P.current = !0), re.current = !0, G.current = Date.now(), L) {
232
- const l = Array.isArray(c) ? c : [], s = l.includes(e.value) ? l.filter((n) => n !== e.value) : [...l, e.value];
230
+ const n = v.trim();
231
+ if (n && (u.current = n, P.current = !0), re.current = !0, G.current = Date.now(), L) {
232
+ const l = Array.isArray(c) ? c : [], s = l.includes(e.value) ? l.filter((t) => t !== e.value) : [...l, e.value];
233
233
  F(s);
234
234
  } else
235
235
  F(e.value);
236
- t && !N.current && requestAnimationFrame(() => {
236
+ n && !N.current && requestAnimationFrame(() => {
237
237
  d !== void 0 ? !d && u.current && w?.(u.current) : u.current && q(u.current);
238
238
  });
239
239
  }, U = a.memo(
240
240
  ({
241
241
  label: e,
242
- customLabel: t,
242
+ customLabel: n,
243
243
  isSelected: l
244
244
  }) => {
245
- const { textRef: s, isTruncated: n } = Se(), { textRef: i, isTruncated: o } = Se();
246
- if (t) {
247
- const h = typeof t == "function" ? t(l) : t;
245
+ const { textRef: s, isTruncated: t } = Se(), { textRef: i, isTruncated: o } = Se();
246
+ if (n) {
247
+ const h = typeof n == "function" ? n(l) : n;
248
248
  return /* @__PURE__ */ r(
249
249
  ke,
250
250
  {
@@ -263,7 +263,7 @@ const cr = a.forwardRef(
263
263
  }
264
264
  );
265
265
  }
266
- return /* @__PURE__ */ r(ke, { content: e, disabled: !n, showArrow: !0, children: /* @__PURE__ */ r(
266
+ return /* @__PURE__ */ r(ke, { content: e, disabled: !t, showArrow: !0, children: /* @__PURE__ */ r(
267
267
  ae,
268
268
  {
269
269
  ref: s,
@@ -276,8 +276,8 @@ const cr = a.forwardRef(
276
276
  }
277
277
  );
278
278
  U.displayName = "LabelWithTooltip";
279
- const se = (e, t, l) => {
280
- const s = Je(e.value), n = l || e.value, i = L || m === "checkbox", o = !L && (m === "radio" || m === "single" || m === "separated");
279
+ const se = (e, n, l) => {
280
+ const s = Je(e.value), t = l || e.value, i = L || m === "checkbox", o = !L && (m === "radio" || m === "single" || m === "separated");
281
281
  return m === "default" ? /* @__PURE__ */ r(
282
282
  ye,
283
283
  {
@@ -297,7 +297,7 @@ const cr = a.forwardRef(
297
297
  onSelect: () => T(e),
298
298
  className: fe || Q
299
299
  },
300
- n
300
+ t
301
301
  ) : i ? /* @__PURE__ */ b(
302
302
  "div",
303
303
  {
@@ -343,7 +343,7 @@ const cr = a.forwardRef(
343
343
  ) : typeof e.endIcon == "function" ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center w-4 h-4", children: e.endIcon(s) }) : /* @__PURE__ */ r("div", { className: "flex items-center justify-center w-4 h-4", children: e.endIcon }))
344
344
  ]
345
345
  },
346
- n
346
+ t
347
347
  ) : o ? /* @__PURE__ */ b("div", { children: [
348
348
  /* @__PURE__ */ b(
349
349
  "div",
@@ -382,8 +382,8 @@ const cr = a.forwardRef(
382
382
  ]
383
383
  }
384
384
  ),
385
- t && /* @__PURE__ */ r(ar, { className: "my-xs-4 -mx-1" })
386
- ] }, n) : /* @__PURE__ */ r(
385
+ n && /* @__PURE__ */ r(ar, { className: "my-xs-4 -mx-1" })
386
+ ] }, t) : /* @__PURE__ */ r(
387
387
  ye,
388
388
  {
389
389
  label: e.label,
@@ -402,7 +402,7 @@ const cr = a.forwardRef(
402
402
  onSelect: () => T(e),
403
403
  className: fe || Q
404
404
  },
405
- n
405
+ t
406
406
  );
407
407
  }, Xe = (e) => {
408
408
  switch (e.type) {
@@ -450,20 +450,20 @@ const cr = a.forwardRef(
450
450
  }
451
451
  )
452
452
  ] }) });
453
- const e = (n) => {
454
- if (n.includes(`
453
+ const e = (t) => {
454
+ if (t.includes(`
455
455
  `))
456
- return n.split(`
456
+ return t.split(`
457
457
  `).map((o, h, z) => /* @__PURE__ */ b(a.Fragment, { children: [
458
458
  o,
459
459
  h < z.length - 1 && /* @__PURE__ */ r("br", {})
460
460
  ] }, h));
461
- const i = n.split("Please try a different keyword.");
461
+ const i = t.split("Please try a different keyword.");
462
462
  return i.length > 1 ? /* @__PURE__ */ b(Me, { children: [
463
463
  i[0],
464
464
  /* @__PURE__ */ r("br", {}),
465
465
  "Please try a different keyword."
466
- ] }) : n;
466
+ ] }) : t;
467
467
  };
468
468
  if (k.length === 0)
469
469
  return /* @__PURE__ */ r("div", { className: x.emptyState(), children: e(ce) });
@@ -476,19 +476,19 @@ const cr = a.forwardRef(
476
476
  width: "100%",
477
477
  position: "relative"
478
478
  },
479
- children: K.getVirtualItems().map((n) => {
480
- const i = j[n.index];
479
+ children: K.getVirtualItems().map((t) => {
480
+ const i = j[t.index];
481
481
  return i ? /* @__PURE__ */ r(
482
482
  "div",
483
483
  {
484
- "data-index": n.index,
484
+ "data-index": t.index,
485
485
  style: {
486
486
  position: "absolute",
487
487
  top: 0,
488
488
  left: 0,
489
489
  width: "100%",
490
- height: `${n.size}px`,
491
- transform: `translateY(${n.start}px)`
490
+ height: `${t.size}px`,
491
+ transform: `translateY(${t.start}px)`
492
492
  },
493
493
  children: Xe(i)
494
494
  },
@@ -497,35 +497,35 @@ const cr = a.forwardRef(
497
497
  })
498
498
  }
499
499
  );
500
- const t = A;
500
+ const n = A;
501
501
  if (S && v.trim() && A.length === 0)
502
502
  return /* @__PURE__ */ r("div", { className: x.emptyState(), children: e(ce) });
503
- const s = f && m === "separated" ? t.map((n) => {
504
- if ("items" in n) {
505
- const i = n.items.filter(
503
+ const s = f && m === "separated" ? n.map((t) => {
504
+ if ("items" in t) {
505
+ const i = t.items.filter(
506
506
  (o) => !I.includes(o.value)
507
507
  );
508
508
  return i.length > 0 ? {
509
- ...n,
509
+ ...t,
510
510
  items: i
511
511
  } : null;
512
512
  }
513
- return I.includes(n.value) ? null : n;
514
- }).filter((n) => n !== null) : t;
515
- return s.map((n, i) => {
516
- if ("items" in n)
513
+ return I.includes(t.value) ? null : t;
514
+ }).filter((t) => t !== null) : n;
515
+ return s.map((t, i) => {
516
+ if ("items" in t)
517
517
  return /* @__PURE__ */ b(a.Fragment, { children: [
518
- n.label && /* @__PURE__ */ r(
518
+ t.label && /* @__PURE__ */ r(
519
519
  be,
520
520
  {
521
521
  className: g(
522
522
  x.label(),
523
- n.disabled && "opacity-50 text-fg-neutral-disabled"
523
+ t.disabled && "opacity-50 text-fg-neutral-disabled"
524
524
  ),
525
- children: n.label
525
+ children: t.label
526
526
  }
527
527
  ),
528
- n.items.map((o, h) => {
528
+ t.items.map((o, h) => {
529
529
  const z = s.reduce(
530
530
  (C, le) => "items" in le ? [...C, ...le.items] : [...C, le],
531
531
  []
@@ -535,7 +535,7 @@ const cr = a.forwardRef(
535
535
  z
536
536
  ) : !1, ie = {
537
537
  ...o,
538
- disabled: n.disabled || o.disabled
538
+ disabled: t.disabled || o.disabled
539
539
  }, J = `group-${i}-${o.value}-${h}`;
540
540
  return se(
541
541
  ie,
@@ -548,8 +548,8 @@ const cr = a.forwardRef(
548
548
  {
549
549
  const o = s.filter(
550
550
  (z) => !("items" in z)
551
- ), h = $ ? $(n, i, o) : !1;
552
- return se(n, h);
551
+ ), h = $ ? $(t, i, o) : !1;
552
+ return se(t, h);
553
553
  }
554
554
  });
555
555
  }, _e = /* @__PURE__ */ b("div", { className: "flex items-center gap-xs-3", children: [
@@ -558,9 +558,9 @@ const cr = a.forwardRef(
558
558
  {
559
559
  className: g(
560
560
  "flex-1 truncate text-left text-sm",
561
- te ? "text-fg-neutral-main" : x.placeholder()
561
+ ne ? "text-fg-neutral-main" : x.placeholder()
562
562
  ),
563
- children: te ? te.label : Te
563
+ children: ne ? ne.label : Te
564
564
  }
565
565
  ),
566
566
  /* @__PURE__ */ r(R, { name: "chevron-down", size: 16, className: x.chevron() })
@@ -589,8 +589,8 @@ const cr = a.forwardRef(
589
589
  children: $e || Le || _e
590
590
  }
591
591
  ),
592
- /* @__PURE__ */ r(nr, { container: document.body, children: /* @__PURE__ */ b(
593
- tr,
592
+ /* @__PURE__ */ r(tr, { container: document.body, children: /* @__PURE__ */ b(
593
+ nr,
594
594
  {
595
595
  side: Ae,
596
596
  align: Ie,
@@ -626,8 +626,8 @@ const cr = a.forwardRef(
626
626
  autoFocus: !0,
627
627
  value: v,
628
628
  onChange: (e) => {
629
- const t = e.target.value;
630
- N.current = !0, q(t), t.trim() ? (P.current = !0, u.current = t) : u.current || (P.current = !1), t.trim() ? B(!0) : B(!1), w && w(t);
629
+ const n = e.target.value;
630
+ N.current = !0, q(n), n.trim() ? (P.current = !0, u.current = n) : u.current || (P.current = !1), n.trim() ? B(!0) : B(!1), w && w(n);
631
631
  },
632
632
  placeholder: Oe,
633
633
  sizeVariant: "sm",
@@ -647,7 +647,7 @@ const cr = a.forwardRef(
647
647
  /* @__PURE__ */ b(
648
648
  "div",
649
649
  {
650
- ref: ne,
650
+ ref: te,
651
651
  className: g("overflow-y-auto overflow-x-hidden"),
652
652
  style: {
653
653
  maxHeight: `${We - (S ? 46 : 0) - (de ? 40 : 0)}px`,
@@ -669,14 +669,13 @@ const cr = a.forwardRef(
669
669
  children: /* @__PURE__ */ r(
670
670
  "div",
671
671
  {
672
- className: "p-xs-3 space-y-1 overflow-hidden",
673
672
  onClick: (e) => e.stopPropagation(),
674
673
  children: he.map((e) => /* @__PURE__ */ b(
675
674
  "div",
676
675
  {
677
676
  className: "flex flex-1 w-full items-center gap-2 p-2 cursor-pointer hover:bg-bg-neutral-subtle text-fg-neutral-main rounded-sm overflow-hidden",
678
- onClick: (t) => {
679
- t.stopPropagation(), T(e);
677
+ onClick: (n) => {
678
+ n.stopPropagation(), T(e);
680
679
  },
681
680
  children: [
682
681
  L ? /* @__PURE__ */ r(
@@ -684,8 +683,8 @@ const cr = a.forwardRef(
684
683
  {
685
684
  checked: !0,
686
685
  disabled: e.disabled,
687
- onChange: (t) => {
688
- t.stopPropagation(), T(e);
686
+ onChange: (n) => {
687
+ n.stopPropagation(), T(e);
689
688
  }
690
689
  }
691
690
  ) : /* @__PURE__ */ r(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mcr-design-systems",
3
3
  "private": false,
4
- "version": "1.0.210",
4
+ "version": "1.0.211",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",