@atlaskit/link-datasource 2.3.1 → 2.3.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 (29) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/ui/issue-like-table/draggable-table-heading.js +12 -5
  3. package/dist/cjs/ui/issue-like-table/index.js +86 -48
  4. package/dist/cjs/ui/issue-like-table/render-type/richtext/index.js +2 -3
  5. package/dist/cjs/ui/issue-like-table/styled.js +11 -0
  6. package/dist/cjs/ui/issue-like-table/utils.js +13 -6
  7. package/dist/es2019/ui/issue-like-table/draggable-table-heading.js +12 -5
  8. package/dist/es2019/ui/issue-like-table/index.js +50 -17
  9. package/dist/es2019/ui/issue-like-table/render-type/richtext/index.js +2 -3
  10. package/dist/es2019/ui/issue-like-table/styled.js +11 -0
  11. package/dist/es2019/ui/issue-like-table/utils.js +14 -5
  12. package/dist/esm/ui/issue-like-table/draggable-table-heading.js +12 -5
  13. package/dist/esm/ui/issue-like-table/index.js +86 -48
  14. package/dist/esm/ui/issue-like-table/render-type/richtext/index.js +2 -3
  15. package/dist/esm/ui/issue-like-table/styled.js +11 -0
  16. package/dist/esm/ui/issue-like-table/utils.js +13 -6
  17. package/dist/types/common/utils/adf.d.ts +1 -1
  18. package/dist/types/ui/datasource-table-view/datasourceTableView.d.ts +0 -1
  19. package/dist/types/ui/datasource-table-view/types.d.ts +1 -2
  20. package/dist/types/ui/issue-like-table/draggable-table-heading.d.ts +2 -2
  21. package/dist/types/ui/issue-like-table/index.d.ts +1 -1
  22. package/dist/types/ui/issue-like-table/utils.d.ts +2 -2
  23. package/dist/types-ts4.5/common/utils/adf.d.ts +1 -1
  24. package/dist/types-ts4.5/ui/datasource-table-view/datasourceTableView.d.ts +0 -1
  25. package/dist/types-ts4.5/ui/datasource-table-view/types.d.ts +1 -2
  26. package/dist/types-ts4.5/ui/issue-like-table/draggable-table-heading.d.ts +2 -2
  27. package/dist/types-ts4.5/ui/issue-like-table/index.d.ts +1 -1
  28. package/dist/types-ts4.5/ui/issue-like-table/utils.d.ts +2 -2
  29. package/package.json +12 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/link-datasource
2
2
 
3
+ ## 2.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#97435](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97435)
8
+ [`74d425408d1e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/74d425408d1e) -
9
+ [ux] Fix a bug where when sum of all column widths is less than container total width the
10
+ resizing is somewhat broken
11
+ - [#99133](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99133)
12
+ [`2de9d30e7ac6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2de9d30e7ac6) -
13
+ Updates docs to include in atlaskit for use of smart link list view and configuration modals and
14
+ respective props and examples.
15
+ - Updated dependencies
16
+
3
17
  ## 2.3.1
4
18
 
5
19
  ### Patch Changes
@@ -124,6 +124,11 @@ var DraggableTableHeading = exports.DraggableTableHeading = function DraggableTa
124
124
  closestEdge = _useState6[0],
125
125
  setClosestEdge = _useState6[1];
126
126
  var dropTargetRef = (0, _react.useRef)(null);
127
+ /**
128
+ * When width is not set (or callback is not set) we assume not resizing is needed.
129
+ * In our case width won't be set for last cell when table container is bigger than sum of all columns
130
+ */
131
+ var resizeIsEnabled = !!onWidthChange && !!width;
127
132
  (0, _react.useEffect)(function () {
128
133
  var cell = mainHeaderCellRef.current;
129
134
  (0, _tinyInvariant.default)(cell);
@@ -231,7 +236,7 @@ var DraggableTableHeading = exports.DraggableTableHeading = function DraggableTa
231
236
 
232
237
  // Handling column resizing
233
238
  (0, _react.useEffect)(function () {
234
- if (!onWidthChange) {
239
+ if (!resizeIsEnabled) {
235
240
  return;
236
241
  }
237
242
  var resizeHandle = columnResizeHandleRef.current;
@@ -287,7 +292,7 @@ var DraggableTableHeading = exports.DraggableTableHeading = function DraggableTa
287
292
  }
288
293
  }
289
294
  });
290
- }, [id, index, onWidthChange, state, tableId, width]);
295
+ }, [id, index, onWidthChange, resizeIsEnabled, state, tableId, width]);
291
296
  var _useState7 = (0, _react.useState)(false),
292
297
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
293
298
  buttonHovered = _useState8[0],
