@hsu-react/ui 0.0.9 → 0.0.10

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 (74) hide show
  1. package/es/components/FormItem/ItemContainer/index.d.ts +2 -0
  2. package/es/components/FormItem/ItemContainer/index.js +4 -15
  3. package/es/components/Search/{_components → SearchAdvanced/_components}/AdvancedFiltersDrawer/index.d.ts +3 -3
  4. package/es/components/Search/{_components → SearchAdvanced/_components}/AdvancedFiltersDrawer/index.js +3 -3
  5. package/es/components/Search/SearchAdvanced/index.js +26 -148
  6. package/es/components/Search/SearchCard/index.js +1 -1
  7. package/es/components/Search/{_components → SearchCollapsible/_components}/CollapseToggle/index.js +2 -2
  8. package/es/components/Search/SearchCollapsible/index.js +17 -138
  9. package/es/components/Search/SearchWithFilter/index.js +4 -143
  10. package/es/components/Search/SearchWithMore/index.js +11 -142
  11. package/es/components/Search/_components/FilterDropdown/index.js +5 -6
  12. package/es/components/Search/_components/SearchBase/index.d.ts +32 -0
  13. package/es/components/Search/_components/SearchBase/index.js +185 -0
  14. package/es/components/Search/_hooks/useSearchCommon.js +5 -11
  15. package/es/components/Search/_hooks/useSearchExpand.js +4 -13
  16. package/es/components/Search/_utils/calculateButtonGroupAndColumnWidth.js +3 -10
  17. package/es/components/Search/_utils/calculateVisibleItems.js +4 -5
  18. package/es/components/Search/_utils/index.d.ts +2 -0
  19. package/es/components/Search/_utils/index.js +3 -1
  20. package/es/components/Search/_utils/measureButtonGroupWidth.d.ts +6 -0
  21. package/es/components/Search/_utils/measureButtonGroupWidth.js +18 -0
  22. package/es/components/Search/_utils/shouldDisplayExtraItem.d.ts +11 -0
  23. package/es/components/Search/_utils/shouldDisplayExtraItem.js +13 -0
  24. package/es/components/Search/index.d.ts +4 -0
  25. package/es/components/Search/index.js +6 -133
  26. package/es/components/Table/_hooks/useTableColumns.js +11 -0
  27. package/lib/components/FormItem/ItemContainer/index.d.ts +2 -0
  28. package/lib/components/FormItem/ItemContainer/index.js +2 -5
  29. package/lib/components/Search/{_components → SearchAdvanced/_components}/AdvancedFiltersDrawer/index.d.ts +3 -3
  30. package/lib/components/Search/{_components → SearchAdvanced/_components}/AdvancedFiltersDrawer/index.js +3 -3
  31. package/lib/components/Search/SearchAdvanced/index.js +19 -134
  32. package/lib/components/Search/SearchCard/index.js +1 -1
  33. package/lib/components/Search/{_components → SearchCollapsible/_components}/CollapseToggle/index.js +2 -2
  34. package/lib/components/Search/SearchCollapsible/index.js +12 -124
  35. package/lib/components/Search/SearchWithFilter/index.js +5 -129
  36. package/lib/components/Search/SearchWithMore/index.js +7 -126
  37. package/lib/components/Search/_components/FilterDropdown/index.js +5 -6
  38. package/lib/components/Search/_components/SearchBase/index.d.ts +32 -0
  39. package/lib/components/Search/_components/SearchBase/index.js +169 -0
  40. package/lib/components/Search/_hooks/useSearchCommon.js +4 -6
  41. package/lib/components/Search/_hooks/useSearchExpand.js +2 -13
  42. package/lib/components/Search/_utils/calculateButtonGroupAndColumnWidth.js +2 -10
  43. package/lib/components/Search/_utils/calculateVisibleItems.js +3 -5
  44. package/lib/components/Search/_utils/index.d.ts +2 -0
  45. package/lib/components/Search/_utils/index.js +15 -1
  46. package/lib/components/Search/_utils/measureButtonGroupWidth.d.ts +6 -0
  47. package/lib/components/Search/_utils/measureButtonGroupWidth.js +24 -0
  48. package/lib/components/Search/_utils/shouldDisplayExtraItem.d.ts +11 -0
  49. package/lib/components/Search/_utils/shouldDisplayExtraItem.js +19 -0
  50. package/lib/components/Search/index.d.ts +4 -0
  51. package/lib/components/Search/index.js +8 -119
  52. package/lib/components/Table/_hooks/useTableColumns.js +11 -0
  53. package/package.json +1 -1
  54. package/src/components/FormItem/ItemContainer/index.tsx +4 -7
  55. package/src/components/Search/{_components → SearchAdvanced/_components}/AdvancedFiltersDrawer/index.tsx +6 -6
  56. package/src/components/Search/SearchAdvanced/index.tsx +25 -164
  57. package/src/components/Search/SearchCard/index.tsx +1 -1
  58. package/src/components/Search/{_components → SearchCollapsible/_components}/CollapseToggle/index.tsx +2 -2
  59. package/src/components/Search/SearchCollapsible/index.tsx +13 -162
  60. package/src/components/Search/SearchWithFilter/index.tsx +2 -164
  61. package/src/components/Search/SearchWithMore/index.tsx +9 -161
  62. package/src/components/Search/_components/FilterDropdown/index.tsx +5 -6
  63. package/src/components/Search/_components/SearchBase/index.tsx +224 -0
  64. package/src/components/Search/_hooks/useSearchCommon.ts +10 -13
  65. package/src/components/Search/_hooks/useSearchExpand.ts +3 -13
  66. package/src/components/Search/_utils/calculateButtonGroupAndColumnWidth.ts +2 -10
  67. package/src/components/Search/_utils/calculateVisibleItems.ts +10 -11
  68. package/src/components/Search/_utils/index.ts +2 -0
  69. package/src/components/Search/_utils/measureButtonGroupWidth.ts +23 -0
  70. package/src/components/Search/_utils/shouldDisplayExtraItem.ts +23 -0
  71. package/src/components/Search/index.tsx +7 -153
  72. package/src/components/Table/_hooks/useTableColumns.tsx +17 -0
  73. /package/es/components/Search/{_components → SearchCollapsible/_components}/CollapseToggle/index.d.ts +0 -0
  74. /package/lib/components/Search/{_components → SearchCollapsible/_components}/CollapseToggle/index.d.ts +0 -0
