@ccs-ui/rc-pro 2.3.6-beta-34 → 2.3.6-beta-36

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 (65) hide show
  1. package/es/aj-captcha/index.d.ts +5 -2
  2. package/es/aj-captcha/index.js +6 -2
  3. package/es/auth/index.d.ts +3 -0
  4. package/es/auth/index.js +3 -0
  5. package/es/button/dropdown.js +5 -17
  6. package/es/button/group.js +31 -48
  7. package/es/button/index.d.ts +2 -8
  8. package/es/button/index.js +10 -13
  9. package/es/cascader/index.d.ts +5 -2
  10. package/es/cascader/index.js +6 -2
  11. package/es/ccs.d.ts +7 -8
  12. package/es/color-picker/index.d.ts +5 -1
  13. package/es/color-picker/index.js +6 -2
  14. package/es/date-picker/index.d.ts +1 -0
  15. package/es/date-picker/index.js +3 -0
  16. package/es/dialog/button.d.ts +1 -1
  17. package/es/dialog/index.d.ts +3 -1
  18. package/es/dialog/index.js +3 -0
  19. package/es/editor/index.d.ts +1 -0
  20. package/es/editor/index.js +3 -0
  21. package/es/ellipsis/index.d.ts +2 -2
  22. package/es/ellipsis/index.js +7 -6
  23. package/es/index.d.ts +1 -2
  24. package/es/index.js +1 -2
  25. package/es/interval-button/index.js +3 -0
  26. package/es/layout-keep-alive/index.d.ts +5 -2
  27. package/es/layout-keep-alive/index.js +6 -2
  28. package/es/layout-single-page/index.d.ts +5 -2
  29. package/es/layout-single-page/index.js +8 -7
  30. package/es/loading/index.d.ts +4 -1
  31. package/es/loading/index.js +4 -1
  32. package/es/pro-table/index.d.ts +7 -0
  33. package/es/pro-table/index.js +9 -0
  34. package/es/pro-table/selection-alert.d.ts +18 -0
  35. package/es/pro-table/selection-alert.js +52 -0
  36. package/es/pro-table/summary.d.ts +8 -0
  37. package/es/pro-table/summary.js +32 -0
  38. package/es/pro-table/table.d.ts +28 -18
  39. package/es/pro-table/table.js +279 -141
  40. package/es/pro-table/useSelection.d.ts +28 -0
  41. package/es/pro-table/useSelection.js +146 -0
  42. package/es/pro-tabs/index.d.ts +5 -2
  43. package/es/pro-tabs/index.js +6 -2
  44. package/es/result/index.d.ts +11 -15
  45. package/es/result/index.js +57 -54
  46. package/es/select/ modal.d.ts +16 -0
  47. package/es/select/ modal.js +100 -0
  48. package/es/select/api.d.ts +25 -0
  49. package/es/select/api.js +67 -0
  50. package/es/select/customize.d.ts +33 -0
  51. package/es/{select-customize/index.js → select/customize.js} +82 -98
  52. package/es/select/index.d.ts +20 -20
  53. package/es/select/index.js +69 -80
  54. package/es/status-tag/index.d.ts +5 -1
  55. package/es/status-tag/index.js +6 -2
  56. package/es/table/index.d.ts +5 -2
  57. package/es/table/index.js +53 -43
  58. package/es/trigger/index.d.ts +1 -0
  59. package/es/trigger/index.js +1 -0
  60. package/es/upload/index.d.ts +4 -3
  61. package/es/upload/index.js +6 -3
  62. package/es/water-mark/index.d.ts +4 -1
  63. package/es/water-mark/index.js +3 -0
  64. package/package.json +3 -2
  65. package/es/select-customize/index.d.ts +0 -26
