@stratakit/mui 0.1.2 → 0.1.3

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
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.3
4
+
5
+ - [#1150](https://github.com/iTwin/design-system/pull/1150): Added a new `/types.d.ts` file for augmenting the types from MUI. This file should be included in all projects that rely on `@stratakit/mui`.
6
+ - [#1146](https://github.com/iTwin/design-system/pull/1146): Updated `Button` to use `variant="contained"` by default.
7
+
3
8
  ## 0.1.2
4
9
 
5
10
  - [#1137](https://github.com/iTwin/design-system/pull/1137): Updated `border-radius` of `IconButton` component.
package/README.md CHANGED
@@ -14,6 +14,7 @@ Additional setup/considerations:
14
14
 
15
15
  - `@stratakit/mui` has a direct dependency on [`@stratakit/foundations`](https://www.npmjs.com/package/@stratakit/foundations) and [`@stratakit/icons`](https://www.npmjs.com/package/@stratakit/icons), the latter of which requires [bundler configuration](https://github.com/iTwin/design-system/tree/main/packages/icons#bundler-configuration) to ensure that `.svg` files are not inlined.
16
16
  - You should ensure that [StrataKit fonts](#fonts) are loaded in your application.
17
+ - [`/types.d.ts`](#typescript) must be included in your project to ensure that the module augmentation for MUI components is picked up by TypeScript.
17
18
  - If you are trying to use this package alongside iTwinUI, you will also need to set up the [theme bridge](https://github.com/iTwin/iTwinUI/wiki/StrataKit-theme-bridge).
18
19
 
19
20
  ## Usage
@@ -78,6 +79,26 @@ Build tools such as [Vite](https://vite.dev/guide/assets.html#importing-asset-as
78
79
  > [!NOTE]
79
80
  > If the `<Root>` component cannot find `InterVariable` as a font in the document, it will automatically add a fallback which uses [Inter’s CDN](https://rsms.me/inter/#faq-cdn). In all cases, we recommend self-hosting to avoid any potential security and reliability issues that may arise from the use of a third-party CDN.
80
81
 
82
+ ## TypeScript
83
+
84
+ `@stratakit/mui` uses [module augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation) to modify the props of certain MUI components (for example, to change default prop values). To ensure that these changes are picked up by TypeScript, you must include the `@stratakit/mui/types.d.ts` file in your project.
85
+
86
+ The preferred way to include `types.d.ts` is to add it to the [`types` array](https://www.typescriptlang.org/tsconfig/#types) in your project's `tsconfig.json`:
87
+
88
+ ```json
89
+ {
90
+ "compilerOptions": {
91
+ "types": ["@stratakit/mui/types.d.ts"]
92
+ }
93
+ }
94
+ ```
95
+
96
+ Alternatively, if your project relies on the implicit inclusion of visible `@types` packages, then you can instead add a reference to `types.d.ts` using a [triple-slash directive](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html) in a global declaration file in your project (e.g. in `src/env.d.ts`):
97
+
98
+ ```ts
99
+ /// <reference types="@stratakit/mui/types.d.ts" />
100
+ ```
101
+
81
102
  ## Contributing
82
103
 
83
104
  Are you interested in helping StrataKit grow? You can submit feature requests or bugs by creating [issues](https://github.com/iTwin/design-system/issues).
package/dist/DEV/Root.js CHANGED
@@ -15,7 +15,7 @@ import { createTheme } from "./createTheme.js";
15
15
  import css from "./styles.css.js";
16
16
  const theme = createTheme();
17
17
  const packageName = "@stratakit/mui";
18
- const key = `${packageName}@${"0.1.2"}`;
18
+ const key = `${packageName}@${"0.1.3"}`;
19
19
  const Root = React.forwardRef(
20
20
  (props, forwardedRef) => {
21
21
  const { children, colorScheme, ...rest } = props;
@@ -57,7 +57,7 @@ DEV: ColorScheme.displayName = "ColorScheme";
57
57
  function Styles() {
58
58
  const rootContext = useSafeContext(RootContext);
59
59
  if (!rootContext.versions?.has(packageName))
60
- rootContext.versions?.set(packageName, "0.1.2");
60
+ rootContext.versions?.set(packageName, "0.1.3");
61
61
  const { rootNode, loadStyles } = rootContext;
62
62
  React.useInsertionEffect(() => {
63
63
  if (!rootNode || !loadStyles) return;
@@ -15,6 +15,19 @@ import {
15
15
  WarningIcon
16
16
  } from "./Icon.js";
17
17
  function createTheme() {
18
+ const palette = {
19
+ primary: { main: "var(--stratakit-mui-palette-primary-main)" },
20
+ secondary: { main: "var(--stratakit-mui-palette-secondary-main)" },
21
+ error: { main: "var(--stratakit-mui-palette-error-main)" },
22
+ warning: { main: "var(--stratakit-mui-palette-warning-main)" },
23
+ info: { main: "var(--stratakit-mui-palette-info-main)" },
24
+ success: { main: "var(--stratakit-mui-palette-success-main)" },
25
+ grey: Object.fromEntries(
26
+ ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"].map(
27
+ (shade) => [shade, `var(--stratakit-mui-palette-grey-${shade})`]
28
+ )
29
+ )
30
+ };
18
31
  return createMuiTheme({
19
32
  cssVariables: {
20
33
  nativeColor: true,
@@ -22,8 +35,8 @@ function createTheme() {
22
35
  cssVarPrefix: "stratakit-mui"
23
36
  },
24
37
  colorSchemes: {
25
- light: true,
26
- dark: true
38
+ light: { palette },
39
+ dark: { palette }
27
40
  },
28
41
  typography: {
29
42
  fontFamily: "var(--stratakit-font-family-sans)",
@@ -89,7 +102,8 @@ function createTheme() {
89
102
  },
90
103
  MuiButton: {
91
104
  defaultProps: {
92
- color: "secondary"
105
+ color: "secondary",
106
+ variant: "contained"
93
107
  }
94
108
  },
95
109
  MuiChip: {
package/dist/Root.js CHANGED
@@ -9,7 +9,7 @@ import { createTheme } from "./createTheme.js";
9
9
  import css from "./styles.css.js";
10
10
  const theme = createTheme();
11
11
  const packageName = "@stratakit/mui";
12
- const key = `${packageName}@${"0.1.2"}`;
12
+ const key = `${packageName}@${"0.1.3"}`;
13
13
  const Root = React.forwardRef((props, forwardedRef) => {
14
14
  const {
15
15
  children,
@@ -77,7 +77,7 @@ function Styles() {
77
77
  const $ = _c(4);
78
78
  const rootContext = useSafeContext(RootContext);
79
79
  if (!rootContext.versions?.has(packageName)) {
80
- rootContext.versions?.set(packageName, "0.1.2");
80
+ rootContext.versions?.set(packageName, "0.1.3");
81
81
  }
82
82
  const {
83
83
  rootNode,
@@ -2,6 +2,27 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { createTheme as createMuiTheme } from "@mui/material/styles";
3
3
  import { ArrowDownIcon, CaretsUpDownIcon, ChevronDownIcon, ChevronLeftDoubleIcon, ChevronLeftIcon, ChevronRightDoubleIcon, ChevronRightIcon, DismissIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from "./Icon.js";
4
4
  function createTheme() {
5
+ const palette = {
6
+ primary: {
7
+ main: "var(--stratakit-mui-palette-primary-main)"
8
+ },
9
+ secondary: {
10
+ main: "var(--stratakit-mui-palette-secondary-main)"
11
+ },
12
+ error: {
13
+ main: "var(--stratakit-mui-palette-error-main)"
14
+ },
15
+ warning: {
16
+ main: "var(--stratakit-mui-palette-warning-main)"
17
+ },
18
+ info: {
19
+ main: "var(--stratakit-mui-palette-info-main)"
20
+ },
21
+ success: {
22
+ main: "var(--stratakit-mui-palette-success-main)"
23
+ },
24
+ grey: Object.fromEntries(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"].map((shade) => [shade, `var(--stratakit-mui-palette-grey-${shade})`]))
25
+ };
5
26
  return createMuiTheme({
6
27
  cssVariables: {
7
28
  nativeColor: true,
@@ -9,8 +30,12 @@ function createTheme() {
9
30
  cssVarPrefix: "stratakit-mui"
10
31
  },
11
32
  colorSchemes: {
12
- light: true,
13
- dark: true
33
+ light: {
34
+ palette
35
+ },
36
+ dark: {
37
+ palette
38
+ }
14
39
  },
15
40
  typography: {
16
41
  fontFamily: "var(--stratakit-font-family-sans)",
@@ -76,7 +101,8 @@ function createTheme() {
76
101
  },
77
102
  MuiButton: {
78
103
  defaultProps: {
79
- color: "secondary"
104
+ color: "secondary",
105
+ variant: "contained"
80
106
  }
81
107
  },
82
108
  MuiChip: {
@@ -0,0 +1,11 @@
1
+ import "@mui/material/Button";
2
+ declare module "@mui/material/Button" {
3
+ interface ButtonOwnProps {
4
+ /**
5
+ * The default variant with `@stratakit/mui` is `"contained"`.
6
+ *
7
+ * @default 'contained'
8
+ */
9
+ variant?: "contained" | "outlined" | "text";
10
+ }
11
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stratakit/mui",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
7
7
  "types": "./dist/index.d.ts",
@@ -12,6 +12,11 @@
12
12
  "development": "./dist/DEV/index.js",
13
13
  "default": "./dist/index.js"
14
14
  },
15
+ "./types.d.ts": {
16
+ "@stratakit/source": "./src/types.d.ts",
17
+ "types": "./dist/types.d.ts",
18
+ "default": "./dist/types.d.ts"
19
+ },
15
20
  "./package.json": "./package.json"
16
21
  },
17
22
  "files": [
@@ -49,8 +54,8 @@
49
54
  "@types/react": "^19.2.7",
50
55
  "@types/react-dom": "^19.2.3",
51
56
  "esbuild": "^0.27.0",
52
- "react": "^19.2.1",
53
- "react-dom": "^19.2.1",
57
+ "react": "^19.2.3",
58
+ "react-dom": "^19.2.3",
54
59
  "typescript": "~5.9.3"
55
60
  },
56
61
  "peerDependencies": {