@instructure/ui-form-field 11.6.0 → 11.6.1-snapshot-129

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.
Files changed (248) hide show
  1. package/CHANGELOG.md +46 -300
  2. package/es/FormField/{index.js → v1/index.js} +1 -1
  3. package/es/FormField/v2/index.js +78 -0
  4. package/es/FormField/v2/props.js +26 -0
  5. package/es/FormFieldGroup/{index.js → v1/index.js} +5 -4
  6. package/es/FormFieldGroup/v2/index.js +130 -0
  7. package/es/FormFieldGroup/v2/props.js +26 -0
  8. package/es/FormFieldGroup/v2/styles.js +49 -0
  9. package/es/FormFieldLabel/{index.js → v1/index.js} +1 -1
  10. package/es/FormFieldLabel/v2/index.js +83 -0
  11. package/es/FormFieldLabel/v2/props.js +26 -0
  12. package/es/FormFieldLabel/v2/styles.js +62 -0
  13. package/es/FormFieldLabel/v2/theme.js +52 -0
  14. package/es/FormFieldLayout/{index.js → v1/index.js} +2 -2
  15. package/es/FormFieldLayout/{styles.js → v1/styles.js} +2 -2
  16. package/es/FormFieldLayout/v2/index.js +207 -0
  17. package/es/FormFieldLayout/v2/props.js +26 -0
  18. package/es/FormFieldLayout/v2/styles.js +171 -0
  19. package/es/FormFieldMessage/{index.js → v1/index.js} +1 -1
  20. package/es/FormFieldMessage/v2/index.js +96 -0
  21. package/es/FormFieldMessage/v2/props.js +26 -0
  22. package/es/FormFieldMessage/v2/styles.js +69 -0
  23. package/es/FormFieldMessages/{index.js → v1/index.js} +2 -2
  24. package/es/FormFieldMessages/v2/index.js +88 -0
  25. package/es/FormFieldMessages/v2/props.js +26 -0
  26. package/es/FormFieldMessages/v2/styles.js +50 -0
  27. package/es/{index.js → exports/a.js} +6 -6
  28. package/es/exports/b.js +29 -0
  29. package/lib/FormField/{index.js → v1/index.js} +3 -3
  30. package/lib/FormField/v2/index.js +85 -0
  31. package/lib/FormField/v2/props.js +31 -0
  32. package/lib/FormFieldGroup/{index.js → v1/index.js} +11 -10
  33. package/lib/FormFieldGroup/v2/index.js +136 -0
  34. package/lib/FormFieldGroup/v2/props.js +31 -0
  35. package/lib/FormFieldGroup/v2/styles.js +55 -0
  36. package/lib/FormFieldLabel/{index.js → v1/index.js} +1 -1
  37. package/lib/FormFieldLabel/v2/index.js +89 -0
  38. package/lib/FormFieldLabel/v2/props.js +31 -0
  39. package/lib/FormFieldLabel/v2/styles.js +68 -0
  40. package/lib/FormFieldLabel/v2/theme.js +58 -0
  41. package/lib/FormFieldLayout/{index.js → v1/index.js} +3 -3
  42. package/lib/FormFieldLayout/{styles.js → v1/styles.js} +1 -1
  43. package/lib/FormFieldLayout/v2/index.js +220 -0
  44. package/lib/FormFieldLayout/v2/props.js +31 -0
  45. package/lib/FormFieldLayout/v2/styles.js +177 -0
  46. package/lib/FormFieldMessage/{index.js → v1/index.js} +2 -2
  47. package/lib/FormFieldMessage/v2/index.js +101 -0
  48. package/lib/FormFieldMessage/v2/props.js +31 -0
  49. package/lib/FormFieldMessage/v2/styles.js +75 -0
  50. package/lib/FormFieldMessages/{index.js → v1/index.js} +3 -3
  51. package/lib/FormFieldMessages/v2/index.js +93 -0
  52. package/lib/FormFieldMessages/v2/props.js +31 -0
  53. package/lib/FormFieldMessages/v2/styles.js +56 -0
  54. package/lib/{index.js → exports/a.js} +12 -12
  55. package/lib/exports/b.js +47 -0
  56. package/package.json +43 -21
  57. package/src/FormField/{index.tsx → v1/index.tsx} +1 -1
  58. package/src/FormField/{props.ts → v1/props.ts} +1 -1
  59. package/src/FormField/v2/README.md +43 -0
  60. package/src/FormField/v2/index.tsx +87 -0
  61. package/src/FormField/v2/props.ts +104 -0
  62. package/src/FormFieldGroup/{index.tsx → v1/index.tsx} +6 -4
  63. package/src/FormFieldGroup/{props.ts → v1/props.ts} +2 -2
  64. package/src/FormFieldGroup/v2/README.md +114 -0
  65. package/src/FormFieldGroup/v2/index.tsx +182 -0
  66. package/src/FormFieldGroup/v2/props.ts +103 -0
  67. package/src/FormFieldGroup/v2/styles.ts +58 -0
  68. package/src/FormFieldLabel/{index.tsx → v1/index.tsx} +1 -1
  69. package/src/FormFieldLabel/v2/index.tsx +95 -0
  70. package/src/FormFieldLabel/v2/props.ts +49 -0
  71. package/src/FormFieldLabel/v2/styles.ts +74 -0
  72. package/src/FormFieldLabel/v2/theme.ts +56 -0
  73. package/src/FormFieldLayout/{index.tsx → v1/index.tsx} +2 -2
  74. package/src/FormFieldLayout/{props.ts → v1/props.ts} +1 -1
  75. package/src/FormFieldLayout/{styles.ts → v1/styles.ts} +2 -2
  76. package/src/FormFieldLayout/v2/index.tsx +237 -0
  77. package/src/FormFieldLayout/v2/props.ts +157 -0
  78. package/src/FormFieldLayout/v2/styles.ts +209 -0
  79. package/src/FormFieldMessage/{index.tsx → v1/index.tsx} +1 -1
  80. package/src/FormFieldMessage/{props.ts → v1/props.ts} +4 -1
  81. package/src/FormFieldMessage/{styles.ts → v1/styles.ts} +2 -3
  82. package/src/FormFieldMessage/v2/index.tsx +104 -0
  83. package/src/FormFieldMessage/v2/props.ts +48 -0
  84. package/src/FormFieldMessage/v2/styles.ts +76 -0
  85. package/src/FormFieldMessages/{index.tsx → v1/index.tsx} +2 -2
  86. package/src/FormFieldMessages/{props.ts → v1/props.ts} +1 -1
  87. package/src/FormFieldMessages/v2/index.tsx +99 -0
  88. package/src/FormFieldMessages/v2/props.ts +59 -0
  89. package/src/FormFieldMessages/v2/styles.ts +55 -0
  90. package/src/{index.ts → exports/a.ts} +17 -13
  91. package/src/exports/b.ts +43 -0
  92. package/tsconfig.build.json +1 -0
  93. package/tsconfig.build.tsbuildinfo +1 -1
  94. package/types/FormField/v1/index.d.ts.map +1 -0
  95. package/types/FormField/{props.d.ts → v1/props.d.ts} +1 -1
  96. package/types/FormField/v1/props.d.ts.map +1 -0
  97. package/types/FormField/v2/index.d.ts +23 -0
  98. package/types/FormField/v2/index.d.ts.map +1 -0
  99. package/types/FormField/v2/props.d.ts +57 -0
  100. package/types/FormField/v2/props.d.ts.map +1 -0
  101. package/types/FormFieldGroup/{index.d.ts → v1/index.d.ts} +1 -1
  102. package/types/FormFieldGroup/v1/index.d.ts.map +1 -0
  103. package/types/FormFieldGroup/{props.d.ts → v1/props.d.ts} +2 -2
  104. package/types/FormFieldGroup/v1/props.d.ts.map +1 -0
  105. package/types/FormFieldGroup/v1/styles.d.ts.map +1 -0
  106. package/types/FormFieldGroup/v1/theme.d.ts.map +1 -0
  107. package/types/FormFieldGroup/v2/index.d.ts +45 -0
  108. package/types/FormFieldGroup/v2/index.d.ts.map +1 -0
  109. package/types/FormFieldGroup/v2/props.d.ts +48 -0
  110. package/types/FormFieldGroup/v2/props.d.ts.map +1 -0
  111. package/types/FormFieldGroup/v2/styles.d.ts +14 -0
  112. package/types/FormFieldGroup/v2/styles.d.ts.map +1 -0
  113. package/types/FormFieldLabel/v1/index.d.ts.map +1 -0
  114. package/types/FormFieldLabel/v1/props.d.ts.map +1 -0
  115. package/types/FormFieldLabel/v1/styles.d.ts.map +1 -0
  116. package/types/FormFieldLabel/v1/theme.d.ts.map +1 -0
  117. package/types/FormFieldLabel/v2/index.d.ts +38 -0
  118. package/types/FormFieldLabel/v2/index.d.ts.map +1 -0
  119. package/types/FormFieldLabel/v2/props.d.ts +14 -0
  120. package/types/FormFieldLabel/v2/props.d.ts.map +1 -0
  121. package/types/FormFieldLabel/v2/styles.d.ts +15 -0
  122. package/types/FormFieldLabel/v2/styles.d.ts.map +1 -0
  123. package/types/FormFieldLabel/v2/theme.d.ts +10 -0
  124. package/types/FormFieldLabel/v2/theme.d.ts.map +1 -0
  125. package/types/FormFieldLayout/v1/index.d.ts.map +1 -0
  126. package/types/FormFieldLayout/{props.d.ts → v1/props.d.ts} +1 -1
  127. package/types/FormFieldLayout/v1/props.d.ts.map +1 -0
  128. package/types/FormFieldLayout/v1/styles.d.ts.map +1 -0
  129. package/types/FormFieldLayout/v1/theme.d.ts.map +1 -0
  130. package/types/FormFieldLayout/v2/index.d.ts +14 -0
  131. package/types/FormFieldLayout/v2/index.d.ts.map +1 -0
  132. package/types/FormFieldLayout/v2/props.d.ts +90 -0
  133. package/types/FormFieldLayout/v2/props.d.ts.map +1 -0
  134. package/types/FormFieldLayout/v2/styles.d.ts +25 -0
  135. package/types/FormFieldLayout/v2/styles.d.ts.map +1 -0
  136. package/types/FormFieldMessage/{index.d.ts → v1/index.d.ts} +2 -2
  137. package/types/FormFieldMessage/v1/index.d.ts.map +1 -0
  138. package/types/FormFieldMessage/{props.d.ts → v1/props.d.ts} +1 -1
  139. package/types/FormFieldMessage/v1/props.d.ts.map +1 -0
  140. package/types/FormFieldMessage/v1/styles.d.ts.map +1 -0
  141. package/types/FormFieldMessage/v1/theme.d.ts.map +1 -0
  142. package/types/FormFieldMessage/v2/index.d.ts +24 -0
  143. package/types/FormFieldMessage/v2/index.d.ts.map +1 -0
  144. package/types/FormFieldMessage/v2/props.d.ts +16 -0
  145. package/types/FormFieldMessage/v2/props.d.ts.map +1 -0
  146. package/types/FormFieldMessage/v2/styles.d.ts +18 -0
  147. package/types/FormFieldMessage/v2/styles.d.ts.map +1 -0
  148. package/types/FormFieldMessages/{index.d.ts → v1/index.d.ts} +1 -1
  149. package/types/FormFieldMessages/v1/index.d.ts.map +1 -0
  150. package/types/FormFieldMessages/{props.d.ts → v1/props.d.ts} +1 -1
  151. package/types/FormFieldMessages/v1/props.d.ts.map +1 -0
  152. package/types/FormFieldMessages/v1/styles.d.ts.map +1 -0
  153. package/types/FormFieldMessages/v1/theme.d.ts.map +1 -0
  154. package/types/FormFieldMessages/v2/index.d.ts +36 -0
  155. package/types/FormFieldMessages/v2/index.d.ts.map +1 -0
  156. package/types/FormFieldMessages/v2/props.d.ts +25 -0
  157. package/types/FormFieldMessages/v2/props.d.ts.map +1 -0
  158. package/types/FormFieldMessages/v2/styles.d.ts +14 -0
  159. package/types/FormFieldMessages/v2/styles.d.ts.map +1 -0
  160. package/types/exports/a.d.ts +14 -0
  161. package/types/exports/a.d.ts.map +1 -0
  162. package/types/exports/b.d.ts +14 -0
  163. package/types/exports/b.d.ts.map +1 -0
  164. package/types/utils/v1/FormPropTypes.d.ts.map +1 -0
  165. package/types/FormField/index.d.ts.map +0 -1
  166. package/types/FormField/props.d.ts.map +0 -1
  167. package/types/FormFieldGroup/index.d.ts.map +0 -1
  168. package/types/FormFieldGroup/props.d.ts.map +0 -1
  169. package/types/FormFieldGroup/styles.d.ts.map +0 -1
  170. package/types/FormFieldGroup/theme.d.ts.map +0 -1
  171. package/types/FormFieldLabel/index.d.ts.map +0 -1
  172. package/types/FormFieldLabel/props.d.ts.map +0 -1
  173. package/types/FormFieldLabel/styles.d.ts.map +0 -1
  174. package/types/FormFieldLabel/theme.d.ts.map +0 -1
  175. package/types/FormFieldLayout/index.d.ts.map +0 -1
  176. package/types/FormFieldLayout/props.d.ts.map +0 -1
  177. package/types/FormFieldLayout/styles.d.ts.map +0 -1
  178. package/types/FormFieldLayout/theme.d.ts.map +0 -1
  179. package/types/FormFieldMessage/index.d.ts.map +0 -1
  180. package/types/FormFieldMessage/props.d.ts.map +0 -1
  181. package/types/FormFieldMessage/styles.d.ts.map +0 -1
  182. package/types/FormFieldMessage/theme.d.ts.map +0 -1
  183. package/types/FormFieldMessages/index.d.ts.map +0 -1
  184. package/types/FormFieldMessages/props.d.ts.map +0 -1
  185. package/types/FormFieldMessages/styles.d.ts.map +0 -1
  186. package/types/FormFieldMessages/theme.d.ts.map +0 -1
  187. package/types/FormPropTypes.d.ts.map +0 -1
  188. package/types/index.d.ts +0 -14
  189. package/types/index.d.ts.map +0 -1
  190. /package/es/FormField/{props.js → v1/props.js} +0 -0
  191. /package/es/FormFieldGroup/{props.js → v1/props.js} +0 -0
  192. /package/es/FormFieldGroup/{styles.js → v1/styles.js} +0 -0
  193. /package/es/FormFieldGroup/{theme.js → v1/theme.js} +0 -0
  194. /package/es/FormFieldLabel/{props.js → v1/props.js} +0 -0
  195. /package/es/FormFieldLabel/{styles.js → v1/styles.js} +0 -0
  196. /package/es/FormFieldLabel/{theme.js → v1/theme.js} +0 -0
  197. /package/es/FormFieldLayout/{props.js → v1/props.js} +0 -0
  198. /package/es/FormFieldLayout/{theme.js → v1/theme.js} +0 -0
  199. /package/es/FormFieldMessage/{props.js → v1/props.js} +0 -0
  200. /package/es/FormFieldMessage/{styles.js → v1/styles.js} +0 -0
  201. /package/es/FormFieldMessage/{theme.js → v1/theme.js} +0 -0
  202. /package/es/FormFieldMessages/{props.js → v1/props.js} +0 -0
  203. /package/es/FormFieldMessages/{styles.js → v1/styles.js} +0 -0
  204. /package/es/FormFieldMessages/{theme.js → v1/theme.js} +0 -0
  205. /package/es/{FormPropTypes.js → utils/v1/FormPropTypes.js} +0 -0
  206. /package/lib/FormField/{props.js → v1/props.js} +0 -0
  207. /package/lib/FormFieldGroup/{props.js → v1/props.js} +0 -0
  208. /package/lib/FormFieldGroup/{styles.js → v1/styles.js} +0 -0
  209. /package/lib/FormFieldGroup/{theme.js → v1/theme.js} +0 -0
  210. /package/lib/FormFieldLabel/{props.js → v1/props.js} +0 -0
  211. /package/lib/FormFieldLabel/{styles.js → v1/styles.js} +0 -0
  212. /package/lib/FormFieldLabel/{theme.js → v1/theme.js} +0 -0
  213. /package/lib/FormFieldLayout/{props.js → v1/props.js} +0 -0
  214. /package/lib/FormFieldLayout/{theme.js → v1/theme.js} +0 -0
  215. /package/lib/FormFieldMessage/{props.js → v1/props.js} +0 -0
  216. /package/lib/FormFieldMessage/{styles.js → v1/styles.js} +0 -0
  217. /package/lib/FormFieldMessage/{theme.js → v1/theme.js} +0 -0
  218. /package/lib/FormFieldMessages/{props.js → v1/props.js} +0 -0
  219. /package/lib/FormFieldMessages/{styles.js → v1/styles.js} +0 -0
  220. /package/lib/FormFieldMessages/{theme.js → v1/theme.js} +0 -0
  221. /package/lib/{FormPropTypes.js → utils/v1/FormPropTypes.js} +0 -0
  222. /package/src/FormField/{README.md → v1/README.md} +0 -0
  223. /package/src/FormFieldGroup/{README.md → v1/README.md} +0 -0
  224. /package/src/FormFieldGroup/{styles.ts → v1/styles.ts} +0 -0
  225. /package/src/FormFieldGroup/{theme.ts → v1/theme.ts} +0 -0
  226. /package/src/FormFieldLabel/{props.ts → v1/props.ts} +0 -0
  227. /package/src/FormFieldLabel/{styles.ts → v1/styles.ts} +0 -0
  228. /package/src/FormFieldLabel/{theme.ts → v1/theme.ts} +0 -0
  229. /package/src/FormFieldLayout/{theme.ts → v1/theme.ts} +0 -0
  230. /package/src/FormFieldMessage/{theme.ts → v1/theme.ts} +0 -0
  231. /package/src/FormFieldMessages/{styles.ts → v1/styles.ts} +0 -0
  232. /package/src/FormFieldMessages/{theme.ts → v1/theme.ts} +0 -0
  233. /package/src/{FormPropTypes.ts → utils/v1/FormPropTypes.ts} +0 -0
  234. /package/types/FormField/{index.d.ts → v1/index.d.ts} +0 -0
  235. /package/types/FormFieldGroup/{styles.d.ts → v1/styles.d.ts} +0 -0
  236. /package/types/FormFieldGroup/{theme.d.ts → v1/theme.d.ts} +0 -0
  237. /package/types/FormFieldLabel/{index.d.ts → v1/index.d.ts} +0 -0
  238. /package/types/FormFieldLabel/{props.d.ts → v1/props.d.ts} +0 -0
  239. /package/types/FormFieldLabel/{styles.d.ts → v1/styles.d.ts} +0 -0
  240. /package/types/FormFieldLabel/{theme.d.ts → v1/theme.d.ts} +0 -0
  241. /package/types/FormFieldLayout/{index.d.ts → v1/index.d.ts} +0 -0
  242. /package/types/FormFieldLayout/{styles.d.ts → v1/styles.d.ts} +0 -0
  243. /package/types/FormFieldLayout/{theme.d.ts → v1/theme.d.ts} +0 -0
  244. /package/types/FormFieldMessage/{styles.d.ts → v1/styles.d.ts} +0 -0
  245. /package/types/FormFieldMessage/{theme.d.ts → v1/theme.d.ts} +0 -0
  246. /package/types/FormFieldMessages/{styles.d.ts → v1/styles.d.ts} +0 -0
  247. /package/types/FormFieldMessages/{theme.d.ts → v1/theme.d.ts} +0 -0
  248. /package/types/{FormPropTypes.d.ts → utils/v1/FormPropTypes.d.ts} +0 -0
