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

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 (68) hide show
  1. package/README.md +286 -306
  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 +10 -10
  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/datepicker.d.ts +66 -0
  14. package/dist/dropdown.d.ts +2 -2
  15. package/dist/file-upload.d.ts +34 -0
  16. package/dist/floating-action-button.d.ts +2 -2
  17. package/dist/forms.css +2284 -0
  18. package/dist/index.css +1483 -167
  19. package/dist/index.d.ts +12 -1
  20. package/dist/index.esm.js +3694 -1717
  21. package/dist/index.js +3714 -1716
  22. package/dist/index.min.css +8 -0
  23. package/dist/index.umd.js +3714 -1716
  24. package/dist/input-options.d.ts +1 -1
  25. package/dist/input.d.ts +9 -9
  26. package/dist/label.d.ts +4 -2
  27. package/dist/material-box.d.ts +2 -2
  28. package/dist/modal.d.ts +2 -2
  29. package/dist/option.d.ts +4 -4
  30. package/dist/pagination.d.ts +2 -2
  31. package/dist/parallax.d.ts +2 -2
  32. package/dist/pickers.css +487 -0
  33. package/dist/pushpin.d.ts +32 -0
  34. package/dist/radio.d.ts +4 -4
  35. package/dist/search-select.d.ts +2 -2
  36. package/dist/select.d.ts +2 -2
  37. package/dist/sidenav.d.ts +76 -0
  38. package/dist/switch.d.ts +2 -2
  39. package/dist/tabs.d.ts +2 -4
  40. package/dist/theme-switcher.d.ts +49 -0
  41. package/dist/timepicker.d.ts +42 -0
  42. package/dist/toast.d.ts +45 -0
  43. package/dist/tooltip.d.ts +59 -0
  44. package/dist/utilities.css +3197 -0
  45. package/dist/wizard.d.ts +58 -0
  46. package/package.json +16 -8
  47. package/sass/components/_breadcrumb.scss +248 -0
  48. package/sass/components/_buttons.scss +3 -3
  49. package/sass/components/_chips.scss +8 -8
  50. package/sass/components/_collapsible.scss +8 -8
  51. package/sass/components/_datepicker.scss +45 -14
  52. package/sass/components/_dropdown.scss +5 -5
  53. package/sass/components/_file-upload.scss +228 -0
  54. package/sass/components/_global.scss +7 -5
  55. package/sass/components/_modal.scss +5 -2
  56. package/sass/components/_navbar.scss +13 -5
  57. package/sass/components/_sidenav.scss +164 -7
  58. package/sass/components/_tabs.scss +5 -4
  59. package/sass/components/_theme-switcher.scss +120 -0
  60. package/sass/components/_theme-variables.scss +205 -0
  61. package/sass/components/_timepicker.scss +179 -87
  62. package/sass/components/_wizard.scss +416 -0
  63. package/sass/components/forms/_input-fields.scss +34 -12
  64. package/sass/components/forms/_radio-buttons.scss +10 -10
  65. package/sass/components/forms/_select.scss +8 -8
  66. package/sass/components/forms/_switches.scss +6 -6
  67. package/sass/materialize.scss +7 -0
  68. 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**: Uses custom SVG icons instead of Material Icons font
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,10 +68,16 @@ 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
@@ -43,385 +85,323 @@ Supported components:
43
85
  - Additional
44
86
  - Label
45
87
  - HelperText
46
- - Not from Materialize-CSS
47
88
  - CodeBlock
48
89
  - 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.
