@formily-design/formily-setters 1.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/.umirc.js +44 -0
- package/LICENSE.md +20 -0
- package/README.md +7 -0
- package/copy.ts +6 -0
- package/esm/components/DataSourceSetter/DataSettingPanel.d.ts +10 -0
- package/esm/components/DataSourceSetter/DataSettingPanel.js +66 -0
- package/esm/components/DataSourceSetter/Header.d.ts +7 -0
- package/esm/components/DataSourceSetter/Header.js +10 -0
- package/esm/components/DataSourceSetter/Title.d.ts +7 -0
- package/esm/components/DataSourceSetter/Title.js +50 -0
- package/esm/components/DataSourceSetter/TreePanel.d.ts +12 -0
- package/esm/components/DataSourceSetter/TreePanel.js +98 -0
- package/esm/components/DataSourceSetter/index.d.ts +18 -0
- package/esm/components/DataSourceSetter/index.js +34 -0
- package/esm/components/DataSourceSetter/shared.d.ts +9 -0
- package/esm/components/DataSourceSetter/shared.js +47 -0
- package/esm/components/DataSourceSetter/styles.less +80 -0
- package/esm/components/DataSourceSetter/types.d.ts +18 -0
- package/esm/components/DataSourceSetter/types.js +1 -0
- package/esm/components/ReactionsSetter/FieldPropertySetter.d.ts +10 -0
- package/esm/components/ReactionsSetter/FieldPropertySetter.js +83 -0
- package/esm/components/ReactionsSetter/PathSelector.d.ts +10 -0
- package/esm/components/ReactionsSetter/PathSelector.js +107 -0
- package/esm/components/ReactionsSetter/declarations.d.ts +5 -0
- package/esm/components/ReactionsSetter/declarations.js +51 -0
- package/esm/components/ReactionsSetter/helpers.d.ts +10 -0
- package/esm/components/ReactionsSetter/helpers.js +384 -0
- package/esm/components/ReactionsSetter/index.d.ts +8 -0
- package/esm/components/ReactionsSetter/index.js +282 -0
- package/esm/components/ReactionsSetter/properties.d.ts +11 -0
- package/esm/components/ReactionsSetter/properties.js +41 -0
- package/esm/components/ReactionsSetter/styles.less +103 -0
- package/esm/components/ReactionsSetter/types.d.ts +13 -0
- package/esm/components/ReactionsSetter/types.js +1 -0
- package/esm/components/RemoteDataSourceSetter/RemoteDataSourcePanel.d.ts +8 -0
- package/esm/components/RemoteDataSourceSetter/RemoteDataSourcePanel.js +103 -0
- package/esm/components/RemoteDataSourceSetter/index.d.ts +17 -0
- package/esm/components/RemoteDataSourceSetter/index.js +25 -0
- package/esm/components/RemoteDataSourceSetter/styles.less +33 -0
- package/esm/components/RemoteDataSourceSetter/types.d.ts +8 -0
- package/esm/components/RemoteDataSourceSetter/types.js +1 -0
- package/esm/components/ValidatorSetter/index.d.ts +6 -0
- package/esm/components/ValidatorSetter/index.js +140 -0
- package/esm/components/index.d.ts +4 -0
- package/esm/components/index.js +4 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -0
- package/esm/locales/en-US.d.ts +110 -0
- package/esm/locales/en-US.js +115 -0
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +5 -0
- package/esm/locales/ko-KR.d.ts +110 -0
- package/esm/locales/ko-KR.js +115 -0
- package/esm/locales/zh-CN.d.ts +110 -0
- package/esm/locales/zh-CN.js +115 -0
- package/lib/components/DataSourceSetter/DataSettingPanel.d.ts +10 -0
- package/lib/components/DataSourceSetter/DataSettingPanel.js +102 -0
- package/lib/components/DataSourceSetter/Header.d.ts +7 -0
- package/lib/components/DataSourceSetter/Header.js +16 -0
- package/lib/components/DataSourceSetter/Title.d.ts +7 -0
- package/lib/components/DataSourceSetter/Title.js +56 -0
- package/lib/components/DataSourceSetter/TreePanel.d.ts +12 -0
- package/lib/components/DataSourceSetter/TreePanel.js +134 -0
- package/lib/components/DataSourceSetter/index.d.ts +18 -0
- package/lib/components/DataSourceSetter/index.js +73 -0
- package/lib/components/DataSourceSetter/shared.d.ts +9 -0
- package/lib/components/DataSourceSetter/shared.js +53 -0
- package/lib/components/DataSourceSetter/styles.less +80 -0
- package/lib/components/DataSourceSetter/types.d.ts +18 -0
- package/lib/components/DataSourceSetter/types.js +2 -0
- package/lib/components/ReactionsSetter/FieldPropertySetter.d.ts +10 -0
- package/lib/components/ReactionsSetter/FieldPropertySetter.js +120 -0
- package/lib/components/ReactionsSetter/PathSelector.d.ts +10 -0
- package/lib/components/ReactionsSetter/PathSelector.js +114 -0
- package/lib/components/ReactionsSetter/declarations.d.ts +5 -0
- package/lib/components/ReactionsSetter/declarations.js +55 -0
- package/lib/components/ReactionsSetter/helpers.d.ts +10 -0
- package/lib/components/ReactionsSetter/helpers.js +387 -0
- package/lib/components/ReactionsSetter/index.d.ts +8 -0
- package/lib/components/ReactionsSetter/index.js +319 -0
- package/lib/components/ReactionsSetter/properties.d.ts +11 -0
- package/lib/components/ReactionsSetter/properties.js +44 -0
- package/lib/components/ReactionsSetter/styles.less +103 -0
- package/lib/components/ReactionsSetter/types.d.ts +13 -0
- package/lib/components/ReactionsSetter/types.js +2 -0
- package/lib/components/RemoteDataSourceSetter/RemoteDataSourcePanel.d.ts +8 -0
- package/lib/components/RemoteDataSourceSetter/RemoteDataSourcePanel.js +140 -0
- package/lib/components/RemoteDataSourceSetter/index.d.ts +17 -0
- package/lib/components/RemoteDataSourceSetter/index.js +64 -0
- package/lib/components/RemoteDataSourceSetter/styles.less +33 -0
- package/lib/components/RemoteDataSourceSetter/types.d.ts +8 -0
- package/lib/components/RemoteDataSourceSetter/types.js +2 -0
- package/lib/components/ValidatorSetter/index.d.ts +6 -0
- package/lib/components/ValidatorSetter/index.js +146 -0
- package/lib/components/index.d.ts +4 -0
- package/lib/components/index.js +20 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +18 -0
- package/lib/locales/en-US.d.ts +110 -0
- package/lib/locales/en-US.js +117 -0
- package/lib/locales/index.d.ts +1 -0
- package/lib/locales/index.js +10 -0
- package/lib/locales/ko-KR.d.ts +110 -0
- package/lib/locales/ko-KR.js +117 -0
- package/lib/locales/zh-CN.d.ts +110 -0
- package/lib/locales/zh-CN.js +117 -0
- package/package.json +53 -0
- package/tsconfig.build.json +10 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
'zh-CN': {
|
|
3
|
+
settings: {
|
|
4
|
+
'x-validator': {
|
|
5
|
+
title: string;
|
|
6
|
+
addValidatorRules: string;
|
|
7
|
+
drawer: string;
|
|
8
|
+
triggerType: {
|
|
9
|
+
title: string;
|
|
10
|
+
placeholder: string;
|
|
11
|
+
dataSource: string[];
|
|
12
|
+
};
|
|
13
|
+
format: {
|
|
14
|
+
title: string;
|
|
15
|
+
placeholder: string;
|
|
16
|
+
dataSource: {
|
|
17
|
+
label: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
validator: {
|
|
22
|
+
title: string;
|
|
23
|
+
tooltip: string;
|
|
24
|
+
};
|
|
25
|
+
pattern: string;
|
|
26
|
+
len: string;
|
|
27
|
+
max: string;
|
|
28
|
+
min: string;
|
|
29
|
+
exclusiveMaximum: string;
|
|
30
|
+
exclusiveMinimum: string;
|
|
31
|
+
whitespace: string;
|
|
32
|
+
required: string;
|
|
33
|
+
message: {
|
|
34
|
+
title: string;
|
|
35
|
+
tooltip: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
SettingComponents: {
|
|
40
|
+
DataSourceSetter: {
|
|
41
|
+
nodeProperty: string;
|
|
42
|
+
pleaseSelectNode: string;
|
|
43
|
+
addKeyValuePair: string;
|
|
44
|
+
configureDataSource: string;
|
|
45
|
+
dataSource: string;
|
|
46
|
+
defaultTitle: string;
|
|
47
|
+
dataSourceTree: string;
|
|
48
|
+
addNode: string;
|
|
49
|
+
label: string;
|
|
50
|
+
value: string;
|
|
51
|
+
item: string;
|
|
52
|
+
staticData: string;
|
|
53
|
+
remoteData: string;
|
|
54
|
+
confirm: string;
|
|
55
|
+
cancel: string;
|
|
56
|
+
editConfigure: string;
|
|
57
|
+
};
|
|
58
|
+
RemoteDataSource: {
|
|
59
|
+
basic: string;
|
|
60
|
+
url: string;
|
|
61
|
+
method: string;
|
|
62
|
+
headers: string;
|
|
63
|
+
params: string;
|
|
64
|
+
handlers: string;
|
|
65
|
+
beforeRequest: string;
|
|
66
|
+
dataHandler: string;
|
|
67
|
+
addHeader: string;
|
|
68
|
+
addParam: string;
|
|
69
|
+
};
|
|
70
|
+
ReactionsSetter: {
|
|
71
|
+
configureReactions: string;
|
|
72
|
+
relationsFields: string;
|
|
73
|
+
variableName: string;
|
|
74
|
+
variableNameValidateMessage: string;
|
|
75
|
+
pleaseInput: string;
|
|
76
|
+
sourceField: string;
|
|
77
|
+
sourceProperty: string;
|
|
78
|
+
variableType: string;
|
|
79
|
+
operations: string;
|
|
80
|
+
addRelationField: string;
|
|
81
|
+
propertyReactions: string;
|
|
82
|
+
actionReactions: string;
|
|
83
|
+
visible: string;
|
|
84
|
+
hidden: string;
|
|
85
|
+
display: string;
|
|
86
|
+
pattern: string;
|
|
87
|
+
title: string;
|
|
88
|
+
description: string;
|
|
89
|
+
value: string;
|
|
90
|
+
initialValue: string;
|
|
91
|
+
dataSource: string;
|
|
92
|
+
required: string;
|
|
93
|
+
component: string;
|
|
94
|
+
componentProps: string;
|
|
95
|
+
decorator: string;
|
|
96
|
+
decoratorProps: string;
|
|
97
|
+
pleaseSelect: string;
|
|
98
|
+
expressionValueTypeIs: string;
|
|
99
|
+
};
|
|
100
|
+
ValidatorSetter: {
|
|
101
|
+
pleaseSelect: string;
|
|
102
|
+
formats: {
|
|
103
|
+
label: string;
|
|
104
|
+
value: string;
|
|
105
|
+
}[];
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export default _default;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const ValidatorFormats = [
|
|
2
|
+
{ label: 'URL地址', value: 'url' },
|
|
3
|
+
{ label: '邮箱格式', value: 'email' },
|
|
4
|
+
{ label: '数字格式', value: 'number' },
|
|
5
|
+
{ label: '整数格式', value: 'integer' },
|
|
6
|
+
{ label: '身份证格式', value: 'idcard' },
|
|
7
|
+
{ label: '手机号格式', value: 'phone' },
|
|
8
|
+
{ label: '货币格式', value: 'money' },
|
|
9
|
+
{ label: '中文格式', value: 'zh' },
|
|
10
|
+
{ label: '日期格式', value: 'date' },
|
|
11
|
+
{ label: '邮编格式', value: 'zip' },
|
|
12
|
+
];
|
|
13
|
+
export default {
|
|
14
|
+
'zh-CN': {
|
|
15
|
+
settings: {
|
|
16
|
+
'x-validator': {
|
|
17
|
+
title: '校验规则',
|
|
18
|
+
addValidatorRules: '添加校验规则',
|
|
19
|
+
drawer: '配置规则',
|
|
20
|
+
triggerType: {
|
|
21
|
+
title: '触发类型',
|
|
22
|
+
placeholder: '请选择',
|
|
23
|
+
dataSource: ['输入时', '聚焦时', '失焦时'],
|
|
24
|
+
},
|
|
25
|
+
format: {
|
|
26
|
+
title: '格式校验',
|
|
27
|
+
placeholder: '请选择',
|
|
28
|
+
dataSource: ValidatorFormats,
|
|
29
|
+
},
|
|
30
|
+
validator: {
|
|
31
|
+
title: '自定义校验器',
|
|
32
|
+
tooltip: '格式: function (value){ return "Error Message"}',
|
|
33
|
+
},
|
|
34
|
+
pattern: '正则表达式',
|
|
35
|
+
len: '长度限制',
|
|
36
|
+
max: '长度/数值小于',
|
|
37
|
+
min: '长度/数值大于',
|
|
38
|
+
exclusiveMaximum: '长度/数值小于等于',
|
|
39
|
+
exclusiveMinimum: '长度/数值大于等于',
|
|
40
|
+
whitespace: '不允许空白符',
|
|
41
|
+
required: '是否必填',
|
|
42
|
+
message: {
|
|
43
|
+
title: '错误消息',
|
|
44
|
+
tooltip: '错误消息只对当前规则集的一个内置规则生效,如果需要对不同内置规则定制错误消息,请拆分成多条规则',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
SettingComponents: {
|
|
49
|
+
DataSourceSetter: {
|
|
50
|
+
nodeProperty: '节点属性',
|
|
51
|
+
pleaseSelectNode: '请先选择左侧树节点',
|
|
52
|
+
addKeyValuePair: '添加键值对',
|
|
53
|
+
configureDataSource: '配置可选项',
|
|
54
|
+
dataSource: '可选项',
|
|
55
|
+
defaultTitle: '默认标题',
|
|
56
|
+
dataSourceTree: '可选项节点树',
|
|
57
|
+
addNode: '新增节点',
|
|
58
|
+
label: '键名',
|
|
59
|
+
value: '键值',
|
|
60
|
+
item: '选项',
|
|
61
|
+
staticData: '静态数据',
|
|
62
|
+
remoteData: '远程数据',
|
|
63
|
+
confirm: '确定',
|
|
64
|
+
cancel: '取消',
|
|
65
|
+
editConfigure: '编辑配置',
|
|
66
|
+
},
|
|
67
|
+
RemoteDataSource: {
|
|
68
|
+
basic: '基本配置',
|
|
69
|
+
url: '请求地址',
|
|
70
|
+
method: '请求方式',
|
|
71
|
+
headers: '请求头',
|
|
72
|
+
params: '请求参数',
|
|
73
|
+
handlers: '数据处理',
|
|
74
|
+
beforeRequest: '请求前置处理',
|
|
75
|
+
dataHandler: '请求数据处理',
|
|
76
|
+
addHeader: '添加请求头',
|
|
77
|
+
addParam: '添加请求参数',
|
|
78
|
+
},
|
|
79
|
+
ReactionsSetter: {
|
|
80
|
+
configureReactions: '配置响应器',
|
|
81
|
+
relationsFields: '依赖字段',
|
|
82
|
+
variableName: '变量名',
|
|
83
|
+
variableNameValidateMessage: '不符合变量命名规则',
|
|
84
|
+
pleaseInput: '请输入',
|
|
85
|
+
sourceField: '来源字段',
|
|
86
|
+
sourceProperty: '字段属性',
|
|
87
|
+
variableType: '变量类型',
|
|
88
|
+
operations: '操作',
|
|
89
|
+
addRelationField: '添加依赖字段',
|
|
90
|
+
propertyReactions: '属性响应(仅支持JS表达式)',
|
|
91
|
+
actionReactions: '动作响应(高级,可选,支持JS语句)',
|
|
92
|
+
visible: '显示/隐藏',
|
|
93
|
+
hidden: 'UI隐藏',
|
|
94
|
+
display: '展示状态',
|
|
95
|
+
pattern: 'UI形态',
|
|
96
|
+
title: '标题',
|
|
97
|
+
description: '描述',
|
|
98
|
+
value: '字段值',
|
|
99
|
+
initialValue: '默认值',
|
|
100
|
+
dataSource: '可选项',
|
|
101
|
+
required: '是否必填',
|
|
102
|
+
component: '组件',
|
|
103
|
+
componentProps: '组件属性',
|
|
104
|
+
decorator: '容器',
|
|
105
|
+
decoratorProps: '容器属性',
|
|
106
|
+
pleaseSelect: '请选择',
|
|
107
|
+
expressionValueTypeIs: '表达式值类型为',
|
|
108
|
+
},
|
|
109
|
+
ValidatorSetter: {
|
|
110
|
+
pleaseSelect: '请选择',
|
|
111
|
+
formats: ValidatorFormats,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Form as FormCore } from '@formily/core';
|
|
3
|
+
import { ITreeDataSource } from './types';
|
|
4
|
+
import './styles.less';
|
|
5
|
+
export interface IDataSettingPanelProps {
|
|
6
|
+
treeDataSource: ITreeDataSource;
|
|
7
|
+
allowExtendOption?: boolean;
|
|
8
|
+
effects?: (form: FormCore<any>) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const DataSettingPanel: React.FC<IDataSettingPanelProps>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DataSettingPanel = void 0;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const antd_1 = require("antd");
|
|
39
|
+
const icons_1 = require("@ant-design/icons");
|
|
40
|
+
const antd_v5_1 = require("@formily/antd-v5");
|
|
41
|
+
const core_1 = require("@formily/core");
|
|
42
|
+
const reactive_react_1 = require("@formily/reactive-react");
|
|
43
|
+
const react_2 = require("@formily/react");
|
|
44
|
+
const react_settings_form_1 = require("@formily-design/react-settings-form");
|
|
45
|
+
const react_3 = require("@formily-design/react");
|
|
46
|
+
const Header_1 = require("./Header");
|
|
47
|
+
const shared_1 = require("./shared");
|
|
48
|
+
require("./styles.less");
|
|
49
|
+
const SchemaField = (0, react_2.createSchemaField)({
|
|
50
|
+
components: {
|
|
51
|
+
FormItem: antd_v5_1.FormItem,
|
|
52
|
+
Input: antd_v5_1.Input,
|
|
53
|
+
ArrayItems: antd_v5_1.ArrayItems,
|
|
54
|
+
ValueInput: react_settings_form_1.ValueInput,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
exports.DataSettingPanel = (0, reactive_react_1.observer)((props) => {
|
|
58
|
+
const { allowExtendOption, effects } = props;
|
|
59
|
+
const prefix = (0, react_3.usePrefix)('data-source-setter');
|
|
60
|
+
const form = (0, react_1.useMemo)(() => {
|
|
61
|
+
let values;
|
|
62
|
+
(0, shared_1.traverseTree)(props.treeDataSource.dataSource, (dataItem) => {
|
|
63
|
+
if (dataItem.key === props.treeDataSource.selectedKey) {
|
|
64
|
+
values = dataItem;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return (0, core_1.createForm)({
|
|
68
|
+
values,
|
|
69
|
+
effects: effects,
|
|
70
|
+
});
|
|
71
|
+
}, [
|
|
72
|
+
props.treeDataSource.selectedKey,
|
|
73
|
+
props.treeDataSource.dataSource.length,
|
|
74
|
+
]);
|
|
75
|
+
if (!props.treeDataSource.selectedKey)
|
|
76
|
+
return (react_1.default.createElement(react_1.Fragment, null,
|
|
77
|
+
react_1.default.createElement(Header_1.Header, { title: react_1.default.createElement(react_3.TextWidget, { token: "SettingComponents.DataSourceSetter.nodeProperty" }), extra: null }),
|
|
78
|
+
react_1.default.createElement("div", { className: `${prefix + '-layout-item-content'}` },
|
|
79
|
+
react_1.default.createElement(react_3.TextWidget, { token: "SettingComponents.DataSourceSetter.pleaseSelectNode" }))));
|
|
80
|
+
return (react_1.default.createElement(react_1.Fragment, null,
|
|
81
|
+
react_1.default.createElement(Header_1.Header, { title: react_1.default.createElement(react_3.TextWidget, { token: "SettingComponents.DataSourceSetter.nodeProperty" }), extra: allowExtendOption ? (react_1.default.createElement(antd_1.Button, { type: "text", onClick: () => {
|
|
82
|
+
form.setFieldState('map', (state) => {
|
|
83
|
+
state.value.push({});
|
|
84
|
+
});
|
|
85
|
+
}, icon: react_1.default.createElement(icons_1.PlusOutlined, null) },
|
|
86
|
+
react_1.default.createElement(react_3.TextWidget, { token: "SettingComponents.DataSourceSetter.addKeyValuePair" }))) : null }),
|
|
87
|
+
react_1.default.createElement("div", { className: `${prefix + '-layout-item-content'}` },
|
|
88
|
+
react_1.default.createElement(antd_v5_1.Form, { form: form, labelWidth: 60, wrapperWidth: 160 },
|
|
89
|
+
react_1.default.createElement(SchemaField, null,
|
|
90
|
+
react_1.default.createElement(SchemaField.Array, { name: "map", "x-component": "ArrayItems" },
|
|
91
|
+
react_1.default.createElement(SchemaField.Object, { "x-decorator": "ArrayItems.Item", "x-decorator-props": { type: 'divide' } },
|
|
92
|
+
react_1.default.createElement(SchemaField.String, { title: react_1.default.createElement(react_3.TextWidget, { token: "SettingComponents.DataSourceSetter.label" }), "x-decorator": "FormItem", "x-disabled": !allowExtendOption, name: "label", "x-component": "Input" }),
|
|
93
|
+
react_1.default.createElement(SchemaField.String, { title: react_1.default.createElement(react_3.TextWidget, { token: "SettingComponents.DataSourceSetter.value" }), "x-decorator": "FormItem", name: "value", "x-component": "ValueInput" }),
|
|
94
|
+
react_1.default.createElement(SchemaField.Void, { "x-component": "ArrayItems.Remove", "x-visible": allowExtendOption, "x-component-props": {
|
|
95
|
+
style: {
|
|
96
|
+
margin: 5,
|
|
97
|
+
display: 'flex',
|
|
98
|
+
justifyContent: 'center',
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
},
|
|
101
|
+
} }))))))));
|
|
102
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Header = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const reactive_react_1 = require("@formily/reactive-react");
|
|
9
|
+
const react_2 = require("@formily-design/react");
|
|
10
|
+
require("./styles.less");
|
|
11
|
+
exports.Header = (0, reactive_react_1.observer)(({ extra, title }) => {
|
|
12
|
+
const prefix = (0, react_2.usePrefix)('data-source-setter');
|
|
13
|
+
return (react_1.default.createElement("div", { className: `${prefix + '-layout-item-header'}` },
|
|
14
|
+
react_1.default.createElement("div", { className: `${prefix + '-layout-item-title'}` }, title),
|
|
15
|
+
extra));
|
|
16
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Title = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const shared_1 = require("@formily/shared");
|
|
9
|
+
const reactive_react_1 = require("@formily/reactive-react");
|
|
10
|
+
const react_2 = require("@formily-design/react");
|
|
11
|
+
const shared_2 = require("./shared");
|
|
12
|
+
require("./styles.less");
|
|
13
|
+
exports.Title = (0, reactive_react_1.observer)((props) => {
|
|
14
|
+
const prefix = (0, react_2.usePrefix)('data-source-setter-node-title');
|
|
15
|
+
const getTitleValue = (dataSource) => {
|
|
16
|
+
const optionalKeys = ['label', 'title', 'header'];
|
|
17
|
+
let nodeTitle;
|
|
18
|
+
optionalKeys.some((key) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const title = (_a = (0, shared_1.toArr)(dataSource).find((item) => item.label === key)) === null || _a === void 0 ? void 0 : _a.value;
|
|
21
|
+
if (title !== undefined) {
|
|
22
|
+
nodeTitle = title;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
});
|
|
27
|
+
if (nodeTitle === undefined) {
|
|
28
|
+
(0, shared_1.toArr)(dataSource || []).some((item) => {
|
|
29
|
+
if (item.value && typeof item.value === 'string') {
|
|
30
|
+
nodeTitle = item.value;
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return nodeTitle;
|
|
37
|
+
};
|
|
38
|
+
const renderTitle = (dataSource) => {
|
|
39
|
+
const nodeTitle = getTitleValue(dataSource);
|
|
40
|
+
if (nodeTitle === undefined)
|
|
41
|
+
return (react_1.default.createElement(react_2.TextWidget, { token: "SettingComponents.DataSourceSetter.defaultTitle" }));
|
|
42
|
+
else
|
|
43
|
+
return nodeTitle + '';
|
|
44
|
+
};
|
|
45
|
+
return (react_1.default.createElement("div", { className: prefix },
|
|
46
|
+
react_1.default.createElement("span", { style: { marginRight: '5px' } }, renderTitle((props === null || props === void 0 ? void 0 : props.map) || [])),
|
|
47
|
+
react_1.default.createElement(react_2.IconWidget, { className: prefix + '-icon', infer: "Remove", onClick: () => {
|
|
48
|
+
var _a;
|
|
49
|
+
const newDataSource = (0, shared_1.clone)((_a = props === null || props === void 0 ? void 0 : props.treeDataSource) === null || _a === void 0 ? void 0 : _a.dataSource);
|
|
50
|
+
(0, shared_2.traverseTree)(newDataSource || [], (dataItem, i, data) => {
|
|
51
|
+
if (data[i].key === props.duplicateKey)
|
|
52
|
+
(0, shared_1.toArr)(data).splice(i, 1);
|
|
53
|
+
});
|
|
54
|
+
props.treeDataSource.dataSource = newDataSource;
|
|
55
|
+
} })));
|
|
56
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ITreeDataSource } from './types';
|
|
3
|
+
import './styles.less';
|
|
4
|
+
export interface ITreePanelProps {
|
|
5
|
+
treeDataSource: ITreeDataSource;
|
|
6
|
+
allowTree: boolean;
|
|
7
|
+
defaultOptionValue: {
|
|
8
|
+
label: string;
|
|
9
|
+
value: any;
|
|
10
|
+
}[];
|
|
11
|
+
}
|
|
12
|
+
export declare const TreePanel: React.FC<ITreePanelProps>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.TreePanel = void 0;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const antd_1 = require("antd");
|
|
39
|
+
const shared_1 = require("@formily/shared");
|
|
40
|
+
const reactive_react_1 = require("@formily/reactive-react");
|
|
41
|
+
const react_2 = require("@formily-design/react");
|
|
42
|
+
const Title_1 = require("./Title");
|
|
43
|
+
const Header_1 = require("./Header");
|
|
44
|
+
const shared_2 = require("./shared");
|
|
45
|
+
require("./styles.less");
|
|
46
|
+
const core_1 = require("@formily-design/core");
|
|
47
|
+
const limitTreeDrag = ({ dropPosition }) => {
|
|
48
|
+
if (dropPosition === 0) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
};
|
|
53
|
+
exports.TreePanel = (0, reactive_react_1.observer)((props) => {
|
|
54
|
+
const prefix = (0, react_2.usePrefix)('data-source-setter');
|
|
55
|
+
const dropHandler = (info) => {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
const dropKey = (_a = info.node) === null || _a === void 0 ? void 0 : _a.key;
|
|
58
|
+
const dragKey = (_b = info.dragNode) === null || _b === void 0 ? void 0 : _b.key;
|
|
59
|
+
const dropPos = info.node.pos.split('-');
|
|
60
|
+
const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]);
|
|
61
|
+
const data = [...props.treeDataSource.dataSource];
|
|
62
|
+
// Find dragObject
|
|
63
|
+
let dragObj;
|
|
64
|
+
(0, shared_2.traverseTree)(data, (item, index, arr) => {
|
|
65
|
+
if (arr[index].key === dragKey) {
|
|
66
|
+
arr.splice(index, 1);
|
|
67
|
+
dragObj = item;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
if (!info.dropToGap) {
|
|
71
|
+
(0, shared_2.traverseTree)(data, (item) => {
|
|
72
|
+
if (item.key === dropKey) {
|
|
73
|
+
item.children = item.children || [];
|
|
74
|
+
item.children.unshift(dragObj);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else if ((info.node.children || []).length > 0 &&
|
|
79
|
+
info.node.expanded &&
|
|
80
|
+
dropPosition === 1) {
|
|
81
|
+
(0, shared_2.traverseTree)(data, (item) => {
|
|
82
|
+
if (item.key === dropKey) {
|
|
83
|
+
item.children = item.children || [];
|
|
84
|
+
item.children.unshift(dragObj);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
let ar;
|
|
90
|
+
let i;
|
|
91
|
+
(0, shared_2.traverseTree)(data, (item, index, arr) => {
|
|
92
|
+
if (item.key === dropKey) {
|
|
93
|
+
ar = arr;
|
|
94
|
+
i = index;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
if (dropPosition === -1) {
|
|
98
|
+
ar.splice(i, 0, dragObj);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
ar.splice(i + 1, 0, dragObj);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
props.treeDataSource.dataSource = data;
|
|
105
|
+
};
|
|
106
|
+
return (react_1.default.createElement(react_1.Fragment, null,
|
|
107
|
+
react_1.default.createElement(Header_1.Header, { title: react_1.default.createElement(react_2.TextWidget, { token: "SettingComponents.DataSourceSetter.dataSourceTree" }), extra: react_1.default.createElement(antd_1.Button, { type: "text", onClick: () => {
|
|
108
|
+
var _a;
|
|
109
|
+
const uuid = (0, shared_1.uid)();
|
|
110
|
+
const dataSource = props.treeDataSource.dataSource;
|
|
111
|
+
const initialKeyValuePairs = ((_a = props.defaultOptionValue) === null || _a === void 0 ? void 0 : _a.map((item) => ({ ...item }))) || [
|
|
112
|
+
{
|
|
113
|
+
label: 'label',
|
|
114
|
+
value: `${core_1.GlobalRegistry.getDesignerMessage(`SettingComponents.DataSourceSetter.item`)} ${dataSource.length + 1}`,
|
|
115
|
+
},
|
|
116
|
+
{ label: 'value', value: uuid },
|
|
117
|
+
];
|
|
118
|
+
props.treeDataSource.dataSource = dataSource.concat({
|
|
119
|
+
key: uuid,
|
|
120
|
+
duplicateKey: uuid,
|
|
121
|
+
map: initialKeyValuePairs,
|
|
122
|
+
children: [],
|
|
123
|
+
});
|
|
124
|
+
}, icon: react_1.default.createElement(react_2.IconWidget, { infer: "Add" }) },
|
|
125
|
+
react_1.default.createElement(react_2.TextWidget, { token: "SettingComponents.DataSourceSetter.addNode" })) }),
|
|
126
|
+
react_1.default.createElement("div", { className: `${prefix + '-layout-item-content'}` },
|
|
127
|
+
react_1.default.createElement(antd_1.Tree, { blockNode: true, draggable: true, allowDrop: props.allowTree ? () => true : limitTreeDrag, defaultExpandAll: true, defaultExpandParent: true, autoExpandParent: true, showLine: { showLeafIcon: false }, treeData: props.treeDataSource.dataSource, onDragEnter: () => { }, onDrop: dropHandler, titleRender: (titleProps) => {
|
|
128
|
+
return (react_1.default.createElement(Title_1.Title, { ...titleProps, treeDataSource: props.treeDataSource }));
|
|
129
|
+
}, onSelect: (selectedKeys) => {
|
|
130
|
+
if (selectedKeys[0]) {
|
|
131
|
+
props.treeDataSource.selectedKey = selectedKeys[0].toString();
|
|
132
|
+
}
|
|
133
|
+
} }))));
|
|
134
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Form } from '@formily/core';
|
|
3
|
+
import { IDataSourceItem } from './types';
|
|
4
|
+
import './styles.less';
|
|
5
|
+
export interface IDataSourceSetterProps {
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
onChange: (dataSource: IDataSourceItem[]) => void;
|
|
9
|
+
value: IDataSourceItem[];
|
|
10
|
+
allowTree?: boolean;
|
|
11
|
+
allowExtendOption?: boolean;
|
|
12
|
+
defaultOptionValue?: {
|
|
13
|
+
label: string;
|
|
14
|
+
value: any;
|
|
15
|
+
}[];
|
|
16
|
+
effects?: (form: Form<any>) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const DataSourceSetter: React.FC<IDataSourceSetterProps>;
|