@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.
- package/Gruntfile.js +5 -2
- package/dist/css/materialize.css +90 -86
- package/dist/css/materialize.min.css +2 -2
- package/dist/js/materialize.js +2797 -2705
- package/dist/js/materialize.min.js +2 -8967
- package/dist/js/materialize.min.js.map +1 -1
- package/package.json +1 -1
- package/sass/components/_collapsible.scss +0 -41
- package/sass/components/_global.scss +3 -2
- package/sass/components/_icons-material-design.scss +2 -1
- package/sass/components/_navbar.scss +6 -3
- package/sass/components/_sidenav.scss +66 -37
- package/sass/components/_theme_variables.scss +2 -2
- package/sass/components/_typography.scss +2 -2
- package/sass/components/forms/_input-fields.scss +4 -10
- package/sass/materialize.scss +0 -4
- package/src/autocomplete.ts +188 -94
- package/src/buttons.ts +225 -260
- package/src/cards.ts +5 -6
- package/src/carousel.ts +611 -542
- package/src/characterCounter.ts +50 -21
- package/src/chips.ts +152 -63
- package/src/collapsible.ts +97 -32
- package/src/component.ts +99 -10
- package/src/datepicker.ts +905 -726
- package/src/dropdown.ts +576 -484
- package/src/edges.ts +4 -4
- package/src/forms.ts +17 -14
- package/src/global.ts +55 -324
- package/src/materialbox.ts +354 -298
- package/src/modal.ts +296 -211
- package/src/parallax.ts +129 -105
- package/src/pushpin.ts +148 -103
- package/src/range.ts +166 -150
- package/src/scrollspy.ts +214 -174
- package/src/select.ts +434 -398
- package/src/sidenav.ts +447 -381
- package/src/slider.ts +421 -362
- package/src/tabs.ts +276 -222
- package/src/tapTarget.ts +246 -213
- package/src/timepicker.ts +738 -614
- package/src/toasts.ts +254 -230
- package/src/tooltip.ts +315 -252
- package/src/utils.ts +271 -0
- package/src/waves.ts +10 -10
package/src/component.ts
CHANGED
|
@@ -1,9 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base options for component initialization.
|
|
3
|
+
*/
|
|
4
|
+
export interface BaseOptions {};
|
|
1
5
|
|
|
2
|
-
export
|
|
6
|
+
export type MElement = HTMLElement | Element;
|
|
7
|
+
export type InitElements<T extends MElement> = NodeListOf<T> | HTMLCollectionOf<T>;
|
|
8
|
+
type ComponentConstructor<T extends Component<O>, O extends BaseOptions> = {
|
|
9
|
+
new (el: HTMLElement, options: Partial<O>): T
|
|
10
|
+
};
|
|
11
|
+
type ComponentType<C extends Component<O>, O extends BaseOptions> = ComponentConstructor<C, O> & typeof Component<O>;
|
|
3
12
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
13
|
+
export interface I18nOptions {
|
|
14
|
+
cancel: string;
|
|
15
|
+
clear: string;
|
|
16
|
+
done: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Openable {
|
|
20
|
+
isOpen: boolean;
|
|
21
|
+
open(): void;
|
|
22
|
+
close(): void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Base class implementation for Materialize components.
|
|
27
|
+
*/
|
|
28
|
+
export class Component<O extends BaseOptions>{
|
|
29
|
+
/**
|
|
30
|
+
* The DOM element the plugin was initialized with.
|
|
31
|
+
*/
|
|
32
|
+
el: HTMLElement;
|
|
33
|
+
/**
|
|
34
|
+
* The options the instance was initialized with.
|
|
35
|
+
*/
|
|
36
|
+
options: O;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Constructs component instance and set everything up.
|
|
40
|
+
*/
|
|
41
|
+
constructor(el: HTMLElement, options: Partial<O>, classDef: ComponentType<Component<O>, O>){
|
|
42
|
+
// Display error if el is not a valid HTML Element
|
|
43
|
+
if (!(el instanceof HTMLElement)) {
|
|
7
44
|
console.error(Error(el + ' is not an HTML Element'));
|
|
8
45
|
}
|
|
9
46
|
// If exists, destroy and reinitialize in child
|
|
@@ -14,18 +51,70 @@ export class Component {
|
|
|
14
51
|
this.el = el;
|
|
15
52
|
}
|
|
16
53
|
|
|
17
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Initializes component instance.
|
|
56
|
+
* @param el HTML element.
|
|
57
|
+
* @param options Component options.
|
|
58
|
+
* @param classDef Class definition.
|
|
59
|
+
*/
|
|
60
|
+
protected static init<
|
|
61
|
+
I extends HTMLElement, O extends BaseOptions, C extends Component<O>
|
|
62
|
+
>(el: I, options: O, classDef: ComponentType<C, O>): C;
|
|
63
|
+
/**
|
|
64
|
+
* Initializes component instances.
|
|
65
|
+
* @param els HTML elements.
|
|
66
|
+
* @param options Component options.
|
|
67
|
+
* @param classDef Class definition.
|
|
68
|
+
*/
|
|
69
|
+
protected static init<
|
|
70
|
+
I extends MElement, O extends BaseOptions, C extends Component<O>
|
|
71
|
+
>(els: InitElements<I>, options: Partial<O>, classDef: ComponentType<C, O>): C[];
|
|
72
|
+
/**
|
|
73
|
+
* Initializes component instances.
|
|
74
|
+
* @param els HTML elements.
|
|
75
|
+
* @param options Component options.
|
|
76
|
+
* @param classDef Class definition.
|
|
77
|
+
*/
|
|
78
|
+
protected static init<
|
|
79
|
+
I extends MElement, O extends BaseOptions, C extends Component<O>
|
|
80
|
+
>(els: I | InitElements<I>, options: Partial<O>, classDef: ComponentType<C, O>): C | C[];
|
|
81
|
+
/**
|
|
82
|
+
* Initializes component instances.
|
|
83
|
+
* @param els HTML elements.
|
|
84
|
+
* @param options Component options.
|
|
85
|
+
* @param classDef Class definition.
|
|
86
|
+
*/
|
|
87
|
+
protected static init<
|
|
88
|
+
I extends MElement, O extends BaseOptions, C extends Component<O>
|
|
89
|
+
>(els: I | InitElements<I>, options: Partial<O>, classDef: ComponentType<C, O>): C | C[] {
|
|
18
90
|
let instances = null;
|
|
19
91
|
if (els instanceof Element) {
|
|
20
|
-
instances = new classDef(els, options);
|
|
92
|
+
instances = new classDef(<HTMLElement>els, options);
|
|
21
93
|
}
|
|
22
|
-
else if (!!els &&
|
|
23
|
-
|
|
94
|
+
else if (!!els && els.length) {
|
|
95
|
+
instances = [];
|
|
24
96
|
for (let i = 0; i < els.length; i++) {
|
|
25
|
-
|
|
97
|
+
instances.push(new classDef(<HTMLElement>els[i], options));
|
|
26
98
|
}
|
|
27
|
-
instances = instancesArr;
|
|
28
99
|
}
|
|
29
100
|
return instances;
|
|
30
101
|
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @returns default options for component instance.
|
|
105
|
+
*/
|
|
106
|
+
static get defaults(): BaseOptions{ return {}; }
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Retrieves component instance for the given element.
|
|
110
|
+
* @param el Associated HTML Element.
|
|
111
|
+
*/
|
|
112
|
+
static getInstance(el: HTMLElement): Component<BaseOptions> {
|
|
113
|
+
throw new Error("This method must be implemented.");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Destroy plugin instance and teardown.
|
|
118
|
+
*/
|
|
119
|
+
destroy(): void { throw new Error("This method must be implemented."); }
|
|
31
120
|
}
|