@a-vision-software/vue-input-components 1.3.10 → 1.3.12

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": "@a-vision-software/vue-input-components",
3
- "version": "1.3.10",
3
+ "version": "1.3.12",
4
4
  "description": "A collection of reusable Vue 3 input components with TypeScript support",
5
5
  "author": "A-Vision Software",
6
6
  "license": "MIT",
@@ -5,18 +5,26 @@
5
5
  'dropdown--multiple': multiple,
6
6
  'dropdown--large-icon': iconSize === 'large',
7
7
  'dropdown--has-error': error,
8
- }" :style="{
9
- '--dropdown-color': error ? 'var(--danger-color)' : color,
10
- '--dropdown-hover-color': hoverColor ? hoverColor : 'var(--dropdown-color)',
11
- '--dropdown-active-color': activeColor ? activeColor : 'var(--dropdown-color)',
12
- '--dropdown-disabled-color': disabledColor,
13
- '--dropdown-background-color': backgroundColor,
14
- '--dropdown-border-radius': borderRadius,
15
- '--dropdown-padding': padding,
16
- '--dropdown-max-height': maxHeight,
17
- '--dropdown-width': width,
18
- }" @click="toggleDropdown" @keydown.esc="closeDropdown" @keydown.space.prevent="toggleDropdown"
8
+ [`label-${labelPosition}`]: label,
9
+ [`label-align-${labelAlign}`]: label,
10
+ }" :style="[
11
+ { width: width || '100%' },
12
+ labelStyle,
13
+ {
14
+ '--dropdown-color': error ? 'var(--danger-color)' : color,
15
+ '--dropdown-hover-color': hoverColor ? hoverColor : 'var(--dropdown-color)',
16
+ '--dropdown-active-color': activeColor ? activeColor : 'var(--dropdown-color)',
17
+ '--dropdown-disabled-color': disabledColor,
18
+ '--dropdown-background-color': backgroundColor,
19
+ '--dropdown-border-radius': borderRadius,
20
+ '--dropdown-padding': padding,
21
+ '--dropdown-max-height': maxHeight,
22
+ }
23
+ ]" @click="toggleDropdown" @keydown.esc="closeDropdown" @keydown.space.prevent="toggleDropdown"
19
24
  @keydown.enter.prevent="toggleDropdown" tabindex="0">
25
+ <label v-if="label" :for="id" class="label">
26
+ {{ label }}
27
+ </label>
20
28
  <div class="dropdown__selected">
21
29
  <div v-if="icon" class="dropdown__icon">
22
30
  <img v-if="icon.startsWith('img:')" :src="icon.substring(4)" :alt="placeholder" class="dropdown__icon-image" />
@@ -74,7 +82,7 @@
74
82
  </template>
75
83
 
76
84
  <script setup lang="ts">
77
- import { ref, computed, watch, nextTick, onUnmounted } from 'vue'
85
+ import { ref, computed, watch, nextTick, onUnmounted, onMounted } from 'vue'
78
86
  import type { DropdownProps, DropdownOption } from '../types/dropdown'
79
87
 
