@volverjs/ui-vue 0.0.6-beta.5 → 0.0.6-beta.7
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/auto-imports.d.ts +9 -0
- package/dist/Volver.d.ts +1 -1
- package/dist/components/VvAccordion/index.d.ts +1 -1
- package/dist/components/VvButton/VvButton.es.js +25 -19
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.es.js +151 -98
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +37 -1
- package/dist/components/VvCheckbox/index.d.ts +6 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +187 -101
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +36 -0
- package/dist/components/VvCheckboxGroup/index.d.ts +5 -0
- package/dist/components/VvCombobox/VvCombobox.es.js +236 -140
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +25 -1
- package/dist/components/VvDialog/VvDialog.es.js +25 -19
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +19 -4
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +8 -4
- package/dist/components/VvDropdown/index.d.ts +1 -1
- package/dist/components/VvIcon/VvIcon.es.js +25 -19
- package/dist/components/VvIcon/VvIcon.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.vue.d.ts +2 -2
- package/dist/components/VvIcon/index.d.ts +2 -2
- package/dist/components/VvInputText/VvInputText.es.js +160 -136
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +24 -0
- package/dist/components/VvRadio/VvRadio.es.js +151 -98
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +37 -1
- package/dist/components/VvRadio/index.d.ts +6 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +187 -101
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +36 -0
- package/dist/components/VvRadioGroup/index.d.ts +5 -0
- package/dist/components/VvSelect/VvSelect.es.js +163 -137
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +24 -0
- package/dist/components/VvTextarea/VvTextarea.es.js +160 -136
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +24 -0
- package/dist/components/common/HintSlot.d.ts +38 -12
- package/dist/components/index.es.js +466 -168
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/group/useInjectedGroupState.d.ts +1 -1
- package/dist/composables/useOptions.d.ts +2 -2
- package/dist/directives/index.d.ts +2 -2
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +22 -0
- package/package.json +33 -33
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvCheckbox/VvCheckbox.vue +23 -2
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +15 -2
- package/src/components/VvCombobox/VvCombobox.vue +40 -16
- package/src/components/VvDropdown/VvDropdown.vue +20 -2
- package/src/components/VvIcon/VvIcon.vue +37 -34
- package/src/components/VvIcon/index.ts +2 -2
- package/src/components/VvInputText/VvInputText.vue +26 -9
- package/src/components/VvRadio/VvRadio.vue +23 -2
- package/src/components/VvRadioGroup/VvRadioGroup.vue +15 -2
- package/src/components/VvSelect/VvSelect.vue +26 -9
- package/src/components/VvTextarea/VvTextarea.vue +26 -9
- package/src/components/common/HintSlot.ts +129 -170
- package/src/composables/useOptions.ts +9 -7
- package/src/props/index.ts +2 -0
|
@@ -1,202 +1,161 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExtractPropTypes, Slots } from 'vue'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Merge
|
|
5
|
-
* @param {string[] | string}
|
|
4
|
+
* Merge array of string
|
|
5
|
+
* @param {string[] | string} items
|
|
6
6
|
* @returns {string}
|
|
7
7
|
*/
|
|
8
|
-
function joinLines(
|
|
9
|
-
if (Array.isArray(
|
|
10
|
-
return
|
|
8
|
+
function joinLines(items: string[] | string | unknown[] | undefined) {
|
|
9
|
+
if (Array.isArray(items)) {
|
|
10
|
+
return items.filter((item) => isString(item)).join(' ')
|
|
11
11
|
}
|
|
12
|
-
return
|
|
12
|
+
return items
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
15
|
+
export type HintSlotProps = Readonly<
|
|
16
|
+
ExtractPropTypes<{
|
|
17
|
+
hintLabel: {
|
|
18
|
+
type: StringConstructor
|
|
19
|
+
default: ''
|
|
20
|
+
required: true
|
|
21
|
+
}
|
|
22
|
+
modelValue: null
|
|
23
|
+
valid: BooleanConstructor
|
|
24
|
+
validLabel: (StringConstructor | ArrayConstructor)[]
|
|
25
|
+
invalid: BooleanConstructor
|
|
26
|
+
invalidLabel: (StringConstructor | ArrayConstructor)[]
|
|
27
|
+
loading: BooleanConstructor
|
|
28
|
+
loadingLabel: StringConstructor
|
|
29
|
+
}>
|
|
30
|
+
>
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
33
|
* Return a vue component (HintSlot) to render and manage hint, errors, valid, loading state and messages
|
|
35
|
-
* @param {
|
|
34
|
+
* @param {HintSlotProps} parentProps vue props
|
|
36
35
|
* @param {Slots} parentSlots vue slots
|
|
37
36
|
* @returns {Component} vue component
|
|
38
37
|
*/
|
|
39
|
-
export function HintSlotFactory(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
hasLoading: Ref<boolean>
|
|
50
|
-
} {
|
|
51
|
-
// slots
|
|
52
|
-
const {
|
|
53
|
-
invalid: invalidSlot,
|
|
54
|
-
valid: validSlot,
|
|
55
|
-
hint: hintSlot,
|
|
56
|
-
loading: loadingSlot,
|
|
57
|
-
} = parentSlots
|
|
58
|
-
|
|
59
|
-
// props
|
|
60
|
-
const {
|
|
61
|
-
hintLabel,
|
|
62
|
-
modelValue,
|
|
63
|
-
valid,
|
|
64
|
-
validLabel,
|
|
65
|
-
invalid,
|
|
66
|
-
invalidLabel,
|
|
67
|
-
...otherProps
|
|
68
|
-
} = toRefs(parentProps)
|
|
69
|
-
|
|
70
|
-
const loading = resolveFieldData(otherProps, 'loading') as
|
|
71
|
-
| Ref<boolean>
|
|
72
|
-
| undefined
|
|
73
|
-
const loadingLabel = resolveFieldData(otherProps, 'loadingLabel') as
|
|
74
|
-
| Ref<string>
|
|
75
|
-
| undefined
|
|
76
|
-
|
|
77
|
-
const hasInvalid = computed(() => {
|
|
78
|
-
if (!invalid.value) {
|
|
79
|
-
return false
|
|
80
|
-
}
|
|
81
|
-
if (invalid.value && invalidSlot) {
|
|
82
|
-
return true
|
|
83
|
-
}
|
|
84
|
-
if (
|
|
85
|
-
invalidLabel?.value &&
|
|
86
|
-
Array.isArray(invalidLabel.value) &&
|
|
87
|
-
invalidLabel.value.length > 0
|
|
88
|
-
) {
|
|
89
|
-
return true
|
|
90
|
-
}
|
|
91
|
-
if (invalidLabel?.value && !isEmpty(invalidLabel)) {
|
|
92
|
-
return true
|
|
93
|
-
}
|
|
94
|
-
return false
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
const hasHint = computed(
|
|
98
|
-
() => !!((hintLabel && hintLabel.value) || hintSlot),
|
|
38
|
+
export function HintSlotFactory(props: HintSlotProps, slots: Slots) {
|
|
39
|
+
// label
|
|
40
|
+
const invalidLabel = computed(() => joinLines(props.invalidLabel))
|
|
41
|
+
const validLabel = computed(() => joinLines(props.validLabel))
|
|
42
|
+
const loadingLabel = computed(() => props.loadingLabel)
|
|
43
|
+
const hintLabel = computed(() => props.hintLabel)
|
|
44
|
+
|
|
45
|
+
// type
|
|
46
|
+
const hasLoadingLabelOrSlot = computed(() =>
|
|
47
|
+
Boolean(props.loading && (slots.loading || loadingLabel.value)),
|
|
99
48
|
)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
49
|
+
const hasInvalidLabelOrSlot = computed(
|
|
50
|
+
() =>
|
|
51
|
+
!hasLoadingLabelOrSlot.value &&
|
|
52
|
+
Boolean(props.invalid && (slots.invalid || invalidLabel.value)),
|
|
103
53
|
)
|
|
104
|
-
|
|
105
|
-
const hasLoading = computed(
|
|
54
|
+
const hasValidLabelOrSlot = computed(
|
|
106
55
|
() =>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
56
|
+
!hasLoadingLabelOrSlot.value &&
|
|
57
|
+
!hasInvalidLabelOrSlot.value &&
|
|
58
|
+
Boolean(props.valid && (slots.valid || validLabel.value)),
|
|
59
|
+
)
|
|
60
|
+
const hasHintLabelOrSlot = computed(
|
|
61
|
+
() =>
|
|
62
|
+
!hasLoadingLabelOrSlot.value &&
|
|
63
|
+
!hasInvalidLabelOrSlot.value &&
|
|
64
|
+
!hasValidLabelOrSlot.value &&
|
|
65
|
+
Boolean(slots.hint || hintLabel.value),
|
|
111
66
|
)
|
|
112
|
-
|
|
113
67
|
const isVisible = computed(
|
|
114
68
|
() =>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
69
|
+
hasInvalidLabelOrSlot.value ||
|
|
70
|
+
hasValidLabelOrSlot.value ||
|
|
71
|
+
hasLoadingLabelOrSlot.value ||
|
|
72
|
+
hasHintLabelOrSlot.value,
|
|
119
73
|
)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
74
|
+
const hintSlotScope = computed(() => ({
|
|
75
|
+
modelValue: props.modelValue,
|
|
76
|
+
valid: props.valid,
|
|
77
|
+
invalid: props.invalid,
|
|
78
|
+
loading: props.loading,
|
|
79
|
+
}))
|
|
80
|
+
// component
|
|
81
|
+
const HintSlot = defineComponent({
|
|
82
|
+
name: 'HintSlot',
|
|
83
|
+
props: {
|
|
84
|
+
tag: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: 'small',
|
|
133
87
|
},
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return (
|
|
165
|
-
loadingSlot?.(slotProps) ||
|
|
166
|
-
joinLines(loadingLabel?.value) ||
|
|
167
|
-
hintLabel?.value
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
return (
|
|
171
|
-
hintSlot?.(slotProps) ||
|
|
172
|
-
joinLines(hintLabel?.value) ||
|
|
173
|
-
hintLabel?.value
|
|
88
|
+
},
|
|
89
|
+
setup() {
|
|
90
|
+
return {
|
|
91
|
+
isVisible,
|
|
92
|
+
invalidLabel,
|
|
93
|
+
validLabel,
|
|
94
|
+
loadingLabel,
|
|
95
|
+
hintLabel,
|
|
96
|
+
hasInvalidLabelOrSlot,
|
|
97
|
+
hasValidLabelOrSlot,
|
|
98
|
+
hasLoadingLabelOrSlot,
|
|
99
|
+
hasHintLabelOrSlot,
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
render() {
|
|
103
|
+
if (this.isVisible) {
|
|
104
|
+
let role
|
|
105
|
+
if (this.hasInvalidLabelOrSlot) {
|
|
106
|
+
role = 'alert'
|
|
107
|
+
}
|
|
108
|
+
if (this.hasValidLabelOrSlot) {
|
|
109
|
+
role = 'status'
|
|
110
|
+
}
|
|
111
|
+
if (this.hasLoadingLabelOrSlot) {
|
|
112
|
+
return h(
|
|
113
|
+
this.tag,
|
|
114
|
+
{
|
|
115
|
+
role,
|
|
116
|
+
},
|
|
117
|
+
this.$slots.loading?.() ?? this.loadingLabel,
|
|
174
118
|
)
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
isVisible,
|
|
179
|
-
hasInvalid,
|
|
180
|
-
hasValid,
|
|
181
|
-
hintContent,
|
|
182
119
|
}
|
|
183
|
-
|
|
184
|
-
render() {
|
|
185
|
-
if (this.isVisible) {
|
|
120
|
+
if (this.hasInvalidLabelOrSlot) {
|
|
186
121
|
return h(
|
|
187
|
-
|
|
122
|
+
this.tag,
|
|
188
123
|
{
|
|
189
|
-
role
|
|
190
|
-
? 'alert'
|
|
191
|
-
: this.hasValid
|
|
192
|
-
? 'status'
|
|
193
|
-
: undefined,
|
|
124
|
+
role,
|
|
194
125
|
},
|
|
195
|
-
this.
|
|
126
|
+
this.$slots.invalid?.() ??
|
|
127
|
+
this.$slots.invalid ??
|
|
128
|
+
this.invalidLabel,
|
|
196
129
|
)
|
|
197
130
|
}
|
|
198
|
-
|
|
131
|
+
if (this.hasValidLabelOrSlot) {
|
|
132
|
+
return h(
|
|
133
|
+
this.tag,
|
|
134
|
+
{
|
|
135
|
+
role,
|
|
136
|
+
},
|
|
137
|
+
this.$slots.valid?.() ?? this.validLabel,
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
return h(
|
|
141
|
+
this.tag,
|
|
142
|
+
{
|
|
143
|
+
role,
|
|
144
|
+
},
|
|
145
|
+
this.$slots.hint?.() ?? this.$slots.hint ?? this.hintLabel,
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
return null
|
|
199
149
|
},
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
hasInvalidLabelOrSlot,
|
|
154
|
+
hasHintLabelOrSlot,
|
|
155
|
+
hasValidLabelOrSlot,
|
|
156
|
+
hasLoadingLabelOrSlot,
|
|
157
|
+
hintSlotScope,
|
|
158
|
+
HintSlot,
|
|
200
159
|
}
|
|
201
160
|
}
|
|
202
161
|
|
|
@@ -5,12 +5,14 @@ export function useOptions(props: any) {
|
|
|
5
5
|
const { options, labelKey, valueKey, disabledKey } = toRefs(props)
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line
|
|
8
|
-
const getOptionLabel = (option: string | Option) => {
|
|
8
|
+
const getOptionLabel = (option: string | Option): string => {
|
|
9
9
|
if (typeof option !== 'object' && option !== null) return option
|
|
10
10
|
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
return String(
|
|
12
|
+
typeof labelKey.value === 'function'
|
|
13
|
+
? labelKey.value(option)
|
|
14
|
+
: option[labelKey.value],
|
|
15
|
+
)
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
const getOptionValue = (option: string | Option) => {
|
|
@@ -21,7 +23,7 @@ export function useOptions(props: any) {
|
|
|
21
23
|
: option[valueKey.value]
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
const getOptionDisabled = (option: string | Option) => {
|
|
26
|
+
const getOptionDisabled = (option: string | Option): boolean => {
|
|
25
27
|
if (typeof option !== 'object' && option !== null) return false
|
|
26
28
|
|
|
27
29
|
return typeof disabledKey.value === 'function'
|
|
@@ -30,7 +32,7 @@ export function useOptions(props: any) {
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
const getOptionGrouped = (option: string | Option) => {
|
|
33
|
-
|
|
35
|
+
if (typeof option !== 'object' && option !== null) return []
|
|
34
36
|
return option.options || []
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -39,6 +41,6 @@ export function useOptions(props: any) {
|
|
|
39
41
|
getOptionLabel,
|
|
40
42
|
getOptionValue,
|
|
41
43
|
getOptionDisabled,
|
|
42
|
-
getOptionGrouped
|
|
44
|
+
getOptionGrouped,
|
|
43
45
|
}
|
|
44
46
|
}
|
package/src/props/index.ts
CHANGED
|
@@ -406,6 +406,7 @@ export const CheckboxRadioProps = {
|
|
|
406
406
|
...ReadonlyProps,
|
|
407
407
|
...ModifiersProps,
|
|
408
408
|
...LabelProps,
|
|
409
|
+
...LoadingProps,
|
|
409
410
|
/**
|
|
410
411
|
* Input value
|
|
411
412
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value
|
|
@@ -426,6 +427,7 @@ export const CheckboxRadioGroupProps = {
|
|
|
426
427
|
...ReadonlyProps,
|
|
427
428
|
...ModifiersProps,
|
|
428
429
|
...LabelProps,
|
|
430
|
+
...LoadingProps,
|
|
429
431
|
/**
|
|
430
432
|
* Input value
|
|
431
433
|
*/
|