@atlaskit/table-tree 9.12.1 → 10.0.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/CHANGELOG.md +16 -0
  2. package/dist/cjs/components/cell.js +19 -41
  3. package/dist/cjs/components/header.js +23 -38
  4. package/dist/cjs/components/headers.js +31 -40
  5. package/dist/cjs/components/internal/chevron.js +32 -59
  6. package/dist/cjs/components/internal/item.js +38 -52
  7. package/dist/cjs/components/internal/items.js +31 -83
  8. package/dist/cjs/components/internal/loader-item.js +34 -66
  9. package/dist/cjs/components/internal/with-column-width.js +2 -4
  10. package/dist/cjs/components/row.js +120 -177
  11. package/dist/cjs/components/rows.js +17 -37
  12. package/dist/cjs/components/table-tree.js +75 -119
  13. package/dist/es2019/components/cell.js +18 -22
  14. package/dist/es2019/components/header.js +17 -21
  15. package/dist/es2019/components/headers.js +22 -19
  16. package/dist/es2019/components/internal/chevron.js +25 -35
  17. package/dist/es2019/components/internal/item.js +32 -36
  18. package/dist/es2019/components/internal/items.js +24 -60
  19. package/dist/es2019/components/internal/loader-item.js +29 -46
  20. package/dist/es2019/components/internal/with-column-width.js +2 -4
  21. package/dist/es2019/components/row.js +95 -147
  22. package/dist/es2019/components/rows.js +17 -17
  23. package/dist/es2019/components/table-tree.js +66 -90
  24. package/dist/esm/components/cell.js +19 -38
  25. package/dist/esm/components/header.js +17 -36
  26. package/dist/esm/components/headers.js +26 -40
  27. package/dist/esm/components/internal/chevron.js +29 -57
  28. package/dist/esm/components/internal/item.js +33 -53
  29. package/dist/esm/components/internal/items.js +32 -86
  30. package/dist/esm/components/internal/loader-item.js +33 -68
  31. package/dist/esm/components/internal/with-column-width.js +2 -4
  32. package/dist/esm/components/row.js +116 -179
  33. package/dist/esm/components/rows.js +17 -35
  34. package/dist/esm/components/table-tree.js +75 -121
  35. package/dist/types/components/header.d.ts +11 -1
  36. package/dist/types/components/headers.d.ts +13 -3
  37. package/dist/types/components/internal/chevron.d.ts +15 -13
  38. package/dist/types/components/internal/item.d.ts +24 -12
  39. package/dist/types/components/internal/items.d.ts +12 -23
  40. package/dist/types/components/internal/loader-item.d.ts +7 -16
  41. package/dist/types/components/row.d.ts +11 -39
  42. package/dist/types/components/rows.d.ts +15 -10
  43. package/dist/types/components/table-tree.d.ts +10 -20
  44. package/dist/types-ts4.5/components/header.d.ts +11 -1
  45. package/dist/types-ts4.5/components/headers.d.ts +13 -3
  46. package/dist/types-ts4.5/components/internal/chevron.d.ts +15 -13
  47. package/dist/types-ts4.5/components/internal/item.d.ts +24 -12
  48. package/dist/types-ts4.5/components/internal/items.d.ts +12 -23
  49. package/dist/types-ts4.5/components/internal/loader-item.d.ts +7 -16
  50. package/dist/types-ts4.5/components/row.d.ts +11 -39
  51. package/dist/types-ts4.5/components/rows.d.ts +15 -10
  52. package/dist/types-ts4.5/components/table-tree.d.ts +10 -20
  53. package/package.json +5 -9
@@ -1,19 +1,21 @@
1
- import { Component } from 'react';
1
+ /// <reference types="react" />
2
2
  interface ChevronProps {
3
- expandLabel: string;
4
- collapseLabel: string;
3
+ /**
4
+ * @default 'Expand'
5
+ */
6
+ expandLabel?: string;
7
+ /**
8
+ * @default 'Collapse'
9
+ */
10
+ collapseLabel?: string;
5
11
  isExpanded?: boolean;
6
12
  ariaControls?: string;
7
- onExpandToggle?: Function;
13
+ onExpandToggle?: () => void;
8
14
  rowId: string;
9
15
  extendedLabel?: string;
10
16
  }
