@shortfuse/materialdesignweb 0.2.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +2 -1
- package/.eslintrc.json +188 -30
- package/.stylelintrc.json +643 -2
- package/.vscode/launch.json +20 -5
- package/.vscode/settings.json +3 -0
- package/CHANGELOG.md +36 -0
- package/README.md +82 -2
- package/adapters/datatable/column.js +176 -0
- package/adapters/datatable/index.js +253 -437
- package/adapters/dom/index.js +586 -0
- package/adapters/list/index.js +36 -113
- package/adapters/search/index.js +153 -180
- package/components/appbar/_spec.scss +165 -0
- package/components/appbar/_theme.scss +0 -0
- package/components/appbar/index.scss +2 -0
- package/components/banner/_spec.scss +83 -0
- package/components/banner/_theme.scss +0 -0
- package/components/banner/index.scss +2 -0
- package/components/bottomnav/README.md +4 -4
- package/components/bottomnav/_spec.scss +149 -0
- package/components/bottomnav/_theme.scss +0 -0
- package/components/bottomnav/index.js +100 -120
- package/components/bottomnav/index.scss +2 -0
- package/components/bottomnav/item.js +88 -0
- package/components/button/README.md +16 -22
- package/components/button/_spec.scss +162 -0
- package/components/button/_theme.scss +42 -0
- package/components/button/index.eta +32 -0
- package/components/button/index.js +37 -48
- package/components/button/index.pug +18 -0
- package/components/button/index.scss +2 -0
- package/components/card/_spec.scss +241 -0
- package/components/card/_theme.scss +0 -0
- package/components/card/index.scss +2 -0
- package/components/chip/_spec.scss +111 -0
- package/components/chip/_theme.scss +105 -0
- package/components/chip/index.js +23 -0
- package/components/chip/index.scss +2 -0
- package/components/chip/item.js +20 -0
- package/components/datatable/_spec.scss +225 -0
- package/components/datatable/_theme.scss +128 -0
- package/components/datatable/cell.js +44 -0
- package/components/datatable/columnheader.js +46 -0
- package/components/datatable/index.js +339 -443
- package/components/datatable/index.scss +2 -0
- package/components/datatable/row.js +48 -0
- package/components/datatable/rowheader.js +18 -0
- package/components/dialog/_spec.scss +203 -0
- package/components/dialog/_theme.scss +7 -0
- package/components/dialog/index.js +512 -437
- package/components/dialog/index.scss +2 -0
- package/components/divider/_spec.scss +11 -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/{style.scss → _spec.scss} +104 -79
- package/components/fab/_theme.scss +0 -0
- package/components/fab/index.js +85 -79
- package/components/fab/index.scss +2 -0
- package/components/grid/_spec.scss +169 -0
- package/components/grid/_theme.scss +0 -0
- package/components/grid/index.scss +2 -0
- package/components/layout/_mixins.scss +11 -0
- package/components/layout/_spec.scss +916 -0
- package/components/layout/_theme.scss +19 -0
- package/components/layout/index.js +454 -0
- package/components/layout/index.scss +2 -0
- package/components/list/_spec.scss +363 -0
- package/components/list/_theme.scss +102 -0
- package/components/list/content.js +106 -0
- package/components/list/index.js +234 -79
- package/components/list/index.scss +2 -0
- package/components/list/item.js +167 -0
- package/components/list/secondary.js +45 -0
- package/components/menu/_spec.scss +329 -0
- package/components/menu/_theme.scss +0 -0
- package/components/menu/index.js +636 -651
- package/components/menu/index.scss +2 -0
- package/components/menu/item.js +231 -0
- package/components/progress/_spec.scss +156 -0
- package/components/progress/_theme.scss +0 -0
- package/components/progress/index.js +29 -13
- package/components/progress/index.scss +2 -0
- package/components/selection/_spec.scss +376 -0
- package/components/selection/_theme.scss +134 -0
- package/components/selection/index.eta +60 -0
- package/components/selection/index.js +70 -0
- package/components/selection/index.pug +30 -0
- package/components/selection/index.scss +2 -0
- package/components/selection/input.js +54 -0
- package/components/selection/radiogroup.js +40 -0
- package/components/slider/{style.scss → _spec.scss} +31 -34
- package/components/slider/_theme.scss +0 -0
- package/components/slider/index.scss +2 -0
- package/components/snackbar/_spec.scss +150 -0
- package/components/snackbar/_theme.scss +0 -0
- package/components/snackbar/index.js +293 -206
- package/components/snackbar/index.scss +2 -0
- package/components/tab/_spec.scss +220 -0
- package/components/tab/_theme.scss +0 -0
- package/components/tab/content.js +210 -0
- package/components/tab/index.js +229 -213
- package/components/tab/index.scss +2 -0
- package/components/tab/item.js +88 -0
- package/components/tab/list.js +196 -0
- package/components/tab/panel.js +54 -0
- package/components/textfield/README.md +4 -4
- package/components/textfield/_spec.scss +763 -0
- package/components/textfield/_theme.scss +264 -0
- package/components/textfield/index.eta +74 -0
- package/components/textfield/index.js +132 -138
- package/components/textfield/index.pug +30 -0
- package/components/textfield/index.scss +2 -0
- package/components/tooltip/_spec.scss +185 -0
- package/components/tooltip/_theme.scss +0 -0
- package/components/tooltip/index.scss +2 -0
- package/components/type/_spec.scss +227 -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 +78 -0
- package/core/_length.scss +8 -0
- package/core/_motion.scss +31 -0
- package/core/_platform.scss +12 -0
- package/core/_type.scss +128 -0
- package/core/aria/attributes.js +141 -0
- package/core/aria/button.js +49 -0
- package/core/aria/keyboard.js +92 -0
- package/core/aria/rovingtabindex.js +175 -0
- package/core/aria/tab.js +59 -0
- package/core/document/index.js +39 -0
- package/core/dom.js +180 -0
- package/core/overlay/_spec.scss +28 -0
- package/core/overlay/_theme.scss +147 -0
- package/core/overlay/index.js +95 -0
- package/core/overlay/index.scss +2 -0
- package/core/ripple/_spec.scss +196 -0
- package/core/ripple/_theme.scss +20 -0
- package/core/ripple/index.js +286 -0
- package/core/ripple/index.scss +2 -0
- package/core/theme/_aliases.scss +15 -0
- package/core/theme/_config.scss +8 -0
- package/core/theme/_functions.scss +22 -0
- package/{components/theming/palettes.scss → core/theme/_palettes.scss} +173 -151
- package/core/theme/_spec.scss +0 -0
- package/core/theme/_theme.scss +268 -0
- package/core/theme/index.js +50 -0
- package/core/theme/index.scss +4 -0
- package/core/throttler.js +42 -0
- package/core/transition/index.js +465 -0
- package/docs/_flex.scss +28 -0
- package/docs/_menuoptions.js +183 -0
- package/docs/_partials/_androidnavbar.eta +5 -0
- package/docs/_partials/_androidstatusbar.eta +13 -0
- package/docs/_partials/_appbar.eta +27 -0
- package/docs/_partials/_buttontest.eta +31 -0
- package/docs/_partials/_header.eta +146 -0
- package/docs/_partials/_navlistitem.eta +16 -0
- package/docs/_partials/_target.eta +1 -0
- package/docs/_sample-utils.js +88 -0
- package/docs/{src/storage.js → _storage.js} +0 -0
- package/docs/docs.scss +331 -0
- package/docs/framework.scss +26 -0
- package/docs/index.eta +12 -0
- package/docs/index.js +7 -0
- package/docs/pages/appbar.eta +108 -0
- package/docs/pages/appbar.js +0 -0
- package/docs/pages/bottomnav.eta +188 -0
- package/docs/pages/bottomnav.js +118 -0
- package/docs/pages/button.eta +124 -0
- package/docs/pages/button.js +224 -0
- package/docs/pages/card.eta +90 -0
- package/docs/pages/card.js +175 -0
- package/docs/pages/chip.eta +122 -0
- package/docs/pages/chip.js +80 -0
- package/docs/pages/color.eta +143 -0
- package/docs/pages/color.js +261 -0
- package/docs/pages/datatable.eta +323 -0
- package/docs/pages/datatable.js +160 -0
- package/docs/pages/dialog.eta +184 -0
- package/docs/{src/components → pages}/dialog.js +35 -48
- package/docs/pages/dom.eta +26 -0
- package/docs/pages/dom.js +140 -0
- package/docs/pages/elevation.eta +35 -0
- package/docs/pages/elevation.js +0 -0
- package/docs/pages/fab.eta +99 -0
- package/docs/{src/components → pages}/fab.js +6 -13
- package/docs/pages/grid.eta +135 -0
- package/docs/pages/grid.js +128 -0
- package/docs/pages/layout.eta +8 -0
- package/docs/pages/layout.js +0 -0
- package/docs/pages/list.eta +465 -0
- package/docs/pages/list.js +8 -0
- package/docs/pages/menu.eta +274 -0
- package/docs/{src/components → pages}/menu.js +26 -42
- package/docs/pages/overlay.eta +69 -0
- package/docs/pages/overlay.js +3 -0
- package/docs/pages/progress.eta +23 -0
- package/docs/{src/components → pages}/progress.js +2 -4
- package/docs/pages/ripple.eta +27 -0
- package/docs/pages/ripple.js +3 -0
- package/docs/pages/search.eta +242 -0
- package/docs/pages/search.js +226 -0
- package/docs/pages/selection.eta +107 -0
- package/docs/pages/selection.js +12 -0
- package/docs/pages/slider.eta +23 -0
- package/docs/pages/slider.js +0 -0
- package/docs/pages/snackbar.eta +83 -0
- package/docs/{src/components → pages}/snackbar.js +31 -36
- package/docs/pages/tab.eta +407 -0
- package/docs/pages/tab.js +152 -0
- package/docs/pages/textfield.eta +487 -0
- package/docs/{src/components → pages}/textfield.js +41 -45
- package/docs/pages/tooltip.eta +92 -0
- package/docs/pages/tooltip.js +0 -0
- package/docs/pages/transition.eta +117 -0
- package/docs/pages/transition.js +52 -0
- package/docs/pages/type.eta +31 -0
- package/docs/pages/type.js +0 -0
- package/docs/postrender.js +41 -0
- package/docs/prerender.js +16 -0
- package/docs/pwa/_dialogs.eta +143 -0
- package/docs/pwa/_menus.eta +16 -0
- package/docs/pwa/pwa-prerender.js +3 -0
- package/docs/pwa/pwa.eta +478 -0
- package/docs/pwa/pwa.js +298 -0
- package/docs/pwa/pwa.scss +31 -0
- package/docs/themes/theme-colored.scss +15 -0
- package/docs/themes/theme-default.scss +3 -0
- package/index.scss +27 -0
- package/jsconfig.json +8 -2
- package/package.json +54 -27
- package/scripts/deploy-docs.sh +9 -0
- package/templates/index.eta +2 -0
- package/templates/index.pug +3 -0
- package/tsconfig.json +16 -0
- package/utils/function.js +3 -0
- package/webpack.config.js +224 -68
- package/_index.scss +0 -4
- package/components/all-components.scss +0 -21
- package/components/bottomnav/style.scss +0 -190
- package/components/bottomnav/theming.scss +0 -76
- package/components/button/style.scss +0 -315
- package/components/button/theming.scss +0 -134
- package/components/card/style.scss +0 -175
- package/components/card/theming.scss +0 -43
- package/components/common/dom.js +0 -51
- package/components/common/functions.scss +0 -174
- package/components/common/mixins.scss +0 -122
- package/components/common/motion.scss +0 -36
- package/components/common/type.scss +0 -104
- package/components/common/variables.scss +0 -46
- package/components/datatable/style.scss +0 -257
- package/components/datatable/theming.scss +0 -119
- package/components/dialog/style.scss +0 -159
- package/components/dialog/theming.scss +0 -29
- package/components/divider/style.scss +0 -7
- package/components/divider/theming.scss +0 -20
- package/components/elevation/style.scss +0 -32
- package/components/layout/style.scss +0 -223
- package/components/list/style.scss +0 -358
- package/components/list/theming.scss +0 -83
- package/components/menu/style.scss +0 -280
- package/components/menu/theming.scss +0 -80
- package/components/navdrawer/index.js +0 -200
- package/components/navdrawer/style.scss +0 -595
- package/components/navdrawer/theming.scss +0 -62
- package/components/progress/style.scss +0 -136
- package/components/ripple/index.js +0 -63
- package/components/ripple/ripple.scss +0 -122
- package/components/selection/style.scss +0 -320
- package/components/selection/theming.scss +0 -98
- package/components/snackbar/style.scss +0 -212
- package/components/switch/style.scss +0 -3
- package/components/tab/style.scss +0 -275
- package/components/tab/theming.scss +0 -34
- package/components/template/theming.scss +0 -31
- package/components/textfield/style.scss +0 -795
- package/components/textfield/theming.scss +0 -256
- package/components/theming/globals.scss +0 -25
- package/components/theming/theming.scss +0 -559
- package/components/toolbar/style.scss +0 -190
- package/components/toolbar/theming.scss +0 -32
- package/components/tooltip/style.scss +0 -135
- package/components/type/style.scss +0 -167
- package/components/type/theming.scss +0 -25
- package/docs/bottomnav.html +0 -1
- package/docs/bottomnav.min.js +0 -2
- package/docs/bottomnav.min.js.map +0 -1
- package/docs/button.html +0 -1
- package/docs/button.min.js +0 -2
- package/docs/button.min.js.map +0 -1
- package/docs/card.html +0 -1
- package/docs/card.min.js +0 -2
- package/docs/card.min.js.map +0 -1
- package/docs/components.min.css +0 -1
- package/docs/components.min.js +0 -2
- package/docs/components.min.js.map +0 -1
- package/docs/datatable.html +0 -1
- package/docs/datatable.min.js +0 -2
- package/docs/datatable.min.js.map +0 -1
- package/docs/dialog.html +0 -1
- package/docs/dialog.min.js +0 -2
- package/docs/dialog.min.js.map +0 -1
- package/docs/docs.min.css +0 -1
- package/docs/docs.min.js +0 -2
- package/docs/docs.min.js.map +0 -1
- package/docs/elevation.html +0 -1
- package/docs/elevation.min.js +0 -2
- package/docs/elevation.min.js.map +0 -1
- package/docs/fab.html +0 -1
- package/docs/fab.min.js +0 -2
- package/docs/fab.min.js.map +0 -1
- package/docs/index.html +0 -1
- package/docs/index.min.js +0 -2
- package/docs/index.min.js.map +0 -1
- package/docs/layout.html +0 -1
- package/docs/layout.min.js +0 -2
- package/docs/layout.min.js.map +0 -1
- package/docs/list.html +0 -1
- package/docs/list.min.js +0 -2
- package/docs/list.min.js.map +0 -1
- package/docs/menu.html +0 -1
- package/docs/menu.min.js +0 -2
- package/docs/menu.min.js.map +0 -1
- package/docs/navdrawer.html +0 -1
- package/docs/navdrawer.min.js +0 -2
- package/docs/navdrawer.min.js.map +0 -1
- package/docs/prerender.min.js +0 -2
- package/docs/prerender.min.js.map +0 -1
- package/docs/progress.html +0 -1
- package/docs/progress.min.js +0 -2
- package/docs/progress.min.js.map +0 -1
- package/docs/search.html +0 -1
- package/docs/search.min.js +0 -2
- package/docs/search.min.js.map +0 -1
- package/docs/selection.html +0 -1
- package/docs/selection.min.js +0 -2
- package/docs/selection.min.js.map +0 -1
- package/docs/slider.html +0 -1
- package/docs/slider.min.js +0 -2
- package/docs/slider.min.js.map +0 -1
- package/docs/snackbar.html +0 -1
- package/docs/snackbar.min.js +0 -2
- package/docs/snackbar.min.js.map +0 -1
- package/docs/src/components/bottomnav.js +0 -16
- package/docs/src/components/bottomnav.pug +0 -112
- package/docs/src/components/button.js +0 -156
- package/docs/src/components/button.pug +0 -194
- package/docs/src/components/card.js +0 -136
- package/docs/src/components/card.pug +0 -133
- package/docs/src/components/datatable.js +0 -183
- package/docs/src/components/datatable.pug +0 -324
- package/docs/src/components/dialog.pug +0 -138
- package/docs/src/components/elevation.js +0 -3
- package/docs/src/components/elevation.pug +0 -17
- package/docs/src/components/fab.pug +0 -84
- package/docs/src/components/layout.js +0 -116
- package/docs/src/components/layout.pug +0 -104
- package/docs/src/components/list.js +0 -15
- package/docs/src/components/list.pug +0 -293
- package/docs/src/components/menu.pug +0 -292
- package/docs/src/components/navdrawer.js +0 -112
- package/docs/src/components/navdrawer.pug +0 -113
- package/docs/src/components/progress.pug +0 -17
- package/docs/src/components/search.js +0 -206
- package/docs/src/components/search.pug +0 -149
- package/docs/src/components/selection.js +0 -6
- package/docs/src/components/selection.pug +0 -116
- package/docs/src/components/slider.js +0 -3
- package/docs/src/components/slider.pug +0 -19
- package/docs/src/components/snackbar.pug +0 -145
- package/docs/src/components/tab.js +0 -137
- package/docs/src/components/tab.pug +0 -329
- package/docs/src/components/textfield.pug +0 -416
- package/docs/src/components/toolbar.js +0 -6
- package/docs/src/components/toolbar.pug +0 -86
- package/docs/src/components/tooltip.js +0 -6
- package/docs/src/components/tooltip.pug +0 -76
- package/docs/src/components/type.js +0 -6
- package/docs/src/components/type.pug +0 -34
- package/docs/src/components.scss +0 -1
- package/docs/src/docs.scss +0 -284
- package/docs/src/index.js +0 -3
- package/docs/src/index.pug +0 -6
- package/docs/src/menuoptions.js +0 -136
- package/docs/src/mixins.pug +0 -139
- package/docs/src/prerender.js +0 -26
- package/docs/src/sample-utils.js +0 -108
- package/docs/src/targetHandler.js +0 -50
- package/docs/src/theming.ie11.scss +0 -18
- package/docs/src/theming.scss +0 -18
- package/docs/tab.html +0 -1
- package/docs/tab.min.js +0 -2
- package/docs/tab.min.js.map +0 -1
- package/docs/textfield.html +0 -2
- package/docs/textfield.min.js +0 -2
- package/docs/textfield.min.js.map +0 -1
- package/docs/theming.ie11.min.css +0 -1
- package/docs/theming.ie11.min.js +0 -2
- package/docs/theming.ie11.min.js.map +0 -1
- package/docs/theming.min.css +0 -1
- package/docs/theming.min.js +0 -2
- package/docs/theming.min.js.map +0 -1
- package/docs/toolbar.html +0 -1
- package/docs/toolbar.min.js +0 -2
- package/docs/toolbar.min.js.map +0 -1
- package/docs/tooltip.html +0 -1
- package/docs/tooltip.min.js +0 -2
- package/docs/tooltip.min.js.map +0 -1
- package/docs/type.html +0 -1
- package/docs/type.min.js +0 -2
- package/docs/type.min.js.map +0 -1
- package/index.js +0 -16
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/* https://material.io/archive/guidelines/components/text-fields.html#text-fields-states */
|
|
2
|
+
|
|
3
|
+
@use '../../core/_platform.scss' as platform;
|
|
4
|
+
|
|
5
|
+
.mdw-theme {
|
|
6
|
+
--mdw-textfield__text-rgb: var(--mdw-ink-default);
|
|
7
|
+
--mdw-textfield__default-text-opacity: var(--mdw-high-opacity);
|
|
8
|
+
--mdw-textfield__secondary-text-opacity: var(--mdw-medium-opacity);
|
|
9
|
+
--mdw-textfield__disabled-opacity: var(--mdw-inactive-opacity);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.mdw-theme[mdw-light] {
|
|
13
|
+
--mdw-textfield__placeholder-color__focus: RGBA(var(--mdw-ink-default), 0.42);
|
|
14
|
+
--mdw-textfield__filled-disabled-border-color: RGBA(var(--mdw-ink-default), 0.10);
|
|
15
|
+
--mdw-textfield__filled-disabled-background-color: RGBA(var(--mdw-ink-default), 0.03);
|
|
16
|
+
--mdw-textfield__fill-color: RGBA(var(--mdw-ink-default), 0.06);
|
|
17
|
+
--mdw-textfield__fill-color__hover: RGBA(var(--mdw-ink-default), 0.12);
|
|
18
|
+
--mdw-textfield__border-line-color: RGBA(var(--mdw-ink-default), 0.42);
|
|
19
|
+
--mdw-textfield__border-line-color__hover: RGBA(var(--mdw-ink-default), 0.87);
|
|
20
|
+
|
|
21
|
+
--mdw-textfield__warn-color: RGBA(var(--mdw-alias-warn-A700), 1.00);
|
|
22
|
+
--mdw-textfield__warn-color__selection: RGBA(var(--mdw-alias-warn-A700), 0.20);
|
|
23
|
+
|
|
24
|
+
--mdw-textfield__selection-opacity: #{0.08 + 0.12};
|
|
25
|
+
|
|
26
|
+
--mdw-textfield__date-picker-filter: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.mdw-theme[mdw-dark] {
|
|
30
|
+
--mdw-textfield__placeholder-color__focus: RGBA(var(--mdw-ink-default), 0.50);
|
|
31
|
+
--mdw-textfield__filled-disabled-border-color: RGBA(var(--mdw-ink-default), 0.30);
|
|
32
|
+
--mdw-textfield__filled-disabled-background-color: RGBA(var(--mdw-ink-default), 0.05);
|
|
33
|
+
--mdw-textfield__fill-color: RGBA(var(--mdw-ink-default), 0.10);
|
|
34
|
+
--mdw-textfield__fill-color__hover: RGBA(var(--mdw-ink-default), 0.20);
|
|
35
|
+
--mdw-textfield__border-line-color: RGBA(var(--mdw-ink-default), 0.70);
|
|
36
|
+
--mdw-textfield__border-line-color__hover: RGBA(var(--mdw-ink-default), 1.00);
|
|
37
|
+
|
|
38
|
+
--mdw-textfield__warn-color: RGBA(var(--mdw-alias-warn-A200), 1.00);
|
|
39
|
+
--mdw-textfield__warn-color__selection: RGBA(var(--mdw-alias-warn-A200), 0.40);
|
|
40
|
+
|
|
41
|
+
--mdw-textfield__selection-opacity: #{0.16 + 0.24};
|
|
42
|
+
--mdw-textfield__date-picker-filter: invert(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.mdw-textfield[mdw-outlined] {
|
|
46
|
+
&:active > .mdw-textfield__input:not(:disabled),
|
|
47
|
+
& > .mdw-textfield__input:not(:disabled):focus {
|
|
48
|
+
& ~ .mdw-textfield__border {
|
|
49
|
+
color: inherit;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&,
|
|
54
|
+
&[mdw-ink] {
|
|
55
|
+
&:active > .mdw-textfield__input:not(:disabled),
|
|
56
|
+
& > .mdw-textfield__input:not(:disabled):focus {
|
|
57
|
+
&:invalid {
|
|
58
|
+
& ~ .mdw-textfield__border,
|
|
59
|
+
& ~ .mdw-textfield__border::before {
|
|
60
|
+
color: var(--mdw-textfield__warn-color);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.mdw-textfield__error-text {
|
|
68
|
+
color: var(--mdw-textfield__warn-color);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.mdw-textfield {
|
|
72
|
+
// Focus
|
|
73
|
+
&:active > .mdw-textfield__input:not(:disabled),
|
|
74
|
+
& > .mdw-textfield__input:not(:disabled):active,
|
|
75
|
+
& > .mdw-textfield__input:not(:disabled):focus {
|
|
76
|
+
&::selection {
|
|
77
|
+
background-color: RGBA(var(--mdw-ink), var(--mdw-textfield__selection-opacity));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
& ~ .mdw-textfield__border {
|
|
81
|
+
border-block-end-color: inherit;
|
|
82
|
+
color: inherit;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
& ~ .mdw-textfield__border .mdw-textfield__label {
|
|
86
|
+
color: inherit;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
& ~ .mdw-textfield__border::before {
|
|
90
|
+
color: inherit;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&:active > .mdw-textfield__input:not(:disabled):invalid,
|
|
95
|
+
& > .mdw-textfield__input:not(:disabled):focus:invalid {
|
|
96
|
+
caret-color: var(--mdw-textfield__warn-color);
|
|
97
|
+
|
|
98
|
+
&::selection {
|
|
99
|
+
background-color: var(--mdw-textfield__warn-color__selection);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
& ~ .mdw-textfield__border {
|
|
103
|
+
border-block-end-color: currentColor;
|
|
104
|
+
color: var(--mdw-textfield__warn-color);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
& ~ .mdw-textfield__border .mdw-textfield__label {
|
|
108
|
+
// color: var(--mdw-textfield__warn-color);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
& ~ .mdw-textfield__border::after {
|
|
112
|
+
color: var(--mdw-textfield__warn-color);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.mdw-textfield__signifier,
|
|
119
|
+
.mdw-textfield__label,
|
|
120
|
+
.mdw-textfield__prefix,
|
|
121
|
+
.mdw-textfield__suffix {
|
|
122
|
+
color: RGBA(var(--mdw-textfield__text-rgb), var(--mdw-textfield__secondary-text-opacity));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.mdw-textfield__icon[mdw-dropdown] {
|
|
126
|
+
color: RGBA(var(--mdw-textfield__text-rgb), var(--mdw-textfield__secondary-text-opacity));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.mdw-textfield[mdw-value-empty] > input.mdw-textfield__input:not(:focus) {
|
|
130
|
+
color: transparent;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
input.mdw-textfield__input:not(:focus):placeholder-shown {
|
|
134
|
+
color: transparent;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.mdw-textfield__input::-webkit-calendar-picker-indicator {
|
|
138
|
+
filter: var(--mdw-textfield__date-picker-filter);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.mdw-textfield__input::selection {
|
|
142
|
+
// color: inherit;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.mdw-textfield__input::placeholder {
|
|
146
|
+
color: var(--mdw-textfield__placeholder-color__focus);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.mdw-textfield__input {
|
|
150
|
+
caret-color: RGBA(var(--mdw-ink));
|
|
151
|
+
|
|
152
|
+
color: RGBA(var(--mdw-textfield__text-rgb), var(--mdw-textfield__default-text-opacity));
|
|
153
|
+
|
|
154
|
+
// Disabled
|
|
155
|
+
&:disabled,
|
|
156
|
+
&[aria-disabled="true"] {
|
|
157
|
+
&,
|
|
158
|
+
& ~ .mdw-textfield__border,
|
|
159
|
+
& ~ .mdw-textfield__border .mdw-textfield__label,
|
|
160
|
+
& ~ .mdw-textfield__signifier,
|
|
161
|
+
& ~ .mdw-textfield__prefix,
|
|
162
|
+
& ~ .mdw-textfield__suffix,
|
|
163
|
+
& ~ .mdw-textfield__icon {
|
|
164
|
+
color: RGBA(var(--mdw-textfield__text-rgb), var(--mdw-textfield__disabled-opacity));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Hover
|
|
169
|
+
&:not(:focus):hover:not(:disabled):not(:active) ~ .mdw-textfield__border,
|
|
170
|
+
&:not(:focus):not(:disabled):not(:active) ~ .mdw-textfield__border:hover {
|
|
171
|
+
color: var(--mdw-textfield__border-line-color__hover);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
&:not(:focus) {
|
|
175
|
+
/* Rules must be separated for IE11 support */
|
|
176
|
+
&:placeholder-shown ~ .mdw-textfield__prefix,
|
|
177
|
+
&:placeholder-shown ~ .mdw-textfield__suffix {
|
|
178
|
+
color: transparent;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.mdw-textfield[mdw-value-empty] > & ~ .mdw-textfield__prefix,
|
|
182
|
+
.mdw-textfield[mdw-value-empty] > & ~ .mdw-textfield__suffix {
|
|
183
|
+
color: transparent;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
select.mdw-textfield__input {
|
|
189
|
+
// Firefox focusring styling workaround
|
|
190
|
+
// https://dxr.mozilla.org/mozilla-central/source/browser/components/extensions/extension.css
|
|
191
|
+
.mdw-textfield[mdw-value-empty] > & {
|
|
192
|
+
color: var(--mdw-textfield__placeholder-color__focus);
|
|
193
|
+
|
|
194
|
+
&:focus {
|
|
195
|
+
color: RGBA(var(--mdw-textfield__text-rgb), var(--mdw-textfield__secondary-text-opacity));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&:-moz-focusring {
|
|
199
|
+
color: transparent;
|
|
200
|
+
text-shadow: 0 0 0 var(--mdw-textfield__placeholder-color__focus);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
&:focus:-moz-focusring {
|
|
204
|
+
color: transparent;
|
|
205
|
+
text-shadow: 0 0 0 RGBA(var(--mdw-textfield__text-rgb), var(--mdw-textfield__secondary-text-opacity));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
&:-moz-focusring {
|
|
210
|
+
color: transparent;
|
|
211
|
+
text-shadow: 0 0 0 RGBA(var(--mdw-textfield__text-rgb), var(--mdw-textfield__secondary-text-opacity));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.mdw-textfield__border {
|
|
217
|
+
color: var(--mdw-textfield__border-line-color);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.mdw-textfield__helper-text {
|
|
221
|
+
color: RGBA(var(--mdw-textfield__text-rgb), var(--mdw-textfield__secondary-text-opacity));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.mdw-textfield__input:disabled ~ .mdw-textfield__helper-text {
|
|
225
|
+
color: RGBA(var(--mdw-textfield__text-rgb), var(--mdw-textfield__disabled-opacity));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.mdw-textfield__input:focus:invalid ~ .mdw-textfield__helper-text {
|
|
229
|
+
color: transparent;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.mdw-textfield {
|
|
233
|
+
&:not([mdw-solo]) > .mdw-textfield__input:not(:focus)::placeholder {
|
|
234
|
+
color: transparent;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
&:not([mdw-solo]) > .mdw-textfield__input:not(:focus):-ms-input-placeholder {
|
|
238
|
+
color: transparent !important;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
&:not([mdw-solo]) > .mdw-textfield__input:not(:focus)::-ms-input-placeholder {
|
|
242
|
+
color: transparent !important;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.mdw-textfield__input:not(:focus) ~ .mdw-textfield__border {
|
|
246
|
+
color: var(--mdw-textfield__border-line-color);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.mdw-textfield__input:disabled ~ .mdw-textfield__border {
|
|
250
|
+
background-color: var(--mdw-textfield__filled-disabled-background-color);
|
|
251
|
+
color: var(--mdw-textfield__filled-disabled-border-color);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
&:not([mdw-outlined]) > .mdw-textfield__border {
|
|
255
|
+
background-color: var(--mdw-textfield__fill-color);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
&:not([mdw-outlined]) > .mdw-textfield__input:not(:disabled) {
|
|
259
|
+
& ~ .mdw-textfield__border:hover,
|
|
260
|
+
&:hover ~ .mdw-textfield__border {
|
|
261
|
+
background-color: var(--mdw-textfield__fill-color__hover);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<label <%~ Object.entries({
|
|
2
|
+
'class': [
|
|
3
|
+
'mdw-textfield',
|
|
4
|
+
it?.ink || it?.theme ? 'mdw-theme' : '',
|
|
5
|
+
it?.labelClass,
|
|
6
|
+
].filter(v=>v).join(' '),
|
|
7
|
+
'mdw-outlined': it?.outlined,
|
|
8
|
+
'mdw-autosize': it?.autosize,
|
|
9
|
+
'mdw-ink': it?.ink,
|
|
10
|
+
...it?.labelAttributes,
|
|
11
|
+
}).map(([key, value]) => {
|
|
12
|
+
if (value === true) return key;
|
|
13
|
+
if (value === false || value == null) return false;
|
|
14
|
+
return `${key}="${value}"`
|
|
15
|
+
}).filter(v=>v).join(' ')-%>>
|
|
16
|
+
|
|
17
|
+
<%_ if (it?.signifier) { _%>
|
|
18
|
+
<div <%~ Object.entries({
|
|
19
|
+
'class': [
|
|
20
|
+
'mdw-textfield__signifier',
|
|
21
|
+
it?.signifier.class,
|
|
22
|
+
].join(' '),
|
|
23
|
+
...it?.signifier.attributes,
|
|
24
|
+
}).map(([key, value]) => {
|
|
25
|
+
if (value === true) return key;
|
|
26
|
+
if (value === false || value == null) return false;
|
|
27
|
+
return `${key}="${value}"`;
|
|
28
|
+
}).filter(v=>v).join(' ')-%>><%~ it?.signifier.body ?? '' %><%= it?.signifier.text ?? '' %></div>
|
|
29
|
+
<%_ } _%>
|
|
30
|
+
|
|
31
|
+
<input <%~ Object.entries({
|
|
32
|
+
'class': [
|
|
33
|
+
'mdw-textfield__input',
|
|
34
|
+
it?.class,
|
|
35
|
+
].filter(v=>v).join(' '),
|
|
36
|
+
'disabled': it?.disabled && it?.disabled !== 'false',
|
|
37
|
+
'aria-disabled': it?.disabled === true ? 'true' : it?.disabled,
|
|
38
|
+
'minlength': it?.minlength,
|
|
39
|
+
'placeholder': it?.placeholder ?? ' ',
|
|
40
|
+
'required': it?.required,
|
|
41
|
+
'name': it?.name,
|
|
42
|
+
'type': it?.type ?? 'text',
|
|
43
|
+
'value': it?.value,
|
|
44
|
+
...it?.attributes,
|
|
45
|
+
}).map(([key, value]) => {
|
|
46
|
+
if (value === true) return key;
|
|
47
|
+
if (value === false || value == null) return false;
|
|
48
|
+
return `${key}="${value}"`;
|
|
49
|
+
}).filter(v=>v).join(' ')-%> />
|
|
50
|
+
|
|
51
|
+
<%_ _%>
|
|
52
|
+
|
|
53
|
+
<div class="mdw-textfield__border">
|
|
54
|
+
<div class="mdw-textfield__outline-gap">
|
|
55
|
+
<div class="mdw-textfield__label"><%= it?.body ?? '' %><%= it?.text ?? '' %></div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<%_ if (it?.prefix) { _%>
|
|
60
|
+
<div class="mdw-textfield__prefix"><%= it?.prefix %></div>
|
|
61
|
+
<%_ } _%>
|
|
62
|
+
|
|
63
|
+
<%_ if (it?.suffix) { _%>
|
|
64
|
+
<div class="mdw-textfield__suffix"><%= it?.suffix %></div>
|
|
65
|
+
<% } %>
|
|
66
|
+
|
|
67
|
+
<%_ if (it?.helper) { _%>
|
|
68
|
+
<div class="mdw-textfield__helper-text"><%= it?.helper %></div>
|
|
69
|
+
<%_ } _%>
|
|
70
|
+
|
|
71
|
+
<%_ if (it?.error) { _%>
|
|
72
|
+
<div class="mdw-textfield__error-text"><%= it?.error %></div>
|
|
73
|
+
<%_ } _%>
|
|
74
|
+
</label>
|
|
@@ -1,166 +1,160 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (input) {
|
|
12
|
-
input.addEventListener('input', TextField.onInput);
|
|
13
|
-
TextField.onInput({ currentTarget: input });
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {Element} textfieldElement
|
|
19
|
-
* @return {void}
|
|
20
|
-
*/
|
|
21
|
-
static detach(textfieldElement) {
|
|
22
|
-
textfieldElement.removeAttribute('mdw-value-empty');
|
|
23
|
-
const input = getChildElementByClass(textfieldElement, 'mdw-textfield__input');
|
|
24
|
-
if (input) {
|
|
25
|
-
input.removeEventListener('input', TextField.onInput);
|
|
1
|
+
/**
|
|
2
|
+
* @param {HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement} inputElement
|
|
3
|
+
* @return {void}
|
|
4
|
+
*/
|
|
5
|
+
export function updateInputEmptyState(inputElement) {
|
|
6
|
+
const attrName = 'mdw-value-empty';
|
|
7
|
+
const textfieldElement = inputElement.parentElement;
|
|
8
|
+
if (inputElement.value) {
|
|
9
|
+
if (textfieldElement.hasAttribute(attrName)) {
|
|
10
|
+
textfieldElement.removeAttribute(attrName);
|
|
26
11
|
}
|
|
12
|
+
} else if (!textfieldElement.hasAttribute(attrName)) {
|
|
13
|
+
textfieldElement.setAttribute(attrName, '');
|
|
27
14
|
}
|
|
15
|
+
}
|
|
28
16
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @param {HTMLTextAreaElement} inputElement
|
|
19
|
+
* @return {number} Single row height
|
|
20
|
+
*/
|
|
21
|
+
export function updateTextAreaSize(inputElement) {
|
|
22
|
+
const previousRowsAttrValue = inputElement.getAttribute('rows');
|
|
23
|
+
inputElement.rows = 1;
|
|
24
|
+
const { height, paddingTop } = window.getComputedStyle(inputElement);
|
|
25
|
+
if (!height || height === 'auto') {
|
|
26
|
+
if (previousRowsAttrValue == null) {
|
|
27
|
+
inputElement.removeAttribute('rows');
|
|
28
|
+
} else {
|
|
29
|
+
inputElement.setAttribute('rows', previousRowsAttrValue);
|
|
37
30
|
}
|
|
38
|
-
|
|
31
|
+
return -1;
|
|
39
32
|
}
|
|
33
|
+
const heightPx = Number.parseInt(height.replace('px', ''), 10);
|
|
34
|
+
const paddingTopPx = Number.parseInt(paddingTop.replace('px', ''), 10);
|
|
35
|
+
inputElement.rows = Math.floor((inputElement.scrollHeight - paddingTopPx) / heightPx);
|
|
36
|
+
return heightPx;
|
|
37
|
+
}
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
textfieldElement.removeAttribute(attributeName);
|
|
50
|
-
}
|
|
51
|
-
} else if (!textfieldElement.hasAttribute(attributeName)) {
|
|
52
|
-
textfieldElement.setAttribute('mdw-value-empty', '');
|
|
53
|
-
}
|
|
39
|
+
/**
|
|
40
|
+
* @param {Event|{currentTarget:HTMLElement}} event
|
|
41
|
+
* @return {void}
|
|
42
|
+
*/
|
|
43
|
+
export function onInput(event) {
|
|
44
|
+
const inputElement = /** @type {HTMLInputElement|HTMLTextAreaElement} */ (event.currentTarget);
|
|
45
|
+
if (inputElement.parentElement.hasAttribute('mdw-autosize')) {
|
|
46
|
+
updateTextAreaSize(/** @type {HTMLTextAreaElement} */ (inputElement));
|
|
54
47
|
}
|
|
48
|
+
updateInputEmptyState(inputElement);
|
|
49
|
+
}
|
|
55
50
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
inputElement.setAttribute('rows', previousRowsValue);
|
|
65
|
-
return -1;
|
|
66
|
-
}
|
|
67
|
-
const heightPx = parseInt(height.replace('px', ''), 10);
|
|
68
|
-
const paddingTopPx = parseInt(paddingTop.replace('px', ''), 10);
|
|
69
|
-
inputElement.setAttribute('rows', Math.floor((inputElement.scrollHeight - paddingTopPx) / heightPx).toString());
|
|
70
|
-
return heightPx;
|
|
51
|
+
/**
|
|
52
|
+
* @param {Element} textfieldElement
|
|
53
|
+
* @return {string|Date|number}
|
|
54
|
+
*/
|
|
55
|
+
export function getValue(textfieldElement) {
|
|
56
|
+
const input = /** @type {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} */ (textfieldElement.getElementsByClassName('mdw-textfield__input')[0]);
|
|
57
|
+
if ((input instanceof HTMLTextAreaElement) || (input instanceof HTMLSelectElement)) {
|
|
58
|
+
return input.value;
|
|
71
59
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
60
|
+
switch (input.type) {
|
|
61
|
+
case 'number':
|
|
62
|
+
case 'range':
|
|
63
|
+
return Number.isNaN(input.valueAsNumber) ? null : input.valueAsNumber;
|
|
64
|
+
case 'date':
|
|
65
|
+
case 'datetime-local':
|
|
66
|
+
case 'time':
|
|
67
|
+
if (input.value == null) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return new Date(
|
|
71
|
+
(new Date(input.valueAsNumber).getTimezoneOffset() * 60 * 1000) + input.valueAsNumber,
|
|
72
|
+
);
|
|
73
|
+
default:
|
|
81
74
|
return input.value;
|
|
82
|
-
}
|
|
83
|
-
const type = input.hasAttribute('type') && input.getAttribute('type').toLowerCase();
|
|
84
|
-
switch (type) {
|
|
85
|
-
case 'number':
|
|
86
|
-
case 'range':
|
|
87
|
-
return Number.isNaN(input.valueAsNumber) ? null : input.valueAsNumber;
|
|
88
|
-
case 'date':
|
|
89
|
-
case 'datetime-local':
|
|
90
|
-
case 'time':
|
|
91
|
-
if (input.value == null) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
return new Date((new Date(input.valueAsNumber).getTimezoneOffset() * 60 * 1000) + input.valueAsNumber);
|
|
95
|
-
default:
|
|
96
|
-
return input.value;
|
|
97
|
-
}
|
|
98
75
|
}
|
|
76
|
+
}
|
|
99
77
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
input.value = value.toString();
|
|
113
|
-
} else if (typeof value === 'string') {
|
|
114
|
-
input.value = value;
|
|
115
|
-
} else {
|
|
116
|
-
input.value = value.toString(10);
|
|
117
|
-
}
|
|
118
|
-
} else if (value instanceof Date) {
|
|
119
|
-
const type = input.hasAttribute('type') && input.getAttribute('type').toLowerCase();
|
|
120
|
-
if (type === 'time') {
|
|
121
|
-
const hoursStr = `${value.getHours() < 10 ? '0' : ''}${value.getHours()}`;
|
|
122
|
-
const minutesStr = `${value.getMinutes() < 10 ? '0' : ''}${value.getMinutes()}`;
|
|
123
|
-
const secondsStr = `${value.getSeconds() < 10 ? '0' : ''}${value.getSeconds()}`;
|
|
124
|
-
input.value = `${hoursStr}:${minutesStr}:${secondsStr}.${value.getMilliseconds()}`;
|
|
125
|
-
} else {
|
|
126
|
-
switch (type) {
|
|
127
|
-
case 'date':
|
|
128
|
-
input.valueAsDate = value;
|
|
129
|
-
break;
|
|
130
|
-
case 'datetime-local':
|
|
131
|
-
input.valueAsNumber = value.getTime() - (value.getTimezoneOffset() * 60 * 1000);
|
|
132
|
-
break;
|
|
133
|
-
case 'number':
|
|
134
|
-
case 'range':
|
|
135
|
-
input.valueAsNumber = value.getTime();
|
|
136
|
-
break;
|
|
137
|
-
default:
|
|
138
|
-
input.value = value.toString();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
78
|
+
/**
|
|
79
|
+
* @param {Element} textfieldElement
|
|
80
|
+
* @param {string|Date|number|null} [value]
|
|
81
|
+
* @return {void}
|
|
82
|
+
*/
|
|
83
|
+
export function setValue(textfieldElement, value) {
|
|
84
|
+
const input = /** @type {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} */ (textfieldElement.getElementsByClassName('mdw-textfield__input')[0]);
|
|
85
|
+
if (value == null) {
|
|
86
|
+
input.value = null;
|
|
87
|
+
} else if (input instanceof HTMLTextAreaElement || input instanceof HTMLSelectElement) {
|
|
88
|
+
if (value instanceof Date) {
|
|
89
|
+
input.value = value.toString();
|
|
141
90
|
} else if (typeof value === 'string') {
|
|
142
91
|
input.value = value;
|
|
143
92
|
} else {
|
|
144
|
-
|
|
145
|
-
|
|
93
|
+
input.value = value.toString(10);
|
|
94
|
+
}
|
|
95
|
+
} else if (value instanceof Date) {
|
|
96
|
+
if (input.type === 'time') {
|
|
97
|
+
const hoursStr = `${value.getHours() < 10 ? '0' : ''}${value.getHours()}`;
|
|
98
|
+
const minutesStr = `${value.getMinutes() < 10 ? '0' : ''}${value.getMinutes()}`;
|
|
99
|
+
const secondsStr = `${value.getSeconds() < 10 ? '0' : ''}${value.getSeconds()}`;
|
|
100
|
+
input.value = `${hoursStr}:${minutesStr}:${secondsStr}.${value.getMilliseconds()}`;
|
|
101
|
+
} else {
|
|
102
|
+
switch (input.type) {
|
|
146
103
|
case 'date':
|
|
147
|
-
|
|
104
|
+
input.valueAsDate = value;
|
|
105
|
+
break;
|
|
148
106
|
case 'datetime-local':
|
|
107
|
+
input.valueAsNumber = value.getTime() - (value.getTimezoneOffset() * 60 * 1000);
|
|
108
|
+
break;
|
|
149
109
|
case 'number':
|
|
150
110
|
case 'range':
|
|
151
|
-
input.valueAsNumber = value;
|
|
111
|
+
input.valueAsNumber = value.getTime();
|
|
152
112
|
break;
|
|
153
113
|
default:
|
|
154
114
|
input.value = value.toString();
|
|
155
115
|
}
|
|
156
116
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
117
|
+
} else if (typeof value === 'string') {
|
|
118
|
+
input.value = value;
|
|
119
|
+
} else {
|
|
120
|
+
switch (input.type) {
|
|
121
|
+
case 'date':
|
|
122
|
+
case 'time':
|
|
123
|
+
case 'datetime-local':
|
|
124
|
+
case 'number':
|
|
125
|
+
case 'range':
|
|
126
|
+
input.valueAsNumber = value;
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
input.value = value.toString();
|
|
160
130
|
}
|
|
161
131
|
}
|
|
132
|
+
updateInputEmptyState(input);
|
|
133
|
+
if (input instanceof HTMLTextAreaElement && textfieldElement.hasAttribute('mdw-autosize')) {
|
|
134
|
+
updateTextAreaSize(input);
|
|
135
|
+
}
|
|
162
136
|
}
|
|
163
137
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
138
|
+
/**
|
|
139
|
+
* @param {Element} textfieldElement
|
|
140
|
+
* @return {void}
|
|
141
|
+
*/
|
|
142
|
+
export function attach(textfieldElement) {
|
|
143
|
+
const input = /** @type {HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement} */ (textfieldElement.getElementsByClassName('mdw-textfield__input')[0]);
|
|
144
|
+
if (input) {
|
|
145
|
+
input.addEventListener('input', onInput, { passive: true });
|
|
146
|
+
onInput({ currentTarget: input });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @param {Element} textfieldElement
|
|
152
|
+
* @return {void}
|
|
153
|
+
*/
|
|
154
|
+
export function detach(textfieldElement) {
|
|
155
|
+
textfieldElement.removeAttribute('mdw-value-empty');
|
|
156
|
+
const input = (textfieldElement.getElementsByClassName('mdw-textfield__input')[0]);
|
|
157
|
+
if (input) {
|
|
158
|
+
input.removeEventListener('input', onInput);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
mixin mdwTextField(options={})
|
|
2
|
+
label.mdw-textfield(class=([
|
|
3
|
+
options.ink ? 'mdw-theme' : '',
|
|
4
|
+
].filter(v=>v).join(' '))
|
|
5
|
+
mdw-outlined=(options.outlined)
|
|
6
|
+
mdw-autosize=(options.autosize)
|
|
7
|
+
mdw-ink=(options.ink)
|
|
8
|
+
)
|
|
9
|
+
if (options.signifierClass || options.signifier)
|
|
10
|
+
.mdw-textfield__signifier(class=options.signifierClass)= options.signifier
|
|
11
|
+
input.mdw-textfield__input(
|
|
12
|
+
disabled=(options.disabled ? '' : false)
|
|
13
|
+
minlength=(options.minlength ? `${options.minlength}` : false)
|
|
14
|
+
placeholder=(options.placeholder ? options.placeholder: ' ')
|
|
15
|
+
required=(options.required ? '' : false)
|
|
16
|
+
type=(options.type ? options.type : 'text')
|
|
17
|
+
value=(options.value)
|
|
18
|
+
)&attributes(attributes)
|
|
19
|
+
.mdw-textfield__border
|
|
20
|
+
.mdw-textfield__outline-gap
|
|
21
|
+
.mdw-textfield__label
|
|
22
|
+
block
|
|
23
|
+
if (options.prefix)
|
|
24
|
+
.mdw-textfield__prefix= options.prefix
|
|
25
|
+
if (options.suffix)
|
|
26
|
+
.mdw-textfield__suffix= options.suffix
|
|
27
|
+
if (options.helperText)
|
|
28
|
+
.mdw-textfield__helper-text= options.helperText
|
|
29
|
+
if (options.errorText)
|
|
30
|
+
.mdw-textfield__error-text= options.errorText
|