Skip to content

Commit fdecafb

Browse files
committed
feat: support vite-plugin-components
1 parent 22141e7 commit fdecafb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+515
-466
lines changed

components/auto-complete/OptGroup.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { FunctionalComponent } from 'vue';
2+
import { OptionGroupData } from '../vc-select/interface';
3+
4+
export type OptGroupProps = Omit<OptionGroupData, 'options'>;
5+
6+
export interface OptionGroupFC extends FunctionalComponent<OptGroupProps> {
7+
/** Legacy for check if is a Option Group */
8+
isSelectOptGroup: boolean;
9+
}
10+
11+
const OptGroup: OptionGroupFC = () => null;
12+
OptGroup.isSelectOptGroup = true;
13+
OptGroup.displayName = 'AAutoCompleteOptGroup';
14+
export default OptGroup;

components/auto-complete/Option.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { FunctionalComponent } from 'vue';
2+
import { OptionCoreData } from '../vc-select/interface';
3+
4+
export interface OptionProps extends Omit<OptionCoreData, 'label'> {
5+
/** Save for customize data */
6+
[prop: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any
7+
}
8+
9+
export interface OptionFC extends FunctionalComponent<OptionProps> {
10+
/** Legacy for check if is a Option Group */
11+
isSelectOption: boolean;
12+
}
13+
14+
const Option: OptionFC = () => null;
15+
Option.isSelectOption = true;
16+
Option.displayName = 'AAutoCompleteOption';
17+
export default Option;

components/auto-complete/index.tsx

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { App, defineComponent, inject, provide, Plugin, VNode } from 'vue';
1+
import { App, defineComponent, inject, provide, Plugin, VNode, ExtractPropTypes } from 'vue';
22
import Select, { SelectProps } from '../select';
33
import Input from '../input';
44
import InputElement from './InputElement';
@@ -7,26 +7,32 @@ import { defaultConfigProvider } from '../config-provider';
77
import { getComponent, getOptionProps, isValidElement, getSlot } from '../_util/props-util';
88
import Omit from 'omit.js';
99
import warning from '../_util/warning';
10-
11-
const { Option, OptGroup } = Select;
10+
import Option from './Option';
11+
import OptGroup from './OptGroup';
1212

1313
function isSelectOptionOrSelectOptGroup(child: any): boolean {
1414
return child?.type?.isSelectOption || child?.type?.isSelectOptGroup;
1515
}
1616

17-
const AutoCompleteProps = {
17+
const autoCompleteProps = {
1818
...SelectProps(),
1919
dataSource: PropTypes.array,
2020
dropdownMenuStyle: PropTypes.style,
2121
optionLabelProp: PropTypes.string,
2222
dropdownMatchSelectWidth: PropTypes.looseBool,
2323
};
2424

25+
export type AutoCompleteProps = Partial<ExtractPropTypes<typeof autoCompleteProps>>;
26+
27+
export const AutoCompleteOption = Option;
28+
29+
export const AutoCompleteOptGroup = OptGroup;
30+
2531
const AutoComplete = defineComponent({
2632
name: 'AAutoComplete',
2733
inheritAttrs: false,
2834
props: {
29-
...AutoCompleteProps,
35+
...autoCompleteProps,
3036
prefixCls: PropTypes.string.def('ant-select'),
3137
showSearch: PropTypes.looseBool,
3238
transitionName: PropTypes.string.def('slide-up'),
@@ -38,8 +44,8 @@ const AutoComplete = defineComponent({
3844
defaultActiveFirstOption: PropTypes.looseBool.def(true),
3945
},
4046
emits: ['change', 'select', 'focus', 'blur'],
41-
Option: { ...Option, name: 'AAutoCompleteOption' },
42-
OptGroup: { ...OptGroup, name: 'AAutoCompleteOptGroup' },
47+
Option,
48+
OptGroup,
4349
setup(props, { slots }) {
4450
warning(
4551
!(props.dataSource !== undefined || 'dataSource' in slots),
@@ -142,8 +148,8 @@ const AutoComplete = defineComponent({
142148
/* istanbul ignore next */
143149
AutoComplete.install = function(app: App) {
144150
app.component(AutoComplete.name, AutoComplete);
145-
app.component(AutoComplete.Option.name, AutoComplete.Option);
146-
app.component(AutoComplete.OptGroup.name, AutoComplete.OptGroup);
151+
app.component(AutoComplete.Option.displayName, AutoComplete.Option);
152+
app.component(AutoComplete.OptGroup.displayName, AutoComplete.OptGroup);
147153
return app;
148154
};
149155

components/avatar/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Avatar.install = function(app: App) {
1313
app.component(Group.name, Group);
1414
return app;
1515
};
16-
16+
export { Group as AvatarGroup };
1717
export default Avatar as typeof Avatar &
1818
Plugin & {
1919
readonly Group: typeof Group;

components/badge/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { App, Plugin } from 'vue';
22
import Badge from './Badge';
33
import Ribbon from './Ribbon';
4+
export type { BadgeProps } from './Badge'
45

56
Badge.install = function(app: App) {
67
app.component(Badge.name, Badge);
78
app.component(Ribbon.name, Ribbon);
89
return app;
910
};
1011

12+
export {Ribbon as BadgeRibbon}
13+
1114
export default Badge as typeof Badge &
1215
Plugin & {
1316
readonly Ribbon: typeof Ribbon;

components/breadcrumb/BreadcrumbSeparator.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import PropTypes from '../_util/vue-types';
33
import { flattenChildren } from '../_util/props-util';
44
import useConfigInject from '../_util/hooks/useConfigInject';
55

6-
const breadcrumbSeparator = {
6+
const breadcrumbSeparatorProps = {
77
prefixCls: PropTypes.string,
88
};
9-
export type BreadcrumbSeparator = Partial<ExtractPropTypes<typeof breadcrumbSeparator>>;
9+
export type BreadcrumbSeparatorProps = Partial<ExtractPropTypes<typeof breadcrumbSeparatorProps>>;
1010

1111
export default defineComponent({
1212
name: 'ABreadcrumbSeparator',
1313
__ANT_BREADCRUMB_SEPARATOR: true,
1414
inheritAttrs: false,
15-
props: breadcrumbSeparator,
15+
props: breadcrumbSeparatorProps,
1616
setup(props, { slots, attrs }) {
1717
const { prefixCls } = useConfigInject('breadcrumb', props);
1818

components/breadcrumb/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import Breadcrumb from './Breadcrumb';
33
import BreadcrumbItem from './BreadcrumbItem';
44
import BreadcrumbSeparator from './BreadcrumbSeparator';
55

6-
export { BreadcrumbProps } from './Breadcrumb';
7-
export { BreadcrumbItemProps } from './BreadcrumbItem';
8-
export { BreadcrumbSeparator } from './BreadcrumbSeparator';
6+
export type { BreadcrumbProps } from './Breadcrumb';
7+
export type { BreadcrumbItemProps } from './BreadcrumbItem';
8+
export type { BreadcrumbSeparatorProps } from './BreadcrumbSeparator';
99

1010
Breadcrumb.Item = BreadcrumbItem;
1111
Breadcrumb.Separator = BreadcrumbSeparator;
@@ -18,6 +18,7 @@ Breadcrumb.install = function(app: App) {
1818
return app;
1919
};
2020

21+
export { BreadcrumbItem, BreadcrumbSeparator };
2122
export default Breadcrumb as typeof Breadcrumb &
2223
Plugin & {
2324
readonly Item: typeof BreadcrumbItem;

components/button/button.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineComponent, inject, Text, VNode } from 'vue';
1+
import { defineComponent, ExtractPropTypes, inject, Text, VNode } from 'vue';
22
import Wave from '../_util/wave';
33
import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined';
44
import buttonTypes from './buttonTypes';
@@ -8,6 +8,9 @@ import { defaultConfigProvider } from '../config-provider';
88
const rxTwoCNChar = /^[\u4e00-\u9fa5]{2}$/;
99
const isTwoCNChar = rxTwoCNChar.test.bind(rxTwoCNChar);
1010
const props = buttonTypes();
11+
12+
export type ButtonProps = Partial<ExtractPropTypes<ReturnType<typeof buttonTypes>>>;
13+
1114
export default defineComponent({
1215
name: 'AButton',
1316
inheritAttrs: false,

components/button/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { App, Plugin } from 'vue';
22
import Button from './button';
33
import ButtonGroup from './button-group';
4+
export type {ButtonProps} from './button'
45

56
Button.Group = ButtonGroup;
67

@@ -10,7 +11,7 @@ Button.install = function(app: App) {
1011
app.component(ButtonGroup.name, ButtonGroup);
1112
return app;
1213
};
13-
14+
export {ButtonGroup}
1415
export default Button as typeof Button &
1516
Plugin & {
1617
readonly Group: typeof ButtonGroup;

components/card/Card.tsx

+36-24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { inject, isVNode, defineComponent, VNodeTypes, PropType, VNode } from 'vue';
1+
import {
2+
inject,
3+
isVNode,
4+
defineComponent,
5+
VNodeTypes,
6+
PropType,
7+
VNode,
8+
ExtractPropTypes,
9+
} from 'vue';
210
import { tuple } from '../_util/type';
311
import Tabs from '../tabs';
412
import Row from '../row';
@@ -20,32 +28,36 @@ export type CardType = 'inner';
2028

2129
const { TabPane } = Tabs;
2230

31+
const cardProps = {
32+
prefixCls: PropTypes.string,
33+
title: PropTypes.VNodeChild,
34+
extra: PropTypes.VNodeChild,
35+
bordered: PropTypes.looseBool.def(true),
36+
bodyStyle: PropTypes.style,
37+
headStyle: PropTypes.style,
38+
loading: PropTypes.looseBool.def(false),
39+
hoverable: PropTypes.looseBool.def(false),
40+
type: PropTypes.string,
41+
size: PropTypes.oneOf(tuple('default', 'small')),
42+
actions: PropTypes.VNodeChild,
43+
tabList: {
44+
type: Array as PropType<CardTabListType[]>,
45+
},
46+
tabBarExtraContent: PropTypes.VNodeChild,
47+
activeTabKey: PropTypes.string,
48+
defaultActiveTabKey: PropTypes.string,
49+
cover: PropTypes.VNodeChild,
50+
onTabChange: {
51+
type: Function as PropType<(key: string) => void>,
52+
},
53+
};
54+
55+
export type CardProps = Partial<ExtractPropTypes<typeof cardProps>>;
56+
2357
const Card = defineComponent({
2458
name: 'ACard',
2559
mixins: [BaseMixin],
26-
props: {
27-
prefixCls: PropTypes.string,
28-
title: PropTypes.VNodeChild,
29-
extra: PropTypes.VNodeChild,
30-
bordered: PropTypes.looseBool.def(true),
31-
bodyStyle: PropTypes.style,
32-
headStyle: PropTypes.style,
33-
loading: PropTypes.looseBool.def(false),
34-
hoverable: PropTypes.looseBool.def(false),
35-
type: PropTypes.string,
36-
size: PropTypes.oneOf(tuple('default', 'small')),
37-
actions: PropTypes.VNodeChild,
38-
tabList: {
39-
type: Array as PropType<CardTabListType[]>,
40-
},
41-
tabBarExtraContent: PropTypes.VNodeChild,
42-
activeTabKey: PropTypes.string,
43-
defaultActiveTabKey: PropTypes.string,
44-
cover: PropTypes.VNodeChild,
45-
onTabChange: {
46-
type: Function as PropType<(key: string) => void>,
47-
},
48-
},
60+
props: cardProps,
4961
setup() {
5062
return {
5163
configProvider: inject('configProvider', defaultConfigProvider),

components/card/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Card from './Card';
33
import Meta from './Meta';
44
import Grid from './Grid';
55

6+
export type {CardProps} from './Card'
7+
68
Card.Meta = Meta;
79
Card.Grid = Grid;
810

@@ -14,6 +16,8 @@ Card.install = function(app: App) {
1416
return app;
1517
};
1618

19+
export {Meta as CardMeta, Grid as CardGrid}
20+
1721
export default Card as typeof Card &
1822
Plugin & {
1923
readonly Meta: typeof Meta;

components/cascader/index.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { inject, provide, PropType, defineComponent, CSSProperties } from 'vue';
1+
import { inject, provide, PropType, defineComponent, CSSProperties, ExtractPropTypes } from 'vue';
22
import PropTypes from '../_util/vue-types';
33
import VcCascader from '../vc-cascader';
44
import arrayTreeFilter from 'array-tree-filter';
@@ -99,7 +99,7 @@ export interface FilteredOptionsType extends EmptyFilteredOptionsType {
9999
// }).loose;
100100
function noop() {}
101101

102-
const CascaderProps = {
102+
const cascaderProps = {
103103
/** 可选项数据源 */
104104
options: { type: Array as PropType<CascaderOptionType[]>, default: [] },
105105
/** 默认的选中项 */
@@ -154,6 +154,8 @@ const CascaderProps = {
154154
'onUpdate:value': PropTypes.func,
155155
};
156156

157+
export type CascaderProps = Partial<ExtractPropTypes<typeof cascaderProps>>;
158+
157159
// We limit the filtered item count by default
158160
const defaultLimit = 50;
159161

@@ -214,7 +216,7 @@ const Cascader = defineComponent({
214216
name: 'ACascader',
215217
mixins: [BaseMixin],
216218
inheritAttrs: false,
217-
props: CascaderProps,
219+
props: cascaderProps,
218220
setup() {
219221
return {
220222
configProvider: inject('configProvider', defaultConfigProvider),

components/checkbox/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Checkbox.install = function(app: App) {
1010
app.component(CheckboxGroup.name, CheckboxGroup);
1111
return app;
1212
};
13-
13+
export { CheckboxGroup };
1414
export default Checkbox as typeof Checkbox &
1515
Plugin & {
1616
readonly Group: typeof CheckboxGroup;

components/col/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { Col } from '../grid';
22
import { withInstall } from '../_util/type';
3-
3+
export type {ColProps} from '../grid'
44
export default withInstall(Col);

components/collapse/Collapse.tsx

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CSSProperties, defineComponent, inject, PropType } from 'vue';
1+
import { CSSProperties, defineComponent, ExtractPropTypes, inject, PropType } from 'vue';
22
import animation from '../_util/openAnimation';
33
import { getOptionProps, getComponent, isValidElement, getSlot } from '../_util/props-util';
44
import { cloneElement } from '../_util/vnode';
@@ -20,22 +20,27 @@ export interface PanelProps {
2020
extra?: VueNode;
2121
}
2222
type ActiveKeyType = Array<string | number> | string | number;
23+
24+
const collapseProps = {
25+
prefixCls: PropTypes.string,
26+
activeKey: { type: [Array, Number, String] as PropType<ActiveKeyType> },
27+
defaultActiveKey: { type: [Array, Number, String] as PropType<ActiveKeyType> },
28+
accordion: PropTypes.looseBool,
29+
destroyInactivePanel: PropTypes.looseBool,
30+
bordered: PropTypes.looseBool.def(true),
31+
expandIcon: PropTypes.func,
32+
openAnimation: PropTypes.object.def(animation),
33+
expandIconPosition: PropTypes.oneOf(tuple('left', 'right')).def('left'),
34+
'onUpdate:activeKey': PropTypes.func,
35+
onChange: PropTypes.func,
36+
};
37+
38+
export type CollapseProps = Partial<ExtractPropTypes<typeof collapseProps>>;
39+
2340
export default defineComponent({
2441
name: 'ACollapse',
2542
inheritAttrs: false,
26-
props: {
27-
prefixCls: PropTypes.string,
28-
activeKey: { type: [Array, Number, String] as PropType<ActiveKeyType> },
29-
defaultActiveKey: { type: [Array, Number, String] as PropType<ActiveKeyType> },
30-
accordion: PropTypes.looseBool,
31-
destroyInactivePanel: PropTypes.looseBool,
32-
bordered: PropTypes.looseBool.def(true),
33-
expandIcon: PropTypes.func,
34-
openAnimation: PropTypes.object.def(animation),
35-
expandIconPosition: PropTypes.oneOf(tuple('left', 'right')).def('left'),
36-
'onUpdate:activeKey': PropTypes.func,
37-
onChange: PropTypes.func,
38-
},
43+
props: collapseProps,
3944
setup() {
4045
return {
4146
configProvider: inject('configProvider', defaultConfigProvider),

0 commit comments

Comments
 (0)