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

Commit 27ebee9

Browse files
author
DongWoo Kim
committed
Initial commit
0 parents  commit 27ebee9

File tree

9 files changed

+7298
-0
lines changed

9 files changed

+7298
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.prettierrc

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

babel.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = (api) => {
2+
api.cache(true);
3+
4+
return {
5+
presets: [
6+
[
7+
'@babel/preset-env',
8+
{
9+
modules: false,
10+
useBuiltIns: 'entry'
11+
}
12+
],
13+
'@babel/preset-react'
14+
],
15+
plugins: [
16+
'@babel/plugin-proposal-class-properties',
17+
'@babel/plugin-proposal-object-rest-spread'
18+
]
19+
};
20+
};

package-lock.json

Lines changed: 7114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "toast-ui.react-grid",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"dev": "webpack-dev-server --open --mode development",
8+
"build": "webpack -p --progress"
9+
},
10+
"browserslist": "last 2 versions, ie 9",
11+
"peerDependencies": {
12+
"react": "^16.0.0"
13+
},
14+
"author": "",
15+
"license": "MIT",
16+
"devDependencies": {
17+
"@babel/core": "^7.2.2",
18+
"@babel/plugin-proposal-class-properties": "^7.2.3",
19+
"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
20+
"@babel/preset-env": "^7.2.3",
21+
"@babel/preset-react": "^7.0.0",
22+
"babel-loader": "^8.0.5",
23+
"css-loader": "^2.1.0",
24+
"html-webpack-plugin": "^3.2.0",
25+
"prettier": "^1.16.0",
26+
"style-loader": "^0.23.1",
27+
"webpack": "^4.29.0",
28+
"webpack-cli": "^3.2.1",
29+
"webpack-dev-server": "^3.1.14"
30+
},
31+
"dependencies": {
32+
"react": "^16.7.0",
33+
"react-dom": "^16.7.0",
34+
"tui-grid": "^3.4.0"
35+
}
36+
}

public/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html lang="ko">
3+
<head>
4+
<meta charset="utf-8" />
5+
</head>
6+
<body>
7+
<div id="content"></div>
8+
</body>
9+
</html>

src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React from 'react';
2+
import {render} from 'react-dom';
3+
4+
import Grid from './wrapper';
5+
6+
render(<Grid />, document.querySelector('#content'));

src/wrapper.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React from 'react';
2+
import TuiGrid from 'tui-grid';
3+
import 'tui-grid/dist/tui-grid.css';
4+
5+
export function applyTheme(presetName, extOptions) {
6+
TuiGrid.applyTheme(presetName, extOptions);
7+
}
8+
9+
export function setLanguage(localeCode, data) {
10+
TuiGrid.setLanguage(localeCode, data);
11+
}
12+
13+
export function getInstanceById(id) {
14+
return TuiGrid.getInstanceById(id);
15+
}
16+
17+
export class Grid extends React.Component {
18+
container = React.createRef();
19+
20+
gridInst = null;
21+
22+
componentDidMount() {
23+
this.gridInst = new TuiGrid({
24+
el: this.container.current,
25+
columns: [
26+
{
27+
title: 'c1',
28+
name: 'c1'
29+
},
30+
{
31+
title: 'C2',
32+
name: 'c2'
33+
}
34+
],
35+
data: [
36+
{
37+
c1: 1,
38+
c2: 1
39+
},
40+
{
41+
c1: 1,
42+
c2: 1
43+
}
44+
]
45+
});
46+
}
47+
48+
componentWillUnmount() {
49+
this.gridInst.destroy();
50+
this.gridInst = null;
51+
}
52+
53+
render() {
54+
return <div ref={this.container} />;
55+
}
56+
}

webpack.config.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const HtmlWebpackPlugin = require('html-webpack-plugin');
2+
const path = require('path');
3+
4+
const config = {
5+
entry: './src/index.js',
6+
output: {
7+
filename: 'toastui-react-grid.js',
8+
path: path.resolve(__dirname, 'dist'),
9+
library: 'toastui',
10+
libraryTarget: 'umd'
11+
},
12+
// externals: {
13+
// 'tui-grid': {
14+
// commonjs: 'tui-grid',
15+
// commonjs2: 'tui-grid',
16+
// amd: 'tui-grid',
17+
// root: ['tui', 'Grid']
18+
// }
19+
// },
20+
module: {
21+
rules: [
22+
{
23+
test: /\.js$/,
24+
include: [path.resolve(__dirname, 'src')],
25+
use: {
26+
loader: 'babel-loader',
27+
options: {
28+
presets: ['@babel/preset-env']
29+
}
30+
}
31+
},
32+
{
33+
test: /\.css$/,
34+
use: ['style-loader', 'css-loader']
35+
}
36+
]
37+
}
38+
};
39+
40+
module.exports = (env, options = {}) => {
41+
if (options.mode === 'development') {
42+
config.plugins = [
43+
new HtmlWebpackPlugin({
44+
template: 'public/index.html'
45+
})
46+
];
47+
}
48+
49+
return config;
50+
};

0 commit comments

Comments
 (0)