├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── README.md ├── build ├── build.js ├── check-versions.js ├── dev-client.js ├── dev-server.js ├── utils.js ├── vue-loader.conf.js ├── webpack.base.conf.js ├── webpack.dev.conf.js └── webpack.prod.conf.js ├── config ├── dev.env.js ├── index.js └── prod.env.js ├── index.html ├── package.json ├── src ├── App.vue ├── assets │ ├── icons │ │ ├── compare.svg │ │ ├── edit.svg │ │ ├── filter.svg │ │ ├── gear.svg │ │ ├── github.svg │ │ ├── power.svg │ │ └── revision.svg │ └── logo.png ├── components │ ├── DgCellDetail.vue │ ├── DgCellMenu.vue │ ├── DgFilter.vue │ ├── DgMenu.vue │ ├── DgTable.vue │ ├── Icon.vue │ ├── MultiRangeSlider.vue │ ├── NavBar.vue │ └── RoundCheckBox.vue ├── data.json ├── main.js ├── sass │ ├── _transition.sass │ ├── _utils.sass │ └── _variables.sass ├── tableSettings.js └── utils │ ├── filters.js │ └── mouse.js ├── static └── .gitkeep └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["es2015", { "modules": false }], 4 | "stage-2" 5 | ], 6 | "plugins": ["transform-runtime"], 7 | "comments": false, 8 | "env": { 9 | "test": { 10 | "plugins": [ "istanbul" ] 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build/*.js 2 | config/*.js 3 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // http://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parser: 'babel-eslint', 6 | parserOptions: { 7 | sourceType: 'module' 8 | }, 9 | env: { 10 | browser: true, 11 | }, 12 | // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style 13 | extends: 'standard', 14 | // required to lint *.vue files 15 | plugins: [ 16 | 'html' 17 | ], 18 | // add your custom rules here 19 | 'rules': { 20 | // allow paren-less arrow functions 21 | 'arrow-parens': 0, 22 | // allow async-await 23 | 'generator-star-spacing': 0, 24 | // allow debugger during development 25 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vue Data Grid 2 | 3 | > An example([live demo](https://lucienlee.github.io/vue-data-grid/)) that complex table interaction in Vue.js, which is rebounded the design by [Virgil Pana](https://dribbble.com/shots/1903644-Data-Grid) 4 | 5 | ![demo](http://i.imgur.com/GqZSw4u.gif) 6 | 7 | See full interaction [video](https://vimeo.com/208192639) 8 | 9 | ## Build Setup 10 | 11 | ``` bash 12 | # install dependencies 13 | yarn 14 | 15 | # serve with hot reload at localhost:8080 16 | yarn run dev 17 | 18 | # build for production with minification 19 | yarn run build 20 | 21 | # build for production and view the bundle analyzer report 22 | yarn run build --report 23 | 24 | # deploy bundled files to gh-pages 25 | yarn run deploy 26 | ``` 27 | 28 | ## Feature 29 | 30 | - Load data from [json](https://github.com/LucienLee/vue-data-grid/blob/master/src/data.json) and import table interaction [configuration](https://github.com/LucienLee/vue-data-grid/blob/master/src/tableSettings.js), which is flexible and scalable ([data source](https://docs.google.com/spreadsheets/d/1PFbZIAipjNIG90BXIzpFwRu7omXYMhh3e1-tldrAv-I/edit?usp=sharing) used in demo). 31 | - Present data in real `table` tag, which keep html semantic 32 | - Load icons via svg sprite, which is resuable and pixel perfact 33 | - Group data by month and year automatically 34 | - Long contents in cells are trimmed automatically, which are expandable by clicking the columns 35 | - The length of expanding columns are calculated by data automatically 36 | - Cells have more menus or details, such as adding google map query links automatically 37 | - Sort data by ascending or descending and filter data by range, whose bounds are calculated by data automatically 38 | - Select columns to show by opening context menu with right click on header 39 | 40 | ## Acknowledgement 41 | - [Virgil Pana](https://dribbble.com/virgilpana), who designed the interaction first. 42 | - The song played in crafting, 那我懂你意思了 - [沒有人在乎你在乎的事](https://www.youtube.com/watch?v=UX2uQyHaCUk) 43 | -------------------------------------------------------------------------------- /build/build.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | process.env.NODE_ENV = 'production' 4 | 5 | var ora = require('ora') 6 | var rm = require('rimraf') 7 | var path = require('path') 8 | var chalk = require('chalk') 9 | var webpack = require('webpack') 10 | var config = require('../config') 11 | var webpackConfig = require('./webpack.prod.conf') 12 | 13 | var spinner = ora('building for production...') 14 | spinner.start() 15 | 16 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { 17 | if (err) throw err 18 | webpack(webpackConfig, function (err, stats) { 19 | spinner.stop() 20 | if (err) throw err 21 | process.stdout.write(stats.toString({ 22 | colors: true, 23 | modules: false, 24 | children: false, 25 | chunks: false, 26 | chunkModules: false 27 | }) + '\n\n') 28 | 29 | console.log(chalk.cyan(' Build complete.\n')) 30 | console.log(chalk.yellow( 31 | ' Tip: built files are meant to be served over an HTTP server.\n' + 32 | ' Opening index.html over file:// won\'t work.\n' 33 | )) 34 | }) 35 | }) 36 | -------------------------------------------------------------------------------- /build/check-versions.js: -------------------------------------------------------------------------------- 1 | var chalk = require('chalk') 2 | var semver = require('semver') 3 | var packageConfig = require('../package.json') 4 | 5 | function exec (cmd) { 6 | return require('child_process').execSync(cmd).toString().trim() 7 | } 8 | 9 | var versionRequirements = [ 10 | { 11 | name: 'node', 12 | currentVersion: semver.clean(process.version), 13 | versionRequirement: packageConfig.engines.node 14 | }, 15 | { 16 | name: 'npm', 17 | currentVersion: exec('npm --version'), 18 | versionRequirement: packageConfig.engines.npm 19 | } 20 | ] 21 | 22 | module.exports = function () { 23 | var warnings = [] 24 | for (var i = 0; i < versionRequirements.length; i++) { 25 | var mod = versionRequirements[i] 26 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 27 | warnings.push(mod.name + ': ' + 28 | chalk.red(mod.currentVersion) + ' should be ' + 29 | chalk.green(mod.versionRequirement) 30 | ) 31 | } 32 | } 33 | 34 | if (warnings.length) { 35 | console.log('') 36 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 37 | console.log() 38 | for (var i = 0; i < warnings.length; i++) { 39 | var warning = warnings[i] 40 | console.log(' ' + warning) 41 | } 42 | console.log() 43 | process.exit(1) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /build/dev-client.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | require('eventsource-polyfill') 3 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 4 | 5 | hotClient.subscribe(function (event) { 6 | if (event.action === 'reload') { 7 | window.location.reload() 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /build/dev-server.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | var config = require('../config') 4 | if (!process.env.NODE_ENV) { 5 | process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV) 6 | } 7 | 8 | var opn = require('opn') 9 | var path = require('path') 10 | var express = require('express') 11 | var webpack = require('webpack') 12 | var proxyMiddleware = require('http-proxy-middleware') 13 | var webpackConfig = require('./webpack.dev.conf') 14 | 15 | // default port where dev server listens for incoming traffic 16 | var port = process.env.PORT || config.dev.port 17 | // automatically open browser, if not set will be false 18 | var autoOpenBrowser = !!config.dev.autoOpenBrowser 19 | // Define HTTP proxies to your custom API backend 20 | // https://github.com/chimurai/http-proxy-middleware 21 | var proxyTable = config.dev.proxyTable 22 | 23 | var app = express() 24 | var compiler = webpack(webpackConfig) 25 | 26 | var devMiddleware = require('webpack-dev-middleware')(compiler, { 27 | publicPath: webpackConfig.output.publicPath, 28 | quiet: true 29 | }) 30 | 31 | var hotMiddleware = require('webpack-hot-middleware')(compiler, { 32 | log: () => {} 33 | }) 34 | // force page reload when html-webpack-plugin template changes 35 | compiler.plugin('compilation', function (compilation) { 36 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { 37 | hotMiddleware.publish({ action: 'reload' }) 38 | cb() 39 | }) 40 | }) 41 | 42 | // proxy api requests 43 | Object.keys(proxyTable).forEach(function (context) { 44 | var options = proxyTable[context] 45 | if (typeof options === 'string') { 46 | options = { target: options } 47 | } 48 | app.use(proxyMiddleware(options.filter || context, options)) 49 | }) 50 | 51 | // handle fallback for HTML5 history API 52 | app.use(require('connect-history-api-fallback')()) 53 | 54 | // serve webpack bundle output 55 | app.use(devMiddleware) 56 | 57 | // enable hot-reload and state-preserving 58 | // compilation error display 59 | app.use(hotMiddleware) 60 | 61 | // serve pure static assets 62 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory) 63 | app.use(staticPath, express.static('./static')) 64 | 65 | var uri = 'http://localhost:' + port 66 | 67 | devMiddleware.waitUntilValid(function () { 68 | console.log('> Listening at ' + uri + '\n') 69 | }) 70 | 71 | module.exports = app.listen(port, function (err) { 72 | if (err) { 73 | console.log(err) 74 | return 75 | } 76 | 77 | // when env is testing, don't need open it 78 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') { 79 | opn(uri) 80 | } 81 | }) 82 | -------------------------------------------------------------------------------- /build/utils.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var config = require('../config') 3 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 4 | 5 | exports.assetsPath = function (_path) { 6 | var assetsSubDirectory = process.env.NODE_ENV === 'production' 7 | ? config.build.assetsSubDirectory 8 | : config.dev.assetsSubDirectory 9 | return path.posix.join(assetsSubDirectory, _path) 10 | } 11 | 12 | exports.cssLoaders = function (options) { 13 | options = options || {} 14 | 15 | var cssLoader = { 16 | loader: 'css-loader', 17 | options: { 18 | minimize: process.env.NODE_ENV === 'production', 19 | sourceMap: options.sourceMap 20 | } 21 | } 22 | 23 | // generate loader string to be used with extract text plugin 24 | function generateLoaders (loader, loaderOptions) { 25 | var loaders = [cssLoader] 26 | if (loader) { 27 | loaders.push({ 28 | loader: loader + '-loader', 29 | options: Object.assign({}, loaderOptions, { 30 | sourceMap: options.sourceMap 31 | }) 32 | }) 33 | } 34 | 35 | // Extract CSS when that option is specified 36 | // (which is the case during production build) 37 | if (options.extract) { 38 | return ExtractTextPlugin.extract({ 39 | use: loaders, 40 | fallback: 'vue-style-loader' 41 | }) 42 | } else { 43 | return ['vue-style-loader'].concat(loaders) 44 | } 45 | } 46 | 47 | // http://vuejs.github.io/vue-loader/en/configurations/extract-css.html 48 | return { 49 | css: generateLoaders(), 50 | postcss: generateLoaders(), 51 | less: generateLoaders('less'), 52 | sass: generateLoaders('sass', { indentedSyntax: true }), 53 | scss: generateLoaders('sass'), 54 | stylus: generateLoaders('stylus'), 55 | styl: generateLoaders('stylus') 56 | } 57 | } 58 | 59 | // Generate loaders for standalone style files (outside of .vue) 60 | exports.styleLoaders = function (options) { 61 | var output = [] 62 | var loaders = exports.cssLoaders(options) 63 | for (var extension in loaders) { 64 | var loader = loaders[extension] 65 | output.push({ 66 | test: new RegExp('\\.' + extension + '$'), 67 | use: loader 68 | }) 69 | } 70 | return output 71 | } 72 | -------------------------------------------------------------------------------- /build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var config = require('../config') 3 | var isProduction = process.env.NODE_ENV === 'production' 4 | 5 | module.exports = { 6 | loaders: utils.cssLoaders({ 7 | sourceMap: isProduction 8 | ? config.build.productionSourceMap 9 | : config.dev.cssSourceMap, 10 | extract: isProduction 11 | }), 12 | postcss: [ 13 | require('autoprefixer')({ 14 | browsers: ['last 2 versions'] 15 | }) 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var config = require('../config') 4 | var vueLoaderConfig = require('./vue-loader.conf') 5 | 6 | function resolve (dir) { 7 | return path.join(__dirname, '..', dir) 8 | } 9 | 10 | module.exports = { 11 | entry: { 12 | app: './src/main.js' 13 | }, 14 | output: { 15 | path: config.build.assetsRoot, 16 | filename: '[name].js', 17 | publicPath: process.env.NODE_ENV === 'production' 18 | ? config.build.assetsPublicPath 19 | : config.dev.assetsPublicPath 20 | }, 21 | resolve: { 22 | extensions: ['.js', '.vue', '.json'], 23 | modules: [ 24 | resolve('src'), 25 | resolve('node_modules') 26 | ], 27 | alias: { 28 | 'src': resolve('src'), 29 | 'assets': resolve('src/assets'), 30 | 'components': resolve('src/components'), 31 | 'utils': resolve('src/utils'), 32 | } 33 | }, 34 | module: { 35 | rules: [ 36 | { 37 | test: /\.(js|vue)$/, 38 | loader: 'eslint-loader', 39 | enforce: "pre", 40 | include: [resolve('src'), resolve('test')], 41 | options: { 42 | formatter: require('eslint-friendly-formatter') 43 | } 44 | }, 45 | { 46 | test: /\.vue$/, 47 | loader: 'vue-loader', 48 | options: vueLoaderConfig 49 | }, 50 | { 51 | test: /\.js$/, 52 | loader: 'babel-loader', 53 | include: [resolve('src'), resolve('test')] 54 | }, 55 | { 56 | test: /\.svg$/, 57 | loader: 'svg-sprite-loader', 58 | include: /assets[\\/]icons/ 59 | }, 60 | { 61 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 62 | loader: 'url-loader', 63 | exclude: /assets[\\/]icons/, 64 | query: { 65 | limit: 10000, 66 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 67 | } 68 | }, 69 | { 70 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 71 | loader: 'url-loader', 72 | query: { 73 | limit: 10000, 74 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 75 | } 76 | } 77 | ] 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var webpack = require('webpack') 3 | var config = require('../config') 4 | var merge = require('webpack-merge') 5 | var baseWebpackConfig = require('./webpack.base.conf') 6 | var HtmlWebpackPlugin = require('html-webpack-plugin') 7 | var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 8 | 9 | // add hot-reload related code to entry chunks 10 | Object.keys(baseWebpackConfig.entry).forEach(function (name) { 11 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]) 12 | }) 13 | 14 | module.exports = merge(baseWebpackConfig, { 15 | module: { 16 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }) 17 | }, 18 | // cheap-module-eval-source-map is faster for development 19 | devtool: '#cheap-module-eval-source-map', 20 | plugins: [ 21 | new webpack.DefinePlugin({ 22 | 'process.env': config.dev.env 23 | }), 24 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage 25 | new webpack.HotModuleReplacementPlugin(), 26 | new webpack.NoEmitOnErrorsPlugin(), 27 | // https://github.com/ampedandwired/html-webpack-plugin 28 | new HtmlWebpackPlugin({ 29 | filename: 'index.html', 30 | template: 'index.html', 31 | inject: true 32 | }), 33 | new FriendlyErrorsPlugin() 34 | ] 35 | }) 36 | -------------------------------------------------------------------------------- /build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var webpack = require('webpack') 4 | var config = require('../config') 5 | var merge = require('webpack-merge') 6 | var baseWebpackConfig = require('./webpack.base.conf') 7 | var CopyWebpackPlugin = require('copy-webpack-plugin') 8 | var HtmlWebpackPlugin = require('html-webpack-plugin') 9 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 10 | var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') 11 | 12 | var env = config.build.env 13 | 14 | var webpackConfig = merge(baseWebpackConfig, { 15 | module: { 16 | rules: utils.styleLoaders({ 17 | sourceMap: config.build.productionSourceMap, 18 | extract: true 19 | }) 20 | }, 21 | devtool: config.build.productionSourceMap ? '#source-map' : false, 22 | output: { 23 | path: config.build.assetsRoot, 24 | filename: utils.assetsPath('js/[name].[chunkhash].js'), 25 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 26 | }, 27 | plugins: [ 28 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 29 | new webpack.DefinePlugin({ 30 | 'process.env': env 31 | }), 32 | new webpack.optimize.UglifyJsPlugin({ 33 | compress: { 34 | warnings: false 35 | }, 36 | sourceMap: true 37 | }), 38 | // extract css into its own file 39 | new ExtractTextPlugin({ 40 | filename: utils.assetsPath('css/[name].[contenthash].css') 41 | }), 42 | // Compress extracted CSS. We are using this plugin so that possible 43 | // duplicated CSS from different components can be deduped. 44 | new OptimizeCSSPlugin(), 45 | // generate dist index.html with correct asset hash for caching. 46 | // you can customize output by editing /index.html 47 | // see https://github.com/ampedandwired/html-webpack-plugin 48 | new HtmlWebpackPlugin({ 49 | filename: config.build.index, 50 | template: 'index.html', 51 | inject: true, 52 | minify: { 53 | removeComments: true, 54 | collapseWhitespace: true, 55 | removeAttributeQuotes: true 56 | // more options: 57 | // https://github.com/kangax/html-minifier#options-quick-reference 58 | }, 59 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 60 | chunksSortMode: 'dependency' 61 | }), 62 | // split vendor js into its own file 63 | new webpack.optimize.CommonsChunkPlugin({ 64 | name: 'vendor', 65 | minChunks: function (module, count) { 66 | // any required modules inside node_modules are extracted to vendor 67 | return ( 68 | module.resource && 69 | /\.js$/.test(module.resource) && 70 | module.resource.indexOf( 71 | path.join(__dirname, '../node_modules') 72 | ) === 0 73 | ) 74 | } 75 | }), 76 | // extract webpack runtime and module manifest to its own file in order to 77 | // prevent vendor hash from being updated whenever app bundle is updated 78 | new webpack.optimize.CommonsChunkPlugin({ 79 | name: 'manifest', 80 | chunks: ['vendor'] 81 | }), 82 | // copy custom static assets 83 | new CopyWebpackPlugin([ 84 | { 85 | from: path.resolve(__dirname, '../static'), 86 | to: config.build.assetsSubDirectory, 87 | ignore: ['.*'] 88 | } 89 | ]) 90 | ] 91 | }) 92 | 93 | if (config.build.productionGzip) { 94 | var CompressionWebpackPlugin = require('compression-webpack-plugin') 95 | 96 | webpackConfig.plugins.push( 97 | new CompressionWebpackPlugin({ 98 | asset: '[path].gz[query]', 99 | algorithm: 'gzip', 100 | test: new RegExp( 101 | '\\.(' + 102 | config.build.productionGzipExtensions.join('|') + 103 | ')$' 104 | ), 105 | threshold: 10240, 106 | minRatio: 0.8 107 | }) 108 | ) 109 | } 110 | 111 | if (config.build.bundleAnalyzerReport) { 112 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 113 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()) 114 | } 115 | 116 | module.exports = webpackConfig 117 | -------------------------------------------------------------------------------- /config/dev.env.js: -------------------------------------------------------------------------------- 1 | var merge = require('webpack-merge') 2 | var prodEnv = require('./prod.env') 3 | 4 | module.exports = merge(prodEnv, { 5 | NODE_ENV: '"development"' 6 | }) 7 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | // see http://vuejs-templates.github.io/webpack for documentation. 2 | var path = require('path') 3 | 4 | module.exports = { 5 | build: { 6 | env: require('./prod.env'), 7 | index: path.resolve(__dirname, '../dist/index.html'), 8 | assetsRoot: path.resolve(__dirname, '../dist'), 9 | assetsSubDirectory: 'static', 10 | assetsPublicPath: '/vue-data-grid/', 11 | productionSourceMap: true, 12 | // Gzip off by default as many popular static hosts such as 13 | // Surge or Netlify already gzip all static assets for you. 14 | // Before setting to `true`, make sure to: 15 | // npm install --save-dev compression-webpack-plugin 16 | productionGzip: false, 17 | productionGzipExtensions: ['js', 'css'], 18 | // Run the build command with an extra argument to 19 | // View the bundle analyzer report after build finishes: 20 | // `npm run build --report` 21 | // Set to `true` or `false` to always turn it on or off 22 | bundleAnalyzerReport: process.env.npm_config_report 23 | }, 24 | dev: { 25 | env: require('./dev.env'), 26 | port: 8080, 27 | autoOpenBrowser: true, 28 | assetsSubDirectory: 'static', 29 | assetsPublicPath: '/', 30 | proxyTable: {}, 31 | // CSS Sourcemaps off by default because relative paths are "buggy" 32 | // with this option, according to the CSS-Loader README 33 | // (https://github.com/webpack/css-loader#sourcemaps) 34 | // In our experience, they generally work as expected, 35 | // just be aware of this issue when enabling this option. 36 | cssSourceMap: false 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | NODE_ENV: '"production"' 3 | } 4 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | vue data grid 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-data-grid", 3 | "version": "1.0.0", 4 | "description": "A Vue.js project", 5 | "author": "Lucien Lee ", 6 | "private": true, 7 | "scripts": { 8 | "dev": "node build/dev-server.js", 9 | "build": "node build/build.js", 10 | "deploy": "gh-pages -d dist", 11 | "lint": "eslint --ext .js,.vue src" 12 | }, 13 | "dependencies": { 14 | "gsap": "^1.19.1", 15 | "lodash": "^4.17.4", 16 | "moment": "^2.17.1", 17 | "normalize.css": "^5.0.0", 18 | "vue": "^2.1.10" 19 | }, 20 | "devDependencies": { 21 | "autoprefixer": "^6.7.2", 22 | "babel-core": "^6.22.1", 23 | "babel-eslint": "^7.1.1", 24 | "babel-loader": "^6.2.10", 25 | "babel-plugin-transform-runtime": "^6.22.0", 26 | "babel-preset-es2015": "^6.22.0", 27 | "babel-preset-stage-2": "^6.22.0", 28 | "babel-register": "^6.22.0", 29 | "chalk": "^1.1.3", 30 | "connect-history-api-fallback": "^1.3.0", 31 | "copy-webpack-plugin": "^4.0.1", 32 | "css-loader": "^0.26.1", 33 | "eslint": "^3.14.1", 34 | "eslint-config-standard": "^6.2.1", 35 | "eslint-friendly-formatter": "^2.0.7", 36 | "eslint-loader": "^1.6.1", 37 | "eslint-plugin-html": "^2.0.0", 38 | "eslint-plugin-promise": "^3.4.0", 39 | "eslint-plugin-standard": "^2.0.1", 40 | "eventsource-polyfill": "^0.9.6", 41 | "express": "^4.14.1", 42 | "extract-text-webpack-plugin": "^2.0.0-rc.2", 43 | "file-loader": "^0.10.0", 44 | "friendly-errors-webpack-plugin": "^1.1.3", 45 | "function-bind": "^1.1.0", 46 | "gh-pages": "^0.12.0", 47 | "html-webpack-plugin": "^2.28.0", 48 | "http-proxy-middleware": "^0.17.3", 49 | "node-sass": "^4.5.0", 50 | "opn": "^4.0.2", 51 | "optimize-css-assets-webpack-plugin": "^1.3.0", 52 | "ora": "^1.1.0", 53 | "pug": "^2.0.0-beta11", 54 | "rimraf": "^2.6.0", 55 | "sass-loader": "^6.0.1", 56 | "semver": "^5.3.0", 57 | "svg-sprite-loader": "^0.3.0", 58 | "url-loader": "^0.5.7", 59 | "vue-loader": "^11.0.0", 60 | "vue-style-loader": "^2.0.0", 61 | "vue-template-compiler": "^2.1.10", 62 | "webpack": "^2.2.1", 63 | "webpack-bundle-analyzer": "^2.2.1", 64 | "webpack-dev-middleware": "^1.10.0", 65 | "webpack-hot-middleware": "^2.16.1", 66 | "webpack-merge": "^2.6.1" 67 | }, 68 | "engines": { 69 | "node": ">= 4.0.0", 70 | "npm": ">= 3.0.0" 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 19 | 20 | 43 | -------------------------------------------------------------------------------- /src/assets/icons/compare.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/icons/edit.svg: -------------------------------------------------------------------------------- 1 | editCreated with Sketch. -------------------------------------------------------------------------------- /src/assets/icons/filter.svg: -------------------------------------------------------------------------------- 1 | filterCreated with Sketch. -------------------------------------------------------------------------------- /src/assets/icons/gear.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/assets/icons/github.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/assets/icons/power.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/assets/icons/revision.svg: -------------------------------------------------------------------------------- 1 | revisionCreated with Sketch. -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucienLee/vue-data-grid/dcbe5211a970856a1a66f5660915314d5a0a0530/src/assets/logo.png -------------------------------------------------------------------------------- /src/components/DgCellDetail.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 16 | 17 | 48 | -------------------------------------------------------------------------------- /src/components/DgCellMenu.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 36 | 37 | 84 | -------------------------------------------------------------------------------- /src/components/DgFilter.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 68 | 69 | 130 | -------------------------------------------------------------------------------- /src/components/DgMenu.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 41 | 42 | 57 | -------------------------------------------------------------------------------- /src/components/DgTable.vue: -------------------------------------------------------------------------------- 1 | 34 | 35 | 258 | 259 | 350 | -------------------------------------------------------------------------------- /src/components/Icon.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 24 | 25 | 32 | -------------------------------------------------------------------------------- /src/components/MultiRangeSlider.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 55 | 56 | 147 | -------------------------------------------------------------------------------- /src/components/NavBar.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 23 | 24 | 64 | -------------------------------------------------------------------------------- /src/components/RoundCheckBox.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 28 | 29 | 78 | -------------------------------------------------------------------------------- /src/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "records": [ 3 | { 4 | "uid": 1, 5 | "customer": "IBBP Apps", 6 | "company": "H&R Real Inc.", 7 | "contact": "Jerome R. Camacho - eromeRCamacho@dayrep.com", 8 | "address": "3982 Rose Street, Dublin, CA 94568", 9 | "revenue": 90277.76, 10 | "VAT": 5441, 11 | "totalPrice": 864484.73, 12 | "status": "FINISHED", 13 | "date": "2014-03-07" 14 | }, 15 | { 16 | "uid": 2, 17 | "customer": "SRA-General Contacts", 18 | "company": "Rossi Auto Parts", 19 | "contact": "Denise M. Briggs - DeniseMBriggs@dayrep.com", 20 | "address": "7920 Glenlake Avenue, Ankeny, IA 50023", 21 | "revenue": 394038.65, 22 | "VAT": 6651, 23 | "totalPrice": 699604.19, 24 | "status": "ETA", 25 | "date": "2014-03-08" 26 | }, 27 | { 28 | "uid": 3, 29 | "customer": "CCST", 30 | "company": "Hudson's MensWear", 31 | "contact": "Sheryl G. Dorsey - SherylGDorsey@jourrapide.com", 32 | "address": "42 West Arch Drive Windermere, FL 34786", 33 | "revenue": 52359.44, 34 | "VAT": 6617, 35 | "totalPrice": 944097.04, 36 | "status": "WIP", 37 | "date": "2014-03-09" 38 | }, 39 | { 40 | "uid": 4, 41 | "customer": "Accupure", 42 | "company": "Lum's", 43 | "contact": "Iris D. Hurtado - IrisDHurtado@jourrapide.com", 44 | "address": "4275 Gordon Street, Ontario, CA 91761", 45 | "revenue": 417685.45, 46 | "VAT": 4996, 47 | "totalPrice": 966285.76, 48 | "status": "FINISHED", 49 | "date": "2014-03-10" 50 | }, 51 | { 52 | "uid": 5, 53 | "customer": "El Tools", 54 | "company": "Wholesale Club, Inc.", 55 | "contact": "William S. Arnold - williamSArnold@armyspy.com", 56 | "address": "2178 Rardin Drive, Mountain View, CA 94041", 57 | "revenue": 846116.07, 58 | "VAT": 8959, 59 | "totalPrice": 457582.04, 60 | "status": "ETA", 61 | "date": "2014-04-17" 62 | }, 63 | { 64 | "uid": 6, 65 | "customer": "IBBP Apps", 66 | "company": "Atco Ltd.", 67 | "contact": "Gary M. Webb - GaryMWebb@rhyta.com", 68 | "address": "1596 Bridge Avenue, Lafayette, LA 70501", 69 | "revenue": 273209.79, 70 | "VAT": 9027, 71 | "totalPrice": 986750.81, 72 | "status": "ETA", 73 | "date": "2014-04-18" 74 | }, 75 | { 76 | "uid": 7, 77 | "customer": "Accupure", 78 | "company": "Lum's", 79 | "contact": "Rebecca M. Gosser - RebeccaMGosser@armyspy.com", 80 | "address": "4275 Gordon Street, Ontario, CA 91761", 81 | "revenue": 875475.58, 82 | "VAT": 9683, 83 | "totalPrice": 633683.87, 84 | "status": "ETA", 85 | "date": "2014-04-19" 86 | }, 87 | { 88 | "uid": 8, 89 | "customer": "eDiscovery", 90 | "company": "Ensign Energy Services Inc.", 91 | "contact": "Harold C. Loewen - HaroldCLoewen@rhyta.com", 92 | "address": "1310 Kerry Way, Irvine, CA 92614", 93 | "revenue": 866891.34, 94 | "VAT": 9744, 95 | "totalPrice": 985341.75, 96 | "status": "FINISHED", 97 | "date": "2014-04-20" 98 | }, 99 | { 100 | "uid": 9, 101 | "customer": "IBBP Apps", 102 | "company": "Atco Ltd.", 103 | "contact": "Gary M. Webb - GaryMWebb@rhyta.com", 104 | "address": "1596 Bridge Avenue, Lafayette, LA 70501", 105 | "revenue": 781620.85, 106 | "VAT": 937, 107 | "totalPrice": 693687.08, 108 | "status": "WIP", 109 | "date": "2014-05-21" 110 | }, 111 | { 112 | "uid": 10, 113 | "customer": "Voxel Plus", 114 | "company": "Schucks Auto Supply", 115 | "contact": "Joshua C. Brown - JoshuaCBrown@armyspy.com", 116 | "address": "4822 Maloy Court, Colby, KS 67701", 117 | "revenue": 307248.33, 118 | "VAT": 684, 119 | "totalPrice": 721256.26, 120 | "status": "WIP", 121 | "date": "2014-05-01" 122 | }, 123 | { 124 | "uid": 11, 125 | "customer": "Red Game", 126 | "company": "Huffman and Boyle", 127 | "contact": "Randy D. Johnson - RandyDJohnson@teleworm.us", 128 | "address": "4414 Shadowmar Drive, New Orleans, LA 70112", 129 | "revenue": 771609.44, 130 | "VAT": 2773, 131 | "totalPrice": 309906.58, 132 | "status": "ETA", 133 | "date": "2014-05-13" 134 | }, 135 | { 136 | "uid": 12, 137 | "customer": "Accupure", 138 | "company": "Lum's", 139 | "contact": "Rebecca M. Gosser - RebeccaMGosser@armyspy.com", 140 | "address": "4275 Gordon Street, Ontario, CA 91761", 141 | "revenue": 211927.83, 142 | "VAT": 9772, 143 | "totalPrice": 916957.17, 144 | "status": "FINISHED", 145 | "date": "2014-05-24" 146 | } 147 | ] 148 | } 149 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App' 3 | 4 | /* eslint-disable no-new */ 5 | new Vue({ 6 | el: '#app', 7 | render: h => h(App) 8 | }) 9 | -------------------------------------------------------------------------------- /src/sass/_transition.sass: -------------------------------------------------------------------------------- 1 | @import 'variables' 2 | 3 | .fade-enter-active, .fade-leave-active 4 | transition: opacity $medium !important 5 | 6 | .fade-enter, .fade-leave-to 7 | opacity: 0 8 | -------------------------------------------------------------------------------- /src/sass/_utils.sass: -------------------------------------------------------------------------------- 1 | @import "variables" 2 | 3 | @function fitted-cell-width($len) 4 | @return $cell-padding + ($len / 2) 5 | 6 | %clearfix::after 7 | content: '' 8 | display: block 9 | clear: both 10 | 11 | .is-visible 12 | visibility: visible !important 13 | -------------------------------------------------------------------------------- /src/sass/_variables.sass: -------------------------------------------------------------------------------- 1 | /* COLORS */ 2 | $primary-color: #15a4fa 3 | $secondary-color: #7590b4 4 | 5 | $cell-color: #28415f 6 | $menu-color: #233b5a 7 | $hover-color: #1f3650 8 | $border-color: #273e5b 9 | $text-color: #6180a6 10 | $bg-color: #1c324a 11 | $shadow-color: rgba(#000, 0.24) 12 | 13 | /* SIZES */ 14 | $cell-padding: 1em 15 | $nav-height: 60px 16 | $base-font-size: 14px 17 | 18 | /* TIMES */ 19 | $fast: 0.2s 20 | $medium: 0.4s 21 | 22 | /* STYLE */ 23 | $shadow: 4px 4px 2px 0 $shadow-color 24 | $half-shadow: 4px 0 2px 0 $shadow-color 25 | 26 | $popup-index: 100 27 | $nav-index: 1000 28 | -------------------------------------------------------------------------------- /src/tableSettings.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Table Data and Interaction Settings 3 | * --- 4 | * attributes: the attributes showed on the table, whose the boolean values determind whether showing on the table at first. 5 | * expandables: the data of the attributes could be expand when clicking. 6 | * interactables: the data of attributes have actions. 7 | * currencies: the data of the attributes should be transformed to currency format. 8 | * hasDetails: the data of the attributes have more detail, such as google map link. 9 | * filterables: the attributes could be filtered. 10 | * omitOnMneu: the attributes not used on the context menu. 11 | */ 12 | 13 | export default { 14 | attributes: { 15 | customer: true, 16 | company: true, 17 | contact: true, 18 | address: true, 19 | revenue: true, 20 | VAT: true, 21 | totalPrice: true, 22 | status: true 23 | }, 24 | expandables: ['company', 'contact', 'address'], 25 | interactables: ['revenue', 'VAT', 'totalPrice'], 26 | currencies: ['revenue', 'VAT', 'totalPrice'], 27 | hasDetails: ['address'], 28 | filterables: ['VAT'], 29 | omitOnMenu: ['customer'] 30 | } 31 | -------------------------------------------------------------------------------- /src/utils/filters.js: -------------------------------------------------------------------------------- 1 | /* Pure functions for transforming data. */ 2 | 3 | import moment from 'moment' 4 | 5 | function toCurrency (n) { 6 | const num = n.toString().split('.') 7 | const decimal = num[1] ? `.${num[1]}` : '' 8 | return '$' + num[0].replace(/(\d{1,3})(?=(\d{3})+$)/g, '$1,') + decimal 9 | } 10 | 11 | function capitalize (text) { 12 | return text[0].toUpperCase() + text.slice(1) 13 | } 14 | 15 | function toMMMMYYYY (text) { 16 | return moment(text).format('MMMM YYYY') 17 | } 18 | 19 | function toGMapQuery (address) { 20 | return `https://www.google.com/maps?q=${address.replace(/\s/g, '+')}` 21 | } 22 | 23 | function toUpperMagnitude (num) { 24 | return Math.pow(10, num.toString().length) 25 | } 26 | 27 | export { toCurrency, toMMMMYYYY, capitalize, toGMapQuery, toUpperMagnitude } 28 | -------------------------------------------------------------------------------- /src/utils/mouse.js: -------------------------------------------------------------------------------- 1 | /* Mouse position calc */ 2 | 3 | // normalize pageX and pageY in mouse event 4 | function normPagePosInEvent (e) { 5 | e = e || window.event 6 | 7 | if (e.pageX === undefined) { 8 | e.pageX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft 9 | e.pageY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop 10 | } 11 | 12 | return e 13 | } 14 | 15 | export { normPagePosInEvent } 16 | -------------------------------------------------------------------------------- /static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucienLee/vue-data-grid/dcbe5211a970856a1a66f5660915314d5a0a0530/static/.gitkeep --------------------------------------------------------------------------------