w-table-vue 1.0.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/.editorconfig +9 -0
- package/.eslintignore +3 -0
- package/.eslintrc.js +55 -0
- package/.jsdoc +25 -0
- package/LICENSE +21 -0
- package/README.md +109 -0
- package/SECURITY.md +5 -0
- package/babel.config.js +16 -0
- package/dist/w-table-vue.umd.js +7 -0
- package/dist/w-table-vue.umd.js.map +1 -0
- package/docs/examples/app.html +63 -0
- package/docs/examples/app.umd.js +7 -0
- package/docs/examples/app.umd.js.map +1 -0
- package/docs/examples/w-table-edit_default.html +525 -0
- package/docs/examples/w-table-edit_editable.html +528 -0
- package/docs/examples/w-table-edit_editable_checkId.html +529 -0
- package/docs/examples/w-table-edit_editable_checkId_opt.modifyDataWhenSave_save(call cmp. method).html +544 -0
- package/docs/examples/w-table-edit_editable_checkId_successMsgFromAddRow_errorMsgFromAddRow.html +539 -0
- package/docs/examples/w-table-edit_editable_inforPaddingStyle_menuBackgroundColor.html +534 -0
- package/docs/examples/w-table-edit_editable_language_checkId_tooltipAddRow.html +540 -0
- package/docs/examples/w-table-edit_editable_language_textLabelDataName_textPlaceholderDataName.html +535 -0
- package/docs/examples/w-table-edit_editable_no enableInfor.html +529 -0
- package/docs/examples/w-table-edit_editable_no enableMenu.html +529 -0
- package/docs/examples/w-table-edit_editable_opt.beforeAddRow.html +528 -0
- package/docs/examples/w-table-edit_editable_opt.kpConvertKeysWhenUploadData.html +528 -0
- package/docs/examples/w-table-edit_editable_opt.optForUploadData.html +528 -0
- package/docs/examples/w-table-edit_editable_slot btns-right.html +552 -0
- package/docs/examples/w-table-edit_fixIds (fix id).html +529 -0
- package/docs/examples/w-table-edit_hideIds (hide mappingId).html +529 -0
- package/docs/examples/w-table-edit_name_description.html +527 -0
- package/docs/examples/w-table-edit_no enableInfor.html +528 -0
- package/docs/examples/w-table-edit_no enableMenu.html +528 -0
- package/docs/examples/w-table-edit_opt.kpHead.html +527 -0
- package/docs/examples/w-table-edit_removeIdsWhenDownload (remove id, mappingId, order, isActive).html +530 -0
- package/docs/examples/w-table-edit_slot btns-left.html +551 -0
- package/docs/examples/w-table-edit_slot btns-right.html +551 -0
- package/docs/examples/w-table-edit_slot infor (name_description).html +544 -0
- package/docs/examples/w-table-edit_sortColIds (sort by order).html +528 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/index.html +84 -0
- package/docs/module-WTableEdit.html +1486 -0
- package/docs/scripts/collapse.js +39 -0
- package/docs/scripts/commonNav.js +28 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/nav.js +12 -0
- package/docs/scripts/polyfill.js +4 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/scripts/search.js +99 -0
- package/docs/styles/jsdoc.css +776 -0
- package/docs/styles/prettify.css +80 -0
- package/package.json +66 -0
- package/public/index.html +25 -0
- package/script.txt +24 -0
- package/src/App.vue +322 -0
- package/src/AppZoneWTableEdit.vue +740 -0
- package/src/components/WTableEdit.vue +1278 -0
- package/src/components/WTableVue.vue +12 -0
- package/src/components/demolink.vue +105 -0
- package/src/main.js +8 -0
- package/test/all.test.mjs +10 -0
- package/toolg/addVersion.mjs +4 -0
- package/toolg/cleanFolder.mjs +5 -0
- package/toolg/cvCasename.mjs +43 -0
- package/toolg/gDistApp.mjs +38 -0
- package/toolg/gDistRollupComps.mjs +23 -0
- package/toolg/gDocExams.mjs +47 -0
- package/toolg/gExtractHtml.mjs +268 -0
- package/toolg/gMergeComps.mjs +75 -0
- package/toolg/modifyReadme.mjs +4 -0
- package/vue.config.js +9 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="item">
|
|
3
|
+
|
|
4
|
+
<div style="display:inline-block;">
|
|
5
|
+
{{casename}}
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<div style="padding-left:5px;"></div>
|
|
9
|
+
|
|
10
|
+
<w-button-circle
|
|
11
|
+
:paddingStyle="{v:3,h:3}"
|
|
12
|
+
:icon="mdiLaunch"
|
|
13
|
+
:iconSize="16"
|
|
14
|
+
:iconColor="'red darken-1'"
|
|
15
|
+
:iconColorHover="'red darken-1'"
|
|
16
|
+
:iconColorFocus="'red darken-1'"
|
|
17
|
+
:backgroundColor="'#fff'"
|
|
18
|
+
:backgroundColorHover="'#fff5f5'"
|
|
19
|
+
:backgroundColorFocus="'#fff2f2'"
|
|
20
|
+
:tooltip="'example'"
|
|
21
|
+
@click="ckExample"
|
|
22
|
+
></w-button-circle>
|
|
23
|
+
|
|
24
|
+
<div style="padding-left:5px;"></div>
|
|
25
|
+
|
|
26
|
+
<w-button-circle
|
|
27
|
+
:paddingStyle="{v:3,h:3}"
|
|
28
|
+
:icon="mdiUnfoldMoreVertical"
|
|
29
|
+
:iconSize="16"
|
|
30
|
+
:iconColor="'red darken-1'"
|
|
31
|
+
:iconColorHover="'red darken-1'"
|
|
32
|
+
:iconColorFocus="'red darken-1'"
|
|
33
|
+
:backgroundColor="'#fff'"
|
|
34
|
+
:backgroundColorHover="'#fff5f5'"
|
|
35
|
+
:backgroundColorFocus="'#fff2f2'"
|
|
36
|
+
:tooltip="'code'"
|
|
37
|
+
@click="ckCode"
|
|
38
|
+
></w-button-circle>
|
|
39
|
+
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
import { mdiLaunch, mdiUnfoldMoreVertical } from '@mdi/js'
|
|
45
|
+
import cvCasename from '../../toolg/cvCasename.mjs'
|
|
46
|
+
import WButtonCircle from 'w-component-vue/src/components/WButtonCircle.vue'
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export default {
|
|
50
|
+
components: {
|
|
51
|
+
WButtonCircle,
|
|
52
|
+
},
|
|
53
|
+
props: {
|
|
54
|
+
kbname: {
|
|
55
|
+
type: String,
|
|
56
|
+
},
|
|
57
|
+
casename: {
|
|
58
|
+
type: String,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
data: function() {
|
|
62
|
+
return {
|
|
63
|
+
mdiLaunch,
|
|
64
|
+
mdiUnfoldMoreVertical
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
mounted: function() {
|
|
68
|
+
},
|
|
69
|
+
computed: {
|
|
70
|
+
|
|
71
|
+
fn: function() {
|
|
72
|
+
let fnc = `${this.casename}`
|
|
73
|
+
return `${this.kbname}_${cvCasename(fnc)}`
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
},
|
|
77
|
+
methods: {
|
|
78
|
+
|
|
79
|
+
ckExample: function() {
|
|
80
|
+
let vo = this
|
|
81
|
+
let url = 'https://yuda-lyu.github.io/w-table-vue/examples/' + vo.fn + '.html'
|
|
82
|
+
window.open(url, '_blank')
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
ckCode: function() {
|
|
86
|
+
let vo = this
|
|
87
|
+
let url = 'https://github.com/yuda-lyu/w-table-vue/blob/master/docs/examples/' + vo.fn + '.html'
|
|
88
|
+
window.open(url, '_blank')
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<style scoped>
|
|
96
|
+
.item {
|
|
97
|
+
border-left: 3px solid #ffba75;
|
|
98
|
+
margin: 5px 5px 8px 0px;
|
|
99
|
+
padding: 3px 3px 5px 10px;
|
|
100
|
+
font-size: 0.9rem;
|
|
101
|
+
display: flex;
|
|
102
|
+
justify-content: flex-start;
|
|
103
|
+
align-items: center;
|
|
104
|
+
}
|
|
105
|
+
</style>
|
package/src/main.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import map from 'lodash-es/map.js'
|
|
2
|
+
import trim from 'lodash-es/trim.js'
|
|
3
|
+
import filter from 'lodash-es/filter.js'
|
|
4
|
+
import toUpper from 'lodash-es/toUpper.js'
|
|
5
|
+
import split from 'lodash-es/split.js'
|
|
6
|
+
import size from 'lodash-es/size.js'
|
|
7
|
+
import join from 'lodash-es/join.js'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
function seCut(str) {
|
|
11
|
+
|
|
12
|
+
//split
|
|
13
|
+
let s = split(str, '&')
|
|
14
|
+
|
|
15
|
+
//trim
|
|
16
|
+
s = map(s, function(v) {
|
|
17
|
+
return trim(v)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
//n
|
|
21
|
+
let n = size(s)
|
|
22
|
+
n = Math.min(4, n)
|
|
23
|
+
|
|
24
|
+
//r
|
|
25
|
+
let r = []
|
|
26
|
+
for (let i = 0; i < n; i++) {
|
|
27
|
+
r.push(s[i])
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//join
|
|
31
|
+
let c = join(r, '_')
|
|
32
|
+
|
|
33
|
+
return c
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
function cvCasename(casename) {
|
|
38
|
+
//return seEncode(casename)
|
|
39
|
+
return seCut(casename)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
export default cvCasename
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import rollupVueToHtml from 'w-package-tools/src/rollupVueToHtml.mjs'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
let opt = {
|
|
5
|
+
title: `w-table-vue`,
|
|
6
|
+
head: `
|
|
7
|
+
|
|
8
|
+
<!-- rollupVueToHtml已自動添加@babel/polyfill與vue -->
|
|
9
|
+
|
|
10
|
+
<!-- fontawesome -->
|
|
11
|
+
<link href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.2/css/all.min.css" rel="stylesheet">
|
|
12
|
+
|
|
13
|
+
<!-- mdi, 各組件使用mdi/js故不需引用 -->
|
|
14
|
+
<link _href="https://cdn.jsdelivr.net/npm/@mdi/font@7.4.47/css/materialdesignicons.min.css" rel="stylesheet">
|
|
15
|
+
|
|
16
|
+
<!-- google, 各組件使用mdi/js故不需引用 -->
|
|
17
|
+
<link _href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
|
|
18
|
+
<link _href="https://fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet">
|
|
19
|
+
|
|
20
|
+
<!-- xlsx, w-aggrid-vue的download與upload會使用 -->
|
|
21
|
+
<script src="https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js"></script>
|
|
22
|
+
|
|
23
|
+
<!-- ag-grid, ag-grid-vue無法被rollup編譯, 須由cdn引入, 且其依賴window.agGrid -->
|
|
24
|
+
<script src="https://cdn.jsdelivr.net/npm/ag-grid-community@31.3.4/dist/ag-grid-community.min.noStyle.js"></script>
|
|
25
|
+
<script src="https://cdn.jsdelivr.net/npm/ag-grid-vue@31.3.4/dist/ag-grid-vue.umd.min.js"></script>
|
|
26
|
+
|
|
27
|
+
`,
|
|
28
|
+
globals: {
|
|
29
|
+
'vue': 'Vue', //因動態加載組件, 現統一使用window內Vue, 故此處不打包進來, 若vue-cli則自動將Vue關聯至window內的Vue
|
|
30
|
+
'ag-grid-vue': 'ag-grid-vue', //ag-grid-vue會再引用vue-class-component與vue-property-decorator, 無法被rollup編譯, 故不打包進來, 須由外部cdn引入, 其umd會掛於window['ag-grid-vue']
|
|
31
|
+
},
|
|
32
|
+
external: [
|
|
33
|
+
'vue',
|
|
34
|
+
'ag-grid-vue',
|
|
35
|
+
],
|
|
36
|
+
}
|
|
37
|
+
rollupVueToHtml('./src/App.vue', './docs/examples/app.html', opt)
|
|
38
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _ from 'lodash-es'
|
|
2
|
+
import rollupFiles from 'w-package-tools/src/rollupFiles.mjs'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
let fdSrc = './src/components/'
|
|
6
|
+
let fdTar = './dist'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
rollupFiles({
|
|
10
|
+
fns: 'WTableVue.vue',
|
|
11
|
+
fdSrc,
|
|
12
|
+
fdTar,
|
|
13
|
+
nameDistType: 'kebabCase',
|
|
14
|
+
globals: {
|
|
15
|
+
'vue': 'Vue', //因動態加載組件, 現統一使用window內Vue, 故此處不打包進來, 若vue-cli則自動將Vue關聯至window內的Vue
|
|
16
|
+
'ag-grid-vue': 'ag-grid-vue', //ag-grid-vue會再引用vue-class-component與vue-property-decorator, 無法被rollup編譯, 故不打包進來, 須由外部cdn引入, 其umd會掛於window['ag-grid-vue']
|
|
17
|
+
},
|
|
18
|
+
external: [
|
|
19
|
+
'vue',
|
|
20
|
+
'ag-grid-vue',
|
|
21
|
+
],
|
|
22
|
+
})
|
|
23
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import _ from 'lodash-es'
|
|
3
|
+
import getFiles from 'w-package-tools/src/getFiles.mjs'
|
|
4
|
+
import getPks from 'w-package-tools/src/getPks.mjs'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
let fdSrc = './test-html/'
|
|
8
|
+
let fdTar = './docs/examples/'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
function main() {
|
|
12
|
+
//把example裡面cdn更換, 再複製到docs的example內, 作為日後發佈為靜態網站
|
|
13
|
+
|
|
14
|
+
//pks
|
|
15
|
+
let pks = getPks()
|
|
16
|
+
|
|
17
|
+
//cdn
|
|
18
|
+
let cdn = `<script src="https://cdn.jsdelivr.net/npm/w-table-vue@${pks.version}/dist/w-table-vue.umd.js"></script>`
|
|
19
|
+
|
|
20
|
+
//mkdirSync
|
|
21
|
+
if (!fs.existsSync(fdTar)) {
|
|
22
|
+
fs.mkdirSync(fdTar)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//getFiles
|
|
26
|
+
let ltfs = getFiles(fdSrc)
|
|
27
|
+
|
|
28
|
+
_.each(ltfs, function(v) {
|
|
29
|
+
|
|
30
|
+
//fn
|
|
31
|
+
let fn = fdSrc + v
|
|
32
|
+
|
|
33
|
+
//c
|
|
34
|
+
let c = fs.readFileSync(fn, 'utf8')
|
|
35
|
+
|
|
36
|
+
//replace
|
|
37
|
+
let r = `<script src="../dist/w-table-vue.umd.js"></script>`
|
|
38
|
+
c = c.replace(r, cdn)
|
|
39
|
+
|
|
40
|
+
//write
|
|
41
|
+
//console.log(c)
|
|
42
|
+
fs.writeFileSync(fdTar + v, c, 'utf8')
|
|
43
|
+
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
main()
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as cheerio from 'cheerio'
|
|
3
|
+
import _ from 'lodash-es'
|
|
4
|
+
import w from 'wsemi'
|
|
5
|
+
import getFiles from 'w-package-tools/src/getFiles.mjs'
|
|
6
|
+
import cleanFolder from 'w-package-tools/src/cleanFolder.mjs'
|
|
7
|
+
import parseVueCode from 'w-package-tools/src/parseVueCode.mjs'
|
|
8
|
+
import kebabPropsVueTemp from 'w-package-tools/src/kebabPropsVueTemp.mjs'
|
|
9
|
+
import extractHtml from 'w-package-tools/src/extractHtml.mjs'
|
|
10
|
+
import cvCasename from './cvCasename.mjs'
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
let fdSrc = './src/'
|
|
14
|
+
let fdTestHtml = './test-html/'
|
|
15
|
+
let fdTestSrc = './test-action/'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
let $setting = {
|
|
19
|
+
//ignoreWhitespace: true,
|
|
20
|
+
xmlMode: false, //不能設定true, 否則會導致vue組件名稱變成self-closing, 此於瀏覽器指定html5規範下無法解析
|
|
21
|
+
decodeEntities: false,
|
|
22
|
+
// recognizeSelfClosing: false, //若xmlMode為true則recognizeSelfClosing必定為true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
function writeHtml(v) {
|
|
27
|
+
|
|
28
|
+
function getAppTmp() {
|
|
29
|
+
|
|
30
|
+
//h
|
|
31
|
+
let h = v.tmp
|
|
32
|
+
// console.log('h', w.strleft(h, 100) + '...')
|
|
33
|
+
|
|
34
|
+
//$
|
|
35
|
+
let $ = cheerio.load(h, $setting)
|
|
36
|
+
|
|
37
|
+
//移除demolink
|
|
38
|
+
$('demolink').remove()
|
|
39
|
+
|
|
40
|
+
//於bk前插入, 添加組件kbname
|
|
41
|
+
$('div.bk').before(`<div class="head1"><span style="cursor:pointer;" title="open for copy link to view component" onclick="window.open('//yuda-lyu.github.io/w-table-vue/examples/app.html?cmp='+this.innerText,'_blank')">${v.kbname}</span></div>`)
|
|
42
|
+
|
|
43
|
+
//於bk內插入, 添加範例casename
|
|
44
|
+
$('div.bk').prepend(`<div class="item">${v.casename}</div>`)
|
|
45
|
+
|
|
46
|
+
//to html
|
|
47
|
+
h = $('body').html()
|
|
48
|
+
// console.log('getAppTmp', w.strleft(h, 100) + '...')
|
|
49
|
+
|
|
50
|
+
return h
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function procHtml(h) {
|
|
54
|
+
|
|
55
|
+
//replace mdi-icon
|
|
56
|
+
let r = `mdi[A-Za-z]+` //有些mdi是放在元素attr內, 有些是放在vue data內, 故不能包含雙引號(限定attr)查找
|
|
57
|
+
let reg = new RegExp(r, 'g')
|
|
58
|
+
let mdis = h.match(reg)
|
|
59
|
+
if (mdis) {
|
|
60
|
+
_.each(mdis, (mdi) => {
|
|
61
|
+
let c = mdi
|
|
62
|
+
c = _.kebabCase(c) //轉kebab
|
|
63
|
+
c = `'${c}'` //添加單引號成為字串
|
|
64
|
+
h = h.replace(mdi, c) //取代
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return h
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//opt
|
|
72
|
+
let opt = {
|
|
73
|
+
title: `w-table-vue`,
|
|
74
|
+
head: `
|
|
75
|
+
|
|
76
|
+
<!-- extractHtml已自動添加@babel/polyfill與vue -->
|
|
77
|
+
|
|
78
|
+
<!-- fontawesome -->
|
|
79
|
+
<link href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.2/css/all.min.css" rel="stylesheet">
|
|
80
|
+
|
|
81
|
+
<!-- mdi, 各組件使用mdi/js會於轉單頁時改為mdi icon, 故需引用mdi/css -->
|
|
82
|
+
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@7.4.47/css/materialdesignicons.min.css" rel="stylesheet">
|
|
83
|
+
|
|
84
|
+
<!-- google, 各組件使用mdi/js故不需引用 -->
|
|
85
|
+
<link _href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
|
|
86
|
+
<link _href="https://fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet">
|
|
87
|
+
|
|
88
|
+
<!-- xlsx, w-aggrid-vue的download與upload會使用 -->
|
|
89
|
+
<script src="https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js"></script>
|
|
90
|
+
|
|
91
|
+
<!-- ag-grid, ag-grid-vue無法被rollup編譯, 須由cdn引入, 且其依賴window.agGrid -->
|
|
92
|
+
<script src="https://cdn.jsdelivr.net/npm/ag-grid-community@31.3.4/dist/ag-grid-community.min.noStyle.js"></script>
|
|
93
|
+
<script src="https://cdn.jsdelivr.net/npm/ag-grid-vue@31.3.4/dist/ag-grid-vue.umd.min.js"></script>
|
|
94
|
+
|
|
95
|
+
<!-- w-table-vue -->
|
|
96
|
+
<script src="../dist/w-table-vue.umd.js"></script>
|
|
97
|
+
|
|
98
|
+
<style>
|
|
99
|
+
.item { /* 因item位於demolink, 提取各範例html後會刪除demolink, 故得額外補上 */
|
|
100
|
+
border-left: 3px solid #ffba75;
|
|
101
|
+
margin: 5px 5px 8px 0px;
|
|
102
|
+
padding: 3px 3px 5px 10px;
|
|
103
|
+
font-size: 0.9rem;
|
|
104
|
+
display: flex;
|
|
105
|
+
justify-content: flex-start;
|
|
106
|
+
align-items: center;
|
|
107
|
+
}
|
|
108
|
+
.head1 {
|
|
109
|
+
padding: 0px 0px 20px 0px;
|
|
110
|
+
font-size: 2.5rem;
|
|
111
|
+
}
|
|
112
|
+
.bkh { /* 寬 */
|
|
113
|
+
padding:20px;
|
|
114
|
+
}
|
|
115
|
+
@media screen and (max-width:800px){ /* 中 */
|
|
116
|
+
.bkh {
|
|
117
|
+
padding:10px;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
@media screen and (max-width:400px){ /* 窄 */
|
|
121
|
+
.bkh {
|
|
122
|
+
padding:5px;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
.bk { /* 寬 */
|
|
126
|
+
display: inline-block;
|
|
127
|
+
vertical-align: top;
|
|
128
|
+
padding: 0px 80px 60px 0px;
|
|
129
|
+
}
|
|
130
|
+
@media screen and (max-width:1000px){ /* 中窄 */
|
|
131
|
+
.bk {
|
|
132
|
+
display: block;
|
|
133
|
+
padding: 0px 0px 50px 0px;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
</style>
|
|
137
|
+
|
|
138
|
+
`,
|
|
139
|
+
appTag: `div`,
|
|
140
|
+
appClass: `bkh`,
|
|
141
|
+
appStyle: ``,
|
|
142
|
+
appTmp: getAppTmp(),
|
|
143
|
+
installVue: `Vue.use(window['w-table-vue'])`,
|
|
144
|
+
data: v.data,
|
|
145
|
+
mounted: v.mounted,
|
|
146
|
+
computed: v.computed,
|
|
147
|
+
methods: v.methods,
|
|
148
|
+
action: v.action,
|
|
149
|
+
procHtml,
|
|
150
|
+
fpHtml: `${fdTestHtml}${v.fn}.html`,
|
|
151
|
+
fpAction: `${fdTestSrc}${v.fn}.action.json`,
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
//extractHtml
|
|
155
|
+
extractHtml(opt)
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
function extractAppZone(fn) {
|
|
161
|
+
|
|
162
|
+
//read
|
|
163
|
+
let hh = fs.readFileSync(fn, 'utf8')
|
|
164
|
+
// console.log('hh', hh)
|
|
165
|
+
|
|
166
|
+
//parseVueCode
|
|
167
|
+
let { tmp, data, mounted, computed, methods, action } = parseVueCode(hh)
|
|
168
|
+
|
|
169
|
+
//vue屬性轉kebab, 記得要在cheerio處理前, 否則attr都會被改成小寫
|
|
170
|
+
tmp = kebabPropsVueTemp(tmp)
|
|
171
|
+
tmp = w.replace(tmp, `=""`, '')
|
|
172
|
+
// console.log('tmp', w.strleft(tmp, 100) + '...')
|
|
173
|
+
|
|
174
|
+
//$
|
|
175
|
+
let $ = cheerio.load(tmp, $setting)
|
|
176
|
+
// console.log(`$('div.bk').html()`, w.strleft($('div.bk').html(), 100) + '...')
|
|
177
|
+
|
|
178
|
+
//name
|
|
179
|
+
let name = fn.split('AppZone')
|
|
180
|
+
name = name[1]
|
|
181
|
+
name = name.replace('.vue', '')
|
|
182
|
+
|
|
183
|
+
//clear data
|
|
184
|
+
let ss = data.split('\r\n')
|
|
185
|
+
ss = _.filter(ss, (s) => {
|
|
186
|
+
return s.indexOf(' mdi') < 0 //去除@mdi/js icon
|
|
187
|
+
})
|
|
188
|
+
ss = _.map(ss, (v, k) => {
|
|
189
|
+
if (k === 0) {
|
|
190
|
+
return v
|
|
191
|
+
}
|
|
192
|
+
return ` ${v}`
|
|
193
|
+
})
|
|
194
|
+
data = ss.join('\r\n')
|
|
195
|
+
//console.log('data', data)
|
|
196
|
+
|
|
197
|
+
function getAttr(h, name) {
|
|
198
|
+
// console.log('getAttr', h, name)
|
|
199
|
+
let $ = cheerio.load(h, $setting)
|
|
200
|
+
let c = $('demolink').attr(':' + name)
|
|
201
|
+
c = w.replace(c, `\'`, '')
|
|
202
|
+
return c
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
//取各個bk, 先於各bk外層添加shell在取html, 才能取到bk含自己的html
|
|
206
|
+
$('div.bk').wrap('<div class="shell"></div>')
|
|
207
|
+
$('div.shell').map((i, v) => {
|
|
208
|
+
// console.log('v', v)
|
|
209
|
+
|
|
210
|
+
//me
|
|
211
|
+
let me = $(v)
|
|
212
|
+
// console.log(i, 'me', me)
|
|
213
|
+
|
|
214
|
+
//tmp
|
|
215
|
+
let tmp = me.html()
|
|
216
|
+
// console.log(i, 'tmp', tmp)
|
|
217
|
+
|
|
218
|
+
//ss
|
|
219
|
+
let kbname = getAttr(tmp, 'kbname')
|
|
220
|
+
let casename = getAttr(tmp, 'casename')
|
|
221
|
+
// console.log(i, kbname, ',', casename)
|
|
222
|
+
|
|
223
|
+
//fn
|
|
224
|
+
let fnc = `${casename}`
|
|
225
|
+
let fn = `${kbname}_${cvCasename(fnc)}`
|
|
226
|
+
|
|
227
|
+
//writeHtml
|
|
228
|
+
writeHtml({ name, kbname, casename, tmp, data, mounted, computed, methods, action, fn })
|
|
229
|
+
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
function main() {
|
|
236
|
+
//由jsdoc產製之wsemi.html, 自動添加將example轉換成codepen線上編輯功能
|
|
237
|
+
|
|
238
|
+
//fdTestHtml
|
|
239
|
+
cleanFolder(fdTestHtml)
|
|
240
|
+
//fs.mkdirSync(fdTestHtml)
|
|
241
|
+
//await fs.promises.mkdir(fdTestHtml)
|
|
242
|
+
|
|
243
|
+
//fdTestSrc
|
|
244
|
+
cleanFolder(fdTestSrc)
|
|
245
|
+
//fs.mkdirSync(fdTestSrc)
|
|
246
|
+
//await fs.promises.mkdir(fdTestSrc)
|
|
247
|
+
|
|
248
|
+
//getFiles
|
|
249
|
+
let ltfs = getFiles(fdSrc)
|
|
250
|
+
|
|
251
|
+
//filter
|
|
252
|
+
ltfs = _.filter(ltfs, (v) => {
|
|
253
|
+
return v.indexOf('AppZone') >= 0
|
|
254
|
+
})
|
|
255
|
+
// ltfs = [
|
|
256
|
+
// 'AppZoneWJsonView.vue',
|
|
257
|
+
// ]
|
|
258
|
+
// console.log(ltfs)
|
|
259
|
+
|
|
260
|
+
//extractAppZone
|
|
261
|
+
_.each(ltfs, (v) => {
|
|
262
|
+
let fn = fdSrc + v
|
|
263
|
+
console.log('extracting: ' + fn)
|
|
264
|
+
extractAppZone(fn)
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
}
|
|
268
|
+
main()
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import _ from 'lodash-es'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import w from 'wsemi'
|
|
4
|
+
import getFiles from 'w-package-tools/src/getFiles.mjs'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
let fdSrc = './src/components/'
|
|
8
|
+
let fn_tar = 'WTableVue.vue'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
function main() {
|
|
12
|
+
//讀取components裡面組件, 自動生成WTableVue, 供rollup打包整體組件
|
|
13
|
+
|
|
14
|
+
//getFiles
|
|
15
|
+
let ltfs = getFiles(fdSrc)
|
|
16
|
+
_.pull(ltfs, fn_tar)
|
|
17
|
+
_.pull(ltfs, 'demolink.vue')
|
|
18
|
+
|
|
19
|
+
//c1, c2
|
|
20
|
+
let c1 = []
|
|
21
|
+
let c2 = []
|
|
22
|
+
_.each(ltfs, function(v) {
|
|
23
|
+
|
|
24
|
+
//name_all
|
|
25
|
+
let name_all = v
|
|
26
|
+
|
|
27
|
+
//s
|
|
28
|
+
let s = _.split(v, '.')
|
|
29
|
+
|
|
30
|
+
//name_ori
|
|
31
|
+
let name_ori = s[0]
|
|
32
|
+
|
|
33
|
+
//name_ext
|
|
34
|
+
let name_ext = s[1]
|
|
35
|
+
|
|
36
|
+
//name_ori, name_kb
|
|
37
|
+
let name_kb = _.kebabCase(name_ori)
|
|
38
|
+
|
|
39
|
+
//c1
|
|
40
|
+
c1.push(`import ${name_ori} from './${name_all}'`)
|
|
41
|
+
|
|
42
|
+
//c2
|
|
43
|
+
if (name_ext === 'vue') {
|
|
44
|
+
c2.push(` Vue.component('${name_kb}', ${name_ori})`)
|
|
45
|
+
}
|
|
46
|
+
else if (name_ext === 'mjs') {
|
|
47
|
+
let funName = _.toLower(name_ori)
|
|
48
|
+
funName = '$' + w.strdelleft(funName, 1)
|
|
49
|
+
c2.push(` Vue.prototype.${funName} = ${name_ori}`)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
//c
|
|
55
|
+
let c =
|
|
56
|
+
`<script>
|
|
57
|
+
${_.join(c1, '\r\n')}
|
|
58
|
+
|
|
59
|
+
let WTableVue = {
|
|
60
|
+
install: function(Vue) {
|
|
61
|
+
${_.join(c2, '\r\n')}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default WTableVue
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
`
|
|
69
|
+
|
|
70
|
+
//write
|
|
71
|
+
//console.log(c)
|
|
72
|
+
fs.writeFileSync(fdSrc + fn_tar, c, 'utf8')
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
main()
|