@hilum/ui 3.0.0 → 3.1.0
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 +17 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/input-group.tsx +20 -3
package/package.json
CHANGED
|
@@ -7,6 +7,8 @@ interface InputGroupProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
|
7
7
|
trailingAddon?: React.ReactNode;
|
|
8
8
|
leadingIcon?: React.ReactNode;
|
|
9
9
|
trailingIcon?: React.ReactNode;
|
|
10
|
+
trailingAction?: React.ReactNode;
|
|
11
|
+
trailingActionClassName?: string;
|
|
10
12
|
trailingButton?: React.ReactNode;
|
|
11
13
|
error?: boolean;
|
|
12
14
|
pill?: boolean;
|
|
@@ -20,6 +22,8 @@ const InputGroup = React.forwardRef<HTMLInputElement, InputGroupProps>(
|
|
|
20
22
|
trailingAddon,
|
|
21
23
|
leadingIcon,
|
|
22
24
|
trailingIcon,
|
|
25
|
+
trailingAction,
|
|
26
|
+
trailingActionClassName,
|
|
23
27
|
trailingButton,
|
|
24
28
|
error,
|
|
25
29
|
pill,
|
|
@@ -31,7 +35,8 @@ const InputGroup = React.forwardRef<HTMLInputElement, InputGroupProps>(
|
|
|
31
35
|
) => {
|
|
32
36
|
const radius = pill ? "rounded-full" : "rounded-lg";
|
|
33
37
|
const hasLeading = leadingAddon || leadingIcon;
|
|
34
|
-
const
|
|
38
|
+
const hasInsetTrailing = trailingIcon || trailingAction || error;
|
|
39
|
+
const hasTrailing = trailingAddon || hasInsetTrailing || trailingButton;
|
|
35
40
|
|
|
36
41
|
const baseInput = cn(
|
|
37
42
|
"flex h-9 w-full border bg-card body text-foreground placeholder:text-muted-foreground",
|
|
@@ -84,16 +89,17 @@ const InputGroup = React.forwardRef<HTMLInputElement, InputGroupProps>(
|
|
|
84
89
|
? pill
|
|
85
90
|
? "rounded-l-full rounded-r-none pl-9 pr-3"
|
|
86
91
|
: "rounded-l-lg rounded-r-none pl-9 pr-3"
|
|
87
|
-
:
|
|
92
|
+
: hasInsetTrailing
|
|
88
93
|
? cn(radius, "pl-9 pr-9")
|
|
89
94
|
: cn(radius, "pl-9 pr-3")
|
|
90
95
|
: trailingAddon
|
|
91
96
|
? pill
|
|
92
97
|
? "rounded-l-full rounded-r-none px-3"
|
|
93
98
|
: "rounded-l-lg rounded-r-none px-3"
|
|
94
|
-
:
|
|
99
|
+
: hasInsetTrailing
|
|
95
100
|
? cn(radius, "pl-3 pr-9")
|
|
96
101
|
: cn(radius, "px-3"),
|
|
102
|
+
trailingAction && "pr-14",
|
|
97
103
|
className,
|
|
98
104
|
)}
|
|
99
105
|
{...props}
|
|
@@ -108,6 +114,17 @@ const InputGroup = React.forwardRef<HTMLInputElement, InputGroupProps>(
|
|
|
108
114
|
)}
|
|
109
115
|
</div>
|
|
110
116
|
)}
|
|
117
|
+
|
|
118
|
+
{trailingAction && (
|
|
119
|
+
<div
|
|
120
|
+
className={cn(
|
|
121
|
+
"absolute inset-y-0 right-2 flex items-center",
|
|
122
|
+
trailingActionClassName,
|
|
123
|
+
)}
|
|
124
|
+
>
|
|
125
|
+
{trailingAction}
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
111
128
|
</div>
|
|
112
129
|
|
|
113
130
|
{/* Trailing addon (text) */}
|