constants.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * @license
  3. * Copyright 2018 Google Inc.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. * THE SOFTWARE.
  22. */
  23. var cssClasses = {
  24. ANCHOR: 'mdc-menu-surface--anchor',
  25. ANIMATING_CLOSED: 'mdc-menu-surface--animating-closed',
  26. ANIMATING_OPEN: 'mdc-menu-surface--animating-open',
  27. FIXED: 'mdc-menu-surface--fixed',
  28. IS_OPEN_BELOW: 'mdc-menu-surface--is-open-below',
  29. OPEN: 'mdc-menu-surface--open',
  30. ROOT: 'mdc-menu-surface',
  31. };
  32. // tslint:disable:object-literal-sort-keys
  33. var strings = {
  34. CLOSED_EVENT: 'MDCMenuSurface:closed',
  35. CLOSING_EVENT: 'MDCMenuSurface:closing',
  36. OPENED_EVENT: 'MDCMenuSurface:opened',
  37. OPENING_EVENT: 'MDCMenuSurface:opening',
  38. FOCUSABLE_ELEMENTS: [
  39. 'button:not(:disabled)',
  40. '[href]:not([aria-disabled="true"])',
  41. 'input:not(:disabled)',
  42. 'select:not(:disabled)',
  43. 'textarea:not(:disabled)',
  44. '[tabindex]:not([tabindex="-1"]):not([aria-disabled="true"])',
  45. ].join(', '),
  46. };
  47. // tslint:enable:object-literal-sort-keys
  48. var numbers = {
  49. /** Total duration of menu-surface open animation. */
  50. TRANSITION_OPEN_DURATION: 120,
  51. /** Total duration of menu-surface close animation. */
  52. TRANSITION_CLOSE_DURATION: 75,
  53. /**
  54. * Margin left to the edge of the viewport when menu-surface is at maximum
  55. * possible height. Also used as a viewport margin.
  56. */
  57. MARGIN_TO_EDGE: 32,
  58. /**
  59. * Ratio of anchor width to menu-surface width for switching from corner
  60. * positioning to center positioning.
  61. */
  62. ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: 0.67,
  63. /**
  64. * Amount of time to wait before restoring focus when closing the menu
  65. * surface. This is important because if a touch event triggered the menu
  66. * close, and the subsequent mouse event occurs after focus is restored, then
  67. * the restored focus would be lost.
  68. */
  69. TOUCH_EVENT_WAIT_MS: 30,
  70. };
  71. /**
  72. * Enum for bits in the {@see Corner) bitmap.
  73. */
  74. var CornerBit;
  75. (function (CornerBit) {
  76. CornerBit[CornerBit["BOTTOM"] = 1] = "BOTTOM";
  77. CornerBit[CornerBit["CENTER"] = 2] = "CENTER";
  78. CornerBit[CornerBit["RIGHT"] = 4] = "RIGHT";
  79. CornerBit[CornerBit["FLIP_RTL"] = 8] = "FLIP_RTL";
  80. })(CornerBit || (CornerBit = {}));
  81. /**
  82. * Enum for representing an element corner for positioning the menu-surface.
  83. *
  84. * The START constants map to LEFT if element directionality is left
  85. * to right and RIGHT if the directionality is right to left.
  86. * Likewise END maps to RIGHT or LEFT depending on the directionality.
  87. */
  88. var Corner;
  89. (function (Corner) {
  90. Corner[Corner["TOP_LEFT"] = 0] = "TOP_LEFT";
  91. Corner[Corner["TOP_RIGHT"] = 4] = "TOP_RIGHT";
  92. Corner[Corner["BOTTOM_LEFT"] = 1] = "BOTTOM_LEFT";
  93. Corner[Corner["BOTTOM_RIGHT"] = 5] = "BOTTOM_RIGHT";
  94. Corner[Corner["TOP_START"] = 8] = "TOP_START";
  95. Corner[Corner["TOP_END"] = 12] = "TOP_END";
  96. Corner[Corner["BOTTOM_START"] = 9] = "BOTTOM_START";
  97. Corner[Corner["BOTTOM_END"] = 13] = "BOTTOM_END";
  98. })(Corner || (Corner = {}));
  99. export { cssClasses, strings, numbers, CornerBit, Corner };
  100. //# sourceMappingURL=constants.js.map