@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.
@@ -1,5 +1,15 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Role } from "@ariakit/react/role";
4
+ import OutlinedInput from "@mui/material/OutlinedInput";
2
5
  import { createTheme as createMuiTheme } from "@mui/material/styles";
6
+ import { MuiBadge } from "./~components/MuiBadge.js";
7
+ import { MuiButtonBase } from "./~components/MuiButtonBase.js";
8
+ import { MuiCard, MuiCardActionArea } from "./~components/MuiCard.js";
9
+ import { MuiChip, MuiChipDeleteIcon, MuiChipLabel } from "./~components/MuiChip.js";
10
+ import { MuiIconButton } from "./~components/MuiIconButton.js";
11
+ import { MuiSnackbar } from "./~components/MuiSnackbar.js";
12
+ import { MuiTableCell, MuiTableHead } from "./~components/MuiTable.js";
3
13
  import { ArrowDownIcon, CaretsUpDownIcon, ChevronDownIcon, ChevronLeftDoubleIcon, ChevronLeftIcon, ChevronRightDoubleIcon, ChevronRightIcon, DismissIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from "./Icon.js";
4
14
  function createTheme() {
5
15
  const palette = {
@@ -43,6 +53,40 @@ function createTheme() {
43
53
  button: {
44
54
  textTransform: "none"
45
55
  // Disable all-caps on buttons and tabs
56
+ },
57
+ // These are only hardcoded here as fallback. The CSS will take precedence.
58
+ body1: {
59
+ fontSize: 16
60
+ },
61
+ body2: {
62
+ fontSize: 14
63
+ },
64
+ h1: {
65
+ fontSize: 48
66
+ },
67
+ h2: {
68
+ fontSize: 40
69
+ },
70
+ h3: {
71
+ fontSize: 32
72
+ },
73
+ h4: {
74
+ fontSize: 28
75
+ },
76
+ h5: {
77
+ fontSize: 24
78
+ },
79
+ h6: {
80
+ fontSize: 20
81
+ },
82
+ caption: {
83
+ fontSize: 12
84
+ },
85
+ subtitle1: {
86
+ fontSize: 12
87
+ },
88
+ subtitle2: {
89
+ fontSize: 11
46
90
  }
47
91
  },
48
92
  shadows: [
@@ -61,13 +105,31 @@ function createTheme() {
61
105
  // biome-ignore lint/suspicious/noExplicitAny: MUI expects 25 items in the shadows array
62
106
  ],
63
107
  components: {
108
+ MuiAppBar: {
109
+ defaultProps: {
110
+ component: Role.header
111
+ }
112
+ },
113
+ MuiAccordion: {
114
+ defaultProps: {
115
+ component: Role.div,
116
+ slotProps: {
117
+ region: {
118
+ role: void 0,
119
+ "aria-labelledby": void 0
120
+ }
121
+ }
122
+ }
123
+ },
64
124
  MuiAccordionSummary: {
65
125
  defaultProps: {
126
+ component: Role.div,
66
127
  expandIcon: /* @__PURE__ */ jsx(ChevronDownIcon, {})
67
128
  }
68
129
  },
69
130
  MuiAlert: {
70
131
  defaultProps: {
132
+ component: Role.div,
71
133
  variant: "outlined",
72
134
  iconMapping: {
73
135
  error: /* @__PURE__ */ jsx(ErrorIcon, {}),
@@ -77,6 +139,11 @@ function createTheme() {
77
139
  }
78
140
  }
79
141
  },
142
+ MuiAlertTitle: {
143
+ defaultProps: {
144
+ component: Role.div
145
+ }
146
+ },
80
147
  MuiAutocomplete: {
81
148
  defaultProps: {
82
149
  popupIcon: /* @__PURE__ */ jsx(ChevronDownIcon, {}),
@@ -85,58 +152,216 @@ function createTheme() {
85
152
  paper: {
86
153
  elevation: 8
87
154
  // match Menu elevation
155
+ },
156
+ clearIndicator: {
157
+ tabIndex: 0
158
+ // make clear indicator focusable
88
159
  }
89
160
  }
90
161
  }
91
162
  },
163
+ MuiAvatar: {
164
+ defaultProps: {
165
+ component: Role.div
166
+ }
167
+ },
168
+ MuiAvatarGroup: {
169
+ defaultProps: {
170
+ component: Role.div
171
+ }
172
+ },
173
+ MuiBackdrop: {
174
+ defaultProps: {
175
+ component: Role.div
176
+ }
177
+ },
178
+ MuiBadge: {
179
+ defaultProps: {
180
+ component: MuiBadge,
181
+ color: "secondary"
182
+ }
183
+ },
184
+ MuiBottomNavigation: {
185
+ defaultProps: {
186
+ component: Role.div
187
+ }
188
+ },
92
189
  MuiBreadcrumbs: {
93
190
  defaultProps: {
191
+ component: Role.nav,
94
192
  separator: /* @__PURE__ */ jsx(ChevronRightIcon, {})
95
193
  }
96
194
  },
97
195
  MuiButtonBase: {
98
196
  defaultProps: {
197
+ component: MuiButtonBase,
99
198
  disableRipple: true
100
199
  // https://mui.com/material-ui/getting-started/faq/#how-can-i-disable-the-ripple-effect-globally
101
200
  }
102
201
  },
103
202
  MuiButton: {
104
203
  defaultProps: {
204
+ component: MuiButtonBase,
105
205
  color: "secondary",
106
206
  variant: "contained"
107
207
  }
108
208
  },
109
209
  MuiButtonGroup: {
110
210
  defaultProps: {
211
+ component: Role.div,
111
212
  color: "secondary",
112
213
  disableRipple: true
113
214
  // ButtonGroup overrides Button's disableRipple so we need to set it here as well
114
215
  }
115
216
  },
116
- MuiChip: {
217
+ MuiCard: {
218
+ defaultProps: {
219
+ component: MuiCard
220
+ }
221
+ },
222
+ MuiCardActionArea: {
223
+ defaultProps: {
224
+ component: MuiCardActionArea
225
+ }
226
+ },
227
+ MuiCardContent: {
117
228
  defaultProps: {
118
- deleteIcon: /* @__PURE__ */ jsx(DismissIcon, {})
229
+ component: Role.div
230
+ }
231
+ },
232
+ MuiCardHeader: {
233
+ defaultProps: {
234
+ component: Role.div,
235
+ slotProps: {
236
+ title: {
237
+ component: Role.h2
238
+ }
239
+ }
240
+ }
241
+ },
242
+ MuiCardMedia: {
243
+ defaultProps: {
244
+ component: Role.div
119
245
  }
120
246
  },
121
247
  MuiCheckbox: {
122
248
  defaultProps: {
123
- disableRipple: true
249
+ component: Role.span,
250
+ disableRipple: true,
124
251
  // Checkbox doesn't inherit from ButtonBase
252
+ icon: /* @__PURE__ */ jsx(Fragment, {}),
253
+ checkedIcon: /* @__PURE__ */ jsx(Fragment, {}),
254
+ indeterminateIcon: /* @__PURE__ */ jsx(Fragment, {})
125
255
  }
126
256
  },
127
- MuiInputLabel: {
257
+ MuiChip: {
128
258
  defaultProps: {
129
- shrink: true
130
- // Removes label animation and masked border from TextField
259
+ component: MuiChip,
260
+ deleteIcon: /* @__PURE__ */ jsx(MuiChipDeleteIcon, {}),
261
+ slotProps: {
262
+ label: {
263
+ component: MuiChipLabel
264
+ }
265
+ }
266
+ }
267
+ },
268
+ MuiContainer: {
269
+ defaultProps: {
270
+ component: Role.div
271
+ }
272
+ },
273
+ MuiDialog: {
274
+ defaultProps: {
275
+ component: Role.div
276
+ }
277
+ },
278
+ MuiDialogContentText: {
279
+ defaultProps: {
280
+ component: Role.p
281
+ }
282
+ },
283
+ MuiDialogTitle: {
284
+ defaultProps: {
285
+ component: Role.h2
286
+ }
287
+ },
288
+ MuiDivider: {
289
+ defaultProps: {
290
+ component: withRenderProp(Role, "hr")
291
+ }
292
+ },
293
+ MuiDrawer: {
294
+ defaultProps: {
295
+ component: Role.div
131
296
  }
132
297
  },
133
298
  MuiFab: {
134
299
  defaultProps: {
300
+ component: MuiButtonBase,
135
301
  color: "primary"
136
302
  }
137
303
  },
304
+ MuiFormControl: {
305
+ defaultProps: {
306
+ component: Role.div
307
+ }
308
+ },
309
+ MuiFormHelperText: {
310
+ defaultProps: {
311
+ component: Role.p
312
+ }
313
+ },
314
+ MuiFormLabel: {
315
+ defaultProps: {
316
+ component: Role.label
317
+ }
318
+ },
319
+ MuiGrid: {
320
+ defaultProps: {
321
+ component: Role.div
322
+ }
323
+ },
324
+ MuiGridLegacy: {
325
+ defaultProps: {
326
+ component: Role.div
327
+ }
328
+ },
329
+ MuiIcon: {
330
+ defaultProps: {
331
+ component: Role.span
332
+ }
333
+ },
334
+ MuiIconButton: {
335
+ defaultProps: {
336
+ component: MuiIconButton,
337
+ color: "secondary"
338
+ }
339
+ },
340
+ MuiImageList: {
341
+ defaultProps: {
342
+ component: Role.ul
343
+ }
344
+ },
345
+ MuiImageListItem: {
346
+ defaultProps: {
347
+ component: Role.li
348
+ }
349
+ },
350
+ MuiInputAdornment: {
351
+ defaultProps: {
352
+ component: Role.div
353
+ }
354
+ },
355
+ MuiInputLabel: {
356
+ defaultProps: {
357
+ component: Role.label,
358
+ shrink: true
359
+ // Removes label animation and masked border from TextField
360
+ }
361
+ },
138
362
  MuiLink: {
139
363
  defaultProps: {
364
+ component: Role.a,
140
365
  color: "textPrimary"
141
366
  },
142
367
  variants: [{
@@ -183,6 +408,60 @@ function createTheme() {
183
408
  }
184
409
  }]
185
410
  },
411
+ MuiList: {
412
+ defaultProps: {
413
+ component: Role.ul
414
+ }
415
+ },
416
+ MuiListItem: {
417
+ defaultProps: {
418
+ component: Role.li
419
+ }
420
+ },
421
+ MuiListItemButton: {
422
+ defaultProps: {
423
+ component: MuiButtonBase
424
+ }
425
+ },
426
+ MuiListItemText: {
427
+ defaultProps: {
428
+ slotProps: {
429
+ primary: {
430
+ variant: "inherit"
431
+ }
432
+ }
433
+ }
434
+ },
435
+ MuiListSubheader: {
436
+ defaultProps: {
437
+ component: Role.li
438
+ }
439
+ },
440
+ MuiMenu: {
441
+ defaultProps: {
442
+ component: Role.div
443
+ }
444
+ },
445
+ MuiMenuItem: {
446
+ defaultProps: {
447
+ component: Role.li
448
+ }
449
+ },
450
+ MuiMenuList: {
451
+ defaultProps: {
452
+ component: Role.ul
453
+ }
454
+ },
455
+ MuiMobileStepper: {
456
+ defaultProps: {
457
+ component: Role.div
458
+ }
459
+ },
460
+ MuiModal: {
461
+ defaultProps: {
462
+ component: Role.div
463
+ }
464
+ },
186
465
  MuiOutlinedInput: {
187
466
  defaultProps: {
188
467
  notched: false
@@ -191,6 +470,7 @@ function createTheme() {
191
470
  },
192
471
  MuiPaginationItem: {
193
472
  defaultProps: {
473
+ component: MuiButtonBase,
194
474
  slots: {
195
475
  previous: ChevronLeftIcon,
196
476
  next: ChevronRightIcon,
@@ -199,11 +479,152 @@ function createTheme() {
199
479
  }
200
480
  }
201
481
  },
482
+ MuiPaper: {
483
+ defaultProps: {
484
+ component: Role.div
485
+ }
486
+ },
487
+ MuiPopover: {
488
+ defaultProps: {
489
+ component: Role.div
490
+ }
491
+ },
492
+ MuiRadio: {
493
+ defaultProps: {
494
+ component: Role.span,
495
+ disableRipple: true,
496
+ // Radio doesn't inherit from ButtonBase
497
+ icon: /* @__PURE__ */ jsx(Fragment, {}),
498
+ checkedIcon: /* @__PURE__ */ jsx(Fragment, {})
499
+ }
500
+ },
501
+ MuiRating: {
502
+ defaultProps: {
503
+ component: Role.span
504
+ }
505
+ },
202
506
  MuiSelect: {
203
507
  defaultProps: {
204
508
  IconComponent: CaretsUpDownIcon
205
509
  }
206
510
  },
511
+ MuiNativeSelect: {
512
+ defaultProps: {
513
+ input: /* @__PURE__ */ jsx(OutlinedInput, {}),
514
+ IconComponent: CaretsUpDownIcon
515
+ }
516
+ },
517
+ MuiSkeleton: {
518
+ defaultProps: {
519
+ component: Role.span
520
+ }
521
+ },
522
+ MuiSlider: {
523
+ defaultProps: {
524
+ component: Role.span
525
+ }
526
+ },
527
+ MuiSnackbar: {
528
+ defaultProps: {
529
+ slotProps: {
530
+ root: {
531
+ component: MuiSnackbar
532
+ }
533
+ }
534
+ }
535
+ },
536
+ MuiSnackbarContent: {
537
+ defaultProps: {
538
+ component: Role.div
539
+ }
540
+ },
541
+ MuiStack: {
542
+ defaultProps: {
543
+ component: Role.div
544
+ }
545
+ },
546
+ MuiStep: {
547
+ defaultProps: {
548
+ component: Role.div
549
+ }
550
+ },
551
+ MuiSwitch: {
552
+ defaultProps: {
553
+ component: Role.span
554
+ }
555
+ },
556
+ MuiStepper: {
557
+ defaultProps: {
558
+ component: Role.div
559
+ }
560
+ },
561
+ MuiSvgIcon: {
562
+ defaultProps: {
563
+ component: Role.svg
564
+ }
565
+ },
566
+ MuiSwipeableDrawer: {
567
+ defaultProps: {
568
+ component: Role.div
569
+ }
570
+ },
571
+ MuiTabs: {
572
+ defaultProps: {
573
+ component: Role.div
574
+ }
575
+ },
576
+ MuiTable: {
577
+ defaultProps: {
578
+ component: withRenderProp(Role, "table")
579
+ }
580
+ },
581
+ MuiTableBody: {
582
+ defaultProps: {
583
+ component: withRenderProp(Role, "tbody")
584
+ }
585
+ },
586
+ MuiTableCell: {
587
+ defaultProps: {
588
+ component: MuiTableCell
589
+ }
590
+ },
591
+ MuiTableContainer: {
592
+ defaultProps: {
593
+ component: withRenderProp(Role, "div")
594
+ }
595
+ },
596
+ MuiTableFooter: {
597
+ defaultProps: {
598
+ component: withRenderProp(Role, "tfoot")
599
+ }
600
+ },
601
+ MuiTableHead: {
602
+ defaultProps: {
603
+ component: MuiTableHead
604
+ }
605
+ },
606
+ MuiTablePagination: {
607
+ defaultProps: {
608
+ component: withRenderProp(Role, "td"),
609
+ slotProps: {
610
+ root: {
611
+ colSpan: 999
612
+ }
613
+ }
614
+ }
615
+ },
616
+ MuiTableRow: {
617
+ defaultProps: {
618
+ component: withRenderProp(Role, "tr")
619
+ }
620
+ },
621
+ MuiTableSortLabel: {
622
+ defaultProps: {
623
+ component: Role.span,
624
+ // TODO: This should use sort-ascending and sort-descending icons, but that requires disabling MUI's built-in icon rotation.
625
+ IconComponent: ArrowDownIcon
626
+ }
627
+ },
207
628
  MuiTablePaginationActions: {
208
629
  defaultProps: {
209
630
  slots: {
@@ -214,20 +635,59 @@ function createTheme() {
214
635
  }
215
636
  }
216
637
  },
217
- MuiTableSortLabel: {
638
+ MuiTextField: {
218
639
  defaultProps: {
219
- // TODO: This should use sort-ascending and sort-descending icons, but that requires disabling MUI's built-in icon rotation.
220
- IconComponent: ArrowDownIcon
640
+ component: Role.div
641
+ }
642
+ },
643
+ MuiToggleButton: {
644
+ defaultProps: {
645
+ component: MuiIconButton
646
+ }
647
+ },
648
+ MuiToolbar: {
649
+ defaultProps: {
650
+ component: Role.div
221
651
  }
222
652
  },
223
653
  MuiTooltip: {
224
654
  defaultProps: {
225
655
  describeChild: true
226
656
  }
657
+ },
658
+ MuiTypography: {
659
+ defaultProps: {
660
+ variant: "body2",
661
+ variantMapping: {
662
+ h1: Role.h1,
663
+ h2: Role.h2,
664
+ h3: Role.h3,
665
+ h4: Role.h4,
666
+ h5: Role.h5,
667
+ h6: Role.h6,
668
+ subtitle1: Role.h6,
669
+ subtitle2: Role.h6,
670
+ body1: Role.p,
671
+ body2: Role.p,
672
+ inherit: Role.p,
673
+ button: Role.span,
674
+ caption: Role.span,
675
+ overline: Role.span
676
+ }
677
+ }
227
678
  }
228
679
  }
229
680
  });
230
681
  }
682
+ function withRenderProp(Role2, DefaultTagName) {
683
+ return React.forwardRef((props, forwardedRef) => {
684
+ return /* @__PURE__ */ jsx(Role2, {
685
+ render: /* @__PURE__ */ jsx(DefaultTagName, {}),
686
+ ...props,
687
+ ref: forwardedRef
688
+ });
689
+ });
690
+ }
231
691
  export {
232
692
  createTheme
233
693
  };