@tanstack/devtools-ui 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/header.d.ts +9 -0
- package/dist/esm/components/header.js +50 -0
- package/dist/esm/components/header.js.map +1 -0
- package/dist/esm/components/icons.d.ts +15 -0
- package/dist/esm/components/icons.js +61 -0
- package/dist/esm/components/icons.js.map +1 -0
- package/dist/esm/components/main-panel.js +1 -3
- package/dist/esm/components/main-panel.js.map +1 -1
- package/dist/esm/components/theme.d.ts +12 -0
- package/dist/esm/components/theme.js +30 -0
- package/dist/esm/components/theme.js.map +1 -0
- package/dist/esm/components/tree.d.ts +1 -0
- package/dist/esm/components/tree.js +219 -93
- package/dist/esm/components/tree.js.map +1 -1
- package/dist/esm/icons.d.ts +1 -0
- package/dist/esm/icons.js +17 -0
- package/dist/esm/icons.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +7 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/styles/tokens.js +12 -2
- package/dist/esm/styles/tokens.js.map +1 -1
- package/dist/esm/styles/use-styles.d.ts +16 -2
- package/dist/esm/styles/use-styles.js +208 -68
- package/dist/esm/styles/use-styles.js.map +1 -1
- package/package.json +7 -6
- package/src/components/header.tsx +44 -0
- package/src/components/icons.tsx +1586 -0
- package/src/components/main-panel.tsx +6 -3
- package/src/components/theme.tsx +34 -0
- package/src/components/tree.tsx +148 -32
- package/src/icons.ts +1 -0
- package/src/index.ts +2 -0
- package/src/styles/use-styles.ts +212 -69
- package/dist/cjs/components/button.cjs +0 -23
- package/dist/cjs/components/button.cjs.map +0 -1
- package/dist/cjs/components/button.d.cts +0 -11
- package/dist/cjs/components/checkbox.cjs +0 -55
- package/dist/cjs/components/checkbox.cjs.map +0 -1
- package/dist/cjs/components/checkbox.d.cts +0 -8
- package/dist/cjs/components/input.cjs +0 -57
- package/dist/cjs/components/input.cjs.map +0 -1
- package/dist/cjs/components/input.d.cts +0 -10
- package/dist/cjs/components/logo.cjs +0 -95
- package/dist/cjs/components/logo.cjs.map +0 -1
- package/dist/cjs/components/logo.d.cts +0 -1
- package/dist/cjs/components/main-panel.cjs +0 -24
- package/dist/cjs/components/main-panel.cjs.map +0 -1
- package/dist/cjs/components/main-panel.d.cts +0 -8
- package/dist/cjs/components/section.cjs +0 -75
- package/dist/cjs/components/section.cjs.map +0 -1
- package/dist/cjs/components/section.d.cts +0 -5
- package/dist/cjs/components/select.cjs +0 -59
- package/dist/cjs/components/select.cjs.map +0 -1
- package/dist/cjs/components/select.d.cts +0 -13
- package/dist/cjs/components/tag.cjs +0 -40
- package/dist/cjs/components/tag.cjs.map +0 -1
- package/dist/cjs/components/tag.d.cts +0 -7
- package/dist/cjs/components/tree.cjs +0 -237
- package/dist/cjs/components/tree.cjs.map +0 -1
- package/dist/cjs/components/tree.d.cts +0 -3
- package/dist/cjs/index.cjs +0 -24
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -9
- package/dist/cjs/styles/tokens.cjs +0 -184
- package/dist/cjs/styles/tokens.cjs.map +0 -1
- package/dist/cjs/styles/tokens.d.cts +0 -298
- package/dist/cjs/styles/use-styles.cjs +0 -461
- package/dist/cjs/styles/use-styles.cjs.map +0 -1
- package/dist/cjs/styles/use-styles.d.cts +0 -53
|
@@ -15,11 +15,14 @@ export const MainPanel = ({
|
|
|
15
15
|
withPadding,
|
|
16
16
|
}: PanelProps) => {
|
|
17
17
|
const styles = useStyles()
|
|
18
|
+
|
|
18
19
|
return (
|
|
19
20
|
<div
|
|
20
|
-
class={clsx(
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
class={clsx(
|
|
22
|
+
styles().mainPanel.panel(Boolean(withPadding)),
|
|
23
|
+
className,
|
|
24
|
+
classStyles,
|
|
25
|
+
)}
|
|
23
26
|
>
|
|
24
27
|
{children}
|
|
25
28
|
</div>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createContext, createEffect, createSignal, useContext } from 'solid-js'
|
|
2
|
+
import type { Accessor, JSX } from 'solid-js'
|
|
3
|
+
|
|
4
|
+
export type Theme = 'light' | 'dark'
|
|
5
|
+
|
|
6
|
+
type ThemeContextValue = {
|
|
7
|
+
theme: Accessor<Theme>
|
|
8
|
+
setTheme: (theme: Theme) => void
|
|
9
|
+
}
|
|
10
|
+
const ThemeContext = createContext<ThemeContextValue | undefined>(undefined)
|
|
11
|
+
|
|
12
|
+
export const ThemeContextProvider = (props: {
|
|
13
|
+
children: JSX.Element
|
|
14
|
+
theme: Theme
|
|
15
|
+
}) => {
|
|
16
|
+
const [theme, setTheme] = createSignal<Theme>(props.theme)
|
|
17
|
+
createEffect(() => {
|
|
18
|
+
setTheme(props.theme)
|
|
19
|
+
})
|
|
20
|
+
return (
|
|
21
|
+
<ThemeContext.Provider value={{ theme, setTheme }}>
|
|
22
|
+
{props.children}
|
|
23
|
+
</ThemeContext.Provider>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function useTheme() {
|
|
28
|
+
const context = useContext(ThemeContext)
|
|
29
|
+
if (!context) {
|
|
30
|
+
throw new Error('useTheme must be used within a ThemeContextProvider')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return context
|
|
34
|
+
}
|
package/src/components/tree.tsx
CHANGED
|
@@ -1,9 +1,100 @@
|
|
|
1
|
-
import { For, Show, createSignal } from 'solid-js'
|
|
1
|
+
import { For, Match, Show, Switch, createSignal } from 'solid-js'
|
|
2
2
|
import clsx from 'clsx'
|
|
3
|
-
import { useStyles } from '../styles/use-styles'
|
|
3
|
+
import { css, useStyles } from '../styles/use-styles'
|
|
4
|
+
import { CopiedCopier, Copier, ErrorCopier } from './icons'
|
|
4
5
|
|
|
5
|
-
export function JsonTree(props: { value: any }) {
|
|
6
|
-
return <JsonValue isRoot value={props.value} />
|
|
6
|
+
export function JsonTree(props: { value: any; copyable?: boolean }) {
|
|
7
|
+
return <JsonValue isRoot value={props.value} copyable={props.copyable} />
|
|
8
|
+
}
|
|
9
|
+
type CopyState = 'NoCopy' | 'SuccessCopy' | 'ErrorCopy'
|
|
10
|
+
|
|
11
|
+
const CopyButton = (props: { value: unknown }) => {
|
|
12
|
+
const styles = useStyles()
|
|
13
|
+
const [copyState, setCopyState] = createSignal<CopyState>('NoCopy')
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<button
|
|
17
|
+
class={styles().tree.actionButton}
|
|
18
|
+
title="Copy object to clipboard"
|
|
19
|
+
aria-label={`${
|
|
20
|
+
copyState() === 'NoCopy'
|
|
21
|
+
? 'Copy object to clipboard'
|
|
22
|
+
: copyState() === 'SuccessCopy'
|
|
23
|
+
? 'Object copied to clipboard'
|
|
24
|
+
: 'Error copying object to clipboard'
|
|
25
|
+
}`}
|
|
26
|
+
onClick={
|
|
27
|
+
copyState() === 'NoCopy'
|
|
28
|
+
? () => {
|
|
29
|
+
navigator.clipboard
|
|
30
|
+
.writeText(JSON.stringify(props.value, null, 2))
|
|
31
|
+
.then(
|
|
32
|
+
() => {
|
|
33
|
+
setCopyState('SuccessCopy')
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
setCopyState('NoCopy')
|
|
36
|
+
}, 1500)
|
|
37
|
+
},
|
|
38
|
+
(err) => {
|
|
39
|
+
console.error('Failed to copy: ', err)
|
|
40
|
+
setCopyState('ErrorCopy')
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
setCopyState('NoCopy')
|
|
43
|
+
}, 1500)
|
|
44
|
+
},
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
: undefined
|
|
48
|
+
}
|
|
49
|
+
>
|
|
50
|
+
<Switch>
|
|
51
|
+
<Match when={copyState() === 'NoCopy'}>
|
|
52
|
+
<Copier />
|
|
53
|
+
</Match>
|
|
54
|
+
<Match when={copyState() === 'SuccessCopy'}>
|
|
55
|
+
<CopiedCopier theme={'dark'} />
|
|
56
|
+
</Match>
|
|
57
|
+
<Match when={copyState() === 'ErrorCopy'}>
|
|
58
|
+
<ErrorCopier />
|
|
59
|
+
</Match>
|
|
60
|
+
</Switch>
|
|
61
|
+
</button>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const Expander = (props: { expanded: boolean }) => {
|
|
66
|
+
const styles = useStyles()
|
|
67
|
+
return (
|
|
68
|
+
<span
|
|
69
|
+
class={clsx(
|
|
70
|
+
styles().tree.expander,
|
|
71
|
+
css`
|
|
72
|
+
transform: rotate(${props.expanded ? 90 : 0}deg);
|
|
73
|
+
`,
|
|
74
|
+
props.expanded &&
|
|
75
|
+
css`
|
|
76
|
+
& svg {
|
|
77
|
+
top: -1px;
|
|
78
|
+
}
|
|
79
|
+
`,
|
|
80
|
+
)}
|
|
81
|
+
>
|
|
82
|
+
<svg
|
|
83
|
+
width="16"
|
|
84
|
+
height="16"
|
|
85
|
+
viewBox="0 0 16 16"
|
|
86
|
+
fill="none"
|
|
87
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
88
|
+
>
|
|
89
|
+
<path
|
|
90
|
+
d="M6 12L10 8L6 4"
|
|
91
|
+
stroke-width="2"
|
|
92
|
+
stroke-linecap="round"
|
|
93
|
+
stroke-linejoin="round"
|
|
94
|
+
/>
|
|
95
|
+
</svg>
|
|
96
|
+
</span>
|
|
97
|
+
)
|
|
7
98
|
}
|
|
8
99
|
|
|
9
100
|
function JsonValue(props: {
|
|
@@ -11,8 +102,9 @@ function JsonValue(props: {
|
|
|
11
102
|
keyName?: string
|
|
12
103
|
isRoot?: boolean
|
|
13
104
|
isLastKey?: boolean
|
|
105
|
+
copyable?: boolean
|
|
14
106
|
}) {
|
|
15
|
-
const { value, keyName, isRoot = false, isLastKey } = props
|
|
107
|
+
const { value, keyName, isRoot = false, isLastKey, copyable } = props
|
|
16
108
|
const styles = useStyles()
|
|
17
109
|
|
|
18
110
|
return (
|
|
@@ -44,13 +136,22 @@ function JsonValue(props: {
|
|
|
44
136
|
)
|
|
45
137
|
}
|
|
46
138
|
if (Array.isArray(value)) {
|
|
47
|
-
return
|
|
139
|
+
return (
|
|
140
|
+
<ArrayValue copyable={copyable} keyName={keyName} value={value} />
|
|
141
|
+
)
|
|
48
142
|
}
|
|
49
143
|
if (typeof value === 'object') {
|
|
50
|
-
return
|
|
144
|
+
return (
|
|
145
|
+
<ObjectValue copyable={copyable} keyName={keyName} value={value} />
|
|
146
|
+
)
|
|
51
147
|
}
|
|
52
148
|
return <span />
|
|
53
149
|
})()}
|
|
150
|
+
{copyable && (
|
|
151
|
+
<div class={clsx(styles().tree.actions, 'actions')}>
|
|
152
|
+
<CopyButton value={value} />
|
|
153
|
+
</div>
|
|
154
|
+
)}
|
|
54
155
|
{isLastKey || isRoot ? '' : <span>,</span>}
|
|
55
156
|
</span>
|
|
56
157
|
)
|
|
@@ -59,14 +160,17 @@ function JsonValue(props: {
|
|
|
59
160
|
const ArrayValue = ({
|
|
60
161
|
value,
|
|
61
162
|
keyName,
|
|
163
|
+
copyable,
|
|
62
164
|
}: {
|
|
63
165
|
value: Array<any>
|
|
166
|
+
copyable?: boolean
|
|
64
167
|
keyName?: string
|
|
65
168
|
}) => {
|
|
66
169
|
const styles = useStyles()
|
|
67
170
|
const [expanded, setExpanded] = createSignal(true)
|
|
68
171
|
return (
|
|
69
|
-
<span>
|
|
172
|
+
<span class={styles().tree.expanderContainer}>
|
|
173
|
+
<Expander expanded={expanded()} />
|
|
70
174
|
{keyName && (
|
|
71
175
|
<span
|
|
72
176
|
onclick={(e) => {
|
|
@@ -77,20 +181,25 @@ const ArrayValue = ({
|
|
|
77
181
|
class={clsx(styles().tree.valueKey, styles().tree.collapsible)}
|
|
78
182
|
>
|
|
79
183
|
"{keyName}":{' '}
|
|
184
|
+
<span class={styles().tree.info}>{value.length} items</span>
|
|
80
185
|
</span>
|
|
81
186
|
)}
|
|
82
187
|
<span class={styles().tree.valueBraces}>[</span>
|
|
83
188
|
<Show when={expanded()}>
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
<JsonValue
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
189
|
+
<span class={styles().tree.expandedLine(Boolean(keyName))}>
|
|
190
|
+
<For each={value}>
|
|
191
|
+
{(item, i) => {
|
|
192
|
+
const isLastKey = i() === value.length - 1
|
|
193
|
+
return (
|
|
194
|
+
<JsonValue
|
|
195
|
+
copyable={copyable}
|
|
196
|
+
value={item}
|
|
197
|
+
isLastKey={isLastKey}
|
|
198
|
+
/>
|
|
199
|
+
)
|
|
200
|
+
}}
|
|
201
|
+
</For>
|
|
202
|
+
</span>
|
|
94
203
|
</Show>
|
|
95
204
|
<Show when={!expanded()}>
|
|
96
205
|
<span
|
|
@@ -101,7 +210,7 @@ const ArrayValue = ({
|
|
|
101
210
|
}}
|
|
102
211
|
class={clsx(styles().tree.valueKey, styles().tree.collapsible)}
|
|
103
212
|
>
|
|
104
|
-
{
|
|
213
|
+
{`...`}
|
|
105
214
|
</span>
|
|
106
215
|
</Show>
|
|
107
216
|
<span class={styles().tree.valueBraces}>]</span>
|
|
@@ -112,9 +221,11 @@ const ArrayValue = ({
|
|
|
112
221
|
const ObjectValue = ({
|
|
113
222
|
value,
|
|
114
223
|
keyName,
|
|
224
|
+
copyable,
|
|
115
225
|
}: {
|
|
116
226
|
value: Record<string, any>
|
|
117
227
|
keyName?: string
|
|
228
|
+
copyable?: boolean
|
|
118
229
|
}) => {
|
|
119
230
|
const styles = useStyles()
|
|
120
231
|
const [expanded, setExpanded] = createSignal(true)
|
|
@@ -122,7 +233,8 @@ const ObjectValue = ({
|
|
|
122
233
|
const lastKeyName = keys[keys.length - 1]
|
|
123
234
|
|
|
124
235
|
return (
|
|
125
|
-
<span>
|
|
236
|
+
<span class={styles().tree.expanderContainer}>
|
|
237
|
+
{keyName && <Expander expanded={expanded()} />}
|
|
126
238
|
{keyName && (
|
|
127
239
|
<span
|
|
128
240
|
onClick={(e) => {
|
|
@@ -133,21 +245,25 @@ const ObjectValue = ({
|
|
|
133
245
|
class={clsx(styles().tree.valueKey, styles().tree.collapsible)}
|
|
134
246
|
>
|
|
135
247
|
"{keyName}":{' '}
|
|
248
|
+
<span class={styles().tree.info}>{keys.length} items</span>
|
|
136
249
|
</span>
|
|
137
250
|
)}
|
|
138
251
|
<span class={styles().tree.valueBraces}>{'{'}</span>
|
|
139
252
|
<Show when={expanded()}>
|
|
140
|
-
<
|
|
141
|
-
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
253
|
+
<span class={styles().tree.expandedLine(Boolean(keyName))}>
|
|
254
|
+
<For each={keys}>
|
|
255
|
+
{(k) => (
|
|
256
|
+
<>
|
|
257
|
+
<JsonValue
|
|
258
|
+
value={value[k]}
|
|
259
|
+
keyName={k}
|
|
260
|
+
isLastKey={lastKeyName === k}
|
|
261
|
+
copyable={copyable}
|
|
262
|
+
/>
|
|
263
|
+
</>
|
|
264
|
+
)}
|
|
265
|
+
</For>
|
|
266
|
+
</span>
|
|
151
267
|
</Show>
|
|
152
268
|
<Show when={!expanded()}>
|
|
153
269
|
<span
|
|
@@ -158,7 +274,7 @@ const ObjectValue = ({
|
|
|
158
274
|
}}
|
|
159
275
|
class={clsx(styles().tree.valueKey, styles().tree.collapsible)}
|
|
160
276
|
>
|
|
161
|
-
{
|
|
277
|
+
{`...`}
|
|
162
278
|
</span>
|
|
163
279
|
</Show>
|
|
164
280
|
<span class={styles().tree.valueBraces}>{'}'}</span>
|
package/src/icons.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/icons'
|