@materializecss/materialize 2.0.1-alpha → 2.0.2-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 (45) hide show
  1. package/Gruntfile.js +5 -2
  2. package/dist/css/materialize.css +90 -86
  3. package/dist/css/materialize.min.css +2 -2
  4. package/dist/js/materialize.js +2797 -2705
  5. package/dist/js/materialize.min.js +2 -8967
  6. package/dist/js/materialize.min.js.map +1 -1
  7. package/package.json +1 -1
  8. package/sass/components/_collapsible.scss +0 -41
  9. package/sass/components/_global.scss +3 -2
  10. package/sass/components/_icons-material-design.scss +2 -1
  11. package/sass/components/_navbar.scss +6 -3
  12. package/sass/components/_sidenav.scss +66 -37
  13. package/sass/components/_theme_variables.scss +2 -2
  14. package/sass/components/_typography.scss +2 -2
  15. package/sass/components/forms/_input-fields.scss +4 -10
  16. package/sass/materialize.scss +0 -4
  17. package/src/autocomplete.ts +188 -94
  18. package/src/buttons.ts +225 -260
  19. package/src/cards.ts +5 -6
  20. package/src/carousel.ts +611 -542
  21. package/src/characterCounter.ts +50 -21
  22. package/src/chips.ts +152 -63
  23. package/src/collapsible.ts +97 -32
  24. package/src/component.ts +99 -10
  25. package/src/datepicker.ts +905 -726
  26. package/src/dropdown.ts +576 -484
  27. package/src/edges.ts +4 -4
  28. package/src/forms.ts +17 -14
  29. package/src/global.ts +55 -324
  30. package/src/materialbox.ts +354 -298
  31. package/src/modal.ts +296 -211
  32. package/src/parallax.ts +129 -105
  33. package/src/pushpin.ts +148 -103
  34. package/src/range.ts +166 -150
  35. package/src/scrollspy.ts +214 -174
  36. package/src/select.ts +434 -398
  37. package/src/sidenav.ts +447 -381
  38. package/src/slider.ts +421 -362
  39. package/src/tabs.ts +276 -222
  40. package/src/tapTarget.ts +246 -213
  41. package/src/timepicker.ts +738 -614
  42. package/src/toasts.ts +254 -230
  43. package/src/tooltip.ts +315 -252
  44. package/src/utils.ts +271 -0
  45. package/src/waves.ts +10 -10
package/src/buttons.ts CHANGED
@@ -1,295 +1,260 @@
1
- import { Component } from "./component";
2
1
  import anim from "animejs";
3
2
 
