@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
@@ -1,136 +0,0 @@
1
- (function($) {
2
- 'use strict';
3
-
4
- let _defaults = {};
5
-
6
- /**
7
- * @class
8
- *
9
- */
10
- class CharacterCounter extends Component {
11
- /**
12
- * Construct CharacterCounter instance
13
- * @constructor
14
- * @param {Element} el
15
- * @param {Object} options
16
- */
17
- constructor(el, options) {
18
- super(CharacterCounter, el, options);
19
-
20
- this.el.M_CharacterCounter = this;
21
-
22
- /**
23
- * Options for the character counter
24
- */
25
- this.options = $.extend({}, CharacterCounter.defaults, options);
26
-
27
- this.isInvalid = false;
28
- this.isValidLength = false;
29
- this._setupCounter();
30
- this._setupEventHandlers();
31
- }
32
-
33
- static get defaults() {
34
- return _defaults;
35
- }
36
-
37
- static init(els, options) {
38
- return super.init(this, els, options);
39
- }
40
-
41
- /**
42
- * Get Instance
43
- */
44
- static getInstance(el) {
45
- let domElem = !!el.jquery ? el[0] : el;
46
- return domElem.M_CharacterCounter;
47
- }
48
-
49
- /**
50
- * Teardown component
51
- */
52
- destroy() {
53
- this._removeEventHandlers();
54
- this.el.CharacterCounter = undefined;
55
- this._removeCounter();
56
- }
57
-
58
- /**
59
- * Setup Event Handlers
60
- */
61
- _setupEventHandlers() {
62
- this._handleUpdateCounterBound = this.updateCounter.bind(this);
63
-
64
- this.el.addEventListener('focus', this._handleUpdateCounterBound, true);
65
- this.el.addEventListener('input', this._handleUpdateCounterBound, true);
66
- }
67
-
68
- /**
69
- * Remove Event Handlers
70
- */
71
- _removeEventHandlers() {
72
- this.el.removeEventListener('focus', this._handleUpdateCounterBound, true);
73
- this.el.removeEventListener('input', this._handleUpdateCounterBound, true);
74
- }
75
-
76
- /**
77
- * Setup counter element
78
- */
79
- _setupCounter() {
80
- this.counterEl = document.createElement('span');
81
- $(this.counterEl)
82
- .addClass('character-counter')
83
- .css({
84
- float: 'right',
85
- 'font-size': '12px',
86
- height: 1
87
- });
88
-
89
- this.$el.parent().append(this.counterEl);
90
- }
91
-
92
- /**
93
- * Remove counter element
94
- */
95
- _removeCounter() {
96
- $(this.counterEl).remove();
97
- }
98
-
99
- /**
100
- * Update counter
101
- */
102
- updateCounter() {
103
- let maxLength = +this.$el.attr('data-length'),
104
- actualLength = this.el.value.length;
105
- this.isValidLength = actualLength <= maxLength;
106
- let counterString = actualLength;
107
-
108
- if (maxLength) {
109
- counterString += '/' + maxLength;
110
- this._validateInput();
111
- }
112
-
113
- $(this.counterEl).html(counterString);
114
- }
115
-
116
- /**
117
- * Add validation classes
118
- */
119
- _validateInput() {
120
- if (this.isValidLength && this.isInvalid) {
121
- this.isInvalid = false;
122
- this.$el.removeClass('invalid');
123
- } else if (!this.isValidLength && !this.isInvalid) {
124
- this.isInvalid = true;
125
- this.$el.removeClass('valid');
126
- this.$el.addClass('invalid');
127
- }
128
- }
129
- }
130
-
131
- M.CharacterCounter = CharacterCounter;
132
-
133
- if (M.jQueryLoaded) {
134
- M.initializeJqueryWrapper(CharacterCounter, 'characterCounter', 'M_CharacterCounter');
135
- }
136
- })(cash);
package/js/chips.js DELETED
@@ -1,486 +0,0 @@
1
- (function($) {
2
- 'use strict';
3
-
4
- let _defaults = {
5
- data: [],
6
- placeholder: '',
7
- secondaryPlaceholder: '',
8
- autocompleteOptions: {},
9
- autocompleteOnly: false,
10
- limit: Infinity,
11
- onChipAdd: null,
12
- onChipSelect: null,
13
- onChipDelete: null
14
- };
15
-
16
- /**
17
- * @typedef {Object} chip
18
- * @property {String} tag chip tag string
19
- * @property {String} [image] chip avatar image string
20
- */
21
-
22
- /**
23
- * @class
24
- *
25
- */
26
- class Chips extends Component {
27
- /**
28
- * Construct Chips instance and set up overlay
29
- * @constructor
30
- * @param {Element} el
31
- * @param {Object} options
32
- */
33
- constructor(el, options) {
34
- super(Chips, el, options);
35
-
36
- this.el.M_Chips = this;
37
-
38
- /**
39
- * Options for the modal
40
- * @member Chips#options
41
- * @prop {Array} data
42
- * @prop {String} placeholder
43
- * @prop {String} secondaryPlaceholder
44
- * @prop {Object} autocompleteOptions
45
- */
46
- this.options = $.extend({}, Chips.defaults, options);
47
-
48
- this.$el.addClass('chips input-field');
49
- this.chipsData = [];
50
- this.$chips = $();
51
- this._setupInput();
52
- this.hasAutocomplete = Object.keys(this.options.autocompleteOptions).length > 0;
53
-
54
- // Set input id
55
- if (!this.$input.attr('id')) {
56
- this.$input.attr('id', M.guid());
57
- }
58
-
59
- // Render initial chips
60
- if (this.options.data.length) {
61
- this.chipsData = this.options.data;
62
- this._renderChips(this.chipsData);
63
- }
64
-
65
- // Setup autocomplete if needed
66
- if (this.hasAutocomplete) {
67
- this._setupAutocomplete();
68
- }
69
-
70
- this._setPlaceholder();
71
- this._setupLabel();
72
- this._setupEventHandlers();
73
- }
74
-
75
- static get defaults() {
76
- return _defaults;
77
- }
78
-
79
- static init(els, options) {
80
- return super.init(this, els, options);
81
- }
82
-
83
- /**
84
- * Get Instance
85
- */
86
- static getInstance(el) {
87
- let domElem = !!el.jquery ? el[0] : el;
88
- return domElem.M_Chips;
89
- }
90
-
91
- /**
92
- * Get Chips Data
93
- */
94
- getData() {
95
- return this.chipsData;
96
- }
97
-
98
- /**
99
- * Teardown component
100
- */
101
- destroy() {
102
- this._removeEventHandlers();
103
- this.$chips.remove();
104
- this.el.M_Chips = undefined;
105
- }
106
-
107
- /**
108
- * Setup Event Handlers
109
- */
110
- _setupEventHandlers() {
111
- this._handleChipClickBound = this._handleChipClick.bind(this);
112
- this._handleInputKeydownBound = this._handleInputKeydown.bind(this);
113
- this._handleInputFocusBound = this._handleInputFocus.bind(this);
114
- this._handleInputBlurBound = this._handleInputBlur.bind(this);
115
-
116
- this.el.addEventListener('click', this._handleChipClickBound);
117
- document.addEventListener('keydown', Chips._handleChipsKeydown);
118
- document.addEventListener('keyup', Chips._handleChipsKeyup);
119
- this.el.addEventListener('blur', Chips._handleChipsBlur, true);
120
- this.$input[0].addEventListener('focus', this._handleInputFocusBound);
121
- this.$input[0].addEventListener('blur', this._handleInputBlurBound);
122
- this.$input[0].addEventListener('keydown', this._handleInputKeydownBound);
123
- }
124
-
125
- /**
126
- * Remove Event Handlers
127
- */
128
- _removeEventHandlers() {
129
- this.el.removeEventListener('click', this._handleChipClickBound);
130
- document.removeEventListener('keydown', Chips._handleChipsKeydown);
131
- document.removeEventListener('keyup', Chips._handleChipsKeyup);
132
- this.el.removeEventListener('blur', Chips._handleChipsBlur, true);
133
- this.$input[0].removeEventListener('focus', this._handleInputFocusBound);
134
- this.$input[0].removeEventListener('blur', this._handleInputBlurBound);
135
- this.$input[0].removeEventListener('keydown', this._handleInputKeydownBound);
136
- }
137
-
138
- /**
139
- * Handle Chip Click
140
- * @param {Event} e
141
- */
142
- _handleChipClick(e) {
143
- let $chip = $(e.target).closest('.chip');
144
- let clickedClose = $(e.target).is('.close');
145
- if ($chip.length) {
146
- let index = $chip.index();
147
- if (clickedClose) {
148
- // delete chip
149
- this.deleteChip(index);
150
- this.$input[0].focus();
151
- } else {
152
- // select chip
153
- this.selectChip(index);
154
- }
155
-
156
- // Default handle click to focus on input
157
- } else {
158
- this.$input[0].focus();
159
- }
160
- }
161
-
162
- /**
163
- * Handle Chips Keydown
164
- * @param {Event} e
165
- */
166
- static _handleChipsKeydown(e) {
167
- Chips._keydown = true;
168
-
169
- let $chips = $(e.target).closest('.chips');
170
- let chipsKeydown = e.target && $chips.length;
171
-
172
- // Don't handle keydown inputs on input and textarea
173
- if ($(e.target).is('input, textarea') || !chipsKeydown) {
174
- return;
175
- }
176
-
177
- let currChips = $chips[0].M_Chips;
178
-
179
- // backspace and delete
180
- if (e.keyCode === 8 || e.keyCode === 46) {
181
- e.preventDefault();
182
-
183
- let selectIndex = currChips.chipsData.length;
184
- if (currChips._selectedChip) {
185
- let index = currChips._selectedChip.index();
186
- currChips.deleteChip(index);
187
- currChips._selectedChip = null;
188
-
189
- // Make sure selectIndex doesn't go negative
190
- selectIndex = Math.max(index - 1, 0);
191
- }
192
-
193
- if (currChips.chipsData.length) {
194
- currChips.selectChip(selectIndex);
195
- } else {
196
- currChips.$input[0].focus();
197
- }
198
-
199
- // left arrow key
200
- } else if (e.keyCode === 37) {
201
- if (currChips._selectedChip) {
202
- let selectIndex = currChips._selectedChip.index() - 1;
203
- if (selectIndex < 0) {
204
- return;
205
- }
206
- currChips.selectChip(selectIndex);
207
- }
208
-
209
- // right arrow key
210
- } else if (e.keyCode === 39) {
211
- if (currChips._selectedChip) {
212
- let selectIndex = currChips._selectedChip.index() + 1;
213
-
214
- if (selectIndex >= currChips.chipsData.length) {
215
- currChips.$input[0].focus();
216
- } else {
217
- currChips.selectChip(selectIndex);
218
- }
219
- }
220
- }
221
- }
222
-
223
- /**
224
- * Handle Chips Keyup
225
- * @param {Event} e
226
- */
227
- static _handleChipsKeyup(e) {
228
- Chips._keydown = false;
229
- }
230
-
231
- /**
232
- * Handle Chips Blur
233
- * @param {Event} e
234
- */
235
- static _handleChipsBlur(e) {
236
- if (!Chips._keydown && document.hidden) {
237
- let $chips = $(e.target).closest('.chips');
238
- let currChips = $chips[0].M_Chips;
239
-
240
- currChips._selectedChip = null;
241
- }
242
- }
243
-
244
- /**
245
- * Handle Input Focus
246
- */
247
- _handleInputFocus() {
248
- this.$el.addClass('focus');
249
- }
250
-
251
- /**
252
- * Handle Input Blur
253
- */
254
- _handleInputBlur() {
255
- this.$el.removeClass('focus');
256
- }
257
-
258
- /**
259
- * Handle Input Keydown
260
- * @param {Event} e
261
- */
262
- _handleInputKeydown(e) {
263
- Chips._keydown = true;
264
-
265
- // enter
266
- if (e.keyCode === 13) {
267
- // Override enter if autocompleting.
268
- if (this.hasAutocomplete && this.autocomplete && this.autocomplete.isOpen) {
269
- return;
270
- }
271
-
272
- e.preventDefault();
273
- if (!this.hasAutocomplete || (this.hasAutocomplete && !this.options.autocompleteOnly)) {
274
- this.addChip({
275
- tag: this.$input[0].value
276
- });
277
- }
278
- this.$input[0].value = '';
279
-
280
- // delete or left
281
- } else if (
282
- (e.keyCode === 8 || e.keyCode === 37) &&
283
- this.$input[0].value === '' &&
284
- this.chipsData.length
285
- ) {
286
- e.preventDefault();
287
- this.selectChip(this.chipsData.length - 1);
288
- }
289
- }
290
-
291
- /**
292
- * Render Chip
293
- * @param {chip} chip
294
- * @return {Element}
295
- */
296
- _renderChip(chip) {
297
- if (!chip.tag) {
298
- return;
299
- }
300
-
301
- let renderedChip = document.createElement('div');
302
- let closeIcon = document.createElement('i');
303
- renderedChip.classList.add('chip');
304
- renderedChip.textContent = chip.tag;
305
- renderedChip.setAttribute('tabindex', 0);
306
- $(closeIcon).addClass('material-icons close');
307
- closeIcon.textContent = 'close';
308
-
309
- // attach image if needed
310
- if (chip.image) {
311
- let img = document.createElement('img');
312
- img.setAttribute('src', chip.image);
313
- renderedChip.insertBefore(img, renderedChip.firstChild);
314
- }
315
-
316
- renderedChip.appendChild(closeIcon);
317
- return renderedChip;
318
- }
319
-
320
- /**
321
- * Render Chips
322
- */
323
- _renderChips() {
324
- this.$chips.remove();
325
- for (let i = 0; i < this.chipsData.length; i++) {
326
- let chipEl = this._renderChip(this.chipsData[i]);
327
- this.$el.append(chipEl);
328
- this.$chips.add(chipEl);
329
- }
330
-
331
- // move input to end
332
- this.$el.append(this.$input[0]);
333
- }
334
-
335
- /**
336
- * Setup Autocomplete
337
- */
338
- _setupAutocomplete() {
339
- this.options.autocompleteOptions.onAutocomplete = (val) => {
340
- this.addChip({
341
- tag: val
342
- });
343
- this.$input[0].value = '';
344
- this.$input[0].focus();
345
- };
346
-
347
- this.autocomplete = M.Autocomplete.init(this.$input[0], this.options.autocompleteOptions);
348
- }
349
-
350
- /**
351
- * Setup Input
352
- */
353
- _setupInput() {
354
- this.$input = this.$el.find('input');
355
- if (!this.$input.length) {
356
- this.$input = $('<input></input>');
357
- this.$el.append(this.$input);
358
- }
359
-
360
- this.$input.addClass('input');
361
- }
362
-
363
- /**
364
- * Setup Label
365
- */
366
- _setupLabel() {
367
- this.$label = this.$el.find('label');
368
- if (this.$label.length) {
369
- this.$label[0].setAttribute('for', this.$input.attr('id'));
370
- }
371
- }
372
-
373
- /**
374
- * Set placeholder
375
- */
376
- _setPlaceholder() {
377
- if (this.chipsData !== undefined && !this.chipsData.length && this.options.placeholder) {
378
- $(this.$input).prop('placeholder', this.options.placeholder);
379
- } else if (
380
- (this.chipsData === undefined || !!this.chipsData.length) &&
381
- this.options.secondaryPlaceholder
382
- ) {
383
- $(this.$input).prop('placeholder', this.options.secondaryPlaceholder);
384
- }
385
- }
386
-
387
- /**
388
- * Check if chip is valid
389
- * @param {chip} chip
390
- */
391
- _isValid(chip) {
392
- if (chip.hasOwnProperty('tag') && chip.tag !== '') {
393
- let exists = false;
394
- for (let i = 0; i < this.chipsData.length; i++) {
395
- if (this.chipsData[i].tag === chip.tag) {
396
- exists = true;
397
- break;
398
- }
399
- }
400
- return !exists;
401
- }
402
-
403
- return false;
404
- }
405
-
406
- /**
407
- * Add chip
408
- * @param {chip} chip
409
- */
410
- addChip(chip) {
411
- if (!this._isValid(chip) || this.chipsData.length >= this.options.limit) {
412
- return;
413
- }
414
-
415
- let renderedChip = this._renderChip(chip);
416
- this.$chips.add(renderedChip);
417
- this.chipsData.push(chip);
418
- $(this.$input).before(renderedChip);
419
- this._setPlaceholder();
420
-
421
- // fire chipAdd callback
422
- if (typeof this.options.onChipAdd === 'function') {
423
- this.options.onChipAdd.call(this, this.$el, renderedChip);
424
- }
425
- }
426
-
427
- /**
428
- * Delete chip
429
- * @param {Number} chip
430
- */
431
- deleteChip(chipIndex) {
432
- let $chip = this.$chips.eq(chipIndex);
433
- this.$chips.eq(chipIndex).remove();
434
- this.$chips = this.$chips.filter(function(el) {
435
- return $(el).index() >= 0;
436
- });
437
- this.chipsData.splice(chipIndex, 1);
438
- this._setPlaceholder();
439
-
440
- // fire chipDelete callback
441
- if (typeof this.options.onChipDelete === 'function') {
442
- this.options.onChipDelete.call(this, this.$el, $chip[0]);
443
- }
444
- }
445
-
446
- /**
447
- * Select chip
448
- * @param {Number} chip
449
- */
450
- selectChip(chipIndex) {
451
- let $chip = this.$chips.eq(chipIndex);
452
- this._selectedChip = $chip;
453
- $chip[0].focus();
454
-
455
- // fire chipSelect callback
456
- if (typeof this.options.onChipSelect === 'function') {
457
- this.options.onChipSelect.call(this, this.$el, $chip[0]);
458
- }
459
- }
460
- }
461
-
462
- /**
463
- * @static
464
- * @memberof Chips
465
- */
466
- Chips._keydown = false;
467
-
468
- M.Chips = Chips;
469
-
470
- if (M.jQueryLoaded) {
471
- M.initializeJqueryWrapper(Chips, 'chips', 'M_Chips');
472
- }
473
-
474
- $(document).ready(function() {
475
- // Handle removal of static chips.
476
- $(document.body).on('click', '.chip .close', function() {
477
- let $chips = $(this).closest('.chips');
478
- if ($chips.length && $chips[0].M_Chips) {
479
- return;
480
- }
481
- $(this)
482
- .closest('.chip')
483
- .remove();
484
- });
485
- });
486
- })(cash);