@stratakit/mui 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -0
- package/dist/DEV/Root.js +43 -21
- package/dist/DEV/styles.css.js +1 -1
- package/dist/DEV/~components/MuiAccordion.js +36 -0
- package/dist/DEV/~components/MuiAlert.js +37 -0
- package/dist/DEV/~components/MuiAutocomplete.js +134 -11
- package/dist/DEV/~components/MuiBadge.js +22 -4
- package/dist/DEV/~components/MuiCard.js +52 -8
- package/dist/DEV/~components/MuiDivider.js +2 -1
- package/dist/DEV/~components/MuiMenu.js +22 -0
- package/dist/DEV/~components/MuiPopover.js +40 -0
- package/dist/DEV/~components/MuiTabs.js +43 -0
- package/dist/DEV/~components/MuiTypography.js +16 -13
- package/dist/DEV/~createTheme.js +146 -53
- package/dist/Root.internal.d.ts +1 -1
- package/dist/Root.js +13 -4
- package/dist/styles.css.js +1 -1
- package/dist/types.d.ts +137 -5
- package/dist/~components/MuiAccordion.d.ts +11 -0
- package/dist/~components/MuiAccordion.js +30 -0
- package/dist/~components/MuiAlert.d.ts +4 -0
- package/dist/~components/MuiAlert.js +38 -0
- package/dist/~components/MuiAutocomplete.d.ts +4 -1
- package/dist/~components/MuiAutocomplete.js +132 -12
- package/dist/~components/MuiBadge.d.ts +5 -3
- package/dist/~components/MuiBadge.js +22 -4
- package/dist/~components/MuiCard.d.ts +2 -1
- package/dist/~components/MuiCard.js +66 -11
- package/dist/~components/MuiChip.d.ts +1 -1
- package/dist/~components/MuiDivider.js +1 -1
- package/dist/~components/MuiMenu.d.ts +7 -0
- package/dist/~components/MuiMenu.js +25 -0
- package/dist/~components/MuiPopover.d.ts +10 -0
- package/dist/~components/MuiPopover.js +62 -0
- package/dist/~components/MuiTabs.d.ts +8 -0
- package/dist/~components/MuiTabs.js +33 -0
- package/dist/~components/MuiTypography.d.ts +17 -1
- package/dist/~components/MuiTypography.js +13 -12
- package/dist/~createTheme.d.ts +4 -1
- package/dist/~createTheme.js +153 -70
- package/package.json +9 -9
|
@@ -1,23 +1,146 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import * as ReactDOM from "react-dom";
|
|
3
4
|
import { Role } from "@ariakit/react/role";
|
|
4
|
-
import {
|
|
5
|
+
import { ThemeProvider } from "@mui/material/styles";
|
|
6
|
+
import {
|
|
7
|
+
forwardRef,
|
|
8
|
+
useEventHandlers,
|
|
9
|
+
useMergedRefs
|
|
10
|
+
} from "@stratakit/foundations/secret-internals";
|
|
11
|
+
import { MuiChip, MuiChipDeleteIcon } from "./MuiChip.js";
|
|
5
12
|
import { MuiInputLabelContext } from "./MuiInputLabel.js";
|
|
6
|
-
const
|
|
13
|
+
const MuiAutocompleteContext = React.createContext(void 0);
|
|
14
|
+
const MuiAutocomplete = forwardRef((props, forwardedRef) => {
|
|
15
|
+
const [labelId, setLabelId] = React.useState(void 0);
|
|
16
|
+
const [inputRootRef, setInputRootRef] = React.useState(
|
|
17
|
+
null
|
|
18
|
+
);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
ThemeProvider,
|
|
21
|
+
{
|
|
22
|
+
theme: (outerTheme) => ({
|
|
23
|
+
...outerTheme,
|
|
24
|
+
components: {
|
|
25
|
+
...outerTheme.components,
|
|
26
|
+
MuiTextField: {
|
|
27
|
+
defaultProps: {
|
|
28
|
+
slotProps: {
|
|
29
|
+
input: {
|
|
30
|
+
component: MuiAutocompleteTextFieldInput
|
|
31
|
+
},
|
|
32
|
+
htmlInput: {
|
|
33
|
+
slot: "input"
|
|
34
|
+
// Assign input element to the slot named "input"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
children: /* @__PURE__ */ jsx(
|
|
42
|
+
MuiAutocompleteContext.Provider,
|
|
43
|
+
{
|
|
44
|
+
value: { inputRootRef, setInputRootRef },
|
|
45
|
+
children: /* @__PURE__ */ jsx(MuiInputLabelContext.Provider, { value: { setLabelId }, children: /* @__PURE__ */ jsx(
|
|
46
|
+
Role.div,
|
|
47
|
+
{
|
|
48
|
+
role: "group",
|
|
49
|
+
"aria-labelledby": labelId,
|
|
50
|
+
...props,
|
|
51
|
+
onKeyDown: useEventHandlers((e) => {
|
|
52
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
53
|
+
e.defaultMuiPrevented = true;
|
|
54
|
+
}
|
|
55
|
+
}, props.onKeyDown),
|
|
56
|
+
ref: forwardedRef
|
|
57
|
+
}
|
|
58
|
+
) })
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
DEV: MuiAutocomplete.displayName = "MuiAutocomplete";
|
|
65
|
+
const MuiAutocompleteClearIndicator = forwardRef(
|
|
7
66
|
(props, forwardedRef) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Role.div,
|
|
67
|
+
return /* @__PURE__ */ jsx(
|
|
68
|
+
Role.button,
|
|
11
69
|
{
|
|
12
|
-
role: "group",
|
|
13
|
-
"aria-labelledby": labelId,
|
|
14
70
|
...props,
|
|
71
|
+
onKeyDown: useEventHandlers(props.onKeyDown, (e) => {
|
|
72
|
+
e.stopPropagation();
|
|
73
|
+
}),
|
|
15
74
|
ref: forwardedRef
|
|
16
75
|
}
|
|
17
|
-
)
|
|
76
|
+
);
|
|
18
77
|
}
|
|
19
78
|
);
|
|
20
|
-
DEV:
|
|
79
|
+
DEV: MuiAutocompleteClearIndicator.displayName = "MuiAutocompleteClearIndicator";
|
|
80
|
+
const MuiAutocompleteChip = forwardRef(
|
|
81
|
+
(props, forwardedRef) => {
|
|
82
|
+
return /* @__PURE__ */ jsx(MuiChip, { slot: "chips", ...props, role: "listitem", ref: forwardedRef });
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
DEV: MuiAutocompleteChip.displayName = "MuiAutocompleteChip";
|
|
86
|
+
const MuiAutocompleteChipDeleteIcon = forwardRef((props, forwardedRef) => {
|
|
87
|
+
const { inputRootRef } = React.useContext(MuiAutocompleteContext) ?? {};
|
|
88
|
+
return /* @__PURE__ */ jsx(
|
|
89
|
+
MuiChipDeleteIcon,
|
|
90
|
+
{
|
|
91
|
+
...props,
|
|
92
|
+
onKeyDown: useEventHandlers(props.onKeyDown, (e) => {
|
|
93
|
+
e.stopPropagation();
|
|
94
|
+
}),
|
|
95
|
+
onClick: useEventHandlers(props.onClick, () => {
|
|
96
|
+
if (!inputRootRef) return;
|
|
97
|
+
const htmlInput = inputRootRef.getElementsByClassName(
|
|
98
|
+
"MuiAutocomplete-input"
|
|
99
|
+
)[0];
|
|
100
|
+
if (!htmlInput) return;
|
|
101
|
+
htmlInput.focus();
|
|
102
|
+
}),
|
|
103
|
+
ref: forwardedRef
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
DEV: MuiAutocompleteChipDeleteIcon.displayName = "MuiAutocompleteChipDeleteIcon";
|
|
108
|
+
const MuiAutocompleteTextFieldInput = forwardRef(
|
|
109
|
+
(props, forwardedRef) => {
|
|
110
|
+
const { setInputRootRef } = React.useContext(MuiAutocompleteContext) ?? {};
|
|
111
|
+
const [host, setHost] = React.useState(null);
|
|
112
|
+
const [shadow, setShadow] = React.useState(null);
|
|
113
|
+
React.useEffect(() => {
|
|
114
|
+
if (!host) return;
|
|
115
|
+
if (!host.shadowRoot) {
|
|
116
|
+
host.attachShadow({ mode: "open" });
|
|
117
|
+
}
|
|
118
|
+
setShadow(host.shadowRoot);
|
|
119
|
+
}, [host]);
|
|
120
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
121
|
+
/* @__PURE__ */ jsx(
|
|
122
|
+
Role,
|
|
123
|
+
{
|
|
124
|
+
...props,
|
|
125
|
+
ref: useMergedRefs(setHost, setInputRootRef, forwardedRef)
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
shadow && ReactDOM.createPortal(
|
|
129
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
130
|
+
/* @__PURE__ */ jsx("slot", { name: "input" }),
|
|
131
|
+
/* @__PURE__ */ jsx("slot", { role: "list", name: "chips" }),
|
|
132
|
+
/* @__PURE__ */ jsx("slot", {}),
|
|
133
|
+
" "
|
|
134
|
+
] }),
|
|
135
|
+
shadow
|
|
136
|
+
)
|
|
137
|
+
] });
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
DEV: MuiAutocompleteTextFieldInput.displayName = "MuiAutocompleteTextFieldInput";
|
|
21
141
|
export {
|
|
22
|
-
MuiAutocomplete
|
|
142
|
+
MuiAutocomplete,
|
|
143
|
+
MuiAutocompleteChip,
|
|
144
|
+
MuiAutocompleteChipDeleteIcon,
|
|
145
|
+
MuiAutocompleteClearIndicator
|
|
23
146
|
};
|
|
@@ -1,20 +1,38 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
2
3
|
import { Role } from "@ariakit/react/role";
|
|
3
4
|
import {
|
|
4
|
-
forwardRef
|
|
5
|
+
forwardRef,
|
|
6
|
+
useSafeContext
|
|
5
7
|
} from "@stratakit/foundations/secret-internals";
|
|
8
|
+
const MuiBadgeContext = React.createContext(
|
|
9
|
+
void 0
|
|
10
|
+
);
|
|
6
11
|
const MuiBadge = forwardRef((props, forwardedRef) => {
|
|
7
12
|
const { inline, ...rest } = props;
|
|
8
|
-
return /* @__PURE__ */ jsx(
|
|
13
|
+
return /* @__PURE__ */ jsx(MuiBadgeContext.Provider, { value: { inline }, children: /* @__PURE__ */ jsx(
|
|
9
14
|
Role.span,
|
|
10
15
|
{
|
|
11
16
|
...rest,
|
|
12
17
|
"data-_sk-inline": inline ? "" : void 0,
|
|
13
18
|
ref: forwardedRef
|
|
14
19
|
}
|
|
15
|
-
);
|
|
20
|
+
) });
|
|
16
21
|
});
|
|
17
22
|
DEV: MuiBadge.displayName = "MuiBadge";
|
|
23
|
+
const MuiBadgeBadge = forwardRef((props, forwardedRef) => {
|
|
24
|
+
const { inline } = useSafeContext(MuiBadgeContext);
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
Role.span,
|
|
27
|
+
{
|
|
28
|
+
...props,
|
|
29
|
+
"aria-hidden": inline ? void 0 : props["aria-hidden"],
|
|
30
|
+
ref: forwardedRef
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
DEV: MuiBadgeBadge.displayName = "MuiBadgeBadge";
|
|
18
35
|
export {
|
|
19
|
-
MuiBadge
|
|
36
|
+
MuiBadge,
|
|
37
|
+
MuiBadgeBadge
|
|
20
38
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import * as ReactDOM from "react-dom";
|
|
3
4
|
import { Role } from "@ariakit/react/role";
|
|
4
5
|
import {
|
|
5
6
|
forwardRef,
|
|
@@ -10,7 +11,6 @@ import { MuiButtonBase } from "./MuiButtonBase.js";
|
|
|
10
11
|
const MuiCardContext = React.createContext(void 0);
|
|
11
12
|
const MuiCard = forwardRef(
|
|
12
13
|
(props, forwardedRef) => {
|
|
13
|
-
const { role, ...rest } = props;
|
|
14
14
|
const [actionAreaElement, setActionAreaElement] = React.useState(void 0);
|
|
15
15
|
const handleActionAreaClick = (event) => {
|
|
16
16
|
if (!actionAreaElement) return;
|
|
@@ -28,7 +28,7 @@ const MuiCard = forwardRef(
|
|
|
28
28
|
Role,
|
|
29
29
|
{
|
|
30
30
|
render: /* @__PURE__ */ jsx("article", {}),
|
|
31
|
-
...
|
|
31
|
+
...props,
|
|
32
32
|
"data-_sk-actionable": actionAreaElement ? "" : void 0,
|
|
33
33
|
onClick: useEventHandlers(props.onClick, handleActionAreaClick),
|
|
34
34
|
ref: forwardedRef
|
|
@@ -39,20 +39,63 @@ const MuiCard = forwardRef(
|
|
|
39
39
|
}
|
|
40
40
|
);
|
|
41
41
|
DEV: MuiCard.displayName = "MuiCard";
|
|
42
|
-
const
|
|
42
|
+
const MuiCardHeaderTitle = forwardRef(
|
|
43
43
|
(props, forwardedRef) => {
|
|
44
|
-
const
|
|
45
|
-
const
|
|
44
|
+
const cardContext = React.useContext(MuiCardContext);
|
|
45
|
+
const cardActionAreaContext = React.useContext(MuiCardActionAreaContext);
|
|
46
|
+
const { children, ...rest } = props;
|
|
46
47
|
return /* @__PURE__ */ jsx(
|
|
47
|
-
|
|
48
|
+
Role.h2,
|
|
48
49
|
{
|
|
49
50
|
...rest,
|
|
50
|
-
ref: useMergedRefs(
|
|
51
|
+
ref: useMergedRefs(
|
|
52
|
+
cardActionAreaContext?.setTitleElement,
|
|
53
|
+
forwardedRef
|
|
54
|
+
),
|
|
55
|
+
children: (() => {
|
|
56
|
+
if (cardActionAreaContext) {
|
|
57
|
+
return cardContext?.actionAreaElement ? ReactDOM.createPortal(children, cardContext.actionAreaElement) : null;
|
|
58
|
+
}
|
|
59
|
+
return children;
|
|
60
|
+
})()
|
|
51
61
|
}
|
|
52
62
|
);
|
|
53
63
|
}
|
|
54
64
|
);
|
|
65
|
+
DEV: MuiCardHeaderTitle.displayName = "MuiCardHeaderTitle";
|
|
66
|
+
const MuiCardActionAreaContext = React.createContext(void 0);
|
|
67
|
+
const MuiCardActionArea = forwardRef(
|
|
68
|
+
(props, forwardedRef) => {
|
|
69
|
+
const { children, ...rest } = props;
|
|
70
|
+
const [titleElement, setTitleElement] = React.useState(void 0);
|
|
71
|
+
return /* @__PURE__ */ jsx(MuiCardActionAreaContext.Provider, { value: { setTitleElement }, children: (() => {
|
|
72
|
+
if (titleElement) {
|
|
73
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
74
|
+
children,
|
|
75
|
+
ReactDOM.createPortal(
|
|
76
|
+
/* @__PURE__ */ jsx(MuiCardActionAreaButton, { ...rest, ref: forwardedRef }),
|
|
77
|
+
titleElement
|
|
78
|
+
)
|
|
79
|
+
] });
|
|
80
|
+
}
|
|
81
|
+
return /* @__PURE__ */ jsx(MuiCardActionAreaButton, { ...rest, ref: forwardedRef, children });
|
|
82
|
+
})() });
|
|
83
|
+
}
|
|
84
|
+
);
|
|
55
85
|
DEV: MuiCardActionArea.displayName = "MuiCardActionArea";
|
|
86
|
+
const MuiCardActionAreaButton = forwardRef(
|
|
87
|
+
(props, forwardedRef) => {
|
|
88
|
+
const cardContext = React.useContext(MuiCardContext);
|
|
89
|
+
return /* @__PURE__ */ jsx(
|
|
90
|
+
MuiButtonBase,
|
|
91
|
+
{
|
|
92
|
+
...props,
|
|
93
|
+
ref: useMergedRefs(cardContext?.setActionAreaElement, forwardedRef)
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
DEV: MuiCardActionAreaButton.displayName = "MuiCardActionAreaButton";
|
|
56
99
|
const MEDIA_COMPONENTS = ["audio", "iframe", "img", "picture", "video"];
|
|
57
100
|
function extractBackgroundImageUrl(style) {
|
|
58
101
|
const backgroundImage = style?.backgroundImage;
|
|
@@ -98,5 +141,6 @@ DEV: MuiCardMedia.displayName = "MuiCardMedia";
|
|
|
98
141
|
export {
|
|
99
142
|
MuiCard,
|
|
100
143
|
MuiCardActionArea,
|
|
144
|
+
MuiCardHeaderTitle,
|
|
101
145
|
MuiCardMedia
|
|
102
146
|
};
|
|
@@ -4,7 +4,8 @@ import { forwardRef } from "@stratakit/foundations/secret-internals";
|
|
|
4
4
|
const MuiDivider = forwardRef((props, forwardedRef) => {
|
|
5
5
|
const { children, ...rest } = props;
|
|
6
6
|
const defaultRender = (() => {
|
|
7
|
-
if (children || props["aria-orientation"] === "vertical"
|
|
7
|
+
if (children || props["aria-orientation"] === "vertical" || props.role === "presentation")
|
|
8
|
+
return /* @__PURE__ */ jsx("div", {});
|
|
8
9
|
return /* @__PURE__ */ jsx("hr", {});
|
|
9
10
|
})();
|
|
10
11
|
return /* @__PURE__ */ jsx(Role, { render: defaultRender, ...rest, ref: forwardedRef, children });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import MenuList from "@mui/material/MenuList";
|
|
3
|
+
import {
|
|
4
|
+
forwardRef,
|
|
5
|
+
useMergedRefs
|
|
6
|
+
} from "@stratakit/foundations/secret-internals";
|
|
7
|
+
import { useFallbackLabel } from "./MuiPopover.js";
|
|
8
|
+
const MuiMenuListSlot = forwardRef(
|
|
9
|
+
(props, forwardedRef) => {
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
MenuList,
|
|
12
|
+
{
|
|
13
|
+
...props,
|
|
14
|
+
ref: useMergedRefs(forwardedRef, useFallbackLabel(props))
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
DEV: MuiMenuListSlot.displayName = "MuiMenuListSlot";
|
|
20
|
+
export {
|
|
21
|
+
MuiMenuListSlot
|
|
22
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { PopoverPaper } from "@mui/material/Popover";
|
|
4
|
+
import {
|
|
5
|
+
forwardRef,
|
|
6
|
+
useMergedRefs
|
|
7
|
+
} from "@stratakit/foundations/secret-internals";
|
|
8
|
+
function useFallbackLabel(props) {
|
|
9
|
+
const {
|
|
10
|
+
"aria-label": ariaLabel,
|
|
11
|
+
"aria-labelledby": ariaLabelledBy,
|
|
12
|
+
ownerState = {}
|
|
13
|
+
} = props;
|
|
14
|
+
return React.useCallback(
|
|
15
|
+
(element) => {
|
|
16
|
+
if (!element || !(ownerState.anchorEl instanceof HTMLElement)) return;
|
|
17
|
+
if (ariaLabel || ariaLabelledBy || element.ariaLabel || element.ariaLabelledByElements?.length) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
element.ariaLabelledByElements = [ownerState.anchorEl];
|
|
21
|
+
},
|
|
22
|
+
[ownerState.anchorEl, ariaLabel, ariaLabelledBy]
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
const MuiPopoverPaperSlot = forwardRef(
|
|
26
|
+
(props, forwardedRef) => {
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
PopoverPaper,
|
|
29
|
+
{
|
|
30
|
+
...props,
|
|
31
|
+
ref: useMergedRefs(forwardedRef, useFallbackLabel(props))
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
DEV: MuiPopoverPaperSlot.displayName = "MuiPopoverPaperSlot";
|
|
37
|
+
export {
|
|
38
|
+
MuiPopoverPaperSlot,
|
|
39
|
+
useFallbackLabel
|
|
40
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Role } from "@ariakit/react/role";
|
|
3
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
4
|
+
import {
|
|
5
|
+
forwardRef,
|
|
6
|
+
useEventHandlers
|
|
7
|
+
} from "@stratakit/foundations/secret-internals";
|
|
8
|
+
const MuiTabs = forwardRef((props, forwardedRef) => {
|
|
9
|
+
const { size = "medium", ...rest } = props;
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
Role.div,
|
|
12
|
+
{
|
|
13
|
+
...rest,
|
|
14
|
+
"data-_sk-size": size !== "medium" ? size : void 0,
|
|
15
|
+
ref: forwardedRef
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
DEV: MuiTabs.displayName = "MuiTabs";
|
|
20
|
+
const MuiTab = forwardRef(
|
|
21
|
+
(props, forwardedRef) => {
|
|
22
|
+
const motionOk = useMediaQuery("(prefers-reduced-motion: no-preference)");
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
Role.button,
|
|
25
|
+
{
|
|
26
|
+
...props,
|
|
27
|
+
onFocus: useEventHandlers(props.onFocus, (event) => {
|
|
28
|
+
event?.currentTarget?.scrollIntoView({
|
|
29
|
+
block: "nearest",
|
|
30
|
+
inline: "nearest",
|
|
31
|
+
behavior: motionOk ? "smooth" : "auto"
|
|
32
|
+
});
|
|
33
|
+
}),
|
|
34
|
+
ref: forwardedRef
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
DEV: MuiTab.displayName = "MuiTab";
|
|
40
|
+
export {
|
|
41
|
+
MuiTab,
|
|
42
|
+
MuiTabs
|
|
43
|
+
};
|
|
@@ -4,12 +4,12 @@ import { forwardRef } from "@stratakit/foundations/secret-internals";
|
|
|
4
4
|
const variantMapping = {
|
|
5
5
|
h1: "h1",
|
|
6
6
|
h2: "h2",
|
|
7
|
-
h3: "
|
|
8
|
-
h4: "
|
|
9
|
-
h5: "
|
|
10
|
-
h6: "
|
|
11
|
-
subtitle1: "
|
|
12
|
-
subtitle2: "
|
|
7
|
+
h3: "h2",
|
|
8
|
+
h4: "h2",
|
|
9
|
+
h5: "h2",
|
|
10
|
+
h6: "h2",
|
|
11
|
+
subtitle1: "h2",
|
|
12
|
+
subtitle2: "h2",
|
|
13
13
|
body1: "p",
|
|
14
14
|
body2: "p",
|
|
15
15
|
inherit: "p",
|
|
@@ -17,28 +17,31 @@ const variantMapping = {
|
|
|
17
17
|
caption: "span",
|
|
18
18
|
overline: "span"
|
|
19
19
|
};
|
|
20
|
-
const
|
|
20
|
+
const muiVariants = Object.keys(
|
|
21
|
+
variantMapping
|
|
22
|
+
);
|
|
21
23
|
const headings = ["h1", "h2", "h3", "h4", "h5", "h6", "subtitle1", "subtitle2"];
|
|
22
24
|
const MuiTypography = forwardRef((props, forwardedRef) => {
|
|
23
25
|
const classList = props.className?.split(" ").filter(Boolean);
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
+
const muiVariant = (() => {
|
|
27
|
+
const variant = muiVariants.find(
|
|
26
28
|
(name) => classList?.includes(`MuiTypography-${name}`)
|
|
27
29
|
);
|
|
28
|
-
return
|
|
30
|
+
return variant || "body2";
|
|
29
31
|
})();
|
|
30
|
-
DEV: if (!props.render && headings.includes(
|
|
32
|
+
DEV: if (!props.render && headings.includes(muiVariant)) {
|
|
31
33
|
console.warn(
|
|
32
34
|
"MuiTypography: Please explicitly set the `render` prop to ensure correct heading structure."
|
|
33
35
|
);
|
|
34
36
|
}
|
|
35
37
|
const render = (() => {
|
|
36
|
-
const Element = variantMapping[
|
|
38
|
+
const Element = muiVariant in variantMapping ? variantMapping[muiVariant] : "p";
|
|
37
39
|
return /* @__PURE__ */ jsx(Element, {});
|
|
38
40
|
})();
|
|
39
41
|
return /* @__PURE__ */ jsx(Role, { render, ...props, ref: forwardedRef });
|
|
40
42
|
});
|
|
41
43
|
DEV: MuiTypography.displayName = "MuiTypography";
|
|
42
44
|
export {
|
|
43
|
-
MuiTypography
|
|
45
|
+
MuiTypography,
|
|
46
|
+
variantMapping
|
|
44
47
|
};
|