@coreui/react 4.1.2 → 4.2.2
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/accordion/index.d.ts +7 -0
- package/dist/components/alert/index.d.ts +4 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/backdrop/index.d.ts +2 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.d.ts +3 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button-group/index.d.ts +3 -0
- package/dist/components/callout/index.d.ts +2 -0
- package/dist/components/card/CCardImage.d.ts +2 -2
- package/dist/components/card/index.d.ts +12 -0
- package/dist/components/carousel/index.d.ts +4 -0
- package/dist/components/close-button/index.d.ts +2 -0
- package/dist/components/collapse/index.d.ts +2 -0
- package/dist/components/dropdown/CDropdown.d.ts +10 -1
- package/dist/components/dropdown/CDropdownToggle.d.ts +4 -0
- package/dist/components/dropdown/index.d.ts +8 -0
- package/dist/components/footer/index.d.ts +2 -0
- package/dist/components/form/CForm.d.ts +2 -2
- package/dist/components/form/CFormCheck.d.ts +2 -1
- package/dist/components/form/CFormControlValidation.d.ts +46 -0
- package/dist/components/form/CFormControlWrapper.d.ts +31 -0
- package/dist/components/form/CFormInput.d.ts +6 -9
- package/dist/components/form/CFormRange.d.ts +7 -1
- package/dist/components/form/CFormSelect.d.ts +3 -10
- package/dist/components/form/CFormTextarea.d.ts +2 -9
- package/dist/components/form/index.d.ts +14 -0
- package/dist/components/grid/index.d.ts +4 -0
- package/dist/components/header/index.d.ts +7 -0
- package/dist/components/image/index.d.ts +2 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/link/index.d.ts +2 -0
- package/dist/components/list-group/index.d.ts +3 -0
- package/dist/components/modal/CModal.d.ts +3 -0
- package/dist/components/modal/index.d.ts +8 -0
- package/dist/components/nav/index.d.ts +7 -0
- package/dist/components/navbar/index.d.ts +6 -0
- package/dist/components/offcanvas/index.d.ts +5 -0
- package/dist/components/pagination/index.d.ts +3 -0
- package/dist/components/placeholder/index.d.ts +2 -0
- package/dist/components/popover/CPopover.d.ts +2 -2
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/progress/index.d.ts +3 -0
- package/dist/components/sidebar/index.d.ts +7 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/table/index.d.ts +9 -0
- package/dist/components/tabs/index.d.ts +3 -0
- package/dist/components/toast/index.d.ts +6 -0
- package/dist/components/tooltip/CTooltip.d.ts +6 -2
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/index.d.ts +0 -120
- package/dist/index.es.js +3039 -2179
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3034 -2174
- package/dist/index.js.map +1 -1
- package/package.json +17 -16
- package/src/components/accordion/CAccordionButton.tsx +2 -1
- package/src/components/accordion/__tests__/__snapshots__/CAccordionButton.spec.tsx.snap +2 -0
- package/src/components/accordion/__tests__/__snapshots__/CAccordionHeader.spec.tsx.snap +2 -0
- package/src/components/accordion/index.ts +15 -0
- package/src/components/alert/CAlert.tsx +14 -3
- package/src/components/alert/index.ts +5 -0
- package/src/components/avatar/index.ts +3 -0
- package/src/components/backdrop/CBackdrop.tsx +10 -3
- package/src/components/backdrop/index.ts +3 -0
- package/src/components/badge/index.ts +3 -0
- package/src/components/breadcrumb/index.ts +4 -0
- package/src/components/button/index.ts +3 -0
- package/src/components/button-group/index.ts +4 -0
- package/src/components/callout/index.ts +3 -0
- package/src/components/card/CCardImage.tsx +2 -2
- package/src/components/card/index.ts +25 -0
- package/src/components/carousel/index.ts +5 -0
- package/src/components/close-button/CCloseButton.tsx +8 -1
- package/src/components/close-button/index.ts +3 -0
- package/src/components/collapse/CCollapse.tsx +1 -0
- package/src/components/collapse/index.ts +3 -0
- package/src/components/dropdown/CDropdown.tsx +19 -24
- package/src/components/dropdown/CDropdownItem.tsx +1 -1
- package/src/components/dropdown/CDropdownMenu.tsx +55 -3
- package/src/components/dropdown/CDropdownToggle.tsx +28 -5
- package/src/components/dropdown/index.ts +17 -0
- package/src/components/footer/index.ts +3 -0
- package/src/components/form/CForm.tsx +2 -2
- package/src/components/form/CFormCheck.tsx +32 -7
- package/src/components/form/CFormControlValidation.tsx +97 -0
- package/src/components/form/CFormControlWrapper.tsx +85 -0
- package/src/components/form/CFormInput.tsx +75 -19
- package/src/components/form/CFormRange.tsx +18 -4
- package/src/components/form/CFormSelect.tsx +60 -32
- package/src/components/form/CFormTextarea.tsx +45 -17
- package/src/components/form/index.ts +29 -0
- package/src/components/grid/index.ts +5 -0
- package/src/components/header/index.ts +8 -0
- package/src/components/image/index.ts +3 -0
- package/src/components/index.ts +35 -0
- package/src/components/link/index.ts +3 -0
- package/src/components/list-group/index.ts +4 -0
- package/src/components/modal/CModal.tsx +4 -3
- package/src/components/modal/index.ts +9 -0
- package/src/components/nav/CNavGroup.tsx +1 -0
- package/src/components/nav/index.ts +8 -0
- package/src/components/navbar/index.ts +7 -0
- package/src/components/offcanvas/COffcanvas.tsx +2 -1
- package/src/components/offcanvas/index.ts +6 -0
- package/src/components/pagination/index.ts +4 -0
- package/src/components/placeholder/index.ts +3 -0
- package/src/components/popover/CPopover.tsx +59 -57
- package/src/components/popover/__tests__/__snapshots__/CPopover.spec.tsx.snap +1 -1
- package/src/components/popover/index.ts +3 -0
- package/src/components/progress/index.ts +4 -0
- package/src/components/sidebar/index.ts +8 -0
- package/src/components/spinner/index.ts +3 -0
- package/src/components/table/index.ts +19 -0
- package/src/components/tabs/CTabPane.tsx +7 -3
- package/src/components/tabs/index.ts +4 -0
- package/src/components/toast/CToast.tsx +6 -1
- package/src/components/toast/index.ts +7 -0
- package/src/components/tooltip/CTooltip.tsx +63 -45
- package/src/components/tooltip/index.ts +3 -0
- package/src/index.ts +0 -242
|
@@ -5,6 +5,7 @@ import classNames from 'classnames'
|
|
|
5
5
|
import { useForkedRef } from '../../utils/hooks'
|
|
6
6
|
import { Colors, Shapes } from '../Types'
|
|
7
7
|
|
|
8
|
+
import { CFormControlValidation, CFormControlValidationProps } from './CFormControlValidation'
|
|
8
9
|
import { CFormLabel } from './CFormLabel'
|
|
9
10
|
|
|
10
11
|
export type ButtonObject = {
|
|
@@ -30,7 +31,9 @@ export type ButtonObject = {
|
|
|
30
31
|
variant?: 'outline' | 'ghost'
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
export interface CFormCheckProps
|
|
34
|
+
export interface CFormCheckProps
|
|
35
|
+
extends CFormControlValidationProps,
|
|
36
|
+
InputHTMLAttributes<HTMLInputElement> {
|
|
34
37
|
/**
|
|
35
38
|
* Create button-like checkboxes and radio buttons.
|
|
36
39
|
*/
|
|
@@ -78,6 +81,11 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
|
|
|
78
81
|
{
|
|
79
82
|
className,
|
|
80
83
|
button,
|
|
84
|
+
feedback,
|
|
85
|
+
feedbackInvalid,
|
|
86
|
+
feedbackValid,
|
|
87
|
+
floatingLabel,
|
|
88
|
+
tooltipFeedback,
|
|
81
89
|
hitArea,
|
|
82
90
|
id,
|
|
83
91
|
indeterminate,
|
|
@@ -131,6 +139,19 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
|
|
|
131
139
|
return <input type={type} className={inputClassName} id={id} {...rest} ref={forkedRef} />
|
|
132
140
|
}
|
|
133
141
|
|
|
142
|
+
const formValidation = () => (
|
|
143
|
+
<CFormControlValidation
|
|
144
|
+
describedby={rest['aria-describedby']}
|
|
145
|
+
feedback={feedback}
|
|
146
|
+
feedbackInvalid={feedbackInvalid}
|
|
147
|
+
feedbackValid={feedbackValid}
|
|
148
|
+
floatingLabel={floatingLabel}
|
|
149
|
+
invalid={invalid}
|
|
150
|
+
tooltipFeedback={tooltipFeedback}
|
|
151
|
+
valid={valid}
|
|
152
|
+
/>
|
|
153
|
+
)
|
|
154
|
+
|
|
134
155
|
const formLabel = () => {
|
|
135
156
|
return (
|
|
136
157
|
<CFormLabel customClassName={labelClassName} {...(id && { htmlFor: id })}>
|
|
@@ -143,17 +164,22 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
|
|
|
143
164
|
<>
|
|
144
165
|
{formControl()}
|
|
145
166
|
{label && formLabel()}
|
|
167
|
+
{formValidation()}
|
|
146
168
|
</>
|
|
147
169
|
) : label ? (
|
|
148
170
|
hitArea ? (
|
|
149
|
-
|
|
150
|
-
{
|
|
151
|
-
|
|
152
|
-
|
|
171
|
+
<>
|
|
172
|
+
<CFormLabel customClassName={className} {...(id && { htmlFor: id })}>
|
|
173
|
+
{formControl()}
|
|
174
|
+
{label}
|
|
175
|
+
</CFormLabel>
|
|
176
|
+
{formValidation()}
|
|
177
|
+
</>
|
|
153
178
|
) : (
|
|
154
179
|
<div className={_className}>
|
|
155
180
|
{formControl()}
|
|
156
181
|
{formLabel()}
|
|
182
|
+
{formValidation()}
|
|
157
183
|
</div>
|
|
158
184
|
)
|
|
159
185
|
) : (
|
|
@@ -169,10 +195,9 @@ CFormCheck.propTypes = {
|
|
|
169
195
|
id: PropTypes.string,
|
|
170
196
|
indeterminate: PropTypes.bool,
|
|
171
197
|
inline: PropTypes.bool,
|
|
172
|
-
invalid: PropTypes.bool,
|
|
173
198
|
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
174
199
|
type: PropTypes.oneOf(['checkbox', 'radio']),
|
|
175
|
-
|
|
200
|
+
...CFormControlValidation.propTypes,
|
|
176
201
|
}
|
|
177
202
|
|
|
178
203
|
CFormCheck.displayName = 'CFormCheck'
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
|
|
5
|
+
import { CFormFeedback } from './CFormFeedback'
|
|
6
|
+
|
|
7
|
+
export interface CFormControlValidationProps {
|
|
8
|
+
/**
|
|
9
|
+
* @ignore
|
|
10
|
+
*/
|
|
11
|
+
describedby?: string
|
|
12
|
+
/**
|
|
13
|
+
* Provide valuable, actionable feedback.
|
|
14
|
+
*
|
|
15
|
+
* @since 4.2.0
|
|
16
|
+
*/
|
|
17
|
+
feedback?: ReactNode | string
|
|
18
|
+
/**
|
|
19
|
+
* Provide valuable, actionable feedback.
|
|
20
|
+
*
|
|
21
|
+
* @since 4.2.0
|
|
22
|
+
*/
|
|
23
|
+
feedbackInvalid?: ReactNode | string
|
|
24
|
+
/**
|
|
25
|
+
* Provide valuable, actionable invalid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
|
|
26
|
+
*
|
|
27
|
+
* @since 4.2.0
|
|
28
|
+
*/
|
|
29
|
+
feedbackValid?: ReactNode | string
|
|
30
|
+
/**
|
|
31
|
+
* Provide valuable, actionable valid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
|
|
32
|
+
*
|
|
33
|
+
* @since 4.2.0
|
|
34
|
+
*/
|
|
35
|
+
floatingLabel?: ReactNode | string
|
|
36
|
+
/**
|
|
37
|
+
* Set component validation state to invalid.
|
|
38
|
+
*/
|
|
39
|
+
invalid?: boolean
|
|
40
|
+
/**
|
|
41
|
+
* Display validation feedback in a styled tooltip.
|
|
42
|
+
*
|
|
43
|
+
* @since 4.2.0
|
|
44
|
+
*/
|
|
45
|
+
tooltipFeedback?: boolean
|
|
46
|
+
/**
|
|
47
|
+
* Set component validation state to valid.
|
|
48
|
+
*/
|
|
49
|
+
valid?: boolean
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const CFormControlValidation: FC<CFormControlValidationProps> = ({
|
|
53
|
+
describedby,
|
|
54
|
+
feedback,
|
|
55
|
+
feedbackInvalid,
|
|
56
|
+
feedbackValid,
|
|
57
|
+
invalid,
|
|
58
|
+
tooltipFeedback,
|
|
59
|
+
valid,
|
|
60
|
+
}) => {
|
|
61
|
+
return (
|
|
62
|
+
<>
|
|
63
|
+
{feedback && (valid || invalid) && (
|
|
64
|
+
<CFormFeedback
|
|
65
|
+
{...(invalid && { id: describedby })}
|
|
66
|
+
invalid={invalid}
|
|
67
|
+
tooltip={tooltipFeedback}
|
|
68
|
+
valid={valid}
|
|
69
|
+
>
|
|
70
|
+
{feedback}
|
|
71
|
+
</CFormFeedback>
|
|
72
|
+
)}
|
|
73
|
+
{feedbackInvalid && (
|
|
74
|
+
<CFormFeedback id={describedby} invalid tooltip={tooltipFeedback}>
|
|
75
|
+
{feedbackInvalid}
|
|
76
|
+
</CFormFeedback>
|
|
77
|
+
)}
|
|
78
|
+
{feedbackValid && (
|
|
79
|
+
<CFormFeedback valid tooltip={tooltipFeedback}>
|
|
80
|
+
{feedbackValid}
|
|
81
|
+
</CFormFeedback>
|
|
82
|
+
)}
|
|
83
|
+
</>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
CFormControlValidation.propTypes = {
|
|
88
|
+
describedby: PropTypes.string,
|
|
89
|
+
feedback: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
90
|
+
feedbackValid: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
91
|
+
feedbackInvalid: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
92
|
+
invalid: PropTypes.bool,
|
|
93
|
+
tooltipFeedback: PropTypes.bool,
|
|
94
|
+
valid: PropTypes.bool,
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
CFormControlValidation.displayName = 'CFormControlValidation'
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
|
|
5
|
+
import { CFormControlValidation, CFormControlValidationProps } from './CFormControlValidation'
|
|
6
|
+
import { CFormFloating } from './CFormFloating'
|
|
7
|
+
import { CFormLabel } from './CFormLabel'
|
|
8
|
+
import { CFormText } from './CFormText'
|
|
9
|
+
|
|
10
|
+
export interface CFormControlWrapperProps extends CFormControlValidationProps {
|
|
11
|
+
/**
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
children?: ReactNode
|
|
15
|
+
/**
|
|
16
|
+
* Provide valuable, actionable valid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
|
|
17
|
+
*
|
|
18
|
+
* @since 4.2.0
|
|
19
|
+
*/
|
|
20
|
+
floatingLabel?: ReactNode | string
|
|
21
|
+
/**
|
|
22
|
+
* @ignore
|
|
23
|
+
*/
|
|
24
|
+
id?: string
|
|
25
|
+
/**
|
|
26
|
+
* Add a caption for a component.
|
|
27
|
+
*
|
|
28
|
+
* @since 4.2.0
|
|
29
|
+
*/
|
|
30
|
+
label?: ReactNode | string
|
|
31
|
+
/**
|
|
32
|
+
* Add helper text to the component.
|
|
33
|
+
*
|
|
34
|
+
* @since 4.2.0
|
|
35
|
+
*/
|
|
36
|
+
text?: ReactNode | string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const CFormControlWrapper: FC<CFormControlWrapperProps> = ({
|
|
40
|
+
children,
|
|
41
|
+
describedby,
|
|
42
|
+
feedback,
|
|
43
|
+
feedbackInvalid,
|
|
44
|
+
feedbackValid,
|
|
45
|
+
floatingLabel,
|
|
46
|
+
id,
|
|
47
|
+
invalid,
|
|
48
|
+
label,
|
|
49
|
+
text,
|
|
50
|
+
tooltipFeedback,
|
|
51
|
+
valid,
|
|
52
|
+
}) => {
|
|
53
|
+
return floatingLabel ? (
|
|
54
|
+
<CFormFloating>
|
|
55
|
+
{children}
|
|
56
|
+
<CFormLabel htmlFor={id}>{label || floatingLabel}</CFormLabel>
|
|
57
|
+
</CFormFloating>
|
|
58
|
+
) : (
|
|
59
|
+
<>
|
|
60
|
+
{label && <CFormLabel htmlFor={id}>{label}</CFormLabel>}
|
|
61
|
+
{children}
|
|
62
|
+
{text && <CFormText id={describedby}>{text}</CFormText>}
|
|
63
|
+
<CFormControlValidation
|
|
64
|
+
describedby={describedby}
|
|
65
|
+
feedback={feedback}
|
|
66
|
+
feedbackInvalid={feedbackInvalid}
|
|
67
|
+
feedbackValid={feedbackValid}
|
|
68
|
+
floatingLabel={floatingLabel}
|
|
69
|
+
invalid={invalid}
|
|
70
|
+
tooltipFeedback={tooltipFeedback}
|
|
71
|
+
valid={valid}
|
|
72
|
+
/>
|
|
73
|
+
</>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
CFormControlWrapper.propTypes = {
|
|
78
|
+
children: PropTypes.node,
|
|
79
|
+
floatingLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
80
|
+
label: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
81
|
+
text: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
82
|
+
...CFormControlValidation.propTypes,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
CFormControlWrapper.displayName = 'CFormControlWrapper'
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import React, { ChangeEventHandler, forwardRef, InputHTMLAttributes } from 'react'
|
|
2
|
-
|
|
1
|
+
import React, { ChangeEventHandler, forwardRef, InputHTMLAttributes, useState } from 'react'
|
|
2
|
+
|
|
3
3
|
import classNames from 'classnames'
|
|
4
|
-
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
5
|
+
|
|
6
|
+
import { CFormControlWrapper, CFormControlWrapperProps } from './CFormControlWrapper'
|
|
7
|
+
import { useEffect } from 'react'
|
|
5
8
|
|
|
6
|
-
export interface CFormInputProps
|
|
9
|
+
export interface CFormInputProps
|
|
10
|
+
extends CFormControlWrapperProps,
|
|
11
|
+
Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
7
12
|
/**
|
|
8
13
|
* A string of all className you want applied to the component.
|
|
9
14
|
*/
|
|
10
15
|
className?: string
|
|
11
16
|
/**
|
|
12
|
-
*
|
|
17
|
+
* Delay onChange event while typing. If set to true onChange event will be delayed 500ms, you can also provide the number of milliseconds you want to delay the onChange event.
|
|
13
18
|
*/
|
|
14
|
-
|
|
19
|
+
delay?: boolean | number
|
|
15
20
|
/**
|
|
16
|
-
*
|
|
21
|
+
* Toggle the disabled state for the component.
|
|
17
22
|
*/
|
|
18
|
-
|
|
23
|
+
disabled?: boolean
|
|
19
24
|
/**
|
|
20
25
|
* Method called immediately after the `value` prop changes.
|
|
21
26
|
*/
|
|
@@ -36,10 +41,6 @@ export interface CFormInputProps extends Omit<InputHTMLAttributes<HTMLInputEleme
|
|
|
36
41
|
* Specifies the type of component.
|
|
37
42
|
*/
|
|
38
43
|
type?: 'color' | 'file' | 'text' | string
|
|
39
|
-
/**
|
|
40
|
-
* Set component validation state to valid.
|
|
41
|
-
*/
|
|
42
|
-
valid?: boolean
|
|
43
44
|
/**
|
|
44
45
|
* The `value` attribute of component.
|
|
45
46
|
*
|
|
@@ -49,7 +50,40 @@ export interface CFormInputProps extends Omit<InputHTMLAttributes<HTMLInputEleme
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
export const CFormInput = forwardRef<HTMLInputElement, CFormInputProps>(
|
|
52
|
-
(
|
|
53
|
+
(
|
|
54
|
+
{
|
|
55
|
+
children,
|
|
56
|
+
className,
|
|
57
|
+
delay = false,
|
|
58
|
+
feedback,
|
|
59
|
+
feedbackInvalid,
|
|
60
|
+
feedbackValid,
|
|
61
|
+
floatingLabel,
|
|
62
|
+
id,
|
|
63
|
+
invalid,
|
|
64
|
+
label,
|
|
65
|
+
onChange,
|
|
66
|
+
plainText,
|
|
67
|
+
size,
|
|
68
|
+
text,
|
|
69
|
+
tooltipFeedback,
|
|
70
|
+
type = 'text',
|
|
71
|
+
valid,
|
|
72
|
+
...rest
|
|
73
|
+
},
|
|
74
|
+
ref,
|
|
75
|
+
) => {
|
|
76
|
+
const [value, setValue] = useState<React.ChangeEvent<HTMLInputElement>>()
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const timeOutId = setTimeout(
|
|
80
|
+
() => value && onChange && onChange(value),
|
|
81
|
+
typeof delay === 'number' ? delay : 500,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
return () => clearTimeout(timeOutId)
|
|
85
|
+
}, [value])
|
|
86
|
+
|
|
53
87
|
const _className = classNames(
|
|
54
88
|
plainText ? 'form-control-plaintext' : 'form-control',
|
|
55
89
|
{
|
|
@@ -60,22 +94,44 @@ export const CFormInput = forwardRef<HTMLInputElement, CFormInputProps>(
|
|
|
60
94
|
},
|
|
61
95
|
className,
|
|
62
96
|
)
|
|
97
|
+
|
|
63
98
|
return (
|
|
64
|
-
<
|
|
65
|
-
{
|
|
66
|
-
|
|
99
|
+
<CFormControlWrapper
|
|
100
|
+
describedby={rest['aria-describedby']}
|
|
101
|
+
feedback={feedback}
|
|
102
|
+
feedbackInvalid={feedbackInvalid}
|
|
103
|
+
feedbackValid={feedbackValid}
|
|
104
|
+
floatingLabel={floatingLabel}
|
|
105
|
+
id={id}
|
|
106
|
+
invalid={invalid}
|
|
107
|
+
label={label}
|
|
108
|
+
text={text}
|
|
109
|
+
tooltipFeedback={tooltipFeedback}
|
|
110
|
+
valid={valid}
|
|
111
|
+
>
|
|
112
|
+
<input
|
|
113
|
+
className={_className}
|
|
114
|
+
id={id}
|
|
115
|
+
type={type}
|
|
116
|
+
onChange={(event) => (delay ? setValue(event) : onChange && onChange(event))}
|
|
117
|
+
{...rest}
|
|
118
|
+
ref={ref}
|
|
119
|
+
>
|
|
120
|
+
{children}
|
|
121
|
+
</input>
|
|
122
|
+
</CFormControlWrapper>
|
|
67
123
|
)
|
|
68
124
|
},
|
|
69
125
|
)
|
|
70
126
|
|
|
71
127
|
CFormInput.propTypes = {
|
|
72
|
-
children: PropTypes.node,
|
|
73
128
|
className: PropTypes.string,
|
|
74
|
-
|
|
129
|
+
id: PropTypes.string,
|
|
130
|
+
delay: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]),
|
|
75
131
|
plainText: PropTypes.bool,
|
|
76
132
|
size: PropTypes.oneOf(['sm', 'lg']),
|
|
77
133
|
type: PropTypes.oneOfType([PropTypes.oneOf(['color', 'file', 'text']), PropTypes.string]),
|
|
78
|
-
|
|
134
|
+
...CFormControlWrapper.propTypes,
|
|
79
135
|
}
|
|
80
136
|
|
|
81
137
|
CFormInput.displayName = 'CFormInput'
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import React, { ChangeEventHandler, forwardRef, InputHTMLAttributes } from 'react'
|
|
2
|
-
|
|
1
|
+
import React, { ChangeEventHandler, forwardRef, InputHTMLAttributes, ReactNode } from 'react'
|
|
2
|
+
|
|
3
3
|
import classNames from 'classnames'
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
4
5
|
|
|
6
|
+
import { CFormLabel } from './CFormLabel'
|
|
5
7
|
export interface CFormRangeProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
6
8
|
/**
|
|
7
9
|
* A string of all className you want applied to the component.
|
|
@@ -11,6 +13,12 @@ export interface CFormRangeProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
11
13
|
* Toggle the disabled state for the component.
|
|
12
14
|
*/
|
|
13
15
|
disabled?: boolean
|
|
16
|
+
/**
|
|
17
|
+
* Add a caption for a component.
|
|
18
|
+
*
|
|
19
|
+
* @since 4.2.0
|
|
20
|
+
*/
|
|
21
|
+
label?: ReactNode | string
|
|
14
22
|
/**
|
|
15
23
|
* Specifies the maximum value for the component.
|
|
16
24
|
*/
|
|
@@ -40,14 +48,20 @@ export interface CFormRangeProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
export const CFormRange = forwardRef<HTMLInputElement, CFormRangeProps>(
|
|
43
|
-
({ className, ...rest }, ref) => {
|
|
51
|
+
({ className, label, ...rest }, ref) => {
|
|
44
52
|
const _className = classNames('form-range', className)
|
|
45
|
-
return
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
{label && <CFormLabel htmlFor={rest.id}>{label}</CFormLabel>}
|
|
56
|
+
<input type="range" className={_className} {...rest} ref={ref} />
|
|
57
|
+
</>
|
|
58
|
+
)
|
|
46
59
|
},
|
|
47
60
|
)
|
|
48
61
|
|
|
49
62
|
CFormRange.propTypes = {
|
|
50
63
|
className: PropTypes.string,
|
|
64
|
+
label: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
51
65
|
}
|
|
52
66
|
|
|
53
67
|
CFormRange.displayName = 'CFormRange'
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import React, { ChangeEventHandler, forwardRef, InputHTMLAttributes } from 'react'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import classNames from 'classnames'
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
5
|
+
|
|
6
|
+
import { CFormControlWrapper, CFormControlWrapperProps } from './CFormControlWrapper'
|
|
4
7
|
|
|
5
8
|
type Option = {
|
|
6
9
|
disabled?: boolean
|
|
7
10
|
label?: string
|
|
8
11
|
value?: string
|
|
9
12
|
}
|
|
10
|
-
export interface CFormSelectProps
|
|
13
|
+
export interface CFormSelectProps
|
|
14
|
+
extends CFormControlWrapperProps,
|
|
15
|
+
Omit<InputHTMLAttributes<HTMLSelectElement>, 'size'> {
|
|
11
16
|
/**
|
|
12
17
|
* A string of all className you want applied to the component.
|
|
13
18
|
*/
|
|
@@ -16,10 +21,6 @@ export interface CFormSelectProps extends Omit<InputHTMLAttributes<HTMLSelectEle
|
|
|
16
21
|
* Specifies the number of visible options in a drop-down list.
|
|
17
22
|
*/
|
|
18
23
|
htmlSize?: number
|
|
19
|
-
/**
|
|
20
|
-
* Set component validation state to invalid.
|
|
21
|
-
*/
|
|
22
|
-
invalid?: boolean
|
|
23
24
|
/**
|
|
24
25
|
* Method called immediately after the `value` prop changes.
|
|
25
26
|
*/
|
|
@@ -35,20 +36,36 @@ export interface CFormSelectProps extends Omit<InputHTMLAttributes<HTMLSelectEle
|
|
|
35
36
|
* Size the component small or large.
|
|
36
37
|
*/
|
|
37
38
|
size?: 'sm' | 'lg'
|
|
38
|
-
/**
|
|
39
|
-
* Set component validation state to valid.
|
|
40
|
-
*/
|
|
41
|
-
valid?: boolean
|
|
42
39
|
/**
|
|
43
40
|
* The `value` attribute of component.
|
|
44
41
|
*
|
|
45
42
|
* @controllable onChange
|
|
46
|
-
|
|
43
|
+
*/
|
|
47
44
|
value?: string | string[] | number
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
export const CFormSelect = forwardRef<HTMLSelectElement, CFormSelectProps>(
|
|
51
|
-
(
|
|
48
|
+
(
|
|
49
|
+
{
|
|
50
|
+
children,
|
|
51
|
+
className,
|
|
52
|
+
feedback,
|
|
53
|
+
feedbackInvalid,
|
|
54
|
+
feedbackValid,
|
|
55
|
+
floatingLabel,
|
|
56
|
+
htmlSize,
|
|
57
|
+
id,
|
|
58
|
+
invalid,
|
|
59
|
+
label,
|
|
60
|
+
options,
|
|
61
|
+
size,
|
|
62
|
+
text,
|
|
63
|
+
tooltipFeedback,
|
|
64
|
+
valid,
|
|
65
|
+
...rest
|
|
66
|
+
},
|
|
67
|
+
ref,
|
|
68
|
+
) => {
|
|
52
69
|
const _className = classNames(
|
|
53
70
|
'form-select',
|
|
54
71
|
{
|
|
@@ -59,34 +76,45 @@ export const CFormSelect = forwardRef<HTMLSelectElement, CFormSelectProps>(
|
|
|
59
76
|
className,
|
|
60
77
|
)
|
|
61
78
|
return (
|
|
62
|
-
<
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
<CFormControlWrapper
|
|
80
|
+
describedby={rest['aria-describedby']}
|
|
81
|
+
feedback={feedback}
|
|
82
|
+
feedbackInvalid={feedbackInvalid}
|
|
83
|
+
feedbackValid={feedbackValid}
|
|
84
|
+
floatingLabel={floatingLabel}
|
|
85
|
+
id={id}
|
|
86
|
+
invalid={invalid}
|
|
87
|
+
label={label}
|
|
88
|
+
text={text}
|
|
89
|
+
tooltipFeedback={tooltipFeedback}
|
|
90
|
+
valid={valid}
|
|
91
|
+
>
|
|
92
|
+
<select id={id} className={_className} size={htmlSize} {...rest} ref={ref}>
|
|
93
|
+
{options
|
|
94
|
+
? options.map((option, index) => {
|
|
95
|
+
return (
|
|
96
|
+
<option
|
|
97
|
+
{...(typeof option === 'object' &&
|
|
98
|
+
option.disabled && { disabled: option.disabled })}
|
|
99
|
+
{...(typeof option === 'object' && option.value && { value: option.value })}
|
|
100
|
+
key={index}
|
|
101
|
+
>
|
|
102
|
+
{typeof option === 'string' ? option : option.label}
|
|
103
|
+
</option>
|
|
104
|
+
)
|
|
105
|
+
})
|
|
106
|
+
: children}
|
|
107
|
+
</select>
|
|
108
|
+
</CFormControlWrapper>
|
|
78
109
|
)
|
|
79
110
|
},
|
|
80
111
|
)
|
|
81
112
|
|
|
82
113
|
CFormSelect.propTypes = {
|
|
83
|
-
children: PropTypes.node,
|
|
84
114
|
className: PropTypes.string,
|
|
85
115
|
htmlSize: PropTypes.number,
|
|
86
|
-
invalid: PropTypes.bool,
|
|
87
116
|
options: PropTypes.array,
|
|
88
|
-
|
|
89
|
-
valid: PropTypes.bool,
|
|
117
|
+
...CFormControlWrapper.propTypes,
|
|
90
118
|
}
|
|
91
119
|
|
|
92
120
|
CFormSelect.displayName = 'CFormSelect'
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import React, { ChangeEventHandler, forwardRef, InputHTMLAttributes } from 'react'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import classNames from 'classnames'
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
import { CFormControlWrapper, CFormControlWrapperProps } from './CFormControlWrapper'
|
|
7
|
+
|
|
8
|
+
export interface CFormTextareaProps
|
|
9
|
+
extends CFormControlWrapperProps,
|
|
10
|
+
InputHTMLAttributes<HTMLTextAreaElement> {
|
|
6
11
|
/**
|
|
7
12
|
* A string of all className you want applied to the component.
|
|
8
13
|
*/
|
|
@@ -11,10 +16,6 @@ export interface CFormTextareaProps extends InputHTMLAttributes<HTMLTextAreaElem
|
|
|
11
16
|
* Toggle the disabled state for the component.
|
|
12
17
|
*/
|
|
13
18
|
disabled?: boolean
|
|
14
|
-
/**
|
|
15
|
-
* Set component validation state to invalid.
|
|
16
|
-
*/
|
|
17
|
-
invalid?: boolean
|
|
18
19
|
/**
|
|
19
20
|
* Method called immediately after the `value` prop changes.
|
|
20
21
|
*/
|
|
@@ -27,10 +28,6 @@ export interface CFormTextareaProps extends InputHTMLAttributes<HTMLTextAreaElem
|
|
|
27
28
|
* Toggle the readonly state for the component.
|
|
28
29
|
*/
|
|
29
30
|
readOnly?: boolean
|
|
30
|
-
/**
|
|
31
|
-
* Set component validation state to valid.
|
|
32
|
-
*/
|
|
33
|
-
valid?: boolean
|
|
34
31
|
/**
|
|
35
32
|
* The `value` attribute of component.
|
|
36
33
|
*
|
|
@@ -40,7 +37,25 @@ export interface CFormTextareaProps extends InputHTMLAttributes<HTMLTextAreaElem
|
|
|
40
37
|
}
|
|
41
38
|
|
|
42
39
|
export const CFormTextarea = forwardRef<HTMLTextAreaElement, CFormTextareaProps>(
|
|
43
|
-
(
|
|
40
|
+
(
|
|
41
|
+
{
|
|
42
|
+
children,
|
|
43
|
+
className,
|
|
44
|
+
feedback,
|
|
45
|
+
feedbackInvalid,
|
|
46
|
+
feedbackValid,
|
|
47
|
+
floatingLabel,
|
|
48
|
+
id,
|
|
49
|
+
invalid,
|
|
50
|
+
label,
|
|
51
|
+
plainText,
|
|
52
|
+
text,
|
|
53
|
+
tooltipFeedback,
|
|
54
|
+
valid,
|
|
55
|
+
...rest
|
|
56
|
+
},
|
|
57
|
+
ref,
|
|
58
|
+
) => {
|
|
44
59
|
const _className = classNames(
|
|
45
60
|
plainText ? 'form-control-plaintext' : 'form-control',
|
|
46
61
|
{
|
|
@@ -50,19 +65,32 @@ export const CFormTextarea = forwardRef<HTMLTextAreaElement, CFormTextareaProps>
|
|
|
50
65
|
className,
|
|
51
66
|
)
|
|
52
67
|
return (
|
|
53
|
-
<
|
|
54
|
-
{
|
|
55
|
-
|
|
68
|
+
<CFormControlWrapper
|
|
69
|
+
describedby={rest['aria-describedby']}
|
|
70
|
+
feedback={feedback}
|
|
71
|
+
feedbackInvalid={feedbackInvalid}
|
|
72
|
+
feedbackValid={feedbackValid}
|
|
73
|
+
floatingLabel={floatingLabel}
|
|
74
|
+
id={id}
|
|
75
|
+
invalid={invalid}
|
|
76
|
+
label={label}
|
|
77
|
+
text={text}
|
|
78
|
+
tooltipFeedback={tooltipFeedback}
|
|
79
|
+
valid={valid}
|
|
80
|
+
>
|
|
81
|
+
<textarea className={_className} id={id} {...rest} ref={ref}>
|
|
82
|
+
{children}
|
|
83
|
+
</textarea>
|
|
84
|
+
</CFormControlWrapper>
|
|
56
85
|
)
|
|
57
86
|
},
|
|
58
87
|
)
|
|
59
88
|
|
|
60
89
|
CFormTextarea.propTypes = {
|
|
61
|
-
children: PropTypes.node,
|
|
62
90
|
className: PropTypes.string,
|
|
63
|
-
|
|
91
|
+
id: PropTypes.string,
|
|
64
92
|
plainText: PropTypes.bool,
|
|
65
|
-
|
|
93
|
+
...CFormControlWrapper.propTypes,
|
|
66
94
|
}
|
|
67
95
|
|
|
68
96
|
CFormTextarea.displayName = 'CFormTextarea'
|