@nurvus/ui 0.1.0-alpha.15 → 0.1.0-alpha.17

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 (87) hide show
  1. package/README.md +17 -1
  2. package/dist/icons.svg +74 -0
  3. package/dist/index.js +1 -1
  4. package/dist/nurvus.css +15 -10
  5. package/dist/respawn.js +1 -1
  6. package/dist/types/anchor.d.ts +37 -0
  7. package/dist/types/breakpoints.d.ts +14 -0
  8. package/dist/types/components/Anchor/Anchor.d.ts +30 -0
  9. package/dist/types/components/Dropdown/Dropdown.d.ts +31 -0
  10. package/dist/types/components/FullPageModal/FullPageModal.d.ts +11 -2
  11. package/dist/types/components/Grid/Grid.d.ts +26 -0
  12. package/dist/types/components/Loader/Loader.d.ts +21 -0
  13. package/dist/types/components/Menu/Menu.d.ts +61 -19
  14. package/dist/types/components/Progress/Progress.d.ts +19 -5
  15. package/dist/types/components/Stack/Stack.d.ts +26 -0
  16. package/dist/types/dialog.d.ts +12 -0
  17. package/dist/types/dropdown.d.ts +9 -0
  18. package/dist/types/icons.d.ts +29 -0
  19. package/dist/types/index.d.ts +13 -1
  20. package/dist/types/loader.d.ts +28 -0
  21. package/dist/types/logo.d.ts +5 -0
  22. package/dist/types/menu.d.ts +43 -14
  23. package/dist/types/progress.d.ts +11 -0
  24. package/dist/types/respawn/Anchor.d.ts +28 -0
  25. package/dist/types/respawn/Dropdown.d.ts +27 -0
  26. package/dist/types/respawn/FullPageModal.d.ts +7 -1
  27. package/dist/types/respawn/Grid.d.ts +21 -0
  28. package/dist/types/respawn/Loader.d.ts +18 -0
  29. package/dist/types/respawn/Menu.d.ts +47 -15
  30. package/dist/types/respawn/Progress.d.ts +18 -6
  31. package/dist/types/respawn/Stack.d.ts +21 -0
  32. package/dist/types/respawn/index.d.ts +13 -1
  33. package/package.json +1 -3
  34. package/src/anchor.ts +127 -0
  35. package/src/breakpoints.ts +28 -0
  36. package/src/components/Anchor/Anchor.md +59 -0
  37. package/src/components/Anchor/Anchor.scss +65 -0
  38. package/src/components/Anchor/Anchor.tsx +105 -0
  39. package/src/components/Button/Button.scss +20 -20
  40. package/src/components/Dropdown/Dropdown.md +48 -0
  41. package/src/components/Dropdown/Dropdown.scss +67 -0
  42. package/src/components/Dropdown/Dropdown.tsx +110 -0
  43. package/src/components/FullPageModal/FullPageModal.md +20 -17
  44. package/src/components/FullPageModal/FullPageModal.scss +5 -0
  45. package/src/components/FullPageModal/FullPageModal.tsx +37 -3
  46. package/src/components/Grid/Grid.md +37 -0
  47. package/src/components/Grid/Grid.scss +37 -0
  48. package/src/components/Grid/Grid.tsx +54 -0
  49. package/src/components/HistoryList/HistoryList.scss +2 -2
  50. package/src/components/Loader/Loader.md +30 -0
  51. package/src/components/Loader/Loader.scss +42 -0
  52. package/src/components/Loader/Loader.tsx +68 -0
  53. package/src/components/Menu/Menu.md +67 -3
  54. package/src/components/Menu/Menu.scss +126 -18
  55. package/src/components/Menu/Menu.tsx +159 -40
  56. package/src/components/Progress/Progress.md +27 -26
  57. package/src/components/Progress/Progress.scss +41 -36
  58. package/src/components/Progress/Progress.tsx +50 -6
  59. package/src/components/Select/Select.scss +20 -19
  60. package/src/components/Stack/Stack.md +43 -0
  61. package/src/components/Stack/Stack.scss +36 -0
  62. package/src/components/Stack/Stack.tsx +52 -0
  63. package/src/components/Table/Table.scss +1 -1
  64. package/src/components/Tag/Tag.scss +2 -2
  65. package/src/components/Title/Title.scss +6 -6
  66. package/src/components/Tree/Tree.md +1 -1
  67. package/src/css.ts +5 -0
  68. package/src/dialog.ts +47 -0
  69. package/src/dropdown.ts +24 -0
  70. package/src/icons.ts +31 -0
  71. package/src/index.ts +13 -1
  72. package/src/loader.ts +43 -0
  73. package/src/logo.ts +12 -0
  74. package/src/menu.ts +91 -21
  75. package/src/progress.ts +21 -0
  76. package/src/respawn/Anchor.ts +126 -0
  77. package/src/respawn/Dropdown.ts +90 -0
  78. package/src/respawn/FullPageModal.ts +30 -3
  79. package/src/respawn/Grid.ts +41 -0
  80. package/src/respawn/Loader.ts +77 -0
  81. package/src/respawn/Menu.ts +144 -37
  82. package/src/respawn/Progress.ts +56 -13
  83. package/src/respawn/Stack.ts +37 -0
  84. package/src/respawn/index.ts +13 -1
  85. package/src/styles/breakpoints.scss +3 -0
  86. package/src/styles/theme.scss +55 -55
  87. package/src/styles/type.json +9 -9
