@linzjs/windows 10.3.1 → 11.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.
Files changed (223) hide show
  1. package/dist/LuiModalAsync/LuiModalAsync.d.ts +14 -0
  2. package/dist/LuiModalAsync/LuiModalAsync.js +45 -0
  3. package/dist/LuiModalAsync/LuiModalAsync.js.map +1 -0
  4. package/dist/LuiModalAsync/LuiModalAsync.scss +1 -2
  5. package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.d.ts +19 -0
  6. package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.js +27 -0
  7. package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.js.map +1 -0
  8. package/dist/LuiModalAsync/LuiModalAsyncContent.d.ts +6 -0
  9. package/dist/LuiModalAsync/LuiModalAsyncContent.js +7 -0
  10. package/dist/LuiModalAsync/LuiModalAsyncContent.js.map +1 -0
  11. package/dist/LuiModalAsync/LuiModalAsyncContext.d.ts +28 -0
  12. package/dist/LuiModalAsync/LuiModalAsyncContext.js +9 -0
  13. package/dist/LuiModalAsync/LuiModalAsyncContext.js.map +1 -0
  14. package/dist/LuiModalAsync/LuiModalAsyncContextProvider.d.ts +54 -0
  15. package/dist/LuiModalAsync/LuiModalAsyncContextProvider.js +160 -0
  16. package/dist/LuiModalAsync/LuiModalAsyncContextProvider.js.map +1 -0
  17. package/dist/LuiModalAsync/LuiModalAsyncHeader.d.ts +15 -0
  18. package/dist/LuiModalAsync/LuiModalAsyncHeader.js +23 -0
  19. package/dist/LuiModalAsync/LuiModalAsyncHeader.js.map +1 -0
  20. package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.d.ts +13 -0
  21. package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.js +13 -0
  22. package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.js.map +1 -0
  23. package/dist/LuiModalAsync/LuiModalAsyncMain.d.ts +5 -0
  24. package/dist/LuiModalAsync/LuiModalAsyncMain.js +6 -0
  25. package/dist/LuiModalAsync/LuiModalAsyncMain.js.map +1 -0
  26. package/dist/LuiModalAsync/index.js +12 -0
  27. package/dist/LuiModalAsync/index.js.map +1 -0
  28. package/dist/LuiModalAsync/useLuiModalPrefab.d.ts +56 -0
  29. package/dist/LuiModalAsync/useLuiModalPrefab.js +118 -0
  30. package/dist/LuiModalAsync/useLuiModalPrefab.js.map +1 -0
  31. package/dist/LuiModalAsync/useLuiModalUpload.d.ts +16 -0
  32. package/dist/LuiModalAsync/useLuiModalUpload.js +34 -0
  33. package/dist/LuiModalAsync/useLuiModalUpload.js.map +1 -0
  34. package/dist/LuiModalAsync/useShowAsyncModal.d.ts +6 -0
  35. package/dist/LuiModalAsync/useShowAsyncModal.js +13 -0
  36. package/dist/LuiModalAsync/useShowAsyncModal.js.map +1 -0
  37. package/dist/common/debug.d.ts +1 -0
  38. package/dist/common/debug.js +11 -0
  39. package/dist/common/debug.js.map +1 -0
  40. package/dist/common/index.js +3 -0
  41. package/dist/common/index.js.map +1 -0
  42. package/dist/common/useConstFunction.d.ts +5 -0
  43. package/dist/common/useConstFunction.js +17 -0
  44. package/dist/common/useConstFunction.js.map +1 -0
  45. package/dist/common/useInterval.d.ts +17 -0
  46. package/dist/common/{useInterval.ts → useInterval.js} +21 -25
  47. package/dist/common/useInterval.js.map +1 -0
  48. package/dist/common/useIsomorphicLayoutEffect.d.ts +17 -0
  49. package/dist/common/{useIsomorphicLayoutEffect.ts → useIsomorphicLayoutEffect.js} +1 -1
  50. package/dist/common/useIsomorphicLayoutEffect.js.map +1 -0
  51. package/dist/common/util.d.ts +3 -0
  52. package/dist/common/util.js +25 -0
  53. package/dist/common/util.js.map +1 -0
  54. package/dist/common/uuid.d.ts +1 -0
  55. package/dist/common/{uuid.ts → uuid.js} +1 -1
  56. package/dist/common/uuid.js.map +1 -0
  57. package/dist/components/CopyableText.d.ts +9 -0
  58. package/dist/components/CopyableText.js +29 -0
  59. package/dist/components/CopyableText.js.map +1 -0
  60. package/dist/components/index.js +2 -0
  61. package/dist/components/index.js.map +1 -0
  62. package/dist/index.js +7 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/panel/OpenPanelButton.d.ts +8 -0
  65. package/dist/panel/OpenPanelButton.js +11 -0
  66. package/dist/panel/OpenPanelButton.js.map +1 -0
  67. package/dist/panel/Panel.d.ts +10 -0
  68. package/dist/panel/Panel.js +122 -0
  69. package/dist/panel/Panel.js.map +1 -0
  70. package/dist/panel/PanelContext.d.ts +10 -0
  71. package/dist/panel/PanelContext.js +13 -0
  72. package/dist/panel/PanelContext.js.map +1 -0
  73. package/dist/panel/PanelDock.d.ts +5 -0
  74. package/dist/panel/PanelDock.js +9 -0
  75. package/dist/panel/PanelDock.js.map +1 -0
  76. package/dist/panel/PanelHeader.d.ts +15 -0
  77. package/dist/panel/PanelHeader.js +33 -0
  78. package/dist/panel/PanelHeader.js.map +1 -0
  79. package/dist/panel/PanelHeaderButton.d.ts +8 -0
  80. package/dist/panel/PanelHeaderButton.js +16 -0
  81. package/dist/panel/PanelHeaderButton.js.map +1 -0
  82. package/dist/panel/PanelInline.d.ts +10 -0
  83. package/dist/panel/PanelInline.js +26 -0
  84. package/dist/panel/PanelInline.js.map +1 -0
  85. package/dist/panel/PanelInstanceContext.d.ts +21 -0
  86. package/dist/panel/PanelInstanceContext.js +25 -0
  87. package/dist/panel/PanelInstanceContext.js.map +1 -0
  88. package/dist/panel/PanelInstanceContextProvider.d.ts +11 -0
  89. package/dist/panel/PanelInstanceContextProvider.js +50 -0
  90. package/dist/panel/PanelInstanceContextProvider.js.map +1 -0
  91. package/dist/panel/PanelsContext.d.ts +33 -0
  92. package/dist/panel/PanelsContext.js +19 -0
  93. package/dist/panel/PanelsContext.js.map +1 -0
  94. package/dist/panel/PanelsContextProvider.d.ts +12 -0
  95. package/dist/panel/PanelsContextProvider.js +145 -0
  96. package/dist/panel/PanelsContextProvider.js.map +1 -0
  97. package/dist/panel/PopinWIndow.d.ts +11 -0
  98. package/dist/panel/PopinWIndow.js +74 -0
  99. package/dist/panel/PopinWIndow.js.map +1 -0
  100. package/dist/panel/PopoutWindow.d.ts +17 -0
  101. package/dist/panel/PopoutWindow.js +72 -0
  102. package/dist/panel/PopoutWindow.js.map +1 -0
  103. package/dist/panel/generateId.d.ts +6 -0
  104. package/dist/panel/{generateId.ts → generateId.js} +3 -4
  105. package/dist/panel/generateId.js.map +1 -0
  106. package/dist/panel/handleStyleSheetsChanges.d.ts +9 -0
  107. package/dist/panel/handleStyleSheetsChanges.js +65 -0
  108. package/dist/panel/handleStyleSheetsChanges.js.map +1 -0
  109. package/dist/panel/index.js +13 -0
  110. package/dist/panel/index.js.map +1 -0
  111. package/dist/panel/openExternalWindow.d.ts +23 -0
  112. package/dist/panel/openExternalWindow.js +62 -0
  113. package/dist/panel/openExternalWindow.js.map +1 -0
  114. package/dist/panel/types/{PanelPosition.ts → PanelPosition.d.ts} +2 -2
  115. package/dist/panel/types/PanelPosition.js +2 -0
  116. package/dist/panel/types/PanelPosition.js.map +1 -0
  117. package/dist/panel/types/PanelProps.d.ts +19 -0
  118. package/dist/panel/types/PanelProps.js +2 -0
  119. package/dist/panel/types/PanelProps.js.map +1 -0
  120. package/dist/panel/types/{PanelRestoredState.ts → PanelRestoredState.d.ts} +3 -4
  121. package/dist/panel/types/PanelRestoredState.js +2 -0
  122. package/dist/panel/types/PanelRestoredState.js.map +1 -0
  123. package/dist/panel/types/PanelSize.d.ts +8 -0
  124. package/dist/panel/types/PanelSize.js +2 -0
  125. package/dist/panel/types/PanelSize.js.map +1 -0
  126. package/dist/panel/types/{PanelState.ts → PanelState.d.ts} +5 -8
  127. package/dist/panel/types/PanelState.js +2 -0
  128. package/dist/panel/types/PanelState.js.map +1 -0
  129. package/dist/panel/types/{PanelStateOptions.ts → PanelStateOptions.d.ts} +4 -6
  130. package/dist/panel/types/PanelStateOptions.js +2 -0
  131. package/dist/panel/types/PanelStateOptions.js.map +1 -0
  132. package/dist/panel/types/index.js +7 -0
  133. package/dist/panel/types/index.js.map +1 -0
  134. package/dist/panel/usePanelStateHandler.d.ts +8 -0
  135. package/dist/panel/usePanelStateHandler.js +81 -0
  136. package/dist/panel/usePanelStateHandler.js.map +1 -0
  137. package/dist/ribbon/RibbonButton.d.ts +21 -0
  138. package/dist/ribbon/RibbonButton.js +28 -0
  139. package/dist/ribbon/RibbonButton.js.map +1 -0
  140. package/dist/ribbon/RibbonButtonLink.d.ts +12 -0
  141. package/dist/ribbon/RibbonButtonLink.js +11 -0
  142. package/dist/ribbon/RibbonButtonLink.js.map +1 -0
  143. package/dist/ribbon/RibbonButtonOpenPanel.d.ts +5 -0
  144. package/dist/ribbon/RibbonButtonOpenPanel.js +11 -0
  145. package/dist/ribbon/RibbonButtonOpenPanel.js.map +1 -0
  146. package/dist/ribbon/RibbonButtonSlider.d.ts +11 -0
  147. package/dist/ribbon/RibbonButtonSlider.js +28 -0
  148. package/dist/ribbon/RibbonButtonSlider.js.map +1 -0
  149. package/dist/ribbon/RibbonButtonSliderContext.d.ts +25 -0
  150. package/dist/ribbon/RibbonButtonSliderContext.js +25 -0
  151. package/dist/ribbon/RibbonButtonSliderContext.js.map +1 -0
  152. package/dist/ribbon/RibbonContainer.d.ts +10 -0
  153. package/dist/ribbon/RibbonContainer.js +7 -0
  154. package/dist/ribbon/RibbonContainer.js.map +1 -0
  155. package/dist/ribbon/RibbonDeprecated.d.ts +10 -0
  156. package/dist/ribbon/RibbonDeprecated.js +13 -0
  157. package/dist/ribbon/RibbonDeprecated.js.map +1 -0
  158. package/dist/ribbon/RibbonMenu.d.ts +7 -0
  159. package/dist/ribbon/RibbonMenu.js +12 -0
  160. package/dist/ribbon/RibbonMenu.js.map +1 -0
  161. package/dist/ribbon/RibbonMenuOption.d.ts +17 -0
  162. package/dist/ribbon/RibbonMenuOption.js +26 -0
  163. package/dist/ribbon/RibbonMenuOption.js.map +1 -0
  164. package/dist/ribbon/RibbonMenuSeparator.d.ts +2 -0
  165. package/dist/ribbon/RibbonMenuSeparator.js +6 -0
  166. package/dist/ribbon/RibbonMenuSeparator.js.map +1 -0
  167. package/dist/ribbon/RibbonSeparator.d.ts +2 -0
  168. package/dist/ribbon/RibbonSeparator.js +4 -0
  169. package/dist/ribbon/RibbonSeparator.js.map +1 -0
  170. package/dist/ribbon/index.js +12 -0
  171. package/dist/ribbon/index.js.map +1 -0
  172. package/package.json +15 -8
  173. package/dist/LuiModalAsync/LuiModalAsync.tsx +0 -82
  174. package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.tsx +0 -55
  175. package/dist/LuiModalAsync/LuiModalAsyncContent.tsx +0 -9
  176. package/dist/LuiModalAsync/LuiModalAsyncContext.tsx +0 -52
  177. package/dist/LuiModalAsync/LuiModalAsyncContextProvider.tsx +0 -223
  178. package/dist/LuiModalAsync/LuiModalAsyncHeader.tsx +0 -67
  179. package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.ts +0 -24
  180. package/dist/LuiModalAsync/LuiModalAsyncMain.tsx +0 -8
  181. package/dist/LuiModalAsync/useLuiModalPrefab.tsx +0 -227
  182. package/dist/LuiModalAsync/useLuiModalUpload.tsx +0 -79
  183. package/dist/LuiModalAsync/useShowAsyncModal.ts +0 -34
  184. package/dist/common/debug.ts +0 -9
  185. package/dist/common/useConstFunction.ts +0 -22
  186. package/dist/common/util.ts +0 -31
  187. package/dist/components/CopyableText.tsx +0 -58
  188. package/dist/panel/OpenPanelButton.tsx +0 -52
  189. package/dist/panel/Panel.tsx +0 -211
  190. package/dist/panel/PanelContext.ts +0 -22
  191. package/dist/panel/PanelDock.tsx +0 -20
  192. package/dist/panel/PanelHeader.tsx +0 -105
  193. package/dist/panel/PanelHeaderButton.tsx +0 -26
  194. package/dist/panel/PanelInline.tsx +0 -46
  195. package/dist/panel/PanelInstanceContext.ts +0 -44
  196. package/dist/panel/PanelInstanceContextProvider.tsx +0 -75
  197. package/dist/panel/PanelsContext.tsx +0 -56
  198. package/dist/panel/PanelsContextProvider.tsx +0 -220
  199. package/dist/panel/PopinWIndow.tsx +0 -147
  200. package/dist/panel/PopoutWindow.tsx +0 -117
  201. package/dist/panel/handleStyleSheetsChanges.ts +0 -71
  202. package/dist/panel/openExternalWindow.ts +0 -98
  203. package/dist/panel/types/PanelProps.ts +0 -22
  204. package/dist/panel/types/PanelSize.ts +0 -9
  205. package/dist/panel/usePanelStateHandler.tsx +0 -102
  206. package/dist/ribbon/RibbonButton.tsx +0 -112
  207. package/dist/ribbon/RibbonButtonLink.tsx +0 -27
  208. package/dist/ribbon/RibbonButtonOpenPanel.tsx +0 -23
  209. package/dist/ribbon/RibbonButtonSlider.tsx +0 -66
  210. package/dist/ribbon/RibbonButtonSliderContext.tsx +0 -34
  211. package/dist/ribbon/RibbonContainer.tsx +0 -19
  212. package/dist/ribbon/RibbonDeprecated.tsx +0 -27
  213. package/dist/ribbon/RibbonMenu.tsx +0 -25
  214. package/dist/ribbon/RibbonMenuOption.tsx +0 -67
  215. package/dist/ribbon/RibbonMenuSeparator.tsx +0 -5
  216. package/dist/ribbon/RibbonSeparator.tsx +0 -3
  217. /package/dist/LuiModalAsync/{index.ts → index.d.ts} +0 -0
  218. /package/dist/common/{index.ts → index.d.ts} +0 -0
  219. /package/dist/components/{index.ts → index.d.ts} +0 -0
  220. /package/dist/{index.ts → index.d.ts} +0 -0
  221. /package/dist/panel/{index.ts → index.d.ts} +0 -0
  222. /package/dist/panel/types/{index.ts → index.d.ts} +0 -0
  223. /package/dist/ribbon/{index.ts → index.d.ts} +0 -0
