vuestic-ui
Version:
Vue 3 UI Framework
1 lines • 1.28 kB
Source Map (JSON)
{"version":3,"file":"useLocalConfig.mjs","sources":["../../../../src/composables/useLocalConfig.ts"],"sourcesContent":["import { inject, provide, computed, ComputedRef } from 'vue'\nimport { ComponentConfig } from '../services/component-config'\n\n/**\n * We need another key to provide injected value.\n */\nexport const LocalConfigKey = 'VaLocalConfig'\n\nexport const CONFIGS_DEFAULT = computed(() => [])\n\nexport function useLocalConfig (): ComputedRef<ComponentConfig[]> {\n return inject(LocalConfigKey, CONFIGS_DEFAULT)\n}\n\nexport function provideLocalConfig (config: ComputedRef<ComponentConfig[]>) {\n provide(LocalConfigKey, config)\n}\n\nexport function useLocalConfigProvider (config: ComputedRef<ComponentConfig>) {\n const prevChain = useLocalConfig()\n // We want it to be an array and not a merged object for optimization purposes\n const nextChain = computed(() => [...prevChain.value, config.value])\n\n provideLocalConfig(nextChain)\n}\n"],"names":[],"mappings":";AAMO,MAAM,iBAAiB;AAEvB,MAAM,kBAAkB,SAAS,MAAM,CAAA,CAAE;AAEzC,SAAS,iBAAkD;AACzD,SAAA,OAAO,gBAAgB,eAAe;AAC/C;AAEO,SAAS,mBAAoB,QAAwC;AAC1E,UAAQ,gBAAgB,MAAM;AAChC;AAEO,SAAS,uBAAwB,QAAsC;AAC5E,QAAM,YAAY;AAEZ,QAAA,YAAY,SAAS,MAAM,CAAC,GAAG,UAAU,OAAO,OAAO,KAAK,CAAC;AAEnE,qBAAmB,SAAS;AAC9B;"}