@atlaskit/link-datasource 1.22.8 → 1.23.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 (57) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/ui/datasource-table-view/datasourceTableView.js +5 -1
  3. package/dist/cjs/ui/issue-like-table/custom-icons.js +55 -0
  4. package/dist/cjs/ui/issue-like-table/drag-column-preview.js +20 -5
  5. package/dist/cjs/ui/issue-like-table/draggable-table-heading.js +72 -13
  6. package/dist/cjs/ui/issue-like-table/index.js +70 -15
  7. package/dist/cjs/ui/issue-like-table/messages.js +19 -0
  8. package/dist/cjs/ui/issue-like-table/render-type/date-time/index.js +3 -3
  9. package/dist/cjs/ui/issue-like-table/render-type/link/index.js +1 -1
  10. package/dist/cjs/ui/issue-like-table/render-type/richtext/index.js +0 -3
  11. package/dist/cjs/ui/issue-like-table/render-type/text/index.js +3 -3
  12. package/dist/cjs/ui/issue-like-table/render-type/user/index.js +8 -5
  13. package/dist/cjs/ui/issue-like-table/styled.js +34 -6
  14. package/dist/es2019/ui/datasource-table-view/datasourceTableView.js +5 -1
  15. package/dist/es2019/ui/issue-like-table/custom-icons.js +42 -0
  16. package/dist/es2019/ui/issue-like-table/drag-column-preview.js +19 -18
  17. package/dist/es2019/ui/issue-like-table/draggable-table-heading.js +58 -11
  18. package/dist/es2019/ui/issue-like-table/index.js +75 -62
  19. package/dist/es2019/ui/issue-like-table/messages.js +13 -0
  20. package/dist/es2019/ui/issue-like-table/render-type/date-time/index.js +4 -4
  21. package/dist/es2019/ui/issue-like-table/render-type/link/index.js +2 -2
  22. package/dist/es2019/ui/issue-like-table/render-type/richtext/index.js +0 -3
  23. package/dist/es2019/ui/issue-like-table/render-type/text/index.js +4 -4
  24. package/dist/es2019/ui/issue-like-table/render-type/user/index.js +6 -6
  25. package/dist/es2019/ui/issue-like-table/styled.js +36 -56
  26. package/dist/esm/ui/datasource-table-view/datasourceTableView.js +5 -1
  27. package/dist/esm/ui/issue-like-table/custom-icons.js +48 -0
  28. package/dist/esm/ui/issue-like-table/drag-column-preview.js +19 -5
  29. package/dist/esm/ui/issue-like-table/draggable-table-heading.js +66 -11
  30. package/dist/esm/ui/issue-like-table/index.js +71 -16
  31. package/dist/esm/ui/issue-like-table/messages.js +13 -0
  32. package/dist/esm/ui/issue-like-table/render-type/date-time/index.js +4 -4
  33. package/dist/esm/ui/issue-like-table/render-type/link/index.js +2 -2
  34. package/dist/esm/ui/issue-like-table/render-type/richtext/index.js +0 -3
  35. package/dist/esm/ui/issue-like-table/render-type/text/index.js +4 -4
  36. package/dist/esm/ui/issue-like-table/render-type/user/index.js +7 -5
  37. package/dist/esm/ui/issue-like-table/styled.js +33 -5
  38. package/dist/types/ui/datasource-table-view/datasourceTableView.d.ts +6 -2
  39. package/dist/types/ui/datasource-table-view/types.d.ts +3 -14
  40. package/dist/types/ui/issue-like-table/custom-icons.d.ts +5 -0
  41. package/dist/types/ui/issue-like-table/draggable-table-heading.d.ts +7 -3
  42. package/dist/types/ui/issue-like-table/index.d.ts +1 -1
  43. package/dist/types/ui/issue-like-table/messages.d.ts +12 -0
  44. package/dist/types/ui/issue-like-table/styled.d.ts +1 -1
  45. package/dist/types/ui/issue-like-table/types.d.ts +18 -2
  46. package/dist/types-ts4.5/ui/datasource-table-view/datasourceTableView.d.ts +6 -2
  47. package/dist/types-ts4.5/ui/datasource-table-view/types.d.ts +3 -14
  48. package/dist/types-ts4.5/ui/issue-like-table/custom-icons.d.ts +5 -0
  49. package/dist/types-ts4.5/ui/issue-like-table/draggable-table-heading.d.ts +7 -3
  50. package/dist/types-ts4.5/ui/issue-like-table/index.d.ts +1 -1
  51. package/dist/types-ts4.5/ui/issue-like-table/messages.d.ts +12 -0
  52. package/dist/types-ts4.5/ui/issue-like-table/styled.d.ts +1 -1
  53. package/dist/types-ts4.5/ui/issue-like-table/types.d.ts +18 -2
  54. package/examples-helpers/buildIssueLikeTable.tsx +26 -24
  55. package/examples-helpers/buildJiraIssuesTable.tsx +17 -22
  56. package/examples-helpers/useCommonTableProps.tsx +57 -0
  57. package/package.json +2 -2
