first commit
This commit is contained in:
118
node_modules/vant/es/circle/Circle.d.ts
generated
vendored
Normal file
118
node_modules/vant/es/circle/Circle.d.ts
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
import { type PropType, type ExtractPropTypes } from 'vue';
|
||||
export type CircleStartPosition = 'top' | 'right' | 'bottom' | 'left';
|
||||
export declare const circleProps: {
|
||||
text: StringConstructor;
|
||||
size: (NumberConstructor | StringConstructor)[];
|
||||
fill: {
|
||||
type: PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
rate: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
speed: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
color: PropType<string | Record<string, string>>;
|
||||
clockwise: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
layerColor: StringConstructor;
|
||||
currentRate: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
strokeWidth: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
strokeLinecap: PropType<CanvasLineCap>;
|
||||
startPosition: {
|
||||
type: PropType<CircleStartPosition>;
|
||||
default: CircleStartPosition;
|
||||
};
|
||||
};
|
||||
export type CircleProps = ExtractPropTypes<typeof circleProps>;
|
||||
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
||||
text: StringConstructor;
|
||||
size: (NumberConstructor | StringConstructor)[];
|
||||
fill: {
|
||||
type: PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
rate: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
speed: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
color: PropType<string | Record<string, string>>;
|
||||
clockwise: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
layerColor: StringConstructor;
|
||||
currentRate: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
strokeWidth: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
strokeLinecap: PropType<CanvasLineCap>;
|
||||
startPosition: {
|
||||
type: PropType<CircleStartPosition>;
|
||||
default: CircleStartPosition;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:currentRate"[], "update:currentRate", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
||||
text: StringConstructor;
|
||||
size: (NumberConstructor | StringConstructor)[];
|
||||
fill: {
|
||||
type: PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
rate: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
speed: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
color: PropType<string | Record<string, string>>;
|
||||
clockwise: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
layerColor: StringConstructor;
|
||||
currentRate: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
strokeWidth: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
strokeLinecap: PropType<CanvasLineCap>;
|
||||
startPosition: {
|
||||
type: PropType<CircleStartPosition>;
|
||||
default: CircleStartPosition;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
"onUpdate:currentRate"?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
fill: string;
|
||||
strokeWidth: string | number;
|
||||
rate: string | number;
|
||||
speed: string | number;
|
||||
clockwise: boolean;
|
||||
currentRate: number;
|
||||
startPosition: CircleStartPosition;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
152
node_modules/vant/es/circle/Circle.mjs
generated
vendored
Normal file
152
node_modules/vant/es/circle/Circle.mjs
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
import { watch, computed, defineComponent, createVNode as _createVNode } from "vue";
|
||||
import { raf, cancelRaf } from "@vant/use";
|
||||
import { isObject, truthProp, numericProp, getSizeStyle, makeStringProp, makeNumberProp, makeNumericProp, createNamespace } from "../utils/index.mjs";
|
||||
const [name, bem] = createNamespace("circle");
|
||||
let uid = 0;
|
||||
const format = (rate) => Math.min(Math.max(+rate, 0), 100);
|
||||
function getPath(clockwise, viewBoxSize) {
|
||||
const sweepFlag = clockwise ? 1 : 0;
|
||||
return `M ${viewBoxSize / 2} ${viewBoxSize / 2} m 0, -500 a 500, 500 0 1, ${sweepFlag} 0, 1000 a 500, 500 0 1, ${sweepFlag} 0, -1000`;
|
||||
}
|
||||
const circleProps = {
|
||||
text: String,
|
||||
size: numericProp,
|
||||
fill: makeStringProp("none"),
|
||||
rate: makeNumericProp(100),
|
||||
speed: makeNumericProp(0),
|
||||
color: [String, Object],
|
||||
clockwise: truthProp,
|
||||
layerColor: String,
|
||||
currentRate: makeNumberProp(0),
|
||||
strokeWidth: makeNumericProp(40),
|
||||
strokeLinecap: String,
|
||||
startPosition: makeStringProp("top")
|
||||
};
|
||||
var stdin_default = defineComponent({
|
||||
name,
|
||||
props: circleProps,
|
||||
emits: ["update:currentRate"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
const id = `van-circle-${uid++}`;
|
||||
const viewBoxSize = computed(() => +props.strokeWidth + 1e3);
|
||||
const path = computed(() => getPath(props.clockwise, viewBoxSize.value));
|
||||
const svgStyle = computed(() => {
|
||||
const ROTATE_ANGLE_MAP = {
|
||||
top: 0,
|
||||
right: 90,
|
||||
bottom: 180,
|
||||
left: 270
|
||||
};
|
||||
const angleValue = ROTATE_ANGLE_MAP[props.startPosition];
|
||||
if (angleValue) {
|
||||
return {
|
||||
transform: `rotate(${angleValue}deg)`
|
||||
};
|
||||
}
|
||||
});
|
||||
watch(() => props.rate, (rate) => {
|
||||
let rafId;
|
||||
const startTime = Date.now();
|
||||
const startRate = props.currentRate;
|
||||
const endRate = format(rate);
|
||||
const duration = Math.abs((startRate - endRate) * 1e3 / +props.speed);
|
||||
const animate = () => {
|
||||
const now = Date.now();
|
||||
const progress = Math.min((now - startTime) / duration, 1);
|
||||
const rate2 = progress * (endRate - startRate) + startRate;
|
||||
emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
|
||||
if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
|
||||
rafId = raf(animate);
|
||||
}
|
||||
};
|
||||
if (props.speed) {
|
||||
if (rafId) {
|
||||
cancelRaf(rafId);
|
||||
}
|
||||
rafId = raf(animate);
|
||||
} else {
|
||||
emit("update:currentRate", endRate);
|
||||
}
|
||||
}, {
|
||||
immediate: true
|
||||
});
|
||||
const renderHover = () => {
|
||||
const PERIMETER = 3140;
|
||||
const {
|
||||
strokeWidth,
|
||||
currentRate,
|
||||
strokeLinecap
|
||||
} = props;
|
||||
const offset = PERIMETER * currentRate / 100;
|
||||
const color = isObject(props.color) ? `url(#${id})` : props.color;
|
||||
const style = {
|
||||
stroke: color,
|
||||
strokeWidth: `${+strokeWidth + 1}px`,
|
||||
strokeLinecap,
|
||||
strokeDasharray: `${offset}px ${PERIMETER}px`
|
||||
};
|
||||
return _createVNode("path", {
|
||||
"d": path.value,
|
||||
"style": style,
|
||||
"class": bem("hover"),
|
||||
"stroke": color
|
||||
}, null);
|
||||
};
|
||||
const renderLayer = () => {
|
||||
const style = {
|
||||
fill: props.fill,
|
||||
stroke: props.layerColor,
|
||||
strokeWidth: `${props.strokeWidth}px`
|
||||
};
|
||||
return _createVNode("path", {
|
||||
"class": bem("layer"),
|
||||
"style": style,
|
||||
"d": path.value
|
||||
}, null);
|
||||
};
|
||||
const renderGradient = () => {
|
||||
const {
|
||||
color
|
||||
} = props;
|
||||
if (!isObject(color)) {
|
||||
return;
|
||||
}
|
||||
const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => _createVNode("stop", {
|
||||
"key": index,
|
||||
"offset": key,
|
||||
"stop-color": color[key]
|
||||
}, null));
|
||||
return _createVNode("defs", null, [_createVNode("linearGradient", {
|
||||
"id": id,
|
||||
"x1": "100%",
|
||||
"y1": "0%",
|
||||
"x2": "0%",
|
||||
"y2": "0%"
|
||||
}, [Stops])]);
|
||||
};
|
||||
const renderText = () => {
|
||||
if (slots.default) {
|
||||
return slots.default();
|
||||
}
|
||||
if (props.text) {
|
||||
return _createVNode("div", {
|
||||
"class": bem("text")
|
||||
}, [props.text]);
|
||||
}
|
||||
};
|
||||
return () => _createVNode("div", {
|
||||
"class": bem(),
|
||||
"style": getSizeStyle(props.size)
|
||||
}, [_createVNode("svg", {
|
||||
"viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
|
||||
"style": svgStyle.value
|
||||
}, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
|
||||
}
|
||||
});
|
||||
export {
|
||||
circleProps,
|
||||
stdin_default as default
|
||||
};
|
||||
1
node_modules/vant/es/circle/index.css
generated
vendored
Normal file
1
node_modules/vant/es/circle/index.css
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
:root,:host{--van-circle-size: 100px;--van-circle-color: var(--van-primary-color);--van-circle-layer-color: var(--van-white);--van-circle-text-color: var(--van-text-color);--van-circle-text-font-weight: var(--van-font-bold);--van-circle-text-font-size: var(--van-font-size-md);--van-circle-text-line-height: var(--van-line-height-md)}.van-circle{position:relative;display:inline-block;width:var(--van-circle-size);height:var(--van-circle-size);text-align:center}.van-circle svg{position:absolute;top:0;left:0;width:100%;height:100%}.van-circle__layer{stroke:var(--van-circle-layer-color)}.van-circle__hover{fill:none;stroke:var(--van-circle-color);stroke-linecap:round}.van-circle__text{position:absolute;top:50%;left:0;box-sizing:border-box;width:100%;padding:0 var(--van-padding-base);color:var(--van-circle-text-color);font-weight:var(--van-circle-text-font-weight);font-size:var(--van-circle-text-font-size);line-height:var(--van-circle-text-line-height);transform:translateY(-50%)}
|
||||
88
node_modules/vant/es/circle/index.d.ts
generated
vendored
Normal file
88
node_modules/vant/es/circle/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
export declare const Circle: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
text: StringConstructor;
|
||||
size: (NumberConstructor | StringConstructor)[];
|
||||
fill: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
rate: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
speed: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
color: import("vue").PropType<string | Record<string, string>>;
|
||||
clockwise: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
layerColor: StringConstructor;
|
||||
currentRate: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
strokeWidth: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
strokeLinecap: import("vue").PropType<CanvasLineCap>;
|
||||
startPosition: {
|
||||
type: import("vue").PropType<import("./Circle").CircleStartPosition>;
|
||||
default: import("./Circle").CircleStartPosition;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:currentRate"[], "update:currentRate", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
text: StringConstructor;
|
||||
size: (NumberConstructor | StringConstructor)[];
|
||||
fill: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
rate: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
speed: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
color: import("vue").PropType<string | Record<string, string>>;
|
||||
clockwise: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
layerColor: StringConstructor;
|
||||
currentRate: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
strokeWidth: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
strokeLinecap: import("vue").PropType<CanvasLineCap>;
|
||||
startPosition: {
|
||||
type: import("vue").PropType<import("./Circle").CircleStartPosition>;
|
||||
default: import("./Circle").CircleStartPosition;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
"onUpdate:currentRate"?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
fill: string;
|
||||
strokeWidth: string | number;
|
||||
rate: string | number;
|
||||
speed: string | number;
|
||||
clockwise: boolean;
|
||||
currentRate: number;
|
||||
startPosition: import("./Circle").CircleStartPosition;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
||||
export default Circle;
|
||||
export { circleProps } from './Circle';
|
||||
export type { CircleProps, CircleStartPosition } from './Circle';
|
||||
export type { CircleThemeVars } from './types';
|
||||
declare module 'vue' {
|
||||
interface GlobalComponents {
|
||||
VanCircle: typeof Circle;
|
||||
}
|
||||
}
|
||||
10
node_modules/vant/es/circle/index.mjs
generated
vendored
Normal file
10
node_modules/vant/es/circle/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { withInstall } from "../utils/index.mjs";
|
||||
import _Circle from "./Circle.mjs";
|
||||
const Circle = withInstall(_Circle);
|
||||
var stdin_default = Circle;
|
||||
import { circleProps } from "./Circle.mjs";
|
||||
export {
|
||||
Circle,
|
||||
circleProps,
|
||||
stdin_default as default
|
||||
};
|
||||
1
node_modules/vant/es/circle/style/index.d.ts
generated
vendored
Normal file
1
node_modules/vant/es/circle/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
2
node_modules/vant/es/circle/style/index.mjs
generated
vendored
Normal file
2
node_modules/vant/es/circle/style/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import "../../style/base.css";
|
||||
import "../index.css";
|
||||
9
node_modules/vant/es/circle/types.d.ts
generated
vendored
Normal file
9
node_modules/vant/es/circle/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export type CircleThemeVars = {
|
||||
circleSize?: string;
|
||||
circleColor?: string;
|
||||
circleLayerColor?: string;
|
||||
circleTextColor?: string;
|
||||
circleTextFontWeight?: string;
|
||||
circleTextFontSize?: string;
|
||||
circleTextLineHeight?: number | string;
|
||||
};
|
||||
0
node_modules/vant/es/circle/types.mjs
generated
vendored
Normal file
0
node_modules/vant/es/circle/types.mjs
generated
vendored
Normal file
Reference in New Issue
Block a user