Skip to content

Commit bac14df

Browse files
committed
feat(exports): improve component importing
1 parent bd0edd4 commit bac14df

File tree

8 files changed

+86
-24
lines changed

8 files changed

+86
-24
lines changed

src/components/Anchor/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import Anchor from "./Anchor.vue";
33

44
import { registerComponent } from "../../utils/plugins/index";
55

6-
const Plugin = {
6+
const AnchorPlugin = {
77
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
88
install: (vue: Application) => {
99
registerComponent(vue, Anchor);
1010
}
1111
};
1212

13-
export default Plugin;
13+
export default Anchor;
1414

15-
export { Anchor };
15+
export { AnchorPlugin };

src/components/Button/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import Button from "./Button.vue";
33

44
import { registerComponent } from "../../utils/plugins/index";
55

6-
const Plugin = {
6+
const ButtonPlugin = {
77
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
88
install: (vue: Application) => {
99
registerComponent(vue, Button);
1010
}
1111
};
1212

13-
export default Plugin;
13+
// export default Plugin;
1414

15-
export { Button };
15+
export default Button;
16+
17+
export { ButtonPlugin };

src/components/Dropdown/index.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,40 @@
11
import { App as Application } from "vue";
2-
import Dropdown from "./Dropdown.vue";
2+
import {Dropdown, DropdownButton, DropdownItems, DropdownItem } from "./Dropdown.vue";
33

44
import { registerComponent } from "../../utils/plugins/index";
55

6-
const Plugin = {
6+
const DropdownPlugin = {
77
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
88
install(vue: Application) {
99
registerComponent(vue, Dropdown);
1010
},
1111
};
12+
const DropdownButtonPlugin = {
13+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
14+
install(vue: Application) {
15+
registerComponent(vue, DropdownButton);
16+
},
17+
};
18+
const DropdownItemsPlugin = {
19+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
20+
install(vue: Application) {
21+
registerComponent(vue, DropdownItems);
22+
},
23+
};
24+
const DropdownItemPlugin = {
25+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
26+
install(vue: Application) {
27+
registerComponent(vue, DropdownItem);
28+
},
29+
};
1230

13-
export default Plugin;
14-
15-
export { Dropdown };
31+
export {
32+
DropdownPlugin,
33+
DropdownButtonPlugin,
34+
DropdownItemsPlugin,
35+
DropdownItemPlugin,
36+
Dropdown,
37+
DropdownButton,
38+
DropdownItems,
39+
DropdownItem
40+
};

src/components/Table/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import Table from "./Table.vue";
33

44
import { registerComponent } from "../../utils/plugins/index";
55

6-
const Plugin = {
6+
const TablePlugin = {
77
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
88
install(vue: Application) {
99
registerComponent(vue, Table);
1010
},
1111
};
1212

13-
export default Plugin;
13+
export default Table;
1414

15-
export { Table };
15+
export { TablePlugin };

src/components/index.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
import Anchor from "./Anchor";
12
import Button from "./Button";
2-
import Dropdown from "./Dropdown";
3+
import {
4+
Dropdown,
5+
DropdownButton,
6+
DropdownItems,
7+
DropdownItem
8+
} from "./Dropdown";
39
import Table from "./Table";
410

5-
export { Button, Dropdown, Table };
11+
export {
12+
Anchor,
13+
Button,
14+
Dropdown,
15+
DropdownButton,
16+
DropdownItems,
17+
DropdownItem,
18+
Table,
19+
};

src/components/plugins.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {AnchorPlugin} from './Anchor';
2+
import { ButtonPlugin } from './Button';
3+
import {
4+
DropdownPlugin,
5+
DropdownButtonPlugin,
6+
DropdownItemsPlugin,
7+
DropdownItemPlugin
8+
} from "./Dropdown";
9+
import {TablePlugin } from "./Table";
10+
11+
export {
12+
AnchorPlugin,
13+
ButtonPlugin,
14+
DropdownPlugin,
15+
DropdownButtonPlugin,
16+
DropdownItemsPlugin,
17+
DropdownItemPlugin,
18+
TablePlugin
19+
};

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { App as Application, Plugin } from "vue";
2-
import * as components from "./components/index";
2+
import * as componentsAsPlugins from "./components/plugins";
33
import { setVueInstance } from "./utils/config/index";
44
import merge from "lodash.merge";
55
import { setup, silent } from "twind";
@@ -38,9 +38,9 @@ export default function pluginSetup(
3838
const install: Exclude<Plugin["install"], undefined> = (app: Application) => {
3939
// Components
4040
setVueInstance(app);
41-
for (const componentKey in components) {
41+
for (const componentKey in componentsAsPlugins) {
4242
// eslint-disable-next-line @typescript-eslint/no-explicit-any
43-
app.use((components as any)[componentKey]);
43+
app.use((componentsAsPlugins as any)[componentKey]);
4444
}
4545

4646
// Provide data to components

src/shims-vue.d.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
declare module '*.vue' {
2-
import type { DefineComponent } from 'vue'
3-
const component: DefineComponent<{}, {}, any>
4-
export default component
5-
}
1+
// declare module '*.vue' {
2+
// import type { DefineComponent } from 'vue'
3+
// const component: DefineComponent<{}, {}, any>
4+
// export default component
5+
// }
6+
7+
declare module '*.vue';
68

79
declare module 'prettier';
810
declare module 'prettier/standalone';

0 commit comments

Comments
 (0)