@ainias42/react-bootstrap-mobile 0.1.18 → 0.1.20

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * @ainias42/react-bootstrap-mobile v0.1.17
3
+ * @ainias42/react-bootstrap-mobile v0.1.19
4
4
  * git+https://github.com/Ainias/Bootstrap-React-Mobile.git
5
5
  * Copyright (c) Silas Günther and project contributors.
6
6
  * This source code is licensed under the MIT license found in the
@@ -22277,6 +22277,266 @@ function useSharedSelectedColor(key, numberSavedColors = 15) {
22277
22277
  addColor
22278
22278
  };
22279
22279
  }
22280
+ // EXTERNAL MODULE: ./src/Components/Menu/menu.scss
22281
+ var menu = __webpack_require__(1266);
22282
+ var menu_default = /*#__PURE__*/__webpack_require__.n(menu);
22283
+ ;// CONCATENATED MODULE: ./src/helper/withRenderBrowserOnly.tsx
22284
+ var withRenderBrowserOnly_rest = undefined && undefined.__rest || function (s, e) {
22285
+ var t = {};
22286
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
22287
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22288
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
22289
+ }
22290
+ return t;
22291
+ };
22292
+
22293
+ function withRenderBrowserOnly(Component) {
22294
+ const displayName = `WithRenderBrowserOnly(${Component.displayName || Component.name})`;
22295
+ const HocComponent = (_a, ref) => {
22296
+ var {
22297
+ children
22298
+ } = _a,
22299
+ props = withRenderBrowserOnly_rest(_a, ["children"]);
22300
+ const [isBrowser, setIsBrowser] = (0,external_react_.useState)(false);
22301
+ (0,external_react_.useEffect)(() => setIsBrowser(true), []);
22302
+ if (!isBrowser) {
22303
+ return null;
22304
+ }
22305
+ const newProps = props;
22306
+ if (ref && Object.keys(ref).length > 0) {
22307
+ newProps.ref = ref;
22308
+ }
22309
+ return (
22310
+ /*#__PURE__*/
22311
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
22312
+ // @ts-ignore
22313
+ external_react_default().createElement(Component, newProps, children)
22314
+ );
22315
+ };
22316
+ HocComponent.displayName = displayName;
22317
+ return HocComponent;
22318
+ }
22319
+ ;// CONCATENATED MODULE: ./src/WindowContext/WindowContext.ts
22320
+
22321
+ const WindowContext = /*#__PURE__*/external_react_default().createContext(undefined);
22322
+ WindowContext.displayName = 'WindowContext';
22323
+ function useWindow() {
22324
+ var _a;
22325
+ return (_a = (0,external_react_.useContext)(WindowContext)) !== null && _a !== void 0 ? _a : typeof window !== 'undefined' ? window : undefined;
22326
+ }
22327
+ ;// CONCATENATED MODULE: ./src/Components/Menu/MenuCloseContext.ts
22328
+
22329
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
22330
+ const MenuCloseContext = /*#__PURE__*/external_react_default().createContext(() => {});
22331
+ const MenuCloseContextProvider = MenuCloseContext.Provider;
22332
+ function useMenuClose() {
22333
+ return (0,external_react_.useContext)(MenuCloseContext);
22334
+ }
22335
+ ;// CONCATENATED MODULE: ./src/Components/Menu/MenuItem.tsx
22336
+ function MenuItem_extends() { MenuItem_extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return MenuItem_extends.apply(this, arguments); }
22337
+ var MenuItem_rest = undefined && undefined.__rest || function (s, e) {
22338
+ var t = {};
22339
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
22340
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22341
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
22342
+ }
22343
+ return t;
22344
+ };
22345
+
22346
+
22347
+
22348
+
22349
+
22350
+
22351
+
22352
+
22353
+
22354
+ const MenuItem = withMemo(function MenuItem(_a) {
22355
+ // Refs
22356
+ var {
22357
+ children,
22358
+ icon,
22359
+ iconColor,
22360
+ className,
22361
+ onClick,
22362
+ onMouseEnter,
22363
+ onMouseLeave,
22364
+ active,
22365
+ item,
22366
+ disabled = false
22367
+ } = _a,
22368
+ props = MenuItem_rest(_a, ["children", "icon", "iconColor", "className", "onClick", "onMouseEnter", "onMouseLeave", "active", "item", "disabled"]);
22369
+ // States/Variables/Selectors
22370
+ const close = useMenuClose();
22371
+ // Dispatch
22372
+ // Callbacks
22373
+ const onClickInner = (0,external_react_.useCallback)(() => {
22374
+ if (disabled) {
22375
+ return;
22376
+ }
22377
+ onClick(item);
22378
+ close();
22379
+ }, [close, disabled, item, onClick]);
22380
+ const onMouseEnterInner = (0,external_react_.useCallback)(() => {
22381
+ if (disabled) {
22382
+ return;
22383
+ }
22384
+ onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter(item);
22385
+ }, [disabled, item, onMouseEnter]);
22386
+ const onMouseLeaveInner = (0,external_react_.useCallback)(() => {
22387
+ if (disabled) {
22388
+ return;
22389
+ }
22390
+ onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(item);
22391
+ }, [disabled, item, onMouseLeave]);
22392
+ // Effects
22393
+ // Other
22394
+ const childElements = typeof children === "string" ? /*#__PURE__*/external_react_default().createElement(tmp, null, children) : children;
22395
+ // RenderFunctions
22396
+ return /*#__PURE__*/external_react_default().createElement(ClickableMemo, MenuItem_extends({
22397
+ className: classnames_default()((menu_default()).item, {
22398
+ [(menu_default()).disabled]: disabled,
22399
+ [(menu_default()).active]: active
22400
+ }, className)
22401
+ }, props, {
22402
+ onClick: onClickInner,
22403
+ onMouseEnter: onMouseEnterInner,
22404
+ onMouseLeave: onMouseLeaveInner,
22405
+ __allowChildren: "all"
22406
+ }), /*#__PURE__*/external_react_default().createElement(BlockMemo, {
22407
+ className: classnames_default()((menu_default()).itemChildren)
22408
+ }, !!icon && /*#__PURE__*/external_react_default().createElement(Icon, {
22409
+ icon: icon,
22410
+ color: iconColor,
22411
+ className: (menu_default()).icon
22412
+ }), childElements));
22413
+ }, (menu_default()), "text");
22414
+ ;// CONCATENATED MODULE: external "react-dom"
22415
+ const external_react_dom_namespaceObject = require("react-dom");
22416
+ ;// CONCATENATED MODULE: ./src/Components/Menu/Menu.tsx
22417
+
22418
+
22419
+
22420
+
22421
+
22422
+
22423
+
22424
+
22425
+
22426
+
22427
+
22428
+ const MENU_CONTAINER_CLASS = "rbm-menu-container";
22429
+ const Menu = withMemo(withRenderBrowserOnly(function Menu({
22430
+ className,
22431
+ style,
22432
+ items,
22433
+ y,
22434
+ x,
22435
+ isOpen,
22436
+ onClose,
22437
+ children,
22438
+ offsetY = 0,
22439
+ offsetX = 0
22440
+ }) {
22441
+ // Variables
22442
+ // Refs
22443
+ const menuRef = (0,external_react_.useRef)(null);
22444
+ const window = useWindow();
22445
+ // States
22446
+ const [portalContainer] = (0,external_react_.useState)(() => {
22447
+ return document.createElement('div');
22448
+ });
22449
+ const [innerX, setInnerX] = (0,external_react_.useState)(x);
22450
+ const [innerY, setInnerY] = (0,external_react_.useState)(y);
22451
+ // Selectors
22452
+ // Callbacks
22453
+ // Effects
22454
+ (0,external_react_.useEffect)(() => {
22455
+ if (isOpen) {
22456
+ const listener = e => {
22457
+ var _a;
22458
+ if (!((_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
22459
+ onClose();
22460
+ }
22461
+ };
22462
+ window === null || window === void 0 ? void 0 : window.addEventListener('mousedown', listener, {
22463
+ capture: true
22464
+ });
22465
+ return () => window === null || window === void 0 ? void 0 : window.removeEventListener('mousedown', listener, {
22466
+ capture: true
22467
+ });
22468
+ }
22469
+ return undefined;
22470
+ }, [isOpen, onClose, window]);
22471
+ (0,external_react_.useLayoutEffect)(() => {
22472
+ if (!isOpen) {
22473
+ return;
22474
+ }
22475
+ let elem = window === null || window === void 0 ? void 0 : window.document.body.querySelector("." + MENU_CONTAINER_CLASS);
22476
+ if (!elem) {
22477
+ elem = window === null || window === void 0 ? void 0 : window.document.body;
22478
+ }
22479
+ elem === null || elem === void 0 ? void 0 : elem.appendChild(portalContainer);
22480
+ }, [isOpen, portalContainer, window === null || window === void 0 ? void 0 : window.document.body]);
22481
+ (0,external_react_.useLayoutEffect)(() => {
22482
+ var _a;
22483
+ if (!menuRef.current) {
22484
+ return;
22485
+ }
22486
+ const width = parseFloat(getComputedStyle(menuRef.current).width);
22487
+ let newX = x;
22488
+ if (newX > ((_a = window === null || window === void 0 ? void 0 : window.innerWidth) !== null && _a !== void 0 ? _a : 0) - width) {
22489
+ newX -= width + offsetX;
22490
+ }
22491
+ if (newX < 0) {
22492
+ newX = 0;
22493
+ }
22494
+ setInnerX(newX);
22495
+ }, [offsetX, window === null || window === void 0 ? void 0 : window.innerWidth, x]);
22496
+ (0,external_react_.useLayoutEffect)(() => {
22497
+ var _a;
22498
+ if (!menuRef.current) {
22499
+ return;
22500
+ }
22501
+ const height = parseFloat(getComputedStyle(menuRef.current).height);
22502
+ let newY = y;
22503
+ if (newY > ((_a = window === null || window === void 0 ? void 0 : window.innerHeight) !== null && _a !== void 0 ? _a : 0) - height) {
22504
+ newY -= height + offsetY;
22505
+ }
22506
+ if (newY < 0) {
22507
+ newY = 0;
22508
+ }
22509
+ setInnerY(newY);
22510
+ }, [offsetY, window === null || window === void 0 ? void 0 : window.innerHeight, y]);
22511
+ // Other
22512
+ // Render Functions
22513
+ if (!isOpen) {
22514
+ return null;
22515
+ }
22516
+ return /*#__PURE__*/external_react_.createElement(external_react_.Fragment, null, /*#__PURE__*/(0,external_react_dom_namespaceObject.createPortal)( /*#__PURE__*/external_react_.createElement(MenuCloseContextProvider, {
22517
+ value: onClose
22518
+ }, /*#__PURE__*/external_react_.createElement(BlockMemo, {
22519
+ className: classnames_default()(className, (menu_default()).menu),
22520
+ style: Object.assign(Object.assign({}, style), {
22521
+ top: innerY,
22522
+ left: innerX
22523
+ }),
22524
+ ref: menuRef,
22525
+ __allowChildren: "all"
22526
+ }, items === null || items === void 0 ? void 0 : items.map(item => {
22527
+ const icon = !!item.icon && typeof item.icon === "object" && "color" in item.icon ? item.icon.icon : item.icon;
22528
+ const iconColor = !!item.icon && typeof item.icon === "object" && "color" in item.icon ? item.icon.color : undefined;
22529
+ return /*#__PURE__*/external_react_.createElement(MenuItem, {
22530
+ key: item.key,
22531
+ onClick: item.callback,
22532
+ className: classnames_default()((menu_default()).item, item.className),
22533
+ onMouseEnter: item.onMouseEnter,
22534
+ icon: icon,
22535
+ iconColor: iconColor,
22536
+ onMouseLeave: item.onMouseLeave
22537
+ }, item.label);
22538
+ }), children)), portalContainer));
22539
+ }), (menu_default()));
22280
22540
  ;// CONCATENATED MODULE: ./src/Components/FormElements/ColorInput/ColorInput.tsx
22281
22541
  var ColorInput_rest = undefined && undefined.__rest || function (s, e) {
22282
22542
  var t = {};
@@ -22293,6 +22553,7 @@ var ColorInput_rest = undefined && undefined.__rest || function (s, e) {
22293
22553
 
22294
22554
 
22295
22555
 
22556
+
22296
22557
  function convertToHex(color, disableAlpha) {
22297
22558
  let newColor = `#${color.r.toString(16).padStart(2, '0')}${color.g.toString(16).padStart(2, '0')}${color.b.toString(16).padStart(2, '0')}`;
22298
22559
  if (color.a !== undefined && !disableAlpha) {
@@ -22314,11 +22575,11 @@ function ColorInput(_a) {
22314
22575
  onClose,
22315
22576
  disableAlpha,
22316
22577
  presetColors,
22317
- sharedColorKey
22578
+ sharedColorKey = "default",
22579
+ disabled
22318
22580
  } = _a,
22319
- otherProps = ColorInput_rest(_a, ["defaultValue", "value", "label", "onChangeColor", "onChangeColorComplete", "onOpen", "onClose", "disableAlpha", "presetColors", "sharedColorKey"]);
22581
+ otherProps = ColorInput_rest(_a, ["defaultValue", "value", "label", "onChangeColor", "onChangeColorComplete", "onOpen", "onClose", "disableAlpha", "presetColors", "sharedColorKey", "disabled"]);
22320
22582
  // Refs
22321
- const containerRef = (0,external_react_.useRef)(null);
22322
22583
  const modalRef = (0,external_react_.useRef)(null);
22323
22584
  // States
22324
22585
  const [color, setColor] = (0,external_react_.useState)((_b = value !== null && value !== void 0 ? value : defaultValue) !== null && _b !== void 0 ? _b : '#000000FF');
@@ -22331,6 +22592,7 @@ function ColorInput(_a) {
22331
22592
  colors,
22332
22593
  addColor
22333
22594
  } = useSharedSelectedColor(sharedColorKey);
22595
+ const realIsOpen = disabled !== true && isOpen;
22334
22596
  const colVal = value !== null && value !== void 0 ? value : color;
22335
22597
  // Selectors
22336
22598
  // Callbacks
@@ -22350,21 +22612,22 @@ function ColorInput(_a) {
22350
22612
  onChangeColorComplete(hexColor);
22351
22613
  }
22352
22614
  }, [disableAlpha, onChangeColorComplete]);
22353
- const onContainerClick = (0,external_react_.useCallback)(e => {
22354
- if (e.target === (containerRef === null || containerRef === void 0 ? void 0 : containerRef.current)) {
22355
- setIsOpen(false);
22356
- addColor(colVal);
22357
- onClose === null || onClose === void 0 ? void 0 : onClose(colVal);
22358
- }
22615
+ const onMenuClose = (0,external_react_.useCallback)(() => {
22616
+ setIsOpen(false);
22617
+ addColor(colVal);
22618
+ onClose === null || onClose === void 0 ? void 0 : onClose(colVal);
22359
22619
  }, [addColor, colVal, onClose]);
22360
22620
  const openElement = (0,external_react_.useCallback)(e => {
22621
+ if (disabled) {
22622
+ return;
22623
+ }
22361
22624
  setIsOpen(true);
22362
22625
  setPosition({
22363
22626
  x: e.clientX,
22364
22627
  y: e.clientY
22365
22628
  });
22366
22629
  onOpen === null || onOpen === void 0 ? void 0 : onOpen(colVal);
22367
- }, [colVal, onOpen]);
22630
+ }, [colVal, disabled, onOpen]);
22368
22631
  // Effects
22369
22632
  (0,external_react_.useLayoutEffect)(() => {
22370
22633
  if (!modalRef.current) {
@@ -22373,34 +22636,30 @@ function ColorInput(_a) {
22373
22636
  const dimension = modalRef.current.getBoundingClientRect();
22374
22637
  if (dimension.right > window.innerWidth || dimension.bottom > window.innerHeight) {
22375
22638
  const newPosition = {
22376
- x: Math.max(0, Math.min(window.innerWidth - dimension.width, position.x)),
22377
- y: Math.max(0, Math.min(window.innerHeight - dimension.height, position.y))
22639
+ x: Math.max(0, Math.min(window.innerWidth - dimension.width - 3, position.x)),
22640
+ y: Math.max(0, Math.min(window.innerHeight - dimension.height - 3, position.y))
22378
22641
  };
22379
- setPosition(newPosition);
22642
+ if (newPosition.x !== position.x || newPosition.y !== position.y) {
22643
+ setPosition(newPosition);
22644
+ }
22380
22645
  }
22381
22646
  }, [position]);
22382
22647
  // Other
22383
22648
  // Render Functions
22384
22649
  return /*#__PURE__*/external_react_.createElement("span", {
22385
22650
  className: (colorInput_default()).colorInput
22386
- }, isOpen ? /*#__PURE__*/external_react_.createElement("div", {
22387
- onClick: onContainerClick,
22388
- className: (colorInput_default()).modalContainer,
22389
- ref: containerRef
22390
- }, /*#__PURE__*/external_react_.createElement("div", {
22391
- className: (colorInput_default()).modal,
22392
- style: {
22393
- top: position.y,
22394
- left: position.x
22395
- },
22396
- ref: modalRef
22651
+ }, /*#__PURE__*/external_react_.createElement(Menu, {
22652
+ x: position.x,
22653
+ y: position.y,
22654
+ isOpen: realIsOpen,
22655
+ onClose: onMenuClose
22397
22656
  }, /*#__PURE__*/external_react_.createElement(sketch_Sketch, {
22398
22657
  color: colVal,
22399
22658
  onChange: onChange,
22400
22659
  onChangeComplete: onChangeComplete,
22401
22660
  disableAlpha: disableAlpha,
22402
22661
  presetColors: presetColors !== null && presetColors !== void 0 ? presetColors : colors
22403
- }))) : null, /*#__PURE__*/external_react_.createElement("span", {
22662
+ })), /*#__PURE__*/external_react_.createElement("span", {
22404
22663
  onClick: openElement,
22405
22664
  className: (colorInput_default()).label
22406
22665
  }, label), /*#__PURE__*/external_react_.createElement("span", {
@@ -22959,14 +23218,6 @@ const PasswordInput = withForwardRef(function PasswordInput(_a, ref) {
22959
23218
  // EXTERNAL MODULE: ./src/Components/FormElements/SearchSelectInput/seachSelectInput.scss
22960
23219
  var seachSelectInput = __webpack_require__(2399);
22961
23220
  var seachSelectInput_default = /*#__PURE__*/__webpack_require__.n(seachSelectInput);
22962
- ;// CONCATENATED MODULE: ./src/WindowContext/WindowContext.ts
22963
-
22964
- const WindowContext = /*#__PURE__*/external_react_default().createContext(undefined);
22965
- WindowContext.displayName = 'WindowContext';
22966
- function useWindow() {
22967
- var _a;
22968
- return (_a = (0,external_react_.useContext)(WindowContext)) !== null && _a !== void 0 ? _a : typeof window !== 'undefined' ? window : undefined;
22969
- }
22970
23221
  ;// CONCATENATED MODULE: ./src/Components/FormElements/SearchSelectInput/SearchSelectInput.tsx
22971
23222
 
22972
23223
 
@@ -23149,7 +23400,7 @@ const Select = withMemo(function Select(_a) {
23149
23400
  // States
23150
23401
  // Selectors
23151
23402
  // Callbacks
23152
- const onChangeWithData = useListener('onChange', otherProps);
23403
+ const [onChangeWithData, propsWithoutData] = useListenerWithExtractedProps('onChange', otherProps);
23153
23404
  const onChange = (0,external_react_.useCallback)(e => {
23154
23405
  onChangeValue === null || onChangeValue === void 0 ? void 0 : onChangeValue(e.target.value);
23155
23406
  onChangeWithData(e);
@@ -23168,7 +23419,7 @@ const Select = withMemo(function Select(_a) {
23168
23419
  style: style
23169
23420
  }, label ? /*#__PURE__*/external_react_.createElement("span", {
23170
23421
  className: (select_default()).label
23171
- }, label) : null, /*#__PURE__*/external_react_.createElement("select", Select_extends({}, otherProps, {
23422
+ }, label) : null, /*#__PURE__*/external_react_.createElement("select", Select_extends({}, propsWithoutData, {
23172
23423
  className: (select_default()).input,
23173
23424
  onChange: onChange
23174
23425
  }), options.map(option => {
@@ -23609,7 +23860,7 @@ function useKeyUpListener(key, listener, dependencies = [], ignoreFormElements =
23609
23860
  (0,external_react_.useEffect)(() => {
23610
23861
  const lowercaseKey = key.toLowerCase();
23611
23862
  const keyListener = e => {
23612
- if (e.key.toLowerCase() === lowercaseKey && (!ignoreFormElements || !isFormElement(e.target))) {
23863
+ if ((e.key === "Meta" || e.key.toLowerCase() === lowercaseKey) && (!ignoreFormElements || !isFormElement(e.target))) {
23613
23864
  listener(e);
23614
23865
  }
23615
23866
  };
@@ -26624,258 +26875,6 @@ function LoadingArea({
26624
26875
  }
26625
26876
  const LoadingAreaMemo = withMemo(LoadingArea, (loadingArea_default()));
26626
26877
 
26627
- // EXTERNAL MODULE: ./src/Components/Menu/menu.scss
26628
- var menu = __webpack_require__(1266);
26629
- var menu_default = /*#__PURE__*/__webpack_require__.n(menu);
26630
- ;// CONCATENATED MODULE: ./src/helper/withRenderBrowserOnly.tsx
26631
- var withRenderBrowserOnly_rest = undefined && undefined.__rest || function (s, e) {
26632
- var t = {};
26633
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
26634
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
26635
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
26636
- }
26637
- return t;
26638
- };
26639
-
26640
- function withRenderBrowserOnly(Component) {
26641
- const displayName = `WithRenderBrowserOnly(${Component.displayName || Component.name})`;
26642
- const HocComponent = (_a, ref) => {
26643
- var {
26644
- children
26645
- } = _a,
26646
- props = withRenderBrowserOnly_rest(_a, ["children"]);
26647
- const [isBrowser, setIsBrowser] = (0,external_react_.useState)(false);
26648
- (0,external_react_.useEffect)(() => setIsBrowser(true), []);
26649
- if (!isBrowser) {
26650
- return null;
26651
- }
26652
- const newProps = props;
26653
- if (ref && Object.keys(ref).length > 0) {
26654
- newProps.ref = ref;
26655
- }
26656
- return (
26657
- /*#__PURE__*/
26658
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
26659
- // @ts-ignore
26660
- external_react_default().createElement(Component, newProps, children)
26661
- );
26662
- };
26663
- HocComponent.displayName = displayName;
26664
- return HocComponent;
26665
- }
26666
- ;// CONCATENATED MODULE: ./src/Components/Menu/MenuCloseContext.ts
26667
-
26668
- // eslint-disable-next-line @typescript-eslint/no-empty-function
26669
- const MenuCloseContext = /*#__PURE__*/external_react_default().createContext(() => {});
26670
- const MenuCloseContextProvider = MenuCloseContext.Provider;
26671
- function useMenuClose() {
26672
- return (0,external_react_.useContext)(MenuCloseContext);
26673
- }
26674
- ;// CONCATENATED MODULE: ./src/Components/Menu/MenuItem.tsx
26675
- function MenuItem_extends() { MenuItem_extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return MenuItem_extends.apply(this, arguments); }
26676
- var MenuItem_rest = undefined && undefined.__rest || function (s, e) {
26677
- var t = {};
26678
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
26679
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
26680
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
26681
- }
26682
- return t;
26683
- };
26684
-
26685
-
26686
-
26687
-
26688
-
26689
-
26690
-
26691
-
26692
-
26693
- const MenuItem = withMemo(function MenuItem(_a) {
26694
- // Refs
26695
- var {
26696
- children,
26697
- icon,
26698
- iconColor,
26699
- className,
26700
- onClick,
26701
- onMouseEnter,
26702
- onMouseLeave,
26703
- active,
26704
- item,
26705
- disabled = false
26706
- } = _a,
26707
- props = MenuItem_rest(_a, ["children", "icon", "iconColor", "className", "onClick", "onMouseEnter", "onMouseLeave", "active", "item", "disabled"]);
26708
- // States/Variables/Selectors
26709
- const close = useMenuClose();
26710
- // Dispatch
26711
- // Callbacks
26712
- const onClickInner = (0,external_react_.useCallback)(() => {
26713
- if (disabled) {
26714
- return;
26715
- }
26716
- onClick(item);
26717
- close();
26718
- }, [close, disabled, item, onClick]);
26719
- const onMouseEnterInner = (0,external_react_.useCallback)(() => {
26720
- if (disabled) {
26721
- return;
26722
- }
26723
- onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter(item);
26724
- }, [disabled, item, onMouseEnter]);
26725
- const onMouseLeaveInner = (0,external_react_.useCallback)(() => {
26726
- if (disabled) {
26727
- return;
26728
- }
26729
- onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(item);
26730
- }, [disabled, item, onMouseLeave]);
26731
- // Effects
26732
- // Other
26733
- const childElements = typeof children === "string" ? /*#__PURE__*/external_react_default().createElement(tmp, null, children) : children;
26734
- // RenderFunctions
26735
- return /*#__PURE__*/external_react_default().createElement(ClickableMemo, MenuItem_extends({
26736
- className: classnames_default()((menu_default()).item, {
26737
- [(menu_default()).disabled]: disabled,
26738
- [(menu_default()).active]: active
26739
- }, className)
26740
- }, props, {
26741
- onClick: onClickInner,
26742
- onMouseEnter: onMouseEnterInner,
26743
- onMouseLeave: onMouseLeaveInner,
26744
- __allowChildren: "all"
26745
- }), /*#__PURE__*/external_react_default().createElement(BlockMemo, {
26746
- className: classnames_default()((menu_default()).itemChildren)
26747
- }, !!icon && /*#__PURE__*/external_react_default().createElement(Icon, {
26748
- icon: icon,
26749
- color: iconColor,
26750
- className: (menu_default()).icon
26751
- }), childElements));
26752
- }, (menu_default()), "text");
26753
- ;// CONCATENATED MODULE: external "react-dom"
26754
- const external_react_dom_namespaceObject = require("react-dom");
26755
- ;// CONCATENATED MODULE: ./src/Components/Menu/Menu.tsx
26756
-
26757
-
26758
-
26759
-
26760
-
26761
-
26762
-
26763
-
26764
-
26765
-
26766
-
26767
- const MENU_CONTAINER_CLASS = "rbm-menu-container";
26768
- const Menu = withMemo(withRenderBrowserOnly(function Menu({
26769
- className,
26770
- style,
26771
- items,
26772
- y,
26773
- x,
26774
- isOpen,
26775
- onClose,
26776
- children,
26777
- offsetY = 0,
26778
- offsetX = 0
26779
- }) {
26780
- // Variables
26781
- // Refs
26782
- const menuRef = (0,external_react_.useRef)(null);
26783
- const window = useWindow();
26784
- // States
26785
- const [portalContainer] = (0,external_react_.useState)(() => {
26786
- return document.createElement('div');
26787
- });
26788
- const [innerX, setInnerX] = (0,external_react_.useState)(x);
26789
- const [innerY, setInnerY] = (0,external_react_.useState)(y);
26790
- // Selectors
26791
- // Callbacks
26792
- // Effects
26793
- (0,external_react_.useEffect)(() => {
26794
- if (isOpen) {
26795
- const listener = e => {
26796
- var _a;
26797
- if (!((_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
26798
- onClose();
26799
- }
26800
- };
26801
- window === null || window === void 0 ? void 0 : window.addEventListener('mousedown', listener, {
26802
- capture: true
26803
- });
26804
- return () => window === null || window === void 0 ? void 0 : window.removeEventListener('mousedown', listener, {
26805
- capture: true
26806
- });
26807
- }
26808
- return undefined;
26809
- }, [isOpen, onClose, window]);
26810
- (0,external_react_.useLayoutEffect)(() => {
26811
- if (!isOpen) {
26812
- return;
26813
- }
26814
- let elem = window === null || window === void 0 ? void 0 : window.document.body.querySelector("." + MENU_CONTAINER_CLASS);
26815
- if (!elem) {
26816
- elem = window === null || window === void 0 ? void 0 : window.document.body;
26817
- }
26818
- elem === null || elem === void 0 ? void 0 : elem.appendChild(portalContainer);
26819
- }, [isOpen, portalContainer, window === null || window === void 0 ? void 0 : window.document.body]);
26820
- (0,external_react_.useLayoutEffect)(() => {
26821
- var _a;
26822
- if (!menuRef.current) {
26823
- return;
26824
- }
26825
- const width = parseFloat(getComputedStyle(menuRef.current).width);
26826
- let newX = x;
26827
- if (newX > ((_a = window === null || window === void 0 ? void 0 : window.innerWidth) !== null && _a !== void 0 ? _a : 0) - width) {
26828
- newX -= width + offsetX;
26829
- }
26830
- if (newX < 0) {
26831
- newX = 0;
26832
- }
26833
- setInnerX(newX);
26834
- }, [offsetX, window === null || window === void 0 ? void 0 : window.innerWidth, x]);
26835
- (0,external_react_.useLayoutEffect)(() => {
26836
- var _a;
26837
- if (!menuRef.current) {
26838
- return;
26839
- }
26840
- const height = parseFloat(getComputedStyle(menuRef.current).height);
26841
- let newY = y;
26842
- if (newY > ((_a = window === null || window === void 0 ? void 0 : window.innerHeight) !== null && _a !== void 0 ? _a : 0) - height) {
26843
- newY -= height + offsetY;
26844
- }
26845
- if (newY < 0) {
26846
- newY = 0;
26847
- }
26848
- setInnerY(newY);
26849
- }, [offsetY, window === null || window === void 0 ? void 0 : window.innerHeight, y]);
26850
- // Other
26851
- // Render Functions
26852
- if (!isOpen) {
26853
- return null;
26854
- }
26855
- return /*#__PURE__*/external_react_.createElement(external_react_.Fragment, null, /*#__PURE__*/(0,external_react_dom_namespaceObject.createPortal)( /*#__PURE__*/external_react_.createElement(MenuCloseContextProvider, {
26856
- value: onClose
26857
- }, /*#__PURE__*/external_react_.createElement(BlockMemo, {
26858
- className: classnames_default()(className, (menu_default()).menu),
26859
- style: Object.assign(Object.assign({}, style), {
26860
- top: innerY,
26861
- left: innerX
26862
- }),
26863
- ref: menuRef,
26864
- __allowChildren: "all"
26865
- }, items === null || items === void 0 ? void 0 : items.map(item => {
26866
- const icon = !!item.icon && typeof item.icon === "object" && "color" in item.icon ? item.icon.icon : item.icon;
26867
- const iconColor = !!item.icon && typeof item.icon === "object" && "color" in item.icon ? item.icon.color : undefined;
26868
- return /*#__PURE__*/external_react_.createElement(MenuItem, {
26869
- key: item.key,
26870
- onClick: item.callback,
26871
- className: classnames_default()((menu_default()).item, item.className),
26872
- onMouseEnter: item.onMouseEnter,
26873
- icon: icon,
26874
- iconColor: iconColor,
26875
- onMouseLeave: item.onMouseLeave
26876
- }, item.label);
26877
- }), children)), portalContainer));
26878
- }), (menu_default()));
26879
26878
  ;// CONCATENATED MODULE: ./src/Components/Menu/HoverMenu.tsx
26880
26879
 
26881
26880
 
@@ -26946,6 +26945,11 @@ const HoverMenu = withMemo(function HoverMenu({
26946
26945
  recalculatePosition();
26947
26946
  setIsOpen(true);
26948
26947
  }, [recalculatePosition]);
26948
+ const onClickInner = (0,external_react_.useCallback)(() => {
26949
+ if ((onClick === null || onClick === void 0 ? void 0 : onClick()) !== false) {
26950
+ open();
26951
+ }
26952
+ }, [onClick, open]);
26949
26953
  // Effects
26950
26954
  // Other
26951
26955
  // RenderFunctions
@@ -26953,7 +26957,7 @@ const HoverMenu = withMemo(function HoverMenu({
26953
26957
  onMouseEnter: open,
26954
26958
  onMouseLeave: close,
26955
26959
  useReactOnMouseLeave: true,
26956
- onClick: onClick,
26960
+ onClick: onClickInner,
26957
26961
  className: classnames_default()((menu_default()).hoverMenu, {
26958
26962
  [(menu_default()).open]: isOpen
26959
26963
  }, className),