welcome-ui 10.0.0-alpha.11 → 10.0.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Select.js CHANGED
@@ -1,19 +1,18 @@
1
1
  "use client";
2
2
  import './Select.css';
3
- import { jsx as v, jsxs as L } from "react/jsx-runtime";
4
- import { D as me } from "./downshift.esm-xtYanIDi.js";
5
- import { g as Ke, c as ye } from "./index-PAaZGbyz.js";
6
- import { forwardRef as Le, useMemo as Pe, useState as P, useEffect as he, useCallback as $e, Fragment as Ye } from "react";
7
- import { CloseButton as Be } from "./CloseButton.js";
8
- import { useField as Xe } from "./Field.js";
9
- import { Icon as _e } from "./Icon.js";
10
- import { c as Ze } from "./create-event-rXDe5aCQ.js";
11
- import { u as Qe } from "./useForkRef-D807AV7D.js";
12
- import { Tag as Ge } from "./Tag.js";
13
- var V = { exports: {} }, pe;
14
- function Je() {
15
- if (pe) return V.exports;
16
- pe = 1;
3
+ import { jsx as p, jsxs as L } from "react/jsx-runtime";
4
+ import { D as pe } from "./downshift.esm-xtYanIDi.js";
5
+ import { g as Ye, c as Ce } from "./index-PAaZGbyz.js";
6
+ import { useRef as Be, useMemo as be, forwardRef as Xe, useState as $, useEffect as ge, useCallback as Ze, Fragment as Qe } from "react";
7
+ import { CloseButton as Ge } from "./CloseButton.js";
8
+ import { useField as Je } from "./Field.js";
9
+ import { Icon as Ae } from "./Icon.js";
10
+ import { c as et } from "./create-event-rXDe5aCQ.js";
11
+ import { Tag as tt } from "./Tag.js";
12
+ var H = { exports: {} }, Ie;
13
+ function nt() {
14
+ if (Ie) return H.exports;
15
+ Ie = 1;
17
16
  var e = {
18
17
  À: "A",
19
18
  Á: "A",
@@ -475,25 +474,25 @@ function Je() {
475
474
  ё: "е",
476
475
  Ё: "Е"
477
476
  }, t = Object.keys(e).join("|"), n = new RegExp(t, "g"), r = new RegExp(t, "");
478
- function s(o) {
479
- return e[o];
477
+ function a(l) {
478
+ return e[l];
480
479
  }
481
- var c = function(o) {
482
- return o.replace(n, s);
483
- }, i = function(o) {
484
- return !!o.match(r);
480
+ var i = function(l) {
481
+ return l.replace(n, a);
482
+ }, f = function(l) {
483
+ return !!l.match(r);
485
484
  };
486
- return V.exports = c, V.exports.has = i, V.exports.remove = c, V.exports;
485
+ return H.exports = i, H.exports.has = f, H.exports.remove = i, H.exports;
487
486
  }
488
- var et = Je();
489
- const tt = /* @__PURE__ */ Ke(et);
487
+ var rt = nt();
488
+ const st = /* @__PURE__ */ Ye(rt);
490
489
  /**
491
490
  * @name match-sorter
492
491
  * @license MIT license.
493
492
  * @copyright (c) 2020 Kent C. Dodds
494
493
  * @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
495
494
  */
496
- const g = {
495
+ const A = {
497
496
  CASE_SENSITIVE_EQUAL: 7,
498
497
  EQUAL: 6,
499
498
  STARTS_WITH: 5,
@@ -502,125 +501,125 @@ const g = {
502
501
  ACRONYM: 2,
503
502
  MATCHES: 1,
504
503
  NO_MATCH: 0
505
- }, nt = (e, t) => String(e.rankedValue).localeCompare(String(t.rankedValue));
506
- function G(e, t, n) {
504
+ }, at = (e, t) => String(e.rankedValue).localeCompare(String(t.rankedValue));
505
+ function te(e, t, n) {
507
506
  n === void 0 && (n = {});
508
507
  const {
509
508
  keys: r,
510
- threshold: s = g.MATCHES,
511
- baseSort: c = nt,
512
- sorter: i = (d) => d.sort((u, h) => ot(u, h, c))
513
- } = n, o = e.reduce(l, []);
514
- return i(o).map((d) => {
509
+ threshold: a = A.MATCHES,
510
+ baseSort: i = at,
511
+ sorter: f = (u) => u.sort((o, m) => ot(o, m, i))
512
+ } = n, l = e.reduce(s, []);
513
+ return f(l).map((u) => {
515
514
  let {
516
- item: u
517
- } = d;
518
- return u;
515
+ item: o
516
+ } = u;
517
+ return o;
519
518
  });
520
- function l(d, u, h) {
521
- const E = rt(u, r, t, n), {
522
- rank: p,
523
- keyThreshold: m = s
524
- } = E;
525
- return p >= m && d.push({
526
- ...E,
527
- item: u,
528
- index: h
529
- }), d;
519
+ function s(u, o, m) {
520
+ const C = lt(o, r, t, n), {
521
+ rank: q,
522
+ keyThreshold: v = a
523
+ } = C;
524
+ return q >= v && u.push({
525
+ ...C,
526
+ item: o,
527
+ index: m
528
+ }), u;
530
529
  }
531
530
  }
532
- G.rankings = g;
533
- function rt(e, t, n, r) {
531
+ te.rankings = A;
532
+ function lt(e, t, n, r) {
534
533
  if (!t) {
535
- const c = e;
534
+ const i = e;
536
535
  return {
537
536
  // ends up being duplicate of 'item' in matches but consistent
538
- rankedValue: c,
539
- rank: Ae(c, n, r),
537
+ rankedValue: i,
538
+ rank: ve(i, n, r),
540
539
  keyIndex: -1,
541
540
  keyThreshold: r.threshold
542
541
  };
543
542
  }
544
- return it(e, t).reduce((c, i, o) => {
543
+ return ft(e, t).reduce((i, f, l) => {
545
544
  let {
546
- rank: l,
547
- rankedValue: d,
548
- keyIndex: u,
549
- keyThreshold: h
550
- } = c, {
551
- itemValue: E,
552
- attributes: p
553
- } = i, m = Ae(E, n, r), k = d;
545
+ rank: s,
546
+ rankedValue: u,
547
+ keyIndex: o,
548
+ keyThreshold: m
549
+ } = i, {
550
+ itemValue: C,
551
+ attributes: q
552
+ } = f, v = ve(C, n, r), g = u;
554
553
  const {
555
- minRanking: T,
556
- maxRanking: R,
557
- threshold: S
558
- } = p;
559
- return m < T && m >= g.MATCHES ? m = T : m > R && (m = R), m > l && (l = m, u = o, h = S, k = E), {
560
- rankedValue: k,
561
- rank: l,
562
- keyIndex: u,
563
- keyThreshold: h
554
+ minRanking: E,
555
+ maxRanking: U,
556
+ threshold: P
557
+ } = q;
558
+ return v < E && v >= A.MATCHES ? v = E : v > U && (v = U), v > s && (s = v, o = l, m = P, g = C), {
559
+ rankedValue: g,
560
+ rank: s,
561
+ keyIndex: o,
562
+ keyThreshold: m
564
563
  };
565
564
  }, {
566
565
  rankedValue: e,
567
- rank: g.NO_MATCH,
566
+ rank: A.NO_MATCH,
568
567
  keyIndex: -1,
569
568
  keyThreshold: r.threshold
570
569
  });
571
570
  }
572
- function Ae(e, t, n) {
573
- return e = ge(e, n), t = ge(t, n), t.length > e.length ? g.NO_MATCH : e === t ? g.CASE_SENSITIVE_EQUAL : (e = e.toLowerCase(), t = t.toLowerCase(), e === t ? g.EQUAL : e.startsWith(t) ? g.STARTS_WITH : e.includes(` ${t}`) ? g.WORD_STARTS_WITH : e.includes(t) ? g.CONTAINS : t.length === 1 ? g.NO_MATCH : st(e).includes(t) ? g.ACRONYM : at(e, t));
571
+ function ve(e, t, n) {
572
+ return e = Ee(e, n), t = Ee(t, n), t.length > e.length ? A.NO_MATCH : e === t ? A.CASE_SENSITIVE_EQUAL : (e = e.toLowerCase(), t = t.toLowerCase(), e === t ? A.EQUAL : e.startsWith(t) ? A.STARTS_WITH : e.includes(` ${t}`) ? A.WORD_STARTS_WITH : e.includes(t) ? A.CONTAINS : t.length === 1 ? A.NO_MATCH : ct(e).includes(t) ? A.ACRONYM : it(e, t));
574
573
  }
575
- function st(e) {
574
+ function ct(e) {
576
575
  let t = "";
577
576
  return e.split(" ").forEach((r) => {
578
- r.split("-").forEach((c) => {
579
- t += c.substr(0, 1);
577
+ r.split("-").forEach((i) => {
578
+ t += i.substr(0, 1);
580
579
  });
581
580
  }), t;
582
581
  }
583
- function at(e, t) {
582
+ function it(e, t) {
584
583
  let n = 0, r = 0;
585
- function s(l, d, u) {
586
- for (let h = u, E = d.length; h < E; h++)
587
- if (d[h] === l)
588
- return n += 1, h + 1;
584
+ function a(s, u, o) {
585
+ for (let m = o, C = u.length; m < C; m++)
586
+ if (u[m] === s)
587
+ return n += 1, m + 1;
589
588
  return -1;
590
589
  }
591
- function c(l) {
592
- const d = 1 / l, u = n / t.length;
593
- return g.MATCHES + u * d;
590
+ function i(s) {
591
+ const u = 1 / s, o = n / t.length;
592
+ return A.MATCHES + o * u;
594
593
  }
595
- const i = s(t[0], e, 0);
596
- if (i < 0)
597
- return g.NO_MATCH;
598
- r = i;
599
- for (let l = 1, d = t.length; l < d; l++) {
600
- const u = t[l];
601
- if (r = s(u, e, r), !(r > -1))
602
- return g.NO_MATCH;
594
+ const f = a(t[0], e, 0);
595
+ if (f < 0)
596
+ return A.NO_MATCH;
597
+ r = f;
598
+ for (let s = 1, u = t.length; s < u; s++) {
599
+ const o = t[s];
600
+ if (r = a(o, e, r), !(r > -1))
601
+ return A.NO_MATCH;
603
602
  }
604
- const o = r - i;
605
- return c(o);
603
+ const l = r - f;
604
+ return i(l);
606
605
  }
607
606
  function ot(e, t, n) {
608
607
  const {
609
- rank: c,
610
- keyIndex: i
608
+ rank: i,
609
+ keyIndex: f
611
610
  } = e, {
612
- rank: o,
613
- keyIndex: l
611
+ rank: l,
612
+ keyIndex: s
614
613
  } = t;
615
- return c === o ? i === l ? n(e, t) : i < l ? -1 : 1 : c > o ? -1 : 1;
614
+ return i === l ? f === s ? n(e, t) : f < s ? -1 : 1 : i > l ? -1 : 1;
616
615
  }
617
- function ge(e, t) {
616
+ function Ee(e, t) {
618
617
  let {
619
618
  keepDiacritics: n
620
619
  } = t;
621
- return e = `${e}`, n || (e = tt(e)), e;
620
+ return e = `${e}`, n || (e = st(e)), e;
622
621
  }
623
- function lt(e, t) {
622
+ function ut(e, t) {
624
623
  typeof t == "object" && (t = t.key);
625
624
  let n;
626
625
  if (typeof t == "function")
@@ -631,65 +630,77 @@ function lt(e, t) {
631
630
  n = e[t];
632
631
  else {
633
632
  if (t.includes("."))
634
- return ct(t, e);
633
+ return dt(t, e);
635
634
  n = null;
636
635
  }
637
636
  return n == null ? [] : Array.isArray(n) ? n : [String(n)];
638
637
  }
639
- function ct(e, t) {
638
+ function dt(e, t) {
640
639
  const n = e.split(".");
641
640
  let r = [t];
642
- for (let s = 0, c = n.length; s < c; s++) {
643
- const i = n[s];
644
- let o = [];
645
- for (let l = 0, d = r.length; l < d; l++) {
646
- const u = r[l];
647
- if (u != null)
648
- if (Object.hasOwnProperty.call(u, i)) {
649
- const h = u[i];
650
- h != null && o.push(h);
651
- } else i === "*" && (o = o.concat(u));
641
+ for (let a = 0, i = n.length; a < i; a++) {
642
+ const f = n[a];
643
+ let l = [];
644
+ for (let s = 0, u = r.length; s < u; s++) {
645
+ const o = r[s];
646
+ if (o != null)
647
+ if (Object.hasOwnProperty.call(o, f)) {
648
+ const m = o[f];
649
+ m != null && l.push(m);
650
+ } else f === "*" && (l = l.concat(o));
652
651
  }
653
- r = o;
652
+ r = l;
654
653
  }
655
654
  return Array.isArray(r[0]) ? [].concat(...r) : r;
656
655
  }
657
- function it(e, t) {
656
+ function ft(e, t) {
658
657
  const n = [];
659
- for (let r = 0, s = t.length; r < s; r++) {
660
- const c = t[r], i = ut(c), o = lt(e, c);
661
- for (let l = 0, d = o.length; l < d; l++)
658
+ for (let r = 0, a = t.length; r < a; r++) {
659
+ const i = t[r], f = mt(i), l = ut(e, i);
660
+ for (let s = 0, u = l.length; s < u; s++)
662
661
  n.push({
663
- itemValue: o[l],
664
- attributes: i
662
+ itemValue: l[s],
663
+ attributes: f
665
664
  });
666
665
  }
667
666
  return n;
668
667
  }
669
- const Ie = {
668
+ const ye = {
670
669
  maxRanking: 1 / 0,
671
670
  minRanking: -1 / 0
672
671
  };
673
- function ut(e) {
674
- return typeof e == "string" ? Ie : {
675
- ...Ie,
672
+ function mt(e) {
673
+ return typeof e == "string" ? ye : {
674
+ ...ye,
676
675
  ...e
677
676
  };
678
677
  }
679
- const dt = "_indicators_1tqnt_2", ft = "_open_1tqnt_34", mt = "_disabled_1tqnt_40", ht = "_root_1tqnt_51", _t = "_clearable_1tqnt_86", pt = "_transparent_1tqnt_104", At = "_wrapper_1tqnt_204", gt = "_menu_1tqnt_211", It = "_item_1tqnt_239", vt = "_highlighted_1tqnt_253", Et = "_selected_1tqnt_256", Ot = "_multiple_1tqnt_256", yt = "_allowUnselectFromList_1tqnt_260", wt = "_tags_1tqnt_268", we = {
680
- indicators: dt,
678
+ function ht(...e) {
679
+ return (t) => {
680
+ e.forEach((n) => _t(n, t));
681
+ };
682
+ }
683
+ function _t(e, t) {
684
+ e && (typeof e == "function" && t !== void 0 ? e(t) : e.current = t ?? null);
685
+ }
686
+ function pt(e, t) {
687
+ const n = Be(null), r = be(() => ht(e, n, t), [e, n, t]);
688
+ return [n, r];
689
+ }
690
+ const gt = "_indicators_1tqnt_2", At = "_open_1tqnt_34", It = "_disabled_1tqnt_40", vt = "_root_1tqnt_51", Et = "_clearable_1tqnt_86", yt = "_transparent_1tqnt_104", Ot = "_wrapper_1tqnt_204", wt = "_menu_1tqnt_211", xt = "_item_1tqnt_239", Ct = "_highlighted_1tqnt_253", bt = "_selected_1tqnt_256", Nt = "_multiple_1tqnt_256", qt = "_allowUnselectFromList_1tqnt_260", Rt = "_tags_1tqnt_268", Ne = {
691
+ indicators: gt,
681
692
  "size-xs": "_size-xs_1tqnt_11",
682
693
  "dropdown-indicator": "_dropdown-indicator_1tqnt_14",
683
694
  "styled-icon": "_styled-icon_1tqnt_28",
684
- open: ft,
685
- disabled: mt,
695
+ open: At,
696
+ disabled: It,
686
697
  "input-wrapper": "_input-wrapper_1tqnt_44",
687
698
  "icon-placement-right": "_icon-placement-right_1tqnt_47",
688
- root: ht,
699
+ root: vt,
689
700
  "icon-placement-left": "_icon-placement-left_1tqnt_83",
690
701
  "icon-placement-both": "_icon-placement-both_1tqnt_83",
691
- clearable: _t,
692
- transparent: pt,
702
+ clearable: Et,
703
+ transparent: yt,
693
704
  "variant-danger": "_variant-danger_1tqnt_140",
694
705
  "variant-success": "_variant-success_1tqnt_143",
695
706
  "variant-warning": "_variant-warning_1tqnt_146",
@@ -697,23 +708,23 @@ const dt = "_indicators_1tqnt_2", ft = "_open_1tqnt_34", mt = "_disabled_1tqnt_4
697
708
  "size-md": "_size-md_1tqnt_157",
698
709
  "size-sm": "_size-sm_1tqnt_165",
699
710
  "icon-wrapper": "_icon-wrapper_1tqnt_173",
700
- wrapper: At,
701
- menu: gt,
702
- item: It,
703
- highlighted: vt,
704
- selected: Et,
705
- multiple: Ot,
706
- allowUnselectFromList: yt,
707
- tags: wt,
711
+ wrapper: Ot,
712
+ menu: wt,
713
+ item: xt,
714
+ highlighted: Ct,
715
+ selected: bt,
716
+ multiple: Nt,
717
+ allowUnselectFromList: qt,
718
+ tags: Rt,
708
719
  "styled-tag": "_styled-tag_1tqnt_271"
709
- }, ve = ye(we);
710
- function Ct(e, t) {
711
- return /* @__PURE__ */ v("div", { className: ve("tags"), role: "list", children: e.map((n) => (
720
+ }, Oe = Ce(Ne);
721
+ function kt(e, t) {
722
+ return /* @__PURE__ */ p("div", { className: Oe("tags"), role: "list", children: e.map((n) => (
712
723
  // TODO migrate after WUI-187/tag
713
- /* @__PURE__ */ v(
714
- Ge,
724
+ /* @__PURE__ */ p(
725
+ tt,
715
726
  {
716
- className: ve("styled-tag"),
727
+ className: Oe("styled-tag"),
717
728
  onRemove: () => t(n.value.toString()),
718
729
  role: "listitem",
719
730
  children: n.label
@@ -722,174 +733,177 @@ function Ct(e, t) {
722
733
  )
723
734
  )) });
724
735
  }
725
- const ee = "", xt = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g, Ce = (e) => {
736
+ const re = "", St = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g, qe = (e) => {
726
737
  if (typeof e == "number")
727
738
  return String(e);
728
739
  if (typeof e == "string") {
729
- const t = e.match(xt);
740
+ const t = e.match(St);
730
741
  return t && t.map((n) => n.toLowerCase()).join("-");
731
742
  }
732
- }, Ee = (e) => e ? e.label : ee, Nt = (e) => e.reduce(
743
+ }, we = (e) => e ? e.label : re, Ut = (e) => e.reduce(
733
744
  (t, n) => n.label && t.length > n.label.length ? t : n.label,
734
- ee
735
- ), bt = (e, t, n) => {
736
- const r = t.find((s) => e.value === s.value);
737
- return r && n ? t.filter((s) => e.value !== s.value) : r ? t : [...t, e];
738
- }, Q = (e, t) => !!t.find((n) => n.value === e), J = (e, t = []) => t.find(
745
+ re
746
+ ), Vt = (e, t, n) => {
747
+ const r = t.find((a) => e.value === a.value);
748
+ return r && n ? t.filter((a) => e.value !== a.value) : r ? t : [...t, e];
749
+ }, ee = (e, t) => !!t.find((n) => n.value === e), ne = (e, t = []) => t.find(
739
750
  (r) => r.label === (e.label || e) || r.value === (e.value || e)
740
- ) || { label: e, value: Ce(e) }, Rt = (e, t, n = !1) => {
741
- const r = n ? t.flatMap((s) => s.options) : t;
742
- return !e && e !== 0 ? [] : Array.isArray(e) ? e.map((s) => J(s, r)) : [J(e, r)];
743
- }, qt = (e, t) => !!t.find((n) => n.value === e.value), kt = (e, t) => qt(e, t) ? e.value : e.label, Oe = (e, t) => e ? e.map((n) => kt(n, t)) : [], St = (e, t) => e ? e.filter(
751
+ ) || { label: e, value: qe(e) }, Tt = (e, t, n = !1) => {
752
+ const r = n ? t.flatMap((a) => a.options) : t;
753
+ return !e && e !== 0 ? [] : Array.isArray(e) ? e.map((a) => ne(a, r)) : [ne(e, r)];
754
+ }, Ht = (e, t) => !!t.find((n) => n.value === e.value), zt = (e, t) => Ht(e, t) ? e.value : e.label, xe = (e, t) => e ? e.map((n) => zt(n, t)) : [], Ft = (e, t) => e ? e.filter(
744
755
  (n) => !t.find((r) => r.value === n.value)
745
- ) : [], Ut = ({
756
+ ) : [], Dt = ({
746
757
  inputValue: e,
747
758
  isMultiple: t,
748
759
  isSearchable: n,
749
760
  options: r,
750
- renderItem: s
761
+ renderItem: a
751
762
  }) => {
752
- const c = J(e, r);
753
- return t ? e : c.label ? n ? c.label : s(c) : ee;
754
- }, w = ye(we), Vt = me.default || me, Tt = Le(
763
+ const i = ne(e, r);
764
+ return t ? e : i.label ? n ? i.label : a(i) : re;
765
+ }, y = Ce(Ne), jt = pe.default || pe, Mt = Xe(
755
766
  ({
756
767
  allowUnselectFromList: e,
757
768
  autoComplete: t = "off",
758
769
  autoFocus: n,
759
770
  className: r,
760
- dataTestId: s,
761
- disableCloseOnSelect: c,
762
- disabled: i,
763
- groupsEnabled: o,
764
- icon: l,
765
- iconPlacement: d = "left",
766
- id: u,
767
- isClearable: h,
768
- isCreatable: E,
769
- isMultiple: p,
770
- isSearchable: m,
771
- name: k,
772
- onBlur: T,
773
- onChange: R,
774
- onClick: S,
775
- onCreate: $,
776
- onFocus: xe,
771
+ dataTestId: a,
772
+ defaultHighlightedIndex: i,
773
+ disableCloseOnSelect: f,
774
+ disabled: l,
775
+ groupsEnabled: s,
776
+ highlightedIndex: u,
777
+ icon: o,
778
+ iconPlacement: m = "left",
779
+ id: C,
780
+ isClearable: q,
781
+ isCreatable: v,
782
+ isMultiple: g,
783
+ isSearchable: E,
784
+ name: U,
785
+ onBlur: P,
786
+ onChange: Y,
787
+ onClick: B,
788
+ onCreate: X,
789
+ onFocus: Re,
777
790
  options: I = [],
778
- placeholder: te = "Choose from…",
779
- renderCreateItem: Ne = (F) => `Create "${F}"`,
780
- renderGroupHeader: ne,
781
- renderItem: H = Ee,
782
- renderMultiple: be = Ct,
783
- size: z = "lg",
784
- transparent: re,
785
- value: se,
786
- variant: ae,
791
+ placeholder: se = "Choose from…",
792
+ renderCreateItem: ke = (D) => `Create "${D}"`,
793
+ renderGroupHeader: ae,
794
+ renderItem: z = we,
795
+ renderMultiple: Se = kt,
796
+ renderNoResults: V,
797
+ size: F = "lg",
798
+ transparent: le,
799
+ value: ce,
800
+ variant: ie,
787
801
  ...oe
788
- }, Re) => {
789
- const { getInputProps: F, variant: qe } = Xe(), le = qe || ae, D = Pe(
790
- () => Rt(se, I, o),
791
- [se, I, o]
792
- ), Y = !p && D[0] || null, B = Y ? Y.label : "", [x, X] = P(D), [C, U] = P(B), [M, j] = P(I), [N, q] = P(!1);
793
- m = E || m;
794
- const [Z, ke] = Qe(Re);
795
- he(() => {
796
- n && Z.current && (Z.current.focus(), m && q(!0));
797
- }, [m, n, Z]), he(() => {
798
- X(D), U(B), j(I);
799
- }, [B, I, D]);
800
- const Se = (a) => {
801
- if (m && a !== C) {
802
- let f = [];
803
- o ? f = G(I, a, {
802
+ }, Ue) => {
803
+ const { getInputProps: D, variant: Ve } = Je(), ue = Ve || ie, j = be(
804
+ () => Tt(ce, I, s),
805
+ [ce, I, s]
806
+ ), Z = !g && j[0] || null, Q = Z ? Z.label : "", [b, G] = $(j), [w, T] = $(Q), [k, M] = $(I), [N, S] = $(!1);
807
+ E = v || E;
808
+ const [J, Te] = pt(Ue);
809
+ ge(() => {
810
+ n && J.current && (J.current.focus(), E && S(!0));
811
+ }, [E, n, J]), ge(() => {
812
+ G(j), T(Q), M(I);
813
+ }, [Q, I, j]);
814
+ const He = (c) => {
815
+ if (E && c !== w) {
816
+ let d = [];
817
+ s ? d = te(I, c, {
804
818
  // should match on group.label OR group.options.label
805
- keys: [(A) => A.label, (A) => A.options.map((O) => O.label)]
806
- }) : f = G(I, a, { keys: ["label"] }), U(a), j(f);
819
+ keys: [(_) => _.label, (_) => _.options.map((O) => O.label)]
820
+ }) : d = te(I, c, { keys: ["label"] }), T(c), M(d);
807
821
  }
808
- }, Ue = () => {
809
- m && !N && q(!0);
810
- }, ce = (a) => {
811
- let f = [];
812
- o ? f = Oe(
813
- a,
814
- I.flatMap((_) => _.options)
815
- ) : f = Oe(a, I);
816
- const A = p ? f : f[0], O = Ze({ name: k, value: p ? a : a[0] });
817
- if (R == null || R(A, O), E) {
818
- const _ = St(a, I);
819
- _.length && ($ == null || $(_[0].label, O));
822
+ }, ze = () => {
823
+ E && !N && S(!0);
824
+ }, de = (c) => {
825
+ let d = [];
826
+ s ? d = xe(
827
+ c,
828
+ I.flatMap((h) => h.options)
829
+ ) : d = xe(c, I);
830
+ const _ = g ? d : d[0], O = et({ name: U, value: g ? c : c[0] });
831
+ if (Y == null || Y(_, O), v) {
832
+ const h = Ft(c, I);
833
+ h.length && (X == null || X(h[0].label, O));
820
834
  }
821
- }, Ve = (a) => {
822
- let f, A;
823
- !a || a != null && a.disabled ? (f = p ? x : [], A = !0) : (f = p ? bt(a, x, e) : [a], A = p), A && U(""), j(I), X(f), ce(f), c || q(!1);
824
- }, Te = (a) => {
825
- const f = x.filter((A) => A.value !== a);
826
- X(f), ce(f);
827
- }, He = (a) => {
828
- S == null || S(a), q(!N);
829
- }, ze = (a) => {
830
- p && a.selectedItem ? U("") : m && a.selectedItem && U(a.selectedItem.label), j(I), q(!1);
831
- }, Fe = Nt(I), ie = Ut({
832
- inputValue: C,
833
- isMultiple: p,
834
- isSearchable: m,
835
+ }, Fe = (c) => {
836
+ let d, _;
837
+ !c || c != null && c.disabled ? (d = g ? b : [], _ = !0) : (d = g ? Vt(c, b, e) : [c], _ = g), _ && T(""), M(I), G(d), de(d), f || S(!1);
838
+ }, De = (c) => {
839
+ const d = b.filter((_) => _.value !== c);
840
+ G(d), de(d);
841
+ }, je = (c) => {
842
+ B == null || B(c), S(!N);
843
+ }, Me = (c) => {
844
+ g && c.selectedItem ? T("") : E && c.selectedItem && T(c.selectedItem.label), M(I), S(!1);
845
+ }, We = Ut(I), fe = Dt({
846
+ inputValue: w,
847
+ isMultiple: g,
848
+ isSearchable: E,
835
849
  options: I,
836
- renderItem: H
837
- }), De = $e(
850
+ renderItem: z
851
+ }), Ke = Ze(
838
852
  ({
839
- getItemProps: a,
840
- highlightedIndex: f,
841
- options: A
842
- }) => A.reduce(
843
- (O, _, W) => {
844
- if (o && "options" in _)
853
+ getItemProps: c,
854
+ highlightedIndex: d,
855
+ options: _
856
+ }) => _.reduce(
857
+ (O, h, W) => {
858
+ if (s && "options" in h)
845
859
  O.itemsToRender.push(
846
- /* @__PURE__ */ L(Ye, { children: [
847
- ne(_),
848
- _.options ? _.options.map((y) => {
849
- const b = O.itemIndex++, K = Q(y.value, x);
850
- return /* @__PURE__ */ v(
860
+ /* @__PURE__ */ L(Qe, { children: [
861
+ ae(h),
862
+ h.options ? h.options.map((x) => {
863
+ const R = O.itemIndex++, K = ee(x.value, b);
864
+ return /* @__PURE__ */ p(
851
865
  "li",
852
866
  {
853
- className: w(
867
+ className: y(
854
868
  "item",
855
- f === b && "highlighted",
856
- p && "multiple",
869
+ d === R && "highlighted",
870
+ g && "multiple",
857
871
  e && "allowUnselectFromList",
858
- y.disabled && "disabled",
872
+ x.disabled && "disabled",
859
873
  K && "selected"
860
874
  ),
861
- ...a({
862
- index: b,
863
- item: y
875
+ ...c({
876
+ index: R,
877
+ item: x
864
878
  }),
865
- children: H(y, K)
879
+ children: z(x, K)
866
880
  },
867
- y.value
881
+ x.value
868
882
  );
869
883
  }) : null
870
- ] }, _.label)
884
+ ] }, h.label)
871
885
  );
872
- else if ("value" in _) {
873
- const y = Q(_.value, x), b = f === W;
886
+ else if ("value" in h) {
887
+ const x = ee(h.value, b), R = d === W;
874
888
  O.itemsToRender.push(
875
- /* @__PURE__ */ v(
889
+ /* @__PURE__ */ p(
876
890
  "li",
877
891
  {
878
- className: w(
892
+ className: y(
879
893
  "item",
880
- b && "highlighted",
881
- p && "multiple",
894
+ R && "highlighted",
895
+ g && "multiple",
882
896
  e && "allowUnselectFromList",
883
- _.disabled && "disabled",
884
- y && "selected"
897
+ h.disabled && "disabled",
898
+ x && "selected"
885
899
  ),
886
- ...a({
900
+ ...c({
887
901
  index: W,
888
- item: _
902
+ item: h
889
903
  }),
890
- children: H(_, y)
904
+ children: z(h, x)
891
905
  },
892
- _.value
906
+ h.value
893
907
  )
894
908
  );
895
909
  }
@@ -897,116 +911,120 @@ const ee = "", xt = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|
897
911
  },
898
912
  { itemIndex: 0, itemsToRender: [] }
899
913
  ).itemsToRender,
900
- [p, e, x, o, ne, H]
901
- ), ue = w(
914
+ [g, e, b, s, ae, z]
915
+ ), me = y(
902
916
  "root",
903
- `size-${z}`,
904
- le && `variant-${le}`,
905
- h && "clearable",
906
- re && "transparent",
907
- l && `icon-placement-${d}`,
917
+ `size-${F}`,
918
+ ue && `variant-${ue}`,
919
+ q && "clearable",
920
+ le && "transparent",
921
+ o && `icon-placement-${m}`,
908
922
  r,
909
- i && "disabled"
923
+ l && "disabled"
910
924
  );
911
- return /* @__PURE__ */ v(
912
- Vt,
925
+ return /* @__PURE__ */ p(
926
+ jt,
913
927
  {
914
- id: u,
915
- inputValue: m ? ie : "",
928
+ defaultHighlightedIndex: i,
929
+ highlightedIndex: u,
930
+ id: C,
931
+ inputValue: E ? fe : "",
916
932
  isOpen: N,
917
- itemToString: Ee,
918
- onInputValueChange: Se,
919
- onOuterClick: ze,
920
- onSelect: Ve,
921
- selectedItem: Y,
933
+ itemToString: we,
934
+ onInputValueChange: He,
935
+ onOuterClick: Me,
936
+ onSelect: Fe,
937
+ selectedItem: Z,
922
938
  children: ({
923
- clearSelection: a,
924
- getInputProps: f,
925
- getItemProps: A,
939
+ clearSelection: c,
940
+ getInputProps: d,
941
+ getItemProps: _,
926
942
  getMenuProps: O,
927
- getRootProps: _,
943
+ getRootProps: h,
928
944
  getToggleButtonProps: W,
929
- highlightedIndex: y
945
+ highlightedIndex: x
930
946
  }) => {
931
- const b = !!(E && C && !Q(C, x)), K = N && (M.length || b), de = h && C, Me = /* @__PURE__ */ v("div", { className: w("dropdown-indicator", N && "open"), children: /* @__PURE__ */ v(
932
- Be,
947
+ const R = !!(v && w && !ee(w, b)), K = N && (k.length || R), he = q && w, Le = /* @__PURE__ */ p("div", { className: y("dropdown-indicator", N && "open"), children: /* @__PURE__ */ p(
948
+ Ge,
933
949
  {
934
950
  animatePresence: !0,
935
- onClick: a,
951
+ onClick: c,
936
952
  title: "Clear"
937
953
  }
938
- ) }), je = /* @__PURE__ */ v(
954
+ ) }), $e = /* @__PURE__ */ p(
939
955
  "div",
940
956
  {
941
- className: w("dropdown-indicator", N && "open", i && "disabled"),
942
- "data-testid": s ? `${s}-arrow-icon` : null,
943
- disabled: i,
957
+ className: y("dropdown-indicator", N && "open", l && "disabled"),
958
+ "data-testid": a ? `${a}-arrow-icon` : null,
959
+ disabled: l,
944
960
  tabIndex: -1,
945
961
  ...W({
946
- onClick: () => !i && q(!N)
962
+ onClick: () => !l && S(!N)
947
963
  }),
948
- children: /* @__PURE__ */ v(_e, { className: w("styled-icon"), name: "angle-down", size: "lg" })
964
+ children: /* @__PURE__ */ p(Ae, { className: y("styled-icon"), name: "angle-down", size: "lg" })
949
965
  }
950
- ), We = _(oe, { suppressRefError: !0 }), fe = f({
966
+ ), Pe = h(oe, { suppressRefError: !0 }), _e = d({
951
967
  autoComplete: t,
952
968
  autoFocus: n,
953
- "data-spacer": Fe || te,
954
- "data-testid": s,
955
- disabled: i,
956
- id: u,
957
- name: k,
958
- onBlur: T,
959
- onClick: i ? void 0 : He,
960
- onFocus: xe,
961
- onKeyDown: Ue,
962
- placeholder: te,
963
- ref: ke,
964
- size: z,
969
+ "data-spacer": We || se,
970
+ "data-testid": a,
971
+ disabled: l,
972
+ id: C,
973
+ name: U,
974
+ onBlur: P,
975
+ onClick: l ? void 0 : je,
976
+ onFocus: Re,
977
+ onKeyDown: ze,
978
+ placeholder: se,
979
+ ref: Te,
980
+ size: F,
965
981
  tabIndex: 0,
966
- transparent: re,
967
- variant: N ? "focused" : ae,
982
+ transparent: le,
983
+ variant: N ? "focused" : ie,
968
984
  ...oe
969
985
  });
970
- return /* @__PURE__ */ L("div", { ...We, className: w("wrapper", i && "disabled", "field-input"), children: [
971
- m ? /* @__PURE__ */ v(
986
+ return /* @__PURE__ */ L("div", { ...Pe, className: y("wrapper", l && "disabled", "field-input"), children: [
987
+ E ? /* @__PURE__ */ p(
972
988
  "input",
973
989
  {
974
- className: ue,
990
+ className: me,
975
991
  type: "text",
976
- ...F(fe)
992
+ ...D(_e)
977
993
  }
978
- ) : /* @__PURE__ */ v("div", { className: ue, ...F(fe), children: ie }),
979
- l ? /* @__PURE__ */ v("div", { className: w("icon-wrapper", "icon-placement-left", `size-${z}`), children: /* @__PURE__ */ v(_e, { ...l.props, size: "md" }) }) : null,
980
- /* @__PURE__ */ L("div", { className: w("indicators", `size-${z}`), children: [
981
- de ? Me : null,
982
- je
994
+ ) : /* @__PURE__ */ p("div", { className: me, ...D(_e), children: fe }),
995
+ o ? /* @__PURE__ */ p("div", { className: y("icon-wrapper", "icon-placement-left", `size-${F}`), children: /* @__PURE__ */ p(Ae, { ...o.props, size: "md" }) }) : null,
996
+ /* @__PURE__ */ L("div", { className: y("indicators", `size-${F}`), children: [
997
+ he ? Le : null,
998
+ $e
983
999
  ] }),
984
- K ? /* @__PURE__ */ L("ul", { className: w("menu"), ...O(), children: [
985
- De({ getItemProps: A, highlightedIndex: y, options: M }),
986
- b && C.length ? /* @__PURE__ */ v(
1000
+ K ? /* @__PURE__ */ L("ul", { className: y("menu"), ...O(), children: [
1001
+ Ke({ getItemProps: _, highlightedIndex: x, options: k }),
1002
+ k.length ? null : V == null ? void 0 : V(w),
1003
+ R && w.length ? /* @__PURE__ */ p(
987
1004
  "li",
988
1005
  {
989
- className: w("item", y === M.length && "highlighted"),
990
- ...A({
991
- index: M.length,
1006
+ className: y("item", x === k.length && "highlighted"),
1007
+ ..._({
1008
+ index: k.length,
992
1009
  item: {
993
- label: C,
994
- value: Ce(C)
1010
+ label: w,
1011
+ value: qe(w)
995
1012
  }
996
1013
  }),
997
- children: Ne(C)
1014
+ children: ke(w)
998
1015
  },
999
1016
  "add"
1000
1017
  ) : null
1001
1018
  ] }) : null,
1002
- p ? be(x, Te) : null
1019
+ !k.length && V ? /* @__PURE__ */ p("ul", { className: y("menu"), ...O(), children: /* @__PURE__ */ p("li", { className: `${y("item")} cursor-default`, children: V(w) }) }) : null,
1020
+ g ? Se(b, De) : null
1003
1021
  ] });
1004
1022
  }
1005
1023
  }
1006
1024
  );
1007
1025
  }
1008
1026
  );
1009
- Tt.displayName = "Select";
1027
+ Mt.displayName = "Select";
1010
1028
  export {
1011
- Tt as Select
1029
+ Mt as Select
1012
1030
  };