@starasia/dropdown 5.2.1 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { jsxs as l, jsx as n, Fragment as an } from "react/jsx-runtime";
2
- import tn, { useState as P, useRef as W, useEffect as x, forwardRef as fn } from "react";
3
- const bn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
1
+ import { jsxs as l, jsx as n, Fragment as tn } from "react/jsx-runtime";
2
+ import dn, { useState as W, useRef as I, useEffect as x, forwardRef as gn } from "react";
3
+ const vn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
4
4
  * {
5
5
  margin: 0;
6
6
  padding: 0;
@@ -486,15 +486,15 @@ const bn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
486
486
  }
487
487
 
488
488
  `;
489
- function gn(o) {
490
- const [p, t] = P(o), s = W(null), d = (r) => {
489
+ function xn(o) {
490
+ const [p, t] = W(o), s = I(null), d = (r) => {
491
491
  s.current && !s.current.contains(r.target) && t(!1);
492
492
  };
493
493
  return x(() => (document.addEventListener("click", d, !0), () => {
494
494
  document.removeEventListener("click", d, !0);
495
495
  }), []), { ref: s, isComponentVisible: p, setIsComponentVisible: t };
496
496
  }
497
- const vn = ({ ...o }) => /* @__PURE__ */ l(
497
+ const mn = ({ ...o }) => /* @__PURE__ */ l(
498
498
  "svg",
499
499
  {
500
500
  xmlns: "http://www.w3.org/2000/svg",
@@ -526,7 +526,7 @@ const vn = ({ ...o }) => /* @__PURE__ */ l(
526
526
  )
527
527
  ]
528
528
  }
529
- ), xn = ({ width: o = 16 }) => /* @__PURE__ */ n(
529
+ ), kn = ({ width: o = 16 }) => /* @__PURE__ */ n(
530
530
  "svg",
531
531
  {
532
532
  xmlns: "http://www.w3.org/2000/svg",
@@ -545,7 +545,7 @@ const vn = ({ ...o }) => /* @__PURE__ */ l(
545
545
  }
546
546
  )
547
547
  }
548
- ), mn = fn(
548
+ ), yn = gn(
549
549
  ({
550
550
  positionDropdown: o,
551
551
  dropdownLists: p,
@@ -558,17 +558,17 @@ const vn = ({ ...o }) => /* @__PURE__ */ l(
558
558
  multiSelect: C,
559
559
  searchValue: z,
560
560
  highlightedIndex: y,
561
- footer: I,
562
- groupLabel: F,
561
+ footer: F,
562
+ groupLabel: H,
563
563
  onSelectAll: R
564
- }, q) => {
565
- const D = W([]);
564
+ }, G) => {
565
+ const S = I([]);
566
566
  x(() => {
567
567
  var a;
568
- y >= 0 && D.current[y] && ((a = D.current[y]) == null || a.scrollIntoView({ block: "nearest" }));
568
+ y >= 0 && S.current[y] && ((a = S.current[y]) == null || a.scrollIntoView({ block: "nearest" }));
569
569
  }, [y]);
570
- const H = s && !d ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
571
- /* @__PURE__ */ n(vn, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
570
+ const M = s && !d ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
571
+ /* @__PURE__ */ n(mn, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
572
572
  /* @__PURE__ */ n(
573
573
  "input",
574
574
  {
@@ -581,21 +581,21 @@ const vn = ({ ...o }) => /* @__PURE__ */ l(
581
581
  }
582
582
  )
583
583
  ] }) : null;
584
- return /* @__PURE__ */ n(an, { children: t ? /* @__PURE__ */ l(
584
+ return /* @__PURE__ */ n(tn, { children: t ? /* @__PURE__ */ l(
585
585
  "div",
586
586
  {
587
587
  className: "sa-input-dropdown-lists-container",
588
588
  onClick: (a) => a.stopPropagation(),
589
- ref: q,
589
+ ref: G,
590
590
  children: [
591
- o !== "top" && H,
591
+ o !== "top" && M,
592
592
  /* @__PURE__ */ l(
593
593
  "div",
594
594
  {
595
595
  className: `sa-input-dropdown-item-container ${C ? "multi" : ""}`,
596
596
  children: [
597
- F && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
598
- /* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: F }),
597
+ H && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
598
+ /* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: H }),
599
599
  C && R && /* @__PURE__ */ n(
600
600
  "button",
601
601
  {
@@ -608,24 +608,24 @@ const vn = ({ ...o }) => /* @__PURE__ */ l(
608
608
  )
609
609
  ] }),
610
610
  p.map((a, A) => {
611
- const M = !!(m != null && m.find((j) => j.value === a.value)), w = !!a.description;
611
+ const $ = !!(m != null && m.find((P) => P.value === a.value)), w = !!a.description;
612
612
  return /* @__PURE__ */ l(
613
613
  "div",
614
614
  {
615
615
  className: [
616
616
  "sa-input-dropdown-item",
617
617
  w ? "has-description" : "",
618
- M ? "active" : "",
618
+ $ ? "active" : "",
619
619
  A === y ? "highlight" : "",
620
620
  a.disable ? "sa-input-dropdown-item-disable" : ""
621
621
  ].filter(Boolean).join(" "),
622
- ref: (j) => {
623
- D.current[A] = j;
622
+ ref: (P) => {
623
+ S.current[A] = P;
624
624
  },
625
625
  onClick: () => u(a.label, a.value),
626
626
  children: [
627
- C && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-item-check", children: M && /* @__PURE__ */ n(xn, { width: 16 }) }),
628
- a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: tn.cloneElement(a.icon, { width: 16 }) }),
627
+ C && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-item-check", children: $ && /* @__PURE__ */ n(kn, { width: 16 }) }),
628
+ a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: dn.cloneElement(a.icon, { width: 16 }) }),
629
629
  /* @__PURE__ */ l("div", { style: { minWidth: 0, flex: 1 }, children: [
630
630
  /* @__PURE__ */ n(
631
631
  "p",
@@ -656,17 +656,17 @@ const vn = ({ ...o }) => /* @__PURE__ */ l(
656
656
  ]
657
657
  }
658
658
  ),
659
- o === "top" && H,
660
- I && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (a) => a.stopPropagation(), children: I })
659
+ o === "top" && M,
660
+ F && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (a) => a.stopPropagation(), children: F })
661
661
  ]
662
662
  }
663
663
  ) : null });
664
664
  }
665
- ), kn = ({
665
+ ), Nn = ({
666
666
  children: o,
667
667
  handleChangePosition: p
668
668
  }) => {
669
- const t = W(null);
669
+ const t = I(null);
670
670
  x(() => {
671
671
  var m;
672
672
  const d = () => {
@@ -686,14 +686,14 @@ const vn = ({ ...o }) => /* @__PURE__ */ l(
686
686
  }, []);
687
687
  const s = (d) => d && (d.scrollHeight > d.clientHeight || d.scrollWidth > d.clientWidth);
688
688
  return /* @__PURE__ */ n("div", { ref: t, children: o });
689
- }, en = "sa-input-dropdown-styles", yn = (o) => {
690
- if (!document.getElementById(en)) {
689
+ }, on = "sa-input-dropdown-styles", En = (o) => {
690
+ if (!document.getElementById(on)) {
691
691
  const p = document.createElement("style");
692
- p.id = en, p.textContent = o, document.head.appendChild(p);
692
+ p.id = on, p.textContent = o, document.head.appendChild(p);
693
693
  }
694
694
  };
695
- yn(bn);
696
- const Rn = ({
695
+ En(vn);
696
+ const Bn = ({
697
697
  dropdownLists: o,
698
698
  onChange: p,
699
699
  defaultValue: t,
@@ -705,72 +705,73 @@ const Rn = ({
705
705
  placeholder: C,
706
706
  onSearch: z,
707
707
  error: y,
708
- onBlur: I,
709
- onFocus: F,
708
+ onBlur: F,
709
+ onFocus: H,
710
710
  disable: R,
711
- searchValue: q,
712
- variant: D = "outline",
713
- footer: H,
711
+ searchValue: G,
712
+ variant: S = "outline",
713
+ footer: M,
714
714
  groupLabel: a,
715
715
  onSelectAll: A,
716
- fullWidth: M = !0,
716
+ fullWidth: $ = !0,
717
717
  triggerInput: w = !1,
718
- clearOnSelect: j = !1,
718
+ clearOnSelect: P = !1,
719
+ hideChevronIcon: sn = !1,
719
720
  /* field wrapper */
720
- label: G,
721
- labelPosition: dn = "outside-top",
722
- required: Y,
723
- optional: _,
721
+ label: K,
722
+ labelPosition: ln = "outside-top",
723
+ required: _,
724
+ optional: V,
724
725
  description: L,
725
726
  helperText: B,
726
727
  errorText: h
727
728
  }) => {
728
- const K = [
729
+ const U = [
729
730
  "sa-select-field",
730
- M ? "sa-select-field-fullwidth" : ""
731
- ].filter(Boolean).join(" "), S = s !== void 0, U = W(), sn = y || !!h, [c, O] = P(
732
- S ? s || [] : t || []
733
- ), [ln, V] = P(""), [k, J] = P(-1), [pn, T] = P(
731
+ $ ? "sa-select-field-fullwidth" : ""
732
+ ].filter(Boolean).join(" "), D = s !== void 0, J = I(), pn = y || !!h, [c, j] = W(
733
+ D ? s || [] : t || []
734
+ ), [cn, nn] = W(""), [k, T] = W(-1), [wn, Z] = W(
734
735
  () => {
735
736
  var e, i;
736
737
  return !r && (s != null && s.length || t != null && t.length) ? ((e = s == null ? void 0 : s[0]) == null ? void 0 : e.label) ?? ((i = t == null ? void 0 : t[0]) == null ? void 0 : i.label) ?? "" : "";
737
738
  }
738
- ), g = W(null), { isComponentVisible: f, ref: Z, setIsComponentVisible: N } = gn(!1), cn = () => {
739
- N((e) => !e);
740
- }, $ = (e, i) => {
739
+ ), g = I(null), { isComponentVisible: f, ref: Q, setIsComponentVisible: N } = xn(!1), O = o !== void 0, un = () => {
740
+ O && N((e) => !e);
741
+ }, q = (e, i) => {
741
742
  if (r) {
742
743
  if (c == null ? void 0 : c.find((v) => v.value === i)) {
743
- const v = c.filter((hn) => hn.value !== i);
744
- S || O(v), p(v);
744
+ const v = c.filter((bn) => bn.value !== i);
745
+ D || j(v), p(v);
745
746
  } else {
746
747
  const v = [...c, { label: e, value: i }];
747
- S || O(v), p(v);
748
+ D || j(v), p(v);
748
749
  }
749
- w && T("");
750
+ w && Z("");
750
751
  } else {
751
752
  const b = [{ label: e, value: i }];
752
- S || O(b), p(b), w && T(j ? "" : e), N(!1);
753
+ D || j(b), p(b), w && Z(P ? "" : e), N(!1);
753
754
  }
754
755
  };
755
756
  x(() => {
756
- S && O(s || []);
757
+ D && j(s || []);
757
758
  }, [s]), x(() => {
758
- S || JSON.stringify(U.current) === JSON.stringify(t) || (U.current = t, O(U.current || []));
759
+ D || JSON.stringify(J.current) === JSON.stringify(t) || (J.current = t, j(J.current || []));
759
760
  }, [t]);
760
- const wn = () => c.length ? r ? c == null ? void 0 : c.map((e, i) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
761
+ const hn = () => c.length ? r ? c == null ? void 0 : c.map((e, i) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
761
762
  /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
762
763
  /* @__PURE__ */ n(
763
- rn,
764
+ an,
764
765
  {
765
766
  onClick: (b) => {
766
- b.stopPropagation(), $(e.label, e.value);
767
+ b.stopPropagation(), q(e.label, e.value);
767
768
  }
768
769
  }
769
770
  )
770
771
  ] }, i)) : /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: c == null ? void 0 : c[0].label }) : /* @__PURE__ */ n("p", { className: "sa-input-dropdown-placeholder", children: C }), E = () => {
771
- if (Z.current && g.current) {
772
- const e = window.innerHeight, i = Z.current.getBoundingClientRect(), b = g.current.getBoundingClientRect(), v = i.bottom + b.height;
773
- g.current.style.left = `${i.left}px`, g.current.style.width = `${i.width}px`, v >= e - 10 ? (g.current.style.top = `${i.top - b.height - 5}px`, V("top")) : (g.current.style.top = `${i.top + i.height + 4}px`, V("bottom"));
772
+ if (Q.current && g.current) {
773
+ const e = window.innerHeight, i = Q.current.getBoundingClientRect(), b = g.current.getBoundingClientRect(), v = i.bottom + b.height;
774
+ g.current.style.left = `${i.left}px`, g.current.style.width = `${i.width}px`, v >= e - 10 ? (g.current.style.top = `${i.top - b.height - 5}px`, nn("top")) : (g.current.style.top = `${i.top + i.height + 4}px`, nn("bottom"));
774
775
  }
775
776
  };
776
777
  x(() => (window.addEventListener("scroll", E), window.addEventListener("resize", E), () => {
@@ -785,45 +786,47 @@ const Rn = ({
785
786
  });
786
787
  return e.observe(g.current), () => e.disconnect();
787
788
  }, [f]), x(() => {
788
- f || J(-1);
789
+ f || T(-1);
789
790
  }, [f]);
790
- const nn = (e) => {
791
- if (!f) {
792
- (e.key === "ArrowDown" || e.key === "Enter") && (e.preventDefault(), N(!0));
793
- return;
794
- }
795
- switch (e.key) {
796
- case "ArrowDown": {
797
- e.preventDefault();
798
- const i = on(o, k, 1);
799
- i !== -1 && J(i);
800
- break;
801
- }
802
- case "ArrowUp": {
803
- e.preventDefault();
804
- const i = on(o, k, -1);
805
- i !== -1 && J(i);
806
- break;
791
+ const en = (e) => {
792
+ if (O) {
793
+ if (!f) {
794
+ (e.key === "ArrowDown" || e.key === "Enter") && (e.preventDefault(), N(!0));
795
+ return;
807
796
  }
808
- case "Enter": {
809
- e.preventDefault(), k >= 0 && o[k] && !o[k].disable && $(
810
- o[k].label,
811
- o[k].value
812
- );
813
- break;
797
+ switch (e.key) {
798
+ case "ArrowDown": {
799
+ e.preventDefault();
800
+ const i = rn(o, k, 1);
801
+ i !== -1 && T(i);
802
+ break;
803
+ }
804
+ case "ArrowUp": {
805
+ e.preventDefault();
806
+ const i = rn(o, k, -1);
807
+ i !== -1 && T(i);
808
+ break;
809
+ }
810
+ case "Enter": {
811
+ e.preventDefault(), k >= 0 && o[k] && !o[k].disable && q(
812
+ o[k].label,
813
+ o[k].value
814
+ );
815
+ break;
816
+ }
817
+ case "Escape":
818
+ N(!1);
819
+ break;
814
820
  }
815
- case "Escape":
816
- N(!1);
817
- break;
818
821
  }
819
- }, Q = d === "lg" || d === "xl" ? 20 : 16, un = w ? /* @__PURE__ */ l(an, { children: [
822
+ }, X = d === "lg" || d === "xl" ? 20 : 16, fn = w ? /* @__PURE__ */ l(tn, { children: [
820
823
  r && c.map((e, i) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
821
824
  /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
822
825
  /* @__PURE__ */ n(
823
- rn,
826
+ an,
824
827
  {
825
828
  onClick: (b) => {
826
- b.stopPropagation(), $(e.label, e.value);
829
+ b.stopPropagation(), q(e.label, e.value);
827
830
  }
828
831
  }
829
832
  )
@@ -832,65 +835,65 @@ const Rn = ({
832
835
  "input",
833
836
  {
834
837
  className: "sa-input-dropdown-trigger-input",
835
- value: pn,
838
+ value: wn,
836
839
  onChange: (e) => {
837
840
  const i = e.target.value;
838
- T(i), z == null || z(i), f || N(!0);
841
+ Z(i), z == null || z(i), !f && O && N(!0);
839
842
  },
840
843
  onFocus: () => {
841
- R || N(!0);
844
+ !R && O && N(!0);
842
845
  },
843
846
  onBlur: () => {
844
- setTimeout(() => N(!1), 150);
847
+ r || setTimeout(() => N(!1), 150);
845
848
  },
846
- onKeyDown: nn,
849
+ onKeyDown: en,
847
850
  placeholder: c.length === 0 || r ? C : void 0,
848
851
  disabled: R
849
852
  }
850
853
  )
851
- ] }) : null, X = /* @__PURE__ */ n(kn, { handleChangePosition: E, children: /* @__PURE__ */ l(
854
+ ] }) : null, Y = /* @__PURE__ */ n(Nn, { handleChangePosition: E, children: /* @__PURE__ */ l(
852
855
  "div",
853
856
  {
854
857
  className: [
855
858
  "sa-input-dropdown-container",
856
- D,
859
+ S,
857
860
  `sa-input-dropdown-size-${d}`,
858
861
  w ? "trigger-input" : "",
859
862
  f ? "active" : "",
860
- sn ? "error" : "",
863
+ pn ? "error" : "",
861
864
  R ? "disable" : ""
862
865
  ].filter(Boolean).join(" "),
863
- ref: Z,
864
- onClick: w ? void 0 : cn,
865
- onKeyDown: w ? void 0 : nn,
866
+ ref: Q,
867
+ onClick: w ? void 0 : un,
868
+ onKeyDown: w ? void 0 : en,
866
869
  tabIndex: w ? void 0 : 0,
867
- onBlur: w ? void 0 : I,
868
- onFocus: w ? void 0 : F,
870
+ onBlur: w ? void 0 : F,
871
+ onFocus: w ? void 0 : H,
869
872
  children: [
870
873
  /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-container", children: [
871
- u ? tn.cloneElement(u, {
872
- width: Q,
874
+ u ? dn.cloneElement(u, {
875
+ width: X,
873
876
  style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 }
874
877
  }) : null,
875
- /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: w ? un : wn() }),
876
- f ? /* @__PURE__ */ n(En, { width: Q }) : /* @__PURE__ */ n(Nn, { width: Q })
878
+ /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: w ? fn : hn() }),
879
+ !sn && (f ? /* @__PURE__ */ n(zn, { width: X }) : /* @__PURE__ */ n(Cn, { width: X }))
877
880
  ] }),
878
- /* @__PURE__ */ n(
879
- mn,
881
+ O && /* @__PURE__ */ n(
882
+ yn,
880
883
  {
881
884
  dropdownLists: o,
882
- handleChangeValue: $,
885
+ handleChangeValue: q,
883
886
  isComponentVisible: f,
884
- positionDropdown: ln,
887
+ positionDropdown: cn,
885
888
  searchAble: !!m,
886
889
  hideSearch: w,
887
890
  value: c,
888
891
  onSearch: z,
889
892
  ref: g,
890
893
  multiSelect: r,
891
- searchValue: q,
894
+ searchValue: G,
892
895
  highlightedIndex: k,
893
- footer: H,
896
+ footer: M,
894
897
  groupLabel: a,
895
898
  onSelectAll: A
896
899
  }
@@ -898,37 +901,37 @@ const Rn = ({
898
901
  ]
899
902
  }
900
903
  ) });
901
- return G ? dn === "outside-left" ? /* @__PURE__ */ l("div", { className: `${K} sa-select-field-left`, children: [
904
+ return K ? ln === "outside-left" ? /* @__PURE__ */ l("div", { className: `${U} sa-select-field-left`, children: [
902
905
  /* @__PURE__ */ l("div", { className: "sa-select-field-left-label", children: [
903
906
  /* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
904
- /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: G }),
905
- _ && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
906
- Y && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
907
+ /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: K }),
908
+ V && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
909
+ _ && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
907
910
  ] }),
908
911
  L && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: L })
909
912
  ] }),
910
913
  /* @__PURE__ */ l("div", { className: "sa-select-field-input-wrap", children: [
911
- X,
914
+ Y,
912
915
  B && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: B }),
913
916
  h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
914
917
  ] })
915
- ] }) : /* @__PURE__ */ l("div", { className: K, children: [
918
+ ] }) : /* @__PURE__ */ l("div", { className: U, children: [
916
919
  /* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
917
- /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: G }),
918
- _ && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
919
- Y && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
920
+ /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: K }),
921
+ V && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
922
+ _ && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
920
923
  ] }),
921
924
  L && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: L }),
922
- X,
925
+ Y,
923
926
  B && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: B }),
924
927
  h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
925
- ] }) : /* @__PURE__ */ l("div", { className: K, children: [
928
+ ] }) : /* @__PURE__ */ l("div", { className: U, children: [
926
929
  L && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: L }),
927
- X,
930
+ Y,
928
931
  B && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: B }),
929
932
  h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
930
933
  ] });
931
- }, on = (o, p, t) => {
934
+ }, rn = (o, p, t) => {
932
935
  const s = o.length;
933
936
  let d = p + t;
934
937
  for (; d >= 0 && d < s; ) {
@@ -945,7 +948,7 @@ const Rn = ({
945
948
  if (!o[r].disable)
946
949
  return r;
947
950
  return -1;
948
- }, rn = (o) => /* @__PURE__ */ n(
951
+ }, an = (o) => /* @__PURE__ */ n(
949
952
  "svg",
950
953
  {
951
954
  xmlns: "http://www.w3.org/2000/svg",
@@ -966,7 +969,7 @@ const Rn = ({
966
969
  }
967
970
  )
968
971
  }
969
- ), Nn = ({ width: o = 16 }) => /* @__PURE__ */ n(
972
+ ), Cn = ({ width: o = 16 }) => /* @__PURE__ */ n(
970
973
  "svg",
971
974
  {
972
975
  xmlns: "http://www.w3.org/2000/svg",
@@ -986,7 +989,7 @@ const Rn = ({
986
989
  }
987
990
  )
988
991
  }
989
- ), En = ({ width: o = 16 }) => /* @__PURE__ */ n(
992
+ ), zn = ({ width: o = 16 }) => /* @__PURE__ */ n(
990
993
  "svg",
991
994
  {
992
995
  xmlns: "http://www.w3.org/2000/svg",
@@ -1008,5 +1011,5 @@ const Rn = ({
1008
1011
  }
1009
1012
  );
1010
1013
  export {
1011
- Rn as Dropdown
1014
+ Bn as Dropdown
1012
1015
  };
@@ -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 on=`@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
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 rn=`@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;
@@ -483,4 +483,4 @@
483
483
  margin: 0;
484
484
  }
485
485
 
486
- `;function rn(o){const[p,d]=l.useState(o),t=l.useRef(null),i=r=>{t.current&&!t.current.contains(r.target)&&d(!1)};return l.useEffect(()=>(document.addEventListener("click",i,!0),()=>{document.removeEventListener("click",i,!0)}),[]),{ref:t,isComponentVisible:p,setIsComponentVisible:d}}const an=({...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"})]}),sn=({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"})}),dn=l.forwardRef(({positionDropdown:o,dropdownLists:p,isComponentVisible:d,searchAble:t,hideSearch:i,onSearch:r,value:k,handleChangeValue:f,multiSelect:C,searchValue:z,highlightedIndex:y,footer:W,groupLabel:I,onSelectAll:L},$)=>{const j=l.useRef([]);l.useEffect(()=>{var s;y>=0&&j.current[y]&&((s=j.current[y])==null||s.scrollIntoView({block:"nearest"}))},[y]);const F=t&&!i?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(an,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:s=>{r&&r(s.target.value)},value:z,autoFocus:!0,placeholder:"Search..."})]}):null;return n.jsx(n.Fragment,{children:d?n.jsxs("div",{className:"sa-input-dropdown-lists-container",onClick:s=>s.stopPropagation(),ref:$,children:[o!=="top"&&F,n.jsxs("div",{className:`sa-input-dropdown-item-container ${C?"multi":""}`,children:[I&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:I}),C&&L&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:s=>{s.stopPropagation(),L()},children:"Select all"})]}),p.map((s,A)=>{const M=!!(k!=null&&k.find(O=>O.value===s.value)),w=!!s.description;return n.jsxs("div",{className:["sa-input-dropdown-item",w?"has-description":"",M?"active":"",A===y?"highlight":"",s.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),ref:O=>{j.current[A]=O},onClick:()=>f(s.label,s.value),children:[C&&n.jsx("div",{className:"sa-input-dropdown-item-check",children:M&&n.jsx(sn,{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"&&F,W&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:s=>s.stopPropagation(),children:W})]}):null})}),tn=({children:o,handleChangePosition:p})=>{const d=l.useRef(null);l.useEffect(()=>{var k;const i=()=>{if(d.current){let f=d.current.parentElement;for(;f&&!t(f);)f=f.parentElement;f&&p()}};let r=(k=d.current)==null?void 0:k.parentElement;for(;r&&!t(r);)r=r.parentElement;return r&&r.addEventListener("scroll",i),i(),()=>{r&&r.removeEventListener("scroll",i)}},[]);const t=i=>i&&(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth);return n.jsx("div",{ref:d,children:o})},X="sa-input-dropdown-styles";(o=>{if(!document.getElementById(X)){const p=document.createElement("style");p.id=X,p.textContent=o,document.head.appendChild(p)}})(on);const ln=({dropdownLists:o,onChange:p,defaultValue:d,value:t,size:i="md",multiSelect:r,searchAble:k,iconLeft:f,placeholder:C,onSearch:z,error:y,onBlur:W,onFocus:I,disable:L,searchValue:$,variant:j="outline",footer:F,groupLabel:s,onSelectAll:A,fullWidth:M=!0,triggerInput:w=!1,clearOnSelect:O=!1,label:q,labelPosition:wn="outside-top",required:V,optional:R,description:S,helperText:B,errorText:h})=>{const G=["sa-select-field",M?"sa-select-field-fullwidth":""].filter(Boolean).join(" "),D=t!==void 0,T=l.useRef(),fn=y||!!h,[c,P]=l.useState(D?t||[]:d||[]),[hn,nn]=l.useState(""),[m,K]=l.useState(-1),[un,U]=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:J,setIsComponentVisible:E}=rn(!1),bn=()=>{E(e=>!e)},H=(e,a)=>{if(r){if(c==null?void 0:c.find(v=>v.value===a)){const v=c.filter(xn=>xn.value!==a);D||P(v),p(v)}else{const v=[...c,{label:e,value:a}];D||P(v),p(v)}w&&U("")}else{const b=[{label:e,value:a}];D||P(b),p(b),w&&U(O?"":e),E(!1)}};l.useEffect(()=>{D&&P(t||[])},[t]),l.useEffect(()=>{D||JSON.stringify(T.current)===JSON.stringify(d)||(T.current=d,P(T.current||[]))},[d]);const gn=()=>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(_,{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:C}),N=()=>{if(J.current&&g.current){const e=window.innerHeight,a=J.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`,nn("top")):(g.current.style.top=`${a.top+a.height+4}px`,nn("bottom"))}};l.useEffect(()=>(window.addEventListener("scroll",N),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N),window.removeEventListener("resize",N)}),[]),l.useEffect(()=>{N()},[u]),l.useEffect(()=>{if(!u||!g.current)return;const e=new ResizeObserver(()=>{N()});return e.observe(g.current),()=>e.disconnect()},[u]),l.useEffect(()=>{u||K(-1)},[u]);const en=e=>{if(!u){(e.key==="ArrowDown"||e.key==="Enter")&&(e.preventDefault(),E(!0));return}switch(e.key){case"ArrowDown":{e.preventDefault();const a=Y(o,m,1);a!==-1&&K(a);break}case"ArrowUp":{e.preventDefault();const a=Y(o,m,-1);a!==-1&&K(a);break}case"Enter":{e.preventDefault(),m>=0&&o[m]&&!o[m].disable&&H(o[m].label,o[m].value);break}case"Escape":E(!1);break}},Z=i==="lg"||i==="xl"?20:16,vn=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(_,{onClick:b=>{b.stopPropagation(),H(e.label,e.value)}})]},a)),n.jsx("input",{className:"sa-input-dropdown-trigger-input",value:un,onChange:e=>{const a=e.target.value;U(a),z==null||z(a),u||E(!0)},onFocus:()=>{L||E(!0)},onBlur:()=>{setTimeout(()=>E(!1),150)},onKeyDown:en,placeholder:c.length===0||r?C:void 0,disabled:L})]}):null,Q=n.jsx(tn,{handleChangePosition:N,children:n.jsxs("div",{className:["sa-input-dropdown-container",j,`sa-input-dropdown-size-${i}`,w?"trigger-input":"",u?"active":"",fn?"error":"",L?"disable":""].filter(Boolean).join(" "),ref:J,onClick:w?void 0:bn,onKeyDown:w?void 0:en,tabIndex:w?void 0:0,onBlur:w?void 0:W,onFocus:w?void 0:I,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[f?l.cloneElement(f,{width:Z,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:w?vn:gn()}),u?n.jsx(cn,{width:Z}):n.jsx(pn,{width:Z})]}),n.jsx(dn,{dropdownLists:o,handleChangeValue:H,isComponentVisible:u,positionDropdown:hn,searchAble:!!k,hideSearch:w,value:c,onSearch:z,ref:g,multiSelect:r,searchValue:$,highlightedIndex:m,footer:F,groupLabel:s,onSelectAll:A})]})});return q?wn==="outside-left"?n.jsxs("div",{className:`${G} 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:q}),R&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),V&&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:[Q,B&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:B}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]})]}):n.jsxs("div",{className:G,children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:q}),R&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),V&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S}),Q,B&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:B}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]}):n.jsxs("div",{className:G,children:[S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S}),Q,B&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:B}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]})},Y=(o,p,d)=>{const t=o.length;let i=p+d;for(;i>=0&&i<t;){if(!o[i].disable)return i;i+=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},_=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"})}),pn=({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"})}),cn=({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=ln,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
486
+ `;function an(o){const[p,d]=l.useState(o),t=l.useRef(null),i=r=>{t.current&&!t.current.contains(r.target)&&d(!1)};return l.useEffect(()=>(document.addEventListener("click",i,!0),()=>{document.removeEventListener("click",i,!0)}),[]),{ref:t,isComponentVisible:p,setIsComponentVisible:d}}const sn=({...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"})]}),dn=({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"})}),tn=l.forwardRef(({positionDropdown:o,dropdownLists:p,isComponentVisible:d,searchAble:t,hideSearch:i,onSearch:r,value:k,handleChangeValue:f,multiSelect:C,searchValue:z,highlightedIndex:y,footer:I,groupLabel:F,onSelectAll:L},q)=>{const j=l.useRef([]);l.useEffect(()=>{var s;y>=0&&j.current[y]&&((s=j.current[y])==null||s.scrollIntoView({block:"nearest"}))},[y]);const M=t&&!i?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(sn,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:s=>{r&&r(s.target.value)},value:z,autoFocus:!0,placeholder:"Search..."})]}):null;return n.jsx(n.Fragment,{children:d?n.jsxs("div",{className:"sa-input-dropdown-lists-container",onClick:s=>s.stopPropagation(),ref:q,children:[o!=="top"&&M,n.jsxs("div",{className:`sa-input-dropdown-item-container ${C?"multi":""}`,children:[F&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:F}),C&&L&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:s=>{s.stopPropagation(),L()},children:"Select all"})]}),p.map((s,P)=>{const H=!!(k!=null&&k.find(A=>A.value===s.value)),w=!!s.description;return n.jsxs("div",{className:["sa-input-dropdown-item",w?"has-description":"",H?"active":"",P===y?"highlight":"",s.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),ref:A=>{j.current[P]=A},onClick:()=>f(s.label,s.value),children:[C&&n.jsx("div",{className:"sa-input-dropdown-item-check",children:H&&n.jsx(dn,{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})]})]},P)})]}),o==="top"&&M,I&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:s=>s.stopPropagation(),children:I})]}):null})}),ln=({children:o,handleChangePosition:p})=>{const d=l.useRef(null);l.useEffect(()=>{var k;const i=()=>{if(d.current){let f=d.current.parentElement;for(;f&&!t(f);)f=f.parentElement;f&&p()}};let r=(k=d.current)==null?void 0:k.parentElement;for(;r&&!t(r);)r=r.parentElement;return r&&r.addEventListener("scroll",i),i(),()=>{r&&r.removeEventListener("scroll",i)}},[]);const t=i=>i&&(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth);return n.jsx("div",{ref:d,children:o})},Y="sa-input-dropdown-styles";(o=>{if(!document.getElementById(Y)){const p=document.createElement("style");p.id=Y,p.textContent=o,document.head.appendChild(p)}})(rn);const pn=({dropdownLists:o,onChange:p,defaultValue:d,value:t,size:i="md",multiSelect:r,searchAble:k,iconLeft:f,placeholder:C,onSearch:z,error:y,onBlur:I,onFocus:F,disable:L,searchValue:q,variant:j="outline",footer:M,groupLabel:s,onSelectAll:P,fullWidth:H=!0,triggerInput:w=!1,clearOnSelect:A=!1,hideChevronIcon:fn=!1,label:G,labelPosition:hn="outside-top",required:R,optional:nn,description:B,helperText:S,errorText:h})=>{const T=["sa-select-field",H?"sa-select-field-fullwidth":""].filter(Boolean).join(" "),D=t!==void 0,K=l.useRef(),un=y||!!h,[c,O]=l.useState(D?t||[]:d||[]),[bn,en]=l.useState(""),[m,U]=l.useState(-1),[gn,J]=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:Z,setIsComponentVisible:E}=an(!1),W=o!==void 0,vn=()=>{W&&E(e=>!e)},$=(e,a)=>{if(r){if(c==null?void 0:c.find(v=>v.value===a)){const v=c.filter(mn=>mn.value!==a);D||O(v),p(v)}else{const v=[...c,{label:e,value:a}];D||O(v),p(v)}w&&J("")}else{const b=[{label:e,value:a}];D||O(b),p(b),w&&J(A?"":e),E(!1)}};l.useEffect(()=>{D&&O(t||[])},[t]),l.useEffect(()=>{D||JSON.stringify(K.current)===JSON.stringify(d)||(K.current=d,O(K.current||[]))},[d]);const xn=()=>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(V,{onClick:b=>{b.stopPropagation(),$(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:C}),N=()=>{if(Z.current&&g.current){const e=window.innerHeight,a=Z.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`,en("top")):(g.current.style.top=`${a.top+a.height+4}px`,en("bottom"))}};l.useEffect(()=>(window.addEventListener("scroll",N),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N),window.removeEventListener("resize",N)}),[]),l.useEffect(()=>{N()},[u]),l.useEffect(()=>{if(!u||!g.current)return;const e=new ResizeObserver(()=>{N()});return e.observe(g.current),()=>e.disconnect()},[u]),l.useEffect(()=>{u||U(-1)},[u]);const on=e=>{if(W){if(!u){(e.key==="ArrowDown"||e.key==="Enter")&&(e.preventDefault(),E(!0));return}switch(e.key){case"ArrowDown":{e.preventDefault();const a=_(o,m,1);a!==-1&&U(a);break}case"ArrowUp":{e.preventDefault();const a=_(o,m,-1);a!==-1&&U(a);break}case"Enter":{e.preventDefault(),m>=0&&o[m]&&!o[m].disable&&$(o[m].label,o[m].value);break}case"Escape":E(!1);break}}},Q=i==="lg"||i==="xl"?20:16,kn=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(V,{onClick:b=>{b.stopPropagation(),$(e.label,e.value)}})]},a)),n.jsx("input",{className:"sa-input-dropdown-trigger-input",value:gn,onChange:e=>{const a=e.target.value;J(a),z==null||z(a),!u&&W&&E(!0)},onFocus:()=>{!L&&W&&E(!0)},onBlur:()=>{r||setTimeout(()=>E(!1),150)},onKeyDown:on,placeholder:c.length===0||r?C:void 0,disabled:L})]}):null,X=n.jsx(ln,{handleChangePosition:N,children:n.jsxs("div",{className:["sa-input-dropdown-container",j,`sa-input-dropdown-size-${i}`,w?"trigger-input":"",u?"active":"",un?"error":"",L?"disable":""].filter(Boolean).join(" "),ref:Z,onClick:w?void 0:vn,onKeyDown:w?void 0:on,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:[f?l.cloneElement(f,{width:Q,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:w?kn:xn()}),!fn&&(u?n.jsx(wn,{width:Q}):n.jsx(cn,{width:Q}))]}),W&&n.jsx(tn,{dropdownLists:o,handleChangeValue:$,isComponentVisible:u,positionDropdown:bn,searchAble:!!k,hideSearch:w,value:c,onSearch:z,ref:g,multiSelect:r,searchValue:q,highlightedIndex:m,footer:M,groupLabel:s,onSelectAll:P})]})});return G?hn==="outside-left"?n.jsxs("div",{className:`${T} 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:G}),nn&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),R&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),B&&n.jsx("p",{className:"sa-select-field-helper-top",children:B})]}),n.jsxs("div",{className:"sa-select-field-input-wrap",children:[X,S&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:S}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]})]}):n.jsxs("div",{className:T,children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:G}),nn&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),R&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),B&&n.jsx("p",{className:"sa-select-field-helper-top",children:B}),X,S&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:S}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]}):n.jsxs("div",{className:T,children:[B&&n.jsx("p",{className:"sa-select-field-helper-top",children:B}),X,S&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:S}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]})},_=(o,p,d)=>{const t=o.length;let i=p+d;for(;i>=0&&i<t;){if(!o[i].disable)return i;i+=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},V=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"})}),cn=({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"})}),wn=({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=pn,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
@@ -9,7 +9,7 @@ export interface IDropdown {
9
9
  label: string;
10
10
  value: string;
11
11
  }[]) => void;
12
- dropdownLists: {
12
+ dropdownLists?: {
13
13
  icon?: React.ReactElement<IconPropsDropdown>;
14
14
  label: string;
15
15
  value: string;
@@ -43,6 +43,7 @@ export interface IDropdown {
43
43
  fullWidth?: boolean;
44
44
  triggerInput?: boolean;
45
45
  clearOnSelect?: boolean;
46
+ hideChevronIcon?: boolean;
46
47
  label?: React.ReactNode;
47
48
  labelPosition?: DropdownLabelPosition;
48
49
  required?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/dropdown",
3
- "version": "5.2.1",
3
+ "version": "5.3.0",
4
4
  "description": "dropdown component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/dropdown.umd.js",