@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,28 +1,46 @@
1
- /* eslint-disable import/no-extraneous-dependencies */
2
- /* eslint-disable @typescript-eslint/no-var-requires */
1
+ /** eslint-env node */
3
2
 
4
- const fs = require('fs');
5
- const path = require('path');
3
+ import { readdirSync, statSync } from 'node:fs';
4
+ import { join as joinPath, dirname as parseDirname, resolve as resolvePath } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
6
 
7
- const eta = require('eta');
8
- const sass = require('sass');
9
- const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
10
-
11
- const isProduction = (process.env.NODE_ENV === 'production');
7
+ import * as eta from 'eta';
8
+ import sass from 'sass';
9
+ import TerserPlugin from 'terser-webpack-plugin';
10
+ import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
12
11
 
13
12
  /** @typedef {import('webpack').Configuration} WebpackConfiguration */
13
+ /** @typedef {import('webpack-dev-server').Configuration} DevServerConfiguration */
14
+
15
+ // eslint-disable-next-line no-underscore-dangle
16
+ const __dirname = parseDirname(fileURLToPath(import.meta.url));
17
+
18
+ /**
19
+ * @param {Record<string,string[]>} object
20
+ * @param {string} key
21
+ * @param {string} entry
22
+ * @return {void}
23
+ */
24
+ function addEntry(object, key, entry) {
25
+ if (!object[key]) {
26
+ object[key] = [entry];
27
+ } else if (!object[key].includes(entry)) {
28
+ object[key].push(entry);
29
+ }
30
+ }
14
31
 
15
32
  /**
16
33
  * @param {Object<string,string>} env
17
34
  * @return {Object}
18
35
  */
