MCPcopy Create free account
hub / github.com/TanStack/devtools / ObjectValue

Function ObjectValue

packages/devtools-ui/src/components/tree.tsx:237–352  ·  view source on GitHub ↗
(props: {
  value: Record<string, any>
  keyName?: string
  copyable?: boolean
  defaultExpansionDepth: number
  depth: number
  collapsePaths?: Array<string>
  path: string
  config?: { dateFormat?: string }
})

Source from the content-addressed store, hash-verified

235}
236
237const ObjectValue = (props: {
238 value: Record<string, any>
239 keyName?: string
240 copyable?: boolean
241 defaultExpansionDepth: number
242 depth: number
243 collapsePaths?: Array<string>
244 path: string
245 config?: { dateFormat?: string }
246}) => {
247 const styles = createStyles()
248
249 const [expanded, setExpanded] = createSignal(
250 props.depth <= props.defaultExpansionDepth &&
251 !props.collapsePaths?.includes(props.path),
252 )
253
254 const keys = Object.keys(props.value)
255 const lastKeyName = keys[keys.length - 1]
256
257 if (props.value instanceof Date) {
258 return (
259 <span class={styles().tree.expanderContainer}>
260 {props.keyName && (
261 <span class={clsx(styles().tree.valueKey, styles().tree.collapsible)}>
262 &quot;{props.keyName}&quot;:{' '}
263 </span>
264 )}
265
266 <span class={styles().tree.valueBraces}>
267 {dayjs(props.value).format(
268 props.config?.dateFormat ? props.config.dateFormat : 'DDMMMYY',
269 )}
270 </span>
271 </span>
272 )
273 }
274
275 if (keys.length === 0) {
276 return (
277 <span class={styles().tree.expanderContainer}>
278 {props.keyName && (
279 <span class={clsx(styles().tree.valueKey, styles().tree.collapsible)}>
280 &quot;{props.keyName}&quot;:{' '}
281 </span>
282 )}
283
284 <span class={styles().tree.valueBraces}>{'{}'}</span>
285 </span>
286 )
287 }
288
289 return (
290 <span class={styles().tree.expanderContainer}>
291 {props.keyName && (
292 <Expander
293 onClick={() => setExpanded(!expanded())}
294 expanded={expanded()}

Callers

nothing calls this directly

Calls 1

createStylesFunction · 0.90

Tested by

no test coverage detected