@availity/mui-tree 1.0.1 → 1.0.3
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/CHANGELOG.md +14 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -5
- package/dist/index.mjs +6 -5
- package/package.json +6 -6
- package/src/lib/JsonViewer.tsx +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.0.3](https://github.com/Availity/element/compare/@availity/mui-tree@1.0.2...@availity/mui-tree@1.0.3) (2025-04-11)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `mui-icon` updated to version `1.0.2`
|
|
10
|
+
* `mui-layout` updated to version `1.0.2`
|
|
11
|
+
* `mui-typography` updated to version `1.0.2`
|
|
12
|
+
## [1.0.2](https://github.com/Availity/element/compare/@availity/mui-tree@1.0.1...@availity/mui-tree@1.0.2) (2025-04-04)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **mui-tree:** account for duplicative ids and keys ([dad00ae](https://github.com/Availity/element/commit/dad00ae252ae316dd7ed128f19031e299132d3a1))
|
|
18
|
+
|
|
5
19
|
## [1.0.1](https://github.com/Availity/element/compare/@availity/mui-tree@1.0.0...@availity/mui-tree@1.0.1) (2025-03-07)
|
|
6
20
|
|
|
7
21
|
### Dependency Updates
|
package/dist/index.d.mts
CHANGED
|
@@ -16,7 +16,7 @@ declare const TreeItem: ({ children, label, slots, slotProps, truncate, ...rest
|
|
|
16
16
|
|
|
17
17
|
interface JsonViewerProps extends Omit<TreeViewProps, 'children'> {
|
|
18
18
|
/** Data to be rendered, can be most valid javascript objects, some uncommon types may not by fully supported - like cyclical objects, proxies, symbols as keys. */
|
|
19
|
-
data: Record<string, unknown
|
|
19
|
+
data: Record<string, unknown> | Record<string, unknown>[];
|
|
20
20
|
}
|
|
21
21
|
declare const JsonViewer: ({ data, ...rest }: JsonViewerProps) => JSX.Element;
|
|
22
22
|
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ declare const TreeItem: ({ children, label, slots, slotProps, truncate, ...rest
|
|
|
16
16
|
|
|
17
17
|
interface JsonViewerProps extends Omit<TreeViewProps, 'children'> {
|
|
18
18
|
/** Data to be rendered, can be most valid javascript objects, some uncommon types may not by fully supported - like cyclical objects, proxies, symbols as keys. */
|
|
19
|
-
data: Record<string, unknown
|
|
19
|
+
data: Record<string, unknown> | Record<string, unknown>[];
|
|
20
20
|
}
|
|
21
21
|
declare const JsonViewer: ({ data, ...rest }: JsonViewerProps) => JSX.Element;
|
|
22
22
|
|
package/dist/index.js
CHANGED
|
@@ -114,16 +114,17 @@ var isPrimitive = (value) => {
|
|
|
114
114
|
var isObject = (value) => {
|
|
115
115
|
return !!value && typeof value === "object";
|
|
116
116
|
};
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
var validateId = (id) => id.replace(/[^.\w:-]+/gi, "");
|
|
118
|
+
var getDetails = ({ data }, parentKey) => {
|
|
119
|
+
return Object.entries(data).map(([key, value], index) => {
|
|
120
|
+
const id = validateId(parentKey ? `${parentKey}.${index}.${key}` : `${index}.${key}`);
|
|
120
121
|
if (isPrimitive(value)) {
|
|
121
122
|
const label = `${key}: ${value.toString()}`;
|
|
122
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TreeItem, { label, itemId:
|
|
123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TreeItem, { label, itemId: id }, id);
|
|
123
124
|
}
|
|
124
125
|
if (isObject(value)) {
|
|
125
126
|
const label = `${key}: ${Array.isArray(value) ? `[ ] ${value.length} items` : `{ } ${Object.keys(value).length} keys`}`;
|
|
126
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TreeItem, { label, itemId:
|
|
127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TreeItem, { label, itemId: id, children: getDetails({ data: value }, id) }, id);
|
|
127
128
|
}
|
|
128
129
|
return null;
|
|
129
130
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -88,16 +88,17 @@ var isPrimitive = (value) => {
|
|
|
88
88
|
var isObject = (value) => {
|
|
89
89
|
return !!value && typeof value === "object";
|
|
90
90
|
};
|
|
91
|
-
var
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
var validateId = (id) => id.replace(/[^.\w:-]+/gi, "");
|
|
92
|
+
var getDetails = ({ data }, parentKey) => {
|
|
93
|
+
return Object.entries(data).map(([key, value], index) => {
|
|
94
|
+
const id = validateId(parentKey ? `${parentKey}.${index}.${key}` : `${index}.${key}`);
|
|
94
95
|
if (isPrimitive(value)) {
|
|
95
96
|
const label = `${key}: ${value.toString()}`;
|
|
96
|
-
return /* @__PURE__ */ jsx4(TreeItem, { label, itemId:
|
|
97
|
+
return /* @__PURE__ */ jsx4(TreeItem, { label, itemId: id }, id);
|
|
97
98
|
}
|
|
98
99
|
if (isObject(value)) {
|
|
99
100
|
const label = `${key}: ${Array.isArray(value) ? `[ ] ${value.length} items` : `{ } ${Object.keys(value).length} keys`}`;
|
|
100
|
-
return /* @__PURE__ */ jsx4(TreeItem, { label, itemId:
|
|
101
|
+
return /* @__PURE__ */ jsx4(TreeItem, { label, itemId: id, children: getDetails({ data: value }, id) }, id);
|
|
101
102
|
}
|
|
102
103
|
return null;
|
|
103
104
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-tree",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Availity MUI Tree Component - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@availity/mui-icon": "^1.0.
|
|
44
|
-
"@availity/mui-layout": "^1.0.
|
|
45
|
-
"@availity/mui-typography": "^1.0.
|
|
43
|
+
"@availity/mui-icon": "^1.0.2",
|
|
44
|
+
"@availity/mui-layout": "^1.0.2",
|
|
45
|
+
"@availity/mui-typography": "^1.0.2",
|
|
46
46
|
"@mui/material": "^6.4.5",
|
|
47
47
|
"react": "18.2.0",
|
|
48
48
|
"react-dom": "18.2.0",
|
|
49
|
-
"tsup": "^8.
|
|
49
|
+
"tsup": "^8.4.0",
|
|
50
50
|
"typescript": "^5.4.5"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@availity/mui-icon": "^1.0.
|
|
53
|
+
"@availity/mui-icon": "^1.0.2",
|
|
54
54
|
"@mui/material": "^6.4.5",
|
|
55
55
|
"react": ">=16.3.0"
|
|
56
56
|
},
|
package/src/lib/JsonViewer.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { TreeView, TreeViewProps } from './TreeView';
|
|
|
3
3
|
|
|
4
4
|
export interface JsonViewerProps extends Omit<TreeViewProps, 'children'> {
|
|
5
5
|
/** Data to be rendered, can be most valid javascript objects, some uncommon types may not by fully supported - like cyclical objects, proxies, symbols as keys. */
|
|
6
|
-
data: Record<string, unknown
|
|
6
|
+
data: Record<string, unknown> | Record<string, unknown>[];
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const isPrimitive = (value: unknown): value is string | number | boolean => {
|
|
@@ -14,19 +14,22 @@ const isObject = (value: unknown): value is Record<string, unknown> => {
|
|
|
14
14
|
return !!value && typeof value === 'object';
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const validateId = (id: string) => id.replace(/[^.\w:-]+/gi, '');
|
|
18
|
+
|
|
19
|
+
const getDetails = ({ data }: JsonViewerProps, parentKey?: string): (JSX.Element | null)[] => {
|
|
20
|
+
return Object.entries(data).map(([key, value], index) => {
|
|
21
|
+
const id = validateId(parentKey ? `${parentKey}.${index}.${key}` : `${index}.${key}`);
|
|
20
22
|
|
|
21
23
|
if (isPrimitive(value)) {
|
|
22
24
|
const label = `${key}: ${value.toString()}`;
|
|
23
|
-
|
|
25
|
+
|
|
26
|
+
return <TreeItem label={label} itemId={id} key={id} />;
|
|
24
27
|
}
|
|
25
28
|
if (isObject(value)) {
|
|
26
29
|
const label = `${key}: ${Array.isArray(value) ? `[ ] ${value.length} items` : `{ } ${Object.keys(value).length} keys`}`;
|
|
27
30
|
return (
|
|
28
|
-
<TreeItem label={label} itemId={
|
|
29
|
-
{getDetails({ data: value })}
|
|
31
|
+
<TreeItem label={label} itemId={id} key={id}>
|
|
32
|
+
{getDetails({ data: value }, id)}
|
|
30
33
|
</TreeItem>
|
|
31
34
|
);
|
|
32
35
|
}
|