feffery_utils_components 0.0.20 → 0.0.22

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 (45) hide show
  1. package/DESCRIPTION +1 -1
  2. package/NAMESPACE +3 -0
  3. package/Project.toml +1 -1
  4. package/build/lib/feffery_utils_components/FefferyCaptcha.py +5 -3
  5. package/build/lib/feffery_utils_components/FefferyDiv.py +9 -5
  6. package/build/lib/feffery_utils_components/FefferyDocumentVisibility.py +46 -0
  7. package/{feffery_utils_components/FefferySliderColorPicker.py → build/lib/feffery_utils_components/FefferyExternalCss.py} +9 -11
  8. package/build/lib/feffery_utils_components/FefferyGeolocation.py +46 -0
  9. package/build/lib/feffery_utils_components/FefferyIdle.py +48 -0
  10. package/build/lib/feffery_utils_components/FefferyKeyPress.py +48 -0
  11. package/build/lib/feffery_utils_components/FefferyResponsive.py +46 -0
  12. package/build/lib/feffery_utils_components/FefferySetTitle.py +46 -0
  13. package/build/lib/feffery_utils_components/FefferyTimeout.py +48 -0
  14. package/build/lib/feffery_utils_components/FefferyWindowSize.py +48 -0
  15. package/build/lib/feffery_utils_components/_imports_.py +18 -0
  16. package/build/lib/feffery_utils_components/feffery_utils_components.min.js +1 -1
  17. package/build/lib/feffery_utils_components/metadata.json +582 -10
  18. package/build/lib/feffery_utils_components/package-info.json +2 -1
  19. package/feffery_utils_components/FefferyCaptcha.py +5 -3
  20. package/feffery_utils_components/FefferyCountDown.py +50 -0
  21. package/feffery_utils_components/FefferyDiv.py +7 -5
  22. package/feffery_utils_components/FefferyKeyPress.py +48 -0
  23. package/feffery_utils_components/FefferyTimeout.py +48 -0
  24. package/feffery_utils_components/_imports_.py +6 -0
  25. package/feffery_utils_components/feffery_utils_components.min.js +1 -1
  26. package/feffery_utils_components/metadata.json +216 -2
  27. package/feffery_utils_components/package-info.json +1 -1
  28. package/package.json +1 -1
  29. package/src/FefferyUtilsComponents.jl +6 -3
  30. package/src/jl/''_fefferycaptcha.jl +2 -1
  31. package/src/jl/''_fefferycountdown.jl +26 -0
  32. package/src/jl/''_fefferydiv.jl +4 -3
  33. package/src/jl/''_fefferykeypress.jl +25 -0
  34. package/src/jl/''_fefferytimeout.jl +25 -0
  35. package/src/lib/components/FefferyCaptcha.react.js +14 -2
  36. package/src/lib/components/FefferyCountDown.react.js +92 -0
  37. package/src/lib/components/FefferyTimeout.react.js +68 -0
  38. package/src/lib/components/listeners/FefferyDiv.react.js +20 -11
  39. package/src/lib/components/listeners/FefferyKeyPress.react.js +69 -0
  40. package/src/lib/index.js +7 -1
  41. package/tests/FefferyCaptchaRefreshRef/app.py +49 -0
  42. package/tests/FefferyClickAwayTest/app.py +41 -0
  43. package/tests/FefferyCountDownTest/app.py +53 -0
  44. package/tests/FefferyKeyPressTest/app.py +43 -0
  45. package/tests/FefferyTimeoutTest/app.py +63 -0
@@ -844,6 +844,13 @@
844
844
  "required": false,
845
845
  "description": ""
846
846
  },
847
+ "refresh": {
848
+ "type": {
849
+ "name": "bool"
850
+ },
851
+ "required": false,
852
+ "description": ""
853
+ },
847
854
  "loading_state": {
848
855
  "type": {
849
856
  "name": "shape",
@@ -877,6 +884,76 @@
877
884
  }
878
885
  }
879
886
  },
