@adam-milo/ui 1.0.32 → 1.0.34

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 (152) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +58 -22
  3. package/dist/index10.cjs +1 -1
  4. package/dist/index10.js +94 -56
  5. package/dist/index11.cjs +1 -1
  6. package/dist/index11.js +199 -40
  7. package/dist/index12.cjs +1 -1
  8. package/dist/index12.js +305 -105
  9. package/dist/index13.cjs +1 -1
  10. package/dist/index13.js +260 -74
  11. package/dist/index14.cjs +1 -1
  12. package/dist/index14.js +135 -27
  13. package/dist/index15.cjs +1 -1
  14. package/dist/index15.js +52 -469
  15. package/dist/index16.cjs +1 -1
  16. package/dist/index16.js +57 -111
  17. package/dist/index17.cjs +1 -1
  18. package/dist/index17.js +101 -20
  19. package/dist/index18.cjs +1 -1
  20. package/dist/index18.js +76 -21
  21. package/dist/index19.cjs +1 -1
  22. package/dist/index19.js +25 -29
  23. package/dist/index2.cjs +1 -1
  24. package/dist/index2.js +6 -4
  25. package/dist/index20.cjs +1 -1
  26. package/dist/index20.js +468 -31
  27. package/dist/index21.cjs +1 -1
  28. package/dist/index21.js +155 -41
  29. package/dist/index22.cjs +1 -1
  30. package/dist/index22.js +42 -12
  31. package/dist/index23.cjs +1 -0
  32. package/dist/index23.js +38 -0
  33. package/dist/index24.cjs +1 -1
  34. package/dist/index24.js +32 -287
  35. package/dist/index25.cjs +1 -1
  36. package/dist/index25.js +115 -13
  37. package/dist/index26.cjs +1 -0
  38. package/dist/index26.js +55 -0
  39. package/dist/index27.cjs +1 -0
  40. package/dist/index27.js +45 -0
  41. package/dist/index28.cjs +1 -0
  42. package/dist/index28.js +53 -0
  43. package/dist/index29.cjs +1 -0
  44. package/dist/index29.js +55 -0
  45. package/dist/index3.cjs +1 -1
  46. package/dist/index3.js +33 -33
  47. package/dist/index30.cjs +1 -0
  48. package/dist/index30.js +72 -0
  49. package/dist/index31.cjs +1 -0
  50. package/dist/index31.js +14 -0
  51. package/dist/index32.cjs +1 -0
  52. package/dist/index32.js +332 -0
  53. package/dist/index36.cjs +1 -0
  54. package/dist/index36.js +386 -0
  55. package/dist/index37.cjs +1 -0
  56. package/dist/index37.js +16 -0
  57. package/dist/index4.cjs +1 -1
  58. package/dist/index4.js +59 -11
  59. package/dist/index5.cjs +1 -1
  60. package/dist/index5.js +19 -35
  61. package/dist/index6.cjs +1 -1
  62. package/dist/index6.js +11 -101
  63. package/dist/index62.cjs +1 -0
  64. package/dist/index62.js +502 -0
  65. package/dist/index64.cjs +1 -0
  66. package/dist/index64.js +11 -0
  67. package/dist/index65.cjs +1 -0
  68. package/dist/index65.js +39 -0
  69. package/dist/index66.cjs +1 -0
  70. package/dist/index66.js +64 -0
  71. package/dist/index67.cjs +1 -0
  72. package/dist/index67.js +212 -0
  73. package/dist/index68.cjs +1 -0
  74. package/dist/index68.js +14 -0
  75. package/dist/index69.cjs +1 -0
  76. package/dist/index69.js +293 -0
  77. package/dist/index7.cjs +1 -1
  78. package/dist/index7.js +46 -97
  79. package/dist/index70.cjs +1 -0
  80. package/dist/index70.js +18 -0
  81. package/dist/index71.cjs +1 -0
  82. package/dist/index71.js +129 -0
  83. package/dist/index72.cjs +1 -0
  84. package/dist/index72.js +43 -0
  85. package/dist/index73.cjs +1 -0
  86. package/dist/index73.js +99 -0
  87. package/dist/index74.cjs +1 -0
  88. package/dist/index74.js +71 -0
  89. package/dist/index75.cjs +1 -0
  90. package/dist/index75.js +36 -0
  91. package/dist/index76.cjs +1 -0
  92. package/dist/index76.js +14 -0
  93. package/dist/index77.cjs +1 -0
  94. package/dist/index77.js +17 -0
  95. package/dist/index78.cjs +1 -0
  96. package/dist/index78.js +6 -0
  97. package/dist/index79.cjs +1 -0
  98. package/dist/index79.js +297 -0
  99. package/dist/index8.cjs +1 -1
  100. package/dist/index8.js +97 -88
  101. package/dist/index80.cjs +1 -0
  102. package/dist/index80.js +25 -0
  103. package/dist/index81.cjs +1 -0
  104. package/dist/index81.js +39 -0
  105. package/dist/index82.cjs +1 -0
  106. package/dist/index82.js +625 -0
  107. package/dist/index83.cjs +1 -0
  108. package/dist/index83.js +721 -0
  109. package/dist/index84.cjs +1 -0
  110. package/dist/index84.js +154 -0
  111. package/dist/index85.cjs +1 -0
  112. package/dist/index85.js +173 -0
  113. package/dist/index9.cjs +1 -1
  114. package/dist/index9.js +55 -197
  115. package/dist/src/components/core/button/Button.component.d.ts +13 -7
  116. package/dist/src/components/core/button/Button.component.d.ts.map +1 -1
  117. package/dist/src/components/core/icon/Icon.component.d.ts +1 -1
  118. package/dist/src/components/core/icon/Icon.component.d.ts.map +1 -1
  119. package/dist/src/components/core/icon-button/IconButton.component.d.ts +36 -0
  120. package/dist/src/components/core/icon-button/IconButton.component.d.ts.map +1 -0
  121. package/dist/src/components/core/menu-icon-button/MenuIconButton.component.d.ts +79 -0
  122. package/dist/src/components/core/menu-icon-button/MenuIconButton.component.d.ts.map +1 -0
  123. package/dist/src/components/feedback/spinner/Spinner.component.d.ts +62 -0
  124. package/dist/src/components/feedback/spinner/Spinner.component.d.ts.map +1 -0
  125. package/dist/src/components/forms/input/Input.component.d.ts +5 -0
  126. package/dist/src/components/forms/input/Input.component.d.ts.map +1 -1
  127. package/dist/src/components/forms/otp-input/OTPInput.component.d.ts +82 -0
  128. package/dist/src/components/forms/otp-input/OTPInput.component.d.ts.map +1 -0
  129. package/dist/src/components/forms/phone-input/PhoneInput.component.d.ts +96 -0
  130. package/dist/src/components/forms/phone-input/PhoneInput.component.d.ts.map +1 -0
  131. package/dist/src/components/forms/phone-input/countries.d.ts +93 -0
  132. package/dist/src/components/forms/phone-input/countries.d.ts.map +1 -0
  133. package/dist/src/components/forms/select/Select.component.d.ts +5 -1
  134. package/dist/src/components/forms/select/Select.component.d.ts.map +1 -1
  135. package/dist/src/components/forms/toggle/Toggle.component.d.ts +80 -0
  136. package/dist/src/components/forms/toggle/Toggle.component.d.ts.map +1 -0
  137. package/dist/src/components/layout/auth-layout/AuthLayout.component.d.ts +86 -0
  138. package/dist/src/components/layout/auth-layout/AuthLayout.component.d.ts.map +1 -0
  139. package/dist/src/components/overlays/dialog/Dialog.component.d.ts +36 -2
  140. package/dist/src/components/overlays/dialog/Dialog.component.d.ts.map +1 -1
  141. package/dist/src/components/typography/heading/Heading.component.d.ts +92 -0
  142. package/dist/src/components/typography/heading/Heading.component.d.ts.map +1 -0
  143. package/dist/src/components/typography/link/Link.component.d.ts +80 -0
  144. package/dist/src/components/typography/link/Link.component.d.ts.map +1 -0
  145. package/dist/src/index.d.ts +24 -5
  146. package/dist/src/index.d.ts.map +1 -1
  147. package/dist/style.css +1 -1
  148. package/package.json +2 -1
  149. /package/dist/{index35.cjs → index50.cjs} +0 -0
  150. /package/dist/{index35.js → index50.js} +0 -0
  151. /package/dist/{index42.cjs → index61.cjs} +0 -0
  152. /package/dist/{index42.js → index61.js} +0 -0
