@okta/odyssey-react-mui 1.11.0 → 1.12.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 (92) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/@types/react-augment.d.js.map +1 -1
  3. package/dist/Autocomplete.js +5 -3
  4. package/dist/Autocomplete.js.map +1 -1
  5. package/dist/Button.js +5 -6
  6. package/dist/Button.js.map +1 -1
  7. package/dist/Checkbox.js +8 -7
  8. package/dist/Checkbox.js.map +1 -1
  9. package/dist/CheckboxGroup.js +2 -0
  10. package/dist/CheckboxGroup.js.map +1 -1
  11. package/dist/Field.js +3 -2
  12. package/dist/Field.js.map +1 -1
  13. package/dist/FieldComponentProps.js.map +1 -1
  14. package/dist/Link.js +5 -6
  15. package/dist/Link.js.map +1 -1
  16. package/dist/NativeSelect.js +18 -4
  17. package/dist/NativeSelect.js.map +1 -1
  18. package/dist/PasswordField.js +8 -7
  19. package/dist/PasswordField.js.map +1 -1
  20. package/dist/Radio.js +8 -7
  21. package/dist/Radio.js.map +1 -1
  22. package/dist/RadioGroup.js +2 -0
  23. package/dist/RadioGroup.js.map +1 -1
  24. package/dist/SearchField.js +2 -0
  25. package/dist/SearchField.js.map +1 -1
  26. package/dist/Select.js +10 -7
  27. package/dist/Select.js.map +1 -1
  28. package/dist/TextField.js +8 -7
  29. package/dist/TextField.js.map +1 -1
  30. package/dist/Typography.js +5 -6
  31. package/dist/Typography.js.map +1 -1
  32. package/dist/inputUtils.js.map +1 -1
  33. package/dist/labs/Switch.js +3 -3
  34. package/dist/labs/Switch.js.map +1 -1
  35. package/dist/labs/VirtualizedAutocomplete.js +5 -3
  36. package/dist/labs/VirtualizedAutocomplete.js.map +1 -1
  37. package/dist/src/Autocomplete.d.ts +2 -2
  38. package/dist/src/Autocomplete.d.ts.map +1 -1
  39. package/dist/src/Button.d.ts +4 -4
  40. package/dist/src/Button.d.ts.map +1 -1
  41. package/dist/src/Checkbox.d.ts +4 -4
  42. package/dist/src/Checkbox.d.ts.map +1 -1
  43. package/dist/src/CheckboxGroup.d.ts +2 -2
  44. package/dist/src/CheckboxGroup.d.ts.map +1 -1
  45. package/dist/src/Field.d.ts +1 -1
  46. package/dist/src/Field.d.ts.map +1 -1
  47. package/dist/src/FieldComponentProps.d.ts +4 -0
  48. package/dist/src/FieldComponentProps.d.ts.map +1 -1
  49. package/dist/src/Link.d.ts +4 -4
  50. package/dist/src/Link.d.ts.map +1 -1
  51. package/dist/src/NativeSelect.d.ts +13 -2
  52. package/dist/src/NativeSelect.d.ts.map +1 -1
  53. package/dist/src/PasswordField.d.ts +5 -5
  54. package/dist/src/PasswordField.d.ts.map +1 -1
  55. package/dist/src/Radio.d.ts +4 -4
  56. package/dist/src/Radio.d.ts.map +1 -1
  57. package/dist/src/RadioGroup.d.ts +2 -2
  58. package/dist/src/RadioGroup.d.ts.map +1 -1
  59. package/dist/src/SearchField.d.ts +2 -2
  60. package/dist/src/SearchField.d.ts.map +1 -1
  61. package/dist/src/Select.d.ts +5 -5
  62. package/dist/src/Select.d.ts.map +1 -1
  63. package/dist/src/TextField.d.ts +5 -5
  64. package/dist/src/TextField.d.ts.map +1 -1
  65. package/dist/src/Typography.d.ts +4 -4
  66. package/dist/src/Typography.d.ts.map +1 -1
  67. package/dist/src/inputUtils.d.ts +3 -0
  68. package/dist/src/inputUtils.d.ts.map +1 -1
  69. package/dist/src/labs/Switch.d.ts.map +1 -1
  70. package/dist/src/labs/VirtualizedAutocomplete.d.ts +2 -2
  71. package/dist/src/labs/VirtualizedAutocomplete.d.ts.map +1 -1
  72. package/dist/tsconfig.production.tsbuildinfo +1 -1
  73. package/package.json +3 -3
  74. package/src/@types/react-augment.d.ts +8 -4
  75. package/src/Autocomplete.tsx +6 -1
  76. package/src/Button.tsx +8 -9
  77. package/src/Checkbox.tsx +15 -11
  78. package/src/CheckboxGroup.tsx +3 -0
  79. package/src/Field.tsx +8 -4
  80. package/src/FieldComponentProps.ts +4 -0
  81. package/src/Link.tsx +8 -9
  82. package/src/NativeSelect.tsx +36 -2
  83. package/src/PasswordField.tsx +11 -11
  84. package/src/Radio.tsx +16 -10
  85. package/src/RadioGroup.tsx +3 -0
  86. package/src/SearchField.tsx +6 -1
  87. package/src/Select.tsx +12 -10
  88. package/src/TextField.tsx +11 -11
  89. package/src/Typography.tsx +8 -9
  90. package/src/inputUtils.ts +4 -0
  91. package/src/labs/Switch.tsx +2 -1
  92. package/src/labs/VirtualizedAutocomplete.tsx +20 -3
