Skip to content

Commit 8a7a0f2

Browse files
author
Daniel
authored
Merge pull request #126 from leezng/dev
release
2 parents 23c4055 + fd162d1 commit 8a7a0f2

File tree

7 files changed

+4416
-2137
lines changed

7 files changed

+4416
-2137
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ $ npm install vue-json-pretty --save
5252
$ yarn add vue-json-pretty
5353
```
5454

55+
## Use Vue3
56+
57+
```bash
58+
$ npm install vue-json-pretty@next --save
59+
```
60+
5561
## Usage
5662

5763
The CSS file is included separately and needs to be imported manually. You can either import CSS globally in your app (if supported by your framework) or directly from the component.

build/webpack.prod.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ if (!isExampleEnv) {
4343
libraryTarget: 'umd',
4444
};
4545
webpackConfig.externals = {
46-
vue: 'vue',
46+
vue: 'Vue',
4747
};
4848
webpackConfig.plugins.push(
4949
// extract css into its own file

example/VirtualList.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
<h3>Options:</h3>
88
<div class="options">
9+
<div>
10+
<label>virtualLines</label>
11+
<input v-model="state.virtualLines" type="number" />
12+
</div>
913
<div>
1014
<label>showLine</label>
1115
<input v-model="state.showLine" type="checkbox" />
@@ -27,8 +31,9 @@
2731
<div class="block">
2832
<h3>vue-json-pretty(1000+ items):</h3>
2933
<vue-json-pretty
30-
style="height: 200px"
34+
style="height:400px"
3135
:virtual="true"
36+
:virtualLines="+state.virtualLines"
3237
:data="state.data"
3338
:deep="state.deep"
3439
:show-line="state.showLine"
@@ -64,6 +69,7 @@ export default defineComponent({
6469
showLine: true,
6570
collapsedOnClickBrackets: true,
6671
deep: 3,
72+
virtualLines: 20,
6773
});
6874
6975
watch(

package-lock.json

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

package.json

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,54 +30,54 @@
3030
"url": "https://github.com/leezng/vue-json-pretty/issues"
3131
},
3232
"devDependencies": {
33-
"@babel/core": "^7.12.3",
34-
"@babel/plugin-transform-runtime": "^7.12.1",
35-
"@babel/preset-env": "^7.12.1",
36-
"@babel/preset-typescript": "^7.12.1",
37-
"@typescript-eslint/eslint-plugin": "^4.7.0",
38-
"@typescript-eslint/parser": "^4.7.0",
39-
"@vue/babel-plugin-jsx": "^1.0.0-rc.4",
40-
"@vue/compiler-sfc": "^3.0.4",
33+
"@babel/core": "^7.14.6",
34+
"@babel/plugin-transform-runtime": "^7.14.5",
35+
"@babel/preset-env": "^7.14.7",
36+
"@babel/preset-typescript": "^7.14.5",
37+
"@typescript-eslint/eslint-plugin": "^4.28.0",
38+
"@typescript-eslint/parser": "^4.28.0",
39+
"@vue/babel-plugin-jsx": "^1.0.6",
40+
"@vue/compiler-sfc": "^3.1.2",
4141
"@vue/eslint-config-typescript": "^7.0.0",
42-
"autoprefixer": "^10.0.1",
43-
"babel-loader": "^8.1.0",
44-
"chalk": "^4.1.0",
42+
"autoprefixer": "^10.2.6",
43+
"babel-loader": "^8.2.2",
44+
"chalk": "^4.1.1",
4545
"clean-webpack-plugin": "^3.0.0",
4646
"connect-history-api-fallback": "^1.3.0",
47-
"copy-webpack-plugin": "^6.0.2",
48-
"cross-env": "^7.0.2",
47+
"copy-webpack-plugin": "^6.4.1",
48+
"cross-env": "^7.0.3",
4949
"cross-spawn": "^7.0.3",
50-
"css-loader": "^5.0.0",
51-
"cssnano": "^4.1.10",
50+
"css-loader": "^5.2.6",
51+
"cssnano": "^4.1.11",
5252
"cypress": "^5.5.0",
53-
"eslint": "^7.3.1",
54-
"eslint-plugin-vue": "^7.1.0",
55-
"eslint-webpack-plugin": "^2.3.0",
53+
"eslint": "^7.29.0",
54+
"eslint-plugin-vue": "^7.11.1",
55+
"eslint-webpack-plugin": "^2.5.4",
5656
"eventsource-polyfill": "^0.9.6",
5757
"express": "^4.17.1",
5858
"file-loader": "^6.0.0",
5959
"friendly-errors-webpack-plugin": "^1.7.0",
60-
"html-webpack-plugin": "^4.3.0",
61-
"http-proxy-middleware": "^1.0.6",
62-
"less": "^3.11.3",
63-
"less-loader": "^7.0.2",
64-
"mini-css-extract-plugin": "^1.2.1",
65-
"open": "^7.3.0",
66-
"optimize-css-assets-webpack-plugin": "^5.0.3",
67-
"prettier": "^2.1.2",
60+
"html-webpack-plugin": "^4.5.2",
61+
"http-proxy-middleware": "^1.3.1",
62+
"less": "^3.13.1",
63+
"less-loader": "^7.3.0",
64+
"mini-css-extract-plugin": "^1.6.0",
65+
"open": "^7.4.2",
66+
"optimize-css-assets-webpack-plugin": "^5.0.7",
67+
"prettier": "^2.3.1",
6868
"selenium-server": "^3.0.1",
69-
"semver": "^7.3.2",
69+
"semver": "^7.3.5",
7070
"shelljs": "^0.8.4",
71-
"typescript": "^4.0.5",
71+
"typescript": "^4.3.4",
7272
"url-loader": "^4.1.0",
73-
"vue": "^3.0.4",
74-
"vue-loader": "^16.0.0-rc.1",
75-
"vue-style-loader": "^4.1.2",
76-
"webpack": "^5.3.0",
73+
"vue": "^3.1.2",
74+
"vue-loader": "^16.2.0",
75+
"vue-style-loader": "^4.1.3",
76+
"webpack": "^5.40.0",
7777
"webpack-bundle-analyzer": "^3.8.0",
78-
"webpack-dev-middleware": "^3.7.2",
78+
"webpack-dev-middleware": "^3.7.3",
7979
"webpack-hot-middleware": "^2.25.0",
80-
"webpack-merge": "^5.2.0"
80+
"webpack-merge": "^5.8.0"
8181
},
8282
"engines": {
8383
"node": ">= 10.0.0",
@@ -92,5 +92,8 @@
9292
"lib",
9393
"types"
9494
],
95+
"peerDependencies": {
96+
"vue": ">=3.0.0"
97+
},
9598
"dependencies": {}
9699
}

src/components/Tree/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ export default defineComponent({
3030
type: Boolean,
3131
default: false,
3232
},
33+
//When using virtual scroll, set the number of items there can be
34+
virtualLines: {
35+
type: Number,
36+
default: 10,
37+
},
3338
// When using virtual scroll, define the height of each row.
3439
itemHeight: {
3540
type: Number,
@@ -111,7 +116,7 @@ export default defineComponent({
111116
const updateVisibleData = (flatDataValue: FlatDataType) => {
112117
if (props.virtual) {
113118
const treeRefValue = tree.value;
114-
const visibleCount = 10;
119+
const visibleCount = props.virtualLines;
115120
const scrollTop = (treeRefValue && treeRefValue.scrollTop) || 0;
116121
const scrollCount = Math.floor(scrollTop / props.itemHeight);
117122
let start =

src/utils/index.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ export function jsonFlatten(
3535
level = 0,
3636
options?: JSONFlattenOptions,
3737
): JSONFlattenReturnType[] {
38-
const { key, index, type = 'content', showComma = false, length = 1 } =
39-
options || ({} as JSONFlattenOptions);
38+
const {
39+
key,
40+
index,
41+
type = 'content',
42+
showComma = false,
43+
length = 1,
44+
} = options || ({} as JSONFlattenOptions);
4045
const dataType = getDataType(data);
4146

4247
if (dataType === 'array') {
@@ -49,7 +54,8 @@ export function jsonFlatten(
4954
type,
5055
}),
5156
)
52-
.flat();
57+
// No flat, for compatibility.
58+
.reduce((acc, val) => acc.concat(val), []);
5359
return [
5460
jsonFlatten('[', path, level, {
5561
showComma: false,
@@ -81,7 +87,8 @@ export function jsonFlatten(
8187
},
8288
),
8389
)
84-
.flat();
90+
// No flat, for compatibility.
91+
.reduce((acc, val) => acc.concat(val), []);
8592
return [
8693
jsonFlatten('{', path, level, {
8794
showComma: false,

0 commit comments

Comments
 (0)