@ccs-ui/rc-pro 1.0.0
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/LICENSE +21 -0
- package/README.md +37 -0
- package/es/auth/auth-button.js +59 -0
- package/es/auth/auth-dropdown.js +67 -0
- package/es/auth/index.js +164 -0
- package/es/ccs.js +82 -0
- package/es/color-picker/index.js +63 -0
- package/es/color-picker/index.less +9 -0
- package/es/config.js +11 -0
- package/es/context/index.js +11 -0
- package/es/date-picker/index.js +59 -0
- package/es/drawer/buttons.js +93 -0
- package/es/drawer/index.js +8 -0
- package/es/drawer/index.less +5 -0
- package/es/drawer/open/content.js +43 -0
- package/es/drawer/open/destory-fns.js +3 -0
- package/es/drawer/open/form.js +32 -0
- package/es/drawer/open/index.js +171 -0
- package/es/full-screen/index.js +57 -0
- package/es/hooks/use-event.js +67 -0
- package/es/hooks/use-global.js +10 -0
- package/es/hooks/use-once-event.js +16 -0
- package/es/hooks/use-page.js +10 -0
- package/es/hooks/use-tabs.js +10 -0
- package/es/hooks/use-window.js +10 -0
- package/es/index.js +27 -0
- package/es/interval-button/index.js +118 -0
- package/es/keep-alive-tabs/index.js +250 -0
- package/es/keep-alive-tabs/index.less +23 -0
- package/es/keep-alive-tabs/page.js +37 -0
- package/es/loading/index.js +27 -0
- package/es/modal/buttons.js +90 -0
- package/es/modal/index.js +8 -0
- package/es/modal/index.less +25 -0
- package/es/modal/open/destory-fns.js +3 -0
- package/es/modal/open/drag.js +104 -0
- package/es/modal/open/form.js +35 -0
- package/es/modal/open/index.js +93 -0
- package/es/pro-grid/context.js +4 -0
- package/es/pro-grid/index.js +88 -0
- package/es/pro-grid/index.less +29 -0
- package/es/pro-grid/useProGrid.js +10 -0
- package/es/pro-table/index.js +578 -0
- package/es/pro-table/index.less +165 -0
- package/es/pro-table/search.js +399 -0
- package/es/pro-tabs/index.js +77 -0
- package/es/pro-tabs/index.less +5 -0
- package/es/select/index.js +72 -0
- package/es/table/index.js +173 -0
- package/es/table/index.less +117 -0
- package/es/trigger/index.js +288 -0
- package/es/trigger/index.less +42 -0
- package/es/types.js +0 -0
- package/es/utils.js +205 -0
- package/es/virtual-list/index.js +125 -0
- package/es/water-mark/index.js +135 -0
- package/package.json +102 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import { Button, Form, Space } from 'antd';
|
|
8
|
+
import _memoize from 'lodash/memoize';
|
|
9
|
+
import { render as reactRender } from 'rc-util/lib/React/render';
|
|
10
|
+
import React, { useEffect, useRef } from 'react';
|
|
11
|
+
import { CcsAuth, useCcsWindow } from '..';
|
|
12
|
+
import { FnContext } from "./open/content";
|
|
13
|
+
var onGetDrawerBodyDom = _memoize(function (dom) {
|
|
14
|
+
var _parent$classList;
|
|
15
|
+
var parent = dom === null || dom === void 0 ? void 0 : dom.parentNode;
|
|
16
|
+
if (!parent) return;
|
|
17
|
+
if ((_parent$classList = parent.classList) !== null && _parent$classList !== void 0 && _parent$classList.contains("ant-drawer-wrapper-body")) {
|
|
18
|
+
return parent;
|
|
19
|
+
} else {
|
|
20
|
+
return onGetDrawerBodyDom(parent);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
export default function DrawerButton(_ref) {
|
|
24
|
+
var children = _ref.children,
|
|
25
|
+
okText = _ref.okText,
|
|
26
|
+
onOk = _ref.onOk,
|
|
27
|
+
okAuth = _ref.okAuth,
|
|
28
|
+
loading = _ref.loading;
|
|
29
|
+
var ref = useRef(null);
|
|
30
|
+
var _useCcsWindow = useCcsWindow(),
|
|
31
|
+
close = _useCcsWindow.close,
|
|
32
|
+
formInitialValues = _useCcsWindow.formInitialValues,
|
|
33
|
+
locationKey = _useCcsWindow.locationKey;
|
|
34
|
+
var form = Form.useFormInstance();
|
|
35
|
+
var onOkClick = function onOkClick() {
|
|
36
|
+
if (!onOk) return;
|
|
37
|
+
|
|
38
|
+
// form返回表单值和所有初始值
|
|
39
|
+
if (form) {
|
|
40
|
+
form.validateFields().then(function (values) {
|
|
41
|
+
onOk(_objectSpread(_objectSpread({}, formInitialValues), values));
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
onOk();
|
|
46
|
+
};
|
|
47
|
+
var renderDefaultButtom = /*#__PURE__*/React.createElement(React.Fragment, null, okAuth ? /*#__PURE__*/React.createElement(CcsAuth.Button, {
|
|
48
|
+
type: "primary",
|
|
49
|
+
onClick: onOkClick,
|
|
50
|
+
loading: loading,
|
|
51
|
+
auth: okAuth
|
|
52
|
+
}, okText || '确定') : /*#__PURE__*/React.createElement(Button, {
|
|
53
|
+
type: "primary",
|
|
54
|
+
onClick: onOkClick,
|
|
55
|
+
loading: loading
|
|
56
|
+
}, okText || '确定'), /*#__PURE__*/React.createElement(Button, {
|
|
57
|
+
style: {
|
|
58
|
+
borderRadius: 3
|
|
59
|
+
},
|
|
60
|
+
onClick: close
|
|
61
|
+
}, "\u53D6\u6D88"));
|
|
62
|
+
var timeoutId;
|
|
63
|
+
var onRenderButton = function onRenderButton() {
|
|
64
|
+
if (!onOk && !children) return;
|
|
65
|
+
if (!ref.current) return;
|
|
66
|
+
|
|
67
|
+
// get drawer body dom
|
|
68
|
+
var drawerBody = onGetDrawerBodyDom(ref.current);
|
|
69
|
+
|
|
70
|
+
// add footer
|
|
71
|
+
clearTimeout(timeoutId);
|
|
72
|
+
timeoutId = setTimeout(function () {
|
|
73
|
+
if (drawerBody !== null && drawerBody !== void 0 && drawerBody.lastChild) {
|
|
74
|
+
(drawerBody === null || drawerBody === void 0 ? void 0 : drawerBody.lastChild).classList.add('ccs-drawer-buttons');
|
|
75
|
+
reactRender( /*#__PURE__*/React.createElement(FnContext, {
|
|
76
|
+
locationKey: locationKey
|
|
77
|
+
}, /*#__PURE__*/React.createElement(Space, {
|
|
78
|
+
size: 16
|
|
79
|
+
}, children, renderDefaultButtom)), drawerBody.lastChild);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
useEffect(function () {
|
|
84
|
+
onRenderButton();
|
|
85
|
+
}, []);
|
|
86
|
+
onRenderButton();
|
|
87
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
88
|
+
style: {
|
|
89
|
+
display: 'none'
|
|
90
|
+
},
|
|
91
|
+
ref: ref
|
|
92
|
+
});
|
|
93
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ConfigProvider } from 'antd';
|
|
2
|
+
import zhCN from 'antd/locale/zh_CN';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { CCS, CcsConfigProvider } from "../..";
|
|
5
|
+
import { DrawerAndModalContext, PageContext } from "../../context";
|
|
6
|
+
export function FnContext(_ref) {
|
|
7
|
+
var children = _ref.children,
|
|
8
|
+
locationKey = _ref.locationKey;
|
|
9
|
+
var config = CCS.setDefaultConfig(CCS.GlobalConfig);
|
|
10
|
+
return /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
11
|
+
locale: zhCN,
|
|
12
|
+
theme: config.theme
|
|
13
|
+
}, /*#__PURE__*/React.createElement(CcsConfigProvider, {
|
|
14
|
+
userDetail: {}
|
|
15
|
+
}, /*#__PURE__*/React.createElement(PageContext.Provider, {
|
|
16
|
+
value: {
|
|
17
|
+
onAuth: function onAuth(e) {
|
|
18
|
+
var _CCS$UrlAuth$location;
|
|
19
|
+
return (_CCS$UrlAuth$location = CCS.UrlAuth[locationKey]) === null || _CCS$UrlAuth$location === void 0 ? void 0 : _CCS$UrlAuth$location.includes(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}, children)));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 函数式打开无法获取全局context,需重新设置,但无法获取用户信息和history
|
|
27
|
+
* 为子组件添加form,子组件可以使用useFormInstance来获取form实例
|
|
28
|
+
*/
|
|
29
|
+
export default function FnContent(_ref2) {
|
|
30
|
+
var form = _ref2.form,
|
|
31
|
+
children = _ref2.children,
|
|
32
|
+
locationKey = _ref2.locationKey,
|
|
33
|
+
close = _ref2.close;
|
|
34
|
+
return /*#__PURE__*/React.createElement(FnContext, {
|
|
35
|
+
locationKey: locationKey
|
|
36
|
+
}, /*#__PURE__*/React.createElement(DrawerAndModalContext.Provider, {
|
|
37
|
+
value: {
|
|
38
|
+
close: close,
|
|
39
|
+
locationKey: locationKey,
|
|
40
|
+
formInitialValues: (form === null || form === void 0 ? void 0 : form.initialValues) || {}
|
|
41
|
+
}
|
|
42
|
+
}, children));
|
|
43
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { Form } from 'antd';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
/**
|
|
10
|
+
* 添加form实例
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export default function DrawerForm(_ref) {
|
|
14
|
+
var children = _ref.children,
|
|
15
|
+
_ref$formProps = _ref.formProps,
|
|
16
|
+
initialValues = _ref$formProps.initialValues,
|
|
17
|
+
labelCol = _ref$formProps.labelCol,
|
|
18
|
+
wrapperCol = _ref$formProps.wrapperCol;
|
|
19
|
+
var _Form$useForm = Form.useForm(),
|
|
20
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
21
|
+
form = _Form$useForm2[0];
|
|
22
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
23
|
+
form: form,
|
|
24
|
+
initialValues: initialValues,
|
|
25
|
+
labelCol: labelCol || {
|
|
26
|
+
span: 7
|
|
27
|
+
},
|
|
28
|
+
wrapperCol: wrapperCol || {
|
|
29
|
+
span: 14
|
|
30
|
+
}
|
|
31
|
+
}, children);
|
|
32
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
8
|
+
import { LeftOutlined } from '@ant-design/icons';
|
|
9
|
+
import { Button, Divider, Drawer } from 'antd';
|
|
10
|
+
import { render as reactRender, unmount as reactUnmount } from 'rc-util/lib/React/render';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import FnContent from "./content";
|
|
13
|
+
import destroyDrawerFns from "./destory-fns";
|
|
14
|
+
import DrawerForm from "./form";
|
|
15
|
+
export default function DrawerFn(config) {
|
|
16
|
+
var container = document.createDocumentFragment();
|
|
17
|
+
var isDestroy = false;
|
|
18
|
+
var locationKey = '';
|
|
19
|
+
var open = config.open,
|
|
20
|
+
title = config.title,
|
|
21
|
+
content = config.content,
|
|
22
|
+
titleExtra = config.titleExtra,
|
|
23
|
+
getContainer = config.getContainer,
|
|
24
|
+
_config$rootStyle = config.rootStyle,
|
|
25
|
+
rootStyle = _config$rootStyle === void 0 ? {} : _config$rootStyle,
|
|
26
|
+
_config$bodyStyle = config.bodyStyle,
|
|
27
|
+
bodyStyle = _config$bodyStyle === void 0 ? {} : _config$bodyStyle,
|
|
28
|
+
_config$maskStyle = config.maskStyle,
|
|
29
|
+
maskStyle = _config$maskStyle === void 0 ? {} : _config$maskStyle,
|
|
30
|
+
_config$headerStyle = config.headerStyle,
|
|
31
|
+
headerStyle = _config$headerStyle === void 0 ? {} : _config$headerStyle,
|
|
32
|
+
_config$footerStyle = config.footerStyle,
|
|
33
|
+
footerStyle = _config$footerStyle === void 0 ? {} : _config$footerStyle,
|
|
34
|
+
_config$contentWrappe = config.contentWrapperStyle,
|
|
35
|
+
contentWrapperStyle = _config$contentWrappe === void 0 ? {} : _config$contentWrappe;
|
|
36
|
+
function afterOpenChange(open) {
|
|
37
|
+
if (config.afterOpenChange) afterOpenChange(open);
|
|
38
|
+
|
|
39
|
+
// 关闭,默认销毁组件
|
|
40
|
+
if (!open && config.destroyOnClose !== false) {
|
|
41
|
+
// 删除destroyDrawerFns关闭方法
|
|
42
|
+
for (var i = 0; i < destroyDrawerFns.length; i++) {
|
|
43
|
+
var fn = destroyDrawerFns[i];
|
|
44
|
+
if (fn === close) {
|
|
45
|
+
destroyDrawerFns.splice(i, 1);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 卸载dom
|
|
51
|
+
reactUnmount(container);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 添加关闭事件
|
|
56
|
+
function onDrawerClose(e) {
|
|
57
|
+
if (config.onClose) config.onClose(e);
|
|
58
|
+
close();
|
|
59
|
+
}
|
|
60
|
+
var renderTitle = /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
style: {
|
|
62
|
+
display: 'flex',
|
|
63
|
+
justifyContent: 'space-between'
|
|
64
|
+
}
|
|
65
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
|
|
66
|
+
icon: /*#__PURE__*/React.createElement(LeftOutlined, null),
|
|
67
|
+
type: "text",
|
|
68
|
+
style: {
|
|
69
|
+
color: '#9e9e9e',
|
|
70
|
+
padding: 0
|
|
71
|
+
},
|
|
72
|
+
size: "small",
|
|
73
|
+
onClick: function onClick() {
|
|
74
|
+
return close && close();
|
|
75
|
+
}
|
|
76
|
+
}, config.closeText), /*#__PURE__*/React.createElement(Divider, {
|
|
77
|
+
type: "vertical"
|
|
78
|
+
}), title ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
79
|
+
style: {
|
|
80
|
+
fontWeight: 500,
|
|
81
|
+
fontSize: 14
|
|
82
|
+
}
|
|
83
|
+
}, title)) : null), /*#__PURE__*/React.createElement("div", null, titleExtra));
|
|
84
|
+
var defaultConfig = {};
|
|
85
|
+
// 默认抽屉加载到当前tab下面
|
|
86
|
+
if (!('getContainer' in config)) {
|
|
87
|
+
var doms = document.body.querySelectorAll("[id*=\"_tab_content_\"][data-display=\"true\"]");
|
|
88
|
+
if (doms.length > 0) {
|
|
89
|
+
var dom = doms[0];
|
|
90
|
+
defaultConfig.getContainer = dom;
|
|
91
|
+
defaultConfig.rootStyle = _objectSpread({
|
|
92
|
+
position: 'absolute'
|
|
93
|
+
}, rootStyle);
|
|
94
|
+
defaultConfig.contentWrapperStyle = _objectSpread({
|
|
95
|
+
boxShadow: 'none'
|
|
96
|
+
}, contentWrapperStyle);
|
|
97
|
+
var id = dom.getAttribute('id');
|
|
98
|
+
locationKey = (id === null || id === void 0 ? void 0 : id.replace('_tab_content_', '')) || '';
|
|
99
|
+
} else {
|
|
100
|
+
defaultConfig.getContainer = undefined;
|
|
101
|
+
}
|
|
102
|
+
} else if (config.getContainer === false) {
|
|
103
|
+
// 命令式不能挂载到当前dom
|
|
104
|
+
defaultConfig.getContainer = undefined;
|
|
105
|
+
} else {
|
|
106
|
+
defaultConfig.getContainer = getContainer;
|
|
107
|
+
}
|
|
108
|
+
var currentConfig = _objectSpread(_objectSpread(_objectSpread({}, config), defaultConfig), {}, {
|
|
109
|
+
open: open === false ? false : true,
|
|
110
|
+
maskStyle: _objectSpread({
|
|
111
|
+
background: 'rgba(0, 0, 0, 0.1)'
|
|
112
|
+
}, maskStyle),
|
|
113
|
+
headerStyle: _objectSpread({
|
|
114
|
+
padding: '8px 10px'
|
|
115
|
+
}, headerStyle),
|
|
116
|
+
bodyStyle: _objectSpread({
|
|
117
|
+
padding: 16
|
|
118
|
+
}, bodyStyle),
|
|
119
|
+
children: content,
|
|
120
|
+
close: close,
|
|
121
|
+
afterOpenChange: afterOpenChange,
|
|
122
|
+
onClose: onDrawerClose,
|
|
123
|
+
title: renderTitle,
|
|
124
|
+
closable: false,
|
|
125
|
+
footer: /*#__PURE__*/React.createElement(React.Fragment, null),
|
|
126
|
+
footerStyle: _objectSpread({
|
|
127
|
+
padding: 0
|
|
128
|
+
}, footerStyle)
|
|
129
|
+
});
|
|
130
|
+
var timeoutId;
|
|
131
|
+
function render(props) {
|
|
132
|
+
clearTimeout(timeoutId);
|
|
133
|
+
timeoutId = setTimeout(function () {
|
|
134
|
+
var Rc = /*#__PURE__*/React.createElement(FnContent, {
|
|
135
|
+
form: config.form,
|
|
136
|
+
close: onDrawerClose,
|
|
137
|
+
locationKey: locationKey
|
|
138
|
+
}, /*#__PURE__*/React.createElement(Drawer, props));
|
|
139
|
+
reactRender(config.form ? /*#__PURE__*/React.createElement(DrawerForm, {
|
|
140
|
+
formProps: config.form
|
|
141
|
+
}, Rc) : Rc, container);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function close(open) {
|
|
145
|
+
if (isDestroy) return;
|
|
146
|
+
currentConfig = _objectSpread(_objectSpread({}, currentConfig), {}, {
|
|
147
|
+
open: open
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// 改变open状态
|
|
151
|
+
render(currentConfig);
|
|
152
|
+
}
|
|
153
|
+
function update(configUpdate) {
|
|
154
|
+
if (isDestroy) return;
|
|
155
|
+
if (typeof configUpdate === 'function') {
|
|
156
|
+
currentConfig = configUpdate(currentConfig);
|
|
157
|
+
} else {
|
|
158
|
+
currentConfig = _objectSpread(_objectSpread({}, currentConfig), configUpdate);
|
|
159
|
+
}
|
|
160
|
+
render(currentConfig);
|
|
161
|
+
}
|
|
162
|
+
render(currentConfig);
|
|
163
|
+
destroyDrawerFns.push(close);
|
|
164
|
+
return {
|
|
165
|
+
destroy: function destroy() {
|
|
166
|
+
isDestroy = true;
|
|
167
|
+
reactUnmount(container);
|
|
168
|
+
},
|
|
169
|
+
update: update
|
|
170
|
+
};
|
|
171
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons';
|
|
8
|
+
import { Button, Tooltip } from 'antd';
|
|
9
|
+
import React, { useState } from 'react';
|
|
10
|
+
import { classPrefix } from "../pro-table";
|
|
11
|
+
export default (function (_ref) {
|
|
12
|
+
var onFullScreen = _ref.onFullScreen;
|
|
13
|
+
var _useState = useState(false),
|
|
14
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15
|
+
isFull = _useState2[0],
|
|
16
|
+
setIsFull = _useState2[1];
|
|
17
|
+
var handleOnFullScreen = function handleOnFullScreen(full) {
|
|
18
|
+
var display = full ? 'none' : '';
|
|
19
|
+
var header = document.getElementsByClassName('ccs-layout-header');
|
|
20
|
+
if (header && header.length > 0) header[0].style.display = display;
|
|
21
|
+
var menu = document.getElementsByClassName('ccs-layout-menu');
|
|
22
|
+
if (menu && menu.length > 0) menu[0].style.display = display;
|
|
23
|
+
var alive = document.getElementsByClassName('ccs-keep-alive');
|
|
24
|
+
if (alive && alive.length > 0) {
|
|
25
|
+
var tabs = alive[0].getElementsByClassName('ant-tabs');
|
|
26
|
+
if (tabs && tabs.length > 0) tabs[0].style.display = display;
|
|
27
|
+
}
|
|
28
|
+
var inf = !isFull;
|
|
29
|
+
setIsFull(inf);
|
|
30
|
+
if (onFullScreen) onFullScreen(inf);
|
|
31
|
+
};
|
|
32
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
33
|
+
title: isFull ? '取消全屏' : '全屏'
|
|
34
|
+
}, isFull ? /*#__PURE__*/React.createElement(Button, {
|
|
35
|
+
onClick: function onClick() {
|
|
36
|
+
return handleOnFullScreen(false);
|
|
37
|
+
},
|
|
38
|
+
icon: /*#__PURE__*/React.createElement(FullscreenExitOutlined, {
|
|
39
|
+
className: "".concat(classPrefix, "-icon")
|
|
40
|
+
}),
|
|
41
|
+
type: "text",
|
|
42
|
+
style: {
|
|
43
|
+
width: 24
|
|
44
|
+
}
|
|
45
|
+
}) : /*#__PURE__*/React.createElement(Button, {
|
|
46
|
+
onClick: function onClick() {
|
|
47
|
+
return handleOnFullScreen(true);
|
|
48
|
+
},
|
|
49
|
+
icon: /*#__PURE__*/React.createElement(FullscreenOutlined, {
|
|
50
|
+
className: "".concat(classPrefix, "-icon")
|
|
51
|
+
}),
|
|
52
|
+
type: "text",
|
|
53
|
+
style: {
|
|
54
|
+
width: 24
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
3
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
+
import { useRef, useEffect } from 'react';
|
|
9
|
+
import _cloneDeep from 'lodash/cloneDeep';
|
|
10
|
+
import _uniqueId from 'lodash/uniqueId';
|
|
11
|
+
export var EventInstance = /*#__PURE__*/_createClass(function EventInstance() {
|
|
12
|
+
var _this = this;
|
|
13
|
+
_classCallCheck(this, EventInstance);
|
|
14
|
+
_defineProperty(this, "subscriptions", []);
|
|
15
|
+
_defineProperty(this, "emit", function (val, actionType) {
|
|
16
|
+
_this.subscriptions.forEach(function (subscription) {
|
|
17
|
+
// 未传入actionType 全部执行
|
|
18
|
+
if (actionType === undefined) {
|
|
19
|
+
var values = _cloneDeep(val);
|
|
20
|
+
subscription.record = values;
|
|
21
|
+
subscription.func(values);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 仅执行匹配的方法
|
|
26
|
+
if (actionType === subscription.type) {
|
|
27
|
+
var _values = _cloneDeep(val);
|
|
28
|
+
subscription.record = _values;
|
|
29
|
+
subscription.func(_values);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
_defineProperty(this, "useSubscription", function (callback, actionType) {
|
|
34
|
+
var _this$subscriptions$f;
|
|
35
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
36
|
+
var callbackRef = useRef(_uniqueId("_Subscription"));
|
|
37
|
+
|
|
38
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
_this.subscriptions.push({
|
|
41
|
+
id: callbackRef.current,
|
|
42
|
+
func: callback,
|
|
43
|
+
type: actionType
|
|
44
|
+
});
|
|
45
|
+
return function () {
|
|
46
|
+
_this.subscriptions = _this.subscriptions.filter(function (sub) {
|
|
47
|
+
return sub.id !== callbackRef.current;
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
}, []);
|
|
51
|
+
return ((_this$subscriptions$f = _this.subscriptions.find(function (s) {
|
|
52
|
+
return s.id === callbackRef.current;
|
|
53
|
+
})) === null || _this$subscriptions$f === void 0 ? void 0 : _this$subscriptions$f.record) || {};
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 组件消息订阅方式传值
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
export default function Event() {
|
|
62
|
+
var ref = useRef();
|
|
63
|
+
if (!ref.current) {
|
|
64
|
+
ref.current = new EventInstance();
|
|
65
|
+
}
|
|
66
|
+
return ref.current;
|
|
67
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { GlobalContext } from "../context";
|
|
3
|
+
var useGlobal = function useGlobal() {
|
|
4
|
+
var context = useContext(GlobalContext);
|
|
5
|
+
if (context === undefined) {
|
|
6
|
+
throw new Error('GlobalContext not found');
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
export default useGlobal;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
var useOnceEvent = function useOnceEvent(fn) {
|
|
4
|
+
var ref = useRef(false);
|
|
5
|
+
var fnc = function fnc() {
|
|
6
|
+
if (!ref.current) {
|
|
7
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8
|
+
args[_key] = arguments[_key];
|
|
9
|
+
}
|
|
10
|
+
fn(args);
|
|
11
|
+
ref.current = true;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
return fnc;
|
|
15
|
+
};
|
|
16
|
+
export default useOnceEvent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { PageContext } from "../context";
|
|
3
|
+
var usePage = function usePage() {
|
|
4
|
+
var context = useContext(PageContext);
|
|
5
|
+
if (context === undefined) {
|
|
6
|
+
throw new Error('PageContext not found');
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
export default usePage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { TabsContext } from "../context";
|
|
3
|
+
var useTabs = function useTabs() {
|
|
4
|
+
var context = useContext(TabsContext);
|
|
5
|
+
if (context === undefined) {
|
|
6
|
+
throw new Error('TabsContext not found');
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
export default useTabs;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { DrawerAndModalContext } from "../context";
|
|
3
|
+
var useCcsWindow = function useCcsWindow() {
|
|
4
|
+
var context = useContext(DrawerAndModalContext);
|
|
5
|
+
if (context === undefined) {
|
|
6
|
+
throw new Error('DrawerAndModalContext not found');
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
export default useCcsWindow;
|
package/es/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// any param
|
|
2
|
+
|
|
3
|
+
export { default as CcsAuth } from "./auth";
|
|
4
|
+
export { default as CCS } from "./ccs";
|
|
5
|
+
export { default as CcsColorPicker } from "./color-picker";
|
|
6
|
+
export { default as CcsConfigProvider } from "./config";
|
|
7
|
+
export { default as CcsDatePicker } from "./date-picker";
|
|
8
|
+
export { default as CcsDrawer } from "./drawer";
|
|
9
|
+
export { default as CcsFullScreenButton } from "./full-screen";
|
|
10
|
+
export { default as useCcsGlobal } from "./hooks/use-global";
|
|
11
|
+
export { default as useCcsOnceEvent } from "./hooks/use-once-event";
|
|
12
|
+
export { default as useCcsPage } from "./hooks/use-page";
|
|
13
|
+
export { default as useCcsTabsChange } from "./hooks/use-tabs";
|
|
14
|
+
export { default as useCcsWindow } from "./hooks/use-window";
|
|
15
|
+
export { default as CcsIntervalButton } from "./interval-button";
|
|
16
|
+
export { default as CcsKeepAliveTabs } from "./keep-alive-tabs";
|
|
17
|
+
export { default as CcsLoading } from "./loading";
|
|
18
|
+
export { default as CcsModal } from "./modal";
|
|
19
|
+
export { default as CcsProGrid } from "./pro-grid";
|
|
20
|
+
export { default as CcsProTable } from "./pro-table";
|
|
21
|
+
export { default as CcsProTabs } from "./pro-tabs";
|
|
22
|
+
export { default as CcsApiSelect } from "./select";
|
|
23
|
+
export { default as CcsTable } from "./table";
|
|
24
|
+
export { default as CcsTrigger } from "./trigger";
|
|
25
|
+
export { default as CcsUtils } from "./utils";
|
|
26
|
+
export { default as CcsVirtualList } from "./virtual-list";
|
|
27
|
+
export { default as CcsWaterMark } from "./water-mark";
|