@ssa-ui-kit/core 3.21.3 → 3.22.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 (62) hide show
  1. package/dist/ai/source-map.md +2243 -0
  2. package/dist/components/ButtonGroup/ButtonGroup.d.ts +7 -3
  3. package/dist/components/ButtonGroup/ButtonGroupButton.d.ts +15 -5
  4. package/dist/components/ButtonGroup/ButtonGroupButtonBase.d.ts +17 -1
  5. package/dist/components/ButtonGroup/styles.d.ts +22 -0
  6. package/dist/components/ButtonGroup/types.d.ts +45 -7
  7. package/dist/components/Card/Card.d.ts +60 -0
  8. package/dist/components/Card/types.d.ts +13 -0
  9. package/dist/components/CardContent/CardContent.d.ts +46 -0
  10. package/dist/components/CardHeader/CardHeader.d.ts +42 -0
  11. package/dist/components/CollapsibleNavBar/CollapsibleNavBar.d.ts +35 -2
  12. package/dist/components/CollapsibleNavBar/components/NavHeader.d.ts +18 -0
  13. package/dist/components/CollapsibleNavBar/components/NavPopoverContent.d.ts +12 -0
  14. package/dist/components/CollapsibleNavBar/components/NavTree.d.ts +22 -0
  15. package/dist/components/CollapsibleNavBar/components/index.d.ts +3 -3
  16. package/dist/components/CollapsibleNavBar/navItems.d.ts +57 -0
  17. package/dist/components/CollapsibleNavBar/styles.d.ts +34 -0
  18. package/dist/components/CollapsibleNavBar/types.d.ts +40 -3
  19. package/dist/components/DatePicker/DatePicker.d.ts +57 -0
  20. package/dist/components/Drawer/DrawerRoot.d.ts +70 -0
  21. package/dist/components/DropdownOption/DropdownOption.d.ts +43 -0
  22. package/dist/components/Form/Form.d.ts +40 -0
  23. package/dist/components/Icon/Icon.d.ts +47 -0
  24. package/dist/components/Icon/icons/Columns.d.ts +3 -0
  25. package/dist/components/Icon/icons/List.d.ts +3 -0
  26. package/dist/components/Icon/icons/all.d.ts +2 -0
  27. package/dist/components/Icon/icons/iconsList.d.ts +1 -1
  28. package/dist/components/Icon/types.d.ts +13 -0
  29. package/dist/components/Input/Input.d.ts +94 -0
  30. package/dist/components/MultipleDropdown/MultipleDropdown.d.ts +73 -0
  31. package/dist/components/NestedTable/WithNestedTableRow.d.ts +39 -0
  32. package/dist/components/NestedTable/components/NestedTable.d.ts +57 -0
  33. package/dist/components/NestedTable/components/NestedTableCell.d.ts +33 -0
  34. package/dist/components/NestedTable/components/NestedTableRow.d.ts +44 -0
  35. package/dist/components/NestedTable/types.d.ts +17 -0
  36. package/dist/components/TableRow/TableRow.d.ts +51 -0
  37. package/dist/components/Tooltip/Tooltip.d.ts +10 -6
  38. package/dist/components/Tooltip/types.d.ts +20 -7
  39. package/dist/components/TooltipContent/TooltipContent.d.ts +7 -3
  40. package/dist/components/TreeView/TreeView.d.ts +62 -0
  41. package/dist/components/TreeView/TreeViewItem.d.ts +32 -0
  42. package/dist/components/TreeView/index.d.ts +2 -0
  43. package/dist/components/TreeView/styles.d.ts +18 -0
  44. package/dist/components/TreeView/types.d.ts +162 -0
  45. package/dist/components/TreeView/useTreeViewState.d.ts +21 -0
  46. package/dist/components/TreeView/utils.d.ts +42 -0
  47. package/dist/components/Wrapper/Wrapper.d.ts +6 -6
  48. package/dist/components/index.d.ts +1 -0
  49. package/dist/index.js +2326 -678
  50. package/dist/index.mjs +2327 -680
  51. package/dist/tsbuildcache +1 -1
  52. package/package.json +4 -4
  53. package/dist/components/CollapsibleNavBar/components/ItemWithSubmenu/AccordionContent.d.ts +0 -11
  54. package/dist/components/CollapsibleNavBar/components/ItemWithSubmenu/AccordionContentItem.d.ts +0 -8
  55. package/dist/components/CollapsibleNavBar/components/ItemWithSubmenu/CollapsibleNavBarItem.d.ts +0 -6
  56. package/dist/components/CollapsibleNavBar/components/ItemWithSubmenu/ItemAccordionTitle.d.ts +0 -9
  57. package/dist/components/CollapsibleNavBar/components/ItemWithSubmenu/ItemWithSubMenu.d.ts +0 -7
  58. package/dist/components/CollapsibleNavBar/components/ItemWithSubmenu/index.d.ts +0 -5
  59. package/dist/components/CollapsibleNavBar/components/ItemWithSubmenu/styles.d.ts +0 -6
  60. package/dist/components/CollapsibleNavBar/components/ItemWithoutSubmenu/ItemWithoutSubMenu.d.ts +0 -5
  61. package/dist/components/CollapsibleNavBar/components/ItemWithoutSubmenu/index.d.ts +0 -1
  62. package/dist/components/CollapsibleNavBar/components/NavBarItem.d.ts +0 -8
