@adam-milo/ui 1.0.23 → 1.0.24
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 +18 -9
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +53 -59
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +50 -104
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +108 -76
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +77 -26
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +22 -462
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +466 -109
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +111 -30
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +42 -12
- package/dist/index18.cjs +1 -0
- package/dist/index18.js +14 -0
- package/dist/index2.cjs +1 -1
- package/dist/index2.js +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +20 -299
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +298 -13
- package/dist/index22.cjs +1 -0
- package/dist/index22.js +16 -0
- package/dist/index25.cjs +1 -0
- package/dist/index25.js +1193 -0
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +2 -2
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +7 -19
- package/dist/index36.cjs +1 -0
- package/dist/index36.js +21 -0
- package/dist/index38.cjs +1 -0
- package/dist/index38.js +6 -0
- package/dist/index39.cjs +1 -0
- package/dist/index39.js +11 -0
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +1 -1
- package/dist/index40.cjs +1 -0
- package/dist/index40.js +70 -0
- package/dist/index41.cjs +1 -0
- package/dist/index41.js +39 -0
- package/dist/index42.cjs +1 -0
- package/dist/index42.js +64 -0
- package/dist/index43.cjs +1 -0
- package/dist/index43.js +10 -0
- package/dist/index44.cjs +1 -0
- package/dist/index44.js +212 -0
- package/dist/index45.cjs +1 -0
- package/dist/index45.js +29 -0
- package/dist/index46.cjs +1 -0
- package/dist/index46.js +208 -0
- package/dist/index47.cjs +1 -0
- package/dist/index47.js +14 -0
- package/dist/index48.cjs +1 -0
- package/dist/index48.js +293 -0
- package/dist/index49.cjs +1 -0
- package/dist/index49.js +18 -0
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +1 -1
- package/dist/index50.cjs +1 -0
- package/dist/index50.js +43 -0
- package/dist/index51.cjs +1 -0
- package/dist/index51.js +89 -0
- package/dist/index52.cjs +1 -0
- package/dist/index52.js +14 -0
- package/dist/index53.cjs +1 -0
- package/dist/index53.js +71 -0
- package/dist/index54.cjs +1 -0
- package/dist/index54.js +6 -0
- package/dist/index55.cjs +1 -0
- package/dist/index55.js +14 -0
- package/dist/index56.cjs +1 -0
- package/dist/index56.js +34 -0
- package/dist/index57.cjs +1 -0
- package/dist/index57.js +122 -0
- package/dist/index58.cjs +1 -0
- package/dist/index58.js +11 -0
- package/dist/index59.cjs +1 -0
- package/dist/index59.js +17 -0
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +2 -2
- package/dist/index60.cjs +1 -0
- package/dist/index60.js +297 -0
- package/dist/index61.cjs +1 -0
- package/dist/index61.js +25 -0
- package/dist/index62.cjs +1 -0
- package/dist/index62.js +39 -0
- package/dist/index63.cjs +1 -0
- package/dist/index63.js +625 -0
- package/dist/index64.cjs +1 -0
- package/dist/index64.js +39 -0
- package/dist/index65.cjs +1 -0
- package/dist/index65.js +38 -0
- package/dist/index66.cjs +1 -0
- package/dist/index66.js +7 -0
- package/dist/index67.cjs +1 -0
- package/dist/index67.js +10 -0
- package/dist/index68.cjs +1 -0
- package/dist/index68.js +5 -0
- package/dist/index69.cjs +1 -0
- package/dist/index69.js +35 -0
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +1 -1
- package/dist/index70.cjs +1 -0
- package/dist/index70.js +180 -0
- package/dist/index71.cjs +1 -0
- package/dist/index71.js +21 -0
- package/dist/index72.cjs +1 -0
- package/dist/index72.js +721 -0
- package/dist/index73.cjs +1 -0
- package/dist/index73.js +154 -0
- package/dist/index74.cjs +1 -0
- package/dist/index74.js +173 -0
- package/dist/index75.cjs +1 -0
- package/dist/index75.js +88 -0
- package/dist/index76.cjs +1 -0
- package/dist/index76.js +47 -0
- package/dist/index77.cjs +1 -0
- package/dist/index77.js +13 -0
- package/dist/index78.cjs +1 -0
- package/dist/index78.js +19 -0
- package/dist/index79.cjs +1 -0
- package/dist/index79.js +102 -0
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +1 -1
- package/dist/index80.cjs +1 -0
- package/dist/index80.js +11 -0
- package/dist/index81.cjs +1 -0
- package/dist/index81.js +29 -0
- package/dist/index82.cjs +1 -0
- package/dist/index82.js +16 -0
- package/dist/index83.cjs +1 -0
- package/dist/index83.js +48 -0
- package/dist/index84.cjs +1 -0
- package/dist/index84.js +9 -0
- package/dist/index85.cjs +1 -0
- package/dist/index85.js +37 -0
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +224 -35
- package/dist/src/components/forms/select/Select.component.d.ts +100 -0
- package/dist/src/components/forms/select/Select.component.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/dist/index19.cjs +0 -1
- package/dist/index19.js +0 -22
- package/dist/index30.cjs +0 -1
- package/dist/index30.js +0 -9
package/dist/index16.js
CHANGED
|
@@ -1,44 +1,125 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import
|
|
3
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
4
|
+
import { cn } from "./index18.js";
|
|
4
5
|
/* empty css */
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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,
|
|
15
|
+
{
|
|
16
|
+
ref,
|
|
17
|
+
className: cn("dialog-overlay", className),
|
|
18
|
+
"data-cy": finalDataCy,
|
|
19
|
+
"data-testid": finalTestId,
|
|
20
|
+
...props
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
});
|
|
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,
|
|
22
32
|
{
|
|
23
33
|
ref,
|
|
24
|
-
className: cn(
|
|
25
|
-
"stack",
|
|
26
|
-
`stack--${direction}`,
|
|
27
|
-
`stack--spacing-${spacing}`,
|
|
28
|
-
`stack--align-${align}`,
|
|
29
|
-
`stack--justify-${justify}`,
|
|
30
|
-
wrap && "stack--wrap",
|
|
31
|
-
className
|
|
32
|
-
),
|
|
34
|
+
className: cn("dialog-content", className),
|
|
33
35
|
"data-cy": finalDataCy,
|
|
34
36
|
"data-testid": finalTestId,
|
|
35
37
|
...props,
|
|
36
38
|
children
|
|
37
39
|
}
|
|
40
|
+
)
|
|
41
|
+
] });
|
|
42
|
+
});
|
|
43
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
44
|
+
const DialogHeader = ({
|
|
45
|
+
className,
|
|
46
|
+
"data-cy": dataCy,
|
|
47
|
+
"data-testid": dataTestId,
|
|
48
|
+
...props
|
|
49
|
+
}) => {
|
|
50
|
+
const finalDataCy = dataCy || "dialog-header";
|
|
51
|
+
const finalTestId = dataTestId || "dialog-header";
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
className: cn("dialog-header", className),
|
|
56
|
+
"data-cy": finalDataCy,
|
|
57
|
+
"data-testid": finalTestId,
|
|
58
|
+
...props
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
DialogHeader.displayName = "DialogHeader";
|
|
63
|
+
const DialogFooter = ({
|
|
64
|
+
className,
|
|
65
|
+
"data-cy": dataCy,
|
|
66
|
+
"data-testid": dataTestId,
|
|
67
|
+
...props
|
|
68
|
+
}) => {
|
|
69
|
+
const finalDataCy = dataCy || "dialog-footer";
|
|
70
|
+
const finalTestId = dataTestId || "dialog-footer";
|
|
71
|
+
return /* @__PURE__ */ jsx(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
className: cn("dialog-footer", className),
|
|
75
|
+
"data-cy": finalDataCy,
|
|
76
|
+
"data-testid": finalTestId,
|
|
77
|
+
...props
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
};
|
|
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,
|
|
88
|
+
{
|
|
89
|
+
ref,
|
|
90
|
+
className: cn("dialog-title", className),
|
|
91
|
+
"data-cy": finalDataCy,
|
|
92
|
+
"data-testid": finalTestId,
|
|
93
|
+
...props
|
|
94
|
+
}
|
|
38
95
|
);
|
|
39
96
|
}
|
|
40
97
|
);
|
|
41
|
-
|
|
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,
|
|
104
|
+
{
|
|
105
|
+
ref,
|
|
106
|
+
className: cn("dialog-description", className),
|
|
107
|
+
"data-cy": finalDataCy,
|
|
108
|
+
"data-testid": finalTestId,
|
|
109
|
+
...props
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
42
114
|
export {
|
|
43
|
-
|
|
115
|
+
Dialog,
|
|
116
|
+
DialogClose,
|
|
117
|
+
DialogContent,
|
|
118
|
+
DialogDescription,
|
|
119
|
+
DialogFooter,
|
|
120
|
+
DialogHeader,
|
|
121
|
+
DialogOverlay,
|
|
122
|
+
DialogPortal,
|
|
123
|
+
DialogTitle,
|
|
124
|
+
DialogTrigger
|
|
44
125
|
};
|
package/dist/index17.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("./index18.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/index17.js
CHANGED
|
@@ -1,14 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "./index18.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
const Stack = forwardRef(
|
|
6
|
+
({
|
|
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(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
ref,
|
|
24
|
+
className: cn(
|
|
25
|
+
"stack",
|
|
26
|
+
`stack--${direction}`,
|
|
27
|
+
`stack--spacing-${spacing}`,
|
|
28
|
+
`stack--align-${align}`,
|
|
29
|
+
`stack--justify-${justify}`,
|
|
30
|
+
wrap && "stack--wrap",
|
|
31
|
+
className
|
|
32
|
+
),
|
|
33
|
+
"data-cy": finalDataCy,
|
|
34
|
+
"data-testid": finalTestId,
|
|
35
|
+
...props,
|
|
36
|
+
children
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
Stack.displayName = "Stack";
|
|
11
42
|
export {
|
|
12
|
-
|
|
13
|
-
generateId
|
|
43
|
+
Stack
|
|
14
44
|
};
|
package/dist/index18.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
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/index18.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
function cn(...inputs) {
|
|
4
|
+
return twMerge(clsx(inputs));
|
|
5
|
+
}
|
|
6
|
+
let idCounter = 0;
|
|
7
|
+
function generateId(prefix = "id") {
|
|
8
|
+
idCounter += 1;
|
|
9
|
+
return `${prefix}-${idCounter}`;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
cn,
|
|
13
|
+
generateId
|
|
14
|
+
};
|
package/dist/index2.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),e=require("react"),r=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),e=require("react"),r=require("./index18.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
package/dist/index20.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var t=/^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;exports.validate=function(e){if(!e)return!1;if(e.length>254)return!1;if(!t.test(e))return!1;var r=e.split("@");return!(r[0].length>64)&&!r[1].split(".").some(function(t){return t.length>63})};
|
package/dist/index20.js
CHANGED
|
@@ -1,301 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
id: providedId,
|
|
21
|
-
onChange,
|
|
22
|
-
onBlur,
|
|
23
|
-
required,
|
|
24
|
-
value: controlledValue,
|
|
25
|
-
"data-cy": dataCy,
|
|
26
|
-
"data-testid": dataTestId,
|
|
27
|
-
...props
|
|
28
|
-
}, ref) => {
|
|
29
|
-
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
|
|
30
|
-
const [internalError, setInternalError] = useState();
|
|
31
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
32
|
-
const [isHovered, setIsHovered] = useState(false);
|
|
33
|
-
const touchedRef = useRef(false);
|
|
34
|
-
const [displayPassword, setDisplayPassword] = useState("");
|
|
35
|
-
const actualPasswordRef = useRef("");
|
|
36
|
-
const timeoutRef = useRef(null);
|
|
37
|
-
const inputRef = useRef(null);
|
|
38
|
-
const mergedRef = useMergedRef(ref, inputRef);
|
|
39
|
-
const generatedId = useId();
|
|
40
|
-
const id = providedId || generatedId;
|
|
41
|
-
const errorId = `${id}-error`;
|
|
42
|
-
const helperId = `${id}-helper`;
|
|
43
|
-
const finalDataCy = dataCy || "input";
|
|
44
|
-
const finalTestId = dataTestId || "input";
|
|
45
|
-
const isPasswordType = type === "password";
|
|
46
|
-
const showToggle = isPasswordType && showPasswordToggle;
|
|
47
|
-
const shouldEnableLastCharPreview = isPasswordType && showLastChar && !isPasswordVisible;
|
|
48
|
-
const inputType = isPasswordType && (isPasswordVisible || shouldEnableLastCharPreview && actualPasswordRef.current.length > 0) ? "text" : type;
|
|
49
|
-
const displayLabel = label && required && !label.includes("*") ? `${label} *` : label;
|
|
50
|
-
const togglePasswordVisibility = () => {
|
|
51
|
-
setIsPasswordVisible((prev) => !prev);
|
|
52
|
-
setTimeout(() => {
|
|
53
|
-
var _a;
|
|
54
|
-
return (_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
55
|
-
}, 0);
|
|
56
|
-
};
|
|
57
|
-
const debouncedValidate = useMemo(
|
|
58
|
-
() => debounce((value) => {
|
|
59
|
-
if (validate && touchedRef.current) {
|
|
60
|
-
const validationError = validate(value);
|
|
61
|
-
setInternalError(validationError);
|
|
62
|
-
onValidationChange == null ? void 0 : onValidationChange(!validationError);
|
|
63
|
-
}
|
|
64
|
-
}, 300),
|
|
65
|
-
[validate, onValidationChange]
|
|
66
|
-
);
|
|
67
|
-
const debouncedValidateRef = useRef(debouncedValidate);
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
debouncedValidateRef.current = debouncedValidate;
|
|
70
|
-
}, [debouncedValidate]);
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (process.env.NODE_ENV === "development") {
|
|
73
|
-
if (isPasswordType && showLastChar && controlledValue !== void 0) {
|
|
74
|
-
console.warn(
|
|
75
|
-
"[Input] Password last character preview (showLastChar) only works in uncontrolled mode. Remove the value prop to use this feature, or set showLastChar={false}."
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}, [isPasswordType, showLastChar, controlledValue]);
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
return () => {
|
|
82
|
-
if (timeoutRef.current) {
|
|
83
|
-
clearTimeout(timeoutRef.current);
|
|
84
|
-
}
|
|
85
|
-
debouncedValidateRef.current.cancel();
|
|
86
|
-
};
|
|
87
|
-
}, []);
|
|
88
|
-
const inputValue = shouldEnableLastCharPreview && controlledValue === void 0 ? displayPassword : isPasswordVisible && isPasswordType && controlledValue === void 0 ? actualPasswordRef.current || "" : controlledValue;
|
|
89
|
-
const handleChange = (e) => {
|
|
90
|
-
onChange == null ? void 0 : onChange(e);
|
|
91
|
-
let value = e.target.value;
|
|
92
|
-
if (shouldEnableLastCharPreview) {
|
|
93
|
-
const input = e.target;
|
|
94
|
-
const newValue = input.value;
|
|
95
|
-
actualPasswordRef.current = newValue;
|
|
96
|
-
const masked = newValue ? "•".repeat(newValue.length - 1) + newValue.slice(-1) : "";
|
|
97
|
-
setDisplayPassword(masked);
|
|
98
|
-
input.value = masked;
|
|
99
|
-
value = newValue;
|
|
100
|
-
if (timeoutRef.current) {
|
|
101
|
-
clearTimeout(timeoutRef.current);
|
|
102
|
-
}
|
|
103
|
-
timeoutRef.current = setTimeout(() => {
|
|
104
|
-
setDisplayPassword("•".repeat(newValue.length));
|
|
105
|
-
}, lastCharDelay);
|
|
106
|
-
}
|
|
107
|
-
if (touchedRef.current) {
|
|
108
|
-
debouncedValidate(value);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const handleFocus = (e) => {
|
|
112
|
-
var _a;
|
|
113
|
-
setIsFocused(true);
|
|
114
|
-
(_a = props.onFocus) == null ? void 0 : _a.call(props, e);
|
|
115
|
-
};
|
|
116
|
-
const handleBlur = (e) => {
|
|
117
|
-
setIsFocused(false);
|
|
118
|
-
touchedRef.current = true;
|
|
119
|
-
if (validate) {
|
|
120
|
-
const valueToValidate = shouldEnableLastCharPreview ? actualPasswordRef.current : e.target.value;
|
|
121
|
-
const validationError = validate(valueToValidate);
|
|
122
|
-
setInternalError(validationError);
|
|
123
|
-
onValidationChange == null ? void 0 : onValidationChange(!validationError);
|
|
124
|
-
}
|
|
125
|
-
onBlur == null ? void 0 : onBlur(e);
|
|
126
|
-
};
|
|
127
|
-
const handleMouseEnter = () => {
|
|
128
|
-
setIsHovered(true);
|
|
129
|
-
};
|
|
130
|
-
const handleMouseLeave = () => {
|
|
131
|
-
setIsHovered(false);
|
|
132
|
-
};
|
|
133
|
-
const displayError = externalError || internalError;
|
|
134
|
-
const inputState = props.disabled ? "disabled" : displayError ? "error" : isFocused ? "focus" : isHovered ? "hover" : "idle";
|
|
135
|
-
return /* @__PURE__ */ jsxs(
|
|
136
|
-
"div",
|
|
137
|
-
{
|
|
138
|
-
className: cn("input-wrapper", fullWidth && "input-wrapper--full-width"),
|
|
139
|
-
"data-cy": `${finalDataCy}-wrapper`,
|
|
140
|
-
"data-testid": `${finalTestId}-wrapper`,
|
|
141
|
-
children: [
|
|
142
|
-
label && /* @__PURE__ */ jsx(
|
|
143
|
-
"label",
|
|
144
|
-
{
|
|
145
|
-
htmlFor: id,
|
|
146
|
-
className: "input__label",
|
|
147
|
-
"data-cy": `${finalDataCy}-label`,
|
|
148
|
-
"data-testid": `${finalTestId}-label`,
|
|
149
|
-
children: displayLabel
|
|
150
|
-
}
|
|
151
|
-
),
|
|
152
|
-
/* @__PURE__ */ jsxs("div", { className: "input__field-container", children: [
|
|
153
|
-
/* @__PURE__ */ jsx(
|
|
154
|
-
"input",
|
|
155
|
-
{
|
|
156
|
-
ref: mergedRef,
|
|
157
|
-
id,
|
|
158
|
-
type: inputType,
|
|
159
|
-
value: inputValue,
|
|
160
|
-
className: cn(
|
|
161
|
-
"input",
|
|
162
|
-
displayError && "input--error",
|
|
163
|
-
fullWidth && "input--full-width",
|
|
164
|
-
showToggle && "input--with-toggle",
|
|
165
|
-
className
|
|
166
|
-
),
|
|
167
|
-
"aria-invalid": displayError ? "true" : "false",
|
|
168
|
-
"aria-required": required ? "true" : void 0,
|
|
169
|
-
"aria-describedby": displayError ? errorId : helperText ? helperId : void 0,
|
|
170
|
-
"data-cy": finalDataCy,
|
|
171
|
-
"data-testid": finalTestId,
|
|
172
|
-
"data-state": inputState,
|
|
173
|
-
onChange: handleChange,
|
|
174
|
-
onFocus: handleFocus,
|
|
175
|
-
onBlur: handleBlur,
|
|
176
|
-
onMouseEnter: handleMouseEnter,
|
|
177
|
-
onMouseLeave: handleMouseLeave,
|
|
178
|
-
required,
|
|
179
|
-
...props
|
|
180
|
-
}
|
|
181
|
-
),
|
|
182
|
-
showToggle && /* @__PURE__ */ jsx(
|
|
183
|
-
"button",
|
|
184
|
-
{
|
|
185
|
-
type: "button",
|
|
186
|
-
className: "input__toggle",
|
|
187
|
-
onClick: togglePasswordVisibility,
|
|
188
|
-
"aria-label": isPasswordVisible ? "Hide password" : "Show password",
|
|
189
|
-
"data-cy": `${finalDataCy}-toggle`,
|
|
190
|
-
"data-testid": `${finalTestId}-toggle`,
|
|
191
|
-
children: isPasswordVisible ? /* @__PURE__ */ jsxs(
|
|
192
|
-
"svg",
|
|
193
|
-
{
|
|
194
|
-
width: "20",
|
|
195
|
-
height: "20",
|
|
196
|
-
viewBox: "0 0 20 20",
|
|
197
|
-
fill: "none",
|
|
198
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
199
|
-
"aria-hidden": "true",
|
|
200
|
-
children: [
|
|
201
|
-
/* @__PURE__ */ jsx(
|
|
202
|
-
"path",
|
|
203
|
-
{
|
|
204
|
-
d: "M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",
|
|
205
|
-
stroke: "currentColor",
|
|
206
|
-
strokeWidth: "1.5",
|
|
207
|
-
strokeLinecap: "round",
|
|
208
|
-
strokeLinejoin: "round",
|
|
209
|
-
fill: "none"
|
|
210
|
-
}
|
|
211
|
-
),
|
|
212
|
-
/* @__PURE__ */ jsx(
|
|
213
|
-
"circle",
|
|
214
|
-
{
|
|
215
|
-
cx: "10",
|
|
216
|
-
cy: "10",
|
|
217
|
-
r: "2.5",
|
|
218
|
-
stroke: "currentColor",
|
|
219
|
-
strokeWidth: "1.5",
|
|
220
|
-
fill: "none"
|
|
221
|
-
}
|
|
222
|
-
)
|
|
223
|
-
]
|
|
224
|
-
}
|
|
225
|
-
) : /* @__PURE__ */ jsxs(
|
|
226
|
-
"svg",
|
|
227
|
-
{
|
|
228
|
-
width: "20",
|
|
229
|
-
height: "20",
|
|
230
|
-
viewBox: "0 0 20 20",
|
|
231
|
-
fill: "none",
|
|
232
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
233
|
-
"aria-hidden": "true",
|
|
234
|
-
children: [
|
|
235
|
-
/* @__PURE__ */ jsx(
|
|
236
|
-
"path",
|
|
237
|
-
{
|
|
238
|
-
d: "M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",
|
|
239
|
-
stroke: "currentColor",
|
|
240
|
-
strokeWidth: "1.5",
|
|
241
|
-
strokeLinecap: "round",
|
|
242
|
-
strokeLinejoin: "round",
|
|
243
|
-
fill: "none"
|
|
244
|
-
}
|
|
245
|
-
),
|
|
246
|
-
/* @__PURE__ */ jsx(
|
|
247
|
-
"circle",
|
|
248
|
-
{
|
|
249
|
-
cx: "10",
|
|
250
|
-
cy: "10",
|
|
251
|
-
r: "2.5",
|
|
252
|
-
stroke: "currentColor",
|
|
253
|
-
strokeWidth: "1.5",
|
|
254
|
-
fill: "none"
|
|
255
|
-
}
|
|
256
|
-
),
|
|
257
|
-
/* @__PURE__ */ jsx(
|
|
258
|
-
"path",
|
|
259
|
-
{
|
|
260
|
-
d: "M3 3l14 14",
|
|
261
|
-
stroke: "currentColor",
|
|
262
|
-
strokeWidth: "1.5",
|
|
263
|
-
strokeLinecap: "round"
|
|
264
|
-
}
|
|
265
|
-
)
|
|
266
|
-
]
|
|
267
|
-
}
|
|
268
|
-
)
|
|
269
|
-
}
|
|
270
|
-
)
|
|
271
|
-
] }),
|
|
272
|
-
displayError && /* @__PURE__ */ jsx(
|
|
273
|
-
"span",
|
|
274
|
-
{
|
|
275
|
-
id: errorId,
|
|
276
|
-
className: "input__error",
|
|
277
|
-
role: "alert",
|
|
278
|
-
"data-cy": `${finalDataCy}-error`,
|
|
279
|
-
"data-testid": `${finalTestId}-error`,
|
|
280
|
-
children: displayError
|
|
281
|
-
}
|
|
282
|
-
),
|
|
283
|
-
helperText && !displayError && /* @__PURE__ */ jsx(
|
|
284
|
-
"span",
|
|
285
|
-
{
|
|
286
|
-
id: helperId,
|
|
287
|
-
className: "input__helper",
|
|
288
|
-
"data-cy": `${finalDataCy}-helper`,
|
|
289
|
-
"data-testid": `${finalTestId}-helper`,
|
|
290
|
-
children: helperText
|
|
291
|
-
}
|
|
292
|
-
)
|
|
293
|
-
]
|
|
294
|
-
}
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
);
|
|
298
|
-
Input.displayName = "Input";
|
|
1
|
+
var tester = /^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;
|
|
2
|
+
var validate = function(email) {
|
|
3
|
+
if (!email)
|
|
4
|
+
return false;
|
|
5
|
+
if (email.length > 254)
|
|
6
|
+
return false;
|
|
7
|
+
var valid = tester.test(email);
|
|
8
|
+
if (!valid)
|
|
9
|
+
return false;
|
|
10
|
+
var parts = email.split("@");
|
|
11
|
+
if (parts[0].length > 64)
|
|
12
|
+
return false;
|
|
13
|
+
var domainParts = parts[1].split(".");
|
|
14
|
+
if (domainParts.some(function(part) {
|
|
15
|
+
return part.length > 63;
|
|
16
|
+
}))
|
|
17
|
+
return false;
|
|
18
|
+
return true;
|
|
19
|
+
};
|
|
299
20
|
export {
|
|
300
|
-
|
|
21
|
+
validate
|
|
301
22
|
};
|
package/dist/index21.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),t=require("./index18.cjs");;/* empty css */const a=require("./index22.cjs"),s=require("./index36.cjs"),n=r.forwardRef(({type:n="text",label:l,error:i,helperText:o,fullWidth:u=!1,showPasswordToggle:d=!0,showLastChar:c=!0,lastCharDelay:p=500,validate:h,onValidationChange:f,className:g,id:x,onChange:v,onBlur:w,required:j,value:m,"data-cy":y,"data-testid":k,...b},C)=>{const[$,N]=r.useState(!1),[_,q]=r.useState(),[M,S]=r.useState(!1),[L,R]=r.useState(!1),T=r.useRef(!1),[E,W]=r.useState(""),B=r.useRef(""),F=r.useRef(null),I=r.useRef(null),z=a.useMergedRef(C,I),D=r.useId(),O=x||D,P=`${O}-error`,V=`${O}-helper`,H=y||"input",A=k||"input",G="password"===n,J=G&&d,K=G&&c&&!$,Q=G&&($||K&&B.current.length>0)?"text":n,U=l&&j&&!l.includes("*")?`${l} *`:l,X=r.useMemo(()=>s.debounce(e=>{if(h&&T.current){const r=h(e);q(r),null==f||f(!r)}},300),[h,f]),Y=r.useRef(X);r.useEffect(()=>{Y.current=X},[X]),r.useEffect(()=>{process.env.NODE_ENV},[G,c,m]),r.useEffect(()=>()=>{F.current&&clearTimeout(F.current),Y.current.cancel()},[]);const Z=K&&void 0===m?E:$&&G&&void 0===m?B.current||"":m,ee=i||_,re=b.disabled?"disabled":ee?"error":M?"focus":L?"hover":"idle";return e.jsxs("div",{className:t.cn("input-wrapper",u&&"input-wrapper--full-width"),"data-cy":`${H}-wrapper`,"data-testid":`${A}-wrapper`,children:[l&&e.jsx("label",{htmlFor:O,className:"input__label","data-cy":`${H}-label`,"data-testid":`${A}-label`,children:U}),e.jsxs("div",{className:"input__field-container",children:[e.jsx("input",{ref:z,id:O,type:Q,value:Z,className:t.cn("input",ee&&"input--error",u&&"input--full-width",J&&"input--with-toggle",g),"aria-invalid":ee?"true":"false","aria-required":j?"true":void 0,"aria-describedby":ee?P:o?V:void 0,"data-cy":H,"data-testid":A,"data-state":re,onChange:e=>{null==v||v(e);let r=e.target.value;if(K){const t=e.target,a=t.value;B.current=a;const s=a?"•".repeat(a.length-1)+a.slice(-1):"";W(s),t.value=s,r=a,F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{W("•".repeat(a.length))},p)}T.current&&X(r)},onFocus:e=>{var r;S(!0),null==(r=b.onFocus)||r.call(b,e)},onBlur:e=>{if(S(!1),T.current=!0,h){const r=K?B.current:e.target.value,t=h(r);q(t),null==f||f(!t)}null==w||w(e)},onMouseEnter:()=>{R(!0)},onMouseLeave:()=>{R(!1)},required:j,...b}),J&&e.jsx("button",{type:"button",className:"input__toggle",onClick:()=>{N(e=>!e),setTimeout(()=>{var e;return null==(e=I.current)?void 0:e.focus()},0)},"aria-label":$?"Hide password":"Show password","data-cy":`${H}-toggle`,"data-testid":`${A}-toggle`,children:$?e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[e.jsx("path",{d:"M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),e.jsx("circle",{cx:"10",cy:"10",r:"2.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})]}):e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[e.jsx("path",{d:"M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),e.jsx("circle",{cx:"10",cy:"10",r:"2.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none"}),e.jsx("path",{d:"M3 3l14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})})]}),ee&&e.jsx("span",{id:P,className:"input__error",role:"alert","data-cy":`${H}-error`,"data-testid":`${A}-error`,children:ee}),o&&!ee&&e.jsx("span",{id:V,className:"input__helper","data-cy":`${H}-helper`,"data-testid":`${A}-helper`,children:o})]})});n.displayName="Input",exports.Input=n;
|