tntd 3.0.47-beta.1 → 3.0.47

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.
Files changed (90) hide show
  1. package/es/form/style/index.less +5 -5
  2. package/es/index.js +0 -7
  3. package/es/index.js.map +1 -1
  4. package/es/query-form/Field/Checkbox.js +1 -1
  5. package/es/query-form/Field/Checkbox.js.map +1 -1
  6. package/es/query-form/Field/Composition/FieldPopover.js +109 -13
  7. package/es/query-form/Field/Composition/Select.js +109 -13
  8. package/es/query-form/Field/Composition/SelectInput.js +87 -10
  9. package/es/query-form/Field/Composition/ValueTag.js +87 -10
  10. package/es/query-form/Field/Composition/index.js +121 -17
  11. package/es/query-form/Field/Composition/utils.js +5 -1
  12. package/es/query-form/Field/SelectInput.js +12 -16
  13. package/es/query-form/Field/SelectInput.js.map +1 -1
  14. package/es/query-form/Field/fieldsMap.js +2 -2
  15. package/es/query-form/Field/fieldsMap.js.map +1 -1
  16. package/es/query-form/Field/index.js +1 -2
  17. package/es/query-form/Field/index.js.map +1 -1
  18. package/es/query-form/index.js +357 -226
  19. package/es/query-form/index.js.map +1 -1
  20. package/es/query-form/index.less +63 -26
  21. package/es/query-list-scene/List.js +3 -16
  22. package/es/query-list-scene/List.js.map +1 -1
  23. package/es/query-list-scene/QueryForm.js +13 -35
  24. package/es/query-list-scene/QueryForm.js.map +1 -1
  25. package/es/query-list-scene/index.js +1 -2
  26. package/es/query-list-scene/index.js.map +1 -1
  27. package/es/scroll-bar/Bar.js +87 -10
  28. package/es/scroll-bar/Context.js +5 -1
  29. package/es/scroll-bar/ScrollBar.js +39 -4
  30. package/es/scroll-bar/Thumb.js +87 -10
  31. package/es/scroll-bar/index.js +5 -1
  32. package/es/scroll-bar/util.js +31 -4
  33. package/es/table/hooks/use-column-setting.js.map +1 -1
  34. package/es/table/resizableTable/index.js +5 -34
  35. package/es/table/resizableTable/index.js.map +1 -1
  36. package/es/table/resizableTable/index.less +1 -9
  37. package/es/table/table.js +2 -8
  38. package/es/table/table.js.map +1 -1
  39. package/es/tntd-select/index.js.map +1 -1
  40. package/es/tntd-virtual-tree/index.js +3 -0
  41. package/es/tntd-virtual-tree/index.js.map +1 -1
  42. package/lib/form/style/index.less +5 -5
  43. package/lib/index.d.ts +0 -1
  44. package/lib/index.d.ts.map +1 -1
  45. package/lib/index.js +0 -7
  46. package/lib/index.js.map +1 -1
  47. package/lib/query-form/Field/Checkbox.js +1 -1
  48. package/lib/query-form/Field/Checkbox.js.map +1 -1
  49. package/lib/query-form/Field/SelectInput.d.ts.map +1 -1
  50. package/lib/query-form/Field/SelectInput.js +12 -16
  51. package/lib/query-form/Field/SelectInput.js.map +1 -1
  52. package/lib/query-form/Field/fieldsMap.d.ts +3 -6
  53. package/lib/query-form/Field/fieldsMap.d.ts.map +1 -1
  54. package/lib/query-form/Field/fieldsMap.js +2 -2
  55. package/lib/query-form/Field/fieldsMap.js.map +1 -1
  56. package/lib/query-form/Field/index.d.ts.map +1 -1
  57. package/lib/query-form/Field/index.js +1 -2
  58. package/lib/query-form/Field/index.js.map +1 -1
  59. package/lib/query-form/index.d.ts +36 -1
  60. package/lib/query-form/index.d.ts.map +1 -1
  61. package/lib/query-form/index.js +397 -262
  62. package/lib/query-form/index.js.map +1 -1
  63. package/lib/query-form/index.less +63 -26
  64. package/lib/query-list-scene/List.d.ts.map +1 -1
  65. package/lib/query-list-scene/List.js +3 -16
  66. package/lib/query-list-scene/List.js.map +1 -1
  67. package/lib/query-list-scene/QueryForm.d.ts +4 -5
  68. package/lib/query-list-scene/QueryForm.d.ts.map +1 -1
  69. package/lib/query-list-scene/QueryForm.js +13 -35
  70. package/lib/query-list-scene/QueryForm.js.map +1 -1
  71. package/lib/query-list-scene/index.d.ts.map +1 -1
  72. package/lib/query-list-scene/index.js +1 -2
  73. package/lib/query-list-scene/index.js.map +1 -1
  74. package/lib/segmented/index.d.ts +1 -1
  75. package/lib/table/hooks/use-column-setting.d.ts +0 -1
  76. package/lib/table/hooks/use-column-setting.d.ts.map +1 -1
  77. package/lib/table/hooks/use-column-setting.js.map +1 -1
  78. package/lib/table/resizableTable/index.d.ts +0 -3
  79. package/lib/table/resizableTable/index.d.ts.map +1 -1
  80. package/lib/table/resizableTable/index.js +5 -34
  81. package/lib/table/resizableTable/index.js.map +1 -1
  82. package/lib/table/resizableTable/index.less +1 -9
  83. package/lib/table/table.d.ts.map +1 -1
  84. package/lib/table/table.js +2 -8
  85. package/lib/table/table.js.map +1 -1
  86. package/lib/tntd-select/index.d.ts.map +1 -1
  87. package/lib/tntd-select/index.js.map +1 -1
  88. package/lib/tntd-virtual-tree/index.js +3 -0
  89. package/lib/tntd-virtual-tree/index.js.map +1 -1
  90. package/package.json +2 -3
