@nocobase/client 0.10.0-alpha.2 → 0.10.0-alpha.3
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/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 +90 -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 +4 -4
- 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/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/grid-card/GridCard.Designer.js +3 -4
- package/es/schema-component/antd/index.less +1 -3
- 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 +58 -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 +9 -7
- 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 +155 -102
- 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 +123 -46
- 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/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 +104 -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 +3 -3
- 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/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/grid-card/GridCard.Designer.js +4 -5
- package/lib/schema-component/antd/index.less +1 -3
- 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 +55 -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 +9 -7
- 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 +154 -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 +122 -45
- 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
|
@@ -9,7 +9,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
9
9
|
import { SchemaInitializer } from '../SchemaInitializer';
|
|
10
10
|
import { itemsMerge, useAssociatedTableColumnInitializerFields, useTableColumnInitializerFields, useInheritsTableColumnInitializerFields } from '../utils';
|
|
11
11
|
import { useCompile } from '../../schema-component';
|
|
12
|
-
import { useFieldSchema } from '@formily/react';
|
|
12
|
+
import { useField, useFieldSchema } from '@formily/react';
|
|
13
13
|
// 表格列配置
|
|
14
14
|
export var TableColumnInitializers = function TableColumnInitializers(props) {
|
|
15
15
|
var _props$items = props.items,
|
|
@@ -18,6 +18,7 @@ export var TableColumnInitializers = function TableColumnInitializers(props) {
|
|
|
18
18
|
action = _props$action === void 0 ? true : _props$action;
|
|
19
19
|
var _useTranslation = useTranslation(),
|
|
20
20
|
t = _useTranslation.t;
|
|
21
|
+
var field = useField();
|
|
21
22
|
var fieldSchema = useFieldSchema();
|
|
22
23
|
var associatedFields = useAssociatedTableColumnInitializerFields();
|
|
23
24
|
var inheritFields = useInheritsTableColumnInitializerFields();
|
|
@@ -42,7 +43,7 @@ export var TableColumnInitializers = function TableColumnInitializers(props) {
|
|
|
42
43
|
});
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
|
-
if ((associatedFields === null || associatedFields === void 0 ? void 0 : associatedFields.length) > 0 &&
|
|
46
|
+
if ((associatedFields === null || associatedFields === void 0 ? void 0 : associatedFields.length) > 0 && field.readPretty) {
|
|
46
47
|
fieldItems.push({
|
|
47
48
|
type: 'divider'
|
|
48
49
|
}, {
|
|
@@ -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) {
|
|
@@ -16,13 +16,13 @@ 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); }
|
|
23
22
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
24
23
|
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; } }
|
|
25
24
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
26
26
|
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; }
|
|
27
27
|
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; }
|
|
28
28
|
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; }
|
|
@@ -36,7 +36,7 @@ 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
42
|
import React, { createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
@@ -45,6 +45,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
45
45
|
import { APIClientProvider, ActionContextProvider, CollectionManagerContext, FormProvider, RemoteSchemaComponent, SchemaComponent, SchemaComponentContext, SchemaComponentOptions, createDesignable, findFormBlock, useAPIClient, useCollection, useCollectionManager, useCompile, useDesignable, useFilterBlock, useLinkageCollectionFilterOptions } from '..';
|
|
46
46
|
import { findFilterTargets, updateFilterTargets } from '../block-provider/hooks';
|
|
47
47
|
import { isSameCollection, useSupportedBlocks } from '../filter-provider/utils';
|
|
48
|
+
import { useCollectMenuItem, useCollectMenuItems, useMenuItem } from '../hooks/useMenuItem';
|
|
48
49
|
import { getTargetKey } from '../schema-component/antd/association-filter/utilts';
|
|
49
50
|
import { useSchemaTemplateManager } from '../schema-templates';
|
|
50
51
|
import { useBlockTemplateContext } from '../schema-templates/BlockTemplate';
|
|
@@ -73,6 +74,7 @@ export var SchemaSettingsProvider = function SchemaSettingsProvider(props) {
|
|
|
73
74
|
}, others)
|
|
74
75
|
}, children);
|
|
75
76
|
};
|
|
77
|
+
var overlayClassName = classNames('nb-schema-initializer-button-overlay', css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ant-dropdown-menu-item-group-list {\n max-height: 40vh;\n overflow: auto;\n }\n "]))));
|
|
76
78
|
export var SchemaSettings = function SchemaSettings(props) {
|
|
77
79
|
var title = props.title,
|
|
78
80
|
dn = props.dn,
|
|
@@ -81,22 +83,44 @@ export var SchemaSettings = function SchemaSettings(props) {
|
|
|
81
83
|
_useState2 = _slicedToArray(_useState, 2),
|
|
82
84
|
visible = _useState2[0],
|
|
83
85
|
setVisible = _useState2[1];
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
var _useMenuItem = useMenuItem(),
|
|
87
|
+
Component = _useMenuItem.Component,
|
|
88
|
+
getMenuItems = _useMenuItem.getMenuItems;
|
|
89
|
+
var _useState3 = useState(false),
|
|
90
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
91
|
+
shouldRender = _useState4[0],
|
|
92
|
+
setShouldRender = _useState4[1];
|
|
93
|
+
if (!shouldRender) {
|
|
94
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
95
|
+
onMouseEnter: function onMouseEnter() {
|
|
96
|
+
setShouldRender(true);
|
|
97
|
+
setVisible(true);
|
|
98
|
+
}
|
|
99
|
+
}, typeof title === 'string' ? /*#__PURE__*/React.createElement("span", null, title) : title);
|
|
100
|
+
}
|
|
101
|
+
var dropdownMenu = function dropdownMenu() {
|
|
102
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Component, null), /*#__PURE__*/React.createElement(Dropdown, {
|
|
103
|
+
open: visible,
|
|
104
|
+
onOpenChange: function onOpenChange() {
|
|
105
|
+
setShouldRender(false);
|
|
106
|
+
setVisible(false);
|
|
107
|
+
},
|
|
108
|
+
menu: {
|
|
109
|
+
items: getMenuItems(function () {
|
|
110
|
+
return props.children;
|
|
111
|
+
})
|
|
112
|
+
},
|
|
113
|
+
overlayClassName: overlayClassName
|
|
114
|
+
}, typeof title === 'string' ? /*#__PURE__*/React.createElement("span", null, title) : title));
|
|
115
|
+
};
|
|
92
116
|
if (dn) {
|
|
93
117
|
return /*#__PURE__*/React.createElement(SchemaSettingsProvider, _objectSpread({
|
|
94
118
|
visible: visible,
|
|
95
119
|
setVisible: setVisible,
|
|
96
120
|
dn: dn
|
|
97
|
-
}, others),
|
|
121
|
+
}, others), dropdownMenu());
|
|
98
122
|
}
|
|
99
|
-
return
|
|
123
|
+
return dropdownMenu();
|
|
100
124
|
};
|
|
101
125
|
SchemaSettings.Template = function Template(props) {
|
|
102
126
|
var componentName = props.componentName,
|
|
@@ -449,14 +473,17 @@ SchemaSettings.FormItemTemplate = function FormItemTemplate(props) {
|
|
|
449
473
|
}, t('Save as block template'));
|
|
450
474
|
};
|
|
451
475
|
SchemaSettings.Item = function Item(props) {
|
|
476
|
+
var _useCollectMenuItems = useCollectMenuItems(),
|
|
477
|
+
pushMenuItem = _useCollectMenuItems.pushMenuItem;
|
|
478
|
+
var _useCollectMenuItem = useCollectMenuItem(),
|
|
479
|
+
collectMenuItem = _useCollectMenuItem.collectMenuItem;
|
|
452
480
|
var eventKey = props.eventKey;
|
|
453
481
|
var key = useMemo(function () {
|
|
454
482
|
return uid();
|
|
455
483
|
}, []);
|
|
456
|
-
|
|
484
|
+
var item = _objectSpread(_objectSpread({}, _.omit(props, ['children'])), {}, {
|
|
457
485
|
key: key,
|
|
458
|
-
eventKey: eventKey || key
|
|
459
|
-
}, props), {}, {
|
|
486
|
+
eventKey: eventKey || key,
|
|
460
487
|
onClick: function onClick(info) {
|
|
461
488
|
var _props$onClick;
|
|
462
489
|
info.domEvent.preventDefault();
|
|
@@ -465,17 +492,67 @@ SchemaSettings.Item = function Item(props) {
|
|
|
465
492
|
},
|
|
466
493
|
style: {
|
|
467
494
|
minWidth: 120
|
|
468
|
-
}
|
|
469
|
-
|
|
495
|
+
},
|
|
496
|
+
label: props.children || props.title,
|
|
497
|
+
title: props.title
|
|
498
|
+
});
|
|
499
|
+
pushMenuItem === null || pushMenuItem === void 0 ? void 0 : pushMenuItem(item);
|
|
500
|
+
collectMenuItem === null || collectMenuItem === void 0 ? void 0 : collectMenuItem(item);
|
|
501
|
+
return null;
|
|
470
502
|
};
|
|
471
|
-
SchemaSettings.ItemGroup = function (props) {
|
|
472
|
-
|
|
503
|
+
SchemaSettings.ItemGroup = function ItemGroup(props) {
|
|
504
|
+
var _useMenuItem2 = useMenuItem(),
|
|
505
|
+
Component = _useMenuItem2.Component,
|
|
506
|
+
getMenuItems = _useMenuItem2.getMenuItems;
|
|
507
|
+
var _useCollectMenuItems2 = useCollectMenuItems(),
|
|
508
|
+
pushMenuItem = _useCollectMenuItems2.pushMenuItem;
|
|
509
|
+
var key = useMemo(function () {
|
|
510
|
+
return uid();
|
|
511
|
+
}, []);
|
|
512
|
+
var item = {
|
|
513
|
+
key: key,
|
|
514
|
+
type: 'group',
|
|
515
|
+
title: props.title,
|
|
516
|
+
label: props.title,
|
|
517
|
+
children: getMenuItems(function () {
|
|
518
|
+
return props.children;
|
|
519
|
+
})
|
|
520
|
+
};
|
|
521
|
+
pushMenuItem(item);
|
|
522
|
+
return /*#__PURE__*/React.createElement(Component, null);
|
|
473
523
|
};
|
|
474
|
-
SchemaSettings.SubMenu = function (props) {
|
|
475
|
-
|
|
524
|
+
SchemaSettings.SubMenu = function SubMenu(props) {
|
|
525
|
+
var _useMenuItem3 = useMenuItem(),
|
|
526
|
+
Component = _useMenuItem3.Component,
|
|
527
|
+
getMenuItems = _useMenuItem3.getMenuItems;
|
|
528
|
+
var _useCollectMenuItems3 = useCollectMenuItems(),
|
|
529
|
+
pushMenuItem = _useCollectMenuItems3.pushMenuItem;
|
|
530
|
+
var key = useMemo(function () {
|
|
531
|
+
return uid();
|
|
532
|
+
}, []);
|
|
533
|
+
var item = {
|
|
534
|
+
key: key,
|
|
535
|
+
label: props.title,
|
|
536
|
+
title: props.title,
|
|
537
|
+
children: getMenuItems(function () {
|
|
538
|
+
return props.children;
|
|
539
|
+
})
|
|
540
|
+
};
|
|
541
|
+
pushMenuItem(item);
|
|
542
|
+
return /*#__PURE__*/React.createElement(Component, null);
|
|
476
543
|
};
|
|
477
|
-
SchemaSettings.Divider = function (
|
|
478
|
-
|
|
544
|
+
SchemaSettings.Divider = function Divider() {
|
|
545
|
+
var _useCollectMenuItems4 = useCollectMenuItems(),
|
|
546
|
+
pushMenuItem = _useCollectMenuItems4.pushMenuItem;
|
|
547
|
+
var key = useMemo(function () {
|
|
548
|
+
return uid();
|
|
549
|
+
}, []);
|
|
550
|
+
var item = {
|
|
551
|
+
key: key,
|
|
552
|
+
type: 'divider'
|
|
553
|
+
};
|
|
554
|
+
pushMenuItem(item);
|
|
555
|
+
return null;
|
|
479
556
|
};
|
|
480
557
|
SchemaSettings.Remove = function Remove(props) {
|
|
481
558
|
var confirm = props.confirm,
|
|
@@ -529,6 +606,7 @@ SchemaSettings.ConnectDataBlocks = function ConnectDataBlocks(props) {
|
|
|
529
606
|
var _useFilterBlock = useFilterBlock(),
|
|
530
607
|
inProvider = _useFilterBlock.inProvider;
|
|
531
608
|
var dataBlocks = useSupportedBlocks(type);
|
|
609
|
+
// eslint-disable-next-line prefer-const
|
|
532
610
|
var _findFilterTargets = findFilterTargets(fieldSchema),
|
|
533
611
|
_findFilterTargets$ta = _findFilterTargets.targets,
|
|
534
612
|
targets = _findFilterTargets$ta === void 0 ? [] : _findFilterTargets$ta,
|
|
@@ -638,14 +716,14 @@ SchemaSettings.ConnectDataBlocks = function ConnectDataBlocks(props) {
|
|
|
638
716
|
});
|
|
639
717
|
return /*#__PURE__*/React.createElement(SchemaSettings.SubMenu, {
|
|
640
718
|
title: t('Connect data blocks')
|
|
641
|
-
}, Content.length ? Content : /*#__PURE__*/React.createElement(Empty, {
|
|
719
|
+
}, Content.length ? Content : /*#__PURE__*/React.createElement(SchemaSettings.Item, null, /*#__PURE__*/React.createElement(Empty, {
|
|
642
720
|
style: {
|
|
643
721
|
width: 160,
|
|
644
722
|
padding: '0 1em'
|
|
645
723
|
},
|
|
646
724
|
description: emptyDescription,
|
|
647
725
|
image: Empty.PRESENTED_IMAGE_SIMPLE
|
|
648
|
-
}));
|
|
726
|
+
})));
|
|
649
727
|
};
|
|
650
728
|
SchemaSettings.SelectItem = function SelectItem(props) {
|
|
651
729
|
var title = props.title,
|
|
@@ -655,10 +733,10 @@ SchemaSettings.SelectItem = function SelectItem(props) {
|
|
|
655
733
|
openOnHover = props.openOnHover,
|
|
656
734
|
_onClick = props.onClick,
|
|
657
735
|
others = _objectWithoutProperties(props, _excluded3);
|
|
658
|
-
var
|
|
659
|
-
|
|
660
|
-
open =
|
|
661
|
-
setOpen =
|
|
736
|
+
var _useState5 = useState(false),
|
|
737
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
738
|
+
open = _useState6[0],
|
|
739
|
+
setOpen = _useState6[1];
|
|
662
740
|
var onClick = function onClick() {
|
|
663
741
|
setOpen(false);
|
|
664
742
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -722,10 +800,10 @@ SchemaSettings.SwitchItem = function SwitchItem(props) {
|
|
|
722
800
|
var title = props.title,
|
|
723
801
|
onChange = props.onChange,
|
|
724
802
|
others = _objectWithoutProperties(props, _excluded5);
|
|
725
|
-
var
|
|
726
|
-
|
|
727
|
-
checked =
|
|
728
|
-
setChecked =
|
|
803
|
+
var _useState7 = useState(!!props.checked),
|
|
804
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
805
|
+
checked = _useState8[0],
|
|
806
|
+
setChecked = _useState8[1];
|
|
729
807
|
return /*#__PURE__*/React.createElement(SchemaSettings.Item, _objectSpread(_objectSpread({}, others), {}, {
|
|
730
808
|
onClick: function onClick() {
|
|
731
809
|
onChange === null || onChange === void 0 ? void 0 : onChange(!checked);
|
|
@@ -748,10 +826,10 @@ SchemaSettings.SwitchItem = function SwitchItem(props) {
|
|
|
748
826
|
SchemaSettings.PopupItem = function PopupItem(props) {
|
|
749
827
|
var schema = props.schema,
|
|
750
828
|
others = _objectWithoutProperties(props, _excluded6);
|
|
751
|
-
var
|
|
752
|
-
|
|
753
|
-
visible =
|
|
754
|
-
setVisible =
|
|
829
|
+
var _useState9 = useState(false),
|
|
830
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
831
|
+
visible = _useState10[0],
|
|
832
|
+
setVisible = _useState10[1];
|
|
755
833
|
var ctx = useContext(SchemaSettingsContext);
|
|
756
834
|
return /*#__PURE__*/React.createElement(ActionContextProvider, {
|
|
757
835
|
value: {
|
|
@@ -779,14 +857,14 @@ SchemaSettings.ActionModalItem = /*#__PURE__*/React.memo(function (props) {
|
|
|
779
857
|
modalTip = props.modalTip,
|
|
780
858
|
components = props.components,
|
|
781
859
|
others = _objectWithoutProperties(props, _excluded7);
|
|
782
|
-
var
|
|
783
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
784
|
-
visible = _useState10[0],
|
|
785
|
-
setVisible = _useState10[1];
|
|
786
|
-
var _useState11 = useState(props.uid),
|
|
860
|
+
var _useState11 = useState(false),
|
|
787
861
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
788
|
-
|
|
789
|
-
|
|
862
|
+
visible = _useState12[0],
|
|
863
|
+
setVisible = _useState12[1];
|
|
864
|
+
var _useState13 = useState(props.uid),
|
|
865
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
866
|
+
schemaUid = _useState14[0],
|
|
867
|
+
setSchemaUid = _useState14[1];
|
|
790
868
|
var _useTranslation5 = useTranslation(),
|
|
791
869
|
t = _useTranslation5.t;
|
|
792
870
|
var fieldSchema = useFieldSchema();
|
|
@@ -873,7 +951,7 @@ SchemaSettings.ActionModalItem = /*#__PURE__*/React.memo(function (props) {
|
|
|
873
951
|
title: compile(title)
|
|
874
952
|
}, others), {}, {
|
|
875
953
|
destroyOnClose: true,
|
|
876
|
-
|
|
954
|
+
open: visible,
|
|
877
955
|
onCancel: cancelHandler,
|
|
878
956
|
footer: /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
|
|
879
957
|
onClick: cancelHandler
|
|
@@ -1252,7 +1330,6 @@ SchemaSettings.EnableChildCollections = function EnableChildCollectionsItem(prop
|
|
|
1252
1330
|
ArrayItems: ArrayItems,
|
|
1253
1331
|
FormLayout: FormLayout
|
|
1254
1332
|
},
|
|
1255
|
-
width: 600,
|
|
1256
1333
|
schema: {
|
|
1257
1334
|
type: 'object',
|
|
1258
1335
|
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
|
+
};
|