gbs-add-block 0.0.66 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- # GBS Building Blocks 2.0 (v0.0.65)
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.65)
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbs-add-block",
3
- "version": "0.0.66",
3
+ "version": "0.0.67",
4
4
  "description": "React Component Library",
5
5
  "files": [
6
6
  "index.js",
@@ -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 dark:stroke-white",
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 && onClose) {
49
- onClose();
47
+ if (event.key === "Escape" && showModal && dismissible) {
48
+ setShowModal(false);
50
49
  }
51
50
  },
52
- [showModal, onClose]
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 (onClose && e.target === e.currentTarget && dismissible) {
59
- onClose();
57
+ if (e.target === e.currentTarget && dismissible) {
58
+ setShowModal(false);
60
59
  }
61
60
  },
62
- [onClose, dismissible]
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 && onClose && (
117
+ {showCloseButton && (
114
118
  <button
115
- onClick={onClose}
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;