|
1 | 1 | <section class="ngx-json-treeview"> |
2 | 2 | @if (segments().length === 0) { |
3 | | - @let sectionClass = |
4 | | - ['object', 'array'].includes(rootType()) |
5 | | - ? 'punctuation' |
6 | | - : 'segment-type-' + rootType(); |
7 | | - <section [class]="sectionClass"> |
8 | | - <span class="segment-primative"> |
| 3 | + <div [class]="primativeSegmentClass()"> |
| 4 | + <span class="segment-primitive"> |
9 | 5 | {{ asString() }} |
10 | 6 | </span> |
11 | | - </section> |
| 7 | + </div> |
12 | 8 | } @else { |
13 | 9 | @if (_currentDepth() === 0) { |
14 | 10 | <span class="punctuation">{{ openingBrace() }}</span> |
|
19 | 15 | let i = $index; |
20 | 16 | let len = $count |
21 | 17 | ) { |
22 | | - <section [class]="'segment segment-type-' + segment.type"> |
23 | | - @let expandable = isExpandable(segment); |
24 | | - @let empty = isEmpty(segment); |
25 | | - @let openingBrace = openingBraceForSegment(segment); |
26 | | - @let closingBrace = closingBraceForSegment(segment); |
27 | | - @let clickableValue = isClickable(segment); |
28 | | - <section class="segment-main"> |
| 18 | + @let needsComma = i < len - 1; |
| 19 | + @let expandable = isExpandable(segment); |
| 20 | + @let empty = isEmpty(segment); |
| 21 | + @let openingBrace = openingBraceForSegment(segment); |
| 22 | + @let closingBrace = closingBraceForSegment(segment); |
| 23 | + @let clickableValue = isClickable(segment); |
| 24 | + <div [class]="'segment segment-type-' + segment.type"> |
| 25 | + <div class="segment-main"> |
29 | 26 | <span |
30 | 27 | [tabindex]="expandable ? 0 : -1" |
31 | 28 | [class.expandable]="expandable" |
|
39 | 36 | </span> |
40 | 37 | <span class="punctuation">: </span> |
41 | 38 | @if (empty) { |
42 | | - <span |
43 | | - class="punctuation" |
44 | | - >{{ `${openingBrace}${closingBrace}${i < len - 1 ? ',' : ''}` }}</span |
| 39 | + <span class="punctuation" |
| 40 | + >{{ openingBrace }}{{ closingBrace |
| 41 | + }}{{ needsComma ? ',' : '' }}</span |
45 | 42 | > |
46 | 43 | } @else if (!expandable || !segment.expanded) { |
47 | 44 | <span |
|
53 | 50 | (keydown.enter)="onValueClickHandler(segment)" |
54 | 51 | >{{ segment.description }}</span |
55 | 52 | > |
56 | | - <span class="punctuation">{{ i < len - 1 ? ',' : '' }}</span> |
| 53 | + <span class="punctuation">{{ needsComma ? ',' : '' }}</span> |
57 | 54 | } @else { |
58 | | - @if (openingBrace) { |
59 | | - <span class="punctuation"> |
60 | | - {{ openingBrace }} |
61 | | - </span> |
62 | | - } |
| 55 | + <span class="punctuation"> |
| 56 | + {{ openingBrace }} |
| 57 | + </span> |
63 | 58 | } |
64 | | - </section> |
| 59 | + </div> |
65 | 60 | @if (expandable && segment.expanded) { |
66 | | - <section class="children"> |
| 61 | + <div class="children"> |
67 | 62 | <ngx-json-treeview |
68 | 63 | [json]="segment.value" |
69 | 64 | [expanded]="expanded()" |
|
73 | 68 | [_parent]="segment" |
74 | 69 | [_currentDepth]="_currentDepth() + 1" |
75 | 70 | (onValueClick)="onValueClickHandler($event)" /> |
76 | | - @if (closingBrace) { |
77 | | - <span class="punctuation" |
78 | | - >{{ closingBrace }}{{ i < len - 1 ? ',' : '' }}</span |
79 | | - > |
80 | | - } |
81 | | - </section> |
| 71 | + <span class="punctuation"> |
| 72 | + {{ closingBrace }}{{ needsComma ? ',' : '' }} |
| 73 | + </span> |
| 74 | + </div> |
82 | 75 | } |
83 | | - </section> |
| 76 | + </div> |
84 | 77 | } |
85 | 78 | @if (_currentDepth() === 0) { |
86 | 79 | <span class="punctuation">{{ closingBrace() }}</span> |
|
0 commit comments