feffery_utils_components 0.1.1 → 0.1.3

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.
@@ -299,17 +299,6 @@
299
299
  "required": false,
300
300
  "description": ""
301
301
  },
302
- "width": {
303
- "type": {
304
- "name": "string"
305
- },
306
- "required": false,
307
- "description": "",
308
- "defaultValue": {
309
- "value": "'200px'",
310
- "computed": false
311
- }
312
- },
313
302
  "color": {
314
303
  "type": {
315
304
  "name": "string"
@@ -670,11 +659,7 @@
670
659
  "name": "string"
671
660
  },
672
661
  "required": false,
673
- "description": "",
674
- "defaultValue": {
675
- "value": "'#fffc51'",
676
- "computed": false
677
- }
662
+ "description": ""
678
663
  },
679
664
  "loading_state": {
680
665
  "type": {
@@ -2239,11 +2224,11 @@
2239
2224
  "required": false
2240
2225
  },
2241
2226
  "title": {
2242
- "name": "string",
2227
+ "name": "node",
2243
2228
  "required": false
2244
2229
  },
2245
2230
  "content": {
2246
- "name": "string",
2231
+ "name": "node",
2247
2232
  "required": false
2248
2233
  },
2249
2234
  "placement": {
@@ -2353,7 +2338,11 @@
2353
2338
  "name": "bool"
2354
2339
  },
2355
2340
  "required": false,
2356
- "description": ""
2341
+ "description": "",
2342
+ "defaultValue": {
2343
+ "value": "true",
2344
+ "computed": false
2345
+ }
2357
2346
  },