4
- let _defaults = {
5
- direction: 'top',
6
- hoverEnabled: true,
7
- toolbarEnabled: false
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;
26
-
27
- constructor(el, options) {
28
- super(FloatingActionButton, el, options);
29
-
30
- (this.el as any).M_FloatingActionButton = this;
31
-
32
- this.options = {...FloatingActionButton.defaults, ...options};
33
- this.isOpen = false;
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();
38
- this.offsetY = 0;
39
- this.offsetX = 0;
40
-
41
- this.el.classList.add(`direction-${this.options.direction}`);
42
- if (this.options.direction === 'top')
43
- this.offsetY = 40;
44
- else if (this.options.direction === 'right')
45
- this.offsetX = -40;
46
- else if (this.options.direction === 'bottom')
47
- this.offsetY = -40;
48
- else
49
- this.offsetX = 40;
50
- this._setupEventHandlers();
51
- }
3
+ import { Component, BaseOptions, InitElements, MElement, Openable } from "./component";
4
+
5
+ export interface FloatingActionButtonOptions extends BaseOptions {
6
+ /**
7
+ * Direction FAB menu opens.
8
+ * @default "top"
9
+ */
10
+ direction: "top" | "right" | "bottom" | "left";
11
+ /**
12
+ * true: FAB menu appears on hover, false: FAB menu appears on click.
13
+ * @default true
14
+ */
15
+ hoverEnabled: boolean;
16
+ /**
17
+ * Enable transit the FAB into a toolbar on click.
18
+ * @default false
19
+ */
20
+ toolbarEnabled: boolean;
21
+ };
22
+
23
+ let _defaults: FloatingActionButtonOptions = {
24
+ direction: 'top',
25
+ hoverEnabled: true,
26
+ toolbarEnabled: false
27
+ };
28
+
29
+ export class FloatingActionButton extends Component<FloatingActionButtonOptions> implements Openable {
30
+ /**
31
+ * Describes open/close state of FAB.
32
+ */
33
+ isOpen: boolean;
34
+
35
+ private _anchor: HTMLAnchorElement;
36
+ private _menu: HTMLElement|null;
37
+ private _floatingBtns: HTMLElement[];
38
+ private _floatingBtnsReverse: HTMLElement[];
39
+
40
+ offsetY: number;
41
+ offsetX: number;
42
+ btnBottom: number;
43
+ btnLeft: number;
44
+ btnWidth: number;
45
+
46
+ constructor(el: HTMLElement, options: Partial<FloatingActionButtonOptions>) {
47
+ super(el, options, FloatingActionButton);
48
+ (this.el as any).M_FloatingActionButton = this;
49
+
50
+ this.options = {
51
+ ...FloatingActionButton.defaults,
52
+ ...options
53
+ };
54
+
55
+ this.isOpen = false;
56
+ this._anchor = this.el.querySelector('a');
57
+ this._menu = this.el.querySelector('ul');
58
+ this._floatingBtns = Array.from(this.el.querySelectorAll('ul .btn-floating'));
59
+ this._floatingBtnsReverse = this._floatingBtns.reverse();
60
+ this.offsetY = 0;
61
+ this.offsetX = 0;
62
+
63
+ this.el.classList.add(`direction-${this.options.direction}`);
64
+ if (this.options.direction === 'top')
65
+ this.offsetY = 40;
66
+ else if (this.options.direction === 'right')
67
+ this.offsetX = -40;
68
+ else if (this.options.direction === 'bottom')
69
+ this.offsetY = -40;
70
+ else
71
+ this.offsetX = 40;
72
+ this._setupEventHandlers();
73
+ }
52
74
 
53
- static get defaults() {
54
- return _defaults;
55
- }
75
+ static get defaults() {
76
+ return _defaults;
77
+ }
56
78
 
57
- static init(els, options) {
58
- return super.init(this, els, options);
59
- }
79
+ /**
80
+ * Initializes instance of FloatingActionButton.
81
+ * @param el HTML element.
82
+ * @param options Component options.
83
+ */
84
+ static init(el: HTMLElement, options?: Partial<FloatingActionButtonOptions>): FloatingActionButton
85
+ /**
86
+ * Initializes instances of FloatingActionButton.
87
+ * @param els HTML elements.
88
+ * @param options Component options.
89
+ */
90
+ static init(els: InitElements<MElement>, options?: Partial<FloatingActionButtonOptions>): FloatingActionButton[];
91
+ /**
92
+ * Initializes instances of FloatingActionButton.
93
+ * @param els HTML elements.
94
+ * @param options Component options.
95
+ */
96
+ static init(els: HTMLElement | InitElements<MElement>, options: Partial<FloatingActionButtonOptions> = {}): FloatingActionButton | FloatingActionButton[] {
97
+ return super.init(els, options, FloatingActionButton);
98
+ }
60
99
 
61
- static getInstance(el) {
62
- let domElem = !!el.jquery ? el[0] : el;
63
- return domElem.M_FloatingActionButton;
64
- }
100
+ static getInstance(el: HTMLElement): FloatingActionButton {
101
+ return (el as any).M_FloatingActionButton;
102
+ }
65
103
 
66
- destroy() {
67
- this._removeEventHandlers();
68
- (this.el as any).M_FloatingActionButton = undefined;
69
- }
104
+ destroy() {
105
+ this._removeEventHandlers();
106
+ (this.el as any).M_FloatingActionButton = undefined;
107
+ }
70
108
 
71
- _setupEventHandlers() {
72
- this._handleFABClickBound = this._handleFABClick.bind(this);
73
- this._handleOpenBound = this.open.bind(this);
74
- this._handleCloseBound = this.close.bind(this);
75
-
76
- if (this.options.hoverEnabled && !this.options.toolbarEnabled) {
77
- this.el.addEventListener('mouseenter', this._handleOpenBound);
78
- this.el.addEventListener('mouseleave', this._handleCloseBound);
79
- } else {
80
- this.el.addEventListener('click', this._handleFABClickBound);
81
- }
109
+ _setupEventHandlers() {
110
+ if (this.options.hoverEnabled && !this.options.toolbarEnabled) {
111
+ this.el.addEventListener('mouseenter', this.open);
112
+ this.el.addEventListener('mouseleave', this.close);
113
+ } else {
114
+ this.el.addEventListener('click', this._handleFABClick);
82
115
  }
116
+ }
83
117
 
84
- _removeEventHandlers() {
85
- if (this.options.hoverEnabled && !this.options.toolbarEnabled) {
86
- this.el.removeEventListener('mouseenter', this._handleOpenBound);
87
- this.el.removeEventListener('mouseleave', this._handleCloseBound);
88
- } else {
89
- this.el.removeEventListener('click', this._handleFABClickBound);
90
- }
118
+ _removeEventHandlers() {
119
+ if (this.options.hoverEnabled && !this.options.toolbarEnabled) {
120
+ this.el.removeEventListener('mouseenter', this.open);
121
+ this.el.removeEventListener('mouseleave', this.close);
122
+ } else {
123
+ this.el.removeEventListener('click', this._handleFABClick);
91
124
  }
125
+ }
92
126
 
93
- _handleFABClick() {
94
- if (this.isOpen) {
95
- this.close();
96
- } else {
97
- this.open();
98
- }
127
+ _handleFABClick = () => {
128
+ if (this.isOpen) {
129
+ this.close();
130
+ } else {
131
+ this.open();
99
132
  }
133
+ }
100
134
 
101
- _handleDocumentClick(e) {
102
- const elem = <HTMLElement>e.target;
103
- if (elem !== this._menu) this.close;
104
- /*
105
- if (!elem.closest(this.$menu)) {
106
- this.close();
107
- }*/
108
- }
135
+ _handleDocumentClick = (e: MouseEvent) => {
136
+ const elem = e.target;
137
+ if (elem !== this._menu) this.close;
138
+ }
109
139
 
110
- open() {
111
- if (this.isOpen) return;
112
- if (this.options.toolbarEnabled)
113
- this._animateInToolbar();
114
- else
115
- this._animateInFAB();
116
- this.isOpen = true;
117
- }
140
+ /**
141
+ * Open FAB.
142
+ */
143
+ open = (): void => {
144
+ if (this.isOpen) return;
145
+ if (this.options.toolbarEnabled)
146
+ this._animateInToolbar();
147
+ else
148
+ this._animateInFAB();
149
+ this.isOpen = true;
150
+ }
118
151
 
119
- close() {
120
- if (!this.isOpen) return;
121
- if (this.options.toolbarEnabled) {
122
- window.removeEventListener('scroll', this._handleCloseBound, true);
123
- document.body.removeEventListener('click', this._handleDocumentClickBound, true);
124
- this._animateOutToolbar();
125
- }
126
- else {
127
- this._animateOutFAB();
128
- }
129
- this.isOpen = false;
152
+ /**
153
+ * Close FAB.
154
+ */
155
+ close = (): void => {
156
+ if (!this.isOpen) return;
157
+ if (this.options.toolbarEnabled) {
158
+ window.removeEventListener('scroll', this.close, true);
159
+ document.body.removeEventListener('click', this._handleDocumentClick, true);
130
160
  }
131
-
132
- _animateInFAB() {
133
- this.el.classList.add('active');
134
- let time = 0;
135
- this._floatingBtnsReverse.forEach((el) => {
136
- anim({
137
- targets: el,
138
- opacity: 1,
139
- scale: [0.4, 1],
140
- translateY: [this.offsetY, 0],
141
- translateX: [this.offsetX, 0],
142
- duration: 275,
143
- delay: time,
144
- easing: 'easeInOutQuad'
145
- });
146
- time += 40;
147
- });
161
+ else {
162
+ this._animateOutFAB();
148
163
  }
164
+ this.isOpen = false;
165
+ }
149
166
 
150
- _animateOutFAB() {
151
- this._floatingBtnsReverse.forEach((el) => {
152
- anim.remove(el);
153
- anim({
154
- targets: el,
155
- opacity: 0,
156
- scale: 0.4,
157
- translateY: this.offsetY,
158
- translateX: this.offsetX,
159
- duration: 175,
160
- easing: 'easeOutQuad',
161
- complete: () => {
162
- this.el.classList.remove('active');
163
- }
164
- });
167
+ _animateInFAB() {
168
+ this.el.classList.add('active');
169
+ let time = 0;
170
+ this._floatingBtnsReverse.forEach((el) => {
171
+ anim({
172
+ targets: el,
173
+ opacity: 1,
174
+ scale: [0.4, 1],
175
+ translateY: [this.offsetY, 0],
176
+ translateX: [this.offsetX, 0],
177
+ duration: 275,
178
+ delay: time,
179
+ easing: 'easeInOutQuad'
165
180
  });
166
- }
167
-
168
- _animateInToolbar() {
169
- let scaleFactor;
170
- let windowWidth = window.innerWidth;
171
- let windowHeight = window.innerHeight;
172
- let btnRect = this.el.getBoundingClientRect();
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);
180
-
181
- this.offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2;
182
- this.offsetY = windowHeight - btnRect.bottom;
183
- scaleFactor = windowWidth / backdrop[0].clientWidth;
184
- this.btnBottom = btnRect.bottom;
185
- this.btnLeft = btnRect.left;
186
- this.btnWidth = btnRect.width;
187
-
188
- // Set initial state
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';
181
+ time += 40;
182
+ });
183
+ }
199
184
 
200
- (<HTMLElement>backdrop).style.backgroundColor = fabColor;
185
+ _animateOutFAB() {
186
+ this._floatingBtnsReverse.forEach((el) => {
187
+ anim.remove(el);
188
+ anim({
189
+ targets: el,
190
+ opacity: 0,
191
+ scale: 0.4,
192
+ translateY: this.offsetY,
193
+ translateX: this.offsetX,
194
+ duration: 175,
195
+ easing: 'easeOutQuad',
196
+ complete: () => {
197
+ this.el.classList.remove('active');
198
+ }
199
+ });
200
+ });
201
+ }
201
202
 
202
- setTimeout(() => {
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';
203
+ _animateInToolbar() {
204
+ let scaleFactor;
205
+ let windowWidth = window.innerWidth;
206
+ let windowHeight = window.innerHeight;
207
+ let btnRect = this.el.getBoundingClientRect();
205
208
 
206
- this._anchor.style.overflow = 'visible';
207
- this._anchor.style.transform = '';
208
- this._anchor.style.transition = 'transform .2s';
209
+ const backdrop = document.createElement('div');
210
+ backdrop.classList.add('fab-backdrop'); // $('<div class="fab-backdrop"></div>');
209
211
 
210
- setTimeout(() => {
211
- this.el.style.overflow = 'hidden';
212
- this.el.style.backgroundColor = fabColor;
212
+ const fabColor = getComputedStyle(this._anchor).backgroundColor; // css('background-color');
213
213
 
214
- backdrop.style.transform = 'scale(' + scaleFactor + ')';
215
- backdrop.style.transition = 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)';
214
+ this._anchor.append(backdrop);
216
215
 
217
- this._menu.querySelectorAll('li > a').forEach((a: HTMLAnchorElement) => a.style.opacity = '1');
216
+ this.offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2;
217
+ this.offsetY = windowHeight - btnRect.bottom;
218
+ scaleFactor = windowWidth / backdrop[0].clientWidth;
219
+ this.btnBottom = btnRect.bottom;
220
+ this.btnLeft = btnRect.left;
221
+ this.btnWidth = btnRect.width;
218
222
 
219
- // Scroll to close.
220
- this._handleDocumentClickBound = this._handleDocumentClick.bind(this);
221
- window.addEventListener('scroll', this._handleCloseBound, true);
222
- document.body.addEventListener('click', this._handleDocumentClickBound, true);
223
- }, 100);
224
- }, 0);
225
- }
223
+ // Set initial state
224
+ this.el.classList.add('active');
225
+ this.el.style.textAlign = 'center';
226
+ this.el.style.width = '100%';
227
+ this.el.style.bottom = '0';
228
+ this.el.style.left = '0';
229
+ this.el.style.transform = 'translateX(' + this.offsetX + 'px)';
230
+ this.el.style.transition = 'none';
226
231
 
232
+ this._anchor.style.transform = `translateY(${this.offsetY}px`;
233
+ this._anchor.style.transition = 'none';
227
234
 
235
+ backdrop.style.backgroundColor = fabColor;
228
236
 
237
+ setTimeout(() => {
238
+ this.el.style.transform = '';
239
+ this.el.style.transition = 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s';
229
240
 
230
- _animateOutToolbar() {
231
- return;
232
- /*
233
- let windowWidth = window.innerWidth;
234
- let windowHeight = window.innerHeight;
235
- let backdrop = this.$el.find('.fab-backdrop');
236
- let fabColor = this.$anchor.css('background-color');
241
+ this._anchor.style.overflow = 'visible';
242
+ this._anchor.style.transform = '';
243
+ this._anchor.style.transition = 'transform .2s';
237
244
 
238
- this.offsetX = this.btnLeft - windowWidth / 2 + this.btnWidth / 2;
239
- this.offsetY = windowHeight - this.btnBottom;
245
+ setTimeout(() => {
246
+ this.el.style.overflow = 'hidden';
247
+ this.el.style.backgroundColor = fabColor;
240
248
 
241
- // Hide backdrop
242
- this.$el.removeClass('active');
243
- this.$el.css({
244
- 'background-color': 'transparent',
245
- transition: 'none'
246
- });
247
- // this.$anchor.css({
248
- // transition: 'none'
249
- // });
250
- backdrop.css({
251
- transform: 'scale(0)',
252
- 'background-color': fabColor
253
- });
249
+ backdrop.style.transform = 'scale(' + scaleFactor + ')';
250
+ backdrop.style.transition = 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)';
254
251
 
255
- // this.$menu
256
- // .children('li')
257
- // .children('a')
258
- // .css({
259
- // opacity: ''
260
- // });
252
+ this._menu.querySelectorAll('li > a').forEach((a: HTMLAnchorElement) => a.style.opacity = '1');
261
253
 
262
- setTimeout(() => {
263
- backdrop.remove();
264
-
265
- // Set initial state.
266
- this.$el.css({
267
- 'text-align': '',
268
- width: '',
269
- bottom: '',
270
- left: '',
271
- overflow: '',
272
- 'background-color': '',
273
- transform: 'translate3d(' + -this.offsetX + 'px,0,0)'
274
- });
275
- // this.$anchor.css({
276
- // overflow: '',
277
- // transform: 'translate3d(0,' + this.offsetY + 'px,0)'
278
- // });
279
-
280
- setTimeout(() => {
281
- this.$el.css({
282
- transform: 'translate3d(0,0,0)',
283
- transition: 'transform .2s'
284
- });
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
- // });
289
- }, 20);
290
- }, 200);
291
- */
292
- }
254
+ // Scroll to close.
255
+ window.addEventListener('scroll', this.close, true);
256
+ document.body.addEventListener('click', this._handleDocumentClick, true);
257
+ }, 100);
258
+ }, 0);
293
259
  }
294
-
295
-
260
+ }
package/src/cards.ts CHANGED
@@ -15,7 +15,7 @@ export class Cards {
15
15
  if (!cardReveal) return;
16
16
  const initialOverflow = getComputedStyle(card).overflow;
17
17
 
18
- // Close Card
18
+ // Close Card
19
19
  const closeArea = cardReveal.querySelector('.card-reveal .card-title');
20
20
  if (trigger === closeArea || closeArea.contains(trigger)) {
21
21
  anim({
@@ -29,7 +29,7 @@ export class Cards {
29
29
  }
30
30
  });
31
31
  };
32
-
32
+
33
33
  // Reveal Card
34
34
  const activators = card.querySelectorAll('.activator');
35
35
  activators.forEach(activator => {
@@ -44,11 +44,10 @@ export class Cards {
44
44
  });
45
45
  }
46
46
  });
47
-
48
47
 
49
- });
48
+
49
+ });
50
50
  });
51
51
 
52
- }
52
+ }
53
53
  }
54
-