chunk.L3JZUJQ6.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import {
  2. l
  3. } from "./chunk.5MED2A3H.js";
  4. import {
  5. e as e2
  6. } from "./chunk.YXKHB4AC.js";
  7. import {
  8. T,
  9. e,
  10. h,
  11. n,
  12. o,
  13. r,
  14. r2
  15. } from "./chunk.5PIDMFOE.js";
  16. import {
  17. __decorateClass
  18. } from "./chunk.IHGPZX35.js";
  19. // _uyihdawu1:/Users/claviska/Projects/shoelace/src/components/menu-item/menu-item.scss
  20. var menu_item_default = ":host {\n position: relative;\n box-sizing: border-box;\n}\n:host *, :host *:before, :host *:after {\n box-sizing: inherit;\n}\n\n[hidden] {\n display: none !important;\n}\n\n:host {\n display: block;\n}\n\n.menu-item {\n position: relative;\n display: flex;\n align-items: stretch;\n font-family: var(--sl-font-sans);\n font-size: var(--sl-font-size-medium);\n font-weight: var(--sl-font-weight-normal);\n line-height: var(--sl-line-height-normal);\n letter-spacing: var(--sl-letter-spacing-normal);\n text-align: left;\n color: var(--sl-color-gray-700);\n padding: var(--sl-spacing-xx-small) var(--sl-spacing-x-large);\n transition: var(--sl-transition-fast) fill;\n user-select: none;\n white-space: nowrap;\n cursor: pointer;\n}\n.menu-item.menu-item--focused:not(.menu-item--disabled) {\n outline: none;\n background-color: var(--sl-color-primary-500);\n color: var(--sl-color-white);\n}\n.menu-item.menu-item--disabled {\n outline: none;\n color: var(--sl-color-gray-400);\n cursor: not-allowed;\n}\n.menu-item .menu-item__label {\n flex: 1 1 auto;\n}\n.menu-item .menu-item__prefix {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n}\n.menu-item .menu-item__prefix ::slotted(*) {\n margin-right: var(--sl-spacing-x-small);\n}\n.menu-item .menu-item__suffix {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n}\n.menu-item .menu-item__suffix ::slotted(*) {\n margin-left: var(--sl-spacing-x-small);\n}\n\n.menu-item .menu-item__check {\n display: flex;\n position: absolute;\n left: 0.5em;\n top: calc(50% - 0.5em);\n visibility: hidden;\n align-items: center;\n font-size: inherit;\n}\n\n.menu-item--checked .menu-item__check {\n visibility: visible;\n}";
  21. // src/components/menu-item/menu-item.ts
  22. var SlMenuItem = class extends h {
  23. constructor() {
  24. super(...arguments);
  25. this.hasFocus = false;
  26. this.checked = false;
  27. this.value = "";
  28. this.disabled = false;
  29. }
  30. focus(options) {
  31. this.menuItem.focus(options);
  32. }
  33. blur() {
  34. this.menuItem.blur();
  35. }
  36. handleBlur() {
  37. this.hasFocus = false;
  38. }
  39. handleFocus() {
  40. this.hasFocus = true;
  41. }
  42. handleMouseEnter() {
  43. this.focus();
  44. }
  45. handleMouseLeave() {
  46. this.blur();
  47. }
  48. render() {
  49. return T`
  50. <div
  51. part="base"
  52. class=${e2({
  53. "menu-item": true,
  54. "menu-item--checked": this.checked,
  55. "menu-item--disabled": this.disabled,
  56. "menu-item--focused": this.hasFocus
  57. })}
  58. role="menuitem"
  59. aria-disabled=${this.disabled ? "true" : "false"}
  60. aria-checked=${this.checked ? "true" : "false"}
  61. tabindex=${l(!this.disabled ? "0" : void 0)}
  62. @focus=${this.handleFocus}
  63. @blur=${this.handleBlur}
  64. @mouseenter=${this.handleMouseEnter}
  65. @mouseleave=${this.handleMouseLeave}
  66. >
  67. <span part="checked-icon" class="menu-item__check">
  68. <sl-icon name="check" library="system" aria-hidden="true"></sl-icon>
  69. </span>
  70. <span part="prefix" class="menu-item__prefix">
  71. <slot name="prefix"></slot>
  72. </span>
  73. <span part="label" class="menu-item__label">
  74. <slot></slot>
  75. </span>
  76. <span part="suffix" class="menu-item__suffix">
  77. <slot name="suffix"></slot>
  78. </span>
  79. </div>
  80. `;
  81. }
  82. };
  83. SlMenuItem.styles = r(menu_item_default);
  84. __decorateClass([
  85. o(".menu-item")
  86. ], SlMenuItem.prototype, "menuItem", 2);
  87. __decorateClass([
  88. r2()
  89. ], SlMenuItem.prototype, "hasFocus", 2);
  90. __decorateClass([
  91. e({ type: Boolean, reflect: true })
  92. ], SlMenuItem.prototype, "checked", 2);
  93. __decorateClass([
  94. e()
  95. ], SlMenuItem.prototype, "value", 2);
  96. __decorateClass([
  97. e({ type: Boolean, reflect: true })
  98. ], SlMenuItem.prototype, "disabled", 2);
  99. SlMenuItem = __decorateClass([
  100. n("sl-menu-item")
  101. ], SlMenuItem);
  102. var menu_item_default2 = SlMenuItem;
  103. export {
  104. menu_item_default2 as menu_item_default
  105. };