@adam-milo/ui 1.0.33 → 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 +57 -23
  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 -39
  29. package/dist/index22.cjs +1 -1
  30. package/dist/index22.js +16 -27
  31. package/dist/index23.cjs +1 -1
  32. package/dist/index23.js +36 -12
  33. package/dist/index24.cjs +1 -0
  34. package/dist/index24.js +46 -0
  35. package/dist/index25.cjs +1 -1
  36. package/dist/index25.js +80 -263
  37. package/dist/index26.cjs +1 -1
  38. package/dist/index26.js +52 -13
  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 -1
  54. package/dist/index36.js +383 -6
  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/index50.cjs +1 -0
  62. package/dist/index50.js +9 -0
  63. package/dist/index6.cjs +1 -1
  64. package/dist/index6.js +11 -101
  65. package/dist/index62.cjs +1 -0
  66. package/dist/index62.js +502 -0
  67. package/dist/index64.cjs +1 -0
  68. package/dist/index64.js +11 -0
  69. package/dist/index65.cjs +1 -0
  70. package/dist/index65.js +39 -0
  71. package/dist/index66.cjs +1 -0
  72. package/dist/index66.js +64 -0
  73. package/dist/index67.cjs +1 -0
  74. package/dist/index67.js +212 -0
  75. package/dist/index68.cjs +1 -0
  76. package/dist/index68.js +14 -0
  77. package/dist/index69.cjs +1 -0
  78. package/dist/index69.js +293 -0
  79. package/dist/index7.cjs +1 -1
  80. package/dist/index7.js +46 -97
  81. package/dist/index70.cjs +1 -0
  82. package/dist/index70.js +18 -0
  83. package/dist/index71.cjs +1 -0
  84. package/dist/index71.js +129 -0
  85. package/dist/index72.cjs +1 -0
  86. package/dist/index72.js +43 -0
  87. package/dist/index73.cjs +1 -0
  88. package/dist/index73.js +99 -0
  89. package/dist/index74.cjs +1 -0
  90. package/dist/index74.js +71 -0
  91. package/dist/index75.cjs +1 -0
  92. package/dist/index75.js +36 -0
  93. package/dist/index76.cjs +1 -0
  94. package/dist/index76.js +14 -0
  95. package/dist/index77.cjs +1 -0
  96. package/dist/index77.js +17 -0
  97. package/dist/index78.cjs +1 -0
  98. package/dist/index78.js +6 -0
  99. package/dist/index79.cjs +1 -0
  100. package/dist/index79.js +297 -0
  101. package/dist/index8.cjs +1 -1
  102. package/dist/index8.js +97 -88
  103. package/dist/index80.cjs +1 -0
  104. package/dist/index80.js +25 -0
  105. package/dist/index81.cjs +1 -0
  106. package/dist/index81.js +39 -0
  107. package/dist/index82.cjs +1 -0
  108. package/dist/index82.js +625 -0
  109. package/dist/index83.cjs +1 -0
  110. package/dist/index83.js +721 -0
  111. package/dist/index84.cjs +1 -0
  112. package/dist/index84.js +154 -0
  113. package/dist/index85.cjs +1 -0
  114. package/dist/index85.js +173 -0
  115. package/dist/index9.cjs +1 -1
  116. package/dist/index9.js +55 -197
  117. package/dist/src/components/core/button/Button.component.d.ts +13 -7
  118. package/dist/src/components/core/button/Button.component.d.ts.map +1 -1
  119. package/dist/src/components/core/icon/Icon.component.d.ts +1 -1
  120. package/dist/src/components/core/icon/Icon.component.d.ts.map +1 -1
  121. package/dist/src/components/core/icon-button/IconButton.component.d.ts +36 -0
  122. package/dist/src/components/core/icon-button/IconButton.component.d.ts.map +1 -0
  123. package/dist/src/components/core/menu-icon-button/MenuIconButton.component.d.ts +79 -0
  124. package/dist/src/components/core/menu-icon-button/MenuIconButton.component.d.ts.map +1 -0
  125. package/dist/src/components/feedback/spinner/Spinner.component.d.ts +62 -0
  126. package/dist/src/components/feedback/spinner/Spinner.component.d.ts.map +1 -0
  127. package/dist/src/components/forms/input/Input.component.d.ts +5 -0
  128. package/dist/src/components/forms/input/Input.component.d.ts.map +1 -1
  129. package/dist/src/components/forms/otp-input/OTPInput.component.d.ts +82 -0
  130. package/dist/src/components/forms/otp-input/OTPInput.component.d.ts.map +1 -0
  131. package/dist/src/components/forms/phone-input/PhoneInput.component.d.ts +96 -0
  132. package/dist/src/components/forms/phone-input/PhoneInput.component.d.ts.map +1 -0
  133. package/dist/src/components/forms/phone-input/countries.d.ts +93 -0
  134. package/dist/src/components/forms/phone-input/countries.d.ts.map +1 -0
  135. package/dist/src/components/forms/select/Select.component.d.ts +5 -1
  136. package/dist/src/components/forms/select/Select.component.d.ts.map +1 -1
  137. package/dist/src/components/forms/toggle/Toggle.component.d.ts +80 -0
  138. package/dist/src/components/forms/toggle/Toggle.component.d.ts.map +1 -0
  139. package/dist/src/components/layout/auth-layout/AuthLayout.component.d.ts +86 -0
  140. package/dist/src/components/layout/auth-layout/AuthLayout.component.d.ts.map +1 -0
  141. package/dist/src/components/overlays/dialog/Dialog.component.d.ts +36 -2
  142. package/dist/src/components/overlays/dialog/Dialog.component.d.ts.map +1 -1
  143. package/dist/src/components/typography/heading/Heading.component.d.ts +3 -2
  144. package/dist/src/components/typography/heading/Heading.component.d.ts.map +1 -1
  145. package/dist/src/components/typography/link/Link.component.d.ts +80 -0
  146. package/dist/src/components/typography/link/Link.component.d.ts.map +1 -0
  147. package/dist/src/index.d.ts +22 -5
  148. package/dist/src/index.d.ts.map +1 -1
  149. package/dist/style.css +1 -1
  150. package/package.json +2 -1
  151. /package/dist/{index44.cjs → index61.cjs} +0 -0
  152. /package/dist/{index44.js → index61.js} +0 -0
