@stratakit/mui 0.2.1 → 0.3.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 +101 -24
- package/README.md +8 -4
- package/dist/DEV/Root.internal.js +57 -0
- package/dist/DEV/Root.js +7 -9
- package/dist/DEV/createTheme.js +220 -16
- package/dist/DEV/styles.css.js +2 -2
- package/dist/DEV/~components/MuiBadge.js +20 -0
- package/dist/DEV/~components/MuiButtonBase.js +53 -0
- package/dist/DEV/~components/MuiCard.js +59 -0
- package/dist/DEV/~components/MuiChip.js +83 -0
- package/dist/DEV/~components/MuiIconButton.js +17 -0
- package/dist/DEV/~components/MuiSnackbar.js +12 -0
- package/dist/DEV/~components/MuiTable.js +23 -0
- package/dist/Root.d.ts +3 -1
- package/dist/Root.internal.d.ts +3 -0
- package/dist/Root.internal.js +77 -0
- package/dist/Root.js +6 -4
- package/dist/createTheme.js +470 -10
- package/dist/styles.css.js +2 -2
- package/dist/types.d.ts +158 -1
- package/dist/~components/MuiBadge.d.ts +7 -0
- package/dist/~components/MuiBadge.js +17 -0
- package/dist/~components/MuiButtonBase.d.ts +7 -0
- package/dist/~components/MuiButtonBase.js +80 -0
- package/dist/~components/MuiCard.d.ts +4 -0
- package/dist/~components/MuiCard.js +49 -0
- package/dist/~components/MuiChip.d.ts +9 -0
- package/dist/~components/MuiChip.js +82 -0
- package/dist/~components/MuiIconButton.d.ts +6 -0
- package/dist/~components/MuiIconButton.js +27 -0
- package/dist/~components/MuiSnackbar.d.ts +2 -0
- package/dist/~components/MuiSnackbar.js +12 -0
- package/dist/~components/MuiTable.d.ts +4 -0
- package/dist/~components/MuiTable.js +28 -0
- package/package.json +13 -9
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Role } from "@ariakit/react/role";
|
|
4
|
+
import { VisuallyHidden } from "@ariakit/react/visually-hidden";
|
|
5
|
+
import IconButton from "@mui/material/IconButton";
|
|
6
|
+
import { useTheme } from "@mui/material/styles";
|
|
7
|
+
import { DismissIcon } from "../Icon.js";
|
|
8
|
+
import { MuiButtonBase } from "./MuiButtonBase.js";
|
|
9
|
+
const MuiChipContext = React.createContext(void 0);
|
|
10
|
+
const MuiChip = React.forwardRef(
|
|
11
|
+
(props, forwardedRef) => {
|
|
12
|
+
const { role, deleteLabel, ...rest } = props;
|
|
13
|
+
const clearId = React.useId();
|
|
14
|
+
const [labelId, setLabelId] = React.useState(void 0);
|
|
15
|
+
const isClickable = props.className?.includes("MuiChip-clickable") ?? false;
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
MuiChipContext.Provider,
|
|
18
|
+
{
|
|
19
|
+
value: { labelId, setLabelId, clearId, isClickable, deleteLabel },
|
|
20
|
+
children: /* @__PURE__ */ jsx(
|
|
21
|
+
Role.div,
|
|
22
|
+
{
|
|
23
|
+
...rest,
|
|
24
|
+
role: role === "button" ? void 0 : role,
|
|
25
|
+
tabIndex: void 0,
|
|
26
|
+
ref: forwardedRef
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
DEV: MuiChip.displayName = "MuiChip";
|
|
34
|
+
const MuiChipLabel = React.forwardRef((props, forwardedRef) => {
|
|
35
|
+
const defaultId = React.useId();
|
|
36
|
+
const { id = defaultId, ...rest } = props;
|
|
37
|
+
const { setLabelId, isClickable } = React.useContext(MuiChipContext) ?? {};
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
if (!setLabelId) return;
|
|
40
|
+
setLabelId(id);
|
|
41
|
+
return () => {
|
|
42
|
+
setLabelId(void 0);
|
|
43
|
+
};
|
|
44
|
+
}, [id, setLabelId]);
|
|
45
|
+
const Component = isClickable ? MuiButtonBase : Role.span;
|
|
46
|
+
return /* @__PURE__ */ jsx(
|
|
47
|
+
Component,
|
|
48
|
+
{
|
|
49
|
+
id,
|
|
50
|
+
...rest,
|
|
51
|
+
ref: forwardedRef
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
DEV: MuiChipLabel.displayName = "MuiChipLabel";
|
|
56
|
+
const MuiChipDeleteIcon = React.forwardRef((props, forwardedRef) => {
|
|
57
|
+
const theme = useTheme();
|
|
58
|
+
const defaultLabel = theme.components?.MuiAutocomplete?.defaultProps?.clearText ?? "Clear";
|
|
59
|
+
const {
|
|
60
|
+
clearId,
|
|
61
|
+
labelId,
|
|
62
|
+
deleteLabel = defaultLabel
|
|
63
|
+
} = React.useContext(MuiChipContext) ?? {};
|
|
64
|
+
return /* @__PURE__ */ jsxs(
|
|
65
|
+
IconButton,
|
|
66
|
+
{
|
|
67
|
+
"aria-labelledby": `${clearId} ${labelId}`,
|
|
68
|
+
size: "small",
|
|
69
|
+
...props,
|
|
70
|
+
ref: forwardedRef,
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { id: clearId, children: deleteLabel }),
|
|
73
|
+
/* @__PURE__ */ jsx(DismissIcon, {})
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
DEV: MuiChipDeleteIcon.displayName = "MuiChipDeleteIcon";
|
|
79
|
+
export {
|
|
80
|
+
MuiChip,
|
|
81
|
+
MuiChipDeleteIcon,
|
|
82
|
+
MuiChipLabel
|
|
83
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
3
|
+
import { forwardRef } from "@stratakit/foundations/secret-internals";
|
|
4
|
+
import { MuiButtonBase } from "./MuiButtonBase.js";
|
|
5
|
+
const MuiIconButton = forwardRef(
|
|
6
|
+
(props, forwardedRef) => {
|
|
7
|
+
const { label, ...rest } = props;
|
|
8
|
+
if (label) {
|
|
9
|
+
return /* @__PURE__ */ jsx(Tooltip, { title: label, describeChild: false, children: /* @__PURE__ */ jsx(MuiButtonBase, { ...rest, ref: forwardedRef }) });
|
|
10
|
+
}
|
|
11
|
+
return /* @__PURE__ */ jsx(MuiButtonBase, { ...rest, ref: forwardedRef });
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
DEV: MuiIconButton.displayName = "MuiIconButton";
|
|
15
|
+
export {
|
|
16
|
+
MuiIconButton
|
|
17
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Portal } from "@ariakit/react/portal";
|
|
3
|
+
import { forwardRef } from "@stratakit/foundations/secret-internals";
|
|
4
|
+
const MuiSnackbar = forwardRef(
|
|
5
|
+
(props, forwardedRef) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(Portal, { ...props, ref: forwardedRef });
|
|
7
|
+
}
|
|
8
|
+
);
|
|
9
|
+
DEV: MuiSnackbar.displayName = "MuiSnackbar";
|
|
10
|
+
export {
|
|
11
|
+
MuiSnackbar
|
|
12
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Role } from "@ariakit/react/role";
|
|
4
|
+
import { forwardRef } from "@stratakit/foundations/secret-internals";
|
|
5
|
+
const MuiTableHeadContext = React.createContext(false);
|
|
6
|
+
const MuiTableHead = forwardRef(
|
|
7
|
+
(props, forwardedRef) => {
|
|
8
|
+
return /* @__PURE__ */ jsx(MuiTableHeadContext.Provider, { value: true, children: /* @__PURE__ */ jsx(Role, { render: /* @__PURE__ */ jsx("thead", {}), ...props, ref: forwardedRef }) });
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
DEV: MuiTableHead.displayName = "MuiTableHead";
|
|
12
|
+
const MuiTableCell = forwardRef(
|
|
13
|
+
(props, forwardedRef) => {
|
|
14
|
+
const inHeader = React.useContext(MuiTableHeadContext);
|
|
15
|
+
const Component = inHeader ? "th" : "td";
|
|
16
|
+
return /* @__PURE__ */ jsx(Role, { render: /* @__PURE__ */ jsx(Component, {}), ...props, ref: forwardedRef });
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
DEV: MuiTableCell.displayName = "MuiTableCell";
|
|
20
|
+
export {
|
|
21
|
+
MuiTableCell,
|
|
22
|
+
MuiTableHead
|
|
23
|
+
};
|
package/dist/Root.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
import { Root as StrataKitRoot } from "@stratakit/foundations";
|
|
3
|
+
import type { BaseProps } from "@stratakit/foundations/secret-internals";
|
|
4
|
+
interface RootProps extends BaseProps<"div">, Pick<React.ComponentProps<typeof StrataKitRoot>, "rootNode"> {
|
|
3
5
|
children?: React.ReactNode;
|
|
4
6
|
/**
|
|
5
7
|
* The color scheme to use for all components on the page.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { c as _c } from "react-compiler-runtime";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import createCache from "@emotion/cache";
|
|
5
|
+
import { CacheProvider } from "@emotion/react";
|
|
6
|
+
function StyledEngineProvider(t0) {
|
|
7
|
+
const $ = _c(3);
|
|
8
|
+
const {
|
|
9
|
+
children
|
|
10
|
+
} = t0;
|
|
11
|
+
const [cache] = React.useState(_temp);
|
|
12
|
+
let t1;
|
|
13
|
+
if ($[0] !== cache || $[1] !== children) {
|
|
14
|
+
t1 = jsx(CacheProvider, {
|
|
15
|
+
value: cache,
|
|
16
|
+
children
|
|
17
|
+
});
|
|
18
|
+
$[0] = cache;
|
|
19
|
+
$[1] = children;
|
|
20
|
+
$[2] = t1;
|
|
21
|
+
} else {
|
|
22
|
+
t1 = $[2];
|
|
23
|
+
}
|
|
24
|
+
return t1;
|
|
25
|
+
}
|
|
26
|
+
function _temp() {
|
|
27
|
+
return createEmotionCache();
|
|
28
|
+
}
|
|
29
|
+
function createEmotionCache() {
|
|
30
|
+
const cache = createCache({
|
|
31
|
+
key: "css",
|
|
32
|
+
speedy: true,
|
|
33
|
+
// This injects styles using the `insertRule` API.
|
|
34
|
+
stylisPlugins: [prefixer]
|
|
35
|
+
});
|
|
36
|
+
const prevInsert = cache.insert;
|
|
37
|
+
cache.insert = (...args) => {
|
|
38
|
+
if (!args[1].styles.match(/^@layer\s+[^{]*$/)) {
|
|
39
|
+
args[1].styles = `@layer mui {${args[1].styles}}`;
|
|
40
|
+
}
|
|
41
|
+
return prevInsert(...args);
|
|
42
|
+
};
|
|
43
|
+
return cache;
|
|
44
|
+
}
|
|
45
|
+
function prefixer(element) {
|
|
46
|
+
if (element.length > -1 && !element.return && element.type === "decl") {
|
|
47
|
+
element.return = prefix(element.value, element.length);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function prefix(value, length) {
|
|
51
|
+
switch (hash(value, length)) {
|
|
52
|
+
// color-adjust
|
|
53
|
+
case 5103:
|
|
54
|
+
return `-webkit-print-${value}${value}`;
|
|
55
|
+
// box-decoration-break
|
|
56
|
+
case 3005:
|
|
57
|
+
// mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,
|
|
58
|
+
case 6391:
|
|
59
|
+
case 5879:
|
|
60
|
+
case 5623:
|
|
61
|
+
case 6135:
|
|
62
|
+
case 4599:
|
|
63
|
+
case 4855:
|
|
64
|
+
// user-select, hyphens, text-size-adjust
|
|
65
|
+
case 4246:
|
|
66
|
+
case 6968:
|
|
67
|
+
case 2756:
|
|
68
|
+
return `-webkit-${value}${value}`;
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
function hash(value, length) {
|
|
73
|
+
return (value.charCodeAt(0) | 0) ^ 45 ? (((length << 2 ^ (value.charCodeAt(0) | 0)) << 2 ^ (value.charCodeAt(1) | 0)) << 2 ^ (value.charCodeAt(2) | 0)) << 2 ^ (value.charCodeAt(3) | 0) : 0;
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
StyledEngineProvider
|
|
77
|
+
};
|
package/dist/Root.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { c as _c } from "react-compiler-runtime";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { ThemeProvider, useColorScheme } from "@mui/material/styles";
|
|
5
5
|
import { Root as StrataKitRoot } from "@stratakit/foundations";
|
|
6
6
|
import { RootContext, useSafeContext } from "@stratakit/foundations/secret-internals";
|
|
7
7
|
import cx from "classnames";
|
|
8
8
|
import { createTheme } from "./createTheme.js";
|
|
9
|
+
import { StyledEngineProvider } from "./Root.internal.js";
|
|
9
10
|
import css from "./styles.css.js";
|
|
10
11
|
const theme = createTheme();
|
|
11
12
|
const packageName = "@stratakit/mui";
|
|
12
|
-
const key = `${packageName}@${"0.
|
|
13
|
+
const key = `${packageName}@${"0.3.0"}`;
|
|
13
14
|
const Root = React.forwardRef((props, forwardedRef) => {
|
|
14
15
|
const {
|
|
15
16
|
children,
|
|
@@ -17,7 +18,6 @@ const Root = React.forwardRef((props, forwardedRef) => {
|
|
|
17
18
|
...rest
|
|
18
19
|
} = props;
|
|
19
20
|
return /* @__PURE__ */ jsx(StyledEngineProvider, {
|
|
20
|
-
enableCssLayer: true,
|
|
21
21
|
children: /* @__PURE__ */ jsxs(ThemeProvider, {
|
|
22
22
|
theme,
|
|
23
23
|
defaultMode: colorScheme,
|
|
@@ -36,12 +36,14 @@ const RootInner = React.forwardRef((props, forwardedRef) => {
|
|
|
36
36
|
const {
|
|
37
37
|
children,
|
|
38
38
|
colorScheme,
|
|
39
|
+
rootNode,
|
|
39
40
|
...rest
|
|
40
41
|
} = props;
|
|
41
42
|
return /* @__PURE__ */ jsx(StrataKitRoot, {
|
|
42
43
|
...rest,
|
|
43
44
|
className: cx("\u{1F95D}MuiRoot", props.className),
|
|
44
45
|
colorScheme,
|
|
46
|
+
rootNode,
|
|
45
47
|
synchronizeColorScheme: true,
|
|
46
48
|
ref: forwardedRef,
|
|
47
49
|
children
|
|
@@ -77,7 +79,7 @@ function Styles() {
|
|
|
77
79
|
const $ = _c(4);
|
|
78
80
|
const rootContext = useSafeContext(RootContext);
|
|
79
81
|
if (!rootContext.versions?.has(packageName)) {
|
|
80
|
-
rootContext.versions?.set(packageName, "0.
|
|
82
|
+
rootContext.versions?.set(packageName, "0.3.0");
|
|
81
83
|
}
|
|
82
84
|
const {
|
|
83
85
|
rootNode,
|