@@ -13,14 +13,18 @@ Object.defineProperty(exports, "__esModule", {
13
13
  value: true
14
14
  });
15
15
  exports["default"] = void 0;
16
- var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
16
+ var _debounce2 = _interopRequireDefault(require("lodash/debounce"));
17
+ var _classnames3 = _interopRequireDefault(require("classnames"));
17
18
  var _react = _interopRequireWildcard(require("react"));
18
- var _classnames = _interopRequireDefault(require("classnames"));
19
- var _Composition = _interopRequireDefault(require("./Field/Composition"));
20
- var _form = _interopRequireDefault(require("../form"));
21
19
  var _createActions = _interopRequireDefault(require("./createActions"));
22
20
  var _Field = _interopRequireDefault(require("./Field"));
23
21
  var _useForm = _interopRequireDefault(require("./useForm"));
22
+ var _badge = _interopRequireDefault(require("../badge"));
23
+ var _button = _interopRequireDefault(require("../button"));
24
+ var _drawer = _interopRequireDefault(require("../drawer"));
25
+ var _form = _interopRequireDefault(require("../form"));
26
+ var _prevLocale = require("../prev-locale");
27
+ var _tntdIcon = _interopRequireDefault(require("../tntd-icon"));
24
28
  require("./index.less");
25
29
  function _getRequireWildcardCache(e) {
26
30
  if ("function" != typeof WeakMap) return null;
@@ -60,6 +64,20 @@ function _defineProperty(e, r, t) {
60
64
  writable: !0
61
65
  }) : e[r] = t, e;
62
66
  }
67
+ function _classCallCheck(a, n) {
68
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
69
+ }
70
+ function _defineProperties(e, r) {
71
+ for (var t = 0; t < r.length; t++) {
72
+ var o = r[t];
73
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
74
+ }
75
+ }
76
+ function _createClass(e, r, t) {
77
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
78
+ writable: !1
79
+ }), e;
80
+ }
63
81
  function _toPropertyKey(t) {
64
82
  var i = _toPrimitive(t, "string");
65
83
  return "symbol" == _typeof(i) ? i : i + "";
@@ -74,282 +92,399 @@ function _toPrimitive(t, r) {
74
92
  }
75
93
  return ("string" === r ? String : Number)(t);
76
94
  }