package/src/Select.tsx CHANGED
@@ -36,10 +36,10 @@ import { CheckIcon } from "./icons.generated";
36
36
  import type { AllowedProps } from "./AllowedProps";
37
37
  import {
38
38
  ComponentControlledState,
39
+ FocusHandle,
39
40
  useInputValues,
40
41
  getControlState,
41
42
  } from "./inputUtils";
42
- import { FocusHandle } from "./@types/react-augment";
43
43
 
44
44
  export type SelectOption = {
45
45
  text: string;
@@ -63,9 +63,9 @@ export type SelectProps<
63
63
  */
64
64
  hasMultipleChoices?: HasMultipleChoices;
65
65
  /**
66
- * The ref forwarded to the Select to expose focus()
66
+ * The ref forwarded to the Select
67
67
  */
68
- inputFocusRef?: React.RefObject<FocusHandle>;
68
+ inputRef?: React.RefObject<FocusHandle>;
69
69
  /**
70
70
  * @deprecated Use `hasMultipleChoices` instead.
71
71
  */
@@ -97,6 +97,7 @@ export type SelectProps<
97
97
  value?: Value;
98
98
  } & Pick<
99
99
  FieldComponentProps,
100
+ | "ariaDescribedBy"
100
101
  | "errorMessage"
101
102
  | "errorMessageList"
102
103
  | "hint"
@@ -129,6 +130,7 @@ const Select = <
129
130
  Value extends SelectValueType<HasMultipleChoices>,
130
131
  HasMultipleChoices extends boolean
