@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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/es/auth/auth-button.js +59 -0
  4. package/es/auth/auth-dropdown.js +67 -0
  5. package/es/auth/index.js +164 -0
  6. package/es/ccs.js +82 -0
  7. package/es/color-picker/index.js +63 -0
  8. package/es/color-picker/index.less +9 -0
  9. package/es/config.js +11 -0
  10. package/es/context/index.js +11 -0
  11. package/es/date-picker/index.js +59 -0
  12. package/es/drawer/buttons.js +93 -0
  13. package/es/drawer/index.js +8 -0
  14. package/es/drawer/index.less +5 -0
  15. package/es/drawer/open/content.js +43 -0
  16. package/es/drawer/open/destory-fns.js +3 -0
  17. package/es/drawer/open/form.js +32 -0
  18. package/es/drawer/open/index.js +171 -0
  19. package/es/full-screen/index.js +57 -0
  20. package/es/hooks/use-event.js +67 -0
  21. package/es/hooks/use-global.js +10 -0
  22. package/es/hooks/use-once-event.js +16 -0
  23. package/es/hooks/use-page.js +10 -0
  24. package/es/hooks/use-tabs.js +10 -0
  25. package/es/hooks/use-window.js +10 -0
  26. package/es/index.js +27 -0
  27. package/es/interval-button/index.js +118 -0
  28. package/es/keep-alive-tabs/index.js +250 -0
  29. package/es/keep-alive-tabs/index.less +23 -0
  30. package/es/keep-alive-tabs/page.js +37 -0
  31. package/es/loading/index.js +27 -0
  32. package/es/modal/buttons.js +90 -0
  33. package/es/modal/index.js +8 -0
  34. package/es/modal/index.less +25 -0
  35. package/es/modal/open/destory-fns.js +3 -0
  36. package/es/modal/open/drag.js +104 -0
  37. package/es/modal/open/form.js +35 -0
  38. package/es/modal/open/index.js +93 -0
  39. package/es/pro-grid/context.js +4 -0
  40. package/es/pro-grid/index.js +88 -0
  41. package/es/pro-grid/index.less +29 -0
  42. package/es/pro-grid/useProGrid.js +10 -0
  43. package/es/pro-table/index.js +578 -0
  44. package/es/pro-table/index.less +165 -0
  45. package/es/pro-table/search.js +399 -0
  46. package/es/pro-tabs/index.js +77 -0
  47. package/es/pro-tabs/index.less +5 -0
  48. package/es/select/index.js +72 -0
  49. package/es/table/index.js +173 -0
  50. package/es/table/index.less +117 -0
  51. package/es/trigger/index.js +288 -0
  52. package/es/trigger/index.less +42 -0
  53. package/es/types.js +0 -0
  54. package/es/utils.js +205 -0
  55. package/es/virtual-list/index.js +125 -0
  56. package/es/water-mark/index.js +135 -0
  57. package/package.json +102 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Dx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # @ccs-ui/rc-pro
