@majoo-ui/react 3.0.0 → 3.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.
@@ -7,7 +7,7 @@ import 'core-js/modules/es.iterator.map.js';
7
7
  import 'core-js/modules/es.iterator.reduce.js';
8
8
  import { __rest, __awaiter } from 'tslib';
9
9
  import * as React from 'react';
10
- import { useState, useRef, useCallback, useEffect, createElement } from 'react';
10
+ import { useState, useRef, useEffect, useCallback, createElement } from 'react';
11
11
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
12
12
  import { renderToString } from 'react-dom/server';
13
13
  import Downshift from 'downshift';
@@ -411,6 +411,24 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
411
411
  const selectBoxRef = useRef(null);
412
412
  const scrollerRef = useRef(null);
413
413
  const downshiftMenuRef = useRef();
414
+ const footerRef = useRef(null);
415
+ const isReleaseInFooterRef = useRef(false);
416
+ const hasFooter = typeof renderFooter === 'function';
417
+ // Captured on document so it is set before Downshift's own mouseup/touchend listeners on window read it.
418
+ useEffect(() => {
419
+ if (!open || !hasFooter || isMobile) return undefined;
420
+ const handleRelease = event => {
421
+ var _a;
422
+ isReleaseInFooterRef.current = Boolean((_a = footerRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target));
423
+ };
424
+ document.addEventListener('mouseup', handleRelease, true);
425
+ document.addEventListener('touchend', handleRelease, true);
426
+ return () => {
427
+ isReleaseInFooterRef.current = false;
428
+ document.removeEventListener('mouseup', handleRelease, true);
429
+ document.removeEventListener('touchend', handleRelease, true);
430
+ };
431
+ }, [open, hasFooter, isMobile]);
414
432
  // The desktop menu shows only while Downshift's isOpen and the Popover's own open state are both true,
415
433
  // and each one opens and closes itself: the search input toggles Downshift only while it is closed, the
416
434
  // Popover trigger toggles on every click and also closes on outside press or ancestor scroll. Kept as two
@@ -553,6 +571,11 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
553
571
  return {
554
572
  isOpen: state.isOpen
555
573
  };
574
+ // The desktop footer sits outside getMenuProps, so Downshift takes a press on it for an outside click;
575
+ // closing here unmounts the Popover before the footer's click fires. The footer closes the menu itself.
576
+ case Downshift.stateChangeTypes.mouseUp:
577
+ case Downshift.stateChangeTypes.touchEnd:
578
+ return isReleaseInFooterRef.current ? {} : changes;
556
579
  // Downshift wipes selectedItem on Escape whenever its own isOpen is already false,
557
580
  // firing onChange(null) on consumers that never asked to clear the selection.
558
581
  // Escape only closes the menu and restores the label of the current selection.
@@ -741,6 +764,8 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
741
764
  width: '100%'
742
765
  },
743
766
  children: [child, renderFooter && typeof renderFooter === 'function' && jsx(StyledFooter, {
767
+ ref: footerRef,
768
+ onClick: () => closeMenu(),
744
769
  children: renderFooter === null || renderFooter === void 0 ? void 0 : renderFooter()
745
770
  })]
746
771
  }),
package/index.esm.css CHANGED
@@ -1,3 +1,7 @@
1
+ .recharts-pie-sector {
2
+ outline: none;
3
+ }
4
+
1
5
  .rdw-option-wrapper {
2
6
  padding: 5px;
3
7
  min-width: 25px;
@@ -1289,7 +1293,3 @@
1289
1293
  height: 24px;
1290
1294
  }
1291
1295
  }
1292
-
1293
- .recharts-pie-sector {
1294
- outline: none;
1295
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@majoo-ui/react",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "main": "./index.esm.js",
5
5
  "sideEffects": [
6
6
  "*.css",