@materializecss/materialize 1.2.2 → 2.0.0-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.
Files changed (89) hide show
  1. package/Gruntfile.js +68 -313
  2. package/README.md +2 -2
  3. package/dist/css/materialize.css +1009 -1822
  4. package/dist/css/materialize.min.css +2 -8
  5. package/dist/js/materialize.js +8402 -12300
  6. package/dist/js/materialize.min.js +3 -2
  7. package/dist/js/materialize.min.js.map +1 -0
  8. package/package.json +13 -9
  9. package/sass/components/_badges.scss +12 -2
  10. package/sass/components/_buttons.scss +16 -11
  11. package/sass/components/_cards.scss +14 -9
  12. package/sass/components/_carousel.scss +5 -2
  13. package/sass/components/_chips.scss +3 -3
  14. package/sass/components/_collapsible.scss +22 -8
  15. package/sass/components/_collection.scss +14 -6
  16. package/sass/components/_datepicker.scss +30 -11
  17. package/sass/components/_dropdown.scss +6 -4
  18. package/sass/components/_global.scss +132 -111
  19. package/sass/components/_grid.scss +119 -98
  20. package/sass/components/_modal.scss +3 -3
  21. package/sass/components/_navbar.scss +31 -17
  22. package/sass/components/_normalize.scss +26 -124
  23. package/sass/components/_sidenav.scss +21 -20
  24. package/sass/components/_slider.scss +27 -7
  25. package/sass/components/_table_of_contents.scss +12 -12
  26. package/sass/components/_tabs.scss +47 -16
  27. package/sass/components/_tapTarget.scss +6 -6
  28. package/sass/components/_timepicker.scss +54 -46
  29. package/sass/components/_toast.scss +3 -3
  30. package/sass/components/_tooltip.scss +4 -5
  31. package/sass/components/_typography.scss +1 -1
  32. package/sass/components/_variables.scss +185 -120
  33. package/sass/components/forms/_checkboxes.scss +9 -9
  34. package/sass/components/forms/_file-input.scss +9 -7
  35. package/sass/components/forms/_input-fields.scss +173 -234
  36. package/sass/components/forms/_radio-buttons.scss +1 -1
  37. package/sass/components/forms/_range.scss +11 -11
  38. package/sass/components/forms/_select.scss +29 -19
  39. package/sass/components/forms/_switches.scss +22 -18
  40. package/sass/materialize.scss +1 -1
  41. package/src/autocomplete.ts +459 -0
  42. package/src/bounding.ts +6 -0
  43. package/{js/buttons.js → src/buttons.ts} +103 -162
  44. package/src/cards.ts +54 -0
  45. package/{js/carousel.js → src/carousel.ts} +137 -262
  46. package/src/characterCounter.ts +88 -0
  47. package/src/chips.ts +350 -0
  48. package/src/collapsible.ts +184 -0
  49. package/{js/component.js → src/component.ts} +6 -19
  50. package/{js/datepicker.js → src/datepicker.ts} +213 -299
  51. package/{js/dropdown.js → src/dropdown.ts} +140 -254
  52. package/src/edges.ts +6 -0
  53. package/src/forms.ts +120 -0
  54. package/src/global.ts +385 -0
  55. package/src/materialbox.ts +348 -0
  56. package/src/modal.ts +256 -0
  57. package/{js/parallax.js → src/parallax.ts} +47 -60
  58. package/{js/pushpin.js → src/pushpin.ts} +19 -47
  59. package/{js/range.js → src/range.ts} +58 -139
  60. package/{js/scrollspy.js → src/scrollspy.ts} +81 -153
  61. package/src/select.ts +448 -0
  62. package/{js/sidenav.js → src/sidenav.ts} +96 -202
  63. package/src/slider.ts +415 -0
  64. package/src/tabs.ts +290 -0
  65. package/src/tapTarget.ts +240 -0
  66. package/{js/timepicker.js → src/timepicker.ts} +268 -272
  67. package/{js/toasts.js → src/toasts.ts} +75 -134
  68. package/{js/tooltip.js → src/tooltip.ts} +59 -96
  69. package/src/waves.ts +70 -0
  70. package/extras/noUiSlider/nouislider.css +0 -404
  71. package/extras/noUiSlider/nouislider.js +0 -2147
  72. package/extras/noUiSlider/nouislider.min.js +0 -1
  73. package/js/anime.min.js +0 -34
  74. package/js/autocomplete.js +0 -479
  75. package/js/cards.js +0 -40
  76. package/js/cash.js +0 -960
  77. package/js/characterCounter.js +0 -136
  78. package/js/chips.js +0 -486
  79. package/js/collapsible.js +0 -275
  80. package/js/forms.js +0 -285
  81. package/js/global.js +0 -428
  82. package/js/materialbox.js +0 -453
  83. package/js/modal.js +0 -382
  84. package/js/select.js +0 -391
  85. package/js/slider.js +0 -497
  86. package/js/tabs.js +0 -402
  87. package/js/tapTarget.js +0 -315
  88. package/js/waves.js +0 -615
  89. package/sass/components/_waves.scss +0 -187
