@okta/odyssey-react-mui 1.5.0 → 1.6.1

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 (53) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/OdysseyCacheProvider.js +7 -1
  3. package/dist/OdysseyCacheProvider.js.map +1 -1
  4. package/dist/OdysseyProvider.js +3 -4
  5. package/dist/OdysseyProvider.js.map +1 -1
  6. package/dist/OdysseyThemeProvider.js +3 -3
  7. package/dist/OdysseyThemeProvider.js.map +1 -1
  8. package/dist/PasswordField.js +1 -1
  9. package/dist/PasswordField.js.map +1 -1
  10. package/dist/Select.js +23 -25
  11. package/dist/Select.js.map +1 -1
  12. package/dist/Tooltip.js +5 -1
  13. package/dist/Tooltip.js.map +1 -1
  14. package/dist/{createShadowDom.js → createShadowRootElement.js} +6 -11
  15. package/dist/createShadowRootElement.js.map +1 -0
  16. package/dist/index.js +1 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/src/OdysseyCacheProvider.d.ts +2 -2
  19. package/dist/src/OdysseyCacheProvider.d.ts.map +1 -1
  20. package/dist/src/OdysseyProvider.d.ts +1 -1
  21. package/dist/src/OdysseyProvider.d.ts.map +1 -1
  22. package/dist/src/OdysseyThemeProvider.d.ts +2 -2
  23. package/dist/src/OdysseyThemeProvider.d.ts.map +1 -1
  24. package/dist/src/Select.d.ts +14 -8
  25. package/dist/src/Select.d.ts.map +1 -1
  26. package/dist/src/Tooltip.d.ts +2 -1
  27. package/dist/src/Tooltip.d.ts.map +1 -1
  28. package/dist/src/{createShadowDom.d.ts → createShadowRootElement.d.ts} +2 -5
  29. package/dist/src/createShadowRootElement.d.ts.map +1 -0
  30. package/dist/src/index.d.ts +1 -0
  31. package/dist/src/index.d.ts.map +1 -1
  32. package/dist/src/theme/components.d.ts +2 -2
  33. package/dist/src/theme/components.d.ts.map +1 -1
  34. package/dist/src/theme/createOdysseyMuiTheme.d.ts +2 -2
  35. package/dist/theme/components.js +18 -15
  36. package/dist/theme/components.js.map +1 -1
  37. package/dist/theme/createOdysseyMuiTheme.js +2 -2
  38. package/dist/theme/createOdysseyMuiTheme.js.map +1 -1
  39. package/dist/tsconfig.production.tsbuildinfo +1 -1
  40. package/package.json +3 -3
  41. package/src/OdysseyCacheProvider.tsx +12 -2
  42. package/src/OdysseyProvider.tsx +3 -4
  43. package/src/OdysseyThemeProvider.tsx +4 -4
  44. package/src/PasswordField.tsx +1 -1
  45. package/src/Select.tsx +64 -45
  46. package/src/Tooltip.tsx +7 -2
  47. package/src/createShadowRootElement.ts +21 -0
  48. package/src/index.ts +1 -0
  49. package/src/theme/components.tsx +19 -16
  50. package/src/theme/createOdysseyMuiTheme.ts +3 -3
  51. package/dist/createShadowDom.js.map +0 -1
  52. package/dist/src/createShadowDom.d.ts.map +0 -1
  53. package/src/createShadowDom.ts +0 -46
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okta/odyssey-react-mui",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "description": "React MUI components for Odyssey, Okta's design system",
5
5
  "author": "Okta, Inc.",
6
6
  "license": "Apache-2.0",
@@ -51,7 +51,7 @@
51
51
  "@mui/system": "^5.14.9",
52
52
  "@mui/utils": "^5.11.2",
53
53
  "@mui/x-date-pickers": "^5.0.15",
54
- "@okta/odyssey-design-tokens": "1.5.0",
54
+ "@okta/odyssey-design-tokens": "1.6.1",
55
55
  "date-fns": "^2.30.0",
56
56
  "i18next": "^23.5.1",
57
57
  "material-react-table": "^1.14.0",
@@ -63,5 +63,5 @@
63
63
  "react": ">=17 <19",
64
64
  "react-dom": ">=17 <19"
65
65
  },
66
- "gitHead": "cf8dbb65cb3ca95e69bfe65b9825366146682368"
66
+ "gitHead": "162c333bbd49eea327a699b1b0fe883f8c11425d"
67
67
  }
