Skip to content

Commit 144bb2e

Browse files
committed
feat: support vue 3.3 slot type
1 parent b4258dc commit 144bb2e

File tree

9 files changed

+90
-62
lines changed

9 files changed

+90
-62
lines changed

components/auto-complete/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const AutoComplete = defineComponent({
4646
props: autoCompleteProps(),
4747
// emits: ['change', 'select', 'focus', 'blur'],
4848
slots: Object as CustomSlotsType<{
49-
option: any;
49+
options: any;
5050
default: any;
5151
notFoundContent: any;
5252
dataSource: any;

components/calendar/demo/customize-header.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Customize Calendar header content.
3737
:value="String(current.year())"
3838
@change="
3939
newYear => {
40-
onChange(current.year(newYear));
40+
onChange(current.year(+newYear));
4141
}
4242
"
4343
>

components/calendar/generateCalendar.tsx

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { useLocaleReceiver } from '../locale-provider/LocaleReceiver';
1212
import enUS from './locale/en_US';
1313
import CalendarHeader from './Header';
1414
import type { CustomSlotsType, VueNode } from '../_util/type';
15-
import type { App } from 'vue';
15+
import type { App, PropType } from 'vue';
1616
import { computed, defineComponent, toRef } from 'vue';
1717
import useConfigInject from '../_util/hooks/useConfigInject';
1818
import classNames from '../_util/classNames';
@@ -86,28 +86,41 @@ function generateCalendar<
8686
);
8787
}
8888

89-
const Calendar = defineComponent<Props>({
89+
const Calendar = defineComponent({
9090
name: 'ACalendar',
9191
inheritAttrs: false,
92-
props: [
93-
'prefixCls',
94-
'locale',
95-
'validRange',
96-
'disabledDate',
97-
'dateFullCellRender',
98-
'dateCellRender',
99-
'monthFullCellRender',
100-
'monthCellRender',
101-
'headerRender',
102-
'value',
103-
'defaultValue',
104-
'mode',
105-
'fullscreen',
106-
'onChange',
107-
'onPanelChange',
108-
'onSelect',
109-
'valueFormat',
110-
] as any,
92+
props: {
93+
prefixCls: String,
94+
locale: { type: Object as PropType<Props['locale']>, default: undefined as Props['locale'] },
95+
validRange: { type: Array as PropType<DateType[]>, default: undefined },
96+
disabledDate: { type: Function as PropType<Props['disabledDate']>, default: undefined },
97+
dateFullCellRender: {
98+
type: Function as PropType<Props['dateFullCellRender']>,
99+
default: undefined,
100+
},
101+
dateCellRender: { type: Function as PropType<Props['dateCellRender']>, default: undefined },
102+
monthFullCellRender: {
103+
type: Function as PropType<Props['monthFullCellRender']>,
104+
default: undefined,
105+
},
106+
monthCellRender: { type: Function as PropType<Props['monthCellRender']>, default: undefined },
107+
headerRender: { type: Function as PropType<Props['headerRender']>, default: undefined },
108+
value: {
109+
type: [Object, String] as PropType<Props['value']>,
110+
default: undefined as Props['value'],
111+
},
112+
defaultValue: {
113+
type: [Object, String] as PropType<Props['defaultValue']>,
114+
default: undefined as Props['defaultValue'],
115+
},
116+
mode: { type: String as PropType<Props['mode']>, default: undefined },
117+
fullscreen: { type: Boolean as PropType<Props['fullscreen']>, default: undefined },
118+
onChange: { type: Function as PropType<Props['onChange']>, default: undefined },
119+
'onUpdate:value': { type: Function as PropType<Props['onUpdate:value']>, default: undefined },
120+
onPanelChange: { type: Function as PropType<Props['onPanelChange']>, default: undefined },
121+
onSelect: { type: Function as PropType<Props['onSelect']>, default: undefined },
122+
valueFormat: { type: String, default: undefined },
123+
},
111124
slots: Object as CustomSlotsType<{
112125
dateFullCellRender?: { current: DateType };
113126
dateCellRender?: { current: DateType };
@@ -121,7 +134,8 @@ function generateCalendar<
121134
};
122135
default: any;
123136
}>,
124-
setup(props, { emit, slots, attrs }) {
137+
setup(p, { emit, slots, attrs }) {
138+
const props = p as unknown as Props;
125139
const { prefixCls, direction } = useConfigInject('picker', props);
126140
const calendarPrefixCls = computed(() => `${prefixCls.value}-calendar`);
127141
const maybeToString = (date: DateType) => {

components/popconfirm/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const Popconfirm = defineComponent({
7676
content?: any;
7777
okText?: any;
7878
icon?: any;
79+
cancel?: any;
7980
cancelText?: any;
8081
cancelButton?: any;
8182
okButton?: any;

components/result/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const Result = defineComponent({
6868
subTitle?: any;
6969
icon?: any;
7070
extra?: any;
71-
dfault?: any;
71+
default?: any;
7272
}>,
7373
setup(props, { slots }) {
7474
const { prefixCls, direction } = useConfigInject('result', props);

components/table/Table.tsx

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -224,38 +224,27 @@ export const tableProps = () => {
224224
type: [Boolean, Object] as PropType<boolean | TooltipProps>,
225225
default: true,
226226
},
227-
contextSlots: {
228-
type: Object as PropType<ContextSlots>,
229-
},
227+
230228
transformCellText: {
231229
type: Function as PropType<TableProps['transformCellText']>,
232230
},
233231
};
234232
};
235233

236-
const InteralTable = defineComponent<
237-
TableProps & {
238-
contextSlots: ContextSlots;
239-
}
240-
>({
234+
const InteralTable = defineComponent({
241235
name: 'InteralTable',
242236
inheritAttrs: false,
243-
props: initDefaultProps(tableProps(), {
244-
rowKey: 'key',
245-
}) as any,
246-
slots: Object as CustomSlotsType<{
247-
emptyText?: any;
248-
expandIcon?: RenderExpandIconProps<any>;
249-
title?: any;
250-
footer?: any;
251-
summary?: any;
252-
expandedRowRender?: any;
253-
bodyCell?: any;
254-
headerCell?: any;
255-
customFilterIcon?: any;
256-
customFilterDropdown?: any;
257-
default: any;
258-
}>,
237+
props: initDefaultProps(
238+
{
239+
...tableProps(),
240+
contextSlots: {
241+
type: Object as PropType<ContextSlots>,
242+
},
243+
},
244+
{
245+
rowKey: 'key',
246+
},
247+
),
259248
setup(props, { attrs, slots, expose, emit }) {
260249
devWarning(
261250
!(typeof props.rowKey === 'function' && props.rowKey.length > 1),
@@ -684,9 +673,34 @@ const InteralTable = defineComponent<
684673
},
685674
});
686675

687-
const Table = defineComponent<TableProps>({
676+
const Table = defineComponent({
688677
name: 'ATable',
689678
inheritAttrs: false,
679+
props: initDefaultProps(tableProps(), {
680+
rowKey: 'key',
681+
}),
682+
slots: Object as CustomSlotsType<{
683+
emptyText?: any;
684+
expandIcon?: RenderExpandIconProps<any>;
685+
title?: any;
686+
footer?: any;
687+
summary?: any;
688+
expandedRowRender?: any;
689+
bodyCell?: {
690+
text: any;
691+
value: any;
692+
record: Record<string, any>;
693+
index: number;
694+
column: ColumnType;
695+
};
696+
headerCell?: {
697+
title: any;
698+
column: ColumnType;
699+
};
700+
customFilterIcon?: any;
701+
customFilterDropdown?: any;
702+
default: any;
703+
}>,
690704
setup(_props, { attrs, slots, expose }) {
691705
const table = ref();
692706
expose({

components/time-picker/time-picker.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,24 @@ function createTimePicker<
8585
});
8686

8787
const { TimePicker: InternalTimePicker, RangePicker: InternalRangePicker } = DatePicker as any;
88-
const TimePicker = defineComponent<DTimePickerProps>({
88+
const TimePicker = defineComponent({
8989
name: 'ATimePicker',
9090
inheritAttrs: false,
9191
props: {
9292
...commonProps<DateType>(),
9393
...datePickerProps<DateType>(),
9494
...timePickerProps(),
9595
addon: { type: Function },
96-
} as any,
96+
},
9797
slots: Object as CustomSlotsType<{
9898
addon?: any;
9999
renderExtraFooter?: any;
100100
suffixIcon?: any;
101101
clearIcon?: any;
102102
default: any;
103103
}>,
104-
setup(props, { slots, expose, emit, attrs }) {
104+
setup(p, { slots, expose, emit, attrs }) {
105+
const props = p as unknown as DTimePickerProps;
105106
const formItemContext = useInjectFormItemContext();
106107
devWarning(
107108
!(slots.addon || props.addon),
@@ -162,22 +163,23 @@ function createTimePicker<
162163
},
163164
});
164165

165-
const TimeRangePicker = defineComponent<DTimeRangePickerProps>({
166+
const TimeRangePicker = defineComponent({
166167
name: 'ATimeRangePicker',
167168
inheritAttrs: false,
168169
props: {
169170
...commonProps<DateType>(),
170171
...rangePickerProps<DateType>(),
171172
...timePickerProps(),
172173
order: { type: Boolean, default: true },
173-
} as any,
174+
},
174175
slots: Object as CustomSlotsType<{
175176
renderExtraFooter?: any;
176177
suffixIcon?: any;
177178
clearIcon?: any;
178179
default: any;
179180
}>,
180-
setup(props, { slots, expose, emit, attrs }) {
181+
setup(p, { slots, expose, emit, attrs }) {
182+
const props = p as unknown as DTimeRangePickerProps;
181183
const pickerRef = ref();
182184
const formItemContext = useInjectFormItemContext();
183185
expose({

components/typography/Typography.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,27 @@ export const typographyProps = () => ({
1818
// Form Internal use
1919
component: String,
2020
});
21-
const Typography = defineComponent<InternalTypographyProps>({
21+
const Typography = defineComponent({
2222
name: 'ATypography',
2323
inheritAttrs: false,
24-
props: typographyProps() as any,
24+
props: typographyProps(),
2525
setup(props, { slots, attrs }) {
2626
const { prefixCls, direction } = useConfigInject('typography', props);
2727
return () => {
2828
const {
2929
prefixCls: _prefixCls,
30-
class: _className,
3130
direction: _direction,
3231
component: Component = 'article' as any,
3332
...restProps
3433
} = { ...props, ...attrs };
3534
return (
3635
<Component
36+
{...restProps}
3737
class={classNames(
3838
prefixCls.value,
3939
{ [`${prefixCls.value}-rtl`]: direction.value === 'rtl' },
4040
attrs.class,
4141
)}
42-
{...restProps}
4342
>
4443
{slots.default?.()}
4544
</Component>

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@
251251
"url-loader": "^3.0.0",
252252
"vite": "^3.0.0",
253253
"vue": "^3.2.0",
254-
"vue-antd-md-loader": "^1.2.1-beta.1",
255254
"vue-clipboard2": "0.3.3",
256255
"vue-drag-resize": "^2.0.3",
257256
"vue-eslint-parser": "^8.0.0",
@@ -260,7 +259,6 @@
260259
"vue-loader": "^17.0.0",
261260
"vue-request": "^1.0.2",
262261
"vue-router": "^4.0.0",
263-
"vue-server-renderer": "^2.6.11",
264262
"vue-style-loader": "^4.1.2",
265263
"vue-tsc": "^1.0.6",
266264
"vuex": "^4.0.0",

0 commit comments

Comments
 (0)