gbs-add-block 0.0.56 → 0.0.58

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.55)
1
+ # GBS Building Blocks 2.0 (v0.0.58)
2
2
 
3
3
  Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
4
4
 
@@ -6,11 +6,10 @@ 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.55)
9
+ ## What's New 🎉 (Ver 0.0.58)
10
10
 
11
- - Updated for more general installation methods
12
- - Fixed bug in Framework detection for more accuracy
13
- - Style Update
11
+ - Updated for bug fixes.
12
+ - New component "Skeleton" Added.
14
13
 
15
14
  ## Authors
16
15
 
package/index.js CHANGED
@@ -24,6 +24,7 @@ const CONFIG = {
24
24
  "FormRenderer",
25
25
  "MaterialInput",
26
26
  "ContextMenu",
27
+ "Skeleton",
27
28
  ],
28
29
  // Define component dependencies
29
30
  dependencies: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbs-add-block",
3
- "version": "0.0.56",
3
+ "version": "0.0.58",
4
4
  "description": "React Component Library",
5
5
  "files": [
6
6
  "index.js",
@@ -50,9 +50,29 @@ export const Input = ({
50
50
  if (e.key === "Backspace" && otpValues[index] === "" && index > 0) {
51
51
  inputRefs.current[index - 1]?.focus();
52
52
  } else if (e.key === "ArrowLeft" && index > 0) {
53
+ e.preventDefault();
53
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);
54
64
  } else if (e.key === "ArrowRight" && index < OTPLength - 1) {
65
+ e.preventDefault();
55
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);
56
76
  }
57
77
  };
58
78
 
@@ -0,0 +1,90 @@
1
+ import React, { useMemo, memo } from "react";
2
+
3
+ type SkeletonType = "text" | "circle" | "rectangle";
4
+
5
+ interface SkeletonProps {
6
+ type?: SkeletonType;
7
+ lines?: number;
8
+ height?: string | number;
9
+ width?: string | number;
10
+ className?: string;
11
+ style?: React.CSSProperties;
12
+ animationDuration?: number;
13
+ keyframes?: string;
14
+ }
15
+
16
+ const Skeleton: React.FC<SkeletonProps> = memo(
17
+ ({
18
+ type = "text",
19
+ lines = 1,
20
+ height,
21
+ width,
22
+ className = "",
23
+ style = {},
24
+ animationDuration = 1.5,
25
+ keyframes = `
26
+ @keyframes pulse {
27
+ 0% { opacity: 0.6; }
28
+ 50% { opacity: 1; }
29
+ 100% { opacity: 0.6; }
30
+ }
31
+ `,
32
+ }) => {
33
+ const getStyle = useMemo(() => {
34
+ const baseStyle: React.CSSProperties = {
35
+ backgroundColor: "#e0e0e0",
36
+ borderRadius: "4px",
37
+ animation: `pulse ${animationDuration}s ease-in-out 0.5s infinite`,
38
+ width: width || "100%",
39
+ ...style,
40
+ };
41
+
42
+ switch (type) {
43
+ case "text":
44
+ return {
45
+ ...baseStyle,
46
+ height: height || "16px",
47
+ marginBottom: "8px",
48
+ };
49
+ case "circle":
50
+ return {
51
+ ...baseStyle,
52
+ height: height || "48px",
53
+ width: width || "48px",
54
+ borderRadius: "50%",
55
+ };
56
+ case "rectangle":
57
+ return {
58
+ ...baseStyle,
59
+ height: height || "120px",
60
+ };
61
+ default:
62
+ return baseStyle;
63
+ }
64
+ }, [type, height, width, style, animationDuration]);
65
+
66
+ const renderLines = useMemo(() => {
67
+ if (type !== "text" || lines <= 1) return null;
68
+
69
+ return Array.from({ length: lines - 1 }, (_, index) => (
70
+ <div
71
+ key={index}
72
+ className={`skeleton-line ${className}`}
73
+ style={getStyle}
74
+ />
75
+ ));
76
+ }, [type, lines, className, getStyle]);
77
+
78
+ return (
79
+ <div className="skeleton-wrapper" style={{ width: "100%" }}>
80
+ <style>{keyframes}</style>
81
+ <div className={`skeleton ${className}`} style={getStyle} />
82
+ {renderLines}
83
+ </div>
84
+ );
85
+ }
86
+ );
87
+
88
+ Skeleton.displayName = "Skeleton";
89
+
90
+ export default Skeleton;