gbs-add-block 0.0.65 → 0.0.67
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 +2 -2
- package/index.js +6 -57
- package/package.json +1 -1
- package/source/components/modal/index.tsx +16 -12
- package/source/components/modal/types.ts +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# GBS Building Blocks 2.0 (v0.0.
|
|
1
|
+
# GBS Building Blocks 2.0 (v0.0.66)
|
|
2
2
|
|
|
3
3
|
Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ 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.66)
|
|
10
10
|
|
|
11
11
|
- Updated for bug fixes.
|
|
12
12
|
- New component "Skeleton", "Breadcrumb" & "Navbar" Added.
|
package/index.js
CHANGED
|
@@ -33,20 +33,11 @@ const CONFIG = {
|
|
|
33
33
|
dependencies: {
|
|
34
34
|
FormRenderer: ["Select", "MultiSelect", "Input", "DatePicker"],
|
|
35
35
|
},
|
|
36
|
-
frameworks: {
|
|
37
|
-
next: {
|
|
38
|
-
name: "Next.js",
|
|
39
|
-
path: ["app", "component-lib"],
|
|
40
|
-
},
|
|
41
|
-
vite: {
|
|
42
|
-
name: "Vite",
|
|
43
|
-
path: ["src", "component-lib"],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
36
|
docs: "https://blackmax-designs.gitbook.io/building-block-v2.0",
|
|
47
37
|
};
|
|
48
38
|
|
|
49
39
|
const SOURCE_PATH = path.join(__dirname, "source", "components");
|
|
40
|
+
const DEFAULT_DEST_PATH = path.join(process.cwd(), "component-lib");
|
|
50
41
|
|
|
51
42
|
const copyCommonFiles = async (destPath) => {
|
|
52
43
|
const commonFiles = [
|
|
@@ -80,8 +71,9 @@ const copyComponent = async (component, destPath) => {
|
|
|
80
71
|
await fs.copy(componentSrc, componentDest, { overwrite: true });
|
|
81
72
|
console.log(
|
|
82
73
|
`✓ Component ${component} installed successfully ${
|
|
83
|
-
component === "Grid"
|
|
84
|
-
|
|
74
|
+
component === "Grid"
|
|
75
|
+
? "This Version of Grid will be deprecated soon. Please Install The New Data Grid Component"
|
|
76
|
+
: ""
|
|
85
77
|
}`
|
|
86
78
|
);
|
|
87
79
|
} catch (error) {
|
|
@@ -122,24 +114,6 @@ const installComponentWithDependencies = async (component, destPath) => {
|
|
|
122
114
|
console.log(`\nFor documentation visit: ${CONFIG.docs}`);
|
|
123
115
|
};
|
|
124
116
|
|
|
125
|
-
const detectFramework = () => {
|
|
126
|
-
// Check for Next.js
|
|
127
|
-
if (
|
|
128
|
-
fs.existsSync(path.join(process.cwd(), "next.config.ts")) ||
|
|
129
|
-
fs.existsSync(path.join(process.cwd(), "next.config.js"))
|
|
130
|
-
) {
|
|
131
|
-
return "next";
|
|
132
|
-
}
|
|
133
|
-
// Check for Vite
|
|
134
|
-
if (
|
|
135
|
-
fs.existsSync(path.join(process.cwd(), "vite.config.js")) ||
|
|
136
|
-
fs.existsSync(path.join(process.cwd(), "vite.config.ts"))
|
|
137
|
-
) {
|
|
138
|
-
return "vite";
|
|
139
|
-
}
|
|
140
|
-
return null;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
117
|
const main = async () => {
|
|
144
118
|
const argv = yargs(hideBin(process.argv))
|
|
145
119
|
.option("add", {
|
|
@@ -147,11 +121,6 @@ const main = async () => {
|
|
|
147
121
|
describe: "Component to install",
|
|
148
122
|
type: "string",
|
|
149
123
|
})
|
|
150
|
-
.option("framework", {
|
|
151
|
-
alias: "f",
|
|
152
|
-
describe: "Framework to use (next or vite)",
|
|
153
|
-
type: "string",
|
|
154
|
-
})
|
|
155
124
|
.option("list", {
|
|
156
125
|
alias: "l",
|
|
157
126
|
describe: "List available components",
|
|
@@ -185,28 +154,8 @@ const main = async () => {
|
|
|
185
154
|
process.exit(1);
|
|
186
155
|
}
|
|
187
156
|
|
|
188
|
-
//
|
|
189
|
-
|
|
190
|
-
if (!framework) {
|
|
191
|
-
framework = detectFramework();
|
|
192
|
-
if (!framework) {
|
|
193
|
-
console.error(
|
|
194
|
-
"Could not detect framework. Please specify using -f or --framework"
|
|
195
|
-
);
|
|
196
|
-
process.exit(1);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (!CONFIG.frameworks[framework]) {
|
|
201
|
-
console.error(`Unsupported framework: ${framework}`);
|
|
202
|
-
process.exit(1);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Create destination directory
|
|
206
|
-
const destPath = path.join(
|
|
207
|
-
process.cwd(),
|
|
208
|
-
...CONFIG.frameworks[framework].path
|
|
209
|
-
);
|
|
157
|
+
// Create destination directory in project root
|
|
158
|
+
const destPath = DEFAULT_DEST_PATH;
|
|
210
159
|
await fs.ensureDir(destPath);
|
|
211
160
|
|
|
212
161
|
// Copy common files if they don't exist
|
package/package.json
CHANGED
|
@@ -12,19 +12,19 @@ import { x } from "../icon/iconPaths";
|
|
|
12
12
|
import { ModalProps } from "./types";
|
|
13
13
|
|
|
14
14
|
const defaultClasses = {
|
|
15
|
-
modal:
|
|
16
|
-
"fixed z-10 overflow-y-auto inset-0 flex items-center justify-center bg-gray-500 bg-opacity-75 transition-opacity",
|
|
15
|
+
modal: "fixed z-10 overflow-y-auto inset-0 flex items-center justify-center",
|
|
17
16
|
modalContent: "bg-white m-10 md:w-[80vh] rounded-xl relative",
|
|
18
17
|
modalTitle:
|
|
19
18
|
"p-4 text-lg leading-6 font-medium text-gray-900 flex justify-between items-center",
|
|
20
19
|
closeButton:
|
|
21
20
|
"p-2 hover:bg-gray-100 rounded-full transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-gray-300",
|
|
22
|
-
closeIcon: "h-5 w-5 stroke-gray-500 fill-none
|
|
21
|
+
closeIcon: "h-5 w-5 stroke-gray-500 fill-none",
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
export const Modal = memo(
|
|
26
25
|
({
|
|
27
26
|
showModal = false,
|
|
27
|
+
setShowModal,
|
|
28
28
|
modalTitle = "Modal Title",
|
|
29
29
|
modalClass = defaultClasses.modal,
|
|
30
30
|
modalContentClass = defaultClasses.modalContent,
|
|
@@ -33,7 +33,6 @@ export const Modal = memo(
|
|
|
33
33
|
classModalTitle = "",
|
|
34
34
|
children,
|
|
35
35
|
showCloseButton = false,
|
|
36
|
-
onClose,
|
|
37
36
|
dismissible = false,
|
|
38
37
|
titleId = "modal-title",
|
|
39
38
|
closeButtonContent,
|
|
@@ -45,23 +44,28 @@ export const Modal = memo(
|
|
|
45
44
|
// Handle ESC key press to close modal
|
|
46
45
|
const handleEscKey = useCallback(
|
|
47
46
|
(event: KeyboardEvent) => {
|
|
48
|
-
if (event.key === "Escape" && showModal &&
|
|
49
|
-
|
|
47
|
+
if (event.key === "Escape" && showModal && dismissible) {
|
|
48
|
+
setShowModal(false);
|
|
50
49
|
}
|
|
51
50
|
},
|
|
52
|
-
[showModal,
|
|
51
|
+
[showModal, dismissible, setShowModal]
|
|
53
52
|
);
|
|
54
53
|
|
|
55
54
|
// Handle click outside modal to close
|
|
56
55
|
const handleOutsideClick = useCallback(
|
|
57
56
|
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
58
|
-
if (
|
|
59
|
-
|
|
57
|
+
if (e.target === e.currentTarget && dismissible) {
|
|
58
|
+
setShowModal(false);
|
|
60
59
|
}
|
|
61
60
|
},
|
|
62
|
-
[
|
|
61
|
+
[dismissible, setShowModal]
|
|
63
62
|
);
|
|
64
63
|
|
|
64
|
+
// Handle close button click
|
|
65
|
+
const handleClose = useCallback(() => {
|
|
66
|
+
setShowModal(false);
|
|
67
|
+
}, [setShowModal]);
|
|
68
|
+
|
|
65
69
|
// Manage focus trap and keyboard events
|
|
66
70
|
useEffect(() => {
|
|
67
71
|
if (showModal) {
|
|
@@ -110,9 +114,9 @@ export const Modal = memo(
|
|
|
110
114
|
>
|
|
111
115
|
<div className={twMerge(modalTitleClass, classModalTitle)}>
|
|
112
116
|
<h2 id={titleId}>{modalTitle}</h2>
|
|
113
|
-
{showCloseButton &&
|
|
117
|
+
{showCloseButton && (
|
|
114
118
|
<button
|
|
115
|
-
onClick={
|
|
119
|
+
onClick={handleClose}
|
|
116
120
|
className={defaultClasses.closeButton}
|
|
117
121
|
aria-label="Close modal"
|
|
118
122
|
type="button"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type ModalProps = {
|
|
2
2
|
showModal?: boolean;
|
|
3
|
+
setShowModal: (show: boolean) => void;
|
|
3
4
|
modalTitle?: string;
|
|
4
5
|
modalClass?: string;
|
|
5
6
|
modalContentClass?: string;
|
|
@@ -8,7 +9,6 @@ export type ModalProps = {
|
|
|
8
9
|
classModalTitle?: string;
|
|
9
10
|
children: React.ReactNode;
|
|
10
11
|
showCloseButton?: boolean;
|
|
11
|
-
onClose?: () => void;
|
|
12
12
|
dismissible?: boolean;
|
|
13
13
|
titleId?: string;
|
|
14
14
|
closeButtonContent?: React.ReactNode;
|