feffery_utils_components 0.1.13 → 0.1.14
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/Project.toml +1 -1
- package/build/lib/feffery_utils_components/FefferyShortcutPanel.py +21 -10
- package/build/lib/feffery_utils_components/feffery_utils_components.min.js +4 -4
- package/build/lib/feffery_utils_components/metadata.json +38 -21
- package/build/lib/feffery_utils_components/package-info.json +1 -1
- package/feffery_utils_components/FefferyShortcutPanel.py +21 -10
- package/feffery_utils_components/feffery_utils_components.min.js +4 -4
- package/feffery_utils_components/metadata.json +38 -21
- package/feffery_utils_components/package-info.json +1 -1
- package/package.json +1 -1
- package/src/FefferyUtilsComponents.jl +3 -3
- package/src/jl/''_fefferyshortcutpanel.jl +8 -5
- package/src/lib/components/FefferyShortcutPanel.react.js +106 -69
- package/src/lib/components/colorPickers/FefferyBlockColorPicker.react.js +1 -1
- package/src/lib/components/colorPickers/FefferyCircleColorPicker.react.js +1 -1
- package/src/lib/components/colorPickers/FefferyGithubColorPicker.react.js +1 -1
- package/src/lib/components/colorPickers/FefferyTwitterColorPicker.react.js +1 -1
- package/src/lib/components/styles.css +5 -0
- package/tests/ShortcutPanelTest/app.py +32 -0
|
@@ -4687,13 +4687,6 @@
|
|
|
4687
4687
|
"required": false,
|
|
4688
4688
|
"description": ""
|
|
4689
4689
|
},
|
|
4690
|
-
"style": {
|
|
4691
|
-
"type": {
|
|
4692
|
-
"name": "object"
|
|
4693
|
-
},
|
|
4694
|
-
"required": false,
|
|
4695
|
-
"description": ""
|
|
4696
|
-
},
|
|
4697
4690
|
"locale": {
|
|
4698
4691
|
"type": {
|
|
4699
4692
|
"name": "enum",
|
|
@@ -4767,17 +4760,22 @@
|
|
|
4767
4760
|
}
|
|
4768
4761
|
}
|
|
4769
4762
|
},
|
|
4770
|
-
"required":
|
|
4763
|
+
"required": true,
|
|
4771
4764
|
"description": ""
|
|
4772
4765
|
},
|
|
4773
4766
|
"triggeredHotkey": {
|
|
4774
4767
|
"type": {
|
|
4775
|
-
"name": "
|
|
4776
|
-
"value":
|
|
4777
|
-
{
|
|
4778
|
-
"name": "string"
|
|
4768
|
+
"name": "exact",
|
|
4769
|
+
"value": {
|
|
4770
|
+
"id": {
|
|
4771
|
+
"name": "string",
|
|
4772
|
+
"required": false
|
|
4773
|
+
},
|
|
4774
|
+
"timestamp": {
|
|
4775
|
+
"name": "number",
|
|
4776
|
+
"required": false
|
|
4779
4777
|
}
|
|
4780
|
-
|
|
4778
|
+
}
|
|
4781
4779
|
},
|
|
4782
4780
|
"required": false,
|
|
4783
4781
|
"description": ""
|
|
@@ -4789,19 +4787,16 @@
|
|
|
4789
4787
|
"required": false,
|
|
4790
4788
|
"description": ""
|
|
4791
4789
|
},
|
|
4792
|
-
"disableHotkeys": {
|
|
4793
|
-
"type": {
|
|
4794
|
-
"name": "bool"
|
|
4795
|
-
},
|
|
4796
|
-
"required": false,
|
|
4797
|
-
"description": ""
|
|
4798
|
-
},
|
|
4799
4790
|
"openHotkey": {
|
|
4800
4791
|
"type": {
|
|
4801
4792
|
"name": "string"
|
|
4802
4793
|
},
|
|
4803
4794
|
"required": false,
|
|
4804
|
-
"description": ""
|
|
4795
|
+
"description": "",
|
|
4796
|
+
"defaultValue": {
|
|
4797
|
+
"value": "'cmd+k,ctrl+k'",
|
|
4798
|
+
"computed": false
|
|
4799
|
+
}
|
|
4805
4800
|
},
|
|
4806
4801
|
"theme": {
|
|
4807
4802
|
"type": {
|
|
@@ -4824,6 +4819,28 @@
|
|
|
4824
4819
|
"computed": false
|
|
4825
4820
|
}
|
|
4826
4821
|
},
|
|
4822
|
+
"open": {
|
|
4823
|
+
"type": {
|
|
4824
|
+
"name": "bool"
|
|
4825
|
+
},
|
|
4826
|
+
"required": false,
|
|
4827
|
+
"description": "",
|
|
4828
|
+
"defaultValue": {
|
|
4829
|
+
"value": "false",
|
|
4830
|
+
"computed": false
|
|
4831
|
+
}
|
|
4832
|
+
},
|
|
4833
|
+
"close": {
|
|
4834
|
+
"type": {
|
|
4835
|
+
"name": "bool"
|
|
4836
|
+
},
|
|
4837
|
+
"required": false,
|
|
4838
|
+
"description": "",
|
|
4839
|
+
"defaultValue": {
|
|
4840
|
+
"value": "false",
|
|
4841
|
+
"computed": false
|
|
4842
|
+
}
|
|
4843
|
+
},
|
|
4827
4844
|
"loading_state": {
|
|
4828
4845
|
"type": {
|
|
4829
4846
|
"name": "shape",
|
package/package.json
CHANGED
|
@@ -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
|
+
const version = "0.1.14"
|
|
7
7
|
|
|
8
8
|
include("jl/''_fefferyblockcolorpicker.jl")
|
|
9
9
|
include("jl/''_fefferycirclecolorpicker.jl")
|
|
@@ -68,14 +68,14 @@ function __init__()
|
|
|
68
68
|
[
|
|
69
69
|
DashBase.Resource(
|
|
70
70
|
relative_package_path = "feffery_utils_components.min.js",
|
|
71
|
-
external_url = "https://unpkg.com/feffery_utils_components@0.1.
|
|
71
|
+
external_url = "https://unpkg.com/feffery_utils_components@0.1.14/feffery_utils_components/feffery_utils_components.min.js",
|
|
72
72
|
dynamic = nothing,
|
|
73
73
|
async = nothing,
|
|
74
74
|
type = :js
|
|
75
75
|
),
|
|
76
76
|
DashBase.Resource(
|
|
77
77
|
relative_package_path = "feffery_utils_components.min.js.map",
|
|
78
|
-
external_url = "https://unpkg.com/feffery_utils_components@0.1.
|
|
78
|
+
external_url = "https://unpkg.com/feffery_utils_components@0.1.14/feffery_utils_components/feffery_utils_components.min.js.map",
|
|
79
79
|
dynamic = true,
|
|
80
80
|
async = nothing,
|
|
81
81
|
type = :js
|
|
@@ -9,7 +9,8 @@ A FefferyShortcutPanel component.
|
|
|
9
9
|
|
|
10
10
|
Keyword arguments:
|
|
11
11
|
- `id` (String; optional)
|
|
12
|
-
- `
|
|
12
|
+
- `close` (Bool; optional)
|
|
13
|
+
- `data` (required): . data has the following type: Array of lists containing elements 'id', 'title', 'hotkey', 'handler', 'parent', 'keywords', 'children', 'section'.
|
|
13
14
|
Those elements have the following types:
|
|
14
15
|
- `id` (String; required)
|
|
15
16
|
- `title` (String; required)
|
|
@@ -19,21 +20,23 @@ Those elements have the following types:
|
|
|
19
20
|
- `keywords` (String; optional)
|
|
20
21
|
- `children` (Array of Strings; optional)
|
|
21
22
|
- `section` (String; optional)s
|
|
22
|
-
- `disableHotkeys` (Bool; optional)
|
|
23
23
|
- `loading_state` (optional): . loading_state has the following type: lists containing elements 'is_loading', 'prop_name', 'component_name'.
|
|
24
24
|
Those elements have the following types:
|
|
25
25
|
- `is_loading` (Bool; optional): Determines if the component is loading or not
|
|
26
26
|
- `prop_name` (String; optional): Holds which property is loading
|
|
27
27
|
- `component_name` (String; optional): Holds the name of the component that is loading
|
|
28
28
|
- `locale` (a value equal to: 'en', 'zh'; optional)
|
|
29
|
+
- `open` (Bool; optional)
|
|
29
30
|
- `openHotkey` (String; optional)
|
|
30
31
|
- `placeholder` (String; optional)
|
|
31
|
-
- `style` (Dict; optional)
|
|
32
32
|
- `theme` (a value equal to: 'light', 'dark'; optional)
|
|
33
|
-
- `triggeredHotkey` (
|
|
33
|
+
- `triggeredHotkey` (optional): . triggeredHotkey has the following type: lists containing elements 'id', 'timestamp'.
|
|
34
|
+
Those elements have the following types:
|
|
35
|
+
- `id` (String; optional)
|
|
36
|
+
- `timestamp` (Real; optional)
|
|
34
37
|
"""
|
|
35
38
|
function ''_fefferyshortcutpanel(; kwargs...)
|
|
36
|
-
available_props = Symbol[:id, :
|
|
39
|
+
available_props = Symbol[:id, :close, :data, :loading_state, :locale, :open, :openHotkey, :placeholder, :theme, :triggeredHotkey]
|
|
37
40
|
wild_props = Symbol[]
|
|
38
41
|
return Component("''_fefferyshortcutpanel", "FefferyShortcutPanel", "feffery_utils_components", available_props, wild_props; kwargs...)
|
|
39
42
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState, useRef, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import { isString } from 'lodash';
|
|
3
4
|
import "ninja-keys";
|
|
4
|
-
import './styles.css'
|
|
5
5
|
|
|
6
6
|
const footerHtmlEn = <div class="modal-footer" slot="footer">
|
|
7
7
|
<span class="help">
|
|
@@ -76,76 +76,45 @@ const footerHtmlZh = <div className="modal-footer" slot="footer">
|
|
|
76
76
|
</span>
|
|
77
77
|
</div>
|
|
78
78
|
|
|
79
|
+
const locale2footer = new Map([
|
|
80
|
+
['en', footerHtmlEn],
|
|
81
|
+
['zh', footerHtmlZh]
|
|
82
|
+
])
|
|
83
|
+
|
|
84
|
+
const locale2placeholder = new Map([
|
|
85
|
+
['en', 'Type a command or search...'],
|
|
86
|
+
['zh', '输入指令或进行搜索...']
|
|
87
|
+
])
|
|
79
88
|
|
|
80
89
|
// 定义快捷方式面板部件FefferyShortcutPanel,api参数参考https://github.com/ssleptsov/ninja-keys
|
|
81
90
|
const FefferyShortcutPanel = (props) => {
|
|
82
91
|
// 取得必要属性或参数
|
|
83
92
|
let {
|
|
84
93
|
id,
|
|
85
|
-
style,
|
|
86
94
|
data,
|
|
87
95
|
placeholder,
|
|
88
|
-
disableHotkeys,
|
|
89
96
|
openHotkey,
|
|
90
97
|
theme,
|
|
91
98
|
locale,
|
|
99
|
+
open,
|
|
100
|
+
close,
|
|
92
101
|
setProps,
|
|
93
102
|
loading_state
|
|
94
103
|
} = props;
|
|
95
104
|
|
|
96
|
-
data = data || [
|
|
97
|
-
{
|
|
98
|
-
id: "Home",
|
|
99
|
-
title: "Open Home",
|
|
100
|
-
hotkey: "cmd+h",
|
|
101
|
-
handler: () => {
|
|
102
|
-
console.log("navigation to home");
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
id: "Open Projects",
|
|
107
|
-
title: "Open Projects",
|
|
108
|
-
hotkey: "cmd+p",
|
|
109
|
-
handler: () => {
|
|
110
|
-
console.log("navigation to projects");
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
id: "Theme",
|
|
115
|
-
title: "Change theme...",
|
|
116
|
-
children: [
|
|
117
|
-
'Light Theme', 'Dark Theme'
|
|
118
|
-
]
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
id: "Light Theme",
|
|
122
|
-
title: "Change theme to Light",
|
|
123
|
-
parent: 'Theme',
|
|
124
|
-
handler: () => {
|
|
125
|
-
console.log("theme light");
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
id: "Dark Theme",
|
|
130
|
-
title: "Change theme to Dark",
|
|
131
|
-
parent: 'Theme',
|
|
132
|
-
keywords: "lol",
|
|
133
|
-
handler: () => {
|
|
134
|
-
console.log("theme dark");
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
]
|
|
138
|
-
|
|
139
105
|
// 填充handler缺省时的默认逻辑
|
|
140
106
|
data = data.map(
|
|
141
107
|
item => {
|
|
142
|
-
return
|
|
108
|
+
return isString(item.handler) || item.hasOwnProperty('children') ?
|
|
143
109
|
item : {
|
|
144
110
|
...item,
|
|
145
111
|
...{
|
|
146
112
|
handler: () => {
|
|
147
113
|
setProps({
|
|
148
|
-
triggeredHotkey:
|
|
114
|
+
triggeredHotkey: {
|
|
115
|
+
id: item.id,
|
|
116
|
+
timestamp: Date.parse(new Date())
|
|
117
|
+
}
|
|
149
118
|
})
|
|
150
119
|
}
|
|
151
120
|
}
|
|
@@ -156,7 +125,7 @@ const FefferyShortcutPanel = (props) => {
|
|
|
156
125
|
const ninjaKeys = useRef(null);
|
|
157
126
|
const [hotkeys, setHotkeys] = useState(
|
|
158
127
|
data.map(
|
|
159
|
-
item =>
|
|
128
|
+
item => isString(item.handler) ?
|
|
160
129
|
{
|
|
161
130
|
...item,
|
|
162
131
|
...{
|
|
@@ -172,21 +141,40 @@ const FefferyShortcutPanel = (props) => {
|
|
|
172
141
|
}
|
|
173
142
|
}, []);
|
|
174
143
|
|
|
144
|
+
// 自主控制指令面板打开/关闭
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (ninjaKeys.current && open) {
|
|
147
|
+
ninjaKeys.current.open()
|
|
148
|
+
// 重置
|
|
149
|
+
setProps({
|
|
150
|
+
open: false
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
}, [open])
|
|
154
|
+
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
if (ninjaKeys.current && close) {
|
|
157
|
+
ninjaKeys.current.close()
|
|
158
|
+
// 重置
|
|
159
|
+
setProps({
|
|
160
|
+
close: false
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
}, [close])
|
|
164
|
+
|
|
175
165
|
// 返回向页面注入的快捷键监听
|
|
176
166
|
return (
|
|
177
167
|
<ninja-keys id={id}
|
|
178
|
-
class={theme
|
|
179
|
-
style={style}
|
|
168
|
+
class={theme}
|
|
180
169
|
ref={ninjaKeys}
|
|
181
|
-
placeholder={placeholder}
|
|
182
|
-
disableHotkeys={disableHotkeys}
|
|
170
|
+
placeholder={placeholder || locale2placeholder.get(locale)}
|
|
183
171
|
openHotkey={openHotkey}
|
|
184
172
|
hotKeysJoinedView={true}
|
|
185
173
|
hideBreadcrumbs={true}
|
|
186
174
|
data-dash-is-loading={
|
|
187
175
|
(loading_state && loading_state.is_loading) || undefined
|
|
188
176
|
} >
|
|
189
|
-
{locale
|
|
177
|
+
{locale2footer.get(locale)}
|
|
190
178
|
</ ninja-keys>
|
|
191
179
|
);
|
|
192
180
|
}
|
|
@@ -196,13 +184,53 @@ FefferyShortcutPanel.propTypes = {
|
|
|
196
184
|
// 部件id
|
|
197
185
|
id: PropTypes.string,
|
|
198
186
|
|
|
199
|
-
//
|
|
200
|
-
style: PropTypes.object,
|
|
201
|
-
|
|
202
|
-
// 设置语言,可选的有'en'、'zh'
|
|
187
|
+
// 设置语言,可选的有'en'、'zh',默认为'zh'
|
|
203
188
|
locale: PropTypes.oneOf(['en', 'zh']),
|
|
204
189
|
|
|
205
190
|
// 用于定义热键节点的数据结构
|
|
191
|
+
// 例:
|
|
192
|
+
// [
|
|
193
|
+
// {
|
|
194
|
+
// id: "Home",
|
|
195
|
+
// title: "Open Home",
|
|
196
|
+
// hotkey: "cmd+h",
|
|
197
|
+
// handler: () => {
|
|
198
|
+
// console.log("navigation to home");
|
|
199
|
+
// }
|
|
200
|
+
// },
|
|
201
|
+
// {
|
|
202
|
+
// id: "Open Projects",
|
|
203
|
+
// title: "Open Projects",
|
|
204
|
+
// hotkey: "cmd+p",
|
|
205
|
+
// handler: () => {
|
|
206
|
+
// console.log("navigation to projects");
|
|
207
|
+
// }
|
|
208
|
+
// },
|
|
209
|
+
// {
|
|
210
|
+
// id: "Theme",
|
|
211
|
+
// title: "Change theme...",
|
|
212
|
+
// children: [
|
|
213
|
+
// 'Light Theme', 'Dark Theme'
|
|
214
|
+
// ]
|
|
215
|
+
// },
|
|
216
|
+
// {
|
|
217
|
+
// id: "Light Theme",
|
|
218
|
+
// title: "Change theme to Light",
|
|
219
|
+
// parent: 'Theme',
|
|
220
|
+
// handler: () => {
|
|
221
|
+
// console.log("theme light");
|
|
222
|
+
// }
|
|
223
|
+
// },
|
|
224
|
+
// {
|
|
225
|
+
// id: "Dark Theme",
|
|
226
|
+
// title: "Change theme to Dark",
|
|
227
|
+
// parent: 'Theme',
|
|
228
|
+
// keywords: "lol",
|
|
229
|
+
// handler: () => {
|
|
230
|
+
// console.log("theme dark");
|
|
231
|
+
// }
|
|
232
|
+
// }
|
|
233
|
+
// ]
|
|
206
234
|
data: PropTypes.arrayOf(
|
|
207
235
|
PropTypes.exact({
|
|
208
236
|
// 用于定义当前热键的唯一id,会在顶端热键面包屑中进行显示
|
|
@@ -232,25 +260,31 @@ FefferyShortcutPanel.propTypes = {
|
|
|
232
260
|
// 用于设置分组标题文字
|
|
233
261
|
section: PropTypes.string
|
|
234
262
|
})
|
|
235
|
-
),
|
|
263
|
+
).isRequired,
|
|
236
264
|
|
|
237
|
-
// 监听记录最近一次被触发的热键id
|
|
238
|
-
triggeredHotkey: PropTypes.
|
|
239
|
-
|
|
240
|
-
|
|
265
|
+
// 监听记录最近一次被触发的热键id以及对应触发时间的时间戳信息
|
|
266
|
+
triggeredHotkey: PropTypes.exact({
|
|
267
|
+
// 触发指令菜单项id
|
|
268
|
+
id: PropTypes.string,
|
|
269
|
+
// 触发时间戳信息
|
|
270
|
+
timestamp: PropTypes.number
|
|
271
|
+
}),
|
|
241
272
|
|
|
242
|
-
//
|
|
273
|
+
// 定义输入框提示内容,默认会根据locale赋以不同的缺省值
|
|
243
274
|
placeholder: PropTypes.string,
|
|
244
275
|
|
|
245
|
-
// 设置是否禁用热键,默认为false
|
|
246
|
-
disableHotkeys: PropTypes.bool,
|
|
247
|
-
|
|
248
276
|
// 设置唤出指令面板的快捷键组合,默认为'cmd+k,ctrl+k'
|
|
249
277
|
openHotkey: PropTypes.string,
|
|
250
278
|
|
|
251
|
-
// 设置主题,可选的有'light'、'dark'
|
|
279
|
+
// 设置主题,可选的有'light'、'dark',默认为'light'
|
|
252
280
|
theme: PropTypes.oneOf(['light', 'dark']),
|
|
253
281
|
|
|
282
|
+
// 传入true时手动展开指令面板,默认为false
|
|
283
|
+
open: PropTypes.bool,
|
|
284
|
+
|
|
285
|
+
// 传入true时手动关闭指令面板,默认为false
|
|
286
|
+
close: PropTypes.bool,
|
|
287
|
+
|
|
254
288
|
loading_state: PropTypes.shape({
|
|
255
289
|
/**
|
|
256
290
|
* Determines if the component is loading or not
|
|
@@ -276,7 +310,10 @@ FefferyShortcutPanel.propTypes = {
|
|
|
276
310
|
// 设置默认参数
|
|
277
311
|
FefferyShortcutPanel.defaultProps = {
|
|
278
312
|
locale: 'zh',
|
|
279
|
-
theme: 'light'
|
|
313
|
+
theme: 'light',
|
|
314
|
+
openHotkey: 'cmd+k,ctrl+k',
|
|
315
|
+
open: false,
|
|
316
|
+
close: false
|
|
280
317
|
}
|
|
281
318
|
|
|
282
319
|
export default FefferyShortcutPanel;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
if True:
|
|
2
|
+
import sys
|
|
3
|
+
sys.path.append('../..')
|
|
4
|
+
import dash
|
|
5
|
+
from dash import html, dcc
|
|
6
|
+
import feffery_utils_components as fuc
|
|
7
|
+
from dash.dependencies import Input, Output, State
|
|
8
|
+
|
|
9
|
+
app = dash.Dash(__name__)
|
|
10
|
+
|
|
11
|
+
app.layout = html.Div(
|
|
12
|
+
[
|
|
13
|
+
fuc.FefferyShortcutPanel(
|
|
14
|
+
data=[
|
|
15
|
+
{
|
|
16
|
+
'id': f'指令{i}',
|
|
17
|
+
'title': f'指令{i}',
|
|
18
|
+
'handler': f'() => alert("指令{i}")'
|
|
19
|
+
}
|
|
20
|
+
for i in range(20)
|
|
21
|
+
],
|
|
22
|
+
open=True
|
|
23
|
+
)
|
|
24
|
+
],
|
|
25
|
+
style={
|
|
26
|
+
'height': '2000px'
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if __name__ == '__main__':
|
|
32
|
+
app.run(debug=True)
|