@epilot/spark-ui 0.31.0 → 0.32.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/dist/button-B_RNHEc7.d.ts +52 -0
- package/dist/button-DBcEcIMk.d.cts +52 -0
- package/dist/cn-DzRH6EW_.d.cts +4 -0
- package/dist/cn-DzRH6EW_.d.ts +4 -0
- package/dist/components/accordion.cjs +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/alert-dialog.d.cts +1 -1
- package/dist/components/alert-dialog.d.ts +1 -1
- package/dist/components/attachment.cjs +1 -1
- package/dist/components/attachment.d.cts +2 -2
- package/dist/components/attachment.d.ts +2 -2
- package/dist/components/attachment.js +1 -1
- package/dist/components/autocomplete.cjs +8 -6
- package/dist/components/autocomplete.cjs.map +1 -1
- package/dist/components/autocomplete.d.cts +4 -10
- package/dist/components/autocomplete.d.ts +4 -10
- package/dist/components/autocomplete.js +8 -6
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/badge.cjs +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/banner.cjs +1 -1
- package/dist/components/banner.js +1 -1
- package/dist/components/bar-chart.cjs +1 -1
- package/dist/components/bar-chart.js +2 -2
- package/dist/components/box.cjs +1 -1
- package/dist/components/box.cjs.map +1 -1
- package/dist/components/box.js +2 -2
- package/dist/components/box.js.map +1 -1
- package/dist/components/breadcrumbs.cjs +1 -1
- package/dist/components/breadcrumbs.js +1 -1
- package/dist/components/bubble.cjs +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/bubble.js +1 -1
- package/dist/components/button-group.cjs +1 -1
- package/dist/components/button-group.js +1 -1
- package/dist/components/button.cjs +27 -10
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +3 -28
- package/dist/components/button.d.ts +3 -28
- package/dist/components/button.js +27 -11
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar.cjs +32 -4
- package/dist/components/calendar.cjs.map +1 -1
- package/dist/components/calendar.d.cts +2 -2
- package/dist/components/calendar.d.ts +2 -2
- package/dist/components/calendar.js +34 -6
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/callout.cjs +1 -1
- package/dist/components/callout.d.cts +1 -1
- package/dist/components/callout.d.ts +1 -1
- package/dist/components/callout.js +1 -1
- package/dist/components/card.cjs +5 -4
- package/dist/components/card.cjs.map +1 -1
- package/dist/components/card.d.cts +9 -8
- package/dist/components/card.d.ts +9 -8
- package/dist/components/card.js +6 -5
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox-card.cjs +177 -0
- package/dist/components/checkbox-card.cjs.map +1 -0
- package/dist/components/checkbox-card.d.cts +47 -0
- package/dist/components/checkbox-card.d.ts +47 -0
- package/dist/components/checkbox-card.js +170 -0
- package/dist/components/checkbox-card.js.map +1 -0
- package/dist/components/checkbox.cjs +5 -18
- package/dist/components/checkbox.cjs.map +1 -1
- package/dist/components/checkbox.js +6 -19
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/combobox.cjs +3 -2
- package/dist/components/combobox.cjs.map +1 -1
- package/dist/components/combobox.js +3 -2
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/drawer.cjs +1 -1
- package/dist/components/drawer.js +1 -1
- package/dist/components/dropzone.cjs +224 -0
- package/dist/components/dropzone.cjs.map +1 -0
- package/dist/components/dropzone.d.cts +66 -0
- package/dist/components/dropzone.d.ts +66 -0
- package/dist/components/dropzone.js +215 -0
- package/dist/components/dropzone.js.map +1 -0
- package/dist/components/empty-state.cjs +1 -1
- package/dist/components/empty-state.d.cts +1 -1
- package/dist/components/empty-state.d.ts +1 -1
- package/dist/components/empty-state.js +1 -1
- package/dist/components/entity-card.cjs +1 -1
- package/dist/components/entity-card.js +1 -1
- package/dist/components/field.cjs +68 -10
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.cts +16 -3
- package/dist/components/field.d.ts +16 -3
- package/dist/components/field.js +67 -10
- package/dist/components/field.js.map +1 -1
- package/dist/components/hero-metric.cjs +1 -1
- package/dist/components/hero-metric.js +1 -1
- package/dist/components/image-carousel.cjs +183 -0
- package/dist/components/image-carousel.cjs.map +1 -0
- package/dist/components/image-carousel.d.cts +54 -0
- package/dist/components/image-carousel.d.ts +54 -0
- package/dist/components/image-carousel.js +174 -0
- package/dist/components/image-carousel.js.map +1 -0
- package/dist/components/info-block.cjs +1 -1
- package/dist/components/info-block.d.cts +1 -1
- package/dist/components/info-block.d.ts +1 -1
- package/dist/components/info-block.js +1 -1
- package/dist/components/input-date-time.cjs +16 -202
- package/dist/components/input-date-time.cjs.map +1 -1
- package/dist/components/input-date-time.d.cts +14 -31
- package/dist/components/input-date-time.d.ts +14 -31
- package/dist/components/input-date-time.js +15 -202
- package/dist/components/input-date-time.js.map +1 -1
- package/dist/components/input-date.cjs +14 -146
- package/dist/components/input-date.cjs.map +1 -1
- package/dist/components/input-date.d.cts +11 -19
- package/dist/components/input-date.d.ts +11 -19
- package/dist/components/input-date.js +13 -146
- package/dist/components/input-date.js.map +1 -1
- package/dist/components/input-group.cjs +5 -4
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.d.cts +2 -30
- package/dist/components/input-group.d.ts +2 -30
- package/dist/components/input-group.js +4 -3
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input-otp.cjs +4 -4
- package/dist/components/input-otp.cjs.map +1 -1
- package/dist/components/input-otp.js +4 -4
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/input.cjs +5 -3
- package/dist/components/input.cjs.map +1 -1
- package/dist/components/input.d.cts +2 -12
- package/dist/components/input.d.ts +2 -12
- package/dist/components/input.js +5 -3
- package/dist/components/input.js.map +1 -1
- package/dist/components/line-chart.cjs +3 -3
- package/dist/components/line-chart.js +4 -4
- package/dist/components/link.cjs +31 -0
- package/dist/components/link.cjs.map +1 -0
- package/dist/components/link.d.cts +16 -0
- package/dist/components/link.d.ts +16 -0
- package/dist/components/link.js +28 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/list.cjs +1 -1
- package/dist/components/list.js +1 -1
- package/dist/components/marker.cjs +1 -1
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/marker.js +1 -1
- package/dist/components/message-scroller.d.cts +1 -1
- package/dist/components/message-scroller.d.ts +1 -1
- package/dist/components/message-scroller.js +1 -1
- package/dist/components/page-header.cjs +1 -1
- package/dist/components/page-header.d.cts +1 -1
- package/dist/components/page-header.d.ts +1 -1
- package/dist/components/page-header.js +1 -1
- package/dist/components/pagination.cjs +124 -0
- package/dist/components/pagination.cjs.map +1 -0
- package/dist/components/pagination.d.cts +42 -0
- package/dist/components/pagination.d.ts +42 -0
- package/dist/components/pagination.js +115 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/period-tabs.d.cts +1 -1
- package/dist/components/period-tabs.d.ts +1 -1
- package/dist/components/pill.cjs +42 -23
- package/dist/components/pill.cjs.map +1 -1
- package/dist/components/pill.d.cts +13 -3
- package/dist/components/pill.d.ts +13 -3
- package/dist/components/pill.js +42 -24
- package/dist/components/pill.js.map +1 -1
- package/dist/components/popover.cjs +1 -1
- package/dist/components/popover.d.cts +2 -29
- package/dist/components/popover.d.ts +2 -29
- package/dist/components/popover.js +1 -1
- package/dist/components/power-history-chart.cjs +3 -3
- package/dist/components/power-history-chart.js +4 -4
- package/dist/components/power-network.js +1 -1
- package/dist/components/progress.cjs +126 -13
- package/dist/components/progress.cjs.map +1 -1
- package/dist/components/progress.d.cts +19 -10
- package/dist/components/progress.d.ts +19 -10
- package/dist/components/progress.js +126 -15
- package/dist/components/progress.js.map +1 -1
- package/dist/components/radio-card-group.cjs +137 -70
- package/dist/components/radio-card-group.cjs.map +1 -1
- package/dist/components/radio-card-group.d.cts +37 -15
- package/dist/components/radio-card-group.d.ts +37 -15
- package/dist/components/radio-card-group.js +135 -71
- package/dist/components/radio-card-group.js.map +1 -1
- package/dist/components/select.cjs +11 -4
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.d.cts +1 -0
- package/dist/components/select.d.ts +1 -0
- package/dist/components/select.js +11 -4
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +1 -1
- package/dist/components/separator.js +1 -1
- package/dist/components/skeleton.cjs +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/solar-forecast-chart.js +1 -1
- package/dist/components/spark-home.js +1 -1
- package/dist/components/step-indicator.cjs +128 -0
- package/dist/components/step-indicator.cjs.map +1 -0
- package/dist/components/step-indicator.d.cts +25 -0
- package/dist/components/step-indicator.d.ts +25 -0
- package/dist/components/step-indicator.js +124 -0
- package/dist/components/step-indicator.js.map +1 -0
- package/dist/components/stepper.cjs +2 -1
- package/dist/components/stepper.cjs.map +1 -1
- package/dist/components/stepper.d.cts +1 -2
- package/dist/components/stepper.d.ts +1 -2
- package/dist/components/stepper.js +2 -1
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/tabs.cjs +2 -2
- package/dist/components/tabs.cjs.map +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/textarea.cjs +9 -3
- package/dist/components/textarea.cjs.map +1 -1
- package/dist/components/textarea.js +9 -3
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/theme.cjs +1 -1
- package/dist/components/theme.js +2 -2
- package/dist/components/time-picker.cjs +3 -38
- package/dist/components/time-picker.cjs.map +1 -1
- package/dist/components/time-picker.js +1 -36
- package/dist/components/time-picker.js.map +1 -1
- package/dist/components/toggle.d.cts +1 -1
- package/dist/components/toggle.d.ts +1 -1
- package/dist/components/tooltip.cjs +2 -1
- package/dist/components/tooltip.cjs.map +1 -1
- package/dist/components/tooltip.d.cts +3 -2
- package/dist/components/tooltip.d.ts +3 -2
- package/dist/components/tooltip.js +2 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/hooks/use-isomorphic-layout-effect.cjs +9 -0
- package/dist/hooks/use-isomorphic-layout-effect.cjs.map +1 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.cts +9 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts +9 -0
- package/dist/hooks/use-isomorphic-layout-effect.js +8 -0
- package/dist/hooks/use-isomorphic-layout-effect.js.map +1 -0
- package/dist/input-BZFPU-j4.d.cts +14 -0
- package/dist/input-group-5lh67qyY.d.cts +32 -0
- package/dist/input-group-Bc9_sPPN.d.ts +32 -0
- package/dist/input-zB3zmz9J.d.ts +14 -0
- package/dist/lib/accent-theme.cjs +46 -22
- package/dist/lib/accent-theme.cjs.map +1 -1
- package/dist/lib/accent-theme.js +26 -1
- package/dist/lib/accent-theme.js.map +1 -1
- package/dist/lib/calendar-field.cjs +11 -0
- package/dist/lib/calendar-field.cjs.map +1 -0
- package/dist/lib/calendar-field.d.cts +18 -0
- package/dist/lib/calendar-field.d.ts +18 -0
- package/dist/lib/calendar-field.js +8 -0
- package/dist/lib/calendar-field.js.map +1 -0
- package/dist/lib/calendar-lists.cjs +86 -97
- package/dist/lib/calendar-lists.cjs.map +1 -1
- package/dist/lib/calendar-lists.d.cts +30 -2
- package/dist/lib/calendar-lists.d.ts +30 -2
- package/dist/lib/calendar-lists.js +85 -97
- package/dist/lib/calendar-lists.js.map +1 -1
- package/dist/lib/card-control.cjs +18 -0
- package/dist/lib/card-control.cjs.map +1 -0
- package/dist/lib/card-control.d.cts +10 -0
- package/dist/lib/card-control.d.ts +10 -0
- package/dist/lib/card-control.js +17 -0
- package/dist/lib/card-control.js.map +1 -0
- package/dist/lib/checkbox-box.cjs +30 -0
- package/dist/lib/checkbox-box.cjs.map +1 -0
- package/dist/lib/checkbox-box.d.cts +13 -0
- package/dist/lib/checkbox-box.d.ts +13 -0
- package/dist/lib/checkbox-box.js +27 -0
- package/dist/lib/checkbox-box.js.map +1 -0
- package/dist/lib/container-chrome.cjs +8 -1
- package/dist/lib/container-chrome.cjs.map +1 -1
- package/dist/lib/container-chrome.d.cts +4 -2
- package/dist/lib/container-chrome.d.ts +4 -2
- package/dist/lib/container-chrome.js +8 -2
- package/dist/lib/container-chrome.js.map +1 -1
- package/dist/lib/date-field-input.cjs +121 -0
- package/dist/lib/date-field-input.cjs.map +1 -0
- package/dist/lib/date-field-input.d.cts +14 -0
- package/dist/lib/date-field-input.d.ts +14 -0
- package/dist/lib/date-field-input.js +118 -0
- package/dist/lib/date-field-input.js.map +1 -0
- package/dist/lib/date-field-time-list.cjs +81 -0
- package/dist/lib/date-field-time-list.cjs.map +1 -0
- package/dist/lib/date-field-time-list.d.cts +18 -0
- package/dist/lib/date-field-time-list.d.ts +18 -0
- package/dist/lib/date-field-time-list.js +77 -0
- package/dist/lib/date-field-time-list.js.map +1 -0
- package/dist/lib/date-field.cjs +183 -0
- package/dist/lib/date-field.cjs.map +1 -0
- package/dist/lib/date-field.d.cts +76 -0
- package/dist/lib/date-field.d.ts +76 -0
- package/dist/lib/date-field.js +177 -0
- package/dist/lib/date-field.js.map +1 -0
- package/dist/lib/date-time-mask.cjs +148 -102
- package/dist/lib/date-time-mask.cjs.map +1 -1
- package/dist/lib/date-time-mask.d.cts +21 -3
- package/dist/lib/date-time-mask.d.ts +21 -3
- package/dist/lib/date-time-mask.js +142 -103
- package/dist/lib/date-time-mask.js.map +1 -1
- package/dist/lib/generate-radix-colors.cjs +64 -5
- package/dist/lib/generate-radix-colors.cjs.map +1 -1
- package/dist/lib/generate-radix-colors.js +61 -1
- package/dist/lib/generate-radix-colors.js.map +1 -1
- package/dist/lib/input-box-variants.cjs +3 -3
- package/dist/lib/input-box-variants.cjs.map +1 -1
- package/dist/lib/input-box-variants.d.cts +1 -1
- package/dist/lib/input-box-variants.d.ts +1 -1
- package/dist/lib/input-box-variants.js +3 -3
- package/dist/lib/input-box-variants.js.map +1 -1
- package/dist/lib/mask-hint.cjs +15 -0
- package/dist/lib/mask-hint.cjs.map +1 -0
- package/dist/lib/mask-hint.d.cts +10 -0
- package/dist/lib/mask-hint.d.ts +10 -0
- package/dist/lib/mask-hint.js +14 -0
- package/dist/lib/mask-hint.js.map +1 -0
- package/dist/lib/option-list.cjs +71 -0
- package/dist/lib/option-list.cjs.map +1 -0
- package/dist/lib/option-list.d.cts +4 -0
- package/dist/lib/option-list.d.ts +4 -0
- package/dist/lib/option-list.js +67 -0
- package/dist/lib/option-list.js.map +1 -0
- package/dist/lib/time-grid.cjs +34 -0
- package/dist/lib/time-grid.cjs.map +1 -0
- package/dist/lib/time-grid.d.cts +9 -0
- package/dist/lib/time-grid.d.ts +9 -0
- package/dist/lib/time-grid.js +31 -0
- package/dist/lib/time-grid.js.map +1 -0
- package/dist/lib/toggle-group-context.d.cts +1 -1
- package/dist/lib/toggle-group-context.d.ts +1 -1
- package/dist/option-list-CxhR_DGq.d.cts +34 -0
- package/dist/option-list-CxhR_DGq.d.ts +34 -0
- package/dist/popover-DmcqNOkO.d.cts +31 -0
- package/dist/popover-DmcqNOkO.d.ts +31 -0
- package/dist/styles/spark-default.css +21 -0
- package/dist/styles/theme.css +2 -1
- package/dist/utils/cn.d.cts +1 -1
- package/dist/utils/cn.d.ts +1 -1
- package/package.json +3 -3
- package/dist/calendar-lists-CTby2kR5.d.cts +0 -27
- package/dist/calendar-lists-DoloqsCN.d.ts +0 -27
- package/dist/lib/calendar-day-button.cjs +0 -23
- package/dist/lib/calendar-day-button.cjs.map +0 -1
- package/dist/lib/calendar-day-button.d.cts +0 -14
- package/dist/lib/calendar-day-button.d.ts +0 -14
- package/dist/lib/calendar-day-button.js +0 -20
- package/dist/lib/calendar-day-button.js.map +0 -1
- package/dist/lib/input-date-parts.cjs +0 -155
- package/dist/lib/input-date-parts.cjs.map +0 -1
- package/dist/lib/input-date-parts.d.cts +0 -53
- package/dist/lib/input-date-parts.d.ts +0 -53
- package/dist/lib/input-date-parts.js +0 -148
- package/dist/lib/input-date-parts.js.map +0 -1
- package/dist/lib/scroll-within.cjs +0 -27
- package/dist/lib/scroll-within.cjs.map +0 -1
- package/dist/lib/scroll-within.d.cts +0 -14
- package/dist/lib/scroll-within.d.ts +0 -14
- package/dist/lib/scroll-within.js +0 -25
- package/dist/lib/scroll-within.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.cjs","names":["React","Button","FirstPage","ChevronLeft","ChevronRight","LastPage"],"sources":["../../src/components/pagination.tsx"],"sourcesContent":["'use client'\n\nimport {\n ChevronLeft,\n ChevronRight,\n FirstPage,\n LastPage,\n} from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\nimport { Button, type ButtonProps } from './button'\n\ntype PaginationProps = React.ComponentProps<'nav'> & {\n /** Names the navigation for screen readers, in the reader's language. */\n 'aria-label': string\n /** The 1-based page on view. */\n page: number\n /** How many pages there are. */\n totalPages: number\n /** Called with the page to go to. */\n onPageChange: (page: number) => void\n}\n\ninterface PaginationContextValue {\n page: number\n totalPages: number\n onPageChange: (page: number) => void\n}\n\nconst PaginationContext = React.createContext<PaginationContextValue | null>(\n null,\n)\n\nfunction usePagination(part: string) {\n const context = React.useContext(PaginationContext)\n if (!context) throw new Error(`${part} must be placed inside Pagination.`)\n return context\n}\n\nconst Pagination = React.forwardRef<HTMLElement, PaginationProps>(\n ({ page, totalPages, onPageChange, className, ...props }, ref) => {\n const context = React.useMemo(\n () => ({ page, totalPages, onPageChange }),\n [page, totalPages, onPageChange],\n )\n\n return (\n <PaginationContext.Provider value={context}>\n <nav\n ref={ref}\n data-slot=\"pagination\"\n className={cn('flex flex-wrap items-center gap-1', className)}\n {...props}\n />\n </PaginationContext.Provider>\n )\n },\n)\n\nPagination.displayName = 'Pagination'\n\ntype PaginationStepButtonProps = ButtonProps & {\n /** Names the button for screen readers, in the reader's language. */\n 'aria-label': string\n}\n\ntype PaginationStepProps = PaginationStepButtonProps & {\n dataSlot: string\n icon: React.ReactNode\n target: (context: PaginationContextValue) => number\n}\n\n/** First, previous, next and last: an icon button that is disabled once its target is the page on view. */\nfunction PaginationStep({\n dataSlot,\n icon,\n target,\n children,\n onClick,\n ...props\n}: PaginationStepProps) {\n const context = usePagination('Pagination buttons')\n const lastPage = Math.max(context.totalPages, 1)\n const toPageRange = (page: number) => Math.min(Math.max(page, 1), lastPage)\n const targetPage = toPageRange(target(context))\n\n return (\n <Button\n data-slot={dataSlot}\n disabled={targetPage === toPageRange(context.page)}\n focusableWhenDisabled\n size=\"icon\"\n styleVariant=\"ghost\"\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) context.onPageChange(targetPage)\n }}\n {...props}\n >\n {children ?? icon}\n </Button>\n )\n}\n\ntype PaginationFirstProps = PaginationStepButtonProps\n\nfunction PaginationFirst(props: PaginationFirstProps) {\n return (\n <PaginationStep\n icon={<FirstPage />}\n dataSlot=\"pagination-first\"\n target={() => 1}\n {...props}\n />\n )\n}\n\ntype PaginationPreviousProps = PaginationStepButtonProps\n\nfunction PaginationPrevious(props: PaginationPreviousProps) {\n return (\n <PaginationStep\n icon={<ChevronLeft />}\n dataSlot=\"pagination-previous\"\n target={({ page }) => page - 1}\n {...props}\n />\n )\n}\n\ntype PaginationNextProps = PaginationStepButtonProps\n\nfunction PaginationNext(props: PaginationNextProps) {\n return (\n <PaginationStep\n icon={<ChevronRight />}\n dataSlot=\"pagination-next\"\n target={({ page }) => page + 1}\n {...props}\n />\n )\n}\n\ntype PaginationLastProps = PaginationStepButtonProps\n\nfunction PaginationLast(props: PaginationLastProps) {\n return (\n <PaginationStep\n icon={<LastPage />}\n dataSlot=\"pagination-last\"\n target={({ totalPages }) => totalPages}\n {...props}\n />\n )\n}\n\ntype PaginationPageProps = ButtonProps & {\n /** The 1-based page this button goes to; also its default content. */\n page: number\n}\n\nfunction PaginationPage({\n page,\n className,\n children,\n onClick,\n ...props\n}: PaginationPageProps) {\n const context = usePagination('PaginationPage')\n const isCurrent = page === context.page\n\n return (\n <Button\n aria-current={isCurrent ? 'page' : undefined}\n data-slot=\"pagination-page\"\n className={cn('tabular-nums', !isCurrent && 'font-normal', className)}\n size=\"icon\"\n styleVariant={isCurrent ? 'soft' : 'ghost'}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) context.onPageChange(page)\n }}\n {...props}\n >\n {children ?? page}\n </Button>\n )\n}\n\ntype PaginationRangeProps = React.ComponentProps<'span'>\n\nfunction PaginationRange({ className, ...props }: PaginationRangeProps) {\n return (\n <span\n data-slot=\"pagination-range\"\n className={cn('ps-3 text-sm text-gray-light tabular-nums', className)}\n {...props}\n />\n )\n}\n\nexport {\n Pagination,\n PaginationFirst,\n PaginationLast,\n PaginationNext,\n PaginationPage,\n PaginationPrevious,\n PaginationRange,\n}\nexport type {\n PaginationFirstProps,\n PaginationLastProps,\n PaginationNextProps,\n PaginationPageProps,\n PaginationPreviousProps,\n PaginationProps,\n PaginationRangeProps,\n}\n"],"mappings":";;;;;;;;;;;AA6BA,MAAM,oBAAoBA,MAAM,cAC9B,IACF;AAEA,SAAS,cAAc,MAAc;CACnC,MAAM,UAAUA,MAAM,WAAW,iBAAiB;CAClD,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,GAAG,KAAK,mCAAmC;CACzE,OAAO;AACT;AAEA,MAAM,aAAaA,MAAM,YACtB,EAAE,MAAM,YAAY,cAAc,WAAW,GAAG,SAAS,QAAQ;CAChE,MAAM,UAAUA,MAAM,eACb;EAAE;EAAM;EAAY;CAAa,IACxC;EAAC;EAAM;EAAY;CAAY,CACjC;CAEA,OACE,iBAAA,GAAA,kBAAA,KAAC,kBAAkB,UAAnB;EAA4B,OAAO;YACjC,iBAAA,GAAA,kBAAA,KAAC,OAAD;GACO;GACL,aAAU;GACV,YAAA,GAAA,GAAA,IAAc,qCAAqC,SAAS;GAC5D,GAAI;EACL,CAAA;CACyB,CAAA;AAEhC,CACF;AAEA,WAAW,cAAc;;AAczB,SAAS,eAAe,EACtB,UACA,MACA,QACA,UACA,SACA,GAAG,SACmB;CACtB,MAAM,UAAU,cAAc,oBAAoB;CAClD,MAAM,WAAW,KAAK,IAAI,QAAQ,YAAY,CAAC;CAC/C,MAAM,eAAe,SAAiB,KAAK,IAAI,KAAK,IAAI,MAAM,CAAC,GAAG,QAAQ;CAC1E,MAAM,aAAa,YAAY,OAAO,OAAO,CAAC;CAE9C,OACE,iBAAA,GAAA,kBAAA,KAACC,0BAAAA,QAAD;EACE,aAAW;EACX,UAAU,eAAe,YAAY,QAAQ,IAAI;EACjD,uBAAA;EACA,MAAK;EACL,cAAa;EACb,UAAU,UAAU;GAClB,UAAU,KAAK;GACf,IAAI,CAAC,MAAM,kBAAkB,QAAQ,aAAa,UAAU;EAC9D;EACA,GAAI;YAEH,YAAY;CACP,CAAA;AAEZ;AAIA,SAAS,gBAAgB,OAA6B;CACpD,OACE,iBAAA,GAAA,kBAAA,KAAC,gBAAD;EACE,MAAM,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,WAAD,CAAY,CAAA;EAClB,UAAS;EACT,cAAc;EACd,GAAI;CACL,CAAA;AAEL;AAIA,SAAS,mBAAmB,OAAgC;CAC1D,OACE,iBAAA,GAAA,kBAAA,KAAC,gBAAD;EACE,MAAM,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,aAAD,CAAc,CAAA;EACpB,UAAS;EACT,SAAS,EAAE,WAAW,OAAO;EAC7B,GAAI;CACL,CAAA;AAEL;AAIA,SAAS,eAAe,OAA4B;CAClD,OACE,iBAAA,GAAA,kBAAA,KAAC,gBAAD;EACE,MAAM,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,cAAD,CAAe,CAAA;EACrB,UAAS;EACT,SAAS,EAAE,WAAW,OAAO;EAC7B,GAAI;CACL,CAAA;AAEL;AAIA,SAAS,eAAe,OAA4B;CAClD,OACE,iBAAA,GAAA,kBAAA,KAAC,gBAAD;EACE,MAAM,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,UAAD,CAAW,CAAA;EACjB,UAAS;EACT,SAAS,EAAE,iBAAiB;EAC5B,GAAI;CACL,CAAA;AAEL;AAOA,SAAS,eAAe,EACtB,MACA,WACA,UACA,SACA,GAAG,SACmB;CACtB,MAAM,UAAU,cAAc,gBAAgB;CAC9C,MAAM,YAAY,SAAS,QAAQ;CAEnC,OACE,iBAAA,GAAA,kBAAA,KAACJ,0BAAAA,QAAD;EACE,gBAAc,YAAY,SAAS,KAAA;EACnC,aAAU;EACV,YAAA,GAAA,GAAA,IAAc,gBAAgB,CAAC,aAAa,eAAe,SAAS;EACpE,MAAK;EACL,cAAc,YAAY,SAAS;EACnC,UAAU,UAAU;GAClB,UAAU,KAAK;GACf,IAAI,CAAC,MAAM,kBAAkB,QAAQ,aAAa,IAAI;EACxD;EACA,GAAI;YAEH,YAAY;CACP,CAAA;AAEZ;AAIA,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAA+B;CACtE,OACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;EACE,aAAU;EACV,YAAA,GAAA,GAAA,IAAc,6CAA6C,SAAS;EACpE,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { r as ButtonProps } from "../button-DBcEcIMk.cjs";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/pagination.d.ts
|
|
7
|
+
type PaginationProps = React$1.ComponentProps<'nav'> & {
|
|
8
|
+
/** Names the navigation for screen readers, in the reader's language. */'aria-label': string; /** The 1-based page on view. */
|
|
9
|
+
page: number; /** How many pages there are. */
|
|
10
|
+
totalPages: number; /** Called with the page to go to. */
|
|
11
|
+
onPageChange: (page: number) => void;
|
|
12
|
+
};
|
|
13
|
+
declare const Pagination: React$1.ForwardRefExoticComponent<Omit<PaginationProps, "ref"> & React$1.RefAttributes<HTMLElement>>;
|
|
14
|
+
type PaginationStepButtonProps = ButtonProps & {
|
|
15
|
+
/** Names the button for screen readers, in the reader's language. */'aria-label': string;
|
|
16
|
+
};
|
|
17
|
+
type PaginationFirstProps = PaginationStepButtonProps;
|
|
18
|
+
declare function PaginationFirst(props: PaginationFirstProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
type PaginationPreviousProps = PaginationStepButtonProps;
|
|
20
|
+
declare function PaginationPrevious(props: PaginationPreviousProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
type PaginationNextProps = PaginationStepButtonProps;
|
|
22
|
+
declare function PaginationNext(props: PaginationNextProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
type PaginationLastProps = PaginationStepButtonProps;
|
|
24
|
+
declare function PaginationLast(props: PaginationLastProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
type PaginationPageProps = ButtonProps & {
|
|
26
|
+
/** The 1-based page this button goes to; also its default content. */page: number;
|
|
27
|
+
};
|
|
28
|
+
declare function PaginationPage({
|
|
29
|
+
page,
|
|
30
|
+
className,
|
|
31
|
+
children,
|
|
32
|
+
onClick,
|
|
33
|
+
...props
|
|
34
|
+
}: PaginationPageProps): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
type PaginationRangeProps = React$1.ComponentProps<'span'>;
|
|
36
|
+
declare function PaginationRange({
|
|
37
|
+
className,
|
|
38
|
+
...props
|
|
39
|
+
}: PaginationRangeProps): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Pagination, PaginationFirst, type PaginationFirstProps, PaginationLast, type PaginationLastProps, PaginationNext, type PaginationNextProps, PaginationPage, type PaginationPageProps, PaginationPrevious, type PaginationPreviousProps, type PaginationProps, PaginationRange, type PaginationRangeProps };
|
|
42
|
+
//# sourceMappingURL=pagination.d.cts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { r as ButtonProps } from "../button-B_RNHEc7.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/pagination.d.ts
|
|
7
|
+
type PaginationProps = React$1.ComponentProps<'nav'> & {
|
|
8
|
+
/** Names the navigation for screen readers, in the reader's language. */'aria-label': string; /** The 1-based page on view. */
|
|
9
|
+
page: number; /** How many pages there are. */
|
|
10
|
+
totalPages: number; /** Called with the page to go to. */
|
|
11
|
+
onPageChange: (page: number) => void;
|
|
12
|
+
};
|
|
13
|
+
declare const Pagination: React$1.ForwardRefExoticComponent<Omit<PaginationProps, "ref"> & React$1.RefAttributes<HTMLElement>>;
|
|
14
|
+
type PaginationStepButtonProps = ButtonProps & {
|
|
15
|
+
/** Names the button for screen readers, in the reader's language. */'aria-label': string;
|
|
16
|
+
};
|
|
17
|
+
type PaginationFirstProps = PaginationStepButtonProps;
|
|
18
|
+
declare function PaginationFirst(props: PaginationFirstProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
type PaginationPreviousProps = PaginationStepButtonProps;
|
|
20
|
+
declare function PaginationPrevious(props: PaginationPreviousProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
type PaginationNextProps = PaginationStepButtonProps;
|
|
22
|
+
declare function PaginationNext(props: PaginationNextProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
type PaginationLastProps = PaginationStepButtonProps;
|
|
24
|
+
declare function PaginationLast(props: PaginationLastProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
type PaginationPageProps = ButtonProps & {
|
|
26
|
+
/** The 1-based page this button goes to; also its default content. */page: number;
|
|
27
|
+
};
|
|
28
|
+
declare function PaginationPage({
|
|
29
|
+
page,
|
|
30
|
+
className,
|
|
31
|
+
children,
|
|
32
|
+
onClick,
|
|
33
|
+
...props
|
|
34
|
+
}: PaginationPageProps): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
type PaginationRangeProps = React$1.ComponentProps<'span'>;
|
|
36
|
+
declare function PaginationRange({
|
|
37
|
+
className,
|
|
38
|
+
...props
|
|
39
|
+
}: PaginationRangeProps): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Pagination, PaginationFirst, type PaginationFirstProps, PaginationLast, type PaginationLastProps, PaginationNext, type PaginationNextProps, PaginationPage, type PaginationPageProps, PaginationPrevious, type PaginationPreviousProps, type PaginationProps, PaginationRange, type PaginationRangeProps };
|
|
42
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../utils/cn.js";
|
|
4
|
+
import { Button } from "./button.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { ChevronLeft, ChevronRight, FirstPage, LastPage } from "@epilot/spark-icons";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/pagination.tsx
|
|
9
|
+
const PaginationContext = React$1.createContext(null);
|
|
10
|
+
function usePagination(part) {
|
|
11
|
+
const context = React$1.useContext(PaginationContext);
|
|
12
|
+
if (!context) throw new Error(`${part} must be placed inside Pagination.`);
|
|
13
|
+
return context;
|
|
14
|
+
}
|
|
15
|
+
const Pagination = React$1.forwardRef(({ page, totalPages, onPageChange, className, ...props }, ref) => {
|
|
16
|
+
const context = React$1.useMemo(() => ({
|
|
17
|
+
page,
|
|
18
|
+
totalPages,
|
|
19
|
+
onPageChange
|
|
20
|
+
}), [
|
|
21
|
+
page,
|
|
22
|
+
totalPages,
|
|
23
|
+
onPageChange
|
|
24
|
+
]);
|
|
25
|
+
return /* @__PURE__ */ jsx(PaginationContext.Provider, {
|
|
26
|
+
value: context,
|
|
27
|
+
children: /* @__PURE__ */ jsx("nav", {
|
|
28
|
+
ref,
|
|
29
|
+
"data-slot": "pagination",
|
|
30
|
+
className: cn("flex flex-wrap items-center gap-1", className),
|
|
31
|
+
...props
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
Pagination.displayName = "Pagination";
|
|
36
|
+
/** First, previous, next and last: an icon button that is disabled once its target is the page on view. */
|
|
37
|
+
function PaginationStep({ dataSlot, icon, target, children, onClick, ...props }) {
|
|
38
|
+
const context = usePagination("Pagination buttons");
|
|
39
|
+
const lastPage = Math.max(context.totalPages, 1);
|
|
40
|
+
const toPageRange = (page) => Math.min(Math.max(page, 1), lastPage);
|
|
41
|
+
const targetPage = toPageRange(target(context));
|
|
42
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
43
|
+
"data-slot": dataSlot,
|
|
44
|
+
disabled: targetPage === toPageRange(context.page),
|
|
45
|
+
focusableWhenDisabled: true,
|
|
46
|
+
size: "icon",
|
|
47
|
+
styleVariant: "ghost",
|
|
48
|
+
onClick: (event) => {
|
|
49
|
+
onClick?.(event);
|
|
50
|
+
if (!event.defaultPrevented) context.onPageChange(targetPage);
|
|
51
|
+
},
|
|
52
|
+
...props,
|
|
53
|
+
children: children ?? icon
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function PaginationFirst(props) {
|
|
57
|
+
return /* @__PURE__ */ jsx(PaginationStep, {
|
|
58
|
+
icon: /* @__PURE__ */ jsx(FirstPage, {}),
|
|
59
|
+
dataSlot: "pagination-first",
|
|
60
|
+
target: () => 1,
|
|
61
|
+
...props
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function PaginationPrevious(props) {
|
|
65
|
+
return /* @__PURE__ */ jsx(PaginationStep, {
|
|
66
|
+
icon: /* @__PURE__ */ jsx(ChevronLeft, {}),
|
|
67
|
+
dataSlot: "pagination-previous",
|
|
68
|
+
target: ({ page }) => page - 1,
|
|
69
|
+
...props
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function PaginationNext(props) {
|
|
73
|
+
return /* @__PURE__ */ jsx(PaginationStep, {
|
|
74
|
+
icon: /* @__PURE__ */ jsx(ChevronRight, {}),
|
|
75
|
+
dataSlot: "pagination-next",
|
|
76
|
+
target: ({ page }) => page + 1,
|
|
77
|
+
...props
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function PaginationLast(props) {
|
|
81
|
+
return /* @__PURE__ */ jsx(PaginationStep, {
|
|
82
|
+
icon: /* @__PURE__ */ jsx(LastPage, {}),
|
|
83
|
+
dataSlot: "pagination-last",
|
|
84
|
+
target: ({ totalPages }) => totalPages,
|
|
85
|
+
...props
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function PaginationPage({ page, className, children, onClick, ...props }) {
|
|
89
|
+
const context = usePagination("PaginationPage");
|
|
90
|
+
const isCurrent = page === context.page;
|
|
91
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
92
|
+
"aria-current": isCurrent ? "page" : void 0,
|
|
93
|
+
"data-slot": "pagination-page",
|
|
94
|
+
className: cn("tabular-nums", !isCurrent && "font-normal", className),
|
|
95
|
+
size: "icon",
|
|
96
|
+
styleVariant: isCurrent ? "soft" : "ghost",
|
|
97
|
+
onClick: (event) => {
|
|
98
|
+
onClick?.(event);
|
|
99
|
+
if (!event.defaultPrevented) context.onPageChange(page);
|
|
100
|
+
},
|
|
101
|
+
...props,
|
|
102
|
+
children: children ?? page
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function PaginationRange({ className, ...props }) {
|
|
106
|
+
return /* @__PURE__ */ jsx("span", {
|
|
107
|
+
"data-slot": "pagination-range",
|
|
108
|
+
className: cn("ps-3 text-sm text-gray-light tabular-nums", className),
|
|
109
|
+
...props
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { Pagination, PaginationFirst, PaginationLast, PaginationNext, PaginationPage, PaginationPrevious, PaginationRange };
|
|
114
|
+
|
|
115
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","names":["React"],"sources":["../../src/components/pagination.tsx"],"sourcesContent":["'use client'\n\nimport {\n ChevronLeft,\n ChevronRight,\n FirstPage,\n LastPage,\n} from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\nimport { Button, type ButtonProps } from './button'\n\ntype PaginationProps = React.ComponentProps<'nav'> & {\n /** Names the navigation for screen readers, in the reader's language. */\n 'aria-label': string\n /** The 1-based page on view. */\n page: number\n /** How many pages there are. */\n totalPages: number\n /** Called with the page to go to. */\n onPageChange: (page: number) => void\n}\n\ninterface PaginationContextValue {\n page: number\n totalPages: number\n onPageChange: (page: number) => void\n}\n\nconst PaginationContext = React.createContext<PaginationContextValue | null>(\n null,\n)\n\nfunction usePagination(part: string) {\n const context = React.useContext(PaginationContext)\n if (!context) throw new Error(`${part} must be placed inside Pagination.`)\n return context\n}\n\nconst Pagination = React.forwardRef<HTMLElement, PaginationProps>(\n ({ page, totalPages, onPageChange, className, ...props }, ref) => {\n const context = React.useMemo(\n () => ({ page, totalPages, onPageChange }),\n [page, totalPages, onPageChange],\n )\n\n return (\n <PaginationContext.Provider value={context}>\n <nav\n ref={ref}\n data-slot=\"pagination\"\n className={cn('flex flex-wrap items-center gap-1', className)}\n {...props}\n />\n </PaginationContext.Provider>\n )\n },\n)\n\nPagination.displayName = 'Pagination'\n\ntype PaginationStepButtonProps = ButtonProps & {\n /** Names the button for screen readers, in the reader's language. */\n 'aria-label': string\n}\n\ntype PaginationStepProps = PaginationStepButtonProps & {\n dataSlot: string\n icon: React.ReactNode\n target: (context: PaginationContextValue) => number\n}\n\n/** First, previous, next and last: an icon button that is disabled once its target is the page on view. */\nfunction PaginationStep({\n dataSlot,\n icon,\n target,\n children,\n onClick,\n ...props\n}: PaginationStepProps) {\n const context = usePagination('Pagination buttons')\n const lastPage = Math.max(context.totalPages, 1)\n const toPageRange = (page: number) => Math.min(Math.max(page, 1), lastPage)\n const targetPage = toPageRange(target(context))\n\n return (\n <Button\n data-slot={dataSlot}\n disabled={targetPage === toPageRange(context.page)}\n focusableWhenDisabled\n size=\"icon\"\n styleVariant=\"ghost\"\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) context.onPageChange(targetPage)\n }}\n {...props}\n >\n {children ?? icon}\n </Button>\n )\n}\n\ntype PaginationFirstProps = PaginationStepButtonProps\n\nfunction PaginationFirst(props: PaginationFirstProps) {\n return (\n <PaginationStep\n icon={<FirstPage />}\n dataSlot=\"pagination-first\"\n target={() => 1}\n {...props}\n />\n )\n}\n\ntype PaginationPreviousProps = PaginationStepButtonProps\n\nfunction PaginationPrevious(props: PaginationPreviousProps) {\n return (\n <PaginationStep\n icon={<ChevronLeft />}\n dataSlot=\"pagination-previous\"\n target={({ page }) => page - 1}\n {...props}\n />\n )\n}\n\ntype PaginationNextProps = PaginationStepButtonProps\n\nfunction PaginationNext(props: PaginationNextProps) {\n return (\n <PaginationStep\n icon={<ChevronRight />}\n dataSlot=\"pagination-next\"\n target={({ page }) => page + 1}\n {...props}\n />\n )\n}\n\ntype PaginationLastProps = PaginationStepButtonProps\n\nfunction PaginationLast(props: PaginationLastProps) {\n return (\n <PaginationStep\n icon={<LastPage />}\n dataSlot=\"pagination-last\"\n target={({ totalPages }) => totalPages}\n {...props}\n />\n )\n}\n\ntype PaginationPageProps = ButtonProps & {\n /** The 1-based page this button goes to; also its default content. */\n page: number\n}\n\nfunction PaginationPage({\n page,\n className,\n children,\n onClick,\n ...props\n}: PaginationPageProps) {\n const context = usePagination('PaginationPage')\n const isCurrent = page === context.page\n\n return (\n <Button\n aria-current={isCurrent ? 'page' : undefined}\n data-slot=\"pagination-page\"\n className={cn('tabular-nums', !isCurrent && 'font-normal', className)}\n size=\"icon\"\n styleVariant={isCurrent ? 'soft' : 'ghost'}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) context.onPageChange(page)\n }}\n {...props}\n >\n {children ?? page}\n </Button>\n )\n}\n\ntype PaginationRangeProps = React.ComponentProps<'span'>\n\nfunction PaginationRange({ className, ...props }: PaginationRangeProps) {\n return (\n <span\n data-slot=\"pagination-range\"\n className={cn('ps-3 text-sm text-gray-light tabular-nums', className)}\n {...props}\n />\n )\n}\n\nexport {\n Pagination,\n PaginationFirst,\n PaginationLast,\n PaginationNext,\n PaginationPage,\n PaginationPrevious,\n PaginationRange,\n}\nexport type {\n PaginationFirstProps,\n PaginationLastProps,\n PaginationNextProps,\n PaginationPageProps,\n PaginationPreviousProps,\n PaginationProps,\n PaginationRangeProps,\n}\n"],"mappings":";;;;;;;;AA6BA,MAAM,oBAAoBA,QAAM,cAC9B,IACF;AAEA,SAAS,cAAc,MAAc;CACnC,MAAM,UAAUA,QAAM,WAAW,iBAAiB;CAClD,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,GAAG,KAAK,mCAAmC;CACzE,OAAO;AACT;AAEA,MAAM,aAAaA,QAAM,YACtB,EAAE,MAAM,YAAY,cAAc,WAAW,GAAG,SAAS,QAAQ;CAChE,MAAM,UAAUA,QAAM,eACb;EAAE;EAAM;EAAY;CAAa,IACxC;EAAC;EAAM;EAAY;CAAY,CACjC;CAEA,OACE,oBAAC,kBAAkB,UAAnB;EAA4B,OAAO;YACjC,oBAAC,OAAD;GACO;GACL,aAAU;GACV,WAAW,GAAG,qCAAqC,SAAS;GAC5D,GAAI;EACL,CAAA;CACyB,CAAA;AAEhC,CACF;AAEA,WAAW,cAAc;;AAczB,SAAS,eAAe,EACtB,UACA,MACA,QACA,UACA,SACA,GAAG,SACmB;CACtB,MAAM,UAAU,cAAc,oBAAoB;CAClD,MAAM,WAAW,KAAK,IAAI,QAAQ,YAAY,CAAC;CAC/C,MAAM,eAAe,SAAiB,KAAK,IAAI,KAAK,IAAI,MAAM,CAAC,GAAG,QAAQ;CAC1E,MAAM,aAAa,YAAY,OAAO,OAAO,CAAC;CAE9C,OACE,oBAAC,QAAD;EACE,aAAW;EACX,UAAU,eAAe,YAAY,QAAQ,IAAI;EACjD,uBAAA;EACA,MAAK;EACL,cAAa;EACb,UAAU,UAAU;GAClB,UAAU,KAAK;GACf,IAAI,CAAC,MAAM,kBAAkB,QAAQ,aAAa,UAAU;EAC9D;EACA,GAAI;YAEH,YAAY;CACP,CAAA;AAEZ;AAIA,SAAS,gBAAgB,OAA6B;CACpD,OACE,oBAAC,gBAAD;EACE,MAAM,oBAAC,WAAD,CAAY,CAAA;EAClB,UAAS;EACT,cAAc;EACd,GAAI;CACL,CAAA;AAEL;AAIA,SAAS,mBAAmB,OAAgC;CAC1D,OACE,oBAAC,gBAAD;EACE,MAAM,oBAAC,aAAD,CAAc,CAAA;EACpB,UAAS;EACT,SAAS,EAAE,WAAW,OAAO;EAC7B,GAAI;CACL,CAAA;AAEL;AAIA,SAAS,eAAe,OAA4B;CAClD,OACE,oBAAC,gBAAD;EACE,MAAM,oBAAC,cAAD,CAAe,CAAA;EACrB,UAAS;EACT,SAAS,EAAE,WAAW,OAAO;EAC7B,GAAI;CACL,CAAA;AAEL;AAIA,SAAS,eAAe,OAA4B;CAClD,OACE,oBAAC,gBAAD;EACE,MAAM,oBAAC,UAAD,CAAW,CAAA;EACjB,UAAS;EACT,SAAS,EAAE,iBAAiB;EAC5B,GAAI;CACL,CAAA;AAEL;AAOA,SAAS,eAAe,EACtB,MACA,WACA,UACA,SACA,GAAG,SACmB;CACtB,MAAM,UAAU,cAAc,gBAAgB;CAC9C,MAAM,YAAY,SAAS,QAAQ;CAEnC,OACE,oBAAC,QAAD;EACE,gBAAc,YAAY,SAAS,KAAA;EACnC,aAAU;EACV,WAAW,GAAG,gBAAgB,CAAC,aAAa,eAAe,SAAS;EACpE,MAAK;EACL,cAAc,YAAY,SAAS;EACnC,UAAU,UAAU;GAClB,UAAU,KAAK;GACf,IAAI,CAAC,MAAM,kBAAkB,QAAQ,aAAa,IAAI;EACxD;EACA,GAAI;YAEH,YAAY;CACP,CAAA;AAEZ;AAIA,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAA+B;CACtE,OACE,oBAAC,QAAD;EACE,aAAU;EACV,WAAW,GAAG,6CAA6C,SAAS;EACpE,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { ButtonProps } from "
|
|
3
|
+
import { r as ButtonProps } from "../button-DBcEcIMk.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/components/period-tabs.d.ts
|
|
6
6
|
type PeriodStepperButtonProps = Omit<ButtonProps, 'styleVariant' | 'color' | 'size' | 'children' | 'aria-label'> & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { ButtonProps } from "
|
|
3
|
+
import { r as ButtonProps } from "../button-B_RNHEc7.js";
|
|
4
4
|
|
|
5
5
|
//#region src/components/period-tabs.d.ts
|
|
6
6
|
type PeriodStepperButtonProps = Omit<ButtonProps, 'styleVariant' | 'color' | 'size' | 'children' | 'aria-label'> & {
|
package/dist/components/pill.cjs
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
"use client";
|
|
2
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
4
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
5
|
const require_lib_accent_colors = require("../lib/accent-colors.cjs");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
react = require_chunk.__toESM(react);
|
|
7
8
|
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
9
|
+
let _base_ui_react_button = require("@base-ui/react/button");
|
|
8
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
11
|
let cn = require("cn");
|
|
10
12
|
//#region src/components/pill.tsx
|
|
13
|
+
const PillDisabledContext = react.createContext(false);
|
|
11
14
|
/**
|
|
12
15
|
* Like Badge, but interactive: `onClick` makes the whole pill a button
|
|
13
16
|
* (Enter/Space), `onRemove` adds a Delete/Backspace-and-click affordance.
|
|
@@ -34,33 +37,49 @@ const Pill = react.forwardRef(function Pill({ className, children, styleVariant,
|
|
|
34
37
|
},
|
|
35
38
|
...focusable && { tabIndex: 0 }
|
|
36
39
|
};
|
|
37
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
children:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
40
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PillDisabledContext.Provider, {
|
|
41
|
+
value: disabled,
|
|
42
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
43
|
+
"aria-disabled": disabled || void 0,
|
|
44
|
+
"aria-keyshortcuts": removable ? "Delete" : void 0,
|
|
45
|
+
"data-slot": "pill",
|
|
46
|
+
"data-style": hasLook ? styleVariant ?? "soft" : void 0,
|
|
47
|
+
"data-accent-color": color ? require_lib_accent_colors.accentByColor[color] : void 0,
|
|
48
|
+
...interaction,
|
|
49
|
+
ref,
|
|
50
|
+
className: (0, cn.cn)("inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none", "bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--spark-badge-fg,var(--neutral-a11)))", "shadow-[inset_0_0_0_var(--spark-style-border-width,1px)_var(--spark-style-border,transparent)]", focusable && "transition-colors motion-reduce:transition-none", clickable && "cursor-pointer hover:bg-(--spark-style-bg-hover,var(--neutral-a4))", disabled && "pointer-events-none opacity-50", className),
|
|
51
|
+
...props,
|
|
52
|
+
children: [children, removable ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
53
|
+
className: "sr-only",
|
|
54
|
+
children: removeLabel
|
|
55
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
56
|
+
"aria-hidden": "true",
|
|
57
|
+
"data-slot": "pill-remove",
|
|
58
|
+
onClick: (event) => {
|
|
59
|
+
event.stopPropagation();
|
|
60
|
+
onRemove?.(event);
|
|
61
|
+
},
|
|
62
|
+
className: "-mr-1 inline-flex size-4 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) motion-reduce:transition-none",
|
|
63
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_epilot_spark_icons.Close, { className: "[--spark-icon-size:14px]" })
|
|
64
|
+
})] }) : null]
|
|
65
|
+
})
|
|
60
66
|
});
|
|
61
67
|
});
|
|
62
68
|
Pill.displayName = "Pill";
|
|
69
|
+
/** A button inside a static `Pill` (no `onClick`, no `onRemove`); it is disabled with the pill. */
|
|
70
|
+
const PillButton = react.forwardRef(function PillButton({ className, disabled, ...props }, ref) {
|
|
71
|
+
const pillDisabled = react.useContext(PillDisabledContext);
|
|
72
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_button.Button, {
|
|
73
|
+
ref,
|
|
74
|
+
"data-slot": "pill-button",
|
|
75
|
+
disabled: disabled ?? pillDisabled,
|
|
76
|
+
className: (0, cn.cn)("-mr-2 inline-flex size-[24px] shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) focus-visible:outline-current motion-reduce:transition-none", className),
|
|
77
|
+
...props
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
PillButton.displayName = "PillButton";
|
|
63
81
|
//#endregion
|
|
64
82
|
exports.Pill = Pill;
|
|
83
|
+
exports.PillButton = PillButton;
|
|
65
84
|
|
|
66
85
|
//# sourceMappingURL=pill.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pill.cjs","names":["React","accentByColor","Close"],"sources":["../../src/components/pill.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"pill.cjs","names":["React","accentByColor","Close","ButtonPrimitive"],"sources":["../../src/components/pill.tsx"],"sourcesContent":["'use client'\n\nimport { Button as ButtonPrimitive } from '@base-ui/react/button'\nimport { Close } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkAccentColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\ntype PillOnRemoveProps =\n | { onRemove?: undefined; removeLabel?: string }\n | {\n /** Fires on a pointer click of the (decorative) glyph, or Delete/Backspace while the pill has focus. */\n onRemove: (event: React.SyntheticEvent) => void\n /** Visually-hidden text folded into the pill's accessible name -- the glyph itself is `aria-hidden`. */\n removeLabel: string\n }\n\ntype PillProps = Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick'> &\n PillOnRemoveProps & {\n styleVariant?: SparkStyle\n color?: SparkAccentColor\n disabled?: boolean\n onClick?: (event: React.SyntheticEvent<HTMLSpanElement>) => void\n }\n\nconst PillDisabledContext = React.createContext(false)\n\n/**\n * Like Badge, but interactive: `onClick` makes the whole pill a button\n * (Enter/Space), `onRemove` adds a Delete/Backspace-and-click affordance.\n * Both are optional -- with neither, it's a static label.\n */\nconst Pill = React.forwardRef<HTMLSpanElement, PillProps>(function Pill(\n {\n className,\n children,\n styleVariant,\n color,\n disabled = false,\n onClick,\n onRemove,\n removeLabel,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const clickable = !disabled && onClick !== undefined\n const removable = !disabled && onRemove !== undefined\n const focusable = clickable || removable\n const hasLook = styleVariant !== undefined || color !== undefined\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n onKeyDown?.(event)\n if (clickable && (event.key === 'Enter' || event.key === ' ')) {\n if (event.key === ' ') event.preventDefault()\n onClick?.(event)\n }\n if (removable && (event.key === 'Delete' || event.key === 'Backspace')) {\n onRemove?.(event)\n }\n }\n\n // button role and click handler travel together, so a clickable pill always\n // answers Enter/Space; a removable-only pill stays generic and answers Delete\n const interaction = {\n onKeyDown: handleKeyDown,\n ...(clickable && { role: 'button' as const, onClick }),\n ...(focusable && { tabIndex: 0 }),\n }\n\n return (\n <PillDisabledContext.Provider value={disabled}>\n <span\n aria-disabled={disabled || undefined}\n aria-keyshortcuts={removable ? 'Delete' : undefined}\n data-slot=\"pill\"\n data-style={hasLook ? (styleVariant ?? 'soft') : undefined}\n data-accent-color={color ? accentByColor[color] : undefined}\n {...interaction}\n ref={ref}\n className={cn(\n 'inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none',\n 'bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--spark-badge-fg,var(--neutral-a11)))',\n 'shadow-[inset_0_0_0_var(--spark-style-border-width,1px)_var(--spark-style-border,transparent)]',\n focusable && 'transition-colors motion-reduce:transition-none',\n clickable &&\n 'cursor-pointer hover:bg-(--spark-style-bg-hover,var(--neutral-a4))',\n disabled && 'pointer-events-none opacity-50',\n className,\n )}\n {...props}\n >\n {children}\n {removable ? (\n <>\n {/* aria-hidden hides the glyph itself; this carries removeLabel into the pill's own accessible name */}\n <span className=\"sr-only\">{removeLabel}</span>\n <span\n aria-hidden=\"true\"\n data-slot=\"pill-remove\"\n onClick={(event) => {\n event.stopPropagation()\n onRemove?.(event)\n }}\n className=\"-mr-1 inline-flex size-4 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) motion-reduce:transition-none\"\n >\n <Close className=\"[--spark-icon-size:14px]\" />\n </span>\n </>\n ) : null}\n </span>\n </PillDisabledContext.Provider>\n )\n})\n\nPill.displayName = 'Pill'\n\ntype PillButtonProps = Omit<\n React.ComponentProps<typeof ButtonPrimitive>,\n 'ref' | 'className' | 'aria-label'\n> & {\n className?: string\n /** Names the button; the icon inside is decorative. */\n 'aria-label': string\n}\n\n/** A button inside a static `Pill` (no `onClick`, no `onRemove`); it is disabled with the pill. */\nconst PillButton = React.forwardRef<HTMLButtonElement, PillButtonProps>(\n function PillButton({ className, disabled, ...props }, ref) {\n const pillDisabled = React.useContext(PillDisabledContext)\n return (\n <ButtonPrimitive\n ref={ref}\n data-slot=\"pill-button\"\n disabled={disabled ?? pillDisabled}\n // fixed 24px target at any scaling; the ring takes the pill's ink, which reads on its fill\n className={cn(\n '-mr-2 inline-flex size-[24px] shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) focus-visible:outline-current motion-reduce:transition-none',\n className,\n )}\n {...props}\n />\n )\n },\n)\n\nPillButton.displayName = 'PillButton'\n\nexport { Pill, PillButton }\nexport type { PillButtonProps, PillProps }\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,sBAAsBA,MAAM,cAAc,KAAK;;;;;;AAOrD,MAAM,OAAOA,MAAM,WAAuC,SAAS,KACjE,EACE,WACA,UACA,cACA,OACA,WAAW,OACX,SACA,UACA,aACA,WACA,GAAG,SAEL,KACA;CACA,MAAM,YAAY,CAAC,YAAY,YAAY,KAAA;CAC3C,MAAM,YAAY,CAAC,YAAY,aAAa,KAAA;CAC5C,MAAM,YAAY,aAAa;CAC/B,MAAM,UAAU,iBAAiB,KAAA,KAAa,UAAU,KAAA;CAExD,MAAM,iBAAiB,UAAgD;EACrE,YAAY,KAAK;EACjB,IAAI,cAAc,MAAM,QAAQ,WAAW,MAAM,QAAQ,MAAM;GAC7D,IAAI,MAAM,QAAQ,KAAK,MAAM,eAAe;GAC5C,UAAU,KAAK;EACjB;EACA,IAAI,cAAc,MAAM,QAAQ,YAAY,MAAM,QAAQ,cACxD,WAAW,KAAK;CAEpB;CAIA,MAAM,cAAc;EAClB,WAAW;EACX,GAAI,aAAa;GAAE,MAAM;GAAmB;EAAQ;EACpD,GAAI,aAAa,EAAE,UAAU,EAAE;CACjC;CAEA,OACE,iBAAA,GAAA,kBAAA,KAAC,oBAAoB,UAArB;EAA8B,OAAO;YACnC,iBAAA,GAAA,kBAAA,MAAC,QAAD;GACE,iBAAe,YAAY,KAAA;GAC3B,qBAAmB,YAAY,WAAW,KAAA;GAC1C,aAAU;GACV,cAAY,UAAW,gBAAgB,SAAU,KAAA;GACjD,qBAAmB,QAAQC,0BAAAA,cAAc,SAAS,KAAA;GAClD,GAAI;GACC;GACL,YAAA,GAAA,GAAA,IACE,0FACA,4GACA,kGACA,aAAa,mDACb,aACE,sEACF,YAAY,kCACZ,SACF;GACA,GAAI;aAlBN,CAoBG,UACA,YACC,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA,CAEE,iBAAA,GAAA,kBAAA,KAAC,QAAD;IAAM,WAAU;cAAW;GAAkB,CAAA,GAC7C,iBAAA,GAAA,kBAAA,KAAC,QAAD;IACE,eAAY;IACZ,aAAU;IACV,UAAU,UAAU;KAClB,MAAM,gBAAgB;KACtB,WAAW,KAAK;IAClB;IACA,WAAU;cAEV,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,OAAD,EAAO,WAAU,2BAA4B,CAAA;GACzC,CAAA,CACN,EAAA,CAAA,IACA,IACA;;CACsB,CAAA;AAElC,CAAC;AAED,KAAK,cAAc;;AAYnB,MAAM,aAAaF,MAAM,WACvB,SAAS,WAAW,EAAE,WAAW,UAAU,GAAG,SAAS,KAAK;CAC1D,MAAM,eAAeA,MAAM,WAAW,mBAAmB;CACzD,OACE,iBAAA,GAAA,kBAAA,KAACG,sBAAAA,QAAD;EACO;EACL,aAAU;EACV,UAAU,YAAY;EAEtB,YAAA,GAAA,GAAA,IACE,oOACA,SACF;EACA,GAAI;CACL,CAAA;AAEL,CACF;AAEA,WAAW,cAAc"}
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
import { v as SparkStyle } from "../theme-types-CHl-L2F-.cjs";
|
|
4
4
|
import { SparkAccentColor } from "../lib/accent-colors.cjs";
|
|
5
5
|
import * as React$1 from "react";
|
|
6
|
+
import { Button } from "@base-ui/react/button";
|
|
6
7
|
|
|
7
8
|
//#region src/components/pill.d.ts
|
|
8
|
-
type
|
|
9
|
+
type PillOnRemoveProps = {
|
|
9
10
|
onRemove?: undefined;
|
|
10
11
|
removeLabel?: string;
|
|
11
12
|
} | {
|
|
12
13
|
/** Fires on a pointer click of the (decorative) glyph, or Delete/Backspace while the pill has focus. */onRemove: (event: React$1.SyntheticEvent) => void; /** Visually-hidden text folded into the pill's accessible name -- the glyph itself is `aria-hidden`. */
|
|
13
14
|
removeLabel: string;
|
|
14
15
|
};
|
|
15
|
-
type PillProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'onClick'> &
|
|
16
|
+
type PillProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'onClick'> & PillOnRemoveProps & {
|
|
16
17
|
styleVariant?: SparkStyle;
|
|
17
18
|
color?: SparkAccentColor;
|
|
18
19
|
disabled?: boolean;
|
|
@@ -24,6 +25,15 @@ type PillProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'onClick'> & Pill
|
|
|
24
25
|
* Both are optional -- with neither, it's a static label.
|
|
25
26
|
*/
|
|
26
27
|
declare const Pill: React$1.ForwardRefExoticComponent<PillProps & React$1.RefAttributes<HTMLSpanElement>>;
|
|
28
|
+
type PillButtonProps = Omit<React$1.ComponentProps<typeof Button>, 'ref' | 'className' | 'aria-label'> & {
|
|
29
|
+
className?: string; /** Names the button; the icon inside is decorative. */
|
|
30
|
+
'aria-label': string;
|
|
31
|
+
};
|
|
32
|
+
/** A button inside a static `Pill` (no `onClick`, no `onRemove`); it is disabled with the pill. */
|
|
33
|
+
declare const PillButton: React$1.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ButtonProps, "ref"> & React$1.RefAttributes<HTMLElement>, "className" | "ref" | "aria-label"> & {
|
|
34
|
+
className?: string; /** Names the button; the icon inside is decorative. */
|
|
35
|
+
'aria-label': string;
|
|
36
|
+
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
27
37
|
//#endregion
|
|
28
|
-
export { Pill, type PillProps };
|
|
38
|
+
export { Pill, PillButton, type PillButtonProps, type PillProps };
|
|
29
39
|
//# sourceMappingURL=pill.d.cts.map
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
import { v as SparkStyle } from "../theme-types-CHl-L2F-.js";
|
|
4
4
|
import { SparkAccentColor } from "../lib/accent-colors.js";
|
|
5
5
|
import * as React$1 from "react";
|
|
6
|
+
import { Button } from "@base-ui/react/button";
|
|
6
7
|
|
|
7
8
|
//#region src/components/pill.d.ts
|
|
8
|
-
type
|
|
9
|
+
type PillOnRemoveProps = {
|
|
9
10
|
onRemove?: undefined;
|
|
10
11
|
removeLabel?: string;
|
|
11
12
|
} | {
|
|
12
13
|
/** Fires on a pointer click of the (decorative) glyph, or Delete/Backspace while the pill has focus. */onRemove: (event: React$1.SyntheticEvent) => void; /** Visually-hidden text folded into the pill's accessible name -- the glyph itself is `aria-hidden`. */
|
|
13
14
|
removeLabel: string;
|
|
14
15
|
};
|
|
15
|
-
type PillProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'onClick'> &
|
|
16
|
+
type PillProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'onClick'> & PillOnRemoveProps & {
|
|
16
17
|
styleVariant?: SparkStyle;
|
|
17
18
|
color?: SparkAccentColor;
|
|
18
19
|
disabled?: boolean;
|
|
@@ -24,6 +25,15 @@ type PillProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'onClick'> & Pill
|
|
|
24
25
|
* Both are optional -- with neither, it's a static label.
|
|
25
26
|
*/
|
|
26
27
|
declare const Pill: React$1.ForwardRefExoticComponent<PillProps & React$1.RefAttributes<HTMLSpanElement>>;
|
|
28
|
+
type PillButtonProps = Omit<React$1.ComponentProps<typeof Button>, 'ref' | 'className' | 'aria-label'> & {
|
|
29
|
+
className?: string; /** Names the button; the icon inside is decorative. */
|
|
30
|
+
'aria-label': string;
|
|
31
|
+
};
|
|
32
|
+
/** A button inside a static `Pill` (no `onClick`, no `onRemove`); it is disabled with the pill. */
|
|
33
|
+
declare const PillButton: React$1.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ButtonProps, "ref"> & React$1.RefAttributes<HTMLElement>, "className" | "ref" | "aria-label"> & {
|
|
34
|
+
className?: string; /** Names the button; the icon inside is decorative. */
|
|
35
|
+
'aria-label': string;
|
|
36
|
+
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
27
37
|
//#endregion
|
|
28
|
-
export { Pill, type PillProps };
|
|
38
|
+
export { Pill, PillButton, type PillButtonProps, type PillProps };
|
|
29
39
|
//# sourceMappingURL=pill.d.ts.map
|
package/dist/components/pill.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
"use client";
|
|
2
3
|
import { cn } from "../utils/cn.js";
|
|
3
4
|
import { accentByColor } from "../lib/accent-colors.js";
|
|
4
5
|
import * as React$1 from "react";
|
|
5
6
|
import { Close } from "@epilot/spark-icons";
|
|
7
|
+
import { Button } from "@base-ui/react/button";
|
|
6
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
9
|
//#region src/components/pill.tsx
|
|
10
|
+
const PillDisabledContext = React$1.createContext(false);
|
|
8
11
|
/**
|
|
9
12
|
* Like Badge, but interactive: `onClick` makes the whole pill a button
|
|
10
13
|
* (Enter/Space), `onRemove` adds a Delete/Backspace-and-click affordance.
|
|
@@ -31,33 +34,48 @@ const Pill = React$1.forwardRef(function Pill({ className, children, styleVarian
|
|
|
31
34
|
},
|
|
32
35
|
...focusable && { tabIndex: 0 }
|
|
33
36
|
};
|
|
34
|
-
return /* @__PURE__ */
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
children:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
return /* @__PURE__ */ jsx(PillDisabledContext.Provider, {
|
|
38
|
+
value: disabled,
|
|
39
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
40
|
+
"aria-disabled": disabled || void 0,
|
|
41
|
+
"aria-keyshortcuts": removable ? "Delete" : void 0,
|
|
42
|
+
"data-slot": "pill",
|
|
43
|
+
"data-style": hasLook ? styleVariant ?? "soft" : void 0,
|
|
44
|
+
"data-accent-color": color ? accentByColor[color] : void 0,
|
|
45
|
+
...interaction,
|
|
46
|
+
ref,
|
|
47
|
+
className: cn("inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none", "bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--spark-badge-fg,var(--neutral-a11)))", "shadow-[inset_0_0_0_var(--spark-style-border-width,1px)_var(--spark-style-border,transparent)]", focusable && "transition-colors motion-reduce:transition-none", clickable && "cursor-pointer hover:bg-(--spark-style-bg-hover,var(--neutral-a4))", disabled && "pointer-events-none opacity-50", className),
|
|
48
|
+
...props,
|
|
49
|
+
children: [children, removable ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
50
|
+
className: "sr-only",
|
|
51
|
+
children: removeLabel
|
|
52
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
53
|
+
"aria-hidden": "true",
|
|
54
|
+
"data-slot": "pill-remove",
|
|
55
|
+
onClick: (event) => {
|
|
56
|
+
event.stopPropagation();
|
|
57
|
+
onRemove?.(event);
|
|
58
|
+
},
|
|
59
|
+
className: "-mr-1 inline-flex size-4 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) motion-reduce:transition-none",
|
|
60
|
+
children: /* @__PURE__ */ jsx(Close, { className: "[--spark-icon-size:14px]" })
|
|
61
|
+
})] }) : null]
|
|
62
|
+
})
|
|
57
63
|
});
|
|
58
64
|
});
|
|
59
65
|
Pill.displayName = "Pill";
|
|
66
|
+
/** A button inside a static `Pill` (no `onClick`, no `onRemove`); it is disabled with the pill. */
|
|
67
|
+
const PillButton = React$1.forwardRef(function PillButton({ className, disabled, ...props }, ref) {
|
|
68
|
+
const pillDisabled = React$1.useContext(PillDisabledContext);
|
|
69
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
70
|
+
ref,
|
|
71
|
+
"data-slot": "pill-button",
|
|
72
|
+
disabled: disabled ?? pillDisabled,
|
|
73
|
+
className: cn("-mr-2 inline-flex size-[24px] shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) focus-visible:outline-current motion-reduce:transition-none", className),
|
|
74
|
+
...props
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
PillButton.displayName = "PillButton";
|
|
60
78
|
//#endregion
|
|
61
|
-
export { Pill };
|
|
79
|
+
export { Pill, PillButton };
|
|
62
80
|
|
|
63
81
|
//# sourceMappingURL=pill.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pill.js","names":["React"],"sources":["../../src/components/pill.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"pill.js","names":["React","ButtonPrimitive"],"sources":["../../src/components/pill.tsx"],"sourcesContent":["'use client'\n\nimport { Button as ButtonPrimitive } from '@base-ui/react/button'\nimport { Close } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkAccentColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\ntype PillOnRemoveProps =\n | { onRemove?: undefined; removeLabel?: string }\n | {\n /** Fires on a pointer click of the (decorative) glyph, or Delete/Backspace while the pill has focus. */\n onRemove: (event: React.SyntheticEvent) => void\n /** Visually-hidden text folded into the pill's accessible name -- the glyph itself is `aria-hidden`. */\n removeLabel: string\n }\n\ntype PillProps = Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick'> &\n PillOnRemoveProps & {\n styleVariant?: SparkStyle\n color?: SparkAccentColor\n disabled?: boolean\n onClick?: (event: React.SyntheticEvent<HTMLSpanElement>) => void\n }\n\nconst PillDisabledContext = React.createContext(false)\n\n/**\n * Like Badge, but interactive: `onClick` makes the whole pill a button\n * (Enter/Space), `onRemove` adds a Delete/Backspace-and-click affordance.\n * Both are optional -- with neither, it's a static label.\n */\nconst Pill = React.forwardRef<HTMLSpanElement, PillProps>(function Pill(\n {\n className,\n children,\n styleVariant,\n color,\n disabled = false,\n onClick,\n onRemove,\n removeLabel,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const clickable = !disabled && onClick !== undefined\n const removable = !disabled && onRemove !== undefined\n const focusable = clickable || removable\n const hasLook = styleVariant !== undefined || color !== undefined\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n onKeyDown?.(event)\n if (clickable && (event.key === 'Enter' || event.key === ' ')) {\n if (event.key === ' ') event.preventDefault()\n onClick?.(event)\n }\n if (removable && (event.key === 'Delete' || event.key === 'Backspace')) {\n onRemove?.(event)\n }\n }\n\n // button role and click handler travel together, so a clickable pill always\n // answers Enter/Space; a removable-only pill stays generic and answers Delete\n const interaction = {\n onKeyDown: handleKeyDown,\n ...(clickable && { role: 'button' as const, onClick }),\n ...(focusable && { tabIndex: 0 }),\n }\n\n return (\n <PillDisabledContext.Provider value={disabled}>\n <span\n aria-disabled={disabled || undefined}\n aria-keyshortcuts={removable ? 'Delete' : undefined}\n data-slot=\"pill\"\n data-style={hasLook ? (styleVariant ?? 'soft') : undefined}\n data-accent-color={color ? accentByColor[color] : undefined}\n {...interaction}\n ref={ref}\n className={cn(\n 'inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none',\n 'bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--spark-badge-fg,var(--neutral-a11)))',\n 'shadow-[inset_0_0_0_var(--spark-style-border-width,1px)_var(--spark-style-border,transparent)]',\n focusable && 'transition-colors motion-reduce:transition-none',\n clickable &&\n 'cursor-pointer hover:bg-(--spark-style-bg-hover,var(--neutral-a4))',\n disabled && 'pointer-events-none opacity-50',\n className,\n )}\n {...props}\n >\n {children}\n {removable ? (\n <>\n {/* aria-hidden hides the glyph itself; this carries removeLabel into the pill's own accessible name */}\n <span className=\"sr-only\">{removeLabel}</span>\n <span\n aria-hidden=\"true\"\n data-slot=\"pill-remove\"\n onClick={(event) => {\n event.stopPropagation()\n onRemove?.(event)\n }}\n className=\"-mr-1 inline-flex size-4 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) motion-reduce:transition-none\"\n >\n <Close className=\"[--spark-icon-size:14px]\" />\n </span>\n </>\n ) : null}\n </span>\n </PillDisabledContext.Provider>\n )\n})\n\nPill.displayName = 'Pill'\n\ntype PillButtonProps = Omit<\n React.ComponentProps<typeof ButtonPrimitive>,\n 'ref' | 'className' | 'aria-label'\n> & {\n className?: string\n /** Names the button; the icon inside is decorative. */\n 'aria-label': string\n}\n\n/** A button inside a static `Pill` (no `onClick`, no `onRemove`); it is disabled with the pill. */\nconst PillButton = React.forwardRef<HTMLButtonElement, PillButtonProps>(\n function PillButton({ className, disabled, ...props }, ref) {\n const pillDisabled = React.useContext(PillDisabledContext)\n return (\n <ButtonPrimitive\n ref={ref}\n data-slot=\"pill-button\"\n disabled={disabled ?? pillDisabled}\n // fixed 24px target at any scaling; the ring takes the pill's ink, which reads on its fill\n className={cn(\n '-mr-2 inline-flex size-[24px] shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) focus-visible:outline-current motion-reduce:transition-none',\n className,\n )}\n {...props}\n />\n )\n },\n)\n\nPillButton.displayName = 'PillButton'\n\nexport { Pill, PillButton }\nexport type { PillButtonProps, PillProps }\n"],"mappings":";;;;;;;;;AA2BA,MAAM,sBAAsBA,QAAM,cAAc,KAAK;;;;;;AAOrD,MAAM,OAAOA,QAAM,WAAuC,SAAS,KACjE,EACE,WACA,UACA,cACA,OACA,WAAW,OACX,SACA,UACA,aACA,WACA,GAAG,SAEL,KACA;CACA,MAAM,YAAY,CAAC,YAAY,YAAY,KAAA;CAC3C,MAAM,YAAY,CAAC,YAAY,aAAa,KAAA;CAC5C,MAAM,YAAY,aAAa;CAC/B,MAAM,UAAU,iBAAiB,KAAA,KAAa,UAAU,KAAA;CAExD,MAAM,iBAAiB,UAAgD;EACrE,YAAY,KAAK;EACjB,IAAI,cAAc,MAAM,QAAQ,WAAW,MAAM,QAAQ,MAAM;GAC7D,IAAI,MAAM,QAAQ,KAAK,MAAM,eAAe;GAC5C,UAAU,KAAK;EACjB;EACA,IAAI,cAAc,MAAM,QAAQ,YAAY,MAAM,QAAQ,cACxD,WAAW,KAAK;CAEpB;CAIA,MAAM,cAAc;EAClB,WAAW;EACX,GAAI,aAAa;GAAE,MAAM;GAAmB;EAAQ;EACpD,GAAI,aAAa,EAAE,UAAU,EAAE;CACjC;CAEA,OACE,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;YACnC,qBAAC,QAAD;GACE,iBAAe,YAAY,KAAA;GAC3B,qBAAmB,YAAY,WAAW,KAAA;GAC1C,aAAU;GACV,cAAY,UAAW,gBAAgB,SAAU,KAAA;GACjD,qBAAmB,QAAQ,cAAc,SAAS,KAAA;GAClD,GAAI;GACC;GACL,WAAW,GACT,0FACA,4GACA,kGACA,aAAa,mDACb,aACE,sEACF,YAAY,kCACZ,SACF;GACA,GAAI;aAlBN,CAoBG,UACA,YACC,qBAAA,UAAA,EAAA,UAAA,CAEE,oBAAC,QAAD;IAAM,WAAU;cAAW;GAAkB,CAAA,GAC7C,oBAAC,QAAD;IACE,eAAY;IACZ,aAAU;IACV,UAAU,UAAU;KAClB,MAAM,gBAAgB;KACtB,WAAW,KAAK;IAClB;IACA,WAAU;cAEV,oBAAC,OAAD,EAAO,WAAU,2BAA4B,CAAA;GACzC,CAAA,CACN,EAAA,CAAA,IACA,IACA;;CACsB,CAAA;AAElC,CAAC;AAED,KAAK,cAAc;;AAYnB,MAAM,aAAaA,QAAM,WACvB,SAAS,WAAW,EAAE,WAAW,UAAU,GAAG,SAAS,KAAK;CAC1D,MAAM,eAAeA,QAAM,WAAW,mBAAmB;CACzD,OACE,oBAACC,QAAD;EACO;EACL,aAAU;EACV,UAAU,YAAY;EAEtB,WAAW,GACT,oOACA,SACF;EACA,GAAI;CACL,CAAA;AAEL,CACF;AAEA,WAAW,cAAc"}
|
|
@@ -4,9 +4,9 @@ const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
|
4
4
|
const require_components_theme = require("./theme.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
react = require_chunk.__toESM(react);
|
|
7
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
7
|
let _base_ui_react_merge_props = require("@base-ui/react/merge-props");
|
|
9
8
|
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
10
|
let _base_ui_react_popover = require("@base-ui/react/popover");
|
|
11
11
|
let cn = require("cn");
|
|
12
12
|
//#region src/components/popover.tsx
|