chunk.EOB7TE2N.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import {
  2. event
  3. } from "./chunk.XX234VRK.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. } from "./chunk.5PIDMFOE.js";
  15. import {
  16. __decorateClass
  17. } from "./chunk.IHGPZX35.js";
  18. // _uyihdawu1:/Users/claviska/Projects/shoelace/src/components/tab/tab.scss
  19. var tab_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 --focus-ring: inset 0 0 0 var(--sl-focus-ring-width) var(--sl-focus-ring-color-primary);\n display: inline-block;\n}\n\n.tab {\n display: inline-flex;\n align-items: center;\n font-family: var(--sl-font-sans);\n font-size: var(--sl-font-size-small);\n font-weight: var(--sl-font-weight-semibold);\n border-radius: 4px;\n color: var(--sl-color-gray-600);\n padding: var(--sl-spacing-medium) var(--sl-spacing-large);\n white-space: nowrap;\n user-select: none;\n cursor: pointer;\n transition: var(--transition-speed) box-shadow, var(--transition-speed) color;\n}\n.tab:hover:not(.tab--disabled) {\n color: var(--sl-color-primary-500);\n}\n.tab:focus {\n outline: none;\n}\n.tab:focus:not(.tab--disabled) {\n color: var(--sl-color-primary-500);\n box-shadow: var(--focus-ring);\n}\n.tab.tab--active:not(.tab--disabled) {\n color: var(--sl-color-primary-500);\n}\n.tab.tab--closable {\n padding-right: var(--sl-spacing-small);\n}\n.tab.tab--disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.tab__close-button {\n font-size: var(--sl-font-size-large);\n margin-left: var(--sl-spacing-xx-small);\n}\n.tab__close-button::part(base) {\n padding: var(--sl-spacing-xxx-small);\n}";
  20. // src/components/tab/tab.ts
  21. var id = 0;
  22. var SlTab = class extends h {
  23. constructor() {
  24. super(...arguments);
  25. this.componentId = `tab-${++id}`;
  26. this.panel = "";
  27. this.active = false;
  28. this.closable = false;
  29. this.disabled = false;
  30. }
  31. focus(options) {
  32. this.tab.focus(options);
  33. }
  34. blur() {
  35. this.tab.blur();
  36. }
  37. handleCloseClick() {
  38. this.slClose.emit();
  39. }
  40. render() {
  41. this.id = this.id || this.componentId;
  42. return T`
  43. <div
  44. part="base"
  45. class=${e2({
  46. tab: true,
  47. "tab--active": this.active,
  48. "tab--closable": this.closable,
  49. "tab--disabled": this.disabled
  50. })}
  51. role="tab"
  52. aria-disabled=${this.disabled ? "true" : "false"}
  53. aria-selected=${this.active ? "true" : "false"}
  54. tabindex=${this.disabled || !this.active ? "-1" : "0"}
  55. >
  56. <slot></slot>
  57. ${this.closable ? T`
  58. <sl-icon-button
  59. name="x"
  60. library="system"
  61. exportparts="base:close-button"
  62. class="tab__close-button"
  63. @click=${this.handleCloseClick}
  64. tabindex="-1"
  65. aria-hidden="true"
  66. ></sl-icon-button>
  67. ` : ""}
  68. </div>
  69. `;
  70. }
  71. };
  72. SlTab.styles = r(tab_default);
  73. __decorateClass([
  74. o(".tab")
  75. ], SlTab.prototype, "tab", 2);
  76. __decorateClass([
  77. e()
  78. ], SlTab.prototype, "panel", 2);
  79. __decorateClass([
  80. e({ type: Boolean, reflect: true })
  81. ], SlTab.prototype, "active", 2);
  82. __decorateClass([
  83. e({ type: Boolean })
  84. ], SlTab.prototype, "closable", 2);
  85. __decorateClass([
  86. e({ type: Boolean, reflect: true })
  87. ], SlTab.prototype, "disabled", 2);
  88. __decorateClass([
  89. event("sl-close")
  90. ], SlTab.prototype, "slClose", 2);
  91. SlTab = __decorateClass([
  92. n("sl-tab")
  93. ], SlTab);
  94. var tab_default2 = SlTab;
  95. export {
  96. tab_default2 as tab_default
  97. };