887
+ "src/lib/components/FefferyCountDown.react.js": {
888
+ "description": "",
889
+ "displayName": "FefferyCountDown",
890
+ "methods": [],
891
+ "props": {
892
+ "id": {
893
+ "type": {
894
+ "name": "string"
895
+ },
896
+ "required": false,
897
+ "description": ""
898
+ },
899
+ "delay": {
900
+ "type": {
901
+ "name": "number"
902
+ },
903
+ "required": false,
904
+ "description": ""
905
+ },
906
+ "interval": {
907
+ "type": {
908
+ "name": "number"
909
+ },
910
+ "required": false,
911
+ "description": "",
912
+ "defaultValue": {
913
+ "value": "1",
914
+ "computed": false
915
+ }
916
+ },
917
+ "countdown": {
918
+ "type": {
919
+ "name": "number"
920
+ },
921
+ "required": false,
922
+ "description": ""
923
+ },
924
+ "setProps": {
925
+ "type": {
926
+ "name": "func"
927
+ },
928
+ "required": false,
929
+ "description": "Dash-assigned callback that should be called to report property changes\r\nto Dash, to make them available for callbacks."
930
+ },
931
+ "loading_state": {
932
+ "type": {
933
+ "name": "shape",
934
+ "value": {
935
+ "is_loading": {
936
+ "name": "bool",
937
+ "description": "Determines if the component is loading or not",
938
+ "required": false
939
+ },
940
+ "prop_name": {
941
+ "name": "string",
942
+ "description": "Holds which property is loading",
943
+ "required": false
944
+ },
945
+ "component_name": {
946
+ "name": "string",
947
+ "description": "Holds the name of the component that is loading",
948
+ "required": false
949
+ }
950
+ }
951
+ },
952
+ "required": false,
953
+ "description": ""
954
+ }
955
+ }
956
+ },
880
957
  "src/lib/components/FefferyExecuteJs.react.js": {
881
958
  "description": "",
882
959
  "displayName": "FefferyExecuteJs",
@@ -2539,6 +2616,69 @@
2539
2616
  }
2540
2617
  }
2541
2618
  },
2619
+ "src/lib/components/FefferyTimeout.react.js": {
2620
+ "description": "",
2621
+ "displayName": "FefferyTimeout",
2622
+ "methods": [],
2623
+ "props": {
2624
+ "id": {
2625
+ "type": {
2626
+ "name": "string"
2627
+ },
2628
+ "required": false,
2629
+ "description": ""
2630
+ },
2631
+ "timeoutCount": {
2632
+ "type": {
2633
+ "name": "number"
2634
+ },
2635
+ "required": false,
2636
+ "description": "",
2637
+ "defaultValue": {
2638
+ "value": "0",
2639
+ "computed": false
2640
+ }
2641
+ },
2642
+ "delay": {
2643
+ "type": {
2644
+ "name": "number"
2645
+ },
2646
+ "required": false,
2647
+ "description": ""
2648
+ },
2649
+ "setProps": {
2650
+ "type": {
2651
+ "name": "func"
2652
+ },
2653
+ "required": false,
2654
+ "description": "Dash-assigned callback that should be called to report property changes\r\nto Dash, to make them available for callbacks."
2655
+ },
2656
+ "loading_state": {
2657
+ "type": {
2658
+ "name": "shape",
2659
+ "value": {
2660
+ "is_loading": {
2661
+ "name": "bool",
2662
+ "description": "Determines if the component is loading or not",
2663
+ "required": false
2664
+ },
2665
+ "prop_name": {
2666
+ "name": "string",
2667
+ "description": "Holds which property is loading",
2668
+ "required": false
2669
+ },
2670
+ "component_name": {
2671
+ "name": "string",
2672
+ "description": "Holds the name of the component that is loading",
2673
+ "required": false
2674
+ }
2675
+ }
2676
+ },
2677
+ "required": false,
2678
+ "description": ""
2679
+ }
2680
+ }
2681
+ },
2542
2682
  "src/lib/components/FefferyTopProgress.react.js": {
2543
2683
  "description": "",
2544
2684
  "displayName": "FefferyTopProgress",
@@ -2846,7 +2986,7 @@
2846
2986
  "computed": false
2847
2987
  }
