@volverjs/ui-vue 0.0.10-beta.15 → 0.0.10-beta.17

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.
Files changed (154) hide show
  1. package/README.md +96 -2
  2. package/auto-imports.d.ts +2 -0
  3. package/dist/components/VvAccordion/VvAccordion.es.js +33 -9
  4. package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
  5. package/dist/components/VvAccordion/VvAccordion.vue.d.ts +9 -2
  6. package/dist/components/VvAccordion/index.d.ts +4 -1
  7. package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +33 -9
  8. package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
  9. package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +9 -2
  10. package/dist/components/VvAccordionGroup/index.d.ts +4 -1
  11. package/dist/components/VvAction/VvAction.es.js +29 -8
  12. package/dist/components/VvAction/VvAction.umd.js +1 -1
  13. package/dist/components/VvAction/VvAction.vue.d.ts +44 -10
  14. package/dist/components/VvAction/index.d.ts +21 -5
  15. package/dist/components/VvAlert/VvAlert.es.js +91 -107
  16. package/dist/components/VvAlert/VvAlert.umd.js +1 -1
  17. package/dist/components/VvAlert/VvAlert.vue.d.ts +14 -4
  18. package/dist/components/VvAlert/index.d.ts +7 -3
  19. package/dist/components/VvAlertGroup/VvAlertGroup.es.js +91 -107
  20. package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
  21. package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +9 -2
  22. package/dist/components/VvAlertGroup/index.d.ts +6 -2
  23. package/dist/components/VvAvatar/VvAvatar.es.js +33 -9
  24. package/dist/components/VvAvatar/VvAvatar.umd.js +1 -1
  25. package/dist/components/VvAvatar/VvAvatar.vue.d.ts +11 -3
  26. package/dist/components/VvAvatar/index.d.ts +4 -1
  27. package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +33 -9
  28. package/dist/components/VvAvatarGroup/VvAvatarGroup.umd.js +1 -1
  29. package/dist/components/VvAvatarGroup/VvAvatarGroup.vue.d.ts +9 -2
  30. package/dist/components/VvAvatarGroup/index.d.ts +4 -1
  31. package/dist/components/VvBadge/VvBadge.es.js +33 -9
  32. package/dist/components/VvBadge/VvBadge.umd.js +1 -1
  33. package/dist/components/VvBadge/VvBadge.vue.d.ts +11 -3
  34. package/dist/components/VvBadge/index.d.ts +4 -1
  35. package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +33 -9
  36. package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
  37. package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +11 -3
  38. package/dist/components/VvBreadcrumb/index.d.ts +4 -1
  39. package/dist/components/VvButton/VvButton.es.js +100 -119
  40. package/dist/components/VvButton/VvButton.umd.js +1 -1
  41. package/dist/components/VvButton/VvButton.vue.d.ts +78 -20
  42. package/dist/components/VvButton/index.d.ts +34 -12
  43. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +33 -9
  44. package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
  45. package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +17 -4
  46. package/dist/components/VvButtonGroup/index.d.ts +8 -2
  47. package/dist/components/VvCard/VvCard.es.js +33 -9
  48. package/dist/components/VvCard/VvCard.umd.js +1 -1
  49. package/dist/components/VvCard/VvCard.vue.d.ts +11 -3
  50. package/dist/components/VvCard/index.d.ts +4 -1
  51. package/dist/components/VvCheckbox/VvCheckbox.es.js +56 -17
  52. package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
  53. package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +94 -22
  54. package/dist/components/VvCheckbox/index.d.ts +44 -11
  55. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +64 -19
  56. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
  57. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +93 -22
  58. package/dist/components/VvCheckboxGroup/index.d.ts +44 -11
  59. package/dist/components/VvCombobox/VvCombobox.es.js +108 -165
  60. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  61. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +97 -24
  62. package/dist/components/VvCombobox/index.d.ts +42 -11
  63. package/dist/components/VvDialog/VvDialog.es.js +51 -103
  64. package/dist/components/VvDialog/VvDialog.umd.js +1 -1
  65. package/dist/components/VvDropdown/VvDropdown.es.js +33 -9
  66. package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
  67. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +14 -2
  68. package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +61 -12
  69. package/dist/components/VvDropdown/VvDropdownOptgroup.vue.d.ts +11 -3
  70. package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +25 -6
  71. package/dist/components/VvDropdown/index.d.ts +6 -1
  72. package/dist/components/VvDropdownAction/VvDropdownAction.es.js +33 -9
  73. package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
  74. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +29 -8
  75. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -1
  76. package/dist/components/VvDropdownOption/VvDropdownOption.es.js +37 -10
  77. package/dist/components/VvDropdownOption/VvDropdownOption.umd.js +1 -1
  78. package/dist/components/VvIcon/VvIcon.es.js +22 -95
  79. package/dist/components/VvIcon/VvIcon.umd.js +1 -1
  80. package/dist/components/VvIcon/VvIcon.vue.d.ts +81 -44
  81. package/dist/components/VvIcon/index.d.ts +21 -48
  82. package/dist/components/VvInputFile/VvInputFile.es.js +146 -140
  83. package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
  84. package/dist/components/VvInputFile/VvInputFile.vue.d.ts +52 -12
  85. package/dist/components/VvInputFile/index.d.ts +24 -6
  86. package/dist/components/VvInputText/VvInputText.es.js +115 -147
  87. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  88. package/dist/components/VvInputText/VvInputText.vue.d.ts +141 -34
  89. package/dist/components/VvInputText/index.d.ts +71 -26
  90. package/dist/components/VvNav/VvNav.es.js +33 -9
  91. package/dist/components/VvNav/VvNav.umd.js +1 -1
  92. package/dist/components/VvNav/VvNav.vue.d.ts +9 -2
  93. package/dist/components/VvNav/index.d.ts +4 -1
  94. package/dist/components/VvNavItem/VvNavItem.es.js +29 -8
  95. package/dist/components/VvNavItem/VvNavItem.umd.js +1 -1
  96. package/dist/components/VvProgress/VvProgress.es.js +33 -9
  97. package/dist/components/VvProgress/VvProgress.umd.js +1 -1
  98. package/dist/components/VvProgress/VvProgress.vue.d.ts +9 -2
  99. package/dist/components/VvProgress/index.d.ts +4 -1
  100. package/dist/components/VvRadio/VvRadio.es.js +56 -17
  101. package/dist/components/VvRadio/VvRadio.umd.js +1 -1
  102. package/dist/components/VvRadio/VvRadio.vue.d.ts +94 -22
  103. package/dist/components/VvRadio/index.d.ts +44 -11
  104. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +64 -19
  105. package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
  106. package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +93 -22
  107. package/dist/components/VvRadioGroup/index.d.ts +44 -11
  108. package/dist/components/VvSelect/VvSelect.es.js +95 -138
  109. package/dist/components/VvSelect/VvSelect.umd.js +1 -1
  110. package/dist/components/VvSelect/VvSelect.vue.d.ts +97 -24
  111. package/dist/components/VvSelect/index.d.ts +46 -12
  112. package/dist/components/VvTab/VvTab.es.js +33 -9
  113. package/dist/components/VvTab/VvTab.umd.js +1 -1
  114. package/dist/components/VvTab/VvTab.vue.d.ts +9 -2
  115. package/dist/components/VvTab/index.d.ts +4 -1
  116. package/dist/components/VvTextarea/VvTextarea.es.js +109 -143
  117. package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
  118. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +141 -34
  119. package/dist/components/VvTextarea/index.d.ts +66 -17
  120. package/dist/components/VvTooltip/VvTooltip.es.js +33 -9
  121. package/dist/components/VvTooltip/VvTooltip.umd.js +1 -1
  122. package/dist/components/VvTooltip/VvTooltip.vue.d.ts +9 -2
  123. package/dist/components/VvTooltip/index.d.ts +4 -1
  124. package/dist/components/index.es.js +217 -249
  125. package/dist/components/index.umd.js +1 -1
  126. package/dist/composables/useComponentIcon.d.ts +9 -8
  127. package/dist/directives/index.es.js +33 -9
  128. package/dist/directives/index.umd.js +1 -1
  129. package/dist/directives/v-tooltip.es.js +33 -9
  130. package/dist/directives/v-tooltip.umd.js +1 -1
  131. package/dist/icons.es.js +3 -3
  132. package/dist/icons.umd.js +1 -1
  133. package/dist/props/index.d.ts +251 -61
  134. package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +15 -4
  135. package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +77 -22
  136. package/dist/stories/Icon/Icon.settings.d.ts +1 -0
  137. package/package.json +33 -33
  138. package/src/assets/icons/detailed.json +1 -1
  139. package/src/assets/icons/normal.json +1 -1
  140. package/src/assets/icons/simple.json +1 -1
  141. package/src/components/VvAlert/index.ts +1 -3
  142. package/src/components/VvAlertGroup/index.ts +2 -1
  143. package/src/components/VvButton/VvButton.vue +6 -6
  144. package/src/components/VvButton/index.ts +2 -4
  145. package/src/components/VvCombobox/VvCombobox.vue +5 -8
  146. package/src/components/VvIcon/VvIcon.vue +2 -2
  147. package/src/components/VvIcon/index.ts +22 -48
  148. package/src/components/VvInputFile/VvInputFile.vue +33 -10
  149. package/src/components/VvInputText/VvInputText.vue +11 -12
  150. package/src/components/VvSelect/VvSelect.vue +5 -8
  151. package/src/components/VvTextarea/VvTextarea.vue +5 -8
  152. package/src/composables/useComponentIcon.ts +15 -14
  153. package/src/props/index.ts +89 -25
  154. package/src/stories/Icon/Icon.settings.ts +3 -3