@@ -0,0 +1,37 @@
1
+ export interface AnchorItem {
2
+ /** "#id" of the section (or any link). */
3
+ href: string;
4
+ /** What the row says. */
5
+ label: string;
6
+ /** 1 for a top-level section, 2 for one inside it, and so on. Defaults to 1. */
7
+ level?: number;
8
+ }
9
+ export declare const ANCHOR_ROW = 28;
10
+ export declare const ANCHOR_INDENT = 12;
11
+ export interface AnchorRail {
12
+ /** The path, in units (1 unit = 1px at the default text size). */
13
+ d: string;
14
+ width: number;
15
+ height: number;
16
+ /** The whole path's length. */
17
+ length: number;
18
+ /** Each row's stretch along the path: [start, end]. */
19
+ spans: [number, number][];
20
+ }
21
+ /** The rail for rows at these levels. */
22
+ export declare function anchorRail(levels: number[]): AnchorRail;
23
+ /** The dash that lights row `i`'s stretch: stroke-dasharray and stroke-dashoffset. */
24
+ export declare function anchorDash(rail: AnchorRail, i: number): {
25
+ dasharray: string;
26
+ dashoffset: number;
27
+ };
28
+ /** The id an "#id" href points at, or null for other links. */
29
+ export declare const anchorTarget: (href: string) => string | null;
30
+ /**
31
+ * Which row is in view: the last section whose top has passed `offset` pixels
32
+ * below the top of the scroll area (the first one before any has), and the
33
+ * last one once the area is scrolled to its end.
34
+ */
35
+ export declare function anchorActive(items: AnchorItem[], offset: number, scrollRoot?: Element | null): number;
36
+ /** Scrolls a section into view (smoothly unless people asked for less motion) and moves focus to it. */
37
+ export declare function anchorGo(href: string, updateHash: boolean): boolean;
@@ -0,0 +1,14 @@
1
+ export type Breakpoint = 'sm' | 'md' | 'lg' | 'xl';
2
+ /** Each breakpoint's min-width: from this width up, the `sm`/`md`/`lg`/`xl` value applies. */
3
+ export declare const BREAKPOINTS: Record<Breakpoint, string>;
4
+ /** A value for every width (`base`), changing from a breakpoint up: { base: 1, md: 2, lg: 3 }. */
5
+ export type Responsive<T> = T | ({
6
+ base?: T;
7
+ } & Partial<Record<Breakpoint, T>>);
8
+ /** `true` once the window is at least as wide as `breakpoint` (for your own code). */
9
+ export declare const isAtLeast: (breakpoint: Breakpoint) => boolean;
10
+ /**
11
+ * The data attributes for a responsive value: data-<name>="base value" and
12
+ * data-<name>-md="…" for each breakpoint given. The CSS reads them.
13
+ */
14
+ export declare function responsiveData<T>(name: string, value: Responsive<T> | undefined): Record<string, T | undefined>;
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { AnchorItem } from '../../anchor';
3
+ export type { AnchorItem };
4
+ export interface AnchorProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
5
+ /** The sections, in page order: each an "#id" href, a label and a level (1, 2…). */
6
+ items: AnchorItem[];
7
+ /** The heading above the list. */
8
+ title?: string;
9
+ /** Prefix for the ids inside (the title is "<id>-title"). Defaults to "anchor". */
10
+ id?: string;
11
+ /** How far below the top a section's heading must be scrolled to count as "in view", in pixels (room for a sticky header). */
12
+ offset?: number;
13
+ /** The section in view, set by you (its href). Left out, the Anchor follows the scrolling itself. */
14
+ current?: string;
15
+ /** Scroll-spy inside this element instead of the page: an element or a CSS selector. */
16
+ scrollRoot?: Element | string;
17
+ /** Writes the section's #id in the address bar when one is picked. Turn off for hash routers. */
18
+ updateHash?: boolean;
19
+ /** Called when a row is picked, with its href. Call event.preventDefault() to handle it yourself. */
20
+ onNavigate?: (href: string, event: React.MouseEvent<HTMLAnchorElement>) => void;
21
+ /** Custom class name. */
22
+ className?: string;
23
+ }
24
+ /**
25
+ * "On this page": the sections of a long page, the one being read marked as
26
+ * you scroll. A rail runs down beside the rows, bending in and out with the
27
+ * nesting, and a highlight slides along it to the section in view. Picking a
28
+ * row scrolls to the section and moves focus there.
29
+ */
30
+ export default function Anchor({ items, title, id, offset, current, scrollRoot, updateHash, onNavigate, className, ...restProps }: AnchorProps): React.ReactElement;
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { ButtonSize, ButtonType } from '../Button/Button';
3
+ import { MenuItem, MenuSection } from '../Menu/Menu';
4
+ export interface DropdownProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> {
5
+ /** What the button says (text, or an Icon with a label for an icon-only button). */
6
+ label: React.ReactNode;
7
+ /** The actions, in groups (each may have a title). */
8
+ sections?: MenuSection[];
9
+ /** Or the actions as one flat list. */
10
+ items?: MenuItem[];
11
+ /** Which edge of the button the menu lines up with. */
12
+ align?: 'start' | 'end';
13
+ /** The button's look. Defaults to secondary. */
14
+ type?: ButtonType;
15
+ /** The button's size. */
16
+ size?: ButtonSize;
17
+ /** Stops the button working. */
18
+ disabled?: boolean;
19
+ /** Names the button and the menu ("<id>-button", "<id>-menu"). */
20
+ id: string;
21
+ /** Custom class name. */
22
+ className?: string;
23
+ }
24
+ /**
25
+ * A button that opens a menu of actions (the WAI-ARIA menu button pattern).
26
+ * A click, Enter, Space or ↓ opens it on its first item, ↑ on its last; inside,
27
+ * the Menu's keys work (↑ ↓ Home End, type a letter); choosing an action runs
28
+ * it, closes the menu and puts focus back on the button; Esc does the same
29
+ * without choosing; Tab or a click outside closes it.
30
+ */
31
+ export default function Dropdown({ label, sections, items, align, type, size, disabled, id, className, ...restProps }: DropdownProps): React.ReactElement;
@@ -8,8 +8,17 @@ export interface FullPageModalProps extends Omit<React.HTMLAttributes<HTMLDivEle
8
8
  headerActions?: React.ReactNode;