@@ -1,10 +1,12 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2;
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ var _styled$th;
3
3
  import styled from '@emotion/styled';
4
4
  import { N40 } from '@atlaskit/theme/colors';
5
5
  export var ScrollableContainerHeight = 590;
6
- export var FieldTextFontSize = '14px';
7
- export var Table = styled.table(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 100%;\n"])));
6
+ export var fieldTextFontSize = "var(--ds-font-size-100, 14px)";
7
+ export var Table = styled.table({
8
+ width: '100%'
9
+ });
8
10
  var lineHeight = "var(--ds-font-lineHeight-300, 24px)";
9
11
  var verticalPadding = "var(--ds-space-025, 2px)";
10
12
 
@@ -20,4 +22,30 @@ export var withTablePluginPrefix = function withTablePluginPrefix(tableSection)
20
22
  };
21
23
  export var withTablePluginHeaderPrefix = withTablePluginPrefix.bind(null, 'thead');
22
24
  export var withTablePluginBodyPrefix = withTablePluginPrefix.bind(null, 'tbody');
23
- export var TableHeading = styled.th(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", " {\n border: 0;\n position: relative;\n\n /* This makes resizing work with out jumping due to padding + changes overall width for same default values. */\n box-sizing: border-box;\n\n line-height: ", ";\n padding: ", " ", ";\n border-right: 0.5px solid ", ";\n border-bottom: 2px solid ", ";\n\n /*\n lineHeight * 2 -> Max height of two lined header\n verticalPadding * 2 -> padding for this component itself\n verticalPadding * 2 -> padding inside span (--container)\n 2px -> Bottom border\n Last two terms are needed because of border-box box sizing.\n */\n height: calc(", " * 2 + ", " * 4 + 2px);\n vertical-align: bottom;\n background-color: ", ";\n }\n\n ", " {\n border-right: 0;\n }\n\n ", " {\n padding-left: ", ";\n }\n\n ", " {\n border-right: 0;\n }\n\n & [data-testid='datasource-header-content--container'] {\n width: 100%;\n padding: ", " ", ";\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n white-space: normal;\n overflow: hidden;\n word-wrap: break-word;\n\n &:hover {\n background: ", ";\n border-radius: 3px;\n }\n }\n"])), withTablePluginHeaderPrefix(), lineHeight, verticalPadding, "var(--ds-space-050, 4px)", "var(--ds-border, ".concat(N40, ")"), "var(--ds-border, ".concat(N40, ")"), lineHeight, verticalPadding, "var(--ds-elevation-surface-current, #FFF)", withTablePluginPrefix('', 'thead.has-column-picker &:nth-last-of-type(2)'), withTablePluginHeaderPrefix('&:first-child'), "var(--ds-space-050, 4px)", withTablePluginHeaderPrefix('&:last-child'), verticalPadding, "var(--ds-space-050, 4px)", "var(--ds-background-input-hovered, #F7F8F9)");
25
+ export var TableHeading = styled.th((_styled$th = {}, _defineProperty(_styled$th, "".concat(withTablePluginHeaderPrefix()), {
26
+ border: 0,
27
+ position: 'relative',
28
+ boxSizing: 'border-box',
29
+ lineHeight: lineHeight,
30
+ padding: "".concat(verticalPadding, " ", "var(--ds-space-050, 4px)"),
31
+ borderRight: "0.5px solid ".concat("var(--ds-border, ".concat(N40, ")")),
32
+ borderBottom: "2px solid ".concat("var(--ds-border, ".concat(N40, ")")),
33
+ height: "calc(".concat(lineHeight, " * 2 + ").concat(verticalPadding, " * 4 + 2px)"),
34
+ verticalAlign: 'bottom',
35
+ backgroundColor: "var(--ds-elevation-surface-current, #FFF)"
36
+ }), _defineProperty(_styled$th, "".concat(withTablePluginPrefix('', 'thead.has-column-picker &:nth-last-of-type(2)')), {
37
+ borderRight: 0
38
+ }), _defineProperty(_styled$th, "".concat(withTablePluginHeaderPrefix('&:first-child')), {
39
+ paddingLeft: "var(--ds-space-050, 4px)"
40
+ }), _defineProperty(_styled$th, "".concat(withTablePluginHeaderPrefix('&:last-child')), {
41
+ borderRight: 0
42
+ }), _defineProperty(_styled$th, "& [data-testid='datasource-header-content--container']", {
43
+ width: '100%',
44
+ padding: "".concat(verticalPadding, " ", "var(--ds-space-050, 4px)"),
45
+ display: '-webkit-box',
46
+ WebkitLineClamp: 2,
47
+ WebkitBoxOrient: 'vertical',
48
+ whiteSpace: 'normal',
49
+ overflow: 'hidden',
50
+ wordWrap: 'break-word'
51
+ }), _styled$th));
@@ -1,3 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { DatasourceTableViewProps } from './types';
3
- export declare const DatasourceTableView: import("react").ForwardRefExoticComponent<DatasourceTableViewProps & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;
2
+ export declare const DatasourceTableView: import("react").ForwardRefExoticComponent<{
3
+ datasourceId: string;
4
+ parameters: object;
5
+ fields?: string[] | undefined;
6
+ url?: string | undefined;
7
+ } & Partial<Pick<import("../issue-like-table/types").IssueLikeDataTableViewProps, "visibleColumnKeys">> & Pick<import("../issue-like-table/types").IssueLikeDataTableViewProps, "onVisibleColumnKeysChange" | "columnCustomSizes" | "onColumnResize" | "wrappedColumnKeys" | "onWrappedColumnChange"> & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;
@@ -1,21 +1,10 @@
1
- export interface DatasourceTableViewProps {
1
+ import { IssueLikeDataTableViewProps } from '../issue-like-table/types';
2
+ export type DatasourceTableViewProps = {
2
3
  /** Unique identifier for which type of datasource is being rendered and for making its requests */
3
4
  datasourceId: string;
4
5
  /** Parameters for making the data requests necessary to render data within the table */
5
6
  parameters: object;
6
7
  fields?: string[];
7
- /**
8
- * Callback to be invoked whenever a user changes the visible columns in a datasource table
9
- *
10
- * @param visibleColumnKeys the array of keys for all of the selected columns
11
- */
12
- onVisibleColumnKeysChange?: (visibleColumnKeys: string[]) => void;
13
- /** The array of keys for all of the columns to be shown in the table */
14
- visibleColumnKeys?: string[];
15
8
  /** Url for an existing datasource, initially used for displaying to a user unauthorized to query that site */
16
9
  url?: string;
17
- columnCustomSizes?: {
18
- [key: string]: number;
19
- };
20
- onColumnResize?: (key: string, width: number) => void;
21
- }
10
+ } & Partial<Pick<IssueLikeDataTableViewProps, 'visibleColumnKeys'>> & Pick<IssueLikeDataTableViewProps, 'onVisibleColumnKeysChange' | 'wrappedColumnKeys' | 'onWrappedColumnChange' | 'onColumnResize' | 'columnCustomSizes'>;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { CustomGlyphProps } from '@atlaskit/icon';
3
+ export declare const GlyphPlaceholder: (props: CustomGlyphProps) => JSX.Element;
4
+ export declare const WrapTextIcon: () => JSX.Element;
5
+ export declare const UnwrapTextIcon: () => JSX.Element;
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { ReactNode } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
- export declare const DraggableTableHeading: ({ children, id, index, tableId, dndPreviewHeight, dragPreview, width, onWidthChange, }: {
4
+ interface DraggableTableHeadingProps {
5
5
  children: ReactNode;
6
6
  id: string;
7
7
  index: number;
@@ -9,5 +9,9 @@ export declare const DraggableTableHeading: ({ children, id, index, tableId, dnd
9
9
  dndPreviewHeight: number;
10
10
  dragPreview: React.ReactNode;
11
11
  width: number;
12
- onWidthChange?: ((width: number) => void) | undefined;
13
- }) => jsx.JSX.Element;
12
+ onWidthChange?: (width: number) => void;
13
+ isWrapped?: boolean;
14
+ onIsWrappedChange?: (shouldWrap: boolean) => void;
15
+ }
16
+ export declare const DraggableTableHeading: ({ children, id, index, tableId, dndPreviewHeight, dragPreview, width, onWidthChange, isWrapped, onIsWrappedChange, }: DraggableTableHeadingProps) => jsx.JSX.Element;
17
+ export {};
@@ -22,5 +22,5 @@ export interface RowCellType {
22
22
  content?: React.ReactNode | string;
23
23
  }
24
24
  export declare const getOrderedColumns: (columns: DatasourceResponseSchemaProperty[], visibleColumnKeys: string[]) => DatasourceResponseSchemaProperty[];
25
- export declare const IssueLikeDataTableView: ({ testId, onNextPage, onLoadDatasourceDetails, items, columns, renderItem, visibleColumnKeys, onVisibleColumnKeysChange, columnCustomSizes, onColumnResize, status, hasNextPage, scrollableContainerHeight, parentContainerRenderInstanceId, extensionKey, }: IssueLikeDataTableViewProps) => jsx.JSX.Element;
25
+ export declare const IssueLikeDataTableView: ({ testId, onNextPage, onLoadDatasourceDetails, items, columns, renderItem, visibleColumnKeys, onVisibleColumnKeysChange, columnCustomSizes, onColumnResize, wrappedColumnKeys, onWrappedColumnChange, status, hasNextPage, scrollableContainerHeight, parentContainerRenderInstanceId, extensionKey, }: IssueLikeDataTableViewProps) => jsx.JSX.Element;
26
26
  export declare const EmptyState: ({ isCompact, testId }: import("./empty-state").Props) => jsx.JSX.Element;
@@ -0,0 +1,12 @@
1
+ export declare const issueLikeTableMessages: {
2
+ wrapText: {
3
+ id: string;
4
+ description: string;
5
+ defaultMessage: string;
6
+ };
7
+ unwrapText: {
8
+ id: string;
9
+ description: string;
10
+ defaultMessage: string;
11
+ };
12
+ };
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export declare const ScrollableContainerHeight = 590;
3
- export declare const FieldTextFontSize = "14px";
3
+ export declare const fieldTextFontSize: "var(--ds-font-size-100)";
4
4
  export declare const Table: import("@emotion/styled").StyledComponent<{
5
5
  theme?: import("@emotion/react").Theme | undefined;
6
6
  as?: import("react").ElementType<any> | undefined;
@@ -52,8 +52,10 @@ export interface IssueLikeDataTableViewProps {
52
52
  */
53
53
  renderItem?: TableViewPropsRenderType;
54
54
  /**
55
- * Callback that is called in either column re-order or columns being selected/unselected
56
- * @param visibleColumnKeys
55
+ * Callback to be invoked whenever a user changes the visible columns in a datasource table
56
+ * either by selecting/unselecting or reordering (drag and drop)
57
+ *
58
+ * @param visibleColumnKeys the array of keys for all of the selected columns
57
59
  */
58
60
  onVisibleColumnKeysChange?: (visibleColumnKeys: string[]) => void;
59
61
  /**
@@ -61,6 +63,20 @@ export interface IssueLikeDataTableViewProps {
61
63
  * It this number is undefined it will not restrict height and not make container scrollable.
62
64
  */
63
65
  scrollableContainerHeight?: number;
66
+ /**
67
+ * Map of column key to custom column width
68
+ */
64
69
  columnCustomSizes?: ColumnSizesMap;
65
70
  onColumnResize?: (key: string, width: number) => void;
71
+ /**
72
+ * List of column keys that needs to be shown without truncation (content will wrap to a new line)
73
+ */
74
+ wrappedColumnKeys?: string[];
75
+ /**
76
+ * Callback to be invoked whenever user changes wrap attribute of the column.
77
+ *
78
+ * @param key Column key
79
+ * @param shouldWrap Whenever column should wrap
80
+ */
81
+ onWrappedColumnChange?: (key: string, shouldWrap: boolean) => void;
66
82
  }
@@ -1,3 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { DatasourceTableViewProps } from './types';
3
- export declare const DatasourceTableView: import("react").ForwardRefExoticComponent<DatasourceTableViewProps & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;
2
+ export declare const DatasourceTableView: import("react").ForwardRefExoticComponent<{
3
+ datasourceId: string;
4
+ parameters: object;
5
+ fields?: string[] | undefined;
6
+ url?: string | undefined;
7
+ } & Partial<Pick<import("../issue-like-table/types").IssueLikeDataTableViewProps, "visibleColumnKeys">> & Pick<import("../issue-like-table/types").IssueLikeDataTableViewProps, "onVisibleColumnKeysChange" | "columnCustomSizes" | "onColumnResize" | "wrappedColumnKeys" | "onWrappedColumnChange"> & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;
@@ -1,21 +1,10 @@
1
- export interface DatasourceTableViewProps {
1
+ import { IssueLikeDataTableViewProps } from '../issue-like-table/types';
2
+ export type DatasourceTableViewProps = {
2
3
  /** Unique identifier for which type of datasource is being rendered and for making its requests */
3
4
  datasourceId: string;
4
5
  /** Parameters for making the data requests necessary to render data within the table */
5
6
  parameters: object;
6
7
  fields?: string[];
7
- /**
8
- * Callback to be invoked whenever a user changes the visible columns in a datasource table
9
- *
10
- * @param visibleColumnKeys the array of keys for all of the selected columns
11
- */
12
- onVisibleColumnKeysChange?: (visibleColumnKeys: string[]) => void;
13
- /** The array of keys for all of the columns to be shown in the table */
14
- visibleColumnKeys?: string[];
15
8
  /** Url for an existing datasource, initially used for displaying to a user unauthorized to query that site */
16
9
  url?: string;
17
- columnCustomSizes?: {
18
- [key: string]: number;
19
- };
20
- onColumnResize?: (key: string, width: number) => void;
21
- }
10
+ } & Partial<Pick<IssueLikeDataTableViewProps, 'visibleColumnKeys'>> & Pick<IssueLikeDataTableViewProps, 'onVisibleColumnKeysChange' | 'wrappedColumnKeys' | 'onWrappedColumnChange' | 'onColumnResize' | 'columnCustomSizes'>;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { CustomGlyphProps } from '@atlaskit/icon';
3
+ export declare const GlyphPlaceholder: (props: CustomGlyphProps) => JSX.Element;
4
+ export declare const WrapTextIcon: () => JSX.Element;
5
+ export declare const UnwrapTextIcon: () => JSX.Element;
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { ReactNode } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
- export declare const DraggableTableHeading: ({ children, id, index, tableId, dndPreviewHeight, dragPreview, width, onWidthChange, }: {
4
+ interface DraggableTableHeadingProps {
5
5
  children: ReactNode;
6
6
  id: string;
7
7
  index: number;
@@ -9,5 +9,9 @@ export declare const DraggableTableHeading: ({ children, id, index, tableId, dnd
9
9
  dndPreviewHeight: number;
10
10
  dragPreview: React.ReactNode;
11
11
  width: number;
12
- onWidthChange?: ((width: number) => void) | undefined;
13
- }) => jsx.JSX.Element;
12
+ onWidthChange?: (width: number) => void;
13
+ isWrapped?: boolean;
14
+ onIsWrappedChange?: (shouldWrap: boolean) => void;
15
+ }
16
+ export declare const DraggableTableHeading: ({ children, id, index, tableId, dndPreviewHeight, dragPreview, width, onWidthChange, isWrapped, onIsWrappedChange, }: DraggableTableHeadingProps) => jsx.JSX.Element;
17
+ export {};
@@ -22,5 +22,5 @@ export interface RowCellType {
22
22
  content?: React.ReactNode | string;
23
23
  }
24
24
  export declare const getOrderedColumns: (columns: DatasourceResponseSchemaProperty[], visibleColumnKeys: string[]) => DatasourceResponseSchemaProperty[];
25
- export declare const IssueLikeDataTableView: ({ testId, onNextPage, onLoadDatasourceDetails, items, columns, renderItem, visibleColumnKeys, onVisibleColumnKeysChange, columnCustomSizes, onColumnResize, status, hasNextPage, scrollableContainerHeight, parentContainerRenderInstanceId, extensionKey, }: IssueLikeDataTableViewProps) => jsx.JSX.Element;
25
+ export declare const IssueLikeDataTableView: ({ testId, onNextPage, onLoadDatasourceDetails, items, columns, renderItem, visibleColumnKeys, onVisibleColumnKeysChange, columnCustomSizes, onColumnResize, wrappedColumnKeys, onWrappedColumnChange, status, hasNextPage, scrollableContainerHeight, parentContainerRenderInstanceId, extensionKey, }: IssueLikeDataTableViewProps) => jsx.JSX.Element;
26
26
  export declare const EmptyState: ({ isCompact, testId }: import("./empty-state").Props) => jsx.JSX.Element;
@@ -0,0 +1,12 @@
1
+ export declare const issueLikeTableMessages: {
2
+ wrapText: {
3
+ id: string;
4
+ description: string;
5
+ defaultMessage: string;
6
+ };
7
+ unwrapText: {
8
+ id: string;
9
+ description: string;
10
+ defaultMessage: string;
11
+ };
12
+ };
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export declare const ScrollableContainerHeight = 590;
3
- export declare const FieldTextFontSize = "14px";
3
+ export declare const fieldTextFontSize: "var(--ds-font-size-100)";
4
4
  export declare const Table: import("@emotion/styled").StyledComponent<{
5
5
  theme?: import("@emotion/react").Theme | undefined;
6
6
  as?: import("react").ElementType<any> | undefined;
@@ -52,8 +52,10 @@ export interface IssueLikeDataTableViewProps {
52
52
  */
53
53
  renderItem?: TableViewPropsRenderType;
54
54
  /**
55
- * Callback that is called in either column re-order or columns being selected/unselected
56
- * @param visibleColumnKeys
55
+ * Callback to be invoked whenever a user changes the visible columns in a datasource table
56
+ * either by selecting/unselecting or reordering (drag and drop)
57
+ *
58
+ * @param visibleColumnKeys the array of keys for all of the selected columns
57
59
  */
58
60
  onVisibleColumnKeysChange?: (visibleColumnKeys: string[]) => void;
59
61
  /**
@@ -61,6 +63,20 @@ export interface IssueLikeDataTableViewProps {
61
63
  * It this number is undefined it will not restrict height and not make container scrollable.
62
64
  */
63
65
  scrollableContainerHeight?: number;
66
+ /**
67
+ * Map of column key to custom column width
68
+ */
64
69
  columnCustomSizes?: ColumnSizesMap;
65
70
  onColumnResize?: (key: string, width: number) => void;
71
+ /**
72
+ * List of column keys that needs to be shown without truncation (content will wrap to a new line)
73
+ */
74
+ wrappedColumnKeys?: string[];
75
+ /**
76
+ * Callback to be invoked whenever user changes wrap attribute of the column.
77
+ *
78
+ * @param key Column key
79
+ * @param shouldWrap Whenever column should wrap
80
+ */
81
+ onWrappedColumnChange?: (key: string, shouldWrap: boolean) => void;
66
82
  }
@@ -1,28 +1,26 @@
1
1
  /** @jsx jsx */
2
- import { useCallback, useEffect, useMemo, useState } from 'react';
2
+ import { useEffect, useMemo } from 'react';
3
3
 
4
4
  import { jsx } from '@emotion/react';
5
5
  import styled from '@emotion/styled';
6
6
  import { IntlProvider } from 'react-intl-next';
7
7
 
8
8
  import { SmartCardProvider } from '@atlaskit/link-provider';
9
- import {
10
- defaultInitialVisibleColumnKeys,
11
- mockDatasourceFetchRequests,
12
- } from '@atlaskit/link-test-helpers/datasource';
9
+ import { mockDatasourceFetchRequests } from '@atlaskit/link-test-helpers/datasource';
13
10
 
14
11
  import { useDatasourceTableState } from '../src/hooks/useDatasourceTableState';
15
12
  import { IssueLikeDataTableView } from '../src/ui/issue-like-table';
16
- import { ColumnSizesMap } from '../src/ui/issue-like-table/types';
17
13
  import { JiraIssueDatasourceParameters } from '../src/ui/jira-issues-modal/types';
18
14
 
19
15
  import SmartLinkClient from './smartLinkCustomClient';
16
+ import { useCommonTableProps } from './useCommonTableProps';
20
17
 
21
18
  mockDatasourceFetchRequests();
22
19
 
23
20
  interface Props {
24
21
  isReadonly?: boolean;
25
22
  canResizeColumns?: boolean;
23
+ canControlWrapping?: boolean;
26
24
  }
27
25
 
28
26
  const TableViewWrapper = styled.div`
@@ -33,7 +31,11 @@ const TableViewWrapper = styled.div`
33
31
  height: 100%;
34
32
  `;
35
33
 
36
- const ExampleBody = ({ isReadonly, canResizeColumns = true }: Props) => {
34
+ const ExampleBody = ({
35
+ isReadonly,
36
+ canResizeColumns = true,
37
+ canControlWrapping = true,
38
+ }: Props) => {
37
39
  const parameters = useMemo<JiraIssueDatasourceParameters>(
38
40
  () => ({
39
41
  cloudId: 'some-cloud-id',
@@ -55,26 +57,20 @@ const ExampleBody = ({ isReadonly, canResizeColumns = true }: Props) => {
55
57
  parameters,
56
58
  });
57
59
 
58
- const [visibleColumnKeys, setVisibleColumnKeys] = useState<string[]>(
59
- defaultInitialVisibleColumnKeys,
60
- );
61
-
62
- const [columnCustomSizes, setColumnCustomSizes] = useState<
63
- ColumnSizesMap | undefined
64
- >();
65
-
66
- const onColumnResize = useCallback(
67
- (key: string, width: number) => {
68
- setColumnCustomSizes({ ...columnCustomSizes, [key]: width });
69
- },
70
- [columnCustomSizes],
71
- );
60
+ const {
61
+ visibleColumnKeys,
62
+ onVisibleColumnKeysChange,
63
+ columnCustomSizes,
64
+ onColumnResize,
65
+ wrappedColumnKeys,
66
+ onWrappedColumnChange,
67
+ } = useCommonTableProps();
72
68
 
73
69
  useEffect(() => {
74
70
  if (visibleColumnKeys.length === 0 && defaultVisibleColumnKeys.length > 0) {
75
- setVisibleColumnKeys(defaultVisibleColumnKeys);
71
+ onVisibleColumnKeysChange(defaultVisibleColumnKeys);
76
72
  }
77
- }, [visibleColumnKeys, defaultVisibleColumnKeys, setVisibleColumnKeys]);
73
+ }, [visibleColumnKeys, defaultVisibleColumnKeys, onVisibleColumnKeysChange]);
78
74
 
79
75
  return (
80
76
  <TableViewWrapper>
@@ -89,12 +85,16 @@ const ExampleBody = ({ isReadonly, canResizeColumns = true }: Props) => {
89
85
  columns={columns}
90
86
  visibleColumnKeys={visibleColumnKeys}
91
87
  onVisibleColumnKeysChange={
92
- isReadonly ? undefined : setVisibleColumnKeys
88
+ isReadonly ? undefined : onVisibleColumnKeysChange
93
89
  }
94
90
  onColumnResize={
95
91
  isReadonly || !canResizeColumns ? undefined : onColumnResize
96
92
  }
97
93
  columnCustomSizes={columnCustomSizes}
94
+ onWrappedColumnChange={
95
+ canControlWrapping ? onWrappedColumnChange : undefined
96
+ }
97
+ wrappedColumnKeys={wrappedColumnKeys}
98
98
  />
99
99
  ) : (
100
100
  <span>Loading ...</span>
@@ -106,6 +106,7 @@ const ExampleBody = ({ isReadonly, canResizeColumns = true }: Props) => {
106
106
  export const ExampleIssueLikeTable = ({
107
107
  isReadonly,
108
108
  canResizeColumns,
109
+ canControlWrapping,
109
110
  }: Props) => {
110
111
  return (
111
112
  <IntlProvider locale="en">
@@ -113,6 +114,7 @@ export const ExampleIssueLikeTable = ({
113
114
  <ExampleBody
114
115
  isReadonly={isReadonly}
115
116
  canResizeColumns={canResizeColumns}
117
+ canControlWrapping={canControlWrapping}
116
118
  />
117
119
  </SmartCardProvider>
118
120
  </IntlProvider>
@@ -1,19 +1,16 @@
1
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
1
+ import React, { useEffect, useMemo } from 'react';
2
2
 
3
3
  import { IntlProvider } from 'react-intl-next';
4
4
 
5
5
  import { SmartCardProvider } from '@atlaskit/link-provider';
6
- import {
7
- defaultInitialVisibleColumnKeys,
8
- mockDatasourceFetchRequests,
9
- } from '@atlaskit/link-test-helpers/datasource';
6
+ import { mockDatasourceFetchRequests } from '@atlaskit/link-test-helpers/datasource';
10
7
  import { DatasourceParameters } from '@atlaskit/linking-types';
11
8
 
12
9
  import { DatasourceTableView } from '../src';
13
- import { ColumnSizesMap } from '../src/ui/issue-like-table/types';
14
10
  import { JiraIssueDatasourceParameters } from '../src/ui/jira-issues-modal/types';
15
11
 
16
12
  import SmartLinkClient from './smartLinkCustomClient';
13
+ import { useCommonTableProps } from './useCommonTableProps';
17
14
 
18
15
  interface JiraIssuesTableViewProps {
19
16
  parameters?: DatasourceParameters;
@@ -23,10 +20,6 @@ interface JiraIssuesTableViewProps {
23
20
  const JiraIssuesTableView = ({ parameters }: JiraIssuesTableViewProps) => {
24
21
  const cloudId = parameters?.cloudId || 'some-cloud-id';
25
22
 
26
- const [visibleColumnKeys, setVisibleColumnKeys] = useState<string[]>(
27
- defaultInitialVisibleColumnKeys,
28
- );
29
-
30
23
  const datasourceParameters = useMemo<JiraIssueDatasourceParameters>(
31
24
  () => ({
32
25
  cloudId,
@@ -35,27 +28,29 @@ const JiraIssuesTableView = ({ parameters }: JiraIssuesTableViewProps) => {
35
28
  [cloudId],
36
29
  );
37
30
 
38
- const [columnCustomSizes, setColumnCustomSizes] = useState<
39
- ColumnSizesMap | undefined
40
- >({
41
- people: 100,
42
- });
43
-
44
- const onColumnResize = useCallback(
45
- (key: string, width: number) => {
46
- setColumnCustomSizes({ ...columnCustomSizes, [key]: width });
31
+ const {
32
+ visibleColumnKeys,
33
+ onVisibleColumnKeysChange,
34
+ columnCustomSizes,
35
+ onColumnResize,
36
+ wrappedColumnKeys,
37
+ onWrappedColumnChange,
38
+ } = useCommonTableProps({
39
+ defaultColumnCustomSizes: {
40
+ people: 100,
47
41
  },
48
- [columnCustomSizes],
49
- );
42
+ });
50
43
 
51
44
  return (
52
45
  <DatasourceTableView
53
46
  datasourceId={'some-datasource-id'}
54
47
  parameters={datasourceParameters}
55
48
  visibleColumnKeys={visibleColumnKeys}
56
- onVisibleColumnKeysChange={setVisibleColumnKeys}
49
+ onVisibleColumnKeysChange={onVisibleColumnKeysChange}
57
50
  columnCustomSizes={columnCustomSizes}
58
51
  onColumnResize={onColumnResize}
52
+ onWrappedColumnChange={onWrappedColumnChange}
53
+ wrappedColumnKeys={wrappedColumnKeys}
59
54
  />
60
55
  );
61
56
  };
@@ -0,0 +1,57 @@
1
+ import { useCallback, useState } from 'react';
2
+
3
+ import { defaultInitialVisibleColumnKeys } from '@atlaskit/link-test-helpers/datasource';
4
+
5
+ import { DatasourceTableViewProps } from '../src/ui/datasource-table-view/types';
6
+ import { ColumnSizesMap } from '../src/ui/issue-like-table/types';
7
+
8
+ export const useCommonTableProps = (
9
+ props: { defaultColumnCustomSizes?: ColumnSizesMap } = {},
10
+ ): Required<
11
+ Pick<
12
+ DatasourceTableViewProps,
13
+ | 'visibleColumnKeys'
14
+ | 'onVisibleColumnKeysChange'
15
+ | 'wrappedColumnKeys'
16
+ | 'onWrappedColumnChange'
17
+ | 'onColumnResize'
18
+ >
19
+ > &
20
+ Pick<DatasourceTableViewProps, 'columnCustomSizes'> => {
21
+ const [visibleColumnKeys, onVisibleColumnKeysChange] = useState<string[]>(
22
+ defaultInitialVisibleColumnKeys,
23
+ );
24
+
25
+ const [columnCustomSizes, setColumnCustomSizes] = useState<
26
+ ColumnSizesMap | undefined
27
+ >(props.defaultColumnCustomSizes);
28
+
29
+ const onColumnResize = useCallback(
30
+ (key: string, width: number) => {
31
+ setColumnCustomSizes({ ...columnCustomSizes, [key]: width });
32
+ },
33
+ [columnCustomSizes],
34
+ );
35
+
36
+ const [wrappedColumnKeys, setWrappedColumnKeys] = useState<string[]>([]);
37
+
38
+ const onWrappedColumnChange = useCallback(
39
+ (key: string, shouldWrap: boolean) => {
40
+ if (shouldWrap) {
41
+ setWrappedColumnKeys([...wrappedColumnKeys, key]);
42
+ } else {
43
+ setWrappedColumnKeys(wrappedColumnKeys.filter(k => k !== key));
44
+ }
45
+ },
46
+ [wrappedColumnKeys],
47
+ );
48
+
49
+ return {
50
+ visibleColumnKeys,
51
+ onVisibleColumnKeysChange,
52
+ columnCustomSizes,
53
+ onColumnResize,
54
+ wrappedColumnKeys,
55
+ onWrappedColumnChange,
56
+ };
57
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "1.22.8",
3
+ "version": "1.23.0",
4
4
  "description": "UI Components to support linking platform dataset feature",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -61,7 +61,7 @@
61
61
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.0.0",
62
62
  "@atlaskit/primitives": "^2.1.0",
63
63
  "@atlaskit/select": "^17.1.0",
64
- "@atlaskit/smart-card": "^26.47.0",
64
+ "@atlaskit/smart-card": "^26.48.0",
65
65
  "@atlaskit/spinner": "^16.0.0",
66
66
  "@atlaskit/tag": "^12.0.0",
67
67
  "@atlaskit/textfield": "6.0.1",