@zat-design/sisyphus-react 3.1.5-beta.9 → 3.2.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.
- package/dist/index.esm.css +60 -1
- package/es/ProAction/index.js +7 -5
- package/es/ProConfigProvider/index.js +6 -1
- package/es/ProDownload/utils.js +4 -3
- package/es/ProDrawerForm/components/ProDrawer/index.js +6 -4
- package/es/ProDrawerForm/index.js +4 -4
- package/es/ProEditTable/components/ActionButton/index.js +3 -2
- package/es/ProEditTable/components/RenderField/index.js +2 -1
- package/es/ProEditTable/index.js +7 -6
- package/es/ProEditTable/utils/config.d.ts +8 -8
- package/es/ProEditTable/utils/config.js +9 -8
- package/es/ProEditTable/utils/index.js +3 -2
- package/es/ProEnum/hooks/useEnumRequest.js +17 -10
- package/es/ProEnum/index.js +9 -4
- package/es/ProForm/components/FormFooter/index.js +16 -20
- package/es/ProForm/components/base/Input/index.js +4 -3
- package/es/ProForm/components/base/InputNumber/index.js +4 -3
- package/es/ProForm/components/base/Select/index.js +2 -1
- package/es/ProForm/components/base/Switch/index.js +9 -5
- package/es/ProForm/components/base/SwitchCheckbox/index.js +2 -1
- package/es/ProForm/components/base/TextArea/index.js +4 -2
- package/es/ProForm/components/combination/FormList/components/ActionButton.js +13 -17
- package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +2 -1
- package/es/ProForm/components/combination/Group/index.js +2 -2
- package/es/ProForm/components/combination/ProAddressBar/index.js +5 -5
- package/es/ProForm/components/combination/ProModalSelect/index.js +3 -4
- package/es/ProForm/components/combination/ProNumberRange/index.js +3 -2
- package/es/ProForm/components/combination/ProRangeLimit/index.js +3 -7
- package/es/ProForm/components/combination/ProTimeLimit/index.js +4 -11
- package/es/ProForm/components/combination/ProTimeLimit/style/index.less +17 -0
- package/es/ProForm/components/render/Render.js +4 -2
- package/es/ProForm/components/render/RenderFields.js +6 -4
- package/es/ProForm/index.js +14 -2
- package/es/ProForm/style/index.less +65 -35
- package/es/ProForm/utils/index.d.ts +1 -1
- package/es/ProForm/utils/index.js +7 -2
- package/es/ProForm/utils/rulesCreator.js +2 -1
- package/es/ProForm/utils/useRules.js +4 -3
- package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +6 -0
- package/es/ProLayout/components/Layout/Notice/index.js +3 -2
- package/es/ProLayout/components/ProHeader/components/Copy/index.js +2 -1
- package/es/ProLayout/components/ProHeader/components/ProBackBtn/index.js +2 -1
- package/es/ProLayout/components/ProHeader/index.js +5 -4
- package/es/ProLayout/utils/index.js +1 -1
- package/es/ProSelect/index.d.ts +3 -3
- package/es/ProSelect/index.js +4 -2
- package/es/ProStep/components/Step/index.js +3 -1
- package/es/ProTable/index.js +7 -6
- package/es/ProTable/useAntdTable.d.ts +12 -4
- package/es/ProTable/useAntdTable.js +18 -6
- package/es/ProTree/components/ProTree.js +5 -4
- package/es/ProTree/components/Tree.js +3 -1
- package/es/ProTreeModal/components/List.js +0 -14
- package/es/ProTreeModal/components/Trigger.js +9 -3
- package/es/ProTreeModal/index.js +29 -13
- package/es/ProUpload/components/ButtonRender.js +5 -2
- package/es/ProUpload/components/DragRender.js +8 -8
- package/es/ProUpload/components/Example.js +3 -1
- package/es/ProUpload/components/ImageRender.js +8 -6
- package/es/ProUpload/index.js +8 -6
- package/es/locale/en_US.d.ts +123 -54
- package/es/locale/en_US.js +130 -61
- package/es/locale/index.d.ts +6 -0
- package/es/locale/index.js +11 -0
- package/es/locale/zh_CN.d.ts +122 -54
- package/es/locale/zh_CN.js +128 -60
- package/es/style/core/normalize.less +0 -1
- package/lib/ProAction/index.js +7 -5
- package/lib/ProConfigProvider/index.js +6 -1
- package/lib/ProDownload/utils.js +4 -3
- package/lib/ProDrawerForm/components/ProDrawer/index.js +6 -4
- package/lib/ProDrawerForm/index.js +4 -4
- package/lib/ProEditTable/components/ActionButton/index.js +3 -2
- package/lib/ProEditTable/components/RenderField/index.js +2 -1
- package/lib/ProEditTable/index.js +7 -6
- package/lib/ProEditTable/utils/config.d.ts +8 -8
- package/lib/ProEditTable/utils/config.js +9 -8
- package/lib/ProEditTable/utils/index.js +3 -2
- package/lib/ProEnum/hooks/useEnumRequest.js +17 -10
- package/lib/ProEnum/index.js +9 -4
- package/lib/ProForm/components/FormFooter/index.js +16 -19
- package/lib/ProForm/components/base/Input/index.js +4 -3
- package/lib/ProForm/components/base/InputNumber/index.js +4 -3
- package/lib/ProForm/components/base/Select/index.js +2 -1
- package/lib/ProForm/components/base/Switch/index.js +8 -5
- package/lib/ProForm/components/base/SwitchCheckbox/index.js +2 -1
- package/lib/ProForm/components/base/TextArea/index.js +4 -2
- package/lib/ProForm/components/combination/FormList/components/ActionButton.js +13 -17
- package/lib/ProForm/components/combination/FormList/components/ToolbarButton.js +2 -1
- package/lib/ProForm/components/combination/Group/index.js +2 -2
- package/lib/ProForm/components/combination/ProAddressBar/index.js +5 -5
- package/lib/ProForm/components/combination/ProModalSelect/index.js +3 -4
- package/lib/ProForm/components/combination/ProNumberRange/index.js +3 -2
- package/lib/ProForm/components/combination/ProRangeLimit/index.js +3 -7
- package/lib/ProForm/components/combination/ProTimeLimit/index.js +4 -11
- package/lib/ProForm/components/combination/ProTimeLimit/style/index.less +17 -0
- package/lib/ProForm/components/render/Render.js +4 -2
- package/lib/ProForm/components/render/RenderFields.js +5 -3
- package/lib/ProForm/index.js +14 -2
- package/lib/ProForm/style/index.less +65 -35
- package/lib/ProForm/utils/index.d.ts +1 -1
- package/lib/ProForm/utils/index.js +7 -2
- package/lib/ProForm/utils/rulesCreator.js +2 -1
- package/lib/ProForm/utils/useRules.js +4 -3
- package/lib/ProLayout/components/Layout/Menu/OpenMenu/index.js +6 -0
- package/lib/ProLayout/components/Layout/Notice/index.js +3 -2
- package/lib/ProLayout/components/ProHeader/components/Copy/index.js +2 -1
- package/lib/ProLayout/components/ProHeader/components/ProBackBtn/index.js +3 -1
- package/lib/ProLayout/components/ProHeader/index.js +5 -4
- package/lib/ProLayout/utils/index.js +1 -1
- package/lib/ProSelect/index.d.ts +3 -3
- package/lib/ProSelect/index.js +4 -2
- package/lib/ProStep/components/Step/index.js +3 -1
- package/lib/ProTable/index.js +7 -6
- package/lib/ProTable/useAntdTable.d.ts +12 -4
- package/lib/ProTable/useAntdTable.js +19 -6
- package/lib/ProTree/components/ProTree.js +5 -4
- package/lib/ProTree/components/Tree.js +3 -1
- package/lib/ProTreeModal/components/List.js +0 -14
- package/lib/ProTreeModal/components/Trigger.js +10 -3
- package/lib/ProTreeModal/index.js +29 -13
- package/lib/ProUpload/components/ButtonRender.js +5 -2
- package/lib/ProUpload/components/DragRender.js +8 -8
- package/lib/ProUpload/components/Example.js +3 -1
- package/lib/ProUpload/components/ImageRender.js +8 -6
- package/lib/ProUpload/index.js +8 -6
- package/lib/locale/en_US.d.ts +123 -54
- package/lib/locale/en_US.js +130 -61
- package/lib/locale/index.d.ts +6 -0
- package/lib/locale/index.js +14 -1
- package/lib/locale/zh_CN.d.ts +122 -54
- package/lib/locale/zh_CN.js +128 -60
- package/lib/style/core/normalize.less +0 -1
- package/package.json +1 -1
- package/.dumi/theme/builtins/Alert.tsx +0 -19
- package/.dumi/theme/builtins/Previewer.tsx +0 -232
- package/.dumi/theme/builtins/SourceCode.tsx +0 -64
- package/.dumi/theme/hooks/useCodeSandbox.tsx +0 -197
- package/.dumi/theme/hooks/useTheme.tsx +0 -707
- package/.dumi/theme/layouts/BasicLayout.tsx +0 -88
- package/.dumi/theme/layouts/components/Dark.less +0 -157
- package/.dumi/theme/layouts/components/Dark.tsx +0 -78
- package/.dumi/theme/layouts/components/Navbar.tsx +0 -83
- package/.dumi/theme/layouts/components/SideMenu.tsx +0 -61
- package/.dumi/theme/layouts/index.tsx +0 -26
- package/.dumi/theme/layouts/layout.less +0 -87
- package/.dumi/theme/typings.d.ts +0 -7
package/lib/locale/zh_CN.js
CHANGED
|
@@ -5,70 +5,138 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _default = exports.default = {
|
|
8
|
-
|
|
8
|
+
ProDrawerForm: {
|
|
9
9
|
save: '保存',
|
|
10
|
-
|
|
10
|
+
confirm: '确定',
|
|
11
|
+
cancel: '取消',
|
|
12
|
+
isSureClose: '确认关闭当前页面',
|
|
13
|
+
secondTipsWhenSave: '关闭当前页面内容不会被保存,需要点击“保存”按钮进行保存'
|
|
11
14
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
ProLayout: {
|
|
16
|
+
tipAlt: '提示',
|
|
17
|
+
closeAlt: '关闭'
|
|
15
18
|
},
|
|
16
|
-
|
|
19
|
+
ProHeader: {
|
|
20
|
+
versionTitle: '版本号',
|
|
21
|
+
confirmTitle: '确认返回?',
|
|
22
|
+
confirm: '确定',
|
|
23
|
+
cancel: '取消',
|
|
24
|
+
backText: '返回',
|
|
25
|
+
copyTooltips: ['复制', '复制成功']
|
|
26
|
+
},
|
|
27
|
+
ProDownload: {
|
|
28
|
+
errorMessage: '请求失败!'
|
|
29
|
+
},
|
|
30
|
+
ProForm: {
|
|
31
|
+
unfold: '展开',
|
|
32
|
+
packUp: '收起',
|
|
33
|
+
inputPlaceholder: '请输入',
|
|
34
|
+
selectPlaceHolder: '请选择',
|
|
35
|
+
switchText: ['是', '否'],
|
|
17
36
|
search: '查询',
|
|
18
37
|
reset: '重置',
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
38
|
+
ruleText: '正确的',
|
|
39
|
+
completeText: '请完整输入',
|
|
40
|
+
formList_actions: ['新增', '删除', '复制', '上移', '下移', '新增一行'],
|
|
41
|
+
formList_confirmMessage: '确认删除吗?'
|
|
42
|
+
},
|
|
43
|
+
ProAction: {
|
|
44
|
+
errorMessage: 'ProAction 配置 config 必须为数据',
|
|
45
|
+
defaultTitle: '确认删除吗?'
|
|
46
|
+
},
|
|
47
|
+
ProWaterMark: {},
|
|
48
|
+
ProTable: {
|
|
49
|
+
noData: '暂无数据',
|
|
50
|
+
resetColumnWidth: '重置列宽',
|
|
51
|
+
customColumns: '自定义列',
|
|
52
|
+
transformResponseMsg: '请返回正确的数据类型',
|
|
53
|
+
deselect: '取消选择',
|
|
54
|
+
selectCurPage: '选择当前页({total}条)',
|
|
55
|
+
selectAll: '选择全部({total}条)',
|
|
56
|
+
hasSelected: '已选 {selectedNum} 条数据',
|
|
57
|
+
total: '共{total}条'
|
|
58
|
+
},
|
|
59
|
+
ProAddressBar: {
|
|
60
|
+
placeholder: '请选择',
|
|
61
|
+
detailPlaceholder: '请输入详细地址'
|
|
62
|
+
},
|
|
63
|
+
ProTree: {
|
|
64
|
+
inputPlaceholder: '请输入',
|
|
65
|
+
unExpand: '全部收起',
|
|
66
|
+
expand: '全部展开',
|
|
67
|
+
all: '全选',
|
|
68
|
+
emptyTips: '诶呀,没有找到您要查询的内容'
|
|
69
|
+
},
|
|
70
|
+
ProUpload: {
|
|
71
|
+
exampleTitle: '查看示例',
|
|
72
|
+
errorInfoExt: '文件格式只支持',
|
|
73
|
+
errorInfoSize: '上传的文件不能超过',
|
|
74
|
+
buttonText: '上传文件',
|
|
75
|
+
draggerSelect: '重新选择',
|
|
76
|
+
draggerDelete: '删除',
|
|
77
|
+
draggerTips: '将文件拖拽到此处,或点击上传',
|
|
78
|
+
draggerBtnTxt: '点击上传',
|
|
79
|
+
draggerFileExt: '支持扩展名',
|
|
80
|
+
draggerLimitless: '无限制',
|
|
81
|
+
view: '查看',
|
|
82
|
+
delete: '删除',
|
|
83
|
+
download: '下载'
|
|
84
|
+
},
|
|
85
|
+
ProStep: {
|
|
86
|
+
catalogue: '目录'
|
|
87
|
+
},
|
|
88
|
+
ProEditTable: {
|
|
89
|
+
confirm: '确定',
|
|
90
|
+
cancel: '取消',
|
|
91
|
+
select: '请选择',
|
|
92
|
+
enter: '请输入',
|
|
93
|
+
add: '添加',
|
|
94
|
+
edit: '编辑',
|
|
95
|
+
copy: '复制',
|
|
96
|
+
delete: '删除',
|
|
97
|
+
mulDelete: '删除',
|
|
98
|
+
save: '保存',
|
|
99
|
+
custom: '自定义',
|
|
100
|
+
operation: '操作',
|
|
101
|
+
noData: '暂无数据',
|
|
102
|
+
clickAdd: '点击添加',
|
|
103
|
+
onlyOneLineMsg: '请先保存数据',
|
|
104
|
+
deletePoConfirmMsg: '您确定要删除该行数据吗?',
|
|
105
|
+
mulDeletePoConfirmMsg: '您确定要删除选中的数据吗?'
|
|
106
|
+
},
|
|
107
|
+
ProModalSelect: {
|
|
108
|
+
checkMsg: '请先勾选',
|
|
109
|
+
select: '请选择'
|
|
110
|
+
},
|
|
111
|
+
ProSelect: {
|
|
112
|
+
checkMsg: '请先勾选',
|
|
113
|
+
select: '请选择'
|
|
114
|
+
},
|
|
115
|
+
ProEnum: {
|
|
116
|
+
errorDataSource: '请传入有效的数据源',
|
|
117
|
+
errorMessage: '请返回正确的数据类型',
|
|
118
|
+
errorArrayMessage: '请返回有效的数组',
|
|
119
|
+
errorNoEnumType: '请传入枚举类型',
|
|
120
|
+
mainInitByRequest: '主应用初始化触发从接口读取数据更新',
|
|
121
|
+
mainInitByCache: '主应用初始化触发从缓存读取数据更新',
|
|
122
|
+
requestError: '请求失败',
|
|
123
|
+
mainInitOnce: '主应用初始化触发一次',
|
|
124
|
+
sonInitEvent: '子应用初始化监听动作'
|
|
125
|
+
},
|
|
126
|
+
ProTreeModal: {
|
|
127
|
+
checkMsg: '请先勾选',
|
|
128
|
+
select: '请选择',
|
|
129
|
+
input: '请输入',
|
|
130
|
+
errorArrayMessage: '请返回有效的数组',
|
|
131
|
+
selectMin: '最少选择{min}个',
|
|
132
|
+
selectMax: '最多选择{max}个',
|
|
133
|
+
noCheck: '暂无已选',
|
|
134
|
+
checkAll: '全选',
|
|
135
|
+
check: '已选',
|
|
136
|
+
clearAll: '清空全部',
|
|
137
|
+
checkNumber: '已选择{num}项'
|
|
138
|
+
},
|
|
139
|
+
ProTimeLimit: {
|
|
140
|
+
foreverText: '长期'
|
|
73
141
|
}
|
|
74
142
|
};
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { InfoCircleFilled } from '@ant-design/icons'
|
|
3
|
-
|
|
4
|
-
export default function MyAlert(props: any) {
|
|
5
|
-
return (
|
|
6
|
-
<span
|
|
7
|
-
style={{
|
|
8
|
-
display: 'block',
|
|
9
|
-
backgroundColor: '#e6f7ff',
|
|
10
|
-
border: '1px solid #91d5ff',
|
|
11
|
-
borderRadius: 2,
|
|
12
|
-
padding: '8px 15px'
|
|
13
|
-
}}
|
|
14
|
-
>
|
|
15
|
-
<InfoCircleFilled style={{ color: '#1890ff', marginRight: 8 }} />
|
|
16
|
-
{props.children}
|
|
17
|
-
</span>
|
|
18
|
-
)
|
|
19
|
-
}
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import React, { useState, useContext, useRef, useEffect } from 'react'
|
|
2
|
-
import Tabs, { TabPane } from 'rc-tabs'
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
import { history } from 'dumi'
|
|
5
|
-
import { IPreviewerComponentProps } from 'dumi/theme'
|
|
6
|
-
import {
|
|
7
|
-
context,
|
|
8
|
-
useRiddle,
|
|
9
|
-
useMotions,
|
|
10
|
-
useCopy,
|
|
11
|
-
useLocaleProps,
|
|
12
|
-
useDemoUrl,
|
|
13
|
-
useTSPlaygroundUrl,
|
|
14
|
-
Link,
|
|
15
|
-
AnchorLink,
|
|
16
|
-
usePrefersColor
|
|
17
|
-
} from 'dumi/theme'
|
|
18
|
-
import { ICodeBlockProps } from './SourceCode'
|
|
19
|
-
import SourceCode from './SourceCode'
|
|
20
|
-
import 'dumi-theme-default/src/builtins/Previewer.less'
|
|
21
|
-
import useCodeSandbox from '../hooks/useCodeSandbox'
|
|
22
|
-
|
|
23
|
-
export interface IPreviewerProps extends IPreviewerComponentProps {
|
|
24
|
-
/**
|
|
25
|
-
* enable transform to change CSS containing block for demo
|
|
26
|
-
*/
|
|
27
|
-
transform?: boolean
|
|
28
|
-
/**
|
|
29
|
-
* modify background for demo area
|
|
30
|
-
*/
|
|
31
|
-
background?: string
|
|
32
|
-
/**
|
|
33
|
-
* collapse padding of demo area
|
|
34
|
-
*/
|
|
35
|
-
compact?: boolean
|
|
36
|
-
/**
|
|
37
|
-
* configurations for action button
|
|
38
|
-
*/
|
|
39
|
-
hideActions?: ('CSB' | 'EXTERNAL' | 'RIDDLE')[]
|
|
40
|
-
/**
|
|
41
|
-
* show source code by default
|
|
42
|
-
*/
|
|
43
|
-
defaultShowCode?: boolean
|
|
44
|
-
/**
|
|
45
|
-
* use iframe mode for this demo
|
|
46
|
-
*/
|
|
47
|
-
iframe?: true | number
|
|
48
|
-
/**
|
|
49
|
-
* replace builtin demo url
|
|
50
|
-
*/
|
|
51
|
-
demoUrl?: string
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* get source code type for file
|
|
56
|
-
* @param file file path
|
|
57
|
-
* @param source file source object
|
|
58
|
-
*/
|
|
59
|
-
function getSourceType(file: string, source: IPreviewerComponentProps['sources']['_']) {
|
|
60
|
-
// use file extension as source type first
|
|
61
|
-
let type = file.match(/\.(\w+)$/)?.[1]
|
|
62
|
-
|
|
63
|
-
if (!type) {
|
|
64
|
-
type = source.tsx ? 'tsx' : 'jsx'
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return type as ICodeBlockProps['lang']
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const Previewer: React.FC<IPreviewerProps> = oProps => {
|
|
71
|
-
const demoRef = useRef()
|
|
72
|
-
const { locale } = useContext(context)
|
|
73
|
-
const props = useLocaleProps<IPreviewerProps>(locale, oProps)
|
|
74
|
-
const builtinDemoUrl = useDemoUrl(props.identifier)
|
|
75
|
-
const demoUrl = props.demoUrl || builtinDemoUrl
|
|
76
|
-
const isActive = history?.location.hash === `#${props.identifier}`
|
|
77
|
-
const isSingleFile = Object.keys(props.sources).length === 1
|
|
78
|
-
const openCSB = useCodeSandbox(props.hideActions?.includes('CSB') ? null : props)
|
|
79
|
-
const openRiddle = useRiddle(props.hideActions?.includes('RIDDLE') ? null : props)
|
|
80
|
-
const [execMotions, isMotionRunning] = useMotions(props.motions || [], demoRef.current)
|
|
81
|
-
const [copyCode, copyStatus] = useCopy()
|
|
82
|
-
const [currentFile, setCurrentFile] = useState('_')
|
|
83
|
-
const [sourceType, setSourceType] = useState(getSourceType(currentFile, props.sources[currentFile]))
|
|
84
|
-
const [showSource, setShowSource] = useState(Boolean(props.defaultShowCode))
|
|
85
|
-
const [iframeKey, setIframeKey] = useState(Math.random())
|
|
86
|
-
const currentFileCode = props.sources[currentFile][sourceType] || props.sources[currentFile].content
|
|
87
|
-
const playgroundUrl = useTSPlaygroundUrl(locale, currentFileCode)
|
|
88
|
-
const iframeRef = useRef<HTMLIFrameElement>()
|
|
89
|
-
const [color] = usePrefersColor()
|
|
90
|
-
|
|
91
|
-
// re-render iframe if prefers color changed
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
setIframeKey(Math.random())
|
|
94
|
-
}, [color])
|
|
95
|
-
|
|
96
|
-
function handleFileChange(filename: string) {
|
|
97
|
-
setCurrentFile(filename)
|
|
98
|
-
setSourceType(getSourceType(filename, props.sources[filename]))
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<div
|
|
103
|
-
style={props.style}
|
|
104
|
-
className={[props.className, '__dumi-default-previewer', isActive ? '__dumi-default-previewer-target' : '']
|
|
105
|
-
.filter(Boolean)
|
|
106
|
-
.join(' ')}
|
|
107
|
-
id={props.identifier}
|
|
108
|
-
data-debug={props.debug || undefined}
|
|
109
|
-
data-iframe={props.iframe || undefined}
|
|
110
|
-
>
|
|
111
|
-
{props.iframe && <div className="__dumi-default-previewer-browser-nav" />}
|
|
112
|
-
<div
|
|
113
|
-
ref={demoRef}
|
|
114
|
-
className="__dumi-default-previewer-demo"
|
|
115
|
-
style={{
|
|
116
|
-
transform: props.transform ? 'translate(0, 0)' : undefined,
|
|
117
|
-
padding: props.compact || (props.iframe && props.compact !== false) ? '0' : undefined,
|
|
118
|
-
background: props.background
|
|
119
|
-
}}
|
|
120
|
-
>
|
|
121
|
-
{props.iframe ? (
|
|
122
|
-
<iframe
|
|
123
|
-
title="dumi-previewer"
|
|
124
|
-
style={{
|
|
125
|
-
// both compatible with unit or non-unit, such as 100, 100px, 100vh
|
|
126
|
-
height: String(props.iframe).replace(/(\d)$/, '$1px')
|
|
127
|
-
}}
|
|
128
|
-
key={iframeKey}
|
|
129
|
-
src={demoUrl}
|
|
130
|
-
ref={iframeRef}
|
|
131
|
-
/>
|
|
132
|
-
) : (
|
|
133
|
-
props.children
|
|
134
|
-
)}
|
|
135
|
-
</div>
|
|
136
|
-
<div className="__dumi-default-previewer-desc" data-title={props.title}>
|
|
137
|
-
{props.title && <AnchorLink to={`#${props.identifier}`}>{props.title}</AnchorLink>}
|
|
138
|
-
{props.description && (
|
|
139
|
-
<div
|
|
140
|
-
// eslint-disable-next-line
|
|
141
|
-
dangerouslySetInnerHTML={{ __html: props.description }}
|
|
142
|
-
/>
|
|
143
|
-
)}
|
|
144
|
-
</div>
|
|
145
|
-
<div className="__dumi-default-previewer-actions">
|
|
146
|
-
{openCSB && (
|
|
147
|
-
<button
|
|
148
|
-
title="Open demo on CodeSandbox.io"
|
|
149
|
-
className="__dumi-default-icon"
|
|
150
|
-
role="codesandbox"
|
|
151
|
-
onClick={openCSB}
|
|
152
|
-
/>
|
|
153
|
-
)}
|
|
154
|
-
{openRiddle && (
|
|
155
|
-
<button title="Open demo on Riddle" className="__dumi-default-icon" role="riddle" onClick={openRiddle} />
|
|
156
|
-
)}
|
|
157
|
-
{props.motions && (
|
|
158
|
-
<button
|
|
159
|
-
title="Execute motions"
|
|
160
|
-
className="__dumi-default-icon"
|
|
161
|
-
role="motions"
|
|
162
|
-
disabled={isMotionRunning}
|
|
163
|
-
onClick={() => execMotions()}
|
|
164
|
-
/>
|
|
165
|
-
)}
|
|
166
|
-
{props.iframe && (
|
|
167
|
-
<button
|
|
168
|
-
title="Reload demo iframe page"
|
|
169
|
-
className="__dumi-default-icon"
|
|
170
|
-
role="refresh"
|
|
171
|
-
onClick={() => setIframeKey(Math.random())}
|
|
172
|
-
/>
|
|
173
|
-
)}
|
|
174
|
-
{!props.hideActions?.includes('EXTERNAL') && (
|
|
175
|
-
<Link target="_blank" to={demoUrl}>
|
|
176
|
-
<button title="Open demo in new tab" className="__dumi-default-icon" role="open-demo" type="button" />
|
|
177
|
-
</Link>
|
|
178
|
-
)}
|
|
179
|
-
<span />
|
|
180
|
-
<button
|
|
181
|
-
title="Copy source code"
|
|
182
|
-
className="__dumi-default-icon"
|
|
183
|
-
role="copy"
|
|
184
|
-
data-status={copyStatus}
|
|
185
|
-
onClick={() => copyCode(currentFileCode)}
|
|
186
|
-
/>
|
|
187
|
-
{sourceType === 'tsx' && showSource && (
|
|
188
|
-
<Link target="_blank" to={playgroundUrl}>
|
|
189
|
-
<button
|
|
190
|
-
title="Get JSX via TypeScript Playground"
|
|
191
|
-
className="__dumi-default-icon"
|
|
192
|
-
role="change-tsx"
|
|
193
|
-
type="button"
|
|
194
|
-
/>
|
|
195
|
-
</Link>
|
|
196
|
-
)}
|
|
197
|
-
<button
|
|
198
|
-
title="Toggle source code panel"
|
|
199
|
-
className={`__dumi-default-icon${showSource ? ' __dumi-default-btn-expand' : ''}`}
|
|
200
|
-
role="source"
|
|
201
|
-
type="button"
|
|
202
|
-
onClick={() => setShowSource(!showSource)}
|
|
203
|
-
/>
|
|
204
|
-
</div>
|
|
205
|
-
{showSource && (
|
|
206
|
-
<div className="__dumi-default-previewer-source-wrapper">
|
|
207
|
-
{!isSingleFile && (
|
|
208
|
-
<Tabs
|
|
209
|
-
className="__dumi-default-previewer-source-tab"
|
|
210
|
-
prefixCls="__dumi-default-tabs"
|
|
211
|
-
moreIcon="···"
|
|
212
|
-
defaultActiveKey={currentFile}
|
|
213
|
-
onChange={handleFileChange}
|
|
214
|
-
>
|
|
215
|
-
{Object.keys(props.sources).map(filename => (
|
|
216
|
-
<TabPane
|
|
217
|
-
tab={filename === '_' ? `index.${getSourceType(filename, props.sources[filename])}` : filename}
|
|
218
|
-
key={filename}
|
|
219
|
-
/>
|
|
220
|
-
))}
|
|
221
|
-
</Tabs>
|
|
222
|
-
)}
|
|
223
|
-
<div className="__dumi-default-previewer-source">
|
|
224
|
-
<SourceCode code={currentFileCode} lang={sourceType} showCopy={false} />
|
|
225
|
-
</div>
|
|
226
|
-
</div>
|
|
227
|
-
)}
|
|
228
|
-
</div>
|
|
229
|
-
)
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export default Previewer
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
// import styled from 'styled-components'
|
|
3
|
-
import { Language } from 'prism-react-renderer'
|
|
4
|
-
import Highlight, { defaultProps } from 'prism-react-renderer'
|
|
5
|
-
import { useCopy } from 'dumi/theme'
|
|
6
|
-
import 'prismjs/themes/prism.css'
|
|
7
|
-
import 'dumi-theme-default/src/builtins/SourceCode.less'
|
|
8
|
-
|
|
9
|
-
export interface ICodeBlockProps {
|
|
10
|
-
code: string
|
|
11
|
-
lang: Language
|
|
12
|
-
showCopy?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// const Line = styled.div`
|
|
16
|
-
// display: table-row;
|
|
17
|
-
// `
|
|
18
|
-
|
|
19
|
-
// const LineNo = styled.span`
|
|
20
|
-
// display: table-cell;
|
|
21
|
-
// text-align: right;
|
|
22
|
-
// padding-right: 1em;
|
|
23
|
-
// min-width: 4em;
|
|
24
|
-
// user-select: none;
|
|
25
|
-
// opacity: 0.5;
|
|
26
|
-
// `
|
|
27
|
-
|
|
28
|
-
// const LineContent = styled.span`
|
|
29
|
-
// display: table-cell;
|
|
30
|
-
// `
|
|
31
|
-
|
|
32
|
-
export default ({ code, lang, showCopy = true }: ICodeBlockProps) => {
|
|
33
|
-
const [copyCode, copyStatus] = useCopy()
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<div className="__dumi-default-code-block">
|
|
37
|
-
<Highlight {...defaultProps} code={code} language={lang} theme={undefined}>
|
|
38
|
-
{({ className, style, tokens, getLineProps, getTokenProps }) => (
|
|
39
|
-
<pre className={className} style={style}>
|
|
40
|
-
{showCopy && (
|
|
41
|
-
<button
|
|
42
|
-
className="__dumi-default-icon __dumi-default-code-block-copy-btn"
|
|
43
|
-
data-status={copyStatus}
|
|
44
|
-
onClick={() => copyCode(code)}
|
|
45
|
-
/>
|
|
46
|
-
)}
|
|
47
|
-
{tokens.map((line, i) => (
|
|
48
|
-
<div {...getLineProps({ line, key: i })}>
|
|
49
|
-
<div key={i} {...getLineProps({ line, key: i })}>
|
|
50
|
-
{/* <div>{i + 1}</div> */}
|
|
51
|
-
<div>
|
|
52
|
-
{line.map((token, key) => (
|
|
53
|
-
<span key={key} {...getTokenProps({ token, key })} />
|
|
54
|
-
))}
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
))}
|
|
59
|
-
</pre>
|
|
60
|
-
)}
|
|
61
|
-
</Highlight>
|
|
62
|
-
</div>
|
|
63
|
-
)
|
|
64
|
-
}
|