feffery_utils_components 0.0.32 → 0.1.0

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.
@@ -210,6 +210,69 @@
210
210
  }
211
211
  }
212
212
  },
213
+ "src/lib/components/colorPickers/FefferyEyeDropper.react.js": {
214
+ "description": "",
215
+ "displayName": "FefferyEyeDropper",
216
+ "methods": [],
217
+ "props": {
218
+ "id": {
219
+ "type": {
220
+ "name": "string"
221
+ },
222
+ "required": false,
223
+ "description": ""
224
+ },
225
+ "enable": {
226
+ "type": {
227
+ "name": "bool"
228
+ },
229
+ "required": false,
230
+ "description": "",
231
+ "defaultValue": {
232
+ "value": "false",
233
+ "computed": false
234
+ }
235
+ },
236
+ "color": {
237
+ "type": {
238
+ "name": "string"
239
+ },
240
+ "required": false,
241
+ "description": ""
242
+ },
243
+ "loading_state": {
244
+ "type": {
245
+ "name": "shape",
246
+ "value": {
247
+ "is_loading": {
248
+ "name": "bool",
249
+ "description": "Determines if the component is loading or not",
250
+ "required": false
251
+ },
252
+ "prop_name": {
253
+ "name": "string",
254
+ "description": "Holds which property is loading",
255
+ "required": false
256
+ },
257
+ "component_name": {
258
+ "name": "string",
259
+ "description": "Holds the name of the component that is loading",
260
+ "required": false
261
+ }
262
+ }
263
+ },
264
+ "required": false,
265
+ "description": ""
266
+ },
267
+ "setProps": {
268
+ "type": {
269
+ "name": "func"
270
+ },
271
+ "required": false,
272
+ "description": "Dash-assigned callback that should be called to report property changes\r\nto Dash, to make them available for callbacks."
273
+ }
274
+ }
275
+ },
213
276
  "src/lib/components/colorPickers/FefferyGithubColorPicker.react.js": {
214
277
  "description": "",
215
278
  "displayName": "FefferyGithubColorPicker",
@@ -1113,6 +1176,17 @@
1113
1176
  "computed": false
1114
1177
  }
1115
1178
  },
1179
+ "enableClickAway": {
1180
+ "type": {
1181
+ "name": "bool"
1182
+ },
1183
+ "required": false,
1184
+ "description": "",
1185
+ "defaultValue": {
1186
+ "value": "false",
1187
+ "computed": false
1188
+ }
1189
+ },
1116
1190
  "setProps": {
1117
1191
  "type": {
1118
1192
  "name": "func"
@@ -1612,69 +1686,6 @@
1612
1686
  }
1613
1687
  }
1614
1688
  },
1615
- "src/lib/components/FefferyEyeDropper.react.js": {
1616
- "description": "",
1617
- "displayName": "FefferyEyeDropper",
1618
- "methods": [],
1619
- "props": {
1620
- "id": {
1621
- "type": {
1622
- "name": "string"
1623
- },
1624
- "required": false,
1625
- "description": ""
1626
- },
1627
- "enable": {
1628
- "type": {
1629
- "name": "bool"
1630
- },
1631
- "required": false,
1632
- "description": "",
1633
- "defaultValue": {
1634
- "value": "false",
1635
- "computed": false
1636
- }
1637
- },
1638
- "color": {
1639
- "type": {
1640
- "name": "string"
1641
- },
1642
- "required": false,
1643
- "description": ""
1644
- },
1645
- "loading_state": {
1646
- "type": {
1647
- "name": "shape",
1648
- "value": {
1649
- "is_loading": {
1650
- "name": "bool",
1651
- "description": "Determines if the component is loading or not",
1652
- "required": false
1653
- },
1654
- "prop_name": {
1655
- "name": "string",
1656
- "description": "Holds which property is loading",
1657
- "required": false
1658
- },
1659
- "component_name": {
1660
- "name": "string",
1661
- "description": "Holds the name of the component that is loading",
1662
- "required": false
1663
- }
1664
- }
1665
- },
1666
- "required": false,
1667
- "description": ""
1668
- },
1669
- "setProps": {
1670
- "type": {
1671
- "name": "func"
1672
- },
1673
- "required": false,
1674
- "description": "Dash-assigned callback that should be called to report property changes\r\nto Dash, to make them available for callbacks."
1675
- }
1676
- }
1677
- },
1678
1689
  "src/lib/components/FefferyFancyMessage.js": {
1679
1690
  "description": "",
1680
1691
  "displayName": "FefferyFancyMessage",
@@ -2788,96 +2799,6 @@
2788
2799
  }
