File tree Expand file tree Collapse file tree 7 files changed +32
-18
lines changed Expand file tree Collapse file tree 7 files changed +32
-18
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,6 @@ module.exports = {
3131 loader : 'babel-loader' ,
3232 } ,
3333 } ,
34- {
35- test : / \. h t m l $ / ,
36- use : [
37- {
38- loader : 'html-loader' ,
39- } ,
40- ] ,
41- } ,
4234 {
4335 test : / \. s c s s $ / ,
4436 use : [
@@ -51,6 +43,7 @@ module.exports = {
5143 } ,
5244 plugins : [
5345 // generates an HTML file by injecting automatically all our generated bundles.
46+ // any css result will be automagically included as a <link>
5447 new HtmlWebPackPlugin ( {
5548 template : path . resolve ( __dirname , '../public/index.html' ) ,
5649 favicon : path . resolve ( __dirname , '../public/pokeball.ico' ) ,
Original file line number Diff line number Diff line change 11const path = require ( 'path' ) ;
22const CleanTerminalPlugin = require ( 'clean-terminal-webpack-plugin' ) ;
3+ const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' ) ;
34const { BundleAnalyzerPlugin } = require ( 'webpack-bundle-analyzer' ) ;
45
56module . exports = {
@@ -32,16 +33,17 @@ module.exports = {
3233 {
3334 test : / \. s c s s $ / ,
3435 use : [
35- 'style- loader' , // creates style nodes from JS strings
36- 'css-loader' , // translates CSS into CommonJS
37- 'sass-loader' , // compiles Sass to CSS, using Node Sass by default
36+ MiniCssExtractPlugin . loader , // generate a separate style.css
37+ 'css-loader' , // translates CSS into CommonJS
38+ 'sass-loader' , // compiles Sass to CSS, using Node Sass by default
3839 ] ,
3940 } ,
4041 ] ,
4142 } ,
4243 plugins : [
4344 // clear terminal in each build
4445 new CleanTerminalPlugin ( ) ,
46+ new MiniCssExtractPlugin ( { filename : 'style.css' } ) ,
4547 // new BundleAnalyzerPlugin(),
4648 ] ,
4749 externals : {
Original file line number Diff line number Diff line change 44 "description" : " customizable react folder tree library" ,
55 "main" : " dist/react-folder-tree.bundle.js" ,
66 "files" : [
7- " dist/react-folder-tree.bundle.js"
7+ " dist/react-folder-tree.bundle.js" ,
8+ " dist/style.css"
89 ],
910 "author" : " Shunji Zhan <shunhahaha@live.com>" ,
1011 "keywords" : [
8283 "identity-obj-proxy" : " ^3.0.0" ,
8384 "jest" : " ^26.6.3" ,
8485 "lint-staged" : " ^10.5.1" ,
86+ "mini-css-extract-plugin" : " ^1.6.0" ,
8587 "node-sass" : " ^5.0.0" ,
8688 "react" : " ^16.8.0 || ^17" ,
8789 "react-dom" : " ^16.8.0 || ^17" ,
Original file line number Diff line number Diff line change @@ -14,13 +14,14 @@ import './FolderTree.scss';
1414
1515const FolderTree = ( {
1616 data,
17- onChange = console . log ,
17+ onChange = console . log , // eslint-disable-line
1818 initCheckedStatus = 'unchecked' ,
1919 initOpenStatus = 'open' ,
2020 iconComponents = { } ,
2121 showCheckbox = true ,
2222 indentPixels = 30 ,
2323 onNameClick = null ,
24+ readOnly = false ,
2425} ) => {
2526 const options = {
2627 initCheckedStatus,
@@ -48,6 +49,7 @@ const FolderTree = ({
4849 iconComponents,
4950 indentPixels,
5051 showCheckbox,
52+ readOnly,
5153 } ;
5254
5355 /* ----------
@@ -88,8 +90,9 @@ FolderTree.propTypes = {
8890 CaretDownIcon : PropTypes . func ,
8991 } ) ,
9092 indentPixels : PropTypes . number ,
91- showCheckbox : PropTypes . bool ,
9293 onNameClick : PropTypes . func ,
94+ showCheckbox : PropTypes . bool ,
95+ readOnly : PropTypes . bool ,
9396} ;
9497
9598export {
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import FolderTree , { testData } from '../FolderTree/FolderTree' ;
33
4+ /* eslint-disable */
45const SandBox = ( ) => {
5- const onTreeStateChange = ( state , e ) => console . log ( { state, e } ) ;
6+ const onTreeStateChange = ( state , e ) => console . log ( { state, e } ) ;
67
78 return (
89 < div className = 'demo-sandbox' >
910 < FolderTree
1011 data = { testData }
1112 onChange = { onTreeStateChange }
13+ readOnly
1214 // showCheckbox={ false }
1315 />
1416 </ div >
Original file line number Diff line number Diff line change @@ -47,8 +47,9 @@ const TreeNode = ({
4747
4848 iconComponents,
4949 indentPixels,
50- showCheckbox,
5150 onNameClick,
51+ showCheckbox,
52+ readOnly,
5253 } = useContext ( ConfigContext ) ;
5354
5455 const isFolder = ! ! children ;
@@ -87,13 +88,15 @@ const TreeNode = ({
8788 }
8889
8990 const handleCheckBoxChange = e => {
91+ if ( readOnly ) return ;
92+
9093 const newStatus = + e . target . checked ;
9194 handleCheck ( path , newStatus ) ;
9295 } ;
9396
9497 const onNameChange = newName => handleRename ( path , newName ) ;
9598
96- const selectMe = ( ) => ( ! isEditing && setIsSelected ( true ) ) ;
99+ const selectMe = ( ) => ( ! isEditing && ! readOnly && setIsSelected ( true ) ) ;
97100 const unSelectMe = ( ) => setIsSelected ( false ) ;
98101
99102 const openMe = ( ) => handleToggleOpen ( path , true ) ;
Original file line number Diff line number Diff line change @@ -6900,6 +6900,15 @@ mimic-response@^2.0.0, mimic-response@^2.1.0:
69006900 resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-2.1.0.tgz#d13763d35f613d09ec37ebb30bac0469c0ee8f43"
69016901 integrity sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==
69026902
6903+ mini-css-extract-plugin@^1.6.0 :
6904+ version "1.6.0"
6905+ resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-1.6.0.tgz#b4db2525af2624899ed64a23b0016e0036411893"
6906+ integrity sha512-nPFKI7NSy6uONUo9yn2hIfb9vyYvkFu95qki0e21DQ9uaqNKDP15DGpK0KnV6wDroWxPHtExrdEwx/yDQ8nVRw==
6907+ dependencies :
6908+ loader-utils "^2.0.0"
6909+ schema-utils "^3.0.0"
6910+ webpack-sources "^1.1.0"
6911+
69036912minimalistic-assert@^1.0.0 :
69046913 version "1.0.1"
69056914 resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7"
@@ -10125,7 +10134,7 @@ webpack-merge@^4.2.2:
1012510134 dependencies :
1012610135 lodash "^4.17.15"
1012710136
10128- webpack-sources@^1.4.3 :
10137+ webpack-sources@^1.1.0, webpack-sources@^1. 4.3 :
1012910138 version "1.4.3"
1013010139 resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933"
1013110140 integrity sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ==
You can’t perform that action at this time.
0 commit comments