90
+ - Icon, a simple wrapper for creating icons using material-icons font
91
+ - MaterialIcon, for creating the close/clear and caret as SVG
92
+
93
+ ## 📖 Usage Instructions
94
+
95
+ ### Quick Start
96
+
97
+ 1. **Install the package**:
98
+
99
+ ```bash
100
+ npm install mithril mithril-materialized
101
+ ```
102
+
103
+ 2. **Import the CSS** (optional, for Material Design styling):
104
+
105
+ ```typescript
106
+ import 'mithril-materialized/index.css';
107
+ ```
108
+
109
+ 3. **Use components in your app**:
110
+
111
+ ```typescript
112
+ import m from 'mithril';
113
+ import {
114
+ TextInput,
115
+ Button,
116
+ DatePicker,
117
+ ThemeToggle,
118
+ FileUpload,
119
+ Sidenav,
120
+ Breadcrumb,
121
+ Wizard
122
+ } from 'mithril-materialized';
123
+
124
+ const MyComponent = () => ({
125
+ view: () => m('.container', [
126
+ // Theme toggle in header
127
+ m('nav', [
128
+ m('.nav-wrapper', [
129
+ m('.right', m(ThemeToggle))
130
+ ])
131
+ ]),
132
+
133
+ // Breadcrumb navigation
134
+ m(Breadcrumb, {
135
+ items: [
136
+ { text: 'Home', href: '/' },
137
+ { text: 'Products', href: '/products' },
138
+ { text: 'Details', active: true }
139
+ ]
140
+ }),
141
+
142
+ // Form inputs
143
+ m(TextInput, {
144
+ label: 'Your name',
145
+ onchange: (value) => console.log(value)
146
+ }),
147
+ m(Button, {
148
+ label: 'Submit',
149
+ onclick: () => alert('Hello!')
150
+ }),
151
+
152
+ // File upload
153
+ m(FileUpload, {
154
+ accept: 'image/*',
155
+ multiple: true,
156
+ onFilesSelected: (files) => console.log(files)
157
+ })
158
+ ])
159
+ });
160
+ ```
139
161
 
140
- v0.14.3
162
+ ### Integration with Build Tools
141
163
 
142
- - When using a placeholder in an `input` field, the label should be active.
164
+ **Webpack/Vite/Parcel**: The library works out-of-the-box with modern bundlers.
143
165
 
144
- v0.14.2
166
+ **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.
145
167
 
146
- - `LinksCollection` sometimes created unwanted `href` attribute in links.
168
+ **TypeScript**: Full TypeScript support with comprehensive type definitions included.
147
169
 
148
- v0.14.1 Using Mithril v2
170
+ See the [live documentation](https://erikvullings.github.io/mithril-materialized/index.html) for examples and component APIs.
149
171
 
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).
172
+ ## 🗺️ Roadmap & Planned Improvements
152
173
 
153
- v0.14.0 Using Mithril v2
174
+ ### 🚀 Phase 1: Core Optimizations & New Components (In Progress)
154
175
 
155
- - Upgrading all dependencies
156
- - `Pickers` now trigger `onchange` when closing.
157
- - Replace all links `oncreate: m.route.link` with `m.route.Link`.
176
+ **✅ Completed:**
158
177
 
159
- v0.13.15 Patch
178
+ - ✅ Modular CSS architecture with tree-shaking support
179
+ - ✅ Dark theme system with CSS custom properties
180
+ - ✅ File upload component with drag-and-drop
181
+ - ✅ Theme switching components (ThemeSwitcher, ThemeToggle)
182
+ - ✅ Sidenav component with responsive behavior
183
+ - ✅ Breadcrumb navigation component
184
+ - ✅ Wizard/Stepper component for multi-step forms
160
185
 
161
- - `Select` removed `console.warn` in library.
162
- - Updated `npm` scripts.
186
+ **🔄 Currently Working On:**
163
187
 
164
- v0.13.14 Enhancements
188
+ - 🔄 DataTable component with sorting, filtering, and pagination
165
189
 
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.
190
+ **📋 Phase 1 Remaining:**
169
191
 
170
- v0.13.13 Bug fix related to mithril RC7
192
+ - Enhanced TypeScript definitions with better JSDoc comments
193
+ - Performance optimizations and bundle size improvements
171
194
 
172
- - FIX `Kanban` key usage and drag-n-drop behaviour
195
+ ### 🎯 Phase 2: Advanced Components & Features
173
196
 
174
- v0.13.12 Bug fix
197
+ **Navigation & Layout:**
175
198
 
