初始化项目, 添加TDesign等包

This commit is contained in:
zhengw
2025-11-28 16:49:36 +08:00
commit 3e53beb7bb
980 changed files with 39201 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
export default class Bus {
listeners: Map<string, any>;
emitted: Set<string>;
constructor();
on(evtName: string, listener: any): void;
emit(evtName: string): void;
}

View File

@@ -0,0 +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)}}

View File

@@ -0,0 +1,56 @@
export declare type Classes = Array<string>;
export interface Styles {
[css: string]: string | number;
}
export declare type ImageEvent = any;
export declare type PlainObject = {
[key: string]: any;
};
export declare type OptionData = {
label?: string;
value?: string | number;
} & PlainObject;
export declare type TreeOptionData<T = string | number> = {
children?: Array<TreeOptionData<T>> | boolean;
label?: string;
text?: string;
value?: T;
content?: string;
} & PlainObject;
export declare type SizeEnum = 'small' | 'medium' | 'large';
export declare type ShapeEnum = 'circle' | 'round';
export declare type HorizontalAlignEnum = 'left' | 'center' | 'right';
export declare type VerticalAlignEnum = 'top' | 'middle' | 'bottom';
export declare type LayoutEnum = 'vertical' | 'horizontal';
export declare type ClassName = {
[className: string]: any;
} | ClassName[] | string;
export declare type CSSSelector = string;
export interface KeysType {
value?: string;
label?: string;
disabled?: string;
}
export interface TreeKeysType extends KeysType {
children?: string;
}
export interface HTMLElementAttributes {
[attribute: string]: string;
}
export interface TScroll {
bufferSize?: number;
isFixedRowHeight?: boolean;
rowHeight?: number;
threshold?: number;
type: 'lazy' | 'virtual';
}
export declare type InfinityScroll = TScroll;
export interface ScrollToElementParams {
index?: number;
top?: number;
time?: number;
behavior?: 'auto' | 'smooth';
}
export interface ComponentScrollToElementParams extends ScrollToElementParams {
key?: string | number;
}

View File

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

View File

@@ -0,0 +1,3 @@
/// <reference types="miniprogram-api-typings" />
declare const TComponent: typeof Component;
export default TComponent;

View File

@@ -0,0 +1 @@
const TComponent=o=>(o.options=Object.assign({multipleSlots:!0,addGlobalClass:!0},o.options),Component(o));export default TComponent;

View File

@@ -0,0 +1,5 @@
declare const _default: {
prefix: string;
};
export default _default;
export declare const prefix = "t";

View File

@@ -0,0 +1 @@
export default{prefix:"t"};export const prefix="t";

View File

@@ -0,0 +1,20 @@
import type { TDate, TCalendarType, TCalendarValue } from './type';
export default class TCalendar {
firstDayOfWeek: number;
value: TCalendarValue | TCalendarValue[];
type: TCalendarType;
minDate: Date;
maxDate: Date;
allowSameDay: Boolean;
format: (day: TDate) => TDate;
constructor(options?: {});
getTrimValue(): Date | Date[];
getDays(weekdays: string[]): any[];
getMonths(): any[];
select({ cellType, year, month, date }: {
cellType: any;
year: any;
month: any;
date: any;
}): Date | TCalendarValue[];
}

View File

@@ -0,0 +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,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

@@ -0,0 +1,11 @@
export declare type TCalendarValue = number | Date;
export declare type TDateType = 'selected' | 'disabled' | 'start-end' | 'start' | 'centre' | 'end' | '';
export declare type TCalendarType = 'single' | 'multiple' | 'range';
export interface TDate {
date: Date;
day: number;
type: TDateType;
className?: string;
prefix?: string;
suffix?: string;
}

View File

@@ -0,0 +1,7 @@
export declare const rgb2cmyk: (red: number, green: number, blue: number) => number[];
export declare const cmyk2rgb: (cyan: number, magenta: number, yellow: number, black: number) => {
r: number;
g: number;
b: number;
};
export declare const cmykInputToColor: (input: string) => string;

View File

