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B,CAG3B;;AACA,QAAI,IAAI,CAAC,QAAT,EAAmB;AACjB,MAAA,QAAQ,GAAG,IAAI,CAAC,QAAL,CAAc,WAAd,IACT,IAAI,CAAC,QAAL,CAAc,SADL,IAET,QAFF,CADiB,CAKjB;AACA;;AACA,aAAO,IAAI,CAAC,QAAL,CAAc,WAArB;AACA,aAAO,IAAI,CAAC,QAAL,CAAc,SAArB;AACD;;AAED,WAAO,CAAC,CAAC,KAAD,EAAQ,IAAR,EAAc,QAAQ,GAAG,CAAC,QAAD,CAAH,GAAgB,QAAtC,CAAR;AACD;;AAvBuB,CAAX,CAAf","sourcesContent":["import './VIcon.sass'\n// Mixins\nimport Colorable from '../../mixins/colorable'\nimport Sizeable from '../../mixins/sizeable'\nimport Themeable from '../../mixins/themeable'\n// Util\nimport { convertToUnit, keys, remapInternalIcon } from '../../util/helpers'\n// Types\nimport Vue, { CreateElement, VNode, VNodeChildren, VNodeData } from 'vue'\nimport mixins from '../../util/mixins'\nimport { VuetifyIcon, VuetifyIconComponent } from 'vuetify/types/services/icons'\n\nenum SIZE_MAP {\n xSmall = '12px',\n small = '16px',\n default = '24px',\n medium = '28px',\n large = '36px',\n xLarge = '40px'\n}\n\nfunction isFontAwesome5 (iconType: string): boolean {\n return ['fas', 'far', 'fal', 'fab'].some(val => iconType.includes(val))\n}\n\nfunction isSvgPath (icon: string): boolean {\n return (/^[mzlhvcsqta]\\s*[-+.0-9][^mlhvzcsqta]+/i.test(icon) && /[\\dz]$/i.test(icon) && icon.length > 4)\n}\n\nconst VIcon = mixins(\n Colorable,\n Sizeable,\n Themeable\n /* @vue/component */\n).extend({\n name: 'v-icon',\n\n props: {\n dense: Boolean,\n disabled: Boolean,\n left: Boolean,\n right: Boolean,\n size: [Number, String],\n tag: {\n type: String,\n required: false,\n default: 'i',\n },\n },\n\n computed: {\n medium () {\n return false\n },\n },\n\n methods: {\n getIcon (): VuetifyIcon {\n let iconName = ''\n if (this.$slots.default) iconName = this.$slots.default[0].text!.trim()\n\n return remapInternalIcon(this, iconName)\n },\n getSize (): string | undefined {\n const sizes = {\n xSmall: this.xSmall,\n small: this.small,\n medium: this.medium,\n large: this.large,\n xLarge: this.xLarge,\n }\n\n const explicitSize = keys(sizes).find(key => sizes[key])\n\n return (\n (explicitSize && SIZE_MAP[explicitSize]) || convertToUnit(this.size)\n )\n },\n // Component data for both font and svg icon.\n getDefaultData (): VNodeData {\n const hasClickListener = Boolean(\n this.$listeners.click || this.$listeners['!click']\n )\n const data: VNodeData = {\n staticClass: 'v-icon notranslate',\n class: {\n 'v-icon--disabled': this.disabled,\n 'v-icon--left': this.left,\n 'v-icon--link': hasClickListener,\n 'v-icon--right': this.right,\n 'v-icon--dense': this.dense,\n },\n attrs: {\n 'aria-hidden': !hasClickListener,\n role: hasClickListener ? 'button' : null,\n ...this.$attrs,\n },\n on: this.$listeners,\n }\n\n return data\n },\n applyColors (data: VNodeData): void {\n data.class = { ...data.class, ...this.themeClasses }\n this.setTextColor(this.color, data)\n },\n renderFontIcon (icon: string, h: CreateElement): VNode {\n const newChildren: VNodeChildren = []\n const data = this.getDefaultData()\n\n let iconType = 'material-icons'\n // Material Icon delimiter is _\n // https://material.io/icons/\n const delimiterIndex = icon.indexOf('-')\n const isMaterialIcon = delimiterIndex <= -1\n\n if (isMaterialIcon) {\n // Material icon uses ligatures.\n newChildren.push(icon)\n } else {\n iconType = icon.slice(0, delimiterIndex)\n if (isFontAwesome5(iconType)) iconType = ''\n }\n\n data.class[iconType] = true\n data.class[icon] = !isMaterialIcon\n\n const fontSize = this.getSize()\n if (fontSize) data.style = { fontSize }\n\n this.applyColors(data)\n\n return h(this.tag, data, newChildren)\n },\n renderSvgIcon (icon: string, h: CreateElement): VNode {\n const data = this.getDefaultData()\n data.class['v-icon--svg'] = true\n\n data.attrs = {\n xmlns: 'http://www.w3.org/2000/svg',\n viewBox: '0 0 24 24',\n height: '24',\n width: '24',\n role: 'img',\n 'aria-hidden': !this.$attrs['aria-label'],\n 'aria-label': this.$attrs['aria-label'],\n }\n\n const fontSize = this.getSize()\n if (fontSize) {\n data.style = {\n fontSize,\n height: fontSize,\n width: fontSize,\n }\n data.attrs.height = fontSize\n data.attrs.width = fontSize\n }\n\n this.applyColors(data)\n\n return h('svg', data, [\n h('path', {\n attrs: {\n d: icon,\n },\n }),\n ])\n },\n renderSvgIconComponent (\n icon: VuetifyIconComponent,\n h: CreateElement\n ): VNode {\n const data = this.getDefaultData()\n data.class['v-icon--is-component'] = true\n\n const size = this.getSize()\n if (size) {\n data.style = {\n fontSize: size,\n height: size,\n }\n }\n\n this.applyColors(data)\n\n const component = icon.component\n data.props = icon.props\n data.nativeOn = data.on\n\n return h(component, data)\n },\n },\n\n render (h: CreateElement): VNode {\n const icon = this.getIcon()\n\n if (typeof icon === 'string') {\n if (isSvgPath(icon)) {\n return this.renderSvgIcon(icon, h)\n }\n return this.renderFontIcon(icon, h)\n }\n\n return this.renderSvgIconComponent(icon, h)\n },\n})\n\nexport default Vue.extend({\n name: 'v-icon',\n\n $_wrapperFor: VIcon,\n\n functional: true,\n\n render (h, { data, children }): VNode {\n let iconName = ''\n\n // Support usage of v-text and v-html\n if (data.domProps) {\n iconName = data.domProps.textContent ||\n data.domProps.innerHTML ||\n iconName\n\n // Remove nodes so it doesn't\n // overwrite our changes\n delete data.domProps.textContent\n delete data.domProps.innerHTML\n }\n\n return h(VIcon, data, iconName ? [iconName] : children)\n },\n})\n"],"sourceRoot":"","file":"VIcon.js"} |