This commit is contained in:
lik
2026-05-28 17:06:18 +08:00
parent a93a75b3c6
commit db0f47d994
582 changed files with 8060 additions and 1781 deletions

View File

@@ -1 +1 @@
export default class Bus{constructor(){this.listeners=new Map,this.emitted=new Set}on(t,e){if(this.emitted.has(t))return void e();const s=this.listeners.get(t)||[];s.push(e),this.listeners.set(t,s)}emit(t){const e=this.listeners.get(t);e&&e.forEach((t=>t())),this.emitted.add(t)}}
export default class Bus{constructor(){this.listeners=new Map,this.emitted=new Set}on(t,e){if(this.emitted.has(t))return void e();const s=this.listeners.get(t)||[];s.push(e),this.listeners.set(t,s)}emit(t){const e=this.listeners.get(t);e&&e.forEach(t=>t()),this.emitted.add(t)}}

View File

@@ -1,4 +1,3 @@
/// <reference types="typing" />
declare const _default: {
prefix: string;
};

View File

@@ -5,6 +5,7 @@ export default class TCalendar {
type: TCalendarType;
minDate: Date;
maxDate: Date;
allowSameDay: Boolean;
format: (day: TDate) => TDate;
constructor(options?: {});
getTrimValue(): Date | Date[];

View File

@@ -1 +1 @@
import{getDateRect,isSameDate,getMonthDateRect,isValidDate,getDate}from"../date";export default class TCalendar{constructor(e={}){this.type="single",Object.assign(this,e),this.minDate||(this.minDate=getDate()),this.maxDate||(this.maxDate=getDate(6))}getTrimValue(){const{value:e,type:t}=this,a=e=>e instanceof Date?e:"number"==typeof e?new Date(e):new Date;if("single"===t&&isValidDate(e))return a(e);if("multiple"===t||"range"===t){if(Array.isArray(e)){return e.every((e=>isValidDate(e)))?e.map((e=>a(e))):[]}return[]}}getDays(e){const t=[];let a=this.firstDayOfWeek%7;for(;t.length<7;)t.push(e[a]),a=(a+1)%7;return t}getMonths(){const e=[],t=this.getTrimValue(),{minDate:a,maxDate:i,type:r,format:s}=this,n=getDateRect(a);let{year:m,month:l}=n;const{time:o}=n,{year:D,month:h,time:u}=getDateRect(i),y=(e,a,i)=>{const s=new Date(e,a,i,23,59,59);if("single"===r&&t&&isSameDate({year:e,month:a,date:i},t))return"selected";if("multiple"===r&&t){if(t.some((t=>isSameDate({year:e,month:a,date:i},t))))return"selected"}if("range"===r&&t&&Array.isArray(t)){const[r,n]=t;if(r&&isSameDate({year:e,month:a,date:i},r))return"start";if(n&&isSameDate({year:e,month:a,date:i},n))return"end";if(r&&n&&s.getTime()>r.getTime()&&s.getTime()<n.getTime())return"centre"}const n=new Date(e,a,i,0,0,0);return s.getTime()<o||n.getTime()>u?"disabled":""};for(;m<D||m===D&&l<=h;){const t=getMonthDateRect(new Date(m,l,1)),a=[];for(let e=1;e<=31&&!(e>t.lastDate);e+=1){const t={date:new Date(m,l,e),day:e,type:y(m,l,e)};a.push(s?s(t):t)}e.push({year:m,month:l,months:a,weekdayOfFirstDay:t.weekdayOfFirstDay});const i=getDateRect(new Date(m,l+1,1));m=i.year,l=i.month}return e}select({cellType:e,year:t,month:a,date:i}){const{type:r}=this,s=this.getTrimValue();if("disabled"===e)return;const n=new Date(t,a,i);if(this.value=n,"range"===r&&Array.isArray(s))1===s.length&&n>s[0]?this.value=[s[0],n]:this.value=[n];else if("multiple"===r&&Array.isArray(s)){const e=[...s],t=s.findIndex((e=>isSameDate(e,n)));t>-1?e.splice(t,1):e.push(n),this.value=e}return this.value}}
import{getDateRect,isSameDate,getMonthDateRect,isValidDate,getDate}from"../date";export default class TCalendar{constructor(e={}){this.type="single",Object.assign(this,e),this.minDate||(this.minDate=getDate()),this.maxDate||(this.maxDate=getDate(6))}getTrimValue(){const{value:e,type:t}=this,a=e=>e instanceof Date?e:"number"==typeof e?new Date(e):new Date;if("single"===t&&isValidDate(e))return a(e);if("multiple"===t||"range"===t){if(Array.isArray(e)){return e.every(e=>isValidDate(e))?e.map(e=>a(e)):[]}return[]}}getDays(e){const t=[];let a=this.firstDayOfWeek%7;for(;t.length<7;)t.push(e[a]),a=(a+1)%7;return t}getMonths(){const e=[],t=this.getTrimValue(),{minDate:a,maxDate:i,type:r,allowSameDay:s,format:n}=this,m=getDateRect(a);let{year:l,month:o}=m;const{time:D}=m,{year:h,month:u,time:y}=getDateRect(i),c=(e,a,i)=>{const n=new Date(e,a,i,23,59,59);if("single"===r&&t&&isSameDate({year:e,month:a,date:i},t))return"selected";if("multiple"===r&&t){if(t.some(t=>isSameDate({year:e,month:a,date:i},t)))return"selected"}if("range"===r&&t&&Array.isArray(t)){const[r,m]=t,l=r&&isSameDate({year:e,month:a,date:i},r),o=m&&isSameDate({year:e,month:a,date:i},m);if(l&&o&&s)return"start-end";if(l)return"start";if(o)return"end";if(r&&m&&n.getTime()>r.getTime()&&n.getTime()<m.getTime())return"centre"}const m=new Date(e,a,i,0,0,0);return n.getTime()<D||m.getTime()>y?"disabled":""};for(;l<h||l===h&&o<=u;){const t=getMonthDateRect(new Date(l,o,1)),a=[];for(let e=1;e<=31&&!(e>t.lastDate);e+=1){const t={date:new Date(l,o,e),day:e,type:c(l,o,e)};a.push(n?n(t):t)}e.push({year:l,month:o,months:a,weekdayOfFirstDay:t.weekdayOfFirstDay});const i=getDateRect(new Date(l,o+1,1));l=i.year,o=i.month}return e}select({cellType:e,year:t,month:a,date:i}){const{type:r}=this,s=this.getTrimValue();if("disabled"===e)return;const n=new Date(t,a,i);if(this.value=n,"range"===r&&Array.isArray(s))1===s.length&&n>=s[0]?this.value=[s[0],n]:this.value=[n];else if("multiple"===r&&Array.isArray(s)){const e=[...s],t=s.findIndex(e=>isSameDate(e,n));t>-1?e.splice(t,1):e.push(n),this.value=e}return this.value}}

View File

@@ -1,5 +1,5 @@
export declare type TCalendarValue = number | Date;
export declare type TDateType = 'selected' | 'disabled' | 'start' | 'centre' | 'end' | '';
export declare type TDateType = 'selected' | 'disabled' | 'start-end' | 'start' | 'centre' | 'end' | '';
export declare type TCalendarType = 'single' | 'multiple' | 'range';
export interface TDate {
date: Date;

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
import tinyColor from"tinycolor2/esm/tinycolor";import{isString,isNull}from"../../validator";const combineRegExp=(e,t)=>{let o="";for(let t=0;t<e.length;t+=1)isString(e[t])?o+=e[t]:o+=e[t].source;return new RegExp(o,t)},generateRegExp=()=>{const e=/\s*,\s*/,t=/(?:[+-]?\d*\.?\d+)(?:%|[a-z]+)?/,o=combineRegExp(["(?:",/#(?:[a-f0-9]{6}|[a-f0-9]{3})/,"|","(?:rgb|hsl)",/\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*\)/,"|","(?:rgba|hsla)",/\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*,\s*\d*\.?\d+\)/,"|",/[_a-z-][_a-z0-9-]*/,")"],""),r=combineRegExp([o,"(?:\\s+",t,"(?:\\s+",t,")?)?"],""),i=combineRegExp(["(?:",r,e,")*",r],""),n=combineRegExp(["(?:(",/(?:[+-]?\d*\.?\d+)(?:deg|grad|rad|turn)/,")|",/to\s+((?:(?:left|right|top|bottom)(?:\s+(?:top|bottom|left|right))?))/,")"],"");return{gradientSearch:combineRegExp(["(?:(",n,")",e,")?(",i,")"],"gi"),colorStopSearch:combineRegExp(["\\s*(",o,")","(?:\\s+","(",t,"))?","(?:",e,"\\s*)?"],"gi")}},parseGradient=(e,t)=>{let o,r,i;e.gradientSearch.lastIndex=0;const n=e.gradientSearch.exec(t);if(!isNull(n))for(o={original:n[0],colorStopList:[]},n[1]&&(o.line=n[1]),n[2]&&(o.angle=n[2]),n[3]&&(o.sideCorner=n[3]),e.colorStopSearch.lastIndex=0,r=e.colorStopSearch.exec(n[4]);!isNull(r);)i={color:r[1]},r[2]&&(i.position=r[2]),o.colorStopList.push(i),r=e.colorStopSearch.exec(n[4]);return o},REGEXP_LIB=generateRegExp(),REG_GRADIENT=/.*gradient\s*\(((?:\([^)]*\)|[^)(]*)*)\)/gim;export const isGradientColor=e=>(REG_GRADIENT.lastIndex=0,REG_GRADIENT.exec(e));const sideCornerDegreeMap={top:0,right:90,bottom:180,left:270,"top left":225,"left top":225,"top right":135,"right top":135,"bottom left":315,"left bottom":315,"bottom right":45,"right bottom":45};export const parseGradientString=e=>{const t=isGradientColor(e);if(!t)return!1;const o={points:[],degree:0},r=parseGradient(REGEXP_LIB,t[1]);if(r.original.trim()!==t[1].trim())return!1;const i=r.colorStopList.map((({color:e,position:t})=>{const o=Object.create(null);return o.color=tinyColor(e).toRgbString(),o.left=parseFloat(t),o}));o.points=i;let n=parseInt(r.angle,10);return Number.isNaN(n)&&(n=sideCornerDegreeMap[r.sideCorner]||90),o.degree=n,o};export default parseGradientString;
import tinyColor from"tinycolor2/esm/tinycolor";import{isString,isNull}from"../../validator";const combineRegExp=(e,t)=>{let o="";for(let t=0;t<e.length;t+=1)isString(e[t])?o+=e[t]:o+=e[t].source;return new RegExp(o,t)},generateRegExp=()=>{const e=/\s*,\s*/,t=/(?:[+-]?\d*\.?\d+)(?:%|[a-z]+)?/,o=combineRegExp(["(?:",/#(?:[a-f0-9]{6}|[a-f0-9]{3})/,"|","(?:rgb|hsl)",/\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*\)/,"|","(?:rgba|hsla)",/\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*,\s*\d*\.?\d+\)/,"|",/[_a-z-][_a-z0-9-]*/,")"],""),r=combineRegExp([o,"(?:\\s+",t,"(?:\\s+",t,")?)?"],""),i=combineRegExp(["(?:",r,e,")*",r],""),n=combineRegExp(["(?:(",/(?:[+-]?\d*\.?\d+)(?:deg|grad|rad|turn)/,")|",/to\s+((?:(?:left|right|top|bottom)(?:\s+(?:top|bottom|left|right))?))/,")"],"");return{gradientSearch:combineRegExp(["(?:(",n,")",e,")?(",i,")"],"gi"),colorStopSearch:combineRegExp(["\\s*(",o,")","(?:\\s+","(",t,"))?","(?:",e,"\\s*)?"],"gi")}},parseGradient=(e,t)=>{let o,r,i;e.gradientSearch.lastIndex=0;const n=e.gradientSearch.exec(t);if(!isNull(n))for(o={original:n[0],colorStopList:[]},n[1]&&(o.line=n[1]),n[2]&&(o.angle=n[2]),n[3]&&(o.sideCorner=n[3]),e.colorStopSearch.lastIndex=0,r=e.colorStopSearch.exec(n[4]);!isNull(r);)i={color:r[1]},r[2]&&(i.position=r[2]),o.colorStopList.push(i),r=e.colorStopSearch.exec(n[4]);return o},REGEXP_LIB=generateRegExp(),REG_GRADIENT=/.*gradient\s*\(((?:\([^)]*\)|[^)(]*)*)\)/gim;export const isGradientColor=e=>(REG_GRADIENT.lastIndex=0,REG_GRADIENT.exec(e));const sideCornerDegreeMap={top:0,right:90,bottom:180,left:270,"top left":225,"left top":225,"top right":135,"right top":135,"bottom left":315,"left bottom":315,"bottom right":45,"right bottom":45};export const parseGradientString=e=>{const t=isGradientColor(e);if(!t)return!1;const o={points:[],degree:0},r=parseGradient(REGEXP_LIB,t[1]);if(r.original.trim()!==t[1].trim())return!1;const i=r.colorStopList.map(({color:e,position:t})=>{const o=Object.create(null);return o.color=tinyColor(e).toRgbString(),o.left=parseFloat(t),o});o.points=i;let n=parseInt(r.angle,10);return Number.isNaN(n)&&(n=sideCornerDegreeMap[r.sideCorner]||90),o.degree=n,o};export default parseGradientString;

View File

@@ -10,7 +10,7 @@ export declare const getDateRect: (date: Date | number) => {
day: number;
time: number;
};
export declare const isSameDate: (date1: CompareDate, date2: CompareDate) => boolean;
export declare const isSameDate: (date1: CompareDate, date2: CompareDate) => Boolean;
export declare const getMonthDateRect: (date: Date | number) => {
year: number;
month: number;

View File

@@ -1 +1 @@
export const getDateRect=e=>{const t=new Date(e);return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),day:t.getDay(),time:t.getTime()}};export const isSameDate=(e,t)=>{(e instanceof Date||"number"==typeof e)&&(e=getDateRect(e)),(t instanceof Date||"number"==typeof t)&&(t=getDateRect(t));return["year","month","date"].every((a=>e[a]===t[a]))};export const getMonthDateRect=e=>{const{year:t,month:a}=getDateRect(e);return{year:t,month:a,weekdayOfFirstDay:new Date(t,a,1).getDay(),lastDate:new Date(+new Date(t,a+1,1)-864e5).getDate()}};export const isValidDate=e=>"number"==typeof e||e instanceof Date;export const getDate=(...e)=>{const t=new Date;if(0===e.length)return t;if(1===e.length&&e[0]<=1e3){const{year:a,month:n,date:r}=getDateRect(t);return new Date(a,n+e[0],r)}return Date.apply(null,e)};
export const getDateRect=e=>{const t=new Date(e);return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),day:t.getDay(),time:t.getTime()}};export const isSameDate=(e,t)=>{(e instanceof Date||"number"==typeof e)&&(e=getDateRect(e)),(t instanceof Date||"number"==typeof t)&&(t=getDateRect(t));return["year","month","date"].every(a=>e[a]===t[a])};export const getMonthDateRect=e=>{const{year:t,month:a}=getDateRect(e);return{year:t,month:a,weekdayOfFirstDay:new Date(t,a,1).getDay(),lastDate:new Date(+new Date(t,a+1,1)-864e5).getDate()}};export const isValidDate=e=>"number"==typeof e||e instanceof Date;export const getDate=(...e)=>{const t=new Date;if(0===e.length)return t;if(1===e.length&&e[0]<=1e3){const{year:a,month:n,date:r}=getDateRect(t);return new Date(a,n+e[0],r)}return Date.apply(null,e)};

View File

@@ -0,0 +1,80 @@
export declare class Mode {
static readonly NUMERIC: Mode;
static readonly ALPHANUMERIC: Mode;
static readonly BYTE: Mode;
static readonly KANJI: Mode;
static readonly ECI: Mode;
modeBits: number;
private numBitsCharCount;
private constructor();
numCharCountBits(ver: number): number;
}
export declare class Ecc {
static readonly LOW: Ecc;
static readonly MEDIUM: Ecc;
static readonly QUARTILE: Ecc;
static readonly HIGH: Ecc;
ordinal: number;
formatBits: number;
private constructor();
}
export declare class QrSegment {
static makeBytes(data: Readonly<number[]>): QrSegment;
static makeNumeric(digits: string): QrSegment;
static makeAlphanumeric(text: string): QrSegment;
static makeSegments(text: string): QrSegment[];
static makeEci(assignVal: number): QrSegment;
static isNumeric(text: string): boolean;
static isAlphanumeric(text: string): boolean;
mode: Mode;
numChars: number;
private bitData;
constructor(mode: Mode, numChars: number, bitData: number[]);
getData(): number[];
static getTotalBits(segs: Readonly<QrSegment[]>, version: number): number;
private static toUtf8ByteArray;
private static readonly NUMERIC_REGEX;
private static readonly ALPHANUMERIC_REGEX;
private static readonly ALPHANUMERIC_CHARSET;
}
export declare class QrCode {
static encodeText(text: string, ecl: Ecc): QrCode;
static encodeBinary(data: Readonly<number[]>, ecl: Ecc): QrCode;
static encodeSegments(segs: Readonly<QrSegment[]>, oriEcl: Ecc, minVersion?: number, maxVersion?: number, mask?: number, boostEcl?: boolean): QrCode;
readonly size: number;
readonly mask: number;
private readonly modules;
private readonly isFunction;
version: number;
errorCorrectionLevel: Ecc;
constructor(version: number, errorCorrectionLevel: Ecc, dataCodewords: Readonly<number[]>, oriMsk: number);
getModule(x: number, y: number): boolean;
getModules(): boolean[][];
private drawFunctionPatterns;
private drawFormatBits;
private drawVersion;
private drawFinderPattern;
private drawAlignmentPattern;
private setFunctionModule;
private addEccAndInterleave;
private drawCodewords;
private applyMask;
private getPenaltyScore;
private getAlignmentPatternPositions;
private static getNumRawDataModules;
private static getNumDataCodewords;
private static reedSolomonComputeDivisor;
private static reedSolomonComputeRemainder;
private static reedSolomonMultiply;
private finderPenaltyCountPatterns;
private finderPenaltyTerminateAndCount;
private finderPenaltyAddHistory;
static readonly MIN_VERSION: number;
static readonly MAX_VERSION: number;
private static readonly PENALTY_N1;
private static readonly PENALTY_N2;
private static readonly PENALTY_N3;
private static readonly PENALTY_N4;
private static readonly ECC_CODEWORDS_PER_BLOCK;
private static readonly NUM_ERROR_CORRECTION_BLOCKS;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,23 @@
import type { Ecc, QrCode } from './qrcodegen';
export declare type Modules = ReturnType<QrCode['getModules']>;
export declare type Excavation = {
x: number;
y: number;
w: number;
h: number;
};
export declare type ErrorCorrectionLevel = 'L' | 'M' | 'Q' | 'H';
export declare type CrossOrigin = 'anonymous' | 'use-credentials' | '' | undefined;
export declare type ERROR_LEVEL_MAPPED_TYPE = {
[index in ErrorCorrectionLevel]: Ecc;
};
export declare type ImageSettings = {
src: string;
height: number;
width: number;
excavate: boolean;
x?: number;
y?: number;
opacity?: number;
crossOrigin?: CrossOrigin;
};

View File

@@ -0,0 +1 @@
export{};

View File

@@ -0,0 +1,24 @@
import type { CrossOrigin, ERROR_LEVEL_MAPPED_TYPE, ErrorCorrectionLevel, Excavation, ImageSettings } from './types';
export declare const ERROR_LEVEL_MAP: ERROR_LEVEL_MAPPED_TYPE;
export declare const DEFAULT_SIZE = 160;
export declare const DEFAULT_LEVEL: ErrorCorrectionLevel;
export declare const DEFAULT_BACKGROUND_COLOR = "#FFFFFF";
export declare const DEFAULT_FRONT_COLOR = "#000000";
export declare const DEFAULT_NEED_MARGIN = false;
export declare const DEFAULT_MINVERSION = 1;
export declare const SPEC_MARGIN_SIZE = 4;
export declare const DEFAULT_MARGIN_SIZE = 0;
export declare const DEFAULT_IMG_SCALE = 0.1;
export declare const generatePath: (modules: boolean[][], margin?: number) => string;
export declare const excavateModules: (modules: boolean[][], excavation: Excavation) => boolean[][];
export declare const getImageSettings: (cells: boolean[][], size: number, margin: number, imageSettings?: ImageSettings) => {
x: number;
y: number;
h: number;
w: number;
excavation: Excavation | null;
opacity: number;
crossOrigin: CrossOrigin;
};
export declare const getMarginSize: (needMargin: boolean, marginSize?: number) => number;
export declare const isSupportPath2d: boolean;

View File

@@ -0,0 +1 @@
import{Ecc}from"./qrcodegen";export const ERROR_LEVEL_MAP={L:Ecc.LOW,M:Ecc.MEDIUM,Q:Ecc.QUARTILE,H:Ecc.HIGH};export const DEFAULT_SIZE=160;export const DEFAULT_LEVEL="M";export const DEFAULT_BACKGROUND_COLOR="#FFFFFF";export const DEFAULT_FRONT_COLOR="#000000";export const DEFAULT_NEED_MARGIN=!1;export const DEFAULT_MINVERSION=1;export const SPEC_MARGIN_SIZE=4;export const DEFAULT_MARGIN_SIZE=0;export const DEFAULT_IMG_SCALE=.1;export const generatePath=(t,o=0)=>{const e=[];return t.forEach((t,n)=>{let r=null;t.forEach((c,l)=>{if(!c&&null!==r)return e.push(`M${r+o} ${n+o}h${l-r}v1H${r+o}z`),void(r=null);if(l!==t.length-1)c&&null===r&&(r=l);else{if(!c)return;null===r?e.push(`M${l+o},${n+o} h1v1H${l+o}z`):e.push(`M${r+o},${n+o} h${l+1-r}v1H${r+o}z`)}})}),e.join("")};export const excavateModules=(t,o)=>t.slice().map((t,e)=>e<o.y||e>=o.y+o.h?t:t.map((t,e)=>(e<o.x||e>=o.x+o.w)&&t));export const getImageSettings=(t,o,e,n)=>{if(null==n)return null;const r=t.length+2*e,c=Math.floor(.1*o),l=r/o,a=(n.width||c)*l,h=(n.height||c)*l,s=null==n.x?t.length/2-a/2:n.x*l,E=null==n.y?t.length/2-h/2:n.y*l,p=null==n.opacity?1:n.opacity;let i=null;if(n.excavate){const t=Math.floor(s),o=Math.floor(E);i={x:t,y:o,w:Math.ceil(a+s-t),h:Math.ceil(h+E-o)}}const{crossOrigin:x}=n;return{x:s,y:E,h:h,w:a,excavation:i,opacity:p,crossOrigin:x}};export const getMarginSize=(t,o)=>null!=o?Math.max(Math.floor(o),0):t?4:0;export const isSupportPath2d=(()=>{try{(new Path2D).addPath(new Path2D)}catch(t){return!1}return!0})();

View File

@@ -1 +1 @@
import{isObject}from"../../common/validator";export const getPrototypeOf=function(t){return Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__};export const iterateInheritedPrototype=function(t,e,o,r=!0){let n=e.prototype||e;const c=o.prototype||o;for(;n&&(r||n!==c)&&!1!==t(n)&&n!==c;)n=getPrototypeOf(n)};export const toObject=function(t,e={}){const o={};if(!isObject(t))return o;const r=e.excludes||["constructor"],{enumerable:n=!0,configurable:c=0,writable:i=0}=e,p={};return 0!==n&&(p.enumerable=n),0!==c&&(p.configurable=c),0!==i&&(p.writable=i),iterateInheritedPrototype((t=>{Object.getOwnPropertyNames(t).forEach((n=>{if(r.indexOf(n)>=0)return;if(Object.prototype.hasOwnProperty.call(o,n))return;const c=Object.getOwnPropertyDescriptor(t,n);["get","set","value"].forEach((t=>{if("function"==typeof c[t]){const o=c[t];c[t]=function(...t){return o.apply(Object.prototype.hasOwnProperty.call(e,"bindTo")?e.bindTo:this,t)}}})),Object.defineProperty(o,n,Object.assign(Object.assign({},c),p))}))}),t,e.till||Object,!1),o};
import{isObject}from"../../common/validator";export const getPrototypeOf=function(t){return Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__};export const iterateInheritedPrototype=function(t,e,o,r=!0){let n=e.prototype||e;const c=o.prototype||o;for(;n&&(r||n!==c)&&!1!==t(n)&&n!==c;)n=getPrototypeOf(n)};export const toObject=function(t,e={}){const o={};if(!isObject(t))return o;const r=e.excludes||["constructor"],{enumerable:n=!0,configurable:c=0,writable:i=0}=e,p={};return 0!==n&&(p.enumerable=n),0!==c&&(p.configurable=c),0!==i&&(p.writable=i),iterateInheritedPrototype(t=>{Object.getOwnPropertyNames(t).forEach(n=>{if(r.indexOf(n)>=0)return;if(Object.prototype.hasOwnProperty.call(o,n))return;const c=Object.getOwnPropertyDescriptor(t,n);["get","set","value"].forEach(t=>{if("function"==typeof c[t]){const o=c[t];c[t]=function(...t){return o.apply(Object.prototype.hasOwnProperty.call(e,"bindTo")?e.bindTo:this,t)}}}),Object.defineProperty(o,n,Object.assign(Object.assign({},c),p))})},t,e.till||Object,!1),o};

View File

@@ -1 +1 @@
import{toObject}from"./flatTool";import{isPlainObject}from"../validator";import{canUseVirtualHost}from"../version";const RawLifeCycles=["Created","Attached","Ready","Moved","Detached","Error"],NativeLifeCycles=RawLifeCycles.map((e=>e.toLowerCase())),ComponentNativeProps=["properties","data","observers","methods","behaviors",...NativeLifeCycles,"relations","externalClasses","options","lifetimes","pageLifeTimes","definitionFilter"];export const toComponent=function(e){const{relations:t,behaviors:o=[],externalClasses:i=[]}=e;if(e.properties){Object.keys(e.properties).forEach((t=>{let o=e.properties[t];isPlainObject(o)||(o={type:o}),e.properties[t]=o}));[{key:"ariaHidden",type:Boolean},{key:"ariaRole",type:String},{key:"ariaLabel",type:String},{key:"ariaLabelledby",type:String},{key:"ariaDescribedby",type:String},{key:"ariaBusy",type:Boolean}].forEach((({key:t,type:o})=>{e.properties[t]={type:o}})),e.properties.style={type:String,value:""},e.properties.customStyle={type:String,value:""}}e.methods||(e.methods={}),e.lifetimes||(e.lifetimes={});const s={};if(t){const e=(e,t)=>Behavior({created(){Object.defineProperty(this,`$${e}`,{get:()=>{const o=this.getRelationNodes(t)||[];return"parent"===e?o[0]:o}})}}),i={};Object.keys(t).forEach((o=>{const s=t[o],r=["parent","ancestor"].includes(s.type)?"parent":"children",n=e(r,o);i[r]=n})),o.push(...Object.keys(i).map((e=>i[e])))}if(e.behaviors=[...o],e.externalClasses=["class",...i],Object.getOwnPropertyNames(e).forEach((t=>{const o=Object.getOwnPropertyDescriptor(e,t);o&&(NativeLifeCycles.indexOf(t)<0&&"function"==typeof o.value?(Object.defineProperty(e.methods,t,o),delete e[t]):ComponentNativeProps.indexOf(t)<0?s[t]=o:NativeLifeCycles.indexOf(t)>=0&&(e.lifetimes[t]=e[t]))})),Object.keys(s).length){const t=e.lifetimes.created,o=e.lifetimes.attached,{controlledProps:i=[]}=e;e.lifetimes.created=function(...e){Object.defineProperties(this,s),t&&t.apply(this,e)},e.lifetimes.attached=function(...e){o&&o.apply(this,e),i.forEach((({key:e})=>{const t=`default${e.replace(/^(\w)/,((e,t)=>t.toUpperCase()))}`,o=this.properties;null==o[e]&&(this._selfControlled=!0),null==o[e]&&null!=o[t]&&this.setData({[e]:o[t]})}))},e.methods._trigger=function(e,t,o){const s=i.find((t=>t.event===e));if(s){const{key:e}=s;this._selfControlled&&this.setData({[e]:t[e]})}this.triggerEvent(e,t,o)}}return e};export const wxComponent=function(){return function(e){const t=new class extends e{};t.options=t.options||{},canUseVirtualHost()&&(t.options.virtualHost=!0);const o=toComponent(toObject(t));Component(o)}};
import{toObject}from"./flatTool";import{isPlainObject}from"../validator";import{canUseVirtualHost}from"../version";const RawLifeCycles=["Created","Attached","Ready","Moved","Detached","Error"],NativeLifeCycles=RawLifeCycles.map(e=>e.toLowerCase()),ComponentNativeProps=["properties","data","observers","methods","behaviors",...NativeLifeCycles,"relations","externalClasses","options","lifetimes","pageLifeTimes","definitionFilter"];export const toComponent=function(e){const{relations:t,behaviors:o=[],externalClasses:i=[]}=e;if(e.properties){Object.keys(e.properties).forEach(t=>{let o=e.properties[t];isPlainObject(o)||(o={type:o}),e.properties[t]=o});[{key:"ariaHidden",type:Boolean},{key:"ariaRole",type:String},{key:"ariaLabel",type:String},{key:"ariaLabelledby",type:String},{key:"ariaDescribedby",type:String},{key:"ariaBusy",type:Boolean}].forEach(({key:t,type:o})=>{e.properties[t]={type:o}}),e.properties.style={type:String,value:""},e.properties.customStyle={type:String,value:""}}e.methods||(e.methods={}),e.lifetimes||(e.lifetimes={});const s={};if(t){const e=(e,t)=>Behavior({created(){Object.defineProperty(this,`$${e}`,{get:()=>{const o=this.getRelationNodes(t)||[];return"parent"===e?o[0]:o}})}}),i={};Object.keys(t).forEach(o=>{const s=t[o],r=["parent","ancestor"].includes(s.type)?"parent":"children",n=e(r,o);i[r]=n}),o.push(...Object.keys(i).map(e=>i[e]))}if(e.behaviors=[...o],e.externalClasses=["class",...i],Object.getOwnPropertyNames(e).forEach(t=>{const o=Object.getOwnPropertyDescriptor(e,t);o&&(NativeLifeCycles.indexOf(t)<0&&"function"==typeof o.value?(Object.defineProperty(e.methods,t,o),delete e[t]):ComponentNativeProps.indexOf(t)<0?s[t]=o:NativeLifeCycles.indexOf(t)>=0&&(e.lifetimes[t]=e[t]))}),Object.keys(s).length){const t=e.lifetimes.created,o=e.lifetimes.attached,{controlledProps:i=[]}=e;e.lifetimes.created=function(...e){Object.defineProperties(this,s),t&&t.apply(this,e)},e.lifetimes.attached=function(...e){o&&o.apply(this,e),i.forEach(({key:e})=>{const t=`default${e.replace(/^(\w)/,(e,t)=>t.toUpperCase())}`,o=this.properties;null==o[e]&&(this._selfControlled=!0),null==o[e]&&null!=o[t]&&this.setData({[e]:o[t]})})},e.methods._trigger=function(e,t,o){const s=i.find(t=>t.event===e);if(s){const{key:e}=s;this._selfControlled&&this.setData({[e]:t[e]})}this.triggerEvent(e,t,o)}}return e};export const wxComponent=function(){return function(e){const t=new class extends e{};t.options=t.options||{},canUseVirtualHost()&&(t.options.virtualHost=!0);const o=toComponent(toObject(t));Component(o)}};

View File

@@ -1 +1,2 @@
.hotspot-expanded.relative{position:relative}.hotspot-expanded::after{content:'';display:block;position:absolute;left:0;top:0;right:0;bottom:0;transform:scale(1.5)}
.hotspot-expanded.relative{position:relative;}
.hotspot-expanded::after{content:'';display:block;position:absolute;left:0;top:0;right:0;bottom:0;transform:scale(1.5);}

View File

@@ -1 +1,4 @@
@media (prefers-color-scheme:light){.page,page{--td-picker-transparent-color:rgba(255, 255, 255, 0)}}@media (prefers-color-scheme:dark){.page,page{--td-button-primary-disabled-color:var(--td-font-white-4);--td-skeleton-animation-gradient:rgba(255, 255, 255, 0.06);--td-slider-dot-bg-color:var(--td-gray-color-4);--td-slider-dot-disabled-bg-color:var(--td-gray-color-11);--td-slider-dot-disabled-border-color:var(--td-gray-color-12);--td-picker-transparent-color:transparent;--td-switch-dot-disabled-color:var(--td-font-white-2)}}
@media (prefers-color-scheme:light){
.page,page{--td-picker-transparent-color:rgba(255, 255, 255, 0);--td-switch-dot-disabled-color:var(--td-font-white-1);--td-switch-loading-color:var(--td-brand-color);}}
@media (prefers-color-scheme:dark){
.page,page{--td-button-primary-disabled-color:var(--td-font-white-4);--td-skeleton-animation-gradient:rgba(255, 255, 255, 0.06);--td-slider-dot-bg-color:var(--td-gray-color-4);--td-slider-dot-disabled-bg-color:var(--td-gray-color-11);--td-slider-dot-disabled-border-color:var(--td-gray-color-12);--td-picker-transparent-color:transparent;--td-switch-dot-disabled-color:var(--td-font-white-2);--td-switch-loading-color:var(--td-font-white-1);--td-progress-circle-inner-bg-color:var(--bg-color-page);}}

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
.page,page{--td-font-family:PingFang SC,Microsoft YaHei,Arial Regular;--td-font-family-medium:PingFang SC,Microsoft YaHei,Arial Medium;--td-font-size-link-small:24rpx;--td-font-size-link-medium:28rpx;--td-font-size-link-large:32rpx;--td-font-size-mark-extra-small:20rpx;--td-font-size-mark-small:24rpx;--td-font-size-mark-medium:28rpx;--td-font-size-mark-large:32rpx;--td-font-size-body-extra-small:20rpx;--td-font-size-body-small:24rpx;--td-font-size-body-medium:28rpx;--td-font-size-body-large:32rpx;--td-font-size-title-small:28rpx;--td-font-size-title-medium:32rpx;--td-font-size-title-large:36rpx;--td-font-size-title-extra-large:40rpx;--td-font-size-headline-small:48rpx;--td-font-size-headline-medium:56rpx;--td-font-size-headline-large:72rpx;--td-font-size-display-medium:96rpx;--td-font-size-display-large:128rpx;--td-font-size:20rpx;--td-font-size-xs:var(--td-font-size-body-extra-small);--td-font-size-s:var(--td-font-size-body-small);--td-font-size-base:var(--td-font-size-title-small);--td-font-size-m:var(--td-font-size-title-medium);--td-font-size-l:var(--td-font-size-title-large);--td-font-size-xl:var(--td-font-size-title-extra-large);--td-font-size-xxl:var(--td-font-size-headline-large)}
.page,page{--td-font-family:PingFang SC,Microsoft YaHei,Arial Regular;--td-font-family-medium:PingFang SC,Microsoft YaHei,Arial Medium;--td-font-size-link-small:24rpx;--td-font-size-link-medium:28rpx;--td-font-size-link-large:32rpx;--td-font-size-mark-extraSmall:20rpx;--td-font-size-mark-small:24rpx;--td-font-size-mark-medium:28rpx;--td-font-size-mark-large:32rpx;--td-font-size-body-extraSmall:20rpx;--td-font-size-body-small:24rpx;--td-font-size-body-medium:28rpx;--td-font-size-body-large:32rpx;--td-font-size-title-small:28rpx;--td-font-size-title-medium:32rpx;--td-font-size-title-large:36rpx;--td-font-size-title-extraLarge:40rpx;--td-font-size-headline-small:48rpx;--td-font-size-headline-medium:56rpx;--td-font-size-headline-large:72rpx;--td-font-size-display-medium:96rpx;--td-font-size-display-large:128rpx;--td-line-height-link-small:40rpx;--td-line-height-link-medium:44rpx;--td-line-height-link-large:48rpx;--td-line-height-mark-extraSmall:32rpx;--td-line-height-mark-small:40rpx;--td-line-height-mark-medium:44rpx;--td-line-height-mark-large:48rpx;--td-line-height-body-extraSmall:32rpx;--td-line-height-body-small:40rpx;--td-line-height-body-medium:44rpx;--td-line-height-body-large:48rpx;--td-line-height-title-small:44rpx;--td-line-height-title-medium:48rpx;--td-line-height-title-large:52rpx;--td-line-height-title-extraLarge:56rpx;--td-line-height-headline-small:64rpx;--td-line-height-headline-medium:72rpx;--td-line-height-headline-large:88rpx;--td-line-height-display-medium:112rpx;--td-line-height-display-large:144rpx;--td-font-link-small:var(--td-font-size-link-small)/var(--td-line-height-link-small) var(--td-font-family);--td-font-link-medium:var(--td-font-size-link-medium)/var(--td-line-height-link-medium) var(--td-font-family);--td-font-link-large:var(--td-font-size-link-large)/var(--td-line-height-link-large) var(--td-font-family);--td-font-mark-extraSmall:600 var(--td-font-size-mark-extraSmall)/var(--td-line-height-mark-extraSmall) var(--td-font-family);--td-font-mark-small:600 var(--td-font-size-mark-small)/var(--td-line-height-mark-small) var(--td-font-family);--td-font-mark-medium:600 var(--td-font-size-mark-medium)/var(--td-line-height-mark-medium) var(--td-font-family);--td-font-mark-large:600 var(--td-font-size-mark-large)/var(--td-line-height-mark-large) var(--td-font-family);--td-font-body-extraSmall:var(--td-font-size-body-extraSmall)/var(--td-line-height-body-extraSmall) var(--td-font-family);--td-font-body-small:var(--td-font-size-body-small)/var(--td-line-height-body-small) var(--td-font-family);--td-font-body-medium:var(--td-font-size-body-medium)/var(--td-line-height-body-medium) var(--td-font-family);--td-font-body-large:var(--td-font-size-body-large)/var(--td-line-height-body-large) var(--td-font-family);--td-font-title-small:600 var(--td-font-size-title-small)/var(--td-line-height-title-small) var(--td-font-family);--td-font-title-medium:600 var(--td-font-size-title-medium)/var(--td-line-height-title-medium) var(--td-font-family);--td-font-title-large:600 var(--td-font-size-title-large)/var(--td-line-height-title-large) var(--td-font-family);--td-font-title-extraLarge:600 var(--td-font-size-title-extraLarge)/var(--td-line-height-title-extraLarge) var(--td-font-family);--td-font-headline-small:600 var(--td-font-size-headline-small)/var(--td-line-height-headline-small) var(--td-font-family);--td-font-headline-medium:600 var(--td-font-size-headline-medium)/var(--td-line-height-headline-medium) var(--td-font-family);--td-font-headline-large:600 var(--td-font-size-headline-large)/var(--td-line-height-headline-large) var(--td-font-family);--td-font-display-medium:600 var(--td-font-size-display-medium)/var(--td-line-height-display-medium) var(--td-font-family);--td-font-display-large:600 var(--td-font-size-display-large)/var(--td-line-height-display-large) var(--td-font-family);--td-font-size:20rpx;--td-font-size-xs:var(--td-font-size-body-extraSmall);--td-font-size-s:var(--td-font-size-body-small);--td-font-size-base:var(--td-font-size-title-small);--td-font-size-m:var(--td-font-size-title-medium);--td-font-size-l:var(--td-font-size-title-large);--td-font-size-xl:var(--td-font-size-title-extraLarge);--td-font-size-xxl:var(--td-font-size-headline-large);}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
.page,page{--td-radius-small:6rpx;--td-radius-default:12rpx;--td-radius-large:18rpx;--td-radius-extra-large:24rpx;--td-radius-round:999px;--td-radius-circle:50%}
.page,page{--td-radius-small:6rpx;--td-radius-default:12rpx;--td-radius-large:18rpx;--td-radius-extraLarge:24rpx;--td-radius-round:999px;--td-radius-circle:50%;}

View File

@@ -1 +1 @@
.page,page{--td-spacer:16rpx;--td-spacer-1:24rpx;--td-spacer-2:32rpx;--td-spacer-3:48rpx;--td-spacer-4:64rpx;--td-spacer-5:96rpx;--td-spacer-6:160rpx}
.page,page{--td-spacer:16rpx;--td-spacer-1:24rpx;--td-spacer-2:32rpx;--td-spacer-3:48rpx;--td-spacer-4:64rpx;--td-spacer-5:96rpx;--td-spacer-6:160rpx;}

View File

@@ -1 +1,2 @@
.hotspot-expanded.relative{position:relative}.hotspot-expanded::after{content:'';display:block;position:absolute;left:0;top:0;right:0;bottom:0;transform:scale(1.5)}
.hotspot-expanded.relative{position:relative;}
.hotspot-expanded::after{content:'';display:block;position:absolute;left:0;top:0;right:0;bottom:0;transform:scale(1.5);}

View File

@@ -1 +1 @@
<template name="button"><t-button t-id="{{tId || ''}}" style="{{style || ''}}" block="{{block || false}}" class="{{rootClass || ''}}" t-class="{{tClass}}" disabled="{{disabled || false}}" data-type="{{type}}" data-extra="{{extra}}" custom-dataset="{{customDataset}}" content="{{content || ''}}" icon="{{icon || ''}}" loading="{{loading || false}}" loading-props="{{loadingProps || null }}" theme="{{theme || 'default'}}" ghost="{{ghost || false}}" shape="{{shape || 'rectangle'}}" size="{{size || 'medium'}}" variant="{{variant || 'base'}}" open-type="{{openType || ''}}" hover-class="{{hoverClass || ''}}" hover-stop-propagation="{{hoverStopPropagation || false}}" hover-start-time="{{hoverStartTime || 20}}" hover-stay-time="{{hoverStayTime || 70}}" lang="{{lang || 'en'}}" session-from="{{sessionFrom || ''}}" send-message-title="{{sendMessageTitle || ''}}" send-message-path="{{sendMessagePath || ''}}" send-message-img="{{sendMessageImg || ''}}" app-parameter="{{appParameter || ''}}" show-message-card="{{showMessageCard || false}}" bind:tap="onTplButtonTap" bind:getuserinfo="onTplButtonTap" bind:contact="onTplButtonTap" bind:getphonenumber="onTplButtonTap" bind:error="onTplButtonTap" bind:opensetting="onTplButtonTap" bind:launchapp="onTplButtonTap" bind:agreeprivacyauthorization="onTplButtonTap" aria-label="{{ariaLabel || ''}}"><slot wx:if="{{useDefaultSlot || false}}"/></t-button></template>
<template name="button"><t-button t-id="{{tId || ''}}" style="{{style || ''}}" block="{{block || false}}" class="{{rootClass || ''}}" t-class="{{tClass}}" disabled="{{disabled || false}}" data-type="{{type}}" data-extra="{{extra}}" custom-dataset="{{customDataset}}" content="{{content || ''}}" icon="{{icon || ''}}" loading="{{loading || false}}" loading-props="{{loadingProps || null }}" theme="{{theme || 'default'}}" ghost="{{ghost || false}}" shape="{{shape || 'rectangle'}}" size="{{size || 'medium'}}" variant="{{variant || 'base'}}" open-type="{{openType || ''}}" hover-class="{{hoverClass || ''}}" hover-stop-propagation="{{hoverStopPropagation || false}}" hover-start-time="{{hoverStartTime || 20}}" hover-stay-time="{{hoverStayTime || 70}}" lang="{{lang || 'en'}}" session-from="{{sessionFrom || ''}}" send-message-title="{{sendMessageTitle || ''}}" send-message-path="{{sendMessagePath || ''}}" send-message-img="{{sendMessageImg || ''}}" app-parameter="{{appParameter || ''}}" show-message-card="{{showMessageCard || false}}" bind:tap="onTplButtonTap" bind:getuserinfo="onTplButtonTap" bind:contact="onTplButtonTap" bind:createliveactivity="onTplButtonTap" bind:getphonenumber="onTplButtonTap" bind:getrealtimephonenumber="onTplButtonTap" bind:error="onTplButtonTap" bind:opensetting="onTplButtonTap" bind:launchapp="onTplButtonTap" bind:agreeprivacyauthorization="onTplButtonTap" aria-label="{{ariaLabel || ''}}"><slot wx:if="{{useDefaultSlot || false}}"/></t-button></template>

View File

@@ -1,9 +1,14 @@
/// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" />
export declare const systemInfo: WechatMiniprogram.WindowInfo | WechatMiniprogram.SystemInfo;
export declare const appBaseInfo: WechatMiniprogram.AppBaseInfo | WechatMiniprogram.SystemInfo;
export declare const deviceInfo: WechatMiniprogram.DeviceInfo | WechatMiniprogram.SystemInfo;
interface WxWorkSystemInfo extends WechatMiniprogram.SystemInfo {
environment?: 'wxwork';
}
interface SystemInfo extends WxWorkSystemInfo {
}
export declare const systemInfo: WechatMiniprogram.WindowInfo | SystemInfo;
export declare const appBaseInfo: WechatMiniprogram.AppBaseInfo | SystemInfo;
export declare const deviceInfo: WechatMiniprogram.DeviceInfo | SystemInfo;
declare type Context = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
export declare const debounce: (func: any, wait?: number) => (...rest: any[]) => void;
export declare const throttle: (func: any, wait?: number, options?: any) => (...args: any[]) => void;
@@ -17,6 +22,8 @@ interface TreeNode {
}
export declare const getTreeDepth: (tree: TreeNode[], key?: string) => any;
export declare const isIOS: () => boolean;
export declare const isWxWork: boolean;
export declare const isPC: boolean;
export declare const addUnit: (value?: string | number) => string | undefined;
export declare const getCharacterLength: (type: string, char: string | number, max?: number) => {
length: number;
@@ -29,6 +36,7 @@ export declare const setIcon: (iconName: any, icon: any, defaultIcon: any) => {
[x: string]: any;
};
export declare const toCamel: (str: any) => any;
export declare function toKebabCase(str: string): string;
export declare const getCurrentPage: <T>() => T & WechatMiniprogram.OptionalInterface<WechatMiniprogram.Page.ILifetime> & WechatMiniprogram.Page.InstanceProperties & WechatMiniprogram.Page.InstanceMethods<WechatMiniprogram.IAnyObject> & WechatMiniprogram.Page.Data<WechatMiniprogram.IAnyObject> & WechatMiniprogram.IAnyObject;
export declare const uniqueFactory: (compName: any) => () => string;
export declare const calcIcon: (icon: string | Record<string, any>, defaultIcon?: string) => Record<string, any>;

View File

@@ -1 +1 @@
import{prefix}from"./config";import{isString,isNumber,isDef,isBoolean,isObject}from"./validator";import{getWindowInfo,getAppBaseInfo,getDeviceInfo}from"./wechat";export const systemInfo=getWindowInfo();export const appBaseInfo=getAppBaseInfo();export const deviceInfo=getDeviceInfo();export const debounce=function(e,t=500){let n;return function(...o){n&&clearTimeout(n),n=setTimeout((()=>{e.apply(this,o)}),t)}};export const throttle=(e,t=100,n=null)=>{let o=0,r=null;return n||(n={leading:!0}),function(...c){const s=Date.now();o||n.leading||(o=s);const i=this;t-(s-o)<=0&&(r&&(clearTimeout(r),r=null),o=s,e.apply(i,c))}};export const classNames=function(...e){const t={}.hasOwnProperty,n=[];return e.forEach((e=>{if(!e)return;const o=typeof e;if("string"===o||"number"===o)n.push(e);else if(Array.isArray(e)&&e.length){const t=classNames(...e);t&&n.push(t)}else if("object"===o)for(const o in e)t.call(e,o)&&e[o]&&n.push(o)})),n.join(" ")};export const styles=function(e){return Object.keys(e).map((t=>`${t}: ${e[t]}`)).join("; ")};export const getAnimationFrame=function(e,t){return e.createSelectorQuery().selectViewport().boundingClientRect().exec((()=>{t()}))};export const getRect=function(e,t,n=!1){return new Promise(((o,r)=>{e.createSelectorQuery()[n?"selectAll":"select"](t).boundingClientRect((e=>{e?o(e):r(e)})).exec()}))};export const getTreeDepth=(e,t)=>e.reduce(((e,n)=>n[null!=t?t:"children"]&&n[null!=t?t:"children"].length>0?Math.max(e,getTreeDepth(n[null!=t?t:"children"],t)+1):Math.max(e,1)),0);export const isIOS=function(){var e;return!!((null===(e=null==deviceInfo?void 0:deviceInfo.system)||void 0===e?void 0:e.toLowerCase().search("ios"))+1)};export const addUnit=function(e){if(isDef(e))return e=String(e),isNumber(e)?`${e}px`:e};export const getCharacterLength=(e,t,n)=>{const o=String(null!=t?t:"");if(0===o.length)return{length:0,characters:""};if("maxcharacter"===e){let e=0;for(let t=0;t<o.length;t+=1){let r=0;if(r=o.charCodeAt(t)>127||94===o.charCodeAt(t)?2:1,e+r>n)return{length:e,characters:o.slice(0,t)};e+=r}return{length:e,characters:o}}if("maxlength"===e){const e=o.length>n?n:o.length;return{length:e,characters:o.slice(0,e)}}return{length:o.length,characters:o}};export const chunk=(e,t)=>Array.from({length:Math.ceil(e.length/t)},((n,o)=>e.slice(o*t,o*t+t)));export const getInstance=function(e,t){if(!e){const t=getCurrentPages(),n=t[t.length-1];e=n.$$basePage||n}const n=e?e.selectComponent(t):null;return n||(console.warn("未找到组件,请检查selector是否正确"),null)};export const unitConvert=e=>{var t;return"string"==typeof e?e.includes("rpx")?parseInt(e,10)*(null!==(t=null==systemInfo?void 0:systemInfo.screenWidth)&&void 0!==t?t:750)/750:parseInt(e,10):null!=e?e:0};export const setIcon=(e,t,n)=>t?"string"==typeof t?{[`${e}Name`]:t,[`${e}Data`]:{}}:"object"==typeof t?{[`${e}Name`]:"",[`${e}Data`]:t}:{[`${e}Name`]:n,[`${e}Data`]:{}}:{[`${e}Name`]:"",[`${e}Data`]:{}};export const toCamel=e=>e.replace(/-(\w)/g,((e,t)=>t.toUpperCase()));export const getCurrentPage=function(){const e=getCurrentPages();return e[e.length-1]};export const uniqueFactory=e=>{let t=0;return()=>{const n=`${prefix}_${e}_${t}`;return t+=1,n}};export const calcIcon=(e,t)=>e&&(isBoolean(e)&&t||isString(e))?{name:isBoolean(e)?t:e}:isObject(e)?e:null;export const isOverSize=(e,t)=>{var n;if(!t)return!1;const o=1e3,r={B:1,KB:o,MB:1e6,GB:1e9};return e>("number"==typeof t?t*o:(null==t?void 0:t.size)*r[null!==(n=null==t?void 0:t.unit)&&void 0!==n?n:"KB"])};export const rpx2px=e=>Math.floor(systemInfo.windowWidth*e/750);export const nextTick=()=>new Promise((e=>{wx.nextTick((()=>{e()}))}));
import{prefix}from"./config";import{isString,isNumeric,isDef,isBoolean,isObject}from"./validator";import{getWindowInfo,getAppBaseInfo,getDeviceInfo}from"./wechat";export const systemInfo=getWindowInfo();export const appBaseInfo=getAppBaseInfo();export const deviceInfo=getDeviceInfo();export const debounce=function(e,t=500){let n;return function(...o){n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,o)},t)}};export const throttle=(e,t=100,n=null)=>{let o=0,r=null;return n||(n={leading:!0}),function(...c){const s=Date.now();o||n.leading||(o=s);const i=this;t-(s-o)<=0&&(r&&(clearTimeout(r),r=null),o=s,e.apply(i,c))}};export const classNames=function(...e){const t={}.hasOwnProperty,n=[];return e.forEach(e=>{if(!e)return;const o=typeof e;if("string"===o||"number"===o)n.push(e);else if(Array.isArray(e)&&e.length){const t=classNames(...e);t&&n.push(t)}else if("object"===o)for(const o in e)t.call(e,o)&&e[o]&&n.push(o)}),n.join(" ")};export const styles=function(e){return Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ")};export const getAnimationFrame=function(e,t){return e.createSelectorQuery().selectViewport().boundingClientRect().exec(()=>{t()})};export const getRect=function(e,t,n=!1){return new Promise((o,r)=>{e.createSelectorQuery()[n?"selectAll":"select"](t).boundingClientRect(e=>{e?o(e):r(e)}).exec()})};export const getTreeDepth=(e,t)=>e.reduce((e,n)=>n[null!=t?t:"children"]&&n[null!=t?t:"children"].length>0?Math.max(e,getTreeDepth(n[null!=t?t:"children"],t)+1):Math.max(e,1),0);export const isIOS=function(){var e;return!!((null===(e=null==deviceInfo?void 0:deviceInfo.system)||void 0===e?void 0:e.toLowerCase().search("ios"))+1)};export const isWxWork="wxwork"===(null==deviceInfo?void 0:deviceInfo.environment);export const isPC=["mac","windows"].includes(null==deviceInfo?void 0:deviceInfo.platform);export const addUnit=function(e){if(isDef(e))return e=String(e),isNumeric(e)?`${e}px`:e};export const getCharacterLength=(e,t,n)=>{const o=String(null!=t?t:"");if(0===o.length)return{length:0,characters:""};if("maxcharacter"===e){let e=0;for(let t=0;t<o.length;t+=1){let r=0;if(r=o.charCodeAt(t)>127||94===o.charCodeAt(t)?2:1,e+r>n)return{length:e,characters:o.slice(0,t)};e+=r}return{length:e,characters:o}}if("maxlength"===e){const e=o.length>n?n:o.length;return{length:e,characters:o.slice(0,e)}}return{length:o.length,characters:o}};export const chunk=(e,t)=>Array.from({length:Math.ceil(e.length/t)},(n,o)=>e.slice(o*t,o*t+t));export const getInstance=function(e,t){if(!e){const t=getCurrentPages(),n=t[t.length-1];e=n.$$basePage||n}const n=e?e.selectComponent(t):null;return n||(console.warn("未找到组件,请检查selector是否正确"),null)};export const unitConvert=e=>{var t;return"string"==typeof e?e.includes("rpx")?parseInt(e,10)*(null!==(t=null==systemInfo?void 0:systemInfo.screenWidth)&&void 0!==t?t:750)/750:parseInt(e,10):null!=e?e:0};export const setIcon=(e,t,n)=>t?"string"==typeof t?{[`${e}Name`]:t,[`${e}Data`]:{}}:"object"==typeof t?{[`${e}Name`]:"",[`${e}Data`]:t}:{[`${e}Name`]:n,[`${e}Data`]:{}}:{[`${e}Name`]:"",[`${e}Data`]:{}};export const toCamel=e=>e.replace(/-(\w)/g,(e,t)=>t.toUpperCase());export function toKebabCase(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/([0-9])([a-zA-Z])/g,"$1-$2").toLowerCase()}export const getCurrentPage=function(){const e=getCurrentPages();return e[e.length-1]};export const uniqueFactory=e=>{let t=0;return()=>{const n=`${prefix}_${e}_${t}`;return t+=1,n}};export const calcIcon=(e,t)=>e&&(isBoolean(e)&&t||isString(e))?{name:isBoolean(e)?t:e}:isObject(e)?e:null;export const isOverSize=(e,t)=>{var n;if(!t)return!1;const o=1e3,r={B:1,KB:o,MB:1e6,GB:1e9};return e>("number"==typeof t?t*o:(null==t?void 0:t.size)*r[null!==(n=null==t?void 0:t.unit)&&void 0!==n?n:"KB"])};export const rpx2px=e=>Math.floor(systemInfo.windowWidth*e/750);export const nextTick=()=>new Promise(e=>{wx.nextTick(()=>{e()})});

View File

@@ -28,9 +28,9 @@ function isBoolean(value) {
return typeof value === 'boolean';
}
var isNoEmptyObj = function (obj) {
function isNoEmptyObj(obj) {
return isObject(obj) && JSON.stringify(obj) !== '{}';
};
}
function includes(arr, value) {
if (!arr || !isArray(arr)) return false;
@@ -110,7 +110,7 @@ function _style(styles) {
return item != null && item !== '';
})
.map(function (item) {
return isArray(item) ? _style(item) : endsWith(item, ';');
return isString(item) ? endsWith(item, ';') : _style(item);
})
.join(' ');
}
@@ -131,7 +131,7 @@ function _style(styles) {
function isValidIconName(str) {
// prettier-ignore
return getRegExp('^[A-Za-z0-9\-]+$').test(str);
return getRegExp('^[A-Za-z0-9\-\_]+$').test(str);
}
module.exports = {

View File

@@ -3,7 +3,23 @@ export declare const isString: (val: unknown) => val is string;
export declare const isNull: <T>(value: T) => value is null;
export declare const isUndefined: <T>(value: T) => value is undefined;
export declare function isDef(value: unknown): boolean;
export declare function isNumber(value: string): boolean;
export declare function isInteger(value: unknown): boolean;
export declare function isNumeric(value: unknown): boolean;
export declare function isNumber(value: unknown): boolean;
export declare function isBoolean(value: unknown): value is boolean;
export declare function isObject(x: unknown): x is Record<string, unknown>;
export declare function isPlainObject(val: unknown): val is Record<string, unknown>;
export declare function isEmpty(val: unknown): boolean;
export declare function isDate(input: unknown, options?: {
format?: string;
delimiters?: string[];
strictMode?: boolean;
}): boolean;
export declare function isEmail(str: unknown): boolean;
export declare function isURL(str: unknown, options?: {
protocols?: string[];
require_tld?: boolean;
require_protocol?: boolean;
require_host?: boolean;
allow_protocol_relative_urls?: boolean;
}): boolean;

View File

@@ -1 +1 @@
export function isFunction(t){return"function"==typeof t}export const isString=t=>"string"==typeof t;export const isNull=t=>null===t;export const isUndefined=t=>void 0===t;export function isDef(t){return!isUndefined(t)&&!isNull(t)}export function isNumber(t){return/^\d+(\.\d+)?$/.test(t)}export function isBoolean(t){return"boolean"==typeof t}export function isObject(t){const n=typeof t;return null!==t&&("object"===n||"function"===n)}export function isPlainObject(t){return null!==t&&"object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)}
export function isFunction(t){return"function"==typeof t}export const isString=t=>"string"==typeof t;export const isNull=t=>null===t;export const isUndefined=t=>void 0===t;export function isDef(t){return!isUndefined(t)&&!isNull(t)}export function isInteger(t){return Number.isInteger(t)}export function isNumeric(t){return!Number.isNaN(Number(t))}export function isNumber(t){return"number"==typeof t}export function isBoolean(t){return"boolean"==typeof t}export function isObject(t){const e=typeof t;return null!==t&&("object"===e||"function"===e)}export function isPlainObject(t){return null!==t&&"object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)}export function isEmpty(t){return null==t||("string"==typeof t||Array.isArray(t)?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"object"!=typeof t||0===Object.keys(t).length)}export function isDate(t,e){const r=Object.assign(Object.assign({},{format:"YYYY/MM/DD",delimiters:["/","-"],strictMode:!1}),e);if("string"==typeof t){const e=r.delimiters.find(t=>r.format.includes(t));if(!e)return!1;const n=r.format.split(e),i=t.split(e);if(n.length!==i.length)return!1;let o="",s="",u="";for(let t=0;t<n.length;t+=1){const e=n[t].toUpperCase(),r=i[t];e.includes("Y")?o=r:e.includes("M")?s=r:e.includes("D")&&(u=r)}if(1===s.length&&(s=`0${s}`),1===u.length&&(u=`0${u}`),2===o.length){const t=(new Date).getFullYear()%100;o=Number(o)<=t?`20${o}`:`19${o}`}const l=new Date(`${o}-${s}-${u}T00:00:00.000Z`);return l.getUTCFullYear()===Number(o)&&l.getUTCMonth()+1===Number(s)&&l.getUTCDate()===Number(u)}return!(r.strictMode||"[object Date]"!==Object.prototype.toString.call(t)||!Number.isFinite(t.getTime()))}export function isEmail(t){if("string"!=typeof t)return!1;if(t.length>254)return!1;const e=t.split("@");if(2!==e.length)return!1;const[r,n]=e;if(!r||r.length>64)return!1;if(!n)return!1;if(/^[-.]/.test(n)||/[-.]$/.test(n))return!1;if(!/^[a-zA-Z0-9.-]+$/.test(n))return!1;if(!n.includes("."))return!1;const i=n.split(".").pop();if(!i||i.length<2)return!1;return/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(r)}export function isURL(t,e){if("string"!=typeof t)return!1;if(0===t.length||/\s/.test(t))return!1;if(t.length>2084)return!1;const r=Object.assign(Object.assign({},{protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,allow_protocol_relative_urls:!1}),e);let n=t;const i=n.match(/^([a-z][a-z0-9+\-.]*):\/\//i);if(i){const t=i[1].toLowerCase();if(!r.protocols.includes(t))return!1;n=n.slice(i[0].length)}else if(r.require_protocol){if(!r.allow_protocol_relative_urls||!t.startsWith("//"))return!1;n=n.slice(2)}else if(t.startsWith("//")){if(!r.allow_protocol_relative_urls)return!1;n=n.slice(2)}if(!n&&r.require_host)return!1;const[o]=n.split(/[/?#]/);if(!o&&r.require_host)return!1;let s=o;s.includes("@")&&(s=s.split("@").pop()||"");let u=s;const l=s.match(/:(\d+)$/);if(l){const t=Number(l[1]);if(t<0||t>65535)return!1;u=s.slice(0,s.lastIndexOf(":"))}if(!u)return!1;const c=u.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(c)return c.slice(1).every(t=>Number(t)>=0&&Number(t)<=255);if(u.startsWith("[")&&u.endsWith("]"))return!0;const f=u.split(".");if(r.require_tld&&f.length<2)return!1;if(f.some(t=>!t||t.length>63||(!/^[a-zA-Z0-9-]+$/.test(t)||!(!t.startsWith("-")&&!t.endsWith("-")))))return!1;if(r.require_tld){const t=f[f.length-1];if(/^\d+$/.test(t))return!1}return!0}

View File

@@ -1,4 +1,4 @@
export declare const getObserver: (context: any, selector: string) => Promise<unknown>;
export declare const getObserver: (context: any, selector: string) => Promise<WechatMiniprogram.IntersectionObserverObserveCallbackResult>;
export declare const getWindowInfo: () => WechatMiniprogram.WindowInfo | WechatMiniprogram.SystemInfo;
export declare const getAppBaseInfo: () => WechatMiniprogram.SystemInfo | WechatMiniprogram.AppBaseInfo;
export declare const getDeviceInfo: () => WechatMiniprogram.SystemInfo | WechatMiniprogram.DeviceInfo;

View File

@@ -1 +1 @@
export const getObserver=(e,t)=>new Promise((o=>{e.createIntersectionObserver(e).relativeToViewport().observe(t,(e=>{o(e)}))}));export const getWindowInfo=()=>wx.getWindowInfo&&wx.getWindowInfo()||wx.getSystemInfoSync();export const getAppBaseInfo=()=>wx.getAppBaseInfo&&wx.getAppBaseInfo()||wx.getSystemInfoSync();export const getDeviceInfo=()=>wx.getDeviceInfo&&wx.getDeviceInfo()||wx.getSystemInfoSync();
export const getObserver=(e,t)=>new Promise(o=>{e.createIntersectionObserver({nativeMode:!0}).relativeToViewport().observe(t,e=>{o(e)})});export const getWindowInfo=()=>wx.getWindowInfo&&wx.getWindowInfo()||wx.getSystemInfoSync();export const getAppBaseInfo=()=>wx.getAppBaseInfo&&wx.getAppBaseInfo()||wx.getSystemInfoSync();export const getDeviceInfo=()=>wx.getDeviceInfo&&wx.getDeviceInfo()||wx.getSystemInfoSync();