@adam-milo/ui 1.0.20 → 1.0.22

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.
Files changed (66) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +53 -53
  3. package/dist/index10.cjs +1 -1
  4. package/dist/index10.js +38 -36
  5. package/dist/index11.cjs +1 -1
  6. package/dist/index11.js +82 -76
  7. package/dist/index12.cjs +1 -1
  8. package/dist/index12.js +50 -49
  9. package/dist/index13.cjs +1 -1
  10. package/dist/index13.js +30 -30
  11. package/dist/index14.cjs +1 -1
  12. package/dist/index14.js +348 -209
  13. package/dist/index15.cjs +1 -1
  14. package/dist/index15.js +92 -82
  15. package/dist/index16.cjs +1 -1
  16. package/dist/index16.js +32 -31
  17. package/dist/index17.cjs +1 -1
  18. package/dist/index17.js +10 -7
  19. package/dist/index19.cjs +1 -0
  20. package/dist/index19.js +22 -0
  21. package/dist/index2.cjs +1 -1
  22. package/dist/index2.js +26 -26
  23. package/dist/index20.cjs +1 -0
  24. package/dist/index20.js +301 -0
  25. package/dist/index21.cjs +1 -0
  26. package/dist/index21.js +16 -0
  27. package/dist/index3.cjs +1 -1
  28. package/dist/index3.js +37 -95
  29. package/dist/index30.cjs +1 -0
  30. package/dist/index30.js +9 -0
  31. package/dist/index33.cjs +1 -0
  32. package/dist/index33.js +21 -0
  33. package/dist/index4.cjs +1 -1
  34. package/dist/index4.js +18 -174
  35. package/dist/index5.cjs +1 -1
  36. package/dist/index5.js +51 -155
  37. package/dist/index6.cjs +1 -1
  38. package/dist/index6.js +102 -159
  39. package/dist/index7.cjs +1 -1
  40. package/dist/index7.js +76 -61
  41. package/dist/index8.cjs +1 -1
  42. package/dist/index8.js +68 -54
  43. package/dist/index9.cjs +1 -1
  44. package/dist/index9.js +47 -43
  45. package/dist/src/components/forms/alphanumeric-input/AlphanumericInput.component.d.ts +23 -38
  46. package/dist/src/components/forms/alphanumeric-input/AlphanumericInput.component.d.ts.map +1 -1
  47. package/dist/src/components/forms/email-input/EmailInput.component.d.ts +17 -20
  48. package/dist/src/components/forms/email-input/EmailInput.component.d.ts.map +1 -1
  49. package/dist/src/components/forms/input/Input.component.d.ts +105 -0
  50. package/dist/src/components/forms/input/Input.component.d.ts.map +1 -0
  51. package/dist/src/components/forms/numeric-input/NumericInput.component.d.ts +30 -48
  52. package/dist/src/components/forms/numeric-input/NumericInput.component.d.ts.map +1 -1
  53. package/dist/src/components/forms/password-input/PasswordInput.component.d.ts +19 -16
  54. package/dist/src/components/forms/password-input/PasswordInput.component.d.ts.map +1 -1
  55. package/dist/src/lib/debounce.d.ts +12 -0
  56. package/dist/src/lib/debounce.d.ts.map +1 -0
  57. package/dist/src/lib/debounce.spec.d.ts +2 -0
  58. package/dist/src/lib/debounce.spec.d.ts.map +1 -0
  59. package/dist/src/lib/dev-utils.d.ts +41 -0
  60. package/dist/src/lib/dev-utils.d.ts.map +1 -0
  61. package/dist/src/lib/index.d.ts +15 -2
  62. package/dist/src/lib/index.d.ts.map +1 -1
  63. package/dist/src/lib/useMergedRef.d.ts +19 -0
  64. package/dist/src/lib/useMergedRef.d.ts.map +1 -0
  65. package/dist/style.css +1 -1
  66. package/package.json +5 -2
