@starasia/dropdown 5.0.2 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DropdownList.d.ts +1 -0
- package/dist/dropdown.es.js +319 -239
- package/dist/dropdown.umd.js +52 -15
- package/dist/interface.d.ts +2 -0
- package/package.json +1 -1
package/dist/DropdownList.d.ts
CHANGED
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 an } from "react/jsx-runtime";
|
|
2
|
+
import tn, { useState as P, useRef as W, useEffect as x, forwardRef as fn } from "react";
|
|
3
|
+
const bn = `@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;
|
|
@@ -199,13 +199,45 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
199
199
|
color: var(--sa-dropdown-placeholder-subtle);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
/* === TRIGGER INPUT MODE === */
|
|
203
|
+
.sa-input-dropdown-container.trigger-input {
|
|
204
|
+
cursor: text;
|
|
205
|
+
}
|
|
206
|
+
.sa-input-dropdown-container.trigger-input .sa-input-dropdown-container-preview-item {
|
|
207
|
+
flex-wrap: wrap;
|
|
208
|
+
gap: 4px;
|
|
209
|
+
align-items: center;
|
|
210
|
+
}
|
|
211
|
+
.sa-input-dropdown-trigger-input {
|
|
212
|
+
flex: 1;
|
|
213
|
+
min-width: 80px;
|
|
214
|
+
border: none;
|
|
215
|
+
outline: none;
|
|
216
|
+
background: transparent;
|
|
217
|
+
font-size: var(--baseFont);
|
|
218
|
+
font-family: inherit;
|
|
219
|
+
color: var(--sa-dropdown-text-primary);
|
|
220
|
+
padding: 0;
|
|
221
|
+
line-height: normal;
|
|
222
|
+
}
|
|
223
|
+
.sa-input-dropdown-trigger-input::placeholder {
|
|
224
|
+
color: var(--sa-dropdown-placeholder);
|
|
225
|
+
}
|
|
226
|
+
.sa-input-dropdown-container.outline .sa-input-dropdown-trigger-input::placeholder,
|
|
227
|
+
.sa-input-dropdown-container.flushed .sa-input-dropdown-trigger-input::placeholder {
|
|
228
|
+
color: var(--sa-dropdown-placeholder-subtle);
|
|
229
|
+
}
|
|
230
|
+
.sa-input-dropdown-container.disable .sa-input-dropdown-trigger-input {
|
|
231
|
+
cursor: not-allowed;
|
|
232
|
+
}
|
|
233
|
+
|
|
202
234
|
/* === DROPDOWN PANEL === */
|
|
203
235
|
.sa-input-dropdown-lists-container {
|
|
204
236
|
position: fixed;
|
|
205
237
|
background-color: var(--sa-dropdown-bg);
|
|
206
238
|
border-radius: var(--sa-dropdown-radius);
|
|
207
239
|
box-shadow: var(--sa-dropdown-shadow-panel);
|
|
208
|
-
max-height: min(
|
|
240
|
+
max-height: min(360px, calc(100vh - 80px));
|
|
209
241
|
overflow: hidden;
|
|
210
242
|
z-index: 999;
|
|
211
243
|
width: 100%;
|
|
@@ -244,7 +276,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
244
276
|
}
|
|
245
277
|
|
|
246
278
|
/* === LIST SCROLL AREA === */
|
|
247
|
-
.sa-input-
|
|
279
|
+
.sa-input-dropdown-item-container {
|
|
248
280
|
flex: 1 1 auto;
|
|
249
281
|
overflow-y: auto;
|
|
250
282
|
min-height: 0;
|
|
@@ -284,8 +316,8 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
284
316
|
}
|
|
285
317
|
|
|
286
318
|
/* === LIST ITEMS === */
|
|
287
|
-
.sa-input-
|
|
288
|
-
min-height:
|
|
319
|
+
.sa-input-dropdown-item {
|
|
320
|
+
min-height: 32px;
|
|
289
321
|
box-sizing: border-box;
|
|
290
322
|
padding: 4px 12px 4px 8px;
|
|
291
323
|
display: flex;
|
|
@@ -298,32 +330,37 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
298
330
|
font-size: 14px;
|
|
299
331
|
transition: background-color 0.12s ease;
|
|
300
332
|
}
|
|
301
|
-
.sa-input-
|
|
333
|
+
.sa-input-dropdown-item.has-description {
|
|
302
334
|
min-height: 32px;
|
|
303
335
|
font-size: 12px;
|
|
304
336
|
}
|
|
305
|
-
.sa-input-
|
|
337
|
+
.sa-input-dropdown-size-sm .sa-input-dropdown-item,
|
|
338
|
+
.sa-input-dropdown-size-md .sa-input-dropdown-item {
|
|
339
|
+
font-size: 12px;
|
|
340
|
+
font-weight: 500;
|
|
341
|
+
}
|
|
342
|
+
.sa-input-dropdown-item:hover:not(.sa-input-dropdown-item-disable) {
|
|
306
343
|
background-color: var(--sa-dropdown-bg-hover);
|
|
307
344
|
}
|
|
308
|
-
.sa-input-
|
|
345
|
+
.sa-input-dropdown-item.active {
|
|
309
346
|
background-color: var(--sa-dropdown-bg-selected);
|
|
310
347
|
}
|
|
311
|
-
.sa-input-
|
|
348
|
+
.sa-input-dropdown-item.active:hover {
|
|
312
349
|
background-color: var(--sa-dropdown-bg-selected);
|
|
313
350
|
}
|
|
314
|
-
.sa-input-
|
|
351
|
+
.sa-input-dropdown-item.highlight {
|
|
315
352
|
background-color: var(--sa-dropdown-bg-selected);
|
|
316
353
|
outline: 1.2px solid var(--sa-dropdown-border-active);
|
|
317
354
|
outline-offset: -1.2px;
|
|
318
355
|
}
|
|
319
|
-
.sa-input-
|
|
356
|
+
.sa-input-dropdown-item-disable {
|
|
320
357
|
color: var(--sa-dropdown-color-disable) !important;
|
|
321
358
|
pointer-events: none;
|
|
322
359
|
cursor: not-allowed;
|
|
323
360
|
}
|
|
324
361
|
|
|
325
362
|
/* check indicator for selected items in single-select mode */
|
|
326
|
-
.sa-input-
|
|
363
|
+
.sa-input-dropdown-item-check {
|
|
327
364
|
flex-shrink: 0;
|
|
328
365
|
width: 20px;
|
|
329
366
|
height: 20px;
|
|
@@ -333,7 +370,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
333
370
|
color: var(--sa-dropdown-brand);
|
|
334
371
|
}
|
|
335
372
|
|
|
336
|
-
.sa-input-
|
|
373
|
+
.sa-input-dropdown-item-text {
|
|
337
374
|
color: var(--sa-dropdown-text-primary);
|
|
338
375
|
font-size: inherit;
|
|
339
376
|
font-weight: 500;
|
|
@@ -342,7 +379,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
342
379
|
white-space: nowrap;
|
|
343
380
|
line-height: normal;
|
|
344
381
|
}
|
|
345
|
-
.sa-input-
|
|
382
|
+
.sa-input-dropdown-item-text-description {
|
|
346
383
|
color: var(--sa-dropdown-text-secondary);
|
|
347
384
|
font-size: 12px;
|
|
348
385
|
font-weight: 400;
|
|
@@ -449,19 +486,19 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
449
486
|
}
|
|
450
487
|
|
|
451
488
|
`;
|
|
452
|
-
function
|
|
453
|
-
const [p,
|
|
454
|
-
s.current && !s.current.contains(
|
|
489
|
+
function gn(o) {
|
|
490
|
+
const [p, t] = P(o), s = W(null), d = (r) => {
|
|
491
|
+
s.current && !s.current.contains(r.target) && t(!1);
|
|
455
492
|
};
|
|
456
|
-
return
|
|
457
|
-
document.removeEventListener("click",
|
|
458
|
-
}), []), { ref: s, isComponentVisible: p, setIsComponentVisible:
|
|
493
|
+
return x(() => (document.addEventListener("click", d, !0), () => {
|
|
494
|
+
document.removeEventListener("click", d, !0);
|
|
495
|
+
}), []), { ref: s, isComponentVisible: p, setIsComponentVisible: t };
|
|
459
496
|
}
|
|
460
|
-
const
|
|
497
|
+
const vn = ({ ...o }) => /* @__PURE__ */ l(
|
|
461
498
|
"svg",
|
|
462
499
|
{
|
|
463
500
|
xmlns: "http://www.w3.org/2000/svg",
|
|
464
|
-
...
|
|
501
|
+
...o,
|
|
465
502
|
viewBox: "0 0 20 20",
|
|
466
503
|
fill: "none",
|
|
467
504
|
children: [
|
|
@@ -489,12 +526,12 @@ const un = ({ ...e }) => /* @__PURE__ */ l(
|
|
|
489
526
|
)
|
|
490
527
|
]
|
|
491
528
|
}
|
|
492
|
-
),
|
|
529
|
+
), xn = ({ width: o = 16 }) => /* @__PURE__ */ n(
|
|
493
530
|
"svg",
|
|
494
531
|
{
|
|
495
532
|
xmlns: "http://www.w3.org/2000/svg",
|
|
496
|
-
width:
|
|
497
|
-
height:
|
|
533
|
+
width: o,
|
|
534
|
+
height: o,
|
|
498
535
|
viewBox: "0 0 16 16",
|
|
499
536
|
fill: "none",
|
|
500
537
|
children: /* @__PURE__ */ n(
|
|
@@ -508,93 +545,94 @@ const un = ({ ...e }) => /* @__PURE__ */ l(
|
|
|
508
545
|
}
|
|
509
546
|
)
|
|
510
547
|
}
|
|
511
|
-
),
|
|
548
|
+
), mn = fn(
|
|
512
549
|
({
|
|
513
|
-
positionDropdown:
|
|
550
|
+
positionDropdown: o,
|
|
514
551
|
dropdownLists: p,
|
|
515
|
-
isComponentVisible:
|
|
552
|
+
isComponentVisible: t,
|
|
516
553
|
searchAble: s,
|
|
554
|
+
hideSearch: d,
|
|
517
555
|
onSearch: r,
|
|
518
|
-
value:
|
|
519
|
-
handleChangeValue:
|
|
520
|
-
multiSelect:
|
|
521
|
-
searchValue:
|
|
522
|
-
highlightedIndex:
|
|
556
|
+
value: m,
|
|
557
|
+
handleChangeValue: u,
|
|
558
|
+
multiSelect: C,
|
|
559
|
+
searchValue: z,
|
|
560
|
+
highlightedIndex: y,
|
|
523
561
|
footer: I,
|
|
524
|
-
groupLabel:
|
|
525
|
-
onSelectAll:
|
|
526
|
-
},
|
|
527
|
-
const
|
|
528
|
-
|
|
562
|
+
groupLabel: F,
|
|
563
|
+
onSelectAll: R
|
|
564
|
+
}, q) => {
|
|
565
|
+
const D = W([]);
|
|
566
|
+
x(() => {
|
|
529
567
|
var a;
|
|
530
|
-
|
|
531
|
-
}, [
|
|
532
|
-
const
|
|
533
|
-
/* @__PURE__ */ n(
|
|
568
|
+
y >= 0 && D.current[y] && ((a = D.current[y]) == null || a.scrollIntoView({ block: "nearest" }));
|
|
569
|
+
}, [y]);
|
|
570
|
+
const H = s && !d ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
|
|
571
|
+
/* @__PURE__ */ n(vn, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
|
|
534
572
|
/* @__PURE__ */ n(
|
|
535
573
|
"input",
|
|
536
574
|
{
|
|
537
575
|
onChange: (a) => {
|
|
538
576
|
r && r(a.target.value);
|
|
539
577
|
},
|
|
540
|
-
value:
|
|
578
|
+
value: z,
|
|
541
579
|
autoFocus: !0,
|
|
542
580
|
placeholder: "Search..."
|
|
543
581
|
}
|
|
544
582
|
)
|
|
545
583
|
] }) : null;
|
|
546
|
-
return /* @__PURE__ */ n(
|
|
584
|
+
return /* @__PURE__ */ n(an, { children: t ? /* @__PURE__ */ l(
|
|
547
585
|
"div",
|
|
548
586
|
{
|
|
549
587
|
className: "sa-input-dropdown-lists-container",
|
|
550
588
|
onClick: (a) => a.stopPropagation(),
|
|
551
|
-
ref:
|
|
589
|
+
ref: q,
|
|
552
590
|
children: [
|
|
553
|
-
|
|
591
|
+
o !== "top" && H,
|
|
554
592
|
/* @__PURE__ */ l(
|
|
555
593
|
"div",
|
|
556
594
|
{
|
|
557
|
-
className: `sa-input-
|
|
595
|
+
className: `sa-input-dropdown-item-container ${C ? "multi" : ""}`,
|
|
558
596
|
children: [
|
|
559
|
-
|
|
560
|
-
/* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children:
|
|
561
|
-
|
|
597
|
+
F && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
|
|
598
|
+
/* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: F }),
|
|
599
|
+
C && R && /* @__PURE__ */ n(
|
|
562
600
|
"button",
|
|
563
601
|
{
|
|
564
602
|
className: "sa-input-dropdown-section-select-all",
|
|
565
603
|
onClick: (a) => {
|
|
566
|
-
a.stopPropagation(),
|
|
604
|
+
a.stopPropagation(), R();
|
|
567
605
|
},
|
|
568
606
|
children: "Select all"
|
|
569
607
|
}
|
|
570
608
|
)
|
|
571
609
|
] }),
|
|
572
|
-
p.map((a,
|
|
573
|
-
const
|
|
610
|
+
p.map((a, A) => {
|
|
611
|
+
const M = !!(m != null && m.find((j) => j.value === a.value)), w = !!a.description;
|
|
574
612
|
return /* @__PURE__ */ l(
|
|
575
613
|
"div",
|
|
576
614
|
{
|
|
577
615
|
className: [
|
|
578
|
-
"sa-input-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
a.disable ? "sa-input-
|
|
616
|
+
"sa-input-dropdown-item",
|
|
617
|
+
w ? "has-description" : "",
|
|
618
|
+
M ? "active" : "",
|
|
619
|
+
A === y ? "highlight" : "",
|
|
620
|
+
a.disable ? "sa-input-dropdown-item-disable" : ""
|
|
583
621
|
].filter(Boolean).join(" "),
|
|
584
|
-
ref: (
|
|
585
|
-
|
|
622
|
+
ref: (j) => {
|
|
623
|
+
D.current[A] = j;
|
|
586
624
|
},
|
|
587
|
-
onClick: () =>
|
|
625
|
+
onClick: () => u(a.label, a.value),
|
|
588
626
|
children: [
|
|
589
|
-
|
|
590
|
-
a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children:
|
|
627
|
+
C && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-item-check", children: M && /* @__PURE__ */ n(xn, { width: 16 }) }),
|
|
628
|
+
a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: tn.cloneElement(a.icon, { width: 16 }) }),
|
|
591
629
|
/* @__PURE__ */ l("div", { style: { minWidth: 0, flex: 1 }, children: [
|
|
592
630
|
/* @__PURE__ */ n(
|
|
593
631
|
"p",
|
|
594
632
|
{
|
|
595
633
|
className: [
|
|
596
|
-
"sa-input-
|
|
597
|
-
a.disable ? "sa-input-
|
|
634
|
+
"sa-input-dropdown-item-text",
|
|
635
|
+
a.disable ? "sa-input-dropdown-item-disable" : ""
|
|
598
636
|
].filter(Boolean).join(" "),
|
|
599
637
|
children: a.label
|
|
600
638
|
}
|
|
@@ -603,8 +641,8 @@ const un = ({ ...e }) => /* @__PURE__ */ l(
|
|
|
603
641
|
"p",
|
|
604
642
|
{
|
|
605
643
|
className: [
|
|
606
|
-
"sa-input-
|
|
607
|
-
a.disable ? "sa-input-
|
|
644
|
+
"sa-input-dropdown-item-text-description",
|
|
645
|
+
a.disable ? "sa-input-dropdown-item-disable" : ""
|
|
608
646
|
].filter(Boolean).join(" "),
|
|
609
647
|
children: a.description
|
|
610
648
|
}
|
|
@@ -612,260 +650,302 @@ const un = ({ ...e }) => /* @__PURE__ */ l(
|
|
|
612
650
|
] })
|
|
613
651
|
]
|
|
614
652
|
},
|
|
615
|
-
|
|
653
|
+
A
|
|
616
654
|
);
|
|
617
655
|
})
|
|
618
656
|
]
|
|
619
657
|
}
|
|
620
658
|
),
|
|
621
|
-
|
|
659
|
+
o === "top" && H,
|
|
622
660
|
I && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (a) => a.stopPropagation(), children: I })
|
|
623
661
|
]
|
|
624
662
|
}
|
|
625
663
|
) : null });
|
|
626
664
|
}
|
|
627
|
-
),
|
|
628
|
-
children:
|
|
665
|
+
), kn = ({
|
|
666
|
+
children: o,
|
|
629
667
|
handleChangePosition: p
|
|
630
668
|
}) => {
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
var
|
|
634
|
-
const
|
|
635
|
-
if (
|
|
636
|
-
let u =
|
|
669
|
+
const t = W(null);
|
|
670
|
+
x(() => {
|
|
671
|
+
var m;
|
|
672
|
+
const d = () => {
|
|
673
|
+
if (t.current) {
|
|
674
|
+
let u = t.current.parentElement;
|
|
637
675
|
for (; u && !s(u); )
|
|
638
676
|
u = u.parentElement;
|
|
639
677
|
u && p();
|
|
640
678
|
}
|
|
641
679
|
};
|
|
642
|
-
let
|
|
643
|
-
for (;
|
|
644
|
-
|
|
645
|
-
return
|
|
646
|
-
|
|
680
|
+
let r = (m = t.current) == null ? void 0 : m.parentElement;
|
|
681
|
+
for (; r && !s(r); )
|
|
682
|
+
r = r.parentElement;
|
|
683
|
+
return r && r.addEventListener("scroll", d), d(), () => {
|
|
684
|
+
r && r.removeEventListener("scroll", d);
|
|
647
685
|
};
|
|
648
686
|
}, []);
|
|
649
|
-
const s = (
|
|
650
|
-
return /* @__PURE__ */ n("div", { ref:
|
|
651
|
-
},
|
|
652
|
-
if (!document.getElementById(
|
|
687
|
+
const s = (d) => d && (d.scrollHeight > d.clientHeight || d.scrollWidth > d.clientWidth);
|
|
688
|
+
return /* @__PURE__ */ n("div", { ref: t, children: o });
|
|
689
|
+
}, en = "sa-input-dropdown-styles", yn = (o) => {
|
|
690
|
+
if (!document.getElementById(en)) {
|
|
653
691
|
const p = document.createElement("style");
|
|
654
|
-
p.id =
|
|
692
|
+
p.id = en, p.textContent = o, document.head.appendChild(p);
|
|
655
693
|
}
|
|
656
694
|
};
|
|
657
|
-
bn
|
|
658
|
-
const
|
|
659
|
-
dropdownLists:
|
|
695
|
+
yn(bn);
|
|
696
|
+
const Rn = ({
|
|
697
|
+
dropdownLists: o,
|
|
660
698
|
onChange: p,
|
|
661
|
-
defaultValue:
|
|
699
|
+
defaultValue: t,
|
|
662
700
|
value: s,
|
|
663
|
-
size:
|
|
664
|
-
multiSelect:
|
|
665
|
-
searchAble:
|
|
701
|
+
size: d = "md",
|
|
702
|
+
multiSelect: r,
|
|
703
|
+
searchAble: m,
|
|
666
704
|
iconLeft: u,
|
|
667
|
-
placeholder:
|
|
668
|
-
onSearch:
|
|
669
|
-
error:
|
|
670
|
-
onBlur:
|
|
671
|
-
onFocus:
|
|
672
|
-
disable:
|
|
673
|
-
searchValue:
|
|
674
|
-
variant:
|
|
675
|
-
footer:
|
|
676
|
-
groupLabel:
|
|
677
|
-
onSelectAll:
|
|
705
|
+
placeholder: C,
|
|
706
|
+
onSearch: z,
|
|
707
|
+
error: y,
|
|
708
|
+
onBlur: I,
|
|
709
|
+
onFocus: F,
|
|
710
|
+
disable: R,
|
|
711
|
+
searchValue: q,
|
|
712
|
+
variant: D = "outline",
|
|
713
|
+
footer: H,
|
|
714
|
+
groupLabel: a,
|
|
715
|
+
onSelectAll: A,
|
|
678
716
|
fullWidth: M = !0,
|
|
717
|
+
triggerInput: w = !1,
|
|
718
|
+
clearOnSelect: j = !1,
|
|
679
719
|
/* field wrapper */
|
|
680
|
-
label:
|
|
681
|
-
labelPosition:
|
|
682
|
-
required:
|
|
683
|
-
optional:
|
|
684
|
-
description:
|
|
685
|
-
helperText:
|
|
686
|
-
errorText:
|
|
720
|
+
label: G,
|
|
721
|
+
labelPosition: dn = "outside-top",
|
|
722
|
+
required: Y,
|
|
723
|
+
optional: _,
|
|
724
|
+
description: L,
|
|
725
|
+
helperText: B,
|
|
726
|
+
errorText: h
|
|
687
727
|
}) => {
|
|
688
|
-
const
|
|
728
|
+
const K = [
|
|
689
729
|
"sa-select-field",
|
|
690
730
|
M ? "sa-select-field-fullwidth" : ""
|
|
691
|
-
].filter(Boolean).join(" "),
|
|
692
|
-
|
|
693
|
-
), [
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
731
|
+
].filter(Boolean).join(" "), S = s !== void 0, U = W(), sn = y || !!h, [c, O] = P(
|
|
732
|
+
S ? s || [] : t || []
|
|
733
|
+
), [ln, V] = P(""), [k, J] = P(-1), [pn, T] = P(
|
|
734
|
+
() => {
|
|
735
|
+
var e, i;
|
|
736
|
+
return !r && (s != null && s.length || t != null && t.length) ? ((e = s == null ? void 0 : s[0]) == null ? void 0 : e.label) ?? ((i = t == null ? void 0 : t[0]) == null ? void 0 : i.label) ?? "" : "";
|
|
737
|
+
}
|
|
738
|
+
), g = W(null), { isComponentVisible: f, ref: Z, setIsComponentVisible: N } = gn(!1), cn = () => {
|
|
739
|
+
N((e) => !e);
|
|
740
|
+
}, $ = (e, i) => {
|
|
741
|
+
if (r) {
|
|
742
|
+
if (c == null ? void 0 : c.find((v) => v.value === i)) {
|
|
743
|
+
const v = c.filter((hn) => hn.value !== i);
|
|
744
|
+
S || O(v), p(v);
|
|
700
745
|
} else {
|
|
701
|
-
const
|
|
702
|
-
|
|
746
|
+
const v = [...c, { label: e, value: i }];
|
|
747
|
+
S || O(v), p(v);
|
|
703
748
|
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
749
|
+
w && T("");
|
|
750
|
+
} else {
|
|
751
|
+
const b = [{ label: e, value: i }];
|
|
752
|
+
S || O(b), p(b), w && T(j ? "" : e), N(!1);
|
|
707
753
|
}
|
|
708
754
|
};
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}, [s]),
|
|
712
|
-
|
|
713
|
-
}, [
|
|
714
|
-
const
|
|
715
|
-
/* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children:
|
|
755
|
+
x(() => {
|
|
756
|
+
S && O(s || []);
|
|
757
|
+
}, [s]), x(() => {
|
|
758
|
+
S || JSON.stringify(U.current) === JSON.stringify(t) || (U.current = t, O(U.current || []));
|
|
759
|
+
}, [t]);
|
|
760
|
+
const wn = () => c.length ? r ? c == null ? void 0 : c.map((e, i) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
|
|
761
|
+
/* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
|
|
716
762
|
/* @__PURE__ */ n(
|
|
717
|
-
|
|
763
|
+
rn,
|
|
718
764
|
{
|
|
719
|
-
onClick: (
|
|
720
|
-
|
|
765
|
+
onClick: (b) => {
|
|
766
|
+
b.stopPropagation(), $(e.label, e.value);
|
|
721
767
|
}
|
|
722
768
|
}
|
|
723
769
|
)
|
|
724
|
-
] }, i)) : /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: c == null ? void 0 : c[0].label }) : /* @__PURE__ */ n("p", { className: "sa-input-dropdown-placeholder", children:
|
|
725
|
-
if (
|
|
726
|
-
const
|
|
727
|
-
|
|
770
|
+
] }, i)) : /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: c == null ? void 0 : c[0].label }) : /* @__PURE__ */ n("p", { className: "sa-input-dropdown-placeholder", children: C }), E = () => {
|
|
771
|
+
if (Z.current && g.current) {
|
|
772
|
+
const e = window.innerHeight, i = Z.current.getBoundingClientRect(), b = g.current.getBoundingClientRect(), v = i.bottom + b.height;
|
|
773
|
+
g.current.style.left = `${i.left}px`, g.current.style.width = `${i.width}px`, v >= e - 10 ? (g.current.style.top = `${i.top - b.height - 5}px`, V("top")) : (g.current.style.top = `${i.top + i.height + 4}px`, V("bottom"));
|
|
728
774
|
}
|
|
729
775
|
};
|
|
730
|
-
|
|
731
|
-
window.removeEventListener("scroll",
|
|
732
|
-
}), []),
|
|
733
|
-
|
|
734
|
-
}, [f]),
|
|
735
|
-
if (!f || !
|
|
776
|
+
x(() => (window.addEventListener("scroll", E), window.addEventListener("resize", E), () => {
|
|
777
|
+
window.removeEventListener("scroll", E), window.removeEventListener("resize", E);
|
|
778
|
+
}), []), x(() => {
|
|
779
|
+
E();
|
|
780
|
+
}, [f]), x(() => {
|
|
781
|
+
if (!f || !g.current)
|
|
736
782
|
return;
|
|
737
|
-
const
|
|
738
|
-
|
|
783
|
+
const e = new ResizeObserver(() => {
|
|
784
|
+
E();
|
|
739
785
|
});
|
|
740
|
-
return
|
|
741
|
-
}, [f]),
|
|
742
|
-
f ||
|
|
786
|
+
return e.observe(g.current), () => e.disconnect();
|
|
787
|
+
}, [f]), x(() => {
|
|
788
|
+
f || J(-1);
|
|
743
789
|
}, [f]);
|
|
744
|
-
const
|
|
790
|
+
const nn = (e) => {
|
|
745
791
|
if (!f) {
|
|
746
|
-
(
|
|
792
|
+
(e.key === "ArrowDown" || e.key === "Enter") && (e.preventDefault(), N(!0));
|
|
747
793
|
return;
|
|
748
794
|
}
|
|
749
|
-
switch (
|
|
795
|
+
switch (e.key) {
|
|
750
796
|
case "ArrowDown": {
|
|
751
|
-
|
|
752
|
-
const i =
|
|
753
|
-
i !== -1 &&
|
|
797
|
+
e.preventDefault();
|
|
798
|
+
const i = on(o, k, 1);
|
|
799
|
+
i !== -1 && J(i);
|
|
754
800
|
break;
|
|
755
801
|
}
|
|
756
802
|
case "ArrowUp": {
|
|
757
|
-
|
|
758
|
-
const i =
|
|
759
|
-
i !== -1 &&
|
|
803
|
+
e.preventDefault();
|
|
804
|
+
const i = on(o, k, -1);
|
|
805
|
+
i !== -1 && J(i);
|
|
760
806
|
break;
|
|
761
807
|
}
|
|
762
808
|
case "Enter": {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
809
|
+
e.preventDefault(), k >= 0 && o[k] && !o[k].disable && $(
|
|
810
|
+
o[k].label,
|
|
811
|
+
o[k].value
|
|
766
812
|
);
|
|
767
813
|
break;
|
|
768
814
|
}
|
|
769
815
|
case "Escape":
|
|
770
|
-
|
|
816
|
+
N(!1);
|
|
771
817
|
break;
|
|
772
818
|
}
|
|
773
|
-
},
|
|
819
|
+
}, Q = d === "lg" || d === "xl" ? 20 : 16, un = w ? /* @__PURE__ */ l(an, { children: [
|
|
820
|
+
r && c.map((e, i) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
|
|
821
|
+
/* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
|
|
822
|
+
/* @__PURE__ */ n(
|
|
823
|
+
rn,
|
|
824
|
+
{
|
|
825
|
+
onClick: (b) => {
|
|
826
|
+
b.stopPropagation(), $(e.label, e.value);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
)
|
|
830
|
+
] }, i)),
|
|
831
|
+
/* @__PURE__ */ n(
|
|
832
|
+
"input",
|
|
833
|
+
{
|
|
834
|
+
className: "sa-input-dropdown-trigger-input",
|
|
835
|
+
value: pn,
|
|
836
|
+
onChange: (e) => {
|
|
837
|
+
const i = e.target.value;
|
|
838
|
+
T(i), z == null || z(i), f || N(!0);
|
|
839
|
+
},
|
|
840
|
+
onFocus: () => {
|
|
841
|
+
R || N(!0);
|
|
842
|
+
},
|
|
843
|
+
onBlur: () => {
|
|
844
|
+
setTimeout(() => N(!1), 150);
|
|
845
|
+
},
|
|
846
|
+
onKeyDown: nn,
|
|
847
|
+
placeholder: c.length === 0 || r ? C : void 0,
|
|
848
|
+
disabled: R
|
|
849
|
+
}
|
|
850
|
+
)
|
|
851
|
+
] }) : null, X = /* @__PURE__ */ n(kn, { handleChangePosition: E, children: /* @__PURE__ */ l(
|
|
774
852
|
"div",
|
|
775
853
|
{
|
|
776
854
|
className: [
|
|
777
855
|
"sa-input-dropdown-container",
|
|
778
|
-
|
|
779
|
-
`sa-input-dropdown-size-${
|
|
856
|
+
D,
|
|
857
|
+
`sa-input-dropdown-size-${d}`,
|
|
858
|
+
w ? "trigger-input" : "",
|
|
780
859
|
f ? "active" : "",
|
|
781
|
-
|
|
782
|
-
|
|
860
|
+
sn ? "error" : "",
|
|
861
|
+
R ? "disable" : ""
|
|
783
862
|
].filter(Boolean).join(" "),
|
|
784
|
-
ref:
|
|
785
|
-
onClick:
|
|
786
|
-
onKeyDown:
|
|
787
|
-
tabIndex: 0,
|
|
788
|
-
onBlur:
|
|
789
|
-
onFocus:
|
|
863
|
+
ref: Z,
|
|
864
|
+
onClick: w ? void 0 : cn,
|
|
865
|
+
onKeyDown: w ? void 0 : nn,
|
|
866
|
+
tabIndex: w ? void 0 : 0,
|
|
867
|
+
onBlur: w ? void 0 : I,
|
|
868
|
+
onFocus: w ? void 0 : F,
|
|
790
869
|
children: [
|
|
791
870
|
/* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-container", children: [
|
|
792
|
-
u ?
|
|
793
|
-
width:
|
|
871
|
+
u ? tn.cloneElement(u, {
|
|
872
|
+
width: Q,
|
|
794
873
|
style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 }
|
|
795
874
|
}) : null,
|
|
796
|
-
/* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children:
|
|
797
|
-
f ? /* @__PURE__ */ n(
|
|
875
|
+
/* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: w ? un : wn() }),
|
|
876
|
+
f ? /* @__PURE__ */ n(En, { width: Q }) : /* @__PURE__ */ n(Nn, { width: Q })
|
|
798
877
|
] }),
|
|
799
878
|
/* @__PURE__ */ n(
|
|
800
|
-
|
|
879
|
+
mn,
|
|
801
880
|
{
|
|
802
|
-
dropdownLists:
|
|
803
|
-
handleChangeValue:
|
|
881
|
+
dropdownLists: o,
|
|
882
|
+
handleChangeValue: $,
|
|
804
883
|
isComponentVisible: f,
|
|
805
|
-
positionDropdown:
|
|
806
|
-
searchAble: !!
|
|
884
|
+
positionDropdown: ln,
|
|
885
|
+
searchAble: !!m,
|
|
886
|
+
hideSearch: w,
|
|
807
887
|
value: c,
|
|
808
|
-
onSearch:
|
|
809
|
-
ref:
|
|
810
|
-
multiSelect:
|
|
811
|
-
searchValue:
|
|
812
|
-
highlightedIndex:
|
|
813
|
-
footer:
|
|
814
|
-
groupLabel:
|
|
815
|
-
onSelectAll:
|
|
888
|
+
onSearch: z,
|
|
889
|
+
ref: g,
|
|
890
|
+
multiSelect: r,
|
|
891
|
+
searchValue: q,
|
|
892
|
+
highlightedIndex: k,
|
|
893
|
+
footer: H,
|
|
894
|
+
groupLabel: a,
|
|
895
|
+
onSelectAll: A
|
|
816
896
|
}
|
|
817
897
|
)
|
|
818
898
|
]
|
|
819
899
|
}
|
|
820
900
|
) });
|
|
821
|
-
return
|
|
901
|
+
return G ? dn === "outside-left" ? /* @__PURE__ */ l("div", { className: `${K} sa-select-field-left`, children: [
|
|
822
902
|
/* @__PURE__ */ l("div", { className: "sa-select-field-left-label", children: [
|
|
823
903
|
/* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
|
|
824
|
-
/* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children:
|
|
825
|
-
|
|
826
|
-
|
|
904
|
+
/* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: G }),
|
|
905
|
+
_ && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
|
|
906
|
+
Y && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
|
|
827
907
|
] }),
|
|
828
|
-
|
|
908
|
+
L && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: L })
|
|
829
909
|
] }),
|
|
830
910
|
/* @__PURE__ */ l("div", { className: "sa-select-field-input-wrap", children: [
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
911
|
+
X,
|
|
912
|
+
B && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: B }),
|
|
913
|
+
h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
|
|
834
914
|
] })
|
|
835
|
-
] }) : /* @__PURE__ */ l("div", { className:
|
|
915
|
+
] }) : /* @__PURE__ */ l("div", { className: K, children: [
|
|
836
916
|
/* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
|
|
837
|
-
/* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children:
|
|
838
|
-
|
|
839
|
-
|
|
917
|
+
/* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: G }),
|
|
918
|
+
_ && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
|
|
919
|
+
Y && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
|
|
840
920
|
] }),
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
] }) : /* @__PURE__ */ l("div", { className:
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
921
|
+
L && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: L }),
|
|
922
|
+
X,
|
|
923
|
+
B && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: B }),
|
|
924
|
+
h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
|
|
925
|
+
] }) : /* @__PURE__ */ l("div", { className: K, children: [
|
|
926
|
+
L && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: L }),
|
|
927
|
+
X,
|
|
928
|
+
B && !h && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: B }),
|
|
929
|
+
h && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: h })
|
|
850
930
|
] });
|
|
851
|
-
},
|
|
852
|
-
const s =
|
|
853
|
-
let
|
|
854
|
-
for (;
|
|
855
|
-
if (!
|
|
856
|
-
return
|
|
857
|
-
|
|
931
|
+
}, on = (o, p, t) => {
|
|
932
|
+
const s = o.length;
|
|
933
|
+
let d = p + t;
|
|
934
|
+
for (; d >= 0 && d < s; ) {
|
|
935
|
+
if (!o[d].disable)
|
|
936
|
+
return d;
|
|
937
|
+
d += t;
|
|
858
938
|
}
|
|
859
|
-
if (
|
|
860
|
-
for (let
|
|
861
|
-
if (!
|
|
862
|
-
return
|
|
939
|
+
if (t === 1) {
|
|
940
|
+
for (let r = 0; r < s; r++)
|
|
941
|
+
if (!o[r].disable)
|
|
942
|
+
return r;
|
|
863
943
|
} else
|
|
864
|
-
for (let
|
|
865
|
-
if (!
|
|
866
|
-
return
|
|
944
|
+
for (let r = s - 1; r >= 0; r--)
|
|
945
|
+
if (!o[r].disable)
|
|
946
|
+
return r;
|
|
867
947
|
return -1;
|
|
868
|
-
},
|
|
948
|
+
}, rn = (o) => /* @__PURE__ */ n(
|
|
869
949
|
"svg",
|
|
870
950
|
{
|
|
871
951
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -874,7 +954,7 @@ const yn = ({
|
|
|
874
954
|
viewBox: "0 0 18 18",
|
|
875
955
|
fill: "none",
|
|
876
956
|
style: { flexShrink: 0, cursor: "pointer" },
|
|
877
|
-
...
|
|
957
|
+
...o,
|
|
878
958
|
children: /* @__PURE__ */ n(
|
|
879
959
|
"path",
|
|
880
960
|
{
|
|
@@ -886,12 +966,12 @@ const yn = ({
|
|
|
886
966
|
}
|
|
887
967
|
)
|
|
888
968
|
}
|
|
889
|
-
),
|
|
969
|
+
), Nn = ({ width: o = 16 }) => /* @__PURE__ */ n(
|
|
890
970
|
"svg",
|
|
891
971
|
{
|
|
892
972
|
xmlns: "http://www.w3.org/2000/svg",
|
|
893
|
-
width:
|
|
894
|
-
height:
|
|
973
|
+
width: o,
|
|
974
|
+
height: o,
|
|
895
975
|
viewBox: "0 0 16 16",
|
|
896
976
|
fill: "none",
|
|
897
977
|
style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 },
|
|
@@ -906,12 +986,12 @@ const yn = ({
|
|
|
906
986
|
}
|
|
907
987
|
)
|
|
908
988
|
}
|
|
909
|
-
),
|
|
989
|
+
), En = ({ width: o = 16 }) => /* @__PURE__ */ n(
|
|
910
990
|
"svg",
|
|
911
991
|
{
|
|
912
992
|
xmlns: "http://www.w3.org/2000/svg",
|
|
913
|
-
width:
|
|
914
|
-
height:
|
|
993
|
+
width: o,
|
|
994
|
+
height: o,
|
|
915
995
|
viewBox: "0 0 16 16",
|
|
916
996
|
fill: "none",
|
|
917
997
|
style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 },
|
|
@@ -928,5 +1008,5 @@ const yn = ({
|
|
|
928
1008
|
}
|
|
929
1009
|
);
|
|
930
1010
|
export {
|
|
931
|
-
|
|
1011
|
+
Rn as Dropdown
|
|
932
1012
|
};
|
package/dist/dropdown.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(x,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(x=typeof globalThis<"u"?globalThis:x||self,n(x.Dropdown={},x.jsxRuntime,x.React))})(this,function(x,n,l){"use strict";const on=`@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;
|
|
@@ -197,13 +197,45 @@
|
|
|
197
197
|
color: var(--sa-dropdown-placeholder-subtle);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
/* === TRIGGER INPUT MODE === */
|
|
201
|
+
.sa-input-dropdown-container.trigger-input {
|
|
202
|
+
cursor: text;
|
|
203
|
+
}
|
|
204
|
+
.sa-input-dropdown-container.trigger-input .sa-input-dropdown-container-preview-item {
|
|
205
|
+
flex-wrap: wrap;
|
|
206
|
+
gap: 4px;
|
|
207
|
+
align-items: center;
|
|
208
|
+
}
|
|
209
|
+
.sa-input-dropdown-trigger-input {
|
|
210
|
+
flex: 1;
|
|
211
|
+
min-width: 80px;
|
|
212
|
+
border: none;
|
|
213
|
+
outline: none;
|
|
214
|
+
background: transparent;
|
|
215
|
+
font-size: var(--baseFont);
|
|
216
|
+
font-family: inherit;
|
|
217
|
+
color: var(--sa-dropdown-text-primary);
|
|
218
|
+
padding: 0;
|
|
219
|
+
line-height: normal;
|
|
220
|
+
}
|
|
221
|
+
.sa-input-dropdown-trigger-input::placeholder {
|
|
222
|
+
color: var(--sa-dropdown-placeholder);
|
|
223
|
+
}
|
|
224
|
+
.sa-input-dropdown-container.outline .sa-input-dropdown-trigger-input::placeholder,
|
|
225
|
+
.sa-input-dropdown-container.flushed .sa-input-dropdown-trigger-input::placeholder {
|
|
226
|
+
color: var(--sa-dropdown-placeholder-subtle);
|
|
227
|
+
}
|
|
228
|
+
.sa-input-dropdown-container.disable .sa-input-dropdown-trigger-input {
|
|
229
|
+
cursor: not-allowed;
|
|
230
|
+
}
|
|
231
|
+
|
|
200
232
|
/* === DROPDOWN PANEL === */
|
|
201
233
|
.sa-input-dropdown-lists-container {
|
|
202
234
|
position: fixed;
|
|
203
235
|
background-color: var(--sa-dropdown-bg);
|
|
204
236
|
border-radius: var(--sa-dropdown-radius);
|
|
205
237
|
box-shadow: var(--sa-dropdown-shadow-panel);
|
|
206
|
-
max-height: min(
|
|
238
|
+
max-height: min(360px, calc(100vh - 80px));
|
|
207
239
|
overflow: hidden;
|
|
208
240
|
z-index: 999;
|
|
209
241
|
width: 100%;
|
|
@@ -242,7 +274,7 @@
|
|
|
242
274
|
}
|
|
243
275
|
|
|
244
276
|
/* === LIST SCROLL AREA === */
|
|
245
|
-
.sa-input-
|
|
277
|
+
.sa-input-dropdown-item-container {
|
|
246
278
|
flex: 1 1 auto;
|
|
247
279
|
overflow-y: auto;
|
|
248
280
|
min-height: 0;
|
|
@@ -282,8 +314,8 @@
|
|
|
282
314
|
}
|
|
283
315
|
|
|
284
316
|
/* === LIST ITEMS === */
|
|
285
|
-
.sa-input-
|
|
286
|
-
min-height:
|
|
317
|
+
.sa-input-dropdown-item {
|
|
318
|
+
min-height: 32px;
|
|
287
319
|
box-sizing: border-box;
|
|
288
320
|
padding: 4px 12px 4px 8px;
|
|
289
321
|
display: flex;
|
|
@@ -296,32 +328,37 @@
|
|
|
296
328
|
font-size: 14px;
|
|
297
329
|
transition: background-color 0.12s ease;
|
|
298
330
|
}
|
|
299
|
-
.sa-input-
|
|
331
|
+
.sa-input-dropdown-item.has-description {
|
|
300
332
|
min-height: 32px;
|
|
301
333
|
font-size: 12px;
|
|
302
334
|
}
|
|
303
|
-
.sa-input-
|
|
335
|
+
.sa-input-dropdown-size-sm .sa-input-dropdown-item,
|
|
336
|
+
.sa-input-dropdown-size-md .sa-input-dropdown-item {
|
|
337
|
+
font-size: 12px;
|
|
338
|
+
font-weight: 500;
|
|
339
|
+
}
|
|
340
|
+
.sa-input-dropdown-item:hover:not(.sa-input-dropdown-item-disable) {
|
|
304
341
|
background-color: var(--sa-dropdown-bg-hover);
|
|
305
342
|
}
|
|
306
|
-
.sa-input-
|
|
343
|
+
.sa-input-dropdown-item.active {
|
|
307
344
|
background-color: var(--sa-dropdown-bg-selected);
|
|
308
345
|
}
|
|
309
|
-
.sa-input-
|
|
346
|
+
.sa-input-dropdown-item.active:hover {
|
|
310
347
|
background-color: var(--sa-dropdown-bg-selected);
|
|
311
348
|
}
|
|
312
|
-
.sa-input-
|
|
349
|
+
.sa-input-dropdown-item.highlight {
|
|
313
350
|
background-color: var(--sa-dropdown-bg-selected);
|
|
314
351
|
outline: 1.2px solid var(--sa-dropdown-border-active);
|
|
315
352
|
outline-offset: -1.2px;
|
|
316
353
|
}
|
|
317
|
-
.sa-input-
|
|
354
|
+
.sa-input-dropdown-item-disable {
|
|
318
355
|
color: var(--sa-dropdown-color-disable) !important;
|
|
319
356
|
pointer-events: none;
|
|
320
357
|
cursor: not-allowed;
|
|
321
358
|
}
|
|
322
359
|
|
|
323
360
|
/* check indicator for selected items in single-select mode */
|
|
324
|
-
.sa-input-
|
|
361
|
+
.sa-input-dropdown-item-check {
|
|
325
362
|
flex-shrink: 0;
|
|
326
363
|
width: 20px;
|
|
327
364
|
height: 20px;
|
|
@@ -331,7 +368,7 @@
|
|
|
331
368
|
color: var(--sa-dropdown-brand);
|
|
332
369
|
}
|
|
333
370
|
|
|
334
|
-
.sa-input-
|
|
371
|
+
.sa-input-dropdown-item-text {
|
|
335
372
|
color: var(--sa-dropdown-text-primary);
|
|
336
373
|
font-size: inherit;
|
|
337
374
|
font-weight: 500;
|
|
@@ -340,7 +377,7 @@
|
|
|
340
377
|
white-space: nowrap;
|
|
341
378
|
line-height: normal;
|
|
342
379
|
}
|
|
343
|
-
.sa-input-
|
|
380
|
+
.sa-input-dropdown-item-text-description {
|
|
344
381
|
color: var(--sa-dropdown-text-secondary);
|
|
345
382
|
font-size: 12px;
|
|
346
383
|
font-weight: 400;
|
|
@@ -446,4 +483,4 @@
|
|
|
446
483
|
margin: 0;
|
|
447
484
|
}
|
|
448
485
|
|
|
449
|
-
`;function _(e){const[p,i]=d.useState(e),l=d.useRef(null),r=o=>{l.current&&!l.current.contains(o.target)&&i(!1)};return d.useEffect(()=>(document.addEventListener("click",r,!0),()=>{document.removeEventListener("click",r,!0)}),[]),{ref:l,isComponentVisible:p,setIsComponentVisible:i}}const R=({...e})=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",...e,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"})]}),nn=({width:e=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,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"})}),en=d.forwardRef(({positionDropdown:e,dropdownLists:p,isComponentVisible:i,searchAble:l,onSearch:r,value:o,handleChangeValue:E,multiSelect:f,searchValue:W,highlightedIndex:k,footer:j,groupLabel:I,onSelectAll:D},F)=>{const L=d.useRef([]);d.useEffect(()=>{var a;k>=0&&L.current[k]&&((a=L.current[k])==null||a.scrollIntoView({block:"nearest"}))},[k]);const A=l?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(R,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:a=>{r&&r(a.target.value)},value:W,autoFocus:!0,placeholder:"Search..."})]}):null;return n.jsx(n.Fragment,{children:i?n.jsxs("div",{className:"sa-input-dropdown-lists-container",onClick:a=>a.stopPropagation(),ref:F,children:[e!=="top"&&A,n.jsxs("div",{className:`sa-input-dropdwon-item-container ${f?"multi":""}`,children:[I&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:I}),f&&D&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:a=>{a.stopPropagation(),D()},children:"Select all"})]}),p.map((a,z)=>{const O=!!(o!=null&&o.find(m=>m.value===a.value)),H=!!a.description;return n.jsxs("div",{className:["sa-input-dropdwon-item",H?"has-description":"",O?"active":"",z===k?"highlight":"",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),ref:m=>{L.current[z]=m},onClick:()=>E(a.label,a.value),children:[f&&n.jsx("div",{className:"sa-input-dropdwon-item-check",children:O&&n.jsx(nn,{width:16})}),a.icon&&n.jsx("div",{style:{flexShrink:0,display:"flex"},children:d.cloneElement(a.icon,{width:16})}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsx("p",{className:["sa-input-dropdwon-item-text",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),children:a.label}),a.description&&n.jsx("p",{className:["sa-input-dropdwon-item-text-description",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),children:a.description})]})]},z)})]}),e==="top"&&A,j&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:a=>a.stopPropagation(),children:j})]}):null})}),on=({children:e,handleChangePosition:p})=>{const i=d.useRef(null);d.useEffect(()=>{var E;const r=()=>{if(i.current){let f=i.current.parentElement;for(;f&&!l(f);)f=f.parentElement;f&&p()}};let o=(E=i.current)==null?void 0:E.parentElement;for(;o&&!l(o);)o=o.parentElement;return o&&o.addEventListener("scroll",r),r(),()=>{o&&o.removeEventListener("scroll",r)}},[]);const l=r=>r&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth);return n.jsx("div",{ref:i,children:e})},U="sa-input-dropdown-styles";(e=>{if(!document.getElementById(U)){const p=document.createElement("style");p.id=U,p.textContent=e,document.head.appendChild(p)}})(Y);const rn=({dropdownLists:e,onChange:p,defaultValue:i,value:l,size:r="md",multiSelect:o,searchAble:E,iconLeft:f,placeholder:W,onSearch:k,error:j,onBlur:I,onFocus:D,disable:F,searchValue:L,variant:A="outline",footer:a,groupLabel:z,onSelectAll:O,fullWidth:H=!0,label:m,labelPosition:tn="outside-top",required:Z,optional:Q,description:N,helperText:C,errorText:w})=>{const M=["sa-select-field",H?"sa-select-field-fullwidth":""].filter(Boolean).join(" "),S=l!==void 0,$=d.useRef(),ln=j||!!w,[c,B]=d.useState(S?l||[]:i||[]),[pn,X]=d.useState(""),[x,q]=d.useState(-1),h=d.useRef(null),{isComponentVisible:u,ref:V,setIsComponentVisible:P}=_(!1),cn=()=>{P(s=>!s)},G=(s,t)=>{if(o)if(c==null?void 0:c.find(b=>b.value===t)){const b=c.filter(hn=>hn.value!==t);S||B(b),p(b)}else{const b=[...c,{label:s,value:t}];S||B(b),p(b)}else{const v=[{label:s,value:t}];S||B(v),p(v),P(!1)}};d.useEffect(()=>{S&&B(l||[])},[l]),d.useEffect(()=>{S||JSON.stringify($.current)===JSON.stringify(i)||($.current=i,B($.current||[]))},[i]);const fn=()=>c.length?o?c==null?void 0:c.map((s,t)=>n.jsxs("div",{className:"sa-input-dropdown-preview-item",children:[n.jsx("p",{style:{minWidth:"max-content"},children:s==null?void 0:s.label}),n.jsx(an,{onClick:v=>{v.stopPropagation(),G(s.label,s.value)}})]},t)):n.jsx("p",{style:{minWidth:"max-content"},children:c==null?void 0:c[0].label}):n.jsx("p",{className:"sa-input-dropdown-placeholder",children:W}),y=()=>{if(V.current&&h.current){const s=window.innerHeight,t=V.current.getBoundingClientRect(),v=h.current.getBoundingClientRect(),b=t.bottom+v.height;h.current.style.left=`${t.left}px`,h.current.style.width=`${t.width}px`,b>=s-10?(h.current.style.top=`${t.top-v.height-5}px`,X("top")):(h.current.style.top=`${t.top+t.height+4}px`,X("bottom"))}};d.useEffect(()=>(window.addEventListener("scroll",y),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",y),window.removeEventListener("resize",y)}),[]),d.useEffect(()=>{y()},[u]),d.useEffect(()=>{if(!u||!h.current)return;const s=new ResizeObserver(()=>{y()});return s.observe(h.current),()=>s.disconnect()},[u]),d.useEffect(()=>{u||q(-1)},[u]);const wn=s=>{if(!u){(s.key==="ArrowDown"||s.key==="Enter")&&(s.preventDefault(),P(!0));return}switch(s.key){case"ArrowDown":{s.preventDefault();const t=T(e,x,1);t!==-1&&q(t);break}case"ArrowUp":{s.preventDefault();const t=T(e,x,-1);t!==-1&&q(t);break}case"Enter":{s.preventDefault(),x>=0&&e[x]&&!e[x].disable&&G(e[x].label,e[x].value);break}case"Escape":P(!1);break}},J=r==="lg"||r==="xl"?20:16,K=n.jsx(on,{handleChangePosition:y,children:n.jsxs("div",{className:["sa-input-dropdown-container",A,`sa-input-dropdown-size-${r}`,u?"active":"",ln?"error":"",F?"disable":""].filter(Boolean).join(" "),ref:V,onClick:cn,onKeyDown:wn,tabIndex:0,onBlur:I,onFocus:D,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[f?d.cloneElement(f,{width:J,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:fn()}),u?n.jsx(dn,{width:J}):n.jsx(sn,{width:J})]}),n.jsx(en,{dropdownLists:e,handleChangeValue:G,isComponentVisible:u,positionDropdown:pn,searchAble:!!E,value:c,onSearch:k,ref:h,multiSelect:o,searchValue:L,highlightedIndex:x,footer:a,groupLabel:z,onSelectAll:O})]})});return m?tn==="outside-left"?n.jsxs("div",{className:`${M} 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:m}),Q&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),Z&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),N&&n.jsx("p",{className:"sa-select-field-helper-top",children:N})]}),n.jsxs("div",{className:"sa-select-field-input-wrap",children:[K,C&&!w&&n.jsx("p",{className:"sa-select-field-helper",children:C}),w&&n.jsx("p",{className:"sa-select-field-error-msg",children:w})]})]}):n.jsxs("div",{className:M,children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:m}),Q&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),Z&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),N&&n.jsx("p",{className:"sa-select-field-helper-top",children:N}),K,C&&!w&&n.jsx("p",{className:"sa-select-field-helper",children:C}),w&&n.jsx("p",{className:"sa-select-field-error-msg",children:w})]}):n.jsxs("div",{className:M,children:[N&&n.jsx("p",{className:"sa-select-field-helper-top",children:N}),K,C&&!w&&n.jsx("p",{className:"sa-select-field-helper",children:C}),w&&n.jsx("p",{className:"sa-select-field-error-msg",children:w})]})},T=(e,p,i)=>{const l=e.length;let r=p+i;for(;r>=0&&r<l;){if(!e[r].disable)return r;r+=i}if(i===1){for(let o=0;o<l;o++)if(!e[o].disable)return o}else for(let o=l-1;o>=0;o--)if(!e[o].disable)return o;return-1},an=e=>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"},...e,children:n.jsx("path",{d:"M12 6L6 12M6.00001 6L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),sn=({width:e=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,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"})}),dn=({width:e=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,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=rn,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
486
|
+
`;function rn(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 an=({...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"})]}),sn=({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"})}),dn=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:W,groupLabel:I,onSelectAll:L},$)=>{const j=l.useRef([]);l.useEffect(()=>{var s;y>=0&&j.current[y]&&((s=j.current[y])==null||s.scrollIntoView({block:"nearest"}))},[y]);const F=t&&!i?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(an,{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:$,children:[o!=="top"&&F,n.jsxs("div",{className:`sa-input-dropdown-item-container ${C?"multi":""}`,children:[I&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:I}),C&&L&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:s=>{s.stopPropagation(),L()},children:"Select all"})]}),p.map((s,A)=>{const M=!!(k!=null&&k.find(O=>O.value===s.value)),w=!!s.description;return n.jsxs("div",{className:["sa-input-dropdown-item",w?"has-description":"",M?"active":"",A===y?"highlight":"",s.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),ref:O=>{j.current[A]=O},onClick:()=>f(s.label,s.value),children:[C&&n.jsx("div",{className:"sa-input-dropdown-item-check",children:M&&n.jsx(sn,{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})]})]},A)})]}),o==="top"&&F,W&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:s=>s.stopPropagation(),children:W})]}):null})}),tn=({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})},X="sa-input-dropdown-styles";(o=>{if(!document.getElementById(X)){const p=document.createElement("style");p.id=X,p.textContent=o,document.head.appendChild(p)}})(on);const ln=({dropdownLists:o,onChange:p,defaultValue:d,value:t,size:i="md",multiSelect:r,searchAble:k,iconLeft:f,placeholder:C,onSearch:z,error:y,onBlur:W,onFocus:I,disable:L,searchValue:$,variant:j="outline",footer:F,groupLabel:s,onSelectAll:A,fullWidth:M=!0,triggerInput:w=!1,clearOnSelect:O=!1,label:q,labelPosition:wn="outside-top",required:V,optional:R,description:S,helperText:B,errorText:h})=>{const G=["sa-select-field",M?"sa-select-field-fullwidth":""].filter(Boolean).join(" "),D=t!==void 0,T=l.useRef(),fn=y||!!h,[c,P]=l.useState(D?t||[]:d||[]),[hn,nn]=l.useState(""),[m,K]=l.useState(-1),[un,U]=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:J,setIsComponentVisible:E}=rn(!1),bn=()=>{E(e=>!e)},H=(e,a)=>{if(r){if(c==null?void 0:c.find(v=>v.value===a)){const v=c.filter(xn=>xn.value!==a);D||P(v),p(v)}else{const v=[...c,{label:e,value:a}];D||P(v),p(v)}w&&U("")}else{const b=[{label:e,value:a}];D||P(b),p(b),w&&U(O?"":e),E(!1)}};l.useEffect(()=>{D&&P(t||[])},[t]),l.useEffect(()=>{D||JSON.stringify(T.current)===JSON.stringify(d)||(T.current=d,P(T.current||[]))},[d]);const gn=()=>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(_,{onClick:b=>{b.stopPropagation(),H(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(J.current&&g.current){const e=window.innerHeight,a=J.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`,nn("top")):(g.current.style.top=`${a.top+a.height+4}px`,nn("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||K(-1)},[u]);const en=e=>{if(!u){(e.key==="ArrowDown"||e.key==="Enter")&&(e.preventDefault(),E(!0));return}switch(e.key){case"ArrowDown":{e.preventDefault();const a=Y(o,m,1);a!==-1&&K(a);break}case"ArrowUp":{e.preventDefault();const a=Y(o,m,-1);a!==-1&&K(a);break}case"Enter":{e.preventDefault(),m>=0&&o[m]&&!o[m].disable&&H(o[m].label,o[m].value);break}case"Escape":E(!1);break}},Z=i==="lg"||i==="xl"?20:16,vn=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(_,{onClick:b=>{b.stopPropagation(),H(e.label,e.value)}})]},a)),n.jsx("input",{className:"sa-input-dropdown-trigger-input",value:un,onChange:e=>{const a=e.target.value;U(a),z==null||z(a),u||E(!0)},onFocus:()=>{L||E(!0)},onBlur:()=>{setTimeout(()=>E(!1),150)},onKeyDown:en,placeholder:c.length===0||r?C:void 0,disabled:L})]}):null,Q=n.jsx(tn,{handleChangePosition:N,children:n.jsxs("div",{className:["sa-input-dropdown-container",j,`sa-input-dropdown-size-${i}`,w?"trigger-input":"",u?"active":"",fn?"error":"",L?"disable":""].filter(Boolean).join(" "),ref:J,onClick:w?void 0:bn,onKeyDown:w?void 0:en,tabIndex:w?void 0:0,onBlur:w?void 0:W,onFocus:w?void 0:I,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[f?l.cloneElement(f,{width:Z,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:w?vn:gn()}),u?n.jsx(cn,{width:Z}):n.jsx(pn,{width:Z})]}),n.jsx(dn,{dropdownLists:o,handleChangeValue:H,isComponentVisible:u,positionDropdown:hn,searchAble:!!k,hideSearch:w,value:c,onSearch:z,ref:g,multiSelect:r,searchValue:$,highlightedIndex:m,footer:F,groupLabel:s,onSelectAll:A})]})});return q?wn==="outside-left"?n.jsxs("div",{className:`${G} 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:q}),R&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),V&&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:[Q,B&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:B}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]})]}):n.jsxs("div",{className:G,children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:q}),R&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),V&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S}),Q,B&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:B}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]}):n.jsxs("div",{className:G,children:[S&&n.jsx("p",{className:"sa-select-field-helper-top",children:S}),Q,B&&!h&&n.jsx("p",{className:"sa-select-field-helper",children:B}),h&&n.jsx("p",{className:"sa-select-field-error-msg",children:h})]})},Y=(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},_=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"})}),pn=({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"})}),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 10L8 6L12 10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});x.Dropdown=ln,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
|
package/dist/interface.d.ts
CHANGED