ui-layout-manager-dev 0.0.1
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/.storybook/main.js +22 -0
- package/.storybook/manager.js +6 -0
- package/.storybook/preview.js +13 -0
- package/LICENSE +201 -0
- package/README.md +80 -0
- package/babel.config.js +6 -0
- package/dist/cjs/index.js +15 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/LayoutWorker.js +494 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -0
- package/jsconfig.json +13 -0
- package/package.json +68 -0
- package/rollup.config.mjs +49 -0
- package/src/components/LayoutManager/Components/Container/Container.jsx +136 -0
- package/src/components/LayoutManager/Components/Container/Container.scss +23 -0
- package/src/components/LayoutManager/Components/HandleBar/HandleBar.jsx +183 -0
- package/src/components/LayoutManager/Components/HandleBar/HandleBar.scss +74 -0
- package/src/components/LayoutManager/Components/LazyLoader/LazyLoader.js +33 -0
- package/src/components/LayoutManager/Components/LazyLoader/LazyLoader.scss +7 -0
- package/src/components/LayoutManager/Components/RootContainer/RootContainer.jsx +106 -0
- package/src/components/LayoutManager/Components/RootContainer/RootContainer.scss +13 -0
- package/src/components/LayoutManager/Controller/LAYOUT_WORKER_PROTOCOL.js +11 -0
- package/src/components/LayoutManager/Controller/LayoutController.js +201 -0
- package/src/components/LayoutManager/Controller/TRANSFORMATION_TYPES.js +6 -0
- package/src/components/LayoutManager/Controller/Worker/HandleRulesEnforcer.js +179 -0
- package/src/components/LayoutManager/Controller/Worker/LayoutEditor.js +183 -0
- package/src/components/LayoutManager/Controller/Worker/LayoutWorker.js +41 -0
- package/src/components/LayoutManager/Controller/Worker/ParentRuleEnforcer.js +79 -0
- package/src/components/LayoutManager/Controller/Worker/Size.js +29 -0
- package/src/components/LayoutManager/LayoutManager.jsx +31 -0
- package/src/components/LayoutManager/LayoutManager.scss +0 -0
- package/src/components/LayoutManager/Providers/ComponentRegistryContext.js +7 -0
- package/src/components/LayoutManager/Providers/LayoutProvider.js +48 -0
- package/src/components/LayoutManager/docs/ui_layout_manager_system_diagram.JPG +0 -0
- package/src/components/LayoutManager/index.js +1 -0
- package/src/index.js +1 -0
- package/src/stories/LayoutManager.stories.js +64 -0
- package/src/stories/LayoutManager.stories.scss +7 -0
- package/src/stories/layouts/vsCode/default.json +195 -0
- package/src/stories/layouts/vsCode/sample1.json +151 -0
- package/src/stories/sample_components/editor/EditorVSCode.jsx +11 -0
- package/src/stories/sample_components/editor/filetree.json +1 -0
- package/src/stories/sample_components/flow/Flow.jsx +10 -0
- package/src/stories/sample_components/flow/SampleTree.json +8 -0
- package/src/stories/sample_components/map/MapSample.jsx +43 -0
- package/src/stories/sample_components/map/MapSample.scss +3 -0
- package/src/stories/sample_components/stack/Stack.jsx +21 -0
- package/tests/LayoutEditor/LayoutEditor.test.js +14 -0
- package/tests/LayoutEditor/layouts/default.json +195 -0
- package/vitest.config.js +8 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
|
|
3
|
+
/** @type { import('@storybook/react-webpack5').StorybookConfig } */
|
|
4
|
+
const config = {
|
|
5
|
+
"stories": [
|
|
6
|
+
"../src/**/*.mdx",
|
|
7
|
+
"../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"
|
|
8
|
+
],
|
|
9
|
+
"addons": [
|
|
10
|
+
"@storybook/addon-webpack5-compiler-swc",
|
|
11
|
+
"@storybook/addon-essentials",
|
|
12
|
+
"@storybook/addon-onboarding",
|
|
13
|
+
"@chromatic-com/storybook",
|
|
14
|
+
"@storybook/addon-interactions",
|
|
15
|
+
"@storybook/preset-scss",
|
|
16
|
+
],
|
|
17
|
+
"framework": {
|
|
18
|
+
"name": "@storybook/react-webpack5",
|
|
19
|
+
"options": {}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export default config;
|
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
|
+
# ui-layout-manager
|
|
2
|
+
A react component to manage layouts and themes in single page applications.
|
|
3
|
+
|
|
4
|
+
Link to [storybook](https://vishalpalaniappan.github.io/ui-layout-manager/).
|
|
5
|
+
|
|
6
|
+
## Developing
|
|
7
|
+
Install Libraries:
|
|
8
|
+
```
|
|
9
|
+
npm i
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Run Storybook:
|
|
13
|
+
```
|
|
14
|
+
npm run storybook
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Build Storybook:
|
|
18
|
+
```
|
|
19
|
+
npm run build-storybook
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Build the library:
|
|
23
|
+
```
|
|
24
|
+
npm run build
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Developing Locally Using Storybook
|
|
28
|
+
|
|
29
|
+
The configuration needed for developing the application locally using storybook has already been added. Run `npm run storybook` to start the server and update the relevant components and stories to see the changes in the UI.
|
|
30
|
+
|
|
31
|
+
## Developing Locally Using `npm link`
|
|
32
|
+
To test the library locally by importing it into another react application, use the following steps:
|
|
33
|
+
|
|
34
|
+
- run `npm link` in the component library folder.
|
|
35
|
+
- run `npm link ui-layout-manager` in the local application which will import the library
|
|
36
|
+
- You should now be able to import the component into the local application
|
|
37
|
+
- run `npm run build` in the component library to push the changes to the local application
|
|
38
|
+
|
|
39
|
+
## Background
|
|
40
|
+
|
|
41
|
+
As I began scoping out the observability platform from the ground up, it quickly became clear that the UI tools would become increasingly complex. The current approach of hardcoding UI layouts is not practical for managing more complex applications. This realization underscored the need for a layout manager, which motivated the development of this React component.
|
|
42
|
+
|
|
43
|
+
To ensure reusability and broad adoption, I decided to develop this layout manager as a standalone React library that can be integrated into any application.
|
|
44
|
+
|
|
45
|
+
### Features
|
|
46
|
+
This layout manager component will provide the following features:
|
|
47
|
+
|
|
48
|
+
- JSON-Based Layout Definition:
|
|
49
|
+
- Define the entire application layout through a structured JSON object.
|
|
50
|
+
- Dynamic Component Injection:
|
|
51
|
+
- Programmatically load components into designated containers within the layout.
|
|
52
|
+
- Support for Multiple Layouts:
|
|
53
|
+
- Define and switch between multiple layout configurations using JSON.
|
|
54
|
+
- Theme Support:
|
|
55
|
+
- Define themes in JSON.
|
|
56
|
+
- Load and apply themes dynamically across components.
|
|
57
|
+
- Layout Persistence:
|
|
58
|
+
- Cache layout state to local storage.
|
|
59
|
+
- Load the saved layout state automatically on startup.
|
|
60
|
+
- Collapsible Containers:
|
|
61
|
+
- Allow containers to collapse into side menus for a cleaner and more flexible UI.
|
|
62
|
+
- Tabbed Containers:
|
|
63
|
+
- Define tabs within a container, each capable of rendering a different custom component.
|
|
64
|
+
- Resizable and Movable Containers:
|
|
65
|
+
- All containers should be fully resizable and draggable, giving users complete control over their workspace layout.
|
|
66
|
+
|
|
67
|
+
The objective is to abstract all layout logic away from the application developer. Developers should be able to define a layout, register their components, and integrate everything into a single-page application—without needing to manage layout behavior themselves.
|
|
68
|
+
|
|
69
|
+
### Example JSON Document
|
|
70
|
+
|
|
71
|
+
To define the layout, the component will use a grid system represented by a JSON object. This grid system will allow developers to:
|
|
72
|
+
- Position and size containers on a grid
|
|
73
|
+
- Define which components go into each container
|
|
74
|
+
- Specify tabbed content within containers
|
|
75
|
+
- Configure collapsible menus for minimized or hidden containers
|
|
76
|
+
|
|
77
|
+
An example JSON schema will be provided as the layout specification is finalized. The design for collapsible menus will follow a model similar to applications like Adobe Photoshop, where panels can be collapsed and docked for space efficiency and quick access.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
package/babel.config.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";var e=require("react"),n=require("react/jsx-runtime"),r="undefined"!=typeof document?document.currentScript:null;function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var o,i={exports:{}},a={exports:{}},c={};var s,u,l,f,d,p,y,h,v,m,b,g,w,x,S,E={};
|
|
2
|
+
/** @license React v16.13.1
|
|
3
|
+
* react-is.development.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/function O(){return u||(u=1,"production"===process.env.NODE_ENV?a.exports=function(){if(o)return c;o=1;var e="function"==typeof Symbol&&Symbol.for,n=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,t=e?Symbol.for("react.fragment"):60107,i=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,u=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,f=e?Symbol.for("react.concurrent_mode"):60111,d=e?Symbol.for("react.forward_ref"):60112,p=e?Symbol.for("react.suspense"):60113,y=e?Symbol.for("react.suspense_list"):60120,h=e?Symbol.for("react.memo"):60115,v=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,b=e?Symbol.for("react.fundamental"):60117,g=e?Symbol.for("react.responder"):60118,w=e?Symbol.for("react.scope"):60119;function x(e){if("object"==typeof e&&null!==e){var o=e.$$typeof;switch(o){case n:switch(e=e.type){case l:case f:case t:case a:case i:case p:return e;default:switch(e=e&&e.$$typeof){case u:case d:case v:case h:case s:return e;default:return o}}case r:return o}}}function S(e){return x(e)===f}return c.AsyncMode=l,c.ConcurrentMode=f,c.ContextConsumer=u,c.ContextProvider=s,c.Element=n,c.ForwardRef=d,c.Fragment=t,c.Lazy=v,c.Memo=h,c.Portal=r,c.Profiler=a,c.StrictMode=i,c.Suspense=p,c.isAsyncMode=function(e){return S(e)||x(e)===l},c.isConcurrentMode=S,c.isContextConsumer=function(e){return x(e)===u},c.isContextProvider=function(e){return x(e)===s},c.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},c.isForwardRef=function(e){return x(e)===d},c.isFragment=function(e){return x(e)===t},c.isLazy=function(e){return x(e)===v},c.isMemo=function(e){return x(e)===h},c.isPortal=function(e){return x(e)===r},c.isProfiler=function(e){return x(e)===a},c.isStrictMode=function(e){return x(e)===i},c.isSuspense=function(e){return x(e)===p},c.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===t||e===f||e===a||e===i||e===p||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===v||e.$$typeof===h||e.$$typeof===s||e.$$typeof===u||e.$$typeof===d||e.$$typeof===b||e.$$typeof===g||e.$$typeof===w||e.$$typeof===m)},c.typeOf=x,c}():a.exports=(s||(s=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,n=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,t=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,a=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,s=e?Symbol.for("react.async_mode"):60111,u=e?Symbol.for("react.concurrent_mode"):60111,l=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,d=e?Symbol.for("react.suspense_list"):60120,p=e?Symbol.for("react.memo"):60115,y=e?Symbol.for("react.lazy"):60116,h=e?Symbol.for("react.block"):60121,v=e?Symbol.for("react.fundamental"):60117,m=e?Symbol.for("react.responder"):60118,b=e?Symbol.for("react.scope"):60119;function g(e){if("object"==typeof e&&null!==e){var d=e.$$typeof;switch(d){case n:var h=e.type;switch(h){case s:case u:case t:case i:case o:case f:return h;default:var v=h&&h.$$typeof;switch(v){case c:case l:case y:case p:case a:return v;default:return d}}case r:return d}}}var w=s,x=u,S=c,O=a,j=n,R=l,C=t,k=y,T=p,I=r,L=i,P=o,N=f,z=!1;function $(e){return g(e)===u}E.AsyncMode=w,E.ConcurrentMode=x,E.ContextConsumer=S,E.ContextProvider=O,E.Element=j,E.ForwardRef=R,E.Fragment=C,E.Lazy=k,E.Memo=T,E.Portal=I,E.Profiler=L,E.StrictMode=P,E.Suspense=N,E.isAsyncMode=function(e){return z||(z=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),$(e)||g(e)===s},E.isConcurrentMode=$,E.isContextConsumer=function(e){return g(e)===c},E.isContextProvider=function(e){return g(e)===a},E.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},E.isForwardRef=function(e){return g(e)===l},E.isFragment=function(e){return g(e)===t},E.isLazy=function(e){return g(e)===y},E.isMemo=function(e){return g(e)===p},E.isPortal=function(e){return g(e)===r},E.isProfiler=function(e){return g(e)===i},E.isStrictMode=function(e){return g(e)===o},E.isSuspense=function(e){return g(e)===f},E.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===t||e===u||e===i||e===o||e===f||e===d||"object"==typeof e&&null!==e&&(e.$$typeof===y||e.$$typeof===p||e.$$typeof===a||e.$$typeof===c||e.$$typeof===l||e.$$typeof===v||e.$$typeof===m||e.$$typeof===b||e.$$typeof===h)},E.typeOf=g}()),E)),a.exports}
|
|
10
|
+
/*
|
|
11
|
+
object-assign
|
|
12
|
+
(c) Sindre Sorhus
|
|
13
|
+
@license MIT
|
|
14
|
+
*/function j(){if(f)return l;f=1;var e=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;return l=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var n={},r=0;r<10;r++)n["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(n).map(function(e){return n[e]}).join(""))return!1;var t={};return"abcdefghijklmnopqrst".split("").forEach(function(e){t[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},t)).join("")}catch(e){return!1}}()?Object.assign:function(t,o){for(var i,a,c=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(t),s=1;s<arguments.length;s++){for(var u in i=Object(arguments[s]))n.call(i,u)&&(c[u]=i[u]);if(e){a=e(i);for(var l=0;l<a.length;l++)r.call(i,a[l])&&(c[a[l]]=i[a[l]])}}return c},l}function R(){if(p)return d;p=1;return d="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function C(){return h?y:(h=1,y=Function.call.bind(Object.prototype.hasOwnProperty))}function k(){if(m)return v;m=1;var e=function(){};if("production"!==process.env.NODE_ENV){var n=R(),r={},t=C();e=function(e){var n="Warning: "+e;"undefined"!=typeof console&&console.error(n);try{throw new Error(n)}catch(e){}}}function o(o,i,a,c,s){if("production"!==process.env.NODE_ENV)for(var u in o)if(t(o,u)){var l;try{if("function"!=typeof o[u]){var f=Error((c||"React class")+": "+a+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw f.name="Invariant Violation",f}l=o[u](i,u,c,a,null,n)}catch(e){l=e}if(!l||l instanceof Error||e((c||"React class")+": type specification of "+a+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof l+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),l instanceof Error&&!(l.message in r)){r[l.message]=!0;var d=s?s():"";e("Failed "+a+" type: "+l.message+(null!=d?d:""))}}}return o.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(r={})},v=o}function T(){if(g)return b;g=1;var e=O(),n=j(),r=R(),t=C(),o=k(),i=function(){};function a(){return null}return"production"!==process.env.NODE_ENV&&(i=function(e){var n="Warning: "+e;"undefined"!=typeof console&&console.error(n);try{throw new Error(n)}catch(e){}}),b=function(c,s){var u="function"==typeof Symbol&&Symbol.iterator;var l="<<anonymous>>",f={array:h("array"),bigint:h("bigint"),bool:h("boolean"),func:h("function"),number:h("number"),object:h("object"),string:h("string"),symbol:h("symbol"),any:y(a),arrayOf:function(e){return y(function(n,t,o,i,a){if("function"!=typeof e)return new p("Property `"+a+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var c=n[t];if(!Array.isArray(c))return new p("Invalid "+i+" `"+a+"` of type `"+b(c)+"` supplied to `"+o+"`, expected an array.");for(var s=0;s<c.length;s++){var u=e(c,s,o,i,a+"["+s+"]",r);if(u instanceof Error)return u}return null})},element:y(function(e,n,r,t,o){var i=e[n];return c(i)?null:new p("Invalid "+t+" `"+o+"` of type `"+b(i)+"` supplied to `"+r+"`, expected a single ReactElement.")}),elementType:y(function(n,r,t,o,i){var a=n[r];return e.isValidElementType(a)?null:new p("Invalid "+o+" `"+i+"` of type `"+b(a)+"` supplied to `"+t+"`, expected a single ReactElement type.")}),instanceOf:function(e){return y(function(n,r,t,o,i){if(!(n[r]instanceof e)){var a=e.name||l;return new p("Invalid "+o+" `"+i+"` of type `"+(((c=n[r]).constructor&&c.constructor.name?c.constructor.name:l)+"` supplied to `")+t+"`, expected instance of `"+a+"`.")}var c;return null})},node:y(function(e,n,r,t,o){return m(e[n])?null:new p("Invalid "+t+" `"+o+"` supplied to `"+r+"`, expected a ReactNode.")}),objectOf:function(e){return y(function(n,o,i,a,c){if("function"!=typeof e)return new p("Property `"+c+"` of component `"+i+"` has invalid PropType notation inside objectOf.");var s=n[o],u=b(s);if("object"!==u)return new p("Invalid "+a+" `"+c+"` of type `"+u+"` supplied to `"+i+"`, expected an object.");for(var l in s)if(t(s,l)){var f=e(s,l,i,a,c+"."+l,r);if(f instanceof Error)return f}return null})},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&i(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),a;return y(function(n,r,t,o,i){for(var a=n[r],c=0;c<e.length;c++)if(d(a,e[c]))return null;var s=JSON.stringify(e,function(e,n){return"symbol"===g(n)?String(n):n});return new p("Invalid "+o+" `"+i+"` of value `"+String(a)+"` supplied to `"+t+"`, expected one of "+s+".")})},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&i("Invalid argument supplied to oneOfType, expected an instance of array."),a;for(var n=0;n<e.length;n++){var o=e[n];if("function"!=typeof o)return i("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+w(o)+" at index "+n+"."),a}return y(function(n,o,i,a,c){for(var s=[],u=0;u<e.length;u++){var l=(0,e[u])(n,o,i,a,c,r);if(null==l)return null;l.data&&t(l.data,"expectedType")&&s.push(l.data.expectedType)}return new p("Invalid "+a+" `"+c+"` supplied to `"+i+"`"+(s.length>0?", expected one of type ["+s.join(", ")+"]":"")+".")})},shape:function(e){return y(function(n,t,o,i,a){var c=n[t],s=b(c);if("object"!==s)return new p("Invalid "+i+" `"+a+"` of type `"+s+"` supplied to `"+o+"`, expected `object`.");for(var u in e){var l=e[u];if("function"!=typeof l)return v(o,i,a,u,g(l));var f=l(c,u,o,i,a+"."+u,r);if(f)return f}return null})},exact:function(e){return y(function(o,i,a,c,s){var u=o[i],l=b(u);if("object"!==l)return new p("Invalid "+c+" `"+s+"` of type `"+l+"` supplied to `"+a+"`, expected `object`.");var f=n({},o[i],e);for(var d in f){var y=e[d];if(t(e,d)&&"function"!=typeof y)return v(a,c,s,d,g(y));if(!y)return new p("Invalid "+c+" `"+s+"` key `"+d+"` supplied to `"+a+"`.\nBad object: "+JSON.stringify(o[i],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var h=y(u,d,a,c,s+"."+d,r);if(h)return h}return null})}};function d(e,n){return e===n?0!==e||1/e==1/n:e!=e&&n!=n}function p(e,n){this.message=e,this.data=n&&"object"==typeof n?n:{},this.stack=""}function y(e){if("production"!==process.env.NODE_ENV)var n={},t=0;function o(o,a,c,u,f,d,y){if(u=u||l,d=d||c,y!==r){if(s){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var v=u+":"+c;!n[v]&&t<3&&(i("You are manually calling a React.PropTypes validation function for the `"+d+"` prop on `"+u+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),n[v]=!0,t++)}}return null==a[c]?o?null===a[c]?new p("The "+f+" `"+d+"` is marked as required in `"+u+"`, but its value is `null`."):new p("The "+f+" `"+d+"` is marked as required in `"+u+"`, but its value is `undefined`."):null:e(a,c,u,f,d)}var a=o.bind(null,!1);return a.isRequired=o.bind(null,!0),a}function h(e){return y(function(n,r,t,o,i,a){var c=n[r];return b(c)!==e?new p("Invalid "+o+" `"+i+"` of type `"+g(c)+"` supplied to `"+t+"`, expected `"+e+"`.",{expectedType:e}):null})}function v(e,n,r,t,o){return new p((e||"React class")+": "+n+" type `"+r+"."+t+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function m(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(m);if(null===e||c(e))return!0;var n=function(e){var n=e&&(u&&e[u]||e["@@iterator"]);if("function"==typeof n)return n}(e);if(!n)return!1;var r,t=n.call(e);if(n!==e.entries){for(;!(r=t.next()).done;)if(!m(r.value))return!1}else for(;!(r=t.next()).done;){var o=r.value;if(o&&!m(o[1]))return!1}return!0;default:return!1}}function b(e){var n=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,n){return"symbol"===e||!!n&&("Symbol"===n["@@toStringTag"]||"function"==typeof Symbol&&n instanceof Symbol)}(n,e)?"symbol":n}function g(e){if(null==e)return""+e;var n=b(e);if("object"===n){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return n}function w(e){var n=g(e);switch(n){case"array":case"object":return"an "+n;case"boolean":case"date":case"regexp":return"a "+n;default:return n}}return p.prototype=Error.prototype,f.checkPropTypes=o,f.resetWarningCache=o.resetWarningCache,f.PropTypes=f,f},b}function I(){if(x)return w;x=1;var e=R();function n(){}function r(){}return r.resetWarningCache=n,w=function(){function t(n,r,t,o,i,a){if(a!==e){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function o(){return t}t.isRequired=t;var i={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:o,element:t,elementType:t,instanceOf:o,node:t,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:r,resetWarningCache:n};return i.PropTypes=i,i}}function L(){if(S)return i.exports;if(S=1,"production"!==process.env.NODE_ENV){var e=O();i.exports=T()(e.isElement,true)}else i.exports=I()();return i.exports}var P=t(L());function N(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}function z(e,n,r){return n&&function(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,A(t.key),t)}}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function $(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=B(e))||n){r&&(e=r);var t=0,o=function(){};return{s:o,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function _(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(e)).next,0===n);else for(;!(s=(t=i.call(r)).done)&&(c.push(t.value),c.length!==n);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(e,n)||B(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e){var n=function(e,n){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var t=r.call(e,n);if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof n?n:n+""}function B(e,n){if(e){if("string"==typeof e)return N(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?N(e,n):void 0}}var M={INITIALIZE:1,INITIALIZE_FLEXBOX:2,APPLY_SIZES:3,ERROR:4,TRANSFORMATIONS:5,MOVE_HANDLE_BAR:6},V=M=Object.freeze(M),D={UPDATE_SIZE:1},F=D=Object.freeze(D),W=function(){return z(function e(n){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.containers={},this.containerRefs={},this.ldf=n,this.numberOfContainers=0,this.registeredContainers=0,this.layoutLoaded=!1,this.numberOfContainers=this.ldf.containers?Object.keys(this.ldf.containers).length:0;try{this.worker=new Worker(new URL("./Worker/LayoutWorker.js","undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index.js",document.baseURI).href),{type:"module"}),this.worker.onmessage=this.handleWorkerMessage.bind(this),this.worker.onerror=function(e){return console.error("Worker error:",e)},this.sendToWorker(V.INITIALIZE,{ldf:n})}catch(e){console.error("Failed to create worker:",e)}},[{key:"sendToWorker",value:function(e,n){this.worker.postMessage({code:e,args:n})}},{key:"registerContainer",value:function(e,n,r){e in this.containers||(this.registeredContainers+=1),this.containers[e]=n,this.containerRefs[e]=r,console.log("Registered container with id: ".concat(e," ")),this.registeredContainers!==this.numberOfContainers||this.layoutLoaded||(console.log("All containers registered, layout is ready."),this.sendToWorker(V.INITIALIZE_FLEXBOX))}},{key:"unregisterContainer",value:function(e){delete this.containers[e]}},{key:"handleRootResize",value:function(){if(this.layoutLoaded){var e={};for(var n in this.containerRefs)if(this.containerRefs.hasOwnProperty(n)){var r=this.containerRefs[n].getBoundingClientRect();e[n]={width:r.width,height:r.height}}this.sendToWorker(V.APPLY_SIZES,{sizes:e})}}},{key:"moveHandleBar",value:function(e){for(var n={},r=0,t=[e.parent,e.sibling1,e.sibling2];r<t.length;r++){var o=t[r],i=this.containerRefs[o].getBoundingClientRect();n[o]={width:i.width,height:i.height}}e.sizes=n,this.sendToWorker(V.MOVE_HANDLE_BAR,{metadata:e}),this.handleRootResize()}},{key:"applyTransformations",value:function(e,n){var r=this;requestAnimationFrame(function(){var t,o=$(e);try{for(o.s();!(t=o.n()).done;){var i=t.value;switch(i.type){case F.UPDATE_SIZE:r.containers[i.id].current.updateStyles(i.args.style);break;case F.REMOVE_NODE:break;default:console.warn("Unknown transformation was requested.")}}}catch(e){o.e(e)}finally{o.f()}n&&(r.layoutLoaded=!0)})}},{key:"handleWorkerMessage",value:function(e){var n;switch(e.data.type){case V.INITIALIZE_FLEXBOX:n=e.data.data,this.applyTransformations(n,!0);break;case V.TRANSFORMATIONS:n=e.data.data,this.applyTransformations(n,!1);break;case V.ERROR:console.error("Error from worker:",e.data)}}},{key:"destroy",value:function(){this.worker&&(this.worker.terminate(),this.worker=null)}}])}(),H=e.createContext(null);function q(r){var t=r.layout,o=r.children,i=e.useMemo(function(){return new W(t)},[t]);return e.useEffect(function(){return function(){i.destroy()}},[i]),n.jsx(H.Provider,{value:i,children:o})}function U(){var n=e.useContext(H);if(!n)throw new Error("useLayoutController must be used within a LayoutControllerProvider");return n}function Y(e,n){void 0===n&&(n={});var r=n.insertAt;if(e&&"undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}q.propTypes={layout:P.object.isRequired,children:P.node.isRequired};Y(".handleBarHorizontalContainer {\n position: relative;\n width: 100%;\n height: 1px;\n background-color: #414141;\n}\n\n.handleBarHorizontal {\n position: absolute;\n top: 50%;\n height: 1px;\n left: 0;\n right: 0;\n transform: translateY(-50%);\n transition: all 0.2s ease;\n}\n\n.handleBarHorizontal:hover {\n background-color: #007acc;\n cursor: ns-resize;\n height: 5px;\n z-index: 10;\n}\n\n.handleBarHorizontalHover {\n background-color: #007acc;\n cursor: ns-resize;\n height: 5px;\n z-index: 10;\n}\n\n.handleBarVerticalContainer {\n position: relative;\n height: 100%;\n width: 1px;\n background-color: #414141;\n z-index: 1;\n}\n\n.handleBarVertical {\n position: absolute;\n top: 0;\n width: 1px;\n left: 50%;\n bottom: 0;\n transform: translateX(-50%);\n transition: all 0.3s ease;\n}\n\n.handleBarVertical:hover {\n background-color: #007acc;\n cursor: ew-resize;\n width: 5px;\n z-index: 10;\n}\n\n.handleBarVerticalHover {\n background-color: #007acc;\n cursor: ew-resize;\n width: 5px;\n z-index: 10;\n}");var X=function(r){var t=r.orientation,o=r.parent,i=r.sibling1,a=r.sibling2,c=U(),s=e.useRef(null),u=e.useRef(null),l=e.useRef(null),f=function(e){var n,r,l;e.preventDefault(),e.stopPropagation(),document.addEventListener("mousemove",d),document.addEventListener("mouseup",p),"horizontal"===t?(n="clientY",r="height",l="handleBarHorizontalHover"):"vertical"===t&&(n="clientX",r="width",l="handleBarVerticalHover");for(var f,y,h=c.containerRefs[o],v=c.containerRefs[i],m=c.containerRefs[a],b=c.ldf.containers[o],g=0;g<b.children.length;g++)b.children[g].containerId===i?f=b.children[g].size:b.children[g].containerId===a&&(y=b.children[g].size);s.current={downValueY:e[n],hoverClass:l,downKey:n,propKey:r,parentSize:h.getBoundingClientRect()[r],parentRef:h,sibling1Ref:v,sibling2Ref:m,sibling1LayoutConfig:f,sibling2LayoutConfig:y,sibling1Size:v.getBoundingClientRect()[r],sibling2Size:m.getBoundingClientRect()[r]},u.current.classList.add(l)};var d=function(e){if(s.current){e.preventDefault(),e.stopPropagation();var n=s.current,r=e[n.downKey]-n.downValueY,t=n.sibling1Size+r,u=n.sibling2Size-r;clearTimeout(l.current),l.current=setTimeout(function(){var r,t,s;c.moveHandleBar({handle:(r=e,t=n.parentRef,s=t.getBoundingClientRect(),{x:r.clientX-s.left,y:r.clientY-s.top}),parent:o,sibling1:i,sibling2:a})},.1);var f=Object.keys(n.sibling1LayoutConfig);if(!(f.includes("min")&&t<=n.sibling1LayoutConfig.min.value||f.includes("max")&&t>=n.sibling1LayoutConfig.max.value)){var d=Object.keys(n.sibling2LayoutConfig);if(!(d.includes("min")&&u<=n.sibling2LayoutConfig.min.value||d.includes("max")&&u>=n.sibling2LayoutConfig.max.value)){var p=n.sibling1LayoutConfig.initial.type,y=n.sibling2LayoutConfig.initial.type;if("fill"===p&&"fill"===y&&t>50&&u>50)return c.containerRefs[i].style[n.propKey]=t+"px",void(c.containerRefs[a].style[n.propKey]=u+"px");"fill"!==p&&(c.containerRefs[i].style[n.propKey]=t+"px"),"fill"!==y&&(c.containerRefs[a].style[n.propKey]=u+"px")}}}},p=function(e){e.preventDefault(),e.stopPropagation(),document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",p),u.current.classList.remove(s.current.hoverClass),s.current=null};return n.jsx(e.Fragment,{children:"horizontal"===t?n.jsx("div",{onMouseDown:function(e){return f(e)},className:"handleBarHorizontalContainer",children:n.jsx("div",{ref:u,className:"handleBarHorizontal"})}):"vertical"===t?n.jsx("div",{onMouseDown:function(e){return f(e)},className:"handleBarVerticalContainer",children:n.jsx("div",{ref:u,className:"handleBarVertical"})}):null})};X.propTypes={orientation:P.string,sibling1:P.string,sibling2:P.string,parent:P.string};Y(".relative-container {\n position: relative;\n}\n\n.relative-container.hiding-horizontal {\n width: 0px !important;\n}\n\n.relative-container.hiding-vertical {\n height: 0px !important;\n}\n\n.verticalLine {\n height: 100%;\n width: 1px;\n background: red;\n}\n\n.horizontalLine {\n width: 100%;\n height: 1px;\n background: red;\n}");var Z=e.createContext({});Z.displayName="ComponentRegistryContext";Y(".lazyContainer {\n position: absolute;\n top: 0px;\n bottom: 0px;\n left: 0px;\n right: 0px;\n}");var K=function(r){var t=r.content,o=e.useContext(Z),i=e.useMemo(function(){if(o&&t&&"component"in t&&t.component in o)return e.lazy(o[t.component])},[o,t]);return n.jsx("div",{className:"lazyContainer",children:n.jsx(e.Suspense,{fallback:n.jsx("div",{children:"Loading..."}),children:i&&n.jsx(i,{})})})};K.propTypes={content:P.object};var J=function(r){var t=r.node,o=U(),i=e.useRef(null),a=e.useRef(null),c=_(e.useState(null),2),s=c[0],u=c[1],l=e.useCallback(function(e){for(var r=[],t=0;t<e.children.length;t++){var i=e.children[t];if("container"===i.type){var a=o.ldf.containers[e.children[t].containerId];a.parent=e,r.push(n.jsx(J,{meta:e.children[t],id:a.id,node:a},t))}else"handleBar"===i.type&&("horizontal"===e.orientation?r.push(n.jsx(X,{orientation:"vertical",parent:e.id,sibling1:i.sibling1,sibling2:i.sibling2},t)):"vertical"===e.orientation&&r.push(n.jsx(X,{orientation:"horizontal",parent:e.id,sibling1:i.sibling1,sibling2:i.sibling2},t)))}return r},[o]),f=e.useRef({});return f.current={updateStyles:function(e){var n="hiding-"+a.current;for(var r in e)if("display"===r&&"none"===e[r]){if(i.current.classList.contains(n))return;i.current.classList.add(n)}else if("display"===r&&"flex"===e[r]){if(!i.current.classList.contains(n))return;i.current.classList.remove(n)}else i.current.style[r]=e[r]}},e.useLayoutEffect(function(){if(t&&o&&i.current){a.current=t.parent.orientation;var e=t.children&&t.children.length>0;return e?"horizontal"===t.orientation?(i.current.style.display="flex",i.current.style.flexDirection="row",i.current.style.width="100%"):"vertical"===t.orientation?(i.current.style.display="flex",i.current.style.flexDirection="column",i.current.style.height="100%"):console.warn("Unknown orientation:",t.orientation):t.background?i.current.style.background=t.background:i.current.style.background="transparent",u(e?l(t):n.jsx(K,{content:t})),o.registerContainer(t.id,f,i.current),function(){o.unregisterContainer(t.id)}}},[t,o,l]),n.jsx("div",{ref:i,className:"relative-container",children:s})};J.propTypes={node:P.object};Y(".root-container {\n width: 100%;\n height: 100%;\n overflow: hidden;\n}\n\n.relative-container {\n position: relative;\n display: flex;\n width: 100%;\n height: 100%;\n overflow: hidden;\n}");var G=function(){var r=U(),t=e.useRef(null),o=e.useRef(null),i=e.useRef(!1),a=e.useRef({});a.current={};var c=_(e.useState(null),2),s=c[0],u=c[1],l=e.useCallback(function(e){for(var t=[],o=0;o<e.children.length;o++){var i=e.children[o];if("container"===i.type){var a=r.ldf.containers[e.children[o].containerId];a.parent=e,t.push(n.jsx(J,{meta:e.children[o],id:a.id,node:a},o))}else"handleBar"===i.type&&("horizontal"===e.orientation?t.push(n.jsx("div",{className:"verticalLine"})):"vertical"===e.orientation&&t.push(n.jsx("div",{className:"horizontalLine"})))}return t},[r]);return e.useLayoutEffect(function(){if(r){var e=r.ldf.containers[r.ldf.layoutRoot],n=e.children&&e.children.length>0;r.registerContainer(e.id,a,t.current),n&&("horizontal"===e.orientation?t.current.style.flexDirection="row":"vertical"===e.orientation&&(t.current.style.flexDirection="column")),u(n?l(e):null);var c=new ResizeObserver(function(e){i.current||(i.current=!0);var n,t=$(e);try{var a=function(){var e=n.value.contentRect,t=e.width,a=e.height;clearTimeout(o.current),o.current=setTimeout(function(){i.current=!1,r.handleRootResize(t,a)},1)};for(t.s();!(n=t.n()).done;)a()}catch(e){t.e(e)}finally{t.f()}});return c.observe(t.current),function(){r.unregisterContainer(r.ldf.layoutRoot),c.disconnect()}}},[r]),n.jsx("div",{className:"root-container",children:n.jsx("div",{ref:t,className:"relative-container",children:s})})};Y("");var Q=function(e){var r=e.ldf,t=e.registry;return n.jsx(q,{layout:r,children:n.jsx(Z.Provider,{value:t,children:n.jsx(G,{})})})};Q.propTypes={ldf:P.object,registry:P.object},exports.LayoutManager=Q;
|
|
15
|
+
//# sourceMappingURL=index.js.map
|