jaci-ui 0.9.4 → 1.0.2
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 +25 -0
- package/README.md +11 -1
- package/dist/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/components/accordion/accordion.cjs.map +1 -1
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/alert/alert.cjs.map +1 -1
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.cjs.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/aspect-ratio/aspect-ratio.cjs.map +1 -1
- package/dist/components/avatar/avatar.cjs.map +1 -1
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/breadcrumbs/breadcrumbs.cjs.map +1 -1
- package/dist/components/button/button.cjs +1 -0
- package/dist/components/button/button.cjs.map +1 -1
- package/dist/components/button/button.d.cts +2 -1
- package/dist/components/button/button.d.ts +2 -1
- package/dist/components/button/button.js +1 -0
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button-group/button-group.cjs.map +1 -1
- package/dist/components/calendar/calendar.cjs +4 -6
- package/dist/components/calendar/calendar.cjs.map +1 -1
- package/dist/components/calendar/calendar.js +4 -6
- package/dist/components/calendar/calendar.js.map +1 -1
- package/dist/components/card/card.cjs.map +1 -1
- package/dist/components/carousel/carousel.cjs.map +1 -1
- package/dist/components/carousel/carousel.js.map +1 -1
- package/dist/components/checkbox-group/checkbox-group.cjs +7 -3
- package/dist/components/checkbox-group/checkbox-group.cjs.map +1 -1
- package/dist/components/checkbox-group/checkbox-group.js +7 -3
- package/dist/components/checkbox-group/checkbox-group.js.map +1 -1
- package/dist/components/code/code.cjs.map +1 -1
- package/dist/components/code/code.js.map +1 -1
- package/dist/components/collapsible/collapsible.cjs.map +1 -1
- package/dist/components/collapsible/collapsible.js.map +1 -1
- package/dist/components/color-picker/color-picker.cjs.map +1 -1
- package/dist/components/color-picker/color-picker.js.map +1 -1
- package/dist/components/color-picker/color-utils.cjs +5 -3
- package/dist/components/color-picker/color-utils.cjs.map +1 -1
- package/dist/components/color-picker/color-utils.js +5 -3
- package/dist/components/color-picker/color-utils.js.map +1 -1
- package/dist/components/color-swatch/color-swatch.cjs.map +1 -1
- package/dist/components/combobox/combobox.cjs +2 -1
- package/dist/components/combobox/combobox.cjs.map +1 -1
- package/dist/components/combobox/combobox.js +2 -1
- package/dist/components/combobox/combobox.js.map +1 -1
- package/dist/components/command/command.cjs.map +1 -1
- package/dist/components/command/command.js.map +1 -1
- package/dist/components/context-menu/context-menu.cjs.map +1 -1
- package/dist/components/context-menu/context-menu.d.cts +2 -2
- package/dist/components/context-menu/context-menu.d.ts +2 -2
- package/dist/components/controls/checkbox.cjs.map +1 -1
- package/dist/components/controls/checkbox.js.map +1 -1
- package/dist/components/controls/input.cjs.map +1 -1
- package/dist/components/controls/input.js.map +1 -1
- package/dist/components/controls/radio.cjs.map +1 -1
- package/dist/components/controls/switch.cjs.map +1 -1
- package/dist/components/controls/switch.js.map +1 -1
- package/dist/components/controls/textarea.cjs.map +1 -1
- package/dist/components/controls/textarea.js.map +1 -1
- package/dist/components/copyable/copyable.cjs.map +1 -1
- package/dist/components/copyable/copyable.js.map +1 -1
- package/dist/components/data-toolbar/data-toolbar.cjs.map +1 -1
- package/dist/components/data-toolbar/data-toolbar.js.map +1 -1
- package/dist/components/data-view/data-view.cjs.map +1 -1
- package/dist/components/date-picker/date-picker.cjs +4 -7
- package/dist/components/date-picker/date-picker.cjs.map +1 -1
- package/dist/components/date-picker/date-picker.js +4 -7
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.cjs +4 -6
- package/dist/components/date-range-picker/date-range-picker.cjs.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.js +4 -6
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/dialog/dialog.cjs.map +1 -1
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/download-trigger/download-trigger.cjs.map +1 -1
- package/dist/components/drawer/drawer.cjs.map +1 -1
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/empty-state/empty-state.cjs.map +1 -1
- package/dist/components/feedback/badge.cjs.map +1 -1
- package/dist/components/field/field.cjs.map +1 -1
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/fieldset/fieldset.cjs.map +1 -1
- package/dist/components/figure/figure.cjs.map +1 -1
- package/dist/components/figure/figure.js.map +1 -1
- package/dist/components/form/form.cjs.map +1 -1
- package/dist/components/form/form.js.map +1 -1
- package/dist/components/icon-button/icon-button.cjs.map +1 -1
- package/dist/components/icon-button/icon-button.js.map +1 -1
- package/dist/components/image/image.cjs.map +1 -1
- package/dist/components/image/image.js.map +1 -1
- package/dist/components/input-group/input-group.cjs.map +1 -1
- package/dist/components/kbd/kbd.cjs.map +1 -1
- package/dist/components/layout/index.cjs.map +1 -1
- package/dist/components/list/list.cjs.map +1 -1
- package/dist/components/menu/menu.cjs.map +1 -1
- package/dist/components/menu/menu.d.cts +2 -2
- package/dist/components/menu/menu.d.ts +2 -2
- package/dist/components/menubar/menubar.cjs.map +1 -1
- package/dist/components/menubar/menubar.d.cts +2 -2
- package/dist/components/menubar/menubar.d.ts +2 -2
- package/dist/components/menubar/menubar.js.map +1 -1
- package/dist/components/meter/meter.cjs.map +1 -1
- package/dist/components/meter/meter.js.map +1 -1
- package/dist/components/navigation/navigation.cjs.map +1 -1
- package/dist/components/navigation/navigation.js.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.cjs.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/number-field/number-field.cjs +2 -1
- package/dist/components/number-field/number-field.cjs.map +1 -1
- package/dist/components/number-field/number-field.js +2 -1
- package/dist/components/number-field/number-field.js.map +1 -1
- package/dist/components/option-selector/option-selector.cjs.map +1 -1
- package/dist/components/option-selector/option-selector.js.map +1 -1
- package/dist/components/pagination/pagination.cjs.map +1 -1
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/pin-input/pin-input.cjs.map +1 -1
- package/dist/components/pin-input/pin-input.js.map +1 -1
- package/dist/components/popover/popover.cjs.map +1 -1
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/progress/progress.cjs.map +1 -1
- package/dist/components/progress/progress.js.map +1 -1
- package/dist/components/qr-code/qr-code.cjs.map +1 -1
- package/dist/components/qr-code/qr-code.js.map +1 -1
- package/dist/components/quote/quote.cjs.map +1 -1
- package/dist/components/quote/quote.js.map +1 -1
- package/dist/components/radio-group/radio-group.cjs +7 -3
- package/dist/components/radio-group/radio-group.cjs.map +1 -1
- package/dist/components/radio-group/radio-group.js +7 -3
- package/dist/components/radio-group/radio-group.js.map +1 -1
- package/dist/components/range-slider/range-slider.cjs.map +1 -1
- package/dist/components/range-slider/range-slider.js.map +1 -1
- package/dist/components/scroll-area/scroll-area.cjs.map +1 -1
- package/dist/components/select/select.cjs.map +1 -1
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/sidebar/sidebar.cjs.map +1 -1
- package/dist/components/sidebar/sidebar.js.map +1 -1
- package/dist/components/skeleton/skeleton.cjs.map +1 -1
- package/dist/components/slider/slider.cjs.map +1 -1
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/spacer/spacer.cjs.map +1 -1
- package/dist/components/stat/stat.cjs.map +1 -1
- package/dist/components/stat/stat.js.map +1 -1
- package/dist/components/stepper/stepper.cjs +2 -1
- package/dist/components/stepper/stepper.cjs.map +1 -1
- package/dist/components/stepper/stepper.js +2 -1
- package/dist/components/stepper/stepper.js.map +1 -1
- package/dist/components/table/table.cjs.map +1 -1
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.cjs.map +1 -1
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/tags-input/tags-input.cjs +10 -9
- package/dist/components/tags-input/tags-input.cjs.map +1 -1
- package/dist/components/tags-input/tags-input.js +10 -9
- package/dist/components/tags-input/tags-input.js.map +1 -1
- package/dist/components/toast/toast.cjs.map +1 -1
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toggle/toggle.cjs.map +1 -1
- package/dist/components/toggle-group/toggle-group.cjs.map +1 -1
- package/dist/components/toolbar/toolbar.cjs.map +1 -1
- package/dist/components/tooltip/tooltip.cjs.map +1 -1
- package/dist/components/tree-view/tree-view.cjs.map +1 -1
- package/dist/components/tree-view/tree-view.js.map +1 -1
- package/dist/components/typography/heading.cjs.map +1 -1
- package/dist/components/typography/link.cjs.map +1 -1
- package/dist/components/typography/paragraph.cjs.map +1 -1
- package/dist/components/typography/text.cjs.map +1 -1
- package/dist/components/upload/upload.cjs +2 -2
- package/dist/components/upload/upload.cjs.map +1 -1
- package/dist/components/upload/upload.js +2 -2
- package/dist/components/upload/upload.js.map +1 -1
- package/dist/components/visually-hidden/visually-hidden.cjs.map +1 -1
- package/dist/panda-preset.cjs.map +1 -1
- package/dist/styles/theme.cjs +18 -18
- package/dist/styles/theme.cjs.map +1 -1
- package/dist/styles/theme.js +18 -18
- package/dist/styles/theme.js.map +1 -1
- package/dist/styles.css +12 -21
- package/dist/theme/theme-provider.cjs.map +1 -1
- package/dist/theme/theme-provider.js.map +1 -1
- package/dist/theme/theme-scope.cjs.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.cjs","names":["startOfMonth","calendar","createCalendarDate","isBeforeDay","isAfterDay","addMonths","addDays","dateKey","formatMonthLabel","cx","isSameDay","getCalendarDays","getWeekdayLabels"],"sources":["../../../src/components/calendar/calendar.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { calendar } from \"../../styled-system/recipes\";\nimport {\n addDays,\n addMonths,\n createCalendarDate,\n dateKey,\n formatMonthLabel,\n getCalendarDays,\n getWeekdayLabels,\n isAfterDay,\n isBeforeDay,\n isSameDay,\n startOfMonth,\n} from \"../date-picker/date-utils\";\n\nexport interface CalendarYearRange {\n start: number;\n end: number;\n}\n\nexport interface CalendarRootProps\n extends Omit<ComponentPropsWithoutRef<\"section\">, \"children\" | \"defaultValue\" | \"value\"> {\n value?: Date | null;\n defaultValue?: Date | null;\n onValueChange?: (value: Date | null) => void;\n referenceDate?: Date;\n locale?: string;\n weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n minDate?: Date;\n maxDate?: Date;\n isDateDisabled?: (date: Date) => boolean;\n yearRange?: CalendarYearRange;\n disabled?: boolean;\n children?: ReactNode;\n}\n\ninterface CalendarContextValue {\n calendarId: string;\n dateDisabled: (date: Date) => boolean;\n disabled: boolean;\n focusedDate: Date;\n focusDate: (date: Date, direction?: number) => void;\n locale: string;\n month: Date;\n monthDisabled: (date: Date) => boolean;\n onSelect: (date: Date) => void;\n selected: Date | null;\n setMonth: (date: Date) => void;\n styles: ReturnType<typeof calendar>;\n today: Date;\n weekStartsOn: number;\n yearRange: CalendarYearRange;\n canNavigate: (amount: number) => boolean;\n selectMonth: (month: number) => void;\n selectYear: (year: number) => void;\n registerDay: (key: string, node: HTMLButtonElement | null) => void;\n}\n\nimport { createContext, useContext } from \"react\";\n\nconst CalendarContext = createContext<CalendarContextValue | null>(null);\n\nfunction useCalendarContext() {\n const context = useContext(CalendarContext);\n if (!context) throw new Error(\"Calendar parts must be rendered inside Calendar.Root.\");\n return context;\n}\n\nfunction sameMonth(left: Date, right: Date) {\n return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth();\n}\n\nexport const CalendarRoot = forwardRef<HTMLElement, CalendarRootProps>(function CalendarRoot(\n {\n children,\n className,\n defaultValue = null,\n disabled = false,\n isDateDisabled,\n locale = \"pt-BR\",\n maxDate,\n minDate,\n onValueChange,\n referenceDate,\n value: controlledValue,\n weekStartsOn = 0,\n yearRange: configuredYearRange,\n ...props\n },\n ref,\n) {\n const initialDate = controlledValue ?? defaultValue ?? referenceDate ?? new Date();\n const [uncontrolledValue, setUncontrolledValue] = useState<Date | null>(defaultValue);\n const selected = controlledValue === undefined ? uncontrolledValue : controlledValue;\n const [month, setMonthState] = useState(() => startOfMonth(initialDate));\n const [focusedDate, setFocusedDate] = useState(selected ?? initialDate);\n const dayRefs = useRef(new Map<string, HTMLButtonElement>());\n const calendarId = useId();\n const styles = calendar();\n const today = useMemo(\n () =>\n createCalendarDate(\n (referenceDate ?? new Date()).getFullYear(),\n (referenceDate ?? new Date()).getMonth(),\n (referenceDate ?? new Date()).getDate(),\n ),\n [referenceDate],\n );\n const minMonth = minDate ? startOfMonth(minDate) : undefined;\n const maxMonth = maxDate ? startOfMonth(maxDate) : undefined;\n const yearRange = useMemo(() => {\n const start = configuredYearRange?.start ?? today.getFullYear() - 100;\n const end = configuredYearRange?.end ?? today.getFullYear() + 20;\n const years = [selected?.getFullYear(), minDate?.getFullYear(), maxDate?.getFullYear()].filter(\n (year): year is number => year !== undefined,\n );\n return { start: Math.min(start, end, ...years), end: Math.max(start, end, ...years) };\n }, [configuredYearRange?.end, configuredYearRange?.start, maxDate, minDate, selected, today]);\n\n const dateDisabled = useCallback(\n (date: Date) =>\n Boolean(\n (minDate && isBeforeDay(date, minDate)) ||\n (maxDate && isAfterDay(date, maxDate)) ||\n isDateDisabled?.(date),\n ),\n [isDateDisabled, maxDate, minDate],\n );\n const monthDisabled = useCallback(\n (date: Date) => {\n const first = startOfMonth(date);\n const last = createCalendarDate(date.getFullYear(), date.getMonth() + 1, 0);\n return Boolean(\n (minDate && isBeforeDay(last, minDate)) || (maxDate && isAfterDay(first, maxDate)),\n );\n },\n [maxDate, minDate],\n );\n const clampMonth = useCallback(\n (date: Date) => {\n const normalized = startOfMonth(date);\n if (minMonth && isBeforeDay(normalized, minMonth)) return minMonth;\n if (maxMonth && isAfterDay(normalized, maxMonth)) return maxMonth;\n return normalized;\n },\n [maxMonth, minMonth],\n );\n const setMonth = useCallback((date: Date) => setMonthState(clampMonth(date)), [clampMonth]);\n const canNavigate = useCallback(\n (amount: number) => {\n const next = addMonths(month, amount);\n return (\n !(minMonth && isBeforeDay(next, minMonth)) && !(maxMonth && isAfterDay(next, maxMonth))\n );\n },\n [maxMonth, minMonth, month],\n );\n const setValue = useCallback(\n (nextValue: Date | null) => {\n if (controlledValue === undefined) setUncontrolledValue(nextValue);\n onValueChange?.(nextValue);\n },\n [controlledValue, onValueChange],\n );\n const onSelect = useCallback(\n (date: Date) => {\n if (disabled || dateDisabled(date)) return;\n const next = createCalendarDate(date.getFullYear(), date.getMonth(), date.getDate());\n setValue(next);\n setFocusedDate(next);\n setMonth(next);\n },\n [dateDisabled, disabled, setMonth, setValue],\n );\n const focusDate = useCallback(\n (date: Date, direction = 1) => {\n let next = createCalendarDate(date.getFullYear(), date.getMonth(), date.getDate());\n const step = direction < 0 ? -1 : 1;\n let attempts = 0;\n while (dateDisabled(next) && attempts < 366) {\n next = addDays(next, step);\n attempts += 1;\n }\n setFocusedDate(next);\n setMonth(next);\n const focusTarget = () => dayRefs.current.get(dateKey(next))?.focus();\n focusTarget();\n queueMicrotask(focusTarget);\n },\n [dateDisabled, setMonth],\n );\n const selectMonth = useCallback(\n (monthIndex: number) => setMonth(createCalendarDate(month.getFullYear(), monthIndex, 1)),\n [month, setMonth],\n );\n const selectYear = useCallback(\n (year: number) => setMonth(createCalendarDate(year, month.getMonth(), 1)),\n [month, setMonth],\n );\n const registerDay = useCallback((key: string, node: HTMLButtonElement | null) => {\n if (node) dayRefs.current.set(key, node);\n else dayRefs.current.delete(key);\n }, []);\n\n useEffect(() => {\n if (!selected) return;\n setFocusedDate(selected);\n setMonthState((current) => (sameMonth(current, selected) ? current : clampMonth(selected)));\n }, [clampMonth, selected]);\n\n const context: CalendarContextValue = {\n calendarId,\n canNavigate,\n dateDisabled,\n disabled,\n focusedDate,\n focusDate,\n locale,\n month,\n monthDisabled,\n onSelect,\n registerDay,\n selected,\n selectMonth,\n selectYear,\n setMonth,\n styles,\n today,\n weekStartsOn,\n yearRange,\n };\n\n return (\n <CalendarContext.Provider value={context}>\n <section\n {...props}\n aria-label={props[\"aria-label\"] ?? formatMonthLabel(month, locale)}\n className={cx(styles.root, className)}\n data-jaci-component=\"calendar\"\n data-slot=\"calendar\"\n ref={ref}\n >\n {children ?? (\n <>\n <CalendarHeader>\n <CalendarPrevious />\n <CalendarCaption />\n <CalendarNext />\n </CalendarHeader>\n <CalendarGrid />\n </>\n )}\n </section>\n </CalendarContext.Provider>\n );\n});\n\nexport type CalendarHeaderProps = ComponentPropsWithoutRef<\"div\">;\nexport const CalendarHeader = forwardRef<HTMLDivElement, CalendarHeaderProps>(\n function CalendarHeader({ className, ...props }, ref) {\n const { styles } = useCalendarContext();\n return (\n <div\n {...props}\n className={cx(styles.header, className)}\n data-slot=\"calendar-header\"\n ref={ref}\n />\n );\n },\n);\n\nexport type CalendarCaptionProps = ComponentPropsWithoutRef<\"span\">;\nexport const CalendarCaption = forwardRef<HTMLSpanElement, CalendarCaptionProps>(\n function CalendarCaption({ children, className, ...props }, ref) {\n const { locale, month, styles } = useCalendarContext();\n return (\n <span\n {...props}\n className={cx(styles.caption, className)}\n data-slot=\"calendar-caption\"\n ref={ref}\n >\n {children ?? formatMonthLabel(month, locale)}\n </span>\n );\n },\n);\n\nexport interface CalendarNavigationProps extends ComponentPropsWithoutRef<\"button\"> {\n amount?: number;\n}\n\nconst CalendarNavigationButton = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarNavigationButton({ amount = 1, children, className, onClick, ...props }, ref) {\n const { canNavigate, month, setMonth, styles } = useCalendarContext();\n const isDisabled = props.disabled || !canNavigate(amount);\n return (\n <button\n {...props}\n aria-label={props[\"aria-label\"] ?? (amount < 0 ? \"Previous month\" : \"Next month\")}\n className={cx(styles.navigation, className)}\n data-slot={amount < 0 ? \"calendar-previous\" : \"calendar-next\"}\n disabled={isDisabled}\n onClick={(event) => {\n if (!isDisabled) setMonth(addMonths(month, amount));\n onClick?.(event);\n }}\n ref={ref}\n type=\"button\"\n >\n {children ?? (amount < 0 ? \"‹\" : \"›\")}\n </button>\n );\n },\n);\n\nexport const CalendarPrevious = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarPrevious(props, ref) {\n return <CalendarNavigationButton {...props} amount={-1} ref={ref} />;\n },\n);\nexport const CalendarNext = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarNext(props, ref) {\n return <CalendarNavigationButton {...props} amount={1} ref={ref} />;\n },\n);\n\nexport type CalendarMonthSelectProps = Omit<\n ComponentPropsWithoutRef<\"select\">,\n \"children\" | \"onChange\" | \"value\"\n>;\nexport const CalendarMonthSelect = forwardRef<HTMLSelectElement, CalendarMonthSelectProps>(\n function CalendarMonthSelect({ className, ...props }, ref) {\n const { locale, month, monthDisabled, selectMonth, styles } = useCalendarContext();\n const labels = Array.from({ length: 12 }, (_, index) =>\n new Intl.DateTimeFormat(locale, { month: \"long\" }).format(createCalendarDate(2024, index, 1)),\n );\n return (\n <select\n {...props}\n aria-label={props[\"aria-label\"] ?? \"Select month\"}\n className={cx(styles.monthSelect, className)}\n data-slot=\"calendar-month-select\"\n onChange={(event) => selectMonth(Number(event.currentTarget.value))}\n ref={ref}\n value={month.getMonth()}\n >\n {labels.map((label, index) => (\n <option\n disabled={monthDisabled(createCalendarDate(month.getFullYear(), index, 1))}\n key={label}\n value={index}\n >\n {label}\n </option>\n ))}\n </select>\n );\n },\n);\n\nexport type CalendarYearSelectProps = Omit<\n ComponentPropsWithoutRef<\"select\">,\n \"children\" | \"onChange\" | \"value\"\n>;\nexport const CalendarYearSelect = forwardRef<HTMLSelectElement, CalendarYearSelectProps>(\n function CalendarYearSelect({ className, ...props }, ref) {\n const { month, monthDisabled, selectYear, styles, yearRange } = useCalendarContext();\n const years = Array.from(\n { length: yearRange.end - yearRange.start + 1 },\n (_, index) => yearRange.start + index,\n );\n return (\n <select\n {...props}\n aria-label={props[\"aria-label\"] ?? \"Select year\"}\n className={cx(styles.yearSelect, className)}\n data-slot=\"calendar-year-select\"\n onChange={(event) => selectYear(Number(event.currentTarget.value))}\n ref={ref}\n value={month.getFullYear()}\n >\n {years.map((year) => (\n <option\n disabled={monthDisabled(createCalendarDate(year, month.getMonth(), 1))}\n key={year}\n value={year}\n >\n {year}\n </option>\n ))}\n </select>\n );\n },\n);\n\nexport interface CalendarDayProps extends Omit<ComponentPropsWithoutRef<\"button\">, \"value\"> {\n date: Date;\n}\n\nexport const CalendarDay = forwardRef<HTMLButtonElement, CalendarDayProps>(function CalendarDay(\n { children, className, date, disabled, onClick, onKeyDown, ...props },\n ref,\n) {\n const {\n dateDisabled,\n disabled: calendarDisabled,\n focusDate,\n focusedDate,\n locale,\n month,\n onSelect,\n registerDay,\n selected,\n styles,\n today,\n weekStartsOn,\n } = useCalendarContext();\n const key = dateKey(date);\n const outsideMonth = !sameMonth(date, month);\n const isDisabled = Boolean(disabled || calendarDisabled || dateDisabled(date));\n const isSelected = isSameDay(date, selected);\n const isFocused = isSameDay(date, focusedDate);\n const isToday = isSameDay(date, today);\n return (\n // biome-ignore lint/a11y/useSemanticElements: the roving button is the interactive grid cell.\n <button\n {...props}\n aria-label={\n props[\"aria-label\"] ?? new Intl.DateTimeFormat(locale, { dateStyle: \"full\" }).format(date)\n }\n aria-current={isToday ? \"date\" : undefined}\n aria-selected={isSelected}\n className={cx(styles.day, className)}\n data-date={key}\n data-disabled={isDisabled || undefined}\n data-outside-month={outsideMonth || undefined}\n data-selected={isSelected || undefined}\n data-slot=\"calendar-day\"\n data-today={isToday || undefined}\n disabled={isDisabled}\n onClick={(event) => {\n onSelect(date);\n onClick?.(event);\n }}\n onKeyDown={(event) => {\n if (!event.defaultPrevented) {\n let nextDate: Date | undefined;\n switch (event.key) {\n case \"ArrowLeft\":\n nextDate = addDays(date, -1);\n break;\n case \"ArrowRight\":\n nextDate = addDays(date, 1);\n break;\n case \"ArrowUp\":\n nextDate = addDays(date, -7);\n break;\n case \"ArrowDown\":\n nextDate = addDays(date, 7);\n break;\n case \"Home\":\n nextDate = addDays(date, -((date.getDay() - weekStartsOn + 7) % 7));\n break;\n case \"End\":\n nextDate = addDays(date, 6 - ((date.getDay() - weekStartsOn + 7) % 7));\n break;\n case \"PageUp\":\n nextDate = addMonths(date, event.shiftKey ? -12 : -1);\n break;\n case \"PageDown\":\n nextDate = addMonths(date, event.shiftKey ? 12 : 1);\n break;\n case \"Enter\":\n case \" \":\n if (!isDisabled) {\n event.preventDefault();\n onSelect(date);\n }\n break;\n }\n if (nextDate) {\n event.preventDefault();\n focusDate(nextDate, nextDate < date ? -1 : 1);\n }\n }\n onKeyDown?.(event);\n }}\n ref={(node) => {\n registerDay(key, node);\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n role=\"gridcell\"\n tabIndex={isFocused && !isDisabled ? 0 : -1}\n type=\"button\"\n >\n {children ?? date.getDate()}\n </button>\n );\n});\n\nexport interface CalendarGridProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n \"aria-label\"?: string;\n}\n\nexport const CalendarGrid = forwardRef<HTMLDivElement, CalendarGridProps>(function CalendarGrid(\n { \"aria-label\": ariaLabel, className, ...props },\n ref,\n) {\n const { locale, month, styles, weekStartsOn } = useCalendarContext();\n const days = useMemo(() => getCalendarDays(month, weekStartsOn), [month, weekStartsOn]);\n const weeks = useMemo(\n () =>\n Array.from({ length: Math.ceil(days.length / 7) }, (_, index) =>\n days.slice(index * 7, index * 7 + 7),\n ),\n [days],\n );\n const weekdays = useMemo(() => getWeekdayLabels(locale, weekStartsOn), [locale, weekStartsOn]);\n return (\n <div {...props} className={cx(styles.calendar, className)} data-slot=\"calendar-grid\" ref={ref}>\n <div aria-hidden=\"true\" className={styles.weekdays} data-slot=\"calendar-weekdays\">\n {weekdays.map((weekday) => (\n <span className={styles.weekday} data-slot=\"calendar-weekday\" key={weekday}>\n {weekday}\n </span>\n ))}\n </div>\n {/* biome-ignore lint/a11y/useSemanticElements: the calendar uses the ARIA grid pattern. */}\n <div\n aria-label={ariaLabel ?? formatMonthLabel(month, locale)}\n className={styles.grid}\n data-slot=\"calendar-day-grid\"\n role=\"grid\"\n >\n {weeks.map((week, index) => (\n // biome-ignore lint/a11y/useSemanticElements: Calendar rows use ARIA grid semantics while the day controls remain buttons.\n <div\n aria-rowindex={index + 1}\n className={styles.row}\n data-slot=\"calendar-week\"\n key={week.map(dateKey).join(\"-\")}\n role=\"row\"\n tabIndex={-1}\n >\n {week.map((date) => (\n <CalendarDay date={date} key={dateKey(date)} />\n ))}\n </div>\n ))}\n </div>\n </div>\n );\n});\n\nexport const Calendar = {\n Root: CalendarRoot,\n Header: CalendarHeader,\n Caption: CalendarCaption,\n Previous: CalendarPrevious,\n Next: CalendarNext,\n MonthSelect: CalendarMonthSelect,\n YearSelect: CalendarYearSelect,\n Grid: CalendarGrid,\n Day: CalendarDay,\n};\n"],"mappings":";;;;;;;AAkEA,MAAM,mBAAA,GAAA,MAAA,cAAA,CAA6D,IAAI;AAEvE,SAAS,qBAAqB;CAC5B,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAEA,SAAS,UAAU,MAAY,OAAa;CAC1C,OAAO,KAAK,YAAY,MAAM,MAAM,YAAY,KAAK,KAAK,SAAS,MAAM,MAAM,SAAS;AAC1F;AAEA,MAAa,gBAAA,GAAA,MAAA,WAAA,CAA0D,SAAS,aAC9E,EACE,UACA,WACA,eAAe,MACf,WAAW,OACX,gBACA,SAAS,SACT,SACA,SACA,eACA,eACA,OAAO,iBACP,eAAe,GACf,WAAW,qBACX,GAAG,SAEL,KACA;CACA,MAAM,cAAc,mBAAmB,gBAAgB,iCAAiB,IAAI,KAAK;CACjF,MAAM,CAAC,mBAAmB,yBAAA,GAAA,MAAA,SAAA,CAA8C,YAAY;CACpF,MAAM,WAAW,oBAAoB,K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Context","forwardRef","useState","startOfMonth","useRef","useId","calendar","useMemo","createCalendarDate","useCallback","isBeforeDay","isAfterDay","addMonths","addDays","dateKey","formatMonthLabel","cx","isSameDay","getCalendarDays","getWeekdayLabels"],"sources":["../../../src/components/calendar/calendar.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { calendar } from \"../../styled-system/recipes\";\nimport {\n addDays,\n addMonths,\n createCalendarDate,\n dateKey,\n formatMonthLabel,\n getCalendarDays,\n getWeekdayLabels,\n isAfterDay,\n isBeforeDay,\n isSameDay,\n startOfMonth,\n} from \"../date-picker/date-utils\";\n\nexport interface CalendarYearRange {\n start: number;\n end: number;\n}\n\nexport interface CalendarRootProps\n extends Omit<ComponentPropsWithoutRef<\"section\">, \"children\" | \"defaultValue\" | \"value\"> {\n value?: Date | null;\n defaultValue?: Date | null;\n onValueChange?: (value: Date | null) => void;\n referenceDate?: Date;\n locale?: string;\n weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n minDate?: Date;\n maxDate?: Date;\n isDateDisabled?: (date: Date) => boolean;\n yearRange?: CalendarYearRange;\n disabled?: boolean;\n children?: ReactNode;\n}\n\ninterface CalendarContextValue {\n calendarId: string;\n dateDisabled: (date: Date) => boolean;\n disabled: boolean;\n focusedDate: Date;\n focusDate: (date: Date, direction?: number) => void;\n locale: string;\n month: Date;\n monthDisabled: (date: Date) => boolean;\n onSelect: (date: Date) => void;\n selected: Date | null;\n setMonth: (date: Date) => void;\n styles: ReturnType<typeof calendar>;\n today: Date;\n weekStartsOn: number;\n yearRange: CalendarYearRange;\n canNavigate: (amount: number) => boolean;\n selectMonth: (month: number) => void;\n selectYear: (year: number) => void;\n registerDay: (key: string, node: HTMLButtonElement | null) => void;\n}\n\nimport { createContext, useContext } from \"react\";\n\nconst CalendarContext = createContext<CalendarContextValue | null>(null);\n\nfunction useCalendarContext() {\n const context = useContext(CalendarContext);\n if (!context) throw new Error(\"Calendar parts must be rendered inside Calendar.Root.\");\n return context;\n}\n\nfunction sameMonth(left: Date, right: Date) {\n return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth();\n}\n\nexport const CalendarRoot = forwardRef<HTMLElement, CalendarRootProps>(function CalendarRoot(\n {\n children,\n className,\n defaultValue = null,\n disabled = false,\n isDateDisabled,\n locale = \"pt-BR\",\n maxDate,\n minDate,\n onValueChange,\n referenceDate,\n value: controlledValue,\n weekStartsOn = 0,\n yearRange: configuredYearRange,\n ...props\n },\n ref,\n) {\n const initialDate = controlledValue ?? defaultValue ?? referenceDate ?? new Date();\n const [uncontrolledValue, setUncontrolledValue] = useState<Date | null>(defaultValue);\n const selected = controlledValue === undefined ? uncontrolledValue : controlledValue;\n const [month, setMonthState] = useState(() => startOfMonth(initialDate));\n const [focusedDate, setFocusedDate] = useState(selected ?? initialDate);\n const dayRefs = useRef(new Map<string, HTMLButtonElement>());\n const calendarId = useId();\n const styles = calendar();\n const today = useMemo(\n () =>\n createCalendarDate(\n (referenceDate ?? new Date()).getFullYear(),\n (referenceDate ?? new Date()).getMonth(),\n (referenceDate ?? new Date()).getDate(),\n ),\n [referenceDate],\n );\n const minMonth = minDate ? startOfMonth(minDate) : undefined;\n const maxMonth = maxDate ? startOfMonth(maxDate) : undefined;\n const yearRange = useMemo(() => {\n const start = configuredYearRange?.start ?? today.getFullYear() - 100;\n const end = configuredYearRange?.end ?? today.getFullYear() + 20;\n const years = [selected?.getFullYear(), minDate?.getFullYear(), maxDate?.getFullYear()].filter(\n (year): year is number => year !== undefined,\n );\n return { start: Math.min(start, end, ...years), end: Math.max(start, end, ...years) };\n }, [configuredYearRange?.end, configuredYearRange?.start, maxDate, minDate, selected, today]);\n\n const dateDisabled = useCallback(\n (date: Date) =>\n Boolean(\n (minDate && isBeforeDay(date, minDate)) ||\n (maxDate && isAfterDay(date, maxDate)) ||\n isDateDisabled?.(date),\n ),\n [isDateDisabled, maxDate, minDate],\n );\n const monthDisabled = useCallback(\n (date: Date) => {\n const first = startOfMonth(date);\n const last = createCalendarDate(date.getFullYear(), date.getMonth() + 1, 0);\n return Boolean(\n (minDate && isBeforeDay(last, minDate)) || (maxDate && isAfterDay(first, maxDate)),\n );\n },\n [maxDate, minDate],\n );\n const clampMonth = useCallback(\n (date: Date) => {\n const normalized = startOfMonth(date);\n if (minMonth && isBeforeDay(normalized, minMonth)) return minMonth;\n if (maxMonth && isAfterDay(normalized, maxMonth)) return maxMonth;\n return normalized;\n },\n [maxMonth, minMonth],\n );\n const setMonth = useCallback((date: Date) => setMonthState(clampMonth(date)), [clampMonth]);\n const canNavigate = useCallback(\n (amount: number) => {\n const next = addMonths(month, amount);\n return (\n !(minMonth && isBeforeDay(next, minMonth)) && !(maxMonth && isAfterDay(next, maxMonth))\n );\n },\n [maxMonth, minMonth, month],\n );\n const setValue = useCallback(\n (nextValue: Date | null) => {\n if (controlledValue === undefined) setUncontrolledValue(nextValue);\n onValueChange?.(nextValue);\n },\n [controlledValue, onValueChange],\n );\n const onSelect = useCallback(\n (date: Date) => {\n if (disabled || dateDisabled(date)) return;\n const next = createCalendarDate(date.getFullYear(), date.getMonth(), date.getDate());\n setValue(next);\n setFocusedDate(next);\n setMonth(next);\n },\n [dateDisabled, disabled, setMonth, setValue],\n );\n const focusDate = useCallback(\n (date: Date, direction = 1) => {\n let next = createCalendarDate(date.getFullYear(), date.getMonth(), date.getDate());\n const step = direction < 0 ? -1 : 1;\n let attempts = 0;\n while (dateDisabled(next) && attempts < 366) {\n next = addDays(next, step);\n attempts += 1;\n }\n setFocusedDate(next);\n setMonth(next);\n const focusTarget = () => dayRefs.current.get(dateKey(next))?.focus();\n focusTarget();\n queueMicrotask(focusTarget);\n },\n [dateDisabled, setMonth],\n );\n const selectMonth = useCallback(\n (monthIndex: number) => setMonth(createCalendarDate(month.getFullYear(), monthIndex, 1)),\n [month, setMonth],\n );\n const selectYear = useCallback(\n (year: number) => setMonth(createCalendarDate(year, month.getMonth(), 1)),\n [month, setMonth],\n );\n const registerDay = useCallback((key: string, node: HTMLButtonElement | null) => {\n if (node) dayRefs.current.set(key, node);\n else dayRefs.current.delete(key);\n }, []);\n\n useEffect(() => {\n if (!selected) return;\n setFocusedDate(selected);\n setMonthState((current) => (sameMonth(current, selected) ? current : clampMonth(selected)));\n }, [clampMonth, selected]);\n\n const context: CalendarContextValue = {\n calendarId,\n canNavigate,\n dateDisabled,\n disabled,\n focusedDate,\n focusDate,\n locale,\n month,\n monthDisabled,\n onSelect,\n registerDay,\n selected,\n selectMonth,\n selectYear,\n setMonth,\n styles,\n today,\n weekStartsOn,\n yearRange,\n };\n\n return (\n <CalendarContext.Provider value={context}>\n <section\n {...props}\n aria-label={props[\"aria-label\"] ?? formatMonthLabel(month, locale)}\n className={cx(styles.root, className)}\n data-jaci-component=\"calendar\"\n data-slot=\"calendar\"\n ref={ref}\n >\n {children ?? (\n <>\n <CalendarHeader>\n <CalendarPrevious />\n <CalendarCaption />\n <CalendarNext />\n </CalendarHeader>\n <CalendarGrid />\n </>\n )}\n </section>\n </CalendarContext.Provider>\n );\n});\n\nexport type CalendarHeaderProps = ComponentPropsWithoutRef<\"div\">;\nexport const CalendarHeader = forwardRef<HTMLDivElement, CalendarHeaderProps>(\n function CalendarHeader({ className, ...props }, ref) {\n const { styles } = useCalendarContext();\n return (\n <div\n {...props}\n className={cx(styles.header, className)}\n data-slot=\"calendar-header\"\n ref={ref}\n />\n );\n },\n);\n\nexport type CalendarCaptionProps = ComponentPropsWithoutRef<\"span\">;\nexport const CalendarCaption = forwardRef<HTMLSpanElement, CalendarCaptionProps>(\n function CalendarCaption({ children, className, ...props }, ref) {\n const { locale, month, styles } = useCalendarContext();\n return (\n <span\n {...props}\n className={cx(styles.caption, className)}\n data-slot=\"calendar-caption\"\n ref={ref}\n >\n {children ?? formatMonthLabel(month, locale)}\n </span>\n );\n },\n);\n\nexport interface CalendarNavigationProps extends ComponentPropsWithoutRef<\"button\"> {\n amount?: number;\n}\n\nconst CalendarNavigationButton = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarNavigationButton({ amount = 1, children, className, onClick, ...props }, ref) {\n const { canNavigate, month, setMonth, styles } = useCalendarContext();\n const isDisabled = props.disabled || !canNavigate(amount);\n return (\n <button\n {...props}\n aria-label={props[\"aria-label\"] ?? (amount < 0 ? \"Previous month\" : \"Next month\")}\n className={cx(styles.navigation, className)}\n data-slot={amount < 0 ? \"calendar-previous\" : \"calendar-next\"}\n disabled={isDisabled}\n onClick={(event) => {\n if (!isDisabled) setMonth(addMonths(month, amount));\n onClick?.(event);\n }}\n ref={ref}\n type=\"button\"\n >\n {children ?? (amount < 0 ? \"‹\" : \"›\")}\n </button>\n );\n },\n);\n\nexport const CalendarPrevious = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarPrevious(props, ref) {\n return <CalendarNavigationButton {...props} amount={-1} ref={ref} />;\n },\n);\nexport const CalendarNext = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarNext(props, ref) {\n return <CalendarNavigationButton {...props} amount={1} ref={ref} />;\n },\n);\n\nexport type CalendarMonthSelectProps = Omit<\n ComponentPropsWithoutRef<\"select\">,\n \"children\" | \"onChange\" | \"value\"\n>;\nexport const CalendarMonthSelect = forwardRef<HTMLSelectElement, CalendarMonthSelectProps>(\n function CalendarMonthSelect({ className, ...props }, ref) {\n const { locale, month, monthDisabled, selectMonth, styles } = useCalendarContext();\n const labels = Array.from({ length: 12 }, (_, index) =>\n new Intl.DateTimeFormat(locale, { month: \"long\" }).format(createCalendarDate(2024, index, 1)),\n );\n return (\n <select\n {...props}\n aria-label={props[\"aria-label\"] ?? \"Select month\"}\n className={cx(styles.monthSelect, className)}\n data-slot=\"calendar-month-select\"\n onChange={(event) => selectMonth(Number(event.currentTarget.value))}\n ref={ref}\n value={month.getMonth()}\n >\n {labels.map((label, index) => (\n <option\n disabled={monthDisabled(createCalendarDate(month.getFullYear(), index, 1))}\n key={label}\n value={index}\n >\n {label}\n </option>\n ))}\n </select>\n );\n },\n);\n\nexport type CalendarYearSelectProps = Omit<\n ComponentPropsWithoutRef<\"select\">,\n \"children\" | \"onChange\" | \"value\"\n>;\nexport const CalendarYearSelect = forwardRef<HTMLSelectElement, CalendarYearSelectProps>(\n function CalendarYearSelect({ className, ...props }, ref) {\n const { month, monthDisabled, selectYear, styles, yearRange } = useCalendarContext();\n const years = Array.from(\n { length: yearRange.end - yearRange.start + 1 },\n (_, index) => yearRange.start + index,\n );\n return (\n <select\n {...props}\n aria-label={props[\"aria-label\"] ?? \"Select year\"}\n className={cx(styles.yearSelect, className)}\n data-slot=\"calendar-year-select\"\n onChange={(event) => selectYear(Number(event.currentTarget.value))}\n ref={ref}\n value={month.getFullYear()}\n >\n {years.map((year) => (\n <option\n disabled={monthDisabled(createCalendarDate(year, month.getMonth(), 1))}\n key={year}\n value={year}\n >\n {year}\n </option>\n ))}\n </select>\n );\n },\n);\n\nexport interface CalendarDayProps extends Omit<ComponentPropsWithoutRef<\"button\">, \"value\"> {\n date: Date;\n}\n\nexport const CalendarDay = forwardRef<HTMLButtonElement, CalendarDayProps>(function CalendarDay(\n { children, className, date, disabled, onClick, onKeyDown, ...props },\n ref,\n) {\n const {\n dateDisabled,\n disabled: calendarDisabled,\n focusDate,\n focusedDate,\n locale,\n month,\n onSelect,\n registerDay,\n selected,\n styles,\n today,\n weekStartsOn,\n } = useCalendarContext();\n const key = dateKey(date);\n const outsideMonth = !sameMonth(date, month);\n const isDisabled = Boolean(disabled || calendarDisabled || dateDisabled(date));\n const isSelected = isSameDay(date, selected);\n const isFocused = isSameDay(date, focusedDate);\n const isToday = isSameDay(date, today);\n return (\n // biome-ignore lint/a11y/useSemanticElements: the roving button is the interactive grid cell.\n <button\n {...props}\n aria-label={\n props[\"aria-label\"] ?? new Intl.DateTimeFormat(locale, { dateStyle: \"full\" }).format(date)\n }\n aria-current={isToday ? \"date\" : undefined}\n aria-selected={isSelected}\n className={cx(styles.day, className)}\n data-date={key}\n data-disabled={isDisabled || undefined}\n data-outside-month={outsideMonth || undefined}\n data-selected={isSelected || undefined}\n data-slot=\"calendar-day\"\n data-today={isToday || undefined}\n disabled={isDisabled}\n onClick={(event) => {\n onSelect(date);\n onClick?.(event);\n }}\n onKeyDown={(event) => {\n if (!event.defaultPrevented) {\n let nextDate: Date | undefined;\n switch (event.key) {\n case \"ArrowLeft\":\n nextDate = addDays(date, -1);\n break;\n case \"ArrowRight\":\n nextDate = addDays(date, 1);\n break;\n case \"ArrowUp\":\n nextDate = addDays(date, -7);\n break;\n case \"ArrowDown\":\n nextDate = addDays(date, 7);\n break;\n case \"Home\":\n nextDate = addDays(date, -((date.getDay() - weekStartsOn + 7) % 7));\n break;\n case \"End\":\n nextDate = addDays(date, 6 - ((date.getDay() - weekStartsOn + 7) % 7));\n break;\n case \"PageUp\":\n nextDate = addMonths(date, event.shiftKey ? -12 : -1);\n break;\n case \"PageDown\":\n nextDate = addMonths(date, event.shiftKey ? 12 : 1);\n break;\n case \"Enter\":\n case \" \":\n if (!isDisabled) {\n event.preventDefault();\n onSelect(date);\n }\n break;\n }\n if (nextDate) {\n event.preventDefault();\n focusDate(nextDate, nextDate < date ? -1 : 1);\n }\n }\n onKeyDown?.(event);\n }}\n ref={(node) => {\n registerDay(key, node);\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n role=\"gridcell\"\n tabIndex={isFocused && !isDisabled ? 0 : -1}\n type=\"button\"\n >\n {children ?? date.getDate()}\n </button>\n );\n});\n\nexport interface CalendarGridProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n \"aria-label\"?: string;\n}\n\nexport const CalendarGrid = forwardRef<HTMLDivElement, CalendarGridProps>(function CalendarGrid(\n { \"aria-label\": ariaLabel, className, ...props },\n ref,\n) {\n const { locale, month, styles, weekStartsOn } = useCalendarContext();\n const days = useMemo(() => getCalendarDays(month, weekStartsOn), [month, weekStartsOn]);\n const weeks = useMemo(\n () =>\n Array.from({ length: Math.ceil(days.length / 7) }, (_, index) =>\n days.slice(index * 7, index * 7 + 7),\n ),\n [days],\n );\n const weekdays = useMemo(() => getWeekdayLabels(locale, weekStartsOn), [locale, weekStartsOn]);\n return (\n <div {...props} className={cx(styles.calendar, className)} data-slot=\"calendar-grid\" ref={ref}>\n <div aria-hidden=\"true\" className={styles.weekdays} data-slot=\"calendar-weekdays\">\n {weekdays.map((weekday) => (\n <span className={styles.weekday} data-slot=\"calendar-weekday\" key={weekday}>\n {weekday}\n </span>\n ))}\n </div>\n {/* biome-ignore lint/a11y/useSemanticElements: the calendar uses the ARIA grid pattern. */}\n <div\n aria-label={ariaLabel ?? formatMonthLabel(month, locale)}\n className={styles.grid}\n data-slot=\"calendar-day-grid\"\n role=\"grid\"\n >\n {weeks.map((week, index) => (\n // biome-ignore lint/a11y/useSemanticElements: Calendar rows use ARIA grid semantics while the day controls remain buttons.\n <div\n aria-rowindex={index + 1}\n className={styles.row}\n data-slot=\"calendar-week\"\n key={week.map(dateKey).join(\"-\")}\n role=\"row\"\n tabIndex={-1}\n >\n {week.map((date) => (\n <CalendarDay date={date} key={dateKey(date)} />\n ))}\n </div>\n ))}\n </div>\n </div>\n );\n});\n\nexport const Calendar = {\n Root: CalendarRoot,\n Header: CalendarHeader,\n Caption: CalendarCaption,\n Previous: CalendarPrevious,\n Next: CalendarNext,\n MonthSelect: CalendarMonthSelect,\n YearSelect: CalendarYearSelect,\n Grid: CalendarGrid,\n Day: CalendarDay,\n};\n"],"mappings":";;;;;;;AAkEA,MAAM,mBAAA,GAAkBA,MAAAA,cAAAA,CAA2C,IAAI;AAEvE,SAAS,qBAAqB;CAC5B,MAAM,WAAA,GAAUC,MAAAA,WAAAA,CAAW,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAEA,SAAS,UAAU,MAAY,OAAa;CAC1C,OAAO,KAAK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AAAA,iBAAiB,OAAO,MAAM;GACvD,WAAW,OAAO;GAClB,aAAU;GACV,MAAK;GAEJ,UAAA,MAAM,KAAK,MAAM,UAEhB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IACE,iBAAe,QAAQ;IACvB,WAAW,OAAO;IAClB,aAAU;IAEV,MAAK;IACL,UAAU;IAET,UAAA,KAAK,KAAK,SACT,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAD,EAAmB,KAA2B,GAAhBD,mBAAAA,QAAQ,IAAI,CAAI,CAC/C;GACE,GAPE,KAAK,IAAIA,mBAAAA,OAAO,CAAC,CAAC,KAAK,GAAG,CAO5B,CACN;EACE,CAAA,CACF;;AAET,CAAC;AAED,MAAa,WAAW;CACtB,MAAM;CACN,QAAQ;CACR,SAAS;CACT,UAAU;CACV,MAAM;CACN,aAAa;CACb,YAAY;CACZ,MAAM;CACN,KAAK;AACP"}
|
|
@@ -291,12 +291,10 @@ const CalendarDay = forwardRef(function CalendarDay({ children, className, date,
|
|
|
291
291
|
nextDate = addMonths(date, event.shiftKey ? 12 : 1);
|
|
292
292
|
break;
|
|
293
293
|
case "Enter":
|
|
294
|
-
case " ":
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
break;
|
|
294
|
+
case " ": if (!isDisabled) {
|
|
295
|
+
event.preventDefault();
|
|
296
|
+
onSelect(date);
|
|
297
|
+
}
|
|
300
298
|
}
|
|
301
299
|
if (nextDate) {
|
|
302
300
|
event.preventDefault();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","names":[],"sources":["../../../src/components/calendar/calendar.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { calendar } from \"../../styled-system/recipes\";\nimport {\n addDays,\n addMonths,\n createCalendarDate,\n dateKey,\n formatMonthLabel,\n getCalendarDays,\n getWeekdayLabels,\n isAfterDay,\n isBeforeDay,\n isSameDay,\n startOfMonth,\n} from \"../date-picker/date-utils\";\n\nexport interface CalendarYearRange {\n start: number;\n end: number;\n}\n\nexport interface CalendarRootProps\n extends Omit<ComponentPropsWithoutRef<\"section\">, \"children\" | \"defaultValue\" | \"value\"> {\n value?: Date | null;\n defaultValue?: Date | null;\n onValueChange?: (value: Date | null) => void;\n referenceDate?: Date;\n locale?: string;\n weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n minDate?: Date;\n maxDate?: Date;\n isDateDisabled?: (date: Date) => boolean;\n yearRange?: CalendarYearRange;\n disabled?: boolean;\n children?: ReactNode;\n}\n\ninterface CalendarContextValue {\n calendarId: string;\n dateDisabled: (date: Date) => boolean;\n disabled: boolean;\n focusedDate: Date;\n focusDate: (date: Date, direction?: number) => void;\n locale: string;\n month: Date;\n monthDisabled: (date: Date) => boolean;\n onSelect: (date: Date) => void;\n selected: Date | null;\n setMonth: (date: Date) => void;\n styles: ReturnType<typeof calendar>;\n today: Date;\n weekStartsOn: number;\n yearRange: CalendarYearRange;\n canNavigate: (amount: number) => boolean;\n selectMonth: (month: number) => void;\n selectYear: (year: number) => void;\n registerDay: (key: string, node: HTMLButtonElement | null) => void;\n}\n\nimport { createContext, useContext } from \"react\";\n\nconst CalendarContext = createContext<CalendarContextValue | null>(null);\n\nfunction useCalendarContext() {\n const context = useContext(CalendarContext);\n if (!context) throw new Error(\"Calendar parts must be rendered inside Calendar.Root.\");\n return context;\n}\n\nfunction sameMonth(left: Date, right: Date) {\n return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth();\n}\n\nexport const CalendarRoot = forwardRef<HTMLElement, CalendarRootProps>(function CalendarRoot(\n {\n children,\n className,\n defaultValue = null,\n disabled = false,\n isDateDisabled,\n locale = \"pt-BR\",\n maxDate,\n minDate,\n onValueChange,\n referenceDate,\n value: controlledValue,\n weekStartsOn = 0,\n yearRange: configuredYearRange,\n ...props\n },\n ref,\n) {\n const initialDate = controlledValue ?? defaultValue ?? referenceDate ?? new Date();\n const [uncontrolledValue, setUncontrolledValue] = useState<Date | null>(defaultValue);\n const selected = controlledValue === undefined ? uncontrolledValue : controlledValue;\n const [month, setMonthState] = useState(() => startOfMonth(initialDate));\n const [focusedDate, setFocusedDate] = useState(selected ?? initialDate);\n const dayRefs = useRef(new Map<string, HTMLButtonElement>());\n const calendarId = useId();\n const styles = calendar();\n const today = useMemo(\n () =>\n createCalendarDate(\n (referenceDate ?? new Date()).getFullYear(),\n (referenceDate ?? new Date()).getMonth(),\n (referenceDate ?? new Date()).getDate(),\n ),\n [referenceDate],\n );\n const minMonth = minDate ? startOfMonth(minDate) : undefined;\n const maxMonth = maxDate ? startOfMonth(maxDate) : undefined;\n const yearRange = useMemo(() => {\n const start = configuredYearRange?.start ?? today.getFullYear() - 100;\n const end = configuredYearRange?.end ?? today.getFullYear() + 20;\n const years = [selected?.getFullYear(), minDate?.getFullYear(), maxDate?.getFullYear()].filter(\n (year): year is number => year !== undefined,\n );\n return { start: Math.min(start, end, ...years), end: Math.max(start, end, ...years) };\n }, [configuredYearRange?.end, configuredYearRange?.start, maxDate, minDate, selected, today]);\n\n const dateDisabled = useCallback(\n (date: Date) =>\n Boolean(\n (minDate && isBeforeDay(date, minDate)) ||\n (maxDate && isAfterDay(date, maxDate)) ||\n isDateDisabled?.(date),\n ),\n [isDateDisabled, maxDate, minDate],\n );\n const monthDisabled = useCallback(\n (date: Date) => {\n const first = startOfMonth(date);\n const last = createCalendarDate(date.getFullYear(), date.getMonth() + 1, 0);\n return Boolean(\n (minDate && isBeforeDay(last, minDate)) || (maxDate && isAfterDay(first, maxDate)),\n );\n },\n [maxDate, minDate],\n );\n const clampMonth = useCallback(\n (date: Date) => {\n const normalized = startOfMonth(date);\n if (minMonth && isBeforeDay(normalized, minMonth)) return minMonth;\n if (maxMonth && isAfterDay(normalized, maxMonth)) return maxMonth;\n return normalized;\n },\n [maxMonth, minMonth],\n );\n const setMonth = useCallback((date: Date) => setMonthState(clampMonth(date)), [clampMonth]);\n const canNavigate = useCallback(\n (amount: number) => {\n const next = addMonths(month, amount);\n return (\n !(minMonth && isBeforeDay(next, minMonth)) && !(maxMonth && isAfterDay(next, maxMonth))\n );\n },\n [maxMonth, minMonth, month],\n );\n const setValue = useCallback(\n (nextValue: Date | null) => {\n if (controlledValue === undefined) setUncontrolledValue(nextValue);\n onValueChange?.(nextValue);\n },\n [controlledValue, onValueChange],\n );\n const onSelect = useCallback(\n (date: Date) => {\n if (disabled || dateDisabled(date)) return;\n const next = createCalendarDate(date.getFullYear(), date.getMonth(), date.getDate());\n setValue(next);\n setFocusedDate(next);\n setMonth(next);\n },\n [dateDisabled, disabled, setMonth, setValue],\n );\n const focusDate = useCallback(\n (date: Date, direction = 1) => {\n let next = createCalendarDate(date.getFullYear(), date.getMonth(), date.getDate());\n const step = direction < 0 ? -1 : 1;\n let attempts = 0;\n while (dateDisabled(next) && attempts < 366) {\n next = addDays(next, step);\n attempts += 1;\n }\n setFocusedDate(next);\n setMonth(next);\n const focusTarget = () => dayRefs.current.get(dateKey(next))?.focus();\n focusTarget();\n queueMicrotask(focusTarget);\n },\n [dateDisabled, setMonth],\n );\n const selectMonth = useCallback(\n (monthIndex: number) => setMonth(createCalendarDate(month.getFullYear(), monthIndex, 1)),\n [month, setMonth],\n );\n const selectYear = useCallback(\n (year: number) => setMonth(createCalendarDate(year, month.getMonth(), 1)),\n [month, setMonth],\n );\n const registerDay = useCallback((key: string, node: HTMLButtonElement | null) => {\n if (node) dayRefs.current.set(key, node);\n else dayRefs.current.delete(key);\n }, []);\n\n useEffect(() => {\n if (!selected) return;\n setFocusedDate(selected);\n setMonthState((current) => (sameMonth(current, selected) ? current : clampMonth(selected)));\n }, [clampMonth, selected]);\n\n const context: CalendarContextValue = {\n calendarId,\n canNavigate,\n dateDisabled,\n disabled,\n focusedDate,\n focusDate,\n locale,\n month,\n monthDisabled,\n onSelect,\n registerDay,\n selected,\n selectMonth,\n selectYear,\n setMonth,\n styles,\n today,\n weekStartsOn,\n yearRange,\n };\n\n return (\n <CalendarContext.Provider value={context}>\n <section\n {...props}\n aria-label={props[\"aria-label\"] ?? formatMonthLabel(month, locale)}\n className={cx(styles.root, className)}\n data-jaci-component=\"calendar\"\n data-slot=\"calendar\"\n ref={ref}\n >\n {children ?? (\n <>\n <CalendarHeader>\n <CalendarPrevious />\n <CalendarCaption />\n <CalendarNext />\n </CalendarHeader>\n <CalendarGrid />\n </>\n )}\n </section>\n </CalendarContext.Provider>\n );\n});\n\nexport type CalendarHeaderProps = ComponentPropsWithoutRef<\"div\">;\nexport const CalendarHeader = forwardRef<HTMLDivElement, CalendarHeaderProps>(\n function CalendarHeader({ className, ...props }, ref) {\n const { styles } = useCalendarContext();\n return (\n <div\n {...props}\n className={cx(styles.header, className)}\n data-slot=\"calendar-header\"\n ref={ref}\n />\n );\n },\n);\n\nexport type CalendarCaptionProps = ComponentPropsWithoutRef<\"span\">;\nexport const CalendarCaption = forwardRef<HTMLSpanElement, CalendarCaptionProps>(\n function CalendarCaption({ children, className, ...props }, ref) {\n const { locale, month, styles } = useCalendarContext();\n return (\n <span\n {...props}\n className={cx(styles.caption, className)}\n data-slot=\"calendar-caption\"\n ref={ref}\n >\n {children ?? formatMonthLabel(month, locale)}\n </span>\n );\n },\n);\n\nexport interface CalendarNavigationProps extends ComponentPropsWithoutRef<\"button\"> {\n amount?: number;\n}\n\nconst CalendarNavigationButton = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarNavigationButton({ amount = 1, children, className, onClick, ...props }, ref) {\n const { canNavigate, month, setMonth, styles } = useCalendarContext();\n const isDisabled = props.disabled || !canNavigate(amount);\n return (\n <button\n {...props}\n aria-label={props[\"aria-label\"] ?? (amount < 0 ? \"Previous month\" : \"Next month\")}\n className={cx(styles.navigation, className)}\n data-slot={amount < 0 ? \"calendar-previous\" : \"calendar-next\"}\n disabled={isDisabled}\n onClick={(event) => {\n if (!isDisabled) setMonth(addMonths(month, amount));\n onClick?.(event);\n }}\n ref={ref}\n type=\"button\"\n >\n {children ?? (amount < 0 ? \"‹\" : \"›\")}\n </button>\n );\n },\n);\n\nexport const CalendarPrevious = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarPrevious(props, ref) {\n return <CalendarNavigationButton {...props} amount={-1} ref={ref} />;\n },\n);\nexport const CalendarNext = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarNext(props, ref) {\n return <CalendarNavigationButton {...props} amount={1} ref={ref} />;\n },\n);\n\nexport type CalendarMonthSelectProps = Omit<\n ComponentPropsWithoutRef<\"select\">,\n \"children\" | \"onChange\" | \"value\"\n>;\nexport const CalendarMonthSelect = forwardRef<HTMLSelectElement, CalendarMonthSelectProps>(\n function CalendarMonthSelect({ className, ...props }, ref) {\n const { locale, month, monthDisabled, selectMonth, styles } = useCalendarContext();\n const labels = Array.from({ length: 12 }, (_, index) =>\n new Intl.DateTimeFormat(locale, { month: \"long\" }).format(createCalendarDate(2024, index, 1)),\n );\n return (\n <select\n {...props}\n aria-label={props[\"aria-label\"] ?? \"Select month\"}\n className={cx(styles.monthSelect, className)}\n data-slot=\"calendar-month-select\"\n onChange={(event) => selectMonth(Number(event.currentTarget.value))}\n ref={ref}\n value={month.getMonth()}\n >\n {labels.map((label, index) => (\n <option\n disabled={monthDisabled(createCalendarDate(month.getFullYear(), index, 1))}\n key={label}\n value={index}\n >\n {label}\n </option>\n ))}\n </select>\n );\n },\n);\n\nexport type CalendarYearSelectProps = Omit<\n ComponentPropsWithoutRef<\"select\">,\n \"children\" | \"onChange\" | \"value\"\n>;\nexport const CalendarYearSelect = forwardRef<HTMLSelectElement, CalendarYearSelectProps>(\n function CalendarYearSelect({ className, ...props }, ref) {\n const { month, monthDisabled, selectYear, styles, yearRange } = useCalendarContext();\n const years = Array.from(\n { length: yearRange.end - yearRange.start + 1 },\n (_, index) => yearRange.start + index,\n );\n return (\n <select\n {...props}\n aria-label={props[\"aria-label\"] ?? \"Select year\"}\n className={cx(styles.yearSelect, className)}\n data-slot=\"calendar-year-select\"\n onChange={(event) => selectYear(Number(event.currentTarget.value))}\n ref={ref}\n value={month.getFullYear()}\n >\n {years.map((year) => (\n <option\n disabled={monthDisabled(createCalendarDate(year, month.getMonth(), 1))}\n key={year}\n value={year}\n >\n {year}\n </option>\n ))}\n </select>\n );\n },\n);\n\nexport interface CalendarDayProps extends Omit<ComponentPropsWithoutRef<\"button\">, \"value\"> {\n date: Date;\n}\n\nexport const CalendarDay = forwardRef<HTMLButtonElement, CalendarDayProps>(function CalendarDay(\n { children, className, date, disabled, onClick, onKeyDown, ...props },\n ref,\n) {\n const {\n dateDisabled,\n disabled: calendarDisabled,\n focusDate,\n focusedDate,\n locale,\n month,\n onSelect,\n registerDay,\n selected,\n styles,\n today,\n weekStartsOn,\n } = useCalendarContext();\n const key = dateKey(date);\n const outsideMonth = !sameMonth(date, month);\n const isDisabled = Boolean(disabled || calendarDisabled || dateDisabled(date));\n const isSelected = isSameDay(date, selected);\n const isFocused = isSameDay(date, focusedDate);\n const isToday = isSameDay(date, today);\n return (\n // biome-ignore lint/a11y/useSemanticElements: the roving button is the interactive grid cell.\n <button\n {...props}\n aria-label={\n props[\"aria-label\"] ?? new Intl.DateTimeFormat(locale, { dateStyle: \"full\" }).format(date)\n }\n aria-current={isToday ? \"date\" : undefined}\n aria-selected={isSelected}\n className={cx(styles.day, className)}\n data-date={key}\n data-disabled={isDisabled || undefined}\n data-outside-month={outsideMonth || undefined}\n data-selected={isSelected || undefined}\n data-slot=\"calendar-day\"\n data-today={isToday || undefined}\n disabled={isDisabled}\n onClick={(event) => {\n onSelect(date);\n onClick?.(event);\n }}\n onKeyDown={(event) => {\n if (!event.defaultPrevented) {\n let nextDate: Date | undefined;\n switch (event.key) {\n case \"ArrowLeft\":\n nextDate = addDays(date, -1);\n break;\n case \"ArrowRight\":\n nextDate = addDays(date, 1);\n break;\n case \"ArrowUp\":\n nextDate = addDays(date, -7);\n break;\n case \"ArrowDown\":\n nextDate = addDays(date, 7);\n break;\n case \"Home\":\n nextDate = addDays(date, -((date.getDay() - weekStartsOn + 7) % 7));\n break;\n case \"End\":\n nextDate = addDays(date, 6 - ((date.getDay() - weekStartsOn + 7) % 7));\n break;\n case \"PageUp\":\n nextDate = addMonths(date, event.shiftKey ? -12 : -1);\n break;\n case \"PageDown\":\n nextDate = addMonths(date, event.shiftKey ? 12 : 1);\n break;\n case \"Enter\":\n case \" \":\n if (!isDisabled) {\n event.preventDefault();\n onSelect(date);\n }\n break;\n }\n if (nextDate) {\n event.preventDefault();\n focusDate(nextDate, nextDate < date ? -1 : 1);\n }\n }\n onKeyDown?.(event);\n }}\n ref={(node) => {\n registerDay(key, node);\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n role=\"gridcell\"\n tabIndex={isFocused && !isDisabled ? 0 : -1}\n type=\"button\"\n >\n {children ?? date.getDate()}\n </button>\n );\n});\n\nexport interface CalendarGridProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n \"aria-label\"?: string;\n}\n\nexport const CalendarGrid = forwardRef<HTMLDivElement, CalendarGridProps>(function CalendarGrid(\n { \"aria-label\": ariaLabel, className, ...props },\n ref,\n) {\n const { locale, month, styles, weekStartsOn } = useCalendarContext();\n const days = useMemo(() => getCalendarDays(month, weekStartsOn), [month, weekStartsOn]);\n const weeks = useMemo(\n () =>\n Array.from({ length: Math.ceil(days.length / 7) }, (_, index) =>\n days.slice(index * 7, index * 7 + 7),\n ),\n [days],\n );\n const weekdays = useMemo(() => getWeekdayLabels(locale, weekStartsOn), [locale, weekStartsOn]);\n return (\n <div {...props} className={cx(styles.calendar, className)} data-slot=\"calendar-grid\" ref={ref}>\n <div aria-hidden=\"true\" className={styles.weekdays} data-slot=\"calendar-weekdays\">\n {weekdays.map((weekday) => (\n <span className={styles.weekday} data-slot=\"calendar-weekday\" key={weekday}>\n {weekday}\n </span>\n ))}\n </div>\n {/* biome-ignore lint/a11y/useSemanticElements: the calendar uses the ARIA grid pattern. */}\n <div\n aria-label={ariaLabel ?? formatMonthLabel(month, locale)}\n className={styles.grid}\n data-slot=\"calendar-day-grid\"\n role=\"grid\"\n >\n {weeks.map((week, index) => (\n // biome-ignore lint/a11y/useSemanticElements: Calendar rows use ARIA grid semantics while the day controls remain buttons.\n <div\n aria-rowindex={index + 1}\n className={styles.row}\n data-slot=\"calendar-week\"\n key={week.map(dateKey).join(\"-\")}\n role=\"row\"\n tabIndex={-1}\n >\n {week.map((date) => (\n <CalendarDay date={date} key={dateKey(date)} />\n ))}\n </div>\n ))}\n </div>\n </div>\n );\n});\n\nexport const Calendar = {\n Root: CalendarRoot,\n Header: CalendarHeader,\n Caption: CalendarCaption,\n Previous: CalendarPrevious,\n Next: CalendarNext,\n MonthSelect: CalendarMonthSelect,\n YearSelect: CalendarYearSelect,\n Grid: CalendarGrid,\n Day: CalendarDay,\n};\n"],"mappings":";;;;;;;AAkEA,MAAM,kBAAkB,cAA2C,IAAI;AAEvE,SAAS,qBAAqB;CAC5B,MAAM,UAAU,WAAW,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAEA,SAAS,UAAU,MAAY,OAAa;CAC1C,OAAO,KAAK,YAAY,MAAM,MAAM,YAAY,KAAK,KAAK,SAAS,MAAM,MAAM,SAAS;AAC1F;AAEA,MAAa,eAAe,WAA2C,SAAS,aAC9E,EACE,UACA,WACA,eAAe,MACf,WAAW,OACX,gBACA,SAAS,SACT,SACA,SACA,eACA,eACA,OAAO,iBACP,eAAe,GACf,WAAW,qBACX,GAAG,SAEL,KACA;CACA,MAAM,cAAc,mBAAmB,gBAAgB,iCAAiB,IAAI,KAAK;CACjF,MAAM,CAAC,mBAAmB,wBAAwB,SAAsB,YAAY;CACpF,MAAM,WAAW,oBAAoB,KAAA,IAAY,oBAAoB;CACrE,MAAM,CAAC,OAAO,iBA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O,UAAU,SAAS;EAAG,aAAU;EAAqB;YAA1F,CACE,oBAAC,OAAD;GAAK,eAAY;GAAO,WAAW,OAAO;GAAU,aAAU;aAC3D,SAAS,KAAK,YACb,oBAAC,QAAD;IAAM,WAAW,OAAO;IAAS,aAAU;cACxC;GACG,GAF6D,OAE7D,CACP;EACE,CAAA,GAEL,oBAAC,OAAD;GACE,cAAY,aAAa,iBAAiB,OAAO,MAAM;GACvD,WAAW,OAAO;GAClB,aAAU;GACV,MAAK;aAEJ,MAAM,KAAK,MAAM,UAEhB,oBAAC,OAAD;IACE,iBAAe,QAAQ;IACvB,WAAW,OAAO;IAClB,aAAU;IAEV,MAAK;IACL,UAAU;cAET,KAAK,KAAK,SACT,oBAAC,aAAD,EAAmB,KAA2B,GAAhB,QAAQ,IAAI,CAAI,CAC/C;GACE,GAPE,KAAK,IAAI,OAAO,CAAC,CAAC,KAAK,GAAG,CAO5B,CACN;EACE,CAAA,CACF;;AAET,CAAC;AAED,MAAa,WAAW;CACtB,MAAM;CACN,QAAQ;CACR,SAAS;CACT,UAAU;CACV,MAAM;CACN,aAAa;CACb,YAAY;CACZ,MAAM;CACN,KAAK;AACP"}
|
|
1
|
+
{"version":3,"file":"calendar.js","names":[],"sources":["../../../src/components/calendar/calendar.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { calendar } from \"../../styled-system/recipes\";\nimport {\n addDays,\n addMonths,\n createCalendarDate,\n dateKey,\n formatMonthLabel,\n getCalendarDays,\n getWeekdayLabels,\n isAfterDay,\n isBeforeDay,\n isSameDay,\n startOfMonth,\n} from \"../date-picker/date-utils\";\n\nexport interface CalendarYearRange {\n start: number;\n end: number;\n}\n\nexport interface CalendarRootProps\n extends Omit<ComponentPropsWithoutRef<\"section\">, \"children\" | \"defaultValue\" | \"value\"> {\n value?: Date | null;\n defaultValue?: Date | null;\n onValueChange?: (value: Date | null) => void;\n referenceDate?: Date;\n locale?: string;\n weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n minDate?: Date;\n maxDate?: Date;\n isDateDisabled?: (date: Date) => boolean;\n yearRange?: CalendarYearRange;\n disabled?: boolean;\n children?: ReactNode;\n}\n\ninterface CalendarContextValue {\n calendarId: string;\n dateDisabled: (date: Date) => boolean;\n disabled: boolean;\n focusedDate: Date;\n focusDate: (date: Date, direction?: number) => void;\n locale: string;\n month: Date;\n monthDisabled: (date: Date) => boolean;\n onSelect: (date: Date) => void;\n selected: Date | null;\n setMonth: (date: Date) => void;\n styles: ReturnType<typeof calendar>;\n today: Date;\n weekStartsOn: number;\n yearRange: CalendarYearRange;\n canNavigate: (amount: number) => boolean;\n selectMonth: (month: number) => void;\n selectYear: (year: number) => void;\n registerDay: (key: string, node: HTMLButtonElement | null) => void;\n}\n\nimport { createContext, useContext } from \"react\";\n\nconst CalendarContext = createContext<CalendarContextValue | null>(null);\n\nfunction useCalendarContext() {\n const context = useContext(CalendarContext);\n if (!context) throw new Error(\"Calendar parts must be rendered inside Calendar.Root.\");\n return context;\n}\n\nfunction sameMonth(left: Date, right: Date) {\n return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth();\n}\n\nexport const CalendarRoot = forwardRef<HTMLElement, CalendarRootProps>(function CalendarRoot(\n {\n children,\n className,\n defaultValue = null,\n disabled = false,\n isDateDisabled,\n locale = \"pt-BR\",\n maxDate,\n minDate,\n onValueChange,\n referenceDate,\n value: controlledValue,\n weekStartsOn = 0,\n yearRange: configuredYearRange,\n ...props\n },\n ref,\n) {\n const initialDate = controlledValue ?? defaultValue ?? referenceDate ?? new Date();\n const [uncontrolledValue, setUncontrolledValue] = useState<Date | null>(defaultValue);\n const selected = controlledValue === undefined ? uncontrolledValue : controlledValue;\n const [month, setMonthState] = useState(() => startOfMonth(initialDate));\n const [focusedDate, setFocusedDate] = useState(selected ?? initialDate);\n const dayRefs = useRef(new Map<string, HTMLButtonElement>());\n const calendarId = useId();\n const styles = calendar();\n const today = useMemo(\n () =>\n createCalendarDate(\n (referenceDate ?? new Date()).getFullYear(),\n (referenceDate ?? new Date()).getMonth(),\n (referenceDate ?? new Date()).getDate(),\n ),\n [referenceDate],\n );\n const minMonth = minDate ? startOfMonth(minDate) : undefined;\n const maxMonth = maxDate ? startOfMonth(maxDate) : undefined;\n const yearRange = useMemo(() => {\n const start = configuredYearRange?.start ?? today.getFullYear() - 100;\n const end = configuredYearRange?.end ?? today.getFullYear() + 20;\n const years = [selected?.getFullYear(), minDate?.getFullYear(), maxDate?.getFullYear()].filter(\n (year): year is number => year !== undefined,\n );\n return { start: Math.min(start, end, ...years), end: Math.max(start, end, ...years) };\n }, [configuredYearRange?.end, configuredYearRange?.start, maxDate, minDate, selected, today]);\n\n const dateDisabled = useCallback(\n (date: Date) =>\n Boolean(\n (minDate && isBeforeDay(date, minDate)) ||\n (maxDate && isAfterDay(date, maxDate)) ||\n isDateDisabled?.(date),\n ),\n [isDateDisabled, maxDate, minDate],\n );\n const monthDisabled = useCallback(\n (date: Date) => {\n const first = startOfMonth(date);\n const last = createCalendarDate(date.getFullYear(), date.getMonth() + 1, 0);\n return Boolean(\n (minDate && isBeforeDay(last, minDate)) || (maxDate && isAfterDay(first, maxDate)),\n );\n },\n [maxDate, minDate],\n );\n const clampMonth = useCallback(\n (date: Date) => {\n const normalized = startOfMonth(date);\n if (minMonth && isBeforeDay(normalized, minMonth)) return minMonth;\n if (maxMonth && isAfterDay(normalized, maxMonth)) return maxMonth;\n return normalized;\n },\n [maxMonth, minMonth],\n );\n const setMonth = useCallback((date: Date) => setMonthState(clampMonth(date)), [clampMonth]);\n const canNavigate = useCallback(\n (amount: number) => {\n const next = addMonths(month, amount);\n return (\n !(minMonth && isBeforeDay(next, minMonth)) && !(maxMonth && isAfterDay(next, maxMonth))\n );\n },\n [maxMonth, minMonth, month],\n );\n const setValue = useCallback(\n (nextValue: Date | null) => {\n if (controlledValue === undefined) setUncontrolledValue(nextValue);\n onValueChange?.(nextValue);\n },\n [controlledValue, onValueChange],\n );\n const onSelect = useCallback(\n (date: Date) => {\n if (disabled || dateDisabled(date)) return;\n const next = createCalendarDate(date.getFullYear(), date.getMonth(), date.getDate());\n setValue(next);\n setFocusedDate(next);\n setMonth(next);\n },\n [dateDisabled, disabled, setMonth, setValue],\n );\n const focusDate = useCallback(\n (date: Date, direction = 1) => {\n let next = createCalendarDate(date.getFullYear(), date.getMonth(), date.getDate());\n const step = direction < 0 ? -1 : 1;\n let attempts = 0;\n while (dateDisabled(next) && attempts < 366) {\n next = addDays(next, step);\n attempts += 1;\n }\n setFocusedDate(next);\n setMonth(next);\n const focusTarget = () => dayRefs.current.get(dateKey(next))?.focus();\n focusTarget();\n queueMicrotask(focusTarget);\n },\n [dateDisabled, setMonth],\n );\n const selectMonth = useCallback(\n (monthIndex: number) => setMonth(createCalendarDate(month.getFullYear(), monthIndex, 1)),\n [month, setMonth],\n );\n const selectYear = useCallback(\n (year: number) => setMonth(createCalendarDate(year, month.getMonth(), 1)),\n [month, setMonth],\n );\n const registerDay = useCallback((key: string, node: HTMLButtonElement | null) => {\n if (node) dayRefs.current.set(key, node);\n else dayRefs.current.delete(key);\n }, []);\n\n useEffect(() => {\n if (!selected) return;\n setFocusedDate(selected);\n setMonthState((current) => (sameMonth(current, selected) ? current : clampMonth(selected)));\n }, [clampMonth, selected]);\n\n const context: CalendarContextValue = {\n calendarId,\n canNavigate,\n dateDisabled,\n disabled,\n focusedDate,\n focusDate,\n locale,\n month,\n monthDisabled,\n onSelect,\n registerDay,\n selected,\n selectMonth,\n selectYear,\n setMonth,\n styles,\n today,\n weekStartsOn,\n yearRange,\n };\n\n return (\n <CalendarContext.Provider value={context}>\n <section\n {...props}\n aria-label={props[\"aria-label\"] ?? formatMonthLabel(month, locale)}\n className={cx(styles.root, className)}\n data-jaci-component=\"calendar\"\n data-slot=\"calendar\"\n ref={ref}\n >\n {children ?? (\n <>\n <CalendarHeader>\n <CalendarPrevious />\n <CalendarCaption />\n <CalendarNext />\n </CalendarHeader>\n <CalendarGrid />\n </>\n )}\n </section>\n </CalendarContext.Provider>\n );\n});\n\nexport type CalendarHeaderProps = ComponentPropsWithoutRef<\"div\">;\nexport const CalendarHeader = forwardRef<HTMLDivElement, CalendarHeaderProps>(\n function CalendarHeader({ className, ...props }, ref) {\n const { styles } = useCalendarContext();\n return (\n <div\n {...props}\n className={cx(styles.header, className)}\n data-slot=\"calendar-header\"\n ref={ref}\n />\n );\n },\n);\n\nexport type CalendarCaptionProps = ComponentPropsWithoutRef<\"span\">;\nexport const CalendarCaption = forwardRef<HTMLSpanElement, CalendarCaptionProps>(\n function CalendarCaption({ children, className, ...props }, ref) {\n const { locale, month, styles } = useCalendarContext();\n return (\n <span\n {...props}\n className={cx(styles.caption, className)}\n data-slot=\"calendar-caption\"\n ref={ref}\n >\n {children ?? formatMonthLabel(month, locale)}\n </span>\n );\n },\n);\n\nexport interface CalendarNavigationProps extends ComponentPropsWithoutRef<\"button\"> {\n amount?: number;\n}\n\nconst CalendarNavigationButton = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarNavigationButton({ amount = 1, children, className, onClick, ...props }, ref) {\n const { canNavigate, month, setMonth, styles } = useCalendarContext();\n const isDisabled = props.disabled || !canNavigate(amount);\n return (\n <button\n {...props}\n aria-label={props[\"aria-label\"] ?? (amount < 0 ? \"Previous month\" : \"Next month\")}\n className={cx(styles.navigation, className)}\n data-slot={amount < 0 ? \"calendar-previous\" : \"calendar-next\"}\n disabled={isDisabled}\n onClick={(event) => {\n if (!isDisabled) setMonth(addMonths(month, amount));\n onClick?.(event);\n }}\n ref={ref}\n type=\"button\"\n >\n {children ?? (amount < 0 ? \"‹\" : \"›\")}\n </button>\n );\n },\n);\n\nexport const CalendarPrevious = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarPrevious(props, ref) {\n return <CalendarNavigationButton {...props} amount={-1} ref={ref} />;\n },\n);\nexport const CalendarNext = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarNext(props, ref) {\n return <CalendarNavigationButton {...props} amount={1} ref={ref} />;\n },\n);\n\nexport type CalendarMonthSelectProps = Omit<\n ComponentPropsWithoutRef<\"select\">,\n \"children\" | \"onChange\" | \"value\"\n>;\nexport const CalendarMonthSelect = forwardRef<HTMLSelectElement, CalendarMonthSelectProps>(\n function CalendarMonthSelect({ className, ...props }, ref) {\n const { locale, month, monthDisabled, selectMonth, styles } = useCalendarContext();\n const labels = Array.from({ length: 12 }, (_, index) =>\n new Intl.DateTimeFormat(locale, { month: \"long\" }).format(createCalendarDate(2024, index, 1)),\n );\n return (\n <select\n {...props}\n aria-label={props[\"aria-label\"] ?? \"Select month\"}\n className={cx(styles.monthSelect, className)}\n data-slot=\"calendar-month-select\"\n onChange={(event) => selectMonth(Number(event.currentTarget.value))}\n ref={ref}\n value={month.getMonth()}\n >\n {labels.map((label, index) => (\n <option\n disabled={monthDisabled(createCalendarDate(month.getFullYear(), index, 1))}\n key={label}\n value={index}\n >\n {label}\n </option>\n ))}\n </select>\n );\n },\n);\n\nexport type CalendarYearSelectProps = Omit<\n ComponentPropsWithoutRef<\"select\">,\n \"children\" | \"onChange\" | \"value\"\n>;\nexport const CalendarYearSelect = forwardRef<HTMLSelectElement, CalendarYearSelectProps>(\n function CalendarYearSelect({ className, ...props }, ref) {\n const { month, monthDisabled, selectYear, styles, yearRange } = useCalendarContext();\n const years = Array.from(\n { length: yearRange.end - yearRange.start + 1 },\n (_, index) => yearRange.start + index,\n );\n return (\n <select\n {...props}\n aria-label={props[\"aria-label\"] ?? \"Select year\"}\n className={cx(styles.yearSelect, className)}\n data-slot=\"calendar-year-select\"\n onChange={(event) => selectYear(Number(event.currentTarget.value))}\n ref={ref}\n value={month.getFullYear()}\n >\n {years.map((year) => (\n <option\n disabled={monthDisabled(createCalendarDate(year, month.getMonth(), 1))}\n key={year}\n value={year}\n >\n {year}\n </option>\n ))}\n </select>\n );\n },\n);\n\nexport interface CalendarDayProps extends Omit<ComponentPropsWithoutRef<\"button\">, \"value\"> {\n date: Date;\n}\n\nexport const CalendarDay = forwardRef<HTMLButtonElement, CalendarDayProps>(function CalendarDay(\n { children, className, date, disabled, onClick, onKeyDown, ...props },\n ref,\n) {\n const {\n dateDisabled,\n disabled: calendarDisabled,\n focusDate,\n focusedDate,\n locale,\n month,\n onSelect,\n registerDay,\n selected,\n styles,\n today,\n weekStartsOn,\n } = useCalendarContext();\n const key = dateKey(date);\n const outsideMonth = !sameMonth(date, month);\n const isDisabled = Boolean(disabled || calendarDisabled || dateDisabled(date));\n const isSelected = isSameDay(date, selected);\n const isFocused = isSameDay(date, focusedDate);\n const isToday = isSameDay(date, today);\n return (\n // biome-ignore lint/a11y/useSemanticElements: the roving button is the interactive grid cell.\n <button\n {...props}\n aria-label={\n props[\"aria-label\"] ?? new Intl.DateTimeFormat(locale, { dateStyle: \"full\" }).format(date)\n }\n aria-current={isToday ? \"date\" : undefined}\n aria-selected={isSelected}\n className={cx(styles.day, className)}\n data-date={key}\n data-disabled={isDisabled || undefined}\n data-outside-month={outsideMonth || undefined}\n data-selected={isSelected || undefined}\n data-slot=\"calendar-day\"\n data-today={isToday || undefined}\n disabled={isDisabled}\n onClick={(event) => {\n onSelect(date);\n onClick?.(event);\n }}\n onKeyDown={(event) => {\n if (!event.defaultPrevented) {\n let nextDate: Date | undefined;\n switch (event.key) {\n case \"ArrowLeft\":\n nextDate = addDays(date, -1);\n break;\n case \"ArrowRight\":\n nextDate = addDays(date, 1);\n break;\n case \"ArrowUp\":\n nextDate = addDays(date, -7);\n break;\n case \"ArrowDown\":\n nextDate = addDays(date, 7);\n break;\n case \"Home\":\n nextDate = addDays(date, -((date.getDay() - weekStartsOn + 7) % 7));\n break;\n case \"End\":\n nextDate = addDays(date, 6 - ((date.getDay() - weekStartsOn + 7) % 7));\n break;\n case \"PageUp\":\n nextDate = addMonths(date, event.shiftKey ? -12 : -1);\n break;\n case \"PageDown\":\n nextDate = addMonths(date, event.shiftKey ? 12 : 1);\n break;\n case \"Enter\":\n case \" \":\n if (!isDisabled) {\n event.preventDefault();\n onSelect(date);\n }\n break;\n }\n if (nextDate) {\n event.preventDefault();\n focusDate(nextDate, nextDate < date ? -1 : 1);\n }\n }\n onKeyDown?.(event);\n }}\n ref={(node) => {\n registerDay(key, node);\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n role=\"gridcell\"\n tabIndex={isFocused && !isDisabled ? 0 : -1}\n type=\"button\"\n >\n {children ?? date.getDate()}\n </button>\n );\n});\n\nexport interface CalendarGridProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n \"aria-label\"?: string;\n}\n\nexport const CalendarGrid = forwardRef<HTMLDivElement, CalendarGridProps>(function CalendarGrid(\n { \"aria-label\": ariaLabel, className, ...props },\n ref,\n) {\n const { locale, month, styles, weekStartsOn } = useCalendarContext();\n const days = useMemo(() => getCalendarDays(month, weekStartsOn), [month, weekStartsOn]);\n const weeks = useMemo(\n () =>\n Array.from({ length: Math.ceil(days.length / 7) }, (_, index) =>\n days.slice(index * 7, index * 7 + 7),\n ),\n [days],\n );\n const weekdays = useMemo(() => getWeekdayLabels(locale, weekStartsOn), [locale, weekStartsOn]);\n return (\n <div {...props} className={cx(styles.calendar, className)} data-slot=\"calendar-grid\" ref={ref}>\n <div aria-hidden=\"true\" className={styles.weekdays} data-slot=\"calendar-weekdays\">\n {weekdays.map((weekday) => (\n <span className={styles.weekday} data-slot=\"calendar-weekday\" key={weekday}>\n {weekday}\n </span>\n ))}\n </div>\n {/* biome-ignore lint/a11y/useSemanticElements: the calendar uses the ARIA grid pattern. */}\n <div\n aria-label={ariaLabel ?? formatMonthLabel(month, locale)}\n className={styles.grid}\n data-slot=\"calendar-day-grid\"\n role=\"grid\"\n >\n {weeks.map((week, index) => (\n // biome-ignore lint/a11y/useSemanticElements: Calendar rows use ARIA grid semantics while the day controls remain buttons.\n <div\n aria-rowindex={index + 1}\n className={styles.row}\n data-slot=\"calendar-week\"\n key={week.map(dateKey).join(\"-\")}\n role=\"row\"\n tabIndex={-1}\n >\n {week.map((date) => (\n <CalendarDay date={date} key={dateKey(date)} />\n ))}\n </div>\n ))}\n </div>\n </div>\n );\n});\n\nexport const Calendar = {\n Root: CalendarRoot,\n Header: CalendarHeader,\n Caption: CalendarCaption,\n Previous: CalendarPrevious,\n Next: CalendarNext,\n MonthSelect: CalendarMonthSelect,\n YearSelect: CalendarYearSelect,\n Grid: CalendarGrid,\n Day: CalendarDay,\n};\n"],"mappings":";;;;;;;AAkEA,MAAM,kBAAkB,cAA2C,IAAI;AAEvE,SAAS,qBAAqB;CAC5B,MAAM,UAAU,WAAW,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAEA,SAAS,UAAU,MAAY,OAAa;CAC1C,OAAO,KAAK,YAAY,MAAM,MAAM,YAAY,KAAK,KAAK,SAAS,MAAM,MAAM,SAAS;AAC1F;AAEA,MAAa,eAAe,WAA2C,SAAS,aAC9E,EACE,UACA,WACA,eAAe,MACf,WAAW,OACX,gBACA,SAAS,SACT,SACA,SACA,eACA,eACA,OAAO,iBACP,eAAe,GACf,WAAW,qBACX,GAAG,SAEL,KACA;CACA,MAAM,cAAc,mBAAmB,gBAAgB,iCAAiB,IAAI,KAAK;CACjF,MAAM,CAAC,mBAAmB,wBAAwB,SAAsB,YAAY;CACpF,MAAM,WAAW,oBAAoB,KAAA,IAAY,oBAAoB;CACrE,MAAM,CAAC,OAAO,iBAAiB,eAAe,aAAa,WAAW,CAAC;CACvE,MAAM,CAAC,aAAa,kBAAkB,SAAS,YAAY,WAAW;CACtE,MAAM,UAAU,uBAAO,IAAI,IAA+B,CAAC;CAC3D,MAAM,aAAa,MAAM;CACzB,MAAM,SAAS,SAAS;CACxB,MAAM,QAAQ,cAEV,oBACG,iCAAiB,IAAI,KAAK,EAAA,CAAG,YAAY,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GACG,GAF6D,OAE7D,CACP;EACE,CAAA,GAEL,oBAAC,OAAD;GACE,cAAY,aAAa,iBAAiB,OAAO,MAAM;GACvD,WAAW,OAAO;GAClB,aAAU;GACV,MAAK;GAEJ,UAAA,MAAM,KAAK,MAAM,UAEhB,oBAAC,OAAD;IACE,iBAAe,QAAQ;IACvB,WAAW,OAAO;IAClB,aAAU;IAEV,MAAK;IACL,UAAU;IAET,UAAA,KAAK,KAAK,SACT,oBAAC,aAAD,EAAmB,KAA2B,GAAhB,QAAQ,IAAI,CAAI,CAC/C;GACE,GAPE,KAAK,IAAI,OAAO,CAAC,CAAC,KAAK,GAAG,CAO5B,CACN;EACE,CAAA,CACF;;AAET,CAAC;AAED,MAAa,WAAW;CACtB,MAAM;CACN,QAAQ;CACR,SAAS;CACT,UAAU;CACV,MAAM;CACN,aAAa;CACb,YAAY;CACZ,MAAM;CACN,KAAK;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.cjs","names":["card","cx"],"sources":["../../../src/components/card/card.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { card } from \"../../styled-system/recipes\";\n\nexport interface CardProps extends ComponentPropsWithoutRef<\"article\"> {\n variant?: \"outline\" | \"elevated\" | \"subtle\";\n}\n\nconst CardBase = forwardRef<HTMLElement, CardProps>(function Card(\n { className, variant = \"outline\", ...props },\n ref,\n) {\n const styles = card({ variant });\n\n return (\n <article\n {...props}\n ref={ref}\n className={cx(styles.root, className)}\n data-jaci-component=\"card\"\n data-slot=\"card\"\n />\n );\n});\n\nexport const CardHeader = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<\"div\">>(\n function CardHeader({ className, ...props }, ref) {\n return (\n <div {...props} ref={ref} className={cx(card().header, className)} data-slot=\"card-header\" />\n );\n },\n);\n\nexport const CardTitle = forwardRef<HTMLHeadingElement, ComponentPropsWithoutRef<\"h3\">>(\n function CardTitle({ className, ...props }, ref) {\n return (\n <h3 {...props} ref={ref} className={cx(card().title, className)} data-slot=\"card-title\" />\n );\n },\n);\n\nexport const CardContent = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<\"div\">>(\n function CardContent({ className, ...props }, ref) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(card().content, className)}\n data-slot=\"card-content\"\n />\n );\n },\n);\n\nexport const CardFooter = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<\"div\">>(\n function CardFooter({ className, ...props }, ref) {\n return (\n <div {...props} ref={ref} className={cx(card().footer, className)} data-slot=\"card-footer\" />\n );\n },\n);\n\nexport const Card = Object.assign(CardBase, {\n Root: CardBase,\n Header: CardHeader,\n Title: CardTitle,\n Content: CardContent,\n Footer: CardFooter,\n});\n\nexport const CardNamespace = Card;\n"],"mappings":";;;;;AAUA,MAAM,YAAA,
|
|
1
|
+
{"version":3,"file":"card.cjs","names":["forwardRef","card","cx"],"sources":["../../../src/components/card/card.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { card } from \"../../styled-system/recipes\";\n\nexport interface CardProps extends ComponentPropsWithoutRef<\"article\"> {\n variant?: \"outline\" | \"elevated\" | \"subtle\";\n}\n\nconst CardBase = forwardRef<HTMLElement, CardProps>(function Card(\n { className, variant = \"outline\", ...props },\n ref,\n) {\n const styles = card({ variant });\n\n return (\n <article\n {...props}\n ref={ref}\n className={cx(styles.root, className)}\n data-jaci-component=\"card\"\n data-slot=\"card\"\n />\n );\n});\n\nexport const CardHeader = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<\"div\">>(\n function CardHeader({ className, ...props }, ref) {\n return (\n <div {...props} ref={ref} className={cx(card().header, className)} data-slot=\"card-header\" />\n );\n },\n);\n\nexport const CardTitle = forwardRef<HTMLHeadingElement, ComponentPropsWithoutRef<\"h3\">>(\n function CardTitle({ className, ...props }, ref) {\n return (\n <h3 {...props} ref={ref} className={cx(card().title, className)} data-slot=\"card-title\" />\n );\n },\n);\n\nexport const CardContent = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<\"div\">>(\n function CardContent({ className, ...props }, ref) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(card().content, className)}\n data-slot=\"card-content\"\n />\n );\n },\n);\n\nexport const CardFooter = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<\"div\">>(\n function CardFooter({ className, ...props }, ref) {\n return (\n <div {...props} ref={ref} className={cx(card().footer, className)} data-slot=\"card-footer\" />\n );\n },\n);\n\nexport const Card = Object.assign(CardBase, {\n Root: CardBase,\n Header: CardHeader,\n Title: CardTitle,\n Content: CardContent,\n Footer: CardFooter,\n});\n\nexport const CardNamespace = Card;\n"],"mappings":";;;;;AAUA,MAAM,YAAA,GAAWA,MAAAA,WAAAA,CAAmC,SAAS,KAC3D,EAAE,WAAW,UAAU,WAAW,GAAG,SACrC,KACA;CACA,MAAM,SAASC,aAAAA,KAAK,EAAE,QAAQ,CAAC;CAE/B,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;EACE,GAAI;EACC;EACL,WAAWC,WAAAA,GAAG,OAAO,MAAM,SAAS;EACpC,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CAAC;AAED,MAAa,cAAA,GAAaF,MAAAA,WAAAA,CACxB,SAAS,WAAW,EAAE,WAAW,GAAG,SAAS,KAAK;CAChD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,GAAI;EAAY;EAAK,WAAWE,WAAAA,GAAGD,aAAAA,KAAK,CAAC,CAAC,QAAQ,SAAS;EAAG,aAAU;CAAe,CAAA;AAEhG,CACF;AAEA,MAAa,aAAA,GAAYD,MAAAA,WAAAA,CACvB,SAAS,UAAU,EAAE,WAAW,GAAG,SAAS,KAAK;CAC/C,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;EAAI,GAAI;EAAY;EAAK,WAAWE,WAAAA,GAAGD,aAAAA,KAAK,CAAC,CAAC,OAAO,SAAS;EAAG,aAAU;CAAc,CAAA;AAE7F,CACF;AAEA,MAAa,eAAA,GAAcD,MAAAA,WAAAA,CACzB,SAAS,YAAY,EAAE,WAAW,GAAG,SAAS,KAAK;CACjD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,GAAI;EACC;EACL,WAAWE,WAAAA,GAAGD,aAAAA,KAAK,CAAC,CAAC,SAAS,SAAS;EACvC,aAAU;CACX,CAAA;AAEL,CACF;AAEA,MAAa,cAAA,GAAaD,MAAAA,WAAAA,CACxB,SAAS,WAAW,EAAE,WAAW,GAAG,SAAS,KAAK;CAChD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,GAAI;EAAY;EAAK,WAAWE,WAAAA,GAAGD,aAAAA,KAAK,CAAC,CAAC,QAAQ,SAAS;EAAG,aAAU;CAAe,CAAA;AAEhG,CACF;AAEA,MAAa,OAAO,OAAO,OAAO,UAAU;CAC1C,MAAM;CACN,QAAQ;CACR,OAAO;CACP,SAAS;CACT,QAAQ;AACV,CAAC;AAED,MAAa,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.cjs","names":["carousel","cx"],"sources":["../../../src/components/carousel/carousel.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n ComponentPropsWithoutRef,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n PointerEvent,\n ReactNode,\n Ref,\n} from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { carousel } from \"../../styled-system/recipes\";\n\nexport type CarouselOrientation = \"horizontal\" | \"vertical\";\n\ninterface CarouselContextValue {\n currentIndex: number;\n disabled: boolean;\n getNextIndex: (direction: -1 | 1) => number;\n indexCount: number;\n loop: boolean;\n onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n registerIndex: (index: number) => () => void;\n setIndex: (index: number) => void;\n startSwipe: (event: PointerEvent<HTMLElement>) => void;\n moveSwipe: (event: PointerEvent<HTMLElement>) => void;\n endSwipe: (event: PointerEvent<HTMLElement>) => void;\n orientation: CarouselOrientation;\n styles: ReturnType<typeof carousel>;\n}\n\nconst CarouselContext = createContext<CarouselContextValue | null>(null);\n\nfunction useCarouselContext() {\n const context = useContext(CarouselContext);\n if (!context) throw new Error(\"Carousel parts must be rendered inside Carousel.Root.\");\n return context;\n}\n\nexport interface CarouselRootProps extends ComponentPropsWithoutRef<\"section\"> {\n index?: number;\n defaultIndex?: number;\n onIndexChange?: (index: number) => void;\n orientation?: CarouselOrientation;\n loop?: boolean;\n swipeable?: boolean;\n autoplay?: boolean;\n autoplayInterval?: number;\n pauseOnHover?: boolean;\n pauseOnFocus?: boolean;\n disabled?: boolean;\n}\n\nexport const CarouselRoot = forwardRef<HTMLElement, CarouselRootProps>(function CarouselRoot(\n {\n autoplay = false,\n autoplayInterval = 5000,\n children,\n className,\n defaultIndex = 0,\n disabled = false,\n index,\n onBlur,\n onFocus,\n loop = true,\n onIndexChange,\n onKeyDown,\n onPointerEnter,\n onPointerLeave,\n orientation = \"horizontal\",\n pauseOnFocus = true,\n pauseOnHover = true,\n style,\n swipeable = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledIndex, setUncontrolledIndex] = useState(Math.max(0, defaultIndex));\n const [registered, setRegistered] = useState<Set<number>>(() => new Set());\n const [paused, setPaused] = useState(false);\n const [focusWithin, setFocusWithin] = useState(false);\n const swipeRef = useRef<{ pointerId: number; startX: number; startY: number } | null>(null);\n const isControlled = index !== undefined;\n const indexCount = registered.size ? Math.max(...registered) + 1 : 0;\n const currentIndex = Math.max(\n 0,\n Math.min(indexCount ? indexCount - 1 : 0, index ?? uncontrolledIndex),\n );\n const styles = carousel({ orientation, active: true });\n\n const setIndex = useCallback(\n (nextIndex: number) => {\n if (disabled || !indexCount) return;\n const next = loop\n ? (nextIndex + indexCount) % indexCount\n : Math.max(0, Math.min(indexCount - 1, nextIndex));\n if (!isControlled) setUncontrolledIndex(next);\n if (next !== currentIndex) onIndexChange?.(next);\n },\n [currentIndex, disabled, indexCount, isControlled, loop, onIndexChange],\n );\n\n const getNextIndex = useCallback((direction: -1 | 1) => currentIndex + direction, [currentIndex]);\n\n const registerIndex = useCallback((itemIndex: number) => {\n setRegistered((previous) => {\n if (previous.has(itemIndex)) return previous;\n const next = new Set(previous);\n next.add(itemIndex);\n return next;\n });\n return () =>\n setRegistered((previous) => {\n if (!previous.has(itemIndex)) return previous;\n const next = new Set(previous);\n next.delete(itemIndex);\n return next;\n });\n }, []);\n\n const onRootKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (disabled) return;\n const forward =\n orientation === \"horizontal\" ? event.key === \"ArrowRight\" : event.key === \"ArrowDown\";\n const backward =\n orientation === \"horizontal\" ? event.key === \"ArrowLeft\" : event.key === \"ArrowUp\";\n if (forward || backward) {\n event.preventDefault();\n setIndex(getNextIndex(forward ? 1 : -1));\n } else if (event.key === \"Home\") {\n event.preventDefault();\n setIndex(0);\n } else if (event.key === \"End\") {\n event.preventDefault();\n setIndex(indexCount - 1);\n }\n onKeyDown?.(event);\n },\n [disabled, getNextIndex, indexCount, onKeyDown, orientation, setIndex],\n );\n\n const startSwipe = useCallback(\n (event: PointerEvent<HTMLElement>) => {\n if (!swipeable || disabled || event.pointerType === \"mouse\") return;\n swipeRef.current = {\n pointerId: event.pointerId,\n startX: event.clientX,\n startY: event.clientY,\n };\n event.currentTarget.setPointerCapture?.(event.pointerId);\n },\n [disabled, swipeable],\n );\n\n const moveSwipe = useCallback(() => undefined, []);\n\n const endSwipe = useCallback(\n (event: PointerEvent<HTMLElement>) => {\n const start = swipeRef.current;\n swipeRef.current = null;\n if (!start || start.pointerId !== event.pointerId) return;\n const delta =\n orientation === \"horizontal\" ? event.clientX - start.startX : event.clientY - start.startY;\n if (Math.abs(delta) < 40) return;\n setIndex(getNextIndex(delta < 0 ? 1 : -1));\n },\n [getNextIndex, orientation, setIndex],\n );\n\n useEffect(() => {\n if (!autoplay || paused || disabled || indexCount < 2) return;\n const interval =\n Number.isFinite(autoplayInterval) && autoplayInterval > 0 ? autoplayInterval : 5000;\n const timer = window.setInterval(() => setIndex(getNextIndex(1)), interval);\n return () => window.clearInterval(timer);\n }, [autoplay, autoplayInterval, disabled, getNextIndex, indexCount, paused, setIndex]);\n\n const value = useMemo<CarouselContextValue>(\n () => ({\n currentIndex,\n disabled,\n endSwipe,\n getNextIndex,\n indexCount,\n loop,\n moveSwipe,\n onKeyDown: onRootKeyDown,\n orientation,\n registerIndex,\n setIndex,\n startSwipe,\n styles,\n }),\n [\n currentIndex,\n disabled,\n endSwipe,\n getNextIndex,\n indexCount,\n loop,\n moveSwipe,\n onRootKeyDown,\n orientation,\n registerIndex,\n setIndex,\n startSwipe,\n styles,\n ],\n );\n\n return (\n <CarouselContext.Provider value={value}>\n <section\n {...props}\n ref={ref}\n aria-roledescription=\"carousel\"\n className={cx(styles.root, className)}\n data-jaci-component=\"carousel\"\n data-orientation={orientation}\n data-slot=\"carousel\"\n data-state={paused ? \"paused\" : \"running\"}\n role=\"region\"\n tabIndex={disabled ? -1 : 0}\n onBlur={(event: FocusEvent<HTMLElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {\n setFocusWithin(false);\n if (pauseOnFocus) setPaused(false);\n }\n onBlur?.(event);\n }}\n onFocus={(event: FocusEvent<HTMLElement>) => {\n setFocusWithin(true);\n if (pauseOnFocus) {\n setPaused(true);\n }\n onFocus?.(event);\n }}\n onKeyDown={onRootKeyDown}\n onPointerCancel={endSwipe}\n onPointerDown={startSwipe}\n onPointerEnter={(event) => {\n if (pauseOnHover) setPaused(true);\n onPointerEnter?.(event);\n }}\n onPointerLeave={(event) => {\n if (pauseOnHover && !(pauseOnFocus && focusWithin)) setPaused(false);\n onPointerLeave?.(event);\n }}\n onPointerMove={moveSwipe}\n onPointerUp={endSwipe}\n style={{ \"--jaci-carousel-index\": currentIndex, ...style } as CSSProperties}\n >\n {children}\n </section>\n </CarouselContext.Provider>\n );\n});\n\nexport type CarouselViewportProps = ComponentPropsWithoutRef<\"div\">;\nexport const CarouselViewport = forwardRef<HTMLDivElement, CarouselViewportProps>(\n function CarouselViewport({ className, ...props }, ref) {\n const { styles } = useCarouselContext();\n return (\n <div\n {...props}\n ref={ref}\n className={cx(styles.viewport, className)}\n data-slot=\"carousel-viewport\"\n />\n );\n },\n);\n\nexport type CarouselTrackProps = ComponentPropsWithoutRef<\"div\">;\nexport const CarouselTrack = forwardRef<HTMLDivElement, CarouselTrackProps>(function CarouselTrack(\n { className, style, ...props },\n ref,\n) {\n const { currentIndex, orientation, styles } = useCarouselContext();\n const transform =\n orientation === \"horizontal\"\n ? `translateX(-${currentIndex * 100}%)`\n : `translateY(-${currentIndex * 100}%)`;\n return (\n <div\n {...props}\n ref={ref}\n className={cx(styles.track, className)}\n data-slot=\"carousel-track\"\n style={{ transform, ...style }}\n />\n );\n});\n\nexport interface CarouselItemProps extends ComponentPropsWithoutRef<\"div\"> {\n index: number;\n}\nexport const CarouselItem = forwardRef<HTMLDivElement, CarouselItemProps>(function CarouselItem(\n { children, className, index, ...props },\n ref,\n) {\n const { currentIndex, registerIndex, styles } = useCarouselContext();\n useEffect(() => registerIndex(index), [index, registerIndex]);\n const active = currentIndex === index;\n return (\n // biome-ignore lint/a11y/useSemanticElements: carousel slides use the ARIA group role.\n <div\n {...props}\n ref={ref}\n aria-hidden={!active}\n aria-roledescription=\"slide\"\n className={cx(styles.item, className)}\n data-index={index}\n data-jaci-component=\"carousel-item\"\n data-selected={active || undefined}\n data-slot=\"carousel-item\"\n role=\"group\"\n tabIndex={active ? 0 : -1}\n >\n {children}\n </div>\n );\n});\n\nfunction createSimpleSlot(slot: \"media\" | \"caption\" | \"title\" | \"description\") {\n return forwardRef<HTMLElement, ComponentPropsWithoutRef<\"div\">>(function CarouselSlot(\n { className, ...props },\n ref,\n ) {\n const { styles } = useCarouselContext();\n if (slot === \"title\")\n return (\n <h3\n {...props}\n ref={ref as Ref<HTMLHeadingElement>}\n className={cx(styles.title, className)}\n data-slot={`carousel-${slot}`}\n />\n );\n if (slot === \"description\")\n return (\n <p\n {...props}\n ref={ref as Ref<HTMLParagraphElement>}\n className={cx(styles.description, className)}\n data-slot={`carousel-${slot}`}\n />\n );\n return (\n <div\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(styles[slot], className)}\n data-slot={`carousel-${slot}`}\n />\n );\n });\n}\n\nexport const CarouselMedia = createSimpleSlot(\"media\");\nexport const CarouselCaption = createSimpleSlot(\"caption\");\nexport const CarouselTitle = createSimpleSlot(\"title\");\nexport const CarouselDescription = createSimpleSlot(\"description\");\n\nexport interface CarouselControlProps extends ComponentPropsWithoutRef<\"button\"> {\n children?: ReactNode;\n}\nexport const CarouselPrevious = forwardRef<HTMLButtonElement, CarouselControlProps>(\n function CarouselPrevious(\n { \"aria-label\": ariaLabel = \"Previous slide\", children, className, disabled, ...props },\n ref,\n ) {\n const {\n disabled: contextDisabled,\n getNextIndex,\n orientation,\n setIndex,\n styles,\n } = useCarouselContext();\n return (\n <button\n {...props}\n ref={ref}\n aria-label={ariaLabel}\n className={cx(styles.control, className)}\n data-slot=\"carousel-previous\"\n disabled={disabled ?? contextDisabled}\n onClick={() => setIndex(getNextIndex(-1))}\n type=\"button\"\n >\n {children ?? (orientation === \"vertical\" ? \"↑\" : \"‹\")}\n </button>\n );\n },\n);\n\nexport const CarouselNext = forwardRef<HTMLButtonElement, CarouselControlProps>(\n function CarouselNext(\n { \"aria-label\": ariaLabel = \"Next slide\", children, className, disabled, ...props },\n ref,\n ) {\n const {\n disabled: contextDisabled,\n getNextIndex,\n orientation,\n setIndex,\n styles,\n } = useCarouselContext();\n return (\n <button\n {...props}\n ref={ref}\n aria-label={ariaLabel}\n className={cx(styles.control, className)}\n data-slot=\"carousel-next\"\n disabled={disabled ?? contextDisabled}\n onClick={() => setIndex(getNextIndex(1))}\n type=\"button\"\n >\n {children ?? (orientation === \"vertical\" ? \"↓\" : \"›\")}\n </button>\n );\n },\n);\n\nexport interface CarouselIndicatorProps extends ComponentPropsWithoutRef<\"button\"> {\n index: number;\n}\nexport const CarouselIndicator = forwardRef<HTMLButtonElement, CarouselIndicatorProps>(\n function CarouselIndicator({ \"aria-label\": ariaLabel, className, index, ...props }, ref) {\n const { currentIndex, disabled, setIndex, styles } = useCarouselContext();\n return (\n <button\n {...props}\n ref={ref}\n aria-label={ariaLabel ?? `Go to slide ${index + 1}`}\n aria-selected={currentIndex === index}\n className={cx(styles.indicator, className)}\n data-selected={currentIndex === index || undefined}\n data-slot=\"carousel-indicator\"\n disabled={disabled}\n onClick={() => setIndex(index)}\n role=\"tab\"\n type=\"button\"\n />\n );\n },\n);\n\nexport const CarouselIndicators = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<\"div\">>(\n function CarouselIndicators({ children, className, ...props }, ref) {\n const { indexCount, styles } = useCarouselContext();\n return (\n <div\n {...props}\n ref={ref}\n aria-label=\"Slides\"\n className={cx(styles.indicators, className)}\n data-slot=\"carousel-indicators\"\n role=\"tablist\"\n >\n {children ??\n Array.from({ length: indexCount }, (_, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: indicators are stable by slide index.\n <CarouselIndicator index={index} key={`indicator-${index}`} />\n ))}\n </div>\n );\n },\n);\n\nexport const Carousel = {\n Root: CarouselRoot,\n Viewport: CarouselViewport,\n Track: CarouselTrack,\n Item: CarouselItem,\n Media: CarouselMedia,\n Caption: CarouselCaption,\n Title: CarouselTitle,\n Description: CarouselDescription,\n Previous: CarouselPrevious,\n Next: CarouselNext,\n Indicators: CarouselIndicators,\n Indicator: CarouselIndicator,\n};\n"],"mappings":";;;;;;AA2CA,MAAM,mBAAA,GAAA,MAAA,cAAA,CAA6D,IAAI;AAEvE,SAAS,qBAAqB;CAC5B,MAAM,WAAA,GAAA,MAAA,WAAA,CAA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MAAK;EACL,MAAK;CACN,CAAA;AAEL,CACF;AAEA,MAAa,sBAAA,GAAA,MAAA,WAAA,CACX,SAAS,mBAAmB,EAAE,UAAU,WAAW,GAAG,SAAS,KAAK;CAClE,MAAM,EAAE,YAAY,WAAW,mBAAmB;CAClD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,GAAI;EACC;EACL,cAAW;EACX,WAAWA,WAAAA,GAAG,OAAO,YAAY,SAAS;EAC1C,aAAU;EACV,MAAK;YAEJ,YACC,MAAM,KAAK,EAAE,QAAQ,WAAW,IAAI,GAAG,UAErC,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAD,EAA0B,MAAmC,GAAvB,aAAa,OAAU,CAC9D;CACA,CAAA;AAET,CACF;AAEA,MAAa,WAAW;CACtB,MAAM;CACN,UAAU;CACV,OAAO;CACP,MAAM;CACN,OAAO;CACP,SAAS;CACT,OAAO;CACP,aAAa;CACb,UAAU;CACV,MAAM;CACN,YAAY;CACZ,WAAW;AACb"}
|
|
1
|
+
{"version":3,"file":"carousel.cjs","names":["createContext","useContext","forwardRef","useState","useRef","carousel","useCallback","useMemo","cx"],"sources":["../../../src/components/carousel/carousel.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n ComponentPropsWithoutRef,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n PointerEvent,\n ReactNode,\n Ref,\n} from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { carousel } from \"../../styled-system/recipes\";\n\nexport type CarouselOrientation = \"horizontal\" | \"vertical\";\n\ninterface CarouselContextValue {\n currentIndex: number;\n disabled: boolean;\n getNextIndex: (direction: -1 | 1) => number;\n indexCount: number;\n loop: boolean;\n onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n registerIndex: (index: number) => () => void;\n setIndex: (index: number) => void;\n startSwipe: (event: PointerEvent<HTMLElement>) => void;\n moveSwipe: (event: PointerEvent<HTMLElement>) => void;\n endSwipe: (event: PointerEvent<HTMLElement>) => void;\n orientation: CarouselOrientation;\n styles: ReturnType<typeof carousel>;\n}\n\nconst CarouselContext = createContext<CarouselContextValue | null>(null);\n\nfunction useCarouselContext() {\n const context = useContext(CarouselContext);\n if (!context) throw new Error(\"Carousel parts must be rendered inside Carousel.Root.\");\n return context;\n}\n\nexport interface CarouselRootProps extends ComponentPropsWithoutRef<\"section\"> {\n index?: number;\n defaultIndex?: number;\n onIndexChange?: (index: number) => void;\n orientation?: CarouselOrientation;\n loop?: boolean;\n swipeable?: boolean;\n autoplay?: boolean;\n autoplayInterval?: number;\n pauseOnHover?: boolean;\n pauseOnFocus?: boolean;\n disabled?: boolean;\n}\n\nexport const CarouselRoot = forwardRef<HTMLElement, CarouselRootProps>(function CarouselRoot(\n {\n autoplay = false,\n autoplayInterval = 5000,\n children,\n className,\n defaultIndex = 0,\n disabled = false,\n index,\n onBlur,\n onFocus,\n loop = true,\n onIndexChange,\n onKeyDown,\n onPointerEnter,\n onPointerLeave,\n orientation = \"horizontal\",\n pauseOnFocus = true,\n pauseOnHover = true,\n style,\n swipeable = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledIndex, setUncontrolledIndex] = useState(Math.max(0, defaultIndex));\n const [registered, setRegistered] = useState<Set<number>>(() => new Set());\n const [paused, setPaused] = useState(false);\n const [focusWithin, setFocusWithin] = useState(false);\n const swipeRef = useRef<{ pointerId: number; startX: number; startY: number } | null>(null);\n const isControlled = index !== undefined;\n const indexCount = registered.size ? Math.max(...registered) + 1 : 0;\n const currentIndex = Math.max(\n 0,\n Math.min(indexCount ? indexCount - 1 : 0, index ?? uncontrolledIndex),\n );\n const styles = carousel({ orientation, active: true });\n\n const setIndex = useCallback(\n (nextIndex: number) => {\n if (disabled || !indexCount) return;\n const next = loop\n ? (nextIndex + indexCount) % indexCount\n : Math.max(0, Math.min(indexCount - 1, nextIndex));\n if (!isControlled) setUncontrolledIndex(next);\n if (next !== currentIndex) onIndexChange?.(next);\n },\n [currentIndex, disabled, indexCount, isControlled, loop, onIndexChange],\n );\n\n const getNextIndex = useCallback((direction: -1 | 1) => currentIndex + direction, [currentIndex]);\n\n const registerIndex = useCallback((itemIndex: number) => {\n setRegistered((previous) => {\n if (previous.has(itemIndex)) return previous;\n const next = new Set(previous);\n next.add(itemIndex);\n return next;\n });\n return () =>\n setRegistered((previous) => {\n if (!previous.has(itemIndex)) return previous;\n const next = new Set(previous);\n next.delete(itemIndex);\n return next;\n });\n }, []);\n\n const onRootKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (disabled) return;\n const forward =\n orientation === \"horizontal\" ? event.key === \"ArrowRight\" : event.key === \"ArrowDown\";\n const backward =\n orientation === \"horizontal\" ? event.key === \"ArrowLeft\" : event.key === \"ArrowUp\";\n if (forward || backward) {\n event.preventDefault();\n setIndex(getNextIndex(forward ? 1 : -1));\n } else if (event.key === \"Home\") {\n event.preventDefault();\n setIndex(0);\n } else if (event.key === \"End\") {\n event.preventDefault();\n setIndex(indexCount - 1);\n }\n onKeyDown?.(event);\n },\n [disabled, getNextIndex, indexCount, onKeyDown, orientation, setIndex],\n );\n\n const startSwipe = useCallback(\n (event: PointerEvent<HTMLElement>) => {\n if (!swipeable || disabled || event.pointerType === \"mouse\") return;\n swipeRef.current = {\n pointerId: event.pointerId,\n startX: event.clientX,\n startY: event.clientY,\n };\n event.currentTarget.setPointerCapture?.(event.pointerId);\n },\n [disabled, swipeable],\n );\n\n const moveSwipe = useCallback(() => undefined, []);\n\n const endSwipe = useCallback(\n (event: PointerEvent<HTMLElement>) => {\n const start = swipeRef.current;\n swipeRef.current = null;\n if (!start || start.pointerId !== event.pointerId) return;\n const delta =\n orientation === \"horizontal\" ? event.clientX - start.startX : event.clientY - start.startY;\n if (Math.abs(delta) < 40) return;\n setIndex(getNextIndex(delta < 0 ? 1 : -1));\n },\n [getNextIndex, orientation, setIndex],\n );\n\n useEffect(() => {\n if (!autoplay || paused || disabled || indexCount < 2) return;\n const interval =\n Number.isFinite(autoplayInterval) && autoplayInterval > 0 ? autoplayInterval : 5000;\n const timer = window.setInterval(() => setIndex(getNextIndex(1)), interval);\n return () => window.clearInterval(timer);\n }, [autoplay, autoplayInterval, disabled, getNextIndex, indexCount, paused, setIndex]);\n\n const value = useMemo<CarouselContextValue>(\n () => ({\n currentIndex,\n disabled,\n endSwipe,\n getNextIndex,\n indexCount,\n loop,\n moveSwipe,\n onKeyDown: onRootKeyDown,\n orientation,\n registerIndex,\n setIndex,\n startSwipe,\n styles,\n }),\n [\n currentIndex,\n disabled,\n endSwipe,\n getNextIndex,\n indexCount,\n loop,\n moveSwipe,\n onRootKeyDown,\n orientation,\n registerIndex,\n setIndex,\n startSwipe,\n styles,\n ],\n );\n\n return (\n <CarouselContext.Provider value={value}>\n <section\n {...props}\n ref={ref}\n aria-roledescription=\"carousel\"\n className={cx(styles.root, className)}\n data-jaci-component=\"carousel\"\n data-orientation={orientation}\n data-slot=\"carousel\"\n data-state={paused ? \"paused\" : \"running\"}\n role=\"region\"\n tabIndex={disabled ? -1 : 0}\n onBlur={(event: FocusEvent<HTMLElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {\n setFocusWithin(false);\n if (pauseOnFocus) setPaused(false);\n }\n onBlur?.(event);\n }}\n onFocus={(event: FocusEvent<HTMLElement>) => {\n setFocusWithin(true);\n if (pauseOnFocus) {\n setPaused(true);\n }\n onFocus?.(event);\n }}\n onKeyDown={onRootKeyDown}\n onPointerCancel={endSwipe}\n onPointerDown={startSwipe}\n onPointerEnter={(event) => {\n if (pauseOnHover) setPaused(true);\n onPointerEnter?.(event);\n }}\n onPointerLeave={(event) => {\n if (pauseOnHover && !(pauseOnFocus && focusWithin)) setPaused(false);\n onPointerLeave?.(event);\n }}\n onPointerMove={moveSwipe}\n onPointerUp={endSwipe}\n style={{ \"--jaci-carousel-index\": currentIndex, ...style } as CSSProperties}\n >\n {children}\n </section>\n </CarouselContext.Provider>\n );\n});\n\nexport type CarouselViewportProps = ComponentPropsWithoutRef<\"div\">;\nexport const CarouselViewport = forwardRef<HTMLDivElement, CarouselViewportProps>(\n function CarouselViewport({ className, ...props }, ref) {\n const { styles } = useCarouselContext();\n return (\n <div\n {...props}\n ref={ref}\n className={cx(styles.viewport, className)}\n data-slot=\"carousel-viewport\"\n />\n );\n },\n);\n\nexport type CarouselTrackProps = ComponentPropsWithoutRef<\"div\">;\nexport const CarouselTrack = forwardRef<HTMLDivElement, CarouselTrackProps>(function CarouselTrack(\n { className, style, ...props },\n ref,\n) {\n const { currentIndex, orientation, styles } = useCarouselContext();\n const transform =\n orientation === \"horizontal\"\n ? `translateX(-${currentIndex * 100}%)`\n : `translateY(-${currentIndex * 100}%)`;\n return (\n <div\n {...props}\n ref={ref}\n className={cx(styles.track, className)}\n data-slot=\"carousel-track\"\n style={{ transform, ...style }}\n />\n );\n});\n\nexport interface CarouselItemProps extends ComponentPropsWithoutRef<\"div\"> {\n index: number;\n}\nexport const CarouselItem = forwardRef<HTMLDivElement, CarouselItemProps>(function CarouselItem(\n { children, className, index, ...props },\n ref,\n) {\n const { currentIndex, registerIndex, styles } = useCarouselContext();\n useEffect(() => registerIndex(index), [index, registerIndex]);\n const active = currentIndex === index;\n return (\n // biome-ignore lint/a11y/useSemanticElements: carousel slides use the ARIA group role.\n <div\n {...props}\n ref={ref}\n aria-hidden={!active}\n aria-roledescription=\"slide\"\n className={cx(styles.item, className)}\n data-index={index}\n data-jaci-component=\"carousel-item\"\n data-selected={active || undefined}\n data-slot=\"carousel-item\"\n role=\"group\"\n tabIndex={active ? 0 : -1}\n >\n {children}\n </div>\n );\n});\n\nfunction createSimpleSlot(slot: \"media\" | \"caption\" | \"title\" | \"description\") {\n return forwardRef<HTMLElement, ComponentPropsWithoutRef<\"div\">>(function CarouselSlot(\n { className, ...props },\n ref,\n ) {\n const { styles } = useCarouselContext();\n if (slot === \"title\")\n return (\n <h3\n {...props}\n ref={ref as Ref<HTMLHeadingElement>}\n className={cx(styles.title, className)}\n data-slot={`carousel-${slot}`}\n />\n );\n if (slot === \"description\")\n return (\n <p\n {...props}\n ref={ref as Ref<HTMLParagraphElement>}\n className={cx(styles.description, className)}\n data-slot={`carousel-${slot}`}\n />\n );\n return (\n <div\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(styles[slot], className)}\n data-slot={`carousel-${slot}`}\n />\n );\n });\n}\n\nexport const CarouselMedia = createSimpleSlot(\"media\");\nexport const CarouselCaption = createSimpleSlot(\"caption\");\nexport const CarouselTitle = createSimpleSlot(\"title\");\nexport const CarouselDescription = createSimpleSlot(\"description\");\n\nexport interface CarouselControlProps extends ComponentPropsWithoutRef<\"button\"> {\n children?: ReactNode;\n}\nexport const CarouselPrevious = forwardRef<HTMLButtonElement, CarouselControlProps>(\n function CarouselPrevious(\n { \"aria-label\": ariaLabel = \"Previous slide\", children, className, disabled, ...props },\n ref,\n ) {\n const {\n disabled: contextDisabled,\n getNextIndex,\n orientation,\n setIndex,\n styles,\n } = useCarouselContext();\n return (\n <button\n {...props}\n ref={ref}\n aria-label={ariaLabel}\n className={cx(styles.control, className)}\n data-slot=\"carousel-previous\"\n disabled={disabled ?? contextDisabled}\n onClick={() => setIndex(getNextIndex(-1))}\n type=\"button\"\n >\n {children ?? (orientation === \"vertical\" ? \"↑\" : \"‹\")}\n </button>\n );\n },\n);\n\nexport const CarouselNext = forwardRef<HTMLButtonElement, CarouselControlProps>(\n function CarouselNext(\n { \"aria-label\": ariaLabel = \"Next slide\", children, className, disabled, ...props },\n ref,\n ) {\n const {\n disabled: contextDisabled,\n getNextIndex,\n orientation,\n setIndex,\n styles,\n } = useCarouselContext();\n return (\n <button\n {...props}\n ref={ref}\n aria-label={ariaLabel}\n className={cx(styles.control, className)}\n data-slot=\"carousel-next\"\n disabled={disabled ?? contextDisabled}\n onClick={() => setIndex(getNextIndex(1))}\n type=\"button\"\n >\n {children ?? (orientation === \"vertical\" ? \"↓\" : \"›\")}\n </button>\n );\n },\n);\n\nexport interface CarouselIndicatorProps extends ComponentPropsWithoutRef<\"button\"> {\n index: number;\n}\nexport const CarouselIndicator = forwardRef<HTMLButtonElement, CarouselIndicatorProps>(\n function CarouselIndicator({ \"aria-label\": ariaLabel, className, index, ...props }, ref) {\n const { currentIndex, disabled, setIndex, styles } = useCarouselContext();\n return (\n <button\n {...props}\n ref={ref}\n aria-label={ariaLabel ?? `Go to slide ${index + 1}`}\n aria-selected={currentIndex === index}\n className={cx(styles.indicator, className)}\n data-selected={currentIndex === index || undefined}\n data-slot=\"carousel-indicator\"\n disabled={disabled}\n onClick={() => setIndex(index)}\n role=\"tab\"\n type=\"button\"\n />\n );\n },\n);\n\nexport const CarouselIndicators = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<\"div\">>(\n function CarouselIndicators({ children, className, ...props }, ref) {\n const { indexCount, styles } = useCarouselContext();\n return (\n <div\n {...props}\n ref={ref}\n aria-label=\"Slides\"\n className={cx(styles.indicators, className)}\n data-slot=\"carousel-indicators\"\n role=\"tablist\"\n >\n {children ??\n Array.from({ length: indexCount }, (_, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: indicators are stable by slide index.\n <CarouselIndicator index={index} key={`indicator-${index}`} />\n ))}\n </div>\n );\n },\n);\n\nexport const Carousel = {\n Root: CarouselRoot,\n Viewport: CarouselViewport,\n Track: CarouselTrack,\n Item: CarouselItem,\n Media: CarouselMedia,\n Caption: CarouselCaption,\n Title: CarouselTitle,\n Description: CarouselDescription,\n Previous: CarouselPrevious,\n Next: CarouselNext,\n Indicators: CarouselIndicators,\n Indicator: CarouselIndicator,\n};\n"],"mappings":";;;;;;AA2CA,MAAM,mBAAA,GAAkBA,MAAAA,cAAAA,CAA2C,IAAI;AAEvE,SAAS,qBAAqB;CAC5B,MAAM,WAAA,GAAUC,MAAAA,WAAAA,CAAW,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,O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aAAU;EACA;EACV,eAAe,SAAS,KAAK;EAC7B,MAAK;EACL,MAAK;CACN,CAAA;AAEL,CACF;AAEA,MAAa,sBAAA,GAAqBN,MAAAA,WAAAA,CAChC,SAAS,mBAAmB,EAAE,UAAU,WAAW,GAAG,SAAS,KAAK;CAClE,MAAM,EAAE,YAAY,WAAW,mBAAmB;CAClD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,GAAI;EACC;EACL,cAAW;EACX,WAAWM,WAAAA,GAAG,OAAO,YAAY,SAAS;EAC1C,aAAU;EACV,MAAK;EAEJ,UAAA,YACC,MAAM,KAAK,EAAE,QAAQ,WAAW,IAAI,GAAG,UAErC,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAD,EAA0B,MAAmC,GAAvB,aAAa,OAAU,CAC9D;CACA,CAAA;AAET,CACF;AAEA,MAAa,WAAW;CACtB,MAAM;CACN,UAAU;CACV,OAAO;CACP,MAAM;CACN,OAAO;CACP,SAAS;CACT,OAAO;CACP,aAAa;CACb,UAAU;CACV,MAAM;CACN,YAAY;CACZ,WAAW;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.js","names":[],"sources":["../../../src/components/carousel/carousel.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n ComponentPropsWithoutRef,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n PointerEvent,\n ReactNode,\n Ref,\n} from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { carousel } from \"../../styled-system/recipes\";\n\nexport type CarouselOrientation = \"horizontal\" | \"vertical\";\n\ninterface CarouselContextValue {\n currentIndex: number;\n disabled: boolean;\n getNextIndex: (direction: -1 | 1) => number;\n indexCount: number;\n loop: boolean;\n onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n registerIndex: (index: number) => () => void;\n setIndex: (index: number) => void;\n startSwipe: (event: PointerEvent<HTMLElement>) => void;\n moveSwipe: (event: PointerEvent<HTMLElement>) => void;\n endSwipe: (event: PointerEvent<HTMLElement>) => void;\n orientation: CarouselOrientation;\n styles: ReturnType<typeof carousel>;\n}\n\nconst CarouselContext = createContext<CarouselContextValue | null>(null);\n\nfunction useCarouselContext() {\n const context = useContext(CarouselContext);\n if (!context) throw new Error(\"Carousel parts must be rendered inside Carousel.Root.\");\n return context;\n}\n\nexport interface CarouselRootProps extends ComponentPropsWithoutRef<\"section\"> {\n index?: number;\n defaultIndex?: number;\n onIndexChange?: (index: number) => void;\n orientation?: CarouselOrientation;\n loop?: boolean;\n swipeable?: boolean;\n autoplay?: boolean;\n autoplayInterval?: number;\n pauseOnHover?: boolean;\n pauseOnFocus?: boolean;\n disabled?: boolean;\n}\n\nexport const CarouselRoot = forwardRef<HTMLElement, CarouselRootProps>(function CarouselRoot(\n {\n autoplay = false,\n autoplayInterval = 5000,\n children,\n className,\n defaultIndex = 0,\n disabled = false,\n index,\n onBlur,\n onFocus,\n loop = true,\n onIndexChange,\n onKeyDown,\n onPointerEnter,\n onPointerLeave,\n orientation = \"horizontal\",\n pauseOnFocus = true,\n pauseOnHover = true,\n style,\n swipeable = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledIndex, setUncontrolledIndex] = useState(Math.max(0, defaultIndex));\n const [registered, setRegistered] = useState<Set<number>>(() => new Set());\n const [paused, setPaused] = useState(false);\n const [focusWithin, setFocusWithin] = useState(false);\n const swipeRef = useRef<{ pointerId: number; startX: number; startY: number } | null>(null);\n const isControlled = index !== undefined;\n const indexCount = registered.size ? Math.max(...registered) + 1 : 0;\n const currentIndex = Math.max(\n 0,\n Math.min(indexCount ? indexCount - 1 : 0, index ?? uncontrolledIndex),\n );\n const styles = carousel({ orientation, active: true });\n\n const setIndex = useCallback(\n (nextIndex: number) => {\n if (disabled || !indexCount) return;\n const next = loop\n ? (nextIndex + indexCount) % indexCount\n : Math.max(0, Math.min(indexCount - 1, nextIndex));\n if (!isControlled) setUncontrolledIndex(next);\n if (next !== currentIndex) onIndexChange?.(next);\n },\n [currentIndex, disabled, indexCount, isControlled, loop, onIndexChange],\n );\n\n const getNextIndex = useCallback((direction: -1 | 1) => currentIndex + direction, [currentIndex]);\n\n const registerIndex = useCallback((itemIndex: number) => {\n setRegistered((previous) => {\n if (previous.has(itemIndex)) return previous;\n const next = new Set(previous);\n next.add(itemIndex);\n return next;\n });\n return () =>\n setRegistered((previous) => {\n if (!previous.has(itemIndex)) return previous;\n const next = new Set(previous);\n next.delete(itemIndex);\n return next;\n });\n }, []);\n\n const onRootKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (disabled) return;\n const forward =\n orientation === \"horizontal\" ? event.key === \"ArrowRight\" : event.key === \"ArrowDown\";\n const backward =\n orientation === \"horizontal\" ? event.key === \"ArrowLeft\" : event.key === \"ArrowUp\";\n if (forward || backward) {\n event.preventDefault();\n setIndex(getNextIndex(forward ? 1 : -1));\n } else if (event.key === \"Home\") {\n event.preventDefault();\n setIndex(0);\n } else if (event.key === \"End\") {\n event.preventDefault();\n setIndex(indexCount - 1);\n }\n onKeyDown?.(event);\n },\n [disabled, getNextIndex, indexCount, onKeyDown, orientation, setIndex],\n );\n\n const startSwipe = useCallback(\n (event: PointerEvent<HTMLElement>) => {\n if (!swipeable || disabled || event.pointerType === \"mouse\") return;\n swipeRef.current = {\n pointerId: event.pointerId,\n startX: event.clientX,\n startY: event.clientY,\n };\n event.currentTarget.setPointerCapture?.(event.pointerId);\n },\n [disabled, swipeable],\n );\n\n const moveSwipe = useCallback(() => undefined, []);\n\n const endSwipe = useCallback(\n (event: PointerEvent<HTMLElement>) => {\n const start = swipeRef.current;\n swipeRef.current = null;\n if (!start || start.pointerId !== event.pointerId) return;\n const delta =\n orientation === \"horizontal\" ? event.clientX - start.startX : event.clientY - start.startY;\n if (Math.abs(delta) < 40) return;\n setIndex(getNextIndex(delta < 0 ? 1 : -1));\n },\n [getNextIndex, orientation, setIndex],\n );\n\n useEffect(() => {\n if (!autoplay || paused || disabled || indexCount < 2) return;\n const interval =\n Number.isFinite(autoplayInterval) && autoplayInterval > 0 ? autoplayInterval : 5000;\n const timer = window.setInterval(() => setIndex(getNextIndex(1)), interval);\n return () => window.clearInterval(timer);\n }, [autoplay, autoplayInterval, disabled, getNextIndex, indexCount, paused, setIndex]);\n\n const value = useMemo<CarouselContextValue>(\n () => ({\n currentIndex,\n disabled,\n endSwipe,\n getNextIndex,\n indexCount,\n loop,\n moveSwipe,\n onKeyDown: onRootKeyDown,\n orientation,\n registerIndex,\n setIndex,\n startSwipe,\n styles,\n }),\n [\n currentIndex,\n disabled,\n endSwipe,\n getNextIndex,\n indexCount,\n loop,\n moveSwipe,\n onRootKeyDown,\n orientation,\n registerIndex,\n setIndex,\n startSwipe,\n styles,\n ],\n );\n\n return (\n <CarouselContext.Provider value={value}>\n <section\n {...props}\n ref={ref}\n aria-roledescription=\"carousel\"\n className={cx(styles.root, className)}\n data-jaci-component=\"carousel\"\n data-orientation={orientation}\n data-slot=\"carousel\"\n data-state={paused ? \"paused\" : \"running\"}\n role=\"region\"\n tabIndex={disabled ? -1 : 0}\n onBlur={(event: FocusEvent<HTMLElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {\n setFocusWithin(false);\n if (pauseOnFocus) setPaused(false);\n }\n onBlur?.(event);\n }}\n onFocus={(event: FocusEvent<HTMLElement>) => {\n setFocusWithin(true);\n if (pauseOnFocus) {\n setPaused(true);\n }\n onFocus?.(event);\n }}\n onKeyDown={onRootKeyDown}\n onPointerCancel={endSwipe}\n onPointerDown={startSwipe}\n onPointerEnter={(event) => {\n if (pauseOnHover) setPaused(true);\n onPointerEnter?.(event);\n }}\n onPointerLeave={(event) => {\n if (pauseOnHover && !(pauseOnFocus && focusWithin)) setPaused(false);\n onPointerLeave?.(event);\n }}\n onPointerMove={moveSwipe}\n onPointerUp={endSwipe}\n style={{ \"--jaci-carousel-index\": currentIndex, ...style } as CSSProperties}\n >\n {children}\n </section>\n </CarouselContext.Provider>\n );\n});\n\nexport type CarouselViewportProps = ComponentPropsWithoutRef<\"div\">;\nexport const CarouselViewport = forwardRef<HTMLDivElement, CarouselViewportProps>(\n function CarouselViewport({ className, ...props }, ref) {\n const { styles } = useCarouselContext();\n return (\n <div\n {...props}\n ref={ref}\n className={cx(styles.viewport, className)}\n data-slot=\"carousel-viewport\"\n />\n );\n },\n);\n\nexport type CarouselTrackProps = ComponentPropsWithoutRef<\"div\">;\nexport const CarouselTrack = forwardRef<HTMLDivElement, CarouselTrackProps>(function CarouselTrack(\n { className, style, ...props },\n ref,\n) {\n const { currentIndex, orientation, styles } = useCarouselContext();\n const transform =\n orientation === \"horizontal\"\n ? `translateX(-${currentIndex * 100}%)`\n : `translateY(-${currentIndex * 100}%)`;\n return (\n <div\n {...props}\n ref={ref}\n className={cx(styles.track, className)}\n data-slot=\"carousel-track\"\n style={{ transform, ...style }}\n />\n );\n});\n\nexport interface CarouselItemProps extends ComponentPropsWithoutRef<\"div\"> {\n index: number;\n}\nexport const CarouselItem = forwardRef<HTMLDivElement, CarouselItemProps>(function CarouselItem(\n { children, className, index, ...props },\n ref,\n) {\n const { currentIndex, registerIndex, styles } = useCarouselContext();\n useEffect(() => registerIndex(index), [index, registerIndex]);\n const active = currentIndex === index;\n return (\n // biome-ignore lint/a11y/useSemanticElements: carousel slides use the ARIA group role.\n <div\n {...props}\n ref={ref}\n aria-hidden={!active}\n aria-roledescription=\"slide\"\n className={cx(styles.item, className)}\n data-index={index}\n data-jaci-component=\"carousel-item\"\n data-selected={active || undefined}\n data-slot=\"carousel-item\"\n role=\"group\"\n tabIndex={active ? 0 : -1}\n >\n {children}\n </div>\n );\n});\n\nfunction createSimpleSlot(slot: \"media\" | \"caption\" | \"title\" | \"description\") {\n return forwardRef<HTMLElement, ComponentPropsWithoutRef<\"div\">>(function CarouselSlot(\n { className, ...props },\n ref,\n ) {\n const { styles } = useCarouselContext();\n if (slot === \"title\")\n return (\n <h3\n {...props}\n ref={ref as Ref<HTMLHeadingElement>}\n className={cx(styles.title, className)}\n data-slot={`carousel-${slot}`}\n />\n );\n if (slot === \"description\")\n return (\n <p\n {...props}\n ref={ref as Ref<HTMLParagraphElement>}\n className={cx(styles.description, className)}\n data-slot={`carousel-${slot}`}\n />\n );\n return (\n <div\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(styles[slot], className)}\n data-slot={`carousel-${slot}`}\n />\n );\n });\n}\n\nexport const CarouselMedia = createSimpleSlot(\"media\");\nexport const CarouselCaption = createSimpleSlot(\"caption\");\nexport const CarouselTitle = createSimpleSlot(\"title\");\nexport const CarouselDescription = createSimpleSlot(\"description\");\n\nexport interface CarouselControlProps extends ComponentPropsWithoutRef<\"button\"> {\n children?: ReactNode;\n}\nexport const CarouselPrevious = forwardRef<HTMLButtonElement, CarouselControlProps>(\n function CarouselPrevious(\n { \"aria-label\": ariaLabel = \"Previous slide\", children, className, disabled, ...props },\n ref,\n ) {\n const {\n disabled: contextDisabled,\n getNextIndex,\n orientation,\n setIndex,\n styles,\n } = useCarouselContext();\n return (\n <button\n {...props}\n ref={ref}\n aria-label={ariaLabel}\n className={cx(styles.control, className)}\n data-slot=\"carousel-previous\"\n disabled={disabled ?? contextDisabled}\n onClick={() => setIndex(getNextIndex(-1))}\n type=\"button\"\n >\n {children ?? (orientation === \"vertical\" ? \"↑\" : \"‹\")}\n </button>\n );\n },\n);\n\nexport const CarouselNext = forwardRef<HTMLButtonElement, CarouselControlProps>(\n function CarouselNext(\n { \"aria-label\": ariaLabel = \"Next slide\", children, className, disabled, ...props },\n ref,\n ) {\n const {\n disabled: contextDisabled,\n getNextIndex,\n orientation,\n setIndex,\n styles,\n } = useCarouselContext();\n return (\n <button\n {...props}\n ref={ref}\n aria-label={ariaLabel}\n className={cx(styles.control, className)}\n data-slot=\"carousel-next\"\n disabled={disabled ?? contextDisabled}\n onClick={() => setIndex(getNextIndex(1))}\n type=\"button\"\n >\n {children ?? (orientation === \"vertical\" ? \"↓\" : \"›\")}\n </button>\n );\n },\n);\n\nexport interface CarouselIndicatorProps extends ComponentPropsWithoutRef<\"button\"> {\n index: number;\n}\nexport const CarouselIndicator = forwardRef<HTMLButtonElement, CarouselIndicatorProps>(\n function CarouselIndicator({ \"aria-label\": ariaLabel, className, index, ...props }, ref) {\n const { currentIndex, disabled, setIndex, styles } = useCarouselContext();\n return (\n <button\n {...props}\n ref={ref}\n aria-label={ariaLabel ?? `Go to slide ${index + 1}`}\n aria-selected={currentIndex === index}\n className={cx(styles.indicator, className)}\n data-selected={currentIndex === index || undefined}\n data-slot=\"carousel-indicator\"\n disabled={disabled}\n onClick={() => setIndex(index)}\n role=\"tab\"\n type=\"button\"\n />\n );\n },\n);\n\nexport const CarouselIndicators = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<\"div\">>(\n function CarouselIndicators({ children, className, ...props }, ref) {\n const { indexCount, styles } = useCarouselContext();\n return (\n <div\n {...props}\n ref={ref}\n aria-label=\"Slides\"\n className={cx(styles.indicators, className)}\n data-slot=\"carousel-indicators\"\n role=\"tablist\"\n >\n {children ??\n Array.from({ length: indexCount }, (_, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: indicators are stable by slide index.\n <CarouselIndicator index={index} key={`indicator-${index}`} />\n ))}\n </div>\n );\n },\n);\n\nexport const Carousel = {\n Root: CarouselRoot,\n Viewport: CarouselViewport,\n Track: CarouselTrack,\n Item: CarouselItem,\n Media: CarouselMedia,\n Caption: CarouselCaption,\n Title: CarouselTitle,\n Description: CarouselDescription,\n Previous: CarouselPrevious,\n Next: CarouselNext,\n Indicators: CarouselIndicators,\n Indicator: CarouselIndicator,\n};\n"],"mappings":";;;;;;AA2CA,MAAM,kBAAkB,cAA2C,IAAI;AAEvE,SAAS,qBAAqB;CAC5B,MAAM,UAAU,WAAW,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAgBA,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AAA;AAEZ,CACF;AAKA,MAAa,oBAAoB,WAC/B,SAAS,kBAAkB,EAAE,cAAc,WAAW,WAAW,OAAO,GAAG,SAAS,KAAK;CACvF,MAAM,EAAE,cAAc,UAAU,UAAU,WAAW,mBAAmB;CACxE,OACE,oBAAC,UAAD;EACE,GAAI;EACC;EACL,cAAY,aAAa,eAAe,QAAQ;EAChD,iBAAe,iBAAiB;EAChC,WAAW,GAAG,OAAO,WAAW,SAAS;EACzC,iBAAe,iBAAiB,SAAS,KAAA;EACzC,aAAU;EACA;EACV,eAAe,SAAS,KAAK;EAC7B,MAAK;EACL,MAAK;CACN,CAAA;AAEL,CACF;AAEA,MAAa,qBAAqB,WAChC,SAAS,mBAAmB,EAAE,UAAU,WAAW,GAAG,SAAS,KAAK;CAClE,MAAM,EAAE,YAAY,WAAW,mBAAmB;CAClD,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,cAAW;EACX,WAAW,GAAG,OAAO,YAAY,SAAS;EAC1C,aAAU;EACV,MAAK;YAEJ,YACC,MAAM,KAAK,EAAE,QAAQ,WAAW,IAAI,GAAG,UAErC,oBAAC,mBAAD,EAA0B,MAAmC,GAAvB,aAAa,OAAU,CAC9D;CACA,CAAA;AAET,CACF;AAEA,MAAa,WAAW;CACtB,MAAM;CACN,UAAU;CACV,OAAO;CACP,MAAM;CACN,OAAO;CACP,SAAS;CACT,OAAO;CACP,aAAa;CACb,UAAU;CACV,MAAM;CACN,YAAY;CACZ,WAAW;AACb"}
|
|
1
|
+
{"version":3,"file":"carousel.js","names":[],"sources":["../../../src/components/carousel/carousel.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n ComponentPropsWithoutRef,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n PointerEvent,\n ReactNode,\n Ref,\n} from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { carousel } from \"../../styled-system/recipes\";\n\nexport type CarouselOrientation = \"horizontal\" | \"vertical\";\n\ninterface CarouselContextValue {\n currentIndex: number;\n disabled: boolean;\n getNextIndex: (direction: -1 | 1) => number;\n indexCount: number;\n loop: boolean;\n onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n registerIndex: (index: number) => () => void;\n setIndex: (index: number) => void;\n startSwipe: (event: PointerEvent<HTMLElement>) => void;\n moveSwipe: (event: PointerEvent<HTMLElement>) => void;\n endSwipe: (event: PointerEvent<HTMLElement>) => void;\n orientation: CarouselOrientation;\n styles: ReturnType<typeof carousel>;\n}\n\nconst CarouselContext = createContext<CarouselContextValue | null>(null);\n\nfunction useCarouselContext() {\n const context = useContext(CarouselContext);\n if (!context) throw new Error(\"Carousel parts must be rendered inside Carousel.Root.\");\n return context;\n}\n\nexport interface CarouselRootProps extends ComponentPropsWithoutRef<\"section\"> {\n index?: number;\n defaultIndex?: number;\n onIndexChange?: (index: number) => void;\n orientation?: CarouselOrientation;\n loop?: boolean;\n swipeable?: boolean;\n autoplay?: boolean;\n autoplayInterval?: number;\n pauseOnHover?: boolean;\n pauseOnFocus?: boolean;\n disabled?: boolean;\n}\n\nexport const CarouselRoot = forwardRef<HTMLElement, CarouselRootProps>(function CarouselRoot(\n {\n autoplay = false,\n autoplayInterval = 5000,\n children,\n className,\n defaultIndex = 0,\n disabled = false,\n index,\n onBlur,\n onFocus,\n loop = true,\n onIndexChange,\n onKeyDown,\n onPointerEnter,\n onPointerLeave,\n orientation = \"horizontal\",\n pauseOnFocus = true,\n pauseOnHover = true,\n style,\n swipeable = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledIndex, setUncontrolledIndex] = useState(Math.max(0, defaultIndex));\n const [registered, setRegistered] = useState<Set<number>>(() => new Set());\n const [paused, setPaused] = useState(false);\n const [focusWithin, setFocusWithin] = useState(false);\n const swipeRef = useRef<{ pointerId: number; startX: number; startY: number } | null>(null);\n const isControlled = index !== undefined;\n const indexCount = registered.size ? Math.max(...registered) + 1 : 0;\n const currentIndex = Math.max(\n 0,\n Math.min(indexCount ? indexCount - 1 : 0, index ?? uncontrolledIndex),\n );\n const styles = carousel({ orientation, active: true });\n\n const setIndex = useCallback(\n (nextIndex: number) => {\n if (disabled || !indexCount) return;\n const next = loop\n ? (nextIndex + indexCount) % indexCount\n : Math.max(0, Math.min(indexCount - 1, nextIndex));\n if (!isControlled) setUncontrolledIndex(next);\n if (next !== currentIndex) onIndexChange?.(next);\n },\n [currentIndex, disabled, indexCount, isControlled, loop, onIndexChange],\n );\n\n const getNextIndex = useCallback((direction: -1 | 1) => currentIndex + direction, [currentIndex]);\n\n const registerIndex = useCallback((itemIndex: number) => {\n setRegistered((previous) => {\n if (previous.has(itemIndex)) return previous;\n const next = new Set(previous);\n next.add(itemIndex);\n return next;\n });\n return () =>\n setRegistered((previous) => {\n if (!previous.has(itemIndex)) return previous;\n const next = new Set(previous);\n next.delete(itemIndex);\n return next;\n });\n }, []);\n\n const onRootKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (disabled) return;\n const forward =\n orientation === \"horizontal\" ? event.key === \"ArrowRight\" : event.key === \"ArrowDown\";\n const backward =\n orientation === \"horizontal\" ? event.key === \"ArrowLeft\" : event.key === \"ArrowUp\";\n if (forward || backward) {\n event.preventDefault();\n setIndex(getNextIndex(forward ? 1 : -1));\n } else if (event.key === \"Home\") {\n event.preventDefault();\n setIndex(0);\n } else if (event.key === \"End\") {\n event.preventDefault();\n setIndex(indexCount - 1);\n }\n onKeyDown?.(event);\n },\n [disabled, getNextIndex, indexCount, onKeyDown, orientation, setIndex],\n );\n\n const startSwipe = useCallback(\n (event: PointerEvent<HTMLElement>) => {\n if (!swipeable || disabled || event.pointerType === \"mouse\") return;\n swipeRef.current = {\n pointerId: event.pointerId,\n startX: event.clientX,\n startY: event.clientY,\n };\n event.currentTarget.setPointerCapture?.(event.pointerId);\n },\n [disabled, swipeable],\n );\n\n const moveSwipe = useCallback(() => undefined, []);\n\n const endSwipe = useCallback(\n (event: PointerEvent<HTMLElement>) => {\n const start = swipeRef.current;\n swipeRef.current = null;\n if (!start || start.pointerId !== event.pointerId) return;\n const delta =\n orientation === \"horizontal\" ? event.clientX - start.startX : event.clientY - start.startY;\n if (Math.abs(delta) < 40) return;\n setIndex(getNextIndex(delta < 0 ? 1 : -1));\n },\n [getNextIndex, orientation, setIndex],\n );\n\n useEffect(() => {\n if (!autoplay || paused || disabled || indexCount < 2) return;\n const interval =\n Number.isFinite(autoplayInterval) && autoplayInterval > 0 ? autoplayInterval : 5000;\n const timer = window.setInterval(() => setIndex(getNextIndex(1)), interval);\n return () => window.clearInterval(timer);\n }, [autoplay, autoplayInterval, disabled, getNextIndex, indexCount, paused, setIndex]);\n\n const value = useMemo<CarouselContextValue>(\n () => ({\n currentIndex,\n disabled,\n endSwipe,\n getNextIndex,\n indexCount,\n loop,\n moveSwipe,\n onKeyDown: onRootKeyDown,\n orientation,\n registerIndex,\n setIndex,\n startSwipe,\n styles,\n }),\n [\n currentIndex,\n disabled,\n endSwipe,\n getNextIndex,\n indexCount,\n loop,\n moveSwipe,\n onRootKeyDown,\n orientation,\n registerIndex,\n setIndex,\n startSwipe,\n styles,\n ],\n );\n\n return (\n <CarouselContext.Provider value={value}>\n <section\n {...props}\n ref={ref}\n aria-roledescription=\"carousel\"\n className={cx(styles.root, className)}\n data-jaci-component=\"carousel\"\n data-orientation={orientation}\n data-slot=\"carousel\"\n data-state={paused ? \"paused\" : \"running\"}\n role=\"region\"\n tabIndex={disabled ? -1 : 0}\n onBlur={(event: FocusEvent<HTMLElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {\n setFocusWithin(false);\n if (pauseOnFocus) setPaused(false);\n }\n onBlur?.(event);\n }}\n onFocus={(event: FocusEvent<HTMLElement>) => {\n setFocusWithin(true);\n if (pauseOnFocus) {\n setPaused(true);\n }\n onFocus?.(event);\n }}\n onKeyDown={onRootKeyDown}\n onPointerCancel={endSwipe}\n onPointerDown={startSwipe}\n onPointerEnter={(event) => {\n if (pauseOnHover) setPaused(true);\n onPointerEnter?.(event);\n }}\n onPointerLeave={(event) => {\n if (pauseOnHover && !(pauseOnFocus && focusWithin)) setPaused(false);\n onPointerLeave?.(event);\n }}\n onPointerMove={moveSwipe}\n onPointerUp={endSwipe}\n style={{ \"--jaci-carousel-index\": currentIndex, ...style } as CSSProperties}\n >\n {children}\n </section>\n </CarouselContext.Provider>\n );\n});\n\nexport type CarouselViewportProps = ComponentPropsWithoutRef<\"div\">;\nexport const CarouselViewport = forwardRef<HTMLDivElement, CarouselViewportProps>(\n function CarouselViewport({ className, ...props }, ref) {\n const { styles } = useCarouselContext();\n return (\n <div\n {...props}\n ref={ref}\n className={cx(styles.viewport, className)}\n data-slot=\"carousel-viewport\"\n />\n );\n },\n);\n\nexport type CarouselTrackProps = ComponentPropsWithoutRef<\"div\">;\nexport const CarouselTrack = forwardRef<HTMLDivElement, CarouselTrackProps>(function CarouselTrack(\n { className, style, ...props },\n ref,\n) {\n const { currentIndex, orientation, styles } = useCarouselContext();\n const transform =\n orientation === \"horizontal\"\n ? `translateX(-${currentIndex * 100}%)`\n : `translateY(-${currentIndex * 100}%)`;\n return (\n <div\n {...props}\n ref={ref}\n className={cx(styles.track, className)}\n data-slot=\"carousel-track\"\n style={{ transform, ...style }}\n />\n );\n});\n\nexport interface CarouselItemProps extends ComponentPropsWithoutRef<\"div\"> {\n index: number;\n}\nexport const CarouselItem = forwardRef<HTMLDivElement, CarouselItemProps>(function CarouselItem(\n { children, className, index, ...props },\n ref,\n) {\n const { currentIndex, registerIndex, styles } = useCarouselContext();\n useEffect(() => registerIndex(index), [index, registerIndex]);\n const active = currentIndex === index;\n return (\n // biome-ignore lint/a11y/useSemanticElements: carousel slides use the ARIA group role.\n <div\n {...props}\n ref={ref}\n aria-hidden={!active}\n aria-roledescription=\"slide\"\n className={cx(styles.item, className)}\n data-index={index}\n data-jaci-component=\"carousel-item\"\n data-selected={active || undefined}\n data-slot=\"carousel-item\"\n role=\"group\"\n tabIndex={active ? 0 : -1}\n >\n {children}\n </div>\n );\n});\n\nfunction createSimpleSlot(slot: \"media\" | \"caption\" | \"title\" | \"description\") {\n return forwardRef<HTMLElement, ComponentPropsWithoutRef<\"div\">>(function CarouselSlot(\n { className, ...props },\n ref,\n ) {\n const { styles } = useCarouselContext();\n if (slot === \"title\")\n return (\n <h3\n {...props}\n ref={ref as Ref<HTMLHeadingElement>}\n className={cx(styles.title, className)}\n data-slot={`carousel-${slot}`}\n />\n );\n if (slot === \"description\")\n return (\n <p\n {...props}\n ref={ref as Ref<HTMLParagraphElement>}\n className={cx(styles.description, className)}\n data-slot={`carousel-${slot}`}\n />\n );\n return (\n <div\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(styles[slot], className)}\n data-slot={`carousel-${slot}`}\n />\n );\n });\n}\n\nexport const CarouselMedia = createSimpleSlot(\"media\");\nexport const CarouselCaption = createSimpleSlot(\"caption\");\nexport const CarouselTitle = createSimpleSlot(\"title\");\nexport const CarouselDescription = createSimpleSlot(\"description\");\n\nexport interface CarouselControlProps extends ComponentPropsWithoutRef<\"button\"> {\n children?: ReactNode;\n}\nexport const CarouselPrevious = forwardRef<HTMLButtonElement, CarouselControlProps>(\n function CarouselPrevious(\n { \"aria-label\": ariaLabel = \"Previous slide\", children, className, disabled, ...props },\n ref,\n ) {\n const {\n disabled: contextDisabled,\n getNextIndex,\n orientation,\n setIndex,\n styles,\n } = useCarouselContext();\n return (\n <button\n {...props}\n ref={ref}\n aria-label={ariaLabel}\n className={cx(styles.control, className)}\n data-slot=\"carousel-previous\"\n disabled={disabled ?? contextDisabled}\n onClick={() => setIndex(getNextIndex(-1))}\n type=\"button\"\n >\n {children ?? (orientation === \"vertical\" ? \"↑\" : \"‹\")}\n </button>\n );\n },\n);\n\nexport const CarouselNext = forwardRef<HTMLButtonElement, CarouselControlProps>(\n function CarouselNext(\n { \"aria-label\": ariaLabel = \"Next slide\", children, className, disabled, ...props },\n ref,\n ) {\n const {\n disabled: contextDisabled,\n getNextIndex,\n orientation,\n setIndex,\n styles,\n } = useCarouselContext();\n return (\n <button\n {...props}\n ref={ref}\n aria-label={ariaLabel}\n className={cx(styles.control, className)}\n data-slot=\"carousel-next\"\n disabled={disabled ?? contextDisabled}\n onClick={() => setIndex(getNextIndex(1))}\n type=\"button\"\n >\n {children ?? (orientation === \"vertical\" ? \"↓\" : \"›\")}\n </button>\n );\n },\n);\n\nexport interface CarouselIndicatorProps extends ComponentPropsWithoutRef<\"button\"> {\n index: number;\n}\nexport const CarouselIndicator = forwardRef<HTMLButtonElement, CarouselIndicatorProps>(\n function CarouselIndicator({ \"aria-label\": ariaLabel, className, index, ...props }, ref) {\n const { currentIndex, disabled, setIndex, styles } = useCarouselContext();\n return (\n <button\n {...props}\n ref={ref}\n aria-label={ariaLabel ?? `Go to slide ${index + 1}`}\n aria-selected={currentIndex === index}\n className={cx(styles.indicator, className)}\n data-selected={currentIndex === index || undefined}\n data-slot=\"carousel-indicator\"\n disabled={disabled}\n onClick={() => setIndex(index)}\n role=\"tab\"\n type=\"button\"\n />\n );\n },\n);\n\nexport const CarouselIndicators = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<\"div\">>(\n function CarouselIndicators({ children, className, ...props }, ref) {\n const { indexCount, styles } = useCarouselContext();\n return (\n <div\n {...props}\n ref={ref}\n aria-label=\"Slides\"\n className={cx(styles.indicators, className)}\n data-slot=\"carousel-indicators\"\n role=\"tablist\"\n >\n {children ??\n Array.from({ length: indexCount }, (_, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: indicators are stable by slide index.\n <CarouselIndicator index={index} key={`indicator-${index}`} />\n ))}\n </div>\n );\n },\n);\n\nexport const Carousel = {\n Root: CarouselRoot,\n Viewport: CarouselViewport,\n Track: CarouselTrack,\n Item: CarouselItem,\n Media: CarouselMedia,\n Caption: CarouselCaption,\n Title: CarouselTitle,\n Description: CarouselDescription,\n Previous: CarouselPrevious,\n Next: CarouselNext,\n Indicators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|
|
10
10
|
let _base_ui_react_field = require("@base-ui/react/field");
|
|
11
11
|
//#region src/components/checkbox-group/checkbox-group.tsx
|
|
12
12
|
function CheckboxGroupRoot({ children, className, errors, invalid, name, onValueChange, ...props }) {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const styles = require_checkbox_group.checkboxGroup();
|
|
14
|
+
const fieldProps = {
|
|
15
|
+
className: require_cx.cx(styles.root, className),
|
|
15
16
|
...errors === void 0 ? {} : { errors },
|
|
16
17
|
...invalid === void 0 ? {} : { invalid },
|
|
17
|
-
...name === void 0 ? {} : { name }
|
|
18
|
+
...name === void 0 ? {} : { name }
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_field.Field, {
|
|
21
|
+
...fieldProps,
|
|
18
22
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_checkbox_group.CheckboxGroup, {
|
|
19
23
|
...props,
|
|
20
24
|
onValueChange: (value) => onValueChange?.(value),
|