package/dist/index21.js CHANGED
@@ -1,55 +1,169 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
- import { cn } from "./index22.js";
3
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
4
+ import { cn } from "./index31.js";
4
5
  /* empty css */
5
- const Grid = forwardRef(
6
- ({
7
- columns = 3,
8
- rows,
9
- gap = "4",
10
- rowGap,
11
- columnGap,
12
- align = "stretch",
13
- justify = "stretch",
14
- autoFitMinWidth = "15rem",
15
- className,
16
- children,
17
- style,
18
- "data-cy": dataCy,
19
- "data-testid": dataTestId,
20
- ...props
21
- }, ref) => {
22
- const finalDataCy = dataCy || `grid-${columns}col`;
23
- const finalTestId = dataTestId || `grid-${columns}col`;
24
- const customStyle = {
25
- ...style,
26
- ...columns === "auto" && { "--grid-auto-fit-min": autoFitMinWidth }
27
- };
28
- return /* @__PURE__ */ jsx(
29
- "div",
6
+ import { Icon } from "@adam-milo/icons";
7
+ const Dialog = DialogPrimitive.Root;
8
+ const DialogTrigger = DialogPrimitive.Trigger;
9
+ const DialogPortal = DialogPrimitive.Portal;
10
+ const DialogClose = DialogPrimitive.Close;
11
+ const DialogCloseButton = forwardRef(({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
12
+ const finalDataCy = dataCy || "dialog-close-button";
13
+ const finalTestId = dataTestId || "dialog-close-button";
14
+ return /* @__PURE__ */ jsx(
15
+ DialogPrimitive.Close,
16
+ {
17
+ ref,
18
+ className: cn("dialog-close-button", className),
19
+ "data-cy": finalDataCy,
20
+ "data-testid": finalTestId,
21
+ "aria-label": "Close dialog",
22
+ ...props,
23
+ children: /* @__PURE__ */ jsx(Icon, { name: "Cross2Icon", size: "sm", decorative: true })
24
+ }
25
+ );
26
+ });
27
+ DialogCloseButton.displayName = "DialogCloseButton";
28
+ const DialogIcon = ({
29
+ children,
30
+ variant = "default",
31
+ className,
32
+ "data-cy": dataCy,
33
+ "data-testid": dataTestId,
34
+ ...props
35
+ }) => {
36
+ const finalDataCy = dataCy || "dialog-icon";
37
+ const finalTestId = dataTestId || "dialog-icon";
38
+ return /* @__PURE__ */ jsx(
39
+ "div",
40
+ {
41
+ className: cn("dialog-icon", `dialog-icon--${variant}`, className),
42
+ "data-cy": finalDataCy,
43
+ "data-testid": finalTestId,
44
+ "aria-hidden": "true",
45
+ ...props,
46
+ children
47
+ }
48
+ );
49
+ };
50
+ DialogIcon.displayName = "DialogIcon";
51
+ const DialogOverlay = forwardRef(({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
52
+ const finalDataCy = dataCy || "dialog-overlay";
53
+ const finalTestId = dataTestId || "dialog-overlay";
54
+ return /* @__PURE__ */ jsx(
55
+ DialogPrimitive.Overlay,
56
+ {
57
+ ref,
58
+ className: cn("dialog-overlay", className),
59
+ "data-cy": finalDataCy,
60
+ "data-testid": finalTestId,
61
+ ...props
62
+ }
63
+ );
64
+ });
65
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
66
+ const DialogContent = forwardRef(({ className, children, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
67
+ const finalDataCy = dataCy || "dialog-content";
68
+ const finalTestId = dataTestId || "dialog-content";
69
+ return /* @__PURE__ */ jsxs(DialogPortal, { children: [
70
+ /* @__PURE__ */ jsx(DialogOverlay, {}),
71
+ /* @__PURE__ */ jsx(
72
+ DialogPrimitive.Content,
30
73
  {
31
74
  ref,
32
- className: cn(
33
- "grid",
34
- `grid--columns-${columns}`,
35
- rows && `grid--rows-${rows}`,
36
- `grid--gap-${gap}`,
37
- rowGap && `grid--row-gap-${rowGap}`,
38
- columnGap && `grid--column-gap-${columnGap}`,
39
- `grid--align-${align}`,
40
- `grid--justify-${justify}`,
41
- className
42
- ),
43
- style: customStyle,
75
+ className: cn("dialog-content", className),
44
76
  "data-cy": finalDataCy,
45
77
  "data-testid": finalTestId,
46
78
  ...props,
47
79
  children
48
80
  }
81
+ )
82
+ ] });
83
+ });
84
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
85
+ const DialogHeader = ({
86
+ centered = false,
87
+ className,
88
+ "data-cy": dataCy,
89
+ "data-testid": dataTestId,
90
+ ...props
91
+ }) => {
92
+ const finalDataCy = dataCy || "dialog-header";
93
+ const finalTestId = dataTestId || "dialog-header";
94
+ return /* @__PURE__ */ jsx(
95
+ "div",
96
+ {
97
+ className: cn("dialog-header", centered && "dialog-header--centered", className),
98
+ "data-cy": finalDataCy,
99
+ "data-testid": finalTestId,
100
+ ...props
101
+ }
102
+ );
103
+ };
104
+ DialogHeader.displayName = "DialogHeader";
105
+ const DialogFooter = ({
106
+ className,
107
+ "data-cy": dataCy,
108
+ "data-testid": dataTestId,
109
+ ...props
110
+ }) => {
111
+ const finalDataCy = dataCy || "dialog-footer";
112
+ const finalTestId = dataTestId || "dialog-footer";
113
+ return /* @__PURE__ */ jsx(
114
+ "div",
115
+ {
116
+ className: cn("dialog-footer", className),
117
+ "data-cy": finalDataCy,
118
+ "data-testid": finalTestId,
119
+ ...props
120
+ }
121
+ );
122
+ };
123
+ DialogFooter.displayName = "DialogFooter";
124
+ const DialogTitle = forwardRef(
125
+ ({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
126
+ const finalDataCy = dataCy || "dialog-title";
127
+ const finalTestId = dataTestId || "dialog-title";
128
+ return /* @__PURE__ */ jsx(
129
+ DialogPrimitive.Title,
130
+ {
131
+ ref,
132
+ className: cn("dialog-title", className),
133
+ "data-cy": finalDataCy,
134
+ "data-testid": finalTestId,
135
+ ...props
136
+ }
49
137
  );
50
138
  }
51
139
  );
52
- Grid.displayName = "Grid";
140
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
141
+ const DialogDescription = forwardRef(({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
142
+ const finalDataCy = dataCy || "dialog-description";
143
+ const finalTestId = dataTestId || "dialog-description";
144
+ return /* @__PURE__ */ jsx(
145
+ DialogPrimitive.Description,
146
+ {
147
+ ref,
148
+ className: cn("dialog-description", className),
149
+ "data-cy": finalDataCy,
150
+ "data-testid": finalTestId,
151
+ ...props
152
+ }
153
+ );
154
+ });
155
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
53
156
  export {
54
- Grid
157
+ Dialog,
158
+ DialogClose,
159
+ DialogCloseButton,
160
+ DialogContent,
161
+ DialogDescription,
162
+ DialogFooter,
163
+ DialogHeader,
164
+ DialogIcon,
165
+ DialogOverlay,
166
+ DialogPortal,
167
+ DialogTitle,
168
+ DialogTrigger
55
169
  };
package/dist/index22.cjs CHANGED
@@ -1 +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}`};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),e=require("./index31.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/index22.js CHANGED
@@ -1,14 +1,44 @@
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
- }
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { cn } from "./index31.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
- cn,
13
- generateId
43
+ Stack
14
44
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),r=require("./index31.cjs");;/* empty css */const a=t.forwardRef(({className:t,maxWidth:a="lg",padding:n="md","data-cy":i,"data-testid":d,children:c,...s},o)=>{const l=i||"container",u=d||"container";return e.jsx("div",{ref:o,className:r.cn("container",`container--max-width-${a}`,`container--padding-${n}`,t),"data-cy":l,"data-testid":u,...s,children:c})});a.displayName="Container",exports.Container=a;
@@ -0,0 +1,38 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { cn } from "./index31.js";
4
+ /* empty css */
5
+ const Container = forwardRef(
6
+ ({
7
+ className,
8
+ maxWidth = "lg",
9
+ padding = "md",
10
+ "data-cy": dataCy,
11
+ "data-testid": dataTestId,
12
+ children,
13
+ ...props
14
+ }, ref) => {
15
+ const finalDataCy = dataCy || "container";
16
+ const finalTestId = dataTestId || "container";
17
+ return /* @__PURE__ */ jsx(
18
+ "div",
19
+ {
20
+ ref,
21
+ className: cn(
22
+ "container",
23
+ `container--max-width-${maxWidth}`,
24
+ `container--padding-${padding}`,
25
+ className
26
+ ),
27
+ "data-cy": finalDataCy,
28
+ "data-testid": finalTestId,
29
+ ...props,
30
+ children
31
+ }
32
+ );
33
+ }
34
+ );
35
+ Container.displayName = "Container";
36
+ export {
37
+ Container
38
+ };
package/dist/index24.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),t=require("./index22.cjs");;/* empty css */const a=require("./index25.cjs"),s=require("./index42.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),t=require("@radix-ui/react-separator"),i=require("./index31.cjs");function a(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const t in e)if("default"!==t){const i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:()=>e[t]})}return r.default=e,Object.freeze(r)};/* empty css */const o=a(t),d=r.forwardRef(({orientation:r="horizontal",decorative:t=!0,spacing:a="0",color:d,className:c,style:n,"data-cy":s,"data-testid":u,...l},f)=>{const v=s||`divider-${r}`,g=u||`divider-${r}`;return e.jsx(o.Root,{ref:f,decorative:t,orientation:r,className:i.cn("divider",`divider--${r}`,`divider--spacing-${a}`,c),style:{...d&&{backgroundColor:d},...n},"data-cy":v,"data-testid":g,...l})});d.displayName="Divider",exports.Divider=d;
package/dist/index24.js CHANGED
@@ -1,301 +1,46 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { forwardRef, useState, useRef, useId, useMemo, useEffect } from "react";
3
- import { cn } from "./index22.js";
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
4
+ import { cn } from "./index31.js";
4
5
  /* empty css */
5
- import { useMergedRef } from "./index25.js";
6
- import { debounce } from "./index42.js";
7
- const Input = forwardRef(
6
+ const Divider = forwardRef(
8
7
  ({
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,
8
+ orientation = "horizontal",
9
+ decorative = true,
10
+ spacing = "0",
11
+ color,
19
12
  className,
20
- id: providedId,
21
- onChange,
22
- onBlur,
23
- required,
24
- value: controlledValue,
13
+ style,
25
14
  "data-cy": dataCy,
26
15
  "data-testid": dataTestId,
27
16
  ...props
28
17
  }, 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",
18
+ const finalDataCy = dataCy || `divider-${orientation}`;
19
+ const finalTestId = dataTestId || `divider-${orientation}`;
20
+ return /* @__PURE__ */ jsx(
21
+ SeparatorPrimitive.Root,
137
22
  {
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
- ]
23
+ ref,
24
+ decorative,
25
+ orientation,
26
+ className: cn(
27
+ "divider",
28
+ `divider--${orientation}`,
29
+ `divider--spacing-${spacing}`,
30
+ className
31
+ ),
32
+ style: {
33
+ ...color && { backgroundColor: color },
34
+ ...style
35
+ },
36
+ "data-cy": finalDataCy,
37
+ "data-testid": finalTestId,
38
+ ...props
294
39
  }
295
40
  );
296
41
  }
297
42
  );
298
- Input.displayName = "Input";
43
+ Divider.displayName = "Divider";
299
44
  export {
300
- Input
45
+ Divider
301
46
  };