@shortfuse/materialdesignweb 0.4.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.
Files changed (184) hide show
  1. package/.browserslistrc +2 -1
  2. package/.eslintrc.json +59 -8
  3. package/.stylelintrc.json +94 -49
  4. package/CHANGELOG.md +12 -0
  5. package/README.md +1 -3
  6. package/adapters/datatable/column.js +27 -54
  7. package/adapters/datatable/index.js +69 -81
  8. package/adapters/dom/index.js +32 -47
  9. package/adapters/search/index.js +107 -133
  10. package/components/appbar/_spec.scss +77 -137
  11. package/components/banner/_spec.scss +28 -63
  12. package/components/bottomnav/_spec.scss +46 -54
  13. package/components/bottomnav/index.js +15 -20
  14. package/components/bottomnav/item.js +4 -5
  15. package/components/button/README.md +1 -1
  16. package/components/button/_spec.scss +43 -42
  17. package/components/button/_theme.scss +27 -50
  18. package/components/card/_spec.scss +61 -69
  19. package/components/chip/_spec.scss +21 -44
  20. package/components/chip/_theme.scss +79 -151
  21. package/components/chip/index.js +6 -4
  22. package/components/datatable/_spec.scss +36 -99
  23. package/components/datatable/_theme.scss +98 -124
  24. package/components/datatable/cell.js +1 -2
  25. package/components/datatable/columnheader.js +1 -2
  26. package/components/datatable/index.js +33 -47
  27. package/components/datatable/row.js +4 -5
  28. package/components/dialog/_spec.scss +53 -63
  29. package/components/dialog/_theme.scss +7 -0
  30. package/components/dialog/index.js +62 -88
  31. package/components/divider/_spec.scss +6 -8
  32. package/components/elevation/_spec.scss +1 -1
  33. package/components/fab/_spec.scss +30 -42
  34. package/components/fab/index.js +4 -8
  35. package/components/grid/_spec.scss +68 -211
  36. package/components/layout/_mixins.scss +0 -22
  37. package/components/layout/_spec.scss +267 -363
  38. package/components/layout/_theme.scss +10 -35
  39. package/components/layout/index.js +40 -50
  40. package/components/list/_spec.scss +57 -91
  41. package/components/list/_theme.scss +75 -84
  42. package/components/list/content.js +9 -13
  43. package/components/list/index.js +34 -38
  44. package/components/list/item.js +8 -11
  45. package/components/list/secondary.js +8 -9
  46. package/components/menu/_spec.scss +134 -167
  47. package/components/menu/index.js +45 -61
  48. package/components/menu/item.js +11 -19
  49. package/components/progress/_spec.scss +43 -34
  50. package/components/selection/_spec.scss +123 -133
  51. package/components/selection/_theme.scss +88 -120
  52. package/components/selection/index.js +9 -15
  53. package/components/selection/input.js +3 -5
  54. package/components/selection/radiogroup.js +8 -15
  55. package/components/slider/_spec.scss +23 -28
  56. package/components/snackbar/_spec.scss +17 -62
  57. package/components/snackbar/index.js +15 -21
  58. package/components/tab/_spec.scss +35 -50
  59. package/components/tab/content.js +33 -28
  60. package/components/tab/index.js +30 -33
  61. package/components/tab/item.js +4 -5
  62. package/components/tab/list.js +22 -36
  63. package/components/textfield/README.md +2 -2
  64. package/components/textfield/_spec.scss +241 -287
  65. package/components/textfield/_theme.scss +197 -232
  66. package/components/textfield/index.js +8 -16
  67. package/components/tooltip/_spec.scss +23 -26
  68. package/components/type/_spec.scss +19 -16
  69. package/core/_breakpoint.scss +33 -33
  70. package/core/_elevation.scss +40 -0
  71. package/core/_length.scss +0 -1
  72. package/core/_platform.scss +0 -22
  73. package/core/_type.scss +7 -6
  74. package/core/aria/button.js +4 -5
  75. package/core/aria/keyboard.js +1 -2
  76. package/core/aria/rovingtabindex.js +14 -17
  77. package/core/aria/tab.js +1 -2
  78. package/core/dom.js +18 -109
  79. package/core/overlay/_spec.scss +5 -8
  80. package/core/overlay/_theme.scss +126 -150
  81. package/core/overlay/index.js +19 -32
  82. package/core/ripple/_spec.scss +16 -17
  83. package/core/ripple/_theme.scss +13 -33
  84. package/core/ripple/index.js +36 -44
  85. package/core/theme/_aliases.scss +15 -0
  86. package/core/theme/_config.scss +8 -2
  87. package/core/theme/_functions.scss +22 -0
  88. package/core/theme/_palettes.scss +0 -1
  89. package/core/{color → theme}/_spec.scss +0 -0
  90. package/core/theme/_theme.scss +268 -0
  91. package/core/theme/index.scss +4 -0
  92. package/core/transition/index.js +73 -76
  93. package/docs/_flex.scss +7 -1
  94. package/docs/_menuoptions.js +2 -2
  95. package/docs/_partials/_appbar.eta +12 -14
  96. package/docs/_partials/_header.eta +41 -44
  97. package/docs/_sample-utils.js +15 -20
  98. package/docs/docs.scss +123 -87
  99. package/docs/framework.scss +26 -0
  100. package/docs/index.eta +2 -6
  101. package/docs/index.js +7 -0
  102. package/docs/pages/appbar.eta +22 -28
  103. package/docs/pages/bottomnav.js +17 -14
  104. package/docs/pages/button.js +10 -10
  105. package/docs/pages/card.js +20 -22
  106. package/docs/pages/chip.js +11 -13
  107. package/docs/pages/color.js +35 -36
  108. package/docs/pages/datatable.js +11 -15
  109. package/docs/pages/dialog.eta +9 -11
  110. package/docs/pages/dialog.js +6 -9
  111. package/docs/pages/dom.js +6 -9
  112. package/docs/pages/elevation.eta +10 -10
  113. package/docs/pages/fab.js +2 -3
  114. package/docs/pages/grid.js +5 -5
  115. package/docs/pages/list.js +1 -2
  116. package/docs/pages/menu.eta +17 -19
  117. package/docs/pages/menu.js +7 -11
  118. package/docs/pages/overlay.js +1 -2
  119. package/docs/pages/progress.eta +2 -2
  120. package/docs/pages/progress.js +1 -1
  121. package/docs/pages/ripple.js +1 -2
  122. package/docs/pages/search.eta +20 -24
  123. package/docs/pages/search.js +24 -41
  124. package/docs/pages/selection.eta +2 -6
  125. package/docs/pages/selection.js +3 -4
  126. package/docs/pages/snackbar.js +3 -4
  127. package/docs/pages/tab.eta +61 -75
  128. package/docs/pages/tab.js +16 -15
  129. package/docs/pages/textfield.eta +9 -8
  130. package/docs/pages/textfield.js +26 -23
  131. package/docs/pages/tooltip.eta +10 -12
  132. package/docs/pages/transition.js +5 -7
  133. package/docs/postrender.js +7 -5
  134. package/docs/pwa/pwa.eta +14 -16
  135. package/docs/pwa/pwa.js +19 -27
  136. package/docs/pwa/pwa.scss +12 -7
  137. package/docs/themes/theme-colored.scss +9 -11
  138. package/docs/themes/theme-default.scss +0 -14
  139. package/index.scss +27 -0
  140. package/jsconfig.json +7 -3
  141. package/package.json +26 -15
  142. package/tsconfig.json +16 -0
  143. package/{webpack.config.cjs → webpack.config.js} +105 -58
  144. package/components/template/_theme.scss +0 -27
  145. package/components/textfield/_mixins.scss +0 -52
  146. package/core/color/_theme.scss +0 -390
  147. package/core/color/index.scss +0 -2
  148. package/core/theme/_mixins.scss +0 -172
  149. package/core/theme/_variables.scss +0 -24
  150. package/docs/_mixins.pug +0 -155
  151. package/docs/pages/appbar.pug +0 -78
  152. package/docs/pages/bottomnav.pug +0 -137
  153. package/docs/pages/button.pug +0 -121
  154. package/docs/pages/card.pug +0 -74
  155. package/docs/pages/chip.pug +0 -91
  156. package/docs/pages/color.pug +0 -121
  157. package/docs/pages/datatable.pug +0 -283
  158. package/docs/pages/dialog.pug +0 -132
  159. package/docs/pages/dom.pug +0 -22
  160. package/docs/pages/elevation.pug +0 -25
  161. package/docs/pages/fab.pug +0 -66
  162. package/docs/pages/grid.pug +0 -95
  163. package/docs/pages/layout.pug +0 -7
  164. package/docs/pages/list.pug +0 -326
  165. package/docs/pages/menu.pug +0 -205
  166. package/docs/pages/overlay.pug +0 -55
  167. package/docs/pages/progress.pug +0 -16
  168. package/docs/pages/ripple.pug +0 -21
  169. package/docs/pages/search.pug +0 -165
  170. package/docs/pages/selection.pug +0 -74
  171. package/docs/pages/slider.pug +0 -17
  172. package/docs/pages/snackbar.pug +0 -60
  173. package/docs/pages/tab.pug +0 -304
  174. package/docs/pages/textfield.pug +0 -360
  175. package/docs/pages/tooltip.pug +0 -78
  176. package/docs/pages/transition.pug +0 -76
  177. package/docs/pages/type.pug +0 -29
  178. package/docs/pwa/_dialogs.pug +0 -96
  179. package/docs/pwa/_menus.pug +0 -11
  180. package/docs/pwa/pwa.pug +0 -325
  181. package/docs/spec.scss +0 -26
  182. package/docs/themes/_component-themes.scss +0 -26
  183. package/docs/themes/theme-colored-fallbacks.scss +0 -17
  184. package/docs/themes/theme-default-fallbacks.scss +0 -17
