1 |
- {"version":3,"file":"InputIcon.mjs","names":["VIcon","useLocale","useInputIcon","props","t","InputIcon","_ref","name","localeKey","prepend","prependInner","append","appendInner","clear","listener","label","undefined","_createVNode"],"sources":["../../../src/components/VInput/InputIcon.tsx"],"sourcesContent":["// Components\nimport { VIcon } from '@/components/VIcon'\n\n// Composables\nimport { useLocale } from '@/composables/locale'\n\n// Types\nimport type { IconValue } from '@/composables/icons'\n\ntype names = 'clear' | 'prepend' | 'append' | 'appendInner' | 'prependInner'\n\ntype EventProp<T = (...args: any[]) => any> = T | T[]\ntype InputIconProps<T extends names> = {\n label: string | undefined\n} & {\n [K in `${T}Icon`]: IconValue | undefined\n} & {\n [K in `onClick:${T}`]: EventProp | undefined\n}\n\ntype Listeners<T extends {}, U = keyof T> = U extends `onClick:${infer V extends names}` ? V : never\n\nexport function useInputIcon<T extends {}, K extends names = Listeners<T>> (props: T & InputIconProps<K>) {\n const { t } = useLocale()\n\n function InputIcon ({ name }: { name: Extract<names, K> }) {\n const localeKey = {\n prepend: 'prependAction',\n prependInner: 'prependAction',\n append: 'appendAction',\n appendInner: 'appendAction',\n clear: 'clear',\n }[name]\n const listener = props[`onClick:${name}`]\n const label = listener && localeKey\n ? t(`$vuetify.input.${localeKey}`, props.label ?? '')\n : undefined\n\n return (\n <VIcon\n icon={ props[`${name}Icon`] }\n aria-label={ label }\n onClick={ listener }\n />\n )\n }\n\n return { InputIcon }\n}\n"],"mappings":";AAAA;AAAA,SACSA,KAAK,8BAEd;AAAA,SACSC,SAAS,wCAElB;AAgBA,OAAO,SAASC,YAAYA,CAAgDC,KAA4B,EAAE;EACxG,MAAM;IAAEC;EAAE,CAAC,GAAGH,SAAS,EAAE;EAEzB,SAASI,SAASA,CAAAC,IAAA,EAAyC;IAAA,IAAvC;MAAEC;IAAkC,CAAC,GAAAD,IAAA;IACvD,MAAME,SAAS,GAAG;MAChBC,OAAO,EAAE,eAAe;MACxBC,YAAY,EAAE,eAAe;MAC7BC,MAAM,EAAE,cAAc;MACtBC,WAAW,EAAE,cAAc;MAC3BC,KAAK,EAAE;IACT,CAAC,CAACN,IAAI,CAAC;IACP,MAAMO,QAAQ,GAAGX,KAAK,CAAE,WAAUI,IAAK,EAAC,CAAC;IACzC,MAAMQ,KAAK,GAAGD,QAAQ,IAAIN,SAAS,GAC/BJ,CAAC,CAAE,kBAAiBI,SAAU,EAAC,EAAEL,KAAK,CAACY,KAAK,IAAI,EAAE,CAAC,GACnDC,SAAS;IAEb,OAAAC,YAAA,CAAAjB,KAAA;MAAA,QAEWG,KAAK,CAAE,GAAEI,IAAK,MAAK,CAAC;MAAA,cACdQ,KAAK;MAAA,WACRD;IAAQ;EAGxB;EAEA,OAAO;IAAET;EAAU,CAAC;AACtB"}
|