bootstrap-vue-next
Version:
Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development
1 lines • 1.08 kB
Source Map (JSON)
{"version":3,"file":"useNumberishToStyle-uj-NwKpF.mjs","names":[],"sources":["../src/composables/useNumberishToStyle.ts"],"sourcesContent":["import {computed, type MaybeRefOrGetter, toValue} from 'vue'\nimport type {Numberish} from '../types/CommonTypes'\nimport {RX_NUMBER} from '../utils/constants'\n\nexport const useNumberishToStyle = (\n el: MaybeRefOrGetter<Numberish | undefined>,\n /**\n * The unit to use when converting a numeric value to a string\n *\n * @default 'px'\n */\n unit: MaybeRefOrGetter<string> = 'px'\n) =>\n computed(() => {\n const value = toValue(el)\n const resolvedUnit = toValue(unit)\n // If num is non-numeric, return val as-is (sm, md, lg, undefined or any other custom value), otherwise return num as a px value\n return RX_NUMBER.test(String(value))\n ? `${Number(value)}${resolvedUnit}`\n : (value as string | undefined)\n })\n"],"mappings":";;;AAIA,IAAa,uBACX,IAMA,OAAiC,SAEjC,eAAe;CACb,MAAM,QAAQ,QAAQ,GAAG;CACzB,MAAM,eAAe,QAAQ,KAAK;AAElC,QAAO,UAAU,KAAK,OAAO,MAAM,CAAC,GAChC,GAAG,OAAO,MAAM,GAAG,iBAClB;EACL"}