@jgb-solutions/kit 0.2.3 → 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 (35) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +120 -2
  3. package/dist/admin/blocks/ActivityFeed.d.ts +20 -0
  4. package/dist/admin/blocks/BarChart.d.ts +26 -0
  5. package/dist/admin/blocks/ChartPoints.d.ts +24 -0
  6. package/dist/admin/blocks/DataTable.d.ts +58 -0
  7. package/dist/admin/blocks/Filters.d.ts +12 -0
  8. package/dist/admin/blocks/Hero.d.ts +22 -0
  9. package/dist/admin/blocks/LineChart.d.ts +24 -0
  10. package/dist/admin/blocks/Pagination.d.ts +30 -0
  11. package/dist/admin/blocks/Segmented.d.ts +15 -0
  12. package/dist/admin/blocks/Stat.d.ts +35 -0
  13. package/dist/admin/blocks/Status.d.ts +22 -0
  14. package/dist/admin/blocks/Tile.d.ts +20 -0
  15. package/dist/admin/blocks/sorting.d.ts +29 -0
  16. package/dist/admin/contrast.d.ts +12 -0
  17. package/dist/admin/forms/ConfirmDialog.d.ts +25 -0
  18. package/dist/admin/forms/Field.d.ts +48 -0
  19. package/dist/admin/forms/People.d.ts +28 -0
  20. package/dist/admin/forms/Toast.d.ts +17 -0
  21. package/dist/admin/icons.d.ts +31 -0
  22. package/dist/admin/index.d.ts +33 -0
  23. package/dist/admin/shell/AdminShell.d.ts +31 -0
  24. package/dist/admin/shell/Dock.d.ts +8 -0
  25. package/dist/admin/shell/PageHeader.d.ts +19 -0
  26. package/dist/admin/shell/Sidebar.d.ts +27 -0
  27. package/dist/admin/shell/ThemeToggle.d.ts +10 -0
  28. package/dist/admin/shell/nav.d.ts +33 -0
  29. package/dist/admin/styles.css +1677 -0
  30. package/dist/admin/theme.d.ts +30 -0
  31. package/dist/admin/ui/Avatar.d.ts +14 -0
  32. package/dist/admin/ui/Button.d.ts +19 -0
  33. package/dist/admin.d.ts +2 -0
  34. package/dist/admin.js +2168 -0
  35. package/package.json +36 -7
