From a0f26f77cdc26cc3cc405e96f642eb50a25447ea Mon Sep 17 00:00:00 2001 From: 4Ark Date: Wed, 30 Sep 2020 15:37:27 +0800 Subject: [PATCH 1/4] chore: docs directory (#19) --- .gitignore | 5 +++-- {docs-md => docs}/basic.md | 0 styleguide.config.js | 31 ++++++++++++++++++++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) rename {docs-md => docs}/basic.md (100%) diff --git a/.gitignore b/.gitignore index b714fea..ee981cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ .DS_Store node_modules /dist +docs/build +docs/fonts +docs/index.html # local env files .env.local @@ -20,5 +23,3 @@ pnpm-debug.log* *.njsproj *.sln *.sw? - -docs diff --git a/docs-md/basic.md b/docs/basic.md similarity index 100% rename from docs-md/basic.md rename to docs/basic.md diff --git a/styleguide.config.js b/styleguide.config.js index 2f8e8d1..84ca2ba 100644 --- a/styleguide.config.js +++ b/styleguide.config.js @@ -4,7 +4,7 @@ const glob = require('glob') module.exports = { title: 'v-gantt 文档', - styleguideDir: 'docs', // 每次构建会清除掉内容,所以文档不能放在里面 + styleguideDir: 'docs', version: require('./package.json').version, pagePerSection: true, ribbon: { @@ -20,12 +20,33 @@ module.exports = { { name: 'Demo', sections: glob - .sync('docs-md/*.md') + .sync('docs/*.md') .map((p) => ({ name: path.basename(p, '.md'), content: p })), }, ], - // webpackConfig: { - // // custom config goes here - // }, exampleMode: 'expand', + dangerouslyUpdateWebpackConfig(webpackConfig) { + /** + * @see https://vue-styleguidist.github.io/Configuration.html#dangerouslyupdatewebpackconfig + * + * 官方不推荐使用这个方法,因为随意修改 webpack 配置可能导致 styleguidist 无法正常运行 + * 但由于每次构建都删除 docs 下的所有文件,且不支持自定义 CleanWebpackPlugin 选项 + * 最终只能采用这种方式,使它构建时不删除 .md 文件 + */ + if (webpackConfig.plugins) { + for (const plugin of webpackConfig.plugins) { + const isCleanWebpackPlugin = 'cleanOnceBeforeBuildPatterns' in plugin + + if (!isCleanWebpackPlugin) continue + + const isCleanAll = plugin.cleanOnceBeforeBuildPatterns.includes('**/*') + + if (isCleanAll) { + plugin.cleanOnceBeforeBuildPatterns.push('!*.md') + } + } + } + + return webpackConfig + }, } From 180bbd30241de9cb713f146ca60eac4f18bcf423 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 30 Sep 2020 15:41:59 +0800 Subject: [PATCH 2/4] docs: add gd4Ark as a contributor (#20) --- .all-contributorsrc | 10 ++++++++++ README.md | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index f6e3f6e..1ad5c38 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -21,6 +21,16 @@ "tool", "design" ] + }, + { + "login": "gd4Ark", + "name": "4Ark", + "avatar_url": "https://avatars0.githubusercontent.com/u/27952659?v=4", + "profile": "https://4ark.me", + "contributions": [ + "doc", + "maintenance" + ] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index c65e2ba..ae60f78 100644 --- a/README.md +++ b/README.md @@ -151,12 +151,12 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d +

Donald Shen

💻 📝 🔧 🎨

4Ark

📖 🚧
- This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! From e7f9c62864247656d38e4c5bb3c64518c9a07c48 Mon Sep 17 00:00:00 2001 From: 4Ark Date: Wed, 30 Sep 2020 16:55:52 +0800 Subject: [PATCH 3/4] =?UTF-8?q?docs:=20=E4=BF=AE=E6=AD=A3=20readme.md=20?= =?UTF-8?q?=E8=AF=AD=E6=B3=95=20(#21)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README-zh.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-zh.md b/README-zh.md index c634b4c..ab1faa0 100644 --- a/README-zh.md +++ b/README-zh.md @@ -106,7 +106,7 @@ yarn dev - 修复更改 rowH 时未改变树节点高度的问题 - 支持进度修改功能 - 支持修改里程碑完成状态 -- 修复使用 rollup 打包时, 组件丢失对 的引用的问题 +- 修复使用 rollup 打包时,`` 组件丢失对 `` 的引用的问题 [⬆ Back to Top](#table-of-contents) diff --git a/README.md b/README.md index ae60f78..a946a09 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ yarn dev - fix 'rowH' doesn't inpact tree nodes - support drag to change progress - support click to toggle milestone -- lost in when compile with rollup +- lost `` in `` when compile with rollup [⬆ Back to Top](#table-of-contents) From 4588ed5f698b9baec9f85cf108ed5888d4f6f7a3 Mon Sep 17 00:00:00 2001 From: 4Ark Date: Wed, 11 Nov 2020 04:28:06 -0600 Subject: [PATCH 4/4] feat: add types (#22) --- docs/faq.md | 13 +++++ package.json | 1 + src/index.d.ts | 124 +++++++++++++++++++++++++++++++++++++++++++ styleguide.config.js | 47 +++++++++++----- 4 files changed, 172 insertions(+), 13 deletions(-) create mode 100644 docs/faq.md create mode 100644 src/index.d.ts diff --git a/docs/faq.md b/docs/faq.md new file mode 100644 index 0000000..b8af48f --- /dev/null +++ b/docs/faq.md @@ -0,0 +1,13 @@ +## 在 TypeScript 中指定组件的类型 + +```html + +``` diff --git a/package.json b/package.json index 892838d..25da92d 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "browser": { "./sfc": "src/index.vue" }, + "types": "src/index.d.ts", "scripts": { "dev": "vue-cli-service styleguidist", "build": "yarn build:umd & yarn build:esm & yarn doc", diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..c5c44f5 --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,124 @@ +import { + GanttPropData, + GanttData, + GanttItem, + CollapsedMap, + GanttPropNode, + Bus, + GanttNode, + ColUnit, +} from './utils/types' +import Vue, { VueConstructor, PropType } from 'vue' + +declare module '@femessage/v-gantt' { + class FemessageComponent extends Vue { + static install(vue: typeof Vue): void + } + + type CombinedVueInstance< + Instance extends Vue, + Data, + Methods, + Computed, + Props + > = Data & Methods & Computed & Props & Instance + + type ExtendedVue< + Instance extends Vue, + Data, + Methods, + Computed, + Props + > = VueConstructor< + CombinedVueInstance & Vue + > + + type Combined = Data & + Methods & + Computed & + Props + + type VGanttData = { + collapsedMap: CollapsedMap + + scrollTop: number + + dragData: { + node: null | GanttNode + movedCols: number + } + + resizeData: { + node: null | GanttNode + resizedCols: number + } + + bus: Bus + } + + type VGanttMethods = { + initBus: () => void + + onDelete: ({ + id, + done, + }: { + id: GanttPropNode['id'] + done: Function + }) => void + + onMove: ({ + id, + pid, + index, + done, + }: { + id: GanttPropNode['id'] + pid?: GanttPropNode['id'] + index: number + done: Function + }) => void + + onDragStart: ({ id }: { id: GanttItem['id'] }) => void + + onDrag: ({ movedCols }: { movedCols: number }) => void + + onDragEnd: () => void + + onResizeStart: ({ id }: { id: GanttItem['id'] }) => void + + onResize: ({ resizedCols }: { resizedCols: number }) => void + + onResizeEnd: () => void + } + + type VGanttComputed = { + ganttData: GanttData + } + + type VGanttProps = { + rowH: number + + colW: number + + data: PropType + + view: PropType + + treeAttrs: { [key: string]: any } + } + + type VGantt = Combined + + export interface VGanttType extends FemessageComponent, VGantt {} + + const VGanttConstruction: ExtendedVue< + Vue, + VGanttData, + VGanttMethods, + VGanttComputed, + VGanttProps + > + + export default VGanttConstruction +} diff --git a/styleguide.config.js b/styleguide.config.js index 84ca2ba..b945dda 100644 --- a/styleguide.config.js +++ b/styleguide.config.js @@ -2,6 +2,39 @@ const path = require('path') const glob = require('glob') +const sections = (() => { + const docs = glob + .sync('docs/*.md') + .map((p) => ({ name: path.basename(p, '.md'), content: p })) + const demos = [] + let faq = '' // 约定至多只有一个faq.md + const guides = [] + docs.forEach((d) => { + if (/^faq$/i.test(d.name)) { + d.name = d.name.toUpperCase() + faq = d + } else if (/^guide-/.test(d.name)) { + guides.push(d) + } else { + demos.push(d) + } + }) + return [ + { + name: 'Components', + components: 'src/index.vue', + usageMode: 'expand', + }, + { + name: 'Demo', + sections: demos, + sectionDepth: 2, + }, + ...(faq ? [faq] : []), + ...(guides.length ? [{ name: 'Guide', sections: guides }] : []), + ] +})() + module.exports = { title: 'v-gantt 文档', styleguideDir: 'docs', @@ -11,19 +44,7 @@ module.exports = { url: 'https://github.com/FEMessage/v-gantt', }, require: ['./styleguide.config.extra.js'], - sections: [ - { - name: 'Components', - components: 'src/index.vue', - usageMode: 'expand', - }, - { - name: 'Demo', - sections: glob - .sync('docs/*.md') - .map((p) => ({ name: path.basename(p, '.md'), content: p })), - }, - ], + sections, exampleMode: 'expand', dangerouslyUpdateWebpackConfig(webpackConfig) { /**