gbs-add-block 0.0.37 → 0.0.38
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.38)
|
|
2
2
|
|
|
3
3
|
Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
|
|
4
4
|
|
|
@@ -6,11 +6,9 @@ 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.38)
|
|
10
10
|
|
|
11
|
-
- Updated
|
|
12
|
-
- Updated Grid
|
|
13
|
-
- Updated DatePicker
|
|
11
|
+
- Updated Material Input Component
|
|
14
12
|
|
|
15
13
|
## Authors
|
|
16
14
|
|
package/package.json
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Grampro Business Services and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import React, { useState, useRef } from "react";
|
|
2
9
|
import { MaterialInputProps } from "./types";
|
|
3
10
|
|
|
@@ -11,9 +18,13 @@ const MaterialInput = ({
|
|
|
11
18
|
required = false,
|
|
12
19
|
disabled = false,
|
|
13
20
|
className = "",
|
|
21
|
+
textarea = false,
|
|
22
|
+
rows = 3,
|
|
23
|
+
cols = 30,
|
|
24
|
+
...props
|
|
14
25
|
}: MaterialInputProps) => {
|
|
15
26
|
const [isFocused, setIsFocused] = useState(false);
|
|
16
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
27
|
+
const inputRef = useRef<HTMLTextAreaElement | HTMLInputElement>(null);
|
|
17
28
|
|
|
18
29
|
const handleFocus = () => setIsFocused(true);
|
|
19
30
|
const handleBlur = () => {
|
|
@@ -27,16 +38,50 @@ const MaterialInput = ({
|
|
|
27
38
|
return (
|
|
28
39
|
<div className={`relative w-full ${className}`}>
|
|
29
40
|
<div className="relative">
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
{textarea ? (
|
|
42
|
+
<textarea
|
|
43
|
+
{...props}
|
|
44
|
+
ref={inputRef as React.RefObject<HTMLTextAreaElement>}
|
|
45
|
+
value={value}
|
|
46
|
+
onChange={(e) => {
|
|
47
|
+
if (onChange) onChange(e.target.value);
|
|
48
|
+
}}
|
|
49
|
+
onFocus={handleFocus}
|
|
50
|
+
onBlur={handleBlur}
|
|
51
|
+
rows={rows}
|
|
52
|
+
cols={cols}
|
|
53
|
+
disabled={disabled}
|
|
54
|
+
required={required}
|
|
55
|
+
className={`
|
|
56
|
+
peer w-full px-3 py-3
|
|
57
|
+
bg-transparent
|
|
58
|
+
border rounded-md
|
|
59
|
+
outline-none
|
|
60
|
+
transition-all duration-200 ease-in-out
|
|
61
|
+
placeholder-transparent
|
|
62
|
+
${
|
|
63
|
+
error
|
|
64
|
+
? "border-red-500 focus:border-red-500"
|
|
65
|
+
: "border-gray-300 focus:border-blue-500"
|
|
66
|
+
}
|
|
67
|
+
${disabled ? "text-gray-400 cursor-not-allowed" : "text-gray-900"}
|
|
68
|
+
`}
|
|
69
|
+
/>
|
|
70
|
+
) : (
|
|
71
|
+
<input
|
|
72
|
+
{...props}
|
|
73
|
+
autoComplete="off"
|
|
74
|
+
ref={inputRef as React.RefObject<HTMLInputElement>}
|
|
75
|
+
type={type}
|
|
76
|
+
value={value}
|
|
77
|
+
onChange={(e) => {
|
|
78
|
+
if (onChange) onChange(e.target.value);
|
|
79
|
+
}}
|
|
80
|
+
onFocus={handleFocus}
|
|
81
|
+
onBlur={handleBlur}
|
|
82
|
+
disabled={disabled}
|
|
83
|
+
required={required}
|
|
84
|
+
className={`
|
|
40
85
|
peer w-full px-3 py-3
|
|
41
86
|
bg-transparent
|
|
42
87
|
border rounded-md
|
|
@@ -50,7 +95,8 @@ const MaterialInput = ({
|
|
|
50
95
|
}
|
|
51
96
|
${disabled ? "text-gray-400 cursor-not-allowed" : "text-gray-900"}
|
|
52
97
|
`}
|
|
53
|
-
|
|
98
|
+
/>
|
|
99
|
+
)}
|
|
54
100
|
<label
|
|
55
101
|
onClick={() => inputRef.current?.focus()}
|
|
56
102
|
className={`
|
|
@@ -58,7 +104,7 @@ const MaterialInput = ({
|
|
|
58
104
|
pointer-events-none
|
|
59
105
|
transition-all duration-200 ease-in-out
|
|
60
106
|
cursor-text
|
|
61
|
-
${isFloating ? "-top-2 text-xs bg-white px-1" : "top-
|
|
107
|
+
${isFloating ? "-top-2 text-xs bg-white px-1" : "top-2 text-base"}
|
|
62
108
|
${
|
|
63
109
|
error
|
|
64
110
|
? "text-red-500"
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from "react";
|
|
2
|
+
|
|
1
3
|
export type MaterialInputProps = {
|
|
2
|
-
label
|
|
4
|
+
label?: string;
|
|
3
5
|
type?: string;
|
|
4
|
-
value
|
|
5
|
-
onChange
|
|
6
|
+
value?: string;
|
|
7
|
+
onChange?: (value: string) => void;
|
|
6
8
|
error?: string;
|
|
7
9
|
helperText?: string;
|
|
8
10
|
required?: boolean;
|
|
9
11
|
disabled?: boolean;
|
|
10
12
|
className?: string;
|
|
11
|
-
|
|
13
|
+
textarea?: boolean;
|
|
14
|
+
rows?: number;
|
|
15
|
+
cols?: number;
|
|
16
|
+
} & InputHTMLAttributes<HTMLInputElement | HTMLTextAreaElement>;
|