@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
1 lines • 4.57 kB
Source Map (JSON)
{"version":3,"file":"infinite-scroll-area.cjs","names":["createSlotComponent","infiniteScrollAreaStyle","useInfiniteScroll","useValue","styled","mergeRefs"],"sources":["../../../../src/components/infinite-scroll-area/infinite-scroll-area.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { InfiniteScrollAreaStyle } from \"./infinite-scroll-area.style\"\nimport type { UseInfiniteScrollProps } from \"./use-infinite-scroll\"\nimport { useRef } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { useValue } from \"../../hooks/use-value\"\nimport { mergeRefs } from \"../../utils\"\nimport { infiniteScrollAreaStyle } from \"./infinite-scroll-area.style\"\nimport { useInfiniteScroll } from \"./use-infinite-scroll\"\n\nexport interface InfiniteScrollAreaProps\n extends Omit<HTMLStyledProps, keyof UseInfiniteScrollProps>,\n Omit<UseInfiniteScrollProps, \"orientation\">,\n ThemeProps<InfiniteScrollAreaStyle> {\n /**\n * The infinite scroll area finish to use.\n */\n finish?: ReactNode\n /**\n * The infinite scroll area loading to use.\n */\n loading?: ReactNode\n /**\n * Props for infinite scroll area trigger component.\n */\n triggerProps?: HTMLStyledProps\n}\n\nconst {\n PropsContext: InfiniteScrollAreaPropsContext,\n usePropsContext: useInfiniteScrollAreaPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<InfiniteScrollAreaProps, InfiniteScrollAreaStyle>(\n \"infinite-scroll-area\",\n infiniteScrollAreaStyle,\n)\n\nexport { InfiniteScrollAreaPropsContext, useInfiniteScrollAreaPropsContext }\n\n/**\n * `InfiniteScrollArea` is for providing infinite scroll functionality.\n * This feature provides a smooth scrolling experience by automatically loading and displaying the next dataset when the user reaches the end of the page.\n *\n * @see https://yamada-ui.com/docs/components/infinite-scroll-area\n */\nexport const InfiniteScrollArea = withProvider<\n \"div\",\n InfiniteScrollAreaProps,\n \"orientation\"\n>(\n ({\n ref,\n children,\n disabled,\n finish: finishProp,\n indexRef,\n initialLoad,\n loading,\n orientation: orientationProp,\n resetRef,\n reverse,\n rootMargin,\n rootRef: rootRefProp,\n startIndex,\n threshold,\n triggerProps,\n onLoad,\n ...rest\n }) => {\n const rootRef = useRef<HTMLDivElement>(null)\n const orientation = useValue(orientationProp)\n const { ref: triggerRef, finish } = useInfiniteScroll({\n disabled,\n indexRef,\n initialLoad,\n orientation,\n resetRef,\n reverse,\n rootMargin,\n rootRef: rootRefProp ?? rootRef,\n startIndex,\n threshold,\n onLoad,\n })\n const hasFinish = !!finishProp\n const showTrigger = !disabled && (hasFinish || !finish)\n\n return (\n <styled.div\n ref={mergeRefs(rootRef, ref)}\n aria-busy=\"false\"\n role=\"feed\"\n {...rest}\n >\n {reverse && showTrigger ? (\n <InfiniteScrollTrigger ref={triggerRef} {...triggerProps}>\n {finish ? finishProp : loading}\n </InfiniteScrollTrigger>\n ) : null}\n\n {children}\n\n {!reverse && showTrigger ? (\n <InfiniteScrollTrigger ref={triggerRef} {...triggerProps}>\n {finish ? finishProp : loading}\n </InfiniteScrollTrigger>\n ) : null}\n </styled.div>\n )\n },\n \"root\",\n { transferProps: [\"orientation\"] },\n)()\n\ninterface InfiniteScrollTriggerProps extends HTMLStyledProps {}\n\nconst InfiniteScrollTrigger = withContext<\"div\", InfiniteScrollTriggerProps>(\n \"div\",\n \"trigger\",\n)()\n"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAM,EACJ,cAAc,gCACd,iBAAiB,mCACjB,aACA,iBACEA,6CACF,wBACAC,2DACD;;;;;;;AAUD,MAAa,qBAAqB,cAK/B,EACC,KACA,UACA,UACA,QAAQ,YACR,UACA,aACA,SACA,aAAa,iBACb,UACA,SACA,YACA,SAAS,aACT,YACA,WACA,cACA,OACA,GAAG,WACC;CACJ,MAAM,4BAAiC,KAAK;CAE5C,MAAM,EAAE,KAAK,YAAY,WAAWC,8CAAkB;EACpD;EACA;EACA;EACA,aALkBC,uCAAS,gBAAgB;EAM3C;EACA;EACA;EACA,SAAS,eAAe;EACxB;EACA;EACA;EACD,CAAC;CAEF,MAAM,cAAc,CAAC,aADH,CAAC,CAAC,cAC2B,CAAC;AAEhD,QACE,4CAACC,uBAAO;EACN,KAAKC,sBAAU,SAAS,IAAI;EAC5B,aAAU;EACV,MAAK;EACL,GAAI;;GAEH,WAAW,cACV,2CAAC;IAAsB,KAAK;IAAY,GAAI;cACzC,SAAS,aAAa;KACD,GACtB;GAEH;GAEA,CAAC,WAAW,cACX,2CAAC;IAAsB,KAAK;IAAY,GAAI;cACzC,SAAS,aAAa;KACD,GACtB;;GACO;GAGjB,QACA,EAAE,eAAe,CAAC,cAAc,EAAE,CACnC,EAAE;AAIH,MAAM,wBAAwB,YAC5B,OACA,UACD,EAAE"}