feffery_utils_components 0.0.7 → 0.0.8

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 (36) hide show
  1. package/DESCRIPTION +1 -1
  2. package/NAMESPACE +6 -1
  3. package/Project.toml +2 -2
  4. package/build/lib/feffery_utils_components/FefferyShortcutPanel.py +53 -0
  5. package/build/lib/feffery_utils_components/_imports_.py +2 -0
  6. package/build/lib/feffery_utils_components/feffery_utils_components.min.js +404 -1
  7. package/build/lib/feffery_utils_components/metadata.json +111 -0
  8. package/build/lib/feffery_utils_components/package-info.json +2 -1
  9. package/feffery_utils_components/FefferyDashboard.py +39 -0
  10. package/feffery_utils_components/FefferyGuide.py +69 -0
  11. package/feffery_utils_components/FefferyResizable.py +39 -0
  12. package/feffery_utils_components/FefferyShortcutPanel.py +4 -6
  13. package/feffery_utils_components/FefferySplit.py +59 -0
  14. package/feffery_utils_components/FefferySplitPane.py +48 -0
  15. package/feffery_utils_components/_imports_.py +7 -1
  16. package/feffery_utils_components/feffery_utils_components.min.js +6 -6
  17. package/feffery_utils_components/metadata.json +374 -10
  18. package/feffery_utils_components/package-info.json +6 -2
  19. package/package.json +6 -2
  20. package/src/FefferyUtilsComponents.jl +6 -3
  21. package/src/jl/''_fefferydashboard.jl +23 -0
  22. package/src/jl/''_fefferyguide.jl +38 -0
  23. package/src/jl/''_fefferyresizable.jl +23 -0
  24. package/src/jl/''_fefferyshortcutpanel.jl +1 -2
  25. package/src/jl/''_fefferysplit.jl +39 -0
  26. package/src/jl/''_fefferysplitpane.jl +32 -0
  27. package/src/lib/components/FefferyExecuteJs.react.js +45 -0
  28. package/src/lib/components/FefferyGuide.react.js +174 -0
  29. package/src/lib/components/FefferyShortcutPanel.react.js +5 -9
  30. package/src/lib/components/split/FefferySplit.react.js +199 -0
  31. package/src/lib/components/split/FefferySplitPane.react.js +75 -0
  32. package/src/lib/components/styles.css +31 -1
  33. package/src/lib/index.js +9 -1
  34. package/usage.py +94 -2
  35. package/webpack.config.js +2 -0
  36. package/feffery_utils_components/feffery_utils_components.min.js.LICENSE.txt +0 -102
@@ -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,45 @@
1
+
2
+ // 定义js直接执行部件FefferyExecuteJs
3
+ const FefferyExecuteJs = (props) => {
4
+ // 取得必要属性或参数
5
+ const {
6
+ jsString
7
+ } = props;
8
+
9
+ // 执行原生js程序
10
+ if (jsString) {
11
+ eval(jsString)
12
+ }
13
+
14
+ return
15
+ }
16
+
17
+ // 定义参数或属性
18
+ FefferyExecuteJs.propTypes = {
19
+ // 部件id
20
+ id: PropTypes.string,
21
+
22
+ // 设置要执行的js代码字符串
23
+ jsString: PropTypes.string,
24
+
25
+ loading_state: PropTypes.shape({
26
+ /**
27
+ * Determines if the component is loading or not
28
+ */
29
+ is_loading: PropTypes.bool,
30
+ /**
31
+ * Holds which property is loading
32
+ */
33
+ prop_name: PropTypes.string,
34
+ /**
35
+ * Holds the name of the component that is loading
36
+ */
37
+ component_name: PropTypes.string
38
+ })
39
+ };
40
+
41
+ // 设置默认参数
42
+ FefferyExecuteJs.defaultProps = {
43
+ }
44
+
45
+ export default FefferyExecuteJs;
@@ -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;
@@ -39,7 +39,7 @@ const footerHtmlEn = <div class="modal-footer" slot="footer">
39
39
  </div>
40
40
 
41
41
 
42
- const footerHtmlCn = <div className="modal-footer" slot="footer">
42
+ const footerHtmlZh = <div className="modal-footer" slot="footer">
43
43
  <span className="help">
44
44
  <span className="ninja-examplekey esc">enter</span>
45
45
  选择
