@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/index4.js
CHANGED
|
@@ -1,182 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef
|
|
3
|
-
import {
|
|
4
|
-
/* empty css */
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { Input } from "./index20.js";
|
|
5
4
|
const PasswordInput = forwardRef(
|
|
6
|
-
({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
|
|
19
|
-
const generatedId = useId();
|
|
20
|
-
const id = providedId || generatedId;
|
|
21
|
-
const errorId = `${id}-error`;
|
|
22
|
-
const helperId = `${id}-helper`;
|
|
23
|
-
const finalDataCy = dataCy || "password-input";
|
|
24
|
-
const finalTestId = dataTestId || "password-input";
|
|
25
|
-
const togglePasswordVisibility = () => {
|
|
26
|
-
setIsPasswordVisible((prev) => !prev);
|
|
27
|
-
};
|
|
28
|
-
return /* @__PURE__ */ jsxs("div", { className: "password-input-wrapper", children: [
|
|
29
|
-
/* @__PURE__ */ jsxs(
|
|
30
|
-
"div",
|
|
31
|
-
{
|
|
32
|
-
className: cn("input-wrapper", fullWidth && "input-wrapper--full-width"),
|
|
33
|
-
"data-cy": `${finalDataCy}-wrapper`,
|
|
34
|
-
"data-testid": `${finalTestId}-wrapper`,
|
|
35
|
-
children: [
|
|
36
|
-
label && /* @__PURE__ */ jsx(
|
|
37
|
-
"label",
|
|
38
|
-
{
|
|
39
|
-
htmlFor: id,
|
|
40
|
-
className: "input__label",
|
|
41
|
-
"data-cy": `${finalDataCy}-label`,
|
|
42
|
-
"data-testid": `${finalTestId}-label`,
|
|
43
|
-
children: label
|
|
44
|
-
}
|
|
45
|
-
),
|
|
46
|
-
/* @__PURE__ */ jsx(
|
|
47
|
-
"input",
|
|
48
|
-
{
|
|
49
|
-
ref,
|
|
50
|
-
id,
|
|
51
|
-
type: isPasswordVisible ? "text" : "password",
|
|
52
|
-
className: cn(
|
|
53
|
-
"input",
|
|
54
|
-
"password-input",
|
|
55
|
-
error && "input--error",
|
|
56
|
-
fullWidth && "input--full-width",
|
|
57
|
-
className
|
|
58
|
-
),
|
|
59
|
-
"aria-invalid": error ? "true" : "false",
|
|
60
|
-
"aria-describedby": error ? errorId : helperText ? helperId : void 0,
|
|
61
|
-
"data-cy": finalDataCy,
|
|
62
|
-
"data-testid": finalTestId,
|
|
63
|
-
...props
|
|
64
|
-
}
|
|
65
|
-
),
|
|
66
|
-
error && /* @__PURE__ */ jsx(
|
|
67
|
-
"span",
|
|
68
|
-
{
|
|
69
|
-
id: errorId,
|
|
70
|
-
className: "input__error",
|
|
71
|
-
role: "alert",
|
|
72
|
-
"data-cy": `${finalDataCy}-error`,
|
|
73
|
-
"data-testid": `${finalTestId}-error`,
|
|
74
|
-
children: error
|
|
75
|
-
}
|
|
76
|
-
),
|
|
77
|
-
helperText && !error && /* @__PURE__ */ jsx(
|
|
78
|
-
"span",
|
|
79
|
-
{
|
|
80
|
-
id: helperId,
|
|
81
|
-
className: "input__helper",
|
|
82
|
-
"data-cy": `${finalDataCy}-helper`,
|
|
83
|
-
"data-testid": `${finalTestId}-helper`,
|
|
84
|
-
children: helperText
|
|
85
|
-
}
|
|
86
|
-
)
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
),
|
|
90
|
-
showToggle && /* @__PURE__ */ jsx(
|
|
91
|
-
"button",
|
|
92
|
-
{
|
|
93
|
-
type: "button",
|
|
94
|
-
className: "password-input__toggle",
|
|
95
|
-
onClick: togglePasswordVisibility,
|
|
96
|
-
"aria-label": isPasswordVisible ? "Hide password" : "Show password",
|
|
97
|
-
"data-cy": `${finalDataCy}-toggle`,
|
|
98
|
-
"data-testid": `${finalTestId}-toggle`,
|
|
99
|
-
children: isPasswordVisible ? /* @__PURE__ */ jsxs(
|
|
100
|
-
"svg",
|
|
101
|
-
{
|
|
102
|
-
width: "20",
|
|
103
|
-
height: "20",
|
|
104
|
-
viewBox: "0 0 20 20",
|
|
105
|
-
fill: "none",
|
|
106
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
107
|
-
"aria-hidden": "true",
|
|
108
|
-
children: [
|
|
109
|
-
/* @__PURE__ */ jsx(
|
|
110
|
-
"path",
|
|
111
|
-
{
|
|
112
|
-
d: "M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",
|
|
113
|
-
stroke: "currentColor",
|
|
114
|
-
strokeWidth: "1.5",
|
|
115
|
-
strokeLinecap: "round",
|
|
116
|
-
strokeLinejoin: "round",
|
|
117
|
-
fill: "none"
|
|
118
|
-
}
|
|
119
|
-
),
|
|
120
|
-
/* @__PURE__ */ jsx(
|
|
121
|
-
"circle",
|
|
122
|
-
{
|
|
123
|
-
cx: "10",
|
|
124
|
-
cy: "10",
|
|
125
|
-
r: "2.5",
|
|
126
|
-
stroke: "currentColor",
|
|
127
|
-
strokeWidth: "1.5",
|
|
128
|
-
fill: "none"
|
|
129
|
-
}
|
|
130
|
-
)
|
|
131
|
-
]
|
|
132
|
-
}
|
|
133
|
-
) : /* @__PURE__ */ jsxs(
|
|
134
|
-
"svg",
|
|
135
|
-
{
|
|
136
|
-
width: "20",
|
|
137
|
-
height: "20",
|
|
138
|
-
viewBox: "0 0 20 20",
|
|
139
|
-
fill: "none",
|
|
140
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
141
|
-
"aria-hidden": "true",
|
|
142
|
-
children: [
|
|
143
|
-
/* @__PURE__ */ jsx(
|
|
144
|
-
"path",
|
|
145
|
-
{
|
|
146
|
-
d: "M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",
|
|
147
|
-
stroke: "currentColor",
|
|
148
|
-
strokeWidth: "1.5",
|
|
149
|
-
strokeLinecap: "round",
|
|
150
|
-
strokeLinejoin: "round",
|
|
151
|
-
fill: "none"
|
|
152
|
-
}
|
|
153
|
-
),
|
|
154
|
-
/* @__PURE__ */ jsx(
|
|
155
|
-
"circle",
|
|
156
|
-
{
|
|
157
|
-
cx: "10",
|
|
158
|
-
cy: "10",
|
|
159
|
-
r: "2.5",
|
|
160
|
-
stroke: "currentColor",
|
|
161
|
-
strokeWidth: "1.5",
|
|
162
|
-
fill: "none"
|
|
163
|
-
}
|
|
164
|
-
),
|
|
165
|
-
/* @__PURE__ */ jsx(
|
|
166
|
-
"path",
|
|
167
|
-
{
|
|
168
|
-
d: "M3 3l14 14",
|
|
169
|
-
stroke: "currentColor",
|
|
170
|
-
strokeWidth: "1.5",
|
|
171
|
-
strokeLinecap: "round"
|
|
172
|
-
}
|
|
173
|
-
)
|
|
174
|
-
]
|
|
175
|
-
}
|
|
176
|
-
)
|
|
177
|
-
}
|
|
178
|
-
)
|
|
179
|
-
] });
|
|
5
|
+
({ showToggle = true, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
Input,
|
|
8
|
+
{
|
|
9
|
+
ref,
|
|
10
|
+
type: "password",
|
|
11
|
+
showPasswordToggle: showToggle,
|
|
12
|
+
"data-cy": dataCy || "password-input",
|
|
13
|
+
"data-testid": dataTestId || "password-input",
|
|
14
|
+
...props
|
|
15
|
+
}
|
|
16
|
+
);
|
|
180
17
|
}
|
|
181
18
|
);
|
|
182
19
|
PasswordInput.displayName = "PasswordInput";
|
package/dist/index5.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),a=require("./index20.cjs"),r=t.forwardRef(({min:r,max:i,step:s=1,allowDecimals:u=!1,validate:n,"data-cy":l,"data-testid":c,...d},o)=>{const m=t.useCallback(e=>{if(!e)return;const t=parseFloat(e);return isNaN(t)?"Please enter a valid number":u||Number.isInteger(t)?void 0!==r&&t<r?`Must be at least ${r}`:void 0!==i&&t>i?`Must be at most ${i}`:void 0:"Decimals are not allowed"},[r,i,u]),p=t.useCallback(e=>n?m(e)||n(e):m(e),[m,n]);return e.jsx(a.Input,{ref:o,type:"number",min:r,max:i,validate:p,"data-cy":l||"numeric-input","data-testid":c||"numeric-input",...d,step:u?"any":s})});r.displayName="NumericInput",exports.NumericInput=r;
|
package/dist/index5.js
CHANGED
|
@@ -1,186 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef,
|
|
3
|
-
import {
|
|
4
|
-
/* empty css */
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback } from "react";
|
|
3
|
+
import { Input } from "./index20.js";
|
|
5
4
|
const NumericInput = forwardRef(
|
|
6
5
|
({
|
|
7
|
-
allowDecimal = false,
|
|
8
|
-
allowNegative = false,
|
|
9
6
|
min,
|
|
10
7
|
max,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
maxValueMessage,
|
|
15
|
-
onValidationChange,
|
|
16
|
-
error: externalError,
|
|
17
|
-
onChange,
|
|
18
|
-
onKeyDown,
|
|
19
|
-
label,
|
|
20
|
-
helperText,
|
|
21
|
-
fullWidth = false,
|
|
22
|
-
className,
|
|
23
|
-
id: providedId,
|
|
8
|
+
step = 1,
|
|
9
|
+
allowDecimals = false,
|
|
10
|
+
validate,
|
|
24
11
|
"data-cy": dataCy,
|
|
25
12
|
"data-testid": dataTestId,
|
|
26
13
|
...props
|
|
27
14
|
}, ref) => {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const finalDataCy = dataCy || "numeric-input";
|
|
35
|
-
const finalTestId = dataTestId || "numeric-input";
|
|
36
|
-
const validateNumber = (value) => {
|
|
37
|
-
if (!value) return { isValid: true };
|
|
38
|
-
const isNegativeAllowed = allowNegative ? "-?" : "";
|
|
39
|
-
const decimalPattern = allowDecimal ? `(\\.\\d{0,${decimalPlaces}})?` : "";
|
|
40
|
-
const regex = new RegExp(`^${isNegativeAllowed}\\d+${decimalPattern}$`);
|
|
41
|
-
if (!regex.test(value)) {
|
|
42
|
-
return { isValid: false, error: invalidNumberMessage };
|
|
43
|
-
}
|
|
44
|
-
const numValue = parseFloat(value);
|
|
45
|
-
if (min !== void 0 && numValue < min) {
|
|
46
|
-
return {
|
|
47
|
-
isValid: false,
|
|
48
|
-
error: minValueMessage || `Value must be at least ${min}`
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
if (max !== void 0 && numValue > max) {
|
|
52
|
-
return {
|
|
53
|
-
isValid: false,
|
|
54
|
-
error: maxValueMessage || `Value must be at most ${max}`
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return { isValid: true };
|
|
58
|
-
};
|
|
59
|
-
const handleKeyDown = (e) => {
|
|
60
|
-
const allowedKeys = [
|
|
61
|
-
"Backspace",
|
|
62
|
-
"Delete",
|
|
63
|
-
"Tab",
|
|
64
|
-
"Escape",
|
|
65
|
-
"Enter",
|
|
66
|
-
"ArrowLeft",
|
|
67
|
-
"ArrowRight",
|
|
68
|
-
"Home",
|
|
69
|
-
"End"
|
|
70
|
-
];
|
|
71
|
-
if (e.ctrlKey || e.metaKey) {
|
|
72
|
-
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (allowedKeys.includes(e.key)) {
|
|
76
|
-
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (allowDecimal && e.key === ".") {
|
|
80
|
-
const value = e.currentTarget.value;
|
|
81
|
-
if (value.includes(".")) {
|
|
82
|
-
e.preventDefault();
|
|
83
|
-
return;
|
|
15
|
+
const numericValidation = useCallback(
|
|
16
|
+
(value) => {
|
|
17
|
+
if (!value) return void 0;
|
|
18
|
+
const numValue = parseFloat(value);
|
|
19
|
+
if (isNaN(numValue)) {
|
|
20
|
+
return "Please enter a valid number";
|
|
84
21
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
if (allowNegative && e.key === "-") {
|
|
89
|
-
const value = e.currentTarget.value;
|
|
90
|
-
const selectionStart = e.currentTarget.selectionStart || 0;
|
|
91
|
-
if (selectionStart !== 0 || value.includes("-")) {
|
|
92
|
-
e.preventDefault();
|
|
93
|
-
return;
|
|
22
|
+
if (!allowDecimals && !Number.isInteger(numValue)) {
|
|
23
|
+
return "Decimals are not allowed";
|
|
94
24
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var _a;
|
|
115
|
-
setTouched(true);
|
|
116
|
-
const validation = validateNumber(e.target.value);
|
|
117
|
-
setInternalError(validation.error);
|
|
118
|
-
onValidationChange == null ? void 0 : onValidationChange(validation.isValid);
|
|
119
|
-
(_a = props.onBlur) == null ? void 0 : _a.call(props, e);
|
|
120
|
-
};
|
|
121
|
-
const displayError = externalError || internalError;
|
|
122
|
-
return /* @__PURE__ */ jsxs(
|
|
123
|
-
"div",
|
|
25
|
+
if (min !== void 0 && numValue < min) {
|
|
26
|
+
return `Must be at least ${min}`;
|
|
27
|
+
}
|
|
28
|
+
if (max !== void 0 && numValue > max) {
|
|
29
|
+
return `Must be at most ${max}`;
|
|
30
|
+
}
|
|
31
|
+
return void 0;
|
|
32
|
+
},
|
|
33
|
+
[min, max, allowDecimals]
|
|
34
|
+
);
|
|
35
|
+
const combinedValidation = useCallback(
|
|
36
|
+
(value) => {
|
|
37
|
+
if (!validate) return numericValidation(value);
|
|
38
|
+
return numericValidation(value) || validate(value);
|
|
39
|
+
},
|
|
40
|
+
[numericValidation, validate]
|
|
41
|
+
);
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
Input,
|
|
124
44
|
{
|
|
125
|
-
|
|
126
|
-
"
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"data-cy": `${finalDataCy}-label`,
|
|
135
|
-
"data-testid": `${finalTestId}-label`,
|
|
136
|
-
children: label
|
|
137
|
-
}
|
|
138
|
-
),
|
|
139
|
-
/* @__PURE__ */ jsx(
|
|
140
|
-
"input",
|
|
141
|
-
{
|
|
142
|
-
ref,
|
|
143
|
-
id,
|
|
144
|
-
type: "text",
|
|
145
|
-
inputMode: "numeric",
|
|
146
|
-
className: cn(
|
|
147
|
-
"input",
|
|
148
|
-
displayError && "input--error",
|
|
149
|
-
fullWidth && "input--full-width",
|
|
150
|
-
className
|
|
151
|
-
),
|
|
152
|
-
"aria-invalid": displayError ? "true" : "false",
|
|
153
|
-
"aria-describedby": displayError ? errorId : helperText ? helperId : void 0,
|
|
154
|
-
"data-cy": finalDataCy,
|
|
155
|
-
"data-testid": finalTestId,
|
|
156
|
-
onChange: handleChange,
|
|
157
|
-
onBlur: handleBlur,
|
|
158
|
-
onKeyDown: handleKeyDown,
|
|
159
|
-
...props
|
|
160
|
-
}
|
|
161
|
-
),
|
|
162
|
-
displayError && /* @__PURE__ */ jsx(
|
|
163
|
-
"span",
|
|
164
|
-
{
|
|
165
|
-
id: errorId,
|
|
166
|
-
className: "input__error",
|
|
167
|
-
role: "alert",
|
|
168
|
-
"data-cy": `${finalDataCy}-error`,
|
|
169
|
-
"data-testid": `${finalTestId}-error`,
|
|
170
|
-
children: displayError
|
|
171
|
-
}
|
|
172
|
-
),
|
|
173
|
-
helperText && !displayError && /* @__PURE__ */ jsx(
|
|
174
|
-
"span",
|
|
175
|
-
{
|
|
176
|
-
id: helperId,
|
|
177
|
-
className: "input__helper",
|
|
178
|
-
"data-cy": `${finalDataCy}-helper`,
|
|
179
|
-
"data-testid": `${finalTestId}-helper`,
|
|
180
|
-
children: helperText
|
|
181
|
-
}
|
|
182
|
-
)
|
|
183
|
-
]
|
|
45
|
+
ref,
|
|
46
|
+
type: "number",
|
|
47
|
+
min,
|
|
48
|
+
max,
|
|
49
|
+
validate: combinedValidation,
|
|
50
|
+
"data-cy": dataCy || "numeric-input",
|
|
51
|
+
"data-testid": dataTestId || "numeric-input",
|
|
52
|
+
...props,
|
|
53
|
+
step: allowDecimals ? "any" : step
|
|
184
54
|
}
|
|
185
55
|
);
|
|
186
56
|
}
|
package/dist/index6.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),a=require("./index20.cjs"),n=require("./index21.cjs"),l=t.forwardRef(({allowHyphen:l=!1,allowUnderscore:r=!1,allowSpace:s=!1,minLength:u,maxLength:i,validate:c,onChange:o,"data-cy":p,"data-testid":d,...h},g)=>{const m=t.useRef(null),f=n.useMergedRef(g,m),v=t.useMemo(()=>{let e="^[a-zA-Z0-9";return l&&(e+="\\-"),r&&(e+="_"),s&&(e+=" "),e+="]*$",new RegExp(e)},[l,r,s]),x=t.useMemo(()=>{let e="[a-zA-Z0-9";return l&&(e+="\\-"),r&&(e+="_"),s&&(e+=" "),e+="]",new RegExp(e)},[l,r,s]),y=t.useCallback(e=>{if(e){if(!v.test(e)){let e="letters and numbers";const t=[];return l&&t.push("hyphens"),r&&t.push("underscores"),s&&t.push("spaces"),t.length>0&&(e+=`, ${t.join(", ")}`),`Only ${e} are allowed`}return void 0!==u&&e.length<u?`Must be at least ${u} characters`:void 0!==i&&e.length>i?`Must be at most ${i} characters`:void 0}},[v,u,i,l,r,s]),b=t.useCallback(e=>c?y(e)||c(e):y(e),[y,c]),[j,w]=t.useState(null);t.useEffect(()=>{null!==j&&m.current&&(m.current.setSelectionRange(j,j),w(null))},[h.value,j]);const R=t.useCallback(e=>{const t=e.target,a=t.value,n=t.selectionStart||0,l=a.split("").filter(e=>x.test(e)).join(""),r=n-a.slice(0,n).split("").filter(e=>!x.test(e)).length;t.value=l;void 0!==h.value?w(r):t.setSelectionRange(r,r),null==o||o(e)},[x,o,h.value]);return e.jsx(a.Input,{ref:f,type:"text",minLength:u,maxLength:i,validate:b,onChange:R,"data-cy":p||"alphanumeric-input","data-testid":d||"alphanumeric-input",...h})});l.displayName="AlphanumericInput",exports.AlphanumericInput=l;
|