mithril-materialized 2.0.0-beta.10 → 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.
- package/README.md +18 -19
- package/dist/advanced.css +6 -6
- package/dist/button.d.ts +56 -11
- package/dist/components.css +6 -6
- package/dist/core.css +13 -13
- package/dist/datatable.d.ts +291 -0
- package/dist/forms.css +13 -13
- package/dist/index.css +341 -16
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +1074 -442
- package/dist/index.js +1077 -441
- package/dist/index.min.css +2 -2
- package/dist/index.umd.js +1077 -441
- package/dist/input.d.ts +0 -1
- package/dist/types.d.ts +226 -0
- package/dist/utilities.css +16 -9
- package/package.json +5 -2
- package/sass/components/_cards.scss +10 -3
- package/sass/components/_datatable.scss +417 -0
- package/sass/components/_global.scss +6 -6
- package/sass/components/forms/_range.scss +5 -5
- package/sass/components/forms/_select.scss +1 -1
- package/sass/materialize.scss +1 -0
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ This is a **major breaking release** that removes all external JavaScript depend
|
|
|
20
20
|
|
|
21
21
|
- **Removed dependencies**: No longer requires `materialize-css` or `material-icons` packages
|
|
22
22
|
- **Component updates**: DatePicker and TimePicker now have custom implementations
|
|
23
|
-
- **Icon changes**:
|
|
23
|
+
- **Icon changes**: Library uses custom SVG icons. Material Icons font is supported too, but not required.
|
|
24
24
|
- **Installation**: Simpler installation process with fewer dependencies
|
|
25
25
|
|
|
26
26
|
### 📈 Migration from v1.x
|
|
@@ -81,7 +81,10 @@ Your CSS imports can remain the same, but you no longer need the materialize-css
|
|
|
81
81
|
- MaterialBox
|
|
82
82
|
- Carousel
|
|
83
83
|
- Pagination
|
|
84
|
+
- PaginationControls
|
|
84
85
|
- Parallax
|
|
86
|
+
- Data & Tables
|
|
87
|
+
- DataTable (sorting, filtering, pagination, selection)
|
|
85
88
|
- Additional
|
|
86
89
|
- Label
|
|
87
90
|
- HelperText
|
|
@@ -114,6 +117,7 @@ Your CSS imports can remain the same, but you no longer need the materialize-css
|
|
|
114
117
|
TextInput,
|
|
115
118
|
Button,
|
|
116
119
|
DatePicker,
|
|
120
|
+
DataTable,
|
|
117
121
|
ThemeToggle,
|
|
118
122
|
FileUpload,
|
|
119
123
|
Sidenav,
|
|
@@ -183,36 +187,31 @@ See the [live documentation](https://erikvullings.github.io/mithril-materialized
|
|
|
183
187
|
- ✅ Breadcrumb navigation component
|
|
184
188
|
- ✅ Wizard/Stepper component for multi-step forms
|
|
185
189
|
|
|
186
|
-
|
|
190
|
+
**✅ Recently Completed:**
|
|
187
191
|
|
|
188
|
-
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
- Enhanced TypeScript definitions with better JSDoc comments
|
|
193
|
-
- Performance optimizations and bundle size improvements
|
|
192
|
+
- ✅ DataTable component with sorting, filtering, and pagination
|
|
193
|
+
- ✅ Enhanced TypeScript definitions with better JSDoc comments
|
|
194
|
+
- ✅ Performance optimizations and bundle size improvements
|
|
194
195
|
|
|
195
196
|
### 🎯 Phase 2: Advanced Components & Features
|
|
196
197
|
|
|
197
|
-
**Navigation & Layout:**
|
|
198
|
-
|
|
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
|
|
203
|
-
|
|
204
198
|
**Data Display:**
|
|
205
199
|
|
|
206
|
-
- Enhanced DataTable with virtual scrolling for large datasets
|
|
207
200
|
- TreeView component for hierarchical data
|
|
208
201
|
- Card layouts with enhanced Material Design 3.0 styling
|
|
209
|
-
- List components with advanced features (virtual scrolling, infinite load)
|
|
210
202
|
|
|
211
203
|
**Input & Forms:**
|
|
212
204
|
|
|
213
205
|
- Advanced date range picker
|
|
214
206
|
- Autocomplete with async data loading
|
|
215
207
|
|
|
208
|
+
**Navigation & Layout:**
|
|
209
|
+
|
|
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
|
|
214
|
+
|
|
216
215
|
### 🔮 Phase 3: Modern Features & Integration
|
|
217
216
|
|
|
218
217
|
**Developer Experience:**
|
|
@@ -240,7 +239,7 @@ See the [live documentation](https://erikvullings.github.io/mithril-materialized
|
|
|
240
239
|
|
|
241
240
|
**Current Status (v2.0.0-beta.5):**
|
|
242
241
|
|
|
243
|
-
- Total:
|
|
242
|
+
- Total: 70KB gzipped (44KB JS + 26KB CSS)
|
|
244
243
|
- Modular CSS can reduce bundle by 30-50%
|
|
245
244
|
|
|
246
245
|
**Phase 1 Targets:**
|
|
@@ -378,7 +377,7 @@ m(ThemeToggle); // Simple toggle button
|
|
|
378
377
|
|
|
379
378
|
For advanced customization, you can use the SASS source files directly:
|
|
380
379
|
|
|
381
|
-
```
|
|
380
|
+
```css
|
|
382
381
|
// Import all SASS components
|
|
383
382
|
@import 'mithril-materialized/sass/materialize.scss';
|
|
384
383
|
|
package/dist/advanced.css
CHANGED
|
@@ -205,21 +205,21 @@ video.responsive-video {
|
|
|
205
205
|
height: 30px;
|
|
206
206
|
}
|
|
207
207
|
.pagination li a {
|
|
208
|
-
color: #444;
|
|
208
|
+
color: var(--mm-text-primary, #444);
|
|
209
209
|
display: inline-block;
|
|
210
210
|
font-size: 1.2rem;
|
|
211
211
|
padding: 0 10px;
|
|
212
212
|
line-height: 30px;
|
|
213
213
|
}
|
|
214
214
|
.pagination li.active a {
|
|
215
|
-
color: #fff;
|
|
215
|
+
color: var(--mm-text-on-primary, #fff);
|
|
216
216
|
}
|
|
217
217
|
.pagination li.active {
|
|
218
218
|
background-color: #ee6e73;
|
|
219
219
|
}
|
|
220
220
|
.pagination li.disabled a {
|
|
221
221
|
cursor: default;
|
|
222
|
-
color: #999;
|
|
222
|
+
color: var(--mm-text-disabled, #999);
|
|
223
223
|
}
|
|
224
224
|
.pagination li i {
|
|
225
225
|
font-size: 2rem;
|
|
@@ -550,8 +550,8 @@ td, th {
|
|
|
550
550
|
.collection .collection-item.avatar i.circle {
|
|
551
551
|
font-size: 18px;
|
|
552
552
|
line-height: 42px;
|
|
553
|
-
color: #fff;
|
|
554
|
-
background-color: #999;
|
|
553
|
+
color: var(--mm-text-on-primary, #fff);
|
|
554
|
+
background-color: var(--mm-text-disabled, #999);
|
|
555
555
|
text-align: center;
|
|
556
556
|
}
|
|
557
557
|
.collection .collection-item.avatar .title {
|
|
@@ -573,7 +573,7 @@ td, th {
|
|
|
573
573
|
color: rgb(234.25, 250.25, 248.75);
|
|
574
574
|
}
|
|
575
575
|
.collection .collection-item.active .secondary-content {
|
|
576
|
-
color: #fff;
|
|
576
|
+
color: var(--mm-text-on-primary, #fff);
|
|
577
577
|
}
|
|
578
578
|
.collection a.collection-item {
|
|
579
579
|
display: block;
|
package/dist/button.d.ts
CHANGED
|
@@ -1,30 +1,75 @@
|
|
|
1
1
|
import m, { FactoryComponent, Attributes } from 'mithril';
|
|
2
|
+
import { MaterialPosition, IconClass, ButtonVariant } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* HTML attributes that can be passed to button elements
|
|
5
|
+
* @deprecated Use native HTML attributes directly instead
|
|
6
|
+
*/
|
|
2
7
|
export interface HtmlAttrs {
|
|
3
8
|
id?: string;
|
|
4
9
|
for?: string;
|
|
5
10
|
placeholder?: string;
|
|
6
11
|
autofocus?: boolean;
|
|
7
12
|
disabled?: boolean;
|
|
8
|
-
type?: 'submit' | 'button' | '
|
|
13
|
+
type?: 'submit' | 'button' | 'reset';
|
|
9
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Enhanced button attributes with improved TypeScript support
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Basic button
|
|
20
|
+
* m(Button, { label: 'Click me' })
|
|
21
|
+
*
|
|
22
|
+
* // Submit button with icon
|
|
23
|
+
* m(Button, {
|
|
24
|
+
* variant: { type: 'submit' },
|
|
25
|
+
* label: 'Save',
|
|
26
|
+
* iconName: 'save',
|
|
27
|
+
* iconClass: 'small left'
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* // Modal trigger button
|
|
31
|
+
* m(Button, {
|
|
32
|
+
* variant: { type: 'modal', modalId: 'my-modal' },
|
|
33
|
+
* label: 'Open Modal'
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
10
37
|
export interface ButtonAttrs extends Attributes {
|
|
11
|
-
/**
|
|
38
|
+
/** Button label text (optional for icon-only buttons) */
|
|
12
39
|
label?: string;
|
|
13
|
-
/**
|
|
40
|
+
/** Material icon name - see https://materializecss.com/icons.html */
|
|
14
41
|
iconName?: string;
|
|
15
|
-
/** Optional icon class, e.g. tiny (1em), small (2em), medium (4em), large (6em), or 'tiny right' */
|
|
16
|
-
iconClass?: string;
|
|
17
42
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @
|
|
43
|
+
* Icon size and position class
|
|
44
|
+
* @example 'small', 'medium left', 'large right'
|
|
45
|
+
*/
|
|
46
|
+
iconClass?: IconClass;
|
|
47
|
+
/**
|
|
48
|
+
* Button behavior variant - determines button type and behavior
|
|
49
|
+
* @example
|
|
50
|
+
* { type: 'button' } - Standard button
|
|
51
|
+
* { type: 'submit' } - Form submit button
|
|
52
|
+
* { type: 'modal', modalId: 'my-modal' } - Modal trigger
|
|
53
|
+
* { type: 'reset' } - Form reset button
|
|
54
|
+
*/
|
|
55
|
+
variant?: ButtonVariant;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Use variant instead
|
|
58
|
+
* If the button is intended to open a modal, specify its modal id so we can trigger it
|
|
20
59
|
*/
|
|
21
60
|
modalId?: string;
|
|
22
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Use native HTML attributes directly instead
|
|
63
|
+
* Some additional HTML attributes that can be attached to the button
|
|
64
|
+
*/
|
|
23
65
|
attr?: HtmlAttrs;
|
|
24
|
-
/**
|
|
66
|
+
/** Tooltip text to display on hover */
|
|
25
67
|
tooltip?: string;
|
|
26
|
-
/**
|
|
27
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Tooltip position
|
|
70
|
+
* @fixed typo: tooltipPostion -> tooltipPosition
|
|
71
|
+
*/
|
|
72
|
+
tooltipPosition?: MaterialPosition;
|
|
28
73
|
}
|
|
29
74
|
/**
|
|
30
75
|
* A factory to create new buttons.
|
package/dist/components.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;
|
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.
|
|
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>>;
|