131
132
  >({
133
+ ariaDescribedBy,
132
134
  defaultValue,
133
135
  errorMessage,
134
136
  errorMessageList,
@@ -136,7 +138,7 @@ const Select = <
136
138
  hint,
137
139
  HintLinkComponent,
138
140
  id: idOverride,
139
- inputFocusRef,
141
+ inputRef,
140
142
  isDisabled = false,
141
143
  isFullWidth = false,
142
144
  isMultiSelect,
@@ -164,15 +166,14 @@ const Select = <
164
166
  const [internalSelectedValues, setInternalSelectedValues] = useState(
165
167
  controlledStateRef.current === CONTROLLED ? value : defaultValue
166
168
  );
167
- const inputRef = useRef<HTMLSelectElement>(null);
169
+ const localInputRef = useRef<HTMLSelectElement>(null);
168
170
 
169
171
  useImperativeHandle(
170
- inputFocusRef,
172
+ inputRef,
171
173
  () => {
172
- const element = inputRef.current;
173
174
  return {
174
175
  focus: () => {
175
- element && element.focus();
176
+ localInputRef.current?.focus();
176
177
  },
177
178
  };
178
179
  },
@@ -290,9 +291,9 @@ const Select = <
290
291
  aria-describedby={ariaDescribedBy}
291
292
  aria-errormessage={errorMessageElementId}
292
293
  children={children}
293
- data-se={testId}
294
294
  id={id}
295
- inputRef={inputRef}
295
+ inputProps={{ "data-se": testId }}
296
+ inputRef={localInputRef}
296
297
  labelId={labelElementId}
297
298
  multiple={hasMultipleChoices}
298
299
  name={nameOverride ?? id}
@@ -319,6 +320,7 @@ const Select = <
319
320
 
320
321
  return (
321
322
  <Field
323
+ ariaDescribedBy={ariaDescribedBy}
322
324
  errorMessage={errorMessage}
323
325
  errorMessageList={errorMessageList}
324
326
  fieldType="single"
package/src/TextField.tsx CHANGED
@@ -26,8 +26,7 @@ import { InputAdornment, InputBase } from "@mui/material";
26
26
  import { FieldComponentProps } from "./FieldComponentProps";
27
27
  import { Field } from "./Field";
28
28
  import { AllowedProps } from "./AllowedProps";
29
- import { useInputValues, getControlState } from "./inputUtils";
30
- import { FocusHandle } from "./@types/react-augment";
29
+ import { FocusHandle, useInputValues, getControlState } from "./inputUtils";
31
30
 
32
31
  export const textFieldTypeValues = [
33
32
  "email",
@@ -57,9 +56,9 @@ export type TextFieldProps = {
57
56
  */
58
57
  hasInitialFocus?: boolean;
59
58
  /**
60
- * The ref forwarded to the TextField to expose focus()
59
+ * The ref forwarded to the TextField
61
60
  */
62
- inputFocusRef?: React.RefObject<FocusHandle>;
61
+ inputRef?: React.RefObject<FocusHandle>;
63
62
  /**
64
63
  * Hints at the type of data that might be entered by the user while editing the element or its contents
65
64
  * @see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute
@@ -107,6 +106,7 @@ export type TextFieldProps = {
107
106
  const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
108
107
  (
109
108
  {
109
+ ariaDescribedBy,
110
110
  autoCompleteType,
111
111
  defaultValue,
112
112
  hasInitialFocus,
@@ -116,7 +116,7 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
116
116
  hint,
117
117
  HintLinkComponent,
118
118
  id: idOverride,
119
- inputFocusRef,
119
+ inputRef,
120
120
  inputMode,
121
121
  isDisabled = false,
122
122
  isFullWidth = false,
@@ -149,14 +149,13 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
149
149
  controlState: controlledStateRef.current,
150
150
  });
151
151
 
152
- const inputRef = useRef<HTMLInputElement>(null);
152
+ const localInputRef = useRef<HTMLInputElement>(null);
153
153
  useImperativeHandle(
154
- inputFocusRef,
154
+ inputRef,
155
155
  () => {
156
- const element = inputRef.current;
157
156
  return {
158
157
  focus: () => {
159
- element && element.focus();
158
+ localInputRef.current?.focus();
160
159
  },
161
160
  };
162
161
  },
@@ -180,7 +179,6 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
180
179
  autoComplete={autoCompleteType}
181
180
  /* eslint-disable-next-line jsx-a11y/no-autofocus */
182
181
  autoFocus={hasInitialFocus}
183
- data-se={testId}
184
182
  endAdornment={
185
183
  endAdornment && (
186
184
  <InputAdornment position="end" translate={translate}>
@@ -192,9 +190,10 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
192
190
  inputProps={{
193
191
  "aria-errormessage": errorMessageElementId,
194
192
  "aria-labelledby": labelElementId,
193
+ "data-se": testId,
195
194
  inputmode: inputMode,
196
195
  }}
197
- inputRef={inputRef}
196
+ inputRef={localInputRef}
198
197
  multiline={isMultiline}
199
198
  name={nameOverride ?? id}
200
199
  onBlur={onBlur}
@@ -239,6 +238,7 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
239
238
 
240
239
  return (
241
240
  <Field
241
+ ariaDescribedBy={ariaDescribedBy}
242
242
  errorMessage={errorMessage}
243
243
  errorMessageList={errorMessageList}
244
244
  fieldType="single"
@@ -23,7 +23,7 @@ import {
23
23
  useImperativeHandle,
24
24
  } from "react";
25
25
  import { AllowedProps } from "./AllowedProps";
26
- import { FocusHandle } from "./@types/react-augment";
26
+ import { FocusHandle } from "./inputUtils";
27
27
 
28
28
  export type TypographyVariantValue =
29
29
  | "h1"
@@ -87,9 +87,9 @@ export type TypographyProps = {
87
87
  */
88
88
  component?: ElementType;
89
89
  /**
90
- * The ref forwarded to the Typography to expose focus()
90
+ * The ref forwarded to the Typography
91
91
  */
92
- typographyFocusRef?: React.RefObject<FocusHandle>;
92
+ typographyRef?: React.RefObject<FocusHandle>;
93
93
  /**
94
94
  * The variant of Typography to render.
95
95
  */
@@ -105,7 +105,7 @@ const Typography = ({
105
105
  component: componentProp,
106
106
  testId,
107
107
  translate,
108
- typographyFocusRef,
108
+ typographyRef,
109
109
  variant = "body",
110
110
  }: TypographyProps) => {
111
111
  const component = useMemo(() => {
@@ -121,14 +121,13 @@ const Typography = ({
121
121
  return componentProp;
122
122
  }, [componentProp, variant]);
123
123
 
124
- const ref = useRef<HTMLElement>(null);
124
+ const localTypographyRef = useRef<HTMLElement>(null);
125
125
  useImperativeHandle(
126
- typographyFocusRef,
126
+ typographyRef,
127
127
  () => {
128
- const element = ref.current;
129
128
  return {
130
129
  focus: () => {
131
- element && element.focus();
130
+ localTypographyRef.current?.focus();
132
131
  },
133
132
  };
134
133
  },
@@ -144,7 +143,7 @@ const Typography = ({
144
143
  color={color}
145
144
  component={component}
146
145
  data-se={testId}
147
- ref={ref}
146
+ ref={localTypographyRef}
148
147
  tabIndex={-1}
149
148
  translate={translate}
150
149
  variant={typographyVariantMapping[variant]}
package/src/inputUtils.ts CHANGED
@@ -12,6 +12,10 @@
12
12
 
13
13
  import { useMemo } from "react";
14
14
 
15
+ export type FocusHandle = {
16
+ focus: () => void;
17
+ };
18
+
15
19
  type UseControlledStateProps<Value> = {
16
20
  controlledValue?: Value;
17
21
  uncontrolledValue?: Value;
@@ -186,6 +186,7 @@ const Switch = ({
186
186
  "aria-describedby": hintId,
187
187
  "aria-label": label,
188
188
  "aria-labelledby": labelElementId,
189
+ "data-se": testId,
189
190
  }}
190
191
  name={_name ?? id}
191
192
  onChange={handleOnChange}
@@ -201,6 +202,7 @@ const Switch = ({
201
202
  label,
202
203
  labelElementId,
203
204
  _name,
205
+ testId,
204
206
  ]
205
207
  );
206
208
 
@@ -213,7 +215,6 @@ const Switch = ({
213
215
  <FormControlLabel
214
216
  checked={internalSwitchChecked}
215
217
  control={renderSwitchComponent}
216
- data-se={testId}
217
218
  disabled={isDisabled}
218
219
  id={labelElementId}
219
220
  label={
@@ -168,7 +168,13 @@ export type AutocompleteProps<
168
168
  getIsOptionEqualToValue?: (option: OptionType, value: OptionType) => boolean;
169
169
  } & Pick<
170
170
  FieldComponentProps,
171
- "errorMessage" | "errorMessageList" | "hint" | "id" | "isOptional" | "name"
171
+ | "ariaDescribedBy"
172
+ | "errorMessage"
173
+ | "errorMessageList"
174
+ | "hint"
175
+ | "id"
176
+ | "isOptional"
177
+ | "name"
172
178
  > &
173
179
  AllowedProps;
174
180
 
@@ -177,6 +183,7 @@ const VirtualizedAutocomplete = <
177
183
  HasMultipleChoices extends boolean | undefined,
178
184
  IsCustomValueAllowed extends boolean | undefined
179
185
  >({
186
+ ariaDescribedBy,
180
187
  defaultValue,
181
188
  errorMessage,
182
189
  errorMessageList,
@@ -243,6 +250,7 @@ const VirtualizedAutocomplete = <
243
250
  const renderInput = useCallback(
244
251
  ({ InputLabelProps, InputProps, ...params }) => (
245
252
  <Field
253
+ ariaDescribedBy={ariaDescribedBy}
246
254
  errorMessage={errorMessage}
247
255
  errorMessageList={errorMessageList}
248
256
  fieldType="single"
@@ -264,6 +272,7 @@ const VirtualizedAutocomplete = <
264
272
  ...params.inputProps,
265
273
  "aria-errormessage": errorMessageElementId,
266
274
  "aria-labelledby": labelElementId,
275
+ "data-se": testId,
267
276
  }}
268
277
  aria-describedby={ariaDescribedBy}
269
278
  id={id}
@@ -273,7 +282,16 @@ const VirtualizedAutocomplete = <
273
282
  )}
274
283
  />
275
284
  ),
276
- [errorMessage, errorMessageList, hint, isOptional, label, nameOverride]
285
+ [
286
+ ariaDescribedBy,
287
+ errorMessage,
288
+ errorMessageList,
289
+ hint,
290
+ isOptional,
291
+ label,
292
+ nameOverride,
293
+ testId,
294
+ ]
277
295
  );
278
296
  const onChange = useCallback<
279
297
  NonNullable<
@@ -313,7 +331,6 @@ const VirtualizedAutocomplete = <
313
331
  {...inputValueProp}
314
332
  // AutoComplete is wrapped in a div within MUI which does not get the disabled attr. So this aria-disabled gets set in the div
315
333
  aria-disabled={isDisabled}
316
- data-se={testId}
317
334
  disableCloseOnSelect={hasMultipleChoices}
318
335
  disabled={isDisabled}
319
336
  freeSolo={isCustomValueAllowed}