@foris/avocado-suite 1.10.2 → 1.10.3

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.
@@ -0,0 +1,76 @@
1
+ import type { HTMLAttributes, Key, ReactElement, ReactNode, RefAttributes } from 'react';
2
+ /** Supported pinning edge, relative to the document direction. */
3
+ export type MatrixTablePinnedSide = 'start';
4
+ /**
5
+ * Inline alignment of a column's header and body cells. Logical, so `start` and
6
+ * `end` follow the document direction. Narrow numeric columns want `center`.
7
+ */
8
+ export type MatrixTableAlign = 'start' | 'center' | 'end';
9
+ /** What a group column and a detail column declare in common. */
10
+ interface MatrixTableColumnBase {
11
+ /** Stable identity, unique across both groupColumns and columns. */
12
+ key: string;
13
+ /** Content of the column header. */
14
+ header: ReactNode;
15
+ /** Declared width in px. Applied to the `col`, the header cell and the body cell. */
16
+ width: number;
17
+ /**
18
+ * Pins the column at the logical start. Only a contiguous prefix of
19
+ * `groupColumns` followed by `columns` can be pinned; a later marker is
20
+ * ignored and warned about in development.
21
+ */
22
+ pinned?: MatrixTablePinnedSide;
23
+ /**
24
+ * Alignment of this column's header and body cells. Defaults to the matrix
25
+ * defaults: `center` for detail columns, whose values are short and read as a
26
+ * grid, and `start` for group columns, which hold blocks of text.
27
+ */
28
+ align?: MatrixTableAlign;
29
+ /** Class added to this column's header and body cells; modifiers may take precedence. */
30
+ className?: string;
31
+ }
32
+ /** A column whose single cell spans every detail row of its group. */
33
+ export interface MatrixTableGroupColumn<TGroup> extends MatrixTableColumnBase {
34
+ /** Receives its own definition too, so one factory can serve many columns. */
35
+ renderGroupCell: (group: TGroup, column: MatrixTableGroupColumn<TGroup>) => ReactNode;
36
+ }
37
+ /** A column that renders one cell per detail row. */
38
+ export interface MatrixTableColumn<TGroup, TRow> extends MatrixTableColumnBase {
39
+ /**
40
+ * Receives the row, its group and the column itself. The third argument is
41
+ * what lets a shared handler build a full payload — which row, which group,
42
+ * which column — without a closure per column.
43
+ */
44
+ renderCell: (row: TRow, group: TGroup, column: MatrixTableColumn<TGroup, TRow>) => ReactNode;
45
+ /**
46
+ * Renders the cell as the row's header (`th scope="row"`). Opt in for the
47
+ * value that names the row — a component name, a code — not for data.
48
+ */
49
+ isRowHeader?: boolean;
50
+ }
51
+ /** Grouped matrix data and native attributes applied to the root div. */
52
+ export interface MatrixTableProps<TGroup, TRow> extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'dangerouslySetInnerHTML'> {
53
+ /** Consumer-owned group data. Never mutated, never copied into state. */
54
+ groups: readonly TGroup[];
55
+ /** Columns rendered once per group, spanning its detail rows. */
56
+ groupColumns: readonly MatrixTableGroupColumn<TGroup>[];
57
+ /** Columns rendered once per detail row. The scrolling matrix axis. */
58
+ columns: readonly MatrixTableColumn<TGroup, TRow>[];
59
+ /** Stable identity, unique within groups. */
60
+ getGroupKey: (group: TGroup) => Key;
61
+ /** Detail rows belonging to a group; an empty collection is supported. */
62
+ getRows: (group: TGroup) => readonly TRow[];
63
+ /** Stable detail-row identity, unique within its group. */
64
+ getRowKey: (row: TRow, group: TGroup) => Key;
65
+ /** Accessible name of the table and of its scroll region. Required. */
66
+ accessibleLabel: string;
67
+ /** Content of a spanning body cell when groups is empty. */
68
+ emptyContent?: ReactNode;
69
+ /** Exposed as `aria-busy`. The component ships no loader and no copy. */
70
+ isBusy?: boolean;
71
+ /** Class added to the root div alongside the component's own class. */
72
+ className?: string;
73
+ }
74
+ /** A grouped matrix table; ref and native div attributes target the root container. */
75
+ declare const MatrixTable: <TGroup, TRow>(props: MatrixTableProps<TGroup, TRow> & RefAttributes<HTMLDivElement>) => ReactElement;
76
+ export default MatrixTable;
@@ -0,0 +1,2 @@
1
+ export { default } from './MatrixTable';
2
+ export type { MatrixTableAlign, MatrixTableColumn, MatrixTableGroupColumn, MatrixTablePinnedSide, MatrixTableProps, } from './MatrixTable';
package/dist/index.d.ts CHANGED
@@ -25,6 +25,7 @@ import DropdownButton from './components/dropdown-button/DropdownButton';
25
25
  import Heading from './components/heading/Heading';
