@hitachivantara/uikit-react-core 5.63.0 → 5.63.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.
- package/dist/cjs/AppSwitcher/Action/Action.cjs +1 -1
- package/dist/cjs/Avatar/Avatar.cjs +4 -1
- package/dist/cjs/AvatarGroup/AvatarGroup.cjs +95 -51
- package/dist/cjs/AvatarGroup/AvatarGroup.styles.cjs +54 -4
- package/dist/cjs/AvatarGroup/AvatarGroupContext.cjs +19 -0
- package/dist/cjs/CheckBoxGroup/CheckBoxGroup.styles.cjs +2 -2
- package/dist/cjs/Dialog/Dialog.cjs +0 -1
- package/dist/cjs/Drawer/Drawer.cjs +0 -5
- package/dist/cjs/FilterGroup/Counter/Counter.cjs +4 -6
- package/dist/cjs/FilterGroup/LeftPanel/LeftPanel.cjs +13 -17
- package/dist/cjs/FilterGroup/RightPanel/RightPanel.styles.cjs +1 -4
- package/dist/cjs/Input/Input.cjs +1 -3
- package/dist/cjs/List/List.cjs +25 -57
- package/dist/cjs/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.cjs +25 -20
- package/dist/cjs/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.cjs +24 -29
- package/dist/cjs/ScrollTo/Horizontal/ScrollToHorizontal.cjs +28 -66
- package/dist/cjs/ScrollTo/Horizontal/ScrollToHorizontal.styles.cjs +3 -20
- package/dist/cjs/ScrollTo/Vertical/ScrollToVertical.cjs +9 -22
- package/dist/cjs/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.cjs +8 -15
- package/dist/cjs/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.cjs +12 -7
- package/dist/cjs/providers/ThemeProvider.cjs +7 -0
- package/dist/esm/AppSwitcher/Action/Action.js +1 -1
- package/dist/esm/Avatar/Avatar.js +4 -1
- package/dist/esm/Avatar/Avatar.js.map +1 -1
- package/dist/esm/AvatarGroup/AvatarGroup.js +97 -53
- package/dist/esm/AvatarGroup/AvatarGroup.js.map +1 -1
- package/dist/esm/AvatarGroup/AvatarGroup.styles.js +54 -4
- package/dist/esm/AvatarGroup/AvatarGroup.styles.js.map +1 -1
- package/dist/esm/AvatarGroup/AvatarGroupContext.js +19 -0
- package/dist/esm/AvatarGroup/AvatarGroupContext.js.map +1 -0
- package/dist/esm/CheckBoxGroup/CheckBoxGroup.styles.js +2 -2
- package/dist/esm/CheckBoxGroup/CheckBoxGroup.styles.js.map +1 -1
- package/dist/esm/Dialog/Dialog.js +0 -1
- package/dist/esm/Dialog/Dialog.js.map +1 -1
- package/dist/esm/Drawer/Drawer.js +0 -5
- package/dist/esm/Drawer/Drawer.js.map +1 -1
- package/dist/esm/FilterGroup/Counter/Counter.js +4 -6
- package/dist/esm/FilterGroup/Counter/Counter.js.map +1 -1
- package/dist/esm/FilterGroup/LeftPanel/LeftPanel.js +13 -17
- package/dist/esm/FilterGroup/LeftPanel/LeftPanel.js.map +1 -1
- package/dist/esm/FilterGroup/RightPanel/RightPanel.js.map +1 -1
- package/dist/esm/FilterGroup/RightPanel/RightPanel.styles.js +1 -4
- package/dist/esm/FilterGroup/RightPanel/RightPanel.styles.js.map +1 -1
- package/dist/esm/Input/Input.js +1 -3
- package/dist/esm/Input/Input.js.map +1 -1
- package/dist/esm/List/List.js +25 -57
- package/dist/esm/List/List.js.map +1 -1
- package/dist/esm/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.js +26 -21
- package/dist/esm/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.js.map +1 -1
- package/dist/esm/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.js +24 -29
- package/dist/esm/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.js.map +1 -1
- package/dist/esm/ScrollTo/Horizontal/ScrollToHorizontal.js +29 -67
- package/dist/esm/ScrollTo/Horizontal/ScrollToHorizontal.js.map +1 -1
- package/dist/esm/ScrollTo/Horizontal/ScrollToHorizontal.styles.js +3 -20
- package/dist/esm/ScrollTo/Horizontal/ScrollToHorizontal.styles.js.map +1 -1
- package/dist/esm/ScrollTo/Vertical/ScrollToVertical.js +9 -22
- package/dist/esm/ScrollTo/Vertical/ScrollToVertical.js.map +1 -1
- package/dist/esm/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.js +8 -15
- package/dist/esm/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.js.map +1 -1
- package/dist/esm/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.js +12 -7
- package/dist/esm/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.js.map +1 -1
- package/dist/esm/providers/ThemeProvider.js +7 -0
- package/dist/esm/providers/ThemeProvider.js.map +1 -1
- package/dist/types/index.d.ts +24 -16
- package/package.json +5 -5
- package/dist/cjs/ScrollTo/withTooltip.cjs +0 -17
- package/dist/esm/ScrollTo/withTooltip.js +0 -17
- package/dist/esm/ScrollTo/withTooltip.js.map +0 -1
package/dist/esm/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.js
CHANGED
|
@@ -4,49 +4,44 @@ import { outlineStyles } from "../../../utils/focusUtils.js";
|
|
|
4
4
|
const name = "HvHorizontalScrollListItem";
|
|
5
5
|
const { staticClasses, useClasses } = createClasses(name, {
|
|
6
6
|
root: {
|
|
7
|
-
padding: "
|
|
7
|
+
padding: theme.spacing("xs", 0),
|
|
8
|
+
maxWidth: 120
|
|
8
9
|
},
|
|
9
10
|
button: {
|
|
10
11
|
display: "flex",
|
|
12
|
+
flexDirection: "column",
|
|
11
13
|
justifyContent: "center",
|
|
12
14
|
alignItems: "center",
|
|
13
|
-
height: "48px",
|
|
14
|
-
cursor: "pointer",
|
|
15
|
-
borderBottom: "none",
|
|
16
|
-
"&:hover": {
|
|
17
|
-
backgroundColor: "transparent",
|
|
18
|
-
"& $notSelected": {
|
|
19
|
-
height: "6px",
|
|
20
|
-
width: "6px",
|
|
21
|
-
backgroundColor: theme.colors.secondary
|
|
22
|
-
},
|
|
23
|
-
"& $notSelectedRoot": {
|
|
24
|
-
backgroundColor: theme.colors.containerBackgroundHover
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"&:focus": {
|
|
28
|
-
outline: "none"
|
|
29
|
-
},
|
|
30
15
|
"&:focus-visible": {
|
|
31
16
|
...outlineStyles
|
|
32
17
|
}
|
|
33
18
|
},
|
|
34
19
|
text: {
|
|
20
|
+
margin: theme.spacing("xs", "xs", "0")
|
|
21
|
+
},
|
|
22
|
+
selected: {
|
|
23
|
+
fontWeight: theme.typography.label.fontWeight
|
|
24
|
+
},
|
|
25
|
+
bullet: {
|
|
35
26
|
display: "flex",
|
|
36
|
-
flexDirection: "column",
|
|
37
|
-
alignItems: "center",
|
|
38
27
|
justifyContent: "center",
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
minHeight: 24,
|
|
30
|
+
height: 24,
|
|
31
|
+
width: 24,
|
|
32
|
+
fontSize: 4,
|
|
33
|
+
color: theme.colors.secondary_60,
|
|
34
|
+
"& > span": {
|
|
35
|
+
margin: "auto",
|
|
36
|
+
width: "1em",
|
|
37
|
+
height: "1em",
|
|
38
|
+
backgroundColor: "currentcolor",
|
|
39
|
+
borderRadius: "50%"
|
|
46
40
|
}
|
|
47
41
|
},
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
bulletSelected: {
|
|
43
|
+
fontSize: 6,
|
|
44
|
+
color: theme.colors.secondary
|
|
50
45
|
}
|
|
51
46
|
});
|
|
52
47
|
export {
|
package/dist/esm/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HorizontalScrollListItem.styles.js","sources":["../../../../../src/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../../../utils/classes\";\nimport { outlineStyles } from \"../../../utils/focusUtils\";\n\nconst name = \"HvHorizontalScrollListItem\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n root: {\n padding: \"
|
|
1
|
+
{"version":3,"file":"HorizontalScrollListItem.styles.js","sources":["../../../../../src/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../../../utils/classes\";\nimport { outlineStyles } from \"../../../utils/focusUtils\";\n\nconst name = \"HvHorizontalScrollListItem\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n root: {\n padding: theme.spacing(\"xs\", 0),\n maxWidth: 120,\n },\n button: {\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n \"&:focus-visible\": {\n ...outlineStyles,\n },\n },\n text: {\n margin: theme.spacing(\"xs\", \"xs\", \"0\"),\n },\n selected: {\n fontWeight: theme.typography.label.fontWeight,\n },\n bullet: {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n minHeight: 24,\n height: 24,\n width: 24,\n fontSize: 4,\n color: theme.colors.secondary_60,\n\n \"& > span\": {\n margin: \"auto\",\n width: \"1em\",\n height: \"1em\",\n backgroundColor: \"currentcolor\",\n borderRadius: \"50%\",\n },\n },\n bulletSelected: {\n fontSize: 6,\n color: theme.colors.secondary,\n },\n});\n"],"names":[],"mappings":";;;AAKA,MAAM,OAAO;AAEN,MAAM,EAAE,eAAe,eAAe,cAAc,MAAM;AAAA,EAC/D,MAAM;AAAA,IACJ,SAAS,MAAM,QAAQ,MAAM,CAAC;AAAA,IAC9B,UAAU;AAAA,EACZ;AAAA,EACA,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,mBAAmB;AAAA,MACjB,GAAG;AAAA,IACL;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,QAAQ,MAAM,QAAQ,MAAM,MAAM,GAAG;AAAA,EACvC;AAAA,EACA,UAAU;AAAA,IACR,YAAY,MAAM,WAAW,MAAM;AAAA,EACrC;AAAA,EACA,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU;AAAA,IACV,OAAO,MAAM,OAAO;AAAA,IAEpB,YAAY;AAAA,MACV,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,iBAAiB;AAAA,MACjB,cAAc;AAAA,IAChB;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd,UAAU;AAAA,IACV,OAAO,MAAM,OAAO;AAAA,EACtB;AACF,CAAC;"}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { useMemo, useCallback } from "react";
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
3
2
|
import { useTheme } from "@mui/material/styles";
|
|
4
3
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
5
|
-
import { CurrentStep } from "@hitachivantara/uikit-react-icons";
|
|
6
4
|
import { theme } from "@hitachivantara/uikit-styles";
|
|
7
5
|
import { useDefaultProps } from "../../hooks/useDefaultProps.js";
|
|
8
|
-
import { useTheme as useTheme$1 } from "../../hooks/useTheme.js";
|
|
9
|
-
import { useUniqueId } from "../../hooks/useUniqueId.js";
|
|
10
6
|
import { isKey } from "../../utils/keyboardUtils.js";
|
|
11
7
|
import { setId } from "../../utils/setId.js";
|
|
12
8
|
import { useScrollTo } from "../useScrollTo.js";
|
|
13
|
-
import { withTooltip } from "../withTooltip.js";
|
|
14
9
|
import { useClasses } from "./ScrollToHorizontal.styles.js";
|
|
15
10
|
import { staticClasses } from "./ScrollToHorizontal.styles.js";
|
|
16
11
|
import { HvHorizontalScrollListItem } from "./HorizontalScrollListItem/HorizontalScrollListItem.js";
|
|
@@ -37,8 +32,6 @@ const HvScrollToHorizontal = (props) => {
|
|
|
37
32
|
const muiTheme = useTheme();
|
|
38
33
|
const downSm = useMediaQuery(muiTheme.breakpoints.down("sm"));
|
|
39
34
|
const upMd = useMediaQuery(muiTheme.breakpoints.up("md"));
|
|
40
|
-
const { activeTheme } = useTheme$1();
|
|
41
|
-
const elementId = useUniqueId(id);
|
|
42
35
|
const [selectedIndex, setScrollTo, elements] = useScrollTo(
|
|
43
36
|
defaultSelectedIndex,
|
|
44
37
|
scrollElementId,
|
|
@@ -48,65 +41,34 @@ const HvScrollToHorizontal = (props) => {
|
|
|
48
41
|
options,
|
|
49
42
|
onChange
|
|
50
43
|
);
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const Selected = useCallback(() => {
|
|
67
|
-
return /* @__PURE__ */ jsx(
|
|
68
|
-
CurrentStep,
|
|
69
|
-
{
|
|
70
|
-
height: activeTheme?.scrollTo.dotSelectedSize,
|
|
71
|
-
width: activeTheme?.scrollTo.dotSelectedSize,
|
|
72
|
-
className: classes.selected
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
|
-
}, [classes.selected, activeTheme?.scrollTo.dotSelectedSize]);
|
|
76
|
-
const tabs = elements.map((option, index) => {
|
|
77
|
-
const selected = selectedIndex === index;
|
|
78
|
-
const tooltipWrapper = tooltipWrappers[index];
|
|
79
|
-
return /* @__PURE__ */ jsxs(
|
|
80
|
-
HvHorizontalScrollListItem,
|
|
81
|
-
{
|
|
82
|
-
id: setId(elementId, `item-${index}`),
|
|
83
|
-
onClick: (event) => {
|
|
84
|
-
if (navigationMode !== "none") {
|
|
85
|
-
event.preventDefault();
|
|
86
|
-
}
|
|
87
|
-
handleSelection(event, option.value, index);
|
|
88
|
-
onClick?.(event, index);
|
|
89
|
-
},
|
|
90
|
-
onKeyDown: (event) => {
|
|
91
|
-
if (isKey(event, "Enter") === true) {
|
|
92
|
-
if (navigationMode !== "none") {
|
|
93
|
-
event.preventDefault();
|
|
94
|
-
}
|
|
95
|
-
handleSelection(event, option.value, index);
|
|
96
|
-
onEnter?.(event, index);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
href: navigationMode !== "none" ? option.href : void 0,
|
|
100
|
-
tooltipWrapper,
|
|
101
|
-
selected,
|
|
102
|
-
children: [
|
|
103
|
-
/* @__PURE__ */ jsx("p", { children: option.label }),
|
|
104
|
-
selected ? /* @__PURE__ */ jsx(Selected, {}) : /* @__PURE__ */ jsx(NotSelected, {})
|
|
105
|
-
]
|
|
44
|
+
const tabs = elements.map((option, index) => /* @__PURE__ */ jsx(
|
|
45
|
+
HvHorizontalScrollListItem,
|
|
46
|
+
{
|
|
47
|
+
id: setId(id, `item-${index}`),
|
|
48
|
+
onClick: (event) => {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
setScrollTo(event, option.value, index, () => onChange?.(event, index));
|
|
51
|
+
onClick?.(event, index);
|
|
52
|
+
},
|
|
53
|
+
onKeyDown: (event) => {
|
|
54
|
+
if (isKey(event, "Enter") !== true)
|
|
55
|
+
return;
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
setScrollTo(event, option.value, index, () => onChange?.(event, index));
|
|
58
|
+
onEnter?.(event, index);
|
|
106
59
|
},
|
|
107
|
-
option.
|
|
108
|
-
|
|
109
|
-
|
|
60
|
+
href: navigationMode !== "none" ? option.href : void 0,
|
|
61
|
+
tooltipPlacement: tooltipPosition,
|
|
62
|
+
selected: selectedIndex === index,
|
|
63
|
+
label: option.label,
|
|
64
|
+
iconClasses: cx({
|
|
65
|
+
[classes.selected]: selectedIndex === index,
|
|
66
|
+
[classes.notSelected]: selectedIndex !== index,
|
|
67
|
+
[classes.notSelectedRoot]: selectedIndex !== index
|
|
68
|
+
})
|
|
69
|
+
},
|
|
70
|
+
option.key || option.label
|
|
71
|
+
));
|
|
110
72
|
return /* @__PURE__ */ jsx(
|
|
111
73
|
"ol",
|
|
112
74
|
{
|
|
@@ -125,7 +87,7 @@ const HvScrollToHorizontal = (props) => {
|
|
|
125
87
|
},
|
|
126
88
|
className
|
|
127
89
|
),
|
|
128
|
-
id
|
|
90
|
+
id,
|
|
129
91
|
...others,
|
|
130
92
|
children: tabs
|
|
131
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollToHorizontal.js","sources":["../../../../src/ScrollTo/Horizontal/ScrollToHorizontal.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport { useTheme as useMuiTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\nimport { CurrentStep } from \"@hitachivantara/uikit-react-icons\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { useTheme } from \"../../hooks/useTheme\";\nimport { useUniqueId } from \"../../hooks/useUniqueId\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { isKey } from \"../../utils/keyboardUtils\";\nimport { setId } from \"../../utils/setId\";\nimport { HvScrollToTooltipPositions } from \"../types\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport { withTooltip } from \"../withTooltip\";\nimport { HvHorizontalScrollListItem } from \"./HorizontalScrollListItem\";\nimport { staticClasses, useClasses } from \"./ScrollToHorizontal.styles\";\n\nexport { staticClasses as scrollToHorizontalClasses };\n\nexport type HvScrollToHorizontalClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvScrollToHorizontalOption {\n key?: string;\n label: string;\n value: string;\n offset?: number;\n}\n\nexport type HvScrollToHorizontalPositions = \"sticky\" | \"fixed\" | \"relative\";\n\nexport interface HvScrollToHorizontalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToHorizontalOption[];\n /**\n * Should the active element be reflected in the URL.\n *\n * @default true\n *\n * @deprecated Use `navigationMode` instead.\n * */\n href?: boolean;\n /**\n * The navigation mode to be used when the user clicks on a tab element.\n * - `push` will add a new entry to the history stack.\n * - `replace` will replace the current entry on the history stack.\n * - `none` will not add any entry to the history stack.\n *\n * Defaults to `push`, unless the deprecated `href` prop is set to `false`, in which case it defaults to `none`.\n *\n * When set to `none`, then each element will render a button instead of a link.\n *\n * @default \"push\"\n */\n navigationMode?: \"push\" | \"replace\" | \"none\";\n /**\n * When set to `true`, the generated links will be relative (e.g. `#section`).\n * Relative URLs take into account not only the current location, but also the base URL if it is set (i.e. a `<base>` tag).\n * This can lead to unexpected behavior.\n *\n * When set to `false`, the links will be generated from the current location's full URL (e.g. `http://example.com/hello/world?value=123#section`).\n *\n * @default false\n */\n relativeLinks?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Horizontal scroll to. */\n position?: HvScrollToHorizontalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (\n event: React.MouseEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (\n event: React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToHorizontalClasses;\n}\n\n/**\n * The horizontal scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToHorizontal = (props: HvScrollToHorizontalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n navigationMode = href ? \"push\" : \"none\",\n relativeLinks = false,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"top\",\n ...others\n } = useDefaultProps(\"HvScrollToHorizontal\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const muiTheme = useMuiTheme();\n\n const downSm = useMediaQuery(muiTheme.breakpoints.down(\"sm\"));\n const upMd = useMediaQuery(muiTheme.breakpoints.up(\"md\"));\n\n const { activeTheme } = useTheme();\n\n const elementId = useUniqueId(id);\n\n const [selectedIndex, setScrollTo, elements] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n navigationMode,\n relativeLinks,\n offset,\n options,\n onChange,\n );\n\n const handleSelection = (\n event:\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n value: string,\n index: number,\n ) => {\n event.preventDefault();\n\n const wrappedOnChange = () => {\n onChange?.(event, index);\n };\n\n setScrollTo(event, value, index, wrappedOnChange);\n };\n\n const tooltipWrappers = useMemo(() => {\n return options.map((option) => {\n return withTooltip(option.label, \"div\", tooltipPosition);\n });\n }, [options, tooltipPosition]);\n\n const NotSelected = useCallback(() => {\n return (\n <div className={classes.notSelectedRoot}>\n <div className={classes.notSelected} />\n </div>\n );\n }, [classes.notSelectedRoot, classes.notSelected]);\n\n const Selected = useCallback(() => {\n return (\n <CurrentStep\n height={activeTheme?.scrollTo.dotSelectedSize}\n width={activeTheme?.scrollTo.dotSelectedSize}\n className={classes.selected}\n />\n );\n }, [classes.selected, activeTheme?.scrollTo.dotSelectedSize]);\n\n const tabs = elements.map((option, index) => {\n const selected = selectedIndex === index;\n const tooltipWrapper = tooltipWrappers[index];\n\n return (\n <HvHorizontalScrollListItem\n id={setId(elementId, `item-${index}`)}\n onClick={(event) => {\n if (navigationMode !== \"none\") {\n event.preventDefault();\n }\n\n handleSelection(event, option.value, index);\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") === true) {\n if (navigationMode !== \"none\") {\n event.preventDefault();\n }\n\n handleSelection(event, option.value, index);\n onEnter?.(event, index);\n }\n }}\n href={navigationMode !== \"none\" ? option.href : undefined}\n tooltipWrapper={tooltipWrapper}\n selected={selected}\n key={option.key || option.label}\n >\n <p>{option.label}</p>\n {selected ? <Selected /> : <NotSelected />}\n </HvHorizontalScrollListItem>\n );\n });\n\n return (\n <ol\n className={cx(\n css({\n width:\n position === \"fixed\" && (upMd || downSm)\n ? `calc(100% - 2*${theme.spacing(upMd ? 4 : 2)})`\n : \"100%\",\n marginTop: 0,\n marginBottom: 0,\n marginRight:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n marginLeft:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n }),\n classes.root,\n {\n [classes.positionSticky]: position === \"sticky\",\n [classes.positionFixed]: position === \"fixed\",\n },\n className,\n )}\n id={elementId}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":["useMuiTheme","useTheme"],"mappings":";;;;;;;;;;;;;;;;AAgHa,MAAA,uBAAuB,CAAC,UAAqC;AAClE,QAAA;AAAA,IACJ;AAAA,IACA,uBAAuB;AAAA,IACvB;AAAA,IACA,OAAO;AAAA,IACP,iBAAiB,OAAO,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,QAAQ,UAC7B,MAAM,QAAQ,OAAO,IAAI,CAAC,IAC1B;AAAA,UACN,YACE,aAAa,YAAY,QAAQ,UAC7B,MAAM,QAAQ,OAAO,IAAI,CAAC,IAC1B;AAAA,QAAA,CACP;AAAA,QACD,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,cAAc,GAAG,aAAa;AAAA,UACvC,CAAC,QAAQ,aAAa,GAAG,aAAa;AAAA,QACxC;AAAA,QACA;AAAA,MACF;AAAA,MACA,IAAI;AAAA,MACH,GAAG;AAAA,MAEH,UAAA;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
1
|
+
{"version":3,"file":"ScrollToHorizontal.js","sources":["../../../../src/ScrollTo/Horizontal/ScrollToHorizontal.tsx"],"sourcesContent":["import { useTheme as useMuiTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { isKey } from \"../../utils/keyboardUtils\";\nimport { setId } from \"../../utils/setId\";\nimport { HvScrollToOption, HvScrollToTooltipPositions } from \"../types\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport { HvHorizontalScrollListItem } from \"./HorizontalScrollListItem\";\nimport { staticClasses, useClasses } from \"./ScrollToHorizontal.styles\";\n\nexport { staticClasses as scrollToHorizontalClasses };\n\nexport type HvScrollToHorizontalClasses = ExtractNames<typeof useClasses>;\n\nexport type HvScrollToHorizontalPositions = \"sticky\" | \"fixed\" | \"relative\";\n\nexport interface HvScrollToHorizontalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToOption[];\n /**\n * Should the active element be reflected in the URL.\n *\n * @default true\n *\n * @deprecated Use `navigationMode` instead.\n * */\n href?: boolean;\n /**\n * The navigation mode to be used when the user clicks on a tab element.\n * - `push` will add a new entry to the history stack.\n * - `replace` will replace the current entry on the history stack.\n * - `none` will not add any entry to the history stack.\n *\n * Defaults to `push`, unless the deprecated `href` prop is set to `false`, in which case it defaults to `none`.\n *\n * When set to `none`, then each element will render a button instead of a link.\n *\n * @default \"push\"\n */\n navigationMode?: \"push\" | \"replace\" | \"none\";\n /**\n * When set to `true`, the generated links will be relative (e.g. `#section`).\n * Relative URLs take into account not only the current location, but also the base URL if it is set (i.e. a `<base>` tag).\n * This can lead to unexpected behavior.\n *\n * When set to `false`, the links will be generated from the current location's full URL (e.g. `http://example.com/hello/world?value=123#section`).\n *\n * @default false\n */\n relativeLinks?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Horizontal scroll to. */\n position?: HvScrollToHorizontalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (\n event: React.MouseEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (\n event: React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToHorizontalClasses;\n}\n\n/**\n * The horizontal scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToHorizontal = (props: HvScrollToHorizontalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n navigationMode = href ? \"push\" : \"none\",\n relativeLinks = false,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"top\",\n ...others\n } = useDefaultProps(\"HvScrollToHorizontal\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const muiTheme = useMuiTheme();\n\n const downSm = useMediaQuery(muiTheme.breakpoints.down(\"sm\"));\n const upMd = useMediaQuery(muiTheme.breakpoints.up(\"md\"));\n\n const [selectedIndex, setScrollTo, elements] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n navigationMode,\n relativeLinks,\n offset,\n options,\n onChange,\n );\n\n const tabs = elements.map((option, index) => (\n <HvHorizontalScrollListItem\n id={setId(id, `item-${index}`)}\n onClick={(event) => {\n event.preventDefault();\n\n setScrollTo(event, option.value, index, () => onChange?.(event, index));\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") !== true) return;\n event.preventDefault();\n\n setScrollTo(event, option.value, index, () => onChange?.(event, index));\n onEnter?.(event, index);\n }}\n href={navigationMode !== \"none\" ? option.href : undefined}\n tooltipPlacement={tooltipPosition}\n selected={selectedIndex === index}\n key={option.key || option.label}\n label={option.label}\n iconClasses={cx({\n [classes.selected]: selectedIndex === index,\n [classes.notSelected]: selectedIndex !== index,\n [classes.notSelectedRoot]: selectedIndex !== index,\n })}\n />\n ));\n\n return (\n <ol\n className={cx(\n css({\n width:\n position === \"fixed\" && (upMd || downSm)\n ? `calc(100% - 2*${theme.spacing(upMd ? 4 : 2)})`\n : \"100%\",\n marginTop: 0,\n marginBottom: 0,\n marginRight:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n marginLeft:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n }),\n classes.root,\n {\n [classes.positionSticky]: position === \"sticky\",\n [classes.positionFixed]: position === \"fixed\",\n },\n className,\n )}\n id={id}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":["useMuiTheme"],"mappings":";;;;;;;;;;;AAoGa,MAAA,uBAAuB,CAAC,UAAqC;AAClE,QAAA;AAAA,IACJ;AAAA,IACA,uBAAuB;AAAA,IACvB;AAAA,IACA,OAAO;AAAA,IACP,iBAAiB,OAAO,SAAS;AAAA,IACjC,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,GAAG;AAAA,EAAA,IACD,gBAAgB,wBAAwB,KAAK;AAEjD,QAAM,EAAE,SAAS,KAAK,GAAG,IAAI,WAAW,WAAW;AACnD,QAAM,WAAWA;AAEjB,QAAM,SAAS,cAAc,SAAS,YAAY,KAAK,IAAI,CAAC;AAC5D,QAAM,OAAO,cAAc,SAAS,YAAY,GAAG,IAAI,CAAC;AAExD,QAAM,CAAC,eAAe,aAAa,QAAQ,IAAI;AAAA,IAC7C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,QAAM,OAAO,SAAS,IAAI,CAAC,QAAQ,UACjC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAI,MAAM,IAAI,QAAQ,KAAK,EAAE;AAAA,MAC7B,SAAS,CAAC,UAAU;AAClB,cAAM,eAAe;AAET,oBAAA,OAAO,OAAO,OAAO,OAAO,MAAM,WAAW,OAAO,KAAK,CAAC;AACtE,kBAAU,OAAO,KAAK;AAAA,MACxB;AAAA,MACA,WAAW,CAAC,UAAU;AAChB,YAAA,MAAM,OAAO,OAAO,MAAM;AAAM;AACpC,cAAM,eAAe;AAET,oBAAA,OAAO,OAAO,OA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|
|
31
|
-
width: "16px",
|
|
32
|
-
borderRadius: "50%"
|
|
33
|
-
},
|
|
34
|
-
notSelected: {
|
|
35
|
-
height: "4px",
|
|
36
|
-
width: "4px",
|
|
37
|
-
borderRadius: "50%",
|
|
38
|
-
display: "inline-block",
|
|
39
|
-
backgroundColor: theme.colors.secondary_60
|
|
40
|
-
},
|
|
41
|
-
selected: {
|
|
42
|
-
display: "flex",
|
|
43
|
-
height: "16px",
|
|
44
|
-
width: "16px"
|
|
45
|
-
}
|
|
26
|
+
notSelectedRoot: {},
|
|
27
|
+
notSelected: {},
|
|
28
|
+
selected: {}
|
|
46
29
|
}
|
|
47
30
|
);
|
|
48
31
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollToHorizontal.styles.js","sources":["../../../../src/ScrollTo/Horizontal/ScrollToHorizontal.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../../utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\n \"HvScrollToHorizontal\",\n {\n root: {\n display: \"flex\",\n padding: \"0 30px\",\n listStyleType: \"none\",\n flexWrap: \"wrap\",\n backdropFilter: `blur(4px)`,\n backgroundColor: theme.alpha(\"atmo2\", 0.9),\n },\n positionSticky: {\n position: \"sticky\",\n zIndex: `calc(${theme.zIndices.banner} - 2)`,\n top: 0,\n left: 0,\n },\n positionFixed: {\n position: \"fixed\",\n zIndex: `calc(${theme.zIndices.banner} - 2)`,\n top: 0,\n left: 0,\n },\n notSelectedRoot: {
|
|
1
|
+
{"version":3,"file":"ScrollToHorizontal.styles.js","sources":["../../../../src/ScrollTo/Horizontal/ScrollToHorizontal.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../../utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\n \"HvScrollToHorizontal\",\n {\n root: {\n display: \"flex\",\n padding: \"0 30px\",\n listStyleType: \"none\",\n flexWrap: \"wrap\",\n backdropFilter: `blur(4px)`,\n backgroundColor: theme.alpha(\"atmo2\", 0.9),\n },\n positionSticky: {\n position: \"sticky\",\n zIndex: `calc(${theme.zIndices.banner} - 2)`,\n top: 0,\n left: 0,\n },\n positionFixed: {\n position: \"fixed\",\n zIndex: `calc(${theme.zIndices.banner} - 2)`,\n top: 0,\n left: 0,\n },\n notSelectedRoot: {},\n notSelected: {},\n selected: {},\n },\n);\n"],"names":[],"mappings":";;AAIa,MAAA,EAAE,eAAe,WAAA,IAAe;AAAA,EAC3C;AAAA,EACA;AAAA,IACE,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,SAAS;AAAA,MACT,eAAe;AAAA,MACf,UAAU;AAAA,MACV,gBAAgB;AAAA,MAChB,iBAAiB,MAAM,MAAM,SAAS,GAAG;AAAA,IAC3C;AAAA,IACA,gBAAgB;AAAA,MACd,UAAU;AAAA,MACV,QAAQ,QAAQ,MAAM,SAAS,MAAM;AAAA,MACrC,KAAK;AAAA,MACL,MAAM;AAAA,IACR;AAAA,IACA,eAAe;AAAA,MACb,UAAU;AAAA,MACV,QAAQ,QAAQ,MAAM,SAAS,MAAM;AAAA,MACrC,KAAK;AAAA,MACL,MAAM;AAAA,IACR;AAAA,IACA,iBAAiB,CAAC;AAAA,IAClB,aAAa,CAAC;AAAA,IACd,UAAU,CAAC;AAAA,EACb;AACF;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useDefaultProps } from "../../hooks/useDefaultProps.js";
|
|
3
|
-
import { useUniqueId } from "../../hooks/useUniqueId.js";
|
|
4
3
|
import { isKey } from "../../utils/keyboardUtils.js";
|
|
5
4
|
import { setId } from "../../utils/setId.js";
|
|
6
5
|
import { useScrollTo } from "../useScrollTo.js";
|
|
@@ -28,7 +27,6 @@ const HvScrollToVertical = (props) => {
|
|
|
28
27
|
...others
|
|
29
28
|
} = useDefaultProps("HvScrollToVertical", props);
|
|
30
29
|
const { classes, cx } = useClasses(classesProp);
|
|
31
|
-
const elementId = useUniqueId(id);
|
|
32
30
|
const [selectedIndex, setScrollTo, elements] = useScrollTo(
|
|
33
31
|
defaultSelectedIndex,
|
|
34
32
|
scrollElementId,
|
|
@@ -38,32 +36,21 @@ const HvScrollToVertical = (props) => {
|
|
|
38
36
|
options,
|
|
39
37
|
onChange
|
|
40
38
|
);
|
|
41
|
-
const handleSelection = (event, value, index) => {
|
|
42
|
-
event.preventDefault();
|
|
43
|
-
const wrappedOnChange = () => {
|
|
44
|
-
onChange?.(event, index);
|
|
45
|
-
};
|
|
46
|
-
setScrollTo(event, value, index, wrappedOnChange);
|
|
47
|
-
};
|
|
48
39
|
const tabs = elements.map((option, index) => /* @__PURE__ */ jsx(
|
|
49
40
|
HvVerticalScrollListItem,
|
|
50
41
|
{
|
|
51
|
-
id: setId(
|
|
42
|
+
id: setId(id, `item-${index}`),
|
|
52
43
|
onClick: (event) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
handleSelection(event, option.value, index);
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
setScrollTo(event, option.value, index, () => onChange?.(event, index));
|
|
57
46
|
onClick?.(event, index);
|
|
58
47
|
},
|
|
59
48
|
onKeyDown: (event) => {
|
|
60
|
-
if (isKey(event, "Enter")
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
onEnter?.(event, index);
|
|
66
|
-
}
|
|
49
|
+
if (isKey(event, "Enter") !== true)
|
|
50
|
+
return;
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
setScrollTo(event, option.value, index, () => onChange?.(event, index));
|
|
53
|
+
onEnter?.(event, index);
|
|
67
54
|
},
|
|
68
55
|
href: navigationMode !== "none" ? option.href : void 0,
|
|
69
56
|
tooltipPlacement: tooltipPosition,
|
|
@@ -85,7 +72,7 @@ const HvScrollToVertical = (props) => {
|
|
|
85
72
|
className
|
|
86
73
|
),
|
|
87
74
|
style: { top: `calc(50% - ${positionOffset}px)`, ...style },
|
|
88
|
-
id
|
|
75
|
+
id,
|
|
89
76
|
...others,
|
|
90
77
|
children: tabs
|
|
91
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollToVertical.js","sources":["../../../../src/ScrollTo/Vertical/ScrollToVertical.tsx"],"sourcesContent":["import { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport {
|
|
1
|
+
{"version":3,"file":"ScrollToVertical.js","sources":["../../../../src/ScrollTo/Vertical/ScrollToVertical.tsx"],"sourcesContent":["import { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { isKey } from \"../../utils/keyboardUtils\";\nimport { setId } from \"../../utils/setId\";\nimport {\n HvScrollToOption,\n HvScrollToTooltipPositions,\n HvScrollToVerticalPositions,\n} from \"../types\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport {\n calculateOffset,\n staticClasses,\n useClasses,\n} from \"./ScrollToVertical.styles\";\nimport { HvVerticalScrollListItem } from \"./VerticalScrollListItem\";\n\nexport { staticClasses as scrollToVerticalClasses };\n\nexport type HvScrollToVerticalClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvScrollToVerticalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToOption[];\n /**\n * Should the active element be reflected in the URL.\n *\n * @default true\n *\n * @deprecated Use `navigationMode` instead.\n * */\n href?: boolean;\n /**\n * The navigation mode to be used when the user clicks on a tab element.\n * - `push` will add a new entry to the history stack.\n * - `replace` will replace the current entry on the history stack.\n * - `none` will not add any entry to the history stack.\n *\n * Defaults to `push`, unless the deprecated `href` prop is set to `false`, in which case it defaults to `none`.\n *\n * When set to `none`, then each element will render a button instead of a link.\n *\n * @default \"push\"\n */\n navigationMode?: \"push\" | \"replace\" | \"none\";\n /**\n * When set to `true`, the generated links will be relative (e.g. `#section`).\n * Relative URLs take into account not only the current location, but also the base URL if it is set (i.e. a `<base>` tag).\n * This can lead to unexpected behavior.\n *\n * When set to `false`, the links will be generated from the current location's full URL (e.g. `http://example.com/hello/world?value=123#section`).\n *\n * @default false\n */\n relativeLinks?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Vertical scroll to. */\n position?: HvScrollToVerticalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (\n event: React.MouseEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (\n event: React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToVerticalClasses;\n}\n\n/**\n * The vertical scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToVertical = (props: HvScrollToVerticalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n navigationMode = href ? \"push\" : \"none\",\n relativeLinks = false,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"left\",\n style,\n ...others\n } = useDefaultProps(\"HvScrollToVertical\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const [selectedIndex, setScrollTo, elements] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n navigationMode,\n relativeLinks,\n offset,\n options,\n onChange,\n );\n\n const tabs = elements.map((option, index) => (\n <HvVerticalScrollListItem\n id={setId(id, `item-${index}`)}\n onClick={(event) => {\n event.preventDefault();\n\n setScrollTo(event, option.value, index, () => onChange?.(event, index));\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") !== true) return;\n event.preventDefault();\n\n setScrollTo(event, option.value, index, () => onChange?.(event, index));\n onEnter?.(event, index);\n }}\n href={navigationMode !== \"none\" ? option.href : undefined}\n tooltipPlacement={tooltipPosition}\n selected={selectedIndex === index}\n key={option.key || option.label}\n label={option.label}\n />\n ));\n\n const positionOffset = calculateOffset(options.length);\n\n return (\n <ol\n className={cx(\n classes.root,\n {\n [classes.positionFixed]: position === \"fixed\",\n [classes.positionAbsolute]: position === \"absolute\",\n },\n className,\n )}\n style={{ top: `calc(50% - ${positionOffset}px)`, ...style }}\n id={id}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAsGa,MAAA,qBAAqB,CAAC,UAAmC;AAC9D,QAAA;AAAA,IACJ;AAAA,IACA,uBAAuB;AAAA,IACvB;AAAA,IACA,OAAO;AAAA,IACP,iBAAiB,OAAO,SAAS;AAAA,IACjC,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,sBAAsB,KAAK;AAE/C,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAE9C,QAAM,CAAC,eAAe,aAAa,QAAQ,IAAI;AAAA,IAC7C;AAAA,IACA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ultProps } from "../../../hooks/useDefaultProps.js";
|
|
4
|
-
import { useTheme } from "../../../hooks/useTheme.js";
|
|
5
3
|
import { useClasses } from "./VerticalScrollListItem.styles.js";
|
|
6
4
|
import { staticClasses } from "./VerticalScrollListItem.styles.js";
|
|
7
5
|
import { HvTooltip } from "../../../Tooltip/Tooltip.js";
|
|
@@ -12,33 +10,28 @@ const HvVerticalScrollListItem = (props) => {
|
|
|
12
10
|
classes: classesProp,
|
|
13
11
|
selected,
|
|
14
12
|
label,
|
|
15
|
-
onClick,
|
|
16
|
-
onKeyDown,
|
|
17
13
|
tooltipPlacement = "left",
|
|
18
14
|
href,
|
|
19
15
|
...others
|
|
20
16
|
} = useDefaultProps("HvVerticalScrollListItem", props);
|
|
21
17
|
const { classes, cx } = useClasses(classesProp);
|
|
22
|
-
const { activeTheme } = useTheme();
|
|
23
|
-
const icon = selected ? /* @__PURE__ */ jsx(
|
|
24
|
-
CurrentStep,
|
|
25
|
-
{
|
|
26
|
-
height: activeTheme?.scrollTo.dotSelectedSize,
|
|
27
|
-
width: activeTheme?.scrollTo.dotSelectedSize
|
|
28
|
-
}
|
|
29
|
-
) : /* @__PURE__ */ jsx("div", { className: classes.notSelected });
|
|
30
18
|
const Component = href != null ? "a" : "div";
|
|
31
19
|
return /* @__PURE__ */ jsx("li", { id, className: cx(classes.root, className), "aria-current": selected, children: /* @__PURE__ */ jsx(HvTooltip, { title: label, placement: tooltipPlacement, children: /* @__PURE__ */ jsx(
|
|
32
20
|
Component,
|
|
33
21
|
{
|
|
34
22
|
role: href == null ? "button" : void 0,
|
|
35
23
|
tabIndex: 0,
|
|
36
|
-
onClick,
|
|
37
|
-
onKeyDown,
|
|
38
24
|
className: cx(classes.button, classes.text),
|
|
39
25
|
href,
|
|
40
26
|
...others,
|
|
41
|
-
children:
|
|
27
|
+
children: /* @__PURE__ */ jsx(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
className: cx(classes.icon, {
|
|
31
|
+
[classes.notSelected]: !selected
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
)
|
|
42
35
|
}
|
|
43
36
|
) }) });
|
|
44
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerticalScrollListItem.js","sources":["../../../../../src/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"VerticalScrollListItem.js","sources":["../../../../../src/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.tsx"],"sourcesContent":["import { useDefaultProps } from \"../../../hooks/useDefaultProps\";\nimport { HvTooltip, HvTooltipProps } from \"../../../Tooltip\";\nimport { HvBaseProps } from \"../../../types/generic\";\nimport { ExtractNames } from \"../../../utils/classes\";\nimport { staticClasses, useClasses } from \"./VerticalScrollListItem.styles\";\n\nexport { staticClasses as verticalScrollListItemClasses };\n\nexport type HvVerticalScrollListItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvVerticalScrollListItemProps\n extends HvBaseProps<HTMLDivElement | HTMLAnchorElement> {\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvVerticalScrollListItemClasses;\n /** Whether the element is selected. */\n selected?: boolean;\n label?: React.ReactNode;\n tooltipPlacement?: HvTooltipProps[\"placement\"];\n\n /**\n * The link to be set in the href attribute of the anchor element.\n *\n * If this is not set, the element will be rendered as a div with a button role.\n */\n href?: string;\n}\n\n/**\n * HvVerticalScrollListItem a focusable item to be used as part of the vertical scroll\n */\nexport const HvVerticalScrollListItem = (\n props: HvVerticalScrollListItemProps,\n) => {\n const {\n id,\n className,\n classes: classesProp,\n selected,\n label,\n tooltipPlacement = \"left\",\n href,\n ...others\n } = useDefaultProps(\"HvVerticalScrollListItem\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const Component = href != null ? \"a\" : \"div\";\n\n return (\n <li id={id} className={cx(classes.root, className)} aria-current={selected}>\n <HvTooltip title={label} placement={tooltipPlacement}>\n <Component\n role={href == null ? \"button\" : undefined}\n tabIndex={0}\n className={cx(classes.button, classes.text)}\n href={href}\n {...others}\n >\n <div\n className={cx(classes.icon, {\n [classes.notSelected]: !selected,\n })}\n />\n </Component>\n </HvTooltip>\n </li>\n );\n};\n"],"names":[],"mappings":";;;;;AA8Ba,MAAA,2BAA2B,CACtC,UACG;AACG,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,IACnB;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,4BAA4B,KAAK;AACrD,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAExC,QAAA,YAAY,QAAQ,OAAO,MAAM;AAEvC,6BACG,MAAG,EAAA,IAAQ,WAAW,GAAG,QAAQ,MAAM,SAAS,GAAG,gBAAc,UAChE,UAAC,oBAAA,WAAA,EAAU,OAAO,OAAO,WAAW,kBAClC,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAM,QAAQ,OAAO,WAAW;AAAA,MAChC,UAAU;AAAA,MACV,WAAW,GAAG,QAAQ,QAAQ,QAAQ,IAAI;AAAA,MAC1C;AAAA,MACC,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW,GAAG,QAAQ,MAAM;AAAA,YAC1B,CAAC,QAAQ,WAAW,GAAG,CAAC;AAAA,UAAA,CACzB;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA,EAEJ,CAAA,EACF,CAAA;AAEJ;"}
|
|
@@ -11,12 +11,18 @@ const { staticClasses, useClasses } = createClasses(name, {
|
|
|
11
11
|
justifyContent: "center",
|
|
12
12
|
alignItems: "center"
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
icon: {
|
|
15
|
+
width: "1em",
|
|
16
|
+
height: "1em",
|
|
17
17
|
borderRadius: "50%",
|
|
18
|
+
fontSize: 6,
|
|
19
|
+
color: theme.colors.secondary,
|
|
18
20
|
display: "inline-block",
|
|
19
|
-
backgroundColor:
|
|
21
|
+
backgroundColor: "currentcolor"
|
|
22
|
+
},
|
|
23
|
+
notSelected: {
|
|
24
|
+
fontSize: 4,
|
|
25
|
+
color: theme.colors.secondary_60
|
|
20
26
|
},
|
|
21
27
|
// TODO: remove in v6 (use classes.button)
|
|
22
28
|
text: {},
|
|
@@ -31,9 +37,8 @@ const { staticClasses, useClasses } = createClasses(name, {
|
|
|
31
37
|
"&:hover": {
|
|
32
38
|
backgroundColor: theme.colors.containerBackgroundHover,
|
|
33
39
|
"& $notSelected": {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
backgroundColor: theme.colors.secondary
|
|
40
|
+
fontSize: 6,
|
|
41
|
+
color: theme.colors.secondary
|
|
37
42
|
}
|
|
38
43
|
},
|
|
39
44
|
"&:focus": {
|
package/dist/esm/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerticalScrollListItem.styles.js","sources":["../../../../../src/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../../../utils/classes\";\nimport { outlineStyles } from \"../../../utils/focusUtils\";\n\nconst name = \"HvVerticalScrollListItem\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n root: {\n padding: \"0\",\n height: \"32px\",\n width: \"32px\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n },\n
|
|
1
|
+
{"version":3,"file":"VerticalScrollListItem.styles.js","sources":["../../../../../src/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../../../utils/classes\";\nimport { outlineStyles } from \"../../../utils/focusUtils\";\n\nconst name = \"HvVerticalScrollListItem\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n root: {\n padding: \"0\",\n height: \"32px\",\n width: \"32px\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n },\n icon: {\n width: \"1em\",\n height: \"1em\",\n borderRadius: \"50%\",\n fontSize: 6,\n color: theme.colors.secondary,\n display: \"inline-block\",\n backgroundColor: \"currentcolor\",\n },\n notSelected: {\n fontSize: 4,\n color: theme.colors.secondary_60,\n },\n // TODO: remove in v6 (use classes.button)\n text: {},\n button: {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n height: \"16px\",\n width: \"16px\",\n borderRadius: \"50%\",\n cursor: \"pointer\",\n \"&:hover\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n\n \"& $notSelected\": {\n fontSize: 6,\n color: theme.colors.secondary,\n },\n },\n \"&:focus\": {\n outline: \"none\",\n },\n \"&:focus-visible\": {\n ...outlineStyles,\n },\n },\n});\n"],"names":[],"mappings":";;;AAKA,MAAM,OAAO;AAEN,MAAM,EAAE,eAAe,eAAe,cAAc,MAAM;AAAA,EAC/D,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,YAAY;AAAA,EACd;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,UAAU;AAAA,IACV,OAAO,MAAM,OAAO;AAAA,IACpB,SAAS;AAAA,IACT,iBAAiB;AAAA,EACnB;AAAA,EACA,aAAa;AAAA,IACX,UAAU;AAAA,IACV,OAAO,MAAM,OAAO;AAAA,EACtB;AAAA;AAAA,EAEA,MAAM,CAAC;AAAA,EACP,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,WAAW;AAAA,MACT,iBAAiB,MAAM,OAAO;AAAA,MAE9B,kBAAkB;AAAA,QAChB,UAAU;AAAA,QACV,OAAO,MAAM,OAAO;AAAA,MACtB;AAAA,IACF;AAAA,IACA,WAAW;AAAA,MACT,SAAS;AAAA,IACX;AAAA,IACA,mBAAmB;AAAA,MACjB,GAAG;AAAA,IACL;AAAA,EACF;AACF,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.js","sources":["../../../src/providers/ThemeProvider.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { EmotionCache } from \"@emotion/cache\";\nimport {\n createTheme,\n ThemeProvider as MuiThemeProvider,\n} from \"@mui/material/styles\";\nimport {\n defaultCacheKey,\n defaultEmotionCache,\n EmotionContext,\n HvThemeContext,\n type HvThemeContextValue,\n} from \"@hitachivantara/uikit-react-shared\";\nimport { HvThemeStructure, parseTheme } from \"@hitachivantara/uikit-styles\";\n\nimport { HvTheme } from \"../types/theme\";\nimport { setElementAttrs } from \"../utils/theme\";\n\nexport { HvThemeContext };\nexport type { HvThemeContextValue };\n\nexport { defaultCacheKey, defaultEmotionCache, EmotionContext };\n\ninterface HvThemeProviderProps {\n children: React.ReactNode;\n themes: (HvTheme | HvThemeStructure)[];\n theme: string;\n emotionCache: EmotionCache;\n colorMode: string;\n themeRootId?: string;\n}\n\nexport const HvThemeProvider = ({\n children,\n themes: themesList,\n theme,\n emotionCache,\n colorMode,\n themeRootId: rootId,\n}: HvThemeProviderProps) => {\n const initTheme = parseTheme(themesList, theme, colorMode);\n\n const [parsedTheme, setParsedTheme] = useState(initTheme);\n const [activeTheme, setActiveTheme] = useState(parsedTheme.theme);\n const [selectedTheme, setSelectedTheme] = useState(parsedTheme.selectedTheme);\n const [selectedMode, setThemeMode] = useState(parsedTheme.selectedMode);\n const [colorModes, setColorModes] = useState(parsedTheme.colorModes);\n const [themes, setThemes] = useState(themesList.map((t) => t.name));\n\n useEffect(() => {\n const pTheme = parseTheme(themesList, theme, colorMode);\n setThemes(themesList.map((t) => t.name));\n setParsedTheme(pTheme);\n }, [themesList, theme, colorMode]);\n\n useEffect(() => {\n setActiveTheme(parsedTheme.theme);\n setSelectedTheme(parsedTheme.selectedTheme);\n setThemeMode(parsedTheme.selectedMode);\n setColorModes(parsedTheme.colorModes);\n\n setElementAttrs(\n parsedTheme.selectedTheme,\n parsedTheme.selectedMode,\n parsedTheme.colorScheme,\n rootId,\n );\n }, [parsedTheme, rootId]);\n\n const changeTheme = useCallback(\n (newTheme = selectedTheme, newMode = selectedMode) => {\n const pTheme = parseTheme(themesList, newTheme, newMode);\n setParsedTheme(pTheme);\n },\n [selectedMode, selectedTheme, themesList],\n );\n\n const value = useMemo<HvThemeContextValue>(\n () => ({\n themes,\n colorModes,\n activeTheme: activeTheme as HvTheme,\n selectedTheme,\n selectedMode,\n changeTheme,\n rootId,\n }),\n [\n themes,\n colorModes,\n activeTheme,\n selectedTheme,\n selectedMode,\n changeTheme,\n rootId,\n ],\n );\n\n const MuiTheme = createTheme({\n breakpoints: {\n values: {\n ...activeTheme.breakpoints.values,\n },\n },\n });\n\n const emotionCacheValue = useMemo(\n () => ({ cache: emotionCache }),\n [emotionCache],\n );\n\n return (\n <MuiThemeProvider theme={MuiTheme}>\n <HvThemeContext.Provider value={value}>\n <EmotionContext.Provider value={emotionCacheValue}>\n {children}\n </EmotionContext.Provider>\n </HvThemeContext.Provider>\n </MuiThemeProvider>\n );\n};\n"],"names":["MuiThemeProvider"],"mappings":";;;;;;;AAgCO,MAAM,kBAAkB,CAAC;AAAA,EAC9B;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AACf,MAA4B;AAC1B,QAAM,YAAY,WAAW,YAAY,OAAO,SAAS;AAEzD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,SAAS;AACxD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,YAAY,KAAK;AAChE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AM,oBAAoB;AAAA,IACxB,OAAO,EAAE,OAAO;IAChB,CAAC,YAAY;AAAA,EAAA;AAGf,6BACGA,eAAiB,EAAA,OAAO,UACvB,UAAA,oBAAC,eAAe,UAAf,EAAwB,OACvB,UAAA,oBAAC,eAAe,UAAf,EAAwB,OAAO,mBAC7B,SACH,CAAA,GACF,EACF,CAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"ThemeProvider.js","sources":["../../../src/providers/ThemeProvider.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { EmotionCache } from \"@emotion/cache\";\nimport {\n createTheme,\n ThemeProvider as MuiThemeProvider,\n} from \"@mui/material/styles\";\nimport {\n defaultCacheKey,\n defaultEmotionCache,\n EmotionContext,\n HvThemeContext,\n type HvThemeContextValue,\n} from \"@hitachivantara/uikit-react-shared\";\nimport { HvThemeStructure, parseTheme } from \"@hitachivantara/uikit-styles\";\n\nimport { HvTheme } from \"../types/theme\";\nimport { setElementAttrs } from \"../utils/theme\";\n\nexport { HvThemeContext };\nexport type { HvThemeContextValue };\n\nexport { defaultCacheKey, defaultEmotionCache, EmotionContext };\n\ninterface HvThemeProviderProps {\n children: React.ReactNode;\n themes: (HvTheme | HvThemeStructure)[];\n theme: string;\n emotionCache: EmotionCache;\n colorMode: string;\n themeRootId?: string;\n}\n\nexport const HvThemeProvider = ({\n children,\n themes: themesList,\n theme,\n emotionCache,\n colorMode,\n themeRootId: rootId,\n}: HvThemeProviderProps) => {\n const initTheme = parseTheme(themesList, theme, colorMode);\n\n const [parsedTheme, setParsedTheme] = useState(initTheme);\n const [activeTheme, setActiveTheme] = useState(parsedTheme.theme);\n const [selectedTheme, setSelectedTheme] = useState(parsedTheme.selectedTheme);\n const [selectedMode, setThemeMode] = useState(parsedTheme.selectedMode);\n const [colorModes, setColorModes] = useState(parsedTheme.colorModes);\n const [themes, setThemes] = useState(themesList.map((t) => t.name));\n\n useEffect(() => {\n const pTheme = parseTheme(themesList, theme, colorMode);\n setThemes(themesList.map((t) => t.name));\n setParsedTheme(pTheme);\n }, [themesList, theme, colorMode]);\n\n useEffect(() => {\n setActiveTheme(parsedTheme.theme);\n setSelectedTheme(parsedTheme.selectedTheme);\n setThemeMode(parsedTheme.selectedMode);\n setColorModes(parsedTheme.colorModes);\n\n setElementAttrs(\n parsedTheme.selectedTheme,\n parsedTheme.selectedMode,\n parsedTheme.colorScheme,\n rootId,\n );\n }, [parsedTheme, rootId]);\n\n const changeTheme = useCallback(\n (newTheme = selectedTheme, newMode = selectedMode) => {\n const pTheme = parseTheme(themesList, newTheme, newMode);\n setParsedTheme(pTheme);\n },\n [selectedMode, selectedTheme, themesList],\n );\n\n const value = useMemo<HvThemeContextValue>(\n () => ({\n themes,\n colorModes,\n activeTheme: activeTheme as HvTheme,\n selectedTheme,\n selectedMode,\n changeTheme,\n rootId,\n }),\n [\n themes,\n colorModes,\n activeTheme,\n selectedTheme,\n selectedMode,\n changeTheme,\n rootId,\n ],\n );\n\n const MuiTheme = createTheme({\n components: {\n MuiButtonBase: {\n defaultProps: {\n disableRipple: true,\n },\n },\n },\n breakpoints: {\n values: {\n ...activeTheme.breakpoints.values,\n },\n },\n });\n\n const emotionCacheValue = useMemo(\n () => ({ cache: emotionCache }),\n [emotionCache],\n );\n\n return (\n <MuiThemeProvider theme={MuiTheme}>\n <HvThemeContext.Provider value={value}>\n <EmotionContext.Provider value={emotionCacheValue}>\n {children}\n </EmotionContext.Provider>\n </HvThemeContext.Provider>\n </MuiThemeProvider>\n );\n};\n"],"names":["MuiThemeProvider"],"mappings":";;;;;;;AAgCO,MAAM,kBAAkB,CAAC;AAAA,EAC9B;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AACf,MAA4B;AAC1B,QAAM,YAAY,WAAW,YAAY,OAAO,SAAS;AAEzD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,SAAS;AACxD,QAAM,CAAC,aAAa,cAAc,IAAI,SAA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