package/js/slider.js DELETED
@@ -1,497 +0,0 @@
1
- (function($, anim) {
2
- 'use strict';
3
-
4
- let _defaults = {
5
- indicators: true,
6
- height: 400,
7
- duration: 500,
8
- interval: 6000,
9
- pauseOnFocus: true,
10
- pauseOnHover: true,
11
- indicatorLabelFunc: null // Function which will generate a label for the indicators (ARIA)
12
- };
13
-
14
- /**
15
- * @class
16
- *
17
- */
18
- class Slider extends Component {
19
- /**
20
- * Construct Slider instance and set up overlay
21
- * @constructor
22
- * @param {Element} el
23
- * @param {Object} options
24
- */
25
- constructor(el, options) {
26
- super(Slider, el, options);
27
-
28
- this.el.M_Slider = this;
29
-
30
- /**
31
- * Options for the modal
32
- * @member Slider#options
33
- * @prop {Boolean} [indicators=true] - Show indicators
34
- * @prop {Number} [height=400] - height of slider
35
- * @prop {Number} [duration=500] - Length in ms of slide transition
36
- * @prop {Number} [interval=6000] - Length in ms of slide interval
37
- * @prop {Boolean} [pauseOnFocus=true] - Pauses transition when slider receives keyboard focus
38
- * @prop {Boolean} [pauseOnHover=true] - Pauses transition while mouse hovers the slider
39
- * @prop {Function} [indicatorLabelFunc=null] - Function used to generate ARIA label to indicators (for accessibility purposes).
40
- */
41
- this.options = $.extend({}, Slider.defaults, options);
42
-
43
- // init props
44
- this.interval = null;
45
- this.eventPause = false;
46
- this._hovered = false;
47
- this._focused = false;
48
- this._focusCurrent = false;
49
-
50
- // setup
51
- this.$slider = this.$el.find('.slides');
52
- this.$slides = this.$slider.children('li');
53
- this.activeIndex = this.$slides
54
- .filter(function(item) {
55
- return $(item).hasClass('active');
56
- })
57
- .first()
58
- .index();
59
- if (this.activeIndex != -1) {
60
- this.$active = this.$slides.eq(this.activeIndex);
61
- }
62
-
63
- this._setSliderHeight();
64
-
65
- // Sets element id if it does not have one
66
- if (this.$slider.attr('id')) this._sliderId = this.$slider.attr('id');
67
- else {
68
- this._sliderId = 'slider-' + M.guid();
69
- this.$slider.attr('id', this._sliderId);
70
- }
71
-
72
- // Set initial positions of captions
73
- this.$slides.find('.caption').each((el) => {
74
- this._animateCaptionIn(el, 0);
75
- });
76
-
77
- // Move img src into background-image
78
- this.$slides.find('img').each((el) => {
79
- let placeholderBase64 =
80
- 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
81
- if ($(el).attr('src') !== placeholderBase64) {
82
- $(el).css('background-image', 'url("' + $(el).attr('src') + '")');
83
- $(el).attr('src', placeholderBase64);
84
- }
85
- });
86
- this.$slides.each((el) => {
87
- // Sets slide as focusable by code
88
- if (!el.hasAttribute('tabindex')) el.setAttribute('tabindex', -1);
89
- // Removes initial visibility from "inactive" slides
90
- el.style.visibility = 'hidden';
91
- });
92
-
93
- this._setupIndicators();
94
-
95
- // Show active slide
96
- if (this.$active) {
97
- this.$active.css('display', 'block').css('visibility', 'visible');
98
- } else {
99
- this.$slides.first().addClass('active');
100
- anim({
101
- targets: this.$slides.first()[0],
102
- opacity: 1,
103
- duration: this.options.duration,
104
- easing: 'easeOutQuad'
105
- });
106
- this.$slides.first().css('visibility', 'visible');
107
-
108
- this.activeIndex = 0;
109
- this.$active = this.$slides.eq(this.activeIndex);
110
-
111
- // Update indicators
112
- if (this.options.indicators) {
113
- this.$indicators.eq(this.activeIndex).children().first().addClass('active');
114
- }
115
- }
116
-
117
- // Adjust height to current slide
118
- this.$active.find('img').each((el) => {
119
- anim({
120
- targets: this.$active.find('.caption')[0],
121
- opacity: 1,
122
- translateX: 0,
123
- translateY: 0,
124
- duration: this.options.duration,
125
- easing: 'easeOutQuad'
126
- });
127
- });
128
-
129
- this._setupEventHandlers();
130
-
131
- // auto scroll
132
- this.start();
133
- }
134
-
135
- static get defaults() {
136
- return _defaults;
137
- }
138
-
139
- static init(els, options) {
140
- return super.init(this, els, options);
141
- }
142
-
143
- /**
144
- * Get Instance
145
- */
146
- static getInstance(el) {
147
- let domElem = !!el.jquery ? el[0] : el;
148
- return domElem.M_Slider;
149
- }
150
-
151
- /**
152
- * Teardown component
153
- */
154
- destroy() {
155
- this.pause();
156
- this._removeIndicators();
157
- this._removeEventHandlers();
158
- this.el.M_Slider = undefined;
159
- }
160
-
161
- /**
162
- * Setup Event Handlers
163
- */
164
- _setupEventHandlers() {
165
- this._handleIntervalBound = this._handleInterval.bind(this);
166
- this._handleIndicatorClickBound = this._handleIndicatorClick.bind(this);
167
- this._handleAutoPauseFocusBound = this._handleAutoPauseFocus.bind(this);
168
- this._handleAutoStartFocusBound = this._handleAutoStartFocus.bind(this);
169
- this._handleAutoPauseHoverBound = this._handleAutoPauseHover.bind(this);
170
- this._handleAutoStartHoverBound = this._handleAutoStartHover.bind(this);
171
-
172
- if (this.options.pauseOnFocus) {
173
- this.el.addEventListener('focusin', this._handleAutoPauseFocusBound);
174
- this.el.addEventListener('focusout', this._handleAutoStartFocusBound);
175
- }
176
- if (this.options.pauseOnHover) {
177
- this.el.addEventListener('mouseenter', this._handleAutoPauseHoverBound);
178
- this.el.addEventListener('mouseleave', this._handleAutoStartHoverBound);
179
- }
180
-
181
- if (this.options.indicators) {
182
- this.$indicators.children().on('click', this._handleIndicatorClickBound);
183
- }
184
- }
185
-
186
- /**
187
- * Remove Event Handlers
188
- */
189
- _removeEventHandlers() {
190
- if (this.options.pauseOnFocus) {
191
- this.el.removeEventListener('focusin', this._handleAutoPauseFocusBound);
192
- this.el.removeEventListener('focusout', this._handleAutoStartFocusBound);
193
- }
194
- if (this.options.pauseOnHover) {
195
- this.el.removeEventListener('mouseenter', this._handleAutoPauseHoverBound);
196
- this.el.removeEventListener('mouseleave', this._handleAutoStartHoverBound);
197
- }
198
- if (this.options.indicators) {
199
- this.$indicators.children().off('click', this._handleIndicatorClickBound);
200
- }
201
- }
202
-
203
- /**
204
- * Handle indicator click
205
- * @param {Event} e
206
- */
207
- _handleIndicatorClick(e) {
208
- let currIndex = $(e.target).parent().index();
209
- this._focusCurrent = true;
210
- this.set(currIndex);
211
- }
212
-
213
- /**
214
- * Mouse enter event handler
215
- */
216
- _handleAutoPauseHover() {
217
- this._hovered = true;
218
- if (this.interval != null) {
219
- this._pause(true);
220
- }
221
- }
222
-
223
- /**
224
- * Focus in event handler
225
- */
226
- _handleAutoPauseFocus() {
227
- this._focused = true;
228
- if (this.interval != null) {
229
- this._pause(true);
230
- }
231
- }
232
-
233
- /**
234
- * Mouse enter event handler
235
- */
236
- _handleAutoStartHover() {
237
- this._hovered = false;
238
- if (!(this.options.pauseOnFocus && this._focused) && this.eventPause) {
239
- this.start();
240
- }
241
- }
242
-
243
- /**
244
- * Focus out leave event handler
245
- */
246
- _handleAutoStartFocus() {
247
- this._focused = false;
248
- if (!(this.options.pauseOnHover && this._hovered) && this.eventPause) {
249
- this.start();
250
- }
251
- }
252
-
253
- /**
254
- * Handle Interval
255
- */
256
- _handleInterval() {
257
- let newActiveIndex = this.$slider.find('.active').index();
258
- if (this.$slides.length === newActiveIndex + 1) newActiveIndex = 0;
259
- // loop to start
260
- else newActiveIndex += 1;
261
-
262
- this.set(newActiveIndex);
263
- }
264
-
265
- /**
266
- * Animate in caption
267
- * @param {Element} caption
268
- * @param {Number} duration
269
- */
270
- _animateCaptionIn(caption, duration) {
271
- let animOptions = {
272
- targets: caption,
273
- opacity: 0,
274
- duration: duration,
275
- easing: 'easeOutQuad'
276
- };
277
-
278
- if ($(caption).hasClass('center-align')) {
279
- animOptions.translateY = -100;
280
- } else if ($(caption).hasClass('right-align')) {
281
- animOptions.translateX = 100;
282
- } else if ($(caption).hasClass('left-align')) {
283
- animOptions.translateX = -100;
284
- }
285
-
286
- anim(animOptions);
287
- }
288
-
289
- /**
290
- * Set height of slider
291
- */
292
- _setSliderHeight() {
293
- // If fullscreen, do nothing
294
- if (!this.$el.hasClass('fullscreen')) {
295
- if (this.options.indicators) {
296
- // Add height if indicators are present
297
- this.$el.css('height', this.options.height + 40 + 'px');
298
- } else {
299
- this.$el.css('height', this.options.height + 'px');
300
- }
301
- this.$slider.css('height', this.options.height + 'px');
302
- }
303
- }
304
-
305
- /**
306
- * Setup indicators
307
- */
308
- _setupIndicators() {
309
- if (this.options.indicators) {
310
- this.$indicators = $('<ul class="indicators"></ul>');
311
- this.$slides.each((el, i) => {
312
- let label = this.options.indicatorLabelFunc
313
- ? this.options.indicatorLabelFunc.call(this, i + 1, i === 0)
314
- : `${i + 1}`;
315
- let $indicator = $(`<li class="indicator-item">
316
- <button type="button" class="indicator-item-btn" aria-label="${label}" aria-controls="${this._sliderId}"></button>
317
- </li>`);
318
- this.$indicators.append($indicator[0]);
319
- });
320
- this.$el.append(this.$indicators[0]);
321
- this.$indicators = this.$indicators.children('li.indicator-item');
322
- }
323
- }
324
-
325
- /**
326
- * Remove indicators
327
- */
328
- _removeIndicators() {
329
- this.$el.find('ul.indicators').remove();
330
- }
331
-
332
- /**
333
- * Cycle to nth item
334
- * @param {Number} index
335
- */
336
- set(index) {
337
- // Wrap around indices.
338
- if (index >= this.$slides.length) index = 0;
339
- else if (index < 0) index = this.$slides.length - 1;
340
-
341
- // Only do if index changes
342
- if (this.activeIndex != index) {
343
- this.$active = this.$slides.eq(this.activeIndex);
344
- let $caption = this.$active.find('.caption');
345
- this.$active.removeClass('active');
346
- // Enables every slide
347
- this.$slides.css('visibility', 'visible');
348
-
349
- anim({
350
- targets: this.$active[0],
351
- opacity: 0,
352
- duration: this.options.duration,
353
- easing: 'easeOutQuad',
354
- complete: () => {
355
- this.$slides.not('.active').each((el) => {
356
- anim({
357
- targets: el,
358
- opacity: 0,
359
- translateX: 0,
360
- translateY: 0,
361
- duration: 0,
362
- easing: 'easeOutQuad'
363
- });
364
- // Disables invisible slides (for assistive technologies)
365
- el.style.visibility = 'hidden';
366
- });
367
- }
368
- });
369
-
370
- this._animateCaptionIn($caption[0], this.options.duration);
371
-
372
- // Update indicators
373
- if (this.options.indicators) {
374
- let activeIndicator = this.$indicators
375
- .eq(this.activeIndex)
376
- .children()
377
- .first();
378
- let nextIndicator = this.$indicators
379
- .eq(index)
380
- .children()
381
- .first();
382
- activeIndicator.removeClass('active');
383
- nextIndicator.addClass('active');
384
- if (typeof this.options.indicatorLabelFunc === "function"){
385
- activeIndicator.attr(
386
- 'aria-label',
387
- this.options.indicatorLabelFunc.call(
388
- this,
389
- this.$indicators.eq(this.activeIndex).index(),
390
- false
391
- )
392
- );
393
- nextIndicator.attr(
394
- 'aria-label',
395
- this.options.indicatorLabelFunc.call(
396
- this,
397
- this.$indicators.eq(index).index(),
398
- true
399
- )
400
- );
401
- }
402
- }
403
-
404
- anim({
405
- targets: this.$slides.eq(index)[0],
406
- opacity: 1,
407
- duration: this.options.duration,
408
- easing: 'easeOutQuad'
409
- });
410
-
411
- anim({
412
- targets: this.$slides.eq(index).find('.caption')[0],
413
- opacity: 1,
414
- translateX: 0,
415
- translateY: 0,
416
- duration: this.options.duration,
417
- delay: this.options.duration,
418
- easing: 'easeOutQuad'
419
- });
420
-
421
- this.$slides.eq(index).addClass('active');
422
- if (this._focusCurrent) {
423
- this.$slides.eq(index)[0].focus();
424
- this._focusCurrent = false;
425
- }
426
- this.activeIndex = index;
427
-
428
- // Reset interval, if allowed. This check prevents autostart
429
- // when slider is paused, since it can be changed though indicators.
430
- if (this.interval != null) {
431
- this.start();
432
- }
433
- }
434
- }
435
-
436
- /**
437
- * "Protected" function which pauses current interval
438
- * @param {boolean} fromEvent Specifies if request came from event
439
- */
440
- _pause(fromEvent) {
441
- clearInterval(this.interval);
442
- this.eventPause = fromEvent;
443
- this.interval = null;
444
- }
445
-
446
- /**
447
- * Pause slider interval
448
- */
449
- pause() {
450
- this._pause(false);
451
- }
452
-
453
- /**
454
- * Start slider interval
455
- */
456
- start() {
457
- clearInterval(this.interval);
458
- this.interval = setInterval(
459
- this._handleIntervalBound,
460
- this.options.duration + this.options.interval
461
- );
462
- this.eventPause = false;
463
- }
464
-
465
- /**
466
- * Move to next slide
467
- */
468
- next() {
469
- let newIndex = this.activeIndex + 1;
470
-
471
- // Wrap around indices.
472
- if (newIndex >= this.$slides.length) newIndex = 0;
473
- else if (newIndex < 0) newIndex = this.$slides.length - 1;
474
-
475
- this.set(newIndex);
476
- }
477
-
478
- /**
479
- * Move to previous slide
480
- */
481
- prev() {
482
- let newIndex = this.activeIndex - 1;
483
-
484
- // Wrap around indices.
485
- if (newIndex >= this.$slides.length) newIndex = 0;
486
- else if (newIndex < 0) newIndex = this.$slides.length - 1;
487
-
488
- this.set(newIndex);
489
- }
490
- }
491
-
492
- M.Slider = Slider;
493
-
494
- if (M.jQueryLoaded) {
495
- M.initializeJqueryWrapper(Slider, 'slider', 'M_Slider');
496
- }
497
- })(cash, M.anime);