80
88
  const props = withDefaults(defineProps<DropdownProps>(), {
@@ -95,6 +103,10 @@ const props = withDefaults(defineProps<DropdownProps>(), {
95
103
  iconSize: 'normal',
96
104
  required: false,
97
105
  error: '',
106
+ label: '',
107
+ labelPosition: 'top',
108
+ labelAlign: 'left',
109
+ labelWidth: '',
98
110
  })
99
111
 
100
112
  const emit = defineEmits<{
@@ -257,6 +269,22 @@ onUnmounted(() => {
257
269
  clearTimeout(changedTimer.value)
258
270
  }
259
271
  })
272
+
273
+ const id = ref<string>('')
274
+
275
+ const labelStyle = computed(() => {
276
+ if (!props.label) return {}
277
+ if (props.labelPosition === 'left' && props.labelWidth) {
278
+ return {
279
+ 'grid-template-columns': `${props.labelWidth} 1fr`,
280
+ }
281
+ }
282
+ return {}
283
+ })
284
+
285
+ onMounted(() => {
286
+ id.value = `dropdown-${Math.random().toString(36).substr(2, 9)}`
287
+ })
260
288
  </script>
261
289
 
262
290
  <style scoped>
@@ -267,6 +295,9 @@ onUnmounted(() => {
267
295
  cursor: pointer;
268
296
  user-select: none;
269
297
  outline: none;
298
+ display: grid;
299
+ gap: 0.5rem;
300
+ margin-top: 0.7rem;
270
301
 
271
302
  &.dropdown--has-error {
272
303
  border-color: var(--danger-color);
@@ -367,7 +398,6 @@ onUnmounted(() => {
367
398
  color: white;
368
399
  border-radius: calc(var(--dropdown-border-radius) * 0.75);
369
400
  font-size: 0.875rem;
370
- color: var(--dropdown-color);
371
401
  }
372
402
 
373
403
  .dropdown__selected-tag-remove {
@@ -547,4 +577,37 @@ onUnmounted(() => {
547
577
  .fade-leave-to {
548
578
  opacity: 0;
549
579
  }
580
+
581
+ .dropdown.label-top {
582
+ grid-template-rows: auto 1fr;
583
+ }
584
+
585
+ .dropdown.label-left {
586
+ grid-template-columns: 30% 1fr;
587
+ align-items: start;
588
+ gap: 1rem;
589
+ }
590
+
591
+ .dropdown.label-left .label {
592
+ padding-top: 0.25rem;
593
+ width: 100%;
594
+ }
595
+
596
+ .label {
597
+ font-weight: 500;
598
+ color: var(--text-color);
599
+ text-align: left;
600
+ }
601
+
602
+ .label-align-left .label {
603
+ text-align: left;
604
+ }
605
+
606
+ .label-align-right .label {
607
+ text-align: right;
608
+ }
609
+
610
+ .label-align-center .label {
611
+ text-align: center;
612
+ }
550
613
  </style>
@@ -231,7 +231,7 @@ defineExpose({
231
231
  }
232
232
 
233
233
  .text-input.label-left .label {
234
- padding-top: 0.75rem;
234
+ padding-top: 0.25rem;
235
235
  width: 100%;
236
236
  }
237
237
 
@@ -25,4 +25,8 @@ export interface DropdownProps {
25
25
  error?: string
26
26
  required?: boolean
27
27
  autosave?: (value: string | string[]) => Promise<void>
28
+ label?: string
29
+ labelPosition?: 'top' | 'left'
30
+ labelAlign?: 'left' | 'center' | 'right'
31
+ labelWidth?: string
28
32
  }
@@ -6,8 +6,9 @@
6
6
 
7
7
  <div class="dropdown-test__section">
8
8
  <h2>Single Select Dropdown</h2>
9
- <Dropdown v-model="selectedSingle" :options="options" placeholder="Select a color" filterable required
10
- @update:modelValue="handleSingleChange" error="This is an error" />
9
+ <Dropdown v-model="selectedSingle" :options="options" label="Color" labelPosition="left" labelWidth="100px"
10
+ labelAlign="right" placeholder="Select a color" filterable required @update:modelValue="handleSingleChange"
11
+ error="This is an error" />
11
12
  <div v-if="selectedSingle" class="selection-info">
12
13
  Selected: {{ getOptionLabel(selectedSingle) }}
13
14
  </div>
@@ -15,8 +16,8 @@
15
16
 
16
17
  <div class="dropdown-test__section">
17
18
  <h2>Multiple Select Dropdown</h2>
18
- <Dropdown v-model="selectedMultiple" :options="options" multiple filterable placeholder="Select colors"
19
- icon="paintbrush" @update:modelValue="handleMultipleChange" color="#aa0000" />
19
+ <Dropdown v-model="selectedMultiple" :options="options" label="Multiple colors" multiple filterable
20
+ placeholder="Select colors" icon="paintbrush" @update:modelValue="handleMultipleChange" color="#aa0000" />
20
21
  <div v-if="selectedMultiple.length" class="selection-info">
21
22
  Selected: {{ getSelectedLabels(selectedMultiple).join(', ') }}
22
23
  </div>