@okta/odyssey-react-mui 0.21.3 → 0.22.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 (158) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/Autocomplete.js +58 -0
  3. package/dist/Autocomplete.js.map +1 -0
  4. package/dist/Banner.js +2 -3
  5. package/dist/Banner.js.map +1 -1
  6. package/dist/Button.js +46 -0
  7. package/dist/Button.js.map +1 -0
  8. package/dist/CheckboxGroup.js +2 -3
  9. package/dist/CheckboxGroup.js.map +1 -1
  10. package/dist/CircularProgress.js +12 -0
  11. package/dist/CircularProgress.js.map +1 -0
  12. package/dist/Field.js +59 -0
  13. package/dist/Field.js.map +1 -0
  14. package/dist/FieldError.js +34 -0
  15. package/dist/FieldError.js.map +1 -0
  16. package/dist/FieldHint.js +29 -0
  17. package/dist/FieldHint.js.map +1 -0
  18. package/dist/FieldLabel.js +32 -0
  19. package/dist/FieldLabel.js.map +1 -0
  20. package/dist/Infobox.js +2 -3
  21. package/dist/Infobox.js.map +1 -1
  22. package/dist/MenuButton.js +2 -2
  23. package/dist/MenuButton.js.map +1 -1
  24. package/dist/MenuItem.js +0 -1
  25. package/dist/MenuItem.js.map +1 -1
  26. package/dist/PasswordField.js +68 -0
  27. package/dist/PasswordField.js.map +1 -0
  28. package/dist/RadioGroup.js +2 -3
  29. package/dist/RadioGroup.js.map +1 -1
  30. package/dist/ScreenReaderText.js +30 -0
  31. package/dist/ScreenReaderText.js.map +1 -0
  32. package/dist/SearchField.js +54 -0
  33. package/dist/SearchField.js.map +1 -0
  34. package/dist/Tag.js +28 -0
  35. package/dist/Tag.js.map +1 -0
  36. package/dist/TagList.js +26 -0
  37. package/dist/TagList.js.map +1 -0
  38. package/dist/TagListContext.js +16 -0
  39. package/dist/TagListContext.js.map +1 -0
  40. package/dist/TextField.js +26 -62
  41. package/dist/TextField.js.map +1 -1
  42. package/dist/index.js +12 -2
  43. package/dist/index.js.map +1 -1
  44. package/dist/src/Autocomplete.d.ts +27 -0
  45. package/dist/src/Autocomplete.d.ts.map +1 -0
  46. package/dist/src/Button.d.ts +31 -0
  47. package/dist/src/Button.d.ts.map +1 -0
  48. package/dist/src/CircularProgress.d.ts +16 -0
  49. package/dist/src/CircularProgress.d.ts.map +1 -0
  50. package/dist/src/Field.d.ts +54 -0
  51. package/dist/src/Field.d.ts.map +1 -0
  52. package/dist/src/FieldError.d.ts +19 -0
  53. package/dist/src/FieldError.d.ts.map +1 -0
  54. package/dist/src/FieldHint.d.ts +19 -0
  55. package/dist/src/FieldHint.d.ts.map +1 -0
  56. package/dist/src/FieldLabel.d.ts +23 -0
  57. package/dist/src/FieldLabel.d.ts.map +1 -0
  58. package/dist/src/Icon.d.ts +1 -1
  59. package/dist/src/Link.d.ts +1 -1
  60. package/dist/src/MenuButton.d.ts.map +1 -1
  61. package/dist/src/MenuItem.d.ts +1 -1
  62. package/dist/src/MenuItem.d.ts.map +1 -1
  63. package/dist/src/PasswordField.d.ts +75 -0
  64. package/dist/src/PasswordField.d.ts.map +1 -0
  65. package/dist/src/RadioGroup.d.ts.map +1 -1
  66. package/dist/src/ScreenReaderText.d.ts +21 -0
  67. package/dist/src/ScreenReaderText.d.ts.map +1 -0
  68. package/dist/src/SearchField.d.ts +59 -0
  69. package/dist/src/SearchField.d.ts.map +1 -0
  70. package/dist/src/Tag.d.ts +22 -0
  71. package/dist/src/Tag.d.ts.map +1 -0
  72. package/dist/src/TagList.d.ts +19 -0
  73. package/dist/src/TagList.d.ts.map +1 -0
  74. package/dist/src/TagListContext.d.ts +18 -0
  75. package/dist/src/TagListContext.d.ts.map +1 -0
  76. package/dist/src/TextField.d.ts +3 -8
  77. package/dist/src/TextField.d.ts.map +1 -1
  78. package/dist/src/iconDictionary/Add.d.ts +1 -1
  79. package/dist/src/iconDictionary/AddCircle.d.ts +1 -1
  80. package/dist/src/iconDictionary/AlertCircle.d.ts +1 -1
  81. package/dist/src/iconDictionary/AlertCircleFilled.d.ts +1 -1
  82. package/dist/src/iconDictionary/AlertTriangleFilled.d.ts +1 -1
  83. package/dist/src/iconDictionary/Anchor.d.ts +1 -1
  84. package/dist/src/iconDictionary/ArrowDown.d.ts +1 -1
  85. package/dist/src/iconDictionary/ArrowLeft.d.ts +1 -1
  86. package/dist/src/iconDictionary/ArrowRight.d.ts +1 -1
  87. package/dist/src/iconDictionary/ArrowUp.d.ts +1 -1
  88. package/dist/src/iconDictionary/ArrowUpDown.d.ts +1 -1
  89. package/dist/src/iconDictionary/Calendar.d.ts +1 -1
  90. package/dist/src/iconDictionary/Check.d.ts +1 -1
  91. package/dist/src/iconDictionary/CheckCircleFilled.d.ts +1 -1
  92. package/dist/src/iconDictionary/ChevronDown.d.ts +1 -1
  93. package/dist/src/iconDictionary/ChevronUp.d.ts +1 -1
  94. package/dist/src/iconDictionary/Close.d.ts +1 -1
  95. package/dist/src/iconDictionary/CloseCircleFilled.d.ts +1 -1
  96. package/dist/src/iconDictionary/Copy.d.ts +1 -1
  97. package/dist/src/iconDictionary/Delete.d.ts +1 -1
  98. package/dist/src/iconDictionary/Download.d.ts +1 -1
  99. package/dist/src/iconDictionary/DragHandle.d.ts +1 -1
  100. package/dist/src/iconDictionary/Edit.d.ts +1 -1
  101. package/dist/src/iconDictionary/ExternalLink.d.ts +1 -1
  102. package/dist/src/iconDictionary/Eye.d.ts +1 -1
  103. package/dist/src/iconDictionary/EyeOff.d.ts +1 -1
  104. package/dist/src/iconDictionary/Filter.d.ts +1 -1
  105. package/dist/src/iconDictionary/Globe.d.ts +1 -1
  106. package/dist/src/iconDictionary/Home.d.ts +1 -1
  107. package/dist/src/iconDictionary/InformationCircle.d.ts +1 -1
  108. package/dist/src/iconDictionary/InformationCircleFilled.d.ts +1 -1
  109. package/dist/src/iconDictionary/Notification.d.ts +1 -1
  110. package/dist/src/iconDictionary/OverflowVertical.d.ts +1 -1
  111. package/dist/src/iconDictionary/QuestionCircle.d.ts +1 -1
  112. package/dist/src/iconDictionary/QuestionCircleFilled.d.ts +1 -1
  113. package/dist/src/iconDictionary/Search.d.ts +1 -1
  114. package/dist/src/iconDictionary/Settings.d.ts +1 -1
  115. package/dist/src/iconDictionary/Subtract.d.ts +1 -1
  116. package/dist/src/iconDictionary/User.d.ts +1 -1
  117. package/dist/src/iconDictionary/UserGroup.d.ts +1 -1
  118. package/dist/src/iconDictionary/index.d.ts +40 -40
  119. package/dist/src/index.d.ts +13 -3
  120. package/dist/src/index.d.ts.map +1 -1
  121. package/dist/src/theme/components.d.ts.map +1 -1
  122. package/dist/src/theme/components.types.d.ts +0 -8
  123. package/dist/src/theme/components.types.d.ts.map +1 -1
  124. package/dist/theme/components.js +217 -124
  125. package/dist/theme/components.js.map +1 -1
  126. package/dist/theme/components.types.js.map +1 -1
  127. package/dist/tsconfig.production.tsbuildinfo +1 -1
  128. package/package.json +3 -3
  129. package/src/Autocomplete.tsx +132 -0
  130. package/src/Banner.tsx +2 -2
  131. package/src/Button.tsx +75 -0
  132. package/src/CheckboxGroup.tsx +2 -2
  133. package/src/CircularProgress.tsx +24 -0
  134. package/src/Field.tsx +112 -0
  135. package/src/FieldError.tsx +34 -0
  136. package/src/FieldHint.tsx +28 -0
  137. package/src/FieldLabel.tsx +57 -0
  138. package/src/Infobox.tsx +2 -2
  139. package/src/MenuButton.tsx +2 -3
  140. package/src/MenuItem.tsx +0 -1
  141. package/src/OdysseyCacheProvider.test.tsx +1 -1
  142. package/src/PasswordField.tsx +174 -0
  143. package/src/RadioGroup.tsx +2 -2
  144. package/src/ScreenReaderText.tsx +36 -0
  145. package/src/SearchField.tsx +136 -0
  146. package/src/Tag.tsx +41 -0
  147. package/src/TagList.tsx +43 -0
  148. package/src/TagListContext.tsx +23 -0
  149. package/src/TextField.tsx +43 -101
  150. package/src/index.ts +11 -5
  151. package/src/theme/components.tsx +87 -18
  152. package/src/theme/components.types.ts +0 -8
  153. package/dist/PasswordInput.js +0 -87
  154. package/dist/PasswordInput.js.map +0 -1
  155. package/dist/src/PasswordInput.d.ts +0 -21
  156. package/dist/src/PasswordInput.d.ts.map +0 -1
  157. package/src/PasswordInput.test.tsx +0 -51
  158. package/src/PasswordInput.tsx +0 -111
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okta/odyssey-react-mui",
3
- "version": "0.21.3",
3
+ "version": "0.22.0",
4
4
  "description": "React MUI components for Odyssey, Okta's design system",
