@okta/odyssey-react-mui 1.6.0 → 1.6.2

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 (92) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/Autocomplete.js.map +1 -1
  3. package/dist/Checkbox.js +3 -2
  4. package/dist/Checkbox.js.map +1 -1
  5. package/dist/CheckboxGroup.js.map +1 -1
  6. package/dist/FieldComponentProps.js +2 -0
  7. package/dist/FieldComponentProps.js.map +1 -0
  8. package/dist/NativeSelect.js.map +1 -1
  9. package/dist/OdysseyCacheProvider.js +7 -1
  10. package/dist/OdysseyCacheProvider.js.map +1 -1
  11. package/dist/OdysseyProvider.js +3 -4
  12. package/dist/OdysseyProvider.js.map +1 -1
  13. package/dist/OdysseyThemeProvider.js +3 -3
  14. package/dist/OdysseyThemeProvider.js.map +1 -1
  15. package/dist/PasswordField.js.map +1 -1
  16. package/dist/Radio.js.map +1 -1
  17. package/dist/RadioGroup.js.map +1 -1
  18. package/dist/SearchField.js.map +1 -1
  19. package/dist/Select.js.map +1 -1
  20. package/dist/TextField.js +1 -0
  21. package/dist/TextField.js.map +1 -1
  22. package/dist/Tooltip.js +5 -1
  23. package/dist/Tooltip.js.map +1 -1
  24. package/dist/{createShadowDom.js → createShadowRootElement.js} +6 -11
  25. package/dist/createShadowRootElement.js.map +1 -0
  26. package/dist/index.js +2 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/src/Autocomplete.d.ts +2 -21
  29. package/dist/src/Autocomplete.d.ts.map +1 -1
  30. package/dist/src/Checkbox.d.ts +2 -13
  31. package/dist/src/Checkbox.d.ts.map +1 -1
  32. package/dist/src/CheckboxGroup.d.ts +2 -13
  33. package/dist/src/CheckboxGroup.d.ts.map +1 -1
  34. package/dist/src/FieldComponentProps.d.ts +42 -0
  35. package/dist/src/FieldComponentProps.d.ts.map +1 -0
  36. package/dist/src/NativeSelect.d.ts +3 -42
  37. package/dist/src/NativeSelect.d.ts.map +1 -1
  38. package/dist/src/OdysseyCacheProvider.d.ts +2 -2
  39. package/dist/src/OdysseyCacheProvider.d.ts.map +1 -1
  40. package/dist/src/OdysseyProvider.d.ts +1 -1
  41. package/dist/src/OdysseyProvider.d.ts.map +1 -1
  42. package/dist/src/OdysseyThemeProvider.d.ts +2 -2
  43. package/dist/src/OdysseyThemeProvider.d.ts.map +1 -1
  44. package/dist/src/PasswordField.d.ts +3 -58
  45. package/dist/src/PasswordField.d.ts.map +1 -1
  46. package/dist/src/Radio.d.ts +2 -9
  47. package/dist/src/Radio.d.ts.map +1 -1
  48. package/dist/src/RadioGroup.d.ts +2 -21
  49. package/dist/src/RadioGroup.d.ts.map +1 -1
  50. package/dist/src/SearchField.d.ts +3 -26
  51. package/dist/src/SearchField.d.ts.map +1 -1
  52. package/dist/src/Select.d.ts +2 -25
  53. package/dist/src/Select.d.ts.map +1 -1
  54. package/dist/src/TextField.d.ts +3 -58
  55. package/dist/src/TextField.d.ts.map +1 -1
  56. package/dist/src/Tooltip.d.ts +2 -1
  57. package/dist/src/Tooltip.d.ts.map +1 -1
  58. package/dist/src/{createShadowDom.d.ts → createShadowRootElement.d.ts} +2 -5
  59. package/dist/src/createShadowRootElement.d.ts.map +1 -0
  60. package/dist/src/index.d.ts +2 -1
  61. package/dist/src/index.d.ts.map +1 -1
  62. package/dist/src/theme/components.d.ts +2 -2
  63. package/dist/src/theme/components.d.ts.map +1 -1
  64. package/dist/src/theme/createOdysseyMuiTheme.d.ts +2 -2
  65. package/dist/theme/components.js +90 -70
  66. package/dist/theme/components.js.map +1 -1
  67. package/dist/theme/createOdysseyMuiTheme.js +2 -2
  68. package/dist/theme/createOdysseyMuiTheme.js.map +1 -1
  69. package/dist/tsconfig.production.tsbuildinfo +1 -1
  70. package/package.json +3 -3
  71. package/src/Autocomplete.tsx +6 -21
  72. package/src/Checkbox.tsx +6 -16
  73. package/src/CheckboxGroup.tsx +3 -13
  74. package/src/FieldComponentProps.ts +42 -0
  75. package/src/NativeSelect.tsx +6 -22
  76. package/src/OdysseyCacheProvider.tsx +12 -2
  77. package/src/OdysseyProvider.tsx +3 -4
  78. package/src/OdysseyThemeProvider.tsx +4 -4
  79. package/src/PasswordField.tsx +3 -29
  80. package/src/Radio.tsx +3 -9
  81. package/src/RadioGroup.tsx +6 -21
  82. package/src/SearchField.tsx +3 -13
  83. package/src/Select.tsx +8 -26
  84. package/src/TextField.tsx +4 -30
  85. package/src/Tooltip.tsx +7 -2
  86. package/src/createShadowRootElement.ts +21 -0
  87. package/src/index.ts +2 -1
  88. package/src/theme/components.tsx +34 -15
  89. package/src/theme/createOdysseyMuiTheme.ts +3 -3
  90. package/dist/createShadowDom.js.map +0 -1
  91. package/dist/src/createShadowDom.d.ts.map +0 -1
  92. package/src/createShadowDom.ts +0 -46