@@ -35,6 +35,8 @@ export interface ItemContainerProps extends FormItemProps {
35
35
  labelBreak?: boolean;
36
36
  hideAdditiona?: boolean;
37
37
  hideLabel?: boolean;
38
+ /** 显隐开关,由 FormItem 消费;在此解构剥离,避免透传到 DOM */
39
+ visible?: boolean;
38
40
  }
39
41
  declare const ItemContainer: React.FC<ItemContainerProps>;
40
42
  export default ItemContainer;
@@ -1,16 +1,12 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["children", "className", "required", "rules", "name", "labelWidth", "labelHeight", "labelMinHeight", "inputWidth", "inputMinWidth", "inputHeight", "inputMinHeight", "height", "width", "style", "requiredMsg", "layout", "requiredPosition", "colon", "label", "labelRender", "tips", "horizontalAlignment", "hideRequired", "labelClassName", "en", "type", "hasPermi", "labelExtra", "labelExtraClassName", "labelEllipsis", "labelBreak", "hideAdditiona", "hideLabel"],
2
+ var _excluded = ["children", "className", "required", "rules", "name", "labelWidth", "labelHeight", "labelMinHeight", "inputWidth", "inputMinWidth", "inputHeight", "inputMinHeight", "height", "width", "style", "requiredMsg", "layout", "requiredPosition", "colon", "label", "labelRender", "tips", "horizontalAlignment", "hideRequired", "labelClassName", "en", "type", "hasPermi", "labelExtra", "labelExtraClassName", "labelEllipsis", "labelBreak", "hideAdditiona", "hideLabel", "visible"],
3
3
  _excluded2 = ["icon", "iconClassName"];
