types(Progress): add ProgressInstance type (#9247)

This commit is contained in:
neverland
2021-08-12 10:19:51 +08:00
committed by GitHub
parent 713be26ed2
commit a02cec0f5f
5 changed files with 59 additions and 17 deletions
+21 -17
View File
@@ -6,30 +6,34 @@ import {
reactive,
onMounted,
defineComponent,
ExtractPropTypes,
} from 'vue';
import { truthProp, createNamespace, addUnit } from '../utils';
import { useExpose } from '../composables/use-expose';
const [name, bem] = createNamespace('progress');
const props = {
color: String,
inactive: Boolean,
pivotText: String,
textColor: String,
showPivot: truthProp,
pivotColor: String,
trackColor: String,
strokeWidth: [Number, String],
percentage: {
type: [Number, String],
validator: (value: number | string) => value >= 0 && value <= 100,
},
};
export type ProgressProps = ExtractPropTypes<typeof props>;
export default defineComponent({
name,
props: {
color: String,
inactive: Boolean,
pivotText: String,
textColor: String,
showPivot: truthProp,
pivotColor: String,
trackColor: String,
strokeWidth: [Number, String],
percentage: {
type: [Number, String],
required: true,
validator: (value: number | string) => value >= 0 && value <= 100,
},
},
props,
setup(props) {
const root = ref<HTMLElement>();
@@ -58,7 +62,7 @@ export default defineComponent({
const show = props.showPivot && text;
if (show) {
const left = ((rootWidth - pivotWidth) * +percentage) / 100;
const left = ((rootWidth - pivotWidth) * +percentage!) / 100;
const style = {
color: textColor,
left: `${left}px`,
@@ -85,7 +89,7 @@ export default defineComponent({
};
const portionStyle = {
background: background.value,
width: (state.rootWidth * +percentage) / 100 + 'px',
width: (state.rootWidth * +percentage!) / 100 + 'px',
};
return (