2358
2347
  "arrow": {
2359
2348
  "type": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feffery_utils_components",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Build more utility components for Plotly Dash.",
5
5
  "repository": {
6
6
  "type": "git",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feffery_utils_components",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Build more utility components for Plotly Dash.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -3,7 +3,7 @@ module FefferyUtilsComponents
3
3
  using Dash
4
4
 
5
5
  const resources_path = realpath(joinpath( @__DIR__, "..", "deps"))
6
- const version = "0.1.1"
6
+ const version = "0.1.3"
7
7
 
8
8
  include("jl/''_fefferyblockcolorpicker.jl")
9
9
  include("jl/''_fefferycirclecolorpicker.jl")
@@ -61,14 +61,14 @@ function __init__()
61
61
  [
62
62
  DashBase.Resource(
63
63
  relative_package_path = "feffery_utils_components.min.js",
64
- external_url = "https://unpkg.com/feffery_utils_components@0.1.1/feffery_utils_components/feffery_utils_components.min.js",
64
+ external_url = "https://unpkg.com/feffery_utils_components@0.1.3/feffery_utils_components/feffery_utils_components.min.js",
65
65
  dynamic = nothing,
66
66
  async = nothing,
67
67
  type = :js
68
68
  ),
69
69
  DashBase.Resource(
70
70
  relative_package_path = "feffery_utils_components.min.js.map",
71
- external_url = "https://unpkg.com/feffery_utils_components@0.1.1/feffery_utils_components/feffery_utils_components.min.js.map",
71
+ external_url = "https://unpkg.com/feffery_utils_components@0.1.3/feffery_utils_components/feffery_utils_components.min.js.map",
72
72
  dynamic = true,
73
73
  async = nothing,
74
74
  type = :js
@@ -19,10 +19,9 @@ Those elements have the following types:
19
19
  - `component_name` (String; optional): Holds the name of the component that is loading
20
20
  - `style` (Dict; optional)
21
21
  - `triangle` (a value equal to: 'hide', 'top-left', 'top-right'; optional)
22
- - `width` (String; optional)
23
22
  """
24
23
  function ''_fefferygithubcolorpicker(; kwargs...)
25
- available_props = Symbol[:id, :className, :color, :colors, :loading_state, :style, :triangle, :width]
24
+ available_props = Symbol[:id, :className, :color, :colors, :loading_state, :style, :triangle]
26
25
  wild_props = Symbol[]
27
26
  return Component("''_fefferygithubcolorpicker", "FefferyGithubColorPicker", "feffery_utils_components", available_props, wild_props; kwargs...)
28
27
  end
@@ -38,8 +38,8 @@ Those elements have the following types:
38
38
  - `left` (Real; optional)
39
39
  - `width` (Real; optional)
40
40
  - `height` (Real; optional)
41
- - `title` (String; optional)
42
- - `content` (String; optional)
41
+ - `title` (a list of or a singular dash component, string or number; optional)
42
+ - `content` (a list of or a singular dash component, string or number; optional)
43
43
  - `placement` (a value equal to: 'top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right', 'left-top', 'left-bottom', 'right-top', 'right-bottom'; optional)
44
44
  - `offset` (optional): . offset has the following type: lists containing elements 'x', 'y'.
45
45
  Those elements have the following types:
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import Guide from 'byte-guide'
3
3
  import PropTypes from 'prop-types';
4
+ import { isString } from 'lodash';
4
5
  import './styles.css'
5
6
 
6
7
  // 定义引导部件FefferyGuide,api参数参考https://github.com/bytedance/guide/blob/main/README.zh-CN.md
@@ -29,7 +30,6 @@ const FefferyGuide = (props) => {
29
30
  loading_state
30
31
  } = props;
31
32
 
32
- // 返回向页面注入的快捷键监听
33
33
  return (
34
34
  <Guide id={id}
35
35
  className={className}
@@ -43,13 +43,17 @@ const FefferyGuide = (props) => {
43
43
  mask={mask}
44
44
  arrow={arrow}
45
45
  hotspot={hotspot}
46
- stepText={typeof stepText === typeof ''
46
+ stepText={isString(stepText)
47
47
  ? eval(stepText) : stepText}
48
48
  nextText={nextText}
49
49
  prevText={prevText}
50
50
  showPreviousBtn={showPreviousBtn}
51
51
  okText={okText}
52
52
  step={step}
53
+ onClose={() => {
54
+ // 修复引导结束后页面整体无法滚动的问题
55
+ document.documentElement.style.overflow = 'auto'
56
+ }}
53
57
  data-dash-is-loading={
54
58
  (loading_state && loading_state.is_loading) || undefined
55
59
  } />
@@ -58,16 +62,14 @@ const FefferyGuide = (props) => {
58
62
 
59
63
  // 定义参数或属性
60
64
  FefferyGuide.propTypes = {
61
- // 部件id
65
+
62
66
  id: PropTypes.string,
63
67
 
64
- // css类名
65
68
  className: PropTypes.string,
66
69
 
67
- // 自定义css字典
68
70
  style: PropTypes.object,
69
71
 
70
- // 设置语言,可选的有'en'、'zh'
72
+ // 设置语言,可选的有'en'、'zh',默认为'zh'
71
73
  locale: PropTypes.oneOf(['zh', 'en']),
72
74
 
73
75
  // 必填,用于构造每一步锚定的页面元素
@@ -89,10 +91,10 @@ FefferyGuide.propTypes = {
89
91
  }),
90
92
 
91
93
  // 设置展示面板的标题内容
92
- title: PropTypes.string,
94
+ title: PropTypes.node,
93
95
 
94
96
  // 设置展示面板的描述内容
95
- content: PropTypes.string,
97
+ content: PropTypes.node,
96
98
 
97
99
  // 设置展示面板相对锚点的方位,可选的有'top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right', 'left-top', 'left-bottom',
98
100
  // 'right-top', 'right-bottom',默认为'bottom'
@@ -118,19 +120,19 @@ FefferyGuide.propTypes = {
118
120
  // 设置是否允许跳过引导,默认为true
119
121
  closable: PropTypes.bool,
120
122
 
121
- // 设置展示面板的类名
123
+ // 设置弹窗的css类
122
124
  modalClassName: PropTypes.string,
123
125
 
124
- // 设置蒙版层的类名
126
+ // 设置蒙版层css类
125
127
  maskClassName: PropTypes.string,
126
128
 
127
- // 设置是否展示蒙板层,默认为true
129
+ // 设置是否展示蒙版层,默认为true
128
130
  mask: PropTypes.bool,
129
131
 
130
132
  // 设置展示面板是否添加箭头,默认为true
131
133
  arrow: PropTypes.bool,
132
134
 
133
- // 设置展示面板是否展示热点,默认为false
135
+ // 设置展示面板是否展示热点标识,默认为false
134
136
  hotspot: PropTypes.bool,
135
137
 
136
138
  // 自定义步骤信息展示内容的回调函数,默认为"(stepIndex, stepCount) => { return '第${stepIndex}步,共${stepCount}步'; }"
@@ -176,7 +178,8 @@ FefferyGuide.propTypes = {
176
178
  // 设置默认参数
177
179
  FefferyGuide.defaultProps = {
178
180
  locale: 'zh',
179
- showPreviousBtn: true
181
+ showPreviousBtn: true,
182
+ mask: true
180
183
  }
181
184
 
182
185
  export default FefferyGuide;
@@ -1,3 +1,4 @@
1
+ import React, { useEffect } from 'react';
1
2
  import { BlockPicker } from 'react-color';
2
3
  import PropTypes from 'prop-types';
3
4
  import '../styles.css';
@@ -17,6 +18,15 @@ const FefferyBlockColorPicker = (props) => {
17
18
  loading_state
18
19
  } = props;
19
20
 
21
+ useEffect(() => {
22
+ if (colors && !color) {
23
+ // 默认缺省选中色为colors中第0个色彩
24
+ setProps({
25
+ color: colors[0]
26
+ })
27
+ }
28
+ }, [])
29
+
20
30
  return (
21
31
  <BlockPicker id={id}
22
32
  className={className}
@@ -43,7 +53,7 @@ FefferyBlockColorPicker.propTypes = {
43
53
  // 自定义css字典
44
54
  style: PropTypes.object,
45
55
 
46
- // 设置组件整体宽度,默认为'276px'
56
+ // 设置组件整体宽度,默认为'170px'
47
57
  width: PropTypes.string,
48
58
 
49
59
  // 对应当前选中的16进制色彩字符串
@@ -78,4 +88,4 @@ FefferyBlockColorPicker.defaultProps = {
78
88
  colors: ['#D9E3F0', '#F47373', '#697689', '#37D67A', '#2CCCE4', '#555555', '#dce775', '#ff8a65', '#ba68c8']
79
89
  }
80
90
 
81
- export default FefferyBlockColorPicker;
91
+ export default React.memo(FefferyBlockColorPicker);
@@ -1,3 +1,4 @@
1
+ import React, { useEffect } from 'react';
1
2
  import { CirclePicker } from 'react-color';
2
3
  import PropTypes from 'prop-types';
3
4
  import '../styles.css';
@@ -18,6 +19,15 @@ const FefferyCircleColorPicker = (props) => {
18
19
  loading_state
19
20
  } = props;
20
21
 
22
+ useEffect(() => {
23
+ if (colors && !color) {
24
+ // 默认缺省选中色为colors中第0个色彩
25
+ setProps({
26
+ color: colors[0]
27
+ })
28
+ }
29
+ }, [])
30
+
21
31
  return (
22
32
  <CirclePicker id={id}
23
33
  className={className}
@@ -84,4 +94,4 @@ FefferyCircleColorPicker.defaultProps = {
84
94
  colors: ["#f44336", "#e91e63", "#9c27b0", "#673ab7", "#3f51b5", "#2196f3", "#03a9f4", "#00bcd4", "#009688", "#4caf50", "#8bc34a", "#cddc39", "#ffeb3b", "#ffc107", "#ff9800", "#ff5722", "#795548", "#607d8b"]
85
95
  }
86
96
 
87
- export default FefferyCircleColorPicker;
97
+ export default React.memo(FefferyCircleColorPicker);
@@ -1,3 +1,4 @@
1
+ import React, { useEffect } from 'react';
1
2
  import { GithubPicker } from 'react-color';
2
3
  import PropTypes from 'prop-types';
3
4
  import '../styles.css';
@@ -9,7 +10,6 @@ const FefferyGithubColorPicker = (props) => {
9
10
  id,
10
11
  className,
11
12
  style,
12
- width,
13
13
  color,
14
14
  colors,
15
15
  triangle,
@@ -17,13 +17,22 @@ const FefferyGithubColorPicker = (props) => {
17
17
  loading_state
18
18
  } = props;
19
19
 
20
+
21
+ useEffect(() => {
22
+ if (colors && !color) {
23
+ // 默认缺省选中色为colors中第0个色彩
24
+ setProps({
25
+ color: colors[0]
26
+ })
27
+ }
28
+ }, [])
29
+
20
30
  return (
21
31
  <GithubPicker id={id}
22
32
  className={className}
23
33
  style={style}
24
34
  color={color}
25
35
  colors={colors}
26
- width={width}
27
36
  triangle={triangle}
28
37
  onChangeComplete={(c, e) => setProps({ color: c.hex })}
29
38
  data-dash-is-loading={
@@ -43,9 +52,6 @@ FefferyGithubColorPicker.propTypes = {
43
52
  // 自定义css字典
44
53
  style: PropTypes.object,
45
54
 
46
- // 设置组件整体宽度,默认为'200px'
47
- width: PropTypes.string,
48
-
49
55
  // 对应当前选中的16进制色彩字符串
50
56
  color: PropTypes.string,
51
57
 
@@ -74,8 +80,7 @@ FefferyGithubColorPicker.propTypes = {
74
80
  // 设置默认参数
75
81
  FefferyGithubColorPicker.defaultProps = {
76
82
  triangle: 'top-left',
77
- width: '200px',
78
83
  colors: ['#B80000', '#DB3E00', '#FCCB00', '#008B02', '#006B76', '#1273DE', '#004DCF', '#5300EB', '#EB9694', '#FAD0C3', '#FEF3BD', '#C1E1C5', '#BEDADC', '#C4DEF6', '#BED3F3', '#D4C4FB']
79
84
  }
80
85
 
81
- export default FefferyGithubColorPicker;
86
+ export default React.memo(FefferyGithubColorPicker);
@@ -1,3 +1,4 @@
1
+ import React, { useEffect } from 'react';
1
2
  import { TwitterPicker } from 'react-color';
2
3
  import PropTypes from 'prop-types';
3
4
  import '../styles.css';
@@ -17,6 +18,15 @@ const FefferyTwitterColorPicker = (props) => {
17
18
  loading_state
18
19
  } = props;
19
20
 
21
+ useEffect(() => {
22
+ if (colors && !color) {
23
+ // 默认缺省选中色为colors中第0个色彩
24
+ setProps({
25
+ color: colors[0]
26
+ })
27
+ }
28
+ }, [])
29
+
20
30
  return (
21
31
  <TwitterPicker id={id}
22
32
  className={className}
@@ -78,4 +88,4 @@ FefferyTwitterColorPicker.defaultProps = {
78
88
  colors: ['#FF6900', '#FCB900', '#7BDCB5', '#00D084', '#8ED1FC', '#0693E3', '#ABB8C3', '#EB144C', '#F78DA7', '#9900EF']
79
89
  }
80
90
 
81
- export default FefferyTwitterColorPicker;
91
+ export default React.memo(FefferyTwitterColorPicker);
@@ -1,3 +1,4 @@
1
+ import React, { useEffect } from 'react';
1
2
  import Wheel from '@uiw/react-color-wheel';
2
3
  import { hsvaToHex, hexToHsva } from '@uiw/color-convert'
3
4
  import PropTypes from 'prop-types';
@@ -15,12 +16,22 @@ const FefferyWheelColorPicker = (props) => {
15
16
  loading_state
16
17
  } = props;
17
18
 
19
+ useEffect(() => {
20
+ if (!color) {
21
+ setProps({
22
+ color: '#fffc51'
23
+ })
24
+ }
25
+ }, [])
26
+
18
27
  return (
19
28
  <Wheel id={id}
20
29
  className={className}
21
30
  style={style}
22
- color={color ? hexToHsva(color) : hexToHsva('#fffc51')}
23
- onChange={(c) => setProps({ color: hsvaToHex(c.hsva) })}
31
+ color={color}
32
+ onChange={(c) => {
33
+ setProps({ color: c.hex })
34
+ }}
24
35
  data-dash-is-loading={
25
36
  (loading_state && loading_state.is_loading) || undefined
26
37
  } />
@@ -59,7 +70,6 @@ FefferyWheelColorPicker.propTypes = {
59
70
 
60
71
  // 设置默认参数
61
72
  FefferyWheelColorPicker.defaultProps = {
62
- color: '#fffc51'
63
73
  }
64
74
 
65
- export default FefferyWheelColorPicker;
75
+ export default React.memo(FefferyWheelColorPicker);
@@ -111,3 +111,7 @@
111
111
  box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
112
112
  transition: box-shadow 0.3s ease-in-out;
113
113
  }
114
+
115
+ .github-picker {
116
+ box-sizing: content-box;
117
+ }
package/usage.py CHANGED
@@ -1,6 +1,5 @@
1
1
  import dash
2
- from dash import html
3
- import feffery_antd_components as fac
2
+ from dash import html, dcc
4
3
  import feffery_utils_components as fuc
5
4
  from dash.dependencies import Input, Output, State
6
5
 
@@ -8,59 +7,46 @@ app = dash.Dash(__name__)
8
7
 
9
8
  app.layout = html.Div(
10
9
  [
11
- fac.AntdSpace(
12
- [
13
- fac.AntdSwitch(
14
- id='css-var-demo',
15
- checked=False,
16
- unCheckedChildren='🌞',
17
- checkedChildren='🌛'
18
- ),
19
-
20
- fuc.FefferyCssVar(
21
- id='css-var-demo-output'
22
- ),
23
-
24
- html.Div(
25
- 'FefferyCssVar示例',
26
- style={
27
- 'background': 'var(--demo-bg-color)',
28
- 'color': 'var(--demo-color)',
29
- 'display': 'flex',
30
- 'justifyContent': 'center',
31
- 'alignItems': 'center',
32
- 'fontSize': '28px',
33
- 'transition': '0.2s',
34
- 'padding': '100px 150px'
35
- }
36
- )
37
- ],
38
- direction='vertical'
10
+ fuc.FefferyWheelColorPicker(
11
+ id='wheel-color-picker-demo'
12
+ ),
13
+
14
+ html.Div(
15
+ id='wheel-color-picker-demo-output',
16
+ style={
17
+ 'width': '200px',
18
+ 'height': '200px',
19
+ 'display': 'flex',
20
+ 'alignItems': 'center',
21
+ 'justifyContent': 'center',
22
+ 'borderRadius': '5px',
23
+ 'boxShadow': '0px 0px 12px rgba(0, 0, 0, .12)',
24
+ 'transition': '0.25s'
25
+ }
39
26
  )
40
27
  ],
41
28
  style={
42
- 'padding': '100px'
29
+ 'padding': '50px'
43
30
  }
44
31
  )
45
32
 
33
+
46
34
  @app.callback(
47
- Output('css-var-demo-output', 'cssVars'),
48
- Input('css-var-demo', 'checked')
35
+ [Output('wheel-color-picker-demo-output', 'style'),
36
+ Output('wheel-color-picker-demo-output', 'children')],
37
+ Input('wheel-color-picker-demo', 'color'),
38
+ State('wheel-color-picker-demo-output', 'style')
49
39
  )
50
- def css_var_demo(checked):
40
+ def wheel_color_picker_demo(color, old_style):
51
41
 
52
- print(checked)
42
+ return [
43
+ {
44
+ **old_style,
45
+ 'background': color
46
+ },
47
+ color
48
+ ]
53
49
 
54
- if checked:
55
- return {
56
- '--demo-bg-color': 'black',
57
- '--demo-color': 'white'
58
- }
59
-
60
- return {
61
- '--demo-bg-color': 'white',
62
- '--demo-color': 'black'
63
- }
64
50
 
65
51
  if __name__ == '__main__':
66
52
  app.run(debug=True)