@zap-wunschlachen/wl-shared-components 1.0.59 → 1.0.61

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/App.vue CHANGED
@@ -1848,6 +1848,7 @@
1848
1848
  import NotificationBubble from '@/components/NotificationBubble/NotificationBubble.vue';
1849
1849
  import PhoneInput from '@/components/PhoneInput/PhoneInput.vue';
1850
1850
  import Select from '@/components/Select/Select.vue';
1851
+ import SelectAutocomplete from '@/components/SelectAutocomplete/SelectAutocomplete.vue';
1851
1852
  import TextArea from '@/components/TextArea/TextArea.vue';
1852
1853
  import TickBox from '@/components/TickBox/TickBox.vue';
1853
1854
  import AccordionGroup from '@/components/Accordion/AccordionGroup.vue';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zap-wunschlachen/wl-shared-components",
3
- "version": "1.0.59",
3
+ "version": "1.0.61",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <v-autocomplete
2
+ <v-combobox
3
3
  ref="inputRef"
4
4
  class="wl-select"
5
5
  :class="{
@@ -38,7 +38,6 @@
38
38
  @click:prepend-inner="onClickPrependInner"
39
39
  @update:search="onUpdateSearch"
40
40
  data-testid="root"
41
- :rules="[v => !!v || 'Please select a value from the list']"
42
41
  >
43
42
  <template v-slot:menu>
44
43
  <slot name="menu"></slot>
@@ -59,7 +58,7 @@
59
58
  <template v-if="$slots['append-inner']" #append-inner>
60
59
  <slot name="append-inner"></slot>
61
60
  </template>
62
- </v-autocomplete>
61
+ </v-combobox>
63
62
  </template>
64
63
 
65
64
  <script setup>
