@starasia/dropdown 4.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dropdown.es.js +27 -29
- package/dist/dropdown.umd.js +12 -14
- package/package.json +1 -1
package/dist/dropdown.es.js
CHANGED
|
@@ -114,7 +114,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
114
114
|
/* --- Outline variant --- */
|
|
115
115
|
.sa-input-dropdown-container.outline {
|
|
116
116
|
background-color: transparent;
|
|
117
|
-
border:
|
|
117
|
+
border: 1px solid var(--sa-dropdown-border-subtle);
|
|
118
118
|
border-radius: var(--borderRadius);
|
|
119
119
|
outline: none;
|
|
120
120
|
}
|
|
@@ -124,7 +124,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
124
124
|
}
|
|
125
125
|
.sa-input-dropdown-container.outline.error {
|
|
126
126
|
background-color: transparent;
|
|
127
|
-
border:
|
|
127
|
+
border: 1px solid var(--sa-dropdown-border-error-subtle);
|
|
128
128
|
}
|
|
129
129
|
.sa-input-dropdown-container.outline.disable {
|
|
130
130
|
background-color: var(--sa-dropdown-bg-disabled);
|
|
@@ -138,7 +138,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
138
138
|
.sa-input-dropdown-container.flushed {
|
|
139
139
|
background-color: transparent;
|
|
140
140
|
border: none;
|
|
141
|
-
border-bottom:
|
|
141
|
+
border-bottom: 1px solid var(--sa-dropdown-border-subtle);
|
|
142
142
|
border-radius: 0;
|
|
143
143
|
}
|
|
144
144
|
.sa-input-dropdown-container.flushed.active {
|
|
@@ -146,7 +146,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
146
146
|
box-shadow: none;
|
|
147
147
|
}
|
|
148
148
|
.sa-input-dropdown-container.flushed.error {
|
|
149
|
-
border-bottom:
|
|
149
|
+
border-bottom: 1px solid var(--sa-dropdown-border-error-subtle);
|
|
150
150
|
}
|
|
151
151
|
.sa-input-dropdown-container.flushed.disable {
|
|
152
152
|
cursor: not-allowed;
|
|
@@ -175,7 +175,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
.sa-input-dropdown-preview-item {
|
|
178
|
-
border:
|
|
178
|
+
border: 1px solid var(--sa-dropdown-border-subtle);
|
|
179
179
|
padding-inline: 8px;
|
|
180
180
|
padding-block: 2px;
|
|
181
181
|
border-radius: 4px;
|
|
@@ -221,7 +221,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
221
221
|
align-items: center;
|
|
222
222
|
height: 32px;
|
|
223
223
|
min-height: 32px;
|
|
224
|
-
border-bottom:
|
|
224
|
+
border-bottom: 1px solid var(--sa-dropdown-border-subtle);
|
|
225
225
|
gap: 8px;
|
|
226
226
|
padding-inline: 12px;
|
|
227
227
|
padding-block: 8px;
|
|
@@ -358,7 +358,7 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
358
358
|
flex-shrink: 0;
|
|
359
359
|
background: var(--sa-dropdown-bg);
|
|
360
360
|
padding: 8px;
|
|
361
|
-
border-top:
|
|
361
|
+
border-top: 1px solid var(--sa-dropdown-border-subtle);
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
/* === SELECT FIELD WRAPPER === */
|
|
@@ -417,16 +417,14 @@ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
417
417
|
.sa-select-field-optional-badge {
|
|
418
418
|
display: inline-flex;
|
|
419
419
|
align-items: center;
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
border: 0.8px solid var(--sa-dropdown-border-subtle);
|
|
420
|
+
padding: 0 8px;
|
|
421
|
+
border: 1px solid var(--sa-dropdown-border-subtle);
|
|
423
422
|
border-radius: 4px;
|
|
424
|
-
background
|
|
423
|
+
background: var(--sa-dropdown-bg-neutral);
|
|
425
424
|
font-size: 10px;
|
|
426
425
|
font-weight: 500;
|
|
427
|
-
color: var(--sa-dropdown-text-
|
|
426
|
+
color: var(--sa-dropdown-text-primary);
|
|
428
427
|
line-height: 18px;
|
|
429
|
-
text-transform: lowercase;
|
|
430
428
|
}
|
|
431
429
|
.sa-select-field-helper-top {
|
|
432
430
|
font-size: 12px;
|
|
@@ -523,15 +521,15 @@ const un = ({ ...e }) => /* @__PURE__ */ l(
|
|
|
523
521
|
searchValue: F,
|
|
524
522
|
highlightedIndex: m,
|
|
525
523
|
footer: I,
|
|
526
|
-
groupLabel:
|
|
527
|
-
onSelectAll:
|
|
524
|
+
groupLabel: A,
|
|
525
|
+
onSelectAll: D
|
|
528
526
|
}, H) => {
|
|
529
527
|
const R = B([]);
|
|
530
528
|
g(() => {
|
|
531
529
|
var a;
|
|
532
530
|
m >= 0 && R.current[m] && ((a = R.current[m]) == null || a.scrollIntoView({ block: "nearest" }));
|
|
533
531
|
}, [m]);
|
|
534
|
-
const
|
|
532
|
+
const j = s ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
|
|
535
533
|
/* @__PURE__ */ n(un, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
|
|
536
534
|
/* @__PURE__ */ n(
|
|
537
535
|
"input",
|
|
@@ -552,20 +550,20 @@ const un = ({ ...e }) => /* @__PURE__ */ l(
|
|
|
552
550
|
onClick: (a) => a.stopPropagation(),
|
|
553
551
|
ref: H,
|
|
554
552
|
children: [
|
|
555
|
-
e !== "top" &&
|
|
553
|
+
e !== "top" && j,
|
|
556
554
|
/* @__PURE__ */ l(
|
|
557
555
|
"div",
|
|
558
556
|
{
|
|
559
557
|
className: `sa-input-dropdwon-item-container ${u ? "multi" : ""}`,
|
|
560
558
|
children: [
|
|
561
|
-
|
|
562
|
-
/* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children:
|
|
563
|
-
u &&
|
|
559
|
+
A && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
|
|
560
|
+
/* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: A }),
|
|
561
|
+
u && D && /* @__PURE__ */ n(
|
|
564
562
|
"button",
|
|
565
563
|
{
|
|
566
564
|
className: "sa-input-dropdown-section-select-all",
|
|
567
565
|
onClick: (a) => {
|
|
568
|
-
a.stopPropagation(),
|
|
566
|
+
a.stopPropagation(), D();
|
|
569
567
|
},
|
|
570
568
|
children: "Select all"
|
|
571
569
|
}
|
|
@@ -620,7 +618,7 @@ const un = ({ ...e }) => /* @__PURE__ */ l(
|
|
|
620
618
|
]
|
|
621
619
|
}
|
|
622
620
|
),
|
|
623
|
-
e === "top" &&
|
|
621
|
+
e === "top" && j,
|
|
624
622
|
I && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (a) => a.stopPropagation(), children: I })
|
|
625
623
|
]
|
|
626
624
|
}
|
|
@@ -669,15 +667,15 @@ const yn = ({
|
|
|
669
667
|
placeholder: F,
|
|
670
668
|
onSearch: m,
|
|
671
669
|
error: I,
|
|
672
|
-
onBlur:
|
|
673
|
-
onFocus:
|
|
670
|
+
onBlur: A,
|
|
671
|
+
onFocus: D,
|
|
674
672
|
disable: H,
|
|
675
673
|
searchValue: R,
|
|
676
|
-
variant:
|
|
674
|
+
variant: j = "outline",
|
|
677
675
|
footer: a,
|
|
678
676
|
groupLabel: z,
|
|
679
677
|
onSelectAll: O,
|
|
680
|
-
fullWidth: M = !
|
|
678
|
+
fullWidth: M = !0,
|
|
681
679
|
/* field wrapper */
|
|
682
680
|
label: k,
|
|
683
681
|
labelPosition: nn = "outside-top",
|
|
@@ -777,7 +775,7 @@ const yn = ({
|
|
|
777
775
|
{
|
|
778
776
|
className: [
|
|
779
777
|
"sa-input-dropdown-container",
|
|
780
|
-
|
|
778
|
+
j,
|
|
781
779
|
`sa-input-dropdown-size-${r}`,
|
|
782
780
|
f ? "active" : "",
|
|
783
781
|
en ? "error" : "",
|
|
@@ -787,8 +785,8 @@ const yn = ({
|
|
|
787
785
|
onClick: rn,
|
|
788
786
|
onKeyDown: tn,
|
|
789
787
|
tabIndex: 0,
|
|
790
|
-
onBlur:
|
|
791
|
-
onFocus:
|
|
788
|
+
onBlur: A,
|
|
789
|
+
onFocus: D,
|
|
792
790
|
children: [
|
|
793
791
|
/* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-container", children: [
|
|
794
792
|
u ? T.cloneElement(u, {
|
package/dist/dropdown.umd.js
CHANGED
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
/* --- Outline variant --- */
|
|
113
113
|
.sa-input-dropdown-container.outline {
|
|
114
114
|
background-color: transparent;
|
|
115
|
-
border:
|
|
115
|
+
border: 1px solid var(--sa-dropdown-border-subtle);
|
|
116
116
|
border-radius: var(--borderRadius);
|
|
117
117
|
outline: none;
|
|
118
118
|
}
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
}
|
|
123
123
|
.sa-input-dropdown-container.outline.error {
|
|
124
124
|
background-color: transparent;
|
|
125
|
-
border:
|
|
125
|
+
border: 1px solid var(--sa-dropdown-border-error-subtle);
|
|
126
126
|
}
|
|
127
127
|
.sa-input-dropdown-container.outline.disable {
|
|
128
128
|
background-color: var(--sa-dropdown-bg-disabled);
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
.sa-input-dropdown-container.flushed {
|
|
137
137
|
background-color: transparent;
|
|
138
138
|
border: none;
|
|
139
|
-
border-bottom:
|
|
139
|
+
border-bottom: 1px solid var(--sa-dropdown-border-subtle);
|
|
140
140
|
border-radius: 0;
|
|
141
141
|
}
|
|
142
142
|
.sa-input-dropdown-container.flushed.active {
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
box-shadow: none;
|
|
145
145
|
}
|
|
146
146
|
.sa-input-dropdown-container.flushed.error {
|
|
147
|
-
border-bottom:
|
|
147
|
+
border-bottom: 1px solid var(--sa-dropdown-border-error-subtle);
|
|
148
148
|
}
|
|
149
149
|
.sa-input-dropdown-container.flushed.disable {
|
|
150
150
|
cursor: not-allowed;
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
.sa-input-dropdown-preview-item {
|
|
176
|
-
border:
|
|
176
|
+
border: 1px solid var(--sa-dropdown-border-subtle);
|
|
177
177
|
padding-inline: 8px;
|
|
178
178
|
padding-block: 2px;
|
|
179
179
|
border-radius: 4px;
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
align-items: center;
|
|
220
220
|
height: 32px;
|
|
221
221
|
min-height: 32px;
|
|
222
|
-
border-bottom:
|
|
222
|
+
border-bottom: 1px solid var(--sa-dropdown-border-subtle);
|
|
223
223
|
gap: 8px;
|
|
224
224
|
padding-inline: 12px;
|
|
225
225
|
padding-block: 8px;
|
|
@@ -356,7 +356,7 @@
|
|
|
356
356
|
flex-shrink: 0;
|
|
357
357
|
background: var(--sa-dropdown-bg);
|
|
358
358
|
padding: 8px;
|
|
359
|
-
border-top:
|
|
359
|
+
border-top: 1px solid var(--sa-dropdown-border-subtle);
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
/* === SELECT FIELD WRAPPER === */
|
|
@@ -415,16 +415,14 @@
|
|
|
415
415
|
.sa-select-field-optional-badge {
|
|
416
416
|
display: inline-flex;
|
|
417
417
|
align-items: center;
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
border: 0.8px solid var(--sa-dropdown-border-subtle);
|
|
418
|
+
padding: 0 8px;
|
|
419
|
+
border: 1px solid var(--sa-dropdown-border-subtle);
|
|
421
420
|
border-radius: 4px;
|
|
422
|
-
background
|
|
421
|
+
background: var(--sa-dropdown-bg-neutral);
|
|
423
422
|
font-size: 10px;
|
|
424
423
|
font-weight: 500;
|
|
425
|
-
color: var(--sa-dropdown-text-
|
|
424
|
+
color: var(--sa-dropdown-text-primary);
|
|
426
425
|
line-height: 18px;
|
|
427
|
-
text-transform: lowercase;
|
|
428
426
|
}
|
|
429
427
|
.sa-select-field-helper-top {
|
|
430
428
|
font-size: 12px;
|
|
@@ -448,4 +446,4 @@
|
|
|
448
446
|
margin: 0;
|
|
449
447
|
}
|
|
450
448
|
|
|
451
|
-
`;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=!
|
|
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"})});
|