@react-md/core 1.0.0-next.6 → 1.0.0-next.8
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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +12 -0
- package/coverage/clover.xml +264 -389
- package/coverage/coverage-final.json +2 -3
- package/coverage/lcov-report/MenuItemCheckbox.tsx.html +223 -0
- package/coverage/lcov-report/MenuItemInputToggle.tsx.html +178 -232
- package/coverage/lcov-report/MenuItemRadio.tsx.html +436 -0
- package/coverage/lcov-report/SrOnly.tsx.html +328 -0
- package/coverage/lcov-report/Typography.tsx.html +1027 -0
- package/coverage/lcov-report/index.html +15 -30
- package/coverage/lcov-report/menuItemInputToggleStyles.ts.html +319 -0
- package/coverage/lcov.info +304 -436
- package/dist/_core.scss +49 -43
- package/dist/badge/_badge.scss +23 -19
- package/dist/form/MenuItemInputToggle.d.ts +2 -15
- package/dist/form/MenuItemInputToggle.js +26 -37
- package/dist/form/MenuItemInputToggle.js.map +1 -1
- package/dist/form/_form.scss +109 -87
- package/dist/form/menuItemInputToggleStyles.d.ts +39 -0
- package/dist/form/menuItemInputToggleStyles.js +31 -0
- package/dist/form/menuItemInputToggleStyles.js.map +1 -0
- package/dist/icon/_icon.scss +7 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interaction/_interaction.scss +56 -44
- package/dist/list/types.d.ts +10 -1
- package/dist/list/types.js.map +1 -1
- package/dist/menu/_menu.scss +1 -0
- package/dist/theme/_theme.scss +192 -34
- package/dist/typography/SrOnly.d.ts +3 -3
- package/dist/typography/SrOnly.js +4 -4
- package/dist/typography/SrOnly.js.map +1 -1
- package/dist/typography/Typography.d.ts +19 -19
- package/dist/typography/Typography.js +19 -19
- package/dist/typography/Typography.js.map +1 -1
- package/dist/typography/_typography.scss +65 -25
- package/package.json +11 -11
- package/src/_core.scss +49 -43
- package/src/badge/_badge.scss +23 -19
- package/src/button/__tests__/__snapshots__/Button.tsx.snap +1 -1
- package/src/form/MenuItemInputToggle.tsx +46 -64
- package/src/form/__tests__/MenuItemCheckbox.tsx +53 -0
- package/src/form/__tests__/MenuItemRadio.tsx +53 -0
- package/src/form/__tests__/__snapshots__/FileInput.tsx.snap +23 -23
- package/src/form/__tests__/__snapshots__/MenuItemCheckbox.tsx.snap +96 -0
- package/src/form/__tests__/__snapshots__/MenuItemRadio.tsx.snap +96 -0
- package/src/form/_form.scss +109 -87
- package/src/form/menuItemInputToggleStyles.ts +78 -0
- package/src/icon/_icon.scss +7 -5
- package/src/index.ts +1 -0
- package/src/interaction/_interaction.scss +56 -44
- package/src/list/types.ts +12 -1
- package/src/menu/_menu.scss +1 -0
- package/src/theme/_theme.scss +192 -34
- package/src/typography/SrOnly.tsx +9 -9
- package/src/typography/Typography.tsx +19 -19
- package/src/typography/__tests__/__snapshots__/SrOnly.tsx.snap +5 -5
- package/src/typography/_typography.scss +65 -25
|
@@ -4,6 +4,18 @@
|
|
|
4
4
|
@use "../utils";
|
|
5
5
|
|
|
6
6
|
$disable-text-container: false !default;
|
|
7
|
+
$disable-headline-1: false !default;
|
|
8
|
+
$disable-headline-2: false !default;
|
|
9
|
+
$disable-headline-3: false !default;
|
|
10
|
+
$disable-headline-4: false !default;
|
|
11
|
+
$disable-headline-5: false !default;
|
|
12
|
+
$disable-headline-6: false !default;
|
|
13
|
+
$disable-subtitle-1: false !default;
|
|
14
|
+
$disable-subtitle-2: false !default;
|
|
15
|
+
$disable-body-1: false !default;
|
|
16
|
+
$disable-body-2: false !default;
|
|
17
|
+
$disable-caption: false !default;
|
|
18
|
+
$disable-overline: false !default;
|
|
7
19
|
|
|
8
20
|
/// A small utility function to get the letter spacing based on tracking and
|
|
9
21
|
/// font-size
|
|
@@ -216,9 +228,13 @@ $button-recommended-styles: map.merge(
|
|
|
216
228
|
$base-font-styles,
|
|
217
229
|
(
|
|
218
230
|
font-size: 0.875rem,
|
|
219
|
-
line-height: 2.25rem,
|
|
220
231
|
font-weight: map.get($font-weights, medium),
|
|
221
232
|
letter-spacing: get-letter-spacing(1.25, 0.875),
|
|
233
|
+
line-height: 2.25rem,
|
|
234
|
+
// buttons with multiple lines of text look terrible because of the large
|
|
235
|
+
// line-height. You normally want to use a different component if the
|
|
236
|
+
// clickable area has so much content to line-wrap
|
|
237
|
+
line-wrap: nowrap,
|
|
222
238
|
)
|
|
223
239
|
);
|
|
224
240
|
$button-custom-styles: () !default;
|
|
@@ -276,52 +292,76 @@ $typography-variables: (line-length, text-container-padding);
|
|
|
276
292
|
.rmd-typography {
|
|
277
293
|
@include utils.map-to-styles($base-font-styles);
|
|
278
294
|
|
|
279
|
-
|
|
280
|
-
|
|
295
|
+
@if not $disable-headline-1 {
|
|
296
|
+
&--headline-1 {
|
|
297
|
+
@include utils.map-to-styles($headline-1-styles);
|
|
298
|
+
}
|
|
281
299
|
}
|
|
282
300
|
|
|
283
|
-
|
|
284
|
-
|
|
301
|
+
@if not $disable-headline-2 {
|
|
302
|
+
&--headline-2 {
|
|
303
|
+
@include utils.map-to-styles($headline-2-styles);
|
|
304
|
+
}
|
|
285
305
|
}
|
|
286
306
|
|
|
287
|
-
|
|
288
|
-
|
|
307
|
+
@if not $disable-headline-3 {
|
|
308
|
+
&--headline-3 {
|
|
309
|
+
@include utils.map-to-styles($headline-3-styles);
|
|
310
|
+
}
|
|
289
311
|
}
|
|
290
312
|
|
|
291
|
-
|
|
292
|
-
|
|
313
|
+
@if not $disable-headline-4 {
|
|
314
|
+
&--headline-4 {
|
|
315
|
+
@include utils.map-to-styles($headline-4-styles);
|
|
316
|
+
}
|
|
293
317
|
}
|
|
294
318
|
|
|
295
|
-
|
|
296
|
-
|
|
319
|
+
@if not $disable-headline-5 {
|
|
320
|
+
&--headline-5 {
|
|
321
|
+
@include utils.map-to-styles($headline-5-styles);
|
|
322
|
+
}
|
|
297
323
|
}
|
|
298
324
|
|
|
299
|
-
|
|
300
|
-
|
|
325
|
+
@if not $disable-headline-6 {
|
|
326
|
+
&--headline-6 {
|
|
327
|
+
@include utils.map-to-styles($headline-6-styles);
|
|
328
|
+
}
|
|
301
329
|
}
|
|
302
330
|
|
|
303
|
-
|
|
304
|
-
|
|
331
|
+
@if not $disable-subtitle-1 {
|
|
332
|
+
&--subtitle-1 {
|
|
333
|
+
@include utils.map-to-styles($subtitle-1-styles);
|
|
334
|
+
}
|
|
305
335
|
}
|
|
306
336
|
|
|
307
|
-
|
|
308
|
-
|
|
337
|
+
@if not $disable-subtitle-2 {
|
|
338
|
+
&--subtitle-2 {
|
|
339
|
+
@include utils.map-to-styles($subtitle-2-styles);
|
|
340
|
+
}
|
|
309
341
|
}
|
|
310
342
|
|
|
311
|
-
|
|
312
|
-
|
|
343
|
+
@if not $disable-body-1 {
|
|
344
|
+
&--body-1 {
|
|
345
|
+
@include utils.map-to-styles($body-1-styles);
|
|
346
|
+
}
|
|
313
347
|
}
|
|
314
348
|
|
|
315
|
-
|
|
316
|
-
|
|
349
|
+
@if not $disable-body-2 {
|
|
350
|
+
&--body-2 {
|
|
351
|
+
@include utils.map-to-styles($body-2-styles);
|
|
352
|
+
}
|
|
317
353
|
}
|
|
318
354
|
|
|
319
|
-
|
|
320
|
-
|
|
355
|
+
@if not $disable-caption {
|
|
356
|
+
&--caption {
|
|
357
|
+
@include utils.map-to-styles($caption-styles);
|
|
358
|
+
}
|
|
321
359
|
}
|
|
322
360
|
|
|
323
|
-
|
|
324
|
-
|
|
361
|
+
@if not $disable-overline {
|
|
362
|
+
&--overline {
|
|
363
|
+
@include utils.map-to-styles($overline-styles);
|
|
364
|
+
}
|
|
325
365
|
}
|
|
326
366
|
}
|
|
327
367
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-md/core",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.8",
|
|
4
4
|
"description": "The core components and functionality for react-md.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sass": "./dist/_core.scss",
|
|
@@ -60,15 +60,15 @@
|
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@jest/globals": "^29.7.0",
|
|
62
62
|
"@jest/types": "^29.6.3",
|
|
63
|
-
"@swc/cli": "^0.
|
|
64
|
-
"@swc/core": "1.3.
|
|
63
|
+
"@swc/cli": "^0.3.2",
|
|
64
|
+
"@swc/core": "1.3.106",
|
|
65
65
|
"@swc/jest": "^0.2.31",
|
|
66
66
|
"@testing-library/dom": "^9.3.4",
|
|
67
67
|
"@testing-library/jest-dom": "^6.3.0",
|
|
68
68
|
"@testing-library/react": "^14.1.2",
|
|
69
69
|
"@testing-library/user-event": "^14.5.2",
|
|
70
70
|
"@types/lodash": "^4.14.202",
|
|
71
|
-
"@types/node": "^20.11.
|
|
71
|
+
"@types/node": "^20.11.7",
|
|
72
72
|
"@types/react": "^18.2.48",
|
|
73
73
|
"@types/react-dom": "^18.2.18",
|
|
74
74
|
"chokidar": "^3.5.3",
|
|
@@ -90,12 +90,12 @@
|
|
|
90
90
|
"typescript": "^5.3.3"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
|
-
"@jest/globals": "^29.
|
|
94
|
-
"@jest/types": "^29.6.
|
|
95
|
-
"@testing-library/dom": "^9.3.
|
|
96
|
-
"@testing-library/jest-dom": "^
|
|
97
|
-
"@testing-library/react": "^14.
|
|
98
|
-
"@testing-library/user-event": "^14.
|
|
93
|
+
"@jest/globals": "^29.7.0",
|
|
94
|
+
"@jest/types": "^29.6.3",
|
|
95
|
+
"@testing-library/dom": "^9.3.4",
|
|
96
|
+
"@testing-library/jest-dom": "^6.3.0",
|
|
97
|
+
"@testing-library/react": "^14.1.2",
|
|
98
|
+
"@testing-library/user-event": "^14.5.2",
|
|
99
99
|
"react": ">= 18",
|
|
100
100
|
"react-dom": ">= 18"
|
|
101
101
|
},
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"dev": "npm-run-all --parallel build-esm-watch build-scss-watch build-types-watch",
|
|
133
133
|
"prepare-release": "npm-run-all clean-dist build",
|
|
134
134
|
"build": "npm-run-all build-esm build-scss build-types",
|
|
135
|
-
"build-esm": "swc
|
|
135
|
+
"build-esm": "swc -d ./dist --strip-leading-paths src",
|
|
136
136
|
"build-esm-watch": "pnpm run build-esm --watch",
|
|
137
137
|
"build-types": "tsc -P tsconfig.types.json",
|
|
138
138
|
"build-types-watch": "pnpm run build-types --watch",
|
package/src/_core.scss
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
@forward "icon/icon" as icon-*;
|
|
14
14
|
@forward "divider/divider" as divider-*;
|
|
15
15
|
@forward "progress/progress" as progress-*;
|
|
16
|
+
@forward "overlay/overlay" as overlay-*;
|
|
16
17
|
@forward "button/button" as button-*;
|
|
17
18
|
@forward "badge/badge" as badge-*;
|
|
18
19
|
@forward "tabs/tabs" as tabs-*;
|
|
@@ -21,7 +22,6 @@
|
|
|
21
22
|
@forward "table/table" as table-*;
|
|
22
23
|
@forward "app-bar/app-bar" as app-bar-*;
|
|
23
24
|
@forward "responsive-item/responsive-item" as responsive-item-*;
|
|
24
|
-
@forward "overlay/overlay" as overlay-*;
|
|
25
25
|
@forward "card/card" as card-*;
|
|
26
26
|
@forward "link/link" as link-*;
|
|
27
27
|
@forward "list/list" as list-*;
|
|
@@ -361,53 +361,59 @@ $_layer-order: (
|
|
|
361
361
|
@include typography.typography-variables;
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
@mixin styles
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
@
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
@
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
@
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
@include
|
|
381
|
-
@include
|
|
382
|
-
@include
|
|
383
|
-
@include
|
|
384
|
-
@include
|
|
385
|
-
@include
|
|
386
|
-
@include
|
|
387
|
-
@include
|
|
388
|
-
@include
|
|
389
|
-
@include
|
|
390
|
-
@include
|
|
391
|
-
@include
|
|
392
|
-
@include
|
|
393
|
-
@include
|
|
394
|
-
@include
|
|
395
|
-
@include
|
|
396
|
-
@include
|
|
397
|
-
@include
|
|
398
|
-
@include
|
|
399
|
-
@include
|
|
400
|
-
@include
|
|
364
|
+
@mixin styles(
|
|
365
|
+
$disable-layer: false,
|
|
366
|
+
$disable-layer-order: $disable-layer,
|
|
367
|
+
$disable-reset: false,
|
|
368
|
+
$disable-css-utils: false
|
|
369
|
+
) {
|
|
370
|
+
@if not $disable-layer-order {
|
|
371
|
+
@layer #{$_layer-order};
|
|
372
|
+
}
|
|
373
|
+
@if not $disable-reset {
|
|
374
|
+
@include css-reset;
|
|
375
|
+
}
|
|
376
|
+
@if not $disable-css-utils {
|
|
377
|
+
@include css-utils($disable-layer);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
@include app-bar.styles($disable-layer);
|
|
381
|
+
@include avatar.styles($disable-layer);
|
|
382
|
+
@include badge.styles($disable-layer);
|
|
383
|
+
@include box.styles($disable-layer);
|
|
384
|
+
@include button.styles($disable-layer);
|
|
385
|
+
@include card.styles($disable-layer);
|
|
386
|
+
@include chip.styles($disable-layer);
|
|
387
|
+
@include dialog.styles($disable-layer);
|
|
388
|
+
@include divider.styles($disable-layer);
|
|
389
|
+
@include draggable.styles($disable-layer);
|
|
390
|
+
@include expansion-panel.styles($disable-layer);
|
|
391
|
+
@include form.styles($disable-layer);
|
|
392
|
+
@include icon.styles($disable-layer);
|
|
393
|
+
@include interaction.styles($disable-layer);
|
|
394
|
+
@include layout.styles($disable-layer);
|
|
395
|
+
@include link.styles($disable-layer);
|
|
396
|
+
@include list.styles($disable-layer);
|
|
397
|
+
@include menu.styles($disable-layer);
|
|
398
|
+
@include overlay.styles($disable-layer);
|
|
399
|
+
@include progress.styles($disable-layer);
|
|
400
|
+
@include responsive-item.styles($disable-layer);
|
|
401
|
+
@include segmented-button.styles($disable-layer);
|
|
402
|
+
@include sheet.styles($disable-layer);
|
|
403
|
+
@include snackbar.styles($disable-layer);
|
|
404
|
+
@include table.styles($disable-layer);
|
|
405
|
+
@include tabs.styles($disable-layer);
|
|
406
|
+
@include tooltip.styles($disable-layer);
|
|
407
|
+
@include transition.transition-styles($disable-layer);
|
|
408
|
+
@include tree.styles($disable-layer);
|
|
409
|
+
@include typography.typography-styles($disable-layer);
|
|
410
|
+
@include window-splitter.styles($disable-layer);
|
|
401
411
|
|
|
402
412
|
@if not theme.$disable-default-root-theme {
|
|
403
413
|
:root {
|
|
404
414
|
@include variables;
|
|
405
415
|
|
|
406
|
-
@if
|
|
407
|
-
theme.$disable-default-system-theme and
|
|
408
|
-
theme.$color-scheme ==
|
|
409
|
-
system
|
|
410
|
-
{
|
|
416
|
+
@if theme.$color-scheme == system {
|
|
411
417
|
@media (prefers-color-scheme: dark) {
|
|
412
418
|
@include use-dark-theme;
|
|
413
419
|
}
|
package/src/badge/_badge.scss
CHANGED
|
@@ -69,31 +69,35 @@ $variables: (
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
@mixin use-light-theme {
|
|
72
|
-
@if $
|
|
73
|
-
$
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
@
|
|
72
|
+
@if not $disable-everything {
|
|
73
|
+
@if $light-theme-greyscale-background-color !=
|
|
74
|
+
$dark-theme-greyscale-background-color
|
|
75
|
+
{
|
|
76
|
+
@include set-var(
|
|
77
|
+
greyscale-background-color,
|
|
78
|
+
$light-theme-greyscale-background-color
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
@if $light-theme-greyscale-color != $dark-theme-greyscale-color {
|
|
82
|
+
@include set-var(greyscale-color, $light-theme-greyscale-color);
|
|
83
|
+
}
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
@mixin use-dark-theme {
|
|
86
|
-
@if $
|
|
87
|
-
$
|
|
88
|
-
{
|
|
89
|
-
@include set-var(
|
|
90
|
-
greyscale-background-color,
|
|
88
|
+
@if not $disable-everything {
|
|
89
|
+
@if $light-theme-greyscale-background-color !=
|
|
91
90
|
$dark-theme-greyscale-background-color
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
{
|
|
92
|
+
@include set-var(
|
|
93
|
+
greyscale-background-color,
|
|
94
|
+
$dark-theme-greyscale-background-color
|
|
95
|
+
);
|
|
96
|
+
}
|
|
94
97
|
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
@if $light-theme-greyscale-color != $dark-theme-greyscale-color {
|
|
99
|
+
@include set-var(greyscale-color, $dark-theme-greyscale-color);
|
|
100
|
+
}
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
103
|
|
|
@@ -11,11 +11,11 @@ import { ListItem } from "../list/ListItem.js";
|
|
|
11
11
|
import {
|
|
12
12
|
type ListItemAddonPosition,
|
|
13
13
|
type ListItemAddonType,
|
|
14
|
+
type ListItemChildrenTextProps,
|
|
14
15
|
type ListItemHeight,
|
|
15
16
|
} from "../list/types.js";
|
|
16
17
|
import { type PropsWithRef } from "../types.js";
|
|
17
18
|
import { useEnsuredId } from "../useEnsuredId.js";
|
|
18
|
-
import { bem } from "../utils/bem.js";
|
|
19
19
|
import {
|
|
20
20
|
type IndeterminateCheckboxProps,
|
|
21
21
|
type InputToggleIconProps,
|
|
@@ -23,31 +23,16 @@ import {
|
|
|
23
23
|
import { InputToggleIcon } from "./InputToggleIcon.js";
|
|
24
24
|
import { SwitchTrack } from "./SwitchTrack.js";
|
|
25
25
|
import { type InputToggleSize } from "./inputToggleStyles.js";
|
|
26
|
+
import {
|
|
27
|
+
menuItemInputToggle,
|
|
28
|
+
menuItemInputToggleBall,
|
|
29
|
+
menuItemInputToggleIcon,
|
|
30
|
+
menuItemInputToggleTrack,
|
|
31
|
+
} from "./menuItemInputToggleStyles.js";
|
|
26
32
|
|
|
27
33
|
const noop = (): void => {
|
|
28
34
|
// do nothing
|
|
29
35
|
};
|
|
30
|
-
const styles = bem("rmd-menu-item-input-toggle");
|
|
31
|
-
|
|
32
|
-
/** @remarks \@since 6.0.0 */
|
|
33
|
-
export interface MenuItemInputToggleClassNameOptions {
|
|
34
|
-
className?: string;
|
|
35
|
-
type: "radio" | "checkbox" | "switch";
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @remarks \@since 6.0.0
|
|
40
|
-
*/
|
|
41
|
-
export function menuItemInputToggle(
|
|
42
|
-
options: MenuItemInputToggleClassNameOptions
|
|
43
|
-
): string {
|
|
44
|
-
const { className, type } = options;
|
|
45
|
-
return cnb(
|
|
46
|
-
`rmd-${type}-menu-item`,
|
|
47
|
-
styles({ switch: type === "switch" }),
|
|
48
|
-
className
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
36
|
|
|
52
37
|
/**
|
|
53
38
|
* @remarks \@since 6.0.0
|
|
@@ -60,7 +45,8 @@ export type MenuItemInputToggleCheckedCallback = (
|
|
|
60
45
|
/** @remarks \@since 2.8.0 */
|
|
61
46
|
export interface BaseMenuItemInputToggleProps
|
|
62
47
|
extends HTMLAttributes<HTMLLIElement>,
|
|
63
|
-
InputToggleIconProps
|
|
48
|
+
InputToggleIconProps,
|
|
49
|
+
ListItemChildrenTextProps {
|
|
64
50
|
checked: boolean;
|
|
65
51
|
onCheckedChange: MenuItemInputToggleCheckedCallback;
|
|
66
52
|
|
|
@@ -95,12 +81,6 @@ export interface BaseMenuItemInputToggleProps
|
|
|
95
81
|
/** @defaultValue `"auto"` */
|
|
96
82
|
height?: ListItemHeight;
|
|
97
83
|
|
|
98
|
-
/** @defaultValue `false` */
|
|
99
|
-
multiline?: boolean;
|
|
100
|
-
|
|
101
|
-
/** @defaultValue `false` */
|
|
102
|
-
disableTextChildren?: boolean;
|
|
103
|
-
|
|
104
84
|
/** @defaultValue `false` */
|
|
105
85
|
iconAfter?: boolean;
|
|
106
86
|
|
|
@@ -199,41 +179,43 @@ export const MenuItemInputToggle = forwardRef<
|
|
|
199
179
|
const id = useEnsuredId(propId, "menu-item");
|
|
200
180
|
|
|
201
181
|
let icon = propIcon;
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
182
|
+
if (type === "switch") {
|
|
183
|
+
icon = (
|
|
184
|
+
<SwitchTrack
|
|
185
|
+
style={trackStyle}
|
|
186
|
+
{...trackProps}
|
|
187
|
+
className={cnb(
|
|
188
|
+
menuItemInputToggleTrack(),
|
|
189
|
+
trackClassName,
|
|
190
|
+
trackProps?.className
|
|
191
|
+
)}
|
|
192
|
+
active={checked}
|
|
193
|
+
ballProps={ballProps}
|
|
194
|
+
ballStyle={ballStyle}
|
|
195
|
+
ballClassName={cnb(menuItemInputToggleBall(), ballClassName)}
|
|
196
|
+
/>
|
|
197
|
+
);
|
|
198
|
+
} else {
|
|
199
|
+
icon = (
|
|
200
|
+
<InputToggleIcon
|
|
201
|
+
style={iconStyle}
|
|
202
|
+
disableEm
|
|
203
|
+
{...iconProps}
|
|
204
|
+
className={cnb(
|
|
205
|
+
menuItemInputToggleIcon(),
|
|
206
|
+
iconClassName,
|
|
207
|
+
iconProps?.className
|
|
208
|
+
)}
|
|
209
|
+
size={size}
|
|
210
|
+
type={type}
|
|
211
|
+
checked={checked}
|
|
212
|
+
disabled={disabled}
|
|
213
|
+
icon={propIcon}
|
|
214
|
+
checkedIcon={checkedIcon}
|
|
215
|
+
indeterminate={indeterminate}
|
|
216
|
+
indeterminateIcon={indeterminateIcon}
|
|
217
|
+
/>
|
|
218
|
+
);
|
|
237
219
|
}
|
|
238
220
|
|
|
239
221
|
let leftAddon: ReactNode;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { describe, expect, it, jest } from "@jest/globals";
|
|
2
|
+
import { createRef } from "react";
|
|
3
|
+
import { rmdRender, screen } from "../../test-utils/index.js";
|
|
4
|
+
import { type MenuItemCheckboxProps } from "../MenuItemInputToggle.js";
|
|
5
|
+
import { MenuItemCheckbox } from "../MenuItemCheckbox.js";
|
|
6
|
+
|
|
7
|
+
describe("MenuItemCheckbox", () => {
|
|
8
|
+
it("should apply the correct styling, HTMLAttributes, and allow a ref", () => {
|
|
9
|
+
const ref = createRef<HTMLLIElement>();
|
|
10
|
+
const props = {
|
|
11
|
+
ref,
|
|
12
|
+
checked: false,
|
|
13
|
+
onCheckedChange: jest.fn(),
|
|
14
|
+
children: "Checkbox",
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
const { rerender } = rmdRender(<MenuItemCheckbox {...props} />);
|
|
18
|
+
|
|
19
|
+
const element = screen.getByRole("menuitemcheckbox", { name: "Checkbox" });
|
|
20
|
+
expect(ref.current).toBeInstanceOf(HTMLLIElement);
|
|
21
|
+
expect(ref.current).toBe(element);
|
|
22
|
+
expect(element).toMatchSnapshot();
|
|
23
|
+
|
|
24
|
+
rerender(
|
|
25
|
+
<MenuItemCheckbox
|
|
26
|
+
{...props}
|
|
27
|
+
style={{ color: "white" }}
|
|
28
|
+
className="custom-class-name"
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
expect(element).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should allow for a custom unchecked and checked icon", async () => {
|
|
35
|
+
const props: MenuItemCheckboxProps = {
|
|
36
|
+
icon: null,
|
|
37
|
+
checkedIcon: <span data-testid="checked" />,
|
|
38
|
+
iconAfter: true,
|
|
39
|
+
children: "Checkbox",
|
|
40
|
+
checked: false,
|
|
41
|
+
onCheckedChange: jest.fn(),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const { rerender } = rmdRender(<MenuItemCheckbox {...props} />);
|
|
45
|
+
|
|
46
|
+
const element = screen.getByRole("menuitemcheckbox", { name: "Checkbox" });
|
|
47
|
+
expect(element).toMatchSnapshot();
|
|
48
|
+
expect(element.querySelector(".rmd-icon")).toBeNull();
|
|
49
|
+
|
|
50
|
+
rerender(<MenuItemCheckbox {...props} checked />);
|
|
51
|
+
expect(element).toMatchSnapshot();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { describe, expect, it, jest } from "@jest/globals";
|
|
2
|
+
import { createRef } from "react";
|
|
3
|
+
import { rmdRender, screen } from "../../test-utils/index.js";
|
|
4
|
+
import { type MenuItemRadioProps } from "../MenuItemInputToggle.js";
|
|
5
|
+
import { MenuItemRadio } from "../MenuItemRadio.js";
|
|
6
|
+
|
|
7
|
+
describe("MenuItemRadio", () => {
|
|
8
|
+
it("should apply the correct styling, HTMLAttributes, and allow a ref", () => {
|
|
9
|
+
const ref = createRef<HTMLLIElement>();
|
|
10
|
+
const props = {
|
|
11
|
+
ref,
|
|
12
|
+
checked: false,
|
|
13
|
+
onCheckedChange: jest.fn(),
|
|
14
|
+
children: "Radio",
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
const { rerender } = rmdRender(<MenuItemRadio {...props} />);
|
|
18
|
+
|
|
19
|
+
const element = screen.getByRole("menuitemradio", { name: "Radio" });
|
|
20
|
+
expect(ref.current).toBeInstanceOf(HTMLLIElement);
|
|
21
|
+
expect(ref.current).toBe(element);
|
|
22
|
+
expect(element).toMatchSnapshot();
|
|
23
|
+
|
|
24
|
+
rerender(
|
|
25
|
+
<MenuItemRadio
|
|
26
|
+
{...props}
|
|
27
|
+
style={{ color: "white" }}
|
|
28
|
+
className="custom-class-name"
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
expect(element).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should allow for a custom unchecked and checked icon", async () => {
|
|
35
|
+
const props: MenuItemRadioProps = {
|
|
36
|
+
icon: null,
|
|
37
|
+
checkedIcon: <span data-testid="checked" />,
|
|
38
|
+
iconAfter: true,
|
|
39
|
+
children: "Radio",
|
|
40
|
+
checked: false,
|
|
41
|
+
onCheckedChange: jest.fn(),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const { rerender } = rmdRender(<MenuItemRadio {...props} />);
|
|
45
|
+
|
|
46
|
+
const element = screen.getByRole("menuitemradio", { name: "Radio" });
|
|
47
|
+
expect(element).toMatchSnapshot();
|
|
48
|
+
expect(element.querySelector(".rmd-icon")).toBeNull();
|
|
49
|
+
|
|
50
|
+
rerender(<MenuItemRadio {...props} checked />);
|
|
51
|
+
expect(element).toMatchSnapshot();
|
|
52
|
+
});
|
|
53
|
+
});
|