@grasp-labs/ds-react-components 0.13.0 → 0.15.0

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.
@@ -10,6 +10,8 @@ export type DialogProps = {
10
10
  closeOnEscape?: boolean;
11
11
  /** Whether to show close button in header */
12
12
  showClose?: boolean;
13
+ /** Accessible label for the close button */
14
+ closeButtonAriaLabel?: string;
13
15
  /** Additional CSS classes for the dialog backdrop */
14
16
  backdropClassName?: string;
15
17
  /** Size variant for the dialog */
@@ -28,4 +30,4 @@ export type DialogProps = {
28
30
  * @param props - The props for the Dialog component
29
31
  * @returns A modal dialog with backdrop
30
32
  */
31
- export declare const Dialog: ({ isOpen, onClose, closeOnBackdropClick, closeOnEscape, showClose, backdropClassName, size, className, title, headerActions, footerActions, children, headerClassName, bodyClassName, footerClassName, }: DialogProps) => import("react/jsx-runtime").JSX.Element | null;
33
+ export declare const Dialog: ({ isOpen, onClose, closeOnBackdropClick, closeOnEscape, showClose, closeButtonAriaLabel, backdropClassName, size, className, title, headerActions, footerActions, children, headerClassName, bodyClassName, footerClassName, }: DialogProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,14 @@
1
+ import { CardProps } from '../card/Card';
2
+ export type DrawerProps = {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ placement?: "top" | "right" | "bottom" | "left";
6
+ size?: "sm" | "lg";
7
+ portalContainer?: HTMLElement | null;
8
+ closeOnBackdropClick?: boolean;
9
+ showClose?: boolean;
10
+ closeButtonAriaLabel?: string;
11
+ drawerClassName?: string;
12
+ backdropClassName?: string;
13
+ } & Omit<CardProps, "className">;
14
+ export declare function Drawer({ isOpen, onClose, placement, size, closeOnBackdropClick, showClose, closeButtonAriaLabel, drawerClassName, backdropClassName, title, headerActions, footerActions, portalContainer, children, headerClassName, bodyClassName, footerClassName, }: DrawerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { Drawer, type DrawerProps } from './Drawer';
@@ -0,0 +1,26 @@
1
+ import { default as React, Component, ReactNode } from 'react';
2
+ export type ErrorBoundaryProps = {
3
+ children: ReactNode;
4
+ fallback?: (error: Error, errorInfo: React.ErrorInfo | null) => ReactNode;
5
+ onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
6
+ errorTitle?: string;
7
+ errorMessage?: string;
8
+ retryText?: string;
9
+ };
10
+ type ErrorBoundaryState = {
11
+ hasError: boolean;
12
+ error: Error | null;
13
+ errorInfo: React.ErrorInfo | null;
14
+ };
15
+ /**
16
+ * Error boundary component that catches JavaScript errors anywhere in the child component tree.
17
+ * Displays a fallback UI when an error occurs.
18
+ */
19
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
20
+ constructor(props: ErrorBoundaryProps);
21
+ static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
22
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
23
+ handleReset: () => void;
24
+ render(): ReactNode;
25
+ }
26
+ export {};
@@ -0,0 +1 @@
1
+ export * from './ErrorBoundary';
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ export type ErrorPageProps = {
3
+ title?: string;
4
+ message?: string;
5
+ children?: React.ReactNode;
6
+ };
7
+ /**
8
+ * A user-friendly error display component built with library components.
9
+ * Shows an error page when critical errors occur.
10
+ */
11
+ export declare const ErrorPage: ({ title, message, children, }: ErrorPageProps) => React.JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './ErrorPage';
@@ -0,0 +1,3 @@
1
+ import { Theme } from 'json-edit-react';
2
+ export declare const DEFAULT_COLLAPSE_LEVEL = 1;
3
+ export declare const customTheme: Theme;
@@ -25,8 +25,6 @@ export type PopoverProps = {
25
25
  arrowClassName?: string;
26
26
  /** Offset distance from the trigger element in pixels */
27
27
  offset?: number;
28
- /** Whether the popover should render via a React portal */
29
- renderInPortal?: boolean;
30
28
  /** Optional id applied to the popover panel */
31
29
  id?: string;
32
30
  /** ARIA role describing the type of popover */
@@ -57,4 +55,4 @@ export type PopoverProps = {
57
55
  * @param props - The props for the Popover component
58
56
  * @returns A popover with trigger and floating content
59
57
  */
60
- export declare const Popover: ({ children, content, isOpen, onClose, closeOnClickOutside, closeOnEscape, placement, showArrow, triggerClassName, className, arrowClassName, offset, renderInPortal, id, role, ariaLabel, ariaLabelledBy, ariaDescribedBy, initialFocusRef, returnFocusOnClose, }: PopoverProps) => import("react/jsx-runtime").JSX.Element;
58
+ export declare const Popover: ({ children, content, isOpen, onClose, closeOnClickOutside, closeOnEscape, placement, showArrow, triggerClassName, className, arrowClassName, offset, id, role, ariaLabel, ariaLabelledBy, ariaDescribedBy, initialFocusRef, returnFocusOnClose, }: PopoverProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ export type PortalProps = {
3
+ children: ReactNode;
4
+ container?: Element | null;
5
+ };
6
+ /**
7
+ * A portal component that renders children into a DOM node outside the parent hierarchy.
8
+ * SSR-safe: returns null during server-side rendering and initial client render to avoid hydration mismatches.
9
+ */
10
+ export declare function Portal({ children, container }: PortalProps): import('react').ReactPortal | null;
@@ -0,0 +1 @@
1
+ export { Portal, type PortalProps } from './Portal';
@@ -0,0 +1,12 @@
1
+ import { default as React, SVGProps } from 'react';
2
+ type CenteredSpinnerProps = {
3
+ size?: number;
4
+ } & Omit<SVGProps<SVGSVGElement>, "width" | "height">;
5
+ /**
6
+ * CenteredSpinner component
7
+ *
8
+ * A full-page centered spinner for loading states that take over the entire viewport.
9
+ * Useful for initial page loads, route transitions, or full-page data fetching.
10
+ */
11
+ export declare const CenteredSpinner: ({ size, ...props }: CenteredSpinnerProps) => React.JSX.Element;
12
+ export {};
@@ -0,0 +1,11 @@
1
+ import { default as React, SVGProps } from 'react';
2
+ type SpinnerProps = {
3
+ size?: number;
4
+ } & SVGProps<SVGSVGElement>;
5
+ /**
6
+ * Spinner component
7
+ *
8
+ * A reusable spinning loader component that can be used as an icon
9
+ */
10
+ export declare const Spinner: ({ size, className, ...props }: SpinnerProps) => React.JSX.Element;
11
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './CenteredSpinner';
2
+ export * from './Spinner';
@@ -1,32 +1,5 @@
1
- import { PaginationState, TableOptions } from '@tanstack/react-table';
2
1
  import { JSX } from 'react';
3
- /**
4
- * Props for the Table component.
5
- *
6
- */
7
- export type TableProps<T> = Omit<TableOptions<T>, "getCoreRowModel"> & {
8
- className?: string;
9
- scrollWrapperClassName?: string;
10
- getCoreRowModel?: TableOptions<T>["getCoreRowModel"];
11
- enableRowSelection?: boolean;
12
- enableMultiRowSelection?: boolean;
13
- enablePagination?: boolean;
14
- paginationProps?: {
15
- itemsPerPageOptions?: number[];
16
- pagination?: PaginationState;
17
- onPaginationChange?: (pagination: PaginationState) => void;
18
- totalItems?: number;
19
- itemsPerPageText?: string;
20
- fromText?: string;
21
- };
22
- };
23
- /**
24
- * A customizable table component using TanStack Table.
25
- *
26
- * @template T - The row data type.
27
- * @param {TableProps<T>} props - The table props.
28
- * @returns {JSX.Element} The rendered table.
29
- */
2
+ import { TableProps } from './types';
30
3
  declare function Table<T extends {
31
4
  id?: string | number;
32
5
  }>({ data, columns, className, scrollWrapperClassName, getCoreRowModel, enableRowSelection, enableMultiRowSelection, enablePagination, paginationProps, ...options }: TableProps<T>): JSX.Element;
@@ -1,6 +1,6 @@
1
+ export { Pagination } from './components/Pagination';
2
+ export type { PaginationProps } from './components/Pagination';
1
3
  export { default as Table } from './Table';
2
- export type { TableProps } from './Table';
3
4
  export { TableCell } from './TableCell';
4
5
  export { TableHeaderCell } from './TableHeaderCell';
5
- export { Pagination } from './components/Pagination';
6
- export type { PaginationProps } from './components/Pagination';
6
+ export type { TableProps } from './types';
@@ -0,0 +1,51 @@
1
+ import { TableOptions } from '@tanstack/react-table';
2
+ /**
3
+ * Props for the Table component.
4
+ * Supports both controlled and uncontrolled modes for sorting, selection, and pagination.
5
+ *
6
+ * @template T - The row data type.
7
+ *
8
+ * @example
9
+ * // Uncontrolled (component manages state internally via TanStack Table)
10
+ * <Table data={data} columns={columns} />
11
+ *
12
+ * @example
13
+ * // Controlled selection
14
+ * <Table
15
+ * data={data}
16
+ * columns={columns}
17
+ * enableRowSelection
18
+ * state={{ rowSelection }}
19
+ * onRowSelectionChange={setRowSelection}
20
+ * />
21
+ *
22
+ * @example
23
+ * // Server-side pagination
24
+ * <Table
25
+ * data={data}
26
+ * columns={columns}
27
+ * enablePagination
28
+ * state={{ pagination }}
29
+ * onPaginationChange={setPagination}
30
+ * paginationProps={{ mode: 'server', totalItems: 1000 }}
31
+ * />
32
+ */
33
+ export type TableProps<T> = Omit<TableOptions<T>, "getCoreRowModel" | "getSortedRowModel" | "getPaginationRowModel" | "manualPagination" | "pageCount" | "autoResetPageIndex"> & {
34
+ className?: string;
35
+ scrollWrapperClassName?: string;
36
+ getCoreRowModel?: TableOptions<T>["getCoreRowModel"];
37
+ enablePagination?: boolean;
38
+ paginationProps?: {
39
+ mode?: "client";
40
+ itemsPerPageOptions?: number[];
41
+ itemsPerPageText?: string;
42
+ fromText?: string;
43
+ totalItems?: never;
44
+ } | {
45
+ mode: "server";
46
+ itemsPerPageOptions?: number[];
47
+ itemsPerPageText?: string;
48
+ fromText?: string;
49
+ totalItems: number;
50
+ };
51
+ };
@@ -7,4 +7,4 @@ import { ToasterProps } from './types';
7
7
  * of toasts. State management (adding, removing toasts) should be handled
8
8
  * by the consuming application.
9
9
  */
10
- export declare const Toaster: ({ toasts, onDismiss, maxToasts, className, }: ToasterProps) => import('react').ReactPortal | null;
10
+ export declare const Toaster: ({ toasts, onDismiss, maxToasts, className, }: ToasterProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -1 +1,2 @@
1
+ export { useDropdownPosition } from './useDropdownPosition';
1
2
  export { useViewportCollision } from './useViewportCollision';
@@ -0,0 +1,13 @@
1
+ import { RefObject } from 'react';
2
+ export type DropdownPosition = {
3
+ top?: number;
4
+ bottom?: number;
5
+ left: number;
6
+ width: number;
7
+ };
8
+ export type UseDropdownPositionOptions = {
9
+ isOpen: boolean;
10
+ triggerRef: RefObject<HTMLElement | null>;
11
+ maxHeight: number;
12
+ };
13
+ export declare const useDropdownPosition: ({ isOpen, triggerRef, maxHeight, }: UseDropdownPositionOptions) => DropdownPosition;