@cognite/aura 1.48565.0 → 1.48644.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/README.md +9 -6
- package/dist/components/ui/core/data-grid/data-grid-column-filter.d.ts +10 -2
- package/dist/components/ui/core/data-grid/data-grid-column-filter.js +11 -1
- package/dist/components/ui/core/data-grid/data-grid-column-filter.js.map +1 -1
- package/dist/components/ui/core/data-grid/data-grid-column-menu.d.ts +22 -0
- package/dist/components/ui/core/data-grid/data-grid-column-menu.js +92 -0
- package/dist/components/ui/core/data-grid/data-grid-column-menu.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid-header-row.d.ts +5 -1
- package/dist/components/ui/core/data-grid/data-grid-header-row.js +47 -6
- package/dist/components/ui/core/data-grid/data-grid-header-row.js.map +1 -1
- package/dist/components/ui/core/data-grid/data-grid-pagination.d.ts +18 -0
- package/dist/components/ui/core/data-grid/data-grid-pagination.js +82 -0
- package/dist/components/ui/core/data-grid/data-grid-pagination.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid.d.ts +17 -1
- package/dist/components/ui/core/data-grid/data-grid.js +49 -6
- package/dist/components/ui/core/data-grid/data-grid.js.map +1 -1
- package/dist/components/ui/core/data-grid/index.d.ts +3 -1
- package/dist/components/ui/core/data-grid/index.js +1 -0
- package/dist/components/ui/core/data-grid/index.js.map +1 -1
- package/dist/components/ui/core/pagination/pagination-pages.d.ts +9 -0
- package/dist/components/ui/core/pagination/pagination-pages.js +59 -0
- package/dist/components/ui/core/pagination/pagination-pages.js.map +1 -0
- package/dist/components/ui/core/pagination/pagination.d.ts +6 -0
- package/dist/components/ui/core/pagination/pagination.js.map +1 -1
- package/dist/components/ui/core/pagination/pagination.utils.d.ts +2 -0
- package/dist/components/ui/core/pagination/pagination.utils.js +34 -0
- package/dist/components/ui/core/pagination/pagination.utils.js.map +1 -0
- package/dist/components/ui/core/toggle/count-badge.d.ts +7 -0
- package/dist/components/ui/core/toggle/count-badge.js +13 -0
- package/dist/components/ui/core/toggle/count-badge.js.map +1 -0
- package/dist/components/ui/core/toggle/toggle.js +6 -12
- package/dist/components/ui/core/toggle/toggle.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/ui/core/pagination/pagination.tsx"],"sourcesContent":["import {\n type ForwardRefExoticComponent,\n type RefAttributes,\n type ComponentProps,\n type ComponentRef,\n type MouseEvent,\n type ReactNode,\n forwardRef,\n} from 'react';\n\nimport type { SelectTriggerProps } from '@base-ui/react';\nimport {\n IconChevronLeft,\n IconChevronRight,\n IconChevronsLeft,\n IconChevronsRight,\n IconDots,\n} from '@tabler/icons-react';\nimport { cva } from 'class-variance-authority';\n\nimport { cn } from '../../../../lib/utils';\nimport { Button } from '../button/button';\nimport { SelectTrigger } from '../select/select';\nimport { StatusText } from '../status-text/status-text';\n\nimport {\n type PaginationSize,\n PaginationSizeContext,\n usePaginationSize,\n} from './pagination-size-context';\nimport { PaginationTeleport } from './pagination-teleport';\n\nconst paginationLinkVariants = cva(\n 'border border-transparent text-base font-normal leading-5 tracking-tightest focus-visible:shadow-focus-ring',\n {\n variants: {\n size: {\n default: '',\n small: 'text-sm leading-4.5 tracking-tight',\n },\n active: {\n true: '',\n false: '',\n },\n },\n compoundVariants: [\n {\n active: false,\n className:\n 'text-medium-foreground hover:bg-base-background-hover hover:text-base-foreground focus-visible:bg-medium-background focus-visible:text-base-foreground',\n },\n {\n active: true,\n className:\n 'border-emphasized bg-secondary-background text-secondary-foreground hover:bg-base-background-hover hover:text-secondary-foreground focus-visible:bg-secondary-background focus-visible:text-secondary-foreground',\n },\n ],\n defaultVariants: {\n size: 'default',\n active: false,\n },\n }\n);\n\nconst paginationEllipsisVariants = cva(\n 'flex items-center justify-center text-medium-foreground',\n {\n variants: {\n size: {\n default: 'h-9 w-9',\n small: 'h-7 w-7',\n },\n },\n defaultVariants: {\n size: 'default',\n },\n }\n);\n\nconst paginationSelectTriggerVariants = cva(\n 'w-auto whitespace-nowrap min-h-0',\n {\n variants: {\n size: {\n default: 'h-9 gap-2 rounded-lg px-3 min-w-19',\n sm: 'h-7 gap-1.5 rounded-md px-2 min-w-16',\n },\n },\n defaultVariants: {\n size: 'default',\n },\n }\n);\n\nconst ICON_BUTTON_WIDTH_BY_SIZE: Record<PaginationSize, string> = {\n small: 'max-w-7',\n default: 'max-w-9',\n};\n\nconst TEXT_LINK_WIDTH_BY_SIZE: Record<PaginationSize, string> = {\n small: 'min-w-7',\n default: 'min-w-9',\n};\n\ntype PaginationButtonSize = 'default' | 'sm';\ntype PaginationRadiusClass = 'rounded-md' | 'rounded-lg';\n\nconst getPaginationButtonStyles = (size: PaginationSize = 'default') => {\n const buttonSize: PaginationButtonSize = size === 'small' ? 'sm' : 'default';\n const radiusClass: PaginationRadiusClass =\n size === 'small' ? 'rounded-md' : 'rounded-lg';\n const iconButtonWidth = ICON_BUTTON_WIDTH_BY_SIZE[size];\n const textLinkWidth = TEXT_LINK_WIDTH_BY_SIZE[size];\n\n return {\n buttonSize,\n radiusClass,\n iconButtonWidth,\n textLinkWidth,\n };\n};\n\nconst Pagination: ForwardRefExoticComponent<\n Omit<\n ComponentProps<'nav'> & {\n size?: PaginationSize;\n },\n 'ref'\n > &\n RefAttributes<HTMLElement>\n> = forwardRef<\n ComponentRef<'nav'>,\n ComponentProps<'nav'> & { size?: PaginationSize }\n>(({ className, size = 'default', ...props }, ref) => {\n return (\n <PaginationSizeContext.Provider value={size}>\n <nav\n ref={ref}\n aria-label=\"pagination\"\n data-slot=\"pagination\"\n className={cn('mx-auto flex w-full justify-center gap-2', className)}\n {...props}\n />\n </PaginationSizeContext.Provider>\n );\n});\nPagination.displayName = 'Pagination';\n\nconst PaginationContent: ForwardRefExoticComponent<\n Omit<\n ComponentProps<'ul'> & {\n size?: PaginationSize;\n },\n 'ref'\n > &\n RefAttributes<HTMLUListElement>\n> = forwardRef<\n ComponentRef<'ul'>,\n ComponentProps<'ul'> & { size?: PaginationSize }\n>(({ className, size, ...props }, ref) => {\n const inheritedSize = usePaginationSize();\n const resolvedSize = size ?? inheritedSize;\n return (\n <PaginationSizeContext.Provider value={resolvedSize}>\n <ul\n ref={ref}\n data-slot=\"pagination-content\"\n data-size={resolvedSize}\n className={cn('flex flex-row items-center gap-1', className)}\n {...props}\n />\n </PaginationSizeContext.Provider>\n );\n});\nPaginationContent.displayName = 'PaginationContent';\n\nconst PaginationItem: ForwardRefExoticComponent<\n ComponentProps<'li'> & RefAttributes<HTMLLIElement>\n> = forwardRef<ComponentRef<'li'>, ComponentProps<'li'>>((props, ref) => {\n return <li ref={ref} data-slot=\"pagination-item\" {...props} />;\n});\nPaginationItem.displayName = 'PaginationItem';\n\nconst PaginationStatus: ForwardRefExoticComponent<\n ComponentProps<'output'> & RefAttributes<HTMLOutputElement>\n> = forwardRef<ComponentRef<'output'>, ComponentProps<'output'>>(\n (props, ref) => {\n return <StatusText ref={ref} data-slot=\"pagination-status\" {...props} />;\n }\n);\nPaginationStatus.displayName = 'PaginationStatus';\n\nconst PaginationSelectTrigger: ForwardRefExoticComponent<\n Omit<\n SelectTriggerProps & {\n size?: 'sm' | 'default';\n errorMessage?: string;\n },\n 'ref'\n > &\n RefAttributes<HTMLButtonElement>\n> = forwardRef<\n ComponentRef<typeof SelectTrigger>,\n ComponentProps<typeof SelectTrigger>\n>(({ className, size, style, ...props }, ref) => {\n const inheritedSize = usePaginationSize();\n const isPaginationSmall = inheritedSize === 'small' && size === undefined;\n const resolvedSize = size ?? (isPaginationSmall ? 'sm' : 'default');\n\n return (\n <SelectTrigger\n ref={ref}\n size={resolvedSize}\n data-slot=\"pagination-select-trigger\"\n style={style}\n className={cn(\n paginationSelectTriggerVariants({ size: resolvedSize }),\n className\n )}\n {...props}\n />\n );\n});\nPaginationSelectTrigger.displayName = 'PaginationSelectTrigger';\n\ntype PaginationLinkProps = {\n isActive?: boolean;\n isDisabled?: boolean;\n size?: PaginationSize;\n} & ComponentProps<'a'>;\n\nconst PaginationLink: ForwardRefExoticComponent<\n Omit<PaginationLinkProps, 'ref'> & RefAttributes<HTMLAnchorElement>\n> = forwardRef<ComponentRef<'a'>, PaginationLinkProps>(\n (\n { children, className, isActive, isDisabled, onClick, size, ...props },\n ref\n ) => {\n const inheritedSize = usePaginationSize();\n const resolvedSize = size ?? inheritedSize;\n const { buttonSize, radiusClass, textLinkWidth } =\n getPaginationButtonStyles(resolvedSize);\n const handleClick = (event: MouseEvent<HTMLAnchorElement>) => {\n if (isDisabled) {\n event.preventDefault();\n return;\n }\n\n onClick?.(event);\n };\n\n return (\n <Button\n variant=\"ghost\"\n size={buttonSize}\n data-slot=\"pagination-link\"\n data-active={isActive}\n className={cn(\n radiusClass,\n textLinkWidth,\n paginationLinkVariants({ size: resolvedSize, active: isActive }),\n isDisabled && 'pointer-events-none text-base-foreground-disabled',\n className\n )}\n render={\n <a\n ref={ref}\n aria-current={isActive ? 'page' : undefined}\n aria-disabled={isDisabled || undefined}\n onClick={handleClick}\n tabIndex={isDisabled ? -1 : undefined}\n {...props}\n >\n {children}\n </a>\n }\n />\n );\n }\n);\nPaginationLink.displayName = 'PaginationLink';\n\ntype PaginationIconLinkProps = {\n ariaLabel: string;\n dataSlot: string;\n icon: ReactNode;\n isDisabled?: boolean;\n size?: PaginationSize;\n} & Omit<ComponentProps<'a'>, 'children'>;\n\nconst PaginationIconLink = forwardRef<\n ComponentRef<'a'>,\n PaginationIconLinkProps\n>(\n (\n {\n ariaLabel,\n className,\n dataSlot,\n icon,\n isDisabled,\n onClick,\n size,\n ...linkProps\n },\n ref\n ) => {\n const inheritedSize = usePaginationSize();\n const resolvedSize = size ?? inheritedSize;\n const { buttonSize, radiusClass, iconButtonWidth } =\n getPaginationButtonStyles(resolvedSize);\n const handleClick = (event: MouseEvent<HTMLAnchorElement>) => {\n if (isDisabled) {\n event.preventDefault();\n return;\n }\n\n onClick?.(event);\n };\n\n return (\n <Button\n variant=\"ghost\"\n size={buttonSize}\n data-slot={dataSlot}\n className={cn(\n radiusClass,\n iconButtonWidth,\n paginationLinkVariants({ size: resolvedSize, active: false }),\n isDisabled && 'pointer-events-none text-base-foreground-disabled',\n className\n )}\n render={\n <a\n ref={ref}\n aria-label={ariaLabel}\n aria-disabled={isDisabled || undefined}\n onClick={handleClick}\n tabIndex={isDisabled ? -1 : undefined}\n {...linkProps}\n >\n {icon}\n </a>\n }\n />\n );\n }\n);\nPaginationIconLink.displayName = 'PaginationIconLink';\n\nconst PaginationFirst: ForwardRefExoticComponent<\n Omit<\n Omit<PaginationLinkProps, 'isActive'> & {\n label?: string;\n },\n 'ref'\n > &\n RefAttributes<HTMLAnchorElement>\n> = forwardRef<\n ComponentRef<'a'>,\n Omit<PaginationLinkProps, 'isActive'> & { label?: string }\n>(({ className, size, label = 'Go to first page', ...props }, ref) => {\n return (\n <PaginationIconLink\n ref={ref}\n dataSlot=\"pagination-first\"\n ariaLabel={label}\n icon={<IconChevronsLeft />}\n className={className}\n size={size}\n {...props}\n />\n );\n});\nPaginationFirst.displayName = 'PaginationFirst';\n\nconst PaginationPrevious: ForwardRefExoticComponent<\n Omit<\n Omit<PaginationLinkProps, 'isActive'> & {\n label?: string;\n },\n 'ref'\n > &\n RefAttributes<HTMLAnchorElement>\n> = forwardRef<\n ComponentRef<'a'>,\n Omit<PaginationLinkProps, 'isActive'> & { label?: string }\n>(({ className, size, label = 'Go to previous page', ...props }, ref) => {\n return (\n <PaginationIconLink\n ref={ref}\n dataSlot=\"pagination-previous\"\n ariaLabel={label}\n icon={<IconChevronLeft />}\n className={className}\n size={size}\n {...props}\n />\n );\n});\nPaginationPrevious.displayName = 'PaginationPrevious';\n\nconst PaginationNext: ForwardRefExoticComponent<\n Omit<\n Omit<PaginationLinkProps, 'isActive'> & {\n label?: string;\n },\n 'ref'\n > &\n RefAttributes<HTMLAnchorElement>\n> = forwardRef<\n ComponentRef<'a'>,\n Omit<PaginationLinkProps, 'isActive'> & { label?: string }\n>(({ className, size, label = 'Go to next page', ...props }, ref) => {\n return (\n <PaginationIconLink\n ref={ref}\n dataSlot=\"pagination-next\"\n ariaLabel={label}\n icon={<IconChevronRight />}\n className={className}\n size={size}\n {...props}\n />\n );\n});\nPaginationNext.displayName = 'PaginationNext';\n\nconst PaginationLast: ForwardRefExoticComponent<\n Omit<\n Omit<PaginationLinkProps, 'isActive'> & {\n label?: string;\n },\n 'ref'\n > &\n RefAttributes<HTMLAnchorElement>\n> = forwardRef<\n ComponentRef<'a'>,\n Omit<PaginationLinkProps, 'isActive'> & { label?: string }\n>(({ className, size, label = 'Go to last page', ...props }, ref) => {\n return (\n <PaginationIconLink\n ref={ref}\n dataSlot=\"pagination-last\"\n ariaLabel={label}\n icon={<IconChevronsRight />}\n className={className}\n size={size}\n {...props}\n />\n );\n});\nPaginationLast.displayName = 'PaginationLast';\n\nconst PaginationEllipsis: ForwardRefExoticComponent<\n Omit<\n ComponentProps<'span'> & {\n size?: PaginationSize;\n label?: string;\n },\n 'ref'\n > &\n RefAttributes<HTMLSpanElement>\n> = forwardRef<\n ComponentRef<'span'>,\n ComponentProps<'span'> & { size?: PaginationSize; label?: string }\n>(({ className, size, label = 'More pages', ...props }, ref) => {\n const inheritedSize = usePaginationSize();\n const resolvedSize = size ?? inheritedSize;\n const { iconButtonWidth } = getPaginationButtonStyles(resolvedSize);\n\n return (\n <span\n ref={ref}\n data-slot=\"pagination-ellipsis\"\n className={cn(\n iconButtonWidth,\n paginationEllipsisVariants({ size: resolvedSize }),\n className\n )}\n {...props}\n >\n <IconDots aria-hidden=\"true\" className=\"h-4 w-4\" />\n <span className=\"sr-only\">{label}</span>\n </span>\n );\n});\nPaginationEllipsis.displayName = 'PaginationEllipsis';\n\nconst PaginationResultsPerPage: ForwardRefExoticComponent<\n ComponentProps<'li'> & RefAttributes<HTMLLIElement>\n> = forwardRef<ComponentRef<'li'>, ComponentProps<'li'>>(\n ({ className, ...props }, ref) => {\n return (\n <li\n ref={ref}\n data-slot=\"pagination-results-per-page\"\n className={cn('flex items-center gap-2 pl-3', className)}\n {...props}\n />\n );\n }\n);\nPaginationResultsPerPage.displayName = 'PaginationResultsPerPage';\n\nconst PaginationResultsPerPageLabel: ForwardRefExoticComponent<\n ComponentProps<'span'> & RefAttributes<HTMLSpanElement>\n> = forwardRef<ComponentRef<'span'>, ComponentProps<'span'>>(\n ({ className, ...props }, ref) => {\n return (\n <span\n ref={ref}\n data-slot=\"pagination-results-per-page-label\"\n className={cn(\n 'text-sm leading-4.5 tracking-tight font-normal text-muted-foreground',\n className\n )}\n {...props}\n />\n );\n }\n);\nPaginationResultsPerPageLabel.displayName = 'PaginationResultsPerPageLabel';\n\nexport {\n Pagination,\n PaginationContent,\n PaginationEllipsis,\n PaginationFirst,\n PaginationItem,\n PaginationLast,\n PaginationLink,\n PaginationNext,\n PaginationPrevious,\n PaginationResultsPerPage,\n PaginationResultsPerPageLabel,\n PaginationSelectTrigger,\n PaginationStatus,\n PaginationTeleport,\n};\n"],"names":["forwardRef","IconChevronLeft","IconChevronRight","IconChevronsLeft","IconChevronsRight","IconDots","cva","cn","Button","SelectTrigger","StatusText","PaginationSizeContext","usePaginationSize","PaginationTeleport","paginationLinkVariants","variants","size","default","small","active","true","false","compoundVariants","className","defaultVariants","paginationEllipsisVariants","paginationSelectTriggerVariants","sm","ICON_BUTTON_WIDTH_BY_SIZE","TEXT_LINK_WIDTH_BY_SIZE","getPaginationButtonStyles","buttonSize","radiusClass","iconButtonWidth","textLinkWidth","Pagination","props","ref","Provider","value","nav","aria-label","data-slot","displayName","PaginationContent","inheritedSize","resolvedSize","ul","data-size","PaginationItem","li","PaginationStatus","PaginationSelectTrigger","style","isPaginationSmall","undefined","PaginationLink","children","isActive","isDisabled","onClick","handleClick","event","preventDefault","variant","data-active","render","a","aria-current","aria-disabled","tabIndex","PaginationIconLink","ariaLabel","dataSlot","icon","linkProps","PaginationFirst","label","PaginationPrevious","PaginationNext","PaginationLast","PaginationEllipsis","span","aria-hidden","PaginationResultsPerPage","PaginationResultsPerPageLabel"],"mappings":";AAAA,SAOEA,UAAU,QACL,QAAQ;AAGf,SACEC,eAAe,EACfC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,QAAQ,QACH,sBAAsB;AAC7B,SAASC,GAAG,QAAQ,2BAA2B;AAE/C,SAASC,EAAE,QAAQ,2BAAwB;AAC3C,SAASC,MAAM,QAAQ,sBAAmB;AAC1C,SAASC,aAAa,QAAQ,sBAAmB;AACjD,SAASC,UAAU,QAAQ,gCAA6B;AAExD,SAEEC,qBAAqB,EACrBC,iBAAiB,QACZ,+BAA4B;AACnC,SAASC,kBAAkB,QAAQ,2BAAwB;AAE3D,MAAMC,yBAAyBR,IAC7B,+GACA;IACES,UAAU;QACRC,MAAM;YACJC,SAAS;YACTC,OAAO;QACT;QACAC,QAAQ;YACNC,MAAM;YACNC,OAAO;QACT;IACF;IACAC,kBAAkB;QAChB;YACEH,QAAQ;YACRI,WACE;QACJ;QACA;YACEJ,QAAQ;YACRI,WACE;QACJ;KACD;IACDC,iBAAiB;QACfR,MAAM;QACNG,QAAQ;IACV;AACF;AAGF,MAAMM,6BAA6BnB,IACjC,2DACA;IACES,UAAU;QACRC,MAAM;YACJC,SAAS;YACTC,OAAO;QACT;IACF;IACAM,iBAAiB;QACfR,MAAM;IACR;AACF;AAGF,MAAMU,kCAAkCpB,IACtC,oCACA;IACES,UAAU;QACRC,MAAM;YACJC,SAAS;YACTU,IAAI;QACN;IACF;IACAH,iBAAiB;QACfR,MAAM;IACR;AACF;AAGF,MAAMY,4BAA4D;IAChEV,OAAO;IACPD,SAAS;AACX;AAEA,MAAMY,0BAA0D;IAC9DX,OAAO;IACPD,SAAS;AACX;AAKA,MAAMa,4BAA4B,CAACd,OAAuB,SAAS;IACjE,MAAMe,aAAmCf,SAAS,UAAU,OAAO;IACnE,MAAMgB,cACJhB,SAAS,UAAU,eAAe;IACpC,MAAMiB,kBAAkBL,yBAAyB,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WAAWhB,GACT,wEACAgB;QAED,GAAGa,KAAK;;AAGf;AAEFiD,8BAA8B1C,WAAW,GAAG;AAE5C,SACER,UAAU,EACVS,iBAAiB,EACjBqC,kBAAkB,EAClBL,eAAe,EACf3B,cAAc,EACd+B,cAAc,EACdxB,cAAc,EACduB,cAAc,EACdD,kBAAkB,EAClBM,wBAAwB,EACxBC,6BAA6B,EAC7BjC,uBAAuB,EACvBD,gBAAgB,EAChBtC,kBAAkB,GAClB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/pagination/pagination.tsx"],"sourcesContent":["import {\n type ForwardRefExoticComponent,\n type RefAttributes,\n type ComponentProps,\n type ComponentRef,\n type MouseEvent,\n type ReactNode,\n forwardRef,\n} from 'react';\n\nimport type { SelectTriggerProps } from '@base-ui/react';\nimport {\n IconChevronLeft,\n IconChevronRight,\n IconChevronsLeft,\n IconChevronsRight,\n IconDots,\n} from '@tabler/icons-react';\nimport { cva } from 'class-variance-authority';\n\nimport { cn } from '../../../../lib/utils';\nimport { Button } from '../button/button';\nimport { SelectTrigger } from '../select/select';\nimport { StatusText } from '../status-text/status-text';\n\nimport {\n type PaginationSize,\n PaginationSizeContext,\n usePaginationSize,\n} from './pagination-size-context';\nimport { PaginationTeleport } from './pagination-teleport';\n\nexport type PaginationNavLabels = {\n first?: string;\n previous?: string;\n next?: string;\n last?: string;\n};\n\nconst paginationLinkVariants = cva(\n 'border border-transparent text-base font-normal leading-5 tracking-tightest focus-visible:shadow-focus-ring',\n {\n variants: {\n size: {\n default: '',\n small: 'text-sm leading-4.5 tracking-tight',\n },\n active: {\n true: '',\n false: '',\n },\n },\n compoundVariants: [\n {\n active: false,\n className:\n 'text-medium-foreground hover:bg-base-background-hover hover:text-base-foreground focus-visible:bg-medium-background focus-visible:text-base-foreground',\n },\n {\n active: true,\n className:\n 'border-emphasized bg-secondary-background text-secondary-foreground hover:bg-base-background-hover hover:text-secondary-foreground focus-visible:bg-secondary-background focus-visible:text-secondary-foreground',\n },\n ],\n defaultVariants: {\n size: 'default',\n active: false,\n },\n }\n);\n\nconst paginationEllipsisVariants = cva(\n 'flex items-center justify-center text-medium-foreground',\n {\n variants: {\n size: {\n default: 'h-9 w-9',\n small: 'h-7 w-7',\n },\n },\n defaultVariants: {\n size: 'default',\n },\n }\n);\n\nconst paginationSelectTriggerVariants = cva(\n 'w-auto whitespace-nowrap min-h-0',\n {\n variants: {\n size: {\n default: 'h-9 gap-2 rounded-lg px-3 min-w-19',\n sm: 'h-7 gap-1.5 rounded-md px-2 min-w-16',\n },\n },\n defaultVariants: {\n size: 'default',\n },\n }\n);\n\nconst ICON_BUTTON_WIDTH_BY_SIZE: Record<PaginationSize, string> = {\n small: 'max-w-7',\n default: 'max-w-9',\n};\n\nconst TEXT_LINK_WIDTH_BY_SIZE: Record<PaginationSize, string> = {\n small: 'min-w-7',\n default: 'min-w-9',\n};\n\ntype PaginationButtonSize = 'default' | 'sm';\ntype PaginationRadiusClass = 'rounded-md' | 'rounded-lg';\n\nconst getPaginationButtonStyles = (size: PaginationSize = 'default') => {\n const buttonSize: PaginationButtonSize = size === 'small' ? 'sm' : 'default';\n const radiusClass: PaginationRadiusClass =\n size === 'small' ? 'rounded-md' : 'rounded-lg';\n const iconButtonWidth = ICON_BUTTON_WIDTH_BY_SIZE[size];\n const textLinkWidth = TEXT_LINK_WIDTH_BY_SIZE[size];\n\n return {\n buttonSize,\n radiusClass,\n iconButtonWidth,\n textLinkWidth,\n };\n};\n\nconst Pagination: ForwardRefExoticComponent<\n Omit<\n ComponentProps<'nav'> & {\n size?: PaginationSize;\n },\n 'ref'\n > &\n RefAttributes<HTMLElement>\n> = forwardRef<\n ComponentRef<'nav'>,\n ComponentProps<'nav'> & { size?: PaginationSize }\n>(({ className, size = 'default', ...props }, ref) => {\n return (\n <PaginationSizeContext.Provider value={size}>\n <nav\n ref={ref}\n aria-label=\"pagination\"\n data-slot=\"pagination\"\n className={cn('mx-auto flex w-full justify-center gap-2', className)}\n {...props}\n />\n </PaginationSizeContext.Provider>\n );\n});\nPagination.displayName = 'Pagination';\n\nconst PaginationContent: ForwardRefExoticComponent<\n Omit<\n ComponentProps<'ul'> & {\n size?: PaginationSize;\n },\n 'ref'\n > &\n RefAttributes<HTMLUListElement>\n> = forwardRef<\n ComponentRef<'ul'>,\n ComponentProps<'ul'> & { size?: PaginationSize }\n>(({ className, size, ...props }, ref) => {\n const inheritedSize = usePaginationSize();\n const resolvedSize = size ?? inheritedSize;\n return (\n <PaginationSizeContext.Provider value={resolvedSize}>\n <ul\n ref={ref}\n data-slot=\"pagination-content\"\n data-size={resolvedSize}\n className={cn('flex flex-row items-center gap-1', className)}\n {...props}\n />\n </PaginationSizeContext.Provider>\n );\n});\nPaginationContent.displayName = 'PaginationContent';\n\nconst PaginationItem: ForwardRefExoticComponent<\n ComponentProps<'li'> & RefAttributes<HTMLLIElement>\n> = forwardRef<ComponentRef<'li'>, ComponentProps<'li'>>((props, ref) => {\n return <li ref={ref} data-slot=\"pagination-item\" {...props} />;\n});\nPaginationItem.displayName = 'PaginationItem';\n\nconst PaginationStatus: ForwardRefExoticComponent<\n ComponentProps<'output'> & RefAttributes<HTMLOutputElement>\n> = forwardRef<ComponentRef<'output'>, ComponentProps<'output'>>(\n (props, ref) => {\n return <StatusText ref={ref} data-slot=\"pagination-status\" {...props} />;\n }\n);\nPaginationStatus.displayName = 'PaginationStatus';\n\nconst PaginationSelectTrigger: ForwardRefExoticComponent<\n Omit<\n SelectTriggerProps & {\n size?: 'sm' | 'default';\n errorMessage?: string;\n },\n 'ref'\n > &\n RefAttributes<HTMLButtonElement>\n> = forwardRef<\n ComponentRef<typeof SelectTrigger>,\n ComponentProps<typeof SelectTrigger>\n>(({ className, size, style, ...props }, ref) => {\n const inheritedSize = usePaginationSize();\n const isPaginationSmall = inheritedSize === 'small' && size === undefined;\n const resolvedSize = size ?? (isPaginationSmall ? 'sm' : 'default');\n\n return (\n <SelectTrigger\n ref={ref}\n size={resolvedSize}\n data-slot=\"pagination-select-trigger\"\n style={style}\n className={cn(\n paginationSelectTriggerVariants({ size: resolvedSize }),\n className\n )}\n {...props}\n />\n );\n});\nPaginationSelectTrigger.displayName = 'PaginationSelectTrigger';\n\ntype PaginationLinkProps = {\n isActive?: boolean;\n isDisabled?: boolean;\n size?: PaginationSize;\n} & ComponentProps<'a'>;\n\nconst PaginationLink: ForwardRefExoticComponent<\n Omit<PaginationLinkProps, 'ref'> & RefAttributes<HTMLAnchorElement>\n> = forwardRef<ComponentRef<'a'>, PaginationLinkProps>(\n (\n { children, className, isActive, isDisabled, onClick, size, ...props },\n ref\n ) => {\n const inheritedSize = usePaginationSize();\n const resolvedSize = size ?? inheritedSize;\n const { buttonSize, radiusClass, textLinkWidth } =\n getPaginationButtonStyles(resolvedSize);\n const handleClick = (event: MouseEvent<HTMLAnchorElement>) => {\n if (isDisabled) {\n event.preventDefault();\n return;\n }\n\n onClick?.(event);\n };\n\n return (\n <Button\n variant=\"ghost\"\n size={buttonSize}\n data-slot=\"pagination-link\"\n data-active={isActive}\n className={cn(\n radiusClass,\n textLinkWidth,\n paginationLinkVariants({ size: resolvedSize, active: isActive }),\n isDisabled && 'pointer-events-none text-base-foreground-disabled',\n className\n )}\n render={\n <a\n ref={ref}\n aria-current={isActive ? 'page' : undefined}\n aria-disabled={isDisabled || undefined}\n onClick={handleClick}\n tabIndex={isDisabled ? -1 : undefined}\n {...props}\n >\n {children}\n </a>\n }\n />\n );\n }\n);\nPaginationLink.displayName = 'PaginationLink';\n\ntype PaginationIconLinkProps = {\n ariaLabel: string;\n dataSlot: string;\n icon: ReactNode;\n isDisabled?: boolean;\n size?: PaginationSize;\n} & Omit<ComponentProps<'a'>, 'children'>;\n\nconst PaginationIconLink = forwardRef<\n ComponentRef<'a'>,\n PaginationIconLinkProps\n>(\n (\n {\n ariaLabel,\n className,\n dataSlot,\n icon,\n isDisabled,\n onClick,\n size,\n ...linkProps\n },\n ref\n ) => {\n const inheritedSize = usePaginationSize();\n const resolvedSize = size ?? inheritedSize;\n const { buttonSize, radiusClass, iconButtonWidth } =\n getPaginationButtonStyles(resolvedSize);\n const handleClick = (event: MouseEvent<HTMLAnchorElement>) => {\n if (isDisabled) {\n event.preventDefault();\n return;\n }\n\n onClick?.(event);\n };\n\n return (\n <Button\n variant=\"ghost\"\n size={buttonSize}\n data-slot={dataSlot}\n className={cn(\n radiusClass,\n iconButtonWidth,\n paginationLinkVariants({ size: resolvedSize, active: false }),\n isDisabled && 'pointer-events-none text-base-foreground-disabled',\n className\n )}\n render={\n <a\n ref={ref}\n aria-label={ariaLabel}\n aria-disabled={isDisabled || undefined}\n onClick={handleClick}\n tabIndex={isDisabled ? -1 : undefined}\n {...linkProps}\n >\n {icon}\n </a>\n }\n />\n );\n }\n);\nPaginationIconLink.displayName = 'PaginationIconLink';\n\nconst PaginationFirst: ForwardRefExoticComponent<\n Omit<\n Omit<PaginationLinkProps, 'isActive'> & {\n label?: string;\n },\n 'ref'\n > &\n RefAttributes<HTMLAnchorElement>\n> = forwardRef<\n ComponentRef<'a'>,\n Omit<PaginationLinkProps, 'isActive'> & { label?: string }\n>(({ className, size, label = 'Go to first page', ...props }, ref) => {\n return (\n <PaginationIconLink\n ref={ref}\n dataSlot=\"pagination-first\"\n ariaLabel={label}\n icon={<IconChevronsLeft />}\n className={className}\n size={size}\n {...props}\n />\n );\n});\nPaginationFirst.displayName = 'PaginationFirst';\n\nconst PaginationPrevious: ForwardRefExoticComponent<\n Omit<\n Omit<PaginationLinkProps, 'isActive'> & {\n label?: string;\n },\n 'ref'\n > &\n RefAttributes<HTMLAnchorElement>\n> = forwardRef<\n ComponentRef<'a'>,\n Omit<PaginationLinkProps, 'isActive'> & { label?: string }\n>(({ className, size, label = 'Go to previous page', ...props }, ref) => {\n return (\n <PaginationIconLink\n ref={ref}\n dataSlot=\"pagination-previous\"\n ariaLabel={label}\n icon={<IconChevronLeft />}\n className={className}\n size={size}\n {...props}\n />\n );\n});\nPaginationPrevious.displayName = 'PaginationPrevious';\n\nconst PaginationNext: ForwardRefExoticComponent<\n Omit<\n Omit<PaginationLinkProps, 'isActive'> & {\n label?: string;\n },\n 'ref'\n > &\n RefAttributes<HTMLAnchorElement>\n> = forwardRef<\n ComponentRef<'a'>,\n Omit<PaginationLinkProps, 'isActive'> & { label?: string }\n>(({ className, size, label = 'Go to next page', ...props }, ref) => {\n return (\n <PaginationIconLink\n ref={ref}\n dataSlot=\"pagination-next\"\n ariaLabel={label}\n icon={<IconChevronRight />}\n className={className}\n size={size}\n {...props}\n />\n );\n});\nPaginationNext.displayName = 'PaginationNext';\n\nconst PaginationLast: ForwardRefExoticComponent<\n Omit<\n Omit<PaginationLinkProps, 'isActive'> & {\n label?: string;\n },\n 'ref'\n > &\n RefAttributes<HTMLAnchorElement>\n> = forwardRef<\n ComponentRef<'a'>,\n Omit<PaginationLinkProps, 'isActive'> & { label?: string }\n>(({ className, size, label = 'Go to last page', ...props }, ref) => {\n return (\n <PaginationIconLink\n ref={ref}\n dataSlot=\"pagination-last\"\n ariaLabel={label}\n icon={<IconChevronsRight />}\n className={className}\n size={size}\n {...props}\n />\n );\n});\nPaginationLast.displayName = 'PaginationLast';\n\nconst PaginationEllipsis: ForwardRefExoticComponent<\n Omit<\n ComponentProps<'span'> & {\n size?: PaginationSize;\n label?: string;\n },\n 'ref'\n > &\n RefAttributes<HTMLSpanElement>\n> = forwardRef<\n ComponentRef<'span'>,\n ComponentProps<'span'> & { size?: PaginationSize; label?: string }\n>(({ className, size, label = 'More pages', ...props }, ref) => {\n const inheritedSize = usePaginationSize();\n const resolvedSize = size ?? inheritedSize;\n const { iconButtonWidth } = getPaginationButtonStyles(resolvedSize);\n\n return (\n <span\n ref={ref}\n data-slot=\"pagination-ellipsis\"\n className={cn(\n iconButtonWidth,\n paginationEllipsisVariants({ size: resolvedSize }),\n className\n )}\n {...props}\n >\n <IconDots aria-hidden=\"true\" className=\"h-4 w-4\" />\n <span className=\"sr-only\">{label}</span>\n </span>\n );\n});\nPaginationEllipsis.displayName = 'PaginationEllipsis';\n\nconst PaginationResultsPerPage: ForwardRefExoticComponent<\n ComponentProps<'li'> & RefAttributes<HTMLLIElement>\n> = forwardRef<ComponentRef<'li'>, ComponentProps<'li'>>(\n ({ className, ...props }, ref) => {\n return (\n <li\n ref={ref}\n data-slot=\"pagination-results-per-page\"\n className={cn('flex items-center gap-2 pl-3', className)}\n {...props}\n />\n );\n }\n);\nPaginationResultsPerPage.displayName = 'PaginationResultsPerPage';\n\nconst PaginationResultsPerPageLabel: ForwardRefExoticComponent<\n ComponentProps<'span'> & RefAttributes<HTMLSpanElement>\n> = forwardRef<ComponentRef<'span'>, ComponentProps<'span'>>(\n ({ className, ...props }, ref) => {\n return (\n <span\n ref={ref}\n data-slot=\"pagination-results-per-page-label\"\n className={cn(\n 'text-sm leading-4.5 tracking-tight font-normal text-muted-foreground',\n className\n )}\n {...props}\n />\n );\n }\n);\nPaginationResultsPerPageLabel.displayName = 'PaginationResultsPerPageLabel';\n\nexport {\n Pagination,\n PaginationContent,\n PaginationEllipsis,\n PaginationFirst,\n PaginationItem,\n PaginationLast,\n PaginationLink,\n PaginationNext,\n PaginationPrevious,\n PaginationResultsPerPage,\n PaginationResultsPerPageLabel,\n PaginationSelectTrigger,\n PaginationStatus,\n PaginationTeleport,\n};\n"],"names":["forwardRef","IconChevronLeft","IconChevronRight","IconChevronsLeft","IconChevronsRight","IconDots","cva","cn","Button","SelectTrigger","StatusText","PaginationSizeContext","usePaginationSize","PaginationTeleport","paginationLinkVariants","variants","size","default","small","active","true","false","compoundVariants","className","defaultVariants","paginationEllipsisVariants","paginationSelectTriggerVariants","sm","ICON_BUTTON_WIDTH_BY_SIZE","TEXT_LINK_WIDTH_BY_SIZE","getPaginationButtonStyles","buttonSize","radiusClass","iconButtonWidth","textLinkWidth","Pagination","props","ref","Provider","value","nav","aria-label","data-slot","displayName","PaginationContent","inheritedSize","resolvedSize","ul","data-size","PaginationItem","li","PaginationStatus","PaginationSelectTrigger","style","isPaginationSmall","undefined","PaginationLink","children","isActive","isDisabled","onClick","handleClick","event","preventDefault","variant","data-active","render","a","aria-current","aria-disabled","tabIndex","PaginationIconLink","ariaLabel","dataSlot","icon","linkProps","PaginationFirst","label","PaginationPrevious","PaginationNext","PaginationLast","PaginationEllipsis","span","aria-hidden","PaginationResultsPerPage","PaginationResultsPerPageLabel"],"mappings":";AAAA,SAOEA,UAAU,QACL,QAAQ;AAGf,SACEC,eAAe,EACfC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,QAAQ,QACH,sBAAsB;AAC7B,SAASC,GAAG,QAAQ,2BAA2B;AAE/C,SAASC,EAAE,QAAQ,2BAAwB;AAC3C,SAASC,MAAM,QAAQ,sBAAmB;AAC1C,SAASC,aAAa,QAAQ,sBAAmB;AACjD,SAASC,UAAU,QAAQ,gCAA6B;AAExD,SAEEC,qBAAqB,EACrBC,iBAAiB,QACZ,+BAA4B;AACnC,SAASC,kBAAkB,QAAQ,2BAAwB;AAS3D,MAAMC,yBAAyBR,IAC7B,+GACA;IACES,UAAU;QACRC,MAAM;YACJC,SAAS;YACTC,OAAO;QACT;QACAC,QAAQ;YACNC,MAAM;YACNC,OAAO;QACT;IACF;IACAC,kBAAkB;QAChB;YACEH,QAAQ;YACRI,WACE;QACJ;QACA;YACEJ,QAAQ;YACRI,WACE;QACJ;KACD;IACDC,iBAAiB;QACfR,MAAM;QACNG,QAAQ;IACV;AACF;AAGF,MAAMM,6BAA6BnB,IACjC,2DACA;IACES,UAAU;QACRC,MAAM;YACJC,SAAS;YACTC,OAAO;QACT;IACF;IACAM,iBAAiB;QACfR,MAAM;IACR;AACF;AAGF,MAAMU,kCAAkCpB,IACtC,oCACA;IACES,UAAU;QACRC,MAAM;YACJC,SAAS;YACTU,IAAI;QACN;IACF;IACAH,iBAAiB;QACfR,MAAM;IACR;AACF;AAGF,MAAMY,4BAA4D;IAChEV,OAAO;IACPD,SAAS;AACX;AAEA,MAAMY,0BAA0D;IAC9DX,OAAO;IACPD,SAAS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FgD,yBAAyBzC,WAAW,GAAG;AAEvC,MAAM0C,8CAEFrF,WACF,CAAC,EAAEuB,SAAS,EAAE,GAAGa,OAAO,EAAEC;IACxB,qBACE,KAAC6C;QACC7C,KAAKA;QACLK,aAAU;QACVnB,WAAWhB,GACT,wEACAgB;QAED,GAAGa,KAAK;;AAGf;AAEFiD,8BAA8B1C,WAAW,GAAG;AAE5C,SACER,UAAU,EACVS,iBAAiB,EACjBqC,kBAAkB,EAClBL,eAAe,EACf3B,cAAc,EACd+B,cAAc,EACdxB,cAAc,EACduB,cAAc,EACdD,kBAAkB,EAClBM,wBAAwB,EACxBC,6BAA6B,EAC7BjC,uBAAuB,EACvBD,gBAAgB,EAChBtC,kBAAkB,GAClB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const BOUNDARY_COUNT = 1;
|
|
2
|
+
const SIBLING_COUNT = 1;
|
|
3
|
+
function range(start, end) {
|
|
4
|
+
const length = end - start + 1;
|
|
5
|
+
return Array.from({
|
|
6
|
+
length
|
|
7
|
+
}, (_, index)=>start + index);
|
|
8
|
+
}
|
|
9
|
+
export function getPaginationPageItems(currentPage, totalPages) {
|
|
10
|
+
const count = Math.max(1, totalPages);
|
|
11
|
+
const page = Math.min(Math.max(1, currentPage), count);
|
|
12
|
+
const startPages = range(1, Math.min(BOUNDARY_COUNT, count));
|
|
13
|
+
const endPages = range(Math.max(count - BOUNDARY_COUNT + 1, BOUNDARY_COUNT + 1), count);
|
|
14
|
+
const siblingsStart = Math.max(Math.min(page - SIBLING_COUNT, count - BOUNDARY_COUNT - SIBLING_COUNT * 2 - 1), BOUNDARY_COUNT + 2);
|
|
15
|
+
const siblingsEnd = Math.min(Math.max(page + SIBLING_COUNT, BOUNDARY_COUNT + SIBLING_COUNT * 2 + 2), count - BOUNDARY_COUNT - 1);
|
|
16
|
+
const itemList = [
|
|
17
|
+
...startPages
|
|
18
|
+
];
|
|
19
|
+
if (siblingsStart > BOUNDARY_COUNT + 2) {
|
|
20
|
+
itemList.push('start-ellipsis');
|
|
21
|
+
} else if (BOUNDARY_COUNT + 1 < count - BOUNDARY_COUNT) {
|
|
22
|
+
itemList.push(BOUNDARY_COUNT + 1);
|
|
23
|
+
}
|
|
24
|
+
itemList.push(...range(siblingsStart, siblingsEnd));
|
|
25
|
+
if (siblingsEnd < count - BOUNDARY_COUNT - 1) {
|
|
26
|
+
itemList.push('end-ellipsis');
|
|
27
|
+
} else if (count - BOUNDARY_COUNT > BOUNDARY_COUNT) {
|
|
28
|
+
itemList.push(count - BOUNDARY_COUNT);
|
|
29
|
+
}
|
|
30
|
+
itemList.push(...endPages);
|
|
31
|
+
return itemList;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=pagination.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/pagination/pagination.utils.ts"],"sourcesContent":["export type PaginationPageItem = number | 'start-ellipsis' | 'end-ellipsis';\n\nconst BOUNDARY_COUNT = 1;\nconst SIBLING_COUNT = 1;\n\nfunction range(start: number, end: number): number[] {\n const length = end - start + 1;\n return Array.from({ length }, (_, index) => start + index);\n}\n\nexport function getPaginationPageItems(\n currentPage: number,\n totalPages: number\n): PaginationPageItem[] {\n const count = Math.max(1, totalPages);\n const page = Math.min(Math.max(1, currentPage), count);\n\n const startPages = range(1, Math.min(BOUNDARY_COUNT, count));\n const endPages = range(\n Math.max(count - BOUNDARY_COUNT + 1, BOUNDARY_COUNT + 1),\n count\n );\n\n const siblingsStart = Math.max(\n Math.min(\n page - SIBLING_COUNT,\n count - BOUNDARY_COUNT - SIBLING_COUNT * 2 - 1\n ),\n BOUNDARY_COUNT + 2\n );\n\n const siblingsEnd = Math.min(\n Math.max(page + SIBLING_COUNT, BOUNDARY_COUNT + SIBLING_COUNT * 2 + 2),\n count - BOUNDARY_COUNT - 1\n );\n\n const itemList: PaginationPageItem[] = [...startPages];\n\n if (siblingsStart > BOUNDARY_COUNT + 2) {\n itemList.push('start-ellipsis');\n } else if (BOUNDARY_COUNT + 1 < count - BOUNDARY_COUNT) {\n itemList.push(BOUNDARY_COUNT + 1);\n }\n\n itemList.push(...range(siblingsStart, siblingsEnd));\n\n if (siblingsEnd < count - BOUNDARY_COUNT - 1) {\n itemList.push('end-ellipsis');\n } else if (count - BOUNDARY_COUNT > BOUNDARY_COUNT) {\n itemList.push(count - BOUNDARY_COUNT);\n }\n\n itemList.push(...endPages);\n\n return itemList;\n}\n"],"names":["BOUNDARY_COUNT","SIBLING_COUNT","range","start","end","length","Array","from","_","index","getPaginationPageItems","currentPage","totalPages","count","Math","max","page","min","startPages","endPages","siblingsStart","siblingsEnd","itemList","push"],"mappings":"AAEA,MAAMA,iBAAiB;AACvB,MAAMC,gBAAgB;AAEtB,SAASC,MAAMC,KAAa,EAAEC,GAAW;IACvC,MAAMC,SAASD,MAAMD,QAAQ;IAC7B,OAAOG,MAAMC,IAAI,CAAC;QAAEF;IAAO,GAAG,CAACG,GAAGC,QAAUN,QAAQM;AACtD;AAEA,OAAO,SAASC,uBACdC,WAAmB,EACnBC,UAAkB;IAElB,MAAMC,QAAQC,KAAKC,GAAG,CAAC,GAAGH;IAC1B,MAAMI,OAAOF,KAAKG,GAAG,CAACH,KAAKC,GAAG,CAAC,GAAGJ,cAAcE;IAEhD,MAAMK,aAAahB,MAAM,GAAGY,KAAKG,GAAG,CAACjB,gBAAgBa;IACrD,MAAMM,WAAWjB,MACfY,KAAKC,GAAG,CAACF,QAAQb,iBAAiB,GAAGA,iBAAiB,IACtDa;IAGF,MAAMO,gBAAgBN,KAAKC,GAAG,CAC5BD,KAAKG,GAAG,CACND,OAAOf,eACPY,QAAQb,iBAAiBC,gBAAgB,IAAI,IAE/CD,iBAAiB;IAGnB,MAAMqB,cAAcP,KAAKG,GAAG,CAC1BH,KAAKC,GAAG,CAACC,OAAOf,eAAeD,iBAAiBC,gBAAgB,IAAI,IACpEY,QAAQb,iBAAiB;IAG3B,MAAMsB,WAAiC;WAAIJ;KAAW;IAEtD,IAAIE,gBAAgBpB,iBAAiB,GAAG;QACtCsB,SAASC,IAAI,CAAC;IAChB,OAAO,IAAIvB,iBAAiB,IAAIa,QAAQb,gBAAgB;QACtDsB,SAASC,IAAI,CAACvB,iBAAiB;IACjC;IAEAsB,SAASC,IAAI,IAAIrB,MAAMkB,eAAeC;IAEtC,IAAIA,cAAcR,QAAQb,iBAAiB,GAAG;QAC5CsB,SAASC,IAAI,CAAC;IAChB,OAAO,IAAIV,QAAQb,iBAAiBA,gBAAgB;QAClDsB,SAASC,IAAI,CAACV,QAAQb;IACxB;IAEAsB,SAASC,IAAI,IAAIJ;IAEjB,OAAOG;AACT"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComponentProps, ReactElement } from "react";
|
|
2
|
+
type CountBadgeProps = Omit<ComponentProps<"span">, "children"> & {
|
|
3
|
+
count: number | string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare function CountBadge({ count, disabled, className, ...props }: CountBadgeProps): ReactElement;
|
|
7
|
+
export { CountBadge, type CountBadgeProps };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../../../lib/utils.js";
|
|
3
|
+
function CountBadge({ count, disabled, className, ...props }) {
|
|
4
|
+
return /*#__PURE__*/ _jsx("span", {
|
|
5
|
+
"data-slot": "count-badge",
|
|
6
|
+
className: cn('inline-flex h-4 min-w-4 items-center justify-center rounded-sm px-0.5 text-xs font-medium leading-3.5 tracking-tightest', disabled ? 'bg-base-background-disabled text-base-foreground-disabled' : 'bg-medium-background text-medium-foreground', className),
|
|
7
|
+
...props,
|
|
8
|
+
children: String(count)
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export { CountBadge };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=count-badge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/toggle/count-badge.tsx"],"sourcesContent":["import type { ComponentProps, ReactElement } from 'react';\n\nimport { cn } from '../../../../lib/utils';\n\ntype CountBadgeProps = Omit<ComponentProps<'span'>, 'children'> & {\n count: number | string;\n disabled?: boolean;\n};\n\nfunction CountBadge({\n count,\n disabled,\n className,\n ...props\n}: CountBadgeProps): ReactElement {\n return (\n <span\n data-slot=\"count-badge\"\n className={cn(\n 'inline-flex h-4 min-w-4 items-center justify-center rounded-sm px-0.5 text-xs font-medium leading-3.5 tracking-tightest',\n disabled\n ? 'bg-base-background-disabled text-base-foreground-disabled'\n : 'bg-medium-background text-medium-foreground',\n className\n )}\n {...props}\n >\n {String(count)}\n </span>\n );\n}\n\nexport { CountBadge, type CountBadgeProps };\n"],"names":["cn","CountBadge","count","disabled","className","props","span","data-slot","String"],"mappings":";AAEA,SAASA,EAAE,QAAQ,2BAAwB;AAO3C,SAASC,WAAW,EAClBC,KAAK,EACLC,QAAQ,EACRC,SAAS,EACT,GAAGC,OACa;IAChB,qBACE,KAACC;QACCC,aAAU;QACVH,WAAWJ,GACT,2HACAG,WACI,8DACA,+CACJC;QAED,GAAGC,KAAK;kBAERG,OAAON;;AAGd;AAEA,SAASD,UAAU,GAAyB"}
|
|
@@ -3,6 +3,7 @@ import { forwardRef } from "react";
|
|
|
3
3
|
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
5
|
import { cn } from "../../../../lib/utils.js";
|
|
6
|
+
import { CountBadge } from "./count-badge.js";
|
|
6
7
|
const toggleVariants = cva("group inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium text-medium-foreground hover:bg-base-background-hover disabled:pointer-events-none disabled:text-base-foreground-disabled disabled:[&_svg:not([class*='text-'])]:text-base-foreground-disabled aria-pressed:border aria-pressed:border-emphasized aria-pressed:bg-secondary-background aria-pressed:text-secondary-foreground aria-pressed:[&_svg:not([class*='text-'])]:text-secondary-foreground disabled:aria-pressed:border disabled:aria-pressed:border-default disabled:aria-pressed:bg-base-background-disabled disabled:aria-pressed:text-base-foreground-disabled disabled:aria-pressed:[&_svg:not([class*='text-'])]:text-base-foreground-disabled [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring-muted focus-visible:ring outline-none transition-[color,box-shadow] aria-invalid:ring-destructive-background/20 dark:aria-invalid:ring-destructive-background/40 aria-invalid:border-destructive-background whitespace-nowrap", {
|
|
7
8
|
variants: {
|
|
8
9
|
variant: {
|
|
@@ -20,17 +21,6 @@ const toggleVariants = cva("group inline-flex items-center justify-center gap-2
|
|
|
20
21
|
size: 'default'
|
|
21
22
|
}
|
|
22
23
|
});
|
|
23
|
-
const renderCountBadge = (count, disabled)=>{
|
|
24
|
-
if (count === undefined || count === null || count === '') {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
const countValue = String(count);
|
|
28
|
-
return /*#__PURE__*/ _jsx("span", {
|
|
29
|
-
"data-slot": "toggle-count",
|
|
30
|
-
className: cn('inline-flex h-4 min-w-4 items-center justify-center rounded-sm px-0.5 text-xs font-medium leading-3.5 tracking-tightest', disabled ? 'bg-base-background-disabled text-base-foreground-disabled' : 'bg-medium-background text-medium-foreground'),
|
|
31
|
-
children: countValue
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
24
|
const Toggle = /*#__PURE__*/ forwardRef(({ className, variant, size, icon, label, count, children, disabled, ...props }, ref)=>{
|
|
35
25
|
const hasComposedContent = icon !== undefined || label !== undefined || count !== undefined;
|
|
36
26
|
return /*#__PURE__*/ _jsx(TogglePrimitive, {
|
|
@@ -50,7 +40,11 @@ const Toggle = /*#__PURE__*/ forwardRef(({ className, variant, size, icon, label
|
|
|
50
40
|
"data-slot": "toggle-label",
|
|
51
41
|
children: label
|
|
52
42
|
}),
|
|
53
|
-
|
|
43
|
+
count != null && count !== '' && /*#__PURE__*/ _jsx(CountBadge, {
|
|
44
|
+
"data-slot": "toggle-count",
|
|
45
|
+
count: count,
|
|
46
|
+
disabled: disabled
|
|
47
|
+
})
|
|
54
48
|
]
|
|
55
49
|
}))
|
|
56
50
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/ui/core/toggle/toggle.tsx"],"sourcesContent":["import {\n type ComponentRef,\n type ForwardRefExoticComponent,\n type ReactNode,\n type RefAttributes,\n forwardRef,\n} from 'react';\n\nimport { Toggle as TogglePrimitive } from '@base-ui/react/toggle';\nimport { cva } from 'class-variance-authority';\nimport type { ClassProp } from 'class-variance-authority/types';\n\nimport { cn } from '../../../../lib/utils';\n\ntype ToggleVariantProps = {\n variant?: 'default' | 'outline';\n size?: 'default' | 'sm' | 'lg';\n};\n\nconst toggleVariants: (\n props?: (ToggleVariantProps & ClassProp) | undefined\n) => string = cva(\n \"group inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium text-medium-foreground hover:bg-base-background-hover disabled:pointer-events-none disabled:text-base-foreground-disabled disabled:[&_svg:not([class*='text-'])]:text-base-foreground-disabled aria-pressed:border aria-pressed:border-emphasized aria-pressed:bg-secondary-background aria-pressed:text-secondary-foreground aria-pressed:[&_svg:not([class*='text-'])]:text-secondary-foreground disabled:aria-pressed:border disabled:aria-pressed:border-default disabled:aria-pressed:bg-base-background-disabled disabled:aria-pressed:text-base-foreground-disabled disabled:aria-pressed:[&_svg:not([class*='text-'])]:text-base-foreground-disabled [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring-muted focus-visible:ring outline-none transition-[color,box-shadow] aria-invalid:ring-destructive-background/20 dark:aria-invalid:ring-destructive-background/40 aria-invalid:border-destructive-background whitespace-nowrap\",\n {\n variants: {\n variant: {\n default: 'bg-transparent',\n outline:\n 'border border-emphasized bg-transparent shadow-xs hover:bg-base-background-hover hover:text-base-foreground',\n },\n size: {\n default: 'h-9 px-2 min-w-9',\n sm: 'h-7 px-1.5 min-w-7',\n lg: 'h-8 px-2.5 min-w-8',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\ntype ToggleProps = TogglePrimitive.Props &\n ToggleVariantProps & {\n icon?: ReactNode;\n label?: ReactNode;\n count?: number | string;\n };\n\nconst
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/toggle/toggle.tsx"],"sourcesContent":["import {\n type ComponentRef,\n type ForwardRefExoticComponent,\n type ReactNode,\n type RefAttributes,\n forwardRef,\n} from 'react';\n\nimport { Toggle as TogglePrimitive } from '@base-ui/react/toggle';\nimport { cva } from 'class-variance-authority';\nimport type { ClassProp } from 'class-variance-authority/types';\n\nimport { cn } from '../../../../lib/utils';\n\nimport { CountBadge } from './count-badge';\n\ntype ToggleVariantProps = {\n variant?: 'default' | 'outline';\n size?: 'default' | 'sm' | 'lg';\n};\n\nconst toggleVariants: (\n props?: (ToggleVariantProps & ClassProp) | undefined\n) => string = cva(\n \"group inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium text-medium-foreground hover:bg-base-background-hover disabled:pointer-events-none disabled:text-base-foreground-disabled disabled:[&_svg:not([class*='text-'])]:text-base-foreground-disabled aria-pressed:border aria-pressed:border-emphasized aria-pressed:bg-secondary-background aria-pressed:text-secondary-foreground aria-pressed:[&_svg:not([class*='text-'])]:text-secondary-foreground disabled:aria-pressed:border disabled:aria-pressed:border-default disabled:aria-pressed:bg-base-background-disabled disabled:aria-pressed:text-base-foreground-disabled disabled:aria-pressed:[&_svg:not([class*='text-'])]:text-base-foreground-disabled [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring-muted focus-visible:ring outline-none transition-[color,box-shadow] aria-invalid:ring-destructive-background/20 dark:aria-invalid:ring-destructive-background/40 aria-invalid:border-destructive-background whitespace-nowrap\",\n {\n variants: {\n variant: {\n default: 'bg-transparent',\n outline:\n 'border border-emphasized bg-transparent shadow-xs hover:bg-base-background-hover hover:text-base-foreground',\n },\n size: {\n default: 'h-9 px-2 min-w-9',\n sm: 'h-7 px-1.5 min-w-7',\n lg: 'h-8 px-2.5 min-w-8',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\ntype ToggleProps = TogglePrimitive.Props &\n ToggleVariantProps & {\n icon?: ReactNode;\n label?: ReactNode;\n count?: number | string;\n };\n\nconst Toggle: ForwardRefExoticComponent<\n Omit<ToggleProps, 'ref'> & RefAttributes<ComponentRef<typeof TogglePrimitive>>\n> = forwardRef<ComponentRef<typeof TogglePrimitive>, ToggleProps>(\n (\n {\n className,\n variant,\n size,\n icon,\n label,\n count,\n children,\n disabled,\n ...props\n },\n ref\n ) => {\n const hasComposedContent =\n icon !== undefined || label !== undefined || count !== undefined;\n\n return (\n <TogglePrimitive\n ref={ref}\n data-slot=\"toggle\"\n disabled={disabled}\n className={cn(toggleVariants({ variant, size, className }))}\n {...props}\n >\n {children ??\n (hasComposedContent && (\n <>\n {icon}\n {label && <span data-slot=\"toggle-label\">{label}</span>}\n {count != null && count !== '' && (\n <CountBadge\n data-slot=\"toggle-count\"\n count={count}\n disabled={disabled}\n />\n )}\n </>\n ))}\n </TogglePrimitive>\n );\n }\n);\n\nToggle.displayName = 'Toggle';\n\nexport { Toggle, toggleVariants };\n"],"names":["forwardRef","Toggle","TogglePrimitive","cva","cn","CountBadge","toggleVariants","variants","variant","default","outline","size","sm","lg","defaultVariants","className","icon","label","count","children","disabled","props","ref","hasComposedContent","undefined","data-slot","span","displayName"],"mappings":";AAAA,SAKEA,UAAU,QACL,QAAQ;AAEf,SAASC,UAAUC,eAAe,QAAQ,wBAAwB;AAClE,SAASC,GAAG,QAAQ,2BAA2B;AAG/C,SAASC,EAAE,QAAQ,2BAAwB;AAE3C,SAASC,UAAU,QAAQ,mBAAgB;AAO3C,MAAMC,iBAEQH,IACZ,qjCACA;IACEI,UAAU;QACRC,SAAS;YACPC,SAAS;YACTC,SACE;QACJ;QACAC,MAAM;YACJF,SAAS;YACTG,IAAI;YACJC,IAAI;QACN;IACF;IACAC,iBAAiB;QACfN,SAAS;QACTG,MAAM;IACR;AACF;AAUF,MAAMV,uBAEFD,WACF,CACE,EACEe,SAAS,EACTP,OAAO,EACPG,IAAI,EACJK,IAAI,EACJC,KAAK,EACLC,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACR,GAAGC,OACJ,EACDC;IAEA,MAAMC,qBACJP,SAASQ,aAAaP,UAAUO,aAAaN,UAAUM;IAEzD,qBACE,KAACtB;QACCoB,KAAKA;QACLG,aAAU;QACVL,UAAUA;QACVL,WAAWX,GAAGE,eAAe;YAAEE;YAASG;YAAMI;QAAU;QACvD,GAAGM,KAAK;kBAERF,YACEI,CAAAA,oCACC;;gBACGP;gBACAC,uBAAS,KAACS;oBAAKD,aAAU;8BAAgBR;;gBACzCC,SAAS,QAAQA,UAAU,oBAC1B,KAACb;oBACCoB,aAAU;oBACVP,OAAOA;oBACPE,UAAUA;;;UAIlB;;AAGR;AAGFnB,OAAO0B,WAAW,GAAG;AAErB,SAAS1B,MAAM,EAAEK,cAAc,GAAG"}
|