@materializecss/materialize 2.0.3-alpha → 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.
- package/README.md +1 -1
- package/dist/css/materialize.css +345 -236
- package/dist/css/materialize.min.css +2 -2
- package/dist/js/materialize.js +518 -1979
- package/dist/js/materialize.min.js +2 -2
- package/dist/js/materialize.min.js.map +1 -1
- package/dist/src/buttons.d.ts.map +1 -1
- package/dist/src/cards.d.ts.map +1 -1
- package/dist/src/collapsible.d.ts +1 -0
- package/dist/src/collapsible.d.ts.map +1 -1
- package/dist/src/dropdown.d.ts.map +1 -1
- package/dist/src/global.d.ts.map +1 -1
- package/dist/src/materialbox.d.ts +14 -10
- package/dist/src/materialbox.d.ts.map +1 -1
- package/dist/src/modal.d.ts.map +1 -1
- package/dist/src/range.d.ts.map +1 -1
- package/dist/src/scrollspy.d.ts.map +1 -1
- package/dist/src/sidenav.d.ts +25 -25
- package/dist/src/sidenav.d.ts.map +1 -1
- package/dist/src/slider.d.ts +12 -12
- package/dist/src/slider.d.ts.map +1 -1
- package/dist/src/tabs.d.ts +1 -1
- package/dist/src/tabs.d.ts.map +1 -1
- package/dist/src/toasts.d.ts +7 -2
- package/dist/src/toasts.d.ts.map +1 -1
- package/dist/src/tooltip.d.ts +8 -2
- package/dist/src/tooltip.d.ts.map +1 -1
- package/package.json +14 -13
- package/sass/components/_buttons.scss +158 -73
- package/sass/components/_chips.scss +75 -28
- package/sass/components/_collapsible.scss +14 -2
- package/sass/components/_global.scss +6 -94
- package/sass/components/_materialbox.scss +2 -2
- package/sass/components/_modal.scss +0 -1
- package/sass/components/_preloader.scss +85 -0
- package/sass/components/_tooltip.scss +18 -8
- package/sass/components/_variables.scss +5 -4
- package/sass/components/forms/_range.scss +1 -1
- package/sass/components/forms/_switches.scss +44 -14
- package/Gruntfile.js +0 -480
- package/src/autocomplete.ts +0 -553
- package/src/bounding.ts +0 -6
- package/src/buttons.ts +0 -260
- package/src/cards.ts +0 -53
- package/src/carousel.ts +0 -676
- package/src/characterCounter.ts +0 -117
- package/src/chips.ts +0 -439
- package/src/collapsible.ts +0 -249
- package/src/component.ts +0 -120
- package/src/datepicker.ts +0 -1076
- package/src/dropdown.ts +0 -644
- package/src/edges.ts +0 -6
- package/src/forms.ts +0 -132
- package/src/global.ts +0 -114
- package/src/index.ts +0 -26
- package/src/materialbox.ts +0 -404
- package/src/modal.ts +0 -341
- package/src/parallax.ts +0 -149
- package/src/pushpin.ts +0 -165
- package/src/range.ts +0 -198
- package/src/scrollspy.ts +0 -263
- package/src/select.ts +0 -484
- package/src/sidenav.ts +0 -543
- package/src/slider.ts +0 -474
- package/src/tabs.ts +0 -347
- package/src/tapTarget.ts +0 -273
- package/src/timepicker.ts +0 -832
- package/src/toasts.ts +0 -290
- package/src/tooltip.ts +0 -346
- package/src/utils.ts +0 -271
- package/src/waves.ts +0 -70
package/src/utils.ts
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import { Edges } from './edges';
|
|
2
|
-
import { Bounding } from './bounding';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Class with utilitary functions for global usage.
|
|
6
|
-
*/
|
|
7
|
-
export class Utils {
|
|
8
|
-
/** Specifies wether tab is pressed or not. */
|
|
9
|
-
static tabPressed: boolean = false;
|
|
10
|
-
/** Specifies wether there is a key pressed. */
|
|
11
|
-
static keyDown: boolean = false;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Key maps.
|
|
15
|
-
*/
|
|
16
|
-
static keys = {
|
|
17
|
-
TAB: ['Tab'],
|
|
18
|
-
ENTER: ['Enter'],
|
|
19
|
-
ESC: ['Escape', 'Esc'],
|
|
20
|
-
BACKSPACE: ['Backspace'],
|
|
21
|
-
ARROW_UP: ['ArrowUp', 'Up'],
|
|
22
|
-
ARROW_DOWN: ['ArrowDown', 'Down'],
|
|
23
|
-
ARROW_LEFT: ['ArrowLeft', 'Left'],
|
|
24
|
-
ARROW_RIGHT: ['ArrowRight', 'Right'],
|
|
25
|
-
DELETE: ['Delete', 'Del'],
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Detects when a key is pressed.
|
|
30
|
-
* @param e Event instance.
|
|
31
|
-
*/
|
|
32
|
-
static docHandleKeydown(e: KeyboardEvent) {
|
|
33
|
-
Utils.keyDown = true;
|
|
34
|
-
if ([...Utils.keys.TAB, ...Utils.keys.ARROW_DOWN, ...Utils.keys.ARROW_UP].includes(e.key)) {
|
|
35
|
-
Utils.tabPressed = true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Detects when a key is released.
|
|
41
|
-
* @param e Event instance.
|
|
42
|
-
*/
|
|
43
|
-
static docHandleKeyup(e: KeyboardEvent) {
|
|
44
|
-
Utils.keyDown = false;
|
|
45
|
-
if ([...Utils.keys.TAB, ...Utils.keys.ARROW_DOWN, ...Utils.keys.ARROW_UP].includes(e.key)) {
|
|
46
|
-
Utils.tabPressed = false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Detects when document is focused.
|
|
52
|
-
* @param e Event instance.
|
|
53
|
-
*/
|
|
54
|
-
static docHandleFocus(e: FocusEvent) {
|
|
55
|
-
if (Utils.keyDown) {
|
|
56
|
-
document.body.classList.add('keyboard-focused');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Detects when document is not focused.
|
|
62
|
-
* @param e Event instance.
|
|
63
|
-
*/
|
|
64
|
-
static docHandleBlur(e: FocusEvent) {
|
|
65
|
-
document.body.classList.remove('keyboard-focused');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Generates a unique string identifier.
|
|
70
|
-
*/
|
|
71
|
-
static guid(): string {
|
|
72
|
-
const s4 = (): string => {
|
|
73
|
-
return Math.floor((1 + Math.random()) * 0x10000)
|
|
74
|
-
.toString(16)
|
|
75
|
-
.substring(1);
|
|
76
|
-
}
|
|
77
|
-
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Checks for exceeded edges
|
|
82
|
-
* @param container Container element.
|
|
83
|
-
* @param bounding Bounding rect.
|
|
84
|
-
* @param offset Element offset.
|
|
85
|
-
*/
|
|
86
|
-
static checkWithinContainer(container: HTMLElement, bounding: Bounding, offset: number): Edges {
|
|
87
|
-
let edges = {
|
|
88
|
-
top: false,
|
|
89
|
-
right: false,
|
|
90
|
-
bottom: false,
|
|
91
|
-
left: false
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
let containerRect = container.getBoundingClientRect();
|
|
95
|
-
// If body element is smaller than viewport, use viewport height instead.
|
|
96
|
-
let containerBottom =
|
|
97
|
-
container === document.body
|
|
98
|
-
? Math.max(containerRect.bottom, window.innerHeight)
|
|
99
|
-
: containerRect.bottom;
|
|
100
|
-
|
|
101
|
-
let scrollLeft = container.scrollLeft;
|
|
102
|
-
let scrollTop = container.scrollTop;
|
|
103
|
-
|
|
104
|
-
let scrolledX = bounding.left - scrollLeft;
|
|
105
|
-
let scrolledY = bounding.top - scrollTop;
|
|
106
|
-
|
|
107
|
-
// Check for container and viewport for each edge
|
|
108
|
-
if (scrolledX < containerRect.left + offset || scrolledX < offset) {
|
|
109
|
-
edges.left = true;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
scrolledX + bounding.width > containerRect.right - offset ||
|
|
114
|
-
scrolledX + bounding.width > window.innerWidth - offset
|
|
115
|
-
) {
|
|
116
|
-
edges.right = true;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (scrolledY < containerRect.top + offset || scrolledY < offset) {
|
|
120
|
-
edges.top = true;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (
|
|
124
|
-
scrolledY + bounding.height > containerBottom - offset ||
|
|
125
|
-
scrolledY + bounding.height > window.innerHeight - offset
|
|
126
|
-
) {
|
|
127
|
-
edges.bottom = true;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return edges;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Checks if element can be aligned in multiple directions.
|
|
135
|
-
* @param el Element to be inspected.
|
|
136
|
-
* @param container Container element.
|
|
137
|
-
* @param bounding Bounding rect.
|
|
138
|
-
* @param offset Element offset.
|
|
139
|
-
*/
|
|
140
|
-
static checkPossibleAlignments(el: HTMLElement, container: HTMLElement, bounding: Bounding, offset: number) {
|
|
141
|
-
let canAlign: {
|
|
142
|
-
top: boolean,
|
|
143
|
-
right: boolean,
|
|
144
|
-
bottom: boolean,
|
|
145
|
-
left: boolean,
|
|
146
|
-
spaceOnTop: number,
|
|
147
|
-
spaceOnRight: number,
|
|
148
|
-
spaceOnBottom: number
|
|
149
|
-
spaceOnLeft: number
|
|
150
|
-
} = {
|
|
151
|
-
top: true,
|
|
152
|
-
right: true,
|
|
153
|
-
bottom: true,
|
|
154
|
-
left: true,
|
|
155
|
-
spaceOnTop: null,
|
|
156
|
-
spaceOnRight: null,
|
|
157
|
-
spaceOnBottom: null,
|
|
158
|
-
spaceOnLeft: null
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
let containerAllowsOverflow = getComputedStyle(container).overflow === 'visible';
|
|
162
|
-
let containerRect = container.getBoundingClientRect();
|
|
163
|
-
let containerHeight = Math.min(containerRect.height, window.innerHeight);
|
|
164
|
-
let containerWidth = Math.min(containerRect.width, window.innerWidth);
|
|
165
|
-
let elOffsetRect = el.getBoundingClientRect();
|
|
166
|
-
|
|
167
|
-
let scrollLeft = container.scrollLeft;
|
|
168
|
-
let scrollTop = container.scrollTop;
|
|
169
|
-
|
|
170
|
-
let scrolledX = bounding.left - scrollLeft;
|
|
171
|
-
let scrolledYTopEdge = bounding.top - scrollTop;
|
|
172
|
-
let scrolledYBottomEdge = bounding.top + elOffsetRect.height - scrollTop;
|
|
173
|
-
|
|
174
|
-
// Check for container and viewport for left
|
|
175
|
-
canAlign.spaceOnRight = !containerAllowsOverflow
|
|
176
|
-
? containerWidth - (scrolledX + bounding.width)
|
|
177
|
-
: window.innerWidth - (elOffsetRect.left + bounding.width);
|
|
178
|
-
if (canAlign.spaceOnRight < 0) {
|
|
179
|
-
canAlign.left = false;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Check for container and viewport for Right
|
|
183
|
-
canAlign.spaceOnLeft = !containerAllowsOverflow
|
|
184
|
-
? scrolledX - bounding.width + elOffsetRect.width
|
|
185
|
-
: elOffsetRect.right - bounding.width;
|
|
186
|
-
if (canAlign.spaceOnLeft < 0) {
|
|
187
|
-
canAlign.right = false;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Check for container and viewport for Top
|
|
191
|
-
canAlign.spaceOnBottom = !containerAllowsOverflow
|
|
192
|
-
? containerHeight - (scrolledYTopEdge + bounding.height + offset)
|
|
193
|
-
: window.innerHeight - (elOffsetRect.top + bounding.height + offset);
|
|
194
|
-
if (canAlign.spaceOnBottom < 0) {
|
|
195
|
-
canAlign.top = false;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Check for container and viewport for Bottom
|
|
199
|
-
canAlign.spaceOnTop = !containerAllowsOverflow
|
|
200
|
-
? scrolledYBottomEdge - (bounding.height - offset)
|
|
201
|
-
: elOffsetRect.bottom - (bounding.height + offset);
|
|
202
|
-
if (canAlign.spaceOnTop < 0) {
|
|
203
|
-
canAlign.bottom = false;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return canAlign;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Retrieves target element id from trigger.
|
|
211
|
-
* @param trigger Trigger element.
|
|
212
|
-
*/
|
|
213
|
-
static getIdFromTrigger(trigger: HTMLElement): string {
|
|
214
|
-
let id = trigger.dataset.target;
|
|
215
|
-
if (!id) {
|
|
216
|
-
id = trigger.getAttribute('href');
|
|
217
|
-
return id ? id.slice(1) : '';
|
|
218
|
-
}
|
|
219
|
-
return id;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Retrieves document scroll postion from top.
|
|
224
|
-
*/
|
|
225
|
-
static getDocumentScrollTop(): number {
|
|
226
|
-
return window.scrollY || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Retrieves document scroll postion from left.
|
|
231
|
-
*/
|
|
232
|
-
static getDocumentScrollLeft(): number {
|
|
233
|
-
return window.scrollX || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Fires the given function after a certain ammount of time.
|
|
238
|
-
* @param func Function to be fired.
|
|
239
|
-
* @param wait Wait time.
|
|
240
|
-
* @param options Additional options.
|
|
241
|
-
*/
|
|
242
|
-
public static throttle(func: Function, wait: number, options: Partial<{leading:boolean,trailing:boolean}> = null) {
|
|
243
|
-
let context: object, args: IArguments, result: any;
|
|
244
|
-
let timeout = null;
|
|
245
|
-
let previous = 0;
|
|
246
|
-
options || (options = {});
|
|
247
|
-
let later = function() {
|
|
248
|
-
previous = options.leading === false ? 0 : new Date().getTime();
|
|
249
|
-
timeout = null;
|
|
250
|
-
result = func.apply(context, args);
|
|
251
|
-
context = args = null;
|
|
252
|
-
};
|
|
253
|
-
return function() {
|
|
254
|
-
let now = new Date().getTime();
|
|
255
|
-
if (!previous && options.leading === false) previous = now;
|
|
256
|
-
let remaining = wait - (now - previous);
|
|
257
|
-
context = this;
|
|
258
|
-
args = arguments;
|
|
259
|
-
if (remaining <= 0) {
|
|
260
|
-
clearTimeout(timeout);
|
|
261
|
-
timeout = null;
|
|
262
|
-
previous = now;
|
|
263
|
-
result = func.apply(context, args);
|
|
264
|
-
context = args = null;
|
|
265
|
-
} else if (!timeout && options.trailing !== false) {
|
|
266
|
-
timeout = setTimeout(later, remaining);
|
|
267
|
-
}
|
|
268
|
-
return result;
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
}
|
package/src/waves.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
type RGBColor = {
|
|
2
|
-
r: number,
|
|
3
|
-
g: number,
|
|
4
|
-
b: number,
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
type Position = {
|
|
8
|
-
x: number,
|
|
9
|
-
y: number,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class Waves {
|
|
13
|
-
|
|
14
|
-
private static _offset(el: HTMLElement) {
|
|
15
|
-
const box = el.getBoundingClientRect();
|
|
16
|
-
const docElem = document.documentElement;
|
|
17
|
-
return {
|
|
18
|
-
top: box.top + window.pageYOffset - docElem.clientTop,
|
|
19
|
-
left: box.left + window.pageXOffset - docElem.clientLeft
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// https://phoenix-dx.com/css-techniques-for-material-ripple-effect/
|
|
24
|
-
|
|
25
|
-
public static renderWaveEffect(targetElement: HTMLElement, position: Position|null = null, color: RGBColor|null = null): void {
|
|
26
|
-
const isCentered = position === null;
|
|
27
|
-
const duration = 500;
|
|
28
|
-
let animationFrame: number, animationStart: number;
|
|
29
|
-
const animationStep = function(timestamp: number) {
|
|
30
|
-
if (!animationStart) {
|
|
31
|
-
animationStart = timestamp;
|
|
32
|
-
}
|
|
33
|
-
const frame = timestamp - animationStart;
|
|
34
|
-
if (frame < duration) {
|
|
35
|
-
const easing = (frame/duration) * (2 - (frame/duration));
|
|
36
|
-
const circle = isCentered ? 'circle at 50% 50%' : `circle at ${position.x}px ${position.y}px`;
|
|
37
|
-
const waveColor = `rgba(${color?.r || 0}, ${color?.g || 0}, ${color?.b || 0}, ${ 0.3 * (1-easing) })`;
|
|
38
|
-
const stop = 90 * easing + "%";
|
|
39
|
-
targetElement.style.backgroundImage = "radial-gradient("+circle+", "+waveColor+" "+stop+", transparent "+stop+")";
|
|
40
|
-
animationFrame = window.requestAnimationFrame(animationStep);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
targetElement.style.backgroundImage = 'none';
|
|
44
|
-
window.cancelAnimationFrame(animationFrame);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
animationFrame = window.requestAnimationFrame(animationStep);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
static Init() {
|
|
51
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
52
|
-
document.body.addEventListener('click', e => {
|
|
53
|
-
const trigger = <HTMLElement>e.target;
|
|
54
|
-
const el = <HTMLElement>trigger.closest('.waves-effect');
|
|
55
|
-
if (el && el.contains(trigger)) {
|
|
56
|
-
const isCircular = el.classList.contains('waves-circle');
|
|
57
|
-
const x = e.pageX - Waves._offset(el).left;
|
|
58
|
-
const y = e.pageY - Waves._offset(el).top;
|
|
59
|
-
|
|
60
|
-
let color = null;
|
|
61
|
-
if (el.classList.contains('waves-light'))
|
|
62
|
-
color = {r:255, g:255, b:255};
|
|
63
|
-
|
|
64
|
-
Waves.renderWaveEffect(el, isCircular ? null : {x, y}, color);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
}
|