@spark-ui/components 10.2.3 → 10.2.5
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 +14 -0
- package/dist/carousel/index.js +7 -0
- package/dist/carousel/index.js.map +1 -1
- package/dist/carousel/index.mjs +7 -0
- package/dist/carousel/index.mjs.map +1 -1
- package/dist/{chunk-TUFNIIZE.mjs → chunk-LHZ2JOXC.mjs} +2 -1
- package/dist/{chunk-TUFNIIZE.mjs.map → chunk-LHZ2JOXC.mjs.map} +1 -1
- package/dist/combobox/index.d.mts +1 -1
- package/dist/combobox/index.d.ts +1 -1
- package/dist/combobox/index.js +9 -2
- package/dist/combobox/index.js.map +1 -1
- package/dist/combobox/index.mjs +9 -2
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/input/index.js +1 -0
- package/dist/input/index.js.map +1 -1
- package/dist/input/index.mjs +1 -1
- package/dist/stepper/index.js +1 -0
- package/dist/stepper/index.js.map +1 -1
- package/dist/stepper/index.mjs +1 -1
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/textarea/index.js +1 -0
- package/dist/textarea/index.js.map +1 -1
- package/dist/textarea/index.mjs +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/carousel/Carousel.tsx","../../src/carousel/useCarousel.ts","../../src/carousel/useEvent.ts","../../src/carousel/useIsMounted.ts","../../src/carousel/useScrollEnd.ts","../../src/carousel/useSnapPoints.ts","../../src/carousel/useResizeObserver.ts","../../src/carousel/utils.ts","../../src/carousel/CarouselControls.tsx","../../src/carousel/CarouselNextButton.tsx","../../src/carousel/CarouselPageIndicator.tsx","../../src/carousel/CarouselPagePicker.tsx","../../src/carousel/CarouselPrevButton.tsx","../../src/carousel/CarouselSlide.tsx","../../src/carousel/useIsVisible.ts","../../src/carousel/CarouselSlides.tsx","../../src/carousel/CarouselViewport.tsx","../../src/carousel/index.ts"],"sourcesContent":["import { cx } from 'class-variance-authority'\nimport { createContext, ReactNode, useContext } from 'react'\n\nimport { CarouselAPI, UseCarouselProps } from './types'\nimport { useCarousel } from './useCarousel'\n\ninterface Props extends UseCarouselProps {\n children?: ReactNode\n className?: string\n}\n\nconst CarouselContext = createContext<CarouselAPI | null>(null)\n\nexport const Carousel = ({\n className,\n snapType = 'mandatory',\n snapStop = 'always',\n scrollBehavior = 'smooth',\n slidesPerMove = 'auto',\n slidesPerPage = 1,\n loop = false,\n children,\n gap = 16,\n defaultPage,\n page,\n onPageChange,\n}: Props) => {\n const carouselApi = useCarousel({\n defaultPage,\n slidesPerPage,\n slidesPerMove,\n loop,\n gap,\n scrollBehavior,\n snapStop,\n snapType,\n page,\n onPageChange,\n })\n\n return (\n <CarouselContext.Provider\n value={{\n ...carouselApi,\n scrollBehavior,\n }}\n >\n <div\n className={cx('gap-lg relative box-border flex flex-col', className)}\n {...carouselApi.getRootProps()}\n >\n {children}\n </div>\n </CarouselContext.Provider>\n )\n}\n\nCarousel.displayName = 'Carousel'\n\nexport const useCarouselContext = () => {\n const context = useContext(CarouselContext)\n\n if (!context) {\n throw Error('useCarouselContext must be used within a Carousel provider')\n }\n\n return context\n}\n","/* eslint-disable max-lines-per-function */\nimport {\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n KeyboardEvent,\n} from 'react'\n\nimport {\n CarouselAPI,\n ComputedControlProps,\n ComputedIndicatorGroupProps,\n ComputedIndicatorProps,\n ComputedRootProps,\n ComputedSlideGroupProps,\n ComputedSlideProps,\n ComputedTriggerProps,\n UseCarouselProps,\n} from './types'\nimport { useEvent } from './useEvent'\nimport { useIsMounted } from './useIsMounted'\nimport { useScrollEnd } from './useScrollEnd'\nimport { useSnapPoints } from './useSnapPoints'\nimport { getSnapPositions, isSnapPoint } from './utils'\n\nconst DATA_SCOPE = 'carousel' as const\nconst DIRECTION = 'ltr' as const\n\nexport const useCarousel = ({\n defaultPage,\n gap = 16,\n snapType = 'mandatory',\n snapStop = 'always',\n scrollPadding = 0,\n slidesPerPage = 1,\n slidesPerMove = 'auto',\n scrollBehavior = 'smooth',\n loop = false,\n // state control\n page: controlledPage,\n onPageChange: onPageChangeProp,\n}: UseCarouselProps): CarouselAPI => {\n const carouselId = useId()\n const [pageState, setPageState] = useState(defaultPage || controlledPage || 0)\n\n const carouselRef = useRef<HTMLDivElement>(null)\n const pageIndicatorsRefs = useRef<(HTMLElement | null)[]>([])\n const isMountedRef = useIsMounted()\n const isMounted = isMountedRef.current\n const onPageChange = useEvent(onPageChangeProp)\n\n const [pageSnapPoints] = useSnapPoints([], {\n carouselRef,\n slidesPerMove,\n slidesPerPage,\n })\n\n const canScrollPrev = useRef(loop || pageState > 0)\n const canScrollNext = useRef(loop || pageState < pageSnapPoints.length - 1)\n canScrollPrev.current = loop || pageState > 0\n canScrollNext.current = loop || pageState < pageSnapPoints.length - 1\n\n const handlePageChange = useCallback(\n (page: number) => {\n if (page !== pageState) {\n setPageState(page)\n onPageChange?.(page)\n }\n },\n [onPageChange, pageState]\n )\n\n const scrollTo = useCallback(\n (page: number, behavior: 'instant' | 'smooth') => {\n if (carouselRef.current) {\n carouselRef.current.scrollTo({\n left: pageSnapPoints[page],\n behavior: behavior === 'instant' ? 'auto' : 'smooth',\n })\n handlePageChange(page)\n }\n },\n [handlePageChange, pageSnapPoints]\n )\n\n const scrollPrev = useCallback(\n (cb?: (pageIndex: number) => void) => {\n if (canScrollPrev) {\n const targetPage =\n loop && pageState === 0 ? pageSnapPoints.length - 1 : Math.max(pageState - 1, 0)\n\n scrollTo(targetPage, scrollBehavior)\n cb?.(targetPage)\n }\n },\n [loop, pageSnapPoints, pageState, scrollBehavior, scrollTo]\n )\n\n const scrollNext = useCallback(\n (cb?: (pageIndex: number) => void) => {\n if (canScrollNext) {\n const targetPage =\n loop && pageState === pageSnapPoints.length - 1\n ? 0\n : Math.min(pageState + 1, pageSnapPoints.length - 1)\n\n scrollTo(targetPage, scrollBehavior)\n cb?.(targetPage)\n }\n },\n [loop, pageSnapPoints, pageState, scrollBehavior, scrollTo]\n )\n\n useEffect(() => {\n if (controlledPage != null) {\n scrollTo(controlledPage, scrollBehavior)\n }\n }, [controlledPage, scrollBehavior, scrollTo])\n\n /**\n * Set the default scroll position of the carousel based on `defaultPage`.\n * As this operation is done before the snap points are set in the state, we have to get them from the ref directly.\n */\n useLayoutEffect(() => {\n if (defaultPage != null && !isMounted && carouselRef.current) {\n const snapPositions = getSnapPositions({\n container: carouselRef.current,\n slidesPerMove,\n slidesPerPage,\n })\n\n carouselRef.current.scrollTo({\n left: snapPositions[defaultPage],\n behavior: 'instant',\n })\n }\n }, [defaultPage, isMounted, slidesPerMove, slidesPerPage])\n\n /**\n * Monitoring scrollend events inside the scrollable area to sync the carousel active page with current scroll position.\n * Scrollend has been chosen over \"scroll\" for performance reason.\n */\n const syncPageStateWithScrollPosition = useCallback(() => {\n if (!carouselRef.current || pageSnapPoints.length === 0) return\n\n const { scrollLeft } = carouselRef.current\n\n const distances = pageSnapPoints.map(pagePosition => Math.abs(scrollLeft - pagePosition))\n const pageInViewport = distances.indexOf(Math.min(...distances))\n\n if (pageInViewport !== -1) {\n handlePageChange(pageInViewport)\n }\n }, [pageSnapPoints, handlePageChange])\n\n useScrollEnd(carouselRef, syncPageStateWithScrollPosition)\n\n const contextValue: CarouselAPI = {\n ref: carouselRef,\n pageIndicatorsRefs,\n // props\n gap,\n snapType,\n snapStop,\n scrollPadding,\n slidesPerPage,\n slidesPerMove,\n scrollBehavior,\n loop,\n // computed state\n page: pageState,\n pageSnapPoints,\n canScrollNext: canScrollNext.current,\n canScrollPrev: canScrollPrev.current,\n scrollTo,\n scrollPrev,\n scrollNext,\n // anatomy\n getRootProps: (): ComputedRootProps => ({\n id: `carousel::${carouselId}:`,\n role: 'region',\n 'aria-roledescription': 'carousel',\n 'data-scope': DATA_SCOPE,\n 'data-part': 'root',\n 'data-orientation': 'horizontal',\n dir: DIRECTION,\n style: {\n '--slides-per-page': slidesPerPage,\n '--slide-spacing': `${gap}px`,\n '--slide-item-size':\n 'calc(100% / var(--slides-per-page) - var(--slide-spacing) * (var(--slides-per-page) - 1) / var(--slides-per-page))',\n },\n }),\n\n getControlProps: (): ComputedControlProps => ({\n 'data-scope': DATA_SCOPE,\n 'data-part': 'control',\n 'data-orientation': 'horizontal',\n }),\n\n getPrevTriggerProps: (): ComputedTriggerProps<'prev-trigger'> => ({\n id: `carousel::${carouselId}::prev-trigger`,\n 'aria-controls': `carousel::${carouselId}::item-group`,\n 'data-scope': DATA_SCOPE,\n 'data-part': 'prev-trigger',\n 'data-orientation': 'horizontal',\n type: 'button',\n dir: DIRECTION,\n disabled: !canScrollPrev.current,\n onClick: () => scrollPrev(),\n }),\n\n getNextTriggerProps: (): ComputedTriggerProps<'next-trigger'> => ({\n id: `carousel::${carouselId}::next-trigger`,\n 'aria-controls': `carousel::${carouselId}::item-group`,\n 'data-scope': DATA_SCOPE,\n 'data-part': 'next-trigger',\n 'data-orientation': 'horizontal',\n type: 'button',\n dir: DIRECTION,\n disabled: !canScrollNext.current,\n onClick: () => scrollNext(),\n }),\n\n getSlidesContainerProps: (): ComputedSlideGroupProps => ({\n id: `carousel::${carouselId}::item-group`,\n 'aria-live': slidesPerPage > 1 ? 'off' : 'polite',\n 'data-scope': DATA_SCOPE,\n 'data-part': 'item-group',\n 'data-orientation': 'horizontal',\n dir: DIRECTION,\n tabIndex: 0,\n style: {\n display: 'grid',\n gap: 'var(--slide-spacing)',\n scrollSnapType: `x ${snapType}`,\n gridAutoFlow: 'column',\n scrollbarWidth: 'none',\n overscrollBehavior: 'contain',\n gridAutoColumns: 'var(--slide-item-size)',\n overflowX: 'auto',\n },\n ref: carouselRef,\n }),\n\n getSlideProps: ({ index }): ComputedSlideProps => {\n const isStopPoint = isSnapPoint(index, {\n container: carouselRef.current,\n slidesPerMove,\n slidesPerPage,\n })\n\n return {\n id: `carousel::${carouselId}::item:${index}`,\n role: 'group',\n 'aria-roledescription': 'slide',\n 'data-scope': DATA_SCOPE,\n 'data-part': 'item',\n 'data-index': index,\n 'data-orientation': 'horizontal',\n dir: DIRECTION,\n style: {\n ...(isStopPoint && {\n scrollSnapAlign: 'start',\n scrollSnapStop: snapStop,\n }),\n },\n }\n },\n\n getIndicatorGroupProps: (): ComputedIndicatorGroupProps => ({\n role: 'radiogroup',\n id: `carousel::${carouselId}::indicator-group`,\n 'data-scope': DATA_SCOPE,\n 'data-part': 'indicator-group',\n 'data-orientation': 'horizontal',\n dir: DIRECTION,\n }),\n\n getIndicatorProps: ({ index }): ComputedIndicatorProps => {\n const isActivePage = index === pageState\n\n return {\n role: 'radio',\n id: `carousel::${carouselId}::indicator:${index}`,\n 'aria-checked': isActivePage,\n 'data-scope': DATA_SCOPE,\n 'data-part': 'indicator',\n 'data-orientation': 'horizontal',\n 'data-index': index,\n 'data-state': isActivePage ? 'active' : 'inactive',\n tabIndex: isActivePage ? 0 : -1,\n onClick: () => {\n scrollTo(index, scrollBehavior)\n },\n onKeyDown: (event: KeyboardEvent) => {\n const focusActiveIndicator = (page: number) => {\n pageIndicatorsRefs.current[page]?.focus()\n }\n\n if (event.key === 'ArrowRight' && canScrollNext) {\n scrollNext(focusActiveIndicator)\n } else if (event.key === 'ArrowLeft' && canScrollPrev) {\n scrollPrev(focusActiveIndicator)\n }\n },\n }\n },\n }\n\n return contextValue\n}\n","import { useCallback, useLayoutEffect, useRef } from 'react'\n\ntype AnyFunction = (...args: any[]) => any\n\n/**\n * Directly from this gist: https://gist.github.com/diegohaz/695097a06f038a707c3a1b11e4e40195\n * Until React releases a native `useEvent` hook.\n */\nexport function useEvent<T extends AnyFunction>(callback?: T) {\n const ref = useRef<AnyFunction | undefined>(() => {\n throw new Error('Cannot call an event handler while rendering.')\n })\n\n useLayoutEffect(() => {\n ref.current = callback\n })\n\n return useCallback<AnyFunction>((...args) => ref.current?.(...args), []) as T\n}\n","import { useEffect, useRef } from 'react'\n\nexport const useIsMounted = () => {\n const isMounted = useRef(false)\n\n useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n return isMounted\n}\n","import { useEffect, useRef, RefObject } from 'react'\n\nexport function useScrollEnd(scrollRef: RefObject<HTMLDivElement | null>, callback: () => void) {\n const scrollLeft = useRef(0)\n\n /**\n * Safari (and some smaller browsers) to not yet support the `scrollend` event.\n * For those we must rely on the `scroll` event and and an idle state delay to trigger the \"scroll end\".\n *\n * Caveats:\n * - when using a trackpad or your fingers on a touch device, scrolling then holding the position might trigger the \"scrollend\" callback too early.\n */\n const safariTimeout = useRef<NodeJS.Timeout | null>(null)\n\n useEffect(() => {\n const element = scrollRef.current\n if (!element) return\n\n const supportsScrollend = 'onscrollend' in window\n\n const handleScrollEnd = () => {\n callback()\n }\n\n const handleSafariScroll = () => {\n if (safariTimeout.current) {\n clearTimeout(safariTimeout.current)\n }\n\n if (scrollRef.current) {\n scrollLeft.current = scrollRef.current.scrollLeft\n\n safariTimeout.current = setTimeout(() => {\n if (scrollRef.current) {\n handleScrollEnd()\n }\n }, 150)\n }\n }\n\n if (supportsScrollend) {\n element.addEventListener('scrollend', handleScrollEnd)\n } else {\n element.addEventListener('scroll', handleSafariScroll)\n }\n\n return () => {\n if (safariTimeout.current) {\n clearTimeout(safariTimeout.current)\n }\n\n if (supportsScrollend) {\n element.removeEventListener('scrollend', handleScrollEnd)\n } else {\n element.removeEventListener('scroll', handleSafariScroll)\n }\n }\n }, [callback, scrollRef])\n}\n\nexport default useScrollEnd\n","import { useMemo, useState, RefObject } from 'react'\n\nimport { useResizeObserver } from './useResizeObserver'\nimport { getSnapPositions } from './utils'\n\n/**\n * Get the scroll value of each slides that serves as the start of a page\n * The array is updated when resize event are caught in the carousel.\n */\nexport function useSnapPoints<T extends HTMLDivElement | null>(\n initialSnapPoints: number[] = [],\n {\n carouselRef,\n slidesPerMove,\n slidesPerPage,\n }: {\n carouselRef: RefObject<T>\n slidesPerMove: 'auto' | number\n slidesPerPage: number\n }\n) {\n const [pageSnapPoints, setPageSnapPoints] = useState(initialSnapPoints)\n\n const stableSnapPoints = useMemo(() => pageSnapPoints, [pageSnapPoints])\n\n /**\n * On resize, dimensions of the carousel might changes, which requires to update the snap points positions in the state.\n */\n useResizeObserver(carouselRef, () => {\n const newSnapPoints = getSnapPositions({\n slidesPerMove,\n slidesPerPage,\n container: carouselRef.current,\n })\n\n if (JSON.stringify(pageSnapPoints) !== JSON.stringify(newSnapPoints)) {\n setPageSnapPoints(newSnapPoints)\n }\n })\n\n return [stableSnapPoints, setPageSnapPoints] as const\n}\n","import { useLayoutEffect, RefObject } from 'react'\n\nexport function useResizeObserver<T extends HTMLElement | null>(\n ref: RefObject<T>,\n callback: (width: number) => void\n) {\n useLayoutEffect(() => {\n const element = ref.current\n if (!element) return\n\n const observer = new ResizeObserver(entries => {\n for (const entry of entries) {\n callback(entry.contentRect.width)\n }\n })\n\n observer.observe(element)\n\n return () => observer.disconnect() // Cleanup on unmount\n }, [ref, callback])\n}\n","/**\n * Get the indices of each slides that serves as the start of a page\n * @returns number[] (ex: [0, 2, 4])\n */\nfunction getSnapIndices({\n totalSlides,\n slidesPerMove,\n slidesPerPage,\n}: {\n totalSlides: number\n slidesPerMove: number | 'auto'\n slidesPerPage: number\n}) {\n const slideBy = slidesPerMove === 'auto' ? slidesPerPage : slidesPerMove\n const snapPoints: number[] = []\n\n const lastSnapIndex = Math.floor((totalSlides - slidesPerPage) / slideBy) * slideBy\n\n for (let i = 0; i <= lastSnapIndex; i += slideBy) {\n snapPoints.push(i)\n }\n\n // Adding final snap point if necessary\n if (snapPoints[snapPoints.length - 1] !== totalSlides - slidesPerPage) {\n snapPoints.push(totalSlides - slidesPerPage)\n }\n\n return snapPoints\n}\n\nexport function getSlideElements(container: HTMLDivElement | null): Element[] {\n return container ? Array.from(container.querySelectorAll('[data-part=\"item\"]')) : []\n}\n\nexport function isSnapPoint(\n slideIndex: number,\n {\n container,\n slidesPerMove,\n slidesPerPage,\n }: {\n container: HTMLDivElement | null\n slidesPerMove: number | 'auto'\n slidesPerPage: number\n }\n) {\n return getSnapIndices({\n totalSlides: getSlideElements(container).length,\n slidesPerPage,\n slidesPerMove,\n }).includes(slideIndex)\n}\n\n/**\n * Get the scroll value of each slides that serves as the start of a page\n * @returns number[] (ex for a 400px carousel with no gap: [400, 800, 1200])\n */\nexport function getSnapPositions({\n container,\n slidesPerMove,\n slidesPerPage,\n}: {\n container: HTMLDivElement | null\n slidesPerMove: number | 'auto'\n slidesPerPage: number\n}) {\n if (!container) return []\n\n return getSlideElements(container)\n .filter((_, index) => {\n return isSnapPoint(index, {\n slidesPerMove,\n slidesPerPage,\n container,\n })\n })\n .map(slide => (slide as HTMLElement).offsetLeft)\n}\n","import { ReactNode } from 'react'\n\nimport { useCarouselContext } from './Carousel'\n\ninterface ControlsProps {\n children: ReactNode\n}\n\nexport const CarouselControls = ({ children }: ControlsProps) => {\n const ctx = useCarouselContext()\n\n return (\n <div\n className=\"default:px-lg pointer-events-none absolute inset-0 flex flex-row items-center justify-between\"\n {...ctx.getControlProps()}\n >\n {children}\n </div>\n )\n}\n\nCarouselControls.displayName = 'Carousel.Controls'\n","import { ArrowVerticalRight } from '@spark-ui/icons/ArrowVerticalRight'\n\nimport { Icon } from '../icon'\nimport { IconButton, IconButtonProps } from '../icon-button'\nimport { useCarouselContext } from './Carousel'\n\nexport const CarouselNextButton = ({\n 'aria-label': ariaLabel,\n ...buttonProps\n}: IconButtonProps) => {\n const ctx = useCarouselContext()\n\n return (\n <IconButton\n {...ctx.getNextTriggerProps()}\n intent=\"surface\"\n design=\"filled\"\n className=\"pointer-events-auto cursor-pointer shadow-sm disabled:invisible\"\n aria-label={ariaLabel}\n {...buttonProps}\n >\n <Icon>\n <ArrowVerticalRight />\n </Icon>\n </IconButton>\n )\n}\n\nCarouselNextButton.displayName = 'Carousel.NextButton'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, useEffect, useRef } from 'react'\n\nimport { useCarouselContext } from './Carousel'\n\ninterface Props {\n children?: ReactNode\n 'aria-label': string\n index: number\n className?: string\n unstyled?: boolean\n}\n\nexport const CarouselPageIndicator = ({\n children,\n unstyled = false,\n index,\n 'aria-label': ariaLabel,\n className,\n}: Props) => {\n const ctx = useCarouselContext()\n\n const ref = useRef<HTMLButtonElement | null>(null)\n\n useEffect(() => {\n if (ctx.pageIndicatorsRefs.current) {\n ctx.pageIndicatorsRefs.current[index] = ref.current\n }\n })\n\n const styles = cx(\n 'group h-sz-16 relative flex',\n 'hover:cursor-pointer',\n 'w-sz-16 data-[state=active]:w-sz-44'\n )\n\n const dotsStyles = cx(\n 'before:rounded-sm before:block before:size-md',\n 'before:absolute before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2',\n 'data-[state=active]:before:w-sz-32 data-[state=active]:before:bg-basic',\n 'data-[state=inactive]:before:bg-on-surface/dim-3'\n )\n\n return (\n <button\n ref={ref}\n key={index}\n {...ctx.getIndicatorProps({ index })}\n aria-label={ariaLabel}\n className={cx(\n {\n [styles]: !unstyled,\n [dotsStyles]: !unstyled,\n },\n className\n )}\n >\n {children}\n </button>\n )\n}\n\nCarouselPageIndicator.displayName = 'Carousel.PageIndicator'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode } from 'react'\n\nimport { useCarouselContext } from './Carousel'\nimport { CarouselAPI } from './types'\n\ninterface RenderProps extends CarouselAPI {\n pages: number[]\n}\n\ninterface Props {\n children: (renderProps: RenderProps) => ReactNode\n className?: string\n}\n\nexport const CarouselPagePicker = ({ children, className }: Props) => {\n const ctx = useCarouselContext()\n\n return (\n <>\n <div\n {...ctx.getIndicatorGroupProps()}\n className={cx(\n 'default:min-h-sz-16 flex w-full flex-wrap items-center justify-center',\n className\n )}\n >\n {ctx.pageSnapPoints.length <= 1\n ? null\n : children({\n ...ctx,\n pages: Array.from({ length: ctx.pageSnapPoints.length }, (_, i) => i),\n })}\n </div>\n </>\n )\n}\n\nCarouselPagePicker.displayName = 'Carousel.PagePicker'\n","import { ArrowVerticalLeft } from '@spark-ui/icons/ArrowVerticalLeft'\n\nimport { Icon } from '../icon'\nimport { IconButton, IconButtonProps } from '../icon-button'\nimport { useCarouselContext } from './Carousel'\n\nexport const CarouselPrevButton = ({\n 'aria-label': ariaLabel,\n ...buttonProps\n}: IconButtonProps) => {\n const ctx = useCarouselContext()\n\n return (\n <IconButton\n {...ctx.getPrevTriggerProps()}\n intent=\"surface\"\n design=\"filled\"\n className=\"pointer-events-auto cursor-pointer shadow-sm disabled:invisible\"\n aria-label={ariaLabel}\n {...buttonProps}\n >\n <Icon>\n <ArrowVerticalLeft />\n </Icon>\n </IconButton>\n )\n}\n\nCarouselPrevButton.displayName = 'Carousel.PrevButton'\n","import { cx } from 'class-variance-authority'\nimport { ComponentProps, ReactNode, useRef } from 'react'\n\nimport { useCarouselContext } from './Carousel'\nimport { useIsVisible } from './useIsVisible'\n\nexport interface CarouselSlideProps extends ComponentProps<'div'> {\n isSnapPoint?: boolean\n children?: ReactNode\n index?: number\n totalSlides?: number\n className?: string\n}\n\nexport const CarouselSlide = ({\n children,\n index = 0,\n totalSlides,\n className = '',\n ...props\n}: CarouselSlideProps) => {\n const itemRef = useRef<HTMLDivElement>(null)\n const ctx = useCarouselContext()\n\n const isVisible = useIsVisible(itemRef, ctx.ref)\n\n return (\n <div\n ref={itemRef}\n {...ctx.getSlideProps({ index, totalSlides: totalSlides as number })}\n className={cx('default:bg-surface relative overflow-hidden', className)}\n aria-hidden={!isVisible}\n inert={!isVisible}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nCarouselSlide.displayName = 'Carousel.Slide'\n","import { useLayoutEffect, useState, RefObject } from 'react'\n\nexport function useIsVisible(\n elementRef: RefObject<HTMLElement | null>,\n parentRef: RefObject<HTMLElement | null>\n) {\n const [isVisible, setIsVisible] = useState(true)\n\n useLayoutEffect(() => {\n const el = elementRef.current\n const parent = parentRef.current\n\n if (!parent || !el) return\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry) {\n setIsVisible(entry.isIntersecting)\n }\n },\n { root: parent, threshold: 0.2 }\n )\n\n observer.observe(el)\n\n return () => observer.disconnect()\n })\n\n return isVisible\n}\n","import { cx } from 'class-variance-authority'\nimport { Children, cloneElement, ComponentProps, isValidElement, ReactNode } from 'react'\n\nimport { useCarouselContext } from './Carousel'\nimport { CarouselSlideProps } from './CarouselSlide'\n\ninterface Props extends ComponentProps<'div'> {\n children?: ReactNode\n className?: string\n}\n\nexport const CarouselSlides = ({ children, className = '' }: Props) => {\n const ctx = useCarouselContext()\n\n const childrenElements = Children.toArray(children)\n\n return (\n <div\n {...ctx.getSlidesContainerProps()}\n className={cx(\n 'focus-visible:u-outline relative w-full',\n '[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',\n className\n )}\n >\n {childrenElements.map((child, index) =>\n isValidElement<CarouselSlideProps>(child)\n ? cloneElement(child, {\n index,\n totalSlides: childrenElements.length,\n })\n : child\n )}\n </div>\n )\n}\n\nCarouselSlides.displayName = 'Carousel.Slides'\n","import { ReactNode } from 'react'\n\ninterface Props {\n children: ReactNode\n}\n\nexport const CarouselViewport = ({ children }: Props) => {\n return <div className=\"relative flex items-center justify-around p-0\">{children}</div>\n}\n\nCarouselViewport.displayName = 'Carousel.Viewport'\n","import { Carousel as Root } from './Carousel'\nimport { CarouselControls as Controls } from './CarouselControls'\nimport { CarouselNextButton as NextButton } from './CarouselNextButton'\nimport { CarouselPageIndicator as PageIndicator } from './CarouselPageIndicator'\nimport { CarouselPagePicker as PagePicker } from './CarouselPagePicker'\nimport { CarouselPrevButton as PrevButton } from './CarouselPrevButton'\nimport { CarouselSlide as Slide } from './CarouselSlide'\nimport { CarouselSlides as Slides } from './CarouselSlides'\nimport { CarouselViewport as Viewport } from './CarouselViewport'\n\nexport const Carousel: typeof Root & {\n Controls: typeof Controls\n NextButton: typeof NextButton\n PrevButton: typeof PrevButton\n Slide: typeof Slide\n Slides: typeof Slides\n Viewport: typeof Viewport\n PagePicker: typeof PagePicker\n PageIndicator: typeof PageIndicator\n} = Object.assign(Root, {\n Controls,\n NextButton,\n PrevButton,\n Slide,\n Slides,\n Viewport,\n PagePicker,\n PageIndicator,\n})\n\nCarousel.displayName = 'Carousel'\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,UAAU;AACnB,SAAS,eAA0B,kBAAkB;;;ACArD;AAAA,EACE,eAAAA;AAAA,EACA,aAAAC;AAAA,EACA;AAAA,EACA,mBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,OAEK;;;ACTP,SAAS,aAAa,iBAAiB,cAAc;AAQ9C,SAAS,SAAgC,UAAc;AAC5D,QAAM,MAAM,OAAgC,MAAM;AAChD,UAAM,IAAI,MAAM,+CAA+C;AAAA,EACjE,CAAC;AAED,kBAAgB,MAAM;AACpB,QAAI,UAAU;AAAA,EAChB,CAAC;AAED,SAAO,YAAyB,IAAI,SAAS,IAAI,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC;AACzE;;;AClBA,SAAS,WAAW,UAAAC,eAAc;AAE3B,IAAM,eAAe,MAAM;AAChC,QAAM,YAAYA,QAAO,KAAK;AAE9B,YAAU,MAAM;AACd,cAAU,UAAU;AAEpB,WAAO,MAAM;AACX,gBAAU,UAAU;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;;;ACdA,SAAS,aAAAC,YAAW,UAAAC,eAAyB;AAEtC,SAAS,aAAa,WAA6C,UAAsB;AAC9F,QAAM,aAAaA,QAAO,CAAC;AAS3B,QAAM,gBAAgBA,QAA8B,IAAI;AAExD,EAAAD,WAAU,MAAM;AACd,UAAM,UAAU,UAAU;AAC1B,QAAI,CAAC,QAAS;AAEd,UAAM,oBAAoB,iBAAiB;AAE3C,UAAM,kBAAkB,MAAM;AAC5B,eAAS;AAAA,IACX;AAEA,UAAM,qBAAqB,MAAM;AAC/B,UAAI,cAAc,SAAS;AACzB,qBAAa,cAAc,OAAO;AAAA,MACpC;AAEA,UAAI,UAA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U,YAAY,GAAG,MAAa;AACrE,QAAM,MAAM,mBAAmB;AAE/B,QAAM,mBAAmB,SAAS,QAAQ,QAAQ;AAElD,SACE,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG,IAAI,wBAAwB;AAAA,MAChC,WAAWC;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MAEC,2BAAiB;AAAA,QAAI,CAAC,OAAO,UAC5B,eAAmC,KAAK,IACpC,aAAa,OAAO;AAAA,UAClB;AAAA,UACA,aAAa,iBAAiB;AAAA,QAChC,CAAC,IACD;AAAA,MACN;AAAA;AAAA,EACF;AAEJ;AAEA,eAAe,cAAc;;;AC9BpB,gBAAAC,YAAA;AADF,IAAM,mBAAmB,CAAC,EAAE,SAAS,MAAa;AACvD,SAAO,gBAAAA,KAAC,SAAI,WAAU,iDAAiD,UAAS;AAClF;AAEA,iBAAiB,cAAc;;;ACAxB,IAAMC,YAST,OAAO,OAAO,UAAM;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEDA,UAAS,cAAc;","names":["useCallback","useEffect","useLayoutEffect","useRef","useState","useRef","useEffect","useRef","useLayoutEffect","useState","useRef","useCallback","useEffect","useLayoutEffect","jsx","jsx","cx","useEffect","useRef","jsx","useRef","useEffect","cx","cx","jsx","cx","jsx","cx","useRef","useLayoutEffect","useState","jsx","useRef","cx","cx","jsx","cx","jsx","Carousel"]}
|
|
1
|
+
{"version":3,"sources":["../../src/carousel/Carousel.tsx","../../src/carousel/useCarousel.ts","../../src/carousel/useEvent.ts","../../src/carousel/useIsMounted.ts","../../src/carousel/useScrollEnd.ts","../../src/carousel/useSnapPoints.ts","../../src/carousel/useResizeObserver.ts","../../src/carousel/utils.ts","../../src/carousel/CarouselControls.tsx","../../src/carousel/CarouselNextButton.tsx","../../src/carousel/CarouselPageIndicator.tsx","../../src/carousel/CarouselPagePicker.tsx","../../src/carousel/CarouselPrevButton.tsx","../../src/carousel/CarouselSlide.tsx","../../src/carousel/useIsVisible.ts","../../src/carousel/CarouselSlides.tsx","../../src/carousel/CarouselViewport.tsx","../../src/carousel/index.ts"],"sourcesContent":["import { cx } from 'class-variance-authority'\nimport { createContext, ReactNode, useContext } from 'react'\n\nimport { CarouselAPI, UseCarouselProps } from './types'\nimport { useCarousel } from './useCarousel'\n\ninterface Props extends UseCarouselProps {\n children?: ReactNode\n className?: string\n}\n\nconst CarouselContext = createContext<CarouselAPI | null>(null)\n\nexport const Carousel = ({\n className,\n snapType = 'mandatory',\n snapStop = 'always',\n scrollBehavior = 'smooth',\n slidesPerMove = 'auto',\n slidesPerPage = 1,\n loop = false,\n children,\n gap = 16,\n defaultPage,\n page,\n onPageChange,\n}: Props) => {\n const carouselApi = useCarousel({\n defaultPage,\n slidesPerPage,\n slidesPerMove,\n loop,\n gap,\n scrollBehavior,\n snapStop,\n snapType,\n page,\n onPageChange,\n })\n\n return (\n <CarouselContext.Provider\n value={{\n ...carouselApi,\n scrollBehavior,\n }}\n >\n <div\n className={cx('gap-lg relative box-border flex flex-col', className)}\n {...carouselApi.getRootProps()}\n >\n {children}\n </div>\n </CarouselContext.Provider>\n )\n}\n\nCarousel.displayName = 'Carousel'\n\nexport const useCarouselContext = () => {\n const context = useContext(CarouselContext)\n\n if (!context) {\n throw Error('useCarouselContext must be used within a Carousel provider')\n }\n\n return context\n}\n","/* eslint-disable max-lines-per-function */\nimport {\n KeyboardEvent,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react'\n\nimport {\n CarouselAPI,\n ComputedControlProps,\n ComputedIndicatorGroupProps,\n ComputedIndicatorProps,\n ComputedRootProps,\n ComputedSlideGroupProps,\n ComputedSlideProps,\n ComputedTriggerProps,\n UseCarouselProps,\n} from './types'\nimport { useEvent } from './useEvent'\nimport { useIsMounted } from './useIsMounted'\nimport { useScrollEnd } from './useScrollEnd'\nimport { useSnapPoints } from './useSnapPoints'\nimport { getSnapPositions, isSnapPoint } from './utils'\n\nconst DATA_SCOPE = 'carousel' as const\nconst DIRECTION = 'ltr' as const\n\nexport const useCarousel = ({\n defaultPage,\n gap = 16,\n snapType = 'mandatory',\n snapStop = 'always',\n scrollPadding = 0,\n slidesPerPage = 1,\n slidesPerMove = 'auto',\n scrollBehavior = 'smooth',\n loop = false,\n // state control\n page: controlledPage,\n onPageChange: onPageChangeProp,\n}: UseCarouselProps): CarouselAPI => {\n const carouselId = useId()\n const [pageState, setPageState] = useState(defaultPage || controlledPage || 0)\n\n const carouselRef = useRef<HTMLDivElement>(null)\n const pageIndicatorsRefs = useRef<(HTMLElement | null)[]>([])\n const isMountedRef = useIsMounted()\n const isMounted = isMountedRef.current\n const onPageChange = useEvent(onPageChangeProp)\n\n const [pageSnapPoints] = useSnapPoints([], {\n carouselRef,\n slidesPerMove,\n slidesPerPage,\n })\n\n const canScrollPrev = useRef(loop || pageState > 0)\n const canScrollNext = useRef(loop || pageState < pageSnapPoints.length - 1)\n canScrollPrev.current = loop || pageState > 0\n canScrollNext.current = loop || pageState < pageSnapPoints.length - 1\n\n const handlePageChange = useCallback(\n (page: number) => {\n if (page !== pageState) {\n setPageState(page)\n onPageChange?.(page)\n }\n },\n [onPageChange, pageState]\n )\n\n const scrollTo = useCallback(\n (page: number, behavior: 'instant' | 'smooth') => {\n if (carouselRef.current) {\n carouselRef.current.scrollTo({\n left: pageSnapPoints[page],\n behavior: behavior === 'instant' ? 'auto' : 'smooth',\n })\n handlePageChange(page)\n }\n },\n [handlePageChange, pageSnapPoints]\n )\n\n const scrollPrev = useCallback(\n (cb?: (pageIndex: number) => void) => {\n if (canScrollPrev) {\n const targetPage =\n loop && pageState === 0 ? pageSnapPoints.length - 1 : Math.max(pageState - 1, 0)\n\n scrollTo(targetPage, scrollBehavior)\n cb?.(targetPage)\n }\n },\n [loop, pageSnapPoints, pageState, scrollBehavior, scrollTo]\n )\n\n const scrollNext = useCallback(\n (cb?: (pageIndex: number) => void) => {\n if (canScrollNext) {\n const targetPage =\n loop && pageState === pageSnapPoints.length - 1\n ? 0\n : Math.min(pageState + 1, pageSnapPoints.length - 1)\n\n scrollTo(targetPage, scrollBehavior)\n cb?.(targetPage)\n }\n },\n [loop, pageSnapPoints, pageState, scrollBehavior, scrollTo]\n )\n\n useEffect(() => {\n if (controlledPage != null) {\n scrollTo(controlledPage, scrollBehavior)\n }\n }, [controlledPage, scrollBehavior, scrollTo])\n\n /**\n * Set the default scroll position of the carousel based on `defaultPage`.\n * As this operation is done before the snap points are set in the state, we have to get them from the ref directly.\n */\n useLayoutEffect(() => {\n if (defaultPage != null && !isMounted && carouselRef.current) {\n const snapPositions = getSnapPositions({\n container: carouselRef.current,\n slidesPerMove,\n slidesPerPage,\n })\n\n carouselRef.current.scrollTo({\n left: snapPositions[defaultPage],\n behavior: 'instant',\n })\n }\n }, [defaultPage, isMounted, slidesPerMove, slidesPerPage])\n\n /**\n * Monitoring scrollend events inside the scrollable area to sync the carousel active page with current scroll position.\n * Scrollend has been chosen over \"scroll\" for performance reason.\n */\n const syncPageStateWithScrollPosition = useCallback(() => {\n if (!carouselRef.current || pageSnapPoints.length === 0) return\n\n const { scrollLeft } = carouselRef.current\n\n const distances = pageSnapPoints.map(pagePosition => Math.abs(scrollLeft - pagePosition))\n const pageInViewport = distances.indexOf(Math.min(...distances))\n\n if (pageInViewport !== -1) {\n handlePageChange(pageInViewport)\n }\n }, [pageSnapPoints, handlePageChange])\n\n useScrollEnd(carouselRef, syncPageStateWithScrollPosition)\n\n const contextValue: CarouselAPI = {\n ref: carouselRef,\n pageIndicatorsRefs,\n // props\n gap,\n snapType,\n snapStop,\n scrollPadding,\n slidesPerPage,\n slidesPerMove,\n scrollBehavior,\n loop,\n // computed state\n page: pageState,\n pageSnapPoints,\n canScrollNext: canScrollNext.current,\n canScrollPrev: canScrollPrev.current,\n scrollTo,\n scrollPrev,\n scrollNext,\n // anatomy\n getRootProps: (): ComputedRootProps => ({\n id: `carousel::${carouselId}:`,\n role: 'region',\n 'aria-roledescription': 'carousel',\n 'data-scope': DATA_SCOPE,\n 'data-part': 'root',\n 'data-orientation': 'horizontal',\n dir: DIRECTION,\n style: {\n '--slides-per-page': slidesPerPage,\n '--slide-spacing': `${gap}px`,\n '--slide-item-size':\n 'calc(100% / var(--slides-per-page) - var(--slide-spacing) * (var(--slides-per-page) - 1) / var(--slides-per-page))',\n },\n }),\n\n getControlProps: (): ComputedControlProps => ({\n 'data-scope': DATA_SCOPE,\n 'data-part': 'control',\n 'data-orientation': 'horizontal',\n }),\n\n getPrevTriggerProps: (): ComputedTriggerProps<'prev-trigger'> => ({\n id: `carousel::${carouselId}::prev-trigger`,\n 'aria-controls': `carousel::${carouselId}::item-group`,\n 'data-scope': DATA_SCOPE,\n 'data-part': 'prev-trigger',\n 'data-orientation': 'horizontal',\n type: 'button',\n dir: DIRECTION,\n disabled: !canScrollPrev.current,\n onClick: () => scrollPrev(),\n }),\n\n getNextTriggerProps: (): ComputedTriggerProps<'next-trigger'> => ({\n id: `carousel::${carouselId}::next-trigger`,\n 'aria-controls': `carousel::${carouselId}::item-group`,\n 'data-scope': DATA_SCOPE,\n 'data-part': 'next-trigger',\n 'data-orientation': 'horizontal',\n type: 'button',\n dir: DIRECTION,\n disabled: !canScrollNext.current,\n onClick: () => scrollNext(),\n }),\n\n getSlidesContainerProps: (): ComputedSlideGroupProps => ({\n id: `carousel::${carouselId}::item-group`,\n /**\n * The carousel pattern was originally designed for a single slide.\n * When there is more than one slide, the aria-live region is set to off to avoid announcing the whole list of slides.\n * This is not ideal but we keep it for backwards compatibility.\n *\n * @see https://www.w3.org/WAI/ARIA/apg/patterns/carousel/#wai-aria-attributes\n */\n 'aria-live': slidesPerPage > 1 ? 'off' : 'polite',\n 'data-scope': DATA_SCOPE,\n 'data-part': 'item-group',\n 'data-orientation': 'horizontal',\n dir: DIRECTION,\n tabIndex: 0,\n style: {\n display: 'grid',\n gap: 'var(--slide-spacing)',\n scrollSnapType: `x ${snapType}`,\n gridAutoFlow: 'column',\n scrollbarWidth: 'none',\n overscrollBehavior: 'contain',\n gridAutoColumns: 'var(--slide-item-size)',\n overflowX: 'auto',\n },\n ref: carouselRef,\n }),\n\n getSlideProps: ({ index }): ComputedSlideProps => {\n const isStopPoint = isSnapPoint(index, {\n container: carouselRef.current,\n slidesPerMove,\n slidesPerPage,\n })\n\n return {\n id: `carousel::${carouselId}::item:${index}`,\n role: 'group',\n 'aria-roledescription': 'slide',\n 'data-scope': DATA_SCOPE,\n 'data-part': 'item',\n 'data-index': index,\n 'data-orientation': 'horizontal',\n dir: DIRECTION,\n style: {\n ...(isStopPoint && {\n scrollSnapAlign: 'start',\n scrollSnapStop: snapStop,\n }),\n },\n }\n },\n\n getIndicatorGroupProps: (): ComputedIndicatorGroupProps => ({\n role: 'radiogroup',\n id: `carousel::${carouselId}::indicator-group`,\n 'data-scope': DATA_SCOPE,\n 'data-part': 'indicator-group',\n 'data-orientation': 'horizontal',\n dir: DIRECTION,\n }),\n\n getIndicatorProps: ({ index }): ComputedIndicatorProps => {\n const isActivePage = index === pageState\n\n return {\n role: 'radio',\n id: `carousel::${carouselId}::indicator:${index}`,\n 'aria-checked': isActivePage,\n 'data-scope': DATA_SCOPE,\n 'data-part': 'indicator',\n 'data-orientation': 'horizontal',\n 'data-index': index,\n 'data-state': isActivePage ? 'active' : 'inactive',\n tabIndex: isActivePage ? 0 : -1,\n onClick: () => {\n scrollTo(index, scrollBehavior)\n },\n onKeyDown: (event: KeyboardEvent) => {\n const focusActiveIndicator = (page: number) => {\n pageIndicatorsRefs.current[page]?.focus()\n }\n\n if (event.key === 'ArrowRight' && canScrollNext) {\n scrollNext(focusActiveIndicator)\n } else if (event.key === 'ArrowLeft' && canScrollPrev) {\n scrollPrev(focusActiveIndicator)\n }\n },\n }\n },\n }\n\n return contextValue\n}\n","import { useCallback, useLayoutEffect, useRef } from 'react'\n\ntype AnyFunction = (...args: any[]) => any\n\n/**\n * Directly from this gist: https://gist.github.com/diegohaz/695097a06f038a707c3a1b11e4e40195\n * Until React releases a native `useEvent` hook.\n */\nexport function useEvent<T extends AnyFunction>(callback?: T) {\n const ref = useRef<AnyFunction | undefined>(() => {\n throw new Error('Cannot call an event handler while rendering.')\n })\n\n useLayoutEffect(() => {\n ref.current = callback\n })\n\n return useCallback<AnyFunction>((...args) => ref.current?.(...args), []) as T\n}\n","import { useEffect, useRef } from 'react'\n\nexport const useIsMounted = () => {\n const isMounted = useRef(false)\n\n useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n return isMounted\n}\n","import { useEffect, useRef, RefObject } from 'react'\n\nexport function useScrollEnd(scrollRef: RefObject<HTMLDivElement | null>, callback: () => void) {\n const scrollLeft = useRef(0)\n\n /**\n * Safari (and some smaller browsers) to not yet support the `scrollend` event.\n * For those we must rely on the `scroll` event and and an idle state delay to trigger the \"scroll end\".\n *\n * Caveats:\n * - when using a trackpad or your fingers on a touch device, scrolling then holding the position might trigger the \"scrollend\" callback too early.\n */\n const safariTimeout = useRef<NodeJS.Timeout | null>(null)\n\n useEffect(() => {\n const element = scrollRef.current\n if (!element) return\n\n const supportsScrollend = 'onscrollend' in window\n\n const handleScrollEnd = () => {\n callback()\n }\n\n const handleSafariScroll = () => {\n if (safariTimeout.current) {\n clearTimeout(safariTimeout.current)\n }\n\n if (scrollRef.current) {\n scrollLeft.current = scrollRef.current.scrollLeft\n\n safariTimeout.current = setTimeout(() => {\n if (scrollRef.current) {\n handleScrollEnd()\n }\n }, 150)\n }\n }\n\n if (supportsScrollend) {\n element.addEventListener('scrollend', handleScrollEnd)\n } else {\n element.addEventListener('scroll', handleSafariScroll)\n }\n\n return () => {\n if (safariTimeout.current) {\n clearTimeout(safariTimeout.current)\n }\n\n if (supportsScrollend) {\n element.removeEventListener('scrollend', handleScrollEnd)\n } else {\n element.removeEventListener('scroll', handleSafariScroll)\n }\n }\n }, [callback, scrollRef])\n}\n\nexport default useScrollEnd\n","import { useMemo, useState, RefObject } from 'react'\n\nimport { useResizeObserver } from './useResizeObserver'\nimport { getSnapPositions } from './utils'\n\n/**\n * Get the scroll value of each slides that serves as the start of a page\n * The array is updated when resize event are caught in the carousel.\n */\nexport function useSnapPoints<T extends HTMLDivElement | null>(\n initialSnapPoints: number[] = [],\n {\n carouselRef,\n slidesPerMove,\n slidesPerPage,\n }: {\n carouselRef: RefObject<T>\n slidesPerMove: 'auto' | number\n slidesPerPage: number\n }\n) {\n const [pageSnapPoints, setPageSnapPoints] = useState(initialSnapPoints)\n\n const stableSnapPoints = useMemo(() => pageSnapPoints, [pageSnapPoints])\n\n /**\n * On resize, dimensions of the carousel might changes, which requires to update the snap points positions in the state.\n */\n useResizeObserver(carouselRef, () => {\n const newSnapPoints = getSnapPositions({\n slidesPerMove,\n slidesPerPage,\n container: carouselRef.current,\n })\n\n if (JSON.stringify(pageSnapPoints) !== JSON.stringify(newSnapPoints)) {\n setPageSnapPoints(newSnapPoints)\n }\n })\n\n return [stableSnapPoints, setPageSnapPoints] as const\n}\n","import { useLayoutEffect, RefObject } from 'react'\n\nexport function useResizeObserver<T extends HTMLElement | null>(\n ref: RefObject<T>,\n callback: (width: number) => void\n) {\n useLayoutEffect(() => {\n const element = ref.current\n if (!element) return\n\n const observer = new ResizeObserver(entries => {\n for (const entry of entries) {\n callback(entry.contentRect.width)\n }\n })\n\n observer.observe(element)\n\n return () => observer.disconnect() // Cleanup on unmount\n }, [ref, callback])\n}\n","/**\n * Get the indices of each slides that serves as the start of a page\n * @returns number[] (ex: [0, 2, 4])\n */\nfunction getSnapIndices({\n totalSlides,\n slidesPerMove,\n slidesPerPage,\n}: {\n totalSlides: number\n slidesPerMove: number | 'auto'\n slidesPerPage: number\n}) {\n const slideBy = slidesPerMove === 'auto' ? slidesPerPage : slidesPerMove\n const snapPoints: number[] = []\n\n const lastSnapIndex = Math.floor((totalSlides - slidesPerPage) / slideBy) * slideBy\n\n for (let i = 0; i <= lastSnapIndex; i += slideBy) {\n snapPoints.push(i)\n }\n\n // Adding final snap point if necessary\n if (snapPoints[snapPoints.length - 1] !== totalSlides - slidesPerPage) {\n snapPoints.push(totalSlides - slidesPerPage)\n }\n\n return snapPoints\n}\n\nexport function getSlideElements(container: HTMLDivElement | null): Element[] {\n return container ? Array.from(container.querySelectorAll('[data-part=\"item\"]')) : []\n}\n\nexport function isSnapPoint(\n slideIndex: number,\n {\n container,\n slidesPerMove,\n slidesPerPage,\n }: {\n container: HTMLDivElement | null\n slidesPerMove: number | 'auto'\n slidesPerPage: number\n }\n) {\n return getSnapIndices({\n totalSlides: getSlideElements(container).length,\n slidesPerPage,\n slidesPerMove,\n }).includes(slideIndex)\n}\n\n/**\n * Get the scroll value of each slides that serves as the start of a page\n * @returns number[] (ex for a 400px carousel with no gap: [400, 800, 1200])\n */\nexport function getSnapPositions({\n container,\n slidesPerMove,\n slidesPerPage,\n}: {\n container: HTMLDivElement | null\n slidesPerMove: number | 'auto'\n slidesPerPage: number\n}) {\n if (!container) return []\n\n return getSlideElements(container)\n .filter((_, index) => {\n return isSnapPoint(index, {\n slidesPerMove,\n slidesPerPage,\n container,\n })\n })\n .map(slide => (slide as HTMLElement).offsetLeft)\n}\n","import { ReactNode } from 'react'\n\nimport { useCarouselContext } from './Carousel'\n\ninterface ControlsProps {\n children: ReactNode\n}\n\nexport const CarouselControls = ({ children }: ControlsProps) => {\n const ctx = useCarouselContext()\n\n return (\n <div\n className=\"default:px-lg pointer-events-none absolute inset-0 flex flex-row items-center justify-between\"\n {...ctx.getControlProps()}\n >\n {children}\n </div>\n )\n}\n\nCarouselControls.displayName = 'Carousel.Controls'\n","import { ArrowVerticalRight } from '@spark-ui/icons/ArrowVerticalRight'\n\nimport { Icon } from '../icon'\nimport { IconButton, IconButtonProps } from '../icon-button'\nimport { useCarouselContext } from './Carousel'\n\nexport const CarouselNextButton = ({\n 'aria-label': ariaLabel,\n ...buttonProps\n}: IconButtonProps) => {\n const ctx = useCarouselContext()\n\n return (\n <IconButton\n {...ctx.getNextTriggerProps()}\n intent=\"surface\"\n design=\"filled\"\n className=\"pointer-events-auto cursor-pointer shadow-sm disabled:invisible\"\n aria-label={ariaLabel}\n {...buttonProps}\n >\n <Icon>\n <ArrowVerticalRight />\n </Icon>\n </IconButton>\n )\n}\n\nCarouselNextButton.displayName = 'Carousel.NextButton'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, useEffect, useRef } from 'react'\n\nimport { useCarouselContext } from './Carousel'\n\ninterface Props {\n children?: ReactNode\n 'aria-label': string\n index: number\n className?: string\n unstyled?: boolean\n}\n\nexport const CarouselPageIndicator = ({\n children,\n unstyled = false,\n index,\n 'aria-label': ariaLabel,\n className,\n}: Props) => {\n const ctx = useCarouselContext()\n\n const ref = useRef<HTMLButtonElement | null>(null)\n\n useEffect(() => {\n if (ctx.pageIndicatorsRefs.current) {\n ctx.pageIndicatorsRefs.current[index] = ref.current\n }\n })\n\n const styles = cx(\n 'group h-sz-16 relative flex',\n 'hover:cursor-pointer',\n 'w-sz-16 data-[state=active]:w-sz-44'\n )\n\n const dotsStyles = cx(\n 'before:rounded-sm before:block before:size-md',\n 'before:absolute before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2',\n 'data-[state=active]:before:w-sz-32 data-[state=active]:before:bg-basic',\n 'data-[state=inactive]:before:bg-on-surface/dim-3'\n )\n\n return (\n <button\n ref={ref}\n key={index}\n {...ctx.getIndicatorProps({ index })}\n aria-label={ariaLabel}\n className={cx(\n {\n [styles]: !unstyled,\n [dotsStyles]: !unstyled,\n },\n className\n )}\n >\n {children}\n </button>\n )\n}\n\nCarouselPageIndicator.displayName = 'Carousel.PageIndicator'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode } from 'react'\n\nimport { useCarouselContext } from './Carousel'\nimport { CarouselAPI } from './types'\n\ninterface RenderProps extends CarouselAPI {\n pages: number[]\n}\n\ninterface Props {\n children: (renderProps: RenderProps) => ReactNode\n className?: string\n}\n\nexport const CarouselPagePicker = ({ children, className }: Props) => {\n const ctx = useCarouselContext()\n\n return (\n <>\n <div\n {...ctx.getIndicatorGroupProps()}\n className={cx(\n 'default:min-h-sz-16 flex w-full flex-wrap items-center justify-center',\n className\n )}\n >\n {ctx.pageSnapPoints.length <= 1\n ? null\n : children({\n ...ctx,\n pages: Array.from({ length: ctx.pageSnapPoints.length }, (_, i) => i),\n })}\n </div>\n </>\n )\n}\n\nCarouselPagePicker.displayName = 'Carousel.PagePicker'\n","import { ArrowVerticalLeft } from '@spark-ui/icons/ArrowVerticalLeft'\n\nimport { Icon } from '../icon'\nimport { IconButton, IconButtonProps } from '../icon-button'\nimport { useCarouselContext } from './Carousel'\n\nexport const CarouselPrevButton = ({\n 'aria-label': ariaLabel,\n ...buttonProps\n}: IconButtonProps) => {\n const ctx = useCarouselContext()\n\n return (\n <IconButton\n {...ctx.getPrevTriggerProps()}\n intent=\"surface\"\n design=\"filled\"\n className=\"pointer-events-auto cursor-pointer shadow-sm disabled:invisible\"\n aria-label={ariaLabel}\n {...buttonProps}\n >\n <Icon>\n <ArrowVerticalLeft />\n </Icon>\n </IconButton>\n )\n}\n\nCarouselPrevButton.displayName = 'Carousel.PrevButton'\n","import { cx } from 'class-variance-authority'\nimport { ComponentProps, ReactNode, useRef } from 'react'\n\nimport { useCarouselContext } from './Carousel'\nimport { useIsVisible } from './useIsVisible'\n\nexport interface CarouselSlideProps extends ComponentProps<'div'> {\n isSnapPoint?: boolean\n children?: ReactNode\n index?: number\n totalSlides?: number\n className?: string\n}\n\nexport const CarouselSlide = ({\n children,\n index = 0,\n totalSlides,\n className = '',\n ...props\n}: CarouselSlideProps) => {\n const itemRef = useRef<HTMLDivElement>(null)\n const ctx = useCarouselContext()\n\n const isVisible = useIsVisible(itemRef, ctx.ref)\n\n return (\n <div\n ref={itemRef}\n {...ctx.getSlideProps({ index, totalSlides: totalSlides as number })}\n className={cx('default:bg-surface relative overflow-hidden', className)}\n aria-hidden={!isVisible}\n inert={!isVisible}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nCarouselSlide.displayName = 'Carousel.Slide'\n","import { useLayoutEffect, useState, RefObject } from 'react'\n\nexport function useIsVisible(\n elementRef: RefObject<HTMLElement | null>,\n parentRef: RefObject<HTMLElement | null>\n) {\n const [isVisible, setIsVisible] = useState(true)\n\n useLayoutEffect(() => {\n const el = elementRef.current\n const parent = parentRef.current\n\n if (!parent || !el) return\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry) {\n setIsVisible(entry.isIntersecting)\n }\n },\n { root: parent, threshold: 0.2 }\n )\n\n observer.observe(el)\n\n return () => observer.disconnect()\n })\n\n return isVisible\n}\n","import { cx } from 'class-variance-authority'\nimport { Children, cloneElement, ComponentProps, isValidElement, ReactNode } from 'react'\n\nimport { useCarouselContext } from './Carousel'\nimport { CarouselSlideProps } from './CarouselSlide'\n\ninterface Props extends ComponentProps<'div'> {\n children?: ReactNode\n className?: string\n}\n\nexport const CarouselSlides = ({ children, className = '' }: Props) => {\n const ctx = useCarouselContext()\n\n const childrenElements = Children.toArray(children)\n\n return (\n <div\n {...ctx.getSlidesContainerProps()}\n className={cx(\n 'focus-visible:u-outline relative w-full',\n '[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',\n className\n )}\n >\n {childrenElements.map((child, index) =>\n isValidElement<CarouselSlideProps>(child)\n ? cloneElement(child, {\n index,\n totalSlides: childrenElements.length,\n })\n : child\n )}\n </div>\n )\n}\n\nCarouselSlides.displayName = 'Carousel.Slides'\n","import { ReactNode } from 'react'\n\ninterface Props {\n children: ReactNode\n}\n\nexport const CarouselViewport = ({ children }: Props) => {\n return <div className=\"relative flex items-center justify-around p-0\">{children}</div>\n}\n\nCarouselViewport.displayName = 'Carousel.Viewport'\n","import { Carousel as Root } from './Carousel'\nimport { CarouselControls as Controls } from './CarouselControls'\nimport { CarouselNextButton as NextButton } from './CarouselNextButton'\nimport { CarouselPageIndicator as PageIndicator } from './CarouselPageIndicator'\nimport { CarouselPagePicker as PagePicker } from './CarouselPagePicker'\nimport { CarouselPrevButton as PrevButton } from './CarouselPrevButton'\nimport { CarouselSlide as Slide } from './CarouselSlide'\nimport { CarouselSlides as Slides } from './CarouselSlides'\nimport { CarouselViewport as Viewport } from './CarouselViewport'\n\nexport const Carousel: typeof Root & {\n Controls: typeof Controls\n NextButton: typeof NextButton\n PrevButton: typeof PrevButton\n Slide: typeof Slide\n Slides: typeof Slides\n Viewport: typeof Viewport\n PagePicker: typeof PagePicker\n PageIndicator: typeof PageIndicator\n} = Object.assign(Root, {\n Controls,\n NextButton,\n PrevButton,\n Slide,\n Slides,\n Viewport,\n PagePicker,\n PageIndicator,\n})\n\nCarousel.displayName = 'Carousel'\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,UAAU;AACnB,SAAS,eAA0B,kBAAkB;;;ACArD;AAAA,EAEE,eAAAA;AAAA,EACA,aAAAC;AAAA,EACA;AAAA,EACA,mBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,OACK;;;ACTP,SAAS,aAAa,iBAAiB,cAAc;AAQ9C,SAAS,SAAgC,UAAc;AAC5D,QAAM,MAAM,OAAgC,MAAM;AAChD,UAAM,IAAI,MAAM,+CAA+C;AAAA,EACjE,CAAC;AAED,kBAAgB,MAAM;AACpB,QAAI,UAAU;AAAA,EAChB,CAAC;AAED,SAAO,YAAyB,IAAI,SAAS,IAAI,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC;AACzE;;;AClBA,SAAS,WAAW,UAAAC,eAAc;AAE3B,IAAM,eAAe,MAAM;AAChC,QAAM,YAAYA,QAAO,KAAK;AAE9B,YAAU,MAAM;AACd,cAAU,UAAU;AAEpB,WAAO,MAAM;AACX,gBAAU,UAAU;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;;;ACdA,SAAS,aAAAC,YAAW,UAAAC,eAAyB;AAEtC,SAAS,aAAa,WAA6C,UAAsB;AAC9F,QAAM,aAAaA,QAAO,CAAC;A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AK;AAAA,MACJ,GAAG,IAAI,cAAc,EAAE,OAAO,YAAmC,CAAC;AAAA,MACnE,WAAWE,IAAG,+CAA+C,SAAS;AAAA,MACtE,eAAa,CAAC;AAAA,MACd,OAAO,CAAC;AAAA,MACP,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;AAEA,cAAc,cAAc;;;AExC5B,SAAS,MAAAC,WAAU;AACnB,SAAS,UAAU,cAA8B,sBAAiC;AAgB9E,gBAAAC,YAAA;AANG,IAAM,iBAAiB,CAAC,EAAE,UAAU,YAAY,GAAG,MAAa;AACrE,QAAM,MAAM,mBAAmB;AAE/B,QAAM,mBAAmB,SAAS,QAAQ,QAAQ;AAElD,SACE,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG,IAAI,wBAAwB;AAAA,MAChC,WAAWC;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MAEC,2BAAiB;AAAA,QAAI,CAAC,OAAO,UAC5B,eAAmC,KAAK,IACpC,aAAa,OAAO;AAAA,UAClB;AAAA,UACA,aAAa,iBAAiB;AAAA,QAChC,CAAC,IACD;AAAA,MACN;AAAA;AAAA,EACF;AAEJ;AAEA,eAAe,cAAc;;;AC9BpB,gBAAAC,YAAA;AADF,IAAM,mBAAmB,CAAC,EAAE,SAAS,MAAa;AACvD,SAAO,gBAAAA,KAAC,SAAI,WAAU,iDAAiD,UAAS;AAClF;AAEA,iBAAiB,cAAc;;;ACAxB,IAAMC,YAST,OAAO,OAAO,UAAM;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEDA,UAAS,cAAc;","names":["useCallback","useEffect","useLayoutEffect","useRef","useState","useRef","useEffect","useRef","useLayoutEffect","useState","useRef","useCallback","useEffect","useLayoutEffect","jsx","jsx","cx","useEffect","useRef","jsx","useRef","useEffect","cx","cx","jsx","cx","jsx","cx","useRef","useLayoutEffect","useState","jsx","useRef","cx","cx","jsx","cx","jsx","Carousel"]}
|
|
@@ -418,6 +418,7 @@ var inputStyles = cva3(
|
|
|
418
418
|
"bg-surface",
|
|
419
419
|
"text-ellipsis text-body-1 text-on-surface",
|
|
420
420
|
"caret-neutral",
|
|
421
|
+
"[&:-webkit-autofill]:[-webkit-text-fill-color:var(--color-on-surface)]",
|
|
421
422
|
"autofill:shadow-surface autofill:shadow-[inset_0_0_0px_1000px]",
|
|
422
423
|
"disabled:cursor-not-allowed disabled:border-outline disabled:bg-on-surface/dim-5 disabled:text-on-surface/dim-3",
|
|
423
424
|
"read-only:cursor-default read-only:pointer-events-none read-only:bg-on-surface/dim-5",
|
|
@@ -599,4 +600,4 @@ export {
|
|
|
599
600
|
Input,
|
|
600
601
|
InputGroup2 as InputGroup
|
|
601
602
|
};
|
|
602
|
-
//# sourceMappingURL=chunk-
|
|
603
|
+
//# sourceMappingURL=chunk-LHZ2JOXC.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/input/InputClearButton.tsx","../src/input/InputGroupContext.ts","../src/input/InputGroup.tsx","../src/input/InputGroup.styles.ts","../src/input/InputLeadingAddon.tsx","../src/input/InputAddon.tsx","../src/input/InputAddon.styles.ts","../src/input/InputLeadingIcon.tsx","../src/input/InputIcon.tsx","../src/input/InputTrailingAddon.tsx","../src/input/InputTrailingIcon.tsx","../src/input/Input.tsx","../src/input/Input.styles.ts","../src/input/index.ts"],"sourcesContent":["import { DeleteOutline } from '@spark-ui/icons/DeleteOutline'\nimport { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, MouseEventHandler, Ref } from 'react'\n\nimport { Icon } from '../icon'\nimport { useInputGroup } from './InputGroupContext'\n\nexport interface InputClearButtonProps extends ComponentPropsWithoutRef<'button'> {\n 'aria-label': string\n ref?: Ref<HTMLButtonElement>\n}\n\nconst Root = ({ className, tabIndex = -1, onClick, ref, ...others }: InputClearButtonProps) => {\n const { onClear, hasTrailingIcon } = useInputGroup()\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = event => {\n if (onClick) {\n onClick(event)\n }\n\n if (onClear) {\n onClear()\n }\n }\n\n return (\n <button\n ref={ref}\n className={cx(\n className,\n 'pointer-events-auto absolute top-1/2 -translate-y-1/2',\n 'inline-flex h-full items-center justify-center outline-hidden',\n 'text-neutral hover:text-neutral-hovered',\n hasTrailingIcon ? 'right-3xl px-sz-12' : 'pl-md pr-lg right-0'\n )}\n tabIndex={tabIndex}\n onClick={handleClick}\n type=\"button\"\n {...others}\n >\n <Icon size=\"sm\">\n <DeleteOutline />\n </Icon>\n </button>\n )\n}\n\nexport const InputClearButton = Object.assign(Root, {\n id: 'ClearButton',\n})\n\nRoot.displayName = 'InputGroup.ClearButton'\n","import { createContext, useContext } from 'react'\n\nexport interface InputGroupContextValue {\n disabled?: boolean\n readOnly?: boolean\n hasLeadingIcon: boolean\n hasTrailingIcon: boolean\n hasLeadingAddon: boolean\n hasTrailingAddon: boolean\n hasClearButton: boolean\n state: null | undefined | 'error' | 'alert' | 'success'\n isStandalone?: boolean\n onClear: () => void\n}\n\nexport const InputGroupContext = createContext<Partial<InputGroupContextValue> | null>(null)\n\nexport const useInputGroup = () => {\n const context = useContext(InputGroupContext)\n\n return context || { isStandalone: true }\n}\n","/* eslint-disable complexity */\n\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport {\n ChangeEventHandler,\n Children,\n cloneElement,\n ComponentPropsWithoutRef,\n DetailedReactHTMLElement,\n FC,\n isValidElement,\n PropsWithChildren,\n ReactElement,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react'\n\nimport { InputProps } from './Input'\nimport { inputGroupStyles, InputGroupStylesProps } from './InputGroup.styles'\nimport { InputGroupContext } from './InputGroupContext'\n\nexport interface InputGroupProps extends ComponentPropsWithoutRef<'div'>, InputGroupStylesProps {\n /**\n * Use `state` prop to assign a specific state to the group, choosing from: `error`, `alert` and `success`. By doing so, the outline styles will be updated.\n */\n state?: 'error' | 'alert' | 'success'\n /**\n * Function handler to be executed after the input has been cleared.\n */\n onClear?: () => void\n ref?: Ref<HTMLDivElement>\n}\n\nexport const InputGroup = ({\n className,\n children: childrenProp,\n state: stateProp,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n onClear,\n ref: forwardedRef,\n ...others\n}: PropsWithChildren<InputGroupProps>) => {\n const getElementId = (element?: ReactElement) => {\n return element ? (element.type as FC & { id?: string }).id : ''\n }\n\n const findElement = (...values: string[]) => {\n return children.find(child => values.includes(getElementId(child) || ''))\n }\n\n const children = Children.toArray(childrenProp).filter(isValidElement)\n const input = findElement('Input') as\n | DetailedReactHTMLElement<InputProps, HTMLInputElement>\n | undefined\n const props = input?.props || {}\n\n const inputRef = useRef<HTMLInputElement>(null!)\n const onClearRef = useRef(onClear)\n const ref = useMergeRefs<HTMLInputElement>(input?.ref, inputRef)\n const [value, onChange] = useCombinedState(\n props.value as string,\n props.defaultValue as string,\n props.onValueChange\n )\n\n // Data derivated from FormField context\n const field = useFormFieldControl()\n const state = field.state ?? stateProp\n const disabled = field.disabled || !!disabledProp\n const readOnly = field.readOnly || !!readOnlyProp\n\n // InputGroup elements (in visual order)\n const leadingAddon = findElement('LeadingAddon')\n const leadingIcon = findElement('LeadingIcon')\n const clearButton = findElement('ClearButton')\n const trailingIcon = findElement('TrailingIcon')\n const trailingAddon = findElement('TrailingAddon')\n\n // Acknowledge which subComponents are used in the compound context\n const hasLeadingAddon = !!leadingAddon\n const hasTrailingAddon = !!trailingAddon\n const hasLeadingIcon = !!leadingIcon\n const hasTrailingIcon = !!trailingIcon\n const hasClearButton = !!value && !!clearButton && !disabled && !readOnly\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = event => {\n if (props.onChange) {\n props.onChange(event)\n }\n\n onChange(event.target.value)\n }\n\n const handleClear = useCallback(() => {\n if (onClearRef.current) {\n onClearRef.current()\n }\n\n onChange('')\n\n inputRef.current.focus()\n }, [onChange])\n\n const current = useMemo(() => {\n return {\n state,\n disabled,\n readOnly,\n hasLeadingIcon,\n hasTrailingIcon,\n hasLeadingAddon,\n hasTrailingAddon,\n hasClearButton,\n onClear: handleClear,\n }\n }, [\n state,\n disabled,\n readOnly,\n hasLeadingIcon,\n hasTrailingIcon,\n hasLeadingAddon,\n hasTrailingAddon,\n hasClearButton,\n handleClear,\n ])\n\n useEffect(() => {\n onClearRef.current = onClear\n }, [onClear])\n\n return (\n <InputGroupContext.Provider value={current}>\n <div\n ref={forwardedRef}\n className={inputGroupStyles({ disabled, readOnly, className })}\n {...others}\n >\n {hasLeadingAddon && leadingAddon}\n\n <div className=\"relative inline-flex w-full\">\n {input &&\n cloneElement(input, {\n ref,\n defaultValue: undefined,\n value: value ?? '',\n onChange: handleChange,\n })}\n\n {leadingIcon}\n\n {hasClearButton && clearButton}\n\n {trailingIcon}\n </div>\n\n {hasTrailingAddon && trailingAddon}\n </div>\n </InputGroupContext.Provider>\n )\n}\n\nInputGroup.displayName = 'InputGroup'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const inputGroupStyles = cva(['relative inline-flex w-full'], {\n variants: {\n /**\n * When `true`, prevents the user from interacting.\n */\n disabled: {\n true: [\n 'cursor-not-allowed',\n 'relative',\n 'after:absolute',\n 'after:top-0',\n 'after:h-full',\n 'after:w-full',\n 'after:border-sm after:border-outline',\n 'after:rounded-lg',\n ],\n false: 'after:hidden',\n },\n /**\n * Sets the component as interactive or not.\n */\n readOnly: {\n true: [\n 'relative',\n 'after:absolute',\n 'after:top-0',\n 'after:h-full',\n 'after:w-full',\n 'after:border-sm after:border-outline',\n 'after:rounded-lg',\n ],\n false: 'after:hidden',\n },\n },\n})\n\nexport type InputGroupStylesProps = VariantProps<typeof inputGroupStyles>\n","import { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { InputAddon, InputAddonProps } from './InputAddon'\nimport { useInputGroup } from './InputGroupContext'\n\nexport type InputLeadingAddonProps = InputAddonProps & {\n ref?: Ref<HTMLDivElement>\n}\n\nconst Root = ({ className, ref, ...others }: InputLeadingAddonProps) => {\n const { disabled, readOnly } = useInputGroup()\n const isInactive = disabled || readOnly\n\n return (\n <div className={cx('rounded-l-lg', isInactive ? 'bg-on-surface/dim-5' : null)}>\n <InputAddon\n ref={ref}\n className={cx(className, 'rounded-r-0! mr-[-1px] rounded-l-lg')}\n {...others}\n />\n </div>\n )\n}\n\nexport const InputLeadingAddon = Object.assign(Root, {\n id: 'LeadingAddon',\n})\n\nRoot.displayName = 'InputGroup.LeadingAddon'\n","import { Children, type ComponentPropsWithoutRef, type PropsWithChildren, Ref } from 'react'\n\nimport { Slot } from '../slot'\nimport { inputAddonStyles, type InputAddonStylesProps } from './InputAddon.styles'\nimport { useInputGroup } from './InputGroupContext'\n\nexport interface InputAddonProps\n extends ComponentPropsWithoutRef<'div'>,\n Omit<InputAddonStylesProps, 'intent' | 'disabled'> {\n ref?: Ref<HTMLDivElement>\n}\n\nexport const InputAddon = ({\n asChild: asChildProp,\n className,\n children,\n ref,\n ...others\n}: PropsWithChildren<InputAddonProps>) => {\n const { state, disabled, readOnly } = useInputGroup()\n\n const isRawText = typeof children === 'string'\n const asChild = !!(isRawText ? false : asChildProp)\n const child = isRawText ? children : Children.only(children)\n const Component = asChild && !isRawText ? Slot : 'div'\n\n const getDesign = (): InputAddonStylesProps['design'] => {\n if (isRawText) return 'text'\n\n return asChild ? 'solid' : 'inline'\n }\n\n const design = getDesign()\n\n return (\n <Component\n ref={ref}\n className={inputAddonStyles({\n className,\n intent: state,\n disabled,\n readOnly,\n asChild,\n design,\n })}\n {...(disabled && { tabIndex: -1 })}\n {...others}\n >\n {child}\n </Component>\n )\n}\n\nInputAddon.displayName = 'InputGroup.Addon'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const inputAddonStyles = cva(\n [\n 'overflow-hidden',\n 'border-sm',\n 'shrink-0',\n 'h-full',\n 'focus-visible:relative focus-visible:z-raised',\n ],\n {\n variants: {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild: { false: ['flex', 'items-center', 'px-lg'] },\n intent: {\n neutral: 'border-outline',\n error: 'border-error',\n alert: 'border-alert',\n success: 'border-success',\n },\n /**\n * Disable the input addon, preventing user interaction and adding opacity.\n */\n disabled: {\n true: ['pointer-events-none border-outline!'],\n },\n /**\n * Changes input addon styles based on the read only status from the input.\n */\n readOnly: {\n true: ['pointer-events-none'],\n },\n /**\n * Main style of the input addon.\n */\n design: {\n text: '',\n solid: '',\n inline: '',\n },\n },\n compoundVariants: [\n {\n disabled: false,\n readOnly: false,\n design: 'text',\n class: ['bg-surface', 'text-on-surface'],\n },\n {\n disabled: true,\n design: 'text',\n class: ['text-on-surface/dim-3'],\n },\n {\n disabled: true,\n design: ['solid', 'inline'],\n class: ['opacity-dim-3'],\n },\n ],\n defaultVariants: {\n intent: 'neutral',\n },\n }\n)\n\nexport type InputAddonStylesProps = VariantProps<typeof inputAddonStyles>\n","import { cx } from 'class-variance-authority'\n\nimport { InputIcon, InputIconProps } from './InputIcon'\n\nexport type InputLeadingIconProps = InputIconProps\n\nexport const InputLeadingIcon = ({ className, ...others }: InputLeadingIconProps) => (\n <InputIcon className={cx(className, 'left-lg text-body-1')} {...others} />\n)\n\nInputLeadingIcon.id = 'LeadingIcon'\nInputLeadingIcon.displayName = 'InputGroup.LeadingIcon'\n","import { cx } from 'class-variance-authority'\n\nimport { Icon, type IconProps } from '../icon'\nimport { useInputGroup } from './InputGroupContext'\n\nexport type InputIconProps = IconProps\n\nexport const InputIcon = ({ className, intent, children, ...others }: InputIconProps) => {\n const { disabled, readOnly } = useInputGroup()\n const isInactive = disabled || readOnly\n\n return (\n <Icon\n intent={intent}\n className={cx(\n className,\n 'pointer-events-none absolute top-[calc(var(--spacing-sz-44)/2)] -translate-y-1/2',\n intent ? undefined : 'text-neutral peer-focus:text-outline-high',\n isInactive ? 'opacity-dim-3' : undefined\n )}\n {...others}\n >\n {children}\n </Icon>\n )\n}\n\nInputIcon.displayName = 'InputGroup.Icon'\n","import { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { InputAddon, InputAddonProps } from './InputAddon'\nimport { useInputGroup } from './InputGroupContext'\n\nexport type InputTrailingAddonProps = InputAddonProps & {\n ref?: Ref<HTMLDivElement>\n}\n\nconst Root = ({ className, ref, ...others }: InputTrailingAddonProps) => {\n const { disabled, readOnly } = useInputGroup()\n const isInactive = disabled || readOnly\n\n return (\n <div className={cx('rounded-r-lg', isInactive ? 'bg-on-surface/dim-5' : null)}>\n <InputAddon\n ref={ref}\n className={cx(className, 'rounded-l-0! ml-[-1px] rounded-r-lg')}\n {...others}\n />\n </div>\n )\n}\n\nexport const InputTrailingAddon = Object.assign(Root, {\n id: 'TrailingAddon',\n})\n\nRoot.displayName = 'InputGroup.TrailingAddon'\n","import { cx } from 'class-variance-authority'\n\nimport { InputIcon, InputIconProps } from './InputIcon'\n\nexport type InputTrailingIconProps = InputIconProps\n\nexport const InputTrailingIcon = ({ className, ...others }: InputTrailingIconProps) => (\n <InputIcon className={cx(className, 'right-lg text-body-1')} {...others} />\n)\n\nInputTrailingIcon.id = 'TrailingIcon'\nInputTrailingIcon.displayName = 'InputGroup.TrailingIcon'\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { ChangeEventHandler, ComponentPropsWithoutRef, KeyboardEventHandler, Ref } from 'react'\n\nimport { Slot } from '../slot'\nimport { inputStyles } from './Input.styles'\nimport { useInputGroup } from './InputGroupContext'\n\ntype InputPrimitiveProps = ComponentPropsWithoutRef<'input'>\n\nexport interface InputProps extends InputPrimitiveProps {\n asChild?: boolean\n onValueChange?: (value: string) => void\n ref?: Ref<HTMLInputElement>\n}\n\nconst Root = ({\n className,\n asChild = false,\n onValueChange,\n onChange,\n onKeyDown,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n ref,\n ...others\n}: InputProps) => {\n const field = useFormFieldControl()\n const group = useInputGroup()\n\n const { id, name, isInvalid, isRequired, description } = field\n const {\n hasLeadingAddon,\n hasTrailingAddon,\n hasLeadingIcon,\n hasTrailingIcon,\n hasClearButton,\n onClear,\n } = group\n const Component = asChild ? Slot : 'input'\n const state = field.state || group.state\n const disabled = field.disabled || group.disabled || disabledProp\n const readOnly = field.readOnly || group.readOnly || readOnlyProp\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = event => {\n if (onChange) {\n onChange(event)\n }\n\n if (onValueChange) {\n onValueChange(event.target.value)\n }\n }\n\n const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = event => {\n if (onKeyDown) {\n onKeyDown(event)\n }\n\n if (hasClearButton && onClear && event.key === 'Escape') {\n onClear()\n }\n }\n\n return (\n <Component\n ref={ref}\n id={id}\n name={name}\n className={inputStyles({\n asChild,\n className,\n intent: state,\n hasLeadingAddon: !!hasLeadingAddon,\n hasTrailingAddon: !!hasTrailingAddon,\n hasLeadingIcon: !!hasLeadingIcon,\n hasTrailingIcon: !!hasTrailingIcon,\n hasClearButton: !!hasClearButton,\n })}\n disabled={disabled}\n readOnly={readOnly}\n required={isRequired}\n aria-describedby={description}\n aria-invalid={isInvalid}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n {...others}\n />\n )\n}\n\nexport const Input = Object.assign(Root, {\n id: 'Input',\n})\n\nRoot.displayName = 'Input'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const inputStyles = cva(\n [\n 'relative',\n 'border-sm',\n 'peer',\n 'w-full',\n 'appearance-none outline-hidden',\n 'bg-surface',\n 'text-ellipsis text-body-1 text-on-surface',\n 'caret-neutral',\n 'autofill:shadow-surface autofill:shadow-[inset_0_0_0px_1000px]',\n 'disabled:cursor-not-allowed disabled:border-outline disabled:bg-on-surface/dim-5 disabled:text-on-surface/dim-3',\n 'read-only:cursor-default read-only:pointer-events-none read-only:bg-on-surface/dim-5',\n 'focus:ring-1 focus:ring-inset',\n ],\n {\n variants: {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild: {\n true: ['min-h-sz-44'],\n false: ['h-sz-44'],\n },\n /**\n * Color scheme of the button.\n */\n intent: {\n neutral: [\n 'border-outline',\n 'hover:border-outline-high',\n 'focus:ring-outline-high focus:border-outline-high',\n ],\n success: ['border-success', 'focus:ring-success'],\n alert: ['border-alert', 'focus:ring-alert'],\n error: ['border-error', 'focus:ring-error'],\n },\n /**\n * Sets if there is an addon before the input text.\n */\n hasLeadingAddon: {\n true: ['rounded-l-0'],\n false: ['rounded-l-lg'],\n },\n /**\n * Sets if there is an addon after the input text.\n */\n hasTrailingAddon: {\n true: ['rounded-r-0'],\n false: ['rounded-r-lg'],\n },\n /**\n * Sets if there is an icon before the input text.\n */\n hasLeadingIcon: {\n true: ['pl-3xl'],\n false: ['pl-lg'],\n },\n /**\n * Sets if there is an icon after the input text.\n */\n hasTrailingIcon: { true: '' },\n /**\n * Sets if there is a button to clear the input text.\n */\n hasClearButton: { true: '' },\n },\n compoundVariants: [\n {\n hasTrailingIcon: false,\n hasClearButton: false,\n class: 'pr-lg',\n },\n {\n hasTrailingIcon: true,\n hasClearButton: false,\n class: 'pr-3xl',\n },\n {\n hasTrailingIcon: false,\n hasClearButton: true,\n class: 'pr-3xl',\n },\n {\n hasTrailingIcon: true,\n hasClearButton: true,\n class: 'pr-[calc(var(--spacing-3xl)*2)]',\n },\n ],\n defaultVariants: {\n intent: 'neutral',\n },\n }\n)\n\nexport type InputStylesProps = VariantProps<typeof inputStyles>\n","import { InputClearButton } from './InputClearButton'\nimport { InputGroup as Root } from './InputGroup'\nimport { InputLeadingAddon } from './InputLeadingAddon'\nimport { InputLeadingIcon } from './InputLeadingIcon'\nimport { InputTrailingAddon } from './InputTrailingAddon'\nimport { InputTrailingIcon } from './InputTrailingIcon'\n\nexport * from './Input'\n\nexport const InputGroup: typeof Root & {\n LeadingAddon: typeof InputLeadingAddon\n TrailingAddon: typeof InputTrailingAddon\n LeadingIcon: typeof InputLeadingIcon\n TrailingIcon: typeof InputTrailingIcon\n ClearButton: typeof InputClearButton\n} = Object.assign(Root, {\n LeadingAddon: InputLeadingAddon,\n TrailingAddon: InputTrailingAddon,\n LeadingIcon: InputLeadingIcon,\n TrailingIcon: InputTrailingIcon,\n ClearButton: InputClearButton,\n})\n\nInputGroup.displayName = 'InputGroup'\nInputLeadingAddon.displayName = 'InputGroup.LeadingAddon'\nInputTrailingAddon.displayName = 'InputGroup.TrailingAddon'\nInputLeadingIcon.displayName = 'InputGroup.LeadingIcon'\nInputTrailingIcon.displayName = 'InputGroup.TrailingIcon'\nInputClearButton.displayName = 'InputGroup.ClearButton'\n\nexport { useInputGroup } from './InputGroupContext'\nexport { type InputGroupProps } from './InputGroup'\nexport { type InputLeadingIconProps } from './InputLeadingIcon'\nexport { type InputTrailingIconProps } from './InputTrailingIcon'\nexport { type InputLeadingAddonProps } from './InputLeadingAddon'\nexport { type InputTrailingAddonProps } from './InputTrailingAddon'\nexport { type InputClearButtonProps } from './InputClearButton'\n"],"mappings":";;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,UAAU;;;ACDnB,SAAS,eAAe,kBAAkB;AAenC,IAAM,oBAAoB,cAAsD,IAAI;AAEpF,IAAM,gBAAgB,MAAM;AACjC,QAAM,UAAU,WAAW,iBAAiB;AAE5C,SAAO,WAAW,EAAE,cAAc,KAAK;AACzC;;;ADoBQ;AA7BR,IAAM,OAAO,CAAC,EAAE,WAAW,WAAW,IAAI,SAAS,KAAK,GAAG,OAAO,MAA6B;AAC7F,QAAM,EAAE,SAAS,gBAAgB,IAAI,cAAc;AAEnD,QAAM,cAAoD,WAAS;AACjE,QAAI,SAAS;AACX,cAAQ,KAAK;AAAA,IACf;AAEA,QAAI,SAAS;AACX,cAAQ;AAAA,IACV;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,kBAAkB,uBAAuB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;AAChC,mBAAmB,cAAc;AACjC,iBAAiB,cAAc;AAC/B,kBAAkB,cAAc;AAChC,iBAAiB,cAAc;","names":["jsx","cx","Children","cva","jsx","Children","jsx","Root","cx","cx","cx","jsx","cx","jsx","cx","cx","jsx","Root","cx","cx","jsx","cx","useFormFieldControl","cva","jsx","Root","useFormFieldControl","InputGroup"]}
|
|
1
|
+
{"version":3,"sources":["../src/input/InputClearButton.tsx","../src/input/InputGroupContext.ts","../src/input/InputGroup.tsx","../src/input/InputGroup.styles.ts","../src/input/InputLeadingAddon.tsx","../src/input/InputAddon.tsx","../src/input/InputAddon.styles.ts","../src/input/InputLeadingIcon.tsx","../src/input/InputIcon.tsx","../src/input/InputTrailingAddon.tsx","../src/input/InputTrailingIcon.tsx","../src/input/Input.tsx","../src/input/Input.styles.ts","../src/input/index.ts"],"sourcesContent":["import { DeleteOutline } from '@spark-ui/icons/DeleteOutline'\nimport { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, MouseEventHandler, Ref } from 'react'\n\nimport { Icon } from '../icon'\nimport { useInputGroup } from './InputGroupContext'\n\nexport interface InputClearButtonProps extends ComponentPropsWithoutRef<'button'> {\n 'aria-label': string\n ref?: Ref<HTMLButtonElement>\n}\n\nconst Root = ({ className, tabIndex = -1, onClick, ref, ...others }: InputClearButtonProps) => {\n const { onClear, hasTrailingIcon } = useInputGroup()\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = event => {\n if (onClick) {\n onClick(event)\n }\n\n if (onClear) {\n onClear()\n }\n }\n\n return (\n <button\n ref={ref}\n className={cx(\n className,\n 'pointer-events-auto absolute top-1/2 -translate-y-1/2',\n 'inline-flex h-full items-center justify-center outline-hidden',\n 'text-neutral hover:text-neutral-hovered',\n hasTrailingIcon ? 'right-3xl px-sz-12' : 'pl-md pr-lg right-0'\n )}\n tabIndex={tabIndex}\n onClick={handleClick}\n type=\"button\"\n {...others}\n >\n <Icon size=\"sm\">\n <DeleteOutline />\n </Icon>\n </button>\n )\n}\n\nexport const InputClearButton = Object.assign(Root, {\n id: 'ClearButton',\n})\n\nRoot.displayName = 'InputGroup.ClearButton'\n","import { createContext, useContext } from 'react'\n\nexport interface InputGroupContextValue {\n disabled?: boolean\n readOnly?: boolean\n hasLeadingIcon: boolean\n hasTrailingIcon: boolean\n hasLeadingAddon: boolean\n hasTrailingAddon: boolean\n hasClearButton: boolean\n state: null | undefined | 'error' | 'alert' | 'success'\n isStandalone?: boolean\n onClear: () => void\n}\n\nexport const InputGroupContext = createContext<Partial<InputGroupContextValue> | null>(null)\n\nexport const useInputGroup = () => {\n const context = useContext(InputGroupContext)\n\n return context || { isStandalone: true }\n}\n","/* eslint-disable complexity */\n\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport {\n ChangeEventHandler,\n Children,\n cloneElement,\n ComponentPropsWithoutRef,\n DetailedReactHTMLElement,\n FC,\n isValidElement,\n PropsWithChildren,\n ReactElement,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react'\n\nimport { InputProps } from './Input'\nimport { inputGroupStyles, InputGroupStylesProps } from './InputGroup.styles'\nimport { InputGroupContext } from './InputGroupContext'\n\nexport interface InputGroupProps extends ComponentPropsWithoutRef<'div'>, InputGroupStylesProps {\n /**\n * Use `state` prop to assign a specific state to the group, choosing from: `error`, `alert` and `success`. By doing so, the outline styles will be updated.\n */\n state?: 'error' | 'alert' | 'success'\n /**\n * Function handler to be executed after the input has been cleared.\n */\n onClear?: () => void\n ref?: Ref<HTMLDivElement>\n}\n\nexport const InputGroup = ({\n className,\n children: childrenProp,\n state: stateProp,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n onClear,\n ref: forwardedRef,\n ...others\n}: PropsWithChildren<InputGroupProps>) => {\n const getElementId = (element?: ReactElement) => {\n return element ? (element.type as FC & { id?: string }).id : ''\n }\n\n const findElement = (...values: string[]) => {\n return children.find(child => values.includes(getElementId(child) || ''))\n }\n\n const children = Children.toArray(childrenProp).filter(isValidElement)\n const input = findElement('Input') as\n | DetailedReactHTMLElement<InputProps, HTMLInputElement>\n | undefined\n const props = input?.props || {}\n\n const inputRef = useRef<HTMLInputElement>(null!)\n const onClearRef = useRef(onClear)\n const ref = useMergeRefs<HTMLInputElement>(input?.ref, inputRef)\n const [value, onChange] = useCombinedState(\n props.value as string,\n props.defaultValue as string,\n props.onValueChange\n )\n\n // Data derivated from FormField context\n const field = useFormFieldControl()\n const state = field.state ?? stateProp\n const disabled = field.disabled || !!disabledProp\n const readOnly = field.readOnly || !!readOnlyProp\n\n // InputGroup elements (in visual order)\n const leadingAddon = findElement('LeadingAddon')\n const leadingIcon = findElement('LeadingIcon')\n const clearButton = findElement('ClearButton')\n const trailingIcon = findElement('TrailingIcon')\n const trailingAddon = findElement('TrailingAddon')\n\n // Acknowledge which subComponents are used in the compound context\n const hasLeadingAddon = !!leadingAddon\n const hasTrailingAddon = !!trailingAddon\n const hasLeadingIcon = !!leadingIcon\n const hasTrailingIcon = !!trailingIcon\n const hasClearButton = !!value && !!clearButton && !disabled && !readOnly\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = event => {\n if (props.onChange) {\n props.onChange(event)\n }\n\n onChange(event.target.value)\n }\n\n const handleClear = useCallback(() => {\n if (onClearRef.current) {\n onClearRef.current()\n }\n\n onChange('')\n\n inputRef.current.focus()\n }, [onChange])\n\n const current = useMemo(() => {\n return {\n state,\n disabled,\n readOnly,\n hasLeadingIcon,\n hasTrailingIcon,\n hasLeadingAddon,\n hasTrailingAddon,\n hasClearButton,\n onClear: handleClear,\n }\n }, [\n state,\n disabled,\n readOnly,\n hasLeadingIcon,\n hasTrailingIcon,\n hasLeadingAddon,\n hasTrailingAddon,\n hasClearButton,\n handleClear,\n ])\n\n useEffect(() => {\n onClearRef.current = onClear\n }, [onClear])\n\n return (\n <InputGroupContext.Provider value={current}>\n <div\n ref={forwardedRef}\n className={inputGroupStyles({ disabled, readOnly, className })}\n {...others}\n >\n {hasLeadingAddon && leadingAddon}\n\n <div className=\"relative inline-flex w-full\">\n {input &&\n cloneElement(input, {\n ref,\n defaultValue: undefined,\n value: value ?? '',\n onChange: handleChange,\n })}\n\n {leadingIcon}\n\n {hasClearButton && clearButton}\n\n {trailingIcon}\n </div>\n\n {hasTrailingAddon && trailingAddon}\n </div>\n </InputGroupContext.Provider>\n )\n}\n\nInputGroup.displayName = 'InputGroup'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const inputGroupStyles = cva(['relative inline-flex w-full'], {\n variants: {\n /**\n * When `true`, prevents the user from interacting.\n */\n disabled: {\n true: [\n 'cursor-not-allowed',\n 'relative',\n 'after:absolute',\n 'after:top-0',\n 'after:h-full',\n 'after:w-full',\n 'after:border-sm after:border-outline',\n 'after:rounded-lg',\n ],\n false: 'after:hidden',\n },\n /**\n * Sets the component as interactive or not.\n */\n readOnly: {\n true: [\n 'relative',\n 'after:absolute',\n 'after:top-0',\n 'after:h-full',\n 'after:w-full',\n 'after:border-sm after:border-outline',\n 'after:rounded-lg',\n ],\n false: 'after:hidden',\n },\n },\n})\n\nexport type InputGroupStylesProps = VariantProps<typeof inputGroupStyles>\n","import { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { InputAddon, InputAddonProps } from './InputAddon'\nimport { useInputGroup } from './InputGroupContext'\n\nexport type InputLeadingAddonProps = InputAddonProps & {\n ref?: Ref<HTMLDivElement>\n}\n\nconst Root = ({ className, ref, ...others }: InputLeadingAddonProps) => {\n const { disabled, readOnly } = useInputGroup()\n const isInactive = disabled || readOnly\n\n return (\n <div className={cx('rounded-l-lg', isInactive ? 'bg-on-surface/dim-5' : null)}>\n <InputAddon\n ref={ref}\n className={cx(className, 'rounded-r-0! mr-[-1px] rounded-l-lg')}\n {...others}\n />\n </div>\n )\n}\n\nexport const InputLeadingAddon = Object.assign(Root, {\n id: 'LeadingAddon',\n})\n\nRoot.displayName = 'InputGroup.LeadingAddon'\n","import { Children, type ComponentPropsWithoutRef, type PropsWithChildren, Ref } from 'react'\n\nimport { Slot } from '../slot'\nimport { inputAddonStyles, type InputAddonStylesProps } from './InputAddon.styles'\nimport { useInputGroup } from './InputGroupContext'\n\nexport interface InputAddonProps\n extends ComponentPropsWithoutRef<'div'>,\n Omit<InputAddonStylesProps, 'intent' | 'disabled'> {\n ref?: Ref<HTMLDivElement>\n}\n\nexport const InputAddon = ({\n asChild: asChildProp,\n className,\n children,\n ref,\n ...others\n}: PropsWithChildren<InputAddonProps>) => {\n const { state, disabled, readOnly } = useInputGroup()\n\n const isRawText = typeof children === 'string'\n const asChild = !!(isRawText ? false : asChildProp)\n const child = isRawText ? children : Children.only(children)\n const Component = asChild && !isRawText ? Slot : 'div'\n\n const getDesign = (): InputAddonStylesProps['design'] => {\n if (isRawText) return 'text'\n\n return asChild ? 'solid' : 'inline'\n }\n\n const design = getDesign()\n\n return (\n <Component\n ref={ref}\n className={inputAddonStyles({\n className,\n intent: state,\n disabled,\n readOnly,\n asChild,\n design,\n })}\n {...(disabled && { tabIndex: -1 })}\n {...others}\n >\n {child}\n </Component>\n )\n}\n\nInputAddon.displayName = 'InputGroup.Addon'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const inputAddonStyles = cva(\n [\n 'overflow-hidden',\n 'border-sm',\n 'shrink-0',\n 'h-full',\n 'focus-visible:relative focus-visible:z-raised',\n ],\n {\n variants: {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild: { false: ['flex', 'items-center', 'px-lg'] },\n intent: {\n neutral: 'border-outline',\n error: 'border-error',\n alert: 'border-alert',\n success: 'border-success',\n },\n /**\n * Disable the input addon, preventing user interaction and adding opacity.\n */\n disabled: {\n true: ['pointer-events-none border-outline!'],\n },\n /**\n * Changes input addon styles based on the read only status from the input.\n */\n readOnly: {\n true: ['pointer-events-none'],\n },\n /**\n * Main style of the input addon.\n */\n design: {\n text: '',\n solid: '',\n inline: '',\n },\n },\n compoundVariants: [\n {\n disabled: false,\n readOnly: false,\n design: 'text',\n class: ['bg-surface', 'text-on-surface'],\n },\n {\n disabled: true,\n design: 'text',\n class: ['text-on-surface/dim-3'],\n },\n {\n disabled: true,\n design: ['solid', 'inline'],\n class: ['opacity-dim-3'],\n },\n ],\n defaultVariants: {\n intent: 'neutral',\n },\n }\n)\n\nexport type InputAddonStylesProps = VariantProps<typeof inputAddonStyles>\n","import { cx } from 'class-variance-authority'\n\nimport { InputIcon, InputIconProps } from './InputIcon'\n\nexport type InputLeadingIconProps = InputIconProps\n\nexport const InputLeadingIcon = ({ className, ...others }: InputLeadingIconProps) => (\n <InputIcon className={cx(className, 'left-lg text-body-1')} {...others} />\n)\n\nInputLeadingIcon.id = 'LeadingIcon'\nInputLeadingIcon.displayName = 'InputGroup.LeadingIcon'\n","import { cx } from 'class-variance-authority'\n\nimport { Icon, type IconProps } from '../icon'\nimport { useInputGroup } from './InputGroupContext'\n\nexport type InputIconProps = IconProps\n\nexport const InputIcon = ({ className, intent, children, ...others }: InputIconProps) => {\n const { disabled, readOnly } = useInputGroup()\n const isInactive = disabled || readOnly\n\n return (\n <Icon\n intent={intent}\n className={cx(\n className,\n 'pointer-events-none absolute top-[calc(var(--spacing-sz-44)/2)] -translate-y-1/2',\n intent ? undefined : 'text-neutral peer-focus:text-outline-high',\n isInactive ? 'opacity-dim-3' : undefined\n )}\n {...others}\n >\n {children}\n </Icon>\n )\n}\n\nInputIcon.displayName = 'InputGroup.Icon'\n","import { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { InputAddon, InputAddonProps } from './InputAddon'\nimport { useInputGroup } from './InputGroupContext'\n\nexport type InputTrailingAddonProps = InputAddonProps & {\n ref?: Ref<HTMLDivElement>\n}\n\nconst Root = ({ className, ref, ...others }: InputTrailingAddonProps) => {\n const { disabled, readOnly } = useInputGroup()\n const isInactive = disabled || readOnly\n\n return (\n <div className={cx('rounded-r-lg', isInactive ? 'bg-on-surface/dim-5' : null)}>\n <InputAddon\n ref={ref}\n className={cx(className, 'rounded-l-0! ml-[-1px] rounded-r-lg')}\n {...others}\n />\n </div>\n )\n}\n\nexport const InputTrailingAddon = Object.assign(Root, {\n id: 'TrailingAddon',\n})\n\nRoot.displayName = 'InputGroup.TrailingAddon'\n","import { cx } from 'class-variance-authority'\n\nimport { InputIcon, InputIconProps } from './InputIcon'\n\nexport type InputTrailingIconProps = InputIconProps\n\nexport const InputTrailingIcon = ({ className, ...others }: InputTrailingIconProps) => (\n <InputIcon className={cx(className, 'right-lg text-body-1')} {...others} />\n)\n\nInputTrailingIcon.id = 'TrailingIcon'\nInputTrailingIcon.displayName = 'InputGroup.TrailingIcon'\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { ChangeEventHandler, ComponentPropsWithoutRef, KeyboardEventHandler, Ref } from 'react'\n\nimport { Slot } from '../slot'\nimport { inputStyles } from './Input.styles'\nimport { useInputGroup } from './InputGroupContext'\n\ntype InputPrimitiveProps = ComponentPropsWithoutRef<'input'>\n\nexport interface InputProps extends InputPrimitiveProps {\n asChild?: boolean\n onValueChange?: (value: string) => void\n ref?: Ref<HTMLInputElement>\n}\n\nconst Root = ({\n className,\n asChild = false,\n onValueChange,\n onChange,\n onKeyDown,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n ref,\n ...others\n}: InputProps) => {\n const field = useFormFieldControl()\n const group = useInputGroup()\n\n const { id, name, isInvalid, isRequired, description } = field\n const {\n hasLeadingAddon,\n hasTrailingAddon,\n hasLeadingIcon,\n hasTrailingIcon,\n hasClearButton,\n onClear,\n } = group\n const Component = asChild ? Slot : 'input'\n const state = field.state || group.state\n const disabled = field.disabled || group.disabled || disabledProp\n const readOnly = field.readOnly || group.readOnly || readOnlyProp\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = event => {\n if (onChange) {\n onChange(event)\n }\n\n if (onValueChange) {\n onValueChange(event.target.value)\n }\n }\n\n const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = event => {\n if (onKeyDown) {\n onKeyDown(event)\n }\n\n if (hasClearButton && onClear && event.key === 'Escape') {\n onClear()\n }\n }\n\n return (\n <Component\n ref={ref}\n id={id}\n name={name}\n className={inputStyles({\n asChild,\n className,\n intent: state,\n hasLeadingAddon: !!hasLeadingAddon,\n hasTrailingAddon: !!hasTrailingAddon,\n hasLeadingIcon: !!hasLeadingIcon,\n hasTrailingIcon: !!hasTrailingIcon,\n hasClearButton: !!hasClearButton,\n })}\n disabled={disabled}\n readOnly={readOnly}\n required={isRequired}\n aria-describedby={description}\n aria-invalid={isInvalid}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n {...others}\n />\n )\n}\n\nexport const Input = Object.assign(Root, {\n id: 'Input',\n})\n\nRoot.displayName = 'Input'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const inputStyles = cva(\n [\n 'relative',\n 'border-sm',\n 'peer',\n 'w-full',\n 'appearance-none outline-hidden',\n 'bg-surface',\n 'text-ellipsis text-body-1 text-on-surface',\n 'caret-neutral',\n '[&:-webkit-autofill]:[-webkit-text-fill-color:var(--color-on-surface)]',\n 'autofill:shadow-surface autofill:shadow-[inset_0_0_0px_1000px]',\n 'disabled:cursor-not-allowed disabled:border-outline disabled:bg-on-surface/dim-5 disabled:text-on-surface/dim-3',\n 'read-only:cursor-default read-only:pointer-events-none read-only:bg-on-surface/dim-5',\n 'focus:ring-1 focus:ring-inset',\n ],\n {\n variants: {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild: {\n true: ['min-h-sz-44'],\n false: ['h-sz-44'],\n },\n /**\n * Color scheme of the button.\n */\n intent: {\n neutral: [\n 'border-outline',\n 'hover:border-outline-high',\n 'focus:ring-outline-high focus:border-outline-high',\n ],\n success: ['border-success', 'focus:ring-success'],\n alert: ['border-alert', 'focus:ring-alert'],\n error: ['border-error', 'focus:ring-error'],\n },\n /**\n * Sets if there is an addon before the input text.\n */\n hasLeadingAddon: {\n true: ['rounded-l-0'],\n false: ['rounded-l-lg'],\n },\n /**\n * Sets if there is an addon after the input text.\n */\n hasTrailingAddon: {\n true: ['rounded-r-0'],\n false: ['rounded-r-lg'],\n },\n /**\n * Sets if there is an icon before the input text.\n */\n hasLeadingIcon: {\n true: ['pl-3xl'],\n false: ['pl-lg'],\n },\n /**\n * Sets if there is an icon after the input text.\n */\n hasTrailingIcon: { true: '' },\n /**\n * Sets if there is a button to clear the input text.\n */\n hasClearButton: { true: '' },\n },\n compoundVariants: [\n {\n hasTrailingIcon: false,\n hasClearButton: false,\n class: 'pr-lg',\n },\n {\n hasTrailingIcon: true,\n hasClearButton: false,\n class: 'pr-3xl',\n },\n {\n hasTrailingIcon: false,\n hasClearButton: true,\n class: 'pr-3xl',\n },\n {\n hasTrailingIcon: true,\n hasClearButton: true,\n class: 'pr-[calc(var(--spacing-3xl)*2)]',\n },\n ],\n defaultVariants: {\n intent: 'neutral',\n },\n }\n)\n\nexport type InputStylesProps = VariantProps<typeof inputStyles>\n","import { InputClearButton } from './InputClearButton'\nimport { InputGroup as Root } from './InputGroup'\nimport { InputLeadingAddon } from './InputLeadingAddon'\nimport { InputLeadingIcon } from './InputLeadingIcon'\nimport { InputTrailingAddon } from './InputTrailingAddon'\nimport { InputTrailingIcon } from './InputTrailingIcon'\n\nexport * from './Input'\n\nexport const InputGroup: typeof Root & {\n LeadingAddon: typeof InputLeadingAddon\n TrailingAddon: typeof InputTrailingAddon\n LeadingIcon: typeof InputLeadingIcon\n TrailingIcon: typeof InputTrailingIcon\n ClearButton: typeof InputClearButton\n} = Object.assign(Root, {\n LeadingAddon: InputLeadingAddon,\n TrailingAddon: InputTrailingAddon,\n LeadingIcon: InputLeadingIcon,\n TrailingIcon: InputTrailingIcon,\n ClearButton: InputClearButton,\n})\n\nInputGroup.displayName = 'InputGroup'\nInputLeadingAddon.displayName = 'InputGroup.LeadingAddon'\nInputTrailingAddon.displayName = 'InputGroup.TrailingAddon'\nInputLeadingIcon.displayName = 'InputGroup.LeadingIcon'\nInputTrailingIcon.displayName = 'InputGroup.TrailingIcon'\nInputClearButton.displayName = 'InputGroup.ClearButton'\n\nexport { useInputGroup } from './InputGroupContext'\nexport { type InputGroupProps } from './InputGroup'\nexport { type InputLeadingIconProps } from './InputLeadingIcon'\nexport { type InputTrailingIconProps } from './InputTrailingIcon'\nexport { type InputLeadingAddonProps } from './InputLeadingAddon'\nexport { type InputTrailingAddonProps } from './InputTrailingAddon'\nexport { type InputClearButtonProps } from './InputClearButton'\n"],"mappings":";;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,UAAU;;;ACDnB,SAAS,eAAe,kBAAkB;AAenC,IAAM,oBAAoB,cAAsD,IAAI;AAEpF,IAAM,gBAAgB,MAAM;AACjC,QAAM,UAAU,WAAW,iBAAiB;AAE5C,SAAO,WAAW,EAAE,cAAc,KAAK;AACzC;;;ADoBQ;AA7BR,IAAM,OAAO,CAAC,EAAE,WAAW,WAAW,IAAI,SAAS,KAAK,GAAG,OAAO,MAA6B;AAC7F,QAAM,EAAE,SAAS,gBAAgB,IAAI,cAAc;AAEnD,QAAM,cAAoD,WAAS;AACjE,QAAI,SAAS;AACX,cAAQ,KAAK;AAAA,IACf;AAEA,QAAI,SAAS;AACX,cAAQ;AAAA,IACV;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,kBAAkB,uBAAuB;AAAA,MAC3C;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,MAAK;AAAA,MACJ,GAAG;AAAA,MAEJ,8BAAC,QAAK,MAAK,MACT,8BAAC,iBAAc,GACjB;AAAA;AAAA,EACF;AAEJ;AAEO,IAAM,mBAAmB,OAAO,OAAO,MAAM;AAAA,EAClD,IAAI;AACN,CAAC;AAED,KAAK,cAAc;;;AEjDnB,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAC7B;AAAA,EAEE;AAAA,EACA;AAA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A,IAClC;AAAA,EACF;AAEA,QAAM,gBAAwD,WAAS;AACrE,QAAI,WAAW;AACb,gBAAU,KAAK;AAAA,IACjB;AAEA,QAAI,kBAAkB,WAAW,MAAM,QAAQ,UAAU;AACvD,cAAQ;AAAA,IACV;AAAA,EACF;AAEA,SACE,gBAAAF;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW,YAAY;AAAA,QACrB;AAAA,QACA;AAAA,QACA,QAAQ;AAAA,QACR,iBAAiB,CAAC,CAAC;AAAA,QACnB,kBAAkB,CAAC,CAAC;AAAA,QACpB,gBAAgB,CAAC,CAAC;AAAA,QAClB,iBAAiB,CAAC,CAAC;AAAA,QACnB,gBAAgB,CAAC,CAAC;AAAA,MACpB,CAAC;AAAA,MACD;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACV,oBAAkB;AAAA,MAClB,gBAAc;AAAA,MACd,UAAU;AAAA,MACV,WAAW;AAAA,MACV,GAAG;AAAA;AAAA,EACN;AAEJ;AAEO,IAAM,QAAQ,OAAO,OAAOC,OAAM;AAAA,EACvC,IAAI;AACN,CAAC;AAEDA,MAAK,cAAc;;;AErFZ,IAAME,cAMT,OAAO,OAAO,YAAM;AAAA,EACtB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,aAAa;AAAA,EACb,cAAc;AAAA,EACd,aAAa;AACf,CAAC;AAEDA,YAAW,cAAc;AACzB,kBAAkB,cAAc;AAChC,mBAAmB,cAAc;AACjC,iBAAiB,cAAc;AAC/B,kBAAkB,cAAc;AAChC,iBAAiB,cAAc;","names":["jsx","cx","Children","cva","jsx","Children","jsx","Root","cx","cx","cx","jsx","cx","jsx","cx","cx","jsx","Root","cx","cx","jsx","cx","useFormFieldControl","cva","jsx","Root","useFormFieldControl","InputGroup"]}
|
|
@@ -148,7 +148,7 @@ declare const Disclosure: {
|
|
|
148
148
|
interface EmptyProps {
|
|
149
149
|
className?: string;
|
|
150
150
|
children: ReactNode;
|
|
151
|
-
ref?: Ref<
|
|
151
|
+
ref?: Ref<HTMLLIElement>;
|
|
152
152
|
}
|
|
153
153
|
declare const Empty: {
|
|
154
154
|
({ className, children, ref: forwardedRef }: EmptyProps): react_jsx_runtime.JSX.Element | null;
|
package/dist/combobox/index.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ declare const Disclosure: {
|
|
|
148
148
|
interface EmptyProps {
|
|
149
149
|
className?: string;
|
|
150
150
|
children: ReactNode;
|
|
151
|
-
ref?: Ref<
|
|
151
|
+
ref?: Ref<HTMLLIElement>;
|
|
152
152
|
}
|
|
153
153
|
declare const Empty: {
|
|
154
154
|
({ className, children, ref: forwardedRef }: EmptyProps): react_jsx_runtime.JSX.Element | null;
|
package/dist/combobox/index.js
CHANGED
|
@@ -1836,9 +1836,11 @@ var Empty = ({ className, children, ref: forwardedRef }) => {
|
|
|
1836
1836
|
const ctx = useComboboxContext();
|
|
1837
1837
|
const hasNoItemVisible = ctx.filteredItemsMap.size === 0;
|
|
1838
1838
|
return hasNoItemVisible ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1839
|
-
"
|
|
1839
|
+
"li",
|
|
1840
1840
|
{
|
|
1841
1841
|
ref: forwardedRef,
|
|
1842
|
+
role: "option",
|
|
1843
|
+
"aria-selected": false,
|
|
1842
1844
|
className: (0, import_class_variance_authority12.cx)("px-lg py-md text-body-1 text-on-surface/dim-1", className),
|
|
1843
1845
|
children
|
|
1844
1846
|
}
|
|
@@ -1924,7 +1926,12 @@ var Input = ({
|
|
|
1924
1926
|
ctx.setInputValue(ctx.selectedItem.text);
|
|
1925
1927
|
}
|
|
1926
1928
|
}, []);
|
|
1927
|
-
const
|
|
1929
|
+
const PopoverTrigger = ctx.hasPopover ? Popover2.Trigger : import_react10.Fragment;
|
|
1930
|
+
const popoverTriggerProps = ctx.hasPopover ? {
|
|
1931
|
+
asChild: true,
|
|
1932
|
+
type: void 0,
|
|
1933
|
+
"aria-haspopup": void 0
|
|
1934
|
+
} : {};
|
|
1928
1935
|
const multiselectInputProps = ctx.getDropdownProps();
|
|
1929
1936
|
const inputRef = (0, import_use_merge_refs2.useMergeRefs)(forwardedRef, ctx.innerInputRef, multiselectInputProps.ref);
|
|
1930
1937
|
const downshiftInputProps = ctx.getInputProps({
|