noph-ui 0.8.3 → 0.8.5
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/select/Select.svelte +30 -29
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +4 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import Menu from '../menu/Menu.svelte'
|
|
3
3
|
import { isFirstInvalidControlInForm } from '../text-field/report-validity.js'
|
|
4
|
-
import { generateUUIDv4 } from '../utils.js'
|
|
4
|
+
import { generateUUIDv4, isIOS } from '../utils.js'
|
|
5
5
|
import type { SelectProps } from './types.ts'
|
|
6
6
|
import Item from '../list/Item.svelte'
|
|
7
7
|
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
</svg>
|
|
79
79
|
{/snippet}
|
|
80
80
|
|
|
81
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_to_interactive_role -->
|
|
81
82
|
<label
|
|
82
83
|
style={(variant === 'outlined'
|
|
83
84
|
? '--top-space:1rem;--bottom-space:1rem;--floating-label-top:-0.5rem;--floating-label-left:-2.25rem;--_focus-outline-width:3px;'
|
|
@@ -87,6 +88,28 @@
|
|
|
87
88
|
class={['text-field', attributes.class]}
|
|
88
89
|
bind:this={element}
|
|
89
90
|
bind:clientWidth
|
|
91
|
+
role="combobox"
|
|
92
|
+
aria-controls="listbox"
|
|
93
|
+
aria-expanded={menuOpen}
|
|
94
|
+
onclick={(event) => {
|
|
95
|
+
event.preventDefault()
|
|
96
|
+
menuElement?.showPopover()
|
|
97
|
+
menuElement?.focus()
|
|
98
|
+
}}
|
|
99
|
+
onkeydown={(event) => {
|
|
100
|
+
if (event.key === 'Tab') {
|
|
101
|
+
if (isIOS()) {
|
|
102
|
+
event.preventDefault()
|
|
103
|
+
}
|
|
104
|
+
menuElement?.hidePopover()
|
|
105
|
+
} else {
|
|
106
|
+
event.preventDefault()
|
|
107
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === 'Enter') {
|
|
108
|
+
menuElement?.showPopover()
|
|
109
|
+
;(menuElement?.firstElementChild as HTMLElement)?.focus()
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}}
|
|
90
113
|
>
|
|
91
114
|
<div
|
|
92
115
|
class="field"
|
|
@@ -135,31 +158,7 @@
|
|
|
135
158
|
</div>
|
|
136
159
|
{/if}
|
|
137
160
|
<div class="content">
|
|
138
|
-
<select
|
|
139
|
-
aria-label={label}
|
|
140
|
-
{...attributes}
|
|
141
|
-
onclick={(event) => {
|
|
142
|
-
event.preventDefault()
|
|
143
|
-
menuElement?.showPopover()
|
|
144
|
-
}}
|
|
145
|
-
onkeydown={(event) => {
|
|
146
|
-
if (event.key === 'Tab') {
|
|
147
|
-
menuElement?.hidePopover()
|
|
148
|
-
} else {
|
|
149
|
-
event.preventDefault()
|
|
150
|
-
if (
|
|
151
|
-
event.key === 'ArrowDown' ||
|
|
152
|
-
event.key === 'ArrowUp' ||
|
|
153
|
-
event.key === 'Enter'
|
|
154
|
-
) {
|
|
155
|
-
menuElement?.showPopover()
|
|
156
|
-
;(menuElement?.firstElementChild as HTMLElement)?.focus()
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}}
|
|
160
|
-
bind:value
|
|
161
|
-
bind:this={selectElement}
|
|
162
|
-
>
|
|
161
|
+
<select aria-label={label} {...attributes} bind:value bind:this={selectElement}>
|
|
163
162
|
{#each options as option}
|
|
164
163
|
<option value={option.value} selected={option.value === value}
|
|
165
164
|
>{option.label}</option
|
|
@@ -211,7 +210,9 @@
|
|
|
211
210
|
onclick={(event) => {
|
|
212
211
|
value = option.value
|
|
213
212
|
menuElement?.hidePopover()
|
|
214
|
-
|
|
213
|
+
if (!isIOS()) {
|
|
214
|
+
element?.focus()
|
|
215
|
+
}
|
|
215
216
|
event.preventDefault()
|
|
216
217
|
}}
|
|
217
218
|
onkeydown={(event) => {
|
|
@@ -331,8 +332,8 @@
|
|
|
331
332
|
flex: 1;
|
|
332
333
|
flex-direction: column;
|
|
333
334
|
writing-mode: horizontal-tb;
|
|
334
|
-
max-width: 100
|
|
335
|
-
min-width: 210px;
|
|
335
|
+
max-width: var(--np-select-max-width, 100%);
|
|
336
|
+
min-width: var(--np-select-min-width, 210px);
|
|
336
337
|
}
|
|
337
338
|
|
|
338
339
|
.supporting-text {
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED