@vuu-ui/vuu-layout 0.5.4 → 0.5.6

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 (147) hide show
  1. package/README.md +1 -0
  2. package/cjs/index.js +4 -7379
  3. package/cjs/index.js.map +7 -0
  4. package/esm/index.js +20 -0
  5. package/esm/index.js.map +7 -0
  6. package/index.css +1 -951
  7. package/index.css.map +3 -3
  8. package/package.json +5 -9
  9. package/src/Component.css +0 -2
  10. package/src/Component.tsx +0 -20
  11. package/src/DraggableLayout.css +0 -18
  12. package/src/DraggableLayout.tsx +0 -29
  13. package/src/__tests__/flexbox-utils.spec.js +0 -90
  14. package/src/action-buttons/index.ts +0 -1
  15. package/src/chest-of-drawers/Chest.css +0 -36
  16. package/src/chest-of-drawers/Chest.tsx +0 -42
  17. package/src/chest-of-drawers/Drawer.css +0 -159
  18. package/src/chest-of-drawers/Drawer.tsx +0 -118
  19. package/src/chest-of-drawers/index.ts +0 -2
  20. package/src/common-types.ts +0 -9
  21. package/src/debug.ts +0 -16
  22. package/src/dialog/Dialog.css +0 -16
  23. package/src/dialog/Dialog.tsx +0 -59
  24. package/src/dialog/index.ts +0 -1
  25. package/src/drag-drop/BoxModel.ts +0 -546
  26. package/src/drag-drop/DragState.ts +0 -222
  27. package/src/drag-drop/Draggable.ts +0 -282
  28. package/src/drag-drop/DropMenu.css +0 -71
  29. package/src/drag-drop/DropMenu.tsx +0 -61
  30. package/src/drag-drop/DropTarget.ts +0 -392
  31. package/src/drag-drop/DropTargetRenderer.css +0 -40
  32. package/src/drag-drop/DropTargetRenderer.tsx +0 -279
  33. package/src/drag-drop/dragDropTypes.ts +0 -49
  34. package/src/drag-drop/index.ts +0 -4
  35. package/src/editable-label/EditableLabel.css +0 -28
  36. package/src/editable-label/EditableLabel.tsx +0 -99
  37. package/src/editable-label/index.ts +0 -1
  38. package/src/flexbox/Flexbox.css +0 -45
  39. package/src/flexbox/Flexbox.tsx +0 -70
  40. package/src/flexbox/FlexboxLayout.jsx +0 -26
  41. package/src/flexbox/FluidGrid.css +0 -134
  42. package/src/flexbox/FluidGrid.tsx +0 -84
  43. package/src/flexbox/FluidGridLayout.tsx +0 -10
  44. package/src/flexbox/Splitter.css +0 -140
  45. package/src/flexbox/Splitter.tsx +0 -135
  46. package/src/flexbox/flexbox-utils.ts +0 -128
  47. package/src/flexbox/flexboxTypes.ts +0 -63
  48. package/src/flexbox/index.ts +0 -4
  49. package/src/flexbox/useResponsiveSizing.ts +0 -85
  50. package/src/flexbox/useSplitterResizing.ts +0 -272
  51. package/src/index.ts +0 -21
  52. package/src/layout-action.ts +0 -21
  53. package/src/layout-header/ActionButton.tsx +0 -23
  54. package/src/layout-header/Header.css +0 -8
  55. package/src/layout-header/Header.tsx +0 -222
  56. package/src/layout-header/index.ts +0 -1
  57. package/src/layout-provider/LayoutProvider.tsx +0 -160
  58. package/src/layout-provider/LayoutProviderContext.ts +0 -17
  59. package/src/layout-provider/index.ts +0 -2
  60. package/src/layout-provider/useLayoutDragDrop.ts +0 -241
  61. package/src/layout-reducer/flexUtils.ts +0 -281
  62. package/src/layout-reducer/index.ts +0 -4
  63. package/src/layout-reducer/insert-layout-element.ts +0 -365
  64. package/src/layout-reducer/layout-reducer.ts +0 -255
  65. package/src/layout-reducer/layoutTypes.ts +0 -151
  66. package/src/layout-reducer/layoutUtils.ts +0 -302
  67. package/src/layout-reducer/remove-layout-element.ts +0 -240
  68. package/src/layout-reducer/replace-layout-element.ts +0 -118
  69. package/src/layout-reducer/resize-flex-children.ts +0 -56
  70. package/src/layout-reducer/wrap-layout-element.ts +0 -317
  71. package/src/layout-view/View.css +0 -61
  72. package/src/layout-view/View.tsx +0 -149
  73. package/src/layout-view/ViewContext.ts +0 -31
  74. package/src/layout-view/index.ts +0 -4
  75. package/src/layout-view/useView.tsx +0 -104
  76. package/src/layout-view/useViewActionDispatcher.ts +0 -133
  77. package/src/layout-view/useViewResize.ts +0 -53
  78. package/src/layout-view/viewTypes.ts +0 -37
  79. package/src/menu/ContextMenu.css +0 -22
  80. package/src/menu/ContextMenu.jsx +0 -121
  81. package/src/menu/MenuList.css +0 -150
  82. package/src/menu/MenuList.jsx +0 -179
  83. package/src/menu/aim/aim.js +0 -92
  84. package/src/menu/aim/corners.js +0 -114
  85. package/src/menu/aim/point-in-polygon.js +0 -25
  86. package/src/menu/aim/utils.js +0 -19
  87. package/src/menu/context-menu-provider.jsx +0 -135
  88. package/src/menu/index.js +0 -4
  89. package/src/menu/key-code.js +0 -61
  90. package/src/menu/list-dom-utils.js +0 -22
  91. package/src/menu/use-cascade.js +0 -292
  92. package/src/menu/use-click-away.js +0 -22
  93. package/src/menu/use-items-with-ids.js +0 -75
  94. package/src/menu/use-keyboard-navigation.js +0 -162
  95. package/src/menu/utils.js +0 -5
  96. package/src/palette/Palette.css +0 -37
  97. package/src/palette/Palette.tsx +0 -140
  98. package/src/palette/PaletteSalt.css +0 -9
  99. package/src/palette/PaletteSalt.tsx +0 -79
  100. package/src/palette/index.ts +0 -2
  101. package/src/placeholder/Placeholder.css +0 -10
  102. package/src/placeholder/Placeholder.tsx +0 -39
  103. package/src/placeholder/index.ts +0 -1
  104. package/src/popup/index.js +0 -2
  105. package/src/popup/popup-provider.js +0 -0
  106. package/src/popup/popup-service.css +0 -15
  107. package/src/popup/popup-service.js +0 -281
  108. package/src/portal/Portal.jsx +0 -50
  109. package/src/portal/index.ts +0 -3
  110. package/src/portal/render-portal.jsx +0 -68
  111. package/src/portal/utils.js +0 -16
  112. package/src/registry/ComponentRegistry.ts +0 -35
  113. package/src/registry/index.ts +0 -1
  114. package/src/responsive/OverflowMenu.css +0 -31
  115. package/src/responsive/OverflowMenu.jsx +0 -56
  116. package/src/responsive/breakpoints.ts +0 -62
  117. package/src/responsive/index.ts +0 -4
  118. package/src/responsive/measureMinimumNodeSize.ts +0 -23
  119. package/src/responsive/overflowUtils.js +0 -14
  120. package/src/responsive/use-breakpoints.ts +0 -100
  121. package/src/responsive/useOverflowObserver.ts +0 -606
  122. package/src/responsive/useResizeObserver.ts +0 -154
  123. package/src/responsive/utils.ts +0 -37
  124. package/src/stack/Stack.css +0 -39
  125. package/src/stack/Stack.tsx +0 -161
  126. package/src/stack/StackLayout.tsx +0 -137
  127. package/src/stack/index.ts +0 -3
  128. package/src/stack/stackTypes.ts +0 -19
  129. package/src/tabs/TabPanel.css +0 -12
  130. package/src/tabs/TabPanel.tsx +0 -17
  131. package/src/tabs/index.ts +0 -1
  132. package/src/tools/config-wrapper/ConfigWrapper.jsx +0 -53
  133. package/src/tools/config-wrapper/index.js +0 -1
  134. package/src/tools/devtools-box/layout-configurator.css +0 -112
  135. package/src/tools/devtools-box/layout-configurator.jsx +0 -369
  136. package/src/tools/devtools-tree/layout-tree-viewer.css +0 -15
  137. package/src/tools/devtools-tree/layout-tree-viewer.jsx +0 -36
  138. package/src/tools/index.js +0 -3
  139. package/src/use-persistent-state.ts +0 -115
  140. package/src/utils/apply-handlers.js +0 -15
  141. package/src/utils/componentFromLayout.tsx +0 -30
  142. package/src/utils/index.ts +0 -6
  143. package/src/utils/pathUtils.ts +0 -294
  144. package/src/utils/propUtils.ts +0 -24
  145. package/src/utils/refUtils.ts +0 -16
  146. package/src/utils/styleUtils.ts +0 -14
  147. package/src/utils/typeOf.ts +0 -22