package/src/TextField.tsx CHANGED
@@ -10,7 +10,6 @@
10
10
  * See the License for the specific language governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import { InputAdornment, InputBase } from "@mui/material";
14
13
  import {
15
14
  ChangeEventHandler,
16
15
  FocusEventHandler,
@@ -20,7 +19,9 @@ import {
20
19
  ReactElement,
21
20
  useCallback,
22
21
  } from "react";
22
+ import { InputAdornment, InputBase } from "@mui/material";
23
23
 
24
+ import { FieldComponentProps } from "./FieldComponentProps";
24
25
  import { Field } from "./Field";
25
26
  import { SeleniumProps } from "./SeleniumProps";
26
27
 
@@ -43,46 +44,18 @@ export type TextFieldProps = {
43
44
  * End `InputAdornment` for this component.
44
45
  */
45
46
  endAdornment?: string | ReactElement;
46
- /**
47
- * If `error` is not undefined, the `input` will indicate an error.
48
- */
49
- errorMessage?: string;
50
47
  /**
51
48
  * If `true`, the component will receive focus automatically.
52
49
  */
53
50
  hasInitialFocus?: boolean;
54
- /**
55
- * The helper text content.
56
- */
57
- hint?: string;
58
- /**
59
- * The id of the `input` element.
60
- */
61
- id?: string;
62
- /**
63
- * If `true`, the component is disabled.
64
- */
65
- isDisabled?: boolean;
66
51
  /**
67
52
  * If `true`, a [TextareaAutosize](/material-ui/react-textarea-autosize/) element is rendered.
68
53
  */
69
54
  isMultiline?: boolean;
70
- /**
71
- * If `true`, the `input` element is not required.
72
- */
73
- isOptional?: boolean;
74
- /**
75
- * It prevents the user from changing the value of the field
76
- */
77
- isReadOnly?: boolean;
78
55
  /**
79
56
  * The label for the `input` element.
80
57
  */
81
58
  label: string;
82
- /**
83
- * The name of the `input` element. Defaults to the `id` if not set.
84
- */
85
- name?: string;
86
59
  /**
87
60
  * Callback fired when the `input` element loses focus.
88
61
  */
@@ -111,7 +84,8 @@ export type TextFieldProps = {
111
84
  * The value of the `input` element, required for a controlled component.
112
85
  */
113
86
  value?: string;
114
- } & SeleniumProps;
87
+ } & FieldComponentProps &
88
+ SeleniumProps;
115
89
 
116
90
  const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
117
91
  (
package/src/Tooltip.tsx CHANGED
@@ -14,7 +14,7 @@ import { Tooltip as MuiTooltip } from "@mui/material";
14
14
  import type { TooltipProps as MuiTooltipProps } from "@mui/material";
15
15
 
16
16
  import { MuiPropsChild } from "./MuiPropsChild";
17
- import { ReactElement } from "react";
17
+ import { ReactElement, memo } from "react";
18
18
  import { SeleniumProps } from "./SeleniumProps";
19
19
 
20
20
  export type TooltipProps = {
@@ -36,7 +36,7 @@ export type TooltipProps = {
36
36
  text: string;
37
37
  } & SeleniumProps;
38
38
 
39
- export const Tooltip = ({
39
+ const Tooltip = ({
40
40
  ariaType,
41
41
  children,
42
42
  placement = "top",
@@ -52,3 +52,8 @@ export const Tooltip = ({
52
52
  <MuiPropsChild>{children}</MuiPropsChild>
53
53
  </MuiTooltip>
54
54
  );
55
+
56
+ const MemoizedTooltip = memo(Tooltip);
57
+ MemoizedTooltip.displayName = "Tooltip";
58
+
59
+ export { MemoizedTooltip as Tooltip };
@@ -0,0 +1,21 @@
1
+ /*!
2
+ * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
+ *
5
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * Unless required by applicable law or agreed to in writing, software
7
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ *
10
+ * See the License for the specific language governing permissions and limitations under the License.
11
+ */
12
+
13
+ export const createShadowRootElement = (containerElement: HTMLElement) => {
14
+ const shadowRoot = containerElement.attachShadow({ mode: "open" });
15
+
16
+ const ShadowRootElement = document.createElement("div");
17
+
18
+ shadowRoot.append(ShadowRootElement);
19
+
20
+ return createShadowRootElement;
21
+ };
package/src/index.ts CHANGED
@@ -66,10 +66,11 @@ export * from "./Callout";
66
66
  export * from "./Checkbox";
67
67
  export * from "./CheckboxGroup";
68
68
  export * from "./CircularProgress";
69
- export * from "./createShadowDom";
69
+ export * from "./createShadowRootElement";
70
70
  export * from "./createUniqueId";
71
71
  export * from "./Dialog";
72
72
  export * from "./Fieldset";
73
+ export * from "./FieldComponentProps";
73
74
  export * from "./Form";
74
75
  export * from "./Link";
75
76
  export * from "./MenuButton";
@@ -53,10 +53,10 @@ import { CSSProperties } from "react";
53
53
 
54
54
  export const components = ({
55
55
  odysseyTokens,
56
- shadowRootElement,
56
+ shadowDomElement,
57
57
  }: {
58
58
  odysseyTokens: DesignTokens;
59
- shadowRootElement?: HTMLDivElement;
59
+ shadowDomElement?: HTMLDivElement;
60
60
  }): ThemeOptions["components"] => {
61
61
  return {
62
62
  MuiAccordion: {
@@ -303,7 +303,7 @@ export const components = ({
303
303
  },
304
304
  MuiAlertTitle: {
305
305
  styleOverrides: {
306
- root: {
306
+ root: ({ ownerState }) => ({
307
307
  marginBlockStart: 0,
308
308
  marginBlockEnd: odysseyTokens.Spacing2,
309
309
  lineHeight: odysseyTokens.TypographyLineHeightHeading6,
@@ -311,10 +311,26 @@ export const components = ({
311
311
  fontWeight: odysseyTokens.TypographyWeightHeading,
312
312
  fontFamily: odysseyTokens.TypographyFamilyHeading,
313
313
 
314
+ ...(ownerState.severity === "info" && {
315
+ color: odysseyTokens.PalettePrimaryDark,
316
+ }),
317
+
318
+ ...(ownerState.severity === "error" && {
319
+ color: odysseyTokens.PaletteDangerDarker,
320
+ }),
321
+
322
+ ...(ownerState.severity === "success" && {
323
+ color: odysseyTokens.PaletteSuccessDarker,
324
+ }),
325
+
326
+ ...(ownerState.severity === "warning" && {
327
+ color: odysseyTokens.PaletteWarningDarker,
328
+ }),
329
+
314
330
  [`&:last-child`]: {
315
331
  marginBlockEnd: 0,
316
332
  },
317
- },
333
+ }),
318
334
  },
319
335
  },
320
336
  MuiAutocomplete: {
@@ -788,7 +804,7 @@ export const components = ({
788
804
  [`&.${chipClasses.disabled}`]: {
789
805
  opacity: 1,
790
806
  pointerEvents: "none",
791
- backgroundColor: odysseyTokens.HueNeutral50,
807
+ backgroundColor: odysseyTokens.HueNeutral200,
792
808
  color: odysseyTokens.TypographyColorDisabled,
793
809
  },
794
810
 
@@ -908,6 +924,11 @@ export const components = ({
908
924
 
909
925
  label: {
910
926
  padding: 0,
927
+
928
+ [`.${inputBaseClasses.root}.${inputBaseClasses.disabled} &`]: {
929
+ color: odysseyTokens.TypographyColorDisabled,
930
+ WebkitTextFillColor: odysseyTokens.TypographyColorDisabled,
931
+ } satisfies CSSProperties,
911
932
  },
912
933
 
913
934
  deleteIcon: {
@@ -1854,7 +1875,7 @@ export const components = ({
1854
1875
  },
1855
1876
  MuiModal: {
1856
1877
  defaultProps: {
1857
- container: shadowRootElement,
1878
+ container: shadowDomElement,
1858
1879
  },
1859
1880
  },
1860
1881
  MuiNativeSelect: {
@@ -1894,7 +1915,7 @@ export const components = ({
1894
1915
  },
1895
1916
  MuiPopover: {
1896
1917
  defaultProps: {
1897
- container: shadowRootElement,
1918
+ container: shadowDomElement,
1898
1919
  },
1899
1920
  styleOverrides: {
1900
1921
  paper: {
@@ -1907,7 +1928,7 @@ export const components = ({
1907
1928
  },
1908
1929
  MuiPopper: {
1909
1930
  defaultProps: {
1910
- container: shadowRootElement,
1931
+ container: shadowDomElement,
1911
1932
  },
1912
1933
  },
1913
1934
  MuiRadio: {
@@ -2075,19 +2096,17 @@ export const components = ({
2075
2096
  maxWidth: `calc(${odysseyTokens.TypographyLineLengthMax} / 2)`,
2076
2097
  minWidth: "unset",
2077
2098
  minHeight: "unset",
2078
- padding: `${odysseyTokens.Spacing4} 0`,
2099
+ padding: `${odysseyTokens.Spacing4} ${odysseyTokens.Spacing1}`,
2100
+ fontSize: odysseyTokens.TypographySizeHeading6,
2079
2101
  fontFamily: odysseyTokens.TypographyFamilyHeading,
2080
2102
  lineHeight: odysseyTokens.TypographyLineHeightUi,
2081
2103
  overflow: "visible",
2082
-
2083
- ...(ownerState.textColor === "inherit" && {
2084
- color: "inherit",
2085
- opacity: 1,
2086
- }),
2104
+ color: odysseyTokens.HueNeutral600,
2105
+ opacity: 1,
2087
2106
 
2088
2107
  ...(ownerState.selected == true && {
2089
2108
  color: odysseyTokens.TypographyColorAction,
2090
- fontWeight: odysseyTokens.TypographyWeightBodyBold,
2109
+ fontWeight: odysseyTokens.TypographyWeightHeading,
2091
2110
  }),
2092
2111
 
2093
2112
  ...(ownerState.disabled && {
@@ -29,15 +29,15 @@ export type DesignTokensOverride = Partial<typeof Tokens>;
29
29
 
30
30
  export const createOdysseyMuiTheme = ({
31
31
  odysseyTokens,
32
- shadowRootElement,
32
+ shadowDomElement,
33
33
  }: {
34
34
  odysseyTokens: DesignTokens;
35
- shadowRootElement?: HTMLDivElement;
35
+ shadowDomElement?: HTMLDivElement;
36
36
  }) =>
37
37
  createTheme({
38
38
  components: components({
39
39
  odysseyTokens,
40
- shadowRootElement,
40
+ shadowDomElement,
41
41
  }),
42
42
  mixins: mixins({ odysseyTokens }),
43
43
  palette: palette({ odysseyTokens }),
@@ -1 +0,0 @@
1
- {"version":3,"file":"createShadowDom.js","names":["createShadowDom","containerElement","shadowContainer","attachShadow","mode","emotionRootElement","document","createElement","shadowRootElement","appendChild"],"sources":["../src/createShadowDom.ts"],"sourcesContent":["/*!\n * Copyright (c) 2023-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\nexport const createShadowDom = (containerElement: HTMLElement) => {\n const shadowContainer = containerElement.attachShadow({ mode: \"open\" });\n const emotionRootElement = document.createElement(\"style\");\n const shadowRootElement = document.createElement(\"div\");\n\n shadowContainer.appendChild(emotionRootElement);\n shadowContainer.appendChild(shadowRootElement);\n\n return {\n emotionRootElement,\n shadowRootElement,\n };\n};\n\n// --DOCS--\n\n// const {\n// emotionRootElement,\n// shadowRootElement,\n// } = (\n// createShadowDom(\n// document.querySelector('#root') as HTMLElement\n// )\n// )\n\n// ReactDOM\n// .createRoot(\n// shadowRootElement\n// )\n// .render(\n// <OdysseyProvider emotionRootElement={emotionRootElement} shadowRootElement={shadowRootElement}>\n// <App />\n// </OdysseyProvider>\n// )\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,eAAe,GAAIC,gBAA6B,IAAK;EAChE,MAAMC,eAAe,GAAGD,gBAAgB,CAACE,YAAY,CAAC;IAAEC,IAAI,EAAE;EAAO,CAAC,CAAC;EACvE,MAAMC,kBAAkB,GAAGC,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;EAC1D,MAAMC,iBAAiB,GAAGF,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAEvDL,eAAe,CAACO,WAAW,CAACJ,kBAAkB,CAAC;EAC/CH,eAAe,CAACO,WAAW,CAACD,iBAAiB,CAAC;EAE9C,OAAO;IACLH,kBAAkB;IAClBG;EACF,CAAC;AACH,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createShadowDom.d.ts","sourceRoot":"","sources":["../../src/createShadowDom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,eAAe,qBAAsB,WAAW;;;CAY5D,CAAC"}
@@ -1,46 +0,0 @@
1
- /*!
2
- * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
- *
5
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
- * Unless required by applicable law or agreed to in writing, software
7
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
- *
10
- * See the License for the specific language governing permissions and limitations under the License.
11
- */
12
-
13
- export const createShadowDom = (containerElement: HTMLElement) => {
14
- const shadowContainer = containerElement.attachShadow({ mode: "open" });
15
- const emotionRootElement = document.createElement("style");
16
- const shadowRootElement = document.createElement("div");
17
-
18
- shadowContainer.appendChild(emotionRootElement);
19
- shadowContainer.appendChild(shadowRootElement);
20
-
21
- return {
22
- emotionRootElement,
23
- shadowRootElement,
24
- };
25
- };
26
-
27
- // --DOCS--
28
-
29
- // const {
30
- // emotionRootElement,
31
- // shadowRootElement,
32
- // } = (
33
- // createShadowDom(
34
- // document.querySelector('#root') as HTMLElement
35
- // )
36
- // )
37
-
38
- // ReactDOM
39
- // .createRoot(
40
- // shadowRootElement
41
- // )
42
- // .render(
43
- // <OdysseyProvider emotionRootElement={emotionRootElement} shadowRootElement={shadowRootElement}>
44
- // <App />
45
- // </OdysseyProvider>
46
- // )