@atlaskit/link-datasource 0.14.4 → 0.15.1

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 (28) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/ui/issue-like-table/draggable-table-heading.js +5 -1
  3. package/dist/cjs/ui/issue-like-table/index.js +78 -31
  4. package/dist/cjs/ui/issue-like-table/styled.js +5 -3
  5. package/dist/cjs/version.json +1 -1
  6. package/dist/es2019/ui/issue-like-table/draggable-table-heading.js +5 -1
  7. package/dist/es2019/ui/issue-like-table/index.js +60 -14
  8. package/dist/es2019/ui/issue-like-table/styled.js +3 -0
  9. package/dist/es2019/version.json +1 -1
  10. package/dist/esm/ui/issue-like-table/draggable-table-heading.js +5 -1
  11. package/dist/esm/ui/issue-like-table/index.js +79 -32
  12. package/dist/esm/ui/issue-like-table/styled.js +3 -2
  13. package/dist/esm/version.json +1 -1
  14. package/dist/types/ui/issue-like-table/draggable-table-heading.d.ts +2 -1
  15. package/dist/types/ui/issue-like-table/index.d.ts +1 -0
  16. package/dist/types/ui/issue-like-table/styled.d.ts +4 -0
  17. package/dist/types-ts4.5/ui/issue-like-table/draggable-table-heading.d.ts +2 -1
  18. package/dist/types-ts4.5/ui/issue-like-table/index.d.ts +1 -0
  19. package/dist/types-ts4.5/ui/issue-like-table/styled.d.ts +4 -0
  20. package/examples-helpers/buildIssueLikeTable.tsx +4 -2
  21. package/examples-helpers/buildJiraIssuesTable.tsx +4 -2
  22. package/package.json +4 -4
  23. package/examples-helpers/mockAutocompleteData.ts +0 -54
  24. package/examples-helpers/mockJiraAvailableSites.ts +0 -27
  25. package/examples-helpers/mockJiraData.ts +0 -546
  26. package/examples-helpers/mockSuggestionData.ts +0 -17
  27. package/examples-helpers/setupDatasourcesMocks.ts +0 -199
  28. package/examples-helpers/setupModalExampleMocks.ts +0 -32
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/link-datasource
2
2
 
3
+ ## 0.15.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`3d4e152483b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3d4e152483b) - Move all the mocking outside into link-test-helpers and use it.
8
+
9
+ ## 0.15.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`9b52f1c40fa`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9b52f1c40fa) - Added a default column width to specific fields and types
14
+
3
15
  ## 0.14.4
4
16
 
5
17
  ### Patch Changes
