@shortfuse/materialdesignweb 0.5.0 → 0.7.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/README.md +155 -77
- package/bin/generate-css.js +12 -0
- package/components/Badge.css +30 -0
- package/components/Badge.js +15 -0
- package/components/Body.css +14 -0
- package/components/Body.js +7 -0
- package/components/BottomAppBar.css +23 -0
- package/components/BottomAppBar.js +25 -0
- package/components/Box.css +31 -0
- package/components/Box.js +24 -0
- package/components/Button.css +146 -0
- package/components/Button.js +95 -0
- package/components/Button.md +61 -0
- package/components/Card.css +109 -0
- package/components/Card.js +82 -0
- package/components/Checkbox.css +77 -0
- package/components/Checkbox.js +59 -0
- package/components/CheckboxIcon.css +89 -0
- package/components/CheckboxIcon.js +41 -0
- package/components/Chip.css +35 -0
- package/components/Chip.js +22 -0
- package/components/Dialog.css +235 -0
- package/components/Dialog.js +327 -0
- package/components/DialogActions.js +13 -0
- package/components/Divider.css +41 -0
- package/components/Divider.js +13 -0
- package/components/ExtendedFab.css +24 -0
- package/components/ExtendedFab.js +11 -0
- package/components/Fab.css +23 -0
- package/components/Fab.js +26 -0
- package/components/FilterChip.css +80 -0
- package/components/FilterChip.js +51 -0
- package/components/Headline.css +14 -0
- package/components/Headline.js +33 -0
- package/components/Icon.css +76 -0
- package/components/Icon.js +174 -0
- package/components/IconButton.css +151 -0
- package/components/IconButton.js +65 -0
- package/components/Input.js +16 -0
- package/components/Label.css +14 -0
- package/components/Label.js +7 -0
- package/components/Layout.css +19 -0
- package/components/Layout.js +12 -0
- package/components/List.css +12 -0
- package/components/List.js +17 -0
- package/components/ListItem.css +224 -0
- package/components/ListItem.js +112 -0
- package/components/ListOption.css +34 -0
- package/components/ListOption.js +122 -0
- package/components/ListSelect.css +9 -0
- package/components/ListSelect.js +206 -0
- package/components/Menu.css +171 -0
- package/components/Menu.js +470 -0
- package/components/MenuItem.css +53 -0
- package/components/MenuItem.js +215 -0
- package/components/Nav.css +17 -0
- package/components/Nav.js +23 -0
- package/components/NavBar.css +34 -0
- package/components/NavBar.js +88 -0
- package/components/NavBarItem.css +41 -0
- package/components/NavBarItem.js +7 -0
- package/components/NavDrawer.css +31 -0
- package/components/NavDrawer.js +13 -0
- package/components/NavDrawerItem.css +42 -0
- package/components/NavDrawerItem.js +12 -0
- package/components/NavItem.css +181 -0
- package/components/NavItem.js +83 -0
- package/components/NavRail.css +47 -0
- package/components/NavRail.js +17 -0
- package/components/NavRailItem.css +25 -0
- package/components/NavRailItem.js +7 -0
- package/components/Option.js +91 -0
- package/components/Outline.css +138 -0
- package/components/Pane.css +261 -0
- package/components/Pane.js +21 -0
- package/components/Progress.css +74 -0
- package/components/Progress.js +67 -0
- package/components/ProgressCircle.css +226 -0
- package/components/ProgressLine.css +155 -0
- package/components/Radio.css +83 -0
- package/components/Radio.js +42 -0
- package/components/RadioIcon.css +73 -0
- package/components/RadioIcon.js +37 -0
- package/components/Ripple.css +74 -0
- package/components/Ripple.js +114 -0
- package/components/SegmentedButton.css +94 -0
- package/components/SegmentedButton.js +49 -0
- package/components/SegmentedButtonGroup.css +12 -0
- package/components/SegmentedButtonGroup.js +44 -0
- package/components/Select.css +52 -0
- package/components/Select.js +71 -0
- package/components/Shape.css +132 -0
- package/components/Shape.js +25 -0
- package/components/Slider.css +306 -0
- package/components/Slider.js +206 -0
- package/components/Snackbar.css +80 -0
- package/components/Snackbar.js +75 -0
- package/components/Surface.css +10 -0
- package/components/Surface.js +23 -0
- package/components/Switch.css +63 -0
- package/components/Switch.js +127 -0
- package/components/SwitchIcon.css +177 -0
- package/components/SwitchIcon.js +89 -0
- package/components/SwitchIconAnimations.css +89 -0
- package/components/Tab.css +85 -0
- package/components/Tab.js +103 -0
- package/components/TabContent.js +151 -0
- package/components/TabList.css +129 -0
- package/components/TabList.js +309 -0
- package/components/TabPanel.js +37 -0
- package/components/TextArea.css +93 -0
- package/components/TextArea.js +229 -0
- package/components/Title.css +14 -0
- package/components/Title.js +15 -0
- package/components/Tooltip.css +40 -0
- package/components/Tooltip.js +22 -0
- package/components/TopAppBar.css +209 -0
- package/components/TopAppBar.js +201 -0
- package/core/Composition.js +988 -0
- package/core/CustomElement.js +844 -0
- package/core/ICustomElement.d.ts +288 -0
- package/core/ICustomElement.js +1 -0
- package/core/css.js +51 -0
- package/core/customTypes.js +125 -0
- package/core/dom.js +56 -154
- package/core/identify.js +40 -0
- package/core/observe.js +410 -0
- package/core/template.js +121 -0
- package/core/typings.d.ts +135 -0
- package/core/typings.js +1 -0
- package/mixins/AriaReflectorMixin.js +42 -0
- package/mixins/AriaToolbarMixin.js +13 -0
- package/mixins/ControlMixin.css +57 -0
- package/mixins/ControlMixin.js +212 -0
- package/mixins/DensityMixin.css +40 -0
- package/mixins/DensityMixin.js +11 -0
- package/mixins/FlexableMixin.css +79 -0
- package/mixins/FlexableMixin.js +32 -0
- package/mixins/FormAssociatedMixin.js +170 -0
- package/mixins/InputMixin.js +335 -0
- package/mixins/KeyboardNavMixin.js +244 -0
- package/mixins/RTLObserverMixin.js +35 -0
- package/mixins/ResizeObserverMixin.js +38 -0
- package/mixins/RippleMixin.css +12 -0
- package/mixins/RippleMixin.js +115 -0
- package/mixins/ScrollListenerMixin.js +100 -0
- package/mixins/ShapeMixin.css +135 -0
- package/mixins/ShapeMixin.js +31 -0
- package/mixins/StateMixin.css +82 -0
- package/mixins/StateMixin.js +114 -0
- package/mixins/SurfaceMixin.css +150 -0
- package/mixins/SurfaceMixin.js +32 -0
- package/mixins/TextFieldMixin.css +657 -0
- package/mixins/TextFieldMixin.js +121 -0
- package/mixins/ThemableMixin.css +204 -0
- package/mixins/ThemableMixin.js +16 -0
- package/mixins/TooltipTriggerMixin.css +27 -0
- package/mixins/TooltipTriggerMixin.js +366 -0
- package/mixins/TouchTargetMixin.css +26 -0
- package/mixins/TouchTargetMixin.js +9 -0
- package/package.json +54 -49
- package/theming/index.js +594 -0
- package/theming/loader.js +24 -0
- package/utils/cli.js +11 -0
- package/utils/color_keywords.js +151 -0
- package/utils/hct/Cam16.js +298 -0
- package/utils/hct/CorePalette.js +84 -0
- package/utils/hct/Hct.js +172 -0
- package/utils/hct/Scheme.js +587 -0
- package/utils/hct/TonalPalette.js +68 -0
- package/utils/hct/ViewingConditions.js +136 -0
- package/utils/hct/blend.js +93 -0
- package/utils/hct/colorUtils.js +302 -0
- package/utils/hct/hctSolver.js +559 -0
- package/utils/hct/helper.js +182 -0
- package/utils/hct/mathUtils.js +153 -0
- package/utils/jsonMergePatch.js +100 -0
- package/utils/jsx-runtime.js +101 -0
- package/utils/popup.js +117 -0
- package/utils/svg.js +129 -0
- package/.browserslistrc +0 -4
- package/.eslintrc.json +0 -204
- package/.stylelintrc.json +0 -645
- package/.vscode/launch.json +0 -31
- package/.vscode/settings.json +0 -3
- package/.vscode/tasks.json +0 -32
- package/CHANGELOG.md +0 -36
- package/CODE_OF_CONDUCT.md +0 -46
- package/adapters/datatable/column.js +0 -176
- package/adapters/datatable/index.js +0 -960
- package/adapters/dom/index.js +0 -586
- package/adapters/list/index.js +0 -69
- package/adapters/search/index.js +0 -495
- package/components/appbar/_spec.scss +0 -165
- package/components/appbar/_theme.scss +0 -0
- package/components/appbar/index.scss +0 -2
- package/components/banner/_spec.scss +0 -83
- package/components/banner/_theme.scss +0 -0
- package/components/banner/index.scss +0 -2
- package/components/bottomnav/README.md +0 -85
- package/components/bottomnav/_spec.scss +0 -149
- package/components/bottomnav/_theme.scss +0 -0
- package/components/bottomnav/index.js +0 -117
- package/components/bottomnav/index.scss +0 -2
- package/components/bottomnav/item.js +0 -88
- package/components/button/README.md +0 -61
- package/components/button/_spec.scss +0 -162
- package/components/button/_theme.scss +0 -42
- package/components/button/index.eta +0 -32
- package/components/button/index.js +0 -43
- package/components/button/index.pug +0 -18
- package/components/button/index.scss +0 -2
- package/components/card/_spec.scss +0 -241
- package/components/card/_theme.scss +0 -0
- package/components/card/index.scss +0 -2
- package/components/chip/_spec.scss +0 -111
- package/components/chip/_theme.scss +0 -105
- package/components/chip/index.js +0 -23
- package/components/chip/index.scss +0 -2
- package/components/chip/item.js +0 -20
- package/components/datatable/_spec.scss +0 -225
- package/components/datatable/_theme.scss +0 -128
- package/components/datatable/cell.js +0 -44
- package/components/datatable/columnheader.js +0 -46
- package/components/datatable/index.js +0 -374
- package/components/datatable/index.scss +0 -2
- package/components/datatable/row.js +0 -48
- package/components/datatable/rowheader.js +0 -18
- package/components/dialog/_spec.scss +0 -203
- package/components/dialog/_theme.scss +0 -7
- package/components/dialog/index.js +0 -601
- package/components/dialog/index.scss +0 -2
- package/components/divider/_spec.scss +0 -11
- package/components/divider/_theme.scss +0 -0
- package/components/divider/index.scss +0 -2
- package/components/elevation/_spec.scss +0 -9
- package/components/elevation/_theme.scss +0 -0
- package/components/elevation/index.scss +0 -2
- package/components/fab/_spec.scss +0 -210
- package/components/fab/_theme.scss +0 -0
- package/components/fab/index.js +0 -99
- package/components/fab/index.scss +0 -2
- package/components/grid/_spec.scss +0 -169
- package/components/grid/_theme.scss +0 -0
- package/components/grid/index.scss +0 -2
- package/components/layout/_mixins.scss +0 -11
- package/components/layout/_spec.scss +0 -916
- package/components/layout/_theme.scss +0 -19
- package/components/layout/index.js +0 -454
- package/components/layout/index.scss +0 -2
- package/components/list/_spec.scss +0 -363
- package/components/list/_theme.scss +0 -102
- package/components/list/content.js +0 -106
- package/components/list/index.js +0 -256
- package/components/list/index.scss +0 -2
- package/components/list/item.js +0 -167
- package/components/list/secondary.js +0 -45
- package/components/menu/_spec.scss +0 -329
- package/components/menu/_theme.scss +0 -0
- package/components/menu/index.js +0 -705
- package/components/menu/index.scss +0 -2
- package/components/menu/item.js +0 -231
- package/components/progress/_spec.scss +0 -156
- package/components/progress/_theme.scss +0 -0
- package/components/progress/index.js +0 -36
- package/components/progress/index.scss +0 -2
- package/components/selection/_spec.scss +0 -376
- package/components/selection/_theme.scss +0 -134
- package/components/selection/index.eta +0 -60
- package/components/selection/index.js +0 -70
- package/components/selection/index.pug +0 -30
- package/components/selection/index.scss +0 -2
- package/components/selection/input.js +0 -54
- package/components/selection/radiogroup.js +0 -40
- package/components/slider/_spec.scss +0 -59
- package/components/slider/_theme.scss +0 -0
- package/components/slider/index.scss +0 -2
- package/components/snackbar/_spec.scss +0 -150
- package/components/snackbar/_theme.scss +0 -0
- package/components/snackbar/index.js +0 -338
- package/components/snackbar/index.scss +0 -2
- package/components/tab/_spec.scss +0 -220
- package/components/tab/_theme.scss +0 -0
- package/components/tab/content.js +0 -210
- package/components/tab/index.js +0 -257
- package/components/tab/index.scss +0 -2
- package/components/tab/item.js +0 -88
- package/components/tab/list.js +0 -196
- package/components/tab/panel.js +0 -54
- package/components/textfield/README.md +0 -179
- package/components/textfield/_spec.scss +0 -763
- package/components/textfield/_theme.scss +0 -264
- package/components/textfield/index.eta +0 -74
- package/components/textfield/index.js +0 -160
- package/components/textfield/index.pug +0 -30
- package/components/textfield/index.scss +0 -2
- package/components/tooltip/_spec.scss +0 -185
- package/components/tooltip/_theme.scss +0 -0
- package/components/tooltip/index.scss +0 -2
- package/components/type/_spec.scss +0 -227
- package/components/type/_theme.scss +0 -0
- package/components/type/index.scss +0 -2
- package/core/_breakpoint.scss +0 -189
- package/core/_elevation.scss +0 -78
- package/core/_length.scss +0 -8
- package/core/_motion.scss +0 -31
- package/core/_platform.scss +0 -12
- package/core/_type.scss +0 -128
- package/core/aria/attributes.js +0 -141
- package/core/aria/button.js +0 -49
- package/core/aria/keyboard.js +0 -92
- package/core/aria/rovingtabindex.js +0 -175
- package/core/aria/tab.js +0 -59
- package/core/document/index.js +0 -39
- package/core/overlay/_spec.scss +0 -28
- package/core/overlay/_theme.scss +0 -147
- package/core/overlay/index.js +0 -95
- package/core/overlay/index.scss +0 -2
- package/core/ripple/_spec.scss +0 -196
- package/core/ripple/_theme.scss +0 -20
- package/core/ripple/index.js +0 -286
- package/core/ripple/index.scss +0 -2
- package/core/theme/_aliases.scss +0 -15
- package/core/theme/_config.scss +0 -8
- package/core/theme/_functions.scss +0 -22
- package/core/theme/_palettes.scss +0 -405
- package/core/theme/_spec.scss +0 -0
- package/core/theme/_theme.scss +0 -268
- package/core/theme/index.js +0 -50
- package/core/theme/index.scss +0 -4
- package/core/throttler.js +0 -42
- package/core/transition/index.js +0 -465
- package/docs/_flex.scss +0 -28
- package/docs/_menuoptions.js +0 -183
- package/docs/_partials/_androidnavbar.eta +0 -5
- package/docs/_partials/_androidstatusbar.eta +0 -13
- package/docs/_partials/_appbar.eta +0 -27
- package/docs/_partials/_buttontest.eta +0 -31
- package/docs/_partials/_header.eta +0 -146
- package/docs/_partials/_navlistitem.eta +0 -16
- package/docs/_partials/_target.eta +0 -1
- package/docs/_sample-utils.js +0 -88
- package/docs/_storage.js +0 -33
- package/docs/docs.scss +0 -331
- package/docs/framework.scss +0 -26
- package/docs/index.eta +0 -12
- package/docs/index.js +0 -7
- package/docs/pages/appbar.eta +0 -108
- package/docs/pages/appbar.js +0 -0
- package/docs/pages/bottomnav.eta +0 -188
- package/docs/pages/bottomnav.js +0 -118
- package/docs/pages/button.eta +0 -124
- package/docs/pages/button.js +0 -224
- package/docs/pages/card.eta +0 -90
- package/docs/pages/card.js +0 -175
- package/docs/pages/chip.eta +0 -122
- package/docs/pages/chip.js +0 -80
- package/docs/pages/color.eta +0 -143
- package/docs/pages/color.js +0 -261
- package/docs/pages/datatable.eta +0 -323
- package/docs/pages/datatable.js +0 -160
- package/docs/pages/dialog.eta +0 -184
- package/docs/pages/dialog.js +0 -174
- package/docs/pages/dom.eta +0 -26
- package/docs/pages/dom.js +0 -140
- package/docs/pages/elevation.eta +0 -35
- package/docs/pages/elevation.js +0 -0
- package/docs/pages/fab.eta +0 -99
- package/docs/pages/fab.js +0 -43
- package/docs/pages/grid.eta +0 -135
- package/docs/pages/grid.js +0 -128
- package/docs/pages/layout.eta +0 -8
- package/docs/pages/layout.js +0 -0
- package/docs/pages/list.eta +0 -465
- package/docs/pages/list.js +0 -8
- package/docs/pages/menu.eta +0 -274
- package/docs/pages/menu.js +0 -213
- package/docs/pages/overlay.eta +0 -69
- package/docs/pages/overlay.js +0 -3
- package/docs/pages/progress.eta +0 -23
- package/docs/pages/progress.js +0 -12
- package/docs/pages/ripple.eta +0 -27
- package/docs/pages/ripple.js +0 -3
- package/docs/pages/search.eta +0 -242
- package/docs/pages/search.js +0 -226
- package/docs/pages/selection.eta +0 -107
- package/docs/pages/selection.js +0 -12
- package/docs/pages/slider.eta +0 -23
- package/docs/pages/slider.js +0 -0
- package/docs/pages/snackbar.eta +0 -83
- package/docs/pages/snackbar.js +0 -157
- package/docs/pages/tab.eta +0 -407
- package/docs/pages/tab.js +0 -152
- package/docs/pages/textfield.eta +0 -487
- package/docs/pages/textfield.js +0 -257
- package/docs/pages/tooltip.eta +0 -92
- package/docs/pages/tooltip.js +0 -0
- package/docs/pages/transition.eta +0 -117
- package/docs/pages/transition.js +0 -52
- package/docs/pages/type.eta +0 -31
- package/docs/pages/type.js +0 -0
- package/docs/postrender.js +0 -41
- package/docs/prerender.js +0 -16
- package/docs/pwa/_dialogs.eta +0 -143
- package/docs/pwa/_menus.eta +0 -16
- package/docs/pwa/pwa-prerender.js +0 -3
- package/docs/pwa/pwa.eta +0 -478
- package/docs/pwa/pwa.js +0 -298
- package/docs/pwa/pwa.scss +0 -31
- package/docs/themes/theme-colored.scss +0 -15
- package/docs/themes/theme-default.scss +0 -3
- package/index.scss +0 -27
- package/jsconfig.json +0 -16
- package/scripts/deploy-docs.sh +0 -9
- package/templates/index.eta +0 -2
- package/templates/index.pug +0 -3
- package/tsconfig.json +0 -16
- package/webpack.config.js +0 -304
package/docs/_menuoptions.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { getStorageItem, removeStorageItem, setStorageItem } from './_storage.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param {boolean} value
|
|
5
|
-
* @param {Element} [button]
|
|
6
|
-
* @return {void}
|
|
7
|
-
*/
|
|
8
|
-
export function setRTLMode(value, button) {
|
|
9
|
-
if (value) {
|
|
10
|
-
document.documentElement.dir = 'rtl';
|
|
11
|
-
setStorageItem('rtlmode', 'true');
|
|
12
|
-
} else {
|
|
13
|
-
// Explicit LTR is required for Safari to support repeated toggling
|
|
14
|
-
document.documentElement.dir = 'ltr';
|
|
15
|
-
removeStorageItem('rtlmode');
|
|
16
|
-
}
|
|
17
|
-
if (button) {
|
|
18
|
-
button.setAttribute('aria-pressed', value ? 'true' : 'false');
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** @return {boolean} */
|
|
23
|
-
export function isDarkMode() {
|
|
24
|
-
const userPreference = getStorageItem('darkmode');
|
|
25
|
-
if (userPreference == null) {
|
|
26
|
-
return window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
27
|
-
}
|
|
28
|
-
return userPreference === 'true';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @param {boolean} value
|
|
33
|
-
* @param {Element} [button]
|
|
34
|
-
* @return {void}
|
|
35
|
-
*/
|
|
36
|
-
export function setDarkMode(value, button) {
|
|
37
|
-
if (value) {
|
|
38
|
-
document.documentElement.setAttribute('mdw-dark', '');
|
|
39
|
-
document.documentElement.removeAttribute('mdw-light');
|
|
40
|
-
} else {
|
|
41
|
-
document.documentElement.setAttribute('mdw-light', '');
|
|
42
|
-
document.documentElement.removeAttribute('mdw-dark');
|
|
43
|
-
}
|
|
44
|
-
const stringValue = (value ? 'true' : 'false');
|
|
45
|
-
if (button) {
|
|
46
|
-
button.setAttribute('aria-pressed', stringValue);
|
|
47
|
-
}
|
|
48
|
-
setStorageItem('darkmode', stringValue);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @param {boolean} value
|
|
53
|
-
* @param {Element} [button]
|
|
54
|
-
* @return {void}
|
|
55
|
-
*/
|
|
56
|
-
export function setAltTheme(value, button) {
|
|
57
|
-
const items = document.head.getElementsByTagName('link');
|
|
58
|
-
for (let i = 0; i < items.length; i += 1) {
|
|
59
|
-
const stylesheet = items.item(i);
|
|
60
|
-
if (stylesheet.href.includes(value ? 'theme-colored' : 'theme-default')) {
|
|
61
|
-
stylesheet.disabled = false;
|
|
62
|
-
}
|
|
63
|
-
if (stylesheet.href.includes(value ? 'theme-default' : 'theme-colored')) {
|
|
64
|
-
stylesheet.disabled = true;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const stringValue = (value ? 'true' : 'false');
|
|
69
|
-
if (button) {
|
|
70
|
-
button.setAttribute('aria-pressed', stringValue);
|
|
71
|
-
}
|
|
72
|
-
const statusBarAttribute = document.head.getElementsByTagName('meta').namedItem('theme-color');
|
|
73
|
-
if (statusBarAttribute) {
|
|
74
|
-
statusBarAttribute.setAttribute('content', value ? '#FF5722' : '#E91E63');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
setStorageItem('alttheme', stringValue);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @param {string} value
|
|
82
|
-
* @param {Element} [button]
|
|
83
|
-
* @return {void}
|
|
84
|
-
*/
|
|
85
|
-
export function setFontSize(value, button) {
|
|
86
|
-
if (value) {
|
|
87
|
-
document.documentElement.style.setProperty('font-size', value);
|
|
88
|
-
setStorageItem('fontsize', value);
|
|
89
|
-
} else {
|
|
90
|
-
document.documentElement.style.removeProperty('font-size');
|
|
91
|
-
removeStorageItem('fontsize');
|
|
92
|
-
}
|
|
93
|
-
if (button) {
|
|
94
|
-
button.setAttribute('aria-pressed', value ? 'true' : 'false');
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @param {Element} [element]
|
|
100
|
-
* @return {void}
|
|
101
|
-
*/
|
|
102
|
-
function setupRTLMode(element) {
|
|
103
|
-
if (getStorageItem('rtlmode') === 'true') {
|
|
104
|
-
setRTLMode(true, element);
|
|
105
|
-
}
|
|
106
|
-
if (!element) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
element.addEventListener('click', () => {
|
|
110
|
-
if (document.documentElement.dir === 'rtl') {
|
|
111
|
-
setRTLMode(false, element);
|
|
112
|
-
} else {
|
|
113
|
-
setRTLMode(true, element);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @param {Element} [element]
|
|
120
|
-
* @return {void}
|
|
121
|
-
*/
|
|
122
|
-
function setupAltTheme(element) {
|
|
123
|
-
if (getStorageItem('alttheme') === 'true') {
|
|
124
|
-
setAltTheme(true, element);
|
|
125
|
-
}
|
|
126
|
-
if (!element) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
element.addEventListener('click', () => {
|
|
130
|
-
if (getStorageItem('alttheme') !== 'true') {
|
|
131
|
-
setAltTheme(true, element);
|
|
132
|
-
} else {
|
|
133
|
-
setAltTheme(false, element);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @param {Element} [element]
|
|
140
|
-
* @return {void}
|
|
141
|
-
*/
|
|
142
|
-
function setupDarkMode(element) {
|
|
143
|
-
if (isDarkMode()) {
|
|
144
|
-
setDarkMode(true, element);
|
|
145
|
-
}
|
|
146
|
-
if (!element) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
element.addEventListener('click', () => {
|
|
150
|
-
if (document.documentElement.hasAttribute('mdw-dark')) {
|
|
151
|
-
setDarkMode(false, element);
|
|
152
|
-
} else {
|
|
153
|
-
setDarkMode(true, element);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* @param {Element} element
|
|
160
|
-
* @return {void}
|
|
161
|
-
*/
|
|
162
|
-
function setupLargeFontMode(element) {
|
|
163
|
-
const fontsize = getStorageItem('fontsize');
|
|
164
|
-
setFontSize(fontsize, element);
|
|
165
|
-
if (!element) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
element.addEventListener('click', () => {
|
|
169
|
-
if (document.documentElement.style.getPropertyValue('font-size')) {
|
|
170
|
-
setFontSize(null, element);
|
|
171
|
-
} else {
|
|
172
|
-
setFontSize('200%', element);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/** @return {void} */
|
|
178
|
-
export function setupMenuOptions() {
|
|
179
|
-
setupAltTheme(document.getElementById('altThemeButton'));
|
|
180
|
-
setupRTLMode(document.getElementById('rtlButton'));
|
|
181
|
-
setupDarkMode(document.getElementById('darkModeButton'));
|
|
182
|
-
setupLargeFontMode(document.getElementById('largeFontButton'));
|
|
183
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<div <%~ Object.entries({
|
|
2
|
-
'class': 'androidstatusbar mdw-theme',
|
|
3
|
-
'mdw-surface': it?.surface,
|
|
4
|
-
'mdw-light': it?.light,
|
|
5
|
-
'mdw-dark': it?.dark
|
|
6
|
-
}).map(([key, value]) => {
|
|
7
|
-
if (value === true) return key;
|
|
8
|
-
if (value === false || value == null) return false;
|
|
9
|
-
return `${key}="${value}"`
|
|
10
|
-
}).filter(v=>v).join(' ')-%>>
|
|
11
|
-
<div>12:30</div>
|
|
12
|
-
<i class="material-icons" style="letter-spacing:2px;padding:0 2px;"></i>
|
|
13
|
-
</div>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<% var T = '../../templates/index.eta'; %>
|
|
2
|
-
<div <%~ Object.entries({
|
|
3
|
-
'class': 'mdw-appbar mdw-elevation mdw-theme',
|
|
4
|
-
'style': 'z-index:4',
|
|
5
|
-
'mdw-elevation': 4,
|
|
6
|
-
'mdw-surface': it?.surface,
|
|
7
|
-
'mdw-light': it?.light,
|
|
8
|
-
'mdw-dark': it?.dark
|
|
9
|
-
}).map(([key, value]) => {
|
|
10
|
-
if (value === true) return key;
|
|
11
|
-
if (value === false || value == null) return false;
|
|
12
|
-
return `${key}="${value}"`
|
|
13
|
-
}).filter(v=>v).join(' ')-%>>
|
|
14
|
-
<div class="mdw-appbar__start">
|
|
15
|
-
<%_~ it?.start?.map((icon) => includeFile(T, { button: {
|
|
16
|
-
class:'material-icons', icon:true, text:icon }})).join(' ') ?? '' _%>
|
|
17
|
-
</div>
|
|
18
|
-
<div class="mdw-appbar__title">
|
|
19
|
-
<%_~ it?.body ?? '' %><%= it?.text ?? '' _%>
|
|
20
|
-
</div>
|
|
21
|
-
<div class="mdw-appbar__end">
|
|
22
|
-
<%_~ it?.end?.map((icon) => includeFile(T, { button:{
|
|
23
|
-
class:'material-icons', icon:true, text:icon,
|
|
24
|
-
attributes: { 'mdw-more-button': icon === 'more_vert' }
|
|
25
|
-
}})).join(' ') ?? '' _%>
|
|
26
|
-
</div>
|
|
27
|
-
</div>
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<% var T = '../../templates/index.eta'; %>
|
|
2
|
-
<div class="display-flex flex-wrap">
|
|
3
|
-
<%~ includeFile(T, {button: { text: 'Text' }}) %>
|
|
4
|
-
<%~ includeFile(T, {button: { raised:true, text: 'Contained' }}) %>
|
|
5
|
-
<%~ includeFile(T, {button: { raised:true, disabled:true, text: 'Disabled' }}) %>
|
|
6
|
-
<%~ includeFile(T, {button: { borderInk:'default', text: 'Outlined' }}) %>
|
|
7
|
-
</div>
|
|
8
|
-
<div style="height:24px;"></div>
|
|
9
|
-
<div class="display-flex flex-wrap">
|
|
10
|
-
<%~ includeFile(T, {button: { ink:'primary', text:'Text' }}) %>
|
|
11
|
-
<%~ includeFile(T, {button: { ink:'primary', raised:true, text: 'Contained' }}) %>
|
|
12
|
-
<%~ includeFile(T, {button: { ink:'primary', raised:true, disabled:true, text:'Disabled' }}) %>
|
|
13
|
-
<%~ includeFile(T, {button: { ink:'secondary', text:'Secondary' }}) %>
|
|
14
|
-
<%~ includeFile(T, {button: { ink:'secondary', borderInk:true, text:'Outlined' }}) %>
|
|
15
|
-
</div>
|
|
16
|
-
<div style="height:24px;"></div>
|
|
17
|
-
<div class="display-flex flex-wrap">
|
|
18
|
-
<%~ includeFile(T, { button: { surface:'primary 500', dark:true, text:'Text' }}) %>
|
|
19
|
-
<%~ includeFile(T, { button: { surface:'primary 500', dark:true, raised:true, text:'Contained' }}) %>
|
|
20
|
-
<%~ includeFile(T, { button: { surface:'primary 500', dark:true, raised:true, disabled:true, text:'Disabled' }}) %>
|
|
21
|
-
<%~ includeFile(T, { button: { surface:'secondary 100', light:true, raised:true, text:'Outlined' }}) %>
|
|
22
|
-
</div>
|
|
23
|
-
<div style="height:24px;"></div>
|
|
24
|
-
<div class="display-flex flex-wrap">
|
|
25
|
-
<%~ includeFile(T, { button: { class:'material-icons', text:'favorite', icon:true }}) %>
|
|
26
|
-
<%~ includeFile(T, { button: { class:'material-icons', text:'favorite', ink:"warn", dark:true, icon:true }}) %>
|
|
27
|
-
<%~ includeFile(T, { button: { class:'material-icons', text:'favorite', surface:"warn 500", dark:true, icon:true }}) %>
|
|
28
|
-
<%~ includeFile(T, { button: { class:'material-icons', text:'favorite', surface:"warn 500", dark:true, icon:true, raised:true }}) %>
|
|
29
|
-
<%~ includeFile(T, { button: { class:'material-icons', text:'favorite', surface:"warn 500", dark:true, icon:true, raised:true, disabled:true }}) %>
|
|
30
|
-
<%~ includeFile(T, { button: { class:'material-icons', text:'favorite', icon:true, disabled:true }}) %>
|
|
31
|
-
</div>
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
<% var T = '../../templates/index.eta' -%>
|
|
2
|
-
<!DOCTYPE html>
|
|
3
|
-
<html class="mdw-layout mdw-theme" lang="en" mdw-surface="binary" mdw-light>
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Material Design Web</title>
|
|
7
|
-
<meta charset="utf-8">
|
|
8
|
-
<meta content="IE=edge" http-equiv="X-UA-Compatible">
|
|
9
|
-
<meta content="Material Design Web - CSS/JS Framework" name="description">
|
|
10
|
-
<meta content="width=device-width,initial-scale=1,viewport-fit=cover" name="viewport">
|
|
11
|
-
<meta name="theme-color" content="#C2185B">
|
|
12
|
-
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
13
|
-
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
14
|
-
|
|
15
|
-
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
|
16
|
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
|
|
17
|
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Merriweather:300,400,500">
|
|
18
|
-
<link rel="stylesheet" href="docs.min.css">
|
|
19
|
-
<link rel="stylesheet" href="framework.min.css">
|
|
20
|
-
<link rel="stylesheet" href="theme-default.min.css" title="Default Theme">
|
|
21
|
-
<link rel="stylesheet" disabled href="theme-colored.min.css" title="Colored Theme">
|
|
22
|
-
<script src="prerender.min.js"></script>
|
|
23
|
-
</head>
|
|
24
|
-
|
|
25
|
-
<body class="mdw-layout__body mdw-theme" mdw-surface="background" mdw-sidesheet-toggle="dismissible" mdw-sidesheet-style="modal">
|
|
26
|
-
<div class="mdw-layout__menus"></div>
|
|
27
|
-
<div class="mdw-layout__dialogs"></div>
|
|
28
|
-
<nav class="mdw-layout__navdrawer" id="docs-navdrawer">
|
|
29
|
-
<div class="mdw-layout__sheet-content mdw-theme" mdw-surface="background" mdw-border-ink>
|
|
30
|
-
<ul class="mdw-list" style="padding-bottom:64px;">
|
|
31
|
-
<li class="mdw-list__item">
|
|
32
|
-
<a class="mdw-list__content mdw-overlay mdw-ripple mdw-theme" <%~ it.page === 'Home' ? 'aria-current="page"' : '' %> aria-selected="<%~ it.page === 'Home'%>" href="index.html" mdw-ink="default">
|
|
33
|
-
<div class="mdw-list__text">Home</div>
|
|
34
|
-
</a>
|
|
35
|
-
</li>
|
|
36
|
-
<li class="mdw-list__item" aria-expanded="true">
|
|
37
|
-
<div class="mdw-list__content mdw-list__subheader">
|
|
38
|
-
<div class="mdw-list__text mdw-theme" mdw-ink="medium">Core</div>
|
|
39
|
-
<div class="mdw-list__secondary mdw-theme material-icons" mdw-ink="medium">expand_more</div>
|
|
40
|
-
</div>
|
|
41
|
-
<ul class="mdw-list">
|
|
42
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key: 'color', icon: 'compare', name: 'Color', page: it.page, color: 'primary contrast'}) %>
|
|
43
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key: 'overlay', icon: 'tonality', name: 'Overlay', page: it.page, color: 'primary contrast'}) %>
|
|
44
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key: 'ripple', icon: 'center_focus_strong', name: 'Ripple', page: it.page, color: 'primary contrast'}) %>
|
|
45
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key: 'transition', icon: 'dynamic_feed', name: 'Transition', page: it.page, color: 'primary contrast'}) %>
|
|
46
|
-
</ul>
|
|
47
|
-
</li>
|
|
48
|
-
<li class="mdw-list__item mdw-theme" aria-expanded="true">
|
|
49
|
-
<div class="mdw-list__content mdw-list__subheader">
|
|
50
|
-
<div class="mdw-list__text mdw-theme" mdw-ink="medium">Components</div>
|
|
51
|
-
<div class="mdw-list__secondary mdw-theme material-icons" mdw-ink="medium">expand_more</div>
|
|
52
|
-
</div>
|
|
53
|
-
<ul class="mdw-list">
|
|
54
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'appbar', icon: 'web_asset', name: 'App Bar', page: it.page }) %>
|
|
55
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'bottomnav', icon: 'call_to_action', name: 'Bottom Navigation', page: it.page }) %>
|
|
56
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'button', icon: 'crop_landscape', name: 'Button', page: it.page }) %>
|
|
57
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'card', icon: 'crop_square', name: 'Card', page: it.page }) %>
|
|
58
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'chip', icon: 'check_circle', name: 'Chip', page: it.page }) %>
|
|
59
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'datatable', icon: 'format_align_justify', name: 'Data Table', page: it.page }) %>
|
|
60
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'dialog', icon: 'select_all', name: 'Dialog', page: it.page }) %>
|
|
61
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'elevation', icon: 'layers', name: 'Elevation', page: it.page }) %>
|
|
62
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'fab', icon: 'add_circle', name: 'Floating Action Button', page: it.page }) %>
|
|
63
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'grid', icon: 'view_compact', name: 'Grid', page: it.page }) %>
|
|
64
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'layout', icon: 'view_quilt', name: 'Layout', page: it.page }) %>
|
|
65
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'list', icon: 'view_list', name: 'List', page: it.page }) %>
|
|
66
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'menu', icon: 'picture_in_picture', name: 'Menu', page: it.page }) %>
|
|
67
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'progress', icon: 'timelapse', name: 'Progress', page: it.page }) %>
|
|
68
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'selection', icon: 'toggle_on', name: 'Selection', page: it.page }) %>
|
|
69
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'slider', icon: 'tune', name: 'Slider', page: it.page }) %>
|
|
70
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'snackbar', icon: 'video_label', name: 'Snackbar', page: it.page }) %>
|
|
71
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'tab', icon: 'tab', name: 'Tab', page: it.page }) %>
|
|
72
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'textfield', icon: 'text_fields', name: 'Text Field', page: it.page }) %>
|
|
73
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'tooltip', icon: 'info', name: 'Tooltip', page: it.page }) %>
|
|
74
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'type', icon: 'font_download', name: 'Typography', page: it.page }) %>
|
|
75
|
-
</ul>
|
|
76
|
-
</li>
|
|
77
|
-
<li class="mdw-list__item" aria-expanded="true">
|
|
78
|
-
<div class="mdw-list__content mdw-list__subheader">
|
|
79
|
-
<div class="mdw-list__text mdw-theme" mdw-ink="medium">Adapters</div>
|
|
80
|
-
<div class="mdw-list__secondary mdw-theme material-icons" mdw-ink="medium">expand_more</div>
|
|
81
|
-
</div>
|
|
82
|
-
<ul class="mdw-list">
|
|
83
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'dom', icon:'calendar_view_day', name:'DOM', page: it.page }) %>
|
|
84
|
-
<%~ includeFile('../_partials/_navlistitem.eta', {key:'search', icon:'search', name:'Search', page: it.page }) %>
|
|
85
|
-
</ul>
|
|
86
|
-
</li>
|
|
87
|
-
</ul>
|
|
88
|
-
</div>
|
|
89
|
-
</nav>
|
|
90
|
-
<a class="mdw-layout__scrim" href="#" tabindex="-1"></a>
|
|
91
|
-
<div class="mdw-layout__appbar mdw-appbar mdw-theme" mdw-autohide="mobile tablet" mdw-surface="secondary 500" mdw-dark>
|
|
92
|
-
<div class="mdw-layout__appbar-shape"></div>
|
|
93
|
-
<div class="mdw-appbar__start">
|
|
94
|
-
<div class="mdw-tooltip__wrapper">
|
|
95
|
-
<%~ includeFile(T, { button: {
|
|
96
|
-
class: 'mdw-tooltip__target material-icons mdw-layout__navdrawer-toggle',
|
|
97
|
-
text:'menu', icon:true, attributes: { href:"#docs-navdrawer" },
|
|
98
|
-
}}) %>
|
|
99
|
-
<div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark mdw-align="start">Menu</div>
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
<div class="mdw-appbar__title"><%~ it.page %></div>
|
|
103
|
-
<div class="mdw-appbar__end" id="docs-menu-buttons">
|
|
104
|
-
<div class="mdw-tooltip__wrapper">
|
|
105
|
-
<%~ includeFile(T, { button: {
|
|
106
|
-
id: 'altThemeButton', class: 'mdw-tooltip__target material-icons',
|
|
107
|
-
text:'palette', icon:true, attributes: { 'mdw-overlay-default':'medium', 'mdw-overlay-off':'activated', 'aria-pressed':'false' },
|
|
108
|
-
}}) %>
|
|
109
|
-
<div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark mdw-align="end">Alt Theme</div>
|
|
110
|
-
</div>
|
|
111
|
-
<div class="mdw-tooltip__wrapper">
|
|
112
|
-
<%~ includeFile(T, { button: {
|
|
113
|
-
id: 'darkModeButton', class: 'mdw-tooltip__target material-icons',
|
|
114
|
-
text: 'brightness_3', icon: true, attributes: { 'mdw-overlay-default':'medium', 'mdw-overlay-off':'activated', 'aria-pressed':'false' },
|
|
115
|
-
}}) %>
|
|
116
|
-
<div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark mdw-align="end">Dark Mode</div>
|
|
117
|
-
</div>
|
|
118
|
-
<div class="mdw-tooltip__wrapper">
|
|
119
|
-
<%~ includeFile(T, { button: {
|
|
120
|
-
id: 'rtlButton', class: 'mdw-tooltip__target material-icons',
|
|
121
|
-
text: 'format_align_right', icon: true, attributes: { 'mdw-overlay-default': 'medium', 'mdw-overlay-off':'activated', 'aria-pressed':'false' },
|
|
122
|
-
}}) %>
|
|
123
|
-
<div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark mdw-align="end">Right-to-Left</div>
|
|
124
|
-
</div>
|
|
125
|
-
<div class="mdw-tooltip__wrapper">
|
|
126
|
-
<%~ includeFile(T, { button: {
|
|
127
|
-
id: 'largeFontButton', class: 'mdw-tooltip__target material-icons',
|
|
128
|
-
text: 'format_size', icon: true, attributes: { 'mdw-overlay-default': 'medium', 'mdw-overlay-off':'activated', 'aria-pressed':'false' },
|
|
129
|
-
}}) %>
|
|
130
|
-
<div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark mdw-align="end">200% Text</div>
|
|
131
|
-
</div>
|
|
132
|
-
</div>
|
|
133
|
-
</div>
|
|
134
|
-
<div class="mdw-layout__fab"></div>
|
|
135
|
-
<div class="mdw-layout__snackbar"></div>
|
|
136
|
-
<div class="mdw-layout__content">
|
|
137
|
-
<div class="mdw-layout__content-page">
|
|
138
|
-
<%~ it?.body ?? '' %>
|
|
139
|
-
</div>
|
|
140
|
-
</div>
|
|
141
|
-
</body>
|
|
142
|
-
<script src="postrender.min.js"></script>
|
|
143
|
-
<script src="entire-framework.min.js"></script>
|
|
144
|
-
<script src="docs.common.min.js"></script>
|
|
145
|
-
|
|
146
|
-
</html>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<li class="mdw-list__item">
|
|
2
|
-
<a class="mdw-list__content mdw-overlay mdw-ripple mdw-theme" <%_~ [
|
|
3
|
-
it.page === it.key ? 'aria-current="page"' : '',
|
|
4
|
-
`aria-selected="${it.page === it.key}"`,
|
|
5
|
-
`href="${it.key}.html"`,
|
|
6
|
-
`mdw-ink="${it.color ?? 'secondary contrast'}"`,
|
|
7
|
-
].filter(v=>v).join(' ')
|
|
8
|
-
%>>
|
|
9
|
-
<% if (it.icon) { %>
|
|
10
|
-
<div class="mdw-list__icon mdw-theme material-icons" mdw-ink="medium"><%= it.icon ?? '' %></div>
|
|
11
|
-
<% } %>
|
|
12
|
-
<div class="mdw-list__text">
|
|
13
|
-
<div class="mdw-list__text-block"><%= it.name ?? '' %></div>
|
|
14
|
-
</div>
|
|
15
|
-
</a>
|
|
16
|
-
</li>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<div class="target" style="background-image:url(<%~ it.url %>)"></div>
|
package/docs/_sample-utils.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {Element|HTMLElement} element
|
|
3
|
-
* @param {boolean} [pug=false]
|
|
4
|
-
* @param {string} [linePrefix='']
|
|
5
|
-
* @return {string}
|
|
6
|
-
*/
|
|
7
|
-
function convertElementToCode(element, pug = false, linePrefix = '') {
|
|
8
|
-
const htmlType = element.tagName.toLowerCase();
|
|
9
|
-
/** @type {string[]} */
|
|
10
|
-
const attributes = [];
|
|
11
|
-
/** @type {string[]} */
|
|
12
|
-
const classes = [];
|
|
13
|
-
for (const c of element.classList) {
|
|
14
|
-
classes.push(c);
|
|
15
|
-
}
|
|
16
|
-
for (const attr of element.attributes) {
|
|
17
|
-
if (attr.name === 'class') {
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
if (attr.value.length) {
|
|
21
|
-
attributes.push(`${attr.name}="${attr.value}"`);
|
|
22
|
-
} else {
|
|
23
|
-
attributes.push(attr.name);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
attributes.sort();
|
|
27
|
-
const syntaxItems = [
|
|
28
|
-
htmlType,
|
|
29
|
-
classes.length ? `class="${classes.join(' ')}"` : '',
|
|
30
|
-
attributes.join(' '),
|
|
31
|
-
];
|
|
32
|
-
const openingHTMLLine = pug
|
|
33
|
-
? `${htmlType === 'div' && classes.length ? '' : htmlType}${classes.length ? `.${classes.join('.')}` : ''}${attributes.length ? `(${attributes.join(' ')})` : ''}`
|
|
34
|
-
: `<${syntaxItems.filter(Boolean).join(' ').trim()}>`;
|
|
35
|
-
const closingHTMLLine = pug ? '' : `</${htmlType}>`;
|
|
36
|
-
const lines = [openingHTMLLine];
|
|
37
|
-
/** @type {string[]} */
|
|
38
|
-
const innerLines = [];
|
|
39
|
-
let onlyText = true;
|
|
40
|
-
for (const child of element.childNodes) {
|
|
41
|
-
let lineText;
|
|
42
|
-
if (child instanceof HTMLElement) {
|
|
43
|
-
lineText = convertElementToCode(child, pug, ` ${linePrefix}`);
|
|
44
|
-
if (lineText.trim()) {
|
|
45
|
-
onlyText = false;
|
|
46
|
-
}
|
|
47
|
-
} else if (child.nodeValue && pug) {
|
|
48
|
-
lineText = ` ${child.nodeValue}`;
|
|
49
|
-
}
|
|
50
|
-
if (lineText && lineText.trim()) {
|
|
51
|
-
innerLines.push(lineText);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (onlyText) {
|
|
55
|
-
if (pug) {
|
|
56
|
-
return `${linePrefix + lines.join('')} ${innerLines.join('').trim()}`;
|
|
57
|
-
}
|
|
58
|
-
return linePrefix + lines.join('') + innerLines.join('').trim() + closingHTMLLine;
|
|
59
|
-
}
|
|
60
|
-
lines.push(...innerLines, linePrefix + closingHTMLLine);
|
|
61
|
-
return linePrefix + lines.filter((line) => line.trim()).join('\n');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {Element} element
|
|
66
|
-
* @param {string} tagname
|
|
67
|
-
* @return {Element}
|
|
68
|
-
*/
|
|
69
|
-
function changeElementTagName(element, tagname) {
|
|
70
|
-
const newElement = document.createElement(tagname);
|
|
71
|
-
let i = element.attributes.length;
|
|
72
|
-
while (i--) {
|
|
73
|
-
const attr = element.attributes.item(i);
|
|
74
|
-
const clonedAttr = /** @type {Attr} */ (attr.cloneNode());
|
|
75
|
-
newElement.attributes.setNamedItem(clonedAttr);
|
|
76
|
-
}
|
|
77
|
-
while (element.firstChild) {
|
|
78
|
-
newElement.appendChild(element.firstChild);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
element.replaceWith(newElement);
|
|
82
|
-
return newElement;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export {
|
|
86
|
-
convertElementToCode,
|
|
87
|
-
changeElementTagName,
|
|
88
|
-
};
|
package/docs/_storage.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {string} key
|
|
3
|
-
* @return {string}
|
|
4
|
-
*/
|
|
5
|
-
export function getStorageItem(key) {
|
|
6
|
-
if (!window.localStorage) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
return localStorage.getItem(key);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @param {string} key
|
|
14
|
-
* @param {string} value
|
|
15
|
-
* @return {void}
|
|
16
|
-
*/
|
|
17
|
-
export function setStorageItem(key, value) {
|
|
18
|
-
if (!window.localStorage) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
localStorage.setItem(key, value);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param {string} key
|
|
26
|
-
* @return {void}
|
|
27
|
-
*/
|
|
28
|
-
export function removeStorageItem(key) {
|
|
29
|
-
if (!window.localStorage) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
localStorage.removeItem(key);
|
|
33
|
-
}
|