@nocobase/client 0.7.2-alpha.6 → 0.7.4-alpha.1
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/es/application/Application.d.ts +1 -0
- package/es/application/Application.js +7 -1
- package/es/block-provider/FormBlockProvider.js +8 -3
- package/es/block-provider/TableFieldProvider.d.ts +1 -0
- package/es/block-provider/TableFieldProvider.js +5 -2
- package/es/block-provider/TableSelectorProvider.js +41 -13
- package/es/block-provider/hooks/index.d.ts +6 -0
- package/es/block-provider/hooks/index.js +159 -65
- package/es/collection-manager/CollectionField.js +4 -2
- package/es/collection-manager/Configuration/index.js +5 -1
- package/es/collection-manager/Configuration/schemas/collections.js +2 -1
- package/es/collection-manager/interfaces/input.js +103 -0
- package/es/collection-manager/interfaces/integer.js +63 -0
- package/es/collection-manager/interfaces/m2m.js +2 -0
- package/es/collection-manager/interfaces/m2o.js +1 -0
- package/es/collection-manager/interfaces/markdown.js +34 -0
- package/es/collection-manager/interfaces/number.js +55 -0
- package/es/collection-manager/interfaces/o2m.js +1 -0
- package/es/collection-manager/interfaces/o2o.js +3 -0
- package/es/collection-manager/interfaces/password.js +36 -1
- package/es/collection-manager/interfaces/percent.js +97 -0
- package/es/collection-manager/interfaces/properties/index.d.ts +1 -0
- package/es/collection-manager/interfaces/properties/index.js +1 -0
- package/es/collection-manager/interfaces/properties/operators.js +4 -4
- package/es/collection-manager/interfaces/richText.js +34 -0
- package/es/collection-manager/interfaces/textarea.js +34 -0
- package/es/file-manager/FileStorageShortcut.js +2 -2
- package/es/locale/en_US.d.ts +8 -2
- package/es/locale/en_US.js +9 -3
- package/es/locale/zh_CN.d.ts +26 -2
- package/es/locale/zh_CN.js +27 -3
- package/es/plugin-manager/PluginManager.d.ts +1 -0
- package/es/plugin-manager/PluginManager.js +20 -6
- package/es/schema-component/antd/action/Action.Modal.js +1 -1
- package/es/schema-component/antd/calendar/Calendar.Designer.js +16 -10
- package/es/schema-component/antd/date-picker/DatePicker.d.ts +1 -1
- package/es/schema-component/antd/date-picker/DatePicker.js +1 -1
- package/es/schema-component/antd/date-picker/ReadPretty.js +1 -1
- package/es/schema-component/antd/date-picker/util.d.ts +0 -10
- package/es/schema-component/antd/date-picker/util.js +1 -79
- package/es/schema-component/antd/form-item/FormItem.js +161 -10
- package/es/schema-component/antd/grid/Grid.js +72 -6
- package/es/schema-component/antd/input-number/InputNumber.d.ts +1 -5
- package/es/schema-component/antd/input-number/InputNumber.js +25 -1
- package/es/schema-component/antd/input-number/ReadPretty.js +2 -4
- package/es/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
- package/es/schema-component/antd/menu/Menu.js +6 -3
- package/es/schema-component/antd/percent/Percent.js +2 -2
- package/es/schema-component/antd/record-picker/InputRecordPicker.js +27 -13
- package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +5 -3
- package/es/schema-component/antd/table/Table.Array.js +2 -2
- package/es/schema-component/antd/table/Table.Void.js +11 -1
- package/es/schema-component/antd/table-v2/Table.Column.Designer.js +3 -1
- package/es/schema-component/antd/table-v2/Table.d.ts +0 -11
- package/es/schema-component/antd/table-v2/Table.js +163 -92
- package/es/schema-component/antd/table-v2/TableField.js +3 -0
- package/es/schema-component/antd/tabs/Tabs.Designer.js +23 -12
- package/es/schema-component/antd/tabs/Tabs.js +7 -1
- package/es/schema-component/antd/time-picker/ReadPretty.js +11 -5
- package/es/schema-component/core/DesignableSwitch.js +7 -1
- package/es/schema-component/hooks/useDesignable.js +21 -21
- package/es/schema-component/hooks/useProps.js +1 -1
- package/es/schema-initializer/buttons/FormItemInitializers.js +14 -3
- package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
- package/es/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -3
- package/es/schema-initializer/buttons/RecordBlockInitializers.js +32 -3
- package/es/schema-initializer/buttons/TabPaneInitializers.js +11 -3
- package/es/schema-initializer/buttons/TableActionInitializers.js +11 -0
- package/es/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
- package/es/schema-initializer/components/assigned-field/AssignedField.js +255 -69
- package/es/schema-initializer/items/index.d.ts +2 -0
- package/es/schema-initializer/items/index.js +48 -2
- package/es/schema-initializer/utils.js +22 -2
- package/es/system-settings/SystemSettingsShortcut.js +35 -12
- package/lib/application/Application.d.ts +1 -0
- package/lib/application/Application.js +11 -2
- package/lib/block-provider/FormBlockProvider.js +7 -2
- package/lib/block-provider/TableFieldProvider.d.ts +1 -0
- package/lib/block-provider/TableFieldProvider.js +4 -1
- package/lib/block-provider/TableSelectorProvider.js +41 -13
- package/lib/block-provider/hooks/index.d.ts +6 -0
- package/lib/block-provider/hooks/index.js +168 -67
- package/lib/collection-manager/CollectionField.js +5 -2
- package/lib/collection-manager/Configuration/index.js +5 -0
- package/lib/collection-manager/Configuration/schemas/collections.js +2 -1
- package/lib/collection-manager/interfaces/input.js +104 -0
- package/lib/collection-manager/interfaces/integer.js +65 -0
- package/lib/collection-manager/interfaces/m2m.js +2 -0
- package/lib/collection-manager/interfaces/m2o.js +1 -0
- package/lib/collection-manager/interfaces/markdown.js +35 -0
- package/lib/collection-manager/interfaces/number.js +56 -0
- package/lib/collection-manager/interfaces/o2m.js +1 -0
- package/lib/collection-manager/interfaces/o2o.js +3 -0
- package/lib/collection-manager/interfaces/password.js +37 -1
- package/lib/collection-manager/interfaces/percent.js +99 -0
- package/lib/collection-manager/interfaces/properties/index.d.ts +1 -0
- package/lib/collection-manager/interfaces/properties/index.js +1 -0
- package/lib/collection-manager/interfaces/properties/operators.js +4 -4
- package/lib/collection-manager/interfaces/richText.js +35 -0
- package/lib/collection-manager/interfaces/textarea.js +35 -0
- package/lib/file-manager/FileStorageShortcut.js +1 -1
- package/lib/locale/en_US.d.ts +8 -2
- package/lib/locale/en_US.js +9 -3
- package/lib/locale/zh_CN.d.ts +26 -2
- package/lib/locale/zh_CN.js +27 -3
- package/lib/plugin-manager/PluginManager.d.ts +1 -0
- package/lib/plugin-manager/PluginManager.js +23 -5
- package/lib/schema-component/antd/action/Action.Modal.js +1 -1
- package/lib/schema-component/antd/calendar/Calendar.Designer.js +16 -10
- package/lib/schema-component/antd/date-picker/DatePicker.d.ts +1 -1
- package/lib/schema-component/antd/date-picker/DatePicker.js +2 -2
- package/lib/schema-component/antd/date-picker/ReadPretty.js +6 -6
- package/lib/schema-component/antd/date-picker/util.d.ts +0 -10
- package/lib/schema-component/antd/date-picker/util.js +6 -89
- package/lib/schema-component/antd/form-item/FormItem.js +164 -12
- package/lib/schema-component/antd/grid/Grid.js +69 -3
- package/lib/schema-component/antd/input-number/InputNumber.d.ts +1 -5
- package/lib/schema-component/antd/input-number/InputNumber.js +28 -1
- package/lib/schema-component/antd/input-number/ReadPretty.js +2 -5
- package/lib/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
- package/lib/schema-component/antd/menu/Menu.js +6 -3
- package/lib/schema-component/antd/percent/Percent.js +2 -2
- package/lib/schema-component/antd/record-picker/InputRecordPicker.js +27 -12
- package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +4 -2
- package/lib/schema-component/antd/table/Table.Array.js +2 -2
- package/lib/schema-component/antd/table/Table.Void.js +11 -1
- package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +3 -1
- package/lib/schema-component/antd/table-v2/Table.d.ts +0 -11
- package/lib/schema-component/antd/table-v2/Table.js +172 -94
- package/lib/schema-component/antd/table-v2/TableField.js +3 -0
- package/lib/schema-component/antd/tabs/Tabs.Designer.js +23 -12
- package/lib/schema-component/antd/tabs/Tabs.js +8 -1
- package/lib/schema-component/antd/time-picker/ReadPretty.js +10 -3
- package/lib/schema-component/core/DesignableSwitch.js +8 -1
- package/lib/schema-component/hooks/useDesignable.js +21 -21
- package/lib/schema-component/hooks/useProps.js +1 -1
- package/lib/schema-initializer/buttons/FormItemInitializers.js +14 -2
- package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
- package/lib/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -2
- package/lib/schema-initializer/buttons/RecordBlockInitializers.js +34 -4
- package/lib/schema-initializer/buttons/TabPaneInitializers.js +11 -3
- package/lib/schema-initializer/buttons/TableActionInitializers.js +11 -0
- package/lib/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
- package/lib/schema-initializer/components/assigned-field/AssignedField.js +257 -66
- package/lib/schema-initializer/items/index.d.ts +2 -0
- package/lib/schema-initializer/items/index.js +54 -2
- package/lib/schema-initializer/utils.js +22 -2
- package/lib/system-settings/SystemSettingsShortcut.js +37 -13
- package/package.json +7 -4
|
@@ -9,6 +9,6 @@ export var useProps = function useProps(props, options) {
|
|
|
9
9
|
var useProps = props.useProps,
|
|
10
10
|
props1 = _objectWithoutProperties(props, _excluded);
|
|
11
11
|
|
|
12
|
-
var props2 =
|
|
12
|
+
var props2 = typeof useProps === 'function' ? useProps() : {};
|
|
13
13
|
return merge(props1 || {}, props2, options);
|
|
14
14
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { union } from 'lodash';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { useTranslation } from 'react-i18next';
|
|
3
4
|
import { SchemaInitializer } from '../SchemaInitializer';
|
|
4
|
-
import { gridRowColWrap, useFormItemInitializerFields } from '../utils'; // 表单里配置字段
|
|
5
|
+
import { gridRowColWrap, useAssociatedFormItemInitializerFields, useFormItemInitializerFields } from '../utils'; // 表单里配置字段
|
|
5
6
|
|
|
6
7
|
export var FormItemInitializers = function FormItemInitializers(props) {
|
|
7
8
|
var _useTranslation = useTranslation(),
|
|
@@ -9,14 +10,24 @@ export var FormItemInitializers = function FormItemInitializers(props) {
|
|
|
9
10
|
|
|
10
11
|
var insertPosition = props.insertPosition,
|
|
11
12
|
component = props.component;
|
|
13
|
+
var associationFields = useAssociatedFormItemInitializerFields({
|
|
14
|
+
readPretty: true,
|
|
15
|
+
block: 'Form'
|
|
16
|
+
});
|
|
12
17
|
return /*#__PURE__*/React.createElement(SchemaInitializer.Button, {
|
|
13
18
|
wrap: gridRowColWrap,
|
|
14
19
|
icon: 'SettingOutlined',
|
|
15
|
-
items: [{
|
|
20
|
+
items: union([{
|
|
16
21
|
type: 'itemGroup',
|
|
17
22
|
title: t('Display fields'),
|
|
18
23
|
children: useFormItemInitializerFields()
|
|
24
|
+
}], associationFields.length > 0 ? [{
|
|
25
|
+
type: 'divider'
|
|
19
26
|
}, {
|
|
27
|
+
type: 'itemGroup',
|
|
28
|
+
title: t('Display association fields'),
|
|
29
|
+
children: associationFields
|
|
30
|
+
}] : [], [{
|
|
20
31
|
type: 'divider'
|
|
21
32
|
}, {
|
|
22
33
|
type: 'item',
|
|
@@ -32,7 +43,7 @@ export var FormItemInitializers = function FormItemInitializers(props) {
|
|
|
32
43
|
content: t('This is a demo text, **supports Markdown syntax**.')
|
|
33
44
|
}
|
|
34
45
|
}
|
|
35
|
-
}],
|
|
46
|
+
}]),
|
|
36
47
|
insertPosition: insertPosition,
|
|
37
48
|
component: component,
|
|
38
49
|
title: component ? null : t('Configure fields')
|
|
@@ -27,6 +27,14 @@ export var ReadPrettyFormActionInitializers = {
|
|
|
27
27
|
'x-component': 'Action',
|
|
28
28
|
'x-decorator': 'ACLActionProvider'
|
|
29
29
|
}
|
|
30
|
+
}, {
|
|
31
|
+
type: 'item',
|
|
32
|
+
title: '{{t("Print")}}',
|
|
33
|
+
component: 'PrintActionInitializer',
|
|
34
|
+
schema: {
|
|
35
|
+
'x-component': 'Action',
|
|
36
|
+
'x-decorator': 'ACLActionProvider'
|
|
37
|
+
}
|
|
30
38
|
}]
|
|
31
39
|
}, {
|
|
32
40
|
type: 'divider'
|
|
@@ -1,21 +1,32 @@
|
|
|
1
|
+
import { union } from 'lodash';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { useTranslation } from 'react-i18next';
|
|
3
4
|
import { SchemaInitializer } from '../SchemaInitializer';
|
|
4
|
-
import { gridRowColWrap, useFormItemInitializerFields } from '../utils';
|
|
5
|
+
import { gridRowColWrap, useAssociatedFormItemInitializerFields, useFormItemInitializerFields } from '../utils';
|
|
5
6
|
export var ReadPrettyFormItemInitializers = function ReadPrettyFormItemInitializers(props) {
|
|
6
7
|
var _useTranslation = useTranslation(),
|
|
7
8
|
t = _useTranslation.t;
|
|
8
9
|
|
|
9
10
|
var insertPosition = props.insertPosition,
|
|
10
11
|
component = props.component;
|
|
12
|
+
var associationFields = useAssociatedFormItemInitializerFields({
|
|
13
|
+
readPretty: true,
|
|
14
|
+
block: 'Form'
|
|
15
|
+
});
|
|
11
16
|
return /*#__PURE__*/React.createElement(SchemaInitializer.Button, {
|
|
12
17
|
wrap: gridRowColWrap,
|
|
13
18
|
icon: 'SettingOutlined',
|
|
14
|
-
items: [{
|
|
19
|
+
items: union([{
|
|
15
20
|
type: 'itemGroup',
|
|
16
21
|
title: t('Display fields'),
|
|
17
22
|
children: useFormItemInitializerFields()
|
|
23
|
+
}], associationFields.length > 0 ? [{
|
|
24
|
+
type: 'divider'
|
|
18
25
|
}, {
|
|
26
|
+
type: 'itemGroup',
|
|
27
|
+
title: t('Display association fields'),
|
|
28
|
+
children: associationFields
|
|
29
|
+
}] : [], [{
|
|
19
30
|
type: 'divider'
|
|
20
31
|
}, {
|
|
21
32
|
type: 'item',
|
|
@@ -31,7 +42,7 @@ export var ReadPrettyFormItemInitializers = function ReadPrettyFormItemInitializ
|
|
|
31
42
|
content: t('This is a demo text, **supports Markdown syntax**.')
|
|
32
43
|
}
|
|
33
44
|
}
|
|
34
|
-
}],
|
|
45
|
+
}]),
|
|
35
46
|
insertPosition: insertPosition,
|
|
36
47
|
component: component,
|
|
37
48
|
title: component ? null : t('Configure fields')
|
|
@@ -1,11 +1,40 @@
|
|
|
1
|
+
import { useFieldSchema } from '@formily/react';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import { SchemaInitializer, useCollection } from '../..';
|
|
4
|
+
import { SchemaInitializer, useCollection, useCollectionManager } from '../..';
|
|
4
5
|
import { gridRowColWrap } from '../utils';
|
|
5
6
|
|
|
7
|
+
var recursiveParent = function recursiveParent(schema) {
|
|
8
|
+
var _schema$xDecorator;
|
|
9
|
+
|
|
10
|
+
if (!schema) return null;
|
|
11
|
+
|
|
12
|
+
if ((_schema$xDecorator = schema['x-decorator']) === null || _schema$xDecorator === void 0 ? void 0 : _schema$xDecorator.endsWith('BlockProvider')) {
|
|
13
|
+
var _schema$xDecoratorP;
|
|
14
|
+
|
|
15
|
+
return (_schema$xDecoratorP = schema['x-decorator-props']) === null || _schema$xDecoratorP === void 0 ? void 0 : _schema$xDecoratorP['collection'];
|
|
16
|
+
} else {
|
|
17
|
+
return recursiveParent(schema.parent);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
6
21
|
var useRelationFields = function useRelationFields() {
|
|
7
|
-
var
|
|
8
|
-
|
|
22
|
+
var fieldSchema = useFieldSchema();
|
|
23
|
+
|
|
24
|
+
var _useCollectionManager = useCollectionManager(),
|
|
25
|
+
getCollectionFields = _useCollectionManager.getCollectionFields;
|
|
26
|
+
|
|
27
|
+
var fields = [];
|
|
28
|
+
|
|
29
|
+
if (fieldSchema['x-initializer']) {
|
|
30
|
+
fields = useCollection().fields;
|
|
31
|
+
} else {
|
|
32
|
+
var collection = recursiveParent(fieldSchema.parent);
|
|
33
|
+
|
|
34
|
+
if (collection) {
|
|
35
|
+
fields = getCollectionFields(collection);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
9
38
|
|
|
10
39
|
var relationFields = fields.filter(function (field) {
|
|
11
40
|
return ['linkTo', 'subTable', 'o2m', 'm2m', 'obo', 'oho', 'o2o', 'm2o'].includes(field.interface);
|
|
@@ -20,7 +20,8 @@ export var TabPaneInitializers = function TabPaneInitializers() {
|
|
|
20
20
|
return {
|
|
21
21
|
run: function run() {
|
|
22
22
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
23
|
-
var title;
|
|
23
|
+
var _form$values, title, icon;
|
|
24
|
+
|
|
24
25
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
25
26
|
while (1) {
|
|
26
27
|
switch (_context.prev = _context.next) {
|
|
@@ -29,13 +30,15 @@ export var TabPaneInitializers = function TabPaneInitializers() {
|
|
|
29
30
|
return form.submit();
|
|
30
31
|
|
|
31
32
|
case 2:
|
|
32
|
-
|
|
33
|
+
_form$values = form.values, title = _form$values.title, icon = _form$values.icon;
|
|
33
34
|
insertBeforeEnd({
|
|
34
35
|
type: 'void',
|
|
35
36
|
title: title,
|
|
36
37
|
'x-component': 'Tabs.TabPane',
|
|
37
38
|
'x-designer': 'Tabs.Designer',
|
|
38
|
-
'x-component-props': {
|
|
39
|
+
'x-component-props': {
|
|
40
|
+
icon: icon
|
|
41
|
+
},
|
|
39
42
|
properties: {
|
|
40
43
|
grid: {
|
|
41
44
|
type: 'void',
|
|
@@ -94,6 +97,11 @@ export var TabPaneInitializers = function TabPaneInitializers() {
|
|
|
94
97
|
'x-component': 'Input',
|
|
95
98
|
'x-decorator': 'FormItem'
|
|
96
99
|
},
|
|
100
|
+
icon: {
|
|
101
|
+
title: '{{t("Icon")}}',
|
|
102
|
+
'x-component': 'IconPicker',
|
|
103
|
+
'x-decorator': 'FormItem'
|
|
104
|
+
},
|
|
97
105
|
footer: {
|
|
98
106
|
'x-component': 'Action.Modal.Footer',
|
|
99
107
|
type: 'void',
|
|
@@ -37,6 +37,17 @@ export var TableActionInitializers = {
|
|
|
37
37
|
skipScopeCheck: true
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
}, {
|
|
41
|
+
type: 'item',
|
|
42
|
+
title: "{{t('Refresh')}}",
|
|
43
|
+
component: 'RefreshActionInitializer',
|
|
44
|
+
schema: {
|
|
45
|
+
'x-align': 'right',
|
|
46
|
+
'x-decorator': 'ACLActionProvider',
|
|
47
|
+
'x-acl-action-props': {
|
|
48
|
+
skipScopeCheck: true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
40
51
|
}]
|
|
41
52
|
}]
|
|
42
53
|
};
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
2
|
|
|
9
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -16,81 +10,273 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
16
10
|
|
|
17
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
|
|
19
|
+
import { connect, useField, useFieldSchema } from '@formily/react';
|
|
20
|
+
import { merge } from '@formily/shared';
|
|
21
|
+
import { Cascader, Select, Space } from 'antd';
|
|
22
|
+
import React, { useEffect, useState } from 'react';
|
|
22
23
|
import { useTranslation } from 'react-i18next';
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
24
|
+
import { useFormBlockContext } from '../../../block-provider';
|
|
25
|
+
import { CollectionFieldProvider, useCollection, useCollectionField, useCollectionFilterOptions } from '../../../collection-manager';
|
|
26
|
+
import { useCompile, useComponent } from '../../../schema-component';
|
|
27
|
+
var DYNAMIC_RECORD_REG = /\{\{\s*currentRecord\.(.*)\s*\}\}/;
|
|
28
|
+
var DYNAMIC_USER_REG = /\{\{\s*currentUser\.(.*)\s*\}\}/;
|
|
29
|
+
var DYNAMIC_TIME_REG = /\{\{\s*currentTime\s*\}\}/;
|
|
30
|
+
|
|
31
|
+
var InternalField = function InternalField(props) {
|
|
32
|
+
var field = useField();
|
|
33
|
+
var fieldSchema = useFieldSchema();
|
|
34
|
+
|
|
35
|
+
var _useCollectionField = useCollectionField(),
|
|
36
|
+
name = _useCollectionField.name,
|
|
37
|
+
interfaceType = _useCollectionField.interface,
|
|
38
|
+
uiSchema = _useCollectionField.uiSchema;
|
|
39
|
+
|
|
40
|
+
var component = useComponent(uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['x-component']);
|
|
41
|
+
var compile = useCompile();
|
|
42
|
+
|
|
43
|
+
var setFieldProps = function setFieldProps(key, value) {
|
|
44
|
+
field[key] = typeof field[key] === 'undefined' ? value : field[key];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
var setRequired = function setRequired() {
|
|
48
|
+
if (typeof fieldSchema['required'] === 'undefined') {
|
|
49
|
+
field.required = !!uiSchema['required'];
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var ctx = useFormBlockContext();
|
|
54
|
+
useEffect(function () {
|
|
55
|
+
if (ctx === null || ctx === void 0 ? void 0 : ctx.field) {
|
|
56
|
+
ctx.field.added = ctx.field.added || new Set();
|
|
57
|
+
ctx.field.added.add(fieldSchema.name);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
useEffect(function () {
|
|
61
|
+
if (!uiSchema) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
setFieldProps('content', uiSchema['x-content']);
|
|
66
|
+
setFieldProps('title', uiSchema.title);
|
|
67
|
+
setFieldProps('description', uiSchema.description);
|
|
68
|
+
setFieldProps('initialValue', uiSchema.default);
|
|
69
|
+
|
|
70
|
+
if (!field.validator && uiSchema['x-validator']) {
|
|
71
|
+
field.validator = uiSchema['x-validator'];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (fieldSchema['x-disabled'] === true) {
|
|
75
|
+
field.disabled = true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (fieldSchema['x-read-pretty'] === true) {
|
|
79
|
+
field.readPretty = true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
setRequired(); // @ts-ignore
|
|
83
|
+
|
|
84
|
+
field.dataSource = uiSchema.enum;
|
|
85
|
+
var originalProps = compile(uiSchema['x-component-props']) || {};
|
|
86
|
+
var componentProps = merge(originalProps, field.componentProps || {});
|
|
87
|
+
field.componentProps = componentProps; // field.component = [component, componentProps];
|
|
88
|
+
}, [JSON.stringify(uiSchema)]);
|
|
89
|
+
|
|
90
|
+
if (!uiSchema) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return /*#__PURE__*/React.createElement(component, props, props.children);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var CollectionField = connect(function (props) {
|
|
98
|
+
var fieldSchema = useFieldSchema();
|
|
99
|
+
return /*#__PURE__*/React.createElement(CollectionFieldProvider, {
|
|
100
|
+
name: fieldSchema.name
|
|
101
|
+
}, /*#__PURE__*/React.createElement(InternalField, _objectSpread({}, props)));
|
|
102
|
+
});
|
|
103
|
+
export var AssignedFieldValueType;
|
|
104
|
+
|
|
105
|
+
(function (AssignedFieldValueType) {
|
|
106
|
+
AssignedFieldValueType["ConstantValue"] = "constantValue";
|
|
107
|
+
AssignedFieldValueType["DynamicValue"] = "dynamicValue";
|
|
108
|
+
})(AssignedFieldValueType || (AssignedFieldValueType = {}));
|
|
109
|
+
|
|
25
110
|
export var AssignedField = function AssignedField(props) {
|
|
26
|
-
var
|
|
111
|
+
var _initFieldType, _DYNAMIC_RECORD_REG$e, _DYNAMIC_RECORD_REG$e2, _DYNAMIC_RECORD_REG$e3, _DYNAMIC_USER_REG$exe, _DYNAMIC_USER_REG$exe2, _DYNAMIC_USER_REG$exe3;
|
|
27
112
|
|
|
28
113
|
var _useTranslation = useTranslation(),
|
|
29
114
|
t = _useTranslation.t;
|
|
30
115
|
|
|
31
116
|
var compile = useCompile();
|
|
32
117
|
var field = useField();
|
|
33
|
-
var fieldSchema = useFieldSchema();
|
|
118
|
+
var fieldSchema = useFieldSchema();
|
|
119
|
+
var isDynamicValue = DYNAMIC_RECORD_REG.test(field.value) || DYNAMIC_USER_REG.test(field.value) || DYNAMIC_TIME_REG.test(field.value);
|
|
120
|
+
var initType = isDynamicValue ? AssignedFieldValueType.DynamicValue : AssignedFieldValueType.ConstantValue;
|
|
34
121
|
|
|
35
|
-
var _useState = useState(
|
|
122
|
+
var _useState = useState(initType),
|
|
36
123
|
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
124
|
+
type = _useState2[0],
|
|
125
|
+
setType = _useState2[1];
|
|
126
|
+
|
|
127
|
+
var initFieldType = (_initFieldType = {}, _defineProperty(_initFieldType, "".concat(DYNAMIC_TIME_REG.test(field.value)), 'currentTime'), _defineProperty(_initFieldType, "".concat(DYNAMIC_USER_REG.test(field.value)), 'currentUser'), _defineProperty(_initFieldType, "".concat(DYNAMIC_RECORD_REG.test(field.value)), 'currentRecord'), _initFieldType);
|
|
128
|
+
|
|
129
|
+
var _useState3 = useState(initFieldType['true']),
|
|
130
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
131
|
+
fieldType = _useState4[0],
|
|
132
|
+
setFieldType = _useState4[1];
|
|
133
|
+
|
|
134
|
+
var initRecordValue = (_DYNAMIC_RECORD_REG$e = (_DYNAMIC_RECORD_REG$e2 = DYNAMIC_RECORD_REG.exec(field.value)) === null || _DYNAMIC_RECORD_REG$e2 === void 0 ? void 0 : (_DYNAMIC_RECORD_REG$e3 = _DYNAMIC_RECORD_REG$e2[1]) === null || _DYNAMIC_RECORD_REG$e3 === void 0 ? void 0 : _DYNAMIC_RECORD_REG$e3.split('.')) !== null && _DYNAMIC_RECORD_REG$e !== void 0 ? _DYNAMIC_RECORD_REG$e : [];
|
|
135
|
+
|
|
136
|
+
var _useState5 = useState(initRecordValue),
|
|
137
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
138
|
+
recordValue = _useState6[0],
|
|
139
|
+
setRecordValue = _useState6[1];
|
|
140
|
+
|
|
141
|
+
var initUserValue = (_DYNAMIC_USER_REG$exe = (_DYNAMIC_USER_REG$exe2 = DYNAMIC_USER_REG.exec(field.value)) === null || _DYNAMIC_USER_REG$exe2 === void 0 ? void 0 : (_DYNAMIC_USER_REG$exe3 = _DYNAMIC_USER_REG$exe2[1]) === null || _DYNAMIC_USER_REG$exe3 === void 0 ? void 0 : _DYNAMIC_USER_REG$exe3.split('.')) !== null && _DYNAMIC_USER_REG$exe !== void 0 ? _DYNAMIC_USER_REG$exe : [];
|
|
142
|
+
|
|
143
|
+
var _useState7 = useState(initUserValue),
|
|
144
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
145
|
+
userValue = _useState8[0],
|
|
146
|
+
setUserValue = _useState8[1];
|
|
59
147
|
|
|
148
|
+
var initValue = isDynamicValue ? '' : field.value;
|
|
149
|
+
|
|
150
|
+
var _useState9 = useState(initValue),
|
|
151
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
152
|
+
value = _useState10[0],
|
|
153
|
+
setValue = _useState10[1];
|
|
154
|
+
|
|
155
|
+
var _useState11 = useState([]),
|
|
156
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
157
|
+
options = _useState12[0],
|
|
158
|
+
setOptions = _useState12[1];
|
|
159
|
+
|
|
160
|
+
var _useCollection = useCollection(),
|
|
161
|
+
getField = _useCollection.getField;
|
|
162
|
+
|
|
163
|
+
var collectionField = getField(fieldSchema.name);
|
|
164
|
+
var fields = useCollectionFilterOptions(collectionField === null || collectionField === void 0 ? void 0 : collectionField.collectionName);
|
|
165
|
+
var userFields = useCollectionFilterOptions('users');
|
|
166
|
+
var dateTimeFields = ['createdAt', 'datetime', 'time', 'updatedAt'];
|
|
167
|
+
useEffect(function () {
|
|
168
|
+
var opt = [{
|
|
169
|
+
name: 'currentRecord',
|
|
170
|
+
title: t('Current record')
|
|
171
|
+
}, {
|
|
172
|
+
name: 'currentUser',
|
|
173
|
+
title: t('Current user')
|
|
174
|
+
}];
|
|
175
|
+
|
|
176
|
+
if (dateTimeFields.includes(collectionField.interface)) {
|
|
177
|
+
opt.unshift({
|
|
178
|
+
name: 'currentTime',
|
|
179
|
+
title: t('Current time')
|
|
180
|
+
});
|
|
181
|
+
} else {}
|
|
182
|
+
|
|
183
|
+
setOptions(compile(opt));
|
|
184
|
+
}, []);
|
|
185
|
+
useEffect(function () {
|
|
186
|
+
if (type === AssignedFieldValueType.ConstantValue) {
|
|
187
|
+
field.value = value;
|
|
188
|
+
} else {
|
|
189
|
+
if (fieldType === 'currentTime') {
|
|
190
|
+
field.value = '{{currentTime}}';
|
|
191
|
+
} else if (fieldType === 'currentUser') {
|
|
192
|
+
(userValue === null || userValue === void 0 ? void 0 : userValue.length) > 0 && (field.value = "{{currentUser.".concat(userValue.join('.'), "}}"));
|
|
193
|
+
} else if (fieldType === 'currentRecord') {
|
|
194
|
+
(recordValue === null || recordValue === void 0 ? void 0 : recordValue.length) > 0 && (field.value = "{{currentRecord.".concat(recordValue.join('.'), "}}"));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}, [type, value, fieldType, userValue, recordValue]);
|
|
198
|
+
useEffect(function () {
|
|
199
|
+
if (type === AssignedFieldValueType.ConstantValue) {
|
|
200
|
+
setFieldType(null);
|
|
201
|
+
setUserValue([]);
|
|
202
|
+
setRecordValue([]);
|
|
203
|
+
}
|
|
204
|
+
}, [type]);
|
|
205
|
+
|
|
206
|
+
var typeChangeHandler = function typeChangeHandler(val) {
|
|
207
|
+
setType(val);
|
|
208
|
+
};
|
|
60
209
|
|
|
61
210
|
var valueChangeHandler = function valueChangeHandler(val) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
211
|
+
var _val$target$value, _val$target;
|
|
212
|
+
|
|
213
|
+
setValue((_val$target$value = val === null || val === void 0 ? void 0 : (_val$target = val.target) === null || _val$target === void 0 ? void 0 : _val$target.value) !== null && _val$target$value !== void 0 ? _val$target$value : val);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
var fieldTypeChangeHandler = function fieldTypeChangeHandler(val) {
|
|
217
|
+
setFieldType(val);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
var recordChangeHandler = function recordChangeHandler(val) {
|
|
221
|
+
setRecordValue(val);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
var userChangeHandler = function userChangeHandler(val) {
|
|
225
|
+
setUserValue(val);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
return /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Select, {
|
|
229
|
+
defaultValue: type,
|
|
230
|
+
value: type,
|
|
231
|
+
style: {
|
|
232
|
+
width: 150
|
|
233
|
+
},
|
|
234
|
+
onChange: typeChangeHandler
|
|
235
|
+
}, /*#__PURE__*/React.createElement(Select.Option, {
|
|
236
|
+
value: AssignedFieldValueType.ConstantValue
|
|
237
|
+
}, t('Constant value')), /*#__PURE__*/React.createElement(Select.Option, {
|
|
238
|
+
value: AssignedFieldValueType.DynamicValue
|
|
239
|
+
}, t('Dynamic value'))), type === AssignedFieldValueType.ConstantValue ? /*#__PURE__*/React.createElement(CollectionField, _objectSpread(_objectSpread({}, props), {}, {
|
|
240
|
+
value: value,
|
|
241
|
+
onChange: valueChangeHandler,
|
|
242
|
+
style: {
|
|
243
|
+
minWidth: 150
|
|
244
|
+
}
|
|
245
|
+
})) : /*#__PURE__*/React.createElement(Select, {
|
|
246
|
+
defaultValue: fieldType,
|
|
247
|
+
value: fieldType,
|
|
248
|
+
style: {
|
|
249
|
+
minWidth: 150
|
|
250
|
+
},
|
|
251
|
+
onChange: fieldTypeChangeHandler
|
|
252
|
+
}, options === null || options === void 0 ? void 0 : options.map(function (opt) {
|
|
253
|
+
return /*#__PURE__*/React.createElement(Select.Option, {
|
|
254
|
+
key: opt.name,
|
|
255
|
+
value: opt.name
|
|
256
|
+
}, opt.title);
|
|
257
|
+
})), fieldType === 'currentRecord' && /*#__PURE__*/React.createElement(Cascader, {
|
|
258
|
+
fieldNames: {
|
|
259
|
+
label: 'title',
|
|
260
|
+
value: 'name',
|
|
261
|
+
children: 'children'
|
|
262
|
+
},
|
|
263
|
+
style: {
|
|
264
|
+
minWidth: 150
|
|
265
|
+
},
|
|
266
|
+
options: compile(fields),
|
|
267
|
+
onChange: recordChangeHandler,
|
|
268
|
+
defaultValue: recordValue
|
|
269
|
+
}), fieldType === 'currentUser' && /*#__PURE__*/React.createElement(Cascader, {
|
|
270
|
+
fieldNames: {
|
|
271
|
+
label: 'title',
|
|
272
|
+
value: 'name',
|
|
273
|
+
children: 'children'
|
|
274
|
+
},
|
|
275
|
+
style: {
|
|
276
|
+
minWidth: 150
|
|
277
|
+
},
|
|
278
|
+
options: compile(userFields),
|
|
279
|
+
onChange: userChangeHandler,
|
|
280
|
+
defaultValue: userValue
|
|
281
|
+
}));
|
|
96
282
|
};
|
|
@@ -15,7 +15,9 @@ export declare const CreateActionInitializer: (props: any) => JSX.Element;
|
|
|
15
15
|
export declare const ViewActionInitializer: (props: any) => JSX.Element;
|
|
16
16
|
export declare const UpdateActionInitializer: (props: any) => JSX.Element;
|
|
17
17
|
export declare const DestroyActionInitializer: (props: any) => JSX.Element;
|
|
18
|
+
export declare const PrintActionInitializer: (props: any) => JSX.Element;
|
|
18
19
|
export declare const BulkDestroyActionInitializer: (props: any) => JSX.Element;
|
|
20
|
+
export declare const RefreshActionInitializer: (props: any) => JSX.Element;
|
|
19
21
|
export declare const SubmitActionInitializer: (props: any) => JSX.Element;
|
|
20
22
|
export declare const CreateSubmitActionInitializer: (props: any) => JSX.Element;
|
|
21
23
|
export declare const UpdateSubmitActionInitializer: (props: any) => JSX.Element;
|