@stratakit/mui 0.4.2 → 0.5.1

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 (44) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/dist/DEV/Root.internal.js +1 -1
  3. package/dist/DEV/Root.js +43 -21
  4. package/dist/DEV/styles.css.js +1 -1
  5. package/dist/DEV/~components/MuiAccordion.js +36 -0
  6. package/dist/DEV/~components/MuiAlert.js +37 -0
  7. package/dist/DEV/~components/MuiAutocomplete.js +134 -11
  8. package/dist/DEV/~components/MuiBadge.js +24 -5
  9. package/dist/DEV/~components/MuiCard.js +53 -9
  10. package/dist/DEV/~components/MuiDivider.js +13 -3
  11. package/dist/DEV/~components/MuiMenu.js +22 -0
  12. package/dist/DEV/~components/MuiPopover.js +40 -0
  13. package/dist/DEV/~components/MuiTabs.js +43 -0
  14. package/dist/DEV/~components/MuiTypography.js +16 -13
  15. package/dist/DEV/~createTheme.js +142 -53
  16. package/dist/Root.internal.d.ts +1 -1
  17. package/dist/Root.internal.js +1 -1
  18. package/dist/Root.js +13 -4
  19. package/dist/styles.css.js +1 -1
  20. package/dist/types.d.ts +151 -5
  21. package/dist/~components/MuiAccordion.d.ts +11 -0
  22. package/dist/~components/MuiAccordion.js +30 -0
  23. package/dist/~components/MuiAlert.d.ts +4 -0
  24. package/dist/~components/MuiAlert.js +38 -0
  25. package/dist/~components/MuiAutocomplete.d.ts +4 -1
  26. package/dist/~components/MuiAutocomplete.js +132 -12
  27. package/dist/~components/MuiBadge.d.ts +6 -4
  28. package/dist/~components/MuiBadge.js +24 -4
  29. package/dist/~components/MuiCard.d.ts +2 -1
  30. package/dist/~components/MuiCard.js +67 -12
  31. package/dist/~components/MuiChip.d.ts +1 -1
  32. package/dist/~components/MuiDivider.d.ts +1 -1
  33. package/dist/~components/MuiDivider.js +3 -1
  34. package/dist/~components/MuiMenu.d.ts +7 -0
  35. package/dist/~components/MuiMenu.js +25 -0
  36. package/dist/~components/MuiPopover.d.ts +10 -0
  37. package/dist/~components/MuiPopover.js +62 -0
  38. package/dist/~components/MuiTabs.d.ts +8 -0
  39. package/dist/~components/MuiTabs.js +33 -0
  40. package/dist/~components/MuiTypography.d.ts +17 -1
  41. package/dist/~components/MuiTypography.js +13 -12
  42. package/dist/~createTheme.d.ts +4 -1
  43. package/dist/~createTheme.js +149 -70
  44. 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,32 @@ 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",
156
+ role: "group",
157
+ // Overriding role="alert".
132
158
  iconMapping: {
133
159
  error: /* @__PURE__ */ jsx(ErrorIcon, {}),
134
160
  info: /* @__PURE__ */ jsx(InfoIcon, {}),
135
161
  success: /* @__PURE__ */ jsx(SuccessIcon, {}),
136
162
  warning: /* @__PURE__ */ jsx(WarningIcon, {})
163
+ },
164
+ slotProps: {
165
+ closeButton: {
166
+ edge: "end"
167
+ }
137
168
  }
138
169
  }
139
170
  },
