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

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.158",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist/",
@@ -78,7 +78,9 @@
78
78
  @update:model-value="handleDate"
79
79
  />
80
80
  </div>
81
- <EUIErrorMessage :errors="errors" :name="name" />
81
+ <template v-if="errors && errors.length">
82
+ <EUIErrorMessage :errors="errors" :name="name" class="mt-2" />
83
+ </template>
82
84
  </div>
83
85
  </template>
84
86
 
@@ -87,6 +89,7 @@ import { computed, ref, toRefs, watch } from 'vue'
87
89
  import type { PropType } from 'vue'
88
90
  import VueDatePicker from '@vuepic/vue-datepicker'
89
91
  import '@vuepic/vue-datepicker/dist/main.css'
92
+ import EUIErrorMessage from '../errorMessage/EUIErrorMessage.vue';
90
93
 
91
94
  const props = defineProps({
92
95
  modelValue: {
@@ -190,9 +190,10 @@
190
190
  </div>
191
191
  </template>
192
192
  </Popper>
193
- <div v-if="errors && errors.length > 0 && !showDropDown" class="error-msg">
194
- {{ typeof errors[0] === "object" ? errors[0].$message : errors[0] }}
195
- </div>
193
+ <template v-if="errors && errors.length && !showDropDown">
194
+ <EUIErrorMessage :errors="errors" :name="name" class="mt-2" />
195
+ </template>
196
+
196
197
  <slot v-if="$slots.labelhint" name="labelhint"></slot>
197
198
  <div
198
199
  v-if="selectType === 'multiple' && selectedValues.length > 0 && showTags"
@@ -234,7 +235,7 @@
234
235
  <script setup lang="ts">
235
236
  import { computed, ref, watch, nextTick, onMounted, onUnmounted } from "vue";
236
237
  import { startCase } from "lodash";
237
- import { ErrorObject } from "../../utils/types";
238
+ import { ErrorObject, ValidationErrors } from "../../utils/types";
238
239
  import SearchInput from "./SearchInput.vue";
239
240
  import SearchBigZoomIn from "../../assets/svg/SearchBigZoomIn.vue";
240
241
  import ChevronDownStroke from "../../assets/svg/ChevronDownStroke.vue";
@@ -243,12 +244,14 @@ import EUITag from "../tag/EUITag.vue";
243
244
  import Popper from "vue3-popper";
244
245
  import CheckTick from "../../assets/svg/CheckTick.vue";
245
246
  import { XMarkIcon } from "@heroicons/vue/20/solid";
247
+ import EUIErrorMessage from "../errorMessage/EUIErrorMessage.vue";
246
248
 
247
249
  // Props
248
250
  interface Props {
249
251
  modelValue?: any;
250
252
  items?: any[];
251
253
  label?: string;
254
+ name?: string;
252
255
  placement?:
253
256
  | "auto"
254
257
  | "auto-start"
@@ -269,7 +272,7 @@ interface Props {
269
272
  placeholder?: string;
270
273
  offsetSkid?: string;
271
274
  offsetDistance?: string;
272
- errors?: Array<string | ErrorObject>;
275
+ errors?: ValidationErrors | ErrorObject[];
273
276
  selectType?: "single" | "multiple";
274
277
  filterFunction?: Function;
275
278
  searchable?: boolean;
@@ -287,11 +290,11 @@ interface Props {
287
290
  popperClasses?: string;
288
291
  showCount?: boolean;
289
292
  }
290
-
291
293
  const props = withDefaults(defineProps<Props>(), {
292
294
  items: () => [],
293
295
  itemText: "name",
294
296
  placeholder: "Please Select",
297
+ name: "",
295
298
  offsetDistance: "4",
296
299
  offsetSkid: "0",
297
300
  filterFunction: () => {},
@@ -313,6 +316,7 @@ const props = withDefaults(defineProps<Props>(), {
313
316
  showCount: false,
314
317
  });
315
318
 
319
+
316
320
  // Emits
317
321
  const emit = defineEmits<{
318
322
  "update:modelValue": [value: any];
@@ -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>