@starasia/dropdown 6.1.4 → 6.2.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,5 +1,5 @@
1
1
  import { jsxs as l, jsx as n, Fragment as tn } from "react/jsx-runtime";
2
- import sn, { useState as L, useRef as J, useEffect as x, forwardRef as En } from "react";
2
+ import dn, { useState as A, useRef as J, useEffect as x, forwardRef as En } from "react";
3
3
  const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
4
4
  starasia, components, utilities). CSS app/Tailwind utility selalu bisa
5
5
  menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
@@ -26,6 +26,9 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
26
26
  --sa-dropdown-bg-error: var(--sa-background-error-subtlest, #fff0f3);
27
27
  --sa-dropdown-bg-chip: var(--sa-background-brand-subtlest, #e6edf6);
28
28
  --sa-dropdown-border-subtle: var(--sa-border-subtle, rgba(11, 18, 14, 0.14));
29
+ /* Batas field (outline/flushed) — ≥ 3:1 terhadap kanvas (WCAG 1.4.11).
30
+ border-subtle (≈1.2:1) tetap untuk pemisah panel, chip, dsb. */
31
+ --sa-dropdown-border-field: var(--sa-border-input, #8c8f97);
29
32
  /* State aktif/terbuka = kontrol yang SEDANG fokus → pakai border fokus
30
33
  (--sa-border-focused: biru brand-500 di default, amber di skin tech,
31
34
  biru terang di dark), bukan --sa-border-brand #031f43 yang nyaris hitam. */
@@ -103,6 +106,16 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
103
106
  .sa-input-dropdown-container:focus-visible {
104
107
  outline: none;
105
108
  }
109
+ /* Fokus keyboard (trigger non-searchable, tabIndex 0) sebelum panel dibuka —
110
+ dulu tanpa penanda sama sekali (WCAG 2.4.7). Pakai warna border aktif,
111
+ sama seperti state terbuka. */
112
+ .sa-input-dropdown-container.sa-input-dropdown-standard:focus-visible,
113
+ .sa-input-dropdown-container.sa-input-dropdown-outline:focus-visible {
114
+ border-color: var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
115
+ }
116
+ .sa-input-dropdown-container.sa-input-dropdown-flushed:focus-visible {
117
+ border-bottom-color: var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
118
+ }
106
119
 
107
120
  /* --- Standard variant (default) --- */
108
121
  .sa-input-dropdown-container.sa-input-dropdown-standard {
@@ -129,7 +142,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
129
142
  /* --- Outline variant --- */
130
143
  .sa-input-dropdown-container.sa-input-dropdown-outline {
131
144
  background-color: transparent;
132
- border: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
145
+ border: 1px solid var(--sa-dropdown-border-field);
133
146
  border-radius: var(--borderRadius);
134
147
  outline: none;
135
148
  }
@@ -153,7 +166,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
153
166
  .sa-input-dropdown-container.sa-input-dropdown-flushed {
154
167
  background-color: transparent;
155
168
  border: none;
156
- border-bottom: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
169
+ border-bottom: 1px solid var(--sa-dropdown-border-field);
157
170
  border-radius: 0;
158
171
  }
159
172
  .sa-input-dropdown-container.sa-input-dropdown-flushed.active {
@@ -598,15 +611,27 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
598
611
  display: none;
599
612
  }
600
613
 
614
+ /* Forced colors (Windows High Contrast): fokus/terbuka ditandai ganti warna
615
+ border + ring box-shadow — keduanya hilang di mode ini. Ganti outline
616
+ warna sistem. */
617
+ @media (forced-colors: active) {
618
+ .sa-input-dropdown-container.active,
619
+ .sa-input-dropdown-container:focus-visible,
620
+ .sa-input-dropdown-container.trigger-input:focus-within {
621
+ outline: 2px solid Highlight;
622
+ outline-offset: 1px;
623
+ }
624
+ }
625
+
601
626
  } /* @layer starasia.components */
602
627
  `;
603
628
  function Rn(o) {
604
- const [t, s] = L(o), p = J(null), c = (i) => {
605
- p.current && !p.current.contains(i.target) && s(!1);
629
+ const [t, d] = A(o), p = J(null), c = (i) => {
630
+ p.current && !p.current.contains(i.target) && d(!1);
606
631
  };
607
632
  return x(() => (document.addEventListener("click", c, !0), () => {
608
633
  document.removeEventListener("click", c, !0);
609
- }), []), { ref: p, isComponentVisible: t, setIsComponentVisible: s };
634
+ }), []), { ref: p, isComponentVisible: t, setIsComponentVisible: d };
610
635
  }
611
636
  const Bn = ({ ...o }) => /* @__PURE__ */ l(
612
637
  "svg",
@@ -663,25 +688,25 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
663
688
  ({
664
689
  positionDropdown: o,
665
690
  dropdownLists: t,
666
- isComponentVisible: s,
691
+ isComponentVisible: d,
667
692
  searchAble: p,
668
693
  hideSearch: c,
669
694
  onSearch: i,
670
- value: A,
671
- handleChangeValue: F,
695
+ value: L,
696
+ handleChangeValue: P,
672
697
  multiSelect: k,
673
698
  searchValue: y,
674
699
  highlightedIndex: N,
675
- listboxId: M,
700
+ listboxId: I,
676
701
  footer: T,
677
702
  groupLabel: C,
678
703
  onSelectAll: $,
679
704
  emptyState: X
680
705
  }, Y) => {
681
- const O = J([]), q = y !== void 0, [Z, Q] = L(""), d = q ? y : Z, H = !t || t.length === 0;
706
+ const M = J([]), q = y !== void 0, [Z, Q] = A(""), s = q ? y : Z, G = !t || t.length === 0;
682
707
  x(() => {
683
708
  var a;
684
- N >= 0 && O.current[N] && ((a = O.current[N]) == null || a.scrollIntoView({ block: "nearest" }));
709
+ N >= 0 && M.current[N] && ((a = M.current[N]) == null || a.scrollIntoView({ block: "nearest" }));
685
710
  }, [N]);
686
711
  const _ = p && !c ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
687
712
  /* @__PURE__ */ n(Bn, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
@@ -691,13 +716,13 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
691
716
  onChange: (a) => {
692
717
  q || Q(a.target.value), i && i(a.target.value);
693
718
  },
694
- value: d,
719
+ value: s,
695
720
  autoFocus: !0,
696
721
  placeholder: "Search..."
697
722
  }
698
723
  )
699
724
  ] }) : null;
700
- return /* @__PURE__ */ n(tn, { children: s ? /* @__PURE__ */ l(
725
+ return /* @__PURE__ */ n(tn, { children: d ? /* @__PURE__ */ l(
701
726
  "div",
702
727
  {
703
728
  className: [
@@ -718,19 +743,19 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
718
743
  {
719
744
  className: `sa-input-dropdown-item-container ${k ? "multi" : ""}`,
720
745
  role: "listbox",
721
- id: M,
746
+ id: I,
722
747
  "aria-multiselectable": k || void 0,
723
748
  children: [
724
- H && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-empty", children: X ?? (d ? /* @__PURE__ */ l(tn, { children: [
749
+ G && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-empty", children: X ?? (s ? /* @__PURE__ */ l(tn, { children: [
725
750
  "No results for",
726
751
  " ",
727
752
  /* @__PURE__ */ l("span", { className: "sa-input-dropdown-empty-query", children: [
728
753
  "“",
729
- d,
754
+ s,
730
755
  "”"
731
756
  ] })
732
757
  ] }) : "No data available") }),
733
- C && !H && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
758
+ C && !G && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
734
759
  /* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: C }),
735
760
  k && $ && /* @__PURE__ */ n(
736
761
  "button",
@@ -744,7 +769,7 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
744
769
  )
745
770
  ] }),
746
771
  t == null ? void 0 : t.map((a, m) => {
747
- const E = !!(A != null && A.find((B) => B.value === a.value)), V = !!a.description;
772
+ const E = !!(L != null && L.find((B) => B.value === a.value)), V = !!a.description;
748
773
  return /* @__PURE__ */ l(
749
774
  "div",
750
775
  {
@@ -755,17 +780,17 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
755
780
  m === N ? "highlight" : "",
756
781
  a.disable ? "sa-input-dropdown-item-disable" : ""
757
782
  ].filter(Boolean).join(" "),
758
- id: M ? `${M}-opt-${m}` : void 0,
783
+ id: I ? `${I}-opt-${m}` : void 0,
759
784
  role: "option",
760
785
  "aria-selected": E,
761
786
  "aria-disabled": a.disable || void 0,
762
787
  ref: (B) => {
763
- O.current[m] = B;
788
+ M.current[m] = B;
764
789
  },
765
- onClick: () => F(a.label, a.value),
790
+ onClick: () => P(a.label, a.value),
766
791
  children: [
767
792
  k && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-item-check", children: E && /* @__PURE__ */ n(Dn, { width: 16 }) }),
768
- a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: sn.cloneElement(a.icon, { width: 16 }) }),
793
+ a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: dn.cloneElement(a.icon, { width: 16 }) }),
769
794
  /* @__PURE__ */ l("div", { style: { minWidth: 0, flex: 1 }, children: [
770
795
  /* @__PURE__ */ n(
771
796
  "p",
@@ -804,43 +829,43 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
804
829
  ), Sn = ({
805
830
  children: o,
806
831
  handleChangePosition: t,
807
- enabled: s = !0
832
+ enabled: d = !0
808
833
  }) => (x(() => {
809
- if (s)
834
+ if (d)
810
835
  return window.addEventListener("scroll", t, !0), () => {
811
836
  window.removeEventListener("scroll", t, !0);
812
837
  };
813
- }, [s, t]), /* @__PURE__ */ n("div", { children: o })), hn = "sa-input-dropdown-styles", Ln = (o) => {
838
+ }, [d, t]), /* @__PURE__ */ n("div", { children: o })), hn = "sa-input-dropdown-styles", An = (o) => {
814
839
  if (!(typeof document > "u") && !document.getElementById(hn)) {
815
840
  const t = document.createElement("style");
816
841
  t.id = hn, t.textContent = o, document.head.appendChild(t);
817
842
  }
818
843
  };
819
- Ln(zn);
820
- const Pn = ({
844
+ An(zn);
845
+ const Fn = ({
821
846
  dropdownLists: o,
822
847
  onChange: t,
823
- defaultValue: s,
848
+ defaultValue: d,
824
849
  value: p,
825
850
  size: c = "sm",
826
851
  multiSelect: i,
827
- searchAble: A,
828
- iconLeft: F,
852
+ searchAble: L,
853
+ iconLeft: P,
829
854
  placeholder: k,
830
855
  onSearch: y,
831
856
  error: N,
832
- onBlur: M,
857
+ onBlur: I,
833
858
  onFocus: T,
834
859
  disable: C,
835
860
  searchValue: $,
836
861
  variant: X = "outline",
837
862
  footer: Y,
838
- groupLabel: O,
863
+ groupLabel: M,
839
864
  onSelectAll: q,
840
865
  emptyState: Z,
841
866
  fullWidth: Q = !0,
842
- triggerInput: d = !1,
843
- clearOnSelect: H = !1,
867
+ triggerInput: s = !1,
868
+ clearOnSelect: G = !1,
844
869
  hideChevronIcon: _ = !1,
845
870
  clearable: a = !1,
846
871
  onClear: m,
@@ -848,7 +873,7 @@ const Pn = ({
848
873
  label: E,
849
874
  labelPosition: V = "outside-top",
850
875
  required: B,
851
- optional: dn,
876
+ optional: sn,
852
877
  description: D,
853
878
  helperText: j,
854
879
  errorText: h
@@ -857,19 +882,19 @@ const Pn = ({
857
882
  "sa-select-field",
858
883
  `sa-select-field-size-${c}`,
859
884
  Q ? "sa-select-field-fullwidth" : ""
860
- ].filter(Boolean).join(" "), z = p !== void 0, en = J(), vn = N || !!h, [u, S] = L(
861
- z ? p || [] : s || []
862
- ), [gn, ln] = L(""), [b, on] = L(-1), G = sn.useId(), pn = b >= 0 ? `${G}-opt-${b}` : void 0, [cn, K] = L(
885
+ ].filter(Boolean).join(" "), z = p !== void 0, en = J(), vn = N || !!h, [u, S] = A(
886
+ z ? p || [] : d || []
887
+ ), [gn, ln] = A(""), [b, on] = A(-1), H = dn.useId(), pn = b >= 0 ? `${H}-opt-${b}` : void 0, [cn, K] = A(
863
888
  () => {
864
889
  var e, r;
865
- return !i && (p != null && p.length || s != null && s.length) ? ((e = p == null ? void 0 : p[0]) == null ? void 0 : e.label) ?? ((r = s == null ? void 0 : s[0]) == null ? void 0 : r.label) ?? "" : "";
890
+ return !i && (p != null && p.length || d != null && d.length) ? ((e = p == null ? void 0 : p[0]) == null ? void 0 : e.label) ?? ((r = d == null ? void 0 : d[0]) == null ? void 0 : r.label) ?? "" : "";
866
891
  }
867
- ), v = J(null), { isComponentVisible: w, ref: rn, setIsComponentVisible: R } = Rn(!1), I = o !== void 0, un = u.length > 0, xn = (e) => {
892
+ ), v = J(null), { isComponentVisible: w, ref: rn, setIsComponentVisible: R } = Rn(!1), O = o !== void 0, un = u.length > 0, xn = (e) => {
868
893
  e.stopPropagation();
869
894
  const r = [];
870
- z || S(r), t(r), d && K(""), m == null || m();
895
+ z || S(r), t(r), s && K(""), m == null || m();
871
896
  }, mn = () => {
872
- I && R((e) => !e);
897
+ O && R((e) => !e);
873
898
  }, U = (e, r) => {
874
899
  if (i) {
875
900
  if (u == null ? void 0 : u.find((g) => g.value === r)) {
@@ -879,17 +904,17 @@ const Pn = ({
879
904
  const g = [...u, { label: e, value: r }];
880
905
  z || S(g), t(g);
881
906
  }
882
- d && K("");
907
+ s && K("");
883
908
  } else {
884
909
  const f = [{ label: e, value: r }];
885
- z || S(f), t(f), d && K(H ? "" : e), R(!1);
910
+ z || S(f), t(f), s && K(G ? "" : e), R(!1);
886
911
  }
887
912
  };
888
913
  x(() => {
889
914
  z && S(p || []);
890
915
  }, [p]), x(() => {
891
- z || JSON.stringify(en.current) === JSON.stringify(s) || (en.current = s, S(en.current || []));
892
- }, [s]);
916
+ z || JSON.stringify(en.current) === JSON.stringify(d) || (en.current = d, S(en.current || []));
917
+ }, [d]);
893
918
  const kn = () => u.length ? i ? u == null ? void 0 : u.map((e, r) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
894
919
  /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
895
920
  /* @__PURE__ */ n(
@@ -921,7 +946,7 @@ const Pn = ({
921
946
  w || on(-1);
922
947
  }, [w]);
923
948
  const wn = (e) => {
924
- if (I) {
949
+ if (O) {
925
950
  if (!w) {
926
951
  (e.key === "ArrowDown" || e.key === "Enter") && (e.preventDefault(), R(!0));
927
952
  return;
@@ -951,7 +976,7 @@ const Pn = ({
951
976
  break;
952
977
  }
953
978
  }
954
- }, P = c === "lg" || c === "xl" ? 20 : c === "xs" ? 14 : 16, yn = a && !C ? /* @__PURE__ */ n(
979
+ }, F = c === "lg" || c === "xl" ? 20 : c === "xs" ? 14 : 16, yn = a && !C ? /* @__PURE__ */ n(
955
980
  "button",
956
981
  {
957
982
  type: "button",
@@ -961,9 +986,9 @@ const Pn = ({
961
986
  tabIndex: -1,
962
987
  onClick: xn,
963
988
  onMouseDown: (e) => e.preventDefault(),
964
- children: /* @__PURE__ */ n(An, { width: P, height: P })
989
+ children: /* @__PURE__ */ n(Ln, { width: F, height: F })
965
990
  }
966
- ) : null, Nn = d ? /* @__PURE__ */ l(tn, { children: [
991
+ ) : null, Nn = s ? /* @__PURE__ */ l(tn, { children: [
967
992
  i && u.map((e, r) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
968
993
  /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
969
994
  /* @__PURE__ */ n(
@@ -982,16 +1007,16 @@ const Pn = ({
982
1007
  role: "combobox",
983
1008
  "aria-expanded": w,
984
1009
  "aria-haspopup": "listbox",
985
- "aria-controls": G,
1010
+ "aria-controls": H,
986
1011
  "aria-activedescendant": pn,
987
1012
  "aria-autocomplete": "list",
988
1013
  value: cn,
989
1014
  onChange: (e) => {
990
1015
  const r = e.target.value;
991
- K(r), y == null || y(r), !w && I && R(!0);
1016
+ K(r), y == null || y(r), !w && O && R(!0);
992
1017
  },
993
1018
  onFocus: () => {
994
- !C && I && R(!0);
1019
+ !C && O && R(!0);
995
1020
  },
996
1021
  onBlur: () => {
997
1022
  i || setTimeout(() => R(!1), 150);
@@ -1015,7 +1040,7 @@ const Pn = ({
1015
1040
  // bentrok dgn utility Tailwind/shadcn (mis. `.outline`) → outline gelap.
1016
1041
  `sa-input-dropdown-${X}`,
1017
1042
  `sa-input-dropdown-size-${c}`,
1018
- d ? "trigger-input" : "",
1043
+ s ? "trigger-input" : "",
1019
1044
  // multiSelect = chip bisa membungkus → CSS tempel chevron/clear ke
1020
1045
  // baris atas; single-line tetap center (fix combobox kelihatan naik).
1021
1046
  i ? "multiselect" : "",
@@ -1024,44 +1049,44 @@ const Pn = ({
1024
1049
  C ? "disable" : ""
1025
1050
  ].filter(Boolean).join(" "),
1026
1051
  ref: rn,
1027
- role: d ? void 0 : "combobox",
1028
- "aria-haspopup": d ? void 0 : "listbox",
1029
- "aria-expanded": d ? void 0 : w,
1030
- "aria-controls": d ? void 0 : G,
1031
- "aria-activedescendant": d ? void 0 : pn,
1032
- onClick: d ? void 0 : mn,
1033
- onKeyDown: d ? void 0 : wn,
1034
- tabIndex: d ? void 0 : 0,
1035
- onBlur: d ? void 0 : M,
1036
- onFocus: d ? void 0 : T,
1052
+ role: s ? void 0 : "combobox",
1053
+ "aria-haspopup": s ? void 0 : "listbox",
1054
+ "aria-expanded": s ? void 0 : w,
1055
+ "aria-controls": s ? void 0 : H,
1056
+ "aria-activedescendant": s ? void 0 : pn,
1057
+ onClick: s ? void 0 : mn,
1058
+ onKeyDown: s ? void 0 : wn,
1059
+ tabIndex: s ? void 0 : 0,
1060
+ onBlur: s ? void 0 : I,
1061
+ onFocus: s ? void 0 : T,
1037
1062
  children: [
1038
1063
  /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-container", children: [
1039
- F ? sn.cloneElement(F, {
1040
- width: P,
1064
+ P ? dn.cloneElement(P, {
1065
+ width: F,
1041
1066
  style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 }
1042
1067
  }) : null,
1043
- /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: d ? Nn : kn() }),
1068
+ /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: s ? Nn : kn() }),
1044
1069
  yn,
1045
- !_ && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-chevron", children: w ? /* @__PURE__ */ n(On, { width: P }) : /* @__PURE__ */ n(Mn, { width: P }) })
1070
+ !_ && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-chevron", children: w ? /* @__PURE__ */ n(Mn, { width: F }) : /* @__PURE__ */ n(In, { width: F }) })
1046
1071
  ] }),
1047
- I && /* @__PURE__ */ n(
1072
+ O && /* @__PURE__ */ n(
1048
1073
  jn,
1049
1074
  {
1050
1075
  dropdownLists: o,
1051
1076
  handleChangeValue: U,
1052
1077
  isComponentVisible: w,
1053
- listboxId: G,
1078
+ listboxId: H,
1054
1079
  positionDropdown: gn,
1055
- searchAble: !!A,
1056
- hideSearch: d,
1080
+ searchAble: !!L,
1081
+ hideSearch: s,
1057
1082
  value: u,
1058
1083
  onSearch: y,
1059
1084
  ref: v,
1060
1085
  multiSelect: i,
1061
- searchValue: d ? cn : $,
1086
+ searchValue: s ? cn : $,
1062
1087
  highlightedIndex: b,
1063
1088
  footer: Y,
1064
- groupLabel: O,
1089
+ groupLabel: M,
1065
1090
  onSelectAll: q,
1066
1091
  emptyState: Z
1067
1092
  }
@@ -1075,7 +1100,7 @@ const Pn = ({
1075
1100
  /* @__PURE__ */ l("div", { className: "sa-select-field-left-label", children: [
1076
1101
  /* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
1077
1102
  /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: E }),
1078
- dn && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
1103
+ sn && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
1079
1104
  B && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
1080
1105
  ] }),
1081
1106
  D && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: D })
@@ -1088,7 +1113,7 @@ const Pn = ({
1088
1113
  ] }) : /* @__PURE__ */ l("div", { className: nn, children: [
1089
1114
  /* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
1090
1115
  /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: E }),
1091
- dn && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
1116
+ sn && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
1092
1117
  B && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
1093
1118
  ] }),
1094
1119
  D && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: D }),
@@ -1101,15 +1126,15 @@ const Pn = ({
1101
1126
  j && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: j }),
1102
1127
  h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
1103
1128
  ] });
1104
- }, bn = (o, t, s) => {
1129
+ }, bn = (o, t, d) => {
1105
1130
  const p = o.length;
1106
- let c = t + s;
1131
+ let c = t + d;
1107
1132
  for (; c >= 0 && c < p; ) {
1108
1133
  if (!o[c].disable)
1109
1134
  return c;
1110
- c += s;
1135
+ c += d;
1111
1136
  }
1112
- if (s === 1) {
1137
+ if (d === 1) {
1113
1138
  for (let i = 0; i < p; i++)
1114
1139
  if (!o[i].disable)
1115
1140
  return i;
@@ -1118,7 +1143,7 @@ const Pn = ({
1118
1143
  if (!o[i].disable)
1119
1144
  return i;
1120
1145
  return -1;
1121
- }, An = (o) => /* @__PURE__ */ l("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o, children: [
1146
+ }, Ln = (o) => /* @__PURE__ */ l("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o, children: [
1122
1147
  /* @__PURE__ */ n("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor", opacity: "0.2" }),
1123
1148
  /* @__PURE__ */ n("path", { d: "M5.5 5.5l5 5M10.5 5.5l-5 5", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" })
1124
1149
  ] }), fn = (o) => /* @__PURE__ */ n(
@@ -1142,7 +1167,7 @@ const Pn = ({
1142
1167
  }
1143
1168
  )
1144
1169
  }
1145
- ), Mn = ({ width: o = 16 }) => /* @__PURE__ */ n(
1170
+ ), In = ({ width: o = 16 }) => /* @__PURE__ */ n(
1146
1171
  "svg",
1147
1172
  {
1148
1173
  xmlns: "http://www.w3.org/2000/svg",
@@ -1162,7 +1187,7 @@ const Pn = ({
1162
1187
  }
1163
1188
  )
1164
1189
  }
1165
- ), On = ({ width: o = 16 }) => /* @__PURE__ */ n(
1190
+ ), Mn = ({ width: o = 16 }) => /* @__PURE__ */ n(
1166
1191
  "svg",
1167
1192
  {
1168
1193
  xmlns: "http://www.w3.org/2000/svg",
@@ -1184,5 +1209,5 @@ const Pn = ({
1184
1209
  }
1185
1210
  );
1186
1211
  export {
1187
- Pn as Dropdown
1212
+ Fn as Dropdown
1188
1213
  };
@@ -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,s){"use strict";const un=`/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
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,s){"use strict";const wn=`/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
2
2
  starasia, components, utilities). CSS app/Tailwind utility selalu bisa
3
3
  menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
4
4
  @layer starasia.components {
@@ -24,6 +24,9 @@
24
24
  --sa-dropdown-bg-error: var(--sa-background-error-subtlest, #fff0f3);
25
25
  --sa-dropdown-bg-chip: var(--sa-background-brand-subtlest, #e6edf6);
26
26
  --sa-dropdown-border-subtle: var(--sa-border-subtle, rgba(11, 18, 14, 0.14));
27
+ /* Batas field (outline/flushed) — ≥ 3:1 terhadap kanvas (WCAG 1.4.11).
28
+ border-subtle (≈1.2:1) tetap untuk pemisah panel, chip, dsb. */
29
+ --sa-dropdown-border-field: var(--sa-border-input, #8c8f97);
27
30
  /* State aktif/terbuka = kontrol yang SEDANG fokus → pakai border fokus
28
31
  (--sa-border-focused: biru brand-500 di default, amber di skin tech,
29
32
  biru terang di dark), bukan --sa-border-brand #031f43 yang nyaris hitam. */
@@ -101,6 +104,16 @@
101
104
  .sa-input-dropdown-container:focus-visible {
102
105
  outline: none;
103
106
  }
107
+ /* Fokus keyboard (trigger non-searchable, tabIndex 0) sebelum panel dibuka —
108
+ dulu tanpa penanda sama sekali (WCAG 2.4.7). Pakai warna border aktif,
109
+ sama seperti state terbuka. */
110
+ .sa-input-dropdown-container.sa-input-dropdown-standard:focus-visible,
111
+ .sa-input-dropdown-container.sa-input-dropdown-outline:focus-visible {
112
+ border-color: var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
113
+ }
114
+ .sa-input-dropdown-container.sa-input-dropdown-flushed:focus-visible {
115
+ border-bottom-color: var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
116
+ }
104
117
 
105
118
  /* --- Standard variant (default) --- */
106
119
  .sa-input-dropdown-container.sa-input-dropdown-standard {
@@ -127,7 +140,7 @@
127
140
  /* --- Outline variant --- */
128
141
  .sa-input-dropdown-container.sa-input-dropdown-outline {
129
142
  background-color: transparent;
130
- border: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
143
+ border: 1px solid var(--sa-dropdown-border-field);
131
144
  border-radius: var(--borderRadius);
132
145
  outline: none;
133
146
  }
@@ -151,7 +164,7 @@
151
164
  .sa-input-dropdown-container.sa-input-dropdown-flushed {
152
165
  background-color: transparent;
153
166
  border: none;
154
- border-bottom: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
167
+ border-bottom: 1px solid var(--sa-dropdown-border-field);
155
168
  border-radius: 0;
156
169
  }
157
170
  .sa-input-dropdown-container.sa-input-dropdown-flushed.active {
@@ -596,5 +609,17 @@
596
609
  display: none;
597
610
  }
598
611
 
612
+ /* Forced colors (Windows High Contrast): fokus/terbuka ditandai ganti warna
613
+ border + ring box-shadow — keduanya hilang di mode ini. Ganti outline
614
+ warna sistem. */
615
+ @media (forced-colors: active) {
616
+ .sa-input-dropdown-container.active,
617
+ .sa-input-dropdown-container:focus-visible,
618
+ .sa-input-dropdown-container.trigger-input:focus-within {
619
+ outline: 2px solid Highlight;
620
+ outline-offset: 1px;
621
+ }
622
+ }
623
+
599
624
  } /* @layer starasia.components */
600
- `;function fn(o){const[i,t]=s.useState(o),p=s.useRef(null),c=d=>{p.current&&!p.current.contains(d.target)&&t(!1)};return s.useEffect(()=>(document.addEventListener("click",c,!0),()=>{document.removeEventListener("click",c,!0)}),[]),{ref:p,isComponentVisible:i,setIsComponentVisible:t}}const hn=({...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"})]}),bn=({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"})}),vn=s.forwardRef(({positionDropdown:o,dropdownLists:i,isComponentVisible:t,searchAble:p,hideSearch:c,onSearch:d,value:A,handleChangeValue:P,multiSelect:k,searchValue:y,highlightedIndex:N,listboxId:M,footer:W,groupLabel:E,onSelectAll:$,emptyState:J},X)=>{const O=s.useRef([]),q=y!==void 0,[Y,Z]=s.useState(""),l=q?y:Y,H=!i||i.length===0;s.useEffect(()=>{var a;N>=0&&O.current[N]&&((a=O.current[N])==null||a.scrollIntoView({block:"nearest"}))},[N]);const Q=p&&!c?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(hn,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:a=>{q||Z(a.target.value),d&&d(a.target.value)},value:l,autoFocus:!0,placeholder:"Search..."})]}):null;return n.jsx(n.Fragment,{children:t?n.jsxs("div",{className:["sa-input-dropdown-lists-container",o==="top"?"search-bottom":""].filter(Boolean).join(" "),onClick:a=>a.stopPropagation(),ref:X,children:[Q,n.jsxs("div",{className:`sa-input-dropdown-item-container ${k?"multi":""}`,role:"listbox",id:M,"aria-multiselectable":k||void 0,children:[H&&n.jsx("div",{className:"sa-input-dropdown-empty",children:J??(l?n.jsxs(n.Fragment,{children:["No results for"," ",n.jsxs("span",{className:"sa-input-dropdown-empty-query",children:["“",l,"”"]})]}):"No data available")}),E&&!H&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:E}),k&&$&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:a=>{a.stopPropagation(),$()},children:"Select all"})]}),i==null?void 0:i.map((a,m)=>{const C=!!(A!=null&&A.find(B=>B.value===a.value)),_=!!a.description;return n.jsxs("div",{className:["sa-input-dropdown-item",_?"has-description":"",C?"active":"",m===N?"highlight":"",a.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),id:M?`${M}-opt-${m}`:void 0,role:"option","aria-selected":C,"aria-disabled":a.disable||void 0,ref:B=>{O.current[m]=B},onClick:()=>P(a.label,a.value),children:[k&&n.jsx("div",{className:"sa-input-dropdown-item-check",children:C&&n.jsx(bn,{width:16})}),a.icon&&n.jsx("div",{style:{flexShrink:0,display:"flex"},children:s.cloneElement(a.icon,{width:16})}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsx("p",{className:["sa-input-dropdown-item-text",a.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:a.label}),a.description&&n.jsx("p",{className:["sa-input-dropdown-item-text-description",a.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:a.description})]})]},m)})]}),W&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:a=>a.stopPropagation(),children:W})]}):null})}),gn=({children:o,handleChangePosition:i,enabled:t=!0})=>(s.useEffect(()=>{if(t)return window.addEventListener("scroll",i,!0),()=>{window.removeEventListener("scroll",i,!0)}},[t,i]),n.jsx("div",{children:o})),rn="sa-input-dropdown-styles";(o=>{if(!(typeof document>"u")&&!document.getElementById(rn)){const i=document.createElement("style");i.id=rn,i.textContent=o,document.head.appendChild(i)}})(un);const xn=({dropdownLists:o,onChange:i,defaultValue:t,value:p,size:c="sm",multiSelect:d,searchAble:A,iconLeft:P,placeholder:k,onSearch:y,error:N,onBlur:M,onFocus:W,disable:E,searchValue:$,variant:J="outline",footer:X,groupLabel:O,onSelectAll:q,emptyState:Y,fullWidth:Z=!0,triggerInput:l=!1,clearOnSelect:H=!1,hideChevronIcon:Q=!1,clearable:a=!1,onClear:m,label:C,labelPosition:_="outside-top",required:B,optional:dn,description:D,helperText:j,errorText:f})=>{const V=["sa-select-field",`sa-select-field-size-${c}`,Z?"sa-select-field-fullwidth":""].filter(Boolean).join(" "),z=p!==void 0,R=s.useRef(),Nn=N||!!f,[w,L]=s.useState(z?p||[]:t||[]),[En,tn]=s.useState(""),[h,nn]=s.useState(-1),G=s.useId(),ln=h>=0?`${G}-opt-${h}`:void 0,[pn,K]=s.useState(()=>{var e,r;return!d&&(p!=null&&p.length||t!=null&&t.length)?((e=p==null?void 0:p[0])==null?void 0:e.label)??((r=t==null?void 0:t[0])==null?void 0:r.label)??"":""}),v=s.useRef(null),{isComponentVisible:u,ref:en,setIsComponentVisible:S}=fn(!1),I=o!==void 0,cn=w.length>0,Cn=e=>{e.stopPropagation();const r=[];z||L(r),i(r),l&&K(""),m==null||m()},zn=()=>{I&&S(e=>!e)},U=(e,r)=>{if(d){if(w==null?void 0:w.find(g=>g.value===r)){const g=w.filter(jn=>jn.value!==r);z||L(g),i(g)}else{const g=[...w,{label:e,value:r}];z||L(g),i(g)}l&&K("")}else{const b=[{label:e,value:r}];z||L(b),i(b),l&&K(H?"":e),S(!1)}};s.useEffect(()=>{z&&L(p||[])},[p]),s.useEffect(()=>{z||JSON.stringify(R.current)===JSON.stringify(t)||(R.current=t,L(R.current||[]))},[t]);const Sn=()=>w.length?d?w==null?void 0:w.map((e,r)=>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(sn,{onClick:b=>{b.stopPropagation(),U(e.label,e.value)}})]},r)):n.jsx("p",{style:{minWidth:"max-content"},children:w==null?void 0:w[0].label}):n.jsx("p",{className:"sa-input-dropdown-placeholder",children:k}),T=()=>{if(en.current&&v.current){const e=window.innerHeight,r=en.current.getBoundingClientRect(),b=v.current.getBoundingClientRect(),g=r.bottom+b.height;v.current.style.left=`${r.left}px`,v.current.style.width=`${r.width}px`,g>=e-10?(v.current.style.top=`${r.top-b.height-5}px`,tn("top")):(v.current.style.top=`${r.top+r.height+4}px`,tn("bottom"))}};s.useEffect(()=>(window.addEventListener("resize",T),()=>{window.removeEventListener("resize",T)}),[]),s.useEffect(()=>{T()},[u]),s.useEffect(()=>{if(!u||!v.current)return;const e=new ResizeObserver(()=>{T()});return e.observe(v.current),()=>e.disconnect()},[u]),s.useEffect(()=>{u||nn(-1)},[u]);const wn=e=>{if(I){if(!u){(e.key==="ArrowDown"||e.key==="Enter")&&(e.preventDefault(),S(!0));return}switch(e.key){case"ArrowDown":{e.preventDefault();const r=an(o,h,1);r!==-1&&nn(r);break}case"ArrowUp":{e.preventDefault();const r=an(o,h,-1);r!==-1&&nn(r);break}case"Enter":{e.preventDefault(),h>=0&&o[h]&&!o[h].disable&&U(o[h].label,o[h].value);break}case"Escape":S(!1);break}}},F=c==="lg"||c==="xl"?20:c==="xs"?14:16,Bn=a&&!E?n.jsx("button",{type:"button",className:`sa-input-dropdown-clear${cn?"":" sa-input-dropdown-clear-hidden"}`,"aria-label":"Clear selection","aria-hidden":!cn,tabIndex:-1,onClick:Cn,onMouseDown:e=>e.preventDefault(),children:n.jsx(mn,{width:F,height:F})}):null,Dn=l?n.jsxs(n.Fragment,{children:[d&&w.map((e,r)=>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(sn,{onClick:b=>{b.stopPropagation(),U(e.label,e.value)}})]},r)),n.jsx("input",{className:"sa-input-dropdown-trigger-input",role:"combobox","aria-expanded":u,"aria-haspopup":"listbox","aria-controls":G,"aria-activedescendant":ln,"aria-autocomplete":"list",value:pn,onChange:e=>{const r=e.target.value;K(r),y==null||y(r),!u&&I&&S(!0)},onFocus:()=>{!E&&I&&S(!0)},onBlur:()=>{d||setTimeout(()=>S(!1),150)},onKeyDown:wn,placeholder:w.length===0||d?k:void 0,disabled:E})]}):null,on=n.jsx(gn,{handleChangePosition:T,enabled:u,children:n.jsxs("div",{className:["sa-input-dropdown-container",`sa-input-dropdown-${J}`,`sa-input-dropdown-size-${c}`,l?"trigger-input":"",d?"multiselect":"",u?"active":"",Nn?"error":"",E?"disable":""].filter(Boolean).join(" "),ref:en,role:l?void 0:"combobox","aria-haspopup":l?void 0:"listbox","aria-expanded":l?void 0:u,"aria-controls":l?void 0:G,"aria-activedescendant":l?void 0:ln,onClick:l?void 0:zn,onKeyDown:l?void 0:wn,tabIndex:l?void 0:0,onBlur:l?void 0:M,onFocus:l?void 0:W,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[P?s.cloneElement(P,{width:F,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:l?Dn:Sn()}),Bn,!Q&&n.jsx("div",{className:"sa-input-dropdown-chevron",children:u?n.jsx(yn,{width:F}):n.jsx(kn,{width:F})})]}),I&&n.jsx(vn,{dropdownLists:o,handleChangeValue:U,isComponentVisible:u,listboxId:G,positionDropdown:En,searchAble:!!A,hideSearch:l,value:w,onSearch:y,ref:v,multiSelect:d,searchValue:l?pn:$,highlightedIndex:h,footer:X,groupLabel:O,onSelectAll:q,emptyState:Y})]})});return C?_==="outside-left"?n.jsxs("div",{className:`${V} 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:C}),dn&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),B&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),D&&n.jsx("p",{className:"sa-select-field-helper-top",children:D})]}),n.jsxs("div",{className:"sa-select-field-input-wrap",children:[on,j&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:j}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]})]}):n.jsxs("div",{className:V,children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:C}),dn&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),B&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),D&&n.jsx("p",{className:"sa-select-field-helper-top",children:D}),on,j&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:j}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]}):n.jsxs("div",{className:V,children:[D&&n.jsx("p",{className:"sa-select-field-helper-top",children:D}),on,j&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:j}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]})},an=(o,i,t)=>{const p=o.length;let c=i+t;for(;c>=0&&c<p;){if(!o[c].disable)return c;c+=t}if(t===1){for(let d=0;d<p;d++)if(!o[d].disable)return d}else for(let d=p-1;d>=0;d--)if(!o[d].disable)return d;return-1},mn=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"})]}),sn=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"})}),kn=({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"})}),yn=({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=xn,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
625
+ `;function fn(o){const[i,t]=s.useState(o),p=s.useRef(null),c=d=>{p.current&&!p.current.contains(d.target)&&t(!1)};return s.useEffect(()=>(document.addEventListener("click",c,!0),()=>{document.removeEventListener("click",c,!0)}),[]),{ref:p,isComponentVisible:i,setIsComponentVisible:t}}const hn=({...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"})]}),bn=({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"})}),vn=s.forwardRef(({positionDropdown:o,dropdownLists:i,isComponentVisible:t,searchAble:p,hideSearch:c,onSearch:d,value:L,handleChangeValue:P,multiSelect:k,searchValue:y,highlightedIndex:N,listboxId:M,footer:T,groupLabel:E,onSelectAll:$,emptyState:J},X)=>{const O=s.useRef([]),q=y!==void 0,[Y,Z]=s.useState(""),l=q?y:Y,G=!i||i.length===0;s.useEffect(()=>{var a;N>=0&&O.current[N]&&((a=O.current[N])==null||a.scrollIntoView({block:"nearest"}))},[N]);const Q=p&&!c?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(hn,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:a=>{q||Z(a.target.value),d&&d(a.target.value)},value:l,autoFocus:!0,placeholder:"Search..."})]}):null;return n.jsx(n.Fragment,{children:t?n.jsxs("div",{className:["sa-input-dropdown-lists-container",o==="top"?"search-bottom":""].filter(Boolean).join(" "),onClick:a=>a.stopPropagation(),ref:X,children:[Q,n.jsxs("div",{className:`sa-input-dropdown-item-container ${k?"multi":""}`,role:"listbox",id:M,"aria-multiselectable":k||void 0,children:[G&&n.jsx("div",{className:"sa-input-dropdown-empty",children:J??(l?n.jsxs(n.Fragment,{children:["No results for"," ",n.jsxs("span",{className:"sa-input-dropdown-empty-query",children:["“",l,"”"]})]}):"No data available")}),E&&!G&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:E}),k&&$&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:a=>{a.stopPropagation(),$()},children:"Select all"})]}),i==null?void 0:i.map((a,m)=>{const C=!!(L!=null&&L.find(B=>B.value===a.value)),_=!!a.description;return n.jsxs("div",{className:["sa-input-dropdown-item",_?"has-description":"",C?"active":"",m===N?"highlight":"",a.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),id:M?`${M}-opt-${m}`:void 0,role:"option","aria-selected":C,"aria-disabled":a.disable||void 0,ref:B=>{O.current[m]=B},onClick:()=>P(a.label,a.value),children:[k&&n.jsx("div",{className:"sa-input-dropdown-item-check",children:C&&n.jsx(bn,{width:16})}),a.icon&&n.jsx("div",{style:{flexShrink:0,display:"flex"},children:s.cloneElement(a.icon,{width:16})}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsx("p",{className:["sa-input-dropdown-item-text",a.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:a.label}),a.description&&n.jsx("p",{className:["sa-input-dropdown-item-text-description",a.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:a.description})]})]},m)})]}),T&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:a=>a.stopPropagation(),children:T})]}):null})}),gn=({children:o,handleChangePosition:i,enabled:t=!0})=>(s.useEffect(()=>{if(t)return window.addEventListener("scroll",i,!0),()=>{window.removeEventListener("scroll",i,!0)}},[t,i]),n.jsx("div",{children:o})),rn="sa-input-dropdown-styles";(o=>{if(!(typeof document>"u")&&!document.getElementById(rn)){const i=document.createElement("style");i.id=rn,i.textContent=o,document.head.appendChild(i)}})(wn);const xn=({dropdownLists:o,onChange:i,defaultValue:t,value:p,size:c="sm",multiSelect:d,searchAble:L,iconLeft:P,placeholder:k,onSearch:y,error:N,onBlur:M,onFocus:T,disable:E,searchValue:$,variant:J="outline",footer:X,groupLabel:O,onSelectAll:q,emptyState:Y,fullWidth:Z=!0,triggerInput:l=!1,clearOnSelect:G=!1,hideChevronIcon:Q=!1,clearable:a=!1,onClear:m,label:C,labelPosition:_="outside-top",required:B,optional:dn,description:D,helperText:j,errorText:f})=>{const V=["sa-select-field",`sa-select-field-size-${c}`,Z?"sa-select-field-fullwidth":""].filter(Boolean).join(" "),z=p!==void 0,R=s.useRef(),Nn=N||!!f,[u,A]=s.useState(z?p||[]:t||[]),[En,tn]=s.useState(""),[h,nn]=s.useState(-1),H=s.useId(),ln=h>=0?`${H}-opt-${h}`:void 0,[pn,K]=s.useState(()=>{var e,r;return!d&&(p!=null&&p.length||t!=null&&t.length)?((e=p==null?void 0:p[0])==null?void 0:e.label)??((r=t==null?void 0:t[0])==null?void 0:r.label)??"":""}),v=s.useRef(null),{isComponentVisible:w,ref:en,setIsComponentVisible:S}=fn(!1),I=o!==void 0,cn=u.length>0,Cn=e=>{e.stopPropagation();const r=[];z||A(r),i(r),l&&K(""),m==null||m()},zn=()=>{I&&S(e=>!e)},U=(e,r)=>{if(d){if(u==null?void 0:u.find(g=>g.value===r)){const g=u.filter(jn=>jn.value!==r);z||A(g),i(g)}else{const g=[...u,{label:e,value:r}];z||A(g),i(g)}l&&K("")}else{const b=[{label:e,value:r}];z||A(b),i(b),l&&K(G?"":e),S(!1)}};s.useEffect(()=>{z&&A(p||[])},[p]),s.useEffect(()=>{z||JSON.stringify(R.current)===JSON.stringify(t)||(R.current=t,A(R.current||[]))},[t]);const Sn=()=>u.length?d?u==null?void 0:u.map((e,r)=>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(sn,{onClick:b=>{b.stopPropagation(),U(e.label,e.value)}})]},r)):n.jsx("p",{style:{minWidth:"max-content"},children:u==null?void 0:u[0].label}):n.jsx("p",{className:"sa-input-dropdown-placeholder",children:k}),W=()=>{if(en.current&&v.current){const e=window.innerHeight,r=en.current.getBoundingClientRect(),b=v.current.getBoundingClientRect(),g=r.bottom+b.height;v.current.style.left=`${r.left}px`,v.current.style.width=`${r.width}px`,g>=e-10?(v.current.style.top=`${r.top-b.height-5}px`,tn("top")):(v.current.style.top=`${r.top+r.height+4}px`,tn("bottom"))}};s.useEffect(()=>(window.addEventListener("resize",W),()=>{window.removeEventListener("resize",W)}),[]),s.useEffect(()=>{W()},[w]),s.useEffect(()=>{if(!w||!v.current)return;const e=new ResizeObserver(()=>{W()});return e.observe(v.current),()=>e.disconnect()},[w]),s.useEffect(()=>{w||nn(-1)},[w]);const un=e=>{if(I){if(!w){(e.key==="ArrowDown"||e.key==="Enter")&&(e.preventDefault(),S(!0));return}switch(e.key){case"ArrowDown":{e.preventDefault();const r=an(o,h,1);r!==-1&&nn(r);break}case"ArrowUp":{e.preventDefault();const r=an(o,h,-1);r!==-1&&nn(r);break}case"Enter":{e.preventDefault(),h>=0&&o[h]&&!o[h].disable&&U(o[h].label,o[h].value);break}case"Escape":S(!1);break}}},F=c==="lg"||c==="xl"?20:c==="xs"?14:16,Bn=a&&!E?n.jsx("button",{type:"button",className:`sa-input-dropdown-clear${cn?"":" sa-input-dropdown-clear-hidden"}`,"aria-label":"Clear selection","aria-hidden":!cn,tabIndex:-1,onClick:Cn,onMouseDown:e=>e.preventDefault(),children:n.jsx(mn,{width:F,height:F})}):null,Dn=l?n.jsxs(n.Fragment,{children:[d&&u.map((e,r)=>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(sn,{onClick:b=>{b.stopPropagation(),U(e.label,e.value)}})]},r)),n.jsx("input",{className:"sa-input-dropdown-trigger-input",role:"combobox","aria-expanded":w,"aria-haspopup":"listbox","aria-controls":H,"aria-activedescendant":ln,"aria-autocomplete":"list",value:pn,onChange:e=>{const r=e.target.value;K(r),y==null||y(r),!w&&I&&S(!0)},onFocus:()=>{!E&&I&&S(!0)},onBlur:()=>{d||setTimeout(()=>S(!1),150)},onKeyDown:un,placeholder:u.length===0||d?k:void 0,disabled:E})]}):null,on=n.jsx(gn,{handleChangePosition:W,enabled:w,children:n.jsxs("div",{className:["sa-input-dropdown-container",`sa-input-dropdown-${J}`,`sa-input-dropdown-size-${c}`,l?"trigger-input":"",d?"multiselect":"",w?"active":"",Nn?"error":"",E?"disable":""].filter(Boolean).join(" "),ref:en,role:l?void 0:"combobox","aria-haspopup":l?void 0:"listbox","aria-expanded":l?void 0:w,"aria-controls":l?void 0:H,"aria-activedescendant":l?void 0:ln,onClick:l?void 0:zn,onKeyDown:l?void 0:un,tabIndex:l?void 0:0,onBlur:l?void 0:M,onFocus:l?void 0:T,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[P?s.cloneElement(P,{width:F,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:l?Dn:Sn()}),Bn,!Q&&n.jsx("div",{className:"sa-input-dropdown-chevron",children:w?n.jsx(yn,{width:F}):n.jsx(kn,{width:F})})]}),I&&n.jsx(vn,{dropdownLists:o,handleChangeValue:U,isComponentVisible:w,listboxId:H,positionDropdown:En,searchAble:!!L,hideSearch:l,value:u,onSearch:y,ref:v,multiSelect:d,searchValue:l?pn:$,highlightedIndex:h,footer:X,groupLabel:O,onSelectAll:q,emptyState:Y})]})});return C?_==="outside-left"?n.jsxs("div",{className:`${V} 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:C}),dn&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),B&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),D&&n.jsx("p",{className:"sa-select-field-helper-top",children:D})]}),n.jsxs("div",{className:"sa-select-field-input-wrap",children:[on,j&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:j}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]})]}):n.jsxs("div",{className:V,children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:C}),dn&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),B&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),D&&n.jsx("p",{className:"sa-select-field-helper-top",children:D}),on,j&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:j}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]}):n.jsxs("div",{className:V,children:[D&&n.jsx("p",{className:"sa-select-field-helper-top",children:D}),on,j&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:j}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]})},an=(o,i,t)=>{const p=o.length;let c=i+t;for(;c>=0&&c<p;){if(!o[c].disable)return c;c+=t}if(t===1){for(let d=0;d<p;d++)if(!o[d].disable)return d}else for(let d=p-1;d>=0;d--)if(!o[d].disable)return d;return-1},mn=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"})]}),sn=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"})}),kn=({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"})}),yn=({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=xn,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/dropdown",
3
- "version": "6.1.4",
3
+ "version": "6.2.0",
4
4
  "description": "dropdown component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/dropdown.umd.js",