@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.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/ui/datasource-table-view/datasourceTableView.js +5 -1
- package/dist/cjs/ui/issue-like-table/custom-icons.js +55 -0
- package/dist/cjs/ui/issue-like-table/drag-column-preview.js +20 -5
- package/dist/cjs/ui/issue-like-table/draggable-table-heading.js +72 -13
- package/dist/cjs/ui/issue-like-table/index.js +70 -15
- package/dist/cjs/ui/issue-like-table/messages.js +19 -0
- package/dist/cjs/ui/issue-like-table/render-type/date-time/index.js +3 -3
- package/dist/cjs/ui/issue-like-table/render-type/link/index.js +1 -1
- package/dist/cjs/ui/issue-like-table/render-type/richtext/index.js +0 -3
- package/dist/cjs/ui/issue-like-table/render-type/text/index.js +3 -3
- package/dist/cjs/ui/issue-like-table/render-type/user/index.js +8 -5
- package/dist/cjs/ui/issue-like-table/styled.js +34 -6
- package/dist/es2019/ui/datasource-table-view/datasourceTableView.js +5 -1
- package/dist/es2019/ui/issue-like-table/custom-icons.js +42 -0
- package/dist/es2019/ui/issue-like-table/drag-column-preview.js +19 -18
- package/dist/es2019/ui/issue-like-table/draggable-table-heading.js +58 -11
- package/dist/es2019/ui/issue-like-table/index.js +75 -62
- package/dist/es2019/ui/issue-like-table/messages.js +13 -0
- package/dist/es2019/ui/issue-like-table/render-type/date-time/index.js +4 -4
- package/dist/es2019/ui/issue-like-table/render-type/link/index.js +2 -2
- package/dist/es2019/ui/issue-like-table/render-type/richtext/index.js +0 -3
- package/dist/es2019/ui/issue-like-table/render-type/text/index.js +4 -4
- package/dist/es2019/ui/issue-like-table/render-type/user/index.js +6 -6
- package/dist/es2019/ui/issue-like-table/styled.js +36 -56
- package/dist/esm/ui/datasource-table-view/datasourceTableView.js +5 -1
- package/dist/esm/ui/issue-like-table/custom-icons.js +48 -0
- package/dist/esm/ui/issue-like-table/drag-column-preview.js +19 -5
- package/dist/esm/ui/issue-like-table/draggable-table-heading.js +66 -11
- package/dist/esm/ui/issue-like-table/index.js +71 -16
- package/dist/esm/ui/issue-like-table/messages.js +13 -0
- package/dist/esm/ui/issue-like-table/render-type/date-time/index.js +4 -4
- package/dist/esm/ui/issue-like-table/render-type/link/index.js +2 -2
- package/dist/esm/ui/issue-like-table/render-type/richtext/index.js +0 -3
- package/dist/esm/ui/issue-like-table/render-type/text/index.js +4 -4
- package/dist/esm/ui/issue-like-table/render-type/user/index.js +7 -5
- package/dist/esm/ui/issue-like-table/styled.js +33 -5
- package/dist/types/ui/datasource-table-view/datasourceTableView.d.ts +6 -2
- package/dist/types/ui/datasource-table-view/types.d.ts +3 -14
- package/dist/types/ui/issue-like-table/custom-icons.d.ts +5 -0
- package/dist/types/ui/issue-like-table/draggable-table-heading.d.ts +7 -3
- package/dist/types/ui/issue-like-table/index.d.ts +1 -1
- package/dist/types/ui/issue-like-table/messages.d.ts +12 -0
- package/dist/types/ui/issue-like-table/styled.d.ts +1 -1
- package/dist/types/ui/issue-like-table/types.d.ts +18 -2
- package/dist/types-ts4.5/ui/datasource-table-view/datasourceTableView.d.ts +6 -2
- package/dist/types-ts4.5/ui/datasource-table-view/types.d.ts +3 -14
- package/dist/types-ts4.5/ui/issue-like-table/custom-icons.d.ts +5 -0
- package/dist/types-ts4.5/ui/issue-like-table/draggable-table-heading.d.ts +7 -3
- package/dist/types-ts4.5/ui/issue-like-table/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/issue-like-table/messages.d.ts +12 -0
- package/dist/types-ts4.5/ui/issue-like-table/styled.d.ts +1 -1
- package/dist/types-ts4.5/ui/issue-like-table/types.d.ts +18 -2
- package/examples-helpers/buildIssueLikeTable.tsx +26 -24
- package/examples-helpers/buildJiraIssuesTable.tsx +17 -22
- package/examples-helpers/useCommonTableProps.tsx +57 -0
- package/package.json +2 -2
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
var
|
|
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
|
|
7
|
-
export var Table = styled.table(
|
|
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(
|
|
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
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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?: (
|
|
13
|
-
|
|
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const ScrollableContainerHeight = 590;
|
|
3
|
-
export declare const
|
|
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
|
|
56
|
-
*
|
|
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
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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?: (
|
|
13
|
-
|
|
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const ScrollableContainerHeight = 590;
|
|
3
|
-
export declare const
|
|
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
|
|
56
|
-
*
|
|
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 {
|
|
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 = ({
|
|
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
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
71
|
+
onVisibleColumnKeysChange(defaultVisibleColumnKeys);
|
|
76
72
|
}
|
|
77
|
-
}, [visibleColumnKeys, defaultVisibleColumnKeys,
|
|
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 :
|
|
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, {
|
|
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
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
const {
|
|
32
|
+
visibleColumnKeys,
|
|
33
|
+
onVisibleColumnKeysChange,
|
|
34
|
+
columnCustomSizes,
|
|
35
|
+
onColumnResize,
|
|
36
|
+
wrappedColumnKeys,
|
|
37
|
+
onWrappedColumnChange,
|
|
38
|
+
} = useCommonTableProps({
|
|
39
|
+
defaultColumnCustomSizes: {
|
|
40
|
+
people: 100,
|
|
47
41
|
},
|
|
48
|
-
|
|
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={
|
|
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.
|
|
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.
|
|
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",
|