@okta/odyssey-react-mui 1.9.9 → 1.9.10

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 CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.9.10](https://github.com/okta/odyssey/compare/v1.9.9...v1.9.10) (2023-12-21)
7
+
8
+ **Note:** Version bump only for package @okta/odyssey-react-mui
9
+
6
10
  ## [1.9.9](https://github.com/okta/odyssey/compare/v1.9.8...v1.9.9) (2023-12-20)
7
11
 
8
12
  **Note:** Version bump only for package @okta/odyssey-react-mui
package/dist/index.js CHANGED
@@ -55,6 +55,7 @@ export * from "./TextField.js";
55
55
  export * from "./theme/index.js";
56
56
  export * from "./Toast.js";
57
57
  export * from "./ToastStack.js";
58
+ export * from "./labs/Switch.js";
58
59
  export * from "./Tooltip.js";
59
60
  export * from "./Typography.js";
60
61
  export * from "./useUniqueId.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["deepmerge","visuallyHidden","createTheme","DialogContentText","Divider","InputAdornment","InputBase","ListItemIcon","ListItemText","ListSubheader","MenuList","Paper","ScopedCssBaseline","ThemeProvider","useOdysseyDesignTokens","odysseyTranslate"],"sources":["../src/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2022-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 { deepmerge, visuallyHidden } from \"@mui/utils\";\n\nexport {\n createTheme,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n DialogContentText,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n Divider,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n InputAdornment,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n InputBase,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ListItemIcon,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ListItemText,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ListSubheader,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n MenuList,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n Paper,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ScopedCssBaseline,\n ThemeProvider,\n} from \"@mui/material\";\n\nexport type {\n CssBaselineProps,\n DialogContentTextProps,\n DividerProps,\n InputAdornmentProps,\n InputBaseProps,\n ListItemIconProps,\n ListItemTextProps,\n ListSubheaderProps,\n MenuListProps,\n PaperProps,\n ScopedCssBaselineProps,\n ThemeOptions,\n} from \"@mui/material\";\n\nexport { useOdysseyDesignTokens } from \"./OdysseyDesignTokensContext\";\n\nexport * from \"./Accordion\";\nexport * from \"./Autocomplete\";\nexport * from \"./Banner\";\nexport * from \"./Box\";\nexport * from \"./Breadcrumbs\";\nexport * from \"./Button\";\nexport * from \"./Callout\";\nexport * from \"./Checkbox\";\nexport * from \"./CheckboxGroup\";\nexport * from \"./CircularProgress\";\nexport * from \"./CssBaseline\";\nexport * from \"./createShadowRootElement\";\nexport * from \"./createUniqueId\";\nexport * from \"./Dialog\";\nexport * from \"./Fieldset\";\nexport * from \"./FieldComponentProps\";\nexport * from \"./Form\";\nexport * from \"./HintLink\";\nexport * from \"./Link\";\nexport * from \"./MenuButton\";\nexport * from \"./MenuItem\";\nexport * from \"./NativeSelect\";\nexport * from \"./NullElement\";\nexport * from \"./OdysseyCacheProvider\";\nexport { odysseyTranslate } from \"./i18n\";\nexport * from \"./OdysseyProvider\";\nexport * from \"./OdysseyThemeProvider\";\nexport * from \"./OdysseyTranslationProvider\";\nexport * from \"./PasswordField\";\nexport * from \"./Radio\";\nexport * from \"./RadioGroup\";\nexport * from \"./ScreenReaderText\";\nexport * from \"./SearchField\";\nexport * from \"./Select\";\nexport * from \"./Status\";\nexport * from \"./Tabs\";\nexport * from \"./Tag\";\nexport * from \"./TagList\";\nexport * from \"./TextField\";\nexport * from \"./theme\";\nexport * from \"./Toast\";\nexport * from \"./ToastStack\";\nexport * from \"./Tooltip\";\nexport * from \"./Typography\";\nexport * from \"./useUniqueId\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,EAAEC,cAAc,QAAQ,YAAY;AAEtD,SACEC,WAAW,EAEXC,iBAAiB,EAEjBC,OAAO,EAEPC,cAAc,EAEdC,SAAS,EAETC,YAAY,EAEZC,YAAY,EAEZC,aAAa,EAEbC,QAAQ,EAERC,KAAK,EAELC,iBAAiB,EACjBC,aAAa,QACR,eAAe;AAAC,SAiBdC,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SA0BtBC,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA"}
