@nuralyui/select 0.1.7 → 0.1.8
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/bundle.js +153 -84
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/react.js.map +1 -1
- package/select.component.d.ts +19 -1
- package/select.component.js +49 -14
- package/select.component.js.map +1 -1
- package/select.constant.d.ts +1 -1
- package/select.constant.js +1 -1
- package/select.constant.js.map +1 -1
- package/select.style.js +148 -79
- package/select.style.js.map +1 -1
- package/select.types.js.map +1 -1
package/bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property as
|
|
1
|
+
import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property as r,query as o,customElement as a}from"lit/decorators.js";import{map as n}from"lit/directives/map.js";import{choose as l}from"lit/directives/choose.js";import{classMap as c}from"lit/directives/class-map.js";import{styleMap as h}from"lit/directives/style-map.js";import{NuralyUIBaseMixin as d}from"@nuralyui/common/mixins";const u=t`
|
|
2
2
|
:host {
|
|
3
3
|
/* Layout and sizing */
|
|
4
4
|
--nuraly-select-local-min-height: 40px;
|
|
@@ -12,28 +12,51 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
12
12
|
|
|
13
13
|
/* Dropdown settings */
|
|
14
14
|
--nuraly-select-local-dropdown-z-index: 9999;
|
|
15
|
-
--nuraly-select-local-dropdown-max-height:
|
|
16
|
-
|
|
15
|
+
--nuraly-select-local-dropdown-max-height: auto;
|
|
16
|
+
--nuraly-select-local-dropdown-width: max-content;
|
|
17
17
|
--nuraly-select-local-placeholder-font-size: 14px;
|
|
18
18
|
--nuraly-select-local-option-font-size: 14px;
|
|
19
19
|
|
|
20
|
-
/*
|
|
20
|
+
/* Search input container settings */
|
|
21
|
+
--nuraly-select-local-input-container-max-width: var(--nuraly-select-width);
|
|
22
|
+
|
|
23
|
+
/* Size tokens - small */
|
|
24
|
+
--nuraly-select-local-small-height: 24px;
|
|
25
|
+
--nuraly-select-local-small-font-size: 12px;
|
|
26
|
+
--nuraly-select-local-small-padding: 2px 8px;
|
|
27
|
+
--nuraly-select-local-small-icon-size: 14px;
|
|
28
|
+
|
|
29
|
+
/* Size tokens - medium */
|
|
21
30
|
--nuraly-select-local-medium-height: 40px;
|
|
22
31
|
--nuraly-select-local-medium-font-size: 14px;
|
|
23
32
|
--nuraly-select-local-medium-padding: 8px 12px;
|
|
24
|
-
--nuraly-select-local-
|
|
33
|
+
--nuraly-select-local-medium-icon-size: 16px;
|
|
34
|
+
|
|
35
|
+
/* Size tokens - large */
|
|
36
|
+
--nuraly-select-local-large-height: 48px;
|
|
37
|
+
--nuraly-select-local-large-font-size: 16px;
|
|
38
|
+
--nuraly-select-local-large-padding: 12px 16px;
|
|
39
|
+
--nuraly-select-local-large-icon-size: 20px;
|
|
25
40
|
|
|
26
41
|
/* Animation and transitions */
|
|
27
42
|
--nuraly-select-local-dropdown-animation-duration: 0.15s;
|
|
43
|
+
--nuraly-select-local-transition-duration: 0.2s;
|
|
28
44
|
|
|
29
45
|
/* Multi-select specific */
|
|
30
46
|
--nuraly-select-local-tag-border-radius: 4px;
|
|
31
47
|
--nuraly-select-local-tag-padding: 2px 6px;
|
|
32
48
|
--nuraly-select-local-tag-margin: 2px;
|
|
33
49
|
|
|
50
|
+
/* Icon sizes */
|
|
51
|
+
--nuraly-select-local-icon-size: 16px;
|
|
52
|
+
--nuraly-select-local-arrow-icon-size: 16px;
|
|
53
|
+
|
|
34
54
|
/* Validation message */
|
|
35
55
|
--nuraly-select-local-message-font-size: 12px;
|
|
36
56
|
--nuraly-select-local-message-margin-top: 4px;
|
|
57
|
+
|
|
58
|
+
/* Font settings */
|
|
59
|
+
--nuraly-select-local-font-size: 14px;
|
|
37
60
|
}
|
|
38
61
|
|
|
39
62
|
:host {
|
|
@@ -52,22 +75,37 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
52
75
|
}
|
|
53
76
|
|
|
54
77
|
:host([disabled]) .wrapper {
|
|
55
|
-
background-color: var(--nuraly-select-disabled-background,
|
|
56
|
-
border-color: var(--nuraly-select-disabled-border-color,
|
|
57
|
-
color: var(--nuraly-select-disabled-text-color,
|
|
78
|
+
background-color: var(--nuraly-select-disabled-background, var(--nuraly-color-background-disabled));
|
|
79
|
+
border-color: var(--nuraly-select-disabled-border-color, var(--nuraly-color-border));
|
|
80
|
+
color: var(--nuraly-select-disabled-text-color, var(--nuraly-color-text-disabled));
|
|
58
81
|
cursor: not-allowed;
|
|
59
82
|
}
|
|
60
83
|
|
|
61
84
|
/* Size variants */
|
|
62
85
|
:host([size='small']) .wrapper {
|
|
63
|
-
height: var(--nuraly-select-small-height,
|
|
64
|
-
min-height: var(--nuraly-select-small-height,
|
|
86
|
+
height: var(--nuraly-select-small-height, var(--nuraly-select-local-small-height));
|
|
87
|
+
min-height: var(--nuraly-select-small-height, var(--nuraly-select-local-small-height));
|
|
65
88
|
font-size: var(--nuraly-select-small-font-size, var(--nuraly-select-local-small-font-size));
|
|
66
89
|
}
|
|
67
90
|
|
|
68
91
|
:host([size='small']) .select-trigger {
|
|
69
|
-
padding: var(--nuraly-select-small-padding,
|
|
70
|
-
padding-right: calc(var(--nuraly-select-icon-size,
|
|
92
|
+
padding: var(--nuraly-select-small-padding, var(--nuraly-select-local-small-padding));
|
|
93
|
+
padding-right: calc(var(--nuraly-select-small-icon-size, var(--nuraly-select-local-small-icon-size)) + 20px);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
:host([size='small']) .icons-container nr-icon {
|
|
97
|
+
--nuraly-icon-width: var(--nuraly-select-small-icon-size, var(--nuraly-select-local-small-icon-size));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
:host([size='small']) .option {
|
|
101
|
+
padding: var(--nuraly-select-small-padding, var(--nuraly-select-local-small-padding));
|
|
102
|
+
font-size: var(--nuraly-select-small-font-size, var(--nuraly-select-local-small-font-size));
|
|
103
|
+
min-height: var(--nuraly-select-small-height, var(--nuraly-select-local-small-height));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
:host([size='small']) .option-icon,
|
|
107
|
+
:host([size='small']) .option nr-icon {
|
|
108
|
+
--nuraly-icon-width: var(--nuraly-select-small-icon-size, var(--nuraly-select-local-small-icon-size));
|
|
71
109
|
}
|
|
72
110
|
|
|
73
111
|
:host([size='medium']) .wrapper {
|
|
@@ -77,30 +115,60 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
77
115
|
|
|
78
116
|
:host([size='medium']) .select-trigger {
|
|
79
117
|
padding: var(--nuraly-select-medium-padding, var(--nuraly-select-local-medium-padding));
|
|
80
|
-
padding-right: calc(var(--nuraly-select-icon-size,
|
|
118
|
+
padding-right: calc(var(--nuraly-select-medium-icon-size, var(--nuraly-select-local-medium-icon-size)) + 20px);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
:host([size='medium']) .icons-container nr-icon {
|
|
122
|
+
--nuraly-icon-width: var(--nuraly-select-medium-icon-size, var(--nuraly-select-local-medium-icon-size));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
:host([size='medium']) .option {
|
|
126
|
+
padding: var(--nuraly-select-medium-padding, var(--nuraly-select-local-medium-padding));
|
|
127
|
+
font-size: var(--nuraly-select-medium-font-size, var(--nuraly-select-local-medium-font-size));
|
|
128
|
+
min-height: var(--nuraly-select-medium-height, var(--nuraly-select-local-medium-height));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
:host([size='medium']) .option-icon,
|
|
132
|
+
:host([size='medium']) .option nr-icon {
|
|
133
|
+
--nuraly-icon-width: var(--nuraly-select-medium-icon-size, var(--nuraly-select-local-medium-icon-size));
|
|
81
134
|
}
|
|
82
135
|
|
|
83
136
|
:host([size='large']) .wrapper {
|
|
84
|
-
min-height: var(--nuraly-select-large-height,
|
|
85
|
-
font-size: var(--nuraly-select-large-font-size,
|
|
137
|
+
min-height: var(--nuraly-select-large-height, var(--nuraly-select-local-large-height));
|
|
138
|
+
font-size: var(--nuraly-select-large-font-size, var(--nuraly-select-local-large-font-size));
|
|
86
139
|
}
|
|
87
140
|
|
|
88
141
|
:host([size='large']) .select-trigger {
|
|
89
|
-
padding: var(--nuraly-select-large-padding,
|
|
90
|
-
padding-right: calc(var(--nuraly-select-icon-size,
|
|
142
|
+
padding: var(--nuraly-select-large-padding, var(--nuraly-select-local-large-padding));
|
|
143
|
+
padding-right: calc(var(--nuraly-select-large-icon-size, var(--nuraly-select-local-large-icon-size)) + 20px);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
:host([size='large']) .icons-container nr-icon {
|
|
147
|
+
--nuraly-icon-width: var(--nuraly-select-large-icon-size, var(--nuraly-select-local-large-icon-size));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
:host([size='large']) .option {
|
|
151
|
+
padding: var(--nuraly-select-large-padding, var(--nuraly-select-local-large-padding));
|
|
152
|
+
font-size: var(--nuraly-select-large-font-size, var(--nuraly-select-local-large-font-size));
|
|
153
|
+
min-height: var(--nuraly-select-large-height, var(--nuraly-select-local-large-height));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
:host([size='large']) .option-icon,
|
|
157
|
+
:host([size='large']) .option nr-icon {
|
|
158
|
+
--nuraly-icon-width: var(--nuraly-select-large-icon-size, var(--nuraly-select-local-large-icon-size));
|
|
91
159
|
}
|
|
92
160
|
|
|
93
161
|
/* Status variants */
|
|
94
162
|
:host([status='error']) .wrapper {
|
|
95
|
-
border-color: var(--nuraly-select-error-border-color,
|
|
163
|
+
border-color: var(--nuraly-select-error-border-color, var(--nuraly-color-danger));
|
|
96
164
|
}
|
|
97
165
|
|
|
98
166
|
:host([status='warning']) .wrapper {
|
|
99
|
-
border-color: var(--nuraly-select-warning-border-color,
|
|
167
|
+
border-color: var(--nuraly-select-warning-border-color, var(--nuraly-color-warning));
|
|
100
168
|
}
|
|
101
169
|
|
|
102
170
|
:host([status='success']) .wrapper {
|
|
103
|
-
border-color: var(--nuraly-select-success-border-color,
|
|
171
|
+
border-color: var(--nuraly-select-success-border-color, var(--nuraly-color-success));
|
|
104
172
|
}
|
|
105
173
|
|
|
106
174
|
/* Type variants */
|
|
@@ -132,11 +200,11 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
132
200
|
.wrapper {
|
|
133
201
|
position: relative;
|
|
134
202
|
width: var(--nuraly-select-width, fit-content);
|
|
135
|
-
background-color: var(--nuraly-select-background-color
|
|
203
|
+
background-color: var(--nuraly-select-background, var(--nuraly-color-background-panel));
|
|
136
204
|
border: var(--nuraly-select-border-width, var(--nuraly-select-local-border-width)) solid
|
|
137
|
-
var(--nuraly-select-border-color,
|
|
205
|
+
var(--nuraly-select-border-color, var(--nuraly-color-border));
|
|
138
206
|
border-radius: var(--nuraly-select-border-radius, var(--nuraly-select-local-border-radius));
|
|
139
|
-
transition: all var(--nuraly-select-transition-duration,
|
|
207
|
+
transition: all var(--nuraly-select-transition-duration, var(--nuraly-select-local-transition-duration))
|
|
140
208
|
var(--nuraly-select-transition-timing, ease-in-out);
|
|
141
209
|
cursor: pointer;
|
|
142
210
|
outline: none;
|
|
@@ -150,13 +218,13 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
150
218
|
}
|
|
151
219
|
|
|
152
220
|
.wrapper:hover:not(:disabled) {
|
|
153
|
-
border-color: var(--nuraly-select-border-hover,
|
|
221
|
+
border-color: var(--nuraly-select-border-hover, var(--nuraly-color-primary));
|
|
154
222
|
}
|
|
155
223
|
|
|
156
224
|
.wrapper:focus,
|
|
157
225
|
.wrapper:focus-within {
|
|
158
|
-
border-color: var(--nuraly-select-border-focus,
|
|
159
|
-
box-shadow: 0 0 0 2px var(--nuraly-
|
|
226
|
+
border-color: var(--nuraly-select-border-focus, var(--nuraly-color-primary));
|
|
227
|
+
box-shadow: 0 0 0 2px var(--nuraly-color-primary-light);
|
|
160
228
|
}
|
|
161
229
|
|
|
162
230
|
/* Select container */
|
|
@@ -170,10 +238,10 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
170
238
|
display: flex;
|
|
171
239
|
align-items: center;
|
|
172
240
|
padding: var(--nuraly-select-padding-top, var(--nuraly-select-local-padding-top))
|
|
173
|
-
calc(var(--nuraly-select-icon-size,
|
|
241
|
+
calc(var(--nuraly-select-icon-size, var(--nuraly-select-local-icon-size)) + 20px)
|
|
174
242
|
var(--nuraly-select-padding-bottom, var(--nuraly-select-local-padding-bottom))
|
|
175
243
|
var(--nuraly-select-padding-left, var(--nuraly-select-local-padding-left));
|
|
176
|
-
color: var(--nuraly-select-
|
|
244
|
+
color: var(--nuraly-select-color, var(--nuraly-color-text));
|
|
177
245
|
font-size: inherit;
|
|
178
246
|
line-height: inherit;
|
|
179
247
|
word-break: break-word;
|
|
@@ -186,7 +254,7 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
186
254
|
|
|
187
255
|
.select-trigger:empty:before {
|
|
188
256
|
content: attr(data-placeholder);
|
|
189
|
-
color: var(--nuraly-select-placeholder-color,
|
|
257
|
+
color: var(--nuraly-select-placeholder-color, var(--nuraly-color-text-secondary));
|
|
190
258
|
font-size: var(--nuraly-select-placeholder-font-size, var(--nuraly-select-local-placeholder-font-size));
|
|
191
259
|
}
|
|
192
260
|
|
|
@@ -195,8 +263,8 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
195
263
|
display: inline-flex;
|
|
196
264
|
align-items: center;
|
|
197
265
|
gap: 4px;
|
|
198
|
-
background-color: var(--nuraly-select-tag-background, var(--nuraly-
|
|
199
|
-
color: var(--nuraly-select-tag-color, var(--nuraly-
|
|
266
|
+
background-color: var(--nuraly-select-tag-background, var(--nuraly-color-background-active));
|
|
267
|
+
color: var(--nuraly-select-tag-color, var(--nuraly-color-text));
|
|
200
268
|
padding: var(--nuraly-select-tag-padding, var(--nuraly-select-local-tag-padding));
|
|
201
269
|
border-radius: var(--nuraly-select-tag-border-radius, var(--nuraly-select-local-tag-border-radius));
|
|
202
270
|
font-size: calc(var(--nuraly-select-font-size, var(--nuraly-select-local-font-size)) - 1px);
|
|
@@ -210,7 +278,7 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
210
278
|
}
|
|
211
279
|
|
|
212
280
|
.tag-close {
|
|
213
|
-
color: var(--nuraly-select-tag-close-color, var(--nuraly-
|
|
281
|
+
color: var(--nuraly-select-tag-close-color, var(--nuraly-color-text-secondary));
|
|
214
282
|
cursor: pointer;
|
|
215
283
|
display: flex;
|
|
216
284
|
align-items: center;
|
|
@@ -222,7 +290,7 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
222
290
|
}
|
|
223
291
|
|
|
224
292
|
.tag-close:hover {
|
|
225
|
-
color: var(--nuraly-select-tag-close-hover-color, var(--nuraly-
|
|
293
|
+
color: var(--nuraly-select-tag-close-hover-color, var(--nuraly-color-text));
|
|
226
294
|
}
|
|
227
295
|
|
|
228
296
|
/* Icons container */
|
|
@@ -239,14 +307,14 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
239
307
|
|
|
240
308
|
.icons-container nr-icon {
|
|
241
309
|
--nuraly-icon-width: var(--nuraly-select-icon-size, var(--nuraly-select-local-icon-size));
|
|
242
|
-
--nuraly-icon-color: var(--nuraly-select-icon
|
|
310
|
+
--nuraly-icon-color: var(--nuraly-color-select-icon, var(--nuraly-color-text-secondary));
|
|
243
311
|
pointer-events: auto;
|
|
244
312
|
cursor: pointer;
|
|
245
313
|
transition: color var(--nuraly-select-transition-duration, var(--nuraly-select-local-transition-duration));
|
|
246
314
|
}
|
|
247
315
|
|
|
248
316
|
.icons-container nr-icon:hover {
|
|
249
|
-
--nuraly-icon-color: var(--nuraly-select-icon-hover
|
|
317
|
+
--nuraly-icon-color: var(--nuraly-color-select-icon-hover, var(--nuraly-color-text));
|
|
250
318
|
}
|
|
251
319
|
|
|
252
320
|
.arrow-icon {
|
|
@@ -267,18 +335,18 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
267
335
|
margin-top: 1px;
|
|
268
336
|
left: 0;
|
|
269
337
|
right: 0;
|
|
270
|
-
background-color: var(--nuraly-select-dropdown-background,
|
|
271
|
-
border: var(--nuraly-select-dropdown-border-width, var(--nuraly-select-border-width,
|
|
272
|
-
var(--nuraly-select-dropdown-border-color,
|
|
273
|
-
border-radius: var(--nuraly-select-dropdown-border-radius, var(--nuraly-select-border-radius,
|
|
338
|
+
background-color: var(--nuraly-select-dropdown-background, var(--nuraly-color-background-panel));
|
|
339
|
+
border: var(--nuraly-select-dropdown-border-width, var(--nuraly-select-border-width, var(--nuraly-select-local-border-width))) solid
|
|
340
|
+
var(--nuraly-select-dropdown-border-color, var(--nuraly-color-border));
|
|
341
|
+
border-radius: var(--nuraly-select-dropdown-border-radius, var(--nuraly-select-border-radius, var(--nuraly-select-local-border-radius)));
|
|
274
342
|
box-shadow: var(--nuraly-select-dropdown-shadow, 0 6px 16px 0 rgba(0, 0, 0, 0.08));
|
|
275
|
-
z-index: var(--nuraly-select-dropdown-z-index,
|
|
276
|
-
max-height: var(--nuraly-select-dropdown-max-height,
|
|
343
|
+
z-index: var(--nuraly-select-dropdown-z-index, var(--nuraly-select-local-dropdown-z-index));
|
|
344
|
+
max-height: var(--nuraly-select-dropdown-max-height, var(--nuraly-select-local-dropdown-max-height, auto));
|
|
277
345
|
overflow-y: auto;
|
|
278
346
|
overflow-x: hidden;
|
|
279
347
|
display: none;
|
|
280
348
|
flex-direction: column;
|
|
281
|
-
animation: dropdown-enter var(--nuraly-select-dropdown-animation-duration,
|
|
349
|
+
animation: dropdown-enter var(--nuraly-select-dropdown-animation-duration, var(--nuraly-select-local-dropdown-animation-duration)) ease-out;
|
|
282
350
|
/* Ensure proper containment and exact wrapper width */
|
|
283
351
|
box-sizing: border-box;
|
|
284
352
|
/* Allow overriding width via either of these custom props */
|
|
@@ -331,9 +399,9 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
331
399
|
position: sticky;
|
|
332
400
|
top: 0;
|
|
333
401
|
z-index: 10;
|
|
334
|
-
background-color: var(--nuraly-select-dropdown-background,
|
|
335
|
-
border-bottom: var(--nuraly-select-border-width,
|
|
336
|
-
var(--nuraly-select-dropdown-border-color,
|
|
402
|
+
background-color: var(--nuraly-select-dropdown-background, var(--nuraly-color-background-panel));
|
|
403
|
+
border-bottom: var(--nuraly-select-border-width, var(--nuraly-select-local-border-width)) solid
|
|
404
|
+
var(--nuraly-select-dropdown-border-color, var(--nuraly-color-border));
|
|
337
405
|
padding: 8px;
|
|
338
406
|
margin: 0;
|
|
339
407
|
/* Ensure it stays above options during scroll */
|
|
@@ -347,16 +415,17 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
347
415
|
/* Search input styling */
|
|
348
416
|
.search-container .search-input {
|
|
349
417
|
width: 100%;
|
|
418
|
+
max-width: var(--nuraly-select-input-container-max-width, var(--nuraly-select-local-input-container-max-width));
|
|
350
419
|
--nuraly-input-border-radius: var(--nuraly-select-border-radius, var(--nuraly-select-local-border-radius));
|
|
351
|
-
--nuraly-input-background-color: var(--nuraly-select-background
|
|
352
|
-
--nuraly-input-border-color: var(--nuraly-select-border-color, var(--nuraly-
|
|
353
|
-
--nuraly-input-text-color: var(--nuraly-select-
|
|
354
|
-
--nuraly-input-placeholder-color: var(--nuraly-select-placeholder-color, var(--nuraly-
|
|
420
|
+
--nuraly-input-background-color: var(--nuraly-select-background, var(--nuraly-color-background-panel));
|
|
421
|
+
--nuraly-input-border-color: var(--nuraly-select-border-color, var(--nuraly-color-border));
|
|
422
|
+
--nuraly-input-text-color: var(--nuraly-select-color, var(--nuraly-color-text));
|
|
423
|
+
--nuraly-input-placeholder-color: var(--nuraly-select-placeholder-color, var(--nuraly-color-text-secondary));
|
|
355
424
|
}
|
|
356
425
|
|
|
357
426
|
/* Search icon in the search input */
|
|
358
427
|
.search-container .search-icon {
|
|
359
|
-
--nuraly-icon-color: var(--nuraly-select-icon
|
|
428
|
+
--nuraly-icon-color: var(--nuraly-color-select-icon, var(--nuraly-color-text-secondary));
|
|
360
429
|
}
|
|
361
430
|
|
|
362
431
|
/* Options list container - ensure proper scroll behavior with sticky search */
|
|
@@ -372,10 +441,10 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
372
441
|
gap: 8px;
|
|
373
442
|
padding: var(--nuraly-select-option-padding, 8px 12px);
|
|
374
443
|
min-height: var(--nuraly-select-option-min-height, auto);
|
|
375
|
-
color: var(--nuraly-select-option-
|
|
376
|
-
font-size: var(--nuraly-select-option-font-size,
|
|
444
|
+
color: var(--nuraly-select-option-color, var(--nuraly-color-text));
|
|
445
|
+
font-size: var(--nuraly-select-option-font-size, var(--nuraly-select-local-option-font-size));
|
|
377
446
|
cursor: pointer;
|
|
378
|
-
transition: background-color var(--nuraly-select-transition-duration,
|
|
447
|
+
transition: background-color var(--nuraly-select-transition-duration, var(--nuraly-select-local-transition-duration));
|
|
379
448
|
position: relative;
|
|
380
449
|
}
|
|
381
450
|
|
|
@@ -385,17 +454,17 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
385
454
|
}
|
|
386
455
|
|
|
387
456
|
.option:hover {
|
|
388
|
-
background-color: var(--nuraly-select-option-hover-background,
|
|
457
|
+
background-color: var(--nuraly-select-option-hover-background, var(--nuraly-color-background-hover));
|
|
389
458
|
}
|
|
390
459
|
|
|
391
460
|
.option.selected {
|
|
392
|
-
background-color: var(--nuraly-select-option-selected-background,
|
|
393
|
-
color: var(--nuraly-select-option-selected-color,
|
|
461
|
+
background-color: var(--nuraly-select-option-selected-background, var(--nuraly-color-primary-light));
|
|
462
|
+
color: var(--nuraly-select-option-selected-color, var(--nuraly-color-primary));
|
|
394
463
|
}
|
|
395
464
|
|
|
396
465
|
.option.focused {
|
|
397
|
-
background-color: var(--nuraly-select-option-hover-background,
|
|
398
|
-
outline: 2px solid var(--nuraly-select-border-focus,
|
|
466
|
+
background-color: var(--nuraly-select-option-hover-background, var(--nuraly-color-background-hover));
|
|
467
|
+
outline: 2px solid var(--nuraly-select-border-focus, var(--nuraly-color-primary));
|
|
399
468
|
outline-offset: -2px;
|
|
400
469
|
}
|
|
401
470
|
|
|
@@ -431,7 +500,7 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
431
500
|
|
|
432
501
|
.check-icon {
|
|
433
502
|
--nuraly-icon-width: var(--nuraly-select-icon-size, var(--nuraly-select-local-icon-size));
|
|
434
|
-
--nuraly-icon-color: var(--nuraly-select-option-selected-color, var(--nuraly-
|
|
503
|
+
--nuraly-icon-color: var(--nuraly-select-option-selected-color, var(--nuraly-color-primary));
|
|
435
504
|
}
|
|
436
505
|
|
|
437
506
|
.no-options {
|
|
@@ -439,7 +508,7 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
439
508
|
align-items: center;
|
|
440
509
|
justify-content: center;
|
|
441
510
|
padding: var(--select-no-options-padding, 24px 16px);
|
|
442
|
-
color: var(--select-no-options-color,
|
|
511
|
+
color: var(--select-no-options-color, var(--nuraly-color-text-secondary));
|
|
443
512
|
font-size: var(--nuraly-select-option-font-size, var(--nuraly-select-local-option-font-size));
|
|
444
513
|
cursor: default;
|
|
445
514
|
user-select: none;
|
|
@@ -455,13 +524,13 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
455
524
|
|
|
456
525
|
.no-options-icon {
|
|
457
526
|
--nuraly-icon-width: 24px;
|
|
458
|
-
--nuraly-icon-color: var(--select-no-options-icon-color,
|
|
527
|
+
--nuraly-icon-color: var(--select-no-options-icon-color, var(--nuraly-color-border));
|
|
459
528
|
opacity: 0.8;
|
|
460
529
|
}
|
|
461
530
|
|
|
462
531
|
.no-options-text {
|
|
463
532
|
font-size: var(--nuraly-select-option-font-size, var(--nuraly-select-local-option-font-size));
|
|
464
|
-
color: var(--select-no-options-color,
|
|
533
|
+
color: var(--select-no-options-color, var(--nuraly-color-text-secondary));
|
|
465
534
|
line-height: 1.4;
|
|
466
535
|
}
|
|
467
536
|
|
|
@@ -470,15 +539,15 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
470
539
|
display: block;
|
|
471
540
|
margin-top: var(--nuraly-select-message-margin-top, var(--nuraly-select-local-message-margin-top));
|
|
472
541
|
font-size: var(--nuraly-select-message-font-size, var(--nuraly-select-local-message-font-size));
|
|
473
|
-
color: var(--nuraly-select-error-message-color, var(--nuraly-
|
|
542
|
+
color: var(--nuraly-select-error-message-color, var(--nuraly-color-danger));
|
|
474
543
|
}
|
|
475
544
|
|
|
476
545
|
.validation-message.warning {
|
|
477
|
-
color: var(--nuraly-select-warning-message-color, var(--nuraly-
|
|
546
|
+
color: var(--nuraly-select-warning-message-color, var(--nuraly-color-warning));
|
|
478
547
|
}
|
|
479
548
|
|
|
480
549
|
.validation-message.success {
|
|
481
|
-
color: var(--nuraly-select-success-message-color, var(--nuraly-
|
|
550
|
+
color: var(--nuraly-select-success-message-color, var(--nuraly-color-success));
|
|
482
551
|
}
|
|
483
552
|
|
|
484
553
|
/* Slotted content styles */
|
|
@@ -486,14 +555,14 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
486
555
|
display: block;
|
|
487
556
|
margin-bottom: 4px;
|
|
488
557
|
font-weight: 500;
|
|
489
|
-
color: var(--nuraly-select-
|
|
558
|
+
color: var(--nuraly-select-color, var(--nuraly-color-text));
|
|
490
559
|
}
|
|
491
560
|
|
|
492
561
|
::slotted([slot='helper-text']) {
|
|
493
562
|
display: block;
|
|
494
563
|
margin-top: var(--nuraly-select-message-margin-top, var(--nuraly-select-local-message-margin-top));
|
|
495
564
|
font-size: var(--nuraly-select-message-font-size, var(--nuraly-select-local-message-font-size));
|
|
496
|
-
color: var(--nuraly-select-placeholder-color, var(--nuraly-
|
|
565
|
+
color: var(--nuraly-select-placeholder-color, var(--nuraly-color-text-secondary));
|
|
497
566
|
}
|
|
498
567
|
|
|
499
568
|
/* Accessibility improvements */
|
|
@@ -519,7 +588,7 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
519
588
|
outline: 3px solid;
|
|
520
589
|
}
|
|
521
590
|
}
|
|
522
|
-
`;var p,v,y,g,m,f,b,w,x;!function(t){t.Default="default",t.Inline="inline",t.Button="button",t.Slot="slot"}(p||(p={})),function(t){t.Default="default",t.Warning="warning",t.Error="error",t.Success="success"}(v||(v={})),function(t){t.Small="small",t.Medium="medium",t.Large="large"}(y||(y={})),function(t){t.Small="small",t.Medium="medium",t.Large="large"}(g||(g={})),function(t){t.Horizontal="horizontal",t.Vertical="vertical"}(m||(m={})),function(t){t.Default="default",t.Solid="solid",t.Outline="outline",t.Borderless="borderless"}(f||(f={})),function(t){t.Bottom="bottom",t.Top="top",t.Auto="auto"}(b||(b={})),function(t){t.None="none",t.StartsWith="starts-with",t.Contains="contains",t.Fuzzy="fuzzy"}(w||(w={}));class O{constructor(t){this._host=t,this._host.addController(this)}get host(){return this._host}hostConnected(){}hostDisconnected(){}hostUpdate(){}hostUpdated(){}handleError(t,e){console.error(`[SelectController:${this.constructor.name}] Error in ${e}:`,t),this._host.dispatchEvent(new CustomEvent("nr-select-error",{detail:{error:t.message,context:e,controller:this.constructor.name},bubbles:!0,composed:!0}))}requestUpdate(){try{this._host.requestUpdate()}catch(t){this.handleError(t,"requestUpdate")}}dispatchEvent(t){try{return this._host.dispatchEvent(t)}catch(t){return this.handleError(t,"dispatchEvent"),!1}}}class E extends O{constructor(){super(...arguments),this._selectedOptions=[],this._initialized=!1}getSelectedOptions(){return[...this._selectedOptions]}getSelectedOption(){return this._selectedOptions[0]}selectOption(t){try{if(this.isOptionDisabled(t))return;const e=this.host.multiple,i=this.getCurrentValue();e?this.isOptionSelected(t)||(this._selectedOptions=[...this._selectedOptions,t],this.updateHostValue(),this.dispatchChangeEvent(i)):(this.isOptionSelected(t)?this._selectedOptions=[]:this._selectedOptions=[t],this.updateHostValue(),this.dispatchChangeEvent(i)),this.requestUpdate()}catch(t){this.handleError(t,"selectOption")}}unselectOption(t){try{if(this.isOptionSelected(t)){const e=this.getCurrentValue();this._selectedOptions=this._selectedOptions.filter((e=>e.value!==t.value)),this.updateHostValue(),this.dispatchChangeEvent(e),this.requestUpdate()}}catch(t){this.handleError(t,"unselectOption")}}clearSelection(){try{if(this._selectedOptions.length>0){const t=this.getCurrentValue();this._selectedOptions=[],this.updateHostValue(),this.dispatchChangeEvent(t),this.requestUpdate()}}catch(t){this.handleError(t,"clearSelection")}}isOptionSelected(t){return this._selectedOptions.some((e=>e.value===t.value))}isOptionDisabled(t){return Boolean(t.disabled)||this.host.disabled}toggleOption(t){this.isOptionSelected(t)?this.unselectOption(t):this.selectOption(t)}initializeFromValue(){try{if(this._initialized)return;const t=this.host.value;if(!t||Array.isArray(t)&&0===t.length)return;const e=Array.isArray(t)?t:[t],i=this.host.options.filter((t=>e.includes(t.value)));i.length>0&&(this._selectedOptions=this.host.multiple?i:[i[0]],this.requestUpdate()),this._initialized=!0}catch(t){this.handleError(t,"initializeFromValue")}}updateHostValue(){var t;const e=this.host.multiple?this._selectedOptions.map((t=>t.value)):(null===(t=this._selectedOptions[0])||void 0===t?void 0:t.value)||"",i=this.host.value;let s=!1;if(this.host.multiple){const t=Array.isArray(i)?i:[],o=Array.isArray(e)?e:[];s=t.length===o.length&&t.every(((t,e)=>t===o[e]))}else s=i===e;s||(this.host.value=e)}getCurrentValue(){var t;return this.host.multiple?this._selectedOptions.map((t=>t.value)):(null===(t=this._selectedOptions[0])||void 0===t?void 0:t.value)||""}dispatchChangeEvent(t){const e={value:this.getCurrentValue(),selectedOptions:this.getSelectedOptions(),previousValue:t};this.dispatchEvent(new CustomEvent("nr-change",{detail:e,bubbles:!0,composed:!0}))}hostUpdated(){this.syncWithHostOptions()}syncWithHostOptions(){try{this._selectedOptions=this._selectedOptions.filter((t=>this.host.options.some((e=>e.value===t.value)))),this._selectedOptions=this._selectedOptions.map((t=>this.host.options.find((e=>e.value===t.value))||t)),this.updateHostValue()}catch(t){this.handleError(t,"syncWithHostOptions")}}}class z extends O{constructor(t,e,i){super(t),this.selectionController=e,this.dropdownController=i,this._focusedIndex=-1,this._hasKeyboardNavigated=!1}handleKeyDown(t){try{const e=this.isSearchInputFocused();switch(t.key){case"ArrowDown":t.preventDefault(),this.dropdownController.isOpen?this.navigateNext():this.openDropdown();break;case"ArrowUp":t.preventDefault(),this.dropdownController.isOpen?this.navigatePrevious():this.openDropdown();break;case"Enter":this.dropdownController.isOpen?e&&this._focusedIndex>=0?(t.preventDefault(),this.selectFocused()):e||(t.preventDefault(),this.selectFocused()):(t.preventDefault(),this.openDropdown());break;case" ":e||(t.preventDefault(),this.dropdownController.isOpen?this.selectFocused():this.openDropdown());break;case"Escape":t.preventDefault(),this.closeDropdown();break;case"Tab":this.closeDropdown();break;case"Home":this.dropdownController.isOpen&&(t.preventDefault(),this.setFocusedIndex(0));break;case"End":this.dropdownController.isOpen&&(t.preventDefault(),this.setFocusedIndex(this.host.options.length-1));break;default:1===t.key.length&&/[a-zA-Z0-9]/.test(t.key)&&this.handleAlphanumericKey(t.key.toLowerCase())}}catch(t){this.handleError(t,"handleKeyDown")}}navigateNext(){try{const t=this.getNavigableOptions();if(0===t.length)return;if(this.isSearchInputFocused()&&(this._focusedIndex<0||!this._hasKeyboardNavigated))return this._hasKeyboardNavigated=!0,void this.setFocusedIndex(0);let e=this._focusedIndex+1;e>=t.length&&(e=0),this.setFocusedIndex(e)}catch(t){this.handleError(t,"navigateNext")}}navigatePrevious(){try{const t=this.getNavigableOptions();if(0===t.length)return;if(this.isSearchInputFocused()&&(this._focusedIndex<0||!this._hasKeyboardNavigated))return this._hasKeyboardNavigated=!0,void this.setFocusedIndex(t.length-1);let e=this._focusedIndex-1;e<0&&(e=t.length-1),this.setFocusedIndex(e)}catch(t){this.handleError(t,"navigatePrevious")}}selectFocused(){try{const t=this.getNavigableOptions()[this._focusedIndex];t&&!this.selectionController.isOptionDisabled(t)&&(this.selectionController.selectOption(t),this.host.multiple||this.closeDropdown())}catch(t){this.handleError(t,"selectFocused")}}openDropdown(){try{this.dropdownController.open(),this._hasKeyboardNavigated=!1,this._focusedIndex=-1}catch(t){this.handleError(t,"openDropdown")}}closeDropdown(){try{this.dropdownController.close(),this._focusedIndex=-1,this._hasKeyboardNavigated=!1}catch(t){this.handleError(t,"closeDropdown")}}setFocusedIndex(t){try{const e=this.getNavigableOptions();t>=0&&t<e.length&&(this._focusedIndex=t,this.dispatchFocusEvent(e[t],t),this.requestUpdate(),this.scrollToFocusedOption(t))}catch(t){this.handleError(t,"setFocusedIndex")}}scrollToFocusedOption(t){var e;try{const i=null===(e=this.host.shadowRoot)||void 0===e?void 0:e.querySelector(".options");if(!i)return;setTimeout((()=>{const e=i.querySelector(".option.focused");if(e)e.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});else{const e=40,s=i.clientHeight,o=i.scrollTop,r=t*e,n=r+e,a=o+s;r<o?i.scrollTo({top:r,behavior:"smooth"}):n>a&&i.scrollTo({top:n-s,behavior:"smooth"})}}),10)}catch(t){console.warn("Failed to scroll to focused option:",t)}}get focusedIndex(){return this._focusedIndex}get focusedOption(){return this.getNavigableOptions()[this._focusedIndex]}handleAlphanumericKey(t){try{const e=this.getNavigableOptions(),i=this._focusedIndex+1;for(let s=0;s<e.length;s++){const o=(i+s)%e.length;if(e[o].label.toLowerCase().startsWith(t)){this.setFocusedIndex(o),this.dropdownController.isOpen||this.openDropdown();break}}}catch(t){this.handleError(t,"handleAlphanumericKey")}}getNavigableOptions(){const t=this.host;if(!t.options||!Array.isArray(t.options))return[];let e=t.options;return t.searchable&&t.searchQuery&&"function"==typeof t.getFilteredOptions&&(e=t.getFilteredOptions()),e.filter((t=>!t.disabled))}dispatchFocusEvent(t,e){const i={focusedOption:t,focusedIndex:e};this.dispatchEvent(new CustomEvent("nr-select-focus",{detail:i,bubbles:!0,composed:!0}))}isSearchInputFocused(){var t;try{const e=this.host;if(!e.searchable)return!1;const i=null===(t=e.shadowRoot)||void 0===t?void 0:t.querySelector(".search-input");return!!i&&(document.activeElement===i||i.shadowRoot&&i.shadowRoot.querySelector("input")===i.shadowRoot.activeElement||i.contains(document.activeElement))}catch(t){return!1}}hostUpdated(){this.dropdownController.isOpen||-1===this._focusedIndex||(this._focusedIndex=-1)}}class S extends O{constructor(){super(...arguments),this._isOpen=!1,this._position={top:0,left:0,width:0,placement:"bottom"},this._dropdownElement=null,this._triggerElement=null,this.handleResize=()=>{this._isOpen&&this.calculatePosition()},this.handleScroll=()=>{var t;if(this._isOpen&&this._triggerElement){const e=this._triggerElement.getBoundingClientRect(),i=(null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight;(e.bottom<0||e.top>i)&&this.close()}}}get isOpen(){return this._isOpen}get position(){return Object.assign({},this._position)}open(){try{this._isOpen||(this._isOpen=!0,this.host.show=!0,this.requestUpdate(),this.findElements(),setTimeout((()=>{this.calculatePosition()}),10),this.host&&"function"==typeof this.host.setupEventListeners&&setTimeout((()=>{this.host.setupEventListeners()}),50),this.focusSearchInput(),this.dispatchEvent(new CustomEvent("nr-dropdown-open",{bubbles:!0,composed:!0})))}catch(t){this.handleError(t,"open")}}close(){try{this._isOpen&&(this._isOpen=!1,this.host.show=!1,this.resetPosition(),this.requestUpdate(),this.host&&"function"==typeof this.host.removeEventListeners&&this.host.removeEventListeners(),this.dispatchEvent(new CustomEvent("nr-dropdown-close",{bubbles:!0,composed:!0})))}catch(t){this.handleError(t,"close")}}toggle(){this._isOpen?this.close():this.open()}focusSearchInput(){try{const t=this.host;t&&t.searchable&&setTimeout((()=>{var e;const i=null===(e=t.shadowRoot)||void 0===e?void 0:e.querySelector(".search-input");i&&"function"==typeof i.focus&&i.focus()}),100)}catch(t){console.warn("Failed to focus search input:",t)}}calculatePosition(){var t;try{if(this._dropdownElement&&this._triggerElement||this.findElements(),!this._dropdownElement||!this._triggerElement)return;const e=this._triggerElement.getBoundingClientRect(),i=((null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight)-e.bottom,s=e.top,o=200,r=this.determineOptimalPlacement(o,s,i);this._position={left:0,width:0,placement:r,top:0},this.applyPosition()}catch(t){this.handleError(t,"calculatePosition")}}resetPosition(){try{if(this._dropdownElement){this._dropdownElement.style.removeProperty("position"),this._dropdownElement.style.removeProperty("top"),this._dropdownElement.style.removeProperty("left"),this._dropdownElement.style.removeProperty("width"),this._dropdownElement.style.removeProperty("min-width");this.host.maxHeight||this._dropdownElement.style.removeProperty("max-height"),this._dropdownElement.style.removeProperty("min-height"),this._dropdownElement.style.removeProperty("height"),this._dropdownElement.style.removeProperty("overflow-y"),this._dropdownElement.style.removeProperty("transform"),this._dropdownElement.style.removeProperty("display"),this._dropdownElement.style.removeProperty("opacity"),this._dropdownElement.style.removeProperty("visibility"),this._dropdownElement.style.removeProperty("z-index"),this._dropdownElement.classList.remove("placement-top","placement-bottom")}}catch(t){this.handleError(t,"resetPosition")}}setElements(t,e){this._dropdownElement=t,this._triggerElement=e}findElements(){try{const t=this._host;if(t.optionsElement&&t.wrapper)return this._dropdownElement=t.optionsElement,void(this._triggerElement=t.wrapper);t.shadowRoot&&(this._dropdownElement=t.shadowRoot.querySelector(".options"),this._triggerElement=t.shadowRoot.querySelector(".wrapper"))}catch(t){this.handleError(t,"findElements")}}determineOptimalPlacement(t,e,i){return i>=t?"bottom":e>=t||e>i?"top":"bottom"}applyPosition(){var t;try{if(!this._dropdownElement||!this._triggerElement)return;const e=this.host.maxHeight,{placement:i}=this._position,s=this._triggerElement.getBoundingClientRect(),o=s.width;this._dropdownElement.style.position="absolute",this._dropdownElement.style.left="0",this._dropdownElement.style.right="auto",this._dropdownElement.style.minWidth=`${o}px`,this._dropdownElement.style.removeProperty("width"),this._dropdownElement.style.zIndex="1000",this._dropdownElement.style.height="auto",e||(this._dropdownElement.style.maxHeight="none"),this._dropdownElement.style.minHeight="auto","bottom"===i?(this._dropdownElement.style.top="100%",this._dropdownElement.style.bottom="auto"):(this._dropdownElement.style.top="auto",this._dropdownElement.style.bottom="100%");const r=this._dropdownElement.scrollHeight,n=(null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight;let a;a="bottom"===i?n-s.bottom-10:s.top-10,e?(this._dropdownElement.style.maxHeight=e,this._dropdownElement.style.overflowY="auto"):r>a?(this._dropdownElement.style.maxHeight=`${a}px`,this._dropdownElement.style.overflowY="auto"):(this._dropdownElement.style.maxHeight=`${r}px`,this._dropdownElement.style.overflowY="auto"),this._dropdownElement.classList.remove("placement-top","placement-bottom"),this._dropdownElement.classList.add(`placement-${i}`)}catch(t){this.handleError(t,"applyPosition")}}getAvailableSpace(){var t,e;if(!this._triggerElement)return{above:0,below:0,left:0,right:0};const i=this._triggerElement.getBoundingClientRect(),s=(null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight,o=(null===(e=window.visualViewport)||void 0===e?void 0:e.width)||window.innerWidth;return{above:i.top,below:s-i.bottom,left:i.left,right:o-i.right}}hostConnected(){window.addEventListener("resize",this.handleResize),window.addEventListener("scroll",this.handleScroll,!0)}hostDisconnected(){window.removeEventListener("resize",this.handleResize),window.removeEventListener("scroll",this.handleScroll,!0)}}class $ extends O{constructor(){super(...arguments),this._focusedIndex=-1,this._hasFocus=!1}get focusedIndex(){return this._focusedIndex}getFocusedOption(){if(this._focusedIndex>=0&&this._focusedIndex<this.host.options.length)return this.host.options[this._focusedIndex]}get hasFocus(){return this._hasFocus}setFocusedOption(t){try{t>=0&&t<this.host.options.length&&(this._focusedIndex=t,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-focus-change",{detail:{focusedIndex:t,focusedOption:this.getFocusedOption()},bubbles:!0,composed:!0})))}catch(t){this.handleError(t,"setFocusedOption")}}focus(){var t;try{const e=null===(t=this._host.shadowRoot)||void 0===t?void 0:t.querySelector(".wrapper");e&&(e.focus(),this._hasFocus=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-focus",{bubbles:!0,composed:!0})))}catch(t){this.handleError(t,"focus")}}blur(){var t;try{const e=null===(t=this._host.shadowRoot)||void 0===t?void 0:t.querySelector(".wrapper");e&&e.blur(),this._hasFocus=!1,this._focusedIndex=-1,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-blur",{bubbles:!0,composed:!0}))}catch(t){this.handleError(t,"blur")}}focusNext(){try{const t=this.getNextFocusableIndex(this._focusedIndex);-1!==t&&this.setFocusedOption(t)}catch(t){this.handleError(t,"focusNext")}}focusPrevious(){try{const t=this.getPreviousFocusableIndex(this._focusedIndex);-1!==t&&this.setFocusedOption(t)}catch(t){this.handleError(t,"focusPrevious")}}focusFirst(){try{const t=this.getNextFocusableIndex(-1);-1!==t&&this.setFocusedOption(t)}catch(t){this.handleError(t,"focusFirst")}}focusLast(){try{const t=this.getPreviousFocusableIndex(this.host.options.length);-1!==t&&this.setFocusedOption(t)}catch(t){this.handleError(t,"focusLast")}}clearFocus(){this._focusedIndex=-1,this._hasFocus=!1,this.requestUpdate()}handleFocus(){this._hasFocus=!0,this.requestUpdate()}handleBlur(){this._hasFocus=!1,this._focusedIndex=-1,this.requestUpdate()}getNextFocusableIndex(t){const e=this.host.options;for(let i=t+1;i<e.length;i++)if(!e[i].disabled)return i;for(let i=0;i<=t;i++)if(!e[i].disabled)return i;return-1}getPreviousFocusableIndex(t){const e=this.host.options;for(let i=t-1;i>=0;i--)if(!e[i].disabled)return i;for(let i=e.length-1;i>=t;i--)if(!e[i].disabled)return i;return-1}findOptionIndex(t){return this.host.options.findIndex((e=>e.value===t))}focusOptionByValue(t){const e=this.findOptionIndex(t);-1!==e&&this.setFocusedOption(e)}}!function(t){t.Valid="valid",t.Invalid="invalid",t.Pending="pending",t.Pristine="pristine"}(x||(x={}));class k extends O{constructor(t,e){super(t),this.selectionController=e,this._isValid=!0,this._validationMessage="",this._validationState=x.Pristine}get isValid(){return this._isValid}get validationMessage(){return this._validationMessage}get validationState(){return this._validationState}validate(){try{this._validationState=x.Pending;const t=this.selectionController.getSelectedOptions().length>0;return this.host.required&&!t?(this.setValidationResult(!1,"This field is required",x.Invalid),!1):(this.setValidationResult(!0,"",x.Valid),!0)}catch(t){return this.handleError(t,"validate"),this.setValidationResult(!1,"Validation error occurred",x.Invalid),!1}}reset(){try{this._isValid=!0,this._validationMessage="",this._validationState=x.Pristine,this.requestUpdate(),this.dispatchValidationEvent()}catch(t){this.handleError(t,"reset")}}getFormData(){var t;try{const e=this._host,i=e.name||e.getAttribute("name")||"select",s=this.selectionController.getSelectedOptions();return this.host.multiple?{[i]:s.map((t=>t.value))}:{[i]:(null===(t=s[0])||void 0===t?void 0:t.value)||""}}catch(t){return this.handleError(t,"getFormData"),{}}}checkValidity(){return this.validate()}reportValidity(){var t;const e=this.validate();if(!e){const e=null===(t=this._host.shadowRoot)||void 0===t?void 0:t.querySelector(".wrapper");e&&e.focus()}return e}setCustomValidity(t){try{t?this.setValidationResult(!1,t,x.Invalid):this.validate()}catch(t){this.handleError(t,"setCustomValidity")}}validateOnChange(){this._validationState!==x.Pristine&&this.validate()}validateOnBlur(){this._validationState===x.Pristine&&(this._validationState=x.Pending),this.validate()}setValidationResult(t,e,i){const s=this._isValid!==t||this._validationMessage!==e||this._validationState!==i;this._isValid=t,this._validationMessage=e,this._validationState=i,s&&(this.requestUpdate(),this.dispatchValidationEvent())}dispatchValidationEvent(){const t={isValid:this._isValid,validationMessage:this._validationMessage,validationState:this._validationState};this.dispatchEvent(new CustomEvent("nr-validation",{detail:t,bubbles:!0,composed:!0}))}hostUpdated(){this.validateOnChange()}getValidationClasses(){return{valid:this._isValid&&this._validationState===x.Valid,invalid:!this._isValid&&this._validationState===x.Invalid,pending:this._validationState===x.Pending,pristine:this._validationState===x.Pristine}}getAriaAttributes(){const t={};return this.host.required&&(t["aria-required"]="true"),this._isValid||(t["aria-invalid"]="true",this._validationMessage&&(t["aria-describedby"]="validation-message")),t}}class C extends O{constructor(){super(...arguments),this._searchQuery="",this.handleSearchInput=t=>{this.setSearchQuery(t.detail.value||"")},this.handleSearchClear=()=>{this.clearSearch()},this.handleSearchKeyDown=t=>{if(["ArrowDown","ArrowUp","Enter","Home","End"].includes(t.key)){const e=this.host.keyboardController;e&&e.handleKeyDown(t)}else t.stopPropagation(),"Escape"===t.key&&(this.host.closeDropdown(),this.host.focus())}}get searchQuery(){return this._searchQuery}get hasSearch(){return""!==this._searchQuery.trim()}setSearchQuery(t){this._searchQuery=t,this.host.searchQuery=t,this.host.requestUpdate()}search(t){this.setSearchQuery(t)}clearSearch(){this.setSearchQuery("")}getFilteredOptions(t){if(!this.host.searchable||!this._searchQuery.trim())return t;const e=this._searchQuery.toLowerCase().trim();return t.filter((t=>t.label.toLowerCase().includes(e)||t.value.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e)))}renderSearchInput(){return this.host.searchable?i`
|
|
591
|
+
`;var p,v,y,g,m,b,f,w,x;!function(t){t.Default="default",t.Inline="inline",t.Button="button",t.Slot="slot"}(p||(p={})),function(t){t.Default="default",t.Warning="warning",t.Error="error",t.Success="success"}(v||(v={})),function(t){t.Small="small",t.Medium="medium",t.Large="large"}(y||(y={})),function(t){t.Small="small",t.Medium="medium",t.Large="large"}(g||(g={})),function(t){t.Horizontal="horizontal",t.Vertical="vertical"}(m||(m={})),function(t){t.Default="default",t.Solid="solid",t.Outline="outline",t.Borderless="borderless"}(b||(b={})),function(t){t.Bottom="bottom",t.Top="top",t.Auto="auto"}(f||(f={})),function(t){t.None="none",t.StartsWith="starts-with",t.Contains="contains",t.Fuzzy="fuzzy"}(w||(w={}));class z{constructor(t){this._host=t,this._host.addController(this)}get host(){return this._host}hostConnected(){}hostDisconnected(){}hostUpdate(){}hostUpdated(){}handleError(t,e){console.error(`[SelectController:${this.constructor.name}] Error in ${e}:`,t),this._host.dispatchEvent(new CustomEvent("nr-select-error",{detail:{error:t.message,context:e,controller:this.constructor.name},bubbles:!0,composed:!0}))}requestUpdate(){try{this._host.requestUpdate()}catch(t){this.handleError(t,"requestUpdate")}}dispatchEvent(t){try{return this._host.dispatchEvent(t)}catch(t){return this.handleError(t,"dispatchEvent"),!1}}}class O extends z{constructor(){super(...arguments),this._selectedOptions=[],this._initialized=!1}getSelectedOptions(){return[...this._selectedOptions]}getSelectedOption(){return this._selectedOptions[0]}selectOption(t){try{if(this.isOptionDisabled(t))return;const e=this.host.multiple,i=this.getCurrentValue();e?this.isOptionSelected(t)||(this._selectedOptions=[...this._selectedOptions,t],this.updateHostValue(),this.dispatchChangeEvent(i)):(this.isOptionSelected(t)?this._selectedOptions=[]:this._selectedOptions=[t],this.updateHostValue(),this.dispatchChangeEvent(i)),this.requestUpdate()}catch(t){this.handleError(t,"selectOption")}}unselectOption(t){try{if(this.isOptionSelected(t)){const e=this.getCurrentValue();this._selectedOptions=this._selectedOptions.filter(e=>e.value!==t.value),this.updateHostValue(),this.dispatchChangeEvent(e),this.requestUpdate()}}catch(t){this.handleError(t,"unselectOption")}}clearSelection(){try{if(this._selectedOptions.length>0){const t=this.getCurrentValue();this._selectedOptions=[],this.updateHostValue(),this.dispatchChangeEvent(t),this.requestUpdate()}}catch(t){this.handleError(t,"clearSelection")}}isOptionSelected(t){return this._selectedOptions.some(e=>e.value===t.value)}isOptionDisabled(t){return Boolean(t.disabled)||this.host.disabled}toggleOption(t){this.isOptionSelected(t)?this.unselectOption(t):this.selectOption(t)}initializeFromValue(){try{if(this._initialized)return;const t=this.host.value;if(!t||Array.isArray(t)&&0===t.length)return;const e=Array.isArray(t)?t:[t],i=this.host.options.filter(t=>e.includes(t.value));i.length>0&&(this._selectedOptions=this.host.multiple?i:[i[0]],this.requestUpdate()),this._initialized=!0}catch(t){this.handleError(t,"initializeFromValue")}}updateHostValue(){var t;const e=this.host.multiple?this._selectedOptions.map(t=>t.value):(null===(t=this._selectedOptions[0])||void 0===t?void 0:t.value)||"",i=this.host.value;let s=!1;if(this.host.multiple){const t=Array.isArray(i)?i:[],r=Array.isArray(e)?e:[];s=t.length===r.length&&t.every((t,e)=>t===r[e])}else s=i===e;s||(this.host.value=e)}getCurrentValue(){var t;return this.host.multiple?this._selectedOptions.map(t=>t.value):(null===(t=this._selectedOptions[0])||void 0===t?void 0:t.value)||""}dispatchChangeEvent(t){const e={value:this.getCurrentValue(),selectedOptions:this.getSelectedOptions(),previousValue:t};this.dispatchEvent(new CustomEvent("nr-change",{detail:e,bubbles:!0,composed:!0}))}hostUpdated(){this.syncWithHostOptions()}syncWithHostOptions(){try{this._selectedOptions=this._selectedOptions.filter(t=>this.host.options.some(e=>e.value===t.value)),this._selectedOptions=this._selectedOptions.map(t=>this.host.options.find(e=>e.value===t.value)||t),this.updateHostValue()}catch(t){this.handleError(t,"syncWithHostOptions")}}}class E extends z{constructor(t,e,i){super(t),this.selectionController=e,this.dropdownController=i,this._focusedIndex=-1,this._hasKeyboardNavigated=!1}handleKeyDown(t){try{const e=this.isSearchInputFocused();switch(t.key){case"ArrowDown":t.preventDefault(),this.dropdownController.isOpen?this.navigateNext():this.openDropdown();break;case"ArrowUp":t.preventDefault(),this.dropdownController.isOpen?this.navigatePrevious():this.openDropdown();break;case"Enter":this.dropdownController.isOpen?e&&this._focusedIndex>=0?(t.preventDefault(),this.selectFocused()):e||(t.preventDefault(),this.selectFocused()):(t.preventDefault(),this.openDropdown());break;case" ":e||(t.preventDefault(),this.dropdownController.isOpen?this.selectFocused():this.openDropdown());break;case"Escape":t.preventDefault(),this.closeDropdown();break;case"Tab":this.closeDropdown();break;case"Home":this.dropdownController.isOpen&&(t.preventDefault(),this.setFocusedIndex(0));break;case"End":this.dropdownController.isOpen&&(t.preventDefault(),this.setFocusedIndex(this.host.options.length-1));break;default:1===t.key.length&&/[a-zA-Z0-9]/.test(t.key)&&this.handleAlphanumericKey(t.key.toLowerCase())}}catch(t){this.handleError(t,"handleKeyDown")}}navigateNext(){try{const t=this.getNavigableOptions();if(0===t.length)return;if(this.isSearchInputFocused()&&(this._focusedIndex<0||!this._hasKeyboardNavigated))return this._hasKeyboardNavigated=!0,void this.setFocusedIndex(0);let e=this._focusedIndex+1;e>=t.length&&(e=0),this.setFocusedIndex(e)}catch(t){this.handleError(t,"navigateNext")}}navigatePrevious(){try{const t=this.getNavigableOptions();if(0===t.length)return;if(this.isSearchInputFocused()&&(this._focusedIndex<0||!this._hasKeyboardNavigated))return this._hasKeyboardNavigated=!0,void this.setFocusedIndex(t.length-1);let e=this._focusedIndex-1;e<0&&(e=t.length-1),this.setFocusedIndex(e)}catch(t){this.handleError(t,"navigatePrevious")}}selectFocused(){try{const t=this.getNavigableOptions()[this._focusedIndex];t&&!this.selectionController.isOptionDisabled(t)&&(this.selectionController.selectOption(t),this.host.multiple||this.closeDropdown())}catch(t){this.handleError(t,"selectFocused")}}openDropdown(){try{this.dropdownController.open(),this._hasKeyboardNavigated=!1,this._focusedIndex=-1}catch(t){this.handleError(t,"openDropdown")}}closeDropdown(){try{this.dropdownController.close(),this._focusedIndex=-1,this._hasKeyboardNavigated=!1}catch(t){this.handleError(t,"closeDropdown")}}setFocusedIndex(t){try{const e=this.getNavigableOptions();t>=0&&t<e.length&&(this._focusedIndex=t,this.dispatchFocusEvent(e[t],t),this.requestUpdate(),this.scrollToFocusedOption(t))}catch(t){this.handleError(t,"setFocusedIndex")}}scrollToFocusedOption(t){var e;try{const i=null===(e=this.host.shadowRoot)||void 0===e?void 0:e.querySelector(".options");if(!i)return;setTimeout(()=>{const e=i.querySelector(".option.focused");if(e)e.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});else{const e=40,s=i.clientHeight,r=i.scrollTop,o=t*e,a=o+e,n=r+s;o<r?i.scrollTo({top:o,behavior:"smooth"}):a>n&&i.scrollTo({top:a-s,behavior:"smooth"})}},10)}catch(t){console.warn("Failed to scroll to focused option:",t)}}get focusedIndex(){return this._focusedIndex}get focusedOption(){return this.getNavigableOptions()[this._focusedIndex]}handleAlphanumericKey(t){try{const e=this.getNavigableOptions(),i=this._focusedIndex+1;for(let s=0;s<e.length;s++){const r=(i+s)%e.length;if(e[r].label.toLowerCase().startsWith(t)){this.setFocusedIndex(r),this.dropdownController.isOpen||this.openDropdown();break}}}catch(t){this.handleError(t,"handleAlphanumericKey")}}getNavigableOptions(){const t=this.host;if(!t.options||!Array.isArray(t.options))return[];let e=t.options;return t.searchable&&t.searchQuery&&"function"==typeof t.getFilteredOptions&&(e=t.getFilteredOptions()),e.filter(t=>!t.disabled)}dispatchFocusEvent(t,e){const i={focusedOption:t,focusedIndex:e};this.dispatchEvent(new CustomEvent("nr-select-focus",{detail:i,bubbles:!0,composed:!0}))}isSearchInputFocused(){var t;try{const e=this.host;if(!e.searchable)return!1;const i=null===(t=e.shadowRoot)||void 0===t?void 0:t.querySelector(".search-input");return!!i&&(document.activeElement===i||i.shadowRoot&&i.shadowRoot.querySelector("input")===i.shadowRoot.activeElement||i.contains(document.activeElement))}catch(t){return!1}}hostUpdated(){this.dropdownController.isOpen||-1===this._focusedIndex||(this._focusedIndex=-1)}}class S extends z{constructor(){super(...arguments),this._isOpen=!1,this._position={top:0,left:0,width:0,placement:"bottom"},this._dropdownElement=null,this._triggerElement=null,this.handleResize=()=>{this._isOpen&&this.calculatePosition()},this.handleScroll=()=>{var t;if(this._isOpen&&this._triggerElement){const e=this._triggerElement.getBoundingClientRect(),i=(null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight;(e.bottom<0||e.top>i)&&this.close()}}}get isOpen(){return this._isOpen}get position(){return Object.assign({},this._position)}open(){try{this._isOpen||(this._isOpen=!0,this.host.show=!0,this.requestUpdate(),this.findElements(),setTimeout(()=>{this.calculatePosition()},10),this.host&&"function"==typeof this.host.setupEventListeners&&setTimeout(()=>{this.host.setupEventListeners()},50),this.focusSearchInput(),this.dispatchEvent(new CustomEvent("nr-dropdown-open",{bubbles:!0,composed:!0})))}catch(t){this.handleError(t,"open")}}close(){try{this._isOpen&&(this._isOpen=!1,this.host.show=!1,this.resetPosition(),this.requestUpdate(),this.host&&"function"==typeof this.host.removeEventListeners&&this.host.removeEventListeners(),this.dispatchEvent(new CustomEvent("nr-dropdown-close",{bubbles:!0,composed:!0})))}catch(t){this.handleError(t,"close")}}toggle(){this._isOpen?this.close():this.open()}focusSearchInput(){try{const t=this.host;t&&t.searchable&&setTimeout(()=>{var e;const i=null===(e=t.shadowRoot)||void 0===e?void 0:e.querySelector(".search-input");i&&"function"==typeof i.focus&&i.focus()},100)}catch(t){console.warn("Failed to focus search input:",t)}}calculatePosition(){var t;try{if(this._dropdownElement&&this._triggerElement||this.findElements(),!this._dropdownElement||!this._triggerElement)return;const e=this._triggerElement.getBoundingClientRect(),i=((null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight)-e.bottom,s=e.top,r=200,o=this.determineOptimalPlacement(r,s,i);this._position={left:0,width:0,placement:o,top:0},this.applyPosition()}catch(t){this.handleError(t,"calculatePosition")}}resetPosition(){try{if(this._dropdownElement){this._dropdownElement.style.removeProperty("position"),this._dropdownElement.style.removeProperty("top"),this._dropdownElement.style.removeProperty("left"),this._dropdownElement.style.removeProperty("width"),this._dropdownElement.style.removeProperty("min-width");this.host.maxHeight||this._dropdownElement.style.removeProperty("max-height"),this._dropdownElement.style.removeProperty("min-height"),this._dropdownElement.style.removeProperty("height"),this._dropdownElement.style.removeProperty("overflow-y"),this._dropdownElement.style.removeProperty("transform"),this._dropdownElement.style.removeProperty("display"),this._dropdownElement.style.removeProperty("opacity"),this._dropdownElement.style.removeProperty("visibility"),this._dropdownElement.style.removeProperty("z-index"),this._dropdownElement.classList.remove("placement-top","placement-bottom")}}catch(t){this.handleError(t,"resetPosition")}}setElements(t,e){this._dropdownElement=t,this._triggerElement=e}findElements(){try{const t=this._host;if(t.optionsElement&&t.wrapper)return this._dropdownElement=t.optionsElement,void(this._triggerElement=t.wrapper);t.shadowRoot&&(this._dropdownElement=t.shadowRoot.querySelector(".options"),this._triggerElement=t.shadowRoot.querySelector(".wrapper"))}catch(t){this.handleError(t,"findElements")}}determineOptimalPlacement(t,e,i){return i>=t?"bottom":e>=t||e>i?"top":"bottom"}applyPosition(){var t,e;try{if(!this._dropdownElement||!this._triggerElement)return;const i=this.host.maxHeight,s=null===(t=getComputedStyle(this._dropdownElement).getPropertyValue("--nuraly-select-local-dropdown-max-height"))||void 0===t?void 0:t.trim(),r="auto"===s||!i&&"auto"===s,{placement:o}=this._position,a=this._triggerElement.getBoundingClientRect(),n=a.width;this._dropdownElement.style.position="absolute",this._dropdownElement.style.left="0",this._dropdownElement.style.right="auto",this._dropdownElement.style.minWidth=`${n}px`,this._dropdownElement.style.removeProperty("width"),this._dropdownElement.style.zIndex="1000",this._dropdownElement.style.height="auto",i||r||(this._dropdownElement.style.maxHeight="none"),this._dropdownElement.style.minHeight="auto","bottom"===o?(this._dropdownElement.style.top="100%",this._dropdownElement.style.bottom="auto"):(this._dropdownElement.style.top="auto",this._dropdownElement.style.bottom="100%");const l=this._dropdownElement.scrollHeight,c=(null===(e=window.visualViewport)||void 0===e?void 0:e.height)||window.innerHeight;let h;h="bottom"===o?c-a.bottom-10:a.top-10,i?(this._dropdownElement.style.maxHeight=i,this._dropdownElement.style.overflowY="auto"):r?(this._dropdownElement.style.removeProperty("max-height"),this._dropdownElement.style.overflowY="visible"):l>h?(this._dropdownElement.style.maxHeight=`${h}px`,this._dropdownElement.style.overflowY="auto"):(this._dropdownElement.style.maxHeight=`${l}px`,this._dropdownElement.style.overflowY="auto"),this._dropdownElement.classList.remove("placement-top","placement-bottom"),this._dropdownElement.classList.add(`placement-${o}`)}catch(t){this.handleError(t,"applyPosition")}}getAvailableSpace(){var t,e;if(!this._triggerElement)return{above:0,below:0,left:0,right:0};const i=this._triggerElement.getBoundingClientRect(),s=(null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight,r=(null===(e=window.visualViewport)||void 0===e?void 0:e.width)||window.innerWidth;return{above:i.top,below:s-i.bottom,left:i.left,right:r-i.right}}hostConnected(){window.addEventListener("resize",this.handleResize),window.addEventListener("scroll",this.handleScroll,!0)}hostDisconnected(){window.removeEventListener("resize",this.handleResize),window.removeEventListener("scroll",this.handleScroll,!0)}}class k extends z{constructor(){super(...arguments),this._focusedIndex=-1,this._hasFocus=!1}get focusedIndex(){return this._focusedIndex}getFocusedOption(){if(this._focusedIndex>=0&&this._focusedIndex<this.host.options.length)return this.host.options[this._focusedIndex]}get hasFocus(){return this._hasFocus}setFocusedOption(t){try{t>=0&&t<this.host.options.length&&(this._focusedIndex=t,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-focus-change",{detail:{focusedIndex:t,focusedOption:this.getFocusedOption()},bubbles:!0,composed:!0})))}catch(t){this.handleError(t,"setFocusedOption")}}focus(){var t;try{const e=null===(t=this._host.shadowRoot)||void 0===t?void 0:t.querySelector(".wrapper");e&&(e.focus(),this._hasFocus=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-focus",{bubbles:!0,composed:!0})))}catch(t){this.handleError(t,"focus")}}blur(){var t;try{const e=null===(t=this._host.shadowRoot)||void 0===t?void 0:t.querySelector(".wrapper");e&&e.blur(),this._hasFocus=!1,this._focusedIndex=-1,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-blur",{bubbles:!0,composed:!0}))}catch(t){this.handleError(t,"blur")}}focusNext(){try{const t=this.getNextFocusableIndex(this._focusedIndex);-1!==t&&this.setFocusedOption(t)}catch(t){this.handleError(t,"focusNext")}}focusPrevious(){try{const t=this.getPreviousFocusableIndex(this._focusedIndex);-1!==t&&this.setFocusedOption(t)}catch(t){this.handleError(t,"focusPrevious")}}focusFirst(){try{const t=this.getNextFocusableIndex(-1);-1!==t&&this.setFocusedOption(t)}catch(t){this.handleError(t,"focusFirst")}}focusLast(){try{const t=this.getPreviousFocusableIndex(this.host.options.length);-1!==t&&this.setFocusedOption(t)}catch(t){this.handleError(t,"focusLast")}}clearFocus(){this._focusedIndex=-1,this._hasFocus=!1,this.requestUpdate()}handleFocus(){this._hasFocus=!0,this.requestUpdate()}handleBlur(){this._hasFocus=!1,this._focusedIndex=-1,this.requestUpdate()}getNextFocusableIndex(t){const e=this.host.options;for(let i=t+1;i<e.length;i++)if(!e[i].disabled)return i;for(let i=0;i<=t;i++)if(!e[i].disabled)return i;return-1}getPreviousFocusableIndex(t){const e=this.host.options;for(let i=t-1;i>=0;i--)if(!e[i].disabled)return i;for(let i=e.length-1;i>=t;i--)if(!e[i].disabled)return i;return-1}findOptionIndex(t){return this.host.options.findIndex(e=>e.value===t)}focusOptionByValue(t){const e=this.findOptionIndex(t);-1!==e&&this.setFocusedOption(e)}}!function(t){t.Valid="valid",t.Invalid="invalid",t.Pending="pending",t.Pristine="pristine"}(x||(x={}));class $ extends z{constructor(t,e){super(t),this.selectionController=e,this._isValid=!0,this._validationMessage="",this._validationState=x.Pristine}get isValid(){return this._isValid}get validationMessage(){return this._validationMessage}get validationState(){return this._validationState}validate(){try{this._validationState=x.Pending;const t=this.selectionController.getSelectedOptions().length>0;return this.host.required&&!t?(this.setValidationResult(!1,"This field is required",x.Invalid),!1):(this.setValidationResult(!0,"",x.Valid),!0)}catch(t){return this.handleError(t,"validate"),this.setValidationResult(!1,"Validation error occurred",x.Invalid),!1}}reset(){try{this._isValid=!0,this._validationMessage="",this._validationState=x.Pristine,this.requestUpdate(),this.dispatchValidationEvent()}catch(t){this.handleError(t,"reset")}}getFormData(){var t;try{const e=this._host,i=e.name||e.getAttribute("name")||"select",s=this.selectionController.getSelectedOptions();return this.host.multiple?{[i]:s.map(t=>t.value)}:{[i]:(null===(t=s[0])||void 0===t?void 0:t.value)||""}}catch(t){return this.handleError(t,"getFormData"),{}}}checkValidity(){return this.validate()}reportValidity(){var t;const e=this.validate();if(!e){const e=null===(t=this._host.shadowRoot)||void 0===t?void 0:t.querySelector(".wrapper");e&&e.focus()}return e}setCustomValidity(t){try{t?this.setValidationResult(!1,t,x.Invalid):this.validate()}catch(t){this.handleError(t,"setCustomValidity")}}validateOnChange(){this._validationState!==x.Pristine&&this.validate()}validateOnBlur(){this._validationState===x.Pristine&&(this._validationState=x.Pending),this.validate()}setValidationResult(t,e,i){const s=this._isValid!==t||this._validationMessage!==e||this._validationState!==i;this._isValid=t,this._validationMessage=e,this._validationState=i,s&&(this.requestUpdate(),this.dispatchValidationEvent())}dispatchValidationEvent(){const t={isValid:this._isValid,validationMessage:this._validationMessage,validationState:this._validationState};this.dispatchEvent(new CustomEvent("nr-validation",{detail:t,bubbles:!0,composed:!0}))}hostUpdated(){this.validateOnChange()}getValidationClasses(){return{valid:this._isValid&&this._validationState===x.Valid,invalid:!this._isValid&&this._validationState===x.Invalid,pending:this._validationState===x.Pending,pristine:this._validationState===x.Pristine}}getAriaAttributes(){const t={};return this.host.required&&(t["aria-required"]="true"),this._isValid||(t["aria-invalid"]="true",this._validationMessage&&(t["aria-describedby"]="validation-message")),t}}class C extends z{constructor(){super(...arguments),this._searchQuery="",this.handleSearchInput=t=>{this.setSearchQuery(t.detail.value||"")},this.handleSearchClear=()=>{this.clearSearch()},this.handleSearchKeyDown=t=>{if(["ArrowDown","ArrowUp","Enter","Home","End"].includes(t.key)){const e=this.host.keyboardController;return void(e&&e.handleKeyDown(t))}t.stopPropagation(),"Escape"===t.key&&(this.host.closeDropdown(),this.host.focus())}}get searchQuery(){return this._searchQuery}get hasSearch(){return""!==this._searchQuery.trim()}setSearchQuery(t){this._searchQuery=t,this.host.searchQuery=t,this.host.requestUpdate()}search(t){this.setSearchQuery(t)}clearSearch(){this.setSearchQuery("")}getFilteredOptions(t){if(!this.host.searchable||!this._searchQuery.trim())return t;const e=this._searchQuery.toLowerCase().trim();return t.filter(t=>t.label.toLowerCase().includes(e)||t.value.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e))}renderSearchInput(){return this.host.searchable?i`
|
|
523
592
|
<div class="search-container">
|
|
524
593
|
<nr-input
|
|
525
594
|
type="text"
|
|
@@ -551,12 +620,12 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
551
620
|
<span class="no-options-text">No results found for "${this._searchQuery}"</span>
|
|
552
621
|
</div>
|
|
553
622
|
</div>
|
|
554
|
-
`}hasNoResults(t){return this.host.searchable&&""!==this._searchQuery.trim()&&0===this.getFilteredOptions(t).length}getCurrentQuery(){return this.host.searchQuery||this._searchQuery}hostUpdated(){super.hostUpdated(),this.host.searchQuery!==this._searchQuery&&(this._searchQuery=this.host.searchQuery)}hostConnected(){super.hostConnected(),this._searchQuery=""}}class A extends
|
|
623
|
+
`}hasNoResults(t){return this.host.searchable&&""!==this._searchQuery.trim()&&0===this.getFilteredOptions(t).length}getCurrentQuery(){return this.host.searchQuery||this._searchQuery}hostUpdated(){super.hostUpdated(),this.host.searchQuery!==this._searchQuery&&(this._searchQuery=this.host.searchQuery)}hostConnected(){super.hostConnected(),this._searchQuery=""}}class A extends z{constructor(){super(...arguments),this.handleTriggerClick=t=>{this.host.disabled||(t.preventDefault(),t.stopPropagation(),this.host.toggleDropdown())},this.handleOptionClick=(t,e)=>{t.stopPropagation(),e.disabled||(this.host.multiple?this.host.toggleOption(e):(this.host.selectOption(e),this.host.closeDropdown()))},this.handleTagRemove=(t,e)=>{t.stopPropagation(),this.host.unselectOption(e)},this.handleClearAll=t=>{t.stopPropagation(),this.host.clearSelection()},this.handleKeyDown=t=>{const e=this.host.keyboardController;e&&e.handleKeyDown(t)},this.handleFocus=()=>{const t=this.host.focusController;t&&t.handleFocus()},this.handleBlur=()=>{const t=this.host.focusController;t&&t.handleBlur()},this.handleWindowClick=t=>{const e=t.target;this.host.contains(e)||this.host.closeDropdown()}}setupEventListeners(){window.addEventListener("click",this.handleWindowClick)}removeEventListeners(){window.removeEventListener("click",this.handleWindowClick)}hostDisconnected(){super.hostDisconnected(),this.removeEventListeners()}}
|
|
555
624
|
/**
|
|
556
625
|
* @license
|
|
557
626
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
558
627
|
* SPDX-License-Identifier: MIT
|
|
559
|
-
*/var I=function(t,e,i,s){for(var o
|
|
628
|
+
*/var I=function(t,e,i,s){for(var r,o=arguments.length,a=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s,n=t.length-1;n>=0;n--)(r=t[n])&&(a=(o<3?r(a):o>3?r(e,i,a):r(e,i))||a);return o>3&&a&&Object.defineProperty(e,i,a),a};let D=class extends(d(s)){constructor(){super(...arguments),this.requiredComponents=["nr-input","nr-icon"],this.options=[],this.placeholder="Select an option",this.disabled=!1,this.type=p.Default,this.multiple=!1,this.show=!1,this.status=v.Default,this.size=y.Medium,this.required=!1,this.name="",this.value="",this.noOptionsMessage="No options available",this.noOptionsIcon="info",this.searchable=!1,this.clearable=!1,this.searchPlaceholder="Search options...",this.searchQuery="",this.useCustomSelectedDisplay=!1,this.maxHeight="",this.block=!1,this.selectionController=new O(this),this.dropdownController=new S(this),this.keyboardController=new E(this,this.selectionController,this.dropdownController),this.focusController=new k(this),this.validationController=new $(this,this.selectionController),this.searchController=new C(this),this.eventController=new A(this),this.handleTriggerClick=t=>{this.eventController.handleTriggerClick(t)},this.handleOptionClick=(t,e)=>{this.eventController.handleOptionClick(t,e)},this.handleTagRemove=(t,e)=>{this.eventController.handleTagRemove(t,e)},this.handleClearAll=t=>{this.eventController.handleClearAll(t)},this.handleKeyDown=t=>{this.eventController.handleKeyDown(t)},this.handleFocus=()=>{this.eventController.handleFocus()},this.handleBlur=()=>{this.eventController.handleBlur()}}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}willUpdate(t){super.willUpdate(t),(t.has("options")||t.has("value"))&&this.options.length>0&&this.value&&(Array.isArray(this.value)?this.value.length>0:""!==this.value)&&(this.selectionController._initialized=!1,this.selectionController.initializeFromValue())}firstUpdated(t){super.firstUpdated(t),this.optionsElement&&this.wrapper?this.dropdownController.setElements(this.optionsElement,this.wrapper):setTimeout(()=>{this.optionsElement&&this.wrapper&&this.dropdownController.setElements(this.optionsElement,this.wrapper)},100),this.value&&(Array.isArray(this.value)?this.value.length>0:""!==this.value)&&this.selectionController.initializeFromValue()}get selectedOptions(){return this.selectionController.getSelectedOptions()}get selectedOption(){return this.selectionController.getSelectedOption()}selectOption(t){this.selectionController.selectOption(t)}unselectOption(t){this.selectionController.unselectOption(t)}toggleOption(t){this.selectionController.toggleOption(t)}clearSelection(){this.selectionController.clearSelection()}isOptionSelected(t){return this.selectionController.isOptionSelected(t)}toggleDropdown(){this.dropdownController.toggle()}openDropdown(){this.dropdownController.open()}closeDropdown(){this.dropdownController.close()}focus(){this.focusController.focus()}blur(){this.focusController.blur()}validate(){return this.validationController.validate()}checkValidity(){return this.validationController.checkValidity()}reportValidity(){return this.validationController.reportValidity()}setCustomValidity(t){this.validationController.setCustomValidity(t)}searchOptions(t){this.searchController.search(t)}clearSearch(){this.searchController.clearSearch()}getSearchFilteredOptions(){return this.searchController.getFilteredOptions(this.options)}getCurrentSearchQuery(){return this.searchController.searchQuery}getSelectedOptions(){return this.selectedOptions}setupGlobalEventListeners(){this.eventController.setupEventListeners()}removeGlobalEventListeners(){this.eventController.removeEventListeners()}getFilteredOptions(){return this.searchController.getFilteredOptions(this.options)}setupEventListeners(){this.eventController.setupEventListeners()}removeEventListeners(){this.eventController.removeEventListeners()}render(){return i`${l(this.type,[[p.Default,()=>this.renderDefault()],[p.Inline,()=>this.renderInline()],[p.Button,()=>this.renderButton()],[p.Slot,()=>this.renderSlot()]])}`}renderDefault(){const t=this.selectedOptions,s=this.validationController.getValidationClasses();return i`
|
|
560
629
|
<slot name="label"></slot>
|
|
561
630
|
<div
|
|
562
631
|
class="${c(Object.assign({wrapper:!0},s))}"
|
|
@@ -581,7 +650,7 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
581
650
|
${this.renderStatusIcon()}
|
|
582
651
|
${this.renderClearButton(t)}
|
|
583
652
|
<nr-icon
|
|
584
|
-
name="
|
|
653
|
+
name="chevron-down"
|
|
585
654
|
size="${this.size}"
|
|
586
655
|
class="arrow-icon"
|
|
587
656
|
aria-hidden="true"
|
|
@@ -614,7 +683,7 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
614
683
|
@keydown=${this.handleKeyDown}
|
|
615
684
|
>
|
|
616
685
|
${t.length>0?t[0].label:this.placeholder}
|
|
617
|
-
<nr-icon name="
|
|
686
|
+
<nr-icon name="chevron-down" class="arrow-icon"></nr-icon>
|
|
618
687
|
</button>
|
|
619
688
|
|
|
620
689
|
<div
|
|
@@ -635,20 +704,20 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
635
704
|
${this.searchable?this.renderSearchInput():e}
|
|
636
705
|
${this.renderSelectOptions()}
|
|
637
706
|
</div>
|
|
638
|
-
`}renderSelectedContent(t){return 0===t.length?i`<span class="placeholder" aria-hidden="true">${this.placeholder}</span>`:this.multiple?this.useCustomSelectedDisplay?i`<slot name="selected-display" .selectedOptions=${t}></slot>`:
|
|
707
|
+
`}renderSelectedContent(t){return 0===t.length?i`<span class="placeholder" aria-hidden="true">${this.placeholder}</span>`:this.multiple?this.useCustomSelectedDisplay?i`<slot name="selected-display" .selectedOptions=${t}></slot>`:n(t,t=>i`
|
|
639
708
|
<span class="tag">
|
|
640
709
|
<span class="tag-label">${t.label}</span>
|
|
641
710
|
<nr-icon
|
|
642
|
-
name="
|
|
711
|
+
name="x"
|
|
643
712
|
size="${this.size}"
|
|
644
713
|
class="tag-close"
|
|
645
714
|
@click=${e=>this.handleTagRemove(e,t)}
|
|
646
715
|
aria-label="Remove ${t.label}"
|
|
647
716
|
></nr-icon>
|
|
648
717
|
</span>
|
|
649
|
-
`)
|
|
718
|
+
`):i`${t[0].label}`}renderStatusIcon(){switch(this.status){case v.Warning:return i`<nr-icon name="alert-triangle" size="${this.size}" class="status-icon warning"></nr-icon>`;case v.Error:return i`<nr-icon name="alert-circle" size="${this.size}" class="status-icon error"></nr-icon>`;case v.Success:return i`<nr-icon name="circle-check" size="${this.size}" class="status-icon success"></nr-icon>`;default:return e}}renderClearButton(t){return!this.clearable||0===t.length||this.disabled?e:i`
|
|
650
719
|
<nr-icon
|
|
651
|
-
name="
|
|
720
|
+
name="x"
|
|
652
721
|
size="${this.size}"
|
|
653
722
|
class="clear-icon"
|
|
654
723
|
@click=${this.handleClearAll}
|
|
@@ -666,11 +735,11 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
666
735
|
<span class="no-options-text">${this.noOptionsMessage}</span>
|
|
667
736
|
</div>
|
|
668
737
|
</div>
|
|
669
|
-
`;if(this.searchController.hasNoResults(this.options))return this.searchController.renderNoResults();const s=this.keyboardController.focusedOption;return
|
|
738
|
+
`;if(this.searchController.hasNoResults(this.options))return this.searchController.renderNoResults();const s=this.keyboardController.focusedOption;return n(t,t=>{const r=this.isOptionSelected(t),o=s&&s.value===t.value;return i`
|
|
670
739
|
<div
|
|
671
|
-
class="${c({option:!0,selected:
|
|
740
|
+
class="${c({option:!0,selected:r,focused:o,disabled:Boolean(t.disabled)})}"
|
|
672
741
|
role="option"
|
|
673
|
-
aria-selected="${
|
|
742
|
+
aria-selected="${r}"
|
|
674
743
|
aria-disabled="${Boolean(t.disabled)}"
|
|
675
744
|
data-value="${t.value}"
|
|
676
745
|
@click=${e=>this.handleOptionClick(e,t)}
|
|
@@ -685,23 +754,23 @@ import{css as t,nothing as e,html as i,LitElement as s}from"lit";import{property
|
|
|
685
754
|
</div>
|
|
686
755
|
</div>
|
|
687
756
|
|
|
688
|
-
${
|
|
757
|
+
${r?i`<nr-icon name="check" size="${this.size}" class="check-icon" aria-hidden="true"></nr-icon>`:e}
|
|
689
758
|
|
|
690
759
|
${t.state&&t.message?i`
|
|
691
760
|
<div class="option-message ${t.state}">
|
|
692
|
-
<nr-icon name="${"error"===t.state?"
|
|
761
|
+
<nr-icon name="${"error"===t.state?"alert-circle":"alert-triangle"}" size="${this.size}"></nr-icon>
|
|
693
762
|
<span>${t.message}</span>
|
|
694
763
|
</div>
|
|
695
764
|
`:e}
|
|
696
765
|
</div>
|
|
697
|
-
`})
|
|
766
|
+
`})}renderSearchInput(){return this.searchController.renderSearchInput()}renderValidationMessage(){const t=this.validationController.validationMessage;return t?i`
|
|
698
767
|
<div class="validation-message ${this.status}" id="validation-message">
|
|
699
768
|
${t}
|
|
700
769
|
</div>
|
|
701
|
-
`:e}};D.styles=u,I([
|
|
770
|
+
`:e}};D.styles=u,I([r({type:Array})],D.prototype,"options",void 0),I([r({type:String})],D.prototype,"placeholder",void 0),I([r({type:Boolean,reflect:!0})],D.prototype,"disabled",void 0),I([r({type:String,reflect:!0})],D.prototype,"type",void 0),I([r({type:Boolean,attribute:"multiple"})],D.prototype,"multiple",void 0),I([r({type:Boolean,reflect:!0})],D.prototype,"show",void 0),I([r({type:String,reflect:!0})],D.prototype,"status",void 0),I([r({type:String,reflect:!0})],D.prototype,"size",void 0),I([r({type:Boolean,reflect:!0})],D.prototype,"required",void 0),I([r({type:String})],D.prototype,"name",void 0),I([r()],D.prototype,"value",void 0),I([r({type:String,attribute:"no-options-message"})],D.prototype,"noOptionsMessage",void 0),I([r({type:String,attribute:"no-options-icon"})],D.prototype,"noOptionsIcon",void 0),I([r({type:Boolean,reflect:!0})],D.prototype,"searchable",void 0),I([r({type:Boolean,reflect:!0})],D.prototype,"clearable",void 0),I([r({type:String,attribute:"search-placeholder"})],D.prototype,"searchPlaceholder",void 0),I([r({type:String})],D.prototype,"searchQuery",void 0),I([r({type:Boolean,attribute:"use-custom-selected-display"})],D.prototype,"useCustomSelectedDisplay",void 0),I([r({type:String,attribute:"max-height"})],D.prototype,"maxHeight",void 0),I([r({type:Boolean,reflect:!0})],D.prototype,"block",void 0),I([o(".options")],D.prototype,"optionsElement",void 0),I([o(".wrapper")],D.prototype,"wrapper",void 0),I([o(".search-input")],D.prototype,"searchInput",void 0),D=I([a("nr-select")],D);
|
|
702
771
|
/**
|
|
703
772
|
* @license
|
|
704
773
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
705
774
|
* SPDX-License-Identifier: MIT
|
|
706
775
|
*/
|
|
707
|
-
const N={CHANGE:"nr-change",FOCUS:"nr-focus",BLUR:"nr-blur",DROPDOWN_OPEN:"nr-dropdown-open",DROPDOWN_CLOSE:"nr-dropdown-close",VALIDATION:"nr-validation",ERROR:"nr-select-error"},T={WRAPPER:"wrapper",SELECT:"select",TRIGGER:"select-trigger",OPTIONS:"options",OPTION:"option",SELECTED:"selected",FOCUSED:"focused",DISABLED:"disabled",TAG:"tag",TAG_LABEL:"tag-label",TAG_CLOSE:"tag-close",ICONS_CONTAINER:"icons-container",ARROW_ICON:"arrow-icon",CLEAR_ICON:"clear-icon",STATUS_ICON:"status-icon",CHECK_ICON:"check-icon",VALIDATION_MESSAGE:"validation-message",PLACEHOLDER:"placeholder",NO_OPTIONS:"no-options",NO_OPTIONS_CONTENT:"no-options-content",NO_OPTIONS_ICON:"no-options-icon",NO_OPTIONS_TEXT:"no-options-text",SEARCH_CONTAINER:"search-container",SEARCH_INPUT:"search-input",SEARCH_ICON:"search-icon",SEARCH_CLEAR:"search-clear"},R={COMBOBOX:"combobox",LISTBOX:"listbox",OPTION:"option",EXPANDED:"aria-expanded",HASPOPUP:"aria-haspopup",MULTISELECTABLE:"aria-multiselectable",SELECTED:"aria-selected",DISABLED:"aria-disabled",REQUIRED:"aria-required",INVALID:"aria-invalid",DESCRIBEDBY:"aria-describedby",LABELLEDBY:"aria-labelledby"},L={PLACEHOLDER:"Select an option",MAX_HEIGHT:"
|
|
776
|
+
const N={CHANGE:"nr-change",FOCUS:"nr-focus",BLUR:"nr-blur",DROPDOWN_OPEN:"nr-dropdown-open",DROPDOWN_CLOSE:"nr-dropdown-close",VALIDATION:"nr-validation",ERROR:"nr-select-error"},T={WRAPPER:"wrapper",SELECT:"select",TRIGGER:"select-trigger",OPTIONS:"options",OPTION:"option",SELECTED:"selected",FOCUSED:"focused",DISABLED:"disabled",TAG:"tag",TAG_LABEL:"tag-label",TAG_CLOSE:"tag-close",ICONS_CONTAINER:"icons-container",ARROW_ICON:"arrow-icon",CLEAR_ICON:"clear-icon",STATUS_ICON:"status-icon",CHECK_ICON:"check-icon",VALIDATION_MESSAGE:"validation-message",PLACEHOLDER:"placeholder",NO_OPTIONS:"no-options",NO_OPTIONS_CONTENT:"no-options-content",NO_OPTIONS_ICON:"no-options-icon",NO_OPTIONS_TEXT:"no-options-text",SEARCH_CONTAINER:"search-container",SEARCH_INPUT:"search-input",SEARCH_ICON:"search-icon",SEARCH_CLEAR:"search-clear"},R={COMBOBOX:"combobox",LISTBOX:"listbox",OPTION:"option",EXPANDED:"aria-expanded",HASPOPUP:"aria-haspopup",MULTISELECTABLE:"aria-multiselectable",SELECTED:"aria-selected",DISABLED:"aria-disabled",REQUIRED:"aria-required",INVALID:"aria-invalid",DESCRIBEDBY:"aria-describedby",LABELLEDBY:"aria-labelledby"},L={PLACEHOLDER:"Select an option",MAX_HEIGHT:"auto",DROPDOWN_OFFSET:4,TAG_MAX_WIDTH:"150px",TRANSITION_DURATION:200,DEBOUNCE_DELAY:300},P={ENTER:"Enter",SPACE:" ",ESCAPE:"Escape",ARROW_DOWN:"ArrowDown",ARROW_UP:"ArrowUp",HOME:"Home",END:"End",TAB:"Tab"},F="",B=", ";export{z as BaseSelectController,f as DropdownPlacement,F as EMPTY_STRING,D as HySelectComponent,B as MULTIPLE_OPTIONS_SEPARATOR,g as OptionSize,R as SELECT_ARIA,T as SELECT_CLASSES,L as SELECT_DEFAULTS,N as SELECT_EVENTS,P as SELECT_KEYS,w as SearchMode,m as SelectDirection,S as SelectDropdownController,A as SelectEventController,k as SelectFocusController,E as SelectKeyboardController,C as SelectSearchController,O as SelectSelectionController,y as SelectSize,v as SelectStatus,p as SelectType,$ as SelectValidationController,b as SelectVariant};
|