@materializecss/materialize 2.0.1-alpha → 2.0.3-alpha
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/Gruntfile.js +5 -2
- package/dist/css/materialize.css +1510 -288
- package/dist/css/materialize.min.css +2 -2
- package/dist/js/materialize.js +2782 -2688
- package/dist/js/materialize.min.js +2 -8967
- package/dist/js/materialize.min.js.map +1 -1
- package/dist/src/autocomplete.d.ts +143 -0
- package/dist/src/autocomplete.d.ts.map +1 -0
- package/dist/src/bounding.d.ts +7 -0
- package/dist/src/bounding.d.ts.map +1 -0
- package/dist/src/buttons.d.ts +65 -0
- package/dist/src/buttons.d.ts.map +1 -0
- package/dist/src/cards.d.ts +4 -0
- package/dist/src/cards.d.ts.map +1 -0
- package/dist/src/carousel.d.ts +131 -0
- package/dist/src/carousel.d.ts.map +1 -0
- package/dist/src/characterCounter.d.ts +37 -0
- package/dist/src/characterCounter.d.ts.map +1 -0
- package/dist/src/chips.d.ts +131 -0
- package/dist/src/chips.d.ts.map +1 -0
- package/dist/src/collapsible.d.ts +74 -0
- package/dist/src/collapsible.d.ts.map +1 -0
- package/dist/src/component.d.ts +74 -0
- package/dist/src/component.d.ts.map +1 -0
- package/dist/src/datepicker.d.ts +248 -0
- package/dist/src/datepicker.d.ts.map +1 -0
- package/dist/src/dropdown.d.ts +148 -0
- package/dist/src/dropdown.d.ts.map +1 -0
- package/dist/src/edges.d.ts +7 -0
- package/dist/src/edges.d.ts.map +1 -0
- package/dist/src/forms.d.ts +12 -0
- package/dist/src/forms.d.ts.map +1 -0
- package/dist/src/global.d.ts +60 -0
- package/dist/src/global.d.ts.map +1 -0
- package/dist/src/index.d.ts +27 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/materialbox.d.ts +92 -0
- package/dist/src/materialbox.d.ts.map +1 -0
- package/dist/src/modal.d.ts +119 -0
- package/dist/src/modal.d.ts.map +1 -0
- package/dist/src/parallax.d.ts +40 -0
- package/dist/src/parallax.d.ts.map +1 -0
- package/dist/src/pushpin.d.ts +52 -0
- package/dist/src/pushpin.d.ts.map +1 -0
- package/dist/src/range.d.ts +41 -0
- package/dist/src/range.d.ts.map +1 -0
- package/dist/src/scrollspy.d.ts +62 -0
- package/dist/src/scrollspy.d.ts.map +1 -0
- package/dist/src/select.d.ts +77 -0
- package/dist/src/select.d.ts.map +1 -0
- package/dist/src/sidenav.d.ts +122 -0
- package/dist/src/sidenav.d.ts.map +1 -0
- package/dist/src/slider.d.ts +103 -0
- package/dist/src/slider.d.ts.map +1 -0
- package/dist/src/tabs.d.ts +80 -0
- package/dist/src/tabs.d.ts.map +1 -0
- package/dist/src/tapTarget.d.ts +59 -0
- package/dist/src/tapTarget.d.ts.map +1 -0
- package/dist/src/timepicker.d.ts +208 -0
- package/dist/src/timepicker.d.ts.map +1 -0
- package/dist/src/toasts.d.ts +90 -0
- package/dist/src/toasts.d.ts.map +1 -0
- package/dist/src/tooltip.d.ts +112 -0
- package/dist/src/tooltip.d.ts.map +1 -0
- package/dist/src/utils.d.ts +97 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/waves.d.ts +16 -0
- package/dist/src/waves.d.ts.map +1 -0
- package/package.json +4 -1
- package/sass/components/_cards.scss +1 -1
- package/sass/components/_collapsible.scss +0 -41
- package/sass/components/_global.scss +53 -2
- package/sass/components/_grid.scss +28 -47
- package/sass/components/_icons-material-design.scss +2 -1
- package/sass/components/_navbar.scss +30 -27
- package/sass/components/_pulse.scss +1 -0
- package/sass/components/_sidenav.scss +63 -45
- package/sass/components/_theme_variables.scss +29 -49
- package/sass/components/_typography.scss +2 -2
- package/sass/components/_variables.scss +2 -0
- package/sass/components/colors.module.scss +180 -0
- package/sass/components/forms/_input-fields.scss +4 -10
- package/sass/components/theme.dark.module.scss +32 -0
- package/sass/components/theme.light.module.scss +32 -0
- package/sass/components/tokens.module.scss +272 -0
- package/sass/components/typography.module.scss +150 -0
- package/sass/materialize.scss +6 -4
- package/src/autocomplete.ts +188 -94
- package/src/buttons.ts +225 -260
- package/src/cards.ts +5 -6
- package/src/carousel.ts +611 -542
- package/src/characterCounter.ts +50 -21
- package/src/chips.ts +152 -63
- package/src/collapsible.ts +97 -32
- package/src/component.ts +99 -10
- package/src/datepicker.ts +905 -726
- package/src/dropdown.ts +573 -484
- package/src/edges.ts +4 -4
- package/src/forms.ts +36 -24
- package/src/global.ts +57 -328
- package/src/index.ts +26 -0
- package/src/materialbox.ts +354 -298
- package/src/modal.ts +296 -211
- package/src/parallax.ts +129 -105
- package/src/pushpin.ts +148 -103
- package/src/range.ts +166 -150
- package/src/scrollspy.ts +214 -174
- package/src/select.ts +434 -398
- package/src/sidenav.ts +447 -381
- package/src/slider.ts +421 -362
- package/src/tabs.ts +276 -222
- package/src/tapTarget.ts +246 -213
- package/src/timepicker.ts +738 -614
- package/src/toasts.ts +254 -230
- package/src/tooltip.ts +315 -252
- package/src/utils.ts +271 -0
- package/src/waves.ts +10 -10
package/src/range.ts
CHANGED
|
@@ -1,182 +1,198 @@
|
|
|
1
|
-
import { Component } from "./component";
|
|
2
1
|
import anim from "animejs";
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import { Component, BaseOptions, InitElements, MElement } from "./component";
|
|
4
|
+
|
|
5
|
+
export interface RangeOptions extends BaseOptions {};
|
|
6
|
+
|
|
7
|
+
const _defaults: RangeOptions = {};
|
|
5
8
|
|
|
6
9
|
// TODO: !!!!!
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
private _handleRangeInputMousemoveTouchmoveBound: any;
|
|
14
|
-
private _handleRangeMouseupTouchendBound: any;
|
|
15
|
-
private _handleRangeBlurMouseoutTouchleaveBound: any;
|
|
16
|
-
value: HTMLElement;
|
|
17
|
-
thumb: HTMLElement;
|
|
18
|
-
|
|
19
|
-
constructor(el, options) {
|
|
20
|
-
super(Range, el, options);
|
|
21
|
-
(this.el as any).M_Range = this;
|
|
22
|
-
this.options = {...Range.defaults, ...options};
|
|
23
|
-
this._mousedown = false;
|
|
24
|
-
this._setupThumb();
|
|
25
|
-
this._setupEventHandlers();
|
|
26
|
-
}
|
|
11
|
+
export class Range extends Component<RangeOptions> {
|
|
12
|
+
declare el: HTMLInputElement;
|
|
13
|
+
private _mousedown: boolean;
|
|
14
|
+
value: HTMLElement;
|
|
15
|
+
thumb: HTMLElement;
|
|
27
16
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
constructor(el: HTMLInputElement, options: Partial<RangeOptions>) {
|
|
18
|
+
super(el, options, Range);
|
|
19
|
+
(this.el as any).M_Range = this;
|
|
31
20
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
this.options = {
|
|
22
|
+
...Range.defaults,
|
|
23
|
+
...options
|
|
24
|
+
};
|
|
35
25
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
this._mousedown = false;
|
|
27
|
+
this._setupThumb();
|
|
28
|
+
this._setupEventHandlers();
|
|
29
|
+
}
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(this.el as any).M_Range = undefined;
|
|
45
|
-
}
|
|
31
|
+
static get defaults(): RangeOptions {
|
|
32
|
+
return _defaults;
|
|
33
|
+
}
|
|
46
34
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Initializes instance of Range.
|
|
37
|
+
* @param el HTML element.
|
|
38
|
+
* @param options Component options.
|
|
39
|
+
*/
|
|
40
|
+
static init(el: HTMLInputElement, options?: Partial<RangeOptions>): Range;
|
|
41
|
+
/**
|
|
42
|
+
* Initializes instances of Range.
|
|
43
|
+
* @param els HTML elements.
|
|
44
|
+
* @param options Component options.
|
|
45
|
+
*/
|
|
46
|
+
static init(els: InitElements<HTMLInputElement | MElement>, options?: Partial<RangeOptions>): Range[];
|
|
47
|
+
/**
|
|
48
|
+
* Initializes instances of Range.
|
|
49
|
+
* @param els HTML elements.
|
|
50
|
+
* @param options Component options.
|
|
51
|
+
*/
|
|
52
|
+
static init(els: HTMLInputElement | InitElements<HTMLInputElement | MElement>, options: Partial<RangeOptions> = {}): Range | Range[] {
|
|
53
|
+
return super.init(els, options, Range);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static getInstance(el: HTMLInputElement): Range {
|
|
57
|
+
return (el as any).M_Range;
|
|
58
|
+
}
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
destroy() {
|
|
61
|
+
this._removeEventHandlers();
|
|
62
|
+
this._removeThumb();
|
|
63
|
+
(this.el as any).M_Range = undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_setupEventHandlers() {
|
|
67
|
+
this.el.addEventListener('change', this._handleRangeChange);
|
|
68
|
+
this.el.addEventListener('mousedown', this._handleRangeMousedownTouchstart);
|
|
69
|
+
this.el.addEventListener('touchstart', this._handleRangeMousedownTouchstart);
|
|
70
|
+
this.el.addEventListener('input', this._handleRangeInputMousemoveTouchmove);
|
|
71
|
+
this.el.addEventListener('mousemove', this._handleRangeInputMousemoveTouchmove);
|
|
72
|
+
this.el.addEventListener('touchmove', this._handleRangeInputMousemoveTouchmove);
|
|
73
|
+
this.el.addEventListener('mouseup', this._handleRangeMouseupTouchend);
|
|
74
|
+
this.el.addEventListener('touchend', this._handleRangeMouseupTouchend);
|
|
75
|
+
this.el.addEventListener('blur', this._handleRangeBlurMouseoutTouchleave);
|
|
76
|
+
this.el.addEventListener('mouseout', this._handleRangeBlurMouseoutTouchleave);
|
|
77
|
+
this.el.addEventListener('touchleave', this._handleRangeBlurMouseoutTouchleave);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
_removeEventHandlers() {
|
|
81
|
+
this.el.removeEventListener('change', this._handleRangeChange);
|
|
82
|
+
this.el.removeEventListener('mousedown', this._handleRangeMousedownTouchstart);
|
|
83
|
+
this.el.removeEventListener('touchstart', this._handleRangeMousedownTouchstart);
|
|
84
|
+
this.el.removeEventListener('input', this._handleRangeInputMousemoveTouchmove);
|
|
85
|
+
this.el.removeEventListener('mousemove', this._handleRangeInputMousemoveTouchmove);
|
|
86
|
+
this.el.removeEventListener('touchmove', this._handleRangeInputMousemoveTouchmove);
|
|
87
|
+
this.el.removeEventListener('mouseup', this._handleRangeMouseupTouchend);
|
|
88
|
+
this.el.removeEventListener('touchend', this._handleRangeMouseupTouchend);
|
|
89
|
+
this.el.removeEventListener('blur', this._handleRangeBlurMouseoutTouchleave);
|
|
90
|
+
this.el.removeEventListener('mouseout', this._handleRangeBlurMouseoutTouchleave);
|
|
91
|
+
this.el.removeEventListener('touchleave', this._handleRangeBlurMouseoutTouchleave);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
_handleRangeChange = () => {
|
|
95
|
+
this.value.innerHTML = this.el.value;
|
|
96
|
+
if (!this.thumb.classList.contains('active')) {
|
|
97
|
+
this._showRangeBubble();
|
|
78
98
|
}
|
|
99
|
+
const offsetLeft = this._calcRangeOffset();
|
|
100
|
+
this.thumb.classList.add('active');
|
|
101
|
+
this.thumb.style.left = offsetLeft+'px';
|
|
102
|
+
}
|
|
79
103
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
104
|
+
_handleRangeMousedownTouchstart = (e: MouseEvent | TouchEvent) => {
|
|
105
|
+
// Set indicator value
|
|
106
|
+
this.value.innerHTML = this.el.value;
|
|
107
|
+
this._mousedown = true;
|
|
108
|
+
this.el.classList.add('active');
|
|
109
|
+
if (!this.thumb.classList.contains('active')) {
|
|
110
|
+
this._showRangeBubble();
|
|
111
|
+
}
|
|
112
|
+
if (e.type !== 'input') {
|
|
85
113
|
const offsetLeft = this._calcRangeOffset();
|
|
86
114
|
this.thumb.classList.add('active');
|
|
87
115
|
this.thumb.style.left = offsetLeft+'px';
|
|
88
116
|
}
|
|
117
|
+
}
|
|
89
118
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.value.innerHTML = this.el.value;
|
|
93
|
-
this._mousedown = true;
|
|
94
|
-
this.el.classList.add('active');
|
|
119
|
+
_handleRangeInputMousemoveTouchmove = () => {
|
|
120
|
+
if (this._mousedown) {
|
|
95
121
|
if (!this.thumb.classList.contains('active')) {
|
|
96
122
|
this._showRangeBubble();
|
|
97
123
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
_handleRangeInputMousemoveTouchmove() {
|
|
106
|
-
if (this._mousedown) {
|
|
107
|
-
if (!this.thumb.classList.contains('active')) {
|
|
108
|
-
this._showRangeBubble();
|
|
109
|
-
}
|
|
110
|
-
const offsetLeft = this._calcRangeOffset();
|
|
111
|
-
this.thumb.classList.add('active');
|
|
112
|
-
this.thumb.style.left = offsetLeft+'px';
|
|
113
|
-
this.value.innerHTML = this.el.value;
|
|
114
|
-
}
|
|
124
|
+
const offsetLeft = this._calcRangeOffset();
|
|
125
|
+
this.thumb.classList.add('active');
|
|
126
|
+
this.thumb.style.left = offsetLeft+'px';
|
|
127
|
+
this.value.innerHTML = this.el.value;
|
|
115
128
|
}
|
|
129
|
+
}
|
|
116
130
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
131
|
+
_handleRangeMouseupTouchend = () => {
|
|
132
|
+
this._mousedown = false;
|
|
133
|
+
this.el.classList.remove('active');
|
|
134
|
+
}
|
|
121
135
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
this.thumb.classList.remove('active');
|
|
136
|
+
_handleRangeBlurMouseoutTouchleave = () => {
|
|
137
|
+
if (!this._mousedown) {
|
|
138
|
+
const paddingLeft = parseInt(getComputedStyle(this.el).paddingLeft);
|
|
139
|
+
const marginLeft = 7 + paddingLeft + 'px';
|
|
140
|
+
if (this.thumb.classList.contains('active')) {
|
|
141
|
+
anim.remove(this.thumb);
|
|
142
|
+
anim({
|
|
143
|
+
targets: this.thumb,
|
|
144
|
+
height: 0,
|
|
145
|
+
width: 0,
|
|
146
|
+
top: 10,
|
|
147
|
+
easing: 'easeOutQuad',
|
|
148
|
+
marginLeft: marginLeft,
|
|
149
|
+
duration: 100
|
|
150
|
+
});
|
|
139
151
|
}
|
|
152
|
+
this.thumb.classList.remove('active');
|
|
140
153
|
}
|
|
154
|
+
}
|
|
141
155
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
_removeThumb() {
|
|
152
|
-
this.thumb.remove();
|
|
153
|
-
}
|
|
156
|
+
_setupThumb() {
|
|
157
|
+
this.thumb = document.createElement('span');
|
|
158
|
+
this.value = document.createElement('span');
|
|
159
|
+
this.thumb.classList.add('thumb');
|
|
160
|
+
this.value.classList.add('value');
|
|
161
|
+
this.thumb.append(this.value);
|
|
162
|
+
this.el.after(this.thumb);
|
|
163
|
+
}
|
|
154
164
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
anim.remove(this.thumb);
|
|
159
|
-
anim({
|
|
160
|
-
targets: this.thumb,
|
|
161
|
-
height: 30,
|
|
162
|
-
width: 30,
|
|
163
|
-
top: -30,
|
|
164
|
-
marginLeft: marginLeft,
|
|
165
|
-
duration: 300,
|
|
166
|
-
easing: 'easeOutQuint'
|
|
167
|
-
});
|
|
168
|
-
}
|
|
165
|
+
_removeThumb() {
|
|
166
|
+
this.thumb.remove();
|
|
167
|
+
}
|
|
169
168
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
_showRangeBubble() {
|
|
170
|
+
const paddingLeft = parseInt(getComputedStyle(this.thumb.parentElement).paddingLeft);
|
|
171
|
+
const marginLeft = -7 + paddingLeft + 'px'; // TODO: fix magic number?
|
|
172
|
+
anim.remove(this.thumb);
|
|
173
|
+
anim({
|
|
174
|
+
targets: this.thumb,
|
|
175
|
+
height: 30,
|
|
176
|
+
width: 30,
|
|
177
|
+
top: -30,
|
|
178
|
+
marginLeft: marginLeft,
|
|
179
|
+
duration: 300,
|
|
180
|
+
easing: 'easeOutQuint'
|
|
181
|
+
});
|
|
182
|
+
}
|
|
177
183
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
184
|
+
_calcRangeOffset(): number {
|
|
185
|
+
const width = this.el.getBoundingClientRect().width - 15;
|
|
186
|
+
const max = parseFloat(this.el.getAttribute('max')) || 100; // Range default max
|
|
187
|
+
const min = parseFloat(this.el.getAttribute('min')) || 0; // Range default min
|
|
188
|
+
const percent = (parseFloat(this.el.value) - min) / (max - min);
|
|
189
|
+
return percent * width;
|
|
181
190
|
}
|
|
182
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Initializes every range input in the current document.
|
|
194
|
+
*/
|
|
195
|
+
static Init(){
|
|
196
|
+
Range.init((document.querySelectorAll('input[type=range]')) as NodeListOf<HTMLInputElement>, {});
|
|
197
|
+
}
|
|
198
|
+
}
|