Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
levy committed Nov 11, 2020
2 parents dc6264e + 4588ed5 commit 9272b05
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 22 deletions.
10 changes: 10 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.DS_Store
node_modules
/dist
docs/build
docs/fonts
docs/index.html

# local env files
.env.local
Expand All @@ -20,5 +23,3 @@ pnpm-debug.log*
*.njsproj
*.sln
*.sw?

docs
2 changes: 1 addition & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ yarn dev
- 修复更改 rowH 时未改变树节点高度的问题
- 支持进度修改功能
- 支持修改里程碑完成状态
- 修复使用 rollup 打包时,<gantt-group> 组件丢失对 <gantt-layout> 的引用的问题
- 修复使用 rollup 打包时,`<gantt-group>` 组件丢失对 `<gantt-layout>` 的引用的问题

[⬆ Back to Top](#table-of-contents)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ yarn dev
- fix 'rowH' doesn't inpact tree nodes
- support drag to change progress
- support click to toggle milestone
- lost <gantt-layout> in <gantt-group> when compile with rollup
- lost `<gantt-layout>` in `<gantt-group>` when compile with rollup

[⬆ Back to Top](#table-of-contents)

Expand Down Expand Up @@ -151,12 +151,12 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<table>
<tr>
<td align="center"><a href="https://github.com/donaldshen"><img src="https://avatars3.githubusercontent.com/u/19591950?v=4" width="100px;" alt=""/><br /><sub><b>Donald Shen</b></sub></a><br /><a href="https://github.com/FEMessage/v-gantt/commits?author=donaldshen" title="Code">💻</a> <a href="#blog-donaldshen" title="Blogposts">📝</a> <a href="#tool-donaldshen" title="Tools">🔧</a> <a href="#design-donaldshen" title="Design">🎨</a></td>
<td align="center"><a href="https://4ark.me"><img src="https://avatars0.githubusercontent.com/u/27952659?v=4" width="100px;" alt=""/><br /><sub><b>4Ark</b></sub></a><br /><a href="https://github.com/FEMessage/v-gantt/commits?author=gd4Ark" title="Documentation">📖</a> <a href="#maintenance-gd4Ark" title="Maintenance">🚧</a></td>
</tr>
</table>

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## 在 TypeScript 中指定组件的类型

```html
<script lang="ts">
// 需要引入这个
// import { VGanttType } from '@femessage/v-gantt'
export default {
mounted() {
;(this.$refs.vGantt as VGanttType).collapsedMap[0] = true
},
}
</script>
```
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
124 changes: 124 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -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<Instance, Data, Methods, Computed, Props> & Vue
>

type Combined<Data, Methods, Computed, Props> = 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<GanttPropData>

view: PropType<ColUnit>

treeAttrs: { [key: string]: any }
}

type VGantt = Combined<VGanttData, VGanttMethods, VGanttComputed, VGanttProps>

export interface VGanttType extends FemessageComponent, VGantt {}

const VGanttConstruction: ExtendedVue<
Vue,
VGanttData,
VGanttMethods,
VGanttComputed,
VGanttProps
>

export default VGanttConstruction
}
76 changes: 59 additions & 17 deletions styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,72 @@
const path = require('path')
const glob = require('glob')

module.exports = {
title: 'v-gantt 文档',
styleguideDir: 'docs', // 每次构建会清除掉内容,所以文档不能放在里面
version: require('./package.json').version,
pagePerSection: true,
ribbon: {
url: 'https://github.com/FEMessage/v-gantt',
},
require: ['./styleguide.config.extra.js'],
sections: [
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: glob
.sync('docs-md/*.md')
.map((p) => ({ name: path.basename(p, '.md'), content: p })),
sections: demos,
sectionDepth: 2,
},
],
// webpackConfig: {
// // custom config goes here
// },
...(faq ? [faq] : []),
...(guides.length ? [{ name: 'Guide', sections: guides }] : []),
]
})()

module.exports = {
title: 'v-gantt 文档',
styleguideDir: 'docs',
version: require('./package.json').version,
pagePerSection: true,
ribbon: {
url: 'https://github.com/FEMessage/v-gantt',
},
require: ['./styleguide.config.extra.js'],
sections,
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
},
}

0 comments on commit 9272b05

Please sign in to comment.