UNPKG

@dracoui/ember

Version:

Draco Design System for Ember

3 lines (2 loc) 4.97 kB
import{b as n}from"../../../_rollupPluginBabelHelpers-CLoDr8uC.js";import{DracoButtonSizeValues as t,DracoButtonColorValues as i,DracoButtonShapeValues as e,DracoButtonIconPositionValues as s}from"./types.js";import{assert as o}from"@ember/debug";import r from"@glimmer/component";import{precompileTemplate as a}from"@ember/template-compilation";import{setComponentTemplate as c}from"@ember/component";var l=a('{{#let (or @isRouteExternal this.isExternal) as |external|}}\n <Draco::Interactive\n class={{this.classNames}}\n @current-when={{@current-when}}\n @models={{@model}}\n @query={{@query}}\n @replace={{@replace}}\n @route={{@route}}\n @isRouteExternal={{@isRouteExternal}}\n @href={{@href}}\n @isHrefExternal={{@isHrefExternal}}\n ...attributes\n data-size={{@size}}\n aria-label={{if this.isIconOnly this.text null}}\n >\n {{#if this.loading}}\n <Draco::LoadingDots />\n {{else}}\n {{#if this.isIconOnly}}\n {{#if this.icon}}\n <span class="draco-button__icon">\n <Draco::Icon @name={{this.icon}} @size={{this.iconSize}} />\n </span>\n {{/if}}\n {{else}}\n {{#if (eq this.iconPosition "leading")}}\n {{#if this.icon}}\n <span class="draco-button__icon">\n <Draco::Icon @name={{this.icon}} @size={{this.iconSize}} />\n </span>\n {{/if}}\n\n {{#if this.text}}\n <span class="draco-button__text">\n {{this.text}}\n </span>\n {{/if}}\n\n {{yield}}\n\n {{#if (and this.displayExternalIcon external)}}\n <Draco::Icon\n @size={{11}}\n @name="lucide:external-link"\n class="draco-button--external-indicator"\n />\n {{/if}}\n {{else}}\n\n {{yield}}\n\n {{#if this.text}}\n <span class="draco-button__text">\n {{this.text}}\n </span>\n {{/if}}\n\n {{#if this.icon}}\n <span class="draco-button__icon">\n <Draco::Icon @name={{this.icon}} @size={{this.iconSize}} />\n </span>\n {{/if}}\n\n {{#if (and this.displayExternalIcon external)}}\n <Draco::Icon\n @size={{11}}\n @name="lucide:external-link"\n class="draco-button--external-indicator"\n />\n {{/if}}\n {{/if}}\n {{/if}}\n {{/if}}\n </Draco::Interactive>\n{{/let}}\n');const h=t.Medium,u=e.Square,d=i.Primary,f=s.Leading,m=Object.values(t),g=Object.values(i),p=Object.values(e),b=Object.values(s);class x extends r{constructor(...t){super(...t),n(this,"componentName","Draco::Button")}get text(){const{text:n}=this.args;return n??""}get size(){const{size:n=h}=this.args;return o(`@size for "${this.componentName}" must be one of the following ${m.join(", ")}; received: ${n}`,m.includes(n)),n}get displayExternalIcon(){const{displayExternalIcon:n=!0}=this.args;return o(`@route for "${this.componentName}" must be a valid 'boolean'; received: ${n}`,"boolean"==typeof n),n}get color(){const n=this.args.color||this.args.variant||this.args.type||d;return o(`@color for "${this.componentName}" must be one of the following: ${g.join(", ")}; received: ${n}`,g.includes(n)),n}get loading(){return this.args.loading??!1}get shape(){const{shape:n=u}=this.args;return o(`@shape for "${this.componentName}" must be one of the following: ${p.join(", ")}; received: ${n}`,p.includes(n)),n}get isFullWidth(){return this.args.isFullWidth??!1}get icon(){return this.args.icon??void 0}get isIconOnly(){return!!this.icon&&(this.args.isIconOnly??!1)}get iconSize(){const{iconSize:n,size:t}=this.args;if(!n)switch(t){case"small":return 16;case"medium":return 22;case"large":return 26}return n}get iconPosition(){const{iconPosition:n=f}=this.args;return o(`@iconPosition for "${this.componentName}" can't be used if @isIconOnly is '${this.args.isIconOnly}'`,!(this.args.iconPosition&&this.args.isIconOnly)),o(`@iconPosition for "${this.componentName}" must be one of the following: ${b.join(", ")}; received: ${n}`,b.includes(n)),n}get isExternal(){if(this.args.route&&!this.args.href)return!1;if(this.args.href)try{return new URL(this.args.href,window.location.origin).origin!==window.location.origin}catch(n){return!1}return!1}get classNames(){const n=["draco-button",`draco-button--${this.color}`,`draco-button--${this.shape}`,`draco-button--${this.size}`];return this.isFullWidth&&n.push("draco-button--width-full"),this.args.isInline&&n.push("draco-button--is-inline"),this.isIconOnly&&n.push("draco-button--icon-only"),this.loading&&n.push("mock-disabled"),n.join(" ")}}c(l,x);export{g as AVAILABLE_COLORS,b as AVAILABLE_ICON_POSITIONS,p as AVAILABLE_SHAPES,m as AVAILABLE_SIZES,d as DEFAULT_COLOR,f as DEFAULT_ICON_POSITION,u as DEFAULT_SHAPE,h as DEFAULT_SIZE,x as default}; //# sourceMappingURL=index.js.map