9
9
  /** The modal's content. */
10
10
  children?: React.ReactNode;
11
+ /** Called when someone presses Esc. Set visible to false in it to close the modal. */
12
+ onClose?: () => void;
13
+ /** Names the modal and its title: the title gets the id "<id>-title", and the modal is labelled by it. */
14
+ id?: string;
11
15
  /** Custom class name. */
12
16
  className?: string;
13
17
  }
14
- /** Shows additional content over the whole screen, rendered into `<body>`. */
15
- export default function FullPageModal({ children, className, headerActions, title, visible, ...restProps }: FullPageModalProps): React.ReactElement;
18
+ /**
19
+ * Shows content over the whole screen, rendered into `<body>`: a modal dialog
20
+ * (the WAI-ARIA dialog pattern). Opening it moves focus into it, and screen
21
+ * readers say its title and "dialog"; Tab stays inside; Esc calls onClose;
22
+ * closing it gives focus back to where it was.
23
+ */
24
+ export default function FullPageModal({ children, className, headerActions, title, visible, onClose, id, onKeyDown, ...restProps }: FullPageModalProps): React.ReactElement;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { Spacing } from '../../spacing';
3
+ import { Responsive } from '../../breakpoints';
4
+ export type GridColumns = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
5
+ export interface GridProps extends React.HTMLAttributes<HTMLDivElement> {
6
+ /** How many equal columns: 1 to 12. Can change with the width: { base: 1, md: 2, lg: 3 }. */
7
+ columns?: Responsive<GridColumns>;
8
+ /** Instead of a count: as many columns as fit, each at least this wide (e.g. "15rem" or 240). They fill the row. */
9
+ minItemWidth?: string | number;
10
+ /** Space between cells, from the 4px grid: 0, 2, 4, 8, 12, 16, 24, 32, 48 or 64. */
11
+ gap?: Spacing;
12
+ /** Space between rows when it differs from gap. */
13
+ rowGap?: Spacing;
14
+ /** How cells line up in their row. Defaults to stretch (equal heights). */
15
+ align?: 'start' | 'center' | 'end' | 'stretch';
16
+ /** What to lay out. A child spans more columns with style={{ gridColumn: 'span 2' }}. */
17
+ children?: React.ReactNode;
18
+ /** Custom class name. */
19
+ className?: string;
20
+ }
21
+ /**
22
+ * Lays its children out in columns: a fixed count that changes at the
23
+ * breakpoints (1 on phones, 3 on desktops), or as many as fit at a minimum
24
+ * width. Columns share the width equally and never overflow it.
25
+ */
26
+ export default function Grid({ columns, minItemWidth, gap, rowGap, align, className, style, ...restProps }: GridProps): React.ReactElement;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ export interface LoaderProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ /** Width and height of the mark. Defaults to 2em (twice the text size). A number is pixels. */
4
+ size?: number | string;
5
+ /** What is loading, for screen readers ("Loading photos"). Defaults to "Loading". */
6
+ label?: string;
7
+ /** Shows the label beside the mark, not only to screen readers. */
8
+ showLabel?: boolean;
9
+ /** Fills the segments with the logo's gradients (for big loaders); their ids start with this. Without it, one color each. */
10
+ id?: string;
11
+ /** Custom class name. */
12
+ className?: string;
13
+ }
14
+ /**
15
+ * Shows that something is loading: the NURVUS mark with a light running round
16
+ * it (the logo's Pulse). Screen readers hear the label once, politely
17
+ * (role="status"). The light keeps running with reduced motion: it only
18
+ * changes brightness, nothing moves, and a loader that stopped would look
19
+ * stuck (WCAG 2.2.2 counts a loading animation as essential).
20
+ */
21
+ export default function Loader({ size, label, showLabel, id, className, ...restProps }: LoaderProps): React.ReactElement;
@@ -1,43 +1,85 @@
1
1
  import React from 'react';