@@ -0,0 +1,104 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { forwardRef } from 'react'
26
+
27
+ import { ScreenReaderContent } from '@instructure/ui-a11y-content'
28
+
29
+ import {
30
+ AlertCircleInstUIIcon,
31
+ CheckCircle2InstUIIcon
32
+ } from '@instructure/ui-icons'
33
+
34
+ import { useStyle } from '@instructure/emotion'
35
+ import generateStyle from './styles'
36
+
37
+ import type { FormFieldMessageProps } from './props'
38
+
39
+ /**
40
+ ---
41
+ parent: FormField
42
+ ---
43
+
44
+ This is a helper component that is used by most of the custom form
45
+ components. In most cases it shouldn't be used directly.
46
+
47
+ ```js
48
+ ---
49
+ type: example
50
+ ---
51
+ <FormFieldMessage variant="error">Invalid value</FormFieldMessage>
52
+ ```
53
+ **/
54
+ const FormFieldMessage = forwardRef<HTMLSpanElement, FormFieldMessageProps>(
55
+ ({ variant = 'hint', children, themeOverride }, ref) => {
56
+ const styles = useStyle({
57
+ generateStyle,
58
+ themeOverride,
59
+ params: {
60
+ variant
61
+ },
62
+ componentId: 'FormFieldMessage',
63
+ displayName: 'FormFieldMessage'
64
+ })
65
+
66
+ const handleRef = (el: Element | null) => {
67
+ if (typeof ref === 'function') {
68
+ ref(el as HTMLSpanElement)
69
+ } else if (ref) {
70
+ const refObject = ref
71
+ refObject.current = el as HTMLSpanElement
72
+ }
73
+ }
74
+
75
+ const isErrorVariant = variant === 'error' || variant === 'newError'
76
+ const shouldShowIcon = (isErrorVariant || variant === 'success') && children
77
+
78
+ return variant !== 'screenreader-only' ? (
79
+ <span css={{ display: 'flex' }}>
80
+ {shouldShowIcon && (
81
+ <span css={styles?.icon}>
82
+ {isErrorVariant ? (
83
+ <AlertCircleInstUIIcon size="sm" color="errorColor" />
84
+ ) : (
85
+ <CheckCircle2InstUIIcon size="sm" color="successColor" />
86
+ )}
87
+ </span>
88
+ )}
89
+ <span css={styles?.formFieldMessage} ref={handleRef}>
90
+ {children}
91
+ </span>
92
+ </span>
93
+ ) : (
94
+ <ScreenReaderContent elementRef={handleRef}>
95
+ {children}
96
+ </ScreenReaderContent>
97
+ )
98
+ }
99
+ )
100
+
101
+ FormFieldMessage.displayName = 'FormFieldMessage'
102
+
103
+ export default FormFieldMessage
104
+ export { FormFieldMessage }
@@ -0,0 +1,48 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { ComponentStyle, ThemeOverrideValue } from '@instructure/emotion'
26
+ import type {
27
+ FormMessageType,
28
+ FormMessageChild
29
+ } from '../../utils/v1/FormPropTypes'
30
+
31
+ type FormFieldMessageOwnProps = {
32
+ variant?: FormMessageType
33
+ children?: FormMessageChild
34
+ }
35
+
36
+ type PropKeys = keyof FormFieldMessageOwnProps
37
+
38
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
39
+
40
+ type FormFieldMessageProps = FormFieldMessageOwnProps & {
41
+ themeOverride?: ThemeOverrideValue
42
+ }
43
+
44
+ type FormFieldMessageStyle = ComponentStyle<'formFieldMessage' | 'icon'>
45
+ const allowedProps: AllowedPropKeys = ['variant', 'children']
46
+
47
+ export type { FormFieldMessageProps, FormFieldMessageStyle }
48
+ export { allowedProps }
@@ -0,0 +1,76 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
26
+ import type { FormFieldMessageProps, FormFieldMessageStyle } from './props'
27
+ import type { FormMessageType } from '../../utils/v1/FormPropTypes'
28
+
29
+ type StyleParams = {
30
+ variant: FormFieldMessageProps['variant']
31
+ }
32
+
33
+ /**
34
+ * ---
35
+ * private: true
36
+ * ---
37
+ * Generates the style object from the theme and provided additional information
38
+ * @param {Object} componentTheme The theme variable object.
39
+ * @param {Object} props the props of the component, the style is applied to
40
+ * @param {Object} state the state of the component, the style is applied to
41
+ * @return {Object} The final style object, which will be used in the component
42
+ */
43
+ const generateStyle = (
44
+ componentTheme: NewComponentTypes['FormFieldMessage'],
45
+ params: StyleParams,
46
+ sharedTokens: SharedTokens
47
+ ): FormFieldMessageStyle => {
48
+ const { variant } = params
49
+
50
+ const variants: Record<FormMessageType, { color?: string }> = {
51
+ hint: { color: componentTheme.hintTextColor },
52
+ error: { color: componentTheme.errorTextColor },
53
+ newError: { color: componentTheme.errorTextColor },
54
+ success: { color: componentTheme.successTextColor },
55
+ 'screenreader-only': {}
56
+ }
57
+
58
+ return {
59
+ icon: {
60
+ fontSize: componentTheme.fontSize,
61
+ marginRight: sharedTokens.spacing.general.spaceXs,
62
+ lineHeight: 1.25
63
+ },
64
+ formFieldMessage: {
65
+ label: 'formFieldMessage',
66
+ fontFamily: componentTheme.fontFamily,
67
+ fontWeight: componentTheme.fontWeight,
68
+ fontSize: componentTheme.fontSize,
69
+ lineHeight: componentTheme.lineHeight,
70
+ display: 'block',
71
+ ...variants[variant!]
72
+ }
73
+ }
74
+ }
75
+
76
+ export default generateStyle
@@ -26,9 +26,9 @@ import { Component } from 'react'
26
26
 
