feffery_antd_components 0.3.0-a0 → 0.3.0-a2
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 +1 -0
- package/Project.toml +1 -1
- package/build/lib/feffery_antd_components/AntdDropdown.py +12 -3
- package/build/lib/feffery_antd_components/AntdQRCode.py +88 -0
- package/build/lib/feffery_antd_components/_imports_.py +2 -0
- package/build/lib/feffery_antd_components/async-antd_table.js +1 -1
- package/build/lib/feffery_antd_components/async-data_display.js +4 -4
- package/build/lib/feffery_antd_components/async-data_entry.js +25 -13
- package/build/lib/feffery_antd_components/async-upload.js +2 -2
- package/build/lib/feffery_antd_components/feffery_antd_components.min.js +34 -46
- package/build/lib/feffery_antd_components/metadata.json +292 -0
- package/build/lib/feffery_antd_components/package-info.json +1 -1
- package/feffery_antd_components/AntdDropdown.py +12 -3
- package/feffery_antd_components/AntdQRCode.py +88 -0
- package/feffery_antd_components/_imports_.py +2 -0
- package/feffery_antd_components/async-antd_table.js +1 -1
- package/feffery_antd_components/async-data_display.js +4 -4
- package/feffery_antd_components/async-data_entry.js +25 -13
- package/feffery_antd_components/async-upload.js +2 -2
- package/feffery_antd_components/feffery_antd_components.min.js +34 -46
- package/feffery_antd_components/metadata.json +292 -0
- package/feffery_antd_components/package-info.json +1 -1
- package/package.json +1 -1
- package/src/jl/'feffery'_antddropdown.jl +6 -1
- package/src/jl/'feffery'_antdqrcode.jl +49 -0
- package/src/lib/components/dataDisplay/AntdQRCode.react.js +148 -0
- package/src/lib/components/dataEntry/AntdColorPicker.react.js +10 -84
- package/src/lib/components/navigation/AntdDropdown.react.js +72 -55
- package/src/lib/fragments/dataDisplay/AntdQRCode.react.js +80 -0
- package/src/lib/fragments/dataEntry/AntdColorPicker.react.js +95 -0
- package/src/lib/index.js +3 -1
- package/usage.py +37 -14
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, { useContext, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { Dropdown,
|
|
3
|
+
import { Dropdown, Button, Typography } from 'antd';
|
|
4
4
|
import AntdIcon from '../general/AntdIcon.react';
|
|
5
5
|
import { DownOutlined } from '@ant-design/icons';
|
|
6
6
|
import { isString, isUndefined } from 'lodash';
|
|
7
7
|
import useCss from '../../hooks/useCss';
|
|
8
8
|
import PropsContext from '../../contexts/PropsContext';
|
|
9
9
|
|
|
10
|
+
const { Link } = Typography;
|
|
10
11
|
|
|
11
12
|
// 定义下拉菜单组件AntdDropdown,api参数参考https://ant.design/components/dropdown-cn/
|
|
12
13
|
const AntdDropdown = (props) => {
|
|
@@ -28,6 +29,9 @@ const AntdDropdown = (props) => {
|
|
|
28
29
|
visible,
|
|
29
30
|
menuItems,
|
|
30
31
|
nClicks,
|
|
32
|
+
selectable,
|
|
33
|
+
multiple,
|
|
34
|
+
selectedKeys,
|
|
31
35
|
popupContainer,
|
|
32
36
|
buttonProps,
|
|
33
37
|
freePosition,
|
|
@@ -62,56 +66,55 @@ const AntdDropdown = (props) => {
|
|
|
62
66
|
}
|
|
63
67
|
style={style}
|
|
64
68
|
key={key}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
69
|
+
menu={{
|
|
70
|
+
items: menuItems.map(
|
|
71
|
+
(menuItem) => ({
|
|
72
|
+
type: menuItem.isDivider ? 'divider' : undefined,
|
|
73
|
+
disabled: menuItem.disabled,
|
|
74
|
+
key: menuItem.key || menuItem.title,
|
|
75
|
+
label: (
|
|
76
|
+
<a href={menuItem.href}
|
|
77
|
+
target={menuItem.target}>
|
|
78
|
+
{menuItem.title}
|
|
79
|
+
</a>
|
|
80
|
+
),
|
|
81
|
+
icon: (
|
|
82
|
+
menuItem.icon ?
|
|
83
|
+
(
|
|
84
|
+
menuItem.iconRenderer === 'fontawesome' ?
|
|
85
|
+
(
|
|
86
|
+
React.createElement(
|
|
87
|
+
'i',
|
|
88
|
+
{
|
|
89
|
+
className: menuItem.icon
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
) :
|
|
93
|
+
(
|
|
94
|
+
<AntdIcon icon={menuItem.icon} />
|
|
95
|
+
)
|
|
96
|
+
) :
|
|
97
|
+
null
|
|
76
98
|
)
|
|
77
99
|
})
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
97
|
-
) :
|
|
98
|
-
(
|
|
99
|
-
<AntdIcon icon={menuItem.icon} />
|
|
100
|
-
)
|
|
101
|
-
) : null
|
|
102
|
-
}
|
|
103
|
-
disabled={menuItem.disabled}
|
|
104
|
-
key={menuItem.key ? menuItem.key : menuItem.title}>
|
|
105
|
-
<a href={menuItem.href}
|
|
106
|
-
target={menuItem.target}>
|
|
107
|
-
{menuItem.title}
|
|
108
|
-
</a>
|
|
109
|
-
</Menu.Item>
|
|
110
|
-
)
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
</Menu>
|
|
114
|
-
}
|
|
100
|
+
),
|
|
101
|
+
selectable: selectable,
|
|
102
|
+
multiple: multiple,
|
|
103
|
+
selectedKeys: selectedKeys,
|
|
104
|
+
onClick: (item, key, keyPath, e) => setProps({
|
|
105
|
+
clickedKey: item.key,
|
|
106
|
+
nClicks: nClicks + 1,
|
|
107
|
+
...(
|
|
108
|
+
freePosition && !multiple ?
|
|
109
|
+
{
|
|
110
|
+
visible: false
|
|
111
|
+
} :
|
|
112
|
+
{}
|
|
113
|
+
)
|
|
114
|
+
}),
|
|
115
|
+
onSelect: (e) => setProps({ selectedKeys: e.selectedKeys }),
|
|
116
|
+
onDeselect: (e) => setProps({ selectedKeys: e.selectedKeys })
|
|
117
|
+
}}
|
|
115
118
|
arrow={arrow}
|
|
116
119
|
disabled={
|
|
117
120
|
context && !isUndefined(context.componentDisabled) ?
|
|
@@ -128,9 +131,7 @@ const AntdDropdown = (props) => {
|
|
|
128
131
|
trigger={[trigger]}
|
|
129
132
|
autoAdjustOverflow={autoAdjustOverflow}
|
|
130
133
|
open={visible}
|
|
131
|
-
onOpenChange={(
|
|
132
|
-
visible: v
|
|
133
|
-
})}
|
|
134
|
+
onOpenChange={(e) => setProps({ visible: e })}
|
|
134
135
|
getPopupContainer={
|
|
135
136
|
popupContainer === 'parent' ?
|
|
136
137
|
(triggerNode) => triggerNode.parentNode :
|
|
@@ -162,10 +163,9 @@ const AntdDropdown = (props) => {
|
|
|
162
163
|
{title} <DownOutlined />
|
|
163
164
|
</Button>
|
|
164
165
|
:
|
|
165
|
-
<
|
|
166
|
-
onClick={e => e.preventDefault()}>
|
|
166
|
+
<Link onClick={e => e.preventDefault()}>
|
|
167
167
|
{title} <DownOutlined />
|
|
168
|
-
</
|
|
168
|
+
</Link>
|
|
169
169
|
)
|
|
170
170
|
}
|
|
171
171
|
</Dropdown>
|
|
@@ -258,6 +258,23 @@ AntdDropdown.propTypes = {
|
|
|
258
258
|
})
|
|
259
259
|
),
|
|
260
260
|
|
|
261
|
+
/**
|
|
262
|
+
* 设置菜单项是否可选中
|
|
263
|
+
* 默认:false
|
|
264
|
+
*/
|
|
265
|
+
selectable: PropTypes.bool,
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* 设置菜单是否允许多选
|
|
269
|
+
* 默认:false
|
|
270
|
+
*/
|
|
271
|
+
multiple: PropTypes.bool,
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* 设置或监听当前已选中菜单项key值数组
|
|
275
|
+
*/
|
|
276
|
+
selectedKeys: PropTypes.arrayOf(PropTypes.string),
|
|
277
|
+
|
|
261
278
|
// 设置下拉框是否显示连接箭头,默认为false
|
|
262
279
|
arrow: PropTypes.bool,
|
|
263
280
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { QRCode, ConfigProvider } from 'antd';
|
|
3
|
+
import useCss from '../../hooks/useCss';
|
|
4
|
+
import { isString } from 'lodash';
|
|
5
|
+
import { str2Locale } from '../../components/locales.react';
|
|
6
|
+
import { propTypes, defaultProps } from '../../components/dataDisplay/AntdImage.react';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// 定义二维码组件AntdQRCode,api参数参考https://ant.design/components/collapse/#components-collapse-demo-accordion
|
|
10
|
+
const AntdQRCode = (props) => {
|
|
11
|
+
let {
|
|
12
|
+
id,
|
|
13
|
+
className,
|
|
14
|
+
style,
|
|
15
|
+
key,
|
|
16
|
+
locale,
|
|
17
|
+
value,
|
|
18
|
+
type,
|
|
19
|
+
icon,
|
|
20
|
+
size,
|
|
21
|
+
iconSize,
|
|
22
|
+
color,
|
|
23
|
+
bgColor,
|
|
24
|
+
bordered,
|
|
25
|
+
errorLevel,
|
|
26
|
+
status,
|
|
27
|
+
expires,
|
|
28
|
+
autoSpin,
|
|
29
|
+
refreshClicks,
|
|
30
|
+
setProps,
|
|
31
|
+
loading_state
|
|
32
|
+
} = props;
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (value && expires) {
|
|
36
|
+
setTimeout(
|
|
37
|
+
() => {
|
|
38
|
+
setProps({ status: 'expired' })
|
|
39
|
+
},
|
|
40
|
+
expires * 1000
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
}, [value])
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<ConfigProvider
|
|
47
|
+
locale={str2Locale.get(locale)}
|
|
48
|
+
>
|
|
49
|
+
<QRCode
|
|
50
|
+
id={id}
|
|
51
|
+
className={
|
|
52
|
+
isString(className) ?
|
|
53
|
+
className :
|
|
54
|
+
(className ? useCss(className) : undefined)
|
|
55
|
+
}
|
|
56
|
+
style={style}
|
|
57
|
+
key={key}
|
|
58
|
+
value={value}
|
|
59
|
+
type={type}
|
|
60
|
+
icon={icon}
|
|
61
|
+
size={size}
|
|
62
|
+
iconSize={iconSize}
|
|
63
|
+
color={color}
|
|
64
|
+
bgColor={bgColor}
|
|
65
|
+
bordered={bordered}
|
|
66
|
+
errorLevel={errorLevel}
|
|
67
|
+
status={autoSpin && loading_state?.prop_name?.startsWith('value') ? 'loading' : status}
|
|
68
|
+
onRefresh={() => setProps({ refreshClicks: refreshClicks + 1 })}
|
|
69
|
+
data-dash-is-loading={
|
|
70
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
71
|
+
}
|
|
72
|
+
/>
|
|
73
|
+
</ConfigProvider>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default AntdQRCode;
|
|
78
|
+
|
|
79
|
+
AntdQRCode.defaultProps = defaultProps;
|
|
80
|
+
AntdQRCode.propTypes = propTypes;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { ColorPicker } from 'antd';
|
|
3
|
+
import { Color } from '@rc-component/color-picker';
|
|
4
|
+
import useCss from '../../hooks/useCss';
|
|
5
|
+
import { isString } from 'lodash';
|
|
6
|
+
import { propTypes, defaultProps } from '../../components/dataEntry/AntdColorPicker.react';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// 定义颜色选择器组件AntdColorPicker,api参数参考https://ant.design/components/color-picker-cn
|
|
10
|
+
const AntdColorPicker = (props) => {
|
|
11
|
+
// 取得必要属性或参数
|
|
12
|
+
let {
|
|
13
|
+
id,
|
|
14
|
+
className,
|
|
15
|
+
style,
|
|
16
|
+
key,
|
|
17
|
+
allowClear,
|
|
18
|
+
arrow,
|
|
19
|
+
value,
|
|
20
|
+
format,
|
|
21
|
+
disabled,
|
|
22
|
+
disabledAlpha,
|
|
23
|
+
open,
|
|
24
|
+
presets,
|
|
25
|
+
placement,
|
|
26
|
+
showText,
|
|
27
|
+
size,
|
|
28
|
+
trigger,
|
|
29
|
+
setProps,
|
|
30
|
+
loading_state
|
|
31
|
+
} = props;
|
|
32
|
+
|
|
33
|
+
// 每次format发生变更时,同步更新value值
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (value) {
|
|
36
|
+
let _color = new Color(value)
|
|
37
|
+
setProps({
|
|
38
|
+
value: (
|
|
39
|
+
format === 'hex' ?
|
|
40
|
+
_color.toHexString() :
|
|
41
|
+
(
|
|
42
|
+
format === 'rgb' ?
|
|
43
|
+
_color.toRgbString() :
|
|
44
|
+
_color.toHsbString()
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
}, [format])
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<ColorPicker id={id}
|
|
53
|
+
className={
|
|
54
|
+
isString(className) ?
|
|
55
|
+
className :
|
|
56
|
+
(className ? useCss(className) : undefined)
|
|
57
|
+
}
|
|
58
|
+
style={style}
|
|
59
|
+
key={key}
|
|
60
|
+
allowClear={allowClear}
|
|
61
|
+
arrow={arrow}
|
|
62
|
+
value={value}
|
|
63
|
+
format={format}
|
|
64
|
+
disabled={disabled}
|
|
65
|
+
disabledAlpha={disabledAlpha}
|
|
66
|
+
open={open}
|
|
67
|
+
presets={presets}
|
|
68
|
+
placement={placement}
|
|
69
|
+
showText={showText}
|
|
70
|
+
size={size}
|
|
71
|
+
trigger={trigger}
|
|
72
|
+
onFormatChange={(e) => setProps({ format: e })}
|
|
73
|
+
onOpenChange={(e) => setProps({ open: e })}
|
|
74
|
+
onChangeComplete={(e) => setProps({
|
|
75
|
+
value: (
|
|
76
|
+
format === 'hex' ?
|
|
77
|
+
e.toHexString() :
|
|
78
|
+
(
|
|
79
|
+
format === 'rgb' ?
|
|
80
|
+
e.toRgbString() :
|
|
81
|
+
e.toHsbString()
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
})}
|
|
85
|
+
onClear={() => setProps({ value: null })}
|
|
86
|
+
data-dash-is-loading={
|
|
87
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
88
|
+
} />
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default AntdColorPicker;
|
|
93
|
+
|
|
94
|
+
AntdColorPicker.defaultProps = defaultProps;
|
|
95
|
+
AntdColorPicker.propTypes = propTypes;
|
package/src/lib/index.js
CHANGED
|
@@ -61,6 +61,7 @@ import AntdTimeline from './components/dataDisplay/AntdTimeline.react';
|
|
|
61
61
|
import AntdTooltip from './components/dataDisplay/AntdTooltip.react';
|
|
62
62
|
import AntdTree from './components/dataDisplay/AntdTree.react';
|
|
63
63
|
import AntdSpoiler from './components/dataDisplay/AntdSpoiler.react';
|
|
64
|
+
import AntdQRCode from './components/dataDisplay/AntdQRCode.react';
|
|
64
65
|
// 反馈
|
|
65
66
|
import AntdAlert from './components/feedback/AntdAlert.react';
|
|
66
67
|
import AntdDrawer from './components/feedback/AntdDrawer.react';
|
|
@@ -212,5 +213,6 @@ export {
|
|
|
212
213
|
AntdSpoiler,
|
|
213
214
|
AntdCompact,
|
|
214
215
|
AntdTour,
|
|
215
|
-
AntdColorPicker
|
|
216
|
+
AntdColorPicker,
|
|
217
|
+
AntdQRCode
|
|
216
218
|
};
|
package/usage.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import dash
|
|
2
|
+
import uuid
|
|
2
3
|
import json
|
|
4
|
+
import time
|
|
3
5
|
from dash import html
|
|
4
6
|
import feffery_antd_components as fac
|
|
5
7
|
from dash.dependencies import Input, Output
|
|
@@ -8,18 +10,35 @@ app = dash.Dash(__name__, compress=True)
|
|
|
8
10
|
|
|
9
11
|
app.layout = html.Div(
|
|
10
12
|
[
|
|
11
|
-
fac.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
fac.AntdDropdown(
|
|
14
|
+
id='dropdown-demo',
|
|
15
|
+
title='触发点',
|
|
16
|
+
menuItems=[
|
|
17
|
+
{
|
|
18
|
+
'title': '选项1',
|
|
19
|
+
'key': '选项1',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
'title': '选项2',
|
|
23
|
+
'key': '选项2',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
'isDivider': True
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
'title': '选项3-1',
|
|
30
|
+
'key': '选项3-1',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
'title': '选项3-2',
|
|
34
|
+
'key': '选项3-2',
|
|
35
|
+
}
|
|
21
36
|
],
|
|
22
|
-
|
|
37
|
+
selectable=True,
|
|
38
|
+
multiple=True
|
|
39
|
+
),
|
|
40
|
+
html.Pre(
|
|
41
|
+
id='output'
|
|
23
42
|
)
|
|
24
43
|
],
|
|
25
44
|
style={
|
|
@@ -30,13 +49,17 @@ app.layout = html.Div(
|
|
|
30
49
|
|
|
31
50
|
@app.callback(
|
|
32
51
|
Output('output', 'children'),
|
|
33
|
-
Input('
|
|
52
|
+
[Input('dropdown-demo', 'selectedKeys'),
|
|
53
|
+
Input('dropdown-demo', 'clickedKey'),
|
|
54
|
+
Input('dropdown-demo', 'nClicks')]
|
|
34
55
|
)
|
|
35
|
-
def demo(
|
|
56
|
+
def demo(selectedKeys, clickedKey, nClicks):
|
|
36
57
|
|
|
37
58
|
return json.dumps(
|
|
38
59
|
dict(
|
|
39
|
-
|
|
60
|
+
selectedKeys=selectedKeys,
|
|
61
|
+
clickedKey=clickedKey,
|
|
62
|
+
nClicks=nClicks
|
|
40
63
|
),
|
|
41
64
|
indent=4,
|
|
42
65
|
ensure_ascii=False
|