feffery_utils_components 0.0.9 → 0.0.13
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/DESCRIPTION +1 -1
- package/NAMESPACE +5 -5
- package/Project.toml +1 -1
- package/feffery_utils_components/FefferyCaptcha.py +5 -3
- package/feffery_utils_components/FefferyCircleColorPicker.py +47 -0
- package/{build/lib/feffery_utils_components/FefferyDashboard.py → feffery_utils_components/FefferyColorPicker.py} +9 -11
- package/feffery_utils_components/FefferyDiv.py +47 -0
- package/feffery_utils_components/FefferyExecuteJs.py +5 -3
- package/feffery_utils_components/FefferyExtraSpinner.py +49 -0
- package/feffery_utils_components/FefferyGuide.py +5 -3
- package/feffery_utils_components/FefferyScroll.py +57 -0
- package/feffery_utils_components/FefferyScrollbars.py +51 -0
- package/feffery_utils_components/FefferyShortcutPanel.py +5 -3
- package/feffery_utils_components/FefferySplit.py +8 -8
- package/feffery_utils_components/FefferySplitPane.py +5 -3
- package/feffery_utils_components/FefferySyntaxHighlighter.py +5 -3
- package/feffery_utils_components/FefferyTopProgress.py +5 -3
- package/feffery_utils_components/_imports_.py +10 -4
- package/feffery_utils_components/feffery_utils_components.min.js +50 -28
- package/feffery_utils_components/metadata.json +457 -202
- package/feffery_utils_components/package-info.json +7 -6
- package/package.json +7 -6
- package/src/FefferyUtilsComponents.jl +8 -5
- package/src/jl/''_fefferycirclecolorpicker.jl +26 -0
- package/src/jl/''_fefferycolorpicker.jl +22 -0
- package/src/jl/''_fefferydiv.jl +32 -0
- package/src/jl/''_fefferyextraspinner.jl +27 -0
- package/src/jl/''_fefferyscroll.jl +31 -0
- package/src/jl/''_fefferyscrollbars.jl +34 -0
- package/src/jl/''_fefferysplit.jl +1 -2
- package/src/lib/components/FefferyCaptcha.react.js +6 -2
- package/src/lib/components/FefferyDiv.react.js +85 -0
- package/src/lib/components/FefferyExecuteJs.react.js +21 -12
- package/src/lib/components/FefferyExtraSpinner.react.js +373 -0
- package/src/lib/components/FefferyGuide.react.js +11 -4
- package/src/lib/components/FefferyScroll.react.js +170 -0
- package/src/lib/components/FefferyScrollbars.react.js +104 -0
- package/src/lib/components/FefferyShortcutPanel.react.js +5 -1
- package/src/lib/components/FefferySyntaxHighlighter.react.js +6 -2
- package/src/lib/components/FefferyTopProgress.react.js +3 -3
- package/src/lib/components/colorPickers/FefferyCircleColorPicker.react.js +88 -0
- package/src/lib/components/nprogress.css +84 -0
- package/src/lib/components/split/FefferySplit.react.js +28 -42
- package/src/lib/components/styles.css +32 -8
- package/src/lib/index.js +11 -6
- package/usage.py +107 -39
- package/build/lib/feffery_utils_components/FefferyCaptcha.py +0 -51
- package/build/lib/feffery_utils_components/FefferyGuide.py +0 -69
- package/build/lib/feffery_utils_components/FefferyPasteImage.py +0 -56
- package/build/lib/feffery_utils_components/FefferyResizable.py +0 -39
- package/build/lib/feffery_utils_components/FefferyShortcutPanel.py +0 -51
- package/build/lib/feffery_utils_components/FefferySplit.py +0 -59
- package/build/lib/feffery_utils_components/FefferySplitPane.py +0 -48
- package/build/lib/feffery_utils_components/FefferySyntaxHighlighter.py +0 -52
- package/build/lib/feffery_utils_components/FefferyTopProgress.py +0 -68
- package/build/lib/feffery_utils_components/FefferyUtilsComponents.py +0 -40
- package/build/lib/feffery_utils_components/FefferyWaterMark.py +0 -64
- package/build/lib/feffery_utils_components/__init__.py +0 -89
- package/build/lib/feffery_utils_components/_imports_.py +0 -21
- package/build/lib/feffery_utils_components/feffery_utils_components.min.js +0 -407
- package/build/lib/feffery_utils_components/metadata.json +0 -1053
- package/build/lib/feffery_utils_components/package-info.json +0 -84
- package/src/lib/components/FefferyPasteImage.react.js +0 -168
- package/src/lib/components/FefferyWaterMark.react.js +0 -112
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "feffery_utils_components",
|
|
3
|
-
"version": "0.0.8",
|
|
4
|
-
"description": "Utility augments components of Dash!",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git://github.com/https://github.com/CNFeffery/feffery-utils-components.git"
|
|
8
|
-
},
|
|
9
|
-
"bugs": {
|
|
10
|
-
"url": "https://github.com/https://github.com/CNFeffery/feffery-utils-components/issues"
|
|
11
|
-
},
|
|
12
|
-
"homepage": "https://github.com/https://github.com/CNFeffery/feffery-utils-components",
|
|
13
|
-
"main": "build/index.js",
|
|
14
|
-
"scripts": {
|
|
15
|
-
"start": "webpack-serve --config ./webpack.serve.config.js --open",
|
|
16
|
-
"build:js": "webpack --mode production",
|
|
17
|
-
"build:backends": "dash-generate-components ./src/lib/components feffery_utils_components -p package-info.json --r-prefix '' --jl-prefix ''",
|
|
18
|
-
"build:backends-activated": "(. venv/bin/activate || venv\\scripts\\activate && npm run build:py_and_r)",
|
|
19
|
-
"build": "npm run build:js && npm run build:backends",
|
|
20
|
-
"build:activated": "npm run build:js && npm run build:backends-activated"
|
|
21
|
-
},
|
|
22
|
-
"author": "CNFeffery <fefferypzy@gmail.com>",
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"@ant-design/pro-layout": "^6.24.0",
|
|
26
|
-
"@charliewilco/gluejar": "^1.0.0",
|
|
27
|
-
"byte-guide": "^1.0.7",
|
|
28
|
-
"file-loader": "^6.2.0",
|
|
29
|
-
"github-markdown-css": "^5.0.0",
|
|
30
|
-
"less": "^3.13.1",
|
|
31
|
-
"less-loader": "^5.0.0",
|
|
32
|
-
"ninja-keys": "^1.1.12",
|
|
33
|
-
"nprogress": "^0.2.0",
|
|
34
|
-
"ramda": "^0.26.1",
|
|
35
|
-
"re-resizable": "^6.9.1",
|
|
36
|
-
"react-captcha-code": "^1.0.7",
|
|
37
|
-
"react-contexify": "^5.0.0",
|
|
38
|
-
"react-copy-to-clipboard": "^5.0.4",
|
|
39
|
-
"react-icons": "^4.3.1",
|
|
40
|
-
"react-split": "^2.0.14",
|
|
41
|
-
"react-syntax-highlighter": "^15.4.4"
|
|
42
|
-
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"@babel/core": "^7.5.4",
|
|
45
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.5.4",
|
|
46
|
-
"@babel/preset-env": "^7.5.4",
|
|
47
|
-
"@babel/preset-react": "^7.0.0",
|
|
48
|
-
"@plotly/dash-component-plugins": "^1.2.0",
|
|
49
|
-
"@plotly/webpack-dash-dynamic-import": "^1.2.0",
|
|
50
|
-
"babel-eslint": "^10.0.2",
|
|
51
|
-
"babel-loader": "^8.0.6",
|
|
52
|
-
"copyfiles": "^2.1.1",
|
|
53
|
-
"css-loader": "^3.0.0",
|
|
54
|
-
"eslint": "^6.0.1",
|
|
55
|
-
"eslint-config-prettier": "^6.0.0",
|
|
56
|
-
"eslint-plugin-import": "^2.18.0",
|
|
57
|
-
"eslint-plugin-react": "^7.14.2",
|
|
58
|
-
"npm": "^6.1.0",
|
|
59
|
-
"prop-types": "^15.7.2",
|
|
60
|
-
"react": "^16.8.6",
|
|
61
|
-
"react-docgen": "^4.1.1",
|
|
62
|
-
"react-dom": "^16.8.6",
|
|
63
|
-
"style-loader": "^0.23.1",
|
|
64
|
-
"styled-jsx": "^3.2.1",
|
|
65
|
-
"terser-webpack-plugin": "^2.3.0",
|
|
66
|
-
"url-loader": "^4.1.1",
|
|
67
|
-
"webpack": "4.36.1",
|
|
68
|
-
"webpack-cli": "3.3.6",
|
|
69
|
-
"webpack-serve": "3.1.0"
|
|
70
|
-
},
|
|
71
|
-
"babel": {
|
|
72
|
-
"presets": [
|
|
73
|
-
"@babel/preset-react",
|
|
74
|
-
"@babel/preset-env"
|
|
75
|
-
],
|
|
76
|
-
"plugins": [
|
|
77
|
-
"@babel/plugin-transform-react-jsx"
|
|
78
|
-
]
|
|
79
|
-
},
|
|
80
|
-
"engines": {
|
|
81
|
-
"node": ">=8.11.0",
|
|
82
|
-
"npm": ">=6.1.0"
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { Card, Button } from 'antd';
|
|
4
|
-
import { Gluejar } from '@charliewilco/gluejar'
|
|
5
|
-
import { DeleteOutlined } from '@ant-design/icons';
|
|
6
|
-
import './styles.css'
|
|
7
|
-
import 'antd/dist/antd.css';
|
|
8
|
-
|
|
9
|
-
const urlToBase64 = (url) => {
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
let image = new Image();
|
|
12
|
-
image.onload = function () {
|
|
13
|
-
let canvas = document.createElement('canvas');
|
|
14
|
-
canvas.width = this.naturalWidth;
|
|
15
|
-
canvas.height = this.naturalHeight;
|
|
16
|
-
// 将图片插入画布并开始绘制
|
|
17
|
-
canvas.getContext('2d').drawImage(image, 0, 0);
|
|
18
|
-
// result
|
|
19
|
-
let result = canvas.toDataURL('image/png')
|
|
20
|
-
resolve(result);
|
|
21
|
-
};
|
|
22
|
-
// CORS 策略,会存在跨域问题https://stackoverflow.com/questions/20424279/canvas-todataurl-securityerror
|
|
23
|
-
image.setAttribute("crossOrigin", 'Anonymous');
|
|
24
|
-
image.src = url;
|
|
25
|
-
// 图片加载失败的错误处理
|
|
26
|
-
image.onerror = () => {
|
|
27
|
-
reject(new Error('urlToBase64 error'));
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// 定义图片粘贴组件FefferyPasteImage,api参数参考https://github.com/charliewilco/react-gluejar
|
|
34
|
-
const FefferyPasteImage = (props) => {
|
|
35
|
-
// 取得必要属性或参数
|
|
36
|
-
let {
|
|
37
|
-
id,
|
|
38
|
-
className,
|
|
39
|
-
style,
|
|
40
|
-
currentPastedImages,
|
|
41
|
-
deletedIdx,
|
|
42
|
-
imageHeight,
|
|
43
|
-
setProps
|
|
44
|
-
} = props;
|
|
45
|
-
|
|
46
|
-
const handlePaste = useCallback(async (files) => {
|
|
47
|
-
let results = []
|
|
48
|
-
for (let i = 0; i < files.images.length; i++) {
|
|
49
|
-
if (deletedIdx.indexOf(i) === -1) {
|
|
50
|
-
let result = await urlToBase64(files.images[i])
|
|
51
|
-
results.push(result)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
setProps({
|
|
55
|
-
currentPastedImages: results
|
|
56
|
-
})
|
|
57
|
-
}, []);
|
|
58
|
-
|
|
59
|
-
const handleDelete = useCallback((idx) => {
|
|
60
|
-
if (!deletedIdx) {
|
|
61
|
-
deletedIdx = [idx]
|
|
62
|
-
} else if (deletedIdx.indexOf(idx) === -1) {
|
|
63
|
-
deletedIdx.push(idx)
|
|
64
|
-
}
|
|
65
|
-
setProps({
|
|
66
|
-
currentPastedImages: currentPastedImages.filter((value, idx) => deletedIdx.indexOf(idx) === -1),
|
|
67
|
-
deletedIdx: deletedIdx
|
|
68
|
-
})
|
|
69
|
-
}, []);
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<div id={id}
|
|
73
|
-
className={className}
|
|
74
|
-
style={style}>
|
|
75
|
-
<Gluejar
|
|
76
|
-
key={1}
|
|
77
|
-
onPaste={handlePaste}
|
|
78
|
-
container={document.getElementById(id)}
|
|
79
|
-
onError={err => console.error(err)}>
|
|
80
|
-
{({ images }) => {
|
|
81
|
-
if (images.length > 0) {
|
|
82
|
-
console.log('渲染!')
|
|
83
|
-
return (
|
|
84
|
-
<Card style={{ height: '100%', border: 'none' }}>
|
|
85
|
-
{
|
|
86
|
-
images.map((image, idx) => {
|
|
87
|
-
return deletedIdx.indexOf(idx) === -1 ? (
|
|
88
|
-
<Card.Grid
|
|
89
|
-
style={{ width: '25%', height: imageHeight, padding: 5, cursor: 'pointer', position: 'relative' }}
|
|
90
|
-
>
|
|
91
|
-
<Button shape="circle" size={"small"} icon={<DeleteOutlined />}
|
|
92
|
-
style={{ position: 'absolute', 'right': 10, top: 10 }}
|
|
93
|
-
onClick={() => handleDelete(idx)} />
|
|
94
|
-
<img src={image} key={image} alt={`Pasted: ${image}`}
|
|
95
|
-
style={{ borderTop: '1px solid #f0f0f0', height: '100%', width: '100%', objectFit: 'contain' }} />
|
|
96
|
-
</Card.Grid>
|
|
97
|
-
) : null
|
|
98
|
-
}
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
</Card>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
</Gluejar>
|
|
108
|
-
</div >
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// 定义参数或属性
|
|
113
|
-
FefferyPasteImage.propTypes = {
|
|
114
|
-
// 部件id
|
|
115
|
-
id: PropTypes.string.isRequired,
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* The content of the tab - will only be displayed if this tab is selected
|
|
119
|
-
*/
|
|
120
|
-
children: PropTypes.node,
|
|
121
|
-
|
|
122
|
-
// css类名
|
|
123
|
-
className: PropTypes.string,
|
|
124
|
-
|
|
125
|
-
// 自定义css字典
|
|
126
|
-
style: PropTypes.object,
|
|
127
|
-
|
|
128
|
-
// 存储当前保存的所有图片的base64字符串
|
|
129
|
-
currentPastedImages: PropTypes.arrayOf(PropTypes.any),
|
|
130
|
-
|
|
131
|
-
// 记录生命周期内第几次接受新图片粘贴,进而辅助删除图片操作
|
|
132
|
-
deletedIdx: PropTypes.arrayOf(PropTypes.number),
|
|
133
|
-
|
|
134
|
-
// 设置每张图片块的像素高度,默认为200
|
|
135
|
-
imageHeight: PropTypes.number,
|
|
136
|
-
|
|
137
|
-
loading_state: PropTypes.shape({
|
|
138
|
-
/**
|
|
139
|
-
* Determines if the component is loading or not
|
|
140
|
-
*/
|
|
141
|
-
is_loading: PropTypes.bool,
|
|
142
|
-
/**
|
|
143
|
-
* Holds which property is loading
|
|
144
|
-
*/
|
|
145
|
-
prop_name: PropTypes.string,
|
|
146
|
-
/**
|
|
147
|
-
* Holds the name of the component that is loading
|
|
148
|
-
*/
|
|
149
|
-
component_name: PropTypes.string
|
|
150
|
-
}),
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Dash-assigned callback that should be called to report property changes
|
|
154
|
-
* to Dash, to make them available for callbacks.
|
|
155
|
-
*/
|
|
156
|
-
setProps: PropTypes.func
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
// 设置默认参数
|
|
160
|
-
FefferyPasteImage.defaultProps = {
|
|
161
|
-
className: 'feffery-paste-image-container',
|
|
162
|
-
imageHeight: 200,
|
|
163
|
-
currentPastedImages: [],
|
|
164
|
-
deletedIdx: []
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
export default FefferyPasteImage;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { WaterMark } from '@ant-design/pro-layout';
|
|
4
|
-
import '@ant-design/pro-layout/dist/layout.css';
|
|
5
|
-
|
|
6
|
-
const parseChildrenToArray = children => {
|
|
7
|
-
if (children && !Array.isArray(children)) {
|
|
8
|
-
return [children];
|
|
9
|
-
}
|
|
10
|
-
return children;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// 定义水印部件FefferyWaterMark,api参数参考https://procomponents.ant.design/components/water-mark
|
|
14
|
-
export default class FefferyWaterMark extends Component {
|
|
15
|
-
render() {
|
|
16
|
-
// 取得必要属性或参数
|
|
17
|
-
let {
|
|
18
|
-
id,
|
|
19
|
-
children,
|
|
20
|
-
className,
|
|
21
|
-
style,
|
|
22
|
-
content,
|
|
23
|
-
rotate,
|
|
24
|
-
zIndex,
|
|
25
|
-
fontColor,
|
|
26
|
-
fontSize,
|
|
27
|
-
gapX,
|
|
28
|
-
gapY,
|
|
29
|
-
setProps
|
|
30
|
-
} = this.props;
|
|
31
|
-
|
|
32
|
-
children = parseChildrenToArray(children)
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<WaterMark id={id}
|
|
36
|
-
className={className}
|
|
37
|
-
style={style}
|
|
38
|
-
content={content}
|
|
39
|
-
rotate={rotate}
|
|
40
|
-
zIndex={zIndex}
|
|
41
|
-
fontColor={fontColor}
|
|
42
|
-
fontSize={fontSize}
|
|
43
|
-
gapX={gapX}
|
|
44
|
-
gapY={gapY}>
|
|
45
|
-
{children}
|
|
46
|
-
</WaterMark>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// 定义参数或属性
|
|
52
|
-
FefferyWaterMark.propTypes = {
|
|
53
|
-
// 部件id
|
|
54
|
-
id: PropTypes.string,
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* The content of the tab - will only be displayed if this tab is selected
|
|
58
|
-
*/
|
|
59
|
-
children: PropTypes.node,
|
|
60
|
-
|
|
61
|
-
// css类名
|
|
62
|
-
className: PropTypes.string,
|
|
63
|
-
|
|
64
|
-
// 自定义css字典
|
|
65
|
-
style: PropTypes.object,
|
|
66
|
-
|
|
67
|
-
// 设置水印文字内容
|
|
68
|
-
content: PropTypes.string,
|
|
69
|
-
|
|
70
|
-
// 设置水印旋转角度,默认-22
|
|
71
|
-
rotate: PropTypes.number,
|
|
72
|
-
|
|
73
|
-
// 设置水印z-index
|
|
74
|
-
zIndex: PropTypes.number,
|
|
75
|
-
|
|
76
|
-
// 设置水印文字颜色
|
|
77
|
-
fontColor: PropTypes.string,
|
|
78
|
-
|
|
79
|
-
// 设置水印字体像素大小,默认16
|
|
80
|
-
fontSize: PropTypes.number,
|
|
81
|
-
|
|
82
|
-
// 水印之间的水平像素间距,默认为212
|
|
83
|
-
gapX: PropTypes.number,
|
|
84
|
-
|
|
85
|
-
// 水印之间的垂直间距,默认为222
|
|
86
|
-
gapY: PropTypes.number,
|
|
87
|
-
|
|
88
|
-
loading_state: PropTypes.shape({
|
|
89
|
-
/**
|
|
90
|
-
* Determines if the component is loading or not
|
|
91
|
-
*/
|
|
92
|
-
is_loading: PropTypes.bool,
|
|
93
|
-
/**
|
|
94
|
-
* Holds which property is loading
|
|
95
|
-
*/
|
|
96
|
-
prop_name: PropTypes.string,
|
|
97
|
-
/**
|
|
98
|
-
* Holds the name of the component that is loading
|
|
99
|
-
*/
|
|
100
|
-
component_name: PropTypes.string
|
|
101
|
-
}),
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Dash-assigned callback that should be called to report property changes
|
|
105
|
-
* to Dash, to make them available for callbacks.
|
|
106
|
-
*/
|
|
107
|
-
setProps: PropTypes.func
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// 设置默认参数
|
|
111
|
-
FefferyWaterMark.defaultProps = {
|
|
112
|
-
}
|