2
+
3
+ A react library developed with dumi
4
+
5
+ ## Usage
6
+
7
+ TODO
8
+
9
+ ## Options
10
+
11
+ TODO
12
+
13
+ ## Development
14
+
15
+ ```bash
16
+ # install dependencies
17
+ $ yarn install
18
+
19
+ # develop library by docs demo
20
+ $ yarn start
21
+
22
+ # build library source code
23
+ $ yarn run build
24
+
25
+ # build library source code in watch mode
26
+ $ yarn run build:watch
27
+
28
+ # build docs
29
+ $ yarn run docs:build
30
+
31
+ # check your project for potential problems
32
+ $ yarn run doctor
33
+ ```
34
+
35
+ ## LICENSE
36
+
37
+ MIT
@@ -0,0 +1,59 @@
1
+ var _excluded = ["auth", "text", "confirm", "onClick"];
2
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
+ 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; }
4
+ 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; }
5
+ import { ExclamationCircleOutlined } from '@ant-design/icons';
6
+ import { Button } from 'antd';
7
+ import React, { useRef } from 'react';
8
+ import { ModalConfirm } from '.';
9
+ import { CCS, useCcsPage } from "../";
10
+ /**
11
+ * 带权限的按钮组件、继承Ant Button所有属性
12
+ * @param CcsAuthButtonProps
13
+ * @returns
14
+ */
15
+ export default (function (_ref) {
16
+ var auth = _ref.auth,
17
+ text = _ref.text,
18
+ confirm = _ref.confirm,
19
+ _onClick = _ref.onClick,
20
+ restProps = _objectWithoutProperties(_ref, _excluded);
21
+ var _ref2 = useCcsPage() || {},
22
+ onAuth = _ref2.onAuth;
23
+ var IsAuthButton = CCS.GlobalConfig.IsAuthButton;
24
+ var modalRef = useRef(null);
25
+ var button = /*#__PURE__*/React.createElement(Button, _extends({}, restProps, {
26
+ onClick: function onClick(e) {
27
+ if (!_onClick) return;
28
+ if (confirm) {
29
+ var _modalRef$current;
30
+ (_modalRef$current = modalRef.current) === null || _modalRef$current === void 0 ? void 0 : _modalRef$current.confirm({
31
+ title: '操作确认',
32
+ icon: /*#__PURE__*/React.createElement(ExclamationCircleOutlined, null),
33
+ centered: true,
34
+ content: confirm,
35
+ okText: '确认',
36
+ cancelText: '取消',
37
+ onOk: function onOk() {
38
+ return _onClick(e);
39
+ }
40
+ });
41
+ return;
42
+ }
43
+ _onClick(e);
44
+ }
45
+ }), text, restProps.children);
46
+
47
+ // 不控制权限或没有传auth
48
+ if (!IsAuthButton || !auth) {
49
+ return /*#__PURE__*/React.createElement(React.Fragment, null, button, !!confirm ? /*#__PURE__*/React.createElement(ModalConfirm, {
50
+ modalRef: modalRef
51
+ }) : null);
52
+ }
53
+
54
+ // 当前菜单下查找按钮权限
55
+ var hasAuth = onAuth && onAuth(auth);
56
+ return /*#__PURE__*/React.createElement(React.Fragment, null, hasAuth ? button : /*#__PURE__*/React.createElement(React.Fragment, null), !!confirm ? /*#__PURE__*/React.createElement(ModalConfirm, {
57
+ modalRef: modalRef
58
+ }) : null);
59
+ });
@@ -0,0 +1,67 @@
1
+ var _excluded = ["auth", "menus", "children", "onClick"];
2
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
+ 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; }
4
+ 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; }
5
+ import { Dropdown } from 'antd';
6
+ import React, { useMemo } from 'react';
7
+ import { CCS, useCcsPage } from "../";
8
+ /**
9
+ * 带权限的Dropdown组件
10
+ */
11
+ export default (function (_ref) {
12
+ var auth = _ref.auth,
13
+ _ref$menus = _ref.menus,
14
+ menus = _ref$menus === void 0 ? [] : _ref$menus,
15
+ children = _ref.children,
16
+ onClick = _ref.onClick,
17
+ restProps = _objectWithoutProperties(_ref, _excluded);
18
+ var _ref2 = useCcsPage() || {},
19
+ onAuth = _ref2.onAuth;
20
+ var IsAuthButton = CCS.GlobalConfig.IsAuthButton;
21
+ var items = useMemo(function () {
22
+ function filterTreeArray(menuItems) {
23
+ var mis = menuItems.filter(function (item) {
24
+ if (!item.auth) {
25
+ return true;
26
+ }
27
+ // 传入auth 判断是否有权限
28
+ var btn = onAuth && onAuth(item.auth);
29
+ return btn ? true : false;
30
+ });
31
+ return mis.map(function (mi) {
32
+ var item = Object.assign({}, mi);
33
+ if (item.children) {
34
+ var child = filterTreeArray(item.children);
35
+ item.children = child.length > 0 ? child : null;
36
+ }
37
+ return item;
38
+ }).filter(function (m) {
39
+ return m.children !== null;
40
+ });
41
+ }
42
+ if (IsAuthButton) {
43
+ return filterTreeArray(menus);
44
+ }
45
+ return menus;
46
+ }, [menus.map(function (m) {
47
+ return m === null || m === void 0 ? void 0 : m.key;
48
+ }).join(',')]);
49
+ var renderChildren = useMemo(function () {
50
+ if (!auth || !IsAuthButton) {
51
+ return children;
52
+ }
53
+ var btn = onAuth && onAuth(auth);
54
+ if (btn) {
55
+ return children;
56
+ }
57
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
58
+ }, []);
59
+ return items.filter(function (i) {
60
+ return i.type !== 'divider';
61
+ }).length ? /*#__PURE__*/React.createElement(Dropdown, _extends({}, restProps, {
62
+ menu: {
63
+ items: items,
64
+ onClick: onClick
65
+ }
66
+ }), renderChildren) : /*#__PURE__*/React.createElement(React.Fragment, null);
67
+ });
@@ -0,0 +1,164 @@
1
+ var _excluded = ["key", "label"],
2
+ _excluded2 = ["key", "label"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ 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; }
5
+ 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; }
6
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+ 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."); }
12
+ 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); }
13
+ 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; }
14
+ 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; } }
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+ import { EllipsisOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
17
+ import { Button, Dropdown, Modal, Space } from 'antd';
18
+ import React, { useEffect, useRef } from 'react';
19
+ import { CCS, useCcsPage } from '..';
20
+ import AuthButton from "./auth-button";
21
+ import AuthDropdown from "./auth-dropdown";
22
+ export function ModalConfirm(_ref) {
23
+ var modalRef = _ref.modalRef;
24
+ var _Modal$useModal = Modal.useModal(),
25
+ _Modal$useModal2 = _slicedToArray(_Modal$useModal, 2),
26
+ modal = _Modal$useModal2[0],
27
+ contextHolder = _Modal$useModal2[1];
28
+ useEffect(function () {
29
+ modalRef.current = modal;
30
+ }, []);
31
+ return /*#__PURE__*/React.createElement(React.Fragment, null, " ", contextHolder);
32
+ }
33
+ function CcsAuth(_ref2) {
34
+ var auth = _ref2.auth,
35
+ children = _ref2.children;
36
+ var _ref3 = useCcsPage() || {},
37
+ onAuth = _ref3.onAuth;
38
+ var IsAuthButton = CCS.GlobalConfig.IsAuthButton;
39
+ if (IsAuthButton && onAuth && auth) {
40
+ return onAuth(auth) ? children : null;
41
+ }
42
+ return children;
43
+ }
44
+ function AuthGroup(_ref4) {
45
+ var size = _ref4.size,
46
+ isLink = _ref4.isLink,
47
+ showCount = _ref4.showCount,
48
+ moreIcon = _ref4.moreIcon,
49
+ moreText = _ref4.moreText,
50
+ items = _ref4.items,
51
+ onClick = _ref4.onClick;
52
+ var _ref5 = useCcsPage() || {},
53
+ onAuth = _ref5.onAuth;
54
+ var IsAuthButton = CCS.GlobalConfig.IsAuthButton;
55
+ var modalRef = useRef(null);
56
+ if (!items || items.length === 0) return null;
57
+ var authButtons = [];
58
+ // 需要判断权限
59
+ if (IsAuthButton && onAuth) {
60
+ authButtons = items.filter(function (b) {
61
+ if (b.auth) return onAuth(b.auth);
62
+ return true;
63
+ });
64
+ } else {
65
+ authButtons = _toConsumableArray(items);
66
+ }
67
+
68
+ // 当前菜单下查找按钮权限
69
+ var showBtns = authButtons.splice(0, showCount || items.length);
70
+ var handleOnClick = function handleOnClick(key) {
71
+ if (!onClick) return;
72
+ var item = items.find(function (i) {
73
+ return i.key === key;
74
+ });
75
+ if (item && item.confirm) {
76
+ var _modalRef$current;
77
+ (_modalRef$current = modalRef.current) === null || _modalRef$current === void 0 ? void 0 : _modalRef$current.confirm({
78
+ title: '操作确认',
79
+ icon: /*#__PURE__*/React.createElement(ExclamationCircleOutlined, null),
80
+ centered: true,
81
+ content: item.confirm,
82
+ okText: '确认',
83
+ cancelText: '取消',
84
+ onOk: function onOk() {
85
+ return onClick && onClick(key);
86
+ }
87
+ });
88
+ return;
89
+ }
90
+ onClick(key);
91
+ };
92
+ if (isLink) {
93
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Space, null, showBtns === null || showBtns === void 0 ? void 0 : showBtns.map(function (_ref6) {
94
+ var key = _ref6.key,
95
+ label = _ref6.label,
96
+ restProps = _objectWithoutProperties(_ref6, _excluded);
97
+ return /*#__PURE__*/React.createElement(Button, _extends({
98
+ key: key
99
+ }, restProps, {
100
+ size: size,
101
+ type: "link",
102
+ onClick: function onClick() {
103
+ return handleOnClick(key);
104
+ }
105
+ }), label);
106
+ })), authButtons.length > 0 && /*#__PURE__*/React.createElement(Dropdown, {
107
+ menu: {
108
+ items: authButtons,
109
+ onClick: function onClick(e) {
110
+ return handleOnClick(e.key);
111
+ }
112
+ }
113
+ }, /*#__PURE__*/React.createElement(Button, {
114
+ type: "link",
115
+ icon: moreText ? null : moreIcon || /*#__PURE__*/React.createElement(EllipsisOutlined, null),
116
+ size: "small"
117
+ }, moreText)), items.find(function (i) {
118
+ return !!i.confirm;
119
+ }) ? /*#__PURE__*/React.createElement(ModalConfirm, {
120
+ modalRef: modalRef
121
+ }) : null);
122
+ }
123
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Space, null, showBtns === null || showBtns === void 0 ? void 0 : showBtns.map(function (_ref7, index) {
124
+ var key = _ref7.key,
125
+ label = _ref7.label,
126
+ restProps = _objectWithoutProperties(_ref7, _excluded2);
127
+ // 更多按钮
128
+ if (index === showBtns.length - 1 && authButtons.length > 0) {
129
+ return /*#__PURE__*/React.createElement(Space.Compact, {
130
+ key: key
131
+ }, /*#__PURE__*/React.createElement(Button, _extends({}, restProps, {
132
+ size: size,
133
+ onClick: function onClick() {
134
+ return handleOnClick(key);
135
+ }
136
+ }), label), /*#__PURE__*/React.createElement(Dropdown, {
137
+ menu: {
138
+ items: authButtons,
139
+ onClick: function onClick(e) {
140
+ return handleOnClick(e.key);
141
+ }
142
+ }
143
+ }, /*#__PURE__*/React.createElement(Button, {
144
+ icon: moreText ? null : moreIcon || /*#__PURE__*/React.createElement(EllipsisOutlined, null)
145
+ }, moreText)));
146
+ }
147
+ return /*#__PURE__*/React.createElement(Button, _extends({
148
+ key: key
149
+ }, restProps, {
150
+ size: size,
151
+ onClick: function onClick() {
152
+ return handleOnClick(key);
153
+ }
154
+ }), label);
155
+ })), items.find(function (i) {
156
+ return !!i.confirm;
157
+ }) ? /*#__PURE__*/React.createElement(ModalConfirm, {
158
+ modalRef: modalRef
159
+ }) : null);
160
+ }
161
+ CcsAuth.Group = AuthGroup;
162
+ CcsAuth.Button = AuthButton;
163
+ CcsAuth.Dropdown = AuthDropdown;
164
+ export default CcsAuth;
package/es/ccs.js ADDED
@@ -0,0 +1,82 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ 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); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
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
+ var defaultConfig = {
9
+ theme: {
10
+ token: {
11
+ colorPrimary: '#1677ff',
12
+ borderRadius: 3
13
+ },
14
+ hashed: true
15
+ },
16
+ classPrefix: 'ccs'
17
+ };
18
+ var ccs = /*#__PURE__*/function () {
19
+ function ccs() {
20
+ _classCallCheck(this, ccs);
21
+ }
22
+ _createClass(ccs, null, [{
23
+ key: "setCustomIcon",
24
+ value: /** 自定义按钮 */
25
+
26
+ /** 按钮权限 */
27
+
28
+ /** 全局配置 */
29
+
30
+ /** 添加自定义icon */
31
+ function setCustomIcon(_icons) {
32
+ console.log('_icons', _icons);
33
+
34
+ // this.icons = this.icons.concat(icons);
35
+ // icons.forEach((icon) => {
36
+ // if (['TableFilter', 'TableReset', 'TableColumn'].includes(icon.name)) {
37
+ // this.proTableIcon[icon.name] = icon.node;
38
+ // } else {
39
+ // this.icons.push(icon);
40
+ // }
41
+ // });
42
+ }
43
+
44
+ /** 设置全局配置 */
45
+ }, {
46
+ key: "setGlobalConfig",
47
+ value: function setGlobalConfig(e) {
48
+ this.GlobalConfig = e;
49
+ }
50
+
51
+ /** 添加权限数据 */
52
+ }, {
53
+ key: "setAuthList",
54
+ value: function setAuthList(e, auths) {
55
+ this.UrlAuth[e] = auths;
56
+ }
57
+
58
+ /** 清空权限 */
59
+ }, {
60
+ key: "clearAuthList",
61
+ value: function clearAuthList() {
62
+ this.UrlAuth = {};
63
+ }
64
+
65
+ /** 系统配置 */
66
+ }, {
67
+ key: "setDefaultConfig",
68
+ value: function setDefaultConfig(config) {
69
+ Object.keys(defaultConfig).forEach(function (key) {
70
+ if (config[key] === undefined) {
71
+ config[key] = defaultConfig[key];
72
+ }
73
+ });
74
+ return config;
75
+ }
76
+ }]);
77
+ return ccs;
78
+ }();
79
+ _defineProperty(ccs, "CustomIcon", []);
80
+ _defineProperty(ccs, "UrlAuth", {});
81
+ _defineProperty(ccs, "GlobalConfig", {});
82
+ export { ccs as default };
@@ -0,0 +1,63 @@
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
+ 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(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; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ /* eslint-disable @typescript-eslint/ban-types */
14
+ import { Popover } from 'antd';
15
+ import React, { useState } from 'react';
16
+ import { SketchPicker } from 'react-color';
17
+ import "./index.less";
18
+ /**
19
+ * 颜色选择组件
20
+ */
21
+ var ColorPicker = function ColorPicker(_ref) {
22
+ var onChange = _ref.onChange,
23
+ value = _ref.value,
24
+ style = _ref.style;
25
+ var _useState = useState(false),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ open = _useState2[0],
28
+ setOpen = _useState2[1];
29
+ var handleChange = function handleChange(e) {
30
+ if (onChange) onChange(e.rgb);
31
+ setOpen(false);
32
+ };
33
+ return /*#__PURE__*/React.createElement("div", {
34
+ style: {
35
+ position: 'relative'
36
+ }
37
+ }, /*#__PURE__*/React.createElement(Popover, {
38
+ open: open,
39
+ content: /*#__PURE__*/React.createElement(SketchPicker, {
40
+ color: value,
41
+ onChange: handleChange
42
+ })
43
+ }, /*#__PURE__*/React.createElement("div", {
44
+ style: _objectSpread({
45
+ height: 32,
46
+ padding: '4px 11px',
47
+ border: '1px solid #d9d9d9',
48
+ borderRadius: 3,
49
+ display: 'flex'
50
+ }, style)
51
+ }, /*#__PURE__*/React.createElement("div", {
52
+ onClick: function onClick() {
53
+ return setOpen(!open);
54
+ },
55
+ style: {
56
+ border: '1px solid #777',
57
+ background: "rgb(".concat(value === null || value === void 0 ? void 0 : value.r, ",").concat(value === null || value === void 0 ? void 0 : value.g, ",").concat(value === null || value === void 0 ? void 0 : value.b, ",").concat(value === null || value === void 0 ? void 0 : value.a, ")"),
58
+ width: '100%',
59
+ margin: '4px 0'
60
+ }
61
+ }))));
62
+ };
63
+ export default ColorPicker;
@@ -0,0 +1,9 @@
1
+ .sketch-picker {
2
+ width: 250px !important;
3
+ box-shadow: none !important;
4
+ padding: 0 !important;
5
+ }
6
+
7
+ .flexbox-fix div {
8
+ padding-left: 0 !important;
9
+ }
package/es/config.js ADDED
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { GlobalContext } from "./context";
3
+ export default (function (_ref) {
4
+ var userDetail = _ref.userDetail,
5
+ children = _ref.children;
6
+ return /*#__PURE__*/React.createElement(GlobalContext.Provider, {
7
+ value: {
8
+ userDetail: userDetail
9
+ }
10
+ }, children);
11
+ });
@@ -0,0 +1,11 @@
1
+ import React, { createContext } from 'react';
2
+ var GlobalContext = /*#__PURE__*/createContext({});
3
+ var DrawerAndModalContext = /*#__PURE__*/createContext({});
4
+ var PageContext = /*#__PURE__*/createContext({});
5
+ var TabsContext = /*#__PURE__*/React.createContext({
6
+ items: [],
7
+ activeKey: '',
8
+ option: {},
9
+ onChange: function onChange() {}
10
+ });
11
+ export { TabsContext, PageContext, GlobalContext, DrawerAndModalContext };
@@ -0,0 +1,59 @@
1
+ var _excluded = ["value", "onChange"],
2
+ _excluded2 = ["value", "onChange"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
+ 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."); }
6
+ 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); }
7
+ 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; }
8
+ 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; } }
9
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
+ 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; }
11
+ 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; }
12
+ import { DatePicker } from 'antd';
13
+ import dayjs from 'dayjs';
14
+ import _isArray from 'lodash/isArray';
15
+ import React, { useState } from 'react';
16
+ function CcsDatePicker(_ref) {
17
+ var value = _ref.value,
18
+ onChange = _ref.onChange,
19
+ restProps = _objectWithoutProperties(_ref, _excluded);
20
+ var _useState = useState(function () {
21
+ if (typeof value === 'string') {
22
+ return dayjs(value);
23
+ }
24
+ }),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ dateValue = _useState2[0],
27
+ setDateValue = _useState2[1];
28
+ var handleOnChange = function handleOnChange(date, dateString) {
29
+ setDateValue(date || undefined);
30
+ if (onChange) onChange(dateString);
31
+ };
32
+ return /*#__PURE__*/React.createElement(DatePicker, _extends({
33
+ value: dateValue,
34
+ onChange: handleOnChange
35
+ }, restProps));
36
+ }
37
+ function RangPicker(_ref2) {
38
+ var value = _ref2.value,
39
+ onChange = _ref2.onChange,
40
+ restProps = _objectWithoutProperties(_ref2, _excluded2);
41
+ var _useState3 = useState(function () {
42
+ if (_isArray(value)) {
43
+ return [dayjs(value[0]), dayjs(value[1])];
44
+ }
45
+ }),
46
+ _useState4 = _slicedToArray(_useState3, 2),
47
+ dateValue = _useState4[0],
48
+ setDateValue = _useState4[1];
49
+ var handleOnChange = function handleOnChange(date, dateString) {
50
+ setDateValue(date);
51
+ if (onChange) onChange(dateString);
52
+ };
53
+ return /*#__PURE__*/React.createElement(DatePicker.RangePicker, _extends({
54
+ value: dateValue,
55
+ onChange: handleOnChange
56
+ }, restProps));
57
+ }
58
+ CcsDatePicker.RangPicker = RangPicker;
59
+ export default CcsDatePicker;