@arim-aisdc/public-components 2.1.9 → 2.1.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.
- package/dist/components/CustomForm/CustomForm.js +10 -0
- package/dist/components/CustomForm/RemoteSelectCom/index.d.ts +7 -0
- package/dist/components/CustomForm/RemoteSelectCom/index.js +72 -0
- package/dist/components/CustomForm/type.d.ts +11 -1
- package/dist/components/CustomForm/type.js +1 -0
- package/dist/components/SplitterPane/SplitterPane.d.ts +1 -0
- package/dist/components/SplitterPane/SplitterPane.js +8 -3
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
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
|
+
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
|
+
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; }
|
|
2
4
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
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; }
|
|
4
6
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
@@ -17,6 +19,7 @@ import { debounce } from 'lodash';
|
|
|
17
19
|
import React, { forwardRef, useEffect, useMemo, useState } from 'react';
|
|
18
20
|
import ColorSelector from "../ColorSelector";
|
|
19
21
|
import ConditionExpression from "../ConditionExpression";
|
|
22
|
+
import RemoteSelect from "./RemoteSelectCom";
|
|
20
23
|
import CustomFormItemInputNumber from "./customFormItemInputNumber";
|
|
21
24
|
import "./index.less";
|
|
22
25
|
import { CustomFormItemType } from "./type";
|
|
@@ -628,6 +631,13 @@ var CustomForm = function CustomForm(_ref, ref) {
|
|
|
628
631
|
parameterOptions: item === null || item === void 0 ? void 0 : item.setting
|
|
629
632
|
});
|
|
630
633
|
break;
|
|
634
|
+
case CustomFormItemType.RemoteSelect:
|
|
635
|
+
element = /*#__PURE__*/_jsx(RemoteSelect, _objectSpread(_objectSpread({}, item), {}, {
|
|
636
|
+
onChange: function onChange(e) {
|
|
637
|
+
commonChange(e, item);
|
|
638
|
+
}
|
|
639
|
+
}));
|
|
640
|
+
break;
|
|
631
641
|
}
|
|
632
642
|
return element;
|
|
633
643
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CustomSearchFieldType } from '../type';
|
|
2
|
+
interface IProps extends CustomSearchFieldType {
|
|
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: "customForm-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;
|
|
@@ -37,7 +37,8 @@ export declare enum CustomFormItemType {
|
|
|
37
37
|
MinMax = "min-max",
|
|
38
38
|
CheckBox = "checkbox",
|
|
39
39
|
Color = "color",
|
|
40
|
-
ConditionExpression = "conditionExpression"
|
|
40
|
+
ConditionExpression = "conditionExpression",
|
|
41
|
+
RemoteSelect = "remoteSelect"
|
|
41
42
|
}
|
|
42
43
|
export type SpanConfig = number | {
|
|
43
44
|
xs: number;
|
|
@@ -96,6 +97,15 @@ export type CustomSearchFieldType = {
|
|
|
96
97
|
extra?: ReactNode;
|
|
97
98
|
unit?: string;
|
|
98
99
|
tooltip?: string;
|
|
100
|
+
/**remoteSelect组件获取options函数 */
|
|
101
|
+
getOptionsFn?: (keyword: string) => Promise<any[]>;
|
|
102
|
+
/**自定义节点 label、value、options、groupLabel 的字段 */
|
|
103
|
+
fieldNames?: {
|
|
104
|
+
label?: string;
|
|
105
|
+
value?: string;
|
|
106
|
+
options?: string;
|
|
107
|
+
groupLabel?: string;
|
|
108
|
+
};
|
|
99
109
|
};
|
|
100
110
|
export interface CustomFormProps {
|
|
101
111
|
data: CustomSearchFieldType[];
|
|
@@ -15,6 +15,7 @@ export var CustomFormItemType = /*#__PURE__*/function (CustomFormItemType) {
|
|
|
15
15
|
CustomFormItemType["CheckBox"] = "checkbox";
|
|
16
16
|
CustomFormItemType["Color"] = "color";
|
|
17
17
|
CustomFormItemType["ConditionExpression"] = "conditionExpression";
|
|
18
|
+
CustomFormItemType["RemoteSelect"] = "remoteSelect";
|
|
18
19
|
return CustomFormItemType;
|
|
19
20
|
}({});
|
|
20
21
|
export var PickerType = /*#__PURE__*/function (PickerType) {
|
|
@@ -19,6 +19,7 @@ export type SplitterPaneType = {
|
|
|
19
19
|
onResize?: (sizes: number[]) => void;
|
|
20
20
|
onResizeStart?: (sizes: number[]) => void;
|
|
21
21
|
onResizeEnd?: (sizes: number[]) => void;
|
|
22
|
+
rootClassName?: string;
|
|
22
23
|
};
|
|
23
24
|
declare const _default: React.NamedExoticComponent<SplitterPaneType>;
|
|
24
25
|
export default _default;
|
|
@@ -9,6 +9,7 @@ import { Splitter } from 'antd';
|
|
|
9
9
|
import React, { useCallback, useLayoutEffect, useState } from 'react';
|
|
10
10
|
import { useConfig } from "../ConfigProvider";
|
|
11
11
|
import { SplitTypeEnums } from "./config";
|
|
12
|
+
import { getCurrentRouterName } from "../..";
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
var SplitterPane = function SplitterPane(_ref) {
|
|
14
15
|
var options = _ref.options,
|
|
@@ -17,15 +18,18 @@ var SplitterPane = function SplitterPane(_ref) {
|
|
|
17
18
|
layout = _ref$layout === void 0 ? SplitTypeEnums.horizontal : _ref$layout,
|
|
18
19
|
onResize = _ref.onResize,
|
|
19
20
|
onResizeStart = _ref.onResizeStart,
|
|
20
|
-
onResizeEnd = _ref.onResizeEnd
|
|
21
|
+
onResizeEnd = _ref.onResizeEnd,
|
|
22
|
+
rootClassName = _ref.rootClassName;
|
|
21
23
|
var _useState = useState([]),
|
|
22
24
|
_useState2 = _slicedToArray(_useState, 2),
|
|
23
25
|
sizes = _useState2[0],
|
|
24
26
|
setSizes = _useState2[1];
|
|
25
27
|
var _useConfig = useConfig(),
|
|
28
|
+
userId = _useConfig.userId,
|
|
26
29
|
tableKeyPrefixCls = _useConfig.tableKeyPrefixCls;
|
|
30
|
+
var _cacheKeyKey = "".concat(tableKeyPrefixCls, "SplitterCache-").concat(getCurrentRouterName(), "-").concat(cacheKey, "-").concat(userId);
|
|
27
31
|
useLayoutEffect(function () {
|
|
28
|
-
var defaultCacheSizesCacheKey = localStorage.getItem(
|
|
32
|
+
var defaultCacheSizesCacheKey = localStorage.getItem(_cacheKeyKey);
|
|
29
33
|
var defaultCacheSizes = options === null || options === void 0 ? void 0 : options.map(function (item) {
|
|
30
34
|
if (item.hasOwnProperty('size')) {
|
|
31
35
|
return (item === null || item === void 0 ? void 0 : item.size) || undefined;
|
|
@@ -48,7 +52,7 @@ var SplitterPane = function SplitterPane(_ref) {
|
|
|
48
52
|
return item === null || item === void 0 ? void 0 : item.size;
|
|
49
53
|
}))]);
|
|
50
54
|
useDeepCompareEffect(function () {
|
|
51
|
-
localStorage.setItem(
|
|
55
|
+
localStorage.setItem(_cacheKeyKey, JSON.stringify(sizes));
|
|
52
56
|
}, [sizes]);
|
|
53
57
|
var handlePaneResize = useCallback(function (newSizes) {
|
|
54
58
|
setSizes(newSizes);
|
|
@@ -59,6 +63,7 @@ var SplitterPane = function SplitterPane(_ref) {
|
|
|
59
63
|
onResize: handlePaneResize,
|
|
60
64
|
onResizeStart: onResizeStart,
|
|
61
65
|
onResizeEnd: onResizeEnd,
|
|
66
|
+
rootClassName: rootClassName,
|
|
62
67
|
children: options.map(function (pane, index) {
|
|
63
68
|
return /*#__PURE__*/_jsx(Splitter.Panel, {
|
|
64
69
|
size: sizes[index],
|