@@ -0,0 +1,145 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { castArray, isEmpty, maxBy, partition, sortBy } from 'lodash-es';
3
+ import { Fragment, useCallback, useMemo, useRef, useState } from 'react';
4
+ import { PanelInstanceContextProvider } from './PanelInstanceContextProvider';
5
+ import { PanelsContext } from './PanelsContext';
6
+ import { v4 } from '../common/uuid';
7
+ import { useInterval } from '../common/useInterval';
8
+ const defaultPanelStateOptions = {
9
+ saveStateIn: 'localStorage',
10
+ saveStateKey: 'userId',
11
+ };
12
+ export const PanelsContextProvider = ({ bounds, baseZIndex = 500, children, panelStateOptions: _panelStateOptions, tilingStart = { x: 30, y: 30 }, tilingOffset = { x: 30, y: 50 }, tilingMax = { x: 200, y: 300 }, }) => {
13
+ const panelStateOptions = _panelStateOptions === undefined ? defaultPanelStateOptions : _panelStateOptions;
14
+ const stackPositionRef = useRef(tilingStart);
15
+ // Can't use a map here as we need to retain render order for performance
16
+ const [panelInstances, setPanelInstances] = useState([]);
17
+ const [dockElements, setDockElements] = useState({});
18
+ const setDockElement = useCallback((id, element) => {
19
+ if (dockElements[id] !== element) {
20
+ setDockElements({ ...dockElements, [id]: element });
21
+ }
22
+ }, [dockElements]);
23
+ const bringPanelToFront = useCallback((panelUniqueId) => {
24
+ setPanelInstances((panelInstances) => {
25
+ const panelInstance = panelInstances.find((panelInstance) => panelInstance.uniqueId === panelUniqueId);
26
+ if (!panelInstance) {
27
+ console.warn(`bringPanelToFront cannot find panel with uniqueId: ${panelUniqueId}`);
28
+ return panelInstances;
29
+ }
30
+ if (panelInstance.window) {
31
+ panelInstance.window.focus();
32
+ return panelInstances;
33
+ }
34
+ const maxZIndexPanelInstance = maxBy(panelInstances, 'zIndex');
35
+ // Prevent unnecessary state updates
36
+ if (maxZIndexPanelInstance === panelInstance) {
37
+ return panelInstances;
38
+ }
39
+ sortBy(panelInstances, (pi) => (panelInstance === pi ? 32768 : pi.zIndex)).forEach((pi, i) => (pi.zIndex = baseZIndex + i));
40
+ return [...panelInstances];
41
+ });
42
+ }, [baseZIndex]);
43
+ const showHidePanel = useCallback((hidePanelIds, hidden) => {
44
+ setPanelInstances((panelInstances) => {
45
+ const panelIds = castArray(hidePanelIds);
46
+ return panelInstances.map((pi) => {
47
+ return panelIds.includes(pi.uniqueId) && pi.hidden !== hidden ? { ...pi, hidden } : pi;
48
+ });
49
+ });
50
+ }, []);
51
+ const hidePanel = useCallback((hidePanelIds) => {
52
+ showHidePanel(hidePanelIds, true);
53
+ }, [showHidePanel]);
54
+ const unhidePanel = useCallback((hidePanelIds) => {
55
+ showHidePanel(hidePanelIds, false);
56
+ }, [showHidePanel]);
57
+ const hasHiddenPanel = useCallback((panelId) => {
58
+ return panelInstances.find((pi) => pi.uniqueId === panelId)?.hidden === true;
59
+ }, [panelInstances]);
60
+ const openPanel = useCallback(({ componentFn, poppedOut = false, uniqueId = v4(), onClose }) => {
61
+ try {
62
+ setPanelInstances((panelInstances) => {
63
+ const existingPanelInstance = panelInstances.find((pi) => pi.uniqueId === uniqueId);
64
+ if (existingPanelInstance) {
65
+ if (existingPanelInstance.window) {
66
+ existingPanelInstance.window?.focus();
67
+ }
68
+ else {
69
+ if (existingPanelInstance.hidden) {
70
+ setTimeout(() => unhidePanel(uniqueId), 0);
71
+ }
72
+ setTimeout(() => bringPanelToFront(uniqueId), 0);
73
+ }
74
+ return panelInstances;
75
+ }
76
+ return [
77
+ ...panelInstances,
78
+ {
79
+ uniqueId,
80
+ componentInstance: componentFn(),
81
+ zIndex: baseZIndex + panelInstances.length,
82
+ poppedOut,
83
+ window: null,
84
+ onClose,
85
+ hidden: false,
86
+ },
87
+ ];
88
+ });
89
+ return uniqueId;
90
+ }
91
+ catch (e) {
92
+ console.error(e);
93
+ return null;
94
+ }
95
+ }, [baseZIndex, bringPanelToFront, unhidePanel]);
96
+ const closePanel = useCallback((closePanelUniqueIds) => {
97
+ const panelIds = castArray(closePanelUniqueIds);
98
+ setPanelInstances((panelInstances) => {
99
+ const [closedPanelInstances, stillOpenPanelInstances] = partition(panelInstances, (pi) => panelIds.includes(pi.uniqueId));
100
+ if (!isEmpty(closedPanelInstances)) {
101
+ closedPanelInstances.forEach(({ onClose }) => {
102
+ onClose?.();
103
+ });
104
+ return stillOpenPanelInstances;
105
+ }
106
+ return panelInstances;
107
+ });
108
+ }, []);
109
+ /**
110
+ * It's not easy to tell the difference between a window closing and a window popping in via events,
111
+ * so we're periodically checking instead.
112
+ */
113
+ useInterval(() => {
114
+ // close any panels that have a window that is closed
115
+ closePanel(panelInstances.filter((pi) => pi.window?.closed).map((panel) => panel.uniqueId));
116
+ }, 500);
117
+ /**
118
+ * Tile the panel position relative to previous panel
119
+ */
120
+ const nextStackPosition = useCallback(() => {
121
+ const p = { ...stackPositionRef.current };
122
+ const result = { ...p };
123
+ p.x += tilingOffset.x;
124
+ p.y += tilingOffset.y;
125
+ stackPositionRef.current = p.x > tilingMax.x || p.y > tilingMax.y ? tilingStart : p;
126
+ return result;
127
+ }, [tilingMax.x, tilingMax.y, tilingOffset.x, tilingOffset.y, tilingStart]);
128
+ const openPanels = useMemo(() => new Set(panelInstances.map((pi) => pi.uniqueId)), [panelInstances]);
129
+ const hasOpenPanel = useCallback((panelId) => openPanels.has(panelId), [openPanels]);
130
+ return (_jsxs(PanelsContext.Provider, { value: {
131
+ openPanels,
132
+ hasOpenPanel,
133
+ openPanel,
134
+ closePanel,
135
+ hasHiddenPanel,
136
+ bringPanelToFront,
137
+ nextStackPosition,
138
+ dockElements,
139
+ setDockElement,
140
+ panelStateOptions,
141
+ hidePanel,
142
+ unhidePanel,
143
+ }, children: [_jsx(Fragment, { children: panelInstances.map((panelInstance) => (_jsx(PanelInstanceContextProvider, { panelInstance: panelInstance, bounds: bounds, hidden: panelInstance.hidden, children: panelInstance.componentInstance }, panelInstance.uniqueId))) }, 'panels'), _jsx(Fragment, { children: children }, 'children')] }));
144
+ };
145
+ //# sourceMappingURL=PanelsContextProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PanelsContextProvider.js","sourceRoot":"","sources":["../../src/panel/PanelsContextProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAmC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1G,OAAO,EAAE,4BAA4B,EA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,CAAC,CAAC,CAAC;IAE5E,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErG,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,OAAe,EAAW,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEtG,OAAO,CACL,MAAC,aAAa,CAAC,QAAQ,IACrB,KAAK,EAAE;YACL,UAAU;YACV,YAAY;YACZ,SAAS;YACT,UAAU;YACV,cAAc;YACd,iBAAiB;YACjB,iBAAiB;YACjB,YAAY;YACZ,cAAc;YACd,iBAAiB;YACjB,SAAS;YACT,WAAW;SACZ,aAED,KAAC,QAAQ,cACN,cAAc,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,CACrC,KAAC,4BAA4B,IAE3B,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,CAAC,MAAM,YAE3B,aAAa,CAAC,iBAAiB,IAL3B,aAAa,CAAC,QAAQ,CAME,CAChC,CAAC,IAVW,QAAQ,CAWZ,EACX,KAAC,QAAQ,cAAmB,QAAQ,IAArB,UAAU,CAAuB,IACzB,CAC1B,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Dispatch, ReactElement } from 'react';
2
+ import { PanelPosition, PanelSize } from './types';
3
+ import { PanelProps } from './types/PanelProps';
4
+ export declare function PopinWindow({ children, className, maxHeight, maxWidth, minHeight, minWidth, modal, position, resizeable, size, panelPosition, setPanelPosition, panelSize, setPanelSize, setInitialPanelSize, hidden, }: PanelProps & {
5
+ panelPosition: PanelPosition;
6
+ setPanelPosition: Dispatch<PanelPosition>;
7
+ panelSize: PanelSize;
8
+ setPanelSize: Dispatch<PanelSize>;
9
+ setInitialPanelSize: Dispatch<PanelSize>;
10
+ hidden?: boolean;
11
+ }): ReactElement;
@@ -0,0 +1,74 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import clsx from 'clsx';
3
+ import { pick } from 'lodash-es';
4
+ import { useCallback, useContext, useEffect, useRef } from 'react';
5
+ import { Rnd } from 'react-rnd';
6
+ import { PanelContext } from './PanelContext';
7
+ import { PanelInstanceContext } from './PanelInstanceContext';
8
+ import { useSaveStateIn } from './usePanelStateHandler';
9
+ export function PopinWindow({ children, className, maxHeight, maxWidth, minHeight, minWidth, modal, position = modal ? 'center' : 'tile', resizeable = modal !== true, size = { height: 200, width: 320 }, panelPosition, setPanelPosition, panelSize, setPanelSize, setInitialPanelSize, hidden, }) {
10
+ const panelRef = useRef(null);
11
+ const { bounds, zIndex, bringPanelToFront, uniqueId } = useContext(PanelInstanceContext);
12
+ const centerWindow = useCallback(() => {
13
+ const b = panelRef.current?.getSelfElement()?.getBoundingClientRect();
14
+ let height = b?.height ?? size.height;
15
+ // You can't auto height a centered panel
16
+ if (height === 'auto') {
17
+ height = 400;
18
+ }
19
+ setPanelPosition({
20
+ x: Math.max((window.innerWidth - (b?.width ?? size.width)) / 2, 0),
21
+ y: Math.max((window.innerHeight - height) / 2, 0),
22
+ });
23
+ }, [setPanelPosition, size.height, size.width]);
24
+ useEffect(() => {
25
+ if (position === 'center' && !resizeable) {
26
+ centerWindow();
27
+ window.addEventListener('resize', centerWindow);
28
+ return () => window.removeEventListener('resize', centerWindow);
29
+ }
30
+ return;
31
+ }, [centerWindow, position, resizeable]);
32
+ const resizePanel = useCallback((newPanelSize) => {
33
+ const newSize = { ...panelSize, ...newPanelSize };
34
+ if (newSize.width !== panelSize.width || newSize.height !== panelSize.height) {
35
+ setPanelSize(newSize);
36
+ }
37
+ }, [panelSize, setPanelSize]);
38
+ const initialResizePanel = useCallback((newPanelSize) => {
39
+ const newSize = { ...panelSize, ...newPanelSize };
40
+ if (newSize.width !== panelSize.width || newSize.height !== panelSize.height) {
41
+ setInitialPanelSize(newSize);
42
+ }
43
+ }, [panelSize, setInitialPanelSize]);
44
+ const saveStateIn = useSaveStateIn({ uniqueId });
45
+ useEffect(() => {
46
+ saveStateIn({
47
+ panelPosition,
48
+ panelSize,
49
+ });
50
+ }, [panelPosition, panelSize, saveStateIn]);
51
+ return (_jsxs(PanelContext.Provider, { value: { resizePanel, initialResizePanel, resizeable }, children: [modal && (_jsx("div", { style: {
52
+ position: 'absolute',
53
+ top: 0,
54
+ left: 0,
55
+ bottom: 0,
56
+ right: 0,
57
+ backgroundColor: 'rgb(0,0,0,0.1)',
58
+ zIndex,
59
+ } })), _jsx(Rnd, { ref: panelRef, className: clsx('WindowPanel', className), dragHandleClassName: 'draggable-handle', maxHeight: maxHeight, maxWidth: maxWidth, minWidth: minWidth, minHeight: minHeight, position: panelPosition, size: panelSize.height === 'auto' ? pick(panelSize, 'width') : panelSize, style: { zIndex, visibility: hidden ? 'hidden' : undefined }, disableDragging: !resizeable, enableResizing: resizeable, bounds: bounds ?? document.body, onDragStop: (_evt, data) => {
60
+ setPanelPosition({ x: data.x, y: data.y });
61
+ }, onResizeStop: (_evt, _dir, ref, _delta, position) => {
62
+ setPanelPosition(position);
63
+ setPanelSize({
64
+ width: parseInt(ref.style.width),
65
+ height: parseInt(ref.style.height),
66
+ });
67
+ }, onMouseDown: bringPanelToFront, children: _jsx("div", { style: {
68
+ display: 'flex',
69
+ flexDirection: 'column',
70
+ width: '100%',
71
+ height: '100%',
72
+ }, children: children }) })] }));
73
+ }
74
+ //# sourceMappingURL=PopinWIndow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PopinWIndow.js","sourceRoot":"","sources":["../../src/panel/PopinWIndow.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,E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Ac,EAAE,UAAU,EAC1B,MAAM,EAAE,MAAM,IAAI,QAAQ,CAAC,IAAI,EAC/B,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;oBACzB,gBAAgB,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC7C,CAAC,EACD,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;oBAClD,gBAAgB,CAAC,QAAQ,CAAC,CAAC;oBAC3B,YAAY,CAAC;wBACX,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC;wBAChC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;qBACnC,CAAC,CAAC;gBACL,CAAC,EACD,WAAW,EAAE,iBAAiB,YAE9B,cACE,KAAK,EAAE;wBACL,OAAO,EAAE,MAAM;wBACf,aAAa,EAAE,QAAQ;wBACvB,KAAK,EAAE,MAAM;wBACb,MAAM,EAAE,MAAM;qBACf,YAEA,QAAQ,GACL,GACF,IACgB,CACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { PropsWithChildren, ReactElement } from 'react';
2
+ import { OpenExternalWindowResponse } from './openExternalWindow';
3
+ import { PanelPosition, PanelSizeExact } from './types';
4
+ interface _PopoutWindowProps {
5
+ name: string;
6
+ title?: string;
7
+ size: PanelSizeExact;
8
+ popInPanelPosition: PanelPosition;
9
+ popInPanelSize: PanelSizeExact;
10
+ observeStyleChanges?: boolean;
11
+ /** Testing seam to avoid extensively mocking the window object. */
12
+ openExternalWindowFn?: () => OpenExternalWindowResponse;
13
+ className?: string;
14
+ }
15
+ export type PopoutWindowProps = PropsWithChildren<_PopoutWindowProps>;
16
+ export declare const PopoutWindow: ({ name, title, size, popInPanelPosition, popInPanelSize, observeStyleChanges, className, openExternalWindowFn, children, }: PopoutWindowProps) => ReactElement | null;
17
+ export {};
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import createCache from '@emotion/cache';
3
+ import { CacheProvider } from '@emotion/react';
4
+ import { useContext, useEffect, useState } from 'react';
5
+ import { createPortal } from 'react-dom';
6
+ import { makePopoutId } from './generateId';
7
+ import { openExternalWindow } from './openExternalWindow';
8
+ import { PanelInstanceContext } from './PanelInstanceContext';
9
+ import { useRestoreStateFrom, useSaveStateIn } from './usePanelStateHandler';
10
+ export const PopoutWindow = ({ name, title = name, size, popInPanelPosition, popInPanelSize, observeStyleChanges, className, openExternalWindowFn, children, }) => {
11
+ const { setPanelWindow } = useContext(PanelInstanceContext);
12
+ const [containerElement, setContainerElement] = useState();
13
+ const [headElement, setHeadElement] = useState();
14
+ const savedState = useRestoreStateFrom({ uniqueId: name, panelPoppedOut: true });
15
+ // If we use a popped in position as a popped out position we must adjust for which screen the window is on.
16
+ const poppedInPosition = popInPanelPosition;
17
+ const poppedInPositionAdjusted = {
18
+ x: window.screenX + poppedInPosition.x,
19
+ y: window.screenY + poppedInPosition.y,
20
+ };
21
+ const position = savedState?.panelPosition ?? poppedInPositionAdjusted;
22
+ const panelSize = savedState?.panelSize ?? popInPanelSize ?? size;
23
+ const saveStateIn = useSaveStateIn({ panelPoppedOut: true, uniqueId: name });
24
+ // When we create this component, open a new window
25
+ useEffect(() => {
26
+ const oew = openExternalWindowFn ?? openExternalWindow;
27
+ const { externalWindow, onCloseExternalWindow } = oew({
28
+ title,
29
+ size: panelSize.height === 'auto' ? { ...panelSize, height: 400 } : panelSize,
30
+ setContainerElement,
31
+ setHeadElement,
32
+ observeStyleChanges,
33
+ className,
34
+ position,
35
+ });
36
+ if (!externalWindow)
37
+ return;
38
+ setPanelWindow(externalWindow);
39
+ const closeExternalWindow = () => {
40
+ externalWindow.close();
41
+ };
42
+ const savePanelState = () => {
43
+ saveStateIn({
44
+ panelPosition: {
45
+ x: externalWindow.screenX,
46
+ y: externalWindow.screenY,
47
+ },
48
+ panelSize: {
49
+ height: externalWindow.innerHeight,
50
+ width: externalWindow.innerWidth,
51
+ },
52
+ });
53
+ };
54
+ externalWindow.addEventListener('beforeunload', savePanelState);
55
+ // When the main window closes or reloads, close the popout
56
+ window.addEventListener('beforeunload', closeExternalWindow, { once: true });
57
+ return () => {
58
+ onCloseExternalWindow?.();
59
+ };
60
+ },
61
+ // These deps MUST be empty
62
+ // eslint-disable-next-line react-hooks/exhaustive-deps
63
+ []);
64
+ // Render this component's children into the root element of the popout window
65
+ // The `@emotion/react/CacheProvider`provides a cache derived from createCache for inline styles
66
+ // these will be generated into the `container` and prefixed with the `key` below, ensuring
67
+ // the styles are in the popout rather than the root window.
68
+ const myCache = createCache({ key: makePopoutId(name), container: headElement });
69
+ const wrappedChildren = _jsx(CacheProvider, { value: myCache, children: children });
70
+ return containerElement ? createPortal(wrappedChildren, containerElement) : null;
71
+ };
72
+ //# sourceMappingURL=PopoutWindow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PopoutWindow.js","sourceRoot":"","sources":["../../src/panel/PopoutWindow.tsx"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAmC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAA8B,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAoB7E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,IAAI,EACJ,KA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}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The only valid characters for an @emotion key are lower case chars or '-'.
3
+ * We need to replace any char that is not valid with a substitute.
4
+ */
5
+ export declare const makePopoutId: (str: string) => string;
6
+ export declare const popoutWindowDivId: (windowTitle: string) => string;
@@ -2,8 +2,7 @@
2
2
  * The only valid characters for an @emotion key are lower case chars or '-'.
