UNPKG

@dracoui/ember

Version:

Draco Design System for Ember

3 lines (2 loc) 2.97 kB
import{DracoLinkSizeValues as e,DracoLinkIconPositionValues as n}from"./types.js";import{assert as i}from"@ember/debug";import t from"@glimmer/component";import{precompileTemplate as r}from"@ember/template-compilation";import{setComponentTemplate as o}from"@ember/component";var s=r('{{#let (or @isRouteExternal this.isExternal) as |external|}}\n <Draco::Interactive\n class={{this.classNames}}\n @current-when={{@current-when}}\n @models={{draco-link-to-models @model}}\n @query={{draco-link-to-query @query}}\n @replace={{@replace}}\n @route={{@route}}\n @isRouteExternal={{external}}\n @href={{@href}}\n @isHrefExternal={{external}}\n ...attributes\n aria-label={{if this.isIconOnly this.text null}}\n >\n {{#if (eq this.iconPosition "leading")}}\n {{#if this.icon}}\n <Draco::Icon @name={{this.icon}} @size={{this.iconSize}} />\n {{/if}}\n {{/if}}\n\n {{yield}}\n\n {{#if this.text}}\n <span class="draco-link__text {{if this.underline "draco-link--underline"}}">\n {{this.text}}\n </span>\n {{/if}}\n\n {{#if (eq this.iconPosition "trailing")}}\n {{#if this.icon}}\n <Draco::Icon @name={{this.icon}} @size={{this.iconSize}} />\n {{/if}}\n {{/if}}\n\n {{#if (and (and this.displayExternalIcon external) (eq this.iconPosition "leading"))}}\n <Draco::Icon\n @size={{11}}\n @name="lucide:external-link"\n class="draco-link--external-indicator"\n />\n {{/if}}\n </Draco::Interactive>\n{{/let}}\n');const a=e.Medium,c=n.Leading,l=Object.values(e),u=Object.values(n);class h extends t{constructor(e,n){super(e,n),this.args.href||this.args.route||i("@href or @route must be defined for <Draco::Link>")}get text(){return this.args.text??void 0}get displayExternalIcon(){const{displayExternalIcon:e=!0}=this.args;return i(`@route for "Draco::Link" must be a valid 'boolean'; received: ${e}`,"boolean"==typeof e),e}get size(){const{size:e=a}=this.args;return i(`@size for "Draco::Link" must be a valid 'number' or one of the following ${l.join(", ")}; received: ${e}`,"number"==typeof e||l.includes(e)),e}get icon(){return this.args.icon??void 0}get iconSize(){const{iconSize:e,size:n}=this.args;if(!e)switch(n){case"small":return 16;case"medium":return 22;case"large":return 26}return e}get iconPosition(){const{iconPosition:e=c}=this.args;return i(`@iconPosition for "Draco::Link" must be one of the following: ${u.join(", ")}; received: ${e}`,u.includes(e)),e}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(e){return!1}return!1}get classNames(){const e=["draco-link"];return"number"!=typeof this.size&&e.push(`draco-link--size-${this.size}`),e.join(" ")}}o(s,h);export{u as AVAILABLE_ICON_POSITIONS,l as AVAILABLE_SIZES,c as DEFAULT_ICON_POSITION,h as default}; //# sourceMappingURL=index.js.map