@adam-milo/ui 1.0.21 → 1.0.23
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/index14.cjs +1 -1
- package/dist/index14.js +1 -1
- package/dist/index19.cjs +1 -0
- package/dist/index19.js +22 -0
- package/dist/index20.cjs +1 -0
- package/dist/index20.js +301 -0
- package/dist/index21.cjs +1 -0
- package/dist/index21.js +16 -0
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +28 -104
- package/dist/index33.cjs +1 -0
- package/dist/index33.js +21 -0
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +15 -178
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +42 -172
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +85 -171
- package/dist/src/components/forms/alphanumeric-input/AlphanumericInput.component.d.ts +23 -38
- package/dist/src/components/forms/alphanumeric-input/AlphanumericInput.component.d.ts.map +1 -1
- package/dist/src/components/forms/email-input/EmailInput.component.d.ts +17 -20
- package/dist/src/components/forms/email-input/EmailInput.component.d.ts.map +1 -1
- package/dist/src/components/forms/input/Input.component.d.ts +105 -0
- package/dist/src/components/forms/input/Input.component.d.ts.map +1 -0
- package/dist/src/components/forms/numeric-input/NumericInput.component.d.ts +30 -48
- package/dist/src/components/forms/numeric-input/NumericInput.component.d.ts.map +1 -1
- package/dist/src/components/forms/password-input/PasswordInput.component.d.ts +19 -16
- package/dist/src/components/forms/password-input/PasswordInput.component.d.ts.map +1 -1
- package/dist/src/lib/debounce.d.ts +12 -0
- package/dist/src/lib/debounce.d.ts.map +1 -0
- package/dist/src/lib/debounce.spec.d.ts +2 -0
- package/dist/src/lib/debounce.spec.d.ts.map +1 -0
- package/dist/src/lib/index.d.ts +2 -0
- package/dist/src/lib/index.d.ts.map +1 -1
- package/dist/src/lib/useMergedRef.d.ts +19 -0
- package/dist/src/lib/useMergedRef.d.ts.map +1 -0
- package/dist/style.css +1 -1
- package/package.json +2 -1
- /package/dist/{index31.cjs → index30.cjs} +0 -0
- /package/dist/{index31.js → index30.js} +0 -0
package/dist/index6.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef, useState,
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useRef, useMemo, useCallback, useState, useEffect } from "react";
|
|
3
|
+
import { Input } from "./index20.js";
|
|
4
|
+
import { useMergedRef } from "./index21.js";
|
|
5
5
|
const AlphanumericInput = forwardRef(
|
|
6
6
|
({
|
|
7
7
|
allowHyphen = false,
|
|
@@ -9,185 +9,99 @@ const AlphanumericInput = forwardRef(
|
|
|
9
9
|
allowSpace = false,
|
|
10
10
|
minLength,
|
|
11
11
|
maxLength,
|
|
12
|
-
|
|
13
|
-
minLengthMessage,
|
|
14
|
-
maxLengthMessage,
|
|
15
|
-
onValidationChange,
|
|
16
|
-
error: externalError,
|
|
12
|
+
validate,
|
|
17
13
|
onChange,
|
|
18
|
-
onKeyDown,
|
|
19
|
-
label,
|
|
20
|
-
helperText,
|
|
21
|
-
fullWidth = false,
|
|
22
|
-
className,
|
|
23
|
-
id: providedId,
|
|
24
14
|
"data-cy": dataCy,
|
|
25
15
|
"data-testid": dataTestId,
|
|
26
16
|
...props
|
|
27
17
|
}, ref) => {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const id = providedId || generatedId;
|
|
32
|
-
const errorId = `${id}-error`;
|
|
33
|
-
const helperId = `${id}-helper`;
|
|
34
|
-
const finalDataCy = dataCy || "alphanumeric-input";
|
|
35
|
-
const finalTestId = dataTestId || "alphanumeric-input";
|
|
36
|
-
const validateFormat = (value) => {
|
|
37
|
-
if (!value) return { isValid: true };
|
|
18
|
+
const inputRef = useRef(null);
|
|
19
|
+
const mergedRef = useMergedRef(ref, inputRef);
|
|
20
|
+
const alphanumericRegex = useMemo(() => {
|
|
38
21
|
let pattern = "^[a-zA-Z0-9";
|
|
39
22
|
if (allowHyphen) pattern += "\\-";
|
|
40
23
|
if (allowUnderscore) pattern += "_";
|
|
41
24
|
if (allowSpace) pattern += " ";
|
|
42
|
-
pattern += "]
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
25
|
+
pattern += "]*$";
|
|
26
|
+
return new RegExp(pattern);
|
|
27
|
+
}, [allowHyphen, allowUnderscore, allowSpace]);
|
|
28
|
+
const characterRegex = useMemo(() => {
|
|
29
|
+
let pattern = "[a-zA-Z0-9";
|
|
30
|
+
if (allowHyphen) pattern += "\\-";
|
|
31
|
+
if (allowUnderscore) pattern += "_";
|
|
32
|
+
if (allowSpace) pattern += " ";
|
|
33
|
+
pattern += "]";
|
|
34
|
+
return new RegExp(pattern);
|
|
35
|
+
}, [allowHyphen, allowUnderscore, allowSpace]);
|
|
36
|
+
const alphanumericValidation = useCallback(
|
|
37
|
+
(value) => {
|
|
38
|
+
if (!value) return void 0;
|
|
39
|
+
if (!alphanumericRegex.test(value)) {
|
|
40
|
+
let allowedChars = "letters and numbers";
|
|
41
|
+
const extras = [];
|
|
42
|
+
if (allowHyphen) extras.push("hyphens");
|
|
43
|
+
if (allowUnderscore) extras.push("underscores");
|
|
44
|
+
if (allowSpace) extras.push("spaces");
|
|
45
|
+
if (extras.length > 0) {
|
|
46
|
+
allowedChars += `, ${extras.join(", ")}`;
|
|
47
|
+
}
|
|
48
|
+
return `Only ${allowedChars} are allowed`;
|
|
52
49
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"Enter",
|
|
76
|
-
"ArrowLeft",
|
|
77
|
-
"ArrowRight",
|
|
78
|
-
"Home",
|
|
79
|
-
"End"
|
|
80
|
-
];
|
|
81
|
-
if (e.ctrlKey || e.metaKey) {
|
|
82
|
-
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (allowedKeys.includes(e.key)) {
|
|
86
|
-
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (allowSpace && e.key === " ") {
|
|
90
|
-
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (allowHyphen && e.key === "-") {
|
|
94
|
-
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (allowUnderscore && e.key === "_") {
|
|
98
|
-
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (e.key >= "a" && e.key <= "z" || e.key >= "A" && e.key <= "Z") {
|
|
102
|
-
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
if (e.key >= "0" && e.key <= "9") {
|
|
106
|
-
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
e.preventDefault();
|
|
110
|
-
};
|
|
111
|
-
const handleChange = (e) => {
|
|
112
|
-
const value = e.target.value;
|
|
113
|
-
if (touched) {
|
|
114
|
-
const validation = validateFormat(value);
|
|
115
|
-
setInternalError(validation.error);
|
|
116
|
-
onValidationChange == null ? void 0 : onValidationChange(validation.isValid);
|
|
50
|
+
if (minLength !== void 0 && value.length < minLength) {
|
|
51
|
+
return `Must be at least ${minLength} characters`;
|
|
52
|
+
}
|
|
53
|
+
if (maxLength !== void 0 && value.length > maxLength) {
|
|
54
|
+
return `Must be at most ${maxLength} characters`;
|
|
55
|
+
}
|
|
56
|
+
return void 0;
|
|
57
|
+
},
|
|
58
|
+
[alphanumericRegex, minLength, maxLength, allowHyphen, allowUnderscore, allowSpace]
|
|
59
|
+
);
|
|
60
|
+
const combinedValidation = useCallback(
|
|
61
|
+
(value) => {
|
|
62
|
+
if (!validate) return alphanumericValidation(value);
|
|
63
|
+
return alphanumericValidation(value) || validate(value);
|
|
64
|
+
},
|
|
65
|
+
[alphanumericValidation, validate]
|
|
66
|
+
);
|
|
67
|
+
const [pendingCursorPosition, setPendingCursorPosition] = useState(null);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (pendingCursorPosition !== null && inputRef.current) {
|
|
70
|
+
inputRef.current.setSelectionRange(pendingCursorPosition, pendingCursorPosition);
|
|
71
|
+
setPendingCursorPosition(null);
|
|
117
72
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
73
|
+
}, [props.value, pendingCursorPosition]);
|
|
74
|
+
const handleChange = useCallback(
|
|
75
|
+
(e) => {
|
|
76
|
+
const input = e.target;
|
|
77
|
+
const value = input.value;
|
|
78
|
+
const cursorPosition = input.selectionStart || 0;
|
|
79
|
+
const filteredValue = value.split("").filter((char) => characterRegex.test(char)).join("");
|
|
80
|
+
const removedBeforeCursor = value.slice(0, cursorPosition).split("").filter((char) => !characterRegex.test(char)).length;
|
|
81
|
+
const newPosition = cursorPosition - removedBeforeCursor;
|
|
82
|
+
input.value = filteredValue;
|
|
83
|
+
const isControlled = props.value !== void 0;
|
|
84
|
+
if (isControlled) {
|
|
85
|
+
setPendingCursorPosition(newPosition);
|
|
86
|
+
} else {
|
|
87
|
+
input.setSelectionRange(newPosition, newPosition);
|
|
88
|
+
}
|
|
89
|
+
onChange == null ? void 0 : onChange(e);
|
|
90
|
+
},
|
|
91
|
+
[characterRegex, onChange, props.value]
|
|
92
|
+
);
|
|
93
|
+
return /* @__PURE__ */ jsx(
|
|
94
|
+
Input,
|
|
131
95
|
{
|
|
132
|
-
|
|
133
|
-
"
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
"data-cy": `${finalDataCy}-label`,
|
|
142
|
-
"data-testid": `${finalTestId}-label`,
|
|
143
|
-
children: label
|
|
144
|
-
}
|
|
145
|
-
),
|
|
146
|
-
/* @__PURE__ */ jsx(
|
|
147
|
-
"input",
|
|
148
|
-
{
|
|
149
|
-
ref,
|
|
150
|
-
id,
|
|
151
|
-
type: "text",
|
|
152
|
-
className: cn(
|
|
153
|
-
"input",
|
|
154
|
-
displayError && "input--error",
|
|
155
|
-
fullWidth && "input--full-width",
|
|
156
|
-
className
|
|
157
|
-
),
|
|
158
|
-
"aria-invalid": displayError ? "true" : "false",
|
|
159
|
-
"aria-describedby": displayError ? errorId : helperText ? helperId : void 0,
|
|
160
|
-
"data-cy": finalDataCy,
|
|
161
|
-
"data-testid": finalTestId,
|
|
162
|
-
onChange: handleChange,
|
|
163
|
-
onBlur: handleBlur,
|
|
164
|
-
onKeyDown: handleKeyDown,
|
|
165
|
-
maxLength,
|
|
166
|
-
...props
|
|
167
|
-
}
|
|
168
|
-
),
|
|
169
|
-
displayError && /* @__PURE__ */ jsx(
|
|
170
|
-
"span",
|
|
171
|
-
{
|
|
172
|
-
id: errorId,
|
|
173
|
-
className: "input__error",
|
|
174
|
-
role: "alert",
|
|
175
|
-
"data-cy": `${finalDataCy}-error`,
|
|
176
|
-
"data-testid": `${finalTestId}-error`,
|
|
177
|
-
children: displayError
|
|
178
|
-
}
|
|
179
|
-
),
|
|
180
|
-
helperText && !displayError && /* @__PURE__ */ jsx(
|
|
181
|
-
"span",
|
|
182
|
-
{
|
|
183
|
-
id: helperId,
|
|
184
|
-
className: "input__helper",
|
|
185
|
-
"data-cy": `${finalDataCy}-helper`,
|
|
186
|
-
"data-testid": `${finalTestId}-helper`,
|
|
187
|
-
children: helperText
|
|
188
|
-
}
|
|
189
|
-
)
|
|
190
|
-
]
|
|
96
|
+
ref: mergedRef,
|
|
97
|
+
type: "text",
|
|
98
|
+
minLength,
|
|
99
|
+
maxLength,
|
|
100
|
+
validate: combinedValidation,
|
|
101
|
+
onChange: handleChange,
|
|
102
|
+
"data-cy": dataCy || "alphanumeric-input",
|
|
103
|
+
"data-testid": dataTestId || "alphanumeric-input",
|
|
104
|
+
...props
|
|
191
105
|
}
|
|
192
106
|
);
|
|
193
107
|
}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputProps } from '../input/Input.component';
|
|
2
2
|
|
|
3
|
-
export interface AlphanumericInputProps extends Omit<
|
|
4
|
-
label?: string;
|
|
5
|
-
error?: string;
|
|
6
|
-
helperText?: string;
|
|
7
|
-
fullWidth?: boolean;
|
|
3
|
+
export interface AlphanumericInputProps extends Omit<InputProps, 'type'> {
|
|
8
4
|
/**
|
|
9
|
-
* Allow
|
|
5
|
+
* Allow hyphens in the input
|
|
10
6
|
* @default false
|
|
11
7
|
*/
|
|
12
8
|
allowHyphen?: boolean;
|
|
13
9
|
/**
|
|
14
|
-
* Allow
|
|
10
|
+
* Allow underscores in the input
|
|
15
11
|
* @default false
|
|
16
12
|
*/
|
|
17
13
|
allowUnderscore?: boolean;
|
|
18
14
|
/**
|
|
19
|
-
* Allow
|
|
15
|
+
* Allow spaces in the input
|
|
20
16
|
* @default false
|
|
21
17
|
*/
|
|
22
18
|
allowSpace?: boolean;
|
|
@@ -28,35 +24,24 @@ export interface AlphanumericInputProps extends Omit<InputHTMLAttributes<HTMLInp
|
|
|
28
24
|
* Maximum length
|
|
29
25
|
*/
|
|
30
26
|
maxLength?: number;
|
|
31
|
-
/**
|
|
32
|
-
* Custom validation message for invalid format
|
|
33
|
-
* @default "Only letters and numbers are allowed"
|
|
34
|
-
*/
|
|
35
|
-
invalidFormatMessage?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Custom validation message for min length
|
|
38
|
-
* @default "Must be at least {minLength} characters"
|
|
39
|
-
*/
|
|
40
|
-
minLengthMessage?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Custom validation message for max length
|
|
43
|
-
* @default "Must be at most {maxLength} characters"
|
|
44
|
-
*/
|
|
45
|
-
maxLengthMessage?: string;
|
|
46
|
-
/**
|
|
47
|
-
* Callback when validation changes
|
|
48
|
-
*/
|
|
49
|
-
onValidationChange?: (isValid: boolean) => void;
|
|
50
|
-
/**
|
|
51
|
-
* Custom data-cy attribute for Cypress testing
|
|
52
|
-
* Auto-generates as "alphanumeric-input" if not provided
|
|
53
|
-
*/
|
|
54
|
-
'data-cy'?: string;
|
|
55
|
-
/**
|
|
56
|
-
* Custom data-testid attribute for unit testing
|
|
57
|
-
* Auto-generates as "alphanumeric-input" if not provided
|
|
58
|
-
*/
|
|
59
|
-
'data-testid'?: string;
|
|
60
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* AlphanumericInput - Specialized input component for alphanumeric values
|
|
30
|
+
*
|
|
31
|
+
* A wrapper around the base Input component that only allows letters and numbers,
|
|
32
|
+
* with optional support for hyphens, underscores, and spaces.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <AlphanumericInput
|
|
37
|
+
* label="Username"
|
|
38
|
+
* placeholder="Enter username"
|
|
39
|
+
* minLength={3}
|
|
40
|
+
* maxLength={20}
|
|
41
|
+
* allowUnderscore={true}
|
|
42
|
+
* required
|
|
43
|
+
* />
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
61
46
|
export declare const AlphanumericInput: import('react').ForwardRefExoticComponent<AlphanumericInputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
62
47
|
//# sourceMappingURL=AlphanumericInput.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlphanumericInput.component.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/alphanumeric-input/AlphanumericInput.component.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AlphanumericInput.component.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/alphanumeric-input/AlphanumericInput.component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAS,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG7D,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;IACtE;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iBAAiB,qHAwJ7B,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputProps } from '../input/Input.component';
|
|
2
2
|
|
|
3
|
-
export interface EmailInputProps extends Omit<
|
|
4
|
-
label?: string;
|
|
5
|
-
error?: string;
|
|
6
|
-
helperText?: string;
|
|
7
|
-
fullWidth?: boolean;
|
|
3
|
+
export interface EmailInputProps extends Omit<InputProps, 'type'> {
|
|
8
4
|
/**
|
|
9
5
|
* Enable client-side email validation
|
|
10
6
|
* @default true
|
|
@@ -15,20 +11,21 @@ export interface EmailInputProps extends Omit<InputHTMLAttributes<HTMLInputEleme
|
|
|
15
11
|
* @default "Not a valid email address"
|
|
16
12
|
*/
|
|
17
13
|
invalidEmailMessage?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Callback when email validation changes
|
|
20
|
-
*/
|
|
21
|
-
onValidationChange?: (isValid: boolean) => void;
|
|
22
|
-
/**
|
|
23
|
-
* Custom data-cy attribute for Cypress testing
|
|
24
|
-
* Auto-generates as "email-input" if not provided
|
|
25
|
-
*/
|
|
26
|
-
'data-cy'?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Custom data-testid attribute for unit testing
|
|
29
|
-
* Auto-generates as "email-input" if not provided
|
|
30
|
-
*/
|
|
31
|
-
'data-testid'?: string;
|
|
32
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* EmailInput - Specialized input component for email addresses
|
|
17
|
+
*
|
|
18
|
+
* A wrapper around the base Input component with built-in email validation.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <EmailInput
|
|
23
|
+
* label="Email"
|
|
24
|
+
* placeholder="Enter your email"
|
|
25
|
+
* required
|
|
26
|
+
* validateEmail={true}
|
|
27
|
+
* />
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
33
30
|
export declare const EmailInput: import('react').ForwardRefExoticComponent<EmailInputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
34
31
|
//# sourceMappingURL=EmailInput.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailInput.component.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/email-input/EmailInput.component.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EmailInput.component.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/email-input/EmailInput.component.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAS,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;IAC/D;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,8GA4CtB,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Label text for the input
|
|
6
|
+
*/
|
|
7
|
+
label?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Error message to display below the input
|
|
10
|
+
*/
|
|
11
|
+
error?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Helper text to display below the input (only shown when no error)
|
|
14
|
+
*/
|
|
15
|
+
helperText?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the input should take full width
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
fullWidth?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Show password visibility toggle (only for type="password")
|
|
23
|
+
* @default true for password inputs
|
|
24
|
+
*/
|
|
25
|
+
showPasswordToggle?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Show last character preview for password inputs
|
|
28
|
+
* When enabled, only the last typed character is visible, all others are masked with bullets (•)
|
|
29
|
+
* NOTE: Only works in uncontrolled mode (without value prop)
|
|
30
|
+
* @default true for password inputs
|
|
31
|
+
*/
|
|
32
|
+
showLastChar?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Delay in milliseconds before fully masking the last character
|
|
35
|
+
* @default 500
|
|
36
|
+
*/
|
|
37
|
+
lastCharDelay?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Custom validation function
|
|
40
|
+
* Returns error message if invalid, undefined if valid
|
|
41
|
+
*/
|
|
42
|
+
validate?: (value: string) => string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Callback when validation state changes
|
|
45
|
+
*/
|
|
46
|
+
onValidationChange?: (isValid: boolean) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Custom data-cy attribute for Cypress testing
|
|
49
|
+
* Auto-generates as "input" if not provided
|
|
50
|
+
*/
|
|
51
|
+
'data-cy'?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Custom data-testid attribute for unit testing
|
|
54
|
+
* Auto-generates as "input" if not provided
|
|
55
|
+
*/
|
|
56
|
+
'data-testid'?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Input - Generic input component for the Saas Design System
|
|
60
|
+
*
|
|
61
|
+
* A flexible input component that can be configured for different use cases:
|
|
62
|
+
* - Text input
|
|
63
|
+
* - Email input with custom validation
|
|
64
|
+
* - Password input with visibility toggle and last character preview
|
|
65
|
+
* - Any other HTML input type
|
|
66
|
+
*
|
|
67
|
+
* Features:
|
|
68
|
+
* - Automatically adds asterisk (*) to label when required={true}
|
|
69
|
+
* - Adds aria-required attribute for accessibility
|
|
70
|
+
* - Custom validation with error messages
|
|
71
|
+
* - Password visibility toggle
|
|
72
|
+
* - Last character preview for password inputs (shows ONLY last typed char, masks rest with •)
|
|
73
|
+
* - Helper text support
|
|
74
|
+
* - Full keyboard accessibility
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* // Simple text input
|
|
79
|
+
* <Input label="Name" placeholder="Enter your name" />
|
|
80
|
+
*
|
|
81
|
+
* // Email with validation (asterisk added automatically)
|
|
82
|
+
* <Input
|
|
83
|
+
* type="email"
|
|
84
|
+
* label="Email"
|
|
85
|
+
* placeholder="Enter your email"
|
|
86
|
+
* required
|
|
87
|
+
* validate={(value) => {
|
|
88
|
+
* if (!value.includes('@')) return 'Not a valid email';
|
|
89
|
+
* }}
|
|
90
|
+
* />
|
|
91
|
+
*
|
|
92
|
+
* // Password with toggle and last char preview (asterisk added automatically)
|
|
93
|
+
* <Input
|
|
94
|
+
* type="password"
|
|
95
|
+
* label="Password"
|
|
96
|
+
* placeholder="Enter your password"
|
|
97
|
+
* required
|
|
98
|
+
* showPasswordToggle
|
|
99
|
+
* showLastChar
|
|
100
|
+
* lastCharDelay={500}
|
|
101
|
+
* />
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare const Input: import('react').ForwardRefExoticComponent<InputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
105
|
+
//# sourceMappingURL=Input.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.component.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/input/Input.component.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAQpB,MAAM,OAAO,CAAC;AAEf,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,UAAW,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;IACvE;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAEjD;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAEhD;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,KAAK,yGAsWjB,CAAC"}
|
|
@@ -1,62 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputProps } from '../input/Input.component';
|
|
2
2
|
|
|
3
|
-
export interface NumericInputProps extends Omit<
|
|
4
|
-
label?: string;
|
|
5
|
-
error?: string;
|
|
6
|
-
helperText?: string;
|
|
7
|
-
fullWidth?: boolean;
|
|
3
|
+
export interface NumericInputProps extends Omit<InputProps, 'type'> {
|
|
8
4
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @default false
|
|
11
|
-
*/
|
|
12
|
-
allowDecimal?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Allow negative numbers
|
|
15
|
-
* @default false
|
|
16
|
-
*/
|
|
17
|
-
allowNegative?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Minimum value (inclusive)
|
|
5
|
+
* Minimum value allowed
|
|
20
6
|
*/
|
|
21
7
|
min?: number;
|
|
22
8
|
/**
|
|
23
|
-
* Maximum value
|
|
9
|
+
* Maximum value allowed
|
|
24
10
|
*/
|
|
25
11
|
max?: number;
|
|
26
12
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @default
|
|
29
|
-
*/
|
|
30
|
-
decimalPlaces?: number;
|
|
31
|
-
/**
|
|
32
|
-
* Custom validation message for invalid number
|
|
33
|
-
* @default "Please enter a valid number"
|
|
13
|
+
* Step increment for the number input
|
|
14
|
+
* @default 1
|
|
34
15
|
*/
|
|
35
|
-
|
|
16
|
+
step?: number;
|
|
36
17
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @default
|
|
39
|
-
*/
|
|
40
|
-
minValueMessage?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Custom validation message for max value
|
|
43
|
-
* @default "Value must be at most {max}"
|
|
44
|
-
*/
|
|
45
|
-
maxValueMessage?: string;
|
|
46
|
-
/**
|
|
47
|
-
* Callback when validation changes
|
|
48
|
-
*/
|
|
49
|
-
onValidationChange?: (isValid: boolean) => void;
|
|
50
|
-
/**
|
|
51
|
-
* Custom data-cy attribute for Cypress testing
|
|
52
|
-
* Auto-generates as "numeric-input" if not provided
|
|
53
|
-
*/
|
|
54
|
-
'data-cy'?: string;
|
|
55
|
-
/**
|
|
56
|
-
* Custom data-testid attribute for unit testing
|
|
57
|
-
* Auto-generates as "numeric-input" if not provided
|
|
18
|
+
* Allow decimal numbers
|
|
19
|
+
* @default false
|
|
58
20
|
*/
|
|
59
|
-
|
|
21
|
+
allowDecimals?: boolean;
|
|
60
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* NumericInput - Specialized input component for numeric values
|
|
25
|
+
*
|
|
26
|
+
* A wrapper around the base Input component with number-specific features:
|
|
27
|
+
* - Type="number" by default
|
|
28
|
+
* - Min/max validation
|
|
29
|
+
* - Step increments
|
|
30
|
+
* - Optional decimal support
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <NumericInput
|
|
35
|
+
* label="Age"
|
|
36
|
+
* placeholder="Enter age"
|
|
37
|
+
* min={0}
|
|
38
|
+
* max={120}
|
|
39
|
+
* required
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
61
43
|
export declare const NumericInput: import('react').ForwardRefExoticComponent<NumericInputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
62
44
|
//# sourceMappingURL=NumericInput.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericInput.component.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/numeric-input/NumericInput.component.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NumericInput.component.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/numeric-input/NumericInput.component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAS,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;IACjE;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,gHAmExB,CAAC"}
|