@shortfuse/materialdesignweb 0.0.9 → 0.4.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.
- package/.browserslistrc +3 -0
- package/.eslintrc.json +146 -27
- package/.stylelintrc.json +598 -2
- package/.vscode/launch.json +20 -5
- package/.vscode/settings.json +3 -0
- package/.vscode/tasks.json +19 -10
- package/CHANGELOG.md +24 -0
- package/README.md +84 -2
- package/adapters/datatable/column.js +203 -0
- package/adapters/datatable/index.js +972 -0
- package/adapters/dom/index.js +601 -0
- package/adapters/list/index.js +69 -0
- package/adapters/search/index.js +521 -0
- package/components/appbar/_spec.scss +225 -0
- package/components/appbar/_theme.scss +0 -0
- package/components/appbar/index.scss +2 -0
- package/components/banner/_spec.scss +118 -0
- package/components/banner/_theme.scss +0 -0
- package/components/banner/index.scss +2 -0
- package/components/bottomnav/README.md +85 -0
- package/components/bottomnav/_spec.scss +157 -0
- package/components/bottomnav/_theme.scss +0 -0
- package/components/bottomnav/index.js +122 -0
- package/components/bottomnav/index.scss +2 -0
- package/components/bottomnav/item.js +89 -0
- package/components/{core/button → button}/README.md +16 -22
- package/components/button/_spec.scss +161 -0
- package/components/button/_theme.scss +65 -0
- package/components/button/index.eta +32 -0
- package/components/button/index.js +43 -0
- package/components/button/index.pug +18 -0
- package/components/button/index.scss +2 -0
- package/components/card/_spec.scss +249 -0
- package/components/card/_theme.scss +0 -0
- package/components/card/index.scss +2 -0
- package/components/chip/_spec.scss +134 -0
- package/components/chip/_theme.scss +177 -0
- package/components/chip/index.js +21 -0
- package/components/chip/index.scss +2 -0
- package/components/chip/item.js +20 -0
- package/components/datatable/_spec.scss +288 -0
- package/components/datatable/_theme.scss +154 -0
- package/components/datatable/cell.js +45 -0
- package/components/datatable/columnheader.js +47 -0
- package/components/datatable/index.js +388 -0
- package/components/datatable/index.scss +2 -0
- package/components/datatable/row.js +49 -0
- package/components/datatable/rowheader.js +18 -0
- package/components/dialog/_spec.scss +213 -0
- package/components/dialog/_theme.scss +0 -0
- package/components/dialog/index.js +627 -0
- package/components/dialog/index.scss +2 -0
- package/components/divider/_spec.scss +13 -0
- package/components/divider/_theme.scss +0 -0
- package/components/divider/index.scss +2 -0
- package/components/elevation/_spec.scss +9 -0
- package/components/elevation/_theme.scss +0 -0
- package/components/elevation/index.scss +2 -0
- package/components/fab/_spec.scss +222 -0
- package/components/fab/_theme.scss +0 -0
- package/components/fab/index.js +103 -0
- package/components/fab/index.scss +2 -0
- package/components/grid/_spec.scss +312 -0
- package/components/grid/_theme.scss +0 -0
- package/components/grid/index.scss +2 -0
- package/components/layout/_mixins.scss +33 -0
- package/components/layout/_spec.scss +1012 -0
- package/components/layout/_theme.scss +44 -0
- package/components/layout/index.js +464 -0
- package/components/layout/index.scss +2 -0
- package/components/list/_spec.scss +397 -0
- package/components/list/_theme.scss +111 -0
- package/components/list/content.js +110 -0
- package/components/list/index.js +260 -0
- package/components/list/index.scss +2 -0
- package/components/list/item.js +170 -0
- package/components/list/secondary.js +46 -0
- package/components/menu/_spec.scss +362 -0
- package/components/menu/_theme.scss +0 -0
- package/components/menu/index.js +721 -0
- package/components/menu/index.scss +2 -0
- package/components/menu/item.js +239 -0
- package/components/{core/progress/style.scss → progress/_spec.scss} +36 -25
- package/components/progress/_theme.scss +0 -0
- package/components/progress/index.js +36 -0
- package/components/progress/index.scss +2 -0
- package/components/selection/_spec.scss +386 -0
- package/components/selection/_theme.scss +166 -0
- package/components/selection/index.eta +60 -0
- package/components/selection/index.js +76 -0
- package/components/selection/index.pug +30 -0
- package/components/selection/index.scss +2 -0
- package/components/selection/input.js +56 -0
- package/components/selection/radiogroup.js +47 -0
- package/components/slider/_spec.scss +64 -0
- package/components/slider/_theme.scss +0 -0
- package/components/slider/index.scss +2 -0
- package/components/snackbar/_spec.scss +195 -0
- package/components/snackbar/_theme.scss +0 -0
- package/components/snackbar/index.js +344 -0
- package/components/snackbar/index.scss +2 -0
- package/components/tab/_spec.scss +235 -0
- package/components/tab/_theme.scss +0 -0
- package/components/tab/content.js +205 -0
- package/components/tab/index.js +260 -0
- package/components/tab/index.scss +2 -0
- package/components/tab/item.js +89 -0
- package/components/tab/list.js +210 -0
- package/components/tab/panel.js +54 -0
- package/components/template/_theme.scss +27 -0
- package/components/{core/textfield → textfield}/README.md +70 -50
- package/components/textfield/_mixins.scss +52 -0
- package/components/textfield/_spec.scss +809 -0
- package/components/textfield/_theme.scss +299 -0
- package/components/textfield/index.eta +74 -0
- package/components/textfield/index.js +168 -0
- package/components/textfield/index.pug +30 -0
- package/components/textfield/index.scss +2 -0
- package/components/tooltip/_spec.scss +188 -0
- package/components/tooltip/_theme.scss +0 -0
- package/components/tooltip/index.scss +2 -0
- package/components/type/_spec.scss +224 -0
- package/components/type/_theme.scss +0 -0
- package/components/type/index.scss +2 -0
- package/core/_breakpoint.scss +189 -0
- package/core/_elevation.scss +38 -0
- package/core/_length.scss +9 -0
- package/core/_motion.scss +31 -0
- package/core/_platform.scss +34 -0
- package/core/_type.scss +127 -0
- package/core/aria/attributes.js +141 -0
- package/core/aria/button.js +50 -0
- package/core/aria/keyboard.js +93 -0
- package/core/aria/rovingtabindex.js +178 -0
- package/core/aria/tab.js +60 -0
- package/core/color/_spec.scss +0 -0
- package/core/color/_theme.scss +390 -0
- package/core/color/index.scss +2 -0
- package/core/document/index.js +39 -0
- package/core/dom.js +271 -0
- package/core/overlay/_spec.scss +31 -0
- package/core/overlay/_theme.scss +171 -0
- package/core/overlay/index.js +108 -0
- package/core/overlay/index.scss +2 -0
- package/core/ripple/_spec.scss +197 -0
- package/core/ripple/_theme.scss +40 -0
- package/core/ripple/index.js +294 -0
- package/core/ripple/index.scss +2 -0
- package/core/theme/_config.scss +2 -0
- package/core/theme/_mixins.scss +172 -0
- package/{components/theming/palettes.scss → core/theme/_palettes.scss} +173 -150
- package/core/theme/_variables.scss +24 -0
- package/core/theme/index.js +50 -0
- package/core/throttler.js +42 -0
- package/core/transition/index.js +468 -0
- package/docs/_flex.scss +22 -0
- package/docs/_menuoptions.js +183 -0
- package/docs/_mixins.pug +155 -0
- package/docs/_partials/_androidnavbar.eta +5 -0
- package/docs/_partials/_androidstatusbar.eta +13 -0
- package/docs/_partials/_appbar.eta +29 -0
- package/docs/_partials/_buttontest.eta +31 -0
- package/docs/_partials/_header.eta +149 -0
- package/docs/_partials/_navlistitem.eta +16 -0
- package/docs/_partials/_target.eta +1 -0
- package/docs/_sample-utils.js +93 -0
- package/docs/_storage.js +33 -0
- package/docs/docs.scss +295 -0
- package/docs/index.eta +16 -0
- package/docs/index.js +0 -0
- package/docs/pages/appbar.eta +114 -0
- package/docs/pages/appbar.js +0 -0
- package/docs/pages/appbar.pug +78 -0
- package/docs/pages/bottomnav.eta +188 -0
- package/docs/pages/bottomnav.js +115 -0
- package/docs/pages/bottomnav.pug +137 -0
- package/docs/pages/button.eta +124 -0
- package/docs/pages/button.js +224 -0
- package/docs/pages/button.pug +121 -0
- package/docs/pages/card.eta +90 -0
- package/docs/pages/card.js +177 -0
- package/docs/pages/card.pug +74 -0
- package/docs/pages/chip.eta +122 -0
- package/docs/pages/chip.js +82 -0
- package/docs/pages/chip.pug +91 -0
- package/docs/pages/color.eta +143 -0
- package/docs/pages/color.js +262 -0
- package/docs/pages/color.pug +121 -0
- package/docs/pages/datatable.eta +323 -0
- package/docs/pages/datatable.js +164 -0
- package/docs/pages/datatable.pug +283 -0
- package/docs/pages/dialog.eta +186 -0
- package/docs/pages/dialog.js +177 -0
- package/docs/pages/dialog.pug +132 -0
- package/docs/pages/dom.eta +26 -0
- package/docs/pages/dom.js +143 -0
- package/docs/pages/dom.pug +22 -0
- package/docs/pages/elevation.eta +35 -0
- package/docs/pages/elevation.js +0 -0
- package/docs/pages/elevation.pug +25 -0
- package/docs/pages/fab.eta +99 -0
- package/docs/pages/fab.js +44 -0
- package/docs/pages/fab.pug +66 -0
- package/docs/pages/grid.eta +135 -0
- package/docs/pages/grid.js +128 -0
- package/docs/pages/grid.pug +95 -0
- package/docs/pages/layout.eta +8 -0
- package/docs/pages/layout.js +0 -0
- package/docs/pages/layout.pug +7 -0
- package/docs/pages/list.eta +465 -0
- package/docs/pages/list.js +9 -0
- package/docs/pages/list.pug +326 -0
- package/docs/pages/menu.eta +276 -0
- package/docs/pages/menu.js +217 -0
- package/docs/pages/menu.pug +205 -0
- package/docs/pages/overlay.eta +69 -0
- package/docs/pages/overlay.js +4 -0
- package/docs/pages/overlay.pug +55 -0
- package/docs/pages/progress.eta +23 -0
- package/docs/pages/progress.js +12 -0
- package/docs/pages/progress.pug +16 -0
- package/docs/pages/ripple.eta +27 -0
- package/docs/pages/ripple.js +4 -0
- package/docs/pages/ripple.pug +21 -0
- package/docs/pages/search.eta +246 -0
- package/docs/pages/search.js +243 -0
- package/docs/pages/search.pug +165 -0
- package/docs/pages/selection.eta +111 -0
- package/docs/pages/selection.js +13 -0
- package/docs/pages/selection.pug +74 -0
- package/docs/pages/slider.eta +23 -0
- package/docs/pages/slider.js +0 -0
- package/docs/pages/slider.pug +17 -0
- package/docs/pages/snackbar.eta +83 -0
- package/docs/pages/snackbar.js +158 -0
- package/docs/pages/snackbar.pug +60 -0
- package/docs/pages/tab.eta +421 -0
- package/docs/pages/tab.js +151 -0
- package/docs/pages/tab.pug +304 -0
- package/docs/pages/textfield.eta +486 -0
- package/docs/pages/textfield.js +254 -0
- package/docs/pages/textfield.pug +360 -0
- package/docs/pages/tooltip.eta +94 -0
- package/docs/pages/tooltip.js +0 -0
- package/docs/pages/tooltip.pug +78 -0
- package/docs/pages/transition.eta +117 -0
- package/docs/pages/transition.js +54 -0
- package/docs/pages/transition.pug +76 -0
- package/docs/pages/type.eta +31 -0
- package/docs/pages/type.js +0 -0
- package/docs/pages/type.pug +29 -0
- package/docs/postrender.js +39 -0
- package/docs/prerender.js +16 -0
- package/docs/pwa/_dialogs.eta +143 -0
- package/docs/pwa/_dialogs.pug +96 -0
- package/docs/pwa/_menus.eta +16 -0
- package/docs/pwa/_menus.pug +11 -0
- package/docs/pwa/pwa-prerender.js +3 -0
- package/docs/pwa/pwa.eta +480 -0
- package/docs/pwa/pwa.js +306 -0
- package/docs/pwa/pwa.pug +325 -0
- package/docs/pwa/pwa.scss +26 -0
- package/docs/spec.scss +26 -0
- package/docs/themes/_component-themes.scss +26 -0
- package/docs/themes/theme-colored-fallbacks.scss +17 -0
- package/docs/themes/theme-colored.scss +17 -0
- package/docs/themes/theme-default-fallbacks.scss +17 -0
- package/docs/themes/theme-default.scss +17 -0
- package/jsconfig.json +4 -2
- package/package.json +43 -28
- package/scripts/deploy-docs.sh +9 -0
- package/templates/index.eta +2 -0
- package/templates/index.pug +3 -0
- package/utils/function.js +3 -0
- package/webpack.config.cjs +257 -0
- package/components/_index.scss +0 -4
- package/components/all-components.scss +0 -14
- package/components/common/functions.scss +0 -173
- package/components/common/mixins.scss +0 -107
- package/components/common/motion.scss +0 -36
- package/components/common/ripple.scss +0 -92
- package/components/common/variables.scss +0 -48
- package/components/complex/dialog/style.scss +0 -159
- package/components/complex/dialog/theming.scss +0 -29
- package/components/complex/navdrawer/style.scss +0 -477
- package/components/complex/navdrawer/theming.scss +0 -58
- package/components/complex/search/index.js +0 -492
- package/components/core/bottomnav/README.md +0 -85
- package/components/core/bottomnav/index.js +0 -140
- package/components/core/bottomnav/style.scss +0 -173
- package/components/core/bottomnav/theming.scss +0 -42
- package/components/core/button/index.js +0 -52
- package/components/core/button/style.scss +0 -283
- package/components/core/button/theming.scss +0 -131
- package/components/core/list/index.js +0 -94
- package/components/core/list/style.scss +0 -269
- package/components/core/list/theming.scss +0 -74
- package/components/core/menu/index.js +0 -127
- package/components/core/menu/style.scss +0 -239
- package/components/core/menu/theming.scss +0 -55
- package/components/core/progress/index.js +0 -33
- package/components/core/selection/style.scss +0 -249
- package/components/core/selection/theming.scss +0 -49
- package/components/core/switch/style.scss +0 -3
- package/components/core/tab/index.js +0 -174
- package/components/core/tab/style.scss +0 -202
- package/components/core/tab/theming.scss +0 -43
- package/components/core/textfield/index.js +0 -169
- package/components/core/textfield/style.scss +0 -672
- package/components/core/textfield/theming.scss +0 -262
- package/components/core/toolbar/style.scss +0 -109
- package/components/core/toolbar/theming.scss +0 -28
- package/components/core/tooltip/style.scss +0 -127
- package/components/core/type/style.scss +0 -133
- package/components/core/type/theming.scss +0 -25
- package/components/index.js +0 -24
- package/components/template/theming.scss +0 -31
- package/components/theming/theming.scss +0 -504
- package/docs/bottomnav.html +0 -171
- package/docs/bottomnav.min.js +0 -383
- package/docs/button.html +0 -322
- package/docs/button.min.js +0 -251
- package/docs/components.min.css +0 -1
- package/docs/components.min.js +0 -83
- package/docs/dialog.html +0 -103
- package/docs/dialog.min.js +0 -160
- package/docs/docs.min.css +0 -1
- package/docs/docs.min.js +0 -83
- package/docs/index.html +0 -55
- package/docs/index.min.js +0 -83
- package/docs/list.html +0 -442
- package/docs/list.min.js +0 -312
- package/docs/menu.html +0 -185
- package/docs/menu.min.js +0 -370
- package/docs/navdrawer.html +0 -199
- package/docs/navdrawer.min.js +0 -244
- package/docs/progress.html +0 -75
- package/docs/progress.min.js +0 -162
- package/docs/search.html +0 -230
- package/docs/search.min.js +0 -1202
- package/docs/selection.html +0 -188
- package/docs/selection.min.js +0 -160
- package/docs/src/complex/dialog.js +0 -3
- package/docs/src/complex/dialog.pug +0 -44
- package/docs/src/complex/navdrawer.js +0 -82
- package/docs/src/complex/navdrawer.pug +0 -109
- package/docs/src/complex/search.js +0 -207
- package/docs/src/complex/search.pug +0 -143
- package/docs/src/components.scss +0 -1
- package/docs/src/core/bottomnav.js +0 -22
- package/docs/src/core/bottomnav.pug +0 -93
- package/docs/src/core/button.js +0 -16
- package/docs/src/core/button.pug +0 -73
- package/docs/src/core/list.js +0 -21
- package/docs/src/core/list.pug +0 -246
- package/docs/src/core/menu.js +0 -33
- package/docs/src/core/menu.pug +0 -108
- package/docs/src/core/progress.js +0 -11
- package/docs/src/core/progress.pug +0 -17
- package/docs/src/core/selection.js +0 -4
- package/docs/src/core/selection.pug +0 -92
- package/docs/src/core/tab.js +0 -21
- package/docs/src/core/tab.pug +0 -180
- package/docs/src/core/textfield.js +0 -15
- package/docs/src/core/textfield.pug +0 -274
- package/docs/src/core/toolbar.js +0 -4
- package/docs/src/core/toolbar.pug +0 -79
- package/docs/src/core/tooltip.js +0 -4
- package/docs/src/core/tooltip.pug +0 -76
- package/docs/src/core/type.js +0 -4
- package/docs/src/core/type.pug +0 -36
- package/docs/src/docs.scss +0 -200
- package/docs/src/index.pug +0 -5
- package/docs/src/mixins.pug +0 -72
- package/docs/src/targetHandler.js +0 -50
- package/docs/src/theming.ie11.scss +0 -35
- package/docs/src/theming.scss +0 -36
- package/docs/tab.html +0 -301
- package/docs/tab.min.js +0 -397
- package/docs/textfield.html +0 -476
- package/docs/textfield.min.js +0 -381
- package/docs/theming.ie11.min.css +0 -1
- package/docs/theming.ie11.min.js +0 -83
- package/docs/theming.min.css +0 -1
- package/docs/theming.min.js +0 -83
- package/docs/toolbar.html +0 -213
- package/docs/toolbar.min.js +0 -160
- package/docs/tooltip.html +0 -138
- package/docs/tooltip.min.js +0 -160
- package/docs/type.html +0 -94
- package/docs/type.min.js +0 -160
- package/webpack.config.js +0 -176
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
// https://material.io/guidelines/components/selection-controls.html#
|
|
2
|
+
// https://material.io/guidelines/patterns/selection.html#selection-item-selection
|
|
3
|
+
|
|
4
|
+
@use "sass:math";
|
|
5
|
+
|
|
6
|
+
@use '../../core/_elevation.scss' as elevation;
|
|
7
|
+
@use '../../core/_length.scss' as *;
|
|
8
|
+
@use '../../core/_motion.scss' as motion;
|
|
9
|
+
|
|
10
|
+
$ripple-size: dp(40) !default;
|
|
11
|
+
$icon-size: dp(24) !default;
|
|
12
|
+
$scale-size: math.div($ripple-size, $icon-size) !default;
|
|
13
|
+
$radio-size: dp(20) !default;
|
|
14
|
+
$checkbox-size: dp(18) !default;
|
|
15
|
+
$border-size: dp(2) !default;
|
|
16
|
+
$horizontal-margin: dp(2) !default;
|
|
17
|
+
// from ic_check_black_18px.svg
|
|
18
|
+
// rotated 45°
|
|
19
|
+
$checkbox-icon-height: dp(12.73) !default;
|
|
20
|
+
$checkbox-icon-width: dp(5.93) !default;
|
|
21
|
+
$checkbox-icon-thickness: dp(1.5) !default;
|
|
22
|
+
$checkbox-icon-offset-y: dp(2.64) - $checkbox-icon-thickness - $border-size !default;
|
|
23
|
+
$checkbox-icon-offset-x: dp(6.04) - $border-size !default;
|
|
24
|
+
|
|
25
|
+
.mdw-selection {
|
|
26
|
+
display: inline-flex;
|
|
27
|
+
position: relative;
|
|
28
|
+
flex-direction: row;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.mdw-selection__input {
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
align-self: center;
|
|
34
|
+
order: 1;
|
|
35
|
+
|
|
36
|
+
min-height: $icon-size;
|
|
37
|
+
min-width: $icon-size;
|
|
38
|
+
margin: 0 auto;
|
|
39
|
+
padding: 0;
|
|
40
|
+
|
|
41
|
+
-moz-appearance: none;
|
|
42
|
+
-webkit-appearance: none;
|
|
43
|
+
appearance: none;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
outline: none;
|
|
46
|
+
-webkit-tap-highlight-color: transparent;
|
|
47
|
+
|
|
48
|
+
transition-property: transform, color, opacity;
|
|
49
|
+
|
|
50
|
+
opacity: 0;
|
|
51
|
+
transform: scale($scale-size);
|
|
52
|
+
|
|
53
|
+
background-color: currentColor;
|
|
54
|
+
// background-color: var(--button__ripple-color);
|
|
55
|
+
border-radius: 50%;
|
|
56
|
+
|
|
57
|
+
color: inherit;
|
|
58
|
+
|
|
59
|
+
&::-ms-check {
|
|
60
|
+
background-color: transparent;
|
|
61
|
+
border-color: transparent;
|
|
62
|
+
// IE11
|
|
63
|
+
border-radius: 50%;
|
|
64
|
+
color: transparent;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.mdw-selection[aria-disabled="true"] &,
|
|
68
|
+
&:disabled {
|
|
69
|
+
cursor: not-allowed;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// HTMLInputElement should not have psuedos
|
|
73
|
+
&.mdw-overlay::before {
|
|
74
|
+
display: none;
|
|
75
|
+
content: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&[role="switch"] {
|
|
79
|
+
margin-right: dp(12);
|
|
80
|
+
|
|
81
|
+
transform: translateX(#{dp(-2)}) scale($scale-size);
|
|
82
|
+
|
|
83
|
+
&:checked {
|
|
84
|
+
transform: translateX(#{dp(14)}) scale($scale-size);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
label.mdw-selection:active &:not(:disabled),
|
|
88
|
+
label.mdw-selection:hover &:not(:disabled),
|
|
89
|
+
&:active:not(:disabled),
|
|
90
|
+
&:hover:not(:disabled),
|
|
91
|
+
&:focus {
|
|
92
|
+
transform: translateX(#{dp(-2)}) scale($scale-size);
|
|
93
|
+
|
|
94
|
+
&:checked {
|
|
95
|
+
transform: translateX(#{dp(14)}) scale($scale-size);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.mdw-selection__icon {
|
|
102
|
+
display: inline-flex;
|
|
103
|
+
position: relative;
|
|
104
|
+
|
|
105
|
+
box-sizing: border-box;
|
|
106
|
+
height: $icon-size;
|
|
107
|
+
width: $icon-size;
|
|
108
|
+
flex: none;
|
|
109
|
+
margin: 0;
|
|
110
|
+
margin-top: auto;
|
|
111
|
+
margin-bottom: auto;
|
|
112
|
+
padding: 0;
|
|
113
|
+
|
|
114
|
+
-moz-appearance: none;
|
|
115
|
+
-webkit-appearance: none;
|
|
116
|
+
appearance: none;
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
outline: none;
|
|
119
|
+
-webkit-tap-highlight-color: transparent;
|
|
120
|
+
|
|
121
|
+
transition-property: background-color, border-color;
|
|
122
|
+
|
|
123
|
+
pointer-events: none;
|
|
124
|
+
|
|
125
|
+
z-index: 1;
|
|
126
|
+
|
|
127
|
+
background-color: transparent;
|
|
128
|
+
|
|
129
|
+
:root[dir="rtl"] & {
|
|
130
|
+
order: 1;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.mdw-selection__input ~ & {
|
|
134
|
+
// width is represented by input element
|
|
135
|
+
max-width: 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
&::before {
|
|
140
|
+
content: "";
|
|
141
|
+
|
|
142
|
+
position: absolute;
|
|
143
|
+
top: 0;
|
|
144
|
+
left: 0;
|
|
145
|
+
|
|
146
|
+
box-sizing: border-box;
|
|
147
|
+
border-style: solid;
|
|
148
|
+
border-width: dp(2);
|
|
149
|
+
|
|
150
|
+
transition-property: border-width, border-color, background-color, color;
|
|
151
|
+
|
|
152
|
+
background-color: transparent;
|
|
153
|
+
border-color: currentColor;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&::after {
|
|
157
|
+
content: "";
|
|
158
|
+
|
|
159
|
+
position: absolute;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.mdw-selection[aria-disabled="true"] &,
|
|
163
|
+
.mdw-selection__input:disabled ~ & {
|
|
164
|
+
cursor: not-allowed;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&[mdw-checkbox] {
|
|
168
|
+
// Box outline
|
|
169
|
+
&::before {
|
|
170
|
+
top: ($icon-size - $checkbox-size) * 0.5;
|
|
171
|
+
left: ($icon-size - $checkbox-size) * 0.5;
|
|
172
|
+
|
|
173
|
+
height: $checkbox-size;
|
|
174
|
+
width: $checkbox-size;
|
|
175
|
+
|
|
176
|
+
border-radius: dp(2);
|
|
177
|
+
|
|
178
|
+
// Checked or Active
|
|
179
|
+
.mdw-selection[aria-checked="true"] &,
|
|
180
|
+
.mdw-selection[aria-checked]:not([aria-disabled="true"]):active &,
|
|
181
|
+
.mdw-selection__input[type="checkbox"]:checked ~ &,
|
|
182
|
+
.mdw-selection__input[type="checkbox"]:not(:disabled):active ~ & {
|
|
183
|
+
border-width: $checkbox-size * 0.5;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Checked not
|
|
187
|
+
.mdw-selection[aria-checked="true"]:not(:active):not([aria-disabled="true"]) &,
|
|
188
|
+
.mdw-selection__input[type="checkbox"]:checked:not(:active):not(:disabled) ~ & {
|
|
189
|
+
background-color: currentColor;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Check stencil
|
|
194
|
+
&::after {
|
|
195
|
+
top: $border-size + (($icon-size - $checkbox-size) * 0.5);
|
|
196
|
+
left: $border-size + (($icon-size - $checkbox-size) * 0.5);
|
|
197
|
+
|
|
198
|
+
height: $checkbox-icon-height;
|
|
199
|
+
width: $checkbox-icon-width;
|
|
200
|
+
margin-top: $checkbox-icon-offset-y;
|
|
201
|
+
margin-left: $checkbox-icon-offset-x;
|
|
202
|
+
|
|
203
|
+
.mdw-selection[aria-checked="true"] &,
|
|
204
|
+
.mdw-selection__input[type="checkbox"]:checked ~ & {
|
|
205
|
+
box-sizing: border-box;
|
|
206
|
+
border-right-style: solid;
|
|
207
|
+
border-bottom-style: solid;
|
|
208
|
+
// border-width: $checkbox-icon-thickness;
|
|
209
|
+
// Increase visibility
|
|
210
|
+
border-width: dp(2);
|
|
211
|
+
|
|
212
|
+
animation-name: showCheck;
|
|
213
|
+
animation-direction: normal;
|
|
214
|
+
animation-fill-mode: forwards;
|
|
215
|
+
|
|
216
|
+
transition: none;
|
|
217
|
+
|
|
218
|
+
transform: rotate(45deg);
|
|
219
|
+
|
|
220
|
+
background-color: transparent;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
&[mdw-radio] {
|
|
226
|
+
// Outer ring
|
|
227
|
+
&::before {
|
|
228
|
+
top: ($icon-size - $radio-size) * 0.5;
|
|
229
|
+
left: ($icon-size - $radio-size) * 0.5;
|
|
230
|
+
|
|
231
|
+
height: $radio-size;
|
|
232
|
+
width: $radio-size;
|
|
233
|
+
|
|
234
|
+
border-color: currentColor;
|
|
235
|
+
border-radius: 50%;
|
|
236
|
+
|
|
237
|
+
// Active, not disabled
|
|
238
|
+
.mdw-selection:active:not([aria-disabled="true"]) &,
|
|
239
|
+
.mdw-selection__input:active:not(:disabled) ~ & {
|
|
240
|
+
border-width: $radio-size * 0.5;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Center dot
|
|
245
|
+
&::after {
|
|
246
|
+
top: ($icon-size - $radio-size) * 0.5;
|
|
247
|
+
left: ($icon-size - $radio-size) * 0.5;
|
|
248
|
+
|
|
249
|
+
height: $radio-size;
|
|
250
|
+
width: $radio-size;
|
|
251
|
+
|
|
252
|
+
transition-property: transform, background-color;
|
|
253
|
+
|
|
254
|
+
transform: scale(0);
|
|
255
|
+
|
|
256
|
+
background-color: currentColor;
|
|
257
|
+
border-radius: 50%;
|
|
258
|
+
|
|
259
|
+
.mdw-selection[aria-checked="true"] &,
|
|
260
|
+
.mdw-selection__input:checked ~ & {
|
|
261
|
+
transform: scale(0.5);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
&[mdw-switch] {
|
|
267
|
+
width: dp(36);
|
|
268
|
+
|
|
269
|
+
&::before {
|
|
270
|
+
top: dp(2);
|
|
271
|
+
left: 0;
|
|
272
|
+
|
|
273
|
+
height: dp(20);
|
|
274
|
+
width: dp(20);
|
|
275
|
+
border-style: none;
|
|
276
|
+
|
|
277
|
+
transition-property: background-color, transform;
|
|
278
|
+
|
|
279
|
+
transform: translateX(0);
|
|
280
|
+
z-index: 1;
|
|
281
|
+
|
|
282
|
+
background-color: currentColor;
|
|
283
|
+
|
|
284
|
+
border-radius: 50%;
|
|
285
|
+
box-shadow: elevation.boxShadow(1);
|
|
286
|
+
|
|
287
|
+
.mdw-selection[aria-checked="true"] &,
|
|
288
|
+
.mdw-selection__input:checked ~ & {
|
|
289
|
+
transform: translateX(#{dp(16)});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
&::after {
|
|
294
|
+
top: dp(5);
|
|
295
|
+
bottom: dp(5);
|
|
296
|
+
left: 0;
|
|
297
|
+
|
|
298
|
+
height: dp(14);
|
|
299
|
+
width: dp(36);
|
|
300
|
+
margin: 0;
|
|
301
|
+
border-style: none;
|
|
302
|
+
|
|
303
|
+
animation-name: none;
|
|
304
|
+
|
|
305
|
+
transform: none;
|
|
306
|
+
|
|
307
|
+
background-color: currentColor;
|
|
308
|
+
|
|
309
|
+
border-radius: dp(7);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.mdw-selection:active:not([aria-disabled="true"]) &,
|
|
313
|
+
.mdw-selection__input:active:not(:disabled) ~ & {
|
|
314
|
+
// color: inherit;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.mdw-selection__label {
|
|
320
|
+
order: -1;
|
|
321
|
+
|
|
322
|
+
padding-right: dp(8);
|
|
323
|
+
padding-left: 0;
|
|
324
|
+
|
|
325
|
+
cursor: pointer;
|
|
326
|
+
-webkit-tap-highlight-color: transparent;
|
|
327
|
+
-moz-user-select: none;
|
|
328
|
+
-ms-user-select: none;
|
|
329
|
+
-webkit-user-select: none;
|
|
330
|
+
user-select: none;
|
|
331
|
+
|
|
332
|
+
z-index: 1;
|
|
333
|
+
|
|
334
|
+
:root[dir="rtl"] & {
|
|
335
|
+
padding-right: 0;
|
|
336
|
+
padding-left: dp(8);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Label as suffix
|
|
340
|
+
.mdw-selection__icon ~ & {
|
|
341
|
+
order: 1;
|
|
342
|
+
|
|
343
|
+
padding-right: 0;
|
|
344
|
+
padding-left: dp(8);
|
|
345
|
+
|
|
346
|
+
:root[dir="rtl"] & {
|
|
347
|
+
padding-right: dp(8);
|
|
348
|
+
padding-left: 0;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.mdw-selection[aria-disabled="true"] &,
|
|
353
|
+
.mdw-selection__input:disabled ~ & {
|
|
354
|
+
cursor: not-allowed;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.mdw-selection__input,
|
|
359
|
+
.mdw-selection__icon,
|
|
360
|
+
.mdw-selection__icon::before,
|
|
361
|
+
.mdw-selection__icon::after {
|
|
362
|
+
animation-duration: motion.$simpleDuration;
|
|
363
|
+
animation-timing-function: motion.$standardEasing;
|
|
364
|
+
animation-delay: 0s;
|
|
365
|
+
|
|
366
|
+
transition-delay: 0s;
|
|
367
|
+
transition-duration: motion.$simpleDuration;
|
|
368
|
+
transition-timing-function: motion.$standardEasing;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
@keyframes showCheck {
|
|
372
|
+
// Animation is applied to pre-rotated box;
|
|
373
|
+
// Clip box completely horizontally and vertically upto bottom border
|
|
374
|
+
0% {
|
|
375
|
+
clip: rect($checkbox-icon-height - $checkbox-icon-thickness, 0, auto, auto);
|
|
376
|
+
}
|
|
377
|
+
// Remove horizontal clip
|
|
378
|
+
// % = stroke length upto corner
|
|
379
|
+
#{math.div($checkbox-icon-width, $checkbox-icon-width + $checkbox-icon-height) * 100%} {
|
|
380
|
+
clip: rect($checkbox-icon-height - $checkbox-icon-thickness, $checkbox-icon-width, auto, auto);
|
|
381
|
+
}
|
|
382
|
+
// Remove vertical clip
|
|
383
|
+
100% {
|
|
384
|
+
clip: rect(0, $checkbox-icon-width, auto, auto);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// https://material.io/archive/guidelines/components/selection-controls.html#selection-controls-switch
|
|
2
|
+
|
|
3
|
+
@use '../../core/_platform.scss' as platform;
|
|
4
|
+
@use '../../core/theme/_mixins.scss' as theme;
|
|
5
|
+
|
|
6
|
+
$themeValues: (
|
|
7
|
+
icon-color: theme.$foreground,
|
|
8
|
+
icon-opacity: theme.$medium-opacity,
|
|
9
|
+
|
|
10
|
+
fallback-check-color: (('background', '50', 1.00), ('background','900',1.0)),
|
|
11
|
+
ripple-color: (('foreground-light', 1.00), ('foreground-dark', 1.00)),
|
|
12
|
+
|
|
13
|
+
track-on-opacity: (0.50, 0.50),
|
|
14
|
+
track-off-color: (('foreground-light', 1.00), ('foreground-dark', 1.00)),
|
|
15
|
+
track-off-opacity: (0.38, 0.30),
|
|
16
|
+
|
|
17
|
+
thumb-off-color: (('background', '50', 1.00), ('background','400',1.0)),
|
|
18
|
+
thumb-disabled-color: (('background', '400', 1.00), ('background','800',1.00)),
|
|
19
|
+
|
|
20
|
+
disabled-opacity: (0.38, 0.50),
|
|
21
|
+
|
|
22
|
+
hover-opacity: (0.04, 0.08),
|
|
23
|
+
focus-opacity: (0.12, 0.24),
|
|
24
|
+
selected-opacity: (0.08, 0.16),
|
|
25
|
+
|
|
26
|
+
hover-focus-opacity: (0.04 + 0.12, 0.08 + 0.24),
|
|
27
|
+
|
|
28
|
+
selected-hover-opacity: (0.08 + 0.04, 0.16 + 0.08),
|
|
29
|
+
selected-focus-opacity: (0.08 + 0.12, 0.16 + 0.24),
|
|
30
|
+
selected-hover-focus-opacity: (0.08 + 0.04 + 0.12, 0.16 + 0.08 + 0.24),
|
|
31
|
+
|
|
32
|
+
) !default;
|
|
33
|
+
|
|
34
|
+
@function getThemeValue($key, $type) {
|
|
35
|
+
@return theme.getThemeValue('selection', $themeValues, $key, $type);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@mixin addThemeRules($type: 'var') {
|
|
39
|
+
.mdw-selection__input {
|
|
40
|
+
opacity: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Unchecked
|
|
44
|
+
.mdw-selection:not([aria-checked="true"]) .mdw-selection__input:not(:checked) {
|
|
45
|
+
color: RGBA(getThemeValue("icon-color", $type), getThemeValue("icon-opacity", $type));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Default Focus
|
|
49
|
+
.mdw-selection__input:not([mdw-overlay-touch="true"]):focus:not([mdw-overlay-off~="focus"]) {
|
|
50
|
+
opacity: getThemeValue("focus-opacity", $type);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Checked Focus
|
|
54
|
+
.mdw-selection[aria-checked="true"] .mdw-selection__input,
|
|
55
|
+
.mdw-selection__input:checked {
|
|
56
|
+
&:not([mdw-overlay-touch="true"]):focus:not([mdw-overlay-off~="focus"]):not([mdw-overlay-off~="selected"]) {
|
|
57
|
+
opacity: getThemeValue("selected-focus-opacity", $type);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Default Hover (only when not disabled)
|
|
62
|
+
.mdw-selection:not([aria-disabled="true"]) .mdw-selection__input:not(:disabled) {
|
|
63
|
+
&:not([mdw-overlay-touch="true"]) {
|
|
64
|
+
&:hover:not([mdw-overlay-off~="hover"]) {
|
|
65
|
+
opacity: getThemeValue("hover-opacity", $type);
|
|
66
|
+
|
|
67
|
+
&:focus:not([mdw-overlay-off~="focus"]) {
|
|
68
|
+
opacity: getThemeValue("hover-focus-opacity", $type);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Checked Hover (only when not disabled)
|
|
75
|
+
.mdw-selection:not([aria-disabled="true"])[aria-checked="true"] .mdw-selection__input:not(:disabled),
|
|
76
|
+
.mdw-selection__input:not(:disabled):checked {
|
|
77
|
+
&:not([mdw-overlay-touch="true"]) {
|
|
78
|
+
&:not([mdw-overlay-off~="selected"]) {
|
|
79
|
+
&:hover:not([mdw-overlay-off~="hover"]) {
|
|
80
|
+
opacity: getThemeValue("selected-hover-opacity", $type);
|
|
81
|
+
|
|
82
|
+
&:focus:not([mdw-overlay-off~="focus"]) {
|
|
83
|
+
opacity: getThemeValue("selected-hover-focus-opacity", $type);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
// Checkbox check default
|
|
92
|
+
.mdw-selection__icon[mdw-checkbox]::after {
|
|
93
|
+
// Checkbox color is based on currently filled background-color
|
|
94
|
+
@if($type == 'var') {
|
|
95
|
+
@include platform.ifEdge() {
|
|
96
|
+
// Edge will not inherit css variables for border in psuedos
|
|
97
|
+
border-color: RGBA(getThemeValue("fallback-check-color", $type));
|
|
98
|
+
}
|
|
99
|
+
border-color: RGB(var(--mdw-surface));
|
|
100
|
+
} @else {
|
|
101
|
+
border-color: RGBA(getThemeValue("fallback-check-color", $type));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Switch track default
|
|
106
|
+
.mdw-selection__icon[mdw-switch]::after {
|
|
107
|
+
opacity: getThemeValue("track-on-opacity", $type);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Unchecked or disabled HTMLInputElement
|
|
111
|
+
.mdw-selection[aria-checked="false"] .mdw-selection__icon,
|
|
112
|
+
.mdw-selection[aria-disabled="true"] .mdw-selection__icon,
|
|
113
|
+
input.mdw-selection__input:not(:checked) ~ .mdw-selection__icon,
|
|
114
|
+
.mdw-selection__input:disabled ~ .mdw-selection__icon {
|
|
115
|
+
&[mdw-checkbox],
|
|
116
|
+
&[mdw-radio] {
|
|
117
|
+
color: RGBA(getThemeValue("icon-color", $type), getThemeValue("icon-opacity", $type));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&[mdw-switch] {
|
|
121
|
+
// Thumb
|
|
122
|
+
&::before {
|
|
123
|
+
background-color: RGBA(getThemeValue("thumb-off-color", $type));
|
|
124
|
+
}
|
|
125
|
+
// Track
|
|
126
|
+
&::after {
|
|
127
|
+
opacity: getThemeValue("track-off-opacity", $type);
|
|
128
|
+
|
|
129
|
+
background-color: RGBA(getThemeValue("track-off-color", $type));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Disabled HTMLInputElement
|
|
135
|
+
.mdw-selection[aria-disabled="true"] .mdw-selection__label,
|
|
136
|
+
.mdw-selection[aria-disabled="true"] .mdw-selection__icon,
|
|
137
|
+
.mdw-selection__input:disabled ~ .mdw-selection__label,
|
|
138
|
+
.mdw-selection__input:disabled ~ .mdw-selection__icon {
|
|
139
|
+
opacity: getThemeValue("disabled-opacity", $type);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Disabled switch colors
|
|
143
|
+
.mdw-selection[aria-disabled="true"] .mdw-selection__icon[mdw-switch],
|
|
144
|
+
.mdw-selection__input:disabled ~ .mdw-selection__icon[mdw-switch] {
|
|
145
|
+
// Thumb
|
|
146
|
+
&::before {
|
|
147
|
+
background-color: RGBA(getThemeValue("thumb-disabled-color", $type));
|
|
148
|
+
}
|
|
149
|
+
// Track
|
|
150
|
+
&::after {
|
|
151
|
+
background-color: RGBA(getThemeValue("track-off-color", $type));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
@include theme.addComponentFallbackRules('light') {
|
|
158
|
+
@include addThemeRules('light');
|
|
159
|
+
}
|
|
160
|
+
@include theme.addComponentFallbackRules('dark') {
|
|
161
|
+
@include addThemeRules('dark');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@include theme.addComponentCSSVariableRules('selection', $themeValues) {
|
|
165
|
+
@include addThemeRules();
|
|
166
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<label <%~ Object.entries({
|
|
2
|
+
'class': [
|
|
3
|
+
'mdw-selection',
|
|
4
|
+
it?.labelClass,
|
|
5
|
+
].filter(v=>v).join(' '),
|
|
6
|
+
...it?.labelAttributes,
|
|
7
|
+
}).map(([key, value]) => {
|
|
8
|
+
if (value === true) return key;
|
|
9
|
+
if (value === false || value == null) return false;
|
|
10
|
+
return `${key}="${value}"`
|
|
11
|
+
}).filter(v=>v).join(' ')-%>>
|
|
12
|
+
|
|
13
|
+
<%_ _%>
|
|
14
|
+
|
|
15
|
+
<input <%~ Object.entries({
|
|
16
|
+
class: [
|
|
17
|
+
'mdw-selection__input',
|
|
18
|
+
'mdw-overlay',
|
|
19
|
+
it?.ink || it?.theme ? 'mdw-theme': '',
|
|
20
|
+
].filter(v=>v).join(' '),
|
|
21
|
+
'mdw-overlay-disabled': 'none',
|
|
22
|
+
'mdw-ink': it?.ink,
|
|
23
|
+
'role': it?.type === 'switch' ? 'switch' : false,
|
|
24
|
+
'type': it?.type === 'radio' ? 'radio' : 'checkbox',
|
|
25
|
+
'checked': it?.checked,
|
|
26
|
+
'disabled': it?.disabled && it?.disabled !== 'false',
|
|
27
|
+
'aria-disabled': it?.disabled === true ? 'true' : it?.disabled,
|
|
28
|
+
'name': it?.name,
|
|
29
|
+
'value': it?.value,
|
|
30
|
+
...it?.attributes,
|
|
31
|
+
}).map(([key, value]) => {
|
|
32
|
+
if (value === true) return key;
|
|
33
|
+
if (value === false || value == null) return false;
|
|
34
|
+
return `${key}="${value}"`;
|
|
35
|
+
}).filter(v=>v).join(' ')-%> />
|
|
36
|
+
|
|
37
|
+
<%_ if (it?.prefix) { _%>
|
|
38
|
+
<div class="mdw-selection__label"><%~ it?.body ?? '' %><%= it?.text ?? '' %></div>
|
|
39
|
+
<%_ } _%>
|
|
40
|
+
|
|
41
|
+
<div <%~ Object.entries({
|
|
42
|
+
'class': [
|
|
43
|
+
'mdw-selection__icon',
|
|
44
|
+
it?.ink || it?.theme ? 'mdw-theme' : false,
|
|
45
|
+
].filter(v=>v).join(' '),
|
|
46
|
+
'mdw-ink': it?.ink,
|
|
47
|
+
'mdw-radio': it?.type === 'radio',
|
|
48
|
+
'mdw-switch': it?.type === 'switch',
|
|
49
|
+
'mdw-checkbox': it?.type !== 'radio' && it?.type !== 'switch',
|
|
50
|
+
}).map(([key, value]) => {
|
|
51
|
+
if (value === true) return key;
|
|
52
|
+
if (value === false || value == null) return false;
|
|
53
|
+
return `${key}="${value}"`;
|
|
54
|
+
}).filter(v=>v).join(' ')-%>></div>
|
|
55
|
+
|
|
56
|
+
<%_ if (!it?.prefix) { _%>
|
|
57
|
+
<div class="mdw-selection__label"><%~ it?.body ?? '' %><%= it?.text ?? '' %></div>
|
|
58
|
+
<%_ } _%>
|
|
59
|
+
|
|
60
|
+
</label>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as Attributes from '../../core/aria/attributes.js';
|
|
2
|
+
import * as Keyboard from '../../core/aria/keyboard.js';
|
|
3
|
+
|
|
4
|
+
import * as SelectionInput from './input.js';
|
|
5
|
+
|
|
6
|
+
export const CHECKED_CHANGE_EVENT = 'mdw:selection-checkedchange';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {Element} selectionElement
|
|
10
|
+
* @param {boolean|string} newValue
|
|
11
|
+
* @param {boolean} [dispatchEvent=false]
|
|
12
|
+
* @return {boolean} successful
|
|
13
|
+
*/
|
|
14
|
+
export function setChecked(selectionElement, newValue, dispatchEvent) {
|
|
15
|
+
return Attributes.setChecked(
|
|
16
|
+
selectionElement,
|
|
17
|
+
newValue,
|
|
18
|
+
dispatchEvent ? CHECKED_CHANGE_EVENT : null,
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {CustomEvent} event
|
|
24
|
+
* @return {void}
|
|
25
|
+
*/
|
|
26
|
+
function onActivateEvent(event) {
|
|
27
|
+
if (event.target instanceof HTMLInputElement) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (event.type === Keyboard.SPACEBAR_KEY) {
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
}
|
|
34
|
+
/** @type {HTMLElement} */
|
|
35
|
+
const selectionElement = (event.currentTarget);
|
|
36
|
+
if (Attributes.isDisabled(selectionElement)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (Attributes.isReadonly(selectionElement)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!selectionElement.hasAttribute('aria-checked')) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (event.type === 'click' || event.type === SelectionInput.CLICK_EVENT) {
|
|
46
|
+
if (selectionElement.hasAttribute('mdw-no-autocheck')) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const role = selectionElement.getAttribute('role');
|
|
51
|
+
if (event.type === 'focus' || event.type === SelectionInput.FOCUS_EVENT) {
|
|
52
|
+
if (role !== 'radio') {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const newValue = (role === 'radio' ? true : !Attributes.isChecked(selectionElement));
|
|
57
|
+
setChecked(selectionElement, newValue, true);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @param {HTMLElement} element
|
|
62
|
+
* @return {void}
|
|
63
|
+
*/
|
|
64
|
+
export function attach(element) {
|
|
65
|
+
/** @type {HTMLElement} */
|
|
66
|
+
const inputElement = (element.getElementsByClassName('mdw-selection__input')[0]);
|
|
67
|
+
if (inputElement) {
|
|
68
|
+
SelectionInput.attach(inputElement);
|
|
69
|
+
}
|
|
70
|
+
Keyboard.attach(element);
|
|
71
|
+
element.addEventListener('focus', onActivateEvent);
|
|
72
|
+
element.addEventListener('click', onActivateEvent);
|
|
73
|
+
element.addEventListener(Keyboard.SPACEBAR_KEY, onActivateEvent);
|
|
74
|
+
element.addEventListener(SelectionInput.FOCUS_EVENT, onActivateEvent);
|
|
75
|
+
element.addEventListener(SelectionInput.CLICK_EVENT, onActivateEvent);
|
|
76
|
+
}
|