@@ -1,140 +0,0 @@
1
- import { List, ListItem, ListItemProps } from "@heswell/salt-lab";
2
- import { uuid } from "@vuu-ui/vuu-utils";
3
- import cx from "classnames";
4
- import {
5
- cloneElement,
6
- HTMLAttributes,
7
- memo,
8
- MouseEvent,
9
- ReactElement,
10
- } from "react";
11
- import { useLayoutProviderDispatch } from "../layout-provider";
12
- import { View } from "../layout-view";
13
- import { registerComponent } from "../registry/ComponentRegistry";
14
-
15
- import "./Palette.css";
16
-
17
- const clonePaletteItem = (paletteItem: HTMLElement) => {
18
- const dolly = paletteItem.cloneNode(true) as HTMLElement;
19
- dolly.id = "";
20
- delete dolly.dataset.idx;
21
- return dolly;
22
- };
23
-
24
- export interface PaletteItemProps extends ListItemProps {
25
- children: ReactElement;
26
- closeable?: boolean;
27
- header?: boolean;
28
- idx?: number;
29
- resize?: "defer";
30
- resizeable?: boolean;
31
- }
32
-
33
- export const PaletteItem = memo(
34
- ({
35
- className,
36
- children: component,
37
- idx,
38
- resizeable,
39
- header,
40
- closeable,
41
- ...props
42
- }: PaletteItemProps) => {
43
- return (
44
- <ListItem
45
- className={cx("vuuPaletteItem", className)}
46
- data-icon="grab-handle"
47
- {...props}
48
- />
49
- );
50
- }
51
- );
52
-
53
- PaletteItem.displayName = "PaletteItem";
54
-
55
- export interface PaletteProps
56
- extends Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> {
57
- children: ReactElement[];
58
- orientation: "horizontal" | "vertical";
59
- selection?: string;
60
- }
61
-
62
- export const Palette = ({
63
- children,
64
- className,
65
- orientation = "horizontal",
66
- ...props
67
- }: PaletteProps) => {
68
- const dispatch = useLayoutProviderDispatch();
69
- const classBase = "vuuPalette";
70
-
71
- function handleMouseDown(evt: MouseEvent) {
72
- const target = evt.target as HTMLElement;
73
- const listItemElement = target.closest(".vuuPaletteItem") as HTMLElement;
74
- const idx = parseInt(listItemElement.dataset.idx ?? "-1");
75
- if (idx !== -1) {
76
- console.log({
77
- children,
78
- idx,
79
- listItemElement,
80
- });
81
- }
82
- const {
83
- props: { caption, children: payload, template, ...props },
84
- } = children[idx];
85
- const { height, left, top, width } =
86
- listItemElement.getBoundingClientRect();
87
- const id = uuid();
88
- const identifiers = { id, key: id };
89
- const component = template ? (
90
- payload
91
- ) : (
92
- <View {...identifiers} {...props} title={props.label}>
93
- {payload}
94
- </View>
95
- );
96
-
97
- dispatch({
98
- dragRect: {
99
- left,
100
- top,
101
- right: left + width,
102
- bottom: top + 150,
103
- width,
104
- height,
105
- },
106
- dragElement: clonePaletteItem(listItemElement),
107
- evt: evt.nativeEvent,
108
- instructions: {
109
- DoNotRemove: true,
110
- DoNotTransform: true,
111
- RemoveDraggableOnDragEnd: true,
112
- dragThreshold: 10,
113
- },
114
- path: "*",
115
- payload: component,
116
- type: "drag-start",
117
- });
118
- }
119
-
120
- return (
121
- <List
122
- {...props}
123
- borderless
124
- className={cx(classBase, className, `${classBase}-${orientation}`)}
125
- maxHeight={800}
126
- selected={null}
127
- >
128
- {children.map((child, idx) =>
129
- child.type === PaletteItem
130
- ? cloneElement(child, {
131
- key: idx,
132
- onMouseDown: handleMouseDown,
133
- })
134
- : child
135
- )}
136
- </List>
137
- );
138
- };
139
-
140
- registerComponent("Palette", Palette, "view");
@@ -1,9 +0,0 @@
1
- .vuuPalette {
2
- --list-item-header-bg: inherit;
3
- --list-item-header-color: inherit;
4
- --list-item-padding: 0 6px 0 24px;
5
- --list-item-header-twisty-color: black;
6
- --list-item-header-twisty-left: 3px;
7
- --list-item-header-twisty-right: auto;
8
- }
9
-
@@ -1,79 +0,0 @@
1
- import { List, ListItem, ListItemProps, ListProps } from "@heswell/salt-lab";
2
- import { uuid } from "@vuu-ui/vuu-utils";
3
- import cx from "classnames";
4
- import { MouseEvent, ReactElement } from "react";
5
- import { useLayoutProviderDispatch } from "../layout-provider";
6
- import { View } from "../layout-view";
7
- import { registerComponent } from "../registry/ComponentRegistry";
8
-
9
- import "./PaletteSalt.css";
10
-
11
- const classBase = "vuuPalette";
12
-
13
- export interface PaletteListItemProps extends ListItemProps {
14
- children: ReactElement;
15
- ViewProps: {
16
- header?: boolean;
17
- closeable?: boolean;
18
- resizeable?: boolean;
19
- };
20
- template: boolean;
21
- }
22
-
23
- export const PaletteListItem = (props: PaletteListItemProps) => {
24
- const { children, ViewProps, label, onMouseDown, template, ...restProps } =
25
- props;
26
- const dispatch = useLayoutProviderDispatch();
27
-
28
- const handleMouseDown = (evt: MouseEvent<HTMLDivElement>) => {
29
- const { left, top, width } = evt.currentTarget.getBoundingClientRect();
30
- const id = uuid();
31
- const identifiers = { id, key: id };
32
- const component = template ? (
33
- children
34
- ) : (
35
- <View {...identifiers} {...ViewProps} title={props.label}>
36
- {children}
37
- </View>
38
- );
39
-
40
- dispatch({
41
- type: "drag-start",
42
- evt: evt.nativeEvent,
43
- path: "*",
44
- payload: component,
45
- instructions: {
46
- DoNotRemove: true,
47
- DoNotTransform: true,
48
- RemoveDraggableOnDragEnd: true,
49
- dragThreshold: 10,
50
- },
51
- dragRect: {
52
- left,
53
- top,
54
- right: left + width,
55
- bottom: top + 150,
56
- width,
57
- height: 100,
58
- },
59
- });
60
- };
61
- return (
62
- <ListItem onMouseDown={handleMouseDown} {...restProps}>
63
- {label}
64
- </ListItem>
65
- );
66
- };
67
-
68
- export const PaletteSalt = ({ className, ...props }: ListProps) => {
69
- return (
70
- <List
71
- {...props}
72
- className={cx(classBase, className)}
73
- height="100%"
74
- selectionStrategy="none"
75
- />
76
- );
77
- };
78
-
79
- registerComponent("PaletteSalt", PaletteSalt, "view");
@@ -1,2 +0,0 @@
1
- export * from "./Palette";
2
- export * from "./PaletteSalt";
@@ -1,10 +0,0 @@
1
- .vuuPlaceholder {
2
- flex-basis: 0;
3
- flex-grow: 1;
4
- flex-shrink: 1;
5
- }
6
-
7
- .vuuPlaceholder-shim {
8
- flex-grow: 0;
9
- flex-shrink: 0;
10
- }
@@ -1,39 +0,0 @@
1
- import React, { HTMLAttributes } from "react";
2
- import cx from "classnames";
3
- import { registerComponent } from "../registry/ComponentRegistry";
4
-
5
- import "./Placeholder.css";
6
-
7
- const classBase = "vuuPlaceholder";
8
-
9
- export interface PlaceholderProps extends HTMLAttributes<HTMLDivElement> {
10
- closeable?: boolean;
11
- flexFill?: boolean;
12
- resizeable?: boolean;
13
- shim?: boolean;
14
- }
15
-
16
- export const Placeholder = ({
17
- className,
18
- closeable,
19
- flexFill,
20
- resizeable,
21
- shim,
22
- ...props
23
- }: PlaceholderProps) => {
24
- return (
25
- <div
26
- className={cx(classBase, className, {
27
- [`${classBase}-shim`]: shim,
28
- })}
29
- {...props}
30
- data-placeholder
31
- data-resizeable
32
- >
33
- {/* <LayoutProviderVersion /> */}
34
- </div>
35
- );
36
- };
37
-
38
- Placeholder.displayName = "Placeholder";
39
- registerComponent("Placeholder", Placeholder);
@@ -1 +0,0 @@
1
- export * from './Placeholder';
@@ -1,2 +0,0 @@
1
- export * from './popup-provider';
2
- export * from './popup-service';
File without changes
@@ -1,15 +0,0 @@
1
- .hwReactDialog,
2
- .hwReactPopup {
3
- box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
4
- position: absolute;
5
- top: 0;
6
- left: 0;
7
- width: 0;
8
- height: 0;
9
- overflow: visible;
10
- z-index: 1000;
11
- }
12
-
13
- .hwPopup {
14
- position: absolute;
15
- }
@@ -1,281 +0,0 @@
1
- import React, { createElement, useEffect, useRef } from "react";
2
- import ReactDOM from "react-dom";
3
- import { renderPortal } from "../portal";
4
- import cx from "classnames";
5
-
6
- import "./popup-service.css";
7
- window.popupReact = React;
8
-
9
- let _dialogOpen = false;
10
- const _popups = [];
11
-
12
- function specialKeyHandler(e) {
13
- if (e.keyCode === 27 /* ESC */) {
14
- if (_popups.length) {
15
- closeAllPopups();
16
- } else if (_dialogOpen) {
17
- ReactDOM.unmountComponentAtNode(
18
- document.body.querySelector(".hwReactDialog")
19
- );
20
- }
21
- }
22
- }
23
-
24
- function outsideClickHandler(e) {
25
- if (_popups.length) {
26
- // onsole.log(`Popup.outsideClickHandler`);
27
- const popupContainers = document.body.querySelectorAll(".hwReactPopup");
28
- for (let i = 0; i < popupContainers.length; i++) {
29
- if (popupContainers[i].contains(e.target)) {
30
- return;
31
- }
32
- }
33
- closeAllPopups();
34
- }
35
- }
36
-
37
- function closeAllPopups() {
38
- if (_popups.length) {
39
- // onsole.log(`closeAllPopups`);
40
- const popupContainers = document.body.querySelectorAll(".hwReactPopup");
41
- for (let i = 0; i < popupContainers.length; i++) {
42
- ReactDOM.unmountComponentAtNode(popupContainers[i]);
43
- }
44
- popupClosed("*");
45
- }
46
- }
47
-
48
- function dialogOpened() {
49
- if (_dialogOpen === false) {
50
- _dialogOpen = true;
51
- window.addEventListener("keydown", specialKeyHandler, true);
52
- }
53
- }
54
-
55
- function dialogClosed() {
56
- if (_dialogOpen) {
57
- _dialogOpen = false;
58
- window.removeEventListener("keydown", specialKeyHandler, true);
59
- }
60
- }
61
-
62
- function popupOpened(name /*, group*/) {
63
- if (_popups.indexOf(name) === -1) {
64
- _popups.push(name);
65
- //onsole.log('PopupService, popup opened ' + name + ' popups : ' + _popups);
66
- if (_dialogOpen === false) {
67
- window.addEventListener("keydown", specialKeyHandler, true);
68
- window.addEventListener("click", outsideClickHandler, true);
69
- }
70
- }
71
- }
72
-
73
- function popupClosed(name /*, group=null*/) {
74
- if (_popups.length) {
75
- if (name === "*") {
76
- _popups.length = 0;
77
- } else {
78
- const pos = _popups.indexOf(name);
79
- if (pos !== -1) {
80
- _popups.splice(pos, 1);
81
- }
82
- }
83
- //onsole.log('PopupService, popup closed ' + name + ' popups : ' + _popups);
84
- if (_popups.length === 0 && _dialogOpen === false) {
85
- window.removeEventListener("keydown", specialKeyHandler, true);
86
- window.removeEventListener("click", outsideClickHandler, true);
87
- }
88
- }
89
- }
90
-
91
- const PopupComponent = ({ children, position, style }) => {
92
- const className = cx("hwPopup", "hwPopupContainer", position);
93
- return createElement("div", { className, style }, children);
94
- };
95
-
96
- let incrementingKey = 1;
97
-
98
- export class PopupService {
99
- static showPopup({
100
- name = "anon",
101
- group = "all",
102
- position = "",
103
- left = 0,
104
- right = "auto",
105
- top = 0,
106
- width = "auto",
107
- component,
108
- }) {
109
- if (!component) {
110
- throw Error(`PopupService showPopup, no component supplied`);
111
- }
112
- popupOpened(name, group);
113
- let el = document.body.querySelector(".hwReactPopup." + group);
114
- if (el === null) {
115
- el = document.createElement("div");
116
- el.className = "hwReactPopup " + group;
117
- document.body.appendChild(el);
118
- }
119
-
120
- const style = { width };
121
-
122
- renderPortal(
123
- createElement(
124
- PopupComponent,
125
- { key: incrementingKey++, position, style },
126
- component
127
- ),
128
- el,
129
- left,
130
- top,
131
- () => {
132
- PopupService.keepWithinThePage(el, right);
133
- }
134
- );
135
- }
136
-
137
- static hidePopup(name = "anon", group = "all") {
138
- //onsole.log('PopupService.hidePopup name=' + name + ', group=' + group)
139
-
140
- if (_popups.indexOf(name) !== -1) {
141
- popupClosed(name, group);
142
- ReactDOM.unmountComponentAtNode(
143
- document.body.querySelector(`.hwReactPopup.${group}`)
144
- );
145
- }
146
- }
147
-
148
- static keepWithinThePage(el, right = "auto") {
149
- const target = el.querySelector(".hwPopupContainer > *");
150
- if (target) {
151
- const {
152
- top,
153
- left,
154
- width,
155
- height,
156
- right: currentRight,
157
- } = target.getBoundingClientRect();
158
-
159
- const w = window.innerWidth;
160
- const h = window.innerHeight;
161
-
162
- const overflowH = h - (top + height);
163
- if (overflowH < 0) {
164
- target.style.top = parseInt(top, 10) + overflowH + "px";
165
- }
166
-
167
- const overflowW = w - (left + width);
168
- if (overflowW < 0) {
169
- target.style.left = parseInt(left, 10) + overflowW + "px";
170
- }
171
-
172
- if (typeof right === "number" && right !== currentRight) {
173
- const adjustment = right - currentRight;
174
- target.style.left = left + adjustment + "px";
175
- }
176
- }
177
- }
178
- }
179
-
180
- export class DialogService {
181
- static showDialog(dialog) {
182
- const containerEl = ".hwReactDialog";
183
- const onClose = dialog.props.onClose;
184
-
185
- dialogOpened();
186
-
187
- ReactDOM.render(
188
- React.cloneElement(dialog, {
189
- container: containerEl,
190
- onClose: () => {
191
- DialogService.closeDialog();
192
- if (onClose) {
193
- onClose();
194
- }
195
- },
196
- }),
197
- document.body.querySelector(containerEl)
198
- );
199
- }
200
-
201
- static closeDialog() {
202
- dialogClosed();
203
- ReactDOM.unmountComponentAtNode(
204
- document.body.querySelector(".hwReactDialog")
205
- );
206
- }
207
- }
208
-
209
- export const Popup = (props) => {
210
- const pendingTask = useRef(null);
211
- const ref = useRef(null);
212
-
213
- const show = (props, boundingClientRect) => {
214
- const { name, group, depth, width } = props;
215
- let left, top;
216
-
217
- if (pendingTask.current) {
218
- clearTimeout(pendingTask.current);
219
- pendingTask.current = null;
220
- }
221
-
222
- if (props.close === true) {
223
- PopupService.hidePopup(name, group);
224
- } else {
225
- const { position, children: component } = props;
226
- const {
227
- left: targetLeft,
228
- top: targetTop,
229
- width: clientWidth,
230
- bottom: targetBottom,
231
- } = boundingClientRect;
232
-
233
- if (position === "below") {
234
- left = targetLeft;
235
- top = targetBottom;
236
- } else if (position === "above") {
237
- left = targetLeft;
238
- top = targetTop;
239
- }
240
-
241
- pendingTask.current = setTimeout(() => {
242
- PopupService.showPopup({
243
- name,
244
- group,
245
- depth,
246
- position,
247
- left,
248
- top,
249
- width: width || clientWidth,
250
- component,
251
- });
252
- }, 10);
253
- }
254
- };
255
-
256
- useEffect(() => {
257
- if (ref.current) {
258
- const el = ref.current.parentElement;
259
- const boundingClientRect = el.getBoundingClientRect();
260
- //onsole.log(`%cPopup.componentDidMount about to call show`,'color:green');
261
- show(props, boundingClientRect);
262
- }
263
-
264
- return () => {
265
- PopupService.hidePopup(props.name, props.group);
266
- };
267
- }, [props]);
268
-
269
- return React.createElement("div", { className: "popup-proxy", ref });
270
-
271
- // componentWillReceiveProps(nextProps) {
272
-
273
- // const domNode = ReactDOM.findDOMNode(this);
274
- // if (domNode) {
275
- // const el = domNode.parentElement;
276
- // const boundingClientRect = el.getBoundingClientRect();
277
- // //onsole.log(`%cPopup.componentWillReceiveProps about to call show`,'color:green');
278
- // this.show(nextProps, boundingClientRect);
279
- // }
280
- // }
281
- };
@@ -1,50 +0,0 @@
1
- import { useLayoutEffect, useMemo } from 'react';
2
- import * as ReactDOM from 'react-dom';
3
- import { createContainer, renderPortal } from './render-portal';
4
-
5
- export const Portal = function Portal(props) {
6
- // Do we need to accept container here as a prop ?
7
- const { children, x, y, onRender } = props;
8
- let renderContainer = useMemo(() => {
9
- return createContainer();
10
- }, []);
11
-
12
- // console.log(`Portal render x ${x} y ${y}`);
13
-
14
- // useEffect(() => {
15
- // console.log(`Portal mounted`);
16
- // return () => {
17
- // console.log('Portal unmounted');
18
- // };
19
- // }, []);
20
-
21
- useLayoutEffect(() => {
22
- renderPortal(children, renderContainer, x, y, onRender);
23
- }, [children, onRender, renderContainer, x, y]);
24
-
25
- useLayoutEffect(() => {
26
- return () => {
27
- if (renderContainer) {
28
- ReactDOM.unmountComponentAtNode(renderContainer);
29
- if (renderContainer.classList.contains('hwReactPopup')) {
30
- renderContainer.parentElement.removeChild(renderContainer);
31
- }
32
- }
33
- };
34
- }, [renderContainer]);
35
-
36
- // useLayoutEffect(() => {
37
- // renderContainer.current = renderPortal(children, x, y, container)
38
- // return () => {
39
- // if (renderContainer.current){
40
- // console.log('EXPLICIT UNMOUNT')
41
- // ReactDOM.unmountComponentAtNode(renderContainer.current);
42
- // if (renderContainer.current.classList.contains('hwReactPopup')){
43
- // renderContainer.current.parentElement.removeChild(renderContainer.current);
44
- // renderContainer.current = null;
45
- // }
46
- // }
47
- // }
48
- // },[])
49
- return null;
50
- };
@@ -1,3 +0,0 @@
1
- export * from "./Portal";
2
- export * from "./render-portal";
3
- export * from "./utils";