@arim-aisdc/public-components 2.1.4 → 2.1.5

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.
@@ -12,7 +12,7 @@ export interface CenterModalPropsType extends ModalProps {
12
12
  okText?: string;
13
13
  hasfooter?: boolean;
14
14
  footer?: ReactNode;
15
- width?: number;
15
+ width?: number | string;
16
16
  size?: string;
17
17
  renderContent?: JSX.Element | null;
18
18
  maskClosable?: boolean;
@@ -22,6 +22,7 @@ import dayjs from 'dayjs';
22
22
  import { debounce } from 'lodash';
23
23
  import React, { forwardRef, useEffect, useState } from 'react';
24
24
  import "./index.less";
25
+ import RemoteSelect from "./remoteSelect";
25
26
  import { FormItemType, TimeFormatType } from "./type";
26
27
  import { jsx as _jsx } from "react/jsx-runtime";
27
28
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -264,6 +265,13 @@ var QueryFilter = function QueryFilter(_ref, ref) {
264
265
  })
265
266
  });
266
267
  break;
268
+ case FormItemType.RemoteSelect:
269
+ element = /*#__PURE__*/_jsx(RemoteSelect, _objectSpread(_objectSpread({}, item), {}, {
270
+ onChange: function onChange(e) {
271
+ commonChange(e, item);
272
+ }
273
+ }));
274
+ break;
267
275
  case FormItemType.Radio:
