fix: row ts type not work
parent
31ca070a18
commit
31776a2cf8
|
@ -50,3 +50,11 @@ export function eventType<T>() {
|
||||||
export function objectType<T>(defaultVal?: any) {
|
export function objectType<T>(defaultVal?: any) {
|
||||||
return { type: Object as PropType<T>, default: defaultVal as T };
|
return { type: Object as PropType<T>, default: defaultVal as T };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function booleanType<T>(defaultVal?: any) {
|
||||||
|
return { type: Boolean as PropType<T>, default: defaultVal as T };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function someType<T>(types: any[], defaultVal?: any) {
|
||||||
|
return { type: types as PropType<T>, default: defaultVal as T };
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { ExtractPropTypes, CSSProperties, PropType } from 'vue';
|
import type { ExtractPropTypes, CSSProperties } from 'vue';
|
||||||
import { defineComponent, ref, onMounted, onBeforeUnmount, computed } from 'vue';
|
import { defineComponent, ref, onMounted, onBeforeUnmount, computed } from 'vue';
|
||||||
import classNames from '../_util/classNames';
|
import classNames from '../_util/classNames';
|
||||||
import type { Breakpoint, ScreenMap } from '../_util/responsiveObserve';
|
import type { Breakpoint, ScreenMap } from '../_util/responsiveObserve';
|
||||||
|
@ -7,6 +7,7 @@ import useConfigInject from '../config-provider/hooks/useConfigInject';
|
||||||
import useFlexGapSupport from '../_util/hooks/useFlexGapSupport';
|
import useFlexGapSupport from '../_util/hooks/useFlexGapSupport';
|
||||||
import useProvideRow from './context';
|
import useProvideRow from './context';
|
||||||
import { useRowStyle } from './style';
|
import { useRowStyle } from './style';
|
||||||
|
import { someType } from '../_util/type';
|
||||||
|
|
||||||
const RowAligns = ['top', 'middle', 'bottom', 'stretch'] as const;
|
const RowAligns = ['top', 'middle', 'bottom', 'stretch'] as const;
|
||||||
const RowJustify = [
|
const RowJustify = [
|
||||||
|
@ -34,13 +35,10 @@ export interface rowContextState {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const rowProps = () => ({
|
export const rowProps = () => ({
|
||||||
align: [String, Object] as PropType<(typeof RowAligns)[number] | ResponsiveAligns>,
|
align: someType<(typeof RowAligns)[number] | ResponsiveAligns>([String, Object]),
|
||||||
justify: [String, Object] as PropType<(typeof RowJustify)[number] | ResponsiveJustify>,
|
justify: someType<(typeof RowJustify)[number] | ResponsiveJustify>([String, Object]),
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
gutter: {
|
gutter: someType<Gutter | [Gutter, Gutter]>([Number, Array, Object], 0),
|
||||||
type: [Number, Array, Object] as PropType<Gutter | [Gutter, Gutter]>,
|
|
||||||
default: 0 as Gutter | [Gutter, Gutter],
|
|
||||||
},
|
|
||||||
wrap: { type: Boolean, default: undefined },
|
wrap: { type: Boolean, default: undefined },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -49,8 +47,8 @@ export type RowProps = Partial<ExtractPropTypes<ReturnType<typeof rowProps>>>;
|
||||||
const ARow = defineComponent({
|
const ARow = defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
compatConfig: { MODE: 3 },
|
||||||
name: 'ARow',
|
name: 'ARow',
|
||||||
props: rowProps(),
|
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
|
props: rowProps(),
|
||||||
setup(props, { slots, attrs }) {
|
setup(props, { slots, attrs }) {
|
||||||
const { prefixCls, direction } = useConfigInject('row', props);
|
const { prefixCls, direction } = useConfigInject('row', props);
|
||||||
const [wrapSSR, hashId] = useRowStyle(prefixCls);
|
const [wrapSSR, hashId] = useRowStyle(prefixCls);
|
||||||
|
|
Loading…
Reference in New Issue