gbs-add-block 0.0.54 → 0.0.55
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# GBS Building Blocks 2.0 (v0.0.
|
|
1
|
+
# GBS Building Blocks 2.0 (v0.0.55)
|
|
2
2
|
|
|
3
3
|
Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
|
|
4
4
|
|
|
@@ -6,10 +6,11 @@ Latest and upgraded version of GBS building blocks with headless UI and removed
|
|
|
6
6
|
|
|
7
7
|
For detailed documentation on usage and props, Please visit: [Building Block Documentation v2.0](https://blackmax-designs.gitbook.io/building-block-v2.0)
|
|
8
8
|
|
|
9
|
-
## What's New 🎉 (Ver 0.0.
|
|
9
|
+
## What's New 🎉 (Ver 0.0.55)
|
|
10
10
|
|
|
11
11
|
- Updated for more general installation methods
|
|
12
12
|
- Fixed bug in Framework detection for more accuracy
|
|
13
|
+
- Style Update
|
|
13
14
|
|
|
14
15
|
## Authors
|
|
15
16
|
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React, { useRef } from "react";
|
|
8
|
+
import React, { useEffect, useRef } from "react";
|
|
9
9
|
import {
|
|
10
10
|
useDatePickerState,
|
|
11
11
|
useYearMonthNavigation,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import Icon from "../icon/Icon";
|
|
18
18
|
import { calender, down, leftArrows, rightArrows } from "../icon/iconPaths";
|
|
19
19
|
import type { DatePickerProps } from "./types";
|
|
20
|
-
import { primary } from "../globalStyle";
|
|
20
|
+
import { iconClass, popUp, primary } from "../globalStyle";
|
|
21
21
|
|
|
22
22
|
export const DatePicker = ({
|
|
23
23
|
selectedDateValue,
|
|
@@ -54,6 +54,10 @@ export const DatePicker = ({
|
|
|
54
54
|
hasMounted,
|
|
55
55
|
} = useDatePickerState(selectedDateValue || null);
|
|
56
56
|
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
console.log("selectedDateValue", selectedDate);
|
|
59
|
+
}, [selectedDate]);
|
|
60
|
+
|
|
57
61
|
const { prevMonth, nextMonth } = useYearMonthNavigation(
|
|
58
62
|
currentMonth,
|
|
59
63
|
currentYear,
|
|
@@ -134,10 +138,12 @@ export const DatePicker = ({
|
|
|
134
138
|
<Icon
|
|
135
139
|
dimensions={{ width: "20", height: "20" }}
|
|
136
140
|
elements={calender}
|
|
137
|
-
svgClass={"
|
|
141
|
+
svgClass={iconClass["grey-common"]}
|
|
138
142
|
/>
|
|
139
143
|
<span className={!selectedDate ? "text-gray-400" : ""}>
|
|
140
|
-
{selectedDate
|
|
144
|
+
{selectedDate
|
|
145
|
+
? selectedDate.toLocaleDateString("en-GB")
|
|
146
|
+
: placeholder}
|
|
141
147
|
</span>
|
|
142
148
|
</button>
|
|
143
149
|
{error && <p className={primary["error-primary"]}>{error}</p>}
|
|
@@ -150,7 +156,7 @@ export const DatePicker = ({
|
|
|
150
156
|
/>
|
|
151
157
|
|
|
152
158
|
{showDatepicker && !disabled && (
|
|
153
|
-
<div className="
|
|
159
|
+
<div className={popUp["pop-up-style"]}>
|
|
154
160
|
<div className="flex justify-between items-center p-2">
|
|
155
161
|
<button
|
|
156
162
|
type="button"
|
|
@@ -10,12 +10,13 @@ import { twMerge } from "tailwind-merge";
|
|
|
10
10
|
import Icon from "../icon/Icon";
|
|
11
11
|
import { eye } from "../icon/iconPaths";
|
|
12
12
|
import type { InputProps } from "./types";
|
|
13
|
+
import { iconClass, inputStyles, primary } from "../globalStyle";
|
|
13
14
|
|
|
14
15
|
export const Input = ({
|
|
15
16
|
OTPField = false,
|
|
16
17
|
OTPValue = "",
|
|
17
18
|
OTPLength = 4,
|
|
18
|
-
OTPClass =
|
|
19
|
+
OTPClass = inputStyles.otp,
|
|
19
20
|
onOTPValueChange,
|
|
20
21
|
error = undefined,
|
|
21
22
|
...props
|
|
@@ -24,11 +25,6 @@ export const Input = ({
|
|
|
24
25
|
const [showPassword, setShowPassword] = useState(false);
|
|
25
26
|
const inputRefs = useRef<(HTMLInputElement | null)[]>([]);
|
|
26
27
|
|
|
27
|
-
const defaultClass = `bg-gray-100 p-2 rounded-lg ${
|
|
28
|
-
error ? "border border-red-600" : ""
|
|
29
|
-
}`;
|
|
30
|
-
|
|
31
|
-
// This will update the OTP Field Value
|
|
32
28
|
const updateOtpValue = (
|
|
33
29
|
index: number,
|
|
34
30
|
e: React.ChangeEvent<HTMLInputElement>
|
|
@@ -47,7 +43,6 @@ export const Input = ({
|
|
|
47
43
|
}
|
|
48
44
|
};
|
|
49
45
|
|
|
50
|
-
// Function for handling keyboard navigation in OTP Field
|
|
51
46
|
const handleKeydown = (
|
|
52
47
|
index: number,
|
|
53
48
|
e: React.KeyboardEvent<HTMLInputElement>
|
|
@@ -61,7 +56,6 @@ export const Input = ({
|
|
|
61
56
|
}
|
|
62
57
|
};
|
|
63
58
|
|
|
64
|
-
// Password Feild Toggler
|
|
65
59
|
const toggleTypeForPassword = () => {
|
|
66
60
|
setShowPassword(!showPassword);
|
|
67
61
|
};
|
|
@@ -69,34 +63,38 @@ export const Input = ({
|
|
|
69
63
|
return (
|
|
70
64
|
<div>
|
|
71
65
|
{!OTPField ? (
|
|
72
|
-
<div className="text-input-container w-full relative">
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
<div className="text-input-container w-full relative flex flex-col">
|
|
67
|
+
<div className="relative">
|
|
68
|
+
<input
|
|
69
|
+
className={twMerge(
|
|
70
|
+
inputStyles.default,
|
|
71
|
+
error ? inputStyles.error : "",
|
|
72
|
+
"w-full text-black pr-10"
|
|
73
|
+
)}
|
|
74
|
+
{...props}
|
|
75
|
+
type={
|
|
76
|
+
props.type === "password" && showPassword ? "text" : props.type
|
|
77
|
+
}
|
|
78
|
+
/>
|
|
79
|
+
{props.type === "password" && (
|
|
80
|
+
<button
|
|
81
|
+
type="button"
|
|
82
|
+
className="absolute inset-y-0 right-2 flex items-center"
|
|
83
|
+
onClick={toggleTypeForPassword}
|
|
84
|
+
>
|
|
85
|
+
<Icon
|
|
86
|
+
elements={eye}
|
|
87
|
+
svgClass={
|
|
88
|
+
error ? iconClass["error-icon"] : iconClass["grey-common"]
|
|
89
|
+
}
|
|
90
|
+
/>
|
|
91
|
+
</button>
|
|
77
92
|
)}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
props.type === "password" && showPassword ? "text" : props.type
|
|
81
|
-
}
|
|
82
|
-
/>
|
|
83
|
-
{/* If Type is password, this will show a password visible toggle button */}
|
|
84
|
-
{props.type && props.type === "password" && (
|
|
85
|
-
<button
|
|
86
|
-
type="button"
|
|
87
|
-
className="absolute inset-y-0 right-0 flex items-center pr-2"
|
|
88
|
-
onClick={toggleTypeForPassword}
|
|
89
|
-
>
|
|
90
|
-
<Icon
|
|
91
|
-
elements={eye}
|
|
92
|
-
svgClass={"h-5 w-5 stroke-gray-500 fill-none dark:stroke-white"}
|
|
93
|
-
/>
|
|
94
|
-
</button>
|
|
95
|
-
)}
|
|
96
|
-
{error && <div className="text-xs text-red-500">{error}</div>}
|
|
93
|
+
</div>
|
|
94
|
+
{error && <div className={primary["error-primary"]}>{error}</div>}
|
|
97
95
|
</div>
|
|
98
96
|
) : (
|
|
99
|
-
<div className=
|
|
97
|
+
<div className={inputStyles.otpContainer}>
|
|
100
98
|
{Array(OTPLength)
|
|
101
99
|
.fill("")
|
|
102
100
|
.map((_, index) => (
|
package/source/globalStyle.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const primary = {
|
|
2
2
|
"error-border": "border border-red-600",
|
|
3
|
-
"error-primary": "text-xs text-red-500",
|
|
3
|
+
"error-primary": "text-xs text-red-500 pl-1",
|
|
4
4
|
};
|
|
5
5
|
|
|
6
6
|
export const popUp = {
|
|
@@ -9,5 +9,14 @@ export const popUp = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export const iconClass = {
|
|
12
|
-
"grey-common": "h-4 w-4 stroke-gray-500 fill-none dark:stroke-
|
|
12
|
+
"grey-common": "h-4 w-4 stroke-gray-500 fill-none dark:stroke-black",
|
|
13
|
+
"error-icon": "h-4 w-4 stroke-red-500 fill-none dark:stroke-red-500",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const inputStyles = {
|
|
17
|
+
default: "bg-gray-100 p-2 rounded-lg focus:outline-black",
|
|
18
|
+
error: "border border-red-600",
|
|
19
|
+
otp: "w-8 h-10 m-1 border border-gray-600 rounded-lg text-center text-black",
|
|
20
|
+
passwordToggle: "absolute inset-y-0 right-0 flex items-center pr-2",
|
|
21
|
+
otpContainer: "otp-container",
|
|
13
22
|
};
|