176
- - `Options` `checkboxClass` was not applied, so you could not align items properly.
199
+ - AppBar/Toolbar component with responsive behavior
200
+ - Bottom navigation component for mobile apps
201
+ - Drawer/Sidebar component with overlay and push modes
202
+ - Grid system enhancements with CSS Grid support
177
203
 
178
- v0.13.11 Enhancements
204
+ **Data Display:**
179
205
 
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).
206
+ - Enhanced DataTable with virtual scrolling for large datasets
207
+ - TreeView component for hierarchical data
208
+ - Card layouts with enhanced Material Design 3.0 styling
209
+ - List components with advanced features (virtual scrolling, infinite load)
181
210
 
182
- v0.13.10 Enhancement
211
+ **Input & Forms:**
183
212
 
184
- - Added IIFE and ESM output builds
185
- - Refactoring the code slightly
186
- - `Chips` now has a default `className: col s12`
213
+ - Advanced date range picker
214
+ - Autocomplete with async data loading
187
215
 
188
- v0.13.9 Enhancement
216
+ ### 🔮 Phase 3: Modern Features & Integration
189
217
 
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.
218
+ **Developer Experience:**
192
219
 
193
- v0.13.8 Bug fix
220
+ - Storybook integration for component documentation
221
+ - Figma design system integration
222
+ - CLI tools for component generation
223
+ - Better accessibility (ARIA) support throughout
194
224
 
195
- - `Select`, checkedId is evaluated in the view instead of `oninit`.
225
+ **Performance & Optimization:**
196
226
 
197
- v0.13.6 Minor updates
227
+ - Virtual scrolling for large lists
228
+ - Lazy loading component utilities
229
+ - Bundle analyzer and optimization tools
230
+ - CSS-in-JS runtime support option
198
231
 
199
- - `Dropdown`, `Kanban`, `TimePicker`, `DatePicker` can be disabled.
232
+ **Ecosystem Integration:**
200
233
 
201
- v0.13.5 Minor updates
234
+ - React compatibility layer
235
+ - Vue.js compatibility layer
236
+ - Web Components export option
237
+ - PWA-friendly components
202
238
 
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.
239
+ ### 📊 Bundle Size Targets
205
240
 
206
- v0.13.0 Breaking changes
241
+ **Current Status (v2.0.0-beta.5):**
207
242
 
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.
243
+ - Total: 64KB gzipped (44KB JS + 20KB CSS)
244
+ - Modular CSS can reduce bundle by 30-50%
212
245
 
213
- NEW
246
+ **Phase 1 Targets:**
214
247
 
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.
248
+ - Core bundle: <40KB gzipped
249
+ - Modular approach: <25KB for typical apps
250
+ - Tree-shaking effectiveness: 60%+
220
251
 
221
- v0.13.0 No breaking changes
252
+ **Long-term Goals:**
222
253
 
223
- - `FileInput`: added `initialValue` to set the initial value more clearly, and added a clear button to remove the input.
254
+ - Individual components: <2KB each
255
+ - Micro-bundle support for single components
256
+ - Zero-runtime CSS option for static sites
224
257
 
225
- v0.12.2 No breaking changes
258
+ ### 🤝 Contributing
226
259
 
227
- - `Tabs`: added `contentClass` to add a class to the content.
260
+ We welcome contributions! Priority areas for community involvement:
228
261
 
229
- v0.12.1 No breaking changes
262
+ 1. **High Impact**: New components (DataTable, Sidenav, Breadcrumb)
263
+ 2. **Medium Impact**: Accessibility improvements, performance optimizations
264
+ 3. **Documentation**: Examples, guides, API documentation
265
+ 4. **Testing**: Unit tests, visual regression tests, browser compatibility
230
266
 
231
- - Simplified bundling after issues in `webpack`.
267
+ See our [contributing guide](CONTRIBUTING.md) for detailed information.
232
268
 
233
- v0.12.0 No breaking changes
269
+ ### 📈 Performance Benchmarks
234
270
 
