feffery_antd_components 0.3.0-b2 → 0.3.0-b4

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 (50) hide show
  1. package/DESCRIPTION +1 -1
  2. package/Project.toml +1 -1
  3. package/README-en_US.md +4 -1
  4. package/README.md +4 -1
  5. package/build/lib/feffery_antd_components/AntdDraggablePanel.py +3 -6
  6. package/build/lib/feffery_antd_components/AntdImage.py +11 -2
  7. package/build/lib/feffery_antd_components/AntdImageGroup.py +11 -3
  8. package/build/lib/feffery_antd_components/AntdSelect.py +6 -3
  9. package/build/lib/feffery_antd_components/AntdTree.py +1 -1
  10. package/build/lib/feffery_antd_components/__init__.py +7 -1
  11. package/build/lib/feffery_antd_components/async-antd_table.js +4 -4
  12. package/build/lib/feffery_antd_components/async-data_display.js +3 -3
  13. package/build/lib/feffery_antd_components/async-data_entry.js +14 -38
  14. package/build/lib/feffery_antd_components/async-fac-shared.js +25 -0
  15. package/build/lib/feffery_antd_components/async-upload.js +9 -5
  16. package/build/lib/feffery_antd_components/feffery_antd_components.min.js +40 -40
  17. package/build/lib/feffery_antd_components/metadata.json +67 -12
  18. package/build/lib/feffery_antd_components/package-info.json +93 -93
  19. package/feffery_antd_components/AntdDraggablePanel.py +3 -6
  20. package/feffery_antd_components/AntdImage.py +11 -2
  21. package/feffery_antd_components/AntdImageGroup.py +11 -3
  22. package/feffery_antd_components/AntdSelect.py +6 -3
  23. package/feffery_antd_components/AntdTree.py +1 -1
  24. package/feffery_antd_components/__init__.py +7 -1
  25. package/feffery_antd_components/async-antd_table.js +4 -4
  26. package/feffery_antd_components/async-data_display.js +3 -3
  27. package/feffery_antd_components/async-data_entry.js +14 -38
  28. package/feffery_antd_components/async-fac-shared.js +25 -0
  29. package/feffery_antd_components/async-upload.js +9 -5
  30. package/feffery_antd_components/feffery_antd_components.min.js +40 -40
  31. package/feffery_antd_components/metadata.json +67 -12
  32. package/feffery_antd_components/package-info.json +93 -93
  33. package/package.json +93 -93
  34. package/src/jl/'feffery'_antddraggablepanel.jl +1 -2
  35. package/src/jl/'feffery'_antdimage.jl +5 -1
  36. package/src/jl/'feffery'_antdimagegroup.jl +5 -2
  37. package/src/jl/'feffery'_antdselect.jl +3 -1
  38. package/src/jl/'feffery'_antdtree.jl +1 -1
  39. package/src/lib/components/dataDisplay/AntdDraggablePanel.react.js +0 -5
  40. package/src/lib/components/dataDisplay/AntdImage.react.js +17 -2
  41. package/src/lib/components/dataDisplay/AntdImageGroup.react.js +14 -2
  42. package/src/lib/components/dataDisplay/AntdTag.react.js +9 -36
  43. package/src/lib/components/dataDisplay/AntdTree.react.js +5 -2
  44. package/src/lib/components/dataEntry/AntdSelect.react.js +7 -0
  45. package/src/lib/fragments/dataDisplay/AntdDraggablePanel.react.js +0 -2
  46. package/src/lib/fragments/dataDisplay/AntdTag.react.js +46 -0
  47. package/src/lib/fragments/dataDisplay/AntdTree.react.js +8 -3
  48. package/src/lib/fragments/dataEntry/AntdSelect.react.js +2 -0
  49. package/usage.py +38 -46
  50. package/webpack.config.js +6 -0
@@ -1,43 +1,13 @@
1
- import React from 'react';
1
+ import React, { Suspense } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import useCss from '../../hooks/useCss';
4
- import { isString } from 'lodash';
5
- import { Tag } from 'antd';
6
3
 
4
+ const LazyAntdTag = React.lazy(() => import(/* webpackChunkName: "data_display" */ '../../fragments/dataDisplay/AntdTag.react'));
7
5
 
8
- // 定义标签组件AntdTag,api参数参考https://ant.design/components/tag-cn/
9
6
  const AntdTag = (props) => {
10
- // 取得必要属性或参数
11
- let {
12
- id,
13
- className,
14
- style,
15
- key,
16
- content,
17
- color,
18
- href,
19
- target,
20
- bordered,
21
- setProps,
22
- loading_state
23
- } = props;
24
-
25
7
  return (
26
- <Tag id={id}
27
- key={key}
28
- className={
29
- isString(className) ?
30
- className :
31
- (className ? useCss(className) : undefined)
32
- }
33
- style={style}
34
- color={color}
35
- bordered={bordered}
36
- data-dash-is-loading={
37
- (loading_state && loading_state.is_loading) || undefined
38
- }>
39
- {href ? <a href={href} target={target}>{content}</a> : content}
40
- </Tag>
8
+ <Suspense fallback={null}>
9
+ <LazyAntdTag {...props} />
10
+ </Suspense>
41
11
  );
42
12
  }
