From f40b877c8063eda2bec94dad08cfa58041e8fa3f Mon Sep 17 00:00:00 2001 From: iapyang Date: Fri, 10 Jan 2020 16:56:11 +0800 Subject: [PATCH 1/2] chore: add ignore --- .npmignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.npmignore b/.npmignore index fd0cacc04..52430b7f7 100644 --- a/.npmignore +++ b/.npmignore @@ -9,6 +9,8 @@ !dist/fineui.min.js.map !dist/fineui.ie.min.js !dist/fineui.ie.min.js.map +!babel.config.js +!babel.config.ie8.js !dist/fineui.min.css !dist/fineui.js !dist/fineui.css From 12670b2fde1bf2f6eb73a6d55e6b2a7ead377c0d Mon Sep 17 00:00:00 2001 From: iapyang Date: Fri, 10 Jan 2020 16:57:39 +0800 Subject: [PATCH 2/2] chore: add lib --- .gitignore | 1 - dist/lib/base/pane.d.ts | 10 + dist/lib/base/single/button/button.basic.d.ts | 18 + dist/lib/base/single/single.d.ts | 20 ++ dist/lib/base/single/trigger/trigger.d.ts | 5 + dist/lib/bundle.d.ts | 1 + dist/lib/case/loading/loading_pane.d.ts | 4 + dist/lib/core/action/action.d.ts | 8 + dist/lib/core/action/action.show.d.ts | 3 + dist/lib/core/base.d.ts | 193 +++++++++++ dist/lib/core/behavior/behavior.d.ts | 7 + .../lib/core/behavior/behavior.highlight.d.ts | 3 + dist/lib/core/behavior/behavior.redmark.d.ts | 3 + dist/lib/core/decorator/decorator.d.ts | 64 ++++ dist/lib/core/func/array.d.ts | 9 + dist/lib/core/func/date.d.ts | 92 +++++ dist/lib/core/func/function.d.ts | 36 ++ dist/lib/core/func/index.d.ts | 8 + dist/lib/core/func/number.d.ts | 35 ++ dist/lib/core/func/string.d.ts | 62 ++++ dist/lib/core/i18n.d.ts | 6 + dist/lib/core/ob.d.ts | 35 ++ dist/lib/core/widget.d.ts | 323 ++++++++++++++++++ dist/lib/index.d.ts | 42 +++ 24 files changed, 987 insertions(+), 1 deletion(-) create mode 100644 dist/lib/base/pane.d.ts create mode 100644 dist/lib/base/single/button/button.basic.d.ts create mode 100644 dist/lib/base/single/single.d.ts create mode 100644 dist/lib/base/single/trigger/trigger.d.ts create mode 100644 dist/lib/bundle.d.ts create mode 100644 dist/lib/case/loading/loading_pane.d.ts create mode 100644 dist/lib/core/action/action.d.ts create mode 100644 dist/lib/core/action/action.show.d.ts create mode 100644 dist/lib/core/base.d.ts create mode 100644 dist/lib/core/behavior/behavior.d.ts create mode 100644 dist/lib/core/behavior/behavior.highlight.d.ts create mode 100644 dist/lib/core/behavior/behavior.redmark.d.ts create mode 100644 dist/lib/core/decorator/decorator.d.ts create mode 100644 dist/lib/core/func/array.d.ts create mode 100644 dist/lib/core/func/date.d.ts create mode 100644 dist/lib/core/func/function.d.ts create mode 100644 dist/lib/core/func/index.d.ts create mode 100644 dist/lib/core/func/number.d.ts create mode 100644 dist/lib/core/func/string.d.ts create mode 100644 dist/lib/core/i18n.d.ts create mode 100644 dist/lib/core/ob.d.ts create mode 100644 dist/lib/core/widget.d.ts create mode 100644 dist/lib/index.d.ts diff --git a/.gitignore b/.gitignore index c4b180332..945447be2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,4 @@ node_modules/ coverage unit.test.statistic.json package-lock.json -dist/lib *.tgz \ No newline at end of file diff --git a/dist/lib/base/pane.d.ts b/dist/lib/base/pane.d.ts new file mode 100644 index 000000000..aa114dea8 --- /dev/null +++ b/dist/lib/base/pane.d.ts @@ -0,0 +1,10 @@ +import { _Widget } from "../core/widget"; +export interface _Pane extends _Widget { + _assertTip: (..._args: any[]) => void; + loading: (..._args: any[]) => void; + loaded: (..._args: any[]) => void; + check: (..._args: any[]) => void; +} +export interface _PaneStatic { + EVENT_LOADED: "EVENT_LOADED"; +} diff --git a/dist/lib/base/single/button/button.basic.d.ts b/dist/lib/base/single/button/button.basic.d.ts new file mode 100644 index 000000000..fd31ec7d3 --- /dev/null +++ b/dist/lib/base/single/button/button.basic.d.ts @@ -0,0 +1,18 @@ +import { _Single } from "../single"; +export interface _BasicButton extends _Single { + _createShadow(): void; + bindEvent(): void; + _trigger(e: Event): void; + _doClick(e: Event): void; + beforeClick(): void; + doClick(): void; + handle(): _BasicButton; + hover(): void; + dishover(): void; + setSelected(b: any): void; + isSelected(): boolean; + isOnce(): boolean; + isForceSelected(): boolean; + isForceNotSelected(): boolean; + isDisableSelected(): boolean; +} diff --git a/dist/lib/base/single/single.d.ts b/dist/lib/base/single/single.d.ts new file mode 100644 index 000000000..b7d58bfe9 --- /dev/null +++ b/dist/lib/base/single/single.d.ts @@ -0,0 +1,20 @@ +import { _Widget } from "../../core/widget"; +export interface _Single extends _Widget { + _showToolTip(e: Event, opt?: SingleOpt): void; + _hideTooltip(): void; + _clearTimeOut(): void; + enableHover(opt?: SingleOpt): void; + disabledHover(): void; + setTitle(title: string, opt?: SingleOpt): void; + setWarningTitle(title: string, opt?: SingleOpt): void; + getTipType(): string; + isReadOnly(): boolean; + getTitle(): string; + getWarningTitle(): string; + popluate(..._args: any[]): void; +} +interface SingleOpt { + container?: any; + belowMouse?: boolean; +} +export {}; diff --git a/dist/lib/base/single/trigger/trigger.d.ts b/dist/lib/base/single/trigger/trigger.d.ts new file mode 100644 index 000000000..af0b7ff1c --- /dev/null +++ b/dist/lib/base/single/trigger/trigger.d.ts @@ -0,0 +1,5 @@ +import { _Single } from "../single"; +export interface _Trigger extends _Single { + setKey(..._args: any[]): void; + getKey(): string; +} diff --git a/dist/lib/bundle.d.ts b/dist/lib/bundle.d.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/dist/lib/bundle.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/lib/case/loading/loading_pane.d.ts b/dist/lib/case/loading/loading_pane.d.ts new file mode 100644 index 000000000..47ac80936 --- /dev/null +++ b/dist/lib/case/loading/loading_pane.d.ts @@ -0,0 +1,4 @@ +import { _Pane } from "../../base/pane"; +export interface _LoadingPane extends _Pane { + __loaded: (...args: any[]) => void; +} diff --git a/dist/lib/core/action/action.d.ts b/dist/lib/core/action/action.d.ts new file mode 100644 index 000000000..e57556b8e --- /dev/null +++ b/dist/lib/core/action/action.d.ts @@ -0,0 +1,8 @@ +import { _OB } from "../ob"; +export interface _Action extends _OB { + actionPerformed(src: any, tar: any, callback: Function): void; + actionBack(tar: any, src: any, callback: Function): void; +} +export interface _ActionFactory { + createAction(key: string, options: any): _Action; +} diff --git a/dist/lib/core/action/action.show.d.ts b/dist/lib/core/action/action.show.d.ts new file mode 100644 index 000000000..d41395605 --- /dev/null +++ b/dist/lib/core/action/action.show.d.ts @@ -0,0 +1,3 @@ +import { _Action } from "./action"; +export interface _ShowAction extends _Action { +} diff --git a/dist/lib/core/base.d.ts b/dist/lib/core/base.d.ts new file mode 100644 index 000000000..2d6fd559f --- /dev/null +++ b/dist/lib/core/base.d.ts @@ -0,0 +1,193 @@ +import { _Widget } from "./widget"; +export interface _base { + assert: (v: any, is: Function) => Boolean; + warn: (message: any) => Boolean; + UUID: () => string; + isWidget: (widget: any) => widget is _Widget; + createWidgets: (items: any, options: any, context: any) => any; + createItems: (data: T[], innerAttr?: U, outerAttr?: K) => (U & T & K)[]; + packageItems: (items: any[], layouts: any[]) => any[]; + formatEL: (obj: T) => { + el: T; + } | T; + stripEL: (obj: { + el: T; + } | T) => T; + trans2Element: (widgets: any[]) => any[]; + where: (collection: any[] | object | string, source: object) => any[]; + findWhere: (collection: any[] | object | string, callback?: Function | object | string, thisArg?: any) => object | undefined; + invoke: (collection: any[] | object | string, methodName: Function | string, arg?: any) => any[]; + pluck: (collection: any[] | object | string, property: string) => any[]; + shuffle: (collection: any[] | object | string) => any[]; + sample: (collection: any[] | object | string, n?: number) => any[]; + toArray: (collection: any[] | object | string) => any[]; + size: (collection: any[] | object | string) => number; + each: (collection: T[] | object | string, callback?: ((index: number, value: T) => void) | object | string, thisArg?: any) => any; + map: (collection: T[] | object | string | null | undefined, callback?: ((index: number, value: T) => U) | object | string, thisArg?: any) => U[]; + reduce: (collection: T[] | object | string, callback?: ((total: U extends T ? U : T, currentValue: T, currentIndex: number) => U extends T ? U : T) | object | string, initialValue?: U | T) => U extends T ? U : T; + reduceRight: (collection: T[] | object | string, callback?: ((total: U extends T ? U : T, currentValue: T, currentIndex: number) => U extends T ? U : T) | object | string, initialValue?: U | T) => U extends T ? U : T; + find: (collection: T[] | object | string, callback?: ((index: number, value: T) => boolean) | object | string, thisArg?: any) => any; + filter: (collection: T[] | object | string, callback?: ((index: number, value: T) => boolean) | object | string, thisArg?: any) => any[]; + reject: (collection: any[] | object | string, callback?: ((index: number, value: T) => boolean) | object | string, thisArg?: any) => any[]; + every: (collection: any[] | object | string, callback?: ((index: number, value: T) => boolean) | object | string, thisArg?: any) => boolean; + all: (collection: any[] | object | string, callback?: ((index: number, value: T) => boolean) | object | string, thisArg?: any) => boolean; + some: (collection: any[] | object | string, callback?: ((index: number, value: T) => boolean) | object | string, thisArg?: any) => boolean; + any: (collection: T[] | object | string, callback?: ((index: number, value: T) => boolean) | object | string, thisArg?: any) => boolean; + max: (collection: T[]) => T; + min: (collection: T[]) => T; + sortBy: (collection: any[] | object | string, callback?: ((index: number, value: T) => number) | object | string, thisArg?: any) => any[]; + groupBy: (collection: any[] | object | string, callback?: ((index: number, value: T) => any) | object | string, thisArg?: any) => object; + indexBy: (collection: any[] | object | string, callback?: ((index: number, value: T) => any) | object | string, thisArg?: any) => object; + countBy: (collection: any[] | object | string, callback?: ((index: number, value: T) => any) | object | string, thisArg?: any) => object; + count: (from: number, to: number, predicate: Function) => number; + inverse: (from: number, to: number, predicate: Function) => number; + firstKey: (obj: object) => string; + lastKey: (obj: object) => string; + firstObject: (obj: object) => any; + lastObject: (obj: object) => any; + concat: (obj1: any, obj2: any) => any; + backEach: (obj: any, predicate: Function, context?: any) => boolean; + backAny: (obj: any, predicate: Function, context?: any) => boolean; + backEvery: (obj: any, predicate: Function, context?: any) => boolean; + backFindKey: (obj: any, predicate: Function, context?: any) => string; + backFind: (obj: any, predicate: Function, context?: any) => any; + remove: (obj: any, predicate: any, context?: any) => void; + removeAt: (obj: any, index: number | number[]) => void; + string2Array: (str: string) => string[]; + array2String: (array: any[]) => string; + abc2Int: (str: string) => number; + int2Abc: (num: number) => string; + first: (array: T[], callback?: Function | object | number | string, thisArg?: any) => T; + initial: (array: T[], callback?: Function | object | number | string, thisArg?: any) => T[]; + last: (array: T[], callback?: Function | object | number | string, thisArg?: any) => T; + rest: (array: T[], callback?: Function | object | number | string, thisArg?: any) => T[]; + compact: (array: any[]) => any[]; + flatten: (array: any[], isShallow?: boolean, callback?: Function | object | string, thisArg?: any) => any[]; + without: (array: any[], value?: any) => any[]; + union: (...array: any[]) => any[]; + intersection: (...array: any[]) => any[]; + difference: (...array: any[]) => any[]; + zip: (...array: any[]) => any[]; + unzip: (...array: any[]) => any[]; + object: (keys: string[], values?: any[]) => any[]; + indexOf: (array: any[], value: any, fromIndex?: number) => number; + lastIndexOf: (array: any[], value: any, fromIndex?: number) => number; + sortedIndex: (array: any[], value: any, callback?: Function | object | string, thisArg?: any) => number; + range: (start: number, end: number, step: number) => number[]; + take: (array: T[], n: number) => T[]; + takeRight: (array: T[], n: number) => T[]; + findIndex: (array: any[], value: any, callback?: Function | object | string, thisArg?: any) => number; + findLastIndex: (array: any[], value: any, callback?: Function | object | string, thisArg?: any) => number; + makeArray: (length: number, value?: T) => number[] | T[]; + makeObject: (array: any[], value: any) => any; + makeArrayByArray: (array: any[], value: T) => T[]; + uniq: (array: T[], isSorted?: boolean, iteratee?: any, context?: any) => T[]; + keys: (object: object) => string[]; + allKeys: (object: object) => string[]; + values: (object: object) => any[]; + pairs: (object: object) => any[]; + invert: (object: object, multiValue: boolean) => object; + create: (prototype: object, properties?: object) => object; + functions: (object: object) => string[]; + extend: (object: object, ...sources: any[]) => object; + defaults: (object: object, ...sources: any[]) => object; + clone: (object: T) => T; + property: (path: any[] | string) => Function; + propertyOf: (object: object) => Function; + isEqual: (value: any, other: any, customizer?: Function, thisArg?: any) => boolean; + isMatch: (object: object, source: object, customizer?: Function, thisArg?: any) => boolean; + isEmpty: (value: any[] | object | string | null | undefined | number) => boolean; + isElement: (value: any) => boolean; + isNumber: (value: any) => value is number; + isString: (value: any) => value is string; + isArray: (value: T[] | any) => value is T[]; + isObject: (value: any) => value is object; + isPlainObject: (value: any) => value is object; + isArguments: (value: any) => boolean; + isFunction: (value: any) => value is Function; + isFinite: (value: any) => value is number; + isBoolean: (value: any) => value is boolean; + isDate: (value: any) => value is Date; + isRegExp: (value: any) => value is RegExp; + isError: (value: any) => value is Error; + isNaN: (value: any) => value is number; + isUndefined: (value: any) => value is undefined; + zipObject: (props: any[], values?: any[]) => object; + cloneDeep: (value: any, customizer?: Function, thisArg?: any) => any; + findKey: (object: object, predicate?: Function | object | string, thisArg?: any) => any; + pick: (object: object, predicate?: Function | string | string[], thisArg?: any) => object; + omit: (object: object, predicate?: Function | string | string[], thisArg?: any) => object; + tap: (value: any, interceptor: Function, thisArg?: any) => any; + inherit: (sb: any, sp: any, overrides?: any) => any; + init: () => void; + has: (obj: object, keys: string | string[]) => boolean; + freeze: (value: T) => T; + isKey: (key: any) => key is (number | string); + isCapitalEqual: (a: string | null | undefined, b: string | null | undefined) => boolean; + isWidthOrHeight: (w: number | string) => boolean; + isNotNull: (obj: T) => obj is NonNullable; + isNull: (obj: any) => obj is (undefined | null); + isEmptyArray: (arr: T[] | U) => arr is T[] & { + length: 0; + }; + isNotEmptyArray: (arr: T[] | U) => arr is [T, ...T[]]; + isEmptyObject: (obj: any) => obj is object; + isNotEmptyObject: (obj: any) => obj is object; + isWindow: (obj: any) => obj is Window; + isDeepMatch: (object: any, attrs: any) => boolean; + contains: (obj: any[], target: any, fromIndex?: number) => number; + deepContains: (obj: any[], copy: any) => number; + deepIndexOf: (obj: any[], target: any) => number; + deepRemove: (obj: any[], target: any) => boolean; + deepWithout: (obj: any[], target: any) => any[]; + deepUnique: (array: any[]) => any[]; + deepDiff: (object: any, other: any) => string[]; + uniqueId: (prefix?: string) => string; + result: (object: any, key: string) => any; + chain: (value: any) => any; + iteratee: (func?: Function, thisArg?: any) => Function; + unescape: (str?: string) => string; + bind: (func: Function, thisArg: any, ...partials: any) => Function; + once: (func: Function) => Function; + partial: (func: Function, ...partials: any) => Function; + debounce: (func: Function, wait?: number, options?: any) => Function; + throttle: (func: Function, wait?: number, options?: any) => Function; + delay: (func: Function, wait: number, ...args: any) => number; + defer: (func: Function, ...args: any) => number; + wrap: (value: any, wrapper: Function) => Function; + nextTick: (func: Function) => Promise; + random: (min?: number, max?: number, floating?: boolean) => number; + parseInt: (s: string | number) => number; + parseSafeInt: (s: string) => number; + parseFloat: (string: string) => number; + isNaturalNumber: (value: string | number) => boolean; + isPositiveInteger: (value: string | number) => boolean; + isNegativeInteger: (value: string | number) => boolean; + isInteger: (value: string | number) => boolean; + isNumeric: (value: string | number) => boolean; + isFloat: (value: string | number) => boolean; + isOdd: (value: string | number) => boolean; + isEven: (value: string | number) => boolean; + sum: (array: any[], iteratee: Function, context: any) => number; + average: (array: any[], iteratee: Function, context: any) => number; + trim: (string?: string, chars?: string) => string; + toUpperCase: (string: string) => string; + toLowerCase: (string: string) => string; + isEndWithBlank: (string: string) => boolean; + isLiteral: (string: string) => boolean; + stripQuotes: (string: string) => string; + camelize: (string: string) => string; + hyphenate: (string: string) => string; + isNotEmptyString: (string: string) => boolean; + isEmptyString: (str: any) => str is ""; + encrypt: (type: string, text: string, key: string) => string; + escape: (string: string) => string; + leftPad: (val: string, size: number, ch: string) => string; + format: (format: string, ...str: string[]) => string; + isLeapYear: (year: number) => boolean; + checkDateVoid: (YY: string | number, MM: string | number, DD: string | number, minDate: string, maxDate: string) => (number | string)[]; + checkDateLegal: (str: string) => boolean; + parseDateTime: (str: string, fmt: string) => Date; + getDate: (...args: (number | string)[]) => Date; + getTime: (...args: any[]) => number; +} diff --git a/dist/lib/core/behavior/behavior.d.ts b/dist/lib/core/behavior/behavior.d.ts new file mode 100644 index 000000000..e016a8fd5 --- /dev/null +++ b/dist/lib/core/behavior/behavior.d.ts @@ -0,0 +1,7 @@ +import { _OB } from "../ob"; +export interface _Behavior extends _OB { + doBehavior(items: any[]): void; +} +export interface _BehaviorFactory { + createBehavior(key: string, options: any): _Behavior; +} diff --git a/dist/lib/core/behavior/behavior.highlight.d.ts b/dist/lib/core/behavior/behavior.highlight.d.ts new file mode 100644 index 000000000..9baa08bc7 --- /dev/null +++ b/dist/lib/core/behavior/behavior.highlight.d.ts @@ -0,0 +1,3 @@ +import { _Behavior } from "./behavior"; +export interface _HighlightBehavior extends _Behavior { +} diff --git a/dist/lib/core/behavior/behavior.redmark.d.ts b/dist/lib/core/behavior/behavior.redmark.d.ts new file mode 100644 index 000000000..a7814ee6d --- /dev/null +++ b/dist/lib/core/behavior/behavior.redmark.d.ts @@ -0,0 +1,3 @@ +import { _Behavior } from "./behavior"; +export interface _RedMarkBehavior extends _Behavior { +} diff --git a/dist/lib/core/decorator/decorator.d.ts b/dist/lib/core/decorator/decorator.d.ts new file mode 100644 index 000000000..e754c0bdb --- /dev/null +++ b/dist/lib/core/decorator/decorator.d.ts @@ -0,0 +1,64 @@ +export declare type Constructor = new (...args: any[]) => T; +/** + * 注册widget + */ +export declare function shortcut(): (Target: Constructor & { + xtype: string; +}) => void; +/** + * 注册model + */ +export declare function model(): {}) & { + xtype: string; + context?: readonly string[] | undefined; +}>(Target: U) => void; +/** + * 类注册_store属性 + * @param Model model类 + * @param opts 额外条件 + */ +export declare function store(Model: Constructor & { + xtype: string; +}, opts?: { + props?(this: unknown): { + [key: string]: unknown; + }; +}): {}>(constructor: U) => { + new (...args: any[]): { + _store(): any; + }; +} & U; +/** + * Model基类 + */ +export declare class Model; +} = {}> extends Fix.Model { + model: Pick<{ + [key in keyof U["types"]]: U["types"][key]; + }, U["context"][number]> & { + [key in keyof ReturnType]: ReturnType[key]; + } & { + [key in keyof this["computed"]]: ReturnType; + }; + store: this["actions"]; + state(): { + [key: string]: unknown; + } | {}; + context: U["context"]; + actions: { + [key: string]: (...args: any[]) => any; + }; + childContext: ReadonlyArray)>; + TYPE: Pick<{ + [key in keyof this["computed"]]: ReturnType; + } & { + [key in keyof ReturnType]: ReturnType[key]; + }, this["childContext"][number]>; + computed: { + [key: string]: () => unknown; + } | {}; +} diff --git a/dist/lib/core/func/array.d.ts b/dist/lib/core/func/array.d.ts new file mode 100644 index 000000000..7cefccc88 --- /dev/null +++ b/dist/lib/core/func/array.d.ts @@ -0,0 +1,9 @@ +export declare type _pushArray = (sArray: any[], array: any[]) => void; +export declare type _pushDistinct = (sArray: any[], obj: any) => void; +export declare type _pushDistinctArray = (sArray: any[], array: any[]) => void; +declare type _array = { + pushArray: _pushArray; + pushDistinct: _pushDistinct; + pushDistinctArray: _pushDistinctArray; +}; +export default _array; diff --git a/dist/lib/core/func/date.d.ts b/dist/lib/core/func/date.d.ts new file mode 100644 index 000000000..456d4600b --- /dev/null +++ b/dist/lib/core/func/date.d.ts @@ -0,0 +1,92 @@ +export declare type _Date = { + SECOND: number; + MINUTE: number; + HOUR: number; + DAY: number; + WEEK: number; + _DN: string[]; + _SDN: string[]; + _FD: number; + _MN: string[]; + _SMN: number[]; + _QN: string[]; + _MD: number[]; + _OFFSET: number[]; +}; +/** + * 获取时区 + */ +export declare type _getTimezone = (date: Date) => string; +/** + * 获取指定月共有多少天 + */ +export declare type _getMonthDays = (date: Date, month: number) => string; +/** + * 获取指定月的最后一天 + */ +export declare type _getLastDateOfMonth = (data: Date) => Date; +/** + * 获取指定时间距离当年已经过了多少天 + */ +export declare type _getDayOfYear = (data: Date) => number; +/** + * 获取指定时间距离当年已经过了多少周 + */ +export declare type _getWeekNumber = (data: Date) => number; +/** + * 获取指定时间的所处季度 + */ +export declare type _getQuarter = (date: Date) => number; +/** + * 离当前时间多少天的时间 + */ +export declare type _getOffsetDate = (date: Date, offset: number) => Date; +/** + * 离当前时间多少天季度的时间 + */ +export declare type _getOffsetQuarter = (date: Date, n: number) => Date; +/** + * 得到本季度的起始月份 + */ +export declare type _getQuarterStartMonth = (date: Date) => number; +/** + * 获得本季度的起始日期 + */ +export declare type _getQuarterStartDate = (date: Date) => number; +/** + * 获取本季度的其实日期 + */ +export declare type _getQuarterEndDate = (date: Date) => number; +/** + * 指定日期n个月之前或之后的日期 + */ +export declare type _getOffsetMonth = (date: Date, n: number) => Date; +/** + * 获取本周的起始日期 + */ +export declare type _getWeekStartDate = (date: Date) => Date; +/** + * 获取本周的结束日期 + */ +export declare type _getWeekEndDate = (date: Date) => Date; +/** + * 格式化打印日期 + */ +export declare type _print = (date: Date, str: string) => string; +export declare type _date = { + getTimezone: _getTimezone; + getMonthDays: _getMonthDays; + getLastDateOfMonth: _getLastDateOfMonth; + getDayOfYear: _getDayOfYear; + getWeekNumber: _getWeekNumber; + getQuarter: _getQuarter; + getOffsetDate: _getOffsetDate; + getOffsetQuarter: _getOffsetQuarter; + getQuarterStartMonth: _getQuarterStartMonth; + getQuarterStartDate: _getQuarterStartDate; + getQuarterEndDate: _getQuarterEndDate; + getOffsetMonth: _getOffsetMonth; + getWeekStartDate: _getWeekStartDate; + getWeekEndDate: _getWeekEndDate; + print: _print; +}; diff --git a/dist/lib/core/func/function.d.ts b/dist/lib/core/func/function.d.ts new file mode 100644 index 000000000..17f38f855 --- /dev/null +++ b/dist/lib/core/func/function.d.ts @@ -0,0 +1,36 @@ +/** + * 创建唯一的名字 + * @param array 已有的名字集合 + * @param name 待生成的名字 + * @return 生成后的名字 + */ +export declare type _createDistinctName = (array: any[], name: string) => string; +/** + * 获取搜索结果 + * @param items 待搜索的数据 + * @param keyword 关键字 + * @param param 搜索哪个属性 + */ +export declare type _getSearchResult = (items: any, keyword: any, param: string) => { + find: any; + match: any; +}; +/** + * 在方法A执行之前执行方法B + * @param sFunc 方法A + * @param func 方法B + */ +export declare type _beforeFunc = (sFunc: Function, func: Function) => Function; +/** + * 在方法A执行之后执行方法B + * @param sFunc 方法A + * @param func 方法B + */ +export declare type _afterFunc = (sFunc: Function, func: Function) => Function; +declare type _function = { + createDistinctName: _createDistinctName; + getSearchResult: _getSearchResult; + beforeFunc: _beforeFunc; + afterFunc: _afterFunc; +}; +export default _function; diff --git a/dist/lib/core/func/index.d.ts b/dist/lib/core/func/index.d.ts new file mode 100644 index 000000000..4e7a8d168 --- /dev/null +++ b/dist/lib/core/func/index.d.ts @@ -0,0 +1,8 @@ +import _array from "./array"; +import _string from "./string"; +import _number from "./number"; +import _function from "./function"; +import { _Date } from "./date"; +export interface _func extends _array, _string, _number, _function { + Date: _Date; +} diff --git a/dist/lib/core/func/number.d.ts b/dist/lib/core/func/number.d.ts new file mode 100644 index 000000000..d64d58514 --- /dev/null +++ b/dist/lib/core/func/number.d.ts @@ -0,0 +1,35 @@ +/** + * 加法函数,用来得到精确的加法结果 + * @param {Number} num 被加数 + * @param {Number} arg 加数 + * @return {Number} 两个数字相加后的结果 + */ +export declare type _add = (num: number, arg: number) => number; +/** + * 减法函数,用来得到精确的减法结果 + * @param {Number} num 被减数 + * @param {Number} arg 减数 + * @return {Number} 两个数字相减后的结果 + */ +export declare type _sub = (num: number, arg: number) => number; +/** + * 乘法函数,用来得到精确的乘法结果 + * @param {Number} num 被乘数 + * @param {Number} arg 乘数 + * @return {Number} 两个数字相乘后的结果 + */ +export declare type _mul = (num: number, arg: number) => number; +/** + * 除法函数,用来得到精确的除法结果 + * @param {Number} num 被除数 + * @param {Number} arg 除数 + * @return {Number} 两个数字相除后的结果 + */ +export declare type _div = (num: number, arg: number) => number; +declare type _number = { + add: _add; + sub: _sub; + mul: _mul; + div: _div; +}; +export default _number; diff --git a/dist/lib/core/func/string.d.ts b/dist/lib/core/func/string.d.ts new file mode 100644 index 000000000..6249d2d56 --- /dev/null +++ b/dist/lib/core/func/string.d.ts @@ -0,0 +1,62 @@ +/** + * 判断字符串是否已指定的字符串开始 + * @param str source字符串 + * @param {String} startTag 指定的开始字符串 + * @return {Boolean} 如果字符串以指定字符串开始则返回true,否则返回false + */ +export declare type _startWith = (str: string, startTag: string) => boolean; +/** + * 判断字符串是否以指定的字符串结束 + * @param str source字符串 + * @param {String} endTag 指定的字符串 + * @return {Boolean} 如果字符串以指定字符串结束则返回true,否则返回false + */ +export declare type _endWith = (str: string, endTag: string) => boolean; +/** + * 获取url中指定名字的参数 + * @param str source字符串 + * @param {String} name 参数的名字 + * @return {String} 参数的值 + */ +export declare type _getQuery = (str: string, name: string) => string | null; +/** + * 给url加上给定的参数 + * @param str source字符串 + * @param {Object} paras 参数对象,是一个键值对对象 + * @return {String} 添加了给定参数的url + */ +export declare type _appendQuery = (str: string, paras: { + [key: string]: string | number; +}) => string; +/** + * 将所有符合第一个字符串所表示的字符串替换成为第二个字符串 + * @param str source字符串 + * @param {String} s1 要替换的字符串的正则表达式 + * @param {String} s2 替换的结果字符串 + * @returns {String} 替换后的字符串 + */ +export declare type _replaceAll = (str: string, s1: string, s2: string) => string; +/** + * 总是让字符串以指定的字符开头 + * @param str source字符串 + * @param {String} start 指定的字符 + * @returns {String} 以指定字符开头的字符串 + */ +export declare type _perfectStart = (str: string, start: string) => string; +/** + * 获取字符串中某字符串的所有项位置数组 + * @param str source字符串 + * @param {String} sub 子字符串 + * @return {Number[]} 子字符串在父字符串中出现的所有位置组成的数组 + */ +export declare type _allIndexOf = (str: string, sub: string) => number[]; +declare type _string = { + startWith: _startWith; + endWith: _endWith; + getQuery: _getQuery; + appendQuery: _appendQuery; + replaceAll: _replaceAll; + perfectStart: _perfectStart; + allIndexOf: _allIndexOf; +}; +export default _string; diff --git a/dist/lib/core/i18n.d.ts b/dist/lib/core/i18n.d.ts new file mode 100644 index 000000000..348a3c110 --- /dev/null +++ b/dist/lib/core/i18n.d.ts @@ -0,0 +1,6 @@ +export declare type _addI18n = (v: string | object) => string; +export declare type _i18nText = (key: string, ..._args: any[]) => string; +export declare type _i18n = { + addI18n: _addI18n; + i18nText: _i18nText; +}; diff --git a/dist/lib/core/ob.d.ts b/dist/lib/core/ob.d.ts new file mode 100644 index 000000000..8558913e6 --- /dev/null +++ b/dist/lib/core/ob.d.ts @@ -0,0 +1,35 @@ +export interface _OB { + props: Props | ((config: T) => Props & T); + options: this["props"]; + events?: { + [eventName: string]: Function[]; + }; + init?(): void; + destroyed?(): void; + _defaultConfig(..._args: any[]): { + [key: string]: any; + } | {}; + _init(): void; + _initListeners(): void; + _getEvents(): { + [eventName: string]: Function[]; + }; + on(eventName: string, fn: Function): void; + once(eventName: string, fn: Function): void; + un(eName: string, fn: Function): void; + _initRef(): void; + _purgeRef(): void; + purgeListeners(): void; + fireEvent(eName: string, ...args: any[]): boolean | null; + destroy(): void; +} +interface Props { + listeners?: { + eventName: string; + action: (...args: any[]) => any; + target?: _OB; + once?: boolean; + }[]; + [key: string]: any; +} +export {}; diff --git a/dist/lib/core/widget.d.ts b/dist/lib/core/widget.d.ts new file mode 100644 index 000000000..e369dfcca --- /dev/null +++ b/dist/lib/core/widget.d.ts @@ -0,0 +1,323 @@ +import { _OB } from "./ob"; +export interface _WidgetStatic { + /** + * 注册渲染引擎 + * @param engine 引擎 + */ + registerRenderEngine(engine: RenderEngine): void; +} +export interface _Widget extends _OB { + /** + * 出现loading的锁 + */ + __asking: boolean; + /** + * 同步锁 + */ + __async: boolean; + /** + * widget类标识符 + */ + widgetName: string | null; + /** + * 是否为根节点 + */ + _isRoot: boolean; + /** + * 父节点 + */ + _parent: _Widget | null; + /** + * 真实dom的类jQuery对象 + */ + element: any; + /** + * 子元素 + */ + _children: { + [key: string]: _Widget; + }; + /** + * 是否已挂载 + */ + _isMounted: boolean; + /** + * 手动设置enable + */ + _manualSetEnable: boolean; + /** + * 手动设置valid + */ + _manualSetValid: boolean; + /** + * 渲染引擎 + */ + _renderEngine: RenderEngine; + _store(): void; + /** + * 初始化前 + */ + beforeInit?(cb: Function): void; + /** + * 创建前 + */ + beforeCreate?(): void; + /** + * 创建 + */ + created?(): void; + /** + * 渲染 + */ + render?(): any; + /** + * 挂载前 + */ + beforeMount?(): void; + /** + * 挂载 + */ + mounted?(): void; + /** + * 更新前 + */ + shouldUpdate?(): void; + /** + * 更新 + */ + update?(...args: any[]): void; + /** + * 销毁前 + */ + beforeDestroy?(): void; + /** + * 销毁 + */ + destroyed?(): void; + /** + * 初始化render函数 + */ + _initRender: () => void; + /** + * 内部主render函数 + */ + _render: () => void; + /** + * 初始化根节点 + */ + _initRoot: () => void; + /** + * 初始化元素宽度 + */ + _initElementWidth: () => void; + /** + * 初始化元素高度 + */ + _initElementHeight: () => void; + /** + * 初始化元素可见 + */ + _initVisual: () => void; + /** + * 初始化元素可用不可用 + */ + _initEffects: () => void; + /** + * 设置mounted锁 + */ + _initState: () => void; + /** + * 生成真实dom + */ + _initElement: () => void; + /** + * 设置父节点 + */ + _setParent: () => void; + /** + * @param force 是否强制挂载子节点 + * @param deep 子节点是否也是按照当前force处理 + * @param lifeHook 生命周期钩子触不触发,默认触发 + * @param predicate 递归每个widget的回调 + */ + _mount(force?: boolean, deep?: boolean, lifeHook?: boolean, predicate?: Function): boolean; + /** + * 挂载子节点 + */ + _mountChildren?(): void; + /** + * 是否已挂载 + */ + isMounted(): boolean; + /** + * 设置宽度 + */ + setWidth(w: number): void; + /** + * 设置高度 + */ + setHeight(h: number): void; + /** + * 设置可用 + */ + _setEnable(enable: boolean): void; + /** + * 设置合法 + */ + _setValid(valid: boolean): void; + /** + * 设置可见 + */ + _setVisible(visible: boolean): void; + /** + * 设置是否可用 + */ + setEnable(enable: boolean): void; + /** + * 设置是否可见 + */ + setVisible(visible: boolean): void; + /** + * 设置是否合法 + */ + setValid(valid: boolean): void; + /** + * 设置反馈效果 + * @param args arguments参数 + */ + doBehavior(...args: any[]): void; + /** + * 获取宽度 + */ + getWidth(): number; + /** + * 获取高度 + */ + getHeight(): number; + /** + * 是否合法 + */ + isValid(): boolean; + /** + * 新增子元素 + */ + addWidget(_name: any, _widget: _Widget): _Widget; + /** + * 根据wigetname获取子元素实例 + */ + getWidgetByName(_name: string): _Widget | undefined; + /** + * 移除子元素 + * @param nameOrWidget widgetName或widget实例 + */ + removeWidget(nameOrWidget: string | _Widget): void; + /** + * 是否有某个子元素 + */ + hasWidget(name: string): boolean; + /** + * 获取widgetName + */ + getName(): string; + /** + * 设置tag + * @param tag html tag + */ + setTag(tag: string): void; + /** + * 获取tag + */ + getTag(): string; + /** + * 设置属性 + * @param key 键 + * @param value 值 + */ + attr(key: string | { + [key: string]: any; + }, value?: any): any; + /** + * 获取text + */ + getText(): string; + /** + * 设置text + */ + setText(text: string): void; + /** + * 获取值 + */ + getValue(): any; + /** + * 设置值 + */ + setValue(...args: any[]): void; + /** + * 获取是否enable + */ + isEnabled(): boolean; + /** + * 是否可见 + */ + isVisible(): boolean; + /** + * disable元素 + */ + disable(): void; + /** + * enable元素 + */ + enable(): void; + /** + * 是widget合法 + */ + valid(): void; + /** + * 使元素不合法 + */ + invalid(): void; + /** + * 使不可见 + */ + invisible(..._args: any[]): void; + /** + * 可见 + */ + visible(..._args: any[]): void; + /** + * 清除子元素 + */ + __d(): void; + /** + * 取消挂载 + */ + _unMount(): void; + /** + * hang元素 + */ + isolate(): void; + /** + * 请除元素 + */ + empty(): void; + /** + * 内部destory方法 + */ + _destroy(): void; + /** + * destory元素 + */ + destroy(): void; +} +interface RenderEngine { + /** + * 创建元素方法,返回的类jQuery对象 + * @param widget widget对象 + */ + createElement: (widget: any) => any; + /** + * 创建DocumentFragment对象 + */ + createFragment: () => DocumentFragment; +} +export {}; diff --git a/dist/lib/index.d.ts b/dist/lib/index.d.ts new file mode 100644 index 000000000..e1a8f878d --- /dev/null +++ b/dist/lib/index.d.ts @@ -0,0 +1,42 @@ +import * as decorator from "./core/decorator/decorator"; +import { _i18n } from "./core/i18n"; +import { _OB } from "./core/ob"; +import { _func } from "./core/func"; +import { _Widget, _WidgetStatic } from "./core/widget"; +import { _Single } from "./base/single/single"; +import { _base } from "./core/base"; +import { _BasicButton } from "./base/single/button/button.basic"; +import { _Trigger } from "./base/single/trigger/trigger"; +import { _Action, _ActionFactory } from "./core/action/action"; +import { _ShowAction } from "./core/action/action.show"; +import { _Behavior, _BehaviorFactory } from "./core/behavior/behavior"; +import { _HighlightBehavior } from "./core/behavior/behavior.highlight"; +import { _RedMarkBehavior } from "./core/behavior/behavior.redmark"; +import { _Pane, _PaneStatic } from "./base/pane"; +import { _LoadingPane } from "./case/loading/loading_pane"; +declare type ClassConstructor = T & { + new (config: any): T; + (config: any): T; + readonly prototype: T; +}; +export interface BI extends _func, _i18n, _base { + OB: ClassConstructor<_OB>; + Widget: ClassConstructor<_Widget> & _WidgetStatic; + Single: ClassConstructor<_Single>; + BasicButton: ClassConstructor<_BasicButton>; + Trigger: ClassConstructor<_Trigger>; + Action: ClassConstructor<_Action>; + ActionFactory: ClassConstructor<_ActionFactory>; + ShowAction: ClassConstructor<_ShowAction>; + Behavior: ClassConstructor<_Behavior>; + BehaviorFactory: ClassConstructor<_BehaviorFactory>; + HighlightBehavior: ClassConstructor<_HighlightBehavior>; + RedMarkBehavior: ClassConstructor<_RedMarkBehavior>; + Pane: ClassConstructor<_Pane> & _PaneStatic; + LoadingPane: ClassConstructor<_LoadingPane>; + Decorators: typeof decorator; +} +declare const _default: { + Decorators: typeof decorator; +}; +export default _default;