✨(component): 完善 ts 类型
This commit is contained in:
parent
dbf9374b6b
commit
e8f8c8c2ea
@ -1,5 +1,5 @@
|
||||
export type ButtonType = "primary" | "normal" | "warm" | "danger";
|
||||
export type ButtonSize = "lg" | "sm" | "xs";
|
||||
export type ButtonSize = "lg" | "md" | "sm" | "xs";
|
||||
export type ButtonBorder = "green" | "blue" | "orange" | "red" | "black";
|
||||
export type ButtonNativeType = "button" | "submit" | "reset";
|
||||
|
||||
|
@ -74,10 +74,11 @@ import LayInput from "../input/index.vue";
|
||||
import LayScroll from "../scroll/index.vue";
|
||||
import LayDropdown from "../dropdown/index.vue";
|
||||
import { ref, onMounted, watch, useSlots } from "vue";
|
||||
import { CascaderSize } from "./interface";
|
||||
|
||||
export type DropdownTrigger = "click" | "hover" | "focus" | "contextMenu";
|
||||
|
||||
export interface LayCascaderProps {
|
||||
export interface CascaderProps {
|
||||
options?: Array<any> | null;
|
||||
modelValue?: string;
|
||||
decollator?: string;
|
||||
@ -85,11 +86,11 @@ export interface LayCascaderProps {
|
||||
onlyLastLevel?: boolean;
|
||||
replaceFields?: { label: string; value: string; children: string };
|
||||
allowClear?: boolean;
|
||||
size?: "lg" | "md" | "sm" | "xs";
|
||||
size?: CascaderSize;
|
||||
trigger?: DropdownTrigger | DropdownTrigger[];
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<LayCascaderProps>(), {
|
||||
const props = withDefaults(defineProps<CascaderProps>(), {
|
||||
options: null,
|
||||
modelValue: "",
|
||||
decollator: "/",
|
||||
|
1
package/component/src/component/cascader/interface.ts
Normal file
1
package/component/src/component/cascader/interface.ts
Normal file
@ -0,0 +1 @@
|
||||
export type CascaderSize = "lg" | "md" | "sm" | "xs";
|
@ -8,6 +8,7 @@ export default {
|
||||
import { LayIcon } from "@layui/icons-vue";
|
||||
import { computed, inject, useSlots } from "vue";
|
||||
import "./index.less";
|
||||
import { CheckboxSize } from "./interface";
|
||||
|
||||
export interface LayCheckboxProps {
|
||||
name?: string;
|
||||
@ -17,7 +18,7 @@ export interface LayCheckboxProps {
|
||||
isIndeterminate?: boolean;
|
||||
modelValue?: boolean | Array<string | number | object>;
|
||||
disabled?: boolean;
|
||||
size?: "lg" | "md" | "sm" | "xs";
|
||||
size?: CheckboxSize;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<LayCheckboxProps>(), {
|
||||
|
@ -0,0 +1 @@
|
||||
export type CheckboxSize = "lg" | "md" | "sm" | "xs";
|
@ -29,7 +29,7 @@ provide("checkboxGroup", {
|
||||
});
|
||||
|
||||
watch(
|
||||
() => modelValue,
|
||||
() => modelValue,
|
||||
(val) => {
|
||||
emit("change", modelValue.value);
|
||||
emit("update:modelValue", modelValue.value);
|
||||
|
@ -8,25 +8,25 @@ export default {
|
||||
import "./index.less";
|
||||
import { withDefaults, provide, ref, watch } from "vue";
|
||||
|
||||
export interface LayCollapseProps {
|
||||
modelValue?: number | string | [];
|
||||
export interface CollapseProps {
|
||||
accordion?: boolean;
|
||||
modelValue?: number | string | number[] | string[];
|
||||
collapseTransition?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<LayCollapseProps>(), {
|
||||
const props = withDefaults(defineProps<CollapseProps>(), {
|
||||
modelValue: () => [],
|
||||
accordion: false,
|
||||
collapseTransition: true,
|
||||
});
|
||||
|
||||
// 监听传入的值
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val, oldVal) => {
|
||||
(val) => {
|
||||
activeValues.value = ([] as any[]).concat(val);
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:modelValue", "change"]);
|
||||
|
||||
const activeValues = ref<Array<any>>(([] as any[]).concat(props.modelValue));
|
||||
|
@ -8,13 +8,13 @@ export default {
|
||||
import LayTransition from "../transition/index.vue";
|
||||
import { withDefaults, inject, computed, ref } from "vue";
|
||||
|
||||
export interface LayCollapseItemProps {
|
||||
export interface CollapseItemProps {
|
||||
id: number | string;
|
||||
title: string;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<LayCollapseItemProps>(), {
|
||||
const props = withDefaults(defineProps<CollapseItemProps>(), {
|
||||
disabled: false,
|
||||
});
|
||||
|
||||
|
@ -41,12 +41,9 @@ const props = withDefaults(defineProps<LayCountupProps>(), {
|
||||
let localStartVal: Ref<number> = ref(props.startVal);
|
||||
const isNumber = (val: string) => !isNaN(parseFloat(val));
|
||||
|
||||
/**
|
||||
* from: https://github.com/PanJiaChen/vue-countTo/blob/master/src/vue-countTo.vue
|
||||
* @description 格式化数字
|
||||
* @param num 要格式化的数字
|
||||
* @returns 格式化后的数字
|
||||
*/
|
||||
/**
|
||||
* from: https://github.com/PanJiaChen/vue-countTo/blob/master/src/vue-countTo.vue
|
||||
* */
|
||||
const formatNumber = (num: number | string): string => {
|
||||
if (typeof num != "number") return "0";
|
||||
num = num.toFixed(props.decimalPlaces);
|
||||
@ -69,6 +66,7 @@ const printVal = useTransition(localStartVal, {
|
||||
disabled: !props.useEasing,
|
||||
transition:
|
||||
typeof props.easingFn === "string"
|
||||
// @ts-ignore
|
||||
? TransitionPresets[props.easingFn]
|
||||
: props.easingFn,
|
||||
});
|
||||
|
@ -11,6 +11,7 @@ import { computed, ref, useSlots, watch } from "vue";
|
||||
import { useI18n } from "../../language";
|
||||
import PasswordIcon from "./svg/Password.vue";
|
||||
import UnPasswordIcon from "./svg/unPassword.vue";
|
||||
import { InputSize } from "./interface";
|
||||
|
||||
export interface LayInputProps {
|
||||
name?: string;
|
||||
@ -25,7 +26,7 @@ export interface LayInputProps {
|
||||
disabled?: boolean;
|
||||
readonly?: boolean;
|
||||
password?: boolean;
|
||||
size?: "lg" | "md" | "sm" | "xs";
|
||||
size?: InputSize;
|
||||
maxlength?: number;
|
||||
}
|
||||
|
||||
|
1
package/component/src/component/input/interface.ts
Normal file
1
package/component/src/component/input/interface.ts
Normal file
@ -0,0 +1 @@
|
||||
export type InputSize = "lg" | "md" | "sm" | "xs";
|
@ -10,6 +10,7 @@ import layInput from "../input/index.vue";
|
||||
import { LayIcon } from "@layui/icons-vue";
|
||||
import layButton from "../button/index.vue";
|
||||
import { ref, watch, withDefaults, computed, Ref } from "vue";
|
||||
import { InputNumberSize } from "./interface";
|
||||
|
||||
export interface LayInputNumberProps {
|
||||
modelValue?: number;
|
||||
@ -20,7 +21,7 @@ export interface LayInputNumberProps {
|
||||
position?: "right";
|
||||
min?: number;
|
||||
max?: number;
|
||||
size?: "lg" | "md" | "sm" | "xs";
|
||||
size?: InputNumberSize;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<LayInputNumberProps>(), {
|
||||
|
1
package/component/src/component/inputNumber/interface.ts
Normal file
1
package/component/src/component/inputNumber/interface.ts
Normal file
@ -0,0 +1 @@
|
||||
export type InputNumberSize = "lg" | "md" | "sm" | "xs";
|
@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { computed, inject } from "vue";
|
||||
import { RadioSize } from "./interface";
|
||||
export default {
|
||||
name: "LayRadio",
|
||||
};
|
||||
@ -10,7 +11,7 @@ import "./index.less";
|
||||
|
||||
export interface LayRadioProps {
|
||||
name?: string;
|
||||
size?: "lg" | "md" | "sm" | "xs";
|
||||
size?: RadioSize;
|
||||
disabled?: boolean;
|
||||
modelValue?: string | boolean | number;
|
||||
value?: string | boolean | number;
|
||||
|
@ -0,0 +1 @@
|
||||
export type RadioSize = "lg" | "md" | "sm" | "xs";
|
@ -8,7 +8,7 @@ export default {
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import "./index.less";
|
||||
|
||||
export interface LayRippletProps {
|
||||
export interface RippleProps {
|
||||
type?: "out" | "inset";
|
||||
color?: string;
|
||||
borderRadius?: string;
|
||||
@ -18,7 +18,7 @@ export interface LayRippletProps {
|
||||
center?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<LayRippletProps>(), {
|
||||
const props = withDefaults(defineProps<RippleProps>(), {
|
||||
type: "inset",
|
||||
color: "currentColor",
|
||||
borderRadius: "0",
|
||||
|
@ -28,6 +28,7 @@ import LaySelectOption, {
|
||||
LaySelectOptionProps,
|
||||
} from "../selectOption/index.vue";
|
||||
import { arrayExpression } from "@babel/types";
|
||||
import { SelectSize } from "./interface";
|
||||
|
||||
export interface LaySelectProps {
|
||||
name?: string;
|
||||
@ -39,7 +40,7 @@ export interface LaySelectProps {
|
||||
modelValue?: any;
|
||||
multiple?: boolean;
|
||||
items?: LaySelectOptionProps[];
|
||||
size?: "lg" | "md" | "sm" | "xs";
|
||||
size?: SelectSize;
|
||||
collapseTagsTooltip?: boolean;
|
||||
minCollapsedNum?: number;
|
||||
allowClear?: boolean;
|
||||
|
1
package/component/src/component/select/interface.ts
Normal file
1
package/component/src/component/select/interface.ts
Normal file
@ -0,0 +1 @@
|
||||
export type SelectSize = "lg" | "md" | "sm" | "xs";
|
@ -18,6 +18,7 @@ import {
|
||||
} from "vue";
|
||||
import { isObject, reactiveOmit, useResizeObserver } from "@vueuse/core";
|
||||
import { LayIcon } from "@layui/icons-vue";
|
||||
import { TagInputSize } from "./inerface";
|
||||
|
||||
export interface TagData {
|
||||
value?: string | number;
|
||||
@ -36,7 +37,7 @@ export interface LayTagInputProps {
|
||||
max?: number;
|
||||
minCollapsedNum?: number;
|
||||
collapseTagsTooltip?: boolean;
|
||||
size?: "lg" | "md" | "sm" | "xs";
|
||||
size?: TagInputSize;
|
||||
tagProps?: LayTagProps;
|
||||
disabledInput?: boolean;
|
||||
}
|
||||
|
1
package/component/src/component/tagInput/inerface.ts
Normal file
1
package/component/src/component/tagInput/inerface.ts
Normal file
@ -0,0 +1 @@
|
||||
export type TagInputSize = "lg" | "md" | "sm" | "xs";
|
Loading…
Reference in New Issue
Block a user