@materializecss/materialize 2.0.3-beta → 2.0.4

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 (66) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +16 -18
  3. package/dist/css/materialize.css +73 -26
  4. package/dist/css/materialize.min.css +3 -3
  5. package/dist/js/materialize.js +560 -2015
  6. package/dist/js/materialize.min.js +3 -3
  7. package/dist/js/materialize.min.js.map +1 -1
  8. package/dist/src/buttons.d.ts.map +1 -1
  9. package/dist/src/cards.d.ts.map +1 -1
  10. package/dist/src/collapsible.d.ts +1 -0
  11. package/dist/src/collapsible.d.ts.map +1 -1
  12. package/dist/src/dropdown.d.ts +1 -0
  13. package/dist/src/dropdown.d.ts.map +1 -1
  14. package/dist/src/global.d.ts.map +1 -1
  15. package/dist/src/materialbox.d.ts +14 -10
  16. package/dist/src/materialbox.d.ts.map +1 -1
  17. package/dist/src/modal.d.ts.map +1 -1
  18. package/dist/src/range.d.ts.map +1 -1
  19. package/dist/src/scrollspy.d.ts.map +1 -1
  20. package/dist/src/sidenav.d.ts +25 -25
  21. package/dist/src/sidenav.d.ts.map +1 -1
  22. package/dist/src/slider.d.ts +12 -12
  23. package/dist/src/slider.d.ts.map +1 -1
  24. package/dist/src/tabs.d.ts +1 -1
  25. package/dist/src/tabs.d.ts.map +1 -1
  26. package/dist/src/toasts.d.ts +7 -2
  27. package/dist/src/toasts.d.ts.map +1 -1
  28. package/dist/src/tooltip.d.ts.map +1 -1
  29. package/package.json +29 -44
  30. package/sass/components/_collapsible.scss +14 -2
  31. package/sass/components/_materialbox.scss +2 -2
  32. package/sass/components/_modal.scss +0 -1
  33. package/sass/components/_tooltip.scss +18 -8
  34. package/sass/components/_variables.scss +2 -2
  35. package/Gruntfile.js +0 -385
  36. package/src/autocomplete.ts +0 -553
  37. package/src/bounding.ts +0 -6
  38. package/src/buttons.ts +0 -260
  39. package/src/cards.ts +0 -53
  40. package/src/carousel.ts +0 -676
  41. package/src/characterCounter.ts +0 -117
  42. package/src/chips.ts +0 -439
  43. package/src/collapsible.ts +0 -249
  44. package/src/component.ts +0 -120
  45. package/src/datepicker.ts +0 -1076
  46. package/src/dropdown.ts +0 -644
  47. package/src/edges.ts +0 -6
  48. package/src/forms.ts +0 -132
  49. package/src/global.ts +0 -114
  50. package/src/index.ts +0 -26
  51. package/src/materialbox.ts +0 -404
  52. package/src/modal.ts +0 -341
  53. package/src/parallax.ts +0 -149
  54. package/src/pushpin.ts +0 -165
  55. package/src/range.ts +0 -198
  56. package/src/scrollspy.ts +0 -263
  57. package/src/select.ts +0 -484
  58. package/src/sidenav.ts +0 -543
  59. package/src/slider.ts +0 -474
  60. package/src/tabs.ts +0 -347
  61. package/src/tapTarget.ts +0 -273
  62. package/src/timepicker.ts +0 -832
  63. package/src/toasts.ts +0 -290
  64. package/src/tooltip.ts +0 -366
  65. package/src/utils.ts +0 -271
  66. package/src/waves.ts +0 -70
package/src/buttons.ts DELETED
@@ -1,260 +0,0 @@
1
- import anim from "animejs";
2
-
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
- }
74
-
75
- static get defaults() {
76
- return _defaults;
77
- }
78
-
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
- }
99
-
100
- static getInstance(el: HTMLElement): FloatingActionButton {
101
- return (el as any).M_FloatingActionButton;
102
- }
103
-
104
- destroy() {
105
- this._removeEventHandlers();
106
- (this.el as any).M_FloatingActionButton = undefined;
107
- }
108
-
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);
115
- }
116
- }
117
-
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);
124
- }
125
- }
126
-
127
- _handleFABClick = () => {
128
- if (this.isOpen) {
129
- this.close();
130
- } else {
131
- this.open();
132
- }
133
- }
134
-
135
- _handleDocumentClick = (e: MouseEvent) => {
136
- const elem = e.target;
137
- if (elem !== this._menu) this.close;
138
- }
139
-
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
- }
151
-
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);
160
- }
161
- else {
162
- this._animateOutFAB();
163
- }
164
- this.isOpen = false;
165
- }
166
-
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'
180
- });
181
- time += 40;
182
- });
183
- }
184
-
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
- }
202
-
203
- _animateInToolbar() {
204
- let scaleFactor;
205
- let windowWidth = window.innerWidth;
206
- let windowHeight = window.innerHeight;
207
- let btnRect = this.el.getBoundingClientRect();
208
-
209
- const backdrop = document.createElement('div');
210
- backdrop.classList.add('fab-backdrop'); // $('<div class="fab-backdrop"></div>');
211
-
212
- const fabColor = getComputedStyle(this._anchor).backgroundColor; // css('background-color');
213
-
214
- this._anchor.append(backdrop);
215
-
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;
222
-
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';
231
-
232
- this._anchor.style.transform = `translateY(${this.offsetY}px`;
233
- this._anchor.style.transition = 'none';
234
-
235
- backdrop.style.backgroundColor = fabColor;
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';
240
-
241
- this._anchor.style.overflow = 'visible';
242
- this._anchor.style.transform = '';
243
- this._anchor.style.transition = 'transform .2s';
244
-
245
- setTimeout(() => {
246
- this.el.style.overflow = 'hidden';
247
- this.el.style.backgroundColor = fabColor;
248
-
249
- backdrop.style.transform = 'scale(' + scaleFactor + ')';
250
- backdrop.style.transition = 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)';
251
-
252
- this._menu.querySelectorAll('li > a').forEach((a: HTMLAnchorElement) => a.style.opacity = '1');
253
-
254
- // Scroll to close.
255
- window.addEventListener('scroll', this.close, true);
256
- document.body.addEventListener('click', this._handleDocumentClick, true);
257
- }, 100);
258
- }, 0);
259
- }
260
- }
package/src/cards.ts DELETED
@@ -1,53 +0,0 @@
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
- }