5
5
  "author": "Okta, Inc.",
6
6
  "license": "Apache-2.0",
@@ -25,7 +25,7 @@
25
25
  "@mui/lab": "^5.0.0-alpha.117",
26
26
  "@mui/material": "^5.11.6",
27
27
  "@mui/utils": "^5.11.2",
28
- "@okta/odyssey-design-tokens": "0.21.3"
28
+ "@okta/odyssey-design-tokens": "0.22.0"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@emotion/react": "^11",
@@ -33,5 +33,5 @@
33
33
  "react": ">=17 <19",
34
34
  "react-dom": ">=17 <19"
35
35
  },
36
- "gitHead": "06e016c9b7228f30babae07b3b23be04ceaa2f77"
36
+ "gitHead": "b1a4a93f7d570162a52e4c28012fb65e31d5bb4b"
37
37
  }
@@ -0,0 +1,132 @@
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 {
14
+ Autocomplete as MuiAutocomplete,
15
+ AutocompleteProps as MuiAutocompleteProps,
16
+ InputBase,
17
+ } from "@mui/material";
18
+ import { memo, useCallback } from "react";
19
+
20
+ import { Field } from "./Field";
21
+
22
+ export type AutocompleteProps<
23
+ OptionType,
24
+ HasMultipleChoices extends boolean | undefined,
25
+ IsCustomValueAllowed extends boolean | undefined
26
+ > = {
27
+ hasMultipleChoices?: MuiAutocompleteProps<
28
+ OptionType,
29
+ HasMultipleChoices,
30
+ undefined,
31
+ IsCustomValueAllowed
32
+ >["multiple"];
33
+ hint?: string;
34
+ isCustomValueAllowed?: MuiAutocompleteProps<
35
+ OptionType,
36
+ HasMultipleChoices,
37
+ undefined,
38
+ IsCustomValueAllowed
39
+ >["freeSolo"];
40
+ isDisabled?: MuiAutocompleteProps<
41
+ OptionType,
42
+ HasMultipleChoices,
43
+ undefined,
44
+ IsCustomValueAllowed
45
+ >["disabled"];
46
+ isLoading?: MuiAutocompleteProps<
47
+ OptionType,
48
+ HasMultipleChoices,
49
+ undefined,
50
+ IsCustomValueAllowed
51
+ >["loading"];
52
+ isReadOnly?: MuiAutocompleteProps<
53
+ OptionType,
54
+ HasMultipleChoices,
55
+ undefined,
56
+ IsCustomValueAllowed
57
+ >["readOnly"];
58
+ label: string;
59
+ onChange?: MuiAutocompleteProps<
60
+ OptionType,
61
+ HasMultipleChoices,
62
+ undefined,
63
+ IsCustomValueAllowed
64
+ >["onChange"];
65
+ options: MuiAutocompleteProps<
66
+ OptionType,
67
+ HasMultipleChoices,
68
+ undefined,
69
+ IsCustomValueAllowed
70
+ >["options"];
71
+ value?: MuiAutocompleteProps<
72
+ OptionType,
73
+ HasMultipleChoices,
74
+ undefined,
75
+ IsCustomValueAllowed
76
+ >["value"];
77
+ };
78
+
79
+ const Autocomplete = <
80
+ OptionType,
81
+ HasMultipleChoices extends boolean | undefined,
82
+ IsCustomValueAllowed extends boolean | undefined
83
+ >({
84
+ isCustomValueAllowed,
85
+ hasMultipleChoices,
86
+ isDisabled,
87
+ isLoading,
88
+ isReadOnly,
89
+ hint,
90
+ label,
91
+ onChange,
92
+ options,
93
+ value,
94
+ }: AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>) => {
95
+ const renderInput = useCallback(
96
+ ({ InputLabelProps, InputProps, ...params }) => (
97
+ <Field
98
+ {...InputLabelProps}
99
+ hasVisibleLabel
100
+ hint={hint}
101
+ label={label}
102
+ renderFieldComponent={({ ariaDescribedBy, id }) => (
103
+ <InputBase
104
+ {...params}
105
+ {...InputProps}
106
+ aria-describedby={ariaDescribedBy}
107
+ id={id}
108
+ />
109
+ )}
110
+ />
111
+ ),
112
+ [hint, label]
113
+ );
114
+
115
+ return (
116
+ <MuiAutocomplete
117
+ disabled={isDisabled}
118
+ freeSolo={isCustomValueAllowed}
119
+ loading={isLoading}
120
+ multiple={hasMultipleChoices}
121
+ onChange={onChange}
122
+ options={options}
123
+ readOnly={isReadOnly}
124
+ renderInput={renderInput}
125
+ value={value}
126
+ />
127
+ );
128
+ };
129
+
130
+ const MemoizedAutocomplete = memo(Autocomplete) as typeof Autocomplete;
131
+
132
+ export { MemoizedAutocomplete as Autocomplete };
package/src/Banner.tsx CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  import { AlertColor, AlertProps } from "@mui/material";
14
14
  import { memo } from "react";
