amis-core 3.1.1 → 3.3.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.d.ts +1 -1
- package/esm/RootRenderer.js +3 -3
- package/esm/SchemaRenderer.js +6 -2
- package/esm/Scoped.d.ts +4 -1
- package/esm/Scoped.js +9 -5
- package/esm/StatusScoped.js +1 -1
- package/esm/WithRootStore.d.ts +4 -24
- package/esm/WithRootStore.js +12 -4
- package/esm/WithStore.js +23 -16
- package/esm/actions/Action.d.ts +1 -0
- package/esm/actions/Action.js +70 -45
- package/esm/actions/AjaxAction.d.ts +6 -8
- package/esm/actions/AjaxAction.js +20 -18
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.d.ts +1 -2
- package/esm/actions/CmptAction.js +47 -32
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +3 -2
- package/esm/actions/DialogAction.d.ts +2 -0
- package/esm/actions/DialogAction.js +39 -23
- package/esm/actions/DrawerAction.js +4 -4
- 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/StatusAction.d.ts +15 -0
- package/esm/actions/StatusAction.js +49 -0
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/actions/index.d.ts +1 -0
- package/esm/components/CustomStyle.js +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.js +3 -2
- package/esm/components/PopOver.js +3 -2
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.js +2 -2
- package/esm/index.d.ts +3 -1
- package/esm/index.js +16 -14
- package/esm/locale.js +1 -1
- package/esm/polyfills.d.ts +3 -0
- package/esm/polyfills.js +18 -0
- package/esm/renderers/Form.d.ts +7 -7
- package/esm/renderers/Form.js +182 -128
- package/esm/renderers/Item.d.ts +82 -77
- package/esm/renderers/Item.js +90 -74
- package/esm/renderers/Options.js +1 -2
- 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.d.ts +4 -24
- package/esm/renderers/wrapControl.js +140 -88
- package/esm/store/app.js +42 -4
- package/esm/store/combo.d.ts +564 -1892
- package/esm/store/combo.js +9 -2
- package/esm/store/crud.d.ts +4 -2
- package/esm/store/crud.js +17 -4
- package/esm/store/form.d.ts +182 -882
- package/esm/store/form.js +83 -81
- package/esm/store/formItem.d.ts +6 -2
- package/esm/store/formItem.js +19 -3
- package/esm/store/iRenderer.js +3 -2
- package/esm/store/index.js +1 -1
- package/esm/store/list.d.ts +1 -0
- package/esm/store/list.js +8 -2
- 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 +1 -1
- package/esm/store/root.js +3 -2
- package/esm/store/service.js +17 -12
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +604 -2020
- package/esm/store/table.js +86 -56
- package/esm/store/table2.d.ts +49 -0
- package/esm/store/table2.js +37 -4
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +22 -5
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.d.ts +3 -2
- package/esm/utils/DataSchema.js +27 -7
- package/esm/utils/DataScope.d.ts +10 -3
- package/esm/utils/DataScope.js +50 -12
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.d.ts +2 -2
- package/esm/utils/api.js +152 -112
- package/esm/utils/arraySlice.d.ts +1 -0
- package/esm/utils/arraySlice.js +76 -0
- 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 +29 -19
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.d.ts +2 -0
- package/esm/utils/debug.js +34 -7
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.js +4 -1
- 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.d.ts +0 -1
- package/esm/utils/formula.js +6 -9
- 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 +19 -2
- package/esm/utils/helper.js +69 -10
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.d.ts +4 -2
- package/esm/utils/icon.js +3 -2
- package/esm/utils/image.js +1 -1
- package/esm/utils/index.d.ts +2 -0
- 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/math.d.ts +3 -0
- package/esm/utils/math.js +52 -0
- package/esm/utils/memoryParse.js +1 -1
- package/esm/utils/normalizeLink.js +18 -9
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.d.ts +7 -0
- package/esm/utils/object.js +13 -2
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +2 -2
- package/esm/utils/position.js +1 -1
- package/esm/utils/prettyBytes.js +1 -1
- package/esm/utils/renderer-event.d.ts +1 -1
- package/esm/utils/renderer-event.js +14 -6
- package/esm/utils/replaceText.js +1 -1
- package/esm/utils/resize-sensor.js +1 -1
- package/esm/utils/resolveCondition.js +1 -1
- package/esm/utils/resolveVariable.js +1 -1
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
- 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.js +1 -1
- package/esm/utils/style.js +1 -1
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.js +1 -1
- package/esm/utils/tpl-lodash.js +1 -1
- package/esm/utils/tpl.js +1 -1
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validations.js +1 -1
- package/lib/Root.js +10 -7
- package/lib/RootRenderer.d.ts +1 -1
- package/lib/RootRenderer.js +11 -8
- package/lib/SchemaRenderer.js +13 -6
- package/lib/Scoped.d.ts +4 -1
- package/lib/Scoped.js +19 -13
- package/lib/StatusScoped.js +5 -2
- package/lib/WithRootStore.d.ts +4 -24
- package/lib/WithRootStore.js +15 -4
- package/lib/WithStore.js +27 -17
- package/lib/actions/Action.d.ts +1 -0
- package/lib/actions/Action.js +70 -45
- package/lib/actions/AjaxAction.d.ts +6 -8
- package/lib/actions/AjaxAction.js +20 -18
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.d.ts +1 -2
- package/lib/actions/CmptAction.js +47 -32
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +9 -5
- package/lib/actions/DialogAction.d.ts +2 -0
- package/lib/actions/DialogAction.js +39 -23
- package/lib/actions/DrawerAction.js +4 -4
- 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/StatusAction.d.ts +15 -0
- package/lib/actions/StatusAction.js +53 -0
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/actions/index.d.ts +1 -0
- package/lib/components/CustomStyle.js +1 -1
- package/lib/components/LazyComponent.js +12 -14
- package/lib/components/Overlay.js +15 -14
- package/lib/components/PopOver.js +12 -10
- package/lib/env.js +4 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.js +11 -9
- package/lib/index.d.ts +3 -1
- package/lib/index.js +26 -19
- package/lib/locale.js +6 -3
- package/lib/polyfills.d.ts +3 -0
- package/lib/polyfills.js +20 -0
- package/lib/renderers/Form.d.ts +7 -7
- package/lib/renderers/Form.js +194 -135
- package/lib/renderers/Item.d.ts +82 -77
- package/lib/renderers/Item.js +126 -104
- package/lib/renderers/Options.js +10 -5
- 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.d.ts +4 -24
- package/lib/renderers/wrapControl.js +143 -88
- package/lib/store/app.js +44 -3
- package/lib/store/combo.d.ts +564 -1892
- package/lib/store/combo.js +9 -2
- package/lib/store/crud.d.ts +4 -2
- package/lib/store/crud.js +17 -4
- package/lib/store/form.d.ts +182 -882
- package/lib/store/form.js +81 -79
- package/lib/store/formItem.d.ts +6 -2
- package/lib/store/formItem.js +19 -3
- package/lib/store/iRenderer.js +9 -5
- package/lib/store/index.js +1 -1
- package/lib/store/list.d.ts +1 -0
- package/lib/store/list.js +8 -2
- 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 +1 -1
- package/lib/store/root.js +9 -5
- package/lib/store/service.js +17 -12
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +604 -2020
- package/lib/store/table.js +85 -55
- package/lib/store/table2.d.ts +49 -0
- package/lib/store/table2.js +36 -3
- package/lib/theme.js +6 -3
- package/lib/types.d.ts +22 -5
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.d.ts +3 -2
- package/lib/utils/DataSchema.js +27 -7
- package/lib/utils/DataScope.d.ts +10 -3
- package/lib/utils/DataScope.js +50 -11
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.d.ts +2 -2
- package/lib/utils/api.js +151 -111
- package/lib/utils/arraySlice.d.ts +1 -0
- package/lib/utils/arraySlice.js +80 -0
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/columnsSplit.js +8 -6
- package/lib/utils/dataMapping.js +29 -19
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.d.ts +2 -0
- package/lib/utils/debug.js +61 -33
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.js +10 -5
- 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.d.ts +0 -1
- package/lib/utils/formula.js +6 -10
- 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 +19 -2
- package/lib/utils/helper.js +70 -9
- package/lib/utils/highlight.js +8 -9
- package/lib/utils/icon.d.ts +4 -2
- package/lib/utils/icon.js +12 -10
- package/lib/utils/image.js +1 -1
- package/lib/utils/index.d.ts +2 -0
- 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/math.d.ts +3 -0
- package/lib/utils/math.js +58 -0
- package/lib/utils/memoryParse.js +1 -1
- package/lib/utils/normalizeLink.js +18 -9
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.d.ts +7 -0
- package/lib/utils/object.js +13 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +7 -3
- package/lib/utils/position.js +1 -1
- package/lib/utils/prettyBytes.js +1 -1
- package/lib/utils/renderer-event.d.ts +1 -1
- package/lib/utils/renderer-event.js +13 -5
- package/lib/utils/replaceText.js +1 -1
- package/lib/utils/resize-sensor.js +1 -1
- package/lib/utils/resolveCondition.js +1 -1
- package/lib/utils/resolveVariable.js +1 -1
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
- 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.js +1 -1
- package/lib/utils/style.js +1 -1
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.js +1 -1
- package/lib/utils/tpl-lodash.js +1 -1
- package/lib/utils/tpl.js +1 -1
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validations.js +1 -1
- package/package.json +9 -4
|
@@ -49,30 +49,10 @@ export interface ControlProps {
|
|
|
49
49
|
store: IIRendererStore;
|
|
50
50
|
}
|
|
51
51
|
export declare function wrapControl<T extends React.ComponentType<React.ComponentProps<T> & ControlProps>>(ComposedComponent: T): {
|
|
52
|
-
new (props: Omit<any, "rootStore">
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
forceUpdate(callback?: (() => void) | undefined): void;
|
|
57
|
-
readonly props: Readonly<Omit<any, "rootStore">>;
|
|
58
|
-
state: Readonly<{}>;
|
|
59
|
-
refs: {
|
|
60
|
-
[key: string]: React.ReactInstance;
|
|
61
|
-
};
|
|
62
|
-
componentDidMount?(): void;
|
|
63
|
-
shouldComponentUpdate?(nextProps: Readonly<Omit<any, "rootStore">>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
64
|
-
componentWillUnmount?(): void;
|
|
65
|
-
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
66
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<Omit<any, "rootStore">>, prevState: Readonly<{}>): any;
|
|
67
|
-
componentDidUpdate?(prevProps: Readonly<Omit<any, "rootStore">>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
68
|
-
componentWillMount?(): void;
|
|
69
|
-
UNSAFE_componentWillMount?(): void;
|
|
70
|
-
componentWillReceiveProps?(nextProps: Readonly<Omit<any, "rootStore">>, nextContext: any): void;
|
|
71
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<Omit<any, "rootStore">>, nextContext: any): void;
|
|
72
|
-
componentWillUpdate?(nextProps: Readonly<Omit<any, "rootStore">>, nextState: Readonly<{}>, nextContext: any): void;
|
|
73
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<Omit<any, "rootStore">>, nextState: Readonly<{}>, nextContext: any): void;
|
|
74
|
-
};
|
|
75
|
-
new (props: Omit<any, "rootStore">, context: any): {
|
|
52
|
+
new (props: Omit<any, "rootStore">): {
|
|
53
|
+
ref: any;
|
|
54
|
+
getWrappedInstance(): any;
|
|
55
|
+
refFn(ref: any): void;
|
|
76
56
|
render(): React.JSX.Element;
|
|
77
57
|
context: unknown;
|
|
78
58
|
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<Omit<any, "rootStore">>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ import debounce from 'lodash/debounce';
|
|
|
9
9
|
import isEqual from 'lodash/isEqual';
|
|
10
10
|
import { ComboStore } from '../store/combo.js';
|
|
11
11
|
import { guid, promisify, anyChanged } from '../utils/helper.js';
|
|
12
|
-
import { isExpression, FormulaExec, replaceExpression, isNeedFormula
|
|
12
|
+
import { isExpression, FormulaExec, replaceExpression, isNeedFormula } from '../utils/formula.js';
|
|
13
13
|
import { ScopedContext } from '../Scoped.js';
|
|
14
14
|
import { FormItemStore } from '../store/formItem.js';
|
|
15
15
|
import { isAlive } from 'mobx-state-tree';
|
|
@@ -26,14 +26,14 @@ function wrapControl(ComposedComponent) {
|
|
|
26
26
|
__extends(class_1, _super);
|
|
27
27
|
function class_1(props) {
|
|
28
28
|
var _this = this;
|
|
29
|
-
var _a
|
|
29
|
+
var _a;
|
|
30
30
|
_this = _super.call(this, props) || this;
|
|
31
31
|
_this.value = undefined;
|
|
32
32
|
_this.lazyEmitChange = debounce(_this.emitChange.bind(_this), 250, {
|
|
33
33
|
trailing: true,
|
|
34
34
|
leading: false
|
|
35
35
|
});
|
|
36
|
-
var
|
|
36
|
+
var _b = _this.props, form = _b.formStore, formItem = _b.formItem, rootStore = _b.rootStore, store = _b.store, onChange = _b.onChange, data = _b.data, inputGroupControl = _b.inputGroupControl, _c = _b.$schema, name = _c.name, id = _c.id, type = _c.type, required = _c.required, validations = _c.validations, validationErrors = _c.validationErrors, unique = _c.unique, value = _c.value, extraName = _c.extraName; _c.multiple; var delimiter = _c.delimiter, valueField = _c.valueField, labelField = _c.labelField, joinValues = _c.joinValues, extractValue = _c.extractValue, selectFirst = _c.selectFirst, autoFill = _c.autoFill, clearValueOnHidden = _c.clearValueOnHidden, validateApi = _c.validateApi, minLength = _c.minLength, maxLength = _c.maxLength, validateOnChange = _c.validateOnChange, label = _c.label;
|
|
37
37
|
_this.getValue = _this.getValue.bind(_this);
|
|
38
38
|
_this.setValue = _this.setValue.bind(_this);
|
|
39
39
|
_this.handleChange = _this.handleChange.bind(_this);
|
|
@@ -64,7 +64,7 @@ function wrapControl(ComposedComponent) {
|
|
|
64
64
|
_this.model = model;
|
|
65
65
|
// @issue 打算干掉这个
|
|
66
66
|
formItem === null || formItem === void 0 ? void 0 : formItem.addSubFormItem(model);
|
|
67
|
-
model.config(__assign(__assign({}, pick(__assign(__assign({}, ComposedComponent.defaultProps), _this.props.$schema), ['multiple'])), { id: id, type: type, required: required, unique: unique, value: value, isValueSchemaExp: isExpression(value), rules: validations, messages: validationErrors, delimiter: delimiter, valueField: valueField, labelField: labelField, joinValues: joinValues, extractValue: extractValue, selectFirst: selectFirst, autoFill: autoFill, clearValueOnHidden: clearValueOnHidden, validateApi: validateApi, minLength: minLength, maxLength: maxLength, validateOnChange: validateOnChange, label: label, inputGroupControl: inputGroupControl }));
|
|
67
|
+
model.config(__assign(__assign({}, pick(__assign(__assign({}, ComposedComponent.defaultProps), _this.props.$schema), ['multiple'])), { id: id, type: type, required: required, unique: unique, value: value, isValueSchemaExp: isExpression(value), rules: validations, messages: validationErrors, delimiter: delimiter, valueField: valueField, labelField: labelField, joinValues: joinValues, extractValue: extractValue, selectFirst: selectFirst, autoFill: autoFill, clearValueOnHidden: clearValueOnHidden, validateApi: validateApi, minLength: minLength, maxLength: maxLength, validateOnChange: validateOnChange, label: label, inputGroupControl: inputGroupControl, extraName: extraName }));
|
|
68
68
|
// issue 这个逻辑应该在 combo 里面自己实现。
|
|
69
69
|
if (_this.model.unique &&
|
|
70
70
|
((_a = form === null || form === void 0 ? void 0 : form.parentStore) === null || _a === void 0 ? void 0 : _a.storeType) === ComboStore.name) {
|
|
@@ -73,21 +73,42 @@ function wrapControl(ComposedComponent) {
|
|
|
73
73
|
}
|
|
74
74
|
if (propValue !== undefined && propValue !== null) {
|
|
75
75
|
// 同步 value: 优先使用 props 中的 value
|
|
76
|
-
model.changeTmpValue(propValue);
|
|
76
|
+
model.changeTmpValue(propValue, 'controlled');
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
var isExp = isExpression(value);
|
|
80
|
+
if (isExp) {
|
|
81
|
+
model.changeTmpValue(FormulaExec['formula'](value, data), // 对组件默认值进行运算
|
|
82
|
+
'formulaChanged');
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
var initialValue = model.extraName
|
|
86
|
+
? [
|
|
87
|
+
store === null || store === void 0 ? void 0 : store.getValueByName(model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData),
|
|
88
|
+
store === null || store === void 0 ? void 0 : store.getValueByName(model.extraName, form === null || form === void 0 ? void 0 : form.canAccessSuperData)
|
|
89
|
+
]
|
|
90
|
+
: store === null || store === void 0 ? void 0 : store.getValueByName(model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData);
|
|
91
|
+
if (model.extraName &&
|
|
92
|
+
initialValue.every(function (item) { return item === undefined; })) {
|
|
93
|
+
initialValue = undefined;
|
|
94
|
+
}
|
|
95
|
+
model.changeTmpValue(initialValue !== null && initialValue !== void 0 ? initialValue : replaceExpression(value), typeof initialValue !== 'undefined'
|
|
96
|
+
? 'initialValue'
|
|
97
|
+
: 'defaultValue');
|
|
98
|
+
}
|
|
85
99
|
}
|
|
86
100
|
if (onChange &&
|
|
87
101
|
value !== undefined &&
|
|
88
102
|
model.tmpValue !== undefined) {
|
|
89
103
|
// 组件默认值支持表达式需要: 避免初始化时上下文中丢失组件默认值
|
|
90
|
-
|
|
104
|
+
if (model.extraName) {
|
|
105
|
+
var values = model.splitExtraValue(model.tmpValue);
|
|
106
|
+
onChange(values[0], model.name, false, true);
|
|
107
|
+
onChange(values[1], model.extraName, false, true);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
onChange(model.tmpValue, model.name, false, true);
|
|
111
|
+
}
|
|
91
112
|
}
|
|
92
113
|
else if (onChange &&
|
|
93
114
|
typeof propValue === 'undefined' &&
|
|
@@ -97,7 +118,14 @@ function wrapControl(ComposedComponent) {
|
|
|
97
118
|
// 对应 issue 为 https://github.com/baidu/amis/issues/2674
|
|
98
119
|
(store === null || store === void 0 ? void 0 : store.storeType) !== TableStore.name) {
|
|
99
120
|
// 如果没有初始值,通过 onChange 设置过去
|
|
100
|
-
|
|
121
|
+
if (model.extraName) {
|
|
122
|
+
var values = model.splitExtraValue(model.tmpValue);
|
|
123
|
+
onChange(values[0], model.name, false, true);
|
|
124
|
+
onChange(values[1], model.extraName, false, true);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
onChange(model.tmpValue, model.name, false, true);
|
|
128
|
+
}
|
|
101
129
|
}
|
|
102
130
|
return _this;
|
|
103
131
|
}
|
|
@@ -124,7 +152,7 @@ function wrapControl(ComposedComponent) {
|
|
|
124
152
|
}
|
|
125
153
|
};
|
|
126
154
|
class_1.prototype.componentDidUpdate = function (prevProps) {
|
|
127
|
-
var _a, _b;
|
|
155
|
+
var _a, _b, _c;
|
|
128
156
|
var props = this.props;
|
|
129
157
|
props.formStore;
|
|
130
158
|
var model = this.model;
|
|
@@ -149,7 +177,8 @@ function wrapControl(ComposedComponent) {
|
|
|
149
177
|
'validateApi',
|
|
150
178
|
'minLength',
|
|
151
179
|
'maxLength',
|
|
152
|
-
'label'
|
|
180
|
+
'label',
|
|
181
|
+
'extraName'
|
|
153
182
|
], prevProps.$schema, props.$schema)) {
|
|
154
183
|
model.config({
|
|
155
184
|
required: props.$schema.required,
|
|
@@ -172,7 +201,8 @@ function wrapControl(ComposedComponent) {
|
|
|
172
201
|
minLength: props.$schema.minLength,
|
|
173
202
|
maxLength: props.$schema.maxLength,
|
|
174
203
|
label: props.$schema.label,
|
|
175
|
-
inputGroupControl: props === null || props === void 0 ? void 0 : props.inputGroupControl
|
|
204
|
+
inputGroupControl: props === null || props === void 0 ? void 0 : props.inputGroupControl,
|
|
205
|
+
extraName: props.$schema.extraName
|
|
176
206
|
});
|
|
177
207
|
}
|
|
178
208
|
// 此处需要同时考虑 defaultValue 和 value
|
|
@@ -181,60 +211,56 @@ function wrapControl(ComposedComponent) {
|
|
|
181
211
|
if (!isEqual(props.value, prevProps.value) &&
|
|
182
212
|
!isEqual(props.value, model.tmpValue)) {
|
|
183
213
|
// 外部直接传入的 value 无需执行运算器
|
|
184
|
-
model.changeTmpValue(props.value);
|
|
214
|
+
model.changeTmpValue(props.value, 'controlled');
|
|
185
215
|
}
|
|
186
216
|
}
|
|
187
217
|
else if (model &&
|
|
188
218
|
typeof props.defaultValue !== 'undefined' &&
|
|
189
|
-
isExpression(props.defaultValue)
|
|
190
|
-
|
|
191
|
-
// 渲染器中的 defaultValue 优先(备注: SchemaRenderer中会将 value 改成 defaultValue)
|
|
192
|
-
if (!isEqual(props.defaultValue, prevProps.defaultValue) ||
|
|
219
|
+
isExpression(props.defaultValue) &&
|
|
220
|
+
(!isEqual(props.defaultValue, prevProps.defaultValue) ||
|
|
193
221
|
(props.data !== prevProps.data &&
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
222
|
+
isNeedFormula(props.defaultValue, props.data, prevProps.data)))) {
|
|
223
|
+
var curResult = FormulaExec['formula'](props.defaultValue, props.data);
|
|
224
|
+
var prevResult = FormulaExec['formula'](prevProps.defaultValue, prevProps.data);
|
|
225
|
+
if (!isEqual(curResult, prevResult) &&
|
|
226
|
+
!isEqual(curResult, model.tmpValue)) {
|
|
227
|
+
// 识别上下文变动、自身数值变动、公式运算结果变动
|
|
228
|
+
model.changeTmpValue(curResult, 'formulaChanged');
|
|
229
|
+
if (model.extraName) {
|
|
230
|
+
var values = model.splitExtraValue(curResult);
|
|
231
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, values[0], model.name, false);
|
|
232
|
+
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, values[1], model.extraName, false);
|
|
203
233
|
}
|
|
204
|
-
else
|
|
205
|
-
|
|
206
|
-
// now 表达式,计算后的值永远相同
|
|
207
|
-
model.changeTmpValue(nowData);
|
|
208
|
-
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, nowData, model.name, false);
|
|
234
|
+
else {
|
|
235
|
+
(_c = props.onChange) === null || _c === void 0 ? void 0 : _c.call(props, curResult, model.name, false);
|
|
209
236
|
}
|
|
210
237
|
}
|
|
211
238
|
}
|
|
212
239
|
else if (model) {
|
|
213
|
-
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
props.onChange(curValue, model.name, false);
|
|
240
|
+
// value 非公式表达式时,name 值优先,若 defaultValue 主动变动时,则使用 defaultValue
|
|
241
|
+
if (
|
|
242
|
+
// 然后才是查看关联的 name 属性值是否变化
|
|
243
|
+
props.data !== prevProps.data &&
|
|
244
|
+
(!model.emitedValue ||
|
|
245
|
+
isEqual(model.emitedValue, model.tmpValue))) {
|
|
246
|
+
model.changeEmitedValue(undefined);
|
|
247
|
+
var valueByName = model.extraName
|
|
248
|
+
? [
|
|
249
|
+
getVariable(props.data, model.name, false),
|
|
250
|
+
getVariable(props.data, model.extraName, false)
|
|
251
|
+
]
|
|
252
|
+
: getVariable(props.data, model.name, false);
|
|
253
|
+
if (!isEqual(valueByName, model.extraName
|
|
254
|
+
? model.splitExtraValue(model.tmpValue)
|
|
255
|
+
: model.tmpValue) &&
|
|
256
|
+
(!isEqual(model.extraName ? valueByName[0] : valueByName, getVariable(prevProps.data, model.name, false)) ||
|
|
257
|
+
// extraName
|
|
258
|
+
(model.extraName &&
|
|
259
|
+
!isEqual(valueByName[1], getVariable(prevProps.data, model.extraName, false))))) {
|
|
260
|
+
model.changeTmpValue(valueByName, props.formInited && !prevProps.formInited
|
|
261
|
+
? 'formInited'
|
|
262
|
+
: 'dataChanged');
|
|
263
|
+
this.checkValidate();
|
|
238
264
|
}
|
|
239
265
|
}
|
|
240
266
|
}
|
|
@@ -305,14 +331,33 @@ function wrapControl(ComposedComponent) {
|
|
|
305
331
|
scoped.unRegisterComponent(originRef);
|
|
306
332
|
}
|
|
307
333
|
};
|
|
334
|
+
class_1.prototype.checkValidate = function () {
|
|
335
|
+
var _a;
|
|
336
|
+
if (!this.model)
|
|
337
|
+
return; // 如果 model 为 undefined 则直接返回
|
|
338
|
+
var validated = this.model.validated;
|
|
339
|
+
var _b = this.props, formSubmited = _b.formSubmited, validateOnChange = _b.validateOnChange;
|
|
340
|
+
if (
|
|
341
|
+
// 如果配置了 minLength 或者 maxLength 就切成及时验证
|
|
342
|
+
// this.model.rules.minLength ||
|
|
343
|
+
// this.model.rules.maxLength ||
|
|
344
|
+
validateOnChange === true ||
|
|
345
|
+
(validateOnChange !== false && (formSubmited || validated))) {
|
|
346
|
+
this.validate();
|
|
347
|
+
}
|
|
348
|
+
else if (validateOnChange === false) {
|
|
349
|
+
(_a = this.model) === null || _a === void 0 ? void 0 : _a.reset();
|
|
350
|
+
}
|
|
351
|
+
};
|
|
308
352
|
class_1.prototype.validate = function () {
|
|
309
353
|
return __awaiter(this, void 0, void 0, function () {
|
|
310
|
-
var _a, form, data, formItemDispatchEvent, result, combo, group, validPromises
|
|
354
|
+
var _a, form, data, formItemDispatchEvent, result, combo, group, validPromises;
|
|
311
355
|
return __generator(this, function (_b) {
|
|
312
356
|
switch (_b.label) {
|
|
313
357
|
case 0:
|
|
358
|
+
if (!this.model)
|
|
359
|
+
return [2 /*return*/];
|
|
314
360
|
_a = this.props, form = _a.formStore, data = _a.data, formItemDispatchEvent = _a.formItemDispatchEvent;
|
|
315
|
-
if (!this.model) return [3 /*break*/, 4];
|
|
316
361
|
if (!(this.model.unique &&
|
|
317
362
|
(form === null || form === void 0 ? void 0 : form.parentStore) &&
|
|
318
363
|
form.parentStore.storeType === ComboStore.name)) return [3 /*break*/, 2];
|
|
@@ -325,12 +370,9 @@ function wrapControl(ComposedComponent) {
|
|
|
325
370
|
case 1:
|
|
326
371
|
result = _b.sent();
|
|
327
372
|
return [3 /*break*/, 4];
|
|
328
|
-
case 2:
|
|
329
|
-
validPromises = form === null || form === void 0 ? void 0 : form.getItemsByName(this.model.name).map(function (item) { return item.validate(data); });
|
|
330
|
-
if (!(validPromises && validPromises.length)) return [3 /*break*/, 4];
|
|
331
|
-
return [4 /*yield*/, Promise.all(validPromises)];
|
|
373
|
+
case 2: return [4 /*yield*/, this.model.validate(data)];
|
|
332
374
|
case 3:
|
|
333
|
-
result = _b.sent();
|
|
375
|
+
result = [_b.sent()];
|
|
334
376
|
_b.label = 4;
|
|
335
377
|
case 4:
|
|
336
378
|
if (result && result.length) {
|
|
@@ -365,9 +407,9 @@ function wrapControl(ComposedComponent) {
|
|
|
365
407
|
}
|
|
366
408
|
if (pipeOut) {
|
|
367
409
|
var oldValue = this.model.value;
|
|
368
|
-
value = pipeOut(value, oldValue, data);
|
|
410
|
+
value = pipeOut.call(this, value, oldValue, data);
|
|
369
411
|
}
|
|
370
|
-
this.model.changeTmpValue(value);
|
|
412
|
+
this.model.changeTmpValue(value, 'input');
|
|
371
413
|
if (changeImmediately || conrolChangeImmediately || !formInited) {
|
|
372
414
|
this.emitChange(submitOnChange);
|
|
373
415
|
}
|
|
@@ -377,15 +419,20 @@ function wrapControl(ComposedComponent) {
|
|
|
377
419
|
}
|
|
378
420
|
};
|
|
379
421
|
class_1.prototype.emitChange = function (submitOnChange) {
|
|
380
|
-
var _a;
|
|
381
422
|
if (submitOnChange === void 0) { submitOnChange = this.props.$schema.submitOnChange; }
|
|
382
|
-
var
|
|
423
|
+
var _a = this.props, form = _a.formStore, onChange = _a.onChange, _b = _a.$schema, name = _b.name, id = _b.id, label = _b.label, type = _b.type, onFormItemChange = _b.onChange; _b.maxLength; _b.minLength; var data = _a.data, env = _a.env; _a.validateOnChange; _a.formSubmited;
|
|
383
424
|
if (!this.model) {
|
|
384
425
|
return;
|
|
385
426
|
}
|
|
427
|
+
var model = this.model;
|
|
386
428
|
var value = this.model.tmpValue;
|
|
387
|
-
var oldValue =
|
|
388
|
-
|
|
429
|
+
var oldValue = model.extraName
|
|
430
|
+
? [
|
|
431
|
+
getVariable(data, model.name, false),
|
|
432
|
+
getVariable(data, model.extraName, false)
|
|
433
|
+
]
|
|
434
|
+
: getVariable(data, model.name, false);
|
|
435
|
+
if (model.extraName ? isEqual(oldValue, value) : oldValue === value) {
|
|
389
436
|
return;
|
|
390
437
|
}
|
|
391
438
|
if (type !== 'input-password') {
|
|
@@ -408,19 +455,15 @@ function wrapControl(ComposedComponent) {
|
|
|
408
455
|
if (!this.model) {
|
|
409
456
|
return;
|
|
410
457
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
// this.model.rules.minLength ||
|
|
416
|
-
// this.model.rules.maxLength ||
|
|
417
|
-
validateOnChange === true ||
|
|
418
|
-
(validateOnChange !== false && (formSubmited || validated))) {
|
|
419
|
-
this.validate();
|
|
458
|
+
if (model.extraName) {
|
|
459
|
+
var values = model.splitExtraValue(value);
|
|
460
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values[0], name);
|
|
461
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values[1], model.extraName, submitOnChange === true);
|
|
420
462
|
}
|
|
421
|
-
else
|
|
422
|
-
|
|
463
|
+
else {
|
|
464
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, submitOnChange === true);
|
|
423
465
|
}
|
|
466
|
+
this.checkValidate();
|
|
424
467
|
};
|
|
425
468
|
class_1.prototype.handleBlur = function (e) {
|
|
426
469
|
var _a = this.props, onBlur = _a.onBlur, validateOnBlur = _a.$schema.validateOnBlur;
|
|
@@ -433,17 +476,25 @@ function wrapControl(ComposedComponent) {
|
|
|
433
476
|
if (!this.model) {
|
|
434
477
|
return;
|
|
435
478
|
}
|
|
479
|
+
var model = this.model;
|
|
436
480
|
var _a = this.props; _a.formStore; var name = _a.name, pipeOut = _a.$schema.pipeOut, onChange = _a.onChange, oldValue = _a.value, data = _a.data;
|
|
437
481
|
if (pipeOut) {
|
|
438
|
-
value = pipeOut(value, oldValue, data);
|
|
482
|
+
value = pipeOut.call(this, value, oldValue, data);
|
|
483
|
+
}
|
|
484
|
+
if (model.extraName) {
|
|
485
|
+
var values = model.splitExtraValue(value);
|
|
486
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values[0], name, false, true);
|
|
487
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values[1], model.extraName, false, true);
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, false, true);
|
|
439
491
|
}
|
|
440
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, false, true);
|
|
441
492
|
};
|
|
442
493
|
class_1.prototype.getValue = function () {
|
|
443
494
|
var _a = this.props, data = _a.formStore, control = _a.$schema;
|
|
444
495
|
var value = this.model ? this.model.tmpValue : control.value;
|
|
445
496
|
if (control.pipeIn) {
|
|
446
|
-
value = control.pipeIn(value, data);
|
|
497
|
+
value = control.pipeIn.call(this, value, data);
|
|
447
498
|
}
|
|
448
499
|
return value;
|
|
449
500
|
};
|
|
@@ -477,6 +528,7 @@ function wrapControl(ComposedComponent) {
|
|
|
477
528
|
ref: this.controlRef,
|
|
478
529
|
data: data || (store === null || store === void 0 ? void 0 : store.data),
|
|
479
530
|
value: value,
|
|
531
|
+
changeMotivation: model === null || model === void 0 ? void 0 : model.changeMotivation,
|
|
480
532
|
defaultValue: control.value,
|
|
481
533
|
formItemValue: value,
|
|
482
534
|
onChange: this.handleChange,
|
package/esm/store/app.js
CHANGED
|
@@ -1,13 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { __assign } from 'tslib';
|
|
7
7
|
import { types } from 'mobx-state-tree';
|
|
8
|
-
import { mapTree, findTree, guid } from '../utils/helper.js';
|
|
8
|
+
import { mapTree, findTree, isVisible, guid } from '../utils/helper.js';
|
|
9
9
|
import { ServiceStore } from './service.js';
|
|
10
|
+
import '../utils/api.js';
|
|
11
|
+
import '../utils/ColorScale.js';
|
|
12
|
+
import 'react';
|
|
13
|
+
import 'lodash/chunk';
|
|
14
|
+
import 'amis-formula';
|
|
15
|
+
import 'lodash/isPlainObject';
|
|
10
16
|
import { createObject } from '../utils/object.js';
|
|
17
|
+
import '../utils/DataSchema.js';
|
|
18
|
+
import '../utils/DataScope.js';
|
|
19
|
+
import 'moment';
|
|
20
|
+
import '../utils/debug.js';
|
|
21
|
+
import 'react-dom';
|
|
22
|
+
import '../utils/errors.js';
|
|
23
|
+
import { filter } from '../utils/tpl.js';
|
|
24
|
+
import 'classnames';
|
|
25
|
+
import '../utils/filter.js';
|
|
26
|
+
import 'lodash/isObject';
|
|
27
|
+
import 'lodash/isString';
|
|
28
|
+
import 'lodash/isBoolean';
|
|
29
|
+
import '../utils/image.js';
|
|
30
|
+
import 'lodash/isEqual';
|
|
31
|
+
import '../actions/Action.js';
|
|
32
|
+
import 'lodash/debounce';
|
|
33
|
+
import 'lodash/cloneDeep';
|
|
34
|
+
import '../utils/resize-sensor.js';
|
|
35
|
+
import 'react-overlays/useRootClose';
|
|
36
|
+
import '../utils/SimpleMap.js';
|
|
37
|
+
import 'lodash/mapValues';
|
|
38
|
+
import 'lodash/camelCase';
|
|
39
|
+
import 'uncontrollable';
|
|
40
|
+
import 'hoist-non-react-statics';
|
|
41
|
+
import '../utils/validations.js';
|
|
42
|
+
import '../utils/resolveCondition.js';
|
|
43
|
+
import 'mobx';
|
|
44
|
+
import '../utils/Animation.js';
|
|
11
45
|
|
|
12
46
|
var AppStore = ServiceStore.named('AppStore')
|
|
13
47
|
.props({
|
|
@@ -20,7 +54,7 @@ var AppStore = ServiceStore.named('AppStore')
|
|
|
20
54
|
get navigations() {
|
|
21
55
|
if (Array.isArray(self.pages)) {
|
|
22
56
|
return mapTree(self.pages, function (item) {
|
|
23
|
-
var visible = item.
|
|
57
|
+
var visible = isVisible(item, self.data);
|
|
24
58
|
if (visible !== false &&
|
|
25
59
|
item.path &&
|
|
26
60
|
!~item.path.indexOf('http') &&
|
|
@@ -33,7 +67,11 @@ var AppStore = ServiceStore.named('AppStore')
|
|
|
33
67
|
path: item.path,
|
|
34
68
|
children: item.children,
|
|
35
69
|
className: item.className,
|
|
36
|
-
visible: visible
|
|
70
|
+
visible: visible,
|
|
71
|
+
badge: typeof item.badge === 'string'
|
|
72
|
+
? filter(item.badge, self.data)
|
|
73
|
+
: item.badge,
|
|
74
|
+
badgeClassName: filter(item.badgeClassName, self.data)
|
|
37
75
|
};
|
|
38
76
|
});
|
|
39
77
|
}
|