@okta/odyssey-react-mui 0.22.0 → 0.23.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.
Files changed (280) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/Autocomplete.js +5 -1
  3. package/dist/Autocomplete.js.map +1 -1
  4. package/dist/Banner.js +3 -3
  5. package/dist/Banner.js.map +1 -1
  6. package/dist/Button.js +8 -8
  7. package/dist/Button.js.map +1 -1
  8. package/dist/CheckboxGroup.js +23 -35
  9. package/dist/CheckboxGroup.js.map +1 -1
  10. package/dist/Dialog.js +68 -0
  11. package/dist/Dialog.js.map +1 -0
  12. package/dist/Field.js +18 -5
  13. package/dist/Field.js.map +1 -1
  14. package/dist/FieldLabel.js +3 -3
  15. package/dist/FieldLabel.js.map +1 -1
  16. package/dist/Icon.js +7 -6
  17. package/dist/Icon.js.map +1 -1
  18. package/dist/Infobox.js +1 -1
  19. package/dist/Infobox.js.map +1 -1
  20. package/dist/Link.js +5 -2
  21. package/dist/Link.js.map +1 -1
  22. package/dist/MenuButton.js +3 -2
  23. package/dist/MenuButton.js.map +1 -1
  24. package/dist/MuiPropsChild.js +30 -0
  25. package/dist/MuiPropsChild.js.map +1 -0
  26. package/dist/MuiPropsContext.js +14 -0
  27. package/dist/MuiPropsContext.js.map +1 -0
  28. package/dist/PasswordField.js +8 -3
  29. package/dist/PasswordField.js.map +1 -1
  30. package/dist/RadioGroup.js +25 -26
  31. package/dist/RadioGroup.js.map +1 -1
  32. package/dist/SearchField.js +6 -4
  33. package/dist/SearchField.js.map +1 -1
  34. package/dist/Status.js.map +1 -1
  35. package/dist/TextField.js +17 -8
  36. package/dist/TextField.js.map +1 -1
  37. package/dist/Toast.js +72 -0
  38. package/dist/Toast.js.map +1 -0
  39. package/dist/ToastStack.js +33 -0
  40. package/dist/ToastStack.js.map +1 -0
  41. package/dist/Tooltip.js +20 -0
  42. package/dist/Tooltip.js.map +1 -0
  43. package/dist/iconDictionary/Add.js +4 -4
  44. package/dist/iconDictionary/Add.js.map +1 -1
  45. package/dist/iconDictionary/AddCircle.js +4 -4
  46. package/dist/iconDictionary/AddCircle.js.map +1 -1
  47. package/dist/iconDictionary/AlertCircle.js +4 -4
  48. package/dist/iconDictionary/AlertCircle.js.map +1 -1
  49. package/dist/iconDictionary/AlertCircleFilled.js +4 -4
  50. package/dist/iconDictionary/AlertCircleFilled.js.map +1 -1
  51. package/dist/iconDictionary/AlertTriangleFilled.js +4 -4
  52. package/dist/iconDictionary/AlertTriangleFilled.js.map +1 -1
  53. package/dist/iconDictionary/Anchor.js +5 -5
  54. package/dist/iconDictionary/Anchor.js.map +1 -1
  55. package/dist/iconDictionary/ArrowDown.js +4 -4
  56. package/dist/iconDictionary/ArrowDown.js.map +1 -1
  57. package/dist/iconDictionary/ArrowLeft.js +4 -4
  58. package/dist/iconDictionary/ArrowLeft.js.map +1 -1
  59. package/dist/iconDictionary/ArrowRight.js +4 -4
  60. package/dist/iconDictionary/ArrowRight.js.map +1 -1
  61. package/dist/iconDictionary/ArrowUp.js +4 -4
  62. package/dist/iconDictionary/ArrowUp.js.map +1 -1
  63. package/dist/iconDictionary/ArrowUpDown.js +4 -4
  64. package/dist/iconDictionary/ArrowUpDown.js.map +1 -1
  65. package/dist/iconDictionary/Calendar.js +4 -4
  66. package/dist/iconDictionary/Calendar.js.map +1 -1
  67. package/dist/iconDictionary/Check.js +4 -4
  68. package/dist/iconDictionary/Check.js.map +1 -1
  69. package/dist/iconDictionary/CheckCircleFilled.js +4 -4
  70. package/dist/iconDictionary/CheckCircleFilled.js.map +1 -1
  71. package/dist/iconDictionary/ChevronDown.js +4 -4
  72. package/dist/iconDictionary/ChevronDown.js.map +1 -1
  73. package/dist/iconDictionary/ChevronUp.js +4 -4
  74. package/dist/iconDictionary/ChevronUp.js.map +1 -1
  75. package/dist/iconDictionary/Close.js +4 -4
  76. package/dist/iconDictionary/Close.js.map +1 -1
  77. package/dist/iconDictionary/CloseCircleFilled.js +4 -4
  78. package/dist/iconDictionary/CloseCircleFilled.js.map +1 -1
  79. package/dist/iconDictionary/Copy.js +4 -4
  80. package/dist/iconDictionary/Copy.js.map +1 -1
  81. package/dist/iconDictionary/Delete.js +4 -4
  82. package/dist/iconDictionary/Delete.js.map +1 -1
  83. package/dist/iconDictionary/Download.js +4 -4
  84. package/dist/iconDictionary/Download.js.map +1 -1
  85. package/dist/iconDictionary/DragHandle.js +4 -4
  86. package/dist/iconDictionary/DragHandle.js.map +1 -1
  87. package/dist/iconDictionary/Edit.js +4 -4
  88. package/dist/iconDictionary/Edit.js.map +1 -1
  89. package/dist/iconDictionary/ExternalLink.js +4 -4
  90. package/dist/iconDictionary/ExternalLink.js.map +1 -1
  91. package/dist/iconDictionary/Eye.js +4 -4
  92. package/dist/iconDictionary/Eye.js.map +1 -1
  93. package/dist/iconDictionary/EyeOff.js +4 -4
  94. package/dist/iconDictionary/EyeOff.js.map +1 -1
  95. package/dist/iconDictionary/Filter.js +4 -4
  96. package/dist/iconDictionary/Filter.js.map +1 -1
  97. package/dist/iconDictionary/Globe.js +4 -4
  98. package/dist/iconDictionary/Globe.js.map +1 -1
  99. package/dist/iconDictionary/Home.js +4 -4
  100. package/dist/iconDictionary/Home.js.map +1 -1
  101. package/dist/iconDictionary/InformationCircle.js +4 -4
  102. package/dist/iconDictionary/InformationCircle.js.map +1 -1
  103. package/dist/iconDictionary/InformationCircleFilled.js +4 -4
  104. package/dist/iconDictionary/InformationCircleFilled.js.map +1 -1
  105. package/dist/iconDictionary/Notification.js +4 -4
  106. package/dist/iconDictionary/Notification.js.map +1 -1
  107. package/dist/iconDictionary/OverflowVertical.js +4 -4
  108. package/dist/iconDictionary/OverflowVertical.js.map +1 -1
  109. package/dist/iconDictionary/QuestionCircle.js +4 -4
  110. package/dist/iconDictionary/QuestionCircle.js.map +1 -1
  111. package/dist/iconDictionary/QuestionCircleFilled.js +4 -4
  112. package/dist/iconDictionary/QuestionCircleFilled.js.map +1 -1
  113. package/dist/iconDictionary/Search.js +4 -4
  114. package/dist/iconDictionary/Search.js.map +1 -1
  115. package/dist/iconDictionary/Settings.js +3 -3
  116. package/dist/iconDictionary/Settings.js.map +1 -1
  117. package/dist/iconDictionary/Subtract.js +4 -4
  118. package/dist/iconDictionary/Subtract.js.map +1 -1
  119. package/dist/iconDictionary/User.js +4 -4
  120. package/dist/iconDictionary/User.js.map +1 -1
  121. package/dist/iconDictionary/UserGroup.js +4 -4
  122. package/dist/iconDictionary/UserGroup.js.map +1 -1
  123. package/dist/iconDictionary/index.js.map +1 -1
  124. package/dist/index.js +5 -4
  125. package/dist/index.js.map +1 -1
  126. package/dist/src/Autocomplete.d.ts +2 -1
  127. package/dist/src/Autocomplete.d.ts.map +1 -1
  128. package/dist/src/Banner.d.ts +19 -19
  129. package/dist/src/Banner.d.ts.map +1 -1
  130. package/dist/src/Button.d.ts +4 -3
  131. package/dist/src/Button.d.ts.map +1 -1
  132. package/dist/src/CheckboxGroup.d.ts +7 -4
  133. package/dist/src/CheckboxGroup.d.ts.map +1 -1
  134. package/dist/src/Dialog.d.ts +25 -0
  135. package/dist/src/Dialog.d.ts.map +1 -0
  136. package/dist/src/Field.d.ts +14 -3
  137. package/dist/src/Field.d.ts.map +1 -1
  138. package/dist/src/FieldLabel.d.ts +2 -2
  139. package/dist/src/Icon.d.ts +6 -7
  140. package/dist/src/Icon.d.ts.map +1 -1
  141. package/dist/src/Infobox.d.ts +7 -7
  142. package/dist/src/Infobox.d.ts.map +1 -1
  143. package/dist/src/Link.d.ts +9 -4
  144. package/dist/src/Link.d.ts.map +1 -1
  145. package/dist/src/MenuButton.d.ts +7 -3
  146. package/dist/src/MenuButton.d.ts.map +1 -1
  147. package/dist/src/MenuItem.d.ts +1 -1
  148. package/dist/src/MuiPropsChild.d.ts +18 -0
  149. package/dist/src/MuiPropsChild.d.ts.map +1 -0
  150. package/dist/src/MuiPropsContext.d.ts +15 -0
  151. package/dist/src/MuiPropsContext.d.ts.map +1 -0
  152. package/dist/src/PasswordField.d.ts +8 -8
  153. package/dist/src/PasswordField.d.ts.map +1 -1
  154. package/dist/src/RadioGroup.d.ts +8 -8
  155. package/dist/src/RadioGroup.d.ts.map +1 -1
  156. package/dist/src/SearchField.d.ts +4 -4
  157. package/dist/src/SearchField.d.ts.map +1 -1
  158. package/dist/src/Status.d.ts +2 -2
  159. package/dist/src/Status.d.ts.map +1 -1
  160. package/dist/src/TextField.d.ts +13 -12
  161. package/dist/src/TextField.d.ts.map +1 -1
  162. package/dist/src/Toast.d.ts +60 -0
  163. package/dist/src/Toast.d.ts.map +1 -0
  164. package/dist/src/ToastStack.d.ts +19 -0
  165. package/dist/src/ToastStack.d.ts.map +1 -0
  166. package/dist/src/Tooltip.d.ts +21 -0
  167. package/dist/src/Tooltip.d.ts.map +1 -0
  168. package/dist/src/iconDictionary/Add.d.ts +2 -2
  169. package/dist/src/iconDictionary/AddCircle.d.ts +2 -2
  170. package/dist/src/iconDictionary/AlertCircle.d.ts +2 -2
  171. package/dist/src/iconDictionary/AlertCircleFilled.d.ts +2 -2
  172. package/dist/src/iconDictionary/AlertTriangleFilled.d.ts +2 -2
  173. package/dist/src/iconDictionary/Anchor.d.ts +2 -2
  174. package/dist/src/iconDictionary/ArrowDown.d.ts +2 -2
  175. package/dist/src/iconDictionary/ArrowLeft.d.ts +2 -2
  176. package/dist/src/iconDictionary/ArrowRight.d.ts +2 -2
  177. package/dist/src/iconDictionary/ArrowUp.d.ts +2 -2
  178. package/dist/src/iconDictionary/ArrowUpDown.d.ts +2 -2
  179. package/dist/src/iconDictionary/Calendar.d.ts +2 -2
  180. package/dist/src/iconDictionary/Check.d.ts +2 -2
  181. package/dist/src/iconDictionary/CheckCircleFilled.d.ts +2 -2
  182. package/dist/src/iconDictionary/ChevronDown.d.ts +2 -2
  183. package/dist/src/iconDictionary/ChevronUp.d.ts +2 -2
  184. package/dist/src/iconDictionary/Close.d.ts +2 -2
  185. package/dist/src/iconDictionary/CloseCircleFilled.d.ts +2 -2
  186. package/dist/src/iconDictionary/Copy.d.ts +2 -2
  187. package/dist/src/iconDictionary/Delete.d.ts +2 -2
  188. package/dist/src/iconDictionary/Download.d.ts +2 -2
  189. package/dist/src/iconDictionary/DragHandle.d.ts +2 -2
  190. package/dist/src/iconDictionary/Edit.d.ts +2 -2
  191. package/dist/src/iconDictionary/ExternalLink.d.ts +2 -2
  192. package/dist/src/iconDictionary/Eye.d.ts +2 -2
  193. package/dist/src/iconDictionary/EyeOff.d.ts +2 -2
  194. package/dist/src/iconDictionary/Filter.d.ts +2 -2
  195. package/dist/src/iconDictionary/Globe.d.ts +2 -2
  196. package/dist/src/iconDictionary/Home.d.ts +2 -2
  197. package/dist/src/iconDictionary/InformationCircle.d.ts +2 -2
  198. package/dist/src/iconDictionary/InformationCircleFilled.d.ts +2 -2
  199. package/dist/src/iconDictionary/Notification.d.ts +2 -2
  200. package/dist/src/iconDictionary/OverflowVertical.d.ts +2 -2
  201. package/dist/src/iconDictionary/QuestionCircle.d.ts +2 -2
  202. package/dist/src/iconDictionary/QuestionCircleFilled.d.ts +2 -2
  203. package/dist/src/iconDictionary/Search.d.ts +2 -2
  204. package/dist/src/iconDictionary/Settings.d.ts +2 -2
  205. package/dist/src/iconDictionary/Subtract.d.ts +2 -2
  206. package/dist/src/iconDictionary/User.d.ts +2 -2
  207. package/dist/src/iconDictionary/UserGroup.d.ts +2 -2
  208. package/dist/src/iconDictionary/index.d.ts +40 -40
  209. package/dist/src/index.d.ts +8 -7
  210. package/dist/src/index.d.ts.map +1 -1
  211. package/dist/src/theme/components.d.ts.map +1 -1
  212. package/dist/theme/components.js +32 -12
  213. package/dist/theme/components.js.map +1 -1
  214. package/dist/tsconfig.production.tsbuildinfo +1 -1
  215. package/package.json +3 -3
  216. package/src/Autocomplete.tsx +10 -1
  217. package/src/Banner.tsx +21 -21
  218. package/src/Button.tsx +38 -18
  219. package/src/CheckboxGroup.tsx +27 -34
  220. package/src/Dialog.tsx +110 -0
  221. package/src/Field.tsx +42 -19
  222. package/src/FieldLabel.tsx +7 -7
  223. package/src/Icon.test.tsx +1 -1
  224. package/src/Icon.tsx +24 -7
  225. package/src/Infobox.tsx +7 -7
  226. package/src/Link.tsx +14 -6
  227. package/src/MenuButton.tsx +8 -3
  228. package/src/MuiPropsChild.tsx +41 -0
  229. package/src/MuiPropsContext.ts +17 -0
  230. package/src/PasswordField.tsx +17 -11
  231. package/src/RadioGroup.tsx +31 -46
  232. package/src/SearchField.tsx +10 -8
  233. package/src/Status.tsx +2 -2
  234. package/src/TextField.tsx +32 -21
  235. package/src/Toast.tsx +138 -0
  236. package/src/ToastStack.tsx +33 -0
  237. package/src/Tooltip.tsx +39 -0
  238. package/src/iconDictionary/Add.tsx +3 -3
  239. package/src/iconDictionary/AddCircle.tsx +3 -3
  240. package/src/iconDictionary/AlertCircle.tsx +3 -3
  241. package/src/iconDictionary/AlertCircleFilled.tsx +3 -3
  242. package/src/iconDictionary/AlertTriangleFilled.tsx +3 -3
  243. package/src/iconDictionary/Anchor.tsx +3 -3
  244. package/src/iconDictionary/ArrowDown.tsx +3 -3
  245. package/src/iconDictionary/ArrowLeft.tsx +3 -3
  246. package/src/iconDictionary/ArrowRight.tsx +3 -3
  247. package/src/iconDictionary/ArrowUp.tsx +3 -3
  248. package/src/iconDictionary/ArrowUpDown.tsx +3 -3
  249. package/src/iconDictionary/Calendar.tsx +3 -3
  250. package/src/iconDictionary/Check.tsx +3 -3
  251. package/src/iconDictionary/CheckCircleFilled.tsx +3 -3
  252. package/src/iconDictionary/ChevronDown.tsx +3 -3
  253. package/src/iconDictionary/ChevronUp.tsx +3 -3
  254. package/src/iconDictionary/Close.tsx +3 -3
  255. package/src/iconDictionary/CloseCircleFilled.tsx +3 -3
  256. package/src/iconDictionary/Copy.tsx +3 -3
  257. package/src/iconDictionary/Delete.tsx +3 -3
  258. package/src/iconDictionary/Download.tsx +3 -3
  259. package/src/iconDictionary/DragHandle.tsx +3 -3
  260. package/src/iconDictionary/Edit.tsx +3 -3
  261. package/src/iconDictionary/ExternalLink.tsx +3 -3
  262. package/src/iconDictionary/Eye.tsx +3 -3
  263. package/src/iconDictionary/EyeOff.tsx +3 -3
  264. package/src/iconDictionary/Filter.tsx +3 -3
  265. package/src/iconDictionary/Globe.tsx +3 -3
  266. package/src/iconDictionary/Home.tsx +3 -3
  267. package/src/iconDictionary/InformationCircle.tsx +3 -3
  268. package/src/iconDictionary/InformationCircleFilled.tsx +3 -3
  269. package/src/iconDictionary/Notification.tsx +3 -3
  270. package/src/iconDictionary/OverflowVertical.tsx +3 -3
  271. package/src/iconDictionary/QuestionCircle.tsx +3 -3
  272. package/src/iconDictionary/QuestionCircleFilled.tsx +3 -3
  273. package/src/iconDictionary/Search.tsx +3 -3
  274. package/src/iconDictionary/Settings.tsx +2 -2
  275. package/src/iconDictionary/Subtract.tsx +3 -3
  276. package/src/iconDictionary/User.tsx +3 -3
  277. package/src/iconDictionary/UserGroup.tsx +3 -3
  278. package/src/iconDictionary/index.ts +1 -1
  279. package/src/index.ts +4 -14
  280. package/src/theme/components.tsx +32 -9