15
- import { Alert, Link, visuallyHidden } from "./";
15
+ import { Alert, Link, ScreenReaderText } from "./";
16
16
 
17
17
  export interface BannerProps {
18
18
  /**
@@ -55,7 +55,7 @@ const Banner = ({
55
55
  text,
56
56
  }: BannerProps) => (
57
57
  <Alert onClose={onClose} role={role} severity={severity} variant="banner">
58
- <span style={visuallyHidden}>{severity}:</span>
58
+ <ScreenReaderText>{severity}:</ScreenReaderText>
59
59
  {text}
60
60
  {linkUrl && (
61
61
  <Link href={linkUrl} variant="monochrome">
package/src/Button.tsx ADDED
@@ -0,0 +1,75 @@
1
+ /*!
2
+ * Copyright (c) 2022-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 { Button as MuiButton } from "@mui/material";
14
+ import type { ButtonProps as MuiButtonProps } from "@mui/material";
15
+ import { Tooltip } from "./";
16
+ import { memo } from "react";
17
+
18
+ export type ButtonProps = {
19
+ endIcon?: React.ReactNode;
20
+ id?: string;
21
+ isDisabled?: boolean;
22
+ isFullWidth?: boolean;
23
+ onClick?: MuiButtonProps["onClick"];
24
+ size?: MuiButtonProps["size"];
25
+ startIcon?: React.ReactNode;
26
+ text?: string;
27
+ /**
28
+ * `tooltipText` determines the text of the tooltip that wraps the button if it's icon-only.
29
+ */
30
+ tooltipText?: string;
31
+ variant?: "primary" | "secondary" | "danger" | "floating";
32
+ };
33
+
34
+ const Button = ({
35
+ endIcon,
36
+ id,
37
+ isDisabled,
38
+ isFullWidth,
39
+ onClick,
40
+ size = "medium",
41
+ startIcon,
42
+ text,
43
+ tooltipText,
44
+ variant,
45
+ }: ButtonProps) => {
46
+ const button = (
47
+ <MuiButton
48
+ disabled={isDisabled}
49
+ endIcon={endIcon}
50
+ fullWidth={isFullWidth}
51
+ id={id}
52
+ onClick={onClick}
53
+ size={size}
54
+ startIcon={startIcon}
55
+ variant={variant}
56
+ >
57
+ {text}
58
+ </MuiButton>
59
+ );
60
+
61
+ return (
62
+ <>
63
+ {tooltipText && (
64
+ <Tooltip describeChild placement="top" title={tooltipText}>
65
+ {button}
66
+ </Tooltip>
67
+ )}
68
+ {!tooltipText && button}
69
+ </>
70
+ );
71
+ };
72
+
73
+ const MemoizedButton = memo(Button);
74
+
75
+ export { MemoizedButton as Button };
@@ -18,7 +18,7 @@ import {
18
18
  FormGroup,
19
19
  FormHelperText,
20
20
  FormLabel,
21
- visuallyHidden,
21
+ ScreenReaderText,
22
22
  } from ".";
