@starasia/dropdown 5.4.0 → 5.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { jsxs as l, jsx as n, Fragment as sn } from "react/jsx-runtime";
2
- import ln, { useState as I, useRef as M, useEffect as x, forwardRef as yn } from "react";
1
+ import { jsxs as l, jsx as n, Fragment as dn } from "react/jsx-runtime";
2
+ import ln, { useState as W, useRef as M, useEffect as v, forwardRef as yn } from "react";
3
3
  const Nn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
4
4
  * {
5
5
  margin: 0;
@@ -37,6 +37,15 @@ const Nn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
37
37
  }
38
38
 
39
39
  /* === SIZE VARIANTS === */
40
+ .sa-input-dropdown-size-xs {
41
+ --baseFont: 12px;
42
+ --height: 28px;
43
+ --borderRadius: var(--sa-dropdown-radius);
44
+ --paddingInline: 8px;
45
+ --paddingBlock: 2px;
46
+ --iconSize: 14px;
47
+ --iconMarginTop: 4px;
48
+ }
40
49
  .sa-input-dropdown-size-sm {
41
50
  --baseFont: 12px;
42
51
  --height: 32px;
@@ -352,6 +361,7 @@ const Nn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
352
361
  min-height: 32px;
353
362
  font-size: 12px;
354
363
  }
364
+ .sa-input-dropdown-size-xs .sa-input-dropdown-item,
355
365
  .sa-input-dropdown-size-sm .sa-input-dropdown-item,