3
3
  * We need to replace any char that is not valid with a substitute.
4
4
  */
5
- export const makePopoutId = (str: string): string =>
6
- str
5
+ export const makePopoutId = (str) => str
7
6
  .toLowerCase()
8
7
  .replaceAll(/[^a-z0-9-]/g, '-')
9
8
  .replaceAll('0', '-zero-')
@@ -18,5 +17,5 @@ export const makePopoutId = (str: string): string =>
18
17
  .replaceAll('9', '-nine-')
19
18
  .replaceAll(/-+/g, '-')
20
19
  .toLowerCase();
21
-
22
- export const popoutWindowDivId = (windowTitle: string): string => `popoutWindow-${makePopoutId(windowTitle)}`;
20
+ export const popoutWindowDivId = (windowTitle) => `popoutWindow-${makePopoutId(windowTitle)}`;
21
+ //# sourceMappingURL=generateId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateId.js","sourceRoot":"","sources":["../../src/panel/generateId.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAW,EAAU,EAAE,CAClD,GAAG;KACA,WAAW,EAAE;KACb,UAAU,CAAC,aAAa,EAAE,GAAG,CAAC;KAC9B,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;KACzB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;KACxB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;KACxB,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC;KAC1B,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;KACzB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;KACzB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;KACxB,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC;KAC1B,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC;KAC1B,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;KACzB,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC;KACtB,WAAW,EAAE,CAAC;AAEnB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,WAAmB,EAAU,EAAE,CAAC,gBAAgB,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const copyStyleSheets: (newHeadMountElement: HTMLDivElement) => void;
2
+ /**
3
+ * Add listener for dynamic style changes
4
+ * This works by listening to any changes to the head element
5
+ * If there are any changes it replaces all the styles in the floating window
6
+ * at most every 100ms
7
+ * @param newHeadMountElement
8
+ */
9
+ export declare const observeStyleSheetChanges: (newHeadMountElement: HTMLDivElement) => MutationObserver | null;
@@ -0,0 +1,65 @@
1
+ import { throttle } from 'lodash-es';
2
+ // Copy the app's styles into the new window
3
+ export const copyStyleSheets = (newHeadMountElement) => {
4
+ const stylesheets = Array.from(document.styleSheets);
5
+ stylesheets.forEach((stylesheet) => {
6
+ if (stylesheet.href) {
7
+ const newStyleElement = document.createElement('link');
8
+ newStyleElement.rel = 'stylesheet';
9
+ newStyleElement.href = stylesheet.href;
10
+ newHeadMountElement.appendChild(newStyleElement);
11
+ }
12
+ else {
13
+ const css = stylesheet;
14
+ if (css && css.cssRules && css.cssRules.length > 0) {
15
+ const newStyleElement = document.createElement('style');
16
+ Array.from(css.cssRules).forEach((rule) => {
17
+ newStyleElement.appendChild(document.createTextNode(rule.cssText));
18
+ });
19
+ newHeadMountElement.appendChild(newStyleElement);
20
+ }
21
+ }
22
+ });
23
+ };
24
+ /**
25
+ * Add listener for dynamic style changes
26
+ * This works by listening to any changes to the head element
27
+ * If there are any changes it replaces all the styles in the floating window
28
+ * at most every 100ms
29
+ * @param newHeadMountElement
30
+ */
31
+ export const observeStyleSheetChanges = (newHeadMountElement) => {
32
+ const targetNode = document.querySelector('head');
33
+ if (!targetNode) {
34
+ return null;
35
+ }
36
+ // Options for the observer (which mutations to observe)
37
+ const config = { /*attributes: true,*/ childList: true /*, subtree: true */ };
38
+ //throttle the copying of the all the styles at most 100ms
39
+ const throttleCopyStyleSheets = throttle(() => {
40
+ copyStyleSheets(newHeadMountElement);
41
+ }, 100);
42
+ // Callback function to execute when mutations are observed
43
+ const callback = function (mutationList) {
44
+ for (const mutation of mutationList) {
45
+ if (mutation.type === 'childList') {
46
+ // console.log("A child node has been added or removed.", mutation);
47
+ //naive way up updating style sheets
48
+ //the observer tells us what has been added and removed, but syncing the changes with the
49
+ //floating window is complicated, so the easiest way is to just wait for modifications for finish
50
+ //updating, then replace them all
51
+ //we could probably just copy all style on every modification, by that might have a performance hit
52
+ throttleCopyStyleSheets();
53
+ } /*else if (mutation.type === "attributes") {
54
+ //Do we need to handle attribute modifications?
55
+ // console.log("The " + mutation.attributeName + " attribute was modified.");
56
+ }*/
57
+ }
58
+ };
59
+ // Create an observer instance linked to the callback function
60
+ const observer = new MutationObserver(callback);
61
+ // Start observing the target node for configured mutations
62
+ observer.observe(targetNode, config);
63
+ return observer;
64
+ };
65
+ //# sourceMappingURL=handleStyleSheetsChanges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleStyleSheetsChanges.js","sourceRoot":"","sources":["../../src/panel/handleStyleSheetsChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,4CAA4C;AAC5C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,mBAAmC,EAAE,EAAE;IACrE,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAErD,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QACjC,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YACvD,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K,MAAM,QAAQ,IAAI,YAAY,EAAE,CAAC;YACpC,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBAClC,oEAAoE;gBACpE,oCAAoC;gBACpC,yFAAyF;gBACzF,iGAAiG;gBACjG,iCAAiC;gBACjC,mGAAmG;gBACnG,uBAAuB,EAAE,CAAC;YAC5B,CAAC,CAAC;;;qBAGO;QACX,CAAC;IACH,CAAC,CAAC;IAEF,8DAA8D;IAC9D,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAEhD,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAErC,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export * from './OpenPanelButton';
2
+ export * from './Panel';
3
+ export * from './PanelContext';
4
+ export * from './PanelDock';
5
+ export * from './PanelHeader';
6
+ export * from './PanelHeaderButton';
7
+ export * from './PanelInline';
8
+ export * from './PanelInstanceContext';
9
+ export * from './PanelInstanceContextProvider';
10
+ export * from './PanelsContext';
11
+ export * from './PanelsContextProvider';
12
+ export * from './types';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/panel/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ import { PanelPosition, PanelSizeExact } from './types';
3
+ export type OpenExternalWindowResponse = {
4
+ externalWindow: Window | null;
5
+ onCloseExternalWindow: (() => void) | null;
6
+ };
7
+ /**
8
+ * Open and scaffold the new external window.
9
+ *
10
+ * The main motivation for extracting these procedures into a function is for testing ease. JSDOM does not mock out the
11
+ * entire window object, making the PopoutWindow component difficult to unit test without extensive mocking. Instead, we
12
+ * can avoid mocking most of the window methods entirely by conditionally calling an alternative to `openExternalWindow`
13
+ * during unit testing by providing a truthy `openExternalWindowFn` prop.
14
+ */
15
+ export declare const openExternalWindow: ({ title, size, setContainerElement, setHeadElement, observeStyleChanges, className, position, }: {
16
+ title: string;
17
+ size: PanelSizeExact;
18
+ setContainerElement: Dispatch<SetStateAction<HTMLElement | undefined>>;
19
+ setHeadElement: Dispatch<SetStateAction<HTMLElement | undefined>>;
20
+ observeStyleChanges?: boolean;
21
+ className?: string;
22
+ position: PanelPosition;
23
+ }) => OpenExternalWindowResponse;
@@ -0,0 +1,62 @@
1
+ import { makePopoutId, popoutWindowDivId } from './generateId';
2
+ import { copyStyleSheets, observeStyleSheetChanges } from './handleStyleSheetsChanges';
3
+ /**
4
+ * Open and scaffold the new external window.
5
+ *
6
+ * The main motivation for extracting these procedures into a function is for testing ease. JSDOM does not mock out the
7
+ * entire window object, making the PopoutWindow component difficult to unit test without extensive mocking. Instead, we
8
+ * can avoid mocking most of the window methods entirely by conditionally calling an alternative to `openExternalWindow`
9
+ * during unit testing by providing a truthy `openExternalWindowFn` prop.
10
+ */
11
+ export const openExternalWindow = ({ title, size, setContainerElement, setHeadElement, observeStyleChanges = false, className, position, }) => {
12
+ const response = { externalWindow: null, onCloseExternalWindow: null };
13
+ // NOTE:
14
+ // 1/ Edge ignores the left and top settings
15
+ // 2/ Chrome has a bug that screws up the window size by a factor dependent on your windows scaling settings
16
+ // if you open the browser in a window with a scaling and drag it to a window with a different scaling
17
+ const features = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,` +
18
+ `width=${size.width},height=${size.height},left=${position.x},top=${position.y}`;
19
+ response.externalWindow = window.open('', makePopoutId(title), features);
20
+ if (response.externalWindow) {
21
+ const { externalWindow } = response;
22
+ // Reset the default body style applied by the browser
23
+ externalWindow.document.body.style.margin = '0';
24
+ externalWindow.document.body.style.padding = '0';
25
+ // Remove any existing body HTML from this window
26
+ const existingBodyMountElement = externalWindow.document.body?.firstChild;
27
+ if (existingBodyMountElement) {
28
+ externalWindow.document.body.removeChild(existingBodyMountElement);
29
+ }
30
+ // Create a new HTML element to hang our rendering off
31
+ const newMountElement = externalWindow.document.createElement('div');
32
+ newMountElement.className = `PopoutWindowContainer ${className || ''}`;
33
+ setContainerElement(newMountElement);
34
+ externalWindow.document.body.appendChild(newMountElement);
35
+ // Do the same for the head node (where all the styles are added)
36
+ const existingHeadMountElement = externalWindow.document.head?.firstChild;
37
+ if (existingHeadMountElement) {
38
+ externalWindow.document.head.removeChild(existingHeadMountElement);
39
+ }
40
+ // and an HTML element to hang our copied styles off
41
+ const newHeadMountElement = externalWindow.document.createElement('div');
42
+ externalWindow.document.head.appendChild(newHeadMountElement);
43
+ setHeadElement(newHeadMountElement);
44
+ // Set External window title
45
+ externalWindow.document.title = title;
46
+ // Set an id to the external window div to be queried and used by react-modal as parentSelector
47
+ // so the modal shows up in the popped out window instead the main window
48
+ newMountElement.id = popoutWindowDivId(title);
49
+ copyStyleSheets(newHeadMountElement);
50
+ let observer = null;
51
+ if (observeStyleChanges) {
52
+ observer = observeStyleSheetChanges(newHeadMountElement);
53
+ }
54
+ externalWindow.onbeforeunload = () => observer?.disconnect();
55
+ response.onCloseExternalWindow = () => {
56
+ // Make sure the window closes when the component unmounts
57
+ externalWindow.close();
58
+ };
59
+ }
60
+ return response;
61
+ };
62
+ //# sourceMappingURL=openExternalWindow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openExternalWindow.js","sourceRoot":"","sources":["../../src/panel/openExternalWindow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,iBA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CAAC"}
@@ -1,4 +1,4 @@
1
1
  export interface PanelPosition {
2
- x: number;
3
- y: number;
2
+ x: number;
3
+ y: number;
4
4
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PanelPosition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PanelPosition.js","sourceRoot":"","sources":["../../../src/panel/types/PanelPosition.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { PanelPosition } from './PanelPosition';
3
+ import { PanelSize } from './PanelSize';
4
+ export type PanelBounds = PanelPosition & PanelSize;
5
+ interface _PanelProps {
6
+ className?: string;
7
+ maxHeight?: number | string;
8
+ maxWidth?: number | string;
9
+ minHeight?: number | string;
10
+ minWidth?: number | string;
11
+ modal?: boolean;
12
+ dynamicBounds?: () => PanelBounds | null;
13
+ position?: PanelPosition | 'tile' | 'center';
14
+ resizeable?: boolean;
15
+ size?: PanelSize;
16
+ title: string;
17
+ }
18
+ export type PanelProps = PropsWithChildren<_PanelProps>;
19
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PanelProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PanelProps.js","sourceRoot":"","sources":["../../../src/panel/types/PanelProps.ts"],"names":[],"mappings":""}