@okta/odyssey-react-mui 1.23.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/Autocomplete.js +2 -0
  3. package/dist/Autocomplete.js.map +1 -1
  4. package/dist/Banner.js +6 -2
  5. package/dist/Banner.js.map +1 -1
  6. package/dist/Callout.js +6 -2
  7. package/dist/Callout.js.map +1 -1
  8. package/dist/ContrastModeProvider.js +86 -0
  9. package/dist/ContrastModeProvider.js.map +1 -0
  10. package/dist/FieldHint.js +20 -6
  11. package/dist/FieldHint.js.map +1 -1
  12. package/dist/Link.js.map +1 -1
  13. package/dist/OdysseyProvider.js +40 -20
  14. package/dist/OdysseyProvider.js.map +1 -1
  15. package/dist/Stack.js +32 -0
  16. package/dist/Stack.js.map +1 -0
  17. package/dist/Tag.js +64 -22
  18. package/dist/Tag.js.map +1 -1
  19. package/dist/Typography.js +27 -6
  20. package/dist/Typography.js.map +1 -1
  21. package/dist/index.js +2 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.scss +8 -4
  24. package/dist/labs/datePickerTheme.js +3 -6
  25. package/dist/labs/datePickerTheme.js.map +1 -1
  26. package/dist/src/Autocomplete.d.ts +7 -1
  27. package/dist/src/Autocomplete.d.ts.map +1 -1
  28. package/dist/src/Banner.d.ts +16 -12
  29. package/dist/src/Banner.d.ts.map +1 -1
  30. package/dist/src/Callout.d.ts +9 -9
  31. package/dist/src/Callout.d.ts.map +1 -1
  32. package/dist/src/ContrastModeProvider.d.ts +34 -0
  33. package/dist/src/ContrastModeProvider.d.ts.map +1 -0
  34. package/dist/src/FieldHint.d.ts.map +1 -1
  35. package/dist/src/Link.d.ts +3 -1
  36. package/dist/src/Link.d.ts.map +1 -1
  37. package/dist/src/OdysseyProvider.d.ts +5 -3
  38. package/dist/src/OdysseyProvider.d.ts.map +1 -1
  39. package/dist/src/Stack.d.ts +33 -0
  40. package/dist/src/Stack.d.ts.map +1 -0
  41. package/dist/src/Tag.d.ts.map +1 -1
  42. package/dist/src/Typography.d.ts +3 -2
  43. package/dist/src/Typography.d.ts.map +1 -1
  44. package/dist/src/index.d.ts +6 -2
  45. package/dist/src/index.d.ts.map +1 -1
  46. package/dist/src/labs/datePickerTheme.d.ts.map +1 -1
  47. package/dist/src/theme/components.d.ts.map +1 -1
  48. package/dist/src/theme/palette.d.ts.map +1 -1
  49. package/dist/src/theme/palette.types.d.ts +2 -0
  50. package/dist/src/theme/palette.types.d.ts.map +1 -1
  51. package/dist/theme/components.js +276 -273
  52. package/dist/theme/components.js.map +1 -1
  53. package/dist/theme/palette.js +2 -1
  54. package/dist/theme/palette.js.map +1 -1
  55. package/dist/theme/palette.types.js.map +1 -1
  56. package/dist/tsconfig.production.tsbuildinfo +1 -1
  57. package/package.json +3 -3
  58. package/src/Autocomplete.tsx +13 -0
  59. package/src/Banner.tsx +29 -14
  60. package/src/Callout.tsx +18 -11
  61. package/src/ContrastModeProvider.tsx +131 -0
  62. package/src/FieldHint.tsx +28 -4
  63. package/src/Link.tsx +3 -1
  64. package/src/OdysseyProvider.tsx +54 -27
  65. package/src/Stack.tsx +56 -0
  66. package/src/Tag.tsx +65 -21
  67. package/src/Typography.test.tsx +26 -0
  68. package/src/Typography.tsx +38 -6
  69. package/src/index.ts +4 -0
  70. package/src/labs/datePickerTheme.tsx +2 -6
  71. package/src/theme/components.tsx +285 -283
  72. package/src/theme/palette.ts +2 -1
  73. package/src/theme/palette.types.ts +2 -0
package/src/Tag.tsx CHANGED
@@ -21,6 +21,7 @@ import {
21
21
  useOdysseyDesignTokens,
22
22
  } from "./OdysseyDesignTokensContext";
23
23
  import { CloseCircleFilledIcon } from "./icons.generated";
24
+ import { useContrastContext, ContrastMode } from "./ContrastModeProvider";
24
25
 
