@okta/odyssey-react-mui 0.22.0 → 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 +24 -0
- package/dist/Autocomplete.js +5 -1
- package/dist/Autocomplete.js.map +1 -1
- package/dist/Banner.js +3 -3
- package/dist/Banner.js.map +1 -1
- package/dist/Button.js +8 -8
- package/dist/Button.js.map +1 -1
- 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 +18 -5
- package/dist/Field.js.map +1 -1
- package/dist/FieldLabel.js +3 -3
- package/dist/FieldLabel.js.map +1 -1
- 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 +3 -2
- package/dist/MenuButton.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 +8 -3
- package/dist/PasswordField.js.map +1 -1
- package/dist/RadioGroup.js +25 -26
- package/dist/RadioGroup.js.map +1 -1
- package/dist/SearchField.js +6 -4
- package/dist/SearchField.js.map +1 -1
- package/dist/Status.js.map +1 -1
- package/dist/TextField.js +17 -8
- 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 +5 -4
- package/dist/index.js.map +1 -1
- package/dist/src/Autocomplete.d.ts +2 -1
- package/dist/src/Autocomplete.d.ts.map +1 -1
- package/dist/src/Banner.d.ts +19 -19
- package/dist/src/Banner.d.ts.map +1 -1
- package/dist/src/Button.d.ts +4 -3
- package/dist/src/Button.d.ts.map +1 -1
- 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 +14 -3
- package/dist/src/Field.d.ts.map +1 -1
- package/dist/src/FieldLabel.d.ts +2 -2
- 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/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 +8 -8
- package/dist/src/PasswordField.d.ts.map +1 -1
- package/dist/src/RadioGroup.d.ts +8 -8
- package/dist/src/RadioGroup.d.ts.map +1 -1
- package/dist/src/SearchField.d.ts +4 -4
- package/dist/src/SearchField.d.ts.map +1 -1
- package/dist/src/Status.d.ts +2 -2
- package/dist/src/Status.d.ts.map +1 -1
- package/dist/src/TextField.d.ts +13 -12
- 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 +8 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/theme/components.d.ts.map +1 -1
- package/dist/theme/components.js +32 -12
- package/dist/theme/components.js.map +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Autocomplete.tsx +10 -1
- package/src/Banner.tsx +21 -21
- package/src/Button.tsx +38 -18
- package/src/CheckboxGroup.tsx +27 -34
- package/src/Dialog.tsx +110 -0
- package/src/Field.tsx +42 -19
- package/src/FieldLabel.tsx +7 -7
- 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 +8 -3
- package/src/MuiPropsChild.tsx +41 -0
- package/src/MuiPropsContext.ts +17 -0
- package/src/PasswordField.tsx +17 -11
- package/src/RadioGroup.tsx +31 -46
- package/src/SearchField.tsx +10 -8
- package/src/Status.tsx +2 -2
- package/src/TextField.tsx +32 -21
- 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 +4 -14
- package/src/theme/components.tsx +32 -9
package/src/Link.tsx
CHANGED
|
@@ -12,17 +12,25 @@
|
|
|
12
12
|
|
|
13
13
|
import { forwardRef, ReactElement } from "react";
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
|
|
15
|
+
import {
|
|
16
|
+
Link as MuiLink,
|
|
17
|
+
LinkProps as MuiLinkProps,
|
|
18
|
+
SvgIcon,
|
|
19
|
+
} from "@mui/material";
|
|
17
20
|
|
|
18
|
-
export
|
|
21
|
+
export type LinkProps = {
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
href: string;
|
|
19
24
|
icon?: ReactElement;
|
|
20
|
-
|
|
25
|
+
rel?: string;
|
|
26
|
+
target?: "_self" | "_blank" | "_parent" | "_top" | string;
|
|
27
|
+
variant?: MuiLinkProps["variant"];
|
|
28
|
+
};
|
|
21
29
|
|
|
22
30
|
export const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {
|
|
23
|
-
const { icon, children, target } = props;
|
|
31
|
+
const { icon, children, target, variant } = props;
|
|
24
32
|
return (
|
|
25
|
-
<MuiLink {
|
|
33
|
+
<MuiLink ref={ref} variant={variant} target={target}>
|
|
26
34
|
{icon && <span className="Link-icon">{icon}</span>}
|
|
27
35
|
{children}
|
|
28
36
|
{target === "_blank" && (
|
package/src/MenuButton.tsx
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./";
|
|
23
23
|
import { memo, MouseEvent, ReactElement, useMemo, useState } from "react";
|
|
24
24
|
|
|
25
|
-
export
|
|
25
|
+
export type MenuButtonProps = {
|
|
26
26
|
/**
|
|
27
27
|
* The <MenuItem> components within the Menu.
|
|
28
28
|
*/
|
|
@@ -41,13 +41,18 @@ export interface MenuButtonProps {
|
|
|
41
41
|
* The variant of the triggering Button
|
|
42
42
|
*/
|
|
43
43
|
buttonVariant?: ButtonProps["variant"];
|
|
44
|
-
|
|
44
|
+
/**
|
|
45
|
+
* The id of the `input` element.
|
|
46
|
+
*/
|
|
47
|
+
id?: string;
|
|
48
|
+
};
|
|
45
49
|
|
|
46
50
|
const MenuButton = ({
|
|
47
51
|
buttonLabel = "",
|
|
48
52
|
children,
|
|
49
53
|
buttonEndIcon = <ChevronDownIcon />,
|
|
50
54
|
buttonVariant = "secondary",
|
|
55
|
+
id: idOverride,
|
|
51
56
|
}: MenuButtonProps) => {
|
|
52
57
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
53
58
|
|
|
@@ -61,7 +66,7 @@ const MenuButton = ({
|
|
|
61
66
|
setAnchorEl(null);
|
|
62
67
|
};
|
|
63
68
|
|
|
64
|
-
const uniqueId = useUniqueId();
|
|
69
|
+
const uniqueId = useUniqueId(idOverride);
|
|
65
70
|
|
|
66
71
|
const menuListProps = useMemo(
|
|
67
72
|
() => ({ "aria-labelledby": `${uniqueId}-button` }),
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { forwardRef, memo, ReactNode, useMemo } from "react";
|
|
14
|
+
|
|
15
|
+
import { MuiPropsContext, MuiPropsContextType } from "./MuiPropsContext";
|
|
16
|
+
|
|
17
|
+
export type MuiPropsChildProps = {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const MuiPropsChild = forwardRef<HTMLElement, MuiPropsChildProps>(
|
|
22
|
+
({ children, ...muiProps }, ref) => {
|
|
23
|
+
const providerValue = useMemo<MuiPropsContextType>(
|
|
24
|
+
() => ({
|
|
25
|
+
...muiProps,
|
|
26
|
+
ref,
|
|
27
|
+
}),
|
|
28
|
+
[muiProps, ref]
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<MuiPropsContext.Provider value={providerValue}>
|
|
33
|
+
{children}
|
|
34
|
+
</MuiPropsContext.Provider>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const MemoizedMuiPropsChild = memo(MuiPropsChild);
|
|
40
|
+
|
|
41
|
+
export { MemoizedMuiPropsChild as MuiPropsChild };
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { createContext } from "react";
|
|
14
|
+
|
|
15
|
+
export type MuiPropsContextType = Record<string, unknown>;
|
|
16
|
+
|
|
17
|
+
export const MuiPropsContext = createContext<MuiPropsContextType>({});
|
package/src/PasswordField.tsx
CHANGED
|
@@ -24,10 +24,6 @@ import { EyeIcon, EyeOffIcon, IconButton } from "./";
|
|
|
24
24
|
import { Field } from "./Field";
|
|
25
25
|
|
|
26
26
|
export type PasswordFieldProps = {
|
|
27
|
-
/**
|
|
28
|
-
* If `true`, the component will receive focus automatically.
|
|
29
|
-
*/
|
|
30
|
-
autoFocus?: boolean;
|
|
31
27
|
/**
|
|
32
28
|
* This prop helps users to fill forms faster, especially on mobile devices.
|
|
33
29
|
* The name can be confusing, as it's more like an autofill.
|
|
@@ -38,6 +34,10 @@ export type PasswordFieldProps = {
|
|
|
38
34
|
* If `error` is not undefined, the `input` will indicate an error.
|
|
39
35
|
*/
|
|
40
36
|
errorMessage?: string;
|
|
37
|
+
/**
|
|
38
|
+
* If `true`, the component will receive focus automatically.
|
|
39
|
+
*/
|
|
40
|
+
hasInitialFocus?: boolean;
|
|
41
41
|
/**
|
|
42
42
|
* The helper text content.
|
|
43
43
|
*/
|
|
@@ -51,13 +51,13 @@ export type PasswordFieldProps = {
|
|
|
51
51
|
*/
|
|
52
52
|
isDisabled?: boolean;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* If `true`, the `input` element is not required.
|
|
55
55
|
*/
|
|
56
|
-
|
|
56
|
+
isOptional?: boolean;
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* It prevents the user from changing the value of the field
|
|
59
59
|
*/
|
|
60
|
-
|
|
60
|
+
isReadOnly?: boolean;
|
|
61
61
|
/**
|
|
62
62
|
* The label for the `input` element.
|
|
63
63
|
*/
|
|
@@ -88,11 +88,12 @@ const PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(
|
|
|
88
88
|
(
|
|
89
89
|
{
|
|
90
90
|
autoCompleteType,
|
|
91
|
-
autoFocus,
|
|
92
91
|
errorMessage,
|
|
92
|
+
hasInitialFocus,
|
|
93
93
|
hint,
|
|
94
94
|
id: idOverride,
|
|
95
95
|
isDisabled = false,
|
|
96
|
+
isOptional = false,
|
|
96
97
|
isReadOnly,
|
|
97
98
|
label,
|
|
98
99
|
onChange,
|
|
@@ -117,7 +118,7 @@ const PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(
|
|
|
117
118
|
aria-describedby={ariaDescribedBy}
|
|
118
119
|
autoComplete={autoCompleteType}
|
|
119
120
|
/* eslint-disable-next-line jsx-a11y/no-autofocus */
|
|
120
|
-
autoFocus={
|
|
121
|
+
autoFocus={hasInitialFocus}
|
|
121
122
|
endAdornment={
|
|
122
123
|
<InputAdornment position="end">
|
|
123
124
|
<IconButton
|
|
@@ -130,25 +131,28 @@ const PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(
|
|
|
130
131
|
</InputAdornment>
|
|
131
132
|
}
|
|
132
133
|
id={id}
|
|
134
|
+
name={id}
|
|
133
135
|
onChange={onChange}
|
|
134
136
|
onFocus={onFocus}
|
|
135
137
|
onBlur={onBlur}
|
|
136
138
|
placeholder={placeholder}
|
|
137
139
|
readOnly={isReadOnly}
|
|
138
140
|
ref={ref}
|
|
141
|
+
required={!isOptional}
|
|
139
142
|
type={inputType}
|
|
140
143
|
value={value}
|
|
141
144
|
/>
|
|
142
145
|
),
|
|
143
146
|
[
|
|
144
147
|
autoCompleteType,
|
|
145
|
-
|
|
148
|
+
hasInitialFocus,
|
|
146
149
|
togglePasswordVisibility,
|
|
147
150
|
inputType,
|
|
148
151
|
onChange,
|
|
149
152
|
onFocus,
|
|
150
153
|
onBlur,
|
|
151
154
|
placeholder,
|
|
155
|
+
isOptional,
|
|
152
156
|
isReadOnly,
|
|
153
157
|
ref,
|
|
154
158
|
value,
|
|
@@ -158,10 +162,12 @@ const PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(
|
|
|
158
162
|
return (
|
|
159
163
|
<Field
|
|
160
164
|
errorMessage={errorMessage}
|
|
165
|
+
fieldType="single"
|
|
161
166
|
hasVisibleLabel
|
|
162
167
|
hint={hint}
|
|
163
168
|
id={idOverride}
|
|
164
169
|
isDisabled={isDisabled}
|
|
170
|
+
isOptional={isOptional}
|
|
165
171
|
label={label}
|
|
166
172
|
renderFieldComponent={renderFieldComponent}
|
|
167
173
|
/>
|
package/src/RadioGroup.tsx
CHANGED
|
@@ -11,19 +11,12 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { RadioGroup as MuiRadioGroup } from "@mui/material";
|
|
14
|
-
import { ChangeEventHandler, memo, ReactElement,
|
|
14
|
+
import { ChangeEventHandler, memo, ReactElement, useCallback } from "react";
|
|
15
15
|
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
FormLabel,
|
|
19
|
-
FormHelperText,
|
|
20
|
-
Radio,
|
|
21
|
-
ScreenReaderText,
|
|
22
|
-
useUniqueId,
|
|
23
|
-
RadioProps,
|
|
24
|
-
} from ".";
|
|
16
|
+
import { Radio, RadioProps } from "./Radio";
|
|
17
|
+
import { Field } from "./Field";
|
|
25
18
|
|
|
26
|
-
export
|
|
19
|
+
export type RadioGroupProps = {
|
|
27
20
|
/**
|
|
28
21
|
* The <Radio> components within the group. Must include two or more.
|
|
29
22
|
*/
|
|
@@ -40,6 +33,10 @@ export interface RadioGroupProps {
|
|
|
40
33
|
* Optional hint text
|
|
41
34
|
*/
|
|
42
35
|
hint?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The id of the `input` element. This will also be the input's `name` field.
|
|
38
|
+
*/
|
|
39
|
+
id?: string;
|
|
43
40
|
/**
|
|
44
41
|
* Disables the whole radio group
|
|
45
42
|
*/
|
|
@@ -48,10 +45,6 @@ export interface RadioGroupProps {
|
|
|
48
45
|
* The text label for the radio group
|
|
49
46
|
*/
|
|
50
47
|
label: string;
|
|
51
|
-
/**
|
|
52
|
-
* The name of the radio group, which only needs to be changed if there are multiple radio groups on the same screen
|
|
53
|
-
*/
|
|
54
|
-
name?: string;
|
|
55
48
|
/**
|
|
56
49
|
* Listen for changes in the browser that change `value`.
|
|
57
50
|
*/
|
|
@@ -60,54 +53,46 @@ export interface RadioGroupProps {
|
|
|
60
53
|
* The `value` on the selected radio button.
|
|
61
54
|
*/
|
|
62
55
|
value?: RadioProps["value"];
|
|
63
|
-
}
|
|
56
|
+
};
|
|
64
57
|
|
|
65
58
|
const RadioGroup = ({
|
|
66
59
|
children,
|
|
67
60
|
defaultValue,
|
|
68
61
|
errorMessage,
|
|
69
62
|
hint,
|
|
63
|
+
id: idOverride,
|
|
70
64
|
isDisabled,
|
|
71
65
|
label,
|
|
72
|
-
name,
|
|
73
66
|
onChange,
|
|
67
|
+
value,
|
|
74
68
|
}: RadioGroupProps) => {
|
|
75
|
-
const
|
|
76
|
-
() =>
|
|
77
|
-
errorMessage || hint
|
|
78
|
-
? [hint && `${name}-hint`, errorMessage && `${name}-error`]
|
|
79
|
-
.filter(Boolean)
|
|
80
|
-
.join(" ")
|
|
81
|
-
: undefined,
|
|
82
|
-
[errorMessage, hint, name]
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const uniqueName = useUniqueId(name);
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<FormControl
|
|
89
|
-
component="fieldset"
|
|
90
|
-
disabled={isDisabled}
|
|
91
|
-
error={Boolean(errorMessage)}
|
|
92
|
-
>
|
|
93
|
-
<FormLabel component="legend">{label}</FormLabel>
|
|
94
|
-
{hint && (
|
|
95
|
-
<FormHelperText id={`${uniqueName}-hint`}>{hint}</FormHelperText>
|
|
96
|
-
)}
|
|
69
|
+
const renderFieldComponent = useCallback(
|
|
70
|
+
({ ariaDescribedBy, id }) => (
|
|
97
71
|
<MuiRadioGroup
|
|
98
72
|
aria-describedby={ariaDescribedBy}
|
|
99
73
|
defaultValue={defaultValue}
|
|
100
|
-
|
|
74
|
+
id={id}
|
|
75
|
+
name={id}
|
|
101
76
|
onChange={onChange}
|
|
77
|
+
value={value}
|
|
102
78
|
>
|
|
103
79
|
{children}
|
|
104
80
|
</MuiRadioGroup>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
81
|
+
),
|
|
82
|
+
[children, defaultValue, onChange, value]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Field
|
|
87
|
+
errorMessage={errorMessage}
|
|
88
|
+
fieldType="group"
|
|
89
|
+
hasVisibleLabel={false}
|
|
90
|
+
hint={hint}
|
|
91
|
+
id={idOverride}
|
|
92
|
+
isDisabled={isDisabled}
|
|
93
|
+
label={label}
|
|
94
|
+
renderFieldComponent={renderFieldComponent}
|
|
95
|
+
/>
|
|
111
96
|
);
|
|
112
97
|
};
|
|
113
98
|
|
package/src/SearchField.tsx
CHANGED
|
@@ -24,16 +24,16 @@ import { SearchIcon } from "./";
|
|
|
24
24
|
import { Field } from "./Field";
|
|
25
25
|
|
|
26
26
|
export type SearchFieldProps = {
|
|
27
|
-
/**
|
|
28
|
-
* If `true`, the component will receive focus automatically.
|
|
29
|
-
*/
|
|
30
|
-
autoFocus?: boolean;
|
|
31
27
|
/**
|
|
32
28
|
* This prop helps users to fill forms faster, especially on mobile devices.
|
|
33
29
|
* The name can be confusing, as it's more like an autofill.
|
|
34
30
|
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
|
|
35
31
|
*/
|
|
36
32
|
autoCompleteType?: InputHTMLAttributes<HTMLInputElement>["autoComplete"];
|
|
33
|
+
/**
|
|
34
|
+
* If `true`, the component will receive focus automatically.
|
|
35
|
+
*/
|
|
36
|
+
hasInitialFocus?: boolean;
|
|
37
37
|
/**
|
|
38
38
|
* The id of the `input` element.
|
|
39
39
|
*/
|
|
@@ -72,7 +72,7 @@ const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(
|
|
|
72
72
|
(
|
|
73
73
|
{
|
|
74
74
|
autoCompleteType,
|
|
75
|
-
|
|
75
|
+
hasInitialFocus,
|
|
76
76
|
id: idOverride,
|
|
77
77
|
isDisabled = false,
|
|
78
78
|
label,
|
|
@@ -90,8 +90,9 @@ const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(
|
|
|
90
90
|
aria-describedby={ariaDescribedBy}
|
|
91
91
|
autoComplete={autoCompleteType}
|
|
92
92
|
/* eslint-disable-next-line jsx-a11y/no-autofocus */
|
|
93
|
-
autoFocus={
|
|
93
|
+
autoFocus={hasInitialFocus}
|
|
94
94
|
id={id}
|
|
95
|
+
name={id}
|
|
95
96
|
onChange={onChange}
|
|
96
97
|
onFocus={onFocus}
|
|
97
98
|
onBlur={onBlur}
|
|
@@ -108,7 +109,7 @@ const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(
|
|
|
108
109
|
),
|
|
109
110
|
[
|
|
110
111
|
autoCompleteType,
|
|
111
|
-
|
|
112
|
+
hasInitialFocus,
|
|
112
113
|
onChange,
|
|
113
114
|
onFocus,
|
|
114
115
|
onBlur,
|
|
@@ -120,10 +121,11 @@ const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(
|
|
|
120
121
|
|
|
121
122
|
return (
|
|
122
123
|
<Field
|
|
124
|
+
fieldType="single"
|
|
123
125
|
hasVisibleLabel={false}
|
|
124
126
|
id={idOverride}
|
|
125
127
|
isDisabled={isDisabled}
|
|
126
|
-
|
|
128
|
+
isOptional={true}
|
|
127
129
|
label={label}
|
|
128
130
|
renderFieldComponent={renderFieldComponent}
|
|
129
131
|
/>
|
package/src/Status.tsx
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { Chip } from "./";
|
|
14
14
|
|
|
15
|
-
export
|
|
15
|
+
export type StatusProps = {
|
|
16
16
|
/**
|
|
17
17
|
* Determine the color and icon of the alert
|
|
18
18
|
*/
|
|
@@ -22,7 +22,7 @@ export interface StatusProps {
|
|
|
22
22
|
* The text content of the status
|
|
23
23
|
*/
|
|
24
24
|
label: string;
|
|
25
|
-
}
|
|
25
|
+
};
|
|
26
26
|
|
|
27
27
|
export const Status = ({ severity, label }: StatusProps) => (
|
|
28
28
|
<Chip label={label} color={severity} variant="status" />
|
package/src/TextField.tsx
CHANGED
|
@@ -10,24 +10,21 @@
|
|
|
10
10
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { InputBase } from "@mui/material";
|
|
13
|
+
import { InputAdornment, InputBase } from "@mui/material";
|
|
14
14
|
import {
|
|
15
15
|
ChangeEventHandler,
|
|
16
16
|
FocusEventHandler,
|
|
17
17
|
forwardRef,
|
|
18
18
|
InputHTMLAttributes,
|
|
19
19
|
memo,
|
|
20
|
-
|
|
20
|
+
ReactElement,
|
|
21
21
|
useCallback,
|
|
22
22
|
} from "react";
|
|
23
23
|
|
|
24
24
|
import { Field } from "./Field";
|
|
25
|
+
import { Icon } from "./Icon";
|
|
25
26
|
|
|
26
27
|
export type TextFieldProps = {
|
|
27
|
-
/**
|
|
28
|
-
* If `true`, the component will receive focus automatically.
|
|
29
|
-
*/
|
|
30
|
-
autoFocus?: boolean;
|
|
31
28
|
/**
|
|
32
29
|
* This prop helps users to fill forms faster, especially on mobile devices.
|
|
33
30
|
* The name can be confusing, as it's more like an autofill.
|
|
@@ -37,11 +34,15 @@ export type TextFieldProps = {
|
|
|
37
34
|
/**
|
|
38
35
|
* End `InputAdornment` for this component.
|
|
39
36
|
*/
|
|
40
|
-
endAdornment?:
|
|
37
|
+
endAdornment?: string | ReactElement<typeof Icon>;
|
|
41
38
|
/**
|
|
42
39
|
* If `error` is not undefined, the `input` will indicate an error.
|
|
43
40
|
*/
|
|
44
41
|
errorMessage?: string;
|
|
42
|
+
/**
|
|
43
|
+
* If `true`, the component will receive focus automatically.
|
|
44
|
+
*/
|
|
45
|
+
hasInitialFocus?: boolean;
|
|
45
46
|
/**
|
|
46
47
|
* The helper text content.
|
|
47
48
|
*/
|
|
@@ -59,13 +60,13 @@ export type TextFieldProps = {
|
|
|
59
60
|
*/
|
|
60
61
|
isMultiline?: boolean;
|
|
61
62
|
/**
|
|
62
|
-
*
|
|
63
|
+
* If `true`, the `input` element is not required.
|
|
63
64
|
*/
|
|
64
|
-
|
|
65
|
+
isOptional?: boolean;
|
|
65
66
|
/**
|
|
66
|
-
*
|
|
67
|
+
* It prevents the user from changing the value of the field
|
|
67
68
|
*/
|
|
68
|
-
|
|
69
|
+
isReadOnly?: boolean;
|
|
69
70
|
/**
|
|
70
71
|
* The label for the `input` element.
|
|
71
72
|
*/
|
|
@@ -83,7 +84,7 @@ export type TextFieldProps = {
|
|
|
83
84
|
*/
|
|
84
85
|
onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
85
86
|
/**
|
|
86
|
-
* The label for the `input` element if
|
|
87
|
+
* The label for the `input` element if it's optional
|
|
87
88
|
*/
|
|
88
89
|
optionalLabel?: string;
|
|
89
90
|
/**
|
|
@@ -93,7 +94,7 @@ export type TextFieldProps = {
|
|
|
93
94
|
/**
|
|
94
95
|
* Start `InputAdornment` for this component.
|
|
95
96
|
*/
|
|
96
|
-
startAdornment?:
|
|
97
|
+
startAdornment?: string | ReactElement<typeof Icon>;
|
|
97
98
|
/**
|
|
98
99
|
* Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).
|
|
99
100
|
*/
|
|
@@ -108,20 +109,20 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
108
109
|
(
|
|
109
110
|
{
|
|
110
111
|
autoCompleteType,
|
|
111
|
-
|
|
112
|
+
hasInitialFocus,
|
|
112
113
|
endAdornment,
|
|
113
114
|
errorMessage,
|
|
114
115
|
hint,
|
|
115
116
|
id: idOverride,
|
|
116
117
|
isDisabled = false,
|
|
117
118
|
isMultiline = false,
|
|
119
|
+
isOptional = false,
|
|
118
120
|
isReadOnly,
|
|
119
|
-
isRequired = true,
|
|
120
121
|
label,
|
|
121
122
|
onBlur,
|
|
122
123
|
onChange,
|
|
123
124
|
onFocus,
|
|
124
|
-
optionalLabel,
|
|
125
|
+
optionalLabel = "Optional",
|
|
125
126
|
placeholder,
|
|
126
127
|
startAdornment,
|
|
127
128
|
type = "text",
|
|
@@ -135,24 +136,33 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
135
136
|
aria-describedby={ariaDescribedBy}
|
|
136
137
|
autoComplete={autoCompleteType}
|
|
137
138
|
/* eslint-disable-next-line jsx-a11y/no-autofocus */
|
|
138
|
-
autoFocus={
|
|
139
|
-
endAdornment={
|
|
139
|
+
autoFocus={hasInitialFocus}
|
|
140
|
+
endAdornment={
|
|
141
|
+
endAdornment && (
|
|
142
|
+
<InputAdornment position="end">{endAdornment}</InputAdornment>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
140
145
|
id={id}
|
|
141
146
|
multiline={isMultiline}
|
|
147
|
+
name={id}
|
|
142
148
|
onBlur={onBlur}
|
|
143
149
|
onChange={onChange}
|
|
144
150
|
onFocus={onFocus}
|
|
145
151
|
placeholder={placeholder}
|
|
146
152
|
readOnly={isReadOnly}
|
|
147
153
|
ref={ref}
|
|
148
|
-
startAdornment={
|
|
154
|
+
startAdornment={
|
|
155
|
+
startAdornment && (
|
|
156
|
+
<InputAdornment position="start">{startAdornment}</InputAdornment>
|
|
157
|
+
)
|
|
158
|
+
}
|
|
149
159
|
type={type}
|
|
150
160
|
value={value}
|
|
151
161
|
/>
|
|
152
162
|
),
|
|
153
163
|
[
|
|
154
164
|
autoCompleteType,
|
|
155
|
-
|
|
165
|
+
hasInitialFocus,
|
|
156
166
|
endAdornment,
|
|
157
167
|
isMultiline,
|
|
158
168
|
onChange,
|
|
@@ -170,11 +180,12 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
170
180
|
return (
|
|
171
181
|
<Field
|
|
172
182
|
errorMessage={errorMessage}
|
|
183
|
+
fieldType="single"
|
|
173
184
|
hasVisibleLabel
|
|
174
185
|
hint={hint}
|
|
175
186
|
id={idOverride}
|
|
176
187
|
isDisabled={isDisabled}
|
|
177
|
-
|
|
188
|
+
isOptional={isOptional}
|
|
178
189
|
label={label}
|
|
179
190
|
optionalLabel={optionalLabel}
|
|
180
191
|
renderFieldComponent={renderFieldComponent}
|