From 3843308459a6e6e55a2fe5c9443c5b8d7ed2ce09 Mon Sep 17 00:00:00 2001 From: JiwenBai Date: Tue, 17 Dec 2019 14:04:15 +0800 Subject: [PATCH 1/3] feat(table): doc add property --- .../components/table/enUS/column.md | 22 +++++++++++++++++++ .../components/table/enUS/index.md | 22 ++----------------- .../components/table/enUS/property.md | 11 ++++++++++ 3 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 demo/documentation/components/table/enUS/column.md create mode 100644 demo/documentation/components/table/enUS/property.md diff --git a/demo/documentation/components/table/enUS/column.md b/demo/documentation/components/table/enUS/column.md new file mode 100644 index 000000000..71c14e459 --- /dev/null +++ b/demo/documentation/components/table/enUS/column.md @@ -0,0 +1,22 @@ +# Columns + +| Property | Description | Type | Default | +| :--------------- | :-------------------------------------------------------------------------------------------------------- | :---------------------------- | :------ | +| align | specify which way that column is aligned | 'left' \| 'right' \| 'center' | 'left' | +| ellipsis | ellipsize cell content,recommended when no property:render is used | boolean | false | +| className | className of this column | boolean | false | +| title | Title of this column | String | - | +| key | Unique key of this column,**required** | string | - | +| render | Renderer of the table cell. The return value should be a VueNode | Function(h, record, index) {} | - | +| renderHeader | Renderer of the table header cell. The return value should be a VueNode | Function(h, column) {} | - | +| sortable | use column sort, need property:sorter | boolean | false | +| sorter | Sort function for local sort, see Array.sort's compareFunction.If you need network sorter,set to `custom` | Function \| 'custom' | - | +| defaultSortOrder | default sort order | 'ascend' \| 'descend' | - | +| filterable | use filter | boolean | false | +| filter | Filter function for local filter.If you need network sorter,set to `custom` | Function \| 'custom' | - | +| filterMultiple | Whether multiple filters can be selected | boolean | false | +| defaultFilter | default filter selected | String | - | +| filterItems | Filter menu config,format as [{label,value}] | object[] | - | +| asyncFilterItems | async filter menu config ,Function returns [{label,value}] | Function | - | +| fixed | Set column to be fixed: 'left' 'right' | 'left'\| 'right' | - | +| width | Width of this column | string | number | - | diff --git a/demo/documentation/components/table/enUS/index.md b/demo/documentation/components/table/enUS/index.md index f05a08938..2999ec4fc 100644 --- a/demo/documentation/components/table/enUS/index.md +++ b/demo/documentation/components/table/enUS/index.md @@ -24,24 +24,6 @@ fixedHeaderColumn ellipsis renderHeader bestPractices +property +column ``` - -## Column - -| Property | Description | Type | Default | -| :--------------- | :-------------------------------------------------------------------------------------------------------- | :---------------------------- | :------ | -| align | specify which way that column is aligned | 'left' \| 'right' \| 'center' | 'left' | -| ellipsis | ellipsize cell content,recommended when no property:render is used | boolean | false | -| className | className of this column | boolean | false | -| title | Title of this column | String | - | -| key | Unique key of this column,**required** | string | - | -| render | Renderer of the table cell. The return value should be a VueNode | Function(h, record, index) {} | - | -| sortable | use column sort, need property:sorter | boolean | false | -| sorter | Sort function for local sort, see Array.sort's compareFunction.If you need network sorter,set to `custom` | Function \| 'custom' | - | -| defaultSortOrder | default sort order | 'ascend' \| 'descend' | - | -| filterable | use filter | boolean | false | -| filter | Filter function for local filter.If you need network sorter,set to `custom` | Function \| 'custom' | - | -| filterMultiple | Whether multiple filters can be selected | boolean | false | -| defaultFilter | default filter selected | String | - | -| filterItems | Filter menu config,format as [{label,value}] | object[] | - | -| asyncFilterItems | async filter menu config ,Function returns [{label,value}] | Function | - | diff --git a/demo/documentation/components/table/enUS/property.md b/demo/documentation/components/table/enUS/property.md new file mode 100644 index 000000000..79b4274c5 --- /dev/null +++ b/demo/documentation/components/table/enUS/property.md @@ -0,0 +1,11 @@ +# Property + +| Property | Description | Type | Default | +| :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------- | :------ | +| data | Structured data displayed. | Array | - | +| columns | Column configuration. Details are mentioned below. | Array | - | +| max-height | The max-height of the table. Unit: px / When this prop is set, if the content height is larger then the set value, the header will be fixed at the top. | Number \| String | - | +| row-class-name | Callback function for row's class name. Accept two arguments: -params: current row's data. -index: current row's index | Function | - | +| loading | Whether the table is loading. | Boolean | false | +| scroll-x | Set horizontal scrolling, can also be used to specify the width and height of the scroll area | number | - | +| pagination | Config of pagination. | object | - | From 80a3754a4b958a7501c3026dd6135966bedf3b3d Mon Sep 17 00:00:00 2001 From: JiwenBai Date: Wed, 18 Dec 2019 18:07:22 +0800 Subject: [PATCH 2/3] fixed(table): not found vue bug --- packages/common/AdvanceTable/body/body.vue | 10 +++++----- packages/common/AdvanceTable/header/header.vue | 6 +++--- packages/common/AdvanceTable/src/main.vue | 13 +++++-------- packages/common/AdvanceTable/store.js | 13 ++++++------- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/packages/common/AdvanceTable/body/body.vue b/packages/common/AdvanceTable/body/body.vue index 82bce8e9a..5ea939e6b 100644 --- a/packages/common/AdvanceTable/body/body.vue +++ b/packages/common/AdvanceTable/body/body.vue @@ -183,7 +183,7 @@ export default { } }, watch: { - '$store.state.currentHoverRow' (index, oldIndex) { + '$tableStore.state.currentHoverRow' (index, oldIndex) { const hoverClassName = 'n-table__tr--hover' const rowsDom = this.$el.querySelectorAll('table tr') const oldRowDom = rowsDom[oldIndex] @@ -206,16 +206,16 @@ export default { }, methods: { onMouseEnter (e) { - this.$store.commit('currentTableEl', e.currentTarget) + this.$tableStore.commit('currentTableEl', e.currentTarget) }, onMouseLeave (e) { - this.$store.commit('currentTableEl', null) + this.$tableStore.commit('currentTableEl', null) }, onRowHover (e, rowData, index) { - this.$store.commit('currentHoverRow', index) + this.$tableStore.commit('currentHoverRow', index) }, onRowLeave (e, rowData) { - this.$store.commit('currentHoverRow', null) + this.$tableStore.commit('currentHoverRow', null) }, computeCustomWidthStl (column) { if (column.width) { diff --git a/packages/common/AdvanceTable/header/header.vue b/packages/common/AdvanceTable/header/header.vue index ebf419d03..05188ae50 100644 --- a/packages/common/AdvanceTable/header/header.vue +++ b/packages/common/AdvanceTable/header/header.vue @@ -17,7 +17,7 @@ v-for="(column, i) in columns" :key="i" :style="computeCustomWidthStl(column)" - > + /> @@ -34,7 +34,7 @@ 0 && this.currentPageSelectedLen === this.showingData.length) || this.isCheckedBoxAllIndeterminate - this.$store.commit('selectedAllChecked', needChecked) + this.$tableStore.commit('selectedAllChecked', needChecked) }, computePageDivideData (data) { if (this.pagination && this.pagination.limit && !this.pagination.custom) { @@ -767,7 +764,7 @@ export default { }, onAllCheckboxesClick () { this.showingData.forEach(item => { - this.checkBoxes[item._index] = this.$store.state.selectedAllChecked + this.checkBoxes[item._index] = this.$tableStore.state.selectedAllChecked }) this.checkBoxes = [].concat(this.checkBoxes) }, diff --git a/packages/common/AdvanceTable/store.js b/packages/common/AdvanceTable/store.js index 5121a1a41..d091d7334 100644 --- a/packages/common/AdvanceTable/store.js +++ b/packages/common/AdvanceTable/store.js @@ -2,8 +2,8 @@ * @Author: Volankey@gmail.com * @Company: Tusimple * @Date: 2019-10-25 11:31:12 - * @LastEditors: Jiwen.bai - * @LastEditTime: 2019-11-07 11:13:03 + * @LastEditors : Jiwen.bai + * @LastEditTime : 2019-12-18 17:46:19 */ let Vue = null export class Store { @@ -35,11 +35,10 @@ function vuexInit () { Vue = _Vue } // store injection - if (options.store) { - this.$store = - typeof options.store === 'function' ? options.store() : options.store - } else if (options.parent && options.parent.$store) { - this.$store = options.parent.$store + if (options.parent && options.parent.$tableStore) { + this.$tableStore = options.parent.$tableStore + } else if (!this.$tableStore) { + this.$tableStore = new Store() } } export const storageMixin = { From 2cc57b932d087b98c1bbfcfb4fa8ae71f6eb50f3 Mon Sep 17 00:00:00 2001 From: JiwenBai Date: Wed, 18 Dec 2019 18:08:46 +0800 Subject: [PATCH 3/3] chore: update version to 0.6.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4460fce01..6719baf08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "naive-ui", - "version": "0.6.2", + "version": "0.6.3", "description": "", "main": "index.js", "scripts": {