@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
@@ -0,0 +1,135 @@
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
+ import { ConfigProvider } from 'antd';
14
+ import classNames from 'classnames';
15
+ import React, { useContext, useEffect, useState } from 'react';
16
+ /**
17
+ * 返回当前显示设备的物理像素分辨率与CSS像素分辨率之比
18
+ *
19
+ * @param context
20
+ * @see api 有些废弃了,其实类型 CanvasRenderingContext2D
21
+ */
22
+ var getPixelRatio = function getPixelRatio(context) {
23
+ if (!context) {
24
+ return 1;
25
+ }
26
+ var backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1;
27
+ return (window.devicePixelRatio || 1) / backingStore;
28
+ };
29
+
30
+ /**
31
+ * 水印组件
32
+ * @param WaterMarkProps
33
+ * @returns
34
+ */
35
+ var WaterMarkComponent = function WaterMarkComponent(props) {
36
+ var children = props.children,
37
+ style = props.style,
38
+ className = props.className,
39
+ markStyle = props.markStyle,
40
+ markClassName = props.markClassName,
41
+ _props$zIndex = props.zIndex,
42
+ zIndex = _props$zIndex === void 0 ? 9 : _props$zIndex,
43
+ _props$gapX = props.gapX,
44
+ gapX = _props$gapX === void 0 ? 212 : _props$gapX,
45
+ _props$gapY = props.gapY,
46
+ gapY = _props$gapY === void 0 ? 222 : _props$gapY,
47
+ _props$width = props.width,
48
+ width = _props$width === void 0 ? 120 : _props$width,
49
+ _props$height = props.height,
50
+ height = _props$height === void 0 ? 64 : _props$height,
51
+ _props$rotate = props.rotate,
52
+ rotate = _props$rotate === void 0 ? -22 : _props$rotate,
53
+ image = props.image,
54
+ content = props.content,
55
+ offsetLeft = props.offsetLeft,
56
+ offsetTop = props.offsetTop,
57
+ _props$fontStyle = props.fontStyle,
58
+ fontStyle = _props$fontStyle === void 0 ? 'normal' : _props$fontStyle,
59
+ _props$fontWeight = props.fontWeight,
60
+ fontWeight = _props$fontWeight === void 0 ? 'normal' : _props$fontWeight,
61
+ _props$fontColor = props.fontColor,
62
+ fontColor = _props$fontColor === void 0 ? 'rgba(0,0,0,.15)' : _props$fontColor,
63
+ _props$fontSize = props.fontSize,
64
+ fontSize = _props$fontSize === void 0 ? 16 : _props$fontSize,
65
+ _props$fontFamily = props.fontFamily,
66
+ fontFamily = _props$fontFamily === void 0 ? 'sans-serif' : _props$fontFamily,
67
+ customizePrefixCls = props.prefixCls;
68
+ var _useContext = useContext(ConfigProvider.ConfigContext),
69
+ getPrefixCls = _useContext.getPrefixCls;
70
+ var prefixCls = getPrefixCls('pro-layout-watermark', customizePrefixCls);
71
+ var wrapperCls = classNames("".concat(prefixCls, "-wrapper"), className);
72
+ var waterMakrCls = classNames(prefixCls, markClassName);
73
+ var _useState = useState(''),
74
+ _useState2 = _slicedToArray(_useState, 2),
75
+ base64Url = _useState2[0],
76
+ setBase64Url = _useState2[1];
77
+ useEffect(function () {
78
+ var canvas = document.createElement('canvas');
79
+ var ctx = canvas.getContext('2d');
80
+ var ratio = getPixelRatio(ctx);
81
+ var canvasWidth = "".concat((gapX + width) * ratio, "px");
82
+ var canvasHeight = "".concat((gapY + height) * ratio, "px");
83
+ var canvasOffsetLeft = offsetLeft || gapX / 2;
84
+ var canvasOffsetTop = offsetTop || gapY / 2;
85
+ canvas.setAttribute('width', canvasWidth);
86
+ canvas.setAttribute('height', canvasHeight);
87
+ if (ctx) {
88
+ // 旋转字符 rotate
89
+ ctx.translate(canvasOffsetLeft * ratio, canvasOffsetTop * ratio);
90
+ ctx.rotate(Math.PI / 180 * Number(rotate));
91
+ var markWidth = width * ratio;
92
+ var markHeight = height * ratio;
93
+ if (image) {
94
+ var img = new Image();
95
+ img.crossOrigin = 'anonymous';
96
+ img.referrerPolicy = 'no-referrer';
97
+ img.src = image;
98
+ img.onload = function () {
99
+ ctx.drawImage(img, 0, 0, markWidth, markHeight);
100
+ setBase64Url(canvas.toDataURL());
101
+ };
102
+ } else if (content) {
103
+ var markSize = Number(fontSize) * ratio;
104
+ ctx.font = "".concat(fontStyle, " normal ").concat(fontWeight, " ").concat(markSize, "px/").concat(markHeight, "px ").concat(fontFamily);
105
+ ctx.fillStyle = fontColor;
106
+ ctx.fillText(content, 0, 0);
107
+ setBase64Url(canvas.toDataURL());
108
+ }
109
+ } else {
110
+ // eslint-disable-next-line no-console
111
+ console.error('当前环境不支持Canvas');
112
+ }
113
+ }, [gapX, gapY, offsetLeft, offsetTop, rotate, fontStyle, fontWeight, width, height, fontFamily, fontColor, image, content, fontSize]);
114
+ return /*#__PURE__*/React.createElement("div", {
115
+ style: _objectSpread({
116
+ position: 'relative'
117
+ }, style),
118
+ className: wrapperCls
119
+ }, children, base64Url && /*#__PURE__*/React.createElement("div", {
120
+ className: waterMakrCls,
121
+ style: _objectSpread({
122
+ zIndex: zIndex,
123
+ position: 'absolute',
124
+ left: 0,
125
+ top: 0,
126
+ width: '100%',
127
+ height: '100%',
128
+ backgroundSize: "".concat(gapX + width, "px"),
129
+ pointerEvents: 'none',
130
+ backgroundRepeat: 'repeat',
131
+ backgroundImage: "url('".concat(base64Url, "')")
132
+ }, markStyle)
133
+ }));
134
+ };
135
+ export default WaterMarkComponent;
package/package.json ADDED
@@ -0,0 +1,102 @@
1
+ {
2
+ "name": "@ccs-ui/rc-pro",
3
+ "version": "1.0.0",
4
+ "description": "A react library developed with dumi",
5
+ "license": "MIT",
6
+ "module": "es/index.js",
7
+ "types": "es/index.d.ts",
8
+ "files": [
9
+ "es"
10
+ ],
11
+ "scripts": {
12
+ "build": "father build",
13
+ "build:watch": "father dev",
14
+ "dev": "dumi dev",
15
+ "docs:build": "dumi build",
16
+ "doctor": "father doctor",
17
+ "lint": "npm run lint:es && npm run lint:css",
18
+ "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
19
+ "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
20
+ "prepare": "husky install && dumi setup",
21
+ "prepublishOnly": "father doctor && npm run build",
22
+ "publish-beta": "father build && npm publish --tag=beta && cnpm sync @ccs-ui/rc-pro",
23
+ "publish-prod": "father build && npm publish && cnpm sync @ccs-ui/rc-pro",
24
+ "start": "npm run dev",
25
+ "sync": "cnpm sync @ccs-ui/rc-pro"
26
+ },
27
+ "commitlint": {
28
+ "extends": [
29
+ "@commitlint/config-conventional"
30
+ ]
31
+ },
32
+ "lint-staged": {
33
+ "*.{md,json}": [
34
+ "prettier --write --no-error-on-unmatched-pattern"
35
+ ],
36
+ "*.{css,less}": [
37
+ "stylelint --fix",
38
+ "prettier --write"
39
+ ],
40
+ "*.{js,jsx}": [
41
+ "eslint --fix",
42
+ "prettier --write"
43
+ ],
44
+ "*.{ts,tsx}": [
45
+ "eslint --fix",
46
+ "prettier --parser=typescript --write"
47
+ ]
48
+ },
49
+ "dependencies": {
50
+ "@ant-design/icons": "^5.1.4",
51
+ "@ccs-ui/rc-pro": "1.0.0-rc.37",
52
+ "ahooks": "^3.7.7",
53
+ "antd": "^5.5.2",
54
+ "classnames": "^2.3.2",
55
+ "dayjs": "^1.11.7",
56
+ "js-base64": "^3.7.5",
57
+ "localforage": "^1.10.0",
58
+ "lodash": "^4.17.21",
59
+ "rc-resize-observer": "^1.3.1",
60
+ "rc-trigger": "^5.3.4",
61
+ "rc-util": "^5.32.4",
62
+ "react-color": "^2.19.3",
63
+ "react-custom-scrollbars": "^4.2.1",
64
+ "react-draggable": "^4.4.5",
65
+ "react-router": "^6.11.2",
66
+ "react-router-dom": "^6.11.2",
67
+ "shortid": "^2.2.16"
68
+ },
69
+ "devDependencies": {
70
+ "@commitlint/cli": "^17.1.2",
71
+ "@commitlint/config-conventional": "^17.1.0",
72
+ "@types/lodash": "^4.14.195",
73
+ "@types/react": "^18.0.0",
74
+ "@types/react-color": "^3.0.6",
75
+ "@types/react-custom-scrollbars": "^4.0.10",
76
+ "@types/react-dom": "^18.0.0",
77
+ "@types/shortid": "^0.0.29",
78
+ "@umijs/lint": "^4.0.0",
79
+ "cross-env": "^7.0.3",
80
+ "dumi": "^2.2.0",
81
+ "eslint": "^8.23.0",
82
+ "father": "^4.1.0",
83
+ "husky": "^8.0.1",
84
+ "lint-staged": "^13.0.3",
85
+ "prettier": "^2.7.1",
86
+ "prettier-plugin-organize-imports": "^3.0.0",
87
+ "prettier-plugin-packagejson": "^2.2.18",
88
+ "react": "^18.0.0",
89
+ "react-dom": "^18.0.0",
90
+ "stylelint": "^14.9.1"
91
+ },
92
+ "peerDependencies": {
93
+ "react": ">=16.9.0",
94
+ "react-dom": ">=16.9.0"
95
+ },
96
+ "publishConfig": {
97
+ "access": "public"
98
+ },
99
+ "authors": [
100
+ "Dx"
101
+ ]
102
+ }