77
- function _slicedToArray(r, e) {
78
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
95
+ function _callSuper(t, o, e) {
96
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
79
97
  }
80
- function _nonIterableRest() {
81
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
98
+ function _possibleConstructorReturn(t, e) {
99
+ if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
100
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
101
+ return _assertThisInitialized(t);
82
102
  }
83
- function _unsupportedIterableToArray(r, a) {
84
- if (r) {
85
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
86
- var t = {}.toString.call(r).slice(8, -1);
87
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
88
- }
103
+ function _assertThisInitialized(e) {
104
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
105
+ return e;
89
106
  }
90
- function _arrayLikeToArray(r, a) {
91
- (null == a || a > r.length) && (a = r.length);
92
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
93
- return n;
107
+ function _isNativeReflectConstruct() {
108
+ try {
109
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
110
+ } catch (t) {}
111
+ return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
112
+ return !!t;
113
+ })();
94
114
  }
95
- function _iterableToArrayLimit(r, l) {
96
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
97
- if (null != t) {
98
- var e,
99
- n,
100
- i,
101
- u,
102
- a = [],
103
- f = !0,
104
- o = !1;
105
- try {
106
- if (i = (t = t.call(r)).next, 0 === l) {
107
- if (Object(t) !== t) return;
108
- f = !1;
109
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
110
- } catch (r) {
111
- o = !0, n = r;
112
- } finally {
113
- try {
114
- if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
115
- } finally {
116
- if (o) throw n;
117
- }
115
+ function _getPrototypeOf(t) {
116
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
117
+ return t.__proto__ || Object.getPrototypeOf(t);
118
+ }, _getPrototypeOf(t);
119
+ }
120
+ function _inherits(t, e) {
121
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
122
+ t.prototype = Object.create(e && e.prototype, {
123
+ constructor: {
124
+ value: t,
125
+ writable: !0,
126
+ configurable: !0
118
127
  }
119
- return a;
120
- }
128
+ }), Object.defineProperty(t, "prototype", {
129
+ writable: !1
130
+ }), e && _setPrototypeOf(t, e);
131
+ }
132
+ function _setPrototypeOf(t, e) {
133
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
134
+ return t.__proto__ = e, t;
135
+ }, _setPrototypeOf(t, e);
121
136
  }
122
- function _arrayWithHoles(r) {
123
- if (Array.isArray(r)) return r;
124
- } // import Button from '../button'
125
- // import { getLanguage, getText } from '../prev-locale'
126
137
  var clsPrefix = 'tnt-queryform';
127
- var QueryForm = (0, _react.forwardRef)(function (_ref, ref) {
128
- var form = _ref.form,
129
- _ref$className = _ref.className,
130
- className = _ref$className === void 0 ? '' : _ref$className,
131
- _initialValues = _ref.initialValues,
132
- language = _ref.language,
133
- onSearch = _ref.onSearch,
134
- onReset = _ref.onReset,
135
- hasOnChange = _ref.hasOnChange,
136
- onChange = _ref.onChange,
137
- renderActions = _ref.renderActions,
138
- extraActions = _ref.extraActions,
139
- children = _ref.children,
140
- _ref$showSearch = _ref.showSearch,
141
- showSearch = _ref$showSearch === void 0 ? false : _ref$showSearch,
142
- _ref$showReset = _ref.showReset,
143
- showReset = _ref$showReset === void 0 ? false : _ref$showReset,
144
- _ref$showFieldCount = _ref.showFieldCount,
145
- showFieldCount = _ref$showFieldCount === void 0 ? 3 : _ref$showFieldCount,
146
- _ref$minGroupCount = _ref.minGroupCount,
147
- minGroupCount = _ref$minGroupCount === void 0 ? 3 : _ref$minGroupCount,
148
- _ref$compositionShowR = _ref.compositionShowReset,
149
- compositionShowReset = _ref$compositionShowR === void 0 ? true : _ref$compositionShowR,
150
- inline = _ref.inline,
151
- defaultSearchField = _ref.defaultSearchField,
152
- defaultSearchPlaceholder = _ref.defaultSearchPlaceholder;
153
- var _useState = (0, _react.useState)(_initialValues || {}),
154
- _useState2 = _slicedToArray(_useState, 2),
155
- initialValues = _useState2[0],
156
- setInitialValues = _useState2[1];
157
- var formRef = (0, _react.useRef)(form || (0, _createActions["default"])());
158
- (0, _react.useImperativeHandle)(ref, function () {
159
- return {
160
- form: formRef.current
161
- };
162
- }, []);
163
- (0, _react.useEffect)(function () {
164
- var _search = function _search() {
165
- var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
166
- onSearch === null || onSearch === void 0 ? void 0 : onSearch(Object.assign(Object.assign({}, formRef.current.getValues()), params));
167
- };
168
- formRef.current.setData('initialValues', initialValues);
169
- formRef.current.setData('values', initialValues);
170
- formRef.current.on('search', _search);
171
- return function () {
172
- formRef.current.off('search', _search);
173
- };
174
- }, []);
175
- // const _getText = (key) => {
176
- // return getText(key, language || getLanguage())
177
- // }
178
- var _onSearch = function _onSearch() {
179
- onSearch === null || onSearch === void 0 ? void 0 : onSearch(formRef.current.getValues());
180
- };
181
- var _onReset = function _onReset() {
182
- formRef.current.setValues(Object.assign({}, initialValues));
183
- onReset === null || onReset === void 0 ? void 0 : onReset(initialValues);
184
- setInitialValues(Object.assign({}, initialValues));
185
- };
186
- var _onFieldChange = function _onFieldChange(name, value) {
187
- var values = formRef.current.getValues();
188
- var newValues = Object.assign(Object.assign({}, values), _defineProperty({}, name, value));
189
- var changedInfo = {
190
- name: name,
191
- value: value,
192
- preValue: values === null || values === void 0 ? void 0 : values[name]
193
- };
194
- formRef.current.setData('values', newValues);
195
- for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
196
- rest[_key - 2] = arguments[_key];
197
- }
198
- onChange && onChange.apply(void 0, [newValues, changedInfo].concat(rest));
199
- };
200
- var _onCompositionFieldChange = function _onCompositionFieldChange(value, deleteKeys, needSearch, isReset) {
201
- var values = formRef.current.getValues();
202
- var newValues = Object.assign(Object.assign({}, values), value);
203
- var changeKeys = Object.keys(newValues);
204
- if (deleteKeys === null || deleteKeys === void 0 ? void 0 : deleteKeys.length) {
205
- deleteKeys === null || deleteKeys === void 0 ? void 0 : deleteKeys.forEach(function (key) {
206
- if ((values === null || values === void 0 ? void 0 : values[key]) || (values === null || values === void 0 ? void 0 : values[key]) === 0 || (values === null || values === void 0 ? void 0 : values[key]) === false) {
207
- delete newValues[key];
138
+ var QueryForm = /*#__PURE__*/function (_React$PureComponent) {
139
+ function QueryForm(props) {
140
+ var _this;
141
+ _classCallCheck(this, QueryForm);
142
+ _this = _callSuper(this, QueryForm, [props]);
143
+ Object.defineProperty(_this, "onWindowResize", {
144
+ enumerable: true,
145
+ configurable: true,
146
+ writable: true,
147
+ value: (0, _debounce2["default"])(function () {
148
+ var current = _this.fieldsRef.current;
149
+ if (current) {
150
+ setTimeout(function () {
151
+ _this.setState({
152
+ showMore: _this.isFieldsWidthOverflow()
153
+ });
154
+ }, 25);
208
155
  }
209
- });
210
- }
211
- formRef.current.setData('values', newValues);
212
- if (isReset) {
213
- return;
214
- } else if ((deleteKeys === null || deleteKeys === void 0 ? void 0 : deleteKeys.length) === 1) {
215
- // 删除一定要搜索
216
- if (onSearch) {
217
- onSearch(newValues, true);
218
- } else {
219
- onChange(newValues, {
220
- name: deleteKeys[0]
221
- });
156
+ }, 50)
157
+ });
158
+ Object.defineProperty(_this, "search", {
159
+ enumerable: true,
160
+ configurable: true,
161
+ writable: true,
162
+ value: function value(params) {
163
+ _this.props.onSearch(Object.assign(Object.assign({}, _this.form.getValues()), params));
222
164
  }
223
- } else if (needSearch && !hasOnChange) {
224
- formRef.current.emit('search', Object.assign(Object.assign({}, newValues), {
225
- current: 1
226
- }));
227
- } else if (onChange) {
228
- changeKeys.forEach(function (key) {
229
- if (JSON.stringify(value[key]) !== JSON.stringify(values[key])) {
230
- var changedInfo = {
231
- name: key,
232
- value: value[key],
233
- preValue: values === null || values === void 0 ? void 0 : values[key]
234
- };
235
- onChange(newValues, changedInfo);
236
- }
237
- });
238
- }
239
- };
240
- var _useMemo = (0, _react.useMemo)(function () {
241
- var _a;
242
- var groupFields = [];
243
- var outFields = [];
244
- var otherFields = [];
245
- var rightChildren = [];
246
- var compositionInitValues = {};
247
- _react["default"].Children.map(children, function (child) {
165
+ });
166
+ Object.defineProperty(_this, "onSearch", {
167
+ enumerable: true,
168
+ configurable: true,
169
+ writable: true,
170
+ value: function value() {
248
171
  var _a, _b;
249
- if (child) {
250
- if (((_a = child.props) === null || _a === void 0 ? void 0 : _a.align) === 'right') {
251
- rightChildren.push(child);
252
- return;
253
- } else if (((_b = child.props) === null || _b === void 0 ? void 0 : _b.isGroup) === false) {
254
- outFields.push(child);
255
- } else {
256
- groupFields.push(child);
257
- }
258
- otherFields.push(child);
172
+ (_b = (_a = _this.props).onSearch) === null || _b === void 0 ? void 0 : _b.call(_a, _this.form.getValues());
173
+ }
174
+ });
175
+ Object.defineProperty(_this, "onReset", {
176
+ enumerable: true,
177
+ configurable: true,
178
+ writable: true,
179
+ value: function value() {
180
+ var _this$props = _this.props,
181
+ initialValues = _this$props.initialValues,
182
+ onReset = _this$props.onReset;
183
+ _this.form.setValues(Object.assign({}, initialValues));
184
+ _this.updateDrawerFieldsValueCount();
185
+ onReset === null || onReset === void 0 ? void 0 : onReset(initialValues);
186
+ }
187
+ });
188
+ Object.defineProperty(_this, "onToggleExpand", {
189
+ enumerable: true,
190
+ configurable: true,
191
+ writable: true,
192
+ value: function value() {
193
+ var _a, _b;
194
+ _this.setState({
195
+ expanded: !_this.state.expanded
196
+ });
197
+ (_b = (_a = _this.props).onToggleExpand) === null || _b === void 0 ? void 0 : _b.call(_a, !_this.state.expanded);
198
+ }
199
+ });
200
+ Object.defineProperty(_this, "onShowDrawer", {
201
+ enumerable: true,
202
+ configurable: true,
203
+ writable: true,
204
+ value: function value() {
205
+ _this.setState({
206
+ drawerVisible: true
207
+ });
208
+ }
209
+ });
210
+ Object.defineProperty(_this, "onFieldChange", {
211
+ enumerable: true,
212
+ configurable: true,
213
+ writable: true,
214
+ value: function value(name, _value) {
215
+ var values = _this.form.getValues();
216
+ var newValues = Object.assign(Object.assign({}, values), _defineProperty({}, name, _value));
217
+ var changedInfo = {
218
+ name: name,
219
+ value: _value,
220
+ preValue: values === null || values === void 0 ? void 0 : values[name]
221
+ };
222
+ var onChange = _this.props.onChange;
223
+ _this.form.setData('values', newValues);
224
+ for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
225
+ rest[_key - 2] = arguments[_key];
259
226
  }
260
- });
261
- if (groupFields.length <= minGroupCount) {
262
- groupFields = [];
263
- outFields = otherFields;
264
- } else {
265
- // 初始值
266
- for (var i = 0; i < groupFields.length; i++) {
267
- var name = (_a = groupFields[i].props) === null || _a === void 0 ? void 0 : _a.name;
268
- if (initialValues[name] !== undefined) {
269
- compositionInitValues[name] = initialValues[name];
227
+ onChange && onChange.apply(void 0, [newValues, changedInfo].concat(rest));
228
+ _this.updateDrawerFieldsValueCount(newValues);
229
+ }
230
+ });
231
+ Object.defineProperty(_this, "updateDrawerFieldsValueCount", {
232
+ enumerable: true,
233
+ configurable: true,
234
+ writable: true,
235
+ value: function value() {
236
+ var values = _this.form.getValues();
237
+ var _this$props2 = _this.props,
238
+ showFieldCount = _this$props2.showFieldCount,
239
+ children = _this$props2.children;
240
+ if (showFieldCount) {
241
+ var drawerFieldsValueCount = children.reduce(function (acc, cur, index) {
242
+ var _a;
243
+ if (index >= showFieldCount && (values === null || values === void 0 ? void 0 : values[(_a = cur === null || cur === void 0 ? void 0 : cur.props) === null || _a === void 0 ? void 0 : _a.name])) {
244
+ acc++;
245
+ }
246
+ return acc;
247
+ }, 0);
248
+ if (drawerFieldsValueCount !== _this.state.drawerFieldsValueCount) {
249
+ _this.setState({
250
+ drawerFieldsValueCount: drawerFieldsValueCount
251
+ });
270
252
  }
271
253
  }
272
254
  }
273
- return [(0, _flatten2["default"])(groupFields.map(function (it) {
274
- if (it.props.type === 'selectInput') {
275
- var _ref2 = it.props || {},
276
- _name = _ref2.name,
277
- props = _ref2.props;
278
- var _ref3 = props || {},
279
- _ref3$options = _ref3.options,
280
- options = _ref3$options === void 0 ? [] : _ref3$options;
281
- return options.map(function (_ref4) {
282
- var label = _ref4.label,
283
- value = _ref4.value;
284
- return {
285
- props: {
286
- pName: _name,
287
- cName: value,
288
- name: "".concat(_name, ".").concat(value),
289
- title: label,
290
- type: 'otherInput',
291
- props: {}
292
- }
255
+ });
256
+ Object.defineProperty(_this, "addResizeListener", {
257
+ enumerable: true,
258
+ configurable: true,
259
+ writable: true,
260
+ value: function value() {
261
+ if ('ResizeObserver' in window) {
262
+ var current = _this.fieldsRef.current;
263
+ if (current) {
264
+ var observer = new ResizeObserver(_this.onWindowResize);
265
+ observer.observe(current);
266
+ return function () {
267
+ return observer.disconnect();
293
268
  };
294
- });
269
+ }
295
270
  } else {
296
- return it;
271
+ window.addEventListener('resize', _this.onWindowResize);
272
+ return function () {
273
+ return window.removeEventListener('resize', _this.onWindowResize);
274
+ };
297
275
  }
298
- })), outFields, rightChildren, Object.keys(compositionInitValues).length > 0 ? compositionInitValues : undefined];
299
- }, [children, minGroupCount, initialValues]),
300
- _useMemo2 = _slicedToArray(_useMemo, 4),
301
- groupFields = _useMemo2[0],
302
- outFields = _useMemo2[1],
303
- rightChildren = _useMemo2[2],
304
- compositionInitValues = _useMemo2[3];
305
- var isGroupMode = groupFields.length > 0;
306
- var hasOutField = outFields.length > 0;
307
- var showExtra = rightChildren.length > 0 || extraActions;
308
- console.log(groupFields);
309
- return _react["default"].createElement("div", {
310
- className: (0, _classnames["default"])(clsPrefix, className, _defineProperty({}, "".concat(clsPrefix, "-inline"), inline))
311
- }, _react["default"].createElement(_form["default"], {
312
- layout: "inline"
313
- }, _react["default"].createElement("div", {
314
- className: "".concat(clsPrefix, "-top")
315
- }, _react["default"].createElement("div", {
316
- className: "".concat(clsPrefix, "-top-body")
317
- }, outFields.map(function (child, i) {
318
- var _a;
319
- return _react["default"].cloneElement(child, {
320
- form: formRef.current,
321
- initialValue: initialValues === null || initialValues === void 0 ? void 0 : initialValues[(_a = child.props) === null || _a === void 0 ? void 0 : _a.name],
322
- onChange: _onFieldChange,
323
- key: i
276
+ }
324
277
  });
325
- }), isGroupMode && (!hasOutField || inline) && _react["default"].createElement(_Composition["default"], {
326
- clsPrefix: clsPrefix,
327
- fieldItems: groupFields,
328
- initialValues: compositionInitValues,
329
- _onReset: _onReset,
330
- _onSearch: _onSearch,
331
- onChange: _onCompositionFieldChange,
332
- form: formRef.current,
333
- compositionShowReset: compositionShowReset,
334
- defaultSearchField: defaultSearchField,
335
- defaultSearchPlaceholder: defaultSearchPlaceholder
336
- }), renderActions ? renderActions() : _react["default"].createElement(_react["default"].Fragment, null)), showExtra && _react["default"].createElement("div", {
337
- className: "".concat(clsPrefix, "-extra")
338
- }, rightChildren, extraActions)), isGroupMode && hasOutField && !inline && _react["default"].createElement("div", {
339
- className: "".concat(clsPrefix, "-bottom")
340
- }, _react["default"].createElement(_Composition["default"], {
341
- clsPrefix: clsPrefix,
342
- fieldItems: groupFields,
343
- initialValues: compositionInitValues,
344
- _onReset: _onReset,
345
- _onSearch: _onSearch,
346
- onChange: _onCompositionFieldChange,
347
- form: formRef.current,
348
- compositionShowReset: compositionShowReset,
349
- defaultSearchField: defaultSearchField,
350
- defaultSearchPlaceholder: defaultSearchPlaceholder
351
- }))));
352
- });
278
+ var form = props.form,
279
+ initialValues = props.initialValues,
280
+ _props$showExpand = props.showExpand,
281
+ showExpand = _props$showExpand === void 0 ? true : _props$showExpand,
282
+ renderActions = props.renderActions,
283
+ defaultExpanded = props.defaultExpanded;
284
+ _this.state = {
285
+ showMore: false,
286
+ expanded: defaultExpanded || !showExpand || renderActions ? true : false,
287
+ drawerVisible: false,
288
+ drawerFieldsValueCount: 0
289
+ };
290
+ _this.fieldsRef = (0, _react.createRef)();
291
+ _this.formBoxRef = (0, _react.createRef)();
292
+ _this.form = form || (0, _createActions["default"])();
293
+ _this.form.setData('initialValues', initialValues);
294
+ _this.form.setData('values', Object.assign({}, initialValues));
295
+ return _this;
296
+ }
297
+ _inherits(QueryForm, _React$PureComponent);
298
+ return _createClass(QueryForm, [{
299
+ key: "render",
300
+ value: function render() {
301
+ var _this2 = this;
302
+ var _this$props3 = this.props,
303
+ children = _this$props3.children,
304
+ _this$props3$classNam = _this$props3.className,
305
+ className = _this$props3$classNam === void 0 ? '' : _this$props3$classNam,
306
+ _this$props3$initialV = _this$props3.initialValues,
307
+ initialValues = _this$props3$initialV === void 0 ? {} : _this$props3$initialV,
308
+ renderActions = _this$props3.renderActions,
309
+ _this$props3$showSear = _this$props3.showSearch,
310
+ showSearch = _this$props3$showSear === void 0 ? true : _this$props3$showSear,
311
+ _this$props3$showRese = _this$props3.showReset,
312
+ showReset = _this$props3$showRese === void 0 ? true : _this$props3$showRese,
313
+ showFieldCount = _this$props3.showFieldCount,
314
+ _this$props3$drawerPr = _this$props3.drawerProps,
315
+ drawerProps = _this$props3$drawerPr === void 0 ? {} : _this$props3$drawerPr,
316
+ size = _this$props3.size;
317
+ var extraActions = this.props.extraActions;
318
+ var _this$state = this.state,
319
+ expanded = _this$state.expanded,
320
+ showMore = _this$state.showMore,
321
+ drawerVisible = _this$state.drawerVisible,
322
+ drawerFieldsValueCount = _this$state.drawerFieldsValueCount;
323
+ var renderFormActions = renderActions || function () {
324
+ return _react["default"].createElement(_react["default"].Fragment, null, showFieldCount && _react["default"].createElement(_badge["default"], {
325
+ count: drawerFieldsValueCount
326
+ }, _react["default"].createElement(_button["default"], {
327
+ onClick: _this2.onShowDrawer
328
+ }, _react["default"].createElement(_tntdIcon["default"], {
329
+ type: "filter"
330
+ }), _this2.getText('moreFiltering'))), showSearch && _react["default"].createElement(_button["default"], {
331
+ type: "primary",
332
+ onClick: _this2.onSearch
333
+ }, _this2.getText('search')), showReset && _react["default"].createElement(_button["default"], {
334
+ onClick: _this2.onReset
335
+ }, _this2.getText('reset')), showMore && !showFieldCount && _react["default"].createElement(_button["default"], {
336
+ className: "expand-link",
337
+ type: "link",
338
+ onClick: _this2.onToggleExpand
339
+ }, _this2.getText(expanded ? 'collapse' : 'expand')), _react["default"].Children.map(children, function (child) {
340
+ var _a;
341
+ return child && ((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.align) === 'right' && _react["default"].cloneElement(child);
342
+ }));
343
+ };
344
+ return _react["default"].createElement("div", {
345
+ ref: this.formBoxRef,
346
+ className: (0, _classnames3["default"])(clsPrefix, _defineProperty({}, className, className))
347
+ }, _react["default"].createElement(_form["default"], {
348
+ layout: "inline",
349
+ className: (0, _classnames3["default"])({
350
+ expanded: !showMore || expanded,
351
+ showMore: showMore
352
+ })
353
+ }, _react["default"].createElement("div", {
354
+ ref: this.fieldsRef
355
+ }, _react["default"].Children.map(children, function (child, index) {
356
+ var _a, _b;
357
+ return child && ((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.align) !== 'right' && (!showFieldCount || showFieldCount > index) && _react["default"].cloneElement(child, {
358
+ form: _this2.form,
359
+ initialValue: initialValues === null || initialValues === void 0 ? void 0 : initialValues[(_b = child.props) === null || _b === void 0 ? void 0 : _b.name],
360
+ onChange: _this2.onFieldChange
361
+ });
362
+ })), _react["default"].createElement("div", {
363
+ className: "".concat(clsPrefix, "-actions")
364
+ }, renderFormActions()), showFieldCount && _react["default"].createElement(_drawer["default"], Object.assign({
365
+ title: this.getText('moreFiltering'),
366
+ visible: drawerVisible,
367
+ onClose: function onClose() {
368
+ return _this2.setState({
369
+ drawerVisible: false
370
+ });
371
+ },
372
+ width: 300,
373
+ size: size,
374
+ getContainer: false
375
+ }, drawerProps, {
376
+ className: (0, _classnames3["default"])("".concat(clsPrefix, "-drawer"), _defineProperty({
377
+ 'large-size': size === 'large'
378
+ }, className, className))
379
+ }), _react["default"].Children.map(children, function (child, index) {
380
+ return child && index >= showFieldCount && _react["default"].cloneElement(child, {
381
+ form: _this2.form,
382
+ isFieldInDrawer: true,
383
+ initialValue: initialValues === null || initialValues === void 0 ? void 0 : initialValues[child.props.name],
384
+ onChange: _this2.onFieldChange,
385
+ onSearch: _this2.onSearch
386
+ });
387
+ }), _react["default"].createElement(_button["default"], {
388
+ type: "primary",
389
+ onClick: this.onSearch
390
+ }, this.getText('search')), _react["default"].createElement(_button["default"], {
391
+ onClick: this.onReset
392
+ }, this.getText('reset')))), extraActions && _react["default"].createElement("div", {
393
+ className: "".concat(clsPrefix, "-extra")
394
+ }, extraActions));
395
+ }
396
+ }, {
397
+ key: "getText",
398
+ value: function getText(key) {
399
+ return (0, _prevLocale.getText)(key, this.props.language || (0, _prevLocale.getLanguage)());
400
+ }
401
+ }, {
402
+ key: "isFieldsWidthOverflow",
403
+ value: function isFieldsWidthOverflow() {
404
+ var current = this.fieldsRef.current;
405
+ if (current) {
406
+ return parseFloat(window.getComputedStyle(current).width, 10) < [].reduce.call(current.children, function (acc, cur) {
407
+ var _window$getComputedSt = window.getComputedStyle(cur),
408
+ margin = _window$getComputedSt.margin,
409
+ width = _window$getComputedSt.width;
410
+ var marginArray = margin.split(' ').map(function (str) {
411
+ return parseFloat(str, 10);
412
+ });
413
+ acc += parseFloat(width, 10) + marginArray[1];
414
+ return acc;
415
+ }, 0);
416
+ }
417
+ return false;
418
+ }
419
+ }, {
420
+ key: "updateFieldHeight",
421
+ value: function updateFieldHeight() {
422
+ var _a, _b, _c;
423
+ var formBoxRef = this.formBoxRef,
424
+ fieldsRef = this.fieldsRef;
425
+ var getFieldHeight = function getFieldHeight() {
426
+ var _a;
427
+ var current = fieldsRef.current;
428
+ var height = '32px';
429
+ if (current && ((_a = current.children) === null || _a === void 0 ? void 0 : _a[0])) {
430
+ height = window.getComputedStyle(current.children[0]).height;
431
+ }
432
+ return height;
433
+ };
434
+ var queryFormActionsDom = (_a = formBoxRef === null || formBoxRef === void 0 ? void 0 : formBoxRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(".".concat(clsPrefix, "-actions"));
435
+ var queryFormExtraDom = (_b = formBoxRef === null || formBoxRef === void 0 ? void 0 : formBoxRef.current) === null || _b === void 0 ? void 0 : _b.querySelector(".".concat(clsPrefix, "-extra"));
436
+ var formItemsDomList = (_c = fieldsRef === null || fieldsRef === void 0 ? void 0 : fieldsRef.current) === null || _c === void 0 ? void 0 : _c.querySelectorAll('.ant-form-item-control');
437
+ var fieldHeight = getFieldHeight();
438
+ fieldsRef.current.style.height = fieldHeight;
439
+ [queryFormActionsDom, queryFormExtraDom].forEach(function (item) {
440
+ item && Object.assign(item.style, {
441
+ height: fieldHeight,
442
+ lineHeight: fieldHeight
443
+ });
444
+ });
445
+ [].forEach.call(formItemsDomList, function (item) {
446
+ item.style.lineHeight = fieldHeight;
447
+ });
448
+ }
449
+ }, {
450
+ key: "componentDidMount",
451
+ value: function componentDidMount() {
452
+ var current = this.fieldsRef.current;
453
+ var _this$props4 = this.props,
454
+ showFieldCount = _this$props4.showFieldCount,
455
+ _this$props4$showExpa = _this$props4.showExpand,
456
+ showExpand = _this$props4$showExpa === void 0 ? true : _this$props4$showExpa;
457
+ this.updateFieldHeight();
458
+ this.form.on('search', this.search);
459
+ // 未设置第一行显示数量且禁止了展开操作 或 自定义了操作区域,则不需要处理展开计算逻辑
460
+ // || renderActions
461
+ if (!showFieldCount && !showExpand) {
462
+ return;
463
+ }
464
+ if (!showFieldCount) {
465
+ if (current && this.isFieldsWidthOverflow()) {
466
+ this.setState({
467
+ showMore: true
468
+ });
469
+ }
470
+ this.removeResizeListener = this.addResizeListener();
471
+ } else {
472
+ this.updateDrawerFieldsValueCount();
473
+ this.form.on('setValues', this.updateDrawerFieldsValueCount);
474
+ this.form.on('setValue', this.updateDrawerFieldsValueCount);
475
+ }
476
+ }
477
+ }, {
478
+ key: "componentWillUnmount",
479
+ value: function componentWillUnmount() {
480
+ var _a;
481
+ (_a = this.removeResizeListener) === null || _a === void 0 ? void 0 : _a.call(this);
482
+ this.form.off('setValues', this.updateDrawerFieldsValueCount);
483
+ this.form.off('setValue', this.updateDrawerFieldsValueCount);
484
+ this.form.off('search', this.search);
485
+ }
486
+ }]);
487
+ }(_react["default"].PureComponent);
353
488
  QueryForm.Field = _Field["default"];
354
489
  QueryForm.useForm = _useForm["default"];
355
490
  QueryForm.createForm = _createActions["default"];