356
366
  .sa-input-dropdown-size-md .sa-input-dropdown-item {
357
367
  font-size: 12px;
@@ -451,17 +461,19 @@ const Nn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
451
461
  .sa-select-field-label-row {
452
462
  display: flex;
453
463
  align-items: center;
454
- gap: 6px;
464
+ gap: 4px;
455
465
  flex-wrap: wrap;
456
466
  }
457
467
  .sa-select-field-label-text {
458
468
  font-size: 14px;
459
469
  font-weight: 500;
460
470
  color: var(--sa-dropdown-text-primary);
461
- line-height: 1.3;
471
+ line-height: normal;
462
472
  }
463
- .sa-select-field-left .sa-select-field-label-text {
464
- font-size: 14px;
473
+ /* match Input: xs/sm label drops to 12px */
474
+ .sa-select-field-size-xs .sa-select-field-label-text,
475
+ .sa-select-field-size-sm .sa-select-field-label-text {
476
+ font-size: 12px;
465
477
  }
466
478
  .sa-select-field-required {
467
479
  font-size: 14px;
@@ -469,6 +481,10 @@ const Nn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
469
481
  color: var(--sa-dropdown-text-error);
470
482
  line-height: 1;
471
483
  }
484
+ .sa-select-field-size-xs .sa-select-field-required,
485
+ .sa-select-field-size-sm .sa-select-field-required {
486
+ font-size: 12px;
487
+ }
472
488
  .sa-select-field-optional-badge {
473
489
  display: inline-flex;
474
490
  align-items: center;
@@ -536,12 +552,12 @@ const Nn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
536
552
 
537
553
  `;
538
554
  function En(o) {
539
- const [p, t] = I(o), s = M(null), d = (r) => {
540
- s.current && !s.current.contains(r.target) && t(!1);
555
+ const [p, s] = W(o), d = M(null), i = (r) => {
556
+ d.current && !d.current.contains(r.target) && s(!1);
541
557
  };
542
- return x(() => (document.addEventListener("click", d, !0), () => {
543
- document.removeEventListener("click", d, !0);
544
- }), []), { ref: s, isComponentVisible: p, setIsComponentVisible: t };
558
+ return v(() => (document.addEventListener("click", i, !0), () => {
559
+ document.removeEventListener("click", i, !0);
560
+ }), []), { ref: d, isComponentVisible: p, setIsComponentVisible: s };
545
561
  }
546
562
  const Cn = ({ ...o }) => /* @__PURE__ */ l(
547
563
  "svg",
@@ -598,9 +614,9 @@ const Cn = ({ ...o }) => /* @__PURE__ */ l(
598
614
  ({
599
615
  positionDropdown: o,
600
616
  dropdownLists: p,
601
- isComponentVisible: t,
602
- searchAble: s,
603
- hideSearch: d,
617
+ isComponentVisible: s,
618
+ searchAble: d,
619
+ hideSearch: i,
604
620
  onSearch: r,
605
621
  value: m,
606
622
  handleChangeValue: u,
@@ -608,21 +624,21 @@ const Cn = ({ ...o }) => /* @__PURE__ */ l(
608
624
  searchValue: L,
609
625
  highlightedIndex: y,
610
626
  footer: F,
611
- groupLabel: H,
627
+ groupLabel: T,
612
628
  onSelectAll: N
613
629
  }, U) => {
614
630
  const j = M([]);
615
- x(() => {
616
- var i;
617
- y >= 0 && j.current[y] && ((i = j.current[y]) == null || i.scrollIntoView({ block: "nearest" }));
631
+ v(() => {
632
+ var t;
633
+ y >= 0 && j.current[y] && ((t = j.current[y]) == null || t.scrollIntoView({ block: "nearest" }));
618
634
  }, [y]);
619
- const T = s && !d ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
635
+ const $ = d && !i ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
620
636
  /* @__PURE__ */ n(Cn, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
621
637
  /* @__PURE__ */ n(
622
638
  "input",
623
639
  {
624
- onChange: (i) => {
625
- r && r(i.target.value);
640
+ onChange: (t) => {
641
+ r && r(t.target.value);
626
642
  },
627
643
  value: L,
628
644
  autoFocus: !0,
@@ -630,70 +646,70 @@ const Cn = ({ ...o }) => /* @__PURE__ */ l(
630
646
  }
631
647
  )
632
648
  ] }) : null;
633
- return /* @__PURE__ */ n(sn, { children: t ? /* @__PURE__ */ l(
649
+ return /* @__PURE__ */ n(dn, { children: s ? /* @__PURE__ */ l(
634
650
  "div",
635
651
  {
636
652
  className: "sa-input-dropdown-lists-container",
637
- onClick: (i) => i.stopPropagation(),
653
+ onClick: (t) => t.stopPropagation(),
638
654
  ref: U,
639
655
  children: [
640
- o !== "top" && T,
656
+ o !== "top" && $,
641
657
  /* @__PURE__ */ l(
642
658
  "div",
643
659
  {
644
660
  className: `sa-input-dropdown-item-container ${R ? "multi" : ""}`,
645
661
  children: [
646
- H && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
647
- /* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: H }),
662
+ T && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
663
+ /* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: T }),
648
664
  R && N && /* @__PURE__ */ n(
649
665
  "button",
650
666
  {
651
667
  className: "sa-input-dropdown-section-select-all",
652
- onClick: (i) => {
653
- i.stopPropagation(), N();
668
+ onClick: (t) => {
669
+ t.stopPropagation(), N();
654
670
  },
655
671
  children: "Select all"
656
672
  }
657
673
  )
658
674
  ] }),
659
- p.map((i, A) => {
660
- const $ = !!(m != null && m.find((P) => P.value === i.value)), w = !!i.description;
675
+ p.map((t, A) => {
676
+ const H = !!(m != null && m.find((P) => P.value === t.value)), w = !!t.description;
661
677
  return /* @__PURE__ */ l(
662
678
  "div",
663
679
  {
664
680
  className: [
665
681
  "sa-input-dropdown-item",
666
682
  w ? "has-description" : "",
667
- $ ? "active" : "",
683
+ H ? "active" : "",
668
684
  A === y ? "highlight" : "",
669
- i.disable ? "sa-input-dropdown-item-disable" : ""
685
+ t.disable ? "sa-input-dropdown-item-disable" : ""
670
686
  ].filter(Boolean).join(" "),
671
687
  ref: (P) => {
672
688
  j.current[A] = P;
673
689
  },
674
- onClick: () => u(i.label, i.value),
690
+ onClick: () => u(t.label, t.value),
675
691
  children: [
676
- R && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-item-check", children: $ && /* @__PURE__ */ n(zn, { width: 16 }) }),
677
- i.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: ln.cloneElement(i.icon, { width: 16 }) }),
692
+ R && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-item-check", children: H && /* @__PURE__ */ n(zn, { width: 16 }) }),
693
+ t.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: ln.cloneElement(t.icon, { width: 16 }) }),
678
694
  /* @__PURE__ */ l("div", { style: { minWidth: 0, flex: 1 }, children: [
679
695
  /* @__PURE__ */ n(
680
696
  "p",
681
697
  {
682
698
  className: [
683
699
  "sa-input-dropdown-item-text",
684
- i.disable ? "sa-input-dropdown-item-disable" : ""
700
+ t.disable ? "sa-input-dropdown-item-disable" : ""
685
701
  ].filter(Boolean).join(" "),
686
- children: i.label
702
+ children: t.label
687
703
  }
688
704
  ),
689
- i.description && /* @__PURE__ */ n(
705
+ t.description && /* @__PURE__ */ n(
690
706
  "p",
691
707
  {
692
708
  className: [
693
709
  "sa-input-dropdown-item-text-description",
694
- i.disable ? "sa-input-dropdown-item-disable" : ""
710
+ t.disable ? "sa-input-dropdown-item-disable" : ""
695
711
  ].filter(Boolean).join(" "),
696
- children: i.description
712
+ children: t.description
697
713
  }
698
714
  )
699
715
  ] })
@@ -705,8 +721,8 @@ const Cn = ({ ...o }) => /* @__PURE__ */ l(
705
721
  ]
706
722
  }
707
723
  ),
708
- o === "top" && T,
709
- F && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (i) => i.stopPropagation(), children: F })
724
+ o === "top" && $,
725
+ F && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (t) => t.stopPropagation(), children: F })
710
726
  ]
711
727
  }
712
728
  ) : null });
@@ -715,26 +731,26 @@ const Cn = ({ ...o }) => /* @__PURE__ */ l(
715
731
  children: o,
716
732
  handleChangePosition: p
717
733
  }) => {
718
- const t = M(null);
719
- x(() => {
734
+ const s = M(null);
735
+ v(() => {
720
736
  var m;
721
- const d = () => {
722
- if (t.current) {
723
- let u = t.current.parentElement;
724
- for (; u && !s(u); )
737
+ const i = () => {
738
+ if (s.current) {
739
+ let u = s.current.parentElement;
740
+ for (; u && !d(u); )
725
741
  u = u.parentElement;
726
742
  u && p();
727
743
  }
728
744
  };
729
- let r = (m = t.current) == null ? void 0 : m.parentElement;
730
- for (; r && !s(r); )
745
+ let r = (m = s.current) == null ? void 0 : m.parentElement;
746
+ for (; r && !d(r); )
731
747
  r = r.parentElement;
732
- return r && r.addEventListener("scroll", d), d(), () => {
733
- r && r.removeEventListener("scroll", d);
748
+ return r && r.addEventListener("scroll", i), i(), () => {
749
+ r && r.removeEventListener("scroll", i);
734
750
  };
735
751
  }, []);
736
- const s = (d) => d && (d.scrollHeight > d.clientHeight || d.scrollWidth > d.clientWidth);
737
- return /* @__PURE__ */ n("div", { ref: t, children: o });
752
+ const d = (i) => i && (i.scrollHeight > i.clientHeight || i.scrollWidth > i.clientWidth);
753
+ return /* @__PURE__ */ n("div", { ref: s, children: o });
738
754
  }, an = "sa-input-dropdown-styles", Bn = (o) => {
739
755
  if (!document.getElementById(an)) {
740
756
  const p = document.createElement("style");
@@ -742,12 +758,12 @@ const Cn = ({ ...o }) => /* @__PURE__ */ l(
742
758
  }
743
759
  };
744
760
  Bn(Nn);
745
- const On = ({
761
+ const In = ({
746
762
  dropdownLists: o,
747
763
  onChange: p,
748
- defaultValue: t,
749
- value: s,
750
- size: d = "md",
764
+ defaultValue: s,
765
+ value: d,
766
+ size: i = "sm",
751
767
  multiSelect: r,
752
768
  searchAble: m,
753
769
  iconLeft: u,
@@ -755,14 +771,14 @@ const On = ({
755
771
  onSearch: L,
756
772
  error: y,
757
773
  onBlur: F,
758
- onFocus: H,
774
+ onFocus: T,
759
775
  disable: N,
760
776
  searchValue: U,
761
777
  variant: j = "outline",
762
- footer: T,
763
- groupLabel: i,
778
+ footer: $,
779
+ groupLabel: t,
764
780
  onSelectAll: A,
765
- fullWidth: $ = !0,
781
+ fullWidth: H = !0,
766
782
  triggerInput: w = !1,
767
783
  clearOnSelect: P = !1,
768
784
  hideChevronIcon: pn = !1,
@@ -779,28 +795,29 @@ const On = ({
779
795
  }) => {
780
796
  const Z = [
781
797
  "sa-select-field",
782
- $ ? "sa-select-field-fullwidth" : ""
783
- ].filter(Boolean).join(" "), E = s !== void 0, Q = M(), un = y || !!h, [c, S] = I(
784
- E ? s || [] : t || []
785
- ), [hn, en] = I(""), [k, X] = I(-1), [fn, q] = I(
798
+ `sa-select-field-size-${i}`,
799
+ H ? "sa-select-field-fullwidth" : ""
800
+ ].filter(Boolean).join(" "), E = d !== void 0, Q = M(), un = y || !!h, [c, S] = W(
801
+ E ? d || [] : s || []
802
+ ), [hn, en] = W(""), [k, X] = W(-1), [fn, q] = W(
786
803
  () => {
787
804
  var e, a;
788
- return !r && (s != null && s.length || t != null && t.length) ? ((e = s == null ? void 0 : s[0]) == null ? void 0 : e.label) ?? ((a = t == null ? void 0 : t[0]) == null ? void 0 : a.label) ?? "" : "";
805
+ return !r && (d != null && d.length || s != null && s.length) ? ((e = d == null ? void 0 : d[0]) == null ? void 0 : e.label) ?? ((a = s == null ? void 0 : s[0]) == null ? void 0 : a.label) ?? "" : "";
789
806
  }
790
- ), g = M(null), { isComponentVisible: f, ref: Y, setIsComponentVisible: C } = En(!1), O = o !== void 0, on = c.length > 0, bn = (e) => {
807
+ ), g = M(null), { isComponentVisible: f, ref: Y, setIsComponentVisible: C } = En(!1), I = o !== void 0, on = c.length > 0, bn = (e) => {
791
808
  e.stopPropagation();
792
809
  const a = [];
793
810
  E || S(a), p(a), w && q(""), K == null || K();
794
811
  }, gn = () => {
795
- O && C((e) => !e);
812
+ I && C((e) => !e);
796
813
  }, G = (e, a) => {
797
814
  if (r) {
798
- if (c == null ? void 0 : c.find((v) => v.value === a)) {
799
- const v = c.filter((kn) => kn.value !== a);
800
- E || S(v), p(v);
815
+ if (c == null ? void 0 : c.find((x) => x.value === a)) {
816
+ const x = c.filter((kn) => kn.value !== a);
817
+ E || S(x), p(x);
801
818
  } else {
802
- const v = [...c, { label: e, value: a }];
803
- E || S(v), p(v);
819
+ const x = [...c, { label: e, value: a }];
820
+ E || S(x), p(x);
804
821
  }
805
822
  w && q("");
806
823
  } else {
@@ -808,15 +825,15 @@ const On = ({
808
825
  E || S(b), p(b), w && q(P ? "" : e), C(!1);
809
826
  }
810
827
  };
811
- x(() => {
812
- E && S(s || []);
813
- }, [s]), x(() => {
814
- E || JSON.stringify(Q.current) === JSON.stringify(t) || (Q.current = t, S(Q.current || []));
815
- }, [t]);
816
- const vn = () => c.length ? r ? c == null ? void 0 : c.map((e, a) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
828
+ v(() => {
829
+ E && S(d || []);
830
+ }, [d]), v(() => {
831
+ E || JSON.stringify(Q.current) === JSON.stringify(s) || (Q.current = s, S(Q.current || []));
832
+ }, [s]);
833
+ const xn = () => c.length ? r ? c == null ? void 0 : c.map((e, a) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
817
834
  /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
818
835
  /* @__PURE__ */ n(
819
- dn,
836
+ sn,
820
837
  {
821
838
  onClick: (b) => {
822
839
  b.stopPropagation(), G(e.label, e.value);
@@ -825,26 +842,26 @@ const On = ({
825
842
  )
826
843
  ] }, a)) : /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: c == null ? void 0 : c[0].label }) : /* @__PURE__ */ n("p", { className: "sa-input-dropdown-placeholder", children: R }), z = () => {
827
844
  if (Y.current && g.current) {
828
- const e = window.innerHeight, a = Y.current.getBoundingClientRect(), b = g.current.getBoundingClientRect(), v = a.bottom + b.height;
829
- g.current.style.left = `${a.left}px`, g.current.style.width = `${a.width}px`, v >= e - 10 ? (g.current.style.top = `${a.top - b.height - 5}px`, en("top")) : (g.current.style.top = `${a.top + a.height + 4}px`, en("bottom"));
845
+ const e = window.innerHeight, a = Y.current.getBoundingClientRect(), b = g.current.getBoundingClientRect(), x = a.bottom + b.height;
846
+ g.current.style.left = `${a.left}px`, g.current.style.width = `${a.width}px`, x >= e - 10 ? (g.current.style.top = `${a.top - b.height - 5}px`, en("top")) : (g.current.style.top = `${a.top + a.height + 4}px`, en("bottom"));
830
847
  }
831
848
  };
832
- x(() => (window.addEventListener("scroll", z), window.addEventListener("resize", z), () => {
849
+ v(() => (window.addEventListener("scroll", z), window.addEventListener("resize", z), () => {
833
850
  window.removeEventListener("scroll", z), window.removeEventListener("resize", z);
834
- }), []), x(() => {
851
+ }), []), v(() => {
835
852
  z();
836
- }, [f]), x(() => {
853
+ }, [f]), v(() => {
837
854
  if (!f || !g.current)
838
855
  return;
839
856
  const e = new ResizeObserver(() => {
840
857
  z();
841
858
  });
842
859
  return e.observe(g.current), () => e.disconnect();
843
- }, [f]), x(() => {
860
+ }, [f]), v(() => {
844
861
  f || X(-1);
845
862
  }, [f]);
846
863
  const rn = (e) => {
847
- if (O) {
864
+ if (I) {
848
865
  if (!f) {
849
866
  (e.key === "ArrowDown" || e.key === "Enter") && (e.preventDefault(), C(!0));
850
867
  return;
@@ -874,7 +891,7 @@ const On = ({
874
891
  break;
875
892
  }
876
893
  }
877
- }, W = d === "lg" || d === "xl" ? 20 : 16, xn = cn && !N ? /* @__PURE__ */ n(
894
+ }, O = i === "lg" || i === "xl" ? 20 : i === "xs" ? 14 : 16, vn = cn && !N ? /* @__PURE__ */ n(
878
895
  "button",
879
896
  {
880
897
  type: "button",
@@ -884,13 +901,13 @@ const On = ({
884
901
  tabIndex: -1,
885
902
  onClick: bn,
886
903
  onMouseDown: (e) => e.preventDefault(),
887
- children: /* @__PURE__ */ n(Dn, { width: W, height: W })
904
+ children: /* @__PURE__ */ n(Dn, { width: O, height: O })
888
905
  }
889
- ) : null, mn = w ? /* @__PURE__ */ l(sn, { children: [
906
+ ) : null, mn = w ? /* @__PURE__ */ l(dn, { children: [
890
907
  r && c.map((e, a) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
891
908
  /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
892
909
  /* @__PURE__ */ n(
893
- dn,
910
+ sn,
894
911
  {
895
912
  onClick: (b) => {
896
913
  b.stopPropagation(), G(e.label, e.value);
@@ -905,10 +922,10 @@ const On = ({
905
922
  value: fn,
906
923
  onChange: (e) => {
907
924
  const a = e.target.value;
908
- q(a), L == null || L(a), !f && O && C(!0);
925
+ q(a), L == null || L(a), !f && I && C(!0);
909
926
  },
910
927
  onFocus: () => {
911
- !N && O && C(!0);
928
+ !N && I && C(!0);
912
929
  },
913
930
  onBlur: () => {
914
931
  r || setTimeout(() => C(!1), 150);
@@ -924,7 +941,7 @@ const On = ({
924
941
  className: [
925
942
  "sa-input-dropdown-container",
926
943
  j,
927
- `sa-input-dropdown-size-${d}`,
944
+ `sa-input-dropdown-size-${i}`,
928
945
  w ? "trigger-input" : "",
929
946
  f ? "active" : "",
930
947
  un ? "error" : "",
@@ -935,18 +952,18 @@ const On = ({
935
952
  onKeyDown: w ? void 0 : rn,
936
953
  tabIndex: w ? void 0 : 0,
937
954
  onBlur: w ? void 0 : F,
938
- onFocus: w ? void 0 : H,
955
+ onFocus: w ? void 0 : T,
939
956
  children: [
940
957
  /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-container", children: [
941
958
  u ? ln.cloneElement(u, {
942
- width: W,
959
+ width: O,
943
960
  style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 }
944
961
  }) : null,
945
- /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: w ? mn : vn() }),
946
- xn,
947
- !pn && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-chevron", children: f ? /* @__PURE__ */ n(jn, { width: W }) : /* @__PURE__ */ n(Sn, { width: W }) })
962
+ /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: w ? mn : xn() }),
963
+ vn,
964
+ !pn && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-chevron", children: f ? /* @__PURE__ */ n(jn, { width: O }) : /* @__PURE__ */ n(Sn, { width: O }) })
948
965
  ] }),
949
- O && /* @__PURE__ */ n(
966
+ I && /* @__PURE__ */ n(
950
967
  Rn,
951
968
  {
952
969
  dropdownLists: o,
@@ -961,8 +978,8 @@ const On = ({
961
978
  multiSelect: r,
962
979
  searchValue: U,
963
980
  highlightedIndex: k,
964
- footer: T,
965
- groupLabel: i,
981
+ footer: $,
982
+ groupLabel: t,
966
983
  onSelectAll: A
967
984
  }
968
985
  )
@@ -999,27 +1016,27 @@ const On = ({
999
1016
  D && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: D }),
1000
1017
  h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
1001
1018
  ] });
1002
- }, tn = (o, p, t) => {
1003
- const s = o.length;
1004
- let d = p + t;
1005
- for (; d >= 0 && d < s; ) {
1006
- if (!o[d].disable)
1007
- return d;
1008
- d += t;
1019
+ }, tn = (o, p, s) => {
1020
+ const d = o.length;
1021
+ let i = p + s;
1022
+ for (; i >= 0 && i < d; ) {
1023
+ if (!o[i].disable)
1024
+ return i;
1025
+ i += s;
1009
1026
  }
1010
- if (t === 1) {
1011
- for (let r = 0; r < s; r++)
1027
+ if (s === 1) {
1028
+ for (let r = 0; r < d; r++)
1012
1029
  if (!o[r].disable)
1013
1030
  return r;
1014
1031
  } else
1015
- for (let r = s - 1; r >= 0; r--)
1032
+ for (let r = d - 1; r >= 0; r--)
1016
1033
  if (!o[r].disable)
1017
1034
  return r;
1018
1035
  return -1;
1019
1036
  }, Dn = (o) => /* @__PURE__ */ l("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o, children: [
1020
1037
  /* @__PURE__ */ n("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor", opacity: "0.2" }),
1021
1038
  /* @__PURE__ */ n("path", { d: "M5.5 5.5l5 5M10.5 5.5l-5 5", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" })
1022
- ] }), dn = (o) => /* @__PURE__ */ n(
1039
+ ] }), sn = (o) => /* @__PURE__ */ n(
1023
1040
  "svg",
1024
1041
  {
1025
1042
  xmlns: "http://www.w3.org/2000/svg",
@@ -1082,5 +1099,5 @@ const On = ({
1082
1099
  }
1083
1100
  );
1084
1101
  export {
1085
- On as Dropdown
1102
+ In as Dropdown
1086
1103
  };
@@ -1,4 +1,4 @@
1
- (function(x,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(x=typeof globalThis<"u"?globalThis:x||self,n(x.Dropdown={},x.jsxRuntime,x.React))})(this,function(x,n,l){"use strict";const sn=`@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
1
+ (function(v,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(v=typeof globalThis<"u"?globalThis:v||self,n(v.Dropdown={},v.jsxRuntime,v.React))})(this,function(v,n,l){"use strict";const sn=`@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
2
2
  * {
3
3
  margin: 0;
4
4
  padding: 0;
@@ -35,6 +35,15 @@
35
35
  }
36
36
 
37
37
  /* === SIZE VARIANTS === */
38
+ .sa-input-dropdown-size-xs {
39
+ --baseFont: 12px;
40
+ --height: 28px;
41
+ --borderRadius: var(--sa-dropdown-radius);
42
+ --paddingInline: 8px;
43
+ --paddingBlock: 2px;
44
+ --iconSize: 14px;
45
+ --iconMarginTop: 4px;
46
+ }
38
47
  .sa-input-dropdown-size-sm {
39
48
  --baseFont: 12px;
40
49
  --height: 32px;
@@ -350,6 +359,7 @@
350
359
  min-height: 32px;
351
360
  font-size: 12px;
352
361
  }
362
+ .sa-input-dropdown-size-xs .sa-input-dropdown-item,
353
363
  .sa-input-dropdown-size-sm .sa-input-dropdown-item,
354
364
  .sa-input-dropdown-size-md .sa-input-dropdown-item {
355
365
  font-size: 12px;
@@ -449,17 +459,19 @@
449
459
  .sa-select-field-label-row {
450
460
  display: flex;
451
461
  align-items: center;
452
- gap: 6px;
462
+ gap: 4px;
453
463
  flex-wrap: wrap;
454
464
  }
455
465
  .sa-select-field-label-text {
456
466
  font-size: 14px;
457
467
  font-weight: 500;
458
468
  color: var(--sa-dropdown-text-primary);
459
- line-height: 1.3;
469
+ line-height: normal;
460
470
  }
461
- .sa-select-field-left .sa-select-field-label-text {
462
- font-size: 14px;
471
+ /* match Input: xs/sm label drops to 12px */
472
+ .sa-select-field-size-xs .sa-select-field-label-text,
473
+ .sa-select-field-size-sm .sa-select-field-label-text {
474
+ font-size: 12px;
463
475
  }
464
476
  .sa-select-field-required {
465
477
  font-size: 14px;
@@ -467,6 +479,10 @@
467
479
  color: var(--sa-dropdown-text-error);
468
480
  line-height: 1;
469
481
  }
482
+ .sa-select-field-size-xs .sa-select-field-required,
483
+ .sa-select-field-size-sm .sa-select-field-required {
484
+ font-size: 12px;
485
+ }
470
486
  .sa-select-field-optional-badge {
471
487
  display: inline-flex;
472
488
  align-items: center;
@@ -532,4 +548,4 @@
532
548
  display: none;
533
549
  }
534
550
 
535
- `;function dn(o){const[p,i]=l.useState(o),t=l.useRef(null),d=r=>{t.current&&!t.current.contains(r.target)&&i(!1)};return l.useEffect(()=>(document.addEventListener("click",d,!0),()=>{document.removeEventListener("click",d,!0)}),[]),{ref:t,isComponentVisible:p,setIsComponentVisible:i}}const tn=({...o})=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",...o,viewBox:"0 0 20 20",fill:"none",children:[n.jsx("circle",{cx:"9.80547",cy:"9.8055",r:"7.49047",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M15.0153 15.4043L17.9519 18.3333",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),ln=({width:o=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 16 16",fill:"none",children:n.jsx("path",{d:"M3.5 8L6.5 11L12.5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),pn=l.forwardRef(({positionDropdown:o,dropdownLists:p,isComponentVisible:i,searchAble:t,hideSearch:d,onSearch:r,value:k,handleChangeValue:h,multiSelect:L,searchValue:B,highlightedIndex:m,footer:I,groupLabel:F,onSelectAll:N},G)=>{const P=l.useRef([]);l.useEffect(()=>{var s;m>=0&&P.current[m]&&((s=P.current[m])==null||s.scrollIntoView({block:"nearest"}))},[m]);const T=t&&!d?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(tn,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:s=>{r&&r(s.target.value)},value:B,autoFocus:!0,placeholder:"Search..."})]}):null;return n.jsx(n.Fragment,{children:i?n.jsxs("div",{className:"sa-input-dropdown-lists-container",onClick:s=>s.stopPropagation(),ref:G,children:[o!=="top"&&T,n.jsxs("div",{className:`sa-input-dropdown-item-container ${L?"multi":""}`,children:[F&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:F}),L&&N&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:s=>{s.stopPropagation(),N()},children:"Select all"})]}),p.map((s,A)=>{const H=!!(k!=null&&k.find(O=>O.value===s.value)),w=!!s.description;return n.jsxs("div",{className:["sa-input-dropdown-item",w?"has-description":"",H?"active":"",A===m?"highlight":"",s.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),ref:O=>{P.current[A]=O},onClick:()=>h(s.label,s.value),children:[L&&n.jsx("div",{className:"sa-input-dropdown-item-check",children:H&&n.jsx(ln,{width:16})}),s.icon&&n.jsx("div",{style:{flexShrink:0,display:"flex"},children:l.cloneElement(s.icon,{width:16})}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsx("p",{className:["sa-input-dropdown-item-text",s.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:s.label}),s.description&&n.jsx("p",{className:["sa-input-dropdown-item-text-description",s.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:s.description})]})]},A)})]}),o==="top"&&T,I&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:s=>s.stopPropagation(),children:I})]}):null})}),cn=({children:o,handleChangePosition:p})=>{const i=l.useRef(null);l.useEffect(()=>{var k;const d=()=>{if(i.current){let h=i.current.parentElement;for(;h&&!t(h);)h=h.parentElement;h&&p()}};let r=(k=i.current)==null?void 0:k.parentElement;for(;r&&!t(r);)r=r.parentElement;return r&&r.addEventListener("scroll",d),d(),()=>{r&&r.removeEventListener("scroll",d)}},[]);const t=d=>d&&(d.scrollHeight>d.clientHeight||d.scrollWidth>d.clientWidth);return n.jsx("div",{ref:i,children:o})},_="sa-input-dropdown-styles";(o=>{if(!document.getElementById(_)){const p=document.createElement("style");p.id=_,p.textContent=o,document.head.appendChild(p)}})(sn);const wn=({dropdownLists:o,onChange:p,defaultValue:i,value:t,size:d="md",multiSelect:r,searchAble:k,iconLeft:h,placeholder:L,onSearch:B,error:m,onBlur:I,onFocus:F,disable:N,searchValue:G,variant:P="outline",footer:T,groupLabel:s,onSelectAll:A,fullWidth:H=!0,triggerInput:w=!1,clearOnSelect:O=!1,hideChevronIcon:bn=!1,clearable:gn=!1,onClear:U,label:K,labelPosition:vn="outside-top",required:nn,optional:en,description:S,helperText:D,errorText:f})=>{const J=["sa-select-field",H?"sa-select-field-fullwidth":""].filter(Boolean).join(" "),E=t!==void 0,Z=l.useRef(),xn=m||!!f,[c,j]=l.useState(E?t||[]:i||[]),[kn,on]=l.useState(""),[y,Q]=l.useState(-1),[yn,$]=l.useState(()=>{var e,a;return!r&&(t!=null&&t.length||i!=null&&i.length)?((e=t==null?void 0:t[0])==null?void 0:e.label)??((a=i==null?void 0:i[0])==null?void 0:a.label)??"":""}),g=l.useRef(null),{isComponentVisible:u,ref:X,setIsComponentVisible:C}=dn(!1),W=o!==void 0,rn=c.length>0,mn=e=>{e.stopPropagation();const a=[];E||j(a),p(a),w&&$(""),U==null||U()},Nn=()=>{W&&C(e=>!e)},q=(e,a)=>{if(r){if(c==null?void 0:c.find(v=>v.value===a)){const v=c.filter(Ln=>Ln.value!==a);E||j(v),p(v)}else{const v=[...c,{label:e,value:a}];E||j(v),p(v)}w&&$("")}else{const b=[{label:e,value:a}];E||j(b),p(b),w&&$(O?"":e),C(!1)}};l.useEffect(()=>{E&&j(t||[])},[t]),l.useEffect(()=>{E||JSON.stringify(Z.current)===JSON.stringify(i)||(Z.current=i,j(Z.current||[]))},[i]);const En=()=>c.length?r?c==null?void 0:c.map((e,a)=>n.jsxs("div",{className:"sa-input-dropdown-preview-item",children:[n.jsx("p",{style:{minWidth:"max-content"},children:e==null?void 0:e.label}),n.jsx(R,{onClick:b=>{b.stopPropagation(),q(e.label,e.value)}})]},a)):n.jsx("p",{style:{minWidth:"max-content"},children:c==null?void 0:c[0].label}):n.jsx("p",{className:"sa-input-dropdown-placeholder",children:L}),z=()=>{if(X.current&&g.current){const e=window.innerHeight,a=X.current.getBoundingClientRect(),b=g.current.getBoundingClientRect(),v=a.bottom+b.height;g.current.style.left=`${a.left}px`,g.current.style.width=`${a.width}px`,v>=e-10?(g.current.style.top=`${a.top-b.height-5}px`,on("top")):(g.current.style.top=`${a.top+a.height+4}px`,on("bottom"))}};l.useEffect(()=>(window.addEventListener("scroll",z),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z),window.removeEventListener("resize",z)}),[]),l.useEffect(()=>{z()},[u]),l.useEffect(()=>{if(!u||!g.current)return;const e=new ResizeObserver(()=>{z()});return e.observe(g.current),()=>e.disconnect()},[u]),l.useEffect(()=>{u||Q(-1)},[u]);const an=e=>{if(W){if(!u){(e.key==="ArrowDown"||e.key==="Enter")&&(e.preventDefault(),C(!0));return}switch(e.key){case"ArrowDown":{e.preventDefault();const a=V(o,y,1);a!==-1&&Q(a);break}case"ArrowUp":{e.preventDefault();const a=V(o,y,-1);a!==-1&&Q(a);break}case"Enter":{e.preventDefault(),y>=0&&o[y]&&!o[y].disable&&q(o[y].label,o[y].value);break}case"Escape":C(!1);break}}},M=d==="lg"||d==="xl"?20:16,Cn=gn&&!N?n.jsx("button",{type:"button",className:`sa-input-dropdown-clear${rn?"":" sa-input-dropdown-clear-hidden"}`,"aria-label":"Clear selection","aria-hidden":!rn,tabIndex:-1,onClick:mn,onMouseDown:e=>e.preventDefault(),children:n.jsx(hn,{width:M,height:M})}):null,zn=w?n.jsxs(n.Fragment,{children:[r&&c.map((e,a)=>n.jsxs("div",{className:"sa-input-dropdown-preview-item",children:[n.jsx("p",{style:{minWidth:"max-content"},children:e==null?void 0:e.label}),n.jsx(R,{onClick:b=>{b.stopPropagation(),q(e.label,e.value)}})]},a)),n.jsx("input",{className:"sa-input-dropdown-trigger-input",value:yn,onChange:e=>{const a=e.target.value;$(a),B==null||B(a),!u&&W&&C(!0)},onFocus:()=>{!N&&W&&C(!0)},onBlur:()=>{r||setTimeout(()=>C(!1),150)},onKeyDown:an,placeholder:c.length===0||r?L:void 0,disabled:N})]}):null,Y=n.jsx(cn,{handleChangePosition:z,children:n.jsxs("div",{className:["sa-input-dropdown-container",P,`sa-input-dropdown-size-${d}`,w?"trigger-input":"",u?"active":"",xn?"error":"",N?"disable":""].filter(Boolean).join(" "),ref:X,onClick:w?void 0:Nn,onKeyDown:w?void 0:an,tabIndex:w?void 0:0,onBlur:w?void 0:I,onFocus:w?void 0:F,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[h?l.cloneElement(h,{width:M,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:w?zn:En()}),Cn,!bn&&n.jsx("div",{className:"sa-input-dropdown-chevron",children:u?n.jsx(un,{width:M}):n.jsx(fn,{width:M})})]}),W&&n.jsx(pn,{dropdownLists:o,handleChangeValue:q,isComponentVisible:u,positionDropdown:kn,searchAble:!!k,hideSearch:w,value:c,onSearch:B,ref:g,multiSelect:r,searchValue:G,highlightedIndex:y,footer:T,groupLabel:s,onSelectAll:A})]})});return K?vn==="outside-left"?n.jsxs("div",{className:`${J} sa-select-field-left`,children:[n.jsxs("div",{className:"sa-select-field-left-label",children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:K}),en&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),nn&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S})]}),n.jsxs("div",{className:"sa-select-field-input-wrap",children:[Y,D&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:D}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]})]}):n.jsxs("div",{className:J,children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:K}),en&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),nn&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S}),Y,D&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:D}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]}):n.jsxs("div",{className:J,children:[S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S}),Y,D&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:D}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]})},V=(o,p,i)=>{const t=o.length;let d=p+i;for(;d>=0&&d<t;){if(!o[d].disable)return d;d+=i}if(i===1){for(let r=0;r<t;r++)if(!o[r].disable)return r}else for(let r=t-1;r>=0;r--)if(!o[r].disable)return r;return-1},hn=o=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o,children:[n.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"currentColor",opacity:"0.2"}),n.jsx("path",{d:"M5.5 5.5l5 5M10.5 5.5l-5 5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]}),R=o=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 18 18",fill:"none",style:{flexShrink:0,cursor:"pointer"},...o,children:n.jsx("path",{d:"M12 6L6 12M6.00001 6L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),fn=({width:o=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 16 16",fill:"none",style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0},children:n.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),un=({width:o=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 16 16",fill:"none",style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0},children:n.jsx("path",{d:"M4 10L8 6L12 10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});x.Dropdown=wn,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
551
+ `;function dn(o){const[p,d]=l.useState(o),t=l.useRef(null),s=r=>{t.current&&!t.current.contains(r.target)&&d(!1)};return l.useEffect(()=>(document.addEventListener("click",s,!0),()=>{document.removeEventListener("click",s,!0)}),[]),{ref:t,isComponentVisible:p,setIsComponentVisible:d}}const tn=({...o})=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",...o,viewBox:"0 0 20 20",fill:"none",children:[n.jsx("circle",{cx:"9.80547",cy:"9.8055",r:"7.49047",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M15.0153 15.4043L17.9519 18.3333",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),ln=({width:o=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 16 16",fill:"none",children:n.jsx("path",{d:"M3.5 8L6.5 11L12.5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),pn=l.forwardRef(({positionDropdown:o,dropdownLists:p,isComponentVisible:d,searchAble:t,hideSearch:s,onSearch:r,value:k,handleChangeValue:h,multiSelect:L,searchValue:B,highlightedIndex:y,footer:W,groupLabel:F,onSelectAll:N},G)=>{const P=l.useRef([]);l.useEffect(()=>{var i;y>=0&&P.current[y]&&((i=P.current[y])==null||i.scrollIntoView({block:"nearest"}))},[y]);const T=t&&!s?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(tn,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:i=>{r&&r(i.target.value)},value:B,autoFocus:!0,placeholder:"Search..."})]}):null;return n.jsx(n.Fragment,{children:d?n.jsxs("div",{className:"sa-input-dropdown-lists-container",onClick:i=>i.stopPropagation(),ref:G,children:[o!=="top"&&T,n.jsxs("div",{className:`sa-input-dropdown-item-container ${L?"multi":""}`,children:[F&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:F}),L&&N&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:i=>{i.stopPropagation(),N()},children:"Select all"})]}),p.map((i,A)=>{const $=!!(k!=null&&k.find(O=>O.value===i.value)),w=!!i.description;return n.jsxs("div",{className:["sa-input-dropdown-item",w?"has-description":"",$?"active":"",A===y?"highlight":"",i.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),ref:O=>{P.current[A]=O},onClick:()=>h(i.label,i.value),children:[L&&n.jsx("div",{className:"sa-input-dropdown-item-check",children:$&&n.jsx(ln,{width:16})}),i.icon&&n.jsx("div",{style:{flexShrink:0,display:"flex"},children:l.cloneElement(i.icon,{width:16})}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsx("p",{className:["sa-input-dropdown-item-text",i.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:i.label}),i.description&&n.jsx("p",{className:["sa-input-dropdown-item-text-description",i.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:i.description})]})]},A)})]}),o==="top"&&T,W&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:i=>i.stopPropagation(),children:W})]}):null})}),cn=({children:o,handleChangePosition:p})=>{const d=l.useRef(null);l.useEffect(()=>{var k;const s=()=>{if(d.current){let h=d.current.parentElement;for(;h&&!t(h);)h=h.parentElement;h&&p()}};let r=(k=d.current)==null?void 0:k.parentElement;for(;r&&!t(r);)r=r.parentElement;return r&&r.addEventListener("scroll",s),s(),()=>{r&&r.removeEventListener("scroll",s)}},[]);const t=s=>s&&(s.scrollHeight>s.clientHeight||s.scrollWidth>s.clientWidth);return n.jsx("div",{ref:d,children:o})},_="sa-input-dropdown-styles";(o=>{if(!document.getElementById(_)){const p=document.createElement("style");p.id=_,p.textContent=o,document.head.appendChild(p)}})(sn);const wn=({dropdownLists:o,onChange:p,defaultValue:d,value:t,size:s="sm",multiSelect:r,searchAble:k,iconLeft:h,placeholder:L,onSearch:B,error:y,onBlur:W,onFocus:F,disable:N,searchValue:G,variant:P="outline",footer:T,groupLabel:i,onSelectAll:A,fullWidth:$=!0,triggerInput:w=!1,clearOnSelect:O=!1,hideChevronIcon:bn=!1,clearable:gn=!1,onClear:U,label:K,labelPosition:xn="outside-top",required:nn,optional:en,description:S,helperText:D,errorText:f})=>{const J=["sa-select-field",`sa-select-field-size-${s}`,$?"sa-select-field-fullwidth":""].filter(Boolean).join(" "),E=t!==void 0,Z=l.useRef(),vn=y||!!f,[c,j]=l.useState(E?t||[]:d||[]),[kn,on]=l.useState(""),[m,Q]=l.useState(-1),[mn,q]=l.useState(()=>{var e,a;return!r&&(t!=null&&t.length||d!=null&&d.length)?((e=t==null?void 0:t[0])==null?void 0:e.label)??((a=d==null?void 0:d[0])==null?void 0:a.label)??"":""}),g=l.useRef(null),{isComponentVisible:u,ref:X,setIsComponentVisible:C}=dn(!1),I=o!==void 0,rn=c.length>0,yn=e=>{e.stopPropagation();const a=[];E||j(a),p(a),w&&q(""),U==null||U()},Nn=()=>{I&&C(e=>!e)},H=(e,a)=>{if(r){if(c==null?void 0:c.find(x=>x.value===a)){const x=c.filter(Ln=>Ln.value!==a);E||j(x),p(x)}else{const x=[...c,{label:e,value:a}];E||j(x),p(x)}w&&q("")}else{const b=[{label:e,value:a}];E||j(b),p(b),w&&q(O?"":e),C(!1)}};l.useEffect(()=>{E&&j(t||[])},[t]),l.useEffect(()=>{E||JSON.stringify(Z.current)===JSON.stringify(d)||(Z.current=d,j(Z.current||[]))},[d]);const En=()=>c.length?r?c==null?void 0:c.map((e,a)=>n.jsxs("div",{className:"sa-input-dropdown-preview-item",children:[n.jsx("p",{style:{minWidth:"max-content"},children:e==null?void 0:e.label}),n.jsx(R,{onClick:b=>{b.stopPropagation(),H(e.label,e.value)}})]},a)):n.jsx("p",{style:{minWidth:"max-content"},children:c==null?void 0:c[0].label}):n.jsx("p",{className:"sa-input-dropdown-placeholder",children:L}),z=()=>{if(X.current&&g.current){const e=window.innerHeight,a=X.current.getBoundingClientRect(),b=g.current.getBoundingClientRect(),x=a.bottom+b.height;g.current.style.left=`${a.left}px`,g.current.style.width=`${a.width}px`,x>=e-10?(g.current.style.top=`${a.top-b.height-5}px`,on("top")):(g.current.style.top=`${a.top+a.height+4}px`,on("bottom"))}};l.useEffect(()=>(window.addEventListener("scroll",z),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z),window.removeEventListener("resize",z)}),[]),l.useEffect(()=>{z()},[u]),l.useEffect(()=>{if(!u||!g.current)return;const e=new ResizeObserver(()=>{z()});return e.observe(g.current),()=>e.disconnect()},[u]),l.useEffect(()=>{u||Q(-1)},[u]);const an=e=>{if(I){if(!u){(e.key==="ArrowDown"||e.key==="Enter")&&(e.preventDefault(),C(!0));return}switch(e.key){case"ArrowDown":{e.preventDefault();const a=V(o,m,1);a!==-1&&Q(a);break}case"ArrowUp":{e.preventDefault();const a=V(o,m,-1);a!==-1&&Q(a);break}case"Enter":{e.preventDefault(),m>=0&&o[m]&&!o[m].disable&&H(o[m].label,o[m].value);break}case"Escape":C(!1);break}}},M=s==="lg"||s==="xl"?20:s==="xs"?14:16,Cn=gn&&!N?n.jsx("button",{type:"button",className:`sa-input-dropdown-clear${rn?"":" sa-input-dropdown-clear-hidden"}`,"aria-label":"Clear selection","aria-hidden":!rn,tabIndex:-1,onClick:yn,onMouseDown:e=>e.preventDefault(),children:n.jsx(hn,{width:M,height:M})}):null,zn=w?n.jsxs(n.Fragment,{children:[r&&c.map((e,a)=>n.jsxs("div",{className:"sa-input-dropdown-preview-item",children:[n.jsx("p",{style:{minWidth:"max-content"},children:e==null?void 0:e.label}),n.jsx(R,{onClick:b=>{b.stopPropagation(),H(e.label,e.value)}})]},a)),n.jsx("input",{className:"sa-input-dropdown-trigger-input",value:mn,onChange:e=>{const a=e.target.value;q(a),B==null||B(a),!u&&I&&C(!0)},onFocus:()=>{!N&&I&&C(!0)},onBlur:()=>{r||setTimeout(()=>C(!1),150)},onKeyDown:an,placeholder:c.length===0||r?L:void 0,disabled:N})]}):null,Y=n.jsx(cn,{handleChangePosition:z,children:n.jsxs("div",{className:["sa-input-dropdown-container",P,`sa-input-dropdown-size-${s}`,w?"trigger-input":"",u?"active":"",vn?"error":"",N?"disable":""].filter(Boolean).join(" "),ref:X,onClick:w?void 0:Nn,onKeyDown:w?void 0:an,tabIndex:w?void 0:0,onBlur:w?void 0:W,onFocus:w?void 0:F,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[h?l.cloneElement(h,{width:M,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:w?zn:En()}),Cn,!bn&&n.jsx("div",{className:"sa-input-dropdown-chevron",children:u?n.jsx(un,{width:M}):n.jsx(fn,{width:M})})]}),I&&n.jsx(pn,{dropdownLists:o,handleChangeValue:H,isComponentVisible:u,positionDropdown:kn,searchAble:!!k,hideSearch:w,value:c,onSearch:B,ref:g,multiSelect:r,searchValue:G,highlightedIndex:m,footer:T,groupLabel:i,onSelectAll:A})]})});return K?xn==="outside-left"?n.jsxs("div",{className:`${J} sa-select-field-left`,children:[n.jsxs("div",{className:"sa-select-field-left-label",children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:K}),en&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),nn&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S})]}),n.jsxs("div",{className:"sa-select-field-input-wrap",children:[Y,D&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:D}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]})]}):n.jsxs("div",{className:J,children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:K}),en&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),nn&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S}),Y,D&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:D}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]}):n.jsxs("div",{className:J,children:[S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S}),Y,D&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:D}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]})},V=(o,p,d)=>{const t=o.length;let s=p+d;for(;s>=0&&s<t;){if(!o[s].disable)return s;s+=d}if(d===1){for(let r=0;r<t;r++)if(!o[r].disable)return r}else for(let r=t-1;r>=0;r--)if(!o[r].disable)return r;return-1},hn=o=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o,children:[n.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"currentColor",opacity:"0.2"}),n.jsx("path",{d:"M5.5 5.5l5 5M10.5 5.5l-5 5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]}),R=o=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 18 18",fill:"none",style:{flexShrink:0,cursor:"pointer"},...o,children:n.jsx("path",{d:"M12 6L6 12M6.00001 6L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),fn=({width:o=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 16 16",fill:"none",style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0},children:n.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),un=({width:o=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 16 16",fill:"none",style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0},children:n.jsx("path",{d:"M4 10L8 6L12 10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});v.Dropdown=wn,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  export interface IconPropsDropdown extends React.SVGProps<SVGSVGElement> {
3
3
  }
4
- export type DropdownSize = "sm" | "md" | "lg" | "xl";
4
+ export type DropdownSize = "xs" | "sm" | "md" | "lg" | "xl";
5
5
  export type DropdownVariant = "standard" | "outline" | "flushed";
6
6
  export type DropdownLabelPosition = "outside-top" | "outside-left";
7
7
  export interface IDropdown {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/dropdown",
3
- "version": "5.4.0",
3
+ "version": "5.5.1",
4
4
  "description": "dropdown component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/dropdown.umd.js",