@stratakit/mui 0.4.2 → 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.
Files changed (41) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/DEV/Root.js +43 -21
  3. package/dist/DEV/styles.css.js +1 -1
  4. package/dist/DEV/~components/MuiAccordion.js +36 -0
  5. package/dist/DEV/~components/MuiAlert.js +37 -0
  6. package/dist/DEV/~components/MuiAutocomplete.js +134 -11
  7. package/dist/DEV/~components/MuiBadge.js +22 -4
  8. package/dist/DEV/~components/MuiCard.js +52 -8
  9. package/dist/DEV/~components/MuiDivider.js +2 -1
  10. package/dist/DEV/~components/MuiMenu.js +22 -0
  11. package/dist/DEV/~components/MuiPopover.js +40 -0
  12. package/dist/DEV/~components/MuiTabs.js +43 -0
  13. package/dist/DEV/~components/MuiTypography.js +16 -13
  14. package/dist/DEV/~createTheme.js +135 -52
  15. package/dist/Root.internal.d.ts +1 -1
  16. package/dist/Root.js +13 -4
  17. package/dist/styles.css.js +1 -1
  18. package/dist/types.d.ts +137 -5
  19. package/dist/~components/MuiAccordion.d.ts +11 -0
  20. package/dist/~components/MuiAccordion.js +30 -0
  21. package/dist/~components/MuiAlert.d.ts +4 -0
  22. package/dist/~components/MuiAlert.js +38 -0
  23. package/dist/~components/MuiAutocomplete.d.ts +4 -1
  24. package/dist/~components/MuiAutocomplete.js +132 -12
  25. package/dist/~components/MuiBadge.d.ts +5 -3
  26. package/dist/~components/MuiBadge.js +22 -4
  27. package/dist/~components/MuiCard.d.ts +2 -1
  28. package/dist/~components/MuiCard.js +66 -11
  29. package/dist/~components/MuiChip.d.ts +1 -1
  30. package/dist/~components/MuiDivider.js +1 -1
  31. package/dist/~components/MuiMenu.d.ts +7 -0
  32. package/dist/~components/MuiMenu.js +25 -0
  33. package/dist/~components/MuiPopover.d.ts +10 -0
  34. package/dist/~components/MuiPopover.js +62 -0
  35. package/dist/~components/MuiTabs.d.ts +8 -0
  36. package/dist/~components/MuiTabs.js +33 -0
  37. package/dist/~components/MuiTypography.d.ts +17 -1
  38. package/dist/~components/MuiTypography.js +13 -12
  39. package/dist/~createTheme.d.ts +4 -1
  40. package/dist/~createTheme.js +146 -69
  41. package/package.json +8 -8
@@ -5,14 +5,25 @@ import OutlinedInput from "@mui/material/OutlinedInput";
5
5
  import StepConnector from "@mui/material/StepConnector";
6
6
  import { createTheme as createMuiTheme } from "@mui/material/styles";
7
7
  import cx from "classnames";
8
- import { MuiAutocomplete } from "./~components/MuiAutocomplete.js";
8
+ import {
9
+ MuiAccordionRootSlot,
10
+ MuiAccordionSummary
11
+ } from "./~components/MuiAccordion.js";
12
+ import { MuiAlert, MuiAlertTitle } from "./~components/MuiAlert.js";
13
+ import {
14
+ MuiAutocomplete,
15
+ MuiAutocompleteChip,
16
+ MuiAutocompleteChipDeleteIcon,
17
+ MuiAutocompleteClearIndicator
18
+ } from "./~components/MuiAutocomplete.js";
9
19
  import { MuiAvatarGroup } from "./~components/MuiAvatarGroup.js";
10
- import { MuiBadge } from "./~components/MuiBadge.js";
20
+ import { MuiBadge, MuiBadgeBadge } from "./~components/MuiBadge.js";
11
21
  import { MuiBottomNavigationAction } from "./~components/MuiBottomNavigation.js";
12
22
  import { MuiButtonBase } from "./~components/MuiButtonBase.js";
