@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/index6.js CHANGED
@@ -1,50 +1,73 @@
1
- import { jsxs as U, jsx as b } from "react/jsx-runtime";
2
- import { forwardRef as L, useState as x, useId as g } from "react";
3
- import { cn as z } from "./index17.js";
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 y = L(
5
+ const AlphanumericInput = forwardRef(
6
6
  ({
7
- allowHyphen: u = !1,
8
- allowUnderscore: c = !1,
9
- allowSpace: f = !1,
10
- minLength: h,
11
- maxLength: p,
12
- invalidFormatMessage: F = "Only letters and numbers are allowed",
13
- minLengthMessage: M,
14
- maxLengthMessage: O,
15
- onValidationChange: a,
16
- error: Z,
17
- onChange: v,
18
- onKeyDown: t,
19
- label: _,
20
- helperText: I,
21
- fullWidth: E = !1,
22
- className: T,
23
- id: q,
24
- "data-cy": G,
25
- "data-testid": J,
26
- ...m
27
- }, P) => {
28
- const [Q, A] = x(), [X, Y] = x(!1), W = g(), $ = q || W, N = `${$}-error`, B = `${$}-helper`, d = G || "alphanumeric-input", l = J || "alphanumeric-input", j = (r) => {
29
- if (!r) return { isValid: !0 };
30
- let s = "^[a-zA-Z0-9";
31
- if (u && (s += "\\-"), c && (s += "_"), f && (s += " "), s += "]+$", !new RegExp(s).test(r)) {
32
- let R = F;
33
- if (u || c || f) {
34
- const k = ["letters", "numbers"];
35
- u && k.push("hyphens"), c && k.push("underscores"), f && k.push("spaces"), R = `Only ${k.join(", ")} are allowed`;
7
+ allowHyphen = false,
8
+ allowUnderscore = false,
9
+ allowSpace = false,
10
+ minLength,
11
+ maxLength,
12
+ invalidFormatMessage = "Only letters and numbers are allowed",
13
+ minLengthMessage,
14
+ maxLengthMessage,
15
+ onValidationChange,
16
+ error: externalError,
17
+ onChange,
18
+ onKeyDown,
19
+ label,
20
+ helperText,
21
+ fullWidth = false,
22
+ className,
23
+ id: providedId,
24
+ "data-cy": dataCy,
25
+ "data-testid": dataTestId,
26
+ ...props
27
+ }, ref) => {
28
+ const [internalError, setInternalError] = useState();
29
+ const [touched, setTouched] = useState(false);
30
+ const generatedId = useId();
31
+ const id = providedId || generatedId;
32
+ const errorId = `${id}-error`;
33
+ const helperId = `${id}-helper`;
34
+ const finalDataCy = dataCy || "alphanumeric-input";
35
+ const finalTestId = dataTestId || "alphanumeric-input";
36
+ const validateFormat = (value) => {
37
+ if (!value) return { isValid: true };
38
+ let pattern = "^[a-zA-Z0-9";
39
+ if (allowHyphen) pattern += "\\-";
40
+ if (allowUnderscore) pattern += "_";
41
+ if (allowSpace) pattern += " ";
42
+ pattern += "]+$";
43
+ const regex = new RegExp(pattern);
44
+ if (!regex.test(value)) {
45
+ let message = invalidFormatMessage;
46
+ if (allowHyphen || allowUnderscore || allowSpace) {
47
+ const allowed = ["letters", "numbers"];
48
+ if (allowHyphen) allowed.push("hyphens");
49
+ if (allowUnderscore) allowed.push("underscores");
50
+ if (allowSpace) allowed.push("spaces");
51
+ message = `Only ${allowed.join(", ")} are allowed`;
36
52
  }
37
- return { isValid: !1, error: R };
53
+ return { isValid: false, error: message };
38
54
  }
39
- return h !== void 0 && r.length < h ? {
40
- isValid: !1,
41
- error: M || `Must be at least ${h} characters`
42
- } : p !== void 0 && r.length > p ? {
43
- isValid: !1,
44
- error: O || `Must be at most ${p} characters`
45
- } : { isValid: !0 };
46
- }, H = (r) => {
47
- const s = [
55
+ if (minLength !== void 0 && value.length < minLength) {
56
+ return {
57
+ isValid: false,
58
+ error: minLengthMessage || `Must be at least ${minLength} characters`
59
+ };
60
+ }
61
+ if (maxLength !== void 0 && value.length > maxLength) {
62
+ return {
63
+ isValid: false,
64
+ error: maxLengthMessage || `Must be at most ${maxLength} characters`
65
+ };
66
+ }
67
+ return { isValid: true };
68
+ };
69
+ const handleKeyDown = (e) => {
70
+ const allowedKeys = [
48
71
  "Backspace",
49
72
  "Delete",
50
73
  "Tab",
@@ -55,107 +78,113 @@ const y = L(
55
78
  "Home",
56
79
  "End"
57
80
  ];
58
- if (r.ctrlKey || r.metaKey) {
59
- t == null || t(r);
81
+ if (e.ctrlKey || e.metaKey) {
82
+ onKeyDown == null ? void 0 : onKeyDown(e);
60
83
  return;
61
84
  }
62
- if (s.includes(r.key)) {
63
- t == null || t(r);
85
+ if (allowedKeys.includes(e.key)) {
86
+ onKeyDown == null ? void 0 : onKeyDown(e);
64
87
  return;
65
88
  }
66
- if (f && r.key === " ") {
67
- t == null || t(r);
89
+ if (allowSpace && e.key === " ") {
90
+ onKeyDown == null ? void 0 : onKeyDown(e);
68
91
  return;
69
92
  }
70
- if (u && r.key === "-") {
71
- t == null || t(r);
93
+ if (allowHyphen && e.key === "-") {
94
+ onKeyDown == null ? void 0 : onKeyDown(e);
72
95
  return;
73
96
  }
74
- if (c && r.key === "_") {
75
- t == null || t(r);
97
+ if (allowUnderscore && e.key === "_") {
98
+ onKeyDown == null ? void 0 : onKeyDown(e);
76
99
  return;
77
100
  }
78
- if (r.key >= "a" && r.key <= "z" || r.key >= "A" && r.key <= "Z") {
79
- t == null || t(r);
101
+ if (e.key >= "a" && e.key <= "z" || e.key >= "A" && e.key <= "Z") {
102
+ onKeyDown == null ? void 0 : onKeyDown(e);
80
103
  return;
81
104
  }
82
- if (r.key >= "0" && r.key <= "9") {
83
- t == null || t(r);
105
+ if (e.key >= "0" && e.key <= "9") {
106
+ onKeyDown == null ? void 0 : onKeyDown(e);
84
107
  return;
85
108
  }
86
- r.preventDefault();
87
- }, S = (r) => {
88
- const s = r.target.value;
89
- if (X) {
90
- const i = j(s);
91
- A(i.error), a == null || a(i.isValid);
109
+ e.preventDefault();
110
+ };
111
+ const handleChange = (e) => {
112
+ const value = e.target.value;
113
+ if (touched) {
114
+ const validation = validateFormat(value);
115
+ setInternalError(validation.error);
116
+ onValidationChange == null ? void 0 : onValidationChange(validation.isValid);
92
117
  }
93
- v == null || v(r);
94
- }, V = (r) => {
95
- var i;
96
- Y(!0);
97
- const s = j(r.target.value);
98
- A(s.error), a == null || a(s.isValid), (i = m.onBlur) == null || i.call(m, r);
99
- }, e = Z || Q;
100
- return /* @__PURE__ */ U(
118
+ onChange == null ? void 0 : onChange(e);
119
+ };
120
+ const handleBlur = (e) => {
121
+ var _a;
122
+ setTouched(true);
123
+ const validation = validateFormat(e.target.value);
124
+ setInternalError(validation.error);
125
+ onValidationChange == null ? void 0 : onValidationChange(validation.isValid);
126
+ (_a = props.onBlur) == null ? void 0 : _a.call(props, e);
127
+ };
128
+ const displayError = externalError || internalError;
129
+ return /* @__PURE__ */ jsxs(
101
130
  "div",
102
131
  {
103
- className: z("input-wrapper", E && "input-wrapper--full-width"),
104
- "data-cy": `${d}-wrapper`,
105
- "data-testid": `${l}-wrapper`,
132
+ className: cn("input-wrapper", fullWidth && "input-wrapper--full-width"),
133
+ "data-cy": `${finalDataCy}-wrapper`,
134
+ "data-testid": `${finalTestId}-wrapper`,
106
135
  children: [
107
- _ && /* @__PURE__ */ b(
136
+ label && /* @__PURE__ */ jsx(
108
137
  "label",
109
138
  {
110
- htmlFor: $,
139
+ htmlFor: id,
111
140
  className: "input__label",
112
- "data-cy": `${d}-label`,
113
- "data-testid": `${l}-label`,
114
- children: _
141
+ "data-cy": `${finalDataCy}-label`,
142
+ "data-testid": `${finalTestId}-label`,
143
+ children: label
115
144
  }
116
145
  ),
117
- /* @__PURE__ */ b(
146
+ /* @__PURE__ */ jsx(
118
147
  "input",
119
148
  {
120
- ref: P,
121
- id: $,
149
+ ref,
150
+ id,
122
151
  type: "text",
123
- className: z(
152
+ className: cn(
124
153
  "input",
125
- e && "input--error",
126
- E && "input--full-width",
127
- T
154
+ displayError && "input--error",
155
+ fullWidth && "input--full-width",
156
+ className
128
157
  ),
129
- "aria-invalid": e ? "true" : "false",
130
- "aria-describedby": e ? N : I ? B : void 0,
131
- "data-cy": d,
132
- "data-testid": l,
133
- onChange: S,
134
- onBlur: V,
135
- onKeyDown: H,
136
- maxLength: p,
137
- ...m
158
+ "aria-invalid": displayError ? "true" : "false",
159
+ "aria-describedby": displayError ? errorId : helperText ? helperId : void 0,
160
+ "data-cy": finalDataCy,
161
+ "data-testid": finalTestId,
162
+ onChange: handleChange,
163
+ onBlur: handleBlur,
164
+ onKeyDown: handleKeyDown,
165
+ maxLength,
166
+ ...props
138
167
  }
139
168
  ),
140
- e && /* @__PURE__ */ b(
169
+ displayError && /* @__PURE__ */ jsx(
141
170
  "span",
142
171
  {
143
- id: N,
172
+ id: errorId,
144
173
  className: "input__error",
145
174
  role: "alert",
146
- "data-cy": `${d}-error`,
147
- "data-testid": `${l}-error`,
148
- children: e
175
+ "data-cy": `${finalDataCy}-error`,
176
+ "data-testid": `${finalTestId}-error`,
177
+ children: displayError
149
178
  }
150
179
  ),
151
- I && !e && /* @__PURE__ */ b(
180
+ helperText && !displayError && /* @__PURE__ */ jsx(
152
181
  "span",
153
182
  {
154
- id: B,
183
+ id: helperId,
155
184
  className: "input__helper",
156
- "data-cy": `${d}-helper`,
157
- "data-testid": `${l}-helper`,
158
- children: I
185
+ "data-cy": `${finalDataCy}-helper`,
186
+ "data-testid": `${finalTestId}-helper`,
187
+ children: helperText
159
188
  }
160
189
  )
161
190
  ]
@@ -163,7 +192,7 @@ const y = L(
163
192
  );
164
193
  }
165
194
  );
166
- y.displayName = "AlphanumericInput";
195
+ AlphanumericInput.displayName = "AlphanumericInput";
167
196
  export {
168
- y as AlphanumericInput
197
+ AlphanumericInput
169
198
  };
package/dist/index7.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),i=require("react"),k=require("./index17.cjs");;/* empty css */const f=i.forwardRef(({label:t,error:e,helperText:n,indeterminate:o=!1,className:y,id:_,required:l,disabled:b,checked:$,"data-cy":m,"data-testid":j,...v},c)=>{const N=i.useId(),d=_||N,p=`${d}-error`,x=`${d}-helper`,s=m||"checkbox",r=j||"checkbox",u=i.useRef(null),w=i.useCallback(h=>{u.current=h,c&&(typeof c=="function"?c(h):"current"in c&&(c.current=h))},[c]);i.useEffect(()=>{u.current&&(u.current.indeterminate=o)},[o]);const C=t&&l&&!t.includes("*")?`${t} *`:t;return a.jsxs("div",{className:k.cn("checkbox-wrapper",b&&"checkbox-wrapper--disabled"),"data-cy":`${s}-wrapper`,"data-testid":`${r}-wrapper`,children:[a.jsxs("div",{className:"checkbox__container",children:[a.jsx("input",{ref:w,id:d,type:"checkbox",checked:$,className:k.cn("checkbox__input",e&&"checkbox__input--error",y),"aria-invalid":e?"true":"false","aria-required":l?"true":void 0,"aria-describedby":e?p:n?x:void 0,"data-cy":s,"data-testid":r,"data-indeterminate":o?"true":void 0,disabled:b,required:l,...v}),t&&a.jsx("label",{htmlFor:d,className:"checkbox__label","data-cy":`${s}-label`,"data-testid":`${r}-label`,children:C})]}),e&&a.jsx("span",{id:p,className:"checkbox__error",role:"alert","data-cy":`${s}-error`,"data-testid":`${r}-error`,children:e}),n&&!e&&a.jsx("span",{id:x,className:"checkbox__helper","data-cy":`${s}-helper`,"data-testid":`${r}-helper`,children:n})]})});f.displayName="Checkbox";exports.Checkbox=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),a=require("./index17.cjs");;/* empty css */const c=r.forwardRef(({label:c,error:t,helperText:d,indeterminate:i=!1,className:s,id:l,required:n,disabled:o,checked:u,"data-cy":b,"data-testid":h,...x},p)=>{const k=r.useId(),m=l||k,y=`${m}-error`,_=`${m}-helper`,$=b||"checkbox",f=h||"checkbox",j=r.useRef(null),N=r.useCallback(e=>{j.current=e,p&&("function"==typeof p?p(e):"current"in p&&(p.current=e))},[p]);r.useEffect(()=>{j.current&&(j.current.indeterminate=i)},[i]);const q=c&&n&&!c.includes("*")?`${c} *`:c;return e.jsxs("div",{className:a.cn("checkbox-wrapper",o&&"checkbox-wrapper--disabled"),"data-cy":`${$}-wrapper`,"data-testid":`${f}-wrapper`,children:[e.jsxs("div",{className:"checkbox__container",children:[e.jsx("input",{ref:N,id:m,type:"checkbox",checked:u,className:a.cn("checkbox__input",t&&"checkbox__input--error",s),"aria-invalid":t?"true":"false","aria-required":n?"true":void 0,"aria-describedby":t?y:d?_:void 0,"data-cy":$,"data-testid":f,"data-indeterminate":i?"true":void 0,disabled:o,required:n,...x}),c&&e.jsx("label",{htmlFor:m,className:"checkbox__label","data-cy":`${$}-label`,"data-testid":`${f}-label`,children:q})]}),t&&e.jsx("span",{id:y,className:"checkbox__error",role:"alert","data-cy":`${$}-error`,"data-testid":`${f}-error`,children:t}),d&&!t&&e.jsx("span",{id:_,className:"checkbox__helper","data-cy":`${$}-helper`,"data-testid":`${f}-helper`,children:d})]})});c.displayName="Checkbox",exports.Checkbox=c;
package/dist/index7.js CHANGED
@@ -1,89 +1,104 @@
1
- import { jsxs as f, jsx as i } from "react/jsx-runtime";
2
- import { forwardRef as C, useId as R, useRef as j, useCallback as g, useEffect as D } from "react";
3
- import { cn as k } from "./index17.js";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useId, useRef, useCallback, useEffect } from "react";
3
+ import { cn } from "./index17.js";
4
4
  /* empty css */
5
- const E = C(
5
+ const Checkbox = forwardRef(
6
6
  ({
7
- label: c,
8
- error: a,
9
- helperText: s,
10
- indeterminate: o = !1,
11
- className: m,
12
- id: x,
13
- required: n,
14
- disabled: h,
15
- checked: y,
16
- "data-cy": _,
17
- "data-testid": $,
18
- ...N
19
- }, e) => {
20
- const v = R(), d = x || v, u = `${d}-error`, b = `${d}-helper`, t = _ || "checkbox", r = $ || "checkbox", l = j(null), w = g(
21
- (p) => {
22
- l.current = p, e && (typeof e == "function" ? e(p) : "current" in e && (e.current = p));
7
+ label,
8
+ error,
9
+ helperText,
10
+ indeterminate = false,
11
+ className,
12
+ id: providedId,
13
+ required,
14
+ disabled,
15
+ checked,
16
+ "data-cy": dataCy,
17
+ "data-testid": dataTestId,
18
+ ...props
19
+ }, ref) => {
20
+ const generatedId = useId();
21
+ const id = providedId || generatedId;
22
+ const errorId = `${id}-error`;
23
+ const helperId = `${id}-helper`;
24
+ const finalDataCy = dataCy || "checkbox";
25
+ const finalTestId = dataTestId || "checkbox";
26
+ const internalRef = useRef(null);
27
+ const combinedRef = useCallback(
28
+ (element) => {
29
+ internalRef.current = element;
30
+ if (!ref) return;
31
+ if (typeof ref === "function") {
32
+ ref(element);
33
+ } else if ("current" in ref) {
34
+ ref.current = element;
35
+ }
23
36
  },
24
- [e]
37
+ [ref]
25
38
  );
26
- D(() => {
27
- l.current && (l.current.indeterminate = o);
28
- }, [o]);
29
- const I = c && n && !c.includes("*") ? `${c} *` : c;
30
- return /* @__PURE__ */ f(
39
+ useEffect(() => {
40
+ if (internalRef.current) {
41
+ internalRef.current.indeterminate = indeterminate;
42
+ }
43
+ }, [indeterminate]);
44
+ const displayLabel = label && required && !label.includes("*") ? `${label} *` : label;
45
+ return /* @__PURE__ */ jsxs(
31
46
  "div",
32
47
  {
33
- className: k("checkbox-wrapper", h && "checkbox-wrapper--disabled"),
34
- "data-cy": `${t}-wrapper`,
35
- "data-testid": `${r}-wrapper`,
48
+ className: cn("checkbox-wrapper", disabled && "checkbox-wrapper--disabled"),
49
+ "data-cy": `${finalDataCy}-wrapper`,
50
+ "data-testid": `${finalTestId}-wrapper`,
36
51
  children: [
37
- /* @__PURE__ */ f("div", { className: "checkbox__container", children: [
38
- /* @__PURE__ */ i(
52
+ /* @__PURE__ */ jsxs("div", { className: "checkbox__container", children: [
53
+ /* @__PURE__ */ jsx(
39
54
  "input",
40
55
  {
41
- ref: w,
42
- id: d,
56
+ ref: combinedRef,
57
+ id,
43
58
  type: "checkbox",
44
- checked: y,
45
- className: k("checkbox__input", a && "checkbox__input--error", m),
46
- "aria-invalid": a ? "true" : "false",
47
- "aria-required": n ? "true" : void 0,
48
- "aria-describedby": a ? u : s ? b : void 0,
49
- "data-cy": t,
50
- "data-testid": r,
51
- "data-indeterminate": o ? "true" : void 0,
52
- disabled: h,
53
- required: n,
54
- ...N
59
+ checked,
60
+ className: cn("checkbox__input", error && "checkbox__input--error", className),
61
+ "aria-invalid": error ? "true" : "false",
62
+ "aria-required": required ? "true" : void 0,
63
+ "aria-describedby": error ? errorId : helperText ? helperId : void 0,
64
+ "data-cy": finalDataCy,
65
+ "data-testid": finalTestId,
66
+ "data-indeterminate": indeterminate ? "true" : void 0,
67
+ disabled,
68
+ required,
69
+ ...props
55
70
  }
56
71
  ),
57
- c && /* @__PURE__ */ i(
72
+ label && /* @__PURE__ */ jsx(
58
73
  "label",
59
74
  {
60
- htmlFor: d,
75
+ htmlFor: id,
61
76
  className: "checkbox__label",
62
- "data-cy": `${t}-label`,
63
- "data-testid": `${r}-label`,
64
- children: I
77
+ "data-cy": `${finalDataCy}-label`,
78
+ "data-testid": `${finalTestId}-label`,
79
+ children: displayLabel
65
80
  }
66
81
  )
67
82
  ] }),
68
- a && /* @__PURE__ */ i(
83
+ error && /* @__PURE__ */ jsx(
69
84
  "span",
70
85
  {
71
- id: u,
86
+ id: errorId,
72
87
  className: "checkbox__error",
73
88
  role: "alert",
74
- "data-cy": `${t}-error`,
75
- "data-testid": `${r}-error`,
76
- children: a
89
+ "data-cy": `${finalDataCy}-error`,
90
+ "data-testid": `${finalTestId}-error`,
91
+ children: error
77
92
  }
78
93
  ),
79
- s && !a && /* @__PURE__ */ i(
94
+ helperText && !error && /* @__PURE__ */ jsx(
80
95
  "span",
81
96
  {
82
- id: b,
97
+ id: helperId,
83
98
  className: "checkbox__helper",
84
- "data-cy": `${t}-helper`,
85
- "data-testid": `${r}-helper`,
86
- children: s
99
+ "data-cy": `${finalDataCy}-helper`,
100
+ "data-testid": `${finalTestId}-helper`,
101
+ children: helperText
87
102
  }
88
103
  )
89
104
  ]
@@ -91,7 +106,7 @@ const E = C(
91
106
  );
92
107
  }
93
108
  );
94
- E.displayName = "Checkbox";
109
+ Checkbox.displayName = "Checkbox";
95
110
  export {
96
- E as Checkbox
111
+ Checkbox
97
112
  };
package/dist/index8.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),_=require("./index17.cjs");;/* empty css */const $=n.forwardRef(({label:r,error:d,helperText:c,className:f,id:h,required:l,disabled:p,checked:m,"data-cy":j,"data-testid":R,...b},a)=>{const N=n.useId(),s=h||N,u=`${s}-error`,y=`${s}-helper`,t=j||"radio",i=R||"radio",x=n.useRef(null),w=n.useCallback(o=>{x.current=o,a&&(typeof a=="function"?a(o):"current"in a&&(a.current=o))},[a]),I=r&&l&&!r.includes("*")?`${r} *`:r;return e.jsxs("div",{className:_.cn("radio-wrapper",p&&"radio-wrapper--disabled"),"data-cy":`${t}-wrapper`,"data-testid":`${i}-wrapper`,children:[e.jsxs("div",{className:"radio__container",children:[e.jsx("input",{ref:w,id:s,type:"radio",checked:m,className:_.cn("radio__input",d&&"radio__input--error",f),"aria-describedby":d?u:c?y:void 0,"data-cy":t,"data-testid":i,disabled:p,required:l,...b}),r&&e.jsx("label",{htmlFor:s,className:"radio__label","data-cy":`${t}-label`,"data-testid":`${i}-label`,children:I})]}),d&&e.jsx("span",{id:u,className:"radio__error",role:"alert","data-cy":`${t}-error`,"data-testid":`${i}-error`,children:d}),c&&!d&&e.jsx("span",{id:y,className:"radio__helper","data-cy":`${t}-helper`,"data-testid":`${i}-helper`,children:c})]})});$.displayName="Radio";exports.Radio=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),a=require("./index17.cjs");;/* empty css */const d=r.forwardRef(({label:d,error:i,helperText:t,className:s,id:l,required:c,disabled:o,checked:n,"data-cy":p,"data-testid":u,...b},h)=>{const x=r.useId(),y=l||x,_=`${y}-error`,m=`${y}-helper`,$=p||"radio",j=u||"radio",N=r.useRef(null),f=r.useCallback(e=>{N.current=e,h&&("function"==typeof h?h(e):"current"in h&&(h.current=e))},[h]),q=d&&c&&!d.includes("*")?`${d} *`:d;return e.jsxs("div",{className:a.cn("radio-wrapper",o&&"radio-wrapper--disabled"),"data-cy":`${$}-wrapper`,"data-testid":`${j}-wrapper`,children:[e.jsxs("div",{className:"radio__container",children:[e.jsx("input",{ref:f,id:y,type:"radio",checked:n,className:a.cn("radio__input",i&&"radio__input--error",s),"aria-describedby":i?_:t?m:void 0,"data-cy":$,"data-testid":j,disabled:o,required:c,...b}),d&&e.jsx("label",{htmlFor:y,className:"radio__label","data-cy":`${$}-label`,"data-testid":`${j}-label`,children:q})]}),i&&e.jsx("span",{id:_,className:"radio__error",role:"alert","data-cy":`${$}-error`,"data-testid":`${j}-error`,children:i}),t&&!i&&e.jsx("span",{id:m,className:"radio__helper","data-cy":`${$}-helper`,"data-testid":`${j}-helper`,children:t})]})});d.displayName="Radio",exports.Radio=d;