@instructure/ui-form-field 10.26.1-snapshot-2 → 10.26.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/CHANGELOG.md +2 -23
- package/es/FormField/index.js +2 -1
- package/es/FormField/props.js +18 -1
- package/es/FormFieldGroup/index.js +2 -2
- package/es/FormFieldGroup/props.js +17 -1
- package/es/FormFieldLabel/index.js +6 -6
- package/es/FormFieldLabel/props.js +6 -1
- package/es/FormFieldLayout/index.js +2 -2
- package/es/FormFieldLayout/props.js +20 -1
- package/es/FormFieldMessage/index.js +2 -2
- package/es/FormFieldMessage/props.js +6 -1
- package/es/FormFieldMessages/index.js +2 -2
- package/es/FormFieldMessages/props.js +7 -1
- package/es/FormPropTypes.js +41 -1
- package/es/index.js +2 -1
- package/lib/FormField/index.js +1 -0
- package/lib/FormField/props.js +19 -1
- package/lib/FormFieldGroup/index.js +1 -1
- package/lib/FormFieldGroup/props.js +18 -1
- package/lib/FormFieldLabel/index.js +5 -4
- package/lib/FormFieldLabel/props.js +7 -1
- package/lib/FormFieldLayout/index.js +1 -1
- package/lib/FormFieldLayout/props.js +21 -1
- package/lib/FormFieldMessage/index.js +1 -1
- package/lib/FormFieldMessage/props.js +6 -1
- package/lib/FormFieldMessages/index.js +1 -1
- package/lib/FormFieldMessages/props.js +8 -1
- package/lib/FormPropTypes.js +43 -1
- package/lib/index.js +8 -1
- package/package.json +17 -16
- package/src/FormField/index.tsx +2 -1
- package/src/FormField/props.ts +25 -2
- package/src/FormFieldGroup/index.tsx +3 -3
- package/src/FormFieldGroup/props.ts +22 -1
- package/src/FormFieldLabel/index.tsx +8 -2
- package/src/FormFieldLabel/props.ts +10 -1
- package/src/FormFieldLayout/index.tsx +2 -1
- package/src/FormFieldLayout/props.ts +26 -2
- package/src/FormFieldMessage/index.tsx +2 -1
- package/src/FormFieldMessage/props.ts +16 -2
- package/src/FormFieldMessages/index.tsx +2 -1
- package/src/FormFieldMessages/props.ts +12 -1
- package/src/FormPropTypes.ts +19 -0
- package/src/index.ts +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/FormField/index.d.ts +1 -0
- package/types/FormField/index.d.ts.map +1 -1
- package/types/FormField/props.d.ts +3 -2
- package/types/FormField/props.d.ts.map +1 -1
- package/types/FormFieldGroup/index.d.ts +14 -0
- package/types/FormFieldGroup/index.d.ts.map +1 -1
- package/types/FormFieldGroup/props.d.ts +3 -2
- package/types/FormFieldGroup/props.d.ts.map +1 -1
- package/types/FormFieldLabel/index.d.ts +4 -0
- package/types/FormFieldLabel/index.d.ts.map +1 -1
- package/types/FormFieldLabel/props.d.ts +3 -2
- package/types/FormFieldLabel/props.d.ts.map +1 -1
- package/types/FormFieldLayout/index.d.ts +2 -1
- package/types/FormFieldLayout/index.d.ts.map +1 -1
- package/types/FormFieldLayout/props.d.ts +3 -2
- package/types/FormFieldLayout/props.d.ts.map +1 -1
- package/types/FormFieldMessage/index.d.ts +4 -0
- package/types/FormFieldMessage/index.d.ts.map +1 -1
- package/types/FormFieldMessage/props.d.ts +3 -2
- package/types/FormFieldMessage/props.d.ts.map +1 -1
- package/types/FormFieldMessages/index.d.ts +4 -0
- package/types/FormFieldMessages/index.d.ts.map +1 -1
- package/types/FormFieldMessages/props.d.ts +3 -2
- package/types/FormFieldMessages/props.d.ts.map +1 -1
- package/types/FormPropTypes.d.ts +11 -0
- package/types/FormPropTypes.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
package/lib/index.js
CHANGED
|
@@ -39,9 +39,16 @@ Object.defineProperty(exports, "FormFieldMessages", {
|
|
|
39
39
|
return _FormFieldMessages.FormFieldMessages;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
+
Object.defineProperty(exports, "FormPropTypes", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _FormPropTypes.FormPropTypes;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
42
48
|
var _FormField = require("./FormField");
|
|
43
49
|
var _FormFieldLabel = require("./FormFieldLabel");
|
|
44
50
|
var _FormFieldMessage = require("./FormFieldMessage");
|
|
45
51
|
var _FormFieldMessages = require("./FormFieldMessages");
|
|
46
52
|
var _FormFieldLayout = require("./FormFieldLayout");
|
|
47
|
-
var _FormFieldGroup = require("./FormFieldGroup");
|
|
53
|
+
var _FormFieldGroup = require("./FormFieldGroup");
|
|
54
|
+
var _FormPropTypes = require("./FormPropTypes");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-form-field",
|
|
3
|
-
"version": "10.26.1
|
|
3
|
+
"version": "10.26.1",
|
|
4
4
|
"description": "Form layout components.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,28 +23,29 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "10.26.1
|
|
27
|
-
"@instructure/ui-babel-preset": "10.26.1
|
|
28
|
-
"@instructure/ui-themes": "10.26.1
|
|
26
|
+
"@instructure/ui-axe-check": "10.26.1",
|
|
27
|
+
"@instructure/ui-babel-preset": "10.26.1",
|
|
28
|
+
"@instructure/ui-themes": "10.26.1",
|
|
29
29
|
"@testing-library/jest-dom": "^6.6.3",
|
|
30
|
-
"@testing-library/react": "
|
|
30
|
+
"@testing-library/react": "^16.0.1",
|
|
31
31
|
"vitest": "^3.2.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.27.6",
|
|
35
|
-
"@instructure/console": "10.26.1
|
|
36
|
-
"@instructure/emotion": "10.26.1
|
|
37
|
-
"@instructure/shared-types": "10.26.1
|
|
38
|
-
"@instructure/ui-a11y-content": "10.26.1
|
|
39
|
-
"@instructure/ui-a11y-utils": "10.26.1
|
|
40
|
-
"@instructure/ui-grid": "10.26.1
|
|
41
|
-
"@instructure/ui-icons": "10.26.1
|
|
42
|
-
"@instructure/ui-react-utils": "10.26.1
|
|
43
|
-
"@instructure/ui-utils": "10.26.1
|
|
44
|
-
"@instructure/uid": "10.26.1
|
|
35
|
+
"@instructure/console": "10.26.1",
|
|
36
|
+
"@instructure/emotion": "10.26.1",
|
|
37
|
+
"@instructure/shared-types": "10.26.1",
|
|
38
|
+
"@instructure/ui-a11y-content": "10.26.1",
|
|
39
|
+
"@instructure/ui-a11y-utils": "10.26.1",
|
|
40
|
+
"@instructure/ui-grid": "10.26.1",
|
|
41
|
+
"@instructure/ui-icons": "10.26.1",
|
|
42
|
+
"@instructure/ui-react-utils": "10.26.1",
|
|
43
|
+
"@instructure/ui-utils": "10.26.1",
|
|
44
|
+
"@instructure/uid": "10.26.1",
|
|
45
|
+
"prop-types": "^15.8.1"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"react": ">=
|
|
48
|
+
"react": ">=16.14 <=18"
|
|
48
49
|
},
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"access": "public"
|
package/src/FormField/index.tsx
CHANGED
|
@@ -28,7 +28,7 @@ import { omitProps, pickProps } from '@instructure/ui-react-utils'
|
|
|
28
28
|
|
|
29
29
|
import { FormFieldLayout } from '../FormFieldLayout'
|
|
30
30
|
|
|
31
|
-
import { allowedProps } from './props'
|
|
31
|
+
import { propTypes, allowedProps } from './props'
|
|
32
32
|
import type { FormFieldProps } from './props'
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -39,6 +39,7 @@ category: components
|
|
|
39
39
|
class FormField extends Component<FormFieldProps> {
|
|
40
40
|
static readonly componentId = 'FormField'
|
|
41
41
|
|
|
42
|
+
static propTypes = propTypes
|
|
42
43
|
static allowedProps = allowedProps
|
|
43
44
|
static defaultProps = {
|
|
44
45
|
inline: false,
|
package/src/FormField/props.ts
CHANGED
|
@@ -23,8 +23,14 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
26
27
|
|
|
27
|
-
import
|
|
28
|
+
import { FormPropTypes } from '../FormPropTypes'
|
|
29
|
+
|
|
30
|
+
import type {
|
|
31
|
+
OtherHTMLAttributes,
|
|
32
|
+
PropValidators
|
|
33
|
+
} from '@instructure/shared-types'
|
|
28
34
|
import type { FormMessage } from '../FormPropTypes'
|
|
29
35
|
import type { Spacing } from '@instructure/emotion'
|
|
30
36
|
|
|
@@ -69,6 +75,23 @@ type PropKeys = keyof FormFieldOwnProps
|
|
|
69
75
|
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
70
76
|
|
|
71
77
|
type FormFieldProps = FormFieldOwnProps & OtherHTMLAttributes<FormFieldOwnProps>
|
|
78
|
+
|
|
79
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
80
|
+
label: PropTypes.node.isRequired,
|
|
81
|
+
id: PropTypes.string.isRequired,
|
|
82
|
+
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
83
|
+
messagesId: PropTypes.string,
|
|
84
|
+
children: PropTypes.node,
|
|
85
|
+
inline: PropTypes.bool,
|
|
86
|
+
layout: PropTypes.oneOf(['stacked', 'inline']),
|
|
87
|
+
labelAlign: PropTypes.oneOf(['start', 'end']),
|
|
88
|
+
vAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
|
|
89
|
+
width: PropTypes.string,
|
|
90
|
+
inputContainerRef: PropTypes.func,
|
|
91
|
+
elementRef: PropTypes.func,
|
|
92
|
+
margin: PropTypes.string
|
|
93
|
+
}
|
|
94
|
+
|
|
72
95
|
const allowedProps: AllowedPropKeys = [
|
|
73
96
|
'label',
|
|
74
97
|
'id',
|
|
@@ -86,4 +109,4 @@ const allowedProps: AllowedPropKeys = [
|
|
|
86
109
|
]
|
|
87
110
|
|
|
88
111
|
export type { FormFieldOwnProps, FormFieldProps }
|
|
89
|
-
export { allowedProps }
|
|
112
|
+
export { propTypes, allowedProps }
|
|
@@ -33,7 +33,7 @@ import { FormFieldLayout } from '../FormFieldLayout'
|
|
|
33
33
|
import generateStyle from './styles'
|
|
34
34
|
import generateComponentTheme from './theme'
|
|
35
35
|
|
|
36
|
-
import { allowedProps } from './props'
|
|
36
|
+
import { propTypes, allowedProps } from './props'
|
|
37
37
|
import type { FormFieldGroupProps, FormFieldGroupStyleProps } from './props'
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -45,6 +45,7 @@ category: components
|
|
|
45
45
|
class FormFieldGroup extends Component<FormFieldGroupProps> {
|
|
46
46
|
static readonly componentId = 'FormFieldGroup'
|
|
47
47
|
|
|
48
|
+
static propTypes = propTypes
|
|
48
49
|
static allowedProps = allowedProps
|
|
49
50
|
static defaultProps = {
|
|
50
51
|
as: 'fieldset',
|
|
@@ -99,8 +100,7 @@ class FormFieldGroup extends Component<FormFieldGroupProps> {
|
|
|
99
100
|
return child ? (
|
|
100
101
|
<Grid.Col
|
|
101
102
|
width={
|
|
102
|
-
(child as ReactElement).props &&
|
|
103
|
-
(child as ReactElement<any>).props.width
|
|
103
|
+
(child as ReactElement).props && (child as ReactElement).props.width
|
|
104
104
|
? 'auto'
|
|
105
105
|
: undefined
|
|
106
106
|
}
|
|
@@ -22,8 +22,13 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import PropTypes from 'prop-types'
|
|
26
|
+
|
|
27
|
+
import { FormPropTypes } from '../FormPropTypes'
|
|
28
|
+
|
|
25
29
|
import type {
|
|
26
30
|
AsElementType,
|
|
31
|
+
PropValidators,
|
|
27
32
|
FormFieldGroupTheme,
|
|
28
33
|
OtherHTMLAttributes
|
|
29
34
|
} from '@instructure/shared-types'
|
|
@@ -80,6 +85,22 @@ type FormFieldGroupProps = FormFieldGroupOwnProps &
|
|
|
80
85
|
>
|
|
81
86
|
|
|
82
87
|
type FormFieldGroupStyle = ComponentStyle<'formFieldGroup'>
|
|
88
|
+
|
|
89
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
90
|
+
description: PropTypes.node.isRequired,
|
|
91
|
+
as: PropTypes.elementType,
|
|
92
|
+
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
93
|
+
messagesId: PropTypes.string,
|
|
94
|
+
disabled: PropTypes.bool,
|
|
95
|
+
children: PropTypes.node,
|
|
96
|
+
layout: PropTypes.oneOf(['stacked', 'columns', 'inline']),
|
|
97
|
+
rowSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
|
|
98
|
+
colSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
|
|
99
|
+
vAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
|
|
100
|
+
startAt: PropTypes.oneOf(['small', 'medium', 'large', 'x-large', null]),
|
|
101
|
+
elementRef: PropTypes.func
|
|
102
|
+
}
|
|
103
|
+
|
|
83
104
|
const allowedProps: AllowedPropKeys = [
|
|
84
105
|
'description',
|
|
85
106
|
'as',
|
|
@@ -100,4 +121,4 @@ export type {
|
|
|
100
121
|
FormFieldGroupStyleProps,
|
|
101
122
|
FormFieldGroupStyle
|
|
102
123
|
}
|
|
103
|
-
export { allowedProps }
|
|
124
|
+
export { propTypes, allowedProps }
|
|
@@ -24,13 +24,17 @@
|
|
|
24
24
|
|
|
25
25
|
import { Component } from 'react'
|
|
26
26
|
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
omitProps,
|
|
29
|
+
getElementType,
|
|
30
|
+
deprecated
|
|
31
|
+
} from '@instructure/ui-react-utils'
|
|
28
32
|
import { withStyle } from '@instructure/emotion'
|
|
29
33
|
|
|
30
34
|
import generateStyle from './styles'
|
|
31
35
|
import generateComponentTheme from './theme'
|
|
32
36
|
|
|
33
|
-
import { allowedProps } from './props'
|
|
37
|
+
import { propTypes, allowedProps } from './props'
|
|
34
38
|
import type { FormFieldLabelProps } from './props'
|
|
35
39
|
|
|
36
40
|
/**
|
|
@@ -52,9 +56,11 @@ type: example
|
|
|
52
56
|
removed in the future
|
|
53
57
|
**/
|
|
54
58
|
@withStyle(generateStyle, generateComponentTheme)
|
|
59
|
+
@deprecated('10', null, 'This component will be removed in a future version')
|
|
55
60
|
class FormFieldLabel extends Component<FormFieldLabelProps> {
|
|
56
61
|
static readonly componentId = 'FormFieldLabel'
|
|
57
62
|
|
|
63
|
+
static propTypes = propTypes
|
|
58
64
|
static allowedProps = allowedProps
|
|
59
65
|
static defaultProps = {
|
|
60
66
|
as: 'span'
|
|
@@ -22,8 +22,11 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import PropTypes from 'prop-types'
|
|
26
|
+
|
|
25
27
|
import type {
|
|
26
28
|
AsElementType,
|
|
29
|
+
PropValidators,
|
|
27
30
|
FormFieldLabelTheme,
|
|
28
31
|
OtherHTMLAttributes
|
|
29
32
|
} from '@instructure/shared-types'
|
|
@@ -43,7 +46,13 @@ type FormFieldLabelProps = FormFieldLabelOwnProps &
|
|
|
43
46
|
OtherHTMLAttributes<FormFieldLabelOwnProps>
|
|
44
47
|
|
|
45
48
|
type FormFieldLabelStyle = ComponentStyle<'formFieldLabel'>
|
|
49
|
+
|
|
50
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
51
|
+
children: PropTypes.node.isRequired,
|
|
52
|
+
as: PropTypes.elementType
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
const allowedProps: AllowedPropKeys = ['as', 'children']
|
|
47
56
|
|
|
48
57
|
export type { FormFieldLabelProps, FormFieldLabelStyle }
|
|
49
|
-
export { allowedProps }
|
|
58
|
+
export { propTypes, allowedProps }
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
import { withStyle } from '@instructure/emotion'
|
|
34
34
|
import { FormFieldMessages } from '../FormFieldMessages'
|
|
35
35
|
import generateStyle from './styles'
|
|
36
|
-
import { allowedProps, FormFieldStyleProps } from './props'
|
|
36
|
+
import { propTypes, allowedProps, FormFieldStyleProps } from './props'
|
|
37
37
|
import type { FormFieldLayoutProps } from './props'
|
|
38
38
|
import generateComponentTheme from './theme'
|
|
39
39
|
|
|
@@ -47,6 +47,7 @@ parent: FormField
|
|
|
47
47
|
class FormFieldLayout extends Component<FormFieldLayoutProps> {
|
|
48
48
|
static readonly componentId = 'FormFieldLayout'
|
|
49
49
|
|
|
50
|
+
static propTypes = propTypes
|
|
50
51
|
static allowedProps = allowedProps
|
|
51
52
|
static defaultProps = {
|
|
52
53
|
inline: false,
|
|
@@ -22,9 +22,14 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import PropTypes from 'prop-types'
|
|
26
|
+
|
|
27
|
+
import { FormPropTypes } from '../FormPropTypes'
|
|
28
|
+
|
|
25
29
|
import type {
|
|
26
30
|
AsElementType,
|
|
27
|
-
OtherHTMLAttributes
|
|
31
|
+
OtherHTMLAttributes,
|
|
32
|
+
PropValidators
|
|
28
33
|
} from '@instructure/shared-types'
|
|
29
34
|
import type {
|
|
30
35
|
WithStyleProps,
|
|
@@ -105,6 +110,25 @@ type FormFieldLayoutProps = FormFieldLayoutOwnProps &
|
|
|
105
110
|
type FormFieldLayoutStyle = ComponentStyle<
|
|
106
111
|
'formFieldLayout' | 'formFieldLabel' | 'formFieldChildren'
|
|
107
112
|
>
|
|
113
|
+
|
|
114
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
115
|
+
label: PropTypes.node.isRequired,
|
|
116
|
+
id: PropTypes.string,
|
|
117
|
+
as: PropTypes.elementType,
|
|
118
|
+
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
119
|
+
messagesId: PropTypes.string,
|
|
120
|
+
children: PropTypes.node,
|
|
121
|
+
inline: PropTypes.bool,
|
|
122
|
+
layout: PropTypes.oneOf(['stacked', 'inline']),
|
|
123
|
+
labelAlign: PropTypes.oneOf(['start', 'end']),
|
|
124
|
+
vAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
|
|
125
|
+
width: PropTypes.string,
|
|
126
|
+
inputContainerRef: PropTypes.func,
|
|
127
|
+
elementRef: PropTypes.func,
|
|
128
|
+
isGroup: PropTypes.bool,
|
|
129
|
+
margin: PropTypes.string
|
|
130
|
+
}
|
|
131
|
+
|
|
108
132
|
const allowedProps: AllowedPropKeys = [
|
|
109
133
|
'label',
|
|
110
134
|
'id',
|
|
@@ -134,4 +158,4 @@ export type {
|
|
|
134
158
|
FormFieldLayoutStyle,
|
|
135
159
|
FormFieldLayoutOwnProps
|
|
136
160
|
}
|
|
137
|
-
export { allowedProps }
|
|
161
|
+
export { propTypes, allowedProps }
|
|
@@ -33,7 +33,7 @@ import { withStyle } from '@instructure/emotion'
|
|
|
33
33
|
import generateStyle from './styles'
|
|
34
34
|
import generateComponentTheme from './theme'
|
|
35
35
|
|
|
36
|
-
import { allowedProps } from './props'
|
|
36
|
+
import { propTypes, allowedProps } from './props'
|
|
37
37
|
import type { FormFieldMessageProps } from './props'
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -55,6 +55,7 @@ type: example
|
|
|
55
55
|
class FormFieldMessage extends Component<FormFieldMessageProps> {
|
|
56
56
|
static readonly componentId = 'FormFieldMessage'
|
|
57
57
|
|
|
58
|
+
static propTypes = propTypes
|
|
58
59
|
static allowedProps = allowedProps
|
|
59
60
|
static defaultProps = {
|
|
60
61
|
variant: 'hint'
|
|
@@ -22,7 +22,15 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import
|
|
25
|
+
import {
|
|
26
|
+
formMessageTypePropType,
|
|
27
|
+
formMessageChildPropType
|
|
28
|
+
} from '../FormPropTypes'
|
|
29
|
+
|
|
30
|
+
import type {
|
|
31
|
+
PropValidators,
|
|
32
|
+
FormFieldMessageTheme
|
|
33
|
+
} from '@instructure/shared-types'
|
|
26
34
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
27
35
|
import type { FormMessageType, FormMessageChild } from '../FormPropTypes'
|
|
28
36
|
|
|
@@ -39,7 +47,13 @@ type FormFieldMessageProps = FormFieldMessageOwnProps &
|
|
|
39
47
|
WithStyleProps<FormFieldMessageTheme, FormFieldMessageStyle>
|
|
40
48
|
|
|
41
49
|
type FormFieldMessageStyle = ComponentStyle<'formFieldMessage' | 'errorIcon'>
|
|
50
|
+
|
|
51
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
52
|
+
variant: formMessageTypePropType,
|
|
53
|
+
children: formMessageChildPropType
|
|
54
|
+
}
|
|
55
|
+
|
|
42
56
|
const allowedProps: AllowedPropKeys = ['variant', 'children']
|
|
43
57
|
|
|
44
58
|
export type { FormFieldMessageProps, FormFieldMessageStyle }
|
|
45
|
-
export { allowedProps }
|
|
59
|
+
export { propTypes, allowedProps }
|
|
@@ -33,7 +33,7 @@ import { FormFieldMessage } from '../FormFieldMessage'
|
|
|
33
33
|
import generateStyle from './styles'
|
|
34
34
|
import generateComponentTheme from './theme'
|
|
35
35
|
|
|
36
|
-
import { allowedProps } from './props'
|
|
36
|
+
import { propTypes, allowedProps } from './props'
|
|
37
37
|
import type { FormFieldMessagesProps } from './props'
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -58,6 +58,7 @@ type: example
|
|
|
58
58
|
class FormFieldMessages extends Component<FormFieldMessagesProps> {
|
|
59
59
|
static readonly componentId = 'FormFieldMessages'
|
|
60
60
|
|
|
61
|
+
static propTypes = propTypes
|
|
61
62
|
static allowedProps = allowedProps
|
|
62
63
|
static defaultProps = {}
|
|
63
64
|
|
|
@@ -22,7 +22,12 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import PropTypes from 'prop-types'
|
|
26
|
+
|
|
27
|
+
import { FormPropTypes } from '../FormPropTypes'
|
|
28
|
+
|
|
25
29
|
import type {
|
|
30
|
+
PropValidators,
|
|
26
31
|
FormFieldMessagesTheme,
|
|
27
32
|
OtherHTMLAttributes
|
|
28
33
|
} from '@instructure/shared-types'
|
|
@@ -53,7 +58,13 @@ type FormFieldMessagesProps = FormFieldMessagesOwnProps &
|
|
|
53
58
|
OtherHTMLAttributes<FormFieldMessagesOwnProps>
|
|
54
59
|
|
|
55
60
|
type FormFieldMessagesStyle = ComponentStyle<'formFieldMessages' | 'message'>
|
|
61
|
+
|
|
62
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
63
|
+
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
64
|
+
gridArea: PropTypes.string
|
|
65
|
+
}
|
|
66
|
+
|
|
56
67
|
const allowedProps: AllowedPropKeys = ['messages', 'gridArea']
|
|
57
68
|
|
|
58
69
|
export type { FormFieldMessagesProps, FormFieldMessagesStyle }
|
|
59
|
-
export { allowedProps }
|
|
70
|
+
export { propTypes, allowedProps }
|
package/src/FormPropTypes.ts
CHANGED
|
@@ -23,6 +23,16 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
const formMessageTypePropType = PropTypes.oneOf([
|
|
29
|
+
'error',
|
|
30
|
+
'newError',
|
|
31
|
+
'hint',
|
|
32
|
+
'success',
|
|
33
|
+
'screenreader-only'
|
|
34
|
+
])
|
|
35
|
+
const formMessageChildPropType = PropTypes.node
|
|
26
36
|
|
|
27
37
|
type FormMessageType =
|
|
28
38
|
| 'newError'
|
|
@@ -36,9 +46,18 @@ type FormMessageType =
|
|
|
36
46
|
*/
|
|
37
47
|
type FormMessageChild = React.ReactNode
|
|
38
48
|
|
|
49
|
+
const FormPropTypes = {
|
|
50
|
+
message: PropTypes.shape({
|
|
51
|
+
type: formMessageTypePropType,
|
|
52
|
+
text: formMessageChildPropType
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
39
56
|
type FormMessage = {
|
|
40
57
|
type: FormMessageType
|
|
41
58
|
text: FormMessageChild
|
|
42
59
|
}
|
|
43
60
|
|
|
61
|
+
export default FormPropTypes
|
|
62
|
+
export { FormPropTypes, formMessageTypePropType, formMessageChildPropType }
|
|
44
63
|
export type { FormMessage, FormMessageType, FormMessageChild }
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export { FormFieldMessages } from './FormFieldMessages'
|
|
|
29
29
|
export { FormFieldLayout } from './FormFieldLayout'
|
|
30
30
|
export { FormFieldGroup } from './FormFieldGroup'
|
|
31
31
|
|
|
32
|
+
export { FormPropTypes } from './FormPropTypes'
|
|
32
33
|
export type { FormMessageType, FormMessage } from './FormPropTypes'
|
|
33
34
|
|
|
34
35
|
export type { FormFieldOwnProps, FormFieldProps } from './FormField/props'
|