235
- - `Tabs` component added, to show [tabs](https://erikvullings.github.io/mithril-materialized/#!/misc).
271
+ **Bundle Size Comparison:**
236
272
 
237
- v0.11.11 No breaking changes
273
+ - mithril-materialized v2.0: 64KB gzipped
274
+ - Material-UI: ~350KB gzipped
275
+ - Materialize CSS + jQuery: ~180KB gzipped
276
+ - Vuetify: ~250KB gzipped
238
277
 
239
- - Bug fix: `TextArea` did not invoke `onchange` when the input was cleared.
240
- - Using Rollup as bundler, generating two bundles (ESM, regular JS).
278
+ **Runtime Performance:**
241
279
 
242
- v0.11.8 No breaking changes
280
+ - Component initialization: <5ms average
281
+ - Theme switching: <10ms for full page
282
+ - File upload processing: Real-time without blocking
243
283
 
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.
284
+ ## Build instructions
342
285
 
343
- v0.6.4 Breaking changes, bug fix.
286
+ 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
287
 
345
- - `Select` did not always return the proper id on selection changes with multiple elements.
288
+ 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
289
 
347
- v0.6.3 No breaking changes, bug fix.
290
+ ## 🎨 Styling & CSS
348
291
 
349
- - `Select` did not update dynamically when checkedId changed.
292
+ ### CSS Usage
350
293
 
351
- v0.6.2 No breaking changes
294
+ The library includes carefully crafted CSS that provides Material Design styling without external dependencies. You can import the ready-to-use CSS:
352
295
 
353
- - `Select` can use `M.FormSelectOptions`.
296
+ ```typescript
297
+ import 'mithril-materialized/index.css';
298
+ ```
354
299
 
355
- v0.6.1 No breaking changes
300
+ **Important**: The CSS styling is **completely independent** of the original materialize-css. This means:
356
301
 
357
- - `Select` can have `disabled` options, and `id` is optional (in which case the label is used).
358
- - `Select` can use a prefix icon.
302
+ - No conflicting styles from materialize-css
303
+ - Smaller CSS bundle size
304
+ - ✅ Custom optimizations for better performance
305
+ - ✅ No external font dependencies
359
306
 
360
- v0.6.0 No breaking changes
307
+ ### 🔥 NEW: Modular CSS Architecture
361
308
 
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).
309
+ **Tree-shakable CSS modules** for optimal bundle sizes! Import only the CSS you need:
364
310
 
365
- v0.5.0 No breaking changes
311
+ ```typescript
312
+ // Option 1: Import everything (64KB total)
313
+ import 'mithril-materialized/index.css';
366
314
 
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
315
+ // Option 2: Import only what you need (modular approach)
316
+ import 'mithril-materialized/core.css'; // Essential styles (18KB)
317
+ import 'mithril-materialized/forms.css'; // Form components only
318
+ import 'mithril-materialized/components.css'; // Interactive components
371
319
 
372
- v0.4.4 No breaking changes
320
+ // Option 3: Advanced components only when needed
321
+ import 'mithril-materialized/pickers.css'; // Date/Time pickers
322
+ import 'mithril-materialized/advanced.css'; // Carousel, sidenav, etc.
323
+ import 'mithril-materialized/utilities.css'; // Badges, icons, cards
324
+ ```
373
325
 
374
- - Do not pass attributes through, e.g. if you had a `m(FlatButton, { onupdate })`, the `onupdate` was passed through to the `HelperText` too.
326
+ **CSS Modules Available:**
375
327
 
376
- v0.4.3 No breaking changes
328
+ - `core.css` (18KB) - Essential foundation (normalize, grid, typography, variables)
329
+ - `components.css` - Interactive components (buttons, dropdowns, modals, tabs)
330
+ - `forms.css` - All form components (inputs, selects, switches, file upload)
331
+ - `pickers.css` - Date and time picker components
332
+ - `advanced.css` - Specialized components (carousel, sidenav, navbar, preloader)
333
+ - `utilities.css` - Visual utilities (badges, cards, icons, toast, chips)
377
334
 