@@ -296,7 +301,9 @@ var DraggableTableHeading = exports.DraggableTableHeading = function DraggableTa
296
301
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
297
302
  isDropdownOpen = _useState10[0],
298
303
  setIsDropdownOpen = _useState10[1];
299
- var isWideEnoughToHaveChevron = width > 76;
304
+ // Width is not set when it is a last cell in a wide table.
305
+ // We make assumption thus that there is enough width for chevron.
306
+ var isWideEnoughToHaveChevron = !width || width > 76;
300
307
  var shouldShowTriggerIcon = (buttonHovered || isDropdownOpen) && isWideEnoughToHaveChevron;
301
308
  var triggerIcon = (0, _react.useMemo)(function () {
302
309
  return shouldShowTriggerIcon ? isDropdownOpen ? _chevronUp.default : _chevronDown.default : isWideEnoughToHaveChevron ? _customIcons.GlyphPlaceholder : undefined;
@@ -332,10 +339,10 @@ var DraggableTableHeading = exports.DraggableTableHeading = function DraggableTa
332
339
  style: _objectSpread({
333
340
  cursor: 'grab'
334
341
  }, (0, _utils.getWidthCss)({
335
- shouldUseWidth: !!onWidthChange,
342
+ shouldUseWidth: resizeIsEnabled,
336
343
  width: width
337
344
  }))
338
- }, onWidthChange ? (0, _react2.jsx)("div", {
345
+ }, resizeIsEnabled ? (0, _react2.jsx)("div", {
339
346
  ref: columnResizeHandleRef,
340
347
  css: [resizerStyles, state.type === 'resizing' && resizingStyles],
341
348
  style: {
@@ -14,6 +14,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
14
14
  var _react = require("react");
15
15
  var _react2 = require("@emotion/react");
16
16
  var _styled = _interopRequireDefault(require("@emotion/styled"));
17
+ var _debounce = _interopRequireDefault(require("lodash/debounce"));
17
18
  var _reactIntlNext = require("react-intl-next");
18
19
  var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
19
20
  var _linkingCommon = require("@atlaskit/linking-common");
@@ -25,6 +26,7 @@ var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
25
26
  var _colors = require("@atlaskit/theme/colors");
26
27
  var _typography = require("@atlaskit/theme/typography");
27
28
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
29
+ var _widthDetector = require("@atlaskit/width-detector");
28
30
  var _ufoExperiences = require("../../analytics/ufoExperiences");
29
31
  var _zindex = require("../../common/zindex");
30
32
  var _columnPicker = require("./column-picker");
@@ -35,7 +37,7 @@ var _renderType = require("./render-type");
35
37
  var _styled2 = require("./styled");
36
38
  var _useIsOnScreen = require("./useIsOnScreen");
37
39
  var _utils = require("./utils");
38
- var _styled$th, _styled$td;
40
+ var _styled$td;
39
41
  /** @jsx jsx */
40
42
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
41
43
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -51,27 +53,30 @@ var truncateTextStyles = (0, _react2.css)({
51
53
  textOverflow: 'ellipsis',
52
54
  whiteSpace: 'nowrap'
53
55
  });
54
- var ColumnPickerHeader = _styled.default.th((_styled$th = {}, (0, _defineProperty2.default)(_styled$th, "".concat((0, _styled2.withTablePluginHeaderPrefix)()), {
55
- boxSizing: 'content-box',
56
+ var columnPickerWidth = 80;
57
+ var ColumnPickerHeader = _styled.default.th((0, _defineProperty2.default)({}, "".concat((0, _styled2.withTablePluginHeaderPrefix)('&:last-of-type')), {
58
+ boxSizing: 'border-box',
56
59
  border: 0,
57
- width: '56px',
60
+ width: "".concat(columnPickerWidth, "px"),
58
61
  zIndex: 10,
59
62
  position: 'sticky',
60
63
  right: "calc(-1 * ".concat(tableSidePadding, ")"),
61
64
  backgroundColor: "var(--ds-elevation-surface-current, #FFF)",
65
+ /* It is required to have solid (not half-transparent) color because of this gradient business below */
62
66
  borderBottom: "2px solid ".concat("var(--ds-border, ".concat(_colors.N40, ")")),
63
- paddingRight: "var(--ds-space-100, 4px)",
67
+ paddingRight: tableSidePadding,
64
68
  background: "linear-gradient( 90deg, rgba(255, 255, 255, 0) 0%, ".concat("var(--ds-elevation-surface-current, #FFF)", " 10% )"),
69
+ /* Keeps dropdown button in the middle */
65
70
  verticalAlign: 'middle',
71
+ /* In case when TH itself is bigger we want to keep picker at the right side */
66
72
  textAlign: 'right'
67
- }), (0, _defineProperty2.default)(_styled$th, "".concat((0, _styled2.withTablePluginHeaderPrefix)('&:last-of-type')), {
68
- paddingRight: tableSidePadding
69
- }), _styled$th));
73
+ }));
70
74
  var truncateStyles = (0, _react2.css)({
71
75
  textOverflow: 'ellipsis',
72
76
  whiteSpace: 'nowrap'
73
77
  });
74
78
  var TableCell = _styled.default.td((_styled$td = {}, (0, _defineProperty2.default)(_styled$td, "".concat((0, _styled2.withTablePluginBodyPrefix)()), {
79
+ /* First section here is to override things editor table plugin css defines */
75
80
  font: _styled2.fieldTextFontSize,
76
81
  padding: "var(--ds-space-050, 4px)".concat(" ", "var(--ds-space-100, 8px)"),
77
82
  border: 0,
@@ -92,7 +97,8 @@ var TableCell = _styled.default.td((_styled$td = {}, (0, _defineProperty2.defaul
92
97
  var tableContainerStyles = (0, _react2.css)({
93
98
  borderRadius: 'inherit',
94
99
  borderBottomLeftRadius: 0,
95
- borderBottomRightRadius: 0
100
+ borderBottomRightRadius: 0,
101
+ position: 'relative'
96
102
  });
97
103
 
98
104
  /**
@@ -189,7 +195,10 @@ var tableStyles = (0, _react2.css)({
189
195
  // These styles are needed to prevent thead bottom border from scrolling away.
190
196
  // This happens because it is sticky. https://stackoverflow.com/questions/50361698/border-style-do-not-work-with-sticky-position-element
191
197
  borderCollapse: 'separate',
192
- borderSpacing: 0
198
+ borderSpacing: 0,
199
+ // There is a strange table:first-of-type rule that sets margin-top to 0 coming from container,
200
+ // but because our table is now not the first child (there is an empty div to measure width) we need to set it manually.
201
+ margin: 0
193
202
  });
194
203
 
195
204
  // By default tbody and thead have border-bottom: 2px ...
@@ -301,6 +310,19 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
301
310
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
302
311
  orderedColumns = _useState6[0],
303
312
  setOrderedColumns = _useState6[1];
313
+
314
+ // Table container width is used to know if sum of all column widths is bigger of container or not.
315
+ // When sum of all columns is less than container size we make last column stretchable (width: undefined)
316
+ var _useState7 = (0, _react.useState)(),
317
+ _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
318
+ tableContainerWidth = _useState8[0],
319
+ setTableContainerWidth = _useState8[1];
320
+ (0, _react.useEffect)(function () {
321
+ var current = containerRef.current;
322
+ if (containerRef && current) {
323
+ setTableContainerWidth(current.getBoundingClientRect().width);
324
+ }
325
+ }, [containerRef]);
304
326
  (0, _react.useEffect)(function () {
305
327
  if (!hasFullSchema) {
306
328
  setOrderedColumns(getOrderedColumns((0, _toConsumableArray2.default)(columns), (0, _toConsumableArray2.default)(visibleColumnKeys)));
@@ -327,19 +349,33 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
327
349
  // or some other combination.
328
350
 
329
351
  var identityColumnKey = 'id';
330
- var getColumnWidth = (0, _react.useCallback)(function (key, type) {
331
- return (columnCustomSizes === null || columnCustomSizes === void 0 ? void 0 : columnCustomSizes[key]) || getDefaultColumnWidth(key, type);
332
- }, [columnCustomSizes]);
333
- var headerColumns = (0, _react.useMemo)(function () {
352
+ var columnsWidthsSum = (0, _react.useMemo)(function () {
334
353
  return visibleSortedColumns.map(function (_ref7) {
335
354
  var key = _ref7.key,
336
- title = _ref7.title,
337
355
  type = _ref7.type;
356
+ return (columnCustomSizes === null || columnCustomSizes === void 0 ? void 0 : columnCustomSizes[key]) || getDefaultColumnWidth(key, type);
357
+ }).reduce(function (sum, width) {
358
+ return width + sum;
359
+ }, 0) + (onVisibleColumnKeysChange ? columnPickerWidth : 0);
360
+ }, [columnCustomSizes, onVisibleColumnKeysChange, visibleSortedColumns]);
361
+ var shouldUseWidth = !!(onColumnResize || columnCustomSizes);
362
+ var getColumnWidth = (0, _react.useCallback)(function (key, type, isLastCell) {
363
+ if (isLastCell && shouldUseWidth && (!tableContainerWidth || tableContainerWidth > columnsWidthsSum)) {
364
+ return undefined;
365
+ } else {
366
+ return (columnCustomSizes === null || columnCustomSizes === void 0 ? void 0 : columnCustomSizes[key]) || getDefaultColumnWidth(key, type);
367
+ }
368
+ }, [columnCustomSizes, columnsWidthsSum, shouldUseWidth, tableContainerWidth]);
369
+ var headerColumns = (0, _react.useMemo)(function () {
370
+ return visibleSortedColumns.map(function (_ref8, index) {
371
+ var key = _ref8.key,
372
+ title = _ref8.title,
373
+ type = _ref8.type;
338
374
  return {
339
375
  key: key,
340
376
  content: title,
341
377
  shouldTruncate: true,
342
- width: getColumnWidth(key, type)
378
+ width: getColumnWidth(key, type, index === visibleSortedColumns.length - 1)
343
379
  };
344
380
  });
345
381
  }, [getColumnWidth, visibleSortedColumns]);
@@ -376,9 +412,9 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
376
412
  return;
377
413
  }
378
414
  return (0, _combine.combine)((0, _adapter.monitorForElements)({
379
- onDragStart: function onDragStart(_ref8) {
380
- var location = _ref8.location,
381
- source = _ref8.source;
415
+ onDragStart: function onDragStart(_ref9) {
416
+ var location = _ref9.location,
417
+ source = _ref9.source;
382
418
  initialAutoScrollerClientY.current = location.current.input.clientY;
383
419
  if (source.data.type === 'table-header') {
384
420
  var _containerRef$current;
@@ -394,9 +430,9 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
394
430
  });
395
431
  }
396
432
  },
397
- onDrag: function onDrag(_ref9) {
398
- var location = _ref9.location,
399
- source = _ref9.source;
433
+ onDrag: function onDrag(_ref10) {
434
+ var location = _ref10.location,
435
+ source = _ref10.source;
400
436
  if (source.data.type === 'table-header') {
401
437
  var _containerRef$current2;
402
438
  _pragmaticDragAndDropReactBeautifulDndAutoscroll.autoScroller.updateInput({
@@ -406,9 +442,9 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
406
442
  });
407
443
  }
408
444
  },
409
- onDrop: function onDrop(_ref10) {
410
- var source = _ref10.source,
411
- location = _ref10.location;
445
+ onDrop: function onDrop(_ref11) {
446
+ var source = _ref11.source,
447
+ location = _ref11.location;
412
448
  _pragmaticDragAndDropReactBeautifulDndAutoscroll.autoScroller.stop();
413
449
  if (location.current.dropTargets.length === 0) {
414
450
  return;
@@ -443,10 +479,10 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
443
479
  return items.map(function (newRowData, rowIndex) {
444
480
  return {
445
481
  key: "".concat(identityColumnKey && newRowData[identityColumnKey] && newRowData[identityColumnKey].data || rowIndex),
446
- cells: visibleSortedColumns.map(function (_ref11) {
482
+ cells: visibleSortedColumns.map(function (_ref12, cellIndex) {
447
483
  var _newRowData$key;
448
- var key = _ref11.key,
449
- type = _ref11.type;
484
+ var key = _ref12.key,
485
+ type = _ref12.type;
450
486
  // Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
451
487
  var value = (_newRowData$key = newRowData[key]) === null || _newRowData$key === void 0 ? void 0 : _newRowData$key.data;
452
488
  var values = Array.isArray(value) ? value : [value];
@@ -470,7 +506,7 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
470
506
  return {
471
507
  key: key,
472
508
  content: contentComponent,
473
- width: getColumnWidth(key, type)
509
+ width: getColumnWidth(key, type, cellIndex === visibleSortedColumns.length - 1)
474
510
  };
475
511
  }),
476
512
  ref: rowIndex === items.length - 1 ? function (el) {
@@ -536,7 +572,6 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
536
572
  }
537
573
  }, _callee, null, [[3, 9]]);
538
574
  })), [parentContainerRenderInstanceId, extensionKey, hasFullSchema, onLoadDatasourceDetails]);
539
- var shouldUseWidth = !!(onColumnResize || columnCustomSizes);
540
575
  var isEditable = onVisibleColumnKeysChange && hasData;
541
576
  return (0, _react2.jsx)("div", {
542
577
  /* There is required contentEditable={true} in editor-card-plugin
@@ -548,8 +583,11 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
548
583
  css: [tableContainerStyles, scrollableContainerHeight && scrollableContainerStyles],
549
584
  style: scrollableContainerHeight ? {
550
585
  maxHeight: "".concat(scrollableContainerHeight, "px")
551
- } : undefined
552
- }, (0, _react2.jsx)(_styled2.Table, {
586
+ } : undefined,
587
+ "data-testid": 'issue-like-table-container'
588
+ }, (0, _react2.jsx)(_widthDetector.WidthObserver, {
589
+ setWidth: (0, _debounce.default)(setTableContainerWidth, 100)
590
+ }), (0, _react2.jsx)(_styled2.Table, {
553
591
  css: tableStyles,
554
592
  "data-testid": testId,
555
593
  style: shouldUseWidth ? {
@@ -561,10 +599,10 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
561
599
  className: !!onVisibleColumnKeysChange ? 'has-column-picker' : ''
562
600
  }, (0, _react2.jsx)("tr", {
563
601
  ref: tableHeaderRowRef
564
- }, headerColumns.map(function (_ref13, cellIndex) {
565
- var key = _ref13.key,
566
- content = _ref13.content,
567
- width = _ref13.width;
602
+ }, headerColumns.map(function (_ref14, cellIndex) {
603
+ var key = _ref14.key,
604
+ content = _ref14.content,
605
+ width = _ref14.width;
568
606
  var heading = (0, _react2.jsx)(_tooltip.default, {
569
607
  content: content,
570
608
  tag: "span",
@@ -581,10 +619,10 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
581
619
  }
582
620
  if (isEditable) {
583
621
  var _containerRef$current3;
584
- var previewRows = tableRows.map(function (_ref14) {
585
- var cells = _ref14.cells;
586
- var cell = cells.find(function (_ref15) {
587
- var cellKey = _ref15.key;
622
+ var previewRows = tableRows.map(function (_ref15) {
623
+ var cells = _ref15.cells;
624
+ var cell = cells.find(function (_ref16) {
625
+ var cellKey = _ref16.key;
588
626
  return cellKey === key;
589
627
  });
590
628
  if (cell) {
@@ -626,18 +664,18 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
626
664
  })))), (0, _react2.jsx)("tbody", {
627
665
  css: noDefaultBorderStyles,
628
666
  "data-testid": testId && "".concat(testId, "--body")
629
- }, rows.map(function (_ref16) {
630
- var key = _ref16.key,
631
- cells = _ref16.cells,
632
- ref = _ref16.ref;
667
+ }, rows.map(function (_ref17) {
668
+ var key = _ref17.key,
669
+ cells = _ref17.cells,
670
+ ref = _ref17.ref;
633
671
  return (0, _react2.jsx)("tr", {
634
672
  key: key,
635
673
  "data-testid": testId && "".concat(testId, "--row-").concat(key),
636
674
  ref: ref
637
- }, cells.map(function (_ref17, cellIndex) {
638
- var cellKey = _ref17.key,
639
- content = _ref17.content,
640
- width = _ref17.width;
675
+ }, cells.map(function (_ref18, cellIndex) {
676
+ var cellKey = _ref18.key,
677
+ content = _ref18.content,
678
+ width = _ref18.width;
641
679
  var isLastCell = cellIndex === cells.length - 1;
642
680
  var loadingRowStyle = (0, _utils.getWidthCss)({
643
681
  shouldUseWidth: shouldUseWidth,
@@ -14,8 +14,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
14
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** @jsx jsx */
16
16
  var rootStyles = (0, _react2.css)({
17
- position: 'relative',
18
- display: 'block'
17
+ position: 'relative'
19
18
  });
20
19
  var smartLinkNodeToUrl = function smartLinkNodeToUrl(node) {
21
20
  var _node$attrs$url;
@@ -52,7 +51,7 @@ var RichTextType = function RichTextType(_ref) {
52
51
  return parseRichText(value);
53
52
  }, [value]);
54
53
  if (adfPlainText) {
55
- return (0, _react2.jsx)("div", {
54
+ return (0, _react2.jsx)("span", {
56
55
  css: rootStyles,
57
56
  "data-testid": "richtext-plaintext"
58
57
  }, adfPlainText);
@@ -33,11 +33,19 @@ var withTablePluginBodyPrefix = exports.withTablePluginBodyPrefix = withTablePlu
33
33
  var TableHeading = exports.TableHeading = _styled.default.th((_styled$th = {}, (0, _defineProperty2.default)(_styled$th, "".concat(withTablePluginHeaderPrefix()), {
34
34
  border: 0,
35
35
  position: 'relative',
36
+ /* This makes resizing work with out jumping due to padding + changes overall width for same default values. */
36
37
  boxSizing: 'border-box',
37
38
  lineHeight: lineHeight,
38
39
  padding: "".concat(verticalPadding, " ", "var(--ds-space-050, 4px)"),
39
40
  borderRight: "0.5px solid ".concat("var(--ds-border, ".concat(_colors.N40, ")")),
40
41
  borderBottom: "2px solid ".concat("var(--ds-border, ".concat(_colors.N40, ")")),
42
+ /*
43
+ lineHeight * 2 -> Max height of two lined header
44
+ verticalPadding * 2 -> padding for this component itself
45
+ verticalPadding * 2 -> padding inside span (--container)
46
+ 2px -> Bottom border
47
+ Last two terms are needed because of border-box box sizing.
48
+ */
41
49
  height: "calc(".concat(lineHeight, " * 2 + ").concat(verticalPadding, " * 4 + 2px)"),
42
50
  verticalAlign: 'bottom',
43
51
  backgroundColor: "var(--ds-elevation-surface-current, #FFF)"
@@ -49,6 +57,9 @@ var TableHeading = exports.TableHeading = _styled.default.th((_styled$th = {}, (
49
57
  borderRight: 0
50
58
  }), (0, _defineProperty2.default)(_styled$th, "& [data-testid='datasource-header-content--container']", {
51
59
  width: '100%',
60
+ /* With Button now being a parent for this component it adds its lineHeight value and spoils
61
+ `height` calculation above. */
62
+ lineHeight: lineHeight,
52
63
  padding: "".concat(verticalPadding, " ", "var(--ds-space-050, 4px)"),
53
64
  display: '-webkit-box',
54
65
  WebkitLineClamp: 2,
@@ -14,16 +14,23 @@ var COLUMN_MIN_WIDTH = exports.COLUMN_MIN_WIDTH = COLUMN_BASE_WIDTH * 3;
14
14
  * or rather default width that should be treated as a maximum width. When table inserted initially
15
15
  * and no user custom width defined we set this value to `false`. As soon as user changes any of the
16
16
  * column widths we treat all width as custom hardcoded widths.
17
- * @param width
17
+ * @param width Sometimes set to undefined for last column to make it occupy remainder of the table width
18
18
  */
19
19
  var getWidthCss = exports.getWidthCss = function getWidthCss(_ref) {
20
20
  var shouldUseWidth = _ref.shouldUseWidth,
21
21
  width = _ref.width;
22
- return shouldUseWidth ? {
23
- width: width
24
- } : {
25
- maxWidth: width
26
- };
22
+ if (!width) {
23
+ return {};
24
+ }
25
+ if (shouldUseWidth) {
26
+ return {
27
+ width: width
28
+ };
29
+ } else {
30
+ return {
31
+ maxWidth: width
32
+ };
33
+ }
27
34
  };
28
35
 
29
36
  /**
@@ -100,6 +100,11 @@ export const DraggableTableHeading = ({
100
100
  const [isDraggingAnyColumn, setIsDraggingAnyColumn] = useState(false);
101
101
  const [closestEdge, setClosestEdge] = useState(null);
102
102
  const dropTargetRef = useRef(null);
103
+ /**
104
+ * When width is not set (or callback is not set) we assume not resizing is needed.
105
+ * In our case width won't be set for last cell when table container is bigger than sum of all columns
106
+ */
107
+ const resizeIsEnabled = !!onWidthChange && !!width;
103
108
  useEffect(() => {
104
109
  const cell = mainHeaderCellRef.current;
105
110
  invariant(cell);
@@ -209,7 +214,7 @@ export const DraggableTableHeading = ({
209
214
 
210
215
  // Handling column resizing
211
216
  useEffect(() => {
212
- if (!onWidthChange) {
217
+ if (!resizeIsEnabled) {
213
218
  return;
214
219
  }
215
220
  const resizeHandle = columnResizeHandleRef.current;
@@ -269,10 +274,12 @@ export const DraggableTableHeading = ({
269
274
  }
270
275
  }
271
276
  });
272
- }, [id, index, onWidthChange, state, tableId, width]);
277
+ }, [id, index, onWidthChange, resizeIsEnabled, state, tableId, width]);
273
278
  const [buttonHovered, setButtonHovered] = useState(false);
274
279
  const [isDropdownOpen, setIsDropdownOpen] = useState(false);
275
- const isWideEnoughToHaveChevron = width > 76;
280
+ // Width is not set when it is a last cell in a wide table.
281
+ // We make assumption thus that there is enough width for chevron.
282
+ const isWideEnoughToHaveChevron = !width || width > 76;
276
283
  const shouldShowTriggerIcon = (buttonHovered || isDropdownOpen) && isWideEnoughToHaveChevron;
277
284
  const triggerIcon = useMemo(() => shouldShowTriggerIcon ? isDropdownOpen ? ChevronUp : ChevronDown : isWideEnoughToHaveChevron ? GlyphPlaceholder : undefined, [shouldShowTriggerIcon, isDropdownOpen, isWideEnoughToHaveChevron]);
278
285
  const getTriggerButton = useCallback(({
@@ -300,11 +307,11 @@ export const DraggableTableHeading = ({
300
307
  style: {
301
308
  cursor: 'grab',
302
309
  ...getWidthCss({
303
- shouldUseWidth: !!onWidthChange,
310
+ shouldUseWidth: resizeIsEnabled,
304
311
  width
305
312
  })
306
313
  }
307
- }, onWidthChange ? jsx("div", {
314
+ }, resizeIsEnabled ? jsx("div", {
308
315
  ref: columnResizeHandleRef,
309
316
  css: [resizerStyles, state.type === 'resizing' && resizingStyles],
310
317
  style: {
@@ -3,6 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import styled from '@emotion/styled';
6
+ import debounce from 'lodash/debounce';
6
7
  import { useIntl } from 'react-intl-next';
7
8
  import invariant from 'tiny-invariant';
8
9
  import { Skeleton } from '@atlaskit/linking-common';
@@ -14,6 +15,7 @@ import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/ad
14
15
  import { N40 } from '@atlaskit/theme/colors';
15
16
  import { fontFallback } from '@atlaskit/theme/typography';
16
17
  import Tooltip from '@atlaskit/tooltip';
18
+ import { WidthObserver } from '@atlaskit/width-detector';
17
19
  import { startUfoExperience, succeedUfoExperience } from '../../analytics/ufoExperiences';
18
20
  import { stickyTableHeadersIndex } from '../../common/zindex';
19
21
  import { ColumnPicker } from './column-picker';
@@ -36,23 +38,24 @@ const truncateTextStyles = css({
36
38
  textOverflow: 'ellipsis',
37
39
  whiteSpace: 'nowrap'
38
40
  });
41
+ const columnPickerWidth = 80;
39
42
  const ColumnPickerHeader = styled.th({
40
- [`${withTablePluginHeaderPrefix()}`]: {
41
- boxSizing: 'content-box',
43
+ [`${withTablePluginHeaderPrefix('&:last-of-type')}`]: {
44
+ boxSizing: 'border-box',
42
45
  border: 0,
43
- width: '56px',
46
+ width: `${columnPickerWidth}px`,
44
47
  zIndex: 10,
45
48
  position: 'sticky',
46
49
  right: `calc(-1 * ${tableSidePadding})`,
47
50
  backgroundColor: "var(--ds-elevation-surface-current, #FFF)",
51
+ /* It is required to have solid (not half-transparent) color because of this gradient business below */
48
52
  borderBottom: `2px solid ${`var(--ds-border, ${N40})`}`,
49
- paddingRight: "var(--ds-space-100, 4px)",
53
+ paddingRight: tableSidePadding,
50
54
  background: `linear-gradient( 90deg, rgba(255, 255, 255, 0) 0%, ${"var(--ds-elevation-surface-current, #FFF)"} 10% )`,
55
+ /* Keeps dropdown button in the middle */
51
56
  verticalAlign: 'middle',
57
+ /* In case when TH itself is bigger we want to keep picker at the right side */
52
58
  textAlign: 'right'
53
- },
54
- [`${withTablePluginHeaderPrefix('&:last-of-type')}`]: {
55
- paddingRight: tableSidePadding
56
59
  }
57
60
  });
58
61
  const truncateStyles = css({
@@ -61,6 +64,7 @@ const truncateStyles = css({
61
64
  });
62
65
  const TableCell = styled.td({
63
66
  [`${withTablePluginBodyPrefix()}`]: {
67
+ /* First section here is to override things editor table plugin css defines */
64
68
  font: fieldTextFontSize,
65
69
  padding: `${"var(--ds-space-050, 4px)"} ${"var(--ds-space-100, 8px)"}`,
66
70
  border: 0,
@@ -87,7 +91,8 @@ const TableCell = styled.td({
87
91
  const tableContainerStyles = css({
88
92
  borderRadius: 'inherit',
89
93
  borderBottomLeftRadius: 0,
90
- borderBottomRightRadius: 0
94
+ borderBottomRightRadius: 0,
95
+ position: 'relative'
91
96
  });
92
97
 
93
98
  /**
@@ -220,7 +225,10 @@ const tableStyles = css({
220
225
  // These styles are needed to prevent thead bottom border from scrolling away.
221
226
  // This happens because it is sticky. https://stackoverflow.com/questions/50361698/border-style-do-not-work-with-sticky-position-element
222
227
  borderCollapse: 'separate',
223
- borderSpacing: 0
228
+ borderSpacing: 0,
229
+ // There is a strange table:first-of-type rule that sets margin-top to 0 coming from container,
230
+ // but because our table is now not the first child (there is an empty div to measure width) we need to set it manually.
231
+ margin: 0
224
232
  });
225
233
 
226
234
  // By default tbody and thead have border-bottom: 2px ...
@@ -317,6 +325,18 @@ export const IssueLikeDataTableView = ({
317
325
  const isBottomOfTableVisibleRaw = useIsOnScreen(lastRowElement);
318
326
  const containerRef = useRef(null);
319
327
  const [orderedColumns, setOrderedColumns] = useState(() => getOrderedColumns([...columns], [...visibleColumnKeys]));
328
+
329
+ // Table container width is used to know if sum of all column widths is bigger of container or not.
330
+ // When sum of all columns is less than container size we make last column stretchable (width: undefined)
331
+ const [tableContainerWidth, setTableContainerWidth] = useState();
332
+ useEffect(() => {
333
+ const {
334
+ current
335
+ } = containerRef;
336
+ if (containerRef && current) {
337
+ setTableContainerWidth(current.getBoundingClientRect().width);
338
+ }
339
+ }, [containerRef]);
320
340
  useEffect(() => {
321
341
  if (!hasFullSchema) {
322
342
  setOrderedColumns(getOrderedColumns([...columns], [...visibleColumnKeys]));
@@ -338,16 +358,27 @@ export const IssueLikeDataTableView = ({
338
358
  // or some other combination.
339
359
 
340
360
  const identityColumnKey = 'id';
341
- const getColumnWidth = useCallback((key, type) => (columnCustomSizes === null || columnCustomSizes === void 0 ? void 0 : columnCustomSizes[key]) || getDefaultColumnWidth(key, type), [columnCustomSizes]);
361
+ const columnsWidthsSum = useMemo(() => visibleSortedColumns.map(({
362
+ key,
363
+ type
364
+ }) => (columnCustomSizes === null || columnCustomSizes === void 0 ? void 0 : columnCustomSizes[key]) || getDefaultColumnWidth(key, type)).reduce((sum, width) => width + sum, 0) + (onVisibleColumnKeysChange ? columnPickerWidth : 0), [columnCustomSizes, onVisibleColumnKeysChange, visibleSortedColumns]);
365
+ const shouldUseWidth = !!(onColumnResize || columnCustomSizes);
366
+ const getColumnWidth = useCallback((key, type, isLastCell) => {
367
+ if (isLastCell && shouldUseWidth && (!tableContainerWidth || tableContainerWidth > columnsWidthsSum)) {
368
+ return undefined;
369
+ } else {
370
+ return (columnCustomSizes === null || columnCustomSizes === void 0 ? void 0 : columnCustomSizes[key]) || getDefaultColumnWidth(key, type);
371
+ }
372
+ }, [columnCustomSizes, columnsWidthsSum, shouldUseWidth, tableContainerWidth]);
342
373
  const headerColumns = useMemo(() => visibleSortedColumns.map(({
343
374
  key,
344
375
  title,
345
376
  type
346
- }) => ({
377
+ }, index) => ({
347
378
  key,
348
379
  content: title,
349
380
  shouldTruncate: true,
350
- width: getColumnWidth(key, type)
381
+ width: getColumnWidth(key, type, index === visibleSortedColumns.length - 1)
351
382
  })), [getColumnWidth, visibleSortedColumns]);
352
383
  const loadingRow = useMemo(() => ({
353
384
  key: 'loading',
@@ -450,7 +481,7 @@ export const IssueLikeDataTableView = ({
450
481
  cells: visibleSortedColumns.map(({
451
482
  key,
452
483
  type
453
- }) => {
484
+ }, cellIndex) => {
454
485
  var _newRowData$key;
455
486
  // Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
456
487
  const value = (_newRowData$key = newRowData[key]) === null || _newRowData$key === void 0 ? void 0 : _newRowData$key.data;
@@ -471,7 +502,7 @@ export const IssueLikeDataTableView = ({
471
502
  return {
472
503
  key,
473
504
  content: contentComponent,
474
- width: getColumnWidth(key, type)
505
+ width: getColumnWidth(key, type, cellIndex === visibleSortedColumns.length - 1)
475
506
  };
476
507
  }),
477
508
  ref: rowIndex === items.length - 1 ? el => setLastRowElement(el) : undefined
@@ -517,7 +548,6 @@ export const IssueLikeDataTableView = ({
517
548
  setHasFullSchema(false);
518
549
  }
519
550
  }, [parentContainerRenderInstanceId, extensionKey, hasFullSchema, onLoadDatasourceDetails]);
520
- const shouldUseWidth = !!(onColumnResize || columnCustomSizes);
521
551
  const isEditable = onVisibleColumnKeysChange && hasData;
522
552
  return jsx("div", {
523
553
  /* There is required contentEditable={true} in editor-card-plugin
@@ -529,8 +559,11 @@ export const IssueLikeDataTableView = ({
529
559
  css: [tableContainerStyles, scrollableContainerHeight && scrollableContainerStyles],
530
560
  style: scrollableContainerHeight ? {
531
561
  maxHeight: `${scrollableContainerHeight}px`
532
- } : undefined
533
- }, jsx(Table, {
562
+ } : undefined,
563
+ "data-testid": 'issue-like-table-container'
564
+ }, jsx(WidthObserver, {
565
+ setWidth: debounce(setTableContainerWidth, 100)
566
+ }), jsx(Table, {
534
567
  css: tableStyles,
535
568
  "data-testid": testId,
536
569
  style: shouldUseWidth ? {