feffery_utils_components 0.0.6 → 0.0.9

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 (44) hide show
  1. package/DESCRIPTION +1 -1
  2. package/NAMESPACE +8 -0
  3. package/Project.toml +2 -2
  4. package/build/lib/feffery_utils_components/FefferyDashboard.py +39 -0
  5. package/build/lib/feffery_utils_components/FefferyGuide.py +69 -0
  6. package/build/lib/feffery_utils_components/FefferyResizable.py +39 -0
  7. package/build/lib/feffery_utils_components/FefferyShortcutPanel.py +51 -0
  8. package/build/lib/feffery_utils_components/FefferySplit.py +59 -0
  9. package/build/lib/feffery_utils_components/FefferySplitPane.py +48 -0
  10. package/build/lib/feffery_utils_components/_imports_.py +9 -1
  11. package/build/lib/feffery_utils_components/feffery_utils_components.min.js +404 -1
  12. package/build/lib/feffery_utils_components/metadata.json +475 -0
  13. package/build/lib/feffery_utils_components/package-info.json +7 -2
  14. package/feffery_utils_components/FefferyDashboard.py +39 -0
  15. package/feffery_utils_components/FefferyExecuteJs.py +33 -0
  16. package/feffery_utils_components/FefferyGuide.py +69 -0
  17. package/feffery_utils_components/FefferyResizable.py +39 -0
  18. package/feffery_utils_components/FefferyShortcutPanel.py +51 -0
  19. package/feffery_utils_components/FefferySplit.py +59 -0
  20. package/feffery_utils_components/FefferySplitPane.py +48 -0
  21. package/feffery_utils_components/_imports_.py +11 -1
  22. package/feffery_utils_components/feffery_utils_components.min.js +404 -1
  23. package/feffery_utils_components/metadata.json +506 -0
  24. package/feffery_utils_components/package-info.json +7 -2
  25. package/package.json +7 -2
  26. package/src/FefferyUtilsComponents.jl +8 -3
  27. package/src/jl/''_fefferydashboard.jl +23 -0
  28. package/src/jl/''_fefferyexecutejs.jl +20 -0
  29. package/src/jl/''_fefferyguide.jl +38 -0
  30. package/src/jl/''_fefferykeyboardshortcut.jl +36 -0
  31. package/src/jl/''_fefferyresizable.jl +23 -0
  32. package/src/jl/''_fefferyshortcutpanel.jl +29 -0
  33. package/src/jl/''_fefferysplit.jl +39 -0
  34. package/src/jl/''_fefferysplitpane.jl +32 -0
  35. package/src/lib/components/FefferyExecuteJs.react.js +47 -0
  36. package/src/lib/components/FefferyGuide.react.js +174 -0
  37. package/src/lib/components/FefferyShortcutPanel.react.js +277 -0
  38. package/src/lib/components/split/FefferySplit.react.js +199 -0
  39. package/src/lib/components/split/FefferySplitPane.react.js +75 -0
  40. package/src/lib/components/styles.css +70 -3
  41. package/src/lib/index.js +11 -1
  42. package/usage.py +145 -2
  43. package/webpack.config.js +2 -0
  44. package/feffery_utils_components/feffery_utils_components.min.js.LICENSE.txt +0 -35