378
- - The validate method for inputs now also accepts the HTMLInputElement
379
- - Removed a few left-over `console.log` statements.
335
+ **Bundle Size Optimization:**
380
336
 
381
- v0.4.2 No breaking changes
337
+ - Full bundle: 64KB gzipped (44KB JS + 20KB CSS)
338
+ - Modular approach can reduce CSS by 30-50%
339
+ - Use only `core.css` + specific modules for your use case
382
340
 
383
- - Added `required` and `aria-required="true"` attributes when the `required` or `isMandatory` property are set.
341
+ ### 🌓 Dark Theme Support
384
342
 
385
- v0.4.1 No breaking changes
343
+ Built-in dark theme support with CSS custom properties:
386
344
 
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.
345
+ ```typescript
346
+ import { ThemeManager, ThemeSwitcher } from 'mithril-materialized';
388
347
 
389
- v0.4.0 No breaking changes
348
+ // Programmatic theme control
349
+ ThemeManager.setTheme('dark'); // 'light' | 'dark' | 'auto'
350
+ ThemeManager.toggle(); // Toggle between light/dark
351
+ ThemeManager.getTheme(); // Get current theme
390
352
 
391
- - New components: MaterialBox, Collapsible or accordion, and Carousel
353
+ // UI Components
354
+ m(ThemeSwitcher, {
355
+ onThemeChange: (theme) => console.log('Theme:', theme)
356
+ });
392
357
 
393
- v0.3.0 Breaking changes
358
+ m(ThemeToggle); // Simple toggle button
359
+ ```
394
360
 
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.
361
+ **CSS Custom Properties**: All colors use CSS variables for runtime theme switching:
400
362
 
401
- v0.2.2
363
+ ```css
364
+ :root {
365
+ --mm-primary-color: #26a69a;
366
+ --mm-background-color: #ffffff;
367
+ --mm-text-primary: rgba(0, 0, 0, 0.87);
368
+ }
402
369
 
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.
370
+ [data-theme="dark"] {
371
+ --mm-primary-color: #80cbc4;
372
+ --mm-background-color: #121212;
373
+ --mm-text-primary: rgba(255, 255, 255, 0.87);
374
+ }
375
+ ```
404
376
 
405
- v0.2.1
377
+ ### SASS Usage
406
378
 
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).
379
+ For advanced customization, you can use the SASS source files directly:
411
380
 
412
- ## Usage instructions
381
+ ```scss
382
+ // Import all SASS components
383
+ @import 'mithril-materialized/sass/materialize.scss';
413
384
 
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.
385
+ // Or import individual components
386
+ @import 'mithril-materialized/sass/components/buttons';
387
+ @import 'mithril-materialized/sass/components/forms';
388
+ @import 'mithril-materialized/sass/components/grid';
389
+ ```
415
390
 
416
- ## Build instructions
391
+ **SASS Variables**: You can customize colors, spacing, and other design tokens by overriding SASS variables before importing:
417
392
 
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.
393
+ ```css
394
+ // Customize Material Design variables
395
+ $primary-color: #2196F3;
396
+ $secondary-color: #FF9800;
419
397
 
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.
398
+ // Then import the library
399
+ @import 'mithril-materialized/sass/materialize.scss';
400
+ ```
421
401
 
422
- ## CSS
402
+ ### Custom Styles
423
403
 
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.
404
+ The library includes these additional styles for enhanced functionality:
425
405
 
426
406
  ```css
427
407
  /* For the switch */
@@ -429,7 +409,7 @@ Although I've tried to limit the CSS adaptations to a minimum, I needed to tweak
429
409
  .clear-10,
430
410
  .clear-15 {
431
411
  clear: both;
432
- /* overflow: hidden; Précaution pour IE 7 */
412
+ /* overflow: hidden; Precaution pour IE 7 */
433
413
  }
434
414
  .clear-10 {
435
415
  margin-bottom: 10px;