@starasia/dropdown 6.1.3 → 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.
- package/dist/dropdown.es.js +196 -155
- package/dist/dropdown.umd.js +47 -9
- package/package.json +1 -1
package/dist/dropdown.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as l, jsx as n, Fragment as tn } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
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-
|
|
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-
|
|
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 {
|
|
@@ -174,18 +187,19 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
174
187
|
display: flex;
|
|
175
188
|
flex-direction: row;
|
|
176
189
|
gap: 8px;
|
|
177
|
-
|
|
190
|
+
/* Single-line (combobox input, placeholder, single value) → center supaya
|
|
191
|
+
teks & chevron sejajar persis di tengah field. Kasus multiSelect yang
|
|
192
|
+
chip-nya bisa membungkus di-override ke flex-start di bawah. */
|
|
193
|
+
align-items: center;
|
|
178
194
|
justify-content: space-between;
|
|
179
195
|
width: 100%;
|
|
180
196
|
min-width: 0;
|
|
181
197
|
}
|
|
182
198
|
|
|
183
|
-
/* Chevron + clear button —
|
|
184
|
-
centered when single-line, and snap to top-right when content wraps */
|
|
199
|
+
/* Chevron + clear button — center di single-line (sejajar teks input). */
|
|
185
200
|
.sa-input-dropdown-chevron,
|
|
186
201
|
.sa-input-dropdown-clear {
|
|
187
|
-
align-self:
|
|
188
|
-
margin-top: var(--iconMarginTop, 4px);
|
|
202
|
+
align-self: center;
|
|
189
203
|
}
|
|
190
204
|
.sa-input-dropdown-chevron {
|
|
191
205
|
display: inline-flex;
|
|
@@ -194,6 +208,18 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
194
208
|
flex-shrink: 0;
|
|
195
209
|
}
|
|
196
210
|
|
|
211
|
+
/* multiSelect: chip bisa membungkus ke beberapa baris → tempel area chip &
|
|
212
|
+
chevron/clear ke baris ATAS, bukan center di blok tinggi yang membungkus.
|
|
213
|
+
Single-line tetap center (aturan di atas). */
|
|
214
|
+
.sa-input-dropdown-container.multiselect .sa-input-dropdown-preview-container {
|
|
215
|
+
align-items: flex-start;
|
|
216
|
+
}
|
|
217
|
+
.sa-input-dropdown-container.multiselect .sa-input-dropdown-chevron,
|
|
218
|
+
.sa-input-dropdown-container.multiselect .sa-input-dropdown-clear {
|
|
219
|
+
align-self: flex-start;
|
|
220
|
+
margin-top: var(--iconMarginTop, 4px);
|
|
221
|
+
}
|
|
222
|
+
|
|
197
223
|
.sa-input-dropdown-container-preview-item {
|
|
198
224
|
flex: 1;
|
|
199
225
|
display: flex;
|
|
@@ -585,15 +611,27 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
585
611
|
display: none;
|
|
586
612
|
}
|
|
587
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
|
+
|
|
588
626
|
} /* @layer starasia.components */
|
|
589
627
|
`;
|
|
590
628
|
function Rn(o) {
|
|
591
|
-
const [t,
|
|
592
|
-
p.current && !p.current.contains(
|
|
629
|
+
const [t, d] = A(o), p = J(null), c = (i) => {
|
|
630
|
+
p.current && !p.current.contains(i.target) && d(!1);
|
|
593
631
|
};
|
|
594
|
-
return
|
|
632
|
+
return x(() => (document.addEventListener("click", c, !0), () => {
|
|
595
633
|
document.removeEventListener("click", c, !0);
|
|
596
|
-
}), []), { ref: p, isComponentVisible: t, setIsComponentVisible:
|
|
634
|
+
}), []), { ref: p, isComponentVisible: t, setIsComponentVisible: d };
|
|
597
635
|
}
|
|
598
636
|
const Bn = ({ ...o }) => /* @__PURE__ */ l(
|
|
599
637
|
"svg",
|
|
@@ -646,29 +684,29 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
646
684
|
}
|
|
647
685
|
)
|
|
648
686
|
}
|
|
649
|
-
),
|
|
687
|
+
), jn = En(
|
|
650
688
|
({
|
|
651
689
|
positionDropdown: o,
|
|
652
690
|
dropdownLists: t,
|
|
653
|
-
isComponentVisible:
|
|
691
|
+
isComponentVisible: d,
|
|
654
692
|
searchAble: p,
|
|
655
693
|
hideSearch: c,
|
|
656
|
-
onSearch:
|
|
657
|
-
value:
|
|
658
|
-
handleChangeValue:
|
|
694
|
+
onSearch: i,
|
|
695
|
+
value: L,
|
|
696
|
+
handleChangeValue: P,
|
|
659
697
|
multiSelect: k,
|
|
660
698
|
searchValue: y,
|
|
661
699
|
highlightedIndex: N,
|
|
662
|
-
listboxId:
|
|
663
|
-
footer:
|
|
700
|
+
listboxId: I,
|
|
701
|
+
footer: T,
|
|
664
702
|
groupLabel: C,
|
|
665
|
-
onSelectAll:
|
|
703
|
+
onSelectAll: $,
|
|
666
704
|
emptyState: X
|
|
667
705
|
}, Y) => {
|
|
668
|
-
const
|
|
669
|
-
|
|
706
|
+
const M = J([]), q = y !== void 0, [Z, Q] = A(""), s = q ? y : Z, G = !t || t.length === 0;
|
|
707
|
+
x(() => {
|
|
670
708
|
var a;
|
|
671
|
-
N >= 0 &&
|
|
709
|
+
N >= 0 && M.current[N] && ((a = M.current[N]) == null || a.scrollIntoView({ block: "nearest" }));
|
|
672
710
|
}, [N]);
|
|
673
711
|
const _ = p && !c ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
|
|
674
712
|
/* @__PURE__ */ n(Bn, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
|
|
@@ -676,15 +714,15 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
676
714
|
"input",
|
|
677
715
|
{
|
|
678
716
|
onChange: (a) => {
|
|
679
|
-
q || Q(a.target.value),
|
|
717
|
+
q || Q(a.target.value), i && i(a.target.value);
|
|
680
718
|
},
|
|
681
|
-
value:
|
|
719
|
+
value: s,
|
|
682
720
|
autoFocus: !0,
|
|
683
721
|
placeholder: "Search..."
|
|
684
722
|
}
|
|
685
723
|
)
|
|
686
724
|
] }) : null;
|
|
687
|
-
return /* @__PURE__ */ n(tn, { children:
|
|
725
|
+
return /* @__PURE__ */ n(tn, { children: d ? /* @__PURE__ */ l(
|
|
688
726
|
"div",
|
|
689
727
|
{
|
|
690
728
|
className: [
|
|
@@ -705,33 +743,33 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
705
743
|
{
|
|
706
744
|
className: `sa-input-dropdown-item-container ${k ? "multi" : ""}`,
|
|
707
745
|
role: "listbox",
|
|
708
|
-
id:
|
|
746
|
+
id: I,
|
|
709
747
|
"aria-multiselectable": k || void 0,
|
|
710
748
|
children: [
|
|
711
|
-
|
|
749
|
+
G && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-empty", children: X ?? (s ? /* @__PURE__ */ l(tn, { children: [
|
|
712
750
|
"No results for",
|
|
713
751
|
" ",
|
|
714
752
|
/* @__PURE__ */ l("span", { className: "sa-input-dropdown-empty-query", children: [
|
|
715
753
|
"“",
|
|
716
|
-
|
|
754
|
+
s,
|
|
717
755
|
"”"
|
|
718
756
|
] })
|
|
719
757
|
] }) : "No data available") }),
|
|
720
|
-
C && !
|
|
758
|
+
C && !G && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
|
|
721
759
|
/* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: C }),
|
|
722
|
-
k &&
|
|
760
|
+
k && $ && /* @__PURE__ */ n(
|
|
723
761
|
"button",
|
|
724
762
|
{
|
|
725
763
|
className: "sa-input-dropdown-section-select-all",
|
|
726
764
|
onClick: (a) => {
|
|
727
|
-
a.stopPropagation(),
|
|
765
|
+
a.stopPropagation(), $();
|
|
728
766
|
},
|
|
729
767
|
children: "Select all"
|
|
730
768
|
}
|
|
731
769
|
)
|
|
732
770
|
] }),
|
|
733
771
|
t == null ? void 0 : t.map((a, m) => {
|
|
734
|
-
const E = !!(
|
|
772
|
+
const E = !!(L != null && L.find((B) => B.value === a.value)), V = !!a.description;
|
|
735
773
|
return /* @__PURE__ */ l(
|
|
736
774
|
"div",
|
|
737
775
|
{
|
|
@@ -742,17 +780,17 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
742
780
|
m === N ? "highlight" : "",
|
|
743
781
|
a.disable ? "sa-input-dropdown-item-disable" : ""
|
|
744
782
|
].filter(Boolean).join(" "),
|
|
745
|
-
id:
|
|
783
|
+
id: I ? `${I}-opt-${m}` : void 0,
|
|
746
784
|
role: "option",
|
|
747
785
|
"aria-selected": E,
|
|
748
786
|
"aria-disabled": a.disable || void 0,
|
|
749
787
|
ref: (B) => {
|
|
750
|
-
|
|
788
|
+
M.current[m] = B;
|
|
751
789
|
},
|
|
752
|
-
onClick: () =>
|
|
790
|
+
onClick: () => P(a.label, a.value),
|
|
753
791
|
children: [
|
|
754
792
|
k && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-item-check", children: E && /* @__PURE__ */ n(Dn, { width: 16 }) }),
|
|
755
|
-
a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children:
|
|
793
|
+
a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: dn.cloneElement(a.icon, { width: 16 }) }),
|
|
756
794
|
/* @__PURE__ */ l("div", { style: { minWidth: 0, flex: 1 }, children: [
|
|
757
795
|
/* @__PURE__ */ n(
|
|
758
796
|
"p",
|
|
@@ -783,51 +821,51 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
783
821
|
]
|
|
784
822
|
}
|
|
785
823
|
),
|
|
786
|
-
|
|
824
|
+
T && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (a) => a.stopPropagation(), children: T })
|
|
787
825
|
]
|
|
788
826
|
}
|
|
789
827
|
) : null });
|
|
790
828
|
}
|
|
791
|
-
),
|
|
829
|
+
), Sn = ({
|
|
792
830
|
children: o,
|
|
793
831
|
handleChangePosition: t,
|
|
794
|
-
enabled:
|
|
795
|
-
}) => (
|
|
796
|
-
if (
|
|
832
|
+
enabled: d = !0
|
|
833
|
+
}) => (x(() => {
|
|
834
|
+
if (d)
|
|
797
835
|
return window.addEventListener("scroll", t, !0), () => {
|
|
798
836
|
window.removeEventListener("scroll", t, !0);
|
|
799
837
|
};
|
|
800
|
-
}, [
|
|
838
|
+
}, [d, t]), /* @__PURE__ */ n("div", { children: o })), hn = "sa-input-dropdown-styles", An = (o) => {
|
|
801
839
|
if (!(typeof document > "u") && !document.getElementById(hn)) {
|
|
802
840
|
const t = document.createElement("style");
|
|
803
841
|
t.id = hn, t.textContent = o, document.head.appendChild(t);
|
|
804
842
|
}
|
|
805
843
|
};
|
|
806
|
-
|
|
807
|
-
const
|
|
844
|
+
An(zn);
|
|
845
|
+
const Fn = ({
|
|
808
846
|
dropdownLists: o,
|
|
809
847
|
onChange: t,
|
|
810
|
-
defaultValue:
|
|
848
|
+
defaultValue: d,
|
|
811
849
|
value: p,
|
|
812
850
|
size: c = "sm",
|
|
813
|
-
multiSelect:
|
|
814
|
-
searchAble:
|
|
815
|
-
iconLeft:
|
|
851
|
+
multiSelect: i,
|
|
852
|
+
searchAble: L,
|
|
853
|
+
iconLeft: P,
|
|
816
854
|
placeholder: k,
|
|
817
855
|
onSearch: y,
|
|
818
856
|
error: N,
|
|
819
|
-
onBlur:
|
|
820
|
-
onFocus:
|
|
857
|
+
onBlur: I,
|
|
858
|
+
onFocus: T,
|
|
821
859
|
disable: C,
|
|
822
|
-
searchValue:
|
|
860
|
+
searchValue: $,
|
|
823
861
|
variant: X = "outline",
|
|
824
862
|
footer: Y,
|
|
825
|
-
groupLabel:
|
|
863
|
+
groupLabel: M,
|
|
826
864
|
onSelectAll: q,
|
|
827
865
|
emptyState: Z,
|
|
828
866
|
fullWidth: Q = !0,
|
|
829
|
-
triggerInput:
|
|
830
|
-
clearOnSelect:
|
|
867
|
+
triggerInput: s = !1,
|
|
868
|
+
clearOnSelect: G = !1,
|
|
831
869
|
hideChevronIcon: _ = !1,
|
|
832
870
|
clearable: a = !1,
|
|
833
871
|
onClear: m,
|
|
@@ -835,80 +873,80 @@ const Pn = ({
|
|
|
835
873
|
label: E,
|
|
836
874
|
labelPosition: V = "outside-top",
|
|
837
875
|
required: B,
|
|
838
|
-
optional:
|
|
876
|
+
optional: sn,
|
|
839
877
|
description: D,
|
|
840
|
-
helperText:
|
|
878
|
+
helperText: j,
|
|
841
879
|
errorText: h
|
|
842
880
|
}) => {
|
|
843
881
|
const nn = [
|
|
844
882
|
"sa-select-field",
|
|
845
883
|
`sa-select-field-size-${c}`,
|
|
846
884
|
Q ? "sa-select-field-fullwidth" : ""
|
|
847
|
-
].filter(Boolean).join(" "), z = p !== void 0, en =
|
|
848
|
-
z ? p || [] :
|
|
849
|
-
), [
|
|
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(
|
|
850
888
|
() => {
|
|
851
889
|
var e, r;
|
|
852
|
-
return !
|
|
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) ?? "" : "";
|
|
853
891
|
}
|
|
854
|
-
), v =
|
|
892
|
+
), v = J(null), { isComponentVisible: w, ref: rn, setIsComponentVisible: R } = Rn(!1), O = o !== void 0, un = u.length > 0, xn = (e) => {
|
|
855
893
|
e.stopPropagation();
|
|
856
894
|
const r = [];
|
|
857
|
-
z ||
|
|
895
|
+
z || S(r), t(r), s && K(""), m == null || m();
|
|
858
896
|
}, mn = () => {
|
|
859
|
-
|
|
860
|
-
},
|
|
861
|
-
if (
|
|
862
|
-
if (u == null ? void 0 : u.find((
|
|
863
|
-
const
|
|
864
|
-
z ||
|
|
897
|
+
O && R((e) => !e);
|
|
898
|
+
}, U = (e, r) => {
|
|
899
|
+
if (i) {
|
|
900
|
+
if (u == null ? void 0 : u.find((g) => g.value === r)) {
|
|
901
|
+
const g = u.filter((Cn) => Cn.value !== r);
|
|
902
|
+
z || S(g), t(g);
|
|
865
903
|
} else {
|
|
866
|
-
const
|
|
867
|
-
z ||
|
|
904
|
+
const g = [...u, { label: e, value: r }];
|
|
905
|
+
z || S(g), t(g);
|
|
868
906
|
}
|
|
869
|
-
|
|
907
|
+
s && K("");
|
|
870
908
|
} else {
|
|
871
|
-
const
|
|
872
|
-
z ||
|
|
909
|
+
const f = [{ label: e, value: r }];
|
|
910
|
+
z || S(f), t(f), s && K(G ? "" : e), R(!1);
|
|
873
911
|
}
|
|
874
912
|
};
|
|
875
|
-
|
|
876
|
-
z &&
|
|
877
|
-
}, [p]),
|
|
878
|
-
z || JSON.stringify(en.current) === JSON.stringify(
|
|
879
|
-
}, [
|
|
880
|
-
const kn = () => u.length ?
|
|
913
|
+
x(() => {
|
|
914
|
+
z && S(p || []);
|
|
915
|
+
}, [p]), x(() => {
|
|
916
|
+
z || JSON.stringify(en.current) === JSON.stringify(d) || (en.current = d, S(en.current || []));
|
|
917
|
+
}, [d]);
|
|
918
|
+
const kn = () => u.length ? i ? u == null ? void 0 : u.map((e, r) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
|
|
881
919
|
/* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
|
|
882
920
|
/* @__PURE__ */ n(
|
|
883
|
-
|
|
921
|
+
fn,
|
|
884
922
|
{
|
|
885
|
-
onClick: (
|
|
886
|
-
|
|
923
|
+
onClick: (f) => {
|
|
924
|
+
f.stopPropagation(), U(e.label, e.value);
|
|
887
925
|
}
|
|
888
926
|
}
|
|
889
927
|
)
|
|
890
928
|
] }, 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 = () => {
|
|
891
929
|
if (rn.current && v.current) {
|
|
892
|
-
const e = window.innerHeight, r = rn.current.getBoundingClientRect(),
|
|
893
|
-
v.current.style.left = `${r.left}px`, v.current.style.width = `${r.width}px`,
|
|
930
|
+
const e = window.innerHeight, r = rn.current.getBoundingClientRect(), f = v.current.getBoundingClientRect(), g = r.bottom + f.height;
|
|
931
|
+
v.current.style.left = `${r.left}px`, v.current.style.width = `${r.width}px`, g >= e - 10 ? (v.current.style.top = `${r.top - f.height - 5}px`, ln("top")) : (v.current.style.top = `${r.top + r.height + 4}px`, ln("bottom"));
|
|
894
932
|
}
|
|
895
933
|
};
|
|
896
|
-
|
|
934
|
+
x(() => (window.addEventListener("resize", W), () => {
|
|
897
935
|
window.removeEventListener("resize", W);
|
|
898
|
-
}), []),
|
|
936
|
+
}), []), x(() => {
|
|
899
937
|
W();
|
|
900
|
-
}, [w]),
|
|
938
|
+
}, [w]), x(() => {
|
|
901
939
|
if (!w || !v.current)
|
|
902
940
|
return;
|
|
903
941
|
const e = new ResizeObserver(() => {
|
|
904
942
|
W();
|
|
905
943
|
});
|
|
906
944
|
return e.observe(v.current), () => e.disconnect();
|
|
907
|
-
}, [w]),
|
|
945
|
+
}, [w]), x(() => {
|
|
908
946
|
w || on(-1);
|
|
909
947
|
}, [w]);
|
|
910
948
|
const wn = (e) => {
|
|
911
|
-
if (
|
|
949
|
+
if (O) {
|
|
912
950
|
if (!w) {
|
|
913
951
|
(e.key === "ArrowDown" || e.key === "Enter") && (e.preventDefault(), R(!0));
|
|
914
952
|
return;
|
|
@@ -916,20 +954,20 @@ const Pn = ({
|
|
|
916
954
|
switch (e.key) {
|
|
917
955
|
case "ArrowDown": {
|
|
918
956
|
e.preventDefault();
|
|
919
|
-
const r =
|
|
957
|
+
const r = bn(o, b, 1);
|
|
920
958
|
r !== -1 && on(r);
|
|
921
959
|
break;
|
|
922
960
|
}
|
|
923
961
|
case "ArrowUp": {
|
|
924
962
|
e.preventDefault();
|
|
925
|
-
const r =
|
|
963
|
+
const r = bn(o, b, -1);
|
|
926
964
|
r !== -1 && on(r);
|
|
927
965
|
break;
|
|
928
966
|
}
|
|
929
967
|
case "Enter": {
|
|
930
|
-
e.preventDefault(),
|
|
931
|
-
o[
|
|
932
|
-
o[
|
|
968
|
+
e.preventDefault(), b >= 0 && o[b] && !o[b].disable && U(
|
|
969
|
+
o[b].label,
|
|
970
|
+
o[b].value
|
|
933
971
|
);
|
|
934
972
|
break;
|
|
935
973
|
}
|
|
@@ -938,7 +976,7 @@ const Pn = ({
|
|
|
938
976
|
break;
|
|
939
977
|
}
|
|
940
978
|
}
|
|
941
|
-
},
|
|
979
|
+
}, F = c === "lg" || c === "xl" ? 20 : c === "xs" ? 14 : 16, yn = a && !C ? /* @__PURE__ */ n(
|
|
942
980
|
"button",
|
|
943
981
|
{
|
|
944
982
|
type: "button",
|
|
@@ -946,18 +984,18 @@ const Pn = ({
|
|
|
946
984
|
"aria-label": "Clear selection",
|
|
947
985
|
"aria-hidden": !un,
|
|
948
986
|
tabIndex: -1,
|
|
949
|
-
onClick:
|
|
987
|
+
onClick: xn,
|
|
950
988
|
onMouseDown: (e) => e.preventDefault(),
|
|
951
|
-
children: /* @__PURE__ */ n(
|
|
989
|
+
children: /* @__PURE__ */ n(Ln, { width: F, height: F })
|
|
952
990
|
}
|
|
953
|
-
) : null, Nn =
|
|
954
|
-
|
|
991
|
+
) : null, Nn = s ? /* @__PURE__ */ l(tn, { children: [
|
|
992
|
+
i && u.map((e, r) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
|
|
955
993
|
/* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
|
|
956
994
|
/* @__PURE__ */ n(
|
|
957
|
-
|
|
995
|
+
fn,
|
|
958
996
|
{
|
|
959
|
-
onClick: (
|
|
960
|
-
|
|
997
|
+
onClick: (f) => {
|
|
998
|
+
f.stopPropagation(), U(e.label, e.value);
|
|
961
999
|
}
|
|
962
1000
|
}
|
|
963
1001
|
)
|
|
@@ -969,27 +1007,27 @@ const Pn = ({
|
|
|
969
1007
|
role: "combobox",
|
|
970
1008
|
"aria-expanded": w,
|
|
971
1009
|
"aria-haspopup": "listbox",
|
|
972
|
-
"aria-controls":
|
|
1010
|
+
"aria-controls": H,
|
|
973
1011
|
"aria-activedescendant": pn,
|
|
974
1012
|
"aria-autocomplete": "list",
|
|
975
1013
|
value: cn,
|
|
976
1014
|
onChange: (e) => {
|
|
977
1015
|
const r = e.target.value;
|
|
978
|
-
|
|
1016
|
+
K(r), y == null || y(r), !w && O && R(!0);
|
|
979
1017
|
},
|
|
980
1018
|
onFocus: () => {
|
|
981
|
-
!C &&
|
|
1019
|
+
!C && O && R(!0);
|
|
982
1020
|
},
|
|
983
1021
|
onBlur: () => {
|
|
984
|
-
|
|
1022
|
+
i || setTimeout(() => R(!1), 150);
|
|
985
1023
|
},
|
|
986
1024
|
onKeyDown: wn,
|
|
987
|
-
placeholder: u.length === 0 ||
|
|
1025
|
+
placeholder: u.length === 0 || i ? k : void 0,
|
|
988
1026
|
disabled: C
|
|
989
1027
|
}
|
|
990
1028
|
)
|
|
991
1029
|
] }) : null, an = /* @__PURE__ */ n(
|
|
992
|
-
|
|
1030
|
+
Sn,
|
|
993
1031
|
{
|
|
994
1032
|
handleChangePosition: W,
|
|
995
1033
|
enabled: w,
|
|
@@ -1002,50 +1040,53 @@ const Pn = ({
|
|
|
1002
1040
|
// bentrok dgn utility Tailwind/shadcn (mis. `.outline`) → outline gelap.
|
|
1003
1041
|
`sa-input-dropdown-${X}`,
|
|
1004
1042
|
`sa-input-dropdown-size-${c}`,
|
|
1005
|
-
|
|
1043
|
+
s ? "trigger-input" : "",
|
|
1044
|
+
// multiSelect = chip bisa membungkus → CSS tempel chevron/clear ke
|
|
1045
|
+
// baris atas; single-line tetap center (fix combobox kelihatan naik).
|
|
1046
|
+
i ? "multiselect" : "",
|
|
1006
1047
|
w ? "active" : "",
|
|
1007
1048
|
vn ? "error" : "",
|
|
1008
1049
|
C ? "disable" : ""
|
|
1009
1050
|
].filter(Boolean).join(" "),
|
|
1010
1051
|
ref: rn,
|
|
1011
|
-
role:
|
|
1012
|
-
"aria-haspopup":
|
|
1013
|
-
"aria-expanded":
|
|
1014
|
-
"aria-controls":
|
|
1015
|
-
"aria-activedescendant":
|
|
1016
|
-
onClick:
|
|
1017
|
-
onKeyDown:
|
|
1018
|
-
tabIndex:
|
|
1019
|
-
onBlur:
|
|
1020
|
-
onFocus:
|
|
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,
|
|
1021
1062
|
children: [
|
|
1022
1063
|
/* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-container", children: [
|
|
1023
|
-
|
|
1024
|
-
width:
|
|
1064
|
+
P ? dn.cloneElement(P, {
|
|
1065
|
+
width: F,
|
|
1025
1066
|
style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 }
|
|
1026
1067
|
}) : null,
|
|
1027
|
-
/* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children:
|
|
1068
|
+
/* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: s ? Nn : kn() }),
|
|
1028
1069
|
yn,
|
|
1029
|
-
!_ && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-chevron", children: w ? /* @__PURE__ */ n(
|
|
1070
|
+
!_ && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-chevron", children: w ? /* @__PURE__ */ n(Mn, { width: F }) : /* @__PURE__ */ n(In, { width: F }) })
|
|
1030
1071
|
] }),
|
|
1031
|
-
|
|
1032
|
-
|
|
1072
|
+
O && /* @__PURE__ */ n(
|
|
1073
|
+
jn,
|
|
1033
1074
|
{
|
|
1034
1075
|
dropdownLists: o,
|
|
1035
|
-
handleChangeValue:
|
|
1076
|
+
handleChangeValue: U,
|
|
1036
1077
|
isComponentVisible: w,
|
|
1037
|
-
listboxId:
|
|
1038
|
-
positionDropdown:
|
|
1039
|
-
searchAble: !!
|
|
1040
|
-
hideSearch:
|
|
1078
|
+
listboxId: H,
|
|
1079
|
+
positionDropdown: gn,
|
|
1080
|
+
searchAble: !!L,
|
|
1081
|
+
hideSearch: s,
|
|
1041
1082
|
value: u,
|
|
1042
1083
|
onSearch: y,
|
|
1043
1084
|
ref: v,
|
|
1044
|
-
multiSelect:
|
|
1045
|
-
searchValue:
|
|
1046
|
-
highlightedIndex:
|
|
1085
|
+
multiSelect: i,
|
|
1086
|
+
searchValue: s ? cn : $,
|
|
1087
|
+
highlightedIndex: b,
|
|
1047
1088
|
footer: Y,
|
|
1048
|
-
groupLabel:
|
|
1089
|
+
groupLabel: M,
|
|
1049
1090
|
onSelectAll: q,
|
|
1050
1091
|
emptyState: Z
|
|
1051
1092
|
}
|
|
@@ -1059,53 +1100,53 @@ const Pn = ({
|
|
|
1059
1100
|
/* @__PURE__ */ l("div", { className: "sa-select-field-left-label", children: [
|
|
1060
1101
|
/* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
|
|
1061
1102
|
/* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: E }),
|
|
1062
|
-
|
|
1103
|
+
sn && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
|
|
1063
1104
|
B && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
|
|
1064
1105
|
] }),
|
|
1065
1106
|
D && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: D })
|
|
1066
1107
|
] }),
|
|
1067
1108
|
/* @__PURE__ */ l("div", { className: "sa-select-field-input-wrap", children: [
|
|
1068
1109
|
an,
|
|
1069
|
-
|
|
1110
|
+
j && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: j }),
|
|
1070
1111
|
h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
|
|
1071
1112
|
] })
|
|
1072
1113
|
] }) : /* @__PURE__ */ l("div", { className: nn, children: [
|
|
1073
1114
|
/* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
|
|
1074
1115
|
/* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: E }),
|
|
1075
|
-
|
|
1116
|
+
sn && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
|
|
1076
1117
|
B && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
|
|
1077
1118
|
] }),
|
|
1078
1119
|
D && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: D }),
|
|
1079
1120
|
an,
|
|
1080
|
-
|
|
1121
|
+
j && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: j }),
|
|
1081
1122
|
h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
|
|
1082
1123
|
] }) : /* @__PURE__ */ l("div", { className: nn, children: [
|
|
1083
1124
|
D && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: D }),
|
|
1084
1125
|
an,
|
|
1085
|
-
|
|
1126
|
+
j && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: j }),
|
|
1086
1127
|
h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
|
|
1087
1128
|
] });
|
|
1088
|
-
},
|
|
1129
|
+
}, bn = (o, t, d) => {
|
|
1089
1130
|
const p = o.length;
|
|
1090
|
-
let c = t +
|
|
1131
|
+
let c = t + d;
|
|
1091
1132
|
for (; c >= 0 && c < p; ) {
|
|
1092
1133
|
if (!o[c].disable)
|
|
1093
1134
|
return c;
|
|
1094
|
-
c +=
|
|
1135
|
+
c += d;
|
|
1095
1136
|
}
|
|
1096
|
-
if (
|
|
1097
|
-
for (let
|
|
1098
|
-
if (!o[
|
|
1099
|
-
return
|
|
1137
|
+
if (d === 1) {
|
|
1138
|
+
for (let i = 0; i < p; i++)
|
|
1139
|
+
if (!o[i].disable)
|
|
1140
|
+
return i;
|
|
1100
1141
|
} else
|
|
1101
|
-
for (let
|
|
1102
|
-
if (!o[
|
|
1103
|
-
return
|
|
1142
|
+
for (let i = p - 1; i >= 0; i--)
|
|
1143
|
+
if (!o[i].disable)
|
|
1144
|
+
return i;
|
|
1104
1145
|
return -1;
|
|
1105
|
-
},
|
|
1146
|
+
}, Ln = (o) => /* @__PURE__ */ l("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o, children: [
|
|
1106
1147
|
/* @__PURE__ */ n("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor", opacity: "0.2" }),
|
|
1107
1148
|
/* @__PURE__ */ n("path", { d: "M5.5 5.5l5 5M10.5 5.5l-5 5", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" })
|
|
1108
|
-
] }),
|
|
1149
|
+
] }), fn = (o) => /* @__PURE__ */ n(
|
|
1109
1150
|
"svg",
|
|
1110
1151
|
{
|
|
1111
1152
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1126,7 +1167,7 @@ const Pn = ({
|
|
|
1126
1167
|
}
|
|
1127
1168
|
)
|
|
1128
1169
|
}
|
|
1129
|
-
),
|
|
1170
|
+
), In = ({ width: o = 16 }) => /* @__PURE__ */ n(
|
|
1130
1171
|
"svg",
|
|
1131
1172
|
{
|
|
1132
1173
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1146,7 +1187,7 @@ const Pn = ({
|
|
|
1146
1187
|
}
|
|
1147
1188
|
)
|
|
1148
1189
|
}
|
|
1149
|
-
),
|
|
1190
|
+
), Mn = ({ width: o = 16 }) => /* @__PURE__ */ n(
|
|
1150
1191
|
"svg",
|
|
1151
1192
|
{
|
|
1152
1193
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1168,5 +1209,5 @@ const Pn = ({
|
|
|
1168
1209
|
}
|
|
1169
1210
|
);
|
|
1170
1211
|
export {
|
|
1171
|
-
|
|
1212
|
+
Fn as Dropdown
|
|
1172
1213
|
};
|
package/dist/dropdown.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
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-
|
|
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-
|
|
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 {
|
|
@@ -172,18 +185,19 @@
|
|
|
172
185
|
display: flex;
|
|
173
186
|
flex-direction: row;
|
|
174
187
|
gap: 8px;
|
|
175
|
-
|
|
188
|
+
/* Single-line (combobox input, placeholder, single value) → center supaya
|
|
189
|
+
teks & chevron sejajar persis di tengah field. Kasus multiSelect yang
|
|
190
|
+
chip-nya bisa membungkus di-override ke flex-start di bawah. */
|
|
191
|
+
align-items: center;
|
|
176
192
|
justify-content: space-between;
|
|
177
193
|
width: 100%;
|
|
178
194
|
min-width: 0;
|
|
179
195
|
}
|
|
180
196
|
|
|
181
|
-
/* Chevron + clear button —
|
|
182
|
-
centered when single-line, and snap to top-right when content wraps */
|
|
197
|
+
/* Chevron + clear button — center di single-line (sejajar teks input). */
|
|
183
198
|
.sa-input-dropdown-chevron,
|
|
184
199
|
.sa-input-dropdown-clear {
|
|
185
|
-
align-self:
|
|
186
|
-
margin-top: var(--iconMarginTop, 4px);
|
|
200
|
+
align-self: center;
|
|
187
201
|
}
|
|
188
202
|
.sa-input-dropdown-chevron {
|
|
189
203
|
display: inline-flex;
|
|
@@ -192,6 +206,18 @@
|
|
|
192
206
|
flex-shrink: 0;
|
|
193
207
|
}
|
|
194
208
|
|
|
209
|
+
/* multiSelect: chip bisa membungkus ke beberapa baris → tempel area chip &
|
|
210
|
+
chevron/clear ke baris ATAS, bukan center di blok tinggi yang membungkus.
|
|
211
|
+
Single-line tetap center (aturan di atas). */
|
|
212
|
+
.sa-input-dropdown-container.multiselect .sa-input-dropdown-preview-container {
|
|
213
|
+
align-items: flex-start;
|
|
214
|
+
}
|
|
215
|
+
.sa-input-dropdown-container.multiselect .sa-input-dropdown-chevron,
|
|
216
|
+
.sa-input-dropdown-container.multiselect .sa-input-dropdown-clear {
|
|
217
|
+
align-self: flex-start;
|
|
218
|
+
margin-top: var(--iconMarginTop, 4px);
|
|
219
|
+
}
|
|
220
|
+
|
|
195
221
|
.sa-input-dropdown-container-preview-item {
|
|
196
222
|
flex: 1;
|
|
197
223
|
display: flex;
|
|
@@ -583,5 +609,17 @@
|
|
|
583
609
|
display: none;
|
|
584
610
|
}
|
|
585
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
|
+
|
|
586
624
|
} /* @layer starasia.components */
|
|
587
|
-
`;function fn(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 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: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(hn,{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)}})(un);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: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,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:u,ref:en,setIsComponentVisible:B}=fn(!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()},[u]),s.useEffect(()=>{if(!u||!v.current)return;const e=new ResizeObserver(()=>{F()});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(),B(!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&&J(o[h].label,o[h].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":u,"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),!u&&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:u,children:n.jsxs("div",{className:["sa-input-dropdown-container",`sa-input-dropdown-${K}`,`sa-input-dropdown-size-${c}`,l?"trigger-input":"",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:[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:u?n.jsx(kn,{width:P}):n.jsx(yn,{width:P})})]}),I&&n.jsx(vn,{dropdownLists:o,handleChangeValue:J,isComponentVisible:u,listboxId:G,positionDropdown:En,searchAble:!!A,hideSearch:l,value:w,onSearch:k,ref:v,multiSelect:i,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"}),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&&!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"}),S&&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,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"})});
|
|
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"})});
|