@kivid/native-components 1.0.0-alpha.24 → 1.0.0-alpha.26
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/dist/commonjs/components/DatePicker/assets/theme.js +60 -0
- package/dist/commonjs/components/DatePicker/assets/theme.js.map +1 -1
- package/dist/commonjs/components/DatePicker/index.js +84 -0
- package/dist/commonjs/components/DatePicker/index.js.map +1 -1
- package/dist/commonjs/components/Dropdown/index.js +156 -0
- package/dist/commonjs/components/Dropdown/index.js.map +1 -0
- package/dist/commonjs/components/Dropdown/types.js +6 -0
- package/dist/commonjs/components/Dropdown/types.js.map +1 -0
- package/dist/commonjs/components/ListButton/assets/class-variants.js +2 -1
- package/dist/commonjs/components/ListButton/assets/class-variants.js.map +1 -1
- package/dist/commonjs/components/ListButton/assets/design-system-showcase.js +59 -0
- package/dist/commonjs/components/ListButton/assets/design-system-showcase.js.map +1 -1
- package/dist/commonjs/components/ListButton/enums/variant.js +1 -0
- package/dist/commonjs/components/ListButton/enums/variant.js.map +1 -1
- package/dist/commonjs/components/Tab/assets/class-variants.js +69 -0
- package/dist/commonjs/components/Tab/assets/class-variants.js.map +1 -0
- package/dist/commonjs/components/Tab/index.js +90 -0
- package/dist/commonjs/components/Tab/index.js.map +1 -0
- package/dist/commonjs/components/Tab/types.js +6 -0
- package/dist/commonjs/components/Tab/types.js.map +1 -0
- package/dist/commonjs/components/TextAreaInput/assets/class-variants.js +91 -0
- package/dist/commonjs/components/TextAreaInput/assets/class-variants.js.map +1 -0
- package/dist/commonjs/components/TextAreaInput/enums.js +12 -0
- package/dist/commonjs/components/TextAreaInput/enums.js.map +1 -0
- package/dist/commonjs/components/TextAreaInput/index.js +105 -0
- package/dist/commonjs/components/TextAreaInput/index.js.map +1 -0
- package/dist/commonjs/components/TextAreaInput/types.js +6 -0
- package/dist/commonjs/components/TextAreaInput/types.js.map +1 -0
- package/dist/commonjs/components/Title/components/marker/index.js +11 -4
- package/dist/commonjs/components/Title/components/marker/index.js.map +1 -1
- package/dist/commonjs/components/index.js +81 -26
- package/dist/commonjs/components/index.js.map +1 -1
- package/dist/module/components/DatePicker/assets/theme.js +60 -0
- package/dist/module/components/DatePicker/assets/theme.js.map +1 -1
- package/dist/module/components/DatePicker/index.js +85 -1
- package/dist/module/components/DatePicker/index.js.map +1 -1
- package/dist/module/components/Dropdown/index.js +151 -0
- package/dist/module/components/Dropdown/index.js.map +1 -0
- package/dist/module/components/Dropdown/types.js +4 -0
- package/dist/module/components/Dropdown/types.js.map +1 -0
- package/dist/module/components/ListButton/assets/class-variants.js +2 -1
- package/dist/module/components/ListButton/assets/class-variants.js.map +1 -1
- package/dist/module/components/ListButton/assets/design-system-showcase.js +59 -0
- package/dist/module/components/ListButton/assets/design-system-showcase.js.map +1 -1
- package/dist/module/components/ListButton/enums/variant.js +1 -0
- package/dist/module/components/ListButton/enums/variant.js.map +1 -1
- package/dist/module/components/Tab/assets/class-variants.js +66 -0
- package/dist/module/components/Tab/assets/class-variants.js.map +1 -0
- package/dist/module/components/Tab/index.js +86 -0
- package/dist/module/components/Tab/index.js.map +1 -0
- package/dist/module/components/Tab/types.js +4 -0
- package/dist/module/components/Tab/types.js.map +1 -0
- package/dist/module/components/TextAreaInput/assets/class-variants.js +87 -0
- package/dist/module/components/TextAreaInput/assets/class-variants.js.map +1 -0
- package/dist/module/components/TextAreaInput/enums.js +8 -0
- package/dist/module/components/TextAreaInput/enums.js.map +1 -0
- package/dist/module/components/TextAreaInput/index.js +100 -0
- package/dist/module/components/TextAreaInput/index.js.map +1 -0
- package/dist/module/components/TextAreaInput/types.js +4 -0
- package/dist/module/components/TextAreaInput/types.js.map +1 -0
- package/dist/module/components/Title/components/marker/index.js +11 -4
- package/dist/module/components/Title/components/marker/index.js.map +1 -1
- package/dist/module/components/index.js +5 -0
- package/dist/module/components/index.js.map +1 -1
- package/dist/typescript/components/DatePicker/assets/theme.d.ts +60 -0
- package/dist/typescript/components/Dropdown/index.d.ts +3 -0
- package/dist/typescript/components/Dropdown/types.d.ts +20 -0
- package/dist/typescript/components/ListButton/enums/variant.d.ts +2 -1
- package/dist/typescript/components/Tab/assets/class-variants.d.ts +18 -0
- package/dist/typescript/components/Tab/index.d.ts +2 -0
- package/dist/typescript/components/Tab/types.d.ts +17 -0
- package/dist/typescript/components/TextAreaInput/assets/class-variants.d.ts +17 -0
- package/dist/typescript/components/TextAreaInput/enums.d.ts +4 -0
- package/dist/typescript/components/TextAreaInput/index.d.ts +2 -0
- package/dist/typescript/components/TextAreaInput/types.d.ts +22 -0
- package/dist/typescript/components/Title/components/marker/index.d.ts +1 -1
- package/dist/typescript/components/Title/components/marker/types.d.ts +1 -0
- package/dist/typescript/components/index.d.ts +8 -0
- package/package.json +6 -5
- package/src/components/DatePicker/assets/theme.ts +60 -0
- package/src/components/DatePicker/index.tsx +106 -4
- package/src/components/Dropdown/index.tsx +165 -0
- package/src/components/Dropdown/types.ts +21 -0
- package/src/components/ListButton/assets/class-variants.ts +4 -0
- package/src/components/ListButton/assets/design-system-showcase.ts +69 -0
- package/src/components/ListButton/enums/variant.ts +1 -0
- package/src/components/Tab/assets/class-variants.ts +83 -0
- package/src/components/Tab/index.tsx +92 -0
- package/src/components/Tab/types.ts +20 -0
- package/src/components/TextAreaInput/assets/class-variants.ts +96 -0
- package/src/components/TextAreaInput/enums.ts +4 -0
- package/src/components/TextAreaInput/index.tsx +119 -0
- package/src/components/TextAreaInput/types.ts +28 -0
- package/src/components/Title/components/marker/index.tsx +10 -2
- package/src/components/Title/components/marker/types.ts +1 -0
- package/src/components/index.ts +11 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, Pressable } from "react-native";
|
|
3
|
+
import { Typography } from "../Typography";
|
|
4
|
+
import type { DropdownProps } from "./types";
|
|
5
|
+
import { ArrowChevronDownStroke } from "@kivid/icons/native";
|
|
6
|
+
import { IconButton } from "../IconButton";
|
|
7
|
+
import { IconButtonSizeEnum } from "../IconButton/enums";
|
|
8
|
+
import { cva } from "class-variance-authority";
|
|
9
|
+
import { SizeEnum } from "../../enums";
|
|
10
|
+
import { merge } from "@kivid/tailwind-preset";
|
|
11
|
+
|
|
12
|
+
export function Dropdown(props: DropdownProps) {
|
|
13
|
+
const {
|
|
14
|
+
label,
|
|
15
|
+
value,
|
|
16
|
+
placeholder,
|
|
17
|
+
disabled = false,
|
|
18
|
+
className,
|
|
19
|
+
contentBoxClassName,
|
|
20
|
+
leftButtonText,
|
|
21
|
+
hidePlaceholder = false,
|
|
22
|
+
children,
|
|
23
|
+
iconButtonTrigger,
|
|
24
|
+
iconButtonAlign = "right",
|
|
25
|
+
size = SizeEnum.MEDIUM,
|
|
26
|
+
corner = SizeEnum.SMALL,
|
|
27
|
+
isActive = false,
|
|
28
|
+
onActiveChange,
|
|
29
|
+
} = props;
|
|
30
|
+
|
|
31
|
+
const handlePress = () => {
|
|
32
|
+
if (disabled) return;
|
|
33
|
+
|
|
34
|
+
onActiveChange(!isActive);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const textStyle = cva("text-chia-900", {
|
|
38
|
+
variants: {
|
|
39
|
+
placeholder: {
|
|
40
|
+
true: "text-chia-600",
|
|
41
|
+
false: "text-chia-900",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const dropdownStyle = cva("bg-chia-100 border border-chia-400 px-500 ", {
|
|
47
|
+
variants: {
|
|
48
|
+
size: {
|
|
49
|
+
[SizeEnum.SMALL]: "py-400",
|
|
50
|
+
[SizeEnum.MEDIUM]: "py-600",
|
|
51
|
+
},
|
|
52
|
+
corner: {
|
|
53
|
+
[SizeEnum.SMALL]: "rounded-400",
|
|
54
|
+
[SizeEnum.MEDIUM]: "rounded-700",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const triggerStyle = merge(dropdownStyle({ size, corner }), className);
|
|
60
|
+
const boxStyle = merge("absolute top-full left-0 w-full mt-100 z-50 bg-white border border-gray-200 rounded-xl shadow-lg", contentBoxClassName);
|
|
61
|
+
|
|
62
|
+
const triggerPositionStyle = cva("flex-row w-full", {
|
|
63
|
+
variants: {
|
|
64
|
+
align: {
|
|
65
|
+
left: "justify-start",
|
|
66
|
+
right: "justify-end",
|
|
67
|
+
center: "justify-center",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
function renderVariant() {
|
|
73
|
+
const displayPlaceholder = !!placeholder && !value;
|
|
74
|
+
if (hidePlaceholder) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<View className="flex-row justify-between gap-100">
|
|
80
|
+
<Typography
|
|
81
|
+
variant="label_large"
|
|
82
|
+
weight="700"
|
|
83
|
+
className={textStyle({ placeholder: displayPlaceholder })}
|
|
84
|
+
>
|
|
85
|
+
{displayPlaceholder ? placeholder : value}
|
|
86
|
+
</Typography>
|
|
87
|
+
</View>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function renderTrigger() {
|
|
92
|
+
if (iconButtonTrigger) {
|
|
93
|
+
return (
|
|
94
|
+
<View className={triggerPositionStyle({ align: iconButtonAlign })}>
|
|
95
|
+
<IconButton
|
|
96
|
+
onPress={handlePress}
|
|
97
|
+
disabled={disabled}
|
|
98
|
+
size={IconButtonSizeEnum.MEDIUM}
|
|
99
|
+
{...iconButtonTrigger}
|
|
100
|
+
/>
|
|
101
|
+
</View>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<Pressable
|
|
107
|
+
onPress={handlePress}
|
|
108
|
+
disabled={disabled}
|
|
109
|
+
className={triggerStyle}
|
|
110
|
+
>
|
|
111
|
+
<View className="flex-row justify-between items-center">
|
|
112
|
+
<View className="">
|
|
113
|
+
<View className="flex-col">
|
|
114
|
+
{label && (
|
|
115
|
+
<Typography
|
|
116
|
+
variant="label_small"
|
|
117
|
+
weight="600"
|
|
118
|
+
className="text-chia-900"
|
|
119
|
+
>
|
|
120
|
+
{label}
|
|
121
|
+
</Typography>
|
|
122
|
+
)}
|
|
123
|
+
</View>
|
|
124
|
+
|
|
125
|
+
{renderVariant()}
|
|
126
|
+
</View>
|
|
127
|
+
|
|
128
|
+
<View className="flex-row items-center gap-400">
|
|
129
|
+
{leftButtonText && (
|
|
130
|
+
<Typography
|
|
131
|
+
variant="label_medium"
|
|
132
|
+
weight="700"
|
|
133
|
+
>
|
|
134
|
+
{leftButtonText}
|
|
135
|
+
</Typography>
|
|
136
|
+
)}
|
|
137
|
+
<View
|
|
138
|
+
style={{
|
|
139
|
+
transform: [{ rotate: isActive ? "180deg" : "0deg" }],
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<ArrowChevronDownStroke size={24} className="text-chia-900" />
|
|
143
|
+
</View>
|
|
144
|
+
</View>
|
|
145
|
+
</View>
|
|
146
|
+
</Pressable>
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<View className={className}>
|
|
152
|
+
<View className="relative">
|
|
153
|
+
{renderTrigger()}
|
|
154
|
+
|
|
155
|
+
{isActive && (
|
|
156
|
+
<>
|
|
157
|
+
<View className={boxStyle}>
|
|
158
|
+
{children}
|
|
159
|
+
</View>
|
|
160
|
+
</>
|
|
161
|
+
)}
|
|
162
|
+
</View>
|
|
163
|
+
</View>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { IconButtonProps } from "../IconButton/types";
|
|
3
|
+
import { SizeEnum } from "../../enums";
|
|
4
|
+
|
|
5
|
+
export interface DropdownProps {
|
|
6
|
+
label?: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
contentBoxClassName?: string;
|
|
12
|
+
leftButtonText?: string;
|
|
13
|
+
hidePlaceholder?: boolean;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
iconButtonTrigger?: IconButtonProps;
|
|
16
|
+
iconButtonAlign?: "left" | "right" | "center";
|
|
17
|
+
size?: SizeEnum.SMALL | SizeEnum.MEDIUM;
|
|
18
|
+
corner?: SizeEnum.SMALL | SizeEnum.MEDIUM;
|
|
19
|
+
isActive: boolean;
|
|
20
|
+
onActiveChange: (isActive: boolean) => void;
|
|
21
|
+
}
|
|
@@ -40,6 +40,10 @@ const buttonVariants = cva(
|
|
|
40
40
|
"bg-chia-100 text-chia-900 border border-chia-400",
|
|
41
41
|
"disabled:bg-chia-200 disabled:opacity-50 disabled:text-chia-900",
|
|
42
42
|
],
|
|
43
|
+
[ListButtonVariantEnum.GHOST]: [
|
|
44
|
+
"bg-transparent text-chia-900 border-0",
|
|
45
|
+
"disabled:bg-chia-200 disabled:opacity-50 disabled:text-chia-900",
|
|
46
|
+
],
|
|
43
47
|
},
|
|
44
48
|
size: {
|
|
45
49
|
[SizeEnum.SMALL]: "py-400 pr-400 pl-600",
|
|
@@ -499,4 +499,73 @@ export const listButtonShowcaseVariants: Record<
|
|
|
499
499
|
iconRight: true,
|
|
500
500
|
},
|
|
501
501
|
],
|
|
502
|
+
ghost: [
|
|
503
|
+
{
|
|
504
|
+
variant: ListButtonVariantEnum.GHOST,
|
|
505
|
+
size: SizeEnum.SMALL,
|
|
506
|
+
corners: CornersEnum.SMALL,
|
|
507
|
+
children: "Label Text",
|
|
508
|
+
iconColor: "#393E3E",
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
variant: ListButtonVariantEnum.GHOST,
|
|
512
|
+
size: SizeEnum.SMALL,
|
|
513
|
+
corners: CornersEnum.MEDIUM,
|
|
514
|
+
children: "Label Text",
|
|
515
|
+
iconColor: "#393E3E",
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
variant: ListButtonVariantEnum.GHOST,
|
|
519
|
+
size: SizeEnum.MEDIUM,
|
|
520
|
+
corners: CornersEnum.SMALL,
|
|
521
|
+
children: "Label Text",
|
|
522
|
+
iconColor: "#393E3E",
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
variant: ListButtonVariantEnum.GHOST,
|
|
526
|
+
size: SizeEnum.MEDIUM,
|
|
527
|
+
corners: CornersEnum.MEDIUM,
|
|
528
|
+
children: "Label Text",
|
|
529
|
+
iconColor: "#393E3E",
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
variant: ListButtonVariantEnum.GHOST,
|
|
533
|
+
size: SizeEnum.LARGE,
|
|
534
|
+
corners: CornersEnum.SMALL,
|
|
535
|
+
children: "Label Text",
|
|
536
|
+
iconColor: "#393E3E",
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
variant: ListButtonVariantEnum.GHOST,
|
|
540
|
+
size: SizeEnum.LARGE,
|
|
541
|
+
corners: CornersEnum.MEDIUM,
|
|
542
|
+
children: "Label Text",
|
|
543
|
+
iconColor: "#393E3E",
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
variant: ListButtonVariantEnum.GHOST,
|
|
547
|
+
size: SizeEnum.MEDIUM,
|
|
548
|
+
corners: CornersEnum.MEDIUM,
|
|
549
|
+
children: "Label Text",
|
|
550
|
+
iconColor: "#393E3E",
|
|
551
|
+
disabled: true,
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
variant: ListButtonVariantEnum.GHOST,
|
|
555
|
+
size: SizeEnum.SMALL,
|
|
556
|
+
corners: CornersEnum.MEDIUM,
|
|
557
|
+
children: "Label Text",
|
|
558
|
+
iconColor: "#393E3E",
|
|
559
|
+
iconLeft: true,
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
variant: ListButtonVariantEnum.GHOST,
|
|
563
|
+
size: SizeEnum.SMALL,
|
|
564
|
+
corners: CornersEnum.MEDIUM,
|
|
565
|
+
children: "Label Text",
|
|
566
|
+
iconColor: "#393E3E",
|
|
567
|
+
iconLeft: true,
|
|
568
|
+
iconRight: true,
|
|
569
|
+
},
|
|
570
|
+
],
|
|
502
571
|
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
import { SizeEnum } from "../../../enums";
|
|
3
|
+
|
|
4
|
+
const tabContainerVariants = cva(["flex-row w-full"], {
|
|
5
|
+
variants: {
|
|
6
|
+
size: {
|
|
7
|
+
[SizeEnum.MEDIUM]: "",
|
|
8
|
+
[SizeEnum.SMALL]: "",
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
defaultVariants: {
|
|
12
|
+
size: SizeEnum.MEDIUM,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const dividerVariants = cva(
|
|
17
|
+
[
|
|
18
|
+
"w-full",
|
|
19
|
+
],
|
|
20
|
+
{
|
|
21
|
+
variants: {
|
|
22
|
+
selected: {
|
|
23
|
+
true: "h-200 bg-grape-500",
|
|
24
|
+
false: "h-[1px] bg-chia-400",
|
|
25
|
+
},
|
|
26
|
+
size: {
|
|
27
|
+
[SizeEnum.MEDIUM]: "mt-500",
|
|
28
|
+
[SizeEnum.SMALL]: "mt-400",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
selected: false,
|
|
33
|
+
size: SizeEnum.MEDIUM,
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const tabLabelVariants = cva("", {
|
|
39
|
+
variants: {
|
|
40
|
+
selected: {
|
|
41
|
+
true: "text-chia-900",
|
|
42
|
+
false: "text-chia-700",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
defaultVariants: {
|
|
46
|
+
selected: false,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const tabCountVariants = cva(
|
|
51
|
+
["px-300 rounded-300 items-center justify-center ml-400"],
|
|
52
|
+
{
|
|
53
|
+
variants: {
|
|
54
|
+
selected: {
|
|
55
|
+
true: "bg-grape-500",
|
|
56
|
+
false: "bg-chia-400",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
defaultVariants: {
|
|
60
|
+
selected: false,
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const tabCountTextVariants = cva("", {
|
|
66
|
+
variants: {
|
|
67
|
+
selected: {
|
|
68
|
+
true: "text-chia-100",
|
|
69
|
+
false: "text-chia-700",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
defaultVariants: {
|
|
73
|
+
selected: false,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
tabContainerVariants,
|
|
79
|
+
dividerVariants,
|
|
80
|
+
tabLabelVariants,
|
|
81
|
+
tabCountVariants,
|
|
82
|
+
tabCountTextVariants,
|
|
83
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Pressable, View } from "react-native";
|
|
2
|
+
import { merge } from "@kivid/tailwind-preset";
|
|
3
|
+
import type { TabProps } from "./types";
|
|
4
|
+
import {
|
|
5
|
+
tabContainerVariants,
|
|
6
|
+
dividerVariants,
|
|
7
|
+
tabLabelVariants,
|
|
8
|
+
tabCountVariants,
|
|
9
|
+
tabCountTextVariants,
|
|
10
|
+
} from "./assets/class-variants";
|
|
11
|
+
import { Typography } from "../Typography";
|
|
12
|
+
import { SizeEnum } from "../../enums";
|
|
13
|
+
|
|
14
|
+
export function Tab(props: TabProps) {
|
|
15
|
+
const {
|
|
16
|
+
items,
|
|
17
|
+
onTabChange,
|
|
18
|
+
size = SizeEnum.MEDIUM,
|
|
19
|
+
className,
|
|
20
|
+
selectedTab,
|
|
21
|
+
customDividerColor,
|
|
22
|
+
customDividerComponent,
|
|
23
|
+
} = props;
|
|
24
|
+
|
|
25
|
+
const handleTabPress = (index: number) => {
|
|
26
|
+
onTabChange?.(index);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const containerStyle = merge(tabContainerVariants({ size }), className);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<View className={containerStyle} accessibilityRole="tablist">
|
|
33
|
+
{items.map((item, index) => {
|
|
34
|
+
const selected = selectedTab === index;
|
|
35
|
+
const buttonStyle = merge("flex-1 flex-col items-center justify-center", className);
|
|
36
|
+
const labelStyle = tabLabelVariants({ selected });
|
|
37
|
+
const countTextStyle = tabCountTextVariants({ selected });
|
|
38
|
+
|
|
39
|
+
const dividerStyle = (selected && customDividerColor)
|
|
40
|
+
? merge(dividerVariants({ selected, size }), customDividerColor)
|
|
41
|
+
: dividerVariants({ selected, size });
|
|
42
|
+
|
|
43
|
+
const countContainerStyle = (selected && customDividerColor)
|
|
44
|
+
? merge(tabCountVariants({ selected }), customDividerColor)
|
|
45
|
+
: tabCountVariants({ selected });
|
|
46
|
+
|
|
47
|
+
const renderDivider = () => {
|
|
48
|
+
if (selected && customDividerComponent) {
|
|
49
|
+
return customDividerComponent;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<View className={dividerStyle} />
|
|
54
|
+
)
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Pressable
|
|
59
|
+
key={index}
|
|
60
|
+
testID={`tab-${index}`}
|
|
61
|
+
className={buttonStyle}
|
|
62
|
+
onPress={() => handleTabPress(index)}
|
|
63
|
+
accessibilityRole="tab"
|
|
64
|
+
accessibilityState={{ selected }}
|
|
65
|
+
>
|
|
66
|
+
<View className="flex flex-row">
|
|
67
|
+
<Typography
|
|
68
|
+
variant={size === SizeEnum.MEDIUM ? "label_medium" : "label_small"}
|
|
69
|
+
weight="700"
|
|
70
|
+
className={labelStyle}
|
|
71
|
+
>
|
|
72
|
+
{item.label}
|
|
73
|
+
</Typography>
|
|
74
|
+
{item.count !== undefined && (
|
|
75
|
+
<View className={countContainerStyle}>
|
|
76
|
+
<Typography
|
|
77
|
+
variant="label_small"
|
|
78
|
+
weight="700"
|
|
79
|
+
className={countTextStyle}
|
|
80
|
+
>
|
|
81
|
+
{item.count}
|
|
82
|
+
</Typography>
|
|
83
|
+
</View>
|
|
84
|
+
)}
|
|
85
|
+
</View>
|
|
86
|
+
{renderDivider()}
|
|
87
|
+
</Pressable>
|
|
88
|
+
);
|
|
89
|
+
})}
|
|
90
|
+
</View>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { SizeEnum } from "../../enums";
|
|
3
|
+
|
|
4
|
+
export type TabSize = SizeEnum.SMALL | SizeEnum.MEDIUM;
|
|
5
|
+
|
|
6
|
+
export interface TabItem {
|
|
7
|
+
label: string;
|
|
8
|
+
count?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface TabProps{
|
|
12
|
+
items: TabItem[];
|
|
13
|
+
onTabChange: (index: number) => void;
|
|
14
|
+
size?: TabSize;
|
|
15
|
+
className?: string;
|
|
16
|
+
customDividerColor?: string;
|
|
17
|
+
customDividerComponent?: ReactNode;
|
|
18
|
+
selectedTab: number;
|
|
19
|
+
selected?: boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
export const textInputContainerVariants = cva(
|
|
4
|
+
"flex-row px-600 py-500 border-b border-r border-l border-chia-400 bg-chia-100 min-h-[120px]",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
corners: {
|
|
8
|
+
small: "rounded-500",
|
|
9
|
+
medium: "rounded-700",
|
|
10
|
+
},
|
|
11
|
+
error: {
|
|
12
|
+
true: "border-blackberry-500",
|
|
13
|
+
false: "border-chia-400",
|
|
14
|
+
},
|
|
15
|
+
disabled: {
|
|
16
|
+
true: "opacity-40",
|
|
17
|
+
false: "",
|
|
18
|
+
},
|
|
19
|
+
insideLabel: {
|
|
20
|
+
true: "border-t-0 rounded-100",
|
|
21
|
+
false: "border-t",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
compoundVariants: [
|
|
25
|
+
{
|
|
26
|
+
insideLabel: true,
|
|
27
|
+
corners: "small",
|
|
28
|
+
class: "rounded-bl-500 rounded-br-500",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
insideLabel: true,
|
|
32
|
+
corners: "medium",
|
|
33
|
+
class: "rounded-bl-700 rounded-br-700",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
corners: "medium",
|
|
38
|
+
error: false,
|
|
39
|
+
disabled: false,
|
|
40
|
+
insideLabel: false,
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const labelVariant = cva("flex-row w-full justify-between", {
|
|
46
|
+
variants: {
|
|
47
|
+
insideLabel: {
|
|
48
|
+
true: "border-t border-l border-r border-chia-400 bg-chia-100 px-600 pt-500",
|
|
49
|
+
false: "mb-400",
|
|
50
|
+
},
|
|
51
|
+
corners: {
|
|
52
|
+
small: "rounded-tl-500 rounded-tr-500",
|
|
53
|
+
medium: "rounded-tl-700 rounded-tr-700",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
defaultVariants: {
|
|
57
|
+
insideLabel: false,
|
|
58
|
+
corners: "medium",
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
export const textInputFieldVariants = cva(
|
|
63
|
+
"flex-1 font-nunito-bold text-[16px] leading-[20px] placeholder:text-chia-600 android:p-0 min-w-0",
|
|
64
|
+
{
|
|
65
|
+
variants: {
|
|
66
|
+
disabled: {
|
|
67
|
+
true: "",
|
|
68
|
+
false: "",
|
|
69
|
+
},
|
|
70
|
+
isValid: {
|
|
71
|
+
true: "text-chia-900",
|
|
72
|
+
false: "",
|
|
73
|
+
},
|
|
74
|
+
error: {
|
|
75
|
+
true: "text-blackberry-500",
|
|
76
|
+
false: "",
|
|
77
|
+
},
|
|
78
|
+
showLabel: {
|
|
79
|
+
true: "min-h-700",
|
|
80
|
+
false: "min-h-800",
|
|
81
|
+
},
|
|
82
|
+
size: {
|
|
83
|
+
small: "ios:pt-[3px]",
|
|
84
|
+
medium: "ios:pt-[3px]",
|
|
85
|
+
large: "ios:pt-[2px]",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
defaultVariants: {
|
|
89
|
+
disabled: false,
|
|
90
|
+
isValid: false,
|
|
91
|
+
error: false,
|
|
92
|
+
showLabel: false,
|
|
93
|
+
size: "large",
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
);
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { View, TextInput as RNTextInput, Pressable } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { TextAreaInputProps } from './types';
|
|
4
|
+
import { Tooltip } from '../Tooltip';
|
|
5
|
+
import { TooltipVariantEnum } from '../Tooltip/enum';
|
|
6
|
+
import Typography from '../Typography';
|
|
7
|
+
import { TextAreaInputCornersEnum } from './enums';
|
|
8
|
+
import { labelVariant, textInputContainerVariants, textInputFieldVariants } from './assets/class-variants';
|
|
9
|
+
import { merge } from '@kivid/tailwind-preset';
|
|
10
|
+
import { useRef } from 'react';
|
|
11
|
+
|
|
12
|
+
export function TextAreaInput(props: TextAreaInputProps) {
|
|
13
|
+
const {
|
|
14
|
+
value,
|
|
15
|
+
onChangeText,
|
|
16
|
+
onBlur,
|
|
17
|
+
placeholder,
|
|
18
|
+
label,
|
|
19
|
+
error,
|
|
20
|
+
maxLength = 200,
|
|
21
|
+
disabled = false,
|
|
22
|
+
corners = TextAreaInputCornersEnum.MEDIUM,
|
|
23
|
+
insideLabel = false,
|
|
24
|
+
className,
|
|
25
|
+
inputClassName,
|
|
26
|
+
labelClassName,
|
|
27
|
+
tooltipClassName,
|
|
28
|
+
tooltipPointerClassName,
|
|
29
|
+
tooltipContainerClassName,
|
|
30
|
+
showMaxLength = true,
|
|
31
|
+
containerTestID,
|
|
32
|
+
...rest
|
|
33
|
+
} = props;
|
|
34
|
+
const currentLength = value?.length || 0;
|
|
35
|
+
const hasLabel = !!label;
|
|
36
|
+
const hasError = !!error;
|
|
37
|
+
|
|
38
|
+
const inputRef = useRef<RNTextInput>(null);
|
|
39
|
+
|
|
40
|
+
const handleChangeText = (text: string) => {
|
|
41
|
+
if (text.length <= maxLength) {
|
|
42
|
+
onChangeText?.(text);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const formattedCurrentLength = currentLength.toString().padStart(3, '0');
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Tooltip
|
|
50
|
+
isOpenedByVariantError={hasError}
|
|
51
|
+
message={error}
|
|
52
|
+
variant={TooltipVariantEnum.ERROR}
|
|
53
|
+
className={tooltipClassName}
|
|
54
|
+
pointerClassName={tooltipPointerClassName}
|
|
55
|
+
containerClassName={tooltipContainerClassName}
|
|
56
|
+
>
|
|
57
|
+
<View className={labelVariant({ insideLabel, corners })}>
|
|
58
|
+
{label && (
|
|
59
|
+
<Typography
|
|
60
|
+
variant="label_small"
|
|
61
|
+
weight="600"
|
|
62
|
+
className={merge("text-chia-900", labelClassName)}
|
|
63
|
+
>
|
|
64
|
+
{label}
|
|
65
|
+
</Typography>
|
|
66
|
+
)}
|
|
67
|
+
|
|
68
|
+
{showMaxLength && (
|
|
69
|
+
<Typography
|
|
70
|
+
variant="label_small"
|
|
71
|
+
weight="500"
|
|
72
|
+
className="text-chia-600"
|
|
73
|
+
>
|
|
74
|
+
{formattedCurrentLength}/{maxLength}
|
|
75
|
+
</Typography>
|
|
76
|
+
)}
|
|
77
|
+
</View>
|
|
78
|
+
|
|
79
|
+
<Pressable
|
|
80
|
+
testID={containerTestID}
|
|
81
|
+
className={merge(
|
|
82
|
+
textInputContainerVariants({
|
|
83
|
+
corners,
|
|
84
|
+
error: !!error,
|
|
85
|
+
disabled,
|
|
86
|
+
insideLabel,
|
|
87
|
+
}),
|
|
88
|
+
className
|
|
89
|
+
)}
|
|
90
|
+
onPress={() => {
|
|
91
|
+
if (!disabled) {
|
|
92
|
+
inputRef.current?.focus();
|
|
93
|
+
}
|
|
94
|
+
}}
|
|
95
|
+
disabled={disabled}
|
|
96
|
+
>
|
|
97
|
+
<RNTextInput
|
|
98
|
+
value={value}
|
|
99
|
+
onChangeText={handleChangeText}
|
|
100
|
+
onBlur={onBlur}
|
|
101
|
+
placeholder={placeholder}
|
|
102
|
+
multiline
|
|
103
|
+
maxLength={maxLength}
|
|
104
|
+
placeholderTextColor="#9CA3AF"
|
|
105
|
+
textAlignVertical="top"
|
|
106
|
+
className={merge(
|
|
107
|
+
textInputFieldVariants({
|
|
108
|
+
disabled,
|
|
109
|
+
error: hasError,
|
|
110
|
+
showLabel: hasLabel,
|
|
111
|
+
}),
|
|
112
|
+
inputClassName
|
|
113
|
+
)}
|
|
114
|
+
{...rest}
|
|
115
|
+
/>
|
|
116
|
+
</Pressable>
|
|
117
|
+
</Tooltip>
|
|
118
|
+
);
|
|
119
|
+
}
|