2
+ import { MenuKind } from '../../menu';
3
+ import { TreeProps, TreeItem } from '../Tree/Tree';
4
+ export type { MenuKind };
2
5
  export interface MenuItem {
3
- /** What the link says. */
6
+ /** What the item says. */
4
7
  label: React.ReactNode;
5
- /** Where it goes. The item whose href equals `current` is marked as the current page. */
6
- href: string;
8
+ /** Makes the item a link to this address. The item whose href equals `current` is marked as the current page. */
9
+ href?: string;
10
+ /** Makes the item a button that calls this (an action: "Duplicate", "Sign out"). */
11
+ onSelect?: (event: React.MouseEvent<HTMLElement>) => void;
12
+ /** Shows the item but stops it working (actions only). */
13
+ disabled?: boolean;
7
14
  /** Draws a hairline above this item, to split a section into groups. */
8
15
  divider?: boolean;
9
16
  }
10
17
  export interface MenuSection {
11
18
  /** Stable id: names the section's open state and links its toggle to its list. Defaults to the title. */
12
19
  id?: string;
13
- /** The section heading. */
14
- title: React.ReactNode;
20
+ /** The section heading. Optional for actions. */
21
+ title?: React.ReactNode;
15
22
  /** Makes the heading a link too (e.g. to the section's overview page). */
16
23
  href?: string;
17
- /** The section's links. */
24
+ /** The section's items. */
18
25
  items: MenuItem[];
19
26
  }
20
- export interface MenuProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onToggle'> {
21
- /** The sections, in order. */
22
- sections: MenuSection[];
23
- /** The href of the page being shown: its link is marked, and its section opens. */
27
+ export interface MenuProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onToggle' | 'onClick'> {
28
+ /**
29
+ * What the menu is, which decides what screen readers hear and which keys
30
+ * work: 'nav' (links: a navigation landmark), 'actions' (commands: a menu
31
+ * of buttons) or 'tree' (rows to pick from, with Tree's props). Left out,
32
+ * it follows the props: navigation if any item has an href, actions if none
33
+ * has, a tree for `items`.
34
+ */
35
+ kind?: MenuKind;
36
+ /** Navigation and actions: the sections, in order. */
37
+ sections?: MenuSection[];
38
+ /** Navigation: the href of the page being shown. Its link is marked, and its section opens. */
24
39
  current?: string;
25
- /** Which sections start open: true (all), false (none) or a map of section id → open. Defaults to all. */
40
+ /** Navigation: which sections start open: true (all), false (none) or a map of section id → open. Defaults to all. */
26
41
  defaultOpen?: boolean | Record<string, boolean>;
27
- /** Called when a section opens or closes (e.g. to remember it). */
42
+ /** Navigation: called when a section opens or closes (e.g. to remember it). */
28
43
  onToggle?: (id: string, open: boolean) => void;
29
- /** Called when any link is clicked, with its href (e.g. to close a drawer). */
44
+ /** Navigation: called when any link is clicked, with its href (e.g. to close a drawer). */
30
45
  onNavigate?: (href: string, event: React.MouseEvent<HTMLAnchorElement>) => void;
31
- /** Accessible name of the navigation landmark. */
46
+ /**
47
+ * Navigation: where each section's chevron sits. 'start' (the default): before
48
+ * the title, pointing right when closed and down when open, with a guide line
49
+ * down the open section's items (as Material UI draws it). 'end': after the
50
+ * title, down when closed and up when open.
51
+ */
52
+ chevron?: 'start' | 'end';
53
+ /** Tree: the rows, each with optional child `items`. */
54
+ items?: TreeItem[];
55
+ /** Tree: the picked row as a path of indexes, e.g. [2, 0] = the first child of the third row. */
56
+ activePath?: number[];
57
+ /** Tree: called when a row is picked (a click, Enter or Space), with the event and the row's path. */
58
+ onClick?: (event: React.MouseEvent<HTMLDivElement>, path: number[]) => void;
59
+ /** Tree: draws a row's content instead of its label. */
60
+ itemRenderer?: (item: TreeItem) => React.ReactNode;
61
+ /** Tree: the deepest level that still indents. */
62
+ maxIndentDepth?: number;
63
+ /** What screen readers call the menu ("Pages", "Actions", "Layers"). */
32
64
  label?: string;
