amis-core 2.9.0 → 3.1.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.d.ts +89 -4
- package/esm/Root.js +15 -4
- package/esm/RootRenderer.d.ts +3 -1
- package/esm/RootRenderer.js +9 -3
- package/esm/SchemaRenderer.d.ts +4 -2
- package/esm/SchemaRenderer.js +32 -24
- package/esm/Scoped.d.ts +8 -0
- package/esm/Scoped.js +20 -5
- package/esm/StatusScoped.d.ts +58 -0
- package/esm/StatusScoped.js +54 -0
- package/esm/WithRootStore.d.ts +2 -2
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +6 -2
- package/esm/actions/Action.d.ts +1 -0
- package/esm/actions/Action.js +19 -5
- 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 +8 -7
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +4 -4
- package/esm/actions/DialogAction.d.ts +16 -2
- package/esm/actions/DialogAction.js +23 -7
- 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/CustomStyle.d.ts +13 -0
- package/esm/components/CustomStyle.js +18 -0
- package/esm/components/LazyComponent.d.ts +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.d.ts +3 -3
- package/esm/components/Overlay.js +1 -1
- package/esm/components/PopOver.d.ts +2 -2
- package/esm/components/PopOver.js +1 -1
- package/esm/env.d.ts +10 -2
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -5
- package/esm/factory.d.ts +5 -3
- package/esm/factory.js +3 -3
- package/esm/index.d.ts +11 -4
- package/esm/index.js +55 -33
- package/esm/locale.d.ts +2 -2
- package/esm/locale.js +10 -3
- package/esm/renderers/Form.d.ts +3 -2
- package/esm/renderers/Form.js +216 -180
- package/esm/renderers/Item.d.ts +55 -41
- package/esm/renderers/Item.js +30 -19
- package/esm/renderers/Options.js +11 -4
- 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 +2 -2
- package/esm/renderers/wrapControl.js +13 -16
- package/esm/store/app.d.ts +1 -0
- package/esm/store/app.js +1 -1
- package/esm/store/combo.d.ts +3 -0
- package/esm/store/combo.js +1 -1
- package/esm/store/crud.d.ts +2 -0
- package/esm/store/crud.js +31 -9
- package/esm/store/form.d.ts +1 -0
- package/esm/store/form.js +10 -4
- package/esm/store/formItem.js +2 -2
- package/esm/store/iRenderer.d.ts +1 -0
- package/esm/store/iRenderer.js +54 -13
- package/esm/store/index.js +1 -1
- package/esm/store/list.d.ts +1 -0
- package/esm/store/list.js +7 -3
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.d.ts +1 -0
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.d.ts +1 -0
- package/esm/store/pagination.js +2 -2
- package/esm/store/root.d.ts +4 -6
- package/esm/store/root.js +53 -24
- package/esm/store/service.d.ts +1 -0
- package/esm/store/service.js +1 -1
- package/esm/store/status.d.ts +12 -0
- package/esm/store/status.js +38 -0
- package/esm/store/table.d.ts +28 -23
- package/esm/store/table.js +26 -5
- package/esm/store/table2.d.ts +7 -6
- package/esm/store/table2.js +27 -23
- package/esm/theme.d.ts +1 -1
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +7 -1
- 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.d.ts +3 -5
- package/esm/utils/DataScope.js +88 -31
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.js +14 -5
- package/esm/utils/attachmentAdpator.js +2 -2
- 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.d.ts +7 -0
- package/esm/utils/date.js +34 -2
- package/esm/utils/debug.js +4 -4
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.d.ts +3 -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 +3 -3
- package/esm/utils/handleAction.js +1 -1
- package/esm/utils/helper.d.ts +9 -2
- package/esm/utils/helper.js +52 -20
- 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 +3 -3
- 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/memoryParse.d.ts +17 -0
- package/esm/utils/memoryParse.js +26 -0
- package/esm/utils/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +4 -2
- package/esm/utils/object.d.ts +2 -0
- package/esm/utils/object.js +27 -2
- 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 +4 -3
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
- package/esm/utils/resolveVariableAndFilterForAsync.js +23 -5
- 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 +12 -4
- package/esm/utils/style-helper.js +96 -19
- package/esm/utils/style.js +2 -2
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.d.ts +2 -1
- package/esm/utils/tpl-builtin.js +19 -2
- 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.d.ts +89 -4
- package/lib/Root.js +15 -4
- package/lib/RootRenderer.d.ts +3 -1
- package/lib/RootRenderer.js +8 -2
- package/lib/SchemaRenderer.d.ts +4 -2
- package/lib/SchemaRenderer.js +32 -23
- package/lib/Scoped.d.ts +8 -0
- package/lib/Scoped.js +20 -4
- package/lib/StatusScoped.d.ts +58 -0
- package/lib/StatusScoped.js +63 -0
- package/lib/WithRootStore.d.ts +2 -2
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +6 -2
- package/lib/actions/Action.d.ts +1 -0
- package/lib/actions/Action.js +19 -5
- 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 +8 -7
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +4 -4
- package/lib/actions/DialogAction.d.ts +16 -2
- package/lib/actions/DialogAction.js +23 -7
- 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/CustomStyle.d.ts +13 -0
- package/lib/components/CustomStyle.js +22 -0
- package/lib/components/LazyComponent.d.ts +1 -1
- package/lib/components/LazyComponent.js +1 -1
- package/lib/components/Overlay.d.ts +3 -3
- package/lib/components/Overlay.js +1 -1
- package/lib/components/PopOver.d.ts +2 -2
- package/lib/components/PopOver.js +1 -1
- package/lib/env.d.ts +10 -2
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +1 -5
- package/lib/factory.d.ts +5 -3
- package/lib/factory.js +3 -3
- package/lib/index.d.ts +11 -4
- package/lib/index.js +61 -23
- package/lib/locale.d.ts +2 -2
- package/lib/locale.js +10 -3
- package/lib/renderers/Form.d.ts +3 -2
- package/lib/renderers/Form.js +215 -179
- package/lib/renderers/Item.d.ts +55 -41
- package/lib/renderers/Item.js +30 -19
- package/lib/renderers/Options.js +11 -4
- 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 +2 -2
- package/lib/renderers/wrapControl.js +12 -15
- package/lib/store/app.d.ts +1 -0
- package/lib/store/app.js +1 -1
- package/lib/store/combo.d.ts +3 -0
- package/lib/store/combo.js +1 -1
- package/lib/store/crud.d.ts +2 -0
- package/lib/store/crud.js +31 -9
- package/lib/store/form.d.ts +1 -0
- package/lib/store/form.js +10 -4
- package/lib/store/formItem.js +2 -2
- package/lib/store/iRenderer.d.ts +1 -0
- package/lib/store/iRenderer.js +53 -12
- package/lib/store/index.js +1 -1
- package/lib/store/list.d.ts +1 -0
- package/lib/store/list.js +7 -3
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.d.ts +1 -0
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.d.ts +1 -0
- package/lib/store/pagination.js +2 -2
- package/lib/store/root.d.ts +4 -6
- package/lib/store/root.js +52 -23
- package/lib/store/service.d.ts +1 -0
- package/lib/store/service.js +1 -1
- package/lib/store/status.d.ts +12 -0
- package/lib/store/status.js +42 -0
- package/lib/store/table.d.ts +28 -23
- package/lib/store/table.js +26 -5
- package/lib/store/table2.d.ts +7 -6
- package/lib/store/table2.js +27 -23
- package/lib/theme.d.ts +1 -1
- package/lib/theme.js +1 -1
- package/lib/types.d.ts +7 -1
- 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.d.ts +3 -5
- package/lib/utils/DataScope.js +86 -29
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.js +13 -4
- package/lib/utils/attachmentAdpator.js +2 -2
- 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.d.ts +7 -0
- package/lib/utils/date.js +34 -1
- package/lib/utils/debug.js +4 -4
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.d.ts +3 -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 +3 -3
- package/lib/utils/handleAction.js +1 -1
- package/lib/utils/helper.d.ts +9 -2
- package/lib/utils/helper.js +53 -19
- 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 +3 -3
- 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/memoryParse.d.ts +17 -0
- package/lib/utils/memoryParse.js +30 -0
- package/lib/utils/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +4 -2
- package/lib/utils/object.d.ts +2 -0
- package/lib/utils/object.js +28 -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 +3 -2
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
- package/lib/utils/resolveVariableAndFilterForAsync.js +22 -3
- 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 +12 -4
- package/lib/utils/style-helper.js +101 -18
- package/lib/utils/style.js +2 -2
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.d.ts +2 -1
- package/lib/utils/tpl-builtin.js +19 -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/esm/utils/validations.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -348,12 +348,16 @@ var validateMessages = {
|
|
|
348
348
|
isVariableName: 'validate.isVariableName'
|
|
349
349
|
};
|
|
350
350
|
function validate(value, values, rules, messages, __) {
|
|
351
|
+
var _a;
|
|
351
352
|
if (__ === void 0) { __ = function (str) { return str; }; }
|
|
352
353
|
var errors = [];
|
|
353
|
-
rules
|
|
354
|
-
Object.keys(rules)
|
|
354
|
+
if (rules) {
|
|
355
|
+
var ruleNames = Object.keys(rules);
|
|
356
|
+
var length_1 = ruleNames.length;
|
|
357
|
+
for (var index = 0; index < length_1; index++) {
|
|
358
|
+
var ruleName = ruleNames[index];
|
|
355
359
|
if (!rules[ruleName] && rules[ruleName] !== 0) {
|
|
356
|
-
|
|
360
|
+
continue;
|
|
357
361
|
}
|
|
358
362
|
else if (typeof validations[ruleName] !== 'function') {
|
|
359
363
|
throw new Error('Validation `' + ruleName + '` not exists!');
|
|
@@ -365,19 +369,30 @@ function validate(value, values, rules, messages, __) {
|
|
|
365
369
|
}
|
|
366
370
|
return item;
|
|
367
371
|
});
|
|
368
|
-
|
|
372
|
+
var validateRes = fn.apply(void 0, __spreadArray([values, value], __read(args), false));
|
|
373
|
+
// addRule 允许返回
|
|
374
|
+
// {error: true, msg: '错误提示'}
|
|
375
|
+
// 格式的信息来灵活展示错误
|
|
376
|
+
var fnResErrorMsg = '';
|
|
377
|
+
if (typeof validateRes === 'object' &&
|
|
378
|
+
validateRes.error === true) {
|
|
379
|
+
fnResErrorMsg = (_a = validateRes === null || validateRes === void 0 ? void 0 : validateRes.msg) !== null && _a !== void 0 ? _a : '';
|
|
380
|
+
}
|
|
381
|
+
if (!validateRes || fnResErrorMsg) {
|
|
369
382
|
var msgRuleName = ruleName;
|
|
370
383
|
if (Array.isArray(value)) {
|
|
371
384
|
msgRuleName = "".concat(ruleName, "Array");
|
|
372
385
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
386
|
+
return [{
|
|
387
|
+
rule: ruleName,
|
|
388
|
+
msg: filter(__((messages && messages[ruleName]) ||
|
|
389
|
+
fnResErrorMsg ||
|
|
390
|
+
validateMessages[msgRuleName] ||
|
|
391
|
+
validateMessages[ruleName]), __assign({}, [''].concat(args)))
|
|
392
|
+
}];
|
|
379
393
|
}
|
|
380
|
-
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
381
396
|
return errors;
|
|
382
397
|
}
|
|
383
398
|
function validateObject(values, rules, messages, __) {
|
package/lib/Root.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
/// <reference types="hoist-non-react-statics" />
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { RendererEnv } from './env';
|
|
3
4
|
import { RendererProps } from './factory';
|
|
4
5
|
import { TranslateFn } from './locale';
|
|
5
6
|
import { IRendererStore } from './store';
|
|
6
7
|
import { SchemaNode } from './types';
|
|
8
|
+
import { StatusScopedProps } from './StatusScoped';
|
|
7
9
|
export interface RootRenderProps {
|
|
8
10
|
location?: Location;
|
|
9
11
|
theme?: string;
|
|
12
|
+
data?: Record<string, any>;
|
|
13
|
+
locale?: string;
|
|
10
14
|
[propName: string]: any;
|
|
11
15
|
}
|
|
12
|
-
export interface RootProps {
|
|
16
|
+
export interface RootProps extends StatusScopedProps {
|
|
13
17
|
schema: SchemaNode;
|
|
14
18
|
rootStore: IRendererStore;
|
|
15
19
|
env: RendererEnv;
|
|
@@ -25,22 +29,103 @@ export interface RootWrapperProps {
|
|
|
25
29
|
schema: SchemaNode;
|
|
26
30
|
rootStore: IRendererStore;
|
|
27
31
|
theme: string;
|
|
32
|
+
data?: Record<string, any>;
|
|
33
|
+
context?: Record<string, any>;
|
|
28
34
|
[propName: string]: any;
|
|
29
35
|
}
|
|
30
36
|
export declare function addRootWrapper(fn: (props: RootWrapperProps) => React.ReactNode): void;
|
|
31
37
|
export declare class Root extends React.Component<RootProps> {
|
|
32
38
|
resolveDefinitions(name: string): {} | undefined;
|
|
33
|
-
render(): JSX.Element;
|
|
39
|
+
render(): React.JSX.Element;
|
|
34
40
|
}
|
|
35
|
-
export interface renderChildProps extends Partial<RendererProps
|
|
41
|
+
export interface renderChildProps extends Partial<Omit<RendererProps, 'statusStore'>>, StatusScopedProps {
|
|
36
42
|
env: RendererEnv;
|
|
37
43
|
}
|
|
38
44
|
export type ReactElement = React.ReactNode[] | JSX.Element | null | false;
|
|
39
45
|
export declare function renderChildren(prefix: string, node: SchemaNode, props: renderChildProps): ReactElement;
|
|
40
46
|
export declare function renderChild(prefix: string, node: SchemaNode, props: renderChildProps): ReactElement;
|
|
41
|
-
declare const _default:
|
|
47
|
+
declare const _default: {
|
|
48
|
+
new (props: Omit<RootProps & {
|
|
49
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
50
|
+
}, "statusStore">): {
|
|
51
|
+
store?: ({
|
|
52
|
+
visibleState: any;
|
|
53
|
+
disableState: any;
|
|
54
|
+
staticState: any;
|
|
55
|
+
} & import("mobx-state-tree/dist/internal").NonEmptyObject & {
|
|
56
|
+
setVisible(key: string, value?: boolean | undefined): void;
|
|
57
|
+
setDisable(key: string, value?: boolean | undefined): void;
|
|
58
|
+
setStatic(key: string, value?: boolean | undefined): void;
|
|
59
|
+
resetAll(): void;
|
|
60
|
+
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
61
|
+
visibleState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
62
|
+
disableState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
63
|
+
staticState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
64
|
+
}, {
|
|
65
|
+
setVisible(key: string, value?: boolean | undefined): void;
|
|
66
|
+
setDisable(key: string, value?: boolean | undefined): void;
|
|
67
|
+
setStatic(key: string, value?: boolean | undefined): void;
|
|
68
|
+
resetAll(): void;
|
|
69
|
+
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>) | undefined;
|
|
70
|
+
ref: any;
|
|
71
|
+
childRef(ref: any): void;
|
|
72
|
+
getWrappedInstance(): any;
|
|
73
|
+
componentWillUnmount(): void;
|
|
74
|
+
render(): React.JSX.Element;
|
|
75
|
+
context: unknown;
|
|
76
|
+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<Omit<RootProps & {
|
|
77
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
78
|
+
}, "statusStore">>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
79
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
80
|
+
readonly props: Readonly<Omit<RootProps & {
|
|
81
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
82
|
+
}, "statusStore">>;
|
|
83
|
+
state: Readonly<{}>;
|
|
84
|
+
refs: {
|
|
85
|
+
[key: string]: React.ReactInstance;
|
|
86
|
+
};
|
|
87
|
+
componentDidMount?(): void;
|
|
88
|
+
shouldComponentUpdate?(nextProps: Readonly<Omit<RootProps & {
|
|
89
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
90
|
+
}, "statusStore">>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
91
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
92
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<Omit<RootProps & {
|
|
93
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
94
|
+
}, "statusStore">>, prevState: Readonly<{}>): any;
|
|
95
|
+
componentDidUpdate?(prevProps: Readonly<Omit<RootProps & {
|
|
96
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
97
|
+
}, "statusStore">>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
98
|
+
componentWillMount?(): void;
|
|
99
|
+
UNSAFE_componentWillMount?(): void;
|
|
100
|
+
componentWillReceiveProps?(nextProps: Readonly<Omit<RootProps & {
|
|
101
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
102
|
+
}, "statusStore">>, nextContext: any): void;
|
|
103
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<Omit<RootProps & {
|
|
104
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
105
|
+
}, "statusStore">>, nextContext: any): void;
|
|
106
|
+
componentWillUpdate?(nextProps: Readonly<Omit<RootProps & {
|
|
107
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
108
|
+
}, "statusStore">>, nextState: Readonly<{}>, nextContext: any): void;
|
|
109
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<Omit<RootProps & {
|
|
110
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
111
|
+
}, "statusStore">>, nextState: Readonly<{}>, nextContext: any): void;
|
|
112
|
+
};
|
|
113
|
+
displayName: string;
|
|
114
|
+
ComposedComponent: React.ComponentType<React.ComponentType<RootProps & {
|
|
115
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
116
|
+
}> & {
|
|
117
|
+
ComposedComponent: React.ComponentType<RootProps>;
|
|
118
|
+
}>;
|
|
119
|
+
contextType?: React.Context<any> | undefined;
|
|
120
|
+
} & import("hoist-non-react-statics").NonReactStatics<React.ComponentType<RootProps & {
|
|
42
121
|
scopeRef?: ((ref: any) => void) | undefined;
|
|
43
122
|
}> & {
|
|
44
123
|
ComposedComponent: React.ComponentType<RootProps>;
|
|
124
|
+
}, {}> & {
|
|
125
|
+
ComposedComponent: React.ComponentType<RootProps & {
|
|
126
|
+
scopeRef?: ((ref: any) => void) | undefined;
|
|
127
|
+
}> & {
|
|
128
|
+
ComposedComponent: React.ComponentType<RootProps>;
|
|
129
|
+
};
|
|
45
130
|
};
|
|
46
131
|
export default _default;
|
package/lib/Root.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -17,6 +17,7 @@ var Scoped = require('./Scoped.js');
|
|
|
17
17
|
var theme = require('./theme.js');
|
|
18
18
|
var helper = require('./utils/helper.js');
|
|
19
19
|
var WithRootStore = require('./WithRootStore.js');
|
|
20
|
+
var StatusScoped = require('./StatusScoped.js');
|
|
20
21
|
|
|
21
22
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
23
|
|
|
@@ -40,7 +41,7 @@ var Root = /** @class */ (function (_super) {
|
|
|
40
41
|
return definitions && definitions[name];
|
|
41
42
|
};
|
|
42
43
|
Root.prototype.render = function () {
|
|
43
|
-
var _a = this.props, schema = _a.schema, rootStore = _a.rootStore, env = _a.env, pathPrefix = _a.pathPrefix, location = _a.location, data = _a.data, locale$1 = _a.locale, translate = _a.translate, rest = tslib.__rest(_a, ["schema", "rootStore", "env", "pathPrefix", "location", "data", "locale", "translate"]);
|
|
44
|
+
var _a = this.props, schema = _a.schema, rootStore = _a.rootStore, env = _a.env, pathPrefix = _a.pathPrefix, location = _a.location, data = _a.data, context = _a.context, locale$1 = _a.locale, translate = _a.translate, rest = tslib.__rest(_a, ["schema", "rootStore", "env", "pathPrefix", "location", "data", "context", "locale", "translate"]);
|
|
44
45
|
var theme$1 = env.theme;
|
|
45
46
|
var themeName = this.props.theme || 'cxd';
|
|
46
47
|
if (themeName === 'default') {
|
|
@@ -52,7 +53,7 @@ var Root = /** @class */ (function (_super) {
|
|
|
52
53
|
return tslib.__assign(tslib.__assign({}, props), { children: wrapper(props) });
|
|
53
54
|
}, tslib.__assign(tslib.__assign({ pathPrefix: pathPrefix || '', schema: isPlainObject__default["default"](schema)
|
|
54
55
|
? tslib.__assign({ type: 'page' }, schema) : schema }, rest), { render: renderChild, rootStore: rootStore, resolveDefinitions: this.resolveDefinitions, location: location, data: data, env: env, classnames: theme$1.classnames, classPrefix: theme$1.classPrefix, locale: locale$1, translate: translate, children: (React__default["default"].createElement(RootRenderer.RootRenderer, tslib.__assign({ pathPrefix: pathPrefix || '', schema: isPlainObject__default["default"](schema)
|
|
55
|
-
? tslib.__assign({ type: 'page' }, schema) : schema }, rest, { render: renderChild, rootStore: rootStore, resolveDefinitions: this.resolveDefinitions, location: location, data: data, env: env, classnames: theme$1.classnames, classPrefix: theme$1.classPrefix, locale: locale$1, translate: translate }))) })).children))));
|
|
56
|
+
? tslib.__assign({ type: 'page' }, schema) : schema }, rest, { render: renderChild, rootStore: rootStore, resolveDefinitions: this.resolveDefinitions, location: location, data: data, context: context, env: env, classnames: theme$1.classnames, classPrefix: theme$1.classPrefix, locale: locale$1, translate: translate }))) })).children))));
|
|
56
57
|
};
|
|
57
58
|
tslib.__decorate([
|
|
58
59
|
helper.autobind,
|
|
@@ -62,6 +63,7 @@ var Root = /** @class */ (function (_super) {
|
|
|
62
63
|
], Root.prototype, "resolveDefinitions", null);
|
|
63
64
|
return Root;
|
|
64
65
|
}(React__default["default"].Component));
|
|
66
|
+
var StatusScopedSchemaRenderer = StatusScoped.StatusScoped(SchemaRenderer.SchemaRenderer);
|
|
65
67
|
function renderChildren(prefix, node, props) {
|
|
66
68
|
if (Array.isArray(node)) {
|
|
67
69
|
var elemKey = props.key || props.propKey || props.id || '';
|
|
@@ -91,9 +93,18 @@ function renderChild(prefix, node, props) {
|
|
|
91
93
|
delete props.propsTransform;
|
|
92
94
|
props = transform(props);
|
|
93
95
|
}
|
|
96
|
+
if (['dialog', 'drawer'].includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
|
|
97
|
+
!(schema === null || schema === void 0 ? void 0 : schema.component) &&
|
|
98
|
+
!(schema === null || schema === void 0 ? void 0 : schema.children)) {
|
|
99
|
+
// 因为状态判断实在 SchemaRenderer 里面判断的
|
|
100
|
+
// 找渲染器也是在那,所以没办法在之前根据渲染器信息来包裹个组件下发 statusStore
|
|
101
|
+
// 所以这里先根据 type 来处理一下
|
|
102
|
+
// 等后续把状态处理再抽一层,可以把此处放到 SchemaRenderer 里面去
|
|
103
|
+
return (React__default["default"].createElement(StatusScopedSchemaRenderer, tslib.__assign({ render: renderChild }, props, { schema: schema, propKey: schema.key, "$path": "".concat(prefix ? "".concat(prefix, "/") : '').concat((schema && schema.type) || '') })));
|
|
104
|
+
}
|
|
94
105
|
return (React__default["default"].createElement(SchemaRenderer.SchemaRenderer, tslib.__assign({ render: renderChild }, props, { schema: schema, propKey: schema.key, "$path": "".concat(prefix ? "".concat(prefix, "/") : '').concat((schema && schema.type) || '') })));
|
|
95
106
|
}
|
|
96
|
-
var ScopedRootRenderer = Scoped.HocScoped(Root);
|
|
107
|
+
var ScopedRootRenderer = StatusScoped.StatusScoped(Scoped.HocScoped(Root));
|
|
97
108
|
|
|
98
109
|
exports.Root = Root;
|
|
99
110
|
exports.addRootWrapper = addRootWrapper;
|
package/lib/RootRenderer.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { IRootStore } from './store/root';
|
|
|
5
5
|
import { ActionObject } from './types';
|
|
6
6
|
export interface RootRendererProps extends RootProps {
|
|
7
7
|
location?: any;
|
|
8
|
+
data?: Record<string, any>;
|
|
9
|
+
context?: Record<string, any>;
|
|
8
10
|
render: (region: string, schema: any, props: any) => React.ReactNode;
|
|
9
11
|
}
|
|
10
12
|
export declare class RootRenderer extends React.Component<RootRendererProps> {
|
|
@@ -23,5 +25,5 @@ export declare class RootRenderer extends React.Component<RootRendererProps> {
|
|
|
23
25
|
handleDrawerClose(): void;
|
|
24
26
|
openFeedback(dialog: any, ctx: any): Promise<unknown>;
|
|
25
27
|
reloadTarget(scoped: IScopedContext, target: string, data?: any): void;
|
|
26
|
-
render(): string | number | boolean | JSX.Element | React.ReactFragment | null | undefined;
|
|
28
|
+
render(): string | number | boolean | React.JSX.Element | React.ReactFragment | null | undefined;
|
|
27
29
|
}
|
package/lib/RootRenderer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -39,6 +39,7 @@ var RootRenderer = /** @class */ (function (_super) {
|
|
|
39
39
|
storeType: root.RootStore.name,
|
|
40
40
|
parentId: ''
|
|
41
41
|
});
|
|
42
|
+
_this.store.setContext(props.context);
|
|
42
43
|
_this.store.initData(props.data);
|
|
43
44
|
_this.store.updateLocation(props.location, (_a = _this.props.env) === null || _a === void 0 ? void 0 : _a.parseLocation);
|
|
44
45
|
helper.bulkBindFunctions(_this, [
|
|
@@ -62,8 +63,13 @@ var RootRenderer = /** @class */ (function (_super) {
|
|
|
62
63
|
if (props.location !== prevProps.location) {
|
|
63
64
|
this.store.updateLocation(props.location);
|
|
64
65
|
}
|
|
66
|
+
if (props.context !== prevProps.context) {
|
|
67
|
+
this.store.setContext(props.context);
|
|
68
|
+
}
|
|
65
69
|
};
|
|
66
70
|
RootRenderer.prototype.componentDidCatch = function (error, errorInfo) {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
(_b = (_a = this.props.env) === null || _a === void 0 ? void 0 : _a.errorCatcher) === null || _b === void 0 ? void 0 : _b.call(_a, error, errorInfo);
|
|
67
73
|
this.store.setRuntimeError(error, errorInfo);
|
|
68
74
|
};
|
|
69
75
|
RootRenderer.prototype.componentWillUnmount = function () {
|
|
@@ -160,7 +166,7 @@ var RootRenderer = /** @class */ (function (_super) {
|
|
|
160
166
|
redirect = action.redirect && tpl.filter(action.redirect, store.data);
|
|
161
167
|
redirect && env.jumpTo(redirect, action);
|
|
162
168
|
action.reload &&
|
|
163
|
-
this.reloadTarget(delegate || this.context,
|
|
169
|
+
this.reloadTarget(delegate || this.context, Scoped.filterTarget(action.reload, ctx), store.data);
|
|
164
170
|
return [2 /*return*/];
|
|
165
171
|
}
|
|
166
172
|
});
|
package/lib/SchemaRenderer.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ import { RendererConfig, RendererEnv, RendererProps } from './factory';
|
|
|
3
3
|
import { IScopedContext } from './Scoped';
|
|
4
4
|
import { Schema, SchemaNode } from './types';
|
|
5
5
|
import { RendererEvent } from './utils/renderer-event';
|
|
6
|
-
|
|
6
|
+
import { StatusScopedProps } from './StatusScoped';
|
|
7
|
+
interface SchemaRendererProps extends Partial<Omit<RendererProps, 'statusStore'>>, StatusScopedProps {
|
|
7
8
|
schema: Schema;
|
|
8
9
|
$path: string;
|
|
9
10
|
env: RendererEnv;
|
|
10
11
|
}
|
|
12
|
+
export declare const RENDERER_TRANSMISSION_OMIT_PROPS: string[];
|
|
11
13
|
export declare class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
|
12
14
|
static displayName: string;
|
|
13
15
|
static contextType: React.Context<IScopedContext>;
|
|
@@ -31,7 +33,7 @@ export declare class SchemaRenderer extends React.Component<SchemaRendererProps,
|
|
|
31
33
|
renderChild(region: string, node?: SchemaNode, subProps?: {
|
|
32
34
|
data?: object;
|
|
33
35
|
[propName: string]: any;
|
|
34
|
-
}):
|
|
36
|
+
}): any;
|
|
35
37
|
reRender(): void;
|
|
36
38
|
render(): JSX.Element | null;
|
|
37
39
|
}
|
package/lib/SchemaRenderer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -28,6 +28,7 @@ require('lodash/isPlainObject');
|
|
|
28
28
|
var resolveVariableAndFilter = require('./utils/resolveVariableAndFilter.js');
|
|
29
29
|
require('./utils/filter.js');
|
|
30
30
|
var style = require('./utils/style.js');
|
|
31
|
+
var tpl = require('./utils/tpl.js');
|
|
31
32
|
|
|
32
33
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
33
34
|
|
|
@@ -35,7 +36,7 @@ var difference__default = /*#__PURE__*/_interopDefaultLegacy(difference);
|
|
|
35
36
|
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
36
37
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
37
38
|
|
|
38
|
-
var
|
|
39
|
+
var RENDERER_TRANSMISSION_OMIT_PROPS = [
|
|
39
40
|
'type',
|
|
40
41
|
'name',
|
|
41
42
|
'$ref',
|
|
@@ -60,7 +61,9 @@ var defaultOmitList = [
|
|
|
60
61
|
'mode',
|
|
61
62
|
'body',
|
|
62
63
|
'id',
|
|
63
|
-
'inputOnly'
|
|
64
|
+
'inputOnly',
|
|
65
|
+
'label',
|
|
66
|
+
'renderLabel'
|
|
64
67
|
];
|
|
65
68
|
var componentCache = new SimpleMap.SimpleMap();
|
|
66
69
|
var SchemaRenderer = /** @class */ (function (_super) {
|
|
@@ -74,9 +77,12 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
74
77
|
_this.reRender = _this.reRender.bind(_this);
|
|
75
78
|
_this.resolveRenderer(_this.props);
|
|
76
79
|
_this.dispatchEvent = _this.dispatchEvent.bind(_this);
|
|
77
|
-
// 监听
|
|
80
|
+
// 监听statusStore更新
|
|
78
81
|
_this.reaction = mobx.reaction(function () {
|
|
79
|
-
|
|
82
|
+
var _a, _b, _c;
|
|
83
|
+
var id = tpl.filter(props.schema.id, props.data);
|
|
84
|
+
var name = tpl.filter(props.schema.name, props.data);
|
|
85
|
+
return "".concat((_a = props.statusStore.visibleState[id]) !== null && _a !== void 0 ? _a : props.statusStore.visibleState[name]).concat((_b = props.statusStore.disableState[id]) !== null && _b !== void 0 ? _b : props.statusStore.disableState[name]).concat((_c = props.statusStore.staticState[id]) !== null && _c !== void 0 ? _c : props.statusStore.staticState[name]);
|
|
80
86
|
}, function () { return _this.forceUpdate(); });
|
|
81
87
|
return _this;
|
|
82
88
|
}
|
|
@@ -178,7 +184,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
178
184
|
if (subProps === void 0) { subProps = {}; }
|
|
179
185
|
var _a = this.props; _a.schema; _a.$path; var env = _a.env, render = _a.render, rest = tslib.__rest(_a, ["schema", "$path", "env", "render"]);
|
|
180
186
|
var $path = this.resolveRenderer(this.props).path;
|
|
181
|
-
var omitList =
|
|
187
|
+
var omitList = RENDERER_TRANSMISSION_OMIT_PROPS.concat();
|
|
182
188
|
if (this.renderer) {
|
|
183
189
|
var Component = this.renderer.component;
|
|
184
190
|
Component.propsList &&
|
|
@@ -193,12 +199,12 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
193
199
|
SchemaRenderer.prototype.render = function () {
|
|
194
200
|
var e_1, _a;
|
|
195
201
|
var _this = this;
|
|
196
|
-
var _b, _c, _d;
|
|
197
|
-
var
|
|
202
|
+
var _b, _c, _d, _e, _f, _g;
|
|
203
|
+
var _h = this.props; _h.$path; var __ = _h.schema, rootStore = _h.rootStore, statusStore = _h.statusStore, render = _h.render, rest = tslib.__rest(_h, ["$path", "schema", "rootStore", "statusStore", "render"]);
|
|
198
204
|
if (__ == null) {
|
|
199
205
|
return null;
|
|
200
206
|
}
|
|
201
|
-
var
|
|
207
|
+
var _j = this.resolveRenderer(this.props), $path = _j.path, schema = _j.schema;
|
|
202
208
|
var theme = this.props.env.theme;
|
|
203
209
|
if (Array.isArray(schema)) {
|
|
204
210
|
return render($path, schema, rest);
|
|
@@ -209,14 +215,16 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
209
215
|
? filterSchema.getExprProperties(schema, detectData, undefined, rest)
|
|
210
216
|
: {};
|
|
211
217
|
// 控制显隐
|
|
212
|
-
var
|
|
213
|
-
|
|
218
|
+
var id = tpl.filter(schema.id, rest.data);
|
|
219
|
+
var name = tpl.filter(schema.name, rest.data);
|
|
220
|
+
var visible = mobxStateTree.isAlive(statusStore)
|
|
221
|
+
? (_b = statusStore.visibleState[id]) !== null && _b !== void 0 ? _b : statusStore.visibleState[name]
|
|
214
222
|
: undefined;
|
|
215
|
-
var disable = mobxStateTree.isAlive(
|
|
216
|
-
?
|
|
223
|
+
var disable = mobxStateTree.isAlive(statusStore)
|
|
224
|
+
? (_c = statusStore.disableState[id]) !== null && _c !== void 0 ? _c : statusStore.disableState[name]
|
|
217
225
|
: undefined;
|
|
218
|
-
var isStatic = mobxStateTree.isAlive(
|
|
219
|
-
?
|
|
226
|
+
var isStatic = mobxStateTree.isAlive(statusStore)
|
|
227
|
+
? (_d = statusStore.staticState[id]) !== null && _d !== void 0 ? _d : statusStore.staticState[name]
|
|
220
228
|
: undefined;
|
|
221
229
|
if (visible === false ||
|
|
222
230
|
(visible !== true &&
|
|
@@ -234,7 +242,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
234
242
|
? null
|
|
235
243
|
: React__default["default"].isValidElement(schema.children)
|
|
236
244
|
? schema.children
|
|
237
|
-
: schema.children(tslib.__assign(tslib.__assign(tslib.__assign({}, rest), exprProps), { $path: $path, $schema: schema, render: this.renderChild, forwardedRef: this.refFn, rootStore: rootStore,
|
|
245
|
+
: schema.children(tslib.__assign(tslib.__assign(tslib.__assign({}, rest), exprProps), { $path: $path, $schema: schema, render: this.renderChild, forwardedRef: this.refFn, rootStore: rootStore, statusStore: statusStore, dispatchEvent: this.dispatchEvent }));
|
|
238
246
|
}
|
|
239
247
|
else if (typeof schema.component === 'function') {
|
|
240
248
|
var isSFC = !(schema.component.prototype instanceof React__default["default"].Component);
|
|
@@ -244,7 +252,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
244
252
|
? null
|
|
245
253
|
: React__default["default"].createElement(schema.component, tslib.__assign(tslib.__assign(tslib.__assign(tslib.__assign({}, rest), restSchema_1), exprProps), {
|
|
246
254
|
// value: defaultValue, // 备注: 此处并没有将value传递给渲染器
|
|
247
|
-
defaultData: defaultData_1, defaultValue: defaultValue_1, defaultActiveKey: defaultActiveKey_1, propKey: propKey_1, $path: $path, $schema: schema, ref: isSFC ? undefined : this.refFn, forwardedRef: isSFC ? this.refFn : undefined, render: this.renderChild, rootStore: rootStore,
|
|
255
|
+
defaultData: defaultData_1, defaultValue: defaultValue_1, defaultActiveKey: defaultActiveKey_1, propKey: propKey_1, $path: $path, $schema: schema, ref: isSFC ? undefined : this.refFn, forwardedRef: isSFC ? this.refFn : undefined, render: this.renderChild, rootStore: rootStore, statusStore: statusStore, dispatchEvent: this.dispatchEvent }));
|
|
248
256
|
}
|
|
249
257
|
else if (Object.keys(schema).length === 0) {
|
|
250
258
|
return null;
|
|
@@ -267,7 +275,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
267
275
|
return [2 /*return*/, function () { return factory.loadRenderer(schema, $path); }];
|
|
268
276
|
}
|
|
269
277
|
});
|
|
270
|
-
}); }, "$path": $path, "$schema": schema, retry: this.reRender, rootStore: rootStore,
|
|
278
|
+
}); }, "$path": $path, "$schema": schema, retry: this.reRender, rootStore: rootStore, statusStore: statusStore, dispatchEvent: this.dispatchEvent })));
|
|
271
279
|
}
|
|
272
280
|
var renderer = this.renderer;
|
|
273
281
|
schema = factory.filterSchema(schema, renderer, rest);
|
|
@@ -294,11 +302,11 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
294
302
|
// schema.style是readonly属性
|
|
295
303
|
schema = tslib.__assign(tslib.__assign({}, schema), { style: style.buildStyle(schema.style, detectData) });
|
|
296
304
|
}
|
|
297
|
-
var isClassComponent = (
|
|
305
|
+
var isClassComponent = (_e = Component.prototype) === null || _e === void 0 ? void 0 : _e.isReactComponent;
|
|
298
306
|
var $schema = tslib.__assign(tslib.__assign({}, schema), exprProps);
|
|
299
307
|
var props = tslib.__assign(tslib.__assign(tslib.__assign(tslib.__assign(tslib.__assign({}, theme.getRendererConfig(renderer.name)), restSchema), helper.chainEvents(rest, restSchema)), exprProps), {
|
|
300
308
|
// value: defaultValue, // 备注: 此处并没有将value传递给渲染器
|
|
301
|
-
defaultData: (
|
|
309
|
+
defaultData: (_f = restSchema.defaultData) !== null && _f !== void 0 ? _f : defaultData, defaultValue: (_g = restSchema.defaultValue) !== null && _g !== void 0 ? _g : defaultValue, defaultActiveKey: defaultActiveKey, propKey: propKey, $path: $path, $schema: $schema, ref: this.refFn, render: this.renderChild, rootStore: rootStore, statusStore: statusStore, dispatchEvent: this.dispatchEvent });
|
|
302
310
|
if (disable !== undefined) {
|
|
303
311
|
props.disabled = disable;
|
|
304
312
|
}
|
|
@@ -308,8 +316,8 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
308
316
|
// 自动解析变量模式,主要是方便直接引入第三方组件库,无需为了支持变量封装一层
|
|
309
317
|
if (renderer.autoVar) {
|
|
310
318
|
try {
|
|
311
|
-
for (var
|
|
312
|
-
var key =
|
|
319
|
+
for (var _k = tslib.__values(Object.keys($schema)), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
320
|
+
var key = _l.value;
|
|
313
321
|
if (typeof props[key] === 'string') {
|
|
314
322
|
props[key] = resolveVariableAndFilter.resolveVariableAndFilter(props[key], props.data, '| raw');
|
|
315
323
|
}
|
|
@@ -318,7 +326,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
318
326
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
319
327
|
finally {
|
|
320
328
|
try {
|
|
321
|
-
if (
|
|
329
|
+
if (_l && !_l.done && (_a = _k.return)) _a.call(_k);
|
|
322
330
|
}
|
|
323
331
|
finally { if (e_1) throw e_1.error; }
|
|
324
332
|
}
|
|
@@ -351,4 +359,5 @@ var PlaceholderComponent = /** @class */ (function (_super) {
|
|
|
351
359
|
return PlaceholderComponent;
|
|
352
360
|
}(React__default["default"].Component));
|
|
353
361
|
|
|
362
|
+
exports.RENDERER_TRANSMISSION_OMIT_PROPS = RENDERER_TRANSMISSION_OMIT_PROPS;
|
|
354
363
|
exports.SchemaRenderer = SchemaRenderer;
|
package/lib/Scoped.d.ts
CHANGED
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { RendererEnv, RendererProps } from './factory';
|
|
7
7
|
import { RendererData, ActionObject } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* target 里面可能包含 ?xxx=xxx,这种情况下,需要把 ?xxx=xxx 保留下来,然后对前面的部分进行 filter
|
|
10
|
+
* 因为后面会对 query 部分做不一样的处理。会保留原始的值。而不是会转成字符串。
|
|
11
|
+
* @param target
|
|
12
|
+
* @param data
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function filterTarget(target: string, data: Record<string, any>): string;
|
|
8
16
|
export interface ScopedComponentType extends React.Component<RendererProps> {
|
|
9
17
|
focus?: () => void;
|
|
10
18
|
doAction?: (action: ActionObject, data: RendererData, throwErrors?: boolean) => void;
|
package/lib/Scoped.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -59,7 +59,22 @@ var hoistNonReactStatic__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonRe
|
|
|
59
59
|
* @file 用来创建一个域,在这个域里面会把里面的运行时实例注册进来,方便组件之间的通信。
|
|
60
60
|
* @author fex
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
|
+
* target 里面可能包含 ?xxx=xxx,这种情况下,需要把 ?xxx=xxx 保留下来,然后对前面的部分进行 filter
|
|
64
|
+
* 因为后面会对 query 部分做不一样的处理。会保留原始的值。而不是会转成字符串。
|
|
65
|
+
* @param target
|
|
66
|
+
* @param data
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
function filterTarget(target, data) {
|
|
70
|
+
var idx = target.indexOf('?');
|
|
71
|
+
if (~idx) {
|
|
72
|
+
return tpl.filter(target.slice(0, idx), data) + target.slice(idx);
|
|
73
|
+
}
|
|
74
|
+
return tpl.filter(target, data, '| raw');
|
|
75
|
+
}
|
|
76
|
+
var rootScopedContext = createScopedTools('');
|
|
77
|
+
var ScopedContext = React__default["default"].createContext(rootScopedContext);
|
|
63
78
|
function createScopedTools(path, parent, env) {
|
|
64
79
|
var components = [];
|
|
65
80
|
var self = {
|
|
@@ -104,14 +119,14 @@ function createScopedTools(path, parent, env) {
|
|
|
104
119
|
getComponentById: function (id) {
|
|
105
120
|
var root = this;
|
|
106
121
|
// 找到顶端scoped
|
|
107
|
-
while (root.parent) {
|
|
122
|
+
while (root.parent && root.parent !== rootScopedContext) {
|
|
108
123
|
root = root.parent;
|
|
109
124
|
}
|
|
110
125
|
// 向下查找
|
|
111
126
|
var component = undefined;
|
|
112
127
|
helper.findTree([root], function (item) {
|
|
113
128
|
return item.getComponents().find(function (cmpt) {
|
|
114
|
-
if (cmpt.props.id === id) {
|
|
129
|
+
if (tpl.filter(cmpt.props.id, cmpt.props.data) === id) {
|
|
115
130
|
component = cmpt;
|
|
116
131
|
return true;
|
|
117
132
|
}
|
|
@@ -377,3 +392,4 @@ function HocScoped(ComposedComponent) {
|
|
|
377
392
|
exports.HocScoped = HocScoped;
|
|
378
393
|
exports.ScopedContext = ScopedContext;
|
|
379
394
|
exports["default"] = HocScoped;
|
|
395
|
+
exports.filterTarget = filterTarget;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
3
|
+
import { IStatusStore } from './store/status';
|
|
4
|
+
export interface StatusScopedProps {
|
|
5
|
+
statusStore: IStatusStore;
|
|
6
|
+
}
|
|
7
|
+
export declare function StatusScoped<T extends React.ComponentType<React.ComponentProps<T> & StatusScopedProps>>(ComposedComponent: T): {
|
|
8
|
+
new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}): {
|
|
9
|
+
store?: ({
|
|
10
|
+
visibleState: any;
|
|
11
|
+
disableState: any;
|
|
12
|
+
staticState: any;
|
|
13
|
+
} & import("mobx-state-tree/dist/internal").NonEmptyObject & {
|
|
14
|
+
setVisible(key: string, value?: boolean | undefined): void;
|
|
15
|
+
setDisable(key: string, value?: boolean | undefined): void;
|
|
16
|
+
setStatic(key: string, value?: boolean | undefined): void;
|
|
17
|
+
resetAll(): void;
|
|
18
|
+
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
19
|
+
visibleState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
20
|
+
disableState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
21
|
+
staticState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
22
|
+
}, {
|
|
23
|
+
setVisible(key: string, value?: boolean | undefined): void;
|
|
24
|
+
setDisable(key: string, value?: boolean | undefined): void;
|
|
25
|
+
setStatic(key: string, value?: boolean | undefined): void;
|
|
26
|
+
resetAll(): void;
|
|
27
|
+
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>) | undefined;
|
|
28
|
+
ref: any;
|
|
29
|
+
childRef(ref: any): void;
|
|
30
|
+
getWrappedInstance(): any;
|
|
31
|
+
componentWillUnmount(): void;
|
|
32
|
+
render(): React.JSX.Element;
|
|
33
|
+
context: unknown;
|
|
34
|
+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
35
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
36
|
+
readonly props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>;
|
|
37
|
+
state: Readonly<{}>;
|
|
38
|
+
refs: {
|
|
39
|
+
[key: string]: React.ReactInstance;
|
|
40
|
+
};
|
|
41
|
+
componentDidMount?(): void;
|
|
42
|
+
shouldComponentUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
43
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
44
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, prevState: Readonly<{}>): any;
|
|
45
|
+
componentDidUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
46
|
+
componentWillMount?(): void;
|
|
47
|
+
UNSAFE_componentWillMount?(): void;
|
|
48
|
+
componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextContext: any): void;
|
|
49
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextContext: any): void;
|
|
50
|
+
componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
51
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
52
|
+
};
|
|
53
|
+
displayName: string;
|
|
54
|
+
ComposedComponent: React.ComponentType<T>;
|
|
55
|
+
contextType?: React.Context<any> | undefined;
|
|
56
|
+
} & hoistNonReactStatic.NonReactStatics<T, {}> & {
|
|
57
|
+
ComposedComponent: T;
|
|
58
|
+
};
|