@starasia/dropdown 6.1.0 → 6.1.2

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 A, useRef as K, useEffect as g, forwardRef as En } from "react";
2
+ import sn, { useState as S, useRef as K, useEffect as g, 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,7 +26,10 @@ 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
- --sa-dropdown-border-active: var(--sa-border-brand, #031f43);
29
+ /* State aktif/terbuka = kontrol yang SEDANG fokus → pakai border fokus
30
+ (--sa-border-focused: biru brand-500 di default, amber di skin tech,
31
+ biru terang di dark), bukan --sa-border-brand #031f43 yang nyaris hitam. */
32
+ --sa-dropdown-border-active: var(--sa-border-focused, #1a4fa0);
30
33
  --sa-dropdown-border-error-subtle: var(--sa-border-danger-subtle, #ffb3c1);
31
34
  --sa-dropdown-color-disable: var(--sa-text-disable, rgba(24, 26, 25, 0.56));
32
35
  --sa-dropdown-placeholder: var(--sa-text-subtle, #505258);
@@ -108,7 +111,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
108
111
  border-radius: var(--borderRadius);
109
112
  }
110
113
  .sa-input-dropdown-container.standard.active {
111
- border: 1px solid var(--sa-dropdown-border-active);
114
+ border: 1px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
112
115
  box-shadow: var(--sa-dropdown-ring-active);
113
116
  }
114
117
  .sa-input-dropdown-container.standard.error {
@@ -126,12 +129,12 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
126
129
  /* --- Outline variant --- */
127
130
  .sa-input-dropdown-container.outline {
128
131
  background-color: transparent;
129
- border: 1px solid var(--sa-dropdown-border-subtle);
132
+ border: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
130
133
  border-radius: var(--borderRadius);
131
134
  outline: none;
132
135
  }
133
136
  .sa-input-dropdown-container.outline.active {
134
- border: 1.2px solid var(--sa-dropdown-border-active);
137
+ border: 1.2px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
135
138
  box-shadow: none;
136
139
  }
137
140
  .sa-input-dropdown-container.outline.error {
@@ -140,7 +143,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
140
143
  }
141
144
  .sa-input-dropdown-container.outline.disable {
142
145
  background-color: var(--sa-dropdown-bg-disabled);
143
- border-color: var(--sa-dropdown-border-subtle);
146
+ border-color: var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
144
147
  cursor: not-allowed;
145
148
  pointer-events: none;
146
149
  opacity: 0.6;
@@ -150,11 +153,11 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
150
153
  .sa-input-dropdown-container.flushed {
151
154
  background-color: transparent;
152
155
  border: none;
153
- border-bottom: 1px solid var(--sa-dropdown-border-subtle);
156
+ border-bottom: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
154
157
  border-radius: 0;
155
158
  }
156
159
  .sa-input-dropdown-container.flushed.active {
157
- border-bottom: 1.2px solid var(--sa-dropdown-border-active);
160
+ border-bottom: 1.2px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
158
161
  box-shadow: none;
159
162
  }
160
163
  .sa-input-dropdown-container.flushed.error {
@@ -201,7 +204,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
201
204
  }
202
205
 
203
206
  .sa-input-dropdown-preview-item {
204
- border: 1px solid var(--sa-dropdown-border-subtle);
207
+ border: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
205
208
  padding-inline: 8px;
206
209
  padding-block: 2px;
207
210
  border-radius: var(--sa-radii-xs, 4px);
@@ -279,7 +282,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
279
282
  align-items: center;
280
283
  height: 32px;
281
284
  min-height: 32px;
282
- border-bottom: 1px solid var(--sa-dropdown-border-subtle);
285
+ border-bottom: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
283
286
  gap: 8px;
284
287
  padding-inline: 12px;
285
288
  padding-block: 8px;
@@ -310,7 +313,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
310
313
  .sa-input-dropdown-lists-container.search-bottom > .sa-input-dropdown-container-dropdown-search {
311
314
  order: 2;
312
315
  border-bottom: none;
313
- border-top: 1px solid var(--sa-dropdown-border-subtle);
316
+ border-top: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
314
317
  }
315
318
  .sa-input-dropdown-lists-container.search-bottom > .sa-input-dropdown-footer {
316
319
  order: 3;
@@ -410,7 +413,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
410
413
  }
411
414
  .sa-input-dropdown-item.highlight {
412
415
  background-color: var(--sa-dropdown-bg-selected);
413
- outline: 1.2px solid var(--sa-dropdown-border-active);
416
+ outline: 1.2px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
414
417
  outline-offset: -1.2px;
415
418
  }
416
419
  .sa-input-dropdown-item-disable {
@@ -455,7 +458,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
455
458
  flex-shrink: 0;
456
459
  background: var(--sa-dropdown-bg);
457
460
  padding: 8px;
458
- border-top: 1px solid var(--sa-dropdown-border-subtle);
461
+ border-top: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
459
462
  }
460
463
 
461
464
  /* === SELECT FIELD WRAPPER === */
@@ -521,7 +524,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
521
524
  display: inline-flex;
522
525
  align-items: center;
523
526
  padding: 0 8px;
524
- border: 1px solid var(--sa-dropdown-border-subtle);
527
+ border: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
525
528
  border-radius: var(--sa-radii-xs, 4px);
526
529
  background: var(--sa-dropdown-bg-neutral);
527
530
  font-size: 10px;
@@ -585,12 +588,12 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
585
588
  } /* @layer starasia.components */
586
589
  `;
587
590
  function Rn(o) {
588
- const [i, t] = A(o), p = K(null), c = (s) => {
589
- p.current && !p.current.contains(s.target) && t(!1);
591
+ const [t, i] = S(o), p = K(null), c = (s) => {
592
+ p.current && !p.current.contains(s.target) && i(!1);
590
593
  };
591
594
  return g(() => (document.addEventListener("click", c, !0), () => {
592
595
  document.removeEventListener("click", c, !0);
593
- }), []), { ref: p, isComponentVisible: i, setIsComponentVisible: t };
596
+ }), []), { ref: p, isComponentVisible: t, setIsComponentVisible: i };
594
597
  }
595
598
  const Bn = ({ ...o }) => /* @__PURE__ */ l(
596
599
  "svg",
@@ -646,15 +649,15 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
646
649
  ), Ln = En(
647
650
  ({
648
651
  positionDropdown: o,
649
- dropdownLists: i,
650
- isComponentVisible: t,
652
+ dropdownLists: t,
653
+ isComponentVisible: i,
651
654
  searchAble: p,
652
655
  hideSearch: c,
653
656
  onSearch: s,
654
- value: S,
657
+ value: A,
655
658
  handleChangeValue: F,
656
- multiSelect: y,
657
- searchValue: k,
659
+ multiSelect: k,
660
+ searchValue: y,
658
661
  highlightedIndex: N,
659
662
  listboxId: M,
660
663
  footer: T,
@@ -662,7 +665,7 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
662
665
  onSelectAll: $,
663
666
  emptyState: X
664
667
  }, Y) => {
665
- const O = K([]), q = k !== void 0, [Z, Q] = A(""), d = q ? k : Z, H = !i || i.length === 0;
668
+ const O = K([]), q = y !== void 0, [Z, Q] = S(""), d = q ? y : Z, H = !t || t.length === 0;
666
669
  g(() => {
667
670
  var a;
668
671
  N >= 0 && O.current[N] && ((a = O.current[N]) == null || a.scrollIntoView({ block: "nearest" }));
@@ -681,7 +684,7 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
681
684
  }
682
685
  )
683
686
  ] }) : null;
684
- return /* @__PURE__ */ n(tn, { children: t ? /* @__PURE__ */ l(
687
+ return /* @__PURE__ */ n(tn, { children: i ? /* @__PURE__ */ l(
685
688
  "div",
686
689
  {
687
690
  className: [
@@ -700,10 +703,10 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
700
703
  /* @__PURE__ */ l(
701
704
  "div",
702
705
  {
703
- className: `sa-input-dropdown-item-container ${y ? "multi" : ""}`,
706
+ className: `sa-input-dropdown-item-container ${k ? "multi" : ""}`,
704
707
  role: "listbox",
705
708
  id: M,
706
- "aria-multiselectable": y || void 0,
709
+ "aria-multiselectable": k || void 0,
707
710
  children: [
708
711
  H && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-empty", children: X ?? (d ? /* @__PURE__ */ l(tn, { children: [
709
712
  "No results for",
@@ -716,7 +719,7 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
716
719
  ] }) : "No data available") }),
717
720
  C && !H && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
718
721
  /* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: C }),
719
- y && $ && /* @__PURE__ */ n(
722
+ k && $ && /* @__PURE__ */ n(
720
723
  "button",
721
724
  {
722
725
  className: "sa-input-dropdown-section-select-all",
@@ -727,8 +730,8 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
727
730
  }
728
731
  )
729
732
  ] }),
730
- i == null ? void 0 : i.map((a, m) => {
731
- const E = !!(S != null && S.find((B) => B.value === a.value)), V = !!a.description;
733
+ t == null ? void 0 : t.map((a, m) => {
734
+ const E = !!(A != null && A.find((B) => B.value === a.value)), V = !!a.description;
732
735
  return /* @__PURE__ */ l(
733
736
  "div",
734
737
  {
@@ -748,7 +751,7 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
748
751
  },
749
752
  onClick: () => F(a.label, a.value),
750
753
  children: [
751
- y && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-item-check", children: E && /* @__PURE__ */ n(Dn, { width: 16 }) }),
754
+ k && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-item-check", children: E && /* @__PURE__ */ n(Dn, { width: 16 }) }),
752
755
  a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: sn.cloneElement(a.icon, { width: 16 }) }),
753
756
  /* @__PURE__ */ l("div", { style: { minWidth: 0, flex: 1 }, children: [
754
757
  /* @__PURE__ */ n(
@@ -787,31 +790,31 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
787
790
  }
788
791
  ), jn = ({
789
792
  children: o,
790
- handleChangePosition: i,
791
- enabled: t = !0
793
+ handleChangePosition: t,
794
+ enabled: i = !0
792
795
  }) => (g(() => {
793
- if (t)
794
- return window.addEventListener("scroll", i, !0), () => {
795
- window.removeEventListener("scroll", i, !0);
796
+ if (i)
797
+ return window.addEventListener("scroll", t, !0), () => {
798
+ window.removeEventListener("scroll", t, !0);
796
799
  };
797
- }, [t, i]), /* @__PURE__ */ n("div", { children: o })), hn = "sa-input-dropdown-styles", An = (o) => {
800
+ }, [i, t]), /* @__PURE__ */ n("div", { children: o })), hn = "sa-input-dropdown-styles", Sn = (o) => {
798
801
  if (!(typeof document > "u") && !document.getElementById(hn)) {
799
- const i = document.createElement("style");
800
- i.id = hn, i.textContent = o, document.head.appendChild(i);
802
+ const t = document.createElement("style");
803
+ t.id = hn, t.textContent = o, document.head.appendChild(t);
801
804
  }
802
805
  };
803
- An(zn);
806
+ Sn(zn);
804
807
  const Pn = ({
805
808
  dropdownLists: o,
806
- onChange: i,
807
- defaultValue: t,
809
+ onChange: t,
810
+ defaultValue: i,
808
811
  value: p,
809
812
  size: c = "sm",
810
813
  multiSelect: s,
811
- searchAble: S,
814
+ searchAble: A,
812
815
  iconLeft: F,
813
- placeholder: y,
814
- onSearch: k,
816
+ placeholder: k,
817
+ onSearch: y,
815
818
  error: N,
816
819
  onBlur: M,
817
820
  onFocus: T,
@@ -841,40 +844,40 @@ const Pn = ({
841
844
  "sa-select-field",
842
845
  `sa-select-field-size-${c}`,
843
846
  Q ? "sa-select-field-fullwidth" : ""
844
- ].filter(Boolean).join(" "), z = p !== void 0, en = K(), vn = N || !!h, [u, j] = A(
845
- z ? p || [] : t || []
846
- ), [xn, ln] = A(""), [f, on] = A(-1), G = sn.useId(), pn = f >= 0 ? `${G}-opt-${f}` : void 0, [cn, U] = A(
847
+ ].filter(Boolean).join(" "), z = p !== void 0, en = K(), vn = N || !!h, [u, j] = S(
848
+ z ? p || [] : i || []
849
+ ), [xn, ln] = S(""), [f, on] = S(-1), G = sn.useId(), pn = f >= 0 ? `${G}-opt-${f}` : void 0, [cn, U] = S(
847
850
  () => {
848
851
  var e, r;
849
- return !s && (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) ?? "" : "";
852
+ return !s && (p != null && p.length || i != null && i.length) ? ((e = p == null ? void 0 : p[0]) == null ? void 0 : e.label) ?? ((r = i == null ? void 0 : i[0]) == null ? void 0 : r.label) ?? "" : "";
850
853
  }
851
854
  ), v = K(null), { isComponentVisible: w, ref: rn, setIsComponentVisible: R } = Rn(!1), I = o !== void 0, un = u.length > 0, gn = (e) => {
852
855
  e.stopPropagation();
853
856
  const r = [];
854
- z || j(r), i(r), d && U(""), m == null || m();
857
+ z || j(r), t(r), d && U(""), m == null || m();
855
858
  }, mn = () => {
856
859
  I && R((e) => !e);
857
860
  }, J = (e, r) => {
858
861
  if (s) {
859
862
  if (u == null ? void 0 : u.find((x) => x.value === r)) {
860
863
  const x = u.filter((Cn) => Cn.value !== r);
861
- z || j(x), i(x);
864
+ z || j(x), t(x);
862
865
  } else {
863
866
  const x = [...u, { label: e, value: r }];
864
- z || j(x), i(x);
867
+ z || j(x), t(x);
865
868
  }
866
869
  d && U("");
867
870
  } else {
868
871
  const b = [{ label: e, value: r }];
869
- z || j(b), i(b), d && U(H ? "" : e), R(!1);
872
+ z || j(b), t(b), d && U(H ? "" : e), R(!1);
870
873
  }
871
874
  };
872
875
  g(() => {
873
876
  z && j(p || []);
874
877
  }, [p]), g(() => {
875
- z || JSON.stringify(en.current) === JSON.stringify(t) || (en.current = t, j(en.current || []));
876
- }, [t]);
877
- const yn = () => u.length ? s ? u == null ? void 0 : u.map((e, r) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
878
+ z || JSON.stringify(en.current) === JSON.stringify(i) || (en.current = i, j(en.current || []));
879
+ }, [i]);
880
+ const kn = () => u.length ? s ? u == null ? void 0 : u.map((e, r) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
878
881
  /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
879
882
  /* @__PURE__ */ n(
880
883
  bn,
@@ -884,7 +887,7 @@ const Pn = ({
884
887
  }
885
888
  }
886
889
  )
887
- ] }, r)) : /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: u == null ? void 0 : u[0].label }) : /* @__PURE__ */ n("p", { className: "sa-input-dropdown-placeholder", children: y }), W = () => {
890
+ ] }, r)) : /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: u == null ? void 0 : u[0].label }) : /* @__PURE__ */ n("p", { className: "sa-input-dropdown-placeholder", children: k }), W = () => {
888
891
  if (rn.current && v.current) {
889
892
  const e = window.innerHeight, r = rn.current.getBoundingClientRect(), b = v.current.getBoundingClientRect(), x = r.bottom + b.height;
890
893
  v.current.style.left = `${r.left}px`, v.current.style.width = `${r.width}px`, x >= e - 10 ? (v.current.style.top = `${r.top - b.height - 5}px`, ln("top")) : (v.current.style.top = `${r.top + r.height + 4}px`, ln("bottom"));
@@ -935,7 +938,7 @@ const Pn = ({
935
938
  break;
936
939
  }
937
940
  }
938
- }, P = c === "lg" || c === "xl" ? 20 : c === "xs" ? 14 : 16, kn = a && !C ? /* @__PURE__ */ n(
941
+ }, P = c === "lg" || c === "xl" ? 20 : c === "xs" ? 14 : 16, yn = a && !C ? /* @__PURE__ */ n(
939
942
  "button",
940
943
  {
941
944
  type: "button",
@@ -945,7 +948,7 @@ const Pn = ({
945
948
  tabIndex: -1,
946
949
  onClick: gn,
947
950
  onMouseDown: (e) => e.preventDefault(),
948
- children: /* @__PURE__ */ n(Sn, { width: P, height: P })
951
+ children: /* @__PURE__ */ n(An, { width: P, height: P })
949
952
  }
950
953
  ) : null, Nn = d ? /* @__PURE__ */ l(tn, { children: [
951
954
  s && u.map((e, r) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
@@ -972,7 +975,7 @@ const Pn = ({
972
975
  value: cn,
973
976
  onChange: (e) => {
974
977
  const r = e.target.value;
975
- U(r), k == null || k(r), !w && I && R(!0);
978
+ U(r), y == null || y(r), !w && I && R(!0);
976
979
  },
977
980
  onFocus: () => {
978
981
  !C && I && R(!0);
@@ -981,7 +984,7 @@ const Pn = ({
981
984
  s || setTimeout(() => R(!1), 150);
982
985
  },
983
986
  onKeyDown: wn,
984
- placeholder: u.length === 0 || s ? y : void 0,
987
+ placeholder: u.length === 0 || s ? k : void 0,
985
988
  disabled: C
986
989
  }
987
990
  )
@@ -1019,8 +1022,8 @@ const Pn = ({
1019
1022
  width: P,
1020
1023
  style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 }
1021
1024
  }) : null,
1022
- /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: d ? Nn : yn() }),
1023
- kn,
1025
+ /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: d ? Nn : kn() }),
1026
+ yn,
1024
1027
  !_ && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-chevron", children: w ? /* @__PURE__ */ n(On, { width: P }) : /* @__PURE__ */ n(Mn, { width: P }) })
1025
1028
  ] }),
1026
1029
  I && /* @__PURE__ */ n(
@@ -1031,10 +1034,10 @@ const Pn = ({
1031
1034
  isComponentVisible: w,
1032
1035
  listboxId: G,
1033
1036
  positionDropdown: xn,
1034
- searchAble: !!S,
1037
+ searchAble: !!A,
1035
1038
  hideSearch: d,
1036
1039
  value: u,
1037
- onSearch: k,
1040
+ onSearch: y,
1038
1041
  ref: v,
1039
1042
  multiSelect: s,
1040
1043
  searchValue: d ? cn : $,
@@ -1080,15 +1083,15 @@ const Pn = ({
1080
1083
  L && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: L }),
1081
1084
  h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
1082
1085
  ] });
1083
- }, fn = (o, i, t) => {
1086
+ }, fn = (o, t, i) => {
1084
1087
  const p = o.length;
1085
- let c = i + t;
1088
+ let c = t + i;
1086
1089
  for (; c >= 0 && c < p; ) {
1087
1090
  if (!o[c].disable)
1088
1091
  return c;
1089
- c += t;
1092
+ c += i;
1090
1093
  }
1091
- if (t === 1) {
1094
+ if (i === 1) {
1092
1095
  for (let s = 0; s < p; s++)
1093
1096
  if (!o[s].disable)
1094
1097
  return s;
@@ -1097,7 +1100,7 @@ const Pn = ({
1097
1100
  if (!o[s].disable)
1098
1101
  return s;
1099
1102
  return -1;
1100
- }, Sn = (o) => /* @__PURE__ */ l("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o, children: [
1103
+ }, An = (o) => /* @__PURE__ */ l("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o, children: [
1101
1104
  /* @__PURE__ */ n("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor", opacity: "0.2" }),
1102
1105
  /* @__PURE__ */ n("path", { d: "M5.5 5.5l5 5M10.5 5.5l-5 5", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" })
1103
1106
  ] }), bn = (o) => /* @__PURE__ */ n(
@@ -1,4 +1,4 @@
1
- (function(g,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):(g=typeof globalThis<"u"?globalThis:g||self,n(g.Dropdown={},g.jsxRuntime,g.React))})(this,function(g,n,s){"use strict";const hn=`/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
1
+ (function(g,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):(g=typeof globalThis<"u"?globalThis:g||self,n(g.Dropdown={},g.jsxRuntime,g.React))})(this,function(g,n,s){"use strict";const fn=`/* 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,7 +24,10 @@
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
- --sa-dropdown-border-active: var(--sa-border-brand, #031f43);
27
+ /* State aktif/terbuka = kontrol yang SEDANG fokus → pakai border fokus
28
+ (--sa-border-focused: biru brand-500 di default, amber di skin tech,
29
+ biru terang di dark), bukan --sa-border-brand #031f43 yang nyaris hitam. */
30
+ --sa-dropdown-border-active: var(--sa-border-focused, #1a4fa0);
28
31
  --sa-dropdown-border-error-subtle: var(--sa-border-danger-subtle, #ffb3c1);
29
32
  --sa-dropdown-color-disable: var(--sa-text-disable, rgba(24, 26, 25, 0.56));
30
33
  --sa-dropdown-placeholder: var(--sa-text-subtle, #505258);
@@ -106,7 +109,7 @@
106
109
  border-radius: var(--borderRadius);
107
110
  }
108
111
  .sa-input-dropdown-container.standard.active {
109
- border: 1px solid var(--sa-dropdown-border-active);
112
+ border: 1px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
110
113
  box-shadow: var(--sa-dropdown-ring-active);
111
114
  }
112
115
  .sa-input-dropdown-container.standard.error {
@@ -124,12 +127,12 @@
124
127
  /* --- Outline variant --- */
125
128
  .sa-input-dropdown-container.outline {
126
129
  background-color: transparent;
127
- border: 1px solid var(--sa-dropdown-border-subtle);
130
+ border: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
128
131
  border-radius: var(--borderRadius);
129
132
  outline: none;
130
133
  }
131
134
  .sa-input-dropdown-container.outline.active {
132
- border: 1.2px solid var(--sa-dropdown-border-active);
135
+ border: 1.2px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
133
136
  box-shadow: none;
134
137
  }
135
138
  .sa-input-dropdown-container.outline.error {
@@ -138,7 +141,7 @@
138
141
  }
139
142
  .sa-input-dropdown-container.outline.disable {
140
143
  background-color: var(--sa-dropdown-bg-disabled);
141
- border-color: var(--sa-dropdown-border-subtle);
144
+ border-color: var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
142
145
  cursor: not-allowed;
143
146
  pointer-events: none;
144
147
  opacity: 0.6;
@@ -148,11 +151,11 @@
148
151
  .sa-input-dropdown-container.flushed {
149
152
  background-color: transparent;
150
153
  border: none;
151
- border-bottom: 1px solid var(--sa-dropdown-border-subtle);
154
+ border-bottom: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
152
155
  border-radius: 0;
153
156
  }
154
157
  .sa-input-dropdown-container.flushed.active {
155
- border-bottom: 1.2px solid var(--sa-dropdown-border-active);
158
+ border-bottom: 1.2px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
156
159
  box-shadow: none;
157
160
  }
158
161
  .sa-input-dropdown-container.flushed.error {
@@ -199,7 +202,7 @@
199
202
  }
200
203
 
201
204
  .sa-input-dropdown-preview-item {
202
- border: 1px solid var(--sa-dropdown-border-subtle);
205
+ border: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
203
206
  padding-inline: 8px;
204
207
  padding-block: 2px;
205
208
  border-radius: var(--sa-radii-xs, 4px);
@@ -277,7 +280,7 @@
277
280
  align-items: center;
278
281
  height: 32px;
279
282
  min-height: 32px;
280
- border-bottom: 1px solid var(--sa-dropdown-border-subtle);
283
+ border-bottom: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
281
284
  gap: 8px;
282
285
  padding-inline: 12px;
283
286
  padding-block: 8px;
@@ -308,7 +311,7 @@
308
311
  .sa-input-dropdown-lists-container.search-bottom > .sa-input-dropdown-container-dropdown-search {
309
312
  order: 2;
310
313
  border-bottom: none;
311
- border-top: 1px solid var(--sa-dropdown-border-subtle);
314
+ border-top: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
312
315
  }
313
316
  .sa-input-dropdown-lists-container.search-bottom > .sa-input-dropdown-footer {
314
317
  order: 3;
@@ -408,7 +411,7 @@
408
411
  }
409
412
  .sa-input-dropdown-item.highlight {
410
413
  background-color: var(--sa-dropdown-bg-selected);
411
- outline: 1.2px solid var(--sa-dropdown-border-active);
414
+ outline: 1.2px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
412
415
  outline-offset: -1.2px;
413
416
  }
414
417
  .sa-input-dropdown-item-disable {
@@ -453,7 +456,7 @@
453
456
  flex-shrink: 0;
454
457
  background: var(--sa-dropdown-bg);
455
458
  padding: 8px;
456
- border-top: 1px solid var(--sa-dropdown-border-subtle);
459
+ border-top: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
457
460
  }
458
461
 
459
462
  /* === SELECT FIELD WRAPPER === */
@@ -519,7 +522,7 @@
519
522
  display: inline-flex;
520
523
  align-items: center;
521
524
  padding: 0 8px;
522
- border: 1px solid var(--sa-dropdown-border-subtle);
525
+ border: 1px solid var(--sa-dropdown-border-subtle, var(--sa-border-subtle, rgba(5, 21, 36, 0.1)));
523
526
  border-radius: var(--sa-radii-xs, 4px);
524
527
  background: var(--sa-dropdown-bg-neutral);
525
528
  font-size: 10px;
@@ -581,4 +584,4 @@
581
584
  }
582
585
 
583
586
  } /* @layer starasia.components */
584
- `;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 un=({...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:T,multiSelect:y,searchValue:k,highlightedIndex:N,listboxId:M,footer:W,groupLabel:E,onSelectAll:$,emptyState:K},X)=>{const O=s.useRef([]),q=k!==void 0,[Y,Z]=s.useState(""),l=q?k: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(un,{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 ${y?"multi":""}`,role:"listbox",id:M,"aria-multiselectable":y||void 0,children:[H&&n.jsx("div",{className:"sa-input-dropdown-empty",children:K??(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}),y&&$&&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(D=>D.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:D=>{O.current[m]=D},onClick:()=>T(a.label,a.value),children:[y&&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})}),xn=({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)}})(hn);const gn=({dropdownLists:o,onChange:i,defaultValue:t,value:p,size:c="sm",multiSelect:d,searchAble:A,iconLeft:T,placeholder:y,onSearch:k,error:N,onBlur:M,onFocus:W,disable:E,searchValue:$,variant:K="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:D,optional:tn,description:S,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,dn]=s.useState(""),[u,nn]=s.useState(-1),G=s.useId(),ln=u>=0?`${G}-opt-${u}`:void 0,[pn,U]=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:h,ref:en,setIsComponentVisible:B}=fn(!1),I=o!==void 0,cn=w.length>0,Cn=e=>{e.stopPropagation();const r=[];z||L(r),i(r),l&&U(""),m==null||m()},zn=()=>{I&&B(e=>!e)},J=(e,r)=>{if(d){if(w==null?void 0:w.find(x=>x.value===r)){const x=w.filter(jn=>jn.value!==r);z||L(x),i(x)}else{const x=[...w,{label:e,value:r}];z||L(x),i(x)}l&&U("")}else{const b=[{label:e,value:r}];z||L(b),i(b),l&&U(H?"":e),B(!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 Bn=()=>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(),J(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:y}),F=()=>{if(en.current&&v.current){const e=window.innerHeight,r=en.current.getBoundingClientRect(),b=v.current.getBoundingClientRect(),x=r.bottom+b.height;v.current.style.left=`${r.left}px`,v.current.style.width=`${r.width}px`,x>=e-10?(v.current.style.top=`${r.top-b.height-5}px`,dn("top")):(v.current.style.top=`${r.top+r.height+4}px`,dn("bottom"))}};s.useEffect(()=>(window.addEventListener("resize",F),()=>{window.removeEventListener("resize",F)}),[]),s.useEffect(()=>{F()},[h]),s.useEffect(()=>{if(!h||!v.current)return;const e=new ResizeObserver(()=>{F()});return e.observe(v.current),()=>e.disconnect()},[h]),s.useEffect(()=>{h||nn(-1)},[h]);const wn=e=>{if(I){if(!h){(e.key==="ArrowDown"||e.key==="Enter")&&(e.preventDefault(),B(!0));return}switch(e.key){case"ArrowDown":{e.preventDefault();const r=an(o,u,1);r!==-1&&nn(r);break}case"ArrowUp":{e.preventDefault();const r=an(o,u,-1);r!==-1&&nn(r);break}case"Enter":{e.preventDefault(),u>=0&&o[u]&&!o[u].disable&&J(o[u].label,o[u].value);break}case"Escape":B(!1);break}}},P=c==="lg"||c==="xl"?20:c==="xs"?14:16,Dn=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:P,height:P})}):null,Sn=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(),J(e.label,e.value)}})]},r)),n.jsx("input",{className:"sa-input-dropdown-trigger-input",role:"combobox","aria-expanded":h,"aria-haspopup":"listbox","aria-controls":G,"aria-activedescendant":ln,"aria-autocomplete":"list",value:pn,onChange:e=>{const r=e.target.value;U(r),k==null||k(r),!h&&I&&B(!0)},onFocus:()=>{!E&&I&&B(!0)},onBlur:()=>{d||setTimeout(()=>B(!1),150)},onKeyDown:wn,placeholder:w.length===0||d?y:void 0,disabled:E})]}):null,on=n.jsx(xn,{handleChangePosition:F,enabled:h,children:n.jsxs("div",{className:["sa-input-dropdown-container",K,`sa-input-dropdown-size-${c}`,l?"trigger-input":"",h?"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:h,"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:[T?s.cloneElement(T,{width:P,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:l?Sn:Bn()}),Dn,!Q&&n.jsx("div",{className:"sa-input-dropdown-chevron",children:h?n.jsx(kn,{width:P}):n.jsx(yn,{width:P})})]}),I&&n.jsx(vn,{dropdownLists:o,handleChangeValue:J,isComponentVisible:h,listboxId:G,positionDropdown:En,searchAble:!!A,hideSearch:l,value:w,onSearch:k,ref:v,multiSelect:d,searchValue:l?pn:$,highlightedIndex:u,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}),tn&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),D&&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:[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}),tn&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),D&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S}),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:[S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S}),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"})}),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 6L8 10L12 6",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 10L8 6L12 10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});g.Dropdown=gn,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
587
+ `;function hn(o){const[d,t]=s.useState(o),p=s.useRef(null),c=i=>{p.current&&!p.current.contains(i.target)&&t(!1)};return s.useEffect(()=>(document.addEventListener("click",c,!0),()=>{document.removeEventListener("click",c,!0)}),[]),{ref:p,isComponentVisible:d,setIsComponentVisible:t}}const un=({...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:d,isComponentVisible:t,searchAble:p,hideSearch:c,onSearch:i,value:A,handleChangeValue:T,multiSelect:y,searchValue:k,highlightedIndex:N,listboxId:M,footer:W,groupLabel:E,onSelectAll:$,emptyState:K},X)=>{const O=s.useRef([]),q=k!==void 0,[Y,Z]=s.useState(""),l=q?k:Y,H=!d||d.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(un,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:a=>{q||Z(a.target.value),i&&i(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 ${y?"multi":""}`,role:"listbox",id:M,"aria-multiselectable":y||void 0,children:[H&&n.jsx("div",{className:"sa-input-dropdown-empty",children:K??(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}),y&&$&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:a=>{a.stopPropagation(),$()},children:"Select all"})]}),d==null?void 0:d.map((a,m)=>{const C=!!(A!=null&&A.find(S=>S.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:S=>{O.current[m]=S},onClick:()=>T(a.label,a.value),children:[y&&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})}),xn=({children:o,handleChangePosition:d,enabled:t=!0})=>(s.useEffect(()=>{if(t)return window.addEventListener("scroll",d,!0),()=>{window.removeEventListener("scroll",d,!0)}},[t,d]),n.jsx("div",{children:o})),rn="sa-input-dropdown-styles";(o=>{if(!(typeof document>"u")&&!document.getElementById(rn)){const d=document.createElement("style");d.id=rn,d.textContent=o,document.head.appendChild(d)}})(fn);const gn=({dropdownLists:o,onChange:d,defaultValue:t,value:p,size:c="sm",multiSelect:i,searchAble:A,iconLeft:T,placeholder:y,onSearch:k,error:N,onBlur:M,onFocus:W,disable:E,searchValue:$,variant:K="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:S,optional:dn,description:D,helperText:j,errorText:h})=>{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||!!h,[w,L]=s.useState(z?p||[]:t||[]),[En,tn]=s.useState(""),[u,nn]=s.useState(-1),G=s.useId(),ln=u>=0?`${G}-opt-${u}`:void 0,[pn,U]=s.useState(()=>{var e,r;return!i&&(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:f,ref:en,setIsComponentVisible:B}=hn(!1),I=o!==void 0,cn=w.length>0,Cn=e=>{e.stopPropagation();const r=[];z||L(r),d(r),l&&U(""),m==null||m()},zn=()=>{I&&B(e=>!e)},J=(e,r)=>{if(i){if(w==null?void 0:w.find(x=>x.value===r)){const x=w.filter(jn=>jn.value!==r);z||L(x),d(x)}else{const x=[...w,{label:e,value:r}];z||L(x),d(x)}l&&U("")}else{const b=[{label:e,value:r}];z||L(b),d(b),l&&U(H?"":e),B(!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 Bn=()=>w.length?i?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(),J(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:y}),F=()=>{if(en.current&&v.current){const e=window.innerHeight,r=en.current.getBoundingClientRect(),b=v.current.getBoundingClientRect(),x=r.bottom+b.height;v.current.style.left=`${r.left}px`,v.current.style.width=`${r.width}px`,x>=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",F),()=>{window.removeEventListener("resize",F)}),[]),s.useEffect(()=>{F()},[f]),s.useEffect(()=>{if(!f||!v.current)return;const e=new ResizeObserver(()=>{F()});return e.observe(v.current),()=>e.disconnect()},[f]),s.useEffect(()=>{f||nn(-1)},[f]);const wn=e=>{if(I){if(!f){(e.key==="ArrowDown"||e.key==="Enter")&&(e.preventDefault(),B(!0));return}switch(e.key){case"ArrowDown":{e.preventDefault();const r=an(o,u,1);r!==-1&&nn(r);break}case"ArrowUp":{e.preventDefault();const r=an(o,u,-1);r!==-1&&nn(r);break}case"Enter":{e.preventDefault(),u>=0&&o[u]&&!o[u].disable&&J(o[u].label,o[u].value);break}case"Escape":B(!1);break}}},P=c==="lg"||c==="xl"?20:c==="xs"?14:16,Sn=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:P,height:P})}):null,Dn=l?n.jsxs(n.Fragment,{children:[i&&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(),J(e.label,e.value)}})]},r)),n.jsx("input",{className:"sa-input-dropdown-trigger-input",role:"combobox","aria-expanded":f,"aria-haspopup":"listbox","aria-controls":G,"aria-activedescendant":ln,"aria-autocomplete":"list",value:pn,onChange:e=>{const r=e.target.value;U(r),k==null||k(r),!f&&I&&B(!0)},onFocus:()=>{!E&&I&&B(!0)},onBlur:()=>{i||setTimeout(()=>B(!1),150)},onKeyDown:wn,placeholder:w.length===0||i?y:void 0,disabled:E})]}):null,on=n.jsx(xn,{handleChangePosition:F,enabled:f,children:n.jsxs("div",{className:["sa-input-dropdown-container",K,`sa-input-dropdown-size-${c}`,l?"trigger-input":"",f?"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:f,"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:[T?s.cloneElement(T,{width:P,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:l?Dn:Bn()}),Sn,!Q&&n.jsx("div",{className:"sa-input-dropdown-chevron",children:f?n.jsx(kn,{width:P}):n.jsx(yn,{width:P})})]}),I&&n.jsx(vn,{dropdownLists:o,handleChangeValue:J,isComponentVisible:f,listboxId:G,positionDropdown:En,searchAble:!!A,hideSearch:l,value:w,onSearch:k,ref:v,multiSelect:i,searchValue:l?pn:$,highlightedIndex:u,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"}),S&&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&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:j}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]})]}):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"}),S&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),D&&n.jsx("p",{className:"sa-select-field-helper-top",children:D}),on,j&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:j}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]}):n.jsxs("div",{className:V,children:[D&&n.jsx("p",{className:"sa-select-field-helper-top",children:D}),on,j&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:j}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]})},an=(o,d,t)=>{const p=o.length;let c=d+t;for(;c>=0&&c<p;){if(!o[c].disable)return c;c+=t}if(t===1){for(let i=0;i<p;i++)if(!o[i].disable)return i}else for(let i=p-1;i>=0;i--)if(!o[i].disable)return i;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"})}),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 6L8 10L12 6",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 10L8 6L12 10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});g.Dropdown=gn,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/dropdown",
3
- "version": "6.1.0",
3
+ "version": "6.1.2",
4
4
  "description": "dropdown component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/dropdown.umd.js",
@@ -24,15 +24,15 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^20.11.16",
27
+ "@types/react": "^18.2.55",
28
+ "@types/react-dom": "^18.2.19",
27
29
  "@vitejs/plugin-react": "^4.2.1",
30
+ "react": "^18.2.0",
31
+ "react-dom": "^18.2.0",
28
32
  "tsconfig-paths": "^4.2.0",
29
33
  "typescript": "^5.3.3",
30
34
  "vite": "^5.0.12",
31
- "vite-plugin-dts": "^3.7.2",
32
- "react": "^18.2.0",
33
- "react-dom": "^18.2.0",
34
- "@types/react": "^18.2.55",
35
- "@types/react-dom": "^18.2.19"
35
+ "vite-plugin-dts": "^3.7.2"
36
36
  },
37
37
  "scripts": {
38
38
  "dev": "vite --config vite.config.ts --port 3000",