13
23
  import {
14
24
  MuiCard,
15
25
  MuiCardActionArea,
26
+ MuiCardHeaderTitle,
16
27
  MuiCardMedia
17
28
  } from "./~components/MuiCard.js";
18
29
  import {
@@ -23,6 +34,8 @@ import {
23
34
  import { MuiDivider } from "./~components/MuiDivider.js";
24
35
  import { MuiIconButton } from "./~components/MuiIconButton.js";
25
36
  import { MuiInputLabel } from "./~components/MuiInputLabel.js";
37
+ import { MuiMenuListSlot } from "./~components/MuiMenu.js";
38
+ import { MuiPopoverPaperSlot } from "./~components/MuiPopover.js";
26
39
  import { MuiSnackbar } from "./~components/MuiSnackbar.js";
27
40
  import { MuiStepIcon } from "./~components/MuiStepper.js";
28
41
  import {
@@ -30,8 +43,9 @@ import {
30
43
  MuiTableCell,
31
44
  MuiTableHead
32
45
  } from "./~components/MuiTable.js";
46
+ import { MuiTab, MuiTabs } from "./~components/MuiTabs.js";
33
47
  import { MuiToggleButton } from "./~components/MuiToggleButton.js";
34
- import { MuiTypography } from "./~components/MuiTypography.js";
48
+ import { MuiTypography, variantMapping } from "./~components/MuiTypography.js";
35
49
  import {
36
50
  ArrowDownIcon,
37
51
  CaretsUpDownIcon,
@@ -46,7 +60,8 @@ import {
46
60
  SuccessIcon,
47
61
  WarningIcon
48
62
  } from "./Icon.js";
49
- function createTheme() {
63
+ function createTheme(args) {
64
+ const { portalContainer: container } = args;
50
65
  const palette = {
51
66
  primary: { main: "var(--stratakit-mui-palette-primary-main)" },
52
67
  secondary: { main: "var(--stratakit-mui-palette-secondary-main)" },
@@ -80,15 +95,19 @@ function createTheme() {
80
95
  // These are only hardcoded here as fallback. The CSS will take precedence.
81
96
  body1: { fontSize: 16 },
82
97
  body2: { fontSize: 14 },
83
- h1: { fontSize: 48 },
84
- h2: { fontSize: 40 },
85
- h3: { fontSize: 32 },
86
- h4: { fontSize: 28 },
87
- h5: { fontSize: 24 },
88
- h6: { fontSize: 20 },
98
+ h1: { fontSize: 20 },
99
+ h2: { fontSize: 18 },
100
+ h3: { fontSize: 16 },
101
+ h4: { fontSize: 14 },
102
+ h5: { fontSize: 12 },
103
+ h6: { fontSize: 12 },
89
104
  caption: { fontSize: 12 },
90
- subtitle1: { fontSize: 12 },
91
- subtitle2: { fontSize: 11 }
105
+ overline: {
106
+ fontSize: 12,
107
+ textTransform: "none"
108
+ },
109
+ subtitle1: { fontSize: 16 },
110
+ subtitle2: { fontSize: 14 }
92
111
  },
93
112
  shadows: [
94
113
  "none",
@@ -110,6 +129,10 @@ function createTheme() {
110
129
  MuiAccordion: {
111
130
  defaultProps: {
112
131
  component: Role.div,
132
+ disableGutters: true,
133
+ slots: {
134
+ root: MuiAccordionRootSlot
135
+ },
113
136
  slotProps: {
114
137
  region: {
115
138
  role: void 0,
@@ -120,24 +143,31 @@ function createTheme() {
120
143
  },
121
144
  MuiAccordionSummary: {
122
145
  defaultProps: {
123
- component: Role.div,
146
+ component: MuiAccordionSummary,
124
147
  nativeButton: false,
125
148
  expandIcon: /* @__PURE__ */ jsx(ChevronDownIcon, {})
126
149
  }
127
150
  },
128
151
  MuiAlert: {
129
152
  defaultProps: {
130
- component: Role.div,
153
+ component: MuiAlert,
131
154
  variant: "outlined",
155
+ severity: "none",
132
156
  iconMapping: {
133
157
  error: /* @__PURE__ */ jsx(ErrorIcon, {}),
134
158
  info: /* @__PURE__ */ jsx(InfoIcon, {}),
135
159
  success: /* @__PURE__ */ jsx(SuccessIcon, {}),
136
160
  warning: /* @__PURE__ */ jsx(WarningIcon, {})
161
+ },
162
+ slotProps: {
163
+ root: {
164
+ role: "group"
165
+ // Overriding role="alert".
166
+ }
137
167
  }
138
168
  }
139
169
  },
140
- MuiAlertTitle: { defaultProps: { component: Role.div } },
170
+ MuiAlertTitle: { defaultProps: { component: MuiAlertTitle } },
141
171
  MuiAutocomplete: {
142
172
  defaultProps: {
143
173
  popupIcon: /* @__PURE__ */ jsx(ChevronDownIcon, {}),
@@ -147,6 +177,7 @@ function createTheme() {
147
177
  {
148
178
  ...props,
149
179
  className: cx("MuiMenuItem-root", props.className),
180
+ "data-_sk-dense": ownerState.size === "small" ? "" : void 0,
150
181
  children: ownerState.getOptionLabel(option)
151
182
  },
152
183
  key
@@ -160,9 +191,12 @@ function createTheme() {
160
191
  // match Menu elevation
161
192
  },
162
193
  chip: {
163
- size: "small"
194
+ size: "small",
195
+ component: MuiAutocompleteChip,
196
+ deleteIcon: /* @__PURE__ */ jsx(MuiAutocompleteChipDeleteIcon, {})
164
197
  },
165
198
  clearIndicator: {
199
+ component: MuiAutocompleteClearIndicator,
166
200
  tabIndex: 0,
167
201
  // make clear indicator focusable
168
202
  size: "small"
@@ -199,7 +233,8 @@ function createTheme() {
199
233
  MuiBadge: {
200
234
  defaultProps: {
201
235
  component: MuiBadge,
202
- color: "secondary"
236
+ color: "secondary",
237
+ slotProps: { badge: { component: MuiBadgeBadge } }
203
238
  }
204
239
  },
205
240
  MuiBottomNavigation: { defaultProps: { component: Role.div } },
@@ -236,8 +271,18 @@ function createTheme() {
236
271
  // ButtonGroup overrides Button's disableRipple so we need to set it here as well
237
272
  }
238
273
  },
239
- MuiCard: { defaultProps: { component: MuiCard } },
240
- MuiCardActionArea: { defaultProps: { component: MuiCardActionArea } },
274
+ MuiCard: {
275
+ defaultProps: {
276
+ component: MuiCard,
277
+ variant: "outlined"
278
+ }
279
+ },
280
+ MuiCardActionArea: {
281
+ defaultProps: {
282
+ component: MuiCardActionArea,
283
+ slots: { focusHighlight: Nothing }
284
+ }
285
+ },
241
286
  MuiCardContent: { defaultProps: { component: Role.div } },
242
287
  MuiCardHeader: {
243
288
  defaultProps: {
@@ -245,7 +290,7 @@ function createTheme() {
245
290
  slotProps: {
246
291
  title: {
247
292
  // biome-ignore lint/suspicious/noExplicitAny: MUI's CardHeader.title.component is hardcoded to "span"
248
- component: Role.h2
293
+ component: MuiCardHeaderTitle
249
294
  }
250
295
  }
251
296
  }
@@ -308,33 +353,7 @@ function createTheme() {
308
353
  }
309
354
  },
310
355
  MuiLink: {
311
- defaultProps: { component: Role.a, color: "textPrimary" },
312
- variants: [
313
- {
314
- props: { color: "primary" },
315
- style: { color: "var(--stratakit-color-text-accent-strong)" }
316
- },
317
- {
318
- props: { color: "secondary" },
319
- style: { color: "var(--stratakit-color-text-neutral-primary)" }
320
- },
321
- {
322
- props: { color: "error" },
323
- style: { color: "var(--stratakit-color-text-critical-base)" }
324
- },
325
- {
326
- props: { color: "info" },
327
- style: { color: "var(--stratakit-color-text-info-base)" }
328
- },
329
- {
330
- props: { color: "success" },
331
- style: { color: "var(--stratakit-color-text-positive-base)" }
332
- },
333
- {
334
- props: { color: "warning" },
335
- style: { color: "var(--stratakit-color-text-attention-base)" }
336
- }
337
- ]
356
+ defaultProps: { component: Role.a, color: "textPrimary" }
338
357
  },
339
358
  MuiList: { defaultProps: { component: Role.ul } },
340
359
  MuiListItem: { defaultProps: { component: Role.li } },
@@ -355,6 +374,9 @@ function createTheme() {
355
374
  MuiMenu: {
356
375
  defaultProps: {
357
376
  component: Role.div,
377
+ slots: {
378
+ list: MuiMenuListSlot
379
+ },
358
380
  slotProps: {
359
381
  paper: {
360
382
  role: "presentation"
@@ -366,7 +388,7 @@ function createTheme() {
366
388
  MuiMenuItem: { defaultProps: { component: Role.li } },
367
389
  MuiMenuList: { defaultProps: { component: Role.ul } },
368
390
  MuiMobileStepper: { defaultProps: { component: Role.div } },
369
- MuiModal: { defaultProps: { component: Role.div } },
391
+ MuiModal: { defaultProps: { component: Role.div, container } },
370
392
  MuiOutlinedInput: {
371
393
  defaultProps: {
372
394
  notched: false
@@ -390,7 +412,20 @@ function createTheme() {
390
412
  MuiPopover: {
391
413
  defaultProps: {
392
414
  component: Role.div,
393
- slotProps: { paper: { role: "dialog" } }
415
+ disableScrollLock: true,
416
+ // Popover passes down `container` prop to `Modal` https://github.com/mui/material-ui/blob/708ef10e874efa63d2e4972bd902befa1912f2dc/packages/mui-material/src/Popover/Popover.js#L389
417
+ container,
418
+ slots: {
419
+ paper: MuiPopoverPaperSlot
420
+ },
421
+ slotProps: {
422
+ paper: { role: "dialog" }
423
+ }
424
+ }
425
+ },
426
+ MuiPopper: {
427
+ defaultProps: {
428
+ container
394
429
  }
395
430
  },
396
431
  MuiRadio: {
@@ -455,7 +490,24 @@ function createTheme() {
455
490
  },
456
491
  MuiSvgIcon: { defaultProps: { component: Role.svg } },
457
492
  MuiSwipeableDrawer: { defaultProps: { component: Role.div } },
458
- MuiTabs: { defaultProps: { component: Role.div } },
493
+ MuiTabs: {
494
+ defaultProps: {
495
+ component: MuiTabs,
496
+ allowScrollButtonsMobile: true,
497
+ slotProps: {
498
+ scrollButtons: {
499
+ "aria-hidden": true
500
+ },
501
+ startScrollButtonIcon: {
502
+ component: ChevronLeftIcon
503
+ },
504
+ endScrollButtonIcon: {
505
+ component: ChevronRightIcon
506
+ }
507
+ }
508
+ }
509
+ },
510
+ MuiTab: { defaultProps: { component: MuiTab, iconPosition: "start" } },
459
511
  MuiTable: { defaultProps: { component: withRenderProp(Role, "table") } },
460
512
  MuiTableBody: {
461
513
  defaultProps: {
@@ -521,9 +573,40 @@ function createTheme() {
521
573
  },
522
574
  MuiTypography: {
523
575
  defaultProps: {
524
- variant: "body2",
576
+ variant: "inherit",
577
+ variantMapping,
525
578
  component: MuiTypography
526
- }
579
+ },
580
+ variants: [
581
+ {
582
+ props: { color: "primary" },
583
+ style: { color: "var(--stratakit-color-text-accent-strong)" }
584
+ },
585
+ {
586
+ props: { color: "secondary" },
587
+ style: { color: "var(--stratakit-color-text-neutral-primary)" }
588
+ },
589
+ {
590
+ props: { color: "textTertiary" },
591
+ style: { color: "var(--stratakit-color-text-neutral-tertiary)" }
592
+ },
593
+ {
594
+ props: { color: "error" },
595
+ style: { color: "var(--stratakit-color-text-critical-base)" }
596
+ },
597
+ {
598
+ props: { color: "info" },
599
+ style: { color: "var(--stratakit-color-text-info-base)" }
600
+ },
601
+ {
602
+ props: { color: "success" },
603
+ style: { color: "var(--stratakit-color-text-positive-base)" }
604
+ },
605
+ {
606
+ props: { color: "warning" },
607
+ style: { color: "var(--stratakit-color-text-attention-base)" }
608
+ }
609
+ ]
527
610
  }
528
611
  }
529
612
  });
@@ -1,3 +1,3 @@
1
1
  import * as React from "react";
2
2
  /** This is similar to MUI's `StyledEngineProvider` but with a custom Emotion cache. */
3
- export declare function StyledEngineProvider({ children }: React.PropsWithChildren): import("react/jsx-runtime").JSX.Element;
3
+ export declare function StyledEngineProvider({ children }: React.PropsWithChildren): React.JSX.Element;
package/dist/Root.js CHANGED
@@ -8,9 +8,8 @@ import cx from "classnames";
8
8
  import { createTheme } from "./~createTheme.js";
9
9
  import { StyledEngineProvider } from "./Root.internal.js";
10
10
  import css from "./styles.css.js";
11
- const theme = createTheme();
12
11
  const packageName = "@stratakit/mui";
13
- const key = `${packageName}@${"0.4.2"}`;
12
+ const key = `${packageName}@${"0.5.0"}`;
14
13
  const Root = forwardRef((props, forwardedRef) => {
15
14
  const {
16
15
  children,
@@ -18,16 +17,24 @@ const Root = forwardRef((props, forwardedRef) => {
18
17
  unstable_accentColor,
19
18
  ...rest
20
19
  } = props;
20
+ const [portalContainer, setPortalContainer] = React.useState();
21
+ const theme = React.useMemo(() => createTheme({
22
+ portalContainer
23
+ }), [portalContainer]);
21
24
  return /* @__PURE__ */ jsx(StyledEngineProvider, {
22
25
  children: /* @__PURE__ */ jsxs(ThemeProvider, {
23
26
  theme,
24
27
  defaultMode: colorScheme,
28
+ storageManager: null,
29
+ disableTransitionOnChange: true,
30
+ noSsr: true,
25
31
  children: [/* @__PURE__ */ jsx(ColorScheme, {
26
32
  colorScheme
27
33
  }), /* @__PURE__ */ jsxs(RootInner, {
28
34
  ...rest,
29
35
  colorScheme,
30
36
  unstable_accentColor,
37
+ portalContainerRef: setPortalContainer,
31
38
  ref: forwardedRef,
32
39
  children: [/* @__PURE__ */ jsx(Styles, {}), children]
33
40
  })]
@@ -40,13 +47,15 @@ const RootInner = forwardRef((props, forwardedRef) => {
40
47
  colorScheme,
41
48
  unstable_accentColor,
42
49
  rootNode,
50
+ portalContainerRef,
43
51
  ...rest
44
52
  } = props;
45
53
  return /* @__PURE__ */ jsx(StrataKitRoot, {
46
54
  ...rest,
47
55
  className: cx("\u{1F95D}MuiRoot", props.className),
48
56
  portalContainer: /* @__PURE__ */ jsx("div", {
49
- className: "\u{1F95D}MuiRoot"
57
+ className: "\u{1F95D}MuiRoot",
58
+ ref: portalContainerRef
50
59
  }),
51
60
  colorScheme,
52
61
  unstable_accentColor,
@@ -86,7 +95,7 @@ function Styles() {
86
95
  const $ = _c(4);
87
96
  const rootContext = useSafeContext(RootContext);
88
97
  if (!rootContext.versions?.has(packageName)) {
89
- rootContext.versions?.set(packageName, "0.4.2");
98
+ rootContext.versions?.set(packageName, "0.5.0");
90
99
  }
91
100
  const {
92
101
  rootNode,