@dxos/react-ui-syntax-highlighter 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-syntax-highlighter",
3
- "version": "0.8.4-main.69d29f4",
3
+ "version": "0.8.4-main.6fa680abb7",
4
4
  "description": "A syntax highlighter wrapper.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -29,29 +29,28 @@
29
29
  "src"
30
30
  ],
31
31
  "dependencies": {
32
- "jsonpath": "^1.1.1",
32
+ "jsonpath-plus": "^10.3.0",
33
33
  "react-syntax-highlighter": "^15.6.1",
34
- "@dxos/util": "0.8.4-main.69d29f4"
34
+ "@dxos/util": "0.8.4-main.6fa680abb7"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/jsonpath": "^0.2.4",
38
37
  "@types/react": "~19.2.7",
39
38
  "@types/react-dom": "~19.2.3",
40
39
  "@types/react-syntax-highlighter": "^15.5.13",
41
40
  "react": "~19.2.3",
42
41
  "react-dom": "~19.2.3",
43
- "vite": "7.1.9",
44
- "@dxos/random": "0.8.4-main.69d29f4",
45
- "@dxos/storybook-utils": "0.8.4-main.69d29f4",
46
- "@dxos/ui-theme": "0.8.4-main.69d29f4",
47
- "@dxos/util": "0.8.4-main.69d29f4",
48
- "@dxos/react-ui": "0.8.4-main.69d29f4"
42
+ "vite": "^7.1.11",
43
+ "@dxos/random": "0.8.4-main.6fa680abb7",
44
+ "@dxos/react-ui": "0.8.4-main.6fa680abb7",
45
+ "@dxos/ui-theme": "0.8.4-main.6fa680abb7",
46
+ "@dxos/storybook-utils": "0.8.4-main.6fa680abb7",
47
+ "@dxos/util": "0.8.4-main.6fa680abb7"
49
48
  },
50
49
  "peerDependencies": {
51
50
  "react": "~19.2.3",
52
51
  "react-dom": "~19.2.3",
53
- "@dxos/ui-theme": "0.8.4-main.69d29f4",
54
- "@dxos/react-ui": "0.8.4-main.69d29f4"
52
+ "@dxos/react-ui": "0.8.4-main.6fa680abb7",
53
+ "@dxos/ui-theme": "0.8.4-main.6fa680abb7"
55
54
  },
