schyma 1.0.0
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/LICENSE +201 -0
- package/README.md +80 -0
- package/dist/cjs/components/App.d.ts +9 -0
- package/dist/cjs/components/App.js +37 -0
- package/dist/cjs/components/App.js.map +1 -0
- package/dist/cjs/components/Code.d.ts +3 -0
- package/dist/cjs/components/Code.js +15 -0
- package/dist/cjs/components/Code.js.map +1 -0
- package/dist/cjs/components/Nodes.d.ts +14 -0
- package/dist/cjs/components/Nodes.js +178 -0
- package/dist/cjs/components/Nodes.js.map +1 -0
- package/dist/cjs/components/Panel.d.ts +12 -0
- package/dist/cjs/components/Panel.js +40 -0
- package/dist/cjs/components/Panel.js.map +1 -0
- package/dist/cjs/components/Tables.d.ts +8 -0
- package/dist/cjs/components/Tables.js +19 -0
- package/dist/cjs/components/Tables.js.map +1 -0
- package/dist/cjs/config.d.ts +0 -0
- package/dist/cjs/config.js +99 -0
- package/dist/cjs/config.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/scripts/buildtree.d.ts +34 -0
- package/dist/cjs/scripts/buildtree.js +181 -0
- package/dist/cjs/scripts/buildtree.js.map +1 -0
- package/dist/cjs/scripts/index.d.ts +1 -0
- package/dist/cjs/scripts/index.js +23 -0
- package/dist/cjs/scripts/index.js.map +1 -0
- package/dist/cjs/types/nodes.d.ts +24 -0
- package/dist/cjs/types/nodes.js +3 -0
- package/dist/cjs/types/nodes.js.map +1 -0
- package/dist/cjs/types.d.ts +24 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/reusables.d.ts +6 -0
- package/dist/cjs/utils/reusables.js +111 -0
- package/dist/cjs/utils/reusables.js.map +1 -0
- package/dist/cjs/utils/types.d.ts +34 -0
- package/dist/cjs/utils/types.js +4 -0
- package/dist/cjs/utils/types.js.map +1 -0
- package/dist/esm/components/App.d.ts +9 -0
- package/dist/esm/components/App.js +34 -0
- package/dist/esm/components/App.js.map +1 -0
- package/dist/esm/components/Code.d.ts +3 -0
- package/dist/esm/components/Code.js +12 -0
- package/dist/esm/components/Code.js.map +1 -0
- package/dist/esm/components/Nodes.d.ts +14 -0
- package/dist/esm/components/Nodes.js +176 -0
- package/dist/esm/components/Nodes.js.map +1 -0
- package/dist/esm/components/Panel.d.ts +12 -0
- package/dist/esm/components/Panel.js +37 -0
- package/dist/esm/components/Panel.js.map +1 -0
- package/dist/esm/components/Tables.d.ts +8 -0
- package/dist/esm/components/Tables.js +16 -0
- package/dist/esm/components/Tables.js.map +1 -0
- package/dist/esm/components/worker.d.ts +1 -0
- package/dist/esm/components/worker.js +12 -0
- package/dist/esm/components/worker.js.map +1 -0
- package/dist/esm/config.d.ts +0 -0
- package/dist/esm/config.js +99 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/scripts/buildtree.d.ts +34 -0
- package/dist/esm/scripts/buildtree.js +178 -0
- package/dist/esm/scripts/buildtree.js.map +1 -0
- package/dist/esm/scripts/index.d.ts +1 -0
- package/dist/esm/scripts/index.js +19 -0
- package/dist/esm/scripts/index.js.map +1 -0
- package/dist/esm/types/nodes.d.ts +24 -0
- package/dist/esm/types/nodes.js +2 -0
- package/dist/esm/types/nodes.js.map +1 -0
- package/dist/esm/types.d.ts +24 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/reusables.d.ts +6 -0
- package/dist/esm/utils/reusables.js +102 -0
- package/dist/esm/utils/reusables.js.map +1 -0
- package/dist/esm/utils/types.d.ts +34 -0
- package/dist/esm/utils/types.js +4 -0
- package/dist/esm/utils/types.js.map +1 -0
- package/dist/esm/worker.d.ts +1 -0
- package/dist/esm/worker.js +12 -0
- package/dist/esm/worker.js.map +1 -0
- package/package.json +78 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# JSON Schema Visualizer(Schyma)
|
|
2
|
+
|
|
3
|
+
Schyma is a tool designed to simplify the visualization of JSON Schemas, making it less tedious to learn how different parts of api specs are connected(especially when you’re just starting). The visualizer takes JSON Schema files as input and generates a user-friendly graphical representation of the specification.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Import JSON Schemas: The visualizer supports various JSON Schemas, such as AsyncAPI, Postman Collection Format, OpenAPI (formerly Swagger), Github Action Spec and so much more. You can easily import your JSON Schema files into the tool.
|
|
8
|
+
|
|
9
|
+
- Interactive Visualization: The visualizer provides an interactive and intuitive graphical representation of the JSON Schema. Names, Descriptions, Examples, and other essential details are visually presented for better understanding.
|
|
10
|
+
|
|
11
|
+
## Upcoming Features
|
|
12
|
+
|
|
13
|
+
- Search and Filtering: Quickly search for specific part of the spec or filter. This feature enhances the user experience when dealing with large JSON Schemas.
|
|
14
|
+
|
|
15
|
+
- Ability to support very large JSON Schemas
|
|
16
|
+
|
|
17
|
+
- Additional Panel to render selected Node Schema
|
|
18
|
+
|
|
19
|
+
- Generating dummy APIs fronm the given specification
|
|
20
|
+
|
|
21
|
+
## Supported JSON Schema Formats
|
|
22
|
+
|
|
23
|
+
The JSON Schema Visualizer currently supports the following JSON Schema formats:
|
|
24
|
+
`.json`
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Installation & Usage
|
|
28
|
+
|
|
29
|
+
The easiest way to use schyma is to install it from npm and build it into your app with Webpack.
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
npm install schyma
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Then use it in your app:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import React from 'react';
|
|
39
|
+
import Schyma from 'schyma';
|
|
40
|
+
import 'schyma/src/style.css'
|
|
41
|
+
import schema from '../config/2.6.0.json';
|
|
42
|
+
|
|
43
|
+
export default function App() {
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div className="App">
|
|
47
|
+
<Schyma title="Name of Specification" description="Specification Description" schema={schema} />
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Props
|
|
54
|
+
|
|
55
|
+
Common props you may want to specify include:
|
|
56
|
+
|
|
57
|
+
- `title`: The title of the JSON Schema, which will also be displayed on the initial node.
|
|
58
|
+
|
|
59
|
+
- `description`: The description of the JSON Schema being parsed
|
|
60
|
+
|
|
61
|
+
- `schema`: The JSON Schema schema which will be rendered on the visualizer.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## Contributing
|
|
65
|
+
We welcome contributions from the community! If you find a bug, have a feature request, or want to contribute in any way.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# Thanks
|
|
69
|
+
|
|
70
|
+
We would like to thank the contributors and supporters of the JSON Schema Visualizer project for their valuable contributions and feedback.
|
|
71
|
+
|
|
72
|
+
If you like Schyma, you should [follow me on Twitter](https://twitter.com/_acebuild)!
|
|
73
|
+
|
|
74
|
+
Shout out to the [AsyncAPI Community](https://github.com/asyncapi), [Lukasz Gornicki](https://github.com/derberg) who along with many other contributors have made this possible ❤️
|
|
75
|
+
|
|
76
|
+
Thank you for your interest in our JSON Schema Visualizer project! For more information or to report issues, please visit the [project repository](). Happy visualizing! 🚀
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
Apache Liscence 2.0. Copyright (c) Azeez Elegbede 2024.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { JSONSchema7Object } from "json-schema";
|
|
3
|
+
interface Default {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
schema: JSONSchema7Object;
|
|
7
|
+
}
|
|
8
|
+
declare function Schyma({ title, description, schema }: Default): React.JSX.Element;
|
|
9
|
+
export default Schyma;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const Panel_1 = tslib_1.__importDefault(require("./Panel"));
|
|
6
|
+
const react_2 = require("react");
|
|
7
|
+
const Nodes_1 = tslib_1.__importDefault(require("./Nodes"));
|
|
8
|
+
const ajv_1 = tslib_1.__importDefault(require("ajv"));
|
|
9
|
+
function Schyma({ title, description, schema }) {
|
|
10
|
+
const ajv = new ajv_1.default();
|
|
11
|
+
const [currentNode, setCurrentNode] = (0, react_2.useState)();
|
|
12
|
+
const [nNodes, setnNodes] = (0, react_2.useState)({});
|
|
13
|
+
const [render, setRender] = (0, react_2.useState)(false);
|
|
14
|
+
const position = { x: 0, y: 0 };
|
|
15
|
+
const initialNode = {
|
|
16
|
+
id: '1',
|
|
17
|
+
data: {
|
|
18
|
+
label: title,
|
|
19
|
+
description,
|
|
20
|
+
properties: schema.properties,
|
|
21
|
+
relations: {},
|
|
22
|
+
},
|
|
23
|
+
position,
|
|
24
|
+
};
|
|
25
|
+
const validate = ajv.validateSchema(schema);
|
|
26
|
+
(0, react_1.useEffect)(() => {
|
|
27
|
+
if (validate) {
|
|
28
|
+
setRender(true);
|
|
29
|
+
}
|
|
30
|
+
}, [validate]);
|
|
31
|
+
return (react_1.default.createElement("div", null, render ? react_1.default.createElement("div", { className: "body-wrapper" },
|
|
32
|
+
react_1.default.createElement("div", { className: "node-container" },
|
|
33
|
+
react_1.default.createElement(Nodes_1.default, { setnNodes: setnNodes, nNodes: nNodes, setCurrentNode: setCurrentNode, initialNode: initialNode, schema: schema })),
|
|
34
|
+
react_1.default.createElement(Panel_1.default, { title: title, description: description, node: currentNode, nodes: nNodes })) : react_1.default.createElement("div", null, "loading")));
|
|
35
|
+
}
|
|
36
|
+
exports.default = Schyma;
|
|
37
|
+
//# sourceMappingURL=App.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.js","sourceRoot":"","sources":["../../../src/components/App.tsx"],"names":[],"mappings":";;;AAAA,uDAAyC;AAEzC,4DAA4B;AAC5B,iCAAiC;AACjC,4DAA4B;AAE5B,sDAAsB;AAStB,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAW;IACrD,MAAM,GAAG,GAAG,IAAI,aAAG,EAAE,CAAC;IACtB,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,GAAQ,CAAC;IACvD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAE,GAAG,IAAA,gBAAQ,EAAsB,EAAE,CAAC,CAAC;IAC/D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAEhC,MAAM,WAAW,GAAS;QACxB,EAAE,EAAE,GAAG;QACP,IAAI,EAAE;YACJ,KAAK,EAAE,KAAK;YACZ,WAAW;YACX,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,SAAS,EAAE,EAAE;SACd;QACD,QAAQ;KACT,CAAA;IACD,MAAM,QAAQ,GAAG,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAG,QAAQ,EAAC;YACV,SAAS,CAAC,IAAI,CAAC,CAAA;SAChB;IACH,CAAC,EAAC,CAAC,QAAQ,CAAC,CAAC,CAAA;IACb,OAAO,CACL,2CACG,MAAM,CAAC,CAAC,CAAC,uCAAK,SAAS,EAAC,cAAc;QACrC,uCAAK,SAAS,EAAC,gBAAgB;YAC/B,8BAAC,eAAK,IAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAI,CACnH;QACN,8BAAC,eAAK,IACJ,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,MAAM,GACb,CACE,CAAC,CAAC,CAAC,qDAAkB,CACvB,CACP,CAAC;AACJ,CAAC;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
const react_syntax_highlighter_1 = require("react-syntax-highlighter");
|
|
6
|
+
const hljs_1 = require("react-syntax-highlighter/dist/cjs/styles/hljs");
|
|
7
|
+
const CodeComponent = ({ children }) => {
|
|
8
|
+
return (react_1.default.createElement(react_syntax_highlighter_1.Prism, { language: "javascript", style: hljs_1.dracula, customStyle: {
|
|
9
|
+
background: "#1E293B",
|
|
10
|
+
borderRadius: "10px",
|
|
11
|
+
color: "#94A3B8"
|
|
12
|
+
}, showLineNumbers: true }, children));
|
|
13
|
+
};
|
|
14
|
+
exports.default = CodeComponent;
|
|
15
|
+
//# sourceMappingURL=Code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Code.js","sourceRoot":"","sources":["../../../src/components/Code.tsx"],"names":[],"mappings":";;;AAAA,0DAA0B;AAC1B,uEAAsE;AACtE,wEAAwE;AAExE,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAO,EAAE,EAAE;IAC1C,OAAQ,CACN,8BAAC,gCAAiB,IAChB,QAAQ,EAAC,YAAY,EACrB,KAAK,EAAE,cAAO,EACd,WAAW,EAAE;YACX,UAAU,EAAE,SAAS;YACrB,YAAY,EAAE,MAAM;YACpB,KAAK,EAAE,SAAS;SACjB,EACD,eAAe,EAAE,IAAI,IAGpB,QAAQ,CACS,CACrB,CAAA;AACH,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Node } from 'reactflow';
|
|
3
|
+
import { JSONSchema7Object } from 'json-schema';
|
|
4
|
+
type NodeProps = {
|
|
5
|
+
setCurrentNode: (node: Node) => void;
|
|
6
|
+
setnNodes: any;
|
|
7
|
+
nNodes: {
|
|
8
|
+
[x: string]: Node;
|
|
9
|
+
};
|
|
10
|
+
initialNode: Node;
|
|
11
|
+
schema: JSONSchema7Object;
|
|
12
|
+
};
|
|
13
|
+
declare const _default: ({ setCurrentNode, setnNodes, nNodes, initialNode, schema }: NodeProps) => React.JSX.Element;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
/* eslint-disable import/no-anonymous-default-export */
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const react_flow_smart_edge_1 = require("@tisoap/react-flow-smart-edge");
|
|
7
|
+
const reactflow_1 = tslib_1.__importStar(require("reactflow"));
|
|
8
|
+
const dagre_1 = tslib_1.__importDefault(require("dagre"));
|
|
9
|
+
const reusables_1 = require("../utils/reusables");
|
|
10
|
+
const position = { x: 0, y: 50 };
|
|
11
|
+
const initialEdges = [
|
|
12
|
+
{
|
|
13
|
+
id: 'edges-e5-7',
|
|
14
|
+
source: '0',
|
|
15
|
+
target: '1',
|
|
16
|
+
label: '+',
|
|
17
|
+
labelBgPadding: [8, 4],
|
|
18
|
+
labelBgBorderRadius: 4,
|
|
19
|
+
animated: true,
|
|
20
|
+
markerEnd: {
|
|
21
|
+
type: reactflow_1.MarkerType.ArrowClosed,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
const dagreGraph = new dagre_1.default.graphlib.Graph();
|
|
26
|
+
dagreGraph.setDefaultEdgeLabel(() => ({}));
|
|
27
|
+
const nodeWidth = 172;
|
|
28
|
+
const nodeHeight = 36;
|
|
29
|
+
const getLayoutedElements = (nodes, edges, direction = 'LR') => {
|
|
30
|
+
dagreGraph.setGraph({ rankdir: direction });
|
|
31
|
+
nodes.forEach(node => {
|
|
32
|
+
dagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });
|
|
33
|
+
});
|
|
34
|
+
edges.forEach((edge) => {
|
|
35
|
+
dagreGraph.setEdge(edge.source, edge.target);
|
|
36
|
+
});
|
|
37
|
+
dagre_1.default.layout(dagreGraph);
|
|
38
|
+
nodes.forEach((node) => {
|
|
39
|
+
const nodeId = node.id;
|
|
40
|
+
const nodeWithPosition = dagreGraph.node(nodeId);
|
|
41
|
+
node.sourcePosition = reactflow_1.Position.Right;
|
|
42
|
+
node.targetPosition = reactflow_1.Position.Left;
|
|
43
|
+
node.position = {
|
|
44
|
+
x: nodeWithPosition.x - nodeWidth / 3,
|
|
45
|
+
y: nodeWithPosition.y - nodeHeight / 3,
|
|
46
|
+
};
|
|
47
|
+
return node;
|
|
48
|
+
});
|
|
49
|
+
return { nodes, edges };
|
|
50
|
+
};
|
|
51
|
+
const Nodes = ({ setCurrentNode, setnNodes, initialNode, nNodes, schema }) => {
|
|
52
|
+
const { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements([initialNode], initialEdges);
|
|
53
|
+
const { setCenter } = (0, reactflow_1.useReactFlow)();
|
|
54
|
+
const [nodes, setNodes, onNodesChange] = (0, reactflow_1.useNodesState)(layoutedNodes);
|
|
55
|
+
const [edges, setEdges, onEdgesChange] = (0, reactflow_1.useEdgesState)(layoutedEdges);
|
|
56
|
+
const onConnect = (0, react_1.useCallback)((connection) => setEdges((eds) => (0, reactflow_1.addEdge)(Object.assign(Object.assign({}, connection), { type: reactflow_1.ConnectionLineType.SmoothStep, animated: true }), eds)),
|
|
57
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
|
+
[]);
|
|
59
|
+
const focusNode = (x, y, zoom) => {
|
|
60
|
+
setCenter(x, y, { zoom, duration: 1000 });
|
|
61
|
+
};
|
|
62
|
+
let initialNodes = [initialNode];
|
|
63
|
+
const extractChildren = (props, parent) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
const children = [];
|
|
65
|
+
for (const prop in props) {
|
|
66
|
+
const id = String(Math.floor(Math.random() * 1000000));
|
|
67
|
+
if (props[prop].$ref) {
|
|
68
|
+
const res = yield (0, reusables_1.resolveRef)(props[prop].$ref, schema);
|
|
69
|
+
children.push(Object.assign(Object.assign(Object.assign(Object.assign({}, props[prop]), { label: prop, id, parent: parent.id, relations: Object.assign(Object.assign({}, parent.relations), { [parent.id]: 'node' }) }), res), { children: [] }));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
children.push(Object.assign(Object.assign({}, props[prop]), { label: prop, id, parent: parent.id, relations: Object.assign(Object.assign({}, parent.relations), { [parent.id]: 'node' }), children: [] }));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return children;
|
|
76
|
+
});
|
|
77
|
+
(0, react_1.useEffect)(() => {
|
|
78
|
+
const newNodes = [];
|
|
79
|
+
initialNodes.map((item) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
const children = yield extractChildren(item.data.properties, item);
|
|
81
|
+
newNodes.push({
|
|
82
|
+
id: item.id,
|
|
83
|
+
type: "input",
|
|
84
|
+
data: {
|
|
85
|
+
children,
|
|
86
|
+
label: item.data.label,
|
|
87
|
+
description: item.data.description,
|
|
88
|
+
properties: Object.assign({}, item.data.properties),
|
|
89
|
+
relations: item.data.relations
|
|
90
|
+
},
|
|
91
|
+
position: { x: 0, y: 0 },
|
|
92
|
+
sourcePosition: reactflow_1.Position.Right,
|
|
93
|
+
targetPosition: reactflow_1.Position.Left,
|
|
94
|
+
});
|
|
95
|
+
}));
|
|
96
|
+
setNodes(newNodes);
|
|
97
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
|
+
}, []);
|
|
99
|
+
const nodeClick = (_event, node) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
const findChildren = nodes.filter((item) => { var _a; return ((_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.parent) === node.id; });
|
|
101
|
+
if (!findChildren.length) {
|
|
102
|
+
const itemChildren = node.data.children;
|
|
103
|
+
const newEdges = [
|
|
104
|
+
...edges,
|
|
105
|
+
...node.data.children.map((item) => {
|
|
106
|
+
var _a;
|
|
107
|
+
return {
|
|
108
|
+
id: String(Math.floor(Math.random() * 1000000)),
|
|
109
|
+
source: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.parent,
|
|
110
|
+
target: item === null || item === void 0 ? void 0 : item.id,
|
|
111
|
+
markerEnd: {
|
|
112
|
+
type: reactflow_1.MarkerType.ArrowClosed,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}),
|
|
116
|
+
];
|
|
117
|
+
//TODO: Fix nodes type error
|
|
118
|
+
const newNodes = nodes.concat(node.data.children);
|
|
119
|
+
const { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements(newNodes, newEdges, "LR");
|
|
120
|
+
setNodes([...layoutedNodes]);
|
|
121
|
+
setEdges([...layoutedEdges]);
|
|
122
|
+
if (itemChildren.length) {
|
|
123
|
+
focusNode(itemChildren[0].position.x, itemChildren[0].position.y, 0.9);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const newNodes = (0, reusables_1.removeElementsByParent)(nodes, node.id);
|
|
128
|
+
setNodes([...newNodes]);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
function handleMouseEnter(_e, node) {
|
|
132
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
if (!nNodes[node.id]) {
|
|
134
|
+
const itemChildren = [];
|
|
135
|
+
yield Promise.all(node.data.children.map((item) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
let children = [];
|
|
137
|
+
const extractProps = (0, reusables_1.propMerge)(item);
|
|
138
|
+
if (Object.keys(extractProps).length > 0) {
|
|
139
|
+
const res = yield extractChildren(extractProps, item);
|
|
140
|
+
children = res;
|
|
141
|
+
}
|
|
142
|
+
itemChildren.push({
|
|
143
|
+
id: item.id,
|
|
144
|
+
type: (children === null || children === void 0 ? void 0 : children.length) > 0 ? "default" : "output",
|
|
145
|
+
data: {
|
|
146
|
+
label: item.label,
|
|
147
|
+
children: children,
|
|
148
|
+
parent: item.parent,
|
|
149
|
+
examples: item.examples,
|
|
150
|
+
description: item.description,
|
|
151
|
+
relations: item.relations,
|
|
152
|
+
},
|
|
153
|
+
position: position,
|
|
154
|
+
sourcePosition: reactflow_1.Position.Right,
|
|
155
|
+
targetPosition: reactflow_1.Position.Left,
|
|
156
|
+
draggable: false,
|
|
157
|
+
});
|
|
158
|
+
})));
|
|
159
|
+
node.data.children = itemChildren;
|
|
160
|
+
nNodes[node.id] = node;
|
|
161
|
+
setnNodes(nNodes);
|
|
162
|
+
}
|
|
163
|
+
setCurrentNode(node);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
const edgeTypes = {
|
|
167
|
+
smart: react_flow_smart_edge_1.SmartBezierEdge,
|
|
168
|
+
};
|
|
169
|
+
return (react_1.default.createElement("div", { className: 'wrapper', style: {
|
|
170
|
+
width: '100%',
|
|
171
|
+
height: '95vh',
|
|
172
|
+
} },
|
|
173
|
+
react_1.default.createElement(reactflow_1.default, { nodes: nodes, edges: edges, edgeTypes: edgeTypes, onNodesChange: onNodesChange, connectionLineType: reactflow_1.ConnectionLineType.SmoothStep, onEdgesChange: onEdgesChange, onConnect: onConnect, onNodeClick: nodeClick, onNodeMouseEnter: handleMouseEnter, fitView: true, defaultViewport: { x: 1, y: 1, zoom: 0.9 } })));
|
|
174
|
+
};
|
|
175
|
+
// eslint-disable-next-line react/display-name
|
|
176
|
+
exports.default = ({ setCurrentNode, setnNodes, nNodes, initialNode, schema }) => (react_1.default.createElement(reactflow_1.ReactFlowProvider, null,
|
|
177
|
+
react_1.default.createElement(Nodes, { setnNodes: setnNodes, nNodes: nNodes, setCurrentNode: setCurrentNode, initialNode: initialNode, schema: schema })));
|
|
178
|
+
//# sourceMappingURL=Nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Nodes.js","sourceRoot":"","sources":["../../../src/components/Nodes.tsx"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,uDAAqD;AACrD,yEAA+D;AAC/D,+DAYkB;AAClB,0DAAyB;AACzB,kDAAiF;AAGjF,MAAM,QAAQ,GAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;AAClC,MAAM,YAAY,GAAW;IAC3B;QACE,EAAE,EAAE,YAAY;QAChB,MAAM,EAAE,GAAG;QACX,MAAM,EAAE,GAAG;QACX,KAAK,EAAE,GAAG;QACV,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACtB,mBAAmB,EAAE,CAAC;QACtB,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE;YACT,IAAI,EAAE,sBAAU,CAAC,WAAW;SAC7B;KACF;CACF,CAAC;AAGF,MAAM,UAAU,GAAG,IAAI,eAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,C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AAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,8BAAkB,CAAC,UAAU,EACjD,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,SAAS,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,QACP,eAAe,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAC1C,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,8CAA8C;AAC9C,kBAAe,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAa,EAAE,EAAE,CAAC,CACxF,8BAAC,6BAAiB;IAChB,8BAAC,KAAK,IAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAG,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAI,CACxG,CACrB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Node } from 'reactflow';
|
|
3
|
+
type Props = {
|
|
4
|
+
node: Node | undefined;
|
|
5
|
+
nodes: {
|
|
6
|
+
[x: string]: Node;
|
|
7
|
+
};
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
declare function Panel({ node, nodes, title, description }: Props): React.JSX.Element;
|
|
12
|
+
export default Panel;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const Tables_1 = tslib_1.__importDefault(require("./Tables"));
|
|
6
|
+
const Code_1 = tslib_1.__importDefault(require("./Code"));
|
|
7
|
+
function Panel({ node, nodes, title, description }) {
|
|
8
|
+
var _a;
|
|
9
|
+
const [view, setView] = (0, react_1.useState)();
|
|
10
|
+
const [children, setChildren] = (0, react_1.useState)([]);
|
|
11
|
+
const [activeNode, setActiveNode] = (0, react_1.useState)(node);
|
|
12
|
+
const data = node === null || node === void 0 ? void 0 : node.data;
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
if (node) {
|
|
15
|
+
setView(true);
|
|
16
|
+
if (data.children.length > 0) {
|
|
17
|
+
setChildren(data.children);
|
|
18
|
+
setActiveNode(node);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
setActiveNode(nodes[data.parent]);
|
|
22
|
+
setChildren(nodes[data.parent].data.children);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}, [node]);
|
|
26
|
+
if (view) {
|
|
27
|
+
return (react_1.default.createElement("div", { className: 'panel' },
|
|
28
|
+
react_1.default.createElement("h1", null, (activeNode === null || activeNode === void 0 ? void 0 : activeNode.data.title) || (activeNode === null || activeNode === void 0 ? void 0 : activeNode.data.label)),
|
|
29
|
+
react_1.default.createElement("p", null, activeNode === null || activeNode === void 0 ? void 0 : activeNode.data.description),
|
|
30
|
+
children.length > 0 && react_1.default.createElement(Tables_1.default, { nodes: children, active: node }),
|
|
31
|
+
((_a = activeNode === null || activeNode === void 0 ? void 0 : activeNode.data) === null || _a === void 0 ? void 0 : _a.examples) && (react_1.default.createElement("div", { className: 'examples-wrapper' },
|
|
32
|
+
react_1.default.createElement("h1", { className: 'font-bold' }, "Examples"), activeNode === null || activeNode === void 0 ? void 0 :
|
|
33
|
+
activeNode.data.examples.map((example) => (react_1.default.createElement(Code_1.default, { key: example.title }, JSON.stringify(example, null, 2))))))));
|
|
34
|
+
}
|
|
35
|
+
return (react_1.default.createElement("div", { className: 'panel' },
|
|
36
|
+
react_1.default.createElement("h1", null, title),
|
|
37
|
+
react_1.default.createElement("p", null, description)));
|
|
38
|
+
}
|
|
39
|
+
exports.default = Panel;
|
|
40
|
+
//# sourceMappingURL=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