tntd 1.4.20 → 1.4.22
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/components/Handle/README.md +0 -20
- package/components/Handle/index.js +44 -7
- package/components/locale.js +8 -2
- package/dist/1.tntd.js +1 -1
- package/dist/stats.json +24430 -24390
- package/dist/tntd.css +1 -1
- package/dist/tntd.js +13 -8
- package/es/ArrayInput/icon.js +5 -5
- package/es/ArrayInput/index.js +108 -76
- package/es/AuthContext.js +1 -1
- package/es/Columns/index.js +38 -31
- package/es/DevelopmentLogin/LoginModal.js +45 -32
- package/es/DevelopmentLogin/index.js +17 -13
- package/es/Ellipsis/Svg/CopySVG.js +13 -13
- package/es/Ellipsis/Svg/TickSVG.js +8 -8
- package/es/Ellipsis/index.js +69 -58
- package/es/Handle/README.md +0 -20
- package/es/Handle/index.js +100 -33
- package/es/Icon/fonts/iconfont.js +12 -7
- package/es/Icon/index.js +13 -10
- package/es/Img/Contain.js +29 -24
- package/es/Img/Cover.js +54 -40
- package/es/Img/index.js +45 -36
- package/es/Layout/ActionsContext.js +2 -3
- package/es/Layout/AppList.js +92 -37
- package/es/Layout/Application.js +72 -26
- package/es/Layout/Avatar.js +66 -29
- package/es/Layout/CompatibleLanguage.js +94 -39
- package/es/Layout/EnterpriseLayout/Avatar.js +76 -38
- package/es/Layout/EnterpriseLayout/Language.js +32 -14
- package/es/Layout/EnterpriseLayout/Theme.js +34 -16
- package/es/Layout/EnterpriseLayout/index.js +16 -14
- package/es/Layout/GlobalNavigation/NavigationPopup.js +170 -59
- package/es/Layout/GlobalNavigation/index.js +54 -20
- package/es/Layout/Header.js +46 -25
- package/es/Layout/HeaderActions.js +56 -42
- package/es/Layout/HeaderNavs.js +47 -20
- package/es/Layout/HeaderTabs.js +102 -49
- package/es/Layout/Iconfont.js +1 -1
- package/es/Layout/Language.js +32 -14
- package/es/Layout/Layout.js +108 -86
- package/es/Layout/Logo.js +32 -16
- package/es/Layout/OrgAppList.js +107 -62
- package/es/Layout/SideMenu.js +124 -63
- package/es/Layout/Theme.js +61 -23
- package/es/Layout/checkAuth.js +29 -0
- package/es/Layout/index.js +34 -26
- package/es/Layout/paaslayout/CompactSideMenu.js +74 -35
- package/es/Layout/paaslayout/Header.js +45 -22
- package/es/Layout/paaslayout/Logo.js +13 -3
- package/es/Layout/paaslayout/SideMenu.js +78 -39
- package/es/Layout/paaslayout/index.js +102 -75
- package/es/Layout/storage.js +9 -10
- package/es/Layout/utils.js +136 -0
- package/es/LoadingButton/index.js +24 -15
- package/es/Modal/index.js +46 -38
- package/es/Page/Box.js +41 -34
- package/es/Page/index.js +67 -52
- package/es/Page/utils.js +5 -0
- package/es/QueryForm/Field/Checkbox.js +9 -5
- package/es/QueryForm/Field/Select.js +41 -31
- package/es/QueryForm/Field/SelectInput.js +41 -26
- package/es/QueryForm/Field/fieldsMap.js +1 -0
- package/es/QueryForm/Field/index.js +71 -41
- package/es/QueryForm/createActions.js +7 -6
- package/es/QueryForm/index.js +135 -76
- package/es/QueryListScene/List.js +128 -74
- package/es/QueryListScene/QueryForm.js +81 -46
- package/es/QueryListScene/QueryListScene.js +40 -25
- package/es/QueryListScene/Title.js +3 -3
- package/es/QueryListScene/Toolbar.js +12 -11
- package/es/Select/DropDownWrap.js +50 -29
- package/es/Select/index.js +231 -135
- package/es/Table/ResizableTable/index.js +40 -26
- package/es/Table/index.js +16 -18
- package/es/Title/index.js +23 -21
- package/es/locale.js +11 -3
- package/es/utils/checkAuth.js +5 -3
- package/es/utils/findMenuInfoByPath.js +4 -0
- package/es/utils/index.js +23 -12
- package/lib/ArrayInput/icon.js +6 -6
- package/lib/ArrayInput/index.js +127 -78
- package/lib/AuthContext.js +4 -1
- package/lib/Columns/index.js +47 -31
- package/lib/DevelopmentLogin/LoginModal.js +58 -32
- package/lib/DevelopmentLogin/index.js +27 -16
- package/lib/Ellipsis/Svg/CopySVG.js +15 -13
- package/lib/Ellipsis/Svg/TickSVG.js +10 -8
- package/lib/Ellipsis/index.js +80 -57
- package/lib/Handle/README.md +0 -20
- package/lib/Handle/index.js +119 -33
- package/lib/Icon/fonts/iconfont.js +12 -7
- package/lib/Icon/index.js +20 -11
- package/lib/Img/Contain.js +34 -24
- package/lib/Img/Cover.js +65 -42
- package/lib/Img/index.js +51 -36
- package/lib/Layout/ActionsContext.js +4 -1
- package/lib/Layout/AppList.js +118 -40
- package/lib/Layout/Application.js +86 -26
- package/lib/Layout/Avatar.js +86 -32
- package/lib/Layout/CompatibleLanguage.js +110 -39
- package/lib/Layout/EnterpriseLayout/Avatar.js +100 -41
- package/lib/Layout/EnterpriseLayout/Header.js +113 -0
- package/lib/Layout/EnterpriseLayout/HeaderActions.js +104 -0
- package/lib/Layout/EnterpriseLayout/Language.js +48 -17
- package/lib/Layout/EnterpriseLayout/Theme.js +44 -16
- package/lib/Layout/EnterpriseLayout/index.js +23 -14
- package/lib/Layout/GlobalNavigation/NavigationPopup.js +186 -59
- package/lib/Layout/GlobalNavigation/index.js +74 -23
- package/lib/Layout/Header.js +63 -28
- package/lib/Layout/HeaderActions.js +74 -45
- package/lib/Layout/HeaderNavs.js +61 -23
- package/lib/Layout/HeaderTabs.js +118 -51
- package/lib/Layout/Iconfont.js +5 -1
- package/lib/Layout/Language.js +48 -17
- package/lib/Layout/Layout.js +128 -88
- package/lib/Layout/Logo.js +43 -19
- package/lib/Layout/OrgAppList.js +127 -64
- package/lib/Layout/SideMenu.js +143 -65
- package/lib/Layout/Theme.js +73 -23
- package/lib/Layout/checkAuth.js +39 -0
- package/lib/Layout/createActions.js +5 -0
- package/lib/Layout/images/index.js +28 -0
- package/lib/Layout/index.js +55 -30
- package/lib/Layout/paaslayout/CompactSideMenu.js +84 -35
- package/lib/Layout/paaslayout/Header.js +55 -22
- package/lib/Layout/paaslayout/Logo.js +19 -3
- package/lib/Layout/paaslayout/SideMenu.js +87 -39
- package/lib/Layout/paaslayout/index.js +122 -77
- package/lib/Layout/storage.js +40 -11
- package/lib/Layout/utils.js +166 -0
- package/lib/LoadingButton/index.js +29 -15
- package/lib/Modal/index.js +53 -38
- package/lib/Page/Box.js +45 -34
- package/lib/Page/index.js +77 -52
- package/lib/Page/utils.js +9 -1
- package/lib/QueryForm/Field/Checkbox.js +13 -5
- package/lib/QueryForm/Field/Select.js +53 -33
- package/lib/QueryForm/Field/SelectInput.js +56 -28
- package/lib/QueryForm/Field/fieldsMap.js +15 -1
- package/lib/QueryForm/Field/index.js +81 -43
- package/lib/QueryForm/createActions.js +12 -6
- package/lib/QueryForm/index.js +157 -78
- package/lib/QueryForm/useForm.js +5 -0
- package/lib/QueryListScene/List.js +140 -76
- package/lib/QueryListScene/QueryForm.js +86 -46
- package/lib/QueryListScene/QueryListScene.js +46 -25
- package/lib/QueryListScene/Title.js +7 -3
- package/lib/QueryListScene/Toolbar.js +16 -11
- package/lib/QueryListScene/createActions.js +5 -0
- package/lib/QueryListScene/index.js +10 -0
- package/lib/QueryListScene/useActions.js +5 -0
- package/lib/Select/DropDownWrap.js +56 -31
- package/lib/Select/index.js +241 -135
- package/lib/Table/ResizableTable/index.js +48 -26
- package/lib/Table/index.js +28 -17
- package/lib/Title/index.js +28 -21
- package/lib/index.js +56 -35
- package/lib/locale.js +19 -4
- package/lib/utils/checkAuth.js +9 -4
- package/lib/utils/findMenuInfoByPath.js +8 -1
- package/lib/utils/index.js +42 -15
- package/package.json +2 -2
package/lib/QueryForm/index.js
CHANGED
|
@@ -1,56 +1,92 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports["default"] = void 0;
|
|
7
|
+
|
|
8
8
|
require("antd/lib/form/style");
|
|
9
|
+
|
|
9
10
|
var _form = _interopRequireDefault(require("antd/lib/form"));
|
|
11
|
+
|
|
10
12
|
require("antd/lib/drawer/style");
|
|
13
|
+
|
|
11
14
|
var _drawer = _interopRequireDefault(require("antd/lib/drawer"));
|
|
15
|
+
|
|
12
16
|
require("antd/lib/badge/style");
|
|
17
|
+
|
|
13
18
|
var _badge = _interopRequireDefault(require("antd/lib/badge"));
|
|
19
|
+
|
|
14
20
|
require("antd/lib/button/style");
|
|
21
|
+
|
|
15
22
|
var _button = _interopRequireDefault(require("antd/lib/button"));
|
|
23
|
+
|
|
16
24
|
var _react = _interopRequireWildcard(require("react"));
|
|
25
|
+
|
|
17
26
|
var _classnames3 = _interopRequireDefault(require("classnames"));
|
|
27
|
+
|
|
18
28
|
var _lodash = require("lodash");
|
|
29
|
+
|
|
19
30
|
var _useForm = _interopRequireDefault(require("./useForm"));
|
|
31
|
+
|
|
20
32
|
var _createActions = _interopRequireDefault(require("./createActions"));
|
|
33
|
+
|
|
21
34
|
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
35
|
+
|
|
22
36
|
var _Field = _interopRequireDefault(require("./Field"));
|
|
37
|
+
|
|
23
38
|
var _locale = require("../locale");
|
|
39
|
+
|
|
24
40
|
require("./index.less");
|
|
25
|
-
|
|
26
|
-
function
|
|
41
|
+
|
|
42
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
43
|
+
|
|
44
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
45
|
+
|
|
27
46
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
28
|
-
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
function
|
|
47
|
+
|
|
48
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
49
|
+
|
|
50
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
51
|
+
|
|
52
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
53
|
+
|
|
54
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
55
|
+
|
|
56
|
+
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; }
|
|
57
|
+
|
|
32
58
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
59
|
+
|
|
60
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
61
|
+
|
|
62
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
63
|
+
|
|
64
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
65
|
+
|
|
41
66
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
42
|
-
|
|
43
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf
|
|
67
|
+
|
|
68
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
69
|
+
|
|
70
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
71
|
+
|
|
72
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
73
|
+
|
|
44
74
|
var clsPrefix = 'tnt-queryform';
|
|
45
|
-
|
|
75
|
+
|
|
76
|
+
var QueryForm =
|
|
77
|
+
/*#__PURE__*/
|
|
78
|
+
function (_React$PureComponent) {
|
|
46
79
|
_inherits(QueryForm, _React$PureComponent);
|
|
47
|
-
|
|
80
|
+
|
|
48
81
|
function QueryForm(props) {
|
|
49
82
|
var _this;
|
|
83
|
+
|
|
50
84
|
_classCallCheck(this, QueryForm);
|
|
51
|
-
|
|
85
|
+
|
|
86
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(QueryForm).call(this, props));
|
|
52
87
|
_this.onWindowResize = (0, _lodash.debounce)(function () {
|
|
53
88
|
var current = _this.fieldsRef.current;
|
|
89
|
+
|
|
54
90
|
if (current) {
|
|
55
91
|
setTimeout(function () {
|
|
56
92
|
_this.setState({
|
|
@@ -59,60 +95,82 @@ var QueryForm = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
59
95
|
}, 25);
|
|
60
96
|
}
|
|
61
97
|
}, 50);
|
|
98
|
+
|
|
62
99
|
_this.search = function (params) {
|
|
63
|
-
_this.props.onSearch(_objectSpread(
|
|
100
|
+
_this.props.onSearch(_objectSpread({}, _this.form.getValues(), {}, params));
|
|
64
101
|
};
|
|
102
|
+
|
|
65
103
|
_this.onSearch = function () {
|
|
66
104
|
_this.props.onSearch == null ? void 0 : _this.props.onSearch(_this.form.getValues());
|
|
67
105
|
};
|
|
106
|
+
|
|
68
107
|
_this.onReset = function () {
|
|
69
108
|
var _this$props = _this.props,
|
|
70
|
-
|
|
71
|
-
|
|
109
|
+
initialValues = _this$props.initialValues,
|
|
110
|
+
onReset = _this$props.onReset;
|
|
111
|
+
|
|
72
112
|
_this.form.setValues(_objectSpread({}, initialValues));
|
|
113
|
+
|
|
73
114
|
_this.updateDrawerFieldsValueCount();
|
|
115
|
+
|
|
74
116
|
onReset == null ? void 0 : onReset(initialValues);
|
|
75
117
|
};
|
|
118
|
+
|
|
76
119
|
_this.onToggleExpand = function () {
|
|
77
120
|
_this.setState({
|
|
78
121
|
expanded: !_this.state.expanded
|
|
79
122
|
});
|
|
123
|
+
|
|
80
124
|
_this.props.onToggleExpand == null ? void 0 : _this.props.onToggleExpand(!_this.state.expanded);
|
|
81
125
|
};
|
|
126
|
+
|
|
82
127
|
_this.onShowDrawer = function () {
|
|
83
128
|
_this.setState({
|
|
84
129
|
drawerVisible: true
|
|
85
130
|
});
|
|
86
131
|
};
|
|
132
|
+
|
|
87
133
|
_this.onFieldChange = function (name, value) {
|
|
88
134
|
var values = _this.form.getValues();
|
|
89
|
-
|
|
135
|
+
|
|
136
|
+
var newValues = _objectSpread({}, values, _defineProperty({}, name, value));
|
|
137
|
+
|
|
90
138
|
var changedInfo = {
|
|
91
139
|
name: name,
|
|
92
140
|
value: value,
|
|
93
141
|
preValue: values == null ? void 0 : values[name]
|
|
94
142
|
};
|
|
95
143
|
var onChange = _this.props.onChange;
|
|
144
|
+
|
|
96
145
|
_this.form.setData('values', newValues);
|
|
146
|
+
|
|
97
147
|
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
98
148
|
rest[_key - 2] = arguments[_key];
|
|
99
149
|
}
|
|
150
|
+
|
|
100
151
|
onChange && onChange.apply(void 0, [newValues, changedInfo].concat(rest));
|
|
152
|
+
|
|
101
153
|
_this.updateDrawerFieldsValueCount(newValues);
|
|
102
154
|
};
|
|
155
|
+
|
|
103
156
|
_this.updateDrawerFieldsValueCount = function () {
|
|
104
157
|
var values = _this.form.getValues();
|
|
158
|
+
|
|
105
159
|
var _this$props2 = _this.props,
|
|
106
|
-
|
|
107
|
-
|
|
160
|
+
showFieldCount = _this$props2.showFieldCount,
|
|
161
|
+
children = _this$props2.children;
|
|
162
|
+
|
|
108
163
|
if (showFieldCount) {
|
|
109
164
|
var drawerFieldsValueCount = children.reduce(function (acc, cur, index) {
|
|
110
165
|
var _cur$props;
|
|
111
|
-
|
|
166
|
+
|
|
167
|
+
if (index >= showFieldCount && (values == null ? void 0 : values[cur == null ? void 0 : (_cur$props = cur.props) == null ? void 0 : _cur$props.name])) {
|
|
112
168
|
acc++;
|
|
113
169
|
}
|
|
170
|
+
|
|
114
171
|
return acc;
|
|
115
172
|
}, 0);
|
|
173
|
+
|
|
116
174
|
if (drawerFieldsValueCount !== _this.state.drawerFieldsValueCount) {
|
|
117
175
|
_this.setState({
|
|
118
176
|
drawerFieldsValueCount: drawerFieldsValueCount
|
|
@@ -120,92 +178,102 @@ var QueryForm = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
120
178
|
}
|
|
121
179
|
}
|
|
122
180
|
};
|
|
181
|
+
|
|
123
182
|
var form = props.form,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
183
|
+
_initialValues = props.initialValues,
|
|
184
|
+
_props$showExpand = props.showExpand,
|
|
185
|
+
showExpand = _props$showExpand === void 0 ? true : _props$showExpand,
|
|
186
|
+
renderActions = props.renderActions,
|
|
187
|
+
defaultExpanded = props.defaultExpanded;
|
|
129
188
|
_this.state = {
|
|
130
189
|
showMore: false,
|
|
131
190
|
expanded: defaultExpanded || !showExpand || renderActions ? true : false,
|
|
132
191
|
drawerVisible: false,
|
|
133
192
|
drawerFieldsValueCount: 0
|
|
134
193
|
};
|
|
135
|
-
_this.fieldsRef =
|
|
136
|
-
_this.formBoxRef =
|
|
194
|
+
_this.fieldsRef = (0, _react.createRef)();
|
|
195
|
+
_this.formBoxRef = (0, _react.createRef)();
|
|
137
196
|
_this.form = form || (0, _createActions["default"])();
|
|
197
|
+
|
|
138
198
|
_this.form.setData('initialValues', _initialValues);
|
|
199
|
+
|
|
139
200
|
_this.form.setData('values', _objectSpread({}, _initialValues));
|
|
201
|
+
|
|
140
202
|
return _this;
|
|
141
203
|
}
|
|
204
|
+
|
|
142
205
|
_createClass(QueryForm, [{
|
|
143
206
|
key: "render",
|
|
144
207
|
value: function render() {
|
|
145
208
|
var _this2 = this;
|
|
209
|
+
|
|
146
210
|
var _this$props3 = this.props,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
211
|
+
children = _this$props3.children,
|
|
212
|
+
_this$props3$classNam = _this$props3.className,
|
|
213
|
+
className = _this$props3$classNam === void 0 ? '' : _this$props3$classNam,
|
|
214
|
+
_this$props3$initialV = _this$props3.initialValues,
|
|
215
|
+
initialValues = _this$props3$initialV === void 0 ? {} : _this$props3$initialV,
|
|
216
|
+
renderActions = _this$props3.renderActions,
|
|
217
|
+
_this$props3$showSear = _this$props3.showSearch,
|
|
218
|
+
showSearch = _this$props3$showSear === void 0 ? true : _this$props3$showSear,
|
|
219
|
+
_this$props3$showRese = _this$props3.showReset,
|
|
220
|
+
showReset = _this$props3$showRese === void 0 ? true : _this$props3$showRese,
|
|
221
|
+
showFieldCount = _this$props3.showFieldCount,
|
|
222
|
+
_this$props3$drawerPr = _this$props3.drawerProps,
|
|
223
|
+
drawerProps = _this$props3$drawerPr === void 0 ? {} : _this$props3$drawerPr,
|
|
224
|
+
size = _this$props3.size;
|
|
161
225
|
var extraActions = this.props.extraActions;
|
|
162
226
|
var _this$state = this.state,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
227
|
+
expanded = _this$state.expanded,
|
|
228
|
+
showMore = _this$state.showMore,
|
|
229
|
+
drawerVisible = _this$state.drawerVisible,
|
|
230
|
+
drawerFieldsValueCount = _this$state.drawerFieldsValueCount;
|
|
231
|
+
|
|
167
232
|
var renderFormActions = renderActions || function () {
|
|
168
|
-
return
|
|
233
|
+
return _react["default"].createElement(_react["default"].Fragment, null, showFieldCount && _react["default"].createElement(_badge["default"], {
|
|
169
234
|
count: drawerFieldsValueCount
|
|
170
|
-
},
|
|
235
|
+
}, _react["default"].createElement(_button["default"], {
|
|
171
236
|
onClick: _this2.onShowDrawer
|
|
172
|
-
},
|
|
237
|
+
}, _react["default"].createElement(_Icon["default"], {
|
|
173
238
|
type: "filter"
|
|
174
|
-
}), _this2.getText('moreFiltering'))), showSearch &&
|
|
239
|
+
}), _this2.getText('moreFiltering'))), showSearch && _react["default"].createElement(_button["default"], {
|
|
175
240
|
type: "primary",
|
|
176
241
|
onClick: _this2.onSearch
|
|
177
|
-
}, _this2.getText('search')), showReset &&
|
|
242
|
+
}, _this2.getText('search')), showReset && _react["default"].createElement(_button["default"], {
|
|
178
243
|
onClick: _this2.onReset
|
|
179
|
-
}, _this2.getText('reset')), showMore && !showFieldCount &&
|
|
244
|
+
}, _this2.getText('reset')), showMore && !showFieldCount && _react["default"].createElement(_button["default"], {
|
|
180
245
|
className: "expand-link",
|
|
181
246
|
type: "link",
|
|
182
247
|
onClick: _this2.onToggleExpand
|
|
183
248
|
}, _this2.getText(expanded ? 'collapse' : 'expand')), _react["default"].Children.map(children, function (child) {
|
|
184
249
|
var _child$props;
|
|
185
|
-
|
|
250
|
+
|
|
251
|
+
return child && (child == null ? void 0 : (_child$props = child.props) == null ? void 0 : _child$props.align) === 'right' && _react["default"].cloneElement(child);
|
|
186
252
|
}));
|
|
187
253
|
};
|
|
188
|
-
|
|
254
|
+
|
|
255
|
+
return _react["default"].createElement("div", {
|
|
189
256
|
ref: this.formBoxRef,
|
|
190
257
|
className: (0, _classnames3["default"])(clsPrefix, _defineProperty({}, className, className))
|
|
191
|
-
},
|
|
258
|
+
}, _react["default"].createElement(_form["default"], {
|
|
192
259
|
layout: "inline",
|
|
193
260
|
className: (0, _classnames3["default"])({
|
|
194
261
|
expanded: !showMore || expanded,
|
|
195
262
|
showMore: showMore
|
|
196
263
|
})
|
|
197
|
-
},
|
|
264
|
+
}, _react["default"].createElement("div", {
|
|
198
265
|
ref: this.fieldsRef
|
|
199
266
|
}, _react["default"].Children.map(children, function (child, index) {
|
|
200
267
|
var _child$props2;
|
|
201
|
-
|
|
268
|
+
|
|
269
|
+
return child && (child == null ? void 0 : (_child$props2 = child.props) == null ? void 0 : _child$props2.align) !== 'right' && (!showFieldCount || showFieldCount > index) && _react["default"].cloneElement(child, {
|
|
202
270
|
form: _this2.form,
|
|
203
271
|
initialValue: initialValues == null ? void 0 : initialValues[child.props.name],
|
|
204
272
|
onChange: _this2.onFieldChange
|
|
205
273
|
});
|
|
206
|
-
})),
|
|
274
|
+
})), _react["default"].createElement("div", {
|
|
207
275
|
className: "".concat(clsPrefix, "-actions")
|
|
208
|
-
}, renderFormActions()), showFieldCount &&
|
|
276
|
+
}, renderFormActions()), showFieldCount && _react["default"].createElement(_drawer["default"], _extends({
|
|
209
277
|
title: this.getText('moreFiltering'),
|
|
210
278
|
visible: drawerVisible,
|
|
211
279
|
onClose: function onClose() {
|
|
@@ -221,19 +289,19 @@ var QueryForm = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
221
289
|
'large-size': size === 'large'
|
|
222
290
|
}, className, className))
|
|
223
291
|
}), _react["default"].Children.map(children, function (child, index) {
|
|
224
|
-
return child && index >= showFieldCount &&
|
|
292
|
+
return child && index >= showFieldCount && _react["default"].cloneElement(child, {
|
|
225
293
|
form: _this2.form,
|
|
226
294
|
isFieldInDrawer: true,
|
|
227
295
|
initialValue: initialValues == null ? void 0 : initialValues[child.props.name],
|
|
228
296
|
onChange: _this2.onFieldChange,
|
|
229
297
|
onSearch: _this2.onSearch
|
|
230
298
|
});
|
|
231
|
-
}),
|
|
299
|
+
}), _react["default"].createElement(_button["default"], {
|
|
232
300
|
type: "primary",
|
|
233
301
|
onClick: this.onSearch
|
|
234
|
-
}, this.getText('search')),
|
|
302
|
+
}, this.getText('search')), _react["default"].createElement(_button["default"], {
|
|
235
303
|
onClick: this.onReset
|
|
236
|
-
}, this.getText('reset')))), extraActions &&
|
|
304
|
+
}, this.getText('reset')))), extraActions && _react["default"].createElement("div", {
|
|
237
305
|
className: "".concat(clsPrefix, "-extra")
|
|
238
306
|
}, extraActions));
|
|
239
307
|
}
|
|
@@ -246,6 +314,7 @@ var QueryForm = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
246
314
|
key: "isFieldsWidthOverflow",
|
|
247
315
|
value: function isFieldsWidthOverflow() {
|
|
248
316
|
var current = this.fieldsRef.current;
|
|
317
|
+
|
|
249
318
|
if (current) {
|
|
250
319
|
return current.offsetWidth < [].reduce.call(current.children, function (acc, cur) {
|
|
251
320
|
var marginArray = window.getComputedStyle(cur).margin.split(' ').map(function (str) {
|
|
@@ -255,23 +324,30 @@ var QueryForm = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
255
324
|
return acc;
|
|
256
325
|
}, 0);
|
|
257
326
|
}
|
|
327
|
+
|
|
258
328
|
return false;
|
|
259
329
|
}
|
|
260
330
|
}, {
|
|
261
331
|
key: "updateFieldHeight",
|
|
262
332
|
value: function updateFieldHeight() {
|
|
263
333
|
var _formBoxRef$current, _formBoxRef$current2, _fieldsRef$current;
|
|
334
|
+
|
|
264
335
|
var formBoxRef = this.formBoxRef,
|
|
265
|
-
|
|
336
|
+
fieldsRef = this.fieldsRef;
|
|
337
|
+
|
|
266
338
|
var getFieldHeight = function getFieldHeight() {
|
|
267
339
|
var _current$children;
|
|
340
|
+
|
|
268
341
|
var current = fieldsRef.current;
|
|
269
342
|
var height = '32px';
|
|
270
|
-
|
|
343
|
+
|
|
344
|
+
if (current && ((_current$children = current.children) == null ? void 0 : _current$children[0])) {
|
|
271
345
|
height = window.getComputedStyle(current.children[0]).height;
|
|
272
346
|
}
|
|
347
|
+
|
|
273
348
|
return height;
|
|
274
349
|
};
|
|
350
|
+
|
|
275
351
|
var queryFormActionsDom = formBoxRef == null ? void 0 : (_formBoxRef$current = formBoxRef.current) == null ? void 0 : _formBoxRef$current.querySelector(".".concat(clsPrefix, "-actions"));
|
|
276
352
|
var queryFormExtraDom = formBoxRef == null ? void 0 : (_formBoxRef$current2 = formBoxRef.current) == null ? void 0 : _formBoxRef$current2.querySelector(".".concat(clsPrefix, "-extra"));
|
|
277
353
|
var formItemsDomList = fieldsRef == null ? void 0 : (_fieldsRef$current = fieldsRef.current) == null ? void 0 : _fieldsRef$current.querySelectorAll('.ant-form-item-control');
|
|
@@ -292,24 +368,25 @@ var QueryForm = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
292
368
|
value: function componentDidMount() {
|
|
293
369
|
var current = this.fieldsRef.current;
|
|
294
370
|
var _this$props4 = this.props,
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
371
|
+
showFieldCount = _this$props4.showFieldCount,
|
|
372
|
+
_this$props4$showExpa = _this$props4.showExpand,
|
|
373
|
+
showExpand = _this$props4$showExpa === void 0 ? true : _this$props4$showExpa,
|
|
374
|
+
renderActions = _this$props4.renderActions;
|
|
299
375
|
this.updateFieldHeight();
|
|
300
|
-
this.form.on('search', this.search);
|
|
301
|
-
|
|
302
|
-
// 未设置第一行显示数量且禁止了展开操作 或 自定义了操作区域,则不需要处理展开计算逻辑
|
|
376
|
+
this.form.on('search', this.search); // 未设置第一行显示数量且禁止了展开操作 或 自定义了操作区域,则不需要处理展开计算逻辑
|
|
303
377
|
// || renderActions
|
|
378
|
+
|
|
304
379
|
if (!showFieldCount && !showExpand) {
|
|
305
380
|
return;
|
|
306
381
|
}
|
|
382
|
+
|
|
307
383
|
if (!showFieldCount) {
|
|
308
384
|
if (current && this.isFieldsWidthOverflow()) {
|
|
309
385
|
this.setState({
|
|
310
386
|
showMore: true
|
|
311
387
|
});
|
|
312
388
|
}
|
|
389
|
+
|
|
313
390
|
window.addEventListener('resize', this.onWindowResize);
|
|
314
391
|
} else {
|
|
315
392
|
this.updateDrawerFieldsValueCount();
|
|
@@ -326,8 +403,10 @@ var QueryForm = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
326
403
|
this.form.off('search', this.search);
|
|
327
404
|
}
|
|
328
405
|
}]);
|
|
406
|
+
|
|
329
407
|
return QueryForm;
|
|
330
408
|
}(_react["default"].PureComponent);
|
|
409
|
+
|
|
331
410
|
;
|
|
332
411
|
QueryForm.Field = _Field["default"];
|
|
333
412
|
QueryForm.useForm = _useForm["default"];
|
package/lib/QueryForm/useForm.js
CHANGED
|
@@ -4,11 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = useForm;
|
|
7
|
+
|
|
7
8
|
var _react = require("react");
|
|
9
|
+
|
|
8
10
|
var _createActions = _interopRequireDefault(require("./createActions"));
|
|
11
|
+
|
|
9
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
|
|
10
14
|
function useForm() {
|
|
11
15
|
var form = (0, _react.useRef)((0, _createActions["default"])());
|
|
12
16
|
return [form.current];
|
|
13
17
|
}
|
|
18
|
+
|
|
14
19
|
;
|