@trackunit/react-modal 1.14.27 → 1.14.29

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/index.cjs.js CHANGED
@@ -505,31 +505,39 @@ const useModalStack = (isOpen) => {
505
505
  /** Scale factor per modal depth level (5% smaller per level back) */
506
506
  const SCALE_FACTOR_PER_LEVEL = 0.05;
507
507
  /**
508
- * - Modals are used to present critical information or request user input needed to complete a user's workflow.
509
- * - Modals interrupt a user's workflow by design.
510
- * - The modal component provides a foundation for creating dialogs, lightboxes, etc.
511
- * - Modals should always be used with the `useModal` hook.
508
+ * Modal presents critical information or requests user input in an overlay dialog that interrupts the current workflow.
509
+ * It renders inside a Portal with a backdrop overlay, focus trapping, and proper accessibility roles.
510
+ * Modals must always be used together with the `useModal` hook, which manages open/close state and Floating UI integration.
512
511
  *
513
- * @example
514
- * ```tsx
515
- * const parentComponent = () => {
516
- * const modal = useModal();
512
+ * Compose the modal body with `ModalHeader`, `ModalBody`, and `ModalFooter` for consistent structure.
517
513
  *
518
- * return (
519
- * <ChildComponent {...modal} />
520
- * );
521
- * };
514
+ * ### When to use
515
+ * Use Modal for confirmations, forms, or critical information that requires user attention before proceeding.
516
+ *
517
+ * ### When not to use
518
+ * Do not use Modal for non-blocking notifications — use `Notice` or `Alert`.
519
+ * Do not use Modal for simple tooltips or contextual info — use `Popover`.
522
520
  *
523
- * const ChildComponent = ({...modalProps}: UseModalReturnValue) => {
524
- * return (* <Modal {...modalProps}>
525
- * <ModalHeader onClickClose={modalProps.close} heading="My Modal" />
526
- * <ModalBody>
527
- * <p>This is a modal</p>
528
- * </ModalBody>
529
- * <ModalFooter onCancel={modalProps.close} primaryLabel="Cancel" />
530
- * </Modal> *);
521
+ * @example Modal with header, body, and footer
522
+ * ```tsx
523
+ * import { Modal, ModalHeader, ModalBody, ModalFooter, useModal } from "@trackunit/react-modal";
524
+ *
525
+ * const ConfirmDialog = () => {
526
+ * const modal = useModal();
527
+ * return (
528
+ * <>
529
+ * <button onClick={modal.open}>Open</button>
530
+ * <Modal {...modal} size="medium">
531
+ * <ModalHeader onClickClose={modal.close} heading="Confirm Action" />
532
+ * <ModalBody>Are you sure you want to proceed?</ModalBody>
533
+ * <ModalFooter onCancel={modal.close} primaryLabel="Confirm" />
534
+ * </Modal>
535
+ * </>
536
+ * );
531
537
  * };
532
538
  * ```
539
+ * @param {ModalProps} props - The props for the Modal component
540
+ * @returns {ReactElement} Modal component
533
541
  */
534
542
  const Modal = ({ children, isOpen, role = "dialog", "data-testid": dataTestId, className, size, floatingUi, ref, restoreFocus = true, }) => {
535
543
  // For dialogs/modals, Floating UI recommends not using floatingStyles since the modal
package/index.esm.js CHANGED
@@ -503,31 +503,39 @@ const useModalStack = (isOpen) => {
503
503
  /** Scale factor per modal depth level (5% smaller per level back) */
504
504
  const SCALE_FACTOR_PER_LEVEL = 0.05;
505
505
  /**
506
- * - Modals are used to present critical information or request user input needed to complete a user's workflow.
507
- * - Modals interrupt a user's workflow by design.
508
- * - The modal component provides a foundation for creating dialogs, lightboxes, etc.
509
- * - Modals should always be used with the `useModal` hook.
506
+ * Modal presents critical information or requests user input in an overlay dialog that interrupts the current workflow.
507
+ * It renders inside a Portal with a backdrop overlay, focus trapping, and proper accessibility roles.
508
+ * Modals must always be used together with the `useModal` hook, which manages open/close state and Floating UI integration.
510
509
  *
511
- * @example
512
- * ```tsx
513
- * const parentComponent = () => {
514
- * const modal = useModal();
510
+ * Compose the modal body with `ModalHeader`, `ModalBody`, and `ModalFooter` for consistent structure.
515
511
  *
516
- * return (
517
- * <ChildComponent {...modal} />
518
- * );
519
- * };
512
+ * ### When to use
513
+ * Use Modal for confirmations, forms, or critical information that requires user attention before proceeding.
514
+ *
515
+ * ### When not to use
516
+ * Do not use Modal for non-blocking notifications — use `Notice` or `Alert`.
517
+ * Do not use Modal for simple tooltips or contextual info — use `Popover`.
520
518
  *
521
- * const ChildComponent = ({...modalProps}: UseModalReturnValue) => {
522
- * return (* <Modal {...modalProps}>
523
- * <ModalHeader onClickClose={modalProps.close} heading="My Modal" />
524
- * <ModalBody>
525
- * <p>This is a modal</p>
526
- * </ModalBody>
527
- * <ModalFooter onCancel={modalProps.close} primaryLabel="Cancel" />
528
- * </Modal> *);
519
+ * @example Modal with header, body, and footer
520
+ * ```tsx
521
+ * import { Modal, ModalHeader, ModalBody, ModalFooter, useModal } from "@trackunit/react-modal";
522
+ *
523
+ * const ConfirmDialog = () => {
524
+ * const modal = useModal();
525
+ * return (
526
+ * <>
527
+ * <button onClick={modal.open}>Open</button>
528
+ * <Modal {...modal} size="medium">
529
+ * <ModalHeader onClickClose={modal.close} heading="Confirm Action" />
530
+ * <ModalBody>Are you sure you want to proceed?</ModalBody>
531
+ * <ModalFooter onCancel={modal.close} primaryLabel="Confirm" />
532
+ * </Modal>
533
+ * </>
534
+ * );
529
535
  * };
530
536
  * ```
537
+ * @param {ModalProps} props - The props for the Modal component
538
+ * @returns {ReactElement} Modal component
531
539
  */
532
540
  const Modal = ({ children, isOpen, role = "dialog", "data-testid": dataTestId, className, size, floatingUi, ref, restoreFocus = true, }) => {
533
541
  // For dialogs/modals, Floating UI recommends not using floatingStyles since the modal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-modal",
3
- "version": "1.14.27",
3
+ "version": "1.14.29",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@floating-ui/react": "^0.26.25",
11
- "@trackunit/react-components": "1.17.22",
11
+ "@trackunit/react-components": "1.17.24",
12
12
  "react": "19.0.0",
13
13
  "@trackunit/css-class-variance-utilities": "1.11.43",
14
14
  "@trackunit/shared-utils": "1.13.43",
@@ -26,31 +26,39 @@ export type ModalProps = PropsWithChildren<UseModalReturnValue & {
26
26
  restoreFocus?: boolean;
27
27
  }>;
28
28
  /**
29
- * - Modals are used to present critical information or request user input needed to complete a user's workflow.
30
- * - Modals interrupt a user's workflow by design.
31
- * - The modal component provides a foundation for creating dialogs, lightboxes, etc.
32
- * - Modals should always be used with the `useModal` hook.
29
+ * Modal presents critical information or requests user input in an overlay dialog that interrupts the current workflow.
30
+ * It renders inside a Portal with a backdrop overlay, focus trapping, and proper accessibility roles.
31
+ * Modals must always be used together with the `useModal` hook, which manages open/close state and Floating UI integration.
33
32
  *
34
- * @example
35
- * ```tsx
36
- * const parentComponent = () => {
37
- * const modal = useModal();
33
+ * Compose the modal body with `ModalHeader`, `ModalBody`, and `ModalFooter` for consistent structure.
38
34
  *
39
- * return (
40
- * <ChildComponent {...modal} />
41
- * );
42
- * };
35
+ * ### When to use
36
+ * Use Modal for confirmations, forms, or critical information that requires user attention before proceeding.
37
+ *
38
+ * ### When not to use
39
+ * Do not use Modal for non-blocking notifications — use `Notice` or `Alert`.
40
+ * Do not use Modal for simple tooltips or contextual info — use `Popover`.
41
+ *
42
+ * @example Modal with header, body, and footer
43
+ * ```tsx
44
+ * import { Modal, ModalHeader, ModalBody, ModalFooter, useModal } from "@trackunit/react-modal";
43
45
  *
44
- * const ChildComponent = ({...modalProps}: UseModalReturnValue) => {
45
- * return (* <Modal {...modalProps}>
46
- * <ModalHeader onClickClose={modalProps.close} heading="My Modal" />
47
- * <ModalBody>
48
- * <p>This is a modal</p>
49
- * </ModalBody>
50
- * <ModalFooter onCancel={modalProps.close} primaryLabel="Cancel" />
51
- * </Modal> *);
46
+ * const ConfirmDialog = () => {
47
+ * const modal = useModal();
48
+ * return (
49
+ * <>
50
+ * <button onClick={modal.open}>Open</button>
51
+ * <Modal {...modal} size="medium">
52
+ * <ModalHeader onClickClose={modal.close} heading="Confirm Action" />
53
+ * <ModalBody>Are you sure you want to proceed?</ModalBody>
54
+ * <ModalFooter onCancel={modal.close} primaryLabel="Confirm" />
55
+ * </Modal>
56
+ * </>
57
+ * );
52
58
  * };
53
59
  * ```
60
+ * @param {ModalProps} props - The props for the Modal component
61
+ * @returns {ReactElement} Modal component
54
62
  */
55
63
  export declare const Modal: {
56
64
  ({ children, isOpen, role, "data-testid": dataTestId, className, size, floatingUi, ref, restoreFocus, }: ModalProps): ReactElement;