@ecohouse/ui 0.1.28 → 0.1.30

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.
@@ -0,0 +1,34 @@
1
+ export function normalizeVerificationCode(value: string, length: number): string {
2
+ return value.replace(/\D/g, "").slice(0, Math.max(1, length));
3
+ }
4
+
5
+ export interface VerificationCodeUpdate {
6
+ code: string;
7
+ nextFocus: number;
8
+ }
9
+
10
+ export function updateVerificationCode(
11
+ currentCode: string,
12
+ index: number,
13
+ input: string,
14
+ length: number,
15
+ ): VerificationCodeUpdate {
16
+ const safeLength = Math.max(1, length);
17
+ const safeIndex = Math.min(Math.max(0, index), safeLength - 1);
18
+ const current = normalizeVerificationCode(currentCode, safeLength);
19
+ const insertedDigits = normalizeVerificationCode(input, safeLength - safeIndex);
20
+
21
+ if (!insertedDigits) {
22
+ return {
23
+ code: `${current.slice(0, safeIndex)}${current.slice(safeIndex + 1)}`,
24
+ nextFocus: safeIndex,
25
+ };
26
+ }
27
+
28
+ return {
29
+ code: `${current.slice(0, safeIndex)}${insertedDigits}${current.slice(
30
+ safeIndex + insertedDigits.length,
31
+ )}`.slice(0, safeLength),
32
+ nextFocus: Math.min(safeIndex + insertedDigits.length, safeLength - 1),
33
+ };
34
+ }
@@ -0,0 +1,5 @@
1
+ export { VerificationCodeInput } from "./VerificationCodeInput";
2
+ export type {
3
+ VerificationCodeInputHandle,
4
+ VerificationCodeInputProps,
5
+ } from "./VerificationCodeInput";
@@ -1,6 +1,9 @@
1
1
  export { Avatar } from "./Avatar";
2
2
  export type { AvatarProps, AvatarMenuItem } from "./Avatar";
3
3
 
4
+ export { AvatarSimple } from "./AvatarSimple";
5
+ export type { AvatarSimpleProps } from "./AvatarSimple";
6
+
4
7
  export { Badge } from "./Badge";
5
8
  export type { BadgeProps, BadgeVariant } from "./Badge";
6
9
 
@@ -10,6 +13,9 @@ export type { CounterProps } from "./Counter";
10
13
  export { SegmentedToggle } from "./SegmentedToggle";
11
14
  export type { SegmentedToggleOption, SegmentedToggleProps } from "./SegmentedToggle";
12
15
 
16
+ export { Sidebar } from "./Sidebar";
17
+ export type { SidebarProps, SidebarItem, SidebarUser } from "./Sidebar";
18
+
13
19
  export { LanguageSwitcher, defaultLanguageOptions } from "./LanguageSwitcher";
14
20
  export type { LanguageOption, LanguageSwitcherProps } from "./LanguageSwitcher";
15
21
 
@@ -34,6 +40,12 @@ export type {
34
40
  export { Input } from "./Input";
35
41
  export type { InputIcon, InputProps, InputSize } from "./Input";
36
42
 
43
+ export { VerificationCodeInput } from "./VerificationCodeInput";
44
+ export type {
45
+ VerificationCodeInputHandle,
46
+ VerificationCodeInputProps,
47
+ } from "./VerificationCodeInput";
48
+
37
49
  export { Select } from "./Select";
38
50
  export type {
39
51
  SelectIcon,
@@ -1,3 +1,3 @@
1
1
  /** LogOut icon path — 16×16 viewBox. */
2
2
  export const LOG_OUT_PATH =
3
- "M10.6667 4.66667L14 8L10.6667 11.3333M14 8H6M8 11.3333C8 11.5304 8 11.6289 7.99268 11.7143C7.91655 12.6013 7.26324 13.3312 6.39002 13.5049C6.30602 13.5216 6.20801 13.5324 6.01223 13.5542L5.3313 13.6299C4.30832 13.7435 3.7968 13.8004 3.39044 13.6703C2.84862 13.4969 2.40628 13.101 2.17412 12.5817C2 12.1921 2 11.6775 2 10.6482V5.3518C2 4.32251 2 3.80787 2.17412 3.41835C2.40628 2.89899 2.84862 2.50307 3.39044 2.32969C3.79681 2.19965 4.3083 2.25648 5.33129 2.37015L6.01223 2.44581C6.20808 2.46757 6.306 2.47845 6.39002 2.49515C7.26324 2.66877 7.91655 3.39869 7.99268 4.28574C8 4.37109 8 4.46962 8 4.66667";
3
+ "M10.6667 4.66667L14 8L10.6667 11.3333M14 8H6M6 2H5.2C4.0799 2 3.51984 2 3.09202 2.21799C2.7157 2.40973 2.40973 2.71569 2.21799 3.09202C2 3.51984 2 4.07989 2 5.2V10.8C2 11.9201 2 12.4802 2.21799 12.908C2.40973 13.2843 2.71569 13.5903 3.09202 13.782C3.51984 14 4.0799 14 5.2 14H6";
package/src/index.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  export {
2
2
  Avatar,
3
+ AvatarSimple,
3
4
  Badge,
4
5
  Counter,
5
6
  SegmentedToggle,
7
+ Sidebar,
6
8
  LanguageSwitcher,
7
9
  defaultLanguageOptions,
8
10
  StatCard,
@@ -10,6 +12,7 @@ export {
10
12
  Checkbox,
11
13
  DatePicker,
12
14
  Input,
15
+ VerificationCodeInput,
13
16
  Select,
14
17
  Textarea,
15
18
  Toggle,
@@ -20,11 +23,15 @@ export {
20
23
  export type {
21
24
  AvatarProps,
22
25
  AvatarMenuItem,
26
+ AvatarSimpleProps,
23
27
  BadgeProps,
24
28
  BadgeVariant,
25
29
  CounterProps,
26
30
  SegmentedToggleOption,
27
31
  SegmentedToggleProps,
32
+ SidebarProps,
33
+ SidebarItem,
34
+ SidebarUser,
28
35
  LanguageOption,
29
36
  LanguageSwitcherProps,
30
37
  StatCardProps,
@@ -41,6 +48,8 @@ export type {
41
48
  InputIcon,
42
49
  InputProps,
43
50
  InputSize,
51
+ VerificationCodeInputHandle,
52
+ VerificationCodeInputProps,
44
53
  SelectIcon,
45
54
  SelectOption,
46
55
  SelectProps,