@starasia/dropdown 5.3.0 → 5.5.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 +274 -193
- package/dist/dropdown.umd.js +62 -3
- package/dist/interface.d.ts +3 -1
- package/package.json +1 -1
package/dist/dropdown.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as l, jsx as n, Fragment as
|
|
2
|
-
import
|
|
3
|
-
const
|
|
1
|
+
import { jsxs as l, jsx as n, Fragment as sn } from "react/jsx-runtime";
|
|
2
|
+
import ln, { useState as I, useRef as M, useEffect as v, forwardRef as yn } from "react";
|
|
3
|
+
const Nn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
|
|
4
4
|
* {
|
|
5
5
|
margin: 0;
|
|
6
6
|
padding: 0;
|
|
@@ -37,6 +37,15 @@ const vn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/* === SIZE VARIANTS === */
|
|
40
|
+
.sa-input-dropdown-size-xs {
|
|
41
|
+
--baseFont: 12px;
|
|
42
|
+
--height: 28px;
|
|
43
|
+
--borderRadius: var(--sa-dropdown-radius);
|
|
44
|
+
--paddingInline: 8px;
|
|
45
|
+
--paddingBlock: 2px;
|
|
46
|
+
--iconSize: 14px;
|
|
47
|
+
--iconMarginTop: 4px;
|
|
48
|
+
}
|
|
40
49
|
.sa-input-dropdown-size-sm {
|
|
41
50
|
--baseFont: 12px;
|
|
42
51
|
--height: 32px;
|
|
@@ -44,6 +53,7 @@ const vn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
44
53
|
--paddingInline: 12px;
|
|
45
54
|
--paddingBlock: 4px;
|
|
46
55
|
--iconSize: 16px;
|
|
56
|
+
--iconMarginTop: 4px;
|
|
47
57
|
}
|
|
48
58
|
.sa-input-dropdown-size-md {
|
|
49
59
|
--baseFont: 14px;
|
|
@@ -52,6 +62,7 @@ const vn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
52
62
|
--paddingInline: 12px;
|
|
53
63
|
--paddingBlock: 8px;
|
|
54
64
|
--iconSize: 16px;
|
|
65
|
+
--iconMarginTop: 4px;
|
|
55
66
|
}
|
|
56
67
|
.sa-input-dropdown-size-lg {
|
|
57
68
|
--baseFont: 14px;
|
|
@@ -60,6 +71,7 @@ const vn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
60
71
|
--paddingInline: 12px;
|
|
61
72
|
--paddingBlock: 12px;
|
|
62
73
|
--iconSize: 20px;
|
|
74
|
+
--iconMarginTop: 2px;
|
|
63
75
|
}
|
|
64
76
|
.sa-input-dropdown-size-xl {
|
|
65
77
|
--baseFont: 16px;
|
|
@@ -68,6 +80,7 @@ const vn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
68
80
|
--paddingInline: 16px;
|
|
69
81
|
--paddingBlock: 16px;
|
|
70
82
|
--iconSize: 20px;
|
|
83
|
+
--iconMarginTop: 2px;
|
|
71
84
|
}
|
|
72
85
|
|
|
73
86
|
/* === BASE CONTAINER === */
|
|
@@ -159,12 +172,26 @@ const vn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
159
172
|
display: flex;
|
|
160
173
|
flex-direction: row;
|
|
161
174
|
gap: 8px;
|
|
162
|
-
align-items:
|
|
175
|
+
align-items: flex-start;
|
|
163
176
|
justify-content: space-between;
|
|
164
177
|
width: 100%;
|
|
165
178
|
min-width: 0;
|
|
166
179
|
}
|
|
167
180
|
|
|
181
|
+
/* Chevron + clear button — top-aligned with margin so they appear visually
|
|
182
|
+
centered when single-line, and snap to top-right when content wraps */
|
|
183
|
+
.sa-input-dropdown-chevron,
|
|
184
|
+
.sa-input-dropdown-clear {
|
|
185
|
+
align-self: flex-start;
|
|
186
|
+
margin-top: var(--iconMarginTop, 4px);
|
|
187
|
+
}
|
|
188
|
+
.sa-input-dropdown-chevron {
|
|
189
|
+
display: inline-flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
justify-content: center;
|
|
192
|
+
flex-shrink: 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
168
195
|
.sa-input-dropdown-container-preview-item {
|
|
169
196
|
flex: 1;
|
|
170
197
|
display: flex;
|
|
@@ -334,6 +361,7 @@ const vn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
334
361
|
min-height: 32px;
|
|
335
362
|
font-size: 12px;
|
|
336
363
|
}
|
|
364
|
+
.sa-input-dropdown-size-xs .sa-input-dropdown-item,
|
|
337
365
|
.sa-input-dropdown-size-sm .sa-input-dropdown-item,
|
|
338
366
|
.sa-input-dropdown-size-md .sa-input-dropdown-item {
|
|
339
367
|
font-size: 12px;
|
|
@@ -485,16 +513,47 @@ const vn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
485
513
|
margin: 0;
|
|
486
514
|
}
|
|
487
515
|
|
|
516
|
+
/* === CLEAR BUTTON === */
|
|
517
|
+
.sa-input-dropdown-clear {
|
|
518
|
+
appearance: none;
|
|
519
|
+
border: 0;
|
|
520
|
+
background: transparent;
|
|
521
|
+
padding: 0;
|
|
522
|
+
cursor: pointer;
|
|
523
|
+
color: var(--sa-dropdown-placeholder);
|
|
524
|
+
border-radius: 50%;
|
|
525
|
+
flex-shrink: 0;
|
|
526
|
+
display: inline-flex;
|
|
527
|
+
align-items: center;
|
|
528
|
+
justify-content: center;
|
|
529
|
+
opacity: 1;
|
|
530
|
+
transition: opacity 120ms ease, color 120ms ease, transform 80ms ease;
|
|
531
|
+
}
|
|
532
|
+
.sa-input-dropdown-clear:hover {
|
|
533
|
+
color: var(--sa-dropdown-text-secondary);
|
|
534
|
+
}
|
|
535
|
+
.sa-input-dropdown-clear:active {
|
|
536
|
+
transform: scale(0.92);
|
|
537
|
+
}
|
|
538
|
+
.sa-input-dropdown-clear-hidden {
|
|
539
|
+
opacity: 0;
|
|
540
|
+
pointer-events: none;
|
|
541
|
+
cursor: default;
|
|
542
|
+
}
|
|
543
|
+
.sa-input-dropdown-container.disable .sa-input-dropdown-clear {
|
|
544
|
+
display: none;
|
|
545
|
+
}
|
|
546
|
+
|
|
488
547
|
`;
|
|
489
|
-
function
|
|
490
|
-
const [p,
|
|
491
|
-
s.current && !s.current.contains(r.target) &&
|
|
548
|
+
function En(o) {
|
|
549
|
+
const [p, d] = I(o), s = M(null), i = (r) => {
|
|
550
|
+
s.current && !s.current.contains(r.target) && d(!1);
|
|
492
551
|
};
|
|
493
|
-
return
|
|
494
|
-
document.removeEventListener("click",
|
|
495
|
-
}), []), { ref: s, isComponentVisible: p, setIsComponentVisible:
|
|
552
|
+
return v(() => (document.addEventListener("click", i, !0), () => {
|
|
553
|
+
document.removeEventListener("click", i, !0);
|
|
554
|
+
}), []), { ref: s, isComponentVisible: p, setIsComponentVisible: d };
|
|
496
555
|
}
|
|
497
|
-
const
|
|
556
|
+
const Cn = ({ ...o }) => /* @__PURE__ */ l(
|
|
498
557
|
"svg",
|
|
499
558
|
{
|
|
500
559
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -526,7 +585,7 @@ const mn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
526
585
|
)
|
|
527
586
|
]
|
|
528
587
|
}
|
|
529
|
-
),
|
|
588
|
+
), zn = ({ width: o = 16 }) => /* @__PURE__ */ n(
|
|
530
589
|
"svg",
|
|
531
590
|
{
|
|
532
591
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -545,70 +604,70 @@ const mn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
545
604
|
}
|
|
546
605
|
)
|
|
547
606
|
}
|
|
548
|
-
),
|
|
607
|
+
), Rn = yn(
|
|
549
608
|
({
|
|
550
609
|
positionDropdown: o,
|
|
551
610
|
dropdownLists: p,
|
|
552
|
-
isComponentVisible:
|
|
611
|
+
isComponentVisible: d,
|
|
553
612
|
searchAble: s,
|
|
554
|
-
hideSearch:
|
|
613
|
+
hideSearch: i,
|
|
555
614
|
onSearch: r,
|
|
556
615
|
value: m,
|
|
557
616
|
handleChangeValue: u,
|
|
558
|
-
multiSelect:
|
|
559
|
-
searchValue:
|
|
617
|
+
multiSelect: R,
|
|
618
|
+
searchValue: L,
|
|
560
619
|
highlightedIndex: y,
|
|
561
620
|
footer: F,
|
|
562
|
-
groupLabel:
|
|
563
|
-
onSelectAll:
|
|
564
|
-
},
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
var
|
|
568
|
-
y >= 0 &&
|
|
621
|
+
groupLabel: T,
|
|
622
|
+
onSelectAll: N
|
|
623
|
+
}, U) => {
|
|
624
|
+
const j = M([]);
|
|
625
|
+
v(() => {
|
|
626
|
+
var t;
|
|
627
|
+
y >= 0 && j.current[y] && ((t = j.current[y]) == null || t.scrollIntoView({ block: "nearest" }));
|
|
569
628
|
}, [y]);
|
|
570
|
-
const
|
|
571
|
-
/* @__PURE__ */ n(
|
|
629
|
+
const H = s && !i ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
|
|
630
|
+
/* @__PURE__ */ n(Cn, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
|
|
572
631
|
/* @__PURE__ */ n(
|
|
573
632
|
"input",
|
|
574
633
|
{
|
|
575
|
-
onChange: (
|
|
576
|
-
r && r(
|
|
634
|
+
onChange: (t) => {
|
|
635
|
+
r && r(t.target.value);
|
|
577
636
|
},
|
|
578
|
-
value:
|
|
637
|
+
value: L,
|
|
579
638
|
autoFocus: !0,
|
|
580
639
|
placeholder: "Search..."
|
|
581
640
|
}
|
|
582
641
|
)
|
|
583
642
|
] }) : null;
|
|
584
|
-
return /* @__PURE__ */ n(
|
|
643
|
+
return /* @__PURE__ */ n(sn, { children: d ? /* @__PURE__ */ l(
|
|
585
644
|
"div",
|
|
586
645
|
{
|
|
587
646
|
className: "sa-input-dropdown-lists-container",
|
|
588
|
-
onClick: (
|
|
589
|
-
ref:
|
|
647
|
+
onClick: (t) => t.stopPropagation(),
|
|
648
|
+
ref: U,
|
|
590
649
|
children: [
|
|
591
|
-
o !== "top" &&
|
|
650
|
+
o !== "top" && H,
|
|
592
651
|
/* @__PURE__ */ l(
|
|
593
652
|
"div",
|
|
594
653
|
{
|
|
595
|
-
className: `sa-input-dropdown-item-container ${
|
|
654
|
+
className: `sa-input-dropdown-item-container ${R ? "multi" : ""}`,
|
|
596
655
|
children: [
|
|
597
|
-
|
|
598
|
-
/* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children:
|
|
599
|
-
|
|
656
|
+
T && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
|
|
657
|
+
/* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: T }),
|
|
658
|
+
R && N && /* @__PURE__ */ n(
|
|
600
659
|
"button",
|
|
601
660
|
{
|
|
602
661
|
className: "sa-input-dropdown-section-select-all",
|
|
603
|
-
onClick: (
|
|
604
|
-
|
|
662
|
+
onClick: (t) => {
|
|
663
|
+
t.stopPropagation(), N();
|
|
605
664
|
},
|
|
606
665
|
children: "Select all"
|
|
607
666
|
}
|
|
608
667
|
)
|
|
609
668
|
] }),
|
|
610
|
-
p.map((
|
|
611
|
-
const $ = !!(m != null && m.find((P) => P.value ===
|
|
669
|
+
p.map((t, A) => {
|
|
670
|
+
const $ = !!(m != null && m.find((P) => P.value === t.value)), w = !!t.description;
|
|
612
671
|
return /* @__PURE__ */ l(
|
|
613
672
|
"div",
|
|
614
673
|
{
|
|
@@ -617,34 +676,34 @@ const mn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
617
676
|
w ? "has-description" : "",
|
|
618
677
|
$ ? "active" : "",
|
|
619
678
|
A === y ? "highlight" : "",
|
|
620
|
-
|
|
679
|
+
t.disable ? "sa-input-dropdown-item-disable" : ""
|
|
621
680
|
].filter(Boolean).join(" "),
|
|
622
681
|
ref: (P) => {
|
|
623
|
-
|
|
682
|
+
j.current[A] = P;
|
|
624
683
|
},
|
|
625
|
-
onClick: () => u(
|
|
684
|
+
onClick: () => u(t.label, t.value),
|
|
626
685
|
children: [
|
|
627
|
-
|
|
628
|
-
|
|
686
|
+
R && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-item-check", children: $ && /* @__PURE__ */ n(zn, { width: 16 }) }),
|
|
687
|
+
t.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: ln.cloneElement(t.icon, { width: 16 }) }),
|
|
629
688
|
/* @__PURE__ */ l("div", { style: { minWidth: 0, flex: 1 }, children: [
|
|
630
689
|
/* @__PURE__ */ n(
|
|
631
690
|
"p",
|
|
632
691
|
{
|
|
633
692
|
className: [
|
|
634
693
|
"sa-input-dropdown-item-text",
|
|
635
|
-
|
|
694
|
+
t.disable ? "sa-input-dropdown-item-disable" : ""
|
|
636
695
|
].filter(Boolean).join(" "),
|
|
637
|
-
children:
|
|
696
|
+
children: t.label
|
|
638
697
|
}
|
|
639
698
|
),
|
|
640
|
-
|
|
699
|
+
t.description && /* @__PURE__ */ n(
|
|
641
700
|
"p",
|
|
642
701
|
{
|
|
643
702
|
className: [
|
|
644
703
|
"sa-input-dropdown-item-text-description",
|
|
645
|
-
|
|
704
|
+
t.disable ? "sa-input-dropdown-item-disable" : ""
|
|
646
705
|
].filter(Boolean).join(" "),
|
|
647
|
-
children:
|
|
706
|
+
children: t.description
|
|
648
707
|
}
|
|
649
708
|
)
|
|
650
709
|
] })
|
|
@@ -656,290 +715,309 @@ const mn = ({ ...o }) => /* @__PURE__ */ l(
|
|
|
656
715
|
]
|
|
657
716
|
}
|
|
658
717
|
),
|
|
659
|
-
o === "top" &&
|
|
660
|
-
F && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (
|
|
718
|
+
o === "top" && H,
|
|
719
|
+
F && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (t) => t.stopPropagation(), children: F })
|
|
661
720
|
]
|
|
662
721
|
}
|
|
663
722
|
) : null });
|
|
664
723
|
}
|
|
665
|
-
),
|
|
724
|
+
), Ln = ({
|
|
666
725
|
children: o,
|
|
667
726
|
handleChangePosition: p
|
|
668
727
|
}) => {
|
|
669
|
-
const
|
|
670
|
-
|
|
728
|
+
const d = M(null);
|
|
729
|
+
v(() => {
|
|
671
730
|
var m;
|
|
672
|
-
const
|
|
673
|
-
if (
|
|
674
|
-
let u =
|
|
731
|
+
const i = () => {
|
|
732
|
+
if (d.current) {
|
|
733
|
+
let u = d.current.parentElement;
|
|
675
734
|
for (; u && !s(u); )
|
|
676
735
|
u = u.parentElement;
|
|
677
736
|
u && p();
|
|
678
737
|
}
|
|
679
738
|
};
|
|
680
|
-
let r = (m =
|
|
739
|
+
let r = (m = d.current) == null ? void 0 : m.parentElement;
|
|
681
740
|
for (; r && !s(r); )
|
|
682
741
|
r = r.parentElement;
|
|
683
|
-
return r && r.addEventListener("scroll",
|
|
684
|
-
r && r.removeEventListener("scroll",
|
|
742
|
+
return r && r.addEventListener("scroll", i), i(), () => {
|
|
743
|
+
r && r.removeEventListener("scroll", i);
|
|
685
744
|
};
|
|
686
745
|
}, []);
|
|
687
|
-
const s = (
|
|
688
|
-
return /* @__PURE__ */ n("div", { ref:
|
|
689
|
-
},
|
|
690
|
-
if (!document.getElementById(
|
|
746
|
+
const s = (i) => i && (i.scrollHeight > i.clientHeight || i.scrollWidth > i.clientWidth);
|
|
747
|
+
return /* @__PURE__ */ n("div", { ref: d, children: o });
|
|
748
|
+
}, an = "sa-input-dropdown-styles", Bn = (o) => {
|
|
749
|
+
if (!document.getElementById(an)) {
|
|
691
750
|
const p = document.createElement("style");
|
|
692
|
-
p.id =
|
|
751
|
+
p.id = an, p.textContent = o, document.head.appendChild(p);
|
|
693
752
|
}
|
|
694
753
|
};
|
|
695
|
-
|
|
696
|
-
const
|
|
754
|
+
Bn(Nn);
|
|
755
|
+
const On = ({
|
|
697
756
|
dropdownLists: o,
|
|
698
757
|
onChange: p,
|
|
699
|
-
defaultValue:
|
|
758
|
+
defaultValue: d,
|
|
700
759
|
value: s,
|
|
701
|
-
size:
|
|
760
|
+
size: i = "sm",
|
|
702
761
|
multiSelect: r,
|
|
703
762
|
searchAble: m,
|
|
704
763
|
iconLeft: u,
|
|
705
|
-
placeholder:
|
|
706
|
-
onSearch:
|
|
764
|
+
placeholder: R,
|
|
765
|
+
onSearch: L,
|
|
707
766
|
error: y,
|
|
708
767
|
onBlur: F,
|
|
709
|
-
onFocus:
|
|
710
|
-
disable:
|
|
711
|
-
searchValue:
|
|
712
|
-
variant:
|
|
713
|
-
footer:
|
|
714
|
-
groupLabel:
|
|
768
|
+
onFocus: T,
|
|
769
|
+
disable: N,
|
|
770
|
+
searchValue: U,
|
|
771
|
+
variant: j = "outline",
|
|
772
|
+
footer: H,
|
|
773
|
+
groupLabel: t,
|
|
715
774
|
onSelectAll: A,
|
|
716
775
|
fullWidth: $ = !0,
|
|
717
776
|
triggerInput: w = !1,
|
|
718
777
|
clearOnSelect: P = !1,
|
|
719
|
-
hideChevronIcon:
|
|
778
|
+
hideChevronIcon: pn = !1,
|
|
779
|
+
clearable: cn = !1,
|
|
780
|
+
onClear: K,
|
|
720
781
|
/* field wrapper */
|
|
721
|
-
label:
|
|
722
|
-
labelPosition:
|
|
723
|
-
required:
|
|
724
|
-
optional:
|
|
725
|
-
description:
|
|
726
|
-
helperText:
|
|
782
|
+
label: J,
|
|
783
|
+
labelPosition: wn = "outside-top",
|
|
784
|
+
required: V,
|
|
785
|
+
optional: nn,
|
|
786
|
+
description: B,
|
|
787
|
+
helperText: D,
|
|
727
788
|
errorText: h
|
|
728
789
|
}) => {
|
|
729
|
-
const
|
|
790
|
+
const Z = [
|
|
730
791
|
"sa-select-field",
|
|
731
792
|
$ ? "sa-select-field-fullwidth" : ""
|
|
732
|
-
].filter(Boolean).join(" "),
|
|
733
|
-
|
|
734
|
-
), [
|
|
793
|
+
].filter(Boolean).join(" "), E = s !== void 0, Q = M(), un = y || !!h, [c, S] = I(
|
|
794
|
+
E ? s || [] : d || []
|
|
795
|
+
), [hn, en] = I(""), [k, X] = I(-1), [fn, q] = I(
|
|
735
796
|
() => {
|
|
736
|
-
var e,
|
|
737
|
-
return !r && (s != null && s.length ||
|
|
797
|
+
var e, a;
|
|
798
|
+
return !r && (s != null && s.length || d != null && d.length) ? ((e = s == null ? void 0 : s[0]) == null ? void 0 : e.label) ?? ((a = d == null ? void 0 : d[0]) == null ? void 0 : a.label) ?? "" : "";
|
|
738
799
|
}
|
|
739
|
-
), g =
|
|
740
|
-
|
|
741
|
-
|
|
800
|
+
), g = M(null), { isComponentVisible: f, ref: Y, setIsComponentVisible: C } = En(!1), O = o !== void 0, on = c.length > 0, bn = (e) => {
|
|
801
|
+
e.stopPropagation();
|
|
802
|
+
const a = [];
|
|
803
|
+
E || S(a), p(a), w && q(""), K == null || K();
|
|
804
|
+
}, gn = () => {
|
|
805
|
+
O && C((e) => !e);
|
|
806
|
+
}, G = (e, a) => {
|
|
742
807
|
if (r) {
|
|
743
|
-
if (c == null ? void 0 : c.find((
|
|
744
|
-
const
|
|
745
|
-
|
|
808
|
+
if (c == null ? void 0 : c.find((x) => x.value === a)) {
|
|
809
|
+
const x = c.filter((kn) => kn.value !== a);
|
|
810
|
+
E || S(x), p(x);
|
|
746
811
|
} else {
|
|
747
|
-
const
|
|
748
|
-
|
|
812
|
+
const x = [...c, { label: e, value: a }];
|
|
813
|
+
E || S(x), p(x);
|
|
749
814
|
}
|
|
750
|
-
w &&
|
|
815
|
+
w && q("");
|
|
751
816
|
} else {
|
|
752
|
-
const b = [{ label: e, value:
|
|
753
|
-
|
|
817
|
+
const b = [{ label: e, value: a }];
|
|
818
|
+
E || S(b), p(b), w && q(P ? "" : e), C(!1);
|
|
754
819
|
}
|
|
755
820
|
};
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
}, [s]),
|
|
759
|
-
|
|
760
|
-
}, [
|
|
761
|
-
const
|
|
821
|
+
v(() => {
|
|
822
|
+
E && S(s || []);
|
|
823
|
+
}, [s]), v(() => {
|
|
824
|
+
E || JSON.stringify(Q.current) === JSON.stringify(d) || (Q.current = d, S(Q.current || []));
|
|
825
|
+
}, [d]);
|
|
826
|
+
const xn = () => c.length ? r ? c == null ? void 0 : c.map((e, a) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
|
|
762
827
|
/* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
|
|
763
828
|
/* @__PURE__ */ n(
|
|
764
|
-
|
|
829
|
+
dn,
|
|
765
830
|
{
|
|
766
831
|
onClick: (b) => {
|
|
767
|
-
b.stopPropagation(),
|
|
832
|
+
b.stopPropagation(), G(e.label, e.value);
|
|
768
833
|
}
|
|
769
834
|
}
|
|
770
835
|
)
|
|
771
|
-
] },
|
|
772
|
-
if (
|
|
773
|
-
const e = window.innerHeight,
|
|
774
|
-
g.current.style.left = `${
|
|
836
|
+
] }, a)) : /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: c == null ? void 0 : c[0].label }) : /* @__PURE__ */ n("p", { className: "sa-input-dropdown-placeholder", children: R }), z = () => {
|
|
837
|
+
if (Y.current && g.current) {
|
|
838
|
+
const e = window.innerHeight, a = Y.current.getBoundingClientRect(), b = g.current.getBoundingClientRect(), x = a.bottom + b.height;
|
|
839
|
+
g.current.style.left = `${a.left}px`, g.current.style.width = `${a.width}px`, x >= e - 10 ? (g.current.style.top = `${a.top - b.height - 5}px`, en("top")) : (g.current.style.top = `${a.top + a.height + 4}px`, en("bottom"));
|
|
775
840
|
}
|
|
776
841
|
};
|
|
777
|
-
|
|
778
|
-
window.removeEventListener("scroll",
|
|
779
|
-
}), []),
|
|
780
|
-
|
|
781
|
-
}, [f]),
|
|
842
|
+
v(() => (window.addEventListener("scroll", z), window.addEventListener("resize", z), () => {
|
|
843
|
+
window.removeEventListener("scroll", z), window.removeEventListener("resize", z);
|
|
844
|
+
}), []), v(() => {
|
|
845
|
+
z();
|
|
846
|
+
}, [f]), v(() => {
|
|
782
847
|
if (!f || !g.current)
|
|
783
848
|
return;
|
|
784
849
|
const e = new ResizeObserver(() => {
|
|
785
|
-
|
|
850
|
+
z();
|
|
786
851
|
});
|
|
787
852
|
return e.observe(g.current), () => e.disconnect();
|
|
788
|
-
}, [f]),
|
|
789
|
-
f ||
|
|
853
|
+
}, [f]), v(() => {
|
|
854
|
+
f || X(-1);
|
|
790
855
|
}, [f]);
|
|
791
|
-
const
|
|
856
|
+
const rn = (e) => {
|
|
792
857
|
if (O) {
|
|
793
858
|
if (!f) {
|
|
794
|
-
(e.key === "ArrowDown" || e.key === "Enter") && (e.preventDefault(),
|
|
859
|
+
(e.key === "ArrowDown" || e.key === "Enter") && (e.preventDefault(), C(!0));
|
|
795
860
|
return;
|
|
796
861
|
}
|
|
797
862
|
switch (e.key) {
|
|
798
863
|
case "ArrowDown": {
|
|
799
864
|
e.preventDefault();
|
|
800
|
-
const
|
|
801
|
-
|
|
865
|
+
const a = tn(o, k, 1);
|
|
866
|
+
a !== -1 && X(a);
|
|
802
867
|
break;
|
|
803
868
|
}
|
|
804
869
|
case "ArrowUp": {
|
|
805
870
|
e.preventDefault();
|
|
806
|
-
const
|
|
807
|
-
|
|
871
|
+
const a = tn(o, k, -1);
|
|
872
|
+
a !== -1 && X(a);
|
|
808
873
|
break;
|
|
809
874
|
}
|
|
810
875
|
case "Enter": {
|
|
811
|
-
e.preventDefault(), k >= 0 && o[k] && !o[k].disable &&
|
|
876
|
+
e.preventDefault(), k >= 0 && o[k] && !o[k].disable && G(
|
|
812
877
|
o[k].label,
|
|
813
878
|
o[k].value
|
|
814
879
|
);
|
|
815
880
|
break;
|
|
816
881
|
}
|
|
817
882
|
case "Escape":
|
|
818
|
-
|
|
883
|
+
C(!1);
|
|
819
884
|
break;
|
|
820
885
|
}
|
|
821
886
|
}
|
|
822
|
-
},
|
|
823
|
-
|
|
887
|
+
}, W = i === "lg" || i === "xl" ? 20 : i === "xs" ? 14 : 16, vn = cn && !N ? /* @__PURE__ */ n(
|
|
888
|
+
"button",
|
|
889
|
+
{
|
|
890
|
+
type: "button",
|
|
891
|
+
className: `sa-input-dropdown-clear${on ? "" : " sa-input-dropdown-clear-hidden"}`,
|
|
892
|
+
"aria-label": "Clear selection",
|
|
893
|
+
"aria-hidden": !on,
|
|
894
|
+
tabIndex: -1,
|
|
895
|
+
onClick: bn,
|
|
896
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
897
|
+
children: /* @__PURE__ */ n(Dn, { width: W, height: W })
|
|
898
|
+
}
|
|
899
|
+
) : null, mn = w ? /* @__PURE__ */ l(sn, { children: [
|
|
900
|
+
r && c.map((e, a) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
|
|
824
901
|
/* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
|
|
825
902
|
/* @__PURE__ */ n(
|
|
826
|
-
|
|
903
|
+
dn,
|
|
827
904
|
{
|
|
828
905
|
onClick: (b) => {
|
|
829
|
-
b.stopPropagation(),
|
|
906
|
+
b.stopPropagation(), G(e.label, e.value);
|
|
830
907
|
}
|
|
831
908
|
}
|
|
832
909
|
)
|
|
833
|
-
] },
|
|
910
|
+
] }, a)),
|
|
834
911
|
/* @__PURE__ */ n(
|
|
835
912
|
"input",
|
|
836
913
|
{
|
|
837
914
|
className: "sa-input-dropdown-trigger-input",
|
|
838
|
-
value:
|
|
915
|
+
value: fn,
|
|
839
916
|
onChange: (e) => {
|
|
840
|
-
const
|
|
841
|
-
|
|
917
|
+
const a = e.target.value;
|
|
918
|
+
q(a), L == null || L(a), !f && O && C(!0);
|
|
842
919
|
},
|
|
843
920
|
onFocus: () => {
|
|
844
|
-
!
|
|
921
|
+
!N && O && C(!0);
|
|
845
922
|
},
|
|
846
923
|
onBlur: () => {
|
|
847
|
-
r || setTimeout(() =>
|
|
924
|
+
r || setTimeout(() => C(!1), 150);
|
|
848
925
|
},
|
|
849
|
-
onKeyDown:
|
|
850
|
-
placeholder: c.length === 0 || r ?
|
|
851
|
-
disabled:
|
|
926
|
+
onKeyDown: rn,
|
|
927
|
+
placeholder: c.length === 0 || r ? R : void 0,
|
|
928
|
+
disabled: N
|
|
852
929
|
}
|
|
853
930
|
)
|
|
854
|
-
] }) : null,
|
|
931
|
+
] }) : null, _ = /* @__PURE__ */ n(Ln, { handleChangePosition: z, children: /* @__PURE__ */ l(
|
|
855
932
|
"div",
|
|
856
933
|
{
|
|
857
934
|
className: [
|
|
858
935
|
"sa-input-dropdown-container",
|
|
859
|
-
|
|
860
|
-
`sa-input-dropdown-size-${
|
|
936
|
+
j,
|
|
937
|
+
`sa-input-dropdown-size-${i}`,
|
|
861
938
|
w ? "trigger-input" : "",
|
|
862
939
|
f ? "active" : "",
|
|
863
|
-
|
|
864
|
-
|
|
940
|
+
un ? "error" : "",
|
|
941
|
+
N ? "disable" : ""
|
|
865
942
|
].filter(Boolean).join(" "),
|
|
866
|
-
ref:
|
|
867
|
-
onClick: w ? void 0 :
|
|
868
|
-
onKeyDown: w ? void 0 :
|
|
943
|
+
ref: Y,
|
|
944
|
+
onClick: w ? void 0 : gn,
|
|
945
|
+
onKeyDown: w ? void 0 : rn,
|
|
869
946
|
tabIndex: w ? void 0 : 0,
|
|
870
947
|
onBlur: w ? void 0 : F,
|
|
871
|
-
onFocus: w ? void 0 :
|
|
948
|
+
onFocus: w ? void 0 : T,
|
|
872
949
|
children: [
|
|
873
950
|
/* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-container", children: [
|
|
874
|
-
u ?
|
|
875
|
-
width:
|
|
951
|
+
u ? ln.cloneElement(u, {
|
|
952
|
+
width: W,
|
|
876
953
|
style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 }
|
|
877
954
|
}) : null,
|
|
878
|
-
/* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: w ?
|
|
879
|
-
|
|
955
|
+
/* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: w ? mn : xn() }),
|
|
956
|
+
vn,
|
|
957
|
+
!pn && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-chevron", children: f ? /* @__PURE__ */ n(jn, { width: W }) : /* @__PURE__ */ n(Sn, { width: W }) })
|
|
880
958
|
] }),
|
|
881
959
|
O && /* @__PURE__ */ n(
|
|
882
|
-
|
|
960
|
+
Rn,
|
|
883
961
|
{
|
|
884
962
|
dropdownLists: o,
|
|
885
|
-
handleChangeValue:
|
|
963
|
+
handleChangeValue: G,
|
|
886
964
|
isComponentVisible: f,
|
|
887
|
-
positionDropdown:
|
|
965
|
+
positionDropdown: hn,
|
|
888
966
|
searchAble: !!m,
|
|
889
967
|
hideSearch: w,
|
|
890
968
|
value: c,
|
|
891
|
-
onSearch:
|
|
969
|
+
onSearch: L,
|
|
892
970
|
ref: g,
|
|
893
971
|
multiSelect: r,
|
|
894
|
-
searchValue:
|
|
972
|
+
searchValue: U,
|
|
895
973
|
highlightedIndex: k,
|
|
896
|
-
footer:
|
|
897
|
-
groupLabel:
|
|
974
|
+
footer: H,
|
|
975
|
+
groupLabel: t,
|
|
898
976
|
onSelectAll: A
|
|
899
977
|
}
|
|
900
978
|
)
|
|
901
979
|
]
|
|
902
980
|
}
|
|
903
981
|
) });
|
|
904
|
-
return
|
|
982
|
+
return J ? wn === "outside-left" ? /* @__PURE__ */ l("div", { className: `${Z} sa-select-field-left`, children: [
|
|
905
983
|
/* @__PURE__ */ l("div", { className: "sa-select-field-left-label", children: [
|
|
906
984
|
/* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
|
|
907
|
-
/* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children:
|
|
908
|
-
|
|
909
|
-
|
|
985
|
+
/* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: J }),
|
|
986
|
+
nn && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
|
|
987
|
+
V && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
|
|
910
988
|
] }),
|
|
911
|
-
|
|
989
|
+
B && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: B })
|
|
912
990
|
] }),
|
|
913
991
|
/* @__PURE__ */ l("div", { className: "sa-select-field-input-wrap", children: [
|
|
914
|
-
|
|
915
|
-
|
|
992
|
+
_,
|
|
993
|
+
D && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: D }),
|
|
916
994
|
h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
|
|
917
995
|
] })
|
|
918
|
-
] }) : /* @__PURE__ */ l("div", { className:
|
|
996
|
+
] }) : /* @__PURE__ */ l("div", { className: Z, children: [
|
|
919
997
|
/* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
|
|
920
|
-
/* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children:
|
|
921
|
-
|
|
922
|
-
|
|
998
|
+
/* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: J }),
|
|
999
|
+
nn && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
|
|
1000
|
+
V && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
|
|
923
1001
|
] }),
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
1002
|
+
B && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: B }),
|
|
1003
|
+
_,
|
|
1004
|
+
D && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: D }),
|
|
927
1005
|
h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
|
|
928
|
-
] }) : /* @__PURE__ */ l("div", { className:
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
1006
|
+
] }) : /* @__PURE__ */ l("div", { className: Z, children: [
|
|
1007
|
+
B && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: B }),
|
|
1008
|
+
_,
|
|
1009
|
+
D && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: D }),
|
|
932
1010
|
h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
|
|
933
1011
|
] });
|
|
934
|
-
},
|
|
1012
|
+
}, tn = (o, p, d) => {
|
|
935
1013
|
const s = o.length;
|
|
936
|
-
let
|
|
937
|
-
for (;
|
|
938
|
-
if (!o[
|
|
939
|
-
return
|
|
940
|
-
|
|
1014
|
+
let i = p + d;
|
|
1015
|
+
for (; i >= 0 && i < s; ) {
|
|
1016
|
+
if (!o[i].disable)
|
|
1017
|
+
return i;
|
|
1018
|
+
i += d;
|
|
941
1019
|
}
|
|
942
|
-
if (
|
|
1020
|
+
if (d === 1) {
|
|
943
1021
|
for (let r = 0; r < s; r++)
|
|
944
1022
|
if (!o[r].disable)
|
|
945
1023
|
return r;
|
|
@@ -948,7 +1026,10 @@ const Bn = ({
|
|
|
948
1026
|
if (!o[r].disable)
|
|
949
1027
|
return r;
|
|
950
1028
|
return -1;
|
|
951
|
-
},
|
|
1029
|
+
}, Dn = (o) => /* @__PURE__ */ l("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o, children: [
|
|
1030
|
+
/* @__PURE__ */ n("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor", opacity: "0.2" }),
|
|
1031
|
+
/* @__PURE__ */ n("path", { d: "M5.5 5.5l5 5M10.5 5.5l-5 5", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" })
|
|
1032
|
+
] }), dn = (o) => /* @__PURE__ */ n(
|
|
952
1033
|
"svg",
|
|
953
1034
|
{
|
|
954
1035
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -969,7 +1050,7 @@ const Bn = ({
|
|
|
969
1050
|
}
|
|
970
1051
|
)
|
|
971
1052
|
}
|
|
972
|
-
),
|
|
1053
|
+
), Sn = ({ width: o = 16 }) => /* @__PURE__ */ n(
|
|
973
1054
|
"svg",
|
|
974
1055
|
{
|
|
975
1056
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -989,7 +1070,7 @@ const Bn = ({
|
|
|
989
1070
|
}
|
|
990
1071
|
)
|
|
991
1072
|
}
|
|
992
|
-
),
|
|
1073
|
+
), jn = ({ width: o = 16 }) => /* @__PURE__ */ n(
|
|
993
1074
|
"svg",
|
|
994
1075
|
{
|
|
995
1076
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1011,5 +1092,5 @@ const Bn = ({
|
|
|
1011
1092
|
}
|
|
1012
1093
|
);
|
|
1013
1094
|
export {
|
|
1014
|
-
|
|
1095
|
+
On as Dropdown
|
|
1015
1096
|
};
|
package/dist/dropdown.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(v,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):(v=typeof globalThis<"u"?globalThis:v||self,n(v.Dropdown={},v.jsxRuntime,v.React))})(this,function(v,n,l){"use strict";const sn=`@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
|
|
2
2
|
* {
|
|
3
3
|
margin: 0;
|
|
4
4
|
padding: 0;
|
|
@@ -35,6 +35,15 @@
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/* === SIZE VARIANTS === */
|
|
38
|
+
.sa-input-dropdown-size-xs {
|
|
39
|
+
--baseFont: 12px;
|
|
40
|
+
--height: 28px;
|
|
41
|
+
--borderRadius: var(--sa-dropdown-radius);
|
|
42
|
+
--paddingInline: 8px;
|
|
43
|
+
--paddingBlock: 2px;
|
|
44
|
+
--iconSize: 14px;
|
|
45
|
+
--iconMarginTop: 4px;
|
|
46
|
+
}
|
|
38
47
|
.sa-input-dropdown-size-sm {
|
|
39
48
|
--baseFont: 12px;
|
|
40
49
|
--height: 32px;
|
|
@@ -42,6 +51,7 @@
|
|
|
42
51
|
--paddingInline: 12px;
|
|
43
52
|
--paddingBlock: 4px;
|
|
44
53
|
--iconSize: 16px;
|
|
54
|
+
--iconMarginTop: 4px;
|
|
45
55
|
}
|
|
46
56
|
.sa-input-dropdown-size-md {
|
|
47
57
|
--baseFont: 14px;
|
|
@@ -50,6 +60,7 @@
|
|
|
50
60
|
--paddingInline: 12px;
|
|
51
61
|
--paddingBlock: 8px;
|
|
52
62
|
--iconSize: 16px;
|
|
63
|
+
--iconMarginTop: 4px;
|
|
53
64
|
}
|
|
54
65
|
.sa-input-dropdown-size-lg {
|
|
55
66
|
--baseFont: 14px;
|
|
@@ -58,6 +69,7 @@
|
|
|
58
69
|
--paddingInline: 12px;
|
|
59
70
|
--paddingBlock: 12px;
|
|
60
71
|
--iconSize: 20px;
|
|
72
|
+
--iconMarginTop: 2px;
|
|
61
73
|
}
|
|
62
74
|
.sa-input-dropdown-size-xl {
|
|
63
75
|
--baseFont: 16px;
|
|
@@ -66,6 +78,7 @@
|
|
|
66
78
|
--paddingInline: 16px;
|
|
67
79
|
--paddingBlock: 16px;
|
|
68
80
|
--iconSize: 20px;
|
|
81
|
+
--iconMarginTop: 2px;
|
|
69
82
|
}
|
|
70
83
|
|
|
71
84
|
/* === BASE CONTAINER === */
|
|
@@ -157,12 +170,26 @@
|
|
|
157
170
|
display: flex;
|
|
158
171
|
flex-direction: row;
|
|
159
172
|
gap: 8px;
|
|
160
|
-
align-items:
|
|
173
|
+
align-items: flex-start;
|
|
161
174
|
justify-content: space-between;
|
|
162
175
|
width: 100%;
|
|
163
176
|
min-width: 0;
|
|
164
177
|
}
|
|
165
178
|
|
|
179
|
+
/* Chevron + clear button — top-aligned with margin so they appear visually
|
|
180
|
+
centered when single-line, and snap to top-right when content wraps */
|
|
181
|
+
.sa-input-dropdown-chevron,
|
|
182
|
+
.sa-input-dropdown-clear {
|
|
183
|
+
align-self: flex-start;
|
|
184
|
+
margin-top: var(--iconMarginTop, 4px);
|
|
185
|
+
}
|
|
186
|
+
.sa-input-dropdown-chevron {
|
|
187
|
+
display: inline-flex;
|
|
188
|
+
align-items: center;
|
|
189
|
+
justify-content: center;
|
|
190
|
+
flex-shrink: 0;
|
|
191
|
+
}
|
|
192
|
+
|
|
166
193
|
.sa-input-dropdown-container-preview-item {
|
|
167
194
|
flex: 1;
|
|
168
195
|
display: flex;
|
|
@@ -332,6 +359,7 @@
|
|
|
332
359
|
min-height: 32px;
|
|
333
360
|
font-size: 12px;
|
|
334
361
|
}
|
|
362
|
+
.sa-input-dropdown-size-xs .sa-input-dropdown-item,
|
|
335
363
|
.sa-input-dropdown-size-sm .sa-input-dropdown-item,
|
|
336
364
|
.sa-input-dropdown-size-md .sa-input-dropdown-item {
|
|
337
365
|
font-size: 12px;
|
|
@@ -483,4 +511,35 @@
|
|
|
483
511
|
margin: 0;
|
|
484
512
|
}
|
|
485
513
|
|
|
486
|
-
`;function an(o){const[p,d]=l.useState(o),t=l.useRef(null),i=r=>{t.current&&!t.current.contains(r.target)&&d(!1)};return l.useEffect(()=>(document.addEventListener("click",i,!0),()=>{document.removeEventListener("click",i,!0)}),[]),{ref:t,isComponentVisible:p,setIsComponentVisible:d}}const sn=({...o})=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",...o,viewBox:"0 0 20 20",fill:"none",children:[n.jsx("circle",{cx:"9.80547",cy:"9.8055",r:"7.49047",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M15.0153 15.4043L17.9519 18.3333",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),dn=({width:o=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 16 16",fill:"none",children:n.jsx("path",{d:"M3.5 8L6.5 11L12.5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),tn=l.forwardRef(({positionDropdown:o,dropdownLists:p,isComponentVisible:d,searchAble:t,hideSearch:i,onSearch:r,value:k,handleChangeValue:f,multiSelect:C,searchValue:z,highlightedIndex:y,footer:I,groupLabel:F,onSelectAll:L},q)=>{const j=l.useRef([]);l.useEffect(()=>{var s;y>=0&&j.current[y]&&((s=j.current[y])==null||s.scrollIntoView({block:"nearest"}))},[y]);const M=t&&!i?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(sn,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:s=>{r&&r(s.target.value)},value:z,autoFocus:!0,placeholder:"Search..."})]}):null;return n.jsx(n.Fragment,{children:d?n.jsxs("div",{className:"sa-input-dropdown-lists-container",onClick:s=>s.stopPropagation(),ref:q,children:[o!=="top"&&M,n.jsxs("div",{className:`sa-input-dropdown-item-container ${C?"multi":""}`,children:[F&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:F}),C&&L&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:s=>{s.stopPropagation(),L()},children:"Select all"})]}),p.map((s,P)=>{const H=!!(k!=null&&k.find(A=>A.value===s.value)),w=!!s.description;return n.jsxs("div",{className:["sa-input-dropdown-item",w?"has-description":"",H?"active":"",P===y?"highlight":"",s.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),ref:A=>{j.current[P]=A},onClick:()=>f(s.label,s.value),children:[C&&n.jsx("div",{className:"sa-input-dropdown-item-check",children:H&&n.jsx(dn,{width:16})}),s.icon&&n.jsx("div",{style:{flexShrink:0,display:"flex"},children:l.cloneElement(s.icon,{width:16})}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsx("p",{className:["sa-input-dropdown-item-text",s.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:s.label}),s.description&&n.jsx("p",{className:["sa-input-dropdown-item-text-description",s.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:s.description})]})]},P)})]}),o==="top"&&M,I&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:s=>s.stopPropagation(),children:I})]}):null})}),ln=({children:o,handleChangePosition:p})=>{const d=l.useRef(null);l.useEffect(()=>{var k;const i=()=>{if(d.current){let f=d.current.parentElement;for(;f&&!t(f);)f=f.parentElement;f&&p()}};let r=(k=d.current)==null?void 0:k.parentElement;for(;r&&!t(r);)r=r.parentElement;return r&&r.addEventListener("scroll",i),i(),()=>{r&&r.removeEventListener("scroll",i)}},[]);const t=i=>i&&(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth);return n.jsx("div",{ref:d,children:o})},Y="sa-input-dropdown-styles";(o=>{if(!document.getElementById(Y)){const p=document.createElement("style");p.id=Y,p.textContent=o,document.head.appendChild(p)}})(rn);const pn=({dropdownLists:o,onChange:p,defaultValue:d,value:t,size:i="md",multiSelect:r,searchAble:k,iconLeft:f,placeholder:C,onSearch:z,error:y,onBlur:I,onFocus:F,disable:L,searchValue:q,variant:j="outline",footer:M,groupLabel:s,onSelectAll:P,fullWidth:H=!0,triggerInput:w=!1,clearOnSelect:A=!1,hideChevronIcon:fn=!1,label:G,labelPosition:hn="outside-top",required:R,optional:nn,description:B,helperText:S,errorText:h})=>{const T=["sa-select-field",H?"sa-select-field-fullwidth":""].filter(Boolean).join(" "),D=t!==void 0,K=l.useRef(),un=y||!!h,[c,O]=l.useState(D?t||[]:d||[]),[bn,en]=l.useState(""),[m,U]=l.useState(-1),[gn,J]=l.useState(()=>{var e,a;return!r&&(t!=null&&t.length||d!=null&&d.length)?((e=t==null?void 0:t[0])==null?void 0:e.label)??((a=d==null?void 0:d[0])==null?void 0:a.label)??"":""}),g=l.useRef(null),{isComponentVisible:u,ref:Z,setIsComponentVisible:E}=an(!1),W=o!==void 0,vn=()=>{W&&E(e=>!e)},$=(e,a)=>{if(r){if(c==null?void 0:c.find(v=>v.value===a)){const v=c.filter(mn=>mn.value!==a);D||O(v),p(v)}else{const v=[...c,{label:e,value:a}];D||O(v),p(v)}w&&J("")}else{const b=[{label:e,value:a}];D||O(b),p(b),w&&J(A?"":e),E(!1)}};l.useEffect(()=>{D&&O(t||[])},[t]),l.useEffect(()=>{D||JSON.stringify(K.current)===JSON.stringify(d)||(K.current=d,O(K.current||[]))},[d]);const xn=()=>c.length?r?c==null?void 0:c.map((e,a)=>n.jsxs("div",{className:"sa-input-dropdown-preview-item",children:[n.jsx("p",{style:{minWidth:"max-content"},children:e==null?void 0:e.label}),n.jsx(V,{onClick:b=>{b.stopPropagation(),$(e.label,e.value)}})]},a)):n.jsx("p",{style:{minWidth:"max-content"},children:c==null?void 0:c[0].label}):n.jsx("p",{className:"sa-input-dropdown-placeholder",children:C}),N=()=>{if(Z.current&&g.current){const e=window.innerHeight,a=Z.current.getBoundingClientRect(),b=g.current.getBoundingClientRect(),v=a.bottom+b.height;g.current.style.left=`${a.left}px`,g.current.style.width=`${a.width}px`,v>=e-10?(g.current.style.top=`${a.top-b.height-5}px`,en("top")):(g.current.style.top=`${a.top+a.height+4}px`,en("bottom"))}};l.useEffect(()=>(window.addEventListener("scroll",N),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N),window.removeEventListener("resize",N)}),[]),l.useEffect(()=>{N()},[u]),l.useEffect(()=>{if(!u||!g.current)return;const e=new ResizeObserver(()=>{N()});return e.observe(g.current),()=>e.disconnect()},[u]),l.useEffect(()=>{u||U(-1)},[u]);const on=e=>{if(W){if(!u){(e.key==="ArrowDown"||e.key==="Enter")&&(e.preventDefault(),E(!0));return}switch(e.key){case"ArrowDown":{e.preventDefault();const a=_(o,m,1);a!==-1&&U(a);break}case"ArrowUp":{e.preventDefault();const a=_(o,m,-1);a!==-1&&U(a);break}case"Enter":{e.preventDefault(),m>=0&&o[m]&&!o[m].disable&&$(o[m].label,o[m].value);break}case"Escape":E(!1);break}}},Q=i==="lg"||i==="xl"?20:16,kn=w?n.jsxs(n.Fragment,{children:[r&&c.map((e,a)=>n.jsxs("div",{className:"sa-input-dropdown-preview-item",children:[n.jsx("p",{style:{minWidth:"max-content"},children:e==null?void 0:e.label}),n.jsx(V,{onClick:b=>{b.stopPropagation(),$(e.label,e.value)}})]},a)),n.jsx("input",{className:"sa-input-dropdown-trigger-input",value:gn,onChange:e=>{const a=e.target.value;J(a),z==null||z(a),!u&&W&&E(!0)},onFocus:()=>{!L&&W&&E(!0)},onBlur:()=>{r||setTimeout(()=>E(!1),150)},onKeyDown:on,placeholder:c.length===0||r?C:void 0,disabled:L})]}):null,X=n.jsx(ln,{handleChangePosition:N,children:n.jsxs("div",{className:["sa-input-dropdown-container",j,`sa-input-dropdown-size-${i}`,w?"trigger-input":"",u?"active":"",un?"error":"",L?"disable":""].filter(Boolean).join(" "),ref:Z,onClick:w?void 0:vn,onKeyDown:w?void 0:on,tabIndex:w?void 0:0,onBlur:w?void 0:I,onFocus:w?void 0:F,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[f?l.cloneElement(f,{width:Q,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:w?kn:xn()}),!fn&&(u?n.jsx(wn,{width:Q}):n.jsx(cn,{width:Q}))]}),W&&n.jsx(tn,{dropdownLists:o,handleChangeValue:$,isComponentVisible:u,positionDropdown:bn,searchAble:!!k,hideSearch:w,value:c,onSearch:z,ref:g,multiSelect:r,searchValue:q,highlightedIndex:m,footer:M,groupLabel:s,onSelectAll:P})]})});return G?hn==="outside-left"?n.jsxs("div",{className:`${T} sa-select-field-left`,children:[n.jsxs("div",{className:"sa-select-field-left-label",children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:G}),nn&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),R&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),B&&n.jsx("p",{className:"sa-select-field-helper-top",children:B})]}),n.jsxs("div",{className:"sa-select-field-input-wrap",children:[X,S&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:S}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]})]}):n.jsxs("div",{className:T,children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:G}),nn&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),R&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),B&&n.jsx("p",{className:"sa-select-field-helper-top",children:B}),X,S&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:S}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]}):n.jsxs("div",{className:T,children:[B&&n.jsx("p",{className:"sa-select-field-helper-top",children:B}),X,S&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:S}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]})},_=(o,p,d)=>{const t=o.length;let i=p+d;for(;i>=0&&i<t;){if(!o[i].disable)return i;i+=d}if(d===1){for(let r=0;r<t;r++)if(!o[r].disable)return r}else for(let r=t-1;r>=0;r--)if(!o[r].disable)return r;return-1},V=o=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 18 18",fill:"none",style:{flexShrink:0,cursor:"pointer"},...o,children:n.jsx("path",{d:"M12 6L6 12M6.00001 6L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),cn=({width:o=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 16 16",fill:"none",style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0},children:n.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),wn=({width:o=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 16 16",fill:"none",style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0},children:n.jsx("path",{d:"M4 10L8 6L12 10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});x.Dropdown=pn,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
|
|
514
|
+
/* === CLEAR BUTTON === */
|
|
515
|
+
.sa-input-dropdown-clear {
|
|
516
|
+
appearance: none;
|
|
517
|
+
border: 0;
|
|
518
|
+
background: transparent;
|
|
519
|
+
padding: 0;
|
|
520
|
+
cursor: pointer;
|
|
521
|
+
color: var(--sa-dropdown-placeholder);
|
|
522
|
+
border-radius: 50%;
|
|
523
|
+
flex-shrink: 0;
|
|
524
|
+
display: inline-flex;
|
|
525
|
+
align-items: center;
|
|
526
|
+
justify-content: center;
|
|
527
|
+
opacity: 1;
|
|
528
|
+
transition: opacity 120ms ease, color 120ms ease, transform 80ms ease;
|
|
529
|
+
}
|
|
530
|
+
.sa-input-dropdown-clear:hover {
|
|
531
|
+
color: var(--sa-dropdown-text-secondary);
|
|
532
|
+
}
|
|
533
|
+
.sa-input-dropdown-clear:active {
|
|
534
|
+
transform: scale(0.92);
|
|
535
|
+
}
|
|
536
|
+
.sa-input-dropdown-clear-hidden {
|
|
537
|
+
opacity: 0;
|
|
538
|
+
pointer-events: none;
|
|
539
|
+
cursor: default;
|
|
540
|
+
}
|
|
541
|
+
.sa-input-dropdown-container.disable .sa-input-dropdown-clear {
|
|
542
|
+
display: none;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
`;function dn(o){const[p,d]=l.useState(o),t=l.useRef(null),s=r=>{t.current&&!t.current.contains(r.target)&&d(!1)};return l.useEffect(()=>(document.addEventListener("click",s,!0),()=>{document.removeEventListener("click",s,!0)}),[]),{ref:t,isComponentVisible:p,setIsComponentVisible:d}}const tn=({...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"})]}),ln=({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"})}),pn=l.forwardRef(({positionDropdown:o,dropdownLists:p,isComponentVisible:d,searchAble:t,hideSearch:s,onSearch:r,value:k,handleChangeValue:h,multiSelect:L,searchValue:B,highlightedIndex:y,footer:I,groupLabel:F,onSelectAll:N},G)=>{const P=l.useRef([]);l.useEffect(()=>{var i;y>=0&&P.current[y]&&((i=P.current[y])==null||i.scrollIntoView({block:"nearest"}))},[y]);const T=t&&!s?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(tn,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:i=>{r&&r(i.target.value)},value:B,autoFocus:!0,placeholder:"Search..."})]}):null;return n.jsx(n.Fragment,{children:d?n.jsxs("div",{className:"sa-input-dropdown-lists-container",onClick:i=>i.stopPropagation(),ref:G,children:[o!=="top"&&T,n.jsxs("div",{className:`sa-input-dropdown-item-container ${L?"multi":""}`,children:[F&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:F}),L&&N&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:i=>{i.stopPropagation(),N()},children:"Select all"})]}),p.map((i,A)=>{const H=!!(k!=null&&k.find(O=>O.value===i.value)),w=!!i.description;return n.jsxs("div",{className:["sa-input-dropdown-item",w?"has-description":"",H?"active":"",A===y?"highlight":"",i.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),ref:O=>{P.current[A]=O},onClick:()=>h(i.label,i.value),children:[L&&n.jsx("div",{className:"sa-input-dropdown-item-check",children:H&&n.jsx(ln,{width:16})}),i.icon&&n.jsx("div",{style:{flexShrink:0,display:"flex"},children:l.cloneElement(i.icon,{width:16})}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsx("p",{className:["sa-input-dropdown-item-text",i.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:i.label}),i.description&&n.jsx("p",{className:["sa-input-dropdown-item-text-description",i.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:i.description})]})]},A)})]}),o==="top"&&T,I&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:i=>i.stopPropagation(),children:I})]}):null})}),cn=({children:o,handleChangePosition:p})=>{const d=l.useRef(null);l.useEffect(()=>{var k;const s=()=>{if(d.current){let h=d.current.parentElement;for(;h&&!t(h);)h=h.parentElement;h&&p()}};let r=(k=d.current)==null?void 0:k.parentElement;for(;r&&!t(r);)r=r.parentElement;return r&&r.addEventListener("scroll",s),s(),()=>{r&&r.removeEventListener("scroll",s)}},[]);const t=s=>s&&(s.scrollHeight>s.clientHeight||s.scrollWidth>s.clientWidth);return n.jsx("div",{ref:d,children:o})},_="sa-input-dropdown-styles";(o=>{if(!document.getElementById(_)){const p=document.createElement("style");p.id=_,p.textContent=o,document.head.appendChild(p)}})(sn);const wn=({dropdownLists:o,onChange:p,defaultValue:d,value:t,size:s="sm",multiSelect:r,searchAble:k,iconLeft:h,placeholder:L,onSearch:B,error:y,onBlur:I,onFocus:F,disable:N,searchValue:G,variant:P="outline",footer:T,groupLabel:i,onSelectAll:A,fullWidth:H=!0,triggerInput:w=!1,clearOnSelect:O=!1,hideChevronIcon:bn=!1,clearable:gn=!1,onClear:U,label:K,labelPosition:xn="outside-top",required:nn,optional:en,description:S,helperText:D,errorText:f})=>{const J=["sa-select-field",H?"sa-select-field-fullwidth":""].filter(Boolean).join(" "),E=t!==void 0,Z=l.useRef(),vn=y||!!f,[c,j]=l.useState(E?t||[]:d||[]),[kn,on]=l.useState(""),[m,Q]=l.useState(-1),[mn,$]=l.useState(()=>{var e,a;return!r&&(t!=null&&t.length||d!=null&&d.length)?((e=t==null?void 0:t[0])==null?void 0:e.label)??((a=d==null?void 0:d[0])==null?void 0:a.label)??"":""}),g=l.useRef(null),{isComponentVisible:u,ref:X,setIsComponentVisible:C}=dn(!1),M=o!==void 0,rn=c.length>0,yn=e=>{e.stopPropagation();const a=[];E||j(a),p(a),w&&$(""),U==null||U()},Nn=()=>{M&&C(e=>!e)},q=(e,a)=>{if(r){if(c==null?void 0:c.find(x=>x.value===a)){const x=c.filter(Ln=>Ln.value!==a);E||j(x),p(x)}else{const x=[...c,{label:e,value:a}];E||j(x),p(x)}w&&$("")}else{const b=[{label:e,value:a}];E||j(b),p(b),w&&$(O?"":e),C(!1)}};l.useEffect(()=>{E&&j(t||[])},[t]),l.useEffect(()=>{E||JSON.stringify(Z.current)===JSON.stringify(d)||(Z.current=d,j(Z.current||[]))},[d]);const En=()=>c.length?r?c==null?void 0:c.map((e,a)=>n.jsxs("div",{className:"sa-input-dropdown-preview-item",children:[n.jsx("p",{style:{minWidth:"max-content"},children:e==null?void 0:e.label}),n.jsx(R,{onClick:b=>{b.stopPropagation(),q(e.label,e.value)}})]},a)):n.jsx("p",{style:{minWidth:"max-content"},children:c==null?void 0:c[0].label}):n.jsx("p",{className:"sa-input-dropdown-placeholder",children:L}),z=()=>{if(X.current&&g.current){const e=window.innerHeight,a=X.current.getBoundingClientRect(),b=g.current.getBoundingClientRect(),x=a.bottom+b.height;g.current.style.left=`${a.left}px`,g.current.style.width=`${a.width}px`,x>=e-10?(g.current.style.top=`${a.top-b.height-5}px`,on("top")):(g.current.style.top=`${a.top+a.height+4}px`,on("bottom"))}};l.useEffect(()=>(window.addEventListener("scroll",z),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z),window.removeEventListener("resize",z)}),[]),l.useEffect(()=>{z()},[u]),l.useEffect(()=>{if(!u||!g.current)return;const e=new ResizeObserver(()=>{z()});return e.observe(g.current),()=>e.disconnect()},[u]),l.useEffect(()=>{u||Q(-1)},[u]);const an=e=>{if(M){if(!u){(e.key==="ArrowDown"||e.key==="Enter")&&(e.preventDefault(),C(!0));return}switch(e.key){case"ArrowDown":{e.preventDefault();const a=V(o,m,1);a!==-1&&Q(a);break}case"ArrowUp":{e.preventDefault();const a=V(o,m,-1);a!==-1&&Q(a);break}case"Enter":{e.preventDefault(),m>=0&&o[m]&&!o[m].disable&&q(o[m].label,o[m].value);break}case"Escape":C(!1);break}}},W=s==="lg"||s==="xl"?20:s==="xs"?14:16,Cn=gn&&!N?n.jsx("button",{type:"button",className:`sa-input-dropdown-clear${rn?"":" sa-input-dropdown-clear-hidden"}`,"aria-label":"Clear selection","aria-hidden":!rn,tabIndex:-1,onClick:yn,onMouseDown:e=>e.preventDefault(),children:n.jsx(hn,{width:W,height:W})}):null,zn=w?n.jsxs(n.Fragment,{children:[r&&c.map((e,a)=>n.jsxs("div",{className:"sa-input-dropdown-preview-item",children:[n.jsx("p",{style:{minWidth:"max-content"},children:e==null?void 0:e.label}),n.jsx(R,{onClick:b=>{b.stopPropagation(),q(e.label,e.value)}})]},a)),n.jsx("input",{className:"sa-input-dropdown-trigger-input",value:mn,onChange:e=>{const a=e.target.value;$(a),B==null||B(a),!u&&M&&C(!0)},onFocus:()=>{!N&&M&&C(!0)},onBlur:()=>{r||setTimeout(()=>C(!1),150)},onKeyDown:an,placeholder:c.length===0||r?L:void 0,disabled:N})]}):null,Y=n.jsx(cn,{handleChangePosition:z,children:n.jsxs("div",{className:["sa-input-dropdown-container",P,`sa-input-dropdown-size-${s}`,w?"trigger-input":"",u?"active":"",vn?"error":"",N?"disable":""].filter(Boolean).join(" "),ref:X,onClick:w?void 0:Nn,onKeyDown:w?void 0:an,tabIndex:w?void 0:0,onBlur:w?void 0:I,onFocus:w?void 0:F,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[h?l.cloneElement(h,{width:W,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:w?zn:En()}),Cn,!bn&&n.jsx("div",{className:"sa-input-dropdown-chevron",children:u?n.jsx(un,{width:W}):n.jsx(fn,{width:W})})]}),M&&n.jsx(pn,{dropdownLists:o,handleChangeValue:q,isComponentVisible:u,positionDropdown:kn,searchAble:!!k,hideSearch:w,value:c,onSearch:B,ref:g,multiSelect:r,searchValue:G,highlightedIndex:m,footer:T,groupLabel:i,onSelectAll:A})]})});return K?xn==="outside-left"?n.jsxs("div",{className:`${J} 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:K}),en&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),nn&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S})]}),n.jsxs("div",{className:"sa-select-field-input-wrap",children:[Y,D&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:D}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]})]}):n.jsxs("div",{className:J,children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:K}),en&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),nn&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S}),Y,D&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:D}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]}):n.jsxs("div",{className:J,children:[S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S}),Y,D&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:D}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]})},V=(o,p,d)=>{const t=o.length;let s=p+d;for(;s>=0&&s<t;){if(!o[s].disable)return s;s+=d}if(d===1){for(let r=0;r<t;r++)if(!o[r].disable)return r}else for(let r=t-1;r>=0;r--)if(!o[r].disable)return r;return-1},hn=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"})]}),R=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"})}),fn=({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"})}),un=({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"})});v.Dropdown=wn,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export interface IconPropsDropdown extends React.SVGProps<SVGSVGElement> {
|
|
3
3
|
}
|
|
4
|
-
export type DropdownSize = "sm" | "md" | "lg" | "xl";
|
|
4
|
+
export type DropdownSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
5
5
|
export type DropdownVariant = "standard" | "outline" | "flushed";
|
|
6
6
|
export type DropdownLabelPosition = "outside-top" | "outside-left";
|
|
7
7
|
export interface IDropdown {
|
|
@@ -44,6 +44,8 @@ export interface IDropdown {
|
|
|
44
44
|
triggerInput?: boolean;
|
|
45
45
|
clearOnSelect?: boolean;
|
|
46
46
|
hideChevronIcon?: boolean;
|
|
47
|
+
clearable?: boolean;
|
|
48
|
+
onClear?: () => void;
|
|
47
49
|
label?: React.ReactNode;
|
|
48
50
|
labelPosition?: DropdownLabelPosition;
|
|
49
51
|
required?: boolean;
|