1
+ {"version":3,"file":"index.js","names":["deepmerge","visuallyHidden","createTheme","DialogContentText","Divider","InputAdornment","InputBase","ListItemIcon","ListItemText","ListSubheader","MenuList","Paper","ScopedCssBaseline","ThemeProvider","useOdysseyDesignTokens","odysseyTranslate"],"sources":["../src/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2022-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 { deepmerge, visuallyHidden } from \"@mui/utils\";\n\nexport {\n createTheme,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n DialogContentText,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n Divider,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n InputAdornment,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n InputBase,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ListItemIcon,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ListItemText,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ListSubheader,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n MenuList,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n Paper,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ScopedCssBaseline,\n ThemeProvider,\n} from \"@mui/material\";\n\nexport type {\n CssBaselineProps,\n DialogContentTextProps,\n DividerProps,\n InputAdornmentProps,\n InputBaseProps,\n ListItemIconProps,\n ListItemTextProps,\n ListSubheaderProps,\n MenuListProps,\n PaperProps,\n ScopedCssBaselineProps,\n ThemeOptions,\n} from \"@mui/material\";\n\nexport { useOdysseyDesignTokens } from \"./OdysseyDesignTokensContext\";\n\nexport * from \"./Accordion\";\nexport * from \"./Autocomplete\";\nexport * from \"./Banner\";\nexport * from \"./Box\";\nexport * from \"./Breadcrumbs\";\nexport * from \"./Button\";\nexport * from \"./Callout\";\nexport * from \"./Checkbox\";\nexport * from \"./CheckboxGroup\";\nexport * from \"./CircularProgress\";\nexport * from \"./CssBaseline\";\nexport * from \"./createShadowRootElement\";\nexport * from \"./createUniqueId\";\nexport * from \"./Dialog\";\nexport * from \"./Fieldset\";\nexport * from \"./FieldComponentProps\";\nexport * from \"./Form\";\nexport * from \"./HintLink\";\nexport * from \"./Link\";\nexport * from \"./MenuButton\";\nexport * from \"./MenuItem\";\nexport * from \"./NativeSelect\";\nexport * from \"./NullElement\";\nexport * from \"./OdysseyCacheProvider\";\nexport { odysseyTranslate } from \"./i18n\";\nexport * from \"./OdysseyProvider\";\nexport * from \"./OdysseyThemeProvider\";\nexport * from \"./OdysseyTranslationProvider\";\nexport * from \"./PasswordField\";\nexport * from \"./Radio\";\nexport * from \"./RadioGroup\";\nexport * from \"./ScreenReaderText\";\nexport * from \"./SearchField\";\nexport * from \"./Select\";\nexport * from \"./Status\";\nexport * from \"./Tabs\";\nexport * from \"./Tag\";\nexport * from \"./TagList\";\nexport * from \"./TextField\";\nexport * from \"./theme\";\nexport * from \"./Toast\";\nexport * from \"./ToastStack\";\nexport * from \"./labs/Switch\";\nexport * from \"./Tooltip\";\nexport * from \"./Typography\";\nexport * from \"./useUniqueId\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,EAAEC,cAAc,QAAQ,YAAY;AAEtD,SACEC,WAAW,EAEXC,iBAAiB,EAEjBC,OAAO,EAEPC,cAAc,EAEdC,SAAS,EAETC,YAAY,EAEZC,YAAY,EAEZC,aAAa,EAEbC,QAAQ,EAERC,KAAK,EAELC,iBAAiB,EACjBC,aAAa,QACR,eAAe;AAAC,SAiBdC,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SA0BtBC,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA"}
@@ -0,0 +1,157 @@
1
+ import _FormControlLabel from "@mui/material/FormControlLabel";
2
+ import _Switch from "@mui/material/Switch";
3
+ /*!
4
+ * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
5
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
6
+ *
7
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ *
12
+ * See the License for the specific language governing permissions and limitations under the License.
13
+ */
14
+
15
+ import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
16
+ const {
17
+ CONTROLLED
18
+ } = ComponentControlledState;
19
+ import { useOdysseyDesignTokens } from "../OdysseyDesignTokensContext.js";
20
+ import { Box } from "../Box.js";
21
+ import { FieldHint } from "../FieldHint.js";
22
+ import { useUniqueId } from "../useUniqueId.js";
23
+ import { ComponentControlledState, getControlState } from "../inputUtils.js";
24
+ import { jsx as _jsx } from "react/jsx-runtime";
25
+ import { jsxs as _jsxs } from "react/jsx-runtime";
26
+ import { Fragment as _Fragment } from "react/jsx-runtime";
27
+ const SwitchLabel = _ref => {
28
+ let {
29
+ checked,
30
+ hint,
31
+ hintId,
32
+ isFullWidth,
33
+ label
34
+ } = _ref;
35
+ const odysseyDesignTokens = useOdysseyDesignTokens();
36
+ return _jsxs(_Fragment, {
37
+ children: [_jsxs(Box, {
38
+ sx: {
39
+ display: "flex",
40
+ alignItems: "center",
41
+ flexWrap: "wrap",
42
+ gap: odysseyDesignTokens.Spacing1,
43
+ margin: 0,
44
+ maxWidth: isFullWidth ? "100%" : odysseyDesignTokens.TypographyLineLengthMax,
45
+ fontWeight: odysseyDesignTokens.TypographyWeightBodyBold
46
+ },
47
+ children: [label, _jsx(Box, {
48
+ sx: {
49
+ padding: "2px 4px",
50
+ backgroundColor: checked ? odysseyDesignTokens.PaletteSuccessLighter : odysseyDesignTokens.HueNeutral100,
51
+ borderRadius: odysseyDesignTokens.BorderRadiusMain,
52
+ color: checked ? odysseyDesignTokens.PaletteSuccessText : odysseyDesignTokens.HueNeutral700,
53
+ fontWeight: odysseyDesignTokens.TypographyWeightBodyBold,
54
+ fontSize: odysseyDesignTokens.TypographyScale0,
55
+ lineHeight: odysseyDesignTokens.TypographyLineHeightOverline,
56
+ transitionProperty: "background-color, color",
57
+ transitionDuration: odysseyDesignTokens.TransitionDurationMain
58
+ },
59
+ children: checked ? "Active" : "Inactive"
60
+ })]
61
+ }), hint && _jsx(FieldHint, {
62
+ id: hintId,
63
+ text: hint
64
+ })]
65
+ });
66
+ };
67
+ const Switch = _ref2 => {
68
+ let {
69
+ hint,
70
+ id: _id,
71
+ isChecked,
72
+ isDefaultChecked,
73
+ isDisabled,
74
+ isFullWidth = false,
75
+ label,
76
+ name: _name,
77
+ onChange,
78
+ testId,
79
+ value = "Something"
80
+ } = _ref2;
81
+ const odysseyDesignTokens = useOdysseyDesignTokens();
82
+ const controlledStateRef = useRef(getControlState({
83
+ controlledValue: isChecked,
84
+ uncontrolledValue: isDefaultChecked
85
+ }));
86
+ const inputValues = useMemo(() => {
87
+ if (controlledStateRef.current === CONTROLLED) {
88
+ return {
89
+ checked: isChecked
90
+ };
91
+ }
92
+ return {
93
+ defaultChecked: isDefaultChecked
94
+ };
95
+ }, [isDefaultChecked, isChecked]);
96
+ const [internalSwitchChecked, setInternalSwitchChecked] = useState(controlledStateRef.current === CONTROLLED ? Boolean(isChecked) : Boolean(isDefaultChecked));
97
+ useEffect(() => {
98
+ if (controlledStateRef.current === CONTROLLED) {
99
+ setInternalSwitchChecked(Boolean(isChecked));
100
+ }
101
+ }, [isChecked]);
102
+ const id = useUniqueId(_id);
103
+ const hintId = hint ? `${id}-hint` : undefined;
104
+ const labelElementId = `${id}-label`;
105
+ const handleOnChange = useCallback((_, checked) => {
106
+ setInternalSwitchChecked(checked);
107
+ onChange?.({
108
+ checked,
109
+ value
110
+ });
111
+ }, [onChange, setInternalSwitchChecked, value]);
112
+ const renderSwitchComponent = useMemo(() => _jsx(_Switch, {
113
+ ...inputValues,
114
+ disabled: isDisabled,
115
+ disableRipple: true,
116
+ inputProps: {
117
+ "aria-checked": internalSwitchChecked,
118
+ "aria-describedby": hintId,
119
+ "aria-label": label,
120
+ "aria-labelledby": labelElementId
121
+ },
122
+ name: _name ?? id,
123
+ onChange: handleOnChange
124
+ }), [handleOnChange, hintId, inputValues, internalSwitchChecked, id, isDisabled, label, labelElementId, _name]);
125
+ return _jsx(Box, {
126
+ sx: {
127
+ marginBlockEnd: odysseyDesignTokens.Spacing2
128
+ },
129
+ children: _jsx(_FormControlLabel, {
130
+ checked: internalSwitchChecked,
131
+ control: renderSwitchComponent,
132
+ "data-se": testId,
133
+ disabled: isDisabled,
134
+ id: labelElementId,
135
+ label: _jsx(SwitchLabel, {
136
+ checked: internalSwitchChecked,
137
+ hint: hint,
138
+ hintId: hintId,
139
+ isFullWidth: isFullWidth,
140
+ label: label
141
+ }),
142
+ labelPlacement: "start",
143
+ sx: {
144
+ justifyContent: "space-between",
145
+ alignItems: "flex-start",
146
+ gap: odysseyDesignTokens.Spacing4,
147
+ width: "100%",
148
+ maxWidth: isFullWidth ? "100%" : odysseyDesignTokens.TypographyLineLengthMax
149
+ },
150
+ value: value
151
+ })
152
+ });
153
+ };
154
+ const MemoizedSwitch = memo(Switch);
155
+ MemoizedSwitch.displayName = "Switch";
156
+ export { MemoizedSwitch as Switch };
157
+ //# sourceMappingURL=Switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.js","names":["memo","useCallback","useEffect","useMemo","useRef","useState","CONTROLLED","ComponentControlledState","useOdysseyDesignTokens","Box","FieldHint","useUniqueId","getControlState","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","SwitchLabel","_ref","checked","hint","hintId","isFullWidth","label","odysseyDesignTokens","children","sx","display","alignItems","flexWrap","gap","Spacing1","margin","maxWidth","TypographyLineLengthMax","fontWeight","TypographyWeightBodyBold","padding","backgroundColor","PaletteSuccessLighter","HueNeutral100","borderRadius","BorderRadiusMain","color","PaletteSuccessText","HueNeutral700","fontSize","TypographyScale0","lineHeight","TypographyLineHeightOverline","transitionProperty","transitionDuration","TransitionDurationMain","id","text","Switch","_ref2","_id","isChecked","isDefaultChecked","isDisabled","name","_name","onChange","testId","value","controlledStateRef","controlledValue","uncontrolledValue","inputValues","current","defaultChecked","internalSwitchChecked","setInternalSwitchChecked","Boolean","undefined","labelElementId","handleOnChange","_","renderSwitchComponent","_Switch","disabled","disableRipple","inputProps","marginBlockEnd","Spacing2","_FormControlLabel","control","labelPlacement","justifyContent","Spacing4","width","MemoizedSwitch","displayName"],"sources":["../../src/labs/Switch.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-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\nimport {\n memo,\n SyntheticEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n Switch as MuiSwitch,\n SwitchProps as MuiSwitchProps,\n FormControlLabel,\n} from \"@mui/material\";\n\nconst { CONTROLLED } = ComponentControlledState;\nimport { useOdysseyDesignTokens } from \"../OdysseyDesignTokensContext\";\nimport { Box } from \"../Box\";\nimport { FieldComponentProps } from \"../FieldComponentProps\";\nimport { FieldHint } from \"../FieldHint\";\nimport type { SeleniumProps } from \"../SeleniumProps\";\nimport { useUniqueId } from \"../useUniqueId\";\nimport { ComponentControlledState, getControlState } from \"../inputUtils\";\nimport { CheckedFieldProps } from \"../FormCheckedProps\";\n\ntype OnChangeCallbackArguments = {\n checked: boolean;\n value: string;\n};\n\nexport type SwitchProps = {\n /**\n * if `true`, the label and switch span entire containing element's width\n */\n isFullWidth?: boolean;\n /**\n * The label text for the Switch\n */\n label: string;\n /**\n * The change event handler for the Switch\n */\n onChange?: ({ checked, value }: OnChangeCallbackArguments) => void;\n /**\n * The value attribute of the Switch\n */\n value: string;\n} & Pick<\n FieldComponentProps,\n \"hint\" | \"id\" | \"isFullWidth\" | \"isDisabled\" | \"name\"\n> &\n CheckedFieldProps<MuiSwitchProps> &\n SeleniumProps;\n\ntype SwitchLabelProps = {\n checked: boolean;\n hint: SwitchProps[\"hint\"];\n hintId?: string;\n isFullWidth: SwitchProps[\"isFullWidth\"];\n label: SwitchProps[\"label\"];\n};\n\nconst SwitchLabel = ({\n checked,\n hint,\n hintId,\n isFullWidth,\n label,\n}: SwitchLabelProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n return (\n <>\n <Box\n sx={{\n display: \"flex\",\n alignItems: \"center\",\n flexWrap: \"wrap\",\n gap: odysseyDesignTokens.Spacing1,\n margin: 0,\n maxWidth: isFullWidth\n ? \"100%\"\n : odysseyDesignTokens.TypographyLineLengthMax,\n fontWeight: odysseyDesignTokens.TypographyWeightBodyBold,\n }}\n >\n {label}\n <Box\n sx={{\n padding: \"2px 4px\",\n backgroundColor: checked\n ? odysseyDesignTokens.PaletteSuccessLighter\n : odysseyDesignTokens.HueNeutral100,\n borderRadius: odysseyDesignTokens.BorderRadiusMain,\n color: checked\n ? odysseyDesignTokens.PaletteSuccessText\n : odysseyDesignTokens.HueNeutral700,\n fontWeight: odysseyDesignTokens.TypographyWeightBodyBold,\n fontSize: odysseyDesignTokens.TypographyScale0,\n lineHeight: odysseyDesignTokens.TypographyLineHeightOverline,\n transitionProperty: \"background-color, color\",\n transitionDuration: odysseyDesignTokens.TransitionDurationMain,\n }}\n >\n {checked ? \"Active\" : \"Inactive\"}\n </Box>\n </Box>\n {hint && <FieldHint id={hintId} text={hint} />}\n </>\n );\n};\n\nconst Switch = ({\n hint,\n id: _id,\n isChecked,\n isDefaultChecked,\n isDisabled,\n isFullWidth = false,\n label,\n name: _name,\n onChange,\n testId,\n value = \"Something\",\n}: SwitchProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: isChecked,\n uncontrolledValue: isDefaultChecked,\n })\n );\n const inputValues = useMemo(() => {\n if (controlledStateRef.current === CONTROLLED) {\n return { checked: isChecked };\n }\n return { defaultChecked: isDefaultChecked };\n }, [isDefaultChecked, isChecked]);\n\n const [internalSwitchChecked, setInternalSwitchChecked] = useState(\n controlledStateRef.current === CONTROLLED\n ? Boolean(isChecked)\n : Boolean(isDefaultChecked)\n );\n\n useEffect(() => {\n if (controlledStateRef.current === CONTROLLED) {\n setInternalSwitchChecked(Boolean(isChecked));\n }\n }, [isChecked]);\n\n const id = useUniqueId(_id);\n\n const hintId = hint ? `${id}-hint` : undefined;\n const labelElementId = `${id}-label`;\n\n const handleOnChange = useCallback(\n (_: SyntheticEvent<Element, Event>, checked: boolean) => {\n setInternalSwitchChecked(checked);\n onChange?.({ checked, value });\n },\n [onChange, setInternalSwitchChecked, value]\n );\n\n const renderSwitchComponent = useMemo(\n () => (\n <MuiSwitch\n {...inputValues}\n disabled={isDisabled}\n disableRipple\n inputProps={{\n \"aria-checked\": internalSwitchChecked,\n \"aria-describedby\": hintId,\n \"aria-label\": label,\n \"aria-labelledby\": labelElementId,\n }}\n name={_name ?? id}\n onChange={handleOnChange}\n />\n ),\n [\n handleOnChange,\n hintId,\n inputValues,\n internalSwitchChecked,\n id,\n isDisabled,\n label,\n labelElementId,\n _name,\n ]\n );\n\n return (\n <Box\n sx={{\n marginBlockEnd: odysseyDesignTokens.Spacing2,\n }}\n >\n <FormControlLabel\n checked={internalSwitchChecked}\n control={renderSwitchComponent}\n data-se={testId}\n disabled={isDisabled}\n id={labelElementId}\n label={\n <SwitchLabel\n checked={internalSwitchChecked}\n hint={hint}\n hintId={hintId}\n isFullWidth={isFullWidth}\n label={label}\n />\n }\n labelPlacement=\"start\"\n sx={{\n justifyContent: \"space-between\",\n alignItems: \"flex-start\",\n gap: odysseyDesignTokens.Spacing4,\n width: \"100%\",\n maxWidth: isFullWidth\n ? \"100%\"\n : odysseyDesignTokens.TypographyLineLengthMax,\n }}\n value={value}\n />\n </Box>\n );\n};\n\nconst MemoizedSwitch = memo(Switch);\nMemoizedSwitch.displayName = \"Switch\";\n\nexport { MemoizedSwitch as Switch };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,IAAI,EAEJC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAOd,MAAM;EAAEC;AAAW,CAAC,GAAGC,wBAAwB;AAAC,SACvCC,sBAAsB;AAAA,SACtBC,GAAG;AAAA,SAEHC,SAAS;AAAA,SAETC,WAAW;AAAA,SACXJ,wBAAwB,EAAEK,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAwClD,MAAMC,WAAW,GAAGC,IAAA,IAMI;EAAA,IANH;IACnBC,OAAO;IACPC,IAAI;IACJC,MAAM;IACNC,WAAW;IACXC;EACgB,CAAC,GAAAL,IAAA;EACjB,MAAMM,mBAAmB,GAAGlB,sBAAsB,CAAC,CAAC;EAEpD,OACEQ,KAAA,CAAAE,SAAA;IAAAS,QAAA,GACEX,KAAA,CAACP,GAAG;MACFmB,EAAE,EAAE;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EA;IAAM,CACd;EAAC,CACC,CAAC;AAEV,CAAC;AAED,MAAM2B,cAAc,GAAG9F,IAAI,CAACyD,MAAM,CAAC;AACnCqC,cAAc,CAACC,WAAW,GAAG,QAAQ;AAErC,SAASD,cAAc,IAAIrC,MAAM"}
@@ -22,4 +22,5 @@ export * from "./StaticTable.js";
22
22
  export * from "./PaginatedTable.js";
23
23
  export * from "./GroupPicker.js";
24
24
  export * from "./VirtualizedAutocomplete.js";
25
+ export * from "./Switch.js";
25
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["AdapterDateFns","LocalizationProvider"],"sources":["../../src/labs/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2022-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 { AdapterDateFns } from \"@mui/x-date-pickers/AdapterDateFns\";\nexport { LocalizationProvider } from \"@mui/x-date-pickers\";\nexport type { LocalizationProviderProps } from \"@mui/x-date-pickers\";\n\nexport * from \"./DatePicker\";\nexport * from \"./datePickerTheme\";\n\nexport * from \"./DataTable\";\nexport * from \"./DataTablePagination\";\nexport * from \"./DataFilters\";\n\nexport * from \"./materialReactTableTypes\";\nexport * from \"./StaticTable\";\nexport * from \"./PaginatedTable\";\n\nexport * from \"./GroupPicker\";\nexport * from \"./VirtualizedAutocomplete\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,oCAAoC;AACnE,SAASC,oBAAoB,QAAQ,qBAAqB;AAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA"}
1
+ {"version":3,"file":"index.js","names":["AdapterDateFns","LocalizationProvider"],"sources":["../../src/labs/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2022-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 { AdapterDateFns } from \"@mui/x-date-pickers/AdapterDateFns\";\nexport { LocalizationProvider } from \"@mui/x-date-pickers\";\nexport type { LocalizationProviderProps } from \"@mui/x-date-pickers\";\n\nexport * from \"./DatePicker\";\nexport * from \"./datePickerTheme\";\n\nexport * from \"./DataTable\";\nexport * from \"./DataTablePagination\";\nexport * from \"./DataFilters\";\n\nexport * from \"./materialReactTableTypes\";\nexport * from \"./StaticTable\";\nexport * from \"./PaginatedTable\";\n\nexport * from \"./GroupPicker\";\nexport * from \"./VirtualizedAutocomplete\";\n\nexport * from \"./Switch\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,oCAAoC;AACnE,SAASC,oBAAoB,QAAQ,qBAAqB;AAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA"}
@@ -75,6 +75,7 @@ export * from "./TextField";
75
75
  export * from "./theme";
76
76
  export * from "./Toast";
77
77
  export * from "./ToastStack";
78
+ export * from "./labs/Switch";
78
79
  export * from "./Tooltip";
79
80
  export * from "./Typography";
80
81
  export * from "./useUniqueId";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":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AC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,41 @@
1
+ /*!
2
+ * Copyright (c) 2022-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
+ /// <reference types="react" />
13
+ import { SwitchProps as MuiSwitchProps } from "@mui/material";
14
+ import { FieldComponentProps } from "../FieldComponentProps";
15
+ import type { SeleniumProps } from "../SeleniumProps";
16
+ import { CheckedFieldProps } from "../FormCheckedProps";
17
+ type OnChangeCallbackArguments = {
18
+ checked: boolean;
19
+ value: string;
20
+ };
21
+ export type SwitchProps = {
22
+ /**
23
+ * if `true`, the label and switch span entire containing element's width
24
+ */
25
+ isFullWidth?: boolean;
26
+ /**
27
+ * The label text for the Switch
28
+ */
29
+ label: string;
30
+ /**
31
+ * The change event handler for the Switch
32
+ */
33
+ onChange?: ({ checked, value }: OnChangeCallbackArguments) => void;
34
+ /**
35
+ * The value attribute of the Switch
36
+ */
37
+ value: string;
38
+ } & Pick<FieldComponentProps, "hint" | "id" | "isFullWidth" | "isDisabled" | "name"> & CheckedFieldProps<MuiSwitchProps> & SeleniumProps;
39
+ declare const MemoizedSwitch: import("react").MemoExoticComponent<({ hint, id: _id, isChecked, isDefaultChecked, isDisabled, isFullWidth, label, name: _name, onChange, testId, value, }: SwitchProps) => JSX.Element>;
40
+ export { MemoizedSwitch as Switch };
41
+ //# sourceMappingURL=Switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../src/labs/Switch.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;;AAWH,OAAO,EAEL,WAAW,IAAI,cAAc,EAE9B,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,KAAK,yBAAyB,GAAG;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,yBAAyB,KAAK,IAAI,CAAC;IACnE;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,IAAI,CACN,mBAAmB,EACnB,MAAM,GAAG,IAAI,GAAG,aAAa,GAAG,YAAY,GAAG,MAAM,CACtD,GACC,iBAAiB,CAAC,cAAc,CAAC,GACjC,aAAa,CAAC;AAkLhB,QAAA,MAAM,cAAc,8JA1GjB,WAAW,iBA0GqB,CAAC;AAGpC,OAAO,EAAE,cAAc,IAAI,MAAM,EAAE,CAAC"}
@@ -22,4 +22,5 @@ export * from "./StaticTable";
22
22
  export * from "./PaginatedTable";
23
23
  export * from "./GroupPicker";
24
24
  export * from "./VirtualizedAutocomplete";
25
+ export * from "./Switch";
25
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/labs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,YAAY,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAErE,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAElC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAE9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/labs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,YAAY,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAErE,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAElC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAE9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAE1C,cAAc,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../src/theme/components.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAoC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,eAAO,MAAM,UAAU;mBAIN,YAAY;;MAEzB,YAAY,CAAC,YAAY,CA4iF5B,CAAC"}
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../src/theme/components.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAoC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,eAAO,MAAM,UAAU;mBAIN,YAAY;;MAEzB,YAAY,CAAC,YAAY,CAomF5B,CAAC"}
@@ -1237,6 +1237,65 @@ export const components = _ref => {
1237
1237
  }
1238
1238
  }
