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

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.
package/Alert/index.js CHANGED
@@ -68,13 +68,14 @@ const Alert = props => {
68
68
  iconRight && iconRight)),
69
69
  hasIconLeft: !!iconLeft,
70
70
  hasIconRight: !!iconRight,
71
+ hasThickBorder: !(iconLeft && (iconLeft.props.hasBackground || (iconLeft.props.palette && iconLeft.props.palette !== props.palette))),
71
72
  };
72
73
  };
73
- const [{ children, hasIconLeft, hasIconRight }, setContent] = react_1.default.useState(() => getContent());
74
+ const [{ children, hasIconLeft, hasIconRight, hasThickBorder }, setContent] = react_1.default.useState(() => getContent());
74
75
  (0, useChangeEffect_1.default)(() => {
75
76
  setContent(getContent());
76
77
  }, [props.children]);
77
- return (react_1.default.createElement(AlertElement_1.default, Object.assign({ alertSize: props.size, alertSizeSm: props.sizeSm, alertSizeMd: props.sizeMd, alertSizeLg: props.sizeLg, alertSizeXl: props.sizeXl, hasIconLeft: hasIconLeft, hasIconRight: hasIconRight, isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, shape: props.shape }, (0, element_props_1.default)(props, [click_events_1.default, intrinsic_styled_props_1.default])), children));
78
+ return (react_1.default.createElement(AlertElement_1.default, Object.assign({ alertSize: props.size, alertSizeSm: props.sizeSm, alertSizeMd: props.sizeMd, alertSizeLg: props.sizeLg, alertSizeXl: props.sizeXl, hasIconLeft: hasIconLeft, hasIconRight: hasIconRight, hasThickBorder: hasThickBorder, isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, shape: props.shape }, (0, element_props_1.default)(props, [click_events_1.default, intrinsic_styled_props_1.default])), children));
78
79
  };
79
80
  Alert.defaultProps = {
80
81
  palette: 'primary',
@@ -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
  };
@@ -4,6 +4,7 @@ export declare const Content: import("styled-components").StyledComponent<"div",
4
4
  interface Props extends StyledProps, ResponsiveProp<'alertSize', SizeProp> {
5
5
  hasIconLeft: boolean;
6
6
  hasIconRight: boolean;
7
+ hasThickBorder: boolean;
7
8
  isOutline: boolean;
8
9
  isSoft: boolean;
9
10
  palette: PaletteProp;
@@ -6,20 +6,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Content = void 0;
7
7
  const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
8
8
  const styled_components_1 = __importDefault(require("styled-components"));
9
+ const css_1 = require("../../util/css");
9
10
  exports.Content = styled_components_1.default.div `
10
11
  flex: 1 1 auto;
11
12
  `;
12
- exports.default = (0, styled_components_1.default)(Div_1.default).attrs({
13
+ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ hasIconLeft, hasIconRight }) => ({
13
14
  getAlertSize: (v, t) => `
14
15
  font-size: ${t.$.size.alert[v].fontSize};
15
16
 
16
17
  ${exports.Content} {
17
18
  padding: ${t.$.size.alert[v].padding.y} ${t.$.size.alert[v].padding.x};
19
+
20
+ ${hasIconLeft
21
+ ? `
22
+ padding-left: ${(0, css_1.toCSSValue)(t.$.size.alert[v].padding.x)(v => v / 2)};
23
+ `
24
+ : ''}
25
+
26
+ ${hasIconRight
27
+ ? `
28
+ padding-right: ${(0, css_1.toCSSValue)(t.$.size.alert[v].padding.x)(v => v / 2)};
29
+ `
30
+ : ''}
31
+
18
32
  }
19
33
  `,
20
- })(({ theme, hasIconLeft, hasIconRight, isOutline, isSoft, palette, shape }) => `
34
+ }))(({ theme, hasThickBorder, isOutline, isSoft, palette, shape }) => `
21
35
  border: solid 1px;
22
- border-left-width: 10px;
23
36
  border-radius: ${theme.$.radius.alert[shape]};
24
37
  box-sizing: border-box;
25
38
  display: flex;
@@ -54,21 +67,9 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs({
54
67
  `}
55
68
  `}
56
69
 
57
- ${hasIconLeft
58
- ? `
59
- > ${exports.Content} {
60
- padding-left: 0;
61
- }
62
- `
63
- : ''}
64
-
65
- ${hasIconRight
66
- ? `
67
- > ${exports.Content} {
68
- padding-right: 0;
69
- }
70
- `
71
- : ''}
70
+ ${hasThickBorder && `
71
+ border-left-width: 10px;
72
+ `}
72
73
 
73
74
  ${exports.Content} > {
74
75
  header, h1, h2, h3, h4, h5, h6, p, hr {
@@ -5,9 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
7
7
  const styled_components_1 = __importDefault(require("styled-components"));
8
+ const css_1 = require("../../util/css");
8
9
  exports.default = (0, styled_components_1.default)(Div_1.default).attrs({
9
10
  getAlertIconSize: (v, t) => `
10
- padding: 0 ${t.$.size.alert[v].padding.x};
11
+ padding: 0 ${(0, css_1.toCSSValue)(t.$.size.alert[v].padding.x)(v => v / 2)};
11
12
 
12
13
  > svg {
13
14
  height: ${t.$.size.alert[v].iconSize};
@@ -34,7 +35,9 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs({
34
35
  ? `
35
36
  background: ${!isSoft ? theme.$.palette[palette].main : theme.$.palette[palette].soft};
36
37
  `
37
- : ''}
38
+ : `
39
+ background: ${!isSoft ? theme.$.palette[palette].darkest : theme.$.palette[palette].softDarkest};
40
+ `}
38
41
  `
39
42
  : `
40
43
  color: ${!isSoft ? theme.$.palette[palette].main : theme.$.palette[palette].soft};
@@ -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-28",
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);