widenarrow-ui 1.0.25 → 1.0.26

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,13 +1,15 @@
1
- import { MouseEvent } from 'react';
1
+ import { MouseEvent, CSSProperties } from 'react';
2
2
  import { IconStyleInterface, SizeStyleInterface } from '../../types/styling.types';
3
3
  import { ColorTypes, HierarchyTypes, SizeTypes } from '../../constants';
4
4
  export interface IconButtonProps extends IconStyleInterface, SizeStyleInterface {
5
5
  className?: string;
6
6
  rotateIcon?: boolean;
7
+ id?: string | number;
7
8
  rotateIconByDegree?: 0 | 45 | 90 | 135 | 180 | 225 | 270 | 315;
8
9
  iconClassName?: string;
9
10
  type?: HierarchyTypes.PRIMARY | HierarchyTypes.SECONDARY;
10
11
  onClickCallback?: (e: MouseEvent<HTMLButtonElement>) => void;
12
+ style?: CSSProperties;
11
13
  iconSize?: SizeTypes.SMALL | SizeTypes.MEDIUM | SizeTypes.LARGE;
12
14
  iconColor?: Partial<ColorTypes>;
13
15
  href?: string;
package/lib/index.d.ts CHANGED
@@ -562,10 +562,12 @@ declare const Icon: FC<IconProps>;
562
562
  interface IconButtonProps extends IconStyleInterface, SizeStyleInterface {
563
563
  className?: string;
564
564
  rotateIcon?: boolean;
565
+ id?: string | number;
565
566
  rotateIconByDegree?: 0 | 45 | 90 | 135 | 180 | 225 | 270 | 315;
566
567
  iconClassName?: string;
567
568
  type?: HierarchyTypes.PRIMARY | HierarchyTypes.SECONDARY;
568
569
  onClickCallback?: (e: MouseEvent<HTMLButtonElement>) => void;
570
+ style?: CSSProperties;
569
571
  iconSize?: SizeTypes.SMALL | SizeTypes.MEDIUM | SizeTypes.LARGE;
570
572
  iconColor?: Partial<ColorTypes>;
571
573
  href?: string;
package/lib/index.esm.js CHANGED
@@ -2095,7 +2095,7 @@ var Button = memo(function (_a) {
2095
2095
  className: mergedClassNames,
2096
2096
  id: id,
2097
2097
  disabled: loading || disabled,
2098
- onClickCallback: !!onClickCallback && !loading ? onClickCallback : undefined
2098
+ onClick: !!onClickCallback && !loading ? onClickCallback : undefined
2099
2099
  },
2100
2100
  _c['aria-label'] = ariaLabel || text,
2101
2101
  _c.style = style,
@@ -2570,9 +2570,9 @@ var styles$9 = {"body":"IconButton-module_DV09bK","container":"IconButton-module
2570
2570
 
2571
2571
  var s$9 = classNames.bind(styles$9);
2572
2572
  var IconButton = memo(function (_a) {
2573
- var _b;
2574
- var className = _a.className, disabled = _a.disabled, icon = _a.icon, size = _a.size, _c = _a.type, type = _c === void 0 ? HierarchyTypes.SECONDARY : _c, href = _a.href, iconColor = _a.iconColor, iconSize = _a.iconSize, iconClassName = _a.iconClassName, onClickCallback = _a.onClickCallback, rotateIcon = _a.rotateIcon, rotateIconByDegree = _a.rotateIconByDegree, toolTip = _a.toolTip, ariaLabel = _a.ariaLabel;
2575
- var BUTTON_CLASSES = s$9('container', (_b = {
2573
+ var _b, _c;
2574
+ var className = _a.className, disabled = _a.disabled, style = _a.style, icon = _a.icon, id = _a.id, size = _a.size, _d = _a.type, type = _d === void 0 ? HierarchyTypes.SECONDARY : _d, href = _a.href, iconColor = _a.iconColor, iconSize = _a.iconSize, iconClassName = _a.iconClassName, onClickCallback = _a.onClickCallback, rotateIcon = _a.rotateIcon, rotateIconByDegree = _a.rotateIconByDegree, toolTip = _a.toolTip, ariaLabel = _a.ariaLabel;
2575
+ var mergedClassNames = s$9('container', (_b = {
2576
2576
  container_primary: type === HierarchyTypes.PRIMARY,
2577
2577
  container_secondary: type === HierarchyTypes.SECONDARY,
2578
2578
  container_small: size === SizeTypes.SMALL,
@@ -2582,25 +2582,28 @@ var IconButton = memo(function (_a) {
2582
2582
  },
2583
2583
  _b[className] = className,
2584
2584
  _b));
2585
- var onClicked = function (event) {
2586
- if (event) {
2587
- event.stopPropagation();
2588
- }
2589
- if (onClickCallback) {
2590
- onClickCallback(event);
2591
- }
2592
- };
2593
- var getInnerMarkup = function () {
2594
- return icon && (jsx(Icon, { color: iconColor, icon: icon, size: iconSize || SizeTypes.AUTO, className: iconClassName, rotateIcon: rotateIcon, rotateIconByDegree: rotateIconByDegree }));
2595
- };
2585
+ var iconMarkup = icon ? (jsx(Icon, { color: iconColor, icon: icon, size: iconSize || SizeTypes.AUTO, className: iconClassName, rotateIcon: rotateIcon, rotateIconByDegree: rotateIconByDegree })) : null;
2586
+ var baseAttributes = (_c = {
2587
+ className: mergedClassNames,
2588
+ id: id,
2589
+ disabled: disabled,
2590
+ onClick: !!onClickCallback ? onClickCallback : undefined
2591
+ },
2592
+ _c['aria-label'] = ariaLabel,
2593
+ _c.style = style,
2594
+ _c.href = href,
2595
+ _c.target = href ? '_blank' : undefined,
2596
+ _c.rel = href ? 'noopener noreferrer' : undefined,
2597
+ _c);
2598
+ var buttonAttributes = pickBy(function (val) { return val !== undefined; }, baseAttributes);
2596
2599
  var buttonMarkup = function () {
2597
2600
  if (href) {
2598
- return (jsx("a", __assign({ className: BUTTON_CLASSES, href: href, target: '_BLANK', rel: "noopener noreferrer" }, { children: getInnerMarkup() })));
2601
+ return jsx("a", __assign({}, buttonAttributes, { children: iconMarkup }));
2599
2602
  }
2600
- return (jsx("button", __assign({ onClick: onClicked, className: BUTTON_CLASSES, "aria-label": ariaLabel || toolTip }, { children: getInnerMarkup() })));
2603
+ return jsx("button", __assign({}, buttonAttributes, { children: iconMarkup }));
2601
2604
  };
2602
2605
  if (toolTip) {
2603
- return (jsx(ToolTip, __assign({ text: "".concat(toolTip), offset: 16 }, { children: buttonMarkup() })));
2606
+ return (jsx(ToolTip, __assign({ text: "".concat(toolTip), id: id ? "".concat(id) : undefined, offset: 16 }, { children: buttonMarkup() })));
2604
2607
  }
2605
2608
  return buttonMarkup();
2606
2609
  });
@@ -2704,7 +2707,7 @@ var InlineButton = memo(function (_a) {
2704
2707
  className: mergedClassNames,
2705
2708
  id: id,
2706
2709
  disabled: loading || disabled,
2707
- onClickCallback: !!onClickCallback && !loading ? onClickCallback : undefined
2710
+ onClick: !!onClickCallback && !loading ? onClickCallback : undefined
2708
2711
  },
2709
2712
  _c['aria-label'] = ariaLabel || text,
2710
2713
  _c.style = style,