feffery_antd_components 0.3.0-a3 → 0.3.0-a4

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.
@@ -10239,20 +10239,12 @@
10239
10239
  "value": {
10240
10240
  "label": {
10241
10241
  "name": "node",
10242
- "description": "\u7ec4\u4ef6\u578b\uff0c\u8bbe\u7f6e\u5f53\u524d\u9884\u8bbe\u5b50\u9879\u5143\u7d20",
10242
+ "description": "\u7ec4\u4ef6\u578b\uff0c\u8bbe\u7f6e\u5f53\u524d\u9884\u8bbe\u5b50\u9879\u6807\u9898",
10243
10243
  "required": false
10244
10244
  },
10245
10245
  "value": {
10246
- "name": "union",
10247
- "value": [
10248
- {
10249
- "name": "string"
10250
- },
10251
- {
10252
- "name": "number"
10253
- }
10254
- ],
10255
- "description": "\u8bbe\u7f6e\u5f53\u524d\u9884\u8bbe\u5b50\u9879\u552f\u4e00\u503c",
10246
+ "name": "string",
10247
+ "description": "\u8bbe\u7f6e\u5f53\u524d\u9884\u8bbe\u5b50\u9879\u5bf9\u5e94\u65e5\u671f\u5b57\u7b26\u4e32",
10256
10248
  "required": false
10257
10249
  }
10258
10250
  }
@@ -10878,16 +10870,11 @@
10878
10870
  "required": false
10879
10871
  },
10880
10872
  "value": {
10881
- "name": "union",
10882
- "value": [
10883
- {
10884
- "name": "string"
10885
- },
10886
- {
10887
- "name": "number"
10888
- }
10889
- ],
10890
- "description": "\u8bbe\u7f6e\u5f53\u524d\u9884\u8bbe\u5b50\u9879\u552f\u4e00\u503c",
10873
+ "name": "arrayOf",
10874
+ "value": {
10875
+ "name": "string"
10876
+ },
10877
+ "description": "\u8bbe\u7f6e\u5f53\u524d\u9884\u8bbe\u5b50\u9879\u65e5\u671f\u8303\u56f4\u5b57\u7b26\u4e32\u6570\u7ec4",
10891
10878
  "required": false
10892
10879
  }
10893
10880
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feffery_antd_components",
3
- "version": "0.3.0-a3",
3
+ "version": "0.3.0-a4",
4
4
  "description": "Best implementation of Antd components in Plotly Dash.",
