Skip to content

Commit

Permalink
fix: merge
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxueliang committed Jan 9, 2020
2 parents e5c6140 + c8574d1 commit 0834d52
Show file tree
Hide file tree
Showing 82 changed files with 337 additions and 230 deletions.
7 changes: 7 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"hooks": {
"pre-commit": "pretty-quick --staged",
"pre-publish": "npm run lint",
"commit-msg": "commitlint -x @commitlint/config-conventional -e $GIT_PARAMS"
}
}
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ components/style/color/*.less
.gitattributes
.stylelintrc
.vcmrc
.logo
.npmrc.template
.huskyrc
15 changes: 12 additions & 3 deletions components/checkbox/__tests__/group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ describe('CheckboxGroup', () => {
it('does not trigger onChange callback of both Checkbox and CheckboxGroup when CheckboxGroup is disabled', () => {
const onChangeGroup = jest.fn();

const options = [{ label: 'Apple', value: 'Apple' }, { label: 'Pear', value: 'Pear' }];
const options = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Pear', value: 'Pear' },
];

const groupWrapper = mount(
{
Expand Down Expand Up @@ -95,7 +98,10 @@ describe('CheckboxGroup', () => {
});

it('passes prefixCls down to checkbox', () => {
const options = [{ label: 'Apple', value: 'Apple' }, { label: 'Orange', value: 'Orange' }];
const options = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Orange', value: 'Orange' },
];

const wrapper = mount({
render() {
Expand All @@ -106,7 +112,10 @@ describe('CheckboxGroup', () => {
expect(wrapper.html()).toMatchSnapshot();
});
it('should be controlled by value', async () => {
const options = [{ label: 'Apple', value: 'Apple' }, { label: 'Orange', value: 'Orange' }];
const options = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Orange', value: 'Orange' },
];

const wrapper = mount(Checkbox.Group, {
propsData: { options },
Expand Down
1 change: 0 additions & 1 deletion components/date-picker/__tests__/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/prefer-default-export */
export function $$(className) {
return document.body.querySelectorAll(className);
}
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/demo/disabled-date.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Disabled part of dates and time by `disabledDate` and `disabledTime` respectivel
:disabledDate="disabledDate"
:disabledTime="disabledRangeTime"
:showTime="{
hideDisabledOptions: true,
hideDisabledOptions: true,
defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('11:59:59', 'HH:mm:ss')]
}"
format="YYYY-MM-DD HH:mm:ss"
Expand Down
2 changes: 1 addition & 1 deletion components/drawer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const Drawer = {
return (
<div
class={`${prefixCls}-wrapper-body`}
style={{...containerStyle, ...wrapStyle}}
style={{ ...containerStyle, ...wrapStyle }}
onTransitionend={this.onDestroyTransitionEnd}
>
{this.renderHeader(prefixCls)}
Expand Down
3 changes: 2 additions & 1 deletion components/form/FormItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export default {
const { help, validateStatus } = this.$props;
warning(
this.getControls(this.slotDefault, true).length <= 1 ||
(help !== undefined || validateStatus !== undefined),
help !== undefined ||
validateStatus !== undefined,
'`Form.Item` cannot generate `validateStatus` and `help` automatically, ' +
'while there are more than one `getFieldDecorator` in it.',
);
Expand Down
7 changes: 6 additions & 1 deletion components/form/demo/validate-other.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ Demonstration of validation configuration for form controls which are not shown
</us>

<template>
<a-form id="components-form-demo-validate-other" :form="form" v-bind="formItemLayout" @submit="handleSubmit">
<a-form
id="components-form-demo-validate-other"
:form="form"
v-bind="formItemLayout"
@submit="handleSubmit"
>
<a-form-item label="Plain Text">
<span class="ant-form-text">
China
Expand Down
1 change: 0 additions & 1 deletion components/locale-provider/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/no-multi-comp */
import { mount } from '@vue/test-utils';
import Vue from 'vue';
import moment from 'moment';
Expand Down
5 changes: 4 additions & 1 deletion components/radio/__tests__/group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ describe('Radio', () => {
});

it('passes prefixCls down to radio', () => {
const options = [{ label: 'Apple', value: 'Apple' }, { label: 'Orange', value: 'Orange' }];
const options = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Orange', value: 'Orange' },
];

const wrapper = mount(RadioGroup, {
propsData: {
Expand Down
15 changes: 12 additions & 3 deletions components/table/__tests__/Table.filter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ describe('Table.filter', () => {
{
text: 'Title',
value: 'title',
children: [{ text: 'Designer', value: 'designer' }, { text: 'Coder', value: 'coder' }],
children: [
{ text: 'Designer', value: 'designer' },
{ text: 'Coder', value: 'coder' },
],
},
],
onFilter: filterFn,
Expand Down Expand Up @@ -358,7 +361,10 @@ describe('Table.filter', () => {
title="name"
dataIndex="name"
key="name"
filters={[{ text: 'Jack', value: 'Jack' }, { text: 'Lucy', value: 'Lucy' }]}
filters={[
{ text: 'Jack', value: 'Jack' },
{ text: 'Lucy', value: 'Lucy' },
]}
filteredValue={this.filters.name}
onFilter={filterFn}
/>
Expand Down Expand Up @@ -399,7 +405,10 @@ describe('Table.filter', () => {
title: 'Name',
dataIndex: 'name',
key: 'name',
filters: [{ text: 'Jack', value: 'Jack' }, { text: 'Lucy', value: 'Lucy' }],
filters: [
{ text: 'Jack', value: 'Jack' },
{ text: 'Lucy', value: 'Lucy' },
],
onFilter: filterFn,
filteredValue: ['Jack'],
},
Expand Down
5 changes: 5 additions & 0 deletions components/table/demo/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import RowSelectionCustom from './row-selection-custom.md';
import RowSelection from './row-selection.md';
import Size from './size.md';
import Template from './template.md';
import ResizableColumn from './resizable-column';
import ResizableColumnString from '!raw-loader!./resizable-column';
import CN from '../index.zh-CN.md';
import US from '../index.en-US.md';
Expand Down Expand Up @@ -83,6 +85,9 @@ export default {
<RowSelection />
<Size />
<Template />
<demo-container code={ResizableColumnString}>
<ResizableColumn />
</demo-container>
<api>
<template slot="cn">
<CN />
Expand Down
142 changes: 142 additions & 0 deletions components/table/demo/resizable-column.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<cn>
#### 可伸缩列
集成 [vue-draggable-resizable](https://github.com/mauricius/vue-draggable-resizable) 来实现可伸缩列。
</cn>

<us>
#### Resizable column
Implement resizable column by integrate with [vue-draggable-resizable](https://github.com/mauricius/vue-draggable-resizable).
</us>

<template>
<a-table bordered :columns="columns" :components="components" :dataSource="data">
<template v-slot:action>
<a href="javascript:;">Delete</a>
</template>
</a-table>
</template>

<script>
import Vue from 'vue';
import VueDraggableResizable from 'vue-draggable-resizable';
Vue.component('vue-draggable-resizable', VueDraggableResizable);
const columns = [
{
title: 'Date',
dataIndex: 'date',
width: 200,
},
{
title: 'Amount',
dataIndex: 'amount',
width: 100,
},
{
title: 'Type',
dataIndex: 'type',
width: 100,
},
{
title: 'Note',
dataIndex: 'note',
width: 100,
},
{
title: 'Action',
key: 'action',
scopedSlots: { customRender: 'action' },
},
];
const data = [
{
key: 0,
date: '2018-02-11',
amount: 120,
type: 'income',
note: 'transfer',
},
{
key: 1,
date: '2018-03-11',
amount: 243,
type: 'income',
note: 'transfer',
},
{
key: 2,
date: '2018-04-11',
amount: 98,
type: 'income',
note: 'transfer',
},
];
const draggingMap = {};
columns.forEach(col => {
draggingMap[col.key] = col.width;
});
const draggingState = Vue.observable(draggingMap);
const ResizeableTitle = (h, props, children) => {
let thDom = null;
const { key, ...restProps } = props;
const col = columns.find(col => {
const k = col.dataIndex || col.key;
return k === key;
});
if (!col.width) {
return <th {...restProps}>{children}</th>;
}
const onDrag = (x, y) => {
draggingState[key] = 0;
col.width = Math.max(x, 1);
};
const onDragstop = () => {
draggingState[key] = thDom.getBoundingClientRect().width;
};
return (
<th {...restProps} v-ant-ref={r => (thDom = r)} width={col.width} class="resize-table-th">
{children}
<vue-draggable-resizable
key={col.key}
class="table-draggable-handle"
w={10}
x={draggingState[key] || col.width}
z={1}
axis="x"
draggable={true}
resizable={false}
onDragging={onDrag}
onDragstop={onDragstop}
></vue-draggable-resizable>
</th>
);
};
export default {
name: 'App',
data() {
this.components = {
header: {
cell: ResizeableTitle,
},
};
return {
data,
columns,
};
},
};
</script>
<style lang="less">
.resize-table-th {
position: relative;
.table-draggable-handle {
height: 100% !important;
bottom: 0;
left: auto !important;
right: -5px;
cursor: col-resize;
touch-action: none;
}
}
</style>
37 changes: 0 additions & 37 deletions components/table/index.en-US.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
```jsx
const dataSource = [
{
key: '1',
name: 'Mike',
age: 32,
address: '10 Downing Street',
},
{
key: '2',
name: 'John',
age: 42,
address: '10 Downing Street',
},
];

const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
},
{
title: 'Age',
dataIndex: 'age',
key: 'age',
},
{
title: 'Address',
dataIndex: 'address',
key: 'address',
},
];

<Table dataSource={dataSource} columns={columns} />;
```

## API

### Table
Expand Down
Loading

0 comments on commit 0834d52

Please sign in to comment.