gbs-add-block 0.0.66 → 0.0.68

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.65)
1
+ # GBS Building Blocks 2.0 (v0.0.68)
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.65)
9
+ ## What's New 🎉 (Ver 0.0.68)
10
10
 
11
11
  - Updated for bug fixes.
12
12
  - New component "Skeleton", "Breadcrumb" & "Navbar" Added.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbs-add-block",
3
- "version": "0.0.66",
3
+ "version": "0.0.68",
4
4
  "description": "React Component Library",
5
5
  "files": [
6
6
  "index.js",
@@ -13,18 +13,19 @@ import { ModalProps } from "./types";
13
13
 
14
14
  const defaultClasses = {
15
15
  modal:
16
- "fixed z-10 overflow-y-auto inset-0 flex items-center justify-center bg-gray-500 bg-opacity-75 transition-opacity",
16
+ "fixed z-10 overflow-y-auto inset-0 flex items-center justify-center bg-[#2b2426bd]",
17
17
  modalContent: "bg-white m-10 md:w-[80vh] rounded-xl relative",
18
18
  modalTitle:
19
19
  "p-4 text-lg leading-6 font-medium text-gray-900 flex justify-between items-center",
20
20
  closeButton:
21
21
  "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 dark:stroke-white",
22
+ closeIcon: "h-5 w-5 stroke-gray-500 fill-none",
23
23
  };
24
24
 
25
25
  export const Modal = memo(
26
26
  ({
27
27
  showModal = false,
28
+ setShowModal,
28
29
  modalTitle = "Modal Title",
29
30
  modalClass = defaultClasses.modal,
30
31
  modalContentClass = defaultClasses.modalContent,
@@ -33,7 +34,6 @@ export const Modal = memo(
33
34
  classModalTitle = "",
34
35
  children,
35
36
  showCloseButton = false,
36
- onClose,
37
37
  dismissible = false,
38
38
  titleId = "modal-title",
39
39
  closeButtonContent,
@@ -45,23 +45,28 @@ export const Modal = memo(
45
45
  // Handle ESC key press to close modal
46
46
  const handleEscKey = useCallback(
47
47
  (event: KeyboardEvent) => {
48
- if (event.key === "Escape" && showModal && onClose) {
49
- onClose();
48
+ if (event.key === "Escape" && showModal && dismissible) {
49
+ setShowModal(false);
50
50
  }
51
51
  },
52
- [showModal, onClose]
52
+ [showModal, dismissible, setShowModal]
53
53
  );
54
54
 
55
55
  // Handle click outside modal to close
56
56
  const handleOutsideClick = useCallback(
57
57
  (e: React.MouseEvent<HTMLDivElement>) => {
58
- if (onClose && e.target === e.currentTarget && dismissible) {
59
- onClose();
58
+ if (e.target === e.currentTarget && dismissible) {
59
+ setShowModal(false);
60
60
  }
61
61
  },
62
- [onClose, dismissible]
62
+ [dismissible, setShowModal]
63
63
  );
64
64
 
65
+ // Handle close button click
66
+ const handleClose = useCallback(() => {
67
+ setShowModal(false);
68
+ }, [setShowModal]);
69
+
65
70
  // Manage focus trap and keyboard events
66
71
  useEffect(() => {
67
72
  if (showModal) {
@@ -110,9 +115,9 @@ export const Modal = memo(
110
115
  >
111
116
  <div className={twMerge(modalTitleClass, classModalTitle)}>
112
117
  <h2 id={titleId}>{modalTitle}</h2>
113
- {showCloseButton && onClose && (
118
+ {showCloseButton && (
114
119
  <button
115
- onClick={onClose}
120
+ onClick={handleClose}
116
121
  className={defaultClasses.closeButton}
117
122
  aria-label="Close modal"
118
123
  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;