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

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/dist/core.css CHANGED
@@ -525,21 +525,21 @@ video.responsive-video {
525
525
  height: 30px;
526
526
  }
527
527
  .pagination li a {
528
- color: #444;
528
+ color: var(--mm-text-primary, #444);
529
529
  display: inline-block;
530
530
  font-size: 1.2rem;
531
531
  padding: 0 10px;
532
532
  line-height: 30px;
533
533
  }
534
534
  .pagination li.active a {
535
- color: #fff;
535
+ color: var(--mm-text-on-primary, #fff);
536
536
  }
537
537
  .pagination li.active {
538
538
  background-color: #ee6e73;
539
539
  }
540
540
  .pagination li.disabled a {
541
541
  cursor: default;
542
- color: #999;
542
+ color: var(--mm-text-disabled, #999);
543
543
  }
544
544
  .pagination li i {
545
545
  font-size: 2rem;
@@ -870,8 +870,8 @@ td, th {
870
870
  .collection .collection-item.avatar i.circle {
871
871
  font-size: 18px;
872
872
  line-height: 42px;
873
- color: #fff;
874
- background-color: #999;
873
+ color: var(--mm-text-on-primary, #fff);
874
+ background-color: var(--mm-text-disabled, #999);
875
875
  text-align: center;
876
876
  }
877
877
  .collection .collection-item.avatar .title {
@@ -893,7 +893,7 @@ td, th {
893
893
  color: rgb(234.25, 250.25, 248.75);
894
894
  }
895
895
  .collection .collection-item.active .secondary-content {
896
- color: #fff;
896
+ color: var(--mm-text-on-primary, #fff);
897
897
  }
898
898
  .collection a.collection-item {
899
899
  display: block;
@@ -3122,7 +3122,7 @@ select:disabled {
3122
3122
  }
3123
3123
 
3124
3124
  .select-wrapper i {
3125
- color: rgba(0, 0, 0, 0.3);
3125
+ color: var(--mm-text-primary, rgba(0, 0, 0, 0.87));
3126
3126
  }
3127
3127
 
3128
3128
  .select-dropdown li.disabled,
@@ -3275,7 +3275,7 @@ input[type=range] {
3275
3275
 
3276
3276
  input[type=range]::-webkit-slider-runnable-track {
3277
3277
  height: 3px;
3278
- background: #c2c0c2;
3278
+ background: var(--mm-border-color, #c2c0c2);
3279
3279
  border: none;
3280
3280
  }
3281
3281
 
@@ -3298,13 +3298,13 @@ input[type=range]::-webkit-slider-thumb {
3298
3298
 
3299
3299
  input[type=range] {
3300
3300
  /* fix for FF unable to apply focus style bug */
3301
- border: 1px solid white;
3301
+ border: 1px solid var(--mm-card-background, white);
3302
3302
  /*required for proper track sizing in FF*/
3303
3303
  }
3304
3304
 
3305
3305
  input[type=range]::-moz-range-track {
3306
3306
  height: 3px;
3307
- background: #c2c0c2;
3307
+ background: var(--mm-border-color, #c2c0c2);
3308
3308
  border: none;
3309
3309
  }
3310
3310
 
@@ -3323,7 +3323,7 @@ input[type=range]::-moz-range-thumb {
3323
3323
  }
3324
3324
 
3325
3325
  input[type=range]:-moz-focusring {
3326
- outline: 1px solid #fff;
3326
+ outline: 1px solid var(--mm-card-background, #fff);
3327
3327
  outline-offset: -1px;
3328
3328
  }
3329
3329
 
@@ -3341,11 +3341,11 @@ input[type=range]::-ms-track {
3341
3341
  }
3342
3342
 
3343
3343
  input[type=range]::-ms-fill-lower {
3344
- background: #777;
3344
+ background: var(--mm-text-secondary, #777);
3345
3345
  }
3346
3346
 
3347
3347
  input[type=range]::-ms-fill-upper {
3348
- background: #ddd;
3348
+ background: var(--mm-surface-color, #ddd);
3349
3349
  }
3350
3350
 
3351
3351
  input[type=range]::-ms-thumb {
@@ -0,0 +1,291 @@
1
+ import { Attributes, Component, Vnode, type FactoryComponent } from 'mithril';
2
+ /**
3
+ * Attributes for custom cell renderer components in DataTable
4
+ * @template T The type of the data object for each row
5
+ */
6
+ export interface CellRendererAttrs<T = Record<string, any>> {
7
+ /** The processed value from the data object for this cell */
8
+ value: any;
9
+ /** The complete row data object */
10
+ row: T;
11
+ /** The row index in the processed data */
12
+ index: number;
13
+ /** The column configuration object */
14
+ column: DataTableColumn<T>;
15
+ }
16
+ /**
17
+ * Configuration for a DataTable column
18
+ * @template T The type of the data object for each row
19
+ */
20
+ export interface DataTableColumn<T = Record<string, any>> {
21
+ /** Unique identifier for the column (required for sorting/filtering) */
22
+ key: string;
23
+ /** Display title shown in the column header */
24
+ title: string;
25
+ /** Property name in the data object to display. If not provided, the entire row object is passed to the renderer */
26
+ field?: keyof T;
27
+ /** Custom cell renderer component for advanced cell content */
28
+ cellRenderer?: FactoryComponent<CellRendererAttrs<T>>;
29
+ /** @deprecated Use cellRenderer instead - Legacy render function for cell content */
30
+ render?: (value: any, row: T, index: number) => string | number | Vnode | Vnode[];
31
+ /** Enable sorting for this column */
32
+ sortable?: boolean;
33
+ /** Enable global search filtering for this column */
34
+ filterable?: boolean;
35
+ /** CSS width value (e.g., '100px', '20%', '10rem') */
36
+ width?: string;
37
+ /** Text alignment within cells */
38
+ align?: 'left' | 'center' | 'right';
39
+ /** CSS class applied to all cells in this column */
40
+ className?: string;
41
+ /** CSS class applied to the column header */
42
+ headerClassName?: string;
43
+ }
44
+ /**
45
+ * Configuration for DataTable sorting state
46
+ */
47
+ export interface DataTableSort {
48
+ /** Key of the column to sort by (must match a column's key) */
49
+ column: string;
50
+ /** Sort direction - ascending or descending */
51
+ direction: 'asc' | 'desc';
52
+ }
53
+ /**
54
+ * Configuration for DataTable pagination
55
+ */
56
+ export interface DataTablePagination {
57
+ /** Current page number (0-based indexing) */
58
+ page: number;
59
+ /** Number of items to display per page */
60
+ pageSize: number;
61
+ /** Total number of items in the dataset */
62
+ total: number;
63
+ /** Array of available page size options for user selection */
64
+ pageSizes?: number[];
65
+ }
66
+ /**
67
+ * Configuration for DataTable row selection functionality
68
+ * @template T The type of the data object for each row
69
+ */
70
+ export interface DataTableSelection<T = Record<string, any>> {
71
+ /** Selection mode - controls how many rows can be selected */
72
+ mode: 'single' | 'multiple' | 'none';
73
+ /** Array of currently selected row keys */
74
+ selectedKeys: string[];
75
+ /** Function to generate a unique key for each row */
76
+ getRowKey: (row: T, index: number) => string;
77
+ /** Callback invoked when row selection changes */
78
+ onSelectionChange?: (selectedKeys: string[], selectedRows: T[]) => void;
79
+ }
80
+ /**
81
+ * Configuration for DataTable filtering functionality
82
+ */
83
+ export interface DataTableFilter {
84
+ /** Global search term applied across all filterable columns */
85
+ searchTerm?: string;
86
+ /** Column-specific filter values keyed by column key */
87
+ columnFilters?: Record<string, any>;
88
+ }
89
+ /**
90
+ * Main DataTable component attributes
91
+ * @template T The type of the data object for each row
92
+ *
93
+ * @example Basic usage
94
+ * ```typescript
95
+ * m(DataTable, {
96
+ * data: users,
97
+ * columns: [
98
+ * { key: 'name', title: 'Name', field: 'name', sortable: true },
99
+ * { key: 'email', title: 'Email', field: 'email', filterable: true }
100
+ * ]
101
+ * })
102
+ * ```
103
+ *
104
+ * @example With pagination and selection
105
+ * ```typescript
106
+ * m(DataTable, {
107
+ * data: users,
108
+ * columns,
109
+ * pagination: { page: 0, pageSize: 10, total: users.length },
110
+ * selection: {
111
+ * mode: 'multiple',
112
+ * selectedKeys: [],
113
+ * getRowKey: (user) => user.id,
114
+ * onSelectionChange: (keys, users) => console.log('Selected:', users)
115
+ * }
116
+ * })
117
+ * ```
118
+ */
119
+ export interface DataTableAttrs<T = Record<string, any>> extends Attributes {
120
+ /** Array of data objects to display in the table */
121
+ data: T[];
122
+ /** Column configuration array defining how data should be displayed */
123
+ columns: DataTableColumn<T>[];
124
+ /** Optional title displayed above the table */
125
+ title?: string;
126
+ /** Show loading spinner and disable interactions */
127
+ loading?: boolean;
128
+ /** Message to display when data array is empty */
129
+ emptyMessage?: string;
130
+ /** Apply alternating row background colors */
131
+ striped?: boolean;
132
+ /** Enable row highlighting on hover */
133
+ hoverable?: boolean;
134
+ /** Make table responsive with horizontal scrolling on small screens */
135
+ responsive?: boolean;
136
+ /** Center-align all table content */
137
+ centered?: boolean;
138
+ /** Fixed table height in pixels (enables scrolling) */
139
+ height?: number;
140
+ /** Additional CSS classes to apply to the table */
141
+ className?: string;
142
+ /** Custom HTML id attribute for the table container */
143
+ id?: string;
144
+ /** Current sort configuration. If provided, sorting is controlled externally */
145
+ sort?: DataTableSort;
146
+ /** Callback invoked when user changes sort order */
147
+ onSortChange?: (sort: DataTableSort) => void;
148
+ /** Pagination configuration. If provided, pagination is controlled externally */
149
+ pagination?: DataTablePagination;
150
+ /** Callback invoked when user changes page or page size */
151
+ onPaginationChange?: (pagination: DataTablePagination) => void;
152
+ /** Row selection configuration */
153
+ selection?: DataTableSelection<T>;
154
+ /** Current filter state. If provided, filtering is controlled externally */
155
+ filter?: DataTableFilter;
156
+ /** Callback invoked when filter values change */
157
+ onFilterChange?: (filter: DataTableFilter) => void;
158
+ /** Show global search input above the table */
159
+ enableGlobalSearch?: boolean;
160
+ /** Placeholder text for the global search input */
161
+ searchPlaceholder?: string;
162
+ /** Callback invoked when a row is clicked */
163
+ onRowClick?: (row: T, index: number, event: Event) => void;
164
+ /** Callback invoked when a row is double-clicked */
165
+ onRowDoubleClick?: (row: T, index: number, event: Event) => void;
166
+ /** Function to generate custom CSS classes for each row */
167
+ getRowClassName?: (row: T, index: number) => string;
168
+ /** Internationalization configuration for UI text */
169
+ i18n?: DataTableI18n;
170
+ }
171
+ /**
172
+ * Internationalization configuration for DataTable UI text
173
+ * Allows customization of all user-facing text strings
174
+ */
175
+ export interface DataTableI18n {
176
+ /** Label for the search input */
177
+ search?: string;
178
+ /** Placeholder text for the search input */
179
+ searchPlaceholder?: string;
180
+ /** "Showing" text in pagination display */
181
+ showing?: string;
182
+ /** "to" text in pagination display (e.g., "Showing 1 to 10 of 100") */
183
+ to?: string;
184
+ /** "of" text in pagination display */
185
+ of?: string;
186
+ /** "entries" text in pagination display */
187
+ entries?: string;
188
+ /** "Page" text in pagination controls */
189
+ page?: string;
190
+ /** Message displayed when no data is available */
191
+ noDataAvailable?: string;
192
+ /** Loading message displayed during data fetch */
193
+ loading?: string;
194
+ }
195
+ /**
196
+ * Attributes for the PaginationControls component
197
+ */
198
+ export interface PaginationControlsAttrs {
199
+ /** Pagination configuration object */
200
+ pagination?: DataTablePagination;
201
+ /** Callback function invoked when pagination state changes */
202
+ onPaginationChange: (pagination: DataTablePagination) => void;
203
+ /** Internationalization strings for pagination text */
204
+ i18n?: DataTableI18n;
205
+ }
206
+ /**
207
+ * Standalone Pagination Controls component
208
+ *
209
+ * Provides navigation controls for paginated data with customizable text labels.
210
+ * Includes first page, previous page, next page, last page buttons and page info display.
211
+ * Can be used independently of DataTable for any paginated content.
212
+ *
213
+ * @example
214
+ * ```typescript
215
+ * m(PaginationControls, {
216
+ * pagination: { page: 0, pageSize: 10, total: 100 },
217
+ * onPaginationChange: (newPagination) => console.log('Page changed:', newPagination),
218
+ * i18n: { showing: 'Showing', to: 'to', of: 'of', entries: 'entries', page: 'Page' }
219
+ * })
220
+ * ```
221
+ */
222
+ export declare const PaginationControls: FactoryComponent<PaginationControlsAttrs>;
223
+ /**
224
+ * A comprehensive data table component with sorting, filtering, pagination, and selection capabilities.
225
+ *
226
+ * @template T The type of data objects displayed in each row
227
+ *
228
+ * @description
229
+ * The DataTable component provides a feature-rich interface for displaying and interacting with tabular data.
230
+ * It supports both controlled and uncontrolled modes for all interactive features.
231
+ *
232
+ * **Key Features:**
233
+ * - Sorting: Click column headers to sort data ascending/descending
234
+ * - Filtering: Global search across filterable columns
235
+ * - Pagination: Navigate through large datasets with customizable page sizes
236
+ * - Selection: Single or multiple row selection with callbacks
237
+ * - Custom rendering: Use cellRenderer for complex cell content
238
+ * - Responsive: Adapts to different screen sizes
239
+ * - Internationalization: Customize all UI text
240
+ * - Accessibility: Proper ARIA attributes and keyboard navigation
241
+ *
242
+ * @example Basic usage
243
+ * ```typescript
244
+ * interface User { id: number; name: string; email: string; }
245
+ * const users: User[] = [...];
246
+ * const columns: DataTableColumn<User>[] = [
247
+ * { key: 'name', title: 'Name', field: 'name', sortable: true, filterable: true },
248
+ * { key: 'email', title: 'Email', field: 'email', sortable: true, filterable: true }
249
+ * ];
250
+ *
251
+ * return m(DataTable<User>, { data: users, columns });
252
+ * ```
253
+ *
254
+ * @example Advanced usage with all features
255
+ * ```typescript
256
+ * return m(DataTable<User>, {
257
+ * data: users,
258
+ * columns,
259
+ * title: 'User Management',
260
+ * striped: true,
261
+ * hoverable: true,
262
+ * height: 400,
263
+ *
264
+ * // Pagination
265
+ * pagination: { page: 0, pageSize: 10, total: users.length },
266
+ * onPaginationChange: (pagination) => console.log('Page changed:', pagination),
267
+ *
268
+ * // Selection
269
+ * selection: {
270
+ * mode: 'multiple',
271
+ * selectedKeys: [],
272
+ * getRowKey: (user) => String(user.id),
273
+ * onSelectionChange: (keys, selectedUsers) => console.log('Selection:', selectedUsers)
274
+ * },
275
+ *
276
+ * // Search
277
+ * enableGlobalSearch: true,
278
+ * searchPlaceholder: 'Search users...',
279
+ *
280
+ * // Events
281
+ * onRowClick: (user, index, event) => console.log('Clicked:', user),
282
+ * onRowDoubleClick: (user) => editUser(user),
283
+ *
284
+ * // Styling
285
+ * getRowClassName: (user) => user.active ? '' : 'inactive-row'
286
+ * });
287
+ * ```
288
+ *
289
+ * @returns A Mithril component that renders the data table
290
+ */
291
+ export declare const DataTable: <T = Record<string, any>>() => Component<DataTableAttrs<T>>;
package/dist/forms.css CHANGED
@@ -128,21 +128,21 @@ video.responsive-video {
128
128
  height: 30px;
129
129
  }
130
130
  .pagination li a {
131
- color: #444;
131
+ color: var(--mm-text-primary, #444);
132
132
  display: inline-block;
133
133
  font-size: 1.2rem;
134
134
  padding: 0 10px;
135
135
  line-height: 30px;
136
136
  }
137
137
  .pagination li.active a {
138
- color: #fff;
138
+ color: var(--mm-text-on-primary, #fff);
139
139
  }
140
140
  .pagination li.active {
141
141
  background-color: #ee6e73;
142
142
  }
143
143
  .pagination li.disabled a {
144
144
  cursor: default;
145
- color: #999;
145
+ color: var(--mm-text-disabled, #999);
146
146
  }
147
147
  .pagination li i {
148
148
  font-size: 2rem;
@@ -473,8 +473,8 @@ td, th {
473
473
  .collection .collection-item.avatar i.circle {
474
474
  font-size: 18px;
475
475
  line-height: 42px;
476
- color: #fff;
477
- background-color: #999;
476
+ color: var(--mm-text-on-primary, #fff);
477
+ background-color: var(--mm-text-disabled, #999);
478
478
  text-align: center;
479
479
  }
480
480
  .collection .collection-item.avatar .title {
@@ -496,7 +496,7 @@ td, th {
496
496
  color: rgb(234.25, 250.25, 248.75);
497
497
  }
498
498
  .collection .collection-item.active .secondary-content {
499
- color: #fff;
499
+ color: var(--mm-text-on-primary, #fff);
500
500
  }
501
501
  .collection a.collection-item {
502
502
  display: block;
@@ -1372,7 +1372,7 @@ select:disabled {
1372
1372
  }
1373
1373
 
1374
1374
  .select-wrapper i {
1375
- color: rgba(0, 0, 0, 0.3);
1375
+ color: var(--mm-text-primary, rgba(0, 0, 0, 0.87));
1376
1376
  }
1377
1377
 
1378
1378
  .select-dropdown li.disabled,
@@ -1843,7 +1843,7 @@ input[type=range] {
1843
1843
 
1844
1844
  input[type=range]::-webkit-slider-runnable-track {
1845
1845
  height: 3px;
1846
- background: #c2c0c2;
1846
+ background: var(--mm-border-color, #c2c0c2);
1847
1847
  border: none;
1848
1848
  }
1849
1849
 
@@ -1866,13 +1866,13 @@ input[type=range]::-webkit-slider-thumb {
1866
1866
 
1867
1867
  input[type=range] {
1868
1868
  /* fix for FF unable to apply focus style bug */
1869
- border: 1px solid white;
1869
+ border: 1px solid var(--mm-card-background, white);
1870
1870
  /*required for proper track sizing in FF*/
1871
1871
  }
1872
1872
 
1873
1873
  input[type=range]::-moz-range-track {
1874
1874
  height: 3px;
1875
- background: #c2c0c2;
1875
+ background: var(--mm-border-color, #c2c0c2);
1876
1876
  border: none;
1877
1877
  }
1878
1878
 
@@ -1891,7 +1891,7 @@ input[type=range]::-moz-range-thumb {
1891
1891
  }
1892
1892
 
1893
1893
  input[type=range]:-moz-focusring {
1894
- outline: 1px solid #fff;
1894
+ outline: 1px solid var(--mm-card-background, #fff);
1895
1895
  outline-offset: -1px;
1896
1896
  }
1897
1897
 
@@ -1909,11 +1909,11 @@ input[type=range]::-ms-track {
1909
1909
  }
1910
1910
 
1911
1911
  input[type=range]::-ms-fill-lower {
1912
- background: #777;
1912
+ background: var(--mm-text-secondary, #777);
1913
1913
  }
1914
1914
 
1915
1915
  input[type=range]::-ms-fill-upper {
1916
- background: #ddd;
1916
+ background: var(--mm-surface-color, #ddd);
1917
1917
  }
1918
1918
 
1919
1919
  input[type=range]::-ms-thumb {
package/dist/icon.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { FactoryComponent, Attributes } from 'mithril';
2
- export interface MaterialIcon extends Attributes {
2
+ export interface IconAttrs extends Attributes {
3
3
  iconName: string;
4
4
  }
5
5
  /**
@@ -8,4 +8,4 @@ export interface MaterialIcon extends Attributes {
8
8
  * @example m(Icon, { className: 'small' }, 'create') renders a small 'create' icon
9
9
  * @example m(Icon, { className: 'prefix' }, iconName) renders the icon as a prefix
10
10
  */
11
- export declare const Icon: FactoryComponent<MaterialIcon>;
11
+ export declare const Icon: FactoryComponent<IconAttrs>;