25
26
  export const tagColorVariants = [
26
27
  "default",
@@ -57,61 +58,98 @@ export type TagProps = {
57
58
  const getChipColors = (
58
59
  colorVariant: TagColorVariant,
59
60
  odysseyDesignTokens: DesignTokens,
61
+ contrastMode: ContrastMode,
60
62
  ) => {
61
63
  const colors = {
62
64
  default: {
63
- background: odysseyDesignTokens.HueNeutral100,
65
+ ...(contrastMode === "lowContrast" && {
66
+ background: odysseyDesignTokens.HueNeutral200,
67
+ text: odysseyDesignTokens.HueNeutral700,
68
+ }),
69
+ ...(contrastMode === "highContrast" && {
70
+ background: odysseyDesignTokens.HueNeutral100,
71
+ text: odysseyDesignTokens.HueNeutral700,
72
+ }),
64
73
  hover: odysseyDesignTokens.HueNeutral200,
65
74
  active: odysseyDesignTokens.HueNeutral300,
66
- text: odysseyDesignTokens.HueNeutral700,
67
75
  border: odysseyDesignTokens.HueNeutral200,
68
76
  deleteIcon: odysseyDesignTokens.HueNeutral500,
69
- deleteIconHover: odysseyDesignTokens.HueNeutral600,
77
+ deleteIconHover: odysseyDesignTokens.HueNeutral700,
70
78
  },
71
79
  info: {
72
- background: odysseyDesignTokens.HueBlue100,
80
+ ...(contrastMode === "lowContrast" && {
81
+ background: odysseyDesignTokens.HueBlue200,
82
+ text: odysseyDesignTokens.HueBlue700,
83
+ }),
84
+ ...(contrastMode === "highContrast" && {
85
+ background: odysseyDesignTokens.HueBlue100,
86
+ text: odysseyDesignTokens.HueBlue700,
87
+ }),
73
88
  hover: odysseyDesignTokens.HueBlue200,
74
89
  active: odysseyDesignTokens.HueBlue300,
75
- text: odysseyDesignTokens.HueBlue700,
76
90
  border: odysseyDesignTokens.HueBlue200,
77
91
  deleteIcon: odysseyDesignTokens.HueBlue500,
78
- deleteIconHover: odysseyDesignTokens.HueBlue600,
92
+ deleteIconHover: odysseyDesignTokens.HueBlue700,
79
93
  },
80
94
  accentOne: {
81
- background: odysseyDesignTokens.HueAccentOne100,
95
+ ...(contrastMode === "lowContrast" && {
96
+ background: odysseyDesignTokens.HueAccentOne200,
97
+ text: odysseyDesignTokens.HueAccentOne700,
98
+ }),
99
+ ...(contrastMode === "highContrast" && {
100
+ background: odysseyDesignTokens.HueAccentOne100,
101
+ text: odysseyDesignTokens.HueAccentOne700,
102
+ }),
82
103
  hover: odysseyDesignTokens.HueAccentOne200,
83
104
  active: odysseyDesignTokens.HueAccentOne300,
84
- text: odysseyDesignTokens.HueAccentOne700,
85
105
  border: odysseyDesignTokens.HueAccentOne200,
86
106
  deleteIcon: odysseyDesignTokens.HueAccentOne500,
87
- deleteIconHover: odysseyDesignTokens.HueAccentOne600,
107
+ deleteIconHover: odysseyDesignTokens.HueAccentOne700,
88
108
  },
89
109
  accentTwo: {
90
- background: odysseyDesignTokens.HueAccentTwo100,
110
+ ...(contrastMode === "lowContrast" && {
111
+ background: odysseyDesignTokens.HueAccentTwo200,
112
+ text: odysseyDesignTokens.HueAccentTwo800,
113
+ }),
114
+ ...(contrastMode === "highContrast" && {
115
+ background: odysseyDesignTokens.HueAccentTwo100,
116
+ text: odysseyDesignTokens.HueAccentTwo700,
117
+ }),
91
118
  hover: odysseyDesignTokens.HueAccentTwo200,
92
119
  active: odysseyDesignTokens.HueAccentTwo300,
93
- text: odysseyDesignTokens.HueAccentTwo700,
94
120
  border: odysseyDesignTokens.HueAccentTwo200,
95
121
  deleteIcon: odysseyDesignTokens.HueAccentTwo500,
96
- deleteIconHover: odysseyDesignTokens.HueAccentTwo600,
122
+ deleteIconHover: odysseyDesignTokens.HueAccentTwo700,
97
123
  },
98
124
  accentThree: {
99
- background: odysseyDesignTokens.HueAccentThree100,
125
+ ...(contrastMode === "lowContrast" && {
126
+ background: odysseyDesignTokens.HueAccentThree200,
127
+ text: odysseyDesignTokens.HueAccentThree700,
128
+ }),
129
+ ...(contrastMode === "highContrast" && {
130
+ background: odysseyDesignTokens.HueAccentThree100,
131
+ text: odysseyDesignTokens.HueAccentThree700,
132
+ }),
100
133
  hover: odysseyDesignTokens.HueAccentThree200,
101
134
  active: odysseyDesignTokens.HueAccentThree300,
102
- text: odysseyDesignTokens.HueAccentThree700,
103
135
  border: odysseyDesignTokens.HueAccentThree200,
104
136
  deleteIcon: odysseyDesignTokens.HueAccentThree500,
105
- deleteIconHover: odysseyDesignTokens.HueAccentThree600,
137
+ deleteIconHover: odysseyDesignTokens.HueAccentThree700,
106
138
  },
107
139
  accentFour: {
108
- background: odysseyDesignTokens.HueAccentFour100,
140
+ ...(contrastMode === "lowContrast" && {
141
+ background: odysseyDesignTokens.HueAccentFour200,
142
+ text: odysseyDesignTokens.HueAccentFour700,
143
+ }),
144
+ ...(contrastMode === "highContrast" && {
145
+ background: odysseyDesignTokens.HueAccentFour100,
146
+ text: odysseyDesignTokens.HueAccentFour700,
147
+ }),
109
148
  hover: odysseyDesignTokens.HueAccentFour200,
110
149
  active: odysseyDesignTokens.HueAccentFour300,
111
- text: odysseyDesignTokens.HueAccentFour700,
112
150
  border: odysseyDesignTokens.HueAccentFour200,
113
151
  deleteIcon: odysseyDesignTokens.HueAccentFour500,
114
- deleteIconHover: odysseyDesignTokens.HueAccentFour600,
152
+ deleteIconHover: odysseyDesignTokens.HueAccentFour700,
115
153
  },
116
154
  };
117
155
 
@@ -120,13 +158,16 @@ const getChipColors = (
120
158
 
121
159
  const StyledTag = styled(MuiChip, {
122
160
  shouldForwardProp: (prop) =>
123
- !["colorVariant", "odysseyDesignTokens"].includes(prop as string),
161
+ !["colorVariant", "contrastMode", "odysseyDesignTokens"].includes(
162
+ prop as string,
163
+ ),
124
164
  })<{
125
165
  colorVariant: TagColorVariant;
166
+ contrastMode: ContrastMode;
126
167
  odysseyDesignTokens: DesignTokens;
127
168
  as?: React.ElementType; // Allow the 'as' prop to be forwarded
128
- }>(({ colorVariant, odysseyDesignTokens }) => {
129
- const colors = getChipColors(colorVariant, odysseyDesignTokens);
169
+ }>(({ colorVariant, contrastMode, odysseyDesignTokens }) => {
170
+ const colors = getChipColors(colorVariant, odysseyDesignTokens, contrastMode);
130
171
 
131
172
  return {
132
173
  backgroundColor: colors.background,
@@ -169,6 +210,7 @@ const Tag = ({
169
210
  }: TagProps) => {
170
211
  const odysseyDesignTokens = useOdysseyDesignTokens();
171
212
  const { chipElementType } = useContext(TagListContext);
213
+ const { contrastMode } = useContrastContext();
172
214
 
173
215
  const renderTag = useCallback(
174
216
  (muiProps: MuiPropsContextType) => (
@@ -180,6 +222,7 @@ const Tag = ({
180
222
  data-se={testId}
181
223
  colorVariant={colorVariant}
182
224
  odysseyDesignTokens={odysseyDesignTokens}
225
+ contrastMode={contrastMode}
183
226
  disabled={isDisabled}
184
227
  icon={icon}
185
228
  label={label}
@@ -200,6 +243,7 @@ const Tag = ({
200
243
  translate,
201
244
  colorVariant,
202
245
  odysseyDesignTokens,
246
+ contrastMode,
203
247
  ],
204
248
  );
205
249
 
@@ -0,0 +1,26 @@
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 { render, screen } from "@testing-library/react";
14
+ import { Typography } from "./Typography";
15
+
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
+ });
@@ -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 (variant === "body") {
106
- return "p";
107
- } else if (variant === "subordinate" || variant === "support") {
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,
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";
@@ -100,6 +103,7 @@ export * from "./RadioGroup";
100
103
  export * from "./ScreenReaderText";
101
104
  export * from "./SearchField";
102
105
  export * from "./Select";
106
+ export * from "./Stack";
103
107
  export * from "./Status";
104
108
  export * from "./Surface";
105
109
  export * from "./Tabs";
@@ -47,10 +47,6 @@ const dateStyles: StateStyles = {
47
47
  hoverSelected: ({ theme }) => ({
48
48
  backgroundColor: theme.palette.primary.dark,
49
49
  color: theme.palette.primary.contrastText,
50
-
51
- "@media (pointer: fine)": {
52
- backgroundColor: theme.palette.primary.main,
53
- },
54
50
  }),
55
51
  outsideOfMonth: ({ theme }) => ({
56
52
  backgroundColor: "transparent",
@@ -158,8 +154,8 @@ export const datePickerTheme: ThemeOptions = {
158
154
  borderStyle: theme.mixins.borderStyle,
159
155
  borderWidth: theme.mixins.borderWidth,
160
156
  borderRadius: theme.mixins.borderRadius,
161
- paddingBlock: theme.spacing(3),
162
- paddingInline: theme.spacing(3),
157
+ paddingBlock: theme.spacing(6),
158
+ paddingInline: theme.spacing(6),
163
159
  },
164
160
  }),
165
161
  },