@coreui/vue-pro 4.2.0 → 4.3.0
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 +1 -1
- package/dist/components/calendar/CCalendar.d.ts +198 -0
- package/dist/components/calendar/index.d.ts +6 -0
- package/dist/components/carousel/CCarousel.d.ts +1 -1
- package/dist/components/date-picker/CDatePicker.d.ts +414 -0
- package/dist/components/date-picker/index.d.ts +6 -0
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +563 -0
- package/dist/components/date-range-picker/index.d.ts +6 -0
- 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 +125 -25
- 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/index.d.ts +5 -0
- package/dist/components/modal/CModal.d.ts +1 -1
- package/dist/components/multi-select/CMultiSelect.d.ts +2 -2
- package/dist/components/offcanvas/COffcanvas.d.ts +1 -1
- package/dist/components/picker/CPicker.d.ts +11 -0
- package/dist/components/picker/index.d.ts +6 -0
- package/dist/components/popover/CPopover.d.ts +1 -1
- package/dist/components/sidebar/CSidebar.d.ts +1 -1
- package/dist/components/smart-table/CSmartTable.d.ts +35 -99
- package/dist/components/smart-table/CSmartTableInterface.d.ts +3 -3
- package/dist/components/time-picker/CTimePicker.d.ts +10 -0
- package/dist/components/time-picker/CTimePickerRollCol.d.ts +27 -0
- package/dist/components/time-picker/index.d.ts +6 -0
- package/dist/components/toast/CToast.d.ts +8 -2
- package/dist/index.es.js +6249 -1276
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +6256 -1273
- package/dist/index.js.map +1 -1
- package/dist/utils/calendar.d.ts +23 -0
- package/dist/utils/time.d.ts +21 -0
- package/dist/utils/transition.d.ts +3 -0
- package/package.json +11 -10
- package/src/components/backdrop/CBackdrop.ts +8 -6
- package/src/components/button/CButton.ts +2 -2
- package/src/components/calendar/CCalendar.ts +616 -0
- package/src/components/calendar/index.ts +10 -0
- package/src/components/collapse/CCollapse.ts +5 -6
- package/src/components/date-picker/CDatePicker.ts +240 -0
- package/src/components/date-picker/index.ts +10 -0
- package/src/components/date-range-picker/CDateRangePicker.ts +733 -0
- package/src/components/date-range-picker/index.ts +10 -0
- package/src/components/dropdown/CDropdownMenu.ts +4 -2
- package/src/components/dropdown/CDropdownToggle.ts +24 -9
- package/src/components/form/CFormCheck.ts +119 -94
- package/src/components/form/CFormControlValidation.ts +97 -0
- package/src/components/form/CFormControlWrapper.ts +106 -0
- package/src/components/form/CFormInput.ts +113 -29
- package/src/components/form/CFormRange.ts +25 -11
- package/src/components/form/CFormSelect.ts +126 -41
- package/src/components/form/CFormSwitch.ts +2 -21
- package/src/components/form/CFormTextarea.ts +105 -25
- package/src/components/index.ts +5 -0
- package/src/components/modal/CModal.ts +14 -6
- 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 +221 -0
- package/src/components/picker/index.ts +10 -0
- package/src/components/popover/CPopover.ts +5 -5
- 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 +405 -0
- package/src/components/time-picker/CTimePickerRollCol.ts +58 -0
- package/src/components/time-picker/index.ts +10 -0
- package/src/components/toast/CToast.ts +17 -12
- package/src/components/tooltip/CTooltip.ts +5 -5
- package/src/utils/calendar.ts +270 -0
- package/src/utils/time.ts +84 -0
- package/src/utils/transition.ts +65 -0
|
@@ -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,12 +11,57 @@ 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.
|
|
@@ -23,7 +69,6 @@ const CFormInput = defineComponent({
|
|
|
23
69
|
modelValue: {
|
|
24
70
|
type: 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,55 @@ 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
|
+
...attrs,
|
|
175
|
+
class: [
|
|
176
|
+
props.plainText ? 'form-control-plaintext' : 'form-control',
|
|
177
|
+
{
|
|
178
|
+
'form-control-color': props.type === 'color',
|
|
179
|
+
[`form-control-${props.size}`]: props.size,
|
|
180
|
+
'is-invalid': props.invalid,
|
|
181
|
+
'is-valid': props.valid,
|
|
182
|
+
},
|
|
183
|
+
attrs.class,
|
|
184
|
+
],
|
|
185
|
+
disabled: props.disabled,
|
|
186
|
+
onChange: (event: InputEvent) => handleChange(event),
|
|
187
|
+
onInput: (event: InputEvent) => handleInput(event),
|
|
188
|
+
readonly: props.readonly,
|
|
189
|
+
type: props.type,
|
|
190
|
+
...(props.modelValue && { value: props.modelValue }),
|
|
191
|
+
},
|
|
192
|
+
slots.default && slots.default(),
|
|
193
|
+
),
|
|
194
|
+
...(slots.feedback && { feedback: () => slots.feedback && slots.feedback() }),
|
|
195
|
+
...(slots.feedbackInvalid && {
|
|
196
|
+
feedbackInvalid: () => slots.feedbackInvalid && slots.feedbackInvalid(),
|
|
197
|
+
}),
|
|
198
|
+
...(slots.feedbackValid && {
|
|
199
|
+
feedbackValid: () => slots.feedbackInvalid && slots.feedbackInvalid(),
|
|
200
|
+
}),
|
|
201
|
+
...(slots.label && { label: () => slots.label && slots.label() }),
|
|
202
|
+
...(slots.text && { text: () => slots.text && slots.text() }),
|
|
118
203
|
},
|
|
119
|
-
slots.default && slots.default(),
|
|
120
204
|
)
|
|
121
205
|
},
|
|
122
206
|
})
|
|
@@ -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,71 @@ 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
|
+
...attrs,
|
|
169
|
+
class: [
|
|
170
|
+
'form-select',
|
|
171
|
+
{
|
|
172
|
+
[`form-select-${props.size}`]: props.size,
|
|
173
|
+
'is-invalid': props.invalid,
|
|
174
|
+
'is-valid': props.valid,
|
|
175
|
+
},
|
|
176
|
+
attrs.class,
|
|
177
|
+
],
|
|
178
|
+
multiple: props.multiple,
|
|
179
|
+
onChange: (event: InputEvent) => handleChange(event),
|
|
180
|
+
size: props.htmlSize,
|
|
181
|
+
...(props.modelValue && !props.multiple && { value: props.modelValue }),
|
|
182
|
+
},
|
|
183
|
+
props.options
|
|
184
|
+
? props.options.map((option: Option | string) => {
|
|
185
|
+
return h(
|
|
186
|
+
'option',
|
|
187
|
+
{
|
|
188
|
+
...(typeof option === 'object' && {
|
|
189
|
+
...(option.disabled && { disabled: option.disabled }),
|
|
190
|
+
...(option.selected && { selected: option.selected }),
|
|
191
|
+
...(option.value && {
|
|
192
|
+
value: option.value,
|
|
193
|
+
...(props.modelValue &&
|
|
194
|
+
props.multiple &&
|
|
195
|
+
props.modelValue.includes(option.value) && { selected: true }),
|
|
196
|
+
}),
|
|
197
|
+
}),
|
|
198
|
+
},
|
|
199
|
+
typeof option === 'string' ? option : option.label,
|
|
200
|
+
)
|
|
201
|
+
})
|
|
202
|
+
: slots.default && slots.default(),
|
|
203
|
+
),
|
|
204
|
+
...(slots.feedback && { feedback: () => slots.feedback && slots.feedback() }),
|
|
205
|
+
...(slots.feedbackInvalid && {
|
|
206
|
+
feedbackInvalid: () => slots.feedbackInvalid && slots.feedbackInvalid(),
|
|
207
|
+
}),
|
|
208
|
+
...(slots.feedbackValid && {
|
|
209
|
+
feedbackValid: () => slots.feedbackInvalid && slots.feedbackInvalid(),
|
|
210
|
+
}),
|
|
211
|
+
...(slots.label && { label: () => slots.label && slots.label() }),
|
|
212
|
+
...(slots.text && { text: () => slots.text && slots.text() }),
|
|
108
213
|
},
|
|
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
214
|
)
|
|
130
215
|
},
|
|
131
216
|
})
|
|
@@ -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
|
{
|