@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
@@ -1,105 +1,6 @@
1
1
  import { M as MDCFoundation, a as MDCComponent } from './component-410aad5a.js';
2
2
  import { m as matches, c as closest } from './ponyfill-30263d5e.js';
3
3
  import { n as normalizeKey } from './keyboard-4b9e12e3.js';
4
- import { g as getCorrectPropertyName } from './util-f1bde91c.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$1 = {
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$1 = {
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$1 = {
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
- var Corner;
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
- })(Corner || (Corner = {}));
103
4
 
104
5
  /*! *****************************************************************************
105
6
  Copyright (c) Microsoft Corporation.
@@ -117,30 +18,30 @@ PERFORMANCE OF THIS SOFTWARE.
117
18
  ***************************************************************************** */
118
19
  /* global Reflect, Promise */
119
20
 
120
- var extendStatics$1 = function(d, b) {
121
- extendStatics$1 = Object.setPrototypeOf ||
21
+ var extendStatics = function(d, b) {
22
+ extendStatics = Object.setPrototypeOf ||
122
23
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
123
24
  function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
124
- return extendStatics$1(d, b);
25
+ return extendStatics(d, b);
125
26
  };
126
27
 
127
- function __extends$1(d, b) {
28
+ function __extends(d, b) {
128
29
  if (typeof b !== "function" && b !== null)
129
30
  throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
130
- extendStatics$1(d, b);
31
+ extendStatics(d, b);
131
32
  function __() { this.constructor = d; }
132
33
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
133
34
  }
134
35
 
135
- var __assign$1 = function() {
136
- __assign$1 = Object.assign || function __assign(t) {
36
+ var __assign = function() {
37
+ __assign = Object.assign || function __assign(t) {
137
38
  for (var s, i = 1, n = arguments.length; i < n; i++) {
138
39
  s = arguments[i];
139
40
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
140
41
  }
141
42
  return t;
142
43
  };
143
- return __assign$1.apply(this, arguments);
44
+ return __assign.apply(this, arguments);
144
45
  };
145
46
 
146
47
  /**
@@ -566,9 +467,9 @@ function isNumberArray(selectedIndex) {
566
467
  return selectedIndex instanceof Array;
567
468
  }
568
469
  var MDCListFoundation = /** @class */ (function (_super) {
569
- __extends$1(MDCListFoundation, _super);
470
+ __extends(MDCListFoundation, _super);
570
471
  function MDCListFoundation(adapter) {
571
- var _this = _super.call(this, __assign$1(__assign$1({}, MDCListFoundation.defaultAdapter), adapter)) || this;
472
+ var _this = _super.call(this, __assign(__assign({}, MDCListFoundation.defaultAdapter), adapter)) || this;
572
473
  _this.wrapFocus = false;
573
474
  _this.isVertical = true;
574
475
  _this.isSingleSelectionList = false;
@@ -1240,7 +1141,7 @@ var MDCListFoundation = /** @class */ (function (_super) {
1240
1141
  * THE SOFTWARE.
1241
1142
  */
1242
1143
  var MDCList = /** @class */ (function (_super) {
1243
- __extends$1(MDCList, _super);
1144
+ __extends(MDCList, _super);
1244
1145
  function MDCList() {
1245
1146
  return _super !== null && _super.apply(this, arguments) || this;
1246
1147
  }
@@ -1590,828 +1491,6 @@ var MDCList = /** @class */ (function (_super) {
1590
1491
  return MDCList;
1591
1492
  }(MDCComponent));
1592
1493
 
1593
- /*! *****************************************************************************
1594
- Copyright (c) Microsoft Corporation.
1595
-
1596
- Permission to use, copy, modify, and/or distribute this software for any
1597
- purpose with or without fee is hereby granted.
1598
-
1599
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1600
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1601
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1602
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1603
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1604
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1605
- PERFORMANCE OF THIS SOFTWARE.
1606
- ***************************************************************************** */
1607
- /* global Reflect, Promise */
1608
-
1609
- var extendStatics = function(d, b) {
1610
- extendStatics = Object.setPrototypeOf ||
1611
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1612
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1613
- return extendStatics(d, b);
1614
- };
1615
-
1616
- function __extends(d, b) {
1617
- if (typeof b !== "function" && b !== null)
1618
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1619
- extendStatics(d, b);
1620
- function __() { this.constructor = d; }
1621
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1622
- }
1623
-
1624
- var __assign = function() {
1625
- __assign = Object.assign || function __assign(t) {
1626
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1627
- s = arguments[i];
1628
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1629
- }
1630
- return t;
1631
- };
1632
- return __assign.apply(this, arguments);
1633
- };
1634
-
1635
- function __values(o) {
1636
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
1637
- if (m) return m.call(o);
1638
- if (o && typeof o.length === "number") return {
1639
- next: function () {
1640
- if (o && i >= o.length) o = void 0;
1641
- return { value: o && o[i++], done: !o };
1642
- }
1643
- };
1644
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
1645
- }
1646
-
1647
- /**
1648
- * @license
1649
- * Copyright 2018 Google Inc.
1650
- *
1651
- * Permission is hereby granted, free of charge, to any person obtaining a copy
1652
- * of this software and associated documentation files (the "Software"), to deal
1653
- * in the Software without restriction, including without limitation the rights
1654
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1655
- * copies of the Software, and to permit persons to whom the Software is
1656
- * furnished to do so, subject to the following conditions:
1657
- *
1658
- * The above copyright notice and this permission notice shall be included in
1659
- * all copies or substantial portions of the Software.
1660
- *
1661
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1662
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1663
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1664
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1665
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1666
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1667
- * THE SOFTWARE.
1668
- */
1669
- var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
1670
- __extends(MDCMenuSurfaceFoundation, _super);
1671
- function MDCMenuSurfaceFoundation(adapter) {
1672
- var _this = _super.call(this, __assign(__assign({}, MDCMenuSurfaceFoundation.defaultAdapter), adapter)) || this;
1673
- _this.isSurfaceOpen = false;
1674
- _this.isQuickOpen = false;
1675
- _this.isHoistedElement = false;
1676
- _this.isFixedPosition = false;
1677
- _this.isHorizontallyCenteredOnViewport = false;
1678
- _this.maxHeight = 0;
1679
- _this.openAnimationEndTimerId = 0;
1680
- _this.closeAnimationEndTimerId = 0;
1681
- _this.animationRequestId = 0;
1682
- _this.anchorCorner = Corner.TOP_START;
1683
- /**
1684
- * Corner of the menu surface to which menu surface is attached to anchor.
1685
- *
1686
- * Anchor corner --->+----------+
1687
- * | ANCHOR |
1688
- * +----------+
1689
- * Origin corner --->+--------------+
1690
- * | |
1691
- * | |
1692
- * | MENU SURFACE |
1693
- * | |
1694
- * | |
1695
- * +--------------+
1696
- */
1697
- _this.originCorner = Corner.TOP_START;
1698
- _this.anchorMargin = { top: 0, right: 0, bottom: 0, left: 0 };
1699
- _this.position = { x: 0, y: 0 };
1700
- return _this;
1701
- }
1702
- Object.defineProperty(MDCMenuSurfaceFoundation, "cssClasses", {
1703
- get: function () {
1704
- return cssClasses$1;
1705
- },
1706
- enumerable: false,
1707
- configurable: true
1708
- });
1709
- Object.defineProperty(MDCMenuSurfaceFoundation, "strings", {
1710
- get: function () {
1711
- return strings$1;
1712
- },
1713
- enumerable: false,
1714
- configurable: true
1715
- });
1716
- Object.defineProperty(MDCMenuSurfaceFoundation, "numbers", {
1717
- get: function () {
1718
- return numbers$1;
1719
- },
1720
- enumerable: false,
1721
- configurable: true
1722
- });
1723
- Object.defineProperty(MDCMenuSurfaceFoundation, "Corner", {
1724
- get: function () {
1725
- return Corner;
1726
- },
1727
- enumerable: false,
1728
- configurable: true
1729
- });
1730
- Object.defineProperty(MDCMenuSurfaceFoundation, "defaultAdapter", {
1731
- /**
1732
- * @see {@link MDCMenuSurfaceAdapter} for typing information on parameters and return types.
1733
- */
1734
- get: function () {
1735
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
1736
- return {
1737
- addClass: function () { return undefined; },
1738
- removeClass: function () { return undefined; },
1739
- hasClass: function () { return false; },
1740
- hasAnchor: function () { return false; },
1741
- isElementInContainer: function () { return false; },
1742
- isFocused: function () { return false; },
1743
- isRtl: function () { return false; },
1744
- getInnerDimensions: function () { return ({ height: 0, width: 0 }); },
1745
- getAnchorDimensions: function () { return null; },
1746
- getWindowDimensions: function () { return ({ height: 0, width: 0 }); },
1747
- getBodyDimensions: function () { return ({ height: 0, width: 0 }); },
1748
- getWindowScroll: function () { return ({ x: 0, y: 0 }); },
1749
- setPosition: function () { return undefined; },
1750
- setMaxHeight: function () { return undefined; },
1751
- setTransformOrigin: function () { return undefined; },
1752
- saveFocus: function () { return undefined; },
1753
- restoreFocus: function () { return undefined; },
1754
- notifyClose: function () { return undefined; },
1755
- notifyOpen: function () { return undefined; },
1756
- notifyClosing: function () { return undefined; },
1757
- };
1758
- // tslint:enable:object-literal-sort-keys
1759
- },
1760
- enumerable: false,
1761
- configurable: true
1762
- });
1763
- MDCMenuSurfaceFoundation.prototype.init = function () {
1764
- var _a = MDCMenuSurfaceFoundation.cssClasses, ROOT = _a.ROOT, OPEN = _a.OPEN;
1765
- if (!this.adapter.hasClass(ROOT)) {
1766
- throw new Error(ROOT + " class required in root element.");
1767
- }
1768
- if (this.adapter.hasClass(OPEN)) {
1769
- this.isSurfaceOpen = true;
1770
- }
1771
- };
1772
- MDCMenuSurfaceFoundation.prototype.destroy = function () {
1773
- clearTimeout(this.openAnimationEndTimerId);
1774
- clearTimeout(this.closeAnimationEndTimerId);
1775
- // Cancel any currently running animations.
1776
- cancelAnimationFrame(this.animationRequestId);
1777
- };
1778
- /**
1779
- * @param corner Default anchor corner alignment of top-left menu surface
1780
- * corner.
1781
- */
1782
- MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function (corner) {
1783
- this.anchorCorner = corner;
1784
- };
1785
- /**
1786
- * Flip menu corner horizontally.
1787
- */
1788
- MDCMenuSurfaceFoundation.prototype.flipCornerHorizontally = function () {
1789
- this.originCorner = this.originCorner ^ CornerBit.RIGHT;
1790
- };
1791
- /**
1792
- * @param margin Set of margin values from anchor.
1793
- */
1794
- MDCMenuSurfaceFoundation.prototype.setAnchorMargin = function (margin) {
1795
- this.anchorMargin.top = margin.top || 0;
1796
- this.anchorMargin.right = margin.right || 0;
1797
- this.anchorMargin.bottom = margin.bottom || 0;
1798
- this.anchorMargin.left = margin.left || 0;
1799
- };
1800
- /** Used to indicate if the menu-surface is hoisted to the body. */
1801
- MDCMenuSurfaceFoundation.prototype.setIsHoisted = function (isHoisted) {
1802
- this.isHoistedElement = isHoisted;
1803
- };
1804
- /**
1805
- * Used to set the menu-surface calculations based on a fixed position menu.
1806
- */
1807
- MDCMenuSurfaceFoundation.prototype.setFixedPosition = function (isFixedPosition) {
1808
- this.isFixedPosition = isFixedPosition;
1809
- };
1810
- /**
1811
- * @return Returns true if menu is in fixed (`position: fixed`) position.
1812
- */
1813
- MDCMenuSurfaceFoundation.prototype.isFixed = function () {
1814
- return this.isFixedPosition;
1815
- };
1816
- /** Sets the menu-surface position on the page. */
1817
- MDCMenuSurfaceFoundation.prototype.setAbsolutePosition = function (x, y) {
1818
- this.position.x = this.isFinite(x) ? x : 0;
1819
- this.position.y = this.isFinite(y) ? y : 0;
1820
- };
1821
- /** Sets whether menu-surface should be horizontally centered to viewport. */
1822
- MDCMenuSurfaceFoundation.prototype.setIsHorizontallyCenteredOnViewport = function (isCentered) {
1823
- this.isHorizontallyCenteredOnViewport = isCentered;
1824
- };
1825
- MDCMenuSurfaceFoundation.prototype.setQuickOpen = function (quickOpen) {
1826
- this.isQuickOpen = quickOpen;
1827
- };
1828
- /**
1829
- * Sets maximum menu-surface height on open.
1830
- * @param maxHeight The desired max-height. Set to 0 (default) to
1831
- * automatically calculate max height based on available viewport space.
1832
- */
1833
- MDCMenuSurfaceFoundation.prototype.setMaxHeight = function (maxHeight) {
1834
- this.maxHeight = maxHeight;
1835
- };
1836
- MDCMenuSurfaceFoundation.prototype.isOpen = function () {
1837
- return this.isSurfaceOpen;
1838
- };
1839
- /**
1840
- * Open the menu surface.
1841
- */
1842
- MDCMenuSurfaceFoundation.prototype.open = function () {
1843
- var _this = this;
1844
- if (this.isSurfaceOpen) {
1845
- return;
1846
- }
1847
- this.adapter.saveFocus();
1848
- if (this.isQuickOpen) {
1849
- this.isSurfaceOpen = true;
1850
- this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
1851
- this.dimensions = this.adapter.getInnerDimensions();
1852
- this.autoposition();
1853
- this.adapter.notifyOpen();
1854
- }
1855
- else {
1856
- this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
1857
- this.animationRequestId = requestAnimationFrame(function () {
1858
- _this.dimensions = _this.adapter.getInnerDimensions();
1859
- _this.autoposition();
1860
- _this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
1861
- _this.openAnimationEndTimerId = setTimeout(function () {
1862
- _this.openAnimationEndTimerId = 0;
1863
- _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
1864
- _this.adapter.notifyOpen();
1865
- }, numbers$1.TRANSITION_OPEN_DURATION);
1866
- });
1867
- this.isSurfaceOpen = true;
1868
- }
1869
- };
1870
- /**
1871
- * Closes the menu surface.
1872
- */
1873
- MDCMenuSurfaceFoundation.prototype.close = function (skipRestoreFocus) {
1874
- var _this = this;
1875
- if (skipRestoreFocus === void 0) { skipRestoreFocus = false; }
1876
- if (!this.isSurfaceOpen) {
1877
- return;
1878
- }
1879
- this.adapter.notifyClosing();
1880
- if (this.isQuickOpen) {
1881
- this.isSurfaceOpen = false;
1882
- if (!skipRestoreFocus) {
1883
- this.maybeRestoreFocus();
1884
- }
1885
- this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
1886
- this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
1887
- this.adapter.notifyClose();
1888
- return;
1889
- }
1890
- this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
1891
- requestAnimationFrame(function () {
1892
- _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
1893
- _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
1894
- _this.closeAnimationEndTimerId = setTimeout(function () {
1895
- _this.closeAnimationEndTimerId = 0;
1896
- _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
1897
- _this.adapter.notifyClose();
1898
- }, numbers$1.TRANSITION_CLOSE_DURATION);
1899
- });
1900
- this.isSurfaceOpen = false;
1901
- if (!skipRestoreFocus) {
1902
- this.maybeRestoreFocus();
1903
- }
1904
- };
1905
- /** Handle clicks and close if not within menu-surface element. */
1906
- MDCMenuSurfaceFoundation.prototype.handleBodyClick = function (evt) {
1907
- var el = evt.target;
1908
- if (this.adapter.isElementInContainer(el)) {
1909
- return;
1910
- }
1911
- this.close();
1912
- };
1913
- /** Handle keys that close the surface. */
1914
- MDCMenuSurfaceFoundation.prototype.handleKeydown = function (evt) {
1915
- var keyCode = evt.keyCode, key = evt.key;
1916
- var isEscape = key === 'Escape' || keyCode === 27;
1917
- if (isEscape) {
1918
- this.close();
1919
- }
1920
- };
1921
- MDCMenuSurfaceFoundation.prototype.autoposition = function () {
1922
- var _a;
1923
- // Compute measurements for autoposition methods reuse.
1924
- this.measurements = this.getAutoLayoutmeasurements();
1925
- var corner = this.getoriginCorner();
1926
- var maxMenuSurfaceHeight = this.getMenuSurfaceMaxHeight(corner);
1927
- var verticalAlignment = this.hasBit(corner, CornerBit.BOTTOM) ? 'bottom' : 'top';
1928
- var horizontalAlignment = this.hasBit(corner, CornerBit.RIGHT) ? 'right' : 'left';
1929
- var horizontalOffset = this.getHorizontalOriginOffset(corner);
1930
- var verticalOffset = this.getVerticalOriginOffset(corner);
1931
- var _b = this.measurements, anchorSize = _b.anchorSize, surfaceSize = _b.surfaceSize;
1932
- var position = (_a = {},
1933
- _a[horizontalAlignment] = horizontalOffset,
1934
- _a[verticalAlignment] = verticalOffset,
1935
- _a);
1936
- // Center align when anchor width is comparable or greater than menu
1937
- // surface, otherwise keep corner.
1938
- if (anchorSize.width / surfaceSize.width >
1939
- numbers$1.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) {
1940
- horizontalAlignment = 'center';
1941
- }
1942
- // If the menu-surface has been hoisted to the body, it's no longer relative
1943
- // to the anchor element
1944
- if (this.isHoistedElement || this.isFixedPosition) {
1945
- this.adjustPositionForHoistedElement(position);
1946
- }
1947
- this.adapter.setTransformOrigin(horizontalAlignment + " " + verticalAlignment);
1948
- this.adapter.setPosition(position);
1949
- this.adapter.setMaxHeight(maxMenuSurfaceHeight ? maxMenuSurfaceHeight + 'px' : '');
1950
- // If it is opened from the top then add is-open-below class
1951
- if (!this.hasBit(corner, CornerBit.BOTTOM)) {
1952
- this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
1953
- }
1954
- };
1955
- /**
1956
- * @return Measurements used to position menu surface popup.
1957
- */
1958
- MDCMenuSurfaceFoundation.prototype.getAutoLayoutmeasurements = function () {
1959
- var anchorRect = this.adapter.getAnchorDimensions();
1960
- var bodySize = this.adapter.getBodyDimensions();
1961
- var viewportSize = this.adapter.getWindowDimensions();
1962
- var windowScroll = this.adapter.getWindowScroll();
1963
- if (!anchorRect) {
1964
- // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
1965
- anchorRect = {
1966
- top: this.position.y,
1967
- right: this.position.x,
1968
- bottom: this.position.y,
1969
- left: this.position.x,
1970
- width: 0,
1971
- height: 0,
1972
- };
1973
- // tslint:enable:object-literal-sort-keys
1974
- }
1975
- return {
1976
- anchorSize: anchorRect,
1977
- bodySize: bodySize,
1978
- surfaceSize: this.dimensions,
1979
- viewportDistance: {
1980
- // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
1981
- top: anchorRect.top,
1982
- right: viewportSize.width - anchorRect.right,
1983
- bottom: viewportSize.height - anchorRect.bottom,
1984
- left: anchorRect.left,
1985
- // tslint:enable:object-literal-sort-keys
1986
- },
1987
- viewportSize: viewportSize,
1988
- windowScroll: windowScroll,
1989
- };
1990
- };
1991
- /**
1992
- * Computes the corner of the anchor from which to animate and position the
1993
- * menu surface.
1994
- *
1995
- * Only LEFT or RIGHT bit is used to position the menu surface ignoring RTL
1996
- * context. E.g., menu surface will be positioned from right side on TOP_END.
1997
- */
1998
- MDCMenuSurfaceFoundation.prototype.getoriginCorner = function () {
1999
- var corner = this.originCorner;
2000
- var _a = this.measurements, viewportDistance = _a.viewportDistance, anchorSize = _a.anchorSize, surfaceSize = _a.surfaceSize;
2001
- var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
2002
- var isAnchoredToBottom = this.hasBit(this.anchorCorner, CornerBit.BOTTOM);
2003
- var availableTop;
2004
- var availableBottom;
2005
- if (isAnchoredToBottom) {
2006
- availableTop =
2007
- viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.bottom;
2008
- availableBottom =
2009
- viewportDistance.bottom - MARGIN_TO_EDGE - this.anchorMargin.bottom;
2010
- }
2011
- else {
2012
- availableTop =
2013
- viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.top;
2014
- availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE +
2015
- anchorSize.height - this.anchorMargin.top;
2016
- }
2017
- var isAvailableBottom = availableBottom - surfaceSize.height > 0;
2018
- if (!isAvailableBottom && availableTop > availableBottom) {
2019
- // Attach bottom side of surface to the anchor.
2020
- corner = this.setBit(corner, CornerBit.BOTTOM);
2021
- }
2022
- var isRtl = this.adapter.isRtl();
2023
- var isFlipRtl = this.hasBit(this.anchorCorner, CornerBit.FLIP_RTL);
2024
- var hasRightBit = this.hasBit(this.anchorCorner, CornerBit.RIGHT) ||
2025
- this.hasBit(corner, CornerBit.RIGHT);
2026
- // Whether surface attached to right side of anchor element.
2027
- var isAnchoredToRight = false;
2028
- // Anchored to start
2029
- if (isRtl && isFlipRtl) {
2030
- isAnchoredToRight = !hasRightBit;
2031
- }
2032
- else {
2033
- // Anchored to right
2034
- isAnchoredToRight = hasRightBit;
2035
- }
2036
- var availableLeft;
2037
- var availableRight;
2038
- if (isAnchoredToRight) {
2039
- availableLeft =
2040
- viewportDistance.left + anchorSize.width + this.anchorMargin.right;
2041
- availableRight = viewportDistance.right - this.anchorMargin.right;
2042
- }
2043
- else {
2044
- availableLeft = viewportDistance.left + this.anchorMargin.left;
2045
- availableRight =
2046
- viewportDistance.right + anchorSize.width - this.anchorMargin.left;
2047
- }
2048
- var isAvailableLeft = availableLeft - surfaceSize.width > 0;
2049
- var isAvailableRight = availableRight - surfaceSize.width > 0;
2050
- var isOriginCornerAlignedToEnd = this.hasBit(corner, CornerBit.FLIP_RTL) &&
2051
- this.hasBit(corner, CornerBit.RIGHT);
2052
- if (isAvailableRight && isOriginCornerAlignedToEnd && isRtl ||
2053
- !isAvailableLeft && isOriginCornerAlignedToEnd) {
2054
- // Attach left side of surface to the anchor.
2055
- corner = this.unsetBit(corner, CornerBit.RIGHT);
2056
- }
2057
- else if (isAvailableLeft && isAnchoredToRight && isRtl ||
2058
- (isAvailableLeft && !isAnchoredToRight && hasRightBit) ||
2059
- (!isAvailableRight && availableLeft >= availableRight)) {
2060
- // Attach right side of surface to the anchor.
2061
- corner = this.setBit(corner, CornerBit.RIGHT);
2062
- }
2063
- return corner;
2064
- };
2065
- /**
2066
- * @param corner Origin corner of the menu surface.
2067
- * @return Maximum height of the menu surface, based on available space. 0
2068
- * indicates should not be set.
2069
- */
2070
- MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight = function (corner) {
2071
- if (this.maxHeight > 0) {
2072
- return this.maxHeight;
2073
- }
2074
- var viewportDistance = this.measurements.viewportDistance;
2075
- var maxHeight = 0;
2076
- var isBottomAligned = this.hasBit(corner, CornerBit.BOTTOM);
2077
- var isBottomAnchored = this.hasBit(this.anchorCorner, CornerBit.BOTTOM);
2078
- var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
2079
- // When maximum height is not specified, it is handled from CSS.
2080
- if (isBottomAligned) {
2081
- maxHeight = viewportDistance.top + this.anchorMargin.top - MARGIN_TO_EDGE;
2082
- if (!isBottomAnchored) {
2083
- maxHeight += this.measurements.anchorSize.height;
2084
- }
2085
- }
2086
- else {
2087
- maxHeight = viewportDistance.bottom - this.anchorMargin.bottom +
2088
- this.measurements.anchorSize.height - MARGIN_TO_EDGE;
2089
- if (isBottomAnchored) {
2090
- maxHeight -= this.measurements.anchorSize.height;
2091
- }
2092
- }
2093
- return maxHeight;
2094
- };
2095
- /**
2096
- * @param corner Origin corner of the menu surface.
2097
- * @return Horizontal offset of menu surface origin corner from corresponding
2098
- * anchor corner.
2099
- */
2100
- MDCMenuSurfaceFoundation.prototype.getHorizontalOriginOffset = function (corner) {
2101
- var anchorSize = this.measurements.anchorSize;
2102
- // isRightAligned corresponds to using the 'right' property on the surface.
2103
- var isRightAligned = this.hasBit(corner, CornerBit.RIGHT);
2104
- var avoidHorizontalOverlap = this.hasBit(this.anchorCorner, CornerBit.RIGHT);
2105
- if (isRightAligned) {
2106
- var rightOffset = avoidHorizontalOverlap ?
2107
- anchorSize.width - this.anchorMargin.left :
2108
- this.anchorMargin.right;
2109
- // For hoisted or fixed elements, adjust the offset by the difference
2110
- // between viewport width and body width so when we calculate the right
2111
- // value (`adjustPositionForHoistedElement`) based on the element
2112
- // position, the right property is correct.
2113
- if (this.isHoistedElement || this.isFixedPosition) {
2114
- return rightOffset -
2115
- (this.measurements.viewportSize.width -
2116
- this.measurements.bodySize.width);
2117
- }
2118
- return rightOffset;
2119
- }
2120
- return avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.right :
2121
- this.anchorMargin.left;
2122
- };
2123
- /**
2124
- * @param corner Origin corner of the menu surface.
2125
- * @return Vertical offset of menu surface origin corner from corresponding
2126
- * anchor corner.
2127
- */
2128
- MDCMenuSurfaceFoundation.prototype.getVerticalOriginOffset = function (corner) {
2129
- var anchorSize = this.measurements.anchorSize;
2130
- var isBottomAligned = this.hasBit(corner, CornerBit.BOTTOM);
2131
- var avoidVerticalOverlap = this.hasBit(this.anchorCorner, CornerBit.BOTTOM);
2132
- var y = 0;
2133
- if (isBottomAligned) {
2134
- y = avoidVerticalOverlap ? anchorSize.height - this.anchorMargin.top :
2135
- -this.anchorMargin.bottom;
2136
- }
2137
- else {
2138
- y = avoidVerticalOverlap ?
2139
- (anchorSize.height + this.anchorMargin.bottom) :
2140
- this.anchorMargin.top;
2141
- }
2142
- return y;
2143
- };
2144
- /**
2145
- * Calculates the offsets for positioning the menu-surface when the
2146
- * menu-surface has been hoisted to the body.
2147
- */
2148
- MDCMenuSurfaceFoundation.prototype.adjustPositionForHoistedElement = function (position) {
2149
- var e_1, _a;
2150
- var _b = this.measurements, windowScroll = _b.windowScroll, viewportDistance = _b.viewportDistance, surfaceSize = _b.surfaceSize, viewportSize = _b.viewportSize;
2151
- var props = Object.keys(position);
2152
- try {
2153
- for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
2154
- var prop = props_1_1.value;
2155
- var value = position[prop] || 0;
2156
- if (this.isHorizontallyCenteredOnViewport &&
2157
- (prop === 'left' || prop === 'right')) {
2158
- position[prop] = (viewportSize.width - surfaceSize.width) / 2;
2159
- continue;
2160
- }
2161
- // Hoisted surfaces need to have the anchor elements location on the page
2162
- // added to the position properties for proper alignment on the body.
2163
- value += viewportDistance[prop];
2164
- // Surfaces that are absolutely positioned need to have additional
2165
- // calculations for scroll and bottom positioning.
2166
- if (!this.isFixedPosition) {
2167
- if (prop === 'top') {
2168
- value += windowScroll.y;
2169
- }
2170
- else if (prop === 'bottom') {
2171
- value -= windowScroll.y;
2172
- }
2173
- else if (prop === 'left') {
2174
- value += windowScroll.x;
2175
- }
2176
- else { // prop === 'right'
2177
- value -= windowScroll.x;
2178
- }
2179
- }
2180
- position[prop] = value;
2181
- }
2182
- }
2183
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2184
- finally {
2185
- try {
2186
- if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
2187
- }
2188
- finally { if (e_1) throw e_1.error; }
2189
- }
2190
- };
2191
- /**
2192
- * The last focused element when the menu surface was opened should regain
2193
- * focus, if the user is focused on or within the menu surface when it is
2194
- * closed.
2195
- */
2196
- MDCMenuSurfaceFoundation.prototype.maybeRestoreFocus = function () {
2197
- var _this = this;
2198
- var isRootFocused = this.adapter.isFocused();
2199
- var childHasFocus = document.activeElement &&
2200
- this.adapter.isElementInContainer(document.activeElement);
2201
- if (isRootFocused || childHasFocus) {
2202
- // Wait before restoring focus when closing the menu surface. This is
2203
- // important because if a touch event triggered the menu close, and the
2204
- // subsequent mouse event occurs after focus is restored, then the
2205
- // restored focus would be lost.
2206
- setTimeout(function () {
2207
- _this.adapter.restoreFocus();
2208
- }, numbers$1.TOUCH_EVENT_WAIT_MS);
2209
- }
2210
- };
2211
- MDCMenuSurfaceFoundation.prototype.hasBit = function (corner, bit) {
2212
- return Boolean(corner & bit); // tslint:disable-line:no-bitwise
2213
- };
2214
- MDCMenuSurfaceFoundation.prototype.setBit = function (corner, bit) {
2215
- return corner | bit; // tslint:disable-line:no-bitwise
2216
- };
2217
- MDCMenuSurfaceFoundation.prototype.unsetBit = function (corner, bit) {
2218
- return corner ^ bit;
2219
- };
2220
- /**
2221
- * isFinite that doesn't force conversion to number type.
2222
- * Equivalent to Number.isFinite in ES2015, which is not supported in IE.
2223
- */
2224
- MDCMenuSurfaceFoundation.prototype.isFinite = function (num) {
2225
- return typeof num === 'number' && isFinite(num);
2226
- };
2227
- return MDCMenuSurfaceFoundation;
2228
- }(MDCFoundation));
2229
-
2230
- /**
2231
- * @license
2232
- * Copyright 2018 Google Inc.
2233
- *
2234
- * Permission is hereby granted, free of charge, to any person obtaining a copy
2235
- * of this software and associated documentation files (the "Software"), to deal
2236
- * in the Software without restriction, including without limitation the rights
2237
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2238
- * copies of the Software, and to permit persons to whom the Software is
2239
- * furnished to do so, subject to the following conditions:
2240
- *
2241
- * The above copyright notice and this permission notice shall be included in
2242
- * all copies or substantial portions of the Software.
2243
- *
2244
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2245
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2246
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2247
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2248
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2249
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2250
- * THE SOFTWARE.
2251
- */
2252
- var MDCMenuSurface = /** @class */ (function (_super) {
2253
- __extends(MDCMenuSurface, _super);
2254
- function MDCMenuSurface() {
2255
- return _super !== null && _super.apply(this, arguments) || this;
2256
- }
2257
- MDCMenuSurface.attachTo = function (root) {
2258
- return new MDCMenuSurface(root);
2259
- };
2260
- MDCMenuSurface.prototype.initialSyncWithDOM = function () {
2261
- var _this = this;
2262
- var parentEl = this.root.parentElement;
2263
- this.anchorElement = parentEl && parentEl.classList.contains(cssClasses$1.ANCHOR) ? parentEl : null;
2264
- if (this.root.classList.contains(cssClasses$1.FIXED)) {
2265
- this.setFixedPosition(true);
2266
- }
2267
- this.handleKeydown = function (event) {
2268
- _this.foundation.handleKeydown(event);
2269
- };
2270
- this.handleBodyClick = function (event) {
2271
- _this.foundation.handleBodyClick(event);
2272
- };
2273
- // capture so that no race between handleBodyClick and quickOpen when
2274
- // menusurface opened on button click which registers this listener
2275
- this.registerBodyClickListener = function () {
2276
- document.body.addEventListener('click', _this.handleBodyClick, { capture: true });
2277
- };
2278
- this.deregisterBodyClickListener = function () {
2279
- document.body.removeEventListener('click', _this.handleBodyClick, { capture: true });
2280
- };
2281
- this.listen('keydown', this.handleKeydown);
2282
- this.listen(strings$1.OPENED_EVENT, this.registerBodyClickListener);
2283
- this.listen(strings$1.CLOSED_EVENT, this.deregisterBodyClickListener);
2284
- };
2285
- MDCMenuSurface.prototype.destroy = function () {
2286
- this.unlisten('keydown', this.handleKeydown);
2287
- this.unlisten(strings$1.OPENED_EVENT, this.registerBodyClickListener);
2288
- this.unlisten(strings$1.CLOSED_EVENT, this.deregisterBodyClickListener);
2289
- _super.prototype.destroy.call(this);
2290
- };
2291
- MDCMenuSurface.prototype.isOpen = function () {
2292
- return this.foundation.isOpen();
2293
- };
2294
- MDCMenuSurface.prototype.open = function () {
2295
- this.foundation.open();
2296
- };
2297
- MDCMenuSurface.prototype.close = function (skipRestoreFocus) {
2298
- if (skipRestoreFocus === void 0) { skipRestoreFocus = false; }
2299
- this.foundation.close(skipRestoreFocus);
2300
- };
2301
- Object.defineProperty(MDCMenuSurface.prototype, "quickOpen", {
2302
- set: function (quickOpen) {
2303
- this.foundation.setQuickOpen(quickOpen);
2304
- },
2305
- enumerable: false,
2306
- configurable: true
2307
- });
2308
- /** Sets the foundation to use page offsets for an positioning when the menu is hoisted to the body. */
2309
- MDCMenuSurface.prototype.setIsHoisted = function (isHoisted) {
2310
- this.foundation.setIsHoisted(isHoisted);
2311
- };
2312
- /** Sets the element that the menu-surface is anchored to. */
2313
- MDCMenuSurface.prototype.setMenuSurfaceAnchorElement = function (element) {
2314
- this.anchorElement = element;
2315
- };
2316
- /** Sets the menu-surface to position: fixed. */
2317
- MDCMenuSurface.prototype.setFixedPosition = function (isFixed) {
2318
- if (isFixed) {
2319
- this.root.classList.add(cssClasses$1.FIXED);
2320
- }
2321
- else {
2322
- this.root.classList.remove(cssClasses$1.FIXED);
2323
- }
2324
- this.foundation.setFixedPosition(isFixed);
2325
- };
2326
- /** Sets the absolute x/y position to position based on. Requires the menu to be hoisted. */
2327
- MDCMenuSurface.prototype.setAbsolutePosition = function (x, y) {
2328
- this.foundation.setAbsolutePosition(x, y);
2329
- this.setIsHoisted(true);
2330
- };
2331
- /**
2332
- * @param corner Default anchor corner alignment of top-left surface corner.
2333
- */
2334
- MDCMenuSurface.prototype.setAnchorCorner = function (corner) {
2335
- this.foundation.setAnchorCorner(corner);
2336
- };
2337
- MDCMenuSurface.prototype.setAnchorMargin = function (margin) {
2338
- this.foundation.setAnchorMargin(margin);
2339
- };
2340
- MDCMenuSurface.prototype.getDefaultFoundation = function () {
2341
- var _this = this;
2342
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
2343
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
2344
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
2345
- var adapter = {
2346
- addClass: function (className) { return _this.root.classList.add(className); },
2347
- removeClass: function (className) { return _this.root.classList.remove(className); },
2348
- hasClass: function (className) { return _this.root.classList.contains(className); },
2349
- hasAnchor: function () { return !!_this.anchorElement; },
2350
- notifyClose: function () {
2351
- return _this.emit(MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {});
2352
- },
2353
- notifyClosing: function () {
2354
- _this.emit(MDCMenuSurfaceFoundation.strings.CLOSING_EVENT, {});
2355
- },
2356
- notifyOpen: function () {
2357
- return _this.emit(MDCMenuSurfaceFoundation.strings.OPENED_EVENT, {});
2358
- },
2359
- isElementInContainer: function (el) { return _this.root.contains(el); },
2360
- isRtl: function () {
2361
- return getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
2362
- },
2363
- setTransformOrigin: function (origin) {
2364
- var propertyName = getCorrectPropertyName(window, 'transform') + "-origin";
2365
- _this.root.style.setProperty(propertyName, origin);
2366
- },
2367
- isFocused: function () { return document.activeElement === _this.root; },
2368
- saveFocus: function () {
2369
- _this.previousFocus =
2370
- document.activeElement;
2371
- },
2372
- restoreFocus: function () {
2373
- if (_this.root.contains(document.activeElement)) {
2374
- if (_this.previousFocus && _this.previousFocus.focus) {
2375
- _this.previousFocus.focus();
2376
- }
2377
- }
2378
- },
2379
- getInnerDimensions: function () {
2380
- return {
2381
- width: _this.root.offsetWidth,
2382
- height: _this.root.offsetHeight
2383
- };
2384
- },
2385
- getAnchorDimensions: function () { return _this.anchorElement ?
2386
- _this.anchorElement.getBoundingClientRect() :
2387
- null; },
2388
- getWindowDimensions: function () {
2389
- return { width: window.innerWidth, height: window.innerHeight };
2390
- },
2391
- getBodyDimensions: function () {
2392
- return { width: document.body.clientWidth, height: document.body.clientHeight };
2393
- },
2394
- getWindowScroll: function () {
2395
- return { x: window.pageXOffset, y: window.pageYOffset };
2396
- },
2397
- setPosition: function (position) {
2398
- var rootHTML = _this.root;
2399
- rootHTML.style.left = 'left' in position ? position.left + "px" : '';
2400
- rootHTML.style.right = 'right' in position ? position.right + "px" : '';
2401
- rootHTML.style.top = 'top' in position ? position.top + "px" : '';
2402
- rootHTML.style.bottom =
2403
- 'bottom' in position ? position.bottom + "px" : '';
2404
- },
2405
- setMaxHeight: function (height) {
2406
- _this.root.style.maxHeight = height;
2407
- },
2408
- };
2409
- // tslint:enable:object-literal-sort-keys
2410
- return new MDCMenuSurfaceFoundation(adapter);
2411
- };
2412
- return MDCMenuSurface;
2413
- }(MDCComponent));
2414
-
2415
- export { Corner as C, MDCMenuSurfaceFoundation as M, MDCListFoundation as a, MDCMenuSurface as b, cssClasses as c, MDCList as d, numbers as n, strings as s };
1494
+ export { MDCListFoundation as M, MDCList as a, cssClasses as c, numbers as n, strings as s };
2416
1495
 
2417
- //# sourceMappingURL=component-fffa3419.js.map
1496
+ //# sourceMappingURL=component-0be247ac.js.map