@starasia/dropdown 3.1.0 → 3.3.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 +3 -0
- package/dist/dropdown.es.js +660 -421
- package/dist/dropdown.umd.js +313 -127
- package/dist/interface.d.ts +16 -1
- package/package.json +1 -1
package/dist/dropdown.umd.js
CHANGED
|
@@ -1,79 +1,150 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(b,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):(b=typeof globalThis<"u"?globalThis:b||self,n(b.Dropdown={},b.jsxRuntime,b.React))})(this,function(b,n,d){"use strict";const Z=`@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;
|
|
5
5
|
font-family: "Poppins", sans-serif;
|
|
6
6
|
box-sizing: border-box;
|
|
7
7
|
}
|
|
8
|
+
|
|
8
9
|
:root {
|
|
9
|
-
--sa-dropdown-brand:
|
|
10
|
-
--sa-dropdown-brand-subtle:
|
|
11
|
-
--sa-dropdown-
|
|
12
|
-
--sa-dropdown-bg:
|
|
13
|
-
--sa-dropdown-bg-disabled:
|
|
14
|
-
--sa-dropdown-
|
|
15
|
-
--sa-dropdown-border-
|
|
16
|
-
--sa-dropdown-border-active:
|
|
17
|
-
--sa-dropdown-border-
|
|
18
|
-
--sa-dropdown-border-error:
|
|
19
|
-
--sa-dropdown-color-disable:
|
|
20
|
-
--sa-dropdown-placeholder:
|
|
21
|
-
--sa-dropdown-
|
|
22
|
-
--sa-dropdown-text-
|
|
23
|
-
--sa-dropdown-
|
|
24
|
-
--sa-dropdown-
|
|
25
|
-
--sa-dropdown-
|
|
26
|
-
--sa-dropdown-
|
|
10
|
+
--sa-dropdown-brand: var(--sa-background-brand, #04254f);
|
|
11
|
+
--sa-dropdown-brand-subtle: var(--sa-color-brand-200, #99b3db);
|
|
12
|
+
--sa-dropdown-bg: var(--sa-background-primary, #ffffff);
|
|
13
|
+
--sa-dropdown-bg-neutral: var(--sa-background-neutral, #f0f1f2);
|
|
14
|
+
--sa-dropdown-bg-disabled: var(--sa-background-neutral, #f0f1f2);
|
|
15
|
+
--sa-dropdown-bg-error: #fff0f3;
|
|
16
|
+
--sa-dropdown-border-subtle: rgba(11, 18, 14, 0.14);
|
|
17
|
+
--sa-dropdown-border-active: var(--sa-background-brand, #04254f);
|
|
18
|
+
--sa-dropdown-border-error-subtle: #ffb3c1;
|
|
19
|
+
--sa-dropdown-border-error: var(--sa-color-error-500, #ff4d6d);
|
|
20
|
+
--sa-dropdown-color-disable: var(--sa-color-gray-300, #dddee1);
|
|
21
|
+
--sa-dropdown-placeholder: var(--sa-text-subtle, #505258);
|
|
22
|
+
--sa-dropdown-placeholder-subtle: #6b6e76;
|
|
23
|
+
--sa-dropdown-text-primary: var(--sa-text-primary, #292a2e);
|
|
24
|
+
--sa-dropdown-text-secondary: var(--sa-text-subtle, #6b6e76);
|
|
25
|
+
--sa-dropdown-text-error: #a4133c;
|
|
26
|
+
--sa-dropdown-text-info: #0073ab;
|
|
27
|
+
--sa-dropdown-ring-active: 0px 0px 0px 1.2px var(--sa-color-brand-200, #99b3db);
|
|
28
|
+
--sa-dropdown-shadow-panel: 0px 8px 12px 0px rgba(30, 31, 33, 0.15), 0px 0px 1px 0px rgba(30, 31, 33, 0.31);
|
|
29
|
+
--sa-dropdown-radius: var(--sa-radii-sm, 6px);
|
|
27
30
|
}
|
|
28
31
|
|
|
32
|
+
/* === SIZE VARIANTS === */
|
|
29
33
|
.sa-input-dropdown-size-sm {
|
|
30
|
-
--baseFont: var(--sa-font-size-
|
|
31
|
-
--height:
|
|
34
|
+
--baseFont: var(--sa-font-size-xs, 12px);
|
|
35
|
+
--height: 32px;
|
|
32
36
|
--borderRadius: var(--sa-dropdown-radius);
|
|
33
37
|
--paddingInline: var(--sa-spacing-sm, 8px);
|
|
38
|
+
--paddingBlock: var(--sa-spacing-xs, 4px);
|
|
39
|
+
--iconSize: 16px;
|
|
34
40
|
}
|
|
35
|
-
|
|
36
41
|
.sa-input-dropdown-size-md {
|
|
37
|
-
--baseFont: var(--sa-font-size-
|
|
38
|
-
--height:
|
|
42
|
+
--baseFont: var(--sa-font-size-sm, 14px);
|
|
43
|
+
--height: 40px;
|
|
39
44
|
--borderRadius: var(--sa-dropdown-radius);
|
|
40
45
|
--paddingInline: var(--sa-spacing-3, 12px);
|
|
46
|
+
--paddingBlock: var(--sa-spacing-sm, 8px);
|
|
47
|
+
--iconSize: 16px;
|
|
41
48
|
}
|
|
42
|
-
|
|
43
49
|
.sa-input-dropdown-size-lg {
|
|
44
|
-
--baseFont: var(--sa-font-size-
|
|
45
|
-
--height:
|
|
46
|
-
--borderRadius: var(--sa-dropdown-radius
|
|
50
|
+
--baseFont: var(--sa-font-size-md, 16px);
|
|
51
|
+
--height: 48px;
|
|
52
|
+
--borderRadius: var(--sa-dropdown-radius);
|
|
47
53
|
--paddingInline: var(--sa-spacing-3, 12px);
|
|
54
|
+
--paddingBlock: var(--sa-spacing-sm, 8px);
|
|
55
|
+
--iconSize: 20px;
|
|
56
|
+
}
|
|
57
|
+
.sa-input-dropdown-size-xl {
|
|
58
|
+
--baseFont: var(--sa-font-size-md, 16px);
|
|
59
|
+
--height: 56px;
|
|
60
|
+
--borderRadius: var(--sa-dropdown-radius);
|
|
61
|
+
--paddingInline: var(--sa-spacing-3, 12px);
|
|
62
|
+
--paddingBlock: var(--sa-spacing-sm, 8px);
|
|
63
|
+
--iconSize: 20px;
|
|
48
64
|
}
|
|
49
65
|
|
|
66
|
+
/* === BASE CONTAINER === */
|
|
50
67
|
.sa-input-dropdown-container {
|
|
51
68
|
position: relative;
|
|
52
69
|
min-height: var(--height);
|
|
53
70
|
padding-inline: var(--paddingInline);
|
|
71
|
+
padding-block: var(--paddingBlock);
|
|
54
72
|
display: flex;
|
|
55
73
|
align-items: center;
|
|
56
|
-
border: var(--sa-dropdown-border) solid var(--sa-dropdown-border-color);
|
|
57
|
-
border-radius: var(--borderRadius);
|
|
58
|
-
background-color: var(--sa-dropdown-bg);
|
|
59
74
|
font-size: var(--baseFont);
|
|
60
75
|
cursor: pointer;
|
|
76
|
+
transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
|
|
77
|
+
outline: none;
|
|
78
|
+
}
|
|
79
|
+
.sa-input-dropdown-container:focus-visible {
|
|
80
|
+
outline: none;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* --- Standard variant (default) --- */
|
|
84
|
+
.sa-input-dropdown-container.standard {
|
|
85
|
+
background-color: var(--sa-dropdown-bg-neutral);
|
|
86
|
+
border: 1px solid transparent;
|
|
87
|
+
border-radius: var(--borderRadius);
|
|
88
|
+
}
|
|
89
|
+
.sa-input-dropdown-container.standard.active {
|
|
90
|
+
border-color: var(--sa-dropdown-border-active);
|
|
91
|
+
box-shadow: var(--sa-dropdown-ring-active);
|
|
61
92
|
}
|
|
62
|
-
.sa-input-dropdown-container.
|
|
93
|
+
.sa-input-dropdown-container.standard.error {
|
|
94
|
+
background-color: var(--sa-dropdown-bg-error);
|
|
95
|
+
border-color: var(--sa-dropdown-border-error-subtle);
|
|
96
|
+
}
|
|
97
|
+
.sa-input-dropdown-container.standard.disable {
|
|
63
98
|
background-color: var(--sa-dropdown-bg-disabled);
|
|
99
|
+
border-color: transparent;
|
|
64
100
|
cursor: not-allowed;
|
|
65
101
|
pointer-events: none;
|
|
102
|
+
opacity: 0.6;
|
|
66
103
|
}
|
|
67
104
|
|
|
68
|
-
|
|
69
|
-
|
|
105
|
+
/* --- Outline variant --- */
|
|
106
|
+
.sa-input-dropdown-container.outline {
|
|
107
|
+
background-color: transparent;
|
|
108
|
+
border: 0.8px solid var(--sa-dropdown-border-subtle);
|
|
109
|
+
border-radius: var(--borderRadius);
|
|
70
110
|
}
|
|
71
|
-
.sa-input-dropdown-container.active {
|
|
72
|
-
border
|
|
73
|
-
box-shadow: var(--sa-dropdown-
|
|
74
|
-
|
|
111
|
+
.sa-input-dropdown-container.outline.active {
|
|
112
|
+
border: 1px solid var(--sa-dropdown-border-active);
|
|
113
|
+
box-shadow: var(--sa-dropdown-ring-active);
|
|
114
|
+
}
|
|
115
|
+
.sa-input-dropdown-container.outline.error {
|
|
116
|
+
background-color: var(--sa-dropdown-bg-error);
|
|
117
|
+
border: 1px solid var(--sa-dropdown-border-error-subtle);
|
|
118
|
+
}
|
|
119
|
+
.sa-input-dropdown-container.outline.disable {
|
|
120
|
+
background-color: var(--sa-dropdown-bg-disabled);
|
|
121
|
+
border-color: var(--sa-dropdown-border-subtle);
|
|
122
|
+
cursor: not-allowed;
|
|
123
|
+
pointer-events: none;
|
|
124
|
+
opacity: 0.6;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* --- Flushed variant --- */
|
|
128
|
+
.sa-input-dropdown-container.flushed {
|
|
129
|
+
background-color: transparent;
|
|
130
|
+
border: none;
|
|
131
|
+
border-bottom: 0.8px solid var(--sa-dropdown-border-subtle);
|
|
132
|
+
border-radius: 0;
|
|
133
|
+
}
|
|
134
|
+
.sa-input-dropdown-container.flushed.active {
|
|
135
|
+
border-bottom: 1px solid var(--sa-dropdown-border-active);
|
|
136
|
+
box-shadow: 0px 1.2px 0px 0px var(--sa-color-brand-200, #99b3db);
|
|
137
|
+
}
|
|
138
|
+
.sa-input-dropdown-container.flushed.error {
|
|
139
|
+
border-bottom: 1px solid var(--sa-dropdown-border-error-subtle);
|
|
140
|
+
}
|
|
141
|
+
.sa-input-dropdown-container.flushed.disable {
|
|
142
|
+
cursor: not-allowed;
|
|
143
|
+
pointer-events: none;
|
|
144
|
+
opacity: 0.6;
|
|
75
145
|
}
|
|
76
146
|
|
|
147
|
+
/* === TRIGGER CONTENT === */
|
|
77
148
|
.sa-input-dropdown-preview-container {
|
|
78
149
|
display: flex;
|
|
79
150
|
flex-direction: row;
|
|
@@ -84,158 +155,276 @@
|
|
|
84
155
|
overflow-y: hidden;
|
|
85
156
|
}
|
|
86
157
|
|
|
158
|
+
.sa-input-dropdown-container-preview-item {
|
|
159
|
+
flex: 1;
|
|
160
|
+
display: flex;
|
|
161
|
+
gap: var(--sa-spacing-xs, 4px);
|
|
162
|
+
flex-wrap: wrap;
|
|
163
|
+
align-items: center;
|
|
164
|
+
overflow-y: auto;
|
|
165
|
+
padding-block: 4px;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.sa-input-dropdown-preview-item {
|
|
169
|
+
border: 1px solid var(--sa-dropdown-brand);
|
|
170
|
+
padding-inline: var(--paddingInline);
|
|
171
|
+
border-radius: var(--sa-dropdown-radius);
|
|
172
|
+
background-color: var(--sa-color-brand-50, #e6edf6);
|
|
173
|
+
color: var(--sa-dropdown-brand);
|
|
174
|
+
height: max-content;
|
|
175
|
+
font-size: var(--baseFont);
|
|
176
|
+
display: flex;
|
|
177
|
+
align-items: center;
|
|
178
|
+
gap: 4px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.sa-input-dropdown-placeholder {
|
|
182
|
+
color: var(--sa-dropdown-placeholder);
|
|
183
|
+
font-weight: 400;
|
|
184
|
+
}
|
|
185
|
+
.sa-input-dropdown-container.outline .sa-input-dropdown-placeholder,
|
|
186
|
+
.sa-input-dropdown-container.flushed .sa-input-dropdown-placeholder {
|
|
187
|
+
color: var(--sa-dropdown-placeholder-subtle);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* === DROPDOWN PANEL === */
|
|
87
191
|
.sa-input-dropdown-lists-container {
|
|
88
|
-
/* position: absolute; */
|
|
89
192
|
position: fixed;
|
|
90
|
-
/* left: 0; */
|
|
91
|
-
padding: var(--sa-spacing-sm, 8px);
|
|
92
|
-
border: var(--sa-dropdown-border) solid var(--sa-dropdown-border-color);
|
|
93
|
-
border-radius: var(--borderRadius);
|
|
94
193
|
background-color: var(--sa-dropdown-bg);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
194
|
+
border-radius: var(--sa-dropdown-radius);
|
|
195
|
+
box-shadow: var(--sa-dropdown-shadow-panel);
|
|
196
|
+
max-height: 320px;
|
|
197
|
+
overflow: hidden;
|
|
98
198
|
z-index: 999;
|
|
99
199
|
width: 100%;
|
|
100
|
-
/* width: max-content; */
|
|
101
|
-
/* min-width: 100%; */
|
|
102
200
|
display: flex;
|
|
103
201
|
flex-direction: column;
|
|
104
|
-
gap: var(--sa-spacing-sm, 8px);
|
|
105
|
-
/* overflow: hidden;
|
|
106
|
-
text-overflow: ellipsis;
|
|
107
|
-
white-space: nowrap; */
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.sa-input-dropdown-lists-container-bottom {
|
|
111
|
-
top: 100%;
|
|
112
|
-
margin-top: var(--sa-spacing-xs, 4px);
|
|
113
|
-
}
|
|
114
|
-
.sa-input-dropdown-lists-container-top {
|
|
115
|
-
bottom: 100%;
|
|
116
|
-
margin-bottom: var(--sa-spacing-xs, 4px);
|
|
117
202
|
}
|
|
118
203
|
|
|
204
|
+
/* === SEARCH BAR === */
|
|
119
205
|
.sa-input-dropdown-container-dropdown-search {
|
|
206
|
+
flex-shrink: 0;
|
|
120
207
|
display: flex;
|
|
121
208
|
align-items: center;
|
|
122
|
-
height:
|
|
123
|
-
min-height:
|
|
124
|
-
|
|
125
|
-
border: var(--sa-dropdown-border) solid var(--sa-dropdown-border-search);
|
|
126
|
-
border-radius: var(--borderRadius);
|
|
209
|
+
height: 36px;
|
|
210
|
+
min-height: 36px;
|
|
211
|
+
border-bottom: 0.8px solid var(--sa-dropdown-border-subtle);
|
|
127
212
|
gap: var(--sa-spacing-sm, 8px);
|
|
128
|
-
padding-inline: var(--
|
|
213
|
+
padding-inline: var(--sa-spacing-3, 12px);
|
|
214
|
+
padding-block: var(--sa-spacing-sm, 8px);
|
|
129
215
|
background: var(--sa-dropdown-bg);
|
|
216
|
+
|
|
130
217
|
& input {
|
|
131
218
|
flex: 1;
|
|
132
219
|
outline: none;
|
|
133
220
|
background-color: transparent;
|
|
134
221
|
border: none;
|
|
135
|
-
font-size:
|
|
222
|
+
font-size: var(--baseFont, 14px);
|
|
223
|
+
color: var(--sa-dropdown-text-primary);
|
|
224
|
+
}
|
|
225
|
+
& input::placeholder {
|
|
226
|
+
color: var(--sa-dropdown-placeholder-subtle);
|
|
136
227
|
}
|
|
137
228
|
}
|
|
138
229
|
|
|
230
|
+
/* === LIST SCROLL AREA === */
|
|
139
231
|
.sa-input-dropdwon-item-container {
|
|
232
|
+
flex: 1 1 0;
|
|
233
|
+
overflow-y: auto;
|
|
234
|
+
min-height: 0;
|
|
235
|
+
padding: var(--sa-spacing-sm, 8px);
|
|
140
236
|
display: flex;
|
|
141
237
|
flex-direction: column;
|
|
142
|
-
/* overflow: hidden; */
|
|
143
|
-
|
|
144
|
-
/* gap: var(--sa-spacing-xs, 0.25rem); */
|
|
145
238
|
}
|
|
146
239
|
.sa-input-dropdwon-item-container.multi {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
gap: 8px;
|
|
150
|
-
/* overflow: hidden; */
|
|
240
|
+
gap: 4px;
|
|
241
|
+
}
|
|
151
242
|
|
|
152
|
-
|
|
243
|
+
/* === SECTION HEADER === */
|
|
244
|
+
.sa-input-dropdown-section-header {
|
|
245
|
+
display: flex;
|
|
246
|
+
align-items: center;
|
|
247
|
+
justify-content: space-between;
|
|
248
|
+
gap: 12px;
|
|
249
|
+
padding-inline: 4px;
|
|
250
|
+
padding-bottom: 4px;
|
|
251
|
+
font-size: 12px;
|
|
252
|
+
font-weight: 500;
|
|
253
|
+
flex-shrink: 0;
|
|
254
|
+
}
|
|
255
|
+
.sa-input-dropdown-section-label {
|
|
256
|
+
color: var(--sa-dropdown-text-secondary);
|
|
257
|
+
}
|
|
258
|
+
.sa-input-dropdown-section-select-all {
|
|
259
|
+
color: var(--sa-dropdown-text-info);
|
|
260
|
+
cursor: pointer;
|
|
261
|
+
white-space: nowrap;
|
|
262
|
+
background: none;
|
|
263
|
+
border: none;
|
|
264
|
+
font-size: inherit;
|
|
265
|
+
font-family: inherit;
|
|
266
|
+
font-weight: inherit;
|
|
267
|
+
padding: 0;
|
|
268
|
+
}
|
|
269
|
+
.sa-input-dropdown-section-select-all:hover {
|
|
270
|
+
text-decoration: underline;
|
|
153
271
|
}
|
|
154
272
|
|
|
273
|
+
/* === LIST ITEMS === */
|
|
155
274
|
.sa-input-dropdwon-item {
|
|
156
|
-
|
|
157
|
-
max-height: 58px;
|
|
275
|
+
min-height: 36px;
|
|
158
276
|
box-sizing: border-box;
|
|
159
|
-
padding-
|
|
277
|
+
padding-left: var(--sa-spacing-sm, 8px);
|
|
278
|
+
padding-right: var(--sa-spacing-3, 12px);
|
|
279
|
+
padding-block: var(--sa-spacing-xs, 4px);
|
|
160
280
|
display: flex;
|
|
161
281
|
align-items: center;
|
|
162
282
|
cursor: pointer;
|
|
163
|
-
gap: var(--sa-spacing-
|
|
164
|
-
padding-block: var(--paddingInline);
|
|
283
|
+
gap: var(--sa-spacing-sm, 8px);
|
|
165
284
|
border-radius: var(--sa-dropdown-radius);
|
|
166
|
-
/* min-width: max-content; */
|
|
167
285
|
overflow: hidden;
|
|
286
|
+
flex-shrink: 0;
|
|
168
287
|
}
|
|
169
|
-
|
|
170
288
|
.sa-input-dropdwon-item:hover {
|
|
171
|
-
background-color: color-mix(in srgb, var(--sa-dropdown-brand-
|
|
289
|
+
background-color: color-mix(in srgb, var(--sa-dropdown-brand-subtle) 21%, transparent);
|
|
172
290
|
}
|
|
173
291
|
.sa-input-dropdwon-item.active {
|
|
174
|
-
|
|
175
|
-
/* border-radius: var(--borderRadius); */
|
|
176
|
-
background-color: color-mix(in srgb, var(--sa-dropdown-brand-secondary) 21%, transparent);
|
|
177
|
-
/* background: var(--sa-dropdown-brand-subtle); */
|
|
178
|
-
/* box-shadow: 0px 0px 0px -1px #f0f0f0; */
|
|
292
|
+
background-color: color-mix(in srgb, var(--sa-dropdown-brand-subtle) 21%, transparent);
|
|
179
293
|
}
|
|
180
294
|
.sa-input-dropdwon-item.highlight {
|
|
181
|
-
background-color: color-mix(in srgb, var(--sa-dropdown-brand-
|
|
182
|
-
outline: 2px solid color-mix(in srgb, var(--sa-dropdown-brand-
|
|
295
|
+
background-color: color-mix(in srgb, var(--sa-dropdown-brand-subtle) 35%, transparent);
|
|
296
|
+
outline: 2px solid color-mix(in srgb, var(--sa-dropdown-brand-subtle) 40%, transparent);
|
|
183
297
|
outline-offset: -2px;
|
|
184
298
|
}
|
|
185
|
-
|
|
186
299
|
.sa-input-dropdwon-item-disable {
|
|
187
300
|
color: var(--sa-dropdown-color-disable) !important;
|
|
188
301
|
pointer-events: none;
|
|
189
302
|
}
|
|
190
303
|
|
|
191
|
-
.sa-input-dropdown-container-preview-item {
|
|
192
|
-
flex: 1;
|
|
193
|
-
display: flex;
|
|
194
|
-
gap: var(--sa-spacing-xs, 4px);
|
|
195
|
-
flex-wrap: wrap;
|
|
196
|
-
align-items: center;
|
|
197
|
-
overflow-y: auto;
|
|
198
|
-
padding-block: 4px;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.sa-input-dropdown-preview-item {
|
|
202
|
-
border: var(--sa-dropdown-border) solid var(--sa-dropdown-border-active);
|
|
203
|
-
padding-inline: var(--paddingInline);
|
|
204
|
-
border-radius: var(--borderRadius);
|
|
205
|
-
background-color: var(--sa-dropdown-brand-subtle);
|
|
206
|
-
color: var(--sa-dropdown-brand);
|
|
207
|
-
height: max-content;
|
|
208
|
-
font-size: var(--baseFont);
|
|
209
|
-
display: flex;
|
|
210
|
-
align-items: center;
|
|
211
|
-
gap: 2;
|
|
212
|
-
}
|
|
213
|
-
.sa-input-dropdown-placeholder {
|
|
214
|
-
color: var(--sa-dropdown-placeholder);
|
|
215
|
-
font-weight: var(--sa-font-weight-normal, 300);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
304
|
.sa-input-dropdwon-item-text {
|
|
219
305
|
color: var(--sa-dropdown-text-primary);
|
|
220
|
-
/* font-size: 14px; */
|
|
221
306
|
font-size: inherit;
|
|
222
307
|
font-weight: 500;
|
|
308
|
+
overflow: hidden;
|
|
309
|
+
text-overflow: ellipsis;
|
|
310
|
+
white-space: nowrap;
|
|
223
311
|
}
|
|
224
312
|
.sa-input-dropdwon-item-text.active {
|
|
225
313
|
color: var(--sa-dropdown-brand);
|
|
226
314
|
}
|
|
227
|
-
|
|
228
315
|
.sa-input-dropdwon-item-text-description {
|
|
229
316
|
color: var(--sa-dropdown-text-secondary);
|
|
230
|
-
/* font-size: 14px; */
|
|
231
317
|
font-size: inherit;
|
|
232
318
|
font-weight: 400;
|
|
319
|
+
overflow: hidden;
|
|
320
|
+
text-overflow: ellipsis;
|
|
321
|
+
white-space: nowrap;
|
|
233
322
|
}
|
|
234
323
|
.sa-input-dropdwon-item-text-description.active {
|
|
235
324
|
color: var(--sa-dropdown-brand);
|
|
236
325
|
}
|
|
237
326
|
|
|
238
|
-
/*
|
|
327
|
+
/* === FOOTER SLOT === */
|
|
328
|
+
.sa-input-dropdown-footer {
|
|
329
|
+
flex-shrink: 0;
|
|
330
|
+
background: var(--sa-dropdown-bg);
|
|
331
|
+
padding: var(--sa-spacing-sm, 8px);
|
|
332
|
+
border-top: 0.8px solid var(--sa-dropdown-border-subtle);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/* === SELECT FIELD WRAPPER === */
|
|
336
|
+
.sa-select-field {
|
|
337
|
+
display: flex;
|
|
338
|
+
flex-direction: column;
|
|
339
|
+
gap: 8px;
|
|
340
|
+
width: 100%;
|
|
341
|
+
}
|
|
342
|
+
.sa-select-field-left {
|
|
343
|
+
flex-direction: row;
|
|
344
|
+
align-items: flex-start;
|
|
345
|
+
}
|
|
346
|
+
.sa-select-field-left-label {
|
|
347
|
+
display: flex;
|
|
348
|
+
flex-direction: column;
|
|
349
|
+
gap: 8px;
|
|
350
|
+
flex: 0 0 auto;
|
|
351
|
+
width: 50%;
|
|
352
|
+
padding-top: 7px;
|
|
353
|
+
}
|
|
354
|
+
.sa-select-field-input-wrap {
|
|
355
|
+
display: flex;
|
|
356
|
+
flex-direction: column;
|
|
357
|
+
gap: 8px;
|
|
358
|
+
flex: 1;
|
|
359
|
+
min-width: 0;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.sa-select-field-label-row {
|
|
363
|
+
display: flex;
|
|
364
|
+
align-items: center;
|
|
365
|
+
gap: 4px;
|
|
366
|
+
flex-wrap: wrap;
|
|
367
|
+
}
|
|
368
|
+
.sa-select-field-label-text {
|
|
369
|
+
font-size: 14px;
|
|
370
|
+
font-weight: 500;
|
|
371
|
+
color: var(--sa-dropdown-text-primary);
|
|
372
|
+
line-height: 1;
|
|
373
|
+
}
|
|
374
|
+
.sa-select-field-left .sa-select-field-label-text {
|
|
375
|
+
font-size: 12px;
|
|
376
|
+
}
|
|
377
|
+
.sa-select-field-required {
|
|
378
|
+
font-size: 14px;
|
|
379
|
+
font-weight: 500;
|
|
380
|
+
color: var(--sa-dropdown-text-error);
|
|
381
|
+
line-height: 1;
|
|
382
|
+
}
|
|
383
|
+
.sa-select-field-left .sa-select-field-required {
|
|
384
|
+
font-size: 12px;
|
|
385
|
+
}
|
|
386
|
+
.sa-select-field-optional-badge {
|
|
387
|
+
display: inline-flex;
|
|
388
|
+
align-items: center;
|
|
389
|
+
justify-content: center;
|
|
390
|
+
padding-inline: 8px;
|
|
391
|
+
border: 1px solid var(--sa-dropdown-border-subtle);
|
|
392
|
+
border-radius: 4px;
|
|
393
|
+
background-color: var(--sa-dropdown-bg-neutral);
|
|
394
|
+
font-size: 10px;
|
|
395
|
+
font-weight: 500;
|
|
396
|
+
color: var(--sa-dropdown-text-primary);
|
|
397
|
+
line-height: 18px;
|
|
398
|
+
}
|
|
399
|
+
.sa-select-field-helper-top {
|
|
400
|
+
font-size: 12px;
|
|
401
|
+
font-weight: 400;
|
|
402
|
+
color: var(--sa-dropdown-text-secondary);
|
|
403
|
+
line-height: 1.5;
|
|
404
|
+
}
|
|
405
|
+
.sa-select-field-left .sa-select-field-helper-top {
|
|
406
|
+
font-size: 10px;
|
|
407
|
+
}
|
|
408
|
+
.sa-select-field-helper {
|
|
409
|
+
font-size: 12px;
|
|
410
|
+
font-weight: 400;
|
|
411
|
+
color: var(--sa-dropdown-text-secondary);
|
|
412
|
+
line-height: 1.5;
|
|
413
|
+
}
|
|
414
|
+
.sa-select-field-left .sa-select-field-helper {
|
|
415
|
+
font-size: 10px;
|
|
416
|
+
}
|
|
417
|
+
.sa-select-field-error-msg {
|
|
418
|
+
font-size: 12px;
|
|
419
|
+
font-weight: 400;
|
|
420
|
+
color: var(--sa-dropdown-text-error);
|
|
421
|
+
line-height: 1.5;
|
|
422
|
+
}
|
|
423
|
+
.sa-select-field-left .sa-select-field-error-msg {
|
|
424
|
+
font-size: 10px;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/* === CHECKBOX === */
|
|
239
428
|
.checkbox-wrapper-30 .checkbox {
|
|
240
429
|
--bg: #fff;
|
|
241
430
|
--brdr: #d1d6ee;
|
|
@@ -243,7 +432,6 @@
|
|
|
243
432
|
--brdr-hovr: #bbc1e1;
|
|
244
433
|
--dur: calc((var(--size, 2) / 2) * 0.6s);
|
|
245
434
|
display: inline-block;
|
|
246
|
-
/* width: calc(var(--size, 1) * 22px); */
|
|
247
435
|
width: 16px;
|
|
248
436
|
height: 16px;
|
|
249
437
|
position: relative;
|
|
@@ -281,7 +469,6 @@
|
|
|
281
469
|
.checkbox-wrapper-30 .checkbox input:checked {
|
|
282
470
|
--newBrdrClr: var(--brdr-actv);
|
|
283
471
|
--newBgClr: var(--brdr-actv);
|
|
284
|
-
/* transition-delay: calc(var(--dur) / 1.3); */
|
|
285
472
|
}
|
|
286
473
|
.checkbox-wrapper-30 .checkbox input:checked + svg {
|
|
287
474
|
--dashArray: 16 93;
|
|
@@ -289,7 +476,6 @@
|
|
|
289
476
|
}
|
|
290
477
|
.checkbox-wrapper-30 .checkbox input:checked + svg {
|
|
291
478
|
color: white;
|
|
292
|
-
/* transition-delay: calc(var(--dur) / 1.3); */
|
|
293
479
|
transition-delay: 0.1s;
|
|
294
480
|
}
|
|
295
481
|
.checkbox-wrapper-30 .checkbox svg {
|
|
@@ -311,4 +497,4 @@
|
|
|
311
497
|
height: 100%;
|
|
312
498
|
width: 100%;
|
|
313
499
|
}
|
|
314
|
-
`;function
|
|
500
|
+
`;function Q(e){const[p,t]=d.useState(e),l=d.useRef(null),o=r=>{l.current&&!l.current.contains(r.target)&&t(!1)};return d.useEffect(()=>(document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}),[]),{ref:l,isComponentVisible:p,setIsComponentVisible:t}}const Y=({...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"})]}),_=({isChecked:e})=>n.jsxs("div",{className:"checkbox-wrapper-30",children:[n.jsxs("span",{className:"checkbox",children:[n.jsx("input",{type:"checkbox",style:{pointerEvents:"none"},checked:e}),n.jsx("svg",{children:n.jsx("use",{xlinkHref:"#checkbox-30",className:"checkbox"})})]}),n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",style:{display:"none"},children:n.jsx("symbol",{id:"checkbox-30",viewBox:"0 0 22 22",children:n.jsx("path",{fill:"none",stroke:"currentColor",d:"M5.5,11.3L9,14.8L20.2,3.3l0,0c-0.5-1-1.5-1.8-2.7-1.8h-13c-1.7,0-3,1.3-3,3v13c0,1.7,1.3,3,3,3h13 c1.7,0,3-1.3,3-3v-13c0-0.4-0.1-0.8-0.3-1.2"})})})]}),R=d.forwardRef(({positionDropdown:e,dropdownLists:p,isComponentVisible:t,searchAble:l,onSearch:o,value:r,handleChangeValue:m,multiSelect:h,searchValue:P,highlightedIndex:x,footer:j,groupLabel:A,onSelectAll:D},F)=>{const B=d.useRef([]);d.useEffect(()=>{var a;x>=0&&B.current[x]&&((a=B.current[x])==null||a.scrollIntoView({block:"nearest"}))},[x]);const O=l?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(Y,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:a=>{o&&o(a.target.value)},value:P,autoFocus:!0,placeholder:"Search..."})]}):null;return n.jsx(n.Fragment,{children:t?n.jsxs("div",{className:"sa-input-dropdown-lists-container",onClick:a=>a.stopPropagation(),ref:F,children:[e!=="top"&&O,n.jsxs("div",{className:`sa-input-dropdwon-item-container ${h?"multi":""}`,children:[A&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:A}),h&&D&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:a=>{a.stopPropagation(),D()},children:"Select all"})]}),p.map((a,L)=>{const E=!!(r!=null&&r.find(g=>g.value===a.value));return n.jsxs("div",{className:["sa-input-dropdwon-item",E?"active":"",L===x?"highlight":"",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),ref:g=>{B.current[L]=g},onClick:()=>m(a.label,a.value),children:[h&&n.jsx("div",{style:{flexShrink:0},children:n.jsx(_,{isChecked:E})}),a.icon&&n.jsx("div",{style:{flexShrink:0},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",E?"active":"",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",E?"active":"",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),children:a.description})]})]},L)})]}),e==="top"&&O,j&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:a=>a.stopPropagation(),children:j})]}):null})}),nn=({children:e,handleChangePosition:p})=>{const t=d.useRef(null);d.useEffect(()=>{var m;const o=()=>{if(t.current){let h=t.current.parentElement;for(;h&&!l(h);)h=h.parentElement;h&&p()}};let r=(m=t.current)==null?void 0:m.parentElement;for(;r&&!l(r);)r=r.parentElement;return r&&r.addEventListener("scroll",o),o(),()=>{r&&r.removeEventListener("scroll",o)}},[]);const l=o=>o&&(o.scrollHeight>o.clientHeight||o.scrollWidth>o.clientWidth);return n.jsx("div",{ref:t,children:e})},G="sa-input-dropdown-styles";(e=>{if(!document.getElementById(G)){const p=document.createElement("style");p.id=G,p.textContent=e,document.head.appendChild(p)}})(Z);const en=({dropdownLists:e,onChange:p,defaultValue:t,value:l,size:o="md",multiSelect:r,searchAble:m,iconLeft:h,placeholder:P,onSearch:x,error:j,onBlur:A,onFocus:D,disable:F,searchValue:B,variant:O="outline",footer:a,groupLabel:L,onSelectAll:E,label:g,labelPosition:sn="outside-top",required:U,optional:T,description:N,helperText:C,errorText:f})=>{const z=l!==void 0,H=d.useRef(),dn=j||!!f,[c,I]=d.useState(z?l||[]:t||[]),[tn,X]=d.useState(""),[u,M]=d.useState(-1),k=d.useRef(null),{isComponentVisible:y,ref:q,setIsComponentVisible:W}=Q(!1),ln=()=>{W(s=>!s)},$=(s,i)=>{if(r)if(c==null?void 0:c.find(w=>w.value===i)){const w=c.filter(hn=>hn.value!==i);z||I(w),p(w)}else{const w=[...c,{label:s,value:i}];z||I(w),p(w)}else{const v=[{label:s,value:i}];z||I(v),p(v),W(!1)}};d.useEffect(()=>{z&&I(l||[])},[l]),d.useEffect(()=>{z||JSON.stringify(H.current)===JSON.stringify(t)||(H.current=t,I(H.current||[]))},[t]);const pn=()=>c.length?r?c==null?void 0:c.map((s,i)=>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(rn,{onClick:v=>{v.stopPropagation(),$(s.label,s.value)}})]},i)):n.jsx("p",{style:{minWidth:"max-content"},children:c==null?void 0:c[0].label}):n.jsx("p",{className:"sa-input-dropdown-placeholder",children:P}),S=()=>{if(q.current&&k.current){const s=window.innerHeight,i=q.current.getBoundingClientRect(),v=k.current.getBoundingClientRect(),w=i.bottom+v.height;k.current.style.left=`${i.left}px`,k.current.style.width=`${i.width}px`,w>=s-10?(k.current.style.top=`${i.top-v.height-5}px`,X("top")):(k.current.style.top=`${i.top+i.height+4}px`,X("bottom"))}};d.useEffect(()=>(window.addEventListener("scroll",S),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S),window.removeEventListener("resize",S)}),[]),d.useEffect(()=>{S()},[y]),d.useEffect(()=>{y||M(-1)},[y]);const cn=s=>{if(!y){(s.key==="ArrowDown"||s.key==="Enter")&&(s.preventDefault(),W(!0));return}switch(s.key){case"ArrowDown":{s.preventDefault();const i=J(e,u,1);i!==-1&&M(i);break}case"ArrowUp":{s.preventDefault();const i=J(e,u,-1);i!==-1&&M(i);break}case"Enter":{s.preventDefault(),u>=0&&e[u]&&!e[u].disable&&$(e[u].label,e[u].value);break}case"Escape":W(!1);break}},V=o==="lg"||o==="xl"?20:16,K=n.jsx(nn,{handleChangePosition:S,children:n.jsxs("div",{className:["sa-input-dropdown-container",O,`sa-input-dropdown-size-${o}`,y?"active":"",dn?"error":"",F?"disable":""].filter(Boolean).join(" "),ref:q,onClick:ln,onKeyDown:cn,tabIndex:0,onBlur:A,onFocus:D,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[h?d.cloneElement(h,{width:V,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:pn()}),y?n.jsx(an,{width:V}):n.jsx(on,{width:V})]}),n.jsx(R,{dropdownLists:e,handleChangeValue:$,isComponentVisible:y,positionDropdown:tn,searchAble:!!m,value:c,onSearch:x,ref:k,multiSelect:r,searchValue:B,highlightedIndex:u,footer:a,groupLabel:L,onSelectAll:E})]})});return g?sn==="outside-left"?n.jsxs("div",{className:"sa-select-field sa-select-field-left",children:[n.jsxs("div",{className:"sa-select-field-left-label",children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:g}),T&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),U&&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&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:C}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]})]}):n.jsxs("div",{className:"sa-select-field",children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:g}),T&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),U&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),N&&n.jsx("p",{className:"sa-select-field-helper-top",children:N}),K,C&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:C}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]}):n.jsxs("div",{className:"sa-select-field",children:[N&&n.jsx("p",{className:"sa-select-field-helper-top",children:N}),K,C&&!f&&n.jsx("p",{className:"sa-select-field-helper",children:C}),f&&n.jsx("p",{className:"sa-select-field-error-msg",children:f})]})},J=(e,p,t)=>{const l=e.length;let o=p+t;for(;o>=0&&o<l;){if(!e[o].disable)return o;o+=t}if(t===1){for(let r=0;r<l;r++)if(!e[r].disable)return r}else for(let r=l-1;r>=0;r--)if(!e[r].disable)return r;return-1},rn=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"})}),on=({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"})}),an=({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"})});b.Dropdown=en,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
export interface IconPropsDropdown extends React.SVGProps<SVGSVGElement> {
|
|
2
3
|
}
|
|
4
|
+
export type DropdownSize = "sm" | "md" | "lg" | "xl";
|
|
5
|
+
export type DropdownVariant = "standard" | "outline" | "flushed";
|
|
6
|
+
export type DropdownLabelPosition = "outside-top" | "outside-left";
|
|
3
7
|
export interface IDropdown {
|
|
4
8
|
onChange: (props: {
|
|
5
9
|
label: string;
|
|
@@ -20,7 +24,7 @@ export interface IDropdown {
|
|
|
20
24
|
label: string;
|
|
21
25
|
value: string;
|
|
22
26
|
}[];
|
|
23
|
-
size?:
|
|
27
|
+
size?: DropdownSize;
|
|
24
28
|
error?: boolean;
|
|
25
29
|
multiSelect?: boolean;
|
|
26
30
|
searchAble?: boolean;
|
|
@@ -32,4 +36,15 @@ export interface IDropdown {
|
|
|
32
36
|
onFocus?: (e: React.FocusEvent<HTMLDivElement, Element>) => void;
|
|
33
37
|
disable?: boolean;
|
|
34
38
|
searchValue?: string;
|
|
39
|
+
variant?: DropdownVariant;
|
|
40
|
+
footer?: React.ReactNode;
|
|
41
|
+
groupLabel?: string;
|
|
42
|
+
onSelectAll?: () => void;
|
|
43
|
+
label?: React.ReactNode;
|
|
44
|
+
labelPosition?: DropdownLabelPosition;
|
|
45
|
+
required?: boolean;
|
|
46
|
+
optional?: boolean;
|
|
47
|
+
description?: string;
|
|
48
|
+
helperText?: string;
|
|
49
|
+
errorText?: string;
|
|
35
50
|
}
|