mithril-materialized 2.0.0-beta.6 → 2.0.0-beta.8

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/index.umd.js CHANGED
@@ -1094,8 +1094,8 @@
1094
1094
  maxHeight: '200px',
1095
1095
  overflow: 'auto',
1096
1096
  zIndex: 1000,
1097
- backgroundColor: '#fff',
1098
- boxShadow: '0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.2)',
1097
+ backgroundColor: 'var(--mm-surface-color, #fff)',
1098
+ boxShadow: '0 2px 2px 0 var(--mm-shadow-penumbra, rgba(0,0,0,0.14)), 0 3px 1px -2px var(--mm-shadow-umbra, rgba(0,0,0,0.12)), 0 1px 5px 0 var(--mm-shadow-ambient, rgba(0,0,0,0.2))',
1099
1099
  },
1100
1100
  }, state.autocompleteItems.map((item, index) => m('li.autocomplete-item', {
1101
1101
  key: item.tag,
@@ -1103,7 +1103,8 @@
1103
1103
  style: {
1104
1104
  padding: '12px 16px',
1105
1105
  cursor: 'pointer',
1106
- backgroundColor: state.selectedAutocompleteIndex === index ? '#eee' : 'transparent',
1106
+ backgroundColor: state.selectedAutocompleteIndex === index ? 'var(--mm-border-color, #eee)' : 'transparent',
1107
+ color: 'var(--mm-text-primary, inherit)',
1107
1108
  },
1108
1109
  onmousedown: (e) => {
1109
1110
  e.preventDefault();
@@ -2324,7 +2325,7 @@
2324
2325
  }, oncreate: ({ dom }) => {
2325
2326
  const textarea = (state.textarea = dom);
2326
2327
  // Set initial value and height if provided
2327
- if (initialValue !== undefined) {
2328
+ if (initialValue) {
2328
2329
  textarea.value = String(initialValue);
2329
2330
  updateHeight(textarea);
2330
2331
  // } else {
@@ -2367,7 +2368,7 @@
2367
2368
  if (onchange && state.textarea) {
2368
2369
  onchange(state.textarea.value);
2369
2370
  }
2370
- }, value: initialValue, onkeyup: onkeyup
2371
+ }, onkeyup: onkeyup
2371
2372
  ? (ev) => {
2372
2373
  onkeyup(ev, ev.target.value);
2373
2374
  }
@@ -2384,7 +2385,7 @@
2384
2385
  label,
2385
2386
  id,
2386
2387
  isMandatory,
2387
- isActive: ((_a = state.textarea) === null || _a === void 0 ? void 0 : _a.value) || initialValue || placeholder || state.active,
2388
+ isActive: ((_a = state.textarea) === null || _a === void 0 ? void 0 : _a.value) || placeholder || state.active,
2388
2389
  }),
2389
2390
  m(HelperText, {
2390
2391
  helperText,
@@ -2452,7 +2453,7 @@
2452
2453
  input.focus();
2453
2454
  }
2454
2455
  // Set initial value if provided
2455
- if (initialValue !== undefined) {
2456
+ if (initialValue) {
2456
2457
  input.value = String(initialValue);
2457
2458
  }
2458
2459
  // Update character count state for counter component
@@ -2556,14 +2557,13 @@
2556
2557
  if (onchange && state.inputElement) {
2557
2558
  onchange(getValue(state.inputElement));
2558
2559
  }
2559
- }, value: initialValue })),
2560
+ } })),
2560
2561
  m(Label, {
2561
2562
  label,
2562
2563
  id,
2563
2564
  isMandatory,
2564
2565
  isActive: state.active ||
2565
2566
  ((_a = state.inputElement) === null || _a === void 0 ? void 0 : _a.value) ||
2566
- initialValue ||
2567
2567
  placeholder ||
2568
2568
  type === 'number' ||
2569
2569
  type === 'color' ||
@@ -2642,7 +2642,7 @@
2642
2642
  i.value = initialValue;
2643
2643
  },
2644
2644
  })),
