@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.
- package/CHANGELOG.md +24 -0
- package/dist/Autocomplete.js +58 -0
- package/dist/Autocomplete.js.map +1 -0
- package/dist/Banner.js +2 -3
- package/dist/Banner.js.map +1 -1
- package/dist/Button.js +46 -0
- package/dist/Button.js.map +1 -0
- package/dist/CheckboxGroup.js +2 -3
- package/dist/CheckboxGroup.js.map +1 -1
- package/dist/CircularProgress.js +12 -0
- package/dist/CircularProgress.js.map +1 -0
- package/dist/Field.js +59 -0
- package/dist/Field.js.map +1 -0
- package/dist/FieldError.js +34 -0
- package/dist/FieldError.js.map +1 -0
- package/dist/FieldHint.js +29 -0
- package/dist/FieldHint.js.map +1 -0
- package/dist/FieldLabel.js +32 -0
- package/dist/FieldLabel.js.map +1 -0
- package/dist/Infobox.js +2 -3
- package/dist/Infobox.js.map +1 -1
- package/dist/MenuButton.js +2 -2
- package/dist/MenuButton.js.map +1 -1
- package/dist/MenuItem.js +0 -1
- package/dist/MenuItem.js.map +1 -1
- package/dist/PasswordField.js +68 -0
- package/dist/PasswordField.js.map +1 -0
- package/dist/RadioGroup.js +2 -3
- package/dist/RadioGroup.js.map +1 -1
- package/dist/ScreenReaderText.js +30 -0
- package/dist/ScreenReaderText.js.map +1 -0
- package/dist/SearchField.js +54 -0
- package/dist/SearchField.js.map +1 -0
- package/dist/Tag.js +28 -0
- package/dist/Tag.js.map +1 -0
- package/dist/TagList.js +26 -0
- package/dist/TagList.js.map +1 -0
- package/dist/TagListContext.js +16 -0
- package/dist/TagListContext.js.map +1 -0
- package/dist/TextField.js +26 -62
- package/dist/TextField.js.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/src/Autocomplete.d.ts +27 -0
- package/dist/src/Autocomplete.d.ts.map +1 -0
- package/dist/src/Button.d.ts +31 -0
- package/dist/src/Button.d.ts.map +1 -0
- package/dist/src/CircularProgress.d.ts +16 -0
- package/dist/src/CircularProgress.d.ts.map +1 -0
- package/dist/src/Field.d.ts +54 -0
- package/dist/src/Field.d.ts.map +1 -0
- package/dist/src/FieldError.d.ts +19 -0
- package/dist/src/FieldError.d.ts.map +1 -0
- package/dist/src/FieldHint.d.ts +19 -0
- package/dist/src/FieldHint.d.ts.map +1 -0
- package/dist/src/FieldLabel.d.ts +23 -0
- package/dist/src/FieldLabel.d.ts.map +1 -0
- package/dist/src/Icon.d.ts +1 -1
- package/dist/src/Link.d.ts +1 -1
- package/dist/src/MenuButton.d.ts.map +1 -1
- package/dist/src/MenuItem.d.ts +1 -1
- package/dist/src/MenuItem.d.ts.map +1 -1
- package/dist/src/PasswordField.d.ts +75 -0
- package/dist/src/PasswordField.d.ts.map +1 -0
- package/dist/src/RadioGroup.d.ts.map +1 -1
- package/dist/src/ScreenReaderText.d.ts +21 -0
- package/dist/src/ScreenReaderText.d.ts.map +1 -0
- package/dist/src/SearchField.d.ts +59 -0
- package/dist/src/SearchField.d.ts.map +1 -0
- package/dist/src/Tag.d.ts +22 -0
- package/dist/src/Tag.d.ts.map +1 -0
- package/dist/src/TagList.d.ts +19 -0
- package/dist/src/TagList.d.ts.map +1 -0
- package/dist/src/TagListContext.d.ts +18 -0
- package/dist/src/TagListContext.d.ts.map +1 -0
- package/dist/src/TextField.d.ts +3 -8
- package/dist/src/TextField.d.ts.map +1 -1
- package/dist/src/iconDictionary/Add.d.ts +1 -1
- package/dist/src/iconDictionary/AddCircle.d.ts +1 -1
- package/dist/src/iconDictionary/AlertCircle.d.ts +1 -1
- package/dist/src/iconDictionary/AlertCircleFilled.d.ts +1 -1
- package/dist/src/iconDictionary/AlertTriangleFilled.d.ts +1 -1
- package/dist/src/iconDictionary/Anchor.d.ts +1 -1
- package/dist/src/iconDictionary/ArrowDown.d.ts +1 -1
- package/dist/src/iconDictionary/ArrowLeft.d.ts +1 -1
- package/dist/src/iconDictionary/ArrowRight.d.ts +1 -1
- package/dist/src/iconDictionary/ArrowUp.d.ts +1 -1
- package/dist/src/iconDictionary/ArrowUpDown.d.ts +1 -1
- package/dist/src/iconDictionary/Calendar.d.ts +1 -1
- package/dist/src/iconDictionary/Check.d.ts +1 -1
- package/dist/src/iconDictionary/CheckCircleFilled.d.ts +1 -1
- package/dist/src/iconDictionary/ChevronDown.d.ts +1 -1
- package/dist/src/iconDictionary/ChevronUp.d.ts +1 -1
- package/dist/src/iconDictionary/Close.d.ts +1 -1
- package/dist/src/iconDictionary/CloseCircleFilled.d.ts +1 -1
- package/dist/src/iconDictionary/Copy.d.ts +1 -1
- package/dist/src/iconDictionary/Delete.d.ts +1 -1
- package/dist/src/iconDictionary/Download.d.ts +1 -1
- package/dist/src/iconDictionary/DragHandle.d.ts +1 -1
- package/dist/src/iconDictionary/Edit.d.ts +1 -1
- package/dist/src/iconDictionary/ExternalLink.d.ts +1 -1
- package/dist/src/iconDictionary/Eye.d.ts +1 -1
- package/dist/src/iconDictionary/EyeOff.d.ts +1 -1
- package/dist/src/iconDictionary/Filter.d.ts +1 -1
- package/dist/src/iconDictionary/Globe.d.ts +1 -1
- package/dist/src/iconDictionary/Home.d.ts +1 -1
- package/dist/src/iconDictionary/InformationCircle.d.ts +1 -1
- package/dist/src/iconDictionary/InformationCircleFilled.d.ts +1 -1
- package/dist/src/iconDictionary/Notification.d.ts +1 -1
- package/dist/src/iconDictionary/OverflowVertical.d.ts +1 -1
- package/dist/src/iconDictionary/QuestionCircle.d.ts +1 -1
- package/dist/src/iconDictionary/QuestionCircleFilled.d.ts +1 -1
- package/dist/src/iconDictionary/Search.d.ts +1 -1
- package/dist/src/iconDictionary/Settings.d.ts +1 -1
- package/dist/src/iconDictionary/Subtract.d.ts +1 -1
- package/dist/src/iconDictionary/User.d.ts +1 -1
- package/dist/src/iconDictionary/UserGroup.d.ts +1 -1
- package/dist/src/iconDictionary/index.d.ts +40 -40
- package/dist/src/index.d.ts +13 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/theme/components.d.ts.map +1 -1
- package/dist/src/theme/components.types.d.ts +0 -8
- package/dist/src/theme/components.types.d.ts.map +1 -1
- package/dist/theme/components.js +217 -124
- package/dist/theme/components.js.map +1 -1
- package/dist/theme/components.types.js.map +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Autocomplete.tsx +132 -0
- package/src/Banner.tsx +2 -2
- package/src/Button.tsx +75 -0
- package/src/CheckboxGroup.tsx +2 -2
- package/src/CircularProgress.tsx +24 -0
- package/src/Field.tsx +112 -0
- package/src/FieldError.tsx +34 -0
- package/src/FieldHint.tsx +28 -0
- package/src/FieldLabel.tsx +57 -0
- package/src/Infobox.tsx +2 -2
- package/src/MenuButton.tsx +2 -3
- package/src/MenuItem.tsx +0 -1
- package/src/OdysseyCacheProvider.test.tsx +1 -1
- package/src/PasswordField.tsx +174 -0
- package/src/RadioGroup.tsx +2 -2
- package/src/ScreenReaderText.tsx +36 -0
- package/src/SearchField.tsx +136 -0
- package/src/Tag.tsx +41 -0
- package/src/TagList.tsx +43 -0
- package/src/TagListContext.tsx +23 -0
- package/src/TextField.tsx +43 -101
- package/src/index.ts +11 -5
- package/src/theme/components.tsx +87 -18
- package/src/theme/components.types.ts +0 -8
- package/dist/PasswordInput.js +0 -87
- package/dist/PasswordInput.js.map +0 -1
- package/dist/src/PasswordInput.d.ts +0 -21
- package/dist/src/PasswordInput.d.ts.map +0 -1
- package/src/PasswordInput.test.tsx +0 -51
- 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.
|
|
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.
|
|
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": "
|
|
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,
|
|
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
|
-
<
|
|
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 };
|
package/src/CheckboxGroup.tsx
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
FormGroup,
|
|
19
19
|
FormHelperText,
|
|
20
20
|
FormLabel,
|
|
21
|
-
|
|
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
|
-
<
|
|
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,
|
|
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
|
-
<
|
|
40
|
+
<ScreenReaderText>{severity}: </ScreenReaderText>
|
|
41
41
|
{title && <AlertTitle>{title}</AlertTitle>}
|
|
42
42
|
{children}
|
|
43
43
|
</Alert>
|
package/src/MenuButton.tsx
CHANGED
|
@@ -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