@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.
- package/README.md +17 -13
- package/dist/index.cjs +782 -191
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +89 -2
- package/dist/index.d.ts +89 -2
- package/dist/index.js +782 -194
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AvatarSimple/AvatarSimple.stories.tsx +62 -0
- package/src/components/AvatarSimple/AvatarSimple.tsx +178 -0
- package/src/components/AvatarSimple/index.ts +2 -0
- package/src/components/SegmentedToggle/SegmentedToggle.stories.tsx +22 -0
- package/src/components/SegmentedToggle/SegmentedToggle.tsx +51 -18
- package/src/components/Sidebar/Sidebar.stories.tsx +119 -0
- package/src/components/Sidebar/Sidebar.tsx +305 -0
- package/src/components/Sidebar/index.ts +2 -0
- package/src/components/VerificationCodeInput/VerificationCodeInput.stories.tsx +112 -0
- package/src/components/VerificationCodeInput/VerificationCodeInput.test.ts +42 -0
- package/src/components/VerificationCodeInput/VerificationCodeInput.tsx +255 -0
- package/src/components/VerificationCodeInput/VerificationCodeInput.utils.ts +34 -0
- package/src/components/VerificationCodeInput/index.ts +5 -0
- package/src/components/index.ts +12 -0
- package/src/icons/LogOut/logOutPath.ts +1 -1
- package/src/index.ts +9 -0
|
@@ -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
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -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
|
|
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,
|