Skip to content

Commit 4c3282a

Browse files
committed
fix: incorrect merge
1 parent ce10af6 commit 4c3282a

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

  • packages/devtools-ui/src/components

packages/devtools-ui/src/components/tree.tsx

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function JsonTree<TData, TName extends CollapsiblePaths<TData>>(props: {
88
value: TData
99
copyable?: boolean
1010
defaultExpansionDepth?: number
11-
collapsePath?: TName
11+
collapsePaths?: Array<TName>
1212
}) {
1313
return (
1414
<JsonValue
@@ -18,7 +18,7 @@ export function JsonTree<TData, TName extends CollapsiblePaths<TData>>(props: {
1818
depth={0}
1919
defaultExpansionDepth={props.defaultExpansionDepth ?? 1}
2020
path=""
21-
collapsePath={props.collapsePath}
21+
collapsePaths={props.collapsePaths}
2222
/>
2323
)
2424
}
@@ -33,7 +33,7 @@ function JsonValue(props: {
3333
defaultExpansionDepth: number
3434
depth: number
3535

36-
collapsePath?: string
36+
collapsePaths?: Array<string>
3737
path: string
3838
}) {
3939
const {
@@ -44,13 +44,11 @@ function JsonValue(props: {
4444
copyable,
4545
defaultExpansionDepth,
4646
depth,
47-
collapsePath,
47+
collapsePaths,
4848
path,
4949
} = props
5050
const styles = useStyles()
5151

52-
console.log('path jsonval', path, collapsePath)
53-
5452
return (
5553
<span class={styles().tree.valueContainer(isRoot)}>
5654
{keyName && typeof value !== 'object' && !Array.isArray(value) && (
@@ -87,7 +85,7 @@ function JsonValue(props: {
8785
copyable={copyable}
8886
keyName={keyName}
8987
value={value}
90-
collapsePath={collapsePath}
88+
collapsePaths={collapsePaths}
9189
path={path}
9290
/>
9391
)
@@ -100,7 +98,7 @@ function JsonValue(props: {
10098
copyable={copyable}
10199
keyName={keyName}
102100
value={value}
103-
collapsePath={collapsePath}
101+
collapsePaths={collapsePaths}
104102
path={path}
105103
/>
106104
)
@@ -123,21 +121,21 @@ const ArrayValue = ({
123121
copyable,
124122
defaultExpansionDepth,
125123
depth,
126-
collapsePath,
124+
collapsePaths,
127125
path,
128126
}: {
129127
value: Array<any>
130128
copyable?: boolean
131129
keyName?: string
132130
defaultExpansionDepth: number
133131
depth: number
134-
collapsePath?: string
132+
collapsePaths?: Array<string>
135133
path: string
136134
}) => {
137135
const styles = useStyles()
138136

139137
const [expanded, setExpanded] = createSignal(
140-
depth <= defaultExpansionDepth && collapsePath !== path,
138+
depth <= defaultExpansionDepth && !collapsePaths?.includes(path),
141139
)
142140

143141
if (value.length === 0) {
@@ -148,6 +146,7 @@ const ArrayValue = ({
148146
&quot;{keyName}&quot;:{' '}
149147
</span>
150148
)}
149+
151150
<span class={styles().tree.valueBraces}>[]</span>
152151
</span>
153152
)
@@ -158,6 +157,7 @@ const ArrayValue = ({
158157
onClick={() => setExpanded(!expanded())}
159158
expanded={expanded()}
160159
/>
160+
161161
{keyName && (
162162
<span
163163
onclick={(e) => {
@@ -171,7 +171,9 @@ const ArrayValue = ({
171171
<span class={styles().tree.info}>{value.length} items</span>
172172
</span>
173173
)}
174+
174175
<span class={styles().tree.valueBraces}>[</span>
176+
175177
<Show when={expanded()}>
176178
<span class={styles().tree.expandedLine(Boolean(keyName))}>
177179
<For each={value}>
@@ -184,7 +186,7 @@ const ArrayValue = ({
184186
isLastKey={isLastKey}
185187
defaultExpansionDepth={defaultExpansionDepth}
186188
depth={depth + 1}
187-
collapsePath={collapsePath}
189+
collapsePaths={collapsePaths}
188190
path={path ? `${path}[${i()}]` : `[${i()}]`}
189191
/>
190192
)
@@ -216,21 +218,21 @@ const ObjectValue = ({
216218
copyable,
217219
defaultExpansionDepth,
218220
depth,
219-
collapsePath,
221+
collapsePaths,
220222
path,
221223
}: {
222224
value: Record<string, any>
223225
keyName?: string
224226
copyable?: boolean
225227
defaultExpansionDepth: number
226228
depth: number
227-
collapsePath?: string
229+
collapsePaths?: Array<string>
228230
path: string
229231
}) => {
230232
const styles = useStyles()
231233

232234
const [expanded, setExpanded] = createSignal(
233-
depth <= defaultExpansionDepth && collapsePath !== path,
235+
depth <= defaultExpansionDepth && !collapsePaths?.includes(path),
234236
)
235237

236238
const keys = Object.keys(value)
@@ -244,6 +246,7 @@ const ObjectValue = ({
244246
&quot;{keyName}&quot;:{' '}
245247
</span>
246248
)}
249+
247250
<span class={styles().tree.valueBraces}>{'{}'}</span>
248251
</span>
249252
)
@@ -257,6 +260,7 @@ const ObjectValue = ({
257260
expanded={expanded()}
258261
/>
259262
)}
263+
260264
{keyName && (
261265
<span
262266
onClick={(e) => {
@@ -270,7 +274,9 @@ const ObjectValue = ({
270274
<span class={styles().tree.info}>{keys.length} items</span>
271275
</span>
272276
)}
277+
273278
<span class={styles().tree.valueBraces}>{'{'}</span>
279+
274280
<Show when={expanded()}>
275281
<span class={styles().tree.expandedLine(Boolean(keyName))}>
276282
<For each={keys}>
@@ -283,7 +289,7 @@ const ObjectValue = ({
283289
copyable={copyable}
284290
defaultExpansionDepth={defaultExpansionDepth}
285291
depth={depth + 1}
286-
collapsePath={collapsePath}
292+
collapsePaths={collapsePaths}
287293
path={`${path}${path ? '.' : ''}${k}`}
288294
/>
289295
</>
@@ -304,6 +310,7 @@ const ObjectValue = ({
304310
{`...`}
305311
</span>
306312
</Show>
313+
307314
<span class={styles().tree.valueBraces}>{'}'}</span>
308315
</span>
309316
)

0 commit comments

Comments
 (0)