UNPKG

@extclp/vexip-ui

Version:

A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good

1 lines 4.48 kB
{"version":3,"file":"create.mjs","sources":["../../components/create.ts"],"sourcesContent":["import { computed, unref } from 'vue'\r\n\r\nimport {\r\n configHoverDelay,\r\n configIcons,\r\n configLocale,\r\n configNamespace,\r\n configProps,\r\n configZIndex,\r\n} from '@vexip-ui/config'\r\nimport { isEmpty, toCapitalCase } from '@vexip-ui/utils'\r\n\r\nimport type { App, MaybeRef } from 'vue'\r\nimport type { IconsOptions, LocaleConfig, LocaleOptions } from '@vexip-ui/config'\r\nimport type { PropsOptions } from './props'\r\n\r\nexport interface InstallOptions {\r\n prefix?: string,\r\n namespace?: MaybeRef<string>,\r\n props?: MaybeRef<PropsOptions>,\r\n locale?: MaybeRef<LocaleOptions>,\r\n zIndex?: MaybeRef<number>,\r\n icons?: MaybeRef<IconsOptions>,\r\n hoverDelay?: MaybeRef<number>,\r\n}\r\n\r\nexport function buildInstall(components: any[] = [], defaultLocale?: LocaleConfig) {\r\n return function install(app: App, options: InstallOptions = {}) {\r\n const {\r\n prefix = '',\r\n namespace = '',\r\n props = {},\r\n locale = defaultLocale,\r\n zIndex,\r\n icons = {},\r\n hoverDelay = 100,\r\n } = options\r\n\r\n const withDefaultLocale = computed(() => {\r\n return { ...defaultLocale, ...unref(locale) }\r\n })\r\n\r\n configNamespace(namespace, app)\r\n configProps(props, app)\r\n configLocale(withDefaultLocale, app)\r\n configIcons(icons, app)\r\n configHoverDelay(hoverDelay, app)\r\n\r\n if (typeof unref(zIndex) === 'number') {\r\n configZIndex(zIndex!, app)\r\n }\r\n\r\n const normalizedPrefix = toCapitalCase(prefix || '')\r\n\r\n components.forEach(component => {\r\n if (typeof component === 'function' || typeof component.install === 'function') {\r\n app.use(component)\r\n } else {\r\n app.component(`${normalizedPrefix}${component.name}`, component)\r\n }\r\n })\r\n }\r\n}\r\n\r\n/**\r\n * Provide a props config for under components.\r\n *\r\n * @param props props config\r\n * @param app the app of Vue, will use app.provide if specify\r\n */\r\nfunction proxyConfigProps(props: MaybeRef<PropsOptions>, app?: App) {\r\n !isEmpty(props) && configProps(props, app)\r\n}\r\n\r\n/**\r\n * Provide supported config for under components.\r\n *\r\n * @param config supported config\r\n * @param app the app of Vue, will use app.provide if specify\r\n */\r\nexport function provideConfig(\r\n config: Omit<InstallOptions, 'prefix' | 'namespace'> = {},\r\n app?: App,\r\n) {\r\n const { props = {}, locale = {}, zIndex, icons = {} } = config\r\n\r\n proxyConfigProps(props, app)\r\n !isEmpty(locale) && configLocale(locale, app)\r\n !isEmpty(icons) && configIcons(icons, app)\r\n\r\n if (typeof unref(zIndex) === 'number') {\r\n configZIndex(zIndex!, app)\r\n }\r\n}\r\n\r\nexport { proxyConfigProps as configProps, configLocale, configZIndex, configIcons }\r\n"],"names":["buildInstall","components","defaultLocale","app","options","prefix","namespace","props","locale","zIndex","icons","hoverDelay","withDefaultLocale","computed","unref","configNamespace","configProps","configLocale","configIcons","configHoverDelay","configZIndex","normalizedPrefix","toCapitalCase","component","proxyConfigProps","isEmpty","provideConfig","config"],"mappings":";;;;AA0BO,SAASA,EAAaC,IAAoB,CAAC,GAAGC,GAA8B;AACjF,SAAO,SAAiBC,GAAUC,IAA0B,CAAA,GAAI;AACxD,UAAA;AAAA,MACJ,QAAAC,IAAS;AAAA,MACT,WAAAC,IAAY;AAAA,MACZ,OAAAC,IAAQ,CAAC;AAAA,MACT,QAAAC,IAASN;AAAA,MACT,QAAAO;AAAA,MACA,OAAAC,IAAQ,CAAC;AAAA,MACT,YAAAC,IAAa;AAAA,IAAA,IACXP,GAEEQ,IAAoBC,EAAS,OAC1B,EAAE,GAAGX,GAAe,GAAGY,EAAMN,CAAM,EAAE,EAC7C;AAED,IAAAO,EAAgBT,GAAWH,CAAG,GAC9Ba,EAAYT,GAAOJ,CAAG,GACtBc,EAAaL,GAAmBT,CAAG,GACnCe,EAAYR,GAAOP,CAAG,GACtBgB,EAAiBR,GAAYR,CAAG,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