chunk.54BODVD6.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. import {
  2. hasSlot
  3. } from "./chunk.FMCX45AD.js";
  4. import {
  5. l
  6. } from "./chunk.5MED2A3H.js";
  7. import {
  8. event
  9. } from "./chunk.XX234VRK.js";
  10. import {
  11. e as e2
  12. } from "./chunk.YXKHB4AC.js";
  13. import {
  14. T,
  15. e,
  16. h,
  17. n,
  18. o,
  19. r,
  20. r2
  21. } from "./chunk.5PIDMFOE.js";
  22. import {
  23. __decorateClass
  24. } from "./chunk.IHGPZX35.js";
  25. // _uyihdawu1:/Users/claviska/Projects/shoelace/src/components/button/button.scss
  26. var button_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: inline-block;\n width: auto;\n cursor: pointer;\n}\n\n.button {\n display: inline-flex;\n align-items: stretch;\n justify-content: center;\n width: 100%;\n border-style: solid;\n border-width: var(--sl-input-border-width);\n font-family: var(--sl-input-font-family);\n font-weight: var(--sl-font-weight-semibold);\n text-decoration: none;\n user-select: none;\n white-space: nowrap;\n vertical-align: middle;\n padding: 0;\n transition: var(--sl-transition-fast) background-color, var(--sl-transition-fast) color, var(--sl-transition-fast) border, var(--sl-transition-fast) box-shadow;\n cursor: inherit;\n}\n.button::-moz-focus-inner {\n border: 0;\n}\n.button:focus {\n outline: none;\n}\n.button.button--disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.button.button--disabled * {\n pointer-events: none;\n}\n.button ::slotted(sl-icon) {\n pointer-events: none;\n}\n\n.button__prefix,\n.button__suffix {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n}\n\n.button__label ::slotted(sl-icon) {\n vertical-align: -2px;\n}\n\n.button.button--default {\n background-color: var(--sl-color-white);\n border-color: var(--sl-color-gray-300);\n color: var(--sl-color-gray-600);\n}\n.button.button--default:hover:not(.button--disabled) {\n background-color: var(--sl-color-primary-50);\n border-color: var(--sl-color-primary-300);\n color: var(--sl-color-primary-600);\n}\n.button.button--default:focus:not(.button--disabled) {\n background-color: var(--sl-color-primary-50);\n border-color: var(--sl-color-primary-300);\n color: var(--sl-color-primary-600);\n box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-focus-ring-color-primary);\n}\n.button.button--default:active:not(.button--disabled) {\n background-color: var(--sl-color-primary-100);\n border-color: var(--sl-color-primary-400);\n color: var(--sl-color-primary-700);\n}\n.button.button--primary {\n background-color: var(--sl-color-primary-500);\n border-color: var(--sl-color-primary-500);\n color: var(--sl-color-primary-text);\n}\n.button.button--primary:hover:not(.button--disabled) {\n background-color: var(--sl-color-primary-400);\n border-color: var(--sl-color-primary-400);\n color: var(--sl-color-primary-text);\n}\n.button.button--primary:focus:not(.button--disabled) {\n background-color: var(--sl-color-primary-400);\n border-color: var(--sl-color-primary-400);\n color: var(--sl-color-primary-text);\n box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-focus-ring-color-primary);\n}\n.button.button--primary:active:not(.button--disabled) {\n background-color: var(--sl-color-primary-500);\n border-color: var(--sl-color-primary-500);\n color: var(--sl-color-primary-text);\n}\n.button.button--success {\n background-color: var(--sl-color-success-500);\n border-color: var(--sl-color-success-500);\n color: var(--sl-color-success-text);\n}\n.button.button--success:hover:not(.button--disabled) {\n background-color: var(--sl-color-success-400);\n border-color: var(--sl-color-success-400);\n color: var(--sl-color-success-text);\n}\n.button.button--success:focus:not(.button--disabled) {\n background-color: var(--sl-color-success-400);\n border-color: var(--sl-color-success-400);\n color: var(--sl-color-success-text);\n box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-focus-ring-color-success);\n}\n.button.button--success:active:not(.button--disabled) {\n background-color: var(--sl-color-success-500);\n border-color: var(--sl-color-success-500);\n color: var(--sl-color-success-text);\n}\n.button.button--info {\n background-color: var(--sl-color-info-500);\n border-color: var(--sl-color-info-500);\n color: var(--sl-color-info-text);\n}\n.button.button--info:hover:not(.button--disabled) {\n background-color: var(--sl-color-info-400);\n border-color: var(--sl-color-info-400);\n color: var(--sl-color-info-text);\n}\n.button.button--info:focus:not(.button--disabled) {\n background-color: var(--sl-color-info-400);\n border-color: var(--sl-color-info-400);\n color: var(--sl-color-info-text);\n box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-focus-ring-color-info);\n}\n.button.button--info:active:not(.button--disabled) {\n background-color: var(--sl-color-info-500);\n border-color: var(--sl-color-info-500);\n color: var(--sl-color-info-text);\n}\n.button.button--warning {\n background-color: var(--sl-color-warning-500);\n border-color: var(--sl-color-warning-500);\n color: var(--sl-color-warning-text);\n}\n.button.button--warning:hover:not(.button--disabled) {\n background-color: var(--sl-color-warning-400);\n border-color: var(--sl-color-warning-400);\n color: var(--sl-color-warning-text);\n}\n.button.button--warning:focus:not(.button--disabled) {\n background-color: var(--sl-color-warning-400);\n border-color: var(--sl-color-warning-400);\n color: var(--sl-color-warning-text);\n box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-focus-ring-color-warning);\n}\n.button.button--warning:active:not(.button--disabled) {\n background-color: var(--sl-color-warning-500);\n border-color: var(--sl-color-warning-500);\n color: var(--sl-color-warning-text);\n}\n.button.button--danger {\n background-color: var(--sl-color-danger-500);\n border-color: var(--sl-color-danger-500);\n color: var(--sl-color-danger-text);\n}\n.button.button--danger:hover:not(.button--disabled) {\n background-color: var(--sl-color-danger-400);\n border-color: var(--sl-color-danger-400);\n color: var(--sl-color-danger-text);\n}\n.button.button--danger:focus:not(.button--disabled) {\n background-color: var(--sl-color-danger-400);\n border-color: var(--sl-color-danger-400);\n color: var(--sl-color-danger-text);\n box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-focus-ring-color-danger);\n}\n.button.button--danger:active:not(.button--disabled) {\n background-color: var(--sl-color-danger-500);\n border-color: var(--sl-color-danger-500);\n color: var(--sl-color-danger-text);\n}\n\n.button--text {\n background-color: transparent;\n border-color: transparent;\n color: var(--sl-color-primary-500);\n}\n.button--text:hover:not(.button--disabled) {\n background-color: transparent;\n border-color: transparent;\n color: var(--sl-color-primary-400);\n}\n.button--text:focus:not(.button--disabled) {\n background-color: transparent;\n border-color: transparent;\n color: var(--sl-color-primary-400);\n box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-focus-ring-color-primary);\n}\n.button--text:active:not(.button--disabled) {\n background-color: transparent;\n border-color: transparent;\n color: var(--sl-color-primary-600);\n}\n\n.button--small {\n font-size: var(--sl-button-font-size-small);\n height: var(--sl-input-height-small);\n line-height: calc(var(--sl-input-height-small) - var(--sl-input-border-width) * 2);\n border-radius: var(--sl-input-border-radius-small);\n}\n\n.button--medium {\n font-size: var(--sl-button-font-size-medium);\n height: var(--sl-input-height-medium);\n line-height: calc(var(--sl-input-height-medium) - var(--sl-input-border-width) * 2);\n border-radius: var(--sl-input-border-radius-medium);\n}\n\n.button--large {\n font-size: var(--sl-button-font-size-large);\n height: var(--sl-input-height-large);\n line-height: calc(var(--sl-input-height-large) - var(--sl-input-border-width) * 2);\n border-radius: var(--sl-input-border-radius-large);\n}\n\n.button--pill.button--small {\n border-radius: var(--sl-input-height-small);\n}\n.button--pill.button--medium {\n border-radius: var(--sl-input-height-medium);\n}\n.button--pill.button--large {\n border-radius: var(--sl-input-height-large);\n}\n\n.button--circle {\n padding-left: 0;\n padding-right: 0;\n}\n.button--circle.button--small {\n width: var(--sl-input-height-small);\n border-radius: 50%;\n}\n.button--circle.button--medium {\n width: var(--sl-input-height-medium);\n border-radius: 50%;\n}\n.button--circle.button--large {\n width: var(--sl-input-height-large);\n border-radius: 50%;\n}\n.button--circle .button__prefix,\n.button--circle .button__suffix,\n.button--circle .button__caret {\n display: none;\n}\n\n.button--caret .button__suffix {\n display: none;\n}\n.button--caret .button__caret {\n display: flex;\n align-items: center;\n}\n.button--caret .button__caret svg {\n width: 1em;\n height: 1em;\n}\n\n.button--loading {\n position: relative;\n cursor: wait;\n}\n.button--loading .button__prefix,\n.button--loading .button__label,\n.button--loading .button__suffix,\n.button--loading .button__caret {\n visibility: hidden;\n}\n.button--loading sl-spinner {\n --indicator-color: currentColor;\n position: absolute;\n height: 1em;\n width: 1em;\n top: calc(50% - 0.5em);\n left: calc(50% - 0.5em);\n}\n\n.button ::slotted(sl-badge) {\n position: absolute;\n top: 0;\n right: 0;\n transform: translateY(-50%) translateX(50%);\n pointer-events: none;\n}\n\n.button--has-label.button--small .button__label {\n padding: 0 var(--sl-spacing-small);\n}\n.button--has-label.button--medium .button__label {\n padding: 0 var(--sl-spacing-medium);\n}\n.button--has-label.button--large .button__label {\n padding: 0 var(--sl-spacing-large);\n}\n\n.button--has-prefix.button--small {\n padding-left: var(--sl-spacing-x-small);\n}\n.button--has-prefix.button--small .button__label {\n padding-left: var(--sl-spacing-x-small);\n}\n.button--has-prefix.button--medium {\n padding-left: var(--sl-spacing-small);\n}\n.button--has-prefix.button--medium .button__label {\n padding-left: var(--sl-spacing-small);\n}\n.button--has-prefix.button--large {\n padding-left: var(--sl-spacing-small);\n}\n.button--has-prefix.button--large .button__label {\n padding-left: var(--sl-spacing-small);\n}\n\n.button--has-suffix.button--small,\n.button--caret.button--small {\n padding-right: var(--sl-spacing-x-small);\n}\n.button--has-suffix.button--small .button__label,\n.button--caret.button--small .button__label {\n padding-right: var(--sl-spacing-x-small);\n}\n.button--has-suffix.button--medium,\n.button--caret.button--medium {\n padding-right: var(--sl-spacing-small);\n}\n.button--has-suffix.button--medium .button__label,\n.button--caret.button--medium .button__label {\n padding-right: var(--sl-spacing-small);\n}\n.button--has-suffix.button--large,\n.button--caret.button--large {\n padding-right: var(--sl-spacing-small);\n}\n.button--has-suffix.button--large .button__label,\n.button--caret.button--large .button__label {\n padding-right: var(--sl-spacing-small);\n}\n\n:host(.sl-button-group__button--first) .button {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n\n:host(.sl-button-group__button--inner) .button {\n border-radius: 0;\n}\n\n:host(.sl-button-group__button--last) .button {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n}\n\n:host(.sl-button-group__button:not(.sl-button-group__button--first)) {\n margin-left: calc(-1 * var(--sl-input-border-width));\n}\n\n:host(.sl-button-group__button:not(.sl-button-group__button--focus, .sl-button-group__button--first, [type=default]):not(:hover, :active, :focus)) .button:after {\n content: "";\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n border-left: solid 1px #fff4;\n mix-blend-mode: lighten;\n}\n\n:host(.sl-button-group__button--hover) {\n z-index: 1;\n}\n\n:host(.sl-button-group__button--focus) {\n z-index: 2;\n}';
  27. // src/components/button/button.ts
  28. var SlButton = class extends h {
  29. constructor() {
  30. super(...arguments);
  31. this.hasFocus = false;
  32. this.hasLabel = false;
  33. this.hasPrefix = false;
  34. this.hasSuffix = false;
  35. this.type = "default";
  36. this.size = "medium";
  37. this.caret = false;
  38. this.disabled = false;
  39. this.loading = false;
  40. this.pill = false;
  41. this.circle = false;
  42. this.submit = false;
  43. }
  44. connectedCallback() {
  45. super.connectedCallback();
  46. this.handleSlotChange();
  47. }
  48. click() {
  49. this.button.click();
  50. }
  51. focus(options) {
  52. this.button.focus(options);
  53. }
  54. blur() {
  55. this.button.blur();
  56. }
  57. handleSlotChange() {
  58. this.hasLabel = hasSlot(this);
  59. this.hasPrefix = hasSlot(this, "prefix");
  60. this.hasSuffix = hasSlot(this, "suffix");
  61. }
  62. handleBlur() {
  63. this.hasFocus = false;
  64. this.slBlur.emit();
  65. }
  66. handleFocus() {
  67. this.hasFocus = true;
  68. this.slFocus.emit();
  69. }
  70. handleClick(event2) {
  71. if (this.disabled || this.loading) {
  72. event2.preventDefault();
  73. event2.stopPropagation();
  74. }
  75. }
  76. render() {
  77. const isLink = this.href ? true : false;
  78. const interior = T`
  79. <span part="prefix" class="button__prefix">
  80. <slot @slotchange=${this.handleSlotChange} name="prefix"></slot>
  81. </span>
  82. <span part="label" class="button__label">
  83. <slot @slotchange=${this.handleSlotChange}></slot>
  84. </span>
  85. <span part="suffix" class="button__suffix">
  86. <slot @slotchange=${this.handleSlotChange} name="suffix"></slot>
  87. </span>
  88. ${this.caret ? T`
  89. <span part="caret" class="button__caret">
  90. <svg
  91. viewBox="0 0 24 24"
  92. fill="none"
  93. stroke="currentColor"
  94. stroke-width="2"
  95. stroke-linecap="round"
  96. stroke-linejoin="round"
  97. >
  98. <polyline points="6 9 12 15 18 9"></polyline>
  99. </svg>
  100. </span>
  101. ` : ""}
  102. ${this.loading ? T`<sl-spinner></sl-spinner>` : ""}
  103. `;
  104. const button = T`
  105. <button
  106. part="base"
  107. class=${e2({
  108. button: true,
  109. "button--default": this.type === "default",
  110. "button--primary": this.type === "primary",
  111. "button--success": this.type === "success",
  112. "button--info": this.type === "info",
  113. "button--warning": this.type === "warning",
  114. "button--danger": this.type === "danger",
  115. "button--text": this.type === "text",
  116. "button--small": this.size === "small",
  117. "button--medium": this.size === "medium",
  118. "button--large": this.size === "large",
  119. "button--caret": this.caret,
  120. "button--circle": this.circle,
  121. "button--disabled": this.disabled,
  122. "button--focused": this.hasFocus,
  123. "button--loading": this.loading,
  124. "button--pill": this.pill,
  125. "button--has-label": this.hasLabel,
  126. "button--has-prefix": this.hasPrefix,
  127. "button--has-suffix": this.hasSuffix
  128. })}
  129. ?disabled=${this.disabled}
  130. type=${this.submit ? "submit" : "button"}
  131. name=${l(this.name)}
  132. value=${l(this.value)}
  133. @blur=${this.handleBlur}
  134. @focus=${this.handleFocus}
  135. @click=${this.handleClick}
  136. >
  137. ${interior}
  138. </button>
  139. `;
  140. const link = T`
  141. <a
  142. ref=${(el) => this.button = el}
  143. part="base"
  144. class=${e2({
  145. button: true,
  146. "button--default": this.type === "default",
  147. "button--primary": this.type === "primary",
  148. "button--success": this.type === "success",
  149. "button--info": this.type === "info",
  150. "button--warning": this.type === "warning",
  151. "button--danger": this.type === "danger",
  152. "button--text": this.type === "text",
  153. "button--small": this.size === "small",
  154. "button--medium": this.size === "medium",
  155. "button--large": this.size === "large",
  156. "button--caret": this.caret,
  157. "button--circle": this.circle,
  158. "button--disabled": this.disabled,
  159. "button--focused": this.hasFocus,
  160. "button--loading": this.loading,
  161. "button--pill": this.pill,
  162. "button--has-label": this.hasLabel,
  163. "button--has-prefix": this.hasPrefix,
  164. "button--has-suffix": this.hasSuffix
  165. })}
  166. href=${l(this.href)}
  167. target=${l(this.target)}
  168. download=${l(this.download)}
  169. rel=${l(this.target ? "noreferrer noopener" : void 0)}
  170. role="button"
  171. aria-disabled=${this.disabled ? "true" : "false"}
  172. tabindex=${this.disabled ? "-1" : "0"}
  173. @blur=${this.handleBlur}
  174. @focus=${this.handleFocus}
  175. @click=${this.handleClick}
  176. >
  177. ${interior}
  178. </a>
  179. `;
  180. return isLink ? link : button;
  181. }
  182. };
  183. SlButton.styles = r(button_default);
  184. __decorateClass([
  185. o(".button")
  186. ], SlButton.prototype, "button", 2);
  187. __decorateClass([
  188. r2()
  189. ], SlButton.prototype, "hasFocus", 2);
  190. __decorateClass([
  191. r2()
  192. ], SlButton.prototype, "hasLabel", 2);
  193. __decorateClass([
  194. r2()
  195. ], SlButton.prototype, "hasPrefix", 2);
  196. __decorateClass([
  197. r2()
  198. ], SlButton.prototype, "hasSuffix", 2);
  199. __decorateClass([
  200. e({ reflect: true })
  201. ], SlButton.prototype, "type", 2);
  202. __decorateClass([
  203. e({ reflect: true })
  204. ], SlButton.prototype, "size", 2);
  205. __decorateClass([
  206. e({ type: Boolean, reflect: true })
  207. ], SlButton.prototype, "caret", 2);
  208. __decorateClass([
  209. e({ type: Boolean, reflect: true })
  210. ], SlButton.prototype, "disabled", 2);
  211. __decorateClass([
  212. e({ type: Boolean, reflect: true })
  213. ], SlButton.prototype, "loading", 2);
  214. __decorateClass([
  215. e({ type: Boolean, reflect: true })
  216. ], SlButton.prototype, "pill", 2);
  217. __decorateClass([
  218. e({ type: Boolean, reflect: true })
  219. ], SlButton.prototype, "circle", 2);
  220. __decorateClass([
  221. e({ type: Boolean, reflect: true })
  222. ], SlButton.prototype, "submit", 2);
  223. __decorateClass([
  224. e()
  225. ], SlButton.prototype, "name", 2);
  226. __decorateClass([
  227. e()
  228. ], SlButton.prototype, "value", 2);
  229. __decorateClass([
  230. e()
  231. ], SlButton.prototype, "href", 2);
  232. __decorateClass([
  233. e()
  234. ], SlButton.prototype, "target", 2);
  235. __decorateClass([
  236. e()
  237. ], SlButton.prototype, "download", 2);
  238. __decorateClass([
  239. event("sl-blur")
  240. ], SlButton.prototype, "slBlur", 2);
  241. __decorateClass([
  242. event("sl-focus")
  243. ], SlButton.prototype, "slFocus", 2);
  244. SlButton = __decorateClass([
  245. n("sl-button")
  246. ], SlButton);
  247. var button_default2 = SlButton;
  248. export {
  249. button_default2 as button_default
  250. };