5
5
  "repository": {
6
6
  "type": "git",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feffery_antd_components",
3
- "version": "0.3.0-a3",
3
+ "version": "0.3.0-a4",
4
4
  "description": "Best implementation of Antd components in Plotly Dash.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -57,8 +57,8 @@ session: window.sessionStorage, data is cleared once the browser quit.
57
57
  - `popupContainer` (a value equal to: 'parent', 'body'; optional)
58
58
  - `presets` (optional): 配置预设范围触发列表信息. presets has the following type: Array of lists containing elements 'label', 'value'.
59
59
  Those elements have the following types:
60
- - `label` (a list of or a singular dash component, string or number; optional): 组件型,设置当前预设子项元素
61
- - `value` (String | Real; optional): 设置当前预设子项唯一值s
60
+ - `label` (a list of or a singular dash component, string or number; optional): 组件型,设置当前预设子项标题
61
+ - `value` (String; optional): 设置当前预设子项对应日期字符串s
62
62
  - `readOnly` (Bool; optional)
63
63
  - `showTime` (optional): . showTime has the following type: Bool | lists containing elements 'defaultValue', 'format'.
64
64
  Those elements have the following types:
@@ -59,7 +59,7 @@ session: window.sessionStorage, data is cleared once the browser quit.
59
59
  - `presets` (optional): 配置预设范围触发列表信息. presets has the following type: Array of lists containing elements 'label', 'value'.
60
60
  Those elements have the following types:
61
61
  - `label` (a list of or a singular dash component, string or number; optional): 组件型,设置当前预设子项元素
62
- - `value` (String | Real; optional): 设置当前预设子项唯一值s
62
+ - `value` (Array of Strings; optional): 设置当前预设子项日期范围字符串数组s
63
63
  - `readOnly` (Bool; optional)
64
64
  - `showTime` (optional): . showTime has the following type: Bool | lists containing elements 'defaultValue', 'format'.
65
65
  Those elements have the following types:
@@ -129,17 +129,14 @@ AntdDatePicker.propTypes = {
129
129
  presets: PropTypes.arrayOf(
130
130
  PropTypes.exact({
131
131
  /**
132
- * 组件型,设置当前预设子项元素
132
+ * 组件型,设置当前预设子项标题
133
133
  */
134
134
  label: PropTypes.node,
135
135
 
136
136
  /**
137
- * 设置当前预设子项唯一值
137
+ * 设置当前预设子项对应日期字符串
138
138
  */
139
- value: PropTypes.oneOfType([
140
- PropTypes.string,
141
- PropTypes.number
142
- ])
139
+ value: PropTypes.string
143
140
  })
144
141
  ),
145
142
 
@@ -138,12 +138,9 @@ AntdDateRangePicker.propTypes = {
138
138
  label: PropTypes.node,
139
139
 
140
140
  /**
141
- * 设置当前预设子项唯一值
141
+ * 设置当前预设子项日期范围字符串数组
142
142
  */
143
- value: PropTypes.oneOfType([
144
- PropTypes.string,
145
- PropTypes.number
146
- ])
143
+ value: PropTypes.arrayOf(PropTypes.string)
147
144
  })
148
145
  ),
149
146
 
@@ -434,12 +434,7 @@ const AntdDatePicker = (props) => {
434
434
  (preset) => ({
435
435
  label: preset.label,
436
436
  value: () => {
437
- setProps({
438
- clickedPreset: {
439
- value: preset.value,
440
- timestamp: Date.now()
441
- }
442
- })
437
+ return dayjs(preset.value, format)
443
438
  }
444
439
  })
445
440
  )
@@ -459,12 +459,7 @@ const AntdDateRangePicker = (props) => {
459
459
  (preset) => ({
460
460
  label: preset.label,
461
461
  value: () => {
462
- setProps({
463
- clickedPreset: {
464
- value: preset.value,
465
- timestamp: Date.now()
466
- }
467
- })
462
+ return [dayjs(preset.value[0], format), dayjs(preset.value[1], format)];
468
463
  }
469
464
  })
470
465
  )
package/usage.py CHANGED
@@ -1,82 +1,109 @@
1
1
  import dash
2
2
  from dash import html
3
3
  import feffery_antd_components as fac
4
- from dash.dependencies import Input, Output
4
+ from datetime import datetime, timedelta
5
5
 
6
- app = dash.Dash(__name__, compress=True)
6
+ app = dash.Dash(__name__)
7
7
 