@@ -0,0 +1,28 @@
1
+ import { RowSelectMethod } from 'antd/es/table/interface';
2
+ import React from 'react';
3
+ interface PropsType<T> {
4
+ /** 表单受控 value */
5
+ value?: any[];
6
+ /** 默认选择行数据,一般用于回显数据 */
7
+ defaultRows?: T[];
8
+ /** 是否多选 */
9
+ multiple?: boolean;
10
+ /** 字段配置,默认 { key: 'key'; label: 'label' } */
11
+ keyField: string;
12
+ /** 表单受控 onChange*/
13
+ onChange?: (value: any) => void;
14
+ /** 设置选项 */
15
+ onChangeOptions?: (options: any[]) => void;
16
+ }
17
+ export declare function useSelection<T = any>(props: PropsType<T>): {
18
+ onChange: (keys: React.Key[], rows: T[], info: {
19
+ type: RowSelectMethod;
20
+ }) => void;
21
+ onClear: (key?: React.Key) => void;
22
+ selectedRowKeys?: React.Key[] | undefined;
23
+ selectedRows?: T[] | undefined;
24
+ info: {
25
+ type: RowSelectMethod;
26
+ };
27
+ };
28
+ export {};
@@ -0,0 +1,146 @@
1
+ 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; }
2
+ 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; }
3
+ 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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
5
+ 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); }
6
+ 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); }
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; }
13
+ import { useMemoizedFn, useUpdateEffect } from 'ahooks';
14
+ import { useEffect, useRef, useState } from 'react';
15
+ // 判断相对
16
+ function isEq(obj1, obj2) {
17
+ var o1 = obj1 !== null && obj1 !== void 0 ? obj1 : [];
18
+ var o2 = obj2 !== null && obj2 !== void 0 ? obj2 : [];
19
+ if (!Array.isArray(o1)) {
20
+ o1 = [o1];
21
+ }
22
+ return JSON.stringify(o1) !== JSON.stringify(o2);
23
+ }
24
+ export function useSelection(props) {
25
+ var _ref = props || {},
26
+ value = _ref.value,
27
+ defaultRows = _ref.defaultRows,
28
+ _ref$keyField = _ref.keyField,
29
+ keyField = _ref$keyField === void 0 ? 'key' : _ref$keyField,
30
+ multiple = _ref.multiple,
31
+ onChangeValue = _ref.onChange,
32
+ onChangeOptions = _ref.onChangeOptions;
33
+ var _useState = useState({}),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ setUpdate = _useState2[1];
36
+ var selectionRef = useRef({
37
+ selectedRowKeys: ['number', 'string'].includes(_typeof(value)) ? [value] : value,
38
+ selectedRows: defaultRows,
39
+ info: {
40
+ type: 'none'
41
+ }
42
+ });
43
+ var handleOnChange = useMemoizedFn(function () {
44
+ var _selectionRef$current = selectionRef.current.selectedRowKeys,
45
+ selectedRowKeys = _selectionRef$current === void 0 ? [] : _selectionRef$current;
46
+ if (multiple) {
47
+ // 受控调用onChange
48
+ onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys);
49
+ } else {
50
+ onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys[0]);
51
+ }
52
+ if (!onChangeValue) setUpdate({});
53
+ });
54
+
55
+ // 生成默认选中数据
56
+ useEffect(function () {
57
+ if (defaultRows && !selectionRef.current.selectedRows) {
58
+ selectionRef.current.selectedRows = defaultRows;
59
+
60
+ // 生成选项
61
+ if (onChangeOptions) onChangeOptions(defaultRows);
62
+ setUpdate({});
63
+ }
64
+ }, [defaultRows]);
65
+
66
+ // value 变更,与当前选中数据不匹配
67
+ useUpdateEffect(function () {
68
+ if (isEq(value, selectionRef.current.selectedRowKeys)) {
69
+ var _selectionRef$current2;
70
+ var rows = (_selectionRef$current2 = selectionRef.current.selectedRows) === null || _selectionRef$current2 === void 0 ? void 0 : _selectionRef$current2.filter(function () {
71
+ var _ref2;
72
+ var row = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
73
+ return (_ref2 = value || []) === null || _ref2 === void 0 ? void 0 : _ref2.includes(row[keyField]);
74
+ });
75
+ selectionRef.current = {
76
+ selectedRowKeys: value,
77
+ selectedRows: rows,
78
+ info: {
79
+ type: 'none'
80
+ }
81
+ };
82
+ setUpdate({});
83
+ }
84
+ }, [value]);
85
+
86
+ // 选中改变
87
+ var onChange = useMemoizedFn(function (keys, rows, info) {
88
+ selectionRef.current = {
89
+ selectedRowKeys: keys,
90
+ selectedRows: rows,
91
+ info: info
92
+ };
93
+ // 未知选中数据,在初始化传入数据中匹配
94
+ if (defaultRows && defaultRows.length > 0) {
95
+ rows.forEach(function (row, index) {
96
+ if (!row) {
97
+ var defaultRow = defaultRows.find(function (r) {
98
+ return r[keyField] === keys[index];
99
+ });
100
+ if (defaultRow) rows[index] = defaultRow;
101
+ }
102
+ });
103
+ }
104
+ onChangeOptions === null || onChangeOptions === void 0 || onChangeOptions(rows);
105
+ handleOnChange();
106
+ });
107
+
108
+ // 删除
109
+ var onClear = useMemoizedFn(function (key) {
110
+ // 未传入key,删除全部
111
+ if (!key) {
112
+ selectionRef.current = {
113
+ selectedRowKeys: undefined,
114
+ selectedRows: undefined,
115
+ info: {
116
+ type: 'none'
117
+ }
118
+ };
119
+ } else {
120
+ var _selectionRef$current3 = selectionRef.current,
121
+ _selectionRef$current4 = _selectionRef$current3.selectedRowKeys,
122
+ selectedRowKeys = _selectionRef$current4 === void 0 ? [] : _selectionRef$current4,
123
+ _selectionRef$current5 = _selectionRef$current3.selectedRows,
124
+ selectedRows = _selectionRef$current5 === void 0 ? [] : _selectionRef$current5;
125
+ var newRows = selectedRows.filter(function () {
126
+ var r = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
127
+ return r[keyField] !== key;
128
+ });
129
+ var newKey = selectedRowKeys.filter(function (k) {
130
+ return k !== key;
131
+ });
132
+ selectionRef.current = {
133
+ selectedRowKeys: newKey,
134
+ selectedRows: newRows,
135
+ info: {
136
+ type: 'none'
137
+ }
138
+ };
139
+ }
140
+ handleOnChange();
141
+ });
142
+ return _objectSpread(_objectSpread({}, selectionRef.current), {}, {
143
+ onChange: onChange,
144
+ onClear: onClear
145
+ });
146
+ }
@@ -2,5 +2,8 @@ import { TabsProps } from 'antd';
2
2
  type PropsType = {
3
3
  children: TabsProps;
4
4
  };
