@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.
Files changed (147) hide show
  1. package/dist/index.esm.css +60 -1
  2. package/es/ProAction/index.js +7 -5
  3. package/es/ProConfigProvider/index.js +6 -1
  4. package/es/ProDownload/utils.js +4 -3
  5. package/es/ProDrawerForm/components/ProDrawer/index.js +6 -4
  6. package/es/ProDrawerForm/index.js +4 -4
  7. package/es/ProEditTable/components/ActionButton/index.js +3 -2
  8. package/es/ProEditTable/components/RenderField/index.js +2 -1
  9. package/es/ProEditTable/index.js +7 -6
  10. package/es/ProEditTable/utils/config.d.ts +8 -8
  11. package/es/ProEditTable/utils/config.js +9 -8
  12. package/es/ProEditTable/utils/index.js +3 -2
  13. package/es/ProEnum/hooks/useEnumRequest.js +17 -10
  14. package/es/ProEnum/index.js +9 -4
  15. package/es/ProForm/components/FormFooter/index.js +16 -20
  16. package/es/ProForm/components/base/Input/index.js +4 -3
  17. package/es/ProForm/components/base/InputNumber/index.js +4 -3
  18. package/es/ProForm/components/base/Select/index.js +2 -1
  19. package/es/ProForm/components/base/Switch/index.js +9 -5
  20. package/es/ProForm/components/base/SwitchCheckbox/index.js +2 -1
  21. package/es/ProForm/components/base/TextArea/index.js +4 -2
  22. package/es/ProForm/components/combination/FormList/components/ActionButton.js +13 -17
  23. package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +2 -1
  24. package/es/ProForm/components/combination/Group/index.js +2 -2
  25. package/es/ProForm/components/combination/ProAddressBar/index.js +5 -5
  26. package/es/ProForm/components/combination/ProModalSelect/index.js +3 -4
  27. package/es/ProForm/components/combination/ProNumberRange/index.js +3 -2
  28. package/es/ProForm/components/combination/ProRangeLimit/index.js +3 -7
  29. package/es/ProForm/components/combination/ProTimeLimit/index.js +4 -11
  30. package/es/ProForm/components/combination/ProTimeLimit/style/index.less +17 -0
  31. package/es/ProForm/components/render/Render.js +4 -2
  32. package/es/ProForm/components/render/RenderFields.js +6 -4
  33. package/es/ProForm/index.js +14 -2
  34. package/es/ProForm/style/index.less +65 -35
  35. package/es/ProForm/utils/index.d.ts +1 -1
  36. package/es/ProForm/utils/index.js +7 -2
  37. package/es/ProForm/utils/rulesCreator.js +2 -1
  38. package/es/ProForm/utils/useRules.js +4 -3
  39. package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +6 -0
  40. package/es/ProLayout/components/Layout/Notice/index.js +3 -2
  41. package/es/ProLayout/components/ProHeader/components/Copy/index.js +2 -1
  42. package/es/ProLayout/components/ProHeader/components/ProBackBtn/index.js +2 -1
  43. package/es/ProLayout/components/ProHeader/index.js +5 -4
  44. package/es/ProLayout/utils/index.js +1 -1
  45. package/es/ProSelect/index.d.ts +3 -3
  46. package/es/ProSelect/index.js +4 -2
  47. package/es/ProStep/components/Step/index.js +3 -1
  48. package/es/ProTable/index.js +7 -6
  49. package/es/ProTable/useAntdTable.d.ts +12 -4
  50. package/es/ProTable/useAntdTable.js +18 -6
  51. package/es/ProTree/components/ProTree.js +5 -4
  52. package/es/ProTree/components/Tree.js +3 -1
  53. package/es/ProTreeModal/components/List.js +0 -14
  54. package/es/ProTreeModal/components/Trigger.js +9 -3
  55. package/es/ProTreeModal/index.js +29 -13
  56. package/es/ProUpload/components/ButtonRender.js +5 -2
  57. package/es/ProUpload/components/DragRender.js +8 -8
  58. package/es/ProUpload/components/Example.js +3 -1
  59. package/es/ProUpload/components/ImageRender.js +8 -6
  60. package/es/ProUpload/index.js +8 -6
  61. package/es/locale/en_US.d.ts +123 -54
  62. package/es/locale/en_US.js +130 -61
  63. package/es/locale/index.d.ts +6 -0
  64. package/es/locale/index.js +11 -0
  65. package/es/locale/zh_CN.d.ts +122 -54
  66. package/es/locale/zh_CN.js +128 -60
  67. package/es/style/core/normalize.less +0 -1
  68. package/lib/ProAction/index.js +7 -5
  69. package/lib/ProConfigProvider/index.js +6 -1
  70. package/lib/ProDownload/utils.js +4 -3
  71. package/lib/ProDrawerForm/components/ProDrawer/index.js +6 -4
  72. package/lib/ProDrawerForm/index.js +4 -4
  73. package/lib/ProEditTable/components/ActionButton/index.js +3 -2
  74. package/lib/ProEditTable/components/RenderField/index.js +2 -1
  75. package/lib/ProEditTable/index.js +7 -6
  76. package/lib/ProEditTable/utils/config.d.ts +8 -8
  77. package/lib/ProEditTable/utils/config.js +9 -8
  78. package/lib/ProEditTable/utils/index.js +3 -2
  79. package/lib/ProEnum/hooks/useEnumRequest.js +17 -10
  80. package/lib/ProEnum/index.js +9 -4
  81. package/lib/ProForm/components/FormFooter/index.js +16 -19
  82. package/lib/ProForm/components/base/Input/index.js +4 -3
  83. package/lib/ProForm/components/base/InputNumber/index.js +4 -3
  84. package/lib/ProForm/components/base/Select/index.js +2 -1
  85. package/lib/ProForm/components/base/Switch/index.js +8 -5
  86. package/lib/ProForm/components/base/SwitchCheckbox/index.js +2 -1
  87. package/lib/ProForm/components/base/TextArea/index.js +4 -2
  88. package/lib/ProForm/components/combination/FormList/components/ActionButton.js +13 -17
  89. package/lib/ProForm/components/combination/FormList/components/ToolbarButton.js +2 -1
  90. package/lib/ProForm/components/combination/Group/index.js +2 -2
  91. package/lib/ProForm/components/combination/ProAddressBar/index.js +5 -5
  92. package/lib/ProForm/components/combination/ProModalSelect/index.js +3 -4
  93. package/lib/ProForm/components/combination/ProNumberRange/index.js +3 -2
  94. package/lib/ProForm/components/combination/ProRangeLimit/index.js +3 -7
  95. package/lib/ProForm/components/combination/ProTimeLimit/index.js +4 -11
  96. package/lib/ProForm/components/combination/ProTimeLimit/style/index.less +17 -0
  97. package/lib/ProForm/components/render/Render.js +4 -2
  98. package/lib/ProForm/components/render/RenderFields.js +5 -3
  99. package/lib/ProForm/index.js +14 -2
  100. package/lib/ProForm/style/index.less +65 -35
  101. package/lib/ProForm/utils/index.d.ts +1 -1
  102. package/lib/ProForm/utils/index.js +7 -2
  103. package/lib/ProForm/utils/rulesCreator.js +2 -1
  104. package/lib/ProForm/utils/useRules.js +4 -3
  105. package/lib/ProLayout/components/Layout/Menu/OpenMenu/index.js +6 -0
  106. package/lib/ProLayout/components/Layout/Notice/index.js +3 -2
  107. package/lib/ProLayout/components/ProHeader/components/Copy/index.js +2 -1
  108. package/lib/ProLayout/components/ProHeader/components/ProBackBtn/index.js +3 -1
  109. package/lib/ProLayout/components/ProHeader/index.js +5 -4
  110. package/lib/ProLayout/utils/index.js +1 -1
  111. package/lib/ProSelect/index.d.ts +3 -3
  112. package/lib/ProSelect/index.js +4 -2
  113. package/lib/ProStep/components/Step/index.js +3 -1
  114. package/lib/ProTable/index.js +7 -6
  115. package/lib/ProTable/useAntdTable.d.ts +12 -4
  116. package/lib/ProTable/useAntdTable.js +19 -6
  117. package/lib/ProTree/components/ProTree.js +5 -4
  118. package/lib/ProTree/components/Tree.js +3 -1
  119. package/lib/ProTreeModal/components/List.js +0 -14
  120. package/lib/ProTreeModal/components/Trigger.js +10 -3
  121. package/lib/ProTreeModal/index.js +29 -13
  122. package/lib/ProUpload/components/ButtonRender.js +5 -2
  123. package/lib/ProUpload/components/DragRender.js +8 -8
  124. package/lib/ProUpload/components/Example.js +3 -1
  125. package/lib/ProUpload/components/ImageRender.js +8 -6
  126. package/lib/ProUpload/index.js +8 -6
  127. package/lib/locale/en_US.d.ts +123 -54
  128. package/lib/locale/en_US.js +130 -61
  129. package/lib/locale/index.d.ts +6 -0
  130. package/lib/locale/index.js +14 -1
  131. package/lib/locale/zh_CN.d.ts +122 -54
  132. package/lib/locale/zh_CN.js +128 -60
  133. package/lib/style/core/normalize.less +0 -1
  134. package/package.json +1 -1
  135. package/.dumi/theme/builtins/Alert.tsx +0 -19
  136. package/.dumi/theme/builtins/Previewer.tsx +0 -232
  137. package/.dumi/theme/builtins/SourceCode.tsx +0 -64
  138. package/.dumi/theme/hooks/useCodeSandbox.tsx +0 -197
  139. package/.dumi/theme/hooks/useTheme.tsx +0 -707
  140. package/.dumi/theme/layouts/BasicLayout.tsx +0 -88
  141. package/.dumi/theme/layouts/components/Dark.less +0 -157
  142. package/.dumi/theme/layouts/components/Dark.tsx +0 -78
  143. package/.dumi/theme/layouts/components/Navbar.tsx +0 -83
  144. package/.dumi/theme/layouts/components/SideMenu.tsx +0 -61
  145. package/.dumi/theme/layouts/index.tsx +0 -26
  146. package/.dumi/theme/layouts/layout.less +0 -87
  147. package/.dumi/theme/typings.d.ts +0 -7