@@ -0,0 +1 @@
export const rgb2cmyk=(t,r,e)=>{let n=0,o=0,c=0,a=0;const s=parseInt(`${t}`.replace(/\s/g,""),10),m=parseInt(`${r}`.replace(/\s/g,""),10),u=parseInt(`${e}`.replace(/\s/g,""),10);if(0===s&&0===m&&0===u)return a=1,[0,0,0,1];n=1-s/255,o=1-m/255,c=1-u/255;const p=Math.min(n,Math.min(o,c));return n=(n-p)/(1-p),o=(o-p)/(1-p),c=(c-p)/(1-p),a=p,[n,o,c,a]};export const cmyk2rgb=(t,r,e,n)=>{let o=t/100,c=r/100,a=e/100;const s=n/100;o=o*(1-s)+s,c=c*(1-s)+s,a=a*(1-s)+s;let m=1-o,u=1-c,p=1-a;return m=Math.round(255*m),u=Math.round(255*u),p=Math.round(255*p),{r:m,g:u,b:p}};const REG_CMYK_STRING=/cmyk\((\d+%?),(\d+%?),(\d+%?),(\d+%?)\)/,toNumber=t=>Math.max(0,Math.min(255,parseInt(t,10)));export const cmykInputToColor=t=>{if(/cmyk/i.test(t)){const r=t.replace(/\s/g,"").match(REG_CMYK_STRING),e=toNumber(r[1]),n=toNumber(r[2]),o=toNumber(r[3]),c=toNumber(r[4]),{r:a,g:s,b:m}=cmyk2rgb(e,n,o,c);return`rgb(${a}, ${s}, ${m})`}return t};

View File

@@ -0,0 +1,107 @@
import tinyColor from 'tinycolor2/esm/tinycolor';
import { GradientColors, GradientColorPoint } from './gradient';
export interface ColorObject {
alpha: number;
css: string;
hex: string;
hex8: string;
hsl: string;
hsla: string;
hsv: string;
hsva: string;
rgb: string;
rgba: string;
saturation: number;
value: number;
isGradient: boolean;
linearGradient?: string;
}
interface ColorStates {
s: number;
v: number;
h: number;
a: number;
}
interface GradientStates {
colors: GradientColorPoint[];
degree: number;
selectedId: string;
css?: string;
}
export declare const gradientColors2string: (object: GradientColors) => string;
export declare const getColorWithoutAlpha: (color: string) => any;
export declare const genId: () => string;
export declare const genGradientPoint: (left: number, color: string) => GradientColorPoint;
export declare class Color {
states: ColorStates;
originColor: string;
isGradient: boolean;
gradientStates: GradientStates;
constructor(input: string);
update(input: string): void;
get saturation(): number;
set saturation(value: number);
get value(): number;
set value(value: number);
get hue(): number;
set hue(value: number);
get alpha(): number;
set alpha(value: number);
get rgb(): string;
get rgba(): string;
get hsv(): string;
get hsva(): string;
get hsl(): string;
get hsla(): string;
get hex(): any;
get hex8(): any;
get cmyk(): string;
get css(): string;
get linearGradient(): string;
get gradientColors(): GradientColorPoint[];
set gradientColors(colors: GradientColorPoint[]);
get gradientSelectedId(): string;
set gradientSelectedId(id: string);
get gradientDegree(): number;
set gradientDegree(degree: number);
get gradientSelectedPoint(): GradientColorPoint;
getFormatsColorMap(): {
HEX: any;
CMYK: string;
RGB: string;
RGBA: string;
HSL: string;
HSLA: string;
HSV: string;
HSVA: string;
CSS: string;
HEX8: any;
};
updateCurrentGradientColor(): false | this;
updateStates(input: string): void;
getRgba(): {
r: number;
g: number;
b: number;
a: tinyColor.ColorFormats.RGBA;
};
getCmyk(): {
c: number;
m: number;
y: number;
k: number;
};
getHsva(): tinyColor.ColorFormats.HSVA;
getHsla(): tinyColor.ColorFormats.HSLA;
equals(color: string): boolean;
static isValid(color: string): boolean;
static hsva2color(h: number, s: number, v: number, a: number): any;
static hsla2color(h: number, s: number, l: number, a: number): any;
static rgba2color(r: number, g: number, b: number, a: number): any;
static hex2color(hex: string, a: number): any;
static object2color(object: any, format: string): any;
static isGradientColor: (input: string) => boolean;
static compare: (color1: string, color2: string) => boolean;
}
export declare const getColorObject: (color: Color) => ColorObject;
export default Color;

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
export interface GradientColorPoint {
id?: string;
color?: string;
left?: number;
}
export interface GradientColors {
points: GradientColorPoint[];
degree: number;
}
export declare const isGradientColor: (input: string) => null | RegExpExecArray;
export declare const parseGradientString: (input: string) => GradientColors | boolean;
export default parseGradientString;

