@opengeoweb/shared 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.esm.js +106 -61
- package/index.umd.js +92 -63
- package/lib/components/DraggableResizable/Draggable.d.ts +3 -3
- package/lib/components/StatusTag/StatusTag.stories.d.ts +21 -1
- package/lib/components/WithEggs/WithEggs.d.ts +3 -0
- package/lib/components/WithEggs/WithEggs.spec.d.ts +1 -0
- package/lib/components/WithEggs/index.d.ts +1 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/useMakeSureContainerStaysInsideWindow/useMakeSureContainerStaysInsideWindow.d.ts +3 -0
- package/lib/hooks/useMakeSureContainerStaysInsideWindow/useMakeSureContainerStaysInsideWindow.spec.d.ts +1 -0
- package/package.json +6 -4
package/index.esm.js
CHANGED
|
@@ -4,9 +4,10 @@ import { Box, Typography, Dialog, DialogTitle, IconButton, DialogContent, Dialog
|
|
|
4
4
|
import { Close, Exclamation, Success, Info, ChevronRight, GeoWebLogo, Resize, useThemeContext, DragHandle, ArrowLeft, ArrowRight, KeyOption, ArrowUp, ArrowDown, KeyCommand, Options, Delete, VisibilityOff, Visibility } from '@opengeoweb/theme';
|
|
5
5
|
import { useFormContext } from 'react-hook-form';
|
|
6
6
|
import { isEmpty, errorMessages } from '@opengeoweb/form-fields';
|
|
7
|
+
import { throttle } from 'lodash';
|
|
7
8
|
import Draggable from 'react-draggable';
|
|
8
9
|
import { Resizable } from 're-resizable';
|
|
9
|
-
import {
|
|
10
|
+
import { useStore } from 'react-redux';
|
|
10
11
|
|
|
11
12
|
/*! *****************************************************************************
|
|
12
13
|
Copyright (c) Microsoft Corporation.
|
|
@@ -36,35 +37,37 @@ function __rest(s, e) {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
var bgColors = {
|
|
39
|
-
green: '
|
|
40
|
-
grey: '
|
|
41
|
-
purple: '
|
|
42
|
-
red: '
|
|
43
|
-
yellow: '
|
|
40
|
+
green: 'geowebColors.functional.successOutline.fill',
|
|
41
|
+
grey: 'geowebColors.functional.disabledOutline.fill',
|
|
42
|
+
purple: 'geowebColors.functional.summaryOutline.fill',
|
|
43
|
+
red: 'geowebColors.functional.errorOutline.fill',
|
|
44
|
+
yellow: 'geowebColors.functional.warningOutline.fill',
|
|
45
|
+
blue: 'geowebColors.functional.notificationOutline.fill'
|
|
44
46
|
};
|
|
45
47
|
var borderColors = {
|
|
46
|
-
green: '
|
|
47
|
-
grey: '
|
|
48
|
-
purple: '
|
|
49
|
-
red: '
|
|
50
|
-
yellow: '
|
|
48
|
+
green: 'geowebColors.functional.successOutline.borderColor',
|
|
49
|
+
grey: 'geowebColors.functional.disabledOutline.borderColor',
|
|
50
|
+
purple: 'geowebColors.functional.summaryOutline.borderColor',
|
|
51
|
+
red: 'geowebColors.functional.errorOutline.borderColor',
|
|
52
|
+
yellow: 'geowebColors.functional.warningOutline.borderColor',
|
|
53
|
+
blue: 'geowebColors.functional.notificationOutline.borderColor'
|
|
51
54
|
};
|
|
52
55
|
|
|
53
56
|
var tagStyle = function tagStyle(color) {
|
|
54
57
|
// Set color to grey for summary
|
|
55
|
-
var
|
|
58
|
+
var backgroundColor = bgColors[color];
|
|
56
59
|
var borderColor = borderColors[color];
|
|
57
60
|
return {
|
|
58
|
-
backgroundColor:
|
|
61
|
+
backgroundColor: backgroundColor,
|
|
59
62
|
m: 0,
|
|
60
|
-
p: 0
|
|
61
|
-
border:
|
|
63
|
+
p: 0,
|
|
64
|
+
border: '1px solid',
|
|
65
|
+
borderColor: borderColor,
|
|
62
66
|
borderRadius: '4px',
|
|
63
|
-
width: '
|
|
64
|
-
height: '
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
boxSizing: 'content-box'
|
|
67
|
+
width: '120px',
|
|
68
|
+
height: '18px',
|
|
69
|
+
lineHeight: '16px',
|
|
70
|
+
color: 'geowebColors.captions.captionStatus.rgba'
|
|
68
71
|
};
|
|
69
72
|
};
|
|
70
73
|
|
|
@@ -611,6 +614,65 @@ var useDraftFormHelpers = function useDraftFormHelpers() {
|
|
|
611
614
|
};
|
|
612
615
|
};
|
|
613
616
|
|
|
617
|
+
/* *
|
|
618
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
619
|
+
* you may not use this file except in compliance with the License.
|
|
620
|
+
* You may obtain a copy of the License at
|
|
621
|
+
*
|
|
622
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
623
|
+
*
|
|
624
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
625
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
626
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
627
|
+
* See the License for the specific language governing permissions and
|
|
628
|
+
* limitations under the License.
|
|
629
|
+
*
|
|
630
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
631
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
632
|
+
* */
|
|
633
|
+
var useMakeSureContainerStaysInsideWindow = function useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition) {
|
|
634
|
+
var onResizeWindow = React__default.useCallback(function (event) {
|
|
635
|
+
if (!nodeRef.current) return;
|
|
636
|
+
var bbox = nodeRef.current.firstChild.getBoundingClientRect();
|
|
637
|
+
var windowTarget = event.currentTarget;
|
|
638
|
+
if (!windowTarget) return;
|
|
639
|
+
var innerHeight = windowTarget.innerHeight,
|
|
640
|
+
innerWidth = windowTarget.innerWidth;
|
|
641
|
+
var isHorizontallyLarger = bbox.width > innerWidth;
|
|
642
|
+
var isVerticallyLarger = bbox.height > innerHeight; // left screen
|
|
643
|
+
|
|
644
|
+
if (bbox.x < 0 || isHorizontallyLarger) {
|
|
645
|
+
setPosition(Object.assign(Object.assign({}, position), {
|
|
646
|
+
x: position.x - bbox.x
|
|
647
|
+
}));
|
|
648
|
+
} // right screen
|
|
649
|
+
else if (bbox.x + bbox.width >= innerWidth) {
|
|
650
|
+
var diffX = innerWidth - bbox.x - bbox.width;
|
|
651
|
+
setPosition(Object.assign(Object.assign({}, position), {
|
|
652
|
+
x: position.x + diffX
|
|
653
|
+
}));
|
|
654
|
+
} // top screen
|
|
655
|
+
else if (bbox.y < 0 || isVerticallyLarger) {
|
|
656
|
+
setPosition(Object.assign(Object.assign({}, position), {
|
|
657
|
+
y: position.y - bbox.y
|
|
658
|
+
}));
|
|
659
|
+
} // bottom screen
|
|
660
|
+
else if (bbox.y + bbox.height >= innerHeight) {
|
|
661
|
+
var diffY = innerHeight - bbox.y - bbox.height;
|
|
662
|
+
setPosition(Object.assign(Object.assign({}, position), {
|
|
663
|
+
y: position.y + diffY
|
|
664
|
+
}));
|
|
665
|
+
}
|
|
666
|
+
}, [nodeRef, position, setPosition]);
|
|
667
|
+
React__default.useEffect(function () {
|
|
668
|
+
var throttledResize = throttle(onResizeWindow, 100);
|
|
669
|
+
window.addEventListener('resize', throttledResize);
|
|
670
|
+
return function () {
|
|
671
|
+
window.removeEventListener('resize', throttledResize);
|
|
672
|
+
};
|
|
673
|
+
}, [onResizeWindow]);
|
|
674
|
+
};
|
|
675
|
+
|
|
614
676
|
var ConfirmationServiceContext = /*#__PURE__*/React.createContext(Promise.reject);
|
|
615
677
|
var useConfirmationDialog = function useConfirmationDialog() {
|
|
616
678
|
return React.useContext(ConfirmationServiceContext);
|
|
@@ -1668,46 +1730,7 @@ var DraggableComponent = function DraggableComponent(_a) {
|
|
|
1668
1730
|
height: height
|
|
1669
1731
|
});
|
|
1670
1732
|
}, [onChangeSize]);
|
|
1671
|
-
|
|
1672
|
-
if (!nodeRef.current) return;
|
|
1673
|
-
var bbox = nodeRef.current.firstChild.getBoundingClientRect();
|
|
1674
|
-
var windowTarget = event.currentTarget;
|
|
1675
|
-
if (!windowTarget) return;
|
|
1676
|
-
var innerHeight = windowTarget.innerHeight,
|
|
1677
|
-
innerWidth = windowTarget.innerWidth;
|
|
1678
|
-
var isHorizontallyLarger = bbox.width > innerWidth;
|
|
1679
|
-
var isVerticallyLarger = bbox.height > innerHeight; // left screen
|
|
1680
|
-
|
|
1681
|
-
if (bbox.x < 0 || isHorizontallyLarger) {
|
|
1682
|
-
setPosition(Object.assign(Object.assign({}, position), {
|
|
1683
|
-
x: position.x - bbox.x
|
|
1684
|
-
}));
|
|
1685
|
-
} // right screen
|
|
1686
|
-
else if (bbox.x + bbox.width >= innerWidth) {
|
|
1687
|
-
var diffX = innerWidth - bbox.x - bbox.width;
|
|
1688
|
-
setPosition(Object.assign(Object.assign({}, position), {
|
|
1689
|
-
x: position.x + diffX
|
|
1690
|
-
}));
|
|
1691
|
-
} // top screen
|
|
1692
|
-
else if (bbox.y < 0 || isVerticallyLarger) {
|
|
1693
|
-
setPosition(Object.assign(Object.assign({}, position), {
|
|
1694
|
-
y: position.y - bbox.y
|
|
1695
|
-
}));
|
|
1696
|
-
} // bottom screen
|
|
1697
|
-
else if (bbox.y + bbox.height >= innerHeight) {
|
|
1698
|
-
var diffY = innerHeight - bbox.y - bbox.height;
|
|
1699
|
-
setPosition(Object.assign(Object.assign({}, position), {
|
|
1700
|
-
y: position.y + diffY
|
|
1701
|
-
}));
|
|
1702
|
-
}
|
|
1703
|
-
}, [position]);
|
|
1704
|
-
React__default.useEffect(function () {
|
|
1705
|
-
var throttledResize = throttle(onResizeWindow, 100);
|
|
1706
|
-
window.addEventListener('resize', throttledResize);
|
|
1707
|
-
return function () {
|
|
1708
|
-
window.removeEventListener('resize', throttledResize);
|
|
1709
|
-
};
|
|
1710
|
-
}, [onResizeWindow]);
|
|
1733
|
+
useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition);
|
|
1711
1734
|
var toolcontainerId = React__default.useRef(Date.now().toString()).current;
|
|
1712
1735
|
var headerClassName = "header-".concat(toolcontainerId);
|
|
1713
1736
|
return isOpen ? /*#__PURE__*/React__default.createElement(DraggableComponent$1, {
|
|
@@ -2822,6 +2845,28 @@ var TooltipSelect = function TooltipSelect(_a) {
|
|
|
2822
2845
|
}, otherProps)));
|
|
2823
2846
|
};
|
|
2824
2847
|
|
|
2848
|
+
function withEggs(eggs) {
|
|
2849
|
+
return function (Component) {
|
|
2850
|
+
var WithEggs = function WithEggs(props) {
|
|
2851
|
+
var store = useStore();
|
|
2852
|
+
|
|
2853
|
+
var _React$useState = React.useState(function () {
|
|
2854
|
+
return store.addEggs(eggs);
|
|
2855
|
+
}),
|
|
2856
|
+
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
2857
|
+
remover = _React$useState2[0];
|
|
2858
|
+
|
|
2859
|
+
React.useEffect(function () {
|
|
2860
|
+
return remover;
|
|
2861
|
+
}, [remover]);
|
|
2862
|
+
return /*#__PURE__*/React.createElement(Component, Object.assign({}, props));
|
|
2863
|
+
};
|
|
2864
|
+
|
|
2865
|
+
WithEggs.displayName = "withEggs(".concat(Component.displayName || Component.name || 'Component', ")");
|
|
2866
|
+
return WithEggs;
|
|
2867
|
+
};
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2825
2870
|
/* *
|
|
2826
2871
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2827
2872
|
* you may not use this file except in compliance with the License.
|
|
@@ -2884,4 +2929,4 @@ var getWarningMessage = function getWarningMessage(error) {
|
|
|
2884
2929
|
return '';
|
|
2885
2930
|
};
|
|
2886
2931
|
|
|
2887
|
-
export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, ConfirmationDialog, ConfirmationServiceProvider, CustomSlider, CustomToggleButton, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, EnableButton, ErrorBoundary, HIDDEN_INPUT_HELPER_IS_DRAFT, ManagerButton, ManagerDeleteButton, ResizeComponent as Resizable, StatusTag, ToggleMenu, ToolButton, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, calculateDialogSizeAndPosition, getAxiosErrorMessage, getAxiosWarningMessage, getErrorMessage, getInitials, getPosition, getWarningMessage, isAxiosError, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useDialogActions, useDraftFormHelpers, useIsMounted, usePoller, usePreventBrowserClose, usePrevious, useUserMenu };
|
|
2932
|
+
export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, ConfirmationDialog, ConfirmationServiceProvider, CustomSlider, CustomToggleButton, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, EnableButton, ErrorBoundary, HIDDEN_INPUT_HELPER_IS_DRAFT, ManagerButton, ManagerDeleteButton, ResizeComponent as Resizable, StatusTag, ToggleMenu, ToolButton, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, calculateDialogSizeAndPosition, getAxiosErrorMessage, getAxiosWarningMessage, getErrorMessage, getInitials, getPosition, getWarningMessage, isAxiosError, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useDialogActions, useDraftFormHelpers, useIsMounted, useMakeSureContainerStaysInsideWindow, usePoller, usePreventBrowserClose, usePrevious, useUserMenu, withEggs };
|
package/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('@opengeoweb/theme'), require('react-hook-form'), require('@opengeoweb/form-fields'), require('react-draggable'), require('re-resizable'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', '@opengeoweb/theme', 'react-hook-form', '@opengeoweb/form-fields', 'react-draggable', 're-resizable', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Shared = {}, global.React, global.material, global.theme, global.reactHookForm, global.formFields, global.Draggable, global.reResizable, global.
|
|
5
|
-
})(this, (function (exports, React, material, theme, reactHookForm, formFields, Draggable, reResizable,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('@opengeoweb/theme'), require('react-hook-form'), require('@opengeoweb/form-fields'), require('lodash'), require('react-draggable'), require('re-resizable'), require('react-redux')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', '@opengeoweb/theme', 'react-hook-form', '@opengeoweb/form-fields', 'lodash', 'react-draggable', 're-resizable', 'react-redux'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Shared = {}, global.React, global.material, global.theme, global.reactHookForm, global.formFields, global.lodash, global.Draggable, global.reResizable, global.reactRedux));
|
|
5
|
+
})(this, (function (exports, React, material, theme, reactHookForm, formFields, lodash, Draggable, reResizable, reactRedux) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -110,35 +110,37 @@
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
var bgColors = {
|
|
113
|
-
green: '
|
|
114
|
-
grey: '
|
|
115
|
-
purple: '
|
|
116
|
-
red: '
|
|
117
|
-
yellow: '
|
|
113
|
+
green: 'geowebColors.functional.successOutline.fill',
|
|
114
|
+
grey: 'geowebColors.functional.disabledOutline.fill',
|
|
115
|
+
purple: 'geowebColors.functional.summaryOutline.fill',
|
|
116
|
+
red: 'geowebColors.functional.errorOutline.fill',
|
|
117
|
+
yellow: 'geowebColors.functional.warningOutline.fill',
|
|
118
|
+
blue: 'geowebColors.functional.notificationOutline.fill'
|
|
118
119
|
};
|
|
119
120
|
var borderColors = {
|
|
120
|
-
green: '
|
|
121
|
-
grey: '
|
|
122
|
-
purple: '
|
|
123
|
-
red: '
|
|
124
|
-
yellow: '
|
|
121
|
+
green: 'geowebColors.functional.successOutline.borderColor',
|
|
122
|
+
grey: 'geowebColors.functional.disabledOutline.borderColor',
|
|
123
|
+
purple: 'geowebColors.functional.summaryOutline.borderColor',
|
|
124
|
+
red: 'geowebColors.functional.errorOutline.borderColor',
|
|
125
|
+
yellow: 'geowebColors.functional.warningOutline.borderColor',
|
|
126
|
+
blue: 'geowebColors.functional.notificationOutline.borderColor'
|
|
125
127
|
};
|
|
126
128
|
|
|
127
129
|
var tagStyle = function tagStyle(color) {
|
|
128
130
|
// Set color to grey for summary
|
|
129
|
-
var
|
|
131
|
+
var backgroundColor = bgColors[color];
|
|
130
132
|
var borderColor = borderColors[color];
|
|
131
133
|
return {
|
|
132
|
-
backgroundColor:
|
|
134
|
+
backgroundColor: backgroundColor,
|
|
133
135
|
m: 0,
|
|
134
|
-
p: 0
|
|
135
|
-
border:
|
|
136
|
+
p: 0,
|
|
137
|
+
border: '1px solid',
|
|
138
|
+
borderColor: borderColor,
|
|
136
139
|
borderRadius: '4px',
|
|
137
|
-
width: '
|
|
138
|
-
height: '
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
boxSizing: 'content-box'
|
|
140
|
+
width: '120px',
|
|
141
|
+
height: '18px',
|
|
142
|
+
lineHeight: '16px',
|
|
143
|
+
color: 'geowebColors.captions.captionStatus.rgba'
|
|
142
144
|
};
|
|
143
145
|
};
|
|
144
146
|
|
|
@@ -481,6 +483,49 @@
|
|
|
481
483
|
};
|
|
482
484
|
};
|
|
483
485
|
|
|
486
|
+
var useMakeSureContainerStaysInsideWindow = function useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition) {
|
|
487
|
+
var onResizeWindow = React__default["default"].useCallback(function (event) {
|
|
488
|
+
if (!nodeRef.current) return;
|
|
489
|
+
var bbox = nodeRef.current.firstChild.getBoundingClientRect();
|
|
490
|
+
var windowTarget = event.currentTarget;
|
|
491
|
+
if (!windowTarget) return;
|
|
492
|
+
var innerHeight = windowTarget.innerHeight,
|
|
493
|
+
innerWidth = windowTarget.innerWidth;
|
|
494
|
+
var isHorizontallyLarger = bbox.width > innerWidth;
|
|
495
|
+
var isVerticallyLarger = bbox.height > innerHeight; // left screen
|
|
496
|
+
|
|
497
|
+
if (bbox.x < 0 || isHorizontallyLarger) {
|
|
498
|
+
setPosition(__assign(__assign({}, position), {
|
|
499
|
+
x: position.x - bbox.x
|
|
500
|
+
}));
|
|
501
|
+
} // right screen
|
|
502
|
+
else if (bbox.x + bbox.width >= innerWidth) {
|
|
503
|
+
var diffX = innerWidth - bbox.x - bbox.width;
|
|
504
|
+
setPosition(__assign(__assign({}, position), {
|
|
505
|
+
x: position.x + diffX
|
|
506
|
+
}));
|
|
507
|
+
} // top screen
|
|
508
|
+
else if (bbox.y < 0 || isVerticallyLarger) {
|
|
509
|
+
setPosition(__assign(__assign({}, position), {
|
|
510
|
+
y: position.y - bbox.y
|
|
511
|
+
}));
|
|
512
|
+
} // bottom screen
|
|
513
|
+
else if (bbox.y + bbox.height >= innerHeight) {
|
|
514
|
+
var diffY = innerHeight - bbox.y - bbox.height;
|
|
515
|
+
setPosition(__assign(__assign({}, position), {
|
|
516
|
+
y: position.y + diffY
|
|
517
|
+
}));
|
|
518
|
+
}
|
|
519
|
+
}, [nodeRef, position, setPosition]);
|
|
520
|
+
React__default["default"].useEffect(function () {
|
|
521
|
+
var throttledResize = lodash.throttle(onResizeWindow, 100);
|
|
522
|
+
window.addEventListener('resize', throttledResize);
|
|
523
|
+
return function () {
|
|
524
|
+
window.removeEventListener('resize', throttledResize);
|
|
525
|
+
};
|
|
526
|
+
}, [onResizeWindow]);
|
|
527
|
+
};
|
|
528
|
+
|
|
484
529
|
var ConfirmationServiceContext = /*#__PURE__*/React__namespace.createContext(Promise.reject);
|
|
485
530
|
var useConfirmationDialog = function useConfirmationDialog() {
|
|
486
531
|
return React__namespace.useContext(ConfirmationServiceContext);
|
|
@@ -1547,46 +1592,7 @@
|
|
|
1547
1592
|
height: height
|
|
1548
1593
|
});
|
|
1549
1594
|
}, [onChangeSize]);
|
|
1550
|
-
|
|
1551
|
-
if (!nodeRef.current) return;
|
|
1552
|
-
var bbox = nodeRef.current.firstChild.getBoundingClientRect();
|
|
1553
|
-
var windowTarget = event.currentTarget;
|
|
1554
|
-
if (!windowTarget) return;
|
|
1555
|
-
var innerHeight = windowTarget.innerHeight,
|
|
1556
|
-
innerWidth = windowTarget.innerWidth;
|
|
1557
|
-
var isHorizontallyLarger = bbox.width > innerWidth;
|
|
1558
|
-
var isVerticallyLarger = bbox.height > innerHeight; // left screen
|
|
1559
|
-
|
|
1560
|
-
if (bbox.x < 0 || isHorizontallyLarger) {
|
|
1561
|
-
setPosition(__assign(__assign({}, position), {
|
|
1562
|
-
x: position.x - bbox.x
|
|
1563
|
-
}));
|
|
1564
|
-
} // right screen
|
|
1565
|
-
else if (bbox.x + bbox.width >= innerWidth) {
|
|
1566
|
-
var diffX = innerWidth - bbox.x - bbox.width;
|
|
1567
|
-
setPosition(__assign(__assign({}, position), {
|
|
1568
|
-
x: position.x + diffX
|
|
1569
|
-
}));
|
|
1570
|
-
} // top screen
|
|
1571
|
-
else if (bbox.y < 0 || isVerticallyLarger) {
|
|
1572
|
-
setPosition(__assign(__assign({}, position), {
|
|
1573
|
-
y: position.y - bbox.y
|
|
1574
|
-
}));
|
|
1575
|
-
} // bottom screen
|
|
1576
|
-
else if (bbox.y + bbox.height >= innerHeight) {
|
|
1577
|
-
var diffY = innerHeight - bbox.y - bbox.height;
|
|
1578
|
-
setPosition(__assign(__assign({}, position), {
|
|
1579
|
-
y: position.y + diffY
|
|
1580
|
-
}));
|
|
1581
|
-
}
|
|
1582
|
-
}, [position]);
|
|
1583
|
-
React__default["default"].useEffect(function () {
|
|
1584
|
-
var throttledResize = lodash.throttle(onResizeWindow, 100);
|
|
1585
|
-
window.addEventListener('resize', throttledResize);
|
|
1586
|
-
return function () {
|
|
1587
|
-
window.removeEventListener('resize', throttledResize);
|
|
1588
|
-
};
|
|
1589
|
-
}, [onResizeWindow]);
|
|
1595
|
+
useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition);
|
|
1590
1596
|
var toolcontainerId = React__default["default"].useRef(Date.now().toString()).current;
|
|
1591
1597
|
var headerClassName = "header-" + toolcontainerId;
|
|
1592
1598
|
return isOpen ? /*#__PURE__*/React__default["default"].createElement(DraggableComponent$1, {
|
|
@@ -2718,6 +2724,27 @@
|
|
|
2718
2724
|
}, otherProps)));
|
|
2719
2725
|
};
|
|
2720
2726
|
|
|
2727
|
+
function withEggs(eggs) {
|
|
2728
|
+
return function (Component) {
|
|
2729
|
+
var WithEggs = function WithEggs(props) {
|
|
2730
|
+
var store = reactRedux.useStore();
|
|
2731
|
+
|
|
2732
|
+
var _a = __read(React__namespace.useState(function () {
|
|
2733
|
+
return store.addEggs(eggs);
|
|
2734
|
+
}), 1),
|
|
2735
|
+
remover = _a[0];
|
|
2736
|
+
|
|
2737
|
+
React__namespace.useEffect(function () {
|
|
2738
|
+
return remover;
|
|
2739
|
+
}, [remover]);
|
|
2740
|
+
return /*#__PURE__*/React__namespace.createElement(Component, __assign({}, props));
|
|
2741
|
+
};
|
|
2742
|
+
|
|
2743
|
+
WithEggs.displayName = "withEggs(" + (Component.displayName || Component.name || 'Component') + ")";
|
|
2744
|
+
return WithEggs;
|
|
2745
|
+
};
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2721
2748
|
/* *
|
|
2722
2749
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2723
2750
|
* you may not use this file except in compliance with the License.
|
|
@@ -2823,10 +2850,12 @@
|
|
|
2823
2850
|
exports.useDialogActions = useDialogActions;
|
|
2824
2851
|
exports.useDraftFormHelpers = useDraftFormHelpers;
|
|
2825
2852
|
exports.useIsMounted = useIsMounted;
|
|
2853
|
+
exports.useMakeSureContainerStaysInsideWindow = useMakeSureContainerStaysInsideWindow;
|
|
2826
2854
|
exports.usePoller = usePoller;
|
|
2827
2855
|
exports.usePreventBrowserClose = usePreventBrowserClose;
|
|
2828
2856
|
exports.usePrevious = usePrevious;
|
|
2829
2857
|
exports.useUserMenu = useUserMenu;
|
|
2858
|
+
exports.withEggs = withEggs;
|
|
2830
2859
|
|
|
2831
2860
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2832
2861
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare type
|
|
2
|
+
export declare type DraggablePosition = {
|
|
3
3
|
x: number;
|
|
4
4
|
y: number;
|
|
5
5
|
};
|
|
@@ -7,8 +7,8 @@ interface DraggableComponentProps {
|
|
|
7
7
|
nodeRef?: React.RefObject<HTMLElement>;
|
|
8
8
|
children?: React.ReactNode;
|
|
9
9
|
bounds?: 'parent' | string;
|
|
10
|
-
position?:
|
|
11
|
-
onStop?: (event: React.MouseEvent<HTMLElement>, pos:
|
|
10
|
+
position?: DraggablePosition;
|
|
11
|
+
onStop?: (event: React.MouseEvent<HTMLElement>, pos: DraggablePosition) => void;
|
|
12
12
|
onMouseDown?: (event: MouseEvent) => void;
|
|
13
13
|
handle?: string;
|
|
14
14
|
}
|
|
@@ -3,7 +3,27 @@ declare const _default: {
|
|
|
3
3
|
title: string;
|
|
4
4
|
};
|
|
5
5
|
export default _default;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const StatusTagsGWTheme: {
|
|
7
7
|
(): React.ReactElement;
|
|
8
8
|
storyName: string;
|
|
9
9
|
};
|
|
10
|
+
export declare const StatusTagsLight: {
|
|
11
|
+
(): React.ReactElement;
|
|
12
|
+
storyName: string;
|
|
13
|
+
parameters: {
|
|
14
|
+
zeplinLink: {
|
|
15
|
+
name: string;
|
|
16
|
+
link: string;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare const StatusTagsDark: {
|
|
21
|
+
(): React.ReactElement;
|
|
22
|
+
storyName: string;
|
|
23
|
+
parameters: {
|
|
24
|
+
zeplinLink: {
|
|
25
|
+
name: string;
|
|
26
|
+
link: string;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { withEggs } from './WithEggs';
|
package/lib/hooks/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export * from './usePoller/usePoller';
|
|
|
3
3
|
export * from './usePrevious/usePrevious';
|
|
4
4
|
export * from './useIsMounted/useIsMounted';
|
|
5
5
|
export * from './useDraftFormHelpers/useDraftFormHelpers';
|
|
6
|
+
export * from './useMakeSureContainerStaysInsideWindow/useMakeSureContainerStaysInsideWindow';
|
package/lib/hooks/useMakeSureContainerStaysInsideWindow/useMakeSureContainerStaysInsideWindow.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DraggablePosition } from '../../components/DraggableResizable/Draggable';
|
|
3
|
+
export declare const useMakeSureContainerStaysInsideWindow: (nodeRef: React.RefObject<HTMLDivElement>, position: DraggablePosition, setPosition: (position: DraggablePosition) => void) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/shared",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "GeoWeb shared library with shared components and utils for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,15 +14,17 @@
|
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"react": "^17.0.2",
|
|
16
16
|
"@mui/material": "^5.10.8",
|
|
17
|
-
"@opengeoweb/theme": "4.
|
|
17
|
+
"@opengeoweb/theme": "4.4.0",
|
|
18
18
|
"react-draggable": "^4.4.5",
|
|
19
19
|
"re-resizable": "^6.9.0",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
20
|
+
"@redux-eggs/core": "^2.2.0",
|
|
21
|
+
"react-redux": "^8.0.4",
|
|
22
|
+
"@opengeoweb/form-fields": "4.4.0",
|
|
22
23
|
"react-hook-form": "^6.12.1",
|
|
23
24
|
"moment": "^2.29.0",
|
|
24
25
|
"moment-timezone": "^0.5.31",
|
|
25
26
|
"@mui/x-date-pickers": "^5.0.4",
|
|
27
|
+
"lodash": "^4.17.20",
|
|
26
28
|
"axios": "^0.25.0"
|
|
27
29
|
}
|
|
28
30
|
}
|