@woosmap/ui 2.62.0 → 2.63.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@woosmap/ui",
3
- "version": "2.62.0",
3
+ "version": "2.63.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/WebGeoServices/ui.git"
@@ -58,11 +58,11 @@ function withLayer(MyComponent) {
58
58
  function close() {
59
59
  setOpen(false);
60
60
  }
61
- const { forwardedRef, container, placement, ...rest } = props;
61
+ const { forwardedRef, container, placement, disableClickOutside, ...rest } = props;
62
62
  const { renderLayer, triggerProps, layerProps, arrowProps } = useLayer({
63
63
  isOpen,
64
64
  container,
65
- onOutsideClick: close, // close the menu when the user clicks outside
65
+ onOutsideClick: disableClickOutside ? null : close, // close the menu when the user clicks outside
66
66
  onDisappear: close, // close the menu when the menu gets scrolled out of sight
67
67
  overflowContainer: true, // keep the menu positioned inside the container
68
68
  auto: true, // automatically find the best placement
@@ -87,11 +87,13 @@ function withLayer(MyComponent) {
87
87
  WrappedComponent.defaultProps = {
88
88
  container: null,
89
89
  placement: 'bottom-center',
90
+ disableClickOutside: false,
90
91
  };
91
92
  WrappedComponent.propTypes = {
92
93
  forwardedRef: PropTypes.object.isRequired,
93
94
  container: PropTypes.string,
94
95
  placement: PropTypes.string,
96
+ disableClickOutside: PropTypes.bool,
95
97
  };
96
98
  return React.forwardRef((props, ref) => <WrappedComponent {...props} forwardedRef={ref} />);
97
99
  }
@@ -3,6 +3,12 @@ import Popover from './Popover';
3
3
  import ConfirmationPopover from './ConfirmationPopover';
4
4
  import Button from '../Button/Button';
5
5
 
6
+ const toggle = (ref) => {
7
+ if (ref.current) {
8
+ ref.current.toggle();
9
+ }
10
+ };
11
+
6
12
  const Story = {
7
13
  title: 'base/Popover',
8
14
  component: Popover,
@@ -12,15 +18,10 @@ export default Story;
12
18
 
13
19
  const Template = () => {
14
20
  const popoverRef = React.createRef();
15
- function toggle() {
16
- if (popoverRef.current) {
17
- popoverRef.current.toggle();
18
- }
19
- }
20
21
  return (
21
22
  <div style={{ paddingLeft: '50px' }}>
22
23
  <Popover ref={popoverRef} content="My popover">
23
- <Button label="my button" onClick={toggle} />
24
+ <Button label="my button" onClick={() => toggle(popoverRef)} />
24
25
  </Popover>
25
26
  </div>
26
27
  );
@@ -34,15 +35,10 @@ const TemplateConfirmPopover = (args) => {
34
35
  const confirmCb = () => {
35
36
  // confirm action
36
37
  };
37
- function toggleConfirm() {
38
- if (popoverConfirmRef.current) {
39
- popoverConfirmRef.current.toggle();
40
- }
41
- }
42
38
  return (
43
39
  <div style={{ paddingLeft: '50px' }}>
44
40
  <ConfirmationPopover ref={popoverConfirmRef} text={text} confirmCb={confirmCb}>
45
- <Button label="my button" onClick={toggleConfirm} />
41
+ <Button label="my button" onClick={() => toggle(popoverConfirmRef)} />
46
42
  </ConfirmationPopover>
47
43
  </div>
48
44
  );
@@ -51,3 +47,16 @@ export const ConfirmationPopoverTemplate = TemplateConfirmPopover.bind({});
51
47
  ConfirmationPopoverTemplate.args = {
52
48
  text: 'Do you confirm?',
53
49
  };
50
+
51
+ const TemplatePopoverNoClickOutside = () => {
52
+ const popoverRef = React.createRef();
53
+
54
+ return (
55
+ <div style={{ paddingLeft: '50px' }}>
56
+ <Popover ref={popoverRef} content="My popover, no click outside" disableClickOutside>
57
+ <Button label="my button 2" onClick={() => toggle(popoverRef)} />
58
+ </Popover>
59
+ </div>
60
+ );
61
+ };
62
+ export const TemplatePopoverClickOutsideDisabled = TemplatePopoverNoClickOutside.bind({});