@materializecss/materialize 2.0.3-beta → 2.0.3

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 (64) hide show
  1. package/README.md +1 -1
  2. package/dist/css/materialize.css +37 -15
  3. package/dist/css/materialize.min.css +2 -2
  4. package/dist/js/materialize.js +503 -1974
  5. package/dist/js/materialize.min.js +2 -2
  6. package/dist/js/materialize.min.js.map +1 -1
  7. package/dist/src/buttons.d.ts.map +1 -1
  8. package/dist/src/cards.d.ts.map +1 -1
  9. package/dist/src/collapsible.d.ts +1 -0
  10. package/dist/src/collapsible.d.ts.map +1 -1
  11. package/dist/src/dropdown.d.ts.map +1 -1
  12. package/dist/src/global.d.ts.map +1 -1
  13. package/dist/src/materialbox.d.ts +14 -10
  14. package/dist/src/materialbox.d.ts.map +1 -1
  15. package/dist/src/modal.d.ts.map +1 -1
  16. package/dist/src/range.d.ts.map +1 -1
  17. package/dist/src/scrollspy.d.ts.map +1 -1
  18. package/dist/src/sidenav.d.ts +25 -25
  19. package/dist/src/sidenav.d.ts.map +1 -1
  20. package/dist/src/slider.d.ts +12 -12
  21. package/dist/src/slider.d.ts.map +1 -1
  22. package/dist/src/tabs.d.ts +1 -1
  23. package/dist/src/tabs.d.ts.map +1 -1
  24. package/dist/src/toasts.d.ts +7 -2
  25. package/dist/src/toasts.d.ts.map +1 -1
  26. package/dist/src/tooltip.d.ts.map +1 -1
  27. package/package.json +14 -10
  28. package/sass/components/_collapsible.scss +14 -2
  29. package/sass/components/_materialbox.scss +2 -2
  30. package/sass/components/_modal.scss +0 -1
  31. package/sass/components/_tooltip.scss +18 -8
  32. package/sass/components/_variables.scss +2 -2
  33. package/Gruntfile.js +0 -385
  34. package/src/autocomplete.ts +0 -553
  35. package/src/bounding.ts +0 -6
  36. package/src/buttons.ts +0 -260
  37. package/src/cards.ts +0 -53
  38. package/src/carousel.ts +0 -676
  39. package/src/characterCounter.ts +0 -117
  40. package/src/chips.ts +0 -439
  41. package/src/collapsible.ts +0 -249
  42. package/src/component.ts +0 -120
  43. package/src/datepicker.ts +0 -1076
  44. package/src/dropdown.ts +0 -644
  45. package/src/edges.ts +0 -6
  46. package/src/forms.ts +0 -132
  47. package/src/global.ts +0 -114
  48. package/src/index.ts +0 -26
  49. package/src/materialbox.ts +0 -404
  50. package/src/modal.ts +0 -341
  51. package/src/parallax.ts +0 -149
  52. package/src/pushpin.ts +0 -165
  53. package/src/range.ts +0 -198
  54. package/src/scrollspy.ts +0 -263
  55. package/src/select.ts +0 -484
  56. package/src/sidenav.ts +0 -543
  57. package/src/slider.ts +0 -474
  58. package/src/tabs.ts +0 -347
  59. package/src/tapTarget.ts +0 -273
  60. package/src/timepicker.ts +0 -832
  61. package/src/toasts.ts +0 -290
  62. package/src/tooltip.ts +0 -366
  63. package/src/utils.ts +0 -271
  64. package/src/waves.ts +0 -70
