diff --git a/.prettierrc b/.prettierrc
index 75dc327..dbaa464 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -1,6 +1,4 @@
{
"printWidth" : 100,
- "singleQuote" : true,
- "bracketSpacing" : false,
- "arrowParens": "always"
+ "singleQuote" : true
}
\ No newline at end of file
diff --git a/babel.config.js b/babel.config.js
index f47cfdc..2aefbf8 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -1,4 +1,4 @@
-module.exports = (api) => {
+module.exports = api => {
api.cache(true);
return {
diff --git a/src/index.js b/src/index.js
index fdae059..b25abc9 100644
--- a/src/index.js
+++ b/src/index.js
@@ -15,8 +15,8 @@ export default class Grid extends React.Component {
bindEventHandlers(props, prevProps) {
Object.keys(props)
- .filter((key) => /on[A-Z][a-zA-Z]+/.test(key))
- .forEach((key) => {
+ .filter(key => /on[A-Z][a-zA-Z]+/.test(key))
+ .forEach(key => {
const eventName = key[2].toLowerCase() + key.slice(3);
// For
if (prevProps && prevProps[key] !== props[key]) {
@@ -35,21 +35,31 @@ export default class Grid extends React.Component {
}
componentDidMount() {
+ const {
+ frozenColumnCount: frozenCount = 0,
+ columnOptions: columnOptionsProp = {}
+ } = this.props;
+
+ const columnOptions = {
+ ...columnOptionsProp,
+ frozenCount
+ };
+
this.gridInst = new TuiGrid({
el: this.rootEl.current,
- ...this.props
+ ...this.props,
+ columnOptions
});
-
this.bindEventHandlers(this.props);
}
shouldComponentUpdate(nextProps) {
- const {oneTimeBindingProps = []} = this.props;
+ const { oneTimeBindingProps = [] } = this.props;
const reactiveProps = Object.keys(reactivePropSetterMap).filter(
- (propName) => oneTimeBindingProps.indexOf(propName) === -1
+ propName => oneTimeBindingProps.indexOf(propName) === -1
);
- reactiveProps.forEach((propName) => {
+ reactiveProps.forEach(propName => {
const currentValue = this.props[propName];
const nextValue = nextProps[propName];
if (currentValue !== nextValue) {
diff --git a/stories/index.stories.js b/stories/index.stories.js
index 4d2838b..370c039 100644
--- a/stories/index.stories.js
+++ b/stories/index.stories.js
@@ -1,25 +1,25 @@
-import React, {useCallback} from 'react';
+import React, { useCallback } from 'react';
import XHRMock from 'xhr-mock';
-import {storiesOf} from '@storybook/react';
+import { storiesOf } from '@storybook/react';
import Grid from '../src/index';
import TuiGrid from 'tui-grid';
-import {actions} from '@storybook/addon-actions';
-import {withKnobs, number, radios, button, object, array} from '@storybook/addon-knobs';
-import {data} from './dummy-data';
+import { actions } from '@storybook/addon-actions';
+import { withKnobs, number, radios, button, object, array } from '@storybook/addon-knobs';
+import { data } from './dummy-data';
import 'tui-grid/dist/tui-grid.css';
import 'tui-pagination/dist/tui-pagination.css';
const columns = [
- {header: 'Name', name: 'name'},
- {header: 'Artist', name: 'artist'},
- {header: 'Type', name: 'type', editor: 'text'},
- {header: 'Release', name: 'release', editor: 'text'},
- {header: 'Genre', name: 'genre', editor: 'text'}
+ { header: 'Name', name: 'name' },
+ { header: 'Artist', name: 'artist' },
+ { header: 'Type', name: 'type', editor: 'text' },
+ { header: 'Release', name: 'release', editor: 'text' },
+ { header: 'Genre', name: 'genre', editor: 'text' }
];
const stories = storiesOf('Toast UI Grid', module).addDecorator(withKnobs);
-stories.add('Normal', () => );
+stories.add('Normal', () => );
stories.add('Set Language', () => {
const options = {
@@ -85,7 +85,7 @@ stories.add('Using Method', () => {
}
handleClickAppend = () => {
- this.grid.appendRow({}, {at: 0});
+ this.grid.appendRow({}, { at: 0 });
};
handleClickSort = () => {
@@ -204,15 +204,17 @@ stories.add('dataSource', () => {
withCredentials: false,
initialRequest: true,
api: {
- readData: {url: 'api/readData', method: 'GET'}
+ readData: { url: 'api/readData', method: 'GET' }
}
};
- return ;
+ return (
+
+ );
});
stories.add('hook', () => {
- const condition = radios('condition', {true: 'true', false: 'false'}, 'true');
+ const condition = radios('condition', { true: 'true', false: 'false' }, 'true');
const ReactComponent = () => {
const onClick = useCallback(() => {
console.log('condition:', condition);
@@ -225,7 +227,7 @@ stories.add('hook', () => {
});
stories.add('change event based on condition', () => {
- const condition = radios('condition', {true: 'true', false: 'false'}, 'true');
+ const condition = radios('condition', { true: 'true', false: 'false' }, 'true');
return (