@@ -0,0 +1,167 @@
1
+ .wl-select .v-field__outline {
2
+ opacity: 1 !important; /* Set the opacity to 1 */
3
+ --v-field-border-opacity: 1 !important; /* Ensure full opacity for the border */
4
+ color: var(--Soft-Concrete-2) !important; /* border color */
5
+ }
6
+
7
+ /* Active state border color */
8
+ .wl-select .v-field--active .v-field__outline {
9
+ color: var(--Soft-Concrete-2) !important; /* Active border color */
10
+ opacity: 1 !important;
11
+ --v-field-border-opacity: 1 !important;
12
+ }
13
+
14
+ .wl-select .v-label.v-field-label {
15
+ color: var(--Dental-Blue--3) !important;
16
+ opacity: 1 !important;
17
+ }
18
+
19
+ /* Default input text color */
20
+ .wl-select .v-field__input {
21
+ color: var(--primary-color);
22
+ opacity: 1;
23
+ }
24
+
25
+ .wl-select .v-field--focused .v-field__input {
26
+ color: var(--primary-color);
27
+ opacity: 1;
28
+ }
29
+
30
+ /* Select item - default state (uses CSS variables from menuProps) */
31
+ .wl-select-menu .v-list-item {
32
+ color: var(--select-item-text, var(--primary-color));
33
+ background: var(--select-item-default-bg, var(--bg_0));
34
+ }
35
+
36
+ /* Select item - hover and active state */
37
+ .wl-select-menu .v-list-item:hover,
38
+ .wl-select-menu .v-list-item.v-list-item--active {
39
+ color: var(--select-item-text, var(--primary-color));
40
+ border-left: 4px solid var(--select-item-selected-left-border, var(--primary-color));
41
+ padding-left: 12px; /* Adjust padding to make space for the border */
42
+ background: var(--select-item-hovered-bg, var(--bg_0)) !important;
43
+ }
44
+
45
+ /* Select item - selected state */
46
+ .wl-select-menu .v-list-item--active {
47
+ background: var(--select-item-selected-bg, var(--bg_0)) !important;
48
+ }
49
+
50
+ .wl-select-menu .v-list-item__overlay {
51
+ background: var(--select-item-default-bg, var(--bg_0)) !important;
52
+ }
53
+
54
+ .wl-select-menu .v-list-item:hover .v-list-item__overlay {
55
+ background: var(--select-item-hovered-bg, var(--bg_0)) !important;
56
+ }
57
+
58
+ .wl-select-menu .v-list-item__content {
59
+ color: var(--select-item-text, var(--primary-color));
60
+ }
61
+
62
+ /* Focused state border color */
63
+ .v-field[aria-expanded='true'] .v-field__outline {
64
+ color: var(--Soft-Concrete-2) !important;
65
+ opacity: 1 !important;
66
+
67
+ border-bottom-left-radius: 0;
68
+ border-bottom-right-radius: 0;
69
+ }
70
+
71
+ .wl-select-menu .v-combobox__content {
72
+ border: 2px solid var(--Soft-Concrete-2);
73
+ border-bottom-left-radius: 8px !important;
74
+ border-bottom-right-radius: 8px !important;
75
+ border-top-left-radius: 0 !important;
76
+ border-top-right-radius: 0 !important;
77
+ box-shadow: none;
78
+ }
79
+
80
+ .v-combobox__selection .v-chip {
81
+ background: var(--bg_0);
82
+ color: var(--primary-color);
83
+ border-radius: 8px;
84
+ }
85
+
86
+ .wl-select .v-icon {
87
+ color: var(--primary-color);
88
+ }
89
+
90
+ /* Disabled state styles */
91
+ .wl-select .v-field--disabled,
92
+ .wl-select .v-field--disabled .v-label.v-field-label,
93
+ .wl-select .v-field--disabled .v-field__input,
94
+ .wl-select .v-field--disabled .v-icon {
95
+ color: #bdbdbd !important; /* Grey text and icon */
96
+ background-color: #f5f5f5 !important; /* Light grey background */
97
+ opacity: 1 !important; /* Ensure full opacity */
98
+ cursor: not-allowed !important;
99
+ }
100
+
101
+ .wl-select .v-field--disabled .v-field__outline {
102
+ border-color: #e0e0e0 !important; /* Lighter grey border */
103
+ }
104
+
105
+ .wl-select .v-field--disabled .v-combobox__selection .v-chip {
106
+ background: #e0e0e0 !important;
107
+ color: #bdbdbd !important;
108
+ border: 1px solid #bdbdbd !important;
109
+ }
110
+
111
+ /* Optionally, dim the dropdown if open while disabled */
112
+ .wl-select .v-field--disabled .v-combobox__content {
113
+ background: #f5f5f5 !important;
114
+ color: #bdbdbd !important;
115
+ pointer-events: none;
116
+ }
117
+
118
+ /* Error state styles */
119
+ .wl-select .v-field--error,
120
+ .wl-select .v-field--error .v-label.v-field-label,
121
+ .wl-select .v-field--error .v-field__input,
122
+ .wl-select .v-field--error .v-icon {
123
+ background-color: #fdeaea !important; /* Light red background */
124
+ color: #b71c1c !important; /* Dark red text and icon */
125
+ border-color: #b71c1c !important; /* Dark red border */
126
+ }
127
+
128
+ .wl-select .v-field--error .v-field__outline {
129
+ --v-field-border-opacity: 1 !important;
130
+ }
131
+
132
+ .wl-select .v-field--error .v-combobox__selection .v-chip {
133
+ background: #fdeaea !important; /* Light red background */
134
+ color: #b71c1c !important; /* Dark red text */
135
+ border: 1px solid #b71c1c !important;
136
+ }
137
+
138
+ .wl-select .v-field--error .v-combobox__content {
139
+ background: #fdeaea !important;
140
+ color: #b71c1c !important;
141
+ border-color: #b71c1c !important;
142
+ }
143
+
144
+ .wl-select .v-field--error .v-field__input {
145
+ color: #b71c1c !important;
146
+ background: #fdeaea !important;
147
+ }
148
+
149
+ .wl-select .v-field--disabled .v-field__input {
150
+ color: #bdbdbd !important;
151
+ background: #f5f5f5 !important;
152
+ }
153
+
154
+ .wl-select.border-on-hover .v-field__outline {
155
+ opacity: 0 !important;
156
+ --v-field-border-opacity: 0 !important;
157
+ }
158
+
159
+ .wl-select.border-on-hover:hover .v-field__outline {
160
+ opacity: 1 !important;
161
+ --v-field-border-opacity: 1 !important;
162
+ }
163
+
164
+ .wl-select.border-on-hover .v-field--focused .v-field__outline {
165
+ opacity: 1 !important;
166
+ --v-field-border-opacity: 1 !important;
167
+ }
@@ -0,0 +1,340 @@
1
+ <template>
2
+ <v-autocomplete
3
+ ref="inputRef"
4
+ class="wl-select"
5
+ :class="{
6
+ 'border-on-hover': borderOnHover
7
+ }"
8
+ rounded="lg"
9
+ :density="density"
10
+ :variant="props.variant"
11
+ :label="label"
12
+ :chips="chips"
13
+ :append-icon="appendIcon"
14
+ :append-inner-icon="appendInnerIcon"
15
+ :prepend-icon="prependIcon"
16
+ :prepend-inner-icon="prependInnerIcon"
17
+ :menu-icon="menuIcon"
18
+ :clear-icon="clearIcon"
19
+ :closable-chips="closableChips"
20
+ :multiple="multiple"
21
+ :hide-details="true"
22
+ :clearable="clearable"
23
+ :items="items"
24
+ :disabled="disabled"
25
+ :error="error"
26
+ :item-title="'title'"
27
+ :item-value="'value'"
28
+ :return-object="returnObject"
29
+ :placeholder="placeholder"
30
+ :persistent-placeholder="persistentPlaceholder"
31
+ :aria-invalid="error || undefined"
32
+ :menu-props="computedMenuProps"
33
+ v-model="internalValue"
34
+ @click:append="onClickAppend"
35
+ @click:append-inner="onClickAppendInner"
36
+ @click:clear="onClickClear"
37
+ @click:prepend="onClickPrepend"
38
+ @click:prepend-inner="onClickPrependInner"
39
+ @update:search="onUpdateSearch"
40
+ data-testid="root"
41
+ :rules="[v => !!v || 'Please select a value from the list']"
42
+ >
43
+ <template v-slot:menu>
44
+ <slot name="menu"></slot>
45
+ </template>
46
+
47
+ <template v-if="$slots['prepend']" #prepend>
48
+ <slot name="prepend"></slot>
49
+ </template>
50
+
51
+ <template v-if="$slots['prepend-inner']" #prepend-inner>
52
+ <slot name="prepend-inner"></slot>
53
+ </template>
54
+
55
+ <template v-if="$slots['append']" #append>
56
+ <slot name="append"></slot>
57
+ </template>
58
+
59
+ <template v-if="$slots['append-inner']" #append-inner>
60
+ <slot name="append-inner"></slot>
61
+ </template>
62
+ </v-autocomplete>
63
+ </template>
64
+
65
+ <script setup>
66
+ import './Select2.css';
67
+ import { ref, watch, nextTick, computed, inject } from 'vue';
68
+ import { defineProps, defineEmits } from 'vue';
69
+ import { siteColors } from "../../utils/index";
70
+
71
+ // Inject theme colors from ThemeProvider, fallback to global siteColors
72
+ const injectedThemeColors = inject('themeColors', null);
73
+ const colors = computed(() => {
74
+ if (injectedThemeColors) {
75
+ return injectedThemeColors.value;
76
+ }
77
+ return siteColors;
78
+ });
79
+
80
+ // Compute menu props with domain-specific class and inline CSS variables for dropdown styling
81
+ const computedMenuProps = computed(() => ({
82
+ class: 'wl-select-menu',
83
+ style: {
84
+ '--select-item-text': colors.value['select_item_text'],
85
+ '--select-item-default-bg': colors.value['select_item_default_bg'],
86
+ '--select-item-hovered-bg': colors.value['select_item_hovered_bg'],
87
+ '--select-item-selected-left-border': colors.value['select_item_selected_left_border'],
88
+ '--select-item-selected-bg': colors.value['select_item_selected_bg']
89
+ }
90
+ }));
91
+
92
+ // Define component props with default values and descriptions
93
+ const props = defineProps({
94
+ /**
95
+ * Disables the select input when true, making it non-interactive.
96
+ * Default is false.
97
+ */
98
+ disabled: {
99
+ type: Boolean,
100
+ default: false,
101
+ },
102
+
103
+ /**
104
+ * Changes the select input state, when true, put it into error state.
105
+ * Default is false.
106
+ */
107
+ error: {
108
+ type: Boolean,
109
+ default: false,
110
+ },
111
+
112
+ /**
113
+ * Allows clearing the selected value when true.
114
+ * Default is true.
115
+ */
116
+ clearable: {
117
+ type: Boolean,
118
+ default: false,
119
+ },
120
+
121
+ /**
122
+ * The label displayed above the select input.
123
+ * Default is 'Label'.
124
+ */
125
+ label: {
126
+ type: String,
127
+ default: 'Label',
128
+ },
129
+
130
+ /**
131
+ * Enables the display of selected items as chips when true.
132
+ * Default is false.
133
+ */
134
+ chips: {
135
+ type: Boolean,
136
+ default: false,
137
+ },
138
+
139
+ /**
140
+ * Icon to append to the select field.
141
+ */
142
+ appendIcon: {
143
+ type: String,
144
+ },
145
+
146
+ /**
147
+ * Inner icon to append inside the select field.
148
+ */
149
+ appendInnerIcon: {
150
+ type: String,
151
+ },
152
+
153
+ /**
154
+ * Icon to prepend to the select field.
155
+ */
156
+ prependIcon: {
157
+ type: String,
158
+ },
159
+
160
+ /**
161
+ * Inner icon to prepend inside the select field.
162
+ */
163
+ prependInnerIcon: {
164
+ type: String,
165
+ },
166
+
167
+ /**
168
+ * The icon for the menu toggle.
169
+ * Default is an empty string (no icon).
170
+ */
171
+ menuIcon: {
172
+ type: String,
173
+ default: '',
174
+ },
175
+
176
+ /**
177
+ * The icon to use for the clear button.
178
+ * Default is 'x-mark'.
179
+ */
180
+ clearIcon: {
181
+ type: String,
182
+ default: 'x-mark',
183
+ },
184
+
185
+ /**
186
+ * Enables closing chips when true.
187
+ * Default is false.
188
+ */
189
+ closableChips: {
190
+ type: Boolean,
191
+ default: false,
192
+ },
193
+
194
+ /**
195
+ * Allows multiple selections when true.
196
+ * Default is false.
197
+ */
198
+ multiple: {
199
+ type: Boolean,
200
+ default: false,
201
+ },
202
+
203
+ /**
204
+ * The items available for selection.
205
+ * Default is an empty array.
206
+ */
207
+ items: {
208
+ type: Array,
209
+ default: () => [],
210
+ },
211
+
212
+ /**
213
+ * The selected value (can be a string, array, or object).
214
+ */
215
+ modelValue: {
216
+ type: [String, Array, Object],
217
+ default: undefined,
218
+ },
219
+
220
+ /**
221
+ * The density of the select input.
222
+ * Controls spacing and size. Default is 'compact'.
223
+ */
224
+ density: {
225
+ type: String,
226
+ default: 'compact',
227
+ },
228
+
229
+ /**
230
+ * When true, the selected item is returned as an object.
231
+ * Default is true.
232
+ */
233
+ returnObject: {
234
+ type: Boolean,
235
+ default: true,
236
+ },
237
+
238
+ /**
239
+ * The property name of the item to display as the title.
240
+ */
241
+ itemTitle: {
242
+ type: String,
243
+ default: undefined,
244
+ },
245
+
246
+ /**
247
+ * The property name of the item to use as the value.
248
+ */
249
+ itemValue: {
250
+ type: String,
251
+ default: undefined,
252
+ },
253
+
254
+ variant: {
255
+ type: String,
256
+ default: 'outlined',
257
+ },
258
+
259
+ borderOnHover: {
260
+ type: Boolean,
261
+ default: false
262
+ },
263
+
264
+ placeholder: {
265
+ type: String,
266
+ default: ''
267
+ },
268
+ persistentPlaceholder:{
269
+ type: Boolean,
270
+ default: false
271
+ }
272
+ });
273
+
274
+ // Define events that can be emitted by the component
275
+ const emits = defineEmits([
276
+ 'update:modelValue', // Emit when the model value is updated
277
+ 'click:append', // Emit when the append icon is clicked
278
+ 'click:appendInner', // Emit when the append inner icon is clicked
279
+ 'click:clear', // Emit when the clear button is clicked
280
+ 'click:prepend', // Emit when the prepend icon is clicked
281
+ 'click:prependInner', // Emit when the prepend inner icon is clicked
282
+ 'update:search', // Emit search updates for filtering items
283
+ ]);
284
+
285
+ // Define a reactive reference for internal value based on the modelValue prop
286
+ const internalValue = ref(props.modelValue);
287
+
288
+ // Watch for changes in modelValue prop and update internalValue accordingly
289
+ watch(
290
+ () => props.modelValue,
291
+ (newValue) => {
292
+ internalValue.value = newValue;
293
+ },
294
+ );
295
+
296
+ // Watch for changes in internalValue and emit updated modelValue to parent
297
+ watch(internalValue, (newValue) => {
298
+ emits('update:modelValue', newValue);
299
+ });
300
+
301
+ // Emit click events for various icon and button interactions
302
+ const onClickAppend = (event) => emits('click:append', event);
303
+ const onClickAppendInner = (event) => emits('click:appendInner', event);
304
+ const onClickClear = (event) => emits('click:clear', event);
305
+ const onClickPrepend = (event) => emits('click:prepend', event);
306
+ const onClickPrependInner = (event) => emits('click:prependInner', event);
307
+
308
+ // Emit search updates for filtering or searching items
309
+ const onUpdateSearch = (searchValue) => emits('update:search', searchValue);
310
+
311
+ const inputRef = ref(null)
312
+
313
+ const getNativeInput = () => {
314
+ return inputRef.value?.$el?.querySelector('input');
315
+ }
316
+
317
+ const blur = () => {
318
+ nextTick(() => {
319
+ getNativeInput()?.blur();
320
+ });
321
+ };
322
+
323
+ const select = () => {
324
+ nextTick(() => {
325
+ getNativeInput()?.select();
326
+ });
327
+ };
328
+
329
+ const focus = () => {
330
+ nextTick(() => {
331
+ getNativeInput()?.focus();
332
+ });
333
+ };
334
+
335
+ defineExpose({
336
+ blur,
337
+ select,
338
+ focus
339
+ });
340
+ </script>
@@ -31,6 +31,7 @@ export { default as NotificationBubble } from './NotificationBubble/Notification
31
31
  export { default as OtpInput } from './OtpInput/OtpInput.vue';
32
32
  export { default as PhoneInput } from './PhoneInput/PhoneInput.vue';
33
33
  export { default as Select } from './Select/Select.vue';
34
+ export { default as SelectAutocomplete } from './SelectAutocomplete/SelectAutocomplete.vue';
34
35
  export { default as TextArea } from './TextArea/TextArea.vue';
35
36
  export { default as TickBox } from './TickBox/TickBox.vue';
36
37