@okta/odyssey-react-mui 0.21.4 → 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.
- package/CHANGELOG.md +41 -0
- package/dist/Autocomplete.js +62 -0
- package/dist/Autocomplete.js.map +1 -0
- package/dist/Banner.js +3 -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 +23 -35
- package/dist/CheckboxGroup.js.map +1 -1
- package/dist/Dialog.js +68 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/Field.js +72 -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/Icon.js +7 -6
- package/dist/Icon.js.map +1 -1
- package/dist/Infobox.js +1 -1
- package/dist/Infobox.js.map +1 -1
- package/dist/Link.js +5 -2
- package/dist/Link.js.map +1 -1
- package/dist/MenuButton.js +5 -4
- package/dist/MenuButton.js.map +1 -1
- package/dist/MenuItem.js +0 -1
- package/dist/MenuItem.js.map +1 -1
- package/dist/MuiPropsChild.js +30 -0
- package/dist/MuiPropsChild.js.map +1 -0
- package/dist/MuiPropsContext.js +14 -0
- package/dist/MuiPropsContext.js.map +1 -0
- package/dist/PasswordField.js +73 -0
- package/dist/PasswordField.js.map +1 -0
- package/dist/RadioGroup.js +25 -26
- package/dist/RadioGroup.js.map +1 -1
- package/dist/SearchField.js +56 -0
- package/dist/SearchField.js.map +1 -0
- package/dist/Status.js.map +1 -1
- 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 +36 -62
- package/dist/TextField.js.map +1 -1
- package/dist/Toast.js +72 -0
- package/dist/Toast.js.map +1 -0
- package/dist/ToastStack.js +33 -0
- package/dist/ToastStack.js.map +1 -0
- package/dist/Tooltip.js +20 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/iconDictionary/Add.js +4 -4
- package/dist/iconDictionary/Add.js.map +1 -1
- package/dist/iconDictionary/AddCircle.js +4 -4
- package/dist/iconDictionary/AddCircle.js.map +1 -1
- package/dist/iconDictionary/AlertCircle.js +4 -4
- package/dist/iconDictionary/AlertCircle.js.map +1 -1
- package/dist/iconDictionary/AlertCircleFilled.js +4 -4
- package/dist/iconDictionary/AlertCircleFilled.js.map +1 -1
- package/dist/iconDictionary/AlertTriangleFilled.js +4 -4
- package/dist/iconDictionary/AlertTriangleFilled.js.map +1 -1
- package/dist/iconDictionary/Anchor.js +5 -5
- package/dist/iconDictionary/Anchor.js.map +1 -1
- package/dist/iconDictionary/ArrowDown.js +4 -4
- package/dist/iconDictionary/ArrowDown.js.map +1 -1
- package/dist/iconDictionary/ArrowLeft.js +4 -4
- package/dist/iconDictionary/ArrowLeft.js.map +1 -1
- package/dist/iconDictionary/ArrowRight.js +4 -4
- package/dist/iconDictionary/ArrowRight.js.map +1 -1
- package/dist/iconDictionary/ArrowUp.js +4 -4
- package/dist/iconDictionary/ArrowUp.js.map +1 -1
- package/dist/iconDictionary/ArrowUpDown.js +4 -4
- package/dist/iconDictionary/ArrowUpDown.js.map +1 -1
- package/dist/iconDictionary/Calendar.js +4 -4
- package/dist/iconDictionary/Calendar.js.map +1 -1
- package/dist/iconDictionary/Check.js +4 -4
- package/dist/iconDictionary/Check.js.map +1 -1
- package/dist/iconDictionary/CheckCircleFilled.js +4 -4
- package/dist/iconDictionary/CheckCircleFilled.js.map +1 -1
- package/dist/iconDictionary/ChevronDown.js +4 -4
- package/dist/iconDictionary/ChevronDown.js.map +1 -1
- package/dist/iconDictionary/ChevronUp.js +4 -4
- package/dist/iconDictionary/ChevronUp.js.map +1 -1
- package/dist/iconDictionary/Close.js +4 -4
- package/dist/iconDictionary/Close.js.map +1 -1
- package/dist/iconDictionary/CloseCircleFilled.js +4 -4
- package/dist/iconDictionary/CloseCircleFilled.js.map +1 -1
- package/dist/iconDictionary/Copy.js +4 -4
- package/dist/iconDictionary/Copy.js.map +1 -1
- package/dist/iconDictionary/Delete.js +4 -4
- package/dist/iconDictionary/Delete.js.map +1 -1
- package/dist/iconDictionary/Download.js +4 -4
- package/dist/iconDictionary/Download.js.map +1 -1
- package/dist/iconDictionary/DragHandle.js +4 -4
- package/dist/iconDictionary/DragHandle.js.map +1 -1
- package/dist/iconDictionary/Edit.js +4 -4
- package/dist/iconDictionary/Edit.js.map +1 -1
- package/dist/iconDictionary/ExternalLink.js +4 -4
- package/dist/iconDictionary/ExternalLink.js.map +1 -1
- package/dist/iconDictionary/Eye.js +4 -4
- package/dist/iconDictionary/Eye.js.map +1 -1
- package/dist/iconDictionary/EyeOff.js +4 -4
- package/dist/iconDictionary/EyeOff.js.map +1 -1
- package/dist/iconDictionary/Filter.js +4 -4
- package/dist/iconDictionary/Filter.js.map +1 -1
- package/dist/iconDictionary/Globe.js +4 -4
- package/dist/iconDictionary/Globe.js.map +1 -1
- package/dist/iconDictionary/Home.js +4 -4
- package/dist/iconDictionary/Home.js.map +1 -1
- package/dist/iconDictionary/InformationCircle.js +4 -4
- package/dist/iconDictionary/InformationCircle.js.map +1 -1
- package/dist/iconDictionary/InformationCircleFilled.js +4 -4
- package/dist/iconDictionary/InformationCircleFilled.js.map +1 -1
- package/dist/iconDictionary/Notification.js +4 -4
- package/dist/iconDictionary/Notification.js.map +1 -1
- package/dist/iconDictionary/OverflowVertical.js +4 -4
- package/dist/iconDictionary/OverflowVertical.js.map +1 -1
- package/dist/iconDictionary/QuestionCircle.js +4 -4
- package/dist/iconDictionary/QuestionCircle.js.map +1 -1
- package/dist/iconDictionary/QuestionCircleFilled.js +4 -4
- package/dist/iconDictionary/QuestionCircleFilled.js.map +1 -1
- package/dist/iconDictionary/Search.js +4 -4
- package/dist/iconDictionary/Search.js.map +1 -1
- package/dist/iconDictionary/Settings.js +3 -3
- package/dist/iconDictionary/Settings.js.map +1 -1
- package/dist/iconDictionary/Subtract.js +4 -4
- package/dist/iconDictionary/Subtract.js.map +1 -1
- package/dist/iconDictionary/User.js +4 -4
- package/dist/iconDictionary/User.js.map +1 -1
- package/dist/iconDictionary/UserGroup.js +4 -4
- package/dist/iconDictionary/UserGroup.js.map +1 -1
- package/dist/iconDictionary/index.js.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/src/Autocomplete.d.ts +28 -0
- package/dist/src/Autocomplete.d.ts.map +1 -0
- package/dist/src/Banner.d.ts +19 -19
- package/dist/src/Banner.d.ts.map +1 -1
- package/dist/src/Button.d.ts +32 -0
- package/dist/src/Button.d.ts.map +1 -0
- package/dist/src/CheckboxGroup.d.ts +7 -4
- package/dist/src/CheckboxGroup.d.ts.map +1 -1
- package/dist/src/Dialog.d.ts +25 -0
- package/dist/src/Dialog.d.ts.map +1 -0
- package/dist/src/Field.d.ts +65 -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 +6 -7
- package/dist/src/Icon.d.ts.map +1 -1
- package/dist/src/Infobox.d.ts +7 -7
- package/dist/src/Infobox.d.ts.map +1 -1
- package/dist/src/Link.d.ts +9 -4
- package/dist/src/Link.d.ts.map +1 -1
- package/dist/src/MenuButton.d.ts +7 -3
- 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/MuiPropsChild.d.ts +18 -0
- package/dist/src/MuiPropsChild.d.ts.map +1 -0
- package/dist/src/MuiPropsContext.d.ts +15 -0
- package/dist/src/MuiPropsContext.d.ts.map +1 -0
- package/dist/src/PasswordField.d.ts +75 -0
- package/dist/src/PasswordField.d.ts.map +1 -0
- package/dist/src/RadioGroup.d.ts +8 -8
- package/dist/src/RadioGroup.d.ts.map +1 -1
- package/dist/src/SearchField.d.ts +59 -0
- package/dist/src/SearchField.d.ts.map +1 -0
- package/dist/src/Status.d.ts +2 -2
- package/dist/src/Status.d.ts.map +1 -1
- 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 +16 -20
- package/dist/src/TextField.d.ts.map +1 -1
- package/dist/src/Toast.d.ts +60 -0
- package/dist/src/Toast.d.ts.map +1 -0
- package/dist/src/ToastStack.d.ts +19 -0
- package/dist/src/ToastStack.d.ts.map +1 -0
- package/dist/src/Tooltip.d.ts +21 -0
- package/dist/src/Tooltip.d.ts.map +1 -0
- package/dist/src/iconDictionary/Add.d.ts +2 -2
- package/dist/src/iconDictionary/AddCircle.d.ts +2 -2
- package/dist/src/iconDictionary/AlertCircle.d.ts +2 -2
- package/dist/src/iconDictionary/AlertCircleFilled.d.ts +2 -2
- package/dist/src/iconDictionary/AlertTriangleFilled.d.ts +2 -2
- package/dist/src/iconDictionary/Anchor.d.ts +2 -2
- package/dist/src/iconDictionary/ArrowDown.d.ts +2 -2
- package/dist/src/iconDictionary/ArrowLeft.d.ts +2 -2
- package/dist/src/iconDictionary/ArrowRight.d.ts +2 -2
- package/dist/src/iconDictionary/ArrowUp.d.ts +2 -2
- package/dist/src/iconDictionary/ArrowUpDown.d.ts +2 -2
- package/dist/src/iconDictionary/Calendar.d.ts +2 -2
- package/dist/src/iconDictionary/Check.d.ts +2 -2
- package/dist/src/iconDictionary/CheckCircleFilled.d.ts +2 -2
- package/dist/src/iconDictionary/ChevronDown.d.ts +2 -2
- package/dist/src/iconDictionary/ChevronUp.d.ts +2 -2
- package/dist/src/iconDictionary/Close.d.ts +2 -2
- package/dist/src/iconDictionary/CloseCircleFilled.d.ts +2 -2
- package/dist/src/iconDictionary/Copy.d.ts +2 -2
- package/dist/src/iconDictionary/Delete.d.ts +2 -2
- package/dist/src/iconDictionary/Download.d.ts +2 -2
- package/dist/src/iconDictionary/DragHandle.d.ts +2 -2
- package/dist/src/iconDictionary/Edit.d.ts +2 -2
- package/dist/src/iconDictionary/ExternalLink.d.ts +2 -2
- package/dist/src/iconDictionary/Eye.d.ts +2 -2
- package/dist/src/iconDictionary/EyeOff.d.ts +2 -2
- package/dist/src/iconDictionary/Filter.d.ts +2 -2
- package/dist/src/iconDictionary/Globe.d.ts +2 -2
- package/dist/src/iconDictionary/Home.d.ts +2 -2
- package/dist/src/iconDictionary/InformationCircle.d.ts +2 -2
- package/dist/src/iconDictionary/InformationCircleFilled.d.ts +2 -2
- package/dist/src/iconDictionary/Notification.d.ts +2 -2
- package/dist/src/iconDictionary/OverflowVertical.d.ts +2 -2
- package/dist/src/iconDictionary/QuestionCircle.d.ts +2 -2
- package/dist/src/iconDictionary/QuestionCircleFilled.d.ts +2 -2
- package/dist/src/iconDictionary/Search.d.ts +2 -2
- package/dist/src/iconDictionary/Settings.d.ts +2 -2
- package/dist/src/iconDictionary/Subtract.d.ts +2 -2
- package/dist/src/iconDictionary/User.d.ts +2 -2
- package/dist/src/iconDictionary/UserGroup.d.ts +2 -2
- package/dist/src/iconDictionary/index.d.ts +40 -40
- package/dist/src/index.d.ts +14 -5
- 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 +249 -136
- 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 +141 -0
- package/src/Banner.tsx +21 -21
- package/src/Button.tsx +95 -0
- package/src/CheckboxGroup.tsx +27 -34
- package/src/Dialog.tsx +110 -0
- package/src/Field.tsx +135 -0
- package/src/FieldError.tsx +34 -0
- package/src/FieldHint.tsx +28 -0
- package/src/FieldLabel.tsx +57 -0
- package/src/Icon.test.tsx +1 -1
- package/src/Icon.tsx +24 -7
- package/src/Infobox.tsx +7 -7
- package/src/Link.tsx +14 -6
- package/src/MenuButton.tsx +10 -6
- package/src/MenuItem.tsx +0 -1
- package/src/MuiPropsChild.tsx +41 -0
- package/src/MuiPropsContext.ts +17 -0
- package/src/OdysseyCacheProvider.test.tsx +1 -1
- package/src/PasswordField.tsx +180 -0
- package/src/RadioGroup.tsx +31 -46
- package/src/SearchField.tsx +138 -0
- package/src/Status.tsx +2 -2
- package/src/Tag.tsx +41 -0
- package/src/TagList.tsx +43 -0
- package/src/TagListContext.tsx +23 -0
- package/src/TextField.tsx +64 -111
- package/src/Toast.tsx +138 -0
- package/src/ToastStack.tsx +33 -0
- package/src/Tooltip.tsx +39 -0
- package/src/iconDictionary/Add.tsx +3 -3
- package/src/iconDictionary/AddCircle.tsx +3 -3
- package/src/iconDictionary/AlertCircle.tsx +3 -3
- package/src/iconDictionary/AlertCircleFilled.tsx +3 -3
- package/src/iconDictionary/AlertTriangleFilled.tsx +3 -3
- package/src/iconDictionary/Anchor.tsx +3 -3
- package/src/iconDictionary/ArrowDown.tsx +3 -3
- package/src/iconDictionary/ArrowLeft.tsx +3 -3
- package/src/iconDictionary/ArrowRight.tsx +3 -3
- package/src/iconDictionary/ArrowUp.tsx +3 -3
- package/src/iconDictionary/ArrowUpDown.tsx +3 -3
- package/src/iconDictionary/Calendar.tsx +3 -3
- package/src/iconDictionary/Check.tsx +3 -3
- package/src/iconDictionary/CheckCircleFilled.tsx +3 -3
- package/src/iconDictionary/ChevronDown.tsx +3 -3
- package/src/iconDictionary/ChevronUp.tsx +3 -3
- package/src/iconDictionary/Close.tsx +3 -3
- package/src/iconDictionary/CloseCircleFilled.tsx +3 -3
- package/src/iconDictionary/Copy.tsx +3 -3
- package/src/iconDictionary/Delete.tsx +3 -3
- package/src/iconDictionary/Download.tsx +3 -3
- package/src/iconDictionary/DragHandle.tsx +3 -3
- package/src/iconDictionary/Edit.tsx +3 -3
- package/src/iconDictionary/ExternalLink.tsx +3 -3
- package/src/iconDictionary/Eye.tsx +3 -3
- package/src/iconDictionary/EyeOff.tsx +3 -3
- package/src/iconDictionary/Filter.tsx +3 -3
- package/src/iconDictionary/Globe.tsx +3 -3
- package/src/iconDictionary/Home.tsx +3 -3
- package/src/iconDictionary/InformationCircle.tsx +3 -3
- package/src/iconDictionary/InformationCircleFilled.tsx +3 -3
- package/src/iconDictionary/Notification.tsx +3 -3
- package/src/iconDictionary/OverflowVertical.tsx +3 -3
- package/src/iconDictionary/QuestionCircle.tsx +3 -3
- package/src/iconDictionary/QuestionCircleFilled.tsx +3 -3
- package/src/iconDictionary/Search.tsx +3 -3
- package/src/iconDictionary/Settings.tsx +2 -2
- package/src/iconDictionary/Subtract.tsx +3 -3
- package/src/iconDictionary/User.tsx +3 -3
- package/src/iconDictionary/UserGroup.tsx +3 -3
- package/src/iconDictionary/index.ts +1 -1
- package/src/index.ts +10 -14
- package/src/theme/components.tsx +119 -27
- 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.23.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.23.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": "46e7484fa0317496e65b9ba8b3f930956b0470e9"
|
|
37
37
|
}
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
onInputChange?: MuiAutocompleteProps<
|
|
66
|
+
OptionType,
|
|
67
|
+
HasMultipleChoices,
|
|
68
|
+
undefined,
|
|
69
|
+
IsCustomValueAllowed
|
|
70
|
+
>["onInputChange"];
|
|
71
|
+
options: MuiAutocompleteProps<
|
|
72
|
+
OptionType,
|
|
73
|
+
HasMultipleChoices,
|
|
74
|
+
undefined,
|
|
75
|
+
IsCustomValueAllowed
|
|
76
|
+
>["options"];
|
|
77
|
+
value?: MuiAutocompleteProps<
|
|
78
|
+
OptionType,
|
|
79
|
+
HasMultipleChoices,
|
|
80
|
+
undefined,
|
|
81
|
+
IsCustomValueAllowed
|
|
82
|
+
>["value"];
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const Autocomplete = <
|
|
86
|
+
OptionType,
|
|
87
|
+
HasMultipleChoices extends boolean | undefined,
|
|
88
|
+
IsCustomValueAllowed extends boolean | undefined
|
|
89
|
+
>({
|
|
90
|
+
isCustomValueAllowed,
|
|
91
|
+
hasMultipleChoices,
|
|
92
|
+
isDisabled,
|
|
93
|
+
isLoading,
|
|
94
|
+
isReadOnly,
|
|
95
|
+
hint,
|
|
96
|
+
label,
|
|
97
|
+
onChange,
|
|
98
|
+
onInputChange,
|
|
99
|
+
options,
|
|
100
|
+
value,
|
|
101
|
+
}: AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>) => {
|
|
102
|
+
const renderInput = useCallback(
|
|
103
|
+
({ InputLabelProps, InputProps, ...params }) => (
|
|
104
|
+
<Field
|
|
105
|
+
fieldType="single"
|
|
106
|
+
hasVisibleLabel
|
|
107
|
+
id={InputLabelProps.htmlFor}
|
|
108
|
+
hint={hint}
|
|
109
|
+
label={label}
|
|
110
|
+
renderFieldComponent={({ ariaDescribedBy, id }) => (
|
|
111
|
+
<InputBase
|
|
112
|
+
{...params}
|
|
113
|
+
{...InputProps}
|
|
114
|
+
aria-describedby={ariaDescribedBy}
|
|
115
|
+
id={id}
|
|
116
|
+
/>
|
|
117
|
+
)}
|
|
118
|
+
/>
|
|
119
|
+
),
|
|
120
|
+
[hint, label]
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<MuiAutocomplete
|
|
125
|
+
disabled={isDisabled}
|
|
126
|
+
freeSolo={isCustomValueAllowed}
|
|
127
|
+
loading={isLoading}
|
|
128
|
+
multiple={hasMultipleChoices}
|
|
129
|
+
onChange={onChange}
|
|
130
|
+
onInputChange={onInputChange}
|
|
131
|
+
options={options}
|
|
132
|
+
readOnly={isReadOnly}
|
|
133
|
+
renderInput={renderInput}
|
|
134
|
+
value={value}
|
|
135
|
+
/>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const MemoizedAutocomplete = memo(Autocomplete) as typeof Autocomplete;
|
|
140
|
+
|
|
141
|
+
export { MemoizedAutocomplete as Autocomplete };
|
package/src/Banner.tsx
CHANGED
|
@@ -14,44 +14,44 @@ import { AlertColor, AlertProps } from "@mui/material";
|
|
|
14
14
|
import { memo } from "react";
|
|
15
15
|
import { Alert, Link, ScreenReaderText } from "./";
|
|
16
16
|
|
|
17
|
-
export
|
|
17
|
+
export type BannerProps = {
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Sets the ARIA role of the alert
|
|
24
|
-
* ("status" for something that dynamically updates, "alert" for errors, null for something
|
|
25
|
-
* unchanging)
|
|
19
|
+
* If linkUrl is not undefined, this is the text of the link.
|
|
20
|
+
* If left blank, it defaults to "Learn more".
|
|
21
|
+
* Note that linkText does nothing if linkUrl is not defined
|
|
26
22
|
*/
|
|
27
|
-
|
|
23
|
+
linkText?: string;
|
|
28
24
|
/**
|
|
29
|
-
*
|
|
25
|
+
* If defined, the alert will include a link to the URL
|
|
30
26
|
*/
|
|
31
|
-
|
|
27
|
+
linkUrl?: string;
|
|
32
28
|
/**
|
|
33
29
|
* The function that's fired when the user clicks the close button. If undefined,
|
|
34
30
|
* the close button will not be shown.
|
|
35
31
|
*/
|
|
36
32
|
onClose?: AlertProps["onClose"];
|
|
37
33
|
/**
|
|
38
|
-
*
|
|
34
|
+
* Sets the ARIA role of the alert
|
|
35
|
+
* ("status" for something that dynamically updates, "alert" for errors, null for something
|
|
36
|
+
* unchanging)
|
|
39
37
|
*/
|
|
40
|
-
|
|
38
|
+
role?: "status" | "alert";
|
|
41
39
|
/**
|
|
42
|
-
*
|
|
43
|
-
* If left blank, it defaults to "Learn more".
|
|
44
|
-
* Note that linkText does nothing if linkUrl is not defined
|
|
40
|
+
* Determine the color and icon of the alert
|
|
45
41
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
severity: AlertColor;
|
|
43
|
+
/**
|
|
44
|
+
* The text content of the alert
|
|
45
|
+
*/
|
|
46
|
+
text: string;
|
|
47
|
+
};
|
|
48
48
|
|
|
49
49
|
const Banner = ({
|
|
50
|
-
onClose,
|
|
51
|
-
severity,
|
|
52
|
-
role,
|
|
53
50
|
linkUrl,
|
|
54
51
|
linkText,
|
|
52
|
+
onClose,
|
|
53
|
+
role,
|
|
54
|
+
severity,
|
|
55
55
|
text,
|
|
56
56
|
}: BannerProps) => (
|
|
57
57
|
<Alert onClose={onClose} role={role} severity={severity} variant="banner">
|
package/src/Button.tsx
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
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 { memo, ReactElement, useContext, useMemo } from "react";
|
|
16
|
+
|
|
17
|
+
import { Icon } from "./Icon";
|
|
18
|
+
import { MuiPropsContext } from "./MuiPropsContext";
|
|
19
|
+
import { Tooltip } from "./Tooltip";
|
|
20
|
+
|
|
21
|
+
export type ButtonProps = {
|
|
22
|
+
endIcon?: ReactElement<typeof Icon>;
|
|
23
|
+
id?: string;
|
|
24
|
+
isDisabled?: boolean;
|
|
25
|
+
isFullWidth?: boolean;
|
|
26
|
+
onClick?: MuiButtonProps["onClick"];
|
|
27
|
+
size?: MuiButtonProps["size"];
|
|
28
|
+
startIcon?: ReactElement<typeof Icon>;
|
|
29
|
+
text?: string;
|
|
30
|
+
/**
|
|
31
|
+
* `tooltipText` determines the text of the tooltip that wraps the button if it's icon-only.
|
|
32
|
+
*/
|
|
33
|
+
tooltipText?: string;
|
|
34
|
+
variant?: "primary" | "secondary" | "danger" | "floating";
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const Button = ({
|
|
38
|
+
endIcon,
|
|
39
|
+
id,
|
|
40
|
+
isDisabled,
|
|
41
|
+
isFullWidth,
|
|
42
|
+
onClick,
|
|
43
|
+
size = "medium",
|
|
44
|
+
startIcon,
|
|
45
|
+
text,
|
|
46
|
+
tooltipText,
|
|
47
|
+
variant,
|
|
48
|
+
}: ButtonProps) => {
|
|
49
|
+
const muiProps = useContext(MuiPropsContext);
|
|
50
|
+
|
|
51
|
+
const button = useMemo(
|
|
52
|
+
() => (
|
|
53
|
+
<MuiButton
|
|
54
|
+
{...muiProps}
|
|
55
|
+
disabled={isDisabled}
|
|
56
|
+
endIcon={endIcon}
|
|
57
|
+
fullWidth={isFullWidth}
|
|
58
|
+
id={id}
|
|
59
|
+
onClick={onClick}
|
|
60
|
+
size={size}
|
|
61
|
+
startIcon={startIcon}
|
|
62
|
+
variant={variant}
|
|
63
|
+
>
|
|
64
|
+
{text}
|
|
65
|
+
</MuiButton>
|
|
66
|
+
),
|
|
67
|
+
[
|
|
68
|
+
endIcon,
|
|
69
|
+
id,
|
|
70
|
+
isDisabled,
|
|
71
|
+
isFullWidth,
|
|
72
|
+
muiProps,
|
|
73
|
+
onClick,
|
|
74
|
+
size,
|
|
75
|
+
startIcon,
|
|
76
|
+
text,
|
|
77
|
+
variant,
|
|
78
|
+
]
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<>
|
|
83
|
+
{tooltipText && (
|
|
84
|
+
<Tooltip ariaType="description" placement="top" text={tooltipText}>
|
|
85
|
+
{button}
|
|
86
|
+
</Tooltip>
|
|
87
|
+
)}
|
|
88
|
+
{!tooltipText && button}
|
|
89
|
+
</>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const MemoizedButton = memo(Button);
|
|
94
|
+
|
|
95
|
+
export { MemoizedButton as Button };
|
package/src/CheckboxGroup.tsx
CHANGED
|
@@ -10,16 +10,11 @@
|
|
|
10
10
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { FormGroup as MuiFormGroup } from "@mui/material";
|
|
14
|
+
import { memo, ReactElement, useCallback } from "react";
|
|
14
15
|
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
FormControl,
|
|
18
|
-
FormGroup,
|
|
19
|
-
FormHelperText,
|
|
20
|
-
FormLabel,
|
|
21
|
-
ScreenReaderText,
|
|
22
|
-
} from ".";
|
|
16
|
+
import { Checkbox } from "./Checkbox";
|
|
17
|
+
import { Field } from "./Field";
|
|
23
18
|
|
|
24
19
|
export type CheckboxGroupProps = {
|
|
25
20
|
children:
|
|
@@ -27,9 +22,12 @@ export type CheckboxGroupProps = {
|
|
|
27
22
|
| Array<ReactElement<typeof Checkbox>>;
|
|
28
23
|
errorMessage?: string;
|
|
29
24
|
hint?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The id of the `input` element. This will also be the input's `name` field.
|
|
27
|
+
*/
|
|
28
|
+
id?: string;
|
|
30
29
|
isDisabled?: boolean;
|
|
31
|
-
label
|
|
32
|
-
name?: string;
|
|
30
|
+
label: string;
|
|
33
31
|
};
|
|
34
32
|
|
|
35
33
|
const CheckboxGroup = ({
|
|
@@ -37,34 +35,29 @@ const CheckboxGroup = ({
|
|
|
37
35
|
isDisabled,
|
|
38
36
|
errorMessage,
|
|
39
37
|
hint,
|
|
38
|
+
id: idOverride,
|
|
40
39
|
label,
|
|
41
|
-
name,
|
|
42
40
|
}: CheckboxGroupProps) => {
|
|
43
|
-
const
|
|
44
|
-
() =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
[errorMessage, hint, name]
|
|
41
|
+
const renderFieldComponent = useCallback(
|
|
42
|
+
({ ariaDescribedBy, id }) => (
|
|
43
|
+
<MuiFormGroup aria-describedby={ariaDescribedBy} id={id}>
|
|
44
|
+
{children}
|
|
45
|
+
</MuiFormGroup>
|
|
46
|
+
),
|
|
47
|
+
[children]
|
|
51
48
|
);
|
|
52
49
|
|
|
53
50
|
return (
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
<ScreenReaderText>Error:</ScreenReaderText> {errorMessage}
|
|
65
|
-
</FormHelperText>
|
|
66
|
-
)}
|
|
67
|
-
</FormControl>
|
|
51
|
+
<Field
|
|
52
|
+
errorMessage={errorMessage}
|
|
53
|
+
fieldType="group"
|
|
54
|
+
hasVisibleLabel={false}
|
|
55
|
+
hint={hint}
|
|
56
|
+
id={idOverride}
|
|
57
|
+
isDisabled={isDisabled}
|
|
58
|
+
label={label}
|
|
59
|
+
renderFieldComponent={renderFieldComponent}
|
|
60
|
+
/>
|
|
68
61
|
);
|
|
69
62
|
};
|
|
70
63
|
|
package/src/Dialog.tsx
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
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 { Dialog as MuiDialog } from "@mui/material";
|
|
14
|
+
import {
|
|
15
|
+
DialogTitle,
|
|
16
|
+
DialogContent,
|
|
17
|
+
DialogContentText,
|
|
18
|
+
DialogActions,
|
|
19
|
+
} from "@mui/material";
|
|
20
|
+
import { Button, CloseIcon } from "./";
|
|
21
|
+
import {
|
|
22
|
+
memo,
|
|
23
|
+
ReactNode,
|
|
24
|
+
useState,
|
|
25
|
+
useEffect,
|
|
26
|
+
useRef,
|
|
27
|
+
ReactElement,
|
|
28
|
+
} from "react";
|
|
29
|
+
|
|
30
|
+
export type DialogProps = {
|
|
31
|
+
callToActionPrimaryComponent?: ReactElement<typeof Button>;
|
|
32
|
+
callToActionSecondaryComponent?: ReactElement<typeof Button>;
|
|
33
|
+
callToActionTertiaryComponent?: ReactElement<typeof Button>;
|
|
34
|
+
children: ReactNode | Array<ReactNode>;
|
|
35
|
+
onClose: () => void;
|
|
36
|
+
isOpen: boolean;
|
|
37
|
+
title: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const Dialog = ({
|
|
41
|
+
callToActionPrimaryComponent,
|
|
42
|
+
callToActionSecondaryComponent,
|
|
43
|
+
callToActionTertiaryComponent,
|
|
44
|
+
children,
|
|
45
|
+
isOpen,
|
|
46
|
+
onClose,
|
|
47
|
+
title,
|
|
48
|
+
}: DialogProps) => {
|
|
49
|
+
const [isContentScrollable, setIsContentScrollable] = useState(false);
|
|
50
|
+
const dialogContentRef = useRef<HTMLDivElement>(null);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
let frameId: number;
|
|
54
|
+
|
|
55
|
+
const handleContentScroll = () => {
|
|
56
|
+
const dialogContentElement = dialogContentRef.current;
|
|
57
|
+
if (dialogContentElement) {
|
|
58
|
+
setIsContentScrollable(
|
|
59
|
+
dialogContentElement.scrollHeight > dialogContentElement.clientHeight
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
frameId = requestAnimationFrame(handleContentScroll);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (isOpen) {
|
|
66
|
+
frameId = requestAnimationFrame(handleContentScroll);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return () => {
|
|
70
|
+
cancelAnimationFrame(frameId);
|
|
71
|
+
};
|
|
72
|
+
}, [isOpen]);
|
|
73
|
+
|
|
74
|
+
const content =
|
|
75
|
+
typeof children === "string" ? (
|
|
76
|
+
<DialogContentText>{children}</DialogContentText>
|
|
77
|
+
) : (
|
|
78
|
+
children
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<MuiDialog open={isOpen} onClose={onClose}>
|
|
83
|
+
<DialogTitle>
|
|
84
|
+
{title}
|
|
85
|
+
<Button
|
|
86
|
+
variant="floating"
|
|
87
|
+
onClick={onClose}
|
|
88
|
+
startIcon={<CloseIcon />}
|
|
89
|
+
/>
|
|
90
|
+
</DialogTitle>
|
|
91
|
+
<DialogContent dividers={isContentScrollable} ref={dialogContentRef}>
|
|
92
|
+
{content}
|
|
93
|
+
</DialogContent>
|
|
94
|
+
|
|
95
|
+
{(callToActionPrimaryComponent ||
|
|
96
|
+
callToActionSecondaryComponent ||
|
|
97
|
+
callToActionTertiaryComponent) && (
|
|
98
|
+
<DialogActions>
|
|
99
|
+
{callToActionTertiaryComponent}
|
|
100
|
+
{callToActionSecondaryComponent}
|
|
101
|
+
{callToActionPrimaryComponent}
|
|
102
|
+
</DialogActions>
|
|
103
|
+
)}
|
|
104
|
+
</MuiDialog>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const MemoizedDialog = memo(Dialog);
|
|
109
|
+
|
|
110
|
+
export { MemoizedDialog as Dialog };
|
package/src/Field.tsx
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
FormControl as MuiFormControl,
|
|
17
|
+
FormLabel as MuiFormLabel,
|
|
18
|
+
} from "@mui/material";
|
|
19
|
+
import { FieldError } from "./FieldError";
|
|
20
|
+
import { FieldHint } from "./FieldHint";
|
|
21
|
+
import { FieldLabel } from "./FieldLabel";
|
|
22
|
+
import { useUniqueId } from "./useUniqueId";
|
|
23
|
+
|
|
24
|
+
export type FieldProps = {
|
|
25
|
+
/**
|
|
26
|
+
* If `error` is not undefined, the `input` will indicate an error.
|
|
27
|
+
*/
|
|
28
|
+
errorMessage?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The field type determines how ARIA components are setup. It's important to use this to denote if you expect only one component (like a text field) or multiple (like a radio group).
|
|
31
|
+
*/
|
|
32
|
+
fieldType: "single" | "group";
|
|
33
|
+
hasVisibleLabel: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The helper text content.
|
|
36
|
+
*/
|
|
37
|
+
hint?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The id of the `input` element.
|
|
40
|
+
*/
|
|
41
|
+
id?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Important for narrowing down the `fieldset` role to "radiogroup".
|
|
44
|
+
*/
|
|
45
|
+
isRadioGroup?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* If `true`, the component is disabled.
|
|
48
|
+
*/
|
|
49
|
+
isDisabled?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* If `true`, the `input` element is not required.
|
|
52
|
+
*/
|
|
53
|
+
isOptional?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The label for the `input` element.
|
|
56
|
+
*/
|
|
57
|
+
label: string;
|
|
58
|
+
/**
|
|
59
|
+
* The label for the `input` element if the it's not optional
|
|
60
|
+
*/
|
|
61
|
+
optionalLabel?: string;
|
|
62
|
+
/**
|
|
63
|
+
* The short hint displayed in the `input` before the user enters a value.
|
|
64
|
+
*/
|
|
65
|
+
placeholder?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Render-props function that sends back ARIA props to your field component.
|
|
68
|
+
*/
|
|
69
|
+
renderFieldComponent: ({
|
|
70
|
+
ariaDescribedBy,
|
|
71
|
+
id,
|
|
72
|
+
}: {
|
|
73
|
+
ariaDescribedBy?: string;
|
|
74
|
+
id: string;
|
|
75
|
+
}) => ReactElement;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const Field = ({
|
|
79
|
+
errorMessage,
|
|
80
|
+
fieldType,
|
|
81
|
+
hasVisibleLabel,
|
|
82
|
+
hint,
|
|
83
|
+
id: idOverride,
|
|
84
|
+
isDisabled = false,
|
|
85
|
+
isRadioGroup = false,
|
|
86
|
+
isOptional = false,
|
|
87
|
+
label,
|
|
88
|
+
optionalLabel,
|
|
89
|
+
renderFieldComponent,
|
|
90
|
+
}: FieldProps) => {
|
|
91
|
+
const id = useUniqueId(idOverride);
|
|
92
|
+
const hintId = hint ? `${id}-hint` : undefined;
|
|
93
|
+
const errorId = errorMessage ? `${id}-error` : undefined;
|
|
94
|
+
const labelId = `${id}-label`;
|
|
95
|
+
|
|
96
|
+
const ariaDescribedBy = useMemo(
|
|
97
|
+
() => [hintId, errorId].join(" ").trim() || undefined,
|
|
98
|
+
[errorId, hintId]
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<MuiFormControl
|
|
103
|
+
component={fieldType === "group" ? "fieldset" : "div"}
|
|
104
|
+
disabled={isDisabled}
|
|
105
|
+
error={Boolean(errorMessage)}
|
|
106
|
+
role={isRadioGroup ? "radiogroup" : undefined}
|
|
107
|
+
>
|
|
108
|
+
{fieldType === "group" ? (
|
|
109
|
+
<MuiFormLabel component="legend">{label}</MuiFormLabel>
|
|
110
|
+
) : (
|
|
111
|
+
<FieldLabel
|
|
112
|
+
hasVisibleLabel={hasVisibleLabel}
|
|
113
|
+
id={labelId}
|
|
114
|
+
inputId={id}
|
|
115
|
+
isOptional={isOptional}
|
|
116
|
+
optionalText={optionalLabel}
|
|
117
|
+
text={label}
|
|
118
|
+
/>
|
|
119
|
+
)}
|
|
120
|
+
|
|
121
|
+
{hint && <FieldHint id={hintId} text={hint} />}
|
|
122
|
+
|
|
123
|
+
{renderFieldComponent({
|
|
124
|
+
ariaDescribedBy,
|
|
125
|
+
id,
|
|
126
|
+
})}
|
|
127
|
+
|
|
128
|
+
{errorMessage && <FieldError id={errorId} text={errorMessage} />}
|
|
129
|
+
</MuiFormControl>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const MemoizedField = memo(Field);
|
|
134
|
+
|
|
135
|
+
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 };
|