@smart-react-components/ui 2.0.0-alpha-26 → 2.0.0-alpha-27

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.
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  export interface Props {
4
4
  children: ContentElement;
5
5
  isDisabled?: boolean;
6
- onClick?: (e: React.MouseEvent<HTMLElement>) => void | Promise<void>;
6
+ onClick?: (e: React.MouseEvent<HTMLElement>) => void;
7
7
  }
8
8
  export interface PrivateProps {
9
9
  hasHover: boolean;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -16,15 +7,15 @@ const react_1 = __importDefault(require("react"));
16
7
  const WaveEffect_1 = __importDefault(require("../WaveEffect"));
17
8
  const DropdownItemElement_1 = __importDefault(require("../components/Dropdown/DropdownItemElement"));
18
9
  const DropdownItem = ({ children, hasHover, hasWaveEffect, isDisabled, isOutline, isSoft, onClick, palette, setStatus, waveEffectPalette }) => {
19
- const handleOnClick = (e) => __awaiter(void 0, void 0, void 0, function* () {
10
+ const handleOnClick = (e) => {
20
11
  if (isDisabled) {
21
12
  return;
22
13
  }
23
- yield (onClick === null || onClick === void 0 ? void 0 : onClick(e));
14
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
24
15
  if (!e.defaultPrevented) {
25
16
  setStatus(false);
26
17
  }
27
- });
18
+ };
28
19
  const content = (react_1.default.createElement(DropdownItemElement_1.default, { hasHover: hasHover, isActive: false, isDisabled: isDisabled, isOutline: isOutline, isSoft: isSoft, palette: palette, onClick: handleOnClick }, children));
29
20
  return hasWaveEffect ? react_1.default.createElement(WaveEffect_1.default, { palette: waveEffectPalette }, content) : content;
30
21
  };
@@ -96,7 +96,11 @@ const useFixedBoxMethods = ({ beforeShow, boxEl, getTriggerEl, handlePosition, h
96
96
  (0, react_1.useEffect)(() => {
97
97
  const triggerEl = getTriggerEl();
98
98
  const debounceWindowMouseMove = (0, dom_1.debounce)(handleWindowMouseMove);
99
- const debouncePosition = (0, dom_1.debounce)(() => handlePosition(mouseEvent.current));
99
+ const debouncePosition = (0, dom_1.debounce)(e => {
100
+ if (!boxEl.current.contains(e.target)) {
101
+ handlePosition(mouseEvent.current);
102
+ }
103
+ });
100
104
  const handlePositionBind = () => handlePosition(mouseEvent.current);
101
105
  if (triggerInteraction & types_1.TriggerInteraction.CLICK) {
102
106
  (0, dom_1.addEventListener)(triggerEl, ['click'], handleTriggerClick);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart-react-components/ui",
3
- "version": "2.0.0-alpha-26",
3
+ "version": "2.0.0-alpha-27",
4
4
  "license": "MIT",
5
5
  "main": "index.js",
6
6
  "description": "SRC UI includes React and Styled components.",
package/util/fixed-box.js CHANGED
@@ -18,7 +18,7 @@ const calculatePosition = (triggerEl, boxEl, e, position, maxWidth, minWidth, sp
18
18
  return;
19
19
  }
20
20
  boxEl.removeAttribute('style');
21
- let width = Math.max(boxEl.offsetWidth, position & (types_1.Position.TOP | types_1.Position.BOTTOM) ? triggerEl.offsetWidth : 0);
21
+ let width = Math.max(boxEl.offsetWidth + .5, position & (types_1.Position.TOP | types_1.Position.BOTTOM) ? triggerEl.offsetWidth : 0);
22
22
  if (minWidth && minWidth > width) {
23
23
  width = minWidth;
24
24
  }
@@ -38,7 +38,7 @@ const calculatePositionBasedOnXAxis = (triggerRect, boxEl, e, position, space, w
38
38
  var _a, _b;
39
39
  // left & width
40
40
  let left;
41
- const width = boxEl.offsetWidth;
41
+ const width = boxEl.offsetWidth + .5;
42
42
  const triggerLeft = (_a = e === null || e === void 0 ? void 0 : e.clientX) !== null && _a !== void 0 ? _a : triggerRect.left;
43
43
  const triggerWidth = e ? 0 : triggerRect.width;
44
44
  const diffLeft = triggerRect.left - (space + width);
@@ -79,7 +79,7 @@ const calculatePositionBasedOnYAxis = (triggerRect, boxEl, e, position, space, w
79
79
  var _a, _b;
80
80
  // left & width
81
81
  let left;
82
- const width = boxEl.offsetWidth;
82
+ const width = boxEl.offsetWidth + .5;
83
83
  const triggerLeft = (_a = e === null || e === void 0 ? void 0 : e.clientX) !== null && _a !== void 0 ? _a : triggerRect.left;
84
84
  const triggerWidth = e ? 0 : triggerRect.width;
85
85
  const diffLeft = windowWidth - (triggerLeft + width);