@@ -56,6 +56,7 @@ var DraggableTableHeading = function DraggableTableHeading(_ref) {
56
56
  index = _ref.index,
57
57
  tableId = _ref.tableId,
58
58
  dndPreviewHeight = _ref.dndPreviewHeight,
59
+ maxWidth = _ref.maxWidth,
59
60
  onDragPreviewStart = _ref.onDragPreviewStart,
60
61
  onDragPreviewEnd = _ref.onDragPreviewEnd;
61
62
  var ref = (0, _react.useRef)(null);
@@ -160,7 +161,10 @@ var DraggableTableHeading = function DraggableTableHeading(_ref) {
160
161
  return (0, _react2.jsx)(_styled.TableHeading, {
161
162
  ref: ref,
162
163
  css: [tableHeadingStyles, tableHeadingStatusStyles[status]],
163
- "data-testid": "".concat(id, "-column-heading")
164
+ "data-testid": "".concat(id, "-column-heading"),
165
+ style: {
166
+ maxWidth: maxWidth
167
+ }
164
168
  }, (0, _react2.jsx)("div", {
165
169
  ref: dropTargetRef,
166
170
  css: [dropTargetStyles, isDraggingAnyColumn ? null : noPointerEventsStyles],
@@ -34,6 +34,11 @@ var columnPickerHeaderStyles = (0, _react2.css)({
34
34
  // TODO use some variable for that?
35
35
  paddingBlock: "var(--ds-space-100, 8px)"
36
36
  });
37
+ var truncatedCellStyles = (0, _react2.css)({
38
+ overflow: 'hidden',
39
+ textOverflow: 'ellipsis',
40
+ whiteSpace: 'nowrap'
41
+ });
37
42
  var tableDragPreviewStyles = (0, _react2.css)({
38
43
  backgroundColor: "var(--ds-surface, #FFF)"
39
44
  });
@@ -62,6 +67,29 @@ var orderColumns = function orderColumns(columns, visibleColumnKeys) {
62
67
  });
63
68
  return (0, _toConsumableArray2.default)(columns);
64
69
  };
70
+ var BASE_WIDTH = 8;
71
+ function getColumnWidth(key, type) {
72
+ var keyBasedWidth = {
73
+ assignee: BASE_WIDTH * 22,
74
+ key: BASE_WIDTH * 10,
75
+ labels: BASE_WIDTH * 22,
76
+ priority: BASE_WIDTH * 8,
77
+ status: BASE_WIDTH * 18,
78
+ summary: BASE_WIDTH * 45,
79
+ type: BASE_WIDTH * 8
80
+ };
81
+ if (keyBasedWidth[key]) {
82
+ return keyBasedWidth[key];
83
+ }
84
+ switch (type) {
85
+ case 'date':
86
+ return BASE_WIDTH * 14;
87
+ case 'string':
88
+ return BASE_WIDTH * 22;
89
+ default:
90
+ undefined;
91
+ }
92
+ }
65
93
  var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
66
94
  var _orderedColumns$find;
67
95
  var testId = _ref2.testId,
@@ -126,12 +154,15 @@ var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
126
154
  })
127
155
  };
128
156
  }, [visibleSortedColumns]);
