tntd 3.0.43-beta.1 → 3.0.43

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