Skip to content

Commit a94398f

Browse files
leezngcstuncsik
andauthored
chore: release 2.2.3 (#218)
* chore: remove commented test code. * fix: show null and explicit undefined values (cherry picked from commit 800c416) * chore: run prettier * fix: dynamic left padding on collapse elements. #200 (#216) Co-authored-by: Csaba Tuncsik <csaba.tuncsik@gmail.com>
1 parent 1d09bfa commit a94398f

File tree

9 files changed

+28
-86
lines changed

9 files changed

+28
-86
lines changed

example/Basic.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ import VueJsonPretty from 'src';
9494
9595
const defaultData = {
9696
status: 200,
97-
error: '',
97+
text: '',
98+
error: null,
99+
config: undefined,
98100
data: [
99101
{
100102
news_id: 51184,

example/Editable.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ import VueJsonPretty from 'src';
5656
5757
const defaultData = {
5858
status: 200,
59-
error: '',
59+
text: '',
60+
error: null,
61+
config: undefined,
6062
data: [
6163
{
6264
news_id: 51184,

example/SelectControl.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ import VueJsonPretty from 'src';
9797
9898
const defaultData = {
9999
status: 200,
100-
error: '',
100+
text: '',
101+
error: null,
102+
config: undefined,
101103
data: [
102104
{
103105
news_id: 51184,

example/VirtualList.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ import VueJsonPretty from 'src';
4848
4949
const defaultData = {
5050
status: 200,
51-
error: '',
51+
text: '',
52+
error: null,
53+
config: undefined,
5254
data: [],
5355
};
5456

src/components/Tree/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export default defineComponent({
297297
style={
298298
props.showLineNumber
299299
? {
300-
paddingLeft: `${Number(flatData.value.length.toString().length) * 12}px`,
300+
paddingLeft: `${Number(originFlatData.value.length.toString().length) * 12}px`,
301301
...props.style,
302302
}
303303
: props.style

src/components/TreeNode/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,13 @@ export default defineComponent({
145145
};
146146

147147
const defaultValue = computed(() => {
148-
const str = (props.node?.content ?? '') + '';
149-
const text = dataType.value === 'string' ? `"${str}"` : str;
150-
return text;
148+
let value = props.node?.content;
149+
if (value === null) {
150+
value = 'null';
151+
} else if (value === undefined) {
152+
value = 'undefined';
153+
}
154+
return dataType.value === 'string' ? `"${value}"` : value + '';
151155
});
152156

153157
const renderValue = () => {

src/components/TreeNode/styles.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
.gen-value-style(@color-null);
5656
}
5757

58+
.@{css-prefix}-value-undefined {
59+
.gen-value-style(@color-undefined);
60+
}
61+
5862
.@{css-prefix}-value-number {
5963
.gen-value-style(@color-number);
6064
}

src/themes.less

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
@color-info: #1d8ce0;
77
@color-error: #ff4949;
88
@color-success: #13ce66;
9+
@color-nil: #D55FDE;
910

1011
/* field values color */
1112
@color-string: @color-success;
1213
@color-number: @color-info;
1314
@color-boolean: @color-info;
14-
@color-null: @color-error;
15+
@color-null: @color-nil;
16+
@color-undefined: @color-nil;
1517

1618
/* highlight */
1719
@highlight-bg-color: #e6f7ff;

src/utils/index.ts

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export function arrFlat<T extends unknown[]>(arr: T): unknown[] {
133133
}
134134

135135
export function cloneDeep<T extends unknown>(source: T, hash = new WeakMap()): T {
136-
if (source === null) return source;
136+
if (source === null || source === undefined) return source;
137137
if (source instanceof Date) return new Date(source) as T;
138138
if (source instanceof RegExp) return new RegExp(source) as T;
139139
if (typeof source !== 'object') return source;
@@ -171,79 +171,3 @@ export function stringToAutoType(source: string): unknown {
171171
}
172172
return value;
173173
}
174-
175-
// function jsonFlattenNext(data: JSONDataType, path = 'root'): JSONFlattenReturnType[] {
176-
// function test(content: unknown, path: string, level: number, options: JSONFlattenOptions) {
177-
// const { type = 'content', key, index, showComma, length } = options || {};
178-
// return {
179-
// content,
180-
// level,
181-
// key,
182-
// index,
183-
// path,
184-
// showComma,
185-
// length,
186-
// type,
187-
// };
188-
// }
189-
190-
// let endObj = {} as Record<string, unknown>;
191-
// let i = 0;
192-
// let output: any = [data];
193-
// let startArr = [];
194-
// while (output.length || endObj[i]) {
195-
// if (i && endObj[i]) {
196-
// const k = endObj[i];
197-
// delete endObj[i];
198-
// startArr.push(k);
199-
// i++;
200-
// } else {
201-
// const now = output.shift();
202-
// if (Array.isArray(now)) {
203-
// startArr.push(
204-
// test('[', path, 0, {
205-
// type: 'arrayStart',
206-
// showComma: false,
207-
// length: now.length,
208-
// }),
209-
// );
210-
// output = now.concat(output);
211-
// Object.keys(endObj)
212-
// .sort((a, b) => Number(b) - Number(a))
213-
// .forEach(id => {
214-
// endObj[Number(id) + now.length + 1] = endObj[id];
215-
// delete endObj[id];
216-
// });
217-
// endObj[i + now.length] = ']';
218-
// } else if (typeof now === 'object') {
219-
// startArr.push(
220-
// test('{', path, 0, {
221-
// type: 'objectStart',
222-
// showComma: false,
223-
// length: Object.keys(now).length,
224-
// }),
225-
// );
226-
// output = Object.keys(now)
227-
// .map(key => now[key])
228-
// .concat(output);
229-
// Object.keys(endObj)
230-
// .sort((a, b) => Number(b) - Number(a))
231-
// .forEach(id => {
232-
// endObj[Number(id) + Object.keys(now).length + 1] = endObj[id];
233-
// delete endObj[id];
234-
// });
235-
// endObj[i + Object.keys(now).length] = '}';
236-
// } else {
237-
// startArr.push(
238-
// test(now, path, 0, {
239-
// type: 'content',
240-
// showComma: false,
241-
// length: 0,
242-
// }),
243-
// );
244-
// }
245-
// }
246-
// }
247-
248-
// return startArr as any;
249-
// }

0 commit comments

Comments
 (0)