mithril-materialized 2.0.0-beta.1 → 2.0.0-beta.11

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 (73) hide show
  1. package/README.md +287 -308
  2. package/dist/advanced.css +1888 -0
  3. package/dist/autocomplete.d.ts +3 -3
  4. package/dist/breadcrumb.d.ts +53 -0
  5. package/dist/button.d.ts +66 -21
  6. package/dist/carousel.d.ts +2 -2
  7. package/dist/chip.d.ts +2 -2
  8. package/dist/code-block.d.ts +2 -2
  9. package/dist/collapsible.d.ts +2 -2
  10. package/dist/collection.d.ts +2 -2
  11. package/dist/components.css +2310 -0
  12. package/dist/core.css +3402 -0
  13. package/dist/datatable.d.ts +291 -0
  14. package/dist/datepicker.d.ts +66 -0
  15. package/dist/dropdown.d.ts +2 -2
  16. package/dist/file-upload.d.ts +34 -0
  17. package/dist/floating-action-button.d.ts +2 -2
  18. package/dist/forms.css +2284 -0
  19. package/dist/index.css +1825 -184
  20. package/dist/index.d.ts +14 -1
  21. package/dist/index.esm.js +4752 -2143
  22. package/dist/index.js +4776 -2142
  23. package/dist/index.min.css +8 -0
  24. package/dist/index.umd.js +4776 -2142
  25. package/dist/input-options.d.ts +1 -1
  26. package/dist/input.d.ts +9 -10
  27. package/dist/label.d.ts +4 -2
  28. package/dist/material-box.d.ts +2 -2
  29. package/dist/modal.d.ts +2 -2
  30. package/dist/option.d.ts +4 -4
  31. package/dist/pagination.d.ts +2 -2
  32. package/dist/parallax.d.ts +2 -2
  33. package/dist/pickers.css +487 -0
  34. package/dist/pushpin.d.ts +32 -0
  35. package/dist/radio.d.ts +4 -4
  36. package/dist/search-select.d.ts +2 -2
  37. package/dist/select.d.ts +2 -2
  38. package/dist/sidenav.d.ts +76 -0
  39. package/dist/switch.d.ts +2 -2
  40. package/dist/tabs.d.ts +2 -4
  41. package/dist/theme-switcher.d.ts +49 -0
  42. package/dist/timepicker.d.ts +42 -0
  43. package/dist/toast.d.ts +45 -0
  44. package/dist/tooltip.d.ts +59 -0
  45. package/dist/types.d.ts +226 -0
  46. package/dist/utilities.css +3204 -0
  47. package/dist/wizard.d.ts +58 -0
  48. package/package.json +20 -9
  49. package/sass/components/_breadcrumb.scss +248 -0
  50. package/sass/components/_buttons.scss +3 -3
  51. package/sass/components/_cards.scss +10 -3
  52. package/sass/components/_chips.scss +8 -8
  53. package/sass/components/_collapsible.scss +8 -8
  54. package/sass/components/_datatable.scss +417 -0
  55. package/sass/components/_datepicker.scss +45 -14
  56. package/sass/components/_dropdown.scss +5 -5
  57. package/sass/components/_file-upload.scss +228 -0
  58. package/sass/components/_global.scss +13 -11
  59. package/sass/components/_modal.scss +5 -2
  60. package/sass/components/_navbar.scss +13 -5
  61. package/sass/components/_sidenav.scss +164 -7
  62. package/sass/components/_tabs.scss +5 -4
  63. package/sass/components/_theme-switcher.scss +120 -0
  64. package/sass/components/_theme-variables.scss +205 -0
  65. package/sass/components/_timepicker.scss +179 -87
  66. package/sass/components/_wizard.scss +416 -0
  67. package/sass/components/forms/_input-fields.scss +34 -12
  68. package/sass/components/forms/_radio-buttons.scss +10 -10
  69. package/sass/components/forms/_range.scss +5 -5
  70. package/sass/components/forms/_select.scss +9 -9
  71. package/sass/components/forms/_switches.scss +6 -6
  72. package/sass/materialize.scss +8 -0
  73. package/dist/pickers.d.ts +0 -130
package/README.md CHANGED
@@ -1,15 +1,51 @@
1
1
  # mithril-materialized
2
2
 
