-
Notifications
You must be signed in to change notification settings - Fork 4
/
vue3-plugin.js
48 lines (44 loc) · 1.17 KB
/
vue3-plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import * as Components from "./src/BIMDataComponents/index.js";
import * as Directives from "./src/BIMDataDirectives/index.js";
/**
* Register all components and directives from the design system.
*
* @param {
* {
* includedComponents?: string[],
* excludedComponents?: string[],
* directives?: boolean,
* }
* } [cfg]
*/
const pluginFactory = cfg => {
return {
install(app) {
// COMPONENTS
Object.entries(Components).forEach(([componentName, component]) => {
if (
cfg &&
cfg.excludedComponents &&
cfg.excludedComponents.length > 0 &&
cfg.excludedComponents.includes(componentName)
) {
return;
}
if (
!cfg ||
!cfg.includedComponents ||
cfg.includedComponents.includes(componentName)
) {
app.component(componentName, component);
}
});
// DIRECTIVES
if (!cfg || cfg.directives !== false) {
Object.entries(Directives).forEach(([directiveName, directive]) =>
app.directive(directiveName.split("BIMData")[1], directive)
);
}
},
};
};
export default pluginFactory;