129
- var headColumns = visibleSortedColumns.map(function (column) {
157
+ var headColumns = visibleSortedColumns.map(function (_ref5) {
158
+ var key = _ref5.key,
159
+ title = _ref5.title,
160
+ type = _ref5.type;
130
161
  return {
131
- key: column.key,
132
- content: column.title,
133
- // width: TODO Find out how we going to retrieve column width
134
- shouldTruncate: true
162
+ key: key,
163
+ content: title,
164
+ shouldTruncate: true,
165
+ maxWidth: getColumnWidth(key, type)
135
166
  };
136
167
  });
137
168
  (0, _react.useEffect)(function () {
@@ -154,25 +185,25 @@ var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
154
185
  return;
155
186
  }
156
187
  return (0, _combine.combine)((0, _element.monitorForElements)({
157
- onDragStart: function onDragStart(_ref5) {
158
- var location = _ref5.location;
188
+ onDragStart: function onDragStart(_ref6) {
189
+ var location = _ref6.location;
159
190
  initialAutoScrollerClientY.current = location.current.input.clientY;
160
191
  _pragmaticDragAndDropAutoscroll.autoScroller.start({
161
192
  input: location.current.input,
162
193
  behavior: 'container-only'
163
194
  });
164
195
  },
165
- onDrag: function onDrag(_ref6) {
166
- var location = _ref6.location;
196
+ onDrag: function onDrag(_ref7) {
197
+ var location = _ref7.location;
167
198
  _pragmaticDragAndDropAutoscroll.autoScroller.updateInput({
168
199
  input: _objectSpread(_objectSpread({}, location.current.input), {}, {
169
200
  clientY: initialAutoScrollerClientY.current || 0
170
201
  })
171
202
  });
172
203
  },
173
- onDrop: function onDrop(_ref7) {
174
- var source = _ref7.source,
175
- location = _ref7.location;
204
+ onDrop: function onDrop(_ref8) {
205
+ var source = _ref8.source,
206
+ location = _ref8.location;
176
207
  initialAutoScrollerClientY.current = null;
177
208
  _pragmaticDragAndDropAutoscroll.autoScroller.stop();
178
209
  if (location.current.dropTargets.length === 0) {
@@ -208,9 +239,9 @@ var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
208
239
  return items.map(function (newRowData, rowIndex) {
209
240
  return {
210
241
  key: "".concat(identityColumnKey && newRowData[identityColumnKey] || rowIndex),
211
- cells: visibleSortedColumns.map(function (_ref8) {
212
- var key = _ref8.key,
213
- type = _ref8.type;
242
+ cells: visibleSortedColumns.map(function (_ref9) {
243
+ var key = _ref9.key,
244
+ type = _ref9.type;
214
245
  var value = newRowData[key];
215
246
  var values = Array.isArray(value) ? value : [value];
216
247
  var content = values.map(function (value) {
@@ -221,7 +252,8 @@ var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
221
252
  });
222
253
  return {
223
254
  key: key,
224
- content: content
255
+ content: content,
256
+ maxWidth: getColumnWidth(key, type)
225
257
  };
226
258
  }),
227
259
  ref: rowIndex === items.length - 1 ? function (el) {
@@ -243,30 +275,40 @@ var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
243
275
  return (0, _react2.jsx)("div", {
244
276
  ref: containerRef,
245
277
  css: isDragPreview ? containerDragPreviewStyles : null
246
- }, (0, _react2.jsx)("table", {
278
+ }, (0, _react2.jsx)(_styled.Table, {
247
279
  css: isDragPreview ? tableDragPreviewStyles : null,
248
280
  "data-testid": testId
249
281
  }, (0, _react2.jsx)("thead", {
250
282
  "data-testid": testId && "".concat(testId, "--head"),
251
283
  css: tableHeadStyles
252
- }, (0, _react2.jsx)("tr", null, headColumns.map(function (_ref9, cellIndex) {
253
- var key = _ref9.key,
254
- content = _ref9.content;
284
+ }, (0, _react2.jsx)("tr", null, headColumns.map(function (_ref10, cellIndex) {
285
+ var key = _ref10.key,
286
+ content = _ref10.content,
287
+ maxWidth = _ref10.maxWidth;
288
+ var TruncatedContent = function TruncatedContent() {
289
+ return (0, _react2.jsx)("div", {
290
+ css: truncatedCellStyles
291
+ }, content);
292
+ };
255
293
  if (onVisibleColumnKeysChange) {
256
294
  return (0, _react2.jsx)(_draggableTableHeading.DraggableTableHeading, {
257
295
  tableId: tableId,
258
296
  key: key,
259
297
  id: key,
260
298
  index: cellIndex,
299
+ maxWidth: maxWidth,
261
300
  dndPreviewHeight: dndPreviewHeight,
262
301
  onDragPreviewStart: setIsDragPreviewOn,
263
302
  onDragPreviewEnd: setIsDragPreviewOff
264
- }, content);
303
+ }, (0, _react2.jsx)(TruncatedContent, null));
265
304
  } else {
266
305
  return (0, _react2.jsx)(_styled.TableHeading, {
267
306
  key: key,
268
- "data-testid": "".concat(key, "-column-heading")
269
- }, content);
307
+ "data-testid": "".concat(key, "-column-heading"),
308
+ style: {
309
+ maxWidth: maxWidth
310
+ }
311
+ }, (0, _react2.jsx)(TruncatedContent, null));
270
312
  }
271
313
  }), onVisibleColumnKeysChange && (0, _react2.jsx)("th", {
272
314
  css: columnPickerHeaderStyles
@@ -276,21 +318,26 @@ var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
276
318
  onSelectedColumnKeysChange: onSelectedColumnKeysChange
277
319
  })))), (0, _react2.jsx)("tbody", {
278
320
  "data-testid": testId && "".concat(testId, "--body")
279
- }, rows.map(function (_ref10) {
280
- var key = _ref10.key,
281
- cells = _ref10.cells,
282
- ref = _ref10.ref;
321
+ }, rows.map(function (_ref11) {
322
+ var key = _ref11.key,
323
+ cells = _ref11.cells,
324
+ ref = _ref11.ref;
283
325
  return (0, _react2.jsx)("tr", {
284
326
  key: key,
285
327
  "data-testid": testId && "".concat(testId, "--row-").concat(key),
286
328
  ref: ref
287
- }, cells.map(function (_ref11, cellIndex) {
288
- var key = _ref11.key,
289
- content = _ref11.content;
329
+ }, cells.map(function (_ref12, cellIndex) {
330
+ var key = _ref12.key,
331
+ content = _ref12.content,
332
+ maxWidth = _ref12.maxWidth;
290
333
  return (0, _react2.jsx)("td", {
291
334
  key: key,
292
335
  "data-testid": testId && "".concat(testId, "--cell-").concat(cellIndex),
293
- colSpan: cellIndex + 1 === cells.length ? 2 : undefined
336
+ colSpan: cellIndex + 1 === cells.length ? 2 : undefined,
337
+ css: truncatedCellStyles,
338
+ style: {
339
+ maxWidth: maxWidth
340
+ }
294
341
  }, content);
295
342
  }));
296
343
  }))));
@@ -4,9 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.TableHeading = void 0;
7
+ exports.TableHeading = exports.Table = void 0;
8
8
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
9
  var _styled = _interopRequireDefault(require("@emotion/styled"));
10
- var _templateObject;
11
- var TableHeading = _styled.default.th(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n padding-block: ", ";\n line-height: ", ";\n"])), "var(--ds-space-100, 8px)", "var(--ds-font-lineHeight-300, 24px)");
10
+ var _templateObject, _templateObject2;
11
+ var Table = _styled.default.table(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: auto;\n"])));
12
+ exports.Table = Table;
13
+ var TableHeading = _styled.default.th(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n padding-block: ", ";\n line-height: ", ";\n"])), "var(--ds-space-100, 8px)", "var(--ds-font-lineHeight-300, 24px)");
12
14
  exports.TableHeading = TableHeading;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "0.14.4",
3
+ "version": "0.15.1",
4
4
  "sideEffects": false
5
5
  }
@@ -47,6 +47,7 @@ export const DraggableTableHeading = ({
47
47
  index,
48
48
  tableId,
49
49
  dndPreviewHeight,
50
+ maxWidth,
50
51
  onDragPreviewStart,
51
52
  onDragPreviewEnd
52
53
  }) => {
@@ -145,7 +146,10 @@ export const DraggableTableHeading = ({
145
146
  return jsx(TableHeading, {
146
147
  ref: ref,
147
148
  css: [tableHeadingStyles, tableHeadingStatusStyles[status]],
148
- "data-testid": `${id}-column-heading`
149
+ "data-testid": `${id}-column-heading`,
150
+ style: {
151
+ maxWidth
152
+ }
149
153
  }, jsx("div", {
150
154
  ref: dropTargetRef,
151
155
  css: [dropTargetStyles, isDraggingAnyColumn ? null : noPointerEventsStyles],
@@ -12,7 +12,7 @@ import { ColumnPicker } from './column-picker';
12
12
  import { DraggableTableHeading } from './draggable-table-heading';
13
13
  import TableEmptyState from './empty-state';
14
14
  import { fallbackRenderType } from './render-type';
15
- import { TableHeading } from './styled';
15
+ import { Table, TableHeading } from './styled';
16
16
  import { useIsOnScreen } from './useIsOnScreen';
17
17
  const tableHeadStyles = css({
18
18
  background: "var(--ds-surface, #FFF)",
@@ -23,6 +23,11 @@ const columnPickerHeaderStyles = css({
23
23
  // TODO use some variable for that?
24
24
  paddingBlock: "var(--ds-space-100, 8px)"
25
25
  });
26
+ const truncatedCellStyles = css({
27
+ overflow: 'hidden',
28
+ textOverflow: 'ellipsis',
29
+ whiteSpace: 'nowrap'
30
+ });
26
31
  const tableDragPreviewStyles = css({
27
32
  backgroundColor: "var(--ds-surface, #FFF)"
28
33
  });
@@ -54,6 +59,29 @@ const orderColumns = (columns, visibleColumnKeys) => {
54
59
  });
55
60
  return [...columns];
56
61
  };
62
+ const BASE_WIDTH = 8;
63
+ function getColumnWidth(key, type) {
64
+ const keyBasedWidth = {
65
+ assignee: BASE_WIDTH * 22,
66
+ key: BASE_WIDTH * 10,
67
+ labels: BASE_WIDTH * 22,
68
+ priority: BASE_WIDTH * 8,
69
+ status: BASE_WIDTH * 18,
70
+ summary: BASE_WIDTH * 45,
71
+ type: BASE_WIDTH * 8
72
+ };
73
+ if (keyBasedWidth[key]) {
74
+ return keyBasedWidth[key];
75
+ }
76
+ switch (type) {
77
+ case 'date':
78
+ return BASE_WIDTH * 14;
79
+ case 'string':
80
+ return BASE_WIDTH * 22;
81
+ default:
82
+ undefined;
83
+ }
84
+ }
57
85
  export const IssueLikeDataTableView = ({
58
86
  testId,
59
87
  onNextPage,
@@ -97,11 +125,15 @@ export const IssueLikeDataTableView = ({
97
125
  };
98
126
  })
99
127
  }), [visibleSortedColumns]);
100
- const headColumns = visibleSortedColumns.map(column => ({
101
- key: column.key,
102
- content: column.title,
103
- // width: TODO Find out how we going to retrieve column width
104
- shouldTruncate: true
128
+ const headColumns = visibleSortedColumns.map(({
129
+ key,
130
+ title,
131
+ type
132
+ }) => ({
133
+ key,
134
+ content: title,
135
+ shouldTruncate: true,
136
+ maxWidth: getColumnWidth(key, type)
105
137
  }));
106
138
  useEffect(() => {
107
139
  if (status === 'empty' || isBottomOfTableVisibleRaw && hasNextPage && status !== 'loading') {
@@ -191,7 +223,8 @@ export const IssueLikeDataTableView = ({
191
223
  }));
192
224
  return {
193
225
  key,
194
- content
226
+ content,
227
+ maxWidth: getColumnWidth(key, type)
195
228
  };
196
229
  }),
197
230
  ref: rowIndex === items.length - 1 ? el => setLastRowElement(el) : undefined
@@ -205,7 +238,7 @@ export const IssueLikeDataTableView = ({
205
238
  return jsx("div", {
206
239
  ref: containerRef,
207
240
  css: isDragPreview ? containerDragPreviewStyles : null
208
- }, jsx("table", {
241
+ }, jsx(Table, {
209
242
  css: isDragPreview ? tableDragPreviewStyles : null,
210
243
  "data-testid": testId
211
244
  }, jsx("thead", {
@@ -213,23 +246,31 @@ export const IssueLikeDataTableView = ({
213
246
  css: tableHeadStyles
214
247
  }, jsx("tr", null, headColumns.map(({
215
248
  key,
216
- content
249
+ content,
250
+ maxWidth
217
251
  }, cellIndex) => {
252
+ const TruncatedContent = () => jsx("div", {
253
+ css: truncatedCellStyles
254
+ }, content);
218
255
  if (onVisibleColumnKeysChange) {
219
256
  return jsx(DraggableTableHeading, {
220
257
  tableId: tableId,
221
258
  key: key,
222
259
  id: key,
223
260
  index: cellIndex,
261
+ maxWidth: maxWidth,
224
262
  dndPreviewHeight: dndPreviewHeight,
225
263
  onDragPreviewStart: setIsDragPreviewOn,
226
264
  onDragPreviewEnd: setIsDragPreviewOff
227
- }, content);
265
+ }, jsx(TruncatedContent, null));
228
266
  } else {
229
267
  return jsx(TableHeading, {
230
268
  key: key,
231
- "data-testid": `${key}-column-heading`
232
- }, content);
269
+ "data-testid": `${key}-column-heading`,
270
+ style: {
271
+ maxWidth
272
+ }
273
+ }, jsx(TruncatedContent, null));
233
274
  }
234
275
  }), onVisibleColumnKeysChange && jsx("th", {
235
276
  css: columnPickerHeaderStyles
@@ -249,11 +290,16 @@ export const IssueLikeDataTableView = ({
249
290
  ref: ref
250
291
  }, cells.map(({
251
292
  key,
252
- content
293
+ content,
294
+ maxWidth
253
295
  }, cellIndex) => jsx("td", {
254
296
  key: key,
255
297
  "data-testid": testId && `${testId}--cell-${cellIndex}`,
256
- colSpan: cellIndex + 1 === cells.length ? 2 : undefined
298
+ colSpan: cellIndex + 1 === cells.length ? 2 : undefined,
299
+ css: truncatedCellStyles,
300
+ style: {
301
+ maxWidth
302
+ }
257
303
  }, content)))))));
258
304
  };
259
305
  export const EmptyState = TableEmptyState;
@@ -1,4 +1,7 @@
1
1
  import styled from '@emotion/styled';
2
+ export const Table = styled.table`
3
+ width: auto;
4
+ `;
2
5
  export const TableHeading = styled.th`
3
6
  position: relative;
4
7
  padding-block: ${"var(--ds-space-100, 8px)"};
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "0.14.4",
3
+ "version": "0.15.1",
4
4
  "sideEffects": false
5
5
  }
@@ -48,6 +48,7 @@ export var DraggableTableHeading = function DraggableTableHeading(_ref) {
48
48
  index = _ref.index,
49
49
  tableId = _ref.tableId,
50
50
  dndPreviewHeight = _ref.dndPreviewHeight,
51
+ maxWidth = _ref.maxWidth,
51
52
  onDragPreviewStart = _ref.onDragPreviewStart,
52
53
  onDragPreviewEnd = _ref.onDragPreviewEnd;
53
54
  var ref = useRef(null);
@@ -152,7 +153,10 @@ export var DraggableTableHeading = function DraggableTableHeading(_ref) {
152
153
  return jsx(TableHeading, {
153
154
  ref: ref,
154
155
  css: [tableHeadingStyles, tableHeadingStatusStyles[status]],
155
- "data-testid": "".concat(id, "-column-heading")
156
+ "data-testid": "".concat(id, "-column-heading"),
157
+ style: {
158
+ maxWidth: maxWidth
159
+ }
156
160
  }, jsx("div", {
157
161
  ref: dropTargetRef,
158
162
  css: [dropTargetStyles, isDraggingAnyColumn ? null : noPointerEventsStyles],
@@ -17,7 +17,7 @@ import { ColumnPicker } from './column-picker';
17
17
  import { DraggableTableHeading } from './draggable-table-heading';
18
18
  import TableEmptyState from './empty-state';
19
19
  import { fallbackRenderType } from './render-type';
20
- import { TableHeading } from './styled';
20
+ import { Table, TableHeading } from './styled';
21
21
  import { useIsOnScreen } from './useIsOnScreen';
22
22
  var tableHeadStyles = css({
23
23
  background: "var(--ds-surface, #FFF)",
@@ -28,6 +28,11 @@ var columnPickerHeaderStyles = css({
28
28
  // TODO use some variable for that?
29
29
  paddingBlock: "var(--ds-space-100, 8px)"
30
30
  });
31
+ var truncatedCellStyles = css({
32
+ overflow: 'hidden',
33
+ textOverflow: 'ellipsis',
34
+ whiteSpace: 'nowrap'
35
+ });
31
36
  var tableDragPreviewStyles = css({
32
37
  backgroundColor: "var(--ds-surface, #FFF)"
33
38
  });
@@ -56,6 +61,29 @@ var orderColumns = function orderColumns(columns, visibleColumnKeys) {
56
61
  });
57
62
  return _toConsumableArray(columns);
58
63
  };
64
+ var BASE_WIDTH = 8;
65
+ function getColumnWidth(key, type) {
66
+ var keyBasedWidth = {
67
+ assignee: BASE_WIDTH * 22,
68
+ key: BASE_WIDTH * 10,
69
+ labels: BASE_WIDTH * 22,
70
+ priority: BASE_WIDTH * 8,
71
+ status: BASE_WIDTH * 18,
72
+ summary: BASE_WIDTH * 45,
73
+ type: BASE_WIDTH * 8
74
+ };
75
+ if (keyBasedWidth[key]) {
76
+ return keyBasedWidth[key];
77
+ }
78
+ switch (type) {
79
+ case 'date':
80
+ return BASE_WIDTH * 14;
81
+ case 'string':
82
+ return BASE_WIDTH * 22;
83
+ default:
84
+ undefined;
85
+ }
86
+ }
59
87
  export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
60
88
  var _orderedColumns$find;
61
89
  var testId = _ref2.testId,
@@ -120,12 +148,15 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
120
148
  })
121
149
  };
122
150
  }, [visibleSortedColumns]);
123
- var headColumns = visibleSortedColumns.map(function (column) {
151
+ var headColumns = visibleSortedColumns.map(function (_ref5) {
152
+ var key = _ref5.key,
153
+ title = _ref5.title,
154
+ type = _ref5.type;
124
155
  return {
125
- key: column.key,
126
- content: column.title,
127
- // width: TODO Find out how we going to retrieve column width
128
- shouldTruncate: true
156
+ key: key,
157
+ content: title,
158
+ shouldTruncate: true,
159
+ maxWidth: getColumnWidth(key, type)
129
160
  };
130
161
  });
131
162
  useEffect(function () {
@@ -148,25 +179,25 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
148
179
  return;
149
180
  }
150
181
  return combine(monitorForElements({
151
- onDragStart: function onDragStart(_ref5) {
152
- var location = _ref5.location;
182
+ onDragStart: function onDragStart(_ref6) {
183
+ var location = _ref6.location;
153
184
  initialAutoScrollerClientY.current = location.current.input.clientY;
154
185
  autoScroller.start({
155
186
  input: location.current.input,
156
187
  behavior: 'container-only'
157
188
  });
158
189
  },
159
- onDrag: function onDrag(_ref6) {
160
- var location = _ref6.location;
190
+ onDrag: function onDrag(_ref7) {
191
+ var location = _ref7.location;
161
192
  autoScroller.updateInput({
162
193
  input: _objectSpread(_objectSpread({}, location.current.input), {}, {
163
194
  clientY: initialAutoScrollerClientY.current || 0
164
195
  })
165
196
  });
166
197
  },
167
- onDrop: function onDrop(_ref7) {
168
- var source = _ref7.source,
169
- location = _ref7.location;
198
+ onDrop: function onDrop(_ref8) {
199
+ var source = _ref8.source,
200
+ location = _ref8.location;
170
201
  initialAutoScrollerClientY.current = null;
171
202
  autoScroller.stop();
172
203
  if (location.current.dropTargets.length === 0) {
@@ -202,9 +233,9 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
202
233
  return items.map(function (newRowData, rowIndex) {
203
234
  return {
204
235
  key: "".concat(identityColumnKey && newRowData[identityColumnKey] || rowIndex),
205
- cells: visibleSortedColumns.map(function (_ref8) {
206
- var key = _ref8.key,
207
- type = _ref8.type;
236
+ cells: visibleSortedColumns.map(function (_ref9) {
237
+ var key = _ref9.key,
238
+ type = _ref9.type;
208
239
  var value = newRowData[key];
209
240
  var values = Array.isArray(value) ? value : [value];
210
241
  var content = values.map(function (value) {
@@ -215,7 +246,8 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
215
246
  });
216
247
  return {
217
248
  key: key,
218
- content: content
249
+ content: content,
250
+ maxWidth: getColumnWidth(key, type)
219
251
  };
220
252
  }),
221
253
  ref: rowIndex === items.length - 1 ? function (el) {
@@ -237,30 +269,40 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
237
269
  return jsx("div", {
238
270
  ref: containerRef,
239
271
  css: isDragPreview ? containerDragPreviewStyles : null
240
- }, jsx("table", {
272
+ }, jsx(Table, {
241
273
  css: isDragPreview ? tableDragPreviewStyles : null,
242
274
  "data-testid": testId
243
275
  }, jsx("thead", {
244
276
  "data-testid": testId && "".concat(testId, "--head"),
245
277
  css: tableHeadStyles
246
- }, jsx("tr", null, headColumns.map(function (_ref9, cellIndex) {
247
- var key = _ref9.key,
248
- content = _ref9.content;
278
+ }, jsx("tr", null, headColumns.map(function (_ref10, cellIndex) {
279
+ var key = _ref10.key,
280
+ content = _ref10.content,
281
+ maxWidth = _ref10.maxWidth;
282
+ var TruncatedContent = function TruncatedContent() {
283
+ return jsx("div", {
284
+ css: truncatedCellStyles
285
+ }, content);
286
+ };
249
287
  if (onVisibleColumnKeysChange) {
250
288
  return jsx(DraggableTableHeading, {
251
289
  tableId: tableId,
252
290
  key: key,
253
291
  id: key,
254
292
  index: cellIndex,
293
+ maxWidth: maxWidth,
255
294
  dndPreviewHeight: dndPreviewHeight,
256
295
  onDragPreviewStart: setIsDragPreviewOn,
257
296
  onDragPreviewEnd: setIsDragPreviewOff
258
- }, content);
297
+ }, jsx(TruncatedContent, null));
259
298
  } else {
260
299
  return jsx(TableHeading, {
261
300
  key: key,
262
- "data-testid": "".concat(key, "-column-heading")
263
- }, content);
301
+ "data-testid": "".concat(key, "-column-heading"),
302
+ style: {
303
+ maxWidth: maxWidth
304
+ }
305
+ }, jsx(TruncatedContent, null));
264
306
  }
265
307
  }), onVisibleColumnKeysChange && jsx("th", {
266
308
  css: columnPickerHeaderStyles
@@ -270,21 +312,26 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
270
312
  onSelectedColumnKeysChange: onSelectedColumnKeysChange
271
313
  })))), jsx("tbody", {
272
314
  "data-testid": testId && "".concat(testId, "--body")
273
- }, rows.map(function (_ref10) {
274
- var key = _ref10.key,
275
- cells = _ref10.cells,
276
- ref = _ref10.ref;
315
+ }, rows.map(function (_ref11) {
316
+ var key = _ref11.key,
317
+ cells = _ref11.cells,
318
+ ref = _ref11.ref;
277
319
  return jsx("tr", {
278
320
  key: key,
279
321
  "data-testid": testId && "".concat(testId, "--row-").concat(key),
280
322
  ref: ref
281
- }, cells.map(function (_ref11, cellIndex) {
282
- var key = _ref11.key,
283
- content = _ref11.content;
323
+ }, cells.map(function (_ref12, cellIndex) {
324
+ var key = _ref12.key,
325
+ content = _ref12.content,
326
+ maxWidth = _ref12.maxWidth;
284
327
  return jsx("td", {
285
328
  key: key,
286
329
  "data-testid": testId && "".concat(testId, "--cell-").concat(cellIndex),
287
- colSpan: cellIndex + 1 === cells.length ? 2 : undefined
330
+ colSpan: cellIndex + 1 === cells.length ? 2 : undefined,
331
+ css: truncatedCellStyles,
332
+ style: {
333
+ maxWidth: maxWidth
334
+ }
288
335
  }, content);
289
336
  }));
290
337
  }))));