react-science 1.0.2 → 3.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.
Files changed (68) hide show
  1. package/lib/app/about/AboutDialogToolbarButton.d.ts.map +1 -1
  2. package/lib/app/about/AboutDialogToolbarButton.js +1 -1
  3. package/lib/app/about/AboutDialogToolbarButton.js.map +1 -1
  4. package/lib/app/kinds/iv/plot-view/IvPlotView.js +1 -1
  5. package/lib/app/kinds/iv/plot-view/IvPlotView.js.map +1 -1
  6. package/lib/components/fullscreen/FullscreenToolbarButton.js +1 -1
  7. package/lib/components/fullscreen/FullscreenToolbarButton.js.map +1 -1
  8. package/lib/components/index.d.ts +0 -1
  9. package/lib/components/index.d.ts.map +1 -1
  10. package/lib/components/index.js +0 -1
  11. package/lib/components/index.js.map +1 -1
  12. package/lib/components/info-panel/InfoPanel.d.ts.map +1 -1
  13. package/lib/components/info-panel/InfoPanel.js +65 -18
  14. package/lib/components/info-panel/InfoPanel.js.map +1 -1
  15. package/lib/components/toolbar/PanelPreferencesToolbar.d.ts.map +1 -1
  16. package/lib/components/toolbar/PanelPreferencesToolbar.js +1 -1
  17. package/lib/components/toolbar/PanelPreferencesToolbar.js.map +1 -1
  18. package/lib/components/toolbar/Toolbar.d.ts +3 -3
  19. package/lib/components/toolbar/Toolbar.d.ts.map +1 -1
  20. package/lib/components/toolbar/Toolbar.js +6 -4
  21. package/lib/components/toolbar/Toolbar.js.map +1 -1
  22. package/lib-esm/app/about/AboutDialogToolbarButton.d.ts.map +1 -1
  23. package/lib-esm/app/about/AboutDialogToolbarButton.js +1 -1
  24. package/lib-esm/app/about/AboutDialogToolbarButton.js.map +1 -1
  25. package/lib-esm/app/kinds/iv/plot-view/IvPlotView.js +1 -1
  26. package/lib-esm/app/kinds/iv/plot-view/IvPlotView.js.map +1 -1
  27. package/lib-esm/components/fullscreen/FullscreenToolbarButton.js +1 -1
  28. package/lib-esm/components/fullscreen/FullscreenToolbarButton.js.map +1 -1
  29. package/lib-esm/components/index.d.ts +0 -1
  30. package/lib-esm/components/index.d.ts.map +1 -1
  31. package/lib-esm/components/index.js +0 -1
  32. package/lib-esm/components/index.js.map +1 -1
  33. package/lib-esm/components/info-panel/InfoPanel.d.ts.map +1 -1
  34. package/lib-esm/components/info-panel/InfoPanel.js +67 -20
  35. package/lib-esm/components/info-panel/InfoPanel.js.map +1 -1
  36. package/lib-esm/components/toolbar/PanelPreferencesToolbar.d.ts.map +1 -1
  37. package/lib-esm/components/toolbar/PanelPreferencesToolbar.js +1 -1
  38. package/lib-esm/components/toolbar/PanelPreferencesToolbar.js.map +1 -1
  39. package/lib-esm/components/toolbar/Toolbar.d.ts +3 -3
  40. package/lib-esm/components/toolbar/Toolbar.d.ts.map +1 -1
  41. package/lib-esm/components/toolbar/Toolbar.js +6 -4
  42. package/lib-esm/components/toolbar/Toolbar.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/app/about/AboutDialogToolbarButton.tsx +6 -1
  45. package/src/app/kinds/iv/plot-view/IvPlotView.tsx +1 -1
  46. package/src/components/fullscreen/FullscreenToolbarButton.tsx +1 -1
  47. package/src/components/index.ts +0 -1
  48. package/src/components/info-panel/InfoPanel.tsx +148 -68
  49. package/src/components/toolbar/PanelPreferencesToolbar.tsx +2 -14
  50. package/src/components/toolbar/Toolbar.tsx +11 -7
  51. package/lib/components/layout-manager/LayoutManager.d.ts +0 -18
  52. package/lib/components/layout-manager/LayoutManager.d.ts.map +0 -1
  53. package/lib/components/layout-manager/LayoutManager.js +0 -51
  54. package/lib/components/layout-manager/LayoutManager.js.map +0 -1
  55. package/lib/components/layout-manager/index.d.ts +0 -2
  56. package/lib/components/layout-manager/index.d.ts.map +0 -1
  57. package/lib/components/layout-manager/index.js +0 -18
  58. package/lib/components/layout-manager/index.js.map +0 -1
  59. package/lib-esm/components/layout-manager/LayoutManager.d.ts +0 -18
  60. package/lib-esm/components/layout-manager/LayoutManager.d.ts.map +0 -1
  61. package/lib-esm/components/layout-manager/LayoutManager.js +0 -47
  62. package/lib-esm/components/layout-manager/LayoutManager.js.map +0 -1
  63. package/lib-esm/components/layout-manager/index.d.ts +0 -2
  64. package/lib-esm/components/layout-manager/index.d.ts.map +0 -1
  65. package/lib-esm/components/layout-manager/index.js +0 -2
  66. package/lib-esm/components/layout-manager/index.js.map +0 -1
  67. package/src/components/layout-manager/LayoutManager.tsx +0 -95
  68. package/src/components/layout-manager/index.ts +0 -1
