Skip to content
This repository was archived by the owner on Oct 24, 2019. It is now read-only.

Commit daa31cd

Browse files
author
한정
authored
Merge branch 'master' into feat/reactive-columnOptions
2 parents 6b4f2eb + f71c4a7 commit daa31cd

File tree

6 files changed

+40
-30
lines changed

6 files changed

+40
-30
lines changed

.prettierrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
"printWidth" : 100,
3-
"singleQuote" : true,
4-
"bracketSpacing" : false,
5-
"arrowParens": "always"
3+
"singleQuote" : true
64
}

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = (api) => {
1+
module.exports = api => {
22
api.cache(true);
33

44
return {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@toast-ui/react-grid",
3-
"version": "2.0.0",
3+
"version": "2.0.3",
44
"description": "TOAST UI Grid for React",
55
"main": "dist/toastui-react-grid.js",
66
"files": [
@@ -53,6 +53,6 @@
5353
"xhr-mock": "^2.4.1"
5454
},
5555
"dependencies": {
56-
"tui-grid": "^4.0.0"
56+
"tui-grid": "^4.3.0"
5757
}
5858
}

src/index.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ export default class Grid extends React.Component {
1616

1717
bindEventHandlers(props, prevProps) {
1818
Object.keys(props)
19-
.filter((key) => /on[A-Z][a-zA-Z]+/.test(key))
20-
.forEach((key) => {
19+
.filter(key => /on(?!Grid)[A-Z][a-zA-Z]+/.test(key))
20+
.forEach(key => {
2121
const eventName = key[2].toLowerCase() + key.slice(3);
2222
// For <Grid onFocus={condition ? onFocus1 : onFocus2} />
23-
if (prevProps && prevProps[key] === props[key]) {
23+
if (prevProps && prevProps[key] !== props[key]) {
2424
this.gridInst.off(eventName);
2525
}
2626
this.gridInst.on(eventName, props[key]);
@@ -36,18 +36,28 @@ export default class Grid extends React.Component {
3636
}
3737

3838
componentDidMount() {
39+
const {
40+
frozenColumnCount: frozenCount = 0,
41+
columnOptions: columnOptionsProp = {}
42+
} = this.props;
43+
44+
const columnOptions = {
45+
...columnOptionsProp,
46+
frozenCount
47+
};
48+
3949
this.gridInst = new TuiGrid({
4050
el: this.rootEl.current,
41-
...this.props
51+
...this.props,
52+
columnOptions
4253
});
43-
4454
this.bindEventHandlers(this.props);
4555
}
4656

4757
shouldComponentUpdate(nextProps) {
48-
const {oneTimeBindingProps = []} = this.props;
58+
const { oneTimeBindingProps = [] } = this.props;
4959
const reactiveProps = Object.keys(reactivePropSetterMap).filter(
50-
(propName) => oneTimeBindingProps.indexOf(propName) === -1
60+
propName => oneTimeBindingProps.indexOf(propName) === -1
5161
);
5262

5363
reactiveProps.forEach((propName) => {

stories/index.stories.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import React, {useCallback} from 'react';
1+
import React, { useCallback } from 'react';
22
import XHRMock from 'xhr-mock';
3-
import {storiesOf} from '@storybook/react';
3+
import { storiesOf } from '@storybook/react';
44
import Grid from '../src/index';
55
import TuiGrid from 'tui-grid';
6-
import {actions} from '@storybook/addon-actions';
7-
import {withKnobs, number, radios, button, object, array} from '@storybook/addon-knobs';
8-
import {data} from './dummy-data';
6+
import { actions } from '@storybook/addon-actions';
7+
import { withKnobs, number, radios, button, object, array } from '@storybook/addon-knobs';
8+
import { data } from './dummy-data';
99
import 'tui-grid/dist/tui-grid.css';
1010
import 'tui-pagination/dist/tui-pagination.css';
1111

1212
const columns = [
13-
{header: 'Name', name: 'name'},
14-
{header: 'Artist', name: 'artist'},
15-
{header: 'Type', name: 'type', editor: 'text'},
16-
{header: 'Release', name: 'release', editor: 'text'},
17-
{header: 'Genre', name: 'genre', editor: 'text'}
13+
{ header: 'Name', name: 'name' },
14+
{ header: 'Artist', name: 'artist' },
15+
{ header: 'Type', name: 'type', editor: 'text' },
16+
{ header: 'Release', name: 'release', editor: 'text' },
17+
{ header: 'Genre', name: 'genre', editor: 'text' }
1818
];
1919

2020
const stories = storiesOf('Toast UI Grid', module).addDecorator(withKnobs);
2121

22-
stories.add('Normal', () => <Grid columns={columns} data={data} header={{height: 60}} />);
22+
stories.add('Normal', () => <Grid columns={columns} data={data} header={{ height: 60 }} />);
2323

2424
stories.add('Set Language', () => {
2525
const options = {
@@ -85,7 +85,7 @@ stories.add('Using Method', () => {
8585
}
8686

8787
handleClickAppend = () => {
88-
this.grid.appendRow({}, {at: 0});
88+
this.grid.appendRow({}, { at: 0 });
8989
};
9090

9191
handleClickSort = () => {
@@ -206,15 +206,17 @@ stories.add('dataSource', () => {
206206
withCredentials: false,
207207
initialRequest: true,
208208
api: {
209-
readData: {url: 'api/readData', method: 'GET'}
209+
readData: { url: 'api/readData', method: 'GET' }
210210
}
211211
};
212212

213-
return <Grid columns={columns} pagination={true} data={dataSource} pageOptions={{perPage: 3}} />;
213+
return (
214+
<Grid columns={columns} pagination={true} data={dataSource} pageOptions={{ perPage: 3 }} />
215+
);
214216
});
215217

216218
stories.add('hook', () => {
217-
const condition = radios('condition', {true: 'true', false: 'false'}, 'true');
219+
const condition = radios('condition', { true: 'true', false: 'false' }, 'true');
218220
const ReactComponent = () => {
219221
const onClick = useCallback(() => {
220222
console.log('condition:', condition);
@@ -227,7 +229,7 @@ stories.add('hook', () => {
227229
});
228230

229231
stories.add('change event based on condition', () => {
230-
const condition = radios('condition', {true: 'true', false: 'false'}, 'true');
232+
const condition = radios('condition', { true: 'true', false: 'false' }, 'true');
231233

232234
return (
233235
<Grid

0 commit comments

Comments
 (0)