@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
1 lines • 2.2 kB
Source Map (JSON)
{"version":3,"file":"PaginationLabel.cjs","names":["factory","useProps","usePaginationContext","Box","classes"],"sources":["../../../../src/components/Pagination/PaginationLabel/PaginationLabel.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n CompoundStylesApiProps,\n ElementProps,\n factory,\n Factory,\n useProps,\n} from '../../../core';\nimport { usePaginationContext } from '../Pagination.context';\nimport classes from '../Pagination.module.css';\n\nexport type PaginationFormatLabel = (input: { page: number; totalPages: number }) => string;\nexport type PaginationLabelStylesNames = 'label';\n\nexport interface PaginationLabelProps\n extends BoxProps, CompoundStylesApiProps<PaginationLabelFactory>, ElementProps<'div'> {\n /** Function to format the label text */\n formatLabel?: PaginationFormatLabel;\n}\n\nexport type PaginationLabelFactory = Factory<{\n props: PaginationLabelProps;\n ref: HTMLDivElement;\n stylesNames: PaginationLabelStylesNames;\n compound: true;\n}>;\n\nconst defaultProps = {\n formatLabel: ({ page, totalPages }) => `Page ${page} of ${totalPages}`,\n} satisfies Partial<PaginationLabelProps>;\n\nexport const PaginationLabel = factory<PaginationLabelFactory>((_props) => {\n const props = useProps('PaginationLabel', defaultProps, _props);\n const { classNames, className, style, styles, vars, formatLabel, ...others } = props;\n const ctx = usePaginationContext();\n\n return (\n <Box {...ctx.getStyles('label', { className, style, styles, classNames })} {...others}>\n {formatLabel({ page: ctx.active, totalPages: ctx.total })}\n </Box>\n );\n});\n\nPaginationLabel.classes = classes;\nPaginationLabel.displayName = '@mantine/core/PaginationLabel';\n"],"mappings":";;;;;;;;AA4BA,MAAM,eAAe,EACnB,cAAc,EAAE,MAAM,iBAAiB,QAAQ,KAAK,MAAM,aAC5D;AAEA,MAAa,kBAAkBA,gBAAAA,SAAiC,WAAW;CAEzE,MAAM,EAAE,YAAY,WAAW,OAAO,QAAQ,MAAM,aAAa,GAAG,WADtDC,kBAAAA,SAAS,mBAAmB,cAAc,MAC2B;CACnF,MAAM,MAAMC,2BAAAA,qBAAqB;CAEjC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,YAAAA,KAAD;EAAK,GAAI,IAAI,UAAU,SAAS;GAAE;GAAW;GAAO;GAAQ;EAAW,CAAC;EAAG,GAAI;YAC5E,YAAY;GAAE,MAAM,IAAI;GAAQ,YAAY,IAAI;EAAM,CAAC;CACrD,CAAA;AAET,CAAC;AAED,gBAAgB,UAAUC,0BAAAA;AAC1B,gBAAgB,cAAc"}