@nocobase/client 0.10.0-alpha.2 → 0.10.0-alpha.4
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/acl/Configuration/MenuItemsProvider.js +3 -3
- package/es/application/Application.js +2 -2
- package/es/auth/SigninPage.js +12 -9
- package/es/block-provider/GanttBlockProvider.js +5 -4
- package/es/block-provider/TableBlockProvider.d.ts +1 -0
- package/es/block-provider/TableBlockProvider.js +51 -17
- package/es/collection-manager/Configuration/AddCollectionAction.js +31 -25
- package/es/collection-manager/Configuration/AddFieldAction.js +45 -32
- package/es/collection-manager/Configuration/AddSubFieldAction.js +24 -19
- package/es/collection-manager/Configuration/ConfigurationTabs.js +57 -50
- package/es/collection-manager/hooks/useOptions.js +39 -36
- package/es/collection-manager/interfaces/integer.js +1 -1
- package/es/collection-manager/interfaces/number.js +3 -3
- package/es/collection-manager/interfaces/percent.js +3 -3
- package/es/formula/Expression.js +66 -46
- package/es/hooks/index.d.ts +1 -0
- package/es/hooks/index.js +1 -0
- package/es/hooks/useAdminSchemaUid.d.ts +1 -0
- package/es/hooks/useAdminSchemaUid.js +6 -0
- package/es/hooks/useMenuItem.d.ts +37 -0
- package/es/hooks/useMenuItem.js +93 -0
- package/es/index.d.ts +2 -3
- package/es/index.js +3 -4
- package/es/locale/en_US.d.ts +3 -1
- package/es/locale/en_US.js +4 -2
- package/es/locale/es_ES.d.ts +1 -1
- package/es/locale/es_ES.js +1 -1
- package/es/locale/ja_JP.d.ts +3 -1
- package/es/locale/ja_JP.js +4 -2
- package/es/locale/pt_BR.d.ts +1 -1
- package/es/locale/pt_BR.js +1 -1
- package/es/locale/ru_RU.d.ts +1 -1
- package/es/locale/ru_RU.js +1 -1
- package/es/locale/zh_CN.d.ts +3 -1
- package/es/locale/zh_CN.js +3 -1
- package/es/pm/Card.js +5 -5
- package/es/pm/PluginManagerLink.js +16 -12
- package/es/pm/index.d.ts +2 -1
- package/es/pm/index.js +36 -22
- package/es/route-switch/antd/admin-layout/index.js +5 -5
- package/es/schema-component/antd/action/Action.Designer.js +3 -5
- package/es/schema-component/antd/action/Action.Drawer.js +1 -1
- package/es/schema-component/antd/action/ActionBar.js +1 -1
- package/es/schema-component/antd/association-field/Editable.js +1 -2
- package/es/schema-component/antd/association-field/Nester.js +7 -1
- package/es/schema-component/antd/association-field/SubTable.js +1 -1
- package/es/schema-component/antd/calendar/DeleteEvent.js +1 -1
- package/es/schema-component/antd/cascader/Cascader.js +1 -1
- package/es/schema-component/antd/form-item/FormItem.js +10 -3
- package/es/schema-component/antd/form-v2/Form.js +2 -2
- package/es/schema-component/antd/gantt/components/gantt/gantt.js +0 -1
- package/es/schema-component/antd/gantt/components/grid/grid-body.js +3 -3
- package/es/schema-component/antd/gantt/components/task-item/bar/bar-small.js +1 -1
- package/es/schema-component/antd/gantt/components/task-item/task-item.js +1 -1
- package/es/schema-component/antd/gantt/helpers/bar-helper.d.ts +1 -1
- package/es/schema-component/antd/gantt/helpers/bar-helper.js +4 -4
- package/es/schema-component/antd/gantt/helpers/other-helper.js +3 -1
- package/es/schema-component/antd/grid/Grid.js +2 -2
- package/es/schema-component/antd/grid-card/GridCard.Designer.js +3 -4
- package/es/schema-component/antd/grid-card/GridCard.Item.js +3 -3
- package/es/schema-component/antd/index.less +1 -3
- package/es/schema-component/antd/list/List.Decorator.js +3 -3
- package/es/schema-component/antd/list/List.Item.js +2 -2
- package/es/schema-component/antd/list/List.d.ts +2 -2
- package/es/schema-component/antd/list/List.js +6 -6
- package/es/schema-component/antd/menu/Menu.js +306 -156
- package/es/schema-component/antd/page/Page.js +29 -23
- package/es/schema-component/antd/remote-select/RemoteSelect.js +60 -10
- package/es/schema-component/antd/remote-select/utils.d.ts +4 -0
- package/es/schema-component/antd/remote-select/utils.js +31 -0
- package/es/schema-component/antd/table-v2/FilterDynamicComponent.js +17 -2
- package/es/schema-component/antd/table-v2/Table.Column.Designer.js +51 -12
- package/es/schema-component/antd/table-v2/Table.js +28 -47
- package/es/schema-component/antd/table-v2/utils.d.ts +0 -1
- package/es/schema-component/antd/table-v2/utils.js +0 -28
- package/es/schema-component/antd/tabs/Tabs.js +35 -22
- package/es/schema-component/antd/tabs/context.d.ts +1 -1
- package/es/schema-component/antd/upload/ReadPretty.js +7 -3
- package/es/schema-component/antd/variable/VariableSelect.js +1 -1
- package/es/schema-component/common/utils/uitls.d.ts +1 -0
- package/es/schema-component/common/utils/uitls.js +1 -1
- package/es/schema-initializer/SchemaInitializer.d.ts +7 -2
- package/es/schema-initializer/SchemaInitializer.js +158 -103
- package/es/schema-initializer/SelectCollection.d.ts +1 -2
- package/es/schema-initializer/SelectCollection.js +19 -16
- package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -1
- package/es/schema-initializer/buttons/TableActionInitializers.js +5 -5
- package/es/schema-initializer/buttons/TableColumnInitializers.js +3 -2
- package/es/schema-initializer/components/CreateRecordAction.js +37 -27
- package/es/schema-initializer/components/assigned-field/AssignedField.js +2 -1
- package/es/schema-initializer/items/CalendarBlockInitializer.js +2 -2
- package/es/schema-initializer/utils.d.ts +0 -1
- package/es/schema-initializer/utils.js +40 -25
- package/es/schema-settings/SchemaSettings.js +110 -29
- package/es/schema-settings/VariableInput/hooks/useFormVariable.d.ts +19 -0
- package/es/schema-settings/VariableInput/hooks/useFormVariable.js +89 -0
- package/es/schema-settings/VariableInput/hooks/useIterationVariable.d.ts +8 -0
- package/es/schema-settings/VariableInput/hooks/useIterationVariable.js +77 -0
- package/es/schema-settings/VariableInput/hooks/useVariableOptions.d.ts +5 -12
- package/es/schema-settings/VariableInput/hooks/useVariableOptions.js +19 -3
- package/es/schema-templates/BlockTemplateDetails.js +5 -1
- package/es/schema-templates/BlockTemplatePage.js +4 -1
- package/es/user/ChangePassword.d.ts +1 -2
- package/es/user/ChangePassword.js +30 -26
- package/es/user/CurrentUser.js +172 -141
- package/es/user/EditProfile.d.ts +1 -2
- package/es/user/EditProfile.js +30 -24
- package/es/user/LanguageSettings.d.ts +1 -2
- package/es/user/LanguageSettings.js +67 -64
- package/es/user/SigninPage.js +25 -22
- package/es/user/SwitchRole.d.ts +1 -2
- package/es/user/SwitchRole.js +54 -49
- package/es/user/ThemeSettings.d.ts +1 -2
- package/es/user/ThemeSettings.js +56 -52
- package/lib/acl/Configuration/MenuItemsProvider.js +3 -3
- package/lib/application/Application.js +2 -2
- package/lib/auth/SigninPage.js +25 -22
- package/lib/block-provider/GanttBlockProvider.js +5 -4
- package/lib/block-provider/TableBlockProvider.d.ts +1 -0
- package/lib/block-provider/TableBlockProvider.js +53 -17
- package/lib/collection-manager/Configuration/AddCollectionAction.js +29 -23
- package/lib/collection-manager/Configuration/AddFieldAction.js +43 -30
- package/lib/collection-manager/Configuration/AddSubFieldAction.js +22 -17
- package/lib/collection-manager/Configuration/ConfigurationTabs.js +57 -49
- package/lib/collection-manager/hooks/useOptions.js +39 -36
- package/lib/collection-manager/interfaces/integer.js +1 -1
- package/lib/collection-manager/interfaces/number.js +3 -3
- package/lib/collection-manager/interfaces/percent.js +3 -3
- package/lib/formula/Expression.js +64 -44
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +11 -0
- package/lib/hooks/useAdminSchemaUid.d.ts +1 -0
- package/lib/hooks/useAdminSchemaUid.js +13 -0
- package/lib/hooks/useMenuItem.d.ts +37 -0
- package/lib/hooks/useMenuItem.js +108 -0
- package/lib/index.d.ts +2 -3
- package/lib/index.js +22 -33
- package/lib/locale/en_US.d.ts +3 -1
- package/lib/locale/en_US.js +4 -2
- package/lib/locale/es_ES.d.ts +1 -1
- package/lib/locale/es_ES.js +1 -1
- package/lib/locale/ja_JP.d.ts +3 -1
- package/lib/locale/ja_JP.js +4 -2
- package/lib/locale/pt_BR.d.ts +1 -1
- package/lib/locale/pt_BR.js +1 -1
- package/lib/locale/ru_RU.d.ts +1 -1
- package/lib/locale/ru_RU.js +1 -1
- package/lib/locale/zh_CN.d.ts +3 -1
- package/lib/locale/zh_CN.js +3 -1
- package/lib/pm/Card.js +6 -6
- package/lib/pm/PluginManagerLink.js +15 -10
- package/lib/pm/index.d.ts +2 -1
- package/lib/pm/index.js +37 -23
- package/lib/route-switch/antd/admin-layout/index.js +4 -4
- package/lib/schema-component/antd/action/Action.Designer.js +2 -4
- package/lib/schema-component/antd/action/Action.Drawer.js +1 -1
- package/lib/schema-component/antd/association-field/Editable.js +0 -1
- package/lib/schema-component/antd/association-field/Nester.js +6 -0
- package/lib/schema-component/antd/association-field/SubTable.js +1 -1
- package/lib/schema-component/antd/calendar/DeleteEvent.js +1 -1
- package/lib/schema-component/antd/cascader/Cascader.js +1 -1
- package/lib/schema-component/antd/form-item/FormItem.js +10 -3
- package/lib/schema-component/antd/form-v2/Form.js +2 -2
- package/lib/schema-component/antd/gantt/components/gantt/gantt.js +0 -1
- package/lib/schema-component/antd/gantt/components/grid/grid-body.js +2 -2
- package/lib/schema-component/antd/gantt/components/task-item/bar/bar-small.js +1 -1
- package/lib/schema-component/antd/gantt/components/task-item/task-item.js +1 -1
- package/lib/schema-component/antd/gantt/helpers/bar-helper.d.ts +1 -1
- package/lib/schema-component/antd/gantt/helpers/bar-helper.js +4 -4
- package/lib/schema-component/antd/gantt/helpers/other-helper.js +3 -1
- package/lib/schema-component/antd/grid/Grid.js +1 -1
- package/lib/schema-component/antd/grid-card/GridCard.Designer.js +4 -5
- package/lib/schema-component/antd/grid-card/GridCard.Item.js +8 -8
- package/lib/schema-component/antd/index.less +1 -3
- package/lib/schema-component/antd/list/List.Decorator.js +3 -3
- package/lib/schema-component/antd/list/List.Item.js +6 -6
- package/lib/schema-component/antd/list/List.d.ts +2 -2
- package/lib/schema-component/antd/list/List.js +24 -24
- package/lib/schema-component/antd/menu/Menu.js +304 -154
- package/lib/schema-component/antd/page/Page.js +29 -23
- package/lib/schema-component/antd/remote-select/RemoteSelect.js +57 -7
- package/lib/schema-component/antd/remote-select/utils.d.ts +4 -0
- package/lib/schema-component/antd/remote-select/utils.js +41 -0
- package/lib/schema-component/antd/table-v2/FilterDynamicComponent.js +17 -2
- package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +50 -11
- package/lib/schema-component/antd/table-v2/Table.js +26 -45
- package/lib/schema-component/antd/table-v2/utils.d.ts +0 -1
- package/lib/schema-component/antd/table-v2/utils.js +0 -29
- package/lib/schema-component/antd/tabs/Tabs.js +34 -21
- package/lib/schema-component/antd/tabs/context.d.ts +1 -1
- package/lib/schema-component/antd/upload/ReadPretty.js +7 -3
- package/lib/schema-component/antd/variable/VariableSelect.js +1 -1
- package/lib/schema-component/common/utils/uitls.d.ts +1 -0
- package/lib/schema-component/common/utils/uitls.js +3 -1
- package/lib/schema-initializer/SchemaInitializer.d.ts +7 -2
- package/lib/schema-initializer/SchemaInitializer.js +155 -101
- package/lib/schema-initializer/SelectCollection.d.ts +1 -2
- package/lib/schema-initializer/SelectCollection.js +22 -17
- package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +1 -1
- package/lib/schema-initializer/buttons/TableActionInitializers.js +5 -5
- package/lib/schema-initializer/buttons/TableColumnInitializers.js +2 -1
- package/lib/schema-initializer/components/CreateRecordAction.js +35 -25
- package/lib/schema-initializer/components/assigned-field/AssignedField.js +2 -1
- package/lib/schema-initializer/items/CalendarBlockInitializer.js +9 -9
- package/lib/schema-initializer/utils.d.ts +0 -1
- package/lib/schema-initializer/utils.js +41 -25
- package/lib/schema-settings/SchemaSettings.js +106 -27
- package/lib/schema-settings/VariableInput/hooks/useFormVariable.d.ts +19 -0
- package/lib/schema-settings/VariableInput/hooks/useFormVariable.js +96 -0
- package/lib/schema-settings/VariableInput/hooks/useIterationVariable.d.ts +8 -0
- package/lib/schema-settings/VariableInput/hooks/useIterationVariable.js +84 -0
- package/lib/schema-settings/VariableInput/hooks/useVariableOptions.d.ts +5 -12
- package/lib/schema-settings/VariableInput/hooks/useVariableOptions.js +19 -3
- package/lib/schema-templates/BlockTemplateDetails.js +5 -1
- package/lib/schema-templates/BlockTemplatePage.js +5 -2
- package/lib/user/ChangePassword.d.ts +1 -2
- package/lib/user/ChangePassword.js +30 -26
- package/lib/user/CurrentUser.js +166 -135
- package/lib/user/EditProfile.d.ts +1 -2
- package/lib/user/EditProfile.js +31 -25
- package/lib/user/LanguageSettings.d.ts +1 -2
- package/lib/user/LanguageSettings.js +66 -63
- package/lib/user/SigninPage.js +25 -22
- package/lib/user/SwitchRole.d.ts +1 -2
- package/lib/user/SwitchRole.js +57 -51
- package/lib/user/ThemeSettings.d.ts +1 -2
- package/lib/user/ThemeSettings.js +59 -54
- package/package.json +9 -8
- package/es/settings-form/SettingsForm.d.ts +0 -13
- package/es/settings-form/SettingsForm.js +0 -309
- package/es/settings-form/index.d.ts +0 -1
- package/es/settings-form/index.js +0 -1
- package/lib/settings-form/SettingsForm.d.ts +0 -13
- package/lib/settings-form/SettingsForm.js +0 -320
- package/lib/settings-form/index.d.ts +0 -1
- package/lib/settings-form/index.js +0 -16
|
@@ -15,8 +15,8 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(
|
|
|
15
15
|
import { DownOutlined, PlusOutlined } from '@ant-design/icons';
|
|
16
16
|
import { css } from '@emotion/css';
|
|
17
17
|
import { RecursionField, observer, useField, useFieldSchema } from '@formily/react';
|
|
18
|
-
import { Button, Dropdown
|
|
19
|
-
import React, { useEffect, useState } from 'react';
|
|
18
|
+
import { Button, Dropdown } from 'antd';
|
|
19
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
20
20
|
import { useDesignable } from '../../';
|
|
21
21
|
import { useACLRolesCheck, useRecordPkValue } from '../../acl/ACLProvider';
|
|
22
22
|
import { CollectionProvider, useCollection, useCollectionManager } from '../../collection-manager';
|
|
@@ -124,36 +124,46 @@ export var CreateAction = observer(function (props) {
|
|
|
124
124
|
var _useCollectionManager = useCollectionManager(),
|
|
125
125
|
getChildrenCollections = _useCollectionManager.getChildrenCollections;
|
|
126
126
|
var totalChildCollections = getChildrenCollections(collection.name);
|
|
127
|
-
var inheritsCollections =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
127
|
+
var inheritsCollections = useMemo(function () {
|
|
128
|
+
return enableChildren.map(function (k) {
|
|
129
|
+
if (!k) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
var childCollection = totalChildCollections.find(function (j) {
|
|
133
|
+
return j.name === k.collection;
|
|
134
|
+
});
|
|
135
|
+
if (!childCollection) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
return _objectSpread(_objectSpread({}, childCollection), {}, {
|
|
139
|
+
title: k.title || childCollection.title
|
|
140
|
+
});
|
|
141
|
+
}).filter(function (v) {
|
|
142
|
+
return v && actionAclCheck("".concat(v.name, ":create"));
|
|
139
143
|
});
|
|
140
|
-
}
|
|
141
|
-
return v && actionAclCheck("".concat(v.name, ":create"));
|
|
142
|
-
});
|
|
144
|
+
}, [enableChildren, totalChildCollections]);
|
|
143
145
|
var linkageRules = (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-linkage-rules']) || [];
|
|
144
146
|
var values = useRecord();
|
|
145
147
|
var compile = useCompile();
|
|
146
148
|
var _useDesignable = useDesignable(),
|
|
147
149
|
designable = _useDesignable.designable;
|
|
148
150
|
var icon = props.icon || /*#__PURE__*/React.createElement(PlusOutlined, null);
|
|
149
|
-
var
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
var menuItems = useMemo(function () {
|
|
152
|
+
return inheritsCollections.map(function (option) {
|
|
153
|
+
return {
|
|
154
|
+
key: option.name,
|
|
155
|
+
label: compile(option.title),
|
|
156
|
+
onClick: function onClick() {
|
|
157
|
+
return _onClick === null || _onClick === void 0 ? void 0 : _onClick(option.name);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
}, [inheritsCollections, _onClick]);
|
|
162
|
+
var menu = useMemo(function () {
|
|
163
|
+
return {
|
|
164
|
+
items: menuItems
|
|
165
|
+
};
|
|
166
|
+
}, [menuItems]);
|
|
157
167
|
useEffect(function () {
|
|
158
168
|
field.linkageProperty = {};
|
|
159
169
|
linkageRules.filter(function (k) {
|
|
@@ -178,12 +188,12 @@ export var CreateAction = observer(function (props) {
|
|
|
178
188
|
loading: false
|
|
179
189
|
})];
|
|
180
190
|
},
|
|
181
|
-
|
|
191
|
+
menu: menu,
|
|
182
192
|
onClick: function onClick(info) {
|
|
183
193
|
_onClick === null || _onClick === void 0 ? void 0 : _onClick(collection.name);
|
|
184
194
|
}
|
|
185
195
|
}, icon, props.children) : /*#__PURE__*/React.createElement(Dropdown, {
|
|
186
|
-
|
|
196
|
+
menu: menu
|
|
187
197
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
188
198
|
icon: icon,
|
|
189
199
|
type: componentType
|
|
@@ -93,6 +93,7 @@ export var AssignedField = function AssignedField(props) {
|
|
|
93
93
|
var _useTranslation = useTranslation(),
|
|
94
94
|
t = _useTranslation.t;
|
|
95
95
|
var compile = useCompile();
|
|
96
|
+
var collection = useCollection();
|
|
96
97
|
var field = useField();
|
|
97
98
|
var fieldSchema = useFieldSchema();
|
|
98
99
|
var isDynamicValue = DYNAMIC_RECORD_REG.test(field.value) || DYNAMIC_USER_REG.test(field.value) || DYNAMIC_TIME_REG.test(field.value);
|
|
@@ -128,7 +129,7 @@ export var AssignedField = function AssignedField(props) {
|
|
|
128
129
|
var _useCollection = useCollection(),
|
|
129
130
|
getField = _useCollection.getField;
|
|
130
131
|
var collectionField = getField(fieldSchema.name);
|
|
131
|
-
var fields = useCollectionFilterOptions(
|
|
132
|
+
var fields = useCollectionFilterOptions(collection === null || collection === void 0 ? void 0 : collection.name);
|
|
132
133
|
var userFields = useCollectionFilterOptions('users');
|
|
133
134
|
var dateTimeFields = ['createdAt', 'datetime', 'time', 'updatedAt'];
|
|
134
135
|
useEffect(function () {
|
|
@@ -7,10 +7,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
7
7
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
8
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
9
9
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
10
|
-
import React, { useContext } from 'react';
|
|
11
|
-
import { FormDialog, FormLayout } from '@formily/antd';
|
|
12
10
|
import { FormOutlined } from '@ant-design/icons';
|
|
11
|
+
import { FormDialog, FormLayout } from '@formily/antd';
|
|
13
12
|
import { SchemaOptionsContext } from '@formily/react';
|
|
13
|
+
import React, { useContext } from 'react';
|
|
14
14
|
import { useTranslation } from 'react-i18next';
|
|
15
15
|
import { useCollectionManager } from '../../collection-manager';
|
|
16
16
|
import { SchemaComponent, SchemaComponentOptions } from '../../schema-component';
|
|
@@ -14,10 +14,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
14
14
|
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; }
|
|
15
15
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
16
16
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
-
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."); }
|
|
19
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
20
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
17
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
22
18
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
23
19
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -29,9 +25,11 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
|
|
|
29
25
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
30
26
|
import { Schema, useFieldSchema, useForm } from '@formily/react';
|
|
31
27
|
import { uid } from '@formily/shared';
|
|
32
|
-
import
|
|
28
|
+
import { error } from '@nocobase/utils/client';
|
|
29
|
+
import _ from 'lodash';
|
|
30
|
+
import React, { useCallback, useContext, useMemo } from 'react';
|
|
33
31
|
import { useTranslation } from 'react-i18next';
|
|
34
|
-
import { BlockRequestContext } from '../';
|
|
32
|
+
import { BlockRequestContext, SchemaInitializerButtonContext } from '../';
|
|
35
33
|
import { useCollection, useCollectionManager } from '../collection-manager';
|
|
36
34
|
import { isAssocField } from '../filter-provider/utils';
|
|
37
35
|
import { useActionContext, useDesignable } from '../schema-component';
|
|
@@ -220,6 +218,10 @@ export var useInheritsTableColumnInitializerFields = function useInheritsTableCo
|
|
|
220
218
|
getInheritCollections = _useCollectionManager3.getInheritCollections,
|
|
221
219
|
getCollection = _useCollectionManager3.getCollection,
|
|
222
220
|
getParentCollectionFields = _useCollectionManager3.getParentCollectionFields;
|
|
221
|
+
var fieldSchema = useFieldSchema();
|
|
222
|
+
var isSubTable = fieldSchema['x-component'] === 'AssociationField.SubTable';
|
|
223
|
+
var form = useForm();
|
|
224
|
+
var isReadPretty = isSubTable ? form.readPretty : true;
|
|
223
225
|
var inherits = getInheritCollections(name);
|
|
224
226
|
return inherits === null || inherits === void 0 ? void 0 : inherits.map(function (v) {
|
|
225
227
|
var fields = getParentCollectionFields(v, name);
|
|
@@ -227,18 +229,30 @@ export var useInheritsTableColumnInitializerFields = function useInheritsTableCo
|
|
|
227
229
|
return _defineProperty({}, targetCollection === null || targetCollection === void 0 ? void 0 : targetCollection.title, fields === null || fields === void 0 ? void 0 : fields.filter(function (field) {
|
|
228
230
|
return field === null || field === void 0 ? void 0 : field.interface;
|
|
229
231
|
}).map(function (k) {
|
|
230
|
-
var _k$uiSchema;
|
|
232
|
+
var _getCollection2, _k$uiSchema, _k$uiSchema2;
|
|
231
233
|
var interfaceConfig = getInterface(k.interface);
|
|
234
|
+
var isFileCollection = (k === null || k === void 0 ? void 0 : k.target) && ((_getCollection2 = getCollection(k === null || k === void 0 ? void 0 : k.target)) === null || _getCollection2 === void 0 ? void 0 : _getCollection2.template) === 'file';
|
|
232
235
|
var schema = {
|
|
233
236
|
name: "".concat(k.name),
|
|
234
237
|
'x-component': 'CollectionField',
|
|
235
|
-
'x-read-pretty':
|
|
238
|
+
'x-read-pretty': isReadPretty || ((_k$uiSchema = k.uiSchema) === null || _k$uiSchema === void 0 ? void 0 : _k$uiSchema['x-read-pretty']),
|
|
236
239
|
'x-collection-field': "".concat(name, ".").concat(k.name),
|
|
237
|
-
'x-component-props': {
|
|
240
|
+
'x-component-props': isFileCollection ? {
|
|
241
|
+
fieldNames: {
|
|
242
|
+
label: 'preview',
|
|
243
|
+
value: 'id'
|
|
244
|
+
}
|
|
245
|
+
} : {},
|
|
246
|
+
'x-decorator': isSubTable ? quickEditField.includes(k.interface) || isFileCollection ? 'QuickEdit' : 'FormItem' : null,
|
|
247
|
+
'x-decorator-props': {
|
|
248
|
+
labelStyle: {
|
|
249
|
+
display: 'none'
|
|
250
|
+
}
|
|
251
|
+
}
|
|
238
252
|
};
|
|
239
253
|
return {
|
|
240
254
|
type: 'item',
|
|
241
|
-
title: (k === null || k === void 0 ? void 0 : (_k$
|
|
255
|
+
title: (k === null || k === void 0 ? void 0 : (_k$uiSchema2 = k.uiSchema) === null || _k$uiSchema2 === void 0 ? void 0 : _k$uiSchema2.title) || k.name,
|
|
242
256
|
component: 'TableCollectionFieldInitializer',
|
|
243
257
|
find: findTableColumn,
|
|
244
258
|
remove: removeTableColumn,
|
|
@@ -859,28 +873,26 @@ export var useCollectionDataSourceItems = function useCollectionDataSourceItems(
|
|
|
859
873
|
getCollectionFields = _useCollectionManager12.getCollectionFields;
|
|
860
874
|
var _useSchemaTemplateMan2 = useSchemaTemplateManager(),
|
|
861
875
|
getTemplatesByCollection = _useSchemaTemplateMan2.getTemplatesByCollection;
|
|
862
|
-
var
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
var
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
876
|
+
var _useContext = useContext(SchemaInitializerButtonContext),
|
|
877
|
+
searchValue = _useContext.searchValue,
|
|
878
|
+
setSearchValue = _useContext.setSearchValue;
|
|
879
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
880
|
+
var onChange = useCallback(_.debounce(setSearchValue, 300), [setSearchValue]);
|
|
881
|
+
if (!setSearchValue) {
|
|
882
|
+
error('useCollectionDataSourceItems: please use in SchemaInitializerButtonContext and provide setSearchValue');
|
|
883
|
+
return [];
|
|
884
|
+
}
|
|
870
885
|
var clearKeywords = function clearKeywords() {
|
|
871
|
-
|
|
872
|
-
onChange(null);
|
|
886
|
+
setSearchValue('');
|
|
873
887
|
};
|
|
874
888
|
return [{
|
|
875
889
|
key: 'tableBlock',
|
|
876
890
|
type: 'itemGroup',
|
|
877
891
|
title: /*#__PURE__*/React.createElement(SelectCollection, {
|
|
878
|
-
value:
|
|
879
|
-
onChange: onChange
|
|
880
|
-
setSelected: setSelected
|
|
892
|
+
value: searchValue,
|
|
893
|
+
onChange: onChange
|
|
881
894
|
}),
|
|
882
895
|
children: collections === null || collections === void 0 ? void 0 : (_collections$filter = collections.filter(function (item) {
|
|
883
|
-
var b = !value || selected.includes(item.name);
|
|
884
896
|
if (item.inherit) {
|
|
885
897
|
return false;
|
|
886
898
|
}
|
|
@@ -894,7 +906,10 @@ export var useCollectionDataSourceItems = function useCollectionDataSourceItems(
|
|
|
894
906
|
} else if (item.template === 'file' && ['Kanban', 'FormItem', 'Calendar'].includes(componentName)) {
|
|
895
907
|
return false;
|
|
896
908
|
} else {
|
|
897
|
-
|
|
909
|
+
if (!item.title) {
|
|
910
|
+
return false;
|
|
911
|
+
}
|
|
912
|
+
return item.title.toUpperCase().includes(searchValue.toUpperCase()) && !((item === null || item === void 0 ? void 0 : item.isThrough) && (item === null || item === void 0 ? void 0 : item.autoCreate));
|
|
898
913
|
}
|
|
899
914
|
})) === null || _collections$filter === void 0 ? void 0 : _collections$filter.map(function (item, index) {
|
|
900
915
|
var templates = getTemplatesByCollection(item.name).filter(function (template) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
var _templateObject;
|
|
3
2
|
var _excluded = ["children", "fieldSchema"],
|
|
4
3
|
_excluded2 = ["title", "dn"],
|
|
5
4
|
_excluded3 = ["title", "options", "value", "onChange", "openOnHover", "onClick"],
|
|
@@ -8,6 +7,7 @@ var _excluded = ["children", "fieldSchema"],
|
|
|
8
7
|
_excluded6 = ["schema"],
|
|
9
8
|
_excluded7 = ["title", "onSubmit", "initialValues", "initialSchema", "schema", "modalTip", "components"],
|
|
10
9
|
_excluded8 = ["hidden", "title", "components", "scope", "effects", "schema", "onSubmit", "asyncGetInitialValues", "initialValues", "width"];
|
|
10
|
+
var _templateObject, _templateObject2;
|
|
11
11
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
12
12
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
13
13
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -16,7 +16,6 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
16
16
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
17
17
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
18
18
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
19
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
20
19
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
21
20
|
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."); }
|
|
22
21
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -30,21 +29,25 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
|
|
|
30
29
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
31
30
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
32
31
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
32
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
33
33
|
import { css } from '@emotion/css';
|
|
34
34
|
import { ArrayCollapse, ArrayItems, FormDialog, FormItem, FormLayout, Input } from '@formily/antd';
|
|
35
35
|
import { createForm } from '@formily/core';
|
|
36
36
|
import { SchemaOptionsContext, useField, useFieldSchema, useForm } from '@formily/react';
|
|
37
37
|
import { uid } from '@formily/shared';
|
|
38
38
|
import { error } from '@nocobase/utils/client';
|
|
39
|
-
import { Alert, Button, Cascader, Dropdown, Empty,
|
|
39
|
+
import { Alert, Button, Cascader, Dropdown, Empty, Modal, Select, Space, Switch } from 'antd';
|
|
40
40
|
import classNames from 'classnames';
|
|
41
41
|
import _, { cloneDeep } from 'lodash';
|
|
42
|
-
import React, { createContext, useCallback, useContext, useMemo,
|
|
42
|
+
import React, { createContext, useCallback, useContext, useMemo,
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
useTransition as useReactTransition, useState } from 'react';
|
|
43
45
|
import { createPortal } from 'react-dom';
|
|
44
46
|
import { useTranslation } from 'react-i18next';
|
|
45
47
|
import { APIClientProvider, ActionContextProvider, CollectionManagerContext, FormProvider, RemoteSchemaComponent, SchemaComponent, SchemaComponentContext, SchemaComponentOptions, createDesignable, findFormBlock, useAPIClient, useCollection, useCollectionManager, useCompile, useDesignable, useFilterBlock, useLinkageCollectionFilterOptions } from '..';
|
|
46
48
|
import { findFilterTargets, updateFilterTargets } from '../block-provider/hooks';
|
|
47
49
|
import { isSameCollection, useSupportedBlocks } from '../filter-provider/utils';
|
|
50
|
+
import { useCollectMenuItem, useCollectMenuItems, useMenuItem } from '../hooks/useMenuItem';
|
|
48
51
|
import { getTargetKey } from '../schema-component/antd/association-filter/utilts';
|
|
49
52
|
import { useSchemaTemplateManager } from '../schema-templates';
|
|
50
53
|
import { useBlockTemplateContext } from '../schema-templates/BlockTemplate';
|
|
@@ -53,6 +56,10 @@ import { EnableChildCollections } from './EnableChildCollections';
|
|
|
53
56
|
import { FormLinkageRules } from './LinkageRules';
|
|
54
57
|
import { useLinkageCollectionFieldOptions } from './LinkageRules/action-hooks';
|
|
55
58
|
var SchemaSettingsContext = /*#__PURE__*/createContext(null);
|
|
59
|
+
/**
|
|
60
|
+
* 用于去除菜单的消失动画,优化操作体验
|
|
61
|
+
*/
|
|
62
|
+
var hidden = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: none;\n"])));
|
|
56
63
|
export var useSchemaSettings = function useSchemaSettings() {
|
|
57
64
|
return useContext(SchemaSettingsContext);
|
|
58
65
|
};
|
|
@@ -73,6 +80,7 @@ export var SchemaSettingsProvider = function SchemaSettingsProvider(props) {
|
|
|
73
80
|
}, others)
|
|
74
81
|
}, children);
|
|
75
82
|
};
|
|
83
|
+
var overlayClassName = classNames('nb-schema-initializer-button-overlay', css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .ant-dropdown-menu-item-group-list {\n max-height: 40vh;\n overflow: auto;\n }\n "]))));
|
|
76
84
|
export var SchemaSettings = function SchemaSettings(props) {
|
|
77
85
|
var title = props.title,
|
|
78
86
|
dn = props.dn,
|
|
@@ -81,22 +89,42 @@ export var SchemaSettings = function SchemaSettings(props) {
|
|
|
81
89
|
_useState2 = _slicedToArray(_useState, 2),
|
|
82
90
|
visible = _useState2[0],
|
|
83
91
|
setVisible = _useState2[1];
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
var _useMenuItem = useMenuItem(),
|
|
93
|
+
Component = _useMenuItem.Component,
|
|
94
|
+
getMenuItems = _useMenuItem.getMenuItems;
|
|
95
|
+
var _useReactTransition = useReactTransition(),
|
|
96
|
+
_useReactTransition2 = _slicedToArray(_useReactTransition, 2),
|
|
97
|
+
isPending = _useReactTransition2[0],
|
|
98
|
+
startTransition = _useReactTransition2[1];
|
|
99
|
+
var changeMenu = function changeMenu(v) {
|
|
100
|
+
startTransition(function () {
|
|
101
|
+
setVisible(v);
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
var items = getMenuItems(function () {
|
|
105
|
+
return props.children;
|
|
106
|
+
});
|
|
107
|
+
var dropdownMenu = function dropdownMenu() {
|
|
108
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Component, null), /*#__PURE__*/React.createElement(Dropdown, {
|
|
109
|
+
open: visible,
|
|
110
|
+
onOpenChange: function onOpenChange() {
|
|
111
|
+
changeMenu(!visible);
|
|
112
|
+
},
|
|
113
|
+
menu: {
|
|
114
|
+
items: items,
|
|
115
|
+
className: classNames(_defineProperty({}, hidden, !visible))
|
|
116
|
+
},
|
|
117
|
+
overlayClassName: overlayClassName
|
|
118
|
+
}, typeof title === 'string' ? /*#__PURE__*/React.createElement("span", null, title) : title));
|
|
119
|
+
};
|
|
92
120
|
if (dn) {
|
|
93
121
|
return /*#__PURE__*/React.createElement(SchemaSettingsProvider, _objectSpread({
|
|
94
122
|
visible: visible,
|
|
95
123
|
setVisible: setVisible,
|
|
96
124
|
dn: dn
|
|
97
|
-
}, others),
|
|
125
|
+
}, others), dropdownMenu());
|
|
98
126
|
}
|
|
99
|
-
return
|
|
127
|
+
return dropdownMenu();
|
|
100
128
|
};
|
|
101
129
|
SchemaSettings.Template = function Template(props) {
|
|
102
130
|
var componentName = props.componentName,
|
|
@@ -449,14 +477,17 @@ SchemaSettings.FormItemTemplate = function FormItemTemplate(props) {
|
|
|
449
477
|
}, t('Save as block template'));
|
|
450
478
|
};
|
|
451
479
|
SchemaSettings.Item = function Item(props) {
|
|
480
|
+
var _useCollectMenuItems = useCollectMenuItems(),
|
|
481
|
+
pushMenuItem = _useCollectMenuItems.pushMenuItem;
|
|
482
|
+
var _useCollectMenuItem = useCollectMenuItem(),
|
|
483
|
+
collectMenuItem = _useCollectMenuItem.collectMenuItem;
|
|
452
484
|
var eventKey = props.eventKey;
|
|
453
485
|
var key = useMemo(function () {
|
|
454
486
|
return uid();
|
|
455
487
|
}, []);
|
|
456
|
-
|
|
488
|
+
var item = _objectSpread(_objectSpread({}, _.omit(props, ['children'])), {}, {
|
|
457
489
|
key: key,
|
|
458
|
-
eventKey: eventKey || key
|
|
459
|
-
}, props), {}, {
|
|
490
|
+
eventKey: eventKey || key,
|
|
460
491
|
onClick: function onClick(info) {
|
|
461
492
|
var _props$onClick;
|
|
462
493
|
info.domEvent.preventDefault();
|
|
@@ -465,17 +496,67 @@ SchemaSettings.Item = function Item(props) {
|
|
|
465
496
|
},
|
|
466
497
|
style: {
|
|
467
498
|
minWidth: 120
|
|
468
|
-
}
|
|
469
|
-
|
|
499
|
+
},
|
|
500
|
+
label: props.children || props.title,
|
|
501
|
+
title: props.title
|
|
502
|
+
});
|
|
503
|
+
pushMenuItem === null || pushMenuItem === void 0 ? void 0 : pushMenuItem(item);
|
|
504
|
+
collectMenuItem === null || collectMenuItem === void 0 ? void 0 : collectMenuItem(item);
|
|
505
|
+
return null;
|
|
470
506
|
};
|
|
471
|
-
SchemaSettings.ItemGroup = function (props) {
|
|
472
|
-
|
|
507
|
+
SchemaSettings.ItemGroup = function ItemGroup(props) {
|
|
508
|
+
var _useMenuItem2 = useMenuItem(),
|
|
509
|
+
Component = _useMenuItem2.Component,
|
|
510
|
+
getMenuItems = _useMenuItem2.getMenuItems;
|
|
511
|
+
var _useCollectMenuItems2 = useCollectMenuItems(),
|
|
512
|
+
pushMenuItem = _useCollectMenuItems2.pushMenuItem;
|
|
513
|
+
var key = useMemo(function () {
|
|
514
|
+
return uid();
|
|
515
|
+
}, []);
|
|
516
|
+
var item = {
|
|
517
|
+
key: key,
|
|
518
|
+
type: 'group',
|
|
519
|
+
title: props.title,
|
|
520
|
+
label: props.title,
|
|
521
|
+
children: getMenuItems(function () {
|
|
522
|
+
return props.children;
|
|
523
|
+
})
|
|
524
|
+
};
|
|
525
|
+
pushMenuItem(item);
|
|
526
|
+
return /*#__PURE__*/React.createElement(Component, null);
|
|
473
527
|
};
|
|
474
|
-
SchemaSettings.SubMenu = function (props) {
|
|
475
|
-
|
|
528
|
+
SchemaSettings.SubMenu = function SubMenu(props) {
|
|
529
|
+
var _useMenuItem3 = useMenuItem(),
|
|
530
|
+
Component = _useMenuItem3.Component,
|
|
531
|
+
getMenuItems = _useMenuItem3.getMenuItems;
|
|
532
|
+
var _useCollectMenuItems3 = useCollectMenuItems(),
|
|
533
|
+
pushMenuItem = _useCollectMenuItems3.pushMenuItem;
|
|
534
|
+
var key = useMemo(function () {
|
|
535
|
+
return uid();
|
|
536
|
+
}, []);
|
|
537
|
+
var item = {
|
|
538
|
+
key: key,
|
|
539
|
+
label: props.title,
|
|
540
|
+
title: props.title,
|
|
541
|
+
children: getMenuItems(function () {
|
|
542
|
+
return props.children;
|
|
543
|
+
})
|
|
544
|
+
};
|
|
545
|
+
pushMenuItem(item);
|
|
546
|
+
return /*#__PURE__*/React.createElement(Component, null);
|
|
476
547
|
};
|
|
477
|
-
SchemaSettings.Divider = function (
|
|
478
|
-
|
|
548
|
+
SchemaSettings.Divider = function Divider() {
|
|
549
|
+
var _useCollectMenuItems4 = useCollectMenuItems(),
|
|
550
|
+
pushMenuItem = _useCollectMenuItems4.pushMenuItem;
|
|
551
|
+
var key = useMemo(function () {
|
|
552
|
+
return uid();
|
|
553
|
+
}, []);
|
|
554
|
+
var item = {
|
|
555
|
+
key: key,
|
|
556
|
+
type: 'divider'
|
|
557
|
+
};
|
|
558
|
+
pushMenuItem(item);
|
|
559
|
+
return null;
|
|
479
560
|
};
|
|
480
561
|
SchemaSettings.Remove = function Remove(props) {
|
|
481
562
|
var confirm = props.confirm,
|
|
@@ -529,6 +610,7 @@ SchemaSettings.ConnectDataBlocks = function ConnectDataBlocks(props) {
|
|
|
529
610
|
var _useFilterBlock = useFilterBlock(),
|
|
530
611
|
inProvider = _useFilterBlock.inProvider;
|
|
531
612
|
var dataBlocks = useSupportedBlocks(type);
|
|
613
|
+
// eslint-disable-next-line prefer-const
|
|
532
614
|
var _findFilterTargets = findFilterTargets(fieldSchema),
|
|
533
615
|
_findFilterTargets$ta = _findFilterTargets.targets,
|
|
534
616
|
targets = _findFilterTargets$ta === void 0 ? [] : _findFilterTargets$ta,
|
|
@@ -638,14 +720,14 @@ SchemaSettings.ConnectDataBlocks = function ConnectDataBlocks(props) {
|
|
|
638
720
|
});
|
|
639
721
|
return /*#__PURE__*/React.createElement(SchemaSettings.SubMenu, {
|
|
640
722
|
title: t('Connect data blocks')
|
|
641
|
-
}, Content.length ? Content : /*#__PURE__*/React.createElement(Empty, {
|
|
723
|
+
}, Content.length ? Content : /*#__PURE__*/React.createElement(SchemaSettings.Item, null, /*#__PURE__*/React.createElement(Empty, {
|
|
642
724
|
style: {
|
|
643
725
|
width: 160,
|
|
644
726
|
padding: '0 1em'
|
|
645
727
|
},
|
|
646
728
|
description: emptyDescription,
|
|
647
729
|
image: Empty.PRESENTED_IMAGE_SIMPLE
|
|
648
|
-
}));
|
|
730
|
+
})));
|
|
649
731
|
};
|
|
650
732
|
SchemaSettings.SelectItem = function SelectItem(props) {
|
|
651
733
|
var title = props.title,
|
|
@@ -873,7 +955,7 @@ SchemaSettings.ActionModalItem = /*#__PURE__*/React.memo(function (props) {
|
|
|
873
955
|
title: compile(title)
|
|
874
956
|
}, others), {}, {
|
|
875
957
|
destroyOnClose: true,
|
|
876
|
-
|
|
958
|
+
open: visible,
|
|
877
959
|
onCancel: cancelHandler,
|
|
878
960
|
footer: /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
|
|
879
961
|
onClick: cancelHandler
|
|
@@ -1252,7 +1334,6 @@ SchemaSettings.EnableChildCollections = function EnableChildCollectionsItem(prop
|
|
|
1252
1334
|
ArrayItems: ArrayItems,
|
|
1253
1335
|
FormLayout: FormLayout
|
|
1254
1336
|
},
|
|
1255
|
-
width: 600,
|
|
1256
1337
|
schema: {
|
|
1257
1338
|
type: 'object',
|
|
1258
1339
|
title: t('Enable child collections'),
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Schema } from '@formily/react';
|
|
2
|
+
export declare const useFormVariable: ({ blockForm, rootCollection, operator, schema, level, }: {
|
|
3
|
+
blockForm?: any;
|
|
4
|
+
rootCollection: string;
|
|
5
|
+
operator?: any;
|
|
6
|
+
schema: Schema;
|
|
7
|
+
level?: number;
|
|
8
|
+
}) => {
|
|
9
|
+
label: string;
|
|
10
|
+
value: string;
|
|
11
|
+
key: string;
|
|
12
|
+
children: any[];
|
|
13
|
+
isLeaf: boolean;
|
|
14
|
+
field: {
|
|
15
|
+
target: string;
|
|
16
|
+
};
|
|
17
|
+
depth: number;
|
|
18
|
+
loadChildren: (option: any) => Promise<void>;
|
|
19
|
+
};
|