26
26
  import Link from './components/link/Link';
27
27
  import Loading from './components/loading/Loading';
28
+ import MatrixTable from './components/matrix-table';
28
29
  import Menu from './components/menu/Menu';
29
30
  import Modal from './components/modal/Modal';
30
31
  import Pager from './components/pager/Pager';
@@ -67,7 +68,7 @@ import { toast } from 'react-toastify';
67
68
  * Hooks
68
69
  */
69
70
  export { useFloatingPortal } from './hooks/useFloatingPortal';
70
- export { Banner, Beacon, Header, HeaderNavigation, ContextualNavigation, Hotspot, NavList, Drawer, AccessPanel, AccountMenu, SidebarMenu, Weekly, WeeklyGroup, Accordion, Box, Breadcrumbs, Button, Card, CardAccordion, CardNotification, Checkbox, DataCard, DataTable, DatePicker, Divider, Dropzone, FileUpload, Donut, DonutLabels, DonutLegend, DropdownButton, Heading, Link, Loading, Menu, Modal, Pager, Pill, PreviewerMarkdown, Processing, ProgressBar, RadioButton, RoundButton, Select, SelectPagination, SkeletonBase, SkeletonCircle, Stepper, Switch, Tabs, Tag, Text, TextField, Textarea, ThemeProvider, ThemeStore, LocaleStore, Timer, Toaster, Tooltip, Table, toast, };
71
+ export { Banner, Beacon, Header, HeaderNavigation, ContextualNavigation, Hotspot, NavList, Drawer, AccessPanel, AccountMenu, SidebarMenu, Weekly, WeeklyGroup, Accordion, Box, Breadcrumbs, Button, Card, CardAccordion, CardNotification, Checkbox, DataCard, DataTable, DatePicker, Divider, Dropzone, FileUpload, Donut, DonutLabels, DonutLegend, DropdownButton, Heading, Link, Loading, MatrixTable, Menu, Modal, Pager, Pill, PreviewerMarkdown, Processing, ProgressBar, RadioButton, RoundButton, Select, SelectPagination, SkeletonBase, SkeletonCircle, Stepper, Switch, Tabs, Tag, Text, TextField, Textarea, ThemeProvider, ThemeStore, LocaleStore, Timer, Toaster, Tooltip, Table, toast, };
71
72
  /**
72
73
  * Types
73
74
  */
@@ -85,6 +86,7 @@ export type { HeadingProps } from './components/heading/Heading';
85
86
  export type { HeaderNavigationProps, HeaderNavigationVisual, } from './components/header-navigation';
86
87
  export type { ContextualNavigationProps, ContextualNavigationItem, } from './components/contextual-navigation';
87
88
  export type { LinkProps } from './components/link/Link';
89
+ export type { MatrixTableAlign, MatrixTableColumn, MatrixTableGroupColumn, MatrixTablePinnedSide, MatrixTableProps, } from './components/matrix-table';
88
90
  export type { MenuItem } from './types/menu.types';
89
91
  export type { RoundButtonProps } from './components/round-button/RoundButton';
90
92
  export type { SelectProps } from './components/select/Select';