56
55
  "publishConfig": {
57
56
  "access": "public"
@@ -56,7 +56,7 @@ const createData = ({ depth = 2, children = 3 } = {}): any => {
56
56
  const meta = {
57
57
  title: 'ui/react-ui-syntax-highlighter/Json',
58
58
  component: Json,
59
- decorators: [withTheme, withLayout({ layout: 'column' })],
59
+ decorators: [withTheme(), withLayout({ layout: 'column' })],
60
60
  } satisfies Meta<typeof Json>;
61
61
 
62
62
  export default meta;
package/src/Json/Json.tsx CHANGED
@@ -2,8 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- // TODO(burdon): Use to jsonpath-plus.
6
- import jp from 'jsonpath';
5
+ import { JSONPath } from 'jsonpath-plus';
7
6
  import React, { forwardRef, useEffect, useState } from 'react';
8
7
 
9
8
  import { Input, type ThemedClassName } from '@dxos/react-ui';
@@ -27,7 +26,7 @@ export const Json = forwardRef<HTMLDivElement, JsonProps>((props, forwardedRef)
27
26
  return (
28
27
  <SyntaxHighlighter
29
28
  language='json'
30
- classNames={['is-full overflow-y-auto text-sm', classNames]}
29
+ classNames={['w-full overflow-y-auto text-sm', classNames]}
31
30
  data-testid={testId}
32
31
  ref={forwardedRef}
33
32
  >
@@ -47,7 +46,7 @@ export const JsonFilter = forwardRef<HTMLDivElement, JsonProps>(
47
46
  setData(initialData);
48
47
  } else {
49
48
  try {
50
- setData(jp.query(initialData, text));
49
+ setData(JSONPath({ path: text, json: initialData }));
51
50
  setError(null);
52
51
  } catch (err) {
53
52
  setData(initialData);
@@ -57,10 +56,10 @@ export const JsonFilter = forwardRef<HTMLDivElement, JsonProps>(
57
56
  }, [initialData, text]); // TODO(burdon): Need structural diff.
58
57
 
59
58
  return (
60
- <div className='flex flex-col bs-full overflow-hidden' ref={forwardedRef}>
59
+ <div className='flex flex-col h-full overflow-hidden' ref={forwardedRef}>
61
60
  <Input.Root validationValence={error ? 'error' : 'success'}>
62
61
  <Input.TextInput
63
- classNames={['p-1 pli-2 font-mono', error && 'border-rose-500']}
62
+ classNames={['p-1 px-2 font-mono', error && 'border-rose-500']}
64
63
  variant='subdued'
65
64
  value={text}
66
65
  placeholder='JSONPath (e.g., $.graph.nodes)'
@@ -69,7 +68,7 @@ export const JsonFilter = forwardRef<HTMLDivElement, JsonProps>(
69
68
  </Input.Root>
70
69
  <SyntaxHighlighter
71
70
  language='json'
72
- classNames={['is-full overflow-y-auto text-sm', classNames]}
71
+ classNames={['w-full overflow-y-auto text-sm', classNames]}
73
72
  data-testid={testId}
74
73
  >
75
74
  {safeStringify(data, replacer && createReplacer(replacer), 2)}
@@ -4,15 +4,21 @@
4
4
 
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
 
7
- import { withTheme } from '@dxos/react-ui/testing';
7
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
8
8
  import { trim } from '@dxos/util';
9
9
 
10
+ // @ts-ignore - Vite raw import.
11
+ import TEXT from '../../package.json?raw';
12
+
10
13
  import { SyntaxHighlighter } from './SyntaxHighlighter';
11
14
 
12
15
  const meta = {
13
16
  title: 'ui/react-ui-syntax-highlighter/SyntaxHighlighter',
14
17
  component: SyntaxHighlighter,
15
- decorators: [withTheme],
18
+ decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
19
+ parameters: {
20
+ layout: 'fullscreen',
21
+ },
16
22
  } satisfies Meta<typeof SyntaxHighlighter>;
17
23
 
18
24
  export default meta;
@@ -23,7 +29,7 @@ export const Default: Story = {
23
29
  args: {
24
30
  language: 'json',
25
31
  classNames: 'text-sm',
26
- children: JSON.stringify({ message: 'DXOS', initialized: true }, null, 2),
32
+ children: TEXT,
27
33
  },
28
34
  };
29
35
 
@@ -32,7 +38,7 @@ export const Typescript: Story = {
32
38
  language: 'tsx',
33
39
  children: trim`
34
40
  import React from 'react'
35
-
41
+
36
42
  const Test = () => {
37
43
  return <div>Test</div>
38
44
  }
@@ -40,8 +46,4 @@ export const Typescript: Story = {
40
46
  },
41
47
  };
42
48
 
43
- export const Empty: Story = {
44
- args: {
45
- children: false,
46
- },
47
- };
49
+ export const Empty: Story = {};
@@ -7,7 +7,7 @@ import { type SyntaxHighlighterProps as NaturalSyntaxHighlighterProps } from 're
7
7
  import NativeSyntaxHighlighter from 'react-syntax-highlighter/dist/esm/prism-async-light';
8
8
  import { coldarkDark as dark, coldarkCold as light } from 'react-syntax-highlighter/dist/esm/styles/prism';
9
9
 
10
- import { type ThemedClassName, useThemeContext } from '@dxos/react-ui';
10
+ import { ScrollArea, type ThemedClassName, useThemeContext } from '@dxos/react-ui';
11
11
  import { mx } from '@dxos/ui-theme';
12
12
 
13
13
  const zeroWidthSpace = '\u200b';
@@ -36,24 +36,27 @@ export const SyntaxHighlighter = ({
36
36
  const { themeMode } = useThemeContext();
37
37
 
38
38
  return (
39
- <div className={mx('flex is-full p-1 overflow-hidden', classNames)}>
40
- <NativeSyntaxHighlighter
41
- className='!m-0 is-full overflow-auto scrollbar-thin'
42
- language={languages[language as keyof typeof languages] || language}
43
- style={themeMode === 'dark' ? dark : light}
44
- customStyle={{
45
- background: 'unset',
46
- border: 'none',
47
- boxShadow: 'none',
48
- padding: 0,
49
- margin: 0,
50
- }}
51
- {...props}
52
- >
53
- {/* Non-empty fallback prevents collapse. */}
54
- {children || fallback}
55
- </NativeSyntaxHighlighter>
56
- </div>
39
+ <ScrollArea.Root thin classNames={mx('p1', classNames)}>
40
+ <ScrollArea.Viewport>
41
+ <div role='none'>
42
+ <NativeSyntaxHighlighter
43
+ language={languages[language as keyof typeof languages] || language}
44
+ style={themeMode === 'dark' ? dark : light}
45
+ customStyle={{
46
+ background: 'unset',
47
+ border: 'none',
48
+ boxShadow: 'none',
49
+ padding: 0,
50
+ margin: 0,
51
+ }}
52
+ {...props}
53
+ >
54
+ {/* Non-empty fallback prevents collapse. */}
55
+ {children || fallback}
56
+ </NativeSyntaxHighlighter>
57
+ </div>
58
+ </ScrollArea.Viewport>
59
+ </ScrollArea.Root>
57
60
  );
58
61
  };
59
62