5
- declare const _default: ({ children }: PropsType) => import("react/jsx-runtime").JSX.Element;
6
- export default _default;
5
+ declare const ProTabs: {
6
+ ({ children }: PropsType): import("react/jsx-runtime").JSX.Element;
7
+ displayName: string;
8
+ };
9
+ export default ProTabs;
@@ -12,7 +12,7 @@ import { cloneElement, useState } from 'react';
12
12
  import { TabsContext } from "../context";
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Fragment as _Fragment } from "react/jsx-runtime";
15
- export default (function (_ref) {
15
+ var ProTabs = function ProTabs(_ref) {
16
16
  var children = _ref.children;
17
17
  var _ref2 = (children === null || children === void 0 ? void 0 : children.props) || {},
18
18
  _ref2$items = _ref2.items,
@@ -167,4 +167,8 @@ export default (function (_ref) {
167
167
  },
168
168
  children: /*#__PURE__*/cloneElement(children, addOptions)
169
169
  }) : /*#__PURE__*/_jsx(_Fragment, {});
170
- });
170
+ };
171
+ if (process.env.NODE_ENV !== 'production') {
172
+ ProTabs.displayName = 'CcsProTabs';
173
+ }
174
+ export default ProTabs;
@@ -1,16 +1,12 @@
1
- import { CSSProperties } from 'react';
2
- type ResultProps = {
3
- style?: CSSProperties;
4
- text?: string;
5
- textStyle?: CSSProperties;
6
- iconWidth?: number;
1
+ import { ResultProps } from 'antd/es/result';
2
+ declare const InternalResult: {
3
+ (props: ResultProps): import("react/jsx-runtime").JSX.Element;
4
+ Success: (props: ResultProps) => import("react/jsx-runtime").JSX.Element;
5
+ Info: (props: ResultProps) => import("react/jsx-runtime").JSX.Element;
6
+ Warning: (props: ResultProps) => import("react/jsx-runtime").JSX.Element;
7
+ Error: (props: ResultProps) => import("react/jsx-runtime").JSX.Element;
8
+ Page403: (props: ResultProps) => import("react/jsx-runtime").JSX.Element;
9
+ Page404: (props: ResultProps) => import("react/jsx-runtime").JSX.Element;
10
+ Page500: (props: ResultProps) => import("react/jsx-runtime").JSX.Element;
7
11
  };
8
- declare function NotFound(props: ResultProps): import("react/jsx-runtime").JSX.Element;
9
- declare function NoData(props: ResultProps): import("react/jsx-runtime").JSX.Element;
10
- declare function NoAddData(props: ResultProps): import("react/jsx-runtime").JSX.Element;
11
- declare const CcsResult: {
12
- NotFound: typeof NotFound;
13
- NoData: typeof NoData;
14
- NoAddData: typeof NoAddData;
15
- };
16
- export default CcsResult;
12
+ export default InternalResult;
@@ -4,62 +4,65 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  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
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
- import { theme } from 'antd';
8
- import { noAddData, noData, notFoundIcon } from "./icon";
7
+ import { Result } from 'antd';
9
8
  import { jsx as _jsx } from "react/jsx-runtime";
10
- import { jsxs as _jsxs } from "react/jsx-runtime";
11
- function Basic(_ref) {
12
- var style = _ref.style,
13
- text = _ref.text,
14
- textStyle = _ref.textStyle,
15
- _ref$iconWidth = _ref.iconWidth,
16
- iconWidth = _ref$iconWidth === void 0 ? 140 : _ref$iconWidth,
17
- icon = _ref.icon;
18
- var _theme$useToken = theme.useToken(),
19
- token = _theme$useToken.token;
20
- return /*#__PURE__*/_jsxs("div", {
21
- style: _objectSpread({
22
- display: 'flex',
23
- flexDirection: 'column',
24
- alignItems: 'center',
25
- padding: 16
26
- }, style),
27
- children: [/*#__PURE__*/_jsx("img", {
28
- src: icon,
29
- width: iconWidth
30
- }), /*#__PURE__*/_jsx("p", {
31
- style: _objectSpread({
32
- color: token.colorText,
33
- fontSize: 16
34
- }, textStyle),
35
- children: text
36
- })]
37
- });
38
- }
39
- function NotFound(props) {
40
- return /*#__PURE__*/_jsx(Basic, _objectSpread(_objectSpread({}, _objectSpread(_objectSpread({}, props), {}, {
41
- text: props.text || '页面未找到'
42
- })), {}, {
43
- icon: notFoundIcon
9
+ var InternalResult = function InternalResult(props) {
10
+ return /*#__PURE__*/_jsx(Result, _objectSpread({}, props));
11
+ };
12
+ var ResultSuccess = function ResultSuccess(props) {
13
+ return /*#__PURE__*/_jsx(InternalResult, _objectSpread(_objectSpread({
14
+ title: "\u64CD\u4F5C\u6210\u529F"
15
+ }, props), {}, {
16
+ status: "success"
17
+ }));
18
+ };
19
+ var ResultInfo = function ResultInfo(props) {
20
+ return /*#__PURE__*/_jsx(InternalResult, _objectSpread(_objectSpread({
21
+ title: "\u64CD\u4F5C\u8BE6\u60C5"
22
+ }, props), {}, {
23
+ status: "info"
44
24
  }));
45
- }
46
- function NoData(props) {
47
- return /*#__PURE__*/_jsx(Basic, _objectSpread(_objectSpread({}, _objectSpread(_objectSpread({}, props), {}, {
48
- text: props.text || '暂无数据'
49
- })), {}, {
50
- icon: noData
25
+ };
26
+ var ResultWarning = function ResultWarning(props) {
27
+ return /*#__PURE__*/_jsx(InternalResult, _objectSpread(_objectSpread({
28
+ title: "\u64CD\u4F5C\u63D0\u9192"
29
+ }, props), {}, {
30
+ status: "warning"
31
+ }));
32
+ };
33
+ var ResultError = function ResultError(props) {
34
+ return /*#__PURE__*/_jsx(InternalResult, _objectSpread(_objectSpread({
35
+ title: "\u64CD\u4F5C\u5931\u8D25"
36
+ }, props), {}, {
37
+ status: "error"
51
38
  }));
52
- }
53
- function NoAddData(props) {
54
- return /*#__PURE__*/_jsx(Basic, _objectSpread(_objectSpread({}, _objectSpread(_objectSpread({}, props), {}, {
55
- text: props.text || '未添加任何数据'
56
- })), {}, {
57
- icon: noAddData
39
+ };
40
+ var Result403 = function Result403(props) {
41
+ return /*#__PURE__*/_jsx(InternalResult, _objectSpread(_objectSpread({
42
+ title: "403"
43
+ }, props), {}, {
44
+ status: "403"
45
+ }));
46
+ };
47
+ var Result404 = function Result404(props) {
48
+ return /*#__PURE__*/_jsx(InternalResult, _objectSpread(_objectSpread({
49
+ title: "404"
50
+ }, props), {}, {
51
+ status: "404"
52
+ }));
53
+ };
54
+ var Result500 = function Result500(props) {
55
+ return /*#__PURE__*/_jsx(InternalResult, _objectSpread(_objectSpread({
56
+ title: "500"
57
+ }, props), {}, {
58
+ status: "500"
58
59
  }));
59
- }
60
- var CcsResult = {
61
- NotFound: NotFound,
62
- NoData: NoData,
63
- NoAddData: NoAddData
64
60
  };
65
- export default CcsResult;
61
+ InternalResult.Success = ResultSuccess;
62
+ InternalResult.Info = ResultInfo;
63
+ InternalResult.Warning = ResultWarning;
64
+ InternalResult.Error = ResultError;
65
+ InternalResult.Page403 = Result403;
66
+ InternalResult.Page404 = Result404;
67
+ InternalResult.Page500 = Result500;
68
+ export default InternalResult;
@@ -0,0 +1,16 @@
1
+ import { ModalProps, SelectProps } from 'antd';
2
+ import { ReactElement, ReactNode } from 'react';
3
+ import { SelectChildrenProps } from './customize';
4
+ export interface ModalSelectProps {
5
+ /** modal props */
6
+ modal?: ModalProps;
7
+ /** select props */
8
+ select?: SelectProps;
9
+ /** 自定义内容 */
10
+ children: ReactElement | ((props: SelectChildrenProps) => ReactNode);
11
+ /** form item value */
12
+ value?: any;
13
+ /** form item onChange */
14
+ onChange?: (e: any) => void;
15
+ }
16
+ export default function ModalSelect({ modal, select, value, children, onChange: onOkChange, }: ModalSelectProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,100 @@
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; }
4
+ 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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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
+ 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; }
13
+ import { SelectOutlined } from '@ant-design/icons';
14
+ import { Modal, Select } from 'antd';
15
+ import React, { useState } from 'react';
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { Fragment as _Fragment } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ export default function ModalSelect(_ref) {
20
+ var modal = _ref.modal,
21
+ select = _ref.select,
22
+ value = _ref.value,
23
+ children = _ref.children,
24
+ onOkChange = _ref.onChange;
25
+ var _useState = useState(false),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ open = _useState2[0],
28
+ setOpen = _useState2[1];
29
+ var onClick = function onClick() {
30
+ setOpen(true);
31
+ };
32
+ var _useState3 = useState(value),
33
+ _useState4 = _slicedToArray(_useState3, 2),
34
+ valueState = _useState4[0],
35
+ setValueState = _useState4[1];
36
+ var _useState5 = useState(undefined),
37
+ _useState6 = _slicedToArray(_useState5, 2),
38
+ options = _useState6[0],
39
+ setOptions = _useState6[1];
40
+
41
+ // 确定按钮
42
+ var onClose = function onClose(e) {
43
+ e === null || e === void 0 || e.stopPropagation();
44
+ setOpen(false);
45
+ };
46
+
47
+ // 多选
48
+ var isMulti = (select === null || select === void 0 ? void 0 : select.mode) === 'multiple';
49
+
50
+ // children 参数
51
+ var childrenProps = {
52
+ value: valueState,
53
+ multiple: isMulti,
54
+ onClose: onClose,
55
+ onChange: setValueState,
56
+ onChangeOptions: setOptions
57
+ };
58
+
59
+ // 确定
60
+ var onModalOk = function onModalOk() {
61
+ onOkChange === null || onOkChange === void 0 || onOkChange(valueState);
62
+ setOpen(false);
63
+ };
64
+
65
+ // 取消
66
+ var onModalClose = function onModalClose() {
67
+ setValueState(value);
68
+ setOpen(false);
69
+ };
70
+ return /*#__PURE__*/_jsxs(_Fragment, {
71
+ children: [/*#__PURE__*/_jsx(Select, _objectSpread({
72
+ allowClear: true,
73
+ suffixIcon: /*#__PURE__*/_jsx(SelectOutlined, {}),
74
+ open: false,
75
+ dropdownRender: function dropdownRender() {
76
+ return /*#__PURE__*/_jsx("div", {});
77
+ },
78
+ value: value,
79
+ onClick: onClick,
80
+ placeholder: (select === null || select === void 0 ? void 0 : select.placeholder) || '请选择',
81
+ options: options,
82
+ onChange: function onChange(e) {
83
+ setValueState(e);
84
+ onOkChange === null || onOkChange === void 0 || onOkChange(e);
85
+ }
86
+ }, select)), /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({
87
+ open: open,
88
+ onCancel: onModalClose,
89
+ styles: {
90
+ body: {
91
+ padding: 0
92
+ }
93
+ },
94
+ forceRender: true,
95
+ onOk: onModalOk
96
+ }, modal), {}, {
97
+ children: typeof children === 'function' ? children(childrenProps) : /*#__PURE__*/React.cloneElement(children, childrenProps)
98
+ }))]
99
+ });
100
+ }
@@ -0,0 +1,25 @@
1
+ import { CcsSelectProps } from '.';
2
+ import CCS from '..';
3
+ type CacheType = {
4
+ /** 缓存key,同一个key将共享数据 */
5
+ cacheKey?: string;
6
+ /** 设置数据保持新鲜时间,在该时间内,我们认为数据是新鲜的,不会重新发起请求 */
7
+ staleTime?: number;
8
+ /** 设置数据缓存时间,超过该时间,我们会清空该条缓存数据 */
9
+ cacheTime?: number;
10
+ };
11
+ type ApiSelectProps = CcsSelectProps & {
12
+ /** 开启缓存 */
13
+ cache?: CacheType;
14
+ /** 依赖参数 */
15
+ defaultParams?: CCS.RecordType;
16
+ /** 查询请求 */
17
+ request?: (params?: any) => Promise<any>;
18
+ };
19
+ /**
20
+ * 基于接口查询的select组件
21
+ * @param ApiSelectProps
22
+ * @returns
23
+ */
24
+ declare function ApiSelect({ request, cache, defaultParams, ...restProps }: ApiSelectProps): import("react/jsx-runtime").JSX.Element;
25
+ export default ApiSelect;
@@ -0,0 +1,67 @@
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 = ["request", "cache", "defaultParams"];
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; }
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; }
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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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); }
8
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
9
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
10
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
+ 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; }
12
+ 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
+ import { useRequest } from 'ahooks';
14
+ import { useEffect } from 'react';
15
+ import InternalSelect from '.';
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ /**
18
+ * 基于接口查询的select组件
19
+ * @param ApiSelectProps
20
+ * @returns
21
+ */
22
+ function ApiSelect(_ref) {
23
+ var request = _ref.request,
24
+ cache = _ref.cache,
25
+ _ref$defaultParams = _ref.defaultParams,
26
+ defaultParams = _ref$defaultParams === void 0 ? {} : _ref$defaultParams,
27
+ restProps = _objectWithoutProperties(_ref, _excluded);
28
+ var _useRequest = useRequest( /*#__PURE__*/function () {
29
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
30
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
31
+ while (1) switch (_context.prev = _context.next) {
32
+ case 0:
33
+ if (request) {
34
+ _context.next = 2;
35
+ break;
36
+ }
37
+ return _context.abrupt("return", []);
38
+ case 2:
39
+ _context.next = 4;
40
+ return request(params);
41
+ case 4:
42
+ return _context.abrupt("return", _context.sent);
43
+ case 5:
44
+ case "end":
45
+ return _context.stop();
46
+ }
47
+ }, _callee);
48
+ }));
49
+ return function (_x) {
50
+ return _ref2.apply(this, arguments);
51
+ };
52
+ }(), _objectSpread({
53
+ manual: true
54
+ }, cache || {})),
55
+ loading = _useRequest.loading,
56
+ _useRequest$data = _useRequest.data,
57
+ data = _useRequest$data === void 0 ? [] : _useRequest$data,
58
+ run = _useRequest.run;
59
+ useEffect(function () {
60
+ if (request) run(defaultParams);
61
+ }, [JSON.stringify(defaultParams)]);
62
+ return /*#__PURE__*/_jsx(InternalSelect, _objectSpread({
63
+ options: data,
64
+ loading: loading
65
+ }, restProps));
66
+ }
67
+ export default ApiSelect;
@@ -0,0 +1,33 @@
1
+ import { SelectProps } from 'antd';
2
+ import { ReactElement, ReactNode } from 'react';
3
+ export type SelectChildrenProps = {
4
+ /** 当前选中的值 */
5
+ value?: any;
6
+ /** 是否多选 */
7
+ multiple?: boolean;
8
+ /** 关闭弹框 */
9
+ onClose?: (e?: any) => void;
10
+ /** form item onChange */
11
+ onChange?: (value: any) => void;
12
+ /** 更改select options */
13
+ onChangeOptions?: (options: any[]) => void;
14
+ };
15
+ export interface CustomizeSelectProps extends Omit<SelectProps, 'children'> {
16
+ /** 选择触发器宽度 */
17
+ width?: number;
18
+ /** 内容宽度 */
19
+ contentWidth?: number;
20
+ /** 自定义内容 */
21
+ children: ReactElement | ((props: SelectChildrenProps) => ReactNode);
22
+ /** form item value */
23
+ value?: any;
24
+ /** form item onChange */
25
+ onChange?: (e: any) => void;
26
+ }
27
+ /**
28
+ * 自定义弹框
29
+ * @param SelectCustomizeProps
30
+ * @returns
31
+ */
32
+ declare function SelectIndex({ width, title, children, contentWidth, value, onChange, style, ...otherProps }: CustomizeSelectProps): import("react/jsx-runtime").JSX.Element;
33
+ export default SelectIndex;