@@ -0,0 +1,301 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useState, useRef, useId, useMemo, useEffect } from "react";
3
+ import { cn } from "./index17.js";
4
+ /* empty css */
5
+ import { useMergedRef } from "./index21.js";
6
+ import { debounce } from "./index33.js";
7
+ const Input = forwardRef(
8
+ ({
9
+ type = "text",
10
+ label,
11
+ error: externalError,
12
+ helperText,
13
+ fullWidth = false,
14
+ showPasswordToggle = true,
15
+ showLastChar = true,
16
+ lastCharDelay = 500,
17
+ validate,
18
+ onValidationChange,
19
+ className,
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";
299
+ export {
300
+ Input
301
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");exports.useMergedRef=function(...r){return e.useCallback(e=>{r.forEach(r=>{r&&("function"==typeof r?r(e):r.current=e)})},r)};
@@ -0,0 +1,16 @@
1
+ import { useCallback } from "react";
2
+ function useMergedRef(...refs) {
3
+ return useCallback((element) => {
4
+ refs.forEach((ref) => {
5
+ if (!ref) return;
6
+ if (typeof ref === "function") {
7
+ ref(element);
8
+ } else {
9
+ ref.current = element;
10
+ }
11
+ });
12
+ }, refs);
13
+ }
14
+ export {
15
+ useMergedRef
16
+ };
package/dist/index3.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),n=require("react"),j=require("./index17.cjs");;/* empty css */const L=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,w=n.forwardRef(({validateEmail:m=!0,invalidEmailMessage:y="Not a valid email address",onValidationChange:r,error:N,onChange:p,label:f,helperText:o,fullWidth:$=!1,className:_,id:x,"data-cy":q,"data-testid":S,...i},B)=>{const[R,I]=n.useState(),[h,F]=n.useState(!1),A=n.useId(),l=x||A,v=`${l}-error`,E=`${l}-helper`,s=q||"email-input",a=S||"email-input",b=t=>t?L.test(t):!0,D=t=>{const u=t.target.value;if(m&&h){const d=b(u);I(d?void 0:y),r==null||r(d)}p==null||p(t)},G=t=>{var u;if(F(!0),m){const d=b(t.target.value);I(d?void 0:y),r==null||r(d)}(u=i.onBlur)==null||u.call(i,t)},e=N||R;return c.jsxs("div",{className:j.cn("input-wrapper",$&&"input-wrapper--full-width"),"data-cy":`${s}-wrapper`,"data-testid":`${a}-wrapper`,children:[f&&c.jsx("label",{htmlFor:l,className:"input__label","data-cy":`${s}-label`,"data-testid":`${a}-label`,children:f}),c.jsx("input",{ref:B,id:l,type:"email",className:j.cn("input",e&&"input--error",$&&"input--full-width",_),"aria-invalid":e?"true":"false","aria-describedby":e?v:o?E:void 0,"data-cy":s,"data-testid":a,onChange:D,onBlur:G,...i}),e&&c.jsx("span",{id:v,className:"input__error",role:"alert","data-cy":`${s}-error`,"data-testid":`${a}-error`,children:e}),o&&!e&&c.jsx("span",{id:E,className:"input__helper","data-cy":`${s}-helper`,"data-testid":`${a}-helper`,children:o})]})});w.displayName="EmailInput";exports.EmailInput=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),t=require("./index19.cjs"),i=require("./index20.cjs"),r=a.forwardRef(({validateEmail:r=!0,invalidEmailMessage:l="Not a valid email address",validate:d,"data-cy":s,"data-testid":u,...n},c)=>{const o=a.useCallback(e=>{if(e)return t.validate(e)?void 0:l},[l]),m=a.useCallback(e=>r?d?o(e)||d(e):o(e):null==d?void 0:d(e),[r,d,o]);return e.jsx(i.Input,{ref:c,type:"email",validate:m,"data-cy":s||"email-input","data-testid":u||"email-input",...n})});r.displayName="EmailInput",exports.EmailInput=r;
package/dist/index3.js CHANGED
@@ -1,103 +1,45 @@
1
- import { jsxs as S, jsx as u } from "react/jsx-runtime";
2
- import { forwardRef as X, useState as E, useId as k } from "react";
3
- import { cn as N } from "./index17.js";
4
- /* empty css */
5
- const q = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, z = X(
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback } from "react";
3
+ import { validate } from "./index19.js";
4
+ import { Input } from "./index20.js";
5
+ const EmailInput = forwardRef(
6
6
  ({
7
- validateEmail: m = !0,
8
- invalidEmailMessage: n = "Not a valid email address",
9
- onValidationChange: r,
10
- error: _,
11
- onChange: p,
12
- label: f,
13
- helperText: o,
14
- fullWidth: y = !1,
15
- className: b,
16
- id: B,
17
- "data-cy": h,
18
- "data-testid": j,
19
- ...l
20
- }, F) => {
21
- const [R, $] = E(), [x, A] = E(!1), D = k(), i = B || D, I = `${i}-error`, v = `${i}-helper`, a = h || "email-input", s = j || "email-input", w = (t) => t ? q.test(t) : !0, G = (t) => {
22
- const c = t.target.value;
23
- if (m && x) {
24
- const d = w(c);
25
- $(d ? void 0 : n), r == null || r(d);
26
- }
27
- p == null || p(t);
28
- }, L = (t) => {
29
- var c;
30
- if (A(!0), m) {
31
- const d = w(t.target.value);
32
- $(d ? void 0 : n), r == null || r(d);
33
- }
34
- (c = l.onBlur) == null || c.call(l, t);
35
- }, e = _ || R;
36
- return /* @__PURE__ */ S(
37
- "div",
7
+ validateEmail = true,
8
+ invalidEmailMessage = "Not a valid email address",
9
+ validate: validate$1,
10
+ "data-cy": dataCy,
11
+ "data-testid": dataTestId,
12
+ ...props
13
+ }, ref) => {
14
+ const emailValidation = useCallback(
15
+ (value) => {
16
+ if (!value) return void 0;
17
+ return validate(value) ? void 0 : invalidEmailMessage;
18
+ },
19
+ [invalidEmailMessage]
20
+ );
21
+ const combinedValidation = useCallback(
22
+ (value) => {
23
+ if (!validateEmail) return validate$1 == null ? void 0 : validate$1(value);
24
+ if (!validate$1) return emailValidation(value);
25
+ return emailValidation(value) || validate$1(value);
26
+ },
27
+ [validateEmail, validate$1, emailValidation]
28
+ );
29
+ return /* @__PURE__ */ jsx(
30
+ Input,
38
31
  {
39
- className: N("input-wrapper", y && "input-wrapper--full-width"),
40
- "data-cy": `${a}-wrapper`,
41
- "data-testid": `${s}-wrapper`,
42
- children: [
43
- f && /* @__PURE__ */ u(
44
- "label",
45
- {
46
- htmlFor: i,
47
- className: "input__label",
48
- "data-cy": `${a}-label`,
49
- "data-testid": `${s}-label`,
50
- children: f
51
- }
52
- ),
53
- /* @__PURE__ */ u(
54
- "input",
55
- {
56
- ref: F,
57
- id: i,
58
- type: "email",
59
- className: N(
60
- "input",
61
- e && "input--error",
62
- y && "input--full-width",
63
- b
64
- ),
65
- "aria-invalid": e ? "true" : "false",
66
- "aria-describedby": e ? I : o ? v : void 0,
67
- "data-cy": a,
68
- "data-testid": s,
69
- onChange: G,
70
- onBlur: L,
71
- ...l
72
- }
73
- ),
74
- e && /* @__PURE__ */ u(
75
- "span",
76
- {
77
- id: I,
78
- className: "input__error",
79
- role: "alert",
80
- "data-cy": `${a}-error`,
81
- "data-testid": `${s}-error`,
82
- children: e
83
- }
84
- ),
85
- o && !e && /* @__PURE__ */ u(
86
- "span",
87
- {
88
- id: v,
89
- className: "input__helper",
90
- "data-cy": `${a}-helper`,
91
- "data-testid": `${s}-helper`,
92
- children: o
93
- }
94
- )
95
- ]
32
+ ref,
33
+ type: "email",
34
+ validate: combinedValidation,
35
+ "data-cy": dataCy || "email-input",
36
+ "data-testid": dataTestId || "email-input",
37
+ ...props
96
38
  }
97
39
  );
98
40
  }
99
41
  );
100
- z.displayName = "EmailInput";
42
+ EmailInput.displayName = "EmailInput";
101
43
  export {
102
- z as EmailInput
44
+ EmailInput
103
45
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});process.env.NODE_ENV;exports.devWarn=e=>{};
@@ -0,0 +1,9 @@
1
+ const isDev = process.env.NODE_ENV !== "production";
2
+ const devWarn = (message) => {
3
+ if (isDev) {
4
+ console.warn(message);
5
+ }
6
+ };
7
+ export {
8
+ devWarn
9
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.debounce=function(e,t){let l=null;const n=function(...n){l&&clearTimeout(l);const o=this;l=setTimeout(()=>{e.apply(o,n),l=null},t)};return n.cancel=()=>{l&&(clearTimeout(l),l=null)},n};
@@ -0,0 +1,21 @@
1
+ function debounce(func, wait) {
2
+ let timeoutId = null;
3
+ const debounced = function(...args) {
4
+ if (timeoutId) clearTimeout(timeoutId);
5
+ const context = this;
6
+ timeoutId = setTimeout(() => {
7
+ func.apply(context, args);
8
+ timeoutId = null;
9
+ }, wait);
10
+ };
11
+ debounced.cancel = () => {
12
+ if (timeoutId) {
13
+ clearTimeout(timeoutId);
14
+ timeoutId = null;
15
+ }
16
+ };
17
+ return debounced;
18
+ }
19
+ export {
20
+ debounce
21
+ };
package/dist/index4.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),d=require("react"),u=require("./index17.cjs");;/* empty css */const w=d.forwardRef(({showToggle:h=!0,label:o,error:e,helperText:i,fullWidth:l=!1,className:x,id:g,"data-cy":j,"data-testid":y,...k},f)=>{const[n,b]=d.useState(!1),m=d.useId(),a=g||m,c=`${a}-error`,p=`${a}-helper`,s=j||"password-input",r=y||"password-input",$=()=>{b(v=>!v)};return t.jsxs("div",{className:"password-input-wrapper",children:[t.jsxs("div",{className:u.cn("input-wrapper",l&&"input-wrapper--full-width"),"data-cy":`${s}-wrapper`,"data-testid":`${r}-wrapper`,children:[o&&t.jsx("label",{htmlFor:a,className:"input__label","data-cy":`${s}-label`,"data-testid":`${r}-label`,children:o}),t.jsx("input",{ref:f,id:a,type:n?"text":"password",className:u.cn("input","password-input",e&&"input--error",l&&"input--full-width",x),"aria-invalid":e?"true":"false","aria-describedby":e?c:i?p:void 0,"data-cy":s,"data-testid":r,...k}),e&&t.jsx("span",{id:c,className:"input__error",role:"alert","data-cy":`${s}-error`,"data-testid":`${r}-error`,children:e}),i&&!e&&t.jsx("span",{id:p,className:"input__helper","data-cy":`${s}-helper`,"data-testid":`${r}-helper`,children:i})]}),h&&t.jsx("button",{type:"button",className:"password-input__toggle",onClick:$,"aria-label":n?"Hide password":"Show password","data-cy":`${s}-toggle`,"data-testid":`${r}-toggle`,children:n?t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.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"}),t.jsx("circle",{cx:"10",cy:"10",r:"2.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})]}):t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.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"}),t.jsx("circle",{cx:"10",cy:"10",r:"2.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none"}),t.jsx("path",{d:"M3 3l14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})})]})});w.displayName="PasswordInput";exports.PasswordInput=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),s=require("./index20.cjs"),r=t.forwardRef(({showToggle:t=!0,"data-cy":r,"data-testid":a,...o},d)=>e.jsx(s.Input,{ref:d,type:"password",showPasswordToggle:t,"data-cy":r||"password-input","data-testid":a||"password-input",...o}));r.displayName="PasswordInput",exports.PasswordInput=r;