first commit
This commit is contained in:
76
node_modules/vant/lib/signature/Signature.d.ts
generated
vendored
Normal file
76
node_modules/vant/lib/signature/Signature.d.ts
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
import { type ExtractPropTypes } from 'vue';
|
||||
export declare const signatureProps: {
|
||||
tips: StringConstructor;
|
||||
type: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
penColor: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
lineWidth: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
clearButtonText: StringConstructor;
|
||||
backgroundColor: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
confirmButtonText: StringConstructor;
|
||||
};
|
||||
export type SignatureProps = ExtractPropTypes<typeof signatureProps>;
|
||||
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
||||
tips: StringConstructor;
|
||||
type: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
penColor: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
lineWidth: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
clearButtonText: StringConstructor;
|
||||
backgroundColor: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
confirmButtonText: StringConstructor;
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("submit" | "clear" | "start" | "end" | "signing")[], "submit" | "clear" | "start" | "end" | "signing", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
||||
tips: StringConstructor;
|
||||
type: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
penColor: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
lineWidth: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
clearButtonText: StringConstructor;
|
||||
backgroundColor: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
confirmButtonText: StringConstructor;
|
||||
}>> & Readonly<{
|
||||
onSubmit?: ((...args: any[]) => any) | undefined;
|
||||
onClear?: ((...args: any[]) => any) | undefined;
|
||||
onStart?: ((...args: any[]) => any) | undefined;
|
||||
onEnd?: ((...args: any[]) => any) | undefined;
|
||||
onSigning?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
type: string;
|
||||
backgroundColor: string;
|
||||
lineWidth: number;
|
||||
penColor: string;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
180
node_modules/vant/lib/signature/Signature.js
generated
vendored
Normal file
180
node_modules/vant/lib/signature/Signature.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name2 in all)
|
||||
__defProp(target, name2, { get: all[name2], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
default: () => stdin_default,
|
||||
signatureProps: () => signatureProps
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_vue = require("vue");
|
||||
var import_utils = require("../utils");
|
||||
var import_use = require("@vant/use");
|
||||
var import_use_expose = require("../composables/use-expose");
|
||||
var import_button = require("../button");
|
||||
const [name, bem, t] = (0, import_utils.createNamespace)("signature");
|
||||
const signatureProps = {
|
||||
tips: String,
|
||||
type: (0, import_utils.makeStringProp)("png"),
|
||||
penColor: (0, import_utils.makeStringProp)("#000"),
|
||||
lineWidth: (0, import_utils.makeNumberProp)(3),
|
||||
clearButtonText: String,
|
||||
backgroundColor: (0, import_utils.makeStringProp)(""),
|
||||
confirmButtonText: String
|
||||
};
|
||||
const hasCanvasSupport = () => {
|
||||
var _a;
|
||||
const canvas = document.createElement("canvas");
|
||||
return !!((_a = canvas.getContext) == null ? void 0 : _a.call(canvas, "2d"));
|
||||
};
|
||||
var stdin_default = (0, import_vue.defineComponent)({
|
||||
name,
|
||||
props: signatureProps,
|
||||
emits: ["submit", "clear", "start", "end", "signing"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
const canvasRef = (0, import_vue.ref)();
|
||||
const wrapRef = (0, import_vue.ref)();
|
||||
const ctx = (0, import_vue.computed)(() => {
|
||||
if (!canvasRef.value) return null;
|
||||
return canvasRef.value.getContext("2d");
|
||||
});
|
||||
const isRenderCanvas = import_utils.inBrowser ? hasCanvasSupport() : true;
|
||||
let canvasWidth = 0;
|
||||
let canvasHeight = 0;
|
||||
let canvasRect;
|
||||
const touchStart = () => {
|
||||
if (!ctx.value) {
|
||||
return false;
|
||||
}
|
||||
ctx.value.beginPath();
|
||||
ctx.value.lineWidth = props.lineWidth;
|
||||
ctx.value.strokeStyle = props.penColor;
|
||||
canvasRect = (0, import_use.useRect)(canvasRef);
|
||||
emit("start");
|
||||
};
|
||||
const touchMove = (event) => {
|
||||
if (!ctx.value) {
|
||||
return false;
|
||||
}
|
||||
(0, import_utils.preventDefault)(event);
|
||||
const touch = event.touches[0];
|
||||
const mouseX = touch.clientX - ((canvasRect == null ? void 0 : canvasRect.left) || 0);
|
||||
const mouseY = touch.clientY - ((canvasRect == null ? void 0 : canvasRect.top) || 0);
|
||||
ctx.value.lineCap = "round";
|
||||
ctx.value.lineJoin = "round";
|
||||
ctx.value.lineTo(mouseX, mouseY);
|
||||
ctx.value.stroke();
|
||||
emit("signing", event);
|
||||
};
|
||||
const touchEnd = (event) => {
|
||||
(0, import_utils.preventDefault)(event);
|
||||
emit("end");
|
||||
};
|
||||
const isCanvasEmpty = (canvas) => {
|
||||
const empty = document.createElement("canvas");
|
||||
empty.width = canvas.width;
|
||||
empty.height = canvas.height;
|
||||
if (props.backgroundColor) {
|
||||
const emptyCtx = empty.getContext("2d");
|
||||
setCanvasBgColor(emptyCtx);
|
||||
}
|
||||
return canvas.toDataURL() === empty.toDataURL();
|
||||
};
|
||||
const setCanvasBgColor = (ctx2) => {
|
||||
if (ctx2 && props.backgroundColor) {
|
||||
ctx2.fillStyle = props.backgroundColor;
|
||||
ctx2.fillRect(0, 0, canvasWidth, canvasHeight);
|
||||
}
|
||||
};
|
||||
const submit = () => {
|
||||
var _a, _b;
|
||||
const canvas = canvasRef.value;
|
||||
if (!canvas) {
|
||||
return;
|
||||
}
|
||||
const isEmpty = isCanvasEmpty(canvas);
|
||||
const image = isEmpty ? "" : ((_b = (_a = {
|
||||
jpg: () => canvas.toDataURL("image/jpeg", 0.8),
|
||||
jpeg: () => canvas.toDataURL("image/jpeg", 0.8)
|
||||
})[props.type]) == null ? void 0 : _b.call(_a)) || canvas.toDataURL(`image/${props.type}`);
|
||||
emit("submit", {
|
||||
image,
|
||||
canvas
|
||||
});
|
||||
};
|
||||
const clear = () => {
|
||||
if (ctx.value) {
|
||||
ctx.value.clearRect(0, 0, canvasWidth, canvasHeight);
|
||||
ctx.value.closePath();
|
||||
setCanvasBgColor(ctx.value);
|
||||
}
|
||||
emit("clear");
|
||||
};
|
||||
const initialize = () => {
|
||||
var _a, _b, _c;
|
||||
if (isRenderCanvas && canvasRef.value) {
|
||||
const canvas = canvasRef.value;
|
||||
const dpr = import_utils.inBrowser ? window.devicePixelRatio : 1;
|
||||
canvasWidth = canvas.width = (((_a = wrapRef.value) == null ? void 0 : _a.offsetWidth) || 0) * dpr;
|
||||
canvasHeight = canvas.height = (((_b = wrapRef.value) == null ? void 0 : _b.offsetHeight) || 0) * dpr;
|
||||
(_c = ctx.value) == null ? void 0 : _c.scale(dpr, dpr);
|
||||
setCanvasBgColor(ctx.value);
|
||||
}
|
||||
};
|
||||
const resize = () => {
|
||||
if (ctx.value) {
|
||||
const data = ctx.value.getImageData(0, 0, canvasWidth, canvasHeight);
|
||||
initialize();
|
||||
ctx.value.putImageData(data, 0, 0);
|
||||
}
|
||||
};
|
||||
(0, import_vue.watch)(import_utils.windowWidth, resize);
|
||||
(0, import_vue.onMounted)(initialize);
|
||||
(0, import_use_expose.useExpose)({
|
||||
resize,
|
||||
clear,
|
||||
submit
|
||||
});
|
||||
return () => (0, import_vue.createVNode)("div", {
|
||||
"class": bem()
|
||||
}, [(0, import_vue.createVNode)("div", {
|
||||
"class": bem("content"),
|
||||
"ref": wrapRef
|
||||
}, [isRenderCanvas ? (0, import_vue.createVNode)("canvas", {
|
||||
"ref": canvasRef,
|
||||
"onTouchstartPassive": touchStart,
|
||||
"onTouchmove": touchMove,
|
||||
"onTouchend": touchEnd
|
||||
}, null) : slots.tips ? slots.tips() : (0, import_vue.createVNode)("p", null, [props.tips])]), (0, import_vue.createVNode)("div", {
|
||||
"class": bem("footer")
|
||||
}, [(0, import_vue.createVNode)(import_button.Button, {
|
||||
"size": "small",
|
||||
"onClick": clear
|
||||
}, {
|
||||
default: () => [props.clearButtonText || t("clear")]
|
||||
}), (0, import_vue.createVNode)(import_button.Button, {
|
||||
"type": "primary",
|
||||
"size": "small",
|
||||
"onClick": submit
|
||||
}, {
|
||||
default: () => [props.confirmButtonText || t("confirm")]
|
||||
})])]);
|
||||
}
|
||||
});
|
||||
1
node_modules/vant/lib/signature/index.css
generated
vendored
Normal file
1
node_modules/vant/lib/signature/index.css
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
:root,:host{--van-signature-padding: var(--van-padding-xs);--van-signature-content-height: 200px;--van-signature-content-background: var(--van-background-2);--van-signature-content-border: 1px dotted #dadada}.van-signature{padding:var(--van-signature-padding)}.van-signature__content{display:flex;justify-content:center;align-items:center;height:var(--van-signature-content-height);background-color:var(--van-signature-content-background);border:var(--van-signature-content-border);border-radius:var(--van-radius-lg);overflow:hidden}.van-signature__content canvas{width:100%;height:100%}.van-signature__footer{display:flex;justify-content:flex-end}.van-signature__footer .van-button{padding:0 var(--van-padding-md);margin-top:var(--van-padding-xs);margin-left:var(--van-padding-xs)}
|
||||
60
node_modules/vant/lib/signature/index.d.ts
generated
vendored
Normal file
60
node_modules/vant/lib/signature/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
export declare const Signature: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
tips: StringConstructor;
|
||||
type: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
penColor: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
lineWidth: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
clearButtonText: StringConstructor;
|
||||
backgroundColor: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
confirmButtonText: StringConstructor;
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("submit" | "clear" | "start" | "end" | "signing")[], "submit" | "clear" | "start" | "end" | "signing", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
tips: StringConstructor;
|
||||
type: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
penColor: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
lineWidth: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
clearButtonText: StringConstructor;
|
||||
backgroundColor: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
confirmButtonText: StringConstructor;
|
||||
}>> & Readonly<{
|
||||
onSubmit?: ((...args: any[]) => any) | undefined;
|
||||
onClear?: ((...args: any[]) => any) | undefined;
|
||||
onStart?: ((...args: any[]) => any) | undefined;
|
||||
onEnd?: ((...args: any[]) => any) | undefined;
|
||||
onSigning?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
type: string;
|
||||
backgroundColor: string;
|
||||
lineWidth: number;
|
||||
penColor: string;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
||||
export default Signature;
|
||||
export type { SignatureProps } from './Signature';
|
||||
export type { SignatureInstance, SignatureThemeVars } from './types';
|
||||
declare module 'vue' {
|
||||
interface GlobalComponents {
|
||||
Signature: typeof Signature;
|
||||
}
|
||||
}
|
||||
37
node_modules/vant/lib/signature/index.js
generated
vendored
Normal file
37
node_modules/vant/lib/signature/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
Signature: () => Signature,
|
||||
default: () => stdin_default
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_utils = require("../utils");
|
||||
var import_Signature = __toESM(require("./Signature"));
|
||||
const Signature = (0, import_utils.withInstall)(import_Signature.default);
|
||||
var stdin_default = Signature;
|
||||
1
node_modules/vant/lib/signature/style/index.d.ts
generated
vendored
Normal file
1
node_modules/vant/lib/signature/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
6
node_modules/vant/lib/signature/style/index.js
generated
vendored
Normal file
6
node_modules/vant/lib/signature/style/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
require("../../style/base.css");
|
||||
require("../../badge/index.css");
|
||||
require("../../icon/index.css");
|
||||
require("../../loading/index.css");
|
||||
require("../../button/index.css");
|
||||
require("../index.css");
|
||||
14
node_modules/vant/lib/signature/types.d.ts
generated
vendored
Normal file
14
node_modules/vant/lib/signature/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { ComponentPublicInstance } from 'vue';
|
||||
import type { SignatureProps } from './Signature';
|
||||
export type SignatureExpose = {
|
||||
resize: () => void;
|
||||
clear: () => void;
|
||||
submit: () => void;
|
||||
};
|
||||
export type SignatureInstance = ComponentPublicInstance<SignatureProps, SignatureExpose>;
|
||||
export type SignatureThemeVars = {
|
||||
signaturePadding?: string;
|
||||
signatureContentHeight?: string;
|
||||
signatureContentBackground?: string;
|
||||
signatureContentBorder?: string;
|
||||
};
|
||||
15
node_modules/vant/lib/signature/types.js
generated
vendored
Normal file
15
node_modules/vant/lib/signature/types.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
Reference in New Issue
Block a user