mithril-materialized 2.0.0-beta.11 → 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/README.md +23 -1
- package/dist/components.css +595 -0
- package/dist/icon.d.ts +2 -2
- package/dist/index.css +281 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +440 -155
- package/dist/index.js +441 -154
- package/dist/index.min.css +1 -1
- package/dist/index.umd.js +441 -154
- package/dist/material-icon.d.ts +3 -0
- package/dist/treeview.d.ts +39 -0
- package/package.json +2 -2
- package/sass/components/_treeview.scss +353 -0
- package/sass/materialize.scss +1 -0
package/dist/material-icon.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { FactoryComponent, Attributes } from 'mithril';
|
|
|
2
2
|
declare const iconPaths: {
|
|
3
3
|
readonly caret: readonly ["M7 10l5 5 5-5z", "M0 0h24v24H0z"];
|
|
4
4
|
readonly close: readonly ["M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12l-4.89 4.89a1 1 0 1 0 1.41 1.41L12 13.41l4.89 4.89a1 1 0 0 0 1.41-1.41L13.41 12l4.89-4.89a1 1 0 0 0 0-1.4z", "M0 0h24v24H0z"];
|
|
5
|
+
readonly chevron: readonly ["M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z", "M0 0h24v24H0z"];
|
|
6
|
+
readonly expand: readonly ["M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z", "M0 0h24v24H0z"];
|
|
7
|
+
readonly collapse: readonly ["M19 13H5v-2h14v2z", "M0 0h24v24H0z"];
|
|
5
8
|
};
|
|
6
9
|
type IconName = keyof typeof iconPaths;
|
|
7
10
|
export interface MaterialIconAttrs extends Attributes {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FactoryComponent, Attributes } from 'mithril';
|
|
2
|
+
import { EventHandler, SelectionMode } from './types';
|
|
3
|
+
export interface TreeNode {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
expanded?: boolean;
|
|
9
|
+
children?: TreeNode[];
|
|
10
|
+
}
|
|
11
|
+
export type TreeIconType = 'caret' | 'chevron' | 'plus-minus' | 'triangle';
|
|
12
|
+
export interface TreeViewAttrs<T extends TreeNode = TreeNode> extends Attributes {
|
|
13
|
+
/** Tree data structure */
|
|
14
|
+
data: T[];
|
|
15
|
+
/** Selection mode - none, single, or multiple */
|
|
16
|
+
selectionMode?: SelectionMode;
|
|
17
|
+
/** Currently selected node IDs */
|
|
18
|
+
selectedIds?: string[];
|
|
19
|
+
/** Called when selection changes */
|
|
20
|
+
onselection?: EventHandler<string[]>;
|
|
21
|
+
/** Called when node is expanded/collapsed */
|
|
22
|
+
onexpand?: EventHandler<{
|
|
23
|
+
nodeId: string;
|
|
24
|
+
expanded: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
/** Icon type for expand/collapse indicators */
|
|
27
|
+
iconType?: TreeIconType;
|
|
28
|
+
/** Show connecting lines between tree levels (VSCode-style) */
|
|
29
|
+
showConnectors?: boolean;
|
|
30
|
+
/** Allow keyboard navigation */
|
|
31
|
+
keyboardNavigation?: boolean;
|
|
32
|
+
/** Optional CSS class */
|
|
33
|
+
className?: string;
|
|
34
|
+
/** Optional inline styles */
|
|
35
|
+
style?: Record<string, any>;
|
|
36
|
+
/** Component ID */
|
|
37
|
+
id?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare const TreeView: FactoryComponent<TreeViewAttrs>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mithril-materialized",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.12",
|
|
4
4
|
"description": "A materialize library for mithril.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -97,4 +97,4 @@
|
|
|
97
97
|
"typedoc": "^0.28.9",
|
|
98
98
|
"typescript": "^5.9.2"
|
|
99
99
|
}
|
|
100
|
-
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/* TreeView Component Styles */
|
|
2
|
+
|
|
3
|
+
// CSS Custom Properties for theming
|
|
4
|
+
:root {
|
|
5
|
+
--tree-node-height: 36px;
|
|
6
|
+
--tree-indent-size: 24px;
|
|
7
|
+
--tree-connector-width: 1px;
|
|
8
|
+
--tree-expand-icon-size: 20px;
|
|
9
|
+
|
|
10
|
+
// Light theme colors
|
|
11
|
+
--tree-bg-color: #ffffff;
|
|
12
|
+
--tree-text-color: #212121;
|
|
13
|
+
--tree-text-color-secondary: #757575;
|
|
14
|
+
--tree-border-color: #e0e0e0;
|
|
15
|
+
--tree-connector-color: #bdbdbd;
|
|
16
|
+
--tree-hover-bg: #f5f5f5;
|
|
17
|
+
--tree-selected-bg: #e3f2fd;
|
|
18
|
+
--tree-selected-color: #1976d2;
|
|
19
|
+
--tree-focused-outline: #2196f3;
|
|
20
|
+
--tree-disabled-color: #9e9e9e;
|
|
21
|
+
--tree-disabled-bg: #fafafa;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Dark theme
|
|
25
|
+
[data-theme="dark"],
|
|
26
|
+
.dark-theme,
|
|
27
|
+
body.dark {
|
|
28
|
+
--tree-bg-color: #1e1e1e;
|
|
29
|
+
--tree-text-color: #e0e0e0;
|
|
30
|
+
--tree-text-color-secondary: #a0a0a0;
|
|
31
|
+
--tree-border-color: #333333;
|
|
32
|
+
--tree-connector-color: #555555;
|
|
33
|
+
--tree-hover-bg: #2d2d2d;
|
|
34
|
+
--tree-selected-bg: #282a45;
|
|
35
|
+
--tree-selected-color: #90caf9;
|
|
36
|
+
--tree-focused-outline: #64b5f6;
|
|
37
|
+
--tree-disabled-color: #616161;
|
|
38
|
+
--tree-disabled-bg: #2d2d2d;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.tree-view {
|
|
42
|
+
background-color: var(--tree-bg-color);
|
|
43
|
+
color: var(--tree-text-color);
|
|
44
|
+
border: 1px solid var(--tree-border-color);
|
|
45
|
+
border-radius: 4px;
|
|
46
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
47
|
+
font-size: 14px;
|
|
48
|
+
line-height: 1.5;
|
|
49
|
+
|
|
50
|
+
.tree-root {
|
|
51
|
+
list-style: none;
|
|
52
|
+
margin: 0;
|
|
53
|
+
padding: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.tree-node {
|
|
57
|
+
list-style: none;
|
|
58
|
+
position: relative;
|
|
59
|
+
margin: 0;
|
|
60
|
+
padding: 0;
|
|
61
|
+
|
|
62
|
+
&.disabled {
|
|
63
|
+
opacity: 0.6;
|
|
64
|
+
cursor: not-allowed;
|
|
65
|
+
|
|
66
|
+
.tree-node-content {
|
|
67
|
+
pointer-events: none;
|
|
68
|
+
color: var(--tree-disabled-color);
|
|
69
|
+
background-color: var(--tree-disabled-bg);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.tree-node-content {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
min-height: var(--tree-node-height);
|
|
78
|
+
padding: 4px 8px;
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
position: relative;
|
|
81
|
+
transition: all 0.2s ease;
|
|
82
|
+
user-select: none;
|
|
83
|
+
|
|
84
|
+
&:hover:not(:disabled) {
|
|
85
|
+
background-color: var(--tree-hover-bg);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Selected state
|
|
90
|
+
.tree-node.selected .tree-node-content {
|
|
91
|
+
background-color: var(--tree-selected-bg);
|
|
92
|
+
color: var(--tree-selected-color);
|
|
93
|
+
font-weight: 500;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Focused state
|
|
97
|
+
.tree-node.focused .tree-node-content {
|
|
98
|
+
background-color: var(--tree-hover-bg);
|
|
99
|
+
border-right: 1px solid var(--tree-focused-outline);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.tree-node.selected.focused .tree-node-content {
|
|
103
|
+
background-color: var(--tree-selected-bg);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// VSCode-style connector lines (can be toggled via showConnectors prop)
|
|
107
|
+
&.show-connectors {
|
|
108
|
+
.tree-connectors {
|
|
109
|
+
position: absolute;
|
|
110
|
+
top: 0;
|
|
111
|
+
left: 0;
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: 100%;
|
|
114
|
+
pointer-events: none;
|
|
115
|
+
z-index: 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.tree-connector {
|
|
119
|
+
position: absolute;
|
|
120
|
+
top: 0;
|
|
121
|
+
height: 100%;
|
|
122
|
+
width: var(--tree-connector-width);
|
|
123
|
+
background-color: var(--tree-connector-color);
|
|
124
|
+
|
|
125
|
+
// Horizontal connector to the node
|
|
126
|
+
&::after {
|
|
127
|
+
content: '';
|
|
128
|
+
position: absolute;
|
|
129
|
+
top: calc(var(--tree-node-height) / 2);
|
|
130
|
+
left: 0;
|
|
131
|
+
width: 12px;
|
|
132
|
+
height: var(--tree-connector-width);
|
|
133
|
+
background-color: var(--tree-connector-color);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// For the last child at the deepest level only, show half the vertical line
|
|
138
|
+
// But only if there are no more siblings at any parent level
|
|
139
|
+
.tree-node:last-child .tree-node-content .tree-connector:last-child {
|
|
140
|
+
height: calc(var(--tree-node-height) / 2 + 2px);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Override for nodes that have siblings at parent levels - keep full height
|
|
144
|
+
.tree-node:not(.tree-last-in-branch) .tree-node-content .tree-connector {
|
|
145
|
+
height: 100% !important;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Expand/collapse icon
|
|
150
|
+
.tree-expand-icon {
|
|
151
|
+
display: flex;
|
|
152
|
+
align-items: center;
|
|
153
|
+
justify-content: center;
|
|
154
|
+
width: var(--tree-expand-icon-size);
|
|
155
|
+
height: var(--tree-expand-icon-size);
|
|
156
|
+
margin-right: 8px;
|
|
157
|
+
margin-left: 2px;
|
|
158
|
+
cursor: pointer;
|
|
159
|
+
border-radius: 3px;
|
|
160
|
+
transition: all 0.2s ease;
|
|
161
|
+
flex-shrink: 0;
|
|
162
|
+
|
|
163
|
+
&:hover {
|
|
164
|
+
background-color: var(--tree-hover-bg);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Plus/minus style
|
|
168
|
+
&.plus-minus {
|
|
169
|
+
.tree-plus-minus {
|
|
170
|
+
display: flex;
|
|
171
|
+
align-items: center;
|
|
172
|
+
justify-content: center;
|
|
173
|
+
width: 16px;
|
|
174
|
+
height: 16px;
|
|
175
|
+
border: 1px solid var(--tree-connector-color);
|
|
176
|
+
border-radius: 2px;
|
|
177
|
+
background-color: var(--tree-bg-color);
|
|
178
|
+
font-size: 12px;
|
|
179
|
+
font-weight: bold;
|
|
180
|
+
line-height: 1;
|
|
181
|
+
transition: all 0.2s ease;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Triangle style
|
|
186
|
+
&.triangle {
|
|
187
|
+
.tree-triangle {
|
|
188
|
+
font-size: 10px;
|
|
189
|
+
transition: transform 0.2s ease;
|
|
190
|
+
color: var(--tree-text-color-secondary);
|
|
191
|
+
|
|
192
|
+
&.expanded {
|
|
193
|
+
transform: rotate(90deg);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Caret/chevron style
|
|
199
|
+
.tree-caret-icon,
|
|
200
|
+
.tree-chevron-icon {
|
|
201
|
+
transition: transform 0.2s ease;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Spacer for nodes without children to maintain alignment
|
|
206
|
+
.tree-expand-spacer {
|
|
207
|
+
width: var(--tree-expand-icon-size);
|
|
208
|
+
height: var(--tree-expand-icon-size);
|
|
209
|
+
margin-right: 8px;
|
|
210
|
+
margin-left: 2px;
|
|
211
|
+
flex-shrink: 0;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Selection indicator (checkbox for multiple selection)
|
|
215
|
+
.tree-selection-indicator {
|
|
216
|
+
margin-right: 8px;
|
|
217
|
+
flex-shrink: 0;
|
|
218
|
+
|
|
219
|
+
input[type="checkbox"] {
|
|
220
|
+
width: 16px;
|
|
221
|
+
height: 16px;
|
|
222
|
+
margin: 0;
|
|
223
|
+
cursor: pointer;
|
|
224
|
+
accent-color: var(--tree-selected-color);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Node icon
|
|
229
|
+
.tree-node-icon {
|
|
230
|
+
margin-right: 8px;
|
|
231
|
+
font-size: 18px;
|
|
232
|
+
color: var(--tree-text-color-secondary);
|
|
233
|
+
flex-shrink: 0;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Node label
|
|
237
|
+
.tree-node-label {
|
|
238
|
+
flex: 1;
|
|
239
|
+
overflow: hidden;
|
|
240
|
+
text-overflow: ellipsis;
|
|
241
|
+
white-space: nowrap;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Children container
|
|
245
|
+
.tree-children {
|
|
246
|
+
list-style: none;
|
|
247
|
+
margin: 0;
|
|
248
|
+
padding: 0;
|
|
249
|
+
overflow: hidden;
|
|
250
|
+
transition: all 0.3s ease;
|
|
251
|
+
|
|
252
|
+
// Animation states
|
|
253
|
+
&.tree-collapsing {
|
|
254
|
+
max-height: 0;
|
|
255
|
+
opacity: 0;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
&.tree-expanding {
|
|
259
|
+
max-height: 1000px; // Large enough value for content
|
|
260
|
+
opacity: 1;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Smooth expand/collapse animations
|
|
266
|
+
.tree-node {
|
|
267
|
+
.tree-children {
|
|
268
|
+
animation-duration: 0.3s;
|
|
269
|
+
animation-fill-mode: both;
|
|
270
|
+
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Animation keyframes
|
|
275
|
+
@keyframes tree-expand {
|
|
276
|
+
from {
|
|
277
|
+
max-height: 0;
|
|
278
|
+
opacity: 0;
|
|
279
|
+
}
|
|
280
|
+
to {
|
|
281
|
+
max-height: 1000px;
|
|
282
|
+
opacity: 1;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
@keyframes tree-collapse {
|
|
287
|
+
from {
|
|
288
|
+
max-height: 1000px;
|
|
289
|
+
opacity: 1;
|
|
290
|
+
}
|
|
291
|
+
to {
|
|
292
|
+
max-height: 0;
|
|
293
|
+
opacity: 0;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Responsive adjustments
|
|
298
|
+
@media (max-width: 768px) {
|
|
299
|
+
.tree-view {
|
|
300
|
+
--tree-node-height: 40px;
|
|
301
|
+
--tree-indent-size: 20px;
|
|
302
|
+
|
|
303
|
+
.tree-node-content {
|
|
304
|
+
padding: 0 12px;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// High contrast mode support
|
|
310
|
+
@media (prefers-contrast: high) {
|
|
311
|
+
.tree-view {
|
|
312
|
+
--tree-border-color: #000000;
|
|
313
|
+
--tree-connector-color: #000000;
|
|
314
|
+
--tree-focused-outline: #0066cc;
|
|
315
|
+
|
|
316
|
+
.tree-node-content:focus {
|
|
317
|
+
outline-width: 3px;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Reduced motion support
|
|
323
|
+
@media (prefers-reduced-motion: reduce) {
|
|
324
|
+
.tree-view {
|
|
325
|
+
.tree-children,
|
|
326
|
+
.tree-expand-icon .tree-triangle,
|
|
327
|
+
.tree-expand-icon .tree-caret-icon,
|
|
328
|
+
.tree-expand-icon .tree-plus-minus,
|
|
329
|
+
.tree-node-content {
|
|
330
|
+
transition: none;
|
|
331
|
+
animation: none;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Print styles
|
|
337
|
+
@media print {
|
|
338
|
+
.tree-view {
|
|
339
|
+
--tree-bg-color: white;
|
|
340
|
+
--tree-text-color: black;
|
|
341
|
+
--tree-border-color: black;
|
|
342
|
+
|
|
343
|
+
.tree-expand-icon {
|
|
344
|
+
display: none;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.tree-children {
|
|
348
|
+
display: block !important;
|
|
349
|
+
opacity: 1 !important;
|
|
350
|
+
max-height: none !important;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
package/sass/materialize.scss
CHANGED