@materializecss/materialize 1.2.2 → 2.0.1-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 +68 -313
- package/README.md +26 -14
- package/dist/css/materialize.css +1009 -1822
- package/dist/css/materialize.min.css +2 -8
- package/dist/js/materialize.js +8414 -12299
- package/dist/js/materialize.min.js +8968 -2
- package/dist/js/materialize.min.js.map +1 -0
- package/package.json +13 -9
- package/sass/components/_badges.scss +12 -2
- package/sass/components/_buttons.scss +16 -11
- package/sass/components/_cards.scss +14 -9
- package/sass/components/_carousel.scss +5 -2
- package/sass/components/_chips.scss +3 -3
- package/sass/components/_collapsible.scss +22 -8
- package/sass/components/_collection.scss +14 -6
- package/sass/components/_datepicker.scss +30 -11
- package/sass/components/_dropdown.scss +6 -4
- package/sass/components/_global.scss +132 -111
- package/sass/components/_grid.scss +119 -98
- package/sass/components/_modal.scss +3 -3
- package/sass/components/_navbar.scss +31 -17
- package/sass/components/_normalize.scss +26 -124
- package/sass/components/_sidenav.scss +21 -20
- package/sass/components/_slider.scss +27 -7
- package/sass/components/_table_of_contents.scss +12 -12
- package/sass/components/_tabs.scss +47 -16
- package/sass/components/_tapTarget.scss +6 -6
- package/sass/components/_theme_variables.scss +98 -0
- package/sass/components/_timepicker.scss +54 -46
- package/sass/components/_toast.scss +3 -3
- package/sass/components/_tooltip.scss +4 -5
- package/sass/components/_typography.scss +1 -1
- package/sass/components/_variables.scss +185 -120
- package/sass/components/forms/_checkboxes.scss +9 -9
- package/sass/components/forms/_file-input.scss +9 -7
- package/sass/components/forms/_input-fields.scss +173 -234
- package/sass/components/forms/_radio-buttons.scss +1 -1
- package/sass/components/forms/_range.scss +11 -11
- package/sass/components/forms/_select.scss +29 -19
- package/sass/components/forms/_switches.scss +22 -18
- package/sass/materialize.scss +1 -1
- package/src/autocomplete.ts +459 -0
- package/src/bounding.ts +6 -0
- package/{js/buttons.js → src/buttons.ts} +103 -162
- package/src/cards.ts +54 -0
- package/{js/carousel.js → src/carousel.ts} +137 -262
- package/src/characterCounter.ts +88 -0
- package/src/chips.ts +350 -0
- package/src/collapsible.ts +184 -0
- package/{js/component.js → src/component.ts} +6 -19
- package/{js/datepicker.js → src/datepicker.ts} +213 -299
- package/{js/dropdown.js → src/dropdown.ts} +140 -254
- package/src/edges.ts +6 -0
- package/src/forms.ts +120 -0
- package/src/global.ts +385 -0
- package/src/materialbox.ts +348 -0
- package/src/modal.ts +256 -0
- package/{js/parallax.js → src/parallax.ts} +47 -60
- package/{js/pushpin.js → src/pushpin.ts} +19 -47
- package/{js/range.js → src/range.ts} +58 -139
- package/{js/scrollspy.js → src/scrollspy.ts} +81 -153
- package/src/select.ts +448 -0
- package/{js/sidenav.js → src/sidenav.ts} +96 -202
- package/src/slider.ts +415 -0
- package/src/tabs.ts +293 -0
- package/src/tapTarget.ts +240 -0
- package/{js/timepicker.js → src/timepicker.ts} +268 -272
- package/{js/toasts.js → src/toasts.ts} +75 -134
- package/{js/tooltip.js → src/tooltip.ts} +59 -96
- package/src/waves.ts +70 -0
- package/extras/noUiSlider/nouislider.css +0 -404
- package/extras/noUiSlider/nouislider.js +0 -2147
- package/extras/noUiSlider/nouislider.min.js +0 -1
- package/js/anime.min.js +0 -34
- package/js/autocomplete.js +0 -479
- package/js/cards.js +0 -40
- package/js/cash.js +0 -960
- package/js/characterCounter.js +0 -136
- package/js/chips.js +0 -486
- package/js/collapsible.js +0 -275
- package/js/forms.js +0 -285
- package/js/global.js +0 -428
- package/js/materialbox.js +0 -453
- package/js/modal.js +0 -382
- package/js/select.js +0 -391
- package/js/slider.js +0 -497
- package/js/tabs.js +0 -402
- package/js/tapTarget.js +0 -315
- package/js/waves.js +0 -615
- package/sass/components/_waves.scss +0 -187
|
@@ -1,42 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Component } from "./component";
|
|
2
|
+
import { M } from "./global";
|
|
3
|
+
import anim from "animejs";
|
|
4
|
+
|
|
5
|
+
let _defaults = {
|
|
6
|
+
throttle: 100,
|
|
7
|
+
scrollOffset: 200, // offset - 200 allows elements near bottom of page to scroll
|
|
8
|
+
activeClass: 'active',
|
|
9
|
+
getActiveElement: (id: string): string => { return 'a[href="#'+id+'"]'; }
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export class ScrollSpy extends Component {
|
|
13
|
+
el: HTMLElement;
|
|
14
|
+
static _elements: ScrollSpy[];
|
|
15
|
+
static _count: number;
|
|
16
|
+
static _increment: number;
|
|
17
|
+
tickId: number;
|
|
18
|
+
id: any;
|
|
19
|
+
static _elementsInView: ScrollSpy[];
|
|
20
|
+
static _visibleElements: any[];
|
|
21
|
+
private _handleThrottledResizeBound: any;
|
|
22
|
+
private _handleWindowScrollBound: any;
|
|
23
|
+
static _ticks: number;
|
|
3
24
|
|
|
4
|
-
let _defaults = {
|
|
5
|
-
throttle: 100,
|
|
6
|
-
scrollOffset: 200, // offset - 200 allows elements near bottom of page to scroll
|
|
7
|
-
activeClass: 'active',
|
|
8
|
-
getActiveElement: function(id) {
|
|
9
|
-
return 'a[href="#' + id + '"]';
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @class
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
class ScrollSpy extends Component {
|
|
18
|
-
/**
|
|
19
|
-
* Construct ScrollSpy instance
|
|
20
|
-
* @constructor
|
|
21
|
-
* @param {Element} el
|
|
22
|
-
* @param {Object} options
|
|
23
|
-
*/
|
|
24
25
|
constructor(el, options) {
|
|
25
26
|
super(ScrollSpy, el, options);
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Options for the modal
|
|
31
|
-
* @member Modal#options
|
|
32
|
-
* @prop {Number} [throttle=100] - Throttle of scroll handler
|
|
33
|
-
* @prop {Number} [scrollOffset=200] - Offset for centering element when scrolled to
|
|
34
|
-
* @prop {String} [activeClass='active'] - Class applied to active elements
|
|
35
|
-
* @prop {Function} [getActiveElement] - Used to find active element
|
|
36
|
-
*/
|
|
37
|
-
this.options = $.extend({}, ScrollSpy.defaults, options);
|
|
38
|
-
|
|
39
|
-
// setup
|
|
27
|
+
(this.el as any).M_ScrollSpy = this;
|
|
28
|
+
this.options = {...ScrollSpy.defaults, ...options};
|
|
40
29
|
ScrollSpy._elements.push(this);
|
|
41
30
|
ScrollSpy._count++;
|
|
42
31
|
ScrollSpy._increment++;
|
|
@@ -54,30 +43,22 @@
|
|
|
54
43
|
return super.init(this, els, options);
|
|
55
44
|
}
|
|
56
45
|
|
|
57
|
-
/**
|
|
58
|
-
* Get Instance
|
|
59
|
-
*/
|
|
60
46
|
static getInstance(el) {
|
|
61
47
|
let domElem = !!el.jquery ? el[0] : el;
|
|
62
48
|
return domElem.M_ScrollSpy;
|
|
63
49
|
}
|
|
64
50
|
|
|
65
|
-
/**
|
|
66
|
-
* Teardown component
|
|
67
|
-
*/
|
|
68
51
|
destroy() {
|
|
69
52
|
ScrollSpy._elements.splice(ScrollSpy._elements.indexOf(this), 1);
|
|
70
53
|
ScrollSpy._elementsInView.splice(ScrollSpy._elementsInView.indexOf(this), 1);
|
|
71
|
-
ScrollSpy._visibleElements.splice(ScrollSpy._visibleElements.indexOf(this
|
|
54
|
+
ScrollSpy._visibleElements.splice(ScrollSpy._visibleElements.indexOf(this.el), 1);
|
|
72
55
|
ScrollSpy._count--;
|
|
73
56
|
this._removeEventHandlers();
|
|
74
|
-
|
|
75
|
-
this.
|
|
57
|
+
const actElem = document.querySelector(this.options.getActiveElement(this.el.id));
|
|
58
|
+
actElem.classList.remove(this.options.activeClass);
|
|
59
|
+
(this.el as any).M_ScrollSpy = undefined;
|
|
76
60
|
}
|
|
77
61
|
|
|
78
|
-
/**
|
|
79
|
-
* Setup Event Handlers
|
|
80
|
-
*/
|
|
81
62
|
_setupEventHandlers() {
|
|
82
63
|
let throttledResize = M.throttle(this._handleWindowScroll, 200);
|
|
83
64
|
this._handleThrottledResizeBound = throttledResize.bind(this);
|
|
@@ -89,9 +70,6 @@
|
|
|
89
70
|
}
|
|
90
71
|
}
|
|
91
72
|
|
|
92
|
-
/**
|
|
93
|
-
* Remove Event Handlers
|
|
94
|
-
*/
|
|
95
73
|
_removeEventHandlers() {
|
|
96
74
|
if (ScrollSpy._count === 0) {
|
|
97
75
|
window.removeEventListener('scroll', this._handleWindowScrollBound);
|
|
@@ -100,17 +78,15 @@
|
|
|
100
78
|
}
|
|
101
79
|
}
|
|
102
80
|
|
|
103
|
-
/**
|
|
104
|
-
* Handle Trigger Click
|
|
105
|
-
* @param {Event} e
|
|
106
|
-
*/
|
|
107
81
|
_handleTriggerClick(e) {
|
|
108
|
-
|
|
82
|
+
const trigger = e.target;
|
|
109
83
|
for (let i = ScrollSpy._elements.length - 1; i >= 0; i--) {
|
|
110
|
-
|
|
111
|
-
|
|
84
|
+
const scrollspy = ScrollSpy._elements[i];
|
|
85
|
+
|
|
86
|
+
const x = document.querySelector('a[href="#'+scrollspy.el.id+'"]');
|
|
87
|
+
if (trigger === x) {
|
|
112
88
|
e.preventDefault();
|
|
113
|
-
|
|
89
|
+
const offset = ScrollSpy._offset(scrollspy.el).top + 1;
|
|
114
90
|
|
|
115
91
|
anim({
|
|
116
92
|
targets: [document.documentElement, document.body],
|
|
@@ -118,14 +94,12 @@
|
|
|
118
94
|
duration: 400,
|
|
119
95
|
easing: 'easeOutCubic'
|
|
120
96
|
});
|
|
97
|
+
|
|
121
98
|
break;
|
|
122
99
|
}
|
|
123
100
|
}
|
|
124
101
|
}
|
|
125
102
|
|
|
126
|
-
/**
|
|
127
|
-
* Handle Window Scroll
|
|
128
|
-
*/
|
|
129
103
|
_handleWindowScroll() {
|
|
130
104
|
// unique tick id
|
|
131
105
|
ScrollSpy._ticks++;
|
|
@@ -159,30 +133,30 @@
|
|
|
159
133
|
scrollspy.tickId = -1;
|
|
160
134
|
}
|
|
161
135
|
}
|
|
162
|
-
|
|
163
136
|
// remember elements in view for next tick
|
|
164
137
|
ScrollSpy._elementsInView = intersections;
|
|
165
138
|
}
|
|
166
139
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
140
|
+
static _offset(el) {
|
|
141
|
+
const box = el.getBoundingClientRect();
|
|
142
|
+
const docElem = document.documentElement;
|
|
143
|
+
return {
|
|
144
|
+
top: box.top + window.pageYOffset - docElem.clientTop,
|
|
145
|
+
left: box.left + window.pageXOffset - docElem.clientLeft
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
static _findElements(top: number, right: number, bottom: number, left: number): ScrollSpy[] {
|
|
176
150
|
let hits = [];
|
|
177
151
|
for (let i = 0; i < ScrollSpy._elements.length; i++) {
|
|
178
152
|
let scrollspy = ScrollSpy._elements[i];
|
|
179
153
|
let currTop = top + scrollspy.options.scrollOffset || 200;
|
|
180
154
|
|
|
181
|
-
if (scrollspy
|
|
182
|
-
let elTop = scrollspy
|
|
183
|
-
elLeft = scrollspy
|
|
184
|
-
elRight = elLeft + scrollspy
|
|
185
|
-
elBottom = elTop + scrollspy
|
|
155
|
+
if (scrollspy.el.getBoundingClientRect().height > 0) {
|
|
156
|
+
let elTop = ScrollSpy._offset(scrollspy.el).top,
|
|
157
|
+
elLeft = ScrollSpy._offset(scrollspy.el).left,
|
|
158
|
+
elRight = elLeft + scrollspy.el.getBoundingClientRect().width,
|
|
159
|
+
elBottom = elTop + scrollspy.el.getBoundingClientRect().height;
|
|
186
160
|
|
|
187
161
|
let isIntersect = !(
|
|
188
162
|
elLeft > right ||
|
|
@@ -200,96 +174,50 @@
|
|
|
200
174
|
}
|
|
201
175
|
|
|
202
176
|
_enter() {
|
|
203
|
-
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(
|
|
204
|
-
return value.height() != 0;
|
|
205
|
-
});
|
|
177
|
+
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(value => value.getBoundingClientRect().height !== 0);
|
|
206
178
|
|
|
207
179
|
if (ScrollSpy._visibleElements[0]) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (
|
|
212
|
-
ScrollSpy._visibleElements
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
ScrollSpy._visibleElements.
|
|
216
|
-
} else {
|
|
217
|
-
ScrollSpy._visibleElements.push(this.$el);
|
|
180
|
+
const actElem = document.querySelector(this.options.getActiveElement(ScrollSpy._visibleElements[0].id));
|
|
181
|
+
actElem?.classList.remove(this.options.activeClass);
|
|
182
|
+
|
|
183
|
+
if (ScrollSpy._visibleElements[0].M_ScrollSpy && this.id < ScrollSpy._visibleElements[0].M_ScrollSpy.id) {
|
|
184
|
+
ScrollSpy._visibleElements.unshift(this.el);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
ScrollSpy._visibleElements.push(this.el);
|
|
218
188
|
}
|
|
219
|
-
} else {
|
|
220
|
-
ScrollSpy._visibleElements.push(this.$el);
|
|
221
189
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
);
|
|
190
|
+
else {
|
|
191
|
+
ScrollSpy._visibleElements.push(this.el);
|
|
192
|
+
}
|
|
193
|
+
const selector = this.options.getActiveElement(ScrollSpy._visibleElements[0].id);
|
|
194
|
+
document.querySelector(selector)?.classList.add(this.options.activeClass);
|
|
226
195
|
}
|
|
227
196
|
|
|
228
197
|
_exit() {
|
|
229
|
-
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(
|
|
230
|
-
return value.height() != 0;
|
|
231
|
-
});
|
|
198
|
+
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(value => value.getBoundingClientRect().height !== 0);
|
|
232
199
|
|
|
233
200
|
if (ScrollSpy._visibleElements[0]) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
201
|
+
const actElem = document.querySelector(this.options.getActiveElement(ScrollSpy._visibleElements[0].id));
|
|
202
|
+
actElem?.classList.remove(this.options.activeClass);
|
|
203
|
+
|
|
204
|
+
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter((x) => x.id != this.el.id);
|
|
237
205
|
|
|
238
|
-
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter((el) => {
|
|
239
|
-
return el.attr('id') != this.$el.attr('id');
|
|
240
|
-
});
|
|
241
206
|
if (ScrollSpy._visibleElements[0]) {
|
|
242
207
|
// Check if empty
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
);
|
|
208
|
+
const selector = this.options.getActiveElement(ScrollSpy._visibleElements[0].id);
|
|
209
|
+
document.querySelector(selector)?.classList.add(this.options.activeClass);
|
|
246
210
|
}
|
|
247
211
|
}
|
|
248
212
|
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* @static
|
|
253
|
-
* @memberof ScrollSpy
|
|
254
|
-
* @type {Array.<ScrollSpy>}
|
|
255
|
-
*/
|
|
256
|
-
ScrollSpy._elements = [];
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* @static
|
|
260
|
-
* @memberof ScrollSpy
|
|
261
|
-
* @type {Array.<ScrollSpy>}
|
|
262
|
-
*/
|
|
263
|
-
ScrollSpy._elementsInView = [];
|
|
264
213
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
* @static
|
|
274
|
-
* @memberof ScrollSpy
|
|
275
|
-
*/
|
|
276
|
-
ScrollSpy._count = 0;
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* @static
|
|
280
|
-
* @memberof ScrollSpy
|
|
281
|
-
*/
|
|
282
|
-
ScrollSpy._increment = 0;
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* @static
|
|
286
|
-
* @memberof ScrollSpy
|
|
287
|
-
*/
|
|
288
|
-
ScrollSpy._ticks = 0;
|
|
289
|
-
|
|
290
|
-
M.ScrollSpy = ScrollSpy;
|
|
291
|
-
|
|
292
|
-
if (M.jQueryLoaded) {
|
|
293
|
-
M.initializeJqueryWrapper(ScrollSpy, 'scrollSpy', 'M_ScrollSpy');
|
|
214
|
+
static {
|
|
215
|
+
ScrollSpy._elements = [];
|
|
216
|
+
ScrollSpy._elementsInView = [];
|
|
217
|
+
ScrollSpy._visibleElements = []; // Array.<cash>
|
|
218
|
+
ScrollSpy._count = 0;
|
|
219
|
+
ScrollSpy._increment = 0;
|
|
220
|
+
ScrollSpy._ticks = 0;
|
|
221
|
+
}
|
|
294
222
|
}
|
|
295
|
-
|
|
223
|
+
|