@okta/odyssey-react-mui 1.22.0 → 1.24.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 +40 -0
- package/dist/@types/i18next.d.js.map +1 -1
- package/dist/Autocomplete.js +32 -0
- package/dist/Autocomplete.js.map +1 -1
- package/dist/Banner.js +6 -2
- package/dist/Banner.js.map +1 -1
- package/dist/Callout.js +18 -26
- package/dist/Callout.js.map +1 -1
- package/dist/ContrastModeProvider.js +86 -0
- package/dist/ContrastModeProvider.js.map +1 -0
- package/dist/DataTable/useScrollIndication.js +7 -3
- package/dist/DataTable/useScrollIndication.js.map +1 -1
- package/dist/FieldHint.js +20 -6
- package/dist/FieldHint.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/Link.js.map +1 -1
- package/dist/OdysseyProvider.js +43 -19
- 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/Stack.js +32 -0
- package/dist/Stack.js.map +1 -0
- 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 +144 -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/Typography.js +27 -6
- package/dist/Typography.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 +4 -1
- package/dist/index.js.map +1 -1
- package/dist/index.scss +96 -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/datePickerTheme.js +3 -6
- package/dist/labs/datePickerTheme.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 +37 -1
- package/dist/src/Autocomplete.d.ts.map +1 -1
- package/dist/src/Banner.d.ts +16 -12
- package/dist/src/Banner.d.ts.map +1 -1
- package/dist/src/Callout.d.ts +20 -32
- package/dist/src/Callout.d.ts.map +1 -1
- package/dist/src/ContrastModeProvider.d.ts +34 -0
- package/dist/src/ContrastModeProvider.d.ts.map +1 -0
- package/dist/src/DataTable/useScrollIndication.d.ts.map +1 -1
- package/dist/src/FieldHint.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/Link.d.ts +3 -1
- package/dist/src/Link.d.ts.map +1 -1
- package/dist/src/NativeSelect.d.ts +1 -1
- package/dist/src/OdysseyProvider.d.ts +5 -3
- 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/Stack.d.ts +33 -0
- package/dist/src/Stack.d.ts.map +1 -0
- 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/Typography.d.ts +3 -2
- package/dist/src/Typography.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 +8 -3
- 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/datePickerTheme.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/dist/src/test-selectors/getComputedAccessibleErrorMessageText.d.ts +14 -0
- 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/palette.d.ts.map +1 -1
- package/dist/src/theme/palette.types.d.ts +2 -0
- package/dist/src/theme/palette.types.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 +276 -274
- package/dist/theme/components.js.map +1 -1
- package/dist/theme/palette.js +2 -1
- package/dist/theme/palette.js.map +1 -1
- package/dist/theme/palette.types.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 +45 -0
- package/src/Banner.tsx +29 -14
- package/src/Callout.tsx +31 -36
- package/src/ContrastModeProvider.tsx +131 -0
- package/src/DataTable/useScrollIndication.tsx +9 -2
- package/src/FieldHint.tsx +28 -4
- 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/Link.tsx +3 -1
- package/src/OdysseyCacheProvider.test.tsx +1 -0
- package/src/OdysseyProvider.tsx +58 -26
- package/src/Radio.tsx +2 -2
- package/src/Select.tsx +38 -0
- package/src/Stack.tsx +56 -0
- package/src/{labs/Switch.tsx → Switch.tsx} +10 -10
- package/src/Tabs.tsx +8 -10
- package/src/Tag.tsx +178 -3
- package/src/TextField.tsx +18 -41
- package/src/Toast.tsx +1 -1
- package/src/{test-selectors/odysseyTestSelectors.ts → Typography.test.tsx} +13 -9
- package/src/Typography.tsx +38 -6
- package/src/createShadowDomElements.ts +3 -0
- package/src/i18n.ts +3 -3
- package/src/index.ts +10 -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/datePickerTheme.tsx +2 -6
- 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 +284 -284
- package/src/theme/palette.ts +2 -1
- package/src/theme/palette.types.ts +2 -0
- 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/Tag.tsx
CHANGED
|
@@ -12,9 +12,27 @@
|
|
|
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
|
+
import { useContrastContext, ContrastMode } from "./ContrastModeProvider";
|
|
25
|
+
|
|
26
|
+
export const tagColorVariants = [
|
|
27
|
+
"default",
|
|
28
|
+
"info",
|
|
29
|
+
"accentOne",
|
|
30
|
+
"accentTwo",
|
|
31
|
+
"accentThree",
|
|
32
|
+
"accentFour",
|
|
33
|
+
] as const;
|
|
34
|
+
|
|
35
|
+
type TagColorVariant = (typeof tagColorVariants)[number];
|
|
18
36
|
|
|
19
37
|
export type TagProps = {
|
|
20
38
|
icon?: ReactElement;
|
|
@@ -31,9 +49,157 @@ export type TagProps = {
|
|
|
31
49
|
* Callback fired when the remove button of the Tag is clicked
|
|
32
50
|
*/
|
|
33
51
|
onRemove?: MuiChipProps["onDelete"];
|
|
52
|
+
/**
|
|
53
|
+
* Color variant of the Tag, affecting its appearance
|
|
54
|
+
*/
|
|
55
|
+
colorVariant?: TagColorVariant;
|
|
34
56
|
} & Pick<HtmlProps, "testId" | "translate">;
|
|
35
57
|
|
|
58
|
+
const getChipColors = (
|
|
59
|
+
colorVariant: TagColorVariant,
|
|
60
|
+
odysseyDesignTokens: DesignTokens,
|
|
61
|
+
contrastMode: ContrastMode,
|
|
62
|
+
) => {
|
|
63
|
+
const colors = {
|
|
64
|
+
default: {
|
|
65
|
+
...(contrastMode === "lowContrast" && {
|
|
66
|
+
background: odysseyDesignTokens.HueNeutral200,
|
|
67
|
+
text: odysseyDesignTokens.HueNeutral700,
|
|
68
|
+
}),
|
|
69
|
+
...(contrastMode === "highContrast" && {
|
|
70
|
+
background: odysseyDesignTokens.HueNeutral100,
|
|
71
|
+
text: odysseyDesignTokens.HueNeutral700,
|
|
72
|
+
}),
|
|
73
|
+
hover: odysseyDesignTokens.HueNeutral200,
|
|
74
|
+
active: odysseyDesignTokens.HueNeutral300,
|
|
75
|
+
border: odysseyDesignTokens.HueNeutral200,
|
|
76
|
+
deleteIcon: odysseyDesignTokens.HueNeutral500,
|
|
77
|
+
deleteIconHover: odysseyDesignTokens.HueNeutral700,
|
|
78
|
+
},
|
|
79
|
+
info: {
|
|
80
|
+
...(contrastMode === "lowContrast" && {
|
|
81
|
+
background: odysseyDesignTokens.HueBlue200,
|
|
82
|
+
text: odysseyDesignTokens.HueBlue700,
|
|
83
|
+
}),
|
|
84
|
+
...(contrastMode === "highContrast" && {
|
|
85
|
+
background: odysseyDesignTokens.HueBlue100,
|
|
86
|
+
text: odysseyDesignTokens.HueBlue700,
|
|
87
|
+
}),
|
|
88
|
+
hover: odysseyDesignTokens.HueBlue200,
|
|
89
|
+
active: odysseyDesignTokens.HueBlue300,
|
|
90
|
+
border: odysseyDesignTokens.HueBlue200,
|
|
91
|
+
deleteIcon: odysseyDesignTokens.HueBlue500,
|
|
92
|
+
deleteIconHover: odysseyDesignTokens.HueBlue700,
|
|
93
|
+
},
|
|
94
|
+
accentOne: {
|
|
95
|
+
...(contrastMode === "lowContrast" && {
|
|
96
|
+
background: odysseyDesignTokens.HueAccentOne200,
|
|
97
|
+
text: odysseyDesignTokens.HueAccentOne700,
|
|
98
|
+
}),
|
|
99
|
+
...(contrastMode === "highContrast" && {
|
|
100
|
+
background: odysseyDesignTokens.HueAccentOne100,
|
|
101
|
+
text: odysseyDesignTokens.HueAccentOne700,
|
|
102
|
+
}),
|
|
103
|
+
hover: odysseyDesignTokens.HueAccentOne200,
|
|
104
|
+
active: odysseyDesignTokens.HueAccentOne300,
|
|
105
|
+
border: odysseyDesignTokens.HueAccentOne200,
|
|
106
|
+
deleteIcon: odysseyDesignTokens.HueAccentOne500,
|
|
107
|
+
deleteIconHover: odysseyDesignTokens.HueAccentOne700,
|
|
108
|
+
},
|
|
109
|
+
accentTwo: {
|
|
110
|
+
...(contrastMode === "lowContrast" && {
|
|
111
|
+
background: odysseyDesignTokens.HueAccentTwo200,
|
|
112
|
+
text: odysseyDesignTokens.HueAccentTwo800,
|
|
113
|
+
}),
|
|
114
|
+
...(contrastMode === "highContrast" && {
|
|
115
|
+
background: odysseyDesignTokens.HueAccentTwo100,
|
|
116
|
+
text: odysseyDesignTokens.HueAccentTwo700,
|
|
117
|
+
}),
|
|
118
|
+
hover: odysseyDesignTokens.HueAccentTwo200,
|
|
119
|
+
active: odysseyDesignTokens.HueAccentTwo300,
|
|
120
|
+
border: odysseyDesignTokens.HueAccentTwo200,
|
|
121
|
+
deleteIcon: odysseyDesignTokens.HueAccentTwo500,
|
|
122
|
+
deleteIconHover: odysseyDesignTokens.HueAccentTwo700,
|
|
123
|
+
},
|
|
124
|
+
accentThree: {
|
|
125
|
+
...(contrastMode === "lowContrast" && {
|
|
126
|
+
background: odysseyDesignTokens.HueAccentThree200,
|
|
127
|
+
text: odysseyDesignTokens.HueAccentThree700,
|
|
128
|
+
}),
|
|
129
|
+
...(contrastMode === "highContrast" && {
|
|
130
|
+
background: odysseyDesignTokens.HueAccentThree100,
|
|
131
|
+
text: odysseyDesignTokens.HueAccentThree700,
|
|
132
|
+
}),
|
|
133
|
+
hover: odysseyDesignTokens.HueAccentThree200,
|
|
134
|
+
active: odysseyDesignTokens.HueAccentThree300,
|
|
135
|
+
border: odysseyDesignTokens.HueAccentThree200,
|
|
136
|
+
deleteIcon: odysseyDesignTokens.HueAccentThree500,
|
|
137
|
+
deleteIconHover: odysseyDesignTokens.HueAccentThree700,
|
|
138
|
+
},
|
|
139
|
+
accentFour: {
|
|
140
|
+
...(contrastMode === "lowContrast" && {
|
|
141
|
+
background: odysseyDesignTokens.HueAccentFour200,
|
|
142
|
+
text: odysseyDesignTokens.HueAccentFour700,
|
|
143
|
+
}),
|
|
144
|
+
...(contrastMode === "highContrast" && {
|
|
145
|
+
background: odysseyDesignTokens.HueAccentFour100,
|
|
146
|
+
text: odysseyDesignTokens.HueAccentFour700,
|
|
147
|
+
}),
|
|
148
|
+
hover: odysseyDesignTokens.HueAccentFour200,
|
|
149
|
+
active: odysseyDesignTokens.HueAccentFour300,
|
|
150
|
+
border: odysseyDesignTokens.HueAccentFour200,
|
|
151
|
+
deleteIcon: odysseyDesignTokens.HueAccentFour500,
|
|
152
|
+
deleteIconHover: odysseyDesignTokens.HueAccentFour700,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
return colors[colorVariant] || colors.default;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const StyledTag = styled(MuiChip, {
|
|
160
|
+
shouldForwardProp: (prop) =>
|
|
161
|
+
!["colorVariant", "contrastMode", "odysseyDesignTokens"].includes(
|
|
162
|
+
prop as string,
|
|
163
|
+
),
|
|
164
|
+
})<{
|
|
165
|
+
colorVariant: TagColorVariant;
|
|
166
|
+
contrastMode: ContrastMode;
|
|
167
|
+
odysseyDesignTokens: DesignTokens;
|
|
168
|
+
as?: React.ElementType; // Allow the 'as' prop to be forwarded
|
|
169
|
+
}>(({ colorVariant, contrastMode, odysseyDesignTokens }) => {
|
|
170
|
+
const colors = getChipColors(colorVariant, odysseyDesignTokens, contrastMode);
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
backgroundColor: colors.background,
|
|
174
|
+
color: colors.text,
|
|
175
|
+
borderColor: colors.border,
|
|
176
|
+
|
|
177
|
+
"&.MuiChip-clickable:hover": {
|
|
178
|
+
backgroundColor: colors.hover,
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
"&.MuiChip-clickable:active": {
|
|
182
|
+
backgroundColor: colors.active,
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
"&.Mui-disabled": {
|
|
186
|
+
"& .MuiChip-deleteIcon": {
|
|
187
|
+
color: odysseyDesignTokens.HueNeutral300,
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
"& .MuiChip-deleteIcon": {
|
|
192
|
+
color: colors.deleteIcon,
|
|
193
|
+
|
|
194
|
+
"&:hover": {
|
|
195
|
+
color: colors.deleteIconHover,
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
|
|
36
201
|
const Tag = ({
|
|
202
|
+
colorVariant = "default",
|
|
37
203
|
icon,
|
|
38
204
|
isDisabled,
|
|
39
205
|
label,
|
|
@@ -42,21 +208,27 @@ const Tag = ({
|
|
|
42
208
|
testId,
|
|
43
209
|
translate,
|
|
44
210
|
}: TagProps) => {
|
|
211
|
+
const odysseyDesignTokens = useOdysseyDesignTokens();
|
|
45
212
|
const { chipElementType } = useContext(TagListContext);
|
|
213
|
+
const { contrastMode } = useContrastContext();
|
|
46
214
|
|
|
47
215
|
const renderTag = useCallback(
|
|
48
216
|
(muiProps: MuiPropsContextType) => (
|
|
49
|
-
<
|
|
217
|
+
<StyledTag
|
|
50
218
|
{...muiProps}
|
|
219
|
+
as={chipElementType}
|
|
51
220
|
aria-disabled={isDisabled}
|
|
52
|
-
clickable={onClick
|
|
53
|
-
component={chipElementType}
|
|
221
|
+
clickable={Boolean(onClick)}
|
|
54
222
|
data-se={testId}
|
|
223
|
+
colorVariant={colorVariant}
|
|
224
|
+
odysseyDesignTokens={odysseyDesignTokens}
|
|
225
|
+
contrastMode={contrastMode}
|
|
55
226
|
disabled={isDisabled}
|
|
56
227
|
icon={icon}
|
|
57
228
|
label={label}
|
|
58
229
|
onClick={onClick}
|
|
59
230
|
onDelete={onRemove}
|
|
231
|
+
deleteIcon={<CloseCircleFilledIcon />}
|
|
60
232
|
translate={translate}
|
|
61
233
|
/>
|
|
62
234
|
),
|
|
@@ -69,6 +241,9 @@ const Tag = ({
|
|
|
69
241
|
onRemove,
|
|
70
242
|
testId,
|
|
71
243
|
translate,
|
|
244
|
+
colorVariant,
|
|
245
|
+
odysseyDesignTokens,
|
|
246
|
+
contrastMode,
|
|
72
247
|
],
|
|
73
248
|
);
|
|
74
249
|
|
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
|
@@ -10,13 +10,17 @@
|
|
|
10
10
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { TabsTestSelectors } from "../Tabs";
|
|
16
|
-
import { TextFieldTestSelectors } from "../TextField";
|
|
13
|
+
import { render, screen } from "@testing-library/react";
|
|
14
|
+
import { Typography } from "./Typography";
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
describe("Typography", () => {
|
|
17
|
+
test("renders Overline", () => {
|
|
18
|
+
render(
|
|
19
|
+
<Typography ariaLabel="overline" variant="overline">
|
|
20
|
+
Overline test
|
|
21
|
+
</Typography>,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
expect(screen.getByLabelText("overline")).toBeVisible();
|
|
25
|
+
});
|
|
26
|
+
});
|
package/src/Typography.tsx
CHANGED
|
@@ -34,9 +34,10 @@ export type TypographyVariantValue =
|
|
|
34
34
|
| "h5"
|
|
35
35
|
| "h6"
|
|
36
36
|
| "body"
|
|
37
|
+
| "legend"
|
|
38
|
+
| "overline"
|
|
37
39
|
| "subordinate"
|
|
38
|
-
| "support"
|
|
39
|
-
| "legend";
|
|
40
|
+
| "support";
|
|
40
41
|
|
|
41
42
|
export const typographyVariantMapping: Record<
|
|
42
43
|
TypographyVariantValue,
|
|
@@ -49,9 +50,10 @@ export const typographyVariantMapping: Record<
|
|
|
49
50
|
h5: "h5",
|
|
50
51
|
h6: "h6",
|
|
51
52
|
body: "body1",
|
|
53
|
+
legend: "legend",
|
|
54
|
+
overline: "overline",
|
|
52
55
|
subordinate: "subtitle1",
|
|
53
56
|
support: "subtitle2",
|
|
54
|
-
legend: "legend",
|
|
55
57
|
} as const;
|
|
56
58
|
|
|
57
59
|
export const typographyColorValues = [
|
|
@@ -102,9 +104,12 @@ const Typography = ({
|
|
|
102
104
|
}: TypographyProps) => {
|
|
103
105
|
const component = useMemo(() => {
|
|
104
106
|
if (!componentProp) {
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
if (
|
|
108
|
+
variant === "body" ||
|
|
109
|
+
variant === "subordinate" ||
|
|
110
|
+
variant === "support" ||
|
|
111
|
+
variant === "overline"
|
|
112
|
+
) {
|
|
108
113
|
return "p";
|
|
109
114
|
} else {
|
|
110
115
|
return variant;
|
|
@@ -406,6 +411,32 @@ const Legend = ({
|
|
|
406
411
|
const MemoizedLegend = memo(Legend);
|
|
407
412
|
MemoizedLegend.displayName = "Legend";
|
|
408
413
|
|
|
414
|
+
const Overline = ({
|
|
415
|
+
ariaDescribedBy,
|
|
416
|
+
ariaLabel,
|
|
417
|
+
ariaLabelledBy,
|
|
418
|
+
children,
|
|
419
|
+
color,
|
|
420
|
+
component,
|
|
421
|
+
testId,
|
|
422
|
+
translate,
|
|
423
|
+
}: TypographyProps) => (
|
|
424
|
+
<Typography
|
|
425
|
+
ariaDescribedBy={ariaDescribedBy}
|
|
426
|
+
ariaLabel={ariaLabel}
|
|
427
|
+
ariaLabelledBy={ariaLabelledBy}
|
|
428
|
+
children={children}
|
|
429
|
+
color={color}
|
|
430
|
+
component={component}
|
|
431
|
+
testId={testId}
|
|
432
|
+
translate={translate}
|
|
433
|
+
variant="overline"
|
|
434
|
+
/>
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
const MemoizedOverline = memo(Overline);
|
|
438
|
+
MemoizedOverline.displayName = "Overline";
|
|
439
|
+
|
|
409
440
|
export {
|
|
410
441
|
MemoizedTypography as Typography,
|
|
411
442
|
MemoizedHeading1 as Heading1,
|
|
@@ -415,6 +446,7 @@ export {
|
|
|
415
446
|
MemoizedHeading5 as Heading5,
|
|
416
447
|
MemoizedHeading6 as Heading6,
|
|
417
448
|
MemoizedLegend as Legend,
|
|
449
|
+
MemoizedOverline as Overline,
|
|
418
450
|
MemoizedParagraph as Paragraph,
|
|
419
451
|
MemoizedSubordinate as Subordinate,
|
|
420
452
|
MemoizedSupport as Support,
|
|
@@ -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
|
@@ -34,6 +34,7 @@ export {
|
|
|
34
34
|
Paper,
|
|
35
35
|
/** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */
|
|
36
36
|
ScopedCssBaseline,
|
|
37
|
+
/** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */
|
|
37
38
|
ThemeProvider,
|
|
38
39
|
} from "@mui/material";
|
|
39
40
|
|
|
@@ -49,6 +50,7 @@ export type {
|
|
|
49
50
|
MenuListProps,
|
|
50
51
|
PaperProps,
|
|
51
52
|
ScopedCssBaselineProps,
|
|
53
|
+
StackProps,
|
|
52
54
|
ThemeOptions,
|
|
53
55
|
} from "@mui/material";
|
|
54
56
|
|
|
@@ -68,6 +70,7 @@ export * from "./Callout";
|
|
|
68
70
|
export * from "./Checkbox";
|
|
69
71
|
export * from "./CheckboxGroup";
|
|
70
72
|
export * from "./CircularProgress";
|
|
73
|
+
export * from "./ContrastModeProvider";
|
|
71
74
|
export * from "./CssBaseline";
|
|
72
75
|
export * from "./createShadowDomElements";
|
|
73
76
|
export * from "./createUniqueId";
|
|
@@ -77,6 +80,11 @@ export * from "./Drawer";
|
|
|
77
80
|
export * from "./EmptyState";
|
|
78
81
|
export * from "./Fieldset";
|
|
79
82
|
export * from "./FieldComponentProps";
|
|
83
|
+
export {
|
|
84
|
+
FileUploader,
|
|
85
|
+
fileUploadTypes,
|
|
86
|
+
fileUploadVariants,
|
|
87
|
+
} from "./FileUploader";
|
|
80
88
|
export * from "./Form";
|
|
81
89
|
export * from "./HintLink";
|
|
82
90
|
export * from "./IconWithTooltip";
|
|
@@ -95,6 +103,7 @@ export * from "./RadioGroup";
|
|
|
95
103
|
export * from "./ScreenReaderText";
|
|
96
104
|
export * from "./SearchField";
|
|
97
105
|
export * from "./Select";
|
|
106
|
+
export * from "./Stack";
|
|
98
107
|
export * from "./Status";
|
|
99
108
|
export * from "./Surface";
|
|
100
109
|
export * from "./Tabs";
|
|
@@ -104,7 +113,7 @@ export * from "./TextField";
|
|
|
104
113
|
export * from "./theme";
|
|
105
114
|
export * from "./Toast";
|
|
106
115
|
export * from "./ToastStack";
|
|
107
|
-
export * from "./
|
|
116
|
+
export * from "./Switch";
|
|
108
117
|
export * from "./Tooltip";
|
|
109
118
|
export * from "./Typography";
|
|
110
119
|
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
|
+
});
|