feffery_utils_components 0.1.6 → 0.1.7

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.
@@ -4236,6 +4236,28 @@
4236
4236
  "computed": false
4237
4237
  }
4238
4238
  },
4239
+ "color": {
4240
+ "type": {
4241
+ "name": "string"
4242
+ },
4243
+ "required": false,
4244
+ "description": "",
4245
+ "defaultValue": {
4246
+ "value": "'#29d'",
4247
+ "computed": false
4248
+ }
4249
+ },
4250
+ "zIndex": {
4251
+ "type": {
4252
+ "name": "number"
4253
+ },
4254
+ "required": false,
4255
+ "description": "",
4256
+ "defaultValue": {
4257
+ "value": "99999",
4258
+ "computed": false
4259
+ }
4260
+ },
4239
4261
  "loading_state": {
4240
4262
  "type": {
4241
4263
  "name": "shape",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feffery_utils_components",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
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.6",
3
+ "version": "0.1.7",
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.6"
6
+ const version = "0.1.7"
7
7
 
8
8
  include("jl/''_fefferyblockcolorpicker.jl")
9
9
  include("jl/''_fefferycirclecolorpicker.jl")
@@ -62,14 +62,14 @@ function __init__()
62
62
  [
63
63
  DashBase.Resource(
64
64
  relative_package_path = "feffery_utils_components.min.js",
65
- external_url = "https://unpkg.com/feffery_utils_components@0.1.6/feffery_utils_components/feffery_utils_components.min.js",
65
+ external_url = "https://unpkg.com/feffery_utils_components@0.1.7/feffery_utils_components/feffery_utils_components.min.js",
66
66
  dynamic = nothing,
67
67
  async = nothing,
68
68
  type = :js
69
69
  ),
70
70
  DashBase.Resource(
71
71
  relative_package_path = "feffery_utils_components.min.js.map",
72
- external_url = "https://unpkg.com/feffery_utils_components@0.1.6/feffery_utils_components/feffery_utils_components.min.js.map",
72
+ external_url = "https://unpkg.com/feffery_utils_components@0.1.7/feffery_utils_components/feffery_utils_components.min.js.map",
73
73
  dynamic = true,
74
74
  async = nothing,
75
75
  type = :js
@@ -14,6 +14,7 @@ Keyword arguments:
14
14
  - `children` (a list of or a singular dash component, string or number; optional): The content of the tab - will only be displayed if this tab is selected
15
15
  - `id` (String; optional)
16
16
  - `className` (String; optional)
17
+ - `color` (String; optional)
17
18
  - `debug` (Bool; optional)
18
19
  - `easing` (String; optional)
19
20
  - `excludeProps` (Array of Strings; optional)
@@ -29,9 +30,10 @@ Those elements have the following types:
29
30
  - `speed` (Real; optional)
30
31
  - `spinning` (Bool; optional)
31
32
  - `style` (Dict; optional)
33
+ - `zIndex` (Real; optional)
32
34
  """
33
35
  function ''_fefferytopprogress(; kwargs...)
34
- available_props = Symbol[:children, :id, :className, :debug, :easing, :excludeProps, :includeProps, :listenPropsMode, :loading_state, :minimum, :showSpinner, :speed, :spinning, :style]
36
+ available_props = Symbol[:children, :id, :className, :color, :debug, :easing, :excludeProps, :includeProps, :listenPropsMode, :loading_state, :minimum, :showSpinner, :speed, :spinning, :style, :zIndex]
35
37
  wild_props = Symbol[]
36
38
  return Component("''_fefferytopprogress", "FefferyTopProgress", "feffery_utils_components", available_props, wild_props; kwargs...)
37
39
  end
@@ -1,180 +1,282 @@
1
1
  import React, { useState, useEffect, useRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import NProgress from 'nprogress';
4
- import './nprogress.css';
4
+ import FefferyStyle from './FefferyStyle.react';
5
+ // import './nprogress.css';
5
6
 
6
7
 
7
8
  const parseChildrenToArray = children => {
8
- if (children && !Array.isArray(children)) {
9
- return [children];
10
- }
11
- return children;
9
+ if (children && !Array.isArray(children)) {
10
+ return [children];
11
+ }
12
+ return children;
12
13
  };
13
14
 
14
15
  // 定义顶部加载进度条组件FefferyTopProgress,api参数参考https://github.com/rstacruz/nprogress
15
16
  const FefferyTopProgress = (props) => {
16
- // 取得必要属性或参数
17
- let {
18
- id,
19
- className,
20
- style,
21
- children,
22
- minimum,
23
- easing,
24
- speed,
25
- showSpinner,
26
- spinning,
27
- listenPropsMode,
28
- excludeProps,
29
- includeProps,
30
- debug,
31
- setProps,
32
- loading_state
33
- } = props;
34
-
35
- // 配置NProgress参数信息
36
- NProgress.configure({
37
- minimum,
38
- easing,
39
- speed,
40
- showSpinner
41
- })
42
-
43
- children = parseChildrenToArray(children)
44
-
45
- const [showSpinning, setShowSpinning] = useState(spinning);
46
- const timer = useRef();
47
-
48
- useEffect(() => {
49
- if (loading_state) {
50
- if (timer.current) {
51
- clearTimeout(timer.current);
17
+ // 取得必要属性或参数
18
+ let {
19
+ id,
20
+ className,
21
+ style,
22
+ children,
23
+ minimum,
24
+ easing,
25
+ speed,
26
+ showSpinner,
27
+ spinning,
28
+ listenPropsMode,
29
+ excludeProps,
30
+ includeProps,
31
+ debug,
32
+ color,
33
+ zIndex,
34
+ setProps,
35
+ loading_state
36
+ } = props;
37
+
38
+ // 配置NProgress参数信息
39
+ NProgress.configure({
40
+ minimum,
41
+ easing,
42
+ speed,
43
+ showSpinner
44
+ })
45
+
46
+ children = parseChildrenToArray(children)
47
+
48
+ const [showSpinning, setShowSpinning] = useState(spinning);
49
+ const timer = useRef();
50
+
51
+ useEffect(() => {
52
+ if (loading_state) {
53
+ if (timer.current) {
54
+ clearTimeout(timer.current);
55
+ }
56
+ if (loading_state.is_loading && !showSpinning) {
57
+ // 当listenPropsMode为'default'时
58
+ if (listenPropsMode === 'default') {
59
+ if (debug) {
60
+ console.log(loading_state.component_name + '.' + loading_state.prop_name)
61
+ }
62
+ setShowSpinning(true);
63
+ NProgress.start();
64
+ } else if (listenPropsMode === 'exclude') {
65
+ // 当listenPropsMode为'exclude'模式时
66
+ // 当前触发loading_state的组件+属性组合不在排除列表中时,激活动画
67
+ if (excludeProps.indexOf(loading_state.component_name + '.' + loading_state.prop_name) === -1) {
68
+ if (debug) {
69
+ console.log(loading_state.component_name + '.' + loading_state.prop_name)
52
70
  }
53
- if (loading_state.is_loading && !showSpinning) {
54
- // 当listenPropsMode为'default'时
55
- if (listenPropsMode === 'default') {
56
- if (debug) {
57
- console.log(loading_state.component_name + '.' + loading_state.prop_name)
58
- }
59
- setShowSpinning(true);
60
- NProgress.start();
61
- } else if (listenPropsMode === 'exclude') {
62
- // 当listenPropsMode为'exclude'模式时
63
- // 当前触发loading_state的组件+属性组合不在排除列表中时,激活动画
64
- if (excludeProps.indexOf(loading_state.component_name + '.' + loading_state.prop_name) === -1) {
65
- if (debug) {
66
- console.log(loading_state.component_name + '.' + loading_state.prop_name)
67
- }
68
- setShowSpinning(true);
69
- NProgress.start();
70
- }
71
- } else if (listenPropsMode === 'include') {
72
- // 当listenPropsMode为'include'模式时
73
- // 当前触发loading_state的组件+属性组合在包含列表中时,激活动画
74
- if (includeProps.indexOf(loading_state.component_name + '.' + loading_state.prop_name) !== -1) {
75
- if (debug) {
76
- console.log(loading_state.component_name + '.' + loading_state.prop_name)
77
- }
78
- setShowSpinning(true);
79
- NProgress.start();
80
- }
81
- }
82
-
83
- } else if (!loading_state.is_loading && showSpinning) {
84
- timer.current = setTimeout(() => {
85
- setShowSpinning(false);
86
- NProgress.done();
87
- });
71
+ setShowSpinning(true);
72
+ NProgress.start();
73
+ }
74
+ } else if (listenPropsMode === 'include') {
75
+ // 当listenPropsMode为'include'模式时
76
+ // 当前触发loading_state的组件+属性组合在包含列表中时,激活动画
77
+ if (includeProps.indexOf(loading_state.component_name + '.' + loading_state.prop_name) !== -1) {
78
+ if (debug) {
79
+ console.log(loading_state.component_name + '.' + loading_state.prop_name)
88
80
  }
81
+ setShowSpinning(true);
82
+ NProgress.start();
83
+ }
89
84
  }
90
- }, [loading_state]);
91
-
92
- // 返回定制化的前端组件
93
- return (<div id={id}
94
- className={className}
95
- style={style}
96
- data-dash-is-loading={
97
- (loading_state && loading_state.is_loading) || undefined
98
- } > {children} </div>
99
- );
85
+
86
+ } else if (!loading_state.is_loading && showSpinning) {
87
+ timer.current = setTimeout(() => {
88
+ setShowSpinning(false);
89
+ NProgress.done();
90
+ });
91
+ }
92
+ }
93
+ }, [loading_state]);
94
+
95
+ // 返回定制化的前端组件
96
+ return (<div id={id}
97
+ className={className}
98
+ style={style}
99
+ data-dash-is-loading={
100
+ (loading_state && loading_state.is_loading) || undefined
101
+ } >
102
+ <FefferyStyle
103
+ rawStyle={
104
+ `
105
+ #nprogress {
106
+ pointer-events: none;
107
+ }
108
+
109
+ #nprogress .bar {
110
+ background: ${color};
111
+
112
+ position: fixed;
113
+ z-index: ${zIndex};
114
+ top: 0;
115
+ left: 0;
116
+
117
+ width: 100%;
118
+ height: 2px;
119
+ }
120
+
121
+ /* Fancy blur effect */
122
+ #nprogress .peg {
123
+ display: block;
124
+ position: absolute;
125
+ right: 0px;
126
+ width: 100px;
127
+ height: 100%;
128
+ box-shadow: 0 0 10px ${color}, 0 0 5px ${color};
129
+ opacity: 1.0;
130
+
131
+ -webkit-transform: rotate(3deg) translate(0px, -4px);
132
+ -ms-transform: rotate(3deg) translate(0px, -4px);
133
+ transform: rotate(3deg) translate(0px, -4px);
134
+ }
135
+
136
+ /* Remove these to get rid of the spinner */
137
+ #nprogress .spinner {
138
+ display: block;
139
+ position: fixed;
140
+ z-index: ${zIndex};
141
+ top: 15px;
142
+ right: 15px;
143
+ }
144
+
145
+ #nprogress .spinner-icon {
146
+ width: 18px;
147
+ height: 18px;
148
+ box-sizing: border-box;
149
+
150
+ border: solid 2px transparent;
151
+ border-top-color: ${color};
152
+ border-left-color: ${color};
153
+ border-radius: 50%;
154
+
155
+ -webkit-animation: nprogress-spinner 400ms linear infinite;
156
+ animation: nprogress-spinner 400ms linear infinite;
157
+ }
158
+
159
+ .nprogress-custom-parent {
160
+ overflow: hidden;
161
+ position: relative;
162
+ }
163
+
164
+ .nprogress-custom-parent #nprogress .spinner,
165
+ .nprogress-custom-parent #nprogress .bar {
166
+ position: absolute;
167
+ }
168
+
169
+ @-webkit-keyframes nprogress-spinner {
170
+ 0% {
171
+ -webkit-transform: rotate(0deg);
172
+ }
173
+
174
+ 100% {
175
+ -webkit-transform: rotate(360deg);
176
+ }
177
+ }
178
+
179
+ @keyframes nprogress-spinner {
180
+ 0% {
181
+ transform: rotate(0deg);
182
+ }
183
+
184
+ 100% {
185
+ transform: rotate(360deg);
186
+ }
187
+ }
188
+ `
189
+ }
190
+ />
191
+ {children}
192
+ </div>
193
+ );
100
194
  }
101
195
 
102
196
  FefferyTopProgress._dashprivate_isLoadingComponent = true;
103
197
 
104
198
  // 定义参数或属性
105
199
  FefferyTopProgress.propTypes = {
106
- // 组件id
107
- id: PropTypes.string,
200
+ // 组件id
201
+ id: PropTypes.string,
108
202
 
109
- /**
110
- * The content of the tab - will only be displayed if this tab is selected
111
- */
112
- children: PropTypes.node,
203
+ /**
204
+ * The content of the tab - will only be displayed if this tab is selected
205
+ */
206
+ children: PropTypes.node,
207
+
208
+ // css类名
209
+ className: PropTypes.string,
113
210
 
114
- // css类名
115
- className: PropTypes.string,
211
+ // 自定义css字典
212
+ style: PropTypes.object,
116
213
 
117
- // 自定义css字典
118
- style: PropTypes.object,
214
+ // 设置是否处于加载中状态
215
+ spinning: PropTypes.bool,
119
216
 
120
- // 设置是否处于加载中状态
121
- spinning: PropTypes.bool,
217
+ // 设置顶端进度条的初始进度值,默认为0.33,取值在0到1之间
218
+ minimum: PropTypes.number,
122
219
 
123
- // 设置顶端进度条的初始进度值,默认为0.33,取值在0到1之间
124
- minimum: PropTypes.number,
220
+ // 用于设置同名css动画效果,默认为'ease'
221
+ easing: PropTypes.string,
125
222
 
126
- // 用于设置同名css动画效果,默认为'ease'
127
- easing: PropTypes.string,
223
+ // 设置进度条每步递增耗时(单位:毫秒),默认为200
224
+ speed: PropTypes.number,
128
225
 
129
- // 设置进度条每步递增耗时(单位:毫秒),默认为200
130
- speed: PropTypes.number,
226
+ // 设置是否渲染右上角圆圈加载动画,默认为true
227
+ showSpinner: PropTypes.bool,
131
228
 
132
- // 设置是否渲染右上角圆圈加载动画,默认为true
133
- showSpinner: PropTypes.bool,
229
+ // 设置是否开启debug模式,开启后,每次动画加载都会在开发者工具的控制台打印prop信息
230
+ debug: PropTypes.bool,
134
231
 
135
- // 设置是否开启debug模式,开启后,每次动画加载都会在开发者工具的控制台打印prop信息
136
- debug: PropTypes.bool,
232
+ // 设置自定义监听组件的模式,可选的有'default'、'exclude'、'include',默认为'default'
233
+ listenPropsMode: PropTypes.oneOf(['default', 'exclude', 'include']),
137
234
 
138
- // 设置自定义监听组件的模式,可选的有'default'、'exclude'、'include',默认为'default'
139
- listenPropsMode: PropTypes.oneOf(['default', 'exclude', 'include']),
235
+ // 设置需要忽略输出监听过程的组件信息列表
236
+ // 仅在listenPropsMode'exclude'时生效
237
+ excludeProps: PropTypes.arrayOf(PropTypes.string),
140
238
 
141
- // 设置需要忽略输出监听过程的组件信息列表
142
- // 仅在listenPropsMode为'exclude'时生效
143
- excludeProps: PropTypes.arrayOf(PropTypes.string),
239
+ // 设置需要包含输出监听过程的组件信息列表
240
+ // 仅在listenPropsMode为'include'时生效
241
+ includeProps: PropTypes.arrayOf(PropTypes.string),
144
242
 
145
- // 设置需要包含输出监听过程的组件信息列表
146
- // 仅在listenPropsMode为'include'时生效
147
- includeProps: PropTypes.arrayOf(PropTypes.string),
243
+ // 设置顶部进度条色彩,默认为'#29d'
244
+ color: PropTypes.string,
148
245
 
149
- loading_state: PropTypes.shape({
150
- /**
151
- * Determines if the component is loading or not
152
- */
153
- is_loading: PropTypes.bool,
154
- /**
155
- * Holds which property is loading
156
- */
157
- prop_name: PropTypes.string,
158
- /**
159
- * Holds the name of the component that is loading
160
- */
161
- component_name: PropTypes.string
162
- }),
246
+ // 设置顶部进度条的z-index,默认为99999
247
+ zIndex: PropTypes.number,
163
248
 
249
+ loading_state: PropTypes.shape({
164
250
  /**
165
- * Dash-assigned callback that should be called to report property changes
166
- * to Dash, to make them available for callbacks.
251
+ * Determines if the component is loading or not
167
252
  */
168
- setProps: PropTypes.func
253
+ is_loading: PropTypes.bool,
254
+ /**
255
+ * Holds which property is loading
256
+ */
257
+ prop_name: PropTypes.string,
258
+ /**
259
+ * Holds the name of the component that is loading
260
+ */
261
+ component_name: PropTypes.string
262
+ }),
263
+
264
+ /**
265
+ * Dash-assigned callback that should be called to report property changes
266
+ * to Dash, to make them available for callbacks.
267
+ */
268
+ setProps: PropTypes.func
169
269
  };
170
270
 
171
271
  // 设置默认参数
172
272
  FefferyTopProgress.defaultProps = {
173
- spinning: false,
174
- listenPropsMode: 'default',
175
- excludeProps: [],
176
- includeProps: [],
177
- debug: false
273
+ spinning: false,
274
+ listenPropsMode: 'default',
275
+ excludeProps: [],
276
+ includeProps: [],
277
+ debug: false,
278
+ color: '#29d',
279
+ zIndex: 99999
178
280
  }
179
281
 
180
282
  export default FefferyTopProgress;
package/usage.py CHANGED
@@ -1,4 +1,6 @@
1
1
  import dash
2
+ import time
3
+ from datetime import datetime
2
4
  from dash import html, dcc
3
5
  import feffery_utils_components as fuc
4
6
  from dash.dependencies import Input, Output, State