gbs-add-block 1.2.5 → 1.2.6

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 (v1.2.5)
1
+ # GBS Building Blocks 2.0 (v1.2.6)
2
2
 
3
3
  Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
4
4
 
@@ -6,10 +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://gramprokit.vercel.app)
8
8
 
9
- ## What's New 🎉 (Ver 1.2.5)
9
+ ## What's New 🎉 (Ver 1.2.6)
10
10
 
11
- - Bar Chart Improvement
12
- - Data Grid Style Update
11
+ - UI Update (Canditate update for next major change 2.0.0)
13
12
 
14
13
  ## Authors
15
14
 
package/package.json CHANGED
@@ -1,30 +1,36 @@
1
- {
2
- "name": "gbs-add-block",
3
- "version": "1.2.5",
4
- "description": "React Component Library",
5
- "type": "module",
6
- "files": [
7
- "index.cjs",
8
- "source"
9
- ],
10
- "engines": {
11
- "node": ">=17"
12
- },
13
- "bin": {
14
- "gbs-add-block": "index.cjs"
15
- },
16
- "scripts": {
17
- "test": "echo \"Error: no test specified\" && exit 1"
18
- },
19
- "keywords": [],
20
- "author": "Anandhu Remanan",
21
- "license": "ISC",
22
- "dependencies": {
23
- "fs-extra": "^11.0.4",
24
- "path": "^0.12.7",
25
- "yargs": "^17.7.2"
26
- },
27
- "devDependencies": {
28
- "@types/fs-extra": "^11.0.4"
29
- }
30
- }
1
+ {
2
+ "name": "gbs-add-block",
3
+ "version": "1.2.6",
4
+ "description": "React Component Library",
5
+ "type": "module",
6
+ "files": [
7
+ "index.cjs",
8
+ "source"
9
+ ],
10
+ "engines": {
11
+ "node": ">=17"
12
+ },
13
+ "bin": {
14
+ "gbs-add-block": "index.cjs"
15
+ },
16
+ "scripts": {
17
+ "test": "echo \"Error: no test specified\" && exit 1"
18
+ },
19
+ "keywords": [],
20
+ "author": "Anandhu Remanan",
21
+ "license": "ISC",
22
+ "dependencies": {
23
+ "fs-extra": "^11.0.4",
24
+ "path": "^0.12.7",
25
+ "yargs": "^17.7.2",
26
+ "@grampro/headless-helpers": "^1.0.21",
27
+ "tailwind-merge": "^3.6.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/fs-extra": "^11.0.4"
31
+ },
32
+ "peerDependencies": {
33
+ "react": "^19.0.0",
34
+ "react-dom": "^19.0.0"
35
+ }
36
+ }
@@ -1,25 +1,42 @@
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
-
8
- import React, { type ButtonHTMLAttributes, type ReactNode } from "react";
9
-
10
- interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
11
- children?: ReactNode;
12
- buttonClass?: string;
13
- }
14
-
15
- export const Button = ({
16
- children,
17
- buttonClass = "px-2 py-1 bg-black text-white rounded-md hover:bg-gray-700",
18
- ...props
19
- }: ButtonProps) => {
20
- return (
21
- <button className={buttonClass} {...props}>
22
- {children}
23
- </button>
24
- );
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
+
8
+ import React, { type ButtonHTMLAttributes, type ReactNode } from "react";
9
+ import { twMerge } from "tailwind-merge";
10
+ import { buttonStyles } from "../../globalStyle";
11
+ import type { ComponentSize, ComponentVariant } from "../../theme";
12
+
13
+ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
14
+ children?: ReactNode;
15
+ variant?: ComponentVariant;
16
+ size?: ComponentSize;
17
+ buttonClass?: string;
18
+ }
19
+
20
+ export const Button = ({
21
+ children,
22
+ variant = "primary",
23
+ size = "md",
24
+ buttonClass,
25
+ className,
26
+ ...props
27
+ }: ButtonProps) => {
28
+ return (
29
+ <button
30
+ className={twMerge(
31
+ buttonStyles.base,
32
+ buttonStyles.sizes[size],
33
+ buttonStyles.variants[variant],
34
+ className,
35
+ buttonClass
36
+ )}
37
+ {...props}
38
+ >
39
+ {children}
40
+ </button>
41
+ );
25
42
  };
