pre-installations and preparations
This commit is contained in:
1 parent
3e5a0329cb
commit
201d621ac3
6977 files changed
+742826
No files matched your search
+15
@@ -0,0 +1,15 @@
|
||||
import { PolymorphicComponent } from '../utils';
|
||||
import { TablePaginationTypeMap } from './TablePagination.types';
|
||||
/**
|
||||
* A pagination for tables.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Table Pagination](https://mui.com/base-ui/react-table-pagination/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [TablePagination API](https://mui.com/base-ui/react-table-pagination/components-api/#table-pagination)
|
||||
*/
|
||||
declare const TablePagination: PolymorphicComponent<TablePaginationTypeMap<{}, "td">>;
|
||||
export { TablePagination };
|
||||
+318
@@ -0,0 +1,318 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["colSpan", "count", "getItemAriaLabel", "labelDisplayedRows", "labelId", "labelRowsPerPage", "onPageChange", "onRowsPerPageChange", "page", "rowsPerPage", "rowsPerPageOptions", "selectId", "slotProps", "slots"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_useId as useId, chainPropTypes, integerPropType } from '@mui/utils';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { isHostComponent } from '../utils/isHostComponent';
|
||||
import { TablePaginationActions } from './TablePaginationActions';
|
||||
import { getTablePaginationUtilityClass } from './tablePaginationClasses';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { createElement as _createElement } from "react";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
function defaultLabelDisplayedRows({
|
||||
from,
|
||||
to,
|
||||
count
|
||||
}) {
|
||||
return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`;
|
||||
}
|
||||
function defaultGetAriaLabel(type) {
|
||||
return `Go to ${type} page`;
|
||||
}
|
||||
const useUtilityClasses = () => {
|
||||
const slots = {
|
||||
root: ['root'],
|
||||
toolbar: ['toolbar'],
|
||||
spacer: ['spacer'],
|
||||
selectLabel: ['selectLabel'],
|
||||
select: ['select'],
|
||||
input: ['input'],
|
||||
selectIcon: ['selectIcon'],
|
||||
menuItem: ['menuItem'],
|
||||
displayedRows: ['displayedRows'],
|
||||
actions: ['actions']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getTablePaginationUtilityClass));
|
||||
};
|
||||
|
||||
/**
|
||||
* A pagination for tables.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Table Pagination](https://mui.com/base-ui/react-table-pagination/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [TablePagination API](https://mui.com/base-ui/react-table-pagination/components-api/#table-pagination)
|
||||
*/
|
||||
const TablePagination = /*#__PURE__*/React.forwardRef(function TablePagination(props, forwardedRef) {
|
||||
var _slots$root, _slots$select, _slots$actions, _slots$menuItem, _slots$selectLabel, _slots$displayedRows, _slots$toolbar, _slots$spacer;
|
||||
const {
|
||||
colSpan: colSpanProp,
|
||||
count,
|
||||
getItemAriaLabel = defaultGetAriaLabel,
|
||||
labelDisplayedRows = defaultLabelDisplayedRows,
|
||||
labelId: labelIdProp,
|
||||
labelRowsPerPage = 'Rows per page:',
|
||||
onPageChange,
|
||||
onRowsPerPageChange,
|
||||
page,
|
||||
rowsPerPage,
|
||||
rowsPerPageOptions = [10, 25, 50, 100],
|
||||
selectId: selectIdProp,
|
||||
slotProps = {},
|
||||
slots = {}
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = props;
|
||||
const classes = useUtilityClasses();
|
||||
let colSpan;
|
||||
const Root = (_slots$root = slots.root) != null ? _slots$root : 'td';
|
||||
if (Root === 'td' || !isHostComponent(Root)) {
|
||||
colSpan = colSpanProp || 1000; // col-span over everything
|
||||
}
|
||||
const getLabelDisplayedRowsTo = () => {
|
||||
if (count === -1) {
|
||||
return (page + 1) * rowsPerPage;
|
||||
}
|
||||
return rowsPerPage === -1 ? count : Math.min(count, (page + 1) * rowsPerPage);
|
||||
};
|
||||
const selectId = useId(selectIdProp);
|
||||
const labelId = useId(labelIdProp);
|
||||
const rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
colSpan,
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
const Select = (_slots$select = slots.select) != null ? _slots$select : 'select';
|
||||
const selectProps = useSlotProps({
|
||||
elementType: Select,
|
||||
externalSlotProps: slotProps.select,
|
||||
additionalProps: {
|
||||
value: rowsPerPage,
|
||||
id: selectId,
|
||||
onChange: event => onRowsPerPageChange && onRowsPerPageChange(event),
|
||||
'aria-label': rowsPerPage.toString(),
|
||||
'aria-labelledby': [labelId, selectId].filter(Boolean).join(' ') || undefined
|
||||
},
|
||||
ownerState,
|
||||
className: classes.select
|
||||
});
|
||||
const Actions = (_slots$actions = slots.actions) != null ? _slots$actions : TablePaginationActions;
|
||||
const actionsProps = useSlotProps({
|
||||
elementType: Actions,
|
||||
externalSlotProps: slotProps.actions,
|
||||
additionalProps: {
|
||||
page,
|
||||
rowsPerPage,
|
||||
count,
|
||||
onPageChange,
|
||||
getItemAriaLabel
|
||||
},
|
||||
ownerState,
|
||||
className: classes.actions
|
||||
});
|
||||
const MenuItem = (_slots$menuItem = slots.menuItem) != null ? _slots$menuItem : 'option';
|
||||
const menuItemProps = useSlotProps({
|
||||
elementType: MenuItem,
|
||||
externalSlotProps: slotProps.menuItem,
|
||||
additionalProps: {
|
||||
value: undefined
|
||||
},
|
||||
ownerState,
|
||||
className: classes.menuItem
|
||||
});
|
||||
const SelectLabel = (_slots$selectLabel = slots.selectLabel) != null ? _slots$selectLabel : 'p';
|
||||
const selectLabelProps = useSlotProps({
|
||||
elementType: SelectLabel,
|
||||
externalSlotProps: slotProps.selectLabel,
|
||||
additionalProps: {
|
||||
id: labelId
|
||||
},
|
||||
ownerState,
|
||||
className: classes.selectLabel
|
||||
});
|
||||
const DisplayedRows = (_slots$displayedRows = slots.displayedRows) != null ? _slots$displayedRows : 'p';
|
||||
const displayedRowsProps = useSlotProps({
|
||||
elementType: DisplayedRows,
|
||||
externalSlotProps: slotProps.displayedRows,
|
||||
ownerState,
|
||||
className: classes.displayedRows
|
||||
});
|
||||
const Toolbar = (_slots$toolbar = slots.toolbar) != null ? _slots$toolbar : 'div';
|
||||
const toolbarProps = useSlotProps({
|
||||
elementType: Toolbar,
|
||||
externalSlotProps: slotProps.toolbar,
|
||||
ownerState,
|
||||
className: classes.toolbar
|
||||
});
|
||||
const Spacer = (_slots$spacer = slots.spacer) != null ? _slots$spacer : 'div';
|
||||
const spacerProps = useSlotProps({
|
||||
elementType: Spacer,
|
||||
externalSlotProps: slotProps.spacer,
|
||||
ownerState,
|
||||
className: classes.spacer
|
||||
});
|
||||
return /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
|
||||
children: /*#__PURE__*/_jsxs(Toolbar, _extends({}, toolbarProps, {
|
||||
children: [/*#__PURE__*/_jsx(Spacer, _extends({}, spacerProps)), rowsPerPageOptions.length > 1 && /*#__PURE__*/_jsx(SelectLabel, _extends({}, selectLabelProps, {
|
||||
children: labelRowsPerPage
|
||||
})), rowsPerPageOptions.length > 1 && /*#__PURE__*/_jsx(Select, _extends({}, selectProps, {
|
||||
children: rowsPerPageOptions.map(rowsPerPageOption => /*#__PURE__*/_createElement(MenuItem, _extends({}, menuItemProps, {
|
||||
key: typeof rowsPerPageOption !== 'number' && rowsPerPageOption.label ? rowsPerPageOption.label : rowsPerPageOption,
|
||||
value: typeof rowsPerPageOption !== 'number' && rowsPerPageOption.value ? rowsPerPageOption.value : rowsPerPageOption
|
||||
}), typeof rowsPerPageOption !== 'number' && rowsPerPageOption.label ? rowsPerPageOption.label : rowsPerPageOption))
|
||||
})), /*#__PURE__*/_jsx(DisplayedRows, _extends({}, displayedRowsProps, {
|
||||
children: labelDisplayedRows({
|
||||
from: count === 0 ? 0 : page * rowsPerPage + 1,
|
||||
to: getLabelDisplayedRowsTo(),
|
||||
count: count === -1 ? -1 : count,
|
||||
page
|
||||
})
|
||||
})), /*#__PURE__*/_jsx(Actions, _extends({}, actionsProps))]
|
||||
}))
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? TablePagination.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
colSpan: PropTypes.number,
|
||||
/**
|
||||
* The total number of rows.
|
||||
*
|
||||
* To enable server side pagination for an unknown number of items, provide -1.
|
||||
*/
|
||||
count: PropTypes.number.isRequired,
|
||||
/**
|
||||
* Accepts a function which returns a string value that provides a user-friendly name for the current page.
|
||||
* This is important for screen reader users.
|
||||
*
|
||||
* For localization purposes, you can use the provided [translations](/material-ui/guides/localization/).
|
||||
* @param {string} type The link or button type to format ('first' | 'last' | 'next' | 'previous').
|
||||
* @returns {string}
|
||||
* @default function defaultGetAriaLabel(type: ItemAriaLabelType) {
|
||||
* return `Go to ${type} page`;
|
||||
* }
|
||||
*/
|
||||
getItemAriaLabel: PropTypes.func,
|
||||
/**
|
||||
* Customize the displayed rows label. Invoked with a `{ from, to, count, page }`
|
||||
* object.
|
||||
*
|
||||
* For localization purposes, you can use the provided [translations](/material-ui/guides/localization/).
|
||||
* @default function defaultLabelDisplayedRows({ from, to, count }: LabelDisplayedRowsArgs) {
|
||||
* return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`;
|
||||
* }
|
||||
*/
|
||||
labelDisplayedRows: PropTypes.func,
|
||||
/**
|
||||
* Id of the label element within the pagination.
|
||||
*/
|
||||
labelId: PropTypes.string,
|
||||
/**
|
||||
* Customize the rows per page label.
|
||||
*
|
||||
* For localization purposes, you can use the provided [translations](/material-ui/guides/localization/).
|
||||
* @default 'Rows per page:'
|
||||
*/
|
||||
labelRowsPerPage: PropTypes.node,
|
||||
/**
|
||||
* Callback fired when the page is changed.
|
||||
*
|
||||
* @param {React.MouseEvent<HTMLButtonElement> | null} event The event source of the callback.
|
||||
* @param {number} page The page selected.
|
||||
*/
|
||||
onPageChange: PropTypes.func.isRequired,
|
||||
/**
|
||||
* Callback fired when the number of rows per page is changed.
|
||||
*
|
||||
* @param {React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>} event The event source of the callback.
|
||||
*/
|
||||
onRowsPerPageChange: PropTypes.func,
|
||||
/**
|
||||
* The zero-based index of the current page.
|
||||
*/
|
||||
page: chainPropTypes(integerPropType.isRequired, props => {
|
||||
const {
|
||||
count,
|
||||
page,
|
||||
rowsPerPage
|
||||
} = props;
|
||||
if (count === -1) {
|
||||
return null;
|
||||
}
|
||||
const newLastPage = Math.max(0, Math.ceil(count / rowsPerPage) - 1);
|
||||
if (page < 0 || page > newLastPage) {
|
||||
return new Error('MUI: The page prop of a TablePagination is out of range ' + `(0 to ${newLastPage}, but page is ${page}).`);
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
/**
|
||||
* The number of rows per page.
|
||||
*
|
||||
* Set -1 to display all the rows.
|
||||
*/
|
||||
rowsPerPage: integerPropType.isRequired,
|
||||
/**
|
||||
* Customizes the options of the rows per page select field. If less than two options are
|
||||
* available, no select field will be displayed.
|
||||
* Use -1 for the value with a custom label to show all the rows.
|
||||
* @default [10, 25, 50, 100]
|
||||
*/
|
||||
rowsPerPageOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
||||
label: PropTypes.string.isRequired,
|
||||
value: PropTypes.number.isRequired
|
||||
})]).isRequired),
|
||||
/**
|
||||
* Id of the select element within the pagination.
|
||||
*/
|
||||
selectId: PropTypes.string,
|
||||
/**
|
||||
* The props used for each slot inside the TablePagination.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes /* @typescript-to-proptypes-ignore */.shape({
|
||||
actions: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
displayedRows: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
menuItem: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
select: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
selectLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
spacer: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
toolbar: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the TablePagination.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
actions: PropTypes.elementType,
|
||||
displayedRows: PropTypes.elementType,
|
||||
menuItem: PropTypes.elementType,
|
||||
root: PropTypes.elementType,
|
||||
select: PropTypes.elementType,
|
||||
selectLabel: PropTypes.elementType,
|
||||
spacer: PropTypes.elementType,
|
||||
toolbar: PropTypes.elementType
|
||||
})
|
||||
} : void 0;
|
||||
export { TablePagination };
|
||||
+228
@@ -0,0 +1,228 @@
|
||||
import * as React from 'react';
|
||||
import { PolymorphicProps, SlotComponentProps } from '../utils';
|
||||
import { TablePaginationActions } from './TablePaginationActions';
|
||||
import { ItemAriaLabelType } from './common.types';
|
||||
export interface LabelDisplayedRowsArgs {
|
||||
from: number;
|
||||
to: number;
|
||||
count: number;
|
||||
page: number;
|
||||
}
|
||||
export interface TablePaginationRootSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationActionsSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationSelectSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationSelectLabelSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationMenuItemSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationDisplayedRowsSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationToolbarSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationSpacerSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationOwnProps {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
colSpan?: number;
|
||||
/**
|
||||
* The components used for each slot inside the TablePagination.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots?: TablePaginationSlots;
|
||||
/**
|
||||
* The props used for each slot inside the TablePagination.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: {
|
||||
root?: SlotComponentProps<'td', TablePaginationRootSlotPropsOverrides, TablePaginationOwnerState>;
|
||||
actions?: SlotComponentProps<typeof TablePaginationActions, TablePaginationActionsSlotPropsOverrides, TablePaginationOwnerState>;
|
||||
select?: SlotComponentProps<'select', TablePaginationSelectSlotPropsOverrides, TablePaginationOwnerState>;
|
||||
selectLabel?: SlotComponentProps<'p', TablePaginationSelectLabelSlotPropsOverrides, TablePaginationOwnerState>;
|
||||
menuItem?: SlotComponentProps<'option', TablePaginationMenuItemSlotPropsOverrides, TablePaginationOwnerState>;
|
||||
displayedRows?: SlotComponentProps<'p', TablePaginationDisplayedRowsSlotPropsOverrides, TablePaginationOwnerState>;
|
||||
toolbar?: SlotComponentProps<'div', TablePaginationToolbarSlotPropsOverrides, TablePaginationOwnerState>;
|
||||
spacer?: SlotComponentProps<'div', TablePaginationSpacerSlotPropsOverrides, TablePaginationOwnerState>;
|
||||
};
|
||||
/**
|
||||
* The total number of rows.
|
||||
*
|
||||
* To enable server side pagination for an unknown number of items, provide -1.
|
||||
*/
|
||||
count: number;
|
||||
/**
|
||||
* Accepts a function which returns a string value that provides a user-friendly name for the current page.
|
||||
* This is important for screen reader users.
|
||||
*
|
||||
* For localization purposes, you can use the provided [translations](/material-ui/guides/localization/).
|
||||
* @param {string} type The link or button type to format ('first' | 'last' | 'next' | 'previous').
|
||||
* @returns {string}
|
||||
* @default function defaultGetAriaLabel(type: ItemAriaLabelType) {
|
||||
* return `Go to ${type} page`;
|
||||
* }
|
||||
*/
|
||||
getItemAriaLabel?: (type: ItemAriaLabelType) => string;
|
||||
/**
|
||||
* Customize the displayed rows label. Invoked with a `{ from, to, count, page }`
|
||||
* object.
|
||||
*
|
||||
* For localization purposes, you can use the provided [translations](/material-ui/guides/localization/).
|
||||
* @default function defaultLabelDisplayedRows({ from, to, count }: LabelDisplayedRowsArgs) {
|
||||
* return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`;
|
||||
* }
|
||||
*/
|
||||
labelDisplayedRows?: (paginationInfo: LabelDisplayedRowsArgs) => React.ReactNode;
|
||||
/**
|
||||
* Id of the label element within the pagination.
|
||||
*/
|
||||
labelId?: string;
|
||||
/**
|
||||
* Customize the rows per page label.
|
||||
*
|
||||
* For localization purposes, you can use the provided [translations](/material-ui/guides/localization/).
|
||||
* @default 'Rows per page:'
|
||||
*/
|
||||
labelRowsPerPage?: React.ReactNode;
|
||||
/**
|
||||
* Callback fired when the page is changed.
|
||||
*
|
||||
* @param {React.MouseEvent<HTMLButtonElement> | null} event The event source of the callback.
|
||||
* @param {number} page The page selected.
|
||||
*/
|
||||
onPageChange: (event: React.MouseEvent<HTMLButtonElement> | null, page: number) => void;
|
||||
/**
|
||||
* Callback fired when the number of rows per page is changed.
|
||||
*
|
||||
* @param {React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>} event The event source of the callback.
|
||||
*/
|
||||
onRowsPerPageChange?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
|
||||
/**
|
||||
* The zero-based index of the current page.
|
||||
*/
|
||||
page: number;
|
||||
/**
|
||||
* The number of rows per page.
|
||||
*
|
||||
* Set -1 to display all the rows.
|
||||
*/
|
||||
rowsPerPage: number;
|
||||
/**
|
||||
* Customizes the options of the rows per page select field. If less than two options are
|
||||
* available, no select field will be displayed.
|
||||
* Use -1 for the value with a custom label to show all the rows.
|
||||
* @default [10, 25, 50, 100]
|
||||
*/
|
||||
rowsPerPageOptions?: ReadonlyArray<number | {
|
||||
value: number;
|
||||
label: string;
|
||||
}>;
|
||||
/**
|
||||
* Id of the select element within the pagination.
|
||||
*/
|
||||
selectId?: string;
|
||||
}
|
||||
export interface TablePaginationSlots {
|
||||
/**
|
||||
* The component that renders the root.
|
||||
* @default 'td'
|
||||
*/
|
||||
root?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the actions.
|
||||
* @default TablePaginationActions
|
||||
*/
|
||||
actions?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the select.
|
||||
* @default 'select'
|
||||
*/
|
||||
select?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the select label.
|
||||
* @default 'p'
|
||||
*/
|
||||
selectLabel?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the menu item.
|
||||
* @default 'option'
|
||||
*/
|
||||
menuItem?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the displayed rows.
|
||||
* @default 'p'
|
||||
*/
|
||||
displayedRows?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the toolbar.
|
||||
* @default 'div'
|
||||
*/
|
||||
toolbar?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the spacer.
|
||||
* @default 'div'
|
||||
*/
|
||||
spacer?: React.ElementType;
|
||||
}
|
||||
export interface TablePaginationTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'td'> {
|
||||
props: TablePaginationOwnProps & AdditionalProps;
|
||||
defaultComponent: RootComponentType;
|
||||
}
|
||||
export type TablePaginationProps<RootComponentType extends React.ElementType = TablePaginationTypeMap['defaultComponent']> = PolymorphicProps<TablePaginationTypeMap<{}, RootComponentType>, RootComponentType>;
|
||||
export type TablePaginationOwnerState = TablePaginationOwnProps;
|
||||
export type TablePaginationRootSlotProps = {
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
colSpan?: number;
|
||||
ownerState: TablePaginationOwnerState;
|
||||
ref?: React.Ref<any>;
|
||||
};
|
||||
export type TablePaginationSelectSlotProps = {
|
||||
['aria-label']: string;
|
||||
['aria-labelledby']?: string;
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
id?: string;
|
||||
onChange: (event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => void;
|
||||
ownerState: TablePaginationOwnerState;
|
||||
value: React.SelectHTMLAttributes<HTMLSelectElement>['value'];
|
||||
};
|
||||
export type TablePaginationActionsSlotProps = {
|
||||
className?: string;
|
||||
count: number;
|
||||
getItemAriaLabel: (type: ItemAriaLabelType) => string;
|
||||
onPageChange: (event: React.MouseEvent<HTMLButtonElement> | null, page: number) => void;
|
||||
ownerState: TablePaginationOwnerState;
|
||||
page: number;
|
||||
rowsPerPage: number;
|
||||
};
|
||||
export type TablePaginationMenuItemSlotProps = {
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
ownerState: TablePaginationOwnerState;
|
||||
value: React.SelectHTMLAttributes<HTMLSelectElement>['value'];
|
||||
};
|
||||
export type TablePaginationSelectLabelSlotProps = {
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
id?: string;
|
||||
ownerState: TablePaginationOwnerState;
|
||||
};
|
||||
export type TablePaginationDisplayedRowsSlotProps = {
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
ownerState: TablePaginationOwnerState;
|
||||
};
|
||||
export type TablePaginationToolbarSlotProps = {
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
ownerState: TablePaginationOwnerState;
|
||||
};
|
||||
export type TablePaginationSpacerSlotProps = {
|
||||
className?: string;
|
||||
ownerState: TablePaginationOwnerState;
|
||||
};
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { PolymorphicComponent } from '../utils';
|
||||
import { TablePaginationActionsTypeMap } from './TablePaginationActions.types';
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
declare const TablePaginationActions: PolymorphicComponent<TablePaginationActionsTypeMap<{}, "button">>;
|
||||
export { TablePaginationActions };
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["count", "getItemAriaLabel", "onPageChange", "page", "rowsPerPage", "showFirstButton", "showLastButton", "direction", "ownerState", "slotProps", "slots"];
|
||||
var _span, _span2, _span3, _span4;
|
||||
import * as React from 'react';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
function LastPageIconDefault() {
|
||||
return _span || (_span = /*#__PURE__*/_jsx("span", {
|
||||
children: '⇾|'
|
||||
}));
|
||||
}
|
||||
function FirstPageIconDefault() {
|
||||
return _span2 || (_span2 = /*#__PURE__*/_jsx("span", {
|
||||
children: '|⇽'
|
||||
}));
|
||||
}
|
||||
function NextPageIconDefault() {
|
||||
return _span3 || (_span3 = /*#__PURE__*/_jsx("span", {
|
||||
children: '⇾'
|
||||
}));
|
||||
}
|
||||
function BackPageIconDefault() {
|
||||
return _span4 || (_span4 = /*#__PURE__*/_jsx("span", {
|
||||
children: '⇽'
|
||||
}));
|
||||
}
|
||||
function defaultGetAriaLabel(type) {
|
||||
return `Go to ${type} page`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
const TablePaginationActions = /*#__PURE__*/React.forwardRef(function TablePaginationActions(props, forwardedRef) {
|
||||
var _slots$root, _slots$firstButton, _slots$lastButton, _slots$nextButton, _slots$backButton, _slots$lastPageIcon, _slots$firstPageIcon, _slots$nextPageIcon, _slots$backPageIcon;
|
||||
const {
|
||||
count,
|
||||
getItemAriaLabel = defaultGetAriaLabel,
|
||||
onPageChange,
|
||||
page,
|
||||
rowsPerPage,
|
||||
showFirstButton = false,
|
||||
showLastButton = false,
|
||||
direction
|
||||
// @ts-ignore
|
||||
,
|
||||
|
||||
slotProps = {},
|
||||
slots = {}
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = props;
|
||||
const handleFirstPageButtonClick = event => {
|
||||
onPageChange(event, 0);
|
||||
};
|
||||
const handleBackButtonClick = event => {
|
||||
onPageChange(event, page - 1);
|
||||
};
|
||||
const handleNextButtonClick = event => {
|
||||
onPageChange(event, page + 1);
|
||||
};
|
||||
const handleLastPageButtonClick = event => {
|
||||
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
|
||||
};
|
||||
const Root = (_slots$root = slots.root) != null ? _slots$root : 'div';
|
||||
const rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState
|
||||
});
|
||||
const FirstButton = (_slots$firstButton = slots.firstButton) != null ? _slots$firstButton : 'button';
|
||||
const firstButtonProps = useSlotProps({
|
||||
elementType: FirstButton,
|
||||
externalSlotProps: slotProps.firstButton,
|
||||
additionalProps: {
|
||||
onClick: handleFirstPageButtonClick,
|
||||
disabled: page === 0,
|
||||
'aria-label': getItemAriaLabel('first', page),
|
||||
title: getItemAriaLabel('first', page)
|
||||
},
|
||||
ownerState
|
||||
});
|
||||
const LastButton = (_slots$lastButton = slots.lastButton) != null ? _slots$lastButton : 'button';
|
||||
const lastButtonProps = useSlotProps({
|
||||
elementType: LastButton,
|
||||
externalSlotProps: slotProps.lastButton,
|
||||
additionalProps: {
|
||||
onClick: handleLastPageButtonClick,
|
||||
disabled: page >= Math.ceil(count / rowsPerPage) - 1,
|
||||
'aria-label': getItemAriaLabel('last', page),
|
||||
title: getItemAriaLabel('last', page)
|
||||
},
|
||||
ownerState
|
||||
});
|
||||
const NextButton = (_slots$nextButton = slots.nextButton) != null ? _slots$nextButton : 'button';
|
||||
const nextButtonProps = useSlotProps({
|
||||
elementType: NextButton,
|
||||
externalSlotProps: slotProps.nextButton,
|
||||
additionalProps: {
|
||||
onClick: handleNextButtonClick,
|
||||
disabled: count !== -1 ? page >= Math.ceil(count / rowsPerPage) - 1 : false,
|
||||
'aria-label': getItemAriaLabel('next', page),
|
||||
title: getItemAriaLabel('next', page)
|
||||
},
|
||||
ownerState
|
||||
});
|
||||
const BackButton = (_slots$backButton = slots.backButton) != null ? _slots$backButton : 'button';
|
||||
const backButtonProps = useSlotProps({
|
||||
elementType: BackButton,
|
||||
externalSlotProps: slotProps.backButton,
|
||||
additionalProps: {
|
||||
onClick: handleBackButtonClick,
|
||||
disabled: page === 0,
|
||||
'aria-label': getItemAriaLabel('previous', page),
|
||||
title: getItemAriaLabel('previous', page)
|
||||
},
|
||||
ownerState
|
||||
});
|
||||
const LastPageIcon = (_slots$lastPageIcon = slots.lastPageIcon) != null ? _slots$lastPageIcon : LastPageIconDefault;
|
||||
const FirstPageIcon = (_slots$firstPageIcon = slots.firstPageIcon) != null ? _slots$firstPageIcon : FirstPageIconDefault;
|
||||
const NextPageIcon = (_slots$nextPageIcon = slots.nextPageIcon) != null ? _slots$nextPageIcon : NextPageIconDefault;
|
||||
const BackPageIcon = (_slots$backPageIcon = slots.backPageIcon) != null ? _slots$backPageIcon : BackPageIconDefault;
|
||||
return /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
|
||||
children: [showFirstButton && /*#__PURE__*/_jsx(FirstButton, _extends({}, firstButtonProps, {
|
||||
children: direction === 'rtl' ? /*#__PURE__*/_jsx(LastPageIcon, {}) : /*#__PURE__*/_jsx(FirstPageIcon, {})
|
||||
})), /*#__PURE__*/_jsx(BackButton, _extends({}, backButtonProps, {
|
||||
children: direction === 'rtl' ? /*#__PURE__*/_jsx(NextPageIcon, {}) : /*#__PURE__*/_jsx(BackPageIcon, {})
|
||||
})), /*#__PURE__*/_jsx(NextButton, _extends({}, nextButtonProps, {
|
||||
children: direction === 'rtl' ? /*#__PURE__*/_jsx(BackPageIcon, {}) : /*#__PURE__*/_jsx(NextPageIcon, {})
|
||||
})), showLastButton && /*#__PURE__*/_jsx(LastButton, _extends({}, lastButtonProps, {
|
||||
children: direction === 'rtl' ? /*#__PURE__*/_jsx(FirstPageIcon, {}) : /*#__PURE__*/_jsx(LastPageIcon, {})
|
||||
}))]
|
||||
}));
|
||||
});
|
||||
export { TablePaginationActions };
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
import * as React from 'react';
|
||||
import { PolymorphicProps, SlotComponentProps } from '../utils';
|
||||
export interface TablePaginationActionsRootSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationActionsFirstButtonSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationActionsLastButtonSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationActionsNextButtonSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationActionsBackButtonSlotPropsOverrides {
|
||||
}
|
||||
export interface TablePaginationActionsOwnProps {
|
||||
count: number;
|
||||
/**
|
||||
* The components used for each slot inside the TablePagination.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots?: TablePaginationActionsSlots;
|
||||
/**
|
||||
* The props used for each slot inside the TablePagination.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: {
|
||||
root?: SlotComponentProps<'div', TablePaginationActionsRootSlotPropsOverrides, TablePaginationActionsOwnerState>;
|
||||
firstButton?: SlotComponentProps<'button', TablePaginationActionsFirstButtonSlotPropsOverrides, TablePaginationActionsOwnerState>;
|
||||
lastButton?: SlotComponentProps<'button', TablePaginationActionsLastButtonSlotPropsOverrides, TablePaginationActionsOwnerState>;
|
||||
nextButton?: SlotComponentProps<'button', TablePaginationActionsNextButtonSlotPropsOverrides, TablePaginationActionsOwnerState>;
|
||||
backButton?: SlotComponentProps<'button', TablePaginationActionsBackButtonSlotPropsOverrides, TablePaginationActionsOwnerState>;
|
||||
};
|
||||
/**
|
||||
* Direction of the text.
|
||||
* @default 'ltr'
|
||||
*/
|
||||
direction?: 'ltr' | 'rtl';
|
||||
/**
|
||||
* Accepts a function which returns a string value that provides a user-friendly name for the current page.
|
||||
* This is important for screen reader users.
|
||||
*
|
||||
* For localization purposes, you can use the provided [translations](/material-ui/guides/localization/).
|
||||
* @param {string} type The link or button type to format ('first' | 'last' | 'next' | 'previous').
|
||||
* @returns {string}
|
||||
*/
|
||||
getItemAriaLabel: (type: 'first' | 'last' | 'next' | 'previous', page: number) => string;
|
||||
onPageChange: (event: React.MouseEvent<HTMLButtonElement> | null, page: number) => void;
|
||||
page: number;
|
||||
rowsPerPage: number;
|
||||
showFirstButton: boolean;
|
||||
showLastButton: boolean;
|
||||
}
|
||||
export interface TablePaginationActionsSlots {
|
||||
/**
|
||||
* The component that renders the root.
|
||||
* @default 'div'
|
||||
*/
|
||||
root?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the first button.
|
||||
* @default 'button'
|
||||
*/
|
||||
firstButton?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the last button.
|
||||
* @default 'button'
|
||||
*/
|
||||
lastButton?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the next button.
|
||||
* @default 'button'
|
||||
*/
|
||||
nextButton?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the back button.
|
||||
* @default 'button'
|
||||
*/
|
||||
backButton?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the first page icon.
|
||||
* @default FirstPageIconDefault
|
||||
*/
|
||||
firstPageIcon?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the last page icon.
|
||||
* @default LastPageIconDefault
|
||||
*/
|
||||
lastPageIcon?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the next page icon.
|
||||
* @default NextPageIconDefault
|
||||
*/
|
||||
nextPageIcon?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the back page icon.
|
||||
* @default BackPageIconDefault
|
||||
*/
|
||||
backPageIcon?: React.ElementType;
|
||||
}
|
||||
export type TablePaginationActionsProps<RootComponentType extends React.ElementType = TablePaginationActionsTypeMap['defaultComponent']> = PolymorphicProps<TablePaginationActionsTypeMap<{}, RootComponentType>, RootComponentType>;
|
||||
export interface TablePaginationActionsTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'button'> {
|
||||
props: TablePaginationActionsOwnProps & AdditionalProps;
|
||||
defaultComponent: RootComponentType;
|
||||
}
|
||||
export type TablePaginationActionsOwnerState = TablePaginationActionsOwnProps;
|
||||
export type TablePaginationActionsRootSlotProps = {
|
||||
children?: React.ReactNode;
|
||||
ownerState: TablePaginationActionsOwnerState;
|
||||
ref: React.Ref<any>;
|
||||
};
|
||||
export type TablePaginationActionsButtonSlotProps = {
|
||||
'aria-label': string;
|
||||
children?: React.ReactNode;
|
||||
disabled: boolean;
|
||||
onClick: React.MouseEventHandler<HTMLButtonElement>;
|
||||
ownerState: TablePaginationActionsOwnerState;
|
||||
title: string;
|
||||
};
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+1
@@ -0,0 +1 @@
|
||||
export type ItemAriaLabelType = 'first' | 'last' | 'next' | 'previous';
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
export { TablePagination } from './TablePagination';
|
||||
export * from './TablePagination.types';
|
||||
export { TablePaginationActions } from './TablePaginationActions';
|
||||
export * from './TablePaginationActions.types';
|
||||
export * from './tablePaginationClasses';
|
||||
export * from './common.types';
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
'use client';
|
||||
|
||||
export { TablePagination } from './TablePagination';
|
||||
export * from './TablePagination.types';
|
||||
export { TablePaginationActions } from './TablePaginationActions';
|
||||
export * from './TablePaginationActions.types';
|
||||
export * from './tablePaginationClasses';
|
||||
export * from './common.types';
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sideEffects": false,
|
||||
"module": "./index.js",
|
||||
"main": "../node/TablePagination/index.js",
|
||||
"types": "./index.d.ts"
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
export interface TablePaginationClasses {
|
||||
/** Class name applied to the root element. */
|
||||
root: string;
|
||||
/** Class name applied to the Toolbar component. */
|
||||
toolbar: string;
|
||||
/** Class name applied to the spacer element. */
|
||||
spacer: string;
|
||||
/** Class name applied to the select label Typography element. */
|
||||
selectLabel: string;
|
||||
/** Class name applied to the Select component `root` element. */
|
||||
selectRoot: string;
|
||||
/** Class name applied to the Select component `select` class. */
|
||||
select: string;
|
||||
/** Class name applied to the Select component `icon` class. */
|
||||
selectIcon: string;
|
||||
/** Class name applied to the Select component `root` element. */
|
||||
input: string;
|
||||
/** Class name applied to the MenuItem component. */
|
||||
menuItem: string;
|
||||
/** Class name applied to the displayed rows Typography element. */
|
||||
displayedRows: string;
|
||||
/** Class name applied to the internal `TablePaginationActions` component. */
|
||||
actions: string;
|
||||
}
|
||||
export type TablePaginationClassKey = keyof TablePaginationClasses;
|
||||
export declare function getTablePaginationUtilityClass(slot: string): string;
|
||||
export declare const tablePaginationClasses: TablePaginationClasses;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
const COMPONENT_NAME = 'TablePagination';
|
||||
export function getTablePaginationUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export const tablePaginationClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'toolbar', 'spacer', 'selectLabel', 'selectRoot', 'select', 'selectIcon', 'input', 'menuItem', 'displayedRows', 'actions']);
|
||||
Reference in new issue
Block a user