feffery_utils_components 0.0.4 → 0.0.5

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 (32) hide show
  1. package/DESCRIPTION +1 -1
  2. package/NAMESPACE +1 -2
  3. package/Project.toml +1 -1
  4. package/feffery_utils_components/FefferyPasteImage.py +56 -0
  5. package/feffery_utils_components/__pycache__/FefferyCaptcha.cpython-37.pyc +0 -0
  6. package/feffery_utils_components/__pycache__/FefferyPasteImage.cpython-37.pyc +0 -0
  7. package/feffery_utils_components/__pycache__/FefferySyntaxHighlighter.cpython-37.pyc +0 -0
  8. package/feffery_utils_components/__pycache__/FefferyWaterMark.cpython-37.pyc +0 -0
  9. package/feffery_utils_components/__pycache__/__init__.cpython-37.pyc +0 -0
  10. package/feffery_utils_components/__pycache__/_imports_.cpython-37.pyc +0 -0
  11. package/feffery_utils_components/_imports_.py +2 -2
  12. package/feffery_utils_components/feffery_utils_components.min.js +1 -1
  13. package/feffery_utils_components/feffery_utils_components.min.js.LICENSE.txt +0 -16
  14. package/feffery_utils_components/metadata.json +41 -13
  15. package/feffery_utils_components/package-info.json +13 -11
  16. package/package.json +13 -11
  17. package/src/FefferyUtilsComponents.jl +4 -4
  18. package/src/jl/''_fefferypasteimage.jl +35 -0
  19. package/src/lib/components/FefferyPasteImage.react.js +168 -0
  20. package/src/lib/components/FefferySyntaxHighlighter.react.js +3 -3
  21. package/src/lib/components/styles.css +13 -0
  22. package/src/lib/index.js +4 -3
  23. package/usage.py +28 -170
  24. package/.Rbuildignore +0 -34
  25. package/.babelrc +0 -6
  26. package/feffery_utils_components/FefferyMarkdown.py +0 -50
  27. package/feffery_utils_components/__pycache__/FefferyContextMenu.cpython-37.pyc +0 -0
  28. package/feffery_utils_components/__pycache__/FefferyFefferySyntaxHighlighter.cpython-37.pyc +0 -0
  29. package/feffery_utils_components/__pycache__/FefferyMarkdown.cpython-37.pyc +0 -0
  30. package/feffery_utils_components/__pycache__/FefferyNprogress.cpython-37.pyc +0 -0
  31. package/feffery_utils_components/__pycache__/FefferyUtilsComponents.cpython-37.pyc +0 -0
  32. package/src/lib/components/FefferyMarkdown.react.js +0 -163
package/usage.py CHANGED
@@ -1,12 +1,23 @@
1
1
  import feffery_utils_components as fuc
2
2
  import dash
3
3
  from dash.dependencies import Input, Output
4
- import dash_html_components as html
4
+ from dash import html
5
5
 
6
6
  app = dash.Dash(__name__)
7
7
 
