sh-view 1.7.6 → 2.0.1
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/.eslintrc.js +20 -21
- package/dist/css/227.45fab5b7.css +1 -0
- package/dist/css/291.e7facf7d.css +1 -0
- package/dist/css/299.e98df6ce.css +1 -0
- package/dist/css/358.e641c5d1.css +1 -0
- package/dist/css/534.726e6699.css +1 -0
- package/dist/css/769.8008ac6c.css +1 -0
- package/dist/css/index.2bd4fb37.css +1 -0
- package/dist/css/index.2bd4fb37.css.gz +0 -0
- package/dist/fonts/iconfont.03e5a9f9.ttf +0 -0
- package/dist/fonts/iconfont.03e5a9f9.ttf.gz +0 -0
- package/dist/fonts/ionicons.31fd4446.ttf +0 -0
- package/dist/fonts/ionicons.31fd4446.ttf.gz +0 -0
- package/dist/fonts/ionicons.d03f2836.woff2 +0 -0
- package/dist/fonts/ionicons.dacd136b.woff +0 -0
- package/dist/fonts/ionicons.dacd136b.woff.gz +0 -0
- package/dist/img/ionicons.6e8059e8.svg +870 -0
- package/dist/img/ionicons.6e8059e8.svg.gz +0 -0
- package/dist/js/152.588ca5b4.js +1 -0
- package/dist/js/165.f026fdcd.js +1 -0
- package/dist/js/227.6d340a71.js +1 -0
- package/dist/js/257.285f071f.js +1 -0
- package/dist/js/264.32b3a9a5.js +1 -0
- package/dist/js/291.e100da5e.js +1 -0
- package/dist/js/299.2062f9ff.js +1 -0
- package/dist/js/322.ff97ab5e.js +1 -0
- package/dist/js/333.da633859.js +1 -0
- package/dist/js/341.d4433549.js +1 -0
- package/dist/js/358.81429379.js +1 -0
- package/dist/js/387.7b1e3b8a.js +1 -0
- package/dist/js/392.c53bf6c9.js +1 -0
- package/dist/js/400.03e3be15.js +1 -0
- package/dist/js/41.fca2504e.js +1 -0
- package/dist/js/444.a0350517.js +1 -0
- package/dist/js/452.7f75d556.js +2 -0
- package/dist/js/452.7f75d556.js.gz +0 -0
- package/dist/js/497.06080ae1.js +1 -0
- package/dist/js/514.2ea0055a.js +1 -0
- package/dist/js/534.40a67536.js +1 -0
- package/dist/js/558.6175bf20.js +15 -0
- package/dist/js/558.6175bf20.js.gz +0 -0
- package/dist/js/586.098ab36d.js +1 -0
- package/dist/js/593.df7d7c2e.js +1 -0
- package/dist/js/601.abf6f256.js +1 -0
- package/dist/js/654.99b45cd4.js +18 -0
- package/dist/js/654.99b45cd4.js.gz +0 -0
- package/dist/js/668.a15a0058.js +1 -0
- package/dist/js/704.52e87fec.js +1 -0
- package/dist/js/720.aceca876.js +1 -0
- package/dist/js/769.1376ca7f.js +1 -0
- package/dist/js/875.975891f5.js +1 -0
- package/dist/js/89.c7317ccb.js +1 -0
- package/dist/js/94.d54e8b09.js +1 -0
- package/dist/js/chunk-vendors.e05ef0ac.js +438 -0
- package/dist/js/chunk-vendors.e05ef0ac.js.gz +0 -0
- package/dist/js/index.b31868df.js +1 -0
- package/dist/js/index.b31868df.js.gz +0 -0
- package/package.json +10 -10
- package/packages/assets/css/animated.scss +167 -2
- package/packages/assets/css/loader.scss +42 -42
- package/packages/assets/css/main.scss +41 -21
- package/packages/assets/css/theme.scss +83 -44
- package/packages/components/global-components/sh-alert/index.vue +173 -0
- package/packages/components/global-components/sh-badge/index.vue +227 -0
- package/packages/components/global-components/sh-card/index.vue +140 -122
- package/packages/components/global-components/sh-code-editor/index.vue +260 -260
- package/packages/components/global-components/sh-col/css/index.scss +76 -0
- package/packages/components/global-components/sh-col/index.vue +83 -0
- package/packages/components/global-components/sh-corner/index.vue +1 -9
- package/packages/components/global-components/sh-count-to/index.vue +102 -46
- package/packages/components/global-components/sh-date/index.vue +40 -0
- package/packages/components/global-components/sh-drawer/index.vue +518 -0
- package/packages/components/global-components/sh-drawer/scrollbar.js +76 -0
- package/packages/components/global-components/sh-empty/index.vue +43 -43
- package/packages/components/global-components/{sh-vxe-form → sh-form}/css/index.scss +6 -6
- package/packages/components/global-components/{sh-vxe-form → sh-form}/index.vue +114 -115
- package/packages/components/global-components/{sh-vxe-form → sh-form}/js/methods.js +146 -157
- package/packages/components/global-components/{sh-vxe-form → sh-form}/mixin/defaultData.js +32 -33
- package/packages/components/global-components/sh-header/index.vue +293 -269
- package/packages/components/global-components/sh-icon/css/default/fonts/ionicons.svg +870 -0
- package/packages/components/global-components/sh-icon/css/default/fonts/ionicons.ttf +0 -0
- package/packages/components/global-components/sh-icon/css/default/fonts/ionicons.woff +0 -0
- package/packages/components/global-components/sh-icon/css/default/fonts/ionicons.woff2 +0 -0
- package/packages/components/global-components/sh-icon/css/default/icons.scss +2583 -0
- package/packages/components/global-components/sh-icon/css/default/index.scss +27 -0
- package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.js +1 -0
- package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.json +247 -0
- package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.ttf +0 -0
- package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.woff +0 -0
- package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.woff2 +0 -0
- package/packages/components/global-components/sh-icon/css/font/icons.scss +135 -0
- package/packages/components/global-components/sh-icon/css/font/index.scss +16 -0
- package/packages/components/global-components/sh-icon/icon-default.vue +32 -0
- package/packages/components/global-components/sh-icon/{icons.vue → icon-font.vue} +32 -32
- package/packages/components/global-components/sh-icon/index.vue +28 -27
- package/packages/components/global-components/sh-image/index.vue +123 -0
- package/packages/components/global-components/sh-list/index.vue +141 -0
- package/packages/components/global-components/sh-loading/index.vue +49 -42
- package/packages/components/global-components/{sh-vxe-modal → sh-modal}/index.vue +209 -209
- package/packages/components/global-components/sh-noticebar/index.vue +201 -201
- package/packages/components/global-components/sh-poptip/index.vue +479 -0
- package/packages/components/global-components/sh-poptip/popper.js +115 -0
- package/packages/components/global-components/sh-progress/index.vue +290 -0
- package/packages/components/global-components/sh-pull-refresh/index.vue +290 -290
- package/packages/components/global-components/{sh-vxe-query → sh-query}/index.vue +317 -310
- package/packages/components/global-components/sh-result/index.vue +110 -88
- package/packages/components/global-components/sh-row/css/index.scss +21 -0
- package/packages/components/global-components/sh-row/index.vue +63 -0
- package/packages/components/global-components/sh-split/components/trigger.vue +33 -0
- package/packages/components/global-components/sh-split/index.vue +334 -142
- package/packages/components/global-components/sh-table/components/importModal.vue +351 -0
- package/packages/components/global-components/{sh-vxe-table → sh-table}/css/index.scss +4 -22
- package/packages/components/global-components/{sh-vxe-table → sh-table}/index.vue +329 -351
- package/packages/components/global-components/{sh-vxe-table → sh-table}/js/methods.js +33 -88
- package/packages/components/global-components/{sh-vxe-table → sh-table}/js/props.js +304 -313
- package/packages/components/global-components/{sh-vxe-table → sh-table}/mixin/defaultData.js +94 -116
- package/packages/components/global-components/sh-tabs/index.vue +322 -0
- package/packages/components/global-components/sh-tag/index.vue +163 -0
- package/packages/components/global-components/{sh-vxe-toolbar → sh-toolbar}/index.vue +177 -172
- package/packages/components/global-components/sh-tree/components/table-tree.vue +280 -0
- package/packages/components/global-components/sh-tree/css/index.scss +54 -0
- package/packages/components/global-components/sh-tree/index.vue +195 -0
- package/packages/components/global-components/sh-tree/mixin/treeProps.js +124 -0
- package/packages/components/global-components/sh-upload/index.vue +278 -275
- package/packages/components/global-components/sh-water-fall/index.vue +87 -87
- package/packages/components/index.js +85 -59
- package/packages/components/other-components/sh-cron-modal/css/index.scss +2 -2
- package/packages/components/other-components/sh-menu-card/index.vue +224 -224
- package/packages/css/index.js +4 -6
- package/packages/directive/index.js +19 -19
- package/packages/directive/module/click-out.js +14 -0
- package/packages/directive/module/draggable.js +42 -42
- package/packages/directive/module/line-clamp.js +22 -0
- package/packages/directive/module/prevent-click.js +18 -0
- package/packages/directive/module/resize.js +19 -0
- package/packages/directive/module/ripple.js +166 -0
- package/packages/index.js +39 -40
- package/packages/utils/transfer-queue.js +12 -0
- package/packages/vxeTable/css/index.scss +12 -98
- package/packages/vxeTable/css/variable.scss +7 -265
- package/packages/vxeTable/index.js +184 -183
- package/packages/vxeTable/plugins/export.js +450 -0
- package/packages/vxeTable/render/cell/vxe-render-checkgroup.vue +36 -36
- package/packages/vxeTable/render/cell/vxe-render-goption.vue +94 -93
- package/packages/vxeTable/render/cell/vxe-render-img.vue +21 -28
- package/packages/vxeTable/render/cell/vxe-render-input.vue +51 -51
- package/packages/vxeTable/render/cell/vxe-render-progress.vue +19 -19
- package/packages/vxeTable/render/cell/vxe-render-radiogroup.vue +36 -36
- package/packages/vxeTable/render/cell/vxe-render-select.vue +36 -36
- package/packages/vxeTable/render/cell/vxe-render-tree.vue +59 -59
- package/packages/vxeTable/render/globalRenders.jsx +498 -491
- package/packages/assets/icons/demo.css +0 -539
- package/packages/assets/icons/iconfont.css +0 -415
- package/packages/assets/icons/iconfont.js +0 -1
- package/packages/assets/icons/iconfont.json +0 -709
- package/packages/assets/icons/iconfont.ttf +0 -0
- package/packages/assets/icons/iconfont.woff +0 -0
- package/packages/assets/icons/iconfont.woff2 +0 -0
- package/packages/assets/img/image-error.png +0 -0
- package/packages/assets/img/square-image.png +0 -0
- package/packages/components/global-components/sh-iv-form/components/iv-group-item.vue +0 -57
- package/packages/components/global-components/sh-iv-form/components/iv-single-item.vue +0 -76
- package/packages/components/global-components/sh-iv-form/index.vue +0 -255
- package/packages/components/global-components/sh-vxe-list/index.vue +0 -149
- package/packages/components/global-components/sh-vxe-table/components/importModal.vue +0 -377
- package/packages/components/global-components/sh-vxe-tree/components/table-tree.vue +0 -233
- package/packages/components/global-components/sh-vxe-tree/css/index.scss +0 -20
- package/packages/components/global-components/sh-vxe-tree/index.vue +0 -85
- package/packages/components/global-components/sh-vxe-tree/js/props.js +0 -120
- package/packages/components/global-components/sh-vxe-tree/js/treeMethods.js +0 -169
- package/packages/components/global-components/sh-vxe-tree/mixin/defaultData.js +0 -54
- package/packages/components/global-components/sh-vxe-tree/vxe-direct-tree.vue +0 -203
- package/packages/components/global-components/sh-vxe-tree/vxe-select-tree.vue +0 -291
- package/packages/components/other-components/sh-markdown/tinymce/langs/ar.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/az.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/bg_BG.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/bn_BD.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/ca.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/cs.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/cy.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/da.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/de.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/dv.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/el.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/eo.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/es.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/es_MX.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/et.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/eu.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/fa.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/fi.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/fr_FR.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/ga.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/gl.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/he_IL.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/hi.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/hr.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/hu_HU.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/hy.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/id.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/is_IS.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/it.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/ja.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/kab.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/kk.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/ko_KR.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/ku.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/lt.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/lv.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/nb_NO.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/ne.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/nl.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/nl_BE.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/oc.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/pl.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/pt_BR.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/ro.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/ru.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/sk.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/sl_SI.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/sq.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/sr.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/sv_SE.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/ta.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/tg.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/th_TH.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/tr.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/ug.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/uk.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/langs/vi.js +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/skins/content/dark/content.css +0 -72
- package/packages/components/other-components/sh-markdown/tinymce/skins/content/dark/content.min.css +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/skins/content/default/content.min.css +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/skins/content/document/content.css +0 -72
- package/packages/components/other-components/sh-markdown/tinymce/skins/content/document/content.min.css +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/skins/content/writer/content.css +0 -68
- package/packages/components/other-components/sh-markdown/tinymce/skins/content/writer/content.min.css +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.css +0 -714
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.inline.css +0 -726
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.inline.min.css +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.min.css +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.mobile.css +0 -29
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.mobile.min.css +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/fonts/tinymce-mobile.woff +0 -0
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.css +0 -3047
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.min.css +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.mobile.css +0 -673
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.mobile.min.css +0 -7
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +0 -37
- package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +0 -7
- package/packages/directive/directives.js +0 -27
- package/packages/iview/css/index.scss +0 -32
- package/packages/iview/index.js +0 -25
- /package/packages/components/global-components/{sh-vxe-form → sh-form}/components/form-item.vue +0 -0
- /package/packages/components/global-components/{sh-vxe-form → sh-form}/js/props.js +0 -0
- /package/packages/components/global-components/{sh-vxe-table → sh-table}/js/excel_to_json.js +0 -0
|
@@ -1,260 +1,260 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="sh-code-editor" :style="shStyles">
|
|
3
|
-
<div ref="codeMirror" class="sh-code-content" />
|
|
4
|
-
<div v-if="error" class="sh-code-error" v-html="error"></div>
|
|
5
|
-
</div>
|
|
6
|
-
</template>
|
|
7
|
-
|
|
8
|
-
<script>
|
|
9
|
-
import { basicSetup } from 'codemirror'
|
|
10
|
-
import { keymap, placeholder, drawSelection, lineNumbers, EditorView } from '@codemirror/view'
|
|
11
|
-
import { Compartment, EditorState, StateEffect } from '@codemirror/state'
|
|
12
|
-
import { defaultKeymap, indentWithTab, historyKeymap, history } from '@codemirror/commands'
|
|
13
|
-
import themes from './themes'
|
|
14
|
-
import { javascript } from '@codemirror/lang-javascript'
|
|
15
|
-
import { sql } from '@codemirror/lang-sql'
|
|
16
|
-
import { json } from '@codemirror/lang-json'
|
|
17
|
-
const tabSize = new Compartment()
|
|
18
|
-
export default {
|
|
19
|
-
name: 'ShCodeEditor',
|
|
20
|
-
props: {
|
|
21
|
-
modelValue: {
|
|
22
|
-
type: [String, Object],
|
|
23
|
-
default: ''
|
|
24
|
-
},
|
|
25
|
-
option: {
|
|
26
|
-
type: Object,
|
|
27
|
-
default() {
|
|
28
|
-
return {}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
mode: {
|
|
32
|
-
type: String,
|
|
33
|
-
default: 'javascript'
|
|
34
|
-
},
|
|
35
|
-
theme: {
|
|
36
|
-
type: String,
|
|
37
|
-
default: ''
|
|
38
|
-
},
|
|
39
|
-
placeholder: {
|
|
40
|
-
type: String,
|
|
41
|
-
default: ''
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
type: Boolean
|
|
45
|
-
},
|
|
46
|
-
border: {
|
|
47
|
-
type: Boolean
|
|
48
|
-
},
|
|
49
|
-
indent: {
|
|
50
|
-
type: Number,
|
|
51
|
-
default: 4
|
|
52
|
-
},
|
|
53
|
-
wrap: {
|
|
54
|
-
type: Boolean
|
|
55
|
-
},
|
|
56
|
-
tab: {
|
|
57
|
-
type: Boolean
|
|
58
|
-
},
|
|
59
|
-
multipleSelection: {
|
|
60
|
-
type: Boolean,
|
|
61
|
-
default: true
|
|
62
|
-
},
|
|
63
|
-
extensions: {
|
|
64
|
-
type: Array,
|
|
65
|
-
default() {
|
|
66
|
-
return []
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
width: {
|
|
70
|
-
type: [String, Number],
|
|
71
|
-
default: '100%'
|
|
72
|
-
},
|
|
73
|
-
height: {
|
|
74
|
-
type: [String, Number],
|
|
75
|
-
default: 'auto'
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
emits: ['update:modelValue', 'change', 'loaded', 'focus', 'blur', 'destroy'],
|
|
79
|
-
data() {
|
|
80
|
-
return {
|
|
81
|
-
codeEditor: null,
|
|
82
|
-
codeLength: 0,
|
|
83
|
-
error: null
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
computed: {
|
|
87
|
-
shStyles() {
|
|
88
|
-
return {
|
|
89
|
-
width: this.width,
|
|
90
|
-
height: this.height,
|
|
91
|
-
border: this.border ? '1px solid var(--border-color)' : 'none'
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
codeExtensions() {
|
|
95
|
-
const { mode, disabled, multipleSelection, indent, theme, tab, wrap, extensions } = this
|
|
96
|
-
let defaultExtensions = [basicSetup, history(), drawSelection(), lineNumbers(), placeholder(this.placeholder), keymap.of([...defaultKeymap, ...historyKeymap])]
|
|
97
|
-
if (['javascript', 'js'].includes(mode.toLowerCase())) {
|
|
98
|
-
defaultExtensions.push(javascript())
|
|
99
|
-
} else if (['mysql', 'sql'].includes(mode.toLowerCase())) {
|
|
100
|
-
defaultExtensions.push(sql())
|
|
101
|
-
} else if (['json'].includes(mode.toLowerCase())) {
|
|
102
|
-
defaultExtensions.push(json())
|
|
103
|
-
}
|
|
104
|
-
return [
|
|
105
|
-
...defaultExtensions,
|
|
106
|
-
EditorView.updateListener.of(this.updateListener),
|
|
107
|
-
EditorView.focusChangeEffect.of(this.focusListener),
|
|
108
|
-
EditorView.editable.of(!disabled),
|
|
109
|
-
EditorState.allowMultipleSelections.of(multipleSelection),
|
|
110
|
-
tabSize.of(EditorState.tabSize.of(indent)),
|
|
111
|
-
theme && themes[theme] ? themes[theme] : undefined,
|
|
112
|
-
tab ? keymap.of([indentWithTab]) : undefined,
|
|
113
|
-
wrap ? EditorView.lineWrapping : undefined,
|
|
114
|
-
...extensions
|
|
115
|
-
].filter(item => !!item)
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
watch: {
|
|
119
|
-
modelValue(value) {
|
|
120
|
-
if (this.codeEditor && !this.codeEditor.composing) {
|
|
121
|
-
let docLength = this.codeEditor.state.doc.length
|
|
122
|
-
let docValue = this.getTransformValue(value)
|
|
123
|
-
this.codeEditor.dispatch({
|
|
124
|
-
changes: { from: 0, to: docLength, insert: docValue },
|
|
125
|
-
selection: this.codeEditor.state.selection,
|
|
126
|
-
scrollIntoView: true
|
|
127
|
-
})
|
|
128
|
-
this.codeLength = docLength
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
codeExtensions: {
|
|
132
|
-
handler(exts) {
|
|
133
|
-
this.codeEditor?.dispatch({
|
|
134
|
-
effects: StateEffect.reconfigure.of(exts)
|
|
135
|
-
})
|
|
136
|
-
},
|
|
137
|
-
immediate: true
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
mounted() {
|
|
141
|
-
this.codeRender()
|
|
142
|
-
},
|
|
143
|
-
unmounted() {
|
|
144
|
-
if (this.codeEditor) this.codeEditor.destroy()
|
|
145
|
-
this.emitDestroy()
|
|
146
|
-
},
|
|
147
|
-
methods: {
|
|
148
|
-
codeRef() {
|
|
149
|
-
return this.$refs.codeMirror
|
|
150
|
-
},
|
|
151
|
-
async codeRender() {
|
|
152
|
-
const { codeRef, codeExtensions, modelValue, emitLoaded } = this
|
|
153
|
-
let docValue = this.getTransformValue(modelValue)
|
|
154
|
-
let codeState = EditorState.create({
|
|
155
|
-
doc: docValue,
|
|
156
|
-
extensions: codeExtensions
|
|
157
|
-
})
|
|
158
|
-
this.codeEditor = new EditorView({
|
|
159
|
-
parent: codeRef(),
|
|
160
|
-
state: codeState
|
|
161
|
-
})
|
|
162
|
-
await this.$nextTick()
|
|
163
|
-
emitLoaded()
|
|
164
|
-
},
|
|
165
|
-
focusListener(state, focusing) {
|
|
166
|
-
let valueStr = state.doc.toString()
|
|
167
|
-
if (focusing) {
|
|
168
|
-
this.emitFocus(valueStr)
|
|
169
|
-
} else {
|
|
170
|
-
this.emitValue(valueStr)
|
|
171
|
-
this.emitBlur(valueStr)
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
async updateListener({ state, changes, docChanged }) {
|
|
175
|
-
if (changes.empty || !docChanged) {
|
|
176
|
-
return
|
|
177
|
-
}
|
|
178
|
-
let valueStr = state.doc.toString()
|
|
179
|
-
// if (props.linter) {
|
|
180
|
-
// // Linter process
|
|
181
|
-
// if (props.forceLinting) {
|
|
182
|
-
// // If forceLinting enabled, first liting.
|
|
183
|
-
// forceLinting(view.value);
|
|
184
|
-
// }
|
|
185
|
-
// // Count diagnostics.
|
|
186
|
-
// diagnosticCount.value = (
|
|
187
|
-
// props.linter(view.value) as readonly Diagnostic[]
|
|
188
|
-
// ).length;
|
|
189
|
-
// }
|
|
190
|
-
this.emitChange(valueStr)
|
|
191
|
-
},
|
|
192
|
-
focus() {
|
|
193
|
-
this.codeEditor && this.codeEditor.focus()
|
|
194
|
-
},
|
|
195
|
-
getTransformValue(value, out) {
|
|
196
|
-
const { modelValue, indent } = this
|
|
197
|
-
let result = '',
|
|
198
|
-
error = null
|
|
199
|
-
try {
|
|
200
|
-
if (typeof modelValue === 'object' && value) {
|
|
201
|
-
result = out ? JSON.parse(value, null, indent) : JSON.stringify(value, null, indent)
|
|
202
|
-
} else {
|
|
203
|
-
result = value
|
|
204
|
-
}
|
|
205
|
-
} catch (e) {
|
|
206
|
-
error = e
|
|
207
|
-
}
|
|
208
|
-
this.error = error
|
|
209
|
-
return result
|
|
210
|
-
},
|
|
211
|
-
emitValue(value) {
|
|
212
|
-
let outValue = this.getTransformValue(value, true)
|
|
213
|
-
if (this.error) return
|
|
214
|
-
this.$emit('update:modelValue', outValue)
|
|
215
|
-
},
|
|
216
|
-
emitChange(value) {
|
|
217
|
-
this.$emit('change', { value, $event: this.codeEditor })
|
|
218
|
-
},
|
|
219
|
-
emitFocus(value) {
|
|
220
|
-
let outValue = this.getTransformValue(value, true)
|
|
221
|
-
if (this.error) return
|
|
222
|
-
this.$emit('focus', { value: outValue, $event: this.codeEditor })
|
|
223
|
-
},
|
|
224
|
-
emitBlur(value) {
|
|
225
|
-
let outValue = this.getTransformValue(value, true)
|
|
226
|
-
if (this.error) return
|
|
227
|
-
this.$emit('blur', { value: outValue, $event: this.codeEditor })
|
|
228
|
-
},
|
|
229
|
-
emitLoaded() {
|
|
230
|
-
this.$emit('loaded', { value: this.modelValue, $event: this.codeEditor })
|
|
231
|
-
},
|
|
232
|
-
emitDestroy() {
|
|
233
|
-
this.$emit('destroy', { value: this.modelValue, $event: this.codeEditor })
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
</script>
|
|
238
|
-
|
|
239
|
-
<style lang="scss" scoped>
|
|
240
|
-
.sh-code-editor {
|
|
241
|
-
display: flex;
|
|
242
|
-
position: relative;
|
|
243
|
-
overflow: auto;
|
|
244
|
-
border-radius: var(--border-radius);
|
|
245
|
-
.sh-code-content {
|
|
246
|
-
flex: 1;
|
|
247
|
-
display: block;
|
|
248
|
-
}
|
|
249
|
-
.sh-code-error {
|
|
250
|
-
position: absolute;
|
|
251
|
-
left: 0;
|
|
252
|
-
right: 0;
|
|
253
|
-
bottom: 0;
|
|
254
|
-
background-color: var(--
|
|
255
|
-
color: #fff;
|
|
256
|
-
padding: 0 5px;
|
|
257
|
-
font-size: 12px;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="sh-code-editor" :style="shStyles">
|
|
3
|
+
<div ref="codeMirror" class="sh-code-content" />
|
|
4
|
+
<div v-if="error" class="sh-code-error" v-html="error"></div>
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import { basicSetup } from 'codemirror'
|
|
10
|
+
import { keymap, placeholder, drawSelection, lineNumbers, EditorView } from '@codemirror/view'
|
|
11
|
+
import { Compartment, EditorState, StateEffect } from '@codemirror/state'
|
|
12
|
+
import { defaultKeymap, indentWithTab, historyKeymap, history } from '@codemirror/commands'
|
|
13
|
+
import themes from './themes'
|
|
14
|
+
import { javascript } from '@codemirror/lang-javascript'
|
|
15
|
+
import { sql } from '@codemirror/lang-sql'
|
|
16
|
+
import { json } from '@codemirror/lang-json'
|
|
17
|
+
const tabSize = new Compartment()
|
|
18
|
+
export default {
|
|
19
|
+
name: 'ShCodeEditor',
|
|
20
|
+
props: {
|
|
21
|
+
modelValue: {
|
|
22
|
+
type: [String, Object],
|
|
23
|
+
default: ''
|
|
24
|
+
},
|
|
25
|
+
option: {
|
|
26
|
+
type: Object,
|
|
27
|
+
default() {
|
|
28
|
+
return {}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
mode: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: 'javascript'
|
|
34
|
+
},
|
|
35
|
+
theme: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: ''
|
|
38
|
+
},
|
|
39
|
+
placeholder: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: ''
|
|
42
|
+
},
|
|
43
|
+
disabled: {
|
|
44
|
+
type: Boolean
|
|
45
|
+
},
|
|
46
|
+
border: {
|
|
47
|
+
type: Boolean
|
|
48
|
+
},
|
|
49
|
+
indent: {
|
|
50
|
+
type: Number,
|
|
51
|
+
default: 4
|
|
52
|
+
},
|
|
53
|
+
wrap: {
|
|
54
|
+
type: Boolean
|
|
55
|
+
},
|
|
56
|
+
tab: {
|
|
57
|
+
type: Boolean
|
|
58
|
+
},
|
|
59
|
+
multipleSelection: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: true
|
|
62
|
+
},
|
|
63
|
+
extensions: {
|
|
64
|
+
type: Array,
|
|
65
|
+
default() {
|
|
66
|
+
return []
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
width: {
|
|
70
|
+
type: [String, Number],
|
|
71
|
+
default: '100%'
|
|
72
|
+
},
|
|
73
|
+
height: {
|
|
74
|
+
type: [String, Number],
|
|
75
|
+
default: 'auto'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
emits: ['update:modelValue', 'change', 'loaded', 'focus', 'blur', 'destroy'],
|
|
79
|
+
data() {
|
|
80
|
+
return {
|
|
81
|
+
codeEditor: null,
|
|
82
|
+
codeLength: 0,
|
|
83
|
+
error: null
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
computed: {
|
|
87
|
+
shStyles() {
|
|
88
|
+
return {
|
|
89
|
+
width: this.width,
|
|
90
|
+
height: this.height,
|
|
91
|
+
border: this.border ? '1px solid var(--vxe-table-border-color)' : 'none'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
codeExtensions() {
|
|
95
|
+
const { mode, disabled, multipleSelection, indent, theme, tab, wrap, extensions } = this
|
|
96
|
+
let defaultExtensions = [basicSetup, history(), drawSelection(), lineNumbers(), placeholder(this.placeholder), keymap.of([...defaultKeymap, ...historyKeymap])]
|
|
97
|
+
if (['javascript', 'js'].includes(mode.toLowerCase())) {
|
|
98
|
+
defaultExtensions.push(javascript())
|
|
99
|
+
} else if (['mysql', 'sql'].includes(mode.toLowerCase())) {
|
|
100
|
+
defaultExtensions.push(sql())
|
|
101
|
+
} else if (['json'].includes(mode.toLowerCase())) {
|
|
102
|
+
defaultExtensions.push(json())
|
|
103
|
+
}
|
|
104
|
+
return [
|
|
105
|
+
...defaultExtensions,
|
|
106
|
+
EditorView.updateListener.of(this.updateListener),
|
|
107
|
+
EditorView.focusChangeEffect.of(this.focusListener),
|
|
108
|
+
EditorView.editable.of(!disabled),
|
|
109
|
+
EditorState.allowMultipleSelections.of(multipleSelection),
|
|
110
|
+
tabSize.of(EditorState.tabSize.of(indent)),
|
|
111
|
+
theme && themes[theme] ? themes[theme] : undefined,
|
|
112
|
+
tab ? keymap.of([indentWithTab]) : undefined,
|
|
113
|
+
wrap ? EditorView.lineWrapping : undefined,
|
|
114
|
+
...extensions
|
|
115
|
+
].filter(item => !!item)
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
watch: {
|
|
119
|
+
modelValue(value) {
|
|
120
|
+
if (this.codeEditor && !this.codeEditor.composing) {
|
|
121
|
+
let docLength = this.codeEditor.state.doc.length
|
|
122
|
+
let docValue = this.getTransformValue(value)
|
|
123
|
+
this.codeEditor.dispatch({
|
|
124
|
+
changes: { from: 0, to: docLength, insert: docValue },
|
|
125
|
+
selection: this.codeEditor.state.selection,
|
|
126
|
+
scrollIntoView: true
|
|
127
|
+
})
|
|
128
|
+
this.codeLength = docLength
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
codeExtensions: {
|
|
132
|
+
handler(exts) {
|
|
133
|
+
this.codeEditor?.dispatch({
|
|
134
|
+
effects: StateEffect.reconfigure.of(exts)
|
|
135
|
+
})
|
|
136
|
+
},
|
|
137
|
+
immediate: true
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
mounted() {
|
|
141
|
+
this.codeRender()
|
|
142
|
+
},
|
|
143
|
+
unmounted() {
|
|
144
|
+
if (this.codeEditor) this.codeEditor.destroy()
|
|
145
|
+
this.emitDestroy()
|
|
146
|
+
},
|
|
147
|
+
methods: {
|
|
148
|
+
codeRef() {
|
|
149
|
+
return this.$refs.codeMirror
|
|
150
|
+
},
|
|
151
|
+
async codeRender() {
|
|
152
|
+
const { codeRef, codeExtensions, modelValue, emitLoaded } = this
|
|
153
|
+
let docValue = this.getTransformValue(modelValue)
|
|
154
|
+
let codeState = EditorState.create({
|
|
155
|
+
doc: docValue,
|
|
156
|
+
extensions: codeExtensions
|
|
157
|
+
})
|
|
158
|
+
this.codeEditor = new EditorView({
|
|
159
|
+
parent: codeRef(),
|
|
160
|
+
state: codeState
|
|
161
|
+
})
|
|
162
|
+
await this.$nextTick()
|
|
163
|
+
emitLoaded()
|
|
164
|
+
},
|
|
165
|
+
focusListener(state, focusing) {
|
|
166
|
+
let valueStr = state.doc.toString()
|
|
167
|
+
if (focusing) {
|
|
168
|
+
this.emitFocus(valueStr)
|
|
169
|
+
} else {
|
|
170
|
+
this.emitValue(valueStr)
|
|
171
|
+
this.emitBlur(valueStr)
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
async updateListener({ state, changes, docChanged }) {
|
|
175
|
+
if (changes.empty || !docChanged) {
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
let valueStr = state.doc.toString()
|
|
179
|
+
// if (props.linter) {
|
|
180
|
+
// // Linter process
|
|
181
|
+
// if (props.forceLinting) {
|
|
182
|
+
// // If forceLinting enabled, first liting.
|
|
183
|
+
// forceLinting(view.value);
|
|
184
|
+
// }
|
|
185
|
+
// // Count diagnostics.
|
|
186
|
+
// diagnosticCount.value = (
|
|
187
|
+
// props.linter(view.value) as readonly Diagnostic[]
|
|
188
|
+
// ).length;
|
|
189
|
+
// }
|
|
190
|
+
this.emitChange(valueStr)
|
|
191
|
+
},
|
|
192
|
+
focus() {
|
|
193
|
+
this.codeEditor && this.codeEditor.focus()
|
|
194
|
+
},
|
|
195
|
+
getTransformValue(value, out) {
|
|
196
|
+
const { modelValue, indent } = this
|
|
197
|
+
let result = '',
|
|
198
|
+
error = null
|
|
199
|
+
try {
|
|
200
|
+
if (typeof modelValue === 'object' && value) {
|
|
201
|
+
result = out ? JSON.parse(value, null, indent) : JSON.stringify(value, null, indent)
|
|
202
|
+
} else {
|
|
203
|
+
result = value
|
|
204
|
+
}
|
|
205
|
+
} catch (e) {
|
|
206
|
+
error = e
|
|
207
|
+
}
|
|
208
|
+
this.error = error
|
|
209
|
+
return result
|
|
210
|
+
},
|
|
211
|
+
emitValue(value) {
|
|
212
|
+
let outValue = this.getTransformValue(value, true)
|
|
213
|
+
if (this.error) return
|
|
214
|
+
this.$emit('update:modelValue', outValue)
|
|
215
|
+
},
|
|
216
|
+
emitChange(value) {
|
|
217
|
+
this.$emit('change', { value, $event: this.codeEditor })
|
|
218
|
+
},
|
|
219
|
+
emitFocus(value) {
|
|
220
|
+
let outValue = this.getTransformValue(value, true)
|
|
221
|
+
if (this.error) return
|
|
222
|
+
this.$emit('focus', { value: outValue, $event: this.codeEditor })
|
|
223
|
+
},
|
|
224
|
+
emitBlur(value) {
|
|
225
|
+
let outValue = this.getTransformValue(value, true)
|
|
226
|
+
if (this.error) return
|
|
227
|
+
this.$emit('blur', { value: outValue, $event: this.codeEditor })
|
|
228
|
+
},
|
|
229
|
+
emitLoaded() {
|
|
230
|
+
this.$emit('loaded', { value: this.modelValue, $event: this.codeEditor })
|
|
231
|
+
},
|
|
232
|
+
emitDestroy() {
|
|
233
|
+
this.$emit('destroy', { value: this.modelValue, $event: this.codeEditor })
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
</script>
|
|
238
|
+
|
|
239
|
+
<style lang="scss" scoped>
|
|
240
|
+
.sh-code-editor {
|
|
241
|
+
display: flex;
|
|
242
|
+
position: relative;
|
|
243
|
+
overflow: auto;
|
|
244
|
+
border-radius: var(--vxe-border-radius);
|
|
245
|
+
.sh-code-content {
|
|
246
|
+
flex: 1;
|
|
247
|
+
display: block;
|
|
248
|
+
}
|
|
249
|
+
.sh-code-error {
|
|
250
|
+
position: absolute;
|
|
251
|
+
left: 0;
|
|
252
|
+
right: 0;
|
|
253
|
+
bottom: 0;
|
|
254
|
+
background-color: var(--vxe-danger-color);
|
|
255
|
+
color: #fff;
|
|
256
|
+
padding: 0 5px;
|
|
257
|
+
font-size: 12px;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
</style>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
@use 'sass:math';
|
|
2
|
+
|
|
3
|
+
$uiprefix: sh;
|
|
4
|
+
|
|
5
|
+
.#{$uiprefix}-col {
|
|
6
|
+
position: relative;
|
|
7
|
+
max-width: 100%;
|
|
8
|
+
min-height: 1px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@function percentage ($i, $sum: 24) {
|
|
12
|
+
@return math.div($i, $sum) * 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.#{$uiprefix}-col-span-0 {
|
|
16
|
+
display: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.#{$uiprefix}-col-xs-span-0 {
|
|
20
|
+
display: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@for $i from 1 through 24 {
|
|
24
|
+
.#{$uiprefix}-col-offset-#{$i} {
|
|
25
|
+
margin-left: percentage($i);
|
|
26
|
+
}
|
|
27
|
+
.#{$uiprefix}-col-pull-#{$i} {
|
|
28
|
+
right: percentage($i);
|
|
29
|
+
}
|
|
30
|
+
.#{$uiprefix}-col-push-#{$i} {
|
|
31
|
+
left: percentage($i);
|
|
32
|
+
}
|
|
33
|
+
.#{$uiprefix}-col-span-#{$i} {
|
|
34
|
+
display: block;
|
|
35
|
+
flex: 0 0 percentage($i);
|
|
36
|
+
width: percentage($i);
|
|
37
|
+
}
|
|
38
|
+
.#{$uiprefix}-col-xs-offset-#{$i} {
|
|
39
|
+
margin-left: percentage($i);
|
|
40
|
+
}
|
|
41
|
+
.#{$uiprefix}-col-xs-pull-#{$i} {
|
|
42
|
+
right: percentage($i);
|
|
43
|
+
}
|
|
44
|
+
.#{$uiprefix}-col-xs-push-#{$i} {
|
|
45
|
+
left: percentage($i);
|
|
46
|
+
}
|
|
47
|
+
.#{$uiprefix}-col-xs-span-#{$i} {
|
|
48
|
+
display: block;
|
|
49
|
+
flex: 0 0 percentage($i);
|
|
50
|
+
width: percentage($i);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@each $size, $value in (sm, 576), (md, 768), (lg, 992), (xl, 1200), (xxl, 1600) {
|
|
55
|
+
@media screen and (min-width: #{$value}px) {
|
|
56
|
+
.#{$uiprefix}-col-#{$size}-span-0 {
|
|
57
|
+
display: none;
|
|
58
|
+
}
|
|
59
|
+
@for $i from 1 through 24 {
|
|
60
|
+
.#{$uiprefix}-col-#{$size}-offset-#{$i} {
|
|
61
|
+
margin-left: percentage($i);
|
|
62
|
+
}
|
|
63
|
+
.#{$uiprefix}-col-#{$size}-pull-#{$i} {
|
|
64
|
+
right: percentage($i);
|
|
65
|
+
}
|
|
66
|
+
.#{$uiprefix}-col-#{$size}-push-#{$i} {
|
|
67
|
+
left: percentage($i);
|
|
68
|
+
}
|
|
69
|
+
.#{$uiprefix}-col-#{$size}-span-#{$i} {
|
|
70
|
+
display: block;
|
|
71
|
+
flex: 0 0 percentage($i);
|
|
72
|
+
width: percentage($i);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classes" :style="styles">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import './css/index.scss'
|
|
9
|
+
const prefixCls = 'sh-col'
|
|
10
|
+
function parseFlex(flex) {
|
|
11
|
+
if (typeof flex === 'number') {
|
|
12
|
+
return `${flex} ${flex} auto`
|
|
13
|
+
}
|
|
14
|
+
if (/^\d+(\.\d+)?(px|em|rem|%)$/.test(flex)) {
|
|
15
|
+
return `0 0 ${flex}`
|
|
16
|
+
}
|
|
17
|
+
return flex
|
|
18
|
+
}
|
|
19
|
+
export default {
|
|
20
|
+
name: 'ShCol',
|
|
21
|
+
inject: ['RowInstance'],
|
|
22
|
+
props: {
|
|
23
|
+
span: [Number, String],
|
|
24
|
+
order: [Number, String],
|
|
25
|
+
offset: [Number, String],
|
|
26
|
+
push: [Number, String],
|
|
27
|
+
pull: [Number, String],
|
|
28
|
+
xs: [Number, Object],
|
|
29
|
+
sm: [Number, Object],
|
|
30
|
+
md: [Number, Object],
|
|
31
|
+
lg: [Number, Object],
|
|
32
|
+
xl: [Number, Object],
|
|
33
|
+
xxl: [Number, Object],
|
|
34
|
+
flex: {
|
|
35
|
+
type: [Number, String],
|
|
36
|
+
default: ''
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
computed: {
|
|
40
|
+
gutter() {
|
|
41
|
+
return this.RowInstance?.gutter || 0
|
|
42
|
+
},
|
|
43
|
+
classes() {
|
|
44
|
+
let classList = [
|
|
45
|
+
`${prefixCls}`,
|
|
46
|
+
{
|
|
47
|
+
[`${prefixCls}-span-${this.span}`]: this.span,
|
|
48
|
+
[`${prefixCls}-order-${this.order}`]: this.order,
|
|
49
|
+
[`${prefixCls}-offset-${this.offset}`]: this.offset,
|
|
50
|
+
[`${prefixCls}-push-${this.push}`]: this.push,
|
|
51
|
+
[`${prefixCls}-pull-${this.pull}`]: this.pull
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
;['xs', 'sm', 'md', 'lg', 'xl', 'xxl'].forEach(size => {
|
|
55
|
+
if (typeof this[size] === 'number') {
|
|
56
|
+
classList.push(`${prefixCls}-span-${size}-${this[size]}`)
|
|
57
|
+
} else if (typeof this[size] === 'object') {
|
|
58
|
+
let props = this[size]
|
|
59
|
+
Object.keys(props).forEach(prop => {
|
|
60
|
+
classList.push(prop !== 'span' ? `${prefixCls}-${size}-${prop}-${props[prop]}` : `${prefixCls}-span-${size}-${props[prop]}`)
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
return classList
|
|
65
|
+
},
|
|
66
|
+
styles() {
|
|
67
|
+
let style = {}
|
|
68
|
+
if (this.gutter !== 0) {
|
|
69
|
+
style = {
|
|
70
|
+
paddingLeft: this.gutter / 2 + 'px',
|
|
71
|
+
paddingRight: this.gutter / 2 + 'px'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (this.flex) {
|
|
75
|
+
style.flex = parseFlex(this.flex)
|
|
76
|
+
}
|
|
77
|
+
return style
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<style scoped lang="scss"></style>
|