@@ -0,0 +1,38 @@
1
+ # AUTO GENERATED FILE - DO NOT EDIT
2
+
3
+ export ''_fefferyguide
4
+
5
+ """
6
+ ''_fefferyguide(;kwargs...)
7
+
8
+ A FefferyGuide component.
9
+
10
+ Keyword arguments:
11
+ - `id` (optional)
12
+ - `arrow` (optional)
13
+ - `className` (optional)
14
+ - `closable` (optional)
15
+ - `hotspot` (optional)
16
+ - `loading_state` (optional)
17
+ - `localKey` (optional)
18
+ - `locale` (optional)
19
+ - `mask` (optional)
20
+ - `maskClassName` (optional)
21
+ - `modalClassName` (optional)
22
+ - `nextText` (optional)
23
+ - `okText` (optional)
24
+ - `prevText` (optional)
25
+ - `setProps` (optional): Dash-assigned callback that should be called to report property changes
26
+ to Dash, to make them available for callbacks.
27
+ - `showPreviousBtn` (optional)
28
+ - `step` (optional)
29
+ - `stepText` (optional)
30
+ - `steps` (optional)
31
+ - `style` (optional)
32
+ """
33
+ function ''_fefferyguide(; kwargs...)
34
+ available_props = Symbol[:id, :arrow, :className, :closable, :hotspot, :loading_state, :localKey, :locale, :mask, :maskClassName, :modalClassName, :nextText, :okText, :prevText, :showPreviousBtn, :step, :stepText, :steps, :style]
35
+ wild_props = Symbol[]
36
+ return Component("''_fefferyguide", "FefferyGuide", "feffery_utils_components", available_props, wild_props; kwargs...)
37
+ end
38
+
@@ -0,0 +1,36 @@
1
+ # AUTO GENERATED FILE - DO NOT EDIT
2
+
3
+ export ''_fefferykeyboardshortcut
4
+
5
+ """
6
+ ''_fefferykeyboardshortcut(;kwargs...)
7
+
8
+ A FefferyKeyboardShortcut component.
9
+
10
+ Keyword arguments:
11
+ - `id` (optional)
12
+ - `className` (optional)
13
+ - `closeHotkey` (optional)
14
+ - `data` (optional)
15
+ - `disableHotkeys` (optional)
16
+ - `goBackHotkey` (optional)
17
+ - `hotKeysJoinedView` (optional)
18
+ - `loading_state` (optional)
19
+ - `locale` (optional)
20
+ - `navigationDownHotkey` (optional)
21
+ - `navigationUpHotkey` (optional)
22
+ - `openHotkey` (optional)
23
+ - `placeholder` (optional)
24
+ - `selectHotkey` (optional)
25
+ - `setProps` (optional): Dash-assigned callback that should be called to report property changes
26
+ to Dash, to make them available for callbacks.
27
+ - `style` (optional)
28
+ - `theme` (optional)
29
+ - `triggeredHotkey` (optional)
30
+ """
31
+ function ''_fefferykeyboardshortcut(; kwargs...)
32
+ available_props = Symbol[:id, :className, :closeHotkey, :data, :disableHotkeys, :goBackHotkey, :hotKeysJoinedView, :loading_state, :locale, :navigationDownHotkey, :navigationUpHotkey, :openHotkey, :placeholder, :selectHotkey, :style, :theme, :triggeredHotkey]
33
+ wild_props = Symbol[]
34
+ return Component("''_fefferykeyboardshortcut", "FefferyKeyboardShortcut", "feffery_utils_components", available_props, wild_props; kwargs...)
35
+ end
36
+
@@ -0,0 +1,23 @@
1
+ # AUTO GENERATED FILE - DO NOT EDIT
2
+
3
+ export ''_fefferyresizable
4
+
5
+ """
6
+ ''_fefferyresizable(;kwargs...)
7
+
8
+ A FefferyResizable component.
9
+
10
+ Keyword arguments:
11
+ - `id` (optional)
12
+ - `className` (optional)
13
+ - `loading_state` (optional)
14
+ - `setProps` (optional): Dash-assigned callback that should be called to report property changes
15
+ to Dash, to make them available for callbacks.
16
+ - `style` (optional)
17
+ """
18
+ function ''_fefferyresizable(; kwargs...)
19
+ available_props = Symbol[:id, :className, :loading_state, :style]
20
+ wild_props = Symbol[]
21
+ return Component("''_fefferyresizable", "FefferyResizable", "feffery_utils_components", available_props, wild_props; kwargs...)
22
+ end
23
+
@@ -0,0 +1,29 @@
1
+ # AUTO GENERATED FILE - DO NOT EDIT
2
+
3
+ export ''_fefferyshortcutpanel
4
+
5
+ """
6
+ ''_fefferyshortcutpanel(;kwargs...)
7
+
8
+ A FefferyShortcutPanel component.
9
+
10
+ Keyword arguments:
11
+ - `id` (optional)
12
+ - `data` (optional)
13
+ - `disableHotkeys` (optional)
14
+ - `loading_state` (optional)
15
+ - `locale` (optional)
16
+ - `openHotkey` (optional)
17
+ - `placeholder` (optional)
18
+ - `setProps` (optional): Dash-assigned callback that should be called to report property changes
19
+ to Dash, to make them available for callbacks.
20
+ - `style` (optional)
21
+ - `theme` (optional)
22
+ - `triggeredHotkey` (optional)
23
+ """
24
+ function ''_fefferyshortcutpanel(; kwargs...)
25
+ available_props = Symbol[:id, :data, :disableHotkeys, :loading_state, :locale, :openHotkey, :placeholder, :style, :theme, :triggeredHotkey]
26
+ wild_props = Symbol[]
27
+ return Component("''_fefferyshortcutpanel", "FefferyShortcutPanel", "feffery_utils_components", available_props, wild_props; kwargs...)
28
+ end
29
+
@@ -0,0 +1,39 @@
1
+ # AUTO GENERATED FILE - DO NOT EDIT
2
+
3
+ export ''_fefferysplit
4
+
5
+ """
6
+ ''_fefferysplit(;kwargs...)
7
+ ''_fefferysplit(children::Any;kwargs...)
8
+ ''_fefferysplit(children_maker::Function;kwargs...)
9
+
10
+
11
+ A FefferySplit component.
12
+
13
+ Keyword arguments:
14
+ - `children` (optional)
15
+ - `id` (optional)
16
+ - `className` (optional)
17
+ - `cursor` (optional)
18
+ - `defaultSizes` (optional)
19
+ - `direction` (optional)
20
+ - `dragInterval` (optional)
21
+ - `expandToMin` (optional)
22
+ - `gutterSize` (optional)
23
+ - `loading_state` (optional)
24
+ - `maxSize` (optional)
25
+ - `minSize` (optional)
26
+ - `setProps` (optional): Dash-assigned callback that should be called to report property changes
27
+ to Dash, to make them available for callbacks.
28
+ - `sizes` (optional)
29
+ - `style` (optional)
30
+ """
31
+ function ''_fefferysplit(; kwargs...)
32
+ available_props = Symbol[:children, :id, :className, :cursor, :defaultSizes, :direction, :dragInterval, :expandToMin, :gutterSize, :loading_state, :maxSize, :minSize, :sizes, :style]
33
+ wild_props = Symbol[]
34
+ return Component("''_fefferysplit", "FefferySplit", "feffery_utils_components", available_props, wild_props; kwargs...)
35
+ end
36
+
37
+ ''_fefferysplit(children::Any; kwargs...) = ''_fefferysplit(;kwargs..., children = children)
38
+ ''_fefferysplit(children_maker::Function; kwargs...) = ''_fefferysplit(children_maker(); kwargs...)
39
+
@@ -0,0 +1,32 @@
1
+ # AUTO GENERATED FILE - DO NOT EDIT
2
+
3
+ export ''_fefferysplitpane
4
+
5
+ """
6
+ ''_fefferysplitpane(;kwargs...)
7
+ ''_fefferysplitpane(children::Any;kwargs...)
8
+ ''_fefferysplitpane(children_maker::Function;kwargs...)
9
+
10
+
11
+ A FefferySplitPane component.
12
+
13
+ Keyword arguments:
14
+ - `children` (a list of or a singular dash component, string or number; optional)
15
+ - `id` (String; optional)
16
+ - `className` (String; optional)
17
+ - `loading_state` (optional): . loading_state has the following type: lists containing elements 'is_loading', 'prop_name', 'component_name'.
18
+ Those elements have the following types:
19
+ - `is_loading` (Bool; optional): Determines if the component is loading or not
20
+ - `prop_name` (String; optional): Holds which property is loading
21
+ - `component_name` (String; optional): Holds the name of the component that is loading
22
+ - `style` (Dict; optional)
23
+ """
24
+ function ''_fefferysplitpane(; kwargs...)
25
+ available_props = Symbol[:children, :id, :className, :loading_state, :style]
26
+ wild_props = Symbol[]
27
+ return Component("''_fefferysplitpane", "FefferySplitPane", "feffery_utils_components", available_props, wild_props; kwargs...)
28
+ end
29
+
30
+ ''_fefferysplitpane(children::Any; kwargs...) = ''_fefferysplitpane(;kwargs..., children = children)
31
+ ''_fefferysplitpane(children_maker::Function; kwargs...) = ''_fefferysplitpane(children_maker(); kwargs...)
32
+
@@ -0,0 +1,47 @@
1
+ import { Component } from 'react';
2
+
3
+
4
+ // 定义js直接执行部件FefferyExecuteJs
5
+ export default class FefferyExecuteJs extends Component {
6
+ render() {
7
+ // 取得必要属性或参数
8
+ const {
9
+ jsString
10
+ } = this.props;
11
+
12
+ // 执行原生js程序
13
+ if (jsString) {
14
+ eval(jsString)
15
+ }
16
+
17
+ return <></>
18
+ }
19
+
20
+ }
21
+ // 定义参数或属性
22
+ FefferyExecuteJs.propTypes = {
23
+ // 部件id
24
+ id: PropTypes.string,
25
+
26
+ // 设置要执行的js代码字符串
27
+ jsString: PropTypes.string,
28
+
29
+ loading_state: PropTypes.shape({
30
+ /**
31
+ * Determines if the component is loading or not
32
+ */
33
+ is_loading: PropTypes.bool,
34
+ /**
35
+ * Holds which property is loading
36
+ */
37
+ prop_name: PropTypes.string,
38
+ /**
39
+ * Holds the name of the component that is loading
40
+ */
41
+ component_name: PropTypes.string
42
+ })
43
+ };
44
+
45
+ // 设置默认参数
46
+ FefferyExecuteJs.defaultProps = {
47
+ }
@@ -0,0 +1,174 @@
1
+ import React from 'react';
2
+ import Guide from 'byte-guide'
3
+ import './styles.css'
4
+
5
+ // 定义引导部件FefferyGuide,api参数参考https://github.com/bytedance/guide/blob/main/README.zh-CN.md
6
+ const FefferyGuide = (props) => {
7
+ // 取得必要属性或参数
8
+ let {
9
+ id,
10
+ className,
11
+ style,
12
+ locale,
13
+ steps,
14
+ localKey,
15
+ closable,
16
+ modalClassName,
17
+ maskClassName,
18
+ mask,
19
+ arrow,
20
+ hotspot,
21
+ stepText,
22
+ nextText,
23
+ prevText,
24
+ showPreviousBtn,
25
+ okText,
26
+ step,
27
+ setProps,
28
+ } = props;
29
+
30
+ // 返回向页面注入的快捷键监听
31
+ return (
32
+ <Guide id={id}
33
+ className={className}
34
+ style={style}
35
+ lang={locale}
36
+ steps={steps}
37
+ localKey={localKey}
38
+ closable={closable}
39
+ modalClassName={modalClassName}
40
+ maskClassName={maskClassName}
41
+ mask={mask}
42
+ arrow={arrow}
43
+ hotspot={hotspot}
44
+ stepText={typeof stepText === typeof ''
45
+ ? eval(stepText) : stepText}
46
+ nextText={nextText}
47
+ prevText={prevText}
48
+ showPreviousBtn={showPreviousBtn}
49
+ okText={okText}
50
+ step={step} />
51
+ );
52
+ }
53
+
54
+ // 定义参数或属性
55
+ FefferyGuide.propTypes = {
56
+ // 部件id
57
+ id: PropTypes.string,
58
+
59
+ // css类名
60
+ className: PropTypes.string,
61
+
62
+ // 自定义css字典
63
+ style: PropTypes.object,
64
+
65
+ // 设置语言,可选的有'en'、'zh'
66
+ locale: PropTypes.oneOf(['zh', 'en']),
67
+
68
+ // 必填,用于构造每一步锚定的页面元素
69
+ steps: PropTypes.arrayOf(
70
+ PropTypes.exact({
71
+ // 对应当前步骤锚定的元素对应的css选择器
72
+ selector: PropTypes.string,
73
+
74
+ // 当selector参数缺省时,可用targetPos参数基于绝对位置进行步骤锚定
75
+ targetPos: PropTypes.exact({
76
+ // 设置距离顶部的像素距离
77
+ top: PropTypes.number,
78
+ // 设置距离左端的像素距离
79
+ left: PropTypes.number,
80
+ // 设置锚定范围像素宽度
81
+ width: PropTypes.number,
82
+ // 设置锚定范围像素高度
83
+ height: PropTypes.number
84
+ }),
85
+
86
+ // 设置展示面板的标题内容
87
+ title: PropTypes.string,
88
+
89
+ // 设置展示面板的描述内容
90
+ content: PropTypes.string,
91
+
92
+ // 设置展示面板相对锚点的方位,可选的有'bottom-left'、'left-bottom'、'bottom',默认为'bottom'
93
+ placement: PropTypes.oneOf([
94
+ 'bottom-left', 'left-bottom', 'bottom'
95
+ ]),
96
+
97
+ // 设置展示面板的像素偏移量
98
+ offset: PropTypes.exact({
99
+ // 水平方向偏移像素距离
100
+ x: PropTypes.number,
101
+ // 竖直方向偏移像素距离
102
+ y: PropTypes.number
103
+ })
104
+ })
105
+ ).isRequired,
106
+
107
+ // 用于设置本地缓存唯一标识key,从而辅助应用判断是否已展示过该引导页
108
+ localKey: PropTypes.string.isRequired,
109
+
110
+ // 设置是否允许跳过引导,默认为true
111
+ closable: PropTypes.bool,
112
+
113
+ // 设置展示面板的类名
114
+ modalClassName: PropTypes.string,
115
+
116
+ // 设置蒙版层的类名
117
+ maskClassName: PropTypes.string,
118
+
119
+ // 设置是否展示蒙板层,默认为true
120
+ mask: PropTypes.bool,
121
+
122
+ // 设置展示面板是否添加箭头,默认为true
123
+ arrow: PropTypes.bool,
124
+
125
+ // 设置展示面板是否展示热点,默认为false
126
+ hotspot: PropTypes.bool,
127
+
128
+ // 自定义步骤信息展示内容的回调函数,默认为"(stepIndex, stepCount) => { return '第${stepIndex}步,共${stepCount}步'; }"
129
+ stepText: PropTypes.string,
130
+
131
+ // 设置“下一步”按钮的文案信息
132
+ nextText: PropTypes.string,
133
+
134
+ // 设置“上一步”按钮的文案信息
135
+ prevText: PropTypes.string,
136
+
137
+ // 设置是否显示“上一步”按钮,默认为true
138
+ showPreviousBtn: PropTypes.bool,
139
+
140
+ // 设置确认按钮的文案信息
141
+ okText: PropTypes.string,
142
+
143
+ // 设置初始化时的起始步骤,为-1时则不显示引导组件,默认为0
144
+ step: PropTypes.number,
145
+
146
+ loading_state: PropTypes.shape({
147
+ /**
148
+ * Determines if the component is loading or not
149
+ */
150
+ is_loading: PropTypes.bool,
151
+ /**
152
+ * Holds which property is loading
153
+ */
154
+ prop_name: PropTypes.string,
155
+ /**
156
+ * Holds the name of the component that is loading
157
+ */
158
+ component_name: PropTypes.string
159
+ }),
160
+
161
+ /**
162
+ * Dash-assigned callback that should be called to report property changes
163
+ * to Dash, to make them available for callbacks.
164
+ */
165
+ setProps: PropTypes.func
166
+ };
167
+
168
+ // 设置默认参数
169
+ FefferyGuide.defaultProps = {
170
+ locale: 'zh',
171
+ showPreviousBtn: true
172
+ }
173
+
174
+ export default FefferyGuide;
@@ -0,0 +1,277 @@
1
+ import React, { useState, useRef, useEffect } from 'react';
2
+ import "ninja-keys";
3
+ import './styles.css'
4
+
5
+ const footerHtmlEn = <div class="modal-footer" slot="footer">
6
+ <span class="help">
7
+ <span className="ninja-examplekey esc">enter</span>
8
+ to select
9
+ </span>
10
+ <span className="help">
11
+ <svg
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ className="ninja-examplekey"
14
+ viewBox="0 0 24 24"
15
+ >
16
+ <path d="M0 0h24v24H0V0z" fill="none" />
17
+ <path
18
+ d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
19
+ />
20
+ </svg>
21
+ <svg
22
+ xmlns="http://www.w3.org/2000/svg"
23
+ className="ninja-examplekey"
24
+ viewBox="0 0 24 24"
25
+ >
26
+ <path d="M0 0h24v24H0V0z" fill="none" />
27
+ <path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z" />
28
+ </svg>
29
+ to navigate
30
+ </span>
31
+ <span className="help">
32
+ <span className="ninja-examplekey esc">esc</span>
33
+ to close
34
+ </span>
35
+ <span className="help">
36
+ <span className="ninja-examplekey esc">backspace</span>
37
+ move to parent
38
+ </span>
39
+ </div>
40
+
41
+
42
+ const footerHtmlZh = <div className="modal-footer" slot="footer">
43
+ <span className="help">
44
+ <span className="ninja-examplekey esc">enter</span>
45
+ 选择
46
+ </span>
47
+ <span className="help">
48
+ <svg
49
+ xmlns="http://www.w3.org/2000/svg"
50
+ className="ninja-examplekey"
51
+ viewBox="0 0 24 24"
52
+ >
53
+ <path d="M0 0h24v24H0V0z" fill="none" />
54
+ <path
55
+ d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
56
+ />
57
+ </svg>
58
+ <svg
59
+ xmlns="http://www.w3.org/2000/svg"
60
+ className="ninja-examplekey"
61
+ viewBox="0 0 24 24"
62
+ >
63
+ <path d="M0 0h24v24H0V0z" fill="none" />
64
+ <path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z" />
65
+ </svg>
66
+ 上下切换
67
+ </span>
68
+ <span className="help">
69
+ <span className="ninja-examplekey esc">esc</span>
70
+ 关闭面板
71
+ </span>
72
+ <span className="help">
73
+ <span className="ninja-examplekey esc">backspace</span>
74
+ 回到上一级
75
+ </span>
76
+ </div>
77
+
78
+
79
+ // 定义快捷方式面板部件FefferyShortcutPanel,api参数参考https://github.com/ssleptsov/ninja-keys
80
+ const FefferyShortcutPanel = (props) => {
81
+ // 取得必要属性或参数
82
+ let {
83
+ id,
84
+ style,
85
+ data,
86
+ placeholder,
87
+ disableHotkeys,
88
+ openHotkey,
89
+ theme,
90
+ locale,
91
+ setProps,
92
+ } = props;
93
+
94
+ data = data || [
95
+ {
96
+ id: "Home",
97
+ title: "Open Home",
98
+ hotkey: "cmd+h",
99
+ handler: () => {
100
+ console.log("navigation to home");
101
+ }
102
+ },
103
+ {
104
+ id: "Open Projects",
105
+ title: "Open Projects",
106
+ hotkey: "cmd+p",
107
+ handler: () => {
108
+ console.log("navigation to projects");
109
+ }
110
+ },
111
+ {
112
+ id: "Theme",
113
+ title: "Change theme...",
114
+ children: [
115
+ 'Light Theme', 'Dark Theme'
116
+ ]
117
+ },
118
+ {
119
+ id: "Light Theme",
120
+ title: "Change theme to Light",
121
+ parent: 'Theme',
122
+ handler: () => {
123
+ console.log("theme light");
124
+ }
125
+ },
126
+ {
127
+ id: "Dark Theme",
128
+ title: "Change theme to Dark",
129
+ parent: 'Theme',
130
+ keywords: "lol",
131
+ handler: () => {
132
+ console.log("theme dark");
133
+ }
134
+ }
135
+ ]
136
+
137
+ // 填充handler缺省时的默认逻辑
138
+ data = data.map(
139
+ item => {
140
+ return typeof item.handler === typeof '' || item.hasOwnProperty('children') ?
141
+ item : {
142
+ ...item,
143
+ ...{
144
+ handler: () => {
145
+ setProps({
146
+ triggeredHotkey: item.id + ' ' + Date.parse(new Date()).toString()
147
+ })
148
+ }
149
+ }
150
+ }
151
+ }
152
+ )
153
+
154
+ const ninjaKeys = useRef(null);
155
+ const [hotkeys, setHotkeys] = useState(
156
+ data.map(
157
+ item => typeof item.handler === typeof '' ?
158
+ {
159
+ ...item,
160
+ ...{
161
+ handler: eval(item.handler)
162
+ }
163
+ } : item
164
+ )
165
+ );
166
+
167
+ useEffect(() => {
168
+ if (ninjaKeys.current) {
169
+ ninjaKeys.current.data = hotkeys;
170
+ }
171
+ }, []);
172
+
173
+ // 返回向页面注入的快捷键监听
174
+ return (
175
+ <ninja-keys id={id}
176
+ class={theme || 'light'}
177
+ style={style}
178
+ ref={ninjaKeys}
179
+ placeholder={placeholder}
180
+ disableHotkeys={disableHotkeys}
181
+ openHotkey={openHotkey}
182
+ hotKeysJoinedView={true}
183
+ hideBreadcrumbs={true} >
184
+ {locale === 'en' ? footerHtmlEn : footerHtmlZh}
185
+ </ ninja-keys>
186
+ );
187
+ }
188
+
189
+ // 定义参数或属性
190
+ FefferyShortcutPanel.propTypes = {
191
+ // 部件id
192
+ id: PropTypes.string,
193
+
194
+ // 自定义css字典
195
+ style: PropTypes.object,
196
+
197
+ // 设置语言,可选的有'en'、'zh'
198
+ locale: PropTypes.oneOf(['en', 'zh']),
199
+
200
+ // 用于定义热键节点的数据结构
201
+ data: PropTypes.arrayOf(
202
+ PropTypes.exact({
203
+ // 用于定义当前热键的唯一id,会在顶端热键面包屑中进行显示
204
+ id: PropTypes.string.isRequired,
205
+
206
+ // 用于定义当前热键的标题信息
207
+ title: PropTypes.string.isRequired,
208
+
209
+ // 用于定义当前热键对应的快捷键方式
210
+ hotkey: PropTypes.string,
211
+
212
+ // 用于传入字符型的js函数体源码,作为当前热键被触发时的行为
213
+ handler: PropTypes.oneOfType([
214
+ PropTypes.string,
215
+ PropTypes.func
216
+ ]),
217
+
218
+ // 用于设置当前热键上一层级节点的id信息
219
+ parent: PropTypes.string,
220
+
221
+ // 用于设置当前热键被搜索时对应的关键词
222
+ keywords: PropTypes.string,
223
+
224
+ // 用于设置当前热键节点下一层级对应的节点id信息数组
225
+ children: PropTypes.arrayOf(PropTypes.string),
226
+
227
+ // 用于设置分组标题文字
228
+ section: PropTypes.string
229
+ })
230
+ ),
231
+
232
+ // 监听记录最近一次被触发的热键id以及对应触发时间的秒级时间戳信息
233
+ triggeredHotkey: PropTypes.oneOfType([
234
+ PropTypes.string
235
+ ]),
236
+
237
+ // 定义输入框提示内容
238
+ placeholder: PropTypes.string,
239
+
240
+ // 设置是否禁用热键,默认为false
241
+ disableHotkeys: PropTypes.bool,
242
+
243
+ // 设置唤出指令面板的快捷键组合,默认为'cmd+k,ctrl+k'
244
+ openHotkey: PropTypes.string,
245
+
246
+ // 设置主题,可选的有'light'、'dark'
247
+ theme: PropTypes.oneOf(['light', 'dark']),
248
+
249
+ loading_state: PropTypes.shape({
250
+ /**
251
+ * Determines if the component is loading or not
252
+ */
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
269
+ };
270
+
271
+ // 设置默认参数
272
+ FefferyShortcutPanel.defaultProps = {
273
+ locale: 'zh',
274
+ theme: 'light'
275
+ }
276
+
277
+ export default FefferyShortcutPanel;