8
- app.layout = html.Div(
9
- [
10
- fac.AntdSpace(
11
- [
12
- fac.AntdInput(
13
- id='tree-search-demo-keyword',
14
- placeholder='请输入搜索关键词',
15
- style={
16
- 'width': '100%'
17
- }
18
- ),
19
- fac.AntdTree(
20
- id='tree-search-demo',
21
- treeData=[
22
- {
23
- 'title': '四川省',
24
- 'key': '四川省',
25
- 'children': [
26
- {
27
- 'title': '成都市',
28
- 'key': '成都市'
29
- },
30
- {
31
- 'title': '广安市',
32
- 'key': '广安市'
33
- }
34
- ]
8
+
9
+ def render():
10
+ '''动态layout生成'''
11
+
12
+ return html.Div(
13
+ [
14
+ fac.AntdSpace(
15
+ [
16
+ fac.AntdDatePicker(
17
+ id='date-picker-demo',
18
+ style={
19
+ 'width': 150
20
+ },
21
+ presets=[
22
+ {
23
+ 'label': '前1天',
24
+ 'value': (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
25
+ },
26
+ {
27
+ 'label': '后1天',
28
+ 'value': (datetime.now() + timedelta(days=1)).strftime('%Y-%m-%d')
29
+ },
30
+ {
31
+ 'label': '7天前',
32
+ 'value': (datetime.now() - timedelta(days=7)).strftime('%Y-%m-%d')
33
+ },
34
+ {
35
+ 'label': '7天后',
36
+ 'value': (datetime.now() + timedelta(days=7)).strftime('%Y-%m-%d')
37
+ }
38
+ ]
39
+ ),
40
+ fac.AntdDateRangePicker(
41
+ id='date-range-picker-demo',
42
+ style={
43
+ 'width': 220
35
44
  },
36
- {
37
- 'title': '重庆市',
38
- 'key': '重庆市',
39
- 'children': [
40
- {
41
- 'title': '渝中区',
42
- 'key': '渝中区',
43
- 'children': [
44
- {
45
- 'title': '解放碑街道',
46
- 'key': '解放碑街道'
47
- }
48
- ]
49
- },
50
- {
51
- 'title': '渝北区',
52
- 'key': '渝北区'
53
- }
54
- ]
55
- }
56
- ],
57
- defaultExpandAll=True,
58
- highlightStyle={
59
- 'background': '#ffffb8',
60
- 'padding': 0
61
- }
62
- )
63
- ],
64
- direction='vertical',
65
- style={
66
- 'width': '100%'
67
- }
68
- )
69
- ],
70
- style={
71
- 'padding': '50px 100px'
72
- }
73
- )
45
+ presets=[
46
+ {
47
+ 'label': '前7天',
48
+ 'value': [
49
+ (datetime.now() - timedelta(days=7))
50
+ .strftime('%Y-%m-%d'),
51
+ datetime.now().strftime('%Y-%m-%d')
52
+ ]
53
+ },
54
+ {
55
+ 'label': '后7天',
56
+ 'value': [
57
+ datetime.now().strftime('%Y-%m-%d'),
58
+ (datetime.now() + timedelta(days=7))
59
+ .strftime('%Y-%m-%d')
60
+ ]
61
+ },
62
+ {
63
+ 'label': '前15天',
64
+ 'value': [
65
+ (datetime.now() - timedelta(days=15))
66
+ .strftime('%Y-%m-%d'),
67
+ datetime.now().strftime('%Y-%m-%d')
68
+ ]
69
+ },
70
+ {
71
+ 'label': '后15天',
72
+ 'value': [
73
+ datetime.now().strftime('%Y-%m-%d'),
74
+ (datetime.now() + timedelta(days=15))
75
+ .strftime('%Y-%m-%d')
76
+ ]
77
+ },
78
+ {
79
+ 'label': '前30天',
80
+ 'value': [
81
+ (datetime.now() - timedelta(days=30))
82
+ .strftime('%Y-%m-%d'),
83
+ datetime.now().strftime('%Y-%m-%d')
84
+ ]
85
+ },
86
+ {
87
+ 'label': '后30天',
88
+ 'value': [
89
+ datetime.now().strftime('%Y-%m-%d'),
90
+ (datetime.now() + timedelta(days=30))
91
+ .strftime('%Y-%m-%d')
92
+ ]
93
+ }
94
+ ]
95
+ )
96
+ ]
97
+ )
98
+ ],
99
+ style={
100
+ 'padding': '50px 100px'
101
+ }
102
+ )
103
+
104
+
105
+ app.layout = render
74
106
 
75
- app.clientside_callback(
76
- '''(value) => value''',
77
- Output('tree-search-demo', 'searchKeyword'),
78
- Input('tree-search-demo-keyword', 'value')
79
- )
80
107
 
81
108
  if __name__ == '__main__':
82
109
  app.run(debug=True)