@starasia/dropdown 6.1.1 → 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.
- package/dist/dropdown.es.js +42 -42
- package/dist/dropdown.umd.js +14 -14
- package/package.json +1 -1
package/dist/dropdown.es.js
CHANGED
|
@@ -111,7 +111,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
111
111
|
border-radius: var(--borderRadius);
|
|
112
112
|
}
|
|
113
113
|
.sa-input-dropdown-container.standard.active {
|
|
114
|
-
border: 1px solid var(--sa-dropdown-border-active);
|
|
114
|
+
border: 1px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
|
|
115
115
|
box-shadow: var(--sa-dropdown-ring-active);
|
|
116
116
|
}
|
|
117
117
|
.sa-input-dropdown-container.standard.error {
|
|
@@ -129,12 +129,12 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
129
129
|
/* --- Outline variant --- */
|
|
130
130
|
.sa-input-dropdown-container.outline {
|
|
131
131
|
background-color: transparent;
|
|
132
|
-
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)));
|
|
133
133
|
border-radius: var(--borderRadius);
|
|
134
134
|
outline: none;
|
|
135
135
|
}
|
|
136
136
|
.sa-input-dropdown-container.outline.active {
|
|
137
|
-
border: 1.2px solid var(--sa-dropdown-border-active);
|
|
137
|
+
border: 1.2px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
|
|
138
138
|
box-shadow: none;
|
|
139
139
|
}
|
|
140
140
|
.sa-input-dropdown-container.outline.error {
|
|
@@ -143,7 +143,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
143
143
|
}
|
|
144
144
|
.sa-input-dropdown-container.outline.disable {
|
|
145
145
|
background-color: var(--sa-dropdown-bg-disabled);
|
|
146
|
-
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)));
|
|
147
147
|
cursor: not-allowed;
|
|
148
148
|
pointer-events: none;
|
|
149
149
|
opacity: 0.6;
|
|
@@ -153,11 +153,11 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
153
153
|
.sa-input-dropdown-container.flushed {
|
|
154
154
|
background-color: transparent;
|
|
155
155
|
border: none;
|
|
156
|
-
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)));
|
|
157
157
|
border-radius: 0;
|
|
158
158
|
}
|
|
159
159
|
.sa-input-dropdown-container.flushed.active {
|
|
160
|
-
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));
|
|
161
161
|
box-shadow: none;
|
|
162
162
|
}
|
|
163
163
|
.sa-input-dropdown-container.flushed.error {
|
|
@@ -204,7 +204,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
.sa-input-dropdown-preview-item {
|
|
207
|
-
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)));
|
|
208
208
|
padding-inline: 8px;
|
|
209
209
|
padding-block: 2px;
|
|
210
210
|
border-radius: var(--sa-radii-xs, 4px);
|
|
@@ -282,7 +282,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
282
282
|
align-items: center;
|
|
283
283
|
height: 32px;
|
|
284
284
|
min-height: 32px;
|
|
285
|
-
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)));
|
|
286
286
|
gap: 8px;
|
|
287
287
|
padding-inline: 12px;
|
|
288
288
|
padding-block: 8px;
|
|
@@ -313,7 +313,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
313
313
|
.sa-input-dropdown-lists-container.search-bottom > .sa-input-dropdown-container-dropdown-search {
|
|
314
314
|
order: 2;
|
|
315
315
|
border-bottom: none;
|
|
316
|
-
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)));
|
|
317
317
|
}
|
|
318
318
|
.sa-input-dropdown-lists-container.search-bottom > .sa-input-dropdown-footer {
|
|
319
319
|
order: 3;
|
|
@@ -413,7 +413,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
413
413
|
}
|
|
414
414
|
.sa-input-dropdown-item.highlight {
|
|
415
415
|
background-color: var(--sa-dropdown-bg-selected);
|
|
416
|
-
outline: 1.2px solid var(--sa-dropdown-border-active);
|
|
416
|
+
outline: 1.2px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
|
|
417
417
|
outline-offset: -1.2px;
|
|
418
418
|
}
|
|
419
419
|
.sa-input-dropdown-item-disable {
|
|
@@ -458,7 +458,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
458
458
|
flex-shrink: 0;
|
|
459
459
|
background: var(--sa-dropdown-bg);
|
|
460
460
|
padding: 8px;
|
|
461
|
-
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)));
|
|
462
462
|
}
|
|
463
463
|
|
|
464
464
|
/* === SELECT FIELD WRAPPER === */
|
|
@@ -524,7 +524,7 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
524
524
|
display: inline-flex;
|
|
525
525
|
align-items: center;
|
|
526
526
|
padding: 0 8px;
|
|
527
|
-
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)));
|
|
528
528
|
border-radius: var(--sa-radii-xs, 4px);
|
|
529
529
|
background: var(--sa-dropdown-bg-neutral);
|
|
530
530
|
font-size: 10px;
|
|
@@ -588,12 +588,12 @@ const zn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
|
|
|
588
588
|
} /* @layer starasia.components */
|
|
589
589
|
`;
|
|
590
590
|
function Rn(o) {
|
|
591
|
-
const [
|
|
592
|
-
p.current && !p.current.contains(s.target) &&
|
|
591
|
+
const [t, i] = S(o), p = K(null), c = (s) => {
|
|
592
|
+
p.current && !p.current.contains(s.target) && i(!1);
|
|
593
593
|
};
|
|
594
594
|
return g(() => (document.addEventListener("click", c, !0), () => {
|
|
595
595
|
document.removeEventListener("click", c, !0);
|
|
596
|
-
}), []), { ref: p, isComponentVisible:
|
|
596
|
+
}), []), { ref: p, isComponentVisible: t, setIsComponentVisible: i };
|
|
597
597
|
}
|
|
598
598
|
const Bn = ({ ...o }) => /* @__PURE__ */ l(
|
|
599
599
|
"svg",
|
|
@@ -649,8 +649,8 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
649
649
|
), Ln = En(
|
|
650
650
|
({
|
|
651
651
|
positionDropdown: o,
|
|
652
|
-
dropdownLists:
|
|
653
|
-
isComponentVisible:
|
|
652
|
+
dropdownLists: t,
|
|
653
|
+
isComponentVisible: i,
|
|
654
654
|
searchAble: p,
|
|
655
655
|
hideSearch: c,
|
|
656
656
|
onSearch: s,
|
|
@@ -665,7 +665,7 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
665
665
|
onSelectAll: $,
|
|
666
666
|
emptyState: X
|
|
667
667
|
}, Y) => {
|
|
668
|
-
const O = K([]), q = y !== void 0, [Z, Q] = S(""), d = q ? y : Z, H = !
|
|
668
|
+
const O = K([]), q = y !== void 0, [Z, Q] = S(""), d = q ? y : Z, H = !t || t.length === 0;
|
|
669
669
|
g(() => {
|
|
670
670
|
var a;
|
|
671
671
|
N >= 0 && O.current[N] && ((a = O.current[N]) == null || a.scrollIntoView({ block: "nearest" }));
|
|
@@ -684,7 +684,7 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
684
684
|
}
|
|
685
685
|
)
|
|
686
686
|
] }) : null;
|
|
687
|
-
return /* @__PURE__ */ n(tn, { children:
|
|
687
|
+
return /* @__PURE__ */ n(tn, { children: i ? /* @__PURE__ */ l(
|
|
688
688
|
"div",
|
|
689
689
|
{
|
|
690
690
|
className: [
|
|
@@ -730,7 +730,7 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
730
730
|
}
|
|
731
731
|
)
|
|
732
732
|
] }),
|
|
733
|
-
|
|
733
|
+
t == null ? void 0 : t.map((a, m) => {
|
|
734
734
|
const E = !!(A != null && A.find((B) => B.value === a.value)), V = !!a.description;
|
|
735
735
|
return /* @__PURE__ */ l(
|
|
736
736
|
"div",
|
|
@@ -790,24 +790,24 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
790
790
|
}
|
|
791
791
|
), jn = ({
|
|
792
792
|
children: o,
|
|
793
|
-
handleChangePosition:
|
|
794
|
-
enabled:
|
|
793
|
+
handleChangePosition: t,
|
|
794
|
+
enabled: i = !0
|
|
795
795
|
}) => (g(() => {
|
|
796
|
-
if (
|
|
797
|
-
return window.addEventListener("scroll",
|
|
798
|
-
window.removeEventListener("scroll",
|
|
796
|
+
if (i)
|
|
797
|
+
return window.addEventListener("scroll", t, !0), () => {
|
|
798
|
+
window.removeEventListener("scroll", t, !0);
|
|
799
799
|
};
|
|
800
|
-
}, [
|
|
800
|
+
}, [i, t]), /* @__PURE__ */ n("div", { children: o })), hn = "sa-input-dropdown-styles", Sn = (o) => {
|
|
801
801
|
if (!(typeof document > "u") && !document.getElementById(hn)) {
|
|
802
|
-
const
|
|
803
|
-
|
|
802
|
+
const t = document.createElement("style");
|
|
803
|
+
t.id = hn, t.textContent = o, document.head.appendChild(t);
|
|
804
804
|
}
|
|
805
805
|
};
|
|
806
806
|
Sn(zn);
|
|
807
807
|
const Pn = ({
|
|
808
808
|
dropdownLists: o,
|
|
809
|
-
onChange:
|
|
810
|
-
defaultValue:
|
|
809
|
+
onChange: t,
|
|
810
|
+
defaultValue: i,
|
|
811
811
|
value: p,
|
|
812
812
|
size: c = "sm",
|
|
813
813
|
multiSelect: s,
|
|
@@ -845,38 +845,38 @@ const Pn = ({
|
|
|
845
845
|
`sa-select-field-size-${c}`,
|
|
846
846
|
Q ? "sa-select-field-fullwidth" : ""
|
|
847
847
|
].filter(Boolean).join(" "), z = p !== void 0, en = K(), vn = N || !!h, [u, j] = S(
|
|
848
|
-
z ? p || [] :
|
|
848
|
+
z ? p || [] : i || []
|
|
849
849
|
), [xn, ln] = S(""), [f, on] = S(-1), G = sn.useId(), pn = f >= 0 ? `${G}-opt-${f}` : void 0, [cn, U] = S(
|
|
850
850
|
() => {
|
|
851
851
|
var e, r;
|
|
852
|
-
return !s && (p != null && p.length ||
|
|
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) ?? "" : "";
|
|
853
853
|
}
|
|
854
854
|
), v = K(null), { isComponentVisible: w, ref: rn, setIsComponentVisible: R } = Rn(!1), I = o !== void 0, un = u.length > 0, gn = (e) => {
|
|
855
855
|
e.stopPropagation();
|
|
856
856
|
const r = [];
|
|
857
|
-
z || j(r),
|
|
857
|
+
z || j(r), t(r), d && U(""), m == null || m();
|
|
858
858
|
}, mn = () => {
|
|
859
859
|
I && R((e) => !e);
|
|
860
860
|
}, J = (e, r) => {
|
|
861
861
|
if (s) {
|
|
862
862
|
if (u == null ? void 0 : u.find((x) => x.value === r)) {
|
|
863
863
|
const x = u.filter((Cn) => Cn.value !== r);
|
|
864
|
-
z || j(x),
|
|
864
|
+
z || j(x), t(x);
|
|
865
865
|
} else {
|
|
866
866
|
const x = [...u, { label: e, value: r }];
|
|
867
|
-
z || j(x),
|
|
867
|
+
z || j(x), t(x);
|
|
868
868
|
}
|
|
869
869
|
d && U("");
|
|
870
870
|
} else {
|
|
871
871
|
const b = [{ label: e, value: r }];
|
|
872
|
-
z || j(b),
|
|
872
|
+
z || j(b), t(b), d && U(H ? "" : e), R(!1);
|
|
873
873
|
}
|
|
874
874
|
};
|
|
875
875
|
g(() => {
|
|
876
876
|
z && j(p || []);
|
|
877
877
|
}, [p]), g(() => {
|
|
878
|
-
z || JSON.stringify(en.current) === JSON.stringify(
|
|
879
|
-
}, [
|
|
878
|
+
z || JSON.stringify(en.current) === JSON.stringify(i) || (en.current = i, j(en.current || []));
|
|
879
|
+
}, [i]);
|
|
880
880
|
const kn = () => u.length ? s ? u == null ? void 0 : u.map((e, r) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
|
|
881
881
|
/* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
|
|
882
882
|
/* @__PURE__ */ n(
|
|
@@ -1083,15 +1083,15 @@ const Pn = ({
|
|
|
1083
1083
|
L && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: L }),
|
|
1084
1084
|
h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
|
|
1085
1085
|
] });
|
|
1086
|
-
}, fn = (o,
|
|
1086
|
+
}, fn = (o, t, i) => {
|
|
1087
1087
|
const p = o.length;
|
|
1088
|
-
let c =
|
|
1088
|
+
let c = t + i;
|
|
1089
1089
|
for (; c >= 0 && c < p; ) {
|
|
1090
1090
|
if (!o[c].disable)
|
|
1091
1091
|
return c;
|
|
1092
|
-
c +=
|
|
1092
|
+
c += i;
|
|
1093
1093
|
}
|
|
1094
|
-
if (
|
|
1094
|
+
if (i === 1) {
|
|
1095
1095
|
for (let s = 0; s < p; s++)
|
|
1096
1096
|
if (!o[s].disable)
|
|
1097
1097
|
return s;
|
package/dist/dropdown.umd.js
CHANGED
|
@@ -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
|
|
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 {
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
border-radius: var(--borderRadius);
|
|
110
110
|
}
|
|
111
111
|
.sa-input-dropdown-container.standard.active {
|
|
112
|
-
border: 1px solid var(--sa-dropdown-border-active);
|
|
112
|
+
border: 1px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
|
|
113
113
|
box-shadow: var(--sa-dropdown-ring-active);
|
|
114
114
|
}
|
|
115
115
|
.sa-input-dropdown-container.standard.error {
|
|
@@ -127,12 +127,12 @@
|
|
|
127
127
|
/* --- Outline variant --- */
|
|
128
128
|
.sa-input-dropdown-container.outline {
|
|
129
129
|
background-color: transparent;
|
|
130
|
-
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)));
|
|
131
131
|
border-radius: var(--borderRadius);
|
|
132
132
|
outline: none;
|
|
133
133
|
}
|
|
134
134
|
.sa-input-dropdown-container.outline.active {
|
|
135
|
-
border: 1.2px solid var(--sa-dropdown-border-active);
|
|
135
|
+
border: 1.2px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
|
|
136
136
|
box-shadow: none;
|
|
137
137
|
}
|
|
138
138
|
.sa-input-dropdown-container.outline.error {
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
}
|
|
142
142
|
.sa-input-dropdown-container.outline.disable {
|
|
143
143
|
background-color: var(--sa-dropdown-bg-disabled);
|
|
144
|
-
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)));
|
|
145
145
|
cursor: not-allowed;
|
|
146
146
|
pointer-events: none;
|
|
147
147
|
opacity: 0.6;
|
|
@@ -151,11 +151,11 @@
|
|
|
151
151
|
.sa-input-dropdown-container.flushed {
|
|
152
152
|
background-color: transparent;
|
|
153
153
|
border: none;
|
|
154
|
-
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)));
|
|
155
155
|
border-radius: 0;
|
|
156
156
|
}
|
|
157
157
|
.sa-input-dropdown-container.flushed.active {
|
|
158
|
-
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));
|
|
159
159
|
box-shadow: none;
|
|
160
160
|
}
|
|
161
161
|
.sa-input-dropdown-container.flushed.error {
|
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
.sa-input-dropdown-preview-item {
|
|
205
|
-
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)));
|
|
206
206
|
padding-inline: 8px;
|
|
207
207
|
padding-block: 2px;
|
|
208
208
|
border-radius: var(--sa-radii-xs, 4px);
|
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
align-items: center;
|
|
281
281
|
height: 32px;
|
|
282
282
|
min-height: 32px;
|
|
283
|
-
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)));
|
|
284
284
|
gap: 8px;
|
|
285
285
|
padding-inline: 12px;
|
|
286
286
|
padding-block: 8px;
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
.sa-input-dropdown-lists-container.search-bottom > .sa-input-dropdown-container-dropdown-search {
|
|
312
312
|
order: 2;
|
|
313
313
|
border-bottom: none;
|
|
314
|
-
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)));
|
|
315
315
|
}
|
|
316
316
|
.sa-input-dropdown-lists-container.search-bottom > .sa-input-dropdown-footer {
|
|
317
317
|
order: 3;
|
|
@@ -411,7 +411,7 @@
|
|
|
411
411
|
}
|
|
412
412
|
.sa-input-dropdown-item.highlight {
|
|
413
413
|
background-color: var(--sa-dropdown-bg-selected);
|
|
414
|
-
outline: 1.2px solid var(--sa-dropdown-border-active);
|
|
414
|
+
outline: 1.2px solid var(--sa-dropdown-border-active, var(--sa-border-focused, #1a4fa0));
|
|
415
415
|
outline-offset: -1.2px;
|
|
416
416
|
}
|
|
417
417
|
.sa-input-dropdown-item-disable {
|
|
@@ -456,7 +456,7 @@
|
|
|
456
456
|
flex-shrink: 0;
|
|
457
457
|
background: var(--sa-dropdown-bg);
|
|
458
458
|
padding: 8px;
|
|
459
|
-
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)));
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
/* === SELECT FIELD WRAPPER === */
|
|
@@ -522,7 +522,7 @@
|
|
|
522
522
|
display: inline-flex;
|
|
523
523
|
align-items: center;
|
|
524
524
|
padding: 0 8px;
|
|
525
|
-
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)));
|
|
526
526
|
border-radius: var(--sa-radii-xs, 4px);
|
|
527
527
|
background: var(--sa-dropdown-bg-neutral);
|
|
528
528
|
font-size: 10px;
|
|
@@ -584,4 +584,4 @@
|
|
|
584
584
|
}
|
|
585
585
|
|
|
586
586
|
} /* @layer starasia.components */
|
|
587
|
-
`;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(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: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:S,optional:tn,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,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,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:[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?Dn:Bn()}),Sn,!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"}),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}),tn&&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,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"})});
|