@sapphire-sh/ui 0.1.0 → 0.3.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.
Files changed (53) hide show
  1. package/lib/Button.d.ts +7 -0
  2. package/lib/Button.d.ts.map +1 -0
  3. package/lib/Button.js +10 -0
  4. package/lib/Button.js.map +1 -0
  5. package/lib/Chip.d.ts +8 -0
  6. package/lib/Chip.d.ts.map +1 -0
  7. package/lib/Chip.js +6 -0
  8. package/lib/Chip.js.map +1 -0
  9. package/lib/DataTable.d.ts +7 -0
  10. package/lib/DataTable.d.ts.map +1 -0
  11. package/lib/DataTable.js +3 -0
  12. package/lib/DataTable.js.map +1 -0
  13. package/lib/EmptyState.d.ts +6 -0
  14. package/lib/EmptyState.d.ts.map +1 -0
  15. package/lib/EmptyState.js +3 -0
  16. package/lib/EmptyState.js.map +1 -0
  17. package/lib/Modal.d.ts +9 -0
  18. package/lib/Modal.d.ts.map +1 -0
  19. package/lib/Modal.js +28 -0
  20. package/lib/Modal.js.map +1 -0
  21. package/lib/Nav.d.ts +11 -0
  22. package/lib/Nav.d.ts.map +1 -0
  23. package/lib/Nav.js +19 -0
  24. package/lib/Nav.js.map +1 -0
  25. package/lib/Pagination.d.ts +7 -0
  26. package/lib/Pagination.d.ts.map +1 -0
  27. package/lib/Pagination.js +23 -0
  28. package/lib/Pagination.js.map +1 -0
  29. package/lib/Spinner.d.ts +6 -0
  30. package/lib/Spinner.d.ts.map +1 -0
  31. package/lib/Spinner.js +4 -0
  32. package/lib/Spinner.js.map +1 -0
  33. package/lib/Toast.d.ts +15 -0
  34. package/lib/Toast.d.ts.map +1 -0
  35. package/lib/Toast.js +42 -0
  36. package/lib/Toast.js.map +1 -0
  37. package/lib/fieldClass.d.ts +2 -0
  38. package/lib/fieldClass.d.ts.map +1 -0
  39. package/lib/fieldClass.js +2 -0
  40. package/lib/fieldClass.js.map +1 -0
  41. package/lib/index.d.ts +12 -0
  42. package/lib/index.d.ts.map +1 -1
  43. package/lib/index.js +12 -0
  44. package/lib/index.js.map +1 -1
  45. package/lib/navHref.d.ts +5 -0
  46. package/lib/navHref.d.ts.map +1 -0
  47. package/lib/navHref.js +11 -0
  48. package/lib/navHref.js.map +1 -0
  49. package/lib/paginationTargets.d.ts +7 -0
  50. package/lib/paginationTargets.d.ts.map +1 -0
  51. package/lib/paginationTargets.js +29 -0
  52. package/lib/paginationTargets.js.map +1 -0
  53. package/package.json +7 -1
