@neatui/vue 2.0.8 → 2.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neatui/vue",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "basic component ui",
5
5
  "main": "./src/index.ts",
6
6
  "license": "MIT",
@@ -3,6 +3,6 @@ import Tree from './Tree.vue';
3
3
  import Calendar from './Calendar.vue';
4
4
  import PhotoEditor from './PhotoEditor.vue';
5
5
  import TreeView from './TreeView.vue';
6
- import ChartView from './ChartView.vue';
6
+ // import ChartView from './ChartView.vue';
7
7
 
8
- export { Image, Tree, Calendar, PhotoEditor, TreeView, ChartView };
8
+ export { Image, Tree, Calendar, PhotoEditor, TreeView };
@@ -0,0 +1,64 @@
1
+ <template>
2
+ <form class="m-sm-sub">
3
+ <label v-for="(item, idx) in state.lists" :key="idx" :ui-form="`${theme} type:checkbox${item.disabled ? ' disabled' : ''}`">
4
+ <input v-model="item.__checked" type="checkbox" :disabled="item.disabled" />
5
+ <slot>
6
+ <span>{{ item.label }}</span>
7
+ </slot>
8
+ </label>
9
+ </form>
10
+ </template>
11
+ <script setup lang="ts">
12
+ import { reactive, watch } from 'vue';
13
+
14
+ // 定义类型
15
+ interface OptionsTypes {
16
+ label: string;
17
+ value: any;
18
+ disabled?: boolean;
19
+ }
20
+ interface Props {
21
+ modelValue: any[];
22
+ options: OptionsTypes[];
23
+ theme?: string;
24
+ }
25
+ // 外部入参
26
+ const props = withDefaults(defineProps<Props>(), {
27
+ theme: '@a',
28
+ modelValue: () => [],
29
+ options: () => []
30
+ });
31
+
32
+ // 定义事件
33
+ const emits = defineEmits(['update:modelValue']);
34
+
35
+ // 内部数据
36
+ const state: any = reactive({
37
+ lists: []
38
+ });
39
+
40
+ // 监听数据
41
+ watch(
42
+ [() => props.options, () => props.modelValue],
43
+ ([options, value]) => {
44
+ const lists = options?.map((item) => ({ ...item, __checked: value?.includes(item.value) }));
45
+ // 只有在内容变化时才更新
46
+ if (JSON.stringify(state.lists) !== JSON.stringify(lists)) {
47
+ state.lists = lists;
48
+ }
49
+ },
50
+ {
51
+ immediate: true
52
+ }
53
+ );
54
+ watch(
55
+ () => state.lists,
56
+ (val) => {
57
+ const value = val.filter((item: any) => item.__checked).map((item: any) => item.value);
58
+ emits('update:modelValue', value);
59
+ },
60
+ {
61
+ deep: true
62
+ }
63
+ );
64
+ </script>
@@ -3,6 +3,7 @@ import InputRange from './InputRange.vue';
3
3
  import Switch from './Switch.vue';
4
4
  import TextArea from './TextArea.vue';
5
5
 
6
+ import Checkbox from './Checkbox.vue';
6
7
  import Select from './Select@v3.vue';
7
8
  import SelectList from './SelectList.vue';
8
9
  import SelectTags from './SelectTags.vue';
@@ -32,6 +33,7 @@ export {
32
33
  InputRange,
33
34
  Switch,
34
35
  TextArea,
36
+ Checkbox,
35
37
  Select,
36
38
  SelectList,
37
39
  SelectTags,