268
276
  element = /*#__PURE__*/_jsx(Radio.Group, {
269
277
  onChange: function onChange(e) {
@@ -0,0 +1,7 @@
1
+ import { searchFieldType } from '../type';
2
+ interface IProps extends searchFieldType {
3
+ value?: any;
4
+ onChange?: (value: string, option: any) => void;
5
+ }
6
+ declare const RemoteSelect: ({ value, onChange, getOptionsFn, ...item }: IProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default RemoteSelect;
@@ -0,0 +1,72 @@
1
+ var _excluded = ["value", "onChange", "getOptionsFn"];
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ 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."); }
4
+ 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); }
5
+ 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; }
6
+ 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; } }
7
+ 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; }
10
+ import { Select, Spin } from 'antd';
11
+ import { debounce } from 'lodash';
12
+ import { useEffect, useMemo, useRef, useState } from 'react';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ var RemoteSelect = function RemoteSelect(_ref) {
15
+ var _item$handleSelect;
16
+ var value = _ref.value,
17
+ onChange = _ref.onChange,
18
+ getOptionsFn = _ref.getOptionsFn,
19
+ item = _objectWithoutProperties(_ref, _excluded);
20
+ var _useState = useState(false),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ fetching = _useState2[0],
23
+ setFetching = _useState2[1];
24
+ var _useState3 = useState([]),
25
+ _useState4 = _slicedToArray(_useState3, 2),
26
+ options = _useState4[0],
27
+ setOptions = _useState4[1];
28
+ var fetchRef = useRef(0);
29
+ var debounceFetcher = useMemo(function () {
30
+ var loadOptions = function loadOptions(value) {
31
+ fetchRef.current += 1;
32
+ var fetchId = fetchRef.current;
33
+ if (!getOptionsFn) return;
34
+ setOptions([]);
35
+ setFetching(true);
36
+ getOptionsFn(value).then(function (newOptions) {
37
+ if (fetchId !== fetchRef.current) {
38
+ // for fetch callback order
39
+ return;
40
+ }
41
+ // console.log('newOptions', newOptions);
42
+ setOptions(newOptions);
43
+ setFetching(false);
44
+ });
45
+ };
46
+ return debounce(loadOptions, 500);
47
+ }, [getOptionsFn]);
48
+ useEffect(function () {
49
+ debounceFetcher();
50
+ }, []);
51
+ return /*#__PURE__*/_jsx(Select, {
52
+ className: "queryFilter-remoteSelect",
53
+ mode: item.mode ? item.mode : undefined,
54
+ showSearch: item.showSearch,
55
+ placeholder: item.inputTips,
56
+ allowClear: item.allowClear,
57
+ value: value,
58
+ maxTagCount: item.maxTagCount,
59
+ suffixIcon: null,
60
+ options: options,
61
+ disabled: item.disabled,
62
+ onSearch: debounceFetcher,
63
+ onChange: onChange,
64
+ filterOption: false,
65
+ onSelect: (_item$handleSelect = item.handleSelect) !== null && _item$handleSelect !== void 0 ? _item$handleSelect : undefined,
66
+ notFoundContent: fetching ? /*#__PURE__*/_jsx(Spin, {
67
+ size: "small"
68
+ }) : null,
69
+ fieldNames: item.fieldNames
70
+ });
71
+ };
72
+ export default RemoteSelect;
@@ -6,6 +6,7 @@ export declare enum FormItemType {
6
6
  Number = "number",
7
7
  Switch = "switch",
8
8
  Select = "select",
9
+ RemoteSelect = "remoteSelect",
9
10
  Cascader = "cascader",
10
11
  DateTime = "datetime",
11
12
  DateRang = "daterang",
@@ -28,19 +29,26 @@ export declare enum TimeFormatType {
28
29
  nonSecondTimeType = "HH:mm"
29
30
  }
30
31
  export interface fieldType {
32
+ /**字段 */
31
33
  field: string;
32
34
  label?: string;
33
35
  text: string | Element | JSX.Element;
34
36
  value: any;
37
+ /**单位 */
35
38
  units?: string;
36
39
  width?: string;
37
40
  labelWidth?: string;
38
41
  color?: string;
39
42
  disabledColor?: string;
43
+ /**全部数据 */
40
44
  detail?: object;
45
+ /** 是否显示区间选项 */
41
46
  isShowInterval?: boolean;
47
+ /** 主动触发, 用于触发级联条件 */
42
48
  isActiveTrigger?: boolean;
49
+ /** 主动触发方法 */
43
50
  activeTriggerFun?: (e: any) => void;
51
+ /** 是否超出隐藏显示tooltip */
44
52
  isShowToolTip?: boolean;
45
53
  }
46
54
  export type inputValueType = 'min' | 'max' | string;
@@ -53,40 +61,72 @@ export declare enum PickerType {
53
61
  Quarter = "quarter "
54
62
  }
55
63
  export type searchFieldType = {
64
+ /**字段code */
56
65
  field: string;
66
+ /**字段名称 */
57
67
  label?: string;
68
+ /**表单类型 */
58
69
  formType: FormItemType;
70
+ /**默认值 */
59
71
  defaultValue?: string | any[] | number;
72
+ /**placeholder */
60
73
  inputTips?: string | any;
74
+ /**下拉选配置 */
61
75
  setting?: any[];
76
+ /**下拉选配置(当有并排下拉选时) */
62
77
  setting1?: any[];
78
+ /**字段值 */
63
79
  value?: string;
80
+ /**文本域最大字符 */
64
81
  maxLength?: number;
82
+ /**文本域行数 */
65
83
  rows?: number;
84
+ /**输入/选择框的长度px值 */
66
85
  wapperWidth?: number;
86
+ /**时间面板 */
67
87
  picker?: PickerType;
88
+ /**格式化时间 */
68
89
  defaultFormat?: any;
69
- showTimeFormat?: any;
90
+ /**显示时间格式化 */
70
91
  allowClear?: boolean;
92
+ /**是否显示多个输入框 */
71
93
  isShowInterval?: boolean;
94
+ /**是否禁用 */
72
95
  disabled?: boolean;
96
+ /**imputnumber 最小值 */
73
97
  min?: number;
98
+ /**imputnumber 最大值 */
74
99
  max?: number;
100
+ /**imputnumber 步长 */
75
101
  step?: number;
102
+ /**是否远程搜索 autocomplete 不需要,select需要 */
76
103
  showSearch?: boolean;
104
+ /**自定义节点 label、value、options、groupLabel 的字段 */
77
105
  fieldNames?: {
78
- label: string;
79
- value: string;
106
+ label?: string;
107
+ value?: string;
108
+ options?: string;
109
+ groupLabel?: string;
80
110
  };
81
111
  optionFilterProp?: string;
82
112
  optionLabelProp?: string;
113
+ /**远程搜索函数 */
83
114
  handleSearch?: () => void;
115
+ /**remoteSelect组件获取options函数 */
116
+ getOptionsFn?: (keyword: string) => Promise<any[]>;
117
+ /**后缀,可以是单位 */
84
118
  suffix?: string;
119
+ /**下拉框内容模糊筛选 */
85
120
  isFilter?: boolean;
121
+ /**select下拉选被选中是否触发handleSelect */
86
122
  showSelect?: boolean;
123
+ /**select下拉选被选中时调用 */
87
124
  handleSelect?: () => void;
125
+ /**select下多选模式配置 */
88
126
  mode?: 'multiple' | 'tags';
127
+ /**select下多选模式配置最多显示多少个 tag */
89
128
  maxTagCount?: number | 'responsive';
129
+ /**是否初始化获取options 默认为true */
90
130
  isInitGetOptions?: boolean;
91
131
  };
92
132
  export interface QueryFilterProps {
@@ -4,6 +4,7 @@ export var FormItemType = /*#__PURE__*/function (FormItemType) {
4
4
  FormItemType["Number"] = "number";
5
5
  FormItemType["Switch"] = "switch";
6
6
  FormItemType["Select"] = "select";
7
+ FormItemType["RemoteSelect"] = "remoteSelect";
7
8
  FormItemType["Cascader"] = "cascader";
8
9
  FormItemType["DateTime"] = "datetime";
9
10
  FormItemType["DateRang"] = "daterang";
@@ -1,13 +1,13 @@
1
1
  import { TableMaxColumnType } from "../../type";
2
- export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
3
- export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
4
- export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
5
- export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
2
+ export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
3
+ export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
4
+ export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
5
+ export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
6
6
  declare const customSortFns: {
7
- numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
8
- stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
9
- timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
10
- numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
7
+ numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
8
+ stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
9
+ timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
10
+ numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
11
11
  };
12
12
  export default customSortFns;
13
13
  export type SortFnType = keyof typeof customSortFns | undefined;
@@ -27,7 +27,7 @@ var useCenterModalState = function useCenterModalState(initState) {
27
27
  setProps(_objectSpread(_objectSpread({}, centerModalProps), {}, {
28
28
  open: false
29
29
  }));
30
- }, [setProps]);
30
+ }, [setProps, centerModalProps]);
31
31
 
32
32
  // 设置props
33
33
  var setCenterModalProps = useCallback(function (params) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arim-aisdc/public-components",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",