@adam-milo/ui 1.0.6 → 1.0.9
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.cjs +1 -1
- package/dist/index.js +43 -37
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +90 -9
- package/dist/index11.cjs +1 -0
- package/dist/index11.js +115 -0
- package/dist/index12.cjs +1 -0
- package/dist/index12.js +43 -0
- package/dist/index13.cjs +1 -0
- package/dist/index13.js +11 -0
- package/dist/index2.cjs +1 -1
- package/dist/index2.js +1 -1
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +69 -48
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +173 -56
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +147 -51
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +155 -105
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +53 -84
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +61 -107
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +108 -32
- package/dist/src/components/forms/alphanumeric-input/AlphanumericInput.component.d.ts +62 -0
- package/dist/src/components/forms/alphanumeric-input/AlphanumericInput.component.d.ts.map +1 -0
- package/dist/src/components/forms/email-input/EmailInput.component.d.ts +34 -0
- package/dist/src/components/forms/email-input/EmailInput.component.d.ts.map +1 -0
- package/dist/src/components/forms/numeric-input/NumericInput.component.d.ts +62 -0
- package/dist/src/components/forms/numeric-input/NumericInput.component.d.ts.map +1 -0
- package/dist/src/components/forms/password-input/PasswordInput.component.d.ts +25 -0
- package/dist/src/components/forms/password-input/PasswordInput.component.d.ts.map +1 -0
- package/dist/src/index.d.ts +8 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/src/components/forms/input/Input.component.d.ts +0 -20
- package/dist/src/components/forms/input/Input.component.d.ts.map +0 -1
package/dist/index4.js
CHANGED
|
@@ -1,61 +1,178 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import { cn as b } from "./index10.js";
|
|
1
|
+
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as x, useState as I, useId as N } from "react";
|
|
3
|
+
import { cn as u } from "./index13.js";
|
|
5
4
|
/* empty css */
|
|
6
|
-
const
|
|
7
|
-
({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
const _ = x(
|
|
6
|
+
({
|
|
7
|
+
showToggle: w = !0,
|
|
8
|
+
label: n,
|
|
9
|
+
error: e,
|
|
10
|
+
helperText: o,
|
|
11
|
+
fullWidth: l = !1,
|
|
12
|
+
className: h,
|
|
13
|
+
id: m,
|
|
14
|
+
"data-cy": f,
|
|
15
|
+
"data-testid": g,
|
|
16
|
+
...k
|
|
17
|
+
}, y) => {
|
|
18
|
+
const [d, $] = I(!1), b = N(), a = m || b, p = `${a}-error`, c = `${a}-helper`, r = f || "password-input", s = g || "password-input", v = () => {
|
|
19
|
+
$((C) => !C);
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ i("div", { className: "password-input-wrapper", children: [
|
|
22
|
+
/* @__PURE__ */ i(
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
className: u("input-wrapper", l && "input-wrapper--full-width"),
|
|
26
|
+
"data-cy": `${r}-wrapper`,
|
|
27
|
+
"data-testid": `${s}-wrapper`,
|
|
28
|
+
children: [
|
|
29
|
+
n && /* @__PURE__ */ t(
|
|
30
|
+
"label",
|
|
31
|
+
{
|
|
32
|
+
htmlFor: a,
|
|
33
|
+
className: "input__label",
|
|
34
|
+
"data-cy": `${r}-label`,
|
|
35
|
+
"data-testid": `${s}-label`,
|
|
36
|
+
children: n
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
/* @__PURE__ */ t(
|
|
40
|
+
"input",
|
|
41
|
+
{
|
|
42
|
+
ref: y,
|
|
43
|
+
id: a,
|
|
44
|
+
type: d ? "text" : "password",
|
|
45
|
+
className: u(
|
|
46
|
+
"input",
|
|
47
|
+
"password-input",
|
|
48
|
+
e && "input--error",
|
|
49
|
+
l && "input--full-width",
|
|
50
|
+
h
|
|
51
|
+
),
|
|
52
|
+
"aria-invalid": e ? "true" : "false",
|
|
53
|
+
"aria-describedby": e ? p : o ? c : void 0,
|
|
54
|
+
"data-cy": r,
|
|
55
|
+
"data-testid": s,
|
|
56
|
+
...k
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
e && /* @__PURE__ */ t(
|
|
60
|
+
"span",
|
|
61
|
+
{
|
|
62
|
+
id: p,
|
|
63
|
+
className: "input__error",
|
|
64
|
+
role: "alert",
|
|
65
|
+
"data-cy": `${r}-error`,
|
|
66
|
+
"data-testid": `${s}-error`,
|
|
67
|
+
children: e
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
o && !e && /* @__PURE__ */ t(
|
|
71
|
+
"span",
|
|
72
|
+
{
|
|
73
|
+
id: c,
|
|
74
|
+
className: "input__helper",
|
|
75
|
+
"data-cy": `${r}-helper`,
|
|
76
|
+
"data-testid": `${s}-helper`,
|
|
77
|
+
children: o
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
w && /* @__PURE__ */ t(
|
|
84
|
+
"button",
|
|
85
|
+
{
|
|
86
|
+
type: "button",
|
|
87
|
+
className: "password-input__toggle",
|
|
88
|
+
onClick: v,
|
|
89
|
+
"aria-label": d ? "Hide password" : "Show password",
|
|
90
|
+
"data-cy": `${r}-toggle`,
|
|
91
|
+
"data-testid": `${s}-toggle`,
|
|
92
|
+
children: d ? /* @__PURE__ */ i(
|
|
93
|
+
"svg",
|
|
94
|
+
{
|
|
95
|
+
width: "20",
|
|
96
|
+
height: "20",
|
|
97
|
+
viewBox: "0 0 20 20",
|
|
98
|
+
fill: "none",
|
|
99
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
100
|
+
"aria-hidden": "true",
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ t(
|
|
103
|
+
"path",
|
|
104
|
+
{
|
|
105
|
+
d: "M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",
|
|
106
|
+
stroke: "currentColor",
|
|
107
|
+
strokeWidth: "1.5",
|
|
108
|
+
strokeLinecap: "round",
|
|
109
|
+
strokeLinejoin: "round",
|
|
110
|
+
fill: "none"
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ t(
|
|
114
|
+
"circle",
|
|
115
|
+
{
|
|
116
|
+
cx: "10",
|
|
117
|
+
cy: "10",
|
|
118
|
+
r: "2.5",
|
|
119
|
+
stroke: "currentColor",
|
|
120
|
+
strokeWidth: "1.5",
|
|
121
|
+
fill: "none"
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
) : /* @__PURE__ */ i(
|
|
127
|
+
"svg",
|
|
128
|
+
{
|
|
129
|
+
width: "20",
|
|
130
|
+
height: "20",
|
|
131
|
+
viewBox: "0 0 20 20",
|
|
132
|
+
fill: "none",
|
|
133
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
134
|
+
"aria-hidden": "true",
|
|
135
|
+
children: [
|
|
136
|
+
/* @__PURE__ */ t(
|
|
137
|
+
"path",
|
|
138
|
+
{
|
|
139
|
+
d: "M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",
|
|
140
|
+
stroke: "currentColor",
|
|
141
|
+
strokeWidth: "1.5",
|
|
142
|
+
strokeLinecap: "round",
|
|
143
|
+
strokeLinejoin: "round",
|
|
144
|
+
fill: "none"
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
/* @__PURE__ */ t(
|
|
148
|
+
"circle",
|
|
149
|
+
{
|
|
150
|
+
cx: "10",
|
|
151
|
+
cy: "10",
|
|
152
|
+
r: "2.5",
|
|
153
|
+
stroke: "currentColor",
|
|
154
|
+
strokeWidth: "1.5",
|
|
155
|
+
fill: "none"
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
/* @__PURE__ */ t(
|
|
159
|
+
"path",
|
|
160
|
+
{
|
|
161
|
+
d: "M3 3l14 14",
|
|
162
|
+
stroke: "currentColor",
|
|
163
|
+
strokeWidth: "1.5",
|
|
164
|
+
strokeLinecap: "round"
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
] });
|
|
19
173
|
}
|
|
20
174
|
);
|
|
21
|
-
|
|
22
|
-
const y = m(
|
|
23
|
-
({ className: s, value: t, "data-cy": i, "data-testid": n, ...r }, e) => {
|
|
24
|
-
const o = i || (t ? `tabs-trigger-${t}` : "tabs-trigger"), d = n || (t ? `tabs-trigger-${t}` : "tabs-trigger");
|
|
25
|
-
return /* @__PURE__ */ c(
|
|
26
|
-
a.Trigger,
|
|
27
|
-
{
|
|
28
|
-
ref: e,
|
|
29
|
-
className: b("tabs-trigger", s),
|
|
30
|
-
value: t,
|
|
31
|
-
"data-cy": o,
|
|
32
|
-
"data-testid": d,
|
|
33
|
-
...r
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
y.displayName = a.Trigger.displayName;
|
|
39
|
-
const f = m(
|
|
40
|
-
({ className: s, value: t, "data-cy": i, "data-testid": n, ...r }, e) => {
|
|
41
|
-
const o = i || (t ? `tabs-content-${t}` : "tabs-content"), d = n || (t ? `tabs-content-${t}` : "tabs-content");
|
|
42
|
-
return /* @__PURE__ */ c(
|
|
43
|
-
a.Content,
|
|
44
|
-
{
|
|
45
|
-
ref: e,
|
|
46
|
-
className: b("tabs-content", s),
|
|
47
|
-
value: t,
|
|
48
|
-
"data-cy": o,
|
|
49
|
-
"data-testid": d,
|
|
50
|
-
...r
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
f.displayName = a.Content.displayName;
|
|
175
|
+
_.displayName = "PasswordInput";
|
|
56
176
|
export {
|
|
57
|
-
|
|
58
|
-
f as TabsContent,
|
|
59
|
-
g as TabsList,
|
|
60
|
-
y as TabsTrigger
|
|
177
|
+
_ as PasswordInput
|
|
61
178
|
};
|
package/dist/index5.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),p=require("react"),T=require("./index13.cjs");;/* empty css */const h=p.forwardRef(({allowDecimal:b=!1,allowNegative:N=!1,min:n,max:m,decimalPlaces:q=2,invalidNumberMessage:B="Please enter a valid number",minValueMessage:R,maxValueMessage:A,onValidationChange:s,error:P,onChange:v,onKeyDown:t,label:I,helperText:$,fullWidth:j=!1,className:F,id:M,"data-cy":g,"data-testid":H,...d},L)=>{const[O,x]=p.useState(),[V,z]=p.useState(!1),G=p.useId(),f=M||G,E=`${f}-error`,S=`${f}-helper`,i=g||"numeric-input",l=H||"numeric-input",k=r=>{if(!r)return{isValid:!0};const a=N?"-?":"",e=b?`(\\.\\d{0,${q}})?`:"";if(!new RegExp(`^${a}\\d+${e}$`).test(r))return{isValid:!1,error:B};const _=parseFloat(r);return n!==void 0&&_<n?{isValid:!1,error:R||`Value must be at least ${n}`}:m!==void 0&&_>m?{isValid:!1,error:A||`Value must be at most ${m}`}:{isValid:!0}},J=r=>{const a=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","Home","End"];if(r.ctrlKey||r.metaKey){t==null||t(r);return}if(a.includes(r.key)){t==null||t(r);return}if(b&&r.key==="."){if(r.currentTarget.value.includes(".")){r.preventDefault();return}t==null||t(r);return}if(N&&r.key==="-"){const e=r.currentTarget.value;if((r.currentTarget.selectionStart||0)!==0||e.includes("-")){r.preventDefault();return}t==null||t(r);return}if(r.key>="0"&&r.key<="9"){t==null||t(r);return}r.preventDefault()},Q=r=>{const a=r.target.value;if(V){const e=k(a);x(e.error),s==null||s(e.isValid)}v==null||v(r)},U=r=>{var e;z(!0);const a=k(r.target.value);x(a.error),s==null||s(a.isValid),(e=d.onBlur)==null||e.call(d,r)},u=P||O;return c.jsxs("div",{className:T.cn("input-wrapper",j&&"input-wrapper--full-width"),"data-cy":`${i}-wrapper`,"data-testid":`${l}-wrapper`,children:[I&&c.jsx("label",{htmlFor:f,className:"input__label","data-cy":`${i}-label`,"data-testid":`${l}-label`,children:I}),c.jsx("input",{ref:L,id:f,type:"text",inputMode:"numeric",className:T.cn("input",u&&"input--error",j&&"input--full-width",F),"aria-invalid":u?"true":"false","aria-describedby":u?E:$?S:void 0,"data-cy":i,"data-testid":l,onChange:Q,onBlur:U,onKeyDown:J,...d}),u&&c.jsx("span",{id:E,className:"input__error",role:"alert","data-cy":`${i}-error`,"data-testid":`${l}-error`,children:u}),$&&!u&&c.jsx("span",{id:S,className:"input__helper","data-cy":`${i}-helper`,"data-testid":`${l}-helper`,children:$})]})});h.displayName="NumericInput";exports.NumericInput=h;
|
package/dist/index5.js
CHANGED
|
@@ -1,61 +1,157 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { cn as
|
|
1
|
+
import { jsxs as Y, jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Z, useState as S, useId as g } from "react";
|
|
3
|
+
import { cn as T } from "./index13.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
const
|
|
5
|
+
const W = Z(
|
|
6
6
|
({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
allowDecimal: $ = !1,
|
|
8
|
+
allowNegative: b = !1,
|
|
9
|
+
min: p,
|
|
10
|
+
max: m,
|
|
11
|
+
decimalPlaces: x = 2,
|
|
12
|
+
invalidNumberMessage: A = "Please enter a valid number",
|
|
13
|
+
minValueMessage: R,
|
|
14
|
+
maxValueMessage: j,
|
|
15
|
+
onValidationChange: s,
|
|
16
|
+
error: F,
|
|
17
|
+
onChange: v,
|
|
18
|
+
onKeyDown: t,
|
|
19
|
+
label: N,
|
|
20
|
+
helperText: n,
|
|
21
|
+
fullWidth: I = !1,
|
|
22
|
+
className: P,
|
|
23
|
+
id: H,
|
|
24
|
+
"data-cy": L,
|
|
25
|
+
"data-testid": M,
|
|
26
|
+
...c
|
|
27
|
+
}, V) => {
|
|
28
|
+
const [q, E] = S(), [z, G] = S(!1), J = g(), d = H || J, k = `${d}-error`, _ = `${d}-helper`, l = L || "numeric-input", u = M || "numeric-input", h = (r) => {
|
|
29
|
+
if (!r) return { isValid: !0 };
|
|
30
|
+
const a = b ? "-?" : "", e = $ ? `(\\.\\d{0,${x}})?` : "";
|
|
31
|
+
if (!new RegExp(`^${a}\\d+${e}$`).test(r))
|
|
32
|
+
return { isValid: !1, error: A };
|
|
33
|
+
const B = parseFloat(r);
|
|
34
|
+
return p !== void 0 && B < p ? {
|
|
35
|
+
isValid: !1,
|
|
36
|
+
error: R || `Value must be at least ${p}`
|
|
37
|
+
} : m !== void 0 && B > m ? {
|
|
38
|
+
isValid: !1,
|
|
39
|
+
error: j || `Value must be at most ${m}`
|
|
40
|
+
} : { isValid: !0 };
|
|
41
|
+
}, O = (r) => {
|
|
42
|
+
const a = [
|
|
43
|
+
"Backspace",
|
|
44
|
+
"Delete",
|
|
45
|
+
"Tab",
|
|
46
|
+
"Escape",
|
|
47
|
+
"Enter",
|
|
48
|
+
"ArrowLeft",
|
|
49
|
+
"ArrowRight",
|
|
50
|
+
"Home",
|
|
51
|
+
"End"
|
|
52
|
+
];
|
|
53
|
+
if (r.ctrlKey || r.metaKey) {
|
|
54
|
+
t == null || t(r);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (a.includes(r.key)) {
|
|
58
|
+
t == null || t(r);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if ($ && r.key === ".") {
|
|
62
|
+
if (r.currentTarget.value.includes(".")) {
|
|
63
|
+
r.preventDefault();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
t == null || t(r);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (b && r.key === "-") {
|
|
70
|
+
const e = r.currentTarget.value;
|
|
71
|
+
if ((r.currentTarget.selectionStart || 0) !== 0 || e.includes("-")) {
|
|
72
|
+
r.preventDefault();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
t == null || t(r);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (r.key >= "0" && r.key <= "9") {
|
|
79
|
+
t == null || t(r);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
r.preventDefault();
|
|
83
|
+
}, Q = (r) => {
|
|
84
|
+
const a = r.target.value;
|
|
85
|
+
if (z) {
|
|
86
|
+
const e = h(a);
|
|
87
|
+
E(e.error), s == null || s(e.isValid);
|
|
88
|
+
}
|
|
89
|
+
v == null || v(r);
|
|
90
|
+
}, U = (r) => {
|
|
91
|
+
var e;
|
|
92
|
+
G(!0);
|
|
93
|
+
const a = h(r.target.value);
|
|
94
|
+
E(a.error), s == null || s(a.isValid), (e = c.onBlur) == null || e.call(c, r);
|
|
95
|
+
}, i = F || q;
|
|
96
|
+
return /* @__PURE__ */ Y(
|
|
23
97
|
"div",
|
|
24
98
|
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"data-cy": t,
|
|
29
|
-
"data-testid": a,
|
|
30
|
-
...m,
|
|
99
|
+
className: T("input-wrapper", I && "input-wrapper--full-width"),
|
|
100
|
+
"data-cy": `${l}-wrapper`,
|
|
101
|
+
"data-testid": `${u}-wrapper`,
|
|
31
102
|
children: [
|
|
32
|
-
|
|
33
|
-
"
|
|
103
|
+
N && /* @__PURE__ */ f(
|
|
104
|
+
"label",
|
|
105
|
+
{
|
|
106
|
+
htmlFor: d,
|
|
107
|
+
className: "input__label",
|
|
108
|
+
"data-cy": `${l}-label`,
|
|
109
|
+
"data-testid": `${u}-label`,
|
|
110
|
+
children: N
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ f(
|
|
114
|
+
"input",
|
|
115
|
+
{
|
|
116
|
+
ref: V,
|
|
117
|
+
id: d,
|
|
118
|
+
type: "text",
|
|
119
|
+
inputMode: "numeric",
|
|
120
|
+
className: T(
|
|
121
|
+
"input",
|
|
122
|
+
i && "input--error",
|
|
123
|
+
I && "input--full-width",
|
|
124
|
+
P
|
|
125
|
+
),
|
|
126
|
+
"aria-invalid": i ? "true" : "false",
|
|
127
|
+
"aria-describedby": i ? k : n ? _ : void 0,
|
|
128
|
+
"data-cy": l,
|
|
129
|
+
"data-testid": u,
|
|
130
|
+
onChange: Q,
|
|
131
|
+
onBlur: U,
|
|
132
|
+
onKeyDown: O,
|
|
133
|
+
...c
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
i && /* @__PURE__ */ f(
|
|
137
|
+
"span",
|
|
34
138
|
{
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
139
|
+
id: k,
|
|
140
|
+
className: "input__error",
|
|
141
|
+
role: "alert",
|
|
142
|
+
"data-cy": `${l}-error`,
|
|
143
|
+
"data-testid": `${u}-error`,
|
|
144
|
+
children: i
|
|
39
145
|
}
|
|
40
146
|
),
|
|
41
|
-
/* @__PURE__ */
|
|
42
|
-
"
|
|
147
|
+
n && !i && /* @__PURE__ */ f(
|
|
148
|
+
"span",
|
|
43
149
|
{
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
"data-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"div",
|
|
50
|
-
{
|
|
51
|
-
className: "alert__title",
|
|
52
|
-
"data-cy": `${t}-title`,
|
|
53
|
-
"data-testid": `${a}-title`,
|
|
54
|
-
children: d
|
|
55
|
-
}
|
|
56
|
-
),
|
|
57
|
-
/* @__PURE__ */ s("div", { "data-cy": `${t}-message`, "data-testid": `${a}-message`, children: l })
|
|
58
|
-
]
|
|
150
|
+
id: _,
|
|
151
|
+
className: "input__helper",
|
|
152
|
+
"data-cy": `${l}-helper`,
|
|
153
|
+
"data-testid": `${u}-helper`,
|
|
154
|
+
children: n
|
|
59
155
|
}
|
|
60
156
|
)
|
|
61
157
|
]
|
|
@@ -63,7 +159,7 @@ const _ = y(
|
|
|
63
159
|
);
|
|
64
160
|
}
|
|
65
161
|
);
|
|
66
|
-
|
|
162
|
+
W.displayName = "NumericInput";
|
|
67
163
|
export {
|
|
68
|
-
|
|
164
|
+
W as NumericInput
|
|
69
165
|
};
|
package/dist/index6.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),h=require("react"),R=require("./index13.cjs");;/* empty css */const M=h.forwardRef(({allowHyphen:c=!1,allowUnderscore:f=!1,allowSpace:p=!1,minLength:v,maxLength:m,invalidFormatMessage:O="Only letters and numbers are allowed",minLengthMessage:z,maxLengthMessage:F,onValidationChange:s,error:T,onChange:I,onKeyDown:t,label:_,helperText:j,fullWidth:A=!1,className:Z,id:P,"data-cy":S,"data-testid":G,...$},J)=>{const[Q,E]=h.useState(),[X,Y]=h.useState(!1),W=h.useId(),b=P||W,x=`${b}-error`,N=`${b}-helper`,u=S||"alphanumeric-input",d=G||"alphanumeric-input",q=r=>{if(!r)return{isValid:!0};let e="^[a-zA-Z0-9";if(c&&(e+="\\-"),f&&(e+="_"),p&&(e+=" "),e+="]+$",!new RegExp(e).test(r)){let B=O;if(c||f||p){const k=["letters","numbers"];c&&k.push("hyphens"),f&&k.push("underscores"),p&&k.push("spaces"),B=`Only ${k.join(", ")} are allowed`}return{isValid:!1,error:B}}return v!==void 0&&r.length<v?{isValid:!1,error:z||`Must be at least ${v} characters`}:m!==void 0&&r.length>m?{isValid:!1,error:F||`Must be at most ${m} characters`}:{isValid:!0}},H=r=>{const e=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","Home","End"];if(r.ctrlKey||r.metaKey){t==null||t(r);return}if(e.includes(r.key)){t==null||t(r);return}if(p&&r.key===" "){t==null||t(r);return}if(c&&r.key==="-"){t==null||t(r);return}if(f&&r.key==="_"){t==null||t(r);return}if(r.key>="a"&&r.key<="z"||r.key>="A"&&r.key<="Z"){t==null||t(r);return}if(r.key>="0"&&r.key<="9"){t==null||t(r);return}r.preventDefault()},V=r=>{const e=r.target.value;if(X){const i=q(e);E(i.error),s==null||s(i.isValid)}I==null||I(r)},U=r=>{var i;Y(!0);const e=q(r.target.value);E(e.error),s==null||s(e.isValid),(i=$.onBlur)==null||i.call($,r)},a=T||Q;return l.jsxs("div",{className:R.cn("input-wrapper",A&&"input-wrapper--full-width"),"data-cy":`${u}-wrapper`,"data-testid":`${d}-wrapper`,children:[_&&l.jsx("label",{htmlFor:b,className:"input__label","data-cy":`${u}-label`,"data-testid":`${d}-label`,children:_}),l.jsx("input",{ref:J,id:b,type:"text",className:R.cn("input",a&&"input--error",A&&"input--full-width",Z),"aria-invalid":a?"true":"false","aria-describedby":a?x:j?N:void 0,"data-cy":u,"data-testid":d,onChange:V,onBlur:U,onKeyDown:H,maxLength:m,...$}),a&&l.jsx("span",{id:x,className:"input__error",role:"alert","data-cy":`${u}-error`,"data-testid":`${d}-error`,children:a}),j&&!a&&l.jsx("span",{id:N,className:"input__helper","data-cy":`${u}-helper`,"data-testid":`${d}-helper`,children:j})]})});M.displayName="AlphanumericInput";exports.AlphanumericInput=M;
|