@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
@@ -0,0 +1,297 @@
1
+ import { computePosition, offset as offset$1, shift as shift$1, flip as flip$1, size as size$1, hide as hide$1, limitShift as limitShift$1, arrow as arrow$2 } from "./index82.js";
2
+ import { autoUpdate, platform } from "./index82.js";
3
+ import * as React from "react";
4
+ import { useLayoutEffect } from "react";
5
+ import * as ReactDOM from "react-dom";
6
+ var isClient = typeof document !== "undefined";
7
+ var noop = function noop2() {
8
+ };
9
+ var index = isClient ? useLayoutEffect : noop;
10
+ function deepEqual(a, b) {
11
+ if (a === b) {
12
+ return true;
13
+ }
14
+ if (typeof a !== typeof b) {
15
+ return false;
16
+ }
17
+ if (typeof a === "function" && a.toString() === b.toString()) {
18
+ return true;
19
+ }
20
+ let length;
21
+ let i;
22
+ let keys;
23
+ if (a && b && typeof a === "object") {
24
+ if (Array.isArray(a)) {
25
+ length = a.length;
26
+ if (length !== b.length) return false;
27
+ for (i = length; i-- !== 0; ) {
28
+ if (!deepEqual(a[i], b[i])) {
29
+ return false;
30
+ }
31
+ }
32
+ return true;
33
+ }
34
+ keys = Object.keys(a);
35
+ length = keys.length;
36
+ if (length !== Object.keys(b).length) {
37
+ return false;
38
+ }
39
+ for (i = length; i-- !== 0; ) {
40
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
41
+ return false;
42
+ }
43
+ }
44
+ for (i = length; i-- !== 0; ) {
45
+ const key = keys[i];
46
+ if (key === "_owner" && a.$$typeof) {
47
+ continue;
48
+ }
49
+ if (!deepEqual(a[key], b[key])) {
50
+ return false;
51
+ }
52
+ }
53
+ return true;
54
+ }
55
+ return a !== a && b !== b;
56
+ }
57
+ function getDPR(element) {
58
+ if (typeof window === "undefined") {
59
+ return 1;
60
+ }
61
+ const win = element.ownerDocument.defaultView || window;
62
+ return win.devicePixelRatio || 1;
63
+ }
64
+ function roundByDPR(element, value) {
65
+ const dpr = getDPR(element);
66
+ return Math.round(value * dpr) / dpr;
67
+ }
68
+ function useLatestRef(value) {
69
+ const ref = React.useRef(value);
70
+ index(() => {
71
+ ref.current = value;
72
+ });
73
+ return ref;
74
+ }
75
+ function useFloating(options) {
76
+ if (options === void 0) {
77
+ options = {};
78
+ }
79
+ const {
80
+ placement = "bottom",
81
+ strategy = "absolute",
82
+ middleware = [],
83
+ platform: platform2,
84
+ elements: {
85
+ reference: externalReference,
86
+ floating: externalFloating
87
+ } = {},
88
+ transform = true,
89
+ whileElementsMounted,
90
+ open
91
+ } = options;
92
+ const [data, setData] = React.useState({
93
+ x: 0,
94
+ y: 0,
95
+ strategy,
96
+ placement,
97
+ middlewareData: {},
98
+ isPositioned: false
99
+ });
100
+ const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
101
+ if (!deepEqual(latestMiddleware, middleware)) {
102
+ setLatestMiddleware(middleware);
103
+ }
104
+ const [_reference, _setReference] = React.useState(null);
105
+ const [_floating, _setFloating] = React.useState(null);
106
+ const setReference = React.useCallback((node) => {
107
+ if (node !== referenceRef.current) {
108
+ referenceRef.current = node;
109
+ _setReference(node);
110
+ }
111
+ }, []);
112
+ const setFloating = React.useCallback((node) => {
113
+ if (node !== floatingRef.current) {
114
+ floatingRef.current = node;
115
+ _setFloating(node);
116
+ }
117
+ }, []);
118
+ const referenceEl = externalReference || _reference;
119
+ const floatingEl = externalFloating || _floating;
120
+ const referenceRef = React.useRef(null);
121
+ const floatingRef = React.useRef(null);
122
+ const dataRef = React.useRef(data);
123
+ const hasWhileElementsMounted = whileElementsMounted != null;
124
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
125
+ const platformRef = useLatestRef(platform2);
126
+ const openRef = useLatestRef(open);
127
+ const update = React.useCallback(() => {
128
+ if (!referenceRef.current || !floatingRef.current) {
129
+ return;
130
+ }
131
+ const config = {
132
+ placement,
133
+ strategy,
134
+ middleware: latestMiddleware
135
+ };
136
+ if (platformRef.current) {
137
+ config.platform = platformRef.current;
138
+ }
139
+ computePosition(referenceRef.current, floatingRef.current, config).then((data2) => {
140
+ const fullData = {
141
+ ...data2,
142
+ // The floating element's position may be recomputed while it's closed
143
+ // but still mounted (such as when transitioning out). To ensure
144
+ // `isPositioned` will be `false` initially on the next open, avoid
145
+ // setting it to `true` when `open === false` (must be specified).
146
+ isPositioned: openRef.current !== false
147
+ };
148
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
149
+ dataRef.current = fullData;
150
+ ReactDOM.flushSync(() => {
151
+ setData(fullData);
152
+ });
153
+ }
154
+ });
155
+ }, [latestMiddleware, placement, strategy, platformRef, openRef]);
156
+ index(() => {
157
+ if (open === false && dataRef.current.isPositioned) {
158
+ dataRef.current.isPositioned = false;
159
+ setData((data2) => ({
160
+ ...data2,
161
+ isPositioned: false
162
+ }));
163
+ }
164
+ }, [open]);
165
+ const isMountedRef = React.useRef(false);
166
+ index(() => {
167
+ isMountedRef.current = true;
168
+ return () => {
169
+ isMountedRef.current = false;
170
+ };
171
+ }, []);
172
+ index(() => {
173
+ if (referenceEl) referenceRef.current = referenceEl;
174
+ if (floatingEl) floatingRef.current = floatingEl;
175
+ if (referenceEl && floatingEl) {
176
+ if (whileElementsMountedRef.current) {
177
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
178
+ }
179
+ update();
180
+ }
181
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
182
+ const refs = React.useMemo(() => ({
183
+ reference: referenceRef,
184
+ floating: floatingRef,
185
+ setReference,
186
+ setFloating
187
+ }), [setReference, setFloating]);
188
+ const elements = React.useMemo(() => ({
189
+ reference: referenceEl,
190
+ floating: floatingEl
191
+ }), [referenceEl, floatingEl]);
192
+ const floatingStyles = React.useMemo(() => {
193
+ const initialStyles = {
194
+ position: strategy,
195
+ left: 0,
196
+ top: 0
197
+ };
198
+ if (!elements.floating) {
199
+ return initialStyles;
200
+ }
201
+ const x = roundByDPR(elements.floating, data.x);
202
+ const y = roundByDPR(elements.floating, data.y);
203
+ if (transform) {
204
+ return {
205
+ ...initialStyles,
206
+ transform: "translate(" + x + "px, " + y + "px)",
207
+ ...getDPR(elements.floating) >= 1.5 && {
208
+ willChange: "transform"
209
+ }
210
+ };
211
+ }
212
+ return {
213
+ position: strategy,
214
+ left: x,
215
+ top: y
216
+ };
217
+ }, [strategy, transform, elements.floating, data.x, data.y]);
218
+ return React.useMemo(() => ({
219
+ ...data,
220
+ update,
221
+ refs,
222
+ elements,
223
+ floatingStyles
224
+ }), [data, update, refs, elements, floatingStyles]);
225
+ }
226
+ const arrow$1 = (options) => {
227
+ function isRef(value) {
228
+ return {}.hasOwnProperty.call(value, "current");
229
+ }
230
+ return {
231
+ name: "arrow",
232
+ options,
233
+ fn(state) {
234
+ const {
235
+ element,
236
+ padding
237
+ } = typeof options === "function" ? options(state) : options;
238
+ if (element && isRef(element)) {
239
+ if (element.current != null) {
240
+ return arrow$2({
241
+ element: element.current,
242
+ padding
243
+ }).fn(state);
244
+ }
245
+ return {};
246
+ }
247
+ if (element) {
248
+ return arrow$2({
249
+ element,
250
+ padding
251
+ }).fn(state);
252
+ }
253
+ return {};
254
+ }
255
+ };
256
+ };
257
+ const offset = (options, deps) => ({
258
+ ...offset$1(options),
259
+ options: [options, deps]
260
+ });
261
+ const shift = (options, deps) => ({
262
+ ...shift$1(options),
263
+ options: [options, deps]
264
+ });
265
+ const limitShift = (options, deps) => ({
266
+ ...limitShift$1(options),
267
+ options: [options, deps]
268
+ });
269
+ const flip = (options, deps) => ({
270
+ ...flip$1(options),
271
+ options: [options, deps]
272
+ });
273
+ const size = (options, deps) => ({
274
+ ...size$1(options),
275
+ options: [options, deps]
276
+ });
277
+ const hide = (options, deps) => ({
278
+ ...hide$1(options),
279
+ options: [options, deps]
280
+ });
281
+ const arrow = (options, deps) => ({
282
+ ...arrow$1(options),
283
+ options: [options, deps]
284
+ });
285
+ export {
286
+ arrow,
287
+ autoUpdate,
288
+ computePosition,
289
+ flip,
290
+ hide,
291
+ limitShift,
292
+ offset,
293
+ platform,
294
+ shift,
295
+ size,
296
+ useFloating
297
+ };
package/dist/index8.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),a=require("./index22.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),a=require("./index36.cjs"),n=require("./index37.cjs"),l=t.forwardRef(({allowHyphen:l=!1,allowUnderscore:r=!1,allowSpace:s=!1,minLength:u,maxLength:i,validate:c,onChange:o,"data-cy":p,"data-testid":d,...h},g)=>{const m=t.useRef(null),f=n.useMergedRef(g,m),v=t.useMemo(()=>{let e="^[a-zA-Z0-9";return l&&(e+="\\-"),r&&(e+="_"),s&&(e+=" "),e+="]*$",new RegExp(e)},[l,r,s]),x=t.useMemo(()=>{let e="[a-zA-Z0-9";return l&&(e+="\\-"),r&&(e+="_"),s&&(e+=" "),e+="]",new RegExp(e)},[l,r,s]),y=t.useCallback(e=>{if(e){if(!v.test(e)){let e="letters and numbers";const t=[];return l&&t.push("hyphens"),r&&t.push("underscores"),s&&t.push("spaces"),t.length>0&&(e+=`, ${t.join(", ")}`),`Only ${e} are allowed`}return void 0!==u&&e.length<u?`Must be at least ${u} characters`:void 0!==i&&e.length>i?`Must be at most ${i} characters`:void 0}},[v,u,i,l,r,s]),b=t.useCallback(e=>c?y(e)||c(e):y(e),[y,c]),[j,w]=t.useState(null);t.useEffect(()=>{null!==j&&m.current&&(m.current.setSelectionRange(j,j),w(null))},[h.value,j]);const R=t.useCallback(e=>{const t=e.target,a=t.value,n=t.selectionStart||0,l=a.split("").filter(e=>x.test(e)).join(""),r=n-a.slice(0,n).split("").filter(e=>!x.test(e)).length;t.value=l;void 0!==h.value?w(r):t.setSelectionRange(r,r),null==o||o(e)},[x,o,h.value]);return e.jsx(a.Input,{ref:f,type:"text",minLength:u,maxLength:i,validate:b,onChange:R,"data-cy":p||"alphanumeric-input","data-testid":d||"alphanumeric-input",...h})});l.displayName="AlphanumericInput",exports.AlphanumericInput=l;
package/dist/index8.js CHANGED
@@ -1,103 +1,112 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { forwardRef, useId, useRef, useCallback } from "react";
3
- import { cn } from "./index22.js";
4
- /* empty css */
5
- const Radio = forwardRef(
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useRef, useMemo, useCallback, useState, useEffect } from "react";
3
+ import { Input } from "./index36.js";
4
+ import { useMergedRef } from "./index37.js";
5
+ const AlphanumericInput = forwardRef(
6
6
  ({
7
- label,
8
- error,
9
- helperText,
10
- className,
11
- id: providedId,
12
- required,
13
- disabled,
14
- checked,
7
+ allowHyphen = false,
8
+ allowUnderscore = false,
9
+ allowSpace = false,
10
+ minLength,
11
+ maxLength,
12
+ validate,
13
+ onChange,
15
14
  "data-cy": dataCy,
16
15
  "data-testid": dataTestId,
17
16
  ...props
18
17
  }, ref) => {
19
- const generatedId = useId();
20
- const id = providedId || generatedId;
21
- const errorId = `${id}-error`;
22
- const helperId = `${id}-helper`;
23
- const finalDataCy = dataCy || "radio";
24
- const finalTestId = dataTestId || "radio";
25
- const internalRef = useRef(null);
26
- const combinedRef = useCallback(
27
- (element) => {
28
- internalRef.current = element;
29
- if (!ref) return;
30
- if (typeof ref === "function") {
31
- ref(element);
32
- } else if ("current" in ref) {
33
- ref.current = element;
18
+ const inputRef = useRef(null);
19
+ const mergedRef = useMergedRef(ref, inputRef);
20
+ const alphanumericRegex = useMemo(() => {
21
+ let pattern = "^[a-zA-Z0-9";
22
+ if (allowHyphen) pattern += "\\-";
23
+ if (allowUnderscore) pattern += "_";
24
+ if (allowSpace) pattern += " ";
25
+ pattern += "]*$";
26
+ return new RegExp(pattern);
27
+ }, [allowHyphen, allowUnderscore, allowSpace]);
28
+ const characterRegex = useMemo(() => {
29
+ let pattern = "[a-zA-Z0-9";
30
+ if (allowHyphen) pattern += "\\-";
31
+ if (allowUnderscore) pattern += "_";
32
+ if (allowSpace) pattern += " ";
33
+ pattern += "]";
34
+ return new RegExp(pattern);
35
+ }, [allowHyphen, allowUnderscore, allowSpace]);
36
+ const alphanumericValidation = useCallback(
37
+ (value) => {
38
+ if (!value) return void 0;
39
+ if (!alphanumericRegex.test(value)) {
40
+ let allowedChars = "letters and numbers";
41
+ const extras = [];
42
+ if (allowHyphen) extras.push("hyphens");
43
+ if (allowUnderscore) extras.push("underscores");
44
+ if (allowSpace) extras.push("spaces");
45
+ if (extras.length > 0) {
46
+ allowedChars += `, ${extras.join(", ")}`;
47
+ }
48
+ return `Only ${allowedChars} are allowed`;
34
49
  }
50
+ if (minLength !== void 0 && value.length < minLength) {
51
+ return `Must be at least ${minLength} characters`;
52
+ }
53
+ if (maxLength !== void 0 && value.length > maxLength) {
54
+ return `Must be at most ${maxLength} characters`;
55
+ }
56
+ return void 0;
57
+ },
58
+ [alphanumericRegex, minLength, maxLength, allowHyphen, allowUnderscore, allowSpace]
59
+ );
60
+ const combinedValidation = useCallback(
61
+ (value) => {
62
+ if (!validate) return alphanumericValidation(value);
63
+ return alphanumericValidation(value) || validate(value);
64
+ },
65
+ [alphanumericValidation, validate]
66
+ );
67
+ const [pendingCursorPosition, setPendingCursorPosition] = useState(null);
68
+ useEffect(() => {
69
+ if (pendingCursorPosition !== null && inputRef.current) {
70
+ inputRef.current.setSelectionRange(pendingCursorPosition, pendingCursorPosition);
71
+ setPendingCursorPosition(null);
72
+ }
73
+ }, [props.value, pendingCursorPosition]);
74
+ const handleChange = useCallback(
75
+ (e) => {
76
+ const input = e.target;
77
+ const value = input.value;
78
+ const cursorPosition = input.selectionStart || 0;
79
+ const filteredValue = value.split("").filter((char) => characterRegex.test(char)).join("");
80
+ const removedBeforeCursor = value.slice(0, cursorPosition).split("").filter((char) => !characterRegex.test(char)).length;
81
+ const newPosition = cursorPosition - removedBeforeCursor;
82
+ input.value = filteredValue;
83
+ const isControlled = props.value !== void 0;
84
+ if (isControlled) {
85
+ setPendingCursorPosition(newPosition);
86
+ } else {
87
+ input.setSelectionRange(newPosition, newPosition);
88
+ }
89
+ onChange == null ? void 0 : onChange(e);
35
90
  },
36
- [ref]
91
+ [characterRegex, onChange, props.value]
37
92
  );
38
- const displayLabel = label && required && !label.includes("*") ? `${label} *` : label;
39
- return /* @__PURE__ */ jsxs(
40
- "div",
93
+ return /* @__PURE__ */ jsx(
94
+ Input,
41
95
  {
42
- className: cn("radio-wrapper", disabled && "radio-wrapper--disabled"),
43
- "data-cy": `${finalDataCy}-wrapper`,
44
- "data-testid": `${finalTestId}-wrapper`,
45
- children: [
46
- /* @__PURE__ */ jsxs("div", { className: "radio__container", children: [
47
- /* @__PURE__ */ jsx(
48
- "input",
49
- {
50
- ref: combinedRef,
51
- id,
52
- type: "radio",
53
- checked,
54
- className: cn("radio__input", error && "radio__input--error", className),
55
- "aria-describedby": error ? errorId : helperText ? helperId : void 0,
56
- "data-cy": finalDataCy,
57
- "data-testid": finalTestId,
58
- disabled,
59
- required,
60
- ...props
61
- }
62
- ),
63
- label && /* @__PURE__ */ jsx(
64
- "label",
65
- {
66
- htmlFor: id,
67
- className: "radio__label",
68
- "data-cy": `${finalDataCy}-label`,
69
- "data-testid": `${finalTestId}-label`,
70
- children: displayLabel
71
- }
72
- )
73
- ] }),
74
- error && /* @__PURE__ */ jsx(
75
- "span",
76
- {
77
- id: errorId,
78
- className: "radio__error",
79
- role: "alert",
80
- "data-cy": `${finalDataCy}-error`,
81
- "data-testid": `${finalTestId}-error`,
82
- children: error
83
- }
84
- ),
85
- helperText && !error && /* @__PURE__ */ jsx(
86
- "span",
87
- {
88
- id: helperId,
89
- className: "radio__helper",
90
- "data-cy": `${finalDataCy}-helper`,
91
- "data-testid": `${finalTestId}-helper`,
92
- children: helperText
93
- }
94
- )
95
- ]
96
+ ref: mergedRef,
97
+ type: "text",
98
+ minLength,
99
+ maxLength,
100
+ validate: combinedValidation,
101
+ onChange: handleChange,
102
+ "data-cy": dataCy || "alphanumeric-input",
103
+ "data-testid": dataTestId || "alphanumeric-input",
104
+ ...props
96
105
  }
97
106
  );
98
107
  }
99
108
  );
100
- Radio.displayName = "Radio";
109
+ AlphanumericInput.displayName = "AlphanumericInput";
101
110
  export {
102
- Radio
111
+ AlphanumericInput
103
112
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("./index72.cjs"),t=require("react/jsx-runtime");function o(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const t in e)if("default"!==t){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}return r.default=e,Object.freeze(r)}var i=o(e).forwardRef((e,o)=>{const{children:i,width:n=10,height:s=5,...c}=e;return t.jsx(r.Primitive.svg,{...c,ref:o,width:n,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?i:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});i.displayName="Arrow";var n=i;exports.Arrow=i,exports.Root=n;
@@ -0,0 +1,25 @@
1
+ import * as React from "react";
2
+ import { Primitive } from "./index72.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ var NAME = "Arrow";
5
+ var Arrow = React.forwardRef((props, forwardedRef) => {
6
+ const { children, width = 10, height = 5, ...arrowProps } = props;
7
+ return /* @__PURE__ */ jsx(
8
+ Primitive.svg,
9
+ {
10
+ ...arrowProps,
11
+ ref: forwardedRef,
12
+ width,
13
+ height,
14
+ viewBox: "0 0 30 10",
15
+ preserveAspectRatio: "none",
16
+ children: props.asChild ? children : /* @__PURE__ */ jsx("polygon", { points: "0,0 30,0 15,10" })
17
+ }
18
+ );
19
+ });
20
+ Arrow.displayName = NAME;
21
+ var Root = Arrow;
22
+ export {
23
+ Arrow,
24
+ Root
25
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("./index78.cjs");function r(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}const o=r(e);exports.useSize=function(e){const[r,i]=o.useState(void 0);return t.useLayoutEffect(()=>{if(e){i({width:e.offsetWidth,height:e.offsetHeight});const t=new ResizeObserver(t=>{if(!Array.isArray(t))return;if(!t.length)return;const r=t[0];let o,n;if("borderBoxSize"in r){const e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;o=t.inlineSize,n=t.blockSize}else o=e.offsetWidth,n=e.offsetHeight;i({width:o,height:n})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}i(void 0)},[e]),r};
@@ -0,0 +1,39 @@
1
+ import * as React from "react";
2
+ import { useLayoutEffect as useLayoutEffect2 } from "./index78.js";
3
+ function useSize(element) {
4
+ const [size, setSize] = React.useState(void 0);
5
+ useLayoutEffect2(() => {
6
+ if (element) {
7
+ setSize({ width: element.offsetWidth, height: element.offsetHeight });
8
+ const resizeObserver = new ResizeObserver((entries) => {
9
+ if (!Array.isArray(entries)) {
10
+ return;
11
+ }
12
+ if (!entries.length) {
13
+ return;
14
+ }
15
+ const entry = entries[0];
16
+ let width;
17
+ let height;
18
+ if ("borderBoxSize" in entry) {
19
+ const borderSizeEntry = entry["borderBoxSize"];
20
+ const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
21
+ width = borderSize["inlineSize"];
22
+ height = borderSize["blockSize"];
23
+ } else {
24
+ width = element.offsetWidth;
25
+ height = element.offsetHeight;
26
+ }
27
+ setSize({ width, height });
28
+ });
29
+ resizeObserver.observe(element, { box: "border-box" });
30
+ return () => resizeObserver.unobserve(element);
31
+ } else {
32
+ setSize(void 0);
33
+ }
34
+ }, [element]);
35
+ return size;
36
+ }
37
+ export {
38
+ useSize
39
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index83.cjs"),e=require("./index84.cjs"),n=require("./index85.cjs");function o(t){const o=n.getComputedStyle(t);let i=parseFloat(o.width)||0,r=parseFloat(o.height)||0;const l=n.isHTMLElement(t),s=l?t.offsetWidth:i,c=l?t.offsetHeight:r,f=e.round(i)!==s||e.round(r)!==c;return f&&(i=s,r=c),{width:i,height:r,$:f}}function i(t){return n.isElement(t)?t:t.contextElement}function r(t){const r=i(t);if(!n.isHTMLElement(r))return e.createCoords(1);const l=r.getBoundingClientRect(),{width:s,height:c,$:f}=o(r);let u=(f?e.round(l.width):l.width)/s,a=(f?e.round(l.height):l.height)/c;return u&&Number.isFinite(u)||(u=1),a&&Number.isFinite(a)||(a=1),{x:u,y:a}}const l=e.createCoords(0);function s(t){const e=n.getWindow(t);return n.isWebKit()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:l}function c(t,o,l,c){void 0===o&&(o=!1),void 0===l&&(l=!1);const f=t.getBoundingClientRect(),u=i(t);let a=e.createCoords(1);o&&(c?n.isElement(c)&&(a=r(c)):a=r(t));const d=function(t,e,o){return void 0===e&&(e=!1),!(!o||e&&o!==n.getWindow(t))&&e}(u,l,c)?s(u):e.createCoords(0);let g=(f.left+d.x)/a.x,h=(f.top+d.y)/a.y,m=f.width/a.x,p=f.height/a.y;if(u){const t=n.getWindow(u),e=c&&n.isElement(c)?n.getWindow(c):c;let o=t,i=n.getFrameElement(o);for(;i&&c&&e!==o;){const t=r(i),e=i.getBoundingClientRect(),l=n.getComputedStyle(i),s=e.left+(i.clientLeft+parseFloat(l.paddingLeft))*t.x,c=e.top+(i.clientTop+parseFloat(l.paddingTop))*t.y;g*=t.x,h*=t.y,m*=t.x,p*=t.y,g+=s,h+=c,o=n.getWindow(i),i=n.getFrameElement(o)}}return e.rectToClientRect({width:m,height:p,x:g,y:h})}function f(t,e){const o=n.getNodeScroll(t).scrollLeft;return e?e.left+o:c(n.getDocumentElement(t)).left+o}function u(t,e){const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-f(t,n),y:n.top+e.scrollTop}}const a=new Set(["absolute","fixed"]);function d(t,o,i){let l;if("viewport"===o)l=function(t,e){const o=n.getWindow(t),i=n.getDocumentElement(t),r=o.visualViewport;let l=i.clientWidth,s=i.clientHeight,c=0,u=0;if(r){l=r.width,s=r.height;const t=n.isWebKit();(!t||t&&"fixed"===e)&&(c=r.offsetLeft,u=r.offsetTop)}const a=f(i);if(a<=0){const t=i.ownerDocument,e=t.body,n=getComputedStyle(e),o="CSS1Compat"===t.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,r=Math.abs(i.clientWidth-e.clientWidth-o);r<=25&&(l-=r)}else a<=25&&(l+=a);return{width:l,height:s,x:c,y:u}}(t,i);else if("document"===o)l=function(t){const o=n.getDocumentElement(t),i=n.getNodeScroll(t),r=t.ownerDocument.body,l=e.max(o.scrollWidth,o.clientWidth,r.scrollWidth,r.clientWidth),s=e.max(o.scrollHeight,o.clientHeight,r.scrollHeight,r.clientHeight);let c=-i.scrollLeft+f(t);const u=-i.scrollTop;return"rtl"===n.getComputedStyle(r).direction&&(c+=e.max(o.clientWidth,r.clientWidth)-l),{width:l,height:s,x:c,y:u}}(n.getDocumentElement(t));else if(n.isElement(o))l=function(t,o){const i=c(t,!0,"fixed"===o),l=i.top+t.clientTop,s=i.left+t.clientLeft,f=n.isHTMLElement(t)?r(t):e.createCoords(1);return{width:t.clientWidth*f.x,height:t.clientHeight*f.y,x:s*f.x,y:l*f.y}}(o,i);else{const e=s(t);l={x:o.x-e.x,y:o.y-e.y,width:o.width,height:o.height}}return e.rectToClientRect(l)}function g(t,e){const o=n.getParentNode(t);return!(o===e||!n.isElement(o)||n.isLastTraversableNode(o))&&("fixed"===n.getComputedStyle(o).position||g(o,e))}function h(t,o,i){const r=n.isHTMLElement(o),l=n.getDocumentElement(o),s="fixed"===i,a=c(t,!0,s,o);let d={scrollLeft:0,scrollTop:0};const g=e.createCoords(0);function h(){g.x=f(l)}if(r||!r&&!s)if(("body"!==n.getNodeName(o)||n.isOverflowElement(l))&&(d=n.getNodeScroll(o)),r){const t=c(o,!0,s,o);g.x=t.x+o.clientLeft,g.y=t.y+o.clientTop}else l&&h();s&&!r&&l&&h();const m=!l||r||s?e.createCoords(0):u(l,d);return{x:a.left+d.scrollLeft-g.x-m.x,y:a.top+d.scrollTop-g.y-m.y,width:a.width,height:a.height}}function m(t){return"static"===n.getComputedStyle(t).position}function p(t,e){if(!n.isHTMLElement(t)||"fixed"===n.getComputedStyle(t).position)return null;if(e)return e(t);let o=t.offsetParent;return n.getDocumentElement(t)===o&&(o=o.ownerDocument.body),o}function x(t,e){const o=n.getWindow(t);if(n.isTopLayer(t))return o;if(!n.isHTMLElement(t)){let e=n.getParentNode(t);for(;e&&!n.isLastTraversableNode(e);){if(n.isElement(e)&&!m(e))return e;e=n.getParentNode(e)}return o}let i=p(t,e);for(;i&&n.isTableElement(i)&&m(i);)i=p(i,e);return i&&n.isLastTraversableNode(i)&&m(i)&&!n.isContainingBlock(i)?o:i||n.getContainingBlock(t)||o}const y={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:o,rect:i,offsetParent:l,strategy:s}=t;const f="fixed"===s,a=n.getDocumentElement(l),d=!!o&&n.isTopLayer(o.floating);if(l===a||d&&f)return i;let g={scrollLeft:0,scrollTop:0},h=e.createCoords(1);const m=e.createCoords(0),p=n.isHTMLElement(l);if((p||!p&&!f)&&(("body"!==n.getNodeName(l)||n.isOverflowElement(a))&&(g=n.getNodeScroll(l)),n.isHTMLElement(l))){const t=c(l);h=r(l),m.x=t.x+l.clientLeft,m.y=t.y+l.clientTop}const x=!a||p||f?e.createCoords(0):u(a,g);return{width:i.width*h.x,height:i.height*h.y,x:i.x*h.x-g.scrollLeft*h.x+m.x+x.x,y:i.y*h.y-g.scrollTop*h.y+m.y+x.y}},getDocumentElement:n.getDocumentElement,getClippingRect:function(t){let{element:o,boundary:i,rootBoundary:r,strategy:l}=t;const s=[..."clippingAncestors"===i?n.isTopLayer(o)?[]:function(t,e){const o=e.get(t);if(o)return o;let i=n.getOverflowAncestors(t,[],!1).filter(t=>n.isElement(t)&&"body"!==n.getNodeName(t)),r=null;const l="fixed"===n.getComputedStyle(t).position;let s=l?n.getParentNode(t):t;for(;n.isElement(s)&&!n.isLastTraversableNode(s);){const e=n.getComputedStyle(s),o=n.isContainingBlock(s);o||"fixed"!==e.position||(r=null),(l?!o&&!r:!o&&"static"===e.position&&r&&a.has(r.position)||n.isOverflowElement(s)&&!o&&g(t,s))?i=i.filter(t=>t!==s):r=e,s=n.getParentNode(s)}return e.set(t,i),i}(o,this._c):[].concat(i),r],c=s[0],f=s.reduce((t,n)=>{const i=d(o,n,l);return t.top=e.max(i.top,t.top),t.right=e.min(i.right,t.right),t.bottom=e.min(i.bottom,t.bottom),t.left=e.max(i.left,t.left),t},d(o,c,l));return{width:f.right-f.left,height:f.bottom-f.top,x:f.left,y:f.top}},getOffsetParent:x,getElementRects:async function(t){const e=this.getOffsetParent||x,n=this.getDimensions,o=await n(t.floating);return{reference:h(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=o(t);return{width:e,height:n}},getScale:r,isElement:n.isElement,isRTL:function(t){return"rtl"===n.getComputedStyle(t).direction}};function w(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}const v=t.offset,E=t.shift,C=t.flip,T=t.size,L=t.hide,b=t.arrow,S=t.limitShift;exports.getOverflowAncestors=n.getOverflowAncestors,exports.arrow=b,exports.autoUpdate=function(t,o,r,l){void 0===l&&(l={});const{ancestorScroll:s=!0,ancestorResize:f=!0,elementResize:u="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:d=!1}=l,g=i(t),h=s||f?[...g?n.getOverflowAncestors(g):[],...n.getOverflowAncestors(o)]:[];h.forEach(t=>{s&&t.addEventListener("scroll",r,{passive:!0}),f&&t.addEventListener("resize",r)});const m=g&&a?function(t,o){let i,r=null;const l=n.getDocumentElement(t);function s(){var t;clearTimeout(i),null==(t=r)||t.disconnect(),r=null}return function n(c,f){void 0===c&&(c=!1),void 0===f&&(f=1),s();const u=t.getBoundingClientRect(),{left:a,top:d,width:g,height:h}=u;if(c||o(),!g||!h)return;const m={rootMargin:-e.floor(d)+"px "+-e.floor(l.clientWidth-(a+g))+"px "+-e.floor(l.clientHeight-(d+h))+"px "+-e.floor(a)+"px",threshold:e.max(0,e.min(1,f))||1};let p=!0;function x(e){const o=e[0].intersectionRatio;if(o!==f){if(!p)return n();o?n(!1,o):i=setTimeout(()=>{n(!1,1e-7)},1e3)}1!==o||w(u,t.getBoundingClientRect())||n(),p=!1}try{r=new IntersectionObserver(x,{...m,root:l.ownerDocument})}catch(y){r=new IntersectionObserver(x,m)}r.observe(t)}(!0),s}(g,r):null;let p,x=-1,y=null;u&&(y=new ResizeObserver(t=>{let[e]=t;e&&e.target===g&&y&&(y.unobserve(o),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var t;null==(t=y)||t.observe(o)})),r()}),g&&!d&&y.observe(g),y.observe(o));let v=d?c(t):null;return d&&function e(){const n=c(t);v&&!w(v,n)&&r();v=n,p=requestAnimationFrame(e)}(),r(),()=>{var t;h.forEach(t=>{s&&t.removeEventListener("scroll",r),f&&t.removeEventListener("resize",r)}),null==m||m(),null==(t=y)||t.disconnect(),y=null,d&&cancelAnimationFrame(p)}},exports.computePosition=(e,n,o)=>{const i=new Map,r={platform:y,...o},l={...r.platform,_c:i};return t.computePosition(e,n,{...r,platform:l})},exports.flip=C,exports.hide=L,exports.limitShift=S,exports.offset=v,exports.platform=y,exports.shift=E,exports.size=T;