@@ -86,7 +86,6 @@ const FefferyShortcutPanel = (props) => {
86
86
  placeholder,
87
87
  disableHotkeys,
88
88
  openHotkey,
89
- hotKeysJoinedView,
90
89
  theme,
91
90
  locale,
92
91
  setProps,
@@ -182,7 +181,7 @@ const FefferyShortcutPanel = (props) => {
182
181
  openHotkey={openHotkey}
183
182
  hotKeysJoinedView={true}
184
183
  hideBreadcrumbs={true} >
185
- {locale === 'en' ? footerHtmlEn : footerHtmlCn}
184
+ {locale === 'en' ? footerHtmlEn : footerHtmlZh}
186
185
  </ ninja-keys>
187
186
  );
188
187
  }
@@ -192,14 +191,11 @@ FefferyShortcutPanel.propTypes = {
192
191
  // 部件id
193
192
  id: PropTypes.string,
194
193
 
195
- // css类名
196
- className: PropTypes.string,
197
-
198
194
  // 自定义css字典
199
195
  style: PropTypes.object,
200
196
 
201
- // 设置语言,可选的有'en'、'cn'
202
- locale: PropTypes.oneOf(['en', 'cn']),
197
+ // 设置语言,可选的有'en'、'zh'
198
+ locale: PropTypes.oneOf(['en', 'zh']),
203
199
 
204
200
  // 用于定义热键节点的数据结构
205
201
  data: PropTypes.arrayOf(
@@ -274,7 +270,7 @@ FefferyShortcutPanel.propTypes = {
274
270
 
275
271
  // 设置默认参数
276
272
  FefferyShortcutPanel.defaultProps = {
277
- locale: 'cn',
273
+ locale: 'zh',
278
274
  theme: 'light'
279
275
  }
280
276
 
@@ -0,0 +1,199 @@
1
+ import React, { Component } from 'react';
2
+ import Split from 'react-split'
3
+ import { isNil, omit } from 'ramda';
4
+ import '../styles.css'
5
+
6
+ const parseChildrenToArray = children => {
7
+ if (children && !Array.isArray(children)) {
8
+ return [children];
9
+ }
10
+ return children;
11
+ };
12
+
13
+
14
+ const resolveChildProps = child => {
15
+ // This may need to change in the future if https://github.com/plotly/dash-renderer/issues/84 is addressed
16
+ if (
17
+ // disabled is a defaultProp (so it's always set)
18
+ // meaning that if it's not set on child.props, the actual
19
+ // props we want are lying a bit deeper - which means they
20
+ // are coming from Dash
21
+ isNil(child.props.disabled) &&
22
+ child.props._dashprivate_layout &&
23
+ child.props._dashprivate_layout.props
24
+ ) {
25
+ // props are coming from Dash
26
+ return child.props._dashprivate_layout.props;
27
+ } else {
28
+ // else props are coming from React (e.g. Demo.js, or Tabs.test.js)
29
+ return child.props;
30
+ }
31
+ };
32
+
33
+ // 定义分割面板组件FefferySplit,api参数参考https://github.com/nathancahill/split/tree/master/packages/splitjs
34
+ export default class FefferySplit extends Component {
35
+
36
+ constructor(props) {
37
+ super(props)
38
+ // 初始化value
39
+ if (props.defaultSizes) {
40
+ // 当defaultSizes不为空时,为sizes初始化defaultSizes对应的sizes值
41
+ props.setProps({ sizes: props.defaultSizes })
42
+ }
43
+ }
44
+
45
+ render() {
46
+ // 取得必要属性或参数
47
+ let {
48
+ children,
49
+ id,
50
+ className,
51
+ style,
52
+ sizes,
53
+ defaultSizes,
54
+ minSize,
55
+ maxSize,
56
+ expandToMin,
57
+ gutterSize,
58
+ dragInterval,
59
+ direction,
60
+ cursor,
61
+ setProps,
62
+ loading_state
63
+ } = this.props;
64
+
65
+ children = parseChildrenToArray(children)
66
+
67
+ const splitPanes = children.map(
68
+ (child) => {
69
+ let childProps = resolveChildProps(child)
70
+
71
+ const {
72
+ id,
73
+ className,
74
+ style,
75
+ loading_state,
76
+ ...otherProps
77
+ } = childProps;
78
+
79
+ return (
80
+ <div
81
+ id={id}
82
+ className={className}
83
+ style={style}
84
+ loading_state={loading_state}
85
+ {...omit(
86
+ ['setProps', 'persistence', 'persistence_type', 'persisted_props'],
87
+ otherProps
88
+ )}>
89
+ {child}
90
+ </div>
91
+ );
92
+ }
93
+ )
94
+
95
+ // 返回向页面注入的快捷键监听
96
+ return (
97
+ <Split id={id}
98
+ className={className ? `feffery-split-${direction}` + ' ' + className : `feffery-split-${direction}`}
99
+ style={style}
100
+ sizes={defaultSizes}
101
+ minSize={minSize}
102
+ maxSize={maxSize}
103
+ expandToMin={expandToMin}
104
+ gutterSize={gutterSize}
105
+ snapOffset={1}
106
+ dragInterval={dragInterval}
107
+ direction={direction}
108
+ cursor={cursor}
109
+ onDragEnd={(e) => {
110
+ setProps({ sizes: e })
111
+ }}
112
+ data-dash-is-loading={
113
+ (loading_state && loading_state.is_loading) || undefined
114
+ }
115
+ >
116
+ {splitPanes}
117
+ </Split>
118
+ );
119
+ }
120
+ }
121
+
122
+ // 定义参数或属性
123
+ FefferySplit.propTypes = {
124
+
125
+ children: PropTypes.node,
126
+
127
+ // 部件id
128
+ id: PropTypes.string,
129
+
130
+ // css类名
131
+ className: PropTypes.string,
132
+
133
+ // 自定义css字典
134
+ style: PropTypes.object,
135
+
136
+ // 以数组的形式,分别为每个子元素盒子设置百分比尺寸
137
+ defaultSizes: PropTypes.arrayOf(PropTypes.number),
138
+
139
+ // 记录当前最新的sizes变动情况,分别为每个子元素盒子设置百分比尺寸
140
+ sizes: PropTypes.arrayOf(PropTypes.number),
141
+
142
+ // 设置每个子元素盒子的最小像素尺寸,默认为100
143
+ minSize: PropTypes.oneOfType([
144
+ // 统一设置最小尺寸
145
+ PropTypes.number,
146
+ // 逐一设置最小尺寸
147
+ PropTypes.arrayOf(PropTypes.number)
148
+ ]),
149
+
150
+ // 设置每个子元素盒子的最大像素尺寸,默认为Infinity即无限制
151
+ maxSize: PropTypes.oneOfType([
152
+ // 统一设置最大尺寸
153
+ PropTypes.number,
154
+ // 逐一设置最大尺寸
155
+ PropTypes.arrayOf(PropTypes.number)
156
+ ]),
157
+
158
+ // 设置当有子元素盒子的初始宽度小于设定的minSize时,是否自动调整到minSize,默认为false
159
+ expandToMin: PropTypes.bool,
160
+
161
+ // 设置间隙像素尺寸,默认为10
162
+ gutterSize: PropTypes.number,
163
+
164
+ // 设置拖拽行为的像素移动步长,默认为1
165
+ dragInterval: PropTypes.number,
166
+
167
+ // 设置分割方向,可选的有'horizontal'、'vertical'
168
+ direction: PropTypes.oneOf(['horizontal', 'vertical']),
169
+
170
+ // 设置拖拽分隔条时的鼠标指针,当direction='horizontal'时默认为'col-resize'
171
+ // 当direction='vertical'时默认为'row-resize'
172
+ cursor: PropTypes.string,
173
+
174
+ loading_state: PropTypes.shape({
175
+ /**
176
+ * Determines if the component is loading or not
177
+ */
178
+ is_loading: PropTypes.bool,
179
+ /**
180
+ * Holds which property is loading
181
+ */
182
+ prop_name: PropTypes.string,
183
+ /**
184
+ * Holds the name of the component that is loading
185
+ */
186
+ component_name: PropTypes.string
187
+ }),
188
+
189
+ /**
190
+ * Dash-assigned callback that should be called to report property changes
191
+ * to Dash, to make them available for callbacks.
192
+ */
193
+ setProps: PropTypes.func
194
+ };
195
+
196
+ // 设置默认参数
197
+ FefferySplit.defaultProps = {
198
+ direction: 'horizontal'
199
+ }
@@ -0,0 +1,75 @@
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ const parseChildrenToArray = children => {
5
+ if (children && !Array.isArray(children)) {
6
+ return [children];
7
+ }
8
+ return children;
9
+ };
10
+
11
+ // 定义分割子面板组件FefferySplitPane
12
+ export default class FefferySplitPane extends Component {
13
+ render() {
14
+ // 取得必要属性或参数
15
+ let {
16
+ id,
17
+ children,
18
+ className,
19
+ style,
20
+ loading_state
21
+ } = this.props;
22
+
23
+ children = parseChildrenToArray(children)
24
+
25
+ return (
26
+ <div id={id}
27
+ className={className}
28
+ style={style}
29
+ children={children}
30
+ data-dash-is-loading={
31
+ (loading_state && loading_state.is_loading) || undefined
32
+ }>
33
+ </div>
34
+ );
35
+ }
36
+ }
37
+
38
+ // 定义参数或属性
39
+ FefferySplitPane.propTypes = {
40
+ // 组件id
41
+ id: PropTypes.string,
42
+
43
+ children: PropTypes.node,
44
+
45
+ // css类名
46
+ className: PropTypes.string,
47
+
48
+ // 自定义css字典
49
+ style: PropTypes.object,
50
+
51
+ loading_state: PropTypes.shape({
52
+ /**
53
+ * Determines if the component is loading or not
54
+ */
55
+ is_loading: PropTypes.bool,
56
+ /**
57
+ * Holds which property is loading
58
+ */
59
+ prop_name: PropTypes.string,
60
+ /**
61
+ * Holds the name of the component that is loading
62
+ */
63
+ component_name: PropTypes.string
64
+ }),
65
+
66
+ /**
67
+ * Dash-assigned callback that should be called to report property changes
68
+ * to Dash, to make them available for callbacks.
69
+ */
70
+ setProps: PropTypes.func
71
+ };
72
+
73
+ // 设置默认参数
74
+ FefferySplitPane.defaultProps = {
75
+ }
@@ -35,7 +35,6 @@
35
35
  padding: 0.06em 0.25em;
36
36
  border-radius: var(--ninja-key-border-radius);
37
37
  color: var(--ninja-secondary-text-color);
38
- /* width: 1em; */
39
38
  height: 1em;
40
39
  margin-right: 0.5em;
41
40
  font-size: 1.25em;
@@ -50,4 +49,35 @@
50
49
 
51
50
  .ninja-examplekey.backspace {
52
51
  opacity: 0.7;
52
+ }
53
+
54
+ html {
55
+ overflow: auto !important;
56
+ }
57
+
58
+ .feffery-split-vertical {
59
+ border: none;
60
+ }
61
+
62
+ .feffery-split-horizontal {
63
+ display: flex;
64
+ flex-direction: row;
65
+ }
66
+
67
+ .gutter {
68
+ background-color: #e3f2fd;
69
+ background-repeat: no-repeat;
70
+ background-position: 50%;
71
+ }
72
+
73
+ .gutter:hover {
74
+ background-color: #42a5f5;
75
+ }
76
+
77
+ .gutter.gutter-horizontal {
78
+ cursor: col-resize;
79
+ }
80
+
81
+ .gutter.gutter-vertical {
82
+ cursor: row-resize;
53
83
  }
package/src/lib/index.js CHANGED
@@ -5,6 +5,10 @@ import FefferySyntaxHighlighter from "./components/FefferySyntaxHighlighter.reac
5
5
  import FefferyPasteImage from "./components/FefferyPasteImage.react";
6
6
  import FefferyTopProgress from "./components/FefferyTopProgress.react"
7
7
  import FefferyShortcutPanel from "./components/FefferyShortcutPanel.react"
8
+ import FefferyGuide from "./components/FefferyGuide.react"
9
+ import FefferySplit from "./components/split/FefferySplit.react";
10
+ import FefferySplitPane from "./components/split/FefferySplitPane.react"
11
+ import FefferyExecuteJs from "./components/FefferyExecuteJs.react";
8
12
 
9
13
 
10
14
  export {
@@ -13,5 +17,9 @@ export {
13
17
  FefferySyntaxHighlighter,
14
18
  FefferyPasteImage,
15
19
  FefferyTopProgress,
16
- FefferyShortcutPanel
20
+ FefferyShortcutPanel,
21
+ FefferyGuide,
22
+ FefferySplit,
23
+ FefferySplitPane,
24
+ FefferyExecuteJs
17
25
  };