@@ -1,4 +1,61 @@
1
1
  import { PropsWithChildren, TableHTMLAttributes } from 'react';
2
2
  import { CommonProps } from '../../../types/emotion';
3
3
  import { NestedTableContextType } from '../types';
4
+ /**
5
+ * NestedTable - Table whose rows collapse into expandable groups.
6
+ *
7
+ * Renders a `Table` and provides the context the nested row components read, so
8
+ * every piece below must live inside it.
9
+ *
10
+ * ### Structure
11
+ * ```
12
+ * NestedTable — provides icons + default collapsed state
13
+ * └── TableBody
14
+ * └── WithNestedTableRow — one collapsible group
15
+ * ├── NestedTableRow — first child: the sub-header that toggles
16
+ * │ └── NestedTableCell
17
+ * └── NestedTableRow — remaining children: the collapsible rows
18
+ * └── NestedTableCell
19
+ * ```
20
+ *
21
+ * Each `WithNestedTableRow` is one group. Use as many as you need, and give the
22
+ * header row its own `WithNestedTableRow` with `isHeader` on the row.
23
+ *
24
+ * ### Collapsing is CSS, not unmounting
25
+ * Collapsed rows stay in the DOM at zero height with `visibility: hidden`, which
26
+ * is what makes the transition animate. They remain findable by queries and by
27
+ * `Ctrl+F`, so do not rely on collapse to hide sensitive content.
28
+ *
29
+ * @category Components
30
+ * @subcategory Data Display
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * <NestedTable>
35
+ * <TableBody>
36
+ * <WithNestedTableRow>
37
+ * <NestedTableRow>
38
+ * <NestedTableCell>Engineering</NestedTableCell>
39
+ * <NestedTableCell>24</NestedTableCell>
40
+ * </NestedTableRow>
41
+ * <NestedTableRow>
42
+ * <NestedTableCell>Platform</NestedTableCell>
43
+ * <NestedTableCell>9</NestedTableCell>
44
+ * </NestedTableRow>
45
+ * </WithNestedTableRow>
46
+ * </TableBody>
47
+ * </NestedTable>
48
+ * ```
49
+ *
50
+ * @example
51
+ * ```tsx
52
+ * // Start collapsed, with custom toggle icons
53
+ * <NestedTable
54
+ * defaultCollapsed
55
+ * collapsedIconName="carrot-right"
56
+ * expandedIconName="carrot-down">
57
+ * {groups}
58
+ * </NestedTable>
59
+ * ```
60
+ */
4
61
  export declare const NestedTable: ({ children, collapsedIconName, expandedIconName, defaultCollapsed, ...rest }: PropsWithChildren & NestedTableContextType & CommonProps & TableHTMLAttributes<HTMLTableElement>) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,3 +1,36 @@
1
1
  import { HTMLAttributes } from 'react';
2
2
  import { CommonProps } from '../../../types/emotion';
