1 |
- {"version":3,"file":"icons.mjs","names":["aliases","mdi","computed","inject","unref","defineComponent","genericComponent","mergeDeep","propsFactory","IconValue","String","Function","Object","Array","IconSymbol","Symbol","for","makeIconProps","icon","type","tag","required","VComponentIcon","name","props","setup","_ref","slots","Icon","_createVNode","default","VSvgIcon","inheritAttrs","_ref2","attrs","_mergeProps","isArray","map","path","VLigatureIcon","VClassIcon","defaultSets","svg","component","class","createIcons","options","defaultSet","sets","vuetify","useIcon","icons","Error","iconData","iconAlias","trim","startsWith","slice","iconSetName","keys","find","setName","iconName","length","iconSet"],"sources":["../../src/composables/icons.tsx"],"sourcesContent":["// Icons\nimport { aliases, mdi } from '@/iconsets/mdi'\n\n// Utilities\nimport { computed, inject, unref } from 'vue'\nimport { defineComponent, genericComponent, mergeDeep, propsFactory } from '@/util'\n\n// Types\nimport type { InjectionKey, JSXComponent, PropType, Ref } from 'vue'\n\nexport type IconValue =\n | string\n | (string | [path: string, opacity: number])[]\n | JSXComponent\nexport const IconValue = [String, Function, Object, Array] as PropType<IconValue>\n\nexport interface IconAliases {\n [name: string]: IconValue\n complete: IconValue\n cancel: IconValue\n close: IconValue\n delete: IconValue\n clear: IconValue\n success: IconValue\n info: IconValue\n warning: IconValue\n error: IconValue\n prev: IconValue\n next: IconValue\n checkboxOn: IconValue\n checkboxOff: IconValue\n checkboxIndeterminate: IconValue\n delimiter: IconValue\n sortAsc: IconValue\n sortDesc: IconValue\n expand: IconValue\n menu: IconValue\n subgroup: IconValue\n dropdown: IconValue\n radioOn: IconValue\n radioOff: IconValue\n edit: IconValue\n ratingEmpty: IconValue\n ratingFull: IconValue\n ratingHalf: IconValue\n loading: IconValue\n first: IconValue\n last: IconValue\n unfold: IconValue\n file: IconValue\n plus: IconValue\n minus: IconValue\n calendar: IconValue\n}\n\nexport interface IconProps {\n tag: string\n icon?: IconValue\n disabled?: Boolean\n}\n\ntype IconComponent = JSXComponent<IconProps>\n\nexport interface IconSet {\n component: IconComponent\n}\n\nexport type IconOptions = {\n defaultSet?: string\n aliases?: Partial<IconAliases>\n sets?: Record<string, IconSet>\n}\n\ntype IconInstance = {\n component: IconComponent\n icon?: IconValue\n}\n\nexport const IconSymbol: InjectionKey<Required<IconOptions>> = Symbol.for('vuetify:icons')\n\nexport const makeIconProps = propsFactory({\n icon: {\n type: IconValue,\n },\n // Could not remove this and use makeTagProps, types complained because it is not required\n tag: {\n type: String,\n required: true,\n },\n}, 'icon')\n\nexport const VComponentIcon = genericComponent()({\n name: 'VComponentIcon',\n\n props: makeIconProps(),\n\n setup (props, { slots }) {\n return () => {\n const Icon = props.icon as JSXComponent\n return (\n <props.tag>\n { props.icon ? <Icon /> : slots.default?.() }\n </props.tag>\n )\n }\n },\n})\nexport type VComponentIcon = InstanceType<typeof VComponentIcon>\n\nexport const VSvgIcon = defineComponent({\n name: 'VSvgIcon',\n\n inheritAttrs: false,\n\n props: makeIconProps(),\n\n setup (props, { attrs }) {\n return () => {\n return (\n <props.tag { ...attrs } style={ null }>\n <svg\n class=\"v-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n role=\"img\"\n aria-hidden=\"true\"\n >\n { Array.isArray(props.icon)\n ? props.icon.map(path => (\n Array.isArray(path)\n ? <path d={ path[0] as string } fill-opacity={ path[1] }></path>\n : <path d={ path as string }></path>\n ))\n : <path d={ props.icon as string }></path>\n }\n </svg>\n </props.tag>\n )\n }\n },\n})\nexport type VSvgIcon = InstanceType<typeof VSvgIcon>\n\nexport const VLigatureIcon = defineComponent({\n name: 'VLigatureIcon',\n\n props: makeIconProps(),\n\n setup (props) {\n return () => {\n return <props.tag>{ props.icon }</props.tag>\n }\n },\n})\nexport type VLigatureIcon = InstanceType<typeof VLigatureIcon>\n\nexport const VClassIcon = defineComponent({\n name: 'VClassIcon',\n\n props: makeIconProps(),\n\n setup (props) {\n return () => {\n return <props.tag class={ props.icon }></props.tag>\n }\n },\n})\nexport type VClassIcon = InstanceType<typeof VClassIcon>\n\nexport const defaultSets: Record<string, IconSet> = {\n svg: {\n component: VSvgIcon,\n },\n class: {\n component: VClassIcon,\n },\n}\n\n// Composables\nexport function createIcons (options?: IconOptions) {\n return mergeDeep({\n defaultSet: 'mdi',\n sets: {\n ...defaultSets,\n mdi,\n },\n aliases: {\n ...aliases,\n /* eslint-disable max-len */\n vuetify: [\n 'M8.2241 14.2009L12 21L22 3H14.4459L8.2241 14.2009Z',\n ['M7.26303 12.4733L7.00113 12L2 3H12.5261C12.5261 3 12.5261 3 12.5261 3L7.26303 12.4733Z', 0.6],\n ],\n 'vuetify-outline': 'svg:M7.26 12.47 12.53 3H2L7.26 12.47ZM14.45 3 8.22 14.2 12 21 22 3H14.45ZM18.6 5 12 16.88 10.51 14.2 15.62 5ZM7.26 8.35 5.4 5H9.13L7.26 8.35Z',\n /* eslint-enable max-len */\n },\n }, options)\n}\n\nexport const useIcon = (props: Ref<IconValue | undefined>) => {\n const icons = inject(IconSymbol)\n\n if (!icons) throw new Error('Missing Vuetify Icons provide!')\n\n const iconData = computed<IconInstance>(() => {\n const iconAlias = unref(props)\n\n if (!iconAlias) return { component: VComponentIcon }\n\n let icon: IconValue | undefined = iconAlias\n\n if (typeof icon === 'string') {\n icon = icon.trim()\n\n if (icon.startsWith('$')) {\n icon = icons.aliases?.[icon.slice(1)]\n }\n }\n\n if (!icon) throw new Error(`Could not find aliased icon \"${iconAlias}\"`)\n\n if (Array.isArray(icon)) {\n return {\n component: VSvgIcon,\n icon,\n }\n } else if (typeof icon !== 'string') {\n return {\n component: VComponentIcon,\n icon,\n }\n }\n\n const iconSetName = Object.keys(icons.sets).find(\n setName => typeof icon === 'string' && icon.startsWith(`${setName}:`)\n )\n\n const iconName = iconSetName ? icon.slice(iconSetName.length + 1) : icon\n const iconSet = icons.sets[iconSetName ?? icons.defaultSet]\n\n return {\n component: iconSet.component,\n icon: iconName,\n }\n })\n\n return { iconData }\n}\n"],"mappings":";AAAA;AAAA,SACSA,OAAO,EAAEC,GAAG,+BAErB;A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