33
- /** Prefix for the ids that link each toggle to its list. Defaults to "menu". */
65
+ /** Prefix for the ids inside (each toggle names its list). Defaults to "menu". A menu of actions also carries it (so a button can point at it with aria-controls). */
34
66
  id?: string;
35
67
  /** Custom class name. */
36
68
  className?: string;
37
69
  }
70
+ /** Menu's props for navigation and actions. */
71
+ export type MenuListProps = Omit<MenuProps, 'items' | 'activePath' | 'onClick' | 'itemRenderer' | 'maxIndentDepth'>;
72
+ /** Menu kind="tree": Tree's props (Tree is the same thing under its own name). */
73
+ export type MenuTreeProps = TreeProps & {
74
+ kind: 'tree';
75
+ };
38
76
  /**
39
- * Site navigation: sections of links that open and close (an accordion, with
40
- * a smooth animation), and the current page marked by a bar beside it.
41
- * A section opens by itself when the current page is in it.
77
+ * One component for lists of things to go to, do or pick. The items decide
78
+ * what it is, and screen readers hear it that way:
79
+ * - links: site navigation (sections that open and close, the current page
80
+ * marked), and Tab goes link by link;
81
+ * - actions: a menu of commands, one Tab stop, the arrow keys move;
82
+ * - kind="tree": a tree to pick a row from, like layers (see Tree).
83
+ * Up and Down move between items in all three.
42
84
  */
43
- export default function Menu({ defaultOpen, label, ...props }: MenuProps): React.ReactElement;
85
+ export default function Menu(props: MenuProps): React.ReactElement;
@@ -1,15 +1,29 @@
1
1
  import React from 'react';
2
+ import { ProgressStatus } from '../../progress';
2
3
  export type ProgressSize = 'small' | 'medium' | 'large';