package/src/range.ts DELETED
@@ -1,198 +0,0 @@
1
- import anim from "animejs";
2
-
3
- import { Component, BaseOptions, InitElements, MElement } from "./component";
4
-
5
- export interface RangeOptions extends BaseOptions {};
6
-
7
- const _defaults: RangeOptions = {};
8
-
9
- // TODO: !!!!!
10
-
11
- export class Range extends Component<RangeOptions> {
12
- declare el: HTMLInputElement;
13
- private _mousedown: boolean;
14
- value: HTMLElement;
15
- thumb: HTMLElement;
16
-
17
- constructor(el: HTMLInputElement, options: Partial<RangeOptions>) {
18
- super(el, options, Range);
19
- (this.el as any).M_Range = this;
20
-
21
- this.options = {
22
- ...Range.defaults,
23
- ...options
24
- };
25
-
26
- this._mousedown = false;
27
- this._setupThumb();
28
- this._setupEventHandlers();
29
- }
30
-
31
- static get defaults(): RangeOptions {
32
- return _defaults;
33
- }
34
-
35
- /**
36
- * Initializes instance of Range.
37
- * @param el HTML element.
38
- * @param options Component options.
39
- */
40
- static init(el: HTMLInputElement, options?: Partial<RangeOptions>): Range;
41
- /**
42
- * Initializes instances of Range.
43
- * @param els HTML elements.
44
- * @param options Component options.
45
- */
46
- static init(els: InitElements<HTMLInputElement | MElement>, options?: Partial<RangeOptions>): Range[];
47
- /**
48
- * Initializes instances of Range.
49
- * @param els HTML elements.
50
- * @param options Component options.
51
- */
52
- static init(els: HTMLInputElement | InitElements<HTMLInputElement | MElement>, options: Partial<RangeOptions> = {}): Range | Range[] {
53
- return super.init(els, options, Range);
54
- }
55
-
56
- static getInstance(el: HTMLInputElement): Range {
57
- return (el as any).M_Range;
58
- }
59
-
60
- destroy() {
61
- this._removeEventHandlers();
62
- this._removeThumb();
63
- (this.el as any).M_Range = undefined;
64
- }
65
-
66
- _setupEventHandlers() {
67
- this.el.addEventListener('change', this._handleRangeChange);
68
- this.el.addEventListener('mousedown', this._handleRangeMousedownTouchstart);
69
- this.el.addEventListener('touchstart', this._handleRangeMousedownTouchstart);
70
- this.el.addEventListener('input', this._handleRangeInputMousemoveTouchmove);
71
- this.el.addEventListener('mousemove', this._handleRangeInputMousemoveTouchmove);
72
- this.el.addEventListener('touchmove', this._handleRangeInputMousemoveTouchmove);
73
- this.el.addEventListener('mouseup', this._handleRangeMouseupTouchend);
74
- this.el.addEventListener('touchend', this._handleRangeMouseupTouchend);
75
- this.el.addEventListener('blur', this._handleRangeBlurMouseoutTouchleave);
76
- this.el.addEventListener('mouseout', this._handleRangeBlurMouseoutTouchleave);
77
- this.el.addEventListener('touchleave', this._handleRangeBlurMouseoutTouchleave);
78
- }
79
-
80
- _removeEventHandlers() {
81
- this.el.removeEventListener('change', this._handleRangeChange);
82
- this.el.removeEventListener('mousedown', this._handleRangeMousedownTouchstart);
83
- this.el.removeEventListener('touchstart', this._handleRangeMousedownTouchstart);
84
- this.el.removeEventListener('input', this._handleRangeInputMousemoveTouchmove);
85
- this.el.removeEventListener('mousemove', this._handleRangeInputMousemoveTouchmove);
86
- this.el.removeEventListener('touchmove', this._handleRangeInputMousemoveTouchmove);
87
- this.el.removeEventListener('mouseup', this._handleRangeMouseupTouchend);
88
- this.el.removeEventListener('touchend', this._handleRangeMouseupTouchend);
89
- this.el.removeEventListener('blur', this._handleRangeBlurMouseoutTouchleave);
90
- this.el.removeEventListener('mouseout', this._handleRangeBlurMouseoutTouchleave);
91
- this.el.removeEventListener('touchleave', this._handleRangeBlurMouseoutTouchleave);
92
- }
93
-
94
- _handleRangeChange = () => {
95
- this.value.innerHTML = this.el.value;
96
- if (!this.thumb.classList.contains('active')) {
97
- this._showRangeBubble();
98
- }
99
- const offsetLeft = this._calcRangeOffset();
100
- this.thumb.classList.add('active');
101
- this.thumb.style.left = offsetLeft+'px';
102
- }
103
-
104
- _handleRangeMousedownTouchstart = (e: MouseEvent | TouchEvent) => {
105
- // Set indicator value
106
- this.value.innerHTML = this.el.value;
107
- this._mousedown = true;
108
- this.el.classList.add('active');
109
- if (!this.thumb.classList.contains('active')) {
110
- this._showRangeBubble();
111
- }
112
- if (e.type !== 'input') {
113
- const offsetLeft = this._calcRangeOffset();
114
- this.thumb.classList.add('active');
115
- this.thumb.style.left = offsetLeft+'px';
116
- }
117
- }
118
-
119
- _handleRangeInputMousemoveTouchmove = () => {
120
- if (this._mousedown) {
121
- if (!this.thumb.classList.contains('active')) {
122
- this._showRangeBubble();
123
- }
124
- const offsetLeft = this._calcRangeOffset();
125
- this.thumb.classList.add('active');
126
- this.thumb.style.left = offsetLeft+'px';
127
- this.value.innerHTML = this.el.value;
128
- }
129
- }
130
-
131
- _handleRangeMouseupTouchend = () => {
132
- this._mousedown = false;
133
- this.el.classList.remove('active');
134
- }
135
-
136
- _handleRangeBlurMouseoutTouchleave = () => {
137
- if (!this._mousedown) {
138
- const paddingLeft = parseInt(getComputedStyle(this.el).paddingLeft);
139
- const marginLeft = 7 + paddingLeft + 'px';
140
- if (this.thumb.classList.contains('active')) {
141
- anim.remove(this.thumb);
142
- anim({
143
- targets: this.thumb,
144
- height: 0,
145
- width: 0,
146
- top: 10,
147
- easing: 'easeOutQuad',
148
- marginLeft: marginLeft,
149
- duration: 100
150
- });
151
- }
152
- this.thumb.classList.remove('active');
153
- }
154
- }
155
-
156
- _setupThumb() {
157
- this.thumb = document.createElement('span');
158
- this.value = document.createElement('span');
159
- this.thumb.classList.add('thumb');
160
- this.value.classList.add('value');
161
- this.thumb.append(this.value);
162
- this.el.after(this.thumb);
163
- }
164
-
165
- _removeThumb() {
166
- this.thumb.remove();
167
- }
168
-
169
- _showRangeBubble() {
170
- const paddingLeft = parseInt(getComputedStyle(this.thumb.parentElement).paddingLeft);
171
- const marginLeft = -7 + paddingLeft + 'px'; // TODO: fix magic number?
172
- anim.remove(this.thumb);
173
- anim({
174
- targets: this.thumb,
175
- height: 30,
176
- width: 30,
177
- top: -30,
178
- marginLeft: marginLeft,
179
- duration: 300,
180
- easing: 'easeOutQuint'
181
- });
182
- }
183
-
184
- _calcRangeOffset(): number {
185
- const width = this.el.getBoundingClientRect().width - 15;
186
- const max = parseFloat(this.el.getAttribute('max')) || 100; // Range default max
187
- const min = parseFloat(this.el.getAttribute('min')) || 0; // Range default min
188
- const percent = (parseFloat(this.el.value) - min) / (max - min);
189
- return percent * width;
190
- }
191
-
192
- /**
193
- * Initializes every range input in the current document.
194
- */
195
- static Init(){
196
- Range.init((document.querySelectorAll('input[type=range]')) as NodeListOf<HTMLInputElement>, {});
197
- }
198
- }
package/src/scrollspy.ts DELETED
@@ -1,263 +0,0 @@
1
- import anim from "animejs";
2
-
3
- import { Utils } from "./utils";
4
- import { Component, BaseOptions, InitElements, MElement } from "./component";
5
-
6
- export interface ScrollSpyOptions extends BaseOptions {
7
- /**
8
- * Throttle of scroll handler.
9
- * @default 100
10
- */
11
- throttle: number;
12
- /**
13
- * Offset for centering element when scrolled to.
14
- * @default 200
15
- */
16
- scrollOffset: number;
17
- /**
18
- * Class applied to active elements.
19
- * @default 'active'
20
- */
21
- activeClass: string;
22
- /**
23
- * Used to find active element.
24
- * @default id => 'a[href="#' + id + '"]'
25
- */
26
- getActiveElement: (id: string) => string;
27
- };
28
-
29
- let _defaults: ScrollSpyOptions = {
30
- throttle: 100,
31
- scrollOffset: 200, // offset - 200 allows elements near bottom of page to scroll
32
- activeClass: 'active',
33
- getActiveElement: (id: string): string => { return 'a[href="#'+id+'"]'; }
34
- };
35
-
36
- export class ScrollSpy extends Component<ScrollSpyOptions> {
37
- static _elements: ScrollSpy[];
38
- static _count: number;
39
- static _increment: number;
40
- tickId: number;
41
- id: any;
42
- static _elementsInView: ScrollSpy[];
43
- static _visibleElements: any[];
44
- static _ticks: number;
45
-
46
- constructor(el: HTMLElement, options: Partial<ScrollSpyOptions>) {
47
- super(el, options, ScrollSpy);
48
- (this.el as any).M_ScrollSpy = this;
49
-
50
- this.options = {
51
- ...ScrollSpy.defaults,
52
- ...options
53
- };
54
-
55
- ScrollSpy._elements.push(this);
56
- ScrollSpy._count++;
57
- ScrollSpy._increment++;
58
- this.tickId = -1;
59
- this.id = ScrollSpy._increment;
60
- this._setupEventHandlers();
61
- this._handleWindowScroll();
62
- }
63
-
64
- static get defaults(): ScrollSpyOptions {
65
- return _defaults;
66
- }
67
-
68
- /**
69
- * Initializes instance of ScrollSpy.
70
- * @param el HTML element.
71
- * @param options Component options.
72
- */
73
- static init(el: HTMLElement, options?: Partial<ScrollSpyOptions>): ScrollSpy;
74
- /**
75
- * Initializes instances of ScrollSpy.
76
- * @param els HTML elements.
77
- * @param options Component options.
78
- */
79
- static init(els: InitElements<MElement>, options?: Partial<ScrollSpyOptions>): ScrollSpy[];
80
- /**
81
- * Initializes instances of ScrollSpy.
82
- * @param els HTML elements.
83
- * @param options Component options.
84
- */
85
- static init(els: HTMLElement | InitElements<MElement>, options: Partial<ScrollSpyOptions> = {}): ScrollSpy | ScrollSpy[] {
86
- return super.init(els, options, ScrollSpy);
87
- }
88
-
89
- static getInstance(el: HTMLElement): ScrollSpy {
90
- return (el as any).M_ScrollSpy;
91
- }
92
-
93
- destroy() {
94
- ScrollSpy._elements.splice(ScrollSpy._elements.indexOf(this), 1);
95
- ScrollSpy._elementsInView.splice(ScrollSpy._elementsInView.indexOf(this), 1);
96
- ScrollSpy._visibleElements.splice(ScrollSpy._visibleElements.indexOf(this.el), 1);
97
- ScrollSpy._count--;
98
- this._removeEventHandlers();
99
- const actElem = document.querySelector(this.options.getActiveElement(this.el.id));
100
- actElem.classList.remove(this.options.activeClass);
101
- (this.el as any).M_ScrollSpy = undefined;
102
- }
103
-
104
- _setupEventHandlers() {
105
- if (ScrollSpy._count === 1) {
106
- window.addEventListener('scroll', this._handleWindowScroll);
107
- window.addEventListener('resize', this._handleThrottledResize);
108
- document.body.addEventListener('click', this._handleTriggerClick);
109
- }
110
- }
111
-
112
- _removeEventHandlers() {
113
- if (ScrollSpy._count === 0) {
114
- window.removeEventListener('scroll', this._handleWindowScroll);
115
- window.removeEventListener('resize', this._handleThrottledResize);
116
- document.body.removeEventListener('click', this._handleTriggerClick);
117
- }
118
- }
119
-
120
- _handleThrottledResize: () => void = Utils.throttle(function(){ this._handleWindowScroll(); }, 200).bind(this);
121
-
122
- _handleTriggerClick = (e: MouseEvent) => {
123
- const trigger = e.target;
124
- for (let i = ScrollSpy._elements.length - 1; i >= 0; i--) {
125
- const scrollspy = ScrollSpy._elements[i];
126
-
127
- const x = document.querySelector('a[href="#'+scrollspy.el.id+'"]');
128
- if (trigger === x) {
129
- e.preventDefault();
130
- const offset = ScrollSpy._offset(scrollspy.el).top + 1;
131
-
132
- anim({
133
- targets: [document.documentElement, document.body],
134
- scrollTop: offset - scrollspy.options.scrollOffset,
135
- duration: 400,
136
- easing: 'easeOutCubic'
137
- });
138
-
139
- break;
140
- }
141
- }
142
- }
143
-
144
- _handleWindowScroll = () => {
145
- // unique tick id
146
- ScrollSpy._ticks++;
147
-
148
- // viewport rectangle
149
- let top = Utils.getDocumentScrollTop(),
150
- left = Utils.getDocumentScrollLeft(),
151
- right = left + window.innerWidth,
152
- bottom = top + window.innerHeight;
153
-
154
- // determine which elements are in view
155
- let intersections = ScrollSpy._findElements(top, right, bottom, left);
156
- for (let i = 0; i < intersections.length; i++) {
157
- let scrollspy = intersections[i];
158
- let lastTick = scrollspy.tickId;
159
- if (lastTick < 0) {
160
- // entered into view
161
- scrollspy._enter();
162
- }
163
-
164
- // update tick id
165
- scrollspy.tickId = ScrollSpy._ticks;
166
- }
167
-
168
- for (let i = 0; i < ScrollSpy._elementsInView.length; i++) {
169
- let scrollspy = ScrollSpy._elementsInView[i];
170
- let lastTick = scrollspy.tickId;
171
- if (lastTick >= 0 && lastTick !== ScrollSpy._ticks) {
172
- // exited from view
173
- scrollspy._exit();
174
- scrollspy.tickId = -1;
175
- }
176
- }
177
- // remember elements in view for next tick
178
- ScrollSpy._elementsInView = intersections;
179
- }
180
-
181
- static _offset(el) {
182
- const box = el.getBoundingClientRect();
183
- const docElem = document.documentElement;
184
- return {
185
- top: box.top + window.pageYOffset - docElem.clientTop,
186
- left: box.left + window.pageXOffset - docElem.clientLeft
187
- };
188
- }
189
-
190
- static _findElements(top: number, right: number, bottom: number, left: number): ScrollSpy[] {
191
- let hits = [];
192
- for (let i = 0; i < ScrollSpy._elements.length; i++) {
193
- let scrollspy = ScrollSpy._elements[i];
194
- let currTop = top + scrollspy.options.scrollOffset || 200;
195
-
196
- if (scrollspy.el.getBoundingClientRect().height > 0) {
197
- let elTop = ScrollSpy._offset(scrollspy.el).top,
198
- elLeft = ScrollSpy._offset(scrollspy.el).left,
199
- elRight = elLeft + scrollspy.el.getBoundingClientRect().width,
200
- elBottom = elTop + scrollspy.el.getBoundingClientRect().height;
201
-
202
- let isIntersect = !(
203
- elLeft > right ||
204
- elRight < left ||
205
- elTop > bottom ||
206
- elBottom < currTop
207
- );
208
-
209
- if (isIntersect) {
210
- hits.push(scrollspy);
211
- }
212
- }
213
- }
214
- return hits;
215
- }
216
-
217
- _enter() {
218
- ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(value => value.getBoundingClientRect().height !== 0);
219
-
220
- if (ScrollSpy._visibleElements[0]) {
221
- const actElem = document.querySelector(this.options.getActiveElement(ScrollSpy._visibleElements[0].id));
222
- actElem?.classList.remove(this.options.activeClass);
223
-
224
- if (ScrollSpy._visibleElements[0].M_ScrollSpy && this.id < ScrollSpy._visibleElements[0].M_ScrollSpy.id) {
225
- ScrollSpy._visibleElements.unshift(this.el);
226
- }
227
- else {
228
- ScrollSpy._visibleElements.push(this.el);
229
- }
230
- }
231
- else {
232
- ScrollSpy._visibleElements.push(this.el);
233
- }
234
- const selector = this.options.getActiveElement(ScrollSpy._visibleElements[0].id);
235
- document.querySelector(selector)?.classList.add(this.options.activeClass);
236
- }
237
-
238
- _exit() {
239
- ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(value => value.getBoundingClientRect().height !== 0);
240
-
241
- if (ScrollSpy._visibleElements[0]) {
242
- const actElem = document.querySelector(this.options.getActiveElement(ScrollSpy._visibleElements[0].id));
243
- actElem?.classList.remove(this.options.activeClass);
244
-
245
- ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter((x) => x.id != this.el.id);
246
-
247
- if (ScrollSpy._visibleElements[0]) {
248
- // Check if empty
249
- const selector = this.options.getActiveElement(ScrollSpy._visibleElements[0].id);
250
- document.querySelector(selector)?.classList.add(this.options.activeClass);
251
- }
252
- }
253
- }
254
-
255
- static {
256
- ScrollSpy._elements = [];
257
- ScrollSpy._elementsInView = [];
258
- ScrollSpy._visibleElements = []; // Array.<cash>
259
- ScrollSpy._count = 0;
260
- ScrollSpy._increment = 0;
261
- ScrollSpy._ticks = 0;
262
- }
263
- }