edvoyui-component-library-test-flight 0.0.156 → 0.0.157

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,7 +1,7 @@
1
1
  {
2
2
  "name": "edvoyui-component-library-test-flight",
3
3
  "private": false,
4
- "version": "0.0.156",
4
+ "version": "0.0.157",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist/",
@@ -494,8 +494,17 @@ const selectAll = (e: Event) => {
494
494
  };
495
495
 
496
496
  watch(selected, (newValue) => {
497
- emit("update:modelValue", newValue);
498
- if (newValue === null || !newValue) {
497
+ // Emit scalar for single-select, array for multi-select
498
+ if (props.multiple) {
499
+ emit("update:modelValue", newValue);
500
+ } else {
501
+ if (Array.isArray(newValue)) {
502
+ emit("update:modelValue", newValue[0] ?? "");
503
+ } else {
504
+ emit("update:modelValue", newValue as any);
505
+ }
506
+ }
507
+ if (newValue === null || !newValue || (Array.isArray(newValue) && newValue.length === 0)) {
499
508
  emit("deselected", newValue);
500
509
  }
501
510
  });
@@ -512,7 +521,12 @@ const deselected = (newValue: any) => {
512
521
  };
513
522
 
514
523
  watch(modelValue, (newValue: any) => {
515
- selected.value = newValue;
524
+ if (props.multiple) {
525
+ selected.value = Array.isArray(newValue) ? newValue : (newValue ? [newValue] : []);
526
+ } else {
527
+ // keep scalar
528
+ selected.value = Array.isArray(newValue) ? (newValue[0] ?? "") : newValue;
529
+ }
516
530
  });
517
531
 
518
532
  const search = (x: string) => {
@@ -565,12 +579,21 @@ const fuseSearch = (
565
579
  };
566
580
 
567
581
  onMounted(() => {
568
- if (Array.isArray(props.value)) {
569
- selected.value = props.value;
570
- } else if (props.value) {
571
- selected.value = [props.value];
582
+ if (props.multiple) {
583
+ if (Array.isArray(props.value)) {
584
+ selected.value = props.value;
585
+ } else if (props.value) {
586
+ selected.value = [props.value];
587
+ } else {
588
+ selected.value = [];
589
+ }
572
590
  } else {
573
- selected.value = [];
591
+ // single: scalar
592
+ if (Array.isArray(props.value)) {
593
+ selected.value = props.value[0] ?? "";
594
+ } else {
595
+ selected.value = props.value ?? "";
596
+ }
574
597
  }
575
598
  });
576
599
 
@@ -0,0 +1,120 @@
1
+ <template>
2
+ <div class="grid w-full grid-cols-3 gap-10">
3
+ <div>
4
+ <EUISelect
5
+ v-model="businessAreaSel"
6
+ :items="businessArea"
7
+ search-label="name"
8
+ label="Select Label"
9
+ placeholder="Placeholder"
10
+ :multiple="false"
11
+ :inputFilled="false"
12
+ />
13
+ <pre class="text-green-500 text-xxs">{{ businessAreaSel }}</pre>
14
+ </div>
15
+
16
+ <div>
17
+ <EUISelect
18
+ v-model="checkboxData"
19
+ search-label="name"
20
+ placeholder="Placeholder"
21
+ :items="datas"
22
+ :selected-count="true"
23
+ selectedCountLabel="Checkbox"
24
+ :multiple="true"
25
+ :is-checkbox="true"
26
+ />
27
+ <pre class="text-green-500 text-xxs">{{ checkboxData }}</pre>
28
+ </div>
29
+
30
+ <div>
31
+ <EUISelect
32
+ v-model="multipleData"
33
+ search-label="name"
34
+ label="Select Label"
35
+ placeholder="Placeholder"
36
+ :items="datas"
37
+ :multiple="true"
38
+ :multiple-limit="3"
39
+ />
40
+ <pre class="text-green-500 text-xxs">{{ multipleData }}</pre>
41
+ </div>
42
+ <div>
43
+ <EUISelect
44
+ v-model="singleData"
45
+ search-label="name"
46
+ label="Select Label"
47
+ placeholder="Placeholder"
48
+ :items="datas"
49
+ :multiple="false"
50
+ />
51
+ <pre class="text-green-500 text-xxs">{{ singleData }}</pre>
52
+ </div>
53
+ </div>
54
+ </template>
55
+
56
+ <script setup lang="ts">
57
+ import { ref } from "vue";
58
+ import EUISelect from "../select/EUISelect.vue";
59
+
60
+ const businessArea = ref(["All", "B2B", "B2C", "Accelerator"]);
61
+ const businessAreaSel = ref(businessArea.value?.[0]);
62
+
63
+ const checkboxData = ref([]);
64
+ const multipleData = ref([]);
65
+ const singleData = ref({});
66
+ const datas = ref([
67
+ {
68
+ value: "ShawnBurke",
69
+ name: "Shawn Burke",
70
+ age: 6,
71
+ },
72
+ {
73
+ value: "EmeryNolan",
74
+ name: "Emery Nolan",
75
+ age: 4,
76
+ },
77
+ {
78
+ value: "EmbryGrant",
79
+ name: "Embry Grant",
80
+ age: 3,
81
+ },
82
+ {
83
+ value: "JesseAustin",
84
+ name: "Jesse Austin",
85
+ age: 9,
86
+ },
87
+ {
88
+ value: "TandyChristensen",
89
+ name: "Tandy Christensen",
90
+ age: 7,
91
+ },
92
+ {
93
+ value: "ShawnBurkeNew",
94
+ name: "Shawn Burke New",
95
+ age: 6,
96
+ },
97
+ {
98
+ value: "EmeryNolanNew",
99
+ name: "Emery Nolan New",
100
+ age: 4,
101
+ },
102
+ {
103
+ value: "EmbryGrantNew",
104
+ name: "Embry Grant New",
105
+ age: 3,
106
+ },
107
+ {
108
+ value: "JesseAustinNew",
109
+ name: "Jesse Austin New",
110
+ age: 9,
111
+ },
112
+ {
113
+ value: "TandyChristensenNew",
114
+ name: "Tandy Christensen New",
115
+ age: 7,
116
+ },
117
+ ]);
118
+ </script>
119
+
120
+ <style scoped></style>