xmirror-components 1.0.1 → 1.0.3

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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/build/LICENSE +21 -0
  3. package/build/dist/xmirror-components.css +1 -0
  4. package/build/dist/xmirror-components.js +784 -0
  5. package/build/dist/xmirror-components.umd.cjs +35 -0
  6. package/build/es/AntdApp/index.d.ts +12 -0
  7. package/build/es/AntdApp/index.js +14 -0
  8. package/build/es/Button/button.d.ts +6 -0
  9. package/build/es/Button/button.js +22 -0
  10. package/build/es/Button/index.d.ts +3 -0
  11. package/build/es/Button/index.js +7 -0
  12. package/build/es/CheckboxValue/index.d.ts +40 -0
  13. package/build/es/CheckboxValue/index.js +33 -0
  14. package/build/es/ChunkUploader/FileItem.d.ts +13 -0
  15. package/build/es/ChunkUploader/FileItem.js +472 -0
  16. package/build/es/ChunkUploader/UploaderContext.d.ts +8 -0
  17. package/build/es/ChunkUploader/UploaderContext.js +65 -0
  18. package/build/es/ChunkUploader/generateFileUniqueID.d.ts +2 -0
  19. package/build/es/ChunkUploader/generateFileUniqueID.js +140 -0
  20. package/build/es/ChunkUploader/index.d.ts +4 -0
  21. package/build/es/ChunkUploader/index.js +259 -0
  22. package/build/es/GlobalLoading/index.d.ts +11 -0
  23. package/build/es/GlobalLoading/index.js +32 -0
  24. package/build/es/IconButton/index.d.ts +42 -0
  25. package/build/es/IconButton/index.js +51 -0
  26. package/build/es/IconFont/index.d.ts +21 -0
  27. package/build/es/IconFont/index.js +32 -0
  28. package/build/es/LevelGroup/index.d.ts +10 -0
  29. package/build/es/LevelGroup/index.js +33 -0
  30. package/build/es/LevelTag/index.d.ts +21 -0
  31. package/build/es/LevelTag/index.js +84 -0
  32. package/build/es/SearchArea/Item/index.d.ts +13 -0
  33. package/build/es/SearchArea/Item/index.js +38 -0
  34. package/build/es/SearchArea/ToggleButton/index.d.ts +9 -0
  35. package/build/es/SearchArea/ToggleButton/index.js +24 -0
  36. package/build/es/SearchArea/index.d.ts +13 -0
  37. package/build/es/SearchArea/index.js +153 -0
  38. package/build/es/SwitchValue/index.d.ts +30 -0
  39. package/build/es/SwitchValue/index.js +36 -0
  40. package/build/es/Table/Footer/index.d.ts +3 -0
  41. package/build/es/Table/Footer/index.js +82 -0
  42. package/build/es/Table/PopoverSetColumns/index.d.ts +11 -0
  43. package/build/es/Table/PopoverSetColumns/index.js +164 -0
  44. package/build/es/Table/index.d.ts +4 -0
  45. package/build/es/Table/index.js +230 -0
  46. package/build/es/Uploader/index.d.ts +10 -0
  47. package/build/es/Uploader/index.js +175 -0
  48. package/build/es/index.d.ts +5 -0
  49. package/build/es/index.js +5 -0
  50. package/build/lib/AntdApp/index.js +19 -0
  51. package/build/lib/Button/button.js +22 -0
  52. package/build/lib/Button/index.js +7 -0
  53. package/build/lib/CheckboxValue/index.js +38 -0
  54. package/build/lib/IconButton/index.js +91 -0
  55. package/build/lib/IconFont/index.js +67 -0
  56. package/build/lib/SwitchValue/index.js +41 -0
  57. package/build/lib/index.d.ts +1 -0
  58. package/build/lib/index.js +19 -0
  59. package/build/package.json +64 -0
  60. package/package.json +47 -23
  61. package/dist/index.es.js +0 -470
  62. package/dist/index.umd.js +0 -31
  63. /package/{dist → build/dist}/vite.svg +0 -0
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ var react_1 = __importDefault(require("react"));
29
+ var classnames_1 = __importDefault(require("classnames"));
30
+ var index_module_less_1 = __importDefault(require("./index.module.less"));
31
+ var static_1 = require("@/store/static");
32
+ var utils_1 = require("@/utils");
33
+ /**
34
+ * 等级tag
35
+ * @param level
36
+ * @param type {'default' | 'license' | 'component' | 'sensitive' | 'url'}
37
+ * @param children
38
+ * @param theme
39
+ * @param attrs
40
+ * @returns {JSX.Element}
41
+ * @constructor
42
+ */
43
+ var LevelTag = function (_a) {
44
+ var _b;
45
+ var level = _a.level, _c = _a.type, type = _c === void 0 ? 'default' : _c, children = _a.children, theme = _a.theme, attrs = __rest(_a, ["level", "type", "children", "theme"]);
46
+ var levelOptions = static_1.LEVELS;
47
+ switch (type) {
48
+ case 'license':
49
+ levelOptions = static_1.LICENSE_LEVELS;
50
+ break;
51
+ case 'component':
52
+ levelOptions = static_1.COMPONENT_LEVELS;
53
+ break;
54
+ case 'sensitive':
55
+ levelOptions = static_1.SENSITIVE_LEVELS;
56
+ break;
57
+ case 'url':
58
+ levelOptions = static_1.URL_LEVELS;
59
+ break;
60
+ case 'crypto':
61
+ levelOptions = static_1.CRYPTO_LEVELS;
62
+ break;
63
+ case 'asset':
64
+ levelOptions = static_1.ASSET_LEVELS;
65
+ break;
66
+ }
67
+ var item = (0, utils_1.matching)(levelOptions, level, 'value');
68
+ var label = item.label;
69
+ var color = item.color;
70
+ return (react_1.default.createElement("span", __assign({}, attrs, { className: (0, classnames_1.default)([
71
+ theme === 'solid' ? index_module_less_1.default.level_tag_solid : index_module_less_1.default.level_tag,
72
+ (_b = {},
73
+ _b[index_module_less_1.default.severity] = color === 'serious',
74
+ _b[index_module_less_1.default.danger] = color === 'danger',
75
+ _b[index_module_less_1.default.warning] = color === 'warning',
76
+ _b[index_module_less_1.default.low] = color === 'low',
77
+ _b[index_module_less_1.default.success] = color === 'success',
78
+ _b[index_module_less_1.default.info] = color === 'info',
79
+ _b[index_module_less_1.default.gray] = color === 'gray' || !color,
80
+ _b),
81
+ attrs.className
82
+ ]), style: __assign({}, (attrs.style ? attrs.style : {})) }), children || label || '未知'));
83
+ };
84
+ exports.default = LevelTag;
@@ -0,0 +1,13 @@
1
+ import './index.less';
2
+ /**
3
+ * 筛选项
4
+ * @param children
5
+ * @param props
6
+ * @return {JSX.Element}
7
+ * @constructor
8
+ */
9
+ declare function Index({ children, ...props }: {
10
+ [x: string]: any;
11
+ children: any;
12
+ }): import("react").JSX.Element;
13
+ export default Index;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ var antd_1 = require("antd");
26
+ require("./index.less");
27
+ /**
28
+ * 筛选项
29
+ * @param children
30
+ * @param props
31
+ * @return {JSX.Element}
32
+ * @constructor
33
+ */
34
+ function Index(_a) {
35
+ var children = _a.children, props = __rest(_a, ["children"]);
36
+ return (React.createElement(antd_1.Form.Item, __assign({}, props), children));
37
+ }
38
+ exports.default = Index;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 高级筛选触发按钮
3
+ * @return {JSX.Element}
4
+ * @constructor
5
+ */
6
+ declare function ToggleButton({ panel }: {
7
+ panel: any;
8
+ }): import("react").JSX.Element;
9
+ export default ToggleButton;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var antd_1 = require("antd");
7
+ var icons_1 = require("@ant-design/icons");
8
+ var rc_tween_one_1 = __importDefault(require("rc-tween-one"));
9
+ /**
10
+ * 高级筛选触发按钮
11
+ * @return {JSX.Element}
12
+ * @constructor
13
+ */
14
+ function ToggleButton(_a) {
15
+ var panel = _a.panel;
16
+ var show = panel.show, toggle = panel.toggle;
17
+ return (React.createElement(antd_1.Button, { type: "link", style: { paddingLeft: 0, paddingRight: 0 }, onClick: toggle },
18
+ "\u9AD8\u7EA7\u641C\u7D22",
19
+ React.createElement(rc_tween_one_1.default, { component: icons_1.CaretUpOutlined, animation: {
20
+ rotate: show ? 0 : 180,
21
+ duration: 300
22
+ } })));
23
+ }
24
+ exports.default = ToggleButton;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import Item from './Item';
3
+ import ToggleButton from './ToggleButton';
4
+ import './index.less';
5
+ declare const SearchArea: React.ForwardRefExoticComponent<any> & {
6
+ Item: typeof Item;
7
+ ToggleButton: typeof ToggleButton;
8
+ useSearchArea: (show: boolean) => {
9
+ show: boolean;
10
+ toggle: () => void;
11
+ };
12
+ };
13
+ export default SearchArea;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ var __rest = (this && this.__rest) || function (s, e) {
47
+ var t = {};
48
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
49
+ t[p] = s[p];
50
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
51
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
52
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
53
+ t[p[i]] = s[p[i]];
54
+ }
55
+ return t;
56
+ };
57
+ var __importDefault = (this && this.__importDefault) || function (mod) {
58
+ return (mod && mod.__esModule) ? mod : { "default": mod };
59
+ };
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ var react_1 = __importStar(require("react"));
62
+ var antd_1 = require("antd");
63
+ var ahooks_1 = require("ahooks");
64
+ var icons_1 = require("@ant-design/icons");
65
+ var rc_tween_one_1 = __importDefault(require("rc-tween-one"));
66
+ var Item_1 = __importDefault(require("./Item"));
67
+ var ToggleButton_1 = __importDefault(require("./ToggleButton"));
68
+ require("./index.less");
69
+ /**
70
+ * 高级筛选
71
+ * @param children 子元素
72
+ * @param onSearch {function} 接收函数,点筛选时执行,返回筛选数据
73
+ * @param col 与 Col 的配置相同,控制筛选项排版
74
+ * @param row Row 的配置相同,控制筛选项排版
75
+ * @param loading {boolean} 筛选加载状态
76
+ * @param props 多余参数,绑定至 Form 上
77
+ * @param ref
78
+ * @return {JSX.Element}
79
+ * @constructor
80
+ */
81
+ function InternalSearchArea(_a, ref) {
82
+ var children = _a.children, _b = _a.onSearch, onSearch = _b === void 0 ? function (data) { } : _b, _c = _a.col, col = _c === void 0 ? {} : _c, _d = _a.row, row = _d === void 0 ? {} : _d, _e = _a.loading, loading = _e === void 0 ? false : _e, props = __rest(_a, ["children", "onSearch", "col", "row", "loading"]);
83
+ var show, toggle;
84
+ var form = antd_1.Form.useForm()[0];
85
+ if (ref) {
86
+ show = ref.show;
87
+ toggle = ref.toggle;
88
+ ref.form = form;
89
+ }
90
+ else {
91
+ var _f = (0, ahooks_1.useSafeState)(false), _show = _f[0], _setShow_1 = _f[1];
92
+ show = _show;
93
+ toggle = function () { _setShow_1(function (v) { return !v; }); };
94
+ }
95
+ /**
96
+ * 提交搜索
97
+ */
98
+ var submit = function () {
99
+ var data = form.getFieldsValue();
100
+ onSearch(data);
101
+ };
102
+ /**
103
+ * 重置
104
+ */
105
+ var reset = function () {
106
+ form.resetFields();
107
+ submit();
108
+ };
109
+ /**
110
+ * 重置
111
+ */
112
+ var close = function () {
113
+ toggle();
114
+ };
115
+ return (react_1.default.createElement(rc_tween_one_1.default, { className: "search-area-collapse", animation: {
116
+ maxHeight: show ? 450 : 0,
117
+ duration: 400
118
+ } },
119
+ react_1.default.createElement(antd_1.Form, __assign({ className: "search-area-container", form: form, labelCol: { flex: '70px' }, wrapperCol: { flex: '1', style: { maxWidth: '280px' } } }, props),
120
+ react_1.default.createElement(antd_1.Row, __assign({ gutter: 10, justify: "space-between" }, row),
121
+ Array.isArray(children)
122
+ ? children.map(function (item) {
123
+ return (react_1.default.createElement(antd_1.Col, __assign({ span: 6, xxl: 6,
124
+ xl: 8,
125
+ lg: 12,
126
+ xs: 24, key: item.props.name || item.key || item.props.label }, col), item));
127
+ })
128
+ : children,
129
+ react_1.default.createElement(antd_1.Col, { flex: 1 },
130
+ react_1.default.createElement("div", { className: "search-area-handle" },
131
+ react_1.default.createElement(antd_1.Button, { loading: loading, type: "primary", onClick: submit }, "\u7B5B\u9009"),
132
+ react_1.default.createElement(antd_1.Button, { loading: loading, onClick: reset }, "\u91CD\u7F6E"),
133
+ react_1.default.createElement(antd_1.Button, { type: "link", style: {
134
+ paddingLeft: 0,
135
+ paddingRight: 0
136
+ }, onClick: close },
137
+ "\u6536\u8D77",
138
+ react_1.default.createElement(icons_1.UpOutlined, null))))))));
139
+ }
140
+ var SearchArea = (0, react_1.forwardRef)(InternalSearchArea);
141
+ SearchArea.Item = Item_1.default;
142
+ SearchArea.ToggleButton = ToggleButton_1.default;
143
+ SearchArea.useSearchArea = function useSearchArea() {
144
+ var _a = (0, ahooks_1.useSafeState)(false), show = _a[0], setShow = _a[1];
145
+ var toggle = function () {
146
+ setShow(function (value) { return !value; });
147
+ };
148
+ return {
149
+ show: show,
150
+ toggle: toggle
151
+ };
152
+ };
153
+ exports.default = SearchArea;
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { type SwitchProps } from 'antd/es/switch';
3
+ /**
4
+ * Switch 可自定义 value
5
+ * 使用场景:
6
+ * 1. 需要自定义 value 的 switch
7
+ */
8
+ interface SwitchValueProps<T = any, F = any> extends Omit<SwitchProps, 'checked' | 'onChange'> {
9
+ /**
10
+ * 选中值
11
+ */
12
+ trueValue?: T;
13
+ /**
14
+ * 未选中值
15
+ */
16
+ falseValue?: F;
17
+ /**
18
+ * 选中值
19
+ */
20
+ checked?: T | F;
21
+ /**
22
+ * 选中事件
23
+ */
24
+ onChange?: (value: T | F, event: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
25
+ }
26
+ /**
27
+ * Switch 可自定义 value
28
+ */
29
+ declare const Index: ({ checked, onChange, trueValue, falseValue, ...props }: SwitchValueProps) => React.JSX.Element;
30
+ export default Index;
@@ -0,0 +1,36 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import React from 'react';
24
+ import { Switch } from 'antd';
25
+ /**
26
+ * Switch 可自定义 value
27
+ */
28
+ var Index = function (_a) {
29
+ var checked = _a.checked, onChange = _a.onChange, _b = _a.trueValue, trueValue = _b === void 0 ? true : _b, _c = _a.falseValue, falseValue = _c === void 0 ? false : _c, props = __rest(_a, ["checked", "onChange", "trueValue", "falseValue"]);
30
+ var _checked = checked === trueValue;
31
+ var change = function (checked, event) {
32
+ onChange === null || onChange === void 0 ? void 0 : onChange(checked ? trueValue : falseValue, event);
33
+ };
34
+ return (React.createElement(Switch, __assign({ checked: _checked, onChange: change }, props)));
35
+ };
36
+ export default Index;
@@ -0,0 +1,3 @@
1
+ import './index.less';
2
+ declare function Index(props: any): import("react").JSX.Element;
3
+ export default Index;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var react_1 = require("react");
4
+ var react_intl_1 = require("react-intl");
5
+ var antd_1 = require("antd");
6
+ var react_transition_group_1 = require("react-transition-group");
7
+ var icons_1 = require("@ant-design/icons");
8
+ require("./index.less");
9
+ function Index(props) {
10
+ var transitionNodeRef = (0, react_1.useRef)(null);
11
+ var pagination = props.pagination, _a = props.rowSelection, rowSelection = _a === void 0 ? { selectedRowKeys: [] } : _a, dataSource = props.dataSource, _b = props.selectionPopover, selectionPopover = _b === void 0 ? false : _b;
12
+ /**
13
+ * 选中所有
14
+ * @param checked 选中状态
15
+ */
16
+ var changeCheckAll = function (_a) {
17
+ var checked = _a.target.checked;
18
+ var _b = props.rowKey, rowKey = _b === void 0 ? 'id' : _b;
19
+ if (!rowSelection.onChange)
20
+ return;
21
+ if (checked) {
22
+ var getCheckboxProps_1 = rowSelection.getCheckboxProps;
23
+ var tableData = dataSource;
24
+ if (getCheckboxProps_1) {
25
+ tableData = dataSource.filter(function (item) {
26
+ var data = getCheckboxProps_1(item);
27
+ return !data.disabled;
28
+ });
29
+ }
30
+ rowSelection.onChange(tableData.map(function (item) { return item[rowKey]; }), tableData);
31
+ }
32
+ else {
33
+ rowSelection.onChange([], []);
34
+ }
35
+ };
36
+ /**
37
+ * optionalNum 可选的数量
38
+ * @return {number}
39
+ */
40
+ var optionalNum = (0, react_1.useMemo)(function () {
41
+ var getCheckboxProps = rowSelection.getCheckboxProps;
42
+ var tableData = dataSource;
43
+ if (getCheckboxProps) {
44
+ tableData = dataSource.filter(function (item) {
45
+ var data = getCheckboxProps(item);
46
+ return !data.disabled;
47
+ });
48
+ }
49
+ return tableData.length;
50
+ }, [dataSource]);
51
+ /**
52
+ * indeterminate 选了,但没全选
53
+ * @return {boolean}
54
+ */
55
+ var indeterminate = (0, react_1.useMemo)(function () {
56
+ var _a = rowSelection.selectedRowKeys, selectedRowKeys = _a === void 0 ? [] : _a;
57
+ return !!(selectedRowKeys.length > 0 && selectedRowKeys.length < optionalNum);
58
+ }, [rowSelection.selectedRowKeys]);
59
+ /**
60
+ * checked 选中状态
61
+ * @return {boolean}
62
+ */
63
+ var checked = (0, react_1.useMemo)(function () {
64
+ var _a = rowSelection.selectedRowKeys, selectedRowKeys = _a === void 0 ? [] : _a;
65
+ return !!(rowSelection.selectedRowKeys.length > 0 && selectedRowKeys.length === optionalNum);
66
+ }, [rowSelection.selectedRowKeys]);
67
+ return (React.createElement("div", { className: "table-footer" },
68
+ React.createElement(react_transition_group_1.CSSTransition, { in: (props.rowSelection && props.selectionPopover && (checked || indeterminate)), nodeRef: transitionNodeRef, classNames: "zoom", unmountOnExit: true, timeout: 300 }, function () {
69
+ return (React.createElement(antd_1.Row, { ref: transitionNodeRef, className: "table-batch-dialog", justify: "space-between" },
70
+ React.createElement(antd_1.Col, { style: { display: 'flex', alignItems: 'center' } },
71
+ React.createElement(antd_1.Checkbox, { checked: checked, indeterminate: indeterminate, onChange: changeCheckAll },
72
+ React.createElement(react_intl_1.FormattedMessage, { id: "component.table.selected", defaultMessage: '已选{length}条', values: {
73
+ length: rowSelection.selectedRowKeys.length
74
+ } }))),
75
+ React.createElement(antd_1.Col, { style: { display: 'flex', alignItems: 'center' } },
76
+ selectionPopover,
77
+ React.createElement("span", { className: "btn-close", onClick: function () { changeCheckAll({ target: { checked: false } }); } },
78
+ React.createElement(icons_1.CloseOutlined, null)))));
79
+ }),
80
+ pagination && (React.createElement("span", { className: "table-footer-total" }, pagination.showTotal(pagination.total)))));
81
+ }
82
+ exports.default = Index;
@@ -0,0 +1,11 @@
1
+ import './index.less';
2
+ declare function PopoverSetColumns({ order, visibleItems, columns, onChangeOrder, columnsVisible, columnsSort, onChangeVisible }: {
3
+ order: any;
4
+ visibleItems: any;
5
+ columns: any;
6
+ onChangeOrder: any;
7
+ columnsVisible: any;
8
+ columnsSort: any;
9
+ onChangeVisible: any;
10
+ }): import("react").JSX.Element;
11
+ export default PopoverSetColumns;
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ var react_1 = require("react");
16
+ var antd_1 = require("antd");
17
+ var react_intl_1 = require("react-intl");
18
+ var icons_1 = require("@ant-design/icons");
19
+ var AntdApp_1 = require("@/components/public/AntdApp");
20
+ var IconFont_1 = __importDefault(require("@/components/public/IconFont"));
21
+ require("./index.less");
22
+ function PopoverSetColumns(_a) {
23
+ var order = _a.order, visibleItems = _a.visibleItems, columns = _a.columns, onChangeOrder = _a.onChangeOrder, columnsVisible = _a.columnsVisible, columnsSort = _a.columnsSort, onChangeVisible = _a.onChangeVisible;
24
+ var dragged = (0, react_1.useRef)(null);
25
+ var over = (0, react_1.useRef)(null);
26
+ /**
27
+ * 开始拖拽字段
28
+ * @param event{object}
29
+ * */
30
+ var dragStart = function (event) {
31
+ dragged.current = event.currentTarget;
32
+ };
33
+ /**
34
+ * 拖拽结束
35
+ * @param event{object}
36
+ * */
37
+ var dragEnd = function (event) {
38
+ if (!over.current) {
39
+ return;
40
+ }
41
+ dragged.current.style.display = 'block';
42
+ event.target.classList.remove('drag-up');
43
+ over.current.classList.remove('drag-up');
44
+ event.target.classList.remove('drag-down');
45
+ over.current.classList.remove('drag-down');
46
+ var newOrder = __spreadArray([], order, true);
47
+ var from = Number(dragged.current.dataset.index);
48
+ var to = Number(over.current.dataset.index);
49
+ newOrder.splice(to, 0, newOrder.splice(from, 1)[0]);
50
+ onChangeOrder(newOrder);
51
+ };
52
+ /**
53
+ * 拖拽中
54
+ * @param event{object}
55
+ * */
56
+ var dragOver = function (event) {
57
+ event.preventDefault();
58
+ dragged.current.style.display = 'none';
59
+ if (event.target.tagName !== 'LI') {
60
+ return;
61
+ }
62
+ var dgIndex = dragged.current.dataset.index;
63
+ var taIndex = event.target.dataset.index;
64
+ var id = event.target.dataset.id;
65
+ if (notDraggableIds.indexOf(id) !== -1) {
66
+ return;
67
+ }
68
+ var animateName = dgIndex > taIndex ? 'drag-up' : 'drag-down';
69
+ if (over.current && event.target.dataset.index !== over.current.dataset.index) {
70
+ over.current.classList.remove('drag-up', 'drag-down');
71
+ }
72
+ if (!event.target.classList.contains(animateName)) {
73
+ event.target.classList.add(animateName);
74
+ over.current = event.target;
75
+ }
76
+ };
77
+ /**
78
+ * 拖拽中
79
+ * @param checked{boolean} 选中状态
80
+ * @param dataIndex{array|string} 列表字段(columns)的 dataIndex
81
+ * */
82
+ var changeVisible = function (_a, _b) {
83
+ var checked = _a.target.checked;
84
+ var dataIndex = _b.dataIndex;
85
+ if (visibleItems.length === 1 && !checked) {
86
+ AntdApp_1.message.error(React.createElement(react_intl_1.FormattedMessage, { id: "component.table.visibleError", defaultMessage: '列表最少保留一个字段' }));
87
+ return;
88
+ }
89
+ var id = Array.isArray(dataIndex) ? dataIndex.join(',') : dataIndex;
90
+ var newVisibleItems = __spreadArray([], visibleItems, true);
91
+ if (checked) {
92
+ newVisibleItems.push(id);
93
+ }
94
+ else {
95
+ newVisibleItems.splice(newVisibleItems.indexOf(id), 1);
96
+ }
97
+ onChangeVisible(newVisibleItems);
98
+ };
99
+ /**
100
+ * 不可拖拽字段的 dataIndex
101
+ * */
102
+ var notDraggableIds = (0, react_1.useMemo)(function () {
103
+ return columns.filter(function (item) {
104
+ return item.columnSortDisabled === true;
105
+ }).map(function (item) {
106
+ var dataIndex;
107
+ if (Array.isArray(item.dataIndex)) {
108
+ dataIndex = item.dataIndex.join(',');
109
+ }
110
+ else {
111
+ dataIndex = item.dataIndex;
112
+ }
113
+ return dataIndex;
114
+ });
115
+ }, [columns]);
116
+ /**
117
+ * 渲染到页面上的列表
118
+ * */
119
+ var renderList = (0, react_1.useMemo)(function () {
120
+ return order.map(function (item, index) {
121
+ var column;
122
+ for (var i in columns) {
123
+ var dataIndex = void 0;
124
+ if (Array.isArray(columns[i].dataIndex)) {
125
+ dataIndex = columns[i].dataIndex.join(',');
126
+ }
127
+ else {
128
+ dataIndex = columns[i].dataIndex;
129
+ }
130
+ if (item === dataIndex) {
131
+ column = columns[i];
132
+ break;
133
+ }
134
+ }
135
+ var draggable = columnsSort && column.columnSortDisabled !== true;
136
+ var id;
137
+ if (Array.isArray(column.dataIndex)) {
138
+ id = column.dataIndex.join(',');
139
+ }
140
+ else {
141
+ id = column.dataIndex;
142
+ }
143
+ var checked = visibleItems.indexOf(id) !== -1;
144
+ return column
145
+ ? (React.createElement("li", { key: column.dataIndex, draggable: draggable, onDragEnd: dragEnd, onDragStart: dragStart, "data-index": index, "data-id": column.dataIndex },
146
+ columnsSort && React.createElement(icons_1.HolderOutlined, { className: "icon-drag" }),
147
+ columnsVisible &&
148
+ React.createElement(antd_1.Checkbox, { style: { marginRight: '10px' }, checked: checked, disabled: column.columnVisibleDisabled, onChange: function (event) { changeVisible(event, column); } }),
149
+ column.title))
150
+ : '';
151
+ });
152
+ }, [order, visibleItems]);
153
+ return (React.createElement(antd_1.Popover, { overlayClassName: "table-columns-setting-popover", content: React.createElement("ul", { onDragOver: dragOver, className: "table-columns-setting-wrapper" }, renderList), trigger: "click", align: {
154
+ offset: [-60, -14]
155
+ } },
156
+ React.createElement(IconFont_1.default, { type: "icon-setting", style: {
157
+ float: 'right',
158
+ fontSize: '17px',
159
+ lineHeight: 1,
160
+ marginTop: '2px',
161
+ fontWeight: 500
162
+ } })));
163
+ }
164
+ exports.default = PopoverSetColumns;