UNPKG

vuestic-ui

Version:
1 lines 2.75 kB
{"version":3,"file":"create-vuestic-essential.mjs","sources":["../../../../../../src/services/vue-plugin/create-vuestic/create-vuestic-essential.ts"],"sourcesContent":["import type { VuesticComponent, VuesticPlugin, VuesticPluginFabric } from '../types'\nimport { defineVuesticPlugin } from '../utils/define-vuestic-plugin'\nimport type { PartialGlobalConfig } from '../../global-config/global-config'\nimport { usePlugin } from '../utils'\nimport { setCurrentApp } from '../../current-app'\n\nimport { GlobalConfigPlugin, ColorConfigPlugin, CachePlugin } from '../plugins'\n\nconst ESSENTIAL_PLUGIN_NAMES = ['GlobalConfigPlugin', 'ColorConfigPlugin']\n\n/**\n * Register only essential Vuestic Plugins.\n *\n * This plugin will register globally only provided component and plugins in options.\n * @notice this plugin will not bundle all vuestic components and plugins\n *\n * @example\n * ```ts\n * createVuesticEssential({\n * plugins: [VaToastPlugin], // or [VaToastPlugin({ makeLifeEasier: true })],\n * components: { VaButton, VaInput },\n * config: { VaButton: { color: '#f0f' } }\n * })\n * ```\n */\nexport const createVuesticEssential = defineVuesticPlugin((options: {\n config?: PartialGlobalConfig,\n components?: Record<string, VuesticComponent>,\n plugins?: Record<string, VuesticPlugin | VuesticPluginFabric>\n } = {}) => ({\n install (app) {\n const { config, components, plugins } = options\n\n setCurrentApp(app)\n\n // These plugins have dependant plugins, so have to be registered first.\n usePlugin(app, plugins?.GlobalConfigPlugin || GlobalConfigPlugin, config)\n usePlugin(app, plugins?.CachePlugin || CachePlugin)\n usePlugin(app, plugins?.ColorConfigPlugin || ColorConfigPlugin, config)\n\n if (plugins) {\n Object.entries(plugins).forEach(([name, plugin]) => {\n if (ESSENTIAL_PLUGIN_NAMES.includes(name)) { return }\n usePlugin(app, plugin)\n })\n }\n\n if (components) {\n Object.entries(components).forEach(([name, component]) => {\n app.component(name, component)\n })\n }\n\n setCurrentApp(null)\n },\n}))\n"],"names":[],"mappings":";;;;;;AAQA,MAAM,yBAAyB,CAAC,sBAAsB,mBAAmB;AAiBlE,MAAM,yBAAyB,oBAAoB,CAAC,UAItD,QAAQ;AAAA,EACX,QAAS,KAAK;AACZ,UAAM,EAAE,QAAQ,YAAY,QAAA,IAAY;AAExC,kBAAc,GAAG;AAGjB,cAAU,MAAK,mCAAS,uBAAsB,oBAAoB,MAAM;AAC9D,cAAA,MAAK,mCAAS,gBAAe,WAAW;AAClD,cAAU,MAAK,mCAAS,sBAAqB,mBAAmB,MAAM;AAEtE,QAAI,SAAS;AACJ,aAAA,QAAQ,OAAO,EAAE,QAAQ,CAAC,CAAC,MAAM,MAAM,MAAM;AAC9C,YAAA,uBAAuB,SAAS,IAAI,GAAG;AAAE;AAAA,QAAO;AACpD,kBAAU,KAAK,MAAM;AAAA,MAAA,CACtB;AAAA,IACH;AAEA,QAAI,YAAY;AACP,aAAA,QAAQ,UAAU,EAAE,QAAQ,CAAC,CAAC,MAAM,SAAS,MAAM;AACpD,YAAA,UAAU,MAAM,SAAS;AAAA,MAAA,CAC9B;AAAA,IACH;AAEA,kBAAc,IAAI;AAAA,EACpB;AACF,EAAE;"}