@atlaskit/dynamic-table
Version:
A dynamic table displays rows of data with built-in pagination, sorting, and re-ordering functionality.
57 lines • 2.99 kB
JavaScript
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
import React from 'react';
import Pagination from '@atlaskit/pagination';
// eslint-disable-next-line @repo/internal/react/no-class-components
var ManagedPagination = /*#__PURE__*/function (_React$Component) {
function ManagedPagination() {
var _this;
_classCallCheck(this, ManagedPagination);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _callSuper(this, ManagedPagination, [].concat(args));
_defineProperty(_this, "onChange", function (_event, newValue, analyticsEvent) {
_this.props.onChange(newValue, analyticsEvent);
});
return _this;
}
_inherits(ManagedPagination, _React$Component);
return _createClass(ManagedPagination, [{
key: "render",
value: function render() {
var _this$props = this.props,
total = _this$props.total,
_this$props$value = _this$props.value,
value = _this$props$value === void 0 ? 1 : _this$props$value,
i18n = _this$props.i18n,
testId = _this$props.testId,
isDisabled = _this$props.isDisabled;
var pages = _toConsumableArray(Array(total)).map(function (_, index) {
return index + 1;
});
// Pagination accepts array now thus selectedIndex starts with 0
// So, we are substracting value by one thus not breaking dynamic table
var selectedIndex = value - 1;
return /*#__PURE__*/React.createElement(Pagination, {
selectedIndex: selectedIndex,
isDisabled: isDisabled,
label: i18n === null || i18n === void 0 ? void 0 : i18n.label,
nextLabel: i18n === null || i18n === void 0 ? void 0 : i18n.next,
previousLabel: i18n === null || i18n === void 0 ? void 0 : i18n.prev,
pageLabel: i18n === null || i18n === void 0 ? void 0 : i18n.pageLabel,
onChange: this.onChange,
pages: pages,
testId: testId && "".concat(testId, "--pagination")
});
}
}]);
}(React.Component);
export { ManagedPagination as default };