@@ -1,10 +1,31 @@
1
- import React, { type ReactNode } from "react";
2
-
3
- interface CardProps {
4
- children?: ReactNode;
5
- cardClass?: string;
6
- }
7
-
8
- export function Card({ children, cardClass = "shadow-md rounded-xl p-4" }: CardProps) {
9
- return <div className={cardClass}>{children}</div>;
1
+ import React, { type HTMLAttributes, type ReactNode } from "react";
2
+ import { twMerge } from "tailwind-merge";
3
+ import { cardStyles } from "../../globalStyle";
4
+
5
+ interface CardProps extends HTMLAttributes<HTMLDivElement> {
6
+ children?: ReactNode;
7
+ cardClass?: string;
8
+ interactive?: boolean;
9
+ }
10
+
11
+ export function Card({
12
+ children,
13
+ cardClass,
14
+ className,
15
+ interactive = false,
16
+ ...props
17
+ }: CardProps) {
18
+ return (
19
+ <div
20
+ className={twMerge(
21
+ cardStyles.base,
22
+ interactive ? cardStyles.interactive : "",
23
+ className,
24
+ cardClass
25
+ )}
26
+ {...props}
27
+ >
28
+ {children}
29
+ </div>
30
+ );
10
31
  }
@@ -1,16 +1,25 @@
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
-
8
- import React, { type InputHTMLAttributes } from "react";
9
-
10
- export const Checkbox = ({
11
- ...props
12
- }: InputHTMLAttributes<HTMLInputElement>) => {
13
- return (
14
- <input type="checkbox" className="w-5 h-5 cursor-pointer" {...props} />
15
- );
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
+
8
+ import React, { type InputHTMLAttributes } from "react";
9
+ import { twMerge } from "tailwind-merge";
10
+
11
+ export const Checkbox = ({
12
+ className,
13
+ ...props
14
+ }: InputHTMLAttributes<HTMLInputElement>) => {
15
+ return (
16
+ <input
17
+ type="checkbox"
18
+ className={twMerge(
19
+ "h-5 w-5 cursor-pointer rounded border-slate-300 text-sky-600 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-55",
20
+ className
21
+ )}
22
+ {...props}
23
+ />
24
+ );
16
25
  };
@@ -17,7 +17,7 @@ import {
17
17
  import Icon from "../icon/Icon";
18
18
  import { calender, down, leftArrow, rightArrow, x } from "../icon/iconPaths";
19
19
  import type { DatePickerProps } from "./types";
20
- import { iconClass, popUp, primary } from "../globalStyle";
20
+ import { iconClass, popUp, primary } from "../../globalStyle";
21
21
 
22
22
  export const DatePicker = ({
23
23
  selectedDateValue,
@@ -362,3 +362,4 @@ export const DatePicker = ({
362
362
  </div>
363
363
  );
364
364
  };
365
+
@@ -1,144 +1,142 @@
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
-
8
- import React, { useState, useRef } from "react";
9
- import { twMerge } from "tailwind-merge";
10
- import Icon from "../icon/Icon";
11
- import { eye, search } from "../icon/iconPaths";
12
- import type { InputProps } from "./types";
13
- import { iconClass, inputStyles, primary } from "../globalStyle";
14
-
15
- export const Input = ({
16
- OTPField = false,
17
- OTPValue = "",
18
- OTPLength = 4,
19
- OTPClass = inputStyles.otp,
20
- onOTPValueChange,
21
- error = undefined,
22
- ...props
23
- }: InputProps) => {
24
- const [otpValues, setOtpValues] = useState(new Array(OTPLength).fill(""));
25
- const [showPassword, setShowPassword] = useState(false);
26
- const inputRefs = useRef<(HTMLInputElement | null)[]>([]);
27
-
28
- const updateOtpValue = (
29
- index: number,
30
- e: React.ChangeEvent<HTMLInputElement>
31
- ) => {
32
- e.preventDefault();
33
- const input = e.target;
34
- if (input) {
35
- const newOtpValues = [...otpValues];
36
- newOtpValues[index] = input.value;
37
- setOtpValues(newOtpValues);
38
- if (index < OTPLength - 1 && input.value) {
39
- inputRefs.current[index + 1]?.focus();
40
- }
41
- OTPValue = newOtpValues.join("");
42
- if (onOTPValueChange) onOTPValueChange(OTPValue);
43
- }
44
- };
45
-
46
- const handleKeydown = (
47
- index: number,
48
- e: React.KeyboardEvent<HTMLInputElement>
49
- ) => {
50
- if (e.key === "Backspace" && otpValues[index] === "" && index > 0) {
51
- inputRefs.current[index - 1]?.focus();
52
- } else if (e.key === "ArrowLeft" && index > 0) {
53
- e.preventDefault();
54
- inputRefs.current[index - 1]?.focus();
55
- setTimeout(() => {
56
- if (inputRefs.current[index - 1]) {
57
- const inputEl = inputRefs.current[index - 1];
58
- if (inputEl) {
59
- const length = inputEl.value.length;
60
- inputEl.setSelectionRange(length, length);
61
- }
62
- }
63
- }, 0);
64
- } else if (e.key === "ArrowRight" && index < OTPLength - 1) {
65
- e.preventDefault();
66
- inputRefs.current[index + 1]?.focus();
67
- setTimeout(() => {
68
- if (inputRefs.current[index + 1]) {
69
- const inputEl = inputRefs.current[index + 1];
70
- if (inputEl) {
71
- const length = inputEl.value.length;
72
- inputEl.setSelectionRange(length, length);
73
- }
74
- }
75
- }, 0);
76
- }
77
- };
78
-
79
- const toggleTypeForPassword = () => {
80
- setShowPassword(!showPassword);
81
- };
82
-
83
- return (
84
- <div>
85
- {!OTPField ? (
86
- <div className="text-input-container w-full relative flex flex-col">
87
- <div className="relative">
88
- <input
89
- className={twMerge(
90
- inputStyles.default,
91
- error ? inputStyles.error : "",
92
- "w-full text-black pr-10"
93
- )}
94
- {...props}
95
- type={
96
- props.type === "password" && showPassword ? "text" : props.type
97
- }
98
- />
99
- {props.type === "search" && (
100
- <div className="absolute inset-y-0 right-2 flex items-center">
101
- <Icon elements={search} svgClass={iconClass["grey-common"]} />
102
- </div>
103
- )}
104
- {props.type === "password" && (
105
- <button
106
- type="button"
107
- className="absolute inset-y-0 right-2 flex items-center"
108
- onClick={toggleTypeForPassword}
109
- >
110
- <Icon
111
- elements={eye}
112
- svgClass={
113
- error ? iconClass["error-icon"] : iconClass["grey-common"]
114
- }
115
- />
116
- </button>
117
- )}
118
- </div>
119
- {error && <div className={primary["error-primary"]}>{error}</div>}
120
- </div>
121
- ) : (
122
- <div className={inputStyles.otpContainer}>
123
- {Array(OTPLength)
124
- .fill("")
125
- .map((_, index) => (
126
- <input
127
- key={index}
128
- type="text"
129
- maxLength={1}
130
- pattern="[0-9]*"
131
- value={otpValues[index]}
132
- onChange={(e) => updateOtpValue(index, e)}
133
- onKeyDown={(e) => handleKeydown(index, e)}
134
- ref={(ref) => {
135
- inputRefs.current[index] = ref;
136
- }}
137
- className={OTPClass}
138
- />
139
- ))}
140
- </div>
141
- )}
142
- </div>
143
- );
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
+
8
+ import React, { useState, useRef } from "react";
9
+ import { twMerge } from "tailwind-merge";
10
+ import Icon from "../icon/Icon";
11
+ import { eye, search } from "../icon/iconPaths";
12
+ import type { InputProps } from "./types";
13
+ import { iconClass, inputStyles, primary } from "../../globalStyle";
14
+
15
+ export const Input = ({
16
+ OTPField = false,
17
+ OTPValue = "",
18
+ OTPLength = 4,
19
+ OTPClass = inputStyles.otp,
20
+ onOTPValueChange,
21
+ error = undefined,
22
+ className,
23
+ ...props
24
+ }: InputProps) => {
25
+ const [otpValues, setOtpValues] = useState(new Array(OTPLength).fill(""));
26
+ const [showPassword, setShowPassword] = useState(false);
27
+ const inputRefs = useRef<(HTMLInputElement | null)[]>([]);
28
+
29
+ const updateOtpValue = (
30
+ index: number,
31
+ e: React.ChangeEvent<HTMLInputElement>
32
+ ) => {
33
+ e.preventDefault();
34
+ const input = e.target;
35
+ if (input) {
36
+ const newOtpValues = [...otpValues];
37
+ newOtpValues[index] = input.value;
38
+ setOtpValues(newOtpValues);
39
+ if (index < OTPLength - 1 && input.value) {
40
+ inputRefs.current[index + 1]?.focus();
41
+ }
42
+ OTPValue = newOtpValues.join("");
43
+ if (onOTPValueChange) onOTPValueChange(OTPValue);
44
+ }
45
+ };
46
+
47
+ const handleKeydown = (
48
+ index: number,
49
+ e: React.KeyboardEvent<HTMLInputElement>
50
+ ) => {
51
+ if (e.key === "Backspace" && otpValues[index] === "" && index > 0) {
52
+ inputRefs.current[index - 1]?.focus();
53
+ } else if (e.key === "ArrowLeft" && index > 0) {
54
+ e.preventDefault();
55
+ inputRefs.current[index - 1]?.focus();
56
+ setTimeout(() => {
57
+ const inputEl = inputRefs.current[index - 1];
58
+ if (inputEl) {
59
+ const length = inputEl.value.length;
60
+ inputEl.setSelectionRange(length, length);
61
+ }
62
+ }, 0);
63
+ } else if (e.key === "ArrowRight" && index < OTPLength - 1) {
64
+ e.preventDefault();
65
+ inputRefs.current[index + 1]?.focus();
66
+ setTimeout(() => {
67
+ const inputEl = inputRefs.current[index + 1];
68
+ if (inputEl) {
69
+ const length = inputEl.value.length;
70
+ inputEl.setSelectionRange(length, length);
71
+ }
72
+ }, 0);
73
+ }
74
+ };
75
+
76
+ const toggleTypeForPassword = () => {
77
+ setShowPassword(!showPassword);
78
+ };
79
+
80
+ return (
81
+ <div>
82
+ {!OTPField ? (
83
+ <div className="text-input-container relative flex w-full flex-col">
84
+ <div className="relative">
85
+ <input
86
+ className={twMerge(
87
+ inputStyles.default,
88
+ error ? inputStyles.error : "",
89
+ "w-full pr-10",
90
+ className
91
+ )}
92
+ {...props}
93
+ type={
94
+ props.type === "password" && showPassword ? "text" : props.type
95
+ }
96
+ />
97
+ {props.type === "search" && (
98
+ <div className="absolute inset-y-0 right-2 flex items-center">
99
+ <Icon elements={search} svgClass={iconClass["grey-common"]} />
100
+ </div>
101
+ )}
102
+ {props.type === "password" && (
103
+ <button
104
+ type="button"
105
+ className="absolute inset-y-0 right-2 flex items-center rounded-md p-1"
106
+ onClick={toggleTypeForPassword}
107
+ >
108
+ <Icon
109
+ elements={eye}
110
+ svgClass={
111
+ error ? iconClass["error-icon"] : iconClass["grey-common"]
112
+ }
113
+ />
114
+ </button>
115
+ )}
116
+ </div>
117
+ {error && <div className={primary["error-primary"]}>{error}</div>}
118
+ </div>
119
+ ) : (
120
+ <div className={inputStyles.otpContainer}>
121
+ {Array(OTPLength)
122
+ .fill("")
123
+ .map((_, index) => (
124
+ <input
125
+ key={index}
126
+ type="text"
127
+ maxLength={1}
128
+ pattern="[0-9]*"
129
+ value={otpValues[index]}
130
+ onChange={(e) => updateOtpValue(index, e)}
131
+ onKeyDown={(e) => handleKeydown(index, e)}
132
+ ref={(ref) => {
133
+ inputRefs.current[index] = ref;
134
+ }}
135
+ className={OTPClass}
136
+ />
137
+ ))}
138
+ </div>
139
+ )}
140
+ </div>
141
+ );
144
142
  };