View File

@@ -0,0 +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;

View File

@@ -0,0 +1,3 @@
export * from './cmyk';
export * from './color';
export * from './gradient';

View File

@@ -0,0 +1 @@
export*from"./cmyk";export*from"./color";export*from"./gradient";

View File

@@ -0,0 +1,21 @@
export declare type CompareDate = Date | number | {
year: number;
month: number;
date: number;
};
export declare const getDateRect: (date: Date | number) => {
year: number;
month: number;
date: number;
day: number;
time: number;
};
export declare const isSameDate: (date1: CompareDate, date2: CompareDate) => Boolean;
export declare const getMonthDateRect: (date: Date | number) => {
year: number;
month: number;
weekdayOfFirstDay: number;
lastDate: number;
};
export declare const isValidDate: (val: any) => boolean;
export declare const getDate: (...args: any[]) => any;

View File

@@ -0,0 +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)};

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,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

@@ -0,0 +1,15 @@
declare type ControlInstance = {
controlled: boolean;
initValue: any;
set(newVal: any, extObj?: Object, fn?: any): void;
get(): any;
change(newVal: any, customChangeData?: any, customUpdateFn?: any): void;
};
declare type ControlOption = {
valueKey?: string;
defaultValueKey?: string;
changeEventName?: string;
strict?: boolean;
};
declare function useControl(this: any, option?: ControlOption): ControlInstance;
export { ControlOption, ControlInstance, useControl };

View File

@@ -0,0 +1 @@
const defaultOption={valueKey:"value",defaultValueKey:"defaultValue",changeEventName:"change",strict:!0};function useControl(e={}){const{valueKey:t,defaultValueKey:a,changeEventName:n,strict:s}=Object.assign(Object.assign({},defaultOption),e),l=this.properties||{},i=l[t],u=l[s?a:t];let o=!1;s&&null!=i&&(o=!0);const c=(e,a,n)=>{this.setData(Object.assign({[`_${t}`]:e},a),n)};return{controlled:o,initValue:o?i:u,set:c,get:()=>this.data[`_${t}`],change:(e,t,a)=>{this.triggerEvent(n,void 0!==t?t:e),o||("function"==typeof a?a():c(e))}}}export{useControl};

View File

@@ -0,0 +1,13 @@
export declare const getPrototypeOf: (obj: any) => any;
export declare const iterateInheritedPrototype: (callback: (proto: Record<string, any>) => boolean | void, fromCtor: any, toCtor: any, includeToCtor?: boolean) => void;
export interface ClassInstanceToObjectOptions {
bindTo?: any;
excludes?: string[];
till?: any;
enumerable?: 0 | boolean;
configurable?: 0 | boolean;
writable?: 0 | boolean;
}
export declare const toObject: (something: any, options?: ClassInstanceToObjectOptions) => {
[key: string]: any;
};

View File

@@ -0,0 +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};

View File

@@ -0,0 +1,4 @@
export * from './superComponent';
export * from './flatTool';
export * from './instantiationDecorator';
export * from './control';

View File

@@ -0,0 +1 @@
export*from"./superComponent";export*from"./flatTool";export*from"./instantiationDecorator";export*from"./control";

View File

@@ -0,0 +1,3 @@
import { SuperComponent } from './superComponent';
export declare const toComponent: (options: Record<string, any>) => Record<string, any>;
export declare const wxComponent: () => (constructor: new () => SuperComponent) => void;

View File

@@ -0,0 +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)}};

View File

