@agility/plenum-ui 2.0.3 → 2.0.4
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/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/types/stories/organisms/FormInputWithAddons/FormInputWithAddons.d.ts +2 -0
- package/package.json +1 -1
- package/stories/molecules/inputs/NestedInputButton/NestedInputButton.tsx +2 -2
- package/stories/organisms/FormInputWithAddons/FormInputWithAddons.stories.tsx +19 -0
- package/stories/organisms/FormInputWithAddons/FormInputWithAddons.tsx +8 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IDynamicIconProps } from "@/stories/atoms/icons";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { IInputFieldProps, AcceptedInputTypes } from "@/stories/molecules/inputs/InputField";
|
|
4
|
+
import { INestedInputButtonProps } from "@/stories/molecules/inputs/NestedInputButton";
|
|
4
5
|
export interface IFormInputWithAddonsProps extends Omit<IInputFieldProps, "type"> {
|
|
5
6
|
leadIcon?: IDynamicIconProps;
|
|
6
7
|
leadLabel?: string;
|
|
@@ -16,6 +17,7 @@ export interface IFormInputWithAddonsProps extends Omit<IInputFieldProps, "type"
|
|
|
16
17
|
leadIconClassNames?: string;
|
|
17
18
|
customIconClass?: string;
|
|
18
19
|
type: AcceptedInputTypes;
|
|
20
|
+
addonBTN?: INestedInputButtonProps;
|
|
19
21
|
}
|
|
20
22
|
declare const FormInputWithAddons: React.FC<IFormInputWithAddonsProps>;
|
|
21
23
|
export default FormInputWithAddons;
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ const NestedInputButton: React.FC<INestedInputButtonProps> = ({
|
|
|
27
27
|
onClickHandler && onClickHandler()
|
|
28
28
|
}
|
|
29
29
|
const buttonStyle = cn(
|
|
30
|
-
"relative
|
|
30
|
+
"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
31
|
{
|
|
32
32
|
"rounded-r text-gray-500 -ml-px": align === "right"
|
|
33
33
|
},
|
|
@@ -55,7 +55,7 @@ const NestedInputButton: React.FC<INestedInputButtonProps> = ({
|
|
|
55
55
|
)
|
|
56
56
|
return (
|
|
57
57
|
<button {...{ ...buttonProps, className: buttonStyle, onClick: handleClick }}>
|
|
58
|
-
{icon && <DynamicIcon {...{ ...icon, className: "text-gray-400" }} />}
|
|
58
|
+
{icon && <DynamicIcon {...{ ...icon, className: "text-gray-400 h-5 w-5" }} />}
|
|
59
59
|
{ctaLabel && <span>{ctaLabel}</span>}
|
|
60
60
|
</button>
|
|
61
61
|
)
|
|
@@ -27,3 +27,22 @@ export const DefaultFormInputWithAddons: Story = {
|
|
|
27
27
|
trailIcon: { icon: "IconSearch" }
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
export const FormInputWithAddonBTN: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
id: "appSearch",
|
|
33
|
+
name: "appSearch",
|
|
34
|
+
addonOffset: 60,
|
|
35
|
+
labelClass: "text-gray-900",
|
|
36
|
+
addonBTN: {
|
|
37
|
+
icon: {
|
|
38
|
+
icon: "IconPencil",
|
|
39
|
+
className: "h-5 w-5 text-gray-400"
|
|
40
|
+
},
|
|
41
|
+
ctaLabel: "Edit",
|
|
42
|
+
align: "right",
|
|
43
|
+
onClickHandler: () => {
|
|
44
|
+
alert("Button Clicked")
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -2,6 +2,7 @@ import { DynamicIcon, IDynamicIconProps } from "@/stories/atoms/icons"
|
|
|
2
2
|
import React, { useLayoutEffect, useRef, useState } from "react"
|
|
3
3
|
import { default as cn } from "classnames"
|
|
4
4
|
import InputField, { IInputFieldProps, AcceptedInputTypes } from "@/stories/molecules/inputs/InputField"
|
|
5
|
+
import NestedInputButton, { INestedInputButtonProps } from "@/stories/molecules/inputs/NestedInputButton"
|
|
5
6
|
|
|
6
7
|
export interface IFormInputWithAddonsProps extends Omit<IInputFieldProps, "type"> {
|
|
7
8
|
leadIcon?: IDynamicIconProps
|
|
@@ -18,6 +19,7 @@ export interface IFormInputWithAddonsProps extends Omit<IInputFieldProps, "type"
|
|
|
18
19
|
leadIconClassNames?: string
|
|
19
20
|
customIconClass?: string
|
|
20
21
|
type: AcceptedInputTypes
|
|
22
|
+
addonBTN?: INestedInputButtonProps
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
const FormInputWithAddons: React.FC<IFormInputWithAddonsProps> = ({
|
|
@@ -43,6 +45,7 @@ const FormInputWithAddons: React.FC<IFormInputWithAddonsProps> = ({
|
|
|
43
45
|
leadIconClassNames,
|
|
44
46
|
customIconClass,
|
|
45
47
|
type,
|
|
48
|
+
addonBTN,
|
|
46
49
|
...rest
|
|
47
50
|
}) => {
|
|
48
51
|
// #region logic to determine the width of the lead and or trailing labels in order to offset the input padding by the appropriate amount.
|
|
@@ -137,6 +140,11 @@ const FormInputWithAddons: React.FC<IFormInputWithAddonsProps> = ({
|
|
|
137
140
|
{trailLabel && trailLabel}
|
|
138
141
|
</label>
|
|
139
142
|
)}
|
|
143
|
+
{addonBTN && (
|
|
144
|
+
<div className="absolute top-0 bottom-0 right-0 flex items-center ">
|
|
145
|
+
<NestedInputButton {...addonBTN} />
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
140
148
|
</div>
|
|
141
149
|
</div>
|
|
142
150
|
)
|