@atlaskit/dynamic-table 14.8.8 → 14.8.10

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 (91) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/components/body.js +5 -22
  3. package/dist/cjs/components/loading-container-advanced.js +17 -61
  4. package/dist/cjs/components/loading-container.js +5 -23
  5. package/dist/cjs/components/managed-pagination.js +7 -28
  6. package/dist/cjs/components/rankable/body.js +12 -41
  7. package/dist/cjs/components/rankable/table-cell.js +10 -34
  8. package/dist/cjs/components/rankable/table-head-cell.js +4 -25
  9. package/dist/cjs/components/rankable/table-row.js +11 -46
  10. package/dist/cjs/components/stateful.js +23 -54
  11. package/dist/cjs/components/stateless.js +31 -84
  12. package/dist/cjs/components/table-head-cell.js +8 -16
  13. package/dist/cjs/components/table-head.js +12 -42
  14. package/dist/cjs/components/table-row.js +13 -23
  15. package/dist/cjs/hoc/with-dimensions.js +6 -27
  16. package/dist/cjs/hoc/with-sorted-page-rows.js +27 -64
  17. package/dist/cjs/index.js +0 -3
  18. package/dist/cjs/internal/helpers.js +9 -30
  19. package/dist/cjs/styled/constants.js +3 -9
  20. package/dist/cjs/styled/dynamic-table.js +5 -21
  21. package/dist/cjs/styled/empty-body.js +3 -10
  22. package/dist/cjs/styled/loading-container-advanced.js +5 -15
  23. package/dist/cjs/styled/loading-container.js +5 -15
  24. package/dist/cjs/styled/rankable/row-placeholder.js +6 -9
  25. package/dist/cjs/styled/rankable/table-cell.js +6 -12
  26. package/dist/cjs/styled/rankable/table-row.js +4 -11
  27. package/dist/cjs/styled/table-cell.js +8 -15
  28. package/dist/cjs/styled/table-head.js +12 -31
  29. package/dist/cjs/styled/table-row.js +5 -11
  30. package/dist/cjs/theme.js +0 -5
  31. package/dist/cjs/version.json +1 -1
  32. package/dist/es2019/components/body.js +0 -3
  33. package/dist/es2019/components/loading-container-advanced.js +7 -40
  34. package/dist/es2019/components/loading-container.js +0 -2
  35. package/dist/es2019/components/managed-pagination.js +2 -5
  36. package/dist/es2019/components/rankable/body.js +0 -8
  37. package/dist/es2019/components/rankable/table-cell.js +0 -1
  38. package/dist/es2019/components/rankable/table-head-cell.js +0 -3
  39. package/dist/es2019/components/rankable/table-row.js +2 -7
  40. package/dist/es2019/components/stateful.js +0 -14
  41. package/dist/es2019/components/stateless.js +3 -34
  42. package/dist/es2019/components/table-head-cell.js +2 -4
  43. package/dist/es2019/components/table-head.js +2 -10
  44. package/dist/es2019/components/table-row.js +2 -3
  45. package/dist/es2019/hoc/with-dimensions.js +4 -11
  46. package/dist/es2019/hoc/with-sorted-page-rows.js +16 -33
  47. package/dist/es2019/internal/helpers.js +6 -11
  48. package/dist/es2019/styled/constants.js +3 -3
  49. package/dist/es2019/styled/dynamic-table.js +2 -6
  50. package/dist/es2019/styled/empty-body.js +1 -1
  51. package/dist/es2019/styled/loading-container-advanced.js +3 -5
  52. package/dist/es2019/styled/loading-container.js +1 -1
  53. package/dist/es2019/styled/rankable/row-placeholder.js +6 -5
  54. package/dist/es2019/styled/rankable/table-cell.js +5 -4
  55. package/dist/es2019/styled/rankable/table-row.js +2 -2
  56. package/dist/es2019/styled/table-cell.js +7 -5
  57. package/dist/es2019/styled/table-head.js +4 -5
  58. package/dist/es2019/styled/table-row.js +2 -2
  59. package/dist/es2019/types.js +1 -0
  60. package/dist/es2019/version.json +1 -1
  61. package/dist/esm/components/body.js +5 -15
  62. package/dist/esm/components/loading-container-advanced.js +17 -65
  63. package/dist/esm/components/loading-container.js +5 -16
  64. package/dist/esm/components/managed-pagination.js +7 -23
  65. package/dist/esm/components/rankable/body.js +12 -30
  66. package/dist/esm/components/rankable/table-cell.js +10 -21
  67. package/dist/esm/components/rankable/table-head-cell.js +4 -15
  68. package/dist/esm/components/rankable/table-row.js +11 -31
  69. package/dist/esm/components/stateful.js +23 -51
  70. package/dist/esm/components/stateless.js +31 -70
  71. package/dist/esm/components/table-head-cell.js +8 -11
  72. package/dist/esm/components/table-head.js +12 -33
  73. package/dist/esm/components/table-row.js +13 -18
  74. package/dist/esm/hoc/with-dimensions.js +6 -22
  75. package/dist/esm/hoc/with-sorted-page-rows.js +27 -54
  76. package/dist/esm/internal/helpers.js +9 -16
  77. package/dist/esm/styled/constants.js +3 -3
  78. package/dist/esm/styled/dynamic-table.js +5 -11
  79. package/dist/esm/styled/empty-body.js +3 -3
  80. package/dist/esm/styled/loading-container-advanced.js +5 -8
  81. package/dist/esm/styled/loading-container.js +5 -6
  82. package/dist/esm/styled/rankable/row-placeholder.js +6 -5
  83. package/dist/esm/styled/rankable/table-cell.js +7 -7
  84. package/dist/esm/styled/rankable/table-row.js +4 -5
  85. package/dist/esm/styled/table-cell.js +11 -10
  86. package/dist/esm/styled/table-head.js +12 -19
  87. package/dist/esm/styled/table-row.js +5 -6
  88. package/dist/esm/types.js +1 -0
  89. package/dist/esm/version.json +1 -1
  90. package/package.json +1 -1
  91. package/report.api.md +14 -0
