PageSourceSearch

https://www.thiqa.ae/portal/assets/react-outside-click-handler-EW9C_Jp7.js

js thiqa.ae collected 2026-10-01 14:49:25 UTC 8,808 bytes, 231 lines download raw bytes

1import { r as reactExports, g as getDefaultExportFromCjs } from "./react-CuY1Cvos.js";
2import { p as propTypesExports } from "./prop-types-BnWbMLOC.js";
3import { r as require$$3 } from "./consolidated-events-DfwJHnSn.js";
4import { o as object_values } from "./object.values-BB-WjARL.js";
5import { d as document_contains } from "./document.contains-BtvDwDg3.js";
6var OutsideClickHandler$1 = {};
7function noop() {
8  return null;
9}
10noop.isRequired = noop;
11var mocks = {
12  forbidExtraProps: Object
13};
14var airbnbPropTypes = mocks;
15(function(exports) {
16  Object.defineProperty(exports, "__esModule", {
17    value: true
18  });
19  var _createClass = /* @__PURE__ */ function() {
20    function defineProperties(target, props) {
21      for (var i = 0; i < props.length; i++) {
22        var descriptor = props[i];
23        descriptor.enumerable = descriptor.enumerable || false;
24        descriptor.configurable = true;
25        if ("value" in descriptor)
26          descriptor.writable = true;
27        Object.defineProperty(target, descriptor.key, descriptor);
28      }
29    }
30    return function(Constructor, protoProps, staticProps) {
31      if (protoProps)
32        defineProperties(Constructor.prototype, protoProps);
33      if (staticProps)
34        defineProperties(Constructor, staticProps);
35      return Constructor;
36    };
37  }();
38  var _react = reactExports;
39  var _react2 = _interopRequireDefault(_react);
40  var _propTypes = propTypesExports;
41  var _propTypes2 = _interopRequireDefault(_propTypes);
42  var _airbnbPropTypes = airbnbPropTypes;
43  var _consolidatedEvents = require$$3;
44  var _object = object_values;
45  var _object2 = _interopRequireDefault(_object);
46  var _document = document_contains;
47  var _document2 = _interopRequireDefault(_document);
48  function _interopRequireDefault(obj) {
49    return obj && obj.__esModule ? obj : { "default": obj };
50  }
51  function _classCallCheck(instance, Constructor) {
52    if (!(instance instanceof Constructor)) {
53      throw new TypeError("Cannot call a class as a function");
54    }
55  }
56  function _possibleConstructorReturn(self, call) {
57    if (!self) {
58      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
59    }
60    return call && (typeof call === "object" || typeof call === "function") ? call : self;
61  }
62  function _inherits(subClass, superClass) {
63    if (typeof superClass !== "function" && superClass !== null) {
64      throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
65    }
66    subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });
67    if (superClass)
68      Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
69  }
70  var DISPLAY = {
71    BLOCK: "block",
72    FLEX: "flex",
73    INLINE: "inline",
74    INLINE_BLOCK: "inline-block",
75    CONTENTS: "contents"
76  };
77  var propTypes = (0, _airbnbPropTypes.forbidExtraProps)({
78    children: _propTypes2["default"].node.isRequired,
79    onOutsideClick: _propTypes2["default"].func.isRequired,
80    disabled: _propTypes2["default"].bool,
81    useCapture: _propTypes2["default"].bool,
82    display: _propTypes2["default"].oneOf((0, _object2["default"])(DISPLAY))
83  });
84  var defaultProps = {
85    disabled: false,
86    // `useCapture` is set to true by default so that a `stopPropagation` in the
87    // children will not prevent all outside click handlers from firing - maja
88    useCapture: true,
89    display: DISPLAY.BLOCK
90  };
91  var OutsideClickHandler2 = function(_React$Component) {
92    _inherits(OutsideClickHandler3, _React$Component);
93    function OutsideClickHandler3() {
94      var _ref;
95      _classCallCheck(this, OutsideClickHandler3);
96      for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
97        args[_key] = arguments[_key];
98      }
99      var _this = _possibleConstructorReturn(this, (_ref = OutsideClickHandler3.__proto__ || Object.getPrototypeOf(OutsideClickHandler3)).call.apply(_ref, [this].concat(args)));
100      _this.onMouseDown = _this.onMouseDown.bind(_this);
101      _this.onMouseUp = _this.onMouseUp.bind(_this);
102      _this.setChildNodeRef = _this.setChildNodeRef.bind(_this);
103      return _this;
104    }
105    _createClass(OutsideClickHandler3, [{
106      key: "componentDidMount",
107      value: /* @__PURE__ */ function() {
108        function componentDidMount() {
109          var _props = this.props, disabled = _props.disabled, useCapture = _props.useCapture;
110          if (!disabled)
111            this.addMouseDownEventListener(useCapture);
112        }
113        return componentDidMount;
114      }()
115    }, {
116      key: "componentDidUpdate",
117      value: /* @__PURE__ */ function() {
118        function componentDidUpdate(_ref2) {
119          var prevDisabled = _ref2.disabled;
120          var _props2 = this.props, disabled = _props2.disabled, useCapture = _props2.useCapture;
121          if (prevDisabled !== disabled) {
122            if (disabled) {
123              this.removeEventListeners();
124            } else {
125              this.addMouseDownEventListener(useCapture);
126            }
127          }
128        }
129        return componentDidUpdate;
130      }()
131    }, {
132      key: "componentWillUnmount",
133      value: /* @__PURE__ */ function() {
134        function componentWillUnmount() {
135          this.removeEventListeners();
136        }
137        return componentWillUnmount;
138      }()
139      // Use mousedown/mouseup to enforce that clicks remain outside the root's
140      // descendant tree, even when dragged. This should also get triggered on
141      // touch devices.
142    }, {
143      key: "onMouseDown",
144      value: /* @__PURE__ */ function() {
145        function onMouseDown(e) {
146          var useCapture = this.props.useCapture;
147          var isDescendantOfRoot = this.childNode && (0, _document2["default"])(this.childNode, e.target);
148          if (!isDescendantOfRoot) {
149            if (this.removeMouseUp) {
150              this.removeMouseUp();
151              this.removeMouseUp = null;
152            }
153            this.removeMouseUp = (0, _consolidatedEvents.addEventListener)(document, "mouseup", this.onMouseUp, { capture: useCapture });
154          }
155        }
156        return onMouseDown;
157      }()
158      // Use mousedown/mouseup to enforce that clicks remain outside the root's
159      // descendant tree, even when dragged. This should also get triggered on
160      // touch devices.
161    }, {
162      key: "onMouseUp",
163      value: /* @__PURE__ */ function() {
164        function onMouseUp(e) {
165          var onOutsideClick = this.props.onOutsideClick;
166          var isDescendantOfRoot = this.childNode && (0, _document2["default"])(this.childNode, e.target);
167          if (this.removeMouseUp) {
168            this.removeMouseUp();
169            this.removeMouseUp = null;
170          }
171          if (!isDescendantOfRoot) {
172            onOutsideClick(e);
173          }
174        }
175        return onMouseUp;
176      }()
177    }, {
178      key: "setChildNodeRef",
179      value: /* @__PURE__ */ function() {
180        function setChildNodeRef(ref) {
181          this.childNode = ref;
182        }
183        return setChildNodeRef;
184      }()
185    }, {
186      key: "addMouseDownEventListener",
187      value: /* @__PURE__ */ function() {
188        function addMouseDownEventListener(useCapture) {
189          this.removeMouseDown = (0, _consolidatedEvents.addEventListener)(document, "mousedown", this.onMouseDown, { capture: useCapture });
190        }
191        return addMouseDownEventListener;
192      }()
193    }, {
194      key: "removeEventListeners",
195      value: /* @__PURE__ */ function() {
196        function removeEventListeners() {
197          if (this.removeMouseDown)
198            this.removeMouseDown();
199          if (this.removeMouseUp)
200            this.removeMouseUp();
201        }
202        return removeEventListeners;
203      }()
204    }, {
205      key: "render",
206      value: /* @__PURE__ */ function() {
207        function render() {
208          var _props3 = this.props, children = _props3.children, display = _props3.display;
209          return _react2["default"].createElement(
210            "div",
211            {
212              ref: this.setChildNodeRef,
213              style: display !== DISPLAY.BLOCK && (0, _object2["default"])(DISPLAY).includes(display) ? { display } : void 0
214            },
215            children
216          );
217        }
218        return render;
219      }()
220    }]);
221    return OutsideClickHandler3;
222  }(_react2["default"].Component);
223  exports["default"] = OutsideClickHandler2;
224  OutsideClickHandler2.propTypes = propTypes;
225  OutsideClickHandler2.defaultProps = defaultProps;
226})(OutsideClickHandler$1);
227var reactOutsideClickHandler = OutsideClickHandler$1;
228const OutsideClickHandler = /* @__PURE__ */ getDefaultExportFromCjs(reactOutsideClickHandler);
229export {
230  OutsideClickHandler as O
231};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.