package/src/Link.tsx CHANGED
@@ -12,17 +12,25 @@
12
12
 
13
13
  import { forwardRef, ReactElement } from "react";
14
14
 
15
- import { Link as MuiLink, SvgIcon } from "@mui/material";
16
- import type { LinkProps as MuiLinkProps } from "@mui/material";
15
+ import {
16
+ Link as MuiLink,
17
+ LinkProps as MuiLinkProps,
18
+ SvgIcon,
19
+ } from "@mui/material";
17
20
 
18
- export interface LinkProps extends MuiLinkProps {
21
+ export type LinkProps = {
22
+ children: React.ReactNode;
23
+ href: string;
19
24
  icon?: ReactElement;
20
- }
25
+ rel?: string;
26
+ target?: "_self" | "_blank" | "_parent" | "_top" | string;
27
+ variant?: MuiLinkProps["variant"];
28
+ };
21
29
 
22
30
  export const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {
23
- const { icon, children, target } = props;
31
+ const { icon, children, target, variant } = props;
24
32
  return (
25
- <MuiLink {...props} ref={ref}>
33
+ <MuiLink ref={ref} variant={variant} target={target}>
26
34
  {icon && <span className="Link-icon">{icon}</span>}
27
35
  {children}
28
36
  {target === "_blank" && (
@@ -22,7 +22,7 @@ import {
22
22
  } from "./";
23
23
  import { memo, MouseEvent, ReactElement, useMemo, useState } from "react";
24
24
 
25
- export interface MenuButtonProps {
25
+ export type MenuButtonProps = {
26
26
  /**
27
27
  * The <MenuItem> components within the Menu.
28
28
  */
@@ -41,13 +41,18 @@ export interface MenuButtonProps {
41
41
  * The variant of the triggering Button
42
42
  */
43
43
  buttonVariant?: ButtonProps["variant"];
44
- }
44
+ /**
45
+ * The id of the `input` element.
46
+ */
47
+ id?: string;
48
+ };
45
49
 
46
50
  const MenuButton = ({
47
51
  buttonLabel = "",
48
52
  children,
49
53
  buttonEndIcon = <ChevronDownIcon />,
50
54
  buttonVariant = "secondary",
55
+ id: idOverride,
51
56
  }: MenuButtonProps) => {
52
57
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
53
58
 
@@ -61,7 +66,7 @@ const MenuButton = ({
61
66
  setAnchorEl(null);
62
67
  };
63
68
 
64
- const uniqueId = useUniqueId();
69
+ const uniqueId = useUniqueId(idOverride);
65
70
 
66
71
  const menuListProps = useMemo(
67
72
  () => ({ "aria-labelledby": `${uniqueId}-button` }),
@@ -0,0 +1,41 @@
1
+ /*!
2
+ * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
+ *
5
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * Unless required by applicable law or agreed to in writing, software
7
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ *
10
+ * See the License for the specific language governing permissions and limitations under the License.
11
+ */
12
+
13
+ import { forwardRef, memo, ReactNode, useMemo } from "react";
14
+
15
+ import { MuiPropsContext, MuiPropsContextType } from "./MuiPropsContext";
16
+
17
+ export type MuiPropsChildProps = {
18
+ children: ReactNode;
19
+ };
20
+
21
+ const MuiPropsChild = forwardRef<HTMLElement, MuiPropsChildProps>(
22
+ ({ children, ...muiProps }, ref) => {
23
+ const providerValue = useMemo<MuiPropsContextType>(
24
+ () => ({
25
+ ...muiProps,
26
+ ref,
27
+ }),
28
+ [muiProps, ref]
29
+ );
30
+
31
+ return (
32
+ <MuiPropsContext.Provider value={providerValue}>
33
+ {children}
34
+ </MuiPropsContext.Provider>
35
+ );
36
+ }
37
+ );
38
+
39
+ const MemoizedMuiPropsChild = memo(MuiPropsChild);
40
+
41
+ export { MemoizedMuiPropsChild as MuiPropsChild };
@@ -0,0 +1,17 @@
1
+ /*!
2
+ * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
+ *
5
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * Unless required by applicable law or agreed to in writing, software
7
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ *
10
+ * See the License for the specific language governing permissions and limitations under the License.
11
+ */
12
+
13
+ import { createContext } from "react";
14
+
15
+ export type MuiPropsContextType = Record<string, unknown>;
16
+
17
+ export const MuiPropsContext = createContext<MuiPropsContextType>({});
@@ -24,10 +24,6 @@ import { EyeIcon, EyeOffIcon, IconButton } from "./";
24
24
  import { Field } from "./Field";
25
25
 
26
26
  export type PasswordFieldProps = {
27
- /**
28
- * If `true`, the component will receive focus automatically.
29
- */
30
- autoFocus?: boolean;
31
27
  /**
32
28
  * This prop helps users to fill forms faster, especially on mobile devices.
33
29
  * The name can be confusing, as it's more like an autofill.
@@ -38,6 +34,10 @@ export type PasswordFieldProps = {
38
34
  * If `error` is not undefined, the `input` will indicate an error.
39
35
  */
40
36
  errorMessage?: string;
37
+ /**
38
+ * If `true`, the component will receive focus automatically.
39
+ */
40
+ hasInitialFocus?: boolean;
41
41
  /**
42
42
  * The helper text content.
43
43
  */
@@ -51,13 +51,13 @@ export type PasswordFieldProps = {
51
51
  */
52
52
  isDisabled?: boolean;
53
53
  /**
54
- * It prevents the user from changing the value of the field
54
+ * If `true`, the `input` element is not required.
55
55
  */
56
- isReadOnly?: boolean;
56
+ isOptional?: boolean;
57
57
  /**
58
- * If `true`, the `input` element is required.
58
+ * It prevents the user from changing the value of the field
59
59
  */
60
- isRequired?: boolean;
60
+ isReadOnly?: boolean;
61
61
  /**
62
62
  * The label for the `input` element.
63
63
  */
@@ -88,11 +88,12 @@ const PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(
88
88
  (
89
89
  {
90
90
  autoCompleteType,
91
- autoFocus,
92
91
  errorMessage,
92
+ hasInitialFocus,
93
93
  hint,
94
94
  id: idOverride,
95
95
  isDisabled = false,
96
+ isOptional = false,
96
97
  isReadOnly,
97
98
  label,
98
99
  onChange,
@@ -117,7 +118,7 @@ const PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(
117
118
  aria-describedby={ariaDescribedBy}
118
119
  autoComplete={autoCompleteType}
119
120
  /* eslint-disable-next-line jsx-a11y/no-autofocus */
120
- autoFocus={autoFocus}
121
+ autoFocus={hasInitialFocus}
121
122
  endAdornment={
122
123
  <InputAdornment position="end">
123
124
  <IconButton
@@ -130,25 +131,28 @@ const PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(
130
131
  </InputAdornment>
131
132
  }
132
133
  id={id}
134
+ name={id}
133
135
  onChange={onChange}
134
136
  onFocus={onFocus}
135
137
  onBlur={onBlur}
136
138
  placeholder={placeholder}
137
139
  readOnly={isReadOnly}
138
140
  ref={ref}
141
+ required={!isOptional}
139
142
  type={inputType}
140
143
  value={value}
141
144
  />
142
145
  ),
143
146
  [
144
147
  autoCompleteType,
145
- autoFocus,
148
+ hasInitialFocus,
146
149
  togglePasswordVisibility,
147
150
  inputType,
148
151
  onChange,
149
152
  onFocus,
150
153
  onBlur,
151
154
  placeholder,
155
+ isOptional,
152
156
  isReadOnly,
153
157
  ref,
154
158
  value,
@@ -158,10 +162,12 @@ const PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(
158
162
  return (
159
163
  <Field
160
164
  errorMessage={errorMessage}
165
+ fieldType="single"
161
166
  hasVisibleLabel
162
167
  hint={hint}
163
168
  id={idOverride}
164
169
  isDisabled={isDisabled}
170
+ isOptional={isOptional}
165
171
  label={label}
166
172
  renderFieldComponent={renderFieldComponent}
167
173
  />
@@ -11,19 +11,12 @@
11
11
  */
12
12
 
13
13
  import { RadioGroup as MuiRadioGroup } from "@mui/material";
14
- import { ChangeEventHandler, memo, ReactElement, useMemo } from "react";
14
+ import { ChangeEventHandler, memo, ReactElement, useCallback } from "react";
15
15
 
16
- import {
17
- FormControl,
18
- FormLabel,
19
- FormHelperText,
20
- Radio,
21
- ScreenReaderText,
22
- useUniqueId,
23
- RadioProps,
24
- } from ".";
16
+ import { Radio, RadioProps } from "./Radio";
17
+ import { Field } from "./Field";
25
18
 
26
- export interface RadioGroupProps {
19
+ export type RadioGroupProps = {
27
20
  /**
28
21
  * The <Radio> components within the group. Must include two or more.
29
22
  */
@@ -40,6 +33,10 @@ export interface RadioGroupProps {
40
33
  * Optional hint text
41
34
  */
42
35
  hint?: string;
36
+ /**
37
+ * The id of the `input` element. This will also be the input's `name` field.
38
+ */
39
+ id?: string;
43
40
  /**
44
41
  * Disables the whole radio group
45
42
  */
@@ -48,10 +45,6 @@ export interface RadioGroupProps {
48
45
  * The text label for the radio group
49
46
  */
50
47
  label: string;
51
- /**
52
- * The name of the radio group, which only needs to be changed if there are multiple radio groups on the same screen
53
- */
54
- name?: string;
55
48
  /**
56
49
  * Listen for changes in the browser that change `value`.
57
50
  */
@@ -60,54 +53,46 @@ export interface RadioGroupProps {
60
53
  * The `value` on the selected radio button.
61
54
  */
62
55
  value?: RadioProps["value"];
63
- }
56
+ };
64
57
 
65
58
  const RadioGroup = ({
66
59
  children,
67
60
  defaultValue,
68
61
  errorMessage,
69
62
  hint,
63
+ id: idOverride,
70
64
  isDisabled,
71
65
  label,
72
- name,
73
66
  onChange,
67
+ value,
74
68
  }: RadioGroupProps) => {
75
- const ariaDescribedBy = useMemo(
76
- () =>
77
- errorMessage || hint
78
- ? [hint && `${name}-hint`, errorMessage && `${name}-error`]
79
- .filter(Boolean)
80
- .join(" ")
81
- : undefined,
82
- [errorMessage, hint, name]
83
- );
84
-
85
- const uniqueName = useUniqueId(name);
86
-
87
- return (
88
- <FormControl
89
- component="fieldset"
90
- disabled={isDisabled}
91
- error={Boolean(errorMessage)}
92
- >
93
- <FormLabel component="legend">{label}</FormLabel>
94
- {hint && (
95
- <FormHelperText id={`${uniqueName}-hint`}>{hint}</FormHelperText>
96
- )}
69
+ const renderFieldComponent = useCallback(
70
+ ({ ariaDescribedBy, id }) => (
97
71
  <MuiRadioGroup
98
72
  aria-describedby={ariaDescribedBy}
99
73
  defaultValue={defaultValue}
100
- name={uniqueName}
74
+ id={id}
75
+ name={id}
101
76
  onChange={onChange}
77
+ value={value}
102
78
  >
103
79
  {children}
104
80
  </MuiRadioGroup>
105
- {errorMessage && (
106
- <FormHelperText id={`${uniqueName}-error`} error>
107
- <ScreenReaderText>Error:</ScreenReaderText> {errorMessage}
108
- </FormHelperText>
109
- )}
110
- </FormControl>
81
+ ),
82
+ [children, defaultValue, onChange, value]
83
+ );
84
+
85
+ return (
86
+ <Field
87
+ errorMessage={errorMessage}
88
+ fieldType="group"
89
+ hasVisibleLabel={false}
90
+ hint={hint}
91
+ id={idOverride}
92
+ isDisabled={isDisabled}
93
+ label={label}
94
+ renderFieldComponent={renderFieldComponent}
95
+ />
111
96
  );
112
97
  };
113
98
 
@@ -24,16 +24,16 @@ import { SearchIcon } from "./";
24
24
  import { Field } from "./Field";
25
25
 
26
26
  export type SearchFieldProps = {
27
- /**
28
- * If `true`, the component will receive focus automatically.
29
- */
30
- autoFocus?: boolean;
31
27
  /**
32
28
  * This prop helps users to fill forms faster, especially on mobile devices.
33
29
  * The name can be confusing, as it's more like an autofill.
34
30
  * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
35
31
  */
36
32
  autoCompleteType?: InputHTMLAttributes<HTMLInputElement>["autoComplete"];
33
+ /**
34
+ * If `true`, the component will receive focus automatically.
35
+ */
36
+ hasInitialFocus?: boolean;
37
37
  /**
38
38
  * The id of the `input` element.
39
39
  */
@@ -72,7 +72,7 @@ const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(
72
72
  (
73
73
  {
74
74
  autoCompleteType,
75
- autoFocus,
75
+ hasInitialFocus,
76
76
  id: idOverride,
77
77
  isDisabled = false,
78
78
  label,
@@ -90,8 +90,9 @@ const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(
90
90
  aria-describedby={ariaDescribedBy}
91
91
  autoComplete={autoCompleteType}
92
92
  /* eslint-disable-next-line jsx-a11y/no-autofocus */
93
- autoFocus={autoFocus}
93
+ autoFocus={hasInitialFocus}
94
94
  id={id}
95
+ name={id}
95
96
  onChange={onChange}
96
97
  onFocus={onFocus}
97
98
  onBlur={onBlur}
@@ -108,7 +109,7 @@ const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(
108
109
  ),
109
110
  [
110
111
  autoCompleteType,
111
- autoFocus,
112
+ hasInitialFocus,
112
113
  onChange,
113
114
  onFocus,
114
115
  onBlur,
@@ -120,10 +121,11 @@ const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(
120
121
 
121
122
  return (
122
123
  <Field
124
+ fieldType="single"
123
125
  hasVisibleLabel={false}
124
126
  id={idOverride}
125
127
  isDisabled={isDisabled}
126
- isRequired={false}
128
+ isOptional={true}
127
129
  label={label}
128
130
  renderFieldComponent={renderFieldComponent}
129
131
  />
package/src/Status.tsx CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  import { Chip } from "./";
14
14
 
15
- export interface StatusProps {
15
+ export type StatusProps = {
16
16
  /**
17
17
  * Determine the color and icon of the alert
18
18
  */
@@ -22,7 +22,7 @@ export interface StatusProps {
22
22
  * The text content of the status
23
23
  */
24
24
  label: string;
25
- }
25
+ };
26
26
 
27
27
  export const Status = ({ severity, label }: StatusProps) => (
28
28
  <Chip label={label} color={severity} variant="status" />
package/src/TextField.tsx CHANGED
@@ -10,24 +10,21 @@
10
10
  * See the License for the specific language governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import { InputBase } from "@mui/material";
13
+ import { InputAdornment, InputBase } from "@mui/material";
14
14
  import {
15
15
  ChangeEventHandler,
16
16
  FocusEventHandler,
17
17
  forwardRef,
18
18
  InputHTMLAttributes,
19
19
  memo,
20
- ReactNode,
20
+ ReactElement,
21
21
  useCallback,
22
22
  } from "react";
23
23
 
24
24
  import { Field } from "./Field";
25
+ import { Icon } from "./Icon";
25
26
 
26
27
  export type TextFieldProps = {
27
- /**
28
- * If `true`, the component will receive focus automatically.
29
- */
30
- autoFocus?: boolean;
31
28
  /**
32
29
  * This prop helps users to fill forms faster, especially on mobile devices.
33
30
  * The name can be confusing, as it's more like an autofill.
@@ -37,11 +34,15 @@ export type TextFieldProps = {
37
34
  /**
38
35
  * End `InputAdornment` for this component.
39
36
  */
40
- endAdornment?: ReactNode;
37
+ endAdornment?: string | ReactElement<typeof Icon>;
41
38
  /**
42
39
  * If `error` is not undefined, the `input` will indicate an error.
43
40
  */
44
41
  errorMessage?: string;
42
+ /**
43
+ * If `true`, the component will receive focus automatically.
44
+ */
45
+ hasInitialFocus?: boolean;
45
46
  /**
46
47
  * The helper text content.
47
48
  */
@@ -59,13 +60,13 @@ export type TextFieldProps = {
59
60
  */
60
61
  isMultiline?: boolean;
61
62
  /**
62
- * It prevents the user from changing the value of the field
63
+ * If `true`, the `input` element is not required.
63
64
  */
64
- isReadOnly?: boolean;
65
+ isOptional?: boolean;
65
66
  /**
66
- * If `true`, the `input` element is required.
67
+ * It prevents the user from changing the value of the field
67
68
  */
68
- isRequired?: boolean;
69
+ isReadOnly?: boolean;
69
70
  /**
70
71
  * The label for the `input` element.
71
72
  */
@@ -83,7 +84,7 @@ export type TextFieldProps = {
83
84
  */
84
85
  onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
85
86
  /**
86
- * The label for the `input` element if the it's not optional
87
+ * The label for the `input` element if it's optional
87
88
  */
88
89
  optionalLabel?: string;
89
90
  /**
@@ -93,7 +94,7 @@ export type TextFieldProps = {
93
94
  /**
94
95
  * Start `InputAdornment` for this component.
95
96
  */
96
- startAdornment?: ReactNode;
97
+ startAdornment?: string | ReactElement<typeof Icon>;
97
98
  /**
98
99
  * Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).
99
100
  */
@@ -108,20 +109,20 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
108
109
  (
109
110
  {
110
111
  autoCompleteType,
111
- autoFocus,
112
+ hasInitialFocus,
112
113
  endAdornment,
113
114
  errorMessage,
114
115
  hint,
115
116
  id: idOverride,
116
117
  isDisabled = false,
117
118
  isMultiline = false,
119
+ isOptional = false,
118
120
  isReadOnly,
119
- isRequired = true,
120
121
  label,
121
122
  onBlur,
122
123
  onChange,
123
124
  onFocus,
124
- optionalLabel,
125
+ optionalLabel = "Optional",
125
126
  placeholder,
126
127
  startAdornment,
127
128
  type = "text",
@@ -135,24 +136,33 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
135
136
  aria-describedby={ariaDescribedBy}
136
137
  autoComplete={autoCompleteType}
137
138
  /* eslint-disable-next-line jsx-a11y/no-autofocus */
138
- autoFocus={autoFocus}
139
- endAdornment={endAdornment}
139
+ autoFocus={hasInitialFocus}
140
+ endAdornment={
141
+ endAdornment && (
142
+ <InputAdornment position="end">{endAdornment}</InputAdornment>
143
+ )
144
+ }
140
145
  id={id}
141
146
  multiline={isMultiline}
147
+ name={id}
142
148
  onBlur={onBlur}
143
149
  onChange={onChange}
144
150
  onFocus={onFocus}
145
151
  placeholder={placeholder}
146
152
  readOnly={isReadOnly}
147
153
  ref={ref}
148
- startAdornment={startAdornment}
154
+ startAdornment={
155
+ startAdornment && (
156
+ <InputAdornment position="start">{startAdornment}</InputAdornment>
157
+ )
158
+ }
149
159
  type={type}
150
160
  value={value}
151
161
  />
152
162
  ),
153
163
  [
154
164
  autoCompleteType,
155
- autoFocus,
165
+ hasInitialFocus,
156
166
  endAdornment,
157
167
  isMultiline,
158
168
  onChange,
@@ -170,11 +180,12 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
170
180
  return (
171
181
  <Field
172
182
  errorMessage={errorMessage}
183
+ fieldType="single"
173
184
  hasVisibleLabel
174
185
  hint={hint}
175
186
  id={idOverride}
176
187
  isDisabled={isDisabled}
177
- isRequired={isRequired}
188
+ isOptional={isOptional}
178
189
  label={label}
179
190
  optionalLabel={optionalLabel}
180
191
  renderFieldComponent={renderFieldComponent}