tntd 3.0.19-beta.2 → 3.0.20

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