@atlaskit/table 0.4.0 → 0.4.2

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 (55) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/version.json +1 -1
  3. package/dist/es2019/version.json +1 -1
  4. package/dist/esm/version.json +1 -1
  5. package/dist/types/body.d.ts +1 -1
  6. package/dist/types/expandable-row-content.d.ts +1 -1
  7. package/dist/types/expandable-row.d.ts +1 -1
  8. package/dist/types/hooks/selection-provider.d.ts +1 -1
  9. package/dist/types/hooks/use-expand-content.d.ts +1 -1
  10. package/dist/types/hooks/use-expand.d.ts +1 -1
  11. package/dist/types/hooks/use-selectable.d.ts +2 -2
  12. package/dist/types/hooks/use-table.d.ts +3 -3
  13. package/dist/types/row.d.ts +1 -1
  14. package/dist/types/table.d.ts +1 -1
  15. package/dist/types/thead.d.ts +1 -1
  16. package/dist/types/ui/base-cell.d.ts +2 -2
  17. package/dist/types/ui/expandable-cell.d.ts +1 -1
  18. package/dist/types/ui/selectable-cell.d.ts +1 -1
  19. package/dist/types/ui/table.d.ts +1 -1
  20. package/dist/types/ui/th.d.ts +2 -2
  21. package/dist/types-ts4.5/body.d.ts +15 -0
  22. package/dist/types-ts4.5/expandable-cell.d.ts +10 -0
  23. package/dist/types-ts4.5/expandable-row-content.d.ts +12 -0
  24. package/dist/types-ts4.5/expandable-row.d.ts +19 -0
  25. package/dist/types-ts4.5/head-cell.d.ts +10 -0
  26. package/dist/types-ts4.5/hooks/selection-provider.d.ts +20 -0
  27. package/dist/types-ts4.5/hooks/use-expand-content.d.ts +15 -0
  28. package/dist/types-ts4.5/hooks/use-expand.d.ts +17 -0
  29. package/dist/types-ts4.5/hooks/use-row-id.d.ts +10 -0
  30. package/dist/types-ts4.5/hooks/use-selectable.d.ts +41 -0
  31. package/dist/types-ts4.5/hooks/use-sorting.d.ts +7 -0
  32. package/dist/types-ts4.5/hooks/use-table-body.d.ts +7 -0
  33. package/dist/types-ts4.5/hooks/use-table.d.ts +22 -0
  34. package/dist/types-ts4.5/index.d.ts +10 -0
  35. package/dist/types-ts4.5/row.d.ts +22 -0
  36. package/dist/types-ts4.5/selectable-cell.d.ts +3 -0
  37. package/dist/types-ts4.5/sortable-column.d.ts +22 -0
  38. package/dist/types-ts4.5/table.d.ts +30 -0
  39. package/dist/types-ts4.5/thead.d.ts +8 -0
  40. package/dist/types-ts4.5/ui/base-cell.d.ts +88 -0
  41. package/dist/types-ts4.5/ui/bulk-action-overlay.d.ts +10 -0
  42. package/dist/types-ts4.5/ui/expand-icon.d.ts +10 -0
  43. package/dist/types-ts4.5/ui/expandable-cell.d.ts +14 -0
  44. package/dist/types-ts4.5/ui/index.d.ts +14 -0
  45. package/dist/types-ts4.5/ui/selectable-cell.d.ts +14 -0
  46. package/dist/types-ts4.5/ui/sort-icon.d.ts +10 -0
  47. package/dist/types-ts4.5/ui/table.d.ts +31 -0
  48. package/dist/types-ts4.5/ui/tbody.d.ts +10 -0
  49. package/dist/types-ts4.5/ui/td.d.ts +11 -0
  50. package/dist/types-ts4.5/ui/th.d.ts +15 -0
  51. package/dist/types-ts4.5/ui/thead.d.ts +12 -0
  52. package/dist/types-ts4.5/ui/tr.d.ts +34 -0
  53. package/package.json +12 -4
  54. package/primitives/package.json +2 -2
  55. package/tmp/api-report-tmp.d.ts +130 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/table
2
2
 
3
+ ## 0.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
8
+
9
+ ## 0.4.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
14
+
3
15
  ## 0.4.0
4
16
 
