@amaui/ui-react
Version:
UI for React
73 lines • 3.51 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
const _excluded = ["tonal", "color", "version", "elevation", "size", "TypeProps", "className", "children"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
import React from 'react';
import { is } from '@amaui/utils';
import { classNames, style as styleMethod, useAmauiTheme } from '@amaui/style-react';
import TypeElement from '../Type';
import ButtonElement from '../Button';
import { staticClassName } from '../utils';
const useStyle = styleMethod(theme => ({
root: {},
size_small: {
'&.amaui-Button-root': {
width: 'unset',
minWidth: '30px',
paddingInline: theme.methods.space.value(0.5, 'px')
}
},
size_regular: {
'&.amaui-Button-root': {
width: 'unset',
minWidth: '40px',
paddingInline: theme.methods.space.value(1, 'px')
}
},
size_large: {
'&.amaui-Button-root': {
width: 'unset',
minWidth: '50px',
paddingInline: theme.methods.space.value(1.25, 'px')
}
}
}), {
name: 'amaui-PaginationItem'
});
const PaginationItem = /*#__PURE__*/React.forwardRef((props_, ref) => {
const theme = useAmauiTheme();
const props = React.useMemo(() => _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.amauiPaginationItem?.props?.default), props_), [props_]);
const Button = React.useMemo(() => theme?.elements?.Button || ButtonElement, [theme]);
const Type = React.useMemo(() => theme?.elements?.Type || TypeElement, [theme]);
const {
tonal = false,
color = 'default',
version = 'text',
elevation = false,
size = 'regular',
TypeProps,
className,
children
} = props,
other = _objectWithoutProperties(props, _excluded);
const {
classes
} = useStyle();
return /*#__PURE__*/React.createElement(Button, _extends({
ref: ref,
tonal: tonal,
color: color,
version: version,
elevation: elevation,
size: size,
icon: true,
noFontSize: true,
className: classNames([staticClassName('PaginationItem', theme) && ['amaui-PaginationItem-root', `amaui-PaginationItem-version-${version}`, `amaui-PaginationItem-size-${size}`], className, classes.root, classes[`size_${size}`]])
}, other), is('simple', children) ? /*#__PURE__*/React.createElement(Type, _extends({
version: size === 'large' ? 'b1' : size === 'regular' ? 'b2' : 'b3'
}, TypeProps), children) : children);
});
PaginationItem.displayName = 'amaui-PaginationItem';
export default PaginationItem;