@materializecss/materialize 1.2.1 → 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 (91) hide show
  1. package/Gruntfile.js +68 -313
  2. package/README.md +3 -3
  3. package/dist/css/materialize.css +1019 -1824
  4. package/dist/css/materialize.min.css +3 -9
  5. package/dist/js/materialize.js +8416 -12190
  6. package/dist/js/materialize.min.js +4 -3
  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 +36 -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 -359
  86. package/js/tabs.js +0 -402
  87. package/js/tapTarget.js +0 -315
  88. package/js/waves.js +0 -615
  89. package/sass/_style.scss +0 -929
  90. package/sass/components/_waves.scss +0 -187
  91. package/sass/ghpages-materialize.scss +0 -7
@@ -0,0 +1,6 @@
1
+ export class Bounding {
2
+ public left: number; // left offset coordinate
3
+ public top: number;
4
+ public width: number;
5
+ public height: number;
6
+ }
@@ -1,57 +1,52 @@
1
- (function($, anim) {
2
- 'use strict';
1
+ import { Component } from "./component";
2
+ import anim from "animejs";
3
3
 
4
4
  let _defaults = {
5
5
  direction: 'top',
6
6
  hoverEnabled: true,
7
7
  toolbarEnabled: false
8
8
  };
9
+
10
+ export class FloatingActionButton extends Component {
11
+ el: HTMLElement;
12
+ isOpen: boolean;
13
+ private _anchor: HTMLAnchorElement;
14
+ private _menu: HTMLElement|null;
15
+ private _floatingBtns: HTMLElement[];
16
+ private _floatingBtnsReverse: HTMLElement[];
17
+ offsetY: number;
18
+ offsetX: number;
19
+ private _handleFABClickBound: any;
20
+ private _handleOpenBound: any;
21
+ private _handleCloseBound: any;
22
+ private _handleDocumentClickBound: (this: HTMLElement, ev: MouseEvent) => any;
23
+ btnBottom: number;
24
+ btnLeft: number;
25
+ btnWidth: number;
9
26
 
10
- $.fn.reverse = [].reverse;
11
-
12
- /**
13
- * @class
14
- *
15
- */
16
- class FloatingActionButton extends Component {
17
- /**
18
- * Construct FloatingActionButton instance
19
- * @constructor
20
- * @param {Element} el
21
- * @param {Object} options
22
- */
23
27
  constructor(el, options) {
24
28
  super(FloatingActionButton, el, options);
25
29
 
26
- this.el.M_FloatingActionButton = this;
27
-
28
- /**
29
- * Options for the fab
30
- * @member FloatingActionButton#options
31
- * @prop {Boolean} [direction] - Direction fab menu opens
32
- * @prop {Boolean} [hoverEnabled=true] - Enable hover vs click
33
- * @prop {Boolean} [toolbarEnabled=false] - Enable toolbar transition
34
- */
35
- this.options = $.extend({}, FloatingActionButton.defaults, options);
30
+ (this.el as any).M_FloatingActionButton = this;
36
31
 
32
+ this.options = {...FloatingActionButton.defaults, ...options};
37
33
  this.isOpen = false;
38
- this.$anchor = this.$el.children('a').first();
39
- this.$menu = this.$el.children('ul').first();
40
- this.$floatingBtns = this.$el.find('ul .btn-floating');
41
- this.$floatingBtnsReverse = this.$el.find('ul .btn-floating').reverse();
34
+ this._anchor = this.el.querySelector('a');
35
+ this._menu = this.el.querySelector('ul');
36
+ this._floatingBtns = Array.from(this.el.querySelectorAll('ul .btn-floating'));
37
+ this._floatingBtnsReverse = this._floatingBtns.reverse();
42
38
  this.offsetY = 0;
43
39
  this.offsetX = 0;
44
40
 
45
- this.$el.addClass(`direction-${this.options.direction}`);
46
- if (this.options.direction === 'top') {
41
+ this.el.classList.add(`direction-${this.options.direction}`);
42
+ if (this.options.direction === 'top')
47
43
  this.offsetY = 40;
48
- } else if (this.options.direction === 'right') {
44
+ else if (this.options.direction === 'right')
49
45
  this.offsetX = -40;
50
- } else if (this.options.direction === 'bottom') {
46
+ else if (this.options.direction === 'bottom')
51
47
  this.offsetY = -40;
52
- } else {
48
+ else
53
49
  this.offsetX = 40;
54
- }
55
50
  this._setupEventHandlers();
56
51
  }
57
52
 
@@ -63,25 +58,16 @@
63
58
  return super.init(this, els, options);
64
59
  }
65
60
 
66
- /**
67
- * Get Instance
68
- */
69
61
  static getInstance(el) {
70
62
  let domElem = !!el.jquery ? el[0] : el;
71
63
  return domElem.M_FloatingActionButton;
72
64
  }
73
65
 
74
- /**
75
- * Teardown component
76
- */
77
66
  destroy() {
78
67
  this._removeEventHandlers();
79
- this.el.M_FloatingActionButton = undefined;
68
+ (this.el as any).M_FloatingActionButton = undefined;
80
69
  }
81
70
 
82
- /**
83
- * Setup Event Handlers
84
- */
85
71
  _setupEventHandlers() {
86
72
  this._handleFABClickBound = this._handleFABClick.bind(this);
87
73
  this._handleOpenBound = this.open.bind(this);
@@ -95,9 +81,6 @@
95
81
  }
96
82
  }
97
83
 
98
- /**
99
- * Remove Event Handlers
100
- */
101
84
  _removeEventHandlers() {
102
85
  if (this.options.hoverEnabled && !this.options.toolbarEnabled) {
103
86
  this.el.removeEventListener('mouseenter', this._handleOpenBound);
@@ -107,9 +90,6 @@
107
90
  }
108
91
  }
109
92
 
110
- /**
111
- * Handle FAB Click
112
- */
113
93
  _handleFABClick() {
114
94
  if (this.isOpen) {
115
95
  this.close();
@@ -118,58 +98,41 @@
118
98
  }
119
99
  }
120
100
 
121
- /**
122
- * Handle Document Click
123
- * @param {Event} e
124
- */
125
101
  _handleDocumentClick(e) {
126
- if (!$(e.target).closest(this.$menu).length) {
102
+ const elem = <HTMLElement>e.target;
103
+ if (elem !== this._menu) this.close;
104
+ /*
105
+ if (!elem.closest(this.$menu)) {
127
106
  this.close();
128
- }
107
+ }*/
129
108
  }
130
109
 
131
- /**
132
- * Open FAB
133
- */
134
110
  open() {
135
- if (this.isOpen) {
136
- return;
137
- }
138
-
139
- if (this.options.toolbarEnabled) {
111
+ if (this.isOpen) return;
112
+ if (this.options.toolbarEnabled)
140
113
  this._animateInToolbar();
141
- } else {
114
+ else
142
115
  this._animateInFAB();
143
- }
144
116
  this.isOpen = true;
145
117
  }
146
118
 
147
- /**
148
- * Close FAB
149
- */
150
119
  close() {
151
- if (!this.isOpen) {
152
- return;
153
- }
154
-
120
+ if (!this.isOpen) return;
155
121
  if (this.options.toolbarEnabled) {
156
122
  window.removeEventListener('scroll', this._handleCloseBound, true);
157
123
  document.body.removeEventListener('click', this._handleDocumentClickBound, true);
158
124
  this._animateOutToolbar();
159
- } else {
125
+ }
126
+ else {
160
127
  this._animateOutFAB();
161
128
  }
162
129
  this.isOpen = false;
163
130
  }
164
131
 
165
- /**
166
- * Classic FAB Menu open
167
- */
168
132
  _animateInFAB() {
169
- this.$el.addClass('active');
170
-
133
+ this.el.classList.add('active');
171
134
  let time = 0;
172
- this.$floatingBtnsReverse.each((el) => {
135
+ this._floatingBtnsReverse.forEach((el) => {
173
136
  anim({
174
137
  targets: el,
175
138
  opacity: 1,
@@ -184,11 +147,8 @@
184
147
  });
185
148
  }
186
149
 
187
- /**
188
- * Classic FAB Menu close
189
- */
190
150
  _animateOutFAB() {
191
- this.$floatingBtnsReverse.each((el) => {
151
+ this._floatingBtnsReverse.forEach((el) => {
192
152
  anim.remove(el);
193
153
  anim({
194
154
  targets: el,
@@ -199,23 +159,24 @@
199
159
  duration: 175,
200
160
  easing: 'easeOutQuad',
201
161
  complete: () => {
202
- this.$el.removeClass('active');
162
+ this.el.classList.remove('active');
203
163
  }
204
164
  });
205
165
  });
206
166
  }
207
167
 
208
- /**
209
- * Toolbar transition Menu open
210
- */
211
168
  _animateInToolbar() {
212
169
  let scaleFactor;
213
170
  let windowWidth = window.innerWidth;
214
171
  let windowHeight = window.innerHeight;
215
172
  let btnRect = this.el.getBoundingClientRect();
216
- let backdrop = $('<div class="fab-backdrop"></div>');
217
- let fabColor = this.$anchor.css('background-color');
218
- this.$anchor.append(backdrop);
173
+
174
+ const backdrop = document.createElement('div');
175
+ backdrop.classList.add('fab-backdrop'); // $('<div class="fab-backdrop"></div>');
176
+
177
+ const fabColor = getComputedStyle(this._anchor).backgroundColor; // css('background-color');
178
+
179
+ this._anchor.append(backdrop);
219
180
 
220
181
  this.offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2;
221
182
  this.offsetY = windowHeight - btnRect.bottom;
@@ -225,50 +186,35 @@
225
186
  this.btnWidth = btnRect.width;
226
187
 
227
188
  // Set initial state
228
- this.$el.addClass('active');
229
- this.$el.css({
230
- 'text-align': 'center',
231
- width: '100%',
232
- bottom: 0,
233
- left: 0,
234
- transform: 'translateX(' + this.offsetX + 'px)',
235
- transition: 'none'
236
- });
237
- this.$anchor.css({
238
- transform: 'translateY(' + -this.offsetY + 'px)',
239
- transition: 'none'
240
- });
241
- backdrop.css({
242
- 'background-color': fabColor
243
- });
189
+ this.el.classList.add('active');
190
+ this.el.style.textAlign = 'center';
191
+ this.el.style.width = '100%';
192
+ this.el.style.bottom = '0';
193
+ this.el.style.left = '0';
194
+ this.el.style.transform = 'translateX(' + this.offsetX + 'px)';
195
+ this.el.style.transition = 'none';
196
+
197
+ this._anchor.style.transform = `translateY(${this.offsetY}px`;
198
+ this._anchor.style.transition = 'none';
199
+
200
+ (<HTMLElement>backdrop).style.backgroundColor = fabColor;
244
201
 
245
202
  setTimeout(() => {
246
- this.$el.css({
247
- transform: '',
248
- transition:
249
- 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s'
250
- });
251
- this.$anchor.css({
252
- overflow: 'visible',
253
- transform: '',
254
- transition: 'transform .2s'
255
- });
203
+ this.el.style.transform = '';
204
+ this.el.style.transition = 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s';
205
+
206
+ this._anchor.style.overflow = 'visible';
207
+ this._anchor.style.transform = '';
208
+ this._anchor.style.transition = 'transform .2s';
256
209
 
257
210
  setTimeout(() => {
258
- this.$el.css({
259
- overflow: 'hidden',
260
- 'background-color': fabColor
261
- });
262
- backdrop.css({
263
- transform: 'scale(' + scaleFactor + ')',
264
- transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
265
- });
266
- this.$menu
267
- .children('li')
268
- .children('a')
269
- .css({
270
- opacity: 1
271
- });
211
+ this.el.style.overflow = 'hidden';
212
+ this.el.style.backgroundColor = fabColor;
213
+
214
+ backdrop.style.transform = 'scale(' + scaleFactor + ')';
215
+ backdrop.style.transition = 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)';
216
+
217
+ this._menu.querySelectorAll('li > a').forEach((a: HTMLAnchorElement) => a.style.opacity = '1');
272
218
 
273
219
  // Scroll to close.
274
220
  this._handleDocumentClickBound = this._handleDocumentClick.bind(this);
@@ -278,10 +224,12 @@
278
224
  }, 0);
279
225
  }
280
226
 
281
- /**
282
- * Toolbar transition Menu close
283
- */
227
+
228
+
229
+
284
230
  _animateOutToolbar() {
231
+ return;
232
+ /*
285
233
  let windowWidth = window.innerWidth;
286
234
  let windowHeight = window.innerHeight;
287
235
  let backdrop = this.$el.find('.fab-backdrop');
@@ -296,19 +244,20 @@
296
244
  'background-color': 'transparent',
297
245
  transition: 'none'
298
246
  });
299
- this.$anchor.css({
300
- transition: 'none'
301
- });
247
+ // this.$anchor.css({
248
+ // transition: 'none'
249
+ // });
302
250
  backdrop.css({
303
251
  transform: 'scale(0)',
304
252
  'background-color': fabColor
305
253
  });
306
- this.$menu
307
- .children('li')
308
- .children('a')
309
- .css({
310
- opacity: ''
311
- });
254
+
255
+ // this.$menu
256
+ // .children('li')
257
+ // .children('a')
258
+ // .css({
259
+ // opacity: ''
260
+ // });
312
261
 
313
262
  setTimeout(() => {
314
263
  backdrop.remove();
@@ -323,32 +272,24 @@
323
272
  'background-color': '',
324
273
  transform: 'translate3d(' + -this.offsetX + 'px,0,0)'
325
274
  });
326
- this.$anchor.css({
327
- overflow: '',
328
- transform: 'translate3d(0,' + this.offsetY + 'px,0)'
329
- });
275
+ // this.$anchor.css({
276
+ // overflow: '',
277
+ // transform: 'translate3d(0,' + this.offsetY + 'px,0)'
278
+ // });
330
279
 
331
280
  setTimeout(() => {
332
281
  this.$el.css({
333
282
  transform: 'translate3d(0,0,0)',
334
283
  transition: 'transform .2s'
335
284
  });
336
- this.$anchor.css({
337
- transform: 'translate3d(0,0,0)',
338
- transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
339
- });
285
+ // this.$anchor.css({
286
+ // transform: 'translate3d(0,0,0)',
287
+ // transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
288
+ // });
340
289
  }, 20);
341
290
  }, 200);
291
+ */
342
292
  }
343
293
  }
344
294
 
345
- M.FloatingActionButton = FloatingActionButton;
346
-
347
- if (M.jQueryLoaded) {
348
- M.initializeJqueryWrapper(
349
- FloatingActionButton,
350
- 'floatingActionButton',
351
- 'M_FloatingActionButton'
352
- );
353
- }
354
- })(cash, M.anime);
295
+
package/src/cards.ts ADDED
@@ -0,0 +1,54 @@
1
+ import anim from "animejs";
2
+
3
+ export class Cards {
4
+
5
+ static Init() {
6
+
7
+ document.addEventListener("DOMContentLoaded", () => {
8
+ document.body.addEventListener('click', e => {
9
+ const trigger = <HTMLElement>e.target;
10
+
11
+ const card: HTMLElement = trigger.closest('.card');
12
+ if (!card) return;
13
+
14
+ const cardReveal = <HTMLElement|null>Array.from(card.children).find(elem => elem.classList.contains('card-reveal'));
15
+ if (!cardReveal) return;
16
+ const initialOverflow = getComputedStyle(card).overflow;
17
+
18
+ // Close Card
19
+ const closeArea = cardReveal.querySelector('.card-reveal .card-title');
20
+ if (trigger === closeArea || closeArea.contains(trigger)) {
21
+ anim({
22
+ targets: cardReveal,
23
+ translateY: 0,
24
+ duration: 225,
25
+ easing: 'easeInOutQuad',
26
+ complete: (anim) => {
27
+ cardReveal.style.display = 'none';
28
+ card.style.overflow = initialOverflow;
29
+ }
30
+ });
31
+ };
32
+
33
+ // Reveal Card
34
+ const activators = card.querySelectorAll('.activator');
35
+ activators.forEach(activator => {
36
+ if (trigger === activator || activator.contains(trigger)) {
37
+ card.style.overflow = 'hidden';
38
+ cardReveal.style.display = 'block';
39
+ anim({
40
+ targets: cardReveal,
41
+ translateY: '-100%',
42
+ duration: 300,
43
+ easing: 'easeInOutQuad'
44
+ });
45
+ }
46
+ });
47
+
48
+
49
+ });
50
+ });
51
+
52
+ }
53
+ }
54
+