UNPKG

casc-cesium

Version:

Vue 3.x components for CesiumJS.

1 lines 12.7 kB
{"version":3,"file":"index.mjs","sources":["../../../../../../packages/components/ui/icon/index.ts"],"sourcesContent":["import { h, defineComponent, computed, VNode, ComponentPublicInstance } from 'vue'\nimport type { CSSProperties } from 'vue'\nimport useSize, { useSizeProps } from 'casc-cesium-composables/private/use-size'\nimport { hMergeSlot, hSlot } from 'casc-cesium-utils/private/render'\n\nexport const iconProps = {\n ...useSizeProps,\n\n tag: {\n type: String,\n default: 'i'\n },\n\n name: String,\n color: String,\n hoverColor: String,\n left: Boolean,\n right: Boolean\n}\nexport default defineComponent({\n name: 'VcIcon',\n props: iconProps,\n setup(props: VcIconProps, { slots }) {\n const sizeStyle = useSize(props)\n const style = computed(() => {\n const css: CSSProperties | null = sizeStyle.value\n if (!css) {\n return undefined\n }\n props.color && (css.color = props.color)\n props.hoverColor && (css['--hover-color'] = props.hoverColor)\n return css\n })\n\n const classes = computed(\n () =>\n 'vc-icon' +\n (props.left === true ? ' on-left' : '') +\n (props.right === true ? ' on-right' : '') +\n (props.color !== void 0 ? ` text-${props.color}` : '')\n )\n\n const type = computed(() => {\n let cls\n let icon = props.name\n\n if (!icon) {\n return {\n none: true,\n cls: classes.value\n }\n }\n\n if (icon.startsWith('M') === true) {\n const [def, viewBox] = icon.split('|')\n\n return {\n svg: true,\n cls: classes.value,\n nodes: def.split('&&').map(path => {\n const [d, style, transform] = path.split('@@')\n return h('path', {\n style,\n d,\n transform\n })\n }),\n viewBox: viewBox !== void 0 ? viewBox : '0 0 24 24'\n }\n }\n\n if (icon.startsWith('img:') === true) {\n return {\n img: true,\n cls: classes.value,\n src: icon.substring(4)\n }\n }\n\n if (icon.startsWith('svguse:') === true) {\n const [def, viewBox] = icon.split('|')\n\n return {\n svguse: true,\n cls: classes.value,\n src: def.substring(7),\n viewBox: viewBox !== void 0 ? viewBox : '0 0 24 24'\n }\n }\n\n let content = ' '\n\n if (/^[l|f]a[s|r|l|b|d]{0,1} /.test(icon) || icon.startsWith('icon-') === true) {\n cls = icon\n } else if (icon.startsWith('bt-') === true) {\n cls = `bt ${icon}`\n } else if (icon.startsWith('eva-') === true) {\n cls = `eva ${icon}`\n } else if (/^ion-(md|ios|logo)/.test(icon) === true) {\n cls = `ionicons ${icon}`\n } else if (icon.startsWith('ion-') === true) {\n cls = `ionicons ion-md${icon.substr(3)}`\n } else if (icon.startsWith('mdi-') === true) {\n cls = `mdi ${icon}`\n } else if (icon.startsWith('iconfont ') === true) {\n cls = `${icon}`\n } else if (icon.startsWith('ti-') === true) {\n cls = `themify-icon ${icon}`\n } else if (icon.startsWith('vc-') === true) {\n cls = `vc-icons ${icon}`\n } else {\n // \"notranslate\" class is for Google Translate\n // to avoid tampering with Material Icons ligature font\n //\n // Caution: To be able to add suffix to the class name,\n // keep the 'material-icons' at the end of the string.\n cls = 'notranslate material-icons'\n\n if (icon.startsWith('o_') === true) {\n icon = icon.substring(2)\n cls += '-outlined'\n } else if (icon.startsWith('r_') === true) {\n icon = icon.substring(2)\n cls += '-round'\n } else if (icon.startsWith('s_') === true) {\n icon = icon.substring(2)\n cls += '-sharp'\n }\n\n content = icon\n }\n\n return {\n cls: cls + ' ' + classes.value,\n content\n }\n })\n\n return () => {\n const data = {\n class: type.value.cls,\n style: style.value,\n 'aria-hidden': 'true',\n role: 'presentation',\n viewBox: '',\n src: ''\n }\n\n if (type.value.none === true) {\n return h(props.tag, data, hSlot(slots.default))\n }\n\n if (type.value.img === true) {\n data.src = type.value.src\n if (data.style) {\n data.style.width = data.style.fontSize\n data.style.height = data.style.fontSize\n }\n return h('img', data)\n }\n\n if (type.value.svg === true) {\n data.viewBox = type.value.viewBox\n data['aria-hidden'] = 'true'\n\n if (data.style) {\n data.style.width = data.style.fontSize\n data.style.height = data.style.fontSize\n }\n\n return h('svg', data, hMergeSlot(slots.default, type.value.nodes))\n }\n\n if (type.value.svguse === true) {\n data.viewBox = type.value.viewBox\n data['aria-hidden'] = 'true'\n\n if (data.style) {\n data.style.width = data.style.fontSize\n data.style.height = data.style.fontSize\n }\n return h('svg', data, hMergeSlot(slots.default, [h('use', { 'xlink:href': type.value.src })]))\n }\n\n return h(props.tag, data, hMergeSlot(slots.default, [type.value.content]))\n }\n }\n})\n\nexport interface VcIconProps {\n /**\n * Size in CSS units, including unit name or standard size name (xs|sm|md|lg|xl).\n */\n size?: string\n /**\n * HTML tag to render, unless no icon is supplied or it's an svg icon.\n * Default value: i\n */\n tag?: string\n /**\n * Name of the icon, following VueCesium convention.\n */\n name?: string\n /**\n * Color name for component from the css color palette.\n */\n color?: string\n hoverColor?: string\n /**\n * Useful if icon is on the left side of something: applies a standard margin on the right side of Icon.\n */\n left?: boolean\n /**\n * Useful if icon is on the right side of something: applies a standard margin on the left side of Icon.\n */\n right?: boolean\n}\n\nexport interface VcIconSlots {\n /**\n * Suggestions: VcTooltip\n */\n default: () => VNode[]\n}\n\nexport type VcIconRef = ComponentPublicInstance<VcIconProps>\n"],"names":[],"mappings":";;;;AAGY,MAAC,SAAS,GAAG;AACzB,EAAE,GAAG,YAAY;AACjB,EAAE,GAAG,EAAE;AACP,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,GAAG;AAChB,GAAG;AACH,EAAE,IAAI,EAAE,MAAM;AACd,EAAE,KAAK,EAAE,MAAM;AACf,EAAE,UAAU,EAAE,MAAM;AACpB,EAAE,IAAI,EAAE,OAAO;AACf,EAAE,KAAK,EAAE,OAAO;AAChB,EAAE;AACF,WAAe,eAAe,CAAC;AAC/B,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,KAAK,EAAE,SAAS;AAClB,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE;AAC1B,IAAI,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AACrC,IAAI,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM;AACjC,MAAM,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC;AAClC,M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