mtrl 0.2.6 → 0.2.8
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/demo/build.ts +349 -0
- package/demo/index.html +110 -0
- package/demo/main.js +448 -0
- package/demo/styles.css +239 -0
- package/index.ts +18 -0
- package/package.json +14 -3
- package/server.ts +86 -0
- package/src/components/badge/api.ts +70 -63
- package/src/components/badge/badge.ts +16 -2
- package/src/components/badge/config.ts +66 -13
- package/src/components/badge/features.ts +51 -42
- package/src/components/badge/index.ts +27 -2
- package/src/components/badge/types.ts +62 -30
- package/src/components/bottom-app-bar/bottom-app-bar.ts +154 -0
- package/src/components/bottom-app-bar/config.ts +29 -0
- package/src/components/bottom-app-bar/index.ts +17 -0
- package/src/components/bottom-app-bar/types.ts +114 -0
- package/src/components/button/api.ts +5 -0
- package/src/components/button/button.ts +0 -1
- package/src/components/button/config.ts +6 -2
- package/src/components/button/index.ts +10 -2
- package/src/components/button/types.ts +20 -2
- package/src/components/card/card.ts +13 -25
- package/src/components/card/config.ts +83 -30
- package/src/components/card/content.ts +8 -10
- package/src/components/card/features.ts +4 -3
- package/src/components/card/index.ts +29 -2
- package/src/components/card/types.ts +33 -22
- package/src/components/checkbox/config.ts +3 -4
- package/src/components/checkbox/index.ts +1 -2
- package/src/components/checkbox/types.ts +12 -3
- package/src/components/chip/api.ts +170 -221
- package/src/components/chip/chip.ts +34 -302
- package/src/components/chip/config.ts +1 -2
- package/src/components/chip/index.ts +10 -2
- package/src/components/chip/types.ts +224 -35
- package/src/components/datepicker/api.ts +265 -0
- package/src/components/datepicker/config.ts +141 -0
- package/src/components/datepicker/datepicker.ts +341 -0
- package/src/components/datepicker/index.ts +12 -0
- package/src/components/datepicker/render.ts +450 -0
- package/src/components/datepicker/types.ts +397 -0
- package/src/components/datepicker/utils.ts +289 -0
- package/src/components/dialog/api.ts +55 -21
- package/src/components/dialog/config.ts +12 -9
- package/src/components/dialog/dialog.ts +6 -3
- package/src/components/dialog/features.ts +345 -151
- package/src/components/dialog/index.ts +38 -8
- package/src/components/dialog/types.ts +40 -14
- package/src/components/divider/config.ts +81 -0
- package/src/components/divider/divider.ts +37 -0
- package/src/components/divider/features.ts +207 -0
- package/src/components/divider/index.ts +9 -0
- package/src/components/divider/types.ts +55 -0
- package/src/components/extended-fab/api.ts +141 -0
- package/src/components/extended-fab/config.ts +112 -0
- package/src/components/extended-fab/extended-fab.ts +125 -0
- package/src/components/extended-fab/index.ts +9 -0
- package/src/components/extended-fab/types.ts +304 -0
- package/src/components/fab/api.ts +97 -0
- package/src/components/fab/config.ts +93 -0
- package/src/components/fab/fab.ts +67 -0
- package/src/components/fab/index.ts +9 -0
- package/src/components/fab/types.ts +251 -0
- package/src/components/list/config.ts +4 -5
- package/src/components/list/features.ts +6 -7
- package/src/components/list/index.ts +7 -9
- package/src/components/list/list-item.ts +12 -13
- package/src/components/list/types.ts +50 -5
- package/src/components/list/utils.ts +30 -3
- package/src/components/menu/features/items-manager.ts +9 -9
- package/src/components/menu/features/positioning.ts +7 -7
- package/src/components/menu/features/visibility.ts +7 -7
- package/src/components/menu/index.ts +7 -9
- package/src/components/menu/menu-item.ts +6 -6
- package/src/components/menu/menu.ts +22 -0
- package/src/components/menu/types.ts +29 -10
- package/src/components/menu/utils.ts +67 -0
- package/src/components/navigation/api.ts +78 -50
- package/src/components/navigation/config.ts +22 -10
- package/src/components/navigation/features/items.ts +284 -0
- package/src/components/navigation/index.ts +0 -6
- package/src/components/navigation/nav-item.ts +70 -33
- package/src/components/navigation/navigation.ts +53 -3
- package/src/components/navigation/types.ts +117 -70
- package/src/components/progress/api.ts +2 -3
- package/src/components/progress/config.ts +2 -3
- package/src/components/progress/index.ts +0 -1
- package/src/components/progress/progress.ts +1 -2
- package/src/components/progress/types.ts +186 -33
- package/src/components/radios/config.ts +1 -1
- package/src/components/radios/index.ts +0 -1
- package/src/components/radios/types.ts +0 -7
- package/src/components/search/api.ts +203 -0
- package/src/components/search/config.ts +86 -0
- package/src/components/search/features/index.ts +4 -0
- package/src/components/search/features/search.ts +717 -0
- package/src/components/search/features/states.ts +169 -0
- package/src/components/search/features/structure.ts +197 -0
- package/src/components/search/index.ts +7 -0
- package/src/components/search/search.ts +52 -0
- package/src/components/search/types.ts +175 -0
- package/src/components/segmented-button/config.ts +80 -0
- package/src/components/segmented-button/index.ts +4 -0
- package/src/components/segmented-button/segment.ts +154 -0
- package/src/components/segmented-button/segmented-button.ts +249 -0
- package/src/components/segmented-button/types.ts +254 -0
- package/src/components/slider/accessibility.md +5 -5
- package/src/components/slider/api.ts +41 -120
- package/src/components/slider/config.ts +51 -47
- package/src/components/slider/features/handlers.ts +495 -0
- package/src/components/slider/features/index.ts +1 -2
- package/src/components/slider/features/slider.ts +66 -84
- package/src/components/slider/features/states.ts +195 -0
- package/src/components/slider/features/structure.ts +136 -206
- package/src/components/slider/features/ui.ts +145 -206
- package/src/components/slider/index.ts +2 -11
- package/src/components/slider/slider.ts +9 -12
- package/src/components/slider/types.ts +67 -26
- package/src/components/snackbar/config.ts +2 -3
- package/src/components/snackbar/constants.ts +0 -32
- package/src/components/snackbar/index.ts +0 -1
- package/src/components/snackbar/position.ts +9 -1
- package/src/components/snackbar/types.ts +122 -46
- package/src/components/switch/config.ts +2 -3
- package/src/components/switch/index.ts +0 -1
- package/src/components/switch/types.ts +3 -2
- package/src/components/tabs/config.ts +3 -4
- package/src/components/tabs/features.ts +4 -2
- package/src/components/tabs/index.ts +0 -15
- package/src/components/tabs/indicator.ts +73 -13
- package/src/components/tabs/tab-api.ts +12 -4
- package/src/components/tabs/tab.ts +18 -6
- package/src/components/tabs/types.ts +23 -5
- package/src/components/textfield/config.ts +2 -3
- package/src/components/textfield/index.ts +0 -1
- package/src/components/textfield/types.ts +17 -3
- package/src/components/timepicker/README.md +277 -0
- package/src/components/timepicker/api.ts +632 -0
- package/src/components/timepicker/clockdial.ts +482 -0
- package/src/components/timepicker/config.ts +228 -0
- package/src/components/timepicker/index.ts +3 -0
- package/src/components/timepicker/render.ts +613 -0
- package/src/components/timepicker/timepicker.ts +117 -0
- package/src/components/timepicker/types.ts +336 -0
- package/src/components/timepicker/utils.ts +241 -0
- package/src/components/tooltip/api.ts +1 -1
- package/src/components/tooltip/config.ts +27 -6
- package/src/components/tooltip/index.ts +0 -1
- package/src/components/tooltip/types.ts +13 -3
- package/src/components/top-app-bar/config.ts +83 -0
- package/src/components/top-app-bar/index.ts +11 -0
- package/src/components/top-app-bar/top-app-bar.ts +316 -0
- package/src/components/top-app-bar/types.ts +140 -0
- package/src/core/build/_ripple.scss +6 -6
- package/src/core/build/ripple.ts +72 -95
- package/src/core/compose/features/icon.ts +3 -1
- package/src/core/compose/features/ripple.ts +4 -1
- package/src/core/compose/features/textlabel.ts +23 -2
- package/src/core/dom/create.ts +5 -0
- package/src/index.ts +9 -0
- package/src/styles/abstract/_theme.scss +9 -1
- package/src/styles/components/_badge.scss +182 -0
- package/src/styles/components/_bottom-app-bar.scss +103 -0
- package/src/{components/button/_styles.scss → styles/components/_button.scss} +0 -10
- package/src/{components/checkbox/_styles.scss → styles/components/_checkbox.scss} +0 -2
- package/src/styles/components/_datepicker.scss +358 -0
- package/src/styles/components/_dialog.scss +259 -0
- package/src/styles/components/_divider.scss +57 -0
- package/src/styles/components/_extended-fab.scss +267 -0
- package/src/styles/components/_fab.scss +225 -0
- package/src/{components/navigation/_styles.scss → styles/components/_navigation.scss} +1 -0
- package/src/styles/components/_search.scss +306 -0
- package/src/styles/components/_segmented-button.scss +117 -0
- package/src/{components/slider/_styles.scss → styles/components/_slider.scss} +83 -24
- package/src/{components/switch/_styles.scss → styles/components/_switch.scss} +0 -2
- package/src/{components/tabs/_styles.scss → styles/components/_tabs.scss} +95 -33
- package/src/{components/textfield/_styles.scss → styles/components/_textfield.scss} +70 -67
- package/src/styles/components/_timepicker.scss +451 -0
- package/src/styles/components/_top-app-bar.scss +225 -0
- package/src/styles/main.scss +98 -49
- package/src/styles/themes/_autumn.scss +21 -0
- package/src/styles/themes/_base-theme.scss +61 -0
- package/src/styles/themes/_baseline.scss +58 -0
- package/src/styles/themes/_bluekhaki.scss +125 -0
- package/src/styles/themes/_brownbeige.scss +125 -0
- package/src/styles/themes/_browngreen.scss +125 -0
- package/src/styles/themes/_forest.scss +6 -0
- package/src/styles/themes/_greenbeige.scss +125 -0
- package/src/styles/themes/_material.scss +125 -0
- package/src/styles/themes/_ocean.scss +6 -0
- package/src/styles/themes/_sageivory.scss +125 -0
- package/src/styles/themes/_spring.scss +6 -0
- package/src/styles/themes/_summer.scss +5 -0
- package/src/styles/themes/_sunset.scss +5 -0
- package/src/styles/themes/_tealcaramel.scss +125 -0
- package/src/styles/themes/_winter.scss +6 -0
- package/src/components/badge/_styles.scss +0 -174
- package/src/components/badge/constants.ts +0 -30
- package/src/components/button/constants.ts +0 -11
- package/src/components/card/constants.ts +0 -84
- package/src/components/dialog/_styles.scss +0 -213
- package/src/components/dialog/constants.ts +0 -32
- package/src/components/menu/constants.ts +0 -154
- package/src/components/navigation/constants.ts +0 -200
- package/src/components/navigation/features/items.js +0 -192
- package/src/components/progress/constants.ts +0 -29
- package/src/components/slider/features/appearance.ts +0 -94
- package/src/components/slider/features/disabled.ts +0 -68
- package/src/components/slider/features/events.ts +0 -164
- package/src/components/slider/features/interactions.ts +0 -396
- package/src/components/slider/features/keyboard.ts +0 -233
- package/src/components/switch/constants.ts +0 -80
- package/src/components/tabs/constants.ts +0 -89
- package/src/core/collection/adapters/mongodb.js +0 -232
- /package/src/{components/card/_styles.scss → styles/components/_card.scss} +0 -0
- /package/src/{components/carousel/_styles.scss → styles/components/_carousel.scss} +0 -0
- /package/src/{components/chip/_styles.scss → styles/components/_chip.scss} +0 -0
- /package/src/{components/list/_styles.scss → styles/components/_list.scss} +0 -0
- /package/src/{components/menu/_styles.scss → styles/components/_menu.scss} +0 -0
- /package/src/{components/progress/_styles.scss → styles/components/_progress.scss} +0 -0
- /package/src/{components/radios/_styles.scss → styles/components/_radios.scss} +0 -0
- /package/src/{components/sheet/_styles.scss → styles/components/_sheet.scss} +0 -0
- /package/src/{components/snackbar/_styles.scss → styles/components/_snackbar.scss} +0 -0
- /package/src/{components/tooltip/_styles.scss → styles/components/_tooltip.scss} +0 -0
- /package/src/styles/utilities/{_color.scss → _colors.scss} +0 -0
package/demo/build.ts
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
// src/demo/build.ts
|
|
2
|
+
import { mkdir } from 'fs/promises'
|
|
3
|
+
import { existsSync, watch } from 'fs'
|
|
4
|
+
import { join, dirname } from 'path'
|
|
5
|
+
import { fileURLToPath } from 'url'
|
|
6
|
+
import * as sass from 'sass'
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
9
|
+
const isWatch = process.argv.includes('--watch')
|
|
10
|
+
const isProduction = process.argv.includes('--production') || process.env.NODE_ENV === 'production'
|
|
11
|
+
|
|
12
|
+
// Define consistent output paths
|
|
13
|
+
const DIST_DIR = join(__dirname, 'dist')
|
|
14
|
+
const STYLES_DIR = join(DIST_DIR, 'styles')
|
|
15
|
+
const JS_OUTPUT = join(DIST_DIR, 'bundle.js')
|
|
16
|
+
const CSS_OUTPUT = join(STYLES_DIR, 'main.css')
|
|
17
|
+
const HTML_SOURCE = join(__dirname, 'index.html')
|
|
18
|
+
const HTML_OUTPUT = join(DIST_DIR, 'index.html')
|
|
19
|
+
|
|
20
|
+
// Log build mode
|
|
21
|
+
console.log(`Building in ${isProduction ? 'PRODUCTION' : 'DEVELOPMENT'} mode`)
|
|
22
|
+
|
|
23
|
+
const compileSass = async () => {
|
|
24
|
+
try {
|
|
25
|
+
const inputFile = join(__dirname, '../src/styles/main.scss')
|
|
26
|
+
const outputFile = CSS_OUTPUT
|
|
27
|
+
|
|
28
|
+
console.log('┌─────────────────────────────────────────')
|
|
29
|
+
console.log('│ SASS Compilation')
|
|
30
|
+
console.log('│ Mode:', isProduction ? 'PRODUCTION' : 'DEVELOPMENT')
|
|
31
|
+
console.log('│ Input:', inputFile)
|
|
32
|
+
console.log('│ Output:', outputFile)
|
|
33
|
+
console.log('│ Minify:', isProduction ? 'Yes' : 'No')
|
|
34
|
+
console.log('└─────────────────────────────────────────')
|
|
35
|
+
|
|
36
|
+
const result = await sass.compileAsync(inputFile, {
|
|
37
|
+
loadPaths: [
|
|
38
|
+
join(__dirname, '../node_modules'),
|
|
39
|
+
join(__dirname, '../src/styles'),
|
|
40
|
+
join(__dirname, '..') // Add root directory to help resolve paths
|
|
41
|
+
],
|
|
42
|
+
style: isProduction ? 'compressed' : 'expanded',
|
|
43
|
+
sourceMap: !isProduction
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
await mkdir(dirname(outputFile), { recursive: true })
|
|
47
|
+
await Bun.write(outputFile, result.css)
|
|
48
|
+
|
|
49
|
+
if (result.sourceMap && !isProduction) {
|
|
50
|
+
await Bun.write(`${outputFile}.map`, JSON.stringify(result.sourceMap))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log('✓ SASS compilation successful')
|
|
54
|
+
console.log(` Size: ${(result.css.length / 1024).toFixed(2)} KB`)
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error('❌ SASS compilation failed:', error)
|
|
57
|
+
if (error.span) {
|
|
58
|
+
console.error(` Error in ${error.span.url}:${error.span.start.line}:${error.span.start.column}`)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const buildApp = async () => {
|
|
64
|
+
try {
|
|
65
|
+
console.log('┌─────────────────────────────────────────')
|
|
66
|
+
console.log('│ JavaScript Build')
|
|
67
|
+
console.log('│ Mode:', isProduction ? 'PRODUCTION' : 'DEVELOPMENT')
|
|
68
|
+
console.log('│ Minify:', isProduction ? 'Yes' : 'No')
|
|
69
|
+
console.log('│ Sourcemaps:', isProduction ? 'No' : 'Yes (inline)')
|
|
70
|
+
console.log('└─────────────────────────────────────────')
|
|
71
|
+
|
|
72
|
+
const jsResult = await Bun.build({
|
|
73
|
+
entrypoints: [join(__dirname, 'main.js')],
|
|
74
|
+
outdir: DIST_DIR,
|
|
75
|
+
minify: isProduction, // Only minify in production
|
|
76
|
+
sourcemap: isProduction ? 'none' : 'inline', // No sourcemaps in production
|
|
77
|
+
format: 'esm',
|
|
78
|
+
target: 'browser',
|
|
79
|
+
naming: {
|
|
80
|
+
entry: 'bundle.js'
|
|
81
|
+
},
|
|
82
|
+
// Add tree shaking in production
|
|
83
|
+
tree: isProduction ? true : undefined,
|
|
84
|
+
// Define production/development environment
|
|
85
|
+
define: {
|
|
86
|
+
'process.env.NODE_ENV': isProduction ? '"production"' : '"development"'
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
if (!jsResult.success) {
|
|
91
|
+
console.error('❌ JavaScript build failed')
|
|
92
|
+
console.error(jsResult.logs)
|
|
93
|
+
return false
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const jsSize = (await Bun.file(JS_OUTPUT).size) / 1024
|
|
97
|
+
console.log('✓ JavaScript build successful')
|
|
98
|
+
console.log(` Size: ${jsSize.toFixed(2)} KB`)
|
|
99
|
+
|
|
100
|
+
return true
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error('❌ JavaScript build error:', error)
|
|
103
|
+
return false
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const copyStaticFiles = async () => {
|
|
108
|
+
try {
|
|
109
|
+
console.log('┌─────────────────────────────────────────')
|
|
110
|
+
console.log('│ Copying Static Files')
|
|
111
|
+
console.log('└─────────────────────────────────────────')
|
|
112
|
+
|
|
113
|
+
// Copy HTML template
|
|
114
|
+
await Bun.write(HTML_OUTPUT, await Bun.file(HTML_SOURCE).text())
|
|
115
|
+
console.log('✓ Copied HTML template')
|
|
116
|
+
|
|
117
|
+
// Add other static files here if needed
|
|
118
|
+
// For example, copy images, fonts, etc.
|
|
119
|
+
|
|
120
|
+
return true
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error('❌ Error copying static files:', error)
|
|
123
|
+
return false
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Update timestamp file to trigger live reload when needed
|
|
128
|
+
const updateReloadTimestamp = async () => {
|
|
129
|
+
if (!isProduction) {
|
|
130
|
+
const reloadDir = join(DIST_DIR)
|
|
131
|
+
const reloadFile = join(reloadDir, 'reload')
|
|
132
|
+
await mkdir(reloadDir, { recursive: true })
|
|
133
|
+
await Bun.write(reloadFile, Date.now().toString())
|
|
134
|
+
console.log('🔄 Browser reload triggered')
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const setupWatchers = () => {
|
|
139
|
+
if (isProduction) {
|
|
140
|
+
console.log('Watch mode not available in production build')
|
|
141
|
+
return { watchJsFiles: () => {}, watchScssFiles: () => {}, watchHtmlFiles: () => {} }
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const jsWatchPaths = [
|
|
145
|
+
join(__dirname, 'main.js'),
|
|
146
|
+
join(__dirname, '../src') // Watch the entire src directory for changes
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
const scssWatchPaths = [
|
|
150
|
+
join(__dirname, '../src/styles')
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
const htmlWatchPaths = [
|
|
154
|
+
join(__dirname, 'index.html')
|
|
155
|
+
]
|
|
156
|
+
|
|
157
|
+
const watchJsFiles = () => {
|
|
158
|
+
// Use a debounce mechanism to prevent duplicate builds
|
|
159
|
+
let buildTimeout = null
|
|
160
|
+
const debouncedBuild = (filename) => {
|
|
161
|
+
if (buildTimeout) {
|
|
162
|
+
clearTimeout(buildTimeout)
|
|
163
|
+
}
|
|
164
|
+
buildTimeout = setTimeout(async () => {
|
|
165
|
+
console.log('\n📁 JavaScript file changed:', filename)
|
|
166
|
+
const success = await buildApp()
|
|
167
|
+
if (success) await updateReloadTimestamp()
|
|
168
|
+
buildTimeout = null
|
|
169
|
+
}, 100) // 100ms debounce time
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
jsWatchPaths.forEach(path => {
|
|
173
|
+
if (existsSync(path)) {
|
|
174
|
+
watch(path, { recursive: true }, (_, filename) => {
|
|
175
|
+
if (filename?.endsWith('.js') || filename?.endsWith('.ts')) {
|
|
176
|
+
debouncedBuild(filename)
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
} else {
|
|
180
|
+
console.warn(`⚠️ Watch path does not exist: ${path}`)
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const watchScssFiles = () => {
|
|
186
|
+
// Use a debounce mechanism to prevent duplicate compilations
|
|
187
|
+
let compileTimeout = null
|
|
188
|
+
const debouncedCompile = (filename) => {
|
|
189
|
+
if (compileTimeout) {
|
|
190
|
+
clearTimeout(compileTimeout)
|
|
191
|
+
}
|
|
192
|
+
compileTimeout = setTimeout(async () => {
|
|
193
|
+
console.log('\n📁 SCSS file changed:', filename)
|
|
194
|
+
await compileSass()
|
|
195
|
+
await updateReloadTimestamp()
|
|
196
|
+
compileTimeout = null
|
|
197
|
+
}, 100) // 100ms debounce time
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
scssWatchPaths.forEach(path => {
|
|
201
|
+
if (existsSync(path)) {
|
|
202
|
+
watch(path, { recursive: true }, (_, filename) => {
|
|
203
|
+
if (filename?.endsWith('.scss')) {
|
|
204
|
+
debouncedCompile(filename)
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
} else {
|
|
208
|
+
console.warn(`⚠️ Watch path does not exist: ${path}`)
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const watchHtmlFiles = () => {
|
|
214
|
+
// Watch HTML files and copy them when changed
|
|
215
|
+
let copyTimeout = null
|
|
216
|
+
const debouncedCopy = (filename) => {
|
|
217
|
+
if (copyTimeout) {
|
|
218
|
+
clearTimeout(copyTimeout)
|
|
219
|
+
}
|
|
220
|
+
copyTimeout = setTimeout(async () => {
|
|
221
|
+
console.log('\n📁 HTML file changed:', filename)
|
|
222
|
+
await copyStaticFiles()
|
|
223
|
+
await updateReloadTimestamp()
|
|
224
|
+
copyTimeout = null
|
|
225
|
+
}, 100) // 100ms debounce time
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
htmlWatchPaths.forEach(path => {
|
|
229
|
+
if (existsSync(path)) {
|
|
230
|
+
watch(path, { recursive: false }, (_, filename) => {
|
|
231
|
+
if (filename?.endsWith('.html')) {
|
|
232
|
+
debouncedCopy(filename)
|
|
233
|
+
}
|
|
234
|
+
})
|
|
235
|
+
} else {
|
|
236
|
+
console.warn(`⚠️ Watch path does not exist: ${path}`)
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
watchJsFiles,
|
|
243
|
+
watchScssFiles,
|
|
244
|
+
watchHtmlFiles
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const verifyOutput = async () => {
|
|
249
|
+
// Check if output files exist
|
|
250
|
+
const jsExists = existsSync(JS_OUTPUT)
|
|
251
|
+
const cssExists = existsSync(CSS_OUTPUT)
|
|
252
|
+
const htmlExists = existsSync(HTML_OUTPUT)
|
|
253
|
+
|
|
254
|
+
console.log('┌─────────────────────────────────────────')
|
|
255
|
+
console.log('│ Build Verification')
|
|
256
|
+
console.log('│ JavaScript:', jsExists ? '✓ OK' : '❌ Missing')
|
|
257
|
+
console.log('│ CSS:', cssExists ? '✓ OK' : '❌ Missing')
|
|
258
|
+
console.log('│ HTML:', htmlExists ? '✓ OK' : '❌ Missing')
|
|
259
|
+
console.log('└─────────────────────────────────────────')
|
|
260
|
+
|
|
261
|
+
// For production builds, check file sizes
|
|
262
|
+
if (isProduction && jsExists && cssExists) {
|
|
263
|
+
const jsStats = await Bun.file(JS_OUTPUT).size
|
|
264
|
+
const cssStats = await Bun.file(CSS_OUTPUT).size
|
|
265
|
+
const totalSize = jsStats + cssStats
|
|
266
|
+
|
|
267
|
+
console.log('┌─────────────────────────────────────────')
|
|
268
|
+
console.log('│ Production Build Stats')
|
|
269
|
+
console.log('│ JavaScript:', (jsStats / 1024).toFixed(2), 'KB')
|
|
270
|
+
console.log('│ CSS:', (cssStats / 1024).toFixed(2), 'KB')
|
|
271
|
+
console.log('│ Total Size:', (totalSize / 1024).toFixed(2), 'KB')
|
|
272
|
+
console.log('└─────────────────────────────────────────')
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return jsExists && cssExists && htmlExists
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const cleanDist = async () => {
|
|
279
|
+
try {
|
|
280
|
+
console.log('🧹 Cleaning dist directory...')
|
|
281
|
+
|
|
282
|
+
// Recreate the directories
|
|
283
|
+
await mkdir(DIST_DIR, { recursive: true })
|
|
284
|
+
await mkdir(STYLES_DIR, { recursive: true })
|
|
285
|
+
|
|
286
|
+
console.log('✓ Dist directory cleaned')
|
|
287
|
+
} catch (error) {
|
|
288
|
+
console.error('❌ Error cleaning dist directory:', error)
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const build = async () => {
|
|
293
|
+
try {
|
|
294
|
+
const startTime = Date.now()
|
|
295
|
+
|
|
296
|
+
console.log('┌───────────────────────────────────────────────')
|
|
297
|
+
console.log('│ 🚀 MTRL Demo Build Process')
|
|
298
|
+
console.log('│ Mode:', isProduction ? '🏭 PRODUCTION' : '🔧 DEVELOPMENT')
|
|
299
|
+
console.log('│ Watch:', isWatch ? '✓ Enabled' : '✗ Disabled')
|
|
300
|
+
console.log('└───────────────────────────────────────────────')
|
|
301
|
+
console.log('')
|
|
302
|
+
|
|
303
|
+
// Clean dist directory
|
|
304
|
+
await cleanDist()
|
|
305
|
+
|
|
306
|
+
// Create output directories
|
|
307
|
+
await mkdir(DIST_DIR, { recursive: true })
|
|
308
|
+
await mkdir(STYLES_DIR, { recursive: true })
|
|
309
|
+
|
|
310
|
+
// Build JavaScript
|
|
311
|
+
await buildApp()
|
|
312
|
+
|
|
313
|
+
// Compile SASS to CSS
|
|
314
|
+
await compileSass()
|
|
315
|
+
|
|
316
|
+
// Copy static files
|
|
317
|
+
await copyStaticFiles()
|
|
318
|
+
|
|
319
|
+
// Verify output
|
|
320
|
+
await verifyOutput()
|
|
321
|
+
|
|
322
|
+
// Update reload timestamp
|
|
323
|
+
await updateReloadTimestamp()
|
|
324
|
+
|
|
325
|
+
const buildTime = ((Date.now() - startTime) / 1000).toFixed(2)
|
|
326
|
+
|
|
327
|
+
if (isWatch && !isProduction) {
|
|
328
|
+
console.log('')
|
|
329
|
+
console.log('┌───────────────────────────────────────────────')
|
|
330
|
+
console.log('│ 👀 Watching for changes...')
|
|
331
|
+
console.log('└───────────────────────────────────────────────')
|
|
332
|
+
|
|
333
|
+
const { watchJsFiles, watchScssFiles, watchHtmlFiles } = setupWatchers()
|
|
334
|
+
watchJsFiles()
|
|
335
|
+
watchScssFiles()
|
|
336
|
+
watchHtmlFiles()
|
|
337
|
+
} else {
|
|
338
|
+
console.log('')
|
|
339
|
+
console.log('┌───────────────────────────────────────────────')
|
|
340
|
+
console.log(`│ ✅ Build completed in ${buildTime}s`)
|
|
341
|
+
console.log('└───────────────────────────────────────────────')
|
|
342
|
+
}
|
|
343
|
+
} catch (error) {
|
|
344
|
+
console.error('❌ Build failed with error:', error)
|
|
345
|
+
process.exit(1)
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
build()
|
package/demo/index.html
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Material Component Library Showcase</title>
|
|
7
|
+
<link rel="stylesheet" href="dist/styles.css">
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<header id="top-app-bar"></header>
|
|
11
|
+
|
|
12
|
+
<main class="content">
|
|
13
|
+
<section id="intro">
|
|
14
|
+
<h1>Material Component Library</h1>
|
|
15
|
+
<p>A lightweight and modular component library using functional composition patterns.</p>
|
|
16
|
+
</section>
|
|
17
|
+
|
|
18
|
+
<section id="buttons" class="component-section">
|
|
19
|
+
<h2>Buttons</h2>
|
|
20
|
+
<div class="component-row">
|
|
21
|
+
<div id="button-container"></div>
|
|
22
|
+
<div id="segmented-button-container"></div>
|
|
23
|
+
</div>
|
|
24
|
+
</section>
|
|
25
|
+
|
|
26
|
+
<section id="inputs" class="component-section">
|
|
27
|
+
<h2>Inputs</h2>
|
|
28
|
+
<div class="component-row">
|
|
29
|
+
<div id="checkbox-container"></div>
|
|
30
|
+
<div id="switch-container"></div>
|
|
31
|
+
<div id="radio-container"></div>
|
|
32
|
+
</div>
|
|
33
|
+
</section>
|
|
34
|
+
|
|
35
|
+
<section id="textfields" class="component-section">
|
|
36
|
+
<h2>Text Fields</h2>
|
|
37
|
+
<div class="component-row">
|
|
38
|
+
<div id="textfield-container"></div>
|
|
39
|
+
<div id="search-container"></div>
|
|
40
|
+
</div>
|
|
41
|
+
</section>
|
|
42
|
+
|
|
43
|
+
<section id="navigation" class="component-section">
|
|
44
|
+
<h2>Navigation</h2>
|
|
45
|
+
<div class="component-row align-top">
|
|
46
|
+
<div id="menu-container"></div>
|
|
47
|
+
<div id="tabs-container"></div>
|
|
48
|
+
<div id="navigation-container"></div>
|
|
49
|
+
</div>
|
|
50
|
+
</section>
|
|
51
|
+
|
|
52
|
+
<section id="feedback" class="component-section">
|
|
53
|
+
<h2>Feedback Components</h2>
|
|
54
|
+
<div class="component-row">
|
|
55
|
+
<div id="snackbar-container"></div>
|
|
56
|
+
<div id="tooltip-container"></div>
|
|
57
|
+
<div id="progress-container"></div>
|
|
58
|
+
</div>
|
|
59
|
+
</section>
|
|
60
|
+
|
|
61
|
+
<section id="containers" class="component-section">
|
|
62
|
+
<h2>Containers</h2>
|
|
63
|
+
<div class="component-row align-top">
|
|
64
|
+
<div id="card-container"></div>
|
|
65
|
+
<div id="dialog-container"></div>
|
|
66
|
+
<div id="sheet-container"></div>
|
|
67
|
+
</div>
|
|
68
|
+
</section>
|
|
69
|
+
|
|
70
|
+
<section id="indicators" class="component-section">
|
|
71
|
+
<h2>Indicators</h2>
|
|
72
|
+
<div class="component-row">
|
|
73
|
+
<div id="badge-container"></div>
|
|
74
|
+
<div id="chip-container"></div>
|
|
75
|
+
<div id="divider-container"></div>
|
|
76
|
+
</div>
|
|
77
|
+
</section>
|
|
78
|
+
|
|
79
|
+
<section id="complex" class="component-section">
|
|
80
|
+
<h2>Complex Components</h2>
|
|
81
|
+
<div class="component-row align-top">
|
|
82
|
+
<div id="carousel-container"></div>
|
|
83
|
+
<div id="date-picker-container"></div>
|
|
84
|
+
<div id="time-picker-container"></div>
|
|
85
|
+
</div>
|
|
86
|
+
</section>
|
|
87
|
+
|
|
88
|
+
<section id="actions" class="component-section">
|
|
89
|
+
<h2>Action Components</h2>
|
|
90
|
+
<div class="component-row">
|
|
91
|
+
<div id="fab-container"></div>
|
|
92
|
+
<div id="extended-fab-container"></div>
|
|
93
|
+
<div id="slider-container"></div>
|
|
94
|
+
</div>
|
|
95
|
+
</section>
|
|
96
|
+
|
|
97
|
+
<section id="lists" class="component-section">
|
|
98
|
+
<h2>Lists</h2>
|
|
99
|
+
<div class="component-row">
|
|
100
|
+
<div id="list-container"></div>
|
|
101
|
+
</div>
|
|
102
|
+
</section>
|
|
103
|
+
</main>
|
|
104
|
+
|
|
105
|
+
<footer id="bottom-app-bar"></footer>
|
|
106
|
+
|
|
107
|
+
<!-- Add type="module" to the script tag -->
|
|
108
|
+
<script type="module" src="dist/bundle.js"></script>
|
|
109
|
+
</body>
|
|
110
|
+
</html>
|