@kivid/native-components 1.0.0-alpha.25 → 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.
Files changed (65) hide show
  1. package/dist/commonjs/components/DatePicker/assets/theme.js +60 -0
  2. package/dist/commonjs/components/DatePicker/assets/theme.js.map +1 -1
  3. package/dist/commonjs/components/DatePicker/index.js +84 -0
  4. package/dist/commonjs/components/DatePicker/index.js.map +1 -1
  5. package/dist/commonjs/components/Dropdown/index.js +25 -68
  6. package/dist/commonjs/components/Dropdown/index.js.map +1 -1
  7. package/dist/commonjs/components/ListButton/assets/class-variants.js +2 -1
  8. package/dist/commonjs/components/ListButton/assets/class-variants.js.map +1 -1
  9. package/dist/commonjs/components/ListButton/assets/design-system-showcase.js +59 -0
  10. package/dist/commonjs/components/ListButton/assets/design-system-showcase.js.map +1 -1
  11. package/dist/commonjs/components/ListButton/enums/variant.js +1 -0
  12. package/dist/commonjs/components/ListButton/enums/variant.js.map +1 -1
  13. package/dist/commonjs/components/TextAreaInput/assets/class-variants.js +91 -0
  14. package/dist/commonjs/components/TextAreaInput/assets/class-variants.js.map +1 -0
  15. package/dist/commonjs/components/TextAreaInput/enums.js +12 -0
  16. package/dist/commonjs/components/TextAreaInput/enums.js.map +1 -0
  17. package/dist/commonjs/components/TextAreaInput/index.js +105 -0
  18. package/dist/commonjs/components/TextAreaInput/index.js.map +1 -0
  19. package/dist/commonjs/components/TextAreaInput/types.js +6 -0
  20. package/dist/commonjs/components/TextAreaInput/types.js.map +1 -0
  21. package/dist/commonjs/components/index.js +61 -28
  22. package/dist/commonjs/components/index.js.map +1 -1
  23. package/dist/module/components/DatePicker/assets/theme.js +60 -0
  24. package/dist/module/components/DatePicker/assets/theme.js.map +1 -1
  25. package/dist/module/components/DatePicker/index.js +85 -1
  26. package/dist/module/components/DatePicker/index.js.map +1 -1
  27. package/dist/module/components/Dropdown/index.js +25 -69
  28. package/dist/module/components/Dropdown/index.js.map +1 -1
  29. package/dist/module/components/ListButton/assets/class-variants.js +2 -1
  30. package/dist/module/components/ListButton/assets/class-variants.js.map +1 -1
  31. package/dist/module/components/ListButton/assets/design-system-showcase.js +59 -0
  32. package/dist/module/components/ListButton/assets/design-system-showcase.js.map +1 -1
  33. package/dist/module/components/ListButton/enums/variant.js +1 -0
  34. package/dist/module/components/ListButton/enums/variant.js.map +1 -1
  35. package/dist/module/components/TextAreaInput/assets/class-variants.js +87 -0
  36. package/dist/module/components/TextAreaInput/assets/class-variants.js.map +1 -0
  37. package/dist/module/components/TextAreaInput/enums.js +8 -0
  38. package/dist/module/components/TextAreaInput/enums.js.map +1 -0
  39. package/dist/module/components/TextAreaInput/index.js +100 -0
  40. package/dist/module/components/TextAreaInput/index.js.map +1 -0
  41. package/dist/module/components/TextAreaInput/types.js +4 -0
  42. package/dist/module/components/TextAreaInput/types.js.map +1 -0
  43. package/dist/module/components/index.js +3 -0
  44. package/dist/module/components/index.js.map +1 -1
  45. package/dist/typescript/components/DatePicker/assets/theme.d.ts +60 -0
  46. package/dist/typescript/components/Dropdown/types.d.ts +3 -0
  47. package/dist/typescript/components/ListButton/enums/variant.d.ts +2 -1
  48. package/dist/typescript/components/TextAreaInput/assets/class-variants.d.ts +17 -0
  49. package/dist/typescript/components/TextAreaInput/enums.d.ts +4 -0
  50. package/dist/typescript/components/TextAreaInput/index.d.ts +2 -0
  51. package/dist/typescript/components/TextAreaInput/types.d.ts +22 -0
  52. package/dist/typescript/components/index.d.ts +4 -0
  53. package/package.json +6 -5
  54. package/src/components/DatePicker/assets/theme.ts +60 -0
  55. package/src/components/DatePicker/index.tsx +106 -4
  56. package/src/components/Dropdown/index.tsx +25 -73
  57. package/src/components/Dropdown/types.ts +3 -0
  58. package/src/components/ListButton/assets/class-variants.ts +4 -0
  59. package/src/components/ListButton/assets/design-system-showcase.ts +69 -0
  60. package/src/components/ListButton/enums/variant.ts +1 -0
  61. package/src/components/TextAreaInput/assets/class-variants.ts +96 -0
  62. package/src/components/TextAreaInput/enums.ts +4 -0
  63. package/src/components/TextAreaInput/index.tsx +119 -0
  64. package/src/components/TextAreaInput/types.ts +28 -0
  65. package/src/components/index.ts +5 -0