2789
2800
  }
2790
2801
  },
2791
- "src/lib/components/FefferyLocation.react.js": {
2792
- "description": "",
2793
- "displayName": "FefferyLocation",
2794
- "methods": [
2795
- {
2796
- "name": "updateLocation",
2797
- "docblock": null,
2798
- "modifiers": [],
2799
- "params": [
2800
- {
2801
- "name": "props",
2802
- "type": null
2803
- }
2804
- ],
2805
- "returns": null
2806
- },
2807
- {
2808
- "name": "onLocationChange",
2809
- "docblock": null,
2810
- "modifiers": [],
2811
- "params": [],
2812
- "returns": null
2813
- }
2814
- ],
2815
- "props": {
2816
- "id": {
2817
- "type": {
2818
- "name": "string"
2819
- },
2820
- "required": true,
2821
- "description": "The ID of this component, used to identify dash components\r\nin callbacks. The ID needs to be unique across all of the\r\ncomponents in an app."
2822
- },
2823
- "pathname": {
2824
- "type": {
2825
- "name": "string"
2826
- },
2827
- "required": false,
2828
- "description": "pathname in window.location - e.g., \"/my/full/pathname\""
2829
- },
2830
- "search": {
2831
- "type": {
2832
- "name": "string"
2833
- },
2834
- "required": false,
2835
- "description": "search in window.location - e.g., \"?myargument=1\""
2836
- },
2837
- "hash": {
2838
- "type": {
2839
- "name": "string"
2840
- },
2841
- "required": false,
2842
- "description": "hash in window.location - e.g., \"#myhash\""
2843
- },
2844
- "href": {
2845
- "type": {
2846
- "name": "string"
2847
- },
2848
- "required": false,
2849
- "description": "href in window.location - e.g., \"/my/full/pathname?myargument=1#myhash\""
2850
- },
2851
- "refresh": {
2852
- "type": {
2853
- "name": "bool"
2854
- },
2855
- "required": false,
2856
- "description": "Refresh the page when the location is updated?",
2857
- "defaultValue": {
2858
- "value": "true",
2859
- "computed": false
2860
- }
2861
- },
2862
- "includePathnames": {
2863
- "type": {
2864
- "name": "arrayOf",
2865
- "value": {
2866
- "name": "string"
2867
- }
2868
- },
2869
- "required": false,
2870
- "description": ""
2871
- },
2872
- "setProps": {
2873
- "type": {
2874
- "name": "func"
2875
- },
2876
- "required": false,
2877
- "description": "Dash-assigned callback that gets fired when the value changes."
2878
- }
2879
- }
2880
- },
2881
2802
  "src/lib/components/FefferyQRCode.react.js": {
2882
2803
  "description": "",
2883
2804
  "displayName": "FefferyQRCode",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feffery_utils_components",
3
- "version": "0.0.32",
3
+ "version": "0.1.0",
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.32",
3
+ "version": "0.1.0",
4
4
  "description": "Build more utility components for Plotly Dash.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -3,10 +3,11 @@ module FefferyUtilsComponents
3
3
  using Dash
4
4
 
5
5
  const resources_path = realpath(joinpath( @__DIR__, "..", "deps"))
6
- const version = "0.0.32"
6
+ const version = "0.1.0"
7
7
 
8
8
  include("jl/''_fefferyblockcolorpicker.jl")
9
9
  include("jl/''_fefferycirclecolorpicker.jl")
10
+ include("jl/''_fefferyeyedropper.jl")
10
11
  include("jl/''_fefferygithubcolorpicker.jl")
11
12
  include("jl/''_fefferyhexcolorpicker.jl")
12
13
  include("jl/''_fefferyrgbcolorpicker.jl")
@@ -20,14 +21,12 @@ include("jl/''_fefferyexecutejs.jl")
20
21
  include("jl/''_fefferyexternalcss.jl")
21
22
  include("jl/''_fefferyexternaljs.jl")
22
23
  include("jl/''_fefferyextraspinner.jl")
23
- include("jl/''_fefferyeyedropper.jl")
24
24
  include("jl/''_fefferyfancymessage.jl")
25
25
  include("jl/''_fefferyfancynotification.jl")
26
26
  include("jl/''_fefferyguide.jl")
27
27
  include("jl/''_fefferyhighlightwords.jl")
28
28
  include("jl/''_fefferylazyload.jl")
29
29
  include("jl/''_fefferylazyloadimage.jl")
30
- include("jl/''_fefferylocation.jl")
31
30
  include("jl/''_fefferyqrcode.jl")
32
31
  include("jl/''_fefferyrawhtml.jl")
33
32
  include("jl/''_fefferyreload.jl")
@@ -62,14 +61,14 @@ function __init__()
62
61
  [
63
62
  DashBase.Resource(
64
63
  relative_package_path = "feffery_utils_components.min.js",
65
- external_url = "https://unpkg.com/feffery_utils_components@0.0.32/feffery_utils_components/feffery_utils_components.min.js",
64
+ external_url = "https://unpkg.com/feffery_utils_components@0.1.0/feffery_utils_components/feffery_utils_components.min.js",
66
65
  dynamic = nothing,
67
66
  async = nothing,
68
67
  type = :js
69
68
  ),
70
69
  DashBase.Resource(
71
70
  relative_package_path = "feffery_utils_components.min.js.map",
72
- external_url = "https://unpkg.com/feffery_utils_components@0.0.32/feffery_utils_components/feffery_utils_components.min.js.map",
71
+ external_url = "https://unpkg.com/feffery_utils_components@0.1.0/feffery_utils_components/feffery_utils_components.min.js.map",
73
72
  dynamic = true,
74
73
  async = nothing,
75
74
  type = :js
@@ -25,6 +25,7 @@ Those elements have the following types:
25
25
  - `timestamp` (Real; optional)
26
26
  - `debounceWait` (Real; optional)
27
27
  - `deleteChildIndex` (Real; optional)
28
+ - `enableClickAway` (Bool; optional)
28
29
  - `enableListenContextMenu` (Bool; optional)
29
30
  - `insertChild` (optional): . insertChild has the following type: lists containing elements 'index', 'element'.
30
31
  Those elements have the following types:
@@ -49,7 +50,7 @@ Those elements have the following types:
49
50
  - `style` (Dict; optional)
50
51
  """
51
52
  function ''_fefferydiv(; kwargs...)
52
- available_props = Symbol[:children, :id, :_height, :_width, :appendChild, :className, :clickAwayCount, :contextMenuEvent, :debounceWait, :deleteChildIndex, :enableListenContextMenu, :insertChild, :isHovering, :key, :loading_state, :mouseEnterCount, :mouseLeaveCount, :nClicks, :nDoubleClicks, :replaceChild, :shadow, :style]
53
+ available_props = Symbol[:children, :id, :_height, :_width, :appendChild, :className, :clickAwayCount, :contextMenuEvent, :debounceWait, :deleteChildIndex, :enableClickAway, :enableListenContextMenu, :insertChild, :isHovering, :key, :loading_state, :mouseEnterCount, :mouseLeaveCount, :nClicks, :nDoubleClicks, :replaceChild, :shadow, :style]
53
54
  wild_props = Symbol[]
54
55
  return Component("''_fefferydiv", "FefferyDiv", "feffery_utils_components", available_props, wild_props; kwargs...)
55
56
  end
@@ -26,6 +26,7 @@ const FefferyDiv = (props) => {
26
26
  replaceChild,
27
27
  deleteChildIndex,
28
28
  shadow,
29
+ enableClickAway,
29
30
  setProps,
30
31
  loading_state
31
32
  } = props;
@@ -104,9 +105,11 @@ const FefferyDiv = (props) => {
104
105
  }, [_isHovering])
105
106
 
106
107
  // 监听元素外点击事件
107
- useClickAway(() => {
108
- setProps({ clickAwayCount: clickAwayCount + 1 })
109
- }, ref);
108
+ if (enableClickAway) {
109
+ useClickAway(() => {
110
+ setProps({ clickAwayCount: clickAwayCount + 1 })
111
+ }, ref);
112
+ }
110
113
 
111
114
  // 根据shadow参数预处理className
112
115
  if (shadow === 'hover-shadow') {
@@ -232,6 +235,10 @@ FefferyDiv.propTypes = {
232
235
  // 默认为'no-shadow'
233
236
  shadow: PropTypes.oneOf(['no-shadow', 'hover-shadow', 'always-shadow']),
234
237
 
238
+ // 设置是否启用元素外点击事件监听,当页面中有大量FefferyDiv元素时,建议不要开启此特性,会导致明显的性能问题
239
+ // 默认为false
240
+ enableClickAway: PropTypes.bool,
241
+
235
242
  /**
236
243
  * Dash-assigned callback that should be called to report property changes
237
244
  * to Dash, to make them available for callbacks.
@@ -263,7 +270,8 @@ FefferyDiv.defaultProps = {
263
270
  enableListenContextMenu: false,
264
271
  debounceWait: 150,
265
272
  clickAwayCount: 0,
266
- shadow: 'no-shadow'
273
+ shadow: 'no-shadow',
274
+ enableClickAway: false
267
275
  }
268
276
 
269
277
  export default React.memo(FefferyDiv);
@@ -120,7 +120,7 @@ FefferyTopProgress.propTypes = {
120
120
  // 设置是否处于加载中状态
121
121
  spinning: PropTypes.bool,
122
122
 
123
- // 设置顶端进度条的初始进度值,默认为0.08,取值在0到1之间
123
+ // 设置顶端进度条的初始进度值,默认为0.33,取值在0到1之间
124
124
  minimum: PropTypes.number,
125
125
 
126
126
  // 用于设置同名css动画效果,默认为'ease'
package/src/lib/index.js CHANGED
@@ -12,7 +12,6 @@ import FefferyScrollbars from "./components/FefferyScrollbars.react";
12
12
  import FefferyExtraSpinner from "./components/FefferyExtraSpinner.react";
13
13
  import FefferyLazyLoad from "./components/FefferyLazyLoad.react";
14
14
  import FefferyVirtualList from "./components/FefferyVirtualList.react";
15
- import FefferyLocation from "./components/FefferyLocation.react";
16
15
  import FefferyInViewport from "./components/listeners/FefferyInViewport.react";
17
16
  import FefferyHexColorPicker from "./components/colorPickers/FefferyHexColorPicker.react";
18
17
  import FefferyRgbColorPicker from "./components/colorPickers/FefferyRgbColorPicker.react";
@@ -43,7 +42,7 @@ import FefferyStyle from "./components/FefferyStyle.react";
43
42
  import FefferyDiv from "./components/FefferyDiv.react";
44
43
  import FefferyReload from "./components/FefferyReload.react";
45
44
  import FefferyCssVar from "./components/FefferyCssVar.react";
46
- import FefferyEyeDropper from "./components/FefferyEyeDropper.react";
45
+ import FefferyEyeDropper from "./components/colorPickers/FefferyEyeDropper.react";
47
46
  import FefferySticky from "./components/FefferySticky.react";
48
47
  import FefferyLazyLoadImage from "./components/FefferyLazyLoadImage.react";
49
48
 
@@ -83,7 +82,6 @@ export {
83
82
  FefferyExtraSpinner,
84
83
  FefferyLazyLoad,
85
84
  FefferyVirtualList,
86
- FefferyLocation,
87
85
  FefferyInViewport,
88
86
  FefferyHexColorPicker,
89
87
  FefferyRgbColorPicker,
package/usage.py CHANGED
@@ -0,0 +1,39 @@
1
+ import dash
2
+ from dash import html
3
+ import feffery_antd_components as fac
4
+ import feffery_utils_components as fuc
5
+
6
+ app = dash.Dash(__name__)
7
+
8
+ app.layout = html.Div(
9
+ [
10
+ *[
11
+ fuc.FefferyDiv(
12
+ enableClickAway=True,
13
+ className={
14
+ '&:hover': {
15
+ 'transform': 'translateX(20px)',
16
+ 'cursor': 'pointer'
17
+ }
18
+ },
19
+ style={
20
+ 'height': '100px',
21
+ 'width': '100px',
22
+ 'background': 'lightgrey',
23
+ 'marginBottom': '20px'
24
+ }
25
+ )
26
+ for i in range(200)
27
+ ],
28
+ fac.AntdBackTop(
29
+ duration=1
30
+ )
31
+ ],
32
+ style={
33
+ 'padding': '100px',
34
+ 'height': '10000px'
35
+ }
36
+ )
37
+
38
+ if __name__ == '__main__':
39
+ app.run(debug=True)
@@ -1,161 +0,0 @@
1
- import { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { type } from 'ramda';
4
-
5
- import { History } from '@plotly/dash-component-plugins';
6
-
7
- export default class FefferyLocation extends Component {
8
- constructor(props) {
9
- super(props);
10
- this.updateLocation = this.updateLocation.bind(this);
11
- this.onLocationChange = this.onLocationChange.bind(this);
12
- }
13
-
14
- updateLocation(props) {
15
- const { hash, href, pathname, refresh, search, setProps } = props;
16
-
17
- // Keep track of props relating to window.location that may need to be updated via setProps
18
- const propsToSet = {};
19
-
20
- /**
21
- * Check if the field exists in props. If the prop with "fieldName" is not defined,
22
- * then it was not set by the user and needs to be equal to the value in window.location.
23
- * This only happens on page load (since props will no longer be undefined after componentDidMount).
24
- *
25
- * @param {string} fieldName
26
- * The name of the prop in window.location and in the component's prop
27
- *
28
- * @returns {boolean}
29
- * Returns true if the prop with fieldName is different and the window state needs to be updated
30
- */
31
- const checkExistsUpdateWindowLocation = fieldName => {
32
- const propVal = props[fieldName];
33
-
34
- if (
35
- (type(propVal) === 'Undefined' || propVal === null) &&
36
- type(window.location[fieldName]) !== 'Undefined'
37
- ) {
38
- // propVal is undefined or null, but window.location has this fieldName defined
39
- propsToSet[fieldName] = window.location[fieldName];
40
- } else if (propVal !== window.location[fieldName]) {
41
- // Prop has changed?
42
- if (refresh) {
43
- // Refresh the page?
44
- window.location[fieldName] = propVal;
45
- } else if (this.props[fieldName] !== propVal) {
46
- // If this prop has changed, need to setProps
47
- propsToSet[fieldName] = propVal;
48
- // This (`${fieldName}`: propVal) needs to be pushed in the window.history
49
- return true;
50
- }
51
- }
52
- // This (`${fieldName}`: propVal) DOES NOT need to be pushed in the window.history
53
- return false;
54
- };
55
-
56
- // Check if the prop value needs to be updated (note that this mutates propsToSet)
57
- const pathnameUpdated = checkExistsUpdateWindowLocation('pathname');
58
- const hrefUpdated = checkExistsUpdateWindowLocation('href');
59
- const hashUpdated = checkExistsUpdateWindowLocation('hash');
60
- const searchUpdated = checkExistsUpdateWindowLocation('search');
61
-
62
- // propsToSet has been updated -- batch update to Dash
63
- if (Object.keys(propsToSet).length > 0) {
64
- setProps(propsToSet);
65
- }
66
-
67
- // Special case -- overrides everything!
68
- if (hrefUpdated) {
69
- window.history.pushState({}, '', href);
70
- } else if (pathnameUpdated || hashUpdated || searchUpdated) {
71
- // Otherwise, we can mash everything together
72
- const searchVal = type(search) !== 'Undefined' ? search : '';
73
- const hashVal = type(hash) !== 'Undefined' ? hash : '';
74
- window.history.pushState(
75
- {},
76
- '',
77
- `${pathname}${searchVal}${hashVal}`
78
- );
79
- }
80
- }
81
-
82
- onLocationChange() {
83
- const { setProps, includePathnames } = this.props;
84
- const propsToChange = {};
85
-
86
- if (this.props.pathname !== window.location.pathname) {
87
- if (includePathnames) {
88
- // 仅当当前pathname在includePathnames中时更新pathname值
89
- if (includePathnames.indexOf(window.location.pathname) !== -1) {
90
- propsToChange.pathname = window.location.pathname;
91
- }
92
- } else {
93
- propsToChange.pathname = window.location.pathname;
94
- }
95
- }
96
- if (this.props.href !== window.location.href) {
97
- propsToChange.href = window.location.href;
98
- }
99
- if (this.props.hash !== window.location.hash) {
100
- propsToChange.hash = window.location.hash;
101
- }
102
- if (this.props.search !== window.location.search) {
103
- propsToChange.search = window.location.search;
104
- }
105
-
106
- setProps(propsToChange);
107
-
108
- History.dispatchChangeEvent();
109
- }
110
-
111
- componentDidMount() {
112
- window.onpopstate = this.onLocationChange;
113
-
114
- window.addEventListener(
115
- '_dashprivate_pushstate',
116
- this.onLocationChange
117
- );
118
- this.updateLocation(this.props);
119
- }
120
-
121
- UNSAFE_componentWillReceiveProps(nextProps) {
122
- this.updateLocation(nextProps);
123
- }
124
-
125
- render() {
126
- return null;
127
- }
128
- }
129
-
130
- FefferyLocation.propTypes = {
131
- /**
132
- * The ID of this component, used to identify dash components
133
- * in callbacks. The ID needs to be unique across all of the
134
- * components in an app.
135
- */
136
- id: PropTypes.string.isRequired,
137
-
138
- /** pathname in window.location - e.g., "/my/full/pathname" */
139
- pathname: PropTypes.string,
140
- /** search in window.location - e.g., "?myargument=1" */
141
- search: PropTypes.string,
142
- /** hash in window.location - e.g., "#myhash" */
143
- hash: PropTypes.string,
144
- /** href in window.location - e.g., "/my/full/pathname?myargument=1#myhash" */
145
- href: PropTypes.string,
146
-
147
- /** Refresh the page when the location is updated? */
148
- refresh: PropTypes.bool,
149
-
150
- // 设置仅监听的pathname枚举数组
151
- includePathnames: PropTypes.arrayOf(PropTypes.string),
152
-
153
- /**
154
- * Dash-assigned callback that gets fired when the value changes.
155
- */
156
- setProps: PropTypes.func,
157
- };
158
-
159
- FefferyLocation.defaultProps = {
160
- refresh: true,
161
- };