feffery_utils_components 0.2.0-rc12 → 0.2.0-rc13
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.
- package/DESCRIPTION +1 -1
- package/NAMESPACE +1 -0
- package/Project.toml +1 -1
- package/README.md +1 -1
- package/assets/demo.jpg +0 -0
- package/feffery_utils_components/FefferySliderCaptcha.py +109 -0
- package/feffery_utils_components/__init__.py +2 -1
- package/feffery_utils_components/_imports_.py +2 -0
- package/feffery_utils_components/async-feffery_animated_3d_background_p5.js +1 -1
- package/feffery_utils_components/async-feffery_animated_3d_background_three.js +2 -2
- package/feffery_utils_components/async-feffery_animated_image.js +1 -1
- package/feffery_utils_components/async-feffery_aplayer.js +1 -1
- package/feffery_utils_components/async-feffery_auto_animate.js +1 -1
- package/feffery_utils_components/async-feffery_auto_fit.js +1 -1
- package/feffery_utils_components/async-feffery_captcha.js +1 -1
- package/feffery_utils_components/async-feffery_color_pickers.js +1 -1
- package/feffery_utils_components/async-feffery_dom2image.js +1 -1
- package/feffery_utils_components/async-feffery_dplayer.js +1 -1
- package/feffery_utils_components/async-feffery_emoji_picker.js +1 -1
- package/feffery_utils_components/async-feffery_excel_preview.js +1 -1
- package/feffery_utils_components/async-feffery_extra_spinner.js +1 -1
- package/feffery_utils_components/async-feffery_fancy_button.js +1 -1
- package/feffery_utils_components/async-feffery_grid.js +1 -1
- package/feffery_utils_components/async-feffery_image_cropper.js +1 -1
- package/feffery_utils_components/async-feffery_json_viewer.js +1 -1
- package/feffery_utils_components/async-feffery_local_large_storage.js +1 -1
- package/feffery_utils_components/async-feffery_markdown_editor.js +2 -2
- package/feffery_utils_components/async-feffery_motion.js +1 -1
- package/feffery_utils_components/async-feffery_music_player.js +1 -1
- package/feffery_utils_components/async-feffery_photo_sphere_viewer.js +1 -1
- package/feffery_utils_components/async-feffery_resizable.js +1 -1
- package/feffery_utils_components/async-feffery_rich_text_editor.js +2 -2
- package/feffery_utils_components/async-feffery_rnd.js +1 -1
- package/feffery_utils_components/async-feffery_seamless_scroll.js +1 -1
- package/feffery_utils_components/async-feffery_shortcut_panel.js +1 -1
- package/feffery_utils_components/async-feffery_slider_captcha.js +1 -0
- package/feffery_utils_components/async-feffery_slider_captcha.js.LICENSE.txt +1 -0
- package/feffery_utils_components/async-feffery_sortable.js +1 -1
- package/feffery_utils_components/async-feffery_word_preview.js +1 -1
- package/feffery_utils_components/async-fuc-shared.js +2 -2
- package/feffery_utils_components/feffery_utils_components.min.js +2 -2
- package/feffery_utils_components/metadata.json +238 -0
- package/feffery_utils_components/package-info.json +3 -1
- package/package.json +3 -1
- package/src/lib/components/FefferySliderCaptcha.react.js +160 -0
- package/src/lib/fragments/FefferySliderCaptcha.react.js +102 -0
- package/src/lib/index.js +3 -1
- package/usage.py +24 -14
|
@@ -13763,6 +13763,244 @@
|
|
|
13763
13763
|
}
|
|
13764
13764
|
}
|
|
13765
13765
|
},
|
|
13766
|
+
"src/lib/components/FefferySliderCaptcha.react.js": {
|
|
13767
|
+
"description": "",
|
|
13768
|
+
"displayName": "FefferySliderCaptcha",
|
|
13769
|
+
"methods": [],
|
|
13770
|
+
"props": {
|
|
13771
|
+
"id": {
|
|
13772
|
+
"type": {
|
|
13773
|
+
"name": "string"
|
|
13774
|
+
},
|
|
13775
|
+
"required": false,
|
|
13776
|
+
"description": "\u7ec4\u4ef6id"
|
|
13777
|
+
},
|
|
13778
|
+
"className": {
|
|
13779
|
+
"type": {
|
|
13780
|
+
"name": "string"
|
|
13781
|
+
},
|
|
13782
|
+
"required": false,
|
|
13783
|
+
"description": "css\u7c7b\u540d"
|
|
13784
|
+
},
|
|
13785
|
+
"style": {
|
|
13786
|
+
"type": {
|
|
13787
|
+
"name": "object"
|
|
13788
|
+
},
|
|
13789
|
+
"required": false,
|
|
13790
|
+
"description": "css\u6837\u5f0f"
|
|
13791
|
+
},
|
|
13792
|
+
"imgSrc": {
|
|
13793
|
+
"type": {
|
|
13794
|
+
"name": "string"
|
|
13795
|
+
},
|
|
13796
|
+
"required": false,
|
|
13797
|
+
"description": "\u7528\u4e8e\u751f\u6210\u62fc\u56fe\u7684\u5b8c\u6574\u56fe\u7247\u5730\u5740"
|
|
13798
|
+
},
|
|
13799
|
+
"imgWidth": {
|
|
13800
|
+
"type": {
|
|
13801
|
+
"name": "number"
|
|
13802
|
+
},
|
|
13803
|
+
"required": false,
|
|
13804
|
+
"description": "\u58f0\u660e\u7528\u4e8e\u751f\u6210\u62fc\u56fe\u7684\u5b8c\u6574\u56fe\u7247\u50cf\u7d20\u5bbd\u5ea6\u503c"
|
|
13805
|
+
},
|
|
13806
|
+
"xOffset": {
|
|
13807
|
+
"type": {
|
|
13808
|
+
"name": "number"
|
|
13809
|
+
},
|
|
13810
|
+
"required": false,
|
|
13811
|
+
"description": "\u62fc\u56fe\u5408\u6cd5\u9a8c\u8bc1\u50cf\u7d20\u504f\u79fb\u91cf\r\n\u9ed8\u8ba4\u503c\uff1a`5`",
|
|
13812
|
+
"defaultValue": {
|
|
13813
|
+
"value": "5",
|
|
13814
|
+
"computed": false
|
|
13815
|
+
}
|
|
13816
|
+
},
|
|
13817
|
+
"mode": {
|
|
13818
|
+
"type": {
|
|
13819
|
+
"name": "enum",
|
|
13820
|
+
"value": [
|
|
13821
|
+
{
|
|
13822
|
+
"value": "'embed'",
|
|
13823
|
+
"computed": false
|
|
13824
|
+
},
|
|
13825
|
+
{
|
|
13826
|
+
"value": "'float'",
|
|
13827
|
+
"computed": false
|
|
13828
|
+
},
|
|
13829
|
+
{
|
|
13830
|
+
"value": "'slider'",
|
|
13831
|
+
"computed": false
|
|
13832
|
+
}
|
|
13833
|
+
]
|
|
13834
|
+
},
|
|
13835
|
+
"required": false,
|
|
13836
|
+
"description": "\u663e\u793a\u6a21\u5f0f\uff0c\u53ef\u9009\u9879\u6709`'embed'`\u3001`'float'`\u3001`'slider'`\r\n\u9ed8\u8ba4\u503c\uff1a`'embed'`",
|
|
13837
|
+
"defaultValue": {
|
|
13838
|
+
"value": "'embed'",
|
|
13839
|
+
"computed": false
|
|
13840
|
+
}
|
|
13841
|
+
},
|
|
13842
|
+
"tipText": {
|
|
13843
|
+
"type": {
|
|
13844
|
+
"name": "exact",
|
|
13845
|
+
"value": {
|
|
13846
|
+
"default": {
|
|
13847
|
+
"name": "node",
|
|
13848
|
+
"description": "\u9ed8\u8ba4\u63d0\u793a\u5185\u5bb9",
|
|
13849
|
+
"required": false
|
|
13850
|
+
},
|
|
13851
|
+
"loading": {
|
|
13852
|
+
"name": "node",
|
|
13853
|
+
"description": "\u52a0\u8f7d\u4e2d\u63d0\u793a\u5185\u5bb9",
|
|
13854
|
+
"required": false
|
|
13855
|
+
},
|
|
13856
|
+
"moving": {
|
|
13857
|
+
"name": "node",
|
|
13858
|
+
"description": "\u79fb\u52a8\u4e2d\u63d0\u793a\u5185\u5bb9",
|
|
13859
|
+
"required": false
|
|
13860
|
+
},
|
|
13861
|
+
"verifying": {
|
|
13862
|
+
"name": "node",
|
|
13863
|
+
"description": "\u9a8c\u8bc1\u4e2d\u63d0\u793a\u5185\u5bb9",
|
|
13864
|
+
"required": false
|
|
13865
|
+
},
|
|
13866
|
+
"success": {
|
|
13867
|
+
"name": "node",
|
|
13868
|
+
"description": "\u9a8c\u8bc1\u6210\u529f\u63d0\u793a\u5185\u5bb9",
|
|
13869
|
+
"required": false
|
|
13870
|
+
},
|
|
13871
|
+
"error": {
|
|
13872
|
+
"name": "node",
|
|
13873
|
+
"description": "\u9a8c\u8bc1\u5931\u8d25\u63d0\u793a\u5185\u5bb9",
|
|
13874
|
+
"required": false
|
|
13875
|
+
}
|
|
13876
|
+
}
|
|
13877
|
+
},
|
|
13878
|
+
"required": false,
|
|
13879
|
+
"description": "\u914d\u7f6e\u76f8\u5173\u6587\u6848\u63d0\u793a\u5185\u5bb9"
|
|
13880
|
+
},
|
|
13881
|
+
"showRefreshIcon": {
|
|
13882
|
+
"type": {
|
|
13883
|
+
"name": "bool"
|
|
13884
|
+
},
|
|
13885
|
+
"required": false,
|
|
13886
|
+
"description": "\u663e\u793a\u53f3\u4e0a\u89d2\u5237\u65b0\u6309\u94ae\r\n\u9ed8\u8ba4\u503c\uff1a`true`",
|
|
13887
|
+
"defaultValue": {
|
|
13888
|
+
"value": "true",
|
|
13889
|
+
"computed": false
|
|
13890
|
+
}
|
|
13891
|
+
},
|
|
13892
|
+
"autoRefreshOnError": {
|
|
13893
|
+
"type": {
|
|
13894
|
+
"name": "bool"
|
|
13895
|
+
},
|
|
13896
|
+
"required": false,
|
|
13897
|
+
"description": "\u9a8c\u8bc1\u5931\u8d25\u540e\u662f\u5426\u81ea\u52a8\u5237\u65b0\r\n\u9ed8\u8ba4\u503c\uff1a`true`",
|
|
13898
|
+
"defaultValue": {
|
|
13899
|
+
"value": "true",
|
|
13900
|
+
"computed": false
|
|
13901
|
+
}
|
|
13902
|
+
},
|
|
13903
|
+
"errorHoldDuration": {
|
|
13904
|
+
"type": {
|
|
13905
|
+
"name": "number"
|
|
13906
|
+
},
|
|
13907
|
+
"required": false,
|
|
13908
|
+
"description": "\u5f53`autoRefreshOnError=True`\u65f6\uff0c\u6bcf\u6b21\u9a8c\u8bc1\u5931\u8d25\u540e\u505c\u987f\u591a\u5c11\u6beb\u79d2\u81ea\u52a8\u5237\u65b0\r\n\u9ed8\u8ba4\u503c\uff1a`500`",
|
|
13909
|
+
"defaultValue": {
|
|
13910
|
+
"value": "500",
|
|
13911
|
+
"computed": false
|
|
13912
|
+
}
|
|
13913
|
+
},
|
|
13914
|
+
"placement": {
|
|
13915
|
+
"type": {
|
|
13916
|
+
"name": "enum",
|
|
13917
|
+
"value": [
|
|
13918
|
+
{
|
|
13919
|
+
"value": "'top'",
|
|
13920
|
+
"computed": false
|
|
13921
|
+
},
|
|
13922
|
+
{
|
|
13923
|
+
"value": "'bottom'",
|
|
13924
|
+
"computed": false
|
|
13925
|
+
}
|
|
13926
|
+
]
|
|
13927
|
+
},
|
|
13928
|
+
"required": false,
|
|
13929
|
+
"description": "\u62fc\u56fe\u56fe\u7247\u663e\u793a\u65b9\u4f4d\uff0c\u53ef\u9009\u9879\u6709`'top'`\u3001`'bottom'`\r\n\u9ed8\u8ba4\u503c\uff1a`'top'`",
|
|
13930
|
+
"defaultValue": {
|
|
13931
|
+
"value": "'top'",
|
|
13932
|
+
"computed": false
|
|
13933
|
+
}
|
|
13934
|
+
},
|
|
13935
|
+
"refresh": {
|
|
13936
|
+
"type": {
|
|
13937
|
+
"name": "bool"
|
|
13938
|
+
},
|
|
13939
|
+
"required": false,
|
|
13940
|
+
"description": "\u624b\u52a8\u5237\u65b0\u7528\uff0c\u6bcf\u6b21\u66f4\u65b0\u4e3a`True`\u65f6\u4f1a\u4e3b\u52a8\u89e6\u53d1\u5237\u65b0\uff0c\u6bcf\u6b21\u6210\u529f\u5237\u65b0\u540e\u4f1a\u91cd\u7f6e\u4e3a`False`"
|
|
13941
|
+
},
|
|
13942
|
+
"verifyResult": {
|
|
13943
|
+
"type": {
|
|
13944
|
+
"name": "exact",
|
|
13945
|
+
"value": {
|
|
13946
|
+
"status": {
|
|
13947
|
+
"name": "enum",
|
|
13948
|
+
"value": [
|
|
13949
|
+
{
|
|
13950
|
+
"value": "'success'",
|
|
13951
|
+
"computed": false
|
|
13952
|
+
},
|
|
13953
|
+
{
|
|
13954
|
+
"value": "'error'",
|
|
13955
|
+
"computed": false
|
|
13956
|
+
}
|
|
13957
|
+
],
|
|
13958
|
+
"description": "\u9a8c\u8bc1\u72b6\u6001\uff0c`'success'`\u8868\u793a\u9a8c\u8bc1\u6210\u529f\uff0c`'error'`\u8868\u793a\u9a8c\u8bc1\u5931\u8d25",
|
|
13959
|
+
"required": false
|
|
13960
|
+
},
|
|
13961
|
+
"timestamp": {
|
|
13962
|
+
"name": "number",
|
|
13963
|
+
"description": "\u4e8b\u4ef6\u53d1\u751f\u65f6\u95f4\u6233",
|
|
13964
|
+
"required": false
|
|
13965
|
+
}
|
|
13966
|
+
}
|
|
13967
|
+
},
|
|
13968
|
+
"required": false,
|
|
13969
|
+
"description": "\u76d1\u542c\u6700\u8fd1\u4e00\u6b21\u9a8c\u8bc1\u7ed3\u679c"
|
|
13970
|
+
},
|
|
13971
|
+
"loading_state": {
|
|
13972
|
+
"type": {
|
|
13973
|
+
"name": "shape",
|
|
13974
|
+
"value": {
|
|
13975
|
+
"is_loading": {
|
|
13976
|
+
"name": "bool",
|
|
13977
|
+
"description": "Determines if the component is loading or not",
|
|
13978
|
+
"required": false
|
|
13979
|
+
},
|
|
13980
|
+
"prop_name": {
|
|
13981
|
+
"name": "string",
|
|
13982
|
+
"description": "Holds which property is loading",
|
|
13983
|
+
"required": false
|
|
13984
|
+
},
|
|
13985
|
+
"component_name": {
|
|
13986
|
+
"name": "string",
|
|
13987
|
+
"description": "Holds the name of the component that is loading",
|
|
13988
|
+
"required": false
|
|
13989
|
+
}
|
|
13990
|
+
}
|
|
13991
|
+
},
|
|
13992
|
+
"required": false,
|
|
13993
|
+
"description": ""
|
|
13994
|
+
},
|
|
13995
|
+
"setProps": {
|
|
13996
|
+
"type": {
|
|
13997
|
+
"name": "func"
|
|
13998
|
+
},
|
|
13999
|
+
"required": false,
|
|
14000
|
+
"description": "Dash-assigned callback that should be called to report property changes\r\nto Dash, to make them available for callbacks."
|
|
14001
|
+
}
|
|
14002
|
+
}
|
|
14003
|
+
},
|
|
13766
14004
|
"src/lib/components/FefferySticky.react.js": {
|
|
13767
14005
|
"description": "",
|
|
13768
14006
|
"displayName": "FefferySticky",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "feffery_utils_components",
|
|
3
|
-
"version": "0.2.0-
|
|
3
|
+
"version": "0.2.0-rc13",
|
|
4
4
|
"description": "Build more utility components for Plotly Dash.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"byte-guide": "^1.0.7",
|
|
44
44
|
"cherry-markdown": "^0.8.31",
|
|
45
45
|
"comutils": "^1.1.19",
|
|
46
|
+
"create-puzzle": "^2.0.2",
|
|
46
47
|
"dashjs": "4.7.2",
|
|
47
48
|
"devtools-detector": "^2.0.15",
|
|
48
49
|
"emoji-mart": "^5.5.2",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
"pinyin_js": "^1.0.4",
|
|
63
64
|
"qrcode.react": "^3.1.0",
|
|
64
65
|
"ramda": "^0.26.1",
|
|
66
|
+
"rc-slider-captcha": "^1.3.0",
|
|
65
67
|
"rc-virtual-list": "^3.4.8",
|
|
66
68
|
"re-resizable": "^6.9.9",
|
|
67
69
|
"react-aplayer": "1.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "feffery_utils_components",
|
|
3
|
-
"version": "0.2.0-
|
|
3
|
+
"version": "0.2.0-rc13",
|
|
4
4
|
"description": "Build more utility components for Plotly Dash.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"byte-guide": "^1.0.7",
|
|
44
44
|
"cherry-markdown": "^0.8.31",
|
|
45
45
|
"comutils": "^1.1.19",
|
|
46
|
+
"create-puzzle": "^2.0.2",
|
|
46
47
|
"dashjs": "4.7.2",
|
|
47
48
|
"devtools-detector": "^2.0.15",
|
|
48
49
|
"emoji-mart": "^5.5.2",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
"pinyin_js": "^1.0.4",
|
|
63
64
|
"qrcode.react": "^3.1.0",
|
|
64
65
|
"ramda": "^0.26.1",
|
|
66
|
+
"rc-slider-captcha": "^1.3.0",
|
|
65
67
|
"rc-virtual-list": "^3.4.8",
|
|
66
68
|
"re-resizable": "^6.9.9",
|
|
67
69
|
"react-aplayer": "1.0.0",
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import React, { Suspense } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
const LazyFefferySliderCaptcha = React.lazy(() => import(/* webpackChunkName: "feffery_slider_captcha" */ '../fragments/FefferySliderCaptcha.react'));
|
|
5
|
+
|
|
6
|
+
const FefferySliderCaptcha = (props) => {
|
|
7
|
+
return (
|
|
8
|
+
<Suspense fallback={null}>
|
|
9
|
+
<LazyFefferySliderCaptcha {...props} />
|
|
10
|
+
</Suspense>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
FefferySliderCaptcha.propTypes = {
|
|
15
|
+
/**
|
|
16
|
+
* 组件id
|
|
17
|
+
*/
|
|
18
|
+
id: PropTypes.string,
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* css类名
|
|
22
|
+
*/
|
|
23
|
+
className: PropTypes.string,
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* css样式
|
|
27
|
+
*/
|
|
28
|
+
style: PropTypes.object,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 用于生成拼图的完整图片地址
|
|
32
|
+
*/
|
|
33
|
+
imgSrc: PropTypes.string,
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 声明用于生成拼图的完整图片像素宽度值
|
|
37
|
+
*/
|
|
38
|
+
imgWidth: PropTypes.number,
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 拼图合法验证像素偏移量
|
|
42
|
+
* 默认值:`5`
|
|
43
|
+
*/
|
|
44
|
+
xOffset: PropTypes.number,
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 显示模式,可选项有`'embed'`、`'float'`、`'slider'`
|
|
48
|
+
* 默认值:`'embed'`
|
|
49
|
+
*/
|
|
50
|
+
mode: PropTypes.oneOf(['embed', 'float', 'slider']),
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 配置相关文案提示内容
|
|
54
|
+
*/
|
|
55
|
+
tipText: PropTypes.exact({
|
|
56
|
+
/**
|
|
57
|
+
* 默认提示内容
|
|
58
|
+
*/
|
|
59
|
+
default: PropTypes.node,
|
|
60
|
+
/**
|
|
61
|
+
* 加载中提示内容
|
|
62
|
+
*/
|
|
63
|
+
loading: PropTypes.node,
|
|
64
|
+
/**
|
|
65
|
+
* 移动中提示内容
|
|
66
|
+
*/
|
|
67
|
+
moving: PropTypes.node,
|
|
68
|
+
/**
|
|
69
|
+
* 验证中提示内容
|
|
70
|
+
*/
|
|
71
|
+
verifying: PropTypes.node,
|
|
72
|
+
/**
|
|
73
|
+
* 验证成功提示内容
|
|
74
|
+
*/
|
|
75
|
+
success: PropTypes.node,
|
|
76
|
+
/**
|
|
77
|
+
* 验证失败提示内容
|
|
78
|
+
*/
|
|
79
|
+
error: PropTypes.node
|
|
80
|
+
}),
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 显示右上角刷新按钮
|
|
84
|
+
* 默认值:`true`
|
|
85
|
+
*/
|
|
86
|
+
showRefreshIcon: PropTypes.bool,
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 验证失败后是否自动刷新
|
|
90
|
+
* 默认值:`true`
|
|
91
|
+
*/
|
|
92
|
+
autoRefreshOnError: PropTypes.bool,
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 当`autoRefreshOnError=True`时,每次验证失败后停顿多少毫秒自动刷新
|
|
96
|
+
* 默认值:`500`
|
|
97
|
+
*/
|
|
98
|
+
errorHoldDuration: PropTypes.number,
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 拼图图片显示方位,可选项有`'top'`、`'bottom'`
|
|
102
|
+
* 默认值:`'top'`
|
|
103
|
+
*/
|
|
104
|
+
placement: PropTypes.oneOf(['top', 'bottom']),
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 手动刷新用,每次更新为`True`时会主动触发刷新,每次成功刷新后会重置为`False`
|
|
108
|
+
*/
|
|
109
|
+
refresh: PropTypes.bool,
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 监听最近一次验证结果
|
|
113
|
+
*/
|
|
114
|
+
verifyResult: PropTypes.exact({
|
|
115
|
+
/**
|
|
116
|
+
* 验证状态,`'success'`表示验证成功,`'error'`表示验证失败
|
|
117
|
+
*/
|
|
118
|
+
status: PropTypes.oneOf(['success', 'error']),
|
|
119
|
+
/**
|
|
120
|
+
* 事件发生时间戳
|
|
121
|
+
*/
|
|
122
|
+
timestamp: PropTypes.number
|
|
123
|
+
}),
|
|
124
|
+
|
|
125
|
+
loading_state: PropTypes.shape({
|
|
126
|
+
/**
|
|
127
|
+
* Determines if the component is loading or not
|
|
128
|
+
*/
|
|
129
|
+
is_loading: PropTypes.bool,
|
|
130
|
+
/**
|
|
131
|
+
* Holds which property is loading
|
|
132
|
+
*/
|
|
133
|
+
prop_name: PropTypes.string,
|
|
134
|
+
/**
|
|
135
|
+
* Holds the name of the component that is loading
|
|
136
|
+
*/
|
|
137
|
+
component_name: PropTypes.string
|
|
138
|
+
}),
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Dash-assigned callback that should be called to report property changes
|
|
142
|
+
* to Dash, to make them available for callbacks.
|
|
143
|
+
*/
|
|
144
|
+
setProps: PropTypes.func
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// 设置默认参数
|
|
148
|
+
FefferySliderCaptcha.defaultProps = {
|
|
149
|
+
xOffset: 5,
|
|
150
|
+
mode: 'embed',
|
|
151
|
+
showRefreshIcon: true,
|
|
152
|
+
autoRefreshOnError: true,
|
|
153
|
+
errorHoldDuration: 500,
|
|
154
|
+
placement: 'top'
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export default FefferySliderCaptcha;
|
|
158
|
+
|
|
159
|
+
export const propTypes = FefferySliderCaptcha.propTypes;
|
|
160
|
+
export const defaultProps = FefferySliderCaptcha.defaultProps;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import SliderCaptcha from 'rc-slider-captcha';
|
|
3
|
+
import createPuzzle from 'create-puzzle';
|
|
4
|
+
import { propTypes, defaultProps } from '../components/FefferySliderCaptcha.react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 滑块验证码组件FefferySliderCaptcha
|
|
8
|
+
*/
|
|
9
|
+
const FefferySliderCaptcha = (props) => {
|
|
10
|
+
let {
|
|
11
|
+
id,
|
|
12
|
+
style,
|
|
13
|
+
className,
|
|
14
|
+
imgSrc,
|
|
15
|
+
xOffset,
|
|
16
|
+
imgWidth,
|
|
17
|
+
mode,
|
|
18
|
+
tipText,
|
|
19
|
+
showRefreshIcon,
|
|
20
|
+
autoRefreshOnError,
|
|
21
|
+
errorHoldDuration,
|
|
22
|
+
placement,
|
|
23
|
+
refresh,
|
|
24
|
+
setProps,
|
|
25
|
+
loading_state
|
|
26
|
+
} = props;
|
|
27
|
+
|
|
28
|
+
// 记录x轴动态偏移量
|
|
29
|
+
const offsetXRef = useRef(0);
|
|
30
|
+
// 手动刷新用
|
|
31
|
+
const actionRef = useRef();
|
|
32
|
+
|
|
33
|
+
// 手动刷新
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (refresh) {
|
|
36
|
+
actionRef.current?.refresh()
|
|
37
|
+
setProps({ refresh: false })
|
|
38
|
+
}
|
|
39
|
+
}, [refresh])
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<SliderCaptcha
|
|
43
|
+
id={id}
|
|
44
|
+
style={style}
|
|
45
|
+
className={className}
|
|
46
|
+
actionRef={actionRef}
|
|
47
|
+
request={
|
|
48
|
+
() => createPuzzle(
|
|
49
|
+
imgSrc,
|
|
50
|
+
{
|
|
51
|
+
format: 'blob'
|
|
52
|
+
}
|
|
53
|
+
).then((res) => {
|
|
54
|
+
// 更新x轴动态偏移量
|
|
55
|
+
offsetXRef.current = res.x;
|
|
56
|
+
return {
|
|
57
|
+
bgUrl: res.bgUrl,
|
|
58
|
+
puzzleUrl: res.puzzleUrl
|
|
59
|
+
};
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
onVerify={
|
|
63
|
+
async (data) => {
|
|
64
|
+
if (data.x >= offsetXRef.current - xOffset && data.x < offsetXRef.current + xOffset) {
|
|
65
|
+
// 验证成功
|
|
66
|
+
setProps({
|
|
67
|
+
verifyResult: {
|
|
68
|
+
status: 'success',
|
|
69
|
+
timestamp: Date.now()
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
return Promise.resolve();
|
|
73
|
+
}
|
|
74
|
+
// 验证失败
|
|
75
|
+
setProps({
|
|
76
|
+
verifyResult: {
|
|
77
|
+
status: 'error',
|
|
78
|
+
timestamp: Date.now()
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
return Promise.reject();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
bgSize={{
|
|
85
|
+
width: imgWidth
|
|
86
|
+
}}
|
|
87
|
+
mode={mode}
|
|
88
|
+
tipText={tipText}
|
|
89
|
+
showRefreshIcon={showRefreshIcon}
|
|
90
|
+
autoRefreshOnError={autoRefreshOnError}
|
|
91
|
+
errorHoldDuration={errorHoldDuration}
|
|
92
|
+
placement={placement}
|
|
93
|
+
data-dash-is-loading={
|
|
94
|
+
(loading_state && loading_state.is_loading) || undefined
|
|
95
|
+
} />
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export default FefferySliderCaptcha;
|
|
100
|
+
|
|
101
|
+
FefferySliderCaptcha.defaultProps = defaultProps;
|
|
102
|
+
FefferySliderCaptcha.propTypes = propTypes;
|
package/src/lib/index.js
CHANGED
|
@@ -104,6 +104,7 @@ import FefferyAnimatedImage from "./components/FefferyAnimatedImage.react";
|
|
|
104
104
|
import FefferyDebugGuardian from "./components/security/FefferyDebugGuardian.react";
|
|
105
105
|
import FefferyDom2Image from "./components/FefferyDom2Image.react";
|
|
106
106
|
import FefferySetFavicon from "./components/FefferySetFavicon.react";
|
|
107
|
+
import FefferySliderCaptcha from "./components/FefferySliderCaptcha.react";
|
|
107
108
|
import './components/styles.css';
|
|
108
109
|
|
|
109
110
|
// 自定义sessionStorage事件监听
|
|
@@ -232,5 +233,6 @@ export {
|
|
|
232
233
|
FefferyAnimatedImage,
|
|
233
234
|
FefferyDebugGuardian,
|
|
234
235
|
FefferyDom2Image,
|
|
235
|
-
FefferySetFavicon
|
|
236
|
+
FefferySetFavicon,
|
|
237
|
+
FefferySliderCaptcha
|
|
236
238
|
};
|
package/usage.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import dash
|
|
2
|
+
import json
|
|
2
3
|
from dash import html
|
|
3
4
|
import feffery_utils_components as fuc
|
|
4
5
|
from dash.dependencies import Input, Output
|
|
@@ -8,31 +9,40 @@ app = dash.Dash(__name__)
|
|
|
8
9
|
app.layout = html.Div(
|
|
9
10
|
[
|
|
10
11
|
html.Button(
|
|
11
|
-
'
|
|
12
|
-
id='
|
|
12
|
+
'手动刷新',
|
|
13
|
+
id='manual-refresh'
|
|
13
14
|
),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)
|
|
15
|
+
fuc.FefferySliderCaptcha(
|
|
16
|
+
id='demo-slider-captcha',
|
|
17
|
+
imgSrc='/assets/demo.jpg',
|
|
18
|
+
imgWidth=360
|
|
19
|
+
),
|
|
20
|
+
html.Pre(id='demo-output')
|
|
20
21
|
],
|
|
21
22
|
style={
|
|
22
|
-
'padding': '
|
|
23
|
+
'padding': '300px 100px'
|
|
23
24
|
}
|
|
24
25
|
)
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
@app.callback(
|
|
28
|
-
Output('demo-
|
|
29
|
-
Input('
|
|
29
|
+
Output('demo-slider-captcha', 'refresh'),
|
|
30
|
+
Input('manual-refresh', 'n_clicks'),
|
|
30
31
|
prevent_initial_call=True
|
|
31
32
|
)
|
|
32
|
-
def
|
|
33
|
+
def manual_refresh(n_clicks):
|
|
34
|
+
return True
|
|
35
|
+
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
@app.callback(
|
|
38
|
+
Output('demo-output', 'children'),
|
|
39
|
+
Input('demo-slider-captcha', 'verifyResult')
|
|
40
|
+
)
|
|
41
|
+
def update_output(verifyResult):
|
|
42
|
+
return json.dumps(
|
|
43
|
+
verifyResult,
|
|
44
|
+
indent=4,
|
|
45
|
+
ensure_ascii=False
|
|
36
46
|
)
|
|
37
47
|
|
|
38
48
|
|