11
- export default class Chevron extends Component<ChevronProps> {
12
- static defaultProps: {
13
- expandLabel: string;
14
- collapseLabel: string;
15
- };
16
- handleClick: () => void;
17
- render(): JSX.Element;
18
- }
19
- export {};
17
+ /**
18
+ * Internal chevron component.
19
+ */
20
+ declare const Chevron: ({ isExpanded, ariaControls, collapseLabel, expandLabel, rowId, extendedLabel, onExpandToggle, }: ChevronProps) => JSX.Element;
21
+ export default Chevron;
@@ -2,16 +2,28 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import { Component } from 'react';
6
- import { jsx } from '@emotion/react';
7
- export default class Item extends Component<any> {
8
- static defaultProps: {
9
- depth: number;
5
+ import { type ReactElement } from 'react';
6
+ import { type RowProps } from '../row';
7
+ import { type RowsProps } from '../rows';
8
+ type ItemProps<Item> = {
9
+ /**
10
+ * @default 0
11
+ */
12
+ depth?: number;
13
+ data: Item & {
14
+ children?: Item[];
10
15
  };
11
- render(): import("react").FunctionComponentElement<{
12
- depth: any;
13
- data: any;
14
- loadingLabel: any;
15
- renderChildren: () => jsx.JSX.Element;
16
- }> | null;
17
- }
16
+ render: (arg: Item & {
17
+ children?: Item[];
18
+ }) => ReactElement<RowProps<Item> | RowsProps<Item>> | null;
19
+ loadingLabel?: string;
20
+ key?: string;
21
+ };
22
+ /**
23
+ * __Item__
24
+ * Internal item component.
25
+ */
26
+ declare function Item<Item extends {
27
+ id: string;
28
+ }>({ depth, data, render, loadingLabel, }: ItemProps<Item>): ReactElement<RowProps<Item> | RowsProps<Item>, string | import("react").JSXElementConstructor<any>> | null;
29
+ export default Item;
@@ -1,25 +1,14 @@
1
- import React, { Component } from 'react';
2
- interface ItemsProps<Item = any> {
3
- parentData?: any;
4
- depth: number;
5
- items?: Item[];
1
+ import { type ReactElement } from 'react';
2
+ import { type RowProps } from '../row';
3
+ export interface ItemsProps<Item> {
4
+ depth?: number;
5
+ items?: Item[] | null;
6
6
  loadingLabel?: string;
7
- render: (arg: Item) => React.ReactNode;
7
+ render: (arg: Item & {
8
+ children?: Item[];
9
+ }) => ReactElement<RowProps<Item>> | null;
8
10
  }
9
- interface State {
10
- isLoaderShown: boolean;
11
- }
12
- export default class Items<Item> extends Component<ItemsProps<Item>, State> {
13
- static defaultProps: {
14
- depth: number;
15
- };
16
- state: State;
17
- static getDerivedStateFromProps(nextProps: any, prevState: any): {
18
- isLoaderShown: boolean;
19
- } | null;
20
- handleLoaderComplete: () => void;
21
- renderLoader(): JSX.Element;
22
- renderItems(): JSX.Element[] | undefined;
23
- render(): JSX.Element | JSX.Element[] | undefined;
24
- }
25
- export {};
11
+ declare function Items<Item extends {
12
+ id: string;
13
+ }>({ depth, items, loadingLabel, render, }: ItemsProps<Item>): JSX.Element;
14
+ export default Items;
@@ -1,21 +1,12 @@
1
- import { Component } from 'react';
1
+ /// <reference types="react" />
2
2
  interface LoaderItemProps {
3
- depth: number;
3
+ /**
4
+ * @default 1
5
+ */
6
+ depth?: number;
4
7
  onComplete: (...args: any[]) => void;
5
8
  isCompleting?: boolean;
6
9
  loadingLabel?: string;
7
10
  }
8
- export default class LoaderItem extends Component<LoaderItemProps, any> {
9
- static defaultProps: {
10
- depth: number;
11
- };
12
- state: {
13
- phase: string;
14
- };
15
- static getDerivedStateFromProps(nextProps: any, prevState: any): {
16
- phase: string;
17
- } | null;
18
- componentDidUpdate(prevProps: any, prevState: any): void;
19
- render(): JSX.Element | null;
20
- }
21
- export {};
11
+ declare const LoaderItem: ({ depth, loadingLabel, isCompleting, onComplete }: LoaderItemProps) => JSX.Element | null;
12
+ export default LoaderItem;
@@ -2,18 +2,10 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import React, { Component, type ReactNode } from 'react';
5
+ import React, { type ReactNode } from 'react';
6
6
  import { jsx } from '@emotion/react';
7
- import type Item from './internal/item';
8
- /**
9
- * This is hard-coded here because our actual <TableTree /> has no typings
10
- * for its props.
11
- *
12
- * Adding types for real *might* break things so will need a little care.
13
- *
14
- * Defining it here for now lets us provide *something* without much headache.
15
- */
16
- export type RowProps = {
7
+ import { type UIAnalyticsEvent } from '@atlaskit/analytics-next';
8
+ export interface RowProps<Item> {
17
9
  /**
18
10
  * Whether the row has children.
19
11
  */
@@ -21,7 +13,7 @@ export type RowProps = {
21
13
  /**
22
14
  * Children contained in the row. Should be one or more cell components.
23
15
  */
24
- children?: React.ReactNode;
16
+ children?: ReactNode;
25
17
  /**
26
18
  * ID for the row item.
27
19
  */
@@ -36,11 +28,11 @@ export type RowProps = {
36
28
  /**
37
29
  * Controls the expanded state of the row.
38
30
  */
39
- isExpanded?: ReactNode;
31
+ isExpanded?: boolean;
40
32
  /**
41
33
  * Sets the default expanded state of the row.
42
34
  */
43
- isDefaultExpanded?: ReactNode;
35
+ isDefaultExpanded?: boolean;
44
36
  /**
45
37
  * This is the accessible name for the expand chevron button, used to tell assistive technology what the button is for.
46
38
  */
@@ -52,11 +44,11 @@ export type RowProps = {
52
44
  /**
53
45
  * Callback called when the row collapses.
54
46
  */
55
- onCollapse?: (data: Item) => void;
47
+ onCollapse?: (data: Item, analytics?: UIAnalyticsEvent) => void | Promise<void>;
56
48
  /**
57
49
  * Callback called when the row expands.
58
50
  */
59
- onExpand?: (data: Item) => void;
51
+ onExpand?: (data: Item, analytics?: UIAnalyticsEvent) => void | Promise<void>;
60
52
  /**
61
53
  * Children to render under the row.
62
54
  * This is normally set by the parent item component, and doesn't need to be configured.
@@ -86,28 +78,8 @@ export type RowProps = {
86
78
  Should be a number when we pass data via the `Rows` component as children in the table tree.
87
79
  */
88
80
  mainColumnForExpandCollapseLabel?: string | number;
89
- };
90
- declare class RowComponent extends Component<any, any> {
91
- state: {
92
- isExpanded: any;
93
- };
94
- componentDidUpdate(prevProps: any): void;
95
- onExpandStateChange(isExpanded: boolean): void;
96
- /**
97
- * This ensures a user won't trigger a click event and expand the accordion
98
- * when making a text selection.
99
- */
100
- onClickHandler: (e: React.MouseEvent) => void;
101
- onExpandToggle: () => void;
102
- isExpanded(): any;
103
- getExtendedLabel: (cellContent: any, cellIndex: number, mainColumnForExpandCollapseLabel: string | number) => any;
104
- renderCell(cell: any, cellIndex: number): React.FunctionComponentElement<{
105
- key: number;
106
- columnIndex: number;
107
- indentLevel: any;
108
- }>;
109
- render(): jsx.JSX.Element;
110
81
  }
111
- export { RowComponent as RowWithoutAnalytics };
112
- declare const Row: React.ForwardRefExoticComponent<Pick<Pick<Omit<any, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, string | number | symbol> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, string | number | symbol> & React.RefAttributes<any>>;
82
+ declare function Row<Item extends {
83
+ id: string;
84
+ }>({ shouldExpandOnClick, hasChildren, depth, renderChildren, isDefaultExpanded, data, onExpand: providedOnExpand, onCollapse: providedOnCollapse, mainColumnForExpandCollapseLabel, expandLabel, collapseLabel, itemId, children, isExpanded: isProvidedExpanded, }: RowProps<Item>): jsx.JSX.Element;
113
85
  export default Row;
@@ -1,27 +1,32 @@
1
- import React, { Component } from 'react';
2
- type WithChildren<T> = T & {
3
- children?: T[] | null;
1
+ import { type ReactElement } from 'react';
2
+ import { type RowProps } from './row';
3
+ type Content = {
4
+ title: string;
5
+ description: string;
4
6
  };
5
- export interface RowsProps<T> {
7
+ export interface RowsProps<Item> {
6
8
  /**
7
9
  * The data used to render the set of rows. Will be passed down via the `children` render prop.
8
10
  *
9
11
  * In addition to these props, any other data can be added to the object, and it will
10
12
  * be provided as props when rendering each cell.
11
13
  */
12
- items?: WithChildren<T>[];
14
+ items?: Item[];
13
15
  /**
14
16
  * Render function for child rows. Render props will contain an item from the
15
17
  * `items` prop above.
16
18
  */
17
- render: (args: WithChildren<T>) => React.ReactNode;
19
+ render: (args: Item & {
20
+ children?: Item[];
21
+ content?: Content;
22
+ }) => ReactElement<RowProps<Item>> | null;
18
23
  /**
19
24
  * This is an accessible name for the loading state's spinner.
20
25
  * The default text is "Loading".
21
26
  */
22
27
  loadingLabel?: string;
23
28
  }
24
- export default class Rows<T> extends Component<RowsProps<T>> {
25
- render(): JSX.Element;
26
- }
27
- export {};
29
+ declare function Rows<T extends {
30
+ id: string;
31
+ }>({ items, render, loadingLabel }: RowsProps<T>): JSX.Element;
32
+ export default Rows;
@@ -1,8 +1,5 @@
1
- import { Component, type ElementType, type ReactNode } from 'react';
1
+ import { type ElementType, type ReactNode } from 'react';
2
2
  import { type ColumnWidth } from './internal/context';
3
- import type Item from './internal/item';
4
- declare class Content extends Object {
5
- }
6
3
  /**
7
4
  * This is hard-coded here because our actual <TableTree /> has no typings
8
5
  * for its props.
@@ -11,7 +8,7 @@ declare class Content extends Object {
11
8
  *
12
9
  * Defining it here for now lets us provide *something* without much headache.
13
10
  */
14
- export type TableTreeProps = {
11
+ export interface TableTreeProps<Item> {
15
12
  /**
16
13
  * The contents of the table.
17
14
  * Use this when composing `Cell`, `Header`, `Headers`, `Row`, and `Rows` components.
@@ -22,11 +19,11 @@ export type TableTreeProps = {
22
19
  * Each column component is used to render the cells in that column.
23
20
  * A cell's `content` value, specified in the data passed to `items`, is provided as props.
24
21
  */
25
- columns?: ElementType<Content>[];
22
+ columns?: ElementType[];
26
23
  /**
27
24
  * The widths of the columns in the table.
28
25
  */
29
- columnWidths?: (string | number)[];
26
+ columnWidths?: ColumnWidth[];
30
27
  /**
31
28
  * The header text of the columns of the table.
32
29
  */
@@ -36,11 +33,11 @@ export type TableTreeProps = {
36
33
 
37
34
  If your cells contain interactive elements, always set this to `false` to avoid unexpected expanding or collapsing.
38
35
 
39
- If you arent using the `items` prop, `shouldExpandOnClick` should be used on the row component instead.
36
+ If you aren't using the `items` prop, `shouldExpandOnClick` should be used on the row component instead.
40
37
  */
41
38
  shouldExpandOnClick?: boolean;
42
39
  /**
43
- The data used to render the table. If youre creating a basic table, use this prop instead of composing cell, header, headers, row, and rows components.
40
+ The data used to render the table. If you're creating a basic table, use this prop instead of composing cell, header, headers, row, and rows components.
44
41
 
45
42
  In addition to the `items` props, any other data can be added, and it will
46
43
  be provided as props when rendering each cell.
@@ -62,15 +59,8 @@ export type TableTreeProps = {
62
59
  * Usage of either this, or the `label` attribute is strongly recommended.
63
60
  */
64
61
  referencedLabel?: string;
65
- };
66
- interface State {
67
- columnWidths: ColumnWidth[];
68
- }
69
- export default class TableTree extends Component<any, State> {
70
- state: State;
71
- componentDidMount(): void;
72
- setColumnWidth: (columnIndex: number, width: ColumnWidth) => void;
73
- getColumnWidth: (columnIndex: any) => ColumnWidth | null;
74
- render(): JSX.Element;
75
62
  }
76
- export {};
63
+ declare function TableTree<Item extends {
64
+ id: string;
65
+ }>({ children, columns, columnWidths: defaultColumnWidths, headers, shouldExpandOnClick, items, mainColumnForExpandCollapseLabel, label, referencedLabel, }: TableTreeProps<Item>): JSX.Element;
66
+ export default TableTree;
@@ -1,4 +1,8 @@
1
1
  /// <reference types="react" />
2
+ /**
3
+ * @jsxRuntime classic
4
+ * @jsx jsx
5
+ */
2
6
  /**
3
7
  * This is hard-coded here because our actual <Header /> has no typings
4
8
  * for its props.
@@ -12,6 +16,12 @@ export type HeaderProps = {
12
16
  * Width of the header item. Takes a string, or a number representing the width in pixels.
13
17
  */
14
18
  width?: string | number;
19
+ /**
20
+ * The contents of the header.
21
+ */
22
+ children?: React.ReactNode;
23
+ onClick?: () => void;
24
+ id?: string;
15
25
  };
16
- declare const Header: (props: any) => JSX.Element;
26
+ declare const Header: (props: HeaderProps & import("./internal/with-column-width").CellWithColumnWidthProps) => JSX.Element;
17
27
  export default Header;
@@ -2,8 +2,18 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import { Component } from 'react';
5
+ import { type ReactElement } from 'react';
6
6
  import { jsx } from '@emotion/react';
7
- export default class Headers extends Component<any> {
8
- render(): jsx.JSX.Element;
7
+ export interface HeadersProps {
8
+ children: ReactElement | ReactElement[];
9
9
  }
10
+ /**
11
+ * __Headers__
12
+ *
13
+ * Headers component for advanced composition of data, allowing custom data structures.
14
+ *
15
+ * - [Examples](https://atlassian.design/components/table-tree/examples#advanced)
16
+ * - [Code](https://atlassian.design/components/table-tree/code#headers-props)
17
+ */
18
+ declare const Headers: ({ children }: HeadersProps) => jsx.JSX.Element;
19
+ export default Headers;
@@ -1,19 +1,21 @@
1
- import { Component } from 'react';
1
+ /// <reference types="react" />
2
2
  interface ChevronProps {
3
- expandLabel: string;
4
- collapseLabel: string;
3
+ /**
4
+ * @default 'Expand'
5
+ */
6
+ expandLabel?: string;
7
+ /**
8
+ * @default 'Collapse'
9
+ */
10
+ collapseLabel?: string;
5
11
  isExpanded?: boolean;
6
12
  ariaControls?: string;
7
- onExpandToggle?: Function;
13
+ onExpandToggle?: () => void;
8
14
  rowId: string;
9
15
  extendedLabel?: string;
10
16
  }
11
- export default class Chevron extends Component<ChevronProps> {
12
- static defaultProps: {
13
- expandLabel: string;
14
- collapseLabel: string;
15
- };
16
- handleClick: () => void;
17
- render(): JSX.Element;
18
- }
19
- export {};
17
+ /**
18
+ * Internal chevron component.
19
+ */
20
+ declare const Chevron: ({ isExpanded, ariaControls, collapseLabel, expandLabel, rowId, extendedLabel, onExpandToggle, }: ChevronProps) => JSX.Element;
21
+ export default Chevron;
@@ -2,16 +2,28 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import { Component } from 'react';
6
- import { jsx } from '@emotion/react';
7
- export default class Item extends Component<any> {
8
- static defaultProps: {
9
- depth: number;
5
+ import { type ReactElement } from 'react';
6
+ import { type RowProps } from '../row';
7
+ import { type RowsProps } from '../rows';
8
+ type ItemProps<Item> = {
9
+ /**
10
+ * @default 0
11
+ */
12
+ depth?: number;
13
+ data: Item & {
14
+ children?: Item[];
10
15
  };
11
- render(): import("react").FunctionComponentElement<{
12
- depth: any;
13
- data: any;
14
- loadingLabel: any;
15
- renderChildren: () => jsx.JSX.Element;
16
- }> | null;
17
- }
16
+ render: (arg: Item & {
17
+ children?: Item[];
18
+ }) => ReactElement<RowProps<Item> | RowsProps<Item>> | null;
19
+ loadingLabel?: string;
20
+ key?: string;
21
+ };
22
+ /**
23
+ * __Item__
24
+ * Internal item component.
25
+ */
26
+ declare function Item<Item extends {
27
+ id: string;
28
+ }>({ depth, data, render, loadingLabel, }: ItemProps<Item>): ReactElement<RowProps<Item> | RowsProps<Item>, string | import("react").JSXElementConstructor<any>> | null;
29
+ export default Item;
@@ -1,25 +1,14 @@
1
- import React, { Component } from 'react';
2
- interface ItemsProps<Item = any> {
3
- parentData?: any;
4
- depth: number;
5
- items?: Item[];
1
+ import { type ReactElement } from 'react';
2
+ import { type RowProps } from '../row';
3
+ export interface ItemsProps<Item> {
4
+ depth?: number;
5
+ items?: Item[] | null;
6
6
  loadingLabel?: string;
7
- render: (arg: Item) => React.ReactNode;
7
+ render: (arg: Item & {
8
+ children?: Item[];
9
+ }) => ReactElement<RowProps<Item>> | null;
8
10
  }
9
- interface State {
10
- isLoaderShown: boolean;
11
- }
12
- export default class Items<Item> extends Component<ItemsProps<Item>, State> {
13
- static defaultProps: {
14
- depth: number;
15
- };
16
- state: State;
17
- static getDerivedStateFromProps(nextProps: any, prevState: any): {
18
- isLoaderShown: boolean;
19
- } | null;
20
- handleLoaderComplete: () => void;
21
- renderLoader(): JSX.Element;
22
- renderItems(): JSX.Element[] | undefined;
23
- render(): JSX.Element | JSX.Element[] | undefined;
24
- }
25
- export {};
11
+ declare function Items<Item extends {
12
+ id: string;
13
+ }>({ depth, items, loadingLabel, render, }: ItemsProps<Item>): JSX.Element;
14
+ export default Items;
@@ -1,21 +1,12 @@
1
- import { Component } from 'react';
1
+ /// <reference types="react" />
2
2
  interface LoaderItemProps {
3
- depth: number;
3
+ /**
4
+ * @default 1
5
+ */
6
+ depth?: number;
4
7
  onComplete: (...args: any[]) => void;
5
8
  isCompleting?: boolean;
6
9
  loadingLabel?: string;
7
10
  }
8
- export default class LoaderItem extends Component<LoaderItemProps, any> {
9
- static defaultProps: {
10
- depth: number;
11
- };
12
- state: {
13
- phase: string;
14
- };
15
- static getDerivedStateFromProps(nextProps: any, prevState: any): {
16
- phase: string;
17
- } | null;
18
- componentDidUpdate(prevProps: any, prevState: any): void;
19
- render(): JSX.Element | null;
20
- }
21
- export {};
11
+ declare const LoaderItem: ({ depth, loadingLabel, isCompleting, onComplete }: LoaderItemProps) => JSX.Element | null;
12
+ export default LoaderItem;
@@ -2,18 +2,10 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import React, { Component, type ReactNode } from 'react';
5
+ import React, { type ReactNode } from 'react';
6
6
  import { jsx } from '@emotion/react';
7
- import type Item from './internal/item';
8
- /**
9
- * This is hard-coded here because our actual <TableTree /> has no typings
10
- * for its props.
11
- *
12
- * Adding types for real *might* break things so will need a little care.
13
- *
14
- * Defining it here for now lets us provide *something* without much headache.
15
- */
16
- export type RowProps = {
7
+ import { type UIAnalyticsEvent } from '@atlaskit/analytics-next';
8
+ export interface RowProps<Item> {
17
9
  /**
18
10
  * Whether the row has children.
19
11
  */
@@ -21,7 +13,7 @@ export type RowProps = {
21
13
  /**
22
14
  * Children contained in the row. Should be one or more cell components.
23
15
  */
24
- children?: React.ReactNode;
16
+ children?: ReactNode;
25
17
  /**
26
18
  * ID for the row item.
27
19
  */
@@ -36,11 +28,11 @@ export type RowProps = {
36
28
  /**
37
29
  * Controls the expanded state of the row.
38
30
  */
39
- isExpanded?: ReactNode;
31
+ isExpanded?: boolean;
40
32
  /**
41
33
  * Sets the default expanded state of the row.
42
34
  */
43
- isDefaultExpanded?: ReactNode;
35
+ isDefaultExpanded?: boolean;
44
36
  /**
45
37
  * This is the accessible name for the expand chevron button, used to tell assistive technology what the button is for.
46
38
  */
@@ -52,11 +44,11 @@ export type RowProps = {
52
44
  /**
53
45
  * Callback called when the row collapses.
54
46
  */
55
- onCollapse?: (data: Item) => void;
47
+ onCollapse?: (data: Item, analytics?: UIAnalyticsEvent) => void | Promise<void>;
56
48
  /**
57
49
  * Callback called when the row expands.
58
50
  */
59
- onExpand?: (data: Item) => void;
51
+ onExpand?: (data: Item, analytics?: UIAnalyticsEvent) => void | Promise<void>;
60
52
  /**
61
53
  * Children to render under the row.
62
54
  * This is normally set by the parent item component, and doesn't need to be configured.
@@ -86,28 +78,8 @@ export type RowProps = {
86
78
  Should be a number when we pass data via the `Rows` component as children in the table tree.
87
79
  */
88
80
  mainColumnForExpandCollapseLabel?: string | number;
89
- };
90
- declare class RowComponent extends Component<any, any> {
91
- state: {
92
- isExpanded: any;
93
- };
94
- componentDidUpdate(prevProps: any): void;
95
- onExpandStateChange(isExpanded: boolean): void;
96
- /**
97
- * This ensures a user won't trigger a click event and expand the accordion
98
- * when making a text selection.
99
- */
100
- onClickHandler: (e: React.MouseEvent) => void;
101
- onExpandToggle: () => void;
102
- isExpanded(): any;
103
- getExtendedLabel: (cellContent: any, cellIndex: number, mainColumnForExpandCollapseLabel: string | number) => any;
104
- renderCell(cell: any, cellIndex: number): React.FunctionComponentElement<{
105
- key: number;
106
- columnIndex: number;
107
- indentLevel: any;
108
- }>;
109
- render(): jsx.JSX.Element;
110
81
  }
111
- export { RowComponent as RowWithoutAnalytics };
112
- declare const Row: React.ForwardRefExoticComponent<Pick<Pick<Omit<any, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, string | number | symbol> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, string | number | symbol> & React.RefAttributes<any>>;
82
+ declare function Row<Item extends {
83
+ id: string;
84
+ }>({ shouldExpandOnClick, hasChildren, depth, renderChildren, isDefaultExpanded, data, onExpand: providedOnExpand, onCollapse: providedOnCollapse, mainColumnForExpandCollapseLabel, expandLabel, collapseLabel, itemId, children, isExpanded: isProvidedExpanded, }: RowProps<Item>): jsx.JSX.Element;
113
85
  export default Row;