@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,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, h } from 'vue'
|
|
2
|
-
import { shape } from 'vue-types'
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { CButton } from '../button'
|
|
4
|
+
import { CFormControlValidation } from './CFormControlValidation'
|
|
5
5
|
import { CFormLabel } from './CFormLabel'
|
|
6
6
|
|
|
7
7
|
const CFormCheck = defineComponent({
|
|
@@ -10,52 +10,51 @@ const CFormCheck = defineComponent({
|
|
|
10
10
|
props: {
|
|
11
11
|
/**
|
|
12
12
|
* Create button-like checkboxes and radio buttons.
|
|
13
|
+
*
|
|
14
|
+
* @see http://coreui.io/vue/docs/components/button.html
|
|
13
15
|
*/
|
|
14
|
-
button:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
16
|
+
button: {
|
|
17
|
+
type: Object,
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* Provide valuable, actionable feedback.
|
|
21
|
+
*
|
|
22
|
+
* @since 4.3.0
|
|
23
|
+
*/
|
|
24
|
+
feedback: {
|
|
25
|
+
type: String,
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* Provide valuable, actionable feedback.
|
|
29
|
+
*
|
|
30
|
+
* @since 4.3.0
|
|
31
|
+
*/
|
|
32
|
+
feedbackInvalid: {
|
|
33
|
+
type: String,
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Provide valuable, actionable invalid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
|
|
37
|
+
*
|
|
38
|
+
* @since 4.3.0
|
|
39
|
+
*/
|
|
40
|
+
feedbackValid: {
|
|
41
|
+
type: String,
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* Sets hit area to the full area of the component.
|
|
45
|
+
*/
|
|
46
|
+
hitArea: {
|
|
47
|
+
type: String,
|
|
48
|
+
validator: (value: string): boolean => {
|
|
49
|
+
// The value must match one of these strings
|
|
50
|
+
return ['full'].includes(value)
|
|
50
51
|
},
|
|
51
|
-
}
|
|
52
|
+
},
|
|
52
53
|
/**
|
|
53
54
|
* The id global attribute defines an identifier (ID) that must be unique in the whole document.
|
|
54
55
|
*/
|
|
55
56
|
id: {
|
|
56
57
|
type: String,
|
|
57
|
-
default: undefined,
|
|
58
|
-
required: false,
|
|
59
58
|
},
|
|
60
59
|
/**
|
|
61
60
|
* Input Checkbox indeterminate Property
|
|
@@ -66,22 +65,16 @@ const CFormCheck = defineComponent({
|
|
|
66
65
|
*/
|
|
67
66
|
inline: {
|
|
68
67
|
type: Boolean,
|
|
69
|
-
required: false,
|
|
70
68
|
},
|
|
71
69
|
/**
|
|
72
70
|
* Set component validation state to invalid.
|
|
73
71
|
*/
|
|
74
|
-
invalid:
|
|
75
|
-
type: Boolean,
|
|
76
|
-
required: false,
|
|
77
|
-
},
|
|
72
|
+
invalid: Boolean,
|
|
78
73
|
/**
|
|
79
74
|
* The element represents a caption for a component.
|
|
80
75
|
*/
|
|
81
76
|
label: {
|
|
82
77
|
type: String,
|
|
83
|
-
default: undefined,
|
|
84
|
-
required: false,
|
|
85
78
|
},
|
|
86
79
|
/**
|
|
87
80
|
* The default name for a value passed using v-model.
|
|
@@ -89,8 +82,13 @@ const CFormCheck = defineComponent({
|
|
|
89
82
|
modelValue: {
|
|
90
83
|
type: [Boolean, String],
|
|
91
84
|
value: undefined,
|
|
92
|
-
required: false,
|
|
93
85
|
},
|
|
86
|
+
/**
|
|
87
|
+
* Display validation feedback in a styled tooltip.
|
|
88
|
+
*
|
|
89
|
+
* @since 4.3.0
|
|
90
|
+
*/
|
|
91
|
+
tooltipFeedback: Boolean,
|
|
94
92
|
/**
|
|
95
93
|
* Specifies the type of component.
|
|
96
94
|
*
|
|
@@ -99,14 +97,12 @@ const CFormCheck = defineComponent({
|
|
|
99
97
|
type: {
|
|
100
98
|
type: String,
|
|
101
99
|
default: 'checkbox',
|
|
102
|
-
required: false,
|
|
103
100
|
},
|
|
104
101
|
/**
|
|
105
102
|
* Set component validation state to valid.
|
|
106
103
|
*/
|
|
107
104
|
valid: {
|
|
108
105
|
type: Boolean,
|
|
109
|
-
required: false,
|
|
110
106
|
},
|
|
111
107
|
},
|
|
112
108
|
emits: [
|
|
@@ -126,66 +122,93 @@ const CFormCheck = defineComponent({
|
|
|
126
122
|
emit('update:modelValue', target.checked)
|
|
127
123
|
}
|
|
128
124
|
|
|
125
|
+
const className = [
|
|
126
|
+
'form-check',
|
|
127
|
+
{
|
|
128
|
+
'form-check-inline': props.inline,
|
|
129
|
+
'is-invalid': props.invalid,
|
|
130
|
+
'is-valid': props.valid,
|
|
131
|
+
},
|
|
132
|
+
attrs.class,
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
const inputClassName = [
|
|
136
|
+
props.button ? 'btn-check' : 'form-check-input',
|
|
137
|
+
{
|
|
138
|
+
'is-invalid': props.invalid,
|
|
139
|
+
'is-valid': props.valid,
|
|
140
|
+
'me-2': props.hitArea,
|
|
141
|
+
},
|
|
142
|
+
]
|
|
143
|
+
|
|
129
144
|
const formControl = () => {
|
|
130
145
|
return h('input', {
|
|
131
146
|
...attrs,
|
|
132
|
-
checked: props.modelValue,
|
|
133
|
-
class:
|
|
134
|
-
props.button ? 'btn-check' : 'form-check-input',
|
|
135
|
-
{
|
|
136
|
-
'is-invalid': props.invalid,
|
|
137
|
-
'is-valid': props.valid,
|
|
138
|
-
},
|
|
139
|
-
],
|
|
147
|
+
...(props.modelValue && { checked: props.modelValue }),
|
|
148
|
+
class: inputClassName,
|
|
140
149
|
id: props.id,
|
|
141
150
|
indeterminate: props.indeterminate,
|
|
142
151
|
onChange: (event: InputEvent) => handleChange(event),
|
|
143
152
|
type: props.type,
|
|
144
153
|
})
|
|
145
154
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
155
|
+
|
|
156
|
+
const formLabel = () =>
|
|
157
|
+
props.button
|
|
158
|
+
? h(
|
|
159
|
+
CButton,
|
|
160
|
+
{
|
|
161
|
+
component: 'label',
|
|
162
|
+
...props.button,
|
|
163
|
+
...(props.id && { for: props.id }),
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
default: () => (slots.label && slots.label()) || props.label,
|
|
167
|
+
},
|
|
168
|
+
)
|
|
169
|
+
: h(
|
|
170
|
+
CFormLabel,
|
|
171
|
+
{ class: 'form-check-label', ...(props.id && { for: props.id }) },
|
|
172
|
+
{
|
|
173
|
+
default: () => (slots.label && slots.label()) || props.label,
|
|
174
|
+
},
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
const formValidation = () => {
|
|
178
|
+
return h(CFormControlValidation, {
|
|
179
|
+
describedby: attrs['aria-describedby'] as string,
|
|
180
|
+
feedback: props.feedback,
|
|
181
|
+
feedbackInvalid: props.feedbackInvalid,
|
|
182
|
+
feedbackValid: props.feedbackValid,
|
|
183
|
+
invalid: props.invalid,
|
|
184
|
+
tooltipFeedback: props.tooltipFeedback,
|
|
185
|
+
valid: props.valid,
|
|
186
|
+
})
|
|
168
187
|
}
|
|
169
188
|
|
|
170
189
|
return () =>
|
|
171
190
|
props.button
|
|
172
|
-
? [formControl(), (slots.label || props.label) && formLabel()]
|
|
191
|
+
? [formControl(), (slots.label || props.label) && formLabel(), formValidation()]
|
|
173
192
|
: props.label
|
|
174
|
-
?
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
'form-check',
|
|
193
|
+
? props.hitArea
|
|
194
|
+
? [
|
|
195
|
+
h(
|
|
196
|
+
CFormLabel,
|
|
179
197
|
{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
'is-valid': props.valid,
|
|
198
|
+
customClassName: className,
|
|
199
|
+
...(props.id && { for: props.id }),
|
|
183
200
|
},
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
201
|
+
[formControl(), props.label],
|
|
202
|
+
),
|
|
203
|
+
formValidation(),
|
|
204
|
+
]
|
|
205
|
+
: h(
|
|
206
|
+
'div',
|
|
207
|
+
{
|
|
208
|
+
class: className,
|
|
209
|
+
},
|
|
210
|
+
[formControl(), props.label && formLabel(), formValidation()],
|
|
211
|
+
)
|
|
189
212
|
: formControl()
|
|
190
213
|
},
|
|
191
214
|
})
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue'
|
|
2
|
+
import { CFormFeedback } from './CFormFeedback'
|
|
3
|
+
|
|
4
|
+
const CFormControlValidation = defineComponent({
|
|
5
|
+
name: 'CFormControlValidation',
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
props: {
|
|
8
|
+
/**
|
|
9
|
+
* @ignore
|
|
10
|
+
*/
|
|
11
|
+
describedby: {
|
|
12
|
+
type: String,
|
|
13
|
+
},
|
|
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
|
+
* Set component validation state to invalid.
|
|
40
|
+
*/
|
|
41
|
+
invalid: Boolean,
|
|
42
|
+
/**
|
|
43
|
+
* Display validation feedback in a styled tooltip.
|
|
44
|
+
*
|
|
45
|
+
* @since 4.3.0
|
|
46
|
+
*/
|
|
47
|
+
tooltipFeedback: Boolean,
|
|
48
|
+
/**
|
|
49
|
+
* Set component validation state to valid.
|
|
50
|
+
*/
|
|
51
|
+
valid: Boolean,
|
|
52
|
+
},
|
|
53
|
+
setup(props, { slots }) {
|
|
54
|
+
return () => [
|
|
55
|
+
props.feedback &&
|
|
56
|
+
(props.valid || props.invalid) &&
|
|
57
|
+
h(
|
|
58
|
+
CFormFeedback,
|
|
59
|
+
{
|
|
60
|
+
...(props.invalid && { id: props.describedby }),
|
|
61
|
+
invalid: props.invalid,
|
|
62
|
+
tooltip: props.tooltipFeedback,
|
|
63
|
+
valid: props.valid,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
default: () => (slots.feedback && slots.feedback()) || props.feedback,
|
|
67
|
+
},
|
|
68
|
+
),
|
|
69
|
+
(props.feedbackInvalid || slots.feedbackInvalid) &&
|
|
70
|
+
h(
|
|
71
|
+
CFormFeedback,
|
|
72
|
+
{
|
|
73
|
+
id: props.describedby,
|
|
74
|
+
invalid: true,
|
|
75
|
+
tooltip: props.tooltipFeedback,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
default: () =>
|
|
79
|
+
(slots.feedbackInvalid && slots.feedbackInvalid()) || props.feedbackInvalid,
|
|
80
|
+
},
|
|
81
|
+
),
|
|
82
|
+
(props.feedbackValid || slots.feedbackValid) &&
|
|
83
|
+
h(
|
|
84
|
+
CFormFeedback,
|
|
85
|
+
{
|
|
86
|
+
tooltip: props.tooltipFeedback,
|
|
87
|
+
valid: true,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
default: () => (slots.feedbackValid && slots.feedbackValid()) || props.feedbackValid,
|
|
91
|
+
},
|
|
92
|
+
),
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
export { CFormControlValidation }
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue'
|
|
2
|
+
import { CFormControlValidation } from './CFormControlValidation'
|
|
3
|
+
import { CFormFloating } from './CFormFloating'
|
|
4
|
+
import { CFormLabel } from './CFormLabel'
|
|
5
|
+
import { CFormText } from './CFormText'
|
|
6
|
+
|
|
7
|
+
const CFormControlWrapper = defineComponent({
|
|
8
|
+
name: 'CFormControlWrapper',
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
props: {
|
|
11
|
+
...CFormControlValidation.props,
|
|
12
|
+
/**
|
|
13
|
+
* Provide valuable, actionable valid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
|
|
14
|
+
*
|
|
15
|
+
* @since 4.3.0
|
|
16
|
+
*/
|
|
17
|
+
floatingLabel: {
|
|
18
|
+
type: String,
|
|
19
|
+
},
|
|
20
|
+
/**
|
|
21
|
+
* @ignore
|
|
22
|
+
*/
|
|
23
|
+
id: {
|
|
24
|
+
type: String,
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* Add a caption for a component.
|
|
28
|
+
*
|
|
29
|
+
* @since 4.3.0
|
|
30
|
+
*/
|
|
31
|
+
label: {
|
|
32
|
+
type: String,
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Add helper text to the component.
|
|
36
|
+
*
|
|
37
|
+
* @since 4.3.0
|
|
38
|
+
*/
|
|
39
|
+
text: {
|
|
40
|
+
type: String,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
setup(props, { slots }) {
|
|
44
|
+
return () =>
|
|
45
|
+
props.floatingLabel
|
|
46
|
+
? h(CFormFloating, () => [
|
|
47
|
+
slots.default && slots.default(),
|
|
48
|
+
h(
|
|
49
|
+
CFormLabel,
|
|
50
|
+
{
|
|
51
|
+
for: props.id,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
default: () => (slots.label && slots.label()) || props.label || props.floatingLabel,
|
|
55
|
+
},
|
|
56
|
+
),
|
|
57
|
+
])
|
|
58
|
+
: [
|
|
59
|
+
(props.label || slots.label) &&
|
|
60
|
+
h(
|
|
61
|
+
CFormLabel,
|
|
62
|
+
{
|
|
63
|
+
for: props.id,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
default: () => (slots.label && slots.label()) || props.label,
|
|
67
|
+
},
|
|
68
|
+
),
|
|
69
|
+
slots.default && slots.default(),
|
|
70
|
+
(props.text || slots.text) &&
|
|
71
|
+
h(
|
|
72
|
+
CFormText,
|
|
73
|
+
{
|
|
74
|
+
id: props.describedby,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
default: () => (slots.text && slots.text()) || props.text,
|
|
78
|
+
},
|
|
79
|
+
),
|
|
80
|
+
h(
|
|
81
|
+
CFormControlValidation,
|
|
82
|
+
{
|
|
83
|
+
describedby: props.describedby,
|
|
84
|
+
feedback: props.feedback,
|
|
85
|
+
feedbackInvalid: props.feedbackInvalid,
|
|
86
|
+
feedbackValid: props.feedbackValid,
|
|
87
|
+
floatingLabel: props.floatingLabel,
|
|
88
|
+
invalid: props.invalid,
|
|
89
|
+
tooltipFeedback: props.tooltipFeedback,
|
|
90
|
+
valid: props.valid,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
...(slots.feedback && { feedback: () => slots.feedback && slots.feedback() }),
|
|
94
|
+
...(slots.feedbackInvalid && {
|
|
95
|
+
feedbackInvalid: () => slots.feedbackInvalid && slots.feedbackInvalid(),
|
|
96
|
+
}),
|
|
97
|
+
...(slots.feedbackValid && {
|
|
98
|
+
feedbackValid: () => slots.feedbackInvalid && slots.feedbackInvalid(),
|
|
99
|
+
}),
|
|
100
|
+
},
|
|
101
|
+
),
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
export { CFormControlWrapper }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineComponent, h } from 'vue'
|
|
2
|
+
import { CFormControlWrapper } from './CFormControlWrapper'
|
|
2
3
|
|
|
3
4
|
const CFormInput = defineComponent({
|
|
4
5
|
name: 'CFormInput',
|
|
@@ -10,20 +11,64 @@ const CFormInput = defineComponent({
|
|
|
10
11
|
type: Boolean,
|
|
11
12
|
required: false,
|
|
12
13
|
},
|
|
14
|
+
|
|
15
|
+
// Inherited Props from CFormControlWrapper
|
|
16
|
+
/**
|
|
17
|
+
* Provide valuable, actionable feedback.
|
|
18
|
+
*
|
|
19
|
+
* @since 4.3.0
|
|
20
|
+
*/
|
|
21
|
+
feedback: {
|
|
22
|
+
type: String,
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* Provide valuable, actionable feedback.
|
|
26
|
+
*
|
|
27
|
+
* @since 4.3.0
|
|
28
|
+
*/
|
|
29
|
+
feedbackInvalid: {
|
|
30
|
+
type: String,
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Provide valuable, actionable invalid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
|
|
34
|
+
*
|
|
35
|
+
* @since 4.3.0
|
|
36
|
+
*/
|
|
37
|
+
feedbackValid: {
|
|
38
|
+
type: String,
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* Provide valuable, actionable valid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
|
|
42
|
+
*
|
|
43
|
+
* @since 4.3.0
|
|
44
|
+
*/
|
|
45
|
+
floatingLabel: {
|
|
46
|
+
type: String,
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* The id global attribute defines an identifier (ID) that must be unique in the whole document.
|
|
50
|
+
*/
|
|
51
|
+
id: {
|
|
52
|
+
type: String,
|
|
53
|
+
},
|
|
13
54
|
/**
|
|
14
55
|
* Set component validation state to invalid.
|
|
15
56
|
*/
|
|
16
|
-
invalid:
|
|
17
|
-
|
|
18
|
-
|
|
57
|
+
invalid: Boolean,
|
|
58
|
+
/**
|
|
59
|
+
* Add a caption for a component.
|
|
60
|
+
*
|
|
61
|
+
* @since 4.3.0
|
|
62
|
+
*/
|
|
63
|
+
label: {
|
|
64
|
+
type: String,
|
|
19
65
|
},
|
|
20
66
|
/**
|
|
21
67
|
* The default name for a value passed using v-model.
|
|
22
68
|
*/
|
|
23
69
|
modelValue: {
|
|
24
|
-
type: String,
|
|
70
|
+
type: [File, Number, String],
|
|
25
71
|
default: undefined,
|
|
26
|
-
require: false,
|
|
27
72
|
},
|
|
28
73
|
/**
|
|
29
74
|
* 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`.
|
|
@@ -46,12 +91,24 @@ const CFormInput = defineComponent({
|
|
|
46
91
|
*/
|
|
47
92
|
size: {
|
|
48
93
|
type: String,
|
|
49
|
-
default: undefined,
|
|
50
|
-
require: false,
|
|
51
94
|
validator: (value: string) => {
|
|
52
95
|
return ['sm', 'lg'].includes(value)
|
|
53
96
|
},
|
|
54
97
|
},
|
|
98
|
+
/**
|
|
99
|
+
* Add helper text to the component.
|
|
100
|
+
*
|
|
101
|
+
* @since 4.3.0
|
|
102
|
+
*/
|
|
103
|
+
text: {
|
|
104
|
+
type: String,
|
|
105
|
+
},
|
|
106
|
+
/**
|
|
107
|
+
* Display validation feedback in a styled tooltip.
|
|
108
|
+
*
|
|
109
|
+
* @since 4.3.0
|
|
110
|
+
*/
|
|
111
|
+
tooltipFeedback: Boolean,
|
|
55
112
|
/**
|
|
56
113
|
* Specifies the type of component.
|
|
57
114
|
*
|
|
@@ -60,15 +117,11 @@ const CFormInput = defineComponent({
|
|
|
60
117
|
type: {
|
|
61
118
|
type: String,
|
|
62
119
|
default: 'text',
|
|
63
|
-
require: false,
|
|
64
120
|
},
|
|
65
121
|
/**
|
|
66
122
|
* Set component validation state to valid.
|
|
67
123
|
*/
|
|
68
|
-
valid:
|
|
69
|
-
type: Boolean,
|
|
70
|
-
required: false,
|
|
71
|
-
},
|
|
124
|
+
valid: Boolean,
|
|
72
125
|
},
|
|
73
126
|
emits: [
|
|
74
127
|
/**
|
|
@@ -84,12 +137,13 @@ const CFormInput = defineComponent({
|
|
|
84
137
|
*/
|
|
85
138
|
'update:modelValue',
|
|
86
139
|
],
|
|
87
|
-
setup(props, { emit, slots }) {
|
|
140
|
+
setup(props, { attrs, emit, slots }) {
|
|
88
141
|
const handleChange = (event: InputEvent) => {
|
|
89
142
|
const target = event.target as HTMLInputElement
|
|
90
143
|
emit('change', event)
|
|
91
144
|
emit('update:modelValue', target.value)
|
|
92
145
|
}
|
|
146
|
+
|
|
93
147
|
const handleInput = (event: InputEvent) => {
|
|
94
148
|
const target = event.target as HTMLInputElement
|
|
95
149
|
emit('input', event)
|
|
@@ -98,25 +152,56 @@ const CFormInput = defineComponent({
|
|
|
98
152
|
|
|
99
153
|
return () =>
|
|
100
154
|
h(
|
|
101
|
-
|
|
155
|
+
CFormControlWrapper,
|
|
156
|
+
{
|
|
157
|
+
describedby: attrs['aria-describedby'],
|
|
158
|
+
feedback: props.feedback,
|
|
159
|
+
feedbackInvalid: props.feedbackInvalid,
|
|
160
|
+
feedbackValid: props.feedbackValid,
|
|
161
|
+
floatingLabel: props.floatingLabel,
|
|
162
|
+
id: props.id,
|
|
163
|
+
invalid: props.invalid,
|
|
164
|
+
label: props.label,
|
|
165
|
+
text: props.text,
|
|
166
|
+
tooltipFeedback: props.tooltipFeedback,
|
|
167
|
+
valid: props.valid,
|
|
168
|
+
},
|
|
102
169
|
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
170
|
+
default: () =>
|
|
171
|
+
h(
|
|
172
|
+
'input',
|
|
173
|
+
{
|
|
174
|
+
id: props.id,
|
|
175
|
+
...attrs,
|
|
176
|
+
class: [
|
|
177
|
+
props.plainText ? 'form-control-plaintext' : 'form-control',
|
|
178
|
+
{
|
|
179
|
+
'form-control-color': props.type === 'color',
|
|
180
|
+
[`form-control-${props.size}`]: props.size,
|
|
181
|
+
'is-invalid': props.invalid,
|
|
182
|
+
'is-valid': props.valid,
|
|
183
|
+
},
|
|
184
|
+
attrs.class,
|
|
185
|
+
],
|
|
186
|
+
disabled: props.disabled,
|
|
187
|
+
onChange: (event: InputEvent) => handleChange(event),
|
|
188
|
+
onInput: (event: InputEvent) => handleInput(event),
|
|
189
|
+
readonly: props.readonly,
|
|
190
|
+
type: props.type,
|
|
191
|
+
...(props.modelValue && { value: props.modelValue }),
|
|
192
|
+
},
|
|
193
|
+
slots.default && slots.default(),
|
|
194
|
+
),
|
|
195
|
+
...(slots.feedback && { feedback: () => slots.feedback && slots.feedback() }),
|
|
196
|
+
...(slots.feedbackInvalid && {
|
|
197
|
+
feedbackInvalid: () => slots.feedbackInvalid && slots.feedbackInvalid(),
|
|
198
|
+
}),
|
|
199
|
+
...(slots.feedbackValid && {
|
|
200
|
+
feedbackValid: () => slots.feedbackInvalid && slots.feedbackInvalid(),
|
|
201
|
+
}),
|
|
202
|
+
...(slots.label && { label: () => slots.label && slots.label() }),
|
|
203
|
+
...(slots.text && { text: () => slots.text && slots.text() }),
|
|
118
204
|
},
|
|
119
|
-
slots.default && slots.default(),
|
|
120
205
|
)
|
|
121
206
|
},
|
|
122
207
|
})
|