@arim-aisdc/public-components 2.2.8-alpha.0 → 2.2.8-alpha.1

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.
@@ -251,7 +251,9 @@ var Filter = function Filter(_ref) {
251
251
  onChange: handleChangeFilterValue,
252
252
  onSearch: onSearch,
253
253
  options: options,
254
- isRemoteSearch: !!getFilterOptionsFn
254
+ isRemoteSearch: !!getFilterOptionsFn,
255
+ onCloseFilterPanel: onCloseFilterPanel,
256
+ loading: apiLoading
255
257
  });
256
258
  case FilterType.MultiSelect:
257
259
  default:
@@ -1,7 +1,7 @@
1
1
  .tableMax-filter-multipleSelect {
2
2
  width: 212px;
3
3
  .header {
4
- border-bottom: 1px solid #d9d9d9;
4
+ border-bottom: 1px solid @tableColor7;
5
5
  padding: 8px 12px;
6
6
  }
7
7
  .body {
@@ -24,7 +24,7 @@
24
24
  }
25
25
  }
26
26
  .footer {
27
- border-top: 1px solid #d9d9d9;
27
+ border-top: 1px solid @tableColor7;
28
28
  padding: 8px 12px;
29
29
  display: flex;
30
30
  justify-content: space-between;
@@ -1,10 +1,12 @@
1
1
  import './index.less';
2
2
  interface IProps {
3
- value: string;
3
+ value: string | number | undefined;
4
4
  options: any[];
5
- onChange: (value: string) => void;
5
+ onChange: (value: string | number | undefined) => void;
6
6
  onSearch: (value: string) => void;
7
7
  isRemoteSearch: boolean;
8
+ loading: boolean;
9
+ onCloseFilterPanel: () => void;
8
10
  }
9
- declare const SingleSelect: ({ value, onChange, options, onSearch, isRemoteSearch }: IProps) => import("react/jsx-runtime").JSX.Element;
11
+ declare const SingleSelect: ({ value, onChange, options, onSearch, isRemoteSearch, loading, onCloseFilterPanel, }: IProps) => import("react/jsx-runtime").JSX.Element;
10
12
  export default SingleSelect;
@@ -1,32 +1,107 @@
1
- import { Select } from 'antd';
2
- import { filterOptions } from "../../../utils";
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { useUpdateEffect } from 'ahooks';
8
+ import { Button, Input, Spin } from 'antd';
9
+ import { useMemo, useState } from 'react';
3
10
  import "./index.less";
4
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
5
13
  var SingleSelect = function SingleSelect(_ref) {
6
- var value = _ref.value,
14
+ var _ref$value = _ref.value,
15
+ value = _ref$value === void 0 ? undefined : _ref$value,
7
16
  onChange = _ref.onChange,
8
17
  options = _ref.options,
9
18
  onSearch = _ref.onSearch,
10
- isRemoteSearch = _ref.isRemoteSearch;
11
- var handleClear = function handleClear() {
12
- onChange('');
19
+ isRemoteSearch = _ref.isRemoteSearch,
20
+ loading = _ref.loading,
21
+ onCloseFilterPanel = _ref.onCloseFilterPanel;
22
+ // 内部state
23
+ var _useState = useState(value),
24
+ _useState2 = _slicedToArray(_useState, 2),
25
+ innerValue = _useState2[0],
26
+ setInnerValue = _useState2[1];
27
+
28
+ // 前端搜索输入值
29
+ var _useState3 = useState(''),
30
+ _useState4 = _slicedToArray(_useState3, 2),
31
+ frontendSearchValue = _useState4[0],
32
+ setFrontendSearchValue = _useState4[1];
33
+ var handleClick = function handleClick(changedValue) {
34
+ console.log('changedValue :>> ', changedValue);
35
+ setInnerValue(changedValue);
13
36
  };
14
- return /*#__PURE__*/_jsx("div", {
37
+ var handleConfirm = function handleConfirm() {
38
+ onChange(innerValue);
39
+ onCloseFilterPanel();
40
+ };
41
+ var handleReset = function handleReset() {
42
+ setInnerValue(undefined);
43
+ onChange(undefined);
44
+ };
45
+ useUpdateEffect(function () {
46
+ // console.log('value :>> ', value);
47
+ setInnerValue(value);
48
+ }, [value]);
49
+ var handleInputChange = function handleInputChange(e) {
50
+ var value = e.target.value;
51
+ if (isRemoteSearch) {
52
+ onSearch(value);
53
+ } else {
54
+ setFrontendSearchValue(value);
55
+ }
56
+ };
57
+
58
+ // 最终的可选值
59
+ var finalOptions = useMemo(function () {
60
+ if (isRemoteSearch) {
61
+ return options;
62
+ }
63
+ var input = (frontendSearchValue !== null && frontendSearchValue !== void 0 ? frontendSearchValue : '').toUpperCase().trim();
64
+ return options.filter(function (option) {
65
+ var _option$label;
66
+ var optionFilterString = ('' + ((_option$label = option.label) !== null && _option$label !== void 0 ? _option$label : option.children)).toUpperCase().trim();
67
+ return optionFilterString.indexOf(input) !== -1;
68
+ });
69
+ }, [options, frontendSearchValue]);
70
+ return /*#__PURE__*/_jsxs("div", {
15
71
  className: "tableMax-filter-singleSelect",
16
- children: /*#__PURE__*/_jsx(Select, {
17
- showSearch: true,
18
- allowClear: true,
19
- value: value,
20
- suffixIcon: null,
21
- options: options,
22
- onChange: onChange,
23
- onClear: handleClear,
24
- onSearch: onSearch,
25
- style: {
26
- width: '100%'
27
- },
28
- filterOption: isRemoteSearch ? false : filterOptions
29
- })
72
+ children: [/*#__PURE__*/_jsx("div", {
73
+ className: "header",
74
+ children: /*#__PURE__*/_jsx(Input, {
75
+ placeholder: "\u8F93\u5165\u641C\u7D22",
76
+ onChange: handleInputChange
77
+ })
78
+ }), /*#__PURE__*/_jsx("div", {
79
+ className: "body",
80
+ children: loading ? /*#__PURE__*/_jsx("div", {
81
+ className: "loading",
82
+ children: /*#__PURE__*/_jsx(Spin, {})
83
+ }) : finalOptions.map(function (option) {
84
+ var _option$label2;
85
+ return /*#__PURE__*/_jsx("div", {
86
+ className: "item ".concat(innerValue === option.value ? 'selected' : ''),
87
+ onClick: function onClick() {
88
+ return handleClick(option.value);
89
+ },
90
+ children: (_option$label2 = option.label) !== null && _option$label2 !== void 0 ? _option$label2 : option.children
91
+ }, option.value);
92
+ })
93
+ }), /*#__PURE__*/_jsxs("div", {
94
+ className: "footer",
95
+ children: [/*#__PURE__*/_jsx(Button, {
96
+ type: "text",
97
+ onClick: handleReset,
98
+ children: "\u91CD\u7F6E"
99
+ }), /*#__PURE__*/_jsx(Button, {
100
+ type: "primary",
101
+ onClick: handleConfirm,
102
+ children: "\u786E\u5B9A"
103
+ })]
104
+ })]
30
105
  });
31
106
  };
32
107
  export default SingleSelect;
@@ -1,9 +1,43 @@
1
1
  .tableMax-filter-singleSelect {
2
- width: 188px;
3
- border-radius: 2px;
4
- overflow: hidden;
5
- padding: 8px 12px;
6
- .ant-select-selection-item {
7
- flex: none !important;
2
+ box-sizing: border-box;
3
+ width: 212px;
4
+ .header {
5
+ border-bottom: 1px solid @tableColor7;
6
+ padding: 8px 12px;
7
+ }
8
+ .body {
9
+ height: 220px;
10
+ overflow-y: auto;
11
+ padding: 4px 12px;
12
+ .loading {
13
+ height: 100%;
14
+ width: 100%;
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ }
19
+ .item {
20
+ padding: 2px 4px;
21
+ cursor: pointer;
22
+ border-radius: 2px;
23
+ height: 20px;
24
+ font-size: 14px;
25
+ line-height: 20px;
26
+ white-space: nowrap;
27
+ overflow: hidden;
28
+ text-overflow: ellipsis;
29
+ }
30
+ .item:hover {
31
+ background-color: @tableColor8;
32
+ }
33
+ .selected {
34
+ background-color: @tableColor8;
35
+ }
36
+ }
37
+ .footer {
38
+ border-top: 1px solid @tableColor7;
39
+ padding: 8px 12px;
40
+ display: flex;
41
+ justify-content: space-between;
8
42
  }
9
43
  }
@@ -71,6 +71,7 @@ export function ColumnFilter(_ref) {
71
71
  // 点击空白处关闭弹层
72
72
  useEffect(function () {
73
73
  var clickHandler = function clickHandler() {
74
+ // console.log('close :>> ');
74
75
  setFilterPanelVisible(false);
75
76
  };
76
77
  if (filterPanelVisible) {
@@ -99,12 +100,12 @@ export function ColumnFilter(_ref) {
99
100
  filterPanelWrapperRef.current.style.top = "".concat(top - height - btnHeight, "px");
100
101
  }
101
102
  // 处理左右位置
102
- if (right > window.innerWidth && left >= width) {
103
+ if (right > window.innerWidth) {
103
104
  // 如果弹层右侧被遮挡,不能完整展示 & 左侧可完整展示弹层 就把弹层展示到设置按钮左侧
104
- filterPanelWrapperRef.current.style.right = "0px";
105
- } else if (left < 0 && right >= width) {
105
+ filterPanelWrapperRef.current.style.left = "".concat(window.innerWidth - 10, "px");
106
+ } else if (left < 0) {
106
107
  // 如果弹层在设置按钮左侧被遮挡,不能完整展示,将弹层向右移动
107
- filterPanelWrapperRef.current.style.left = "0px";
108
+ filterPanelWrapperRef.current.style.left = "".concat(width + 10, "px");
108
109
  }
109
110
  }
110
111
  }, [filterPanelVisible]);
@@ -117,17 +118,16 @@ export function ColumnFilter(_ref) {
117
118
  configRectBottom = _ref2.bottom;
118
119
  setColumnConfigStyle({
119
120
  left: configRectRight,
120
- top: configRectBottom
121
+ top: configRectBottom + 9
121
122
  });
122
- setFilterPanelVisible(!filterPanelVisible);
123
+ setTimeout(function () {
124
+ setFilterPanelVisible(!filterPanelVisible);
125
+ }, 0);
123
126
  };
124
127
  var handleClosePanel = useCallback(function () {
125
128
  setFilterPanelVisible(false);
126
129
  }, []);
127
130
  return /*#__PURE__*/_jsxs("div", {
128
- onClick: function onClick(e) {
129
- return e.stopPropagation();
130
- },
131
131
  children: [/*#__PURE__*/_jsx("i", {
132
132
  className: "iconfont-table icon-table-filter filter-icon ".concat(!!column.getFilterValue() ? 'height-light-filter' : ''),
133
133
  onClick: onFilterIconClick
@@ -135,6 +135,9 @@ export function ColumnFilter(_ref) {
135
135
  ref: filterPanelWrapperRef,
136
136
  className: "filter-panel-wrapper",
137
137
  style: columnConfigStyle,
138
+ onClick: function onClick(e) {
139
+ return e.stopPropagation();
140
+ },
138
141
  children: /*#__PURE__*/_jsx(Filter, {
139
142
  column: column,
140
143
  onCloseFilterPanel: handleClosePanel
@@ -19,6 +19,16 @@ export declare const setInitColumnsSize: (tableColumns: any, columnsMap: any, de
19
19
  tableColumns: any;
20
20
  };
21
21
  export declare const getFormatFilters: (columns: TableMaxColumnType[], originFilters: ColumnFiltersState) => {};
22
+ /**
23
+ * 不同filterType组件的查询格式:
24
+ * 1. DateRange/NumberRange:
25
+ * 1.1 只输入开始:Ge
26
+ * 1.2 只输入结束:Le
27
+ * 1.3 都输入:Between
28
+ * 2. MultiSelect没有填filterType:In
29
+ * 3. Input/AutoComplete:Contains
30
+ * 4. SingleDate/SingleNumber/SingleSelect:Eq
31
+ */
22
32
  export declare const getFormatFiltersV2: (columns: TableMaxColumnType[], originFilters: ColumnFiltersState) => FormatFilterType[];
23
33
  export declare const getFormatSorting: (columns: TableMaxColumnType[], originSorting: SortingState) => {
24
34
  id: string;
@@ -134,6 +134,16 @@ export var getFormatFilters = function getFormatFilters(columns, originFilters)
134
134
  };
135
135
 
136
136
  // 动态化查询格式:https://arim-jyzx.coding.net/p/infra/wiki/3252
137
+ /**
138
+ * 不同filterType组件的查询格式:
139
+ * 1. DateRange/NumberRange:
140
+ * 1.1 只输入开始:Ge
141
+ * 1.2 只输入结束:Le
142
+ * 1.3 都输入:Between
143
+ * 2. MultiSelect没有填filterType:In
144
+ * 3. Input/AutoComplete:Contains
145
+ * 4. SingleDate/SingleNumber/SingleSelect:Eq
146
+ */
137
147
  export var getFormatFiltersV2 = function getFormatFiltersV2(columns, originFilters) {
138
148
  // console.log('getFormatFilters :>> ', columns, originFilters);
139
149
  var formatFilters = [];
@@ -183,12 +193,12 @@ export var getFormatFiltersV2 = function getFormatFiltersV2(columns, originFilte
183
193
  // 多选组件
184
194
  res.operator = FilterOperator.In;
185
195
  res.value = value;
186
- } else if (filterType === FilterType.Input) {
196
+ } else if (filterType === FilterType.Input || filterType === FilterType.AutoComplete) {
187
197
  // Input组件
188
198
  res.operator = FilterOperator.Contains;
189
199
  res.value = value;
190
200
  } else {
191
- // 其他组件: SingleDate/SingleNumber/AutoComplete/SingleSelect
201
+ // 其他组件: SingleDate/SingleNumber/SingleSelect
192
202
  res.operator = FilterOperator.Eq;
193
203
  res.value = value;
194
204
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arim-aisdc/public-components",
3
- "version": "2.2.8-alpha.0",
3
+ "version": "2.2.8-alpha.1",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",