Skip to content

Commit bbc5f85

Browse files
committed
fix: make selected values reactive #51
1 parent 0ae748b commit bbc5f85

File tree

4 files changed

+39
-52
lines changed

4 files changed

+39
-52
lines changed

ant/src/main.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import App from '@/App.vue'
2-
import { Button, Col, Dropdown, Menu, Row } from 'ant-design-vue'
2+
import Antd from 'ant-design-vue'
33
import 'ant-design-vue/dist/antd.css'
44
import { createApp } from 'vue'
55

66
const app = createApp(App)
7-
app.use(Button)
8-
app.use(Dropdown)
9-
app.use(Menu)
10-
app.use(Row)
11-
app.use(Col)
7+
app.use(Antd)
128

139
app.mount('#app')

core/src/components/select.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ export function useSet<T>(options: SetOptions<T>) {
7171
values,
7272
add,
7373
toggle,
74-
has,
7574
remove,
7675
clear,
7776
updated,
@@ -140,6 +139,18 @@ export function useSelect<T, V>(options: SelectOptions<T, V>) {
140139
}
141140
}
142141

142+
const has = (item: T | null): boolean => {
143+
if (item === null) {
144+
return false
145+
}
146+
const value = getValue(item)
147+
if (Array.isArray(selected.value)) {
148+
return selected.value.includes(value)
149+
} else {
150+
return selected.value === value
151+
}
152+
}
153+
143154
const getValue = (item: any): V => {
144155
if (typeof itemValue == 'function') {
145156
return itemValue(item)
@@ -193,6 +204,7 @@ export function useSelect<T, V>(options: SelectOptions<T, V>) {
193204
setItems,
194205
setValues,
195206
isEmpty,
207+
has,
196208
}
197209
}
198210

docs/package-lock.json

Lines changed: 11 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)