19
36
  function getComponentsConfig(env) {
37
+ const isProduction = env.prod != null || (process.env.NODE_ENV === 'production');
20
38
  const DEST = (isProduction ? 'dist/full' : 'test/full');
21
39
  return {
22
40
  entry: {
23
41
  materialdesignweb: [
24
- path.resolve(__dirname, './index.js'),
25
- path.resolve(__dirname, './index.scss'),
42
+ resolvePath(__dirname, './index.js'),
43
+ resolvePath(__dirname, './index.scss'),
26
44
  ],
27
45
  },
28
46
  mode: process.env.NODE_ENV || 'development',
@@ -32,7 +50,7 @@ function getComponentsConfig(env) {
32
50
  },
33
51
  output: {
34
52
  filename: 'materialdesignweb.min.js',
35
- path: path.resolve(__dirname, DEST),
53
+ path: resolvePath(__dirname, DEST),
36
54
  },
37
55
  plugins: [
38
56
  new BundleAnalyzerPlugin({
@@ -78,7 +96,9 @@ function getComponentsConfig(env) {
78
96
  * @param {Object<string,string>} env
79
97
  * @return {WebpackConfiguration}
80
98
  */
81
- function getDocsConfig(env) {
99
+ export default function getDocsConfig(env) {
100
+ const isProduction = env.prod != null || (process.env.NODE_ENV === 'production');
101
+ const DEST = (isProduction ? 'dist/docs' : 'test/docs');
82
102
  const plugins = [
83
103
  new BundleAnalyzerPlugin({
84
104
  analyzerMode: 'static',
@@ -88,40 +108,64 @@ function getDocsConfig(env) {
88
108
  logLevel: 'error',
89
109
  }),
90
110
  ];
91
- /** @type {Object.<string, string[]>} */
111
+ /** @type {Record<string, string[]>} */
92
112
  const entries = {};
93
- ['.', 'pwa', 'pages', 'themes'].map((folder) => path.join('./docs', folder))
94
- .forEach((folderPath) => fs.readdirSync(folderPath).forEach((filename) => {
113
+ for (const folder of ['.', 'pwa', 'pages', 'themes']) {
114
+ const folderPath = joinPath('./docs', folder);
115
+ for (const filename of readdirSync(folderPath)) {
95
116
  if (filename[0] === '_') {
96
- return;
117
+ continue;
97
118
  }
98
- if (filename.endsWith('.pug')) return;
99
- if (fs.statSync(path.join(folderPath, filename)).isDirectory()) {
100
- return;
119
+ if (filename.endsWith('.pug')) continue;
120
+ if (statSync(joinPath(folderPath, filename)).isDirectory()) {
121
+ continue;
101
122
  }
102
- const noExt = filename.substring(0, filename.lastIndexOf('.'));
103
- if (!entries[`${noExt}`]) {
104
- entries[`${noExt}`] = [];
105
- }
106
- entries[`${noExt}`].push(path.resolve(`${folderPath}/${filename}`));
107
- }));
108
- const DEST = (isProduction ? 'dist/docs' : 'test/docs');
123
+ const noExt = filename.slice(0, filename.lastIndexOf('.'));
124
+ const fullPath = resolvePath(folderPath, filename);
125
+ addEntry(entries, `${noExt}`, fullPath);
126
+ }
127
+ }
128
+
129
+ const etaLoader = {
130
+ loader: 'html-loader',
131
+ options: {
132
+ minimize: {
133
+ collapseBooleanAttributes: true,
134
+ minifyCSS: true,
135
+ removeAttributeQuotes: true,
136
+ removeComments: true,
137
+ },
138
+ sources: false,
139
+ preprocessor(content, loaderContext) {
140
+ return eta.render(content, {}, {
141
+ cache: false,
142
+ filename: loaderContext.resourcePath,
143
+ plugins: [{
144
+ processTemplate: (str, config) => {
145
+ loaderContext.addDependency(config.filename);
146
+ return str;
147
+ },
148
+ }],
149
+ });
150
+ },
151
+ },
152
+ };
109
153
 
110
- let port = parseInt(env.port ?? process.env.port, 10);
154
+ let port = Number.parseInt(env.port ?? process.env.port, 10);
111
155
  if (Number.isNaN(port)) {
112
156
  port = 8080;
113
157
  }
114
158
 
115
- /** @type {WebpackConfiguration} */
159
+ /** @type {WebpackConfiguration & {devServer: DevServerConfiguration}} */
116
160
  const webpackConfig = {
117
161
  entry: entries,
118
- context: path.resolve(__dirname, 'docs'),
162
+ context: resolvePath(__dirname, 'docs'),
119
163
  devtool: isProduction ? 'source-map' : 'nosources-source-map',
120
- mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
164
+ mode: isProduction ? 'production' : 'development',
121
165
  devServer: {
122
166
  host: '0.0.0.0',
123
167
  port,
124
- // static: path.resolve(__dirname, DEST),
168
+ // static: resolvePath(__dirname, DEST),
125
169
  compress: true,
126
170
  hot: false,
127
171
  liveReload: false,
@@ -130,16 +174,21 @@ function getDocsConfig(env) {
130
174
  output: {
131
175
  filename: '[name].min.js',
132
176
  chunkFilename: '[name].min.js',
133
- path: path.resolve(__dirname, DEST),
177
+ path: resolvePath(__dirname, DEST),
178
+ clean: true,
134
179
  },
135
180
  optimization: {
181
+ minimize: isProduction,
182
+ minimizer: [new TerserPlugin({
183
+ extractComments: false,
184
+ })],
136
185
  usedExports: true,
137
186
  splitChunks: {
138
187
  chunks: 'all',
139
188
  cacheGroups: {
140
189
  framework: {
141
190
  test(module, chunks) {
142
- if (module && module.resource && module.resource.match(/prerender/)) {
191
+ if (module && module.resource && /prerender/.test(module.resource)) {
143
192
  return false;
144
193
  }
145
194
  /** @type {import('webpack').ChunkGraph} */
@@ -148,10 +197,10 @@ function getDocsConfig(env) {
148
197
  if (chunkGraph && [...chunkGraph.getModuleChunksIterable(module)]?.some((chunk) => chunk.name.match(/prerender/))) {
149
198
  return false;
150
199
  }
151
- if (module && module.resource && module.resource.match(/[\\/]docs[\\/]/)) {
200
+ if (module && module.resource && /[/\\]docs[/\\]/.test(module.resource)) {
152
201
  return false;
153
202
  }
154
- if (module && module.resource && module.resource.match(/[\\/](components|core|adapters)[\\/]/)) {
203
+ if (module && module.resource && /[/\\](components|core|adapters)[/\\]/.test(module.resource)) {
155
204
  return true;
156
205
  }
157
206
  return false;
@@ -165,7 +214,7 @@ function getDocsConfig(env) {
165
214
  },
166
215
  default: {
167
216
  test(module, chunks) {
168
- if (module && module.resource && module.resource.match(/prerender/)) {
217
+ if (module && module.resource && /prerender/.test(module.resource)) {
169
218
  return false;
170
219
  }
171
220
  /** @type {import('webpack').ChunkGraph} */
@@ -173,7 +222,7 @@ function getDocsConfig(env) {
173
222
  if (chunkGraph && [...chunkGraph.getModuleChunksIterable(module)]?.some((chunk) => chunk.name.match(/prerender/))) {
174
223
  return false;
175
224
  }
176
- if (module && module.resource && module.resource.match(/[\\/]docs[\\/]/)) {
225
+ if (module && module.resource && /[/\\]docs[/\\]/.test(module.resource)) {
177
226
  return true;
178
227
  }
179
228
  return false;
@@ -191,19 +240,30 @@ function getDocsConfig(env) {
191
240
  module: {
192
241
  rules: [{
193
242
  test: /\.js$/,
243
+ resolve: { fullySpecified: false },
194
244
  exclude: /(node_modules|bower_components)/,
195
- use: [
196
- 'babel-loader?{"presets":["@babel/preset-env"]}',
197
- ],
245
+ use: [{
246
+ loader: 'babel-loader',
247
+ options: {
248
+ presets: ['@babel/preset-env'],
249
+ plugins: [
250
+ '@babel/plugin-proposal-optional-chaining',
251
+ '@babel/plugin-proposal-class-properties',
252
+ '@babel/plugin-proposal-private-methods',
253
+ '@babel/plugin-proposal-private-property-in-object',
254
+ ],
255
+ },
256
+ }],
198
257
  }, {
199
258
  test: /\.scss$/,
200
259
  use: [
201
260
  'file-loader?name=[name].min.css',
202
261
  'extract-loader',
203
- 'css-loader',
262
+ { loader: 'css-loader', options: { sourceMap: false } },
204
263
  {
205
264
  loader: 'postcss-loader',
206
265
  options: {
266
+ sourceMap: false,
207
267
  postcssOptions: {
208
268
  plugins: ['cssnano'],
209
269
  },
@@ -212,6 +272,7 @@ function getDocsConfig(env) {
212
272
  {
213
273
  loader: 'sass-loader',
214
274
  options: {
275
+ sourceMap: false,
215
276
  implementation: sass,
216
277
  },
217
278
  },
@@ -221,19 +282,7 @@ function getDocsConfig(env) {
221
282
  use: [
222
283
  'file-loader?&name=[name].html',
223
284
  'extract-loader',
224
- {
225
- loader: 'html-loader',
226
- options: {
227
- minimize: {
228
- collapseBooleanAttributes: true,
229
- minifyCSS: true,
230
- },
231
- attributes: false,
232
- preprocessor(content, loaderContext) {
233
- return eta.render(content, {}, { filename: loaderContext.resourcePath });
234
- },
235
- },
236
- },
285
+ etaLoader,
237
286
  ],
238
287
  }],
239
288
  },
@@ -246,12 +295,10 @@ function getDocsConfig(env) {
246
295
  * @param {Object<string,string>} env
247
296
  * @return {WebpackConfiguration}
248
297
  */
249
- function makeWebPackConfig(env = {}) {
298
+ export function makeWebPackConfig(env = {}) {
250
299
  const target = env.target || process.env.target;
251
300
  if (target === 'docs') {
252
301
  return getDocsConfig(env);
253
302
  }
254
303
  return getComponentsConfig(env);
255
304
  }
256
-
257
- module.exports = makeWebPackConfig;
@@ -1,27 +0,0 @@
1
- @use '../../core/theme/_mixins.scss' as theme;
2
-
3
- $themeValues: (
4
- text-color: (('foreground-light', 0.87), ('foreground-dark', 1.00)),
5
- border-color: (('primary', '700', 0.87), ('primary', '200', 1.0)),
6
- ) !default;
7
-
8
- @function getThemeValue($key, $type) {
9
- @return theme.getThemeValue('template', $themeValues, $key, $type);
10
- }
11
-
12
- @mixin addThemeRules($theme: null) {
13
- .mdw-template[mdw-surface] {
14
- border-color: templateThemeValue('border-color', null);
15
- }
16
- }
17
-
18
- @include theme.addComponentFallbackRules('light') {
19
- @include addThemeRules('light');
20
- }
21
- @include theme.addComponentFallbackRules('dark') {
22
- @include addThemeRules('dark');
23
- }
24
-
25
- @include theme.addComponentCSSVariableRules('template', $themeValues) {
26
- @include addThemeRules();
27
- }
@@ -1,52 +0,0 @@
1
- @use '../../core/_type.scss' as type;
2
-
3
- @mixin centerLabel {
4
- .mdw-textfield__label {
5
- @include type.addRules('subtitle');
6
-
7
- top: 50%;
8
-
9
- transform: translateY(-50%);
10
- }
11
-
12
- .mdw-textfield__outline-gap {
13
- &::before,
14
- :root[dir="rtl"] &::after {
15
- right: 50%;
16
- left: 0;
17
- }
18
-
19
- &::after,
20
- :root[dir="rtl"] &::before {
21
- right: 0;
22
- left: 50%;
23
- }
24
- }
25
- }
26
-
27
- @mixin floatLabel {
28
- .mdw-textfield__label {
29
- @include type.addRules('caption');
30
- top: 0;
31
-
32
- transform: translateY(0);
33
-
34
- .mdw-textfield[mdw-outlined] & {
35
- transform: translateY(-50%);
36
- }
37
- }
38
-
39
- .mdw-textfield__outline-gap {
40
- &::before,
41
- :root[dir="rtl"] &::after {
42
- right: 100%;
43
- left: 0;
44
- }
45
-
46
- &::after,
47
- :root[dir="rtl"] &::before {
48
- right: 0;
49
- left: 100%;
50
- }
51
- }
52
- }