@dxos/react-ui-syntax-highlighter 0.8.4-main.b97322e → 0.8.4-main.bc674ce
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/lib/browser/index.mjs +81 -79
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +81 -79
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/Json/Json.d.ts +19 -2
- package/dist/types/src/Json/Json.d.ts.map +1 -1
- package/dist/types/src/Json/Json.stories.d.ts +22 -0
- package/dist/types/src/Json/Json.stories.d.ts.map +1 -0
- package/dist/types/src/SyntaxHighlighter/SyntaxHighlighter.d.ts +7 -3
- package/dist/types/src/SyntaxHighlighter/SyntaxHighlighter.d.ts.map +1 -1
- package/dist/types/src/SyntaxHighlighter/SyntaxHighlighter.stories.d.ts +6 -3
- package/dist/types/src/SyntaxHighlighter/SyntaxHighlighter.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -16
- package/src/Json/Json.stories.tsx +106 -0
- package/src/Json/Json.tsx +63 -40
- package/src/SyntaxHighlighter/SyntaxHighlighter.stories.tsx +12 -7
- package/src/SyntaxHighlighter/SyntaxHighlighter.tsx +34 -20
|
@@ -1,99 +1,101 @@
|
|
|
1
1
|
// src/Json/Json.tsx
|
|
2
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
3
2
|
import jp from "jsonpath";
|
|
4
|
-
import React2, { useEffect, useState } from "react";
|
|
3
|
+
import React2, { forwardRef, useEffect, useState } from "react";
|
|
5
4
|
import { Input } from "@dxos/react-ui";
|
|
5
|
+
import { createReplacer, safeStringify } from "@dxos/util";
|
|
6
6
|
|
|
7
7
|
// src/SyntaxHighlighter/index.ts
|
|
8
8
|
import createElement from "react-syntax-highlighter/dist/esm/create-element";
|
|
9
9
|
|
|
10
10
|
// src/SyntaxHighlighter/SyntaxHighlighter.tsx
|
|
11
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
12
11
|
import React from "react";
|
|
13
|
-
import NativeSyntaxHighlighter from "react-syntax-highlighter/dist/esm/
|
|
14
|
-
import {
|
|
12
|
+
import NativeSyntaxHighlighter from "react-syntax-highlighter/dist/esm/prism-async-light";
|
|
13
|
+
import { coldarkDark as dark, coldarkCold as light } from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
15
14
|
import { useThemeContext } from "@dxos/react-ui";
|
|
16
|
-
import { mx } from "@dxos/
|
|
15
|
+
import { mx } from "@dxos/ui-theme";
|
|
17
16
|
var zeroWidthSpace = "\u200B";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
var SyntaxHighlighter = ({ classNames, children, language = "text", fallback = zeroWidthSpace, ...props }) => {
|
|
18
|
+
const { themeMode } = useThemeContext();
|
|
19
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
20
|
+
className: mx("flex is-full p-1 overflow-hidden", classNames)
|
|
21
|
+
}, /* @__PURE__ */ React.createElement(NativeSyntaxHighlighter, {
|
|
22
|
+
className: "!m-0 is-full overflow-auto scrollbar-thin",
|
|
23
|
+
language: languages[language] || language,
|
|
24
|
+
style: themeMode === "dark" ? dark : light,
|
|
25
|
+
customStyle: {
|
|
26
|
+
background: "unset",
|
|
27
|
+
border: "none",
|
|
28
|
+
boxShadow: "none",
|
|
29
|
+
padding: 0,
|
|
30
|
+
margin: 0
|
|
31
|
+
},
|
|
32
|
+
...props
|
|
33
|
+
}, children || fallback));
|
|
34
|
+
};
|
|
35
|
+
var languages = {
|
|
36
|
+
js: "javascript",
|
|
37
|
+
ts: "typescript"
|
|
32
38
|
};
|
|
33
39
|
|
|
34
40
|
// src/Json/Json.tsx
|
|
35
|
-
var Json =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
|
|
39
|
-
language: "json",
|
|
40
|
-
classNames: [
|
|
41
|
-
"w-full",
|
|
42
|
-
classNames
|
|
43
|
-
],
|
|
44
|
-
"data-testid": testId
|
|
45
|
-
}, JSON.stringify(data, null, 2));
|
|
46
|
-
} finally {
|
|
47
|
-
_effect.f();
|
|
41
|
+
var Json = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
42
|
+
if (props.filter) {
|
|
43
|
+
return /* @__PURE__ */ React2.createElement(JsonFilter, props);
|
|
48
44
|
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
45
|
+
const { classNames, data, replacer, testId } = props;
|
|
46
|
+
return /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
|
|
47
|
+
language: "json",
|
|
48
|
+
classNames: [
|
|
49
|
+
"is-full overflow-y-auto text-sm",
|
|
50
|
+
classNames
|
|
51
|
+
],
|
|
52
|
+
"data-testid": testId,
|
|
53
|
+
ref: forwardedRef
|
|
54
|
+
}, safeStringify(data, replacer && createReplacer(replacer), 2));
|
|
55
|
+
});
|
|
56
|
+
var JsonFilter = /* @__PURE__ */ forwardRef(({ classNames, data: initialData, replacer, testId }, forwardedRef) => {
|
|
57
|
+
const [data, setData] = useState(initialData);
|
|
58
|
+
const [text, setText] = useState("");
|
|
59
|
+
const [error, setError] = useState(null);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!initialData || !text.trim().length) {
|
|
62
|
+
setData(initialData);
|
|
63
|
+
} else {
|
|
64
|
+
try {
|
|
65
|
+
setData(jp.query(initialData, text));
|
|
66
|
+
setError(null);
|
|
67
|
+
} catch (err) {
|
|
58
68
|
setData(initialData);
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
setData(jp.query(initialData, text));
|
|
62
|
-
setError(null);
|
|
63
|
-
} catch (err) {
|
|
64
|
-
setData(initialData);
|
|
65
|
-
setError(err);
|
|
66
|
-
}
|
|
69
|
+
setError(err);
|
|
67
70
|
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
};
|
|
71
|
+
}
|
|
72
|
+
}, [
|
|
73
|
+
initialData,
|
|
74
|
+
text
|
|
75
|
+
]);
|
|
76
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
77
|
+
className: "flex flex-col bs-full overflow-hidden",
|
|
78
|
+
ref: forwardedRef
|
|
79
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, {
|
|
80
|
+
validationValence: error ? "error" : "success"
|
|
81
|
+
}, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
82
|
+
classNames: [
|
|
83
|
+
"p-1 pli-2 font-mono",
|
|
84
|
+
error && "border-rose-500"
|
|
85
|
+
],
|
|
86
|
+
variant: "subdued",
|
|
87
|
+
value: text,
|
|
88
|
+
placeholder: "JSONPath (e.g., $.graph.nodes)",
|
|
89
|
+
onChange: (event) => setText(event.target.value)
|
|
90
|
+
})), /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
|
|
91
|
+
language: "json",
|
|
92
|
+
classNames: [
|
|
93
|
+
"is-full overflow-y-auto text-sm",
|
|
94
|
+
classNames
|
|
95
|
+
],
|
|
96
|
+
"data-testid": testId
|
|
97
|
+
}, safeStringify(data, replacer && createReplacer(replacer), 2)));
|
|
98
|
+
});
|
|
97
99
|
export {
|
|
98
100
|
Json,
|
|
99
101
|
JsonFilter,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Json/Json.tsx", "../../../src/SyntaxHighlighter/index.ts", "../../../src/SyntaxHighlighter/SyntaxHighlighter.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// TODO(burdon):
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jp", "React", "useEffect", "useState", "Input", "createElement", "React", "NativeSyntaxHighlighter", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// TODO(burdon): Use to jsonpath-plus.\nimport jp from 'jsonpath';\nimport React, { forwardRef, useEffect, useState } from 'react';\n\nimport { Input, type ThemedClassName } from '@dxos/react-ui';\nimport { type CreateReplacerProps, createReplacer, safeStringify } from '@dxos/util';\n\nimport { SyntaxHighlighter } from '../SyntaxHighlighter';\n\nexport type JsonProps = ThemedClassName<{\n data?: any;\n filter?: boolean;\n replacer?: CreateReplacerProps;\n testId?: string;\n}>;\n\nexport const Json = forwardRef<HTMLDivElement, JsonProps>((props, forwardedRef) => {\n if (props.filter) {\n return <JsonFilter {...props} />;\n }\n\n const { classNames, data, replacer, testId } = props;\n return (\n <SyntaxHighlighter\n language='json'\n classNames={['is-full overflow-y-auto text-sm', classNames]}\n data-testid={testId}\n ref={forwardedRef}\n >\n {safeStringify(data, replacer && createReplacer(replacer), 2)}\n </SyntaxHighlighter>\n );\n});\n\nexport const JsonFilter = forwardRef<HTMLDivElement, JsonProps>(\n ({ classNames, data: initialData, replacer, testId }, forwardedRef) => {\n const [data, setData] = useState(initialData);\n const [text, setText] = useState('');\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n if (!initialData || !text.trim().length) {\n setData(initialData);\n } else {\n try {\n setData(jp.query(initialData, text));\n setError(null);\n } catch (err) {\n setData(initialData);\n setError(err as Error);\n }\n }\n }, [initialData, text]); // TODO(burdon): Need structural diff.\n\n return (\n <div className='flex flex-col bs-full overflow-hidden' ref={forwardedRef}>\n <Input.Root validationValence={error ? 'error' : 'success'}>\n <Input.TextInput\n classNames={['p-1 pli-2 font-mono', error && 'border-rose-500']}\n variant='subdued'\n value={text}\n placeholder='JSONPath (e.g., $.graph.nodes)'\n onChange={(event) => setText(event.target.value)}\n />\n </Input.Root>\n <SyntaxHighlighter\n language='json'\n classNames={['is-full overflow-y-auto text-sm', classNames]}\n data-testid={testId}\n >\n {safeStringify(data, replacer && createReplacer(replacer), 2)}\n </SyntaxHighlighter>\n </div>\n );\n },\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\n// eslint-disable-next-line no-restricted-imports\nimport createElement from 'react-syntax-highlighter/dist/esm/create-element';\n\nexport { createElement };\n\nexport * from './SyntaxHighlighter';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\nimport { type SyntaxHighlighterProps as NaturalSyntaxHighlighterProps } from 'react-syntax-highlighter';\nimport NativeSyntaxHighlighter from 'react-syntax-highlighter/dist/esm/prism-async-light';\nimport { coldarkDark as dark, coldarkCold as light } from 'react-syntax-highlighter/dist/esm/styles/prism';\n\nimport { type ThemedClassName, useThemeContext } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nconst zeroWidthSpace = '\\u200b';\n\nexport type SyntaxHighlighterProps = ThemedClassName<\n NaturalSyntaxHighlighterProps & {\n fallback?: string;\n }\n>;\n\n/**\n * NOTE: Using `light-async` version directly from dist to avoid any chance of the heavy one being loaded.\n * The lightweight version will load specific language parsers asynchronously.\n *\n * https://github.com/react-syntax-highlighter/react-syntax-highlighter\n * https://react-syntax-highlighter.github.io/react-syntax-highlighter/demo/prism.html\n */\n// TODO(burdon): Replace with react-ui-editor (and reuse styles).\nexport const SyntaxHighlighter = ({\n classNames,\n children,\n language = 'text',\n fallback = zeroWidthSpace,\n ...props\n}: SyntaxHighlighterProps) => {\n const { themeMode } = useThemeContext();\n\n return (\n <div className={mx('flex is-full p-1 overflow-hidden', classNames)}>\n <NativeSyntaxHighlighter\n className='!m-0 is-full overflow-auto scrollbar-thin'\n language={languages[language as keyof typeof languages] || language}\n style={themeMode === 'dark' ? dark : light}\n customStyle={{\n background: 'unset',\n border: 'none',\n boxShadow: 'none',\n padding: 0,\n margin: 0,\n }}\n {...props}\n >\n {/* Non-empty fallback prevents collapse. */}\n {children || fallback}\n </NativeSyntaxHighlighter>\n </div>\n );\n};\n\nconst languages = {\n js: 'javascript',\n ts: 'typescript',\n};\n"],
|
|
5
|
+
"mappings": ";AAKA,OAAOA,QAAQ;AACf,OAAOC,UAASC,YAAYC,WAAWC,gBAAgB;AAEvD,SAASC,aAAmC;AAC5C,SAAmCC,gBAAgBC,qBAAqB;;;ACJxE,OAAOC,mBAAmB;;;ACD1B,OAAOC,WAAW;AAElB,OAAOC,6BAA6B;AACpC,SAASC,eAAeC,MAAMC,eAAeC,aAAa;AAE1D,SAA+BC,uBAAuB;AACtD,SAASC,UAAU;AAEnB,IAAMC,iBAAiB;AAgBhB,IAAMC,oBAAoB,CAAC,EAChCC,YACAC,UACAC,WAAW,QACXC,WAAWL,gBACX,GAAGM,MAAAA,MACoB;AACvB,QAAM,EAAEC,UAAS,IAAKC,gBAAAA;AAEtB,SACE,sBAAA,cAACC,OAAAA;IAAIC,WAAWC,GAAG,oCAAoCT,UAAAA;KACrD,sBAAA,cAACU,yBAAAA;IACCF,WAAU;IACVN,UAAUS,UAAUT,QAAAA,KAAuCA;IAC3DU,OAAOP,cAAc,SAASQ,OAAOC;IACrCC,aAAa;MACXC,YAAY;MACZC,QAAQ;MACRC,WAAW;MACXC,SAAS;MACTC,QAAQ;IACV;IACC,GAAGhB;KAGHH,YAAYE,QAAAA,CAAAA;AAIrB;AAEA,IAAMQ,YAAY;EAChBU,IAAI;EACJC,IAAI;AACN;;;AF1CO,IAAMC,OAAOC,2BAAsC,CAACC,OAAOC,iBAAAA;AAChE,MAAID,MAAME,QAAQ;AAChB,WAAO,gBAAAC,OAAA,cAACC,YAAeJ,KAAAA;EACzB;AAEA,QAAM,EAAEK,YAAYC,MAAMC,UAAUC,OAAM,IAAKR;AAC/C,SACE,gBAAAG,OAAA,cAACM,mBAAAA;IACCC,UAAS;IACTL,YAAY;MAAC;MAAmCA;;IAChDM,eAAaH;IACbI,KAAKX;KAEJY,cAAcP,MAAMC,YAAYO,eAAeP,QAAAA,GAAW,CAAA,CAAA;AAGjE,CAAA;AAEO,IAAMH,aAAaL,2BACxB,CAAC,EAAEM,YAAYC,MAAMS,aAAaR,UAAUC,OAAM,GAAIP,iBAAAA;AACpD,QAAM,CAACK,MAAMU,OAAAA,IAAWC,SAASF,WAAAA;AACjC,QAAM,CAACG,MAAMC,OAAAA,IAAWF,SAAS,EAAA;AACjC,QAAM,CAACG,OAAOC,QAAAA,IAAYJ,SAAuB,IAAA;AAEjDK,YAAU,MAAA;AACR,QAAI,CAACP,eAAe,CAACG,KAAKK,KAAI,EAAGC,QAAQ;AACvCR,cAAQD,WAAAA;IACV,OAAO;AACL,UAAI;AACFC,gBAAQS,GAAGC,MAAMX,aAAaG,IAAAA,CAAAA;AAC9BG,iBAAS,IAAA;MACX,SAASM,KAAK;AACZX,gBAAQD,WAAAA;AACRM,iBAASM,GAAAA;MACX;IACF;EACF,GAAG;IAACZ;IAAaG;GAAK;AAEtB,SACE,gBAAAf,OAAA,cAACyB,OAAAA;IAAIC,WAAU;IAAwCjB,KAAKX;KAC1D,gBAAAE,OAAA,cAAC2B,MAAMC,MAAI;IAACC,mBAAmBZ,QAAQ,UAAU;KAC/C,gBAAAjB,OAAA,cAAC2B,MAAMG,WAAS;IACd5B,YAAY;MAAC;MAAuBe,SAAS;;IAC7Cc,SAAQ;IACRC,OAAOjB;IACPkB,aAAY;IACZC,UAAU,CAACC,UAAUnB,QAAQmB,MAAMC,OAAOJ,KAAK;OAGnD,gBAAAhC,OAAA,cAACM,mBAAAA;IACCC,UAAS;IACTL,YAAY;MAAC;MAAmCA;;IAChDM,eAAaH;KAEZK,cAAcP,MAAMC,YAAYO,eAAeP,QAAAA,GAAW,CAAA,CAAA,CAAA;AAInE,CAAA;",
|
|
6
|
+
"names": ["jp", "React", "forwardRef", "useEffect", "useState", "Input", "createReplacer", "safeStringify", "createElement", "React", "NativeSyntaxHighlighter", "coldarkDark", "dark", "coldarkCold", "light", "useThemeContext", "mx", "zeroWidthSpace", "SyntaxHighlighter", "classNames", "children", "language", "fallback", "props", "themeMode", "useThemeContext", "div", "className", "mx", "NativeSyntaxHighlighter", "languages", "style", "dark", "light", "customStyle", "background", "border", "boxShadow", "padding", "margin", "js", "ts", "Json", "forwardRef", "props", "forwardedRef", "filter", "React", "JsonFilter", "classNames", "data", "replacer", "testId", "SyntaxHighlighter", "language", "data-testid", "ref", "safeStringify", "createReplacer", "initialData", "setData", "useState", "text", "setText", "error", "setError", "useEffect", "trim", "length", "jp", "query", "err", "div", "className", "Input", "Root", "validationValence", "TextInput", "variant", "value", "placeholder", "onChange", "event", "target"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/SyntaxHighlighter/SyntaxHighlighter.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"src/SyntaxHighlighter/SyntaxHighlighter.tsx":{"bytes":5909,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/prism-async-light","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/styles/prism","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"format":"esm"},"src/SyntaxHighlighter/index.ts":{"bytes":979,"imports":[{"path":"react-syntax-highlighter/dist/esm/create-element","kind":"import-statement","external":true},{"path":"src/SyntaxHighlighter/SyntaxHighlighter.tsx","kind":"import-statement","original":"./SyntaxHighlighter"}],"format":"esm"},"src/Json/Json.tsx":{"bytes":8440,"imports":[{"path":"jsonpath","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/SyntaxHighlighter/index.ts","kind":"import-statement","original":"../SyntaxHighlighter"}],"format":"esm"},"src/Json/index.ts":{"bytes":463,"imports":[{"path":"src/Json/Json.tsx","kind":"import-statement","original":"./Json"}],"format":"esm"},"src/index.ts":{"bytes":571,"imports":[{"path":"src/Json/index.ts","kind":"import-statement","original":"./Json"},{"path":"src/SyntaxHighlighter/index.ts","kind":"import-statement","original":"./SyntaxHighlighter"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7909},"dist/lib/browser/index.mjs":{"imports":[{"path":"jsonpath","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/create-element","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/prism-async-light","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/styles/prism","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"exports":["Json","JsonFilter","SyntaxHighlighter","createElement"],"entryPoint":"src/index.ts","inputs":{"src/Json/Json.tsx":{"bytesInOutput":2070},"src/SyntaxHighlighter/index.ts":{"bytesInOutput":78},"src/SyntaxHighlighter/SyntaxHighlighter.tsx":{"bytesInOutput":1081},"src/index.ts":{"bytesInOutput":0}},"bytes":3461}}}
|
|
@@ -1,101 +1,103 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
3
|
// src/Json/Json.tsx
|
|
4
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
5
4
|
import jp from "jsonpath";
|
|
6
|
-
import React2, { useEffect, useState } from "react";
|
|
5
|
+
import React2, { forwardRef, useEffect, useState } from "react";
|
|
7
6
|
import { Input } from "@dxos/react-ui";
|
|
7
|
+
import { createReplacer, safeStringify } from "@dxos/util";
|
|
8
8
|
|
|
9
9
|
// src/SyntaxHighlighter/index.ts
|
|
10
10
|
import createElement from "react-syntax-highlighter/dist/esm/create-element";
|
|
11
11
|
|
|
12
12
|
// src/SyntaxHighlighter/SyntaxHighlighter.tsx
|
|
13
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
14
13
|
import React from "react";
|
|
15
|
-
import NativeSyntaxHighlighter from "react-syntax-highlighter/dist/esm/
|
|
16
|
-
import {
|
|
14
|
+
import NativeSyntaxHighlighter from "react-syntax-highlighter/dist/esm/prism-async-light";
|
|
15
|
+
import { coldarkDark as dark, coldarkCold as light } from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
17
16
|
import { useThemeContext } from "@dxos/react-ui";
|
|
18
|
-
import { mx } from "@dxos/
|
|
17
|
+
import { mx } from "@dxos/ui-theme";
|
|
19
18
|
var zeroWidthSpace = "\u200B";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
var SyntaxHighlighter = ({ classNames, children, language = "text", fallback = zeroWidthSpace, ...props }) => {
|
|
20
|
+
const { themeMode } = useThemeContext();
|
|
21
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
22
|
+
className: mx("flex is-full p-1 overflow-hidden", classNames)
|
|
23
|
+
}, /* @__PURE__ */ React.createElement(NativeSyntaxHighlighter, {
|
|
24
|
+
className: "!m-0 is-full overflow-auto scrollbar-thin",
|
|
25
|
+
language: languages[language] || language,
|
|
26
|
+
style: themeMode === "dark" ? dark : light,
|
|
27
|
+
customStyle: {
|
|
28
|
+
background: "unset",
|
|
29
|
+
border: "none",
|
|
30
|
+
boxShadow: "none",
|
|
31
|
+
padding: 0,
|
|
32
|
+
margin: 0
|
|
33
|
+
},
|
|
34
|
+
...props
|
|
35
|
+
}, children || fallback));
|
|
36
|
+
};
|
|
37
|
+
var languages = {
|
|
38
|
+
js: "javascript",
|
|
39
|
+
ts: "typescript"
|
|
34
40
|
};
|
|
35
41
|
|
|
36
42
|
// src/Json/Json.tsx
|
|
37
|
-
var Json =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
|
|
41
|
-
language: "json",
|
|
42
|
-
classNames: [
|
|
43
|
-
"w-full",
|
|
44
|
-
classNames
|
|
45
|
-
],
|
|
46
|
-
"data-testid": testId
|
|
47
|
-
}, JSON.stringify(data, null, 2));
|
|
48
|
-
} finally {
|
|
49
|
-
_effect.f();
|
|
43
|
+
var Json = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
44
|
+
if (props.filter) {
|
|
45
|
+
return /* @__PURE__ */ React2.createElement(JsonFilter, props);
|
|
50
46
|
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
const { classNames, data, replacer, testId } = props;
|
|
48
|
+
return /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
|
|
49
|
+
language: "json",
|
|
50
|
+
classNames: [
|
|
51
|
+
"is-full overflow-y-auto text-sm",
|
|
52
|
+
classNames
|
|
53
|
+
],
|
|
54
|
+
"data-testid": testId,
|
|
55
|
+
ref: forwardedRef
|
|
56
|
+
}, safeStringify(data, replacer && createReplacer(replacer), 2));
|
|
57
|
+
});
|
|
58
|
+
var JsonFilter = /* @__PURE__ */ forwardRef(({ classNames, data: initialData, replacer, testId }, forwardedRef) => {
|
|
59
|
+
const [data, setData] = useState(initialData);
|
|
60
|
+
const [text, setText] = useState("");
|
|
61
|
+
const [error, setError] = useState(null);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (!initialData || !text.trim().length) {
|
|
64
|
+
setData(initialData);
|
|
65
|
+
} else {
|
|
66
|
+
try {
|
|
67
|
+
setData(jp.query(initialData, text));
|
|
68
|
+
setError(null);
|
|
69
|
+
} catch (err) {
|
|
60
70
|
setData(initialData);
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
setData(jp.query(initialData, text));
|
|
64
|
-
setError(null);
|
|
65
|
-
} catch (err) {
|
|
66
|
-
setData(initialData);
|
|
67
|
-
setError(err);
|
|
68
|
-
}
|
|
71
|
+
setError(err);
|
|
69
72
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
};
|
|
73
|
+
}
|
|
74
|
+
}, [
|
|
75
|
+
initialData,
|
|
76
|
+
text
|
|
77
|
+
]);
|
|
78
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
79
|
+
className: "flex flex-col bs-full overflow-hidden",
|
|
80
|
+
ref: forwardedRef
|
|
81
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, {
|
|
82
|
+
validationValence: error ? "error" : "success"
|
|
83
|
+
}, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
84
|
+
classNames: [
|
|
85
|
+
"p-1 pli-2 font-mono",
|
|
86
|
+
error && "border-rose-500"
|
|
87
|
+
],
|
|
88
|
+
variant: "subdued",
|
|
89
|
+
value: text,
|
|
90
|
+
placeholder: "JSONPath (e.g., $.graph.nodes)",
|
|
91
|
+
onChange: (event) => setText(event.target.value)
|
|
92
|
+
})), /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
|
|
93
|
+
language: "json",
|
|
94
|
+
classNames: [
|
|
95
|
+
"is-full overflow-y-auto text-sm",
|
|
96
|
+
classNames
|
|
97
|
+
],
|
|
98
|
+
"data-testid": testId
|
|
99
|
+
}, safeStringify(data, replacer && createReplacer(replacer), 2)));
|
|
100
|
+
});
|
|
99
101
|
export {
|
|
100
102
|
Json,
|
|
101
103
|
JsonFilter,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Json/Json.tsx", "../../../src/SyntaxHighlighter/index.ts", "../../../src/SyntaxHighlighter/SyntaxHighlighter.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// TODO(burdon):
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jp", "React", "useEffect", "useState", "Input", "createElement", "React", "NativeSyntaxHighlighter", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// TODO(burdon): Use to jsonpath-plus.\nimport jp from 'jsonpath';\nimport React, { forwardRef, useEffect, useState } from 'react';\n\nimport { Input, type ThemedClassName } from '@dxos/react-ui';\nimport { type CreateReplacerProps, createReplacer, safeStringify } from '@dxos/util';\n\nimport { SyntaxHighlighter } from '../SyntaxHighlighter';\n\nexport type JsonProps = ThemedClassName<{\n data?: any;\n filter?: boolean;\n replacer?: CreateReplacerProps;\n testId?: string;\n}>;\n\nexport const Json = forwardRef<HTMLDivElement, JsonProps>((props, forwardedRef) => {\n if (props.filter) {\n return <JsonFilter {...props} />;\n }\n\n const { classNames, data, replacer, testId } = props;\n return (\n <SyntaxHighlighter\n language='json'\n classNames={['is-full overflow-y-auto text-sm', classNames]}\n data-testid={testId}\n ref={forwardedRef}\n >\n {safeStringify(data, replacer && createReplacer(replacer), 2)}\n </SyntaxHighlighter>\n );\n});\n\nexport const JsonFilter = forwardRef<HTMLDivElement, JsonProps>(\n ({ classNames, data: initialData, replacer, testId }, forwardedRef) => {\n const [data, setData] = useState(initialData);\n const [text, setText] = useState('');\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n if (!initialData || !text.trim().length) {\n setData(initialData);\n } else {\n try {\n setData(jp.query(initialData, text));\n setError(null);\n } catch (err) {\n setData(initialData);\n setError(err as Error);\n }\n }\n }, [initialData, text]); // TODO(burdon): Need structural diff.\n\n return (\n <div className='flex flex-col bs-full overflow-hidden' ref={forwardedRef}>\n <Input.Root validationValence={error ? 'error' : 'success'}>\n <Input.TextInput\n classNames={['p-1 pli-2 font-mono', error && 'border-rose-500']}\n variant='subdued'\n value={text}\n placeholder='JSONPath (e.g., $.graph.nodes)'\n onChange={(event) => setText(event.target.value)}\n />\n </Input.Root>\n <SyntaxHighlighter\n language='json'\n classNames={['is-full overflow-y-auto text-sm', classNames]}\n data-testid={testId}\n >\n {safeStringify(data, replacer && createReplacer(replacer), 2)}\n </SyntaxHighlighter>\n </div>\n );\n },\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\n// eslint-disable-next-line no-restricted-imports\nimport createElement from 'react-syntax-highlighter/dist/esm/create-element';\n\nexport { createElement };\n\nexport * from './SyntaxHighlighter';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\nimport { type SyntaxHighlighterProps as NaturalSyntaxHighlighterProps } from 'react-syntax-highlighter';\nimport NativeSyntaxHighlighter from 'react-syntax-highlighter/dist/esm/prism-async-light';\nimport { coldarkDark as dark, coldarkCold as light } from 'react-syntax-highlighter/dist/esm/styles/prism';\n\nimport { type ThemedClassName, useThemeContext } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nconst zeroWidthSpace = '\\u200b';\n\nexport type SyntaxHighlighterProps = ThemedClassName<\n NaturalSyntaxHighlighterProps & {\n fallback?: string;\n }\n>;\n\n/**\n * NOTE: Using `light-async` version directly from dist to avoid any chance of the heavy one being loaded.\n * The lightweight version will load specific language parsers asynchronously.\n *\n * https://github.com/react-syntax-highlighter/react-syntax-highlighter\n * https://react-syntax-highlighter.github.io/react-syntax-highlighter/demo/prism.html\n */\n// TODO(burdon): Replace with react-ui-editor (and reuse styles).\nexport const SyntaxHighlighter = ({\n classNames,\n children,\n language = 'text',\n fallback = zeroWidthSpace,\n ...props\n}: SyntaxHighlighterProps) => {\n const { themeMode } = useThemeContext();\n\n return (\n <div className={mx('flex is-full p-1 overflow-hidden', classNames)}>\n <NativeSyntaxHighlighter\n className='!m-0 is-full overflow-auto scrollbar-thin'\n language={languages[language as keyof typeof languages] || language}\n style={themeMode === 'dark' ? dark : light}\n customStyle={{\n background: 'unset',\n border: 'none',\n boxShadow: 'none',\n padding: 0,\n margin: 0,\n }}\n {...props}\n >\n {/* Non-empty fallback prevents collapse. */}\n {children || fallback}\n </NativeSyntaxHighlighter>\n </div>\n );\n};\n\nconst languages = {\n js: 'javascript',\n ts: 'typescript',\n};\n"],
|
|
5
|
+
"mappings": ";;;AAKA,OAAOA,QAAQ;AACf,OAAOC,UAASC,YAAYC,WAAWC,gBAAgB;AAEvD,SAASC,aAAmC;AAC5C,SAAmCC,gBAAgBC,qBAAqB;;;ACJxE,OAAOC,mBAAmB;;;ACD1B,OAAOC,WAAW;AAElB,OAAOC,6BAA6B;AACpC,SAASC,eAAeC,MAAMC,eAAeC,aAAa;AAE1D,SAA+BC,uBAAuB;AACtD,SAASC,UAAU;AAEnB,IAAMC,iBAAiB;AAgBhB,IAAMC,oBAAoB,CAAC,EAChCC,YACAC,UACAC,WAAW,QACXC,WAAWL,gBACX,GAAGM,MAAAA,MACoB;AACvB,QAAM,EAAEC,UAAS,IAAKC,gBAAAA;AAEtB,SACE,sBAAA,cAACC,OAAAA;IAAIC,WAAWC,GAAG,oCAAoCT,UAAAA;KACrD,sBAAA,cAACU,yBAAAA;IACCF,WAAU;IACVN,UAAUS,UAAUT,QAAAA,KAAuCA;IAC3DU,OAAOP,cAAc,SAASQ,OAAOC;IACrCC,aAAa;MACXC,YAAY;MACZC,QAAQ;MACRC,WAAW;MACXC,SAAS;MACTC,QAAQ;IACV;IACC,GAAGhB;KAGHH,YAAYE,QAAAA,CAAAA;AAIrB;AAEA,IAAMQ,YAAY;EAChBU,IAAI;EACJC,IAAI;AACN;;;AF1CO,IAAMC,OAAOC,2BAAsC,CAACC,OAAOC,iBAAAA;AAChE,MAAID,MAAME,QAAQ;AAChB,WAAO,gBAAAC,OAAA,cAACC,YAAeJ,KAAAA;EACzB;AAEA,QAAM,EAAEK,YAAYC,MAAMC,UAAUC,OAAM,IAAKR;AAC/C,SACE,gBAAAG,OAAA,cAACM,mBAAAA;IACCC,UAAS;IACTL,YAAY;MAAC;MAAmCA;;IAChDM,eAAaH;IACbI,KAAKX;KAEJY,cAAcP,MAAMC,YAAYO,eAAeP,QAAAA,GAAW,CAAA,CAAA;AAGjE,CAAA;AAEO,IAAMH,aAAaL,2BACxB,CAAC,EAAEM,YAAYC,MAAMS,aAAaR,UAAUC,OAAM,GAAIP,iBAAAA;AACpD,QAAM,CAACK,MAAMU,OAAAA,IAAWC,SAASF,WAAAA;AACjC,QAAM,CAACG,MAAMC,OAAAA,IAAWF,SAAS,EAAA;AACjC,QAAM,CAACG,OAAOC,QAAAA,IAAYJ,SAAuB,IAAA;AAEjDK,YAAU,MAAA;AACR,QAAI,CAACP,eAAe,CAACG,KAAKK,KAAI,EAAGC,QAAQ;AACvCR,cAAQD,WAAAA;IACV,OAAO;AACL,UAAI;AACFC,gBAAQS,GAAGC,MAAMX,aAAaG,IAAAA,CAAAA;AAC9BG,iBAAS,IAAA;MACX,SAASM,KAAK;AACZX,gBAAQD,WAAAA;AACRM,iBAASM,GAAAA;MACX;IACF;EACF,GAAG;IAACZ;IAAaG;GAAK;AAEtB,SACE,gBAAAf,OAAA,cAACyB,OAAAA;IAAIC,WAAU;IAAwCjB,KAAKX;KAC1D,gBAAAE,OAAA,cAAC2B,MAAMC,MAAI;IAACC,mBAAmBZ,QAAQ,UAAU;KAC/C,gBAAAjB,OAAA,cAAC2B,MAAMG,WAAS;IACd5B,YAAY;MAAC;MAAuBe,SAAS;;IAC7Cc,SAAQ;IACRC,OAAOjB;IACPkB,aAAY;IACZC,UAAU,CAACC,UAAUnB,QAAQmB,MAAMC,OAAOJ,KAAK;OAGnD,gBAAAhC,OAAA,cAACM,mBAAAA;IACCC,UAAS;IACTL,YAAY;MAAC;MAAmCA;;IAChDM,eAAaH;KAEZK,cAAcP,MAAMC,YAAYO,eAAeP,QAAAA,GAAW,CAAA,CAAA,CAAA;AAInE,CAAA;",
|
|
6
|
+
"names": ["jp", "React", "forwardRef", "useEffect", "useState", "Input", "createReplacer", "safeStringify", "createElement", "React", "NativeSyntaxHighlighter", "coldarkDark", "dark", "coldarkCold", "light", "useThemeContext", "mx", "zeroWidthSpace", "SyntaxHighlighter", "classNames", "children", "language", "fallback", "props", "themeMode", "useThemeContext", "div", "className", "mx", "NativeSyntaxHighlighter", "languages", "style", "dark", "light", "customStyle", "background", "border", "boxShadow", "padding", "margin", "js", "ts", "Json", "forwardRef", "props", "forwardedRef", "filter", "React", "JsonFilter", "classNames", "data", "replacer", "testId", "SyntaxHighlighter", "language", "data-testid", "ref", "safeStringify", "createReplacer", "initialData", "setData", "useState", "text", "setText", "error", "setError", "useEffect", "trim", "length", "jp", "query", "err", "div", "className", "Input", "Root", "validationValence", "TextInput", "variant", "value", "placeholder", "onChange", "event", "target"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/SyntaxHighlighter/SyntaxHighlighter.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"src/SyntaxHighlighter/SyntaxHighlighter.tsx":{"bytes":5909,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/prism-async-light","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/styles/prism","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"format":"esm"},"src/SyntaxHighlighter/index.ts":{"bytes":979,"imports":[{"path":"react-syntax-highlighter/dist/esm/create-element","kind":"import-statement","external":true},{"path":"src/SyntaxHighlighter/SyntaxHighlighter.tsx","kind":"import-statement","original":"./SyntaxHighlighter"}],"format":"esm"},"src/Json/Json.tsx":{"bytes":8440,"imports":[{"path":"jsonpath","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/SyntaxHighlighter/index.ts","kind":"import-statement","original":"../SyntaxHighlighter"}],"format":"esm"},"src/Json/index.ts":{"bytes":463,"imports":[{"path":"src/Json/Json.tsx","kind":"import-statement","original":"./Json"}],"format":"esm"},"src/index.ts":{"bytes":571,"imports":[{"path":"src/Json/index.ts","kind":"import-statement","original":"./Json"},{"path":"src/SyntaxHighlighter/index.ts","kind":"import-statement","original":"./SyntaxHighlighter"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7911},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"jsonpath","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/create-element","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/prism-async-light","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/styles/prism","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"exports":["Json","JsonFilter","SyntaxHighlighter","createElement"],"entryPoint":"src/index.ts","inputs":{"src/Json/Json.tsx":{"bytesInOutput":2070},"src/SyntaxHighlighter/index.ts":{"bytesInOutput":78},"src/SyntaxHighlighter/SyntaxHighlighter.tsx":{"bytesInOutput":1081},"src/index.ts":{"bytesInOutput":0}},"bytes":3554}}}
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
3
|
+
import { type CreateReplacerProps } from '@dxos/util';
|
|
3
4
|
export type JsonProps = ThemedClassName<{
|
|
4
5
|
data?: any;
|
|
6
|
+
filter?: boolean;
|
|
7
|
+
replacer?: CreateReplacerProps;
|
|
5
8
|
testId?: string;
|
|
6
9
|
}>;
|
|
7
|
-
export declare const Json:
|
|
8
|
-
|
|
10
|
+
export declare const Json: React.ForwardRefExoticComponent<Omit<{
|
|
11
|
+
data?: any;
|
|
12
|
+
filter?: boolean;
|
|
13
|
+
replacer?: CreateReplacerProps;
|
|
14
|
+
testId?: string;
|
|
15
|
+
}, "className"> & {
|
|
16
|
+
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
17
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
18
|
+
export declare const JsonFilter: React.ForwardRefExoticComponent<Omit<{
|
|
19
|
+
data?: any;
|
|
20
|
+
filter?: boolean;
|
|
21
|
+
replacer?: CreateReplacerProps;
|
|
22
|
+
testId?: string;
|
|
23
|
+
}, "className"> & {
|
|
24
|
+
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
25
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
9
26
|
//# sourceMappingURL=Json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Json.d.ts","sourceRoot":"","sources":["../../../../src/Json/Json.tsx"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"Json.d.ts","sourceRoot":"","sources":["../../../../src/Json/Json.tsx"],"names":[],"mappings":"AAMA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAS,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,KAAK,mBAAmB,EAAiC,MAAM,YAAY,CAAC;AAIrF,MAAM,MAAM,SAAS,GAAG,eAAe,CAAC;IACtC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAEH,eAAO,MAAM,IAAI;WANR,GAAG;aACD,OAAO;eACL,mBAAmB;aACrB,MAAM;;;wCAmBf,CAAC;AAEH,eAAO,MAAM,UAAU;WAxBd,GAAG;aACD,OAAO;eACL,mBAAmB;aACrB,MAAM;;;wCA8DhB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Json } from './Json';
|
|
4
|
+
declare const meta: {
|
|
5
|
+
title: string;
|
|
6
|
+
component: React.ForwardRefExoticComponent<Omit<{
|
|
7
|
+
data?: any;
|
|
8
|
+
filter?: boolean;
|
|
9
|
+
replacer?: import("@dxos/util").CreateReplacerProps;
|
|
10
|
+
testId?: string;
|
|
11
|
+
}, "className"> & {
|
|
12
|
+
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
13
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
decorators: import("@storybook/react").Decorator[];
|
|
15
|
+
};
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryObj<typeof Json>;
|
|
18
|
+
export declare const Default: Story;
|
|
19
|
+
export declare const Filter: Story;
|
|
20
|
+
export declare const Large: Story;
|
|
21
|
+
export declare const Cycle: Story;
|
|
22
|
+
//# sourceMappingURL=Json.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Json.stories.d.ts","sourceRoot":"","sources":["../../../../src/Json/Json.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AA6C9B,QAAA,MAAM,IAAI;;;;;;;;;;;CAImB,CAAC;AAE9B,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAInC,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAMpB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAWnB,CAAC;AAUF,eAAO,MAAM,KAAK,EAAE,KAEnB,CAAC"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type SyntaxHighlighterProps as
|
|
2
|
+
import { type SyntaxHighlighterProps as NaturalSyntaxHighlighterProps } from 'react-syntax-highlighter';
|
|
3
3
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
4
|
-
export type SyntaxHighlighterProps = ThemedClassName<
|
|
4
|
+
export type SyntaxHighlighterProps = ThemedClassName<NaturalSyntaxHighlighterProps & {
|
|
5
5
|
fallback?: string;
|
|
6
6
|
}>;
|
|
7
7
|
/**
|
|
8
|
+
* NOTE: Using `light-async` version directly from dist to avoid any chance of the heavy one being loaded.
|
|
9
|
+
* The lightweight version will load specific language parsers asynchronously.
|
|
10
|
+
*
|
|
8
11
|
* https://github.com/react-syntax-highlighter/react-syntax-highlighter
|
|
12
|
+
* https://react-syntax-highlighter.github.io/react-syntax-highlighter/demo/prism.html
|
|
9
13
|
*/
|
|
10
|
-
export declare const SyntaxHighlighter: ({ classNames, children, fallback, ...props }: SyntaxHighlighterProps) => React.JSX.Element;
|
|
14
|
+
export declare const SyntaxHighlighter: ({ classNames, children, language, fallback, ...props }: SyntaxHighlighterProps) => React.JSX.Element;
|
|
11
15
|
//# sourceMappingURL=SyntaxHighlighter.d.ts.map
|