@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.
- package/CHANGELOG.md +12 -0
- package/dist/@types/react-augment.d.js.map +1 -1
- package/dist/Autocomplete.js +5 -3
- package/dist/Autocomplete.js.map +1 -1
- package/dist/Button.js +5 -6
- package/dist/Button.js.map +1 -1
- package/dist/Checkbox.js +8 -7
- package/dist/Checkbox.js.map +1 -1
- package/dist/CheckboxGroup.js +2 -0
- package/dist/CheckboxGroup.js.map +1 -1
- package/dist/Field.js +3 -2
- package/dist/Field.js.map +1 -1
- package/dist/FieldComponentProps.js.map +1 -1
- package/dist/Link.js +5 -6
- package/dist/Link.js.map +1 -1
- package/dist/NativeSelect.js +18 -4
- package/dist/NativeSelect.js.map +1 -1
- package/dist/PasswordField.js +8 -7
- package/dist/PasswordField.js.map +1 -1
- package/dist/Radio.js +8 -7
- package/dist/Radio.js.map +1 -1
- package/dist/RadioGroup.js +2 -0
- package/dist/RadioGroup.js.map +1 -1
- package/dist/SearchField.js +2 -0
- package/dist/SearchField.js.map +1 -1
- package/dist/Select.js +10 -7
- package/dist/Select.js.map +1 -1
- package/dist/TextField.js +8 -7
- package/dist/TextField.js.map +1 -1
- package/dist/Typography.js +5 -6
- package/dist/Typography.js.map +1 -1
- package/dist/inputUtils.js.map +1 -1
- package/dist/labs/Switch.js +3 -3
- package/dist/labs/Switch.js.map +1 -1
- package/dist/labs/VirtualizedAutocomplete.js +5 -3
- package/dist/labs/VirtualizedAutocomplete.js.map +1 -1
- package/dist/src/Autocomplete.d.ts +2 -2
- package/dist/src/Autocomplete.d.ts.map +1 -1
- package/dist/src/Button.d.ts +4 -4
- package/dist/src/Button.d.ts.map +1 -1
- package/dist/src/Checkbox.d.ts +4 -4
- package/dist/src/Checkbox.d.ts.map +1 -1
- package/dist/src/CheckboxGroup.d.ts +2 -2
- package/dist/src/CheckboxGroup.d.ts.map +1 -1
- package/dist/src/Field.d.ts +1 -1
- package/dist/src/Field.d.ts.map +1 -1
- package/dist/src/FieldComponentProps.d.ts +4 -0
- package/dist/src/FieldComponentProps.d.ts.map +1 -1
- package/dist/src/Link.d.ts +4 -4
- package/dist/src/Link.d.ts.map +1 -1
- package/dist/src/NativeSelect.d.ts +13 -2
- package/dist/src/NativeSelect.d.ts.map +1 -1
- package/dist/src/PasswordField.d.ts +5 -5
- package/dist/src/PasswordField.d.ts.map +1 -1
- package/dist/src/Radio.d.ts +4 -4
- package/dist/src/Radio.d.ts.map +1 -1
- package/dist/src/RadioGroup.d.ts +2 -2
- package/dist/src/RadioGroup.d.ts.map +1 -1
- package/dist/src/SearchField.d.ts +2 -2
- package/dist/src/SearchField.d.ts.map +1 -1
- package/dist/src/Select.d.ts +5 -5
- package/dist/src/Select.d.ts.map +1 -1
- package/dist/src/TextField.d.ts +5 -5
- package/dist/src/TextField.d.ts.map +1 -1
- package/dist/src/Typography.d.ts +4 -4
- package/dist/src/Typography.d.ts.map +1 -1
- package/dist/src/inputUtils.d.ts +3 -0
- package/dist/src/inputUtils.d.ts.map +1 -1
- package/dist/src/labs/Switch.d.ts.map +1 -1
- package/dist/src/labs/VirtualizedAutocomplete.d.ts +2 -2
- package/dist/src/labs/VirtualizedAutocomplete.d.ts.map +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/@types/react-augment.d.ts +8 -4
- package/src/Autocomplete.tsx +6 -1
- package/src/Button.tsx +8 -9
- package/src/Checkbox.tsx +15 -11
- package/src/CheckboxGroup.tsx +3 -0
- package/src/Field.tsx +8 -4
- package/src/FieldComponentProps.ts +4 -0
- package/src/Link.tsx +8 -9
- package/src/NativeSelect.tsx +36 -2
- package/src/PasswordField.tsx +11 -11
- package/src/Radio.tsx +16 -10
- package/src/RadioGroup.tsx +3 -0
- package/src/SearchField.tsx +6 -1
- package/src/Select.tsx +12 -10
- package/src/TextField.tsx +11 -11
- package/src/Typography.tsx +8 -9
- package/src/inputUtils.ts +4 -0
- package/src/labs/Switch.tsx +2 -1
- 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
|
|
66
|
+
* The ref forwarded to the Select
|
|
67
67
|
*/
|
|
68
|
-
|
|
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
|
-
|
|
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
|
|
169
|
+
const localInputRef = useRef<HTMLSelectElement>(null);
|
|
168
170
|
|
|
169
171
|
useImperativeHandle(
|
|
170
|
-
|
|
172
|
+
inputRef,
|
|
171
173
|
() => {
|
|
172
|
-
const element = inputRef.current;
|
|
173
174
|
return {
|
|
174
175
|
focus: () => {
|
|
175
|
-
|
|
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
|
-
|
|
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
|
|
59
|
+
* The ref forwarded to the TextField
|
|
61
60
|
*/
|
|
62
|
-
|
|
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
|
-
|
|
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
|
|
152
|
+
const localInputRef = useRef<HTMLInputElement>(null);
|
|
153
153
|
useImperativeHandle(
|
|
154
|
-
|
|
154
|
+
inputRef,
|
|
155
155
|
() => {
|
|
156
|
-
const element = inputRef.current;
|
|
157
156
|
return {
|
|
158
157
|
focus: () => {
|
|
159
|
-
|
|
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={
|
|
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"
|
package/src/Typography.tsx
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
useImperativeHandle,
|
|
24
24
|
} from "react";
|
|
25
25
|
import { AllowedProps } from "./AllowedProps";
|
|
26
|
-
import { FocusHandle } from "
|
|
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
|
|
90
|
+
* The ref forwarded to the Typography
|
|
91
91
|
*/
|
|
92
|
-
|
|
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
|
-
|
|
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
|
|
124
|
+
const localTypographyRef = useRef<HTMLElement>(null);
|
|
125
125
|
useImperativeHandle(
|
|
126
|
-
|
|
126
|
+
typographyRef,
|
|
127
127
|
() => {
|
|
128
|
-
const element = ref.current;
|
|
129
128
|
return {
|
|
130
129
|
focus: () => {
|
|
131
|
-
|
|
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={
|
|
146
|
+
ref={localTypographyRef}
|
|
148
147
|
tabIndex={-1}
|
|
149
148
|
translate={translate}
|
|
150
149
|
variant={typographyVariantMapping[variant]}
|
package/src/inputUtils.ts
CHANGED
package/src/labs/Switch.tsx
CHANGED
|
@@ -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
|
-
|
|
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
|
-
[
|
|
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}
|