@@ -0,0 +1,19 @@
/// <reference types="miniprogram-api-typings" />
export interface ComponentsOptionsType extends WechatMiniprogram.Component.ComponentOptions {
styleIsolation?: 'isolated' | 'apply-shared' | 'shared' | 'page-isolated' | 'page-apply-shared' | 'page-shared';
}
export interface RelationsOptions {
[componentName: string]: WechatMiniprogram.Component.RelationOption;
}
export interface SuperComponent<D = {}, P = {}, M = {}> extends WechatMiniprogram.Component.Lifetimes, WechatMiniprogram.Component.OtherOption, WechatMiniprogram.Component.InstanceMethods<D> {
properties: P;
data: D;
options: ComponentsOptionsType;
methods: M | Record<string, (...args: any[]) => any>;
$global: Function;
[x: string]: any;
}
export declare class SuperComponent<D = {}, P = {}, M = {}> {
readonly app: any;
constructor();
}

View File

@@ -0,0 +1 @@
export class SuperComponent{constructor(){this.app=getApp()}}

View File

@@ -0,0 +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);}

View File

@@ -0,0 +1,4 @@
@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);}}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +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-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-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

@@ -0,0 +1 @@
.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

@@ -0,0 +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;}

View File

@@ -0,0 +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);}

View File

@@ -0,0 +1 @@
<template name="badge"><t-badge color="{{color || ''}}" content="{{content || ''}}" count="{{count || 0}}" dot="{{dot || false}}" max-count="{{maxCount || 99}}" offset="{{offset || []}}" shape="{{shape || 'circle'}}" show-zero="{{showZero || false}}" size="{{size || 'medium'}}" t-class="{{tClass}}" t-class-content="{{tClassContent}}" t-class-count="{{tClassCount}}"/></template>

View File

@@ -0,0 +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: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

@@ -0,0 +1 @@
<template name="icon"><t-icon style="{{style || ''}}" t-class="{{tClass}}" prefix="{{prefix || ''}}" name="{{name || ''}}" size="{{size || ''}}" color="{{color || ''}}" aria-hidden="{{ariaHidden || '' }}" aria-label="{{ariaLabel || ''}}" aria-role="{{ariaRole || ''}}" bind:click="{{bindclick || ''}}"/></template>

View File

@@ -0,0 +1 @@
<template name="image"><t-image t-class="{{tClass}}" t-class-load="{{tClassLoad}}" style="{{style || ''}}" customStyle="{{customStyle || ''}}" height="{{height || ''}}" width="{{width || ''}}" error="{{error || 'default'}}" lazy="{{lazy || false}}" loading="{{count || 'default'}}" shape="{{shape || 'square'}}" src="{{src || ''}}" mode="{{mode || 'scaleToFill'}}" webp="{{webp || false}}" showMenuByLongpress="{{showMenuByLongpress || false}}" data-custom="{{dataset || null}}" bind:error="{{binderror}}" bind:load="{{bindload}}"/></template>

View File

@@ -0,0 +1,38 @@
/// <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;
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;
export declare const classNames: (...args: any[]) => string;
export declare const styles: (styleObj: any) => string;
export declare const getAnimationFrame: (context: any, cb: Function) => any;
export declare const getRect: (context: any, selector: string, needAll?: boolean) => Promise<any>;
interface TreeNode {
children?: TreeNode[];
[key: string]: any;
}
export declare const getTreeDepth: (tree: TreeNode[], key?: string) => any;
export declare const isIOS: () => boolean;
export declare const addUnit: (value?: string | number) => string | undefined;
export declare const getCharacterLength: (type: string, char: string | number, max?: number) => {
length: number;
characters: string;
};
export declare const chunk: (arr: any[], size: number) => any[][];
export declare const getInstance: (context?: Context, selector?: string) => WechatMiniprogram.Component.TrivialInstance;
export declare const unitConvert: (value: number | string | null | undefined) => number;
export declare const setIcon: (iconName: any, icon: any, defaultIcon: any) => {
[x: string]: any;
};
export declare const toCamel: (str: any) => any;
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>;
export declare const isOverSize: (size: any, sizeLimit: any) => boolean;
export declare const rpx2px: (rpx: any) => number;
export declare const nextTick: () => Promise<void>;
export {};

View File

@@ -0,0 +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()})});

View File