@@ -8,6 +8,7 @@ import {
8
8
  PopoverProps,
9
9
  TagProps,
10
10
  Icon,
11
+ TooltipProps,
11
12
  } from '@blueprintjs/core';
12
13
  import { IconName } from '@blueprintjs/icons';
13
14
  import { css } from '@emotion/react';
@@ -53,12 +54,12 @@ export interface ToolbarProps extends ToolbarBaseProps {
53
54
 
54
55
  export interface ToolbarItemProps extends ToolbarBaseProps {
55
56
  id?: string;
56
- title: string;
57
+ tooltip?: TooltipProps['content'];
58
+ tooltipProps?: Omit<TooltipProps, 'content'>;
57
59
  icon: IconName | JSX.Element;
58
60
  active?: boolean;
59
61
  onClick?: (item: ToolbarItemProps) => void;
60
62
  className?: string;
61
- noTooltip?: boolean;
62
63
  isPopover?: boolean;
63
64
  tag?: ReactNode;
64
65
  tagProps?: Omit<TagProps, 'children'>;
@@ -140,11 +141,11 @@ Toolbar.Item = function ToolbarItem(props: ToolbarItemProps) {
140
141
  active = false,
141
142
  icon,
142
143
  onClick,
143
- title,
144
+ tooltip,
145
+ tooltipProps,
144
146
  id,
145
147
  intent: itemIntent,
146
148
  disabled: itemDisabled,
147
- noTooltip = false,
148
149
  isPopover,
149
150
  ...other
150
151
  } = props;
@@ -165,6 +166,7 @@ Toolbar.Item = function ToolbarItem(props: ToolbarItemProps) {
165
166
  ? `${icon.props.className} bp5-icon`
166
167
  : 'bp5-icon',
167
168
  });
169
+
168
170
  return (
169
171
  <Button
170
172
  alignText={isPopover ? 'left' : undefined}
@@ -213,13 +215,15 @@ Toolbar.Item = function ToolbarItem(props: ToolbarItemProps) {
213
215
  onClick?.(props);
214
216
  }}
215
217
  tooltipProps={
216
- noTooltip
218
+ !tooltip
217
219
  ? undefined
218
220
  : {
219
- content: title,
221
+ content: tooltip,
220
222
  placement: vertical ? 'right' : 'bottom',
221
223
  intent,
222
224
  compact: !large,
225
+ interactionKind: 'hover',
226
+ ...tooltipProps,
223
227
  }
224
228
  }
225
229
  {...other}
@@ -256,7 +260,7 @@ Toolbar.PopoverItem = function ToolbarPopoverItem(
256
260
  }}
257
261
  {...other}
258
262
  >
259
- <Toolbar.Item noTooltip isPopover {...itemProps} />
263
+ <Toolbar.Item isPopover {...itemProps} />
260
264
  </Popover>
261
265
  );
262
266
  };