3
- export type ProgressStatus = 'active' | 'success' | 'warning' | 'critical';
4
- export interface ProgressProps {
4
+ export type { ProgressStatus };
5
+ export interface ProgressProps extends React.HTMLAttributes<HTMLDivElement> {
5
6
  /** How far along, 0 to 100. */
6
7
  percent?: number;
7
8
  /** Bar height. */
8
9
  size?: ProgressSize;
9
- /** The bar color: active (accent), success, warning or critical (danger). */
10
+ /** The bar color: active (accent), success, warning or critical (danger). With a label or showValue, a status also shows as an icon and a word. */
10
11
  status?: ProgressStatus;
12
+ /** What is in progress ("Uploading"): shown above the bar, and its name for screen readers. */
13
+ label?: string;
14
+ /** Keeps the label for screen readers only. */
15
+ hideLabel?: boolean;
16
+ /** Shows the percent (and the status, as an icon and a word) at the right, above the bar. */
17
+ showValue?: boolean;
18
+ /** What screen readers say for the value, instead of "40%" (e.g. "3 of 8 files"). */
19
+ valueText?: string;
11
20
  /** Custom class name. */
12
21
  className?: string;
13
22
  }
14
- /** A progress bar. Use it to track progress! */
15
- export default function Progress({ className, percent, size, status }: ProgressProps): React.ReactElement;
23
+ /**
24
+ * A progress bar: how far along something is. Screen readers hear it as a
25
+ * progress bar with its label and value ("Uploading, progress bar, 40%").
26
+ * Its status is never color alone: with a label or showValue it shows as an
27
+ * icon and a word too, and screen readers hear the word.
28
+ */
29
+ export default function Progress({ className, percent, size, status, label, hideLabel, showValue, valueText, ...restProps }: ProgressProps): React.ReactElement;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { Spacing } from '../../spacing';
3
+ import { Responsive } from '../../breakpoints';
4
+ export type StackDirection = 'column' | 'row';
5
+ export interface StackProps extends React.HTMLAttributes<HTMLDivElement> {
6
+ /** column (top to bottom, the default) or row. Can change with the width: { base: 'column', md: 'row' }. */
7
+ direction?: Responsive<StackDirection>;
8
+ /** Space between the children, from the 4px grid: 0, 2, 4, 8, 12, 16, 24, 32, 48 or 64. */
9
+ gap?: Spacing;
10
+ /** How the children line up across the stack. */
11
+ align?: 'start' | 'center' | 'end' | 'stretch' | 'baseline';
12
+ /** How the children spread along the stack. */
13
+ justify?: 'start' | 'center' | 'end' | 'between';
14
+ /** Lets a row wrap onto more lines when it runs out of room. */
15
+ wrap?: boolean;
16
+ /** What to lay out. */
17
+ children?: React.ReactNode;
18
+ /** Custom class name. */
19
+ className?: string;
20
+ }
21
+ /**
22
+ * Puts its children in a column or a row with even space between them, from
23
+ * the 4px grid (CSS gap, so wrapped rows keep their spacing too). The
24
+ * direction can change at a breakpoint: a column on phones, a row from md up.
25
+ */
26
+ export default function Stack({ direction, gap, align, justify, wrap, className, ...restProps }: StackProps): React.ReactElement;
@@ -0,0 +1,12 @@
1
+ /** The elements Tab can reach inside `root`, in order (shown ones, not tabindex="-1"). */
2
+ export declare function focusables(root: HTMLElement): HTMLElement[];
3
+ /**
4
+ * The keys of a modal dialog (the WAI-ARIA dialog pattern): Tab and
5
+ * Shift+Tab go round the dialog's own controls and never leave it; Esc calls
6
+ * onClose. Returns true when it used the key.
7
+ */
8
+ export declare function dialogKeydown(event: KeyboardEvent, dialog: HTMLElement, onClose?: () => void): boolean;
9
+ /** Moves focus to the dialog itself once it shows (screen readers then say its name and "dialog"). */
10
+ export declare function focusDialog(dialog: HTMLElement): void;
11
+ /** Gives focus back to what had it before the dialog opened, if it is still on the page. */
12
+ export declare function restoreFocus(opener: Element | null): void;
@@ -0,0 +1,9 @@
1
+ /** The menu's items, in order. */
2
+ export declare const menuItems: (root: HTMLElement) => HTMLElement[];
3
+ /** Moves focus to the first or last item (and makes it the menu's Tab stop). */
4
+ export declare function focusItem(root: HTMLElement, which: 'first' | 'last'): void;
5
+ /**
6
+ * Keys on the button: ↓ (or Enter / Space, which click it) opens the menu on
7
+ * its first item, ↑ on its last. Returns which item to focus, or null.
8
+ */
9
+ export declare function triggerKey(event: KeyboardEvent): 'first' | 'last' | null;
@@ -12,6 +12,12 @@ declare const DEFS: {
12
12
  'arrow-up': IconNode[];
13
13
  'arrow-down': IconNode[];
14
14
  'external-link': IconNode[];
15
+ home: IconNode[];
16
+ 'panel-left': IconNode[];
17
+ 'more-horizontal': IconNode[];
18
+ 'more-vertical': IconNode[];
19
+ maximize: IconNode[];
20
+ minimize: IconNode[];
15
21
  add: IconNode[];
16
22
  remove: IconNode[];
17
23
  edit: IconNode[];
@@ -25,6 +31,11 @@ declare const DEFS: {
25
31
  refresh: IconNode[];
26
32
  undo: IconNode[];
27
33
  redo: IconNode[];
34
+ settings: IconNode[];
35
+ share: IconNode[];
36
+ play: IconNode[];
37
+ pause: IconNode[];
38
+ 'sign-out': IconNode[];
28
39
  check: IconNode[];
29
40
  info: IconNode[];
30
41
  warning: IconNode[];
@@ -38,9 +49,27 @@ declare const DEFS: {
38
49
  'eye-off': IconNode[];
39
50
  lock: IconNode[];
40
51
  unlock: IconNode[];
52
+ user: IconNode[];
53
+ users: IconNode[];
54
+ mail: IconNode[];
55
+ bell: IconNode[];
56
+ calendar: IconNode[];
57
+ clock: IconNode[];
58
+ globe: IconNode[];
59
+ 'map-pin': IconNode[];
60
+ tag: IconNode[];
61
+ bookmark: IconNode[];
62
+ star: IconNode[];
63
+ heart: IconNode[];
64
+ grid: IconNode[];
65
+ list: IconNode[];
41
66
  link: IconNode[];
42
67
  sun: IconNode[];
43
68
  moon: IconNode[];
69
+ contrast: IconNode[];
70
+ palette: IconNode[];
71
+ sparkles: IconNode[];
72
+ zap: IconNode[];
44
73
  code: IconNode[];
45
74
  terminal: IconNode[];
46
75
  };
@@ -12,14 +12,26 @@ export { default as Progress } from './components/Progress/Progress';
12
12
  export type { ProgressProps, ProgressSize, ProgressStatus } from './components/Progress/Progress';
13
13
  export { default as Layout } from './components/Layout/Layout';
14
14
  export type { LayoutProps, Spacing, LegacySpacing } from './components/Layout/Layout';
15
+ export { default as Stack } from './components/Stack/Stack';
16
+ export type { StackProps, StackDirection } from './components/Stack/Stack';
17
+ export { default as Grid } from './components/Grid/Grid';
18
+ export type { GridProps, GridColumns } from './components/Grid/Grid';
19
+ export { BREAKPOINTS, isAtLeast } from './breakpoints';
20
+ export type { Breakpoint, Responsive } from './breakpoints';
15
21
  export { default as Icon } from './components/Icon/Icon';
16
22
  export type { IconProps } from './components/Icon/Icon';
17
23
  export { ICONS, ICON_NAMES } from './icons';
18
24
  export type { IconName, IconNode } from './icons';
25
+ export { default as Loader } from './components/Loader/Loader';
26
+ export type { LoaderProps } from './components/Loader/Loader';
19
27
  export { default as Tree } from './components/Tree/Tree';
20
28
  export type { TreeProps, TreeItem } from './components/Tree/Tree';
29
+ export { default as Anchor } from './components/Anchor/Anchor';
30
+ export type { AnchorProps, AnchorItem } from './components/Anchor/Anchor';
31
+ export { default as Dropdown } from './components/Dropdown/Dropdown';
32
+ export type { DropdownProps } from './components/Dropdown/Dropdown';
21
33
  export { default as Menu } from './components/Menu/Menu';
22
- export type { MenuProps, MenuItem, MenuSection } from './components/Menu/Menu';
34
+ export type { MenuProps, MenuListProps, MenuTreeProps, MenuItem, MenuSection, MenuKind } from './components/Menu/Menu';
23
35
  export { default as Select } from './components/Select/Select';
24
36
  export type { SelectProps, SelectOption, SelectOptionState } from './components/Select/Select';
25
37
  export { default as FullPageModal } from './components/FullPageModal/FullPageModal';
@@ -0,0 +1,28 @@
1
+ export { LOGO_VIEWBOX } from './logo';
2
+ export interface LoaderSegment {
3
+ d: string;
4
+ /** "url(#<id>-<n>)" with gradients, else one color. */
5
+ fill: string;
6
+ /** Where it sits round the ring, 0 to 1 from the top, clockwise: the pulse reaches it then. */
7
+ angle: number;
8
+ }
9
+ export interface LoaderGradient {
10
+ id: string;
11
+ x1: number;
12
+ y1: number;
13
+ x2: number;
14
+ y2: number;
15
+ from: string;
16
+ to: string;
17
+ }
18
+ /**
19
+ * The two rings' segments. With an `id`, each segment is filled with its own
20
+ * gradient (ids "<id>-0", "<id>-1"…), as in the logo; without one, with its
21
+ * gradient's middle color, so a page can show any number of loaders with no
22
+ * ids at all. They look the same up to about 64 pixels.
23
+ */
24
+ export declare function loaderRings(id?: string): {
25
+ inner: LoaderSegment[];
26
+ outer: LoaderSegment[];
27
+ gradients: LoaderGradient[];
28
+ };
@@ -0,0 +1,5 @@
1
+ export type LogoSegment = [d: string, from: string, to: string, line: [number, number, number, number], angle: number];
2
+ /** The artwork's viewBox around the mark alone. */
3
+ export declare const LOGO_VIEWBOX = "492 149 540 540";
4
+ export declare const LOGO_INNER: LogoSegment[];
5
+ export declare const LOGO_OUTER: LogoSegment[];
@@ -1,24 +1,53 @@
1
+ /**
2
+ * What a Menu is, and so what screen readers hear:
3
+ * - 'nav': navigation. A <nav> landmark of links ("link", "current page");
4
+ * an item without an href is a button in it ("button").
5
+ * - 'actions': a menu of commands (the WAI-ARIA menu pattern): role="menu",
6
+ * each item a "menu item"; one Tab stop, the arrow keys move.
7
+ * - 'tree': a tree to pick from (the WAI-ARIA tree pattern), like layers:
8
+ * "tree", each row "level 2, 3 of 5, selected". Drawn by Tree.
9
+ */
10
+ export type MenuKind = 'nav' | 'actions' | 'tree';
11
+ interface KindProps {
12
+ kind?: MenuKind;
13
+ sections?: {
14
+ href?: string;
15
+ items?: {
16
+ href?: string;
17
+ }[];
18
+ }[];
19
+ items?: unknown;
20
+ activePath?: unknown;
21
+ }
22
+ /**
23
+ * The kind to draw: `kind` when given; else a tree for Tree's props (items,
24
+ * activePath), navigation when any item is a link, a menu of actions when
25
+ * none is.
26
+ */
27
+ export declare function menuKind(props: KindProps): MenuKind;
1
28
  /** A section's id: its own, or its title as a slug ("Get started" -> "get-started"). */
2
29
  export declare const sectionId: (section: {
3
30
  id?: string;
4
- title: unknown;
31
+ title?: unknown;
5
32
  }) => string;
6
33
  /** Whether a section starts open: true / false for all, or a map of id -> open (missing = open). */
7
34
  export declare const startsOpen: (defaultOpen: boolean | Record<string, boolean> | undefined, id: string) => boolean;
8
- /** Menu used to be the nested, selectable list that is Tree now: say so once. */
9
- export declare function warnOldMenuProps(props: {
10
- sections?: unknown;
11
- items?: unknown;
12
- activePath?: unknown;
13
- }): boolean;
35
+ /** Makes `row` the one item of an actions menu that Tab reaches (roving tabindex). */
36
+ export declare function roveTo(menu: HTMLElement, row: HTMLElement): void;
37
+ /** Focus moved onto an item of an actions menu (a click, say): it becomes the Tab stop. */
38
+ export declare function menuFocus(event: FocusEvent, menu: HTMLElement): void;
14
39
  /**
15
- * The arrow keys on a Menu (the WAI-ARIA disclosure navigation pattern's
16
- * optional keys). Tab still goes link by link; on top of that:
17
- * - Up / Down: the previous / next row (section titles and the links in open
18
- * sections), going round at the ends;
19
- * - Home / End: the first / last row;
20
- * - Right on a section: opens it, or (when open) goes to its first link;
21
- * - Left on a section: closes it; Left on a link: goes up to its section.
40
+ * The keys on a Menu. Up / Down move to the previous / next item (going round
41
+ * at the ends) and Home / End to the first / last, in every kind.
42
+ * - Navigation (the WAI-ARIA disclosure navigation pattern, with its
43
+ * optional keys): Tab still goes link by link. The rows are the section
44
+ * titles and the links in open sections; Right on a section opens it, or
45
+ * goes to its first link; Left closes it, or goes from a link up to its
46
+ * section. Enter follows a link; Enter or Space opens a section.
47
+ * - Actions (the WAI-ARIA menu pattern): one Tab stop that follows the
48
+ * focus; typing a letter goes to the next item starting with it; Enter or
49
+ * Space runs the item.
22
50
  * Returns true when it used the key.
23
51
  */
24
52
  export declare function menuKeydown(event: KeyboardEvent, nav: HTMLElement): boolean;
53
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { IconName } from './icons';
2
+ export type ProgressStatus = 'active' | 'success' | 'warning' | 'critical';
3
+ /** What each status means, in words and as an icon, so it never rests on color alone (WCAG 1.4.1). */
4
+ export declare const PROGRESS_STATUS: Record<ProgressStatus, {
5
+ word: string;
6
+ icon?: IconName;
7
+ }>;
8
+ /** 0 to 100, whole numbers; anything else (NaN, -5, 140) is pulled into range. */
9
+ export declare const clampPercent: (percent: number) => number;
10
+ /** What screen readers say for the value: "40%", or "100%, Done". */
11
+ export declare const progressValueText: (percent: number, status: ProgressStatus) => string;
@@ -0,0 +1,28 @@
1
+ import { AnchorItem } from '../anchor';
2
+ import { ElementProps } from './spawn';
3
+ import { NurvusElement } from './update';
4
+ export type { AnchorItem };
5
+ export interface AnchorProps extends ElementProps {
6
+ /** The sections, in page order: each an "#id" href, a label and a level (1, 2…). */
7
+ items: AnchorItem[];
8
+ /** The heading above the list. */
9
+ title?: string;
10
+ /** Prefix for the ids inside (the title is "<id>-title"). Defaults to "anchor". */
11
+ id?: string;
12
+ /** How far below the top a section's heading must be scrolled to count as "in view", in pixels. */
13
+ offset?: number;
14
+ /** The section in view, set by you (its href). Left out, the Anchor follows the scrolling itself. */
15
+ current?: string;
16
+ /** Scroll-spy inside this element instead of the page: an element or a CSS selector. */
17
+ scrollRoot?: Element | string;
18
+ /** Writes the section's #id in the address bar when one is picked. Turn off for hash routers. */
19
+ updateHash?: boolean;
20
+ /** Called when a row is picked, with its href. Call event.preventDefault() to handle it yourself. */
21
+ onNavigate?: (href: string, event: MouseEvent) => void;
22
+ }
23
+ /**
24
+ * "On this page", the same markup as the React Anchor: the rail bends with the
25
+ * nesting and its highlight slides to the section in view, in place (the
26
+ * element stays the same while you scroll).
27
+ */
28
+ export default function Anchor(props: AnchorProps): NurvusElement<HTMLElement, AnchorProps>;
@@ -0,0 +1,27 @@
1
+ import { ButtonSize, ButtonType } from './Button';
2
+ import { MenuItem, MenuSection } from './Menu';
3
+ import { Child, ElementProps } from './spawn';
4
+ import { NurvusElement } from './update';
5
+ export interface DropdownProps extends ElementProps {
6
+ /** What the button says (text, or an Icon with a label for an icon-only button). */
7
+ label: Child;
8
+ /** The actions, in groups (each may have a title). */
9
+ sections?: MenuSection[];
10
+ /** Or the actions as one flat list. */
11
+ items?: MenuItem[];
12
+ /** Which edge of the button the menu lines up with. */
13
+ align?: 'start' | 'end';
14
+ /** The button's look. Defaults to secondary. */
15
+ type?: ButtonType;
16
+ /** The button's size. */
17
+ size?: ButtonSize;
18
+ /** Stops the button working. */
19
+ disabled?: boolean;
20
+ /** Names the button and the menu ("<id>-button", "<id>-menu"). */
21
+ id: string;
22
+ }
23
+ /**
24
+ * A button that opens a menu of actions, the same markup and keys as the React
25
+ * Dropdown. Opening and closing change it in place (the element stays the same).
26
+ */
27
+ export default function Dropdown(props: DropdownProps): NurvusElement<HTMLDivElement, DropdownProps>;