@okta/odyssey-react-mui 1.22.0 → 1.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 +19 -0
- package/dist/@types/i18next.d.js.map +1 -1
- package/dist/Autocomplete.js +30 -0
- package/dist/Autocomplete.js.map +1 -1
- package/dist/Callout.js +12 -24
- package/dist/Callout.js.map +1 -1
- package/dist/DataTable/useScrollIndication.js +7 -3
- package/dist/DataTable/useScrollIndication.js.map +1 -1
- package/dist/FileUploader/FileUploadIllustration.js.map +1 -0
- package/dist/FileUploader/FileUploadPreview.js.map +1 -0
- package/dist/{labs/FileUpload.js → FileUploader/FileUploader.js} +6 -5
- package/dist/FileUploader/FileUploader.js.map +1 -0
- package/dist/FileUploader/index.js +13 -0
- package/dist/FileUploader/index.js.map +1 -0
- package/dist/OdysseyProvider.js +4 -0
- package/dist/OdysseyProvider.js.map +1 -1
- package/dist/Radio.js +2 -2
- package/dist/Radio.js.map +1 -1
- package/dist/Select.js +36 -0
- package/dist/Select.js.map +1 -1
- package/dist/{labs/Switch.js → Switch.js} +7 -7
- package/dist/Switch.js.map +1 -0
- package/dist/Tabs.js +7 -9
- package/dist/Tabs.js.map +1 -1
- package/dist/Tag.js +102 -4
- package/dist/Tag.js.map +1 -1
- package/dist/TextField.js +16 -39
- package/dist/TextField.js.map +1 -1
- package/dist/Toast.js +2 -2
- package/dist/Toast.js.map +1 -1
- package/dist/createShadowDomElements.js +1 -0
- package/dist/createShadowDomElements.js.map +1 -1
- package/dist/i18n.js +1 -1
- package/dist/i18n.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.scss +92 -4
- package/dist/labs/DataView/DataView.js +64 -25
- package/dist/labs/DataView/DataView.js.map +1 -1
- package/dist/labs/DataView/TableLayoutContent.js +17 -3
- package/dist/labs/DataView/TableLayoutContent.js.map +1 -1
- package/dist/labs/DataView/componentTypes.js.map +1 -1
- package/dist/labs/DateField.js +2 -0
- package/dist/labs/DateField.js.map +1 -1
- package/dist/labs/DatePicker.js +5 -1
- package/dist/labs/DatePicker.js.map +1 -1
- package/dist/labs/SideNav/OktaLogo.js +36 -0
- package/dist/labs/SideNav/OktaLogo.js.map +1 -0
- package/dist/labs/SideNav/SideNav.js +125 -36
- package/dist/labs/SideNav/SideNav.js.map +1 -1
- package/dist/labs/SideNav/SideNavHeader.js +33 -10
- package/dist/labs/SideNav/SideNavHeader.js.map +1 -1
- package/dist/labs/SideNav/types.js.map +1 -1
- package/dist/labs/TopNav.js +2 -1
- package/dist/labs/TopNav.js.map +1 -1
- package/dist/labs/index.js +0 -2
- package/dist/labs/index.js.map +1 -1
- package/dist/labs/useDateFieldsTranslations.js +1 -1
- package/dist/labs/useDateFieldsTranslations.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui.js +3 -1
- package/dist/properties/ts/odyssey-react-mui.js.map +1 -1
- package/dist/src/Autocomplete.d.ts +30 -0
- package/dist/src/Autocomplete.d.ts.map +1 -1
- package/dist/src/Callout.d.ts +11 -23
- package/dist/src/Callout.d.ts.map +1 -1
- package/dist/src/DataTable/useScrollIndication.d.ts.map +1 -1
- package/dist/src/FileUploader/FileUploadIllustration.d.ts.map +1 -0
- package/dist/src/{labs → FileUploader}/FileUploadPreview.d.ts +2 -2
- package/dist/src/FileUploader/FileUploadPreview.d.ts.map +1 -0
- package/dist/src/{labs/FileUpload.d.ts → FileUploader/FileUploader.d.ts} +5 -4
- package/dist/src/FileUploader/FileUploader.d.ts.map +1 -0
- package/dist/src/FileUploader/index.d.ts +13 -0
- package/dist/src/FileUploader/index.d.ts.map +1 -0
- package/dist/src/NativeSelect.d.ts +1 -1
- package/dist/src/OdysseyProvider.d.ts.map +1 -1
- package/dist/src/OdysseyTranslationProvider.d.ts +1 -1
- package/dist/src/OdysseyTranslationProvider.d.ts.map +1 -1
- package/dist/src/PasswordField.d.ts +1 -1
- package/dist/src/SearchField.d.ts +1 -1
- package/dist/src/Select.d.ts +36 -0
- package/dist/src/Select.d.ts.map +1 -1
- package/dist/src/{labs/Switch.d.ts → Switch.d.ts} +3 -3
- package/dist/src/Switch.d.ts.map +1 -0
- package/dist/src/Tabs.d.ts +6 -8
- package/dist/src/Tabs.d.ts.map +1 -1
- package/dist/src/Tag.d.ts +7 -1
- package/dist/src/Tag.d.ts.map +1 -1
- package/dist/src/TextField.d.ts +17 -40
- package/dist/src/TextField.d.ts.map +1 -1
- package/dist/src/createShadowDomElements.d.ts.map +1 -1
- package/dist/src/i18n.d.ts +2 -2
- package/dist/src/i18n.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/labs/DataView/DataView.d.ts +1 -1
- package/dist/src/labs/DataView/DataView.d.ts.map +1 -1
- package/dist/src/labs/DataView/TableLayoutContent.d.ts +2 -1
- package/dist/src/labs/DataView/TableLayoutContent.d.ts.map +1 -1
- package/dist/src/labs/DataView/componentTypes.d.ts +10 -0
- package/dist/src/labs/DataView/componentTypes.d.ts.map +1 -1
- package/dist/src/labs/DateField.d.ts +2 -2
- package/dist/src/labs/DateField.d.ts.map +1 -1
- package/dist/src/labs/DatePicker.d.ts +2 -2
- package/dist/src/labs/DatePicker.d.ts.map +1 -1
- package/dist/{test-selectors/odysseyTestSelectors.js → src/labs/SideNav/OktaLogo.d.ts} +3 -9
- package/dist/src/labs/SideNav/OktaLogo.d.ts.map +1 -0
- package/dist/src/labs/SideNav/SideNav.d.ts +2 -1
- package/dist/src/labs/SideNav/SideNav.d.ts.map +1 -1
- package/dist/src/labs/SideNav/SideNavHeader.d.ts +1 -1
- package/dist/src/labs/SideNav/SideNavHeader.d.ts.map +1 -1
- package/dist/src/labs/SideNav/types.d.ts +28 -5
- package/dist/src/labs/SideNav/types.d.ts.map +1 -1
- package/dist/src/labs/TopNav.d.ts +1 -0
- package/dist/src/labs/TopNav.d.ts.map +1 -1
- package/dist/src/labs/index.d.ts +0 -2
- package/dist/src/labs/index.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui.d.ts.map +1 -1
- package/dist/src/test-selectors/getByQuerySelector.d.ts +148 -0
- package/dist/src/test-selectors/getByQuerySelector.d.ts.map +1 -0
- package/{src/test-selectors/odysseyTestSelectors.ts → dist/src/test-selectors/getComputedAccessibleErrorMessageText.d.ts} +3 -11
- package/dist/src/test-selectors/getComputedAccessibleErrorMessageText.d.ts.map +1 -0
- package/dist/src/test-selectors/{featureTestSelector.d.ts → getComputedAccessibleText.d.ts} +11 -19
- package/dist/src/test-selectors/getComputedAccessibleText.d.ts.map +1 -0
- package/dist/src/test-selectors/index.d.ts +2 -2
- package/dist/src/test-selectors/index.d.ts.map +1 -1
- package/dist/src/test-selectors/interpolateString.d.ts +15 -0
- package/dist/src/test-selectors/interpolateString.d.ts.map +1 -0
- package/dist/src/test-selectors/linkedHtmlSelectors.d.ts +24 -0
- package/dist/src/test-selectors/linkedHtmlSelectors.d.ts.map +1 -0
- package/dist/src/test-selectors/queryOdysseySelector.d.ts +5755 -0
- package/dist/src/test-selectors/queryOdysseySelector.d.ts.map +1 -0
- package/dist/src/test-selectors/querySelector.d.ts +59 -3613
- package/dist/src/test-selectors/querySelector.d.ts.map +1 -1
- package/dist/src/test-selectors/sanityChecks.d.ts +18 -0
- package/dist/src/test-selectors/sanityChecks.d.ts.map +1 -0
- package/dist/src/test-selectors/testSelector.d.ts +46 -0
- package/dist/src/test-selectors/testSelector.d.ts.map +1 -0
- package/dist/src/theme/components.d.ts.map +1 -1
- package/dist/test-selectors/getByQuerySelector.js +64 -0
- package/dist/test-selectors/getByQuerySelector.js.map +1 -0
- package/dist/test-selectors/getComputedAccessibleErrorMessageText.js +25 -0
- package/dist/test-selectors/getComputedAccessibleErrorMessageText.js.map +1 -0
- package/dist/test-selectors/getComputedAccessibleText.js +24 -0
- package/dist/test-selectors/getComputedAccessibleText.js.map +1 -0
- package/dist/test-selectors/index.js +2 -2
- package/dist/test-selectors/index.js.map +1 -1
- package/{src/test-selectors/featureTestSelector.ts → dist/test-selectors/interpolateString.js} +11 -27
- package/dist/test-selectors/interpolateString.js.map +1 -0
- package/dist/test-selectors/linkedHtmlSelectors.js +34 -0
- package/dist/test-selectors/linkedHtmlSelectors.js.map +1 -0
- package/dist/test-selectors/queryOdysseySelector.js +26 -0
- package/dist/test-selectors/queryOdysseySelector.js.map +1 -0
- package/dist/test-selectors/querySelector.js +82 -58
- package/dist/test-selectors/querySelector.js.map +1 -1
- package/dist/test-selectors/sanityChecks.js +33 -0
- package/dist/test-selectors/sanityChecks.js.map +1 -0
- package/dist/test-selectors/testSelector.js +2 -0
- package/dist/test-selectors/testSelector.js.map +1 -0
- package/dist/test-selectors/testSelectors.json +1 -1
- package/dist/theme/components.js +0 -1
- package/dist/theme/components.js.map +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/jest.setup.js +3 -0
- package/package.json +5 -4
- package/scripts/generateTestSelectorsJson.ts +1 -1
- package/src/@types/i18next.d.ts +1 -1
- package/src/Autocomplete.tsx +32 -0
- package/src/Callout.tsx +13 -25
- package/src/DataTable/useScrollIndication.tsx +9 -2
- package/src/{labs → FileUploader}/FileUploadPreview.tsx +3 -3
- package/src/{labs/FileUpload.tsx → FileUploader/FileUploader.tsx} +7 -6
- package/src/FileUploader/index.ts +13 -0
- package/src/OdysseyCacheProvider.test.tsx +1 -0
- package/src/OdysseyProvider.tsx +6 -1
- package/src/Radio.tsx +2 -2
- package/src/Select.tsx +38 -0
- package/src/{labs/Switch.tsx → Switch.tsx} +10 -10
- package/src/Tabs.tsx +8 -10
- package/src/Tag.tsx +134 -3
- package/src/TextField.tsx +18 -41
- package/src/Toast.tsx +1 -1
- package/src/createShadowDomElements.ts +3 -0
- package/src/i18n.ts +3 -3
- package/src/index.ts +6 -1
- package/src/labs/DataView/DataView.test.tsx +158 -0
- package/src/labs/DataView/DataView.tsx +98 -50
- package/src/labs/DataView/TableLayoutContent.tsx +28 -1
- package/src/labs/DataView/componentTypes.ts +13 -0
- package/src/labs/DateField.tsx +3 -0
- package/src/labs/DatePicker.tsx +12 -1
- package/src/labs/SideNav/OktaLogo.tsx +39 -0
- package/src/labs/SideNav/SideNav.tsx +187 -51
- package/src/labs/SideNav/SideNavHeader.tsx +30 -7
- package/src/labs/SideNav/types.ts +32 -5
- package/src/labs/TopNav.tsx +3 -1
- package/src/labs/index.ts +0 -3
- package/src/labs/useDateFieldsTranslations.ts +1 -1
- package/src/properties/odyssey-react-mui.properties +2 -1
- package/src/properties/ts/odyssey-react-mui.ts +1 -1
- package/src/test-selectors/getByQuerySelector.ts +176 -0
- package/src/test-selectors/getComputedAccessibleErrorMessageText.ts +52 -0
- package/src/test-selectors/getComputedAccessibleText.ts +36 -0
- package/src/test-selectors/index.ts +2 -2
- package/src/test-selectors/interpolateString.ts +41 -0
- package/src/test-selectors/linkedHtmlSelectors.ts +73 -0
- package/src/test-selectors/queryOdysseySelector.ts +36 -0
- package/src/test-selectors/querySelector.ts +221 -170
- package/src/test-selectors/sanityChecks.ts +53 -0
- package/src/test-selectors/testSelector.ts +143 -0
- package/src/theme/components.tsx +0 -2
- package/dist/labs/FileUpload.js.map +0 -1
- package/dist/labs/FileUploadIllustration.js.map +0 -1
- package/dist/labs/FileUploadPreview.js.map +0 -1
- package/dist/labs/Switch.js.map +0 -1
- package/dist/src/labs/FileUpload.d.ts.map +0 -1
- package/dist/src/labs/FileUploadIllustration.d.ts.map +0 -1
- package/dist/src/labs/FileUploadPreview.d.ts.map +0 -1
- package/dist/src/labs/Switch.d.ts.map +0 -1
- package/dist/src/test-selectors/featureTestSelector.d.ts.map +0 -1
- package/dist/src/test-selectors/odysseyTestSelectors.d.ts +0 -120
- package/dist/src/test-selectors/odysseyTestSelectors.d.ts.map +0 -1
- package/dist/test-selectors/featureTestSelector.js +0 -2
- package/dist/test-selectors/featureTestSelector.js.map +0 -1
- package/dist/test-selectors/odysseyTestSelectors.js.map +0 -1
- /package/dist/{labs → FileUploader}/FileUploadIllustration.js +0 -0
- /package/dist/{labs → FileUploader}/FileUploadPreview.js +0 -0
- /package/dist/src/{labs → FileUploader}/FileUploadIllustration.d.ts +0 -0
- /package/src/{labs → FileUploader}/FileUploadIllustration.tsx +0 -0
package/src/Select.tsx
CHANGED
|
@@ -49,6 +49,44 @@ import {
|
|
|
49
49
|
useOdysseyDesignTokens,
|
|
50
50
|
DesignTokens,
|
|
51
51
|
} from "./OdysseyDesignTokensContext";
|
|
52
|
+
import { TestSelector } from "./test-selectors";
|
|
53
|
+
|
|
54
|
+
export const SelectTestSelector = {
|
|
55
|
+
accessibleText: {
|
|
56
|
+
errorMessage: "errorMessage",
|
|
57
|
+
hint: "description",
|
|
58
|
+
label: "label",
|
|
59
|
+
},
|
|
60
|
+
children: {
|
|
61
|
+
list: {
|
|
62
|
+
accessibleText: {
|
|
63
|
+
label: "label",
|
|
64
|
+
},
|
|
65
|
+
children: {
|
|
66
|
+
listItem: {
|
|
67
|
+
accessibleText: {
|
|
68
|
+
label: "label",
|
|
69
|
+
},
|
|
70
|
+
elementSelector: {
|
|
71
|
+
method: "ByRole",
|
|
72
|
+
options: {
|
|
73
|
+
label: "name",
|
|
74
|
+
},
|
|
75
|
+
role: "option",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
isControlledElement: true,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
elementSelector: {
|
|
83
|
+
method: "ByRole",
|
|
84
|
+
options: {
|
|
85
|
+
label: "name",
|
|
86
|
+
},
|
|
87
|
+
role: "combobox",
|
|
88
|
+
},
|
|
89
|
+
} as const satisfies TestSelector;
|
|
52
90
|
|
|
53
91
|
export type SelectOption = {
|
|
54
92
|
text: string;
|
|
@@ -23,19 +23,19 @@ import { SwitchProps as MuiSwitchProps, FormLabel } from "@mui/material";
|
|
|
23
23
|
import { useTranslation } from "react-i18next";
|
|
24
24
|
import styled from "@emotion/styled";
|
|
25
25
|
|
|
26
|
-
import { Box } from "
|
|
27
|
-
import { FieldComponentProps } from "
|
|
28
|
-
import { FieldHint } from "
|
|
29
|
-
import { CheckedFieldProps } from "
|
|
30
|
-
import type { HtmlProps } from "
|
|
31
|
-
import { CheckIcon } from "
|
|
32
|
-
import { ComponentControlledState, getControlState } from "
|
|
26
|
+
import { Box } from "./Box";
|
|
27
|
+
import { FieldComponentProps } from "./FieldComponentProps";
|
|
28
|
+
import { FieldHint } from "./FieldHint";
|
|
29
|
+
import { CheckedFieldProps } from "./FormCheckedProps";
|
|
30
|
+
import type { HtmlProps } from "./HtmlProps";
|
|
31
|
+
import { CheckIcon } from "./icons.generated";
|
|
32
|
+
import { ComponentControlledState, getControlState } from "./inputUtils";
|
|
33
33
|
import {
|
|
34
34
|
DesignTokens,
|
|
35
35
|
useOdysseyDesignTokens,
|
|
36
|
-
} from "
|
|
37
|
-
import { stripRem, toRem } from "
|
|
38
|
-
import { useUniqueId } from "
|
|
36
|
+
} from "./OdysseyDesignTokensContext";
|
|
37
|
+
import { stripRem, toRem } from "./remUtils";
|
|
38
|
+
import { useUniqueId } from "./useUniqueId";
|
|
39
39
|
|
|
40
40
|
const { CONTROLLED } = ComponentControlledState;
|
|
41
41
|
|
package/src/Tabs.tsx
CHANGED
|
@@ -30,30 +30,28 @@ import { Badge, BadgeProps } from "./Badge";
|
|
|
30
30
|
import { Box } from "./Box";
|
|
31
31
|
import { HtmlProps } from "./HtmlProps";
|
|
32
32
|
import { useOdysseyDesignTokens } from "./OdysseyDesignTokensContext";
|
|
33
|
-
import { type
|
|
33
|
+
import { type TestSelector } from "./test-selectors";
|
|
34
34
|
|
|
35
|
-
export const
|
|
36
|
-
|
|
35
|
+
export const TabsTestSelector = {
|
|
36
|
+
children: {
|
|
37
37
|
tabItem: {
|
|
38
|
-
|
|
38
|
+
elementSelector: {
|
|
39
39
|
method: "ByRole",
|
|
40
40
|
options: {
|
|
41
|
-
|
|
41
|
+
label: "name",
|
|
42
42
|
},
|
|
43
|
-
templateVariableNames: ["label"],
|
|
44
43
|
role: "tab",
|
|
45
44
|
},
|
|
46
45
|
},
|
|
47
46
|
},
|
|
48
|
-
|
|
47
|
+
elementSelector: {
|
|
49
48
|
method: "ByRole",
|
|
50
49
|
options: {
|
|
51
|
-
|
|
50
|
+
label: "name",
|
|
52
51
|
},
|
|
53
52
|
role: "tablist",
|
|
54
|
-
templateVariableNames: ["ariaLabel"],
|
|
55
53
|
},
|
|
56
|
-
} as const satisfies
|
|
54
|
+
} as const satisfies TestSelector;
|
|
57
55
|
|
|
58
56
|
export type TabItemProps = {
|
|
59
57
|
/**
|
package/src/Tag.tsx
CHANGED
|
@@ -12,9 +12,26 @@
|
|
|
12
12
|
|
|
13
13
|
import { Chip as MuiChip, ChipProps as MuiChipProps } from "@mui/material";
|
|
14
14
|
import { memo, ReactElement, useCallback, useContext } from "react";
|
|
15
|
+
import styled from "@emotion/styled";
|
|
15
16
|
import { TagListContext } from "./TagListContext";
|
|
16
17
|
import { MuiPropsContext, MuiPropsContextType } from "./MuiPropsContext";
|
|
17
18
|
import { HtmlProps } from "./HtmlProps";
|
|
19
|
+
import {
|
|
20
|
+
DesignTokens,
|
|
21
|
+
useOdysseyDesignTokens,
|
|
22
|
+
} from "./OdysseyDesignTokensContext";
|
|
23
|
+
import { CloseCircleFilledIcon } from "./icons.generated";
|
|
24
|
+
|
|
25
|
+
export const tagColorVariants = [
|
|
26
|
+
"default",
|
|
27
|
+
"info",
|
|
28
|
+
"accentOne",
|
|
29
|
+
"accentTwo",
|
|
30
|
+
"accentThree",
|
|
31
|
+
"accentFour",
|
|
32
|
+
] as const;
|
|
33
|
+
|
|
34
|
+
type TagColorVariant = (typeof tagColorVariants)[number];
|
|
18
35
|
|
|
19
36
|
export type TagProps = {
|
|
20
37
|
icon?: ReactElement;
|
|
@@ -31,9 +48,117 @@ export type TagProps = {
|
|
|
31
48
|
* Callback fired when the remove button of the Tag is clicked
|
|
32
49
|
*/
|
|
33
50
|
onRemove?: MuiChipProps["onDelete"];
|
|
51
|
+
/**
|
|
52
|
+
* Color variant of the Tag, affecting its appearance
|
|
53
|
+
*/
|
|
54
|
+
colorVariant?: TagColorVariant;
|
|
34
55
|
} & Pick<HtmlProps, "testId" | "translate">;
|
|
35
56
|
|
|
57
|
+
const getChipColors = (
|
|
58
|
+
colorVariant: TagColorVariant,
|
|
59
|
+
odysseyDesignTokens: DesignTokens,
|
|
60
|
+
) => {
|
|
61
|
+
const colors = {
|
|
62
|
+
default: {
|
|
63
|
+
background: odysseyDesignTokens.HueNeutral100,
|
|
64
|
+
hover: odysseyDesignTokens.HueNeutral200,
|
|
65
|
+
active: odysseyDesignTokens.HueNeutral300,
|
|
66
|
+
text: odysseyDesignTokens.HueNeutral700,
|
|
67
|
+
border: odysseyDesignTokens.HueNeutral200,
|
|
68
|
+
deleteIcon: odysseyDesignTokens.HueNeutral500,
|
|
69
|
+
deleteIconHover: odysseyDesignTokens.HueNeutral600,
|
|
70
|
+
},
|
|
71
|
+
info: {
|
|
72
|
+
background: odysseyDesignTokens.HueBlue100,
|
|
73
|
+
hover: odysseyDesignTokens.HueBlue200,
|
|
74
|
+
active: odysseyDesignTokens.HueBlue300,
|
|
75
|
+
text: odysseyDesignTokens.HueBlue700,
|
|
76
|
+
border: odysseyDesignTokens.HueBlue200,
|
|
77
|
+
deleteIcon: odysseyDesignTokens.HueBlue500,
|
|
78
|
+
deleteIconHover: odysseyDesignTokens.HueBlue600,
|
|
79
|
+
},
|
|
80
|
+
accentOne: {
|
|
81
|
+
background: odysseyDesignTokens.HueAccentOne100,
|
|
82
|
+
hover: odysseyDesignTokens.HueAccentOne200,
|
|
83
|
+
active: odysseyDesignTokens.HueAccentOne300,
|
|
84
|
+
text: odysseyDesignTokens.HueAccentOne700,
|
|
85
|
+
border: odysseyDesignTokens.HueAccentOne200,
|
|
86
|
+
deleteIcon: odysseyDesignTokens.HueAccentOne500,
|
|
87
|
+
deleteIconHover: odysseyDesignTokens.HueAccentOne600,
|
|
88
|
+
},
|
|
89
|
+
accentTwo: {
|
|
90
|
+
background: odysseyDesignTokens.HueAccentTwo100,
|
|
91
|
+
hover: odysseyDesignTokens.HueAccentTwo200,
|
|
92
|
+
active: odysseyDesignTokens.HueAccentTwo300,
|
|
93
|
+
text: odysseyDesignTokens.HueAccentTwo700,
|
|
94
|
+
border: odysseyDesignTokens.HueAccentTwo200,
|
|
95
|
+
deleteIcon: odysseyDesignTokens.HueAccentTwo500,
|
|
96
|
+
deleteIconHover: odysseyDesignTokens.HueAccentTwo600,
|
|
97
|
+
},
|
|
98
|
+
accentThree: {
|
|
99
|
+
background: odysseyDesignTokens.HueAccentThree100,
|
|
100
|
+
hover: odysseyDesignTokens.HueAccentThree200,
|
|
101
|
+
active: odysseyDesignTokens.HueAccentThree300,
|
|
102
|
+
text: odysseyDesignTokens.HueAccentThree700,
|
|
103
|
+
border: odysseyDesignTokens.HueAccentThree200,
|
|
104
|
+
deleteIcon: odysseyDesignTokens.HueAccentThree500,
|
|
105
|
+
deleteIconHover: odysseyDesignTokens.HueAccentThree600,
|
|
106
|
+
},
|
|
107
|
+
accentFour: {
|
|
108
|
+
background: odysseyDesignTokens.HueAccentFour100,
|
|
109
|
+
hover: odysseyDesignTokens.HueAccentFour200,
|
|
110
|
+
active: odysseyDesignTokens.HueAccentFour300,
|
|
111
|
+
text: odysseyDesignTokens.HueAccentFour700,
|
|
112
|
+
border: odysseyDesignTokens.HueAccentFour200,
|
|
113
|
+
deleteIcon: odysseyDesignTokens.HueAccentFour500,
|
|
114
|
+
deleteIconHover: odysseyDesignTokens.HueAccentFour600,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return colors[colorVariant] || colors.default;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const StyledTag = styled(MuiChip, {
|
|
122
|
+
shouldForwardProp: (prop) =>
|
|
123
|
+
!["colorVariant", "odysseyDesignTokens"].includes(prop as string),
|
|
124
|
+
})<{
|
|
125
|
+
colorVariant: TagColorVariant;
|
|
126
|
+
odysseyDesignTokens: DesignTokens;
|
|
127
|
+
as?: React.ElementType; // Allow the 'as' prop to be forwarded
|
|
128
|
+
}>(({ colorVariant, odysseyDesignTokens }) => {
|
|
129
|
+
const colors = getChipColors(colorVariant, odysseyDesignTokens);
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
backgroundColor: colors.background,
|
|
133
|
+
color: colors.text,
|
|
134
|
+
borderColor: colors.border,
|
|
135
|
+
|
|
136
|
+
"&.MuiChip-clickable:hover": {
|
|
137
|
+
backgroundColor: colors.hover,
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
"&.MuiChip-clickable:active": {
|
|
141
|
+
backgroundColor: colors.active,
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
"&.Mui-disabled": {
|
|
145
|
+
"& .MuiChip-deleteIcon": {
|
|
146
|
+
color: odysseyDesignTokens.HueNeutral300,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
"& .MuiChip-deleteIcon": {
|
|
151
|
+
color: colors.deleteIcon,
|
|
152
|
+
|
|
153
|
+
"&:hover": {
|
|
154
|
+
color: colors.deleteIconHover,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
|
|
36
160
|
const Tag = ({
|
|
161
|
+
colorVariant = "default",
|
|
37
162
|
icon,
|
|
38
163
|
isDisabled,
|
|
39
164
|
label,
|
|
@@ -42,21 +167,25 @@ const Tag = ({
|
|
|
42
167
|
testId,
|
|
43
168
|
translate,
|
|
44
169
|
}: TagProps) => {
|
|
170
|
+
const odysseyDesignTokens = useOdysseyDesignTokens();
|
|
45
171
|
const { chipElementType } = useContext(TagListContext);
|
|
46
172
|
|
|
47
173
|
const renderTag = useCallback(
|
|
48
174
|
(muiProps: MuiPropsContextType) => (
|
|
49
|
-
<
|
|
175
|
+
<StyledTag
|
|
50
176
|
{...muiProps}
|
|
177
|
+
as={chipElementType}
|
|
51
178
|
aria-disabled={isDisabled}
|
|
52
|
-
clickable={onClick
|
|
53
|
-
component={chipElementType}
|
|
179
|
+
clickable={Boolean(onClick)}
|
|
54
180
|
data-se={testId}
|
|
181
|
+
colorVariant={colorVariant}
|
|
182
|
+
odysseyDesignTokens={odysseyDesignTokens}
|
|
55
183
|
disabled={isDisabled}
|
|
56
184
|
icon={icon}
|
|
57
185
|
label={label}
|
|
58
186
|
onClick={onClick}
|
|
59
187
|
onDelete={onRemove}
|
|
188
|
+
deleteIcon={<CloseCircleFilledIcon />}
|
|
60
189
|
translate={translate}
|
|
61
190
|
/>
|
|
62
191
|
),
|
|
@@ -69,6 +198,8 @@ const Tag = ({
|
|
|
69
198
|
onRemove,
|
|
70
199
|
testId,
|
|
71
200
|
translate,
|
|
201
|
+
colorVariant,
|
|
202
|
+
odysseyDesignTokens,
|
|
72
203
|
],
|
|
73
204
|
);
|
|
74
205
|
|
package/src/TextField.tsx
CHANGED
|
@@ -30,56 +30,33 @@ import {
|
|
|
30
30
|
import { Field } from "./Field";
|
|
31
31
|
import { HtmlProps } from "./HtmlProps";
|
|
32
32
|
import { FocusHandle, useInputValues, getControlState } from "./inputUtils";
|
|
33
|
-
import { type
|
|
33
|
+
import { type TestSelector } from "./test-selectors";
|
|
34
34
|
|
|
35
|
-
export const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
errorMessage: {
|
|
45
|
-
selector: {
|
|
46
|
-
method: "ByText",
|
|
47
|
-
templateVariableNames: ["errorMessage"],
|
|
48
|
-
text: "${errorMessage}",
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
input: {
|
|
52
|
-
selector: {
|
|
53
|
-
method: "ByRole",
|
|
54
|
-
options: {
|
|
55
|
-
name: "${label}",
|
|
56
|
-
},
|
|
57
|
-
role: "textbox",
|
|
58
|
-
templateVariableNames: ["label"],
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
label: {
|
|
62
|
-
selector: {
|
|
63
|
-
method: "ByRole",
|
|
64
|
-
options: {
|
|
65
|
-
name: "${label}",
|
|
66
|
-
},
|
|
67
|
-
role: "LabelText",
|
|
68
|
-
templateVariableNames: ["label"],
|
|
69
|
-
},
|
|
70
|
-
},
|
|
35
|
+
export const TextFieldTestSelector = {
|
|
36
|
+
accessibleText: {
|
|
37
|
+
errorMessage: "errorMessage",
|
|
38
|
+
hint: "description",
|
|
39
|
+
label: "label",
|
|
40
|
+
},
|
|
41
|
+
children: {
|
|
71
42
|
link: {
|
|
72
|
-
|
|
43
|
+
elementSelector: {
|
|
73
44
|
method: "ByRole",
|
|
74
45
|
options: {
|
|
75
|
-
|
|
46
|
+
label: "name",
|
|
76
47
|
},
|
|
77
|
-
templateVariableNames: ["label"],
|
|
78
48
|
role: "link",
|
|
79
49
|
},
|
|
80
50
|
},
|
|
81
51
|
},
|
|
82
|
-
|
|
52
|
+
elementSelector: {
|
|
53
|
+
method: "ByRole",
|
|
54
|
+
options: {
|
|
55
|
+
label: "name",
|
|
56
|
+
},
|
|
57
|
+
role: "textbox",
|
|
58
|
+
},
|
|
59
|
+
} as const satisfies TestSelector;
|
|
83
60
|
|
|
84
61
|
export const textFieldTypeValues = [
|
|
85
62
|
"email",
|
package/src/Toast.tsx
CHANGED
|
@@ -21,6 +21,9 @@ export const createShadowDomElements = (containerElement: HTMLElement) => {
|
|
|
21
21
|
// React app root component.
|
|
22
22
|
const shadowRootElement = document.createElement("div");
|
|
23
23
|
shadowRootElement.setAttribute("id", "shadow-root");
|
|
24
|
+
// This div could cause issues with layout of children.
|
|
25
|
+
// For flexibility, make it inherit its parent's height
|
|
26
|
+
shadowRootElement.style.setProperty("height", "inherit");
|
|
24
27
|
|
|
25
28
|
shadowRoot.appendChild(emotionRootElement);
|
|
26
29
|
shadowRoot.appendChild(shadowRootElement);
|
package/src/i18n.ts
CHANGED
|
@@ -44,7 +44,7 @@ import { translation as zhCN } from "./properties/ts/odyssey-react-mui_zh_CN";
|
|
|
44
44
|
import { translation as znTW } from "./properties/ts/odyssey-react-mui_zh_TW";
|
|
45
45
|
|
|
46
46
|
export const defaultLNG = "en";
|
|
47
|
-
export const defaultNS = "
|
|
47
|
+
export const defaultNS = "odyssey";
|
|
48
48
|
|
|
49
49
|
// Note: This is type "string" to allow translation overrides from other languages
|
|
50
50
|
export type I18nResources = Record<string, Partial<typeof en>>;
|
|
@@ -78,7 +78,7 @@ export const resources: I18nResources = {
|
|
|
78
78
|
vi,
|
|
79
79
|
zh_CN: zhCN,
|
|
80
80
|
zh_TW: znTW,
|
|
81
|
-
};
|
|
81
|
+
} as const;
|
|
82
82
|
|
|
83
83
|
i18n.use(initReactI18next).init({
|
|
84
84
|
defaultNS,
|
|
@@ -94,7 +94,7 @@ i18n.use(initReactI18next).init({
|
|
|
94
94
|
useSuspense: false,
|
|
95
95
|
bindI18nStore: "added",
|
|
96
96
|
},
|
|
97
|
-
});
|
|
97
|
+
} as const);
|
|
98
98
|
|
|
99
99
|
Object.entries(resources).forEach(([locale, property]) => {
|
|
100
100
|
i18n.addResourceBundle(locale, defaultNS, property);
|
package/src/index.ts
CHANGED
|
@@ -77,6 +77,11 @@ export * from "./Drawer";
|
|
|
77
77
|
export * from "./EmptyState";
|
|
78
78
|
export * from "./Fieldset";
|
|
79
79
|
export * from "./FieldComponentProps";
|
|
80
|
+
export {
|
|
81
|
+
FileUploader,
|
|
82
|
+
fileUploadTypes,
|
|
83
|
+
fileUploadVariants,
|
|
84
|
+
} from "./FileUploader";
|
|
80
85
|
export * from "./Form";
|
|
81
86
|
export * from "./HintLink";
|
|
82
87
|
export * from "./IconWithTooltip";
|
|
@@ -104,7 +109,7 @@ export * from "./TextField";
|
|
|
104
109
|
export * from "./theme";
|
|
105
110
|
export * from "./Toast";
|
|
106
111
|
export * from "./ToastStack";
|
|
107
|
-
export * from "./
|
|
112
|
+
export * from "./Switch";
|
|
108
113
|
export * from "./Tooltip";
|
|
109
114
|
export * from "./Typography";
|
|
110
115
|
export * from "./useUniqueId";
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2024-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
|
+
fireEvent,
|
|
15
|
+
render,
|
|
16
|
+
screen,
|
|
17
|
+
waitFor,
|
|
18
|
+
within,
|
|
19
|
+
} from "@testing-library/react";
|
|
20
|
+
import { DataView } from "./index";
|
|
21
|
+
import {
|
|
22
|
+
data,
|
|
23
|
+
columns,
|
|
24
|
+
} from "@okta/odyssey-storybook/src/components/odyssey-labs/DataView/personData";
|
|
25
|
+
import { filterData } from "@okta/odyssey-storybook/src/components/odyssey-labs/DataView/dataFunctions";
|
|
26
|
+
|
|
27
|
+
const getData = ({ ...props }) => {
|
|
28
|
+
return filterData({ data, ...props });
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
describe("DataView", () => {
|
|
32
|
+
it("displays the expected number of rows by default", async () => {
|
|
33
|
+
render(
|
|
34
|
+
<DataView
|
|
35
|
+
availableLayouts={["table"]}
|
|
36
|
+
getData={getData}
|
|
37
|
+
tableLayoutOptions={{
|
|
38
|
+
columns: columns,
|
|
39
|
+
}}
|
|
40
|
+
hasSearch
|
|
41
|
+
hasPagination
|
|
42
|
+
// virtualization has to be false for the tests to work properly
|
|
43
|
+
enableVirtualization={false}
|
|
44
|
+
paginationType="loadMore"
|
|
45
|
+
resultsPerPage={20}
|
|
46
|
+
/>,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const tableElement = await screen.findByRole("table", { name: "" });
|
|
50
|
+
const rowElements = within(tableElement).getAllByRole("row", {
|
|
51
|
+
hidden: false,
|
|
52
|
+
});
|
|
53
|
+
expect(rowElements.length).toBe(21);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("displays the expected number of rows on load more", async () => {
|
|
57
|
+
render(
|
|
58
|
+
<DataView
|
|
59
|
+
availableLayouts={["table"]}
|
|
60
|
+
getData={getData}
|
|
61
|
+
tableLayoutOptions={{
|
|
62
|
+
columns: columns,
|
|
63
|
+
}}
|
|
64
|
+
hasSearch
|
|
65
|
+
hasPagination
|
|
66
|
+
// virtualization has to be false for the tests to work properly
|
|
67
|
+
enableVirtualization={false}
|
|
68
|
+
paginationType="loadMore"
|
|
69
|
+
resultsPerPage={20}
|
|
70
|
+
/>,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const tableElement = await screen.findByRole("table", { name: "" });
|
|
74
|
+
const rowElements = within(tableElement).getAllByRole("row", {
|
|
75
|
+
hidden: false,
|
|
76
|
+
});
|
|
77
|
+
expect(rowElements.length).toBe(21);
|
|
78
|
+
|
|
79
|
+
waitFor(() => {
|
|
80
|
+
fireEvent.click(screen.getByText("Show more"));
|
|
81
|
+
|
|
82
|
+
const loadedRows = within(tableElement).getAllByRole("row", {
|
|
83
|
+
hidden: false,
|
|
84
|
+
});
|
|
85
|
+
expect(loadedRows.length).toBe(41);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("resets the rows when searching", async () => {
|
|
90
|
+
render(
|
|
91
|
+
<DataView
|
|
92
|
+
availableLayouts={["table"]}
|
|
93
|
+
getData={getData}
|
|
94
|
+
tableLayoutOptions={{
|
|
95
|
+
columns: columns,
|
|
96
|
+
}}
|
|
97
|
+
hasSearch
|
|
98
|
+
hasPagination
|
|
99
|
+
// virtualization has to be false for the tests to work properly
|
|
100
|
+
enableVirtualization={false}
|
|
101
|
+
paginationType="loadMore"
|
|
102
|
+
resultsPerPage={20}
|
|
103
|
+
/>,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const tableElement = await screen.findByRole("table", { name: "" });
|
|
107
|
+
const rowElements = within(tableElement).getAllByRole("row", {
|
|
108
|
+
hidden: false,
|
|
109
|
+
});
|
|
110
|
+
expect(rowElements.length).toBe(21);
|
|
111
|
+
|
|
112
|
+
fireEvent.click(screen.getByText("Show more"));
|
|
113
|
+
|
|
114
|
+
waitFor(() => {
|
|
115
|
+
const loadedRows = within(tableElement).getAllByRole("row", {
|
|
116
|
+
hidden: false,
|
|
117
|
+
});
|
|
118
|
+
expect(loadedRows.length).toBe(41);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const searchField = screen.getByPlaceholderText("Search");
|
|
122
|
+
fireEvent.change(searchField, { target: { value: "John" } });
|
|
123
|
+
|
|
124
|
+
waitFor(() => {
|
|
125
|
+
const rowsAfterFilter = within(tableElement).getAllByRole("row", {
|
|
126
|
+
hidden: false,
|
|
127
|
+
});
|
|
128
|
+
expect(rowsAfterFilter.length).toBeLessThanOrEqual(21);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("fires onPaginationChange when pagination changes", async () => {
|
|
133
|
+
let currentPage = 1;
|
|
134
|
+
const onPaginationChange = (pagination: {
|
|
135
|
+
pageIndex: number;
|
|
136
|
+
pageSize: number;
|
|
137
|
+
}) => {
|
|
138
|
+
currentPage = pagination.pageIndex;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
render(
|
|
142
|
+
<>
|
|
143
|
+
<DataView
|
|
144
|
+
getData={getData}
|
|
145
|
+
hasPagination
|
|
146
|
+
onPaginationChange={onPaginationChange}
|
|
147
|
+
/>
|
|
148
|
+
</>,
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const nextButton = screen.getByLabelText("Next page");
|
|
152
|
+
fireEvent.click(nextButton);
|
|
153
|
+
|
|
154
|
+
await waitFor(() => {
|
|
155
|
+
expect(currentPage).toBe(2);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
});
|