5
17
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/table",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/table",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/table",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { ReactElement } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
- export declare type BodyProps<Item extends object> = {
4
+ export type BodyProps<Item extends object> = {
5
5
  rows: Item[];
6
6
  children: (row: Item) => ReactElement;
7
7
  } | {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- declare type ExpandableRowContentProps = {
2
+ type ExpandableRowContentProps = {
3
3
  children?: React.ReactNode;
4
4
  };
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- declare type ExpandableRowProps = {
2
+ type ExpandableRowProps = {
3
3
  children: React.ReactNode;
4
4
  /**
5
5
  * Controlled: If the row is expanded.
@@ -1,6 +1,6 @@
1
1
  import React, { FC, ReactNode } from 'react';
2
2
  import { SelectableActions, SelectableState } from './use-selectable';
3
- declare type SelectionContext = [
3
+ type SelectionContext = [
4
4
  SelectableState,
5
5
  /**
6
6
  * Context actions will be undefined without a `SelectionProvider` mounted.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- declare type ExpandContentContext = {
2
+ type ExpandContentContext = {
3
3
  isExpandableContent: boolean;
4
4
  };
5
5
  declare const ExpandContentContext: React.Context<ExpandContentContext>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- declare type ExpandContextState = {
2
+ type ExpandContextState = {
3
3
  isExpanded: boolean;
4
4
  toggleExpanded(): void;
5
5
  };
@@ -1,4 +1,4 @@
1
- export declare type SelectableState = {
1
+ export type SelectableState = {
2
2
  /**
3
3
  * The localised ids that have been checked.
4
4
  */
@@ -27,7 +27,7 @@ export declare type SelectableState = {
27
27
  */
28
28
  previousSelection: number[];
29
29
  };
30
- export declare type SelectableActions = {
30
+ export type SelectableActions = {
31
31
  setAll: () => void;
32
32
  removeAll: () => void;
33
33
  toggleSelection: (id: number, shiftHeld: boolean) => void;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- export declare type SortDirection = 'ascending' | 'descending';
3
- export declare type SortKey<Key extends string | symbol | number> = Key | 'unset';
4
- export declare type TableContext<T, K extends keyof T = keyof T> = {
2
+ export type SortDirection = 'ascending' | 'descending';
3
+ export type SortKey<Key extends string | symbol | number> = Key | 'unset';
4
+ export type TableContext<T, K extends keyof T = keyof T> = {
5
5
  isSelectable?: boolean;
6
6
  sortKey: SortKey<K>;
7
7
  sortDirection?: SortDirection;
@@ -1,6 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { FC, ReactNode } from 'react';
3
- export declare type RowProps = {
3
+ export type RowProps = {
4
4
  /**
5
5
  * A `testId` prop is a unique string that appears as a data attribute `data-testid`
6
6
  * in the rendered code, serving as a hook for automated tests.
@@ -2,7 +2,7 @@
2
2
  import { ReactElement } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import { SortKey } from './hooks/use-table';
5
- export declare type TableProps<ItemType extends object = {}> = {
5
+ export type TableProps<ItemType extends object = {}> = {
6
6
  /**
7
7
  * A `testId` prop is a unique string that appears as a data attribute `data-testid`
8
8
  * in the rendered code, serving as a hook for automated tests.
@@ -1,6 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { FC, ReactNode } from 'react';
3
- declare type THeadProps = {
3
+ type THeadProps = {
4
4
  actions?: (selected: number[]) => ReactNode;
5
5
  children?: ReactNode;
6
6
  };
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { ReactNode } from 'react';
3
3
  import { BoxProps } from '@atlaskit/ds-explorations/box';
4
- export declare type BaseCellProps = {
4
+ export type BaseCellProps = {
5
5
  /**
6
6
  * A percentage of pixel width of the table to apply to a column.
7
7
  */
@@ -37,7 +37,7 @@ export declare type BaseCellProps = {
37
37
  /**
38
38
  * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-sort
39
39
  */
40
- export declare type SortDirection = 'ascending' | 'descending' | 'none' | 'other';
40
+ export type SortDirection = 'ascending' | 'descending' | 'none' | 'other';
41
41
  declare const alignMap: {
42
42
  readonly text: import("@emotion/react").SerializedStyles;
43
43
  readonly number: import("@emotion/react").SerializedStyles;
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { ReactNode } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
- declare type ExpandableCellProps = {
4
+ type ExpandableCellProps = {
5
5
  as: 'td' | 'th';
6
6
  children?: ReactNode;
7
7
  };
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { ReactNode } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
- declare type SelectableCellProps = {
4
+ type SelectableCellProps = {
5
5
  as: 'td' | 'th';
6
6
  children?: ReactNode;
7
7
  };
@@ -1,6 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { FC, ReactNode } from 'react';
3
- declare type TableProps = {
3
+ type TableProps = {
4
4
  /**
5
5
  * A `testId` prop is a unique string that appears as a data attribute `data-testid`
6
6
  * in the rendered code, serving as a hook for automated tests.
@@ -1,7 +1,7 @@
1
1
  import { FC } from 'react';
2
2
  import { BaseCellProps, SortDirection } from './base-cell';
3
- export declare type THProps = Omit<BaseCellProps, 'as'>;
4
- declare type InternalTHProps = THProps & {
3
+ export type THProps = Omit<BaseCellProps, 'as'>;
4
+ type InternalTHProps = THProps & {
5
5
  sortDirection?: SortDirection;
6
6
  };
7
7
  /**
@@ -0,0 +1,15 @@
1
+ /** @jsx jsx */
2
+ import { ReactElement } from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ export type BodyProps<Item extends object> = {
5
+ rows: Item[];
6
+ children: (row: Item) => ReactElement;
7
+ } | {
8
+ rows?: never;
9
+ children: ReactElement[] | ReactElement;
10
+ };
11
+ /**
12
+ * __Table body__
13
+ */
14
+ declare function TBody<ObjectType extends object>({ rows, children, }: BodyProps<ObjectType>): jsx.JSX.Element;
15
+ export default TBody;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { jsx } from '@emotion/react';
3
+ /**
4
+ * __Expandable cell__
5
+ *
6
+ * A cell with an expand button that controls the expanded state
7
+ * of the `<ExpandableRow>`.
8
+ */
9
+ declare const ExpandableCell: import("react").MemoExoticComponent<() => jsx.JSX.Element>;
10
+ export default ExpandableCell;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ type ExpandableRowContentProps = {
3
+ children?: React.ReactNode;
4
+ };
5
+ /**
6
+ * __Expandable row content__
7
+ *
8
+ * Contains expandable content. Uses a context provider to allow children
9
+ * to identify if they are expandable content.
10
+ */
11
+ declare const ExpandableRowContent: ({ children }: ExpandableRowContentProps) => JSX.Element;
12
+ export default ExpandableRowContent;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ type ExpandableRowProps = {
3
+ children: React.ReactNode;
4
+ /**
5
+ * Controlled: If the row is expanded.
6
+ */
7
+ isExpanded?: boolean;
8
+ /**
9
+ * Uncontrolled: If the row is expanded by default.
10
+ */
11
+ isDefaultExpanded?: boolean;
12
+ };
13
+ /**
14
+ * __Expandable row__
15
+ *
16
+ * A context provider for `<Row>` to support expandable content.
17
+ */
18
+ declare const ExpandableRow: ({ children, isExpanded, isDefaultExpanded, }: ExpandableRowProps) => JSX.Element;
19
+ export default ExpandableRow;
@@ -0,0 +1,10 @@
1
+ /** @jsx jsx */
2
+ import type { FC } from 'react';
3
+ import { THProps } from './ui/th';
4
+ /**
5
+ * __HeadCell__
6
+ *
7
+ * HeadCell element
8
+ */
9
+ declare const HeadCell: FC<THProps>;
10
+ export default HeadCell;
@@ -0,0 +1,20 @@
1
+ import React, { FC, ReactNode } from 'react';
2
+ import { SelectableActions, SelectableState } from './use-selectable';
3
+ type SelectionContext = [
4
+ SelectableState,
5
+ /**
6
+ * Context actions will be undefined without a `SelectionProvider` mounted.
7
+ */
8
+ SelectableActions | Partial<SelectableActions>
9
+ ];
10
+ declare const SelectionContext: React.Context<SelectionContext>;
11
+ /**
12
+ * __Selection provider__
13
+ *
14
+ * A selection provider injects selection specific state into the table.
15
+ */
16
+ declare const SelectionProvider: FC<{
17
+ children: ReactNode;
18
+ }>;
19
+ export declare const useSelection: () => SelectionContext;
20
+ export default SelectionProvider;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ type ExpandContentContext = {
3
+ isExpandableContent: boolean;
4
+ };
5
+ declare const ExpandContentContext: React.Context<ExpandContentContext>;
6
+ /**
7
+ * __Expand content provider__
8
+ *
9
+ * An expand content provider allows `<Row>` to determine if it is a subitem.
10
+ */
11
+ export declare const ExpandContentContextProvider: ({ children, }: {
12
+ children: React.ReactNode;
13
+ }) => JSX.Element;
14
+ declare const useExpandContent: () => ExpandContentContext;
15
+ export default useExpandContent;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ type ExpandContextState = {
3
+ isExpanded: boolean;
4
+ toggleExpanded(): void;
5
+ };
6
+ /**
7
+ * __Expand context provider__
8
+ *
9
+ * An expand context provider.
10
+ */
11
+ export declare const ExpandContextProvider: ({ children, isExpanded: isExpandedProp, isDefaultExpanded, }: {
12
+ children: React.ReactNode;
13
+ isExpanded?: boolean | undefined;
14
+ isDefaultExpanded?: boolean | undefined;
15
+ }) => JSX.Element;
16
+ declare const useExpand: () => ExpandContextState;
17
+ export default useExpand;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare const useRowId: () => number | undefined;
6
+ /**
7
+ * __Row provider__
8
+ * @internal
9
+ */
10
+ export declare const RowProvider: import("react").Provider<number | undefined>;
@@ -0,0 +1,41 @@
1
+ export type SelectableState = {
2
+ /**
3
+ * The localised ids that have been checked.
4
+ */
5
+ checked: number[];
6
+ /**
7
+ * Whether all list items are checked.
8
+ */
9
+ allChecked: boolean;
10
+ /**
11
+ * Whether any single row item is checked.
12
+ */
13
+ anyChecked: boolean;
14
+ /**
15
+ * Equal to the data length of the table, i.e. the maximum number of checked items.
16
+ */
17
+ maxChecked: number;
18
+ /**
19
+ * Indicates where a selection begins, i.e. the last selection where the Shift key was **not pressed**
20
+ */
21
+ selectionStart: number;
22
+ /**
23
+ * Indicates the most recent selection range where the Shift key was pressed.
24
+ * This provides the ability to uncheck ids that are not part of a new selection range, but were in the previous selection range,
25
+ * mimicking behaviour such as that in macOS
26
+ * e.g. [2, 3, 4] indicates ids from 2 to 4 were selected the last time the Shift key was pressed.
27
+ */
28
+ previousSelection: number[];
29
+ };
30
+ export type SelectableActions = {
31
+ setAll: () => void;
32
+ removeAll: () => void;
33
+ toggleSelection: (id: number, shiftHeld: boolean) => void;
34
+ setMax: (max: number) => void;
35
+ };
36
+ export declare const defaultSelectableState: SelectableState;
37
+ declare function useSelectable(): [
38
+ SelectableState,
39
+ SelectableActions
40
+ ];
41
+ export default useSelectable;
@@ -0,0 +1,7 @@
1
+ import { SortDirection, SortKey } from './use-table';
2
+ export declare const useSorting: <ItemType extends object>(sortKey: SortKey<keyof ItemType>) => {
3
+ sortKey: "unset" | keyof ItemType;
4
+ sortDirection: SortDirection | undefined;
5
+ setSortState: (key: SortKey<keyof ItemType>) => void;
6
+ sortFn: (rowA: ItemType, rowB: ItemType) => number;
7
+ };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * __Table body provider__
4
+ * Ensures correct nesting of table elements.
5
+ */
6
+ export declare const TableBodyProvider: import("react").Provider<boolean>;
7
+ export declare const useTableBody: () => void;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ export type SortDirection = 'ascending' | 'descending';
3
+ export type SortKey<Key extends string | symbol | number> = Key | 'unset';
4
+ export type TableContext<T, K extends keyof T = keyof T> = {
5
+ isSelectable?: boolean;
6
+ sortKey: SortKey<K>;
7
+ sortDirection?: SortDirection;
8
+ sortFn?: (a: T, b: T) => number;
9
+ setSortState: (key: SortKey<K>) => void;
10
+ };
11
+ /**
12
+ * __Table state provider__
13
+ *
14
+ * The table context provides the data required for more complex functionality.
15
+ *
16
+ * - [Examples](https://atlassian.design/components/table/examples)
17
+ */
18
+ export declare function TableProvider<T extends object>({ children, state, }: {
19
+ children: React.ReactNode;
20
+ state: TableContext<T>;
21
+ }): JSX.Element;
22
+ export declare const useTable: <TableItem extends object>() => TableContext<TableItem, keyof TableItem>;
@@ -0,0 +1,10 @@
1
+ export { default } from './table';
2
+ export { default as TBody } from './body';
3
+ export { default as Row } from './row';
4
+ export { TD as Cell } from './ui';
5
+ export { default as ExpandableCell } from './expandable-cell';
6
+ export { default as ExpandableRow } from './expandable-row';
7
+ export { default as ExpandableRowContent } from './expandable-row-content';
8
+ export { default as HeadCell } from './head-cell';
9
+ export { default as SortableColumn } from './sortable-column';
10
+ export { default as THead } from './thead';
@@ -0,0 +1,22 @@
1
+ /** @jsx jsx */
2
+ import { FC, ReactNode } from 'react';
3
+ export type RowProps = {
4
+ /**
5
+ * A `testId` prop is a unique string that appears as a data attribute `data-testid`
6
+ * in the rendered code, serving as a hook for automated tests.
7
+ */
8
+ testId?: string;
9
+ /**
10
+ * Content of the row.
11
+ */
12
+ children?: ReactNode;
13
+ };
14
+ /**
15
+ * __Row__
16
+ *
17
+ * A table row.
18
+ *
19
+ * - [Examples](https://atlassian.design/components/table/examples)
20
+ */
21
+ declare const Row: FC<RowProps>;
22
+ export default Row;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const _default: import("react").NamedExoticComponent<{}>;
3
+ export default _default;
@@ -0,0 +1,22 @@
1
+ /** @jsx jsx */
2
+ import { FC, ReactNode } from 'react';
3
+ export interface CellProps {
4
+ /**
5
+ * Unique key used for sorting table data by this column
6
+ */
7
+ name: string;
8
+ /**
9
+ * A `testId` prop is a unique string that appears as a data attribute `data-testid`
10
+ * in the rendered code, serving as a hook for automated tests.
11
+ */
12
+ testId?: string;
13
+ onClick?: React.MouseEventHandler;
14
+ children?: ReactNode;
15
+ }
16
+ /**
17
+ * __SortableColumn__
18
+ *
19
+ * SortableColumn is used in place of the default Column when sorting is desired.
20
+ */
21
+ declare const SortableColumn: FC<CellProps>;
22
+ export default SortableColumn;
@@ -0,0 +1,30 @@
1
+ /** @jsx jsx */
2
+ import { ReactElement } from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ import { SortKey } from './hooks/use-table';
5
+ export type TableProps<ItemType extends object = {}> = {
6
+ /**
7
+ * A `testId` prop is a unique string that appears as a data attribute `data-testid`
8
+ * in the rendered code, serving as a hook for automated tests.
9
+ */
10
+ testId?: string;
11
+ /**
12
+ * default sort key to be applied. If unspecified will use default ordering
13
+ */
14
+ sortKey?: SortKey<keyof ItemType>;
15
+ children: ReactElement[] | ReactElement;
16
+ } & ({
17
+ isSelectable: true;
18
+ defaultSelected?: number;
19
+ } | {
20
+ isSelectable?: false;
21
+ });
22
+ /**
23
+ * __Table__
24
+ *
25
+ * A data table is used to display dynamic data.
26
+ *
27
+ * - [Examples](https://atlassian.design/components/table/examples)
28
+ */
29
+ declare function Table<ItemType extends object = object>({ children, isSelectable, sortKey, testId, }: TableProps<ItemType>): jsx.JSX.Element;
30
+ export default Table;
@@ -0,0 +1,8 @@
1
+ /** @jsx jsx */
2
+ import { FC, ReactNode } from 'react';
3
+ type THeadProps = {
4
+ actions?: (selected: number[]) => ReactNode;
5
+ children?: ReactNode;
6
+ };
7
+ declare const THead: FC<THeadProps>;
8
+ export default THead;
@@ -0,0 +1,88 @@
1
+ /** @jsx jsx */
2
+ import { ReactNode } from 'react';
3
+ import { BoxProps } from '@atlaskit/ds-explorations/box';
4
+ export type BaseCellProps = {
5
+ /**
6
+ * A percentage of pixel width of the table to apply to a column.
7
+ */
8
+ width?: string;
9
+ /**
10
+ * Horizontal alignment of content.
11
+ */
12
+ align?: keyof typeof alignMap;
13
+ /**
14
+ * Whether the cell should render as a `td` or `th` element.
15
+ */
16
+ as?: 'td' | 'th';
17
+ /**
18
+ * Same behavior as the HTML attribute.
19
+ *
20
+ * @see 'https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#attr-scope'
21
+ */
22
+ scope?: 'col' | 'row';
23
+ /**
24
+ * A `testId` prop is a unique string that appears as a data attribute `data-testid`
25
+ * in the rendered code, serving as a hook for automated tests.
26
+ */
27
+ testId?: string;
28
+ /**
29
+ * Content of the cell.
30
+ */
31
+ children?: ReactNode;
32
+ /**
33
+ * Number of columns to span.
34
+ */
35
+ colSpan?: number;
36
+ } & Pick<BoxProps, 'paddingBlock' | 'paddingInline' | 'backgroundColor' | 'className'>;
37
+ /**
38
+ * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-sort
39
+ */
40
+ export type SortDirection = 'ascending' | 'descending' | 'none' | 'other';
41
+ declare const alignMap: {
42
+ readonly text: import("@emotion/react").SerializedStyles;
43
+ readonly number: import("@emotion/react").SerializedStyles;
44
+ readonly icon: import("@emotion/react").SerializedStyles;
45
+ };
46
+ /**
47
+ * __BaseCell__
48
+ *
49
+ * @internal
50
+ *
51
+ * Basic cell element.
52
+ */
53
+ export declare const BaseCell: import("react").ForwardRefExoticComponent<{
54
+ /**
55
+ * A percentage of pixel width of the table to apply to a column.
56
+ */
57
+ width?: string | undefined;
58
+ /**
59
+ * Horizontal alignment of content.
60
+ */
61
+ align?: "number" | "text" | "icon" | undefined;
62
+ /**
63
+ * Whether the cell should render as a `td` or `th` element.
64
+ */
65
+ as?: "td" | "th" | undefined;
66
+ /**
67
+ * Same behavior as the HTML attribute.
68
+ *
69
+ * @see 'https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#attr-scope'
70
+ */
71
+ scope?: "col" | "row" | undefined;
72
+ /**
73
+ * A `testId` prop is a unique string that appears as a data attribute `data-testid`
74
+ * in the rendered code, serving as a hook for automated tests.
75
+ */
76
+ testId?: string | undefined;
77
+ /**
78
+ * Content of the cell.
79
+ */
80
+ children?: ReactNode;
81
+ /**
82
+ * Number of columns to span.
83
+ */
84
+ colSpan?: number | undefined;
85
+ } & Pick<BoxProps<"div">, "className" | "backgroundColor" | "paddingBlock" | "paddingInline"> & {
86
+ sortDirection?: SortDirection | undefined;
87
+ } & import("react").RefAttributes<HTMLTableCellElement>>;
88
+ export {};
@@ -0,0 +1,10 @@
1
+ /** @jsx jsx */
2
+ import { FC, ReactNode } from 'react';
3
+ /**
4
+ * __Bulk action overlay__
5
+ *
6
+ * A bulk action overlay is used to conditionally render when a user makes a row selection
7
+ */
8
+ export declare const BulkActionOverlay: FC<{
9
+ children: ReactNode;
10
+ }>;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { jsx } from '@emotion/react';
3
+ /**
4
+ * __Expand icon__
5
+ *
6
+ * An icon used to display the expanded state in an `<ExpandableCell>`.
7
+ */
8
+ export declare const ExpandIcon: import("react").MemoExoticComponent<({ isExpanded }: {
9
+ isExpanded: boolean;
10
+ }) => jsx.JSX.Element>;
@@ -0,0 +1,14 @@
1
+ /** @jsx jsx */
2
+ import { ReactNode } from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ type ExpandableCellProps = {
5
+ as: 'td' | 'th';
6
+ children?: ReactNode;
7
+ };
8
+ /**
9
+ * __Expandable cell__
10
+ *
11
+ * An expandable cell primitive designed to be used for light weight composition.
12
+ */
13
+ export declare const ExpandableCell: ({ children, as }: ExpandableCellProps) => jsx.JSX.Element;
14
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * File exposes the HTML table primitives for use
3
+ */
4
+ export { Table } from './table';
5
+ export { TBody } from './tbody';
6
+ export { TR } from './tr';
7
+ export { TD } from './td';
8
+ export { TH } from './th';
9
+ export { SelectableCell } from './selectable-cell';
10
+ export { ExpandableCell } from './expandable-cell';
11
+ export { ExpandIcon } from './expand-icon';
12
+ export { THead } from './thead';
13
+ export { BulkActionOverlay } from './bulk-action-overlay';
14
+ export { SortIcon } from './sort-icon';
@@ -0,0 +1,14 @@
1
+ /** @jsx jsx */
2
+ import { ReactNode } from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ type SelectableCellProps = {
5
+ as: 'td' | 'th';
6
+ children?: ReactNode;
7
+ };
8
+ /**
9
+ * __Selectable cell__
10
+ *
11
+ * A selectable cell primitive designed to be used for light weight composition.
12
+ */
13
+ export declare const SelectableCell: ({ children, as }: SelectableCellProps) => jsx.JSX.Element;
14
+ export {};
@@ -0,0 +1,10 @@
1
+ /** @jsx jsx */
2
+ import { FC } from 'react';
3
+ /**
4
+ * __SortIcon__
5
+ *
6
+ * SortIcon is used to display the sort state in our SortableColumn.
7
+ */
8
+ export declare const SortIcon: FC<{
9
+ name: string;
10
+ }>;
@@ -0,0 +1,31 @@
1
+ /** @jsx jsx */
2
+ import { FC, ReactNode } from 'react';
3
+ type TableProps = {
4
+ /**
5
+ * A `testId` prop is a unique string that appears as a data attribute `data-testid`
6
+ * in the rendered code, serving as a hook for automated tests.
7
+ */
8
+ testId?: string;
9
+ /**
10
+ * Accessible description of the table data.
11
+ *
12
+ * @see 'https://www.w3.org/WAI/EO/Drafts/tutorials/tables/summary/'
13
+ */
14
+ summary?: string;
15
+ /**
16
+ * Table content.
17
+ */
18
+ children: ReactNode;
19
+ };
20
+ /**
21
+ * __Table__
22
+ *
23
+ * A primitive table container. Applies the HTML native element with no other styling.
24
+ *
25
+ * - [Examples](https://atlassian.design/components/table/examples)
26
+ *
27
+ * @primitive
28
+ * @see https://hello.atlassian.net/wiki/spaces/DST/pages/1947062524/Dynamic+table+2.0+implementation+spec
29
+ */
30
+ export declare const Table: FC<TableProps>;
31
+ export {};
@@ -0,0 +1,10 @@
1
+ /** @jsx jsx */
2
+ import { FC, ReactNode } from 'react';
3
+ /**
4
+ * __TBody__
5
+ * @primitive
6
+ */
7
+ export declare const TBody: FC<{
8
+ children: ReactNode;
9
+ }>;
10
+ export default TBody;
@@ -0,0 +1,11 @@
1
+ /** @jsx jsx */
2
+ import type { FC } from 'react';
3
+ import { BaseCellProps } from './base-cell';
4
+ /**
5
+ * __Cell__
6
+ *
7
+ * A data cell.
8
+ *
9
+ * @primitive
10
+ */
11
+ export declare const TD: FC<Omit<BaseCellProps, 'as'>>;
@@ -0,0 +1,15 @@
1
+ import { FC } from 'react';
2
+ import { BaseCellProps, SortDirection } from './base-cell';
3
+ export type THProps = Omit<BaseCellProps, 'as'>;
4
+ type InternalTHProps = THProps & {
5
+ sortDirection?: SortDirection;
6
+ };
7
+ /**
8
+ * __Head cell__
9
+ *
10
+ * A head cell.
11
+ *
12
+ * @primitive
13
+ */
14
+ export declare const TH: FC<InternalTHProps>;
15
+ export {};
@@ -0,0 +1,12 @@
1
+ /** @jsx jsx */
2
+ import type { FC, ReactNode } from 'react';
3
+ /**
4
+ * __THead__
5
+ *
6
+ * A primitive table head container. Applies the HTML native element with minimal styling.
7
+ *
8
+ * @primitive
9
+ */
10
+ export declare const THead: FC<{
11
+ children?: ReactNode;
12
+ }>;
@@ -0,0 +1,34 @@
1
+ /** @jsx jsx */
2
+ import type { FC, ReactNode } from 'react';
3
+ interface TRProps {
4
+ /**
5
+ * A `testId` prop is a unique string that appears as a data attribute `data-testid`
6
+ * in the rendered code, serving as a hook for automated tests.
7
+ */
8
+ testId?: string;
9
+ /**
10
+ * If the row has programatic selection applied.
11
+ */
12
+ isSelected?: boolean;
13
+ /**
14
+ * Adjust the behavior of the element depending on whether the row is in the `THead` or in the `TBody`.
15
+ */
16
+ isBodyRow?: boolean;
17
+ /**
18
+ * Content of the row.
19
+ */
20
+ children?: ReactNode;
21
+ /**
22
+ * If the row is a subitem (an expandable row nested under a parent).
23
+ */
24
+ isSubitem?: boolean;
25
+ }
26
+ /**
27
+ * __Row__
28
+ *
29
+ * A row primitive.
30
+ *
31
+ * - [Examples](https://atlassian.design/components/table/examples)
32
+ */
33
+ export declare const TR: FC<TRProps>;
34
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/table",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "A table is used to display data.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -25,6 +25,14 @@
25
25
  "module": "dist/esm/index.js",
26
26
  "module:es2019": "dist/es2019/index.js",
27
27
  "types": "dist/types/index.d.ts",
28
+ "typesVersions": {
29
+ ">=4.5 <4.9": {
30
+ "*": [
31
+ "dist/types-ts4.5/*",
32
+ "dist/types-ts4.5/index.d.ts"
33
+ ]
34
+ }
35
+ },
28
36
  "sideEffects": false,
29
37
  "atlaskit:src": "src/index.tsx",
30
38
  "af:exports": {
@@ -33,13 +41,13 @@
33
41
  },
34
42
  "dependencies": {
35
43
  "@atlaskit/button": "^16.7.0",
36
- "@atlaskit/checkbox": "^12.5.0",
44
+ "@atlaskit/checkbox": "^12.6.0",
37
45
  "@atlaskit/ds-explorations": "^2.1.0",
38
46
  "@atlaskit/ds-lib": "^2.2.0",
39
47
  "@atlaskit/focus-ring": "^1.3.0",
40
48
  "@atlaskit/icon": "^21.12.0",
41
49
  "@atlaskit/primitives": "^0.9.0",
42
- "@atlaskit/tokens": "^1.3.0",
50
+ "@atlaskit/tokens": "^1.4.0",
43
51
  "@atlaskit/tooltip": "^17.8.0",
44
52
  "@atlaskit/visually-hidden": "^1.2.0",
45
53
  "@babel/runtime": "^7.0.0",
@@ -67,7 +75,7 @@
67
75
  "jest-axe": "^4.0.0",
68
76
  "react-dom": "^16.8.0",
69
77
  "storybook-addon-designs": "^6.3.1",
70
- "typescript": "4.5.5",
78
+ "typescript": "~4.9.5",
71
79
  "wait-for-expect": "^1.2.0"
72
80
  },
73
81
  "techstack": {
@@ -6,9 +6,9 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/ui/index.d.ts",
8
8
  "typesVersions": {
9
- ">=4.0 <4.5": {
9
+ ">=4.5 <4.9": {
10
10
  "*": [
11
- "../dist/types-ts4.0/ui/index.d.ts"
11
+ "../dist/types-ts4.5/ui/index.d.ts"
12
12
  ]
13
13
  }
14
14
  }
@@ -0,0 +1,130 @@
1
+ ## API Report File for "@atlaskit/table"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ /// <reference types="react" />
8
+
9
+ import { BoxProps } from '@atlaskit/ds-explorations/box';
10
+ import { FC } from 'react';
11
+ import { jsx } from '@emotion/react';
12
+ import { MemoExoticComponent } from 'react';
13
+ import { default as React_2 } from 'react';
14
+ import { ReactElement } from 'react';
15
+ import { ReactNode } from 'react';
16
+ import { SerializedStyles } from '@emotion/react';
17
+
18
+ // @public (undocumented)
19
+ const alignMap: {
20
+ readonly text: SerializedStyles;
21
+ readonly number: SerializedStyles;
22
+ readonly icon: SerializedStyles;
23
+ };
24
+
25
+ // @public (undocumented)
26
+ type BaseCellProps = {
27
+ width?: string;
28
+ align?: keyof typeof alignMap;
29
+ as?: 'td' | 'th';
30
+ scope?: 'col' | 'row';
31
+ testId?: string;
32
+ children?: ReactNode;
33
+ colSpan?: number;
34
+ } & Pick<BoxProps, 'backgroundColor' | 'className' | 'paddingBlock' | 'paddingInline'>;
35
+
36
+ // @public (undocumented)
37
+ type BodyProps<Item extends object> = {
38
+ rows: Item[];
39
+ children: (row: Item) => ReactElement;
40
+ } | {
41
+ rows?: never;
42
+ children: ReactElement | ReactElement[];
43
+ };
44
+
45
+ // @public
46
+ export const Cell: FC<Omit<BaseCellProps, 'as'>>;
47
+
48
+ // @public (undocumented)
49
+ interface CellProps {
50
+ // (undocumented)
51
+ children?: ReactNode;
52
+ name: string;
53
+ // (undocumented)
54
+ onClick?: React.MouseEventHandler;
55
+ testId?: string;
56
+ }
57
+
58
+ // @public
59
+ export const ExpandableCell: MemoExoticComponent<() => jsx.JSX.Element>;
60
+
61
+ // @public
62
+ export const ExpandableRow: ({ children, isExpanded, isDefaultExpanded, }: ExpandableRowProps) => JSX.Element;
63
+
64
+ // @public
65
+ export const ExpandableRowContent: ({ children }: ExpandableRowContentProps) => JSX.Element;
66
+
67
+ // @public (undocumented)
68
+ type ExpandableRowContentProps = {
69
+ children?: React_2.ReactNode;
70
+ };
71
+
72
+ // @public (undocumented)
73
+ type ExpandableRowProps = {
74
+ children: React_2.ReactNode;
75
+ isExpanded?: boolean;
76
+ isDefaultExpanded?: boolean;
77
+ };
78
+
79
+ // @public
80
+ export const HeadCell: FC<THProps>;
81
+
82
+ // @public
83
+ export const Row: FC<RowProps>;
84
+
85
+ // @public (undocumented)
86
+ type RowProps = {
87
+ testId?: string;
88
+ children?: ReactNode;
89
+ };
90
+
91
+ // @public
92
+ export const SortableColumn: FC<CellProps>;
93
+
94
+ // @public (undocumented)
95
+ type SortKey<Key extends number | string | symbol> = 'unset' | Key;
96
+
97
+ // @public
98
+ function Table<ItemType extends object = object>({ children, isSelectable, sortKey, testId, }: TableProps<ItemType>): jsx.JSX.Element;
99
+ export default Table;
100
+
101
+ // @public (undocumented)
102
+ type TableProps<ItemType extends object = {}> = {
103
+ testId?: string;
104
+ sortKey?: SortKey<keyof ItemType>;
105
+ children: ReactElement | ReactElement[];
106
+ } & ({
107
+ isSelectable: true;
108
+ defaultSelected?: number;
109
+ } | {
110
+ isSelectable?: false;
111
+ });
112
+
113
+ // @public
114
+ export function TBody<ObjectType extends object>({ rows, children, }: BodyProps<ObjectType>): jsx.JSX.Element;
115
+
116
+ // @public (undocumented)
117
+ export const THead: FC<THeadProps>;
118
+
119
+ // @public (undocumented)
120
+ type THeadProps = {
121
+ actions?: (selected: number[]) => ReactNode;
122
+ children?: ReactNode;
123
+ };
124
+
125
+ // @public (undocumented)
126
+ type THProps = Omit<BaseCellProps, 'as'>;
127
+
128
+ // (No @packageDocumentation comment for this package)
129
+
130
+ ```