Skip to content

Commit

Permalink
build: add options to register components
Browse files Browse the repository at this point in the history
  • Loading branch information
pirhoo committed May 31, 2024
1 parent b420401 commit 393a1d4
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ type ComponentMap = {[name:string]:Component|DefineComponent}
type PluginOptions = {
useI18n?: boolean,
useBootstrap?: boolean,
useConfig?: boolean
useConfig?: boolean,
registerComponents?: boolean
}

const Murmur = {
Expand Down Expand Up @@ -84,7 +85,12 @@ const Murmur = {
// @ts-expect-error not sure why typescript sees an error here
return Murmur.i18n.global.locale.value
},
install(app: App<Element>, { useI18n = true, useBootstrap = true, useConfig = true }: PluginOptions = {}) {
install(app: App<Element>, {
useI18n = true,
useBootstrap = true,
useConfig = true,
registerComponents = true
}: PluginOptions = {}) {

if (useBootstrap) {
app.use(createBootstrap())
Expand All @@ -97,16 +103,19 @@ const Murmur = {
if (useConfig) {
app.config.globalProperties.$config = Murmur.config
}

if (registerComponents) {
Object.keys(this.components).forEach((key) =>
app.component(key, this.components[key])
)
Object.keys(this.datavisualisations).forEach((key) =>
app.component(key, this.datavisualisations[key])
)
Object.keys(this.maps).forEach((key) =>
app.component(key, this.maps[key])
)
}

Object.keys(this.components).forEach((key) =>
app.component(key, this.components[key])
)
Object.keys(this.datavisualisations).forEach((key) =>
app.component(key, this.datavisualisations[key])
)
Object.keys(this.maps).forEach((key) =>
app.component(key, this.maps[key])
)
}
}

Expand Down

0 comments on commit 393a1d4

Please sign in to comment.