oolib 2.167.0 → 2.167.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.
@@ -13,7 +13,6 @@ var __assign = (this && this.__assign) || function () {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.useDatePickerState = void 0;
15
15
  var react_1 = require("react");
16
- // handles auto closing of date picker popper in both conditions - withPoral true and false
17
16
  var useDatePickerState = function (_a) {
18
17
  var _b = _a.withPortal, withPortal = _b === void 0 ? false : _b, portalId = _a.portalId, onDateSelect = _a.onDateSelect;
19
18
  var _c = (0, react_1.useState)(false), isOpen = _c[0], setIsOpen = _c[1];
@@ -58,6 +57,32 @@ var useDatePickerState = function (_a) {
58
57
  setIsOpen(function (prev) { return !prev; });
59
58
  }
60
59
  }, [withPortal, handlePortalClick]);
60
+ // Handle clicks outside the datepicker
61
+ var handleClickOutside = (0, react_1.useCallback)(function (e) {
62
+ if (!withPortal) {
63
+ setIsOpen(false);
64
+ return;
65
+ }
66
+ var portalElement = document.getElementById(portalId);
67
+ if (!portalElement)
68
+ return;
69
+ var clickedElement = e.target;
70
+ // Check if click was inside this specific portal
71
+ var isClickInPortal = portalElement.contains(clickedElement);
72
+ var isClickOnDatepickerInput = clickedElement.closest('.react-datepicker-wrapper');
73
+ if (!isClickInPortal && !isClickOnDatepickerInput) {
74
+ setPortalOpen(false);
75
+ cleanupPortalBackdrop(portalId);
76
+ }
77
+ }, [withPortal, portalId, cleanupPortalBackdrop]);
78
+ (0, react_1.useEffect)(function () {
79
+ if (withPortal && portalOpen) {
80
+ document.addEventListener('mousedown', handleClickOutside);
81
+ return function () {
82
+ document.removeEventListener('mousedown', handleClickOutside);
83
+ };
84
+ }
85
+ }, [withPortal, portalOpen, handleClickOutside]);
61
86
  (0, react_1.useEffect)(function () {
62
87
  return function () {
63
88
  if (withPortal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.167.0",
3
+ "version": "2.167.1",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",