amis-core 2.9.0 → 3.0.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/esm/Root.js +1 -1
- package/esm/RootRenderer.js +1 -1
- package/esm/SchemaRenderer.d.ts +1 -0
- package/esm/SchemaRenderer.js +7 -5
- package/esm/Scoped.js +1 -1
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +1 -1
- package/esm/actions/Action.js +8 -2
- package/esm/actions/AjaxAction.js +1 -1
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.js +1 -1
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +1 -1
- package/esm/actions/DialogAction.js +5 -1
- package/esm/actions/DrawerAction.js +1 -1
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/LinkAction.js +1 -1
- package/esm/actions/LoopAction.js +1 -1
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.d.ts +2 -2
- package/esm/components/Overlay.js +1 -1
- package/esm/components/PopOver.js +1 -1
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.d.ts +2 -1
- package/esm/factory.js +3 -3
- package/esm/index.d.ts +8 -3
- package/esm/index.js +10 -9
- package/esm/locale.js +1 -1
- package/esm/renderers/Form.d.ts +1 -1
- package/esm/renderers/Form.js +1 -1
- package/esm/renderers/Item.js +10 -7
- package/esm/renderers/Options.js +3 -3
- package/esm/renderers/Placeholder.js +1 -1
- package/esm/renderers/builtin.js +1 -1
- package/esm/renderers/register.js +1 -1
- package/esm/renderers/wrapControl.js +1 -1
- package/esm/store/app.js +1 -1
- package/esm/store/combo.js +1 -1
- package/esm/store/crud.js +22 -8
- package/esm/store/form.js +1 -1
- package/esm/store/formItem.js +2 -2
- package/esm/store/iRenderer.js +1 -1
- package/esm/store/index.js +1 -1
- package/esm/store/list.js +1 -1
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.js +2 -2
- package/esm/store/root.js +1 -1
- package/esm/store/service.js +1 -1
- package/esm/store/table.d.ts +24 -23
- package/esm/store/table.js +17 -4
- package/esm/store/table2.d.ts +5 -5
- package/esm/store/table2.js +23 -19
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +6 -0
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.js +1 -1
- package/esm/utils/DataScope.js +1 -1
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.js +9 -2
- package/esm/utils/attachmentAdpator.js +1 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/dataMapping.js +1 -1
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.js +4 -4
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.d.ts +2 -0
- package/esm/utils/dom.js +47 -10
- package/esm/utils/errors.js +1 -1
- package/esm/utils/escapeHtml.js +1 -1
- package/esm/utils/filter-schema.js +1 -1
- package/esm/utils/filter.js +1 -1
- package/esm/utils/formatDuration.js +1 -1
- package/esm/utils/formula.js +2 -2
- package/esm/utils/getVariable.js +1 -1
- package/esm/utils/grammar.js +1 -1
- package/esm/utils/handleAction.js +1 -1
- package/esm/utils/helper.d.ts +7 -0
- package/esm/utils/helper.js +28 -3
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.d.ts +6 -1
- package/esm/utils/icon.js +6 -1
- package/esm/utils/image.js +1 -1
- package/esm/utils/isPureVariable.js +1 -1
- package/esm/utils/json-schema-2-amis-schema.js +1 -1
- package/esm/utils/keyToPath.js +1 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.js +1 -1
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +1 -1
- package/esm/utils/position.js +1 -1
- package/esm/utils/prettyBytes.js +1 -1
- package/esm/utils/renderer-event.js +35 -32
- package/esm/utils/replaceText.js +1 -1
- package/esm/utils/resize-sensor.js +1 -1
- package/esm/utils/resolveCondition.d.ts +1 -0
- package/esm/utils/resolveCondition.js +19 -4
- package/esm/utils/resolveVariable.js +1 -1
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
- package/esm/utils/resolveVariableAndFilterForAsync.js +20 -3
- package/esm/utils/scrollPosition.js +1 -1
- package/esm/utils/string2regExp.js +1 -1
- package/esm/utils/stripNumber.js +1 -1
- package/esm/utils/style-helper.d.ts +9 -4
- package/esm/utils/style-helper.js +81 -16
- package/esm/utils/style.js +2 -2
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.d.ts +1 -0
- package/esm/utils/tokenize.js +34 -3
- package/esm/utils/tpl-builtin.d.ts +2 -1
- package/esm/utils/tpl-builtin.js +18 -3
- package/esm/utils/tpl-lodash.js +3 -2
- package/esm/utils/tpl.d.ts +2 -0
- package/esm/utils/tpl.js +24 -2
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validations.d.ts +4 -1
- package/esm/utils/validations.js +27 -12
- package/lib/Root.js +1 -1
- package/lib/RootRenderer.js +1 -1
- package/lib/SchemaRenderer.d.ts +1 -0
- package/lib/SchemaRenderer.js +7 -4
- package/lib/Scoped.js +1 -1
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +1 -1
- package/lib/actions/Action.js +8 -2
- package/lib/actions/AjaxAction.js +1 -1
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.js +1 -1
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +1 -1
- package/lib/actions/DialogAction.js +5 -1
- package/lib/actions/DrawerAction.js +1 -1
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/LinkAction.js +1 -1
- package/lib/actions/LoopAction.js +1 -1
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/components/LazyComponent.js +1 -1
- package/lib/components/Overlay.d.ts +2 -2
- package/lib/components/Overlay.js +1 -1
- package/lib/components/PopOver.js +1 -1
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.d.ts +2 -1
- package/lib/factory.js +3 -3
- package/lib/index.d.ts +8 -3
- package/lib/index.js +14 -2
- package/lib/locale.js +1 -1
- package/lib/renderers/Form.d.ts +1 -1
- package/lib/renderers/Form.js +1 -1
- package/lib/renderers/Item.js +10 -7
- package/lib/renderers/Options.js +3 -3
- package/lib/renderers/Placeholder.js +1 -1
- package/lib/renderers/builtin.js +1 -1
- package/lib/renderers/register.js +1 -1
- package/lib/renderers/wrapControl.js +1 -1
- package/lib/store/app.js +1 -1
- package/lib/store/combo.js +1 -1
- package/lib/store/crud.js +22 -8
- package/lib/store/form.js +1 -1
- package/lib/store/formItem.js +2 -2
- package/lib/store/iRenderer.js +1 -1
- package/lib/store/index.js +1 -1
- package/lib/store/list.js +1 -1
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.js +2 -2
- package/lib/store/root.js +1 -1
- package/lib/store/service.js +1 -1
- package/lib/store/table.d.ts +24 -23
- package/lib/store/table.js +17 -4
- package/lib/store/table2.d.ts +5 -5
- package/lib/store/table2.js +23 -19
- package/lib/theme.js +1 -1
- package/lib/types.d.ts +6 -0
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.js +1 -1
- package/lib/utils/DataScope.js +1 -1
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.js +9 -2
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/columnsSplit.js +1 -1
- package/lib/utils/dataMapping.js +1 -1
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.js +4 -4
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.d.ts +2 -0
- package/lib/utils/dom.js +48 -9
- package/lib/utils/errors.js +1 -1
- package/lib/utils/escapeHtml.js +1 -1
- package/lib/utils/filter-schema.js +1 -1
- package/lib/utils/filter.js +1 -1
- package/lib/utils/formatDuration.js +1 -1
- package/lib/utils/formula.js +2 -2
- package/lib/utils/getVariable.js +1 -1
- package/lib/utils/grammar.js +1 -1
- package/lib/utils/handleAction.js +1 -1
- package/lib/utils/helper.d.ts +7 -0
- package/lib/utils/helper.js +29 -2
- package/lib/utils/highlight.js +1 -1
- package/lib/utils/icon.d.ts +6 -1
- package/lib/utils/icon.js +6 -1
- package/lib/utils/image.js +1 -1
- package/lib/utils/isPureVariable.js +1 -1
- package/lib/utils/json-schema-2-amis-schema.js +1 -1
- package/lib/utils/keyToPath.js +1 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.js +1 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +1 -1
- package/lib/utils/position.js +1 -1
- package/lib/utils/prettyBytes.js +1 -1
- package/lib/utils/renderer-event.js +35 -32
- package/lib/utils/replaceText.js +1 -1
- package/lib/utils/resize-sensor.js +1 -1
- package/lib/utils/resolveCondition.d.ts +1 -0
- package/lib/utils/resolveCondition.js +19 -3
- package/lib/utils/resolveVariable.js +1 -1
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
- package/lib/utils/resolveVariableAndFilterForAsync.js +20 -2
- package/lib/utils/scrollPosition.js +1 -1
- package/lib/utils/string2regExp.js +1 -1
- package/lib/utils/stripNumber.js +1 -1
- package/lib/utils/style-helper.d.ts +9 -4
- package/lib/utils/style-helper.js +86 -15
- package/lib/utils/style.js +2 -2
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.d.ts +1 -0
- package/lib/utils/tokenize.js +33 -1
- package/lib/utils/tpl-builtin.d.ts +2 -1
- package/lib/utils/tpl-builtin.js +17 -2
- package/lib/utils/tpl-lodash.js +3 -2
- package/lib/utils/tpl.d.ts +2 -0
- package/lib/utils/tpl.js +24 -1
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validations.d.ts +4 -1
- package/lib/utils/validations.js +27 -12
- package/package.json +3 -3
package/lib/utils/highlight.js
CHANGED
package/lib/utils/icon.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ import { ClassNamesFn } from '../theme';
|
|
|
6
6
|
export interface IconCheckedSchema {
|
|
7
7
|
id: string;
|
|
8
8
|
name?: string;
|
|
9
|
+
svg?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface IconCheckedSchemaNew {
|
|
12
|
+
type: 'icon';
|
|
13
|
+
icon: IconCheckedSchema;
|
|
9
14
|
}
|
|
10
15
|
/**
|
|
11
16
|
* 判断字符串来生成 i 或 img
|
|
@@ -13,4 +18,4 @@ export interface IconCheckedSchema {
|
|
|
13
18
|
* @param className 内部用的 className
|
|
14
19
|
* @param classNameProp amis 配置里设置的 className
|
|
15
20
|
*/
|
|
16
|
-
export declare const generateIcon: (cx: ClassNamesFn, icon?: string | IconCheckedSchema | React.ReactNode, className?: string, classNameProp?: string) => JSX.Element | null | undefined;
|
|
21
|
+
export declare const generateIcon: (cx: ClassNamesFn, icon?: string | IconCheckedSchema | React.ReactNode | IconCheckedSchemaNew, className?: string, classNameProp?: string) => JSX.Element | null | undefined;
|
package/lib/utils/icon.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core
|
|
2
|
+
* amis-core v3.0.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -24,6 +24,11 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
24
24
|
* @param classNameProp amis 配置里设置的 className
|
|
25
25
|
*/
|
|
26
26
|
var generateIcon = function (cx, icon, className, classNameProp) {
|
|
27
|
+
if (lodash.isObject(icon) &&
|
|
28
|
+
icon.type === 'icon' &&
|
|
29
|
+
icon.icon) {
|
|
30
|
+
icon = icon.icon;
|
|
31
|
+
}
|
|
27
32
|
if (React__default["default"].isValidElement(icon)) {
|
|
28
33
|
return icon;
|
|
29
34
|
}
|
package/lib/utils/image.js
CHANGED
package/lib/utils/keyToPath.js
CHANGED
package/lib/utils/makeSorter.js
CHANGED
package/lib/utils/object.js
CHANGED
package/lib/utils/offset.js
CHANGED
package/lib/utils/position.js
CHANGED
package/lib/utils/prettyBytes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core
|
|
2
|
+
* amis-core v3.0.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -42,7 +42,7 @@ function createRendererEvent(type, context) {
|
|
|
42
42
|
// 绑定事件
|
|
43
43
|
var bindEvent = function (renderer) {
|
|
44
44
|
var e_1, _a;
|
|
45
|
-
var _b, _c;
|
|
45
|
+
var _b, _c, _d;
|
|
46
46
|
if (!renderer) {
|
|
47
47
|
return undefined;
|
|
48
48
|
}
|
|
@@ -57,15 +57,16 @@ var bindEvent = function (renderer) {
|
|
|
57
57
|
rendererEventListeners = rendererEventListeners.filter(function (item) {
|
|
58
58
|
return !(item.renderer === listener.renderer && item.type === listener.type);
|
|
59
59
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
listener.actions.length &&
|
|
61
|
+
rendererEventListeners.push({
|
|
62
|
+
renderer: renderer,
|
|
63
|
+
type: key,
|
|
64
|
+
debounce: listener.debounce || null,
|
|
65
|
+
weight: listener.weight || 0,
|
|
66
|
+
actions: listener.actions
|
|
67
|
+
});
|
|
67
68
|
}
|
|
68
|
-
if (!listener) {
|
|
69
|
+
if (!listener && ((_d = listeners[key].actions) === null || _d === void 0 ? void 0 : _d.length)) {
|
|
69
70
|
rendererEventListeners.push({
|
|
70
71
|
renderer: renderer,
|
|
71
72
|
type: key,
|
|
@@ -77,15 +78,15 @@ var bindEvent = function (renderer) {
|
|
|
77
78
|
};
|
|
78
79
|
try {
|
|
79
80
|
// 暂存
|
|
80
|
-
for (var
|
|
81
|
-
var key =
|
|
81
|
+
for (var _e = tslib.__values(Object.keys(listeners)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
82
|
+
var key = _f.value;
|
|
82
83
|
_loop_1(key);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
86
87
|
finally {
|
|
87
88
|
try {
|
|
88
|
-
if (
|
|
89
|
+
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
89
90
|
}
|
|
90
91
|
finally { if (e_1) throw e_1.error; }
|
|
91
92
|
}
|
|
@@ -97,19 +98,20 @@ var bindEvent = function (renderer) {
|
|
|
97
98
|
};
|
|
98
99
|
// 触发事件
|
|
99
100
|
function dispatchEvent(e, renderer, scoped, data, broadcast) {
|
|
100
|
-
var _a, _b, _c, _d, _e, _f;
|
|
101
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
101
102
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
102
103
|
var unbindEvent, eventName, eventConfig, rendererEvent, listeners, executedCount, checkExecuted, _loop_2, listeners_1, listeners_1_1, listener, state_1, e_2_1;
|
|
103
|
-
var e_2,
|
|
104
|
+
var e_2, _j;
|
|
104
105
|
var _this = this;
|
|
105
|
-
return tslib.__generator(this, function (
|
|
106
|
-
switch (
|
|
106
|
+
return tslib.__generator(this, function (_k) {
|
|
107
|
+
switch (_k.label) {
|
|
107
108
|
case 0:
|
|
108
109
|
unbindEvent = null;
|
|
109
110
|
eventName = typeof e === 'string' ? e : e.type;
|
|
110
111
|
(_c = (_b = (_a = renderer === null || renderer === void 0 ? void 0 : renderer.props) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.beforeDispatchEvent) === null || _c === void 0 ? void 0 : _c.call(_b, e, renderer, scoped, data, broadcast);
|
|
112
|
+
broadcast && ((_e = (_d = renderer.props).onBroadcast) === null || _e === void 0 ? void 0 : _e.call(_d, e, broadcast, data));
|
|
111
113
|
if (!broadcast) {
|
|
112
|
-
eventConfig = (
|
|
114
|
+
eventConfig = (_g = (_f = renderer === null || renderer === void 0 ? void 0 : renderer.props) === null || _f === void 0 ? void 0 : _f.onEvent) === null || _g === void 0 ? void 0 : _g[eventName];
|
|
113
115
|
if (!eventConfig) {
|
|
114
116
|
// 没命中也没关系
|
|
115
117
|
return [2 /*return*/, Promise.resolve()];
|
|
@@ -122,7 +124,7 @@ function dispatchEvent(e, renderer, scoped, data, broadcast) {
|
|
|
122
124
|
}
|
|
123
125
|
rendererEvent = broadcast ||
|
|
124
126
|
createRendererEvent(eventName, {
|
|
125
|
-
env: (
|
|
127
|
+
env: (_h = renderer === null || renderer === void 0 ? void 0 : renderer.props) === null || _h === void 0 ? void 0 : _h.env,
|
|
126
128
|
nativeEvent: e,
|
|
127
129
|
data: data,
|
|
128
130
|
scoped: scoped
|
|
@@ -143,11 +145,11 @@ function dispatchEvent(e, renderer, scoped, data, broadcast) {
|
|
|
143
145
|
}
|
|
144
146
|
};
|
|
145
147
|
_loop_2 = function (listener) {
|
|
146
|
-
var
|
|
147
|
-
return tslib.__generator(this, function (
|
|
148
|
-
switch (
|
|
148
|
+
var _l, _m, wait, _o, trailing, _p, leading, _q, maxWait, debounced_1;
|
|
149
|
+
return tslib.__generator(this, function (_r) {
|
|
150
|
+
switch (_r.label) {
|
|
149
151
|
case 0:
|
|
150
|
-
|
|
152
|
+
_l = (listener === null || listener === void 0 ? void 0 : listener.debounce) || {}, _m = _l.wait, wait = _m === void 0 ? 100 : _m, _o = _l.trailing, trailing = _o === void 0 ? true : _o, _p = _l.leading, leading = _p === void 0 ? false : _p, _q = _l.maxWait, maxWait = _q === void 0 ? 10000 : _q;
|
|
151
153
|
if (!(listener === null || listener === void 0 ? void 0 : listener.debounce)) return [3 /*break*/, 1];
|
|
152
154
|
debounced_1 = debounce__default["default"](function () { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
153
155
|
return tslib.__generator(this, function (_a) {
|
|
@@ -176,9 +178,9 @@ function dispatchEvent(e, renderer, scoped, data, broadcast) {
|
|
|
176
178
|
return [3 /*break*/, 3];
|
|
177
179
|
case 1: return [4 /*yield*/, Action.runActions(listener.actions, listener.renderer, rendererEvent)];
|
|
178
180
|
case 2:
|
|
179
|
-
|
|
181
|
+
_r.sent();
|
|
180
182
|
checkExecuted();
|
|
181
|
-
|
|
183
|
+
_r.label = 3;
|
|
182
184
|
case 3:
|
|
183
185
|
// 停止后续监听器执行
|
|
184
186
|
if (rendererEvent.stoped) {
|
|
@@ -188,31 +190,31 @@ function dispatchEvent(e, renderer, scoped, data, broadcast) {
|
|
|
188
190
|
}
|
|
189
191
|
});
|
|
190
192
|
};
|
|
191
|
-
|
|
193
|
+
_k.label = 1;
|
|
192
194
|
case 1:
|
|
193
|
-
|
|
195
|
+
_k.trys.push([1, 6, 7, 8]);
|
|
194
196
|
listeners_1 = tslib.__values(listeners), listeners_1_1 = listeners_1.next();
|
|
195
|
-
|
|
197
|
+
_k.label = 2;
|
|
196
198
|
case 2:
|
|
197
199
|
if (!!listeners_1_1.done) return [3 /*break*/, 5];
|
|
198
200
|
listener = listeners_1_1.value;
|
|
199
201
|
return [5 /*yield**/, _loop_2(listener)];
|
|
200
202
|
case 3:
|
|
201
|
-
state_1 =
|
|
203
|
+
state_1 = _k.sent();
|
|
202
204
|
if (state_1 === "break")
|
|
203
205
|
return [3 /*break*/, 5];
|
|
204
|
-
|
|
206
|
+
_k.label = 4;
|
|
205
207
|
case 4:
|
|
206
208
|
listeners_1_1 = listeners_1.next();
|
|
207
209
|
return [3 /*break*/, 2];
|
|
208
210
|
case 5: return [3 /*break*/, 8];
|
|
209
211
|
case 6:
|
|
210
|
-
e_2_1 =
|
|
212
|
+
e_2_1 = _k.sent();
|
|
211
213
|
e_2 = { error: e_2_1 };
|
|
212
214
|
return [3 /*break*/, 8];
|
|
213
215
|
case 7:
|
|
214
216
|
try {
|
|
215
|
-
if (listeners_1_1 && !listeners_1_1.done && (
|
|
217
|
+
if (listeners_1_1 && !listeners_1_1.done && (_j = listeners_1.return)) _j.call(listeners_1);
|
|
216
218
|
}
|
|
217
219
|
finally { if (e_2) throw e_2.error; }
|
|
218
220
|
return [7 /*endfinally*/];
|
|
@@ -232,6 +234,7 @@ var getRendererEventListeners = function () {
|
|
|
232
234
|
*/
|
|
233
235
|
var resolveEventData = function (props, data, valueKey) {
|
|
234
236
|
var _a, _b;
|
|
237
|
+
if (valueKey === void 0) { valueKey = 'value'; }
|
|
235
238
|
return object.createObject(props.data, props.name && valueKey
|
|
236
239
|
? tslib.__assign(tslib.__assign({}, data), (_a = {}, _a[props.name] = data[valueKey], _a.__rendererData = tslib.__assign(tslib.__assign({}, props.data), (_b = {}, _b[props.name] = data[valueKey], _b)), _a)) : data);
|
|
237
240
|
};
|
package/lib/utils/replaceText.js
CHANGED
|
@@ -3,3 +3,4 @@ export declare function registerConditionComputer(op: string, func: (left: any,
|
|
|
3
3
|
export declare function getConditionComputers(): {
|
|
4
4
|
[op: string]: (left: any, right: any, fieldType?: string | undefined) => boolean;
|
|
5
5
|
};
|
|
6
|
+
export declare function setConditionComputeErrorHandler(fn: (conditions: any, data: any, defaultResult: boolean) => boolean | Promise<boolean>): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core
|
|
2
|
+
* amis-core v3.0.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -29,9 +29,11 @@ var capitalize__default = /*#__PURE__*/_interopDefaultLegacy(capitalize);
|
|
|
29
29
|
|
|
30
30
|
var conditionResolverMap = {};
|
|
31
31
|
var DEFAULT_RESULT = true;
|
|
32
|
+
var conditionComputeErrorHandler;
|
|
32
33
|
function resolveCondition(conditions, data, defaultResult) {
|
|
33
34
|
if (defaultResult === void 0) { defaultResult = true; }
|
|
34
35
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
36
|
+
var e_1;
|
|
35
37
|
return tslib.__generator(this, function (_a) {
|
|
36
38
|
switch (_a.label) {
|
|
37
39
|
case 0:
|
|
@@ -41,8 +43,18 @@ function resolveCondition(conditions, data, defaultResult) {
|
|
|
41
43
|
!conditions.children.length) {
|
|
42
44
|
return [2 /*return*/, defaultResult];
|
|
43
45
|
}
|
|
46
|
+
_a.label = 1;
|
|
47
|
+
case 1:
|
|
48
|
+
_a.trys.push([1, 3, , 6]);
|
|
44
49
|
return [4 /*yield*/, computeConditions(conditions.children, conditions.conjunction, data)];
|
|
45
|
-
case
|
|
50
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
51
|
+
case 3:
|
|
52
|
+
e_1 = _a.sent();
|
|
53
|
+
if (!(e_1.name === 'FormulaEvalError')) return [3 /*break*/, 5];
|
|
54
|
+
return [4 /*yield*/, (conditionComputeErrorHandler === null || conditionComputeErrorHandler === void 0 ? void 0 : conditionComputeErrorHandler(conditions.children, conditions.conjunction, data))];
|
|
55
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
56
|
+
case 5: return [2 /*return*/, defaultResult];
|
|
57
|
+
case 6: return [2 /*return*/];
|
|
46
58
|
}
|
|
47
59
|
});
|
|
48
60
|
});
|
|
@@ -93,7 +105,7 @@ function computeCondition(rule, index, data) {
|
|
|
93
105
|
switch (_b.label) {
|
|
94
106
|
case 0:
|
|
95
107
|
leftValue = get__default["default"](data, rule.left.field);
|
|
96
|
-
return [4 /*yield*/, resolveVariableAndFilterForAsync.resolveVariableAndFilterForAsync(rule.right, data)];
|
|
108
|
+
return [4 /*yield*/, resolveVariableAndFilterForAsync.resolveVariableAndFilterForAsync(rule.right, data, undefined, undefined, true)];
|
|
97
109
|
case 1:
|
|
98
110
|
rightValue = _b.sent();
|
|
99
111
|
func = (_a = conditionResolverMap["".concat(rule.op, "For").concat(capitalize__default["default"](rule.left.type))]) !== null && _a !== void 0 ? _a : conditionResolverMap[rule.op];
|
|
@@ -282,6 +294,9 @@ function registerConditionComputer(op, func, fieldType) {
|
|
|
282
294
|
function getConditionComputers() {
|
|
283
295
|
return conditionResolverMap;
|
|
284
296
|
}
|
|
297
|
+
function setConditionComputeErrorHandler(fn) {
|
|
298
|
+
conditionComputeErrorHandler = fn;
|
|
299
|
+
}
|
|
285
300
|
registerConditionComputer('greater', greaterFunc);
|
|
286
301
|
registerConditionComputer('greater', greaterForDateFunc, 'date');
|
|
287
302
|
registerConditionComputer('greater', greaterForDateFunc, 'time');
|
|
@@ -320,3 +335,4 @@ registerConditionComputer('ends_with', endsWithFunc);
|
|
|
320
335
|
exports.getConditionComputers = getConditionComputers;
|
|
321
336
|
exports.registerConditionComputer = registerConditionComputer;
|
|
322
337
|
exports.resolveCondition = resolveCondition;
|
|
338
|
+
exports.setConditionComputeErrorHandler = setConditionComputeErrorHandler;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 设置自定义函数,functions中找不到处理的函数时执行
|
|
3
|
+
* @param fn
|
|
4
|
+
*/
|
|
5
|
+
export declare function setFormulaEvalErrorHandler(fn: (path: string, data?: object, ...args: any[]) => any): void;
|
|
6
|
+
export declare const resolveVariableAndFilterForAsync: (path?: string, data?: object, defaultFilter?: string, fallbackValue?: (value: any) => any, skipFormulaEvalErrorHandler?: boolean) => Promise<any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core
|
|
2
|
+
* amis-core v3.0.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -10,10 +10,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
10
10
|
var tslib = require('tslib');
|
|
11
11
|
var amisFormula = require('amis-formula');
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var formulaEvalErrorHandler;
|
|
14
|
+
/**
|
|
15
|
+
* 设置自定义函数,functions中找不到处理的函数时执行
|
|
16
|
+
* @param fn
|
|
17
|
+
*/
|
|
18
|
+
function setFormulaEvalErrorHandler(fn) {
|
|
19
|
+
formulaEvalErrorHandler = fn;
|
|
20
|
+
}
|
|
21
|
+
var resolveVariableAndFilterForAsync = function (path, data, defaultFilter, fallbackValue, skipFormulaEvalErrorHandler) {
|
|
14
22
|
if (data === void 0) { data = {}; }
|
|
15
23
|
if (defaultFilter === void 0) { defaultFilter = '| html'; }
|
|
16
24
|
if (fallbackValue === void 0) { fallbackValue = function (value) { return value; }; }
|
|
25
|
+
if (skipFormulaEvalErrorHandler === void 0) { skipFormulaEvalErrorHandler = false; }
|
|
17
26
|
return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
18
27
|
var ast, ret, e_1;
|
|
19
28
|
return tslib.__generator(this, function (_a) {
|
|
@@ -40,6 +49,14 @@ var resolveVariableAndFilterForAsync = function (path, data, defaultFilter, fall
|
|
|
40
49
|
case 3:
|
|
41
50
|
e_1 = _a.sent();
|
|
42
51
|
console.warn(e_1);
|
|
52
|
+
if (e_1.name === 'FormulaEvalError') {
|
|
53
|
+
if (!skipFormulaEvalErrorHandler) {
|
|
54
|
+
// 无法解析时,执行handler自定义解析逻辑
|
|
55
|
+
return [2 /*return*/, formulaEvalErrorHandler === null || formulaEvalErrorHandler === void 0 ? void 0 : formulaEvalErrorHandler(path, data, defaultFilter, fallbackValue)];
|
|
56
|
+
}
|
|
57
|
+
// 跳过自定义解析逻辑,则直接抛异常
|
|
58
|
+
throw e_1;
|
|
59
|
+
}
|
|
43
60
|
return [2 /*return*/, undefined];
|
|
44
61
|
case 4: return [2 /*return*/];
|
|
45
62
|
}
|
|
@@ -48,3 +65,4 @@ var resolveVariableAndFilterForAsync = function (path, data, defaultFilter, fall
|
|
|
48
65
|
};
|
|
49
66
|
|
|
50
67
|
exports.resolveVariableAndFilterForAsync = resolveVariableAndFilterForAsync;
|
|
68
|
+
exports.setFormulaEvalErrorHandler = setFormulaEvalErrorHandler;
|
package/lib/utils/stripNumber.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PlainObject } from '../types';
|
|
2
2
|
export declare const valueMap: PlainObject;
|
|
3
|
+
export declare const inheritValueMap: PlainObject;
|
|
3
4
|
interface extra {
|
|
4
5
|
pre?: string;
|
|
5
6
|
suf?: string;
|
|
@@ -7,7 +8,7 @@ interface extra {
|
|
|
7
8
|
export declare function findOrCreactStyle(id: string): HTMLElement;
|
|
8
9
|
export declare function insertStyle(style: string, id: string): void;
|
|
9
10
|
export declare function addStyle(style: string, id: string): void;
|
|
10
|
-
export declare function formatStyle(
|
|
11
|
+
export declare function formatStyle(themeCss: any, classNames: {
|
|
11
12
|
key: string;
|
|
12
13
|
value?: string;
|
|
13
14
|
weights?: {
|
|
@@ -16,14 +17,14 @@ export declare function formatStyle(css: any, classNames: {
|
|
|
16
17
|
active?: extra;
|
|
17
18
|
disabled?: extra;
|
|
18
19
|
};
|
|
19
|
-
}[], id?: string): {
|
|
20
|
+
}[], id?: string, defaultData?: any): {
|
|
20
21
|
value: string;
|
|
21
22
|
origin: {
|
|
22
23
|
className: string;
|
|
23
24
|
content: string;
|
|
24
25
|
}[];
|
|
25
26
|
};
|
|
26
|
-
export declare function insertCustomStyle(
|
|
27
|
+
export declare function insertCustomStyle(themeCss: any, classNames: {
|
|
27
28
|
key: string;
|
|
28
29
|
value?: string;
|
|
29
30
|
weights?: {
|
|
@@ -32,5 +33,9 @@ export declare function insertCustomStyle(css: any, classNames: {
|
|
|
32
33
|
active?: extra;
|
|
33
34
|
disabled?: extra;
|
|
34
35
|
};
|
|
35
|
-
}[], id?: string): void;
|
|
36
|
+
}[], id?: string, defaultData?: any): void;
|
|
37
|
+
/**
|
|
38
|
+
* 根据路径获取默认值
|
|
39
|
+
*/
|
|
40
|
+
export declare function getValueByPath(path: string, data: any): any;
|
|
36
41
|
export {};
|