3
+ /**
4
+ * NestedTableCell - Cell for a `NestedTableRow`.
5
+ *
6
+ * Use instead of `TableCell` inside a nested table: it reads the group's
7
+ * collapsed state and animates its own height, which a plain `TableCell` will
8
+ * not do. Must be rendered inside `WithNestedTableRow`.
9
+ *
10
+ * ### Children are wrapped in a div
11
+ * The cell renders its children inside a `Wrapper`, and the collapse transition
12
+ * animates that inner element rather than the `td`. Two consequences: a `& div`
13
+ * selector in your `css` will hit the wrapper, and content that must fill the
14
+ * cell should stretch the wrapper rather than the cell itself.
15
+ *
16
+ * Borders and background are cleared so the group reads as one block; the row
17
+ * supplies the shading.
18
+ *
19
+ * @category Components
20
+ * @subcategory Data Display
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * <NestedTableRow>
25
+ * <NestedTableCell>Platform</NestedTableCell>
26
+ * <NestedTableCell>9</NestedTableCell>
27
+ * </NestedTableRow>
28
+ * ```
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * // Header cells render as `th`
33
+ * <NestedTableCell as="th">Headcount</NestedTableCell>
34
+ * ```
35
+ */
3
36
  export declare const NestedTableCell: ({ children, ...props }: React.PropsWithChildren<HTMLAttributes<HTMLTableCellElement>> & CommonProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,4 +1,48 @@
1
1
  import { HTMLAttributes } from 'react';
2
+ /**
3
+ * NestedTableRow - One row inside a `WithNestedTableRow` group.
4
+ *
5
+ * Must be rendered inside `WithNestedTableRow`; it reads that group's context to
6
+ * know whether it is the sub-header and whether the group is collapsed.
7
+ *
8
+ * ### It prepends a cell for you
9
+ * The row renders a narrow toggle cell **before** your children, so a row with
10
+ * two `NestedTableCell` children occupies **three** columns. Size the header and
11
+ * `colSpan` values accordingly — this is the usual cause of a nested table
12
+ * whose columns look off by one.
13
+ *
14
+ * ### First child in the group is the toggle
15
+ * The first `NestedTableRow` in a `WithNestedTableRow` is the sub-header: it is
16
+ * shaded, its cells are bold, it shows the toggle icon, and clicking anywhere on
17
+ * it collapses or expands the rest of the group. Later rows are the collapsible
18
+ * body. A group holding only one row shows no toggle and never collapses.
19
+ *
20
+ * @category Components
21
+ * @subcategory Data Display
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * <WithNestedTableRow>
26
+ * <NestedTableRow>
27
+ * <NestedTableCell>Engineering</NestedTableCell>
28
+ * </NestedTableRow>
29
+ * <NestedTableRow>
30
+ * <NestedTableCell>Platform</NestedTableCell>
31
+ * </NestedTableRow>
32
+ * </WithNestedTableRow>
33
+ * ```
34
+ *
35
+ * @example
36
+ * ```tsx
37
+ * // Header row: renders the leading cell as an empty `th`
38
+ * <WithNestedTableRow>
39
+ * <NestedTableRow isHeader>
40
+ * <NestedTableCell as="th">Team</NestedTableCell>
41
+ * <NestedTableCell as="th">Headcount</NestedTableCell>
42
+ * </NestedTableRow>
43
+ * </WithNestedTableRow>
44
+ * ```
45
+ */
2
46
  export declare const NestedTableRow: ({ children, isHeader, ...props }: React.PropsWithChildren<{
3
47
  isHeader?: boolean;
4
48
  } & HTMLAttributes<HTMLTableRowElement>>) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,8 +1,17 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
2
  import { IconProps } from '../Icon/types';
3
3
  export type NestedTableContextType = {
4
+ /** Toggle icon shown while a group is collapsed. @default 'carrot-up' */
4
5
  collapsedIconName?: IconProps['name'];
6
+ /** Toggle icon shown while a group is expanded. @default 'carrot-down' */
5
7
  expandedIconName?: IconProps['name'];
8
+ /**
9
+ * Whether groups start collapsed. Applies to every group in the table; a
10
+ * single `WithNestedTableRow` can override it. Groups holding one row ignore
11
+ * it, since they have no toggle to reopen with.
12
+ *
13
+ * @default false
14
+ */
6
15
  defaultCollapsed?: boolean;
7
16
  };
8
17
  export type NestedTableRowContextType = {
@@ -12,6 +21,14 @@ export type NestedTableRowContextType = {
12
21
  setIsCollapsed: Dispatch<SetStateAction<boolean>>;
13
22
  };
14
23
  export type WithNestedTableRowProps = {
24
+ /**
25
+ * The group's rows. The first element becomes the sub-header that toggles the
26
+ * group; the rest collapse under it.
27
+ */
15
28
  children: React.ReactNode | React.ReactNode[];
29
+ /**
30
+ * Overrides the table-level `defaultCollapsed` for this group only. Ignored
31
+ * when the group holds a single row.
32
+ */
16
33
  defaultCollapsed?: boolean;
17
34
  };
@@ -1,3 +1,54 @@
1
1
  import { TableRowProps } from './types';
2
+ /**
3
+ * TableRow - Table row component for table data
4
+ *
5
+ * A styled tr element that represents a single row in a table. Used within
6
+ * TableHead or TableBody sections. Supports disabled state for non-interactive
7
+ * rows. Works with TableCell or TableCellHeader components.
8
+ *
9
+ * @category Components
10
+ * @subcategory Data Display
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * // Basic table row in body
15
+ * <TableBody>
16
+ * <TableRow>
17
+ * <TableCell>John Doe</TableCell>
18
+ * <TableCell>john@example.com</TableCell>
19
+ * <TableCell>Admin</TableCell>
20
+ * </TableRow>
21
+ * </TableBody>
22
+ * ```
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * // Table row with click handler
27
+ * <TableRow onClick={() => handleRowClick(item)}>
28
+ * <TableCell>{item.name}</TableCell>
29
+ * <TableCell>{item.email}</TableCell>
30
+ * </TableRow>
31
+ * ```
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * // Disabled table row (aria-disabled is automatically set)
36
+ * <TableRow disabled>
37
+ * <TableCell>Disabled Row</TableCell>
38
+ * </TableRow>
39
+ * ```
40
+ *
41
+ * @see {@link Table} - Parent table component
42
+ * @see {@link TableHead} - Header section (use TableCellHeader in rows)
43
+ * @see {@link TableBody} - Body section (use TableCell in rows)
44
+ * @see {@link TableCell} - Data cell component
45
+ * @see {@link TableCellHeader} - Header cell component
46
+ *
47
+ * @accessibility
48
+ * - Semantic HTML tr element
49
+ * - Automatically sets aria-disabled when disabled is true
50
+ * - Keyboard accessible when clickable
51
+ * - Proper table structure for screen readers
52
+ */
2
53
  declare const TableRow: import("react").ForwardRefExoticComponent<TableRowProps & import("react").RefAttributes<HTMLTableRowElement>>;
3
54
  export default TableRow;
@@ -11,13 +11,17 @@ import { TooltipProps } from './types';
11
11
  * positioning with auto-adjustment, and customizable appearance with size
12
12
  * variants and optional arrows.
13
13
  *
14
+ * Note that the tooltip opens on **click** by default. For the usual hover
15
+ * behaviour pass `enableHover enableClick={false}`, as every example below and
16
+ * every call site in the kit does.
17
+ *
14
18
  * @category Components
15
19
  * @subcategory Overlay
16
20
  *
17
21
  * @example
18
22
  * ```tsx
19
23
  * // Basic tooltip on hover
20
- * <Tooltip>
24
+ * <Tooltip enableHover enableClick={false}>
21
25
  * <TooltipTrigger>
22
26
  * <Button>Hover me</Button>
23
27
  * </TooltipTrigger>
@@ -28,7 +32,7 @@ import { TooltipProps } from './types';
28
32
  * @example
29
33
  * ```tsx
30
34
  * // Tooltip with custom placement
31
- * <Tooltip placement="bottom" size="large">
35
+ * <Tooltip enableHover enableClick={false} placement="bottom" size="large">
32
36
  * <TooltipTrigger>
33
37
  * <Icon name="info" />
34
38
  * </TooltipTrigger>
@@ -43,8 +47,8 @@ import { TooltipProps } from './types';
43
47
  *
44
48
  * @example
45
49
  * ```tsx
46
- * // Click-to-open tooltip
47
- * <Tooltip enableClick enableHover={false}>
50
+ * // Click-to-open tooltip — this is the default interaction
51
+ * <Tooltip>
48
52
  * <TooltipTrigger>
49
53
  * <Button>Click for info</Button>
50
54
  * </TooltipTrigger>
@@ -55,7 +59,7 @@ import { TooltipProps } from './types';
55
59
  * @example
56
60
  * ```tsx
57
61
  * // Dark surface, no shadow
58
- * <Tooltip color="dark" hasShadow={false}>
62
+ * <Tooltip enableHover enableClick={false} color="dark" hasShadow={false}>
59
63
  * <TooltipTrigger>
60
64
  * <Button>Hover me</Button>
61
65
  * </TooltipTrigger>
@@ -68,7 +72,7 @@ import { TooltipProps } from './types';
68
72
  * @example
69
73
  * ```tsx
70
74
  * // Tooltip without arrow
71
- * <Tooltip hasArrow={false}>
75
+ * <Tooltip enableHover enableClick={false} hasArrow={false}>
72
76
  * <TooltipTrigger>
73
77
  * <span>?</span>
74
78
  * </TooltipTrigger>
@@ -30,7 +30,7 @@ export type TooltipColor = FloatingSurfaceColor;
30
30
  *
31
31
  * @example
32
32
  * ```tsx
33
- * <Tooltip placement="top">
33
+ * <Tooltip enableHover enableClick={false} placement="top">
34
34
  * <TooltipTrigger>
35
35
  * <Button>Hover me</Button>
36
36
  * </TooltipTrigger>
@@ -50,13 +50,22 @@ export interface TooltipProps extends CommonProps {
50
50
  */
51
51
  placement?: Placement;
52
52
  /**
53
- * Enable tooltip on hover interaction
54
- * @default true
53
+ * Enable tooltip on hover interaction.
54
+ *
55
+ * Off by default — despite the component's name, the tooltip opens on click
56
+ * unless this is set. Pass `enableHover enableClick={false}` for the usual
57
+ * hover-only behaviour; every call site in the kit does.
58
+ *
59
+ * @default false
55
60
  */
56
61
  enableHover?: boolean;
57
62
  /**
58
- * Enable tooltip on click interaction
59
- * @default false
63
+ * Enable tooltip on click interaction.
64
+ *
65
+ * On by default. Set it to `false` alongside `enableHover` when a click on
66
+ * the trigger has to do something else, such as selecting an item.
67
+ *
68
+ * @default true
60
69
  */
61
70
  enableClick?: boolean;
62
71
  /**
@@ -89,8 +98,12 @@ export interface TooltipProps extends CommonProps {
89
98
  */
90
99
  hoverCloseDelay?: number;
91
100
  /**
92
- * Size variant of the tooltip content
93
- * @default 'medium'
101
+ * Size variant of the tooltip content.
102
+ *
103
+ * Note that `small` is 8px type — intended for dense chart labels rather
104
+ * than prose. Use `medium` (12px) or `large` (14px) for readable text.
105
+ *
106
+ * @default 'small'
94
107
  */
95
108
  size?: TooltipSize;
96
109
  /**
@@ -3,9 +3,13 @@ import { TooltipContentProps } from '../Tooltip/types';
3
3
  * TooltipContent - Content container for tooltip display
4
4
  *
5
5
  * Renders the actual tooltip content that appears when the trigger is activated.
6
- * Uses Floating Portal for proper z-index stacking and FloatingFocusManager for
7
- * keyboard accessibility. Automatically positions based on Floating UI context
8
- * and respects size variants and arrow configuration.
6
+ * Automatically positions based on Floating UI context and respects size
7
+ * variants and arrow configuration. Uses FloatingFocusManager for keyboard
8
+ * accessibility.
9
+ *
10
+ * Renders in a Floating Portal to escape any ancestor's `overflow` clipping.
11
+ * Note that the portal by itself does not lift the tooltip above positioned
12
+ * siblings -- the surface carries its own z-index for that.
9
13
  *
10
14
  * Only renders when tooltip is open (isOpen is true). Supports custom styling
11
15
  * and can contain any React content.
@@ -0,0 +1,62 @@
1
+ import { TreeViewProps } from './types';
2
+ /**
3
+ * TreeView — a nestable list of rows, up to three levels deep.
4
+ *
5
+ * Domain-free by design: it knows about expansion, selection, indentation and
6
+ * keyboard navigation, and nothing about routing or files. Give it `items`,
7
+ * and hand it a `renderItem` when the row needs to be something other than a
8
+ * plain label — a `NavLink`, a row with a size column, a checkbox.
9
+ *
10
+ * The fourth level is a **type error**, not a runtime check: `items` is typed
11
+ * one level at a time, so an over-deep tree fails at the call site.
12
+ *
13
+ * Expansion and selection both follow the kit's controllable pattern
14
+ * (`expandedIds` / `defaultExpandedIds` / `onExpandedIdsChange`, and the same
15
+ * trio for selection). Selection is always an array, even in the default
16
+ * `single` mode, so moving to multi-select later costs nothing.
17
+ *
18
+ * ## Styling
19
+ *
20
+ * Every part carries a stable class — `ssa-tree`, `ssa-tree__group`,
21
+ * `ssa-tree__item` (plus `--level-1|2|3`, `--selected`, `--expanded`),
22
+ * `ssa-tree__row`, `ssa-tree__icon`, `ssa-tree__label`, `ssa-tree__toggle`.
23
+ * Target those from the `css` prop rather than the DOM shape; a single node
24
+ * can also carry its own `css`.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * <TreeView
29
+ * items={[
30
+ * {
31
+ * id: 'education',
32
+ * label: 'Education',
33
+ * iconName: 'education',
34
+ * items: [
35
+ * { id: 'courses', label: 'Courses' },
36
+ * { id: 'exams', label: 'Exams' },
37
+ * ],
38
+ * },
39
+ * { id: 'employee', label: 'Employee', iconName: 'user' },
40
+ * ]}
41
+ * defaultSelectedIds={['exams']}
42
+ * onSelectedIdsChange={(ids) => console.log(ids)}
43
+ * />
44
+ * ```
45
+ *
46
+ * @example Routing rows, with selection owned by the router
47
+ * ```tsx
48
+ * <TreeView
49
+ * items={items}
50
+ * semantics="list"
51
+ * selectedIds={[currentRouteId]}
52
+ * renderItem={({ item, itemProps, icon, hasItems, isExpanded, toggleProps }) => (
53
+ * <NavLink to={item.meta.path} {...itemProps}>
54
+ * {icon}
55
+ * <span>{item.label}</span>
56
+ * {hasItems && <button {...toggleProps}>{isExpanded ? '−' : '+'}</button>}
57
+ * </NavLink>
58
+ * )}
59
+ * />
60
+ * ```
61
+ */
62
+ export declare const TreeView: <TMeta>(props: TreeViewProps<TMeta>) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,32 @@
1
+ import { AnyTreeItem, TreeItemRenderProps, TreeLevel, TreeViewProps } from './types';
2
+ import { TreeIndex } from './utils';
3
+ /**
4
+ * Everything the recursive rows share. Passed down as a prop rather than
5
+ * through React context: the tree is at most three levels deep, so threading
6
+ * it is cheaper than a provider and keeps the data flow readable.
7
+ */
8
+ export interface TreeItemContext<TMeta> {
9
+ treeId: string;
10
+ index: TreeIndex<TMeta>;
11
+ expandedSet: Set<string>;
12
+ selectedSet: Set<string>;
13
+ selectedPath: Set<string>;
14
+ toggle: (id: string) => void;
15
+ select: (item: AnyTreeItem<TMeta>) => void;
16
+ focusedId: string | null;
17
+ registerItem: (id: string, element: HTMLLIElement | null) => void;
18
+ onItemKeyDown: (event: React.KeyboardEvent, id: string) => void;
19
+ theme: NonNullable<TreeViewProps['theme']>;
20
+ activeColor?: string;
21
+ semantics: NonNullable<TreeViewProps['semantics']>;
22
+ toggleOnItemClick: boolean;
23
+ reserveIconSpace: boolean;
24
+ indent?: number;
25
+ renderItem?: (props: TreeItemRenderProps<TMeta>) => React.ReactNode;
26
+ }
27
+ export declare const TreeViewItem: <TMeta>({ item, level, index: position, context, }: {
28
+ item: AnyTreeItem<TMeta>;
29
+ level: TreeLevel;
30
+ index: number;
31
+ context: TreeItemContext<TMeta>;
32
+ }) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { TreeView } from './TreeView';
2
+ export type { TreeViewProps, TreeItem, TreeItemLevel2, TreeItemLevel3, TreeItemBase, AnyTreeItem, TreeItemRenderProps, TreeLevel, } from './types';
@@ -0,0 +1,18 @@
1
+ import { CSSObject } from '@emotion/react';
2
+ import { TreeLevel, TreeViewProps } from './types';
3
+ type TreeTheme = NonNullable<TreeViewProps['theme']>;
4
+ export declare const ICON_SIZE = 24;
5
+ export declare const TOGGLE_SIZE = 20;
6
+ export declare const root: import("@emotion/react").SerializedStyles;
7
+ export declare const group: import("@emotion/react").SerializedStyles;
8
+ export declare const item: import("@emotion/react").SerializedStyles;
9
+ export declare const row: (navTheme: TreeTheme, level: TreeLevel, indent: number, state: {
10
+ isSelected: boolean;
11
+ isEngaged: boolean;
12
+ isDisabled: boolean;
13
+ activeColor?: string;
14
+ }) => CSSObject;
15
+ export declare const icon: import("@emotion/react").SerializedStyles;
16
+ export declare const label: import("@emotion/react").SerializedStyles;
17
+ export declare const toggle: (isExpanded: boolean) => import("@emotion/react").SerializedStyles;
18
+ export {};
@@ -0,0 +1,162 @@
1
+ import { CSSObject, Interpolation, Theme } from '@emotion/react';
2
+ import { MapIconsType } from '../Icon/types';
3
+ /**
4
+ * Fields shared by every node, at any level.
5
+ *
6
+ * `TMeta` is the consumer's own payload — a route path for navigation, a file
7
+ * size and mime type for a file tree. It travels untouched to `renderItem`,
8
+ * which is what keeps `TreeView` free of any domain knowledge.
9
+ */
10
+ export interface TreeItemBase<TMeta = unknown> {
11
+ /**
12
+ * Stable identity. Expansion and selection are both expressed as arrays of
13
+ * these, so an id that changes between renders will drop the node's state.
14
+ */
15
+ id: string;
16
+ label: React.ReactNode;
17
+ /** Kit icon rendered before the label. Ignored when `icon` is set. */
18
+ iconName?: keyof MapIconsType;
19
+ /** Arbitrary icon element, for glyphs the kit doesn't ship. Wins over `iconName`. */
20
+ icon?: React.ReactNode;
21
+ /** Blocks selection, expansion and keyboard focus, and dims the row. */
22
+ disabled?: boolean;
23
+ /** Styles for this row only, merged after the theme defaults. */
24
+ css?: CSSObject;
25
+ meta?: TMeta;
26
+ }
27
+ /**
28
+ * A third-level node. `items?: never` is what caps the tree at three levels:
29
+ * a fourth is a type error at the call site rather than a runtime surprise.
30
+ */
31
+ export interface TreeItemLevel3<TMeta = unknown> extends TreeItemBase<TMeta> {
32
+ items?: never;
33
+ }
34
+ /** A second-level node. Its children are the deepest the tree allows. */
35
+ export interface TreeItemLevel2<TMeta = unknown> extends TreeItemBase<TMeta> {
36
+ items?: TreeItemLevel3<TMeta>[];
37
+ }
38
+ /** A top-level node. `items` is optional, so a flat one-level list is valid. */
39
+ export interface TreeItem<TMeta = unknown> extends TreeItemBase<TMeta> {
40
+ items?: TreeItemLevel2<TMeta>[];
41
+ }
42
+ /** Any node, whatever its depth — what `renderItem` and the callbacks receive. */
43
+ export type AnyTreeItem<TMeta = unknown> = TreeItem<TMeta> | TreeItemLevel2<TMeta> | TreeItemLevel3<TMeta>;
44
+ /** A node's depth, 1-based. Three is the maximum the tree accepts. */
45
+ export type TreeLevel = 1 | 2 | 3;
46
+ /**
47
+ * Everything a custom row needs to render itself and stay in sync.
48
+ *
49
+ * Spread `itemProps` on whatever element you make interactive (a `NavLink`, a
50
+ * `button`, a `div`) and `toggleProps` on the expand/collapse control. The
51
+ * surrounding `li`, its ARIA and its keyboard handling belong to `TreeView` —
52
+ * a custom row never has to reproduce them.
53
+ */
54
+ export interface TreeItemRenderProps<TMeta = unknown> {
55
+ item: AnyTreeItem<TMeta>;
56
+ level: TreeLevel;
57
+ /** Position among siblings, zero-based. */
58
+ index: number;
59
+ isSelected: boolean;
60
+ isExpanded: boolean;
61
+ /**
62
+ * True when the node is an ancestor of a selected node. The design keeps
63
+ * levels 1 and 2 emphasised while the selected level 3 row is blue, and this
64
+ * is the flag that drives it.
65
+ */
66
+ isInSelectedPath: boolean;
67
+ hasItems: boolean;
68
+ isDisabled: boolean;
69
+ /** Selects the node, honouring `selectionMode`. No-op when disabled. */
70
+ select: () => void;
71
+ /** Expands or collapses the node, honouring `expandMode`. No-op without children. */
72
+ toggle: () => void;
73
+ /** Spread on the interactive row element. */
74
+ itemProps: React.HTMLAttributes<HTMLElement>;
75
+ /** Spread on the expand/collapse control. Empty object when `hasItems` is false. */
76
+ toggleProps: React.ButtonHTMLAttributes<HTMLButtonElement>;
77
+ /** The node's icon, already built and themed — `null` when it has none. */
78
+ icon: React.ReactNode;
79
+ }
80
+ /**
81
+ * Props for {@link TreeView}. `TMeta` is the payload carried on each node and
82
+ * handed back to `renderItem` and the selection callback.
83
+ */
84
+ export interface TreeViewProps<TMeta = unknown> {
85
+ /**
86
+ * The tree. Three levels deep at most — the fourth is rejected by the type,
87
+ * and `items` is optional at every level, so a one-level list is valid.
88
+ */
89
+ items: TreeItem<TMeta>[];
90
+ /** Ids of expanded nodes. Pass to control expansion yourself. */
91
+ expandedIds?: string[];
92
+ /** Ids expanded on mount, when expansion is uncontrolled. */
93
+ defaultExpandedIds?: string[];
94
+ onExpandedIdsChange?: (ids: string[]) => void;
95
+ /**
96
+ * `single` collapses siblings when a node expands, accordion-style.
97
+ * @default 'multiple'
98
+ */
99
+ expandMode?: 'multiple' | 'single';
100
+ /**
101
+ * Ids of selected nodes. Always an array, even in `single` mode — which is
102
+ * what lets a consumer move to multi-select later without an API change.
103
+ */
104
+ selectedIds?: string[];
105
+ defaultSelectedIds?: string[];
106
+ /** Receives the full next selection, plus the node that was acted on. */
107
+ onSelectedIdsChange?: (ids: string[], item: AnyTreeItem<TMeta>) => void;
108
+ /**
109
+ * `single` replaces the selection on click, `multiple` toggles membership.
110
+ * @default 'single'
111
+ */
112
+ selectionMode?: 'single' | 'multiple';
113
+ /** Replaces the row's interior. The `li`, ARIA and keyboard stay with `TreeView`. */
114
+ renderItem?: (props: TreeItemRenderProps<TMeta>) => React.ReactNode;
115
+ /**
116
+ * Colour set. `dark` is for sidebars such as `CollapsibleNavBar`'s default theme.
117
+ * @default 'light'
118
+ */
119
+ theme?: 'light' | 'dark';
120
+ /**
121
+ * Overrides the selected row's colour (and the chevron and icon on it), for
122
+ * a consumer whose accent isn't the theme's own. Everything else — rest,
123
+ * hover, the engaged path — still comes from `theme`.
124
+ */
125
+ activeColor?: string;
126
+ /**
127
+ * `tree` gives a real `role="tree"` with roving focus and arrow-key
128
+ * navigation — right for a file tree. `list` gives nested `ul`/`li` with
129
+ * disclosure buttons, which is the correct pattern for a navigation menu of
130
+ * links and leaves focus order to the browser.
131
+ * @default 'tree'
132
+ */
133
+ semantics?: 'tree' | 'list';
134
+ /**
135
+ * Whether clicking anywhere on a parent row toggles it, rather than only the
136
+ * chevron.
137
+ * @default true
138
+ */
139
+ toggleOnItemClick?: boolean;
140
+ /**
141
+ * Expand the ancestors of selected nodes, on mount and whenever the
142
+ * selection moves. Ignored while expansion is controlled.
143
+ * @default true
144
+ */
145
+ autoExpandSelected?: boolean;
146
+ /**
147
+ * Keep the icon column even on rows without an icon, so labels stay aligned
148
+ * with their icon-bearing siblings. Off by default: a tree whose rows have
149
+ * no icons at all would otherwise carry an empty column.
150
+ * @default false
151
+ */
152
+ reserveIconSpace?: boolean;
153
+ /**
154
+ * Left offset per level, in px. Defaults to the design's 0 / 24 / 40; a
155
+ * number here makes the steps linear instead (`(level - 1) * indent`).
156
+ */
157
+ indent?: number;
158
+ /** Accessible name for the tree. */
159
+ 'aria-label'?: string;
160
+ className?: string;
161
+ css?: Interpolation<Theme>;
162
+ }
@@ -0,0 +1,21 @@
1
+ import { AnyTreeItem, TreeViewProps } from './types';
2
+ import { TreeIndex } from './utils';
3
+ export interface UseTreeViewStateOptions<TMeta> extends Pick<TreeViewProps<TMeta>, 'expandedIds' | 'defaultExpandedIds' | 'onExpandedIdsChange' | 'expandMode' | 'selectedIds' | 'defaultSelectedIds' | 'onSelectedIdsChange' | 'selectionMode' | 'autoExpandSelected'> {
4
+ index: TreeIndex<TMeta>;
5
+ /** Presence of the prop, not its value — see `useControllableState`. */
6
+ isExpansionControlled: boolean;
7
+ isSelectionControlled: boolean;
8
+ }
9
+ /**
10
+ * Expansion and selection for `TreeView`, both controllable through the kit's
11
+ * `value` / `defaultValue` / `onChange` trio.
12
+ */
13
+ export declare const useTreeViewState: <TMeta>({ index, isExpansionControlled, expandedIds, defaultExpandedIds, onExpandedIdsChange, expandMode, isSelectionControlled, selectedIds, defaultSelectedIds, onSelectedIdsChange, selectionMode, autoExpandSelected, }: UseTreeViewStateOptions<TMeta>) => {
14
+ expanded: string[];
15
+ expandedSet: Set<string>;
16
+ selectedSet: Set<string>;
17
+ selectedPath: Set<string>;
18
+ setExpanded: (next: string[]) => void;
19
+ toggle: (id: string) => void;
20
+ select: (item: AnyTreeItem<TMeta>) => void;
21
+ };