2645
- (canClear || initialValue) &&
2645
+ (canClear || (i === null || i === void 0 ? void 0 : i.value)) &&
2646
2646
  m('a.waves-effect.waves-teal.btn-flat', {
2647
2647
  style: {
2648
2648
  float: 'right',
@@ -4383,13 +4383,9 @@
4383
4383
  /** CSS-only Tabs component - no MaterializeCSS dependencies */
4384
4384
  const Tabs = () => {
4385
4385
  const toAnchored = () => {
4386
- let activeTabFound = false;
4387
4386
  return (tab) => {
4388
- const active = activeTabFound ? false : tab.active;
4389
- if (active)
4390
- activeTabFound = true;
4391
4387
  const tabId = createId(tab.title, tab.id);
4392
- return Object.assign(Object.assign({}, tab), { active, tabId, anchorId: `anchor-${tabId}` });
4388
+ return Object.assign(Object.assign({}, tab), { tabId, anchorId: `anchor-${tabId}` });
4393
4389
  };
4394
4390
  };
4395
4391
  const state = {
@@ -4400,7 +4396,9 @@
4400
4396
  indicatorStyle: {
4401
4397
  left: '0px',
4402
4398
  width: '0px',
4403
- }};
4399
+ },
4400
+ lastIndicatorUpdate: '',
4401
+ };
4404
4402
  const createId = (title, id) => (id ? id : title.replace(/ /g, '').toLowerCase());
4405
4403
  const updateIndicator = () => {
4406
4404
  const tabElement = document.getElementById(state.activeTabId);
@@ -4422,6 +4420,7 @@
4422
4420
  }
4423
4421
  };
4424
4422
  const handleTabClick = (tabId, tabElement, attrs) => {
4423
+ console.log({ state, tabId });
4425
4424
  if (state.activeTabId === tabId)
4426
4425
  return;
4427
4426
  state.activeTabId = tabId;
@@ -4481,20 +4480,15 @@
4481
4480
  const selectedTab = selectedTabId ? anchoredTabs.find((a) => a.tabId === selectedTabId) : undefined;
4482
4481
  if (selectedTab) {
4483
4482
  state.activeTabId = selectedTab.tabId;
4484
- selectedTab.active = true;
4485
4483
  return selectedTab;
4486
4484
  }
4487
- const activeTab = anchoredTabs.find((t) => t.active);
4488
- if (activeTab) {
4489
- // Active tab property takes precedence over selectedTabId
4490
- state.activeTabId = activeTab.tabId;
4491
- return activeTab;
4492
- }
4485
+ const curTab = state.activeTabId && anchoredTabs.find((a) => a.tabId === state.activeTabId);
4486
+ if (curTab)
4487
+ return curTab;
4493
4488
  // Default to first non-disabled tab
4494
- const firstAvailableTab = anchoredTabs.find((t) => !t.disabled && !t.href);
4489
+ const firstAvailableTab = anchoredTabs.find((a) => !a.disabled && !a.href);
4495
4490
  if (firstAvailableTab) {
4496
4491
  state.activeTabId = firstAvailableTab.tabId;
4497
- firstAvailableTab.active = true;
4498
4492
  return firstAvailableTab;
4499
4493
  }
4500
4494
  return undefined;
@@ -4533,7 +4527,7 @@
4533
4527
  disabled,
4534
4528
  }, m('a', {
4535
4529
  id: anchorId,
4536
- className: tab.active ? 'active' : undefined,
4530
+ className: tab.tabId === state.activeTabId ? 'active' : undefined,
4537
4531
  target,
4538
4532
  href: href || `#${anchorId}`,
4539
4533
  onclick: disabled || href
@@ -4724,7 +4718,7 @@
4724
4718
  placeholder &&
4725
4719
  m('span.placeholder', {
4726
4720
  style: {
4727
- color: '#9e9e9e',
4721
+ color: 'var(--mm-text-hint, #9e9e9e)',
4728
4722
  flexGrow: 1,
4729
4723
  padding: '8px 0',
4730
4724
  },
@@ -4786,7 +4780,9 @@
4786
4780
  fontSize: '0.875rem',
4787
4781
  border: 'none',
4788
4782
  padding: '8px 0',
4789
- borderBottom: '1px solid #9e9e9e',
4783
+ borderBottom: '1px solid var(--mm-input-border, #9e9e9e)',
4784
+ backgroundColor: 'transparent',
4785
+ color: 'var(--mm-text-primary, inherit)',
4790
4786
  },
4791
4787
  }),
4792
4788
  ]),
