Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React from 'react';
import { storiesOf } from '@storybook/react';
import DataTable from 'dash-table/dash/DataTable';
import { TableAction } from 'dash-table/components/Table/props';
const actions = [TableAction.Native, TableAction.Custom];
const setProps = () => { };
let stories = storiesOf('DashTable/Props Validation', module);
actions.forEach(filter => {
actions.forEach(sort => {
actions.forEach(page => {
stories = stories.add(`filter=${filter}, sorting=${sort}, pagination=${page}`, () => ());
});
});
get displayPagination() {
const {
data,
page_action,
page_size
} = this.props;
return (
page_action === TableAction.Native &&
page_size < data.length
) || page_action === TableAction.Custom;
}
const getter = (
page_action: TableAction,
page_current: number,
page_size: number,
setProps: SetProps,
data: Data
): IPaginator => {
switch (page_action) {
case TableAction.None:
return getNoPagination();
case TableAction.Native:
return getFrontEndPagination(page_current, page_size, setProps, data);
case TableAction.Custom:
return getBackEndPagination(page_current, setProps);
default:
throw new Error(`Unknown pagination mode: '${page_action}'`);
}
};
function isFrontEnd(value: TableAction) {
return value !== TableAction.Custom;
}
const getter = (
page_action: TableAction,
page_current: number,
page_size: number,
data: Data,
indices: Indices
): IDerivedData => {
switch (page_action) {
case TableAction.None:
return getNoPagination(data, indices);
case TableAction.Native:
return getFrontEndPagination(page_current, page_size, data, indices);
case TableAction.Custom:
return getBackEndPagination(data, indices);
default:
throw new Error(`Unknown pagination mode: '${page_action}'`);
}
};