@oceanbase/ui 0.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/static/iconfont.22caa259.woff +0 -0
- package/dist/static/iconfont.bf41d69a.woff2 +0 -0
- package/dist/static/iconfont.d8ca098f.ttf +0 -0
- package/dist/ui.min.css +1 -0
- package/dist/ui.min.js +1 -0
- package/es/Action/Group.d.ts +14 -0
- package/es/Action/Group.js +112 -0
- package/es/Action/Item.d.ts +31 -0
- package/es/Action/Item.js +136 -0
- package/es/Action/index.d.ts +8 -0
- package/es/Action/index.js +7 -0
- package/es/BackgroundTaskManager/RefreshMan.d.ts +11 -0
- package/es/BackgroundTaskManager/RefreshMan.js +66 -0
- package/es/BackgroundTaskManager/constants.js +10 -0
- package/es/BackgroundTaskManager/index.d.ts +49 -0
- package/es/BackgroundTaskManager/index.js +155 -0
- package/es/BasicLayout/Header.d.ts +45 -0
- package/es/BasicLayout/Header.js +228 -0
- package/es/BasicLayout/Header.less +134 -0
- package/es/BasicLayout/index.d.ts +45 -0
- package/es/BasicLayout/index.js +312 -0
- package/es/BasicLayout/index.less +400 -0
- package/es/BasicLayout/locale/en-US.js +11 -0
- package/es/BasicLayout/locale/zh-CN.js +11 -0
- package/es/BasicLayout/locale/zh-TW.js +11 -0
- package/es/BatchOperationBar/index.d.ts +33 -0
- package/es/BatchOperationBar/index.js +126 -0
- package/es/BatchOperationBar/index.less +46 -0
- package/es/BatchOperationBar/index.less.d.ts +15 -0
- package/es/BatchOperationBar/locale/en-US.js +6 -0
- package/es/BatchOperationBar/locale/zh-CN.js +6 -0
- package/es/BatchOperationBar/locale/zh-TW.js +6 -0
- package/es/Boundary/Components/Code.d.ts +14 -0
- package/es/Boundary/Components/Code.js +32 -0
- package/es/Boundary/Components/Exception.d.ts +17 -0
- package/es/Boundary/Components/Exception.js +129 -0
- package/es/Boundary/Components/Function.d.ts +9 -0
- package/es/Boundary/Components/Function.js +21 -0
- package/es/Boundary/Components/index.d.ts +3 -0
- package/es/Boundary/Components/index.js +3 -0
- package/es/Boundary/IBoundary.js +1 -0
- package/es/Boundary/constant.js +41 -0
- package/es/Boundary/index.d.ts +8 -0
- package/es/Boundary/index.js +7 -0
- package/es/Boundary/index.less +44 -0
- package/es/Boundary/locale/en-US.js +10 -0
- package/es/Boundary/locale/zh-CN.js +10 -0
- package/es/Boundary/locale/zh-TW.js +10 -0
- package/es/Boundary/utils.js +18 -0
- package/es/ContentWithQuestion/index.d.ts +13 -0
- package/es/ContentWithQuestion/index.js +46 -0
- package/es/ContentWithQuestion/index.less +18 -0
- package/es/Dialog/Anchor.js +104 -0
- package/es/Dialog/Dock.js +84 -0
- package/es/Dialog/EventProxy.js +50 -0
- package/es/Dialog/index.d.ts +35 -0
- package/es/Dialog/index.js +614 -0
- package/es/Dialog/index.less +114 -0
- package/es/Dialog/locale/en-US.js +4 -0
- package/es/Dialog/locale/zh-CN.js +4 -0
- package/es/Dialog/locale/zh-TW.js +4 -0
- package/es/DocDialog/index.d.ts +24 -0
- package/es/DocDialog/index.js +115 -0
- package/es/DocDialog/locale/en-US.js +1 -0
- package/es/DocDialog/locale/zh-CN.js +1 -0
- package/es/DocDialog/locale/zh-TW.js +1 -0
- package/es/FullscreenBox/index.d.ts +42 -0
- package/es/FullscreenBox/index.js +145 -0
- package/es/FullscreenBox/index.less +49 -0
- package/es/FullscreenBox/locale/en-US.js +1 -0
- package/es/FullscreenBox/locale/zh-CN.js +1 -0
- package/es/FullscreenBox/locale/zh-TW.js +1 -0
- package/es/GraphToolbar/index.d.ts +26 -0
- package/es/GraphToolbar/index.js +132 -0
- package/es/GraphToolbar/index.less +65 -0
- package/es/GraphToolbar/locale/en-US.js +8 -0
- package/es/GraphToolbar/locale/zh-CN.js +8 -0
- package/es/GraphToolbar/locale/zh-TW.js +8 -0
- package/es/Highlight/DiffView/DiffCells.js +43 -0
- package/es/Highlight/DiffView/index.d.ts +44 -0
- package/es/Highlight/DiffView/index.js +317 -0
- package/es/Highlight/HighlightCell.js +29 -0
- package/es/Highlight/JsonView.d.ts +8 -0
- package/es/Highlight/JsonView.js +44 -0
- package/es/Highlight/index.d.ts +97 -0
- package/es/Highlight/index.js +257 -0
- package/es/Highlight/index.less +381 -0
- package/es/Highlight/languages/bash.js +2 -0
- package/es/Highlight/languages/cpp.js +2 -0
- package/es/Highlight/languages/css.js +2 -0
- package/es/Highlight/languages/dockerfile.js +2 -0
- package/es/Highlight/languages/go.js +2 -0
- package/es/Highlight/languages/groovy.js +2 -0
- package/es/Highlight/languages/http.js +2 -0
- package/es/Highlight/languages/java.js +2 -0
- package/es/Highlight/languages/javascript.js +2 -0
- package/es/Highlight/languages/json.js +2 -0
- package/es/Highlight/languages/markdown.js +2 -0
- package/es/Highlight/languages/nginx.js +2 -0
- package/es/Highlight/languages/python.js +2 -0
- package/es/Highlight/languages/ruby.js +2 -0
- package/es/Highlight/languages/solidity.js +2 -0
- package/es/Highlight/languages/sql.js +2 -0
- package/es/Highlight/languages/typescript.js +2 -0
- package/es/Highlight/languages/xml.js +2 -0
- package/es/Highlight/languages/yaml.js +2 -0
- package/es/Highlight/locale/en-US.js +1 -0
- package/es/Highlight/locale/zh-CN.js +1 -0
- package/es/Highlight/locale/zh-TW.js +1 -0
- package/es/Highlight/useKeyDownCopyEvent.js +54 -0
- package/es/IconFont/font/iconfont.css +503 -0
- package/es/IconFont/font/iconfont.ttf +0 -0
- package/es/IconFont/font/iconfont.woff +0 -0
- package/es/IconFont/font/iconfont.woff2 +0 -0
- package/es/IconFont/index.d.ts +9 -0
- package/es/IconFont/index.js +26 -0
- package/es/LocaleDropdown/index.d.ts +9 -0
- package/es/LocaleDropdown/index.js +47 -0
- package/es/Login/ActivateForm.d.ts +19 -0
- package/es/Login/ActivateForm.js +98 -0
- package/es/Login/LoginForm.d.ts +20 -0
- package/es/Login/LoginForm.js +142 -0
- package/es/Login/RegisterForm.d.ts +23 -0
- package/es/Login/RegisterForm.js +155 -0
- package/es/Login/index.d.ts +66 -0
- package/es/Login/index.js +177 -0
- package/es/Login/index.less +325 -0
- package/es/Login/locale/en-US.js +26 -0
- package/es/Login/locale/zh-CN.js +27 -0
- package/es/Login/locale/zh-TW.js +26 -0
- package/es/Lottie/index.js +37 -0
- package/es/NavMenu/index.d.ts +19 -0
- package/es/NavMenu/index.js +99 -0
- package/es/NavMenu/index.less +50 -0
- package/es/PageContainer/ItemRender.js +21 -0
- package/es/PageContainer/index.d.ts +16 -0
- package/es/PageContainer/index.js +71 -0
- package/es/PageContainer/locale/en-US.js +3 -0
- package/es/PageContainer/locale/zh-CN.js +3 -0
- package/es/PageContainer/locale/zh-TW.js +3 -0
- package/es/PageContainer/style/index.d.ts +5 -0
- package/es/PageContainer/style/index.js +72 -0
- package/es/Password/Content.d.ts +14 -0
- package/es/Password/Content.js +92 -0
- package/es/Password/index.d.ts +25 -0
- package/es/Password/index.js +137 -0
- package/es/Password/locale/en-US.js +12 -0
- package/es/Password/locale/zh-CN.js +12 -0
- package/es/Password/locale/zh-TW.js +12 -0
- package/es/Ranger/QuickPicker.d.ts +4 -0
- package/es/Ranger/QuickPicker.js +123 -0
- package/es/Ranger/Ranger.d.ts +11 -0
- package/es/Ranger/Ranger.js +140 -0
- package/es/Ranger/constant/index.js +187 -0
- package/es/Ranger/index.d.ts +33 -0
- package/es/Ranger/index.js +32 -0
- package/es/Ranger/index.less +55 -0
- package/es/Ranger/locale/en-US.js +29 -0
- package/es/Ranger/locale/zh-CN.js +3 -0
- package/es/Ranger/locale/zh-TW.js +3 -0
- package/es/Ranger/typing.js +1 -0
- package/es/SideTip/Dragger.d.ts +45 -0
- package/es/SideTip/Dragger.js +293 -0
- package/es/SideTip/IconLoading.d.ts +3 -0
- package/es/SideTip/IconLoading.js +37 -0
- package/es/SideTip/index.d.ts +156 -0
- package/es/SideTip/index.js +177 -0
- package/es/SideTip/index.less +177 -0
- package/es/SideTip/locale/en-US.js +1 -0
- package/es/SideTip/locale/zh-CN.js +1 -0
- package/es/SideTip/locale/zh-TW.js +1 -0
- package/es/SideTip/utils.js +80 -0
- package/es/TaskGraph/Graph.d.ts +24 -0
- package/es/TaskGraph/Graph.js +260 -0
- package/es/TaskGraph/graph.less +23 -0
- package/es/TaskGraph/index.d.ts +16 -0
- package/es/TaskGraph/index.js +165 -0
- package/es/TaskGraph/index.less +117 -0
- package/es/TaskGraph/locale/en-US.js +12 -0
- package/es/TaskGraph/locale/zh-CN.js +12 -0
- package/es/TaskGraph/locale/zh-TW.js +12 -0
- package/es/TaskGraph/register.d.ts +7 -0
- package/es/TaskGraph/register.js +200 -0
- package/es/TreeSearch/index.d.ts +38 -0
- package/es/TreeSearch/index.js +168 -0
- package/es/TreeSearch/util.d.ts +21 -0
- package/es/TreeSearch/util.js +111 -0
- package/es/Welcome/index.d.ts +38 -0
- package/es/Welcome/index.js +140 -0
- package/es/Welcome/index.less +186 -0
- package/es/Welcome/locale/en-US.js +4 -0
- package/es/Welcome/locale/zh-CN.js +4 -0
- package/es/Welcome/locale/zh-TW.js +4 -0
- package/es/Welcome/step.d.ts +18 -0
- package/es/Welcome/step.js +42 -0
- package/es/_util/genComponentStyleHook.d.ts +14 -0
- package/es/_util/genComponentStyleHook.js +27 -0
- package/es/_util/index.js +54 -0
- package/es/_util/useHistory.js +9 -0
- package/es/assets/background_img.svg +30 -0
- package/es/assets/graph_fit_view_icon.svg +14 -0
- package/es/assets/graph_reset_icon.svg +14 -0
- package/es/assets/logo/oceanbase_logo.svg +29 -0
- package/es/assets/logo/oceanbase_watermark.svg +31 -0
- package/es/assets/monitor.svg +21 -0
- package/es/assets/user.svg +16 -0
- package/es/constant/index.js +18 -0
- package/es/index.d.ts +28 -0
- package/es/index.js +27 -0
- package/es/index.less +14 -0
- package/es/interface.js +1 -0
- package/es/locale/LocaleWrapper.d.ts +10 -0
- package/es/locale/LocaleWrapper.js +69 -0
- package/es/locale/en-US.js +38 -0
- package/es/locale/index.js +1 -0
- package/es/locale/zh-CN.js +39 -0
- package/es/locale/zh-TW.js +33 -0
- package/es/variable.less +54 -0
- package/lib/Action/Group.d.ts +14 -0
- package/lib/Action/Group.js +124 -0
- package/lib/Action/Item.d.ts +31 -0
- package/lib/Action/Item.js +126 -0
- package/lib/Action/index.d.ts +8 -0
- package/lib/Action/index.js +37 -0
- package/lib/BackgroundTaskManager/RefreshMan.d.ts +11 -0
- package/lib/BackgroundTaskManager/RefreshMan.js +86 -0
- package/lib/BackgroundTaskManager/constants.js +38 -0
- package/lib/BackgroundTaskManager/index.d.ts +49 -0
- package/lib/BackgroundTaskManager/index.js +161 -0
- package/lib/BasicLayout/Header.d.ts +45 -0
- package/lib/BasicLayout/Header.js +177 -0
- package/lib/BasicLayout/Header.less +134 -0
- package/lib/BasicLayout/index.d.ts +45 -0
- package/lib/BasicLayout/index.js +346 -0
- package/lib/BasicLayout/index.less +400 -0
- package/lib/BasicLayout/locale/en-US.js +35 -0
- package/lib/BasicLayout/locale/zh-CN.js +35 -0
- package/lib/BasicLayout/locale/zh-TW.js +35 -0
- package/lib/BatchOperationBar/index.d.ts +33 -0
- package/lib/BatchOperationBar/index.js +165 -0
- package/lib/BatchOperationBar/index.less +46 -0
- package/lib/BatchOperationBar/index.less.d.ts +15 -0
- package/lib/BatchOperationBar/locale/en-US.js +30 -0
- package/lib/BatchOperationBar/locale/zh-CN.js +30 -0
- package/lib/BatchOperationBar/locale/zh-TW.js +30 -0
- package/lib/Boundary/Components/Code.d.ts +14 -0
- package/lib/Boundary/Components/Code.js +55 -0
- package/lib/Boundary/Components/Exception.d.ts +17 -0
- package/lib/Boundary/Components/Exception.js +114 -0
- package/lib/Boundary/Components/Function.d.ts +9 -0
- package/lib/Boundary/Components/Function.js +47 -0
- package/lib/Boundary/Components/index.d.ts +3 -0
- package/lib/Boundary/Components/index.js +27 -0
- package/lib/Boundary/IBoundary.js +17 -0
- package/lib/Boundary/constant.js +71 -0
- package/lib/Boundary/index.d.ts +8 -0
- package/lib/Boundary/index.js +27 -0
- package/lib/Boundary/index.less +44 -0
- package/lib/Boundary/locale/en-US.js +34 -0
- package/lib/Boundary/locale/zh-CN.js +34 -0
- package/lib/Boundary/locale/zh-TW.js +34 -0
- package/lib/Boundary/utils.js +46 -0
- package/lib/ContentWithQuestion/index.d.ts +13 -0
- package/lib/ContentWithQuestion/index.js +76 -0
- package/lib/ContentWithQuestion/index.less +18 -0
- package/lib/Dialog/Anchor.js +107 -0
- package/lib/Dialog/Dock.js +112 -0
- package/lib/Dialog/EventProxy.js +59 -0
- package/lib/Dialog/index.d.ts +35 -0
- package/lib/Dialog/index.js +558 -0
- package/lib/Dialog/index.less +114 -0
- package/lib/Dialog/locale/en-US.js +28 -0
- package/lib/Dialog/locale/zh-CN.js +28 -0
- package/lib/Dialog/locale/zh-TW.js +28 -0
- package/lib/DocDialog/index.d.ts +24 -0
- package/lib/DocDialog/index.js +135 -0
- package/lib/DocDialog/locale/en-US.js +25 -0
- package/lib/DocDialog/locale/zh-CN.js +25 -0
- package/lib/DocDialog/locale/zh-TW.js +25 -0
- package/lib/FullscreenBox/index.d.ts +42 -0
- package/lib/FullscreenBox/index.js +126 -0
- package/lib/FullscreenBox/index.less +49 -0
- package/lib/FullscreenBox/locale/en-US.js +25 -0
- package/lib/FullscreenBox/locale/zh-CN.js +25 -0
- package/lib/FullscreenBox/locale/zh-TW.js +25 -0
- package/lib/GraphToolbar/index.d.ts +26 -0
- package/lib/GraphToolbar/index.js +154 -0
- package/lib/GraphToolbar/index.less +65 -0
- package/lib/GraphToolbar/locale/en-US.js +32 -0
- package/lib/GraphToolbar/locale/zh-CN.js +32 -0
- package/lib/GraphToolbar/locale/zh-TW.js +32 -0
- package/lib/Highlight/DiffView/DiffCells.js +70 -0
- package/lib/Highlight/DiffView/index.d.ts +44 -0
- package/lib/Highlight/DiffView/index.js +297 -0
- package/lib/Highlight/HighlightCell.js +58 -0
- package/lib/Highlight/JsonView.d.ts +8 -0
- package/lib/Highlight/JsonView.js +83 -0
- package/lib/Highlight/index.d.ts +97 -0
- package/lib/Highlight/index.js +263 -0
- package/lib/Highlight/index.less +381 -0
- package/lib/Highlight/languages/bash.js +36 -0
- package/lib/Highlight/languages/cpp.js +36 -0
- package/lib/Highlight/languages/css.js +36 -0
- package/lib/Highlight/languages/dockerfile.js +36 -0
- package/lib/Highlight/languages/go.js +36 -0
- package/lib/Highlight/languages/groovy.js +36 -0
- package/lib/Highlight/languages/http.js +36 -0
- package/lib/Highlight/languages/java.js +36 -0
- package/lib/Highlight/languages/javascript.js +36 -0
- package/lib/Highlight/languages/json.js +36 -0
- package/lib/Highlight/languages/markdown.js +36 -0
- package/lib/Highlight/languages/nginx.js +36 -0
- package/lib/Highlight/languages/python.js +36 -0
- package/lib/Highlight/languages/ruby.js +36 -0
- package/lib/Highlight/languages/solidity.js +36 -0
- package/lib/Highlight/languages/sql.js +36 -0
- package/lib/Highlight/languages/typescript.js +36 -0
- package/lib/Highlight/languages/xml.js +36 -0
- package/lib/Highlight/languages/yaml.js +36 -0
- package/lib/Highlight/locale/en-US.js +25 -0
- package/lib/Highlight/locale/zh-CN.js +25 -0
- package/lib/Highlight/locale/zh-TW.js +25 -0
- package/lib/Highlight/useKeyDownCopyEvent.js +86 -0
- package/lib/IconFont/font/iconfont.css +503 -0
- package/lib/IconFont/font/iconfont.ttf +0 -0
- package/lib/IconFont/font/iconfont.woff +0 -0
- package/lib/IconFont/font/iconfont.woff2 +0 -0
- package/lib/IconFont/index.d.ts +9 -0
- package/lib/IconFont/index.js +82 -0
- package/lib/LocaleDropdown/index.d.ts +9 -0
- package/lib/LocaleDropdown/index.js +70 -0
- package/lib/Login/ActivateForm.d.ts +19 -0
- package/lib/Login/ActivateForm.js +132 -0
- package/lib/Login/LoginForm.d.ts +20 -0
- package/lib/Login/LoginForm.js +175 -0
- package/lib/Login/RegisterForm.d.ts +23 -0
- package/lib/Login/RegisterForm.js +177 -0
- package/lib/Login/index.d.ts +66 -0
- package/lib/Login/index.js +171 -0
- package/lib/Login/index.less +325 -0
- package/lib/Login/locale/en-US.js +50 -0
- package/lib/Login/locale/zh-CN.js +51 -0
- package/lib/Login/locale/zh-TW.js +50 -0
- package/lib/Lottie/index.js +62 -0
- package/lib/NavMenu/index.d.ts +19 -0
- package/lib/NavMenu/index.js +104 -0
- package/lib/NavMenu/index.less +50 -0
- package/lib/PageContainer/ItemRender.js +51 -0
- package/lib/PageContainer/index.d.ts +16 -0
- package/lib/PageContainer/index.js +88 -0
- package/lib/PageContainer/locale/en-US.js +27 -0
- package/lib/PageContainer/locale/zh-CN.js +27 -0
- package/lib/PageContainer/locale/zh-TW.js +27 -0
- package/lib/PageContainer/style/index.d.ts +5 -0
- package/lib/PageContainer/style/index.js +120 -0
- package/lib/Password/Content.d.ts +14 -0
- package/lib/Password/Content.js +106 -0
- package/lib/Password/index.d.ts +25 -0
- package/lib/Password/index.js +162 -0
- package/lib/Password/locale/en-US.js +36 -0
- package/lib/Password/locale/zh-CN.js +36 -0
- package/lib/Password/locale/zh-TW.js +36 -0
- package/lib/Ranger/QuickPicker.d.ts +4 -0
- package/lib/Ranger/QuickPicker.js +106 -0
- package/lib/Ranger/Ranger.d.ts +11 -0
- package/lib/Ranger/Ranger.js +153 -0
- package/lib/Ranger/constant/index.js +268 -0
- package/lib/Ranger/index.d.ts +33 -0
- package/lib/Ranger/index.js +64 -0
- package/lib/Ranger/index.less +55 -0
- package/lib/Ranger/locale/en-US.js +53 -0
- package/lib/Ranger/locale/zh-CN.js +27 -0
- package/lib/Ranger/locale/zh-TW.js +27 -0
- package/lib/Ranger/typing.js +17 -0
- package/lib/SideTip/Dragger.d.ts +45 -0
- package/lib/SideTip/Dragger.js +259 -0
- package/lib/SideTip/IconLoading.d.ts +3 -0
- package/lib/SideTip/IconLoading.js +75 -0
- package/lib/SideTip/index.d.ts +156 -0
- package/lib/SideTip/index.js +182 -0
- package/lib/SideTip/index.less +177 -0
- package/lib/SideTip/locale/en-US.js +25 -0
- package/lib/SideTip/locale/zh-CN.js +25 -0
- package/lib/SideTip/locale/zh-TW.js +25 -0
- package/lib/SideTip/utils.js +112 -0
- package/lib/TaskGraph/Graph.d.ts +24 -0
- package/lib/TaskGraph/Graph.js +259 -0
- package/lib/TaskGraph/graph.less +23 -0
- package/lib/TaskGraph/index.d.ts +16 -0
- package/lib/TaskGraph/index.js +163 -0
- package/lib/TaskGraph/index.less +117 -0
- package/lib/TaskGraph/locale/en-US.js +36 -0
- package/lib/TaskGraph/locale/zh-CN.js +36 -0
- package/lib/TaskGraph/locale/zh-TW.js +36 -0
- package/lib/TaskGraph/register.d.ts +7 -0
- package/lib/TaskGraph/register.js +205 -0
- package/lib/TreeSearch/index.d.ts +38 -0
- package/lib/TreeSearch/index.js +135 -0
- package/lib/TreeSearch/util.d.ts +21 -0
- package/lib/TreeSearch/util.js +110 -0
- package/lib/Welcome/index.d.ts +38 -0
- package/lib/Welcome/index.js +102 -0
- package/lib/Welcome/index.less +186 -0
- package/lib/Welcome/locale/en-US.js +28 -0
- package/lib/Welcome/locale/zh-CN.js +28 -0
- package/lib/Welcome/locale/zh-TW.js +28 -0
- package/lib/Welcome/step.d.ts +18 -0
- package/lib/Welcome/step.js +51 -0
- package/lib/_util/genComponentStyleHook.d.ts +14 -0
- package/lib/_util/genComponentStyleHook.js +58 -0
- package/lib/_util/index.js +67 -0
- package/lib/_util/useHistory.js +30 -0
- package/lib/assets/background_img.svg +30 -0
- package/lib/assets/graph_fit_view_icon.svg +14 -0
- package/lib/assets/graph_reset_icon.svg +14 -0
- package/lib/assets/logo/oceanbase_logo.svg +29 -0
- package/lib/assets/logo/oceanbase_watermark.svg +31 -0
- package/lib/assets/monitor.svg +21 -0
- package/lib/assets/user.svg +16 -0
- package/lib/constant/index.js +51 -0
- package/lib/index.d.ts +28 -0
- package/lib/index.js +115 -0
- package/lib/index.less +14 -0
- package/lib/interface.js +17 -0
- package/lib/locale/LocaleWrapper.d.ts +10 -0
- package/lib/locale/LocaleWrapper.js +69 -0
- package/lib/locale/en-US.js +67 -0
- package/lib/locale/index.js +17 -0
- package/lib/locale/zh-CN.js +68 -0
- package/lib/locale/zh-TW.js +62 -0
- package/lib/variable.less +54 -0
- package/package.json +70 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { FullscreenOutlined, MinusOutlined, PlusOutlined, SyncOutlined } from '@ant-design/icons';
|
|
8
|
+
import { toPercent } from '@oceanbase/util';
|
|
9
|
+
import { Divider, Space, Tooltip } from '@oceanbase/design';
|
|
10
|
+
import { debounce } from 'lodash';
|
|
11
|
+
import React, { useEffect, useState } from 'react';
|
|
12
|
+
import LocaleWrapper from "../locale/LocaleWrapper";
|
|
13
|
+
import { getPrefix } from "../_util";
|
|
14
|
+
import zhCN from "./locale/zh-CN";
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
import fitViewIcon from "../assets/graph_fit_view_icon.svg";
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
import resetIcon from "../assets/graph_reset_icon.svg";
|
|
19
|
+
import "./index.less";
|
|
20
|
+
export function getCenterPointByGraph(graph) {
|
|
21
|
+
var group = graph === null || graph === void 0 ? void 0 : graph.get('group');
|
|
22
|
+
if (group) {
|
|
23
|
+
var _group$getCanvasBBox = group.getCanvasBBox(),
|
|
24
|
+
minX = _group$getCanvasBBox.minX,
|
|
25
|
+
minY = _group$getCanvasBBox.minY,
|
|
26
|
+
maxX = _group$getCanvasBBox.maxX,
|
|
27
|
+
maxY = _group$getCanvasBBox.maxY;
|
|
28
|
+
return {
|
|
29
|
+
x: (minX + maxX) / 2,
|
|
30
|
+
y: (minY + maxY) / 2
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// 默认返回 undefined,这样传入 G6 时会使用默认的参数值
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
var prefix = getPrefix('graph-toolbar');
|
|
37
|
+
var GraphToolbar = function GraphToolbar(_ref) {
|
|
38
|
+
var _ref$mode = _ref.mode,
|
|
39
|
+
mode = _ref$mode === void 0 ? 'fixed' : _ref$mode,
|
|
40
|
+
graph = _ref.graph,
|
|
41
|
+
showFullscreen = _ref.showFullscreen,
|
|
42
|
+
onFullscreen = _ref.onFullscreen,
|
|
43
|
+
onReload = _ref.onReload,
|
|
44
|
+
locale = _ref.locale,
|
|
45
|
+
className = _ref.className;
|
|
46
|
+
var _useState = useState(0),
|
|
47
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
48
|
+
zoom = _useState2[0],
|
|
49
|
+
setZoom = _useState2[1];
|
|
50
|
+
useEffect(function () {
|
|
51
|
+
var initialZoom = (graph === null || graph === void 0 ? void 0 : graph.getZoom()) > 2 ? 2 : graph === null || graph === void 0 ? void 0 : graph.getZoom();
|
|
52
|
+
// 上层调用 fitView() 后缩放可能超过 100%,因此这里再做一次缩放,避免缩放超过 100%
|
|
53
|
+
graph === null || graph === void 0 ? void 0 : graph.zoomTo(initialZoom, getCenterPointByGraph(graph));
|
|
54
|
+
setZoom(initialZoom);
|
|
55
|
+
graph === null || graph === void 0 ? void 0 : graph.on('wheelzoom',
|
|
56
|
+
// 使用防抖函数,避免状态改变过于频繁,影响页面交互流畅
|
|
57
|
+
// 设置延迟时间为 16ms,为渲染一帧所需时间
|
|
58
|
+
debounce(function () {
|
|
59
|
+
setZoom(graph === null || graph === void 0 ? void 0 : graph.getZoom());
|
|
60
|
+
}, 16));
|
|
61
|
+
}, [graph]);
|
|
62
|
+
return /*#__PURE__*/React.createElement(Space, {
|
|
63
|
+
size: 16,
|
|
64
|
+
className: "".concat(prefix, " ", "".concat(prefix, "-").concat(mode), " ").concat(className)
|
|
65
|
+
}, showFullscreen && /*#__PURE__*/React.createElement(Tooltip, {
|
|
66
|
+
title: locale.fullscreen
|
|
67
|
+
}, /*#__PURE__*/React.createElement(FullscreenOutlined, {
|
|
68
|
+
className: "pointable",
|
|
69
|
+
onClick: function onClick() {
|
|
70
|
+
if (onFullscreen) {
|
|
71
|
+
onFullscreen();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
75
|
+
className: "".concat(prefix, "-zoom-wrapper")
|
|
76
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
77
|
+
title: locale.shrink
|
|
78
|
+
}, /*#__PURE__*/React.createElement(MinusOutlined, {
|
|
79
|
+
className: zoom >= 0.3 ? "".concat(prefix, "-pointable") : "".concat(prefix, "-disabled"),
|
|
80
|
+
onClick: function onClick() {
|
|
81
|
+
if (zoom >= 0.3) {
|
|
82
|
+
var newZoom = zoom - 0.1;
|
|
83
|
+
setZoom(newZoom);
|
|
84
|
+
graph === null || graph === void 0 ? void 0 : graph.zoomTo(newZoom, getCenterPointByGraph(graph));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
})), toPercent(zoom), /*#__PURE__*/React.createElement(Tooltip, {
|
|
88
|
+
title: locale.enlarge
|
|
89
|
+
}, /*#__PURE__*/React.createElement(PlusOutlined, {
|
|
90
|
+
className: zoom <= 0.9 ? "".concat(prefix, "-pointable") : "".concat(prefix, "-disabled"),
|
|
91
|
+
onClick: function onClick() {
|
|
92
|
+
if (zoom <= 0.9) {
|
|
93
|
+
var newZoom = zoom + 0.1;
|
|
94
|
+
setZoom(newZoom);
|
|
95
|
+
graph === null || graph === void 0 ? void 0 : graph.zoomTo(newZoom, getCenterPointByGraph(graph));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
99
|
+
title: locale.reset
|
|
100
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
101
|
+
src: resetIcon,
|
|
102
|
+
alt: "",
|
|
103
|
+
className: "".concat(prefix, "-pointable"),
|
|
104
|
+
onClick: function onClick() {
|
|
105
|
+
setZoom(1);
|
|
106
|
+
graph === null || graph === void 0 ? void 0 : graph.zoomTo(1, getCenterPointByGraph(graph));
|
|
107
|
+
}
|
|
108
|
+
})), /*#__PURE__*/React.createElement(Tooltip, {
|
|
109
|
+
title: locale.fitView
|
|
110
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
111
|
+
src: fitViewIcon,
|
|
112
|
+
alt: "",
|
|
113
|
+
className: "".concat(prefix, "-pointable"),
|
|
114
|
+
onClick: function onClick() {
|
|
115
|
+
graph === null || graph === void 0 ? void 0 : graph.fitView();
|
|
116
|
+
}
|
|
117
|
+
})), onReload && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Divider, {
|
|
118
|
+
type: "vertical",
|
|
119
|
+
className: "".concat(prefix, "-divider")
|
|
120
|
+
})), onReload && /*#__PURE__*/React.createElement(Tooltip, {
|
|
121
|
+
title: locale.refresh
|
|
122
|
+
}, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(SyncOutlined, {
|
|
123
|
+
className: "".concat(prefix, "-pointable"),
|
|
124
|
+
onClick: function onClick() {
|
|
125
|
+
onReload();
|
|
126
|
+
}
|
|
127
|
+
}))));
|
|
128
|
+
};
|
|
129
|
+
export default LocaleWrapper({
|
|
130
|
+
componentName: 'GraphToolbar',
|
|
131
|
+
defaultLocale: zhCN
|
|
132
|
+
})(GraphToolbar);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
@import '../variable.less';
|
|
2
|
+
|
|
3
|
+
@prefix: ob-graph-toolbar;
|
|
4
|
+
|
|
5
|
+
.@{prefix} {
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
|
|
10
|
+
.@{prefix}-pointable {
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.@{prefix}-disabled {
|
|
15
|
+
color: @colorTextQuaternary;
|
|
16
|
+
cursor: not-allowed;
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
span,
|
|
21
|
+
img {
|
|
22
|
+
// 防止加减 zoom 过快时会选中文本 和 img 图标
|
|
23
|
+
user-select: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
> span:not(:last-child) {
|
|
27
|
+
margin-right: 16px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
img:not(:last-child) {
|
|
31
|
+
margin-right: 16px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.@{prefix}-divider {
|
|
35
|
+
margin: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.@{prefix}-zoom-wrapper {
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: space-between;
|
|
42
|
+
width: 90px;
|
|
43
|
+
height: 24px;
|
|
44
|
+
padding: 0 8px;
|
|
45
|
+
color: @colorTextSecondary;
|
|
46
|
+
font-size: 12px;
|
|
47
|
+
background-color: #f5f6fa;
|
|
48
|
+
border-radius: ~'@{borderRadius}px';
|
|
49
|
+
|
|
50
|
+
.@{iconPrefixCls} {
|
|
51
|
+
font-size: 12px;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.@{prefix}-fixed {
|
|
57
|
+
position: absolute;
|
|
58
|
+
top: 24px;
|
|
59
|
+
right: 24px;
|
|
60
|
+
height: 40px;
|
|
61
|
+
padding: 8px 24px;
|
|
62
|
+
background: #fff;
|
|
63
|
+
border-radius: 20px;
|
|
64
|
+
box-shadow: @boxShadowSecondary;
|
|
65
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
export default function DiffCells(_ref) {
|
|
8
|
+
var _mergedClassName, _data$value;
|
|
9
|
+
var diffPrefixCls = _ref.diffPrefixCls,
|
|
10
|
+
data = _ref.data,
|
|
11
|
+
emptyText = _ref.emptyText,
|
|
12
|
+
width = _ref.width,
|
|
13
|
+
lock = _ref.lock,
|
|
14
|
+
_ref$rowOffset = _ref.rowOffset,
|
|
15
|
+
rowOffset = _ref$rowOffset === void 0 ? 0 : _ref$rowOffset,
|
|
16
|
+
onMouseDown = _ref.onMouseDown,
|
|
17
|
+
hashId = _ref.hashId;
|
|
18
|
+
var cellEmptyClassName = "".concat(diffPrefixCls, "-cell-empty");
|
|
19
|
+
var cellAddClassName = "".concat(diffPrefixCls, "-cell-add");
|
|
20
|
+
var cellRemoveClassName = "".concat(diffPrefixCls, "-cell-remove");
|
|
21
|
+
var add = (data === null || data === void 0 ? void 0 : data.type) === 'add';
|
|
22
|
+
var remove = (data === null || data === void 0 ? void 0 : data.type) === 'remove';
|
|
23
|
+
var mergedClassName = (_mergedClassName = {}, _defineProperty(_mergedClassName, cellEmptyClassName, !data), _defineProperty(_mergedClassName, cellAddClassName, add), _defineProperty(_mergedClassName, cellRemoveClassName, remove), _mergedClassName);
|
|
24
|
+
var rowIndex = data === null || data === void 0 ? void 0 : data.index;
|
|
25
|
+
if (rowIndex !== undefined) {
|
|
26
|
+
rowIndex += rowOffset;
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("td", {
|
|
29
|
+
className: classNames("".concat(diffPrefixCls, "-index"), mergedClassName, hashId)
|
|
30
|
+
}, rowIndex), /*#__PURE__*/React.createElement("td", {
|
|
31
|
+
className: classNames("".concat(diffPrefixCls, "-mark"), mergedClassName, hashId)
|
|
32
|
+
}, add && '+', remove && '-'), /*#__PURE__*/React.createElement("td", {
|
|
33
|
+
onMouseDown: onMouseDown,
|
|
34
|
+
style: {
|
|
35
|
+
width: width,
|
|
36
|
+
userSelect: lock ? 'none' : undefined
|
|
37
|
+
},
|
|
38
|
+
className: classNames("".concat(diffPrefixCls, "-code"), mergedClassName, hashId),
|
|
39
|
+
dangerouslySetInnerHTML: {
|
|
40
|
+
__html: (_data$value = data === null || data === void 0 ? void 0 : data.value) !== null && _data$value !== void 0 ? _data$value : emptyText || ''
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { HighlightProps } from '..';
|
|
3
|
+
import '../index.less';
|
|
4
|
+
export interface DiffViewProps extends Omit<HighlightProps, 'children' | 'innerHTML'> {
|
|
5
|
+
/**
|
|
6
|
+
* @description 自定义前缀
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
prefixCls?: string;
|
|
10
|
+
/**
|
|
11
|
+
* @description 样式
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
/**
|
|
16
|
+
* @description className 类名
|
|
17
|
+
* @ignore
|
|
18
|
+
*/
|
|
19
|
+
className?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @title 原始代码
|
|
22
|
+
* @renderType json
|
|
23
|
+
* @description 原始代码
|
|
24
|
+
*/
|
|
25
|
+
source: string;
|
|
26
|
+
/**
|
|
27
|
+
* @title 目标代码
|
|
28
|
+
* @renderType json
|
|
29
|
+
* @description 目标代码
|
|
30
|
+
*/
|
|
31
|
+
target: string;
|
|
32
|
+
/**
|
|
33
|
+
* @title 是否分割展示
|
|
34
|
+
* @description 是否分割展示
|
|
35
|
+
*/
|
|
36
|
+
split?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* @title 起始行号
|
|
39
|
+
* @description 起始行号,默认为 1,也可以分别对左右两侧起始行号进行配置
|
|
40
|
+
*/
|
|
41
|
+
startRowIndex?: number | number[];
|
|
42
|
+
}
|
|
43
|
+
declare const DiffView: React.FC<DiffViewProps>;
|
|
44
|
+
export default DiffView;
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
15
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
import classNames from 'classnames';
|
|
18
|
+
import { diffLines } from 'diff';
|
|
19
|
+
import hljs from 'highlight.js/lib/core';
|
|
20
|
+
import warning from 'rc-util/lib/warning';
|
|
21
|
+
import React, { useEffect, useMemo } from 'react';
|
|
22
|
+
import { languageMap } from '..';
|
|
23
|
+
import { getPrefix } from "../..//_util";
|
|
24
|
+
import { useKeyDownCopyEvent } from "../useKeyDownCopyEvent";
|
|
25
|
+
import DiffCells from "./DiffCells";
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
import "../index.less";
|
|
28
|
+
var MAX_MERGE_TIMES = 10000;
|
|
29
|
+
var EMPTY_TEXT = "<span class=\"hljs-comment\">// \u6CA1\u6709\u6570\u636E</span>";
|
|
30
|
+
function getHighlightRows(language, code) {
|
|
31
|
+
var _ref = language ? hljs.highlight(language, code) : hljs.highlightAuto(code),
|
|
32
|
+
value = _ref.value;
|
|
33
|
+
return value.split(/\r?\n/);
|
|
34
|
+
}
|
|
35
|
+
var DiffView = function DiffView(_ref2) {
|
|
36
|
+
var style = _ref2.style,
|
|
37
|
+
className = _ref2.className,
|
|
38
|
+
customizePrefixCls = _ref2.prefixCls,
|
|
39
|
+
source = _ref2.source,
|
|
40
|
+
target = _ref2.target,
|
|
41
|
+
language = _ref2.language,
|
|
42
|
+
_ref2$split = _ref2.split,
|
|
43
|
+
split = _ref2$split === void 0 ? true : _ref2$split,
|
|
44
|
+
theme = _ref2.theme,
|
|
45
|
+
height = _ref2.height,
|
|
46
|
+
_ref2$startRowIndex = _ref2.startRowIndex,
|
|
47
|
+
baseStartRowIndex = _ref2$startRowIndex === void 0 ? 1 : _ref2$startRowIndex;
|
|
48
|
+
var prefixCls = getPrefix('highlight');
|
|
49
|
+
var diffPrefixCls = "".concat(prefixCls, "-diff");
|
|
50
|
+
var _React$useState = React.useState(null),
|
|
51
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
52
|
+
report = _React$useState2[0],
|
|
53
|
+
setReport = _React$useState2[1];
|
|
54
|
+
var normalizedIndexes = Array.isArray(baseStartRowIndex) ? baseStartRowIndex : [baseStartRowIndex, baseStartRowIndex];
|
|
55
|
+
var _normalizedIndexes = _slicedToArray(normalizedIndexes, 2),
|
|
56
|
+
_normalizedIndexes$ = _normalizedIndexes[0],
|
|
57
|
+
baseStartRowIndexSrc = _normalizedIndexes$ === void 0 ? 1 : _normalizedIndexes$,
|
|
58
|
+
_normalizedIndexes$2 = _normalizedIndexes[1],
|
|
59
|
+
baseStartRowIndexTgt = _normalizedIndexes$2 === void 0 ? 1 : _normalizedIndexes$2;
|
|
60
|
+
var rowOffsetSrc = baseStartRowIndexSrc > 1 ? baseStartRowIndexSrc - 1 : 0;
|
|
61
|
+
var rowOffsetTgt = baseStartRowIndexTgt > 1 ? baseStartRowIndexTgt - 1 : 0;
|
|
62
|
+
|
|
63
|
+
// =========================== Language ===========================
|
|
64
|
+
useEffect(function () {
|
|
65
|
+
if (language) {
|
|
66
|
+
hljs.registerLanguage(language, languageMap[language]);
|
|
67
|
+
} else {
|
|
68
|
+
Object.keys(languageMap).forEach(function (lan) {
|
|
69
|
+
hljs.registerLanguage(lan, languageMap[lan]);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}, [language]);
|
|
73
|
+
|
|
74
|
+
// ============================= Lock =============================
|
|
75
|
+
// Lock the selection to make user easy to copy
|
|
76
|
+
var _React$useState3 = React.useState(null),
|
|
77
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
78
|
+
selectable = _React$useState4[0],
|
|
79
|
+
setSelectable = _React$useState4[1];
|
|
80
|
+
function setSelectableRegion(region) {
|
|
81
|
+
if (region !== selectable) {
|
|
82
|
+
var _window$getSelection, _window, _window$getSelection$, _window$getSelection$2, _window$getSelection2, _window2, _window$getSelection3, _window$getSelection4;
|
|
83
|
+
(_window$getSelection = (_window = window).getSelection) === null || _window$getSelection === void 0 ? void 0 : (_window$getSelection$ = (_window$getSelection$2 = _window$getSelection.call(_window)).removeAllRanges) === null || _window$getSelection$ === void 0 ? void 0 : _window$getSelection$.call(_window$getSelection$2);
|
|
84
|
+
(_window$getSelection2 = (_window2 = window).getSelection) === null || _window$getSelection2 === void 0 ? void 0 : (_window$getSelection3 = (_window$getSelection4 = _window$getSelection2.call(_window2)).empty) === null || _window$getSelection3 === void 0 ? void 0 : _window$getSelection3.call(_window$getSelection4);
|
|
85
|
+
}
|
|
86
|
+
setSelectable(region);
|
|
87
|
+
}
|
|
88
|
+
var onSourceMouseDown = function onSourceMouseDown() {
|
|
89
|
+
setSelectableRegion('source');
|
|
90
|
+
};
|
|
91
|
+
var onTargetMouseDown = function onTargetMouseDown() {
|
|
92
|
+
setSelectableRegion('target');
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// ============================= Diff =============================
|
|
96
|
+
// Collection diff content
|
|
97
|
+
useEffect(function () {
|
|
98
|
+
if (!source && !target) {
|
|
99
|
+
setReport(null);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
var srcRows = getHighlightRows(language, source || '');
|
|
103
|
+
var tgtRows = getHighlightRows(language, target || '');
|
|
104
|
+
var diff = diffLines(source || '', target || '');
|
|
105
|
+
var newReport = {
|
|
106
|
+
source: srcRows,
|
|
107
|
+
target: tgtRows,
|
|
108
|
+
diff: diff
|
|
109
|
+
};
|
|
110
|
+
setReport(newReport);
|
|
111
|
+
}, [source, target, language]);
|
|
112
|
+
|
|
113
|
+
// Get diff rows
|
|
114
|
+
var diffData = useMemo(function () {
|
|
115
|
+
if (!report) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
var startRowIndex = 0;
|
|
119
|
+
var endRowIndex = 0;
|
|
120
|
+
var sourceRows = [];
|
|
121
|
+
var targetRows = [];
|
|
122
|
+
report.diff.forEach(function (_ref3) {
|
|
123
|
+
var count = _ref3.count,
|
|
124
|
+
added = _ref3.added,
|
|
125
|
+
removed = _ref3.removed;
|
|
126
|
+
// Source
|
|
127
|
+
if (added) {
|
|
128
|
+
sourceRows.push.apply(sourceRows, _toConsumableArray(new Array(count).fill(null)));
|
|
129
|
+
} else {
|
|
130
|
+
sourceRows.push.apply(sourceRows, _toConsumableArray(report.source.slice(startRowIndex, startRowIndex + count).map(function (value, index) {
|
|
131
|
+
return {
|
|
132
|
+
value: value,
|
|
133
|
+
index: startRowIndex + index + 1,
|
|
134
|
+
type: removed ? 'remove' : 'keep'
|
|
135
|
+
};
|
|
136
|
+
})));
|
|
137
|
+
startRowIndex += count;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Target
|
|
141
|
+
if (removed) {
|
|
142
|
+
targetRows.push.apply(targetRows, _toConsumableArray(new Array(count).fill(null)));
|
|
143
|
+
} else {
|
|
144
|
+
targetRows.push.apply(targetRows, _toConsumableArray(report.target.slice(endRowIndex, endRowIndex + count).map(function (value, index) {
|
|
145
|
+
return {
|
|
146
|
+
value: value,
|
|
147
|
+
index: endRowIndex + index + 1,
|
|
148
|
+
type: added ? 'add' : 'keep'
|
|
149
|
+
};
|
|
150
|
+
})));
|
|
151
|
+
endRowIndex += count;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
return {
|
|
155
|
+
sourceRows: sourceRows,
|
|
156
|
+
targetRows: targetRows
|
|
157
|
+
};
|
|
158
|
+
}, [report, split]);
|
|
159
|
+
|
|
160
|
+
// Merge -- & ++ to one row
|
|
161
|
+
var mergedData = useMemo(function () {
|
|
162
|
+
if (!diffData) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
function findMergeRowIndex(startIndex, sourceRows, targetRows) {
|
|
166
|
+
for (var index = startIndex; index < sourceRows.length - 1; index += 1) {
|
|
167
|
+
var _sourceRows$index, _targetRows;
|
|
168
|
+
if (
|
|
169
|
+
// Row: ---- | null
|
|
170
|
+
// Row: null | ++++
|
|
171
|
+
((_sourceRows$index = sourceRows[index]) === null || _sourceRows$index === void 0 ? void 0 : _sourceRows$index.type) === 'remove' && !targetRows[index] && !sourceRows[index + 1] && ((_targetRows = targetRows[index + 1]) === null || _targetRows === void 0 ? void 0 : _targetRows.type) === 'add') {
|
|
172
|
+
// Find source remove start index
|
|
173
|
+
var removeStartIndex = index;
|
|
174
|
+
for (var i = index - 1; i >= 0; i -= 1) {
|
|
175
|
+
var _sourceRows$i;
|
|
176
|
+
if (((_sourceRows$i = sourceRows[i]) === null || _sourceRows$i === void 0 ? void 0 : _sourceRows$i.type) !== 'remove') {
|
|
177
|
+
removeStartIndex = i + 1;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Find target add end index
|
|
183
|
+
var addEndIndex = index;
|
|
184
|
+
for (var _i2 = index + 1; _i2 <= targetRows.length; _i2 += 1) {
|
|
185
|
+
var _targetRows$_i;
|
|
186
|
+
if (((_targetRows$_i = targetRows[_i2]) === null || _targetRows$_i === void 0 ? void 0 : _targetRows$_i.type) !== 'add') {
|
|
187
|
+
addEndIndex = _i2 - 1;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
index: index + 1,
|
|
193
|
+
removeCount: index - removeStartIndex + 1,
|
|
194
|
+
addCount: addEndIndex - index
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
var sourceRows = diffData.sourceRows,
|
|
201
|
+
targetRows = diffData.targetRows;
|
|
202
|
+
var mergeStartIndex = 0;
|
|
203
|
+
var times = 0;
|
|
204
|
+
for (; times < MAX_MERGE_TIMES; times += 1) {
|
|
205
|
+
var mergeInfo = findMergeRowIndex(mergeStartIndex, sourceRows, targetRows);
|
|
206
|
+
if (mergeInfo === null) {
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
var index = mergeInfo.index,
|
|
210
|
+
addCount = mergeInfo.addCount,
|
|
211
|
+
removeCount = mergeInfo.removeCount;
|
|
212
|
+
var maxMergeRowCount = Math.min(addCount, removeCount);
|
|
213
|
+
sourceRows = [].concat(_toConsumableArray(sourceRows.slice(0, index)), _toConsumableArray(sourceRows.slice(index + maxMergeRowCount)));
|
|
214
|
+
targetRows = [].concat(_toConsumableArray(targetRows.slice(0, index - maxMergeRowCount)), _toConsumableArray(targetRows.slice(index)));
|
|
215
|
+
mergeStartIndex = index - maxMergeRowCount;
|
|
216
|
+
}
|
|
217
|
+
warning(times < MAX_MERGE_TIMES, 'Diff check too many times. Please help to fire issue of DiffView. Thanks.');
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Change target rows order when has empty content:
|
|
221
|
+
* -- null -- [ Data ]
|
|
222
|
+
* -- null -- => -- null --
|
|
223
|
+
* [ Data ] -- null --
|
|
224
|
+
*/
|
|
225
|
+
var targetRowsLen = targetRows.length;
|
|
226
|
+
for (var i = 0; i < targetRowsLen; i += 1) {
|
|
227
|
+
if (!targetRows[i]) {
|
|
228
|
+
for (var j = i + 1; j < targetRowsLen; j += 1) {
|
|
229
|
+
var followRow = targetRows[j];
|
|
230
|
+
if (followRow) {
|
|
231
|
+
if (followRow.type === 'add') {
|
|
232
|
+
targetRows[i] = followRow;
|
|
233
|
+
targetRows[j] = null;
|
|
234
|
+
}
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
rows: sourceRows.map(function (src, index) {
|
|
242
|
+
return {
|
|
243
|
+
source: src,
|
|
244
|
+
target: targetRows[index]
|
|
245
|
+
};
|
|
246
|
+
}),
|
|
247
|
+
sourceEmpty: sourceRows.every(function (row) {
|
|
248
|
+
return !row;
|
|
249
|
+
}),
|
|
250
|
+
targetEmpty: targetRows.every(function (row) {
|
|
251
|
+
return !row;
|
|
252
|
+
})
|
|
253
|
+
};
|
|
254
|
+
}, [diffData]);
|
|
255
|
+
|
|
256
|
+
// ============================ Render ============================
|
|
257
|
+
var viewRows;
|
|
258
|
+
if (!report) {
|
|
259
|
+
viewRows = /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement(DiffCells, {
|
|
260
|
+
width: "100%",
|
|
261
|
+
diffPrefixCls: diffPrefixCls,
|
|
262
|
+
data: {
|
|
263
|
+
index: 1,
|
|
264
|
+
value: EMPTY_TEXT,
|
|
265
|
+
type: 'keep'
|
|
266
|
+
}
|
|
267
|
+
}));
|
|
268
|
+
} else if (split) {
|
|
269
|
+
// Split view
|
|
270
|
+
viewRows = mergedData.rows.map(function (_ref4, index) {
|
|
271
|
+
var src = _ref4.source,
|
|
272
|
+
tgt = _ref4.target;
|
|
273
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
274
|
+
key: index
|
|
275
|
+
}, /*#__PURE__*/React.createElement(DiffCells, {
|
|
276
|
+
width: "50%",
|
|
277
|
+
diffPrefixCls: diffPrefixCls,
|
|
278
|
+
data: src,
|
|
279
|
+
emptyText: index === 0 && mergedData.sourceEmpty && EMPTY_TEXT,
|
|
280
|
+
onMouseDown: onSourceMouseDown,
|
|
281
|
+
lock: selectable !== 'source',
|
|
282
|
+
rowOffset: rowOffsetSrc
|
|
283
|
+
}), /*#__PURE__*/React.createElement(DiffCells, {
|
|
284
|
+
width: "50%",
|
|
285
|
+
diffPrefixCls: diffPrefixCls,
|
|
286
|
+
data: tgt,
|
|
287
|
+
emptyText: index === 0 && mergedData.targetEmpty && EMPTY_TEXT,
|
|
288
|
+
onMouseDown: onTargetMouseDown,
|
|
289
|
+
lock: selectable !== 'target',
|
|
290
|
+
rowOffset: rowOffsetTgt
|
|
291
|
+
}));
|
|
292
|
+
});
|
|
293
|
+
} else {
|
|
294
|
+
// Merge
|
|
295
|
+
viewRows = diffData.sourceRows.map(function (src, index) {
|
|
296
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
297
|
+
key: index
|
|
298
|
+
}, /*#__PURE__*/React.createElement(DiffCells, {
|
|
299
|
+
width: "100%",
|
|
300
|
+
diffPrefixCls: diffPrefixCls,
|
|
301
|
+
data: src !== null && src !== void 0 ? src : diffData.targetRows[index],
|
|
302
|
+
rowOffset: rowOffsetTgt
|
|
303
|
+
}));
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
var codeRef = React.useRef();
|
|
307
|
+
useKeyDownCopyEvent(codeRef);
|
|
308
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
309
|
+
style: _objectSpread({
|
|
310
|
+
height: height
|
|
311
|
+
}, style),
|
|
312
|
+
ref: codeRef,
|
|
313
|
+
tabIndex: -1,
|
|
314
|
+
className: classNames(prefixCls, diffPrefixCls, "".concat(prefixCls, "-").concat(theme === 'dark' ? 'dark' : 'light'), _defineProperty({}, "".concat(diffPrefixCls, "-split"), split), className)
|
|
315
|
+
}, /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("tbody", null, viewRows)));
|
|
316
|
+
};
|
|
317
|
+
export default DiffView;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export default function HighlightCell(_ref) {
|
|
4
|
+
var _data$value;
|
|
5
|
+
var prefixCls = _ref.prefixCls,
|
|
6
|
+
theme = _ref.theme,
|
|
7
|
+
data = _ref.data,
|
|
8
|
+
emptyText = _ref.emptyText,
|
|
9
|
+
width = _ref.width,
|
|
10
|
+
lock = _ref.lock,
|
|
11
|
+
_ref$lineNumber = _ref.lineNumber,
|
|
12
|
+
lineNumber = _ref$lineNumber === void 0 ? false : _ref$lineNumber,
|
|
13
|
+
onMouseDown = _ref.onMouseDown,
|
|
14
|
+
hashId = _ref.hashId;
|
|
15
|
+
var rowIndex = data === null || data === void 0 ? void 0 : data.index;
|
|
16
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, lineNumber ? /*#__PURE__*/React.createElement("td", {
|
|
17
|
+
className: classNames("".concat(prefixCls, "-").concat(theme, "-index"), "".concat(prefixCls, "-index"), hashId)
|
|
18
|
+
}, rowIndex) : null, /*#__PURE__*/React.createElement("td", {
|
|
19
|
+
onMouseDown: onMouseDown,
|
|
20
|
+
style: {
|
|
21
|
+
width: width,
|
|
22
|
+
userSelect: lock ? 'none' : undefined
|
|
23
|
+
},
|
|
24
|
+
className: classNames("".concat(prefixCls, "-content"), hashId),
|
|
25
|
+
dangerouslySetInnerHTML: {
|
|
26
|
+
__html: (_data$value = data === null || data === void 0 ? void 0 : data.value) !== null && _data$value !== void 0 ? _data$value : emptyText || ''
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { HighlightProps } from '.';
|
|
3
|
+
import './index.less';
|
|
4
|
+
export interface JsonViewProps extends HighlightProps {
|
|
5
|
+
json: object;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: ({ json, theme, style, className, height, onCopyChange, copyable, }: JsonViewProps) => import("react").JSX.Element;
|
|
8
|
+
export default _default;
|