@@ -1,13 +1,13 @@
1
- import React, { useState, useRef, useEffect } from "react";
2
- import { View, Pressable, Modal, TouchableWithoutFeedback } from "react-native";
1
+ import React from "react";
2
+ import { View, Pressable } from "react-native";
3
3
  import { Typography } from "../Typography";
4
4
  import type { DropdownProps } from "./types";
5
5
  import { ArrowChevronDownStroke } from "@kivid/icons/native";
6
- import { Animated, Easing } from "react-native";
7
6
  import { IconButton } from "../IconButton";
8
7
  import { IconButtonSizeEnum } from "../IconButton/enums";
9
8
  import { cva } from "class-variance-authority";
10
9
  import { SizeEnum } from "../../enums";
10
+ import { merge } from "@kivid/tailwind-preset";
11
11
 
12
12
  export function Dropdown(props: DropdownProps) {
13
13
  const {
@@ -16,6 +16,7 @@ export function Dropdown(props: DropdownProps) {
16
16
  placeholder,
17
17
  disabled = false,
18
18
  className,
19
+ contentBoxClassName,
19
20
  leftButtonText,
20
21
  hidePlaceholder = false,
21
22
  children,
@@ -23,48 +24,14 @@ export function Dropdown(props: DropdownProps) {
23
24
  iconButtonAlign = "right",
24
25
  size = SizeEnum.MEDIUM,
25
26
  corner = SizeEnum.SMALL,
27
+ isActive = false,
28
+ onActiveChange,
26
29
  } = props;
27
30
 
28
- const [isOpen, setIsOpen] = useState(false);
29
- const [dropdownLayout, setDropdownLayout] = useState({
30
- top: 0,
31
- left: 0,
32
- width: 0,
33
- });
34
- const triggerRef = useRef<View>(null);
35
-
36
- const rotateAnim = useRef(new Animated.Value(0)).current;
37
-
38
- useEffect(() => {
39
- Animated.timing(rotateAnim, {
40
- toValue: isOpen ? 1 : 0,
41
- duration: 200,
42
- easing: Easing.out(Easing.ease),
43
- useNativeDriver: true,
44
- }).start();
45
- }, [isOpen, rotateAnim]);
46
-
47
- const rotate = rotateAnim.interpolate({
48
- inputRange: [0, 1],
49
- outputRange: ["0deg", "180deg"],
50
- });
51
-
52
-
53
31
  const handlePress = () => {
54
32
  if (disabled) return;
55
33
 
56
- triggerRef.current?.measureInWindow((x, y, width, height) => {
57
- setDropdownLayout({
58
- top: y + height + 4,
59
- left: x,
60
- width: width,
61
- });
62
- setIsOpen(true);
63
- });
64
- };
65
-
66
- const handleClose = () => {
67
- setIsOpen(false);
34
+ onActiveChange(!isActive);
68
35
  };
69
36
 
70
37
  const textStyle = cva("text-chia-900", {
@@ -89,6 +56,9 @@ export function Dropdown(props: DropdownProps) {
89
56
  },
90
57
  });
91
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
+
92
62
  const triggerPositionStyle = cva("flex-row w-full", {
93
63
  variants: {
94
64
  align: {
@@ -136,7 +106,7 @@ export function Dropdown(props: DropdownProps) {
136
106
  <Pressable
137
107
  onPress={handlePress}
138
108
  disabled={disabled}
139
- className={dropdownStyle({ size, corner })}
109
+ className={triggerStyle}
140
110
  >
141
111
  <View className="flex-row justify-between items-center">
142
112
  <View className="">
@@ -164,13 +134,13 @@ export function Dropdown(props: DropdownProps) {
164
134
  {leftButtonText}
165
135
  </Typography>
166
136
  )}
167
- <Animated.View
137
+ <View
168
138
  style={{
169
- transform: [{ rotate }],
139
+ transform: [{ rotate: isActive ? "180deg" : "0deg" }],
170
140
  }}
171
141
  >
172
142
  <ArrowChevronDownStroke size={24} className="text-chia-900" />
173
- </Animated.View>
143
+ </View>
174
144
  </View>
175
145
  </View>
176
146
  </Pressable>
@@ -178,36 +148,18 @@ export function Dropdown(props: DropdownProps) {
178
148
  }
179
149
 
180
150
  return (
181
- <>
182
- <View ref={triggerRef} className={className}>
151
+ <View className={className}>
152
+ <View className="relative">
183
153
  {renderTrigger()}
184
- </View>
185
154
 
186
- <Modal
187
- visible={isOpen}
188
- transparent
189
- animationType="fade"
190
- onRequestClose={handleClose}
191
- >
192
- <TouchableWithoutFeedback onPress={handleClose}>
193
- <View className="flex-1">
194
- <TouchableWithoutFeedback>
195
- <View
196
- style={{
197
- position: "absolute",
198
- top: dropdownLayout.top,
199
- left: dropdownLayout.left,
200
- width: dropdownLayout.width,
201
- zIndex: 9999,
202
- }}
203
- className="bg-white border border-gray-200 rounded-xl shadow-lg"
204
- >
205
- {children}
206
- </View>
207
- </TouchableWithoutFeedback>
208
- </View>
209
- </TouchableWithoutFeedback>
210
- </Modal>
211
- </>
155
+ {isActive && (
156
+ <>
157
+ <View className={boxStyle}>
158
+ {children}
159
+ </View>
160
+ </>
161
+ )}
162
+ </View>
163
+ </View>
212
164
  );
213
165
  }
@@ -8,6 +8,7 @@ export interface DropdownProps {
8
8
  placeholder?: string;
9
9
  disabled?: boolean;
10
10
  className?: string;
11
+ contentBoxClassName?: string;
11
12
  leftButtonText?: string;
12
13
  hidePlaceholder?: boolean;
13
14
  children: ReactNode;
@@ -15,4 +16,6 @@ export interface DropdownProps {
15
16
  iconButtonAlign?: "left" | "right" | "center";
16
17
  size?: SizeEnum.SMALL | SizeEnum.MEDIUM;
17
18
  corner?: SizeEnum.SMALL | SizeEnum.MEDIUM;
19
+ isActive: boolean;
20
+ onActiveChange: (isActive: boolean) => void;
18
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
  };
@@ -6,4 +6,5 @@ export enum ListButtonVariantEnum {
6
6
  BLACKBERRY = "blackberry",
7
7
  CHIA = "chia",
8
8
  OUTLINE = "outline",
9
+ GHOST = "ghost",
9
10
  }
@@ -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,4 @@
1
+ export enum TextAreaInputCornersEnum {
2
+ SMALL = "small",
3
+ MEDIUM = "medium",
4
+ }
@@ -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
+ }
@@ -0,0 +1,28 @@
1
+ import {
2
+ TextInputProps as RNTextInputProps,
3
+ TextInput as RNTextInput,
4
+ } from "react-native";
5
+ import { TextAreaInputCornersEnum } from "./enums";
6
+
7
+ export type TextAreaInputCorners = TextAreaInputCornersEnum;
8
+
9
+ export interface TextAreaInputProps
10
+ extends Omit<RNTextInputProps, "value" | "onChangeText"> {
11
+ corners?: TextAreaInputCorners;
12
+ label?: string;
13
+ value?: string;
14
+ disabled?: boolean;
15
+ error?: string;
16
+ className?: string;
17
+ inputClassName?: string;
18
+ labelClassName?: string;
19
+ containerTestID?: string;
20
+ tooltipClassName?: string;
21
+ tooltipPointerClassName?: string;
22
+ tooltipContainerClassName?: string;
23
+ maxLength?: number;
24
+ showMaxLength?: boolean;
25
+ insideLabel?: boolean;
26
+ onChangeText?: (text: string) => void;
27
+ ref?: React.RefObject<RNTextInput | null>;
28
+ }
@@ -50,6 +50,7 @@ export * from "./Toast/enums";
50
50
  export type * from "./Toast/types";
51
51
 
52
52
  export * from "./Tooltip";
53
+ export * from "./Tooltip/enum";
53
54
  export type * from "./Tooltip/types";
54
55
 
55
56
  export * from "./ListButton";
@@ -92,3 +93,7 @@ export type * from "./Tab/types";
92
93
 
93
94
  export * from "./Dropdown";
94
95
  export type * from "./Dropdown/types";
96
+
97
+ export * from "./TextAreaInput";
98
+ export * from "./TextAreaInput/enums";
99
+ export type * from "./TextAreaInput/types";