package/dist/index12.js CHANGED
@@ -1,125 +1,325 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
3
- import { cn } from "./index23.js";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useState, useId, useRef, useEffect, useCallback } from "react";
3
+ import { cn } from "./index31.js";
4
+ import { Icon } from "@adam-milo/icons";
5
+ import { commonCountries, getPhoneMask, getPhoneDigits, formatPhoneNumber } from "./index32.js";
6
+ import { allCountries, defaultCountries, defaultPhoneMask, getCountriesByDialCode, getCountryByCode, getCountryByDialCode, isValidPhoneLength, phoneMasks, searchCountries } from "./index32.js";
4
7
  /* empty css */
5
- const Card = forwardRef(
8
+ const PhoneInput = forwardRef(
6
9
  ({
7
- variant = "default",
8
- className,
9
- children,
10
+ label,
11
+ error,
12
+ helperText,
13
+ fullWidth = true,
14
+ value = "",
15
+ onChange,
16
+ countryCode = "US",
17
+ onCountryChange,
18
+ countries = commonCountries,
19
+ enableFormatting = true,
20
+ onValidationChange,
21
+ disabled,
22
+ required,
23
+ placeholder,
24
+ id: providedId,
10
25
  "data-cy": dataCy,
11
26
  "data-testid": dataTestId,
27
+ className,
28
+ onFocus,
29
+ onBlur,
12
30
  ...props
13
31
  }, ref) => {
14
- const finalDataCy = dataCy || `card-${variant}`;
15
- const finalTestId = dataTestId || `card-${variant}`;
16
- return /* @__PURE__ */ jsx(
17
- "div",
18
- {
19
- ref,
20
- className: cn("card", `card--${variant}`, className),
21
- "data-cy": finalDataCy,
22
- "data-testid": finalTestId,
23
- ...props,
24
- children
25
- }
26
- );
27
- }
28
- );
29
- Card.displayName = "Card";
30
- const CardHeader = forwardRef(
31
- ({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
32
- const finalDataCy = dataCy || "card-header";
33
- const finalTestId = dataTestId || "card-header";
34
- return /* @__PURE__ */ jsx(
35
- "div",
36
- {
37
- ref,
38
- className: cn("card-header", className),
39
- "data-cy": finalDataCy,
40
- "data-testid": finalTestId,
41
- ...props
32
+ const [isDropdownOpen, setIsDropdownOpen] = useState(false);
33
+ const [isFocused, setIsFocused] = useState(false);
34
+ const [highlightedIndex, setHighlightedIndex] = useState(0);
35
+ const generatedId = useId();
36
+ const id = providedId || generatedId;
37
+ const errorId = `${id}-error`;
38
+ const helperId = `${id}-helper`;
39
+ const listboxId = `${id}-listbox`;
40
+ const wrapperRef = useRef(null);
41
+ const dropdownRef = useRef(null);
42
+ const triggerRef = useRef(null);
43
+ const finalDataCy = dataCy || "phone-input";
44
+ const finalTestId = dataTestId || "phone-input";
45
+ const selectedCountry = countries.find((c) => c.code === countryCode) || countries[0];
46
+ const phoneMask = getPhoneMask(countryCode);
47
+ const displayPlaceholder = placeholder || phoneMask.placeholder;
48
+ const displayLabel = label && required && !label.includes("*") ? `${label}*` : label;
49
+ useEffect(() => {
50
+ const handleClickOutside = (event) => {
51
+ if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
52
+ setIsDropdownOpen(false);
53
+ }
54
+ };
55
+ if (isDropdownOpen) {
56
+ document.addEventListener("mousedown", handleClickOutside);
42
57
  }
58
+ return () => {
59
+ document.removeEventListener("mousedown", handleClickOutside);
60
+ };
61
+ }, [isDropdownOpen]);
62
+ const handleCountrySelect = useCallback(
63
+ (country) => {
64
+ onCountryChange == null ? void 0 : onCountryChange(country);
65
+ setIsDropdownOpen(false);
66
+ setTimeout(() => {
67
+ var _a;
68
+ const input = (_a = wrapperRef.current) == null ? void 0 : _a.querySelector("input");
69
+ input == null ? void 0 : input.focus();
70
+ }, 0);
71
+ },
72
+ [onCountryChange]
43
73
  );
44
- }
45
- );
46
- CardHeader.displayName = "CardHeader";
47
- const CardTitle = forwardRef(
48
- ({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
49
- const finalDataCy = dataCy || "card-title";
50
- const finalTestId = dataTestId || "card-title";
51
- return (
52
- // eslint-disable-next-line jsx-a11y/heading-has-content
53
- /* @__PURE__ */ jsx(
54
- "h3",
55
- {
56
- ref,
57
- className: cn("card-title", className),
58
- "data-cy": finalDataCy,
59
- "data-testid": finalTestId,
60
- ...props
74
+ const handleDropdownKeyDown = useCallback(
75
+ (e) => {
76
+ var _a;
77
+ switch (e.key) {
78
+ case "ArrowDown":
79
+ e.preventDefault();
80
+ setHighlightedIndex((prev) => Math.min(prev + 1, countries.length - 1));
81
+ break;
82
+ case "ArrowUp":
83
+ e.preventDefault();
84
+ setHighlightedIndex((prev) => Math.max(prev - 1, 0));
85
+ break;
86
+ case "Enter":
87
+ case " ":
88
+ e.preventDefault();
89
+ handleCountrySelect(countries[highlightedIndex]);
90
+ break;
91
+ case "Escape":
92
+ e.preventDefault();
93
+ setIsDropdownOpen(false);
94
+ (_a = triggerRef.current) == null ? void 0 : _a.focus();
95
+ break;
96
+ case "Tab":
97
+ setIsDropdownOpen(false);
98
+ break;
61
99
  }
62
- )
100
+ },
101
+ [countries, highlightedIndex, handleCountrySelect]
63
102
  );
64
- }
65
- );
66
- CardTitle.displayName = "CardTitle";
67
- const CardDescription = forwardRef(
68
- ({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
69
- const finalDataCy = dataCy || "card-description";
70
- const finalTestId = dataTestId || "card-description";
71
- return /* @__PURE__ */ jsx(
72
- "p",
73
- {
74
- ref,
75
- className: cn("card-description", className),
76
- "data-cy": finalDataCy,
77
- "data-testid": finalTestId,
78
- ...props
103
+ const handleTriggerKeyDown = (e) => {
104
+ if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") {
105
+ e.preventDefault();
106
+ setIsDropdownOpen(true);
107
+ const index = countries.findIndex((c) => c.code === countryCode);
108
+ setHighlightedIndex(index === -1 ? 0 : index);
79
109
  }
80
- );
81
- }
82
- );
83
- CardDescription.displayName = "CardDescription";
84
- const CardContent = forwardRef(
85
- ({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
86
- const finalDataCy = dataCy || "card-content";
87
- const finalTestId = dataTestId || "card-content";
88
- return /* @__PURE__ */ jsx(
89
- "div",
90
- {
91
- ref,
92
- className: cn("card-content", className),
93
- "data-cy": finalDataCy,
94
- "data-testid": finalTestId,
95
- ...props
110
+ };
111
+ const handleInputChange = (e) => {
112
+ const inputValue = e.target.value;
113
+ if (enableFormatting) {
114
+ const digits = getPhoneDigits(inputValue);
115
+ const limitedDigits = digits.slice(0, phoneMask.maxLength);
116
+ const formattedValue = formatPhoneNumber(limitedDigits, countryCode);
117
+ onChange == null ? void 0 : onChange(formattedValue);
118
+ const isValid = limitedDigits.length === phoneMask.maxLength;
119
+ onValidationChange == null ? void 0 : onValidationChange(isValid);
120
+ } else {
121
+ const numericValue = inputValue.replace(/[^0-9]/g, "");
122
+ onChange == null ? void 0 : onChange(numericValue);
123
+ const isValid = numericValue.length === phoneMask.maxLength;
124
+ onValidationChange == null ? void 0 : onValidationChange(isValid);
96
125
  }
97
- );
98
- }
99
- );
100
- CardContent.displayName = "CardContent";
101
- const CardFooter = forwardRef(
102
- ({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
103
- const finalDataCy = dataCy || "card-footer";
104
- const finalTestId = dataTestId || "card-footer";
105
- return /* @__PURE__ */ jsx(
126
+ };
127
+ const handleInputFocus = (e) => {
128
+ setIsFocused(true);
129
+ onFocus == null ? void 0 : onFocus(e);
130
+ };
131
+ const handleInputBlur = (e) => {
132
+ setIsFocused(false);
133
+ onBlur == null ? void 0 : onBlur(e);
134
+ };
135
+ const inputState = disabled ? "disabled" : error ? "error" : isFocused || isDropdownOpen ? "focus" : "idle";
136
+ return /* @__PURE__ */ jsxs(
106
137
  "div",
107
138
  {
108
- ref,
109
- className: cn("card-footer", className),
110
- "data-cy": finalDataCy,
111
- "data-testid": finalTestId,
112
- ...props
139
+ ref: wrapperRef,
140
+ className: cn("phone-input-wrapper", fullWidth && "phone-input-wrapper--full-width"),
141
+ "data-cy": `${finalDataCy}-wrapper`,
142
+ "data-testid": `${finalTestId}-wrapper`,
143
+ children: [
144
+ label && /* @__PURE__ */ jsx(
145
+ "label",
146
+ {
147
+ htmlFor: id,
148
+ className: "phone-input__label",
149
+ "data-cy": `${finalDataCy}-label`,
150
+ "data-testid": `${finalTestId}-label`,
151
+ children: displayLabel
152
+ }
153
+ ),
154
+ /* @__PURE__ */ jsxs(
155
+ "div",
156
+ {
157
+ className: cn(
158
+ "phone-input__container",
159
+ inputState === "focus" && "phone-input__container--focus",
160
+ inputState === "error" && "phone-input__container--error",
161
+ inputState === "disabled" && "phone-input__container--disabled"
162
+ ),
163
+ "data-state": inputState,
164
+ "data-cy": `${finalDataCy}-container`,
165
+ "data-testid": `${finalTestId}-container`,
166
+ children: [
167
+ /* @__PURE__ */ jsxs(
168
+ "button",
169
+ {
170
+ ref: triggerRef,
171
+ type: "button",
172
+ className: "phone-input__country-trigger",
173
+ onClick: () => !disabled && setIsDropdownOpen(!isDropdownOpen),
174
+ onKeyDown: handleTriggerKeyDown,
175
+ disabled,
176
+ "aria-haspopup": "listbox",
177
+ "aria-expanded": isDropdownOpen,
178
+ "aria-controls": listboxId,
179
+ "aria-label": `Select country. Current: ${selectedCountry.name}`,
180
+ "data-cy": `${finalDataCy}-country-trigger`,
181
+ "data-testid": `${finalTestId}-country-trigger`,
182
+ children: [
183
+ /* @__PURE__ */ jsx(
184
+ "span",
185
+ {
186
+ className: "phone-input__flag",
187
+ "data-cy": `${finalDataCy}-flag`,
188
+ "data-testid": `${finalTestId}-flag`,
189
+ children: selectedCountry.flag
190
+ }
191
+ ),
192
+ /* @__PURE__ */ jsx(
193
+ Icon,
194
+ {
195
+ name: "ChevronDownIcon",
196
+ size: "sm",
197
+ color: isFocused || isDropdownOpen ? "clickable" : "text",
198
+ decorative: true,
199
+ "data-cy": `${finalDataCy}-chevron`
200
+ }
201
+ )
202
+ ]
203
+ }
204
+ ),
205
+ /* @__PURE__ */ jsx(
206
+ "span",
207
+ {
208
+ className: "phone-input__dial-code",
209
+ "data-cy": `${finalDataCy}-dial-code`,
210
+ "data-testid": `${finalTestId}-dial-code`,
211
+ children: selectedCountry.dialCode
212
+ }
213
+ ),
214
+ /* @__PURE__ */ jsx(
215
+ "input",
216
+ {
217
+ ref,
218
+ id,
219
+ type: "tel",
220
+ inputMode: "numeric",
221
+ value,
222
+ onChange: handleInputChange,
223
+ onFocus: handleInputFocus,
224
+ onBlur: handleInputBlur,
225
+ placeholder: displayPlaceholder,
226
+ disabled,
227
+ required,
228
+ className: cn("phone-input__input", className),
229
+ "aria-invalid": error ? "true" : "false",
230
+ "aria-required": required ? "true" : void 0,
231
+ "aria-describedby": error ? errorId : helperText ? helperId : void 0,
232
+ "data-cy": finalDataCy,
233
+ "data-testid": finalTestId,
234
+ ...props
235
+ }
236
+ )
237
+ ]
238
+ }
239
+ ),
240
+ isDropdownOpen && /* @__PURE__ */ jsx(
241
+ "div",
242
+ {
243
+ ref: dropdownRef,
244
+ id: listboxId,
245
+ role: "listbox",
246
+ "aria-label": "Select country",
247
+ className: "phone-input__dropdown",
248
+ tabIndex: -1,
249
+ onKeyDown: handleDropdownKeyDown,
250
+ "data-cy": `${finalDataCy}-dropdown`,
251
+ "data-testid": `${finalTestId}-dropdown`,
252
+ children: countries.map((country, index) => /* @__PURE__ */ jsxs(
253
+ "div",
254
+ {
255
+ role: "option",
256
+ "aria-selected": country.code === countryCode,
257
+ className: cn(
258
+ "phone-input__option",
259
+ country.code === countryCode && "phone-input__option--selected",
260
+ index === highlightedIndex && "phone-input__option--highlighted"
261
+ ),
262
+ onClick: () => handleCountrySelect(country),
263
+ onKeyDown: (e) => {
264
+ if (e.key === "Enter" || e.key === " ") {
265
+ e.preventDefault();
266
+ handleCountrySelect(country);
267
+ }
268
+ },
269
+ onMouseEnter: () => setHighlightedIndex(index),
270
+ tabIndex: index === highlightedIndex ? 0 : -1,
271
+ "data-cy": `${finalDataCy}-option-${country.code.toLowerCase()}`,
272
+ "data-testid": `${finalTestId}-option-${country.code.toLowerCase()}`,
273
+ children: [
274
+ /* @__PURE__ */ jsx("span", { className: "phone-input__option-flag", children: country.flag }),
275
+ /* @__PURE__ */ jsx("span", { className: "phone-input__option-name", children: country.name }),
276
+ /* @__PURE__ */ jsx("span", { className: "phone-input__option-dial-code", children: country.dialCode })
277
+ ]
278
+ },
279
+ country.code
280
+ ))
281
+ }
282
+ ),
283
+ error && /* @__PURE__ */ jsx(
284
+ "span",
285
+ {
286
+ id: errorId,
287
+ className: "phone-input__error",
288
+ role: "alert",
289
+ "data-cy": `${finalDataCy}-error`,
290
+ "data-testid": `${finalTestId}-error`,
291
+ children: error
292
+ }
293
+ ),
294
+ helperText && !error && /* @__PURE__ */ jsx(
295
+ "span",
296
+ {
297
+ id: helperId,
298
+ className: "phone-input__helper",
299
+ "data-cy": `${finalDataCy}-helper`,
300
+ "data-testid": `${finalTestId}-helper`,
301
+ children: helperText
302
+ }
303
+ )
304
+ ]
113
305
  }
114
306
  );
115
307
  }
116
308
  );
117
- CardFooter.displayName = "CardFooter";
309
+ PhoneInput.displayName = "PhoneInput";
118
310
  export {
119
- Card,
120
- CardContent,
121
- CardDescription,
122
- CardFooter,
123
- CardHeader,
124
- CardTitle
311
+ PhoneInput,
312
+ allCountries,
313
+ commonCountries,
314
+ defaultCountries,
315
+ defaultPhoneMask,
316
+ formatPhoneNumber,
317
+ getCountriesByDialCode,
318
+ getCountryByCode,
319
+ getCountryByDialCode,
320
+ getPhoneDigits,
321
+ getPhoneMask,
322
+ isValidPhoneLength,
323
+ phoneMasks,
324
+ searchCountries
125
325
  };
package/dist/index13.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),e=require("react"),t=require("./index23.cjs");;/* empty css */const d=e.forwardRef(({columns:e,data:d,striped:r=!1,hoverable:l=!1,className:s,"data-cy":c,"data-testid":i,...y},o)=>{const b=c||"datatable",n=i||"datatable";return a.jsx("div",{className:"datatable-wrapper","data-cy":`${b}-wrapper`,"data-testid":`${n}-wrapper`,children:a.jsxs("table",{ref:o,className:t.cn("datatable",s),"data-cy":b,"data-testid":n,...y,children:[a.jsx("thead",{className:"datatable__head","data-cy":`${b}-head`,"data-testid":`${n}-head`,children:a.jsx("tr",{children:e.map(e=>a.jsx("th",{className:"datatable__header-cell","data-cy":`${b}-header-${e.key}`,"data-testid":`${n}-header-${e.key}`,children:e.header},e.key))})}),a.jsx("tbody",{"data-cy":`${b}-body`,"data-testid":`${n}-body`,children:0===d.length?a.jsx("tr",{children:a.jsx("td",{colSpan:e.length,className:"datatable__empty","data-cy":`${b}-empty`,"data-testid":`${n}-empty`,children:"No data available"})}):d.map((d,s)=>a.jsx("tr",{className:t.cn("datatable__body-row",l&&"datatable__body-row--hoverable",r&&"datatable__body-row--striped"),"data-cy":`${b}-row-${s}`,"data-testid":`${n}-row-${s}`,children:e.map(e=>a.jsx("td",{className:"datatable__body-cell","data-cy":`${b}-cell-${s}-${e.key}`,"data-testid":`${n}-cell-${s}-${e.key}`,children:String(d[e.key]??"")},e.key))},s))})]})})});d.displayName="DataTable",exports.DataTable=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),a=require("./index31.cjs");;/* empty css */const r=t.forwardRef(({length:r=4,label:l,value:n="",onChange:i,onComplete:s,error:c,helperText:o,disabled:u=!1,autoFocus:p=!1,fullWidth:d=!1,centered:f=!1,type:b="numeric",required:h=!1,"data-cy":g,"data-testid":y},m)=>{const $=t.useId(),_=`${$}-error`,x=`${$}-helper`,k=g||"otp-input",v=y||"otp-input",D=t.useRef([]),[j,C]=t.useState(()=>n.split("").slice(0,r).concat(Array(r).fill("")).slice(0,r));t.useEffect(()=>{const e=n.split("").slice(0,r).concat(Array(r).fill("")).slice(0,r);C(e)},[n,r]);const w=t.useCallback(e=>"numeric"===b?/^\d$/.test(e):/^[a-zA-Z0-9]$/.test(e),[b]),A=t.useCallback(e=>{C(e);const t=e.join("");null==i||i(t),e.every(e=>""!==e)&&e.length===r&&(null==s||s(t))},[i,s,r]),I=t.useCallback(e=>{const t=D.current[e];t&&(t.focus(),t.select())},[]),N=t.useCallback((e,t)=>{const a=t.target.value;if(1===a.length&&w(a)){const t=[...j];t[e]=a,A(t),e<r-1&&I(e+1)}else if(a.length>1){const t=a.split("").filter(w),l=[...j];t.forEach((t,a)=>{e+a<r&&(l[e+a]=t)}),A(l);const n=l.findIndex(e=>""===e);I(-1===n?r-1:n)}},[j,r,w,A,I]),q=t.useCallback((e,t)=>{switch(t.key){case"Backspace":if(t.preventDefault(),j[e]){const t=[...j];t[e]="",A(t)}else if(e>0){const t=[...j];t[e-1]="",A(t),I(e-1)}break;case"Delete":if(t.preventDefault(),j[e]){const t=[...j];t[e]="",A(t)}break;case"ArrowLeft":t.preventDefault(),e>0&&I(e-1);break;case"ArrowRight":t.preventDefault(),e<r-1&&I(e+1);break;case"Home":t.preventDefault(),I(0);break;case"End":t.preventDefault(),I(r-1);break;default:if(1===t.key.length&&w(t.key)){t.preventDefault();const a=[...j];a[e]=t.key,A(a),e<r-1&&I(e+1)}}},[j,r,w,A,I]),E=t.useCallback((e,t)=>{t.preventDefault();const a=t.clipboardData.getData("text").split("").filter(w);if(0===a.length)return;const l=[...j];a.forEach((t,a)=>{e+a<r&&(l[e+a]=t)}),A(l);const n=l.findIndex(e=>""===e);I(-1===n?r-1:n)},[j,r,w,A,I]),P=t.useCallback(e=>{e.target.select()},[]);return t.useImperativeHandle(m,()=>({focus:()=>{const e=j.findIndex(e=>""===e);I(-1===e?r-1:e)},clear:()=>{const e=Array(r).fill("");A(e),I(0)},getValue:()=>j.join("")}),[j,r,I,A]),t.useEffect(()=>{p&&!u&&I(0)},[p,u,I]),e.jsxs("div",{className:a.cn("otp-input-wrapper",d&&"otp-input-wrapper--full-width"),"data-cy":`${k}-wrapper`,"data-testid":`${v}-wrapper`,children:[l&&e.jsx("label",{className:a.cn("otp-input__label",c&&"otp-input__label--error",u&&"otp-input__label--disabled"),"data-cy":`${k}-label`,"data-testid":`${v}-label`,children:l}),e.jsx("div",{className:a.cn("otp-input__container",f&&"otp-input__container--centered"),role:"group","aria-label":l||"OTP Input","data-cy":`${k}-container`,"data-testid":`${v}-container`,children:Array.from({length:r},(t,l)=>e.jsx("input",{ref:e=>{D.current[l]=e},type:"text",inputMode:"numeric"===b?"numeric":"text",pattern:"numeric"===b?"[0-9]*":"[a-zA-Z0-9]*",maxLength:1,value:j[l]||"",onChange:e=>N(l,e),onKeyDown:e=>q(l,e),onPaste:e=>E(l,e),onFocus:P,disabled:u,required:h,"aria-label":`Digit ${l+1} of ${r}`,"aria-invalid":c?"true":"false","aria-describedby":c?_:o?x:void 0,className:a.cn("otp-input__digit",j[l]&&"otp-input__digit--filled",c&&"otp-input__digit--error"),"data-cy":`${k}-digit-${l}`,"data-testid":`${v}-digit-${l}`,autoComplete:"one-time-code"},l))}),c&&e.jsx("span",{id:_,className:"otp-input__error",role:"alert","data-cy":`${k}-error`,"data-testid":`${v}-error`,children:c}),o&&!c&&e.jsx("span",{id:x,className:"otp-input__helper","data-cy":`${k}-helper`,"data-testid":`${v}-helper`,children:o})]})});r.displayName="OTPInput",exports.OTPInput=r;