@@ -1,6 +1,7 @@
1
1
  // https://material.io/design/navigation/navigation-transitions.html
2
2
 
3
- import { nextTick } from '../dom.js';
3
+ const EXPAND_DURATION_MS = 300;
4
+ const COLLAPSE_DURATION_MS = 250;
4
5
 
5
6
  /**
6
7
  * @typedef {Object} ShapeTranformDetails
@@ -21,7 +22,7 @@ function pxToInteger(px) {
21
22
  if (!px) {
22
23
  return 0;
23
24
  }
24
- return parseInt(px, 10);
25
+ return Number.parseInt(px, 10);
25
26
  }
26
27
 
27
28
  /**
@@ -42,26 +43,26 @@ function convertBoxShadow(stringValue, scaleX, scaleY) {
42
43
  let blurRadius = '';
43
44
  let spreadRadius = '';
44
45
  let color = '';
45
- shadow.split(' ').forEach((value) => {
46
+ for (const value of shadow.trim().split(' ')) {
46
47
  if (value.toLowerCase() === 'inset') {
47
48
  inset = value;
48
- return;
49
+ continue;
49
50
  }
50
- if (value.indexOf('(') !== -1 || !value.match(/\d/).length) {
51
+ if (value.includes('(') || !value.match(/\d/).length) {
51
52
  color = value;
52
- return;
53
+ continue;
53
54
  }
54
55
  const numberValue = pxToInteger(value);
55
56
  if (!offsetX) {
56
- offsetX = `${numberValue / scaleX}${value.replace(/[0-9\\-\\.]/g, '')}`;
57
+ offsetX = `${numberValue / scaleX}${value.replace(/[\d.\\]/g, '')}`;
57
58
  } else if (!offsetY) {
58
- offsetY = `${numberValue / scaleY}${value.replace(/[0-9\\-\\.]/g, '')}`;
59
+ offsetY = `${numberValue / scaleY}${value.replace(/[\d.\\]/g, '')}`;
59
60
  } else if (!blurRadius) {
60
- blurRadius = `${numberValue / (scaleX * scaleY)}${value.replace(/[0-9\-\\.]/g, '')}`;
61
+ blurRadius = `${numberValue / (scaleX * scaleY)}${value.replace(/[\d.\\-]/g, '')}`;
61
62
  } else {
62
- spreadRadius = `${numberValue / (scaleX * scaleY)}${value.replace(/[0-9\-\\.]/g, '')}`;
63
+ spreadRadius = `${numberValue / (scaleX * scaleY)}${value.replace(/[\d.\\-]/g, '')}`;
63
64
  }
64
- });
65
+ }
65
66
  return [
66
67
  inset,
67
68
  offsetX,
@@ -69,7 +70,7 @@ function convertBoxShadow(stringValue, scaleX, scaleY) {
69
70
  blurRadius,
70
71
  spreadRadius,
71
72
  color,
72
- ].filter((v) => v).join(' ');
73
+ ].filter(Boolean).join(' ');
73
74
  }
74
75
 
75
76
  if (!stringValue) {
@@ -79,15 +80,26 @@ function convertBoxShadow(stringValue, scaleX, scaleY) {
79
80
  // Strip spaces from anything parenthesized
80
81
  .replace(/\([^)]+\)/g, (substring) => substring.replace(/ /g, ''))
81
82
  // Split shadows by commas no inside parentheses
82
- .match(/[^,(]+\([^)]+\)?[^,]*(|$)/g)
83
- // Trim empty spaces
84
- .map((shadow) => shadow.trim())
83
+ .match(/[^(,]+\([^)]+\)?[^,]*(|$)/g)
85
84
  // Convert values
86
- .map(convertShadow)
85
+ .map((shadow) => convertShadow(shadow))
87
86
  // Rejoin shadows
88
87
  .join(', ');
89
88
  }
90
89
 
90
+ /**
91
+ * @param {string} value
92
+ * @param {number} length
93
+ * @return {number}
94
+ */
95
+ function parsePercentage(value, length) {
96
+ const numValue = pxToInteger(value);
97
+ if (!value.includes('%')) {
98
+ return numValue;
99
+ }
100
+ return ((numValue * length) / 100);
101
+ }
102
+
91
103
  /**
92
104
  * @param {string} stringValue
93
105
  * @param {number} width
@@ -95,19 +107,6 @@ function convertBoxShadow(stringValue, scaleX, scaleY) {
95
107
  * @return {{horizontal:number, vertical:number}}
96
108
  */
