amis-core 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Root.js +94 -0
- package/dist/RootRenderer.js +288 -0
- package/dist/SchemaRenderer.js +323 -0
- package/dist/Scoped.js +252 -0
- package/dist/WithRootStore.js +44 -0
- package/dist/WithStore.js +179 -0
- package/dist/__tests__/compat.test.d.ts +1 -0
- package/dist/__tests__/factory.test.d.ts +1 -0
- package/dist/__tests__/filter.test.d.ts +1 -0
- package/dist/__tests__/helper.d.ts +13 -0
- package/dist/__tests__/tokenize.test.d.ts +1 -0
- package/dist/actions/Action.js +119 -0
- package/dist/actions/AjaxAction.js +96 -0
- package/dist/actions/BreakAction.js +35 -0
- package/dist/actions/BroadcastAction.js +49 -0
- package/dist/actions/CmptAction.js +60 -0
- package/dist/actions/ContinueAction.js +35 -0
- package/dist/actions/CopyAction.js +43 -0
- package/dist/actions/CustomAction.js +49 -0
- package/dist/actions/DialogAction.js +104 -0
- package/dist/actions/DrawerAction.js +66 -0
- package/dist/actions/EmailAction.js +48 -0
- package/dist/actions/LinkAction.js +52 -0
- package/dist/actions/LoopAction.js +107 -0
- package/dist/actions/PageAction.js +80 -0
- package/dist/actions/ParallelAction.js +40 -0
- package/dist/actions/SwitchAction.js +52 -0
- package/dist/actions/ToastAction.js +35 -0
- package/dist/components/LazyComponent.js +99 -0
- package/dist/env.js +20 -0
- package/dist/envOverwrite.js +43 -0
- package/dist/factory.js +308 -0
- package/dist/index.js +218 -0
- package/dist/index2.js +255 -0
- package/dist/locale.js +114 -0
- package/dist/renderers/Form.js +1162 -0
- package/dist/renderers/Item.js +636 -0
- package/dist/renderers/Options.js +881 -0
- package/dist/renderers/Placeholder.js +31 -0
- package/dist/renderers/builtin.js +27 -0
- package/dist/renderers/wrapControl.js +507 -0
- package/dist/src/Root.d.ts +37 -0
- package/dist/src/RootRenderer.d.ts +27 -0
- package/dist/src/SchemaRenderer.d.ts +37 -0
- package/dist/src/Scoped.d.ts +38 -0
- package/dist/src/WithRootStore.d.ts +737 -0
- package/dist/src/WithStore.d.ts +5 -0
- package/dist/src/actions/Action.d.ts +38 -0
- package/dist/src/actions/AjaxAction.d.ts +25 -0
- package/dist/src/actions/BreakAction.d.ts +15 -0
- package/dist/src/actions/BroadcastAction.d.ts +16 -0
- package/dist/src/actions/CmptAction.d.ts +20 -0
- package/dist/src/actions/ContinueAction.d.ts +15 -0
- package/dist/src/actions/CopyAction.d.ts +20 -0
- package/dist/src/actions/CustomAction.d.ts +17 -0
- package/dist/src/actions/Decorators.d.ts +25 -0
- package/dist/src/actions/DialogAction.d.ts +57 -0
- package/dist/src/actions/DrawerAction.d.ts +30 -0
- package/dist/src/actions/EmailAction.d.ts +23 -0
- package/dist/src/actions/LinkAction.d.ts +24 -0
- package/dist/src/actions/LoopAction.d.ts +19 -0
- package/dist/src/actions/PageAction.d.ts +39 -0
- package/dist/src/actions/ParallelAction.d.ts +8 -0
- package/dist/src/actions/SwitchAction.d.ts +11 -0
- package/dist/src/actions/ToastAction.d.ts +19 -0
- package/dist/src/actions/index.d.ts +21 -0
- package/dist/src/components/LazyComponent.d.ts +32 -0
- package/dist/src/env.d.ts +172 -0
- package/dist/src/envOverwrite.d.ts +4 -0
- package/dist/src/factory.d.ts +78 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/src/locale.d.ts +82 -0
- package/dist/src/renderers/Form.d.ts +352 -0
- package/dist/src/renderers/Item.d.ts +795 -0
- package/dist/src/renderers/Options.d.ts +150 -0
- package/dist/src/renderers/Placeholder.d.ts +6 -0
- package/dist/src/renderers/builtin.d.ts +1 -0
- package/dist/src/renderers/wrapControl.d.ts +446 -0
- package/dist/src/schema.d.ts +369 -0
- package/dist/src/store/app.d.ts +89 -0
- package/dist/src/store/combo.d.ts +8504 -0
- package/dist/src/store/crud.d.ts +124 -0
- package/dist/src/store/form.d.ts +3394 -0
- package/dist/src/store/formItem.d.ts +130 -0
- package/dist/src/store/iRenderer.d.ts +46 -0
- package/dist/src/store/index.d.ts +105 -0
- package/dist/src/store/list.d.ts +270 -0
- package/dist/src/store/manager.d.ts +115 -0
- package/dist/src/store/modal.d.ts +84 -0
- package/dist/src/store/node.d.ts +22 -0
- package/dist/src/store/pagination.d.ts +58 -0
- package/dist/src/store/root.d.ts +79 -0
- package/dist/src/store/service.d.ts +71 -0
- package/dist/src/store/table-v2.d.ts +309 -0
- package/dist/src/store/table.d.ts +8334 -0
- package/dist/src/theme.d.ts +83 -0
- package/dist/src/types.d.ts +217 -0
- package/dist/src/utils/Animation.d.ts +22 -0
- package/dist/src/utils/ColorScale.d.ts +19 -0
- package/dist/src/utils/DataSchema.d.ts +25 -0
- package/dist/src/utils/DataScope.d.ts +23 -0
- package/dist/src/utils/RootClose.d.ts +4 -0
- package/dist/src/utils/SimpleMap.d.ts +8 -0
- package/dist/src/utils/api.d.ts +27 -0
- package/dist/src/utils/attachmentAdpator.d.ts +7 -0
- package/dist/src/utils/autobind.d.ts +7 -0
- package/dist/src/utils/columnsSplit.d.ts +1 -0
- package/dist/src/utils/dataMapping.d.ts +3 -0
- package/dist/src/utils/date.d.ts +4 -0
- package/dist/src/utils/debug.d.ts +26 -0
- package/dist/src/utils/dom.d.ts +13 -0
- package/dist/src/utils/errors.d.ts +6 -0
- package/dist/src/utils/escapeHtml.d.ts +1 -0
- package/dist/src/utils/filter-schema.d.ts +12 -0
- package/dist/src/utils/filter.d.ts +1 -0
- package/dist/src/utils/formatDuration.d.ts +1 -0
- package/dist/src/utils/formula.d.ts +16 -0
- package/dist/src/utils/getVariable.d.ts +3 -0
- package/dist/src/utils/grammar.d.ts +4 -0
- package/dist/src/utils/handleAction.d.ts +6 -0
- package/dist/src/utils/helper.d.ts +286 -0
- package/dist/src/utils/icon.d.ts +12 -0
- package/dist/src/utils/image.d.ts +17 -0
- package/dist/src/utils/index.d.ts +12 -0
- package/dist/src/utils/isPureVariable.d.ts +1 -0
- package/dist/src/utils/json-schema-2-amis-schema.d.ts +6 -0
- package/dist/src/utils/keyToPath.d.ts +6 -0
- package/dist/src/utils/makeSorter.d.ts +1 -0
- package/dist/src/utils/markdown.d.ts +5 -0
- package/dist/src/utils/normalizeLink.d.ts +1 -0
- package/dist/src/utils/normalizeOptions.d.ts +7 -0
- package/dist/src/utils/object.d.ts +15 -0
- package/dist/src/utils/offset.d.ts +14 -0
- package/dist/src/utils/offsetParent.d.ts +4 -0
- package/dist/src/utils/optionValueCompare.d.ts +3 -0
- package/dist/src/utils/position.d.ts +15 -0
- package/dist/src/utils/prettyBytes.d.ts +1 -0
- package/dist/src/utils/renderer-event.d.ts +44 -0
- package/dist/src/utils/replaceText.d.ts +6 -0
- package/dist/src/utils/resize-sensor.d.ts +6 -0
- package/dist/src/utils/resolveVariable.d.ts +1 -0
- package/dist/src/utils/resolveVariableAndFilter.d.ts +1 -0
- package/dist/src/utils/scrollPosition.d.ts +6 -0
- package/dist/src/utils/string2regExp.d.ts +1 -0
- package/dist/src/utils/stripNumber.d.ts +1 -0
- package/dist/src/utils/style.d.ts +10 -0
- package/dist/src/utils/tokenize.d.ts +1 -0
- package/dist/src/utils/tpl-builtin.d.ts +18 -0
- package/dist/src/utils/tpl-lodash.d.ts +4 -0
- package/dist/src/utils/tpl.d.ts +11 -0
- package/dist/src/utils/validations.d.ts +39 -0
- package/dist/store/app.js +190 -0
- package/dist/store/combo.js +154 -0
- package/dist/store/crud.js +413 -0
- package/dist/store/form.js +579 -0
- package/dist/store/formItem.js +846 -0
- package/dist/store/iRenderer.js +189 -0
- package/dist/store/index.js +103 -0
- package/dist/store/list.js +248 -0
- package/dist/store/manager.js +56 -0
- package/dist/store/modal.js +54 -0
- package/dist/store/node.js +93 -0
- package/dist/store/pagination.js +60 -0
- package/dist/store/root.js +45 -0
- package/dist/store/service.js +415 -0
- package/dist/store/table-v2.js +471 -0
- package/dist/store/table.js +1105 -0
- package/dist/theme.js +93 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/Animation.js +290 -0
- package/dist/utils/DataSchema.js +120 -0
- package/dist/utils/DataScope.js +151 -0
- package/dist/utils/SimpleMap.js +46 -0
- package/dist/utils/api.js +555 -0
- package/dist/utils/autobind.js +94 -0
- package/dist/utils/dataMapping.js +136 -0
- package/dist/utils/date.js +90 -0
- package/dist/utils/debug.js +343 -0
- package/dist/utils/errors.js +23 -0
- package/dist/utils/escapeHtml.js +24 -0
- package/dist/utils/filter-schema.js +75 -0
- package/dist/utils/filter.js +481 -0
- package/dist/utils/formatDuration.js +27 -0
- package/dist/utils/formula.js +165 -0
- package/dist/utils/getVariable.js +29 -0
- package/dist/utils/grammar.js +54 -0
- package/dist/utils/helper.js +1283 -0
- package/dist/utils/isPureVariable.js +16 -0
- package/dist/utils/keyToPath.js +34 -0
- package/dist/utils/makeSorter.js +30 -0
- package/dist/utils/normalizeLink.js +47 -0
- package/dist/utils/normalizeOptions.js +92 -0
- package/dist/utils/object.js +156 -0
- package/dist/utils/offset.js +36 -0
- package/dist/utils/offsetParent.js +27 -0
- package/dist/utils/optionValueCompare.js +25 -0
- package/dist/utils/position.js +50 -0
- package/dist/utils/prettyBytes.js +28 -0
- package/dist/utils/renderer-event.js +131 -0
- package/dist/utils/replaceText.js +35 -0
- package/dist/utils/resize-sensor.js +177 -0
- package/dist/utils/resolveVariable.js +39 -0
- package/dist/utils/resolveVariableAndFilter.js +37 -0
- package/dist/utils/string2regExp.js +18 -0
- package/dist/utils/stripNumber.js +20 -0
- package/dist/utils/tokenize.js +33 -0
- package/dist/utils/tpl-builtin.js +71 -0
- package/dist/utils/tpl-lodash.js +71 -0
- package/dist/utils/tpl.js +140 -0
- package/dist/utils/validations.js +377 -0
- package/package.json +121 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Schema, PlainObject, FunctionPropertyNames } from '../types';
|
|
3
|
+
import qs from 'qs';
|
|
4
|
+
import { IIRendererStore } from '../store';
|
|
5
|
+
import { autobindMethod } from './autobind';
|
|
6
|
+
import { cloneObject, createObject, deleteVariable, extendObject, isObject, setVariable } from './object';
|
|
7
|
+
import { string2regExp } from './string2regExp';
|
|
8
|
+
import { getVariable } from './getVariable';
|
|
9
|
+
import { keyToPath } from './keyToPath';
|
|
10
|
+
export { createObject, cloneObject, isObject, string2regExp, getVariable, setVariable, deleteVariable, keyToPath, extendObject };
|
|
11
|
+
export declare function preventDefault(event: TouchEvent | Event): void;
|
|
12
|
+
export declare function isMobile(): any;
|
|
13
|
+
export declare function range(num: number, min: number, max: number): number;
|
|
14
|
+
/**
|
|
15
|
+
* 给目标对象添加其他属性,可读取但是不会被遍历。
|
|
16
|
+
* @param target
|
|
17
|
+
* @param props
|
|
18
|
+
*/
|
|
19
|
+
export declare function injectPropsToObject(target: any, props: any): any;
|
|
20
|
+
export declare function isSuperDataModified(data: any, prevData: any, store: IIRendererStore): boolean;
|
|
21
|
+
export declare function syncDataFromSuper(data: any, superObject: any, prevSuperObject: any, store: IIRendererStore, force: boolean): any;
|
|
22
|
+
/**
|
|
23
|
+
* 生成 8 位随机数字。
|
|
24
|
+
*
|
|
25
|
+
* @return {string} 8位随机数字
|
|
26
|
+
*/
|
|
27
|
+
export declare function guid(): string;
|
|
28
|
+
export declare function findIndex(arr: Array<any>, detect: (item?: any, index?: number) => boolean): number;
|
|
29
|
+
export declare function hasOwnProperty(data: {
|
|
30
|
+
[propName: string]: any;
|
|
31
|
+
}, key: string): boolean;
|
|
32
|
+
export declare function noop(): void;
|
|
33
|
+
export declare function anyChanged(attrs: string | Array<string>, from: {
|
|
34
|
+
[propName: string]: any;
|
|
35
|
+
}, to: {
|
|
36
|
+
[propName: string]: any;
|
|
37
|
+
}, strictMode?: boolean): boolean;
|
|
38
|
+
export declare function rmUndefined(obj: PlainObject): PlainObject;
|
|
39
|
+
export declare function isObjectShallowModified(prev: any, next: any, strictMode?: boolean, ignoreUndefined?: boolean, statck?: Array<any>): boolean;
|
|
40
|
+
export declare function isArrayChildrenModified(prev: Array<any>, next: Array<any>, strictMode?: boolean): boolean;
|
|
41
|
+
export declare function immutableExtends(to: any, from: any, deep?: boolean): any;
|
|
42
|
+
export declare function makeColumnClassBuild(steps: number, classNameTpl?: string): (schema: Schema) => any;
|
|
43
|
+
export declare function hasVisibleExpression(schema: {
|
|
44
|
+
visibleOn?: string;
|
|
45
|
+
hiddenOn?: string;
|
|
46
|
+
visible?: boolean;
|
|
47
|
+
hidden?: boolean;
|
|
48
|
+
}): string | undefined;
|
|
49
|
+
export declare function isVisible(schema: {
|
|
50
|
+
visibleOn?: string;
|
|
51
|
+
hiddenOn?: string;
|
|
52
|
+
visible?: boolean;
|
|
53
|
+
hidden?: boolean;
|
|
54
|
+
}, data?: object): boolean;
|
|
55
|
+
export declare function isUnfolded(node: any, config: {
|
|
56
|
+
foldedField?: string;
|
|
57
|
+
unfoldedField?: string;
|
|
58
|
+
}): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* 过滤掉被隐藏的数组元素
|
|
61
|
+
*/
|
|
62
|
+
export declare function visibilityFilter(items: any, data?: object): any;
|
|
63
|
+
export declare function isDisabled(schema: {
|
|
64
|
+
disabledOn?: string;
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
}, data?: object): boolean | "" | undefined;
|
|
67
|
+
export declare function hasAbility(schema: any, ability: string, data?: object, defaultValue?: boolean): boolean;
|
|
68
|
+
export declare function makeHorizontalDeeper(horizontal: {
|
|
69
|
+
left: string;
|
|
70
|
+
right: string;
|
|
71
|
+
offset: string;
|
|
72
|
+
leftFixed?: any;
|
|
73
|
+
}, count: number): {
|
|
74
|
+
left: string | number;
|
|
75
|
+
right: string | number;
|
|
76
|
+
offset: string | number;
|
|
77
|
+
leftFixed?: any;
|
|
78
|
+
};
|
|
79
|
+
export declare function promisify<T extends Function>(fn: T): (...args: Array<any>) => Promise<any> & {
|
|
80
|
+
raw: T;
|
|
81
|
+
};
|
|
82
|
+
export declare function getScrollParent(node: HTMLElement): HTMLElement | null;
|
|
83
|
+
/**
|
|
84
|
+
* Deep diff between two object, using lodash
|
|
85
|
+
* @param {Object} object Object compared
|
|
86
|
+
* @param {Object} base Object to compare with
|
|
87
|
+
* @return {Object} Return a new object who represent the diff
|
|
88
|
+
*/
|
|
89
|
+
export declare function difference<T extends {
|
|
90
|
+
[propName: string]: any;
|
|
91
|
+
}, U extends {
|
|
92
|
+
[propName: string]: any;
|
|
93
|
+
}>(object: T, base: U, keepProps?: Array<string>): {
|
|
94
|
+
[propName: string]: any;
|
|
95
|
+
};
|
|
96
|
+
export declare const padArr: (arr: Array<any>, size?: number) => Array<Array<any>>;
|
|
97
|
+
export declare function __uri(id: string): string;
|
|
98
|
+
export declare function isBreakpoint(str: string): boolean;
|
|
99
|
+
export declare function until(fn: () => Promise<any>, when: (ret: any) => boolean, getCanceler: (fn: () => any) => void, interval?: number): Promise<unknown>;
|
|
100
|
+
export declare function omitControls(controls: Array<any>, omitItems: Array<string>): Array<any>;
|
|
101
|
+
export declare function isEmpty(thing: any): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* 基于时间戳的 uuid
|
|
104
|
+
*
|
|
105
|
+
* @returns uniqueId
|
|
106
|
+
*/
|
|
107
|
+
export declare const uuid: () => string;
|
|
108
|
+
export declare const uuidv4: () => string;
|
|
109
|
+
export interface TreeItem {
|
|
110
|
+
children?: TreeArray;
|
|
111
|
+
[propName: string]: any;
|
|
112
|
+
}
|
|
113
|
+
export interface TreeArray extends Array<TreeItem> {
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 类似于 arr.map 方法,此方法主要针对类似下面示例的树形结构。
|
|
117
|
+
* [
|
|
118
|
+
* {
|
|
119
|
+
* children: []
|
|
120
|
+
* },
|
|
121
|
+
* // 其他成员
|
|
122
|
+
* ]
|
|
123
|
+
*
|
|
124
|
+
* @param {Tree} tree 树形数据
|
|
125
|
+
* @param {Function} iterator 处理函数,返回的数据会被替换成新的。
|
|
126
|
+
* @return {Tree} 返回处理过的 tree
|
|
127
|
+
*/
|
|
128
|
+
export declare function mapTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>) => T, level?: number, depthFirst?: boolean, paths?: Array<T>): any[];
|
|
129
|
+
/**
|
|
130
|
+
* 遍历树
|
|
131
|
+
* @param tree
|
|
132
|
+
* @param iterator
|
|
133
|
+
*/
|
|
134
|
+
export declare function eachTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number) => any, level?: number): void;
|
|
135
|
+
/**
|
|
136
|
+
* 在树中查找节点。
|
|
137
|
+
* @param tree
|
|
138
|
+
* @param iterator
|
|
139
|
+
*/
|
|
140
|
+
export declare function findTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>) => any): T | null;
|
|
141
|
+
/**
|
|
142
|
+
* 在树中查找节点, 返回下标数组。
|
|
143
|
+
* @param tree
|
|
144
|
+
* @param iterator
|
|
145
|
+
*/
|
|
146
|
+
export declare function findTreeIndex<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>) => any): Array<number> | undefined;
|
|
147
|
+
export declare function getTree<T extends TreeItem>(tree: Array<T>, idx: Array<number> | number): T | undefined | null;
|
|
148
|
+
/**
|
|
149
|
+
* 过滤树节点
|
|
150
|
+
*
|
|
151
|
+
* @param tree
|
|
152
|
+
* @param iterator
|
|
153
|
+
*/
|
|
154
|
+
export declare function filterTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number) => any, level?: number, depthFirst?: boolean): T[];
|
|
155
|
+
/**
|
|
156
|
+
* 判断树中每个节点是否满足某个条件。
|
|
157
|
+
* @param tree
|
|
158
|
+
* @param iterator
|
|
159
|
+
*/
|
|
160
|
+
export declare function everyTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>, indexes: Array<number>) => boolean, level?: number, paths?: Array<T>, indexes?: Array<number>): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* 判断树中是否有某些节点满足某个条件。
|
|
163
|
+
* @param tree
|
|
164
|
+
* @param iterator
|
|
165
|
+
*/
|
|
166
|
+
export declare function someTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>) => boolean): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* 将树打平变成一维数组,可以传入第二个参数实现打平节点中的其他属性。
|
|
169
|
+
*
|
|
170
|
+
* 比如:
|
|
171
|
+
*
|
|
172
|
+
* flattenTree([
|
|
173
|
+
* {
|
|
174
|
+
* id: 1,
|
|
175
|
+
* children: [
|
|
176
|
+
* { id: 2 },
|
|
177
|
+
* { id: 3 },
|
|
178
|
+
* ]
|
|
179
|
+
* }
|
|
180
|
+
* ], item => item.id); // 输出为 [1, 2, 3]
|
|
181
|
+
*
|
|
182
|
+
* @param tree
|
|
183
|
+
* @param mapper
|
|
184
|
+
*/
|
|
185
|
+
export declare function flattenTree<T extends TreeItem>(tree: Array<T>): Array<T>;
|
|
186
|
+
export declare function flattenTree<T extends TreeItem, U>(tree: Array<T>, mapper: (value: T, index: number) => U): Array<U>;
|
|
187
|
+
/**
|
|
188
|
+
* 操作树,遵循 imutable, 每次返回一个新的树。
|
|
189
|
+
* 类似数组的 splice 不同的地方这个方法不修改原始数据,
|
|
190
|
+
* 同时第二个参数不是下标,而是下标数组,分别代表每一层的下标。
|
|
191
|
+
*
|
|
192
|
+
* 至于如何获取下标数组,请查看 findTreeIndex
|
|
193
|
+
*
|
|
194
|
+
* @param tree
|
|
195
|
+
* @param idx
|
|
196
|
+
* @param deleteCount
|
|
197
|
+
* @param ...items
|
|
198
|
+
*/
|
|
199
|
+
export declare function spliceTree<T extends TreeItem>(tree: Array<T>, idx: Array<number> | number, deleteCount?: number, ...items: Array<T>): Array<T>;
|
|
200
|
+
/**
|
|
201
|
+
* 计算树的深度
|
|
202
|
+
* @param tree
|
|
203
|
+
*/
|
|
204
|
+
export declare function getTreeDepth<T extends TreeItem>(tree: Array<T>): number;
|
|
205
|
+
/**
|
|
206
|
+
* 从树中获取某个值的所有祖先
|
|
207
|
+
* @param tree
|
|
208
|
+
* @param value
|
|
209
|
+
*/
|
|
210
|
+
export declare function getTreeAncestors<T extends TreeItem>(tree: Array<T>, value: T, includeSelf?: boolean): Array<T> | null;
|
|
211
|
+
/**
|
|
212
|
+
* 从树中获取某个值的上级
|
|
213
|
+
* @param tree
|
|
214
|
+
* @param value
|
|
215
|
+
*/
|
|
216
|
+
export declare function getTreeParent<T extends TreeItem>(tree: Array<T>, value: T): T | null;
|
|
217
|
+
export declare function ucFirst(str?: string): string | undefined;
|
|
218
|
+
export declare function lcFirst(str?: string): string;
|
|
219
|
+
export declare function camel(str?: string): string;
|
|
220
|
+
export declare function getWidthRate(value: any, strictMode?: boolean): number;
|
|
221
|
+
export declare function getLevelFromClassName(value: string, defaultValue?: string): string;
|
|
222
|
+
export declare function pickEventsProps(props: any): any;
|
|
223
|
+
export declare const autobind: typeof autobindMethod;
|
|
224
|
+
export declare const bulkBindFunctions: <T extends {
|
|
225
|
+
[propName: string]: any;
|
|
226
|
+
}>(context: T, funNames: FunctionPropertyNames<T>[]) => void;
|
|
227
|
+
export declare function sortArray<T extends any>(items: Array<T>, field: string, dir: -1 | 1): Array<T>;
|
|
228
|
+
export declare function hasFile(object: any): boolean;
|
|
229
|
+
export declare function qsstringify(data: any, options?: any, keepEmptyArray?: boolean): string;
|
|
230
|
+
export declare function qsparse(data: string, options?: any): qs.ParsedQs;
|
|
231
|
+
export declare function object2formData(data: any, options?: any, fd?: FormData): any;
|
|
232
|
+
export declare function chainFunctions(...fns: Array<(...args: Array<any>) => void>): (...args: Array<any>) => void;
|
|
233
|
+
export declare function chainEvents(props: any, schema: any): any;
|
|
234
|
+
export declare function mapObject(value: any, fn: Function): any;
|
|
235
|
+
export declare function loadScript(src: string): Promise<void>;
|
|
236
|
+
export declare class SkipOperation extends Error {
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* 深度查找具有某个 key 名字段的对象,实际实现是 internalFindObjectsWithKey,这里包一层是为了做循环引用检测
|
|
240
|
+
* @param obj
|
|
241
|
+
* @param key
|
|
242
|
+
*/
|
|
243
|
+
export declare function findObjectsWithKey(obj: any, key: string): any[];
|
|
244
|
+
/**
|
|
245
|
+
* 获取浏览器滚动条宽度 https://stackoverflow.com/a/13382873
|
|
246
|
+
*/
|
|
247
|
+
export declare function getScrollbarWidth(): number;
|
|
248
|
+
export declare function getPropValue<T extends {
|
|
249
|
+
value?: any;
|
|
250
|
+
name?: string;
|
|
251
|
+
data?: any;
|
|
252
|
+
defaultValue?: any;
|
|
253
|
+
}>(props: T, getter?: (props: T) => any): any;
|
|
254
|
+
export declare function detectPropValueChanged<T extends {
|
|
255
|
+
value?: any;
|
|
256
|
+
name?: string;
|
|
257
|
+
data?: any;
|
|
258
|
+
defaultValue?: any;
|
|
259
|
+
}>(props: T, prevProps: T, onChange: (value: any) => void, getter?: (props: T) => any): void;
|
|
260
|
+
export declare function removeHTMLTag(str: string): string;
|
|
261
|
+
/**
|
|
262
|
+
* 将路径格式的value转换成普通格式的value值
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
*
|
|
266
|
+
* 'a/b/c' => 'c';
|
|
267
|
+
* {label: 'A/B/C', value: 'a/b/c'} => {label: 'C', value: 'c'};
|
|
268
|
+
* 'a/b/c,a/d' => 'c,d';
|
|
269
|
+
* ['a/b/c', 'a/d'] => ['c', 'd'];
|
|
270
|
+
* [{label: 'A/B/C', value: 'a/b/c'},{label: 'A/D', value: 'a/d'}] => [{label: 'C', value: 'c'},{label: 'D', value: 'd'}]
|
|
271
|
+
*/
|
|
272
|
+
export declare function normalizeNodePath(value: any, enableNodePath: boolean, labelField?: string, valueField?: string, pathSeparator?: string, delimiter?: string): {
|
|
273
|
+
nodeValueArray: any[];
|
|
274
|
+
nodePathArray: any[];
|
|
275
|
+
};
|
|
276
|
+
export declare function isClickOnInput(e: React.MouseEvent<HTMLElement>): boolean;
|
|
277
|
+
export declare function hashCode(s: string): number;
|
|
278
|
+
/**
|
|
279
|
+
* 遍历 schema
|
|
280
|
+
* @param json
|
|
281
|
+
* @param mapper
|
|
282
|
+
*/
|
|
283
|
+
export declare function JSONTraverse(json: any, mapper: (value: any, key: string | number, host: Object) => any): void;
|
|
284
|
+
export declare function convertArrayValueToMoment(value: number[], types: string[], mom: moment.Moment): moment.Moment;
|
|
285
|
+
export declare function getRange(min: number, max: number, step?: number): number[];
|
|
286
|
+
export declare function repeatCount(count: number, iterator: (index: number) => any): any[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file 图标支持的公共方法,主要是支持自动识别地址和 icon-font
|
|
3
|
+
*/
|
|
4
|
+
/// <reference types="react" />
|
|
5
|
+
import { ClassNamesFn } from '../theme';
|
|
6
|
+
/**
|
|
7
|
+
* 判断字符串来生成 i 或 img
|
|
8
|
+
* @param icon icon 设置
|
|
9
|
+
* @param className 内部用的 className
|
|
10
|
+
* @param classNameProp amis 配置里设置的 className
|
|
11
|
+
*/
|
|
12
|
+
export declare const generateIcon: (cx: ClassNamesFn, icon?: string | undefined, className?: string | undefined, classNameProp?: string | undefined) => JSX.Element | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file image 相关的工具
|
|
3
|
+
* @param url
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 将 url 转成 dataurl
|
|
7
|
+
* @param url
|
|
8
|
+
*/
|
|
9
|
+
export declare const toDataURL: ((url: string) => Promise<string>) & import("lodash").MemoizedFunction;
|
|
10
|
+
/**
|
|
11
|
+
* 根据 url 获取图片尺寸
|
|
12
|
+
* @param url
|
|
13
|
+
*/
|
|
14
|
+
export declare const getImageDimensions: ((url: string) => Promise<{
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
}>) & import("lodash").MemoizedFunction;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './helper';
|
|
2
|
+
export { resizeSensor } from './resize-sensor';
|
|
3
|
+
export * from './api';
|
|
4
|
+
export * from './tpl';
|
|
5
|
+
export * from './tpl-builtin';
|
|
6
|
+
export * from './DataScope';
|
|
7
|
+
export * from './DataSchema';
|
|
8
|
+
export * from './normalizeOptions';
|
|
9
|
+
export * from './validations';
|
|
10
|
+
import './debug';
|
|
11
|
+
import animation from './Animation';
|
|
12
|
+
export { animation };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPureVariable(path?: any): path is string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makeSorter(key: string, method?: 'alpha' | 'numerical', order?: 'desc' | 'asc'): (a: any, b: any) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const normalizeLink: (to: string, location?: Location) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function createObject(superProps?: {
|
|
2
|
+
[propName: string]: any;
|
|
3
|
+
}, props?: {
|
|
4
|
+
[propName: string]: any;
|
|
5
|
+
}, properties?: any): object;
|
|
6
|
+
export declare function cloneObject(target: any, persistOwnProps?: boolean): any;
|
|
7
|
+
export declare function extendObject(target: any, src?: any, persistOwnProps?: boolean): any;
|
|
8
|
+
export declare function isObject(obj: any): any;
|
|
9
|
+
export declare function setVariable(data: {
|
|
10
|
+
[propName: string]: any;
|
|
11
|
+
}, key: string, value: any, convertKeyToPath?: boolean): void;
|
|
12
|
+
export declare function deleteVariable(data: {
|
|
13
|
+
[propName: string]: any;
|
|
14
|
+
}, key: string): void;
|
|
15
|
+
export declare function pickValues(names: string, data: object): any;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 修改自 https://github.com/react-bootstrap/dom-helpers/blob/master/src/offset.ts
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Returns the offset of a given element, including top and left positions, width and height.
|
|
6
|
+
*
|
|
7
|
+
* @param node the element
|
|
8
|
+
*/
|
|
9
|
+
export default function offset(node: HTMLElement): {
|
|
10
|
+
top: number;
|
|
11
|
+
left: number;
|
|
12
|
+
height: number;
|
|
13
|
+
width: number;
|
|
14
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 删减自 https://github.com/react-bootstrap/dom-helpers/blob/master/src/position.ts
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Returns the relative position of a given element.
|
|
6
|
+
*
|
|
7
|
+
* @param node the element
|
|
8
|
+
* @param offsetParent the offset parent
|
|
9
|
+
*/
|
|
10
|
+
export default function position(node: HTMLElement, offsetParent?: HTMLElement): {
|
|
11
|
+
top: number;
|
|
12
|
+
left: number;
|
|
13
|
+
height: number;
|
|
14
|
+
width: number;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const prettyBytes: (num: number) => string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ListenerAction } from '../actions/Action';
|
|
3
|
+
import { RendererProps } from '../factory';
|
|
4
|
+
import { IScopedContext } from '../Scoped';
|
|
5
|
+
export interface EventListeners {
|
|
6
|
+
[propName: string]: {
|
|
7
|
+
weight?: number;
|
|
8
|
+
actions: ListenerAction[];
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface OnEventProps {
|
|
12
|
+
onEvent?: {
|
|
13
|
+
[propName: string]: {
|
|
14
|
+
weight?: number;
|
|
15
|
+
actions: ListenerAction[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface RendererEventListener {
|
|
20
|
+
renderer: React.Component<RendererProps>;
|
|
21
|
+
type: string;
|
|
22
|
+
weight: number;
|
|
23
|
+
actions: ListenerAction[];
|
|
24
|
+
}
|
|
25
|
+
export declare type RendererEvent<T, P = any> = {
|
|
26
|
+
context: T;
|
|
27
|
+
type: string;
|
|
28
|
+
prevented?: boolean;
|
|
29
|
+
stoped?: boolean;
|
|
30
|
+
data?: P;
|
|
31
|
+
preventDefault: () => void;
|
|
32
|
+
stopPropagation: () => void;
|
|
33
|
+
setData: (data: P) => void;
|
|
34
|
+
};
|
|
35
|
+
export interface RendererEventContext {
|
|
36
|
+
data?: any;
|
|
37
|
+
[propName: string]: any;
|
|
38
|
+
}
|
|
39
|
+
export declare function createRendererEvent<T extends RendererEventContext>(type: string, context: T): RendererEvent<T>;
|
|
40
|
+
export declare const bindEvent: (renderer: any) => (() => void) | undefined;
|
|
41
|
+
export declare function dispatchEvent(e: string | React.MouseEvent<any>, renderer: React.Component<RendererProps>, scoped: IScopedContext, data: any, broadcast?: RendererEvent<any>): Promise<RendererEvent<any> | void>;
|
|
42
|
+
export declare const getRendererEventListeners: () => RendererEventListener[];
|
|
43
|
+
declare const _default: {};
|
|
44
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveVariable(path?: string, data?: any): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resolveVariableAndFilter: (path?: string | undefined, data?: object, defaultFilter?: string, fallbackValue?: (value: any) => any) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function string2regExp(value: string, caseSensitive?: boolean): RegExp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stripNumber(number: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tokenize: (str: string, data: object, defaultFilter?: string) => string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Enginer } from './tpl';
|
|
2
|
+
import { getFilters, registerFilter } from 'amis-formula';
|
|
3
|
+
import { prettyBytes } from './prettyBytes';
|
|
4
|
+
import { escapeHtml } from './escapeHtml';
|
|
5
|
+
import { formatDuration } from './formatDuration';
|
|
6
|
+
import { filterDate, parseDuration, relativeValueRe } from './date';
|
|
7
|
+
import { pickValues } from './object';
|
|
8
|
+
import { isPureVariable } from './isPureVariable';
|
|
9
|
+
import { stripNumber } from './stripNumber';
|
|
10
|
+
import { tokenize } from './tokenize';
|
|
11
|
+
import { resolveVariable } from './resolveVariable';
|
|
12
|
+
import { resolveVariableAndFilter } from './resolveVariableAndFilter';
|
|
13
|
+
import { dataMapping, resolveMapping } from './dataMapping';
|
|
14
|
+
import './filter';
|
|
15
|
+
export { prettyBytes, escapeHtml, formatDuration, filterDate, relativeValueRe, parseDuration, getFilters, registerFilter, pickValues, isPureVariable, stripNumber, tokenize, resolveVariable, resolveVariableAndFilter, resolveMapping, dataMapping };
|
|
16
|
+
export declare function register(): Enginer & {
|
|
17
|
+
name: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface Enginer {
|
|
2
|
+
test: (tpl: string) => boolean;
|
|
3
|
+
removeEscapeToken?: (tpl: string) => string;
|
|
4
|
+
compile: (tpl: string, data: object, ...rest: Array<any>) => string;
|
|
5
|
+
}
|
|
6
|
+
export declare function registerTplEnginer(name: string, enginer: Enginer): void;
|
|
7
|
+
export declare function filter(tpl?: any, data?: object, ...rest: Array<any>): string;
|
|
8
|
+
export declare function setCustomEvalExpression(fn: (expression: string, data?: any) => boolean): void;
|
|
9
|
+
export declare function evalExpression(expression: string, data?: object): boolean;
|
|
10
|
+
export declare function setCustomEvalJs(fn: (expression: string, data?: any) => any): void;
|
|
11
|
+
export declare function evalJS(js: string, data: object): any;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface ValidateFn {
|
|
2
|
+
(values: {
|
|
3
|
+
[propsName: string]: any;
|
|
4
|
+
}, value: any, arg1?: any, arg2?: any, arg3?: any): boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const validations: {
|
|
7
|
+
[propsName: string]: ValidateFn;
|
|
8
|
+
};
|
|
9
|
+
export declare function addRule(ruleName: string, fn: ValidateFn, message?: string): void;
|
|
10
|
+
export declare const validateMessages: {
|
|
11
|
+
[propName: string]: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function validate(value: any, values: {
|
|
14
|
+
[propName: string]: any;
|
|
15
|
+
}, rules: {
|
|
16
|
+
[propName: string]: any;
|
|
17
|
+
}, messages?: {
|
|
18
|
+
[propName: string]: string;
|
|
19
|
+
}, __?: (str: string) => string): Array<{
|
|
20
|
+
rule: string;
|
|
21
|
+
msg: string;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function validateObject(values: {
|
|
24
|
+
[propName: string]: any;
|
|
25
|
+
}, rules: {
|
|
26
|
+
[propName: string]: any;
|
|
27
|
+
}, messages?: {
|
|
28
|
+
[propName: string]: string;
|
|
29
|
+
}, __?: (str: string) => string): {
|
|
30
|
+
[propName: string]: {
|
|
31
|
+
rule: string;
|
|
32
|
+
msg: string;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
export declare function str2rules(validations: string | {
|
|
36
|
+
[propName: string]: any;
|
|
37
|
+
}): {
|
|
38
|
+
[propName: string]: any;
|
|
39
|
+
};
|