43
13
 
@@ -101,4 +71,7 @@ AntdTag.defaultProps = {
101
71
  bordered: true
102
72
  }
103
73
 
104
- export default AntdTag;
74
+ export default AntdTag;
75
+
76
+ export const propTypes = AntdTag.propTypes;
77
+ export const defaultProps = AntdTag.defaultProps;
@@ -265,8 +265,11 @@ AntdTree.propTypes = {
265
265
  offset: PropTypes.number
266
266
  }),
267
267
 
268
- // 联动树搜索时使用,用于设置针对树节点title进行搜索的关键词
269
- searchKeyword: PropTypes.string,
268
+ // 联动树搜索时使用,用于设置针对树节点title进行搜索的关键词,也可以传入由多个关键词构成的数组
269
+ searchKeyword: PropTypes.oneOfType([
270
+ PropTypes.string,
271
+ PropTypes.arrayOf(PropTypes.string)
272
+ ]),
270
273
 
271
274
  // 配合searchKeyword参数使用,用于设置树节点title命中关键词部分的高亮样式
272
275
  highlightStyle: PropTypes.object,
@@ -196,6 +196,12 @@ AntdSelect.propTypes = {
196
196
  // 用于设置是否自动获取焦点,默认为false
197
197
  autoFocus: PropTypes.bool,
198
198
 
199
+ /**
200
+ * 设置下拉菜单是否与选择框同款,设置为false时将关闭虚拟滚动功能
201
+ * 默认:true
202
+ */
203
+ popupMatchSelectWidth: PropTypes.bool,
204
+
199
205
  // 设置是否以只读模式进行渲染,底层利用Select的open参数
200
206
  // 默认为false
201
207
  readOnly: PropTypes.bool,
@@ -281,6 +287,7 @@ AntdSelect.defaultProps = {
281
287
  optionFilterMode: 'case-insensitive',
282
288
  autoSpin: false,
283
289
  debounceWait: 200,
290
+ popupMatchSelectWidth: true,
284
291
  popupContainer: 'body',
285
292
  loadingEmptyContent: (
286
293
  <div style={{ display: 'flex', 'justifyContent': 'center' }}>
@@ -23,7 +23,6 @@ const AntdDraggablePanel = (props) => {
23
23
  maxHeight,
24
24
  resize,
25
25
  expandable,
26
- isExpand,
27
26
  setProps,
28
27
  loading_state
29
28
  } = props;
@@ -47,7 +46,6 @@ const AntdDraggablePanel = (props) => {
47
46
  maxHeight={maxHeight}
48
47
  resize={resize}
49
48
  expandable={expandable}
50
- isExpand={isExpand}
51
49
  data-dash-is-loading={
52
50
  (loading_state && loading_state.is_loading) || undefined
53
51
  } >
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import useCss from '../../hooks/useCss';
3
+ import { isString } from 'lodash';
4
+ import { Tag } from 'antd';
5
+ import { propTypes, defaultProps } from '../../components/dataDisplay/AntdTag.react';
6
+
7
+ // 定义标签组件AntdTag,api参数参考https://ant.design/components/tag-cn/
8
+ const AntdTag = (props) => {
9
+ // 取得必要属性或参数
10
+ let {
11
+ id,
12
+ className,
13
+ style,
14
+ key,
15
+ content,
16
+ color,
17
+ href,
18
+ target,
19
+ bordered,
20
+ setProps,
21
+ loading_state
22
+ } = props;
23
+
24
+ return (
25
+ <Tag id={id}
26
+ key={key}
27
+ className={
28
+ isString(className) ?
29
+ className :
30
+ (className ? useCss(className) : undefined)
31
+ }
32
+ style={style}
33
+ color={color}
34
+ bordered={bordered}
35
+ data-dash-is-loading={
36
+ (loading_state && loading_state.is_loading) || undefined
37
+ }>
38
+ {href ? <a href={href} target={target}>{content}</a> : content}
39
+ </Tag>
40
+ );
41
+ }
42
+
43
+ export default AntdTag;
44
+
45
+ AntdTag.defaultProps = defaultProps;
46
+ AntdTag.propTypes = propTypes;
@@ -27,7 +27,12 @@ const isSameParent = (a, b) => {
27
27
  const filterTree = (toFilterData, keyword) => {
28
28
  return toFilterData.filter(node => {
29
29
  // 首先检查当前节点是否匹配关键字
30
- const isMatch = node.title.includes(keyword);
30
+ let isMatch = false;
31
+ if (Array.isArray(keyword)) {
32
+ isMatch = keyword.some(s => node.title.includes(s));
33
+ } else {
34
+ isMatch = node.title.includes(keyword);
35
+ }
31
36
 
32
37
  // 如果当前节点匹配关键字,但不是根节点,才保留它及其全部后代节点信息
33
38
  if (isMatch) {
@@ -383,7 +388,7 @@ const AntdTree = (props) => {
383
388
  searchKeyword ?
384
389
  <Highlighter
385
390
  highlightStyle={highlightStyle}
386
- searchWords={[searchKeyword]}
391
+ searchWords={Array.isArray(searchKeyword) ? searchKeyword : [searchKeyword]}
387
392
  autoEscape
388
393
  textToHighlight={nodeData.title}
389
394
  /> :
@@ -427,7 +432,7 @@ const AntdTree = (props) => {
427
432
  searchKeyword ?
428
433
  <Highlighter
429
434
  highlightStyle={highlightStyle}
430
- searchWords={[searchKeyword]}
435
+ searchWords={Array.isArray(searchKeyword) ? searchKeyword : [searchKeyword]}
431
436
  autoEscape
432
437
  textToHighlight={nodeData.title}
433
438
  /> :
@@ -48,6 +48,7 @@ const AntdSelect = (props) => {
48
48
  dropdownAfter,
49
49
  popupContainer,
50
50
  readOnly,
51
+ popupMatchSelectWidth,
51
52
  loading_state,
52
53
  persistence,
53
54
  persisted_props,
@@ -289,6 +290,7 @@ const AntdSelect = (props) => {
289
290
  undefined
290
291
  }
291
292
  open={isUndefined(readOnly) || !readOnly ? undefined : false}
293
+ popupMatchSelectWidth={popupMatchSelectWidth}
292
294
  >
293
295
  {optionsJsx}
294
296
  </Select>
package/usage.py CHANGED
@@ -7,57 +7,50 @@ app = dash.Dash(__name__)
7
7
 
8
8
  app.layout = html.Div(
9
9
  [
10
- fac.AntdTable(
11
- columns=[
10
+ fac.AntdTree(
11
+ id='tree-search-demo',
12
+ treeData=[
12
13
  {
13
- 'title': '字段1-1-1',
14
- 'dataIndex': '字段1-1-1',
15
- 'group': ['字段1', '字段1-1']
14
+ 'title': '四川省',
15
+ 'key': '四川省',
16
+ 'children': [
17
+ {
18
+ 'title': '成都市',
19
+ 'key': '成都市'
20
+ },
21
+ {
22
+ 'title': '广安市',
23
+ 'key': '广安市'
24
+ }
25
+ ]
16
26
  },
17
27
  {
18
- 'title': '字段1-1-2',
19
- 'dataIndex': '字段1-1-2',
20
- 'group': ['字段1', '字段1-1']
21
- },
22
- {
23
- 'title': '字段1-2',
24
- 'dataIndex': '字段1-2',
25
- 'group': '字段1'
26
- },
27
- {
28
- 'title': '字段2',
29
- 'dataIndex': '字段2'
28
+ 'title': '重庆市',
29
+ 'key': '重庆市',
30
+ 'children': [
31
+ {
32
+ 'title': '渝中区',
33
+ 'key': '渝中区',
34
+ 'children': [
35
+ {
36
+ 'title': '解放碑街道',
37
+ 'key': '解放碑街道'
38
+ }
39
+ ]
40
+ },
41
+ {
42
+ 'title': '渝北区',
43
+ 'key': '渝北区'
44
+ }
45
+ ]
30
46
  }
31
47
  ],
32
- data=[
33
- {
34
- '字段1-1-1': 1,
35
- '字段1-1-2': 1,
36
- '字段1-2': 1,
37
- '字段2': 1
38
- }
39
- ] * 3,
40
- filterOptions={
41
- '字段1-1-1': {}
42
- },
43
- sortOptions={
44
- 'sortDataIndexes': ['字段1-1-1']
48
+ defaultExpandAll=True,
49
+ highlightStyle={
50
+ 'background': '#ffffb8',
51
+ 'padding': 0
45
52
  },
46
- bordered=True,
47
- conditionalStyleFuncs={
48
- '字段1-1-1': '''
49
- (record, index) => {
50
- console.log(record)
51
- if ( index % 2 === 1 ) {
52
- return {
53
- style: {
54
- backgroundColor: "#ebfbee"
55
- }
56
- }
57
- }
58
- }
59
- '''
60
- }
53
+ searchKeyword=['省', '市', '区', '街道']
61
54
  )
62
55
  ],
63
56
  style={
@@ -65,6 +58,5 @@ app.layout = html.Div(
65
58
  }
66
59
  )
67
60
 
68
-
69
61
  if __name__ == '__main__':
70
62
  app.run(debug=True)
package/webpack.config.js CHANGED
@@ -139,6 +139,12 @@ module.exports = (env, argv) => {
139
139
  name(module, chunks, cacheGroupKey) {
140
140
  return `${cacheGroupKey}-${chunks[0].name}`;
141
141
  }
142
+ },
143
+ shared: {
144
+ chunks: 'all',
145
+ minSize: 0,
146
+ minChunks: 2,
147
+ name: 'async-fac-shared'
142
148
  }
143
149
  }
144
150
  }