@materializecss/materialize 2.0.1-alpha → 2.0.3-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 (117) hide show
  1. package/Gruntfile.js +5 -2
  2. package/dist/css/materialize.css +1510 -288
  3. package/dist/css/materialize.min.css +2 -2
  4. package/dist/js/materialize.js +2782 -2688
  5. package/dist/js/materialize.min.js +2 -8967
  6. package/dist/js/materialize.min.js.map +1 -1
  7. package/dist/src/autocomplete.d.ts +143 -0
  8. package/dist/src/autocomplete.d.ts.map +1 -0
  9. package/dist/src/bounding.d.ts +7 -0
  10. package/dist/src/bounding.d.ts.map +1 -0
  11. package/dist/src/buttons.d.ts +65 -0
  12. package/dist/src/buttons.d.ts.map +1 -0
  13. package/dist/src/cards.d.ts +4 -0
  14. package/dist/src/cards.d.ts.map +1 -0
  15. package/dist/src/carousel.d.ts +131 -0
  16. package/dist/src/carousel.d.ts.map +1 -0
  17. package/dist/src/characterCounter.d.ts +37 -0
  18. package/dist/src/characterCounter.d.ts.map +1 -0
  19. package/dist/src/chips.d.ts +131 -0
  20. package/dist/src/chips.d.ts.map +1 -0
  21. package/dist/src/collapsible.d.ts +74 -0
  22. package/dist/src/collapsible.d.ts.map +1 -0
  23. package/dist/src/component.d.ts +74 -0
  24. package/dist/src/component.d.ts.map +1 -0
  25. package/dist/src/datepicker.d.ts +248 -0
  26. package/dist/src/datepicker.d.ts.map +1 -0
  27. package/dist/src/dropdown.d.ts +148 -0
  28. package/dist/src/dropdown.d.ts.map +1 -0
  29. package/dist/src/edges.d.ts +7 -0
  30. package/dist/src/edges.d.ts.map +1 -0
  31. package/dist/src/forms.d.ts +12 -0
  32. package/dist/src/forms.d.ts.map +1 -0
  33. package/dist/src/global.d.ts +60 -0
  34. package/dist/src/global.d.ts.map +1 -0
  35. package/dist/src/index.d.ts +27 -0
  36. package/dist/src/index.d.ts.map +1 -0
  37. package/dist/src/materialbox.d.ts +92 -0
  38. package/dist/src/materialbox.d.ts.map +1 -0
  39. package/dist/src/modal.d.ts +119 -0
  40. package/dist/src/modal.d.ts.map +1 -0
  41. package/dist/src/parallax.d.ts +40 -0
  42. package/dist/src/parallax.d.ts.map +1 -0
  43. package/dist/src/pushpin.d.ts +52 -0
  44. package/dist/src/pushpin.d.ts.map +1 -0
  45. package/dist/src/range.d.ts +41 -0
  46. package/dist/src/range.d.ts.map +1 -0
  47. package/dist/src/scrollspy.d.ts +62 -0
  48. package/dist/src/scrollspy.d.ts.map +1 -0
  49. package/dist/src/select.d.ts +77 -0
  50. package/dist/src/select.d.ts.map +1 -0
  51. package/dist/src/sidenav.d.ts +122 -0
  52. package/dist/src/sidenav.d.ts.map +1 -0
  53. package/dist/src/slider.d.ts +103 -0
  54. package/dist/src/slider.d.ts.map +1 -0
  55. package/dist/src/tabs.d.ts +80 -0
  56. package/dist/src/tabs.d.ts.map +1 -0
  57. package/dist/src/tapTarget.d.ts +59 -0
  58. package/dist/src/tapTarget.d.ts.map +1 -0
  59. package/dist/src/timepicker.d.ts +208 -0
  60. package/dist/src/timepicker.d.ts.map +1 -0
  61. package/dist/src/toasts.d.ts +90 -0
  62. package/dist/src/toasts.d.ts.map +1 -0
  63. package/dist/src/tooltip.d.ts +112 -0
  64. package/dist/src/tooltip.d.ts.map +1 -0
  65. package/dist/src/utils.d.ts +97 -0
  66. package/dist/src/utils.d.ts.map +1 -0
  67. package/dist/src/waves.d.ts +16 -0
  68. package/dist/src/waves.d.ts.map +1 -0
  69. package/package.json +4 -1
  70. package/sass/components/_cards.scss +1 -1
  71. package/sass/components/_collapsible.scss +0 -41
  72. package/sass/components/_global.scss +53 -2
  73. package/sass/components/_grid.scss +28 -47
  74. package/sass/components/_icons-material-design.scss +2 -1
  75. package/sass/components/_navbar.scss +30 -27
  76. package/sass/components/_pulse.scss +1 -0
  77. package/sass/components/_sidenav.scss +63 -45
  78. package/sass/components/_theme_variables.scss +29 -49
  79. package/sass/components/_typography.scss +2 -2
  80. package/sass/components/_variables.scss +2 -0
  81. package/sass/components/colors.module.scss +180 -0
  82. package/sass/components/forms/_input-fields.scss +4 -10
  83. package/sass/components/theme.dark.module.scss +32 -0
  84. package/sass/components/theme.light.module.scss +32 -0
  85. package/sass/components/tokens.module.scss +272 -0
  86. package/sass/components/typography.module.scss +150 -0
  87. package/sass/materialize.scss +6 -4
  88. package/src/autocomplete.ts +188 -94
  89. package/src/buttons.ts +225 -260
  90. package/src/cards.ts +5 -6
  91. package/src/carousel.ts +611 -542
  92. package/src/characterCounter.ts +50 -21
  93. package/src/chips.ts +152 -63
  94. package/src/collapsible.ts +97 -32
  95. package/src/component.ts +99 -10
  96. package/src/datepicker.ts +905 -726
  97. package/src/dropdown.ts +573 -484
  98. package/src/edges.ts +4 -4
  99. package/src/forms.ts +36 -24
  100. package/src/global.ts +57 -328
  101. package/src/index.ts +26 -0
  102. package/src/materialbox.ts +354 -298
  103. package/src/modal.ts +296 -211
  104. package/src/parallax.ts +129 -105
  105. package/src/pushpin.ts +148 -103
  106. package/src/range.ts +166 -150
  107. package/src/scrollspy.ts +214 -174
  108. package/src/select.ts +434 -398
  109. package/src/sidenav.ts +447 -381
  110. package/src/slider.ts +421 -362
  111. package/src/tabs.ts +276 -222
  112. package/src/tapTarget.ts +246 -213
  113. package/src/timepicker.ts +738 -614
  114. package/src/toasts.ts +254 -230
  115. package/src/tooltip.ts +315 -252
  116. package/src/utils.ts +271 -0
  117. 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 class Component {
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
- constructor(classDef, protected el: Element, protected options) {
5
- // Display error if el is valid HTML Element
6
- if (!(el instanceof Element)) {
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
- static init(classDef, els, options) {
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 && (els.jquery || els.cash || els instanceof NodeList || els instanceof HTMLCollection)) {
23
- let instancesArr = [];
94
+ else if (!!els && els.length) {
95
+ instances = [];
24
96
  for (let i = 0; i < els.length; i++) {
25
- instancesArr.push(new classDef(els[i], options));
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
  }