feat: update ts type
parent
55b9ab50af
commit
16464213c1
|
@ -4,7 +4,6 @@ export type KeyboardEventHandler = (e: KeyboardEvent) => void;
|
||||||
export type CompositionEventHandler = (e: CompositionEvent) => void;
|
export type CompositionEventHandler = (e: CompositionEvent) => void;
|
||||||
export type ClipboardEventHandler = (e: ClipboardEvent) => void;
|
export type ClipboardEventHandler = (e: ClipboardEvent) => void;
|
||||||
export type ChangeEventHandler = (e: ChangeEvent) => void;
|
export type ChangeEventHandler = (e: ChangeEvent) => void;
|
||||||
|
|
||||||
export type ChangeEvent = Event & {
|
export type ChangeEvent = Event & {
|
||||||
target: {
|
target: {
|
||||||
value?: string | undefined;
|
value?: string | undefined;
|
||||||
|
|
|
@ -99,7 +99,7 @@ export {
|
||||||
LayoutContent,
|
LayoutContent,
|
||||||
} from './layout';
|
} from './layout';
|
||||||
|
|
||||||
export type { ListProps } from './list';
|
export type { ListProps, ListItemProps, ListItemMetaProps } from './list';
|
||||||
export { default as List, ListItem, ListItemMeta } from './list';
|
export { default as List, ListItem, ListItemMeta } from './list';
|
||||||
|
|
||||||
export type { MessageArgsProps } from './message';
|
export type { MessageArgsProps } from './message';
|
||||||
|
|
|
@ -23,6 +23,7 @@ import type {
|
||||||
ValidateErrorEntity,
|
ValidateErrorEntity,
|
||||||
ValidateOptions,
|
ValidateOptions,
|
||||||
Callbacks,
|
Callbacks,
|
||||||
|
ValidateMessages,
|
||||||
} from './interface';
|
} from './interface';
|
||||||
import { useInjectSize } from '../_util/hooks/useSize';
|
import { useInjectSize } from '../_util/hooks/useSize';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
|
@ -60,7 +61,7 @@ export type ValidationRule = {
|
||||||
trigger?: string;
|
trigger?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const formProps = {
|
export const formProps = () => ({
|
||||||
layout: PropTypes.oneOf(tuple('horizontal', 'inline', 'vertical')),
|
layout: PropTypes.oneOf(tuple('horizontal', 'inline', 'vertical')),
|
||||||
labelCol: { type: Object as PropType<ColProps & HTMLAttributes> },
|
labelCol: { type: Object as PropType<ColProps & HTMLAttributes> },
|
||||||
wrapperCol: { type: Object as PropType<ColProps & HTMLAttributes> },
|
wrapperCol: { type: Object as PropType<ColProps & HTMLAttributes> },
|
||||||
|
@ -73,11 +74,14 @@ export const formProps = {
|
||||||
hideRequiredMark: { type: Boolean, default: undefined },
|
hideRequiredMark: { type: Boolean, default: undefined },
|
||||||
model: PropTypes.object,
|
model: PropTypes.object,
|
||||||
rules: { type: Object as PropType<{ [k: string]: ValidationRule[] | ValidationRule }> },
|
rules: { type: Object as PropType<{ [k: string]: ValidationRule[] | ValidationRule }> },
|
||||||
validateMessages: PropTypes.object,
|
validateMessages: {
|
||||||
|
type: Object as PropType<ValidateMessages>,
|
||||||
|
default: undefined as ValidateMessages,
|
||||||
|
},
|
||||||
validateOnRuleChange: { type: Boolean, default: undefined },
|
validateOnRuleChange: { type: Boolean, default: undefined },
|
||||||
// 提交失败自动滚动到第一个错误字段
|
// 提交失败自动滚动到第一个错误字段
|
||||||
scrollToFirstError: { type: [Boolean, Object] as PropType<boolean | Options> },
|
scrollToFirstError: { type: [Boolean, Object] as PropType<boolean | Options> },
|
||||||
onSubmit: Function,
|
onSubmit: Function as PropType<(e: Event) => void>,
|
||||||
name: String,
|
name: String,
|
||||||
validateTrigger: { type: [String, Array] as PropType<string | string[]> },
|
validateTrigger: { type: [String, Array] as PropType<string | string[]> },
|
||||||
size: { type: String as PropType<SizeType> },
|
size: { type: String as PropType<SizeType> },
|
||||||
|
@ -86,9 +90,9 @@ export const formProps = {
|
||||||
onFinish: { type: Function as PropType<Callbacks['onFinish']> },
|
onFinish: { type: Function as PropType<Callbacks['onFinish']> },
|
||||||
onFinishFailed: { type: Function as PropType<Callbacks['onFinishFailed']> },
|
onFinishFailed: { type: Function as PropType<Callbacks['onFinishFailed']> },
|
||||||
onValidate: { type: Function as PropType<Callbacks['onValidate']> },
|
onValidate: { type: Function as PropType<Callbacks['onValidate']> },
|
||||||
};
|
});
|
||||||
|
|
||||||
export type FormProps = Partial<ExtractPropTypes<typeof formProps>>;
|
export type FormProps = Partial<ExtractPropTypes<ReturnType<typeof formProps>>>;
|
||||||
|
|
||||||
export type FormExpose = {
|
export type FormExpose = {
|
||||||
resetFields: (name?: NamePath) => void;
|
resetFields: (name?: NamePath) => void;
|
||||||
|
@ -120,14 +124,14 @@ function isEqualName(name1: NamePath, name2: NamePath) {
|
||||||
const Form = defineComponent({
|
const Form = defineComponent({
|
||||||
name: 'AForm',
|
name: 'AForm',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: initDefaultProps(formProps, {
|
props: initDefaultProps(formProps(), {
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
hideRequiredMark: false,
|
hideRequiredMark: false,
|
||||||
colon: true,
|
colon: true,
|
||||||
}),
|
}),
|
||||||
Item: FormItem,
|
Item: FormItem,
|
||||||
useForm,
|
useForm,
|
||||||
emits: ['finishFailed', 'submit', 'finish', 'validate'],
|
// emits: ['finishFailed', 'submit', 'finish', 'validate'],
|
||||||
setup(props, { emit, slots, expose, attrs }) {
|
setup(props, { emit, slots, expose, attrs }) {
|
||||||
const size = useInjectSize(props);
|
const size = useInjectSize(props);
|
||||||
const { prefixCls, direction, form: contextForm } = useConfigInject('form', props);
|
const { prefixCls, direction, form: contextForm } = useConfigInject('form', props);
|
||||||
|
|
|
@ -27,7 +27,7 @@ import { toArray } from './utils/typeUtil';
|
||||||
import { warning } from '../vc-util/warning';
|
import { warning } from '../vc-util/warning';
|
||||||
import find from 'lodash-es/find';
|
import find from 'lodash-es/find';
|
||||||
import { tuple } from '../_util/type';
|
import { tuple } from '../_util/type';
|
||||||
import type { InternalNamePath, RuleError, RuleObject, ValidateOptions } from './interface';
|
import type { InternalNamePath, Rule, RuleError, RuleObject, ValidateOptions } from './interface';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
import { useInjectForm } from './context';
|
import { useInjectForm } from './context';
|
||||||
import FormItemLabel from './FormItemLabel';
|
import FormItemLabel from './FormItemLabel';
|
||||||
|
@ -81,7 +81,7 @@ function getPropByPath(obj: any, namePathList: any, strict?: boolean) {
|
||||||
v: tempObj ? tempObj[keyArr[i]] : undefined,
|
v: tempObj ? tempObj[keyArr[i]] : undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
export const formItemProps = {
|
export const formItemProps = () => ({
|
||||||
htmlFor: String,
|
htmlFor: String,
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
label: PropTypes.any,
|
label: PropTypes.any,
|
||||||
|
@ -94,7 +94,7 @@ export const formItemProps = {
|
||||||
labelAlign: PropTypes.oneOf(tuple('left', 'right')),
|
labelAlign: PropTypes.oneOf(tuple('left', 'right')),
|
||||||
prop: { type: [String, Number, Array] as PropType<string | number | Array<string | number>> },
|
prop: { type: [String, Number, Array] as PropType<string | number | Array<string | number>> },
|
||||||
name: { type: [String, Number, Array] as PropType<string | number | Array<string | number>> },
|
name: { type: [String, Number, Array] as PropType<string | number | Array<string | number>> },
|
||||||
rules: PropTypes.oneOfType([Array, Object]),
|
rules: [Array, Object] as PropType<Rule[] | Rule>,
|
||||||
autoLink: { type: Boolean, default: true },
|
autoLink: { type: Boolean, default: true },
|
||||||
required: { type: Boolean, default: undefined },
|
required: { type: Boolean, default: undefined },
|
||||||
validateFirst: { type: Boolean, default: undefined },
|
validateFirst: { type: Boolean, default: undefined },
|
||||||
|
@ -103,9 +103,9 @@ export const formItemProps = {
|
||||||
messageVariables: { type: Object as PropType<Record<string, string>> },
|
messageVariables: { type: Object as PropType<Record<string, string>> },
|
||||||
hidden: Boolean,
|
hidden: Boolean,
|
||||||
noStyle: Boolean,
|
noStyle: Boolean,
|
||||||
};
|
});
|
||||||
|
|
||||||
export type FormItemProps = Partial<ExtractPropTypes<typeof formItemProps>>;
|
export type FormItemProps = Partial<ExtractPropTypes<ReturnType<typeof formItemProps>>>;
|
||||||
|
|
||||||
export type FormItemExpose = {
|
export type FormItemExpose = {
|
||||||
onFieldBlur: () => void;
|
onFieldBlur: () => void;
|
||||||
|
@ -125,7 +125,7 @@ export default defineComponent({
|
||||||
name: 'AFormItem',
|
name: 'AFormItem',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
__ANT_NEW_FORM_ITEM: true,
|
__ANT_NEW_FORM_ITEM: true,
|
||||||
props: formItemProps,
|
props: formItemProps(),
|
||||||
slots: ['help', 'label', 'extra'],
|
slots: ['help', 'label', 'extra'],
|
||||||
setup(props, { slots, attrs, expose }) {
|
setup(props, { slots, attrs, expose }) {
|
||||||
warning(props.prop === undefined, `\`prop\` is deprecated. Please use \`name\` instead.`);
|
warning(props.prop === undefined, `\`prop\` is deprecated. Please use \`name\` instead.`);
|
||||||
|
|
|
@ -34,13 +34,34 @@ export const colProps = () => ({
|
||||||
offset: [String, Number],
|
offset: [String, Number],
|
||||||
push: [String, Number],
|
push: [String, Number],
|
||||||
pull: [String, Number],
|
pull: [String, Number],
|
||||||
xs: { type: [String, Number, Object] as PropType<string | number | ColSize> },
|
xs: {
|
||||||
sm: { type: [String, Number, Object] as PropType<string | number | ColSize> },
|
type: [String, Number, Object] as PropType<string | number | ColSize>,
|
||||||
md: { type: [String, Number, Object] as PropType<string | number | ColSize> },
|
default: undefined as string | number | ColSize,
|
||||||
lg: { type: [String, Number, Object] as PropType<string | number | ColSize> },
|
},
|
||||||
xl: { type: [String, Number, Object] as PropType<string | number | ColSize> },
|
sm: {
|
||||||
xxl: { type: [String, Number, Object] as PropType<string | number | ColSize> },
|
type: [String, Number, Object] as PropType<string | number | ColSize>,
|
||||||
xxxl: { type: [String, Number, Object] as PropType<string | number | ColSize> },
|
default: undefined as string | number | ColSize,
|
||||||
|
},
|
||||||
|
md: {
|
||||||
|
type: [String, Number, Object] as PropType<string | number | ColSize>,
|
||||||
|
default: undefined as string | number | ColSize,
|
||||||
|
},
|
||||||
|
lg: {
|
||||||
|
type: [String, Number, Object] as PropType<string | number | ColSize>,
|
||||||
|
default: undefined as string | number | ColSize,
|
||||||
|
},
|
||||||
|
xl: {
|
||||||
|
type: [String, Number, Object] as PropType<string | number | ColSize>,
|
||||||
|
default: undefined as string | number | ColSize,
|
||||||
|
},
|
||||||
|
xxl: {
|
||||||
|
type: [String, Number, Object] as PropType<string | number | ColSize>,
|
||||||
|
default: undefined as string | number | ColSize,
|
||||||
|
},
|
||||||
|
xxxl: {
|
||||||
|
type: [String, Number, Object] as PropType<string | number | ColSize>,
|
||||||
|
default: undefined as string | number | ColSize,
|
||||||
|
},
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
flex: [String, Number],
|
flex: [String, Number],
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import PreviewGroup from '../vc-image/src/PreviewGroup';
|
import PreviewGroup from '../vc-image/src/PreviewGroup';
|
||||||
import { computed, defineComponent } from 'vue';
|
import { computed, defineComponent } from 'vue';
|
||||||
import PropTypes from '../_util/vue-types';
|
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
|
|
||||||
const InternalPreviewGroup = defineComponent({
|
const InternalPreviewGroup = defineComponent({
|
||||||
name: 'AImagePreviewGroup',
|
name: 'AImagePreviewGroup',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: { previewPrefixCls: PropTypes.string },
|
props: { previewPrefixCls: String },
|
||||||
setup(props, { attrs, slots }) {
|
setup(props, { attrs, slots }) {
|
||||||
const { getPrefixCls } = useConfigInject('image', props);
|
const { getPrefixCls } = useConfigInject('image', props);
|
||||||
const prefixCls = computed(() => getPrefixCls('image-preview', props.previewPrefixCls));
|
const prefixCls = computed(() => getPrefixCls('image-preview', props.previewPrefixCls));
|
||||||
|
|
|
@ -6,12 +6,13 @@ import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
import PreviewGroup from './PreviewGroup';
|
import PreviewGroup from './PreviewGroup';
|
||||||
|
|
||||||
export type ImageProps = Partial<
|
export type ImageProps = Partial<
|
||||||
ExtractPropTypes<typeof imageProps> & Omit<ImgHTMLAttributes, 'placeholder' | 'onClick'>
|
ExtractPropTypes<ReturnType<typeof imageProps>> &
|
||||||
|
Omit<ImgHTMLAttributes, 'placeholder' | 'onClick'>
|
||||||
>;
|
>;
|
||||||
const Image = defineComponent<ImageProps>({
|
const Image = defineComponent<ImageProps>({
|
||||||
name: 'AImage',
|
name: 'AImage',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: imageProps as any,
|
props: imageProps() as any,
|
||||||
setup(props, { slots, attrs }) {
|
setup(props, { slots, attrs }) {
|
||||||
const { prefixCls } = useConfigInject('image', props);
|
const { prefixCls } = useConfigInject('image', props);
|
||||||
return () => {
|
return () => {
|
||||||
|
|
|
@ -11,8 +11,9 @@ import { cloneElement } from '../_util/vnode';
|
||||||
import omit from '../_util/omit';
|
import omit from '../_util/omit';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import isValidValue from '../_util/isValidValue';
|
import isValidValue from '../_util/isValidValue';
|
||||||
export const inputNumberProps = {
|
const baseProps = baseInputNumberProps();
|
||||||
...baseInputNumberProps,
|
export const inputNumberProps = () => ({
|
||||||
|
...baseProps,
|
||||||
size: { type: String as PropType<SizeType> },
|
size: { type: String as PropType<SizeType> },
|
||||||
bordered: { type: Boolean, default: true },
|
bordered: { type: Boolean, default: true },
|
||||||
placeholder: String,
|
placeholder: String,
|
||||||
|
@ -22,16 +23,16 @@ export const inputNumberProps = {
|
||||||
addonBefore: PropTypes.any,
|
addonBefore: PropTypes.any,
|
||||||
addonAfter: PropTypes.any,
|
addonAfter: PropTypes.any,
|
||||||
prefix: PropTypes.any,
|
prefix: PropTypes.any,
|
||||||
'update:value': baseInputNumberProps.onChange,
|
'update:value': baseProps.onChange,
|
||||||
};
|
});
|
||||||
|
|
||||||
export type InputNumberProps = Partial<ExtractPropTypes<typeof inputNumberProps>>;
|
export type InputNumberProps = Partial<ExtractPropTypes<ReturnType<typeof inputNumberProps>>>;
|
||||||
|
|
||||||
const InputNumber = defineComponent({
|
const InputNumber = defineComponent({
|
||||||
name: 'AInputNumber',
|
name: 'AInputNumber',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: inputNumberProps,
|
props: inputNumberProps(),
|
||||||
emits: ['focus', 'blur', 'change', 'input', 'update:value'],
|
// emits: ['focus', 'blur', 'change', 'input', 'update:value'],
|
||||||
slots: ['addonBefore', 'addonAfter', 'prefix'],
|
slots: ['addonBefore', 'addonAfter', 'prefix'],
|
||||||
setup(props, { emit, expose, attrs, slots }) {
|
setup(props, { emit, expose, attrs, slots }) {
|
||||||
const formItemContext = useInjectFormItemContext();
|
const formItemContext = useInjectFormItemContext();
|
||||||
|
|
|
@ -34,7 +34,7 @@ const getDecimalIfValidate = (value: ValueType) => {
|
||||||
return decimal.isInvalidate() ? null : decimal;
|
return decimal.isInvalidate() ? null : decimal;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const inputNumberProps = {
|
export const inputNumberProps = () => ({
|
||||||
/** value will show as string */
|
/** value will show as string */
|
||||||
stringMode: { type: Boolean as PropType<boolean> },
|
stringMode: { type: Boolean as PropType<boolean> },
|
||||||
|
|
||||||
|
@ -76,12 +76,12 @@ export const inputNumberProps = {
|
||||||
},
|
},
|
||||||
onBlur: { type: Function as PropType<(e: InputEvent) => void> },
|
onBlur: { type: Function as PropType<(e: InputEvent) => void> },
|
||||||
onFocus: { type: Function as PropType<(e: InputEvent) => void> },
|
onFocus: { type: Function as PropType<(e: InputEvent) => void> },
|
||||||
};
|
});
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'InnerInputNumber',
|
name: 'InnerInputNumber',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: inputNumberProps,
|
props: inputNumberProps(),
|
||||||
slots: ['upHandler', 'downHandler'],
|
slots: ['upHandler', 'downHandler'],
|
||||||
setup(props, { attrs, slots, emit, expose }) {
|
setup(props, { attrs, slots, emit, expose }) {
|
||||||
const inputRef = ref<HTMLInputElement>();
|
const inputRef = ref<HTMLInputElement>();
|
||||||
|
|
|
@ -107,9 +107,7 @@ export function triggerFocus(
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'AInput',
|
name: 'AInput',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: inputProps(),
|
||||||
...inputProps,
|
|
||||||
},
|
|
||||||
setup(props, { slots, attrs, expose, emit }) {
|
setup(props, { slots, attrs, expose, emit }) {
|
||||||
const inputRef = ref();
|
const inputRef = ref();
|
||||||
const clearableInputRef = ref();
|
const clearableInputRef = ref();
|
||||||
|
|
|
@ -23,7 +23,7 @@ export default defineComponent({
|
||||||
mixins: [BaseMixin],
|
mixins: [BaseMixin],
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
...inputProps,
|
...inputProps(),
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
inputPrefixCls: String,
|
inputPrefixCls: String,
|
||||||
action: PropTypes.string.def('click'),
|
action: PropTypes.string.def('click'),
|
||||||
|
|
|
@ -27,7 +27,7 @@ const ResizableTextArea = defineComponent({
|
||||||
name: 'ResizableTextArea',
|
name: 'ResizableTextArea',
|
||||||
mixins: [BaseMixin],
|
mixins: [BaseMixin],
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: textAreaProps,
|
props: textAreaProps(),
|
||||||
setup(props, { attrs, emit, expose }) {
|
setup(props, { attrs, emit, expose }) {
|
||||||
let nextFrameActionId: any;
|
let nextFrameActionId: any;
|
||||||
let resizeFrameId: any;
|
let resizeFrameId: any;
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default defineComponent({
|
||||||
name: 'AInputSearch',
|
name: 'AInputSearch',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
...inputProps,
|
...inputProps(),
|
||||||
inputPrefixCls: String,
|
inputPrefixCls: String,
|
||||||
// 不能设置默认值 https://github.com/vueComponent/ant-design-vue/issues/1916
|
// 不能设置默认值 https://github.com/vueComponent/ant-design-vue/issues/1916
|
||||||
enterButton: PropTypes.any,
|
enterButton: PropTypes.any,
|
||||||
|
|
|
@ -47,7 +47,7 @@ function setTriggerValue(
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'ATextarea',
|
name: 'ATextarea',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: textAreaProps,
|
props: textAreaProps(),
|
||||||
setup(props, { attrs, expose, emit }) {
|
setup(props, { attrs, expose, emit }) {
|
||||||
const formItemContext = useInjectFormItemContext();
|
const formItemContext = useInjectFormItemContext();
|
||||||
const stateValue = ref(props.value === undefined ? props.defaultValue : props.value);
|
const stateValue = ref(props.value === undefined ? props.defaultValue : props.value);
|
||||||
|
|
|
@ -3,8 +3,14 @@ import PropTypes from '../_util/vue-types';
|
||||||
import type { SizeType } from '../config-provider';
|
import type { SizeType } from '../config-provider';
|
||||||
import omit from '../_util/omit';
|
import omit from '../_util/omit';
|
||||||
import type { LiteralUnion, VueNode } from '../_util/type';
|
import type { LiteralUnion, VueNode } from '../_util/type';
|
||||||
|
import type {
|
||||||
|
ChangeEventHandler,
|
||||||
|
CompositionEventHandler,
|
||||||
|
FocusEventHandler,
|
||||||
|
KeyboardEventHandler,
|
||||||
|
} from '../_util/EventInterface';
|
||||||
export const inputDefaultValue = Symbol() as unknown as string;
|
export const inputDefaultValue = Symbol() as unknown as string;
|
||||||
const inputProps = {
|
const inputProps = () => ({
|
||||||
id: String,
|
id: String,
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
inputPrefixCls: String,
|
inputPrefixCls: String,
|
||||||
|
@ -63,19 +69,19 @@ const inputProps = {
|
||||||
bordered: { type: Boolean, default: undefined },
|
bordered: { type: Boolean, default: undefined },
|
||||||
showCount: { type: [Boolean, Object] as PropType<boolean | ShowCountProps> },
|
showCount: { type: [Boolean, Object] as PropType<boolean | ShowCountProps> },
|
||||||
htmlSize: Number,
|
htmlSize: Number,
|
||||||
onPressEnter: Function,
|
onPressEnter: Function as PropType<KeyboardEventHandler>,
|
||||||
onKeydown: Function,
|
onKeydown: Function as PropType<KeyboardEventHandler>,
|
||||||
onKeyup: Function,
|
onKeyup: Function as PropType<KeyboardEventHandler>,
|
||||||
onFocus: Function,
|
onFocus: Function as PropType<FocusEventHandler>,
|
||||||
onBlur: Function,
|
onBlur: Function as PropType<FocusEventHandler>,
|
||||||
onChange: Function,
|
onChange: Function as PropType<ChangeEventHandler>,
|
||||||
onInput: Function,
|
onInput: Function as PropType<ChangeEventHandler>,
|
||||||
'onUpdate:value': Function,
|
'onUpdate:value': Function as PropType<(val: string) => void>,
|
||||||
valueModifiers: Object,
|
valueModifiers: Object,
|
||||||
hidden: Boolean,
|
hidden: Boolean,
|
||||||
};
|
});
|
||||||
export default inputProps;
|
export default inputProps;
|
||||||
export type InputProps = Partial<ExtractPropTypes<typeof inputProps>>;
|
export type InputProps = Partial<ExtractPropTypes<ReturnType<typeof inputProps>>>;
|
||||||
|
|
||||||
export interface AutoSizeType {
|
export interface AutoSizeType {
|
||||||
minRows?: number;
|
minRows?: number;
|
||||||
|
@ -84,17 +90,17 @@ export interface AutoSizeType {
|
||||||
export interface ShowCountProps {
|
export interface ShowCountProps {
|
||||||
formatter: (args: { count: number; maxlength?: number }) => VueNode;
|
formatter: (args: { count: number; maxlength?: number }) => VueNode;
|
||||||
}
|
}
|
||||||
const textAreaProps = {
|
const textAreaProps = () => ({
|
||||||
...omit(inputProps, ['prefix', 'addonBefore', 'addonAfter', 'suffix']),
|
...omit(inputProps(), ['prefix', 'addonBefore', 'addonAfter', 'suffix']),
|
||||||
rows: Number,
|
rows: Number,
|
||||||
autosize: { type: [Boolean, Object] as PropType<AutoSizeType>, default: undefined },
|
autosize: { type: [Boolean, Object] as PropType<AutoSizeType>, default: undefined },
|
||||||
autoSize: { type: [Boolean, Object] as PropType<AutoSizeType>, default: undefined },
|
autoSize: { type: [Boolean, Object] as PropType<AutoSizeType>, default: undefined },
|
||||||
onResize: { type: Function as PropType<(size: { width: number; height: number }) => void> },
|
onResize: { type: Function as PropType<(size: { width: number; height: number }) => void> },
|
||||||
onCompositionstart: Function,
|
onCompositionstart: Function as PropType<CompositionEventHandler>,
|
||||||
onCompositionend: Function,
|
onCompositionend: Function as PropType<CompositionEventHandler>,
|
||||||
valueModifiers: Object,
|
valueModifiers: Object,
|
||||||
};
|
});
|
||||||
|
|
||||||
export { textAreaProps };
|
export { textAreaProps };
|
||||||
|
|
||||||
export type TextAreaProps = Partial<ExtractPropTypes<typeof textAreaProps>>;
|
export type TextAreaProps = Partial<ExtractPropTypes<ReturnType<typeof textAreaProps>>>;
|
||||||
|
|
|
@ -23,7 +23,7 @@ const dimensionMaxMap = {
|
||||||
|
|
||||||
export type CollapseType = 'clickTrigger' | 'responsive';
|
export type CollapseType = 'clickTrigger' | 'responsive';
|
||||||
|
|
||||||
export const siderProps = {
|
export const siderProps = () => ({
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
collapsible: { type: Boolean, default: undefined },
|
collapsible: { type: Boolean, default: undefined },
|
||||||
collapsed: { type: Boolean, default: undefined },
|
collapsed: { type: Boolean, default: undefined },
|
||||||
|
@ -40,14 +40,9 @@ export const siderProps = {
|
||||||
theme: PropTypes.oneOf(tuple('light', 'dark')).def('dark'),
|
theme: PropTypes.oneOf(tuple('light', 'dark')).def('dark'),
|
||||||
onBreakpoint: Function as PropType<(broken: boolean) => void>,
|
onBreakpoint: Function as PropType<(broken: boolean) => void>,
|
||||||
onCollapse: Function as PropType<(collapsed: boolean, type: CollapseType) => void>,
|
onCollapse: Function as PropType<(collapsed: boolean, type: CollapseType) => void>,
|
||||||
};
|
});
|
||||||
|
|
||||||
export type SiderProps = Partial<ExtractPropTypes<typeof siderProps>>;
|
export type SiderProps = Partial<ExtractPropTypes<ReturnType<typeof siderProps>>>;
|
||||||
// export interface SiderState {
|
|
||||||
// collapsed?: boolean;
|
|
||||||
// below: boolean;
|
|
||||||
// belowShow?: boolean;
|
|
||||||
// }
|
|
||||||
|
|
||||||
export interface SiderContextProps {
|
export interface SiderContextProps {
|
||||||
sCollapsed?: boolean;
|
sCollapsed?: boolean;
|
||||||
|
@ -65,7 +60,7 @@ const generateId = (() => {
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'ALayoutSider',
|
name: 'ALayoutSider',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: initDefaultProps(siderProps, {
|
props: initDefaultProps(siderProps(), {
|
||||||
collapsible: false,
|
collapsible: false,
|
||||||
defaultCollapsed: false,
|
defaultCollapsed: false,
|
||||||
reverseArrow: false,
|
reverseArrow: false,
|
||||||
|
|
|
@ -3,13 +3,13 @@ import { computed, createVNode, defineComponent, provide, ref } from 'vue';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
import { SiderHookProviderKey } from './injectionKey';
|
import { SiderHookProviderKey } from './injectionKey';
|
||||||
|
|
||||||
export const basicProps = {
|
export const basicProps = () => ({
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
hasSider: { type: Boolean, default: undefined },
|
hasSider: { type: Boolean, default: undefined },
|
||||||
tagName: String,
|
tagName: String,
|
||||||
};
|
});
|
||||||
|
|
||||||
export type BasicProps = Partial<ExtractPropTypes<typeof basicProps>> & HTMLAttributes;
|
export type BasicProps = Partial<ExtractPropTypes<ReturnType<typeof basicProps>>> & HTMLAttributes;
|
||||||
|
|
||||||
type GeneratorArgument = {
|
type GeneratorArgument = {
|
||||||
suffixCls: string;
|
suffixCls: string;
|
||||||
|
@ -21,7 +21,7 @@ function generator({ suffixCls, tagName, name }: GeneratorArgument) {
|
||||||
return (BasicComponent: typeof Basic) => {
|
return (BasicComponent: typeof Basic) => {
|
||||||
const Adapter = defineComponent({
|
const Adapter = defineComponent({
|
||||||
name,
|
name,
|
||||||
props: basicProps,
|
props: basicProps(),
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const { prefixCls } = useConfigInject(suffixCls, props);
|
const { prefixCls } = useConfigInject(suffixCls, props);
|
||||||
return () => {
|
return () => {
|
||||||
|
@ -39,14 +39,14 @@ function generator({ suffixCls, tagName, name }: GeneratorArgument) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const Basic = defineComponent({
|
const Basic = defineComponent({
|
||||||
props: basicProps,
|
props: basicProps(),
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
return () => createVNode(props.tagName, { class: props.prefixCls }, slots);
|
return () => createVNode(props.tagName, { class: props.prefixCls }, slots);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const BasicLayout = defineComponent({
|
const BasicLayout = defineComponent({
|
||||||
props: basicProps,
|
props: basicProps(),
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const { direction } = useConfigInject('', props);
|
const { direction } = useConfigInject('', props);
|
||||||
const siders = ref<string[]>([]);
|
const siders = ref<string[]>([]);
|
||||||
|
|
|
@ -3,25 +3,27 @@ import classNames from '../_util/classNames';
|
||||||
import { isStringElement, isEmptyElement, flattenChildren } from '../_util/props-util';
|
import { isStringElement, isEmptyElement, flattenChildren } from '../_util/props-util';
|
||||||
import { Col } from '../grid';
|
import { Col } from '../grid';
|
||||||
import { cloneElement } from '../_util/vnode';
|
import { cloneElement } from '../_util/vnode';
|
||||||
import type { CSSProperties, PropType } from 'vue';
|
import type { CSSProperties, ExtractPropTypes, PropType } from 'vue';
|
||||||
import { defineComponent, inject, ref } from 'vue';
|
import { defineComponent, inject, ref } from 'vue';
|
||||||
import ItemMeta from './ItemMeta';
|
import ItemMeta from './ItemMeta';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
import { ListContextKey } from './contextKey';
|
import { ListContextKey } from './contextKey';
|
||||||
|
import type { ListGridType } from '.';
|
||||||
|
|
||||||
export const ListItemProps = {
|
export const listItemProps = () => ({
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
extra: PropTypes.any,
|
extra: PropTypes.any,
|
||||||
actions: PropTypes.array,
|
actions: PropTypes.array,
|
||||||
grid: PropTypes.any,
|
grid: Object as PropType<ListGridType>,
|
||||||
colStyle: { type: Object as PropType<CSSProperties>, default: undefined as CSSProperties },
|
colStyle: { type: Object as PropType<CSSProperties>, default: undefined as CSSProperties },
|
||||||
};
|
});
|
||||||
|
|
||||||
|
export type ListItemProps = Partial<ExtractPropTypes<ReturnType<typeof listItemProps>>>;
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'AListItem',
|
name: 'AListItem',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
Meta: ItemMeta,
|
Meta: ItemMeta,
|
||||||
props: ListItemProps,
|
props: listItemProps(),
|
||||||
slots: ['actions', 'extra'],
|
slots: ['actions', 'extra'],
|
||||||
setup(props, { slots, attrs }) {
|
setup(props, { slots, attrs }) {
|
||||||
const { itemLayout, grid } = inject(ListContextKey, {
|
const { itemLayout, grid } = inject(ListContextKey, {
|
||||||
|
|
|
@ -3,18 +3,18 @@ import { defineComponent } from 'vue';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
|
|
||||||
export const listItemMetaProps = {
|
export const listItemMetaProps = () => ({
|
||||||
avatar: PropTypes.any,
|
avatar: PropTypes.any,
|
||||||
description: PropTypes.any,
|
description: PropTypes.any,
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
title: PropTypes.any,
|
title: PropTypes.any,
|
||||||
};
|
});
|
||||||
|
|
||||||
export type ListItemMetaProps = Partial<ExtractPropTypes<typeof listItemMetaProps>>;
|
export type ListItemMetaProps = Partial<ExtractPropTypes<ReturnType<typeof listItemMetaProps>>>;
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'AListItemMeta',
|
name: 'AListItemMeta',
|
||||||
props: listItemMetaProps,
|
props: listItemMetaProps(),
|
||||||
displayName: 'AListItemMeta', // 兼容历史函数式组件
|
displayName: 'AListItemMeta', // 兼容历史函数式组件
|
||||||
__ANT_LIST_ITEM_META: true,
|
__ANT_LIST_ITEM_META: true,
|
||||||
slots: ['avatar', 'description', 'title'],
|
slots: ['avatar', 'description', 'title'],
|
||||||
|
|
|
@ -19,7 +19,7 @@ import type { Breakpoint } from '../_util/responsiveObserve';
|
||||||
import { responsiveArray } from '../_util/responsiveObserve';
|
import { responsiveArray } from '../_util/responsiveObserve';
|
||||||
import eagerComputed from '../_util/eagerComputed';
|
import eagerComputed from '../_util/eagerComputed';
|
||||||
|
|
||||||
export { ListItemProps } from './Item';
|
export type { ListItemProps } from './Item';
|
||||||
export type { ListItemMetaProps } from './ItemMeta';
|
export type { ListItemMetaProps } from './ItemMeta';
|
||||||
|
|
||||||
export type ColumnType = 'gutter' | 'column' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'xxxl';
|
export type ColumnType = 'gutter' | 'column' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'xxxl';
|
||||||
|
@ -57,7 +57,7 @@ export const listProps = () => ({
|
||||||
},
|
},
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
rowKey: [String, Number, Function] as PropType<Key | ((item: any) => Key)>,
|
rowKey: [String, Number, Function] as PropType<Key | ((item: any) => Key)>,
|
||||||
renderItem: PropTypes.any,
|
renderItem: Function as PropType<(opt: { item: any; index: number }) => any>,
|
||||||
size: String as PropType<ListSize>,
|
size: String as PropType<ListSize>,
|
||||||
split: { type: Boolean, default: undefined },
|
split: { type: Boolean, default: undefined },
|
||||||
header: PropTypes.any,
|
header: PropTypes.any,
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { flattenChildren, getOptionProps } from '../_util/props-util';
|
||||||
import { useInjectFormItemContext } from '../form/FormItemContext';
|
import { useInjectFormItemContext } from '../form/FormItemContext';
|
||||||
import omit from '../_util/omit';
|
import omit from '../_util/omit';
|
||||||
import { optionProps } from '../vc-mentions/src/Option';
|
import { optionProps } from '../vc-mentions/src/Option';
|
||||||
|
import type { KeyboardEventHandler } from '../_util/EventInterface';
|
||||||
|
|
||||||
interface MentionsConfig {
|
interface MentionsConfig {
|
||||||
prefix?: string | string[];
|
prefix?: string | string[];
|
||||||
|
@ -58,7 +59,7 @@ const getMentions = (value = '', config: MentionsConfig = {}): MentionsEntity[]
|
||||||
.filter((entity): entity is MentionsEntity => !!entity && !!entity.value);
|
.filter((entity): entity is MentionsEntity => !!entity && !!entity.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mentionsProps = {
|
export const mentionsProps = () => ({
|
||||||
...baseMentionsProps,
|
...baseMentionsProps,
|
||||||
loading: { type: Boolean, default: undefined },
|
loading: { type: Boolean, default: undefined },
|
||||||
onFocus: {
|
onFocus: {
|
||||||
|
@ -73,18 +74,23 @@ export const mentionsProps = {
|
||||||
onChange: {
|
onChange: {
|
||||||
type: Function as PropType<(text: string) => void>,
|
type: Function as PropType<(text: string) => void>,
|
||||||
},
|
},
|
||||||
|
onPressenter: {
|
||||||
|
type: Function as PropType<KeyboardEventHandler>,
|
||||||
|
},
|
||||||
|
'onUpdate:value': {
|
||||||
|
type: Function as PropType<(text: string) => void>,
|
||||||
|
},
|
||||||
notFoundContent: PropTypes.any,
|
notFoundContent: PropTypes.any,
|
||||||
defaultValue: String,
|
defaultValue: String,
|
||||||
id: String,
|
id: String,
|
||||||
};
|
});
|
||||||
|
|
||||||
export type MentionsProps = Partial<ExtractPropTypes<typeof mentionsProps>>;
|
export type MentionsProps = Partial<ExtractPropTypes<ReturnType<typeof mentionsProps>>>;
|
||||||
|
|
||||||
const Mentions = defineComponent({
|
const Mentions = defineComponent({
|
||||||
name: 'AMentions',
|
name: 'AMentions',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: mentionsProps,
|
props: mentionsProps(),
|
||||||
emits: ['update:value', 'change', 'focus', 'blur', 'select', 'pressenter'],
|
|
||||||
slots: ['notFoundContent', 'option'],
|
slots: ['notFoundContent', 'option'],
|
||||||
setup(props, { slots, emit, attrs, expose }) {
|
setup(props, { slots, emit, attrs, expose }) {
|
||||||
const { prefixCls, renderEmpty, direction } = useConfigInject('mentions', props);
|
const { prefixCls, renderEmpty, direction } = useConfigInject('mentions', props);
|
||||||
|
|
|
@ -28,7 +28,7 @@ export interface ImagePropsType extends Omit<ImgHTMLAttributes, 'placeholder' |
|
||||||
fallback?: string;
|
fallback?: string;
|
||||||
preview?: boolean | ImagePreviewType;
|
preview?: boolean | ImagePreviewType;
|
||||||
}
|
}
|
||||||
export const imageProps = {
|
export const imageProps = () => ({
|
||||||
src: String,
|
src: String,
|
||||||
wrapperClassName: String,
|
wrapperClassName: String,
|
||||||
wrapperStyle: { type: Object as PropType<CSSProperties>, default: undefined as CSSProperties },
|
wrapperStyle: { type: Object as PropType<CSSProperties>, default: undefined as CSSProperties },
|
||||||
|
@ -40,7 +40,7 @@ export const imageProps = {
|
||||||
type: [Boolean, Object] as PropType<boolean | ImagePreviewType>,
|
type: [Boolean, Object] as PropType<boolean | ImagePreviewType>,
|
||||||
default: true as boolean | ImagePreviewType,
|
default: true as boolean | ImagePreviewType,
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
type ImageStatus = 'normal' | 'error' | 'loading';
|
type ImageStatus = 'normal' | 'error' | 'loading';
|
||||||
|
|
||||||
const mergeDefaultValue = <T extends object>(obj: T, defaultValues: object): T => {
|
const mergeDefaultValue = <T extends object>(obj: T, defaultValues: object): T => {
|
||||||
|
@ -56,7 +56,7 @@ let uuid = 0;
|
||||||
const ImageInternal = defineComponent({
|
const ImageInternal = defineComponent({
|
||||||
name: 'Image',
|
name: 'Image',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: imageProps,
|
props: imageProps(),
|
||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
setup(props, { attrs, slots, emit }) {
|
setup(props, { attrs, slots, emit }) {
|
||||||
const prefixCls = computed(() => props.prefixCls);
|
const prefixCls = computed(() => props.prefixCls);
|
||||||
|
|
Loading…
Reference in New Issue