@agility/plenum-ui 2.0.6 → 2.0.7

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
  import React from "react";
2
2
  import { IDynamicIconProps } from "@/stories/atoms/icons";
3
- export interface INestedInputButtonProps {
3
+ export interface INestedInputButtonProps extends Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> {
4
4
  /** Icon to be included*/
5
5
  icon?: IDynamicIconProps;
6
6
  /** CTA label */
@@ -9,9 +9,6 @@ export interface INestedInputButtonProps {
9
9
  align: "left" | "right";
10
10
  /** Show the CTA without Background color and a border seperator */
11
11
  isClear?: boolean;
12
- /** Onclick callback */
13
- onClickHandler?(): void;
14
- buttonProps?: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
15
12
  }
16
13
  declare const NestedInputButton: React.FC<INestedInputButtonProps>;
17
14
  export default NestedInputButton;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility/plenum-ui",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -1,7 +1,8 @@
1
1
  import React from "react"
2
2
  import { DynamicIcon, IDynamicIconProps } from "@/stories/atoms/icons"
3
3
  import { default as cn } from "classnames"
4
- export interface INestedInputButtonProps {
4
+ export interface INestedInputButtonProps
5
+ extends Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> {
5
6
  /** Icon to be included*/
6
7
  icon?: IDynamicIconProps
7
8
  /** CTA label */
@@ -10,9 +11,6 @@ export interface INestedInputButtonProps {
10
11
  align: "left" | "right"
11
12
  /** Show the CTA without Background color and a border seperator */
12
13
  isClear?: boolean
13
- /** Onclick callback */
14
- onClickHandler?(): void
15
- buttonProps?: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>
16
14
  }
17
15
 
18
16
  const NestedInputButton: React.FC<INestedInputButtonProps> = ({
@@ -20,12 +18,10 @@ const NestedInputButton: React.FC<INestedInputButtonProps> = ({
20
18
  ctaLabel,
21
19
  align = "right",
22
20
  isClear = false,
23
- onClickHandler,
24
- buttonProps
21
+ ...props
25
22
  }) => {
26
- const handleClick = () => {
27
- onClickHandler && onClickHandler()
28
- }
23
+ const { ...buttonProps } = props
24
+ const { onClick } = buttonProps
29
25
  const buttonStyle = cn(
30
26
  "relative flex items-center space-x-2 px-4 py-2 leading-5 border border-gray-300 text-sm font-medium focus:outline-none focus:ring-1 focus:ring-purple-500 focus:border-purple-500",
31
27
  {
@@ -35,10 +31,10 @@ const NestedInputButton: React.FC<INestedInputButtonProps> = ({
35
31
  "rounded-l text-gray-500 -mr-px": align === "left"
36
32
  },
37
33
  {
38
- "cursor-default": !onClickHandler
34
+ "cursor-default": !onClick
39
35
  },
40
36
  {
41
- "hover:bg-gray-100": onClickHandler && !isClear
37
+ "hover:bg-gray-100": onClick && !isClear
42
38
  },
43
39
  {
44
40
  "!border-l-white": isClear && align === "right"
@@ -54,7 +50,16 @@ const NestedInputButton: React.FC<INestedInputButtonProps> = ({
54
50
  }
55
51
  )
56
52
  return (
57
- <button {...{ ...buttonProps, className: buttonStyle, onClick: handleClick }}>
53
+ <button
54
+ {...{
55
+ ...buttonProps,
56
+ className: buttonStyle,
57
+ onClick: (e) => {
58
+ e.preventDefault()
59
+ onClick && onClick(e)
60
+ }
61
+ }}
62
+ >
58
63
  {icon && <DynamicIcon {...{ ...icon, className: "text-gray-400 h-5 w-5" }} />}
59
64
  {ctaLabel && <span>{ctaLabel}</span>}
60
65
  </button>
@@ -23,7 +23,7 @@ const DefaultArgs: IAnimatedFormInputWithAddons = {
23
23
  icon: { icon: "IconPencil" },
24
24
  align: "right",
25
25
  ctaLabel: "Edit",
26
- onClickHandler: () => {
26
+ onClick: () => {
27
27
  alert("clicked")
28
28
  }
29
29
  }