@atlaskit/table-tree
Version:
A table tree is an expandable table for showing nested hierarchies of information.
38 lines (37 loc) • 1.47 kB
JavaScript
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import React, { useEffect, useState } from 'react';
import Spinner from '@atlaskit/spinner/spinner';
import CommonCell from './common-cell';
import { LoaderItemContainer } from './loader-item-container';
import { TreeRowContainer } from './tree-row-container';
var LoaderItem = function LoaderItem(_ref) {
var _ref$depth = _ref.depth,
depth = _ref$depth === void 0 ? 1 : _ref$depth,
loadingLabel = _ref.loadingLabel,
isCompleting = _ref.isCompleting,
onComplete = _ref.onComplete;
var _useState = useState('loading'),
_useState2 = _slicedToArray(_useState, 2),
phase = _useState2[0],
setPhase = _useState2[1];
useEffect(function () {
if (phase === 'loading' && isCompleting) {
setPhase(function () {
onComplete();
return 'complete';
});
}
}, [isCompleting, onComplete, phase]);
return phase === 'loading' ? /*#__PURE__*/React.createElement(TreeRowContainer, null, /*#__PURE__*/React.createElement(CommonCell, {
indent: "calc(".concat("var(--ds-space-300, 24px)", " * ", depth, ")"),
width: "100%"
}, /*#__PURE__*/React.createElement(LoaderItemContainer, {
isRoot: depth === 1
}, /*#__PURE__*/React.createElement(Spinner, {
size: "small",
testId: "table-tree-spinner",
label: loadingLabel
})))) : null;
};
// eslint-disable-next-line @repo/internal/react/require-jsdoc
export default LoaderItem;