97
109
  function convertBorderRadius(stringValue, width, height) {
98
- /**
99
- * @param {string} value
100
- * @param {number} length
101
- * @return {number}
102
- */
103
- function parsePercentage(value, length) {
104
- const numValue = pxToInteger(value);
105
- if (value.indexOf('%') === -1) {
106
- return numValue;
107
- }
108
- return ((numValue * length) / 100.0);
109
- }
110
-
111
110
  if (!stringValue) {
112
111
  return {
113
112
  horizontal: 0,
@@ -222,9 +221,7 @@ function buildTransitionEndListener(element, property, callback, expectedDuratio
222
221
  export function transitionElement(options) {
223
222
  const toStyleSyle = window.getComputedStyle(options.toShapeElement);
224
223
 
225
- const shapeTransform = getShapeTransform(
226
- options.fromShapeElement, options.toShapeElement, toStyleSyle,
227
- );
224
+ const shapeTransform = getShapeTransform(options.fromShapeElement, options.toShapeElement, toStyleSyle);
228
225
  const contentTransform = getShapeTransform(options.toContentElement, options.fromContentElement);
229
226
 
230
227
  const transitionProperties = [
@@ -240,17 +237,17 @@ export function transitionElement(options) {
240
237
  'visibility',
241
238
  ];
242
239
 
243
- /** @type {Object.<string,string>} */
240
+ /** @type {Record<string,string>} */
244
241
  const oldFromShapeProperties = {};
245
- /** @type {Object.<string,string>} */
242
+ /** @type {Record<string,string>} */
246
243
  const oldToShapeProperties = {};
247
- /** @type {Object.<string,string>} */
244
+ /** @type {Record<string,string>} */
248
245
  const oldFromContentProperties = {};
249
- /** @type {Object.<string,string>} */
246
+ /** @type {Record<string,string>} */
250
247
  const oldToContentProperties = {};
251
- /** @type {Object.<string,string>} */
248
+ /** @type {Record<string,string>} */
252
249
  const newFromShapeProperties = {};
253
- transitionProperties.forEach((prop) => {
250
+ for (const prop of transitionProperties) {
254
251
  oldFromShapeProperties[prop] = options.fromShapeElement.style.getPropertyValue(prop);
255
252
  oldToShapeProperties[prop] = options.toShapeElement.style.getPropertyValue(prop);
256
253
  oldFromContentProperties[prop] = options.fromContentElement.style.getPropertyValue(prop);
@@ -298,7 +295,7 @@ export function transitionElement(options) {
298
295
  } else {
299
296
  newFromShapeProperties[prop] = toStyleSyle.getPropertyValue(prop);
300
297
  }
301
- });
298
+ }
302
299
 
303
300
  options.fromShapeElement.setAttribute('mdw-transition-busy', '');
304
301
  options.toShapeElement.setAttribute('mdw-transition-busy', '');
@@ -326,7 +323,7 @@ export function transitionElement(options) {
326
323
  options.toShapeElement.style.setProperty('visibility', 'visible');
327
324
 
328
325
  const revertFunction = () => {
329
- transitionProperties.forEach((prop) => {
326
+ for (const prop of transitionProperties) {
330
327
  if (oldFromShapeProperties[prop] == null) {
331
328
  options.fromShapeElement.style.removeProperty(prop);
332
329
  } else {
@@ -347,22 +344,16 @@ export function transitionElement(options) {
347
344
  } else {
348
345
  options.toContentElement.style.setProperty(prop, oldToContentProperties[prop]);
349
346
  }
350
- });
347
+ }
351
348
  };
352
349
 
353
- nextTick(() => {
354
- nextTick(() => {
355
- let calculatedDuration = options.duration;
356
- if (calculatedDuration == null) {
357
- if (shapeTransform.scaleX * shapeTransform.scaleY >= 1) {
358
- calculatedDuration = 300; // expand
359
- } else {
360
- calculatedDuration = 250; // collapse
361
- }
362
- }
350
+ requestAnimationFrame(() => {
351
+ requestAnimationFrame(() => {
352
+ const calculatedDuration = options.duration
353
+ ?? ((shapeTransform.scaleX * shapeTransform.scaleY >= 1) ? EXPAND_DURATION_MS : COLLAPSE_DURATION_MS);
363
354
  const totalDuration = calculatedDuration.toString(10);
364
- const fadeInTime = (calculatedDuration * 0.70).toString(10);
365
- const fadeOutTime = (calculatedDuration * 0.30).toString(10);
355
+ const fadeInTime = (calculatedDuration * 0.7).toString(10);
356
+ const fadeOutTime = (calculatedDuration * 0.3).toString(10);
366
357
  const transformTransition = transitionProperties
367
358
  .filter((prop) => prop !== 'transform-origin' && prop !== 'opacity' && prop !== 'transition')
368
359
  .map((prop) => `${prop} ${totalDuration}ms cubic-bezier(0.4, 0.0, 0.2, 1) 0s`)
@@ -374,27 +365,34 @@ export function transitionElement(options) {
374
365
  ].join(', ');
375
366
 
376
367
  options.fromShapeElement.style.setProperty('transition', transformTransition);
377
- transitionProperties.forEach((prop) => {
378
- if (prop === 'transform') {
379
- options.fromShapeElement.style.setProperty('transform', shapeTransform.toString());
380
- } else if (prop === 'transition') {
381
- // noop;
382
- } else if (prop === 'transform-origin') {
383
- options.fromShapeElement.style.setProperty('transform-origin', '0 0 0');
384
- } else if (prop === 'z-index') {
385
- options.fromShapeElement.style.setProperty('z-index', '8');
386
- } else if (prop === 'visibility') {
387
- options.fromShapeElement.style.setProperty('visibility', 'hidden');
388
- } else if (newFromShapeProperties[prop] == null) {
389
- options.fromShapeElement.style.removeProperty(prop);
390
- } else {
391
- options.fromShapeElement.style.setProperty(prop, newFromShapeProperties[prop]);
368
+ for (const prop of transitionProperties) {
369
+ switch (prop) {
370
+ case 'transform': {
371
+ options.fromShapeElement.style.setProperty('transform', shapeTransform.toString());
372
+ continue;
373
+ }
374
+ case 'transition': continue;
375
+ case 'transform-origin':
376
+ options.fromShapeElement.style.setProperty('transform-origin', '0 0 0');
377
+ continue;
378
+ case 'z-index':
379
+ options.fromShapeElement.style.setProperty('z-index', '8');
380
+ continue;
381
+ case 'visibility':
382
+ options.fromShapeElement.style.setProperty('visibility', 'hidden');
383
+ continue;
384
+ default:
385
+ if (newFromShapeProperties[prop] == null) {
386
+ options.fromShapeElement.style.removeProperty(prop);
387
+ } else {
388
+ options.fromShapeElement.style.setProperty(prop, newFromShapeProperties[prop]);
389
+ }
392
390
  }
393
- });
391
+ }
394
392
 
395
- nextTick(() => {
393
+ requestAnimationFrame(() => {
396
394
  buildTransitionEndListener(options.fromShapeElement, 'transform', () => {
397
- transitionProperties.forEach((prop) => {
395
+ for (const prop of transitionProperties) {
398
396
  if (prop === 'transition') {
399
397
  options.toShapeElement.style.setProperty('transition', 'none');
400
398
  options.toContentElement.style.setProperty('transition', 'none');
@@ -411,9 +409,8 @@ export function transitionElement(options) {
411
409
  }
412
410
  }
413
411
 
414
- if (prop === 'visibility' && !options.revertFrom) {
415
- return;
416
- }
412
+ if (prop === 'visibility' && !options.revertFrom) continue;
413
+
417
414
  if (oldFromContentProperties[prop] == null) {
418
415
  options.fromContentElement.style.removeProperty(prop);
419
416
  } else {
@@ -424,11 +421,11 @@ export function transitionElement(options) {
424
421
  } else {
425
422
  options.fromShapeElement.style.setProperty(prop, oldFromShapeProperties[prop]);
426
423
  }
427
- });
424
+ }
428
425
  if (options.onTransitionEnd) {
429
426
  options.onTransitionEnd(options);
430
427
  }
431
- nextTick(() => {
428
+ requestAnimationFrame(() => {
432
429
  if (oldToShapeProperties.transition == null) {
433
430
  options.toShapeElement.style.removeProperty('transition');
434
431
  } else {
package/docs/_flex.scss CHANGED
@@ -1,22 +1,28 @@
1
1
  .display-flex {
2
2
  display: flex;
3
3
  }
4
+
4
5
  .flex-column {
5
6
  display: flex;
6
7
  flex-direction: column;
7
8
  }
9
+
8
10
  [flex-column] {
9
11
  flex-direction: column;
10
12
  }
13
+
11
14
  [flex-justify-content="center"] {
12
15
  justify-content: center;
13
16
  }
17
+
14
18
  [flex-align-items="center"] {
15
19
  align-items: center;
16
20
  }
21
+
17
22
  .flex-wrap {
18
23
  flex-wrap: wrap;
19
24
  }
25
+
20
26
  .flex-1 {
21
27
  flex: 1;
22
- }
28
+ }
@@ -57,10 +57,10 @@ export function setAltTheme(value, button) {
57
57
  const items = document.head.getElementsByTagName('link');
58
58
  for (let i = 0; i < items.length; i += 1) {
59
59
  const stylesheet = items.item(i);
60
- if (stylesheet.href.indexOf(value ? 'theme-colored' : 'theme-default') !== -1) {
60
+ if (stylesheet.href.includes(value ? 'theme-colored' : 'theme-default')) {
61
61
  stylesheet.disabled = false;
62
62
  }
63
- if (stylesheet.href.indexOf(value ? 'theme-default' : 'theme-colored') !== -1) {
63
+ if (stylesheet.href.includes(value ? 'theme-default' : 'theme-colored')) {
64
64
  stylesheet.disabled = true;
65
65
  }
66
66
  }
@@ -11,19 +11,17 @@
11
11
  if (value === false || value == null) return false;
12
12
  return `${key}="${value}"`
13
13
  }).filter(v=>v).join(' ')-%>>
14
- <div class="mdw-appbar__action">
15
- <div class="mdw-appbar__start">
16
- <%_~ it?.start?.map((icon) => includeFile(T, { button: {
17
- class:'material-icons', icon:true, text:icon }})).join(' ') ?? '' _%>
18
- </div>
19
- <div class="mdw-appbar__title">
20
- <%_~ it?.body ?? '' %><%= it?.text ?? '' _%>
21
- </div>
22
- <div class="mdw-appbar__end">
23
- <%_~ it?.end?.map((icon) => includeFile(T, { button:{
24
- class:'material-icons', icon:true, text:icon,
25
- attributes: { 'mdw-more-button': icon === 'more_vert' }
26
- }})).join(' ') ?? '' _%>
27
- </div>
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(' ') ?? '' _%>
28
26
  </div>
29
27
  </div>
@@ -11,15 +11,14 @@
11
11
  <meta name="theme-color" content="#C2185B">
12
12
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
13
13
  <meta name="apple-mobile-web-app-capable" content="yes">
14
+
14
15
  <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
15
- <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,400,500">
16
- <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Merriweather:300,400,500">
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">
17
18
  <link rel="stylesheet" href="docs.min.css">
18
- <link rel="stylesheet" href="spec.min.css">
19
+ <link rel="stylesheet" href="framework.min.css">
19
20
  <link rel="stylesheet" href="theme-default.min.css" title="Default Theme">
20
- <link rel="stylesheet" href="theme-default-fallbacks.min.css" media="all\0" title="Default Theme">
21
21
  <link rel="stylesheet" disabled href="theme-colored.min.css" title="Colored Theme">
22
- <link rel="stylesheet" disabled href="theme-colored-fallbacks.min.css" media="all\0" title="Colored Theme">
23
22
  <script src="prerender.min.js"></script>
24
23
  </head>
25
24
 
@@ -91,46 +90,44 @@
91
90
  <a class="mdw-layout__scrim" href="#" tabindex="-1"></a>
92
91
  <div class="mdw-layout__appbar mdw-appbar mdw-theme" mdw-autohide="mobile tablet" mdw-surface="secondary 500" mdw-dark>
93
92
  <div class="mdw-layout__appbar-shape"></div>
94
- <div class="mdw-appbar__action">
95
- <div class="mdw-appbar__start">
96
- <div class="mdw-tooltip__wrapper">
97
- <%~ includeFile(T, { button: {
98
- class: 'mdw-tooltip__target material-icons mdw-layout__navdrawer-toggle',
99
- text:'menu', icon:true, attributes: { href:"#docs-navdrawer" },
100
- }}) %>
101
- <div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark mdw-align="start">Menu</div>
102
- </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>
103
124
  </div>
104
- <div class="mdw-appbar__title"><%~ it.page %></div>
105
- <div class="mdw-appbar__end" id="docs-menu-buttons">
106
- <div class="mdw-tooltip__wrapper">
107
- <%~ includeFile(T, { button: {
108
- id: 'altThemeButton', class: 'mdw-tooltip__target material-icons',
109
- text:'palette', icon:true, attributes: { 'mdw-overlay-default':'medium', 'mdw-overlay-off':'activated', 'aria-pressed':'false' },
110
- }}) %>
111
- <div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark mdw-align="end">Alt Theme</div>
112
- </div>
113
- <div class="mdw-tooltip__wrapper">
114
- <%~ includeFile(T, { button: {
115
- id: 'darkModeButton', class: 'mdw-tooltip__target material-icons',
116
- text: 'brightness_3', icon: true, attributes: { 'mdw-overlay-default':'medium', 'mdw-overlay-off':'activated', 'aria-pressed':'false' },
117
- }}) %>
118
- <div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark mdw-align="end">Dark Mode</div>
119
- </div>
120
- <div class="mdw-tooltip__wrapper">
121
- <%~ includeFile(T, { button: {
122
- id: 'rtlButton', class: 'mdw-tooltip__target material-icons',
123
- text: 'format_align_right', icon: true, attributes: { 'mdw-overlay-default': 'medium', 'mdw-overlay-off':'activated', 'aria-pressed':'false' },
124
- }}) %>
125
- <div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark mdw-align="end">Right-to-Left</div>
126
- </div>
127
- <div class="mdw-tooltip__wrapper">
128
- <%~ includeFile(T, { button: {
129
- id: 'largeFontButton', class: 'mdw-tooltip__target material-icons',
130
- text: 'format_size', icon: true, attributes: { 'mdw-overlay-default': 'medium', 'mdw-overlay-off':'activated', 'aria-pressed':'false' },
131
- }}) %>
132
- <div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark mdw-align="end">200% Text</div>
133
- </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>
134
131
  </div>
135
132
  </div>
136
133
  </div>
@@ -1,5 +1,3 @@
1
- import { iterateArrayLike } from '../core/dom.js';
2
-
3
1
  /**
4
2
  * @param {Element|HTMLElement} element
5
3
  * @param {boolean} [pug=false]
@@ -12,19 +10,19 @@ function convertElementToCode(element, pug = false, linePrefix = '') {
12
10
  const attributes = [];
13
11
  /** @type {string[]} */
14
12
  const classes = [];
15
- iterateArrayLike(element.classList, (c) => {
13
+ for (const c of element.classList) {
16
14
  classes.push(c);
17
- });
18
- iterateArrayLike(element.attributes, (attr) => {
15
+ }
16
+ for (const attr of element.attributes) {
19
17
  if (attr.name === 'class') {
20
- return;
18
+ continue;
21
19
  }
22
20
  if (attr.value.length) {
23
21
  attributes.push(`${attr.name}="${attr.value}"`);
24
22
  } else {
25
23
  attributes.push(attr.name);
26
24
  }
27
- });
25
+ }
28
26
  attributes.sort();
29
27
  const syntaxItems = [
30
28
  htmlType,
@@ -33,36 +31,33 @@ function convertElementToCode(element, pug = false, linePrefix = '') {
33
31
  ];
34
32
  const openingHTMLLine = pug
35
33
  ? `${htmlType === 'div' && classes.length ? '' : htmlType}${classes.length ? `.${classes.join('.')}` : ''}${attributes.length ? `(${attributes.join(' ')})` : ''}`
36
- : `<${syntaxItems.filter((item) => item).join(' ').trim()}>`;
34
+ : `<${syntaxItems.filter(Boolean).join(' ').trim()}>`;
37
35
  const closingHTMLLine = pug ? '' : `</${htmlType}>`;
38
36
  const lines = [openingHTMLLine];
39
37
  /** @type {string[]} */
40
38
  const innerLines = [];
41
39
  let onlyText = true;
42
- iterateArrayLike(element.childNodes, (child) => {
40
+ for (const child of element.childNodes) {
43
41
  let lineText;
44
42
  if (child instanceof HTMLElement) {
45
43
  lineText = convertElementToCode(child, pug, ` ${linePrefix}`);
46
44
  if (lineText.trim()) {
47
45
  onlyText = false;
48
46
  }
49
- } else if (child.nodeValue) {
50
- if (pug) {
51
- lineText = ` ${child.nodeValue}`;
52
- }
47
+ } else if (child.nodeValue && pug) {
48
+ lineText = ` ${child.nodeValue}`;
53
49
  }
54
50
  if (lineText && lineText.trim()) {
55
51
  innerLines.push(lineText);
56
52
  }
57
- });
53
+ }
58
54
  if (onlyText) {
59
55
  if (pug) {
60
56
  return `${linePrefix + lines.join('')} ${innerLines.join('').trim()}`;
61
57
  }
62
58
  return linePrefix + lines.join('') + innerLines.join('').trim() + closingHTMLLine;
63
59
  }
64
- innerLines.forEach((line) => lines.push(line));
65
- lines.push(linePrefix + closingHTMLLine);
60
+ lines.push(...innerLines, linePrefix + closingHTMLLine);
66
61
  return linePrefix + lines.filter((line) => line.trim()).join('\n');
67
62
  }
68
63
 
@@ -73,17 +68,17 @@ function convertElementToCode(element, pug = false, linePrefix = '') {
73
68
  */
74
69
  function changeElementTagName(element, tagname) {
75
70
  const newElement = document.createElement(tagname);
76
- for (let i = element.attributes.length - 1; i >= 0; i -= 1) {
71
+ let i = element.attributes.length;
72
+ while (i--) {
77
73
  const attr = element.attributes.item(i);
78
- /** @type {Attr} */
79
- const clonedAttr = (attr.cloneNode());
74
+ const clonedAttr = /** @type {Attr} */ (attr.cloneNode());
80
75
  newElement.attributes.setNamedItem(clonedAttr);
81
76
  }
82
77
  while (element.firstChild) {
83
78
  newElement.appendChild(element.firstChild);
84
79
  }
85
80
 
86
- element.parentElement.replaceChild(newElement, element);
81
+ element.replaceWith(newElement);
87
82
  return newElement;
88
83
  }
89
84