8
8
  app.layout = html.Div(
9
9
  [
10
+ fuc.FefferyPasteImage(
11
+ id='test',
12
+ style={
13
+ 'height': '500px',
14
+ 'width': '800px',
15
+ 'marginBottom': '100px'
16
+ }
17
+ ),
18
+ html.Div(id='test-output'),
19
+
20
+
10
21
  fuc.FefferyCaptcha(id='captcha-demo',
11
22
  charNum=10,
12
23
  width=300,
@@ -53,180 +64,12 @@ app.layout = html.Div(
53
64
  ''',
54
65
  language='python',
55
66
  codeStyle='coy-without-shadows'
56
- ),
57
-
58
- fuc.FefferyMarkdown(
59
- renderHtml=True,
60
- codeStyle='dracula',
61
- markdownStr=r'''
62
-
63
- 这是行内数学公式测试$c = \pm\sqrt{a^2 + b^2}$
64
-
65
- 块公式测试:
66
-
67
- $$
68
-
69
- x = \begin{cases}
70
- a &\text{if } b \\
71
- c &\text{if } d
72
- \end{cases}
73
-
74
- \\
75
-
76
- \begin{bmatrix}
77
- 1&2&\cdots&4\\\
78
- 7&6&\cdots&5\\\
79
- \vdots&\vdots&\ddots&\vdots\\\
80
- 8&9&\cdots&0
81
- \end{bmatrix}
82
-
83
- $$
84
-
85
- ## 代码示例
86
-
87
- ```py
88
- html.Div(
89
- [
90
- fac.AntdBackTop(
91
- containerId='back-top-container-demo',
92
- duration=1
93
- ),
94
- fac.AntdTitle(
95
- '向下滑动一段距离',
96
- level=4
97
- )
98
- ] + [
99
- html.Div(
100
- [
101
- i if i % 2 == 0 else html.Br() for i in range(200)
102
- ]
103
67
  )
104
68
  ],
105
- id='back-top-container-demo',
106
69
  style={
107
- 'maxHeight': '500px',
108
- 'overflowY': 'auto',
109
- 'position': 'relative',
110
- 'backgroundColor': 'rgba(240, 240, 240, 0.2)',
111
- 'padding': '20px'
70
+ 'padding': '100px'
112
71
  }
113
72
  )
114
- ```
115
-
116
- ## 1 最新版本安装方式
117
-
118
- ```bash
119
- pip install feffery-antd-components==0.0.1rc6
120
- ```
121
-
122
- ## 2 最新开发版本安装方式
123
-
124
- ```bash
125
- pip install git+https://github.com/CNFeffery/feffery-antd-components.git
126
- ```
127
-
128
- 国内镜像加速安装方式:
129
-
130
- ```bash
131
- pip install git+https://hub.fastgit.org/CNFeffery/feffery-antd-components.git
132
- ```
133
-
134
- 或:
135
-
136
- ```bash
137
- pip install git+https://github.com.cnpmjs.org/CNFeffery/feffery-antd-components.git
138
- ```
139
-
140
- ## 3 应用部署CDN加速使用方式
141
-
142
- ```Python
143
- # 实例化Dash对象时,设置参数serve_locally=False会强制浏览器端从unpkg加载各个依赖的
144
- # xxx.min.js静态资源,从而避免消耗服务器带宽,适合中小型站点加速用户访问
145
- app = dash.Dash(serve_locally=False)
146
- ```
147
-
148
- ## 4 已实现部件目录
149
-
150
- - [x] 日期选择框:`AntdDatePicker`
151
- - [x] 日期范围选择框:`AntdDateRangePicker`
152
- - [x] 分割线:`AntdDivider`
153
- - [x] 按钮:`AntdButton`
154
- - [x] 下拉选择:`AntdSelect`
155
- - [x] 树形控件:`AntdTree`
156
- - [x] 表格控件:`AntdTable`
157
- - [x] 锚点:`AntdAnchor`
158
- - [x] 穿梭框:`AntdTransfer`
159
- - [x] 滑杆输入:`AntdSlider`
160
- - [x] 步骤条:`AntdSteps`
161
- - [x] 导航菜单:`AntdMenu`
162
- - [x] 折叠面板:`AntdCollapse`
163
- - [x] 栅格系统
164
- - `AntdRow`
165
- - `AntdCol`
166
- - [x] 布局
167
- - `AntdLayout`
168
- - `AntdHeader`
169
- - `AntdContent`
170
- - `AntdFooter`
171
- - `AntdSider`
172
- - [x] 对话框:`AntdModal`
173
- - [x] 警告提示:`AntdAlert`
174
- - [x] 通知提醒框:`AntdNotification`
175
- - [x] 全局提示:`AntdMessage`
176
- - [x] 标签:`AntdTag`
177
- - [x] 结果:`AntdResult`
178
- - [x] 输入框:`AntdInput`
179
- - [x] 文字提示:`AntdTooltip`
180
- - [x] 选择框:`AntdCheckbox`
181
- - [x] 组合选择框:`AntdCheckboxGroup`
182
- - [x] 加载动画:`AntdSpin`
183
- - [x] 开关:`AntdSwitch`
184
- - [x] 排版
185
- - `AntdTypography`
186
- - `AntdParagraph`
187
- - `AntdTitle`
188
- - `AntdText`
189
- - `AntdLink`
190
- - [x] 标签页
191
- - `AntdTabs`
192
- - `AntdTabPane`
193
- - [x] 分页:`AntdPagination`
194
- - [x] 骨架屏:`AntdSkeleton`
195
- - [x] 树选择:`AntdTreeSelect`
196
- - [x] 抽屉:`AntdDrawer`
197
- - [x] 气泡卡片:`AntdPopover`
198
- - [x] 空状态:`AntdEmpty`
199
- - [x] 级联选择:`AntdCascader`
200
- - [x] 单选框:`AntdRadio`
201
- - [x] 上传:`AntdUpload`
202
- - [x] 气泡确认框:`AntdPopconfirm`
203
- - [x] 回到顶部:`AntdBackTop`
204
-
205
- ## 5 在线交互式说明文档
206
-
207
- <a href='http://fac.feffery.tech/' target='_blank'>文档地址</a>(待同步至最新pypi版本)
208
-
209
- ## 6 TODO计划
210
-
211
- - [ ] 表单:`AntdForm`
212
- - [ ] 卡片:`AntdCard`
213
- - [ ] 头像:`AntdAvatar`
214
- - [ ] 徽标数:`AntdBadge`
215
- - [ ] 描述列表:`AntdDescriptions`
216
- - [ ] 评分:`AntdRate`
217
- - [ ] 日历:`AntdCalendar`
218
- - [ ] 走马灯:`AntdCarousel`
219
- - [ ] 评论:`AntdComment`
220
- - [ ] 统计数值:`AntdStatistic`
221
- - [ ] 时间轴:`AntdTimeline`
222
- - [ ] 进度条:`AntdProgress`
223
- - [ ] 回到顶部:`AntdBackTop`
224
- - [ ] 图片:`AntdImage`
225
-
226
- '''
227
- )
228
- ]
229
- )
230
73
 
231
74
 
232
75
  @app.callback(
@@ -243,5 +86,20 @@ def test(captcha):
243
86
  return captcha
244
87
 
245
88
 
89
+ @app.callback(
90
+ Output('test-output', 'children'),
91
+ Input('test', 'currentPastedImages')
92
+ )
93
+ def test_(currentPastedImages):
94
+
95
+ if currentPastedImages:
96
+ return [
97
+ html.Img(
98
+ src=currentPastedImage
99
+ )
100
+ for currentPastedImage in currentPastedImages
101
+ ]
102
+
103
+
246
104
  if __name__ == '__main__':
247
105
  app.run_server(debug=True)
package/.Rbuildignore DELETED
@@ -1,34 +0,0 @@
1
- # ignore JS config files/folders
2
- node_modules/
3
- coverage/
4
- src/
5
- lib/
6
- .babelrc
7
- .builderrc
8
- .eslintrc
9
- .npmignore
10
- .editorconfig
11
- .eslintignore
12
- .prettierrc
13
- .circleci
14
- .github
15
-
16
- # demo folder has special meaning in R
17
- # this should hopefully make it still
18
- # allow for the possibility to make R demos
19
- demo/.*\.js
20
- demo/.*\.html
21
- demo/.*\.css
22
-
23
- # ignore Python files/folders
24
- setup.py
25
- usage.py
26
- setup.py
27
- requirements.txt
28
- MANIFEST.in
29
- CHANGELOG.md
30
- test/
31
- # CRAN has weird LICENSE requirements
32
- LICENSE.txt
33
- ^.*\.Rproj$
34
- ^\.Rproj\.user$
package/.babelrc DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "presets": [
3
- "@babel/preset-env",
4
- "@babel/preset-react"
5
- ]
6
- }
@@ -1,50 +0,0 @@
1
- # AUTO GENERATED FILE - DO NOT EDIT
2
-
3
- from dash.development.base_component import Component, _explicitize_args
4
-
5
-
6
- class FefferyMarkdown(Component):
7
- """A FefferyMarkdown component.
8
-
9
-
10
- Keyword arguments:
11
-
12
- - id (string; optional)
13
-
14
- - codeStyle (string; default 'coy-without-shadows')
15
-
16
- - linkTarget (string; default '_blank')
17
-
18
- - loading_state (dict; optional)
19
-
20
- `loading_state` is a dict with keys:
21
-
22
- - component_name (string; optional):
23
- Holds the name of the component that is loading.
24
-
25
- - is_loading (boolean; optional):
26
- Determines if the component is loading or not.
27
-
28
- - prop_name (string; optional):
29
- Holds which property is loading.
30
-
31
- - markdownStr (string; optional)
32
-
33
- - renderHtml (boolean; optional)"""
34
- @_explicitize_args
35
- def __init__(self, id=Component.UNDEFINED, markdownStr=Component.UNDEFINED, codeStyle=Component.UNDEFINED, renderHtml=Component.UNDEFINED, linkTarget=Component.UNDEFINED, loading_state=Component.UNDEFINED, **kwargs):
36
- self._prop_names = ['id', 'codeStyle', 'linkTarget', 'loading_state', 'markdownStr', 'renderHtml']
37
- self._type = 'FefferyMarkdown'
38
- self._namespace = 'feffery_utils_components'
39
- self._valid_wildcard_attributes = []
40
- self.available_properties = ['id', 'codeStyle', 'linkTarget', 'loading_state', 'markdownStr', 'renderHtml']
41
- self.available_wildcard_properties = []
42
- _explicit_args = kwargs.pop('_explicit_args')
43
- _locals = locals()
44
- _locals.update(kwargs) # For wildcard attrs
45
- args = {k: _locals[k] for k in _explicit_args if k != 'children'}
46
- for k in []:
47
- if k not in args:
48
- raise TypeError(
49
- 'Required argument `' + k + '` was not specified.')
50
- super(FefferyMarkdown, self).__init__(**args)
@@ -1,163 +0,0 @@
1
- import React, { useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import ReactMarkdown from 'react-markdown'
4
- import remarkGfm from 'remark-gfm'
5
- import remarkMath from 'remark-math'
6
- import rehypeKatex from 'rehype-katex'
7
- import rehypeRaw from 'rehype-raw'
8
- import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
9
- import { CopyToClipboard } from "react-copy-to-clipboard";
10
- import { AiOutlineCheck, AiOutlineCopy } from "react-icons/ai";
11
- import {
12
- a11yDark,
13
- atomDark,
14
- coldarkCold,
15
- coldarkDark,
16
- coy,
17
- coyWithoutShadows,
18
- darcula,
19
- dracula,
20
- nord,
21
- okaidia,
22
- prism,
23
- solarizedlight,
24
- twilight
25
- } from 'react-syntax-highlighter/dist/esm/styles/prism';
26
-
27
- import 'katex/dist/katex.min.css'
28
- import 'github-markdown-css'
29
- import './styles.css'
30
-
31
-
32
- // 定义markdown渲染组件FefferyMarkdown,api参数参考https://github.com/remarkjs/react-markdown
33
- const FefferyMarkdown = (props) => {
34
- // 取得必要属性或参数
35
- let {
36
- id,
37
- markdownStr,
38
- codeStyle,
39
- renderHtml,
40
- linkTarget,
41
- setProps
42
- } = props;
43
-
44
- const str2style = new Map([
45
- ['a11y-dark', a11yDark],
46
- ['atom-dark', atomDark],
47
- ['coldark-cold', coldarkCold],
48
- ['coldark-dark', coldarkDark],
49
- ['coy', coy],
50
- ['coy-without-shadows', coyWithoutShadows],
51
- ['darcula', darcula],
52
- ['dracula', dracula],
53
- ['nord', nord],
54
- ['okaidia', okaidia],
55
- ['prism', prism],
56
- ['solarizedlight', solarizedlight],
57
- ['twilight', twilight]
58
- ])
59
-
60
- return (
61
- <div className='markdown-body' style={{ marginBottom: '10px' }}>
62
- <ReactMarkdown id={id}
63
- linkTarget={linkTarget}
64
- remarkPlugins={[remarkGfm, remarkMath]}
65
- rehypePlugins={renderHtml ? [rehypeRaw, rehypeKatex] : [rehypeKatex]}
66
- components={{
67
- code: ({ node, inline, className, children, ...props }) => {
68
- const [isCopied, setIsCopied] = useState(false);
69
- const match = /language-(\w+)/.exec(className || '')
70
- return !inline && match ? (
71
- <div style={{ position: 'relative' }}>
72
- <CopyToClipboard
73
- onCopy={() => {
74
- setIsCopied(true);
75
- setTimeout(() => setIsCopied(false), 1500);
76
- }}
77
- style={
78
- {
79
- position: 'absolute',
80
- right: '5px',
81
- top: '5px',
82
- padding: '6px',
83
- margin: 0,
84
- background: 'transparent',
85
- border: 'none transparent',
86
- cursor: 'pointer',
87
- zIndex: 999
88
- }
89
- }
90
- text={String(children).replace(/\n$/, '')}
91
- >
92
- <button type="button" aria-label="Copy to Clipboard Button">
93
- {isCopied ? <AiOutlineCheck style={{ color: 'rgb(91, 199, 38)', fontSize: '18px' }} />
94
- : <AiOutlineCopy style={{ color: 'rgb(24, 144, 255)', fontSize: '18px' }} />}
95
- </button>
96
- </CopyToClipboard>
97
- <SyntaxHighlighter
98
- children={String(children).replace(/\n$/, '')}
99
- style={str2style.get(codeStyle)}
100
- showLineNumbers={true}
101
- language={match[1]}
102
- PreTag="div"
103
- {...props} />
104
- </div>
105
- ) : (
106
- <code className={className} {...props}>
107
- {children}
108
- </code>
109
- )
110
- }
111
- }}>
112
- {markdownStr}
113
- </ReactMarkdown>
114
- </div>
115
- );
116
- }
117
-
118
- // 定义参数或属性
119
- FefferyMarkdown.propTypes = {
120
- // 部件id
121
- id: PropTypes.string,
122
-
123
- // 设置要渲染的原始markdown内容
124
- markdownStr: PropTypes.string,
125
-
126
- // 设置代码风格,默认为'coy-without-shadows'
127
- codeStyle: PropTypes.string,
128
-
129
- // 设置是否渲染markdown中的html源码,默认为false
130
- renderHtml: PropTypes.bool,
131
-
132
- // 设置markdown中链接的跳转方式,默认为'_blank'
133
- linkTarget: PropTypes.string,
134
-
135
- loading_state: PropTypes.shape({
136
- /**
137
- * Determines if the component is loading or not
138
- */
139
- is_loading: PropTypes.bool,
140
- /**
141
- * Holds which property is loading
142
- */
143
- prop_name: PropTypes.string,
144
- /**
145
- * Holds the name of the component that is loading
146
- */
147
- component_name: PropTypes.string
148
- }),
149
-
150
- /**
151
- * Dash-assigned callback that should be called to report property changes
152
- * to Dash, to make them available for callbacks.
153
- */
154
- setProps: PropTypes.func
155
- };
156
-
157
- // 设置默认参数
158
- FefferyMarkdown.defaultProps = {
159
- linkTarget: '_blank',
160
- codeStyle: 'coy-without-shadows'
161
- }
162
-
163
- export default FefferyMarkdown;