@@ -0,0 +1,149 @@
/* utils */
/**
* addUnit */
// 为 css 添加单位
function addUnit(value) {
// prettier-ignore
var REGEXP = getRegExp('^-?\d+(.\d+)?$');
if (value == null) {
return undefined;
}
return REGEXP.test('' + value) ? value + 'px' : value;
}
function isString(string) {
return string && string.constructor === 'String';
}
function isArray(array) {
return array && array.constructor === 'Array';
}
function isObject(obj) {
return obj && obj.constructor === 'Object';
}
function isBoolean(value) {
return typeof value === 'boolean';
}
function isNoEmptyObj(obj) {
return isObject(obj) && JSON.stringify(obj) !== '{}';
}
function includes(arr, value) {
if (!arr || !isArray(arr)) return false;
var i = 0;
var len = arr.length;
for (; i < len; i++) {
if (arr[i] === value) return true;
}
return false;
}
function cls(base, arr) {
var res = [base];
var i = 0;
for (var size = arr.length; i < size; i++) {
var item = arr[i];
if (item && item.constructor === 'Array') {
var key = arr[i][0];
var value = arr[i][1];
if (value) {
res.push(base + '--' + key);
}
} else if (typeof item === 'string' || typeof item === 'number') {
if (item) {
res.push(base + '--' + item);
}
}
}
return res.join(' ');
}
function getBadgeAriaLabel(options) {
var maxCount = options.maxCount || 99;
if (options.dot) {
return '有新的消息';
}
if (options.count === '...') {
return '有很多消息';
}
if (isNaN(options.count)) {
return options.count;
}
var str1 = '有' + maxCount + '+条消息';
var str2 = '有' + options.count + '条消息';
return Number(options.count) > maxCount ? str1 : str2;
}
function endsWith(str, endStr) {
return str.slice(-endStr.length) === endStr ? str : str + endStr;
}
function keys(obj) {
return JSON.stringify(obj)
.replace(getRegExp('{|}|"', 'g'), '')
.split(',')
.map(function (item) {
return item.split(':')[0];
});
}
function kebabCase(str) {
return str
.replace(getRegExp('[A-Z]', 'g'), function (ele) {
return '-' + ele;
})
.toLowerCase();
}
function _style(styles) {
if (isArray(styles)) {
return styles
.filter(function (item) {
return item != null && item !== '';
})
.map(function (item) {
return isArray(item) ? _style(item) : endsWith(item, ';');
})
.join(' ');
}
if (isObject(styles)) {
return keys(styles)
.filter(function (key) {
return styles[key] != null && styles[key] !== '';
})
.map(function (key) {
return [kebabCase(key), [styles[key]]].join(':');
})
.join(';');
}
return styles;
}
function isValidIconName(str) {
// prettier-ignore
return getRegExp('^[A-Za-z0-9\-\_]+$').test(str);
}
module.exports = {
addUnit: addUnit,
isString: isString,
isArray: isArray,
isObject: isObject,
isBoolean: isBoolean,
isNoEmptyObj: isNoEmptyObj,
includes: includes,
cls: cls,
getBadgeAriaLabel: getBadgeAriaLabel,
_style: _style,
isValidIconName: isValidIconName,
};

View File

@@ -0,0 +1,9 @@
export declare function isFunction(val: unknown): val is Function;
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 | number): 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>;

View File

@@ -0,0 +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"number"==typeof t||/^-?\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)}

View File

@@ -0,0 +1,4 @@
export declare function compareVersion(v1: any, v2: any): 0 | 1 | -1;
export declare function canIUseFormFieldButton(): boolean;
export declare function canUseVirtualHost(): boolean;
export declare function canUseProxyScrollView(): boolean;

View File

@@ -0,0 +1 @@
import{getAppBaseInfo}from"./wechat";let systemInfo;function getSystemInfo(){return null==systemInfo&&(systemInfo=getAppBaseInfo()),systemInfo}export function compareVersion(e,n){e=e.split("."),n=n.split(".");const t=Math.max(e.length,n.length);for(;e.length<t;)e.push("0");for(;n.length<t;)n.push("0");for(let r=0;r<t;r+=1){const t=parseInt(e[r],10),o=parseInt(n[r],10);if(t>o)return 1;if(t<o)return-1}return 0}function judgeByVersion(e){return compareVersion(getSystemInfo().SDKVersion,e)>=0}export function canIUseFormFieldButton(){return judgeByVersion("2.10.3")}export function canUseVirtualHost(){return judgeByVersion("2.19.2")}export function canUseProxyScrollView(){return judgeByVersion("2.19.2")}

View File

@@ -0,0 +1,4 @@
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

@@ -0,0 +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();