@@ -1,18 +0,0 @@
1
- import { FunctionComponent, ComponentType } from 'react';
2
- declare const layoutComponents: ComponentsMap;
3
- type ComponentsMap = Record<string, ComponentType<any>>;
4
- interface LayoutManagerProps {
5
- layout: Layout;
6
- components?: ComponentsMap;
7
- }
8
- export interface Layout {
9
- layout: LayoutComponent | any;
10
- }
11
- interface LayoutComponent {
12
- id: string;
13
- component: keyof typeof layoutComponents | FunctionComponent;
14
- children?: LayoutComponent[];
15
- }
16
- export declare function LayoutManager(props: LayoutManagerProps): JSX.Element | null;
17
- export {};
18
- //# sourceMappingURL=LayoutManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LayoutManager.d.ts","sourceRoot":"","sources":["../../../src/components/layout-manager/LayoutManager.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,iBAAiB,EACjB,aAAa,EAEd,MAAM,OAAO,CAAC;AAMf,QAAA,MAAM,gBAAgB,EAAE,aAIvB,CAAC;AAEF,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;AAExD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B;AAED,MAAM,WAAW,MAAM;IAErB,MAAM,EAAE,eAAe,GAAG,GAAG,CAAC;CAC/B;AACD,UAAU,eAAe;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,OAAO,gBAAgB,GAAG,iBAAiB,CAAC;IAC7D,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,sBAGtD"}
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LayoutManager = void 0;
4
- const uuid_1 = require("@lukeed/uuid");
5
- const react_1 = require("react");
6
- const Accordion_1 = require("../accordion/Accordion");
7
- const DropZone_1 = require("../drop-zone/DropZone");
8
- const SplitPane_1 = require("../split-pane/SplitPane");
9
- const layoutComponents = {
10
- SplitPane: SplitPane_1.SplitPane,
11
- Accordion: Accordion_1.Accordion,
12
- DropZone: DropZone_1.DropZone,
13
- };
14
- function LayoutManager(props) {
15
- const { layout, components } = props;
16
- return createLayout(layout, components);
17
- }
18
- exports.LayoutManager = LayoutManager;
19
- function createLayoutComponent(com, components, props = {}) {
20
- const { id, component, children, ...compProps } = com;
21
- const componentId = id || (0, uuid_1.v4)();
22
- const componentNode = findComponent(component, components);
23
- if (componentNode) {
24
- const componentProps = { id: componentId, ...compProps, ...props };
25
- const childrenComp = children && typeof children === 'string'
26
- ? children
27
- : createElements(children, components);
28
- return (0, react_1.createElement)(componentNode,
29
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
- componentProps, childrenComp);
31
- }
32
- return null;
33
- }
34
- function createLayout(layout, components) {
35
- return createLayoutComponent(layout.layout, components);
36
- }
37
- function createElements(children, components) {
38
- return children?.map((comp, index) => createLayoutComponent(comp, components, { key: index }));
39
- }
40
- function findComponent(component, definedComponents) {
41
- if (typeof component === 'function')
42
- return component;
43
- if (typeof component === 'string') {
44
- if (definedComponents?.[component])
45
- return definedComponents[component];
46
- if (layoutComponents[component])
47
- return layoutComponents[component];
48
- }
49
- return null;
50
- }
51
- //# sourceMappingURL=LayoutManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LayoutManager.js","sourceRoot":"","sources":["../../../src/components/layout-manager/LayoutManager.tsx"],"names":[],"mappings":";;;AAAA,uCAA0C;AAC1C,iCAKe;AAEf,sDAAmD;AACnD,oDAAiD;AACjD,uDAAoD;AAEpD,MAAM,gBAAgB,GAAkB;IACtC,SAAS,EAAT,qBAAS;IACT,SAAS,EAAT,qBAAS;IACT,QAAQ,EAAR,mBAAQ;CACT,CAAC;AAmBF,SAAgB,aAAa,CAAC,KAAyB;IACrD,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IACrC,OAAO,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC1C,CAAC;AAHD,sCAGC;AAED,SAAS,qBAAqB,CAC5B,GAAoB,EACpB,UAA4C,EAC5C,KAAK,GAAG,EAAE;IAEV,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,GAAG,CAAC;IACtD,MAAM,WAAW,GAAG,EAAE,IAAI,IAAA,SAAI,GAAE,CAAC;IACjC,MAAM,aAAa,GAAG,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAE3D,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,cAAc,GAAG,EAAE,EAAE,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,EAAE,CAAC;QACnE,MAAM,YAAY,GAChB,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;YACtC,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAE3C,OAAO,IAAA,qBAAa,EAClB,aAAa;QACb,8DAA8D;QAC9D,cAAqB,EACrB,YAAY,CACb,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CACnB,MAAc,EACd,UAA4C;IAE5C,OAAO,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,cAAc,CACrB,QAAuC,EACvC,UAA4C;IAE5C,OAAO,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACnC,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CACxD,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CACpB,SAAuC,EACvC,iBAAmD;IAEnD,IAAI,OAAO,SAAS,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IAEtD,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,IAAI,iBAAiB,EAAE,CAAC,SAAS,CAAC;YAAE,OAAO,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACxE,IAAI,gBAAgB,CAAC,SAAS,CAAC;YAAE,OAAO,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './LayoutManager';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/layout-manager/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./LayoutManager"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/layout-manager/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC"}
@@ -1,18 +0,0 @@
1
- import { FunctionComponent, ComponentType } from 'react';
2
- declare const layoutComponents: ComponentsMap;
3
- type ComponentsMap = Record<string, ComponentType<any>>;
4
- interface LayoutManagerProps {
5
- layout: Layout;
6
- components?: ComponentsMap;
7
- }
8
- export interface Layout {
9
- layout: LayoutComponent | any;
10
- }
11
- interface LayoutComponent {
12
- id: string;
13
- component: keyof typeof layoutComponents | FunctionComponent;
14
- children?: LayoutComponent[];
15
- }
16
- export declare function LayoutManager(props: LayoutManagerProps): JSX.Element | null;
17
- export {};
18
- //# sourceMappingURL=LayoutManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LayoutManager.d.ts","sourceRoot":"","sources":["../../../src/components/layout-manager/LayoutManager.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,iBAAiB,EACjB,aAAa,EAEd,MAAM,OAAO,CAAC;AAMf,QAAA,MAAM,gBAAgB,EAAE,aAIvB,CAAC;AAEF,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;AAExD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B;AAED,MAAM,WAAW,MAAM;IAErB,MAAM,EAAE,eAAe,GAAG,GAAG,CAAC;CAC/B;AACD,UAAU,eAAe;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,OAAO,gBAAgB,GAAG,iBAAiB,CAAC;IAC7D,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,sBAGtD"}
@@ -1,47 +0,0 @@
1
- import { v4 as uuid } from '@lukeed/uuid';
2
- import { createElement, } from 'react';
3
- import { Accordion } from '../accordion/Accordion';
4
- import { DropZone } from '../drop-zone/DropZone';
5
- import { SplitPane } from '../split-pane/SplitPane';
6
- const layoutComponents = {
7
- SplitPane,
8
- Accordion,
9
- DropZone,
10
- };
11
- export function LayoutManager(props) {
12
- const { layout, components } = props;
13
- return createLayout(layout, components);
14
- }
15
- function createLayoutComponent(com, components, props = {}) {
16
- const { id, component, children, ...compProps } = com;
17
- const componentId = id || uuid();
18
- const componentNode = findComponent(component, components);
19
- if (componentNode) {
20
- const componentProps = { id: componentId, ...compProps, ...props };
21
- const childrenComp = children && typeof children === 'string'
22
- ? children
23
- : createElements(children, components);
24
- return createElement(componentNode,
25
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- componentProps, childrenComp);
27
- }
28
- return null;
29
- }
30
- function createLayout(layout, components) {
31
- return createLayoutComponent(layout.layout, components);
32
- }
33
- function createElements(children, components) {
34
- return children?.map((comp, index) => createLayoutComponent(comp, components, { key: index }));
35
- }
36
- function findComponent(component, definedComponents) {
37
- if (typeof component === 'function')
38
- return component;
39
- if (typeof component === 'string') {
40
- if (definedComponents?.[component])
41
- return definedComponents[component];
42
- if (layoutComponents[component])
43
- return layoutComponents[component];
44
- }
45
- return null;
46
- }
47
- //# sourceMappingURL=LayoutManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LayoutManager.js","sourceRoot":"","sources":["../../../src/components/layout-manager/LayoutManager.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,aAAa,GAId,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,gBAAgB,GAAkB;IACtC,SAAS;IACT,SAAS;IACT,QAAQ;CACT,CAAC;AAmBF,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IACrC,OAAO,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,qBAAqB,CAC5B,GAAoB,EACpB,UAA4C,EAC5C,KAAK,GAAG,EAAE;IAEV,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,GAAG,CAAC;IACtD,MAAM,WAAW,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC;IACjC,MAAM,aAAa,GAAG,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAE3D,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,cAAc,GAAG,EAAE,EAAE,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,EAAE,CAAC;QACnE,MAAM,YAAY,GAChB,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;YACtC,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAE3C,OAAO,aAAa,CAClB,aAAa;QACb,8DAA8D;QAC9D,cAAqB,EACrB,YAAY,CACb,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CACnB,MAAc,EACd,UAA4C;IAE5C,OAAO,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,cAAc,CACrB,QAAuC,EACvC,UAA4C;IAE5C,OAAO,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACnC,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CACxD,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CACpB,SAAuC,EACvC,iBAAmD;IAEnD,IAAI,OAAO,SAAS,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IAEtD,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,IAAI,iBAAiB,EAAE,CAAC,SAAS,CAAC;YAAE,OAAO,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACxE,IAAI,gBAAgB,CAAC,SAAS,CAAC;YAAE,OAAO,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './LayoutManager';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/layout-manager/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './LayoutManager';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/layout-manager/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -1,95 +0,0 @@
1
- import { v4 as uuid } from '@lukeed/uuid';
2
- import {
3
- createElement,
4
- FunctionComponent,
5
- ComponentType,
6
- ReactNode,
7
- } from 'react';
8
-
9
- import { Accordion } from '../accordion/Accordion';
10
- import { DropZone } from '../drop-zone/DropZone';
11
- import { SplitPane } from '../split-pane/SplitPane';
12
-
13
- const layoutComponents: ComponentsMap = {
14
- SplitPane,
15
- Accordion,
16
- DropZone,
17
- };
18
-
19
- type ComponentsMap = Record<string, ComponentType<any>>;
20
-
21
- interface LayoutManagerProps {
22
- layout: Layout;
23
- components?: ComponentsMap;
24
- }
25
-
26
- export interface Layout {
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- layout: LayoutComponent | any;
29
- }
30
- interface LayoutComponent {
31
- id: string;
32
- component: keyof typeof layoutComponents | FunctionComponent;
33
- children?: LayoutComponent[];
34
- }
35
-
36
- export function LayoutManager(props: LayoutManagerProps) {
37
- const { layout, components } = props;
38
- return createLayout(layout, components);
39
- }
40
-
41
- function createLayoutComponent(
42
- com: LayoutComponent,
43
- components: LayoutManagerProps['components'],
44
- props = {},
45
- ): JSX.Element | null {
46
- const { id, component, children, ...compProps } = com;
47
- const componentId = id || uuid();
48
- const componentNode = findComponent(component, components);
49
-
50
- if (componentNode) {
51
- const componentProps = { id: componentId, ...compProps, ...props };
52
- const childrenComp =
53
- children && typeof children === 'string'
54
- ? children
55
- : createElements(children, components);
56
-
57
- return createElement(
58
- componentNode,
59
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
- componentProps as any,
61
- childrenComp,
62
- );
63
- }
64
- return null;
65
- }
66
-
67
- function createLayout(
68
- layout: Layout,
69
- components: LayoutManagerProps['components'],
70
- ) {
71
- return createLayoutComponent(layout.layout, components);
72
- }
73
-
74
- function createElements(
75
- children: LayoutComponent[] | undefined,
76
- components: LayoutManagerProps['components'],
77
- ): ReactNode[] | undefined {
78
- return children?.map((comp, index) =>
79
- createLayoutComponent(comp, components, { key: index }),
80
- );
81
- }
82
-
83
- function findComponent(
84
- component: LayoutComponent['component'],
85
- definedComponents: LayoutManagerProps['components'],
86
- ): ComponentType<any> | null {
87
- if (typeof component === 'function') return component;
88
-
89
- if (typeof component === 'string') {
90
- if (definedComponents?.[component]) return definedComponents[component];
91
- if (layoutComponents[component]) return layoutComponents[component];
92
- }
93
-
94
- return null;
95
- }
@@ -1 +0,0 @@
1
- export * from './LayoutManager';