Skip to content

Commit af58af7

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents 70f7df6 + 7f681b6 commit af58af7

File tree

1 file changed

+102
-102
lines changed

1 file changed

+102
-102
lines changed

packages/ui/src/components/forms/Select/NvSelect.vue

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
<template>
22
<NvAutocomplete
3-
:autoScrollIndex="autoScrollIndex"
4-
:options="searchResults"
5-
:valueKey="props.valueKey"
6-
:visible="isAutocompleteVisible"
7-
:width="props.autocompleteWidth"
8-
@select="(item) => !item.children && handleValue(item.value)"
9-
@positioner-change="
3+
:autoScrollIndex="autoScrollIndex"
4+
:options="searchResults"
5+
:valueKey="props.valueKey"
6+
:visible="isAutocompleteVisible"
7+
:width="props.autocompleteWidth"
8+
@select="(item) => !item.children && handleValue(item.value)"
9+
@positioner-change="
1010
($event) => {
1111
autocomplete = $event
1212
}
1313
"
14-
@pointer-down-outside="blurInput"
15-
@focus-outside="blurInput"
16-
@interact-outside="blurInput"
14+
@pointer-down-outside="blurInput"
15+
@focus-outside="blurInput"
16+
@interact-outside="blurInput"
1717
>
1818
<template #reference>
1919
<StSelect
20-
ref="select"
21-
:isFocused="hasFocus"
22-
class="w-full"
23-
v-bind="{ ...props, isFocused: hasFocus }"
24-
@click="activate"
20+
ref="select"
21+
:isFocused="hasFocus"
22+
class="w-full"
23+
v-bind="{ ...props, isFocused: hasFocus }"
24+
@click="activate"
2525
>
2626
<StSelectWrapper class="w-full" v-bind="props">
2727
<NvStack :spacing="2" class="w-full">
2828
<template v-if="props.multiple && selectedOptions.length > 0">
2929
<StSelectTagsWrapper>
3030
<NvGroup :spacing="2" class="w-full">
3131
<template
32-
v-for="option in selectedOptions"
33-
:key="get(option.value, props.valueKey) || option.value"
32+
v-for="option in selectedOptions"
33+
:key="get(option.value, props.valueKey) || option.value"
3434
>
3535
<NvTag
36-
:title="option.label"
37-
closable
38-
@close="handleValue(option.value)"
39-
@mousedown="blurInput()"
40-
@click.stop
36+
:title="option.label"
37+
closable
38+
@close="handleValue(option.value)"
39+
@mousedown="blurInput()"
40+
@click.stop
4141
>
4242
{{ option.label }}
4343
</NvTag>
@@ -47,51 +47,51 @@
4747
</template>
4848
<div ref="inputWrapper" class="inline-flex">
4949
<StSelectInput
50-
ref="selectInput"
51-
:isFocused="hasFocus"
52-
:modelValue="inputValue"
53-
:placeholder="$attrs.placeholder"
54-
v-bind="omit(props, ['modelValue'])"
55-
@focus="activate"
56-
@update:modelValue="search = $event"
50+
ref="selectInput"
51+
:isFocused="hasFocus"
52+
:modelValue="inputValue"
53+
:placeholder="$attrs.placeholder"
54+
v-bind="omit(props, ['modelValue'])"
55+
@focus="activate"
56+
@update:modelValue="search = $event"
5757
/>
5858
</div>
5959
</NvStack>
6060
</StSelectWrapper>
6161
<StSelectIcon v-bind="props">
62-
<NvIcon :size="iconSize" name="direction"/>
62+
<NvIcon :size="iconSize" name="direction" />
6363
</StSelectIcon>
6464
</StSelect>
6565
</template>
6666
<template #default="{ active, item }">
6767
<NvOption
68-
v-if="item"
69-
:active="active"
70-
:disabled="item.disabled"
71-
:readonly="item.children"
72-
:selected="
68+
v-if="item"
69+
:active="active"
70+
:disabled="item.disabled"
71+
:readonly="item.children"
72+
:selected="
7373
selectedValues.find(
7474
(v) =>
7575
(get(item.value, props.valueKey) || item.value) ===
7676
(get(v, props.valueKey) || v),
7777
)
7878
"
79-
:title="item.label"
80-
v-bind="item.attrs || {}"
81-
@mousedown="!item.children && handleValue(item.value)"
79+
:title="item.label"
80+
v-bind="item.attrs || {}"
81+
@mousedown="!item.children && handleValue(item.value)"
8282
>
8383
<div class="w-full text-ellipsis overflow-hidden">
8484
{{ item.label }}
8585
</div>
8686
<template #after="props">
87-
<slot :option="item" name="optionAfter" v-bind="props"/>
87+
<slot :option="item" name="optionAfter" v-bind="props" />
8888
</template>
8989
</NvOption>
9090
</template>
9191
<template #fallback>
9292
<StSelectOption
93-
v-if="searchResults.length === 0"
94-
class="justify-center pointer-events-none"
93+
v-if="searchResults.length === 0"
94+
class="justify-center pointer-events-none"
9595
>
9696
No Data
9797
</StSelectOption>
@@ -141,44 +141,44 @@ const iconSize = computed(() => {
141141
})
142142
143143
const selectedValues = computed(() =>
144-
props.multiple ? (props.modelValue as Value[]) : [props.modelValue],
144+
props.multiple ? (props.modelValue as Value[]) : [props.modelValue],
145145
)
146146
147147
const options = computed(() =>
148-
flatten(
149-
props.options.map((option) => {
150-
if (option.children) {
151-
const mappedChildren = option.children.map((o) => ({
152-
id: get(o.value, props.valueKey) || o.value || uuid(),
153-
...o,
154-
}))
155-
return [
156-
{
157-
id: get(option.value, props.valueKey) || option.value || uuid(),
158-
...option,
159-
children: mappedChildren,
160-
},
161-
...mappedChildren,
162-
]
163-
}
164-
return {
148+
flatten(
149+
props.options.map((option) => {
150+
if (option.children) {
151+
const mappedChildren = option.children.map((o) => ({
152+
id: get(o.value, props.valueKey) || o.value || uuid(),
153+
...o,
154+
}))
155+
return [
156+
{
165157
id: get(option.value, props.valueKey) || option.value || uuid(),
166158
...option,
167-
}
168-
}),
169-
),
159+
children: mappedChildren,
160+
},
161+
...mappedChildren,
162+
]
163+
}
164+
return {
165+
id: get(option.value, props.valueKey) || option.value || uuid(),
166+
...option,
167+
}
168+
}),
169+
),
170170
)
171171
172172
const selectedOptions = computed(() =>
173-
selectedValues.value
174-
.map((value) =>
175-
options.value.find(
176-
(option) =>
177-
get(option.value, props.valueKey, option.value) ===
178-
get(value, props.valueKey, value),
179-
),
180-
)
181-
.filter((option) => option !== undefined),
173+
selectedValues.value
174+
.map((value) =>
175+
options.value.find(
176+
(option) =>
177+
get(option.value, props.valueKey, option.value) ===
178+
get(value, props.valueKey, value),
179+
),
180+
)
181+
.filter((option) => option !== undefined),
182182
)
183183
184184
const search = ref('')
@@ -199,22 +199,22 @@ const { hasFocus, activate, deactivate } = useFocusTrap(inputWrapper, {
199199
const isAutocompleteVisible = ref(false)
200200
201201
watch(
202-
() => hasFocus.value,
203-
(value) => {
204-
if (value) {
205-
isAutocompleteVisible.value = true
206-
}
207-
},
202+
() => hasFocus.value,
203+
(value) => {
204+
if (value) {
205+
isAutocompleteVisible.value = true
206+
}
207+
},
208208
)
209209
210210
const fuseOptions = computed<UseFuseOptions<(typeof options.value)[number]>>(
211-
() => ({
212-
fuseOptions: {
213-
keys: ['label', 'category', 'searchValue'],
214-
threshold: 0.3,
215-
shouldSort: false,
216-
},
217-
}),
211+
() => ({
212+
fuseOptions: {
213+
keys: ['label', 'category', 'searchValue'],
214+
threshold: 0.3,
215+
shouldSort: false,
216+
},
217+
}),
218218
)
219219
const { results } = useFuse(search, options, fuseOptions)
220220
const searchResults = computed(() => {
@@ -223,7 +223,7 @@ const searchResults = computed(() => {
223223
return options.value.filter((option) => {
224224
if ('children' in option) {
225225
return filteredOptions.some((o) =>
226-
(option.children as Option[]).find((c) => c.id === o.id),
226+
(option.children as Option[]).find((c) => c.id === o.id),
227227
)
228228
}
229229
return filteredOptions.some((o) => o.id === option.id)
@@ -232,34 +232,34 @@ const searchResults = computed(() => {
232232
return options.value || []
233233
})
234234
const inputValue = computed(
235-
() =>
236-
(!hasFocus.value && !props.multiple && selectedOptions.value[0]?.label) ||
237-
search.value,
235+
() =>
236+
(!hasFocus.value && !props.multiple && selectedOptions.value[0]?.label) ||
237+
search.value,
238238
)
239239
240240
const autoScrollIndex = computed(() => {
241241
return (
242-
selectedValues.value.length > 0 &&
243-
Math.min(
244-
...selectedValues.value
245-
.map((v) =>
246-
options.value.findIndex(
247-
(o) =>
248-
get(o.value, props.valueKey, o.value) ===
249-
get(v, props.valueKey, v),
250-
),
251-
)
252-
.filter((i) => i !== undefined),
253-
)
242+
selectedValues.value.length > 0 &&
243+
Math.min(
244+
...selectedValues.value
245+
.map((v) =>
246+
options.value.findIndex(
247+
(o) =>
248+
get(o.value, props.valueKey, o.value) ===
249+
get(v, props.valueKey, v),
250+
),
251+
)
252+
.filter((i) => i !== undefined),
253+
)
254254
)
255255
})
256256
257257
const handleValue = (value: Value) => {
258258
if (props.multiple) {
259259
const newValue = [...selectedValues.value]
260260
const index = newValue.findIndex(
261-
(item) =>
262-
get(item, props.valueKey, item) === get(value, props.valueKey, value),
261+
(item) =>
262+
get(item, props.valueKey, item) === get(value, props.valueKey, value),
263263
)
264264
if (index > -1) {
265265
newValue.splice(index, 1)

0 commit comments

Comments
 (0)