@@ -0,0 +1,17 @@
1
+ import { type ReactNode } from 'react';
2
+ type ToastApi = {
3
+ /** A short confirmation with the button's verb ("Suspended Leo Martin.", "Priya Nair is now an Editor."). */
4
+ done: (message: ReactNode) => void;
5
+ /** Something failed: what, and what to do. Stays until dismissed. */
6
+ error: (message: ReactNode) => void;
7
+ };
8
+ /** Toasts for the admin (AdminShell provides them): `const toast = useToast(); toast.done('Saved.')`. */
9
+ export declare function useToast(): ToastApi;
10
+ /**
11
+ * Holds the toasts and shows them: dark, short, with the sun tick; bottom right on desktop, above the
12
+ * dock on phones. Announced politely to screen readers. A done toast leaves after 4 seconds.
13
+ */
14
+ export declare function ToastProvider({ children }: {
15
+ children: ReactNode;
16
+ }): import("react").JSX.Element;
17
+ export {};
@@ -0,0 +1,31 @@
1
+ import type { SVGProps } from 'react';
2
+ /**
3
+ * A small set of line icons (24×24, currentColor, 1.9 stroke) for the shell and for apps' navigation.
4
+ * Decorative by default (aria-hidden): the link or button around one names it. Apps may pass any
5
+ * other icon as a ReactNode instead.
6
+ */
7
+ type IconProps = SVGProps<SVGSVGElement>;
8
+ export declare const icons: {
9
+ readonly home: (props: IconProps) => import("react").JSX.Element;
10
+ readonly users: (props: IconProps) => import("react").JSX.Element;
11
+ readonly box: (props: IconProps) => import("react").JSX.Element;
12
+ readonly chart: (props: IconProps) => import("react").JSX.Element;
13
+ readonly flag: (props: IconProps) => import("react").JSX.Element;
14
+ readonly gear: (props: IconProps) => import("react").JSX.Element;
15
+ readonly search: (props: IconProps) => import("react").JSX.Element;
16
+ readonly bell: (props: IconProps) => import("react").JSX.Element;
17
+ readonly screen: (props: IconProps) => import("react").JSX.Element;
18
+ readonly moon: (props: IconProps) => import("react").JSX.Element;
19
+ readonly sun: (props: IconProps) => import("react").JSX.Element;
20
+ readonly sidebar: (props: IconProps) => import("react").JSX.Element;
21
+ readonly doc: (props: IconProps) => import("react").JSX.Element;
22
+ readonly plus: (props: IconProps) => import("react").JSX.Element;
23
+ readonly check: (props: IconProps) => import("react").JSX.Element;
24
+ readonly block: (props: IconProps) => import("react").JSX.Element;
25
+ readonly chevronDown: (props: IconProps) => import("react").JSX.Element;
26
+ readonly chevronRight: (props: IconProps) => import("react").JSX.Element;
27
+ readonly chevronLeft: (props: IconProps) => import("react").JSX.Element;
28
+ readonly close: (props: IconProps) => import("react").JSX.Element;
29
+ };
30
+ export type IconName = keyof typeof icons;
31
+ export {};
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @jgb-solutions/admin: the admin panel kit for JGB Solutions apps. Import the stylesheet once
3
+ * (`import '@jgb-solutions/admin/styles.css'`), wrap the admin in <AdminShell>, and build pages from
4
+ * the blocks. Components take data and callbacks; the app fetches, checks permissions on the server
5
+ * and decides what happens.
6
+ */
7
+ export { AdminShell, type AdminShellProps } from './shell/AdminShell';
8
+ export { Sidebar, type SidebarProps, type AppIdentity } from './shell/Sidebar';
9
+ export { Dock, type DockProps } from './shell/Dock';
10
+ export { PageHeader, TopSearch, type PageHeaderProps, type TopSearchProps } from './shell/PageHeader';
11
+ export { ThemeToggle } from './shell/ThemeToggle';
12
+ export { plainLink, type NavItem, type NavSection, type LinkProps, type RenderLink } from './shell/nav';
13
+ export { useAdminTheme, type Theme, type ThemeChoice } from './theme';
14
+ export { Button, IconButton, type ButtonProps, type IconButtonProps } from './ui/Button';
15
+ export { Avatar, initials, type AvatarProps } from './ui/Avatar';
16
+ export { icons, type IconName } from './icons';
17
+ export { contrastRatio, inkOn } from './contrast';
18
+ export { Bento, Tile, type TileProps } from './blocks/Tile';
19
+ export { StatTile, Meter, AvatarStack, DeltaText, type StatTileProps, type Delta } from './blocks/Stat';
20
+ export { HeroChartTile, type HeroChartTileProps } from './blocks/Hero';
21
+ export { LineChart, type LineChartProps, type ChartPoint } from './blocks/LineChart';
22
+ export { SegmentedControl, type SegmentedOption } from './blocks/Segmented';
23
+ export { DataTable, PersonCell, RowAction, type Column, type DataTableProps } from './blocks/DataTable';
24
+ export { byNumber, byText, nextSort, sortRows, type ColumnSort, type SortDirection, type TableSort } from './blocks/sorting';
25
+ export { FilterTabs, type FilterOption } from './blocks/Filters';
26
+ export { PAGE_SIZES, PageSize, Pagination, type PageSizeProps, type PaginationProps } from './blocks/Pagination';
27
+ export { StatusBadge, PEOPLE_STATUS, type StatusTone } from './blocks/Status';
28
+ export { ActivityFeed, type Activity, type ActivityFeedProps } from './blocks/ActivityFeed';
29
+ export { Field, TextInput, TextArea, Select, Checkbox, Switch, type FieldProps, type FieldIds, type SelectOption } from './forms/Field';
30
+ export { ConfirmDialog, type ConfirmDialogProps } from './forms/ConfirmDialog';
31
+ export { useToast } from './forms/Toast';
32
+ export { RolePicker, BanControl, type RolePickerProps, type RoleOption, type BanControlProps } from './forms/People';
33
+ export { BarChart, type BarChartProps, type BarSeries } from './blocks/BarChart';
@@ -0,0 +1,31 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type ThemeChoice } from '../theme';
3
+ import type { NavSection, RenderLink } from './nav';
4
+ import { type AppIdentity, type SidebarProps } from './Sidebar';
5
+ export type AdminShellProps = {
6
+ app: AppIdentity;
7
+ /** The app's colour (hex): active navigation, primary buttons, meters, links. Text on it is white or ink, whichever reads better. */
8
+ brand?: string | undefined;
9
+ nav: NavSection[];
10
+ /** Which nav items the phone's dock shows, by key (at most 5). Default: the first 5. */
11
+ dockItems?: string[] | undefined;
12
+ user?: SidebarProps['user'];
13
+ /** Renders a navigation link with the app's router (TanStack Router's Link, Next's Link…). Default: <a href>. */
14
+ renderLink?: RenderLink | undefined;
15
+ /** Buttons in the phone's top bar, after the theme switch (notifications). */
16
+ mobileActions?: ReactNode;
17
+ /** Extra things at the bottom of the sidebar, above the person. */
18
+ sidebarFooter?: ReactNode;
19
+ /** The theme, when the app keeps it (controlled). */
20
+ theme?: ThemeChoice | undefined;
21
+ /** The theme before the stored one is read: what server rendering shows. Default "system". */
22
+ defaultTheme?: ThemeChoice | undefined;
23
+ onThemeChange?: ((choice: ThemeChoice) => void) | undefined;
24
+ children: ReactNode;
25
+ };
26
+ /**
27
+ * The admin's frame: the floating dark sidebar on desktop; on phones a top bar and the floating dock.
28
+ * Holds the theme (light, dark, system) and the app's brand colour. Every other part of the kit goes
29
+ * inside it, and its styles stay inside it (`.ja-root`).
30
+ */
31
+ export declare function AdminShell({ app, brand, nav, dockItems, user, renderLink, mobileActions, sidebarFooter, theme, defaultTheme, onThemeChange, children, }: AdminShellProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { type NavItem, type RenderLink } from './nav';
2
+ export type DockProps = {
3
+ /** Up to 5 items (more are not shown): icon over label, the current one filled with the brand colour. */
4
+ items: NavItem[];
5
+ renderLink?: RenderLink | undefined;
6
+ };
7
+ /** The phone's navigation: a floating dark dock at the bottom (760 px and below). */
8
+ export declare function Dock({ items, renderLink }: DockProps): import("react").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import type { InputHTMLAttributes, ReactNode } from 'react';
2
+ export type PageHeaderProps = {
3
+ /** The page's one h1. */
4
+ title: ReactNode;
5
+ /** One line of context under it. */
6
+ description?: ReactNode;
7
+ /** Desktop-only tools: search, theme, notifications. On phones they live in the top bar or the page. */
8
+ tools?: ReactNode;
9
+ /** The page's actions, shown on every screen size; one primary at most. */
10
+ actions?: ReactNode;
11
+ };
12
+ /** The top of a page: its title and context, then search, tools and the main action. */
13
+ export declare function PageHeader({ title, description, tools, actions }: PageHeaderProps): import("react").JSX.Element;
14
+ export type TopSearchProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> & {
15
+ /** The accessible name, also the placeholder unless one is given ("Search anything"). */
16
+ label: string;
17
+ };
18
+ /** The page's search field: a pill with the search icon. The app handles what it searches. */
19
+ export declare function TopSearch({ label, placeholder, className, ...input }: TopSearchProps): import("react").JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type NavSection, type RenderLink } from './nav';
3
+ /** The app's name and mark (a letter, or its logo), shown in the sidebar and the phone's top bar. */
4
+ export type AppIdentity = {
5
+ name: string;
6
+ mark: ReactNode;
7
+ };
8
+ export type SidebarProps = {
9
+ app: AppIdentity;
10
+ sections: NavSection[];
11
+ /** The signed-in person, at the bottom. */
12
+ user?: {
13
+ name: string;
14
+ role?: string | undefined;
15
+ image?: string | null | undefined;
16
+ } | undefined;
17
+ renderLink?: RenderLink | undefined;
18
+ /** Where the collapsed state is remembered in this browser. */
19
+ storageKey?: string | undefined;
20
+ /** Extra things above the person (a sign-out link). */
21
+ footer?: ReactNode;
22
+ };
23
+ /**
24
+ * The desktop navigation: Bento's floating dark panel with Daylight's labelled sections, collapsible
25
+ * to an icon rail (remembered in this browser). Hidden at 760 px and below, where the Dock takes over.
26
+ */
27
+ export declare function Sidebar({ app, sections, user, renderLink, storageKey, footer }: SidebarProps): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ /** Where an arrow, Home or End key moves in the group (the radio pattern), or null for another key. */
2
+ export declare function nextIndex(key: string, current: number, count: number): number | null;
3
+ /**
4
+ * The theme switch: light, dark, or the system's (the default). A radio group of three; in the
5
+ * dark sidebar it shows the names too, and in a collapsed sidebar it's one button that goes to the
6
+ * next choice. The choice is remembered (AdminShell keeps it).
7
+ */
8
+ export declare function ThemeToggle({ tone }: {
9
+ tone?: 'tile' | 'night';
10
+ }): import("react").JSX.Element;
@@ -0,0 +1,33 @@
1
+ import type { ReactNode } from 'react';
2
+ /** One place in the admin. `current` marks the page being shown. */
3
+ export type NavItem = {
4
+ /** Stable and unique: the React key, and how `dockItems` picks items. */
5
+ key: string;
6
+ label: string;
7
+ href: string;
8
+ icon: ReactNode;
9
+ /** A number to show next to it (people waiting, open reports). */
10
+ count?: number | string | undefined;
11
+ current?: boolean | undefined;
12
+ };
13
+ /** A labelled group in the sidebar ("Manage"). `end` groups sit at the bottom (Settings). */
14
+ export type NavSection = {
15
+ label?: string | undefined;
16
+ items: NavItem[];
17
+ placement?: 'start' | 'end' | undefined;
18
+ };
19
+ /** What a link needs; apps with a router pass `renderLink` to render their own link component. */
20
+ export type LinkProps = {
21
+ item: NavItem;
22
+ className: string;
23
+ 'aria-current': 'page' | undefined;
24
+ title: string | undefined;
25
+ children: ReactNode;
26
+ };
27
+ export type RenderLink = (props: LinkProps) => ReactNode;
28
+ /** A plain link: the default when the app passes no `renderLink`. */
29
+ export declare const plainLink: RenderLink;
30
+ /** "2481" → "2,481"; strings as given. */
31
+ export declare const formatCount: (count: number | string) => string;
32
+ /** A count for the icon rail's small badge: 99 at most ("99+"); strings as given. */
33
+ export declare const formatBadge: (count: number | string) => string;