@adam-milo/ui 1.0.19 → 1.0.21
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 +53 -53
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +38 -36
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +82 -76
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +50 -49
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +30 -30
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +348 -209
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +92 -82
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +32 -31
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +10 -7
- package/dist/index2.cjs +1 -1
- package/dist/index2.js +26 -26
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +84 -66
- package/dist/index31.cjs +1 -0
- package/dist/index31.js +9 -0
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +71 -64
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +130 -104
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +136 -107
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +76 -61
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +68 -54
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +47 -43
- package/dist/src/lib/dev-utils.d.ts +41 -0
- package/dist/src/lib/dev-utils.d.ts.map +1 -0
- package/dist/src/lib/index.d.ts +13 -2
- package/dist/src/lib/index.d.ts.map +1 -1
- package/package.json +4 -2
package/dist/index15.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 e=require("react/jsx-runtime"),a=require("react"),t=require("@radix-ui/react-dialog"),o=require("./index17.cjs");function i(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const t in e)if("default"!==t){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,o.get?o:{enumerable:!0,get:()=>e[t]})}return a.default=e,Object.freeze(a)};/* empty css */const r=i(t),s=r.Root,d=r.Trigger,l=r.Portal,c=r.Close,n=a.forwardRef(({className:a,"data-cy":t,"data-testid":i,...s},d)=>{const l=t||"dialog-overlay",c=i||"dialog-overlay";return e.jsx(r.Overlay,{ref:d,className:o.cn("dialog-overlay",a),"data-cy":l,"data-testid":c,...s})});n.displayName=r.Overlay.displayName;const g=a.forwardRef(({className:a,children:t,"data-cy":i,"data-testid":s,...d},c)=>{const g=i||"dialog-content",y=s||"dialog-content";return e.jsxs(l,{children:[e.jsx(n,{}),e.jsx(r.Content,{ref:c,className:o.cn("dialog-content",a),"data-cy":g,"data-testid":y,...d,children:t})]})});g.displayName=r.Content.displayName;const y=({className:a,"data-cy":t,"data-testid":i,...r})=>{const s=t||"dialog-header",d=i||"dialog-header";return e.jsx("div",{className:o.cn("dialog-header",a),"data-cy":s,"data-testid":d,...r})};y.displayName="DialogHeader";const p=({className:a,"data-cy":t,"data-testid":i,...r})=>{const s=t||"dialog-footer",d=i||"dialog-footer";return e.jsx("div",{className:o.cn("dialog-footer",a),"data-cy":s,"data-testid":d,...r})};p.displayName="DialogFooter";const m=a.forwardRef(({className:a,"data-cy":t,"data-testid":i,...s},d)=>{const l=t||"dialog-title",c=i||"dialog-title";return e.jsx(r.Title,{ref:d,className:o.cn("dialog-title",a),"data-cy":l,"data-testid":c,...s})});m.displayName=r.Title.displayName;const f=a.forwardRef(({className:a,"data-cy":t,"data-testid":i,...s},d)=>{const l=t||"dialog-description",c=i||"dialog-description";return e.jsx(r.Description,{ref:d,className:o.cn("dialog-description",a),"data-cy":l,"data-testid":c,...s})});f.displayName=r.Description.displayName,exports.Dialog=s,exports.DialogClose=c,exports.DialogContent=g,exports.DialogDescription=f,exports.DialogFooter=p,exports.DialogHeader=y,exports.DialogOverlay=n,exports.DialogPortal=l,exports.DialogTitle=m,exports.DialogTrigger=d;
|
package/dist/index15.js
CHANGED
|
@@ -1,115 +1,125 @@
|
|
|
1
|
-
import { jsxs
|
|
2
|
-
import { forwardRef
|
|
3
|
-
import * as
|
|
4
|
-
import { cn
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
4
|
+
import { cn } from "./index17.js";
|
|
5
5
|
/* empty css */
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const Dialog = DialogPrimitive.Root;
|
|
7
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
8
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
9
|
+
const DialogClose = DialogPrimitive.Close;
|
|
10
|
+
const DialogOverlay = forwardRef(({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
|
|
11
|
+
const finalDataCy = dataCy || "dialog-overlay";
|
|
12
|
+
const finalTestId = dataTestId || "dialog-overlay";
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
DialogPrimitive.Overlay,
|
|
10
15
|
{
|
|
11
|
-
ref
|
|
12
|
-
className:
|
|
13
|
-
"data-cy":
|
|
14
|
-
"data-testid":
|
|
15
|
-
...
|
|
16
|
+
ref,
|
|
17
|
+
className: cn("dialog-overlay", className),
|
|
18
|
+
"data-cy": finalDataCy,
|
|
19
|
+
"data-testid": finalTestId,
|
|
20
|
+
...props
|
|
16
21
|
}
|
|
17
22
|
);
|
|
18
23
|
});
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
-
|
|
24
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
25
|
+
const DialogContent = forwardRef(({ className, children, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
|
|
26
|
+
const finalDataCy = dataCy || "dialog-content";
|
|
27
|
+
const finalTestId = dataTestId || "dialog-content";
|
|
28
|
+
return /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
29
|
+
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
30
|
+
/* @__PURE__ */ jsx(
|
|
31
|
+
DialogPrimitive.Content,
|
|
26
32
|
{
|
|
27
|
-
ref
|
|
28
|
-
className:
|
|
29
|
-
"data-cy":
|
|
30
|
-
"data-testid":
|
|
31
|
-
...
|
|
32
|
-
children
|
|
33
|
+
ref,
|
|
34
|
+
className: cn("dialog-content", className),
|
|
35
|
+
"data-cy": finalDataCy,
|
|
36
|
+
"data-testid": finalTestId,
|
|
37
|
+
...props,
|
|
38
|
+
children
|
|
33
39
|
}
|
|
34
40
|
)
|
|
35
41
|
] });
|
|
36
42
|
});
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
className
|
|
40
|
-
"data-cy":
|
|
41
|
-
"data-testid":
|
|
42
|
-
...
|
|
43
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
44
|
+
const DialogHeader = ({
|
|
45
|
+
className,
|
|
46
|
+
"data-cy": dataCy,
|
|
47
|
+
"data-testid": dataTestId,
|
|
48
|
+
...props
|
|
43
49
|
}) => {
|
|
44
|
-
const
|
|
45
|
-
|
|
50
|
+
const finalDataCy = dataCy || "dialog-header";
|
|
51
|
+
const finalTestId = dataTestId || "dialog-header";
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
46
53
|
"div",
|
|
47
54
|
{
|
|
48
|
-
className:
|
|
49
|
-
"data-cy":
|
|
50
|
-
"data-testid":
|
|
51
|
-
...
|
|
55
|
+
className: cn("dialog-header", className),
|
|
56
|
+
"data-cy": finalDataCy,
|
|
57
|
+
"data-testid": finalTestId,
|
|
58
|
+
...props
|
|
52
59
|
}
|
|
53
60
|
);
|
|
54
61
|
};
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
className
|
|
58
|
-
"data-cy":
|
|
59
|
-
"data-testid":
|
|
60
|
-
...
|
|
62
|
+
DialogHeader.displayName = "DialogHeader";
|
|
63
|
+
const DialogFooter = ({
|
|
64
|
+
className,
|
|
65
|
+
"data-cy": dataCy,
|
|
66
|
+
"data-testid": dataTestId,
|
|
67
|
+
...props
|
|
61
68
|
}) => {
|
|
62
|
-
const
|
|
63
|
-
|
|
69
|
+
const finalDataCy = dataCy || "dialog-footer";
|
|
70
|
+
const finalTestId = dataTestId || "dialog-footer";
|
|
71
|
+
return /* @__PURE__ */ jsx(
|
|
64
72
|
"div",
|
|
65
73
|
{
|
|
66
|
-
className:
|
|
67
|
-
"data-cy":
|
|
68
|
-
"data-testid":
|
|
69
|
-
...
|
|
74
|
+
className: cn("dialog-footer", className),
|
|
75
|
+
"data-cy": finalDataCy,
|
|
76
|
+
"data-testid": finalTestId,
|
|
77
|
+
...props
|
|
70
78
|
}
|
|
71
79
|
);
|
|
72
80
|
};
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
({ className
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
DialogFooter.displayName = "DialogFooter";
|
|
82
|
+
const DialogTitle = forwardRef(
|
|
83
|
+
({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
|
|
84
|
+
const finalDataCy = dataCy || "dialog-title";
|
|
85
|
+
const finalTestId = dataTestId || "dialog-title";
|
|
86
|
+
return /* @__PURE__ */ jsx(
|
|
87
|
+
DialogPrimitive.Title,
|
|
79
88
|
{
|
|
80
|
-
ref
|
|
81
|
-
className:
|
|
82
|
-
"data-cy":
|
|
83
|
-
"data-testid":
|
|
84
|
-
...
|
|
89
|
+
ref,
|
|
90
|
+
className: cn("dialog-title", className),
|
|
91
|
+
"data-cy": finalDataCy,
|
|
92
|
+
"data-testid": finalTestId,
|
|
93
|
+
...props
|
|
85
94
|
}
|
|
86
95
|
);
|
|
87
96
|
}
|
|
88
97
|
);
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
99
|
+
const DialogDescription = forwardRef(({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
|
|
100
|
+
const finalDataCy = dataCy || "dialog-description";
|
|
101
|
+
const finalTestId = dataTestId || "dialog-description";
|
|
102
|
+
return /* @__PURE__ */ jsx(
|
|
103
|
+
DialogPrimitive.Description,
|
|
94
104
|
{
|
|
95
|
-
ref
|
|
96
|
-
className:
|
|
97
|
-
"data-cy":
|
|
98
|
-
"data-testid":
|
|
99
|
-
...
|
|
105
|
+
ref,
|
|
106
|
+
className: cn("dialog-description", className),
|
|
107
|
+
"data-cy": finalDataCy,
|
|
108
|
+
"data-testid": finalTestId,
|
|
109
|
+
...props
|
|
100
110
|
}
|
|
101
111
|
);
|
|
102
112
|
});
|
|
103
|
-
|
|
113
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
104
114
|
export {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
Dialog,
|
|
116
|
+
DialogClose,
|
|
117
|
+
DialogContent,
|
|
118
|
+
DialogDescription,
|
|
119
|
+
DialogFooter,
|
|
120
|
+
DialogHeader,
|
|
121
|
+
DialogOverlay,
|
|
122
|
+
DialogPortal,
|
|
123
|
+
DialogTitle,
|
|
124
|
+
DialogTrigger
|
|
115
125
|
};
|
package/dist/index16.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 t=require("react/jsx-runtime"),a=require("react"),e=require("./index17.cjs");;/* empty css */const s=a.forwardRef(({direction:a="vertical",spacing:s="4",align:c="stretch",justify:r="start",wrap:i=!1,className:n,children:d,"data-cy":l,"data-testid":o,...u},k)=>{const p=l||`stack-${a}`,j=o||`stack-${a}`;return t.jsx("div",{ref:k,className:e.cn("stack",`stack--${a}`,`stack--spacing-${s}`,`stack--align-${c}`,`stack--justify-${r}`,i&&"stack--wrap",n),"data-cy":p,"data-testid":j,...u,children:d})});s.displayName="Stack",exports.Stack=s;
|
package/dist/index16.js
CHANGED
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { forwardRef
|
|
3
|
-
import { cn
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "./index17.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
const
|
|
5
|
+
const Stack = forwardRef(
|
|
6
6
|
({
|
|
7
|
-
direction
|
|
8
|
-
spacing
|
|
9
|
-
align
|
|
10
|
-
justify
|
|
11
|
-
wrap
|
|
12
|
-
className
|
|
13
|
-
children
|
|
14
|
-
"data-cy":
|
|
15
|
-
"data-testid":
|
|
16
|
-
...
|
|
17
|
-
},
|
|
18
|
-
const
|
|
19
|
-
|
|
7
|
+
direction = "vertical",
|
|
8
|
+
spacing = "4",
|
|
9
|
+
align = "stretch",
|
|
10
|
+
justify = "start",
|
|
11
|
+
wrap = false,
|
|
12
|
+
className,
|
|
13
|
+
children,
|
|
14
|
+
"data-cy": dataCy,
|
|
15
|
+
"data-testid": dataTestId,
|
|
16
|
+
...props
|
|
17
|
+
}, ref) => {
|
|
18
|
+
const finalDataCy = dataCy || `stack-${direction}`;
|
|
19
|
+
const finalTestId = dataTestId || `stack-${direction}`;
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
20
21
|
"div",
|
|
21
22
|
{
|
|
22
|
-
ref
|
|
23
|
-
className:
|
|
23
|
+
ref,
|
|
24
|
+
className: cn(
|
|
24
25
|
"stack",
|
|
25
|
-
`stack--${
|
|
26
|
-
`stack--spacing-${
|
|
27
|
-
`stack--align-${
|
|
28
|
-
`stack--justify-${
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
`stack--${direction}`,
|
|
27
|
+
`stack--spacing-${spacing}`,
|
|
28
|
+
`stack--align-${align}`,
|
|
29
|
+
`stack--justify-${justify}`,
|
|
30
|
+
wrap && "stack--wrap",
|
|
31
|
+
className
|
|
31
32
|
),
|
|
32
|
-
"data-cy":
|
|
33
|
-
"data-testid":
|
|
34
|
-
...
|
|
35
|
-
children
|
|
33
|
+
"data-cy": finalDataCy,
|
|
34
|
+
"data-testid": finalTestId,
|
|
35
|
+
...props,
|
|
36
|
+
children
|
|
36
37
|
}
|
|
37
38
|
);
|
|
38
39
|
}
|
|
39
40
|
);
|
|
40
|
-
|
|
41
|
+
Stack.displayName = "Stack";
|
|
41
42
|
export {
|
|
42
|
-
|
|
43
|
+
Stack
|
|
43
44
|
};
|
package/dist/index17.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("clsx"),r=require("tailwind-merge");let t=0;exports.cn=function(...t){return r.twMerge(e.clsx(t))},exports.generateId=function(e="id"){return t+=1,`${e}-${t}`};
|
package/dist/index17.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
function cn(...inputs) {
|
|
4
|
+
return twMerge(clsx(inputs));
|
|
3
5
|
}
|
|
4
|
-
let
|
|
5
|
-
function
|
|
6
|
-
|
|
6
|
+
let idCounter = 0;
|
|
7
|
+
function generateId(prefix = "id") {
|
|
8
|
+
idCounter += 1;
|
|
9
|
+
return `${prefix}-${idCounter}`;
|
|
7
10
|
}
|
|
8
11
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
cn,
|
|
13
|
+
generateId
|
|
11
14
|
};
|
package/dist/index2.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 t=require("react/jsx-runtime"),e=require("react"),r=require("./index17.cjs");;/* empty css */const a=e.forwardRef(({variant:e="primary-workspace",fullWidth:a=!1,icon:n,className:s,children:i,disabled:c,"data-testid":d,"data-cy":o,...l},u)=>{const b=r.cn("btn",`btn--${e}`,a&&"btn--full-width",s);return t.jsxs("button",{ref:u,disabled:c,className:b,"data-testid":d||`button-${e}`,"data-cy":o||`button-${e}`,...l,children:[n&&t.jsx("span",{className:"btn__icon",children:n}),i]})});a.displayName="Button",exports.Button=a;
|
package/dist/index2.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { jsxs
|
|
2
|
-
import { forwardRef
|
|
3
|
-
import { cn
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "./index17.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
const
|
|
5
|
+
const Button = forwardRef(
|
|
6
6
|
({
|
|
7
|
-
variant
|
|
8
|
-
fullWidth
|
|
9
|
-
icon
|
|
10
|
-
className
|
|
11
|
-
children
|
|
12
|
-
disabled
|
|
13
|
-
"data-testid":
|
|
14
|
-
"data-cy":
|
|
15
|
-
...
|
|
16
|
-
},
|
|
17
|
-
const
|
|
18
|
-
return /* @__PURE__ */
|
|
7
|
+
variant = "primary-workspace",
|
|
8
|
+
fullWidth = false,
|
|
9
|
+
icon,
|
|
10
|
+
className,
|
|
11
|
+
children,
|
|
12
|
+
disabled,
|
|
13
|
+
"data-testid": dataTestId,
|
|
14
|
+
"data-cy": dataCy,
|
|
15
|
+
...props
|
|
16
|
+
}, ref) => {
|
|
17
|
+
const classes = cn("btn", `btn--${variant}`, fullWidth && "btn--full-width", className);
|
|
18
|
+
return /* @__PURE__ */ jsxs(
|
|
19
19
|
"button",
|
|
20
20
|
{
|
|
21
|
-
ref
|
|
22
|
-
disabled
|
|
23
|
-
className:
|
|
24
|
-
"data-testid":
|
|
25
|
-
"data-cy":
|
|
26
|
-
...
|
|
21
|
+
ref,
|
|
22
|
+
disabled,
|
|
23
|
+
className: classes,
|
|
24
|
+
"data-testid": dataTestId || `button-${variant}`,
|
|
25
|
+
"data-cy": dataCy || `button-${variant}`,
|
|
26
|
+
...props,
|
|
27
27
|
children: [
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
icon && /* @__PURE__ */ jsx("span", { className: "btn__icon", children: icon }),
|
|
29
|
+
children
|
|
30
30
|
]
|
|
31
31
|
}
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
);
|
|
35
|
-
|
|
35
|
+
Button.displayName = "Button";
|
|
36
36
|
export {
|
|
37
|
-
|
|
37
|
+
Button
|
|
38
38
|
};
|
package/dist/index3.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 e=require("react/jsx-runtime"),a=require("react"),t=require("./index17.cjs");;/* empty css */const r=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,l=a.forwardRef(({validateEmail:l=!0,invalidEmailMessage:i="Not a valid email address",onValidationChange:s,error:d,onChange:n,label:u,helperText:p,fullWidth:c=!1,className:o,id:m,"data-cy":h,"data-testid":v,...x},y)=>{const[$,f]=a.useState(),[b,j]=a.useState(!1),g=a.useId(),N=m||g,w=`${N}-error`,_=`${N}-helper`,q=h||"email-input",E=v||"email-input",S=e=>!e||r.test(e),C=d||$;return e.jsxs("div",{className:t.cn("input-wrapper",c&&"input-wrapper--full-width"),"data-cy":`${q}-wrapper`,"data-testid":`${E}-wrapper`,children:[u&&e.jsx("label",{htmlFor:N,className:"input__label","data-cy":`${q}-label`,"data-testid":`${E}-label`,children:u}),e.jsx("input",{ref:y,id:N,type:"email",className:t.cn("input",C&&"input--error",c&&"input--full-width",o),"aria-invalid":C?"true":"false","aria-describedby":C?w:p?_:void 0,"data-cy":q,"data-testid":E,onChange:e=>{const a=e.target.value;if(l&&b){const e=S(a);f(e?void 0:i),null==s||s(e)}null==n||n(e)},onBlur:e=>{var a;if(j(!0),l){const a=S(e.target.value);f(a?void 0:i),null==s||s(a)}null==(a=x.onBlur)||a.call(x,e)},...x}),C&&e.jsx("span",{id:w,className:"input__error",role:"alert","data-cy":`${q}-error`,"data-testid":`${E}-error`,children:C}),p&&!C&&e.jsx("span",{id:_,className:"input__helper","data-cy":`${q}-helper`,"data-testid":`${E}-helper`,children:p})]})});l.displayName="EmailInput",exports.EmailInput=l;
|
package/dist/index3.js
CHANGED
|
@@ -1,95 +1,113 @@
|
|
|
1
|
-
import { jsxs
|
|
2
|
-
import { forwardRef
|
|
3
|
-
import { cn
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useId } from "react";
|
|
3
|
+
import { cn } from "./index17.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
const
|
|
5
|
+
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
6
|
+
const EmailInput = forwardRef(
|
|
6
7
|
({
|
|
7
|
-
validateEmail
|
|
8
|
-
invalidEmailMessage
|
|
9
|
-
onValidationChange
|
|
10
|
-
error:
|
|
11
|
-
onChange
|
|
12
|
-
label
|
|
13
|
-
helperText
|
|
14
|
-
fullWidth
|
|
15
|
-
className
|
|
16
|
-
id:
|
|
17
|
-
"data-cy":
|
|
18
|
-
"data-testid":
|
|
19
|
-
...
|
|
20
|
-
},
|
|
21
|
-
const [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
validateEmail = true,
|
|
9
|
+
invalidEmailMessage = "Not a valid email address",
|
|
10
|
+
onValidationChange,
|
|
11
|
+
error: externalError,
|
|
12
|
+
onChange,
|
|
13
|
+
label,
|
|
14
|
+
helperText,
|
|
15
|
+
fullWidth = false,
|
|
16
|
+
className,
|
|
17
|
+
id: providedId,
|
|
18
|
+
"data-cy": dataCy,
|
|
19
|
+
"data-testid": dataTestId,
|
|
20
|
+
...props
|
|
21
|
+
}, ref) => {
|
|
22
|
+
const [internalError, setInternalError] = useState();
|
|
23
|
+
const [touched, setTouched] = useState(false);
|
|
24
|
+
const generatedId = useId();
|
|
25
|
+
const id = providedId || generatedId;
|
|
26
|
+
const errorId = `${id}-error`;
|
|
27
|
+
const helperId = `${id}-helper`;
|
|
28
|
+
const finalDataCy = dataCy || "email-input";
|
|
29
|
+
const finalTestId = dataTestId || "email-input";
|
|
30
|
+
const validateEmailFormat = (value) => {
|
|
31
|
+
if (!value) return true;
|
|
32
|
+
return EMAIL_REGEX.test(value);
|
|
33
|
+
};
|
|
34
|
+
const handleChange = (e) => {
|
|
35
|
+
const value = e.target.value;
|
|
36
|
+
if (validateEmail && touched) {
|
|
37
|
+
const isValid = validateEmailFormat(value);
|
|
38
|
+
setInternalError(isValid ? void 0 : invalidEmailMessage);
|
|
39
|
+
onValidationChange == null ? void 0 : onValidationChange(isValid);
|
|
26
40
|
}
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
onChange == null ? void 0 : onChange(e);
|
|
42
|
+
};
|
|
43
|
+
const handleBlur = (e) => {
|
|
44
|
+
var _a;
|
|
45
|
+
setTouched(true);
|
|
46
|
+
if (validateEmail) {
|
|
47
|
+
const isValid = validateEmailFormat(e.target.value);
|
|
48
|
+
setInternalError(isValid ? void 0 : invalidEmailMessage);
|
|
49
|
+
onValidationChange == null ? void 0 : onValidationChange(isValid);
|
|
33
50
|
}
|
|
34
|
-
(
|
|
35
|
-
}
|
|
36
|
-
|
|
51
|
+
(_a = props.onBlur) == null ? void 0 : _a.call(props, e);
|
|
52
|
+
};
|
|
53
|
+
const displayError = externalError || internalError;
|
|
54
|
+
return /* @__PURE__ */ jsxs(
|
|
37
55
|
"div",
|
|
38
56
|
{
|
|
39
|
-
className:
|
|
40
|
-
"data-cy": `${
|
|
41
|
-
"data-testid": `${
|
|
57
|
+
className: cn("input-wrapper", fullWidth && "input-wrapper--full-width"),
|
|
58
|
+
"data-cy": `${finalDataCy}-wrapper`,
|
|
59
|
+
"data-testid": `${finalTestId}-wrapper`,
|
|
42
60
|
children: [
|
|
43
|
-
|
|
61
|
+
label && /* @__PURE__ */ jsx(
|
|
44
62
|
"label",
|
|
45
63
|
{
|
|
46
|
-
htmlFor:
|
|
64
|
+
htmlFor: id,
|
|
47
65
|
className: "input__label",
|
|
48
|
-
"data-cy": `${
|
|
49
|
-
"data-testid": `${
|
|
50
|
-
children:
|
|
66
|
+
"data-cy": `${finalDataCy}-label`,
|
|
67
|
+
"data-testid": `${finalTestId}-label`,
|
|
68
|
+
children: label
|
|
51
69
|
}
|
|
52
70
|
),
|
|
53
|
-
/* @__PURE__ */
|
|
71
|
+
/* @__PURE__ */ jsx(
|
|
54
72
|
"input",
|
|
55
73
|
{
|
|
56
|
-
ref
|
|
57
|
-
id
|
|
74
|
+
ref,
|
|
75
|
+
id,
|
|
58
76
|
type: "email",
|
|
59
|
-
className:
|
|
77
|
+
className: cn(
|
|
60
78
|
"input",
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
79
|
+
displayError && "input--error",
|
|
80
|
+
fullWidth && "input--full-width",
|
|
81
|
+
className
|
|
64
82
|
),
|
|
65
|
-
"aria-invalid":
|
|
66
|
-
"aria-describedby":
|
|
67
|
-
"data-cy":
|
|
68
|
-
"data-testid":
|
|
69
|
-
onChange:
|
|
70
|
-
onBlur:
|
|
71
|
-
...
|
|
83
|
+
"aria-invalid": displayError ? "true" : "false",
|
|
84
|
+
"aria-describedby": displayError ? errorId : helperText ? helperId : void 0,
|
|
85
|
+
"data-cy": finalDataCy,
|
|
86
|
+
"data-testid": finalTestId,
|
|
87
|
+
onChange: handleChange,
|
|
88
|
+
onBlur: handleBlur,
|
|
89
|
+
...props
|
|
72
90
|
}
|
|
73
91
|
),
|
|
74
|
-
|
|
92
|
+
displayError && /* @__PURE__ */ jsx(
|
|
75
93
|
"span",
|
|
76
94
|
{
|
|
77
|
-
id:
|
|
95
|
+
id: errorId,
|
|
78
96
|
className: "input__error",
|
|
79
97
|
role: "alert",
|
|
80
|
-
"data-cy": `${
|
|
81
|
-
"data-testid": `${
|
|
82
|
-
children:
|
|
98
|
+
"data-cy": `${finalDataCy}-error`,
|
|
99
|
+
"data-testid": `${finalTestId}-error`,
|
|
100
|
+
children: displayError
|
|
83
101
|
}
|
|
84
102
|
),
|
|
85
|
-
|
|
103
|
+
helperText && !displayError && /* @__PURE__ */ jsx(
|
|
86
104
|
"span",
|
|
87
105
|
{
|
|
88
|
-
id:
|
|
106
|
+
id: helperId,
|
|
89
107
|
className: "input__helper",
|
|
90
|
-
"data-cy": `${
|
|
91
|
-
"data-testid": `${
|
|
92
|
-
children:
|
|
108
|
+
"data-cy": `${finalDataCy}-helper`,
|
|
109
|
+
"data-testid": `${finalTestId}-helper`,
|
|
110
|
+
children: helperText
|
|
93
111
|
}
|
|
94
112
|
)
|
|
95
113
|
]
|
|
@@ -97,7 +115,7 @@ const q = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, z = X(
|
|
|
97
115
|
);
|
|
98
116
|
}
|
|
99
117
|
);
|
|
100
|
-
|
|
118
|
+
EmailInput.displayName = "EmailInput";
|
|
101
119
|
export {
|
|
102
|
-
|
|
120
|
+
EmailInput
|
|
103
121
|
};
|
package/dist/index31.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});process.env.NODE_ENV;exports.devWarn=e=>{};
|