1239
1239
  },
1240
+ MuiSwitch: {
1241
+ styleOverrides: {
1242
+ root: {
1243
+ position: "relative",
1244
+ padding: `${odysseyTokens.Spacing0} 0`,
1245
+ width: odysseyTokens.Spacing7,
1246
+ height: odysseyTokens.Spacing5,
1247
+ overflow: "visible"
1248
+ },
1249
+ switchBase: _ref17 => {
1250
+ let {
1251
+ ownerState
1252
+ } = _ref17;
1253
+ return {
1254
+ top: odysseyTokens.Spacing1,
1255
+ left: odysseyTokens.Spacing1,
1256
+ padding: `${odysseyTokens.Spacing0} 0`,
1257
+ ...(ownerState.checked === true && {
1258
+ color: `${odysseyTokens.HueNeutralWhite} !important`,
1259
+ transform: `translateX(${odysseyTokens.Spacing4}) !important`
1260
+ }),
1261
+ "&:hover": {
1262
+ backgroundColor: "transparent",
1263
+ ...(ownerState.checked === true && {
1264
+ backgroundColor: "transparent !important"
1265
+ })
1266
+ },
1267
+ "&.Mui-focusVisible": {
1268
+ " + .MuiSwitch-track": {
1269
+ boxShadow: `0 0 0 2px ${odysseyTokens.HueNeutralWhite}, 0 0 0 4px ${odysseyTokens.PalettePrimaryMain}`
1270
+ }
1271
+ }
1272
+ };
1273
+ },
1274
+ thumb: {
1275
+ width: odysseyTokens.Spacing4,
1276
+ height: odysseyTokens.Spacing4,
1277
+ boxShadow: "none"
1278
+ },
1279
+ track: _ref18 => {
1280
+ let {
1281
+ ownerState
1282
+ } = _ref18;
1283
+ return {
1284
+ borderRadius: odysseyTokens.BorderRadiusRound,
1285
+ backgroundColor: `${odysseyTokens.HueNeutral300}`,
1286
+ opacity: 1,
1287
+ ...(ownerState.checked === true && {
1288
+ opacity: "1 !important",
1289
+ backgroundColor: `${odysseyTokens.PaletteSuccessLight} !important`
1290
+ })
1291
+ };
1292
+ },
1293
+ input: {
1294
+ height: "44px",
1295
+ top: "-14px"
1296
+ }
1297
+ }
1298
+ },
1240
1299
  MuiDialog: {
1241
1300
  defaultProps: {
1242
1301
  scroll: "paper"
@@ -1266,10 +1325,10 @@ export const components = _ref => {
1266
1325
  },
1267
1326
  MuiDialogContent: {
1268
1327
  styleOverrides: {
1269
- root: _ref17 => {
1328
+ root: _ref19 => {
1270
1329
  let {
1271
1330
  ownerState
1272
- } = _ref17;
1331
+ } = _ref19;
1273
1332
  return {
1274
1333
  paddingBlock: 0,
1275
1334
  paddingInline: odysseyTokens.Spacing6,
@@ -1322,10 +1381,10 @@ export const components = _ref => {
1322
1381
  margin: "normal"
1323
1382
  },
1324
1383
  styleOverrides: {
1325
- root: _ref18 => {
1384
+ root: _ref20 => {
1326
1385
  let {
1327
1386
  ownerState
1328
- } = _ref18;
1387
+ } = _ref20;
1329
1388
  return {
1330
1389
  width: "100%",
1331
1390
  maxWidth: odysseyTokens.TypographyLineLengthMax,
@@ -1355,10 +1414,10 @@ export const components = _ref => {
1355
1414
  },
1356
1415
  MuiFormControlLabel: {
1357
1416
  styleOverrides: {
1358
- root: _ref19 => {
1417
+ root: _ref21 => {
1359
1418
  let {
1360
1419
  ownerState
1361
- } = _ref19;
1420
+ } = _ref21;
1362
1421
  return {
1363
1422
  gap: odysseyTokens.Spacing2,
1364
1423
  marginInlineStart: 0,
@@ -1473,10 +1532,10 @@ export const components = _ref => {
1473
1532
  },
1474
1533
  MuiInputAdornment: {
1475
1534
  styleOverrides: {
1476
- root: _ref20 => {
1535
+ root: _ref22 => {
1477
1536
  let {
1478
1537
  ownerState
1479
- } = _ref20;
1538
+ } = _ref22;
1480
1539
  return {
1481
1540
  display: "flex",
1482
1541
  minWidth: "1.25em",
@@ -1503,11 +1562,11 @@ export const components = _ref => {
1503
1562
  minRows: 3
1504
1563
  },
1505
1564
  styleOverrides: {
1506
- root: _ref21 => {
1565
+ root: _ref23 => {
1507
1566
  let {
1508
1567
  ownerState,
1509
1568
  theme
1510
- } = _ref21;
1569
+ } = _ref23;
1511
1570
  return {
1512
1571
  ...theme.typography.body1,
1513
1572
  flex: "1",
@@ -1598,10 +1657,10 @@ export const components = _ref => {
1598
1657
  shrink: false
1599
1658
  },
1600
1659
  styleOverrides: {
1601
- root: _ref22 => {
1660
+ root: _ref24 => {
1602
1661
  let {
1603
1662
  ownerState
1604
- } = _ref22;
1663
+ } = _ref24;
1605
1664
  return {
1606
1665
  display: "flex",
1607
1666
  justifyContent: "space-between",
@@ -1730,10 +1789,10 @@ export const components = _ref => {
1730
1789
  },
1731
1790
  MuiMenuItem: {
1732
1791
  styleOverrides: {
1733
- root: _ref23 => {
1792
+ root: _ref25 => {
1734
1793
  let {
1735
1794
  ownerState
1736
- } = _ref23;
1795
+ } = _ref25;
1737
1796
  return {
1738
1797
  gap: odysseyTokens.Spacing2,
1739
1798
  minHeight: "unset",
@@ -1856,10 +1915,10 @@ export const components = _ref => {
1856
1915
  checkedIcon: _jsx(_Fragment, {})
1857
1916
  },
1858
1917
  styleOverrides: {
1859
- root: _ref24 => {
1918
+ root: _ref26 => {
1860
1919
  let {
1861
1920
  theme
1862
- } = _ref24;
1921
+ } = _ref26;
1863
1922
  return {
1864
1923
  width: `${odysseyTokens.TypographyLineHeightUi}em`,
1865
1924
  height: `${odysseyTokens.TypographyLineHeightUi}em`,
@@ -1982,10 +2041,10 @@ export const components = _ref => {
1982
2041
  color: "inherit"
1983
2042
  },
1984
2043
  styleOverrides: {
1985
- root: _ref25 => {
2044
+ root: _ref27 => {
1986
2045
  let {
1987
2046
  ownerState
1988
- } = _ref25;
2047
+ } = _ref27;
1989
2048
  return {
1990
2049
  fontSize: `${odysseyTokens.TypographyLineHeightUi}rem`,
1991
2050
  ...(ownerState.fontSize === "small" && {
@@ -2003,10 +2062,10 @@ export const components = _ref => {
2003
2062
  iconPosition: "start"
2004
2063
  },
2005
2064
  styleOverrides: {
2006
- root: _ref26 => {
2065
+ root: _ref28 => {
2007
2066
  let {
2008
2067
  ownerState
2009
- } = _ref26;
2068
+ } = _ref28;
2010
2069
  return {
2011
2070
  maxWidth: `calc(${odysseyTokens.TypographyLineLengthMax} / 2)`,
2012
2071
  minWidth: "unset",
@@ -2076,10 +2135,10 @@ export const components = _ref => {
2076
2135
  },
2077
2136
  MuiTable: {
2078
2137
  styleOverrides: {
2079
- root: _ref27 => {
2138
+ root: _ref29 => {
2080
2139
  let {
2081
2140
  ownerState
2082
- } = _ref27;
2141
+ } = _ref29;
2083
2142
  return {
2084
2143
  display: "table",
2085
2144
  width: "auto",
@@ -2113,11 +2172,11 @@ export const components = _ref => {
2113
2172
  },
2114
2173
  MuiTableCell: {
2115
2174
  styleOverrides: {
2116
- root: _ref28 => {
2175
+ root: _ref30 => {
2117
2176
  let {
2118
2177
  theme,
2119
2178
  ownerState
2120
- } = _ref28;
2179
+ } = _ref30;
2121
2180
  return {
2122
2181
  ...theme.typography.body1,
2123
2182
  borderBottom: `${odysseyTokens.BorderWidthMain} ${odysseyTokens.BorderStyleMain} ${odysseyTokens.HueNeutral100}`,
@@ -2333,10 +2392,10 @@ export const components = _ref => {
2333
2392
  color: odysseyTokens.TypographyColorBody
2334
2393
  }
2335
2394
  },
2336
- icon: _ref29 => {
2395
+ icon: _ref31 => {
2337
2396
  let {
2338
2397
  ownerState
2339
- } = _ref29;
2398
+ } = _ref31;
2340
2399
  return {
2341
2400
  ...(ownerState.direction === "asc" && {
2342
2401
  transform: "rotate(180deg) !important"
@@ -2365,10 +2424,10 @@ export const components = _ref => {
2365
2424
  placement: "top"
2366
2425
  },
2367
2426
  styleOverrides: {
2368
- tooltip: _ref30 => {
2427
+ tooltip: _ref32 => {
2369
2428
  let {
2370
2429
  ownerState
2371
- } = _ref30;
2430
+ } = _ref32;
2372
2431
  return {
2373
2432
  maxWidth: `calc(${odysseyTokens.TypographyLineLengthMax} / 2)`,
2374
2433
  paddingBlock: odysseyTokens.Spacing2,