@@ -28,19 +28,29 @@ export type OdysseyCacheProviderProps = {
28
28
  * Emotion renders into this HTML element.
29
29
  * When enabling this prop, Emotion renders at the top of this component rather than the bottom like it does in the HTML `<head>`.
30
30
  */
31
- emotionRootElement?: HTMLStyleElement;
32
31
  nonce?: string;
32
+ shadowDomElement?: HTMLDivElement;
33
33
  stylisPlugins?: StylisPlugin[];
34
34
  };
35
35
 
36
36
  const OdysseyCacheProvider = ({
37
37
  children,
38
- emotionRootElement,
39
38
  nonce,
39
+ shadowDomElement,
40
40
  stylisPlugins,
41
41
  }: OdysseyCacheProviderProps) => {
42
42
  const uniqueAlphabeticalId = useUniqueAlphabeticalId();
43
43
 
44
+ const emotionRootElement = useMemo(() => {
45
+ const emotionRootElement = document.createElement("div");
46
+
47
+ emotionRootElement.setAttribute("data-emotion-root", "data-emotion-root");
48
+
49
+ shadowDomElement?.prepend?.(emotionRootElement);
50
+
51
+ return emotionRootElement;
52
+ }, [shadowDomElement]);
53
+
44
54
  const emotionCache = useMemo(
45
55
  () =>
46
56
  createCache({
@@ -35,8 +35,7 @@ export type OdysseyProviderProps = OdysseyCacheProviderProps &
35
35
  const OdysseyProvider = ({
36
36
  children,
37
37
  designTokensOverride,
38
- emotionRootElement,
39
- shadowRootElement,
38
+ shadowDomElement,
40
39
  languageCode,
41
40
  nonce,
42
41
  stylisPlugins,
@@ -44,13 +43,13 @@ const OdysseyProvider = ({
44
43
  translationOverrides,
45
44
  }: OdysseyProviderProps) => (
46
45
  <OdysseyCacheProvider
47
- emotionRootElement={emotionRootElement}
48
46
  nonce={nonce}
47
+ shadowDomElement={shadowDomElement}
49
48
  stylisPlugins={stylisPlugins}
50
49
  >
51
50
  <OdysseyThemeProvider
52
51
  designTokensOverride={designTokensOverride}
53
- shadowRootElement={shadowRootElement}
52
+ shadowDomElement={shadowDomElement}
54
53
  themeOverride={themeOverride}
55
54
  >
56
55
  <ScopedCssBaseline>
@@ -25,14 +25,14 @@ import { OdysseyDesignTokensContext } from "./OdysseyDesignTokensContext";
25
25
  export type OdysseyThemeProviderProps = {
26
26
  children: ReactNode;
27
27
  designTokensOverride?: DesignTokensOverride;
28
- shadowRootElement?: HTMLDivElement;
28
+ shadowDomElement?: HTMLDivElement;
29
29
  themeOverride?: ThemeOptions;
30
30
  };
31
31
 
32
32
  const OdysseyThemeProvider = ({
33
33
  children,
34
34
  designTokensOverride,
35
- shadowRootElement,
35
+ shadowDomElement,
36
36
  themeOverride,
37
37
  }: OdysseyThemeProviderProps) => {
38
38
  const odysseyTokens = useMemo(
@@ -43,9 +43,9 @@ const OdysseyThemeProvider = ({
43
43
  () =>
44
44
  createOdysseyMuiTheme({
45
45
  odysseyTokens,
46
- shadowRootElement,
46
+ shadowDomElement,
47
47
  }),
48
- [odysseyTokens, shadowRootElement]
48
+ [odysseyTokens, shadowDomElement]
49
49
  );
50
50
 
51
51
  const customOdysseyTheme = useMemo(
@@ -130,7 +130,7 @@ const PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(
130
130
  ({ ariaDescribedBy, errorMessageElementId, id, labelElementId }) => (
131
131
  <InputBase
132
132
  aria-describedby={ariaDescribedBy}
133
- autoComplete={autoCompleteType}
133
+ autoComplete={inputType === "password" ? autoCompleteType : "off"}
134
134
  /* eslint-disable-next-line jsx-a11y/no-autofocus */
135
135
  autoFocus={hasInitialFocus}
136
136
  data-se={testId}
package/src/Select.tsx CHANGED
@@ -10,16 +10,15 @@
10
10
  * See the License for the specific language governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import { ReactNode, memo, useCallback, useMemo, useState } from "react";
13
+ import { memo, useCallback, useMemo, useState } from "react";
14
14
  import {
15
15
  Box,
16
- Chip,
17
16
  Checkbox as MuiCheckbox,
17
+ Chip,
18
+ ListItemSecondaryAction,
18
19
  ListSubheader,
19
20
  MenuItem,
20
21
  Select as MuiSelect,
21
- SelectChangeEvent,
22
- ListItemSecondaryAction,
23
22
  } from "@mui/material";
24
23
  import { SelectProps as MuiSelectProps } from "@mui/material";
25
24
  import { Field } from "./Field";
@@ -32,11 +31,21 @@ export type SelectOption = {
32
31
  value?: string;
33
32
  };
34
33
 
35
- export type SelectProps = {
34
+ export type SelectValueType<HasMultipleChoices> =
35
+ HasMultipleChoices extends true ? string[] : string;
36
+
37
+ export type SelectProps<
38
+ Value extends SelectValueType<HasMultipleChoices>,
39
+ HasMultipleChoices extends boolean
40
+ > = {
36
41
  /**
37
42
  * The error message for the Select
38
43
  */
39
44
  errorMessage?: string;
45
+ /**
46
+ * If `true`, the Select allows multiple selections
47
+ */
48
+ hasMultipleChoices?: HasMultipleChoices;
40
49
  /**
41
50
  * The hint text for the Select
42
51
  */
@@ -50,9 +59,10 @@ export type SelectProps = {
50
59
  */
51
60
  isDisabled?: boolean;
52
61
  /**
53
- * If `true`, the Select allows multiple selections
62
+ * @deprecated Use `hasMultipleChoices` instead.
54
63
  */
55
- isMultiSelect?: boolean;
64
+ /** **Deprecated:** use `hasMultipleChoices` */
65
+ isMultiSelect?: HasMultipleChoices;
56
66
  /**
57
67
  * If `true`, the Select is optional
58
68
  */
@@ -68,15 +78,15 @@ export type SelectProps = {
68
78
  /**
69
79
  * Callback fired when the Select loses focus
70
80
  */
71
- onBlur?: MuiSelectProps["onBlur"];
81
+ onBlur?: MuiSelectProps<Value>["onBlur"];
72
82
  /**
73
83
  * Callback fired when the value of the Select changes
74
84
  */
75
- onChange?: MuiSelectProps["onChange"];
85
+ onChange?: MuiSelectProps<Value>["onChange"];
76
86
  /**
77
87
  * Callback fired when the Select gains focus
78
88
  */
79
- onFocus?: MuiSelectProps["onFocus"];
89
+ onFocus?: MuiSelectProps<Value>["onFocus"];
80
90
  /**
81
91
  * The options for the Select
82
92
  */
@@ -84,7 +94,7 @@ export type SelectProps = {
84
94
  /**
85
95
  * The value or values selected in the Select
86
96
  */
87
- value?: string | string[];
97
+ value?: Value;
88
98
  } & SeleniumProps;
89
99
 
90
100
  /**
@@ -102,50 +112,59 @@ export type SelectProps = {
102
112
  * - { text: string, type: "heading" } — Used to display a group heading with the text
103
113
  */
104
114
 
105
- const Select = ({
115
+ const Select = <
116
+ Value extends SelectValueType<HasMultipleChoices>,
117
+ HasMultipleChoices extends boolean
118
+ >({
106
119
  errorMessage,
120
+ hasMultipleChoices: hasMultipleChoicesProp,
107
121
  hint,
108
122
  id: idOverride,
109
123
  isDisabled = false,
110
- isMultiSelect = false,
124
+ isMultiSelect,
111
125
  isOptional = false,
112
126
  label,
113
127
  name: nameOverride,
114
128
  onBlur,
115
129
  onChange: onChangeProp,
116
130
  onFocus,
117
- value,
118
- testId,
119
131
  options,
120
- }: SelectProps) => {
121
- // If there's no value set, we set it to a blank string (if it's a single-select)
122
- // or an empty array (if it's a multi-select)
123
- if (typeof value === "undefined") {
124
- value = isMultiSelect ? [] : "";
125
- }
132
+ testId,
133
+ value,
134
+ }: SelectProps<Value, HasMultipleChoices>) => {
135
+ const hasMultipleChoices = useMemo(
136
+ () =>
137
+ hasMultipleChoicesProp === undefined
138
+ ? isMultiSelect
139
+ : hasMultipleChoicesProp,
140
+ [hasMultipleChoicesProp, isMultiSelect]
141
+ );
126
142
 
127
- const [selectedValue, setSelectedValue] = useState<string | string[]>(value);
143
+ const formattedValueForMultiSelect = isMultiSelect
144
+ ? ([] as string[] as Value)
145
+ : ("" as string as Value);
128
146
 
129
- const onChange = useCallback(
130
- (event: SelectChangeEvent<string | string[]>, child: ReactNode) => {
131
- const {
132
- target: { value },
133
- } = event;
147
+ const [selectedValue, setSelectedValue] = useState(
148
+ value === undefined ? formattedValueForMultiSelect : value
149
+ );
150
+
151
+ const onChange = useCallback<NonNullable<MuiSelectProps<Value>["onChange"]>>(
152
+ (event, child) => {
153
+ const valueFromEvent = event.target.value;
134
154
 
135
- // Set the field value, with some additional logic to handle array values
136
- // for multi-selects
137
- if (isMultiSelect) {
138
- setSelectedValue(typeof value === "string" ? value.split(",") : value);
155
+ if (typeof valueFromEvent === "string") {
156
+ if (hasMultipleChoices) {
157
+ setSelectedValue(valueFromEvent.split(",") as Value);
158
+ } else {
159
+ setSelectedValue(valueFromEvent as Value);
160
+ }
139
161
  } else {
140
- setSelectedValue(value);
162
+ setSelectedValue(valueFromEvent);
141
163
  }
142
164
 
143
- // Trigger the onChange event, if one has been passed
144
- if (onChangeProp) {
145
- onChangeProp(event, child);
146
- }
165
+ onChangeProp?.(event, child);
147
166
  },
148
- [isMultiSelect, onChangeProp, setSelectedValue]
167
+ [hasMultipleChoices, onChangeProp, setSelectedValue]
149
168
  );
150
169
 
151
170
  // Normalize the options array to accommodate the various
@@ -165,7 +184,7 @@ const Select = ({
165
184
  );
166
185
 
167
186
  const renderValue = useCallback(
168
- (selected: string | string[]) => {
187
+ (selected: Value) => {
169
188
  // If the selected value isn't an array, then we don't need to display
170
189
  // chips and should fall back to the default render behavior
171
190
  if (typeof selected === "string") {
@@ -209,7 +228,7 @@ const Select = ({
209
228
 
210
229
  return (
211
230
  <MenuItem key={option.value} value={option.value}>
212
- {isMultiSelect && (
231
+ {hasMultipleChoices && (
213
232
  <MuiCheckbox checked={selectedValue.includes(option.value)} />
214
233
  )}
215
234
  {option.text}
@@ -221,30 +240,30 @@ const Select = ({
221
240
  </MenuItem>
222
241
  );
223
242
  }),
224
- [isMultiSelect, normalizedOptions, selectedValue]
243
+ [hasMultipleChoices, normalizedOptions, selectedValue]
225
244
  );
226
245
 
227
246
  const renderFieldComponent = useCallback(
228
247
  ({ ariaDescribedBy, errorMessageElementId, id, labelElementId }) => (
229
248
  <MuiSelect
249
+ aria-describedby={ariaDescribedBy}
250
+ aria-errormessage={errorMessageElementId}
230
251
  children={children}
231
252
  data-se={testId}
232
253
  id={id}
233
- aria-errormessage={errorMessageElementId}
234
- aria-describedby={ariaDescribedBy}
235
254
  labelId={labelElementId}
236
- multiple={isMultiSelect}
255
+ multiple={hasMultipleChoices}
237
256
  name={nameOverride ?? id}
238
257
  onBlur={onBlur}
239
258
  onChange={onChange}
240
259
  onFocus={onFocus}
241
- renderValue={isMultiSelect ? renderValue : undefined}
260
+ renderValue={hasMultipleChoices ? renderValue : undefined}
242
261
  value={selectedValue}
243
262
  />
244
263
  ),
245
264
  [
246
265
  children,
247
- isMultiSelect,
266
+ hasMultipleChoices,
248
267
  nameOverride,
249
268
  onBlur,
250
269
  onChange,
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,6 +66,7 @@ export * from "./Callout";
66
66
  export * from "./Checkbox";
67
67
  export * from "./CheckboxGroup";
68
68
  export * from "./CircularProgress";
69
+ export * from "./createShadowRootElement";
69
70
  export * from "./createUniqueId";
70
71
  export * from "./Dialog";
71
72
  export * from "./Fieldset";
@@ -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: {
@@ -788,7 +788,7 @@ export const components = ({
788
788
  [`&.${chipClasses.disabled}`]: {
789
789
  opacity: 1,
790
790
  pointerEvents: "none",
791
- backgroundColor: odysseyTokens.HueNeutral50,
791
+ backgroundColor: odysseyTokens.HueNeutral200,
792
792
  color: odysseyTokens.TypographyColorDisabled,
793
793
  },
794
794
 
@@ -908,6 +908,11 @@ export const components = ({
908
908
 
909
909
  label: {
910
910
  padding: 0,
911
+
912
+ [`.${inputBaseClasses.root}.${inputBaseClasses.disabled} &`]: {
913
+ color: odysseyTokens.TypographyColorDisabled,
914
+ WebkitTextFillColor: odysseyTokens.TypographyColorDisabled,
915
+ } satisfies CSSProperties,
911
916
  },
912
917
 
913
918
  deleteIcon: {
@@ -1675,7 +1680,7 @@ export const components = ({
1675
1680
  styleOverrides: {
1676
1681
  root: {
1677
1682
  color: odysseyTokens.TypographyColorAction,
1678
- textDecoration: "underline",
1683
+ textDecoration: "none",
1679
1684
  cursor: "pointer",
1680
1685
 
1681
1686
  "&:visited": {
@@ -1703,11 +1708,11 @@ export const components = ({
1703
1708
  },
1704
1709
 
1705
1710
  ".Link-indicator": {
1706
- marginInlineStart: odysseyTokens.Spacing2,
1711
+ marginInlineStart: odysseyTokens.Spacing1,
1707
1712
  },
1708
1713
 
1709
1714
  ".Link-icon": {
1710
- marginInlineEnd: odysseyTokens.Spacing2,
1715
+ marginInlineEnd: odysseyTokens.Spacing1,
1711
1716
  },
1712
1717
  svg: {
1713
1718
  fontSize: "1em",
@@ -1854,7 +1859,7 @@ export const components = ({
1854
1859
  },
1855
1860
  MuiModal: {
1856
1861
  defaultProps: {
1857
- container: shadowRootElement,
1862
+ container: shadowDomElement,
1858
1863
  },
1859
1864
  },
1860
1865
  MuiNativeSelect: {
@@ -1894,7 +1899,7 @@ export const components = ({
1894
1899
  },
1895
1900
  MuiPopover: {
1896
1901
  defaultProps: {
1897
- container: shadowRootElement,
1902
+ container: shadowDomElement,
1898
1903
  },
1899
1904
  styleOverrides: {
1900
1905
  paper: {
@@ -1907,7 +1912,7 @@ export const components = ({
1907
1912
  },
1908
1913
  MuiPopper: {
1909
1914
  defaultProps: {
1910
- container: shadowRootElement,
1915
+ container: shadowDomElement,
1911
1916
  },
1912
1917
  },
1913
1918
  MuiRadio: {
@@ -2075,19 +2080,17 @@ export const components = ({
2075
2080
  maxWidth: `calc(${odysseyTokens.TypographyLineLengthMax} / 2)`,
2076
2081
  minWidth: "unset",
2077
2082
  minHeight: "unset",
2078
- padding: `${odysseyTokens.Spacing4} 0`,
2083
+ padding: `${odysseyTokens.Spacing4} ${odysseyTokens.Spacing1}`,
2084
+ fontSize: odysseyTokens.TypographySizeHeading6,
2079
2085
  fontFamily: odysseyTokens.TypographyFamilyHeading,
2080
2086
  lineHeight: odysseyTokens.TypographyLineHeightUi,
2081
2087
  overflow: "visible",
2082
-
2083
- ...(ownerState.textColor === "inherit" && {
2084
- color: "inherit",
2085
- opacity: 1,
2086
- }),
2088
+ color: odysseyTokens.HueNeutral600,
2089
+ opacity: 1,
2087
2090
 
2088
2091
  ...(ownerState.selected == true && {
2089
2092
  color: odysseyTokens.TypographyColorAction,
2090
- fontWeight: odysseyTokens.TypographyWeightBodyBold,
2093
+ fontWeight: odysseyTokens.TypographyWeightHeading,
2091
2094
  }),
2092
2095
 
2093
2096
  ...(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
- // )