3
- A [materialize-css](https://materializecss.com) library for the Mithril framework (tested with v2.0 and higher, but presumably, it should work with v1.1.6 too), making it easier to use a Materialize theme in your application. The main focus of this library is on creating Mithril components for the more complicated Materialize components.
3
+ A Mithril.js component library inspired by [materialize-css](https://materializecss.com) design principles, [available on npm](https://www.npmjs.com/package/mithril-materialized). This library provides you with ready-to-use Mithril components that follow Material Design guidelines, with **no external JavaScript dependencies**.
4
4
 
5
- Supported components:
5
+ ## 🚀 v2.0.0 Beta - Major Release
6
+
7
+ This is a **major breaking release** that removes all external JavaScript dependencies, making the library completely self-contained and significantly reducing bundle sizes.
8
+
9
+ ### ✨ What's New
10
+
11
+ - **🔥 Zero External JS Dependencies**: No longer requires `materialize-css` JavaScript or `material-icons` fonts
12
+ - **📦 Smaller Bundle Size**: Reduced package size by eliminating external dependencies
13
+ - **🎨 Custom SVG Icons**: Built-in MaterialIcon component with custom SVG icons (caret, close)
14
+ - **⚡ Better Performance**: Direct implementations without jQuery or other heavy dependencies
15
+ - **🛠️ Enhanced Components**: Improved DatePicker and TimePicker with custom implementations
16
+ - **📱 Modern Architecture**: Factory components with proper TypeScript support
17
+ - **🎯 CSS-Only Styling**: Uses only CSS for styling - no JavaScript initialization needed
18
+
19
+ ### 💥 Breaking Changes from v1.x
20
+
21
+ - **Removed dependencies**: No longer requires `materialize-css` or `material-icons` packages
22
+ - **Component updates**: DatePicker and TimePicker now have custom implementations
23
+ - **Icon changes**: Library uses custom SVG icons. Material Icons font is supported too, but not required.
24
+ - **Installation**: Simpler installation process with fewer dependencies
25
+
26
+ ### 📈 Migration from v1.x
27
+
28
+ **Old installation (v1.x):**
29
+
30
+ ```bash
31
+ npm install materialize-css material-icons mithril mithril-materialized
32
+ ```
33
+
34
+ **New installation (v2.x):**
35
+
36
+ ```bash
37
+ npm install mithril mithril-materialized
38
+ ```
39
+
40
+ Your CSS imports can remain the same, but you no longer need the materialize-css JavaScript.
41
+
42
+ ## Supported Components
6
43
 
7
44
  - [Buttons](https://erikvullings.github.io/mithril-materialized/#!/buttons)
8
45
  - Button
9
46
  - FlatButton
10
47
  - RoundButton
11
48
  - SubmitButton
12
- - FloatingActionButton
13
49
  - [Inputs](https://erikvullings.github.io/mithril-materialized/#!/inputs)
14
50
  - TextInput
15
51
  - TextArea
@@ -21,7 +57,7 @@ Supported components:
21
57
  - RangeInput
22
58
  - Chips
23
59
  - [Pickers](https://erikvullings.github.io/mithril-materialized/#!/pickers)
24
- - DatePicker
60
+ - DatePicker (with optional week numbers)
25
61
  - TimePicker
26
62
  - [Selections](https://erikvullings.github.io/mithril-materialized/#!/selections)
27
63
  - Select
@@ -32,396 +68,339 @@ Supported components:
32
68
  - [Collections](https://erikvullings.github.io/mithril-materialized/#!/collections)
33
69
  - Basic, Link and Avatar Collections
34
70
  - Collapsible or accordion
35
- - [Modals](https://erikvullings.github.io/mithril-materialized/#!/modals)
71
+ - [Theme & Upload](https://erikvullings.github.io/mithril-materialized/#!/theme)
72
+ - ThemeSwitcher (light/dark/auto theme switching)
73
+ - ThemeToggle (simple light/dark toggle)
74
+ - FileUpload (drag-and-drop with validation and preview)
75
+ - [Navigation](https://erikvullings.github.io/mithril-materialized/#!/navigation)
76
+ - Sidenav (responsive navigation drawer)
77
+ - Breadcrumb (navigation path indicator)
78
+ - Wizard/Stepper (multi-step process guidance)
79
+ - [Others](https://erikvullings.github.io/mithril-materialized/#!/modals)
36
80
  - ModalPanel
37
- - [Miscellaneous](https://erikvullings.github.io/mithril-materialized/#!/misc)
38
- - Tabs
39
81
  - MaterialBox
40
82
  - Carousel
41
83
  - Pagination
84
+ - PaginationControls
42
85
  - Parallax
86
+ - Data & Tables
87
+ - DataTable (sorting, filtering, pagination, selection)
43
88
  - Additional
44
89
  - Label
45
90
  - HelperText
46
- - Not from Materialize-CSS
47
91
  - CodeBlock
48
92
  - SearchSelect, a searchable select dropdown
49
- - [Timeline](https://erikvullings.github.io/mithril-materialized/#!/timeline)
50
- - [MapEditor](https://erikvullings.github.io/mithril-materialized/#!/map_editor)
51
-
52
- ## Version history
53
-
54
- v1.2.0: Added Search select, a searchable select dropdown
55
-
56
- v1.1.7: Added option to add style to InputCheckbox and Options
57
-
58
- v0.17.1: bug fix
59
-
60
- - `Select` component also reacts when the `checkedId` property becomes undefined (previously, it would ignore it).
61
-
62
- v0.17.0
63
-
64
- - Breaking change: `Options` and `RadioButtons` used the `inline` property to put items horizontally. This is actually not needed, and it has been removed. Instead, use the `checkboxClass` to set the grid size of each cell.
65
-
66
- v0.16.3
67
-
68
- - `NumberInput` adds support for the `step` attribute, so you can use the number up/down to represent floats too.
69
-
70
- v0.16.2
71
-
72
- - Updated dependencies, fixed library vulnerabilities
73
-
74
- v0.16.1
75
-
76
- - `Select`, `Options`, and `RadioButtons`: The `checkedId` property can be used to change the selection in `onupdate` dynamically. Otherwise, it is treated the same as `initialValue` (which is only processed in `oninit`). This allows you to dynamically update the selections without recreating the component.
77
-
78
- v0.16.0
79
-
80
- - `Select` `disabled` status is computed dynamically in the view, not only in `oninit`.
81
- - `Select`, `Option`, `Radio`, `Kanban`: `onchange` is computed dynamically in the view, not only in `oninit`. As the `onchange` created a closure, new attributes were not always updated as expected.
82
-
83
- v0.15.4
84
-
85
- - `Pagination` component simplified implementation.
86
-
87
- v0.15.3
88
-
89
- - FIX: `Pickers` destroy them `onremove`.
90
-
91
- v0.15.2
92
-
93
- - FIX: `Pagination` did not properly compute the go forward disabled/enabled state.
94
-
95
- v0.15.1
96
-
97
- - FIX: `Pagination` did not highlight current item when item index exceeded size limit. Also updated example with actual routes.
98
-
99
- v0.15.0
100
-
101
- - NEW: `FloatingActionButton` created.
102
-
103
- v0.14.14
104
-
105
- - FIX: `Kanban` triggering too many `onchange` messages.
106
-
107
- v0.14.12
108
-
109
- - FIX: `Select` when using `multiple` keeps the dropdown open, but re-initialize select when the options change.
110
-
111
- v0.14.11
112
-
113
- - FIX: `Kanban` did not trigger `onChange` when disabled, but with editable properties.
114
-
115
- v0.14.10
116
-
117
- - FIX: `Chips` did not initialize properly when `onChange` was not specified (e.g. when disabled).
118
-
119
- v0.14.9
120
-
121
- - NEW: `PasswordInput` component to enter passwords.
122
-
123
- v0.14.8
124
-
125
- - FIX: `Tabs` component selection did not work in Edge due to the way the `select` function was implemented in materialize-css.
126
-
127
- v0.14.7
128
-
129
- - FIX: `Select` when using `multiple` keeps the dropdown open, `dropdownOptions` and `classes` are passed on creation.
130
- - `Select`, `Options`, `Radios` use `initialValue` instead of `checkedId` (which is deprecated but still working). The rationale is that the checked values are only read initially, when the component is created.
131
-
132
- v0.14.5
133
-
134
- - FIX: `Options` and `Radios` no longer use `h6` element for labels, so they behave more like other labels.
135
-
136
- v0.14.4
137
-
138
- - FIX: `Options` and `RadioButtons` did not listen to the `disabled` property.
139
-
140
- v0.14.3
93
+ - Icon, a simple wrapper for creating icons using material-icons font
94
+ - MaterialIcon, for creating the close/clear and caret as SVG
95
+
96
+ ## 📖 Usage Instructions
97
+
98
+ ### Quick Start
99
+
100
+ 1. **Install the package**:
101
+
102
+ ```bash
103
+ npm install mithril mithril-materialized
104
+ ```
105
+
106
+ 2. **Import the CSS** (optional, for Material Design styling):
107
+
108
+ ```typescript
109
+ import 'mithril-materialized/index.css';
110
+ ```
111
+
112
+ 3. **Use components in your app**:
113
+
114
+ ```typescript
115
+ import m from 'mithril';
116
+ import {
117
+ TextInput,
118
+ Button,
119
+ DatePicker,
120
+ DataTable,
121
+ ThemeToggle,
122
+ FileUpload,
123
+ Sidenav,
124
+ Breadcrumb,
125
+ Wizard
126
+ } from 'mithril-materialized';
127
+
128
+ const MyComponent = () => ({
129
+ view: () => m('.container', [
130
+ // Theme toggle in header
131
+ m('nav', [
132
+ m('.nav-wrapper', [
133
+ m('.right', m(ThemeToggle))
134
+ ])
135
+ ]),
136
+
137
+ // Breadcrumb navigation
138
+ m(Breadcrumb, {
139
+ items: [
140
+ { text: 'Home', href: '/' },
141
+ { text: 'Products', href: '/products' },
142
+ { text: 'Details', active: true }
143
+ ]
144
+ }),
145
+
146
+ // Form inputs
147
+ m(TextInput, {
148
+ label: 'Your name',
149
+ onchange: (value) => console.log(value)
150
+ }),
151
+ m(Button, {
152
+ label: 'Submit',
153
+ onclick: () => alert('Hello!')
154
+ }),
155
+
156
+ // File upload
157
+ m(FileUpload, {
158
+ accept: 'image/*',
159
+ multiple: true,
160
+ onFilesSelected: (files) => console.log(files)
161
+ })
162
+ ])
163
+ });
164
+ ```
141
165
 
142
- - When using a placeholder in an `input` field, the label should be active.
166
+ ### Integration with Build Tools
143
167
 
144
- v0.14.2
168
+ **Webpack/Vite/Parcel**: The library works out-of-the-box with modern bundlers.
145
169
 
146
- - `LinksCollection` sometimes created unwanted `href` attribute in links.
170
+ **CSS Framework Integration**: You can use the components with any CSS framework. The included CSS provides Material Design styling, but you can override it with your own styles.
147
171
 
148
- v0.14.1 Using Mithril v2
172
+ **TypeScript**: Full TypeScript support with comprehensive type definitions included.
149
173
 
150
- - Migrated backwards from Mithril v2.0.3 to v2.0.1 due to bugs in the released version.
151
- - When `Collection` items have an `id` property, the `id` property is used as key (e.g. for sorting the collection). You should not include a `key` property directly in your item's data, as explained [here](https://mithril.js.org/keys.html#avoid-passing-model-data-directly-to-components-if-the-model-uses-key-as-a-data-property).
174
+ See the [live documentation](https://erikvullings.github.io/mithril-materialized/index.html) for examples and component APIs.
152
175
 
153
- v0.14.0 Using Mithril v2
176
+ ## 🗺️ Roadmap & Planned Improvements
154
177
 
155
- - Upgrading all dependencies
156
- - `Pickers` now trigger `onchange` when closing.
157
- - Replace all links `oncreate: m.route.link` with `m.route.Link`.
178
+ ### 🚀 Phase 1: Core Optimizations & New Components (In Progress)
158
179
 
159
- v0.13.15 Patch
180
+ **✅ Completed:**
160
181
 
161
- - `Select` removed `console.warn` in library.
162
- - Updated `npm` scripts.
182
+ - Modular CSS architecture with tree-shaking support
183
+ - Dark theme system with CSS custom properties
184
+ - ✅ File upload component with drag-and-drop
185
+ - ✅ Theme switching components (ThemeSwitcher, ThemeToggle)
186
+ - ✅ Sidenav component with responsive behavior
187
+ - ✅ Breadcrumb navigation component
188
+ - ✅ Wizard/Stepper component for multi-step forms
163
189
 
164
- v0.13.14 Enhancements
190
+ **✅ Recently Completed:**
165
191
 
166
- - `Dropdown`: displayed text is truncated, so it doesn't overflow the button.
167
- - `Select` can receive options, e.g. `dropdownOptions: { container: document.body }` to display it properly in a `Modal`.
168
- - `Modal` examples added with `Select` and `Dropdown` components.
192
+ - DataTable component with sorting, filtering, and pagination
193
+ - Enhanced TypeScript definitions with better JSDoc comments
194
+ - Performance optimizations and bundle size improvements
169
195
 
170
- v0.13.13 Bug fix related to mithril RC7
196
+ ### 🎯 Phase 2: Advanced Components & Features
171
197
 
172
- - FIX `Kanban` key usage and drag-n-drop behaviour
198
+ **Data Display:**
173
199
 
174
- v0.13.12 Bug fix
200
+ - TreeView component for hierarchical data
201
+ - Card layouts with enhanced Material Design 3.0 styling
175
202
 
176
- - `Options` `checkboxClass` was not applied, so you could not align items properly.
203
+ **Input & Forms:**
177
204
 
178
- v0.13.11 Enhancements
205
+ - Advanced date range picker
206
+ - Autocomplete with async data loading
179
207
 
180
- - `Chips` component can now have an optional `label` (title) and `helperText` (under the input). Also the alignment has been fixed (the input used to be slightly wider than a regular input).
208
+ **Navigation & Layout:**
181
209
 
182
- v0.13.10 Enhancement
210
+ - AppBar/Toolbar component with responsive behavior
211
+ - Bottom navigation component for mobile apps
212
+ - Drawer/Sidebar component with overlay and push modes
213
+ - Grid system enhancements with CSS Grid support
183
214
 
184
- - Added IIFE and ESM output builds
185
- - Refactoring the code slightly
186
- - `Chips` now has a default `className: col s12`
215
+ ### 🔮 Phase 3: Modern Features & Integration
187
216
 
188
- v0.13.9 Enhancement
217
+ **Developer Experience:**
189
218
 
190
- - `ModalPanel` buttons' `onclick` handler now also receives the event, so you can prevent mithril from redrawing.
191
- - `ModalPanel` has a new handler, `onCreate` which can be used to receive the modal instance, so you can control it programmatically.
219
+ - Storybook integration for component documentation
220
+ - Figma design system integration
221
+ - CLI tools for component generation
222
+ - Better accessibility (ARIA) support throughout
192
223
 
193
- v0.13.8 Bug fix
224
+ **Performance & Optimization:**
194
225
 
195
- - `Select`, checkedId is evaluated in the view instead of `oninit`.
226
+ - Virtual scrolling for large lists
227
+ - Lazy loading component utilities
228
+ - Bundle analyzer and optimization tools
229
+ - CSS-in-JS runtime support option
196
230
 
197
- v0.13.6 Minor updates
231
+ **Ecosystem Integration:**
198
232
 
199
- - `Dropdown`, `Kanban`, `TimePicker`, `DatePicker` can be disabled.
233
+ - React compatibility layer
234
+ - Vue.js compatibility layer
235
+ - Web Components export option
236
+ - PWA-friendly components
200
237
 
201
- v0.13.5 Minor updates
238
+ ### 📊 Bundle Size Targets
202
239
 
203
- - `Dropdown` id, if not supplied, caused confusion when multiple `Dropdowns` were used on one page.
204
- - `Kanban` uses type information. New property, `editableIds`, which makes some properties also editable in the list view.
240
+ **Current Status (v2.0.0-beta.5):**
205
241
 
206
- v0.13.0 Breaking changes
242
+ - Total: 70KB gzipped (44KB JS + 26KB CSS)
243
+ - Modular CSS can reduce bundle by 30-50%
207
244
 
208
- - `Select` component now maintains the checkedIds internally, i.e. they are only processed during `oninit`. This is to create consistent behaviour with the `Options` and `RadioButtons` components.
209
- - `Select`, `Options`, `Dropdown` and `RadioButtons` are no longer of the generic type, since IDs can only be strings or numbers.
210
- - `ISelectOption` is removed, and is replaced by `IInputOption`, making it easier to switch between a radios, select and options.
211
- - `Options` has a property `checkedId`, similar to `RadioButtons` and `Select`, to specify the checked/selected IDs. This replaces the `IInputOption.isChecked` property, which has been removed.
245
+ **Phase 1 Targets:**
212
246
 
213
- NEW
247
+ - Core bundle: <40KB gzipped
248
+ - Modular approach: <25KB for typical apps
249
+ - Tree-shaking effectiveness: 60%+
214
250
 
215
- - [Kanban](https://erikvullings.github.io/mithril-materialized/#!/kanban): new component to render an editable list of items. Supports drag-and-drop between lists too, essentially allowing you to create a Kanban list. Hence the name.
216
- - `InputCheckbox`: label is optional
217
- - `Options` and `RadioButtons` are more consistent with respect to look and feel.
218
- - `Options` and `RadioButtons` support an `inline` property to align them horizontally.
219
- - `Select`, `Options`, and `RadioButtons` all use `IInputOption` to specify their options. An item can be disabled now.
251
+ **Long-term Goals:**
220
252
 
221
- v0.13.0 No breaking changes
253
+ - Individual components: <2KB each
254
+ - Micro-bundle support for single components
255
+ - Zero-runtime CSS option for static sites
222
256
 
223
- - `FileInput`: added `initialValue` to set the initial value more clearly, and added a clear button to remove the input.
257
+ ### 🤝 Contributing
224
258
 
225
- v0.12.2 No breaking changes
259
+ We welcome contributions! Priority areas for community involvement:
226
260
 
227
- - `Tabs`: added `contentClass` to add a class to the content.
261
+ 1. **High Impact**: New components (DataTable, Sidenav, Breadcrumb)
262
+ 2. **Medium Impact**: Accessibility improvements, performance optimizations
263
+ 3. **Documentation**: Examples, guides, API documentation
264
+ 4. **Testing**: Unit tests, visual regression tests, browser compatibility
228
265
 
229
- v0.12.1 No breaking changes
266
+ See our [contributing guide](CONTRIBUTING.md) for detailed information.
230
267
 
231
- - Simplified bundling after issues in `webpack`.
268
+ ### 📈 Performance Benchmarks
232
269
 
233
- v0.12.0 No breaking changes
270
+ **Bundle Size Comparison:**
234
271
 
235
- - `Tabs` component added, to show [tabs](https://erikvullings.github.io/mithril-materialized/#!/misc).
272
+ - mithril-materialized v2.0: 64KB gzipped
273
+ - Material-UI: ~350KB gzipped
274
+ - Materialize CSS + jQuery: ~180KB gzipped
275
+ - Vuetify: ~250KB gzipped
236
276
 
237
- v0.11.11 No breaking changes
277
+ **Runtime Performance:**
238
278
 
239
- - Bug fix: `TextArea` did not invoke `onchange` when the input was cleared.
240
- - Using Rollup as bundler, generating two bundles (ESM, regular JS).
279
+ - Component initialization: <5ms average
280
+ - Theme switching: <10ms for full page
281
+ - File upload processing: Real-time without blocking
241
282
 
242
- v0.11.8 No breaking changes
243
-
244
- - `Collection onclick` event was not registered properly.
245
-
246
- v0.11.7 No breaking changes
247
-
248
- - `Timeline` title can now be a Vnode too.
249
-
250
- v0.11.6 No breaking changes
251
-
252
- - `Select` control can now be disabled by adding the property `disabled: true` to the control's properties.
253
-
254
- v0.11.5 No breaking changes
255
-
256
- - `MapEditor` has an `onchange` callback to notify changes to the properties collection.
257
- - `MapEditor` allows you to set the column width (`keyClass`) for the key and value column (`keyValue`).
258
-
259
- v0.11.4 No breaking changes
260
-
261
- - FIX `CodeBlock` missed importing of `css`.
262
-
263
- v0.11.3 No breaking changes
264
-
265
- - FIX `Timeline`: Default date formatter did not add 1 to the months. See [here](https://www.w3schools.com/js/js_dates.asp).
266
- - FIX `MapEditor` when dealing with number inputs and the number was 0, it did not work properly.
267
- - FIX `NumberInput` when the number was 0, the label was not active (and overlaying the number).
268
-
269
- v0.11.2 No breaking changes
270
-
271
- - FIX Issue with `SecondaryContent` in `Collection` component: when no `href` was provided, it still created a `href=#!undefined` link.
272
-
273
- v0.11.1 No breaking changes
274
-
275
- - Improved generics of `Select` and `Dropdown` component
276
- - FIX Issue with `placeholder` in `Select` component: when no item was selected, it would not show the placeholder text.
277
-
278
- v0.11.0 New component, `Timeline`
279
-
280
- - Added a `Timeline` component to render vertical timelines.
281
- - `Collection` now accepts other parameters, e.g. styles.
282
- - All `css` styles are extracted into separate `css` files, and imported in the component. This implies that you don't need to add the required CSS in your own application anymore (except for `materialisecss`, of course).
283
- - Added documentation using `Typedoc`. It can be found [here](https://erikvullings.github.io/mithril-materialized/typedoc/index.html).
284
-
285
- v0.10.0 New component, `MapEditor`
286
-
287
- - Added a new component, `MapEditor`, to edit a map of key-value pairs.
288
- - `InputCheckbox` can now be disabled.
289
- - Attributes are better dealt with and no longer end up as unused attributes of elements.
290
- - Fixed a bug for `TextInput`, where sometimes the `active` class was not added even if the `input` element had a value.
291
-
292
- v0.9.10 Breaking changes
293
-
294
- - Deprecated the use of all `contentClass` properties in favour of the mithril convention `className`.
295
-
296
- v0.9.9 Breaking changes
297
-
298
- - `ModalPanel`: it's description (i.e. the main content area of the modal) can be a `Vnode`.
299
- - `Select` does not use `contentClass` anymore, but instead uses the regular mithril `className` (but not `class`, since this is a reserved keyword in TypeScript).
300
-
301
- v0.9.6 No breaking changes
302
-
303
- - For a `Collection` with secondary content, do not create a SPA route (with a #!) but leave the URL as is.
304
-
305
- v0.9.5 No breaking changes
306
-
307
- - FIX `Select` bug when numeric option IDs were used and ID === 0, option was never selected.
308
-
309
- v0.9.4 No breaking changes
310
-
311
- - FIX `Collection` without headers did no longer render.
312
-
313
- v0.9.3 No breaking changes
314
-
315
- - `Collection` with links can now also contain a header.
316
- - `Collection` with no items and only a header will now just render the header
317
-
318
- v0.9.0 Breaking changes
319
-
320
- - `Collapsible` is now correctly spelled (used to be `Collabsible`, oops).
321
- - Added `Collection`, to create a collection of items: supports basic, link and avatar collections.
322
-
323
- v0.8.3 No breaking changes
324
-
325
- - `FileInput` component can be disabled, and accepts file types.
326
-
327
- v0.8.1 No breaking changes
328
-
329
- - Closes issue #1: Select issue with id === 0
330
- - MaterialBox can set height, passes attributes to wrapped image element
331
-
332
- v0.8.0 No breaking changes
333
-
334
- - `FileInput` component can specify `class` property on the `div` wrapper (default `col s12`) and `contentClass` property on the file input element.
335
-
336
- v0.7.0 Breaking changes for Dropdown component.
337
-
338
- - New `FileInput` component to upload one or more files.
339
- - `Dropdown` uses similar items as `Select`, and uses `checkedId` to select the item.
340
- - `Dropdown` items can now use an icon and dividers.
341
- - `Dropdown` can now have a helper text option and an icon prefix.
283
+ ## Build instructions
342
284
 
343
- v0.6.4 Breaking changes, bug fix.
285
+ This repository consists of two packages, combined using `lerna`: the `lib` package that is published to `npm`, as well as an `example` project which uses this library to display the Mithril components that it contains.
344
286
 
345
- - `Select` did not always return the proper id on selection changes with multiple elements.
287
+ To install the dependencies, you can use `npm i`, or, alternatively, use `pnpm m i` (assuming you have installed `pnpm` as alternative package manager using `npm i -g pnpm`) to perform a multi-repository install. Next, build everything using `npm start` and visit the documentation page on [http://localhost:1234](http://localhost:1234) in case port 1234 is not occupied already.
346
288
 
347
- v0.6.3 No breaking changes, bug fix.
289
+ ## 🎨 Styling & CSS
348
290
 
349
- - `Select` did not update dynamically when checkedId changed.
291
+ ### CSS Usage
350
292
 
351
- v0.6.2 No breaking changes
293
+ The library includes carefully crafted CSS that provides Material Design styling without external dependencies. You can import the ready-to-use CSS:
352
294
 
353
- - `Select` can use `M.FormSelectOptions`.
295
+ ```typescript
296
+ import 'mithril-materialized/index.css';
297
+ ```
354
298
 
355
- v0.6.1 No breaking changes
299
+ **Important**: The CSS styling is **completely independent** of the original materialize-css. This means:
356
300
 
357
- - `Select` can have `disabled` options, and `id` is optional (in which case the label is used).
358
- - `Select` can use a prefix icon.
301
+ - No conflicting styles from materialize-css
302
+ - Smaller CSS bundle size
303
+ - ✅ Custom optimizations for better performance
304
+ - ✅ No external font dependencies
359
305
 
360
- v0.6.0 No breaking changes
306
+ ### 🔥 NEW: Modular CSS Architecture
361
307
 
362
- - `Inputs` can now use `onkeyup`, `onkeydown`, and `onkeypress` events. They also return the value.
363
- - Additionally, they can use `readOnly`, `pattern` and `autocomplete` (does not always seem to work).
308
+ **Tree-shakable CSS modules** for optimal bundle sizes! Import only the CSS you need:
364
309
 
365
- v0.5.0 No breaking changes
310
+ ```typescript
311
+ // Option 1: Import everything (64KB total)
312
+ import 'mithril-materialized/index.css';
366
313
 
367
- - NEW: Pagination control
368
- - BUG FIX: `Input.onchange` would not fire if the input was cleared.
369
- - All options now derives from mithril's `Attributes`.
370
- - Using `FactoryComponent` type
314
+ // Option 2: Import only what you need (modular approach)
315
+ import 'mithril-materialized/core.css'; // Essential styles (18KB)
316
+ import 'mithril-materialized/forms.css'; // Form components only
317
+ import 'mithril-materialized/components.css'; // Interactive components
371
318
 
372
- v0.4.4 No breaking changes
319
+ // Option 3: Advanced components only when needed
320
+ import 'mithril-materialized/pickers.css'; // Date/Time pickers
321
+ import 'mithril-materialized/advanced.css'; // Carousel, sidenav, etc.
322
+ import 'mithril-materialized/utilities.css'; // Badges, icons, cards
323
+ ```
373
324
 
374
- - Do not pass attributes through, e.g. if you had a `m(FlatButton, { onupdate })`, the `onupdate` was passed through to the `HelperText` too.
325
+ **CSS Modules Available:**
375
326
 
376
- v0.4.3 No breaking changes
327
+ - `core.css` (18KB) - Essential foundation (normalize, grid, typography, variables)
328
+ - `components.css` - Interactive components (buttons, dropdowns, modals, tabs)
329
+ - `forms.css` - All form components (inputs, selects, switches, file upload)
330
+ - `pickers.css` - Date and time picker components
331
+ - `advanced.css` - Specialized components (carousel, sidenav, navbar, preloader)
332
+ - `utilities.css` - Visual utilities (badges, cards, icons, toast, chips)
377
333
 
378
- - The validate method for inputs now also accepts the HTMLInputElement
379
- - Removed a few left-over `console.log` statements.
334
+ **Bundle Size Optimization:**
380
335
 
381
- v0.4.2 No breaking changes
336
+ - Full bundle: 64KB gzipped (44KB JS + 20KB CSS)
337
+ - Modular approach can reduce CSS by 30-50%
338
+ - Use only `core.css` + specific modules for your use case
382
339
 
383
- - Added `required` and `aria-required="true"` attributes when the `required` or `isMandatory` property are set.
340
+ ### 🌓 Dark Theme Support
384
341
 
385
- v0.4.1 No breaking changes
342
+ Built-in dark theme support with CSS custom properties:
386
343
 
387
- - Updated all components to use the mithril `dom` attribute instead of performing a document query. This has two advantages: first of all, performance, since we do not need to query for an element we already have. Second, when implementing custom elements that have an `oncreate` function. Using document.query... will lead to no results.
344
+ ```typescript
345
+ import { ThemeManager, ThemeSwitcher } from 'mithril-materialized';
388
346
 
389
- v0.4.0 No breaking changes
347
+ // Programmatic theme control
348
+ ThemeManager.setTheme('dark'); // 'light' | 'dark' | 'auto'
349
+ ThemeManager.toggle(); // Toggle between light/dark
350
+ ThemeManager.getTheme(); // Get current theme
390
351
 
391
- - New components: MaterialBox, Collapsible or accordion, and Carousel
352
+ // UI Components
353
+ m(ThemeSwitcher, {
354
+ onThemeChange: (theme) => console.log('Theme:', theme)
355
+ });
392
356
 
393
- v0.3.0 Breaking changes
357
+ m(ThemeToggle); // Simple toggle button
358
+ ```
394
359
 
395
- - Buttons no longer use the `ui` class to specify additional properties like `onclick`. Instead, you can leverage the mithril attributes directly. See the example, `button-page`.
396
- - `contentClass` has been removed in favour of the default mithril `class` or `className` attribute.
397
- - The Icon function has been replaced by the `Icon` component. The `SmallIcon` and `PrefixedIcon` have been removed, as they can easily be created using the `Icon` component.
398
- - The `autofocus` attribute for inputs now also works on updates (by calling the element.focus() method).
399
- - The code has been split over multiple files, so it is easier to only import the components that you need.
360
+ **CSS Custom Properties**: All colors use CSS variables for runtime theme switching:
400
361
 
401
- v0.2.2
362
+ ```css
363
+ :root {
364
+ --mm-primary-color: #26a69a;
365
+ --mm-background-color: #ffffff;
366
+ --mm-text-primary: rgba(0, 0, 0, 0.87);
367
+ }
402
368
 
403
- - Validate function can return a custom validation message. Also, it is called in `onupdate`, so the validation occurs also when you just attach the validate function conditionally.
369
+ [data-theme="dark"] {
370
+ --mm-primary-color: #80cbc4;
371
+ --mm-background-color: #121212;
372
+ --mm-text-primary: rgba(255, 255, 255, 0.87);
373
+ }
374
+ ```
404
375
 
405
- v0.2.1
376
+ ### SASS Usage
406
377
 
407
- - Label field is optional for inputs.
408
- - Added autofocus function|property to input fields.
409
- - Added custom validation using the validate function|property to add valid/invalid label to an input.
410
- - Removed dependency on materialize-css (it is expected that it is imported via the main app).
378
+ For advanced customization, you can use the SASS source files directly:
411
379
 
412
- ## Usage instructions
380
+ ```css
381
+ // Import all SASS components
382
+ @import 'mithril-materialized/sass/materialize.scss';
413
383
 
414
- See the [documentation](https://erikvullings.github.io/mithril-materialized/index.html) for examples on how to use this library in your own application. Please note that the library does not include mithril, nor the materialize-css JavaScript or CSS, so you have to include them yourself, as documented.
384
+ // Or import individual components
385
+ @import 'mithril-materialized/sass/components/buttons';
386
+ @import 'mithril-materialized/sass/components/forms';
387
+ @import 'mithril-materialized/sass/components/grid';
388
+ ```
415
389
 
416
- ## Build instructions
390
+ **SASS Variables**: You can customize colors, spacing, and other design tokens by overriding SASS variables before importing:
417
391
 
418
- This repository consists of two packages, combined using `lerna`: the `lib` package that is published to `npm`, as well as an `example` project which uses this library to display the Mithril components that it contains.
392
+ ```css
393
+ // Customize Material Design variables
394
+ $primary-color: #2196F3;
395
+ $secondary-color: #FF9800;
419
396
 
420
- To install the dependencies, you can use `npm i`, or, alternatively, use `pnpm m i` (assuming you have installed `pnpm` as alternative package manager using `npm i -g pnpm`) to perform a multi-repository install. Next, build everything using `npm start` and visit the documentation page on [http://localhost:1234](http://localhost:1234) in case port 1234 is not occupied already.
397
+ // Then import the library
398
+ @import 'mithril-materialized/sass/materialize.scss';
399
+ ```
421
400
 
422
- ## CSS
401
+ ### Custom Styles
423
402
 
424
- Although I've tried to limit the CSS adaptations to a minimum, I needed to tweak certain parts to make it look better. Here are the styles I've added.
403
+ The library includes these additional styles for enhanced functionality:
425
404
 
426
405
  ```css
427
406
  /* For the switch */
@@ -429,7 +408,7 @@ Although I've tried to limit the CSS adaptations to a minimum, I needed to tweak
429
408
  .clear-10,
430
409
  .clear-15 {
431
410
  clear: both;
432
- /* overflow: hidden; Précaution pour IE 7 */
411
+ /* overflow: hidden; Precaution pour IE 7 */
433
412
  }
434
413
  .clear-10 {
435
414
  margin-bottom: 10px;