4
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
5
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
7
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
8
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
- 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."); }
10
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
9
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
- 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; } }
13
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
11
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
12
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -79,6 +75,7 @@ var ItemContainer = function ItemContainer(props) {
79
75
  hideAdditiona = _props$hideAdditiona === void 0 ? false : _props$hideAdditiona,
80
76
  _props$hideLabel = props.hideLabel,
81
77
  hideLabel = _props$hideLabel === void 0 ? false : _props$hideLabel,
78
+ _visible = props.visible,
82
79
  formItemProps = _objectWithoutProperties(props, _excluded);
83
80
  var _tips$icon = tips.icon,
84
81
  icon = _tips$icon === void 0 ? "material-symbols:help" : _tips$icon,
@@ -164,15 +161,7 @@ var ItemContainer = function ItemContainer(props) {
164
161
  if (!permitted) {
165
162
  return null;
166
163
  }
167
-
168
- // 页面层 FormItemProps 的展示控制属性(如 visible)不属于 antd Form.Item,
169
- // 剥离后再透传,避免被 antd 转发到 DOM 触发 React 非法属性警告。
170
- var restFormItemProps = Object.fromEntries(Object.entries(formItemProps).filter(function (_ref) {
171
- var _ref2 = _slicedToArray(_ref, 1),
172
- key = _ref2[0];
173
- return key !== "visible";
174
- }));
175
- return /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({}, restFormItemProps), {}, {
164
+ return /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({}, formItemProps), {}, {
176
165
  name: name,
177
166
  rules: [{
178
167
  required: required,
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
2
  import type { FormInstance } from "antd";
3
- import { FormItemProps } from "../../../FormItem";
4
- import { DrawerFormProps } from "../../../Form/DrawerForm";
5
- import type useLabelWidth from "../../../../hooks/useLabelWidth";
3
+ import { FormItemProps } from "../../../../FormItem";
4
+ import { DrawerFormProps } from "../../../../Form/DrawerForm";
5
+ import type useLabelWidth from "../../../../../hooks/useLabelWidth";
6
6
  interface AdvancedFiltersDrawerProps {
7
7
  expand: boolean;
8
8
  setExpand: (expand: boolean) => void;
@@ -5,10 +5,10 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  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); }
7
7
  import React from "react";
8
- import Form from "../../../Form";
8
+ import Form from "../../../../Form";
9
9
  import { FilterFilled } from "@ant-design/icons";
10
- import Icon from "../../../Icon";
11
- import styles from "../../index.module.scss";
10
+ import Icon from "../../../../Icon";
11
+ import styles from "../../../index.module.scss";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { jsxs as _jsxs } from "react/jsx-runtime";
14
14
  export var AdvancedFiltersDrawer = function AdvancedFiltersDrawer(_ref) {
@@ -1,30 +1,18 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["className", "advancedFiltersProps", "setFilter", "minLabelWidth"];
2
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
7
  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); }
7
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
- 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."); }
9
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
- 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; } }
12
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
13
10
  import React from "react";
14
- import { Form as AntdForm } from "antd";
15
- import FormItem from "../../FormItem";
16
11
  import classNames from "classnames";
17
12
  import styles from "../index.module.scss";
18
- import { useSearchCommon } from "../_hooks";
19
- import { ButtonGroup } from "../_components/ButtonGroup";
20
- import { SearchButtons } from "../_components/SearchButtons";
21
- import { FilterDropdown } from "../_components/FilterDropdown";
22
- import { ExpandButton } from "../_components/ExpandButton";
23
- import { AdvancedFiltersDrawer } from "../_components/AdvancedFiltersDrawer";
24
- import { createElement as _createElement } from "react";
13
+ import SearchBase from "../_components/SearchBase";
14
+ import { AdvancedFiltersDrawer } from "./_components/AdvancedFiltersDrawer";
25
15
  import { jsx as _jsx } from "react/jsx-runtime";
26
- import { jsxs as _jsxs } from "react/jsx-runtime";
27
- import { Fragment as _Fragment } from "react/jsx-runtime";
28
16
  /**
29
17
  * 高级筛选模式的 Search 组件
30
18
  * - 不显示标签(label)
@@ -32,139 +20,29 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
32
20
  * - 更适合复杂的筛选场景
33
21
  */
34
22
  var SearchAdvanced = function SearchAdvanced(props) {
35
- var _props$searchItems = props.searchItems,
36
- searchItems = _props$searchItems === void 0 ? [] : _props$searchItems,
37
- _props$moreSearchItem = props.moreSearchItems,
38
- moreSearchItems = _props$moreSearchItem === void 0 ? [] : _props$moreSearchItem,
39
- className = props.className,
40
- onSearch = props.onSearch,
41
- onReset = props.onReset,
42
- externalForm = props.externalForm,
43
- hasPermi = props.hasPermi,
44
- _props$columnNum = props.columnNum,
45
- columnNum = _props$columnNum === void 0 ? 4 : _props$columnNum,
46
- beforeButtonGroup = props.beforeButtonGroup,
47
- affterButtonGroup = props.affterButtonGroup,
48
- searchData = props.searchData,
23
+ var className = props.className,
49
24
  advancedFiltersProps = props.advancedFiltersProps,
50
25
  setFilter = props.setFilter,
51
26
  minLabelWidth = props.minLabelWidth,
52
- _props$defaultExpande = props.defaultExpanded,
53
- defaultExpanded = _props$defaultExpande === void 0 ? false : _props$defaultExpande,
54
- onExpandChange = props.onExpandChange,
55
- _props$autoAdaptWidth = props.autoAdaptWidth,
56
- autoAdaptWidth = _props$autoAdaptWidth === void 0 ? true : _props$autoAdaptWidth,
57
- baseWidth = props.baseWidth,
58
- onValuesChange = props.onValuesChange,
59
- _props$searchDisabled = props.searchDisabled,
60
- searchDisabled = _props$searchDisabled === void 0 ? false : _props$searchDisabled,
61
- _props$showAllSearchI = props.showAllSearchItems,
62
- showAllSearchItems = _props$showAllSearchI === void 0 ? false : _props$showAllSearchI,
63
- searchText = props.searchText,
64
- resetText = props.resetText,
65
- onFilterChange = props.onFilterChange,
66
- _props$columnOffsetWi = props.columnOffsetWidth,
67
- columnOffsetWidth = _props$columnOffsetWi === void 0 ? 0 : _props$columnOffsetWi;
68
- var _AntdForm$useForm = AntdForm.useForm(externalForm),
69
- _AntdForm$useForm2 = _slicedToArray(_AntdForm$useForm, 1),
70
- form = _AntdForm$useForm2[0];
71
- var _useSearchCommon = useSearchCommon({
72
- form: form,
73
- searchItems: searchItems,
74
- moreSearchItems: moreSearchItems,
75
- searchData: searchData,
76
- hasPermi: hasPermi,
77
- beforeButtonGroup: beforeButtonGroup,
78
- affterButtonGroup: affterButtonGroup,
79
- columnNum: columnNum,
80
- autoAdaptWidth: autoAdaptWidth,
81
- defaultExpanded: defaultExpanded,
82
- onExpandChange: onExpandChange,
83
- showAllSearchItems: showAllSearchItems,
84
- minLabelWidth: minLabelWidth,
85
- baseWidth: baseWidth,
86
- onSearch: onSearch,
87
- onReset: onReset,
88
- columnOffsetWidth: columnOffsetWidth
89
- }),
90
- containerRef = _useSearchCommon.containerRef,
91
- buttonGroupRef = _useSearchCommon.buttonGroupRef,
92
- cls = _useSearchCommon.cls,
93
- getLabelWidth = _useSearchCommon.getLabelWidth,
94
- processedSearchItems = _useSearchCommon.processedSearchItems,
95
- setSearchItems = _useSearchCommon.setSearchItems,
96
- currentSearchItems = _useSearchCommon.currentSearchItems,
97
- totalColumnNum = _useSearchCommon.totalColumnNum,
98
- expand = _useSearchCommon.expand,
99
- setExpand = _useSearchCommon.setExpand,
100
- toggleExpand = _useSearchCommon.toggleExpand,
101
- showExpandButton = _useSearchCommon.showExpandButton,
102
- onSearchClick = _useSearchCommon.onSearchClick,
103
- onResetClick = _useSearchCommon.onResetClick,
104
- shouldRender = _useSearchCommon.shouldRender,
105
- permitted = _useSearchCommon.permitted;
106
- if (!shouldRender) {
107
- return null;
108
- }
109
- return /*#__PURE__*/_jsxs(_Fragment, {
110
- children: [/*#__PURE__*/_jsx("div", {
111
- ref: containerRef,
112
- className: classNames(styles.Search, className, _defineProperty({}, styles.advancedFilters, true)),
113
- style: {
114
- "--column-number": totalColumnNum,
115
- "--column-offset-width": "".concat(columnOffsetWidth, "px")
116
- },
117
- children: /*#__PURE__*/_jsx("div", {
118
- className: classNames(styles.searchOption, styles[expand.toString()]),
119
- children: /*#__PURE__*/_jsxs(AntdForm, {
120
- form: form,
121
- className: classNames(styles.option, cls),
122
- onValuesChange: onValuesChange,
123
- children: [permitted && (currentSearchItems === null || currentSearchItems === void 0 ? void 0 : currentSearchItems.map(function (item) {
124
- return /*#__PURE__*/_createElement(FormItem, _objectSpread(_objectSpread({}, item), {}, {
125
- key: item.name,
126
- className: classNames(styles.item, item.className, _defineProperty({}, styles.unFill, item.width !== undefined)),
127
- label: undefined,
128
- labelWidth: undefined
129
- }));
130
- })), ((beforeButtonGroup === null || beforeButtonGroup === void 0 ? void 0 : beforeButtonGroup.length) || (affterButtonGroup === null || affterButtonGroup === void 0 ? void 0 : affterButtonGroup.length) || permitted) && /*#__PURE__*/_jsxs(ButtonGroup, {
131
- beforeButtonGroup: beforeButtonGroup,
132
- affterButtonGroup: affterButtonGroup,
133
- expandButton: /*#__PURE__*/_jsx(ExpandButton, {
134
- expand: expand,
135
- toggleExpand: toggleExpand,
136
- advancedFilters: true,
137
- showExpandButton: showExpandButton,
138
- showAllSearchItems: showAllSearchItems || !!(moreSearchItems !== null && moreSearchItems !== void 0 && moreSearchItems.length)
139
- }),
140
- permitted: permitted,
141
- ref: buttonGroupRef,
142
- children: [currentSearchItems.length > 0 && /*#__PURE__*/_jsx(SearchButtons, {
143
- onSearch: onSearchClick,
144
- onReset: onResetClick,
145
- searchDisabled: searchDisabled,
146
- searchText: searchText,
147
- resetText: resetText
148
- }), setFilter && /*#__PURE__*/_jsx(FilterDropdown, {
149
- searchItems: processedSearchItems,
150
- originalSearchItems: searchItems,
151
- setSearchItems: setSearchItems,
152
- onFilterChange: onFilterChange
153
- })]
154
- })]
155
- })
156
- })
157
- }), permitted && setExpand && /*#__PURE__*/_jsx(AdvancedFiltersDrawer, {
158
- expand: expand,
159
- setExpand: setExpand,
160
- searchItems: processedSearchItems,
161
- form: form,
162
- getLabelWidth: getLabelWidth,
163
- minLabelWidth: minLabelWidth,
164
- onSearchClick: onSearchClick,
165
- onResetClick: onResetClick,
166
- advancedFiltersProps: advancedFiltersProps
167
- })]
168
- });
27
+ rest = _objectWithoutProperties(props, _excluded);
28
+ return /*#__PURE__*/_jsx(SearchBase, _objectSpread(_objectSpread({}, rest), {}, {
29
+ minLabelWidth: minLabelWidth,
30
+ advancedFilters: true,
31
+ showFilter: !!setFilter,
32
+ className: classNames(className, styles.advancedFilters),
33
+ renderOutside: function renderOutside(ctx) {
34
+ return ctx.setExpand && /*#__PURE__*/_jsx(AdvancedFiltersDrawer, {
35
+ expand: ctx.expand,
36
+ setExpand: ctx.setExpand,
37
+ searchItems: ctx.processedSearchItems,
38
+ form: ctx.form,
39
+ getLabelWidth: ctx.getLabelWidth,
40
+ minLabelWidth: minLabelWidth,
41
+ onSearchClick: ctx.onSearchClick,
42
+ onResetClick: ctx.onResetClick,
43
+ advancedFiltersProps: advancedFiltersProps
44
+ });
45
+ }
46
+ }));
169
47
  };
170
48
  export default SearchAdvanced;
@@ -66,7 +66,7 @@ var SearchCard = /*#__PURE__*/memo(function (props) {
66
66
  className: classNames(styles.SearchCard, className, _defineProperty(_defineProperty({}, styles.collapse, collapse), styles.legacyHasSearchBox, legacyHasSelector && showSearchBox)),
67
67
  style: {
68
68
  "--searchCard-column-gap": "".concat(gap, "px"),
69
- " --searchCard-padding-left-right": "".concat(padding, "px")
69
+ "--searchCard-padding-left-right": "".concat(padding, "px")
70
70
  },
71
71
  children: [showSearchBox && /*#__PURE__*/_jsx(SearchBox, {
72
72
  value: internalValue,
@@ -3,9 +3,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
3
3
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
4
  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); }
5
5
  import React from "react";
6
- import Icon from "../../../Icon";
6
+ import Icon from "../../../../Icon";
7
7
  import classNames from "classnames";
8
- import styles from "../../index.module.scss";
8
+ import styles from "../../../index.module.scss";
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  export var CollapseToggle = function CollapseToggle(_ref) {
11
11
  var collapse = _ref.collapse,
@@ -1,4 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["className", "defaultExpanded", "onCollapseToggle", "setFilter"];
2
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -10,21 +11,14 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
10
11
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
12
  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; } }
12
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- import React from "react";
14
- import { Form as AntdForm } from "antd";
15
- import FormItem from "../../FormItem";
16
- import { useCallback, useState } from "react";
14
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
+ import React, { useCallback, useState } from "react";
17
17
  import classNames from "classnames";
18
18
  import styles from "../index.module.scss";
19
- import { useSearchCommon } from "../_hooks";
20
- import { ButtonGroup } from "../_components/ButtonGroup";
21
- import { SearchButtons } from "../_components/SearchButtons";
22
- import { FilterDropdown } from "../_components/FilterDropdown";
23
- import { ExpandButton } from "../_components/ExpandButton";
24
- import { CollapseToggle } from "../_components/CollapseToggle";
25
- import { createElement as _createElement } from "react";
19
+ import SearchBase from "../_components/SearchBase";
20
+ import { CollapseToggle } from "./_components/CollapseToggle";
26
21
  import { jsx as _jsx } from "react/jsx-runtime";
27
- import { jsxs as _jsxs } from "react/jsx-runtime";
28
22
  /**
29
23
  * 可折叠模式的 Search 组件
30
24
  * - 可以完全折叠/展开整个搜索区域
@@ -32,81 +26,18 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
32
26
  * - 适合需要隐藏搜索栏以获得更多展示空间的场景
33
27
  */
34
28
  var SearchCollapsible = function SearchCollapsible(props) {
35
- var _props$searchItems = props.searchItems,
36
- searchItems = _props$searchItems === void 0 ? [] : _props$searchItems,
37
- _props$moreSearchItem = props.moreSearchItems,
38
- moreSearchItems = _props$moreSearchItem === void 0 ? [] : _props$moreSearchItem,
39
- className = props.className,
40
- onSearch = props.onSearch,
41
- onReset = props.onReset,
42
- externalForm = props.externalForm,
43
- hasPermi = props.hasPermi,
44
- _props$columnNum = props.columnNum,
45
- columnNum = _props$columnNum === void 0 ? 4 : _props$columnNum,
46
- beforeButtonGroup = props.beforeButtonGroup,
47
- affterButtonGroup = props.affterButtonGroup,
48
- searchData = props.searchData,
49
- setFilter = props.setFilter,
50
- minLabelWidth = props.minLabelWidth,
29
+ var className = props.className,
51
30
  _props$defaultExpande = props.defaultExpanded,
52
31
  defaultExpanded = _props$defaultExpande === void 0 ? false : _props$defaultExpande,
53
32
  onCollapseToggle = props.onCollapseToggle,
54
- onExpandChange = props.onExpandChange,
55
- _props$autoAdaptWidth = props.autoAdaptWidth,
56
- autoAdaptWidth = _props$autoAdaptWidth === void 0 ? true : _props$autoAdaptWidth,
57
- baseWidth = props.baseWidth,
58
- onValuesChange = props.onValuesChange,
59
- _props$searchDisabled = props.searchDisabled,
60
- searchDisabled = _props$searchDisabled === void 0 ? false : _props$searchDisabled,
61
- _props$showAllSearchI = props.showAllSearchItems,
62
- showAllSearchItems = _props$showAllSearchI === void 0 ? false : _props$showAllSearchI,
63
- searchText = props.searchText,
64
- resetText = props.resetText,
65
- onFilterChange = props.onFilterChange,
66
- _props$columnOffsetWi = props.columnOffsetWidth,
67
- columnOffsetWidth = _props$columnOffsetWi === void 0 ? 0 : _props$columnOffsetWi;
68
- var _AntdForm$useForm = AntdForm.useForm(externalForm),
69
- _AntdForm$useForm2 = _slicedToArray(_AntdForm$useForm, 1),
70
- form = _AntdForm$useForm2[0];
33
+ setFilter = props.setFilter,
34
+ rest = _objectWithoutProperties(props, _excluded);
35
+
71
36
  // collapse 的语义是反的,所以需要取反 defaultExpanded
72
37
  var _useState = useState(!defaultExpanded),
73
38
  _useState2 = _slicedToArray(_useState, 2),
74
39
  collapse = _useState2[0],
75
40
  setCollapse = _useState2[1];
76
- var _useSearchCommon = useSearchCommon({
77
- form: form,
78
- searchItems: searchItems,
79
- moreSearchItems: moreSearchItems,
80
- searchData: searchData,
81
- hasPermi: hasPermi,
82
- beforeButtonGroup: beforeButtonGroup,
83
- affterButtonGroup: affterButtonGroup,
84
- columnNum: columnNum,
85
- autoAdaptWidth: autoAdaptWidth,
86
- defaultExpanded: defaultExpanded,
87
- onExpandChange: onExpandChange,
88
- showAllSearchItems: showAllSearchItems,
89
- minLabelWidth: minLabelWidth,
90
- baseWidth: baseWidth,
91
- onSearch: onSearch,
92
- onReset: onReset,
93
- columnOffsetWidth: columnOffsetWidth
94
- }),
95
- containerRef = _useSearchCommon.containerRef,
96
- buttonGroupRef = _useSearchCommon.buttonGroupRef,
97
- cls = _useSearchCommon.cls,
98
- getLabelWidth = _useSearchCommon.getLabelWidth,
99
- processedSearchItems = _useSearchCommon.processedSearchItems,
100
- setSearchItems = _useSearchCommon.setSearchItems,
101
- currentSearchItems = _useSearchCommon.currentSearchItems,
102
- totalColumnNum = _useSearchCommon.totalColumnNum,
103
- expand = _useSearchCommon.expand,
104
- toggleExpand = _useSearchCommon.toggleExpand,
105
- showExpandButton = _useSearchCommon.showExpandButton,
106
- onSearchClick = _useSearchCommon.onSearchClick,
107
- onResetClick = _useSearchCommon.onResetClick,
108
- shouldRender = _useSearchCommon.shouldRender,
109
- permitted = _useSearchCommon.permitted;
110
41
 
111
42
  // 处理折叠切换
112
43
  var handleCollapseToggle = useCallback(function () {
@@ -116,66 +47,14 @@ var SearchCollapsible = function SearchCollapsible(props) {
116
47
  return newCollapse;
117
48
  });
118
49
  }, [onCollapseToggle]);
119
- if (!shouldRender) {
120
- return null;
121
- }
122
- return /*#__PURE__*/_jsxs("div", {
123
- ref: containerRef,
124
- className: classNames(styles.Search, className, _defineProperty(_defineProperty({}, styles.collapseExpand, true), styles.collapse, collapse)),
125
- style: {
126
- "--column-number": totalColumnNum,
127
- "--column-offset-width": "".concat(columnOffsetWidth, "px")
128
- },
129
- children: [/*#__PURE__*/_jsx("div", {
130
- className: classNames(styles.searchOption, styles[expand.toString()]),
131
- children: /*#__PURE__*/_jsxs(AntdForm, {
132
- form: form,
133
- className: classNames(styles.option, cls),
134
- onValuesChange: onValuesChange,
135
- children: [permitted && (currentSearchItems === null || currentSearchItems === void 0 ? void 0 : currentSearchItems.map(function (item, idx) {
136
- // 计算同一列的项(用于计算标签宽度)
137
- var visibleCurrentItems = currentSearchItems.filter(function (i) {
138
- return i.visible !== false;
139
- });
140
- var columnIndex = idx % totalColumnNum;
141
- var sameColumnItems = visibleCurrentItems.filter(function (_, _idx) {
142
- return _idx % totalColumnNum === columnIndex;
143
- });
144
- return /*#__PURE__*/_createElement(FormItem, _objectSpread(_objectSpread({}, item), {}, {
145
- key: item.name,
146
- className: classNames(styles.item, item.className, _defineProperty({}, styles.unFill, item.width !== undefined)),
147
- labelWidth: item.width !== undefined ? undefined : getLabelWidth(sameColumnItems, undefined, minLabelWidth)
148
- }));
149
- })), ((beforeButtonGroup === null || beforeButtonGroup === void 0 ? void 0 : beforeButtonGroup.length) || (affterButtonGroup === null || affterButtonGroup === void 0 ? void 0 : affterButtonGroup.length) || permitted) && /*#__PURE__*/_jsxs(ButtonGroup, {
150
- beforeButtonGroup: beforeButtonGroup,
151
- affterButtonGroup: affterButtonGroup,
152
- expandButton: /*#__PURE__*/_jsx(ExpandButton, {
153
- expand: expand,
154
- toggleExpand: toggleExpand,
155
- advancedFilters: false,
156
- showExpandButton: showExpandButton,
157
- showAllSearchItems: showAllSearchItems || !!(moreSearchItems !== null && moreSearchItems !== void 0 && moreSearchItems.length)
158
- }),
159
- permitted: permitted,
160
- ref: buttonGroupRef,
161
- children: [currentSearchItems.length > 0 && /*#__PURE__*/_jsx(SearchButtons, {
162
- onSearch: onSearchClick,
163
- onReset: onResetClick,
164
- searchDisabled: searchDisabled,
165
- searchText: searchText,
166
- resetText: resetText
167
- }), setFilter && /*#__PURE__*/_jsx(FilterDropdown, {
168
- searchItems: processedSearchItems,
169
- originalSearchItems: searchItems,
170
- setSearchItems: setSearchItems,
171
- onFilterChange: onFilterChange
172
- })]
173
- })]
174
- })
175
- }), permitted && /*#__PURE__*/_jsx(CollapseToggle, {
50
+ return /*#__PURE__*/_jsx(SearchBase, _objectSpread(_objectSpread({}, rest), {}, {
51
+ defaultExpanded: defaultExpanded,
52
+ showFilter: !!setFilter,
53
+ className: classNames(className, styles.collapseExpand, _defineProperty({}, styles.collapse, collapse)),
54
+ afterForm: /*#__PURE__*/_jsx(CollapseToggle, {
176
55
  collapse: collapse,
177
56
  onToggle: handleCollapseToggle
178
- })]
179
- });
57
+ })
58
+ }));
180
59
  };
181
60
  export default SearchCollapsible;