@nocobase/client 0.7.2-alpha.6 → 0.7.4-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/application/Application.d.ts +1 -0
- package/es/application/Application.js +7 -1
- package/es/block-provider/FormBlockProvider.js +8 -3
- package/es/block-provider/TableFieldProvider.d.ts +1 -0
- package/es/block-provider/TableFieldProvider.js +5 -2
- package/es/block-provider/TableSelectorProvider.js +41 -13
- package/es/block-provider/hooks/index.d.ts +6 -0
- package/es/block-provider/hooks/index.js +159 -65
- package/es/collection-manager/CollectionField.js +4 -2
- package/es/collection-manager/Configuration/index.js +5 -1
- package/es/collection-manager/Configuration/schemas/collections.js +2 -1
- package/es/collection-manager/interfaces/input.js +103 -0
- package/es/collection-manager/interfaces/integer.js +63 -0
- package/es/collection-manager/interfaces/m2m.js +2 -0
- package/es/collection-manager/interfaces/m2o.js +1 -0
- package/es/collection-manager/interfaces/markdown.js +34 -0
- package/es/collection-manager/interfaces/number.js +55 -0
- package/es/collection-manager/interfaces/o2m.js +1 -0
- package/es/collection-manager/interfaces/o2o.js +3 -0
- package/es/collection-manager/interfaces/password.js +36 -1
- package/es/collection-manager/interfaces/percent.js +97 -0
- package/es/collection-manager/interfaces/properties/index.d.ts +1 -0
- package/es/collection-manager/interfaces/properties/index.js +1 -0
- package/es/collection-manager/interfaces/properties/operators.js +4 -4
- package/es/collection-manager/interfaces/richText.js +34 -0
- package/es/collection-manager/interfaces/textarea.js +34 -0
- package/es/file-manager/FileStorageShortcut.js +2 -2
- package/es/locale/en_US.d.ts +8 -2
- package/es/locale/en_US.js +9 -3
- package/es/locale/zh_CN.d.ts +26 -2
- package/es/locale/zh_CN.js +27 -3
- package/es/plugin-manager/PluginManager.d.ts +1 -0
- package/es/plugin-manager/PluginManager.js +20 -6
- package/es/schema-component/antd/action/Action.Modal.js +1 -1
- package/es/schema-component/antd/calendar/Calendar.Designer.js +16 -10
- package/es/schema-component/antd/date-picker/DatePicker.d.ts +1 -1
- package/es/schema-component/antd/date-picker/DatePicker.js +1 -1
- package/es/schema-component/antd/date-picker/ReadPretty.js +1 -1
- package/es/schema-component/antd/date-picker/util.d.ts +0 -10
- package/es/schema-component/antd/date-picker/util.js +1 -79
- package/es/schema-component/antd/form-item/FormItem.js +161 -10
- package/es/schema-component/antd/grid/Grid.js +72 -6
- package/es/schema-component/antd/input-number/InputNumber.d.ts +1 -5
- package/es/schema-component/antd/input-number/InputNumber.js +25 -1
- package/es/schema-component/antd/input-number/ReadPretty.js +2 -4
- package/es/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
- package/es/schema-component/antd/menu/Menu.js +6 -3
- package/es/schema-component/antd/percent/Percent.js +2 -2
- package/es/schema-component/antd/record-picker/InputRecordPicker.js +27 -13
- package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +5 -3
- package/es/schema-component/antd/table/Table.Array.js +2 -2
- package/es/schema-component/antd/table/Table.Void.js +11 -1
- package/es/schema-component/antd/table-v2/Table.Column.Designer.js +3 -1
- package/es/schema-component/antd/table-v2/Table.d.ts +0 -11
- package/es/schema-component/antd/table-v2/Table.js +163 -92
- package/es/schema-component/antd/table-v2/TableField.js +3 -0
- package/es/schema-component/antd/tabs/Tabs.Designer.js +23 -12
- package/es/schema-component/antd/tabs/Tabs.js +7 -1
- package/es/schema-component/antd/time-picker/ReadPretty.js +11 -5
- package/es/schema-component/core/DesignableSwitch.js +7 -1
- package/es/schema-component/hooks/useDesignable.js +21 -21
- package/es/schema-component/hooks/useProps.js +1 -1
- package/es/schema-initializer/buttons/FormItemInitializers.js +14 -3
- package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
- package/es/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -3
- package/es/schema-initializer/buttons/RecordBlockInitializers.js +32 -3
- package/es/schema-initializer/buttons/TabPaneInitializers.js +11 -3
- package/es/schema-initializer/buttons/TableActionInitializers.js +11 -0
- package/es/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
- package/es/schema-initializer/components/assigned-field/AssignedField.js +255 -69
- package/es/schema-initializer/items/index.d.ts +2 -0
- package/es/schema-initializer/items/index.js +48 -2
- package/es/schema-initializer/utils.js +22 -2
- package/es/system-settings/SystemSettingsShortcut.js +35 -12
- package/lib/application/Application.d.ts +1 -0
- package/lib/application/Application.js +11 -2
- package/lib/block-provider/FormBlockProvider.js +7 -2
- package/lib/block-provider/TableFieldProvider.d.ts +1 -0
- package/lib/block-provider/TableFieldProvider.js +4 -1
- package/lib/block-provider/TableSelectorProvider.js +41 -13
- package/lib/block-provider/hooks/index.d.ts +6 -0
- package/lib/block-provider/hooks/index.js +168 -67
- package/lib/collection-manager/CollectionField.js +5 -2
- package/lib/collection-manager/Configuration/index.js +5 -0
- package/lib/collection-manager/Configuration/schemas/collections.js +2 -1
- package/lib/collection-manager/interfaces/input.js +104 -0
- package/lib/collection-manager/interfaces/integer.js +65 -0
- package/lib/collection-manager/interfaces/m2m.js +2 -0
- package/lib/collection-manager/interfaces/m2o.js +1 -0
- package/lib/collection-manager/interfaces/markdown.js +35 -0
- package/lib/collection-manager/interfaces/number.js +56 -0
- package/lib/collection-manager/interfaces/o2m.js +1 -0
- package/lib/collection-manager/interfaces/o2o.js +3 -0
- package/lib/collection-manager/interfaces/password.js +37 -1
- package/lib/collection-manager/interfaces/percent.js +99 -0
- package/lib/collection-manager/interfaces/properties/index.d.ts +1 -0
- package/lib/collection-manager/interfaces/properties/index.js +1 -0
- package/lib/collection-manager/interfaces/properties/operators.js +4 -4
- package/lib/collection-manager/interfaces/richText.js +35 -0
- package/lib/collection-manager/interfaces/textarea.js +35 -0
- package/lib/file-manager/FileStorageShortcut.js +1 -1
- package/lib/locale/en_US.d.ts +8 -2
- package/lib/locale/en_US.js +9 -3
- package/lib/locale/zh_CN.d.ts +26 -2
- package/lib/locale/zh_CN.js +27 -3
- package/lib/plugin-manager/PluginManager.d.ts +1 -0
- package/lib/plugin-manager/PluginManager.js +23 -5
- package/lib/schema-component/antd/action/Action.Modal.js +1 -1
- package/lib/schema-component/antd/calendar/Calendar.Designer.js +16 -10
- package/lib/schema-component/antd/date-picker/DatePicker.d.ts +1 -1
- package/lib/schema-component/antd/date-picker/DatePicker.js +2 -2
- package/lib/schema-component/antd/date-picker/ReadPretty.js +6 -6
- package/lib/schema-component/antd/date-picker/util.d.ts +0 -10
- package/lib/schema-component/antd/date-picker/util.js +6 -89
- package/lib/schema-component/antd/form-item/FormItem.js +164 -12
- package/lib/schema-component/antd/grid/Grid.js +69 -3
- package/lib/schema-component/antd/input-number/InputNumber.d.ts +1 -5
- package/lib/schema-component/antd/input-number/InputNumber.js +28 -1
- package/lib/schema-component/antd/input-number/ReadPretty.js +2 -5
- package/lib/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
- package/lib/schema-component/antd/menu/Menu.js +6 -3
- package/lib/schema-component/antd/percent/Percent.js +2 -2
- package/lib/schema-component/antd/record-picker/InputRecordPicker.js +27 -12
- package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +4 -2
- package/lib/schema-component/antd/table/Table.Array.js +2 -2
- package/lib/schema-component/antd/table/Table.Void.js +11 -1
- package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +3 -1
- package/lib/schema-component/antd/table-v2/Table.d.ts +0 -11
- package/lib/schema-component/antd/table-v2/Table.js +172 -94
- package/lib/schema-component/antd/table-v2/TableField.js +3 -0
- package/lib/schema-component/antd/tabs/Tabs.Designer.js +23 -12
- package/lib/schema-component/antd/tabs/Tabs.js +8 -1
- package/lib/schema-component/antd/time-picker/ReadPretty.js +10 -3
- package/lib/schema-component/core/DesignableSwitch.js +8 -1
- package/lib/schema-component/hooks/useDesignable.js +21 -21
- package/lib/schema-component/hooks/useProps.js +1 -1
- package/lib/schema-initializer/buttons/FormItemInitializers.js +14 -2
- package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
- package/lib/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -2
- package/lib/schema-initializer/buttons/RecordBlockInitializers.js +34 -4
- package/lib/schema-initializer/buttons/TabPaneInitializers.js +11 -3
- package/lib/schema-initializer/buttons/TableActionInitializers.js +11 -0
- package/lib/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
- package/lib/schema-initializer/components/assigned-field/AssignedField.js +257 -66
- package/lib/schema-initializer/items/index.d.ts +2 -0
- package/lib/schema-initializer/items/index.js +54 -2
- package/lib/schema-initializer/utils.js +22 -2
- package/lib/system-settings/SystemSettingsShortcut.js +37 -13
- package/package.json +7 -4
|
@@ -12,7 +12,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
12
12
|
|
|
13
13
|
import { observer, RecursionField, useField, useFieldSchema } from '@formily/react';
|
|
14
14
|
import { toArr } from '@formily/shared';
|
|
15
|
-
import React, { useRef, useState } from 'react';
|
|
15
|
+
import React, { Fragment, useRef, useState } from 'react';
|
|
16
16
|
import { BlockAssociationContext, WithoutTableFieldResource } from '../../../block-provider';
|
|
17
17
|
import { CollectionProvider, useCollection, useCollectionManager } from '../../../collection-manager';
|
|
18
18
|
import { RecordProvider, useRecord } from '../../../record-provider';
|
|
@@ -57,7 +57,9 @@ export var ReadPrettyRecordPicker = observer(function (props) {
|
|
|
57
57
|
|
|
58
58
|
var renderRecords = function renderRecords() {
|
|
59
59
|
return toArr(field.value).map(function (record, index, arr) {
|
|
60
|
-
return /*#__PURE__*/React.createElement(
|
|
60
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
61
|
+
key: "".concat(record.id, "_").concat(index)
|
|
62
|
+
}, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("a", {
|
|
61
63
|
onClick: function onClick(e) {
|
|
62
64
|
var _ellipsisWithTooltipR;
|
|
63
65
|
|
|
@@ -67,7 +69,7 @@ export var ReadPrettyRecordPicker = observer(function (props) {
|
|
|
67
69
|
setRecord(record);
|
|
68
70
|
ellipsisWithTooltipRef === null || ellipsisWithTooltipRef === void 0 ? void 0 : (_ellipsisWithTooltipR = ellipsisWithTooltipRef.current) === null || _ellipsisWithTooltipR === void 0 ? void 0 : _ellipsisWithTooltipR.setPopoverVisible(false);
|
|
69
71
|
}
|
|
70
|
-
}, compile(record === null || record === void 0 ? void 0 : record[(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || 'label']))), index < arr.length - 1 ? /*#__PURE__*/React.createElement("span", {
|
|
72
|
+
}, compile(record === null || record === void 0 ? void 0 : record[(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || 'label']) || (record === null || record === void 0 ? void 0 : record[(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value) || 'value']) || (record === null || record === void 0 ? void 0 : record.id))), index < arr.length - 1 ? /*#__PURE__*/React.createElement("span", {
|
|
71
73
|
style: {
|
|
72
74
|
marginRight: 4,
|
|
73
75
|
color: '#aaa'
|
|
@@ -71,8 +71,8 @@ var useTableColumns = function useTableColumns() {
|
|
|
71
71
|
render: function render(v, record) {
|
|
72
72
|
var _field$value;
|
|
73
73
|
|
|
74
|
-
var index = (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.indexOf(record);
|
|
75
|
-
|
|
74
|
+
var index = (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.indexOf(record); // console.log((Date.now() - start) / 1000);
|
|
75
|
+
|
|
76
76
|
return /*#__PURE__*/React.createElement(RecordIndexProvider, {
|
|
77
77
|
index: index
|
|
78
78
|
}, /*#__PURE__*/React.createElement(RecordProvider, {
|
|
@@ -13,7 +13,7 @@ import { useAttach } from '../../hooks';
|
|
|
13
13
|
import { TableArray } from './Table.Array';
|
|
14
14
|
|
|
15
15
|
var usePaginationProps = function usePaginationProps(props, service) {
|
|
16
|
-
var _props$request, _props$request$params;
|
|
16
|
+
var _props$request, _props$request$params, _service$data;
|
|
17
17
|
|
|
18
18
|
if (props.pagination === false) {
|
|
19
19
|
return false;
|
|
@@ -27,6 +27,16 @@ var usePaginationProps = function usePaginationProps(props, service) {
|
|
|
27
27
|
pagination.defaultPageSize = props === null || props === void 0 ? void 0 : (_props$request2 = props.request) === null || _props$request2 === void 0 ? void 0 : (_props$request2$param = _props$request2.params) === null || _props$request2$param === void 0 ? void 0 : _props$request2$param.pageSize;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
if (!pagination.total && (service === null || service === void 0 ? void 0 : (_service$data = service.data) === null || _service$data === void 0 ? void 0 : _service$data.meta)) {
|
|
31
|
+
var _service$data$meta = service.data.meta,
|
|
32
|
+
count = _service$data$meta.count,
|
|
33
|
+
page = _service$data$meta.page,
|
|
34
|
+
pageSize = _service$data$meta.pageSize;
|
|
35
|
+
pagination.total = count;
|
|
36
|
+
pagination.current = page;
|
|
37
|
+
pagination.pageSize = pageSize;
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
return _objectSpread(_objectSpread({
|
|
31
41
|
showSizeChanger: true
|
|
32
42
|
}, pagination), {}, {
|
|
@@ -114,7 +114,9 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
|
|
|
114
114
|
options: options,
|
|
115
115
|
value: fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames['label'],
|
|
116
116
|
onChange: function onChange(label) {
|
|
117
|
-
var
|
|
117
|
+
var _collectionField$uiSc2, _fieldSchema$xCompon2;
|
|
118
|
+
|
|
119
|
+
var fieldNames = _objectSpread(_objectSpread(_objectSpread({}, collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc2 = collectionField.uiSchema) === null || _collectionField$uiSc2 === void 0 ? void 0 : _collectionField$uiSc2['x-component-props']['fieldNames']), fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2['fieldNames']), {}, {
|
|
118
120
|
label: label
|
|
119
121
|
});
|
|
120
122
|
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
export declare const components: {
|
|
2
|
-
header: {
|
|
3
|
-
wrapper: (props: any) => JSX.Element;
|
|
4
|
-
cell: (props: any) => JSX.Element;
|
|
5
|
-
};
|
|
6
|
-
body: {
|
|
7
|
-
wrapper: (props: any) => JSX.Element;
|
|
8
|
-
row: (props: any) => JSX.Element;
|
|
9
|
-
cell: (props: any) => JSX.Element;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
1
|
export declare const Table: any;
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
var _excluded = ["pagination", "useProps", "onChange"],
|
|
2
2
|
_excluded2 = ["pagination"],
|
|
3
|
-
_excluded3 = ["dragSort", "showIndex", "
|
|
3
|
+
_excluded3 = ["dragSort", "showIndex", "onRowSelectionChange", "onChange", "rowSelection", "rowKey", "required"];
|
|
4
4
|
|
|
5
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
6
|
-
|
|
7
|
-
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); } }
|
|
8
|
-
|
|
9
|
-
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); }); }; }
|
|
5
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
10
6
|
|
|
11
7
|
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; }
|
|
12
8
|
|
|
13
9
|
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; }
|
|
14
10
|
|
|
15
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
16
|
-
|
|
17
11
|
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; }
|
|
18
12
|
|
|
19
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
14
|
|
|
21
15
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
16
|
|
|
17
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
18
|
+
|
|
23
19
|
import { MenuOutlined } from '@ant-design/icons';
|
|
20
|
+
import { SortableContext, useSortable } from '@dnd-kit/sortable';
|
|
24
21
|
import { css } from '@emotion/css';
|
|
25
22
|
import { observer, RecursionField, useField, useFieldSchema } from '@formily/react';
|
|
23
|
+
import { reaction } from '@formily/reactive';
|
|
24
|
+
import { useMemoizedFn } from 'ahooks';
|
|
26
25
|
import { Table as AntdTable } from 'antd';
|
|
27
26
|
import { default as classNames, default as cls } from 'classnames';
|
|
28
|
-
import React from 'react';
|
|
29
|
-
import ReactDragListView from 'react-drag-listview';
|
|
27
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
30
28
|
import { useTranslation } from 'react-i18next';
|
|
31
29
|
import { DndContext } from '../..';
|
|
32
30
|
import { RecordIndexProvider, RecordProvider, useSchemaInitializer } from '../../../';
|
|
@@ -48,8 +46,7 @@ var useTableColumns = function useTableColumns() {
|
|
|
48
46
|
|
|
49
47
|
var _useSchemaInitializer = useSchemaInitializer(schema['x-initializer']),
|
|
50
48
|
exists = _useSchemaInitializer.exists,
|
|
51
|
-
render = _useSchemaInitializer.render;
|
|
52
|
-
|
|
49
|
+
render = _useSchemaInitializer.render;
|
|
53
50
|
|
|
54
51
|
var columns = schema.reduceProperties(function (buf, s) {
|
|
55
52
|
if (isColumnComponent(s)) {
|
|
@@ -64,7 +61,6 @@ var useTableColumns = function useTableColumns() {
|
|
|
64
61
|
}
|
|
65
62
|
}, []);
|
|
66
63
|
var dataIndex = (collectionFields === null || collectionFields === void 0 ? void 0 : collectionFields.length) > 0 ? collectionFields[0].name : s.name;
|
|
67
|
-
console.log('useTableColumns', s.name, s, field.value);
|
|
68
64
|
return {
|
|
69
65
|
title: /*#__PURE__*/React.createElement(RecursionField, {
|
|
70
66
|
name: s.name,
|
|
@@ -80,7 +76,6 @@ var useTableColumns = function useTableColumns() {
|
|
|
80
76
|
|
|
81
77
|
var index = (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.indexOf(record); // console.log((Date.now() - start) / 1000);
|
|
82
78
|
|
|
83
|
-
console.log('useTableColumns.index', index, record);
|
|
84
79
|
return /*#__PURE__*/React.createElement(RecordIndexProvider, {
|
|
85
80
|
index: index
|
|
86
81
|
}, /*#__PURE__*/React.createElement(RecordProvider, {
|
|
@@ -105,39 +100,41 @@ var useTableColumns = function useTableColumns() {
|
|
|
105
100
|
});
|
|
106
101
|
};
|
|
107
102
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
}
|
|
103
|
+
var topActiveClass = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n & > td {\n border-top: 2px solid rgba(241, 139, 98, 0.6) !important;\n }\n"])));
|
|
104
|
+
var bottomActiveClass = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n & > td {\n border-bottom: 2px solid rgba(241, 139, 98, 0.6) !important;\n }\n"])));
|
|
105
|
+
|
|
106
|
+
var SortableRow = function SortableRow(props) {
|
|
107
|
+
var _props$dataRowKey, _active$data$current$, _active$data$current, _over$data$current$so, _over$data$current;
|
|
108
|
+
|
|
109
|
+
var id = (_props$dataRowKey = props['data-row-key']) === null || _props$dataRowKey === void 0 ? void 0 : _props$dataRowKey.toString();
|
|
110
|
+
|
|
111
|
+
var _useSortable = useSortable({
|
|
112
|
+
id: id
|
|
113
|
+
}),
|
|
114
|
+
setNodeRef = _useSortable.setNodeRef,
|
|
115
|
+
isOver = _useSortable.isOver,
|
|
116
|
+
active = _useSortable.active,
|
|
117
|
+
over = _useSortable.over;
|
|
118
|
+
|
|
119
|
+
var className = ((_active$data$current$ = active === null || active === void 0 ? void 0 : (_active$data$current = active.data.current) === null || _active$data$current === void 0 ? void 0 : _active$data$current.sortable.index) !== null && _active$data$current$ !== void 0 ? _active$data$current$ : -1) > ((_over$data$current$so = over === null || over === void 0 ? void 0 : (_over$data$current = over.data.current) === null || _over$data$current === void 0 ? void 0 : _over$data$current.sortable.index) !== null && _over$data$current$so !== void 0 ? _over$data$current$so : -1) ? topActiveClass : bottomActiveClass;
|
|
120
|
+
return /*#__PURE__*/React.createElement("tr", _objectSpread(_objectSpread({
|
|
121
|
+
ref: (active === null || active === void 0 ? void 0 : active.id) !== id ? setNodeRef : null
|
|
122
|
+
}, props), {}, {
|
|
123
|
+
className: classNames(_defineProperty({}, className, active && isOver))
|
|
124
|
+
}));
|
|
132
125
|
};
|
|
133
126
|
|
|
134
|
-
var SortHandle = function SortHandle() {
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
var SortHandle = function SortHandle(props) {
|
|
128
|
+
var _useSortable2 = useSortable({
|
|
129
|
+
id: props.id
|
|
130
|
+
}),
|
|
131
|
+
listeners = _useSortable2.listeners;
|
|
132
|
+
|
|
133
|
+
return /*#__PURE__*/React.createElement(MenuOutlined, _objectSpread(_objectSpread({}, listeners), {}, {
|
|
137
134
|
style: {
|
|
138
135
|
cursor: 'grab'
|
|
139
136
|
}
|
|
140
|
-
});
|
|
137
|
+
}));
|
|
141
138
|
};
|
|
142
139
|
|
|
143
140
|
var TableIndex = function TableIndex(props) {
|
|
@@ -172,6 +169,25 @@ var usePaginationProps = function usePaginationProps(pagination1, pagination2) {
|
|
|
172
169
|
}, pagination1), pagination2);
|
|
173
170
|
};
|
|
174
171
|
|
|
172
|
+
var useValidator = function useValidator(validator) {
|
|
173
|
+
var field = useField();
|
|
174
|
+
useEffect(function () {
|
|
175
|
+
var dispose = reaction(function () {
|
|
176
|
+
return field.value;
|
|
177
|
+
}, function (value) {
|
|
178
|
+
var message = validator(value);
|
|
179
|
+
field.setFeedback({
|
|
180
|
+
type: 'error',
|
|
181
|
+
code: 'ValidateError',
|
|
182
|
+
messages: message ? [message] : []
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
return function () {
|
|
186
|
+
dispose();
|
|
187
|
+
};
|
|
188
|
+
}, []);
|
|
189
|
+
};
|
|
190
|
+
|
|
175
191
|
export var Table = observer(function (props) {
|
|
176
192
|
var _field$data, _field$value3, _field$value3$slice;
|
|
177
193
|
|
|
@@ -192,13 +208,92 @@ export var Table = observer(function (props) {
|
|
|
192
208
|
dragSort = _others1$others$dragS === void 0 ? false : _others1$others$dragS,
|
|
193
209
|
_others1$others$showI = _others1$others.showIndex,
|
|
194
210
|
showIndex = _others1$others$showI === void 0 ? true : _others1$others$showI,
|
|
195
|
-
onRowDragEnd = _others1$others.onRowDragEnd,
|
|
196
211
|
onRowSelectionChange = _others1$others.onRowSelectionChange,
|
|
197
212
|
onTableChange = _others1$others.onChange,
|
|
198
213
|
rowSelection = _others1$others.rowSelection,
|
|
214
|
+
rowKey = _others1$others.rowKey,
|
|
215
|
+
required = _others1$others.required,
|
|
199
216
|
others = _objectWithoutProperties(_others1$others, _excluded3);
|
|
200
217
|
|
|
218
|
+
var onRowDragEnd = useMemoizedFn(others.onRowDragEnd || function () {});
|
|
201
219
|
var paginationProps = usePaginationProps(pagination1, pagination2);
|
|
220
|
+
var requiredValidator = field.required || required;
|
|
221
|
+
useEffect(function () {
|
|
222
|
+
field.setValidator(function (value) {
|
|
223
|
+
if (requiredValidator) {
|
|
224
|
+
return Array.isArray(value) && value.length > 0 ? null : 'The field value is required';
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return;
|
|
228
|
+
});
|
|
229
|
+
}, [requiredValidator]);
|
|
230
|
+
var components = useMemo(function () {
|
|
231
|
+
return {
|
|
232
|
+
header: {
|
|
233
|
+
wrapper: function wrapper(props) {
|
|
234
|
+
return /*#__PURE__*/React.createElement(DndContext, null, /*#__PURE__*/React.createElement("thead", _objectSpread({}, props)));
|
|
235
|
+
},
|
|
236
|
+
cell: function cell(props) {
|
|
237
|
+
return /*#__PURE__*/React.createElement("th", _objectSpread(_objectSpread({}, props), {}, {
|
|
238
|
+
className: cls(props.className, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n max-width: 300px;\n white-space: nowrap;\n &:hover .general-schema-designer {\n display: block;\n }\n "]))))
|
|
239
|
+
}));
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
body: {
|
|
243
|
+
wrapper: function wrapper(props) {
|
|
244
|
+
return /*#__PURE__*/React.createElement(DndContext, {
|
|
245
|
+
onDragEnd: function onDragEnd(e) {
|
|
246
|
+
var _e$active, _e$active$data$curren, _e$active$data$curren2, _e$over, _e$over$data$current, _e$over$data$current$;
|
|
247
|
+
|
|
248
|
+
if (!e.active || !e.over) {
|
|
249
|
+
console.warn('move cancel');
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
var fromIndex = (_e$active = e.active) === null || _e$active === void 0 ? void 0 : (_e$active$data$curren = _e$active.data.current) === null || _e$active$data$curren === void 0 ? void 0 : (_e$active$data$curren2 = _e$active$data$curren.sortable) === null || _e$active$data$curren2 === void 0 ? void 0 : _e$active$data$curren2.index;
|
|
254
|
+
var toIndex = (_e$over = e.over) === null || _e$over === void 0 ? void 0 : (_e$over$data$current = _e$over.data.current) === null || _e$over$data$current === void 0 ? void 0 : (_e$over$data$current$ = _e$over$data$current.sortable) === null || _e$over$data$current$ === void 0 ? void 0 : _e$over$data$current$.index;
|
|
255
|
+
var from = field.value[fromIndex];
|
|
256
|
+
var to = field.value[toIndex];
|
|
257
|
+
field.move(fromIndex, toIndex);
|
|
258
|
+
onRowDragEnd({
|
|
259
|
+
fromIndex: fromIndex,
|
|
260
|
+
toIndex: toIndex,
|
|
261
|
+
from: from,
|
|
262
|
+
to: to
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}, /*#__PURE__*/React.createElement("tbody", _objectSpread({}, props)));
|
|
266
|
+
},
|
|
267
|
+
row: function row(props) {
|
|
268
|
+
return /*#__PURE__*/React.createElement(SortableRow, _objectSpread({}, props));
|
|
269
|
+
},
|
|
270
|
+
cell: function cell(props) {
|
|
271
|
+
return /*#__PURE__*/React.createElement("td", _objectSpread(_objectSpread({}, props), {}, {
|
|
272
|
+
className: classNames(props.className, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n max-width: 300px;\n white-space: nowrap;\n .nb-read-pretty-input-number {\n text-align: right;\n }\n "]))))
|
|
273
|
+
}));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
}, [field, onRowDragEnd, dragSort]);
|
|
278
|
+
|
|
279
|
+
var defaultRowKey = function defaultRowKey(record) {
|
|
280
|
+
var _field$value2, _field$value2$indexOf;
|
|
281
|
+
|
|
282
|
+
return (_field$value2 = field.value) === null || _field$value2 === void 0 ? void 0 : (_field$value2$indexOf = _field$value2.indexOf) === null || _field$value2$indexOf === void 0 ? void 0 : _field$value2$indexOf.call(_field$value2, record);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
var getRowKey = function getRowKey(record) {
|
|
286
|
+
if (typeof rowKey === 'string') {
|
|
287
|
+
var _record$rowKey;
|
|
288
|
+
|
|
289
|
+
return (_record$rowKey = record[rowKey]) === null || _record$rowKey === void 0 ? void 0 : _record$rowKey.toString();
|
|
290
|
+
} else {
|
|
291
|
+
var _ref2;
|
|
292
|
+
|
|
293
|
+
return (_ref2 = (rowKey !== null && rowKey !== void 0 ? rowKey : defaultRowKey)(record)) === null || _ref2 === void 0 ? void 0 : _ref2.toString();
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
|
|
202
297
|
var restProps = {
|
|
203
298
|
rowSelection: rowSelection ? _objectSpread({
|
|
204
299
|
type: 'checkbox',
|
|
@@ -223,62 +318,32 @@ export var Table = observer(function (props) {
|
|
|
223
318
|
}
|
|
224
319
|
|
|
225
320
|
return /*#__PURE__*/React.createElement("div", {
|
|
226
|
-
className: classNames(checked ? 'checked' : null, css(
|
|
321
|
+
className: classNames(checked ? 'checked' : null, css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-evenly;\n padding-right: 8px;\n .nb-table-index {\n opacity: 0;\n }\n &:not(.checked) {\n .nb-table-index {\n opacity: 1;\n }\n }\n &:hover {\n .nb-table-index {\n opacity: 0;\n }\n .nb-origin-node {\n display: block;\n }\n }\n "]))))
|
|
227
322
|
}, /*#__PURE__*/React.createElement("div", {
|
|
228
|
-
className: classNames(checked ? 'checked' : null, css(
|
|
229
|
-
}, dragSort && /*#__PURE__*/React.createElement(SortHandle,
|
|
323
|
+
className: classNames(checked ? 'checked' : null, css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-evenly;\n "]))))
|
|
324
|
+
}, dragSort && /*#__PURE__*/React.createElement(SortHandle, {
|
|
325
|
+
id: getRowKey(record)
|
|
326
|
+
}), showIndex && /*#__PURE__*/React.createElement(TableIndex, {
|
|
230
327
|
index: index
|
|
231
328
|
})), /*#__PURE__*/React.createElement("div", {
|
|
232
|
-
className: classNames('nb-origin-node', checked ? 'checked' : null, css(
|
|
329
|
+
className: classNames('nb-origin-node', checked ? 'checked' : null, css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n position: absolute;\n right: 50%;\n transform: translateX(50%);\n &:not(.checked) {\n display: none;\n }\n "]))))
|
|
233
330
|
}, originNode));
|
|
234
331
|
}
|
|
235
332
|
}, rowSelection) : undefined
|
|
236
333
|
};
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
334
|
+
var SortableWrapper = useCallback(function (_ref3) {
|
|
335
|
+
var children = _ref3.children;
|
|
336
|
+
return dragSort ? /*#__PURE__*/React.createElement(SortableContext, {
|
|
337
|
+
items: field.value.map(getRowKey),
|
|
338
|
+
children: children
|
|
339
|
+
}) : /*#__PURE__*/React.createElement(React.Fragment, {
|
|
340
|
+
children: children
|
|
341
|
+
});
|
|
342
|
+
}, [field, dragSort]);
|
|
244
343
|
return /*#__PURE__*/React.createElement("div", {
|
|
245
|
-
className: css(
|
|
246
|
-
}, /*#__PURE__*/React.createElement(
|
|
247
|
-
|
|
248
|
-
onDragEnd: function () {
|
|
249
|
-
var _onDragEnd = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(fromIndex, toIndex) {
|
|
250
|
-
var from, to;
|
|
251
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
252
|
-
while (1) {
|
|
253
|
-
switch (_context.prev = _context.next) {
|
|
254
|
-
case 0:
|
|
255
|
-
from = field.value[fromIndex];
|
|
256
|
-
to = field.value[toIndex];
|
|
257
|
-
field.move(fromIndex, toIndex);
|
|
258
|
-
onRowDragEnd({
|
|
259
|
-
fromIndex: fromIndex,
|
|
260
|
-
toIndex: toIndex,
|
|
261
|
-
from: from,
|
|
262
|
-
to: to
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
case 4:
|
|
266
|
-
case "end":
|
|
267
|
-
return _context.stop();
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}, _callee);
|
|
271
|
-
}));
|
|
272
|
-
|
|
273
|
-
function onDragEnd(_x, _x2) {
|
|
274
|
-
return _onDragEnd.apply(this, arguments);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
return onDragEnd;
|
|
278
|
-
}(),
|
|
279
|
-
lineClassName: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n border-bottom: 2px solid rgba(241, 139, 98, 0.6) !important;\n "])))
|
|
280
|
-
}, /*#__PURE__*/React.createElement(AntdTable, _objectSpread(_objectSpread(_objectSpread({
|
|
281
|
-
rowKey: defaultRowKey
|
|
344
|
+
className: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n .ant-table {\n overflow-x: auto;\n overflow-y: hidden;\n }\n "])))
|
|
345
|
+
}, /*#__PURE__*/React.createElement(SortableWrapper, null, /*#__PURE__*/React.createElement(AntdTable, _objectSpread(_objectSpread(_objectSpread({
|
|
346
|
+
rowKey: rowKey !== null && rowKey !== void 0 ? rowKey : defaultRowKey
|
|
282
347
|
}, others), restProps), {}, {
|
|
283
348
|
pagination: paginationProps,
|
|
284
349
|
components: components,
|
|
@@ -289,5 +354,11 @@ export var Table = observer(function (props) {
|
|
|
289
354
|
// scroll={{ x: 12 * 300 + 80 }}
|
|
290
355
|
columns: columns,
|
|
291
356
|
dataSource: field === null || field === void 0 ? void 0 : (_field$value3 = field.value) === null || _field$value3 === void 0 ? void 0 : (_field$value3$slice = _field$value3.slice) === null || _field$value3$slice === void 0 ? void 0 : _field$value3$slice.call(_field$value3)
|
|
292
|
-
})))
|
|
357
|
+
}))), field.errors.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
358
|
+
className: "ant-formily-item-error-help ant-formily-item-help ant-formily-item-help-enter ant-formily-item-help-enter-active"
|
|
359
|
+
}, field.errors.map(function (error) {
|
|
360
|
+
return error.messages.map(function (message) {
|
|
361
|
+
return /*#__PURE__*/React.createElement("div", null, message);
|
|
362
|
+
});
|
|
363
|
+
})));
|
|
293
364
|
});
|
|
@@ -32,6 +32,9 @@ export var TableField = observer(function (props) {
|
|
|
32
32
|
ctx.field.added.add(fieldSchema.name);
|
|
33
33
|
}
|
|
34
34
|
}, []);
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
field.decoratorProps.asterisk = fieldSchema.required;
|
|
37
|
+
}, [fieldSchema.required]);
|
|
35
38
|
return /*#__PURE__*/React.createElement("div", null, props.children);
|
|
36
39
|
});
|
|
37
40
|
TableField.ActionBar = observer(function (props) {
|
|
@@ -25,28 +25,39 @@ export var TabsDesigner = function TabsDesigner() {
|
|
|
25
25
|
properties: {
|
|
26
26
|
title: {
|
|
27
27
|
title: t('Tab name'),
|
|
28
|
+
required: true,
|
|
28
29
|
'x-decorator': 'FormItem',
|
|
29
30
|
'x-component': 'Input',
|
|
30
31
|
'x-component-props': {}
|
|
32
|
+
},
|
|
33
|
+
icon: {
|
|
34
|
+
title: t('Icon'),
|
|
35
|
+
'x-decorator': 'FormItem',
|
|
36
|
+
'x-component': 'IconPicker',
|
|
37
|
+
'x-component-props': {}
|
|
31
38
|
}
|
|
32
39
|
}
|
|
33
40
|
},
|
|
34
41
|
initialValues: {
|
|
35
|
-
title: field.title
|
|
42
|
+
title: field.title,
|
|
43
|
+
icon: field.componentProps.icon
|
|
36
44
|
},
|
|
37
45
|
onSubmit: function onSubmit(_ref) {
|
|
38
|
-
var
|
|
46
|
+
var _schema;
|
|
39
47
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
var title = _ref.title,
|
|
49
|
+
icon = _ref.icon;
|
|
50
|
+
var props = fieldSchema['x-component-props'] || {};
|
|
51
|
+
fieldSchema.title = title;
|
|
52
|
+
field.title = title;
|
|
53
|
+
props.icon = icon;
|
|
54
|
+
field.componentProps.icon = icon;
|
|
55
|
+
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
|
56
|
+
fieldSchema['x-component-props'].icon = icon;
|
|
57
|
+
dn.emit('patch', {
|
|
58
|
+
schema: (_schema = {}, _defineProperty(_schema, 'x-uid', fieldSchema['x-uid']), _defineProperty(_schema, "title", title), _defineProperty(_schema, 'x-component-props', props), _schema)
|
|
59
|
+
});
|
|
60
|
+
dn.refresh();
|
|
50
61
|
}
|
|
51
62
|
}), /*#__PURE__*/React.createElement(SchemaSettings.Divider, null), /*#__PURE__*/React.createElement(SchemaSettings.Remove, null));
|
|
52
63
|
};
|
|
@@ -7,6 +7,7 @@ import { observer, RecursionField, useField, useFieldSchema } from '@formily/rea
|
|
|
7
7
|
import { Tabs as AntdTabs } from 'antd';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import React from 'react';
|
|
10
|
+
import { Icon } from '../../../icon';
|
|
10
11
|
import { useSchemaInitializer } from '../../../schema-initializer';
|
|
11
12
|
import { DndContext, SortableItem } from '../../common';
|
|
12
13
|
import { useDesigner } from '../../hooks/useDesigner';
|
|
@@ -42,6 +43,11 @@ Tabs.TabPane = observer(function (props) {
|
|
|
42
43
|
var field = useField();
|
|
43
44
|
return /*#__PURE__*/React.createElement(SortableItem, {
|
|
44
45
|
className: classNames('nb-action-link', designerCss, props.className)
|
|
45
|
-
}, props.
|
|
46
|
+
}, props.icon && /*#__PURE__*/React.createElement(Icon, {
|
|
47
|
+
style: {
|
|
48
|
+
marginRight: 2
|
|
49
|
+
},
|
|
50
|
+
type: props.icon
|
|
51
|
+
}), " ", props.tab || field.title, /*#__PURE__*/React.createElement(Designer, null));
|
|
46
52
|
});
|
|
47
53
|
Tabs.Designer = TabsDesigner;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { usePrefixCls } from '@formily/antd/lib/__builtins__';
|
|
2
|
+
import { toArr } from '@formily/shared';
|
|
3
3
|
import cls from 'classnames';
|
|
4
|
+
import moment from 'moment';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
export var ReadPretty = function ReadPretty(props) {
|
|
6
|
-
var
|
|
7
|
+
var value = props.value,
|
|
8
|
+
_props$format = props.format,
|
|
9
|
+
format = _props$format === void 0 ? 'HH:mm:ss' : _props$format;
|
|
7
10
|
var prefixCls = usePrefixCls('description-text', props);
|
|
11
|
+
var values = toArr(value);
|
|
8
12
|
|
|
9
13
|
var getLabels = function getLabels() {
|
|
10
|
-
var labels =
|
|
11
|
-
|
|
14
|
+
var labels = values.map(function (v) {
|
|
15
|
+
return moment(v, 'HH:mm:ss').format(format);
|
|
16
|
+
});
|
|
17
|
+
return labels.join('~');
|
|
12
18
|
};
|
|
13
19
|
|
|
14
20
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { useDesignable } from '..';
|
|
5
5
|
import { PluginManager } from '../../plugin-manager';
|
|
6
|
+
import { useHotkeys } from 'react-hotkeys-hook';
|
|
6
7
|
export var DesignableSwitch = function DesignableSwitch() {
|
|
7
8
|
var _useDesignable = useDesignable(),
|
|
8
9
|
designable = _useDesignable.designable,
|
|
@@ -15,12 +16,17 @@ export var DesignableSwitch = function DesignableSwitch() {
|
|
|
15
16
|
|
|
16
17
|
if (designable) {
|
|
17
18
|
style['backgroundColor'] = '#f18b62';
|
|
18
|
-
}
|
|
19
|
+
} // 快捷键切换编辑状态
|
|
19
20
|
|
|
21
|
+
|
|
22
|
+
useHotkeys('Ctrl+Shift+U', function () {
|
|
23
|
+
return setDesignable(!designable);
|
|
24
|
+
}, [designable]);
|
|
20
25
|
return /*#__PURE__*/React.createElement(PluginManager.Toolbar.Item, {
|
|
21
26
|
selected: designable,
|
|
22
27
|
icon: /*#__PURE__*/React.createElement(HighlightOutlined, null),
|
|
23
28
|
title: t('UI Editor'),
|
|
29
|
+
subtitle: 'Ctrl+Shift+U',
|
|
24
30
|
style: style,
|
|
25
31
|
onClick: function onClick() {
|
|
26
32
|
setDesignable(!designable);
|
|
@@ -724,6 +724,27 @@ export var Designable = /*#__PURE__*/function () {
|
|
|
724
724
|
wrap = _options$wrap4 === void 0 ? defaultWrap : _options$wrap4,
|
|
725
725
|
breakRemoveOn = options.breakRemoveOn,
|
|
726
726
|
removeParentsIfNoChildren = options.removeParentsIfNoChildren;
|
|
727
|
+
var order = 0;
|
|
728
|
+
var newOrder = 0;
|
|
729
|
+
var start = false;
|
|
730
|
+
var properties = {};
|
|
731
|
+
this.current.parent.mapProperties(function (property, key) {
|
|
732
|
+
property['x-index'] = order;
|
|
733
|
+
|
|
734
|
+
if (key === _this4.current.name) {
|
|
735
|
+
++order;
|
|
736
|
+
newOrder = order;
|
|
737
|
+
start = true;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
++order;
|
|
741
|
+
|
|
742
|
+
if (start && key !== _this4.current.name) {
|
|
743
|
+
properties[key] = property;
|
|
744
|
+
|
|
745
|
+
_this4.current.parent.removeProperty(key);
|
|
746
|
+
}
|
|
747
|
+
});
|
|
727
748
|
|
|
728
749
|
if (Schema.isSchemaInstance(schema)) {
|
|
729
750
|
if (this.parentsIn(schema)) {
|
|
@@ -747,27 +768,6 @@ export var Designable = /*#__PURE__*/function () {
|
|
|
747
768
|
schema = cloneDeep(schema);
|
|
748
769
|
}
|
|
749
770
|
|
|
750
|
-
var order = 0;
|
|
751
|
-
var newOrder = 0;
|
|
752
|
-
var start = false;
|
|
753
|
-
var properties = {};
|
|
754
|
-
this.current.parent.mapProperties(function (property, key) {
|
|
755
|
-
property['x-index'] = order;
|
|
756
|
-
|
|
757
|
-
if (key === _this4.current.name) {
|
|
758
|
-
++order;
|
|
759
|
-
newOrder = order;
|
|
760
|
-
start = true;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
++order;
|
|
764
|
-
|
|
765
|
-
if (start && key !== _this4.current.name) {
|
|
766
|
-
properties[key] = property;
|
|
767
|
-
|
|
768
|
-
_this4.current.parent.removeProperty(key);
|
|
769
|
-
}
|
|
770
|
-
});
|
|
771
771
|
this.prepareProperty(schema);
|
|
772
772
|
var wrapped = wrap(schema);
|
|
773
773
|
var s = this.current.parent.addProperty(wrapped.name || uid(), wrapped);
|