23
23
 
24
24
  export type CheckboxGroupProps = {
@@ -61,7 +61,7 @@ const CheckboxGroup = ({
61
61
  <FormGroup aria-describedby={ariaDescribedBy}>{children}</FormGroup>
62
62
  {errorMessage && (
63
63
  <FormHelperText id={`${name}-error`} error>
64
- <span style={visuallyHidden}>Error:</span> {errorMessage}
64
+ <ScreenReaderText>Error:</ScreenReaderText> {errorMessage}
65
65
  </FormHelperText>
66
66
  )}
67
67
  </FormControl>
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * Copyright (c) 2022-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 { CircularProgress as MuiCircularProgress } from "@mui/material";
14
+
15
+ export type CircularProgressProps = {
16
+ value?: number;
17
+ };
18
+
19
+ export const CircularProgress = ({ value }: CircularProgressProps) => (
20
+ <MuiCircularProgress
21
+ value={value}
22
+ variant={value ? "determinate" : "indeterminate"}
23
+ />
24
+ );
package/src/Field.tsx ADDED
@@ -0,0 +1,112 @@
1
+ /*!
2
+ * Copyright (c) 2022-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 { memo, ReactElement, useMemo } from "react";
14
+
15
+ import {
16
+ FieldError,
17
+ FieldHint,
18
+ FieldLabel,
19
+ FormControl,
20
+ useUniqueId,
21
+ } from "./";
22
+
23
+ export type FieldProps = {
24
+ /**
25
+ * If `error` is not undefined, the `input` will indicate an error.
26
+ */
27
+ errorMessage?: string;
28
+ hasVisibleLabel: boolean;
29
+ /**
30
+ * The helper text content.
31
+ */
32
+ hint?: string;
33
+ /**
34
+ * The id of the `input` element.
35
+ */
36
+ id?: string;
37
+ /**
38
+ * If `true`, the component is disabled.
39
+ */
40
+ isDisabled?: boolean;
41
+ /**
42
+ * If `true`, the `input` element is required.
43
+ */
44
+ isRequired?: boolean;
45
+ /**
46
+ * The label for the `input` element.
47
+ */
48
+ label: string;
49
+ /**
50
+ * The label for the `input` element if the it's not optional
51
+ */
52
+ optionalLabel?: string;
53
+ /**
54
+ * The short hint displayed in the `input` before the user enters a value.
55
+ */
56
+ placeholder?: string;
57
+ renderFieldComponent: ({
58
+ ariaDescribedBy,
59
+ id,
60
+ }: {
61
+ ariaDescribedBy?: string;
62
+ id: string;
63
+ }) => ReactElement;
64
+ };
65
+
66
+ const Field = ({
67
+ errorMessage,
68
+ hasVisibleLabel,
69
+ hint,
70
+ id: idOverride,
71
+ isDisabled = false,
72
+ isRequired = true,
73
+ label,
74
+ optionalLabel,
75
+ renderFieldComponent,
76
+ }: FieldProps) => {
77
+ const id = useUniqueId(idOverride);
78
+ const hintId = hint ? `${id}-hint` : undefined;
79
+ const errorId = errorMessage ? `${id}-error` : undefined;
80
+ const labelId = `${id}-label`;
81
+
82
+ const ariaDescribedBy = useMemo(
83
+ () => [hintId, errorId].join(" ").trim() || undefined,
84
+ [errorId, hintId]
85
+ );
86
+
87
+ return (
88
+ <FormControl disabled={isDisabled} error={Boolean(errorMessage)}>
89
+ <FieldLabel
90
+ hasVisibleLabel={hasVisibleLabel}
91
+ id={labelId}
92
+ inputId={id}
93
+ isRequired={isRequired}
94
+ optionalText={optionalLabel}
95
+ text={label}
96
+ />
97
+
98
+ {hint && <FieldHint id={hintId} text={hint} />}
99
+
100
+ {renderFieldComponent({
101
+ ariaDescribedBy,
102
+ id,
103
+ })}
104
+
105
+ {errorMessage && <FieldError id={errorId} text={errorMessage} />}
106
+ </FormControl>
107
+ );
108
+ };
109
+
110
+ const MemoizedField = memo(Field);
111
+
112
+ export { MemoizedField as Field };
@@ -0,0 +1,34 @@
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 { memo } from "react";
14
+
15
+ import { FormHelperText } from ".";
16
+ import { ScreenReaderText } from "./ScreenReaderText";
17
+
18
+ export type FieldErrorProps = {
19
+ id?: string;
20
+ text: string;
21
+ };
22
+
23
+ const FieldError = ({ id, text }: FieldErrorProps) => {
24
+ return (
25
+ <FormHelperText error id={id}>
26
+ <ScreenReaderText>Error:</ScreenReaderText>
27
+ {text}
28
+ </FormHelperText>
29
+ );
30
+ };
31
+
32
+ const MemoizedFieldError = memo(FieldError);
33
+
34
+ export { MemoizedFieldError as FieldError };
@@ -0,0 +1,28 @@
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 { memo } from "react";
14
+
15
+ import { FormHelperText } from "./";
16
+
17
+ export type FieldHintProps = {
18
+ id?: string;
19
+ text: string;
20
+ };
21
+
22
+ const FieldHint = ({ id, text }: FieldHintProps) => {
23
+ return <FormHelperText id={id}>{text}</FormHelperText>;
24
+ };
25
+
26
+ const MemoizedFieldHint = memo(FieldHint);
27
+
28
+ export { MemoizedFieldHint as FieldHint };
@@ -0,0 +1,57 @@
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 { InputLabel } from "@mui/material";
14
+ import { memo, useMemo } from "react";
15
+
16
+ import { ScreenReaderText } from "./ScreenReaderText";
17
+ import { Typography } from ".";
18
+
19
+ export type FieldLabelProps = {
20
+ hasVisibleLabel: boolean;
21
+ id: string;
22
+ inputId: string;
23
+ isRequired: boolean;
24
+ optionalText?: string;
25
+ text: string;
26
+ };
27
+
28
+ const FieldLabel = ({
29
+ hasVisibleLabel,
30
+ id,
31
+ inputId,
32
+ isRequired,
33
+ optionalText,
34
+ text,
35
+ }: FieldLabelProps) => {
36
+ const inputLabel = useMemo(
37
+ () => (
38
+ <InputLabel htmlFor={inputId} id={id}>
39
+ {text}
40
+ {!isRequired && (
41
+ <Typography variant="subtitle1">{optionalText}</Typography>
42
+ )}
43
+ </InputLabel>
44
+ ),
45
+ [id, inputId, isRequired, optionalText, text]
46
+ );
47
+
48
+ return hasVisibleLabel ? (
49
+ inputLabel
50
+ ) : (
51
+ <ScreenReaderText>{inputLabel}</ScreenReaderText>
52
+ );
53
+ };
54
+
55
+ const MemoizedFieldLabel = memo(FieldLabel);
56
+
57
+ export { MemoizedFieldLabel as FieldLabel };
package/src/Infobox.tsx CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  import { AlertColor } from "@mui/material";
14
14
  import { memo, ReactNode } from "react";
15
- import { Alert, AlertTitle, visuallyHidden } from ".";
15
+ import { Alert, AlertTitle, ScreenReaderText } from ".";
16
16
 
17
17
  export interface InfoboxProps {
18
18
  /**
@@ -37,7 +37,7 @@ export interface InfoboxProps {
37
37
 
38
38
  const Infobox = ({ children, severity, role, title }: InfoboxProps) => (
39
39
  <Alert role={role} severity={severity} variant="infobox">
40
- <span style={visuallyHidden}>{severity}: </span>
40
+ <ScreenReaderText>{severity}: </ScreenReaderText>
41
41
  {title && <AlertTitle>{title}</AlertTitle>}
42
42
  {children}
43
43
  </Alert>
@@ -77,10 +77,9 @@ const MenuButton = ({
77
77
  aria-haspopup="true"
78
78
  aria-expanded={open ? "true" : undefined}
79
79
  onClick={handleClick}
80
+ text={buttonLabel}
80
81
  variant={buttonVariant}
81
- >
82
- {buttonLabel}
83
- </Button>
82
+ />
84
83
  <Menu
85
84
  id={`${uniqueId}-menu`}
86
85
  anchorEl={anchorEl}
package/src/MenuItem.tsx CHANGED
@@ -45,6 +45,5 @@ const MenuItem = forwardRef<HTMLLIElement, MenuItemProps>(
45
45
  );
46
46
 
47
47
  const MemoizedMenuItem = memo(MenuItem);
48
- MemoizedMenuItem.displayName = "MenuItem";
49
48
 
50
49
  export { MemoizedMenuItem as MenuItem };
@@ -29,7 +29,7 @@ describe("OdysseyCacheProvider", () => {
29
29
  it("themes a Button", () => {
30
30
  render(
31
31
  <OdysseyCacheProvider>
32
- <Button>text</Button>
32
+ <Button text="text" />
33
33
  </OdysseyCacheProvider>
34
34
  );
35
35