package/dist/tabs.d.ts CHANGED
@@ -14,8 +14,6 @@ export interface TabItem {
14
14
  vnode?: Vnode<any, any>;
15
15
  /** ID of the tab element. Default the title in lowercase */
16
16
  id?: string;
17
- /** If the tab should be active */
18
- active?: boolean;
19
17
  /** If the tab should be disabled */
20
18
  disabled?: boolean;
21
19
  /** CSS class for the tab (li), default `.tab.col.s3` */
@@ -2199,18 +2199,18 @@ table span.badge {
2199
2199
  height: 32px;
2200
2200
  font-size: 13px;
2201
2201
  font-weight: 500;
2202
- color: rgba(0, 0, 0, 0.6);
2202
+ color: var(--mm-text-secondary, rgba(0, 0, 0, 0.6));
2203
2203
  line-height: 32px;
2204
2204
  padding: 0 12px;
2205
2205
  border-radius: 16px;
2206
- background-color: #e4e4e4;
2206
+ background-color: var(--mm-chip-bg, #e4e4e4);
2207
2207
  margin-bottom: 5px;
2208
2208
  margin-right: 5px;
2209
2209
  }
2210
2210
  .chip:focus {
2211
2211
  outline: none;
2212
- background-color: #26a69a;
2213
- color: #fff;
2212
+ background-color: var(--mm-primary-color, #26a69a);
2213
+ color: var(--mm-button-text, #fff);
2214
2214
  }
2215
2215
  .chip > img {
2216
2216
  float: left;
@@ -2229,7 +2229,7 @@ table span.badge {
2229
2229
 
2230
2230
  .chips {
2231
2231
  border: none;
2232
- border-bottom: 1px solid #9e9e9e;
2232
+ border-bottom: 1px solid var(--mm-input-border, #9e9e9e);
2233
2233
  box-shadow: none;
2234
2234
  margin: 0 0 8px 0;
2235
2235
  min-height: 45px;
@@ -2237,8 +2237,8 @@ table span.badge {
2237
2237
  transition: all 0.3s;
2238
2238
  }
2239
2239
  .chips.focus {
2240
- border-bottom: 1px solid #26a69a;
2241
- box-shadow: 0 1px 0 0 #26a69a;
2240
+ border-bottom: 1px solid var(--mm-primary-color, #26a69a);
2241
+ box-shadow: 0 1px 0 0 var(--mm-primary-color, #26a69a);
2242
2242
  }
2243
2243
  .chips:hover {
2244
2244
  cursor: text;
@@ -2246,7 +2246,7 @@ table span.badge {
2246
2246
  .chips .input {
2247
2247
  background: none;
2248
2248
  border: 0;
2249
- color: rgba(0, 0, 0, 0.6);
2249
+ color: var(--mm-text-primary, rgba(0, 0, 0, 0.6));
2250
2250
  display: inline-block;
2251
2251
  font-size: 16px;
2252
2252
  height: 3rem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mithril-materialized",
3
- "version": "2.0.0-beta.6",
3
+ "version": "2.0.0-beta.8",
4
4
  "description": "A materialize library for mithril.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -3,19 +3,19 @@
3
3
  .chip {
4
4
  &:focus {
5
5
  outline: none;
6
- background-color: variables.$chip-selected-color;
7
- color: #fff;
6
+ background-color: var(--mm-primary-color, variables.$chip-selected-color);
7
+ color: var(--mm-button-text, #fff);
8
8
  }
9
9
 
10
10
  display: inline-block;
11
11
  height: 32px;
12
12
  font-size: 13px;
13
13
  font-weight: 500;
14
- color: rgba(0,0,0,.6);
14
+ color: var(--mm-text-secondary, rgba(0,0,0,.6));
15
15
  line-height: 32px;
16
16
  padding: 0 12px;
17
17
  border-radius: 16px;
18
- background-color: variables.$chip-bg-color;
18
+ background-color: var(--mm-chip-bg, variables.$chip-bg-color);
19
19
  margin-bottom: variables.$chip-margin;
20
20
  margin-right: variables.$chip-margin;
21
21
 
@@ -38,7 +38,7 @@
38
38
 
39
39
  .chips {
40
40
  border: none;
41
- border-bottom: 1px solid variables.$chip-border-color;
41
+ border-bottom: 1px solid var(--mm-input-border, variables.$chip-border-color);
42
42
  box-shadow: none;
43
43
  margin: variables.$input-margin;
44
44
  min-height: 45px;
@@ -46,8 +46,8 @@
46
46
  transition: all .3s;
47
47
 
48
48
  &.focus {
49
- border-bottom: 1px solid variables.$chip-selected-color;
50
- box-shadow: 0 1px 0 0 variables.$chip-selected-color;
49
+ border-bottom: 1px solid var(--mm-primary-color, variables.$chip-selected-color);
50
+ box-shadow: 0 1px 0 0 var(--mm-primary-color, variables.$chip-selected-color);
51
51
  }
52
52
 
53
53
  &:hover {
@@ -57,7 +57,7 @@
57
57
  .input {
58
58
  background: none;
59
59
  border: 0;
60
- color: rgba(0,0,0,.6);
60
+ color: var(--mm-text-primary, rgba(0,0,0,.6));
61
61
  display: inline-block;
62
62
  font-size: variables.$input-font-size;
63
63
  height: variables.$input-height;
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
  @extend .z-depth-1 !optional;
13
- background-color: variables.$dropdown-bg-color;
13
+ background-color: var(--mm-surface-color, variables.$dropdown-bg-color);
14
14
  margin: 0;
15
15
  display: none;
16
16
  min-width: 100px;
@@ -25,7 +25,7 @@
25
25
 
26
26
  li {
27
27
  &:hover, &.active {
28
- background-color: variables.$dropdown-hover-bg-color;
28
+ background-color: var(--mm-dropdown-hover, variables.$dropdown-hover-bg-color);
29
29
  }
30
30
 
31
31
  &:focus {
@@ -39,7 +39,7 @@
39
39
 
40
40
  & > a, & > span {
41
41
  font-size: 16px;
42
- color: variables.$dropdown-color;
42
+ color: var(--mm-text-primary, variables.$dropdown-color);
43
43
  display: block;
44
44
  line-height: 22px;
45
45
  padding: math.div((variables.$dropdown-item-height - 22px), 2) 16px;
@@ -62,7 +62,7 @@
62
62
 
63
63
 
64
64
  clear: both;
65
- color: variables.$off-black;
65
+ color: var(--mm-text-primary, variables.$off-black);
66
66
  cursor: pointer;
67
67
  min-height: variables.$dropdown-item-height;
68
68
  line-height: 1.5rem;
@@ -73,7 +73,7 @@
73
73
 
74
74
  body.keyboard-focused {
75
75
  .dropdown-content li:focus {
76
- background-color: color.adjust(variables.$dropdown-hover-bg-color, $lightness: -8%);
76
+ background-color: var(--mm-dropdown-focus, color.adjust(variables.$dropdown-hover-bg-color, $lightness: -8%));
77
77
  }
78
78
  }
79
79
 
@@ -48,6 +48,15 @@
48
48
 
49
49
  // Shadow colors
50
50
  --mm-shadow-color: rgba(0, 0, 0, 0.16);
51
+
52
+ // Chip colors
53
+ --mm-chip-bg: #e4e4e4;
54
+ --mm-chip-text: var(--mm-text-secondary);
55
+
56
+ // Dropdown colors
57
+ --mm-dropdown-hover: #eee;
58
+ --mm-dropdown-focus: #ddd;
59
+ --mm-dropdown-selected: #e3f2fd;
51
60
  --mm-shadow-umbra: rgba(0, 0, 0, 0.2);
52
61
  --mm-shadow-penumbra: rgba(0, 0, 0, 0.14);
53
62
  --mm-shadow-ambient: rgba(0, 0, 0, 0.12);
@@ -123,6 +132,15 @@ body {
123
132
  --mm-shadow-penumbra: rgba(0, 0, 0, 0.36);
124
133
  --mm-shadow-ambient: rgba(0, 0, 0, 0.3);
125
134
 
135
+ // Chip colors
136
+ --mm-chip-bg: #424242;
137
+ --mm-chip-text: var(--mm-text-secondary);
138
+
139
+ // Dropdown colors
140
+ --mm-dropdown-hover: #444;
141
+ --mm-dropdown-focus: #555;
142
+ --mm-dropdown-selected: #1e3a8a;
143
+
126
144
  // Switch colors (dark theme)
127
145
  --mm-switch-checked-track: rgba(128, 203, 196, 0.3);
128
146
  --mm-switch-checked-thumb: #80cbc4;
@@ -179,7 +179,7 @@
179
179
 
180
180
  .timepicker-tick.active,
181
181
  .timepicker-tick:hover {
182
- background-color: transparentize(variables.$secondary-color, .75);
182
+ background-color: color.scale(variables.$secondary-color, $alpha: -75%);
183
183
  }
184
184
  .timepicker-dial {
185
185
  transition: transform 350ms, opacity 350ms;
@@ -86,7 +86,7 @@ select {
86
86
  bottom: 0;
87
87
  margin: auto 0;
88
88
  z-index: 0;
89
- fill: rgba(0,0,0,.87);
89
+ fill: var(--mm-text-primary, rgba(0,0,0,.87));
90
90
  }
91
91
 
92
92
  & + label {
@@ -134,24 +134,24 @@ select:disabled {
134
134
  .select-dropdown li.disabled,
135
135
  .select-dropdown li.disabled > span,
136
136
  .select-dropdown li.optgroup {
137
- color: variables.$select-disabled-color;
137
+ color: var(--mm-text-disabled, variables.$select-disabled-color);
138
138
  background-color: transparent;
139
139
  }
140
140
 
141
141
  body.keyboard-focused {
142
142
  .select-dropdown.dropdown-content li:focus {
143
- background-color: variables.$select-option-focus;
143
+ background-color: var(--mm-dropdown-focus, variables.$select-option-focus);
144
144
  }
145
145
  }
146
146
 
147
147
  .select-dropdown.dropdown-content {
148
148
  li {
149
149
  &:hover {
150
- background-color: variables.$select-option-hover;
150
+ background-color: var(--mm-dropdown-hover, variables.$select-option-hover);
151
151
  }
152
152
 
153
153
  &.selected {
154
- background-color: variables.$select-option-selected;
154
+ background-color: var(--mm-dropdown-selected, variables.$select-option-selected);
155
155
  }
156
156
  }
157
157
  }
@@ -177,14 +177,14 @@ body.keyboard-focused {
177
177
 
178
178
  // Optgroup styles
179
179
  .select-dropdown li.optgroup {
180
- border-top: 1px solid variables.$dropdown-hover-bg-color;
180
+ border-top: 1px solid var(--mm-border-color, variables.$dropdown-hover-bg-color);
181
181
 
182
182
  &.selected > span {
183
- color: rgba(0, 0, 0, .7);
183
+ color: var(--mm-text-secondary, rgba(0, 0, 0, .7));
184
184
  }
185
185
 
186
186
  & > span {
187
- color: rgba(0, 0, 0, .4);
187
+ color: var(--mm-text-hint, rgba(0, 0, 0, .4));
188
188
  }
189
189
 
190
190
  & ~ li.optgroup-option {