27
27
  import { omitProps } from '@instructure/ui-react-utils'
28
28
 
29
- import { withStyle } from '@instructure/emotion'
29
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
30
30
 
31
- import { FormFieldMessage } from '../FormFieldMessage'
31
+ import { FormFieldMessage } from '../../FormFieldMessage/v1'
32
32
 
33
33
  import generateStyle from './styles'
34
34
  import generateComponentTheme from './theme'
@@ -27,7 +27,7 @@ import type {
27
27
  OtherHTMLAttributes
28
28
  } from '@instructure/shared-types'
29
29
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
30
- import type { FormMessage } from '../FormPropTypes'
30
+ import type { FormMessage } from '../../utils/v1/FormPropTypes'
31
31
 
32
32
  type FormFieldMessagesOwnProps = {
33
33
  /**
@@ -0,0 +1,99 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { Component } from 'react'
26
+
27
+ import { omitProps } from '@instructure/ui-react-utils'
28
+
29
+ import { withStyle } from '@instructure/emotion'
30
+
31
+ import { FormFieldMessage } from '../../FormFieldMessage/v2'
32
+
33
+ import generateStyle from './styles'
34
+
35
+ import { allowedProps } from './props'
36
+ import type { FormFieldMessagesProps } from './props'
37
+
38
+ /**
39
+ ---
40
+ parent: FormField
41
+ ---
42
+
43
+ A FormFieldMessages component
44
+
45
+ ```js
46
+ ---
47
+ type: example
48
+ ---
49
+ <FormFieldMessages messages={[
50
+ { text: 'Invalid name', type: 'error' },
51
+ { text: 'Good job!', type: 'success' },
52
+ { text: 'Full name, first and last', type: 'hint' },
53
+ ]} />
54
+ ```
55
+ **/
56
+ @withStyle(generateStyle)
57
+ class FormFieldMessages extends Component<FormFieldMessagesProps> {
58
+ static readonly componentId = 'FormFieldMessages'
59
+
60
+ static allowedProps = allowedProps
61
+ static defaultProps = {}
62
+
63
+ ref: Element | null = null
64
+
65
+ handleRef = (el: Element | null) => {
66
+ this.ref = el
67
+ }
68
+
69
+ componentDidMount() {
70
+ this.props.makeStyles?.()
71
+ }
72
+
73
+ componentDidUpdate() {
74
+ this.props.makeStyles?.()
75
+ }
76
+
77
+ render() {
78
+ const { messages, styles } = this.props
79
+
80
+ return messages && messages.length > 0 ? (
81
+ <div
82
+ css={styles?.formFieldMessages}
83
+ {...omitProps(this.props, FormFieldMessages.allowedProps)}
84
+ ref={this.handleRef}
85
+ >
86
+ {messages.map((msg, i) => {
87
+ return (
88
+ <span key={`error${i}`} css={styles?.message}>
89
+ <FormFieldMessage variant={msg.type}>{msg.text}</FormFieldMessage>
90
+ </span>
91
+ )
92
+ })}
93
+ </div>
94
+ ) : null
95
+ }
96
+ }
97
+
98
+ export default FormFieldMessages
99
+ export { FormFieldMessages }
@@ -0,0 +1,59 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type {
26
+ FormFieldMessagesTheme,
27
+ OtherHTMLAttributes
28
+ } from '@instructure/shared-types'
29
+ import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
30
+ import type { FormMessage } from '../../utils/v1/FormPropTypes'
31
+
32
+ type FormFieldMessagesOwnProps = {
33
+ /**
34
+ * Array of objects with shape: `{
35
+ * text: React.ReactNode,
36
+ * type: One of: ['newError', 'error', 'hint', 'success', 'screenreader-only']
37
+ * }`
38
+ */
39
+ messages?: FormMessage[]
40
+ /**
41
+ * Specifies the size and location if inside a CSS grid, see
42
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area
43
+ */
44
+ gridArea?: string
45
+ }
46
+
47
+ type PropKeys = keyof FormFieldMessagesOwnProps
48
+
49
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
50
+
51
+ type FormFieldMessagesProps = FormFieldMessagesOwnProps &
52
+ WithStyleProps<FormFieldMessagesTheme, FormFieldMessagesStyle> &
53
+ OtherHTMLAttributes<FormFieldMessagesOwnProps>
54
+
55
+ type FormFieldMessagesStyle = ComponentStyle<'formFieldMessages' | 'message'>
56
+ const allowedProps: AllowedPropKeys = ['messages', 'gridArea']
57
+
58
+ export type { FormFieldMessagesProps, FormFieldMessagesStyle }
59
+ export { allowedProps }
@@ -0,0 +1,55 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { FormFieldMessagesTheme } from '@instructure/shared-types'
26
+ import type { FormFieldMessagesProps, FormFieldMessagesStyle } from './props'
27
+
28
+ /**
29
+ * ---
30
+ * private: true
31
+ * ---
32
+ * Generates the style object from the theme and provided additional information
33
+ * @param {Object} componentTheme The theme variable object.
34
+ * @param {Object} props the props of the component, the style is applied to
35
+ * @return {Object} The final style object, which will be used in the component
36
+ */
37
+ const generateStyle = (
38
+ _componentTheme: FormFieldMessagesTheme,
39
+ props: FormFieldMessagesProps
40
+ ): FormFieldMessagesStyle => {
41
+ return {
42
+ formFieldMessages: {
43
+ label: 'formFieldMessages',
44
+ padding: 0,
45
+ display: 'block',
46
+ ...(props.gridArea && { gridArea: props.gridArea })
47
+ },
48
+ message: {
49
+ label: 'formFieldMessages__message',
50
+ display: 'block'
51
+ }
52
+ }
53
+ }
54
+
55
+ export default generateStyle
@@ -22,18 +22,22 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- export { FormField } from './FormField'
26
- export { FormFieldLabel } from './FormFieldLabel'
27
- export { FormFieldMessage } from './FormFieldMessage'
28
- export { FormFieldMessages } from './FormFieldMessages'
29
- export { FormFieldLayout } from './FormFieldLayout'
30
- export { FormFieldGroup } from './FormFieldGroup'
25
+ export { FormField } from '../FormField/v1'
26
+ export { FormFieldLabel } from '../FormFieldLabel/v1'
27
+ export { FormFieldMessage } from '../FormFieldMessage/v1'
28
+ export { FormFieldMessages } from '../FormFieldMessages/v1'
29
+ export { FormFieldLayout } from '../FormFieldLayout/v1'
30
+ export { FormFieldGroup } from '../FormFieldGroup/v1'
31
31
 
32
- export type { FormMessageType, FormMessage } from './FormPropTypes'
32
+ export type {
33
+ FormMessageType,
34
+ FormMessage,
35
+ FormMessageChild
36
+ } from '../utils/v1/FormPropTypes'
33
37
 
34
- export type { FormFieldOwnProps, FormFieldProps } from './FormField/props'
35
- export type { FormFieldLabelProps } from './FormFieldLabel/props'
36
- export type { FormFieldMessageProps } from './FormFieldMessage/props'
37
- export type { FormFieldMessagesProps } from './FormFieldMessages/props'
38
- export type { FormFieldLayoutProps } from './FormFieldLayout/props'
39
- export type { FormFieldGroupProps } from './FormFieldGroup/props'
38
+ export type { FormFieldOwnProps, FormFieldProps } from '../FormField/v1/props'
39
+ export type { FormFieldLabelProps } from '../FormFieldLabel/v1/props'
40
+ export type { FormFieldMessageProps } from '../FormFieldMessage/v1/props'
41
+ export type { FormFieldMessagesProps } from '../FormFieldMessages/v1/props'
42
+ export type { FormFieldLayoutProps } from '../FormFieldLayout/v1/props'
43
+ export type { FormFieldGroupProps } from '../FormFieldGroup/v1/props'
@@ -0,0 +1,43 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ export { FormField } from '../FormField/v2'
26
+ export { FormFieldLabel } from '../FormFieldLabel/v2'
27
+ export { FormFieldMessage } from '../FormFieldMessage/v2'
28
+ export { FormFieldMessages } from '../FormFieldMessages/v2'
29
+ export { FormFieldLayout } from '../FormFieldLayout/v2'
30
+ export { FormFieldGroup } from '../FormFieldGroup/v2'
31
+
32
+ export type {
33
+ FormMessageType,
34
+ FormMessage,
35
+ FormMessageChild
36
+ } from '../utils/v1/FormPropTypes'
37
+
38
+ export type { FormFieldOwnProps, FormFieldProps } from '../FormField/v2/props'
39
+ export type { FormFieldLabelProps } from '../FormFieldLabel/v2/props'
40
+ export type { FormFieldMessageProps } from '../FormFieldMessage/v2/props'
41
+ export type { FormFieldMessagesProps } from '../FormFieldMessages/v2/props'
42
+ export type { FormFieldLayoutProps } from '../FormFieldLayout/v2/props'
43
+ export type { FormFieldGroupProps } from '../FormFieldGroup/v2/props'
@@ -16,6 +16,7 @@
16
16
  { "path": "../ui-a11y-utils/tsconfig.build.json" },
17
17
  { "path": "../ui-grid/tsconfig.build.json" },
18
18
  { "path": "../ui-icons/tsconfig.build.json" },
19
+ { "path": "../ui-icons/tsconfig.build.json" },
19
20
  { "path": "../ui-react-utils/tsconfig.build.json" },
20
21
  { "path": "../ui-utils/tsconfig.build.json" },
21
22
  { "path": "../uid/tsconfig.build.json" },