@@ -5,70 +5,138 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _default = exports.default = {
8
- common: {
8
+ ProDrawerForm: {
9
9
  save: '保存',
10
- cancel: '取消'
10
+ confirm: '确定',
11
+ cancel: '取消',
12
+ isSureClose: '确认关闭当前页面',
13
+ secondTipsWhenSave: '关闭当前页面内容不会被保存,需要点击“保存”按钮进行保存'
11
14
  },
12
- demo: {
13
- openDrawer: '打开抽屉',
14
- openModal: '打开弹框'
15
+ ProLayout: {
16
+ tipAlt: '提示',
17
+ closeAlt: '关闭'
15
18
  },
16
- search: {
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
- collapsed: '展开',
20
- expand: '收起'
21
- },
22
- dialog: {
23
- modeAdd: '新增',
24
- modeUpdate: '编辑',
25
- modeDetail: '详情',
26
- modeCustom: '自定义',
27
- close: '关闭',
28
- confirm: '确定'
29
- },
30
- extra: {
31
- refresh: '刷新',
32
- density: '密度',
33
- densityLarger: '默认',
34
- densityMiddle: '中等',
35
- densitySmall: '紧凑',
36
- fullScreen: '全屏',
37
- exitFullScreen: '退出全屏',
38
- moveUp: '上移',
39
- moveDown: '下移',
40
- rename: '请输入别名',
41
- columnSetting: '设置展示列'
42
- },
43
- action: {
44
- success: '成功',
45
- deleteConfirm: '你确定要删除此行吗?',
46
- deleteSuccess: '删除成功',
47
- noSelection: '请选择一条数据',
48
- deleteConfirmTitle: '确定',
49
- deleteConfirmBefore: '您勾选了',
50
- deleteConfirmAfter: '个,确定要删除吗?',
51
- deleteConfirmBatchSuccess: '批量删除成功'
52
- },
53
- tagGroup: {
54
- all: '全部'
55
- },
56
- table: {
57
- totalBefore: '',
58
- totalAfter: '',
59
- selectedTitle: '已经选中的选项',
60
- selectedBefore: '已选择:',
61
- selectedAfter: '',
62
- selectedClear: '清空'
63
- },
64
- form: {
65
- pleaseInput: '请输入',
66
- pleaseInputAfter: '',
67
- pleaseSelect: '请选择',
68
- pleaseSelectAfter: '',
69
- requiredText: '',
70
- startDate: '开始日期',
71
- endDate: '结束日期',
72
- dateTo: ''
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
  };
@@ -223,7 +223,6 @@ samp {
223
223
  }
224
224
 
225
225
  .clickable,
226
- label,
227
226
  input[type='button'],
228
227
  input[type='submit'],
229
228
  input[type='file'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.1.5-beta.9",
3
+ "version": "3.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -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
- }