@rovula/ui 0.1.1 → 0.1.2
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/cjs/bundle.css +64 -0
- package/dist/cjs/bundle.js +1564 -1570
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/Dropdown/Dropdown.stories.d.ts +1 -0
- package/dist/cjs/types/components/InputFilter/InputFilter.stories.d.ts +1 -0
- package/dist/cjs/types/components/MaskedTextInput/MaskedTextInput.d.ts +1 -0
- package/dist/cjs/types/components/MaskedTextInput/MaskedTextInput.stories.d.ts +2 -0
- package/dist/cjs/types/components/PasswordInput/PasswordInput.stories.d.ts +1 -0
- package/dist/cjs/types/components/Search/Search.stories.d.ts +1 -0
- package/dist/cjs/types/components/TextInput/TextInput.d.ts +2 -0
- package/dist/cjs/types/components/TextInput/TextInput.stories.d.ts +10 -0
- package/dist/cjs/types/components/TextInput/TextInput.styles.d.ts +15 -0
- package/dist/components/PasswordInput/PasswordInput.js +2 -2
- package/dist/components/TextArea/TextArea.styles.js +1 -1
- package/dist/components/TextInput/TextInput.js +33 -24
- package/dist/components/TextInput/TextInput.stories.js +14 -2
- package/dist/components/TextInput/TextInput.styles.js +25 -10
- package/dist/esm/bundle.css +64 -0
- package/dist/esm/bundle.js +1564 -1570
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/Dropdown/Dropdown.stories.d.ts +1 -0
- package/dist/esm/types/components/InputFilter/InputFilter.stories.d.ts +1 -0
- package/dist/esm/types/components/MaskedTextInput/MaskedTextInput.d.ts +1 -0
- package/dist/esm/types/components/MaskedTextInput/MaskedTextInput.stories.d.ts +2 -0
- package/dist/esm/types/components/PasswordInput/PasswordInput.stories.d.ts +1 -0
- package/dist/esm/types/components/Search/Search.stories.d.ts +1 -0
- package/dist/esm/types/components/TextInput/TextInput.d.ts +2 -0
- package/dist/esm/types/components/TextInput/TextInput.stories.d.ts +10 -0
- package/dist/esm/types/components/TextInput/TextInput.styles.d.ts +15 -0
- package/dist/index.d.ts +3 -0
- package/dist/src/theme/global.css +83 -0
- package/package.json +1 -1
- package/src/components/PasswordInput/PasswordInput.tsx +2 -2
- package/src/components/TextArea/TextArea.styles.ts +1 -1
- package/src/components/TextInput/TextInput.stories.tsx +60 -2
- package/src/components/TextInput/TextInput.styles.ts +36 -19
- package/src/components/TextInput/TextInput.tsx +83 -55
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, {
|
|
2
|
-
FC,
|
|
3
2
|
ReactNode,
|
|
4
3
|
forwardRef,
|
|
5
4
|
useCallback,
|
|
@@ -9,18 +8,18 @@ import React, {
|
|
|
9
8
|
} from "react";
|
|
10
9
|
import {
|
|
11
10
|
helperTextVariant,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
iconActionVariant,
|
|
12
|
+
inlineEndIconWrapperVariant,
|
|
13
|
+
inlineStartIconWrapperVariant,
|
|
15
14
|
inputVariant,
|
|
16
15
|
labelVariant,
|
|
17
|
-
|
|
16
|
+
segmentedIconWrapperVariant,
|
|
18
17
|
} from "./TextInput.styles";
|
|
19
18
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} from "
|
|
19
|
+
CircleAlert,
|
|
20
|
+
CircleX,
|
|
21
|
+
Search,
|
|
22
|
+
} from "lucide-react";
|
|
24
23
|
import { cn } from "@/utils/cn";
|
|
25
24
|
|
|
26
25
|
export type InputProps = {
|
|
@@ -39,6 +38,7 @@ export type InputProps = {
|
|
|
39
38
|
required?: boolean;
|
|
40
39
|
isFloatingLabel?: boolean;
|
|
41
40
|
keepCloseIconOnValue?: boolean;
|
|
41
|
+
keepFooterSpace?: boolean;
|
|
42
42
|
hasClearIcon?: boolean;
|
|
43
43
|
hasSearchIcon?: boolean;
|
|
44
44
|
startIcon?: ReactNode;
|
|
@@ -76,6 +76,7 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
76
76
|
required = true,
|
|
77
77
|
isFloatingLabel = true,
|
|
78
78
|
keepCloseIconOnValue = false,
|
|
79
|
+
keepFooterSpace = true,
|
|
79
80
|
hasClearIcon = true,
|
|
80
81
|
hasSearchIcon = false,
|
|
81
82
|
startIcon,
|
|
@@ -118,20 +119,26 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
118
119
|
hasLeftSectionIcon: iconMode === "solid" ? hasLeftSectionIcon : false,
|
|
119
120
|
isFloatingLabel,
|
|
120
121
|
});
|
|
121
|
-
const helperTextClassname = helperTextVariant({
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
const helperTextClassname = helperTextVariant({
|
|
123
|
+
size,
|
|
124
|
+
error,
|
|
125
|
+
disabled,
|
|
126
|
+
});
|
|
127
|
+
const inlineEndIconWrapperClassname = inlineEndIconWrapperVariant({ size });
|
|
128
|
+
const inlineStartIconWrapperClassname = inlineStartIconWrapperVariant({
|
|
129
|
+
size,
|
|
130
|
+
});
|
|
131
|
+
const iconActionClassname = iconActionVariant({ size });
|
|
125
132
|
|
|
126
133
|
// TODO wait for clearify aboutm start,end, search and clearIcon with iconMode
|
|
127
134
|
|
|
128
|
-
const
|
|
135
|
+
const startSegmentIconWrapperClassname = segmentedIconWrapperVariant({
|
|
129
136
|
size,
|
|
130
137
|
rounded,
|
|
131
138
|
error,
|
|
132
139
|
position: "start",
|
|
133
140
|
});
|
|
134
|
-
const
|
|
141
|
+
const endSegmentIconWrapperClassname = segmentedIconWrapperVariant({
|
|
135
142
|
size,
|
|
136
143
|
rounded,
|
|
137
144
|
error,
|
|
@@ -176,7 +183,7 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
176
183
|
return (
|
|
177
184
|
<div
|
|
178
185
|
className={cn(
|
|
179
|
-
|
|
186
|
+
inlineStartIconWrapperClassname,
|
|
180
187
|
"flex",
|
|
181
188
|
classes?.iconSearchWrapper
|
|
182
189
|
)}
|
|
@@ -190,12 +197,12 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
190
197
|
return (
|
|
191
198
|
<div
|
|
192
199
|
className={cn(
|
|
193
|
-
|
|
200
|
+
inlineStartIconWrapperClassname,
|
|
194
201
|
classes?.iconSearchWrapper
|
|
195
202
|
)}
|
|
196
203
|
>
|
|
197
204
|
<div
|
|
198
|
-
className={cn(
|
|
205
|
+
className={cn(iconActionClassname, classes?.icon)}
|
|
199
206
|
onClick={handleOnClickLeftSectionIcon}
|
|
200
207
|
>
|
|
201
208
|
{startIcon}
|
|
@@ -206,7 +213,10 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
206
213
|
|
|
207
214
|
return (
|
|
208
215
|
<div
|
|
209
|
-
className={cn(
|
|
216
|
+
className={cn(
|
|
217
|
+
startSegmentIconWrapperClassname,
|
|
218
|
+
classes?.startIconWrapper
|
|
219
|
+
)}
|
|
210
220
|
onClick={handleOnClickLeftSectionIcon}
|
|
211
221
|
>
|
|
212
222
|
{startIcon}
|
|
@@ -216,9 +226,9 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
216
226
|
hasLeftSectionIcon,
|
|
217
227
|
startIcon,
|
|
218
228
|
iconMode,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
229
|
+
inlineStartIconWrapperClassname,
|
|
230
|
+
startSegmentIconWrapperClassname,
|
|
231
|
+
iconActionClassname,
|
|
222
232
|
renderStartIcon,
|
|
223
233
|
handleOnClickLeftSectionIcon,
|
|
224
234
|
]);
|
|
@@ -229,7 +239,11 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
229
239
|
if (renderEndIcon) {
|
|
230
240
|
return (
|
|
231
241
|
<div
|
|
232
|
-
className={cn(
|
|
242
|
+
className={cn(
|
|
243
|
+
inlineEndIconWrapperClassname,
|
|
244
|
+
"flex",
|
|
245
|
+
classes?.iconWrapper
|
|
246
|
+
)}
|
|
233
247
|
>
|
|
234
248
|
{renderEndIcon()}
|
|
235
249
|
</div>
|
|
@@ -239,10 +253,14 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
239
253
|
if (iconMode === "flat") {
|
|
240
254
|
return (
|
|
241
255
|
<div
|
|
242
|
-
className={cn(
|
|
256
|
+
className={cn(
|
|
257
|
+
inlineEndIconWrapperClassname,
|
|
258
|
+
"flex",
|
|
259
|
+
classes?.iconWrapper
|
|
260
|
+
)}
|
|
243
261
|
>
|
|
244
262
|
<div
|
|
245
|
-
className={cn(
|
|
263
|
+
className={cn(iconActionClassname, classes?.icon)}
|
|
246
264
|
onClick={handleOnClickRightSectionIcon}
|
|
247
265
|
>
|
|
248
266
|
{endIcon}
|
|
@@ -253,7 +271,7 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
253
271
|
|
|
254
272
|
return (
|
|
255
273
|
<div
|
|
256
|
-
className={cn(
|
|
274
|
+
className={cn(endSegmentIconWrapperClassname, classes?.endIconWrapper)}
|
|
257
275
|
onClick={handleOnClickRightSectionIcon}
|
|
258
276
|
>
|
|
259
277
|
{endIcon}
|
|
@@ -263,9 +281,9 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
263
281
|
hasRightSectionIcon,
|
|
264
282
|
endIcon,
|
|
265
283
|
iconMode,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
284
|
+
inlineEndIconWrapperClassname,
|
|
285
|
+
endSegmentIconWrapperClassname,
|
|
286
|
+
iconActionClassname,
|
|
269
287
|
renderEndIcon,
|
|
270
288
|
handleOnClickRightSectionIcon,
|
|
271
289
|
]);
|
|
@@ -273,18 +291,6 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
273
291
|
return (
|
|
274
292
|
<div className={`inline-flex flex-col ${fullwidth ? "w-full" : ""}`}>
|
|
275
293
|
<div className="relative">
|
|
276
|
-
{hasSearchIcon && !hasLeftSectionIcon && (
|
|
277
|
-
<div
|
|
278
|
-
className={cn(
|
|
279
|
-
iconSearchWrapperClassname,
|
|
280
|
-
classes?.iconSearchWrapper
|
|
281
|
-
)}
|
|
282
|
-
>
|
|
283
|
-
<MagnifyingGlassIcon
|
|
284
|
-
className={cn(iconClassname, classes?.icon)}
|
|
285
|
-
/>
|
|
286
|
-
</div>
|
|
287
|
-
)}
|
|
288
294
|
<input
|
|
289
295
|
{...props}
|
|
290
296
|
placeholder=" "
|
|
@@ -294,19 +300,33 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
294
300
|
disabled={disabled}
|
|
295
301
|
className={cn(inputClassname, props.className)}
|
|
296
302
|
/>
|
|
303
|
+
{hasSearchIcon && !hasLeftSectionIcon && (
|
|
304
|
+
<div
|
|
305
|
+
className={cn(
|
|
306
|
+
inlineStartIconWrapperClassname,
|
|
307
|
+
classes?.iconSearchWrapper
|
|
308
|
+
)}
|
|
309
|
+
>
|
|
310
|
+
<Search className={cn(iconActionClassname, classes?.icon)} />
|
|
311
|
+
</div>
|
|
312
|
+
)}
|
|
297
313
|
{startIconElement}
|
|
298
314
|
|
|
299
315
|
{hasClearIcon && !hasRightSectionIcon && (
|
|
300
316
|
<div
|
|
301
|
-
className={cn(
|
|
317
|
+
className={cn(inlineEndIconWrapperClassname, classes?.iconWrapper)}
|
|
302
318
|
style={{
|
|
303
319
|
display:
|
|
304
320
|
keepCloseIconOnValue && props.value ? "flex" : undefined,
|
|
305
321
|
}}
|
|
306
322
|
>
|
|
307
|
-
<
|
|
308
|
-
|
|
309
|
-
|
|
323
|
+
<CircleX
|
|
324
|
+
className={cn(
|
|
325
|
+
iconActionClassname,
|
|
326
|
+
// 'fill-none stroke-current',
|
|
327
|
+
// "fill-none stroke-input-default-text hover:stroke-input-filled-text active:stroke-input-filled-text",
|
|
328
|
+
classes?.icon
|
|
329
|
+
)}
|
|
310
330
|
onMouseDown={handleClearInput}
|
|
311
331
|
/>
|
|
312
332
|
</div>
|
|
@@ -317,7 +337,7 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
317
337
|
{label}{" "}
|
|
318
338
|
{required && (
|
|
319
339
|
<span
|
|
320
|
-
className={cn("text-error", {
|
|
340
|
+
className={cn("text-input-error", {
|
|
321
341
|
"text-input-disable-text": disabled,
|
|
322
342
|
})}
|
|
323
343
|
>
|
|
@@ -326,16 +346,24 @@ export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
|
326
346
|
)}
|
|
327
347
|
</label>
|
|
328
348
|
</div>
|
|
329
|
-
{(errorMessage || helperText) && (
|
|
349
|
+
{(errorMessage || helperText || keepFooterSpace) && (
|
|
330
350
|
<span className={helperTextClassname}>
|
|
331
|
-
|
|
332
|
-
<
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
351
|
+
{(errorMessage || helperText) && (
|
|
352
|
+
<span className="h-full shrink-0">
|
|
353
|
+
<CircleAlert
|
|
354
|
+
width={14}
|
|
355
|
+
height={14}
|
|
356
|
+
className={cn(
|
|
357
|
+
"fill-none",
|
|
358
|
+
error ? "stroke-input-error" : "stroke-input-filled-text"
|
|
359
|
+
)}
|
|
360
|
+
/>
|
|
361
|
+
</span>
|
|
362
|
+
)}
|
|
363
|
+
{keepFooterSpace && !error && !helperText && (
|
|
364
|
+
<span className="block min-h-[14px]" aria-hidden />
|
|
365
|
+
)}
|
|
366
|
+
{(error ? errorMessage : helperText) || ''}
|
|
339
367
|
</span>
|
|
340
368
|
)}
|
|
341
369
|
</div>
|