@@ -16,15 +16,15 @@ export const getTruncationStyleVars = ({
16
16
  [CSS_VAR_WIDTH]: `${width}%`
17
17
  } : undefined;
18
18
  export const cellStyles = css({
19
- padding: `${"var(--ds-scale-050, 4px)"} ${"var(--ds-scale-100, 8px)"}`,
19
+ padding: `${"var(--ds-space-050, 4px)"} ${"var(--ds-space-100, 8px)"}`,
20
20
  border: 'none',
21
21
  textAlign: 'left',
22
22
  '&:first-of-type': {
23
23
  // TODO Delete this comment after verifying spacing token -> previous value `0`
24
- paddingLeft: "var(--ds-scale-0, 0px)"
24
+ paddingLeft: "var(--ds-space-0, 0px)"
25
25
  },
26
26
  '&:last-child': {
27
27
  // TODO Delete this comment after verifying spacing token -> previous value `0`
28
- paddingRight: "var(--ds-scale-0, 0px)"
28
+ paddingRight: "var(--ds-space-0, 0px)"
29
29
  }
30
30
  });
@@ -1,7 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /* eslint-disable @repo/internal/react/require-jsdoc */
4
-
5
3
  /** @jsx jsx */
6
4
  import { forwardRef } from 'react';
7
5
  import { css, jsx } from '@emotion/react';
@@ -46,15 +44,13 @@ export const Table = /*#__PURE__*/forwardRef(({
46
44
  });
47
45
  const captionStyles = css({
48
46
  marginTop: `${gridSize * 3.5}px`,
49
- // TODO Delete this comment after verifying spacing token -> previous value ``${gridSize}px``
50
- marginBottom: "var(--ds-scale-100, 8px)",
47
+ marginBottom: "var(--ds-space-100, 8px)",
51
48
  fontSize: '1.42857143em',
52
49
  fontStyle: 'inherit',
53
- fontWeight: 500,
50
+ fontWeight: "var(--ds-font-weight-medium, 500)",
54
51
  letterSpacing: '-0.008em',
55
52
  lineHeight: 1.2,
56
53
  textAlign: 'left',
57
-
58
54
  /* there is a bug in Safari: if element which creates a new stacking context
59
55
  is a child of a table, table caption re-renders in bad wrong position
60
56
  https://stackoverflow.com/questions/44009186/safari-bug-translating-table-row-group-using-gsap-make-caption-jump-to-bottom
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @repo/internal/react/require-jsdoc */
2
-
3
2
  /** @jsx jsx */
3
+
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import { gridSize } from '@atlaskit/theme/constants';
6
6
  const fixedHeightStyles = css({
@@ -1,13 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /* eslint-disable @repo/internal/react/require-jsdoc */
4
-
5
3
  /** @jsx jsx */
6
4
  import { forwardRef } from 'react';
7
5
  import { css, jsx } from '@emotion/react';
8
6
  const containerStyles = css({
9
- // TODO Delete this comment after verifying spacing token -> previous value ``${gridSize() * 3}px``
10
- marginBottom: "var(--ds-scale-300, 24px)",
7
+ marginBottom: "var(--ds-space-300, 24px)",
11
8
  position: 'relative'
12
9
  });
13
10
  export const Container = props => {
@@ -15,7 +12,8 @@ export const Container = props => {
15
12
  testId,
16
13
  ...rest
17
14
  } = props;
18
- return (// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
15
+ return (
16
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
19
17
  jsx("div", _extends({
20
18
  css: containerStyles
21
19
  }, rest, {
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @repo/internal/react/require-jsdoc */
2
-
3
2
  /** @jsx jsx */
3
+
4
4
  import { css, jsx } from '@emotion/react';
5
5
  export const CSS_VAR_CONTENTS_OPACITY = '--contents-opacity';
6
6
  const containerStyles = css({
@@ -1,13 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
3
+
4
4
  import { css, jsx } from '@emotion/react';
5
5
  const rowPlaceholderStyles = css({
6
- // TODO Delete this comment after verifying spacing token -> previous value `0`
7
- padding: "var(--ds-scale-0, 0px)"
8
- }); // eslint-disable-next-line @repo/internal/react/require-jsdoc
6
+ padding: "var(--ds-space-0, 0px)"
7
+ });
9
8
 
10
- export const RowPlaceholderCell = props => // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
9
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
10
+ export const RowPlaceholderCell = props =>
11
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
11
12
  jsx("td", _extends({
12
13
  css: rowPlaceholderStyles
13
14
  }, props));
@@ -1,19 +1,20 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
3
+
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import { TableBodyCell } from '../table-cell';
6
6
  const rankingStyles = css({
7
7
  boxSizing: 'border-box'
8
- }); // eslint-disable-next-line @repo/internal/react/require-jsdoc
8
+ });
9
9
 
10
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
10
11
  export const RankableTableBodyCell = ({
11
12
  isRanking,
12
13
  innerRef,
13
14
  ...props
14
15
  }) => jsx(TableBodyCell, _extends({
15
- css: isRanking && rankingStyles // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
16
-
16
+ css: isRanking && rankingStyles
17
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
17
18
  }, props, {
18
19
  innerRef: innerRef
19
20
  }));
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
4
3
  import { forwardRef } from 'react';
5
4
  import { css, jsx } from '@emotion/react';
@@ -19,8 +18,9 @@ const draggableStyles = css({
19
18
  outlineColor: `var(--ds-border-focused, ${B100})`,
20
19
  outlineStyle: 'solid'
21
20
  }
22
- }); // eslint-disable-next-line @repo/internal/react/require-jsdoc
21
+ });
23
22
 
23
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
24
24
  export const RankableTableBodyRow = /*#__PURE__*/forwardRef(({
25
25
  isRanking,
26
26
  isRankingItem,
@@ -1,9 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
3
+
4
4
  import { jsx } from '@emotion/react';
5
- import { cellStyles, fixedSizeTruncateStyles, getTruncationStyleVars, overflowTruncateStyles, truncationWidthStyles } from './constants'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
5
+ import { cellStyles, fixedSizeTruncateStyles, getTruncationStyleVars, overflowTruncateStyles, truncationWidthStyles } from './constants';
6
6
 
7
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
7
8
  export const TableBodyCell = ({
8
9
  width,
9
10
  isFixedSize,
@@ -14,9 +15,10 @@ export const TableBodyCell = ({
14
15
  style: getTruncationStyleVars({
15
16
  width
16
17
  }),
17
- css: [truncationWidthStyles, isFixedSize && shouldTruncate && fixedSizeTruncateStyles, isFixedSize && overflowTruncateStyles, cellStyles] // HOC withDimensions complains about the types but it is working fine
18
+ css: [truncationWidthStyles, isFixedSize && shouldTruncate && fixedSizeTruncateStyles, isFixedSize && overflowTruncateStyles, cellStyles]
19
+ // HOC withDimensions complains about the types but it is working fine
18
20
  // @ts-ignore
19
21
  ,
20
- ref: innerRef // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
21
-
22
+ ref: innerRef
23
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
22
24
  }, props));
@@ -1,7 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /* eslint-disable @repo/internal/react/require-jsdoc */
4
-
5
3
  /** @jsx jsx */
6
4
  import { forwardRef } from 'react';
7
5
  import { css, jsx } from '@emotion/react';
@@ -23,8 +21,8 @@ export const Head = ({
23
21
  ...props
24
22
  }) => {
25
23
  return jsx("thead", _extends({
26
- css: [headStyles, isRanking && rankingStyles] // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
27
-
24
+ css: [headStyles, isRanking && rankingStyles]
25
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
28
26
  }, props));
29
27
  };
30
28
  const headCellStyles = css([cellStyles, {
@@ -121,7 +119,8 @@ export const HeadCell = /*#__PURE__*/forwardRef(({
121
119
  style,
122
120
  ...rest
123
121
  }, ref) => {
124
- const mergedStyles = { ...style,
122
+ const mergedStyles = {
123
+ ...style,
125
124
  ...(width && getTruncationStyleVars({
126
125
  width
127
126
  })),
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
4
3
  import { forwardRef } from 'react';
5
4
  import { css, jsx } from '@emotion/react';
@@ -21,8 +20,9 @@ const rowHighlightedBackgroundStyles = css({
21
20
  '&:hover': {
22
21
  backgroundColor: `var(--ds-background-selected-hovered, ${`var(${cssVars.CSS_VAR_HOVER_HIGHLIGHTED_BACKGROUND})`})`
23
22
  }
24
- }); // eslint-disable-next-line @repo/internal/react/require-jsdoc
23
+ });
25
24
 
25
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
26
26
  export const TableBodyRow = /*#__PURE__*/forwardRef(({
27
27
  isHighlighted,
28
28
  children,
@@ -1,2 +1,3 @@
1
1
  /* eslint-disable @repo/internal/react/consistent-types-definitions */
2
+
2
3
  import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dynamic-table",
3
- "version": "14.8.8",
3
+ "version": "14.8.10",
4
4
  "sideEffects": false
5
5
  }
@@ -3,35 +3,27 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
-
7
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
-
9
7
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
-
11
8
  import React from 'react';
12
9
  import withSortedPageRows from '../hoc/with-sorted-page-rows';
13
10
  import TableRow from './table-row';
14
-
15
11
  var Body = /*#__PURE__*/function (_React$Component) {
16
12
  _inherits(Body, _React$Component);
17
-
18
13
  var _super = _createSuper(Body);
19
-
20
14
  function Body() {
21
15
  _classCallCheck(this, Body);
22
-
23
16
  return _super.apply(this, arguments);
24
17
  }
25
-
26
18
  _createClass(Body, [{
27
19
  key: "render",
28
20
  value: function render() {
29
21
  var _this$props = this.props,
30
- pageRows = _this$props.pageRows,
31
- head = _this$props.head,
32
- isFixedSize = _this$props.isFixedSize,
33
- highlightedRowIndex = _this$props.highlightedRowIndex,
34
- testId = _this$props.testId;
22
+ pageRows = _this$props.pageRows,
23
+ head = _this$props.head,
24
+ isFixedSize = _this$props.isFixedSize,
25
+ highlightedRowIndex = _this$props.highlightedRowIndex,
26
+ testId = _this$props.testId;
35
27
  return /*#__PURE__*/React.createElement("tbody", {
36
28
  "data-testid": testId && "".concat(testId, "--body")
37
29
  }, pageRows.map(function (row, rowIndex) {
@@ -46,8 +38,6 @@ var Body = /*#__PURE__*/function (_React$Component) {
46
38
  }));
47
39
  }
48
40
  }]);
49
-
50
41
  return Body;
51
42
  }(React.Component);
52
-
53
43
  export default withSortedPageRows(Body);
@@ -6,18 +6,14 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
-
10
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
-
12
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
-
14
11
  /* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
15
12
  import React from 'react';
16
13
  import { findDOMNode } from 'react-dom';
17
14
  import Spinner from '@atlaskit/spinner';
18
15
  import { LARGE, LOADING_CONTENTS_OPACITY } from '../internal/constants';
19
16
  import { Container, SpinnerBackdrop, SpinnerContainer } from '../styled/loading-container-advanced';
20
-
21
17
  // there is a bug with findDOMNode and Suspense in React < 16.9: https://github.com/facebook/react/issues/14188
22
18
  var safeFindDOMNode = function safeFindDOMNode(component) {
23
19
  try {
@@ -26,33 +22,23 @@ var safeFindDOMNode = function safeFindDOMNode(component) {
26
22
  return null;
27
23
  }
28
24
  };
29
-
30
25
  var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
31
26
  _inherits(LoadingContainerAdvanced, _React$Component);
32
-
33
27
  var _super = _createSuper(LoadingContainerAdvanced);
34
-
35
28
  function LoadingContainerAdvanced() {
36
29
  var _this;
37
-
38
30
  _classCallCheck(this, LoadingContainerAdvanced);
39
-
40
31
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
41
32
  args[_key] = arguments[_key];
42
33
  }
43
-
44
34
  _this = _super.call.apply(_super, [this].concat(args));
45
-
46
35
  _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
47
36
  if (_this.props.isLoading && _this.hasTargetNode()) {
48
37
  _this.attachListeners();
49
-
50
38
  _this.updateTargetAppearance();
51
-
52
39
  _this.updateSpinnerPosition();
53
40
  }
54
41
  });
55
-
56
42
  _defineProperty(_assertThisInitialized(_this), "UNSAFE_componentWillReceiveProps", function (nextProps) {
57
43
  if (!nextProps.isLoading || !_this.hasTargetNode(nextProps)) {
58
44
  _this.detachListeners();
@@ -60,89 +46,70 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
60
46
  _this.attachListeners();
61
47
  }
62
48
  });
63
-
64
49
  _defineProperty(_assertThisInitialized(_this), "componentDidUpdate", function () {
65
50
  if (_this.hasTargetNode()) {
66
51
  _this.updateTargetAppearance();
67
-
68
52
  if (_this.props.isLoading) {
69
53
  _this.updateSpinnerPosition();
70
54
  }
71
55
  }
72
56
  });
73
-
74
57
  _defineProperty(_assertThisInitialized(_this), "componentWillUnmount", function () {
75
58
  _this.detachListeners();
76
59
  });
77
-
78
60
  _defineProperty(_assertThisInitialized(_this), "getTargetNode", function () {
79
61
  var nextProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props;
80
- var targetRef = nextProps.targetRef; // targetRef prop may be defined but it is not guaranteed it returns an element
81
-
82
- var targetElement = targetRef ? targetRef() : _this.children; // @ts-ignore - targetElement is not assignable to type 'ReactInstance'
83
-
62
+ var targetRef = nextProps.targetRef;
63
+ // targetRef prop may be defined but it is not guaranteed it returns an element
64
+ var targetElement = targetRef ? targetRef() : _this.children;
65
+ // @ts-ignore - targetElement is not assignable to type 'ReactInstance'
84
66
  var targetNode = safeFindDOMNode(targetElement);
85
67
  return targetNode;
86
68
  });
87
-
88
69
  _defineProperty(_assertThisInitialized(_this), "getThisNode", function () {
89
70
  return safeFindDOMNode(_assertThisInitialized(_this));
90
71
  });
91
-
92
72
  _defineProperty(_assertThisInitialized(_this), "getSpinnerNode", function () {
93
73
  return safeFindDOMNode(_this.spinnerRef);
94
74
  });
95
-
96
75
  _defineProperty(_assertThisInitialized(_this), "hasTargetNode", function (nextProps) {
97
76
  return !!_this.getTargetNode(nextProps);
98
77
  });
99
-
100
78
  _defineProperty(_assertThisInitialized(_this), "isVerticallyVisible", function (elementRect, viewportHeight) {
101
79
  var top = elementRect.top,
102
- bottom = elementRect.bottom;
103
-
80
+ bottom = elementRect.bottom;
104
81
  if (bottom <= 0) {
105
82
  return false;
106
83
  }
107
-
108
84
  return top < viewportHeight;
109
85
  });
110
-
111
86
  _defineProperty(_assertThisInitialized(_this), "isFullyVerticallyVisible", function (elementRect, viewportHeight) {
112
87
  var top = elementRect.top,
113
- bottom = elementRect.bottom;
88
+ bottom = elementRect.bottom;
114
89
  return top >= 0 && bottom <= viewportHeight;
115
90
  });
116
-
117
91
  _defineProperty(_assertThisInitialized(_this), "handleResize", function () {
118
92
  _this.updateSpinnerPosition();
119
93
  });
120
-
121
94
  _defineProperty(_assertThisInitialized(_this), "handleScroll", function () {
122
95
  _this.updateSpinnerPosition();
123
96
  });
124
-
125
97
  _defineProperty(_assertThisInitialized(_this), "translateSpinner", function (spinnerNode, transformY, isFixed) {
126
98
  spinnerNode.style.position = isFixed ? 'fixed' : '';
127
99
  spinnerNode.style.transform = transformY !== 0 ? "translate3d(0, ".concat(transformY, "px, 0)") : '';
128
100
  });
129
-
130
101
  _defineProperty(_assertThisInitialized(_this), "updateTargetAppearance", function () {
131
102
  var targetNode = _this.getTargetNode();
132
-
133
103
  var _this$props = _this.props,
134
- isLoading = _this$props.isLoading,
135
- contentsOpacity = _this$props.contentsOpacity;
136
-
104
+ isLoading = _this$props.isLoading,
105
+ contentsOpacity = _this$props.contentsOpacity;
137
106
  if (targetNode && targetNode.style && _typeof(targetNode.style) === 'object') {
138
107
  targetNode.style.pointerEvents = isLoading ? 'none' : '';
139
108
  targetNode.style.opacity = isLoading ? contentsOpacity.toString() : '';
140
109
  }
141
110
  });
142
-
143
111
  return _this;
144
112
  }
145
-
146
113
  _createClass(LoadingContainerAdvanced, [{
147
114
  key: "attachListeners",
148
115
  value: function attachListeners() {
@@ -161,24 +128,20 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
161
128
  var viewportHeight = window.innerHeight;
162
129
  var targetNode = this.getTargetNode();
163
130
  var spinnerNode = this.getSpinnerNode();
164
-
165
131
  if (!targetNode || !spinnerNode) {
166
132
  return;
167
133
  }
168
-
169
134
  var targetRect = targetNode.getBoundingClientRect();
170
135
  var spinnerRect = spinnerNode.getBoundingClientRect();
171
136
  var spinnerHeight = spinnerRect.height;
172
137
  var isInViewport = this.isVerticallyVisible(targetRect, viewportHeight);
173
138
  var top = targetRect.top,
174
- bottom = targetRect.bottom,
175
- height = targetRect.height;
176
-
139
+ bottom = targetRect.bottom,
140
+ height = targetRect.height;
177
141
  if (isInViewport) {
178
142
  // The spinner may follow the element only if there is enough space:
179
143
  // Let's say the element can fit at least three spinners (vertically)
180
144
  var canFollow = height >= spinnerHeight * 3;
181
-
182
145
  if (canFollow && !this.isFullyVerticallyVisible(targetRect, viewportHeight)) {
183
146
  if (top >= 0) {
184
147
  // Only the head of the element is visible
@@ -189,17 +152,13 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
189
152
  } else if (top < 0 && bottom > viewportHeight) {
190
153
  // The element takes all viewport, nor its head nor tail are visible
191
154
  var _y = viewportHeight / 2 - spinnerHeight / 2;
192
-
193
155
  this.translateSpinner(spinnerNode, _y, true);
194
156
  } else {
195
157
  // Only the tail of the element is visible
196
158
  var _diff = bottom / 2 - spinnerHeight / 2;
197
-
198
159
  var _y2 = _diff < spinnerHeight ? _diff - (spinnerHeight - _diff) : _diff;
199
-
200
160
  this.translateSpinner(spinnerNode, _y2, true);
201
161
  }
202
-
203
162
  return;
204
163
  }
205
164
  } else {
@@ -207,19 +166,16 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
207
166
  if (!this.isVerticallyVisible(spinnerRect, viewportHeight)) {
208
167
  return;
209
168
  }
210
- } // Three options here:
169
+ }
170
+
171
+ // Three options here:
211
172
  // 1) the element is fully visible
212
173
  // 2) the element is too small for the spinner to follow
213
174
  // 3) the spinner might still be visible while the element isn't
214
-
215
-
216
175
  var thisNode = this.getThisNode();
217
-
218
176
  if (thisNode && typeof thisNode.getBoundingClientRect === 'function') {
219
177
  var thisTop = thisNode.getBoundingClientRect().top;
220
-
221
178
  var _y3 = (top - thisTop) / 2;
222
-
223
179
  this.translateSpinner(spinnerNode, _y3, false);
224
180
  }
225
181
  }
@@ -227,12 +183,11 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
227
183
  key: "render",
228
184
  value: function render() {
229
185
  var _this2 = this;
230
-
231
186
  var _this$props2 = this.props,
232
- children = _this$props2.children,
233
- isLoading = _this$props2.isLoading,
234
- spinnerSize = _this$props2.spinnerSize,
235
- testId = _this$props2.testId;
187
+ children = _this$props2.children,
188
+ isLoading = _this$props2.isLoading,
189
+ spinnerSize = _this$props2.spinnerSize,
190
+ testId = _this$props2.testId;
236
191
  return /*#__PURE__*/React.createElement(Container, {
237
192
  testId: testId && "".concat(testId, "--loading--container--advanced")
238
193
  }, /*#__PURE__*/React.cloneElement(children, {
@@ -251,14 +206,11 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
251
206
  }))));
252
207
  }
253
208
  }]);
254
-
255
209
  return LoadingContainerAdvanced;
256
210
  }(React.Component);
257
-
258
211
  _defineProperty(LoadingContainerAdvanced, "defaultProps", {
259
212
  isLoading: true,
260
213
  spinnerSize: LARGE,
261
214
  contentsOpacity: "var(--ds-opacity-loading, ".concat("".concat(LOADING_CONTENTS_OPACITY), ")")
262
215
  });
263
-
264
216
  export { LoadingContainerAdvanced as default };
@@ -4,36 +4,28 @@ import _inherits from "@babel/runtime/helpers/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
6
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
-
8
7
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
-
10
8
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
-
12
9
  import React from 'react';
13
10
  import Spinner from '@atlaskit/spinner';
14
11
  import { LARGE, LOADING_CONTENTS_OPACITY } from '../internal/constants';
15
12
  import { Container, ContentsContainer, SpinnerContainer } from '../styled/loading-container';
16
-
17
13
  var LoadingContainer = /*#__PURE__*/function (_React$Component) {
18
14
  _inherits(LoadingContainer, _React$Component);
19
-
20
15
  var _super = _createSuper(LoadingContainer);
21
-
22
16
  function LoadingContainer() {
23
17
  _classCallCheck(this, LoadingContainer);
24
-
25
18
  return _super.apply(this, arguments);
26
19
  }
27
-
28
20
  _createClass(LoadingContainer, [{
29
21
  key: "render",
30
22
  value: function render() {
31
23
  var _this$props = this.props,
32
- children = _this$props.children,
33
- isLoading = _this$props.isLoading,
34
- spinnerSize = _this$props.spinnerSize,
35
- contentsOpacity = _this$props.contentsOpacity,
36
- testId = _this$props.testId;
24
+ children = _this$props.children,
25
+ isLoading = _this$props.isLoading,
26
+ spinnerSize = _this$props.spinnerSize,
27
+ contentsOpacity = _this$props.contentsOpacity,
28
+ testId = _this$props.testId;
37
29
  return /*#__PURE__*/React.createElement(Container, {
38
30
  testId: testId
39
31
  }, !isLoading ? children : /*#__PURE__*/React.createElement(ContentsContainer, {
@@ -47,14 +39,11 @@ var LoadingContainer = /*#__PURE__*/function (_React$Component) {
47
39
  })));
48
40
  }
49
41
  }]);
50
-
51
42
  return LoadingContainer;
52
43
  }(React.Component);
53
-
54
44
  _defineProperty(LoadingContainer, "defaultProps", {
55
45
  isLoading: true,
56
46
  spinnerSize: LARGE,
57
47
  contentsOpacity: LOADING_CONTENTS_OPACITY
58
48
  });
59
-
60
49
  export { LoadingContainer as default };