2848
2988
  },
2849
- "mouseEnterCounts": {
2989
+ "mouseEnterCount": {
2850
2990
  "type": {
2851
2991
  "name": "number"
2852
2992
  },
@@ -2857,7 +2997,7 @@
2857
2997
  "computed": false
2858
2998
  }
2859
2999
  },
2860
- "mouseLeaveCounts": {
3000
+ "mouseLeaveCount": {
2861
3001
  "type": {
2862
3002
  "name": "number"
2863
3003
  },
@@ -2929,6 +3069,17 @@
2929
3069
  "required": false,
2930
3070
  "description": ""
2931
3071
  },
3072
+ "clickAwayCount": {
3073
+ "type": {
3074
+ "name": "number"
3075
+ },
3076
+ "required": false,
3077
+ "description": "",
3078
+ "defaultValue": {
3079
+ "value": "0",
3080
+ "computed": false
3081
+ }
3082
+ },
2932
3083
  "setProps": {
2933
3084
  "type": {
2934
3085
  "name": "func"
@@ -3205,6 +3356,69 @@
3205
3356
  }
3206
3357
  }
3207
3358
  },
3359
+ "src/lib/components/listeners/FefferyKeyPress.react.js": {
3360
+ "description": "",
3361
+ "displayName": "FefferyKeyPress",
3362
+ "methods": [],
3363
+ "props": {
3364
+ "id": {
3365
+ "type": {
3366
+ "name": "string"
3367
+ },
3368
+ "required": false,
3369
+ "description": ""
3370
+ },
3371
+ "keys": {
3372
+ "type": {
3373
+ "name": "string"
3374
+ },
3375
+ "required": true,
3376
+ "description": ""
3377
+ },
3378
+ "pressedTimes": {
3379
+ "type": {
3380
+ "name": "number"
3381
+ },
3382
+ "required": false,
3383
+ "description": "",
3384
+ "defaultValue": {
3385
+ "value": "0",
3386
+ "computed": false
3387
+ }
3388
+ },
3389
+ "setProps": {
3390
+ "type": {
3391
+ "name": "func"
3392
+ },
3393
+ "required": false,
3394
+ "description": "Dash-assigned callback that should be called to report property changes\r\nto Dash, to make them available for callbacks."
3395
+ },
3396
+ "loading_state": {
3397
+ "type": {
3398
+ "name": "shape",
3399
+ "value": {
3400
+ "is_loading": {
3401
+ "name": "bool",
3402
+ "description": "Determines if the component is loading or not",
3403
+ "required": false
3404
+ },
3405
+ "prop_name": {
3406
+ "name": "string",
3407
+ "description": "Holds which property is loading",
3408
+ "required": false
3409
+ },
3410
+ "component_name": {
3411
+ "name": "string",
3412
+ "description": "Holds the name of the component that is loading",
3413
+ "required": false
3414
+ }
3415
+ }
3416
+ },
3417
+ "required": false,
3418
+ "description": ""
3419
+ }
3420
+ }
3421
+ },
3208
3422
  "src/lib/components/listeners/FefferyResponsive.react.js": {
3209
3423
  "description": "",
3210
3424
  "displayName": "FefferyResponsive",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feffery_utils_components",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
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.0.20",
3
+ "version": "0.0.22",
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.0.20"
6
+ const version = "0.0.22"
7
7
 
8
8
  include("jl/''_fefferyblockcolorpicker.jl")
9
9
  include("jl/''_fefferycirclecolorpicker.jl")
@@ -15,6 +15,7 @@ include("jl/''_fefferywheelcolorpicker.jl")
15
15
  include("jl/''_fefferyexternalcss.jl")
16
16
  include("jl/''_fefferysettitle.jl")
17
17
  include("jl/''_fefferycaptcha.jl")
18
+ include("jl/''_fefferycountdown.jl")
18
19
  include("jl/''_fefferyexecutejs.jl")
19
20
  include("jl/''_fefferyextraspinner.jl")
20
21
  include("jl/''_fefferyguide.jl")
@@ -25,6 +26,7 @@ include("jl/''_fefferyscroll.jl")
25
26
  include("jl/''_fefferyscrollbars.jl")
26
27
  include("jl/''_fefferyshortcutpanel.jl")
27
28
  include("jl/''_fefferysyntaxhighlighter.jl")
29
+ include("jl/''_fefferytimeout.jl")
28
30
  include("jl/''_fefferytopprogress.jl")
29
31
  include("jl/''_fefferyvirtuallist.jl")
30
32
  include("jl/''_fefferydiv.jl")
@@ -32,6 +34,7 @@ include("jl/''_fefferydocumentvisibility.jl")
32
34
  include("jl/''_fefferygeolocation.jl")
33
35
  include("jl/''_fefferyidle.jl")
34
36
  include("jl/''_fefferyinviewport.jl")
37
+ include("jl/''_fefferykeypress.jl")
35
38
  include("jl/''_fefferyresponsive.jl")
36
39
  include("jl/''_fefferywindowsize.jl")
37
40
  include("jl/''_fefferysplit.jl")
@@ -46,14 +49,14 @@ function __init__()
46
49
  [
47
50
  DashBase.Resource(
48
51
  relative_package_path = "feffery_utils_components.min.js",
49
- external_url = "https://unpkg.com/feffery_utils_components@0.0.20/feffery_utils_components/feffery_utils_components.min.js",
52
+ external_url = "https://unpkg.com/feffery_utils_components@0.0.22/feffery_utils_components/feffery_utils_components.min.js",
50
53
  dynamic = nothing,
51
54
  async = nothing,
52
55
  type = :js
53
56
  ),
54
57
  DashBase.Resource(
55
58
  relative_package_path = "feffery_utils_components.min.js.map",
56
- external_url = "https://unpkg.com/feffery_utils_components@0.0.20/feffery_utils_components/feffery_utils_components.min.js.map",
59
+ external_url = "https://unpkg.com/feffery_utils_components@0.0.22/feffery_utils_components/feffery_utils_components.min.js.map",
57
60
  dynamic = true,
58
61
  async = nothing,
59
62
  type = :js
@@ -20,11 +20,12 @@ Those elements have the following types:
20
20
  - `is_loading` (Bool; optional): Determines if the component is loading or not
21
21
  - `prop_name` (String; optional): Holds which property is loading
22
22
  - `component_name` (String; optional): Holds the name of the component that is loading
23
+ - `refresh` (Bool; optional)
23
24
  - `style` (Dict; optional)
24
25
  - `width` (Real; optional)
25
26
  """
26
27
  function ''_fefferycaptcha(; kwargs...)
27
- available_props = Symbol[:id, :bgColor, :captcha, :charNum, :className, :fontSize, :height, :loading_state, :style, :width]
28
+ available_props = Symbol[:id, :bgColor, :captcha, :charNum, :className, :fontSize, :height, :loading_state, :refresh, :style, :width]
28
29
  wild_props = Symbol[]
29
30
  return Component("''_fefferycaptcha", "FefferyCaptcha", "feffery_utils_components", available_props, wild_props; kwargs...)
30
31
  end
@@ -0,0 +1,26 @@
1
+ # AUTO GENERATED FILE - DO NOT EDIT
2
+
3
+ export ''_fefferycountdown
4
+
5
+ """
6
+ ''_fefferycountdown(;kwargs...)
7
+
8
+ A FefferyCountDown component.
9
+
10
+ Keyword arguments:
11
+ - `id` (String; optional)
12
+ - `countdown` (Real; optional)
13
+ - `delay` (Real; optional)
14
+ - `interval` (Real; optional)
15
+ - `loading_state` (optional): . loading_state has the following type: lists containing elements 'is_loading', 'prop_name', 'component_name'.
16
+ Those elements have the following types:
17
+ - `is_loading` (Bool; optional): Determines if the component is loading or not
18
+ - `prop_name` (String; optional): Holds which property is loading
19
+ - `component_name` (String; optional): Holds the name of the component that is loading
20
+ """
21
+ function ''_fefferycountdown(; kwargs...)
22
+ available_props = Symbol[:id, :countdown, :delay, :interval, :loading_state]
23
+ wild_props = Symbol[]
24
+ return Component("''_fefferycountdown", "FefferyCountDown", "feffery_utils_components", available_props, wild_props; kwargs...)
25
+ end
26
+
@@ -16,6 +16,7 @@ Keyword arguments:
16
16
  - `_height` (Real; optional)
17
17
  - `_width` (Real; optional)
18
18
  - `className` (String; optional)
19
+ - `clickAwayCount` (Real; optional)
19
20
  - `contextMenuEvent` (optional): . contextMenuEvent has the following type: lists containing elements 'pageX', 'pageY', 'timestamp'.
20
21
  Those elements have the following types:
21
22
  - `pageX` (Real; optional)
@@ -29,14 +30,14 @@ Those elements have the following types:
29
30
  - `is_loading` (Bool; optional): Determines if the component is loading or not
30
31
  - `prop_name` (String; optional): Holds which property is loading
31
32
  - `component_name` (String; optional): Holds the name of the component that is loading
32
- - `mouseEnterCounts` (Real; optional)
33
- - `mouseLeaveCounts` (Real; optional)
33
+ - `mouseEnterCount` (Real; optional)
34
+ - `mouseLeaveCount` (Real; optional)
34
35
  - `nClicks` (Real; optional)
35
36
  - `nDoubleClicks` (Real; optional)
36
37
  - `style` (Dict; optional)
37
38
  """
38
39
  function ''_fefferydiv(; kwargs...)
39
- available_props = Symbol[:children, :id, :_height, :_width, :className, :contextMenuEvent, :debounceWait, :enableListenContextMenu, :isHovering, :loading_state, :mouseEnterCounts, :mouseLeaveCounts, :nClicks, :nDoubleClicks, :style]
40
+ available_props = Symbol[:children, :id, :_height, :_width, :className, :clickAwayCount, :contextMenuEvent, :debounceWait, :enableListenContextMenu, :isHovering, :loading_state, :mouseEnterCount, :mouseLeaveCount, :nClicks, :nDoubleClicks, :style]
40
41
  wild_props = Symbol[]
41
42
  return Component("''_fefferydiv", "FefferyDiv", "feffery_utils_components", available_props, wild_props; kwargs...)
42
43
  end
@@ -0,0 +1,25 @@
1
+ # AUTO GENERATED FILE - DO NOT EDIT
2
+
3
+ export ''_fefferykeypress
4
+
5
+ """
6
+ ''_fefferykeypress(;kwargs...)
7
+
8
+ A FefferyKeyPress component.
9
+
10
+ Keyword arguments:
11
+ - `id` (String; optional)
12
+ - `keys` (String; required)
13
+ - `loading_state` (optional): . loading_state has the following type: lists containing elements 'is_loading', 'prop_name', 'component_name'.
14
+ Those elements have the following types:
15
+ - `is_loading` (Bool; optional): Determines if the component is loading or not
16
+ - `prop_name` (String; optional): Holds which property is loading
17
+ - `component_name` (String; optional): Holds the name of the component that is loading
18
+ - `pressedTimes` (Real; optional)
19
+ """
20
+ function ''_fefferykeypress(; kwargs...)
21
+ available_props = Symbol[:id, :keys, :loading_state, :pressedTimes]
22
+ wild_props = Symbol[]
23
+ return Component("''_fefferykeypress", "FefferyKeyPress", "feffery_utils_components", available_props, wild_props; kwargs...)
24
+ end
25
+
@@ -0,0 +1,25 @@
1
+ # AUTO GENERATED FILE - DO NOT EDIT
2
+
3
+ export ''_fefferytimeout
4
+
5
+ """
6
+ ''_fefferytimeout(;kwargs...)
7
+
8
+ A FefferyTimeout component.
9
+
10
+ Keyword arguments:
11
+ - `id` (String; optional)
12
+ - `delay` (Real; optional)
13
+ - `loading_state` (optional): . loading_state has the following type: lists containing elements 'is_loading', 'prop_name', 'component_name'.
14
+ Those elements have the following types:
15
+ - `is_loading` (Bool; optional): Determines if the component is loading or not
16
+ - `prop_name` (String; optional): Holds which property is loading
17
+ - `component_name` (String; optional): Holds the name of the component that is loading
18
+ - `timeoutCount` (Real; optional)
19
+ """
20
+ function ''_fefferytimeout(; kwargs...)
21
+ available_props = Symbol[:id, :delay, :loading_state, :timeoutCount]
22
+ wild_props = Symbol[]
23
+ return Component("''_fefferytimeout", "FefferyTimeout", "feffery_utils_components", available_props, wild_props; kwargs...)
24
+ end
25
+
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useRef } from 'react';
1
+ import React, { useCallback, useEffect, useRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Captcha from 'react-captcha-code';
4
4
 
@@ -15,6 +15,7 @@ const FefferyCaptcha = (props) => {
15
15
  width,
16
16
  bgColor,
17
17
  fontSize,
18
+ refresh,
18
19
  setProps,
19
20
  loading_state
20
21
  } = props;
@@ -24,6 +25,14 @@ const FefferyCaptcha = (props) => {
24
25
  setProps({ captcha: captcha })
25
26
  }, []);
26
27
 
28
+ // 当refresh变化为true时强制刷新验证码
29
+ useEffect(() => {
30
+ if (refresh && captchaRef.current) {
31
+ captchaRef.current.refresh()
32
+ setProps({ refresh: false })
33
+ }
34
+ }, [refresh])
35
+
27
36
  const captchaRef = useRef(< HTMLCanvasElement />);
28
37
 
29
38
  return (
@@ -72,6 +81,9 @@ FefferyCaptcha.propTypes = {
72
81
  // 设置验证码字体像素大小,默认为25
73
82
  fontSize: PropTypes.number,
74
83
 
84
+ // 用于手动刷新验证码,当传入true时会强制刷新验证码,再自动重置为false
85
+ refresh: PropTypes.bool,
86
+
75
87
  loading_state: PropTypes.shape({
76
88
  /**
77
89
  * Determines if the component is loading or not
@@ -99,4 +111,4 @@ FefferyCaptcha.defaultProps = {
99
111
  charNum: 4
100
112
  }
101
113
 
102
- export default FefferyCaptcha;
114
+ export default React.memo(FefferyCaptcha);
@@ -0,0 +1,92 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { useCountDown } from 'ahooks';
3
+ import PropTypes from 'prop-types';
4
+
5
+ // 定义倒计时执行组件FefferyCountDown
6
+ const FefferyCountDown = (props) => {
7
+
8
+ const {
9
+ id,
10
+ delay,
11
+ interval,
12
+ setProps,
13
+ loading_state
14
+ } = props;
15
+
16
+ const [targetDate, setTargetDate] = useState(null);
17
+
18
+ useEffect(() => {
19
+ if (delay) {
20
+ setTargetDate(Date.now() + 1000 * delay)
21
+ }
22
+ }, [delay])
23
+
24
+ const [_countdown] = useCountDown({
25
+ targetDate: targetDate,
26
+ interval: interval * 1000,
27
+ onEnd: () => {
28
+ setProps({
29
+ delay: undefined,
30
+ countdown: 0
31
+ })
32
+ }
33
+ });
34
+
35
+ useEffect(() => {
36
+ if (_countdown && delay) {
37
+ setProps({
38
+ countdown: Math.round(_countdown / 1000)
39
+ })
40
+ }
41
+ }, [_countdown])
42
+
43
+ return (<div
44
+ id={id}
45
+ data-dash-is-loading={
46
+ (loading_state && loading_state.is_loading) || undefined
47
+ } />);
48
+ }
49
+
50
+ // 定义参数或属性
51
+ FefferyCountDown.propTypes = {
52
+ // 部件id
53
+ id: PropTypes.string,
54
+
55
+ // 用于设置距离下一次超时事件触发的倒计时间隔(单位:秒)
56
+ // 每次有效的delay对应超时事件结束后都会被重置为undefined
57
+ delay: PropTypes.number,
58
+
59
+ // 设置倒计时时间间隔(单位:秒),默认为1
60
+ interval: PropTypes.number,
61
+
62
+ // 监听当前剩余时间秒数,默认为0
63
+ countdown: PropTypes.number,
64
+
65
+ /**
66
+ * Dash-assigned callback that should be called to report property changes
67
+ * to Dash, to make them available for callbacks.
68
+ */
69
+ setProps: PropTypes.func,
70
+
71
+ loading_state: PropTypes.shape({
72
+ /**
73
+ * Determines if the component is loading or not
74
+ */
75
+ is_loading: PropTypes.bool,
76
+ /**
77
+ * Holds which property is loading
78
+ */
79
+ prop_name: PropTypes.string,
80
+ /**
81
+ * Holds the name of the component that is loading
82
+ */
83
+ component_name: PropTypes.string
84
+ })
85
+ };
86
+
87
+ // 设置默认参数
88
+ FefferyCountDown.defaultProps = {
89
+ interval: 1
90
+ }
91
+
92
+ export default React.memo(FefferyCountDown);
@@ -0,0 +1,68 @@
1
+ import { useTimeout } from 'ahooks';
2
+ import PropTypes from 'prop-types';
3
+
4
+ // 定义定时执行组件FefferyTimeout
5
+ const FefferyTimeout = (props) => {
6
+
7
+ const {
8
+ id,
9
+ delay,
10
+ timeoutCount,
11
+ setProps,
12
+ loading_state
13
+ } = props;
14
+
15
+ useTimeout(() => {
16
+ setProps({
17
+ timeoutCount: timeoutCount + 1,
18
+ delay: undefined
19
+ });
20
+ }, delay);
21
+
22
+ return (<div
23
+ id={id}
24
+ data-dash-is-loading={
25
+ (loading_state && loading_state.is_loading) || undefined
26
+ } />);
27
+ }
28
+
29
+ // 定义参数或属性
30
+ FefferyTimeout.propTypes = {
31
+ // 部件id
32
+ id: PropTypes.string,
33
+
34
+ // 监听超时事件完成次数,默认为0
35
+ timeoutCount: PropTypes.number,
36
+
37
+ // 用于设置距离下一次超时事件触发的倒计时间隔(单位:毫秒)
38
+ // 每次有效的delay对应超时事件结束后都会被重置为undefined
39
+ delay: PropTypes.number,
40
+
41
+ /**
42
+ * Dash-assigned callback that should be called to report property changes
43
+ * to Dash, to make them available for callbacks.
44
+ */
45
+ setProps: PropTypes.func,
46
+
47
+ loading_state: PropTypes.shape({
48
+ /**
49
+ * Determines if the component is loading or not
50
+ */
51
+ is_loading: PropTypes.bool,
52
+ /**
53
+ * Holds which property is loading
54
+ */
55
+ prop_name: PropTypes.string,
56
+ /**
57
+ * Holds the name of the component that is loading
58
+ */
59
+ component_name: PropTypes.string
60
+ })
61
+ };
62
+
63
+ // 设置默认参数
64
+ FefferyTimeout.defaultProps = {
65
+ timeoutCount: 0
66
+ }
67
+
68
+ export default React.memo(FefferyTimeout);