@@ -86,9 +86,7 @@ export const useVvAlert = (
86
86
  const hasTitleId = computed(() => `${hasId.value}-title`)
87
87
 
88
88
  // icon
89
- const hasIcon = computed(() =>
90
- typeof props.icon === 'string' ? { name: props.icon } : props.icon,
91
- )
89
+ const { hasIcon } = useComponentIcon(computed(() => props.icon))
92
90
 
93
91
  // props
94
92
  const hasClass = useModifiers(
@@ -1,10 +1,11 @@
1
1
  import { ModifiersProps } from '@/props'
2
2
  import type { ExtractPropTypes } from 'vue'
3
+ import type { VvIconProps } from '../VvIcon'
3
4
 
4
5
  export type AlertItem = {
5
6
  id: string | number
6
7
  title?: string
7
- icon?: string | Record<string, unknown>
8
+ icon?: string | VvIconProps
8
9
  content?: string
9
10
  footer?: string
10
11
  modifiers?: string | string[]
@@ -74,9 +74,7 @@
74
74
  * @description Define icon attributes.
75
75
  * @returns {Object} The icon attributes.
76
76
  */
77
- const hasIconProps = computed(() =>
78
- typeof icon?.value === 'string' ? { name: icon?.value } : icon?.value,
79
- )
77
+ const { hasIcon } = useComponentIcon(icon)
80
78
 
81
79
  /**
82
80
  * @description Catch click event
@@ -146,9 +144,11 @@
146
144
  <template v-else>
147
145
  <!-- @slot Before label and icon -->
148
146
  <slot name="before" />
149
- <template v-if="icon">
150
- <VvIcon class="vv-button__icon" v-bind="hasIconProps" />
151
- </template>
147
+ <VvIcon
148
+ v-if="hasIcon"
149
+ v-bind="hasIcon"
150
+ class="vv-button__icon"
151
+ />
152
152
  <span v-if="label" class="vv-button__label">
153
153
  <!-- @slot Use this slot for button label -->
154
154
  <slot name="label">
@@ -6,6 +6,7 @@ import {
6
6
  LoadingProps,
7
7
  ModifiersProps,
8
8
  UnselectableProps,
9
+ IconProps,
9
10
  } from '../../props'
10
11
  import { INJECTION_KEY_BUTTON_GROUP, Side } from '../../constants'
11
12
 
@@ -17,10 +18,7 @@ export const VvButtonProps = {
17
18
  ...ModifiersProps,
18
19
  ...UnselectableProps,
19
20
  ...LoadingProps,
20
- /**
21
- * Button icon
22
- */
23
- icon: [String, Object],
21
+ ...IconProps,
24
22
  /**
25
23
  * Button icon position
26
24
  */
@@ -151,10 +151,7 @@
151
151
  const dropdownEl = ref()
152
152
 
153
153
  // icons
154
- const { hasIcon, hasIconBefore, hasIconAfter } = useComponentIcon(
155
- icon,
156
- iconPosition,
157
- )
154
+ const { hasIconBefore, hasIconAfter } = useComponentIcon(icon, iconPosition)
158
155
 
159
156
  // dirty
160
157
  const isDirty = computed(() => !isEmpty(props.modelValue))
@@ -172,8 +169,8 @@
172
169
  disabled: disabled.value,
173
170
  loading: isLoading.value,
174
171
  readonly: readonly.value,
175
- 'icon-before': Boolean(hasIconBefore.value),
176
- 'icon-after': Boolean(hasIconAfter.value),
172
+ 'icon-before': hasIconBefore.value !== undefined,
173
+ 'icon-after': hasIconAfter.value !== undefined,
177
174
  valid: valid.value,
178
175
  invalid: invalid.value,
179
176
  dirty: isDirty.value,
@@ -429,8 +426,8 @@
429
426
  <div class="vv-select__inner">
430
427
  <VvIcon
431
428
  v-if="hasIconBefore"
429
+ v-bind="hasIconBefore"
432
430
  class="vv-select__icon"
433
- v-bind="hasIcon"
434
431
  />
435
432
  <div
436
433
  ref="inputEl"
@@ -493,8 +490,8 @@
493
490
  </div>
494
491
  <VvIcon
495
492
  v-if="hasIconAfter"
493
+ v-bind="hasIconAfter"
496
494
  class="vv-select__icon vv-select__icon-after"
497
- v-bind="hasIcon"
498
495
  />
499
496
  </div>
500
497
  <div v-if="$slots.after" class="vv-select__input-after">
@@ -6,10 +6,10 @@
6
6
 
7
7
  <script setup lang="ts">
8
8
  import { Icon, addIcon, iconExists } from '@iconify/vue'
9
- import { VvIconProps } from '.'
9
+ import { type VvIconProps, VvIconPropsDefaults } from '.'
10
10
 
11
11
  // props
12
- const props = defineProps(VvIconProps)
12
+ const props = withDefaults(defineProps<VvIconProps>(), VvIconPropsDefaults)
13
13
 
14
14
  const hasRotate = computed(() => {
15
15
  if (typeof props.rotate === 'string') {
@@ -1,4 +1,3 @@
1
- import type { PropType } from 'vue'
2
1
  import type { IconifyIconOnLoad, IconifyRenderMode } from '@iconify/vue'
3
2
 
4
3
  export enum IconPrefix {
@@ -7,65 +6,38 @@ export enum IconPrefix {
7
6
  detailed = 'detailed',
8
7
  }
9
8
 
10
- export const VvIconProps = {
11
- /**
12
- * Color
13
- */
14
- color: String,
15
- /**
16
- * Width
17
- */
18
- width: {
19
- type: [String, Number],
20
- },
21
- /**
22
- * Height
23
- */
24
- height: {
25
- type: [String, Number],
26
- },
9
+ export type VvIconProps = {
27
10
  /**
28
11
  * Icon name
29
12
  * Can be the full composition of iconify name "@{provider}:{prefix}:{name}" or "{prefix}:{name}" or "{name}"
30
13
  * https://docs.iconify.design/api/providers.html#provider-in-icon-name
31
14
  */
32
- name: {
33
- type: String,
34
- required: true,
35
- },
15
+ name: string
16
+ color?: string
17
+ width?: string | number
18
+ height?: string | number
36
19
  /**
37
- * By default 'vv'
38
20
  * If custom collection is not added with "addCollection" DS class method, this prop could not be used
39
21
  * Icon provider: https://docs.iconify.design/api/providers.html#provider-in-icon-name
40
22
  */
41
- provider: {
42
- type: String,
43
- },
23
+ provider?: string
44
24
  /**
25
+ * @default 'normal'
45
26
  * The name of icon set.
46
27
  * Icon default options prefix: simple | normal | detailed
47
28
  */
48
- prefix: {
49
- type: String as PropType<`${IconPrefix}` | string>,
50
- default: 'normal',
51
- },
29
+ prefix?: IconPrefix | string
52
30
  /**
53
31
  * Url remote SVG icon
54
32
  */
55
- src: String,
56
- /**
57
- * Horizontal flip
58
- */
59
- horizontalFlip: Boolean,
60
- /**
61
- * Vertical flip
62
- */
63
- verticalFlip: Boolean,
33
+ src?: string
34
+ horizontalFlip?: boolean
35
+ verticalFlip?: boolean
64
36
  /**
65
37
  * String alternative to "horizontalFlip" and "verticalFlip".
66
38
  * Example: https://docs.iconify.design/icon-components/vue/transform.html
67
39
  */
68
- flip: String,
40
+ flip?: string
69
41
  /**
70
42
  * Icon render mode
71
43
  * 'style' = 'bg' or 'mask', depending on icon content
@@ -74,30 +46,32 @@ export const VvIconProps = {
74
46
  * 'svg' = svg
75
47
  * Iconify doc: https://docs.iconify.design/iconify-icon/modes.html
76
48
  */
77
- mode: String as PropType<`${IconifyRenderMode}`>,
49
+ mode?: IconifyRenderMode
78
50
  /**
79
51
  * Toggles inline or block mode
80
52
  * Example https://docs.iconify.design/icon-components/vue/inline.html
81
53
  */
82
- inline: Boolean,
54
+ inline?: boolean
83
55
  /**
84
56
  * rotates icon
85
57
  * Example https://docs.iconify.design/icon-components/vue/transform.html
86
58
  */
87
- rotate: [Number, String],
59
+ rotate?: number | string
88
60
  /**
89
61
  * A callback that is called when icon data has been loaded
90
62
  */
91
- onLoad: Function as PropType<IconifyIconOnLoad>,
63
+ onLoad?: IconifyIconOnLoad
92
64
  /**
93
65
  * SVG icon string
94
66
  */
95
- svg: String,
67
+ svg?: string
96
68
  /**
97
69
  * Icon modifiers: vv-icon css helper classes, value/s are concatened with prefix 'vv-icon--'
98
70
  * @values string | string[]
99
71
  */
100
- modifiers: {
101
- type: [String, Array] as PropType<string | string[]>,
102
- },
72
+ modifiers?: string | string[]
73
+ }
74
+
75
+ export const VvIconPropsDefaults = {
76
+ prefix: IconPrefix.normal,
103
77
  }
@@ -155,14 +155,17 @@
155
155
  localModelValue.value = toReturn
156
156
  }
157
157
 
158
+ const currentFileIndex = ref(0)
158
159
  const previewSrc = computed(() => {
159
160
  if (files.value.length === 0) {
160
161
  return
161
162
  }
162
- if (files.value[0] instanceof File) {
163
- return URL.createObjectURL(files.value[0])
163
+ if (files.value[currentFileIndex.value] instanceof File) {
164
+ return URL.createObjectURL(
165
+ files.value[currentFileIndex.value] as File,
166
+ )
164
167
  }
165
- return files.value[0].url
168
+ return (files.value[currentFileIndex.value] as UploadedFile).url
166
169
  })
167
170
 
168
171
  onBeforeUnmount(() => {
@@ -177,6 +180,18 @@
177
180
  }
178
181
  return Math.floor(size / 1024)
179
182
  }
183
+
184
+ const onClickDownloadFile = (file: File | UploadedFile) => {
185
+ const link = document.createElement('a')
186
+ if (file instanceof File) {
187
+ link.href = URL.createObjectURL(file)
188
+ } else if (file.url) {
189
+ link.href = file.url
190
+ }
191
+ link.setAttribute('download', file.name)
192
+ document.body.appendChild(link)
193
+ link.click()
194
+ }
180
195
  </script>
181
196
 
182
197
  <template>
@@ -201,7 +216,7 @@
201
216
  :class="{
202
217
  'absolute top-8 right-8': previewSrc,
203
218
  }"
204
- :icon="!previewSrc ? 'image' : 'edit'"
219
+ :icon="!previewSrc ? 'image' : isMultiple ? 'add' : 'edit'"
205
220
  class="z-1"
206
221
  @click.stop="onClick"
207
222
  />
@@ -209,7 +224,7 @@
209
224
  <img
210
225
  v-if="previewSrc"
211
226
  :src="previewSrc"
212
- :alt="files[0].name"
227
+ :alt="files[currentFileIndex].name"
213
228
  />
214
229
  </picture>
215
230
  </slot>
@@ -238,12 +253,20 @@
238
253
  v-for="(file, index) in files"
239
254
  :key="index"
240
255
  class="vv-input-file__item"
256
+ @click.stop="currentFileIndex = index"
241
257
  >
242
- <VvIcon
243
- class="vv-input-file__item-icon"
244
- name="akar-icons:file"
245
- />
246
- <div class="vv-input-file__item-name">{{ file.name }}</div>
258
+ <button
259
+ type="button"
260
+ class="vv-input-file__item-icon cursor-pointer"
261
+ title="Download"
262
+ aria-label="download-file"
263
+ @click.stop="onClickDownloadFile(file)"
264
+ >
265
+ <VvIcon name="download" />
266
+ </button>
267
+ <div class="vv-input-file__item-name cursor-pointer">
268
+ {{ file.name }}
269
+ </div>
247
270
  <small class="vv-input-file__item-info">
248
271
  {{ sizeInKiB(file.size) }} KB
249
272
  </small>
@@ -249,11 +249,11 @@
249
249
  }
250
250
 
251
251
  // icons
252
- const { hasIcon, hasIconBefore, hasIconAfter } = useComponentIcon(
253
- icon,
254
- iconPosition,
255
- )
256
- const defaultAfterIcon = computed(() => {
252
+ const { hasIconBefore, hasIconAfter } = useComponentIcon(icon, iconPosition)
253
+ const iconAfter = computed(() => {
254
+ if (hasIconAfter.value !== undefined) {
255
+ return hasIconAfter.value
256
+ }
257
257
  switch (props.type) {
258
258
  case INPUT_TYPES.COLOR:
259
259
  return { name: TYPES_ICON.COLOR }
@@ -264,9 +264,8 @@
264
264
  return { name: TYPES_ICON.DATE }
265
265
  case INPUT_TYPES.TIME:
266
266
  return { name: TYPES_ICON.TIME }
267
- default:
268
- return ''
269
267
  }
268
+ return undefined
270
269
  })
271
270
 
272
271
  // count
@@ -307,8 +306,8 @@
307
306
  loading: loading.value,
308
307
  disabled: props.disabled,
309
308
  readonly: props.readonly,
310
- 'icon-before': hasIconBefore.value,
311
- 'icon-after': hasIconAfter.value || !isEmpty(defaultAfterIcon),
309
+ 'icon-before': hasIconBefore.value !== undefined,
310
+ 'icon-after': iconAfter.value !== undefined,
312
311
  floating: props.floating && !isEmpty(props.label),
313
312
  dirty: isDirty.value,
314
313
  focus: isFocused.value,
@@ -476,8 +475,8 @@
476
475
  >
477
476
  <VvIcon
478
477
  v-if="hasIconBefore"
478
+ v-bind="hasIconBefore"
479
479
  class="vv-input-text__icon"
480
- v-bind="hasIcon"
481
480
  />
482
481
  <input
483
482
  :id="hasId"
@@ -500,9 +499,9 @@
500
499
  </div>
501
500
  <!-- @slot Slot to replace right icon -->
502
501
  <VvIcon
503
- v-if="hasIconAfter || defaultAfterIcon"
502
+ v-if="iconAfter"
503
+ v-bind="iconAfter"
504
504
  class="vv-input-text__icon vv-input-text__icon-after"
505
- v-bind="hasIconAfter ? hasIcon : defaultAfterIcon"
506
505
  />
507
506
  <PasswordInputActions
508
507
  v-else-if="isPassword && !hideActions && isClickable"
@@ -65,10 +65,7 @@
65
65
  })
66
66
 
67
67
  // icons
68
- const { hasIcon, hasIconBefore, hasIconAfter } = useComponentIcon(
69
- icon,
70
- iconPosition,
71
- )
68
+ const { hasIconBefore, hasIconAfter } = useComponentIcon(icon, iconPosition)
72
69
 
73
70
  // dirty
74
71
  const isDirty = computed(() => !isEmpty(props.modelValue))
@@ -100,8 +97,8 @@
100
97
  loading: loading.value,
101
98
  disabled: disabled.value,
102
99
  readonly: readonly.value,
103
- 'icon-before': hasIconBefore.value,
104
- 'icon-after': hasIconAfter.value,
100
+ 'icon-before': hasIconBefore.value !== undefined,
101
+ 'icon-after': hasIconAfter.value !== undefined,
105
102
  dirty: isDirty.value,
106
103
  focus: focused.value,
107
104
  floating: floating.value,
@@ -174,8 +171,8 @@
174
171
  <div class="vv-select__inner">
175
172
  <VvIcon
176
173
  v-if="hasIconBefore"
174
+ v-bind="hasIconBefore"
177
175
  class="vv-select__icon"
178
- v-bind="hasIcon"
179
176
  />
180
177
  <select
181
178
  :id="hasId"
@@ -219,8 +216,8 @@
219
216
  </select>
220
217
  <VvIcon
221
218
  v-if="hasIconAfter"
219
+ v-bind="hasIconAfter"
222
220
  class="vv-select__icon vv-select__icon-after"
223
- v-bind="hasIcon"
224
221
  />
225
222
  </div>
226
223
  <div v-if="$slots.after" class="vv-select__input-after">
@@ -52,10 +52,7 @@
52
52
  const localModelValue = useDebouncedInput(modelValue, emit, debounce?.value)
53
53
 
54
54
  // icons
55
- const { hasIcon, hasIconBefore, hasIconAfter } = useComponentIcon(
56
- icon,
57
- iconPosition,
58
- )
55
+ const { hasIconBefore, hasIconAfter } = useComponentIcon(icon, iconPosition)
59
56
 
60
57
  // focus
61
58
  const { focused } = useComponentFocus(textarea, emit)
@@ -113,8 +110,8 @@
113
110
  loading: loading.value,
114
111
  disabled: props.disabled,
115
112
  readonly: props.readonly,
116
- 'icon-before': hasIconBefore.value,
117
- 'icon-after': hasIconAfter.value,
113
+ 'icon-before': hasIconBefore.value !== undefined,
114
+ 'icon-after': hasIconAfter.value !== undefined,
118
115
  floating: props.floating && !isEmpty(props.label),
119
116
  dirty: isDirty.value,
120
117
  focus: focused.value,
@@ -180,8 +177,8 @@
180
177
  <div class="vv-textarea__inner">
181
178
  <VvIcon
182
179
  v-if="hasIconBefore"
180
+ v-bind="hasIconBefore"
183
181
  class="vv-textarea__icon"
184
- v-bind="hasIcon"
185
182
  />
186
183
  <textarea
187
184
  :id="hasId"
@@ -192,8 +189,8 @@
192
189
  />
193
190
  <VvIcon
194
191
  v-if="hasIconAfter"
192
+ v-bind="hasIconAfter"
195
193
  class="vv-textarea__icon vv-textarea__icon-after"
196
- v-bind="hasIcon"
197
194
  />
198
195
  </div>
199
196
  <div v-if="$slots.after" class="vv-textarea__input-after">
@@ -1,34 +1,35 @@
1
1
  import type { Ref } from 'vue'
2
+ import type { VvIconProps } from '../components/VvIcon'
2
3
  import { Position, Side } from '../constants'
3
4
 
4
5
  export function useComponentIcon(
5
- icon: Ref<string | object | undefined> | undefined,
6
- iconPosition: Ref<string>,
6
+ icon?: Ref<string | VvIconProps | undefined>,
7
+ iconPosition?: Ref<string | undefined>,
7
8
  ) {
9
+ const hasIcon = computed(() => {
10
+ if (typeof icon?.value === 'string') {
11
+ return { name: icon?.value }
12
+ }
13
+ return icon?.value
14
+ })
8
15
  const hasIconBefore = computed(() =>
9
- Boolean(icon?.value && iconPosition.value === Position.before),
16
+ iconPosition?.value === Position.before ? hasIcon.value : undefined,
10
17
  )
11
18
  const hasIconAfter = computed(() =>
12
- Boolean(icon?.value && iconPosition.value === Position.after),
19
+ iconPosition?.value === Position.after ? hasIcon.value : undefined,
13
20
  )
14
21
  const hasIconLeft = computed(() =>
15
- Boolean(icon?.value && iconPosition.value === Side.left),
22
+ iconPosition?.value === Side.left ? hasIcon.value : undefined,
16
23
  )
17
24
  const hasIconRight = computed(() =>
18
- Boolean(icon?.value && iconPosition.value === Side.right),
25
+ iconPosition?.value === Side.right ? hasIcon.value : undefined,
19
26
  )
20
27
  const hasIconTop = computed(() =>
21
- Boolean(icon?.value && iconPosition.value === Side.top),
28
+ iconPosition?.value === Side.top ? hasIcon.value : undefined,
22
29
  )
23
30
  const hasIconBottom = computed(() =>
24
- Boolean(icon?.value && iconPosition.value === Side.bottom),
31
+ iconPosition?.value === Side.bottom ? hasIcon.value : undefined,
25
32
  )
26
- const hasIcon = computed(() => {
27
- if (typeof icon?.value === 'string') {
28
- return { name: icon?.value }
29
- }
30
- return icon?.value
31
- })
32
33
  return {
33
34
  hasIcon,
34
35
  hasIconLeft,