@coreui/vue-pro 4.3.0-beta.0 → 4.3.1
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/README.md +113 -5
- package/dist/components/accordion/index.d.ts +1 -2
- package/dist/components/calendar/CCalendar.d.ts +15 -2
- package/dist/components/carousel/CCarousel.d.ts +1 -1
- package/dist/components/date-picker/CDatePicker.d.ts +24 -2
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +102 -3
- package/dist/components/form/CFormCheck.d.ts +88 -39
- package/dist/components/form/CFormControlValidation.d.ts +98 -0
- package/dist/components/form/CFormControlWrapper.d.ts +6 -0
- package/dist/components/form/CFormFeedback.d.ts +2 -2
- package/dist/components/form/CFormInput.d.ts +133 -27
- package/dist/components/form/CFormRange.d.ts +18 -16
- package/dist/components/form/CFormSelect.d.ts +125 -16
- package/dist/components/form/CFormSwitch.d.ts +0 -23
- package/dist/components/form/CFormTextarea.d.ts +125 -24
- package/dist/components/modal/CModal.d.ts +1 -1
- package/dist/components/offcanvas/COffcanvas.d.ts +1 -1
- package/dist/components/smart-table/CSmartTable.d.ts +34 -98
- package/dist/components/smart-table/CSmartTableInterface.d.ts +3 -3
- package/dist/components/time-picker/CTimePicker.d.ts +1 -1
- package/dist/components/toast/CToast.d.ts +7 -1
- package/dist/components/widgets/CWidgetStatsB.d.ts +3 -8
- package/dist/components/widgets/CWidgetStatsC.d.ts +3 -8
- package/dist/directives/v-c-popover.d.ts +1 -1
- package/dist/directives/v-c-tooltip.d.ts +1 -1
- package/dist/index.es.js +5523 -644
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +5522 -644
- package/dist/index.js.map +1 -1
- package/dist/utils/calendar.d.ts +4 -2
- package/dist/utils/time.d.ts +6 -2
- package/dist/utils/transition.d.ts +3 -0
- package/package.json +12 -11
- package/src/components/accordion/index.ts +0 -3
- package/src/components/backdrop/CBackdrop.ts +8 -6
- package/src/components/button/CButton.ts +2 -2
- package/src/components/calendar/CCalendar.ts +132 -62
- package/src/components/close-button/CCloseButton.ts +1 -0
- package/src/components/close-button/__tests__/__snapshots__/CCloseButton.spec.ts.snap +2 -2
- package/src/components/collapse/CCollapse.ts +5 -6
- package/src/components/date-picker/CDatePicker.ts +14 -10
- package/src/components/date-range-picker/CDateRangePicker.ts +209 -100
- package/src/components/form/CFormCheck.ts +118 -95
- package/src/components/form/CFormControlValidation.ts +97 -0
- package/src/components/form/CFormControlWrapper.ts +106 -0
- package/src/components/form/CFormInput.ts +115 -30
- package/src/components/form/CFormRange.ts +25 -11
- package/src/components/form/CFormSelect.ts +127 -41
- package/src/components/form/CFormSwitch.ts +2 -21
- package/src/components/form/CFormTextarea.ts +113 -25
- package/src/components/form/__tests__/CFormInput.spec.ts +11 -11
- package/src/components/form/__tests__/CFormRange.spec.ts +9 -9
- package/src/components/form/__tests__/CFormSelect.spec.ts +4 -4
- package/src/components/form/__tests__/CFormTextarea.spec.ts +4 -4
- package/src/components/form/__tests__/__snapshots__/CFormCheck.spec.ts.snap +8 -2
- package/src/components/form/__tests__/__snapshots__/CFormRange.spec.ts.snap +1 -1
- package/src/components/modal/CModal.ts +14 -6
- package/src/components/modal/__tests__/__snapshots__/CModal.spec.ts.snap +1 -2
- package/src/components/modal/__tests__/__snapshots__/CModalHeader.spec.ts.snap +2 -2
- package/src/components/nav/CNavGroup.ts +4 -6
- package/src/components/offcanvas/COffcanvas.ts +5 -7
- package/src/components/pagination/CSmartPagination.ts +4 -4
- package/src/components/picker/CPicker.ts +1 -0
- package/src/components/popover/CPopover.ts +5 -5
- package/src/components/sidebar/__tests__/__snapshots__/CSidebar.spec.ts.snap +2 -8
- package/src/components/smart-table/CSmartTable.ts +17 -49
- package/src/components/smart-table/CSmartTableInterface.ts +5 -3
- package/src/components/tabs/CTabPane.ts +4 -6
- package/src/components/time-picker/CTimePicker.ts +12 -17
- package/src/components/toast/CToast.ts +17 -12
- package/src/components/toast/__tests__/__snapshots__/CToastClose.spec.ts.snap +1 -1
- package/src/components/toast/__tests__/__snapshots__/CToastHeader.spec.ts.snap +1 -1
- package/src/components/tooltip/CTooltip.ts +5 -5
- package/src/directives/v-c-popover.ts +1 -1
- package/src/directives/v-c-tooltip.ts +1 -1
- package/src/utils/calendar.ts +86 -9
- package/src/utils/time.ts +29 -3
- package/src/utils/transition.ts +65 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineComponent, h } from 'vue'
|
|
2
|
+
import { CFormLabel } from './CFormLabel'
|
|
2
3
|
|
|
3
4
|
const CFormRange = defineComponent({
|
|
4
5
|
name: 'CFormRange',
|
|
@@ -9,7 +10,14 @@ const CFormRange = defineComponent({
|
|
|
9
10
|
disabled: {
|
|
10
11
|
type: Boolean,
|
|
11
12
|
default: undefined,
|
|
12
|
-
|
|
13
|
+
},
|
|
14
|
+
/**
|
|
15
|
+
* Add a caption for a component.
|
|
16
|
+
*
|
|
17
|
+
* @since 4.3.0
|
|
18
|
+
*/
|
|
19
|
+
label: {
|
|
20
|
+
type: String,
|
|
13
21
|
},
|
|
14
22
|
/**
|
|
15
23
|
* Specifies the maximum value for the component.
|
|
@@ -17,7 +25,6 @@ const CFormRange = defineComponent({
|
|
|
17
25
|
max: {
|
|
18
26
|
type: Number,
|
|
19
27
|
default: undefined,
|
|
20
|
-
required: false,
|
|
21
28
|
},
|
|
22
29
|
/**
|
|
23
30
|
* Specifies the minimum value for the component.
|
|
@@ -25,7 +32,6 @@ const CFormRange = defineComponent({
|
|
|
25
32
|
min: {
|
|
26
33
|
type: Number,
|
|
27
34
|
default: undefined,
|
|
28
|
-
required: false,
|
|
29
35
|
},
|
|
30
36
|
/**
|
|
31
37
|
* The default name for a value passed using v-model.
|
|
@@ -33,14 +39,12 @@ const CFormRange = defineComponent({
|
|
|
33
39
|
modelValue: {
|
|
34
40
|
type: String,
|
|
35
41
|
value: undefined,
|
|
36
|
-
required: false,
|
|
37
42
|
},
|
|
38
43
|
/**
|
|
39
44
|
* Toggle the readonly state for the component.
|
|
40
45
|
*/
|
|
41
46
|
readonly: {
|
|
42
47
|
type: Boolean,
|
|
43
|
-
required: false,
|
|
44
48
|
},
|
|
45
49
|
/**
|
|
46
50
|
* Specifies the interval between legal numbers in the component.
|
|
@@ -48,7 +52,6 @@ const CFormRange = defineComponent({
|
|
|
48
52
|
steps: {
|
|
49
53
|
type: Number,
|
|
50
54
|
default: undefined,
|
|
51
|
-
required: false,
|
|
52
55
|
},
|
|
53
56
|
/**
|
|
54
57
|
* The `value` attribute of component.
|
|
@@ -58,7 +61,6 @@ const CFormRange = defineComponent({
|
|
|
58
61
|
value: {
|
|
59
62
|
type: Number,
|
|
60
63
|
default: undefined,
|
|
61
|
-
required: false,
|
|
62
64
|
},
|
|
63
65
|
},
|
|
64
66
|
emits: [
|
|
@@ -71,29 +73,41 @@ const CFormRange = defineComponent({
|
|
|
71
73
|
*/
|
|
72
74
|
'update:modelValue',
|
|
73
75
|
],
|
|
74
|
-
setup(props, { emit, slots }) {
|
|
76
|
+
setup(props, { attrs, emit, slots }) {
|
|
75
77
|
const handleChange = (event: InputEvent) => {
|
|
76
78
|
const target = event.target as HTMLInputElement
|
|
77
79
|
emit('change', event)
|
|
78
80
|
emit('update:modelValue', target.value)
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
return () =>
|
|
83
|
+
return () => [
|
|
84
|
+
props.label &&
|
|
85
|
+
h(
|
|
86
|
+
CFormLabel,
|
|
87
|
+
{
|
|
88
|
+
for: attrs.id,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
default: () => (slots.label && slots.label()) || props.label,
|
|
92
|
+
},
|
|
93
|
+
),
|
|
82
94
|
h(
|
|
83
95
|
'input',
|
|
84
96
|
{
|
|
97
|
+
...attrs,
|
|
85
98
|
class: 'form-range',
|
|
86
99
|
disabled: props.disabled,
|
|
87
100
|
max: props.max,
|
|
88
101
|
min: props.min,
|
|
89
102
|
onChange: (event: InputEvent) => handleChange(event),
|
|
90
|
-
steps: props.steps,
|
|
91
103
|
readonly: props.readonly,
|
|
104
|
+
steps: props.steps,
|
|
92
105
|
type: 'range',
|
|
93
106
|
value: props.modelValue,
|
|
94
107
|
},
|
|
95
108
|
slots.default && slots.default(),
|
|
96
|
-
)
|
|
109
|
+
),
|
|
110
|
+
]
|
|
97
111
|
},
|
|
98
112
|
})
|
|
99
113
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineComponent, h, PropType } from 'vue'
|
|
2
|
+
import { CFormControlWrapper } from './CFormControlWrapper'
|
|
2
3
|
|
|
3
4
|
type Option = {
|
|
4
5
|
disabled?: boolean
|
|
@@ -10,6 +11,38 @@ type Option = {
|
|
|
10
11
|
const CFormSelect = defineComponent({
|
|
11
12
|
name: 'CFormSelect',
|
|
12
13
|
props: {
|
|
14
|
+
/**
|
|
15
|
+
* Provide valuable, actionable feedback.
|
|
16
|
+
*
|
|
17
|
+
* @since 4.3.0
|
|
18
|
+
*/
|
|
19
|
+
feedback: {
|
|
20
|
+
type: String,
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* Provide valuable, actionable feedback.
|
|
24
|
+
*
|
|
25
|
+
* @since 4.3.0
|
|
26
|
+
*/
|
|
27
|
+
feedbackInvalid: {
|
|
28
|
+
type: String,
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Provide valuable, actionable invalid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
|
|
32
|
+
*
|
|
33
|
+
* @since 4.3.0
|
|
34
|
+
*/
|
|
35
|
+
feedbackValid: {
|
|
36
|
+
type: String,
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* Provide valuable, actionable valid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
|
|
40
|
+
*
|
|
41
|
+
* @since 4.3.0
|
|
42
|
+
*/
|
|
43
|
+
floatingLabel: {
|
|
44
|
+
type: String,
|
|
45
|
+
},
|
|
13
46
|
/**
|
|
14
47
|
* Specifies the number of visible options in a drop-down list.
|
|
15
48
|
*/
|
|
@@ -18,12 +51,23 @@ const CFormSelect = defineComponent({
|
|
|
18
51
|
default: undefined,
|
|
19
52
|
required: false,
|
|
20
53
|
},
|
|
54
|
+
/**
|
|
55
|
+
* The id global attribute defines an identifier (ID) that must be unique in the whole document.
|
|
56
|
+
*/
|
|
57
|
+
id: {
|
|
58
|
+
type: String,
|
|
59
|
+
},
|
|
21
60
|
/**
|
|
22
61
|
* Set component validation state to invalid.
|
|
23
62
|
*/
|
|
24
|
-
invalid:
|
|
25
|
-
|
|
26
|
-
|
|
63
|
+
invalid: Boolean,
|
|
64
|
+
/**
|
|
65
|
+
* Add a caption for a component.
|
|
66
|
+
*
|
|
67
|
+
* @since 4.3.0
|
|
68
|
+
*/
|
|
69
|
+
label: {
|
|
70
|
+
type: String,
|
|
27
71
|
},
|
|
28
72
|
/**
|
|
29
73
|
* The default name for a value passed using v-model.
|
|
@@ -62,12 +106,23 @@ const CFormSelect = defineComponent({
|
|
|
62
106
|
},
|
|
63
107
|
},
|
|
64
108
|
/**
|
|
65
|
-
*
|
|
109
|
+
* Add helper text to the component.
|
|
110
|
+
*
|
|
111
|
+
* @since 4.3.0
|
|
66
112
|
*/
|
|
67
|
-
|
|
68
|
-
type:
|
|
69
|
-
required: false,
|
|
113
|
+
text: {
|
|
114
|
+
type: String,
|
|
70
115
|
},
|
|
116
|
+
/**
|
|
117
|
+
* Display validation feedback in a styled tooltip.
|
|
118
|
+
*
|
|
119
|
+
* @since 4.3.0
|
|
120
|
+
*/
|
|
121
|
+
tooltipFeedback: Boolean,
|
|
122
|
+
/**
|
|
123
|
+
* Set component validation state to valid.
|
|
124
|
+
*/
|
|
125
|
+
valid: Boolean,
|
|
71
126
|
},
|
|
72
127
|
emits: [
|
|
73
128
|
/**
|
|
@@ -79,7 +134,7 @@ const CFormSelect = defineComponent({
|
|
|
79
134
|
*/
|
|
80
135
|
'update:modelValue',
|
|
81
136
|
],
|
|
82
|
-
setup(props, { emit, slots }) {
|
|
137
|
+
setup(props, { attrs, emit, slots }) {
|
|
83
138
|
const handleChange = (event: InputEvent) => {
|
|
84
139
|
const target = event.target as HTMLSelectElement
|
|
85
140
|
const selected = Array.from(target.options)
|
|
@@ -91,41 +146,72 @@ const CFormSelect = defineComponent({
|
|
|
91
146
|
|
|
92
147
|
return () =>
|
|
93
148
|
h(
|
|
94
|
-
|
|
149
|
+
CFormControlWrapper,
|
|
150
|
+
{
|
|
151
|
+
describedby: attrs['aria-describedby'],
|
|
152
|
+
feedback: props.feedback,
|
|
153
|
+
feedbackInvalid: props.feedbackInvalid,
|
|
154
|
+
feedbackValid: props.feedbackValid,
|
|
155
|
+
floatingLabel: props.floatingLabel,
|
|
156
|
+
id: props.id,
|
|
157
|
+
invalid: props.invalid,
|
|
158
|
+
label: props.label,
|
|
159
|
+
text: props.text,
|
|
160
|
+
tooltipFeedback: props.tooltipFeedback,
|
|
161
|
+
valid: props.valid,
|
|
162
|
+
},
|
|
95
163
|
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
164
|
+
default: () =>
|
|
165
|
+
h(
|
|
166
|
+
'select',
|
|
167
|
+
{
|
|
168
|
+
id: props.id,
|
|
169
|
+
...attrs,
|
|
170
|
+
class: [
|
|
171
|
+
'form-select',
|
|
172
|
+
{
|
|
173
|
+
[`form-select-${props.size}`]: props.size,
|
|
174
|
+
'is-invalid': props.invalid,
|
|
175
|
+
'is-valid': props.valid,
|
|
176
|
+
},
|
|
177
|
+
attrs.class,
|
|
178
|
+
],
|
|
179
|
+
multiple: props.multiple,
|
|
180
|
+
onChange: (event: InputEvent) => handleChange(event),
|
|
181
|
+
size: props.htmlSize,
|
|
182
|
+
...(props.modelValue && !props.multiple && { value: props.modelValue }),
|
|
183
|
+
},
|
|
184
|
+
props.options
|
|
185
|
+
? props.options.map((option: Option | string) => {
|
|
186
|
+
return h(
|
|
187
|
+
'option',
|
|
188
|
+
{
|
|
189
|
+
...(typeof option === 'object' && {
|
|
190
|
+
...(option.disabled && { disabled: option.disabled }),
|
|
191
|
+
...(option.selected && { selected: option.selected }),
|
|
192
|
+
...(option.value && {
|
|
193
|
+
value: option.value,
|
|
194
|
+
...(props.modelValue &&
|
|
195
|
+
props.multiple &&
|
|
196
|
+
props.modelValue.includes(option.value) && { selected: true }),
|
|
197
|
+
}),
|
|
198
|
+
}),
|
|
199
|
+
},
|
|
200
|
+
typeof option === 'string' ? option : option.label,
|
|
201
|
+
)
|
|
202
|
+
})
|
|
203
|
+
: slots.default && slots.default(),
|
|
204
|
+
),
|
|
205
|
+
...(slots.feedback && { feedback: () => slots.feedback && slots.feedback() }),
|
|
206
|
+
...(slots.feedbackInvalid && {
|
|
207
|
+
feedbackInvalid: () => slots.feedbackInvalid && slots.feedbackInvalid(),
|
|
208
|
+
}),
|
|
209
|
+
...(slots.feedbackValid && {
|
|
210
|
+
feedbackValid: () => slots.feedbackInvalid && slots.feedbackInvalid(),
|
|
211
|
+
}),
|
|
212
|
+
...(slots.label && { label: () => slots.label && slots.label() }),
|
|
213
|
+
...(slots.text && { text: () => slots.text && slots.text() }),
|
|
108
214
|
},
|
|
109
|
-
props.options
|
|
110
|
-
? props.options.map((option: Option | string) => {
|
|
111
|
-
return h(
|
|
112
|
-
'option',
|
|
113
|
-
{
|
|
114
|
-
...(typeof option === 'object' && {
|
|
115
|
-
...(option.disabled && { disabled: option.disabled }),
|
|
116
|
-
...(option.selected && { selected: option.selected }),
|
|
117
|
-
...(option.value && {
|
|
118
|
-
value: option.value,
|
|
119
|
-
...(props.modelValue &&
|
|
120
|
-
props.multiple &&
|
|
121
|
-
props.modelValue.includes(option.value) && { selected: true }),
|
|
122
|
-
}),
|
|
123
|
-
}),
|
|
124
|
-
},
|
|
125
|
-
typeof option === 'string' ? option : option.label,
|
|
126
|
-
)
|
|
127
|
-
})
|
|
128
|
-
: slots.default && slots.default(),
|
|
129
215
|
)
|
|
130
216
|
},
|
|
131
217
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, h
|
|
1
|
+
import { defineComponent, h } from 'vue'
|
|
2
2
|
|
|
3
3
|
import { CFormLabel } from './CFormLabel'
|
|
4
4
|
|
|
@@ -11,23 +11,18 @@ const CFormSwitch = defineComponent({
|
|
|
11
11
|
*/
|
|
12
12
|
id: {
|
|
13
13
|
type: String,
|
|
14
|
-
default: undefined,
|
|
15
|
-
required: false,
|
|
16
14
|
},
|
|
17
15
|
/**
|
|
18
16
|
* Set component validation state to invalid.
|
|
19
17
|
*/
|
|
20
18
|
invalid: {
|
|
21
19
|
type: Boolean,
|
|
22
|
-
required: false,
|
|
23
20
|
},
|
|
24
21
|
/**
|
|
25
22
|
* The element represents a caption for a component.
|
|
26
23
|
*/
|
|
27
24
|
label: {
|
|
28
25
|
type: String,
|
|
29
|
-
default: undefined,
|
|
30
|
-
required: false,
|
|
31
26
|
},
|
|
32
27
|
/**
|
|
33
28
|
* The default name for a value passed using v-model.
|
|
@@ -35,7 +30,6 @@ const CFormSwitch = defineComponent({
|
|
|
35
30
|
modelValue: {
|
|
36
31
|
type: [Boolean, String],
|
|
37
32
|
value: undefined,
|
|
38
|
-
required: false,
|
|
39
33
|
},
|
|
40
34
|
/**
|
|
41
35
|
* Size the component large or extra large. Works only with `switch`.
|
|
@@ -44,8 +38,6 @@ const CFormSwitch = defineComponent({
|
|
|
44
38
|
*/
|
|
45
39
|
size: {
|
|
46
40
|
type: String,
|
|
47
|
-
default: undefined,
|
|
48
|
-
required: false,
|
|
49
41
|
validator: (value: string) => {
|
|
50
42
|
return ['lg', 'xl'].includes(value)
|
|
51
43
|
},
|
|
@@ -58,14 +50,12 @@ const CFormSwitch = defineComponent({
|
|
|
58
50
|
type: {
|
|
59
51
|
type: String,
|
|
60
52
|
default: 'checkbox',
|
|
61
|
-
required: false,
|
|
62
53
|
},
|
|
63
54
|
/**
|
|
64
55
|
* Set component validation state to valid.
|
|
65
56
|
*/
|
|
66
57
|
valid: {
|
|
67
58
|
type: Boolean,
|
|
68
|
-
required: false,
|
|
69
59
|
},
|
|
70
60
|
},
|
|
71
61
|
emits: [
|
|
@@ -79,15 +69,6 @@ const CFormSwitch = defineComponent({
|
|
|
79
69
|
'update:modelValue',
|
|
80
70
|
],
|
|
81
71
|
setup(props, { attrs, emit }) {
|
|
82
|
-
const checked = ref(attrs.checked)
|
|
83
|
-
|
|
84
|
-
watch(
|
|
85
|
-
() => props.modelValue,
|
|
86
|
-
() => {
|
|
87
|
-
if (typeof props.modelValue === 'boolean') checked.value = props.modelValue
|
|
88
|
-
},
|
|
89
|
-
)
|
|
90
|
-
|
|
91
72
|
const handleChange = (event: InputEvent) => {
|
|
92
73
|
const target = event.target as HTMLInputElement
|
|
93
74
|
emit('change', event)
|
|
@@ -110,7 +91,7 @@ const CFormSwitch = defineComponent({
|
|
|
110
91
|
[
|
|
111
92
|
h('input', {
|
|
112
93
|
...attrs,
|
|
113
|
-
checked:
|
|
94
|
+
...(props.modelValue && { checked: props.modelValue }),
|
|
114
95
|
class: [
|
|
115
96
|
'form-check-input',
|
|
116
97
|
{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineComponent, h } from 'vue'
|
|
2
|
+
import { CFormControlWrapper } from './CFormControlWrapper'
|
|
2
3
|
|
|
3
4
|
const CFormTextarea = defineComponent({
|
|
4
5
|
name: 'CFormTextarea',
|
|
@@ -8,14 +9,56 @@ const CFormTextarea = defineComponent({
|
|
|
8
9
|
*/
|
|
9
10
|
disabled: {
|
|
10
11
|
type: Boolean,
|
|
11
|
-
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* Provide valuable, actionable feedback.
|
|
15
|
+
*
|
|
16
|
+
* @since 4.3.0
|
|
17
|
+
*/
|
|
18
|
+
feedback: {
|
|
19
|
+
type: String,
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* Provide valuable, actionable feedback.
|
|
23
|
+
*
|
|
24
|
+
* @since 4.3.0
|
|
25
|
+
*/
|
|
26
|
+
feedbackInvalid: {
|
|
27
|
+
type: String,
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* Provide valuable, actionable invalid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
|
|
31
|
+
*
|
|
32
|
+
* @since 4.3.0
|
|
33
|
+
*/
|
|
34
|
+
feedbackValid: {
|
|
35
|
+
type: String,
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Provide valuable, actionable valid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
|
|
39
|
+
*
|
|
40
|
+
* @since 4.3.0
|
|
41
|
+
*/
|
|
42
|
+
floatingLabel: {
|
|
43
|
+
type: String,
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* The id global attribute defines an identifier (ID) that must be unique in the whole document.
|
|
47
|
+
*/
|
|
48
|
+
id: {
|
|
49
|
+
type: String,
|
|
12
50
|
},
|
|
13
51
|
/**
|
|
14
52
|
* Set component validation state to invalid.
|
|
15
53
|
*/
|
|
16
|
-
invalid:
|
|
17
|
-
|
|
18
|
-
|
|
54
|
+
invalid: Boolean,
|
|
55
|
+
/**
|
|
56
|
+
* Add a caption for a component.
|
|
57
|
+
*
|
|
58
|
+
* @since 4.3.0
|
|
59
|
+
*/
|
|
60
|
+
label: {
|
|
61
|
+
type: String,
|
|
19
62
|
},
|
|
20
63
|
/**
|
|
21
64
|
* The default name for a value passed using v-model.
|
|
@@ -23,29 +66,37 @@ const CFormTextarea = defineComponent({
|
|
|
23
66
|
modelValue: {
|
|
24
67
|
type: String,
|
|
25
68
|
default: undefined,
|
|
26
|
-
require: false,
|
|
27
69
|
},
|
|
28
70
|
/**
|
|
29
71
|
* Render the component styled as plain text. Removes the default form field styling and preserve the correct margin and padding. Recommend to use only along side `readonly`.
|
|
30
72
|
*/
|
|
31
73
|
plainText: {
|
|
32
74
|
type: Boolean,
|
|
33
|
-
required: false,
|
|
34
75
|
},
|
|
35
76
|
/**
|
|
36
77
|
* Toggle the readonly state for the component.
|
|
37
78
|
*/
|
|
38
79
|
readonly: {
|
|
39
80
|
type: Boolean,
|
|
40
|
-
required: false,
|
|
41
81
|
},
|
|
42
82
|
/**
|
|
43
|
-
*
|
|
83
|
+
* Add helper text to the component.
|
|
84
|
+
*
|
|
85
|
+
* @since 4.3.0
|
|
44
86
|
*/
|
|
45
|
-
|
|
46
|
-
type:
|
|
47
|
-
required: false,
|
|
87
|
+
text: {
|
|
88
|
+
type: String,
|
|
48
89
|
},
|
|
90
|
+
/**
|
|
91
|
+
* Display validation feedback in a styled tooltip.
|
|
92
|
+
*
|
|
93
|
+
* @since 4.3.0
|
|
94
|
+
*/
|
|
95
|
+
tooltipFeedback: Boolean,
|
|
96
|
+
/**
|
|
97
|
+
* Set component validation state to valid.
|
|
98
|
+
*/
|
|
99
|
+
valid: Boolean,
|
|
49
100
|
},
|
|
50
101
|
emits: [
|
|
51
102
|
/**
|
|
@@ -61,7 +112,13 @@ const CFormTextarea = defineComponent({
|
|
|
61
112
|
*/
|
|
62
113
|
'update:modelValue',
|
|
63
114
|
],
|
|
64
|
-
setup(props, { emit, slots }) {
|
|
115
|
+
setup(props, { attrs, emit, slots }) {
|
|
116
|
+
const handleChange = (event: InputEvent) => {
|
|
117
|
+
const target = event.target as HTMLInputElement
|
|
118
|
+
emit('change', event)
|
|
119
|
+
emit('update:modelValue', target.value)
|
|
120
|
+
}
|
|
121
|
+
|
|
65
122
|
const handleInput = (event: InputEvent) => {
|
|
66
123
|
const target = event.target as HTMLInputElement
|
|
67
124
|
emit('input', event)
|
|
@@ -70,21 +127,52 @@ const CFormTextarea = defineComponent({
|
|
|
70
127
|
|
|
71
128
|
return () =>
|
|
72
129
|
h(
|
|
73
|
-
|
|
130
|
+
CFormControlWrapper,
|
|
131
|
+
{
|
|
132
|
+
describedby: attrs['aria-describedby'],
|
|
133
|
+
feedback: props.feedback,
|
|
134
|
+
feedbackInvalid: props.feedbackInvalid,
|
|
135
|
+
feedbackValid: props.feedbackValid,
|
|
136
|
+
floatingLabel: props.floatingLabel,
|
|
137
|
+
id: props.id,
|
|
138
|
+
invalid: props.invalid,
|
|
139
|
+
label: props.label,
|
|
140
|
+
text: props.text,
|
|
141
|
+
tooltipFeedback: props.tooltipFeedback,
|
|
142
|
+
valid: props.valid,
|
|
143
|
+
},
|
|
74
144
|
{
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
145
|
+
default: () =>
|
|
146
|
+
h(
|
|
147
|
+
'textarea',
|
|
148
|
+
{
|
|
149
|
+
id: props.id,
|
|
150
|
+
...attrs,
|
|
151
|
+
disabled: props.disabled,
|
|
152
|
+
readonly: props.readonly,
|
|
153
|
+
class: [
|
|
154
|
+
props.plainText ? 'form-control-plaintext' : 'form-control',
|
|
155
|
+
{
|
|
156
|
+
'is-invalid': props.invalid,
|
|
157
|
+
'is-valid': props.valid,
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
onChange: (event: InputEvent) => handleChange(event),
|
|
161
|
+
onInput: (event: InputEvent) => handleInput(event),
|
|
162
|
+
...(props.modelValue && { value: props.modelValue }),
|
|
163
|
+
},
|
|
164
|
+
slots.default && slots.default(),
|
|
165
|
+
),
|
|
166
|
+
...(slots.feedback && { feedback: () => slots.feedback && slots.feedback() }),
|
|
167
|
+
...(slots.feedbackInvalid && {
|
|
168
|
+
feedbackInvalid: () => slots.feedbackInvalid && slots.feedbackInvalid(),
|
|
169
|
+
}),
|
|
170
|
+
...(slots.feedbackValid && {
|
|
171
|
+
feedbackValid: () => slots.feedbackInvalid && slots.feedbackInvalid(),
|
|
172
|
+
}),
|
|
173
|
+
...(slots.label && { label: () => slots.label && slots.label() }),
|
|
174
|
+
...(slots.text && { text: () => slots.text && slots.text() }),
|
|
86
175
|
},
|
|
87
|
-
slots.default && slots.default(),
|
|
88
176
|
)
|
|
89
177
|
},
|
|
90
178
|
})
|
|
@@ -49,7 +49,7 @@ describe(`Loads and display ${ComponentName} component`, () => {
|
|
|
49
49
|
})
|
|
50
50
|
it('contain slots and classes', () => {
|
|
51
51
|
expect(defaultWrapper.text()).toContain('Default slot')
|
|
52
|
-
expect(defaultWrapper.classes('form-control')).toBe(true)
|
|
52
|
+
expect(defaultWrapper.find('input').classes('form-control')).toBe(true)
|
|
53
53
|
})
|
|
54
54
|
})
|
|
55
55
|
|
|
@@ -59,11 +59,11 @@ describe(`Customize ${ComponentName} component`, () => {
|
|
|
59
59
|
})
|
|
60
60
|
it('contain slots and classes', () => {
|
|
61
61
|
expect(customWrapper.text()).toContain('Default slot')
|
|
62
|
-
expect(customWrapper.classes('form-control-plaintext')).toBe(true)
|
|
63
|
-
expect(customWrapper.classes('form-control-color')).toBe(true)
|
|
64
|
-
expect(customWrapper.classes('form-control-lg')).toBe(true)
|
|
65
|
-
expect(customWrapper.classes('is-invalid')).toBe(true)
|
|
66
|
-
expect(customWrapper.classes('is-valid')).toBe(true)
|
|
62
|
+
expect(customWrapper.find('input').classes('form-control-plaintext')).toBe(true)
|
|
63
|
+
expect(customWrapper.find('input').classes('form-control-color')).toBe(true)
|
|
64
|
+
expect(customWrapper.find('input').classes('form-control-lg')).toBe(true)
|
|
65
|
+
expect(customWrapper.find('input').classes('is-invalid')).toBe(true)
|
|
66
|
+
expect(customWrapper.find('input').classes('is-valid')).toBe(true)
|
|
67
67
|
})
|
|
68
68
|
})
|
|
69
69
|
|
|
@@ -73,10 +73,10 @@ describe(`Customize (two) ${ComponentName} component`, () => {
|
|
|
73
73
|
})
|
|
74
74
|
it('contain slots and classes', () => {
|
|
75
75
|
expect(customWrapperTwo.text()).toContain('Default slot')
|
|
76
|
-
expect(customWrapperTwo.classes('form-control')).toBe(true)
|
|
77
|
-
expect(customWrapper.classes('form-control-color')).toBe(true)
|
|
78
|
-
expect(customWrapper.classes('form-control-lg')).toBe(true)
|
|
79
|
-
expect(customWrapper.classes('is-invalid')).toBe(true)
|
|
80
|
-
expect(customWrapper.classes('is-valid')).toBe(true)
|
|
76
|
+
expect(customWrapperTwo.find('input').classes('form-control')).toBe(true)
|
|
77
|
+
expect(customWrapper.find('input').classes('form-control-color')).toBe(true)
|
|
78
|
+
expect(customWrapper.find('input').classes('form-control-lg')).toBe(true)
|
|
79
|
+
expect(customWrapper.find('input').classes('is-invalid')).toBe(true)
|
|
80
|
+
expect(customWrapper.find('input').classes('is-valid')).toBe(true)
|
|
81
81
|
})
|
|
82
82
|
})
|
|
@@ -33,8 +33,8 @@ describe(`Loads and display ${ComponentName} component`, () => {
|
|
|
33
33
|
})
|
|
34
34
|
it('contain slots and classes', () => {
|
|
35
35
|
expect(defaultWrapper.text()).toContain('Default slot')
|
|
36
|
-
expect(defaultWrapper.classes('form-range')).toBe(true)
|
|
37
|
-
expect(defaultWrapper.attributes('type')).toBe('range')
|
|
36
|
+
expect(defaultWrapper.find('input').classes('form-range')).toBe(true)
|
|
37
|
+
expect(defaultWrapper.find('input').attributes('type')).toBe('range')
|
|
38
38
|
})
|
|
39
39
|
})
|
|
40
40
|
|
|
@@ -44,12 +44,12 @@ describe(`Customize ${ComponentName} component`, () => {
|
|
|
44
44
|
})
|
|
45
45
|
it('contain slots and classes', () => {
|
|
46
46
|
expect(customWrapper.text()).toContain('Default slot')
|
|
47
|
-
expect(customWrapper.classes('form-range')).toBe(true)
|
|
48
|
-
expect(customWrapper.attributes('type')).toBe('range')
|
|
49
|
-
expect(customWrapper.attributes('disabled')).toBe('')
|
|
50
|
-
expect(customWrapper.attributes('max')).toBe('400')
|
|
51
|
-
expect(customWrapper.attributes('min')).toBe('50')
|
|
52
|
-
expect(customWrapper.attributes('readonly')).toBe('')
|
|
53
|
-
expect(customWrapper.attributes('steps')).toBe('10')
|
|
47
|
+
expect(customWrapper.find('input').classes('form-range')).toBe(true)
|
|
48
|
+
expect(customWrapper.find('input').attributes('type')).toBe('range')
|
|
49
|
+
expect(customWrapper.find('input').attributes('disabled')).toBe('')
|
|
50
|
+
expect(customWrapper.find('input').attributes('max')).toBe('400')
|
|
51
|
+
expect(customWrapper.find('input').attributes('min')).toBe('50')
|
|
52
|
+
expect(customWrapper.find('input').attributes('readonly')).toBe('')
|
|
53
|
+
expect(customWrapper.find('input').attributes('steps')).toBe('10')
|
|
54
54
|
})
|
|
55
55
|
})
|
|
@@ -31,7 +31,7 @@ describe(`Loads and display ${ComponentName} component`, () => {
|
|
|
31
31
|
})
|
|
32
32
|
it('contain slots and classes', () => {
|
|
33
33
|
expect(defaultWrapper.text()).toContain('Default slot')
|
|
34
|
-
expect(defaultWrapper.classes('form-select')).toBe(true)
|
|
34
|
+
expect(defaultWrapper.find('select').classes('form-select')).toBe(true)
|
|
35
35
|
})
|
|
36
36
|
})
|
|
37
37
|
|
|
@@ -41,8 +41,8 @@ describe(`Customize ${ComponentName} component`, () => {
|
|
|
41
41
|
})
|
|
42
42
|
it('contain slots and classes', () => {
|
|
43
43
|
expect(customWrapper.text()).toContain('Default slot')
|
|
44
|
-
expect(customWrapper.classes('form-select')).toBe(true)
|
|
45
|
-
expect(customWrapper.classes('form-select-lg')).toBe(true)
|
|
46
|
-
expect(customWrapper.attributes('size')).toBe('200')
|
|
44
|
+
expect(customWrapper.find('select').classes('form-select')).toBe(true)
|
|
45
|
+
expect(customWrapper.find('select').classes('form-select-lg')).toBe(true)
|
|
46
|
+
expect(customWrapper.find('select').attributes('size')).toBe('200')
|
|
47
47
|
})
|
|
48
48
|
})
|