140
- MuiAlertTitle: { defaultProps: { component: Role.div } },
171
+ MuiAlertTitle: { defaultProps: { component: MuiAlertTitle } },
141
172
  MuiAutocomplete: {
142
173
  defaultProps: {
143
174
  popupIcon: /* @__PURE__ */ jsx(ChevronDownIcon, {}),
@@ -147,6 +178,7 @@ function createTheme() {
147
178
  {
148
179
  ...props,
149
180
  className: cx("MuiMenuItem-root", props.className),
181
+ "data-_sk-dense": ownerState.size === "small" ? "" : void 0,
150
182
  children: ownerState.getOptionLabel(option)
151
183
  },
152
184
  key
@@ -160,9 +192,12 @@ function createTheme() {
160
192
  // match Menu elevation
161
193
  },
162
194
  chip: {
163
- size: "small"
195
+ size: "small",
196
+ component: MuiAutocompleteChip,
197
+ deleteIcon: /* @__PURE__ */ jsx(MuiAutocompleteChipDeleteIcon, {})
164
198
  },
165
199
  clearIndicator: {
200
+ component: MuiAutocompleteClearIndicator,
166
201
  tabIndex: 0,
167
202
  // make clear indicator focusable
168
203
  size: "small"
@@ -199,7 +234,8 @@ function createTheme() {
199
234
  MuiBadge: {
200
235
  defaultProps: {
201
236
  component: MuiBadge,
202
- color: "secondary"
237
+ color: "secondary",
238
+ slotProps: { badge: { component: MuiBadgeBadge } }
203
239
  }
204
240
  },
205
241
  MuiBottomNavigation: { defaultProps: { component: Role.div } },
@@ -236,8 +272,18 @@ function createTheme() {
236
272
  // ButtonGroup overrides Button's disableRipple so we need to set it here as well
237
273
  }
238
274
  },
239
- MuiCard: { defaultProps: { component: MuiCard } },
240
- MuiCardActionArea: { defaultProps: { component: MuiCardActionArea } },
275
+ MuiCard: {
276
+ defaultProps: {
277
+ component: MuiCard,
278
+ variant: "outlined"
279
+ }
280
+ },
281
+ MuiCardActionArea: {
282
+ defaultProps: {
283
+ component: MuiCardActionArea,
284
+ slots: { focusHighlight: Nothing }
285
+ }
286
+ },
241
287
  MuiCardContent: { defaultProps: { component: Role.div } },
242
288
  MuiCardHeader: {
243
289
  defaultProps: {
@@ -245,7 +291,7 @@ function createTheme() {
245
291
  slotProps: {
246
292
  title: {
247
293
  // biome-ignore lint/suspicious/noExplicitAny: MUI's CardHeader.title.component is hardcoded to "span"
248
- component: Role.h2
294
+ component: MuiCardHeaderTitle
249
295
  }
250
296
  }
251
297
  }
@@ -280,7 +326,12 @@ function createTheme() {
280
326
  variant: "inherit"
281
327
  }
282
328
  },
283
- MuiDialogTitle: { defaultProps: { component: Role.h2 } },
329
+ MuiDialogTitle: {
330
+ defaultProps: {
331
+ component: Role.h2,
332
+ variant: "body-lg"
333
+ }
334
+ },
284
335
  MuiDivider: { defaultProps: { component: MuiDivider } },
285
336
  MuiDrawer: { defaultProps: { component: Role.div } },
286
337
  MuiFab: {
@@ -308,33 +359,7 @@ function createTheme() {
308
359
  }
309
360
  },
310
361
  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
- ]
362
+ defaultProps: { component: Role.a, color: "textPrimary" }
338
363
  },
339
364
  MuiList: { defaultProps: { component: Role.ul } },
340
365
  MuiListItem: { defaultProps: { component: Role.li } },
@@ -355,6 +380,9 @@ function createTheme() {
355
380
  MuiMenu: {
356
381
  defaultProps: {
357
382
  component: Role.div,
383
+ slots: {
384
+ list: MuiMenuListSlot
385
+ },
358
386
  slotProps: {
359
387
  paper: {
360
388
  role: "presentation"
@@ -366,7 +394,7 @@ function createTheme() {
366
394
  MuiMenuItem: { defaultProps: { component: Role.li } },
367
395
  MuiMenuList: { defaultProps: { component: Role.ul } },
368
396
  MuiMobileStepper: { defaultProps: { component: Role.div } },
369
- MuiModal: { defaultProps: { component: Role.div } },
397
+ MuiModal: { defaultProps: { component: Role.div, container } },
370
398
  MuiOutlinedInput: {
371
399
  defaultProps: {
372
400
  notched: false
@@ -390,7 +418,20 @@ function createTheme() {
390
418
  MuiPopover: {
391
419
  defaultProps: {
392
420
  component: Role.div,
393
- slotProps: { paper: { role: "dialog" } }
421
+ disableScrollLock: true,
422
+ // Popover passes down `container` prop to `Modal` https://github.com/mui/material-ui/blob/708ef10e874efa63d2e4972bd902befa1912f2dc/packages/mui-material/src/Popover/Popover.js#L389
423
+ container,
424
+ slots: {
425
+ paper: MuiPopoverPaperSlot
426
+ },
427
+ slotProps: {
428
+ paper: { role: "dialog" }
429
+ }
430
+ }
431
+ },
432
+ MuiPopper: {
433
+ defaultProps: {
434
+ container
394
435
  }
395
436
  },
396
437
  MuiRadio: {
@@ -455,7 +496,24 @@ function createTheme() {
455
496
  },
456
497
  MuiSvgIcon: { defaultProps: { component: Role.svg } },
457
498
  MuiSwipeableDrawer: { defaultProps: { component: Role.div } },
458
- MuiTabs: { defaultProps: { component: Role.div } },
499
+ MuiTabs: {
500
+ defaultProps: {
501
+ component: MuiTabs,
502
+ allowScrollButtonsMobile: true,
503
+ slotProps: {
504
+ scrollButtons: {
505
+ "aria-hidden": true
506
+ },
507
+ startScrollButtonIcon: {
508
+ component: ChevronLeftIcon
509
+ },
510
+ endScrollButtonIcon: {
511
+ component: ChevronRightIcon
512
+ }
513
+ }
514
+ }
515
+ },
516
+ MuiTab: { defaultProps: { component: MuiTab, iconPosition: "start" } },
459
517
  MuiTable: { defaultProps: { component: withRenderProp(Role, "table") } },
460
518
  MuiTableBody: {
461
519
  defaultProps: {
@@ -521,9 +579,40 @@ function createTheme() {
521
579
  },
522
580
  MuiTypography: {
523
581
  defaultProps: {
524
- variant: "body2",
582
+ variant: "inherit",
583
+ variantMapping,
525
584
  component: MuiTypography
526
- }
585
+ },
586
+ variants: [
587
+ {
588
+ props: { color: "primary" },
589
+ style: { color: "var(--stratakit-color-text-accent-strong)" }
590
+ },
591
+ {
592
+ props: { color: "secondary" },
593
+ style: { color: "var(--stratakit-color-text-neutral-primary)" }
594
+ },
595
+ {
596
+ props: { color: "textTertiary" },
597
+ style: { color: "var(--stratakit-color-text-neutral-tertiary)" }
598
+ },
599
+ {
600
+ props: { color: "error" },
601
+ style: { color: "var(--stratakit-color-text-critical-base)" }
602
+ },
603
+ {
604
+ props: { color: "info" },
605
+ style: { color: "var(--stratakit-color-text-info-base)" }
606
+ },
607
+ {
608
+ props: { color: "success" },
609
+ style: { color: "var(--stratakit-color-text-positive-base)" }
610
+ },
611
+ {
612
+ props: { color: "warning" },
613
+ style: { color: "var(--stratakit-color-text-attention-base)" }
614
+ }
615
+ ]
527
616
  }
528
617
  }
529
618
  });
@@ -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;
@@ -28,7 +28,7 @@ function _temp() {
28
28
  }
29
29
  function createEmotionCache() {
30
30
  const cache = createCache({
31
- key: "css",
31
+ key: "mui",
32
32
  speedy: true,
33
33
  // This injects styles using the `insertRule` API.
34
34
  stylisPlugins: [prefixer]
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.1"}`;
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.1");
90
99
  }
91
100
  const {
92
101
  rootNode,