first commit
This commit is contained in:
24
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/common/AbortablePromise.js
vendored
Normal file
24
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/common/AbortablePromise.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
class AbortablePromise {
|
||||
constructor(executor) {
|
||||
this._reject = null;
|
||||
this.promise = new Promise((resolve, reject) => {
|
||||
executor(resolve, reject);
|
||||
this._reject = reject;
|
||||
});
|
||||
}
|
||||
// 提供abort方法来中止Promise
|
||||
abort(error) {
|
||||
if (this._reject) {
|
||||
this._reject(error);
|
||||
}
|
||||
}
|
||||
then(onfulfilled, onrejected) {
|
||||
return this.promise.then(onfulfilled, onrejected);
|
||||
}
|
||||
catch(onrejected) {
|
||||
return this.promise.catch(onrejected);
|
||||
}
|
||||
}
|
||||
exports.AbortablePromise = AbortablePromise;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wot-design-uni/components/common/AbortablePromise.js.map
|
||||
28
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/common/base64.js
vendored
Normal file
28
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/common/base64.js
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
const _b64chars = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"];
|
||||
const _mkUriSafe = (src) => src.replace(/[+/]/g, (m0) => m0 === "+" ? "-" : "_").replace(/=+\$/m, "");
|
||||
const fromUint8Array = (src, rfc4648 = false) => {
|
||||
let b64 = "";
|
||||
for (let i = 0, l = src.length; i < l; i += 3) {
|
||||
const [a0, a1, a2] = [src[i], src[i + 1], src[i + 2]];
|
||||
const ord = a0 << 16 | a1 << 8 | a2;
|
||||
b64 += _b64chars[ord >>> 18];
|
||||
b64 += _b64chars[ord >>> 12 & 63];
|
||||
b64 += typeof a1 !== "undefined" ? _b64chars[ord >>> 6 & 63] : "=";
|
||||
b64 += typeof a2 !== "undefined" ? _b64chars[ord & 63] : "=";
|
||||
}
|
||||
return rfc4648 ? _mkUriSafe(b64) : b64;
|
||||
};
|
||||
const _btoa = typeof btoa === "function" ? (s) => btoa(s) : (s) => {
|
||||
if (s.charCodeAt(0) > 255) {
|
||||
throw new RangeError("The string contains invalid characters.");
|
||||
}
|
||||
return fromUint8Array(Uint8Array.from(s, (c) => c.charCodeAt(0)));
|
||||
};
|
||||
const utob = (src) => unescape(encodeURIComponent(src));
|
||||
function encode(src, rfc4648 = false) {
|
||||
const b64 = _btoa(utob(src));
|
||||
return rfc4648 ? _mkUriSafe(b64) : b64;
|
||||
}
|
||||
exports.encode = encode;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wot-design-uni/components/common/base64.js.map
|
||||
2
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/common/clickoutside.js
vendored
Normal file
2
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/common/clickoutside.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wot-design-uni/components/common/clickoutside.js.map
|
||||
31
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/common/interceptor.js
vendored
Normal file
31
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/common/interceptor.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
const uni_modules_wotDesignUni_components_common_util = require("./util.js");
|
||||
function noop() {
|
||||
}
|
||||
function callInterceptor(interceptor, {
|
||||
args = [],
|
||||
done,
|
||||
canceled,
|
||||
error
|
||||
}) {
|
||||
if (interceptor) {
|
||||
const returnVal = interceptor.apply(null, args);
|
||||
if (uni_modules_wotDesignUni_components_common_util.isPromise(returnVal)) {
|
||||
returnVal.then((value) => {
|
||||
if (value) {
|
||||
done();
|
||||
} else if (canceled) {
|
||||
canceled();
|
||||
}
|
||||
}).catch(error || noop);
|
||||
} else if (returnVal) {
|
||||
done();
|
||||
} else if (canceled) {
|
||||
canceled();
|
||||
}
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
}
|
||||
exports.callInterceptor = callInterceptor;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wot-design-uni/components/common/interceptor.js.map
|
||||
45
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/common/props.js
vendored
Normal file
45
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/common/props.js
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
const numericProp = [Number, String];
|
||||
const makeRequiredProp = (type) => ({
|
||||
type,
|
||||
required: true
|
||||
});
|
||||
const makeArrayProp = () => ({
|
||||
type: Array,
|
||||
default: () => []
|
||||
});
|
||||
const makeBooleanProp = (defaultVal) => ({
|
||||
type: Boolean,
|
||||
default: defaultVal
|
||||
});
|
||||
const makeNumberProp = (defaultVal) => ({
|
||||
type: Number,
|
||||
default: defaultVal
|
||||
});
|
||||
const makeNumericProp = (defaultVal) => ({
|
||||
type: numericProp,
|
||||
default: defaultVal
|
||||
});
|
||||
const makeStringProp = (defaultVal) => ({
|
||||
type: String,
|
||||
default: defaultVal
|
||||
});
|
||||
const baseProps = {
|
||||
/**
|
||||
* 自定义根节点样式
|
||||
*/
|
||||
customStyle: makeStringProp(""),
|
||||
/**
|
||||
* 自定义根节点样式类
|
||||
*/
|
||||
customClass: makeStringProp("")
|
||||
};
|
||||
exports.baseProps = baseProps;
|
||||
exports.makeArrayProp = makeArrayProp;
|
||||
exports.makeBooleanProp = makeBooleanProp;
|
||||
exports.makeNumberProp = makeNumberProp;
|
||||
exports.makeNumericProp = makeNumericProp;
|
||||
exports.makeRequiredProp = makeRequiredProp;
|
||||
exports.makeStringProp = makeStringProp;
|
||||
exports.numericProp = numericProp;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wot-design-uni/components/common/props.js.map
|
||||
325
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/common/util.js
vendored
Normal file
325
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/common/util.js
vendored
Normal file
@@ -0,0 +1,325 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_wotDesignUni_components_common_AbortablePromise = require("./AbortablePromise.js");
|
||||
function uuid() {
|
||||
return s4() + s4() + s4() + s4() + s4() + s4() + s4() + s4();
|
||||
}
|
||||
function s4() {
|
||||
return Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
|
||||
}
|
||||
function addUnit(num) {
|
||||
return Number.isNaN(Number(num)) ? `${num}` : `${num}px`;
|
||||
}
|
||||
function isObj(value) {
|
||||
return Object.prototype.toString.call(value) === "[object Object]" || typeof value === "object";
|
||||
}
|
||||
function getType(target) {
|
||||
const typeStr = Object.prototype.toString.call(target);
|
||||
const match = typeStr.match(/\[object (\w+)\]/);
|
||||
const type = match && match.length ? match[1].toLowerCase() : "";
|
||||
return type;
|
||||
}
|
||||
const defaultDisplayFormat = function(items, kv) {
|
||||
const labelKey = (kv == null ? void 0 : kv.labelKey) || "value";
|
||||
if (Array.isArray(items)) {
|
||||
return items.map((item) => item[labelKey]).join(", ");
|
||||
} else {
|
||||
return items[labelKey];
|
||||
}
|
||||
};
|
||||
const isDef = (value) => value !== void 0 && value !== null;
|
||||
function rgbToHex(r, g, b) {
|
||||
const hex = (r << 16 | g << 8 | b).toString(16);
|
||||
const paddedHex = "#" + "0".repeat(Math.max(0, 6 - hex.length)) + hex;
|
||||
return paddedHex;
|
||||
}
|
||||
function hexToRgb(hex) {
|
||||
const rgb = [];
|
||||
for (let i = 1; i < 7; i += 2) {
|
||||
rgb.push(parseInt("0x" + hex.slice(i, i + 2), 16));
|
||||
}
|
||||
return rgb;
|
||||
}
|
||||
const gradient = (startColor, endColor, step = 2) => {
|
||||
const sColor = hexToRgb(startColor);
|
||||
const eColor = hexToRgb(endColor);
|
||||
const rStep = (eColor[0] - sColor[0]) / step;
|
||||
const gStep = (eColor[1] - sColor[1]) / step;
|
||||
const bStep = (eColor[2] - sColor[2]) / step;
|
||||
const gradientColorArr = [];
|
||||
for (let i = 0; i < step; i++) {
|
||||
gradientColorArr.push(
|
||||
rgbToHex(parseInt(String(rStep * i + sColor[0])), parseInt(String(gStep * i + sColor[1])), parseInt(String(bStep * i + sColor[2])))
|
||||
);
|
||||
}
|
||||
return gradientColorArr;
|
||||
};
|
||||
const range = (num, min, max) => {
|
||||
return Math.min(Math.max(num, min), max);
|
||||
};
|
||||
const isEqual = (value1, value2) => {
|
||||
if (value1 === value2) {
|
||||
return true;
|
||||
}
|
||||
if (!Array.isArray(value1) || !Array.isArray(value2)) {
|
||||
return false;
|
||||
}
|
||||
if (value1.length !== value2.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < value1.length; ++i) {
|
||||
if (value1[i] !== value2[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const padZero = (number, length = 2) => {
|
||||
let numStr = number.toString();
|
||||
while (numStr.length < length) {
|
||||
numStr = "0" + numStr;
|
||||
}
|
||||
return numStr;
|
||||
};
|
||||
const context = {
|
||||
id: 1e3
|
||||
};
|
||||
function getRect(selector, all, scope, useFields) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let query = null;
|
||||
if (scope) {
|
||||
query = common_vendor.index.createSelectorQuery().in(scope);
|
||||
} else {
|
||||
query = common_vendor.index.createSelectorQuery();
|
||||
}
|
||||
const method = all ? "selectAll" : "select";
|
||||
const callback = (rect) => {
|
||||
if (all && isArray(rect) && rect.length > 0) {
|
||||
resolve(rect);
|
||||
} else if (!all && rect) {
|
||||
resolve(rect);
|
||||
} else {
|
||||
reject(new Error("No nodes found"));
|
||||
}
|
||||
};
|
||||
if (useFields) {
|
||||
query[method](selector).fields({ size: true, node: true }, callback).exec();
|
||||
} else {
|
||||
query[method](selector).boundingClientRect(callback).exec();
|
||||
}
|
||||
});
|
||||
}
|
||||
function kebabCase(word) {
|
||||
const newWord = word.replace(/[A-Z]/g, function(match) {
|
||||
return "-" + match;
|
||||
}).toLowerCase();
|
||||
return newWord;
|
||||
}
|
||||
function camelCase(word) {
|
||||
return word.replace(/-(\w)/g, (_, c) => c.toUpperCase());
|
||||
}
|
||||
function isArray(value) {
|
||||
if (typeof Array.isArray === "function") {
|
||||
return Array.isArray(value);
|
||||
}
|
||||
return Object.prototype.toString.call(value) === "[object Array]";
|
||||
}
|
||||
function isFunction(value) {
|
||||
return getType(value) === "function" || getType(value) === "asyncfunction";
|
||||
}
|
||||
function isString(value) {
|
||||
return getType(value) === "string";
|
||||
}
|
||||
function isNumber(value) {
|
||||
return getType(value) === "number";
|
||||
}
|
||||
function isPromise(value) {
|
||||
if (isObj(value) && isDef(value)) {
|
||||
return isFunction(value.then) && isFunction(value.catch);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isUndefined(value) {
|
||||
return typeof value === "undefined";
|
||||
}
|
||||
function objToStyle(styles) {
|
||||
if (isArray(styles)) {
|
||||
const result = styles.filter(function(item) {
|
||||
return item != null && item !== "";
|
||||
}).map(function(item) {
|
||||
return objToStyle(item);
|
||||
}).join(";");
|
||||
return result ? result.endsWith(";") ? result : result + ";" : "";
|
||||
}
|
||||
if (isString(styles)) {
|
||||
return styles ? styles.endsWith(";") ? styles : styles + ";" : "";
|
||||
}
|
||||
if (isObj(styles)) {
|
||||
const result = Object.keys(styles).filter(function(key) {
|
||||
return styles[key] != null && styles[key] !== "";
|
||||
}).map(function(key) {
|
||||
return [kebabCase(key), styles[key]].join(":");
|
||||
}).join(";");
|
||||
return result ? result.endsWith(";") ? result : result + ";" : "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
const pause = (ms = 1e3 / 30) => {
|
||||
return new uni_modules_wotDesignUni_components_common_AbortablePromise.AbortablePromise((resolve) => {
|
||||
const timer = setTimeout(() => {
|
||||
clearTimeout(timer);
|
||||
resolve(true);
|
||||
}, ms);
|
||||
});
|
||||
};
|
||||
function deepClone(obj, cache = /* @__PURE__ */ new Map()) {
|
||||
if (obj === null || typeof obj !== "object") {
|
||||
return obj;
|
||||
}
|
||||
if (isDate(obj)) {
|
||||
return new Date(obj.getTime());
|
||||
}
|
||||
if (obj instanceof RegExp) {
|
||||
return new RegExp(obj.source, obj.flags);
|
||||
}
|
||||
if (obj instanceof Error) {
|
||||
const errorCopy = new Error(obj.message);
|
||||
errorCopy.stack = obj.stack;
|
||||
return errorCopy;
|
||||
}
|
||||
if (cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
const copy = Array.isArray(obj) ? [] : {};
|
||||
cache.set(obj, copy);
|
||||
for (const key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
copy[key] = deepClone(obj[key], cache);
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
function deepMerge(target, source) {
|
||||
target = deepClone(target);
|
||||
if (typeof target !== "object" || typeof source !== "object") {
|
||||
throw new Error("Both target and source must be objects.");
|
||||
}
|
||||
for (const prop in source) {
|
||||
if (!source.hasOwnProperty(prop))
|
||||
continue;
|
||||
target[prop] = source[prop];
|
||||
}
|
||||
return target;
|
||||
}
|
||||
function deepAssign(target, source) {
|
||||
Object.keys(source).forEach((key) => {
|
||||
const targetValue = target[key];
|
||||
const newObjValue = source[key];
|
||||
if (isObj(targetValue) && isObj(newObjValue)) {
|
||||
deepAssign(targetValue, newObjValue);
|
||||
} else {
|
||||
target[key] = newObjValue;
|
||||
}
|
||||
});
|
||||
return target;
|
||||
}
|
||||
function debounce(func, wait, options = {}) {
|
||||
let timeoutId = null;
|
||||
let lastArgs;
|
||||
let lastThis;
|
||||
let result;
|
||||
const leading = isDef(options.leading) ? options.leading : false;
|
||||
const trailing = isDef(options.trailing) ? options.trailing : true;
|
||||
function invokeFunc() {
|
||||
if (lastArgs !== void 0) {
|
||||
result = func.apply(lastThis, lastArgs);
|
||||
lastArgs = void 0;
|
||||
}
|
||||
}
|
||||
function startTimer() {
|
||||
timeoutId = setTimeout(() => {
|
||||
timeoutId = null;
|
||||
if (trailing) {
|
||||
invokeFunc();
|
||||
}
|
||||
}, wait);
|
||||
}
|
||||
function cancelTimer() {
|
||||
if (timeoutId !== null) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
}
|
||||
function debounced(...args) {
|
||||
lastArgs = args;
|
||||
lastThis = this;
|
||||
if (timeoutId === null) {
|
||||
if (leading) {
|
||||
invokeFunc();
|
||||
}
|
||||
startTimer();
|
||||
} else if (trailing) {
|
||||
cancelTimer();
|
||||
startTimer();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return debounced;
|
||||
}
|
||||
const getPropByPath = (obj, path) => {
|
||||
const keys = path.split(".");
|
||||
try {
|
||||
return keys.reduce((acc, key) => acc !== void 0 && acc !== null ? acc[key] : void 0, obj);
|
||||
} catch (error) {
|
||||
return void 0;
|
||||
}
|
||||
};
|
||||
const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
|
||||
function isVideoUrl(url) {
|
||||
const videoRegex = /\.(ogm|webm|ogv|asx|m4v|mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|video)(?=$|[?#])/i;
|
||||
return videoRegex.test(url);
|
||||
}
|
||||
function isImageUrl(url) {
|
||||
const imageRegex = /\.(xbm|tif|pjp|apng|svgz|jpeg|jpg|heif|ico|tiff|heic|pjpeg|avif|gif|png|svg|webp|jfif|bmp|dpg|image)(?=$|[?#])/i;
|
||||
return imageRegex.test(url);
|
||||
}
|
||||
const isH5 = /* @__PURE__ */ (() => {
|
||||
let isH52 = false;
|
||||
return isH52;
|
||||
})();
|
||||
function omitBy(obj, predicate) {
|
||||
const newObj = deepClone(obj);
|
||||
Object.keys(newObj).forEach((key) => predicate(newObj[key], key) && delete newObj[key]);
|
||||
return newObj;
|
||||
}
|
||||
exports.addUnit = addUnit;
|
||||
exports.camelCase = camelCase;
|
||||
exports.context = context;
|
||||
exports.debounce = debounce;
|
||||
exports.deepAssign = deepAssign;
|
||||
exports.deepClone = deepClone;
|
||||
exports.deepMerge = deepMerge;
|
||||
exports.defaultDisplayFormat = defaultDisplayFormat;
|
||||
exports.getPropByPath = getPropByPath;
|
||||
exports.getRect = getRect;
|
||||
exports.getType = getType;
|
||||
exports.gradient = gradient;
|
||||
exports.isArray = isArray;
|
||||
exports.isDef = isDef;
|
||||
exports.isEqual = isEqual;
|
||||
exports.isFunction = isFunction;
|
||||
exports.isH5 = isH5;
|
||||
exports.isImageUrl = isImageUrl;
|
||||
exports.isNumber = isNumber;
|
||||
exports.isObj = isObj;
|
||||
exports.isPromise = isPromise;
|
||||
exports.isString = isString;
|
||||
exports.isUndefined = isUndefined;
|
||||
exports.isVideoUrl = isVideoUrl;
|
||||
exports.objToStyle = objToStyle;
|
||||
exports.omitBy = omitBy;
|
||||
exports.padZero = padZero;
|
||||
exports.pause = pause;
|
||||
exports.range = range;
|
||||
exports.uuid = uuid;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wot-design-uni/components/common/util.js.map
|
||||
Reference in New Issue
Block a user