@@ -0,0 +1,7 @@
1
+ import type { ButtonHTMLAttributes } from 'react';
2
+ export type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'ghost';
3
+ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4
+ variant?: ButtonVariant;
5
+ }
6
+ export declare const Button: ({ variant, className, type, ...rest }: ButtonProps) => import("react").JSX.Element;
7
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAElD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEzE,MAAM,WAAW,WAAY,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IAC3E,OAAO,CAAC,EAAE,aAAa,CAAC;CACxB;AAWD,eAAO,MAAM,MAAM,0CAAoE,WAAW,gCAMjG,CAAC"}
package/lib/Button.js ADDED
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const BUTTON_CLASS = 'rounded-md border px-3 py-1 text-sm focus-visible:outline-2 focus-visible:outline-accent';
3
+ const VARIANT_CLASS = {
4
+ primary: 'bg-accent text-accent-foreground border-accent',
5
+ secondary: 'bg-surface text-foreground border-border',
6
+ danger: 'bg-surface text-danger border-danger',
7
+ ghost: 'bg-transparent text-muted border-transparent',
8
+ };
9
+ export const Button = ({ variant = 'secondary', className, type = 'button', ...rest }) => (_jsx("button", { ...rest, type: type, className: `${BUTTON_CLASS} ${VARIANT_CLASS[variant]}${className === undefined ? '' : ` ${className}`}` }));
10
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":";AAQA,MAAM,YAAY,GAAG,0FAA0F,CAAC;AAEhH,MAAM,aAAa,GAAkC;IACpD,OAAO,EAAE,gDAAgD;IACzD,SAAS,EAAE,0CAA0C;IACrD,MAAM,EAAE,sCAAsC;IAC9C,KAAK,EAAE,8CAA8C;CACrD,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EAAE,OAAO,GAAG,WAAW,EAAE,SAAS,EAAE,IAAI,GAAG,QAAQ,EAAE,GAAG,IAAI,EAAe,EAAE,EAAE,CAAC,CACtG,oBACK,IAAI,EACR,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,GAAG,YAAY,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,EAAE,GACtG,CACF,CAAC"}
package/lib/Chip.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface ChipProps {
3
+ pressed: boolean;
4
+ onClick: () => void;
5
+ children: ReactNode;
6
+ }
7
+ export declare const Chip: ({ pressed, onClick, children }: ChipProps) => import("react").JSX.Element;
8
+ //# sourceMappingURL=Chip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../src/Chip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,SAAS;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACpB;AAMD,eAAO,MAAM,IAAI,mCAAoC,SAAS,gCAS7D,CAAC"}
package/lib/Chip.js ADDED
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const CHIP_CLASS = 'rounded-full border px-2.5 py-0.5 text-xs';
3
+ const PRESSED_CHIP_CLASS = 'bg-accent-soft text-accent-ink border-transparent';
4
+ const IDLE_CHIP_CLASS = 'bg-transparent text-muted border-border';
5
+ export const Chip = ({ pressed, onClick, children }) => (_jsx("button", { type: "button", "aria-pressed": pressed, onClick: onClick, className: `${CHIP_CLASS} ${pressed ? PRESSED_CHIP_CLASS : IDLE_CHIP_CLASS}`, children: children }));
6
+ //# sourceMappingURL=Chip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chip.js","sourceRoot":"","sources":["../src/Chip.tsx"],"names":[],"mappings":";AAQA,MAAM,UAAU,GAAG,2CAA2C,CAAC;AAC/D,MAAM,kBAAkB,GAAG,mDAAmD,CAAC;AAC/E,MAAM,eAAe,GAAG,yCAAyC,CAAC;AAElE,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAa,EAAE,EAAE,CAAC,CAClE,iBACC,IAAI,EAAC,QAAQ,kBACC,OAAO,EACrB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,GAAG,UAAU,IAAI,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,eAAe,EAAE,YAE3E,QAAQ,GACD,CACT,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface DataTableProps {
3
+ widthClass?: string;
4
+ children: ReactNode;
5
+ }
6
+ export declare const DataTable: ({ widthClass, children }: DataTableProps) => import("react").JSX.Element;
7
+ //# sourceMappingURL=DataTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../src/DataTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,cAAc;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACpB;AAED,eAAO,MAAM,SAAS,6BAAyC,cAAc,gCAI5E,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const DataTable = ({ widthClass = 'w-full', children }) => (_jsx("div", { className: "overflow-x-auto rounded-lg border border-border", children: _jsx("table", { className: `border-collapse text-foreground tabular-nums ${widthClass}`, children: children }) }));
3
+ //# sourceMappingURL=DataTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTable.js","sourceRoot":"","sources":["../src/DataTable.tsx"],"names":[],"mappings":";AAOA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,UAAU,GAAG,QAAQ,EAAE,QAAQ,EAAkB,EAAE,EAAE,CAAC,CACjF,cAAK,SAAS,EAAC,iDAAiD,YAC/D,gBAAO,SAAS,EAAE,gDAAgD,UAAU,EAAE,YAAG,QAAQ,GAAS,GAC7F,CACN,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface EmptyStateProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare const EmptyState: ({ children }: EmptyStateProps) => import("react").JSX.Element;
6
+ //# sourceMappingURL=EmptyState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptyState.d.ts","sourceRoot":"","sources":["../src/EmptyState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,eAAe;IAC/B,QAAQ,EAAE,SAAS,CAAC;CACpB;AAED,eAAO,MAAM,UAAU,iBAAkB,eAAe,gCAAqD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const EmptyState = ({ children }) => _jsx("p", { className: "text-sm text-muted", children: children });
3
+ //# sourceMappingURL=EmptyState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptyState.js","sourceRoot":"","sources":["../src/EmptyState.tsx"],"names":[],"mappings":";AAMA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAmB,EAAE,EAAE,CAAC,YAAG,SAAS,EAAC,oBAAoB,YAAE,QAAQ,GAAK,CAAC"}
package/lib/Modal.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface ModalProps {
3
+ open: boolean;
4
+ onClose: () => void;
5
+ title: string;
6
+ children: ReactNode;
7
+ }
8
+ export declare const Modal: ({ open, onClose, title, children }: ModalProps) => import("react").JSX.Element;
9
+ //# sourceMappingURL=Modal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../src/Modal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;CACpB;AAED,eAAO,MAAM,KAAK,uCAAwC,UAAU,gCAwCnE,CAAC"}
package/lib/Modal.js ADDED
@@ -0,0 +1,28 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useId, useRef } from 'react';
4
+ export const Modal = ({ open, onClose, title, children }) => {
5
+ const dialogRef = useRef(null);
6
+ const titleId = useId();
7
+ useEffect(() => {
8
+ const dialog = dialogRef.current;
9
+ if (dialog === null) {
10
+ return;
11
+ }
12
+ if (open && !dialog.open) {
13
+ dialog.showModal();
14
+ }
15
+ if (!open && dialog.open) {
16
+ dialog.close();
17
+ }
18
+ }, [open]);
19
+ return (_jsx("dialog", { ref: dialogRef, "aria-labelledby": titleId, onCancel: (event) => {
20
+ event.preventDefault();
21
+ onClose();
22
+ }, onClick: (event) => {
23
+ if (event.target === event.currentTarget) {
24
+ onClose();
25
+ }
26
+ }, className: "rounded-lg border border-border bg-surface p-0 text-foreground backdrop:bg-foreground/40", children: _jsxs("div", { className: "p-4", children: [_jsx("h2", { id: titleId, className: "mb-3 text-base font-semibold", children: title }), children] }) }));
27
+ };
28
+ //# sourceMappingURL=Modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../src/Modal.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AASjD,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAc,EAAE,EAAE;IACvE,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;IAExB,SAAS,CAAC,GAAG,EAAE;QACd,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;QACjC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACrB,OAAO;QACR,CAAC;QACD,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC1B,MAAM,CAAC,SAAS,EAAE,CAAC;QACpB,CAAC;QACD,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAC1B,MAAM,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;IACF,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,CACN,iBACC,GAAG,EAAE,SAAS,qBACG,OAAO,EACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YACnB,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,OAAO,EAAE,CAAC;QACX,CAAC,EACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAClB,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,aAAa,EAAE,CAAC;gBAC1C,OAAO,EAAE,CAAC;YACX,CAAC;QACF,CAAC,EACD,SAAS,EAAC,0FAA0F,YAEpG,eAAK,SAAS,EAAC,KAAK,aACnB,aAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAC,8BAA8B,YACvD,KAAK,GACF,EACJ,QAAQ,IACJ,GACE,CACT,CAAC;AACH,CAAC,CAAC"}
package/lib/Nav.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export interface NavItem {
2
+ href: string;
3
+ label: string;
4
+ children?: readonly NavItem[];
5
+ }
6
+ export interface NavProps {
7
+ brand: string;
8
+ items: readonly NavItem[];
9
+ }
10
+ export declare const Nav: ({ brand, items }: NavProps) => import("react").JSX.Element;
11
+ //# sourceMappingURL=Nav.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Nav.d.ts","sourceRoot":"","sources":["../src/Nav.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,OAAO;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,QAAQ;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,OAAO,EAAE,CAAC;CAC1B;AASD,eAAO,MAAM,GAAG,qBAAsB,QAAQ,gCAoC7C,CAAC"}
package/lib/Nav.js ADDED
@@ -0,0 +1,19 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import Link from 'next/link';
4
+ import { usePathname } from 'next/navigation';
5
+ import { currentNavHref } from './navHref.js';
6
+ const LINK_CLASS = 'block rounded-md px-2.5 py-1 text-sm';
7
+ const CURRENT_LINK_CLASS = 'bg-accent-soft text-accent-ink';
8
+ const IDLE_LINK_CLASS = 'text-muted hover:text-foreground';
9
+ const flattenNavItems = (items) => items.flatMap((item) => [item, ...flattenNavItems(item.children ?? [])]);
10
+ export const Nav = ({ brand, items }) => {
11
+ const pathname = usePathname();
12
+ const current = currentNavHref(pathname, flattenNavItems(items));
13
+ const renderLink = (item) => {
14
+ const isCurrent = item.href === current;
15
+ return (_jsx(Link, { href: item.href, "aria-current": isCurrent ? 'page' : undefined, className: `${LINK_CLASS} ${isCurrent ? CURRENT_LINK_CLASS : IDLE_LINK_CLASS}`, children: item.label }));
16
+ };
17
+ return (_jsxs("nav", { className: "flex items-center gap-4 border-b border-border bg-surface px-4 py-2", children: [_jsx("span", { className: "font-semibold text-foreground", children: brand }), _jsx("ul", { className: "flex items-center gap-1", children: items.map((item) => (_jsxs("li", { className: "group relative", children: [renderLink(item), item.children !== undefined && (_jsx("ul", { className: "invisible absolute top-full left-0 z-10 min-w-40 rounded-md border border-border bg-surface p-1 group-focus-within:visible group-hover:visible", children: item.children.map((child) => (_jsx("li", { children: renderLink(child) }, child.href))) }))] }, item.href))) })] }));
18
+ };
19
+ //# sourceMappingURL=Nav.js.map
package/lib/Nav.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Nav.js","sourceRoot":"","sources":["../src/Nav.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAa9C,MAAM,UAAU,GAAG,sCAAsC,CAAC;AAC1D,MAAM,kBAAkB,GAAG,gCAAgC,CAAC;AAC5D,MAAM,eAAe,GAAG,kCAAkC,CAAC;AAE3D,MAAM,eAAe,GAAG,CAAC,KAAyB,EAAa,EAAE,CAChE,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAE1E,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAY,EAAE,EAAE;IACjD,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IAEjE,MAAM,UAAU,GAAG,CAAC,IAAa,EAAE,EAAE;QACpC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;QACxC,OAAO,CACN,KAAC,IAAI,IACJ,IAAI,EAAE,IAAI,CAAC,IAAI,kBACD,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAC5C,SAAS,EAAE,GAAG,UAAU,IAAI,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,eAAe,EAAE,YAE7E,IAAI,CAAC,KAAK,GACL,CACP,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACN,eAAK,SAAS,EAAC,qEAAqE,aACnF,eAAM,SAAS,EAAC,+BAA+B,YAAE,KAAK,GAAQ,EAC9D,aAAI,SAAS,EAAC,yBAAyB,YACrC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACpB,cAAoB,SAAS,EAAC,gBAAgB,aAC5C,UAAU,CAAC,IAAI,CAAC,EAChB,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,CAC/B,aAAI,SAAS,EAAC,gJAAgJ,YAC5J,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAC7B,uBAAsB,UAAU,CAAC,KAAK,CAAC,IAA9B,KAAK,CAAC,IAAI,CAA0B,CAC7C,CAAC,GACE,CACL,KARO,IAAI,CAAC,IAAI,CASb,CACL,CAAC,GACE,IACA,CACN,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface PaginationProps {
2
+ page: number;
3
+ totalPages: number;
4
+ hrefForPage: (page: number) => string;
5
+ }
6
+ export declare const Pagination: ({ page, totalPages, hrefForPage }: PaginationProps) => import("react").JSX.Element;
7
+ //# sourceMappingURL=Pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["../src/Pagination.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACtC;AAmBD,eAAO,MAAM,UAAU,sCAAuC,eAAe,gCA6B5E,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react';
3
+ import Link from 'next/link';
4
+ import { paginationTargets } from './paginationTargets.js';
5
+ const MOVE_TARGETS = {
6
+ first: { icon: ChevronFirst, label: 'First page' },
7
+ jumpBack: { icon: ChevronsLeft, label: 'Back 10 pages' },
8
+ previous: { icon: ChevronLeft, label: 'Previous page' },
9
+ next: { icon: ChevronRight, label: 'Next page' },
10
+ jumpForward: { icon: ChevronsRight, label: 'Forward 10 pages' },
11
+ last: { icon: ChevronLast, label: 'Last page' },
12
+ };
13
+ const ITEM_CLASS = 'flex h-8 min-w-8 items-center justify-center rounded-md px-2 text-sm';
14
+ const IDLE_ITEM_CLASS = 'text-muted hover:text-foreground';
15
+ export const Pagination = ({ page, totalPages, hrefForPage }) => (_jsx("nav", { "aria-label": "Pagination", children: _jsx("ul", { className: "flex items-center gap-1", children: paginationTargets(page, totalPages).map(({ kind, page: target }) => {
16
+ if (kind === 'page') {
17
+ const isCurrent = target === page;
18
+ return (_jsx("li", { children: _jsx(Link, { href: hrefForPage(target), "aria-current": isCurrent ? 'page' : undefined, className: `${ITEM_CLASS} ${isCurrent ? 'bg-raised text-foreground' : IDLE_ITEM_CLASS}`, children: target }) }, `page-${target}`));
19
+ }
20
+ const { icon: Icon, label } = MOVE_TARGETS[kind];
21
+ return (_jsx("li", { children: _jsx(Link, { href: hrefForPage(target), "aria-label": label, className: `${ITEM_CLASS} ${IDLE_ITEM_CLASS}`, children: _jsx(Icon, { "aria-hidden": true, className: "size-4" }) }) }, kind));
22
+ }) }) }));
23
+ //# sourceMappingURL=Pagination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pagination.js","sourceRoot":"","sources":["../src/Pagination.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACjH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAa3D,MAAM,YAAY,GAA8D;IAC/E,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;IAClD,QAAQ,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE;IACxD,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE;IACvD,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE;IAChD,WAAW,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,kBAAkB,EAAE;IAC/D,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;CAC/C,CAAC;AAEF,MAAM,UAAU,GAAG,sEAAsE,CAAC;AAC1F,MAAM,eAAe,GAAG,kCAAkC,CAAC;AAE3D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAmB,EAAE,EAAE,CAAC,CACjF,4BAAgB,YAAY,YAC3B,aAAI,SAAS,EAAC,yBAAyB,YACrC,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;YACnE,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACrB,MAAM,SAAS,GAAG,MAAM,KAAK,IAAI,CAAC;gBAClC,OAAO,CACN,uBACC,KAAC,IAAI,IACJ,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,kBACX,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAC5C,SAAS,EAAE,GAAG,UAAU,IAAI,SAAS,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,eAAe,EAAE,YAEtF,MAAM,GACD,IAPC,QAAQ,MAAM,EAAE,CAQpB,CACL,CAAC;YACH,CAAC;YACD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;YACjD,OAAO,CACN,uBACC,KAAC,IAAI,IAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,gBAAc,KAAK,EAAE,SAAS,EAAE,GAAG,UAAU,IAAI,eAAe,EAAE,YAChG,KAAC,IAAI,yBAAa,SAAS,EAAC,QAAQ,GAAG,GACjC,IAHC,IAAI,CAIR,CACL,CAAC;QACH,CAAC,CAAC,GACE,GACA,CACN,CAAC"}
@@ -0,0 +1,6 @@
1
+ export interface LoadingBlockProps {
2
+ label: string;
3
+ }
4
+ export declare const Spinner: () => import("react").JSX.Element;
5
+ export declare const LoadingBlock: ({ label }: LoadingBlockProps) => import("react").JSX.Element;
6
+ //# sourceMappingURL=Spinner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Spinner.d.ts","sourceRoot":"","sources":["../src/Spinner.tsx"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,OAAO,mCAInB,CAAC;AAEF,eAAO,MAAM,YAAY,cAAe,iBAAiB,gCAKxD,CAAC"}
package/lib/Spinner.js ADDED
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const Spinner = () => (_jsx("svg", { "aria-hidden": true, viewBox: "0 0 24 24", fill: "none", className: "size-4 motion-safe:animate-spin", children: _jsx("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeDasharray: "42 15" }) }));
3
+ export const LoadingBlock = ({ label }) => (_jsxs("div", { role: "status", className: "flex items-center justify-center gap-2 py-8 text-sm text-muted", children: [_jsx(Spinner, {}), _jsx("span", { children: label })] }));
4
+ //# sourceMappingURL=Spinner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Spinner.js","sourceRoot":"","sources":["../src/Spinner.tsx"],"names":[],"mappings":";AAIA,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAC5B,mCAAiB,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAC,iCAAiC,YAC3F,iBAAQ,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,GAAG,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,GAAG,EAAC,aAAa,EAAC,OAAO,EAAC,eAAe,EAAC,OAAO,GAAG,GAC/G,CACN,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,KAAK,EAAqB,EAAE,EAAE,CAAC,CAC7D,eAAK,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,gEAAgE,aAC5F,KAAC,OAAO,KAAG,EACX,yBAAO,KAAK,GAAQ,IACf,CACN,CAAC"}
package/lib/Toast.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { ReactNode } from 'react';
2
+ export type ToastTone = 'success' | 'error';
3
+ export interface ToastOptions {
4
+ message: string;
5
+ tone: ToastTone;
6
+ }
7
+ export interface ToastContextValue {
8
+ show: (options: ToastOptions) => void;
9
+ }
10
+ export interface ToastProviderProps {
11
+ children: ReactNode;
12
+ }
13
+ export declare const ToastProvider: ({ children }: ToastProviderProps) => import("react").JSX.Element;
14
+ export declare const useToast: () => ToastContextValue;
15
+ //# sourceMappingURL=Toast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE5C,MAAM,WAAW,YAAY;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;CAChB;AAMD,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,kBAAkB;IAClC,QAAQ,EAAE,SAAS,CAAC;CACpB;AAWD,eAAO,MAAM,aAAa,iBAAkB,kBAAkB,gCA2C7D,CAAC;AAEF,eAAO,MAAM,QAAQ,QAAO,iBAM3B,CAAC"}
package/lib/Toast.js ADDED
@@ -0,0 +1,42 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
4
+ const TOAST_DURATION_MS = 3500;
5
+ const TONE_DOT_CLASS = {
6
+ success: 'bg-success',
7
+ error: 'bg-danger',
8
+ };
9
+ const ToastContext = createContext(null);
10
+ export const ToastProvider = ({ children }) => {
11
+ const [toasts, setToasts] = useState([]);
12
+ const nextIdRef = useRef(0);
13
+ const timeoutsRef = useRef(new Set());
14
+ useEffect(() => {
15
+ const timeouts = timeoutsRef.current;
16
+ return () => {
17
+ for (const timeout of timeouts) {
18
+ clearTimeout(timeout);
19
+ }
20
+ };
21
+ }, []);
22
+ const show = useCallback((options) => {
23
+ const id = nextIdRef.current;
24
+ nextIdRef.current += 1;
25
+ setToasts((current) => [...current, { ...options, id }]);
26
+ const timeout = setTimeout(() => {
27
+ timeoutsRef.current.delete(timeout);
28
+ setToasts((current) => current.filter((toast) => toast.id !== id));
29
+ }, TOAST_DURATION_MS);
30
+ timeoutsRef.current.add(timeout);
31
+ }, []);
32
+ const value = useMemo(() => ({ show }), [show]);
33
+ return (_jsxs(ToastContext, { value: value, children: [children, _jsx("div", { role: "status", className: "fixed right-4 bottom-4 z-50 flex flex-col gap-2", children: toasts.map((toast) => (_jsxs("div", { className: "flex items-center gap-2 rounded-md border border-border bg-surface px-3 py-2 text-sm text-foreground", children: [_jsx("span", { "aria-hidden": true, className: `size-2 rounded-full ${TONE_DOT_CLASS[toast.tone]}` }), toast.message] }, toast.id))) })] }));
34
+ };
35
+ export const useToast = () => {
36
+ const value = useContext(ToastContext);
37
+ if (value === null) {
38
+ throw new Error('useToast must be used inside ToastProvider');
39
+ }
40
+ return value;
41
+ };
42
+ //# sourceMappingURL=Toast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toast.js","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAqBrG,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B,MAAM,cAAc,GAA8B;IACjD,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,WAAW;CAClB,CAAC;AAEF,MAAM,YAAY,GAAG,aAAa,CAA2B,IAAI,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAsB,EAAE,EAAE;IACjE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAe,EAAE,CAAC,CAAC;IACvD,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,GAAG,EAAiC,CAAC,CAAC;IAErE,SAAS,CAAC,GAAG,EAAE;QACd,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC;QACrC,OAAO,GAAG,EAAE;YACX,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAChC,YAAY,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;QACF,CAAC,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,OAAqB,EAAE,EAAE;QAClD,MAAM,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC;QAC7B,SAAS,CAAC,OAAO,IAAI,CAAC,CAAC;QACvB,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YAC/B,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACpC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC,EAAE,iBAAiB,CAAC,CAAC;QACtB,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhD,OAAO,CACN,MAAC,YAAY,IAAC,KAAK,EAAE,KAAK,aACxB,QAAQ,EACT,cAAK,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,iDAAiD,YAC5E,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACtB,eAEC,SAAS,EAAC,sGAAsG,aAEhH,oCAAkB,SAAS,EAAE,uBAAuB,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAI,EACnF,KAAK,CAAC,OAAO,KAJT,KAAK,CAAC,EAAE,CAKR,CACN,CAAC,GACG,IACQ,CACf,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAsB,EAAE;IAC/C,MAAM,KAAK,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IACvC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const FIELD_CLASS = "rounded-md border border-border bg-surface px-2.5 py-1 text-sm text-foreground focus:border-accent focus:outline-none";
2
+ //# sourceMappingURL=fieldClass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fieldClass.d.ts","sourceRoot":"","sources":["../src/fieldClass.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,0HACgG,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const FIELD_CLASS = 'rounded-md border border-border bg-surface px-2.5 py-1 text-sm text-foreground focus:border-accent focus:outline-none';
2
+ //# sourceMappingURL=fieldClass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fieldClass.js","sourceRoot":"","sources":["../src/fieldClass.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GACvB,uHAAuH,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,2 +1,14 @@
1
+ export { Button } from './Button.js';
2
+ export { Chip } from './Chip.js';
3
+ export { DataTable } from './DataTable.js';
4
+ export { EmptyState } from './EmptyState.js';
5
+ export { FIELD_CLASS } from './fieldClass.js';
6
+ export { Modal } from './Modal.js';
7
+ export { Nav } from './Nav.js';
8
+ export { currentNavHref } from './navHref.js';
9
+ export { Pagination } from './Pagination.js';
10
+ export { paginationTargets } from './paginationTargets.js';
11
+ export { LoadingBlock, Spinner } from './Spinner.js';
12
+ export { ToastProvider, useToast } from './Toast.js';
1
13
  export { colorTokens } from './tokens.js';
2
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
package/lib/index.js CHANGED
@@ -1,2 +1,14 @@
1
+ export { Button } from './Button.js';
2
+ export { Chip } from './Chip.js';
3
+ export { DataTable } from './DataTable.js';
4
+ export { EmptyState } from './EmptyState.js';
5
+ export { FIELD_CLASS } from './fieldClass.js';
6
+ export { Modal } from './Modal.js';
7
+ export { Nav } from './Nav.js';
8
+ export { currentNavHref } from './navHref.js';
9
+ export { Pagination } from './Pagination.js';
10
+ export { paginationTargets } from './paginationTargets.js';
11
+ export { LoadingBlock, Spinner } from './Spinner.js';
12
+ export { ToastProvider, useToast } from './Toast.js';
1
13
  export { colorTokens } from './tokens.js';
2
14
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ export interface NavHrefItem {
2
+ href: string;
3
+ }
4
+ export declare const currentNavHref: (pathname: string, items: readonly NavHrefItem[]) => string | null;
5
+ //# sourceMappingURL=navHref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navHref.d.ts","sourceRoot":"","sources":["../src/navHref.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;CACb;AAKD,eAAO,MAAM,cAAc,aAAc,MAAM,SAAS,SAAS,WAAW,EAAE,KAAG,MAAM,GAAG,IAQzF,CAAC"}
package/lib/navHref.js ADDED
@@ -0,0 +1,11 @@
1
+ const isSameOrAncestorPath = (href, pathname) => pathname === href || pathname.startsWith(href.endsWith('/') ? href : `${href}/`);
2
+ export const currentNavHref = (pathname, items) => {
3
+ let current = null;
4
+ for (const { href } of items) {
5
+ if (isSameOrAncestorPath(href, pathname) && (current === null || href.length > current.length)) {
6
+ current = href;
7
+ }
8
+ }
9
+ return current;
10
+ };
11
+ //# sourceMappingURL=navHref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navHref.js","sourceRoot":"","sources":["../src/navHref.ts"],"names":[],"mappings":"AAIA,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,QAAgB,EAAW,EAAE,CACxE,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;AAElF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,KAA6B,EAAiB,EAAE;IAChG,IAAI,OAAO,GAAkB,IAAI,CAAC;IAClC,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC;QAC9B,IAAI,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAChG,OAAO,GAAG,IAAI,CAAC;QAChB,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type PaginationTargetKind = 'first' | 'jumpBack' | 'previous' | 'page' | 'next' | 'jumpForward' | 'last';
2
+ export interface PaginationTarget {
3
+ kind: PaginationTargetKind;
4
+ page: number;
5
+ }
6
+ export declare const paginationTargets: (page: number, totalPages: number) => PaginationTarget[];
7
+ //# sourceMappingURL=paginationTargets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginationTargets.d.ts","sourceRoot":"","sources":["../src/paginationTargets.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC;AAEhH,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACb;AAKD,eAAO,MAAM,iBAAiB,SAAU,MAAM,cAAc,MAAM,KAAG,gBAAgB,EAyBpF,CAAC"}
@@ -0,0 +1,29 @@
1
+ const JUMP_PAGES = 10;
2
+ const NEIGHBOR_PAGES = 2;
3
+ export const paginationTargets = (page, totalPages) => {
4
+ const targets = [];
5
+ if (page > 1) {
6
+ targets.push({ kind: 'first', page: 1 });
7
+ }
8
+ if (page - JUMP_PAGES >= 1) {
9
+ targets.push({ kind: 'jumpBack', page: page - JUMP_PAGES });
10
+ }
11
+ if (page > 1) {
12
+ targets.push({ kind: 'previous', page: page - 1 });
13
+ }
14
+ const lastNeighbor = Math.min(totalPages, page + NEIGHBOR_PAGES);
15
+ for (let neighbor = Math.max(1, page - NEIGHBOR_PAGES); neighbor <= lastNeighbor; neighbor += 1) {
16
+ targets.push({ kind: 'page', page: neighbor });
17
+ }
18
+ if (page < totalPages) {
19
+ targets.push({ kind: 'next', page: page + 1 });
20
+ }
21
+ if (page + JUMP_PAGES <= totalPages) {
22
+ targets.push({ kind: 'jumpForward', page: page + JUMP_PAGES });
23
+ }
24
+ if (page < totalPages) {
25
+ targets.push({ kind: 'last', page: totalPages });
26
+ }
27
+ return targets;
28
+ };
29
+ //# sourceMappingURL=paginationTargets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginationTargets.js","sourceRoot":"","sources":["../src/paginationTargets.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,UAAkB,EAAsB,EAAE;IACzF,MAAM,OAAO,GAAuB,EAAE,CAAC;IACvC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACd,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,IAAI,GAAG,UAAU,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,GAAG,UAAU,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACd,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,GAAG,cAAc,CAAC,CAAC;IACjE,KAAK,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,cAAc,CAAC,EAAE,QAAQ,IAAI,YAAY,EAAE,QAAQ,IAAI,CAAC,EAAE,CAAC;QACjG,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,IAAI,GAAG,UAAU,EAAE,CAAC;QACvB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,IAAI,GAAG,UAAU,IAAI,UAAU,EAAE,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,GAAG,UAAU,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,IAAI,GAAG,UAAU,EAAE,CAAC;QACvB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire-sh/ui",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "@sapphire-sh/ui",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -50,6 +50,7 @@
50
50
  "devDependencies": {
51
51
  "@eslint/js": "^10.0.1",
52
52
  "@sapphire-sh/utils": "^3.32.0",
53
+ "@testing-library/react": "^16.3.3",
53
54
  "@types/node": "^26.6.5",
54
55
  "@types/react": "^19.3.0",
55
56
  "@types/react-dom": "^19.3.0",
@@ -58,6 +59,7 @@
58
59
  "eslint-config-next": "^16.4.3",
59
60
  "eslint-config-prettier": "^10.1.8",
60
61
  "eslint-plugin-promise": "^7.3.0",
62
+ "jsdom": "^30.1.3",
61
63
  "next": "^16.4.3",
62
64
  "prettier": "^3.9.10",
63
65
  "prettier-plugin-organize-imports": "^4.3.0",
@@ -69,6 +71,10 @@
69
71
  "vitest": "^5.0.5"
70
72
  },
71
73
  "allowScripts": {
74
+ "fsevents@2.3.3": true,
72
75
  "unrs-resolver@1.12.2": true
76
+ },
77
+ "dependencies": {
78
+ "lucide-react": "^1.61.0"
73
79
  }
74
80
  }