@starasia/dropdown 5.0.2 → 5.1.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 +43 -38
- package/dist/dropdown.umd.js +19 -14
- package/package.json +1 -1
package/dist/dropdown.es.js
CHANGED
|
@@ -205,7 +205,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
205
205
|
background-color: var(--sa-dropdown-bg);
|
|
206
206
|
border-radius: var(--sa-dropdown-radius);
|
|
207
207
|
box-shadow: var(--sa-dropdown-shadow-panel);
|
|
208
|
-
max-height: min(
|
|
208
|
+
max-height: min(360px, calc(100vh - 80px));
|
|
209
209
|
overflow: hidden;
|
|
210
210
|
z-index: 999;
|
|
211
211
|
width: 100%;
|
|
@@ -244,7 +244,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
/* === LIST SCROLL AREA === */
|
|
247
|
-
.sa-input-
|
|
247
|
+
.sa-input-dropdown-item-container {
|
|
248
248
|
flex: 1 1 auto;
|
|
249
249
|
overflow-y: auto;
|
|
250
250
|
min-height: 0;
|
|
@@ -284,8 +284,8 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
/* === LIST ITEMS === */
|
|
287
|
-
.sa-input-
|
|
288
|
-
min-height:
|
|
287
|
+
.sa-input-dropdown-item {
|
|
288
|
+
min-height: 32px;
|
|
289
289
|
box-sizing: border-box;
|
|
290
290
|
padding: 4px 12px 4px 8px;
|
|
291
291
|
display: flex;
|
|
@@ -298,32 +298,37 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
298
298
|
font-size: 14px;
|
|
299
299
|
transition: background-color 0.12s ease;
|
|
300
300
|
}
|
|
301
|
-
.sa-input-
|
|
301
|
+
.sa-input-dropdown-item.has-description {
|
|
302
302
|
min-height: 32px;
|
|
303
303
|
font-size: 12px;
|
|
304
304
|
}
|
|
305
|
-
.sa-input-
|
|
305
|
+
.sa-input-dropdown-size-sm .sa-input-dropdown-item,
|
|
306
|
+
.sa-input-dropdown-size-md .sa-input-dropdown-item {
|
|
307
|
+
font-size: 12px;
|
|
308
|
+
font-weight: 500;
|
|
309
|
+
}
|
|
310
|
+
.sa-input-dropdown-item:hover:not(.sa-input-dropdown-item-disable) {
|
|
306
311
|
background-color: var(--sa-dropdown-bg-hover);
|
|
307
312
|
}
|
|
308
|
-
.sa-input-
|
|
313
|
+
.sa-input-dropdown-item.active {
|
|
309
314
|
background-color: var(--sa-dropdown-bg-selected);
|
|
310
315
|
}
|
|
311
|
-
.sa-input-
|
|
316
|
+
.sa-input-dropdown-item.active:hover {
|
|
312
317
|
background-color: var(--sa-dropdown-bg-selected);
|
|
313
318
|
}
|
|
314
|
-
.sa-input-
|
|
319
|
+
.sa-input-dropdown-item.highlight {
|
|
315
320
|
background-color: var(--sa-dropdown-bg-selected);
|
|
316
321
|
outline: 1.2px solid var(--sa-dropdown-border-active);
|
|
317
322
|
outline-offset: -1.2px;
|
|
318
323
|
}
|
|
319
|
-
.sa-input-
|
|
324
|
+
.sa-input-dropdown-item-disable {
|
|
320
325
|
color: var(--sa-dropdown-color-disable) !important;
|
|
321
326
|
pointer-events: none;
|
|
322
327
|
cursor: not-allowed;
|
|
323
328
|
}
|
|
324
329
|
|
|
325
330
|
/* check indicator for selected items in single-select mode */
|
|
326
|
-
.sa-input-
|
|
331
|
+
.sa-input-dropdown-item-check {
|
|
327
332
|
flex-shrink: 0;
|
|
328
333
|
width: 20px;
|
|
329
334
|
height: 20px;
|
|
@@ -333,7 +338,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
333
338
|
color: var(--sa-dropdown-brand);
|
|
334
339
|
}
|
|
335
340
|
|
|
336
|
-
.sa-input-
|
|
341
|
+
.sa-input-dropdown-item-text {
|
|
337
342
|
color: var(--sa-dropdown-text-primary);
|
|
338
343
|
font-size: inherit;
|
|
339
344
|
font-weight: 500;
|
|
@@ -342,7 +347,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
342
347
|
white-space: nowrap;
|
|
343
348
|
line-height: normal;
|
|
344
349
|
}
|
|
345
|
-
.sa-input-
|
|
350
|
+
.sa-input-dropdown-item-text-description {
|
|
346
351
|
color: var(--sa-dropdown-text-secondary);
|
|
347
352
|
font-size: 12px;
|
|
348
353
|
font-weight: 400;
|
|
@@ -524,10 +529,10 @@ const un = ({ ...e }) => /* @__PURE__ */ l(
|
|
|
524
529
|
groupLabel: A,
|
|
525
530
|
onSelectAll: D
|
|
526
531
|
}, H) => {
|
|
527
|
-
const
|
|
532
|
+
const L = B([]);
|
|
528
533
|
g(() => {
|
|
529
534
|
var a;
|
|
530
|
-
m >= 0 &&
|
|
535
|
+
m >= 0 && L.current[m] && ((a = L.current[m]) == null || a.scrollIntoView({ block: "nearest" }));
|
|
531
536
|
}, [m]);
|
|
532
537
|
const j = s ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
|
|
533
538
|
/* @__PURE__ */ n(un, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
|
|
@@ -554,7 +559,7 @@ const un = ({ ...e }) => /* @__PURE__ */ l(
|
|
|
554
559
|
/* @__PURE__ */ l(
|
|
555
560
|
"div",
|
|
556
561
|
{
|
|
557
|
-
className: `sa-input-
|
|
562
|
+
className: `sa-input-dropdown-item-container ${u ? "multi" : ""}`,
|
|
558
563
|
children: [
|
|
559
564
|
A && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
|
|
560
565
|
/* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: A }),
|
|
@@ -569,32 +574,32 @@ const un = ({ ...e }) => /* @__PURE__ */ l(
|
|
|
569
574
|
}
|
|
570
575
|
)
|
|
571
576
|
] }),
|
|
572
|
-
p.map((a,
|
|
577
|
+
p.map((a, R) => {
|
|
573
578
|
const O = !!(o != null && o.find((k) => k.value === a.value)), M = !!a.description;
|
|
574
579
|
return /* @__PURE__ */ l(
|
|
575
580
|
"div",
|
|
576
581
|
{
|
|
577
582
|
className: [
|
|
578
|
-
"sa-input-
|
|
583
|
+
"sa-input-dropdown-item",
|
|
579
584
|
M ? "has-description" : "",
|
|
580
585
|
O ? "active" : "",
|
|
581
|
-
|
|
582
|
-
a.disable ? "sa-input-
|
|
586
|
+
R === m ? "highlight" : "",
|
|
587
|
+
a.disable ? "sa-input-dropdown-item-disable" : ""
|
|
583
588
|
].filter(Boolean).join(" "),
|
|
584
589
|
ref: (k) => {
|
|
585
|
-
|
|
590
|
+
L.current[R] = k;
|
|
586
591
|
},
|
|
587
592
|
onClick: () => N(a.label, a.value),
|
|
588
593
|
children: [
|
|
589
|
-
u && /* @__PURE__ */ n("div", { className: "sa-input-
|
|
594
|
+
u && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-item-check", children: O && /* @__PURE__ */ n(wn, { width: 16 }) }),
|
|
590
595
|
a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: T.cloneElement(a.icon, { width: 16 }) }),
|
|
591
596
|
/* @__PURE__ */ l("div", { style: { minWidth: 0, flex: 1 }, children: [
|
|
592
597
|
/* @__PURE__ */ n(
|
|
593
598
|
"p",
|
|
594
599
|
{
|
|
595
600
|
className: [
|
|
596
|
-
"sa-input-
|
|
597
|
-
a.disable ? "sa-input-
|
|
601
|
+
"sa-input-dropdown-item-text",
|
|
602
|
+
a.disable ? "sa-input-dropdown-item-disable" : ""
|
|
598
603
|
].filter(Boolean).join(" "),
|
|
599
604
|
children: a.label
|
|
600
605
|
}
|
|
@@ -603,8 +608,8 @@ const un = ({ ...e }) => /* @__PURE__ */ l(
|
|
|
603
608
|
"p",
|
|
604
609
|
{
|
|
605
610
|
className: [
|
|
606
|
-
"sa-input-
|
|
607
|
-
a.disable ? "sa-input-
|
|
611
|
+
"sa-input-dropdown-item-text-description",
|
|
612
|
+
a.disable ? "sa-input-dropdown-item-disable" : ""
|
|
608
613
|
].filter(Boolean).join(" "),
|
|
609
614
|
children: a.description
|
|
610
615
|
}
|
|
@@ -612,7 +617,7 @@ const un = ({ ...e }) => /* @__PURE__ */ l(
|
|
|
612
617
|
] })
|
|
613
618
|
]
|
|
614
619
|
},
|
|
615
|
-
|
|
620
|
+
R
|
|
616
621
|
);
|
|
617
622
|
})
|
|
618
623
|
]
|
|
@@ -670,10 +675,10 @@ const yn = ({
|
|
|
670
675
|
onBlur: A,
|
|
671
676
|
onFocus: D,
|
|
672
677
|
disable: H,
|
|
673
|
-
searchValue:
|
|
678
|
+
searchValue: L,
|
|
674
679
|
variant: j = "outline",
|
|
675
680
|
footer: a,
|
|
676
|
-
groupLabel:
|
|
681
|
+
groupLabel: R,
|
|
677
682
|
onSelectAll: O,
|
|
678
683
|
fullWidth: M = !0,
|
|
679
684
|
/* field wrapper */
|
|
@@ -688,28 +693,28 @@ const yn = ({
|
|
|
688
693
|
const $ = [
|
|
689
694
|
"sa-select-field",
|
|
690
695
|
M ? "sa-select-field-fullwidth" : ""
|
|
691
|
-
].filter(Boolean).join(" "),
|
|
692
|
-
|
|
696
|
+
].filter(Boolean).join(" "), z = s !== void 0, V = B(), en = I || !!w, [c, S] = P(
|
|
697
|
+
z ? s || [] : d || []
|
|
693
698
|
), [on, X] = P(""), [x, q] = P(-1), h = B(null), { isComponentVisible: f, ref: G, setIsComponentVisible: W } = cn(!1), rn = () => {
|
|
694
699
|
W((t) => !t);
|
|
695
700
|
}, J = (t, i) => {
|
|
696
701
|
if (o)
|
|
697
702
|
if (c == null ? void 0 : c.find((b) => b.value === i)) {
|
|
698
703
|
const b = c.filter((dn) => dn.value !== i);
|
|
699
|
-
|
|
704
|
+
z || S(b), p(b);
|
|
700
705
|
} else {
|
|
701
706
|
const b = [...c, { label: t, value: i }];
|
|
702
|
-
|
|
707
|
+
z || S(b), p(b);
|
|
703
708
|
}
|
|
704
709
|
else {
|
|
705
710
|
const v = [{ label: t, value: i }];
|
|
706
|
-
|
|
711
|
+
z || S(v), p(v), W(!1);
|
|
707
712
|
}
|
|
708
713
|
};
|
|
709
714
|
g(() => {
|
|
710
|
-
|
|
715
|
+
z && S(s || []);
|
|
711
716
|
}, [s]), g(() => {
|
|
712
|
-
|
|
717
|
+
z || JSON.stringify(V.current) === JSON.stringify(d) || (V.current = d, S(V.current || []));
|
|
713
718
|
}, [d]);
|
|
714
719
|
const an = () => c.length ? o ? c == null ? void 0 : c.map((t, i) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
|
|
715
720
|
/* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: t == null ? void 0 : t.label }),
|
|
@@ -808,10 +813,10 @@ const yn = ({
|
|
|
808
813
|
onSearch: m,
|
|
809
814
|
ref: h,
|
|
810
815
|
multiSelect: o,
|
|
811
|
-
searchValue:
|
|
816
|
+
searchValue: L,
|
|
812
817
|
highlightedIndex: x,
|
|
813
818
|
footer: a,
|
|
814
|
-
groupLabel:
|
|
819
|
+
groupLabel: R,
|
|
815
820
|
onSelectAll: O
|
|
816
821
|
}
|
|
817
822
|
)
|
package/dist/dropdown.umd.js
CHANGED
|
@@ -203,7 +203,7 @@
|
|
|
203
203
|
background-color: var(--sa-dropdown-bg);
|
|
204
204
|
border-radius: var(--sa-dropdown-radius);
|
|
205
205
|
box-shadow: var(--sa-dropdown-shadow-panel);
|
|
206
|
-
max-height: min(
|
|
206
|
+
max-height: min(360px, calc(100vh - 80px));
|
|
207
207
|
overflow: hidden;
|
|
208
208
|
z-index: 999;
|
|
209
209
|
width: 100%;
|
|
@@ -242,7 +242,7 @@
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
/* === LIST SCROLL AREA === */
|
|
245
|
-
.sa-input-
|
|
245
|
+
.sa-input-dropdown-item-container {
|
|
246
246
|
flex: 1 1 auto;
|
|
247
247
|
overflow-y: auto;
|
|
248
248
|
min-height: 0;
|
|
@@ -282,8 +282,8 @@
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
/* === LIST ITEMS === */
|
|
285
|
-
.sa-input-
|
|
286
|
-
min-height:
|
|
285
|
+
.sa-input-dropdown-item {
|
|
286
|
+
min-height: 32px;
|
|
287
287
|
box-sizing: border-box;
|
|
288
288
|
padding: 4px 12px 4px 8px;
|
|
289
289
|
display: flex;
|
|
@@ -296,32 +296,37 @@
|
|
|
296
296
|
font-size: 14px;
|
|
297
297
|
transition: background-color 0.12s ease;
|
|
298
298
|
}
|
|
299
|
-
.sa-input-
|
|
299
|
+
.sa-input-dropdown-item.has-description {
|
|
300
300
|
min-height: 32px;
|
|
301
301
|
font-size: 12px;
|
|
302
302
|
}
|
|
303
|
-
.sa-input-
|
|
303
|
+
.sa-input-dropdown-size-sm .sa-input-dropdown-item,
|
|
304
|
+
.sa-input-dropdown-size-md .sa-input-dropdown-item {
|
|
305
|
+
font-size: 12px;
|
|
306
|
+
font-weight: 500;
|
|
307
|
+
}
|
|
308
|
+
.sa-input-dropdown-item:hover:not(.sa-input-dropdown-item-disable) {
|
|
304
309
|
background-color: var(--sa-dropdown-bg-hover);
|
|
305
310
|
}
|
|
306
|
-
.sa-input-
|
|
311
|
+
.sa-input-dropdown-item.active {
|
|
307
312
|
background-color: var(--sa-dropdown-bg-selected);
|
|
308
313
|
}
|
|
309
|
-
.sa-input-
|
|
314
|
+
.sa-input-dropdown-item.active:hover {
|
|
310
315
|
background-color: var(--sa-dropdown-bg-selected);
|
|
311
316
|
}
|
|
312
|
-
.sa-input-
|
|
317
|
+
.sa-input-dropdown-item.highlight {
|
|
313
318
|
background-color: var(--sa-dropdown-bg-selected);
|
|
314
319
|
outline: 1.2px solid var(--sa-dropdown-border-active);
|
|
315
320
|
outline-offset: -1.2px;
|
|
316
321
|
}
|
|
317
|
-
.sa-input-
|
|
322
|
+
.sa-input-dropdown-item-disable {
|
|
318
323
|
color: var(--sa-dropdown-color-disable) !important;
|
|
319
324
|
pointer-events: none;
|
|
320
325
|
cursor: not-allowed;
|
|
321
326
|
}
|
|
322
327
|
|
|
323
328
|
/* check indicator for selected items in single-select mode */
|
|
324
|
-
.sa-input-
|
|
329
|
+
.sa-input-dropdown-item-check {
|
|
325
330
|
flex-shrink: 0;
|
|
326
331
|
width: 20px;
|
|
327
332
|
height: 20px;
|
|
@@ -331,7 +336,7 @@
|
|
|
331
336
|
color: var(--sa-dropdown-brand);
|
|
332
337
|
}
|
|
333
338
|
|
|
334
|
-
.sa-input-
|
|
339
|
+
.sa-input-dropdown-item-text {
|
|
335
340
|
color: var(--sa-dropdown-text-primary);
|
|
336
341
|
font-size: inherit;
|
|
337
342
|
font-weight: 500;
|
|
@@ -340,7 +345,7 @@
|
|
|
340
345
|
white-space: nowrap;
|
|
341
346
|
line-height: normal;
|
|
342
347
|
}
|
|
343
|
-
.sa-input-
|
|
348
|
+
.sa-input-dropdown-item-text-description {
|
|
344
349
|
color: var(--sa-dropdown-text-secondary);
|
|
345
350
|
font-size: 12px;
|
|
346
351
|
font-weight: 400;
|
|
@@ -446,4 +451,4 @@
|
|
|
446
451
|
margin: 0;
|
|
447
452
|
}
|
|
448
453
|
|
|
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
|
|
454
|
+
`;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 z=d.useRef([]);d.useEffect(()=>{var a;k>=0&&z.current[k]&&((a=z.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-dropdown-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,L)=>{const O=!!(o!=null&&o.find(m=>m.value===a.value)),H=!!a.description;return n.jsxs("div",{className:["sa-input-dropdown-item",H?"has-description":"",O?"active":"",L===k?"highlight":"",a.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),ref:m=>{z.current[L]=m},onClick:()=>E(a.label,a.value),children:[f&&n.jsx("div",{className:"sa-input-dropdown-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-dropdown-item-text",a.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:a.label}),a.description&&n.jsx("p",{className:["sa-input-dropdown-item-text-description",a.disable?"sa-input-dropdown-item-disable":""].filter(Boolean).join(" "),children:a.description})]})]},L)})]}),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:z,variant:A="outline",footer:a,groupLabel:L,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:z,highlightedIndex:x,footer:a,groupLabel:L,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"})});
|