@okta/odyssey-react-mui 0.17.0 → 0.19.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 +168 -0
- package/README.md +4 -20
- package/dist/Banner.d.ts +47 -0
- package/dist/Banner.d.ts.map +1 -0
- package/dist/Banner.js +41 -0
- package/dist/Banner.js.map +1 -0
- package/dist/Infobox.d.ts +36 -0
- package/dist/Infobox.d.ts.map +1 -0
- package/dist/Infobox.js +36 -0
- package/dist/Infobox.js.map +1 -0
- package/dist/Link.d.ts +1 -1
- package/dist/Link.d.ts.map +1 -1
- package/dist/Link.js +16 -2
- package/dist/Link.js.map +1 -1
- package/dist/OdysseyThemeProvider.d.ts +3 -1
- package/dist/OdysseyThemeProvider.d.ts.map +1 -1
- package/dist/OdysseyThemeProvider.js +7 -4
- package/dist/OdysseyThemeProvider.js.map +1 -1
- package/dist/PasswordInput.d.ts +1 -1
- package/dist/PasswordInput.d.ts.map +1 -1
- package/dist/Radio.d.ts +19 -0
- package/dist/Radio.d.ts.map +1 -0
- package/dist/Radio.js +32 -0
- package/dist/Radio.js.map +1 -0
- package/dist/RadioGroup.d.ts +47 -0
- package/dist/RadioGroup.d.ts.map +1 -0
- package/dist/RadioGroup.js +59 -0
- package/dist/RadioGroup.js.map +1 -0
- package/dist/Status.d.ts +23 -0
- package/dist/Status.d.ts.map +1 -0
- package/dist/Status.js +25 -0
- package/dist/Status.js.map +1 -0
- package/dist/TextField.d.ts +87 -0
- package/dist/TextField.d.ts.map +1 -0
- package/dist/TextField.js +100 -0
- package/dist/TextField.js.map +1 -0
- package/dist/iconDictionary/Add.d.ts +1 -1
- package/dist/iconDictionary/Add.d.ts.map +1 -1
- package/dist/iconDictionary/AddCircle.d.ts +1 -1
- package/dist/iconDictionary/AddCircle.d.ts.map +1 -1
- package/dist/iconDictionary/AlertCircle.d.ts +1 -1
- package/dist/iconDictionary/AlertCircle.d.ts.map +1 -1
- package/dist/iconDictionary/AlertCircleFilled.d.ts +1 -1
- package/dist/iconDictionary/AlertCircleFilled.d.ts.map +1 -1
- package/dist/iconDictionary/AlertTriangleFilled.d.ts +1 -1
- package/dist/iconDictionary/AlertTriangleFilled.d.ts.map +1 -1
- package/dist/iconDictionary/Anchor.d.ts +1 -1
- package/dist/iconDictionary/Anchor.d.ts.map +1 -1
- package/dist/iconDictionary/ArrowDown.d.ts +1 -1
- package/dist/iconDictionary/ArrowDown.d.ts.map +1 -1
- package/dist/iconDictionary/ArrowLeft.d.ts +1 -1
- package/dist/iconDictionary/ArrowLeft.d.ts.map +1 -1
- package/dist/iconDictionary/ArrowRight.d.ts +1 -1
- package/dist/iconDictionary/ArrowRight.d.ts.map +1 -1
- package/dist/iconDictionary/ArrowUp.d.ts +1 -1
- package/dist/iconDictionary/ArrowUp.d.ts.map +1 -1
- package/dist/iconDictionary/ArrowUpDown.d.ts +1 -1
- package/dist/iconDictionary/ArrowUpDown.d.ts.map +1 -1
- package/dist/iconDictionary/Calendar.d.ts +1 -1
- package/dist/iconDictionary/Calendar.d.ts.map +1 -1
- package/dist/iconDictionary/Check.d.ts +1 -1
- package/dist/iconDictionary/Check.d.ts.map +1 -1
- package/dist/iconDictionary/CheckCircleFilled.d.ts +1 -1
- package/dist/iconDictionary/CheckCircleFilled.d.ts.map +1 -1
- package/dist/iconDictionary/ChevronDown.d.ts +1 -1
- package/dist/iconDictionary/ChevronDown.d.ts.map +1 -1
- package/dist/iconDictionary/ChevronUp.d.ts +1 -1
- package/dist/iconDictionary/ChevronUp.d.ts.map +1 -1
- package/dist/iconDictionary/Close.d.ts +1 -1
- package/dist/iconDictionary/Close.d.ts.map +1 -1
- package/dist/iconDictionary/CloseCircleFilled.d.ts +1 -1
- package/dist/iconDictionary/CloseCircleFilled.d.ts.map +1 -1
- package/dist/iconDictionary/Copy.d.ts +1 -1
- package/dist/iconDictionary/Copy.d.ts.map +1 -1
- package/dist/iconDictionary/Delete.d.ts +1 -1
- package/dist/iconDictionary/Delete.d.ts.map +1 -1
- package/dist/iconDictionary/Download.d.ts +1 -1
- package/dist/iconDictionary/Download.d.ts.map +1 -1
- package/dist/iconDictionary/DragHandle.d.ts +1 -1
- package/dist/iconDictionary/DragHandle.d.ts.map +1 -1
- package/dist/iconDictionary/Edit.d.ts +1 -1
- package/dist/iconDictionary/Edit.d.ts.map +1 -1
- package/dist/iconDictionary/ExternalLink.d.ts +1 -1
- package/dist/iconDictionary/ExternalLink.d.ts.map +1 -1
- package/dist/iconDictionary/Eye.d.ts +1 -1
- package/dist/iconDictionary/Eye.d.ts.map +1 -1
- package/dist/iconDictionary/EyeOff.d.ts +1 -1
- package/dist/iconDictionary/EyeOff.d.ts.map +1 -1
- package/dist/iconDictionary/Filter.d.ts +1 -1
- package/dist/iconDictionary/Filter.d.ts.map +1 -1
- package/dist/iconDictionary/Globe.d.ts +1 -1
- package/dist/iconDictionary/Globe.d.ts.map +1 -1
- package/dist/iconDictionary/Home.d.ts +1 -1
- package/dist/iconDictionary/Home.d.ts.map +1 -1
- package/dist/iconDictionary/InformationCircle.d.ts +1 -1
- package/dist/iconDictionary/InformationCircle.d.ts.map +1 -1
- package/dist/iconDictionary/InformationCircleFilled.d.ts +1 -1
- package/dist/iconDictionary/InformationCircleFilled.d.ts.map +1 -1
- package/dist/iconDictionary/Notification.d.ts +1 -1
- package/dist/iconDictionary/Notification.d.ts.map +1 -1
- package/dist/iconDictionary/OverflowVertical.d.ts +1 -1
- package/dist/iconDictionary/OverflowVertical.d.ts.map +1 -1
- package/dist/iconDictionary/QuestionCircle.d.ts +1 -1
- package/dist/iconDictionary/QuestionCircle.d.ts.map +1 -1
- package/dist/iconDictionary/QuestionCircleFilled.d.ts +1 -1
- package/dist/iconDictionary/QuestionCircleFilled.d.ts.map +1 -1
- package/dist/iconDictionary/Search.d.ts +1 -1
- package/dist/iconDictionary/Search.d.ts.map +1 -1
- package/dist/iconDictionary/Settings.d.ts +1 -1
- package/dist/iconDictionary/Settings.d.ts.map +1 -1
- package/dist/iconDictionary/Subtract.d.ts +1 -1
- package/dist/iconDictionary/Subtract.d.ts.map +1 -1
- package/dist/iconDictionary/User.d.ts +1 -1
- package/dist/iconDictionary/User.d.ts.map +1 -1
- package/dist/iconDictionary/UserGroup.d.ts +1 -1
- package/dist/iconDictionary/UserGroup.d.ts.map +1 -1
- package/dist/index.d.ts +12 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/theme/components.d.ts.map +1 -1
- package/dist/theme/components.js +578 -179
- package/dist/theme/components.js.map +1 -1
- package/dist/theme/components.types.d.ts +5 -0
- package/dist/theme/components.types.d.ts.map +1 -1
- package/dist/theme/components.types.js.map +1 -1
- package/dist/theme/typography.d.ts.map +1 -1
- package/dist/theme/typography.js +6 -0
- package/dist/theme/typography.js.map +1 -1
- package/dist/theme/typography.types.d.ts +3 -3
- package/dist/theme/typography.types.d.ts.map +1 -1
- package/dist/theme/typography.types.js.map +1 -1
- package/package.json +7 -7
- package/src/Banner.tsx +69 -0
- package/src/Infobox.tsx +47 -0
- package/src/Link.tsx +4 -4
- package/src/OdysseyThemeProvider.tsx +25 -5
- package/src/Radio.tsx +28 -0
- package/src/RadioGroup.tsx +105 -0
- package/src/Status.tsx +29 -0
- package/src/TextField.tsx +220 -0
- package/src/index.ts +33 -15
- package/src/theme/components.tsx +518 -85
- package/src/theme/components.types.ts +7 -0
- package/src/theme/typography.ts +6 -0
- package/src/theme/typography.types.ts +3 -3
- package/tsconfig.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typography.types.js","names":[],"sources":["../../src/theme/typography.types.ts"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { CSSProperties } from \"react\";\n\ndeclare module \"@mui/material/styles\" {\n interface TypographyVariants {\n
|
|
1
|
+
{"version":3,"file":"typography.types.js","names":[],"sources":["../../src/theme/typography.types.ts"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { CSSProperties } from \"react\";\n\ndeclare module \"@mui/material/styles\" {\n interface TypographyVariants {\n legend: CSSProperties;\n ui: CSSProperties;\n }\n interface TypographyVariantsOptions {\n legend?: CSSProperties;\n ui: CSSProperties;\n }\n}\n\ndeclare module \"@mui/material/Typography\" {\n interface TypographyPropsVariantOverrides {\n body1: true; // Design may refer to this as \"body\"\n body2: false;\n button: false;\n legend: true;\n overline: false;\n subtitle1: true; // Design may refer to this as \"caption\"\n subtitle2: false;\n ui: true;\n default: true; // used by <Link>\n monochrome: true; // used by <Link>\n }\n}\n\nexport {};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA8BA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okta/odyssey-react-mui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "React MUI components for Odyssey, Okta's design system",
|
|
5
5
|
"author": "Okta, Inc.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/cache": "^11.10.5",
|
|
23
|
-
"@mui/icons-material": "^5.
|
|
24
|
-
"@mui/lab": "^5.0.0-alpha.
|
|
25
|
-
"@mui/material": "^5.
|
|
26
|
-
"@mui/utils": "^5.
|
|
27
|
-
"@okta/odyssey-design-tokens": "
|
|
23
|
+
"@mui/icons-material": "^5.11.0",
|
|
24
|
+
"@mui/lab": "^5.0.0-alpha.117",
|
|
25
|
+
"@mui/material": "^5.11.6",
|
|
26
|
+
"@mui/utils": "^5.11.2",
|
|
27
|
+
"@okta/odyssey-design-tokens": "0.19.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@emotion/react": "^11",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"react": ">=17 <19",
|
|
33
33
|
"react-dom": ">=17 <19"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "550e93798127b91b008c362a4aee145854381bfd"
|
|
36
36
|
}
|
package/src/Banner.tsx
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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 { AlertColor, AlertProps } from "@mui/material";
|
|
14
|
+
import { memo } from "react";
|
|
15
|
+
import { Alert, Link } from "./";
|
|
16
|
+
|
|
17
|
+
export interface BannerProps {
|
|
18
|
+
/**
|
|
19
|
+
* Determine the color and icon of the alert
|
|
20
|
+
*/
|
|
21
|
+
severity: AlertColor;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the ARIA role of the alert
|
|
24
|
+
* ("status" for something that dynamically updates, "alert" for errors, null for something
|
|
25
|
+
* unchanging)
|
|
26
|
+
*/
|
|
27
|
+
role?: "status" | "alert";
|
|
28
|
+
/**
|
|
29
|
+
* The text content of the alert
|
|
30
|
+
*/
|
|
31
|
+
text: string;
|
|
32
|
+
/**
|
|
33
|
+
* The function that's fired when the user clicks the close button. If undefined,
|
|
34
|
+
* the close button will not be shown.
|
|
35
|
+
*/
|
|
36
|
+
onClose?: AlertProps["onClose"];
|
|
37
|
+
/**
|
|
38
|
+
* If defined, the alert will include a link to the URL
|
|
39
|
+
*/
|
|
40
|
+
linkUrl?: string;
|
|
41
|
+
/**
|
|
42
|
+
* If linkUrl is not undefined, this is the text of the link.
|
|
43
|
+
* If left blank, it defaults to "Learn more".
|
|
44
|
+
* Note that linkText does nothing if linkUrl is not defined
|
|
45
|
+
*/
|
|
46
|
+
linkText?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const Banner = ({
|
|
50
|
+
onClose,
|
|
51
|
+
severity,
|
|
52
|
+
role,
|
|
53
|
+
linkUrl,
|
|
54
|
+
linkText,
|
|
55
|
+
text,
|
|
56
|
+
}: BannerProps) => (
|
|
57
|
+
<Alert onClose={onClose} role={role} severity={severity} variant="banner">
|
|
58
|
+
{text}
|
|
59
|
+
{linkUrl && (
|
|
60
|
+
<Link href={linkUrl} variant="monochrome">
|
|
61
|
+
{linkText}
|
|
62
|
+
</Link>
|
|
63
|
+
)}
|
|
64
|
+
</Alert>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const MemoizedBanner = memo(Banner);
|
|
68
|
+
|
|
69
|
+
export { MemoizedBanner as Banner };
|
package/src/Infobox.tsx
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
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 { AlertColor } from "@mui/material";
|
|
14
|
+
import { memo, ReactNode } from "react";
|
|
15
|
+
import { Alert, AlertTitle } from ".";
|
|
16
|
+
|
|
17
|
+
export interface InfoboxProps {
|
|
18
|
+
/**
|
|
19
|
+
* The contents of the alert
|
|
20
|
+
*/
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Determine the color and icon of the alert
|
|
24
|
+
*/
|
|
25
|
+
severity: AlertColor;
|
|
26
|
+
/**
|
|
27
|
+
* Sets the ARIA role of the alert
|
|
28
|
+
* ("status" for something that dynamically updates, "alert" for errors, null for something
|
|
29
|
+
* unchanging)
|
|
30
|
+
*/
|
|
31
|
+
role?: "status" | "alert";
|
|
32
|
+
/**
|
|
33
|
+
* The title of the alert
|
|
34
|
+
*/
|
|
35
|
+
title?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const Infobox = ({ children, severity, role, title }: InfoboxProps) => (
|
|
39
|
+
<Alert role={role} severity={severity} variant="infobox">
|
|
40
|
+
{title && <AlertTitle>{title}</AlertTitle>}
|
|
41
|
+
{children}
|
|
42
|
+
</Alert>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const MemoizedInfobox = memo(Infobox);
|
|
46
|
+
|
|
47
|
+
export { MemoizedInfobox as Infobox };
|
package/src/Link.tsx
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { ReactElement } from "react";
|
|
13
|
+
import { forwardRef, ReactElement } from "react";
|
|
14
14
|
|
|
15
15
|
import { Link as MuiLink, SvgIcon } from "@mui/material";
|
|
16
16
|
import type { LinkProps as MuiLinkProps } from "@mui/material";
|
|
@@ -19,10 +19,10 @@ export interface LinkProps extends MuiLinkProps {
|
|
|
19
19
|
icon?: ReactElement;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export const Link = (props
|
|
22
|
+
export const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {
|
|
23
23
|
const { icon, children, target } = props;
|
|
24
24
|
return (
|
|
25
|
-
<MuiLink {...props}>
|
|
25
|
+
<MuiLink {...props} ref={ref}>
|
|
26
26
|
{icon && <span className="Link-icon">{icon}</span>}
|
|
27
27
|
{children}
|
|
28
28
|
{target === "_blank" && (
|
|
@@ -39,4 +39,4 @@ export const Link = (props: LinkProps) => {
|
|
|
39
39
|
)}
|
|
40
40
|
</MuiLink>
|
|
41
41
|
);
|
|
42
|
-
};
|
|
42
|
+
});
|
|
@@ -10,14 +10,34 @@
|
|
|
10
10
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
|
|
13
|
+
import {
|
|
14
|
+
createTheme,
|
|
15
|
+
ThemeOptions,
|
|
16
|
+
ThemeProvider as MuiThemeProvider,
|
|
17
|
+
} from "@mui/material/styles";
|
|
18
|
+
import { deepmerge } from "@mui/utils";
|
|
19
|
+
import { memo, ReactElement, useMemo } from "react";
|
|
15
20
|
|
|
16
21
|
import { odysseyTheme } from "./theme";
|
|
17
22
|
|
|
18
|
-
const OdysseyThemeProvider = ({
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
const OdysseyThemeProvider = ({
|
|
24
|
+
children,
|
|
25
|
+
customTheme,
|
|
26
|
+
}: {
|
|
27
|
+
children: ReactElement;
|
|
28
|
+
customTheme?: ThemeOptions;
|
|
29
|
+
}) => {
|
|
30
|
+
const customOdysseyTheme = useMemo(
|
|
31
|
+
() => customTheme && createTheme(deepmerge(odysseyTheme, customTheme)),
|
|
32
|
+
[customTheme]
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<MuiThemeProvider theme={customOdysseyTheme ?? odysseyTheme}>
|
|
37
|
+
{children}
|
|
38
|
+
</MuiThemeProvider>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
21
41
|
|
|
22
42
|
const MemoizedOdysseyThemeProvider = memo(OdysseyThemeProvider);
|
|
23
43
|
|
package/src/Radio.tsx
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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 { FormControlLabel } from "./";
|
|
14
|
+
import { Radio as MuiRadio } from "@mui/material";
|
|
15
|
+
import { memo } from "react";
|
|
16
|
+
|
|
17
|
+
export type RadioProps = {
|
|
18
|
+
label: string;
|
|
19
|
+
value: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const Radio = ({ label, value }: RadioProps) => (
|
|
23
|
+
<FormControlLabel control={<MuiRadio />} label={label} value={value} />
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const MemoizedRadio = memo(Radio);
|
|
27
|
+
|
|
28
|
+
export { MemoizedRadio as Radio };
|
|
@@ -0,0 +1,105 @@
|
|
|
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 {
|
|
14
|
+
FormControl,
|
|
15
|
+
FormLabel,
|
|
16
|
+
FormHelperText,
|
|
17
|
+
visuallyHidden,
|
|
18
|
+
Radio,
|
|
19
|
+
useUniqueId,
|
|
20
|
+
} from "./";
|
|
21
|
+
import { RadioGroup as MuiRadioGroup } from "@mui/material";
|
|
22
|
+
import { memo, ReactElement, useMemo } from "react";
|
|
23
|
+
|
|
24
|
+
export interface RadioGroupProps {
|
|
25
|
+
/**
|
|
26
|
+
* The <Radio> components within the group. Must include two or more.
|
|
27
|
+
*/
|
|
28
|
+
children: Array<ReactElement<typeof Radio>>;
|
|
29
|
+
/**
|
|
30
|
+
* The text value of the radio that should be selected by default
|
|
31
|
+
*/
|
|
32
|
+
defaultValue?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The error text for an invalid group
|
|
35
|
+
*/
|
|
36
|
+
errorMessage?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional hint text
|
|
39
|
+
*/
|
|
40
|
+
hint?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Disables the whole radio group
|
|
43
|
+
*/
|
|
44
|
+
isDisabled?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The text label for the radio group
|
|
47
|
+
*/
|
|
48
|
+
label: string;
|
|
49
|
+
/**
|
|
50
|
+
* The name of the radio group, which only needs to be changed
|
|
51
|
+
* if there are multiple radio groups on the same screen
|
|
52
|
+
*/
|
|
53
|
+
name?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const RadioGroup = ({
|
|
57
|
+
children,
|
|
58
|
+
defaultValue,
|
|
59
|
+
errorMessage,
|
|
60
|
+
hint,
|
|
61
|
+
isDisabled,
|
|
62
|
+
label,
|
|
63
|
+
name,
|
|
64
|
+
}: RadioGroupProps) => {
|
|
65
|
+
const ariaDescribedBy = useMemo(
|
|
66
|
+
() =>
|
|
67
|
+
errorMessage || hint
|
|
68
|
+
? [hint && `${name}-hint`, errorMessage && `${name}-error`]
|
|
69
|
+
.filter(Boolean)
|
|
70
|
+
.join(" ")
|
|
71
|
+
: undefined,
|
|
72
|
+
[errorMessage, hint, name]
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const uniqueName = useUniqueId(name);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<FormControl
|
|
79
|
+
component="fieldset"
|
|
80
|
+
disabled={isDisabled}
|
|
81
|
+
error={Boolean(errorMessage)}
|
|
82
|
+
>
|
|
83
|
+
<FormLabel component="legend">{label}</FormLabel>
|
|
84
|
+
{hint && (
|
|
85
|
+
<FormHelperText id={`${uniqueName}-hint`}>{hint}</FormHelperText>
|
|
86
|
+
)}
|
|
87
|
+
<MuiRadioGroup
|
|
88
|
+
aria-describedby={ariaDescribedBy}
|
|
89
|
+
defaultValue={defaultValue}
|
|
90
|
+
name={uniqueName}
|
|
91
|
+
>
|
|
92
|
+
{children}
|
|
93
|
+
</MuiRadioGroup>
|
|
94
|
+
{errorMessage && (
|
|
95
|
+
<FormHelperText id={`${uniqueName}-error`} error>
|
|
96
|
+
<span style={visuallyHidden}>Error:</span> {errorMessage}
|
|
97
|
+
</FormHelperText>
|
|
98
|
+
)}
|
|
99
|
+
</FormControl>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const MemoizedRadioGroup = memo(RadioGroup);
|
|
104
|
+
|
|
105
|
+
export { MemoizedRadioGroup as RadioGroup };
|
package/src/Status.tsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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 { Chip } from "./";
|
|
14
|
+
|
|
15
|
+
export interface StatusProps {
|
|
16
|
+
/**
|
|
17
|
+
* Determine the color and icon of the alert
|
|
18
|
+
*/
|
|
19
|
+
severity: "default" | "error" | "info" | "success" | "warning";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The text content of the status
|
|
23
|
+
*/
|
|
24
|
+
label: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const Status = ({ severity, label }: StatusProps) => (
|
|
28
|
+
<Chip label={label} color={severity} variant="status" />
|
|
29
|
+
);
|
|
@@ -0,0 +1,220 @@
|
|
|
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 {
|
|
14
|
+
ChangeEventHandler,
|
|
15
|
+
FocusEventHandler,
|
|
16
|
+
forwardRef,
|
|
17
|
+
InputHTMLAttributes,
|
|
18
|
+
memo,
|
|
19
|
+
ReactNode,
|
|
20
|
+
useCallback,
|
|
21
|
+
useEffect,
|
|
22
|
+
useMemo,
|
|
23
|
+
useState,
|
|
24
|
+
} from "react";
|
|
25
|
+
import {
|
|
26
|
+
EyeIcon,
|
|
27
|
+
EyeOffIcon,
|
|
28
|
+
FormControl,
|
|
29
|
+
FormHelperText,
|
|
30
|
+
IconButton,
|
|
31
|
+
InputAdornment,
|
|
32
|
+
InputBase,
|
|
33
|
+
InputLabel,
|
|
34
|
+
SearchIcon,
|
|
35
|
+
Typography,
|
|
36
|
+
visuallyHidden,
|
|
37
|
+
useUniqueId,
|
|
38
|
+
} from "./";
|
|
39
|
+
|
|
40
|
+
export type TextFieldProps = {
|
|
41
|
+
/**
|
|
42
|
+
* This prop helps users to fill forms faster, especially on mobile devices.
|
|
43
|
+
* The name can be confusing, as it's more like an autofill.
|
|
44
|
+
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
|
|
45
|
+
*/
|
|
46
|
+
autoCompleteType?: InputHTMLAttributes<HTMLInputElement>["autoComplete"];
|
|
47
|
+
/**
|
|
48
|
+
* If `true`, the component is disabled.
|
|
49
|
+
*/
|
|
50
|
+
isDisabled?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* End `InputAdornment` for this component.
|
|
53
|
+
*/
|
|
54
|
+
endAdornment?: ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* If `error` is not undefined, the `input` will indicate an error.
|
|
57
|
+
*/
|
|
58
|
+
errorMessage?: string;
|
|
59
|
+
/**
|
|
60
|
+
* The helper text content.
|
|
61
|
+
*/
|
|
62
|
+
hint?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The id of the `input` element.
|
|
65
|
+
*/
|
|
66
|
+
id?: string;
|
|
67
|
+
/**
|
|
68
|
+
* The label for the `input` element.
|
|
69
|
+
*/
|
|
70
|
+
label?: string;
|
|
71
|
+
/**
|
|
72
|
+
* If `true`, a [TextareaAutosize](/material-ui/react-textarea-autosize/) element is rendered.
|
|
73
|
+
*/
|
|
74
|
+
isMultiline?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Callback fired when the value is changed.
|
|
77
|
+
*/
|
|
78
|
+
onChange?: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
|
|
79
|
+
/**
|
|
80
|
+
* Callback fired when the `input` element get focus.
|
|
81
|
+
*/
|
|
82
|
+
onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
83
|
+
/**
|
|
84
|
+
* The label for the `input` element if the it's not optional
|
|
85
|
+
*/
|
|
86
|
+
optionalLabel?: string;
|
|
87
|
+
/**
|
|
88
|
+
* The short hint displayed in the `input` before the user enters a value.
|
|
89
|
+
*/
|
|
90
|
+
placeholder?: string;
|
|
91
|
+
/**
|
|
92
|
+
* It prevents the user from changing the value of the field
|
|
93
|
+
*/
|
|
94
|
+
isReadOnly?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* If `true`, the `input` element is required.
|
|
97
|
+
*/
|
|
98
|
+
isRequired?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Start `InputAdornment` for this component.
|
|
101
|
+
*/
|
|
102
|
+
startAdornment?: ReactNode;
|
|
103
|
+
/**
|
|
104
|
+
* 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).
|
|
105
|
+
*/
|
|
106
|
+
type?: string;
|
|
107
|
+
/**
|
|
108
|
+
* The value of the `input` element, required for a controlled component.
|
|
109
|
+
*/
|
|
110
|
+
value?: unknown;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const TextField = forwardRef<HTMLInputElement, TextFieldProps>((props, ref) => {
|
|
114
|
+
const {
|
|
115
|
+
autoCompleteType,
|
|
116
|
+
isDisabled = false,
|
|
117
|
+
endAdornment,
|
|
118
|
+
errorMessage,
|
|
119
|
+
hint,
|
|
120
|
+
id: idOverride,
|
|
121
|
+
label,
|
|
122
|
+
isMultiline = false,
|
|
123
|
+
onChange,
|
|
124
|
+
onFocus,
|
|
125
|
+
optionalLabel,
|
|
126
|
+
placeholder,
|
|
127
|
+
isReadOnly,
|
|
128
|
+
isRequired = true,
|
|
129
|
+
startAdornment,
|
|
130
|
+
type = "text",
|
|
131
|
+
value,
|
|
132
|
+
} = props;
|
|
133
|
+
|
|
134
|
+
const [inputType, setInputType] = useState(type);
|
|
135
|
+
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
setInputType(type);
|
|
138
|
+
}, [type]);
|
|
139
|
+
|
|
140
|
+
const togglePasswordVisibility = useCallback(() => {
|
|
141
|
+
setInputType((currentType) =>
|
|
142
|
+
currentType === "password" ? "text" : "password"
|
|
143
|
+
);
|
|
144
|
+
}, []);
|
|
145
|
+
|
|
146
|
+
const id = useUniqueId(idOverride);
|
|
147
|
+
const hintId = hint ? `${id}-hint` : undefined;
|
|
148
|
+
const errorId = errorMessage ? `${id}-error` : undefined;
|
|
149
|
+
const labelId = label ? `${id}-label` : undefined;
|
|
150
|
+
|
|
151
|
+
const inputProps = useMemo(
|
|
152
|
+
() =>
|
|
153
|
+
errorId || hintId
|
|
154
|
+
? {
|
|
155
|
+
"aria-describedby":
|
|
156
|
+
errorId && hintId ? `${hintId} ${errorId}` : errorId || hintId,
|
|
157
|
+
}
|
|
158
|
+
: undefined,
|
|
159
|
+
[errorId, hintId]
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<FormControl disabled={isDisabled} error={Boolean(errorMessage)}>
|
|
164
|
+
<InputLabel htmlFor={id} id={labelId}>
|
|
165
|
+
{label}
|
|
166
|
+
{!isRequired && (
|
|
167
|
+
<Typography variant="subtitle1">{optionalLabel}</Typography>
|
|
168
|
+
)}
|
|
169
|
+
</InputLabel>
|
|
170
|
+
{hint && <FormHelperText id={hintId}>{hint}</FormHelperText>}
|
|
171
|
+
<InputBase
|
|
172
|
+
autoComplete={autoCompleteType}
|
|
173
|
+
endAdornment={
|
|
174
|
+
inputType === "password" ? (
|
|
175
|
+
<InputAdornment position="end">
|
|
176
|
+
<IconButton
|
|
177
|
+
aria-label="toggle password visibility"
|
|
178
|
+
edge="end"
|
|
179
|
+
onClick={togglePasswordVisibility}
|
|
180
|
+
>
|
|
181
|
+
{inputType === "password" ? <EyeIcon /> : <EyeOffIcon />}
|
|
182
|
+
</IconButton>
|
|
183
|
+
</InputAdornment>
|
|
184
|
+
) : (
|
|
185
|
+
endAdornment
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
id={id}
|
|
189
|
+
inputProps={inputProps}
|
|
190
|
+
multiline={isMultiline}
|
|
191
|
+
onChange={onChange}
|
|
192
|
+
onFocus={onFocus}
|
|
193
|
+
placeholder={placeholder}
|
|
194
|
+
readOnly={isReadOnly}
|
|
195
|
+
ref={ref}
|
|
196
|
+
startAdornment={
|
|
197
|
+
inputType === "search" ? (
|
|
198
|
+
<InputAdornment position="start">
|
|
199
|
+
<SearchIcon />
|
|
200
|
+
</InputAdornment>
|
|
201
|
+
) : (
|
|
202
|
+
startAdornment
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
type={inputType}
|
|
206
|
+
value={value}
|
|
207
|
+
/>
|
|
208
|
+
{errorMessage && (
|
|
209
|
+
<FormHelperText error id={errorId}>
|
|
210
|
+
<span style={visuallyHidden}>Error:</span>
|
|
211
|
+
{errorMessage}
|
|
212
|
+
</FormHelperText>
|
|
213
|
+
)}
|
|
214
|
+
</FormControl>
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const MemoizedTextField = memo(TextField);
|
|
219
|
+
|
|
220
|
+
export { MemoizedTextField as TextField };
|
package/src/index.ts
CHANGED
|
@@ -10,17 +10,6 @@
|
|
|
10
10
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export * from "./createUniqueId";
|
|
14
|
-
export * from "./Icon";
|
|
15
|
-
export * from "./iconDictionary";
|
|
16
|
-
export * from "./Link";
|
|
17
|
-
export * from "./OdysseyCacheProvider";
|
|
18
|
-
export * from "./OdysseyThemeProvider";
|
|
19
|
-
export * from "./PasswordInput";
|
|
20
|
-
export * from "./theme";
|
|
21
|
-
export * from "./ThemeProvider";
|
|
22
|
-
export * from "./useUniqueId";
|
|
23
|
-
|
|
24
13
|
export {
|
|
25
14
|
Alert,
|
|
26
15
|
AlertTitle,
|
|
@@ -44,8 +33,13 @@ export {
|
|
|
44
33
|
InputAdornment,
|
|
45
34
|
InputBase,
|
|
46
35
|
InputLabel,
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
List,
|
|
37
|
+
ListItem,
|
|
38
|
+
ListItemIcon,
|
|
39
|
+
ListItemText,
|
|
40
|
+
ListSubheader,
|
|
41
|
+
MenuItem,
|
|
42
|
+
ScopedCssBaseline,
|
|
49
43
|
Select,
|
|
50
44
|
Snackbar,
|
|
51
45
|
Stack,
|
|
@@ -87,8 +81,14 @@ export type {
|
|
|
87
81
|
InputAdornmentProps,
|
|
88
82
|
InputBaseProps,
|
|
89
83
|
InputLabelProps,
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
ListProps,
|
|
85
|
+
ListItemProps,
|
|
86
|
+
ListItemIconProps,
|
|
87
|
+
ListItemTextProps,
|
|
88
|
+
ListSubheaderProps,
|
|
89
|
+
MenuItemProps,
|
|
90
|
+
ScopedCssBaselineProps,
|
|
91
|
+
SelectChangeEvent,
|
|
92
92
|
SelectProps,
|
|
93
93
|
SnackbarProps,
|
|
94
94
|
StackProps,
|
|
@@ -101,6 +101,7 @@ export type {
|
|
|
101
101
|
TableProps,
|
|
102
102
|
TableRowProps,
|
|
103
103
|
TableSortLabelProps,
|
|
104
|
+
ThemeOptions,
|
|
104
105
|
TooltipProps,
|
|
105
106
|
TypographyProps,
|
|
106
107
|
useThemeProps,
|
|
@@ -113,3 +114,20 @@ export type { TabContextProps, TabListProps, TabPanelProps } from "@mui/lab";
|
|
|
113
114
|
export { default as FavoriteIcon } from "@mui/icons-material/Favorite";
|
|
114
115
|
|
|
115
116
|
export { visuallyHidden } from "@mui/utils";
|
|
117
|
+
|
|
118
|
+
export * from "./Banner";
|
|
119
|
+
export * from "./createUniqueId";
|
|
120
|
+
export * from "./Icon";
|
|
121
|
+
export * from "./iconDictionary";
|
|
122
|
+
export * from "./Infobox";
|
|
123
|
+
export * from "./Link";
|
|
124
|
+
export * from "./OdysseyCacheProvider";
|
|
125
|
+
export * from "./OdysseyThemeProvider";
|
|
126
|
+
export * from "./PasswordInput";
|
|
127
|
+
export * from "./Radio";
|
|
128
|
+
export * from "./RadioGroup";
|
|
129
|
+
export * from "./Status";
|
|
130
|
+
export * from "./TextField";
|
|
131
|
+
export * from "./theme";
|
|
132
|
+
export * from "./ThemeProvider";
|
|
133
|
+
export * from "./useUniqueId";
|