@limetech/lime-elements 37.1.0-next.44 → 37.1.0-next.46

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 (139) hide show
  1. package/dist/cjs/{component-66df95e7.js → component-9c3fa668.js} +12 -935
  2. package/dist/cjs/component-9c3fa668.js.map +1 -0
  3. package/dist/cjs/component-a0124759.js +929 -0
  4. package/dist/cjs/component-a0124759.js.map +1 -0
  5. package/dist/cjs/lime-elements.cjs.js +1 -1
  6. package/dist/cjs/limel-callout.cjs.entry.js +1 -1
  7. package/dist/cjs/limel-chip-set.cjs.entry.js +1 -1
  8. package/dist/cjs/limel-code-editor.cjs.entry.js +189 -0
  9. package/dist/cjs/limel-code-editor.cjs.entry.js.map +1 -1
  10. package/dist/cjs/limel-file-viewer.cjs.entry.js +260 -0
  11. package/dist/cjs/limel-file-viewer.cjs.entry.js.map +1 -0
  12. package/dist/cjs/limel-file.cjs.entry.js +1 -1
  13. package/dist/cjs/limel-flatpickr-adapter.cjs.entry.js +1 -1
  14. package/dist/cjs/limel-icon-button.cjs.entry.js +8 -1
  15. package/dist/cjs/limel-icon-button.cjs.entry.js.map +1 -1
  16. package/dist/cjs/{limel-list_2.cjs.entry.js → limel-list.cjs.entry.js} +2 -122
  17. package/dist/cjs/limel-list.cjs.entry.js.map +1 -0
  18. package/dist/cjs/limel-menu-surface.cjs.entry.js +130 -0
  19. package/dist/cjs/limel-menu-surface.cjs.entry.js.map +1 -0
  20. package/dist/cjs/limel-menu_2.cjs.entry.js +14 -13
  21. package/dist/cjs/limel-menu_2.cjs.entry.js.map +1 -1
  22. package/dist/cjs/limel-snackbar.cjs.entry.js +1 -1
  23. package/dist/cjs/loader.cjs.js +1 -1
  24. package/dist/cjs/{translations-f8080c48.js → translations-a384b596.js} +37 -1
  25. package/dist/cjs/translations-a384b596.js.map +1 -0
  26. package/dist/collection/collection-manifest.json +1 -0
  27. package/dist/collection/components/code-editor/code-editor.js +2 -3
  28. package/dist/collection/components/code-editor/code-editor.js.map +1 -1
  29. package/dist/collection/components/code-editor/code-editor.types.js.map +1 -1
  30. package/dist/collection/components/file-viewer/extension-mapping.js +66 -0
  31. package/dist/collection/components/file-viewer/extension-mapping.js.map +1 -0
  32. package/dist/collection/components/file-viewer/file-viewer.css +266 -0
  33. package/dist/collection/components/file-viewer/file-viewer.js +387 -0
  34. package/dist/collection/components/file-viewer/file-viewer.js.map +1 -0
  35. package/dist/collection/components/file-viewer/file-viewer.types.js +2 -0
  36. package/dist/collection/components/file-viewer/file-viewer.types.js.map +1 -0
  37. package/dist/collection/components/file-viewer/fullscreen.js +43 -0
  38. package/dist/collection/components/file-viewer/fullscreen.js.map +1 -0
  39. package/dist/collection/components/icon-button/icon-button.js +8 -1
  40. package/dist/collection/components/icon-button/icon-button.js.map +1 -1
  41. package/dist/collection/index.js.map +1 -1
  42. package/dist/collection/translations/da.js +6 -0
  43. package/dist/collection/translations/da.js.map +1 -1
  44. package/dist/collection/translations/en.js +6 -0
  45. package/dist/collection/translations/en.js.map +1 -1
  46. package/dist/collection/translations/fi.js +6 -0
  47. package/dist/collection/translations/fi.js.map +1 -1
  48. package/dist/collection/translations/nl.js +6 -0
  49. package/dist/collection/translations/nl.js.map +1 -1
  50. package/dist/collection/translations/no.js +6 -0
  51. package/dist/collection/translations/no.js.map +1 -1
  52. package/dist/collection/translations/sv.js +6 -0
  53. package/dist/collection/translations/sv.js.map +1 -1
  54. package/dist/esm/{component-fffa3419.js → component-0be247ac.js} +13 -934
  55. package/dist/esm/component-0be247ac.js.map +1 -0
  56. package/dist/esm/component-6d079abe.js +926 -0
  57. package/dist/esm/component-6d079abe.js.map +1 -0
  58. package/dist/esm/lime-elements.js +1 -1
  59. package/dist/esm/limel-callout.entry.js +1 -1
  60. package/dist/esm/limel-chip-set.entry.js +1 -1
  61. package/dist/esm/limel-code-editor.entry.js +189 -0
  62. package/dist/esm/limel-code-editor.entry.js.map +1 -1
  63. package/dist/esm/limel-file-viewer.entry.js +256 -0
  64. package/dist/esm/limel-file-viewer.entry.js.map +1 -0
  65. package/dist/esm/limel-file.entry.js +1 -1
  66. package/dist/esm/limel-flatpickr-adapter.entry.js +1 -1
  67. package/dist/esm/limel-icon-button.entry.js +8 -1
  68. package/dist/esm/limel-icon-button.entry.js.map +1 -1
  69. package/dist/esm/{limel-list_2.entry.js → limel-list.entry.js} +3 -122
  70. package/dist/esm/limel-list.entry.js.map +1 -0
  71. package/dist/esm/limel-menu-surface.entry.js +126 -0
  72. package/dist/esm/limel-menu-surface.entry.js.map +1 -0
  73. package/dist/esm/limel-menu_2.entry.js +2 -1
  74. package/dist/esm/limel-menu_2.entry.js.map +1 -1
  75. package/dist/esm/limel-snackbar.entry.js +1 -1
  76. package/dist/esm/loader.js +1 -1
  77. package/dist/esm/{translations-f88bb584.js → translations-dea847ae.js} +37 -1
  78. package/dist/esm/translations-dea847ae.js.map +1 -0
  79. package/dist/lime-elements/lime-elements.esm.js +1 -1
  80. package/dist/lime-elements/lime-elements.esm.js.map +1 -1
  81. package/dist/lime-elements/p-3ee3dcdc.js +2 -0
  82. package/dist/lime-elements/p-3ee3dcdc.js.map +1 -0
  83. package/dist/lime-elements/p-45449868.entry.js +2 -0
  84. package/dist/lime-elements/p-45449868.entry.js.map +1 -0
  85. package/dist/lime-elements/{p-550cae4a.entry.js → p-4c100bed.entry.js} +2 -2
  86. package/dist/lime-elements/p-5dd6d677.js +82 -0
  87. package/dist/lime-elements/p-5dd6d677.js.map +1 -0
  88. package/dist/lime-elements/p-685e5867.entry.js +2 -0
  89. package/dist/lime-elements/p-685e5867.entry.js.map +1 -0
  90. package/dist/lime-elements/p-6fa8bf86.entry.js +2 -0
  91. package/dist/lime-elements/p-6fa8bf86.entry.js.map +1 -0
  92. package/dist/lime-elements/{p-9a5745e5.entry.js → p-6fac3a11.entry.js} +2 -2
  93. package/dist/lime-elements/{p-c9aee7a1.entry.js → p-80f0c441.entry.js} +2 -2
  94. package/dist/lime-elements/{p-cf61ac34.entry.js → p-8eff47a6.entry.js} +2 -2
  95. package/dist/lime-elements/p-9eab9eb2.entry.js +2 -0
  96. package/dist/lime-elements/p-9eab9eb2.entry.js.map +1 -0
  97. package/dist/lime-elements/p-b8deba1b.entry.js +2 -0
  98. package/dist/lime-elements/p-b8deba1b.entry.js.map +1 -0
  99. package/dist/lime-elements/{p-7972528a.entry.js → p-dbcae3a0.entry.js} +2 -2
  100. package/dist/lime-elements/p-e3b16b61.js +126 -0
  101. package/dist/lime-elements/p-e3b16b61.js.map +1 -0
  102. package/dist/lime-elements/{p-2d0587d5.entry.js → p-fed820d9.entry.js} +4 -4
  103. package/dist/lime-elements/{p-2d0587d5.entry.js.map → p-fed820d9.entry.js.map} +1 -1
  104. package/dist/types/components/code-editor/code-editor.d.ts +1 -2
  105. package/dist/types/components/code-editor/code-editor.types.d.ts +1 -1
  106. package/dist/types/components/file-viewer/extension-mapping.d.ts +1 -0
  107. package/dist/types/components/file-viewer/file-viewer.types.d.ts +2 -0
  108. package/dist/types/components/file-viewer/fullscreen.d.ts +9 -0
  109. package/dist/types/components/icon-button/icon-button.d.ts +1 -0
  110. package/dist/types/components.d.ts +209 -20
  111. package/dist/types/index.d.ts +1 -1
  112. package/dist/types/translations/da.d.ts +6 -0
  113. package/dist/types/translations/en.d.ts +6 -0
  114. package/dist/types/translations/fi.d.ts +6 -0
  115. package/dist/types/translations/nl.d.ts +6 -0
  116. package/dist/types/translations/no.d.ts +6 -0
  117. package/dist/types/translations/sv.d.ts +6 -0
  118. package/package.json +2 -2
  119. package/dist/cjs/component-66df95e7.js.map +0 -1
  120. package/dist/cjs/limel-list_2.cjs.entry.js.map +0 -1
  121. package/dist/cjs/translations-f8080c48.js.map +0 -1
  122. package/dist/esm/component-fffa3419.js.map +0 -1
  123. package/dist/esm/limel-list_2.entry.js.map +0 -1
  124. package/dist/esm/translations-f88bb584.js.map +0 -1
  125. package/dist/lime-elements/p-172385f4.entry.js +0 -2
  126. package/dist/lime-elements/p-172385f4.entry.js.map +0 -1
  127. package/dist/lime-elements/p-22031b5b.entry.js +0 -2
  128. package/dist/lime-elements/p-22031b5b.entry.js.map +0 -1
  129. package/dist/lime-elements/p-94cb40fb.entry.js +0 -2
  130. package/dist/lime-elements/p-94cb40fb.entry.js.map +0 -1
  131. package/dist/lime-elements/p-b59e4287.js +0 -2
  132. package/dist/lime-elements/p-b59e4287.js.map +0 -1
  133. package/dist/lime-elements/p-dfba92de.js +0 -206
  134. package/dist/lime-elements/p-dfba92de.js.map +0 -1
  135. /package/dist/lime-elements/{p-550cae4a.entry.js.map → p-4c100bed.entry.js.map} +0 -0
  136. /package/dist/lime-elements/{p-9a5745e5.entry.js.map → p-6fac3a11.entry.js.map} +0 -0
  137. /package/dist/lime-elements/{p-c9aee7a1.entry.js.map → p-80f0c441.entry.js.map} +0 -0
  138. /package/dist/lime-elements/{p-cf61ac34.entry.js.map → p-8eff47a6.entry.js.map} +0 -0
  139. /package/dist/lime-elements/{p-7972528a.entry.js.map → p-dbcae3a0.entry.js.map} +0 -0
@@ -0,0 +1,929 @@
1
+ 'use strict';
2
+
3
+ const component = require('./component-67144c1c.js');
4
+ const util = require('./util-b0f5741e.js');
5
+
6
+ /**
7
+ * @license
8
+ * Copyright 2018 Google Inc.
9
+ *
10
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ * of this software and associated documentation files (the "Software"), to deal
12
+ * in the Software without restriction, including without limitation the rights
13
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ * copies of the Software, and to permit persons to whom the Software is
15
+ * furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in
18
+ * all copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
+ * THE SOFTWARE.
27
+ */
28
+ var cssClasses = {
29
+ ANCHOR: 'mdc-menu-surface--anchor',
30
+ ANIMATING_CLOSED: 'mdc-menu-surface--animating-closed',
31
+ ANIMATING_OPEN: 'mdc-menu-surface--animating-open',
32
+ FIXED: 'mdc-menu-surface--fixed',
33
+ IS_OPEN_BELOW: 'mdc-menu-surface--is-open-below',
34
+ OPEN: 'mdc-menu-surface--open',
35
+ ROOT: 'mdc-menu-surface',
36
+ };
37
+ // tslint:disable:object-literal-sort-keys
38
+ var strings = {
39
+ CLOSED_EVENT: 'MDCMenuSurface:closed',
40
+ CLOSING_EVENT: 'MDCMenuSurface:closing',
41
+ OPENED_EVENT: 'MDCMenuSurface:opened',
42
+ FOCUSABLE_ELEMENTS: [
43
+ 'button:not(:disabled)',
44
+ '[href]:not([aria-disabled="true"])',
45
+ 'input:not(:disabled)',
46
+ 'select:not(:disabled)',
47
+ 'textarea:not(:disabled)',
48
+ '[tabindex]:not([tabindex="-1"]):not([aria-disabled="true"])',
49
+ ].join(', '),
50
+ };
51
+ // tslint:enable:object-literal-sort-keys
52
+ var numbers = {
53
+ /** Total duration of menu-surface open animation. */
54
+ TRANSITION_OPEN_DURATION: 120,
55
+ /** Total duration of menu-surface close animation. */
56
+ TRANSITION_CLOSE_DURATION: 75,
57
+ /**
58
+ * Margin left to the edge of the viewport when menu-surface is at maximum
59
+ * possible height. Also used as a viewport margin.
60
+ */
61
+ MARGIN_TO_EDGE: 32,
62
+ /**
63
+ * Ratio of anchor width to menu-surface width for switching from corner
64
+ * positioning to center positioning.
65
+ */
66
+ ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: 0.67,
67
+ /**
68
+ * Amount of time to wait before restoring focus when closing the menu
69
+ * surface. This is important because if a touch event triggered the menu
70
+ * close, and the subsequent mouse event occurs after focus is restored, then
71
+ * the restored focus would be lost.
72
+ */
73
+ TOUCH_EVENT_WAIT_MS: 30,
74
+ };
75
+ /**
76
+ * Enum for bits in the {@see Corner) bitmap.
77
+ */
78
+ var CornerBit;
79
+ (function (CornerBit) {
80
+ CornerBit[CornerBit["BOTTOM"] = 1] = "BOTTOM";
81
+ CornerBit[CornerBit["CENTER"] = 2] = "CENTER";
82
+ CornerBit[CornerBit["RIGHT"] = 4] = "RIGHT";
83
+ CornerBit[CornerBit["FLIP_RTL"] = 8] = "FLIP_RTL";
84
+ })(CornerBit || (CornerBit = {}));
85
+ /**
86
+ * Enum for representing an element corner for positioning the menu-surface.
87
+ *
88
+ * The START constants map to LEFT if element directionality is left
89
+ * to right and RIGHT if the directionality is right to left.
90
+ * Likewise END maps to RIGHT or LEFT depending on the directionality.
91
+ */
92
+ exports.Corner = void 0;
93
+ (function (Corner) {
94
+ Corner[Corner["TOP_LEFT"] = 0] = "TOP_LEFT";
95
+ Corner[Corner["TOP_RIGHT"] = 4] = "TOP_RIGHT";
96
+ Corner[Corner["BOTTOM_LEFT"] = 1] = "BOTTOM_LEFT";
97
+ Corner[Corner["BOTTOM_RIGHT"] = 5] = "BOTTOM_RIGHT";
98
+ Corner[Corner["TOP_START"] = 8] = "TOP_START";
99
+ Corner[Corner["TOP_END"] = 12] = "TOP_END";
100
+ Corner[Corner["BOTTOM_START"] = 9] = "BOTTOM_START";
101
+ Corner[Corner["BOTTOM_END"] = 13] = "BOTTOM_END";
102
+ })(exports.Corner || (exports.Corner = {}));
103
+
104
+ /*! *****************************************************************************
105
+ Copyright (c) Microsoft Corporation.
106
+
107
+ Permission to use, copy, modify, and/or distribute this software for any
108
+ purpose with or without fee is hereby granted.
109
+
110
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
111
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
112
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
113
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
114
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
115
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
116
+ PERFORMANCE OF THIS SOFTWARE.
117
+ ***************************************************************************** */
118
+ /* global Reflect, Promise */
119
+
120
+ var extendStatics = function(d, b) {
121
+ extendStatics = Object.setPrototypeOf ||
122
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
123
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
124
+ return extendStatics(d, b);
125
+ };
126
+
127
+ function __extends(d, b) {
128
+ if (typeof b !== "function" && b !== null)
129
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
130
+ extendStatics(d, b);
131
+ function __() { this.constructor = d; }
132
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
133
+ }
134
+
135
+ var __assign = function() {
136
+ __assign = Object.assign || function __assign(t) {
137
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
138
+ s = arguments[i];
139
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
140
+ }
141
+ return t;
142
+ };
143
+ return __assign.apply(this, arguments);
144
+ };
145
+
146
+ function __values(o) {
147
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
148
+ if (m) return m.call(o);
149
+ if (o && typeof o.length === "number") return {
150
+ next: function () {
151
+ if (o && i >= o.length) o = void 0;
152
+ return { value: o && o[i++], done: !o };
153
+ }
154
+ };
155
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
156
+ }
157
+
158
+ /**
159
+ * @license
160
+ * Copyright 2018 Google Inc.
161
+ *
162
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
163
+ * of this software and associated documentation files (the "Software"), to deal
164
+ * in the Software without restriction, including without limitation the rights
165
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
166
+ * copies of the Software, and to permit persons to whom the Software is
167
+ * furnished to do so, subject to the following conditions:
168
+ *
169
+ * The above copyright notice and this permission notice shall be included in
170
+ * all copies or substantial portions of the Software.
171
+ *
172
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
173
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
174
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
175
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
176
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
177
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
178
+ * THE SOFTWARE.
179
+ */
180
+ var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
181
+ __extends(MDCMenuSurfaceFoundation, _super);
182
+ function MDCMenuSurfaceFoundation(adapter) {
183
+ var _this = _super.call(this, __assign(__assign({}, MDCMenuSurfaceFoundation.defaultAdapter), adapter)) || this;
184
+ _this.isSurfaceOpen = false;
185
+ _this.isQuickOpen = false;
186
+ _this.isHoistedElement = false;
187
+ _this.isFixedPosition = false;
188
+ _this.isHorizontallyCenteredOnViewport = false;
189
+ _this.maxHeight = 0;
190
+ _this.openAnimationEndTimerId = 0;
191
+ _this.closeAnimationEndTimerId = 0;
192
+ _this.animationRequestId = 0;
193
+ _this.anchorCorner = exports.Corner.TOP_START;
194
+ /**
195
+ * Corner of the menu surface to which menu surface is attached to anchor.
196
+ *
197
+ * Anchor corner --->+----------+
198
+ * | ANCHOR |
199
+ * +----------+
200
+ * Origin corner --->+--------------+
201
+ * | |
202
+ * | |
203
+ * | MENU SURFACE |
204
+ * | |
205
+ * | |
206
+ * +--------------+
207
+ */
208
+ _this.originCorner = exports.Corner.TOP_START;
209
+ _this.anchorMargin = { top: 0, right: 0, bottom: 0, left: 0 };
210
+ _this.position = { x: 0, y: 0 };
211
+ return _this;
212
+ }
213
+ Object.defineProperty(MDCMenuSurfaceFoundation, "cssClasses", {
214
+ get: function () {
215
+ return cssClasses;
216
+ },
217
+ enumerable: false,
218
+ configurable: true
219
+ });
220
+ Object.defineProperty(MDCMenuSurfaceFoundation, "strings", {
221
+ get: function () {
222
+ return strings;
223
+ },
224
+ enumerable: false,
225
+ configurable: true
226
+ });
227
+ Object.defineProperty(MDCMenuSurfaceFoundation, "numbers", {
228
+ get: function () {
229
+ return numbers;
230
+ },
231
+ enumerable: false,
232
+ configurable: true
233
+ });
234
+ Object.defineProperty(MDCMenuSurfaceFoundation, "Corner", {
235
+ get: function () {
236
+ return exports.Corner;
237
+ },
238
+ enumerable: false,
239
+ configurable: true
240
+ });
241
+ Object.defineProperty(MDCMenuSurfaceFoundation, "defaultAdapter", {
242
+ /**
243
+ * @see {@link MDCMenuSurfaceAdapter} for typing information on parameters and return types.
244
+ */
245
+ get: function () {
246
+ // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
247
+ return {
248
+ addClass: function () { return undefined; },
249
+ removeClass: function () { return undefined; },
250
+ hasClass: function () { return false; },
251
+ hasAnchor: function () { return false; },
252
+ isElementInContainer: function () { return false; },
253
+ isFocused: function () { return false; },
254
+ isRtl: function () { return false; },
255
+ getInnerDimensions: function () { return ({ height: 0, width: 0 }); },
256
+ getAnchorDimensions: function () { return null; },
257
+ getWindowDimensions: function () { return ({ height: 0, width: 0 }); },
258
+ getBodyDimensions: function () { return ({ height: 0, width: 0 }); },
259
+ getWindowScroll: function () { return ({ x: 0, y: 0 }); },
260
+ setPosition: function () { return undefined; },
261
+ setMaxHeight: function () { return undefined; },
262
+ setTransformOrigin: function () { return undefined; },
263
+ saveFocus: function () { return undefined; },
264
+ restoreFocus: function () { return undefined; },
265
+ notifyClose: function () { return undefined; },
266
+ notifyOpen: function () { return undefined; },
267
+ notifyClosing: function () { return undefined; },
268
+ };
269
+ // tslint:enable:object-literal-sort-keys
270
+ },
271
+ enumerable: false,
272
+ configurable: true
273
+ });
274
+ MDCMenuSurfaceFoundation.prototype.init = function () {
275
+ var _a = MDCMenuSurfaceFoundation.cssClasses, ROOT = _a.ROOT, OPEN = _a.OPEN;
276
+ if (!this.adapter.hasClass(ROOT)) {
277
+ throw new Error(ROOT + " class required in root element.");
278
+ }
279
+ if (this.adapter.hasClass(OPEN)) {
280
+ this.isSurfaceOpen = true;
281
+ }
282
+ };
283
+ MDCMenuSurfaceFoundation.prototype.destroy = function () {
284
+ clearTimeout(this.openAnimationEndTimerId);
285
+ clearTimeout(this.closeAnimationEndTimerId);
286
+ // Cancel any currently running animations.
287
+ cancelAnimationFrame(this.animationRequestId);
288
+ };
289
+ /**
290
+ * @param corner Default anchor corner alignment of top-left menu surface
291
+ * corner.
292
+ */
293
+ MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function (corner) {
294
+ this.anchorCorner = corner;
295
+ };
296
+ /**
297
+ * Flip menu corner horizontally.
298
+ */
299
+ MDCMenuSurfaceFoundation.prototype.flipCornerHorizontally = function () {
300
+ this.originCorner = this.originCorner ^ CornerBit.RIGHT;
301
+ };
302
+ /**
303
+ * @param margin Set of margin values from anchor.
304
+ */
305
+ MDCMenuSurfaceFoundation.prototype.setAnchorMargin = function (margin) {
306
+ this.anchorMargin.top = margin.top || 0;
307
+ this.anchorMargin.right = margin.right || 0;
308
+ this.anchorMargin.bottom = margin.bottom || 0;
309
+ this.anchorMargin.left = margin.left || 0;
310
+ };
311
+ /** Used to indicate if the menu-surface is hoisted to the body. */
312
+ MDCMenuSurfaceFoundation.prototype.setIsHoisted = function (isHoisted) {
313
+ this.isHoistedElement = isHoisted;
314
+ };
315
+ /**
316
+ * Used to set the menu-surface calculations based on a fixed position menu.
317
+ */
318
+ MDCMenuSurfaceFoundation.prototype.setFixedPosition = function (isFixedPosition) {
319
+ this.isFixedPosition = isFixedPosition;
320
+ };
321
+ /**
322
+ * @return Returns true if menu is in fixed (`position: fixed`) position.
323
+ */
324
+ MDCMenuSurfaceFoundation.prototype.isFixed = function () {
325
+ return this.isFixedPosition;
326
+ };
327
+ /** Sets the menu-surface position on the page. */
328
+ MDCMenuSurfaceFoundation.prototype.setAbsolutePosition = function (x, y) {
329
+ this.position.x = this.isFinite(x) ? x : 0;
330
+ this.position.y = this.isFinite(y) ? y : 0;
331
+ };
332
+ /** Sets whether menu-surface should be horizontally centered to viewport. */
333
+ MDCMenuSurfaceFoundation.prototype.setIsHorizontallyCenteredOnViewport = function (isCentered) {
334
+ this.isHorizontallyCenteredOnViewport = isCentered;
335
+ };
336
+ MDCMenuSurfaceFoundation.prototype.setQuickOpen = function (quickOpen) {
337
+ this.isQuickOpen = quickOpen;
338
+ };
339
+ /**
340
+ * Sets maximum menu-surface height on open.
341
+ * @param maxHeight The desired max-height. Set to 0 (default) to
342
+ * automatically calculate max height based on available viewport space.
343
+ */
344
+ MDCMenuSurfaceFoundation.prototype.setMaxHeight = function (maxHeight) {
345
+ this.maxHeight = maxHeight;
346
+ };
347
+ MDCMenuSurfaceFoundation.prototype.isOpen = function () {
348
+ return this.isSurfaceOpen;
349
+ };
350
+ /**
351
+ * Open the menu surface.
352
+ */
353
+ MDCMenuSurfaceFoundation.prototype.open = function () {
354
+ var _this = this;
355
+ if (this.isSurfaceOpen) {
356
+ return;
357
+ }
358
+ this.adapter.saveFocus();
359
+ if (this.isQuickOpen) {
360
+ this.isSurfaceOpen = true;
361
+ this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
362
+ this.dimensions = this.adapter.getInnerDimensions();
363
+ this.autoposition();
364
+ this.adapter.notifyOpen();
365
+ }
366
+ else {
367
+ this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
368
+ this.animationRequestId = requestAnimationFrame(function () {
369
+ _this.dimensions = _this.adapter.getInnerDimensions();
370
+ _this.autoposition();
371
+ _this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
372
+ _this.openAnimationEndTimerId = setTimeout(function () {
373
+ _this.openAnimationEndTimerId = 0;
374
+ _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
375
+ _this.adapter.notifyOpen();
376
+ }, numbers.TRANSITION_OPEN_DURATION);
377
+ });
378
+ this.isSurfaceOpen = true;
379
+ }
380
+ };
381
+ /**
382
+ * Closes the menu surface.
383
+ */
384
+ MDCMenuSurfaceFoundation.prototype.close = function (skipRestoreFocus) {
385
+ var _this = this;
386
+ if (skipRestoreFocus === void 0) { skipRestoreFocus = false; }
387
+ if (!this.isSurfaceOpen) {
388
+ return;
389
+ }
390
+ this.adapter.notifyClosing();
391
+ if (this.isQuickOpen) {
392
+ this.isSurfaceOpen = false;
393
+ if (!skipRestoreFocus) {
394
+ this.maybeRestoreFocus();
395
+ }
396
+ this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
397
+ this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
398
+ this.adapter.notifyClose();
399
+ return;
400
+ }
401
+ this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
402
+ requestAnimationFrame(function () {
403
+ _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
404
+ _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
405
+ _this.closeAnimationEndTimerId = setTimeout(function () {
406
+ _this.closeAnimationEndTimerId = 0;
407
+ _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
408
+ _this.adapter.notifyClose();
409
+ }, numbers.TRANSITION_CLOSE_DURATION);
410
+ });
411
+ this.isSurfaceOpen = false;
412
+ if (!skipRestoreFocus) {
413
+ this.maybeRestoreFocus();
414
+ }
415
+ };
416
+ /** Handle clicks and close if not within menu-surface element. */
417
+ MDCMenuSurfaceFoundation.prototype.handleBodyClick = function (evt) {
418
+ var el = evt.target;
419
+ if (this.adapter.isElementInContainer(el)) {
420
+ return;
421
+ }
422
+ this.close();
423
+ };
424
+ /** Handle keys that close the surface. */
425
+ MDCMenuSurfaceFoundation.prototype.handleKeydown = function (evt) {
426
+ var keyCode = evt.keyCode, key = evt.key;
427
+ var isEscape = key === 'Escape' || keyCode === 27;
428
+ if (isEscape) {
429
+ this.close();
430
+ }
431
+ };
432
+ MDCMenuSurfaceFoundation.prototype.autoposition = function () {
433
+ var _a;
434
+ // Compute measurements for autoposition methods reuse.
435
+ this.measurements = this.getAutoLayoutmeasurements();
436
+ var corner = this.getoriginCorner();
437
+ var maxMenuSurfaceHeight = this.getMenuSurfaceMaxHeight(corner);
438
+ var verticalAlignment = this.hasBit(corner, CornerBit.BOTTOM) ? 'bottom' : 'top';
439
+ var horizontalAlignment = this.hasBit(corner, CornerBit.RIGHT) ? 'right' : 'left';
440
+ var horizontalOffset = this.getHorizontalOriginOffset(corner);
441
+ var verticalOffset = this.getVerticalOriginOffset(corner);
442
+ var _b = this.measurements, anchorSize = _b.anchorSize, surfaceSize = _b.surfaceSize;
443
+ var position = (_a = {},
444
+ _a[horizontalAlignment] = horizontalOffset,
445
+ _a[verticalAlignment] = verticalOffset,
446
+ _a);
447
+ // Center align when anchor width is comparable or greater than menu
448
+ // surface, otherwise keep corner.
449
+ if (anchorSize.width / surfaceSize.width >
450
+ numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) {
451
+ horizontalAlignment = 'center';
452
+ }
453
+ // If the menu-surface has been hoisted to the body, it's no longer relative
454
+ // to the anchor element
455
+ if (this.isHoistedElement || this.isFixedPosition) {
456
+ this.adjustPositionForHoistedElement(position);
457
+ }
458
+ this.adapter.setTransformOrigin(horizontalAlignment + " " + verticalAlignment);
459
+ this.adapter.setPosition(position);
460
+ this.adapter.setMaxHeight(maxMenuSurfaceHeight ? maxMenuSurfaceHeight + 'px' : '');
461
+ // If it is opened from the top then add is-open-below class
462
+ if (!this.hasBit(corner, CornerBit.BOTTOM)) {
463
+ this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
464
+ }
465
+ };
466
+ /**
467
+ * @return Measurements used to position menu surface popup.
468
+ */
469
+ MDCMenuSurfaceFoundation.prototype.getAutoLayoutmeasurements = function () {
470
+ var anchorRect = this.adapter.getAnchorDimensions();
471
+ var bodySize = this.adapter.getBodyDimensions();
472
+ var viewportSize = this.adapter.getWindowDimensions();
473
+ var windowScroll = this.adapter.getWindowScroll();
474
+ if (!anchorRect) {
475
+ // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
476
+ anchorRect = {
477
+ top: this.position.y,
478
+ right: this.position.x,
479
+ bottom: this.position.y,
480
+ left: this.position.x,
481
+ width: 0,
482
+ height: 0,
483
+ };
484
+ // tslint:enable:object-literal-sort-keys
485
+ }
486
+ return {
487
+ anchorSize: anchorRect,
488
+ bodySize: bodySize,
489
+ surfaceSize: this.dimensions,
490
+ viewportDistance: {
491
+ // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
492
+ top: anchorRect.top,
493
+ right: viewportSize.width - anchorRect.right,
494
+ bottom: viewportSize.height - anchorRect.bottom,
495
+ left: anchorRect.left,
496
+ // tslint:enable:object-literal-sort-keys
497
+ },
498
+ viewportSize: viewportSize,
499
+ windowScroll: windowScroll,
500
+ };
501
+ };
502
+ /**
503
+ * Computes the corner of the anchor from which to animate and position the
504
+ * menu surface.
505
+ *
506
+ * Only LEFT or RIGHT bit is used to position the menu surface ignoring RTL
507
+ * context. E.g., menu surface will be positioned from right side on TOP_END.
508
+ */
509
+ MDCMenuSurfaceFoundation.prototype.getoriginCorner = function () {
510
+ var corner = this.originCorner;
511
+ var _a = this.measurements, viewportDistance = _a.viewportDistance, anchorSize = _a.anchorSize, surfaceSize = _a.surfaceSize;
512
+ var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
513
+ var isAnchoredToBottom = this.hasBit(this.anchorCorner, CornerBit.BOTTOM);
514
+ var availableTop;
515
+ var availableBottom;
516
+ if (isAnchoredToBottom) {
517
+ availableTop =
518
+ viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.bottom;
519
+ availableBottom =
520
+ viewportDistance.bottom - MARGIN_TO_EDGE - this.anchorMargin.bottom;
521
+ }
522
+ else {
523
+ availableTop =
524
+ viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.top;
525
+ availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE +
526
+ anchorSize.height - this.anchorMargin.top;
527
+ }
528
+ var isAvailableBottom = availableBottom - surfaceSize.height > 0;
529
+ if (!isAvailableBottom && availableTop > availableBottom) {
530
+ // Attach bottom side of surface to the anchor.
531
+ corner = this.setBit(corner, CornerBit.BOTTOM);
532
+ }
533
+ var isRtl = this.adapter.isRtl();
534
+ var isFlipRtl = this.hasBit(this.anchorCorner, CornerBit.FLIP_RTL);
535
+ var hasRightBit = this.hasBit(this.anchorCorner, CornerBit.RIGHT) ||
536
+ this.hasBit(corner, CornerBit.RIGHT);
537
+ // Whether surface attached to right side of anchor element.
538
+ var isAnchoredToRight = false;
539
+ // Anchored to start
540
+ if (isRtl && isFlipRtl) {
541
+ isAnchoredToRight = !hasRightBit;
542
+ }
543
+ else {
544
+ // Anchored to right
545
+ isAnchoredToRight = hasRightBit;
546
+ }
547
+ var availableLeft;
548
+ var availableRight;
549
+ if (isAnchoredToRight) {
550
+ availableLeft =
551
+ viewportDistance.left + anchorSize.width + this.anchorMargin.right;
552
+ availableRight = viewportDistance.right - this.anchorMargin.right;
553
+ }
554
+ else {
555
+ availableLeft = viewportDistance.left + this.anchorMargin.left;
556
+ availableRight =
557
+ viewportDistance.right + anchorSize.width - this.anchorMargin.left;
558
+ }
559
+ var isAvailableLeft = availableLeft - surfaceSize.width > 0;
560
+ var isAvailableRight = availableRight - surfaceSize.width > 0;
561
+ var isOriginCornerAlignedToEnd = this.hasBit(corner, CornerBit.FLIP_RTL) &&
562
+ this.hasBit(corner, CornerBit.RIGHT);
563
+ if (isAvailableRight && isOriginCornerAlignedToEnd && isRtl ||
564
+ !isAvailableLeft && isOriginCornerAlignedToEnd) {
565
+ // Attach left side of surface to the anchor.
566
+ corner = this.unsetBit(corner, CornerBit.RIGHT);
567
+ }
568
+ else if (isAvailableLeft && isAnchoredToRight && isRtl ||
569
+ (isAvailableLeft && !isAnchoredToRight && hasRightBit) ||
570
+ (!isAvailableRight && availableLeft >= availableRight)) {
571
+ // Attach right side of surface to the anchor.
572
+ corner = this.setBit(corner, CornerBit.RIGHT);
573
+ }
574
+ return corner;
575
+ };
576
+ /**
577
+ * @param corner Origin corner of the menu surface.
578
+ * @return Maximum height of the menu surface, based on available space. 0
579
+ * indicates should not be set.
580
+ */
581
+ MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight = function (corner) {
582
+ if (this.maxHeight > 0) {
583
+ return this.maxHeight;
584
+ }
585
+ var viewportDistance = this.measurements.viewportDistance;
586
+ var maxHeight = 0;
587
+ var isBottomAligned = this.hasBit(corner, CornerBit.BOTTOM);
588
+ var isBottomAnchored = this.hasBit(this.anchorCorner, CornerBit.BOTTOM);
589
+ var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
590
+ // When maximum height is not specified, it is handled from CSS.
591
+ if (isBottomAligned) {
592
+ maxHeight = viewportDistance.top + this.anchorMargin.top - MARGIN_TO_EDGE;
593
+ if (!isBottomAnchored) {
594
+ maxHeight += this.measurements.anchorSize.height;
595
+ }
596
+ }
597
+ else {
598
+ maxHeight = viewportDistance.bottom - this.anchorMargin.bottom +
599
+ this.measurements.anchorSize.height - MARGIN_TO_EDGE;
600
+ if (isBottomAnchored) {
601
+ maxHeight -= this.measurements.anchorSize.height;
602
+ }
603
+ }
604
+ return maxHeight;
605
+ };
606
+ /**
607
+ * @param corner Origin corner of the menu surface.
608
+ * @return Horizontal offset of menu surface origin corner from corresponding
609
+ * anchor corner.
610
+ */
611
+ MDCMenuSurfaceFoundation.prototype.getHorizontalOriginOffset = function (corner) {
612
+ var anchorSize = this.measurements.anchorSize;
613
+ // isRightAligned corresponds to using the 'right' property on the surface.
614
+ var isRightAligned = this.hasBit(corner, CornerBit.RIGHT);
615
+ var avoidHorizontalOverlap = this.hasBit(this.anchorCorner, CornerBit.RIGHT);
616
+ if (isRightAligned) {
617
+ var rightOffset = avoidHorizontalOverlap ?
618
+ anchorSize.width - this.anchorMargin.left :
619
+ this.anchorMargin.right;
620
+ // For hoisted or fixed elements, adjust the offset by the difference
621
+ // between viewport width and body width so when we calculate the right
622
+ // value (`adjustPositionForHoistedElement`) based on the element
623
+ // position, the right property is correct.
624
+ if (this.isHoistedElement || this.isFixedPosition) {
625
+ return rightOffset -
626
+ (this.measurements.viewportSize.width -
627
+ this.measurements.bodySize.width);
628
+ }
629
+ return rightOffset;
630
+ }
631
+ return avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.right :
632
+ this.anchorMargin.left;
633
+ };
634
+ /**
635
+ * @param corner Origin corner of the menu surface.
636
+ * @return Vertical offset of menu surface origin corner from corresponding
637
+ * anchor corner.
638
+ */
639
+ MDCMenuSurfaceFoundation.prototype.getVerticalOriginOffset = function (corner) {
640
+ var anchorSize = this.measurements.anchorSize;
641
+ var isBottomAligned = this.hasBit(corner, CornerBit.BOTTOM);
642
+ var avoidVerticalOverlap = this.hasBit(this.anchorCorner, CornerBit.BOTTOM);
643
+ var y = 0;
644
+ if (isBottomAligned) {
645
+ y = avoidVerticalOverlap ? anchorSize.height - this.anchorMargin.top :
646
+ -this.anchorMargin.bottom;
647
+ }
648
+ else {
649
+ y = avoidVerticalOverlap ?
650
+ (anchorSize.height + this.anchorMargin.bottom) :
651
+ this.anchorMargin.top;
652
+ }
653
+ return y;
654
+ };
655
+ /**
656
+ * Calculates the offsets for positioning the menu-surface when the
657
+ * menu-surface has been hoisted to the body.
658
+ */
659
+ MDCMenuSurfaceFoundation.prototype.adjustPositionForHoistedElement = function (position) {
660
+ var e_1, _a;
661
+ var _b = this.measurements, windowScroll = _b.windowScroll, viewportDistance = _b.viewportDistance, surfaceSize = _b.surfaceSize, viewportSize = _b.viewportSize;
662
+ var props = Object.keys(position);
663
+ try {
664
+ for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
665
+ var prop = props_1_1.value;
666
+ var value = position[prop] || 0;
667
+ if (this.isHorizontallyCenteredOnViewport &&
668
+ (prop === 'left' || prop === 'right')) {
669
+ position[prop] = (viewportSize.width - surfaceSize.width) / 2;
670
+ continue;
671
+ }
672
+ // Hoisted surfaces need to have the anchor elements location on the page
673
+ // added to the position properties for proper alignment on the body.
674
+ value += viewportDistance[prop];
675
+ // Surfaces that are absolutely positioned need to have additional
676
+ // calculations for scroll and bottom positioning.
677
+ if (!this.isFixedPosition) {
678
+ if (prop === 'top') {
679
+ value += windowScroll.y;
680
+ }
681
+ else if (prop === 'bottom') {
682
+ value -= windowScroll.y;
683
+ }
684
+ else if (prop === 'left') {
685
+ value += windowScroll.x;
686
+ }
687
+ else { // prop === 'right'
688
+ value -= windowScroll.x;
689
+ }
690
+ }
691
+ position[prop] = value;
692
+ }
693
+ }
694
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
695
+ finally {
696
+ try {
697
+ if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
698
+ }
699
+ finally { if (e_1) throw e_1.error; }
700
+ }
701
+ };
702
+ /**
703
+ * The last focused element when the menu surface was opened should regain
704
+ * focus, if the user is focused on or within the menu surface when it is
705
+ * closed.
706
+ */
707
+ MDCMenuSurfaceFoundation.prototype.maybeRestoreFocus = function () {
708
+ var _this = this;
709
+ var isRootFocused = this.adapter.isFocused();
710
+ var childHasFocus = document.activeElement &&
711
+ this.adapter.isElementInContainer(document.activeElement);
712
+ if (isRootFocused || childHasFocus) {
713
+ // Wait before restoring focus when closing the menu surface. This is
714
+ // important because if a touch event triggered the menu close, and the
715
+ // subsequent mouse event occurs after focus is restored, then the
716
+ // restored focus would be lost.
717
+ setTimeout(function () {
718
+ _this.adapter.restoreFocus();
719
+ }, numbers.TOUCH_EVENT_WAIT_MS);
720
+ }
721
+ };
722
+ MDCMenuSurfaceFoundation.prototype.hasBit = function (corner, bit) {
723
+ return Boolean(corner & bit); // tslint:disable-line:no-bitwise
724
+ };
725
+ MDCMenuSurfaceFoundation.prototype.setBit = function (corner, bit) {
726
+ return corner | bit; // tslint:disable-line:no-bitwise
727
+ };
728
+ MDCMenuSurfaceFoundation.prototype.unsetBit = function (corner, bit) {
729
+ return corner ^ bit;
730
+ };
731
+ /**
732
+ * isFinite that doesn't force conversion to number type.
733
+ * Equivalent to Number.isFinite in ES2015, which is not supported in IE.
734
+ */
735
+ MDCMenuSurfaceFoundation.prototype.isFinite = function (num) {
736
+ return typeof num === 'number' && isFinite(num);
737
+ };
738
+ return MDCMenuSurfaceFoundation;
739
+ }(component.MDCFoundation));
740
+
741
+ /**
742
+ * @license
743
+ * Copyright 2018 Google Inc.
744
+ *
745
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
746
+ * of this software and associated documentation files (the "Software"), to deal
747
+ * in the Software without restriction, including without limitation the rights
748
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
749
+ * copies of the Software, and to permit persons to whom the Software is
750
+ * furnished to do so, subject to the following conditions:
751
+ *
752
+ * The above copyright notice and this permission notice shall be included in
753
+ * all copies or substantial portions of the Software.
754
+ *
755
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
756
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
757
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
758
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
759
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
760
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
761
+ * THE SOFTWARE.
762
+ */
763
+ var MDCMenuSurface = /** @class */ (function (_super) {
764
+ __extends(MDCMenuSurface, _super);
765
+ function MDCMenuSurface() {
766
+ return _super !== null && _super.apply(this, arguments) || this;
767
+ }
768
+ MDCMenuSurface.attachTo = function (root) {
769
+ return new MDCMenuSurface(root);
770
+ };
771
+ MDCMenuSurface.prototype.initialSyncWithDOM = function () {
772
+ var _this = this;
773
+ var parentEl = this.root.parentElement;
774
+ this.anchorElement = parentEl && parentEl.classList.contains(cssClasses.ANCHOR) ? parentEl : null;
775
+ if (this.root.classList.contains(cssClasses.FIXED)) {
776
+ this.setFixedPosition(true);
777
+ }
778
+ this.handleKeydown = function (event) {
779
+ _this.foundation.handleKeydown(event);
780
+ };
781
+ this.handleBodyClick = function (event) {
782
+ _this.foundation.handleBodyClick(event);
783
+ };
784
+ // capture so that no race between handleBodyClick and quickOpen when
785
+ // menusurface opened on button click which registers this listener
786
+ this.registerBodyClickListener = function () {
787
+ document.body.addEventListener('click', _this.handleBodyClick, { capture: true });
788
+ };
789
+ this.deregisterBodyClickListener = function () {
790
+ document.body.removeEventListener('click', _this.handleBodyClick, { capture: true });
791
+ };
792
+ this.listen('keydown', this.handleKeydown);
793
+ this.listen(strings.OPENED_EVENT, this.registerBodyClickListener);
794
+ this.listen(strings.CLOSED_EVENT, this.deregisterBodyClickListener);
795
+ };
796
+ MDCMenuSurface.prototype.destroy = function () {
797
+ this.unlisten('keydown', this.handleKeydown);
798
+ this.unlisten(strings.OPENED_EVENT, this.registerBodyClickListener);
799
+ this.unlisten(strings.CLOSED_EVENT, this.deregisterBodyClickListener);
800
+ _super.prototype.destroy.call(this);
801
+ };
802
+ MDCMenuSurface.prototype.isOpen = function () {
803
+ return this.foundation.isOpen();
804
+ };
805
+ MDCMenuSurface.prototype.open = function () {
806
+ this.foundation.open();
807
+ };
808
+ MDCMenuSurface.prototype.close = function (skipRestoreFocus) {
809
+ if (skipRestoreFocus === void 0) { skipRestoreFocus = false; }
810
+ this.foundation.close(skipRestoreFocus);
811
+ };
812
+ Object.defineProperty(MDCMenuSurface.prototype, "quickOpen", {
813
+ set: function (quickOpen) {
814
+ this.foundation.setQuickOpen(quickOpen);
815
+ },
816
+ enumerable: false,
817
+ configurable: true
818
+ });
819
+ /** Sets the foundation to use page offsets for an positioning when the menu is hoisted to the body. */
820
+ MDCMenuSurface.prototype.setIsHoisted = function (isHoisted) {
821
+ this.foundation.setIsHoisted(isHoisted);
822
+ };
823
+ /** Sets the element that the menu-surface is anchored to. */
824
+ MDCMenuSurface.prototype.setMenuSurfaceAnchorElement = function (element) {
825
+ this.anchorElement = element;
826
+ };
827
+ /** Sets the menu-surface to position: fixed. */
828
+ MDCMenuSurface.prototype.setFixedPosition = function (isFixed) {
829
+ if (isFixed) {
830
+ this.root.classList.add(cssClasses.FIXED);
831
+ }
832
+ else {
833
+ this.root.classList.remove(cssClasses.FIXED);
834
+ }
835
+ this.foundation.setFixedPosition(isFixed);
836
+ };
837
+ /** Sets the absolute x/y position to position based on. Requires the menu to be hoisted. */
838
+ MDCMenuSurface.prototype.setAbsolutePosition = function (x, y) {
839
+ this.foundation.setAbsolutePosition(x, y);
840
+ this.setIsHoisted(true);
841
+ };
842
+ /**
843
+ * @param corner Default anchor corner alignment of top-left surface corner.
844
+ */
845
+ MDCMenuSurface.prototype.setAnchorCorner = function (corner) {
846
+ this.foundation.setAnchorCorner(corner);
847
+ };
848
+ MDCMenuSurface.prototype.setAnchorMargin = function (margin) {
849
+ this.foundation.setAnchorMargin(margin);
850
+ };
851
+ MDCMenuSurface.prototype.getDefaultFoundation = function () {
852
+ var _this = this;
853
+ // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
854
+ // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
855
+ // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
856
+ var adapter = {
857
+ addClass: function (className) { return _this.root.classList.add(className); },
858
+ removeClass: function (className) { return _this.root.classList.remove(className); },
859
+ hasClass: function (className) { return _this.root.classList.contains(className); },
860
+ hasAnchor: function () { return !!_this.anchorElement; },
861
+ notifyClose: function () {
862
+ return _this.emit(MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {});
863
+ },
864
+ notifyClosing: function () {
865
+ _this.emit(MDCMenuSurfaceFoundation.strings.CLOSING_EVENT, {});
866
+ },
867
+ notifyOpen: function () {
868
+ return _this.emit(MDCMenuSurfaceFoundation.strings.OPENED_EVENT, {});
869
+ },
870
+ isElementInContainer: function (el) { return _this.root.contains(el); },
871
+ isRtl: function () {
872
+ return getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
873
+ },
874
+ setTransformOrigin: function (origin) {
875
+ var propertyName = util.getCorrectPropertyName(window, 'transform') + "-origin";
876
+ _this.root.style.setProperty(propertyName, origin);
877
+ },
878
+ isFocused: function () { return document.activeElement === _this.root; },
879
+ saveFocus: function () {
880
+ _this.previousFocus =
881
+ document.activeElement;
882
+ },
883
+ restoreFocus: function () {
884
+ if (_this.root.contains(document.activeElement)) {
885
+ if (_this.previousFocus && _this.previousFocus.focus) {
886
+ _this.previousFocus.focus();
887
+ }
888
+ }
889
+ },
890
+ getInnerDimensions: function () {
891
+ return {
892
+ width: _this.root.offsetWidth,
893
+ height: _this.root.offsetHeight
894
+ };
895
+ },
896
+ getAnchorDimensions: function () { return _this.anchorElement ?
897
+ _this.anchorElement.getBoundingClientRect() :
898
+ null; },
899
+ getWindowDimensions: function () {
900
+ return { width: window.innerWidth, height: window.innerHeight };
901
+ },
902
+ getBodyDimensions: function () {
903
+ return { width: document.body.clientWidth, height: document.body.clientHeight };
904
+ },
905
+ getWindowScroll: function () {
906
+ return { x: window.pageXOffset, y: window.pageYOffset };
907
+ },
908
+ setPosition: function (position) {
909
+ var rootHTML = _this.root;
910
+ rootHTML.style.left = 'left' in position ? position.left + "px" : '';
911
+ rootHTML.style.right = 'right' in position ? position.right + "px" : '';
912
+ rootHTML.style.top = 'top' in position ? position.top + "px" : '';
913
+ rootHTML.style.bottom =
914
+ 'bottom' in position ? position.bottom + "px" : '';
915
+ },
916
+ setMaxHeight: function (height) {
917
+ _this.root.style.maxHeight = height;
918
+ },
919
+ };
920
+ // tslint:enable:object-literal-sort-keys
921
+ return new MDCMenuSurfaceFoundation(adapter);
922
+ };
923
+ return MDCMenuSurface;
924
+ }(component.MDCComponent));
925
+
926
+ exports.MDCMenuSurface = MDCMenuSurface;
927
+ exports.MDCMenuSurfaceFoundation = MDCMenuSurfaceFoundation;
928
+
929
+ //# sourceMappingURL=component-a0124759.js.map