@uiw/react-json-view 2.0.0-alpha.10 → 2.0.0-alpha.12
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/README.md +80 -14
- package/cjs/comps/KeyValues.js +6 -2
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +2 -0
- package/cjs/section/Row.d.ts +16 -0
- package/cjs/section/Row.js +50 -0
- package/cjs/store/Section.d.ts +2 -0
- package/cjs/store/Section.js +4 -0
- package/cjs/theme/basic.js +2 -0
- package/esm/comps/KeyValues.js +6 -2
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -0
- package/esm/section/Row.d.ts +16 -0
- package/esm/section/Row.js +45 -0
- package/esm/store/Section.d.ts +2 -0
- package/esm/store/Section.js +4 -0
- package/esm/theme/basic.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -147,6 +147,7 @@ const object = {
|
|
|
147
147
|
const customTheme = {
|
|
148
148
|
'--w-rjv-font-family': 'monospace',
|
|
149
149
|
'--w-rjv-color': '#9cdcfe',
|
|
150
|
+
'--w-rjv-key-number': '#268bd2',
|
|
150
151
|
'--w-rjv-key-string': '#9cdcfe',
|
|
151
152
|
'--w-rjv-background-color': '#1e1e1e',
|
|
152
153
|
'--w-rjv-line-color': '#36334280',
|
|
@@ -160,6 +161,7 @@ const customTheme = {
|
|
|
160
161
|
'--w-rjv-curlybraces-color': '#d4d4d4',
|
|
161
162
|
'--w-rjv-colon-color': '#d4d4d4',
|
|
162
163
|
'--w-rjv-brackets-color': '#d4d4d4',
|
|
164
|
+
'--w-rjv-ellipsis-color': '#cb4b16',
|
|
163
165
|
'--w-rjv-quotes-color': 'var(--w-rjv-key-string)',
|
|
164
166
|
'--w-rjv-quotes-string-color': 'var(--w-rjv-type-string-color)',
|
|
165
167
|
|
|
@@ -217,6 +219,7 @@ const object = {
|
|
|
217
219
|
}
|
|
218
220
|
const customTheme = {
|
|
219
221
|
'--w-rjv-color': '#9cdcfe',
|
|
222
|
+
'--w-rjv-key-number': '#268bd2',
|
|
220
223
|
'--w-rjv-key-string': '#9cdcfe',
|
|
221
224
|
'--w-rjv-background-color': '#1e1e1e',
|
|
222
225
|
'--w-rjv-line-color': '#36334280',
|
|
@@ -230,6 +233,7 @@ const customTheme = {
|
|
|
230
233
|
'--w-rjv-curlybraces-color': '#d4d4d4',
|
|
231
234
|
'--w-rjv-colon-color': '#d4d4d4',
|
|
232
235
|
'--w-rjv-brackets-color': '#d4d4d4',
|
|
236
|
+
'--w-rjv-ellipsis-color': '#cb4b16',
|
|
233
237
|
'--w-rjv-quotes-color': '#9cdcfe',
|
|
234
238
|
'--w-rjv-quotes-string-color': '#ce9178',
|
|
235
239
|
|
|
@@ -279,21 +283,31 @@ export default function Demo() {
|
|
|
279
283
|
/>
|
|
280
284
|
<div>
|
|
281
285
|
<Colorful color={hex} onChange={onChange} />
|
|
282
|
-
<div style={{ display: 'flex', gap: '0.4rem', flexDirection: 'column' }}>
|
|
286
|
+
<div style={{ display: 'flex', gap: '0.4rem', flexDirection: 'column', ...customTheme }}>
|
|
283
287
|
{Object.keys(customTheme).map((varname, idx) => {
|
|
284
288
|
const click = () => {
|
|
285
289
|
setCssvar(varname);
|
|
286
290
|
setHex(customTheme[varname]);
|
|
287
291
|
};
|
|
288
292
|
const active = cssvar === varname ? '#a8a8a8' : '';
|
|
289
|
-
return
|
|
293
|
+
return (
|
|
294
|
+
<button key={idx}
|
|
295
|
+
style={{ background: active, border: 0,boxShadow: 'inset 0px 0px 1px #000', display: 'flex', alignItems: 'center', gap: 5, padding: '1px 3px' }}
|
|
296
|
+
onClick={click}
|
|
297
|
+
>
|
|
298
|
+
<span style={{ display: 'inline-block', width: 12, height: 12, background: `var(${varname})` }}></span>
|
|
299
|
+
{varname}
|
|
300
|
+
</button>
|
|
301
|
+
)
|
|
290
302
|
})}
|
|
291
303
|
</div>
|
|
292
304
|
</div>
|
|
293
305
|
</div>
|
|
294
|
-
<
|
|
306
|
+
<div>
|
|
295
307
|
Copy the theme configuration below into your project.
|
|
296
|
-
|
|
308
|
+
</div>
|
|
309
|
+
<pre style={{ padding: 10 }}>
|
|
310
|
+
{JSON.stringify(theme, null, 2)}
|
|
297
311
|
</pre>
|
|
298
312
|
</React.Fragment>
|
|
299
313
|
);
|
|
@@ -363,7 +377,7 @@ export default function Demo() {
|
|
|
363
377
|
}
|
|
364
378
|
```
|
|
365
379
|
|
|
366
|
-
Supports certain partial customizations such as: `<Copied />`, `<CountInfo />`, `<CountInfoExtra />`, `<Ellipsis />`, `<KeyName />`
|
|
380
|
+
Supports certain partial customizations such as: `<Copied />`, `<CountInfo />`, `<CountInfoExtra />`, `<Ellipsis />`, `<KeyName />`, `<Row />`
|
|
367
381
|
|
|
368
382
|
```tsx mdx:preview
|
|
369
383
|
import React, { Fragment } from 'react';
|
|
@@ -580,6 +594,52 @@ Passing **as="tagName"** will automatically infer the type.
|
|
|
580
594
|
/>
|
|
581
595
|
```
|
|
582
596
|
|
|
597
|
+
Add a click event on the data row
|
|
598
|
+
|
|
599
|
+
```tsx mdx:preview
|
|
600
|
+
import React from 'react';
|
|
601
|
+
import JsonView from '@uiw/react-json-view';
|
|
602
|
+
|
|
603
|
+
export default function Demo() {
|
|
604
|
+
return (
|
|
605
|
+
<JsonView
|
|
606
|
+
style={{
|
|
607
|
+
'--w-rjv-background-color': '#ffffff',
|
|
608
|
+
}}
|
|
609
|
+
value={{
|
|
610
|
+
name: 'John',
|
|
611
|
+
age: 30,
|
|
612
|
+
hobbies: ['reading', 'coding', 'swimming'],
|
|
613
|
+
address: {
|
|
614
|
+
street: '123 Main St',
|
|
615
|
+
city: 'New York',
|
|
616
|
+
country: {
|
|
617
|
+
name: 'Main ',
|
|
618
|
+
codex: '123'
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}}
|
|
622
|
+
>
|
|
623
|
+
<JsonView.Row
|
|
624
|
+
as="div"
|
|
625
|
+
render={(props, { keyName, value, parentValue }) => {
|
|
626
|
+
return (
|
|
627
|
+
<div
|
|
628
|
+
{...props}
|
|
629
|
+
onClick={() => {
|
|
630
|
+
console.log("keyName", keyName)
|
|
631
|
+
console.log("value", value)
|
|
632
|
+
console.log("parentValue", parentValue)
|
|
633
|
+
}}
|
|
634
|
+
/>
|
|
635
|
+
)
|
|
636
|
+
}}
|
|
637
|
+
/>
|
|
638
|
+
</JsonView>
|
|
639
|
+
)
|
|
640
|
+
}
|
|
641
|
+
```
|
|
642
|
+
|
|
583
643
|
## Highlight Updates
|
|
584
644
|
|
|
585
645
|
```tsx mdx:preview
|
|
@@ -777,6 +837,7 @@ import { Arrow } from './symbol/Arrow';
|
|
|
777
837
|
import { Colon } from './symbol/Colon';
|
|
778
838
|
import { Quote } from './symbol/Quote';
|
|
779
839
|
import { ValueQuote } from './symbol/ValueQuote';
|
|
840
|
+
|
|
780
841
|
import { Bigint } from './types/Bigint';
|
|
781
842
|
import { Date } from './types/Date';
|
|
782
843
|
import { False } from './types/False';
|
|
@@ -790,13 +851,24 @@ import { StringText } from './types/String';
|
|
|
790
851
|
import { True } from './types/True';
|
|
791
852
|
import { Undefined } from './types/Undefined';
|
|
792
853
|
import { Url } from './types/Url';
|
|
854
|
+
|
|
793
855
|
import { Copied } from './section/Copied';
|
|
794
856
|
import { CountInfo } from './section/CountInfo';
|
|
795
857
|
import { CountInfoExtra } from './section/CountInfoExtra';
|
|
796
858
|
import { Ellipsis } from './section/Ellipsis';
|
|
797
859
|
import { KeyName } from './section/KeyName';
|
|
860
|
+
import { Row } from './section/Row';
|
|
798
861
|
|
|
799
862
|
type JsonViewComponent = React.FC<React.PropsWithRef<JsonViewProps<object>>> & {
|
|
863
|
+
BraceLeft: typeof BraceLeft;
|
|
864
|
+
BraceRight: typeof BraceRight;
|
|
865
|
+
BracketsLeft: typeof BracketsLeft;
|
|
866
|
+
BracketsRight: typeof BracketsRight;
|
|
867
|
+
Arrow: typeof Arrow;
|
|
868
|
+
Colon: typeof Colon;
|
|
869
|
+
Quote: typeof Quote;
|
|
870
|
+
ValueQuote: typeof ValueQuote;
|
|
871
|
+
|
|
800
872
|
Bigint: typeof Bigint;
|
|
801
873
|
Date: typeof Date;
|
|
802
874
|
False: typeof False;
|
|
@@ -810,19 +882,13 @@ type JsonViewComponent = React.FC<React.PropsWithRef<JsonViewProps<object>>> & {
|
|
|
810
882
|
True: typeof True;
|
|
811
883
|
Undefined: typeof Undefined;
|
|
812
884
|
Url: typeof Url;
|
|
813
|
-
|
|
814
|
-
BraceRight: typeof BraceRight;
|
|
815
|
-
BracketsLeft: typeof BracketsLeft;
|
|
816
|
-
BracketsRight: typeof BracketsRight;
|
|
817
|
-
Colon: typeof Colon;
|
|
818
|
-
Ellipsis: typeof Ellipsis;
|
|
819
|
-
Quote: typeof Quote;
|
|
820
|
-
ValueQuote: typeof ValueQuote;
|
|
821
|
-
Arrow: typeof Arrow;
|
|
885
|
+
|
|
822
886
|
Copied: typeof Copied;
|
|
823
887
|
CountInfo: typeof CountInfo;
|
|
824
888
|
CountInfoExtra: typeof CountInfoExtra;
|
|
889
|
+
Ellipsis: typeof Ellipsis;
|
|
825
890
|
KeyName: typeof KeyName;
|
|
891
|
+
Row: typeof Row;
|
|
826
892
|
};
|
|
827
893
|
declare const JsonView: JsonViewComponent;
|
|
828
894
|
export default JsonView;
|
package/cjs/comps/KeyValues.js
CHANGED
|
@@ -15,6 +15,7 @@ var _Expands = require("../store/Expands");
|
|
|
15
15
|
var _ShowTools = require("../store/ShowTools");
|
|
16
16
|
var _Value = require("./Value");
|
|
17
17
|
var _KeyName = require("../section/KeyName");
|
|
18
|
+
var _Row = require("../section/Row");
|
|
18
19
|
var _Container = require("../Container");
|
|
19
20
|
var _symbol = require("../symbol");
|
|
20
21
|
var _useHighlight = require("../utils/useHighlight");
|
|
@@ -143,8 +144,11 @@ var KeyValuesItem = exports.KeyValuesItem = function KeyValuesItem(props) {
|
|
|
143
144
|
return dispatch((0, _defineProperty2["default"])({}, subkeyid, false));
|
|
144
145
|
}
|
|
145
146
|
};
|
|
146
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
147
|
-
className: "w-rjv-line"
|
|
147
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Row.RowComp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
148
|
+
className: "w-rjv-line",
|
|
149
|
+
value: value,
|
|
150
|
+
keyName: keyName,
|
|
151
|
+
parentValue: parentValue
|
|
148
152
|
}, reset), {}, {
|
|
149
153
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(KayName, {
|
|
150
154
|
keyName: keyName,
|
package/cjs/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { CountInfo } from './section/CountInfo';
|
|
|
25
25
|
import { CountInfoExtra } from './section/CountInfoExtra';
|
|
26
26
|
import { Ellipsis } from './section/Ellipsis';
|
|
27
27
|
import { KeyName } from './section/KeyName';
|
|
28
|
+
import { Row } from './section/Row';
|
|
28
29
|
export * from './store';
|
|
29
30
|
export * from './store/Expands';
|
|
30
31
|
export * from './store/ShowTools';
|
|
@@ -89,6 +90,7 @@ type JsonViewComponent = React.FC<React.PropsWithRef<JsonViewProps<object>>> & {
|
|
|
89
90
|
CountInfo: typeof CountInfo;
|
|
90
91
|
CountInfoExtra: typeof CountInfoExtra;
|
|
91
92
|
KeyName: typeof KeyName;
|
|
93
|
+
Row: typeof Row;
|
|
92
94
|
};
|
|
93
95
|
declare const JsonView: JsonViewComponent;
|
|
94
96
|
export default JsonView;
|
package/cjs/index.js
CHANGED
|
@@ -48,6 +48,7 @@ var _CountInfo = require("./section/CountInfo");
|
|
|
48
48
|
var _CountInfoExtra = require("./section/CountInfoExtra");
|
|
49
49
|
var _Ellipsis = require("./section/Ellipsis");
|
|
50
50
|
var _KeyName = require("./section/KeyName");
|
|
51
|
+
var _Row = require("./section/Row");
|
|
51
52
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
52
53
|
var _Expands = require("./store/Expands");
|
|
53
54
|
Object.keys(_Expands).forEach(function (key) {
|
|
@@ -191,5 +192,6 @@ JsonView.Copied = _Copied.Copied;
|
|
|
191
192
|
JsonView.CountInfo = _CountInfo.CountInfo;
|
|
192
193
|
JsonView.CountInfoExtra = _CountInfoExtra.CountInfoExtra;
|
|
193
194
|
JsonView.KeyName = _KeyName.KeyName;
|
|
195
|
+
JsonView.Row = _Row.Row;
|
|
194
196
|
JsonView.displayName = 'JVR.JsonView';
|
|
195
197
|
var _default = exports["default"] = JsonView;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type TagType } from '../store/Types';
|
|
3
|
+
import { type SectionElement } from '../store/Section';
|
|
4
|
+
export declare const Row: {
|
|
5
|
+
<K extends TagType>(props: SectionElement<K>): null;
|
|
6
|
+
displayName: string;
|
|
7
|
+
};
|
|
8
|
+
export interface RowCompProps<T extends object> extends React.HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
value?: T;
|
|
10
|
+
keyName?: string | number;
|
|
11
|
+
parentValue?: unknown;
|
|
12
|
+
}
|
|
13
|
+
export declare const RowComp: {
|
|
14
|
+
<T extends object>({ children, value, keyName, parentValue, ...other }: import("react").PropsWithChildren<RowCompProps<T>>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
displayName: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.RowComp = exports.Row = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
+
var _Section = require("../store/Section");
|
|
11
|
+
var _useRender = require("../utils/useRender");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
var _excluded = ["children", "value", "keyName", "parentValue"],
|
|
14
|
+
_excluded2 = ["as", "render", "children"];
|
|
15
|
+
var Row = exports.Row = function Row(props) {
|
|
16
|
+
var _useSectionStore = (0, _Section.useSectionStore)(),
|
|
17
|
+
_useSectionStore$Row = _useSectionStore.Row,
|
|
18
|
+
Comp = _useSectionStore$Row === void 0 ? {} : _useSectionStore$Row;
|
|
19
|
+
(0, _useRender.useSectionRender)(Comp, props, 'Row');
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
22
|
+
Row.displayName = 'JVR.Row';
|
|
23
|
+
var RowComp = exports.RowComp = function RowComp(_ref) {
|
|
24
|
+
var children = _ref.children,
|
|
25
|
+
value = _ref.value,
|
|
26
|
+
_ref$keyName = _ref.keyName,
|
|
27
|
+
keyName = _ref$keyName === void 0 ? '' : _ref$keyName,
|
|
28
|
+
parentValue = _ref.parentValue,
|
|
29
|
+
other = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
30
|
+
var _useSectionStore2 = (0, _Section.useSectionStore)(),
|
|
31
|
+
_useSectionStore2$Row = _useSectionStore2.Row,
|
|
32
|
+
Comp = _useSectionStore2$Row === void 0 ? {} : _useSectionStore2$Row;
|
|
33
|
+
var as = Comp.as,
|
|
34
|
+
render = Comp.render,
|
|
35
|
+
_ = Comp.children,
|
|
36
|
+
reset = (0, _objectWithoutProperties2["default"])(Comp, _excluded2);
|
|
37
|
+
var Elm = as || 'div';
|
|
38
|
+
var child = render && typeof render === 'function' && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, other), reset), {}, {
|
|
39
|
+
children: children
|
|
40
|
+
}), {
|
|
41
|
+
value: value,
|
|
42
|
+
keyName: keyName,
|
|
43
|
+
parentValue: parentValue
|
|
44
|
+
});
|
|
45
|
+
if (child) return child;
|
|
46
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Elm, (0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, other), reset), {}, {
|
|
47
|
+
children: children
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
50
|
+
RowComp.displayName = 'JVR.RowComp';
|
package/cjs/store/Section.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ type InitialState<T extends TagType> = {
|
|
|
14
14
|
CountInfo?: SectionElement<T>;
|
|
15
15
|
CountInfoExtra?: SectionElement<T>;
|
|
16
16
|
Ellipsis?: SectionElement<T>;
|
|
17
|
+
Row?: SectionElement<T>;
|
|
17
18
|
KeyName?: SectionElement<T>;
|
|
18
19
|
};
|
|
19
20
|
type Dispatch = React.Dispatch<InitialState<TagType>>;
|
|
@@ -23,6 +24,7 @@ export declare function useSection(): [{
|
|
|
23
24
|
CountInfo?: SectionElement<TagType> | undefined;
|
|
24
25
|
CountInfoExtra?: SectionElement<TagType> | undefined;
|
|
25
26
|
Ellipsis?: SectionElement<TagType> | undefined;
|
|
27
|
+
Row?: SectionElement<TagType> | undefined;
|
|
26
28
|
KeyName?: SectionElement<TagType> | undefined;
|
|
27
29
|
}, React.Dispatch<InitialState<TagType>>];
|
|
28
30
|
export declare function useSectionDispatch(): Dispatch;
|
package/cjs/store/Section.js
CHANGED
package/cjs/theme/basic.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.basicTheme = void 0;
|
|
|
7
7
|
var basicTheme = exports.basicTheme = {
|
|
8
8
|
'--w-rjv-font-family': 'monospace',
|
|
9
9
|
'--w-rjv-color': '#b5bd68',
|
|
10
|
+
'--w-rjv-key-number': '#002b36',
|
|
10
11
|
'--w-rjv-key-string': '#b5bd68',
|
|
11
12
|
'--w-rjv-background-color': '#2E3235',
|
|
12
13
|
'--w-rjv-line-color': '#292d30',
|
|
@@ -19,6 +20,7 @@ var basicTheme = exports.basicTheme = {
|
|
|
19
20
|
'--w-rjv-curlybraces-color': '#cc99cc',
|
|
20
21
|
'--w-rjv-colon-color': '#bababa',
|
|
21
22
|
'--w-rjv-brackets-color': '#808080',
|
|
23
|
+
'--w-rjv-ellipsis-color': '#cb4b16',
|
|
22
24
|
'--w-rjv-quotes-color': 'var(--w-rjv-key-string)',
|
|
23
25
|
'--w-rjv-quotes-string-color': 'var(--w-rjv-type-string-color)',
|
|
24
26
|
'--w-rjv-type-string-color': '#b5bd68',
|
package/esm/comps/KeyValues.js
CHANGED
|
@@ -5,6 +5,7 @@ import { useExpandsStore } from '../store/Expands';
|
|
|
5
5
|
import { useShowToolsDispatch } from '../store/ShowTools';
|
|
6
6
|
import { Value } from './Value';
|
|
7
7
|
import { KeyNameComp } from '../section/KeyName';
|
|
8
|
+
import { RowComp } from '../section/Row';
|
|
8
9
|
import { Container } from '../Container';
|
|
9
10
|
import { Quote, Colon } from '../symbol';
|
|
10
11
|
import { useHighlight } from '../utils/useHighlight';
|
|
@@ -130,8 +131,11 @@ export var KeyValuesItem = props => {
|
|
|
130
131
|
[subkeyid]: false
|
|
131
132
|
})
|
|
132
133
|
};
|
|
133
|
-
return /*#__PURE__*/_jsxs(
|
|
134
|
-
className: "w-rjv-line"
|
|
134
|
+
return /*#__PURE__*/_jsxs(RowComp, _extends({
|
|
135
|
+
className: "w-rjv-line",
|
|
136
|
+
value: value,
|
|
137
|
+
keyName: keyName,
|
|
138
|
+
parentValue: parentValue
|
|
135
139
|
}, reset, {
|
|
136
140
|
children: [/*#__PURE__*/_jsx(KayName, {
|
|
137
141
|
keyName: keyName,
|
package/esm/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { CountInfo } from './section/CountInfo';
|
|
|
25
25
|
import { CountInfoExtra } from './section/CountInfoExtra';
|
|
26
26
|
import { Ellipsis } from './section/Ellipsis';
|
|
27
27
|
import { KeyName } from './section/KeyName';
|
|
28
|
+
import { Row } from './section/Row';
|
|
28
29
|
export * from './store';
|
|
29
30
|
export * from './store/Expands';
|
|
30
31
|
export * from './store/ShowTools';
|
|
@@ -89,6 +90,7 @@ type JsonViewComponent = React.FC<React.PropsWithRef<JsonViewProps<object>>> & {
|
|
|
89
90
|
CountInfo: typeof CountInfo;
|
|
90
91
|
CountInfoExtra: typeof CountInfoExtra;
|
|
91
92
|
KeyName: typeof KeyName;
|
|
93
|
+
Row: typeof Row;
|
|
92
94
|
};
|
|
93
95
|
declare const JsonView: JsonViewComponent;
|
|
94
96
|
export default JsonView;
|
package/esm/index.js
CHANGED
|
@@ -30,6 +30,7 @@ import { CountInfo } from './section/CountInfo';
|
|
|
30
30
|
import { CountInfoExtra } from './section/CountInfoExtra';
|
|
31
31
|
import { Ellipsis } from './section/Ellipsis';
|
|
32
32
|
import { KeyName } from './section/KeyName';
|
|
33
|
+
import { Row } from './section/Row';
|
|
33
34
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
35
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
36
|
export * from './store';
|
|
@@ -113,5 +114,6 @@ JsonView.Copied = Copied;
|
|
|
113
114
|
JsonView.CountInfo = CountInfo;
|
|
114
115
|
JsonView.CountInfoExtra = CountInfoExtra;
|
|
115
116
|
JsonView.KeyName = KeyName;
|
|
117
|
+
JsonView.Row = Row;
|
|
116
118
|
JsonView.displayName = 'JVR.JsonView';
|
|
117
119
|
export default JsonView;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type TagType } from '../store/Types';
|
|
3
|
+
import { type SectionElement } from '../store/Section';
|
|
4
|
+
export declare const Row: {
|
|
5
|
+
<K extends TagType>(props: SectionElement<K>): null;
|
|
6
|
+
displayName: string;
|
|
7
|
+
};
|
|
8
|
+
export interface RowCompProps<T extends object> extends React.HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
value?: T;
|
|
10
|
+
keyName?: string | number;
|
|
11
|
+
parentValue?: unknown;
|
|
12
|
+
}
|
|
13
|
+
export declare const RowComp: {
|
|
14
|
+
<T extends object>({ children, value, keyName, parentValue, ...other }: import("react").PropsWithChildren<RowCompProps<T>>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
displayName: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["children", "value", "keyName", "parentValue"],
|
|
4
|
+
_excluded2 = ["as", "render", "children"];
|
|
5
|
+
import { useSectionStore } from '../store/Section';
|
|
6
|
+
import { useSectionRender } from '../utils/useRender';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export var Row = props => {
|
|
9
|
+
var {
|
|
10
|
+
Row: Comp = {}
|
|
11
|
+
} = useSectionStore();
|
|
12
|
+
useSectionRender(Comp, props, 'Row');
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
Row.displayName = 'JVR.Row';
|
|
16
|
+
export var RowComp = _ref => {
|
|
17
|
+
var {
|
|
18
|
+
children,
|
|
19
|
+
value,
|
|
20
|
+
keyName = '',
|
|
21
|
+
parentValue
|
|
22
|
+
} = _ref,
|
|
23
|
+
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
24
|
+
var {
|
|
25
|
+
Row: Comp = {}
|
|
26
|
+
} = useSectionStore();
|
|
27
|
+
var {
|
|
28
|
+
as,
|
|
29
|
+
render
|
|
30
|
+
} = Comp,
|
|
31
|
+
reset = _objectWithoutPropertiesLoose(Comp, _excluded2);
|
|
32
|
+
var Elm = as || 'div';
|
|
33
|
+
var child = render && typeof render === 'function' && render(_extends({}, other, reset, {
|
|
34
|
+
children
|
|
35
|
+
}), {
|
|
36
|
+
value,
|
|
37
|
+
keyName,
|
|
38
|
+
parentValue
|
|
39
|
+
});
|
|
40
|
+
if (child) return child;
|
|
41
|
+
return /*#__PURE__*/_jsx(Elm, _extends({}, other, reset, {
|
|
42
|
+
children: children
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
45
|
+
RowComp.displayName = 'JVR.RowComp';
|
package/esm/store/Section.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ type InitialState<T extends TagType> = {
|
|
|
14
14
|
CountInfo?: SectionElement<T>;
|
|
15
15
|
CountInfoExtra?: SectionElement<T>;
|
|
16
16
|
Ellipsis?: SectionElement<T>;
|
|
17
|
+
Row?: SectionElement<T>;
|
|
17
18
|
KeyName?: SectionElement<T>;
|
|
18
19
|
};
|
|
19
20
|
type Dispatch = React.Dispatch<InitialState<TagType>>;
|
|
@@ -23,6 +24,7 @@ export declare function useSection(): [{
|
|
|
23
24
|
CountInfo?: SectionElement<TagType> | undefined;
|
|
24
25
|
CountInfoExtra?: SectionElement<TagType> | undefined;
|
|
25
26
|
Ellipsis?: SectionElement<TagType> | undefined;
|
|
27
|
+
Row?: SectionElement<TagType> | undefined;
|
|
26
28
|
KeyName?: SectionElement<TagType> | undefined;
|
|
27
29
|
}, React.Dispatch<InitialState<TagType>>];
|
|
28
30
|
export declare function useSectionDispatch(): Dispatch;
|
package/esm/store/Section.js
CHANGED
package/esm/theme/basic.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export var basicTheme = {
|
|
2
2
|
'--w-rjv-font-family': 'monospace',
|
|
3
3
|
'--w-rjv-color': '#b5bd68',
|
|
4
|
+
'--w-rjv-key-number': '#002b36',
|
|
4
5
|
'--w-rjv-key-string': '#b5bd68',
|
|
5
6
|
'--w-rjv-background-color': '#2E3235',
|
|
6
7
|
'--w-rjv-line-color': '#292d30',
|
|
@@ -13,6 +14,7 @@ export var basicTheme = {
|
|
|
13
14
|
'--w-rjv-curlybraces-color': '#cc99cc',
|
|
14
15
|
'--w-rjv-colon-color': '#bababa',
|
|
15
16
|
'--w-rjv-brackets-color': '#808080',
|
|
17
|
+
'--w-rjv-ellipsis-color': '#cb4b16',
|
|
16
18
|
'--w-rjv-quotes-color': 'var(--w-rjv-key-string)',
|
|
17
19
|
'--w-rjv-quotes-string-color': 'var(--w-rjv-type-string-color)',
|
|
18
20
|
'--w-rjv-type-string-color': '#b5bd68',
|