@primereact/headless 11.0.0-alpha.7 → 11.0.0-alpha.9
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/breadcrumb/index.d.ts +2 -0
- package/breadcrumb/index.mjs +2 -0
- package/breadcrumb/index.mjs.map +1 -0
- package/breadcrumb/useBreadcrumb.d.ts +3 -0
- package/breadcrumb/useBreadcrumb.props.d.ts +2 -0
- package/breadcrumb/useBreadcrumb.test.d.ts +0 -0
- package/carousel/index.mjs +1 -1
- package/carousel/index.mjs.map +1 -1
- package/carousel/useCarousel.d.ts +18 -18
- package/colorpicker/colorManager.d.ts +101 -0
- package/colorpicker/index.d.ts +3 -0
- package/colorpicker/index.mjs +2 -0
- package/colorpicker/index.mjs.map +1 -0
- package/colorpicker/input/index.d.ts +2 -0
- package/colorpicker/input/index.mjs +2 -0
- package/colorpicker/input/index.mjs.map +1 -0
- package/colorpicker/input/useColorPickerInput.d.ts +11 -0
- package/colorpicker/input/useColorPickerInput.props.d.ts +2 -0
- package/colorpicker/input/useColorPickerInput.test.d.ts +0 -0
- package/colorpicker/slider/index.d.ts +2 -0
- package/colorpicker/slider/index.mjs +2 -0
- package/colorpicker/slider/index.mjs.map +1 -0
- package/colorpicker/slider/useColorPickerSlider.d.ts +13 -0
- package/colorpicker/slider/useColorPickerSlider.props.d.ts +2 -0
- package/colorpicker/slider/useColorPickerSlider.test.d.ts +0 -0
- package/colorpicker/useColorPicker.d.ts +26 -0
- package/colorpicker/useColorPicker.props.d.ts +2 -0
- package/colorpicker/useColorPicker.test.d.ts +0 -0
- package/commandmenu/index.d.ts +2 -0
- package/commandmenu/index.mjs +2 -0
- package/commandmenu/index.mjs.map +1 -0
- package/commandmenu/useCommandMenu.d.ts +11 -0
- package/commandmenu/useCommandMenu.props.d.ts +2 -0
- package/commandmenu/useCommandMenu.test.d.ts +0 -0
- package/contextmenu/index.d.ts +2 -0
- package/contextmenu/index.mjs +2 -0
- package/contextmenu/index.mjs.map +1 -0
- package/contextmenu/useContextMenu.d.ts +1 -0
- package/contextmenu/useContextMenu.props.d.ts +2 -0
- package/contextmenu/useContextMenu.test.d.ts +0 -0
- package/datepicker/index.d.ts +2 -0
- package/datepicker/index.mjs +2 -0
- package/datepicker/index.mjs.map +1 -0
- package/datepicker/useDatePicker.d.ts +114 -0
- package/datepicker/useDatePicker.props.d.ts +2 -0
- package/datepicker/useDatePicker.test.d.ts +0 -0
- package/gallery/index.mjs +1 -1
- package/gallery/index.mjs.map +1 -1
- package/gallery/item/index.mjs +1 -1
- package/gallery/item/index.mjs.map +1 -1
- package/gallery/useGallery.d.ts +2 -8
- package/inputtags/index.d.ts +2 -0
- package/inputtags/index.mjs +2 -0
- package/inputtags/index.mjs.map +1 -0
- package/inputtags/useInputTags.d.ts +20 -0
- package/inputtags/useInputTags.props.d.ts +2 -0
- package/inputtags/useInputTags.test.d.ts +0 -0
- package/listbox/index.d.ts +2 -0
- package/listbox/index.mjs +2 -0
- package/listbox/index.mjs.map +1 -0
- package/listbox/useListbox.d.ts +45 -0
- package/listbox/useListbox.props.d.ts +2 -0
- package/listbox/useListbox.test.d.ts +0 -0
- package/menu/index.d.ts +2 -0
- package/menu/index.mjs +2 -0
- package/menu/index.mjs.map +1 -0
- package/menu/sub/index.d.ts +2 -0
- package/menu/sub/index.mjs +2 -0
- package/menu/sub/index.mjs.map +1 -0
- package/menu/sub/useMenuSub.d.ts +19 -0
- package/menu/sub/useMenuSub.props.d.ts +2 -0
- package/menu/useMenu.d.ts +34 -0
- package/menu/useMenu.props.d.ts +2 -0
- package/menu/useMenu.test.d.ts +0 -0
- package/orgchart/index.d.ts +2 -0
- package/orgchart/index.mjs +2 -0
- package/orgchart/index.mjs.map +1 -0
- package/orgchart/useOrgChart.d.ts +20 -0
- package/orgchart/useOrgChart.props.d.ts +2 -0
- package/orgchart/useOrgChart.test.d.ts +0 -0
- package/overlay/index.d.ts +2 -0
- package/overlay/index.mjs +2 -0
- package/overlay/index.mjs.map +1 -0
- package/overlay/useOverlay.d.ts +16 -0
- package/overlay/useOverlay.props.d.ts +2 -0
- package/overlay/useOverlay.test.d.ts +0 -0
- package/package.json +4 -4
- package/password/index.d.ts +2 -0
- package/password/index.mjs +2 -0
- package/password/index.mjs.map +1 -0
- package/password/usePassword.d.ts +35 -0
- package/password/usePassword.props.d.ts +2 -0
- package/password/usePassword.test.d.ts +0 -0
- package/placer/index.mjs +1 -1
- package/placer/index.mjs.map +1 -1
- package/toast/index.d.ts +1 -0
- package/toast/index.mjs +1 -1
- package/toast/index.mjs.map +1 -1
- package/toast/item/index.css +1 -1
- package/toast/item/index.css.map +1 -1
- package/toast/item/index.mjs +1 -1
- package/toast/item/index.mjs.map +1 -1
- package/toast/item/useToastItem.d.ts +12 -8
- package/toast/toastStore.d.ts +40 -0
- package/toast/useToast.d.ts +12 -4
- package/tree/TreeDragDropService.d.ts +24 -0
- package/tree/index.d.ts +3 -0
- package/tree/index.mjs +2 -0
- package/tree/index.mjs.map +1 -0
- package/tree/useTree.d.ts +27 -0
- package/tree/useTree.props.d.ts +2 -0
- package/tree/useTree.test.d.ts +0 -0
- package/toast/index.css +0 -2
- package/toast/index.css.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{withHeadless as n}from"@primereact/core/headless";var r={onAction:void 0};var p=n({name:"useBreadcrumb",defaultProps:r,setup({props:e}){return{onAction:(o,t)=>{e.onAction&&(o.preventDefault(),e.onAction(t))}}}});export{r as defaultProps,p as useBreadcrumb};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/breadcrumb/useBreadcrumb.ts","../../src/breadcrumb/useBreadcrumb.props.ts"],"sourcesContent":["import { withHeadless } from '@primereact/core/headless';\nimport { defaultProps } from './useBreadcrumb.props';\n\nexport const useBreadcrumb = withHeadless({\n name: 'useBreadcrumb',\n defaultProps,\n setup({ props }) {\n const onAction = (event: React.MouseEvent, key: string) => {\n if (props.onAction) {\n event.preventDefault();\n props.onAction(key);\n }\n };\n\n return { onAction };\n }\n});\n","import type { useBreadcrumbProps } from '@primereact/types/shared/breadcrumb';\n\nexport const defaultProps: useBreadcrumbProps = {\n onAction: undefined\n};\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,4BCEtB,IAAMC,EAAmC,CAC5C,SAAU,MACd,EDDO,IAAMC,EAAgBC,EAAa,CACtC,KAAM,gBACN,aAAAC,EACA,MAAM,CAAE,MAAAC,CAAM,EAAG,CAQb,MAAO,CAAE,SAPQ,CAACC,EAAyBC,IAAgB,CACnDF,EAAM,WACNC,EAAM,eAAe,EACrBD,EAAM,SAASE,CAAG,EAE1B,CAEkB,CACtB,CACJ,CAAC","names":["withHeadless","defaultProps","useBreadcrumb","withHeadless","defaultProps","props","event","key"]}
|
|
File without changes
|
package/carousel/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{withHeadless as
|
|
1
|
+
import{withHeadless as te}from"@primereact/core/headless";import*as i from"react";var B={orientation:"horizontal",align:"start",loop:!1,snapType:"mandatory",spacing:16,autoSize:!1,slidesPerPage:1,slide:void 0,onSlideChange:void 0,defaultPage:0,page:void 0,onPageChange:void 0};var D="[data-item]";function ne(n,v){if(n.size!==v.size)return!1;for(let g of n)if(!v.has(g))return!1;return!0}var ae=te({name:"useCarousel",defaultProps:B,setup({props:n}){var q,W;let[v,g]=i.useState(!1),[O,F]=i.useState(!1),[H,k]=i.useState(!1),[f,J]=i.useState(new Set),[m,G]=i.useState((W=(q=n.page)!=null?q:n.defaultPage)!=null?W:0),l=i.useRef(null),u=i.useRef(new Set),y=i.useRef([]),I=i.useRef(!1),b=i.useRef(null),T=i.useRef(null),S=i.useRef(null),h=i.useRef(null),z=i.useRef(null),x=i.useRef({x:0,y:0}),E=i.useRef(!1);function M(){let t=l.current;if(!t)return[];let e=n.orientation!=="vertical",r=e?t.clientWidth:t.clientHeight,a=Math.max(0,e?t.scrollWidth-r:t.scrollHeight-r),o=[];y.current=[],t.querySelectorAll(D).forEach(c=>{let R=e?c.offsetLeft:c.offsetTop,N=e?c.clientWidth:c.clientHeight,A=R;n.align==="center"?A=R-(r-N)/2:n.align==="end"&&(A=R-(r-N));let $=Math.max(0,Math.min(A,a));y.current.push($),o.push($)});let s=new Set(o.map(Number));ne(f,s)||(u.current=s,J(s))}function w(t){var e,r;if(!n.loop){let a=u.current.size||f.size,o=!1,s=!1;t===0&&(s=!0),t===a-1&&(o=!0),F(o),k(s)}G(t),(e=n.onPageChange)==null||e.call(n,{value:t}),(r=n.onSlideChange)==null||r.call(n,{value:t})}function P(){let t=l.current,e=u.current;if(!t||e.size===0)return;let r=n.orientation==="horizontal"?t.scrollLeft:t.scrollTop,a=Array.from(e).reduce((s,c)=>Math.abs(c-r)<Math.abs(s-r)?c:s,1/0),o=Array.from(e).indexOf(a);return w(o),o}function d(t,e=!1){let r=u.current;if(r.size===0)return;let a=t!=null?t:m,o=n.loop?(a+r.size)%r.size:Math.max(0,Math.min(a,r.size-1));w(o),C(Array.from(r)[o],e)}function U(){d(m+1)}function _(){d(m-1)}function C(t,e=!1){let r=l.current;r&&r.scrollTo({[n.orientation==="horizontal"?"left":"top"]:t,behavior:e?"instant":"smooth"})}function X(t){let e=u.current,r=y.current;if(e.size===0||r.length===0)return;let a=Math.max(0,Math.min(t,r.length-1)),o=r[a];C(o);let s=Array.from(e).indexOf(o);w(s)}i.useLayoutEffect(()=>{let t=l.current;if(t)return S.current=new ResizeObserver(()=>{M();let e=P();d(e!=null?e:m,!0)}),S.current.observe(t),t.querySelectorAll(D).forEach(e=>{var r;return(r=S.current)==null?void 0:r.observe(e)}),M(),()=>{var e;(e=S.current)==null||e.disconnect(),S.current=null}},[]),i.useLayoutEffect(()=>{var e;I.current||(u.current.size||f.size)===0||(I.current=!0,d((e=n.defaultPage)!=null?e:0,!0))},[f,n.page,n.defaultPage]),i.useEffect(()=>{n.page===void 0||n.page===null||n.slide!==void 0||n.slide!==null||u.current.size===0&&f.size===0||d(n.page)},[n.page,f]),i.useEffect(()=>{n.slide===void 0||n.slide===null||u.current.size===0&&f.size===0||X(n.slide)},[n.slide]),i.useEffect(()=>{let t=l.current;if(t)return b.current=new MutationObserver(e=>{e.forEach(()=>{M(),requestAnimationFrame(()=>{let r=P();d(r!=null?r:m,!0)})})}),b.current.observe(t,{childList:!0,subtree:!0}),()=>{var e;(e=b.current)==null||e.disconnect(),b.current=null}},[]),i.useEffect(()=>{let t=l.current;if(t)return T.current=new IntersectionObserver(e=>{e.forEach(r=>{r.isIntersecting?r.target.setAttribute("data-inview","true"):r.target.setAttribute("data-inview","false")})},{root:l.current,threshold:.6}),t.querySelectorAll(D).forEach(e=>{var r;return(r=T.current)==null?void 0:r.observe(e)}),()=>{var e;(e=T.current)==null||e.disconnect(),T.current=null}},[]),i.useEffect(()=>{let t=l.current;if(!t)return;let e=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{P()},80)};return e(),t.addEventListener("scroll",e,{passive:!0}),()=>{h.current&&clearTimeout(h.current),h.current=null,t.removeEventListener("scroll",e)}},[]);function j(t){t.button===0&&t.pointerType!=="touch"&&(g(!0),x.current={x:t.clientX,y:t.clientY},E.current=!1)}function K(t){var s,c;let e=l.current;if(!v||!e||t.pointerType==="touch")return;let r=t.clientX-x.current.x,a=t.clientY-x.current.y;Math.abs(r)+Math.abs(a)<6||((c=(s=window.getSelection())==null?void 0:s.toString().length)!=null?c:0)>0||(t.currentTarget.setPointerCapture(t.pointerId),e.style.userSelect="none",E.current=!0,e.style.scrollSnapType="none",e.scrollBy({left:-t.movementX,top:-t.movementY,behavior:"instant"}),t.preventDefault())}function Q(t){if(g(!1),t.currentTarget.releasePointerCapture(t.pointerId),!E.current)return;let e=l.current;if(!e)return;e.style.userSelect="";let r=n.orientation==="horizontal"?e.scrollLeft:e.scrollTop,a=u.current,o=Array.from(a).reduce((c,R)=>Math.abs(R-r)<Math.abs(c-r)?R:c,1/0),s=Array.from(a).indexOf(o);requestAnimationFrame(()=>{o!==void 0&&d(s),requestAnimationFrame(()=>{e.style.scrollSnapType=Y()})})}function V(t){z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{let e=n.orientation==="horizontal"?t.deltaX||t.deltaY:t.deltaY||t.deltaX;e>0&&O||e<0&&H||P()},80)}let Y=()=>{var e;return`${n.orientation==="vertical"?"y":"x"} ${(e=n.snapType)!=null?e:"mandatory"}`},Z={position:"relative",scrollSnapType:Y(),overflowX:n.orientation==="vertical"?"":"scroll",overflowY:n.orientation==="horizontal"?"":"scroll",scrollbarWidth:"none",overscrollBehaviorX:n.orientation==="vertical"?"":"contain",overscrollBehaviorY:n.orientation==="horizontal"?"":"contain",display:"flex",flexDirection:n.orientation==="horizontal"?"":"column","--spacing":n.spacing+"px",gap:"var(--spacing)"},L=n.slidesPerPage&&n.slidesPerPage>0?n.slidesPerPage:1,p=n.autoSize?"auto":`calc(100% /${L} - var(--spacing) * (${L} - 1) / ${L})`,ee={scrollSnapAlign:n.align,flexGrow:0,flexShrink:0,minWidth:0,flexBasis:p};return{state:{swiping:v,isNextDisabled:O,isPrevDisabled:H,snapPoints:f,page:m},contentStyles:Z,itemStyles:ee,contentRef:l,onContentPointerDown:j,onContentPointerMove:K,onContentPointerUp:Q,onContentWheel:V,next:U,prev:_,scrollToPage:d,scrollTo:C,scrollToSlide:X,setToClosest:P}}});export{B as defaultProps,ae as useCarousel};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/carousel/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/carousel/useCarousel.ts","../../src/carousel/useCarousel.props.ts"],"sourcesContent":["import { withHeadless } from '@primereact/core/headless';\nimport * as React from 'react';\nimport { defaultProps } from './useCarousel.props';\n\ntype CarouselAnimation = {\n start: () => void;\n stop: () => void;\n reset: () => void;\n};\n\nfunction useCarouselAnimation(update: () => void, render: (alpha: number) => void): CarouselAnimation {\n const frameId = React.useRef(0);\n const lastTimeStamp = React.useRef<number | null>(null);\n const accTime = React.useRef(0);\n const fixedStep = 1000 / 60;\n\n const animate = (timeStamp: number) => {\n if (!frameId.current) return;\n\n if (!lastTimeStamp.current) {\n lastTimeStamp.current = timeStamp;\n update();\n update();\n }\n\n const timeElapsed = timeStamp - lastTimeStamp.current;\n\n lastTimeStamp.current = timeStamp;\n accTime.current += timeElapsed;\n\n while (accTime.current >= fixedStep) {\n update();\n accTime.current -= fixedStep;\n }\n\n const alpha = accTime.current / fixedStep;\n\n render(alpha);\n\n if (frameId.current) frameId.current = requestAnimationFrame(animate);\n };\n\n const start = () => {\n if (!frameId.current) frameId.current = requestAnimationFrame(animate);\n };\n\n const stop = () => {\n cancelAnimationFrame(frameId.current);\n frameId.current = 0;\n lastTimeStamp.current = null;\n accTime.current = 0;\n };\n\n function reset(): void {\n lastTimeStamp.current = null;\n accTime.current = 0;\n }\n\n React.useEffect(() => {\n const handleVisibilityChange = () => {\n if (document.hidden) {\n reset();\n }\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange);\n };\n }, []);\n\n React.useEffect(() => {\n return () => stop();\n }, []);\n\n return { start, stop, reset };\n}\n\nconst DAMPENING_FACTOR = 0.5;\n\nconst applyDampening = (delta: number) => {\n const distance = Math.abs(delta);\n\n const threshold = 20;\n\n if (distance <= threshold) {\n return delta;\n }\n\n const overflow = distance - threshold;\n\n const maxStretch = 80 / DAMPENING_FACTOR;\n\n const dampened = threshold + (maxStretch * overflow) / (overflow + maxStretch);\n\n return Math.sign(delta) * dampened;\n};\n\ntype SwipeDirection = 1 | -1 | 0;\ntype LoopPoint = { index: number; loopPoint: number; target: () => number };\n\nexport const useCarousel = withHeadless({\n name: 'useCarousel',\n defaultProps,\n setup({ props }) {\n const { loop, orientation, align, slide, onSlideChange } = props;\n const [isSwiping, setIsSwiping] = React.useState(false);\n const [activeIndex, setActiveIndex] = React.useState(slide || 0);\n const [slideSizes, setSlideSizes] = React.useState<number[]>([]);\n const [canLoop, setCanLoop] = React.useState<boolean>(loop || false);\n const [snaps, setSnaps] = React.useState<number[]>([]);\n const [scrollSnaps, setScrollSnaps] = React.useState<number[]>([]);\n const [snapPoints, setSnapPoints] = React.useState<number[]>([]);\n const [slidesLength, setSlidesLength] = React.useState<number>(0);\n const [viewSize, setViewSize] = React.useState<number>(0);\n const [prevDisabled, setPrevDisabled] = React.useState<boolean>(false);\n const [nextDisabled, setNextDisabled] = React.useState<boolean>(false);\n\n const loopPointsRef = React.useRef<LoopPoint[]>([]);\n const swipeDirectionRef = React.useRef<SwipeDirection>(0);\n const prevDeltaRef = React.useRef<number>(0);\n const carouselRef = React.useRef<HTMLDivElement>(null);\n const slideRefs = React.useRef<(HTMLDivElement | null)[]>([]);\n const swipeStartTimeRef = React.useRef<number | null>(null);\n const swipeStartPointerRef = React.useRef<{ x: number; y: number } | null>(null);\n const prevSwipeAmountRef = React.useRef<number>(0);\n const recentSwipeRef = React.useRef<{ time: number; startX: number; startY: number; moved: boolean } | null>(null);\n\n const previousPosition = React.useRef(0);\n const position = React.useRef(0);\n const target = React.useRef(0);\n\n const velocity = 0.09;\n\n const update = () => {\n previousPosition.current = position.current;\n\n const delta = target.current - position.current;\n\n if (Math.abs(delta) < 0.5) {\n position.current = target.current;\n animate.stop();\n\n return;\n }\n\n position.current += delta * velocity;\n };\n\n const render = (alpha: number) => {\n const value = position.current * alpha + previousPosition.current * (1 - alpha);\n\n if (canLoop) {\n normalizeSwipeAmount(value);\n } else {\n setSwipeAmount(value);\n }\n };\n\n const animate = useCarouselAnimation(update, render);\n\n const isVertical = React.useMemo(() => orientation === 'vertical', [orientation]);\n const contentSize = React.useMemo(() => -snaps[snaps.length - 1] + slideSizes[slidesLength - 1], [snaps, slideSizes, slidesLength]);\n const { minOffset, maxOffset } = React.useMemo(() => {\n if (!canLoop) {\n return {\n minOffset: snaps[snaps.length - 1] + viewSize - slideSizes[slideSizes.length - 1],\n maxOffset: snaps[0]\n };\n } else {\n return { minOffset: scrollSnaps[scrollSnaps.length - 1] - slideSizes[slideSizes.length - 1], maxOffset: scrollSnaps[0] };\n }\n }, [scrollSnaps, snaps, slideSizes, canLoop, viewSize]);\n\n const calculateSnaps = React.useCallback(() => {\n if (!slideRefs.current || viewSize === 0 || !carouselRef.current || viewSize === 0 || contentSize === 0) return;\n\n const container = carouselRef.current;\n const containerRect = container.getBoundingClientRect();\n const containerSize = container[isVertical ? 'offsetHeight' : 'offsetWidth'] || 0;\n\n const snaps = slideRefs.current.map((slide) => {\n return Math.abs((isVertical ? containerRect.top : containerRect.left) - (slide?.getBoundingClientRect()[isVertical ? 'top' : 'left'] || 0)) * -1;\n });\n\n const scrollSnaps: number[] = [];\n\n for (let i = 0; i < slideRefs.current.length; i++) {\n const slide = slideRefs.current[i];\n\n if (!slide) continue;\n\n const slideRect = slide.getBoundingClientRect();\n const slideSize = isVertical ? slideRect.height : slideRect.width;\n const startOffset = isVertical ? slideRect.top - containerRect.top : slideRect.left - containerRect.left;\n\n let offset = 0;\n\n if (align === 'start') {\n offset = -startOffset;\n } else if (align === 'center') {\n offset = -startOffset + (containerSize - slideSize) / 2;\n } else if (align === 'end') {\n offset = -startOffset + (containerSize - slideSize);\n }\n\n if (canLoop) {\n scrollSnaps.push(offset);\n } else {\n const minClamp = Math.min(0, viewSize - contentSize);\n const clamped = Math.max(minClamp, Math.min(0, offset));\n\n scrollSnaps.push(clamped);\n }\n }\n\n let lastSnap: number | undefined;\n\n const snapPoints: number[] = [];\n\n scrollSnaps.forEach((snap, index) => {\n if (snap !== lastSnap) {\n snapPoints.push(snap);\n }\n\n lastSnap = scrollSnaps[index];\n });\n\n setSnaps(snaps);\n setScrollSnaps(scrollSnaps);\n setSnapPoints(snapPoints);\n }, [isVertical, align, viewSize, canLoop, contentSize]);\n\n const getSwipeAmount = (): number => {\n if (!carouselRef.current) return 0;\n\n const value = getComputedStyle(carouselRef.current).getPropertyValue(isVertical ? '--p-swipe-amount-y' : '--p-swipe-amount-x') || '0';\n\n return parseFloat(value || '0') || 0;\n };\n\n const setSwipeAmount = (amount: number) => {\n if (!carouselRef.current) return;\n\n if (amount === undefined) return;\n\n if (isVertical) {\n carouselRef.current.style.setProperty('--p-swipe-amount-y', `${amount ?? 0}px`);\n carouselRef.current.style.setProperty('--p-swipe-amount-x', `0px`);\n } else {\n carouselRef.current.style.setProperty('--p-swipe-amount-x', `${amount ?? 0}px`);\n carouselRef.current.style.setProperty('--p-swipe-amount-y', `0px`);\n }\n };\n\n const normalizeSwipeAmount = React.useCallback(\n (amount: number) => {\n if (contentSize === 0 || slidesLength === 0 || !carouselRef.current) return;\n\n let computedAmount = amount;\n\n if (!canLoop) {\n if (computedAmount < minOffset) {\n computedAmount = minOffset + applyDampening(computedAmount - minOffset);\n } else if (computedAmount > maxOffset) {\n computedAmount = maxOffset + applyDampening(computedAmount - maxOffset);\n }\n } else {\n while (computedAmount <= minOffset) computedAmount += contentSize;\n while (computedAmount > maxOffset) computedAmount -= contentSize;\n\n if (computedAmount < minOffset) {\n computedAmount = minOffset + applyDampening(computedAmount - minOffset);\n } else if (computedAmount > maxOffset) {\n computedAmount = maxOffset + applyDampening(computedAmount - maxOffset);\n }\n }\n\n if (Object.is(computedAmount, -0)) computedAmount = 0;\n\n setSwipeAmount(computedAmount);\n updateLoopPoints();\n },\n [isVertical, canLoop, contentSize, slidesLength, minOffset, maxOffset]\n );\n\n const findClosestSnapIndex = (currentOffset: number, snaps: number[], contentSize: number, isLoop: boolean) => {\n let closestIndex = 0;\n let minDistance = Infinity;\n\n snaps.forEach((snap, index) => {\n if (isLoop) {\n const distances = [Math.abs(currentOffset - snap), Math.abs(currentOffset - (snap + contentSize)), Math.abs(currentOffset - (snap - contentSize))];\n const distance = Math.min(...distances);\n\n if (distance < minDistance) {\n minDistance = distance;\n closestIndex = index;\n }\n } else {\n const distance = Math.abs(currentOffset - snap);\n\n if (distance < minDistance) {\n minDistance = distance;\n closestIndex = index;\n }\n }\n });\n\n return closestIndex;\n };\n\n const slideTo = (index?: number, offset?: number) => {\n let newIndex: number | undefined = index;\n\n if (viewSize === 0) return;\n\n if (!(index === undefined || index < 0 || index >= slidesLength)) {\n newIndex = Math.min(index, scrollSnaps.length - 1);\n } else if (offset !== undefined) {\n newIndex = findClosestSnapIndex(offset, scrollSnaps, contentSize, canLoop);\n } else {\n return;\n }\n\n const currentOffset = getSwipeAmount();\n let targetOffset = newIndex !== undefined ? scrollSnaps[newIndex] : offset || 0;\n\n if (canLoop) {\n const loopPoints = loopPointsRef.current;\n const relevantLoopPoint = loopPoints.find((point) => point.index === newIndex);\n\n if (relevantLoopPoint) {\n targetOffset -= relevantLoopPoint.target();\n }\n }\n\n let delta = 0;\n\n if (canLoop && targetOffset <= maxOffset && targetOffset >= 0 && scrollSnaps[scrollSnaps.length - 1] >= currentOffset) {\n delta = -contentSize - currentOffset + targetOffset;\n } else {\n delta = targetOffset - currentOffset;\n }\n\n position.current = currentOffset;\n target.current = currentOffset + delta;\n animate.start();\n\n setActiveIndex(newIndex);\n\n if (onSlideChange && newIndex !== activeIndex) {\n onSlideChange({ value: newIndex });\n }\n };\n\n const updateLoopPoints = React.useCallback(() => {\n if (!loop || !slideRefs.current || snaps.length === 0 || slideSizes.length === 0 || scrollSnaps.length === 0 || viewSize === 0 || slidesLength === 0) return;\n\n const ascItems = Array.from({ length: slidesLength }, (_, index) => index);\n const descItems = Array.from({ length: slidesLength }, (_, index) => slidesLength - 1 - index);\n const tolerance = 0.5;\n\n function removeSlideSizes(indexes: number[], from: number): number {\n return indexes.reduce((a: number, i) => {\n return a - slideSizes[i];\n }, from);\n }\n\n const slidesInGap = (indexes: number[], gap: number) => {\n return indexes.reduce((a: number[], i) => {\n const remainingGap = removeSlideSizes(a, gap);\n\n return remainingGap > 0 ? a.concat([i]) : a;\n }, []);\n };\n\n function findSlideBounds(offset: number) {\n return snaps.map((snap, index) => ({\n start: snap - slideSizes[index] + tolerance + offset,\n end: snap + viewSize - tolerance + offset\n }));\n }\n\n function findLoopPoints(indexes: number[], offset: number, isEndEdge: boolean) {\n const slideBounds = findSlideBounds(offset);\n\n return indexes.map((index) => {\n const initial = isEndEdge ? 0 : -contentSize;\n const altered = isEndEdge ? contentSize : 0;\n const boundEdge = isEndEdge ? 'end' : 'start';\n const loopPoint = slideBounds[index][boundEdge];\n\n return {\n index,\n loopPoint,\n target: () => (getSwipeAmount() > loopPoint ? initial : altered)\n };\n });\n }\n\n const startPoints = () => {\n const gap = viewSize;\n const indexes = slidesInGap(descItems, gap);\n\n return findLoopPoints(indexes, contentSize, false);\n };\n\n const endPoints = () => {\n const gap = viewSize - scrollSnaps[0] - 1;\n const indexes = slidesInGap(ascItems, gap);\n\n return findLoopPoints(indexes, -contentSize, true);\n };\n\n const loopPoints: LoopPoint[] = startPoints().concat(endPoints());\n\n loopPointsRef.current = loopPoints;\n\n const canLoop = loopPoints.every(({ index }) => {\n const otherIndexes = ascItems.filter((i) => i !== index);\n\n return removeSlideSizes(otherIndexes, viewSize) <= 0.1;\n });\n\n setCanLoop(canLoop);\n\n if (!canLoop) return;\n\n loopPoints.forEach((loopPoint) => {\n const { target } = loopPoint;\n const shiftLocation = target();\n\n // if (shiftLocation === swipeAmount[swipeAxis]) return;\n\n const slide = slideRefs.current[loopPoint.index];\n\n if (slide) {\n const transformValue = `translate3d(${isVertical ? '0px' : `${shiftLocation}px`}, ${isVertical ? `${shiftLocation}px` : '0px'}, 0px)`;\n\n slide.style.transform = transformValue;\n }\n });\n }, [loop, orientation, snaps, slideSizes, scrollSnaps, slidesLength, viewSize, contentSize, isVertical]);\n\n const addSlideRef = (el: HTMLDivElement | null) => {\n if (el && !slideRefs.current.includes(el)) {\n slideRefs.current.push(el);\n }\n };\n\n const handlePrev = () => {\n if (!canLoop && getSwipeAmount() >= maxOffset) return;\n\n animate.stop();\n const prevIndex = canLoop ? (activeIndex - 1 + scrollSnaps.length) % scrollSnaps.length : Math.max(0, activeIndex - 1);\n\n slideTo(prevIndex);\n };\n\n const handleNext = () => {\n if (!canLoop && getSwipeAmount() <= minOffset) return;\n\n animate.stop();\n const nextIndex = canLoop ? (activeIndex + 1) % scrollSnaps.length : Math.min(scrollSnaps.length - 1, activeIndex + 1);\n\n slideTo(nextIndex);\n };\n\n const handlePointerDown = (event: PointerEvent) => {\n if (event.button === 2) return;\n\n animate.stop();\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n\n setIsSwiping(true);\n\n const time = new Date().getTime();\n\n swipeStartTimeRef.current = time;\n swipeStartPointerRef.current = { x: event.clientX, y: event.clientY };\n prevSwipeAmountRef.current = getSwipeAmount();\n\n recentSwipeRef.current = {\n time,\n startX: event.clientX,\n startY: event.clientY,\n moved: false\n };\n };\n\n const handlePointerMove = (event: PointerEvent) => {\n if (!isSwiping || !swipeStartPointerRef.current || !swipeStartTimeRef.current || !carouselRef.current) return;\n\n if (recentSwipeRef.current) {\n recentSwipeRef.current.moved = true;\n }\n\n const delta = isVertical ? event.clientY - swipeStartPointerRef.current.y : event.clientX - swipeStartPointerRef.current.x;\n\n const prevDelta = prevDeltaRef.current;\n\n if (delta > prevDelta) {\n swipeDirectionRef.current = 1;\n } else if (delta < prevDelta) {\n swipeDirectionRef.current = -1;\n }\n\n prevDeltaRef.current = delta;\n\n const prevSwipeAmount = prevSwipeAmountRef.current;\n\n const totalOffset = prevSwipeAmount + delta;\n\n carouselRef.current.style.userSelect = 'none';\n normalizeSwipeAmount(totalOffset);\n };\n\n const handlePointerUp = (event: PointerEvent) => {\n if (event.target instanceof HTMLElement) {\n event.target.releasePointerCapture(event.pointerId);\n }\n\n if (!swipeStartPointerRef.current || !swipeStartTimeRef.current || !carouselRef.current) {\n setIsSwiping(false);\n\n return;\n }\n\n const elapsed = Date.now() - swipeStartTimeRef.current;\n const distance = getSwipeAmount() - prevSwipeAmountRef.current;\n const velocity = Math.abs(distance / elapsed);\n\n if (velocity > 0.3 && Math.abs(distance) < 25) {\n slideTo((activeIndex + swipeDirectionRef.current + slidesLength) % slidesLength);\n } else {\n const currentOffset = getSwipeAmount();\n const closestIndex = findClosestSnapIndex(currentOffset, scrollSnaps, contentSize, canLoop);\n\n slideTo(closestIndex);\n }\n\n carouselRef.current.style.userSelect = '';\n setIsSwiping(false);\n swipeStartPointerRef.current = null;\n swipeStartTimeRef.current = null;\n\n setTimeout(() => {\n recentSwipeRef.current = null;\n }, 100);\n };\n\n const handleClick = (event: MouseEvent) => {\n if (isSwiping) {\n event.preventDefault();\n event.stopPropagation();\n\n return;\n }\n\n if (recentSwipeRef.current) {\n const elapsed = Date.now() - recentSwipeRef.current.time;\n const deltaX = Math.abs(event.clientX - recentSwipeRef.current.startX);\n const deltaY = Math.abs(event.clientY - recentSwipeRef.current.startY);\n const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);\n\n const significantMovement = recentSwipeRef.current.moved && elapsed > 150;\n const tooLong = elapsed > 500;\n const tooFar = distance > 25;\n\n if (significantMovement || tooLong || tooFar) {\n event.preventDefault();\n event.stopPropagation();\n\n return;\n }\n }\n };\n\n React.useEffect(() => {\n calculateSnaps();\n }, [calculateSnaps]);\n\n React.useEffect(() => {\n if (scrollSnaps.length === 0 || snapPoints.length === 0 || contentSize === 0) return;\n\n slideTo(props.slide !== undefined ? props.slide : 0);\n }, [props.slide, scrollSnaps, snapPoints, canLoop, contentSize]);\n\n React.useEffect(() => {\n if (canLoop) return;\n\n setPrevDisabled(activeIndex === 0 && !canLoop);\n setNextDisabled(activeIndex === snapPoints.length - 1 && !canLoop);\n }, [activeIndex, canLoop, snapPoints]);\n\n React.useEffect(() => {\n setSlidesLength(slideRefs.current.length);\n }, []);\n\n React.useEffect(() => {\n setViewSize(carouselRef.current?.[isVertical ? 'offsetHeight' : 'offsetWidth'] || 0);\n\n const observer = new ResizeObserver(() => {\n setViewSize(carouselRef.current?.[isVertical ? 'offsetHeight' : 'offsetWidth'] || 0);\n });\n\n if (carouselRef.current) {\n observer.observe(carouselRef.current);\n }\n\n return () => {\n observer.disconnect();\n };\n }, [carouselRef]);\n\n React.useEffect(() => {\n slideRefs.current = [];\n }, []);\n\n React.useEffect(() => {\n if (!slideRefs.current) return;\n\n const observer = new ResizeObserver((entries) => {\n entries.forEach((entry) => {\n const index = slideRefs.current.findIndex((slide) => slide === entry.target);\n\n if (index === -1) return;\n\n setSlideSizes((prev) => {\n const newSizes = [...prev];\n\n newSizes[index] = entry.contentRect[isVertical ? 'height' : 'width'];\n\n return newSizes;\n });\n });\n });\n\n slideRefs.current.forEach((slideEl) => {\n if (slideEl) observer.observe(slideEl);\n });\n\n return () => {\n observer.disconnect();\n };\n }, [isVertical]);\n\n React.useLayoutEffect(() => {\n if (!slideRefs.current?.length) return;\n\n setSlideSizes(slideRefs.current.map((el) => (el ? (isVertical ? el.getBoundingClientRect().height : el.getBoundingClientRect().width) : 0)));\n }, [isVertical]);\n\n const state = {\n isSwiping,\n slideSizes,\n canLoop,\n snaps,\n scrollSnaps,\n activeIndex,\n prevDisabled,\n nextDisabled,\n snapPoints\n };\n\n return {\n state,\n handlePrev,\n handleNext,\n handlePointerDown,\n handlePointerMove,\n handlePointerUp,\n addSlideRef,\n slideTo,\n handleClick,\n carouselRef\n };\n }\n});\n","import type { useCarouselProps } from '@primereact/types/shared/carousel';\n\nexport const defaultProps: useCarouselProps = {\n orientation: 'horizontal',\n align: 'start',\n loop: false,\n spacing: 16,\n slide: 0,\n onSlideChange: undefined\n};\n"],"mappings":"AAAA,OAAS,gBAAAA,OAAoB,4BAC7B,UAAYC,MAAW,QCChB,IAAMC,GAAiC,CAC1C,YAAa,aACb,MAAO,QACP,KAAM,GACN,QAAS,GACT,MAAO,EACP,cAAe,MACnB,EDCA,SAASC,GAAqBC,EAAoBC,EAAoD,CAClG,IAAMC,EAAgB,SAAO,CAAC,EACxBC,EAAsB,SAAsB,IAAI,EAChDC,EAAgB,SAAO,CAAC,EACxBC,EAAY,IAAO,GAEnBC,EAAWC,GAAsB,CACnC,GAAI,CAACL,EAAQ,QAAS,OAEjBC,EAAc,UACfA,EAAc,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a0D,EAAG,sBAAsB,EAAE,OAASA,EAAG,sBAAsB,EAAE,MAAS,CAAE,CAAC,CAC/I,EAAG,CAAC1D,CAAU,CAAC,EAcR,CACH,MAbU,CACV,UAAAtC,EACA,WAAAI,EACA,QAAAE,EACA,MAAAE,EACA,YAAAE,EACA,YAAAR,EACA,aAAAgB,GACA,aAAAE,GACA,WAAAR,CACJ,EAII,WAAAqF,GACA,WAAAE,GACA,kBAAAE,GACA,kBAAAG,GACA,gBAAAG,GACA,YAAAZ,GACA,QAAA7B,EACA,YAAA2C,GACA,YAAApF,CACJ,CACJ,CACJ,CAAC","names":["withHeadless","React","defaultProps","useCarouselAnimation","update","render","frameId","lastTimeStamp","accTime","fixedStep","animate","timeStamp","timeElapsed","alpha","start","stop","reset","handleVisibilityChange","DAMPENING_FACTOR","applyDampening","delta","distance","threshold","overflow","maxStretch","dampened","useCarousel","withHeadless","defaultProps","props","loop","orientation","align","slide","onSlideChange","isSwiping","setIsSwiping","activeIndex","setActiveIndex","slideSizes","setSlideSizes","canLoop","setCanLoop","snaps","setSnaps","scrollSnaps","setScrollSnaps","snapPoints","setSnapPoints","slidesLength","setSlidesLength","viewSize","setViewSize","prevDisabled","setPrevDisabled","nextDisabled","setNextDisabled","loopPointsRef","swipeDirectionRef","prevDeltaRef","carouselRef","slideRefs","swipeStartTimeRef","swipeStartPointerRef","prevSwipeAmountRef","recentSwipeRef","previousPosition","position","target","velocity","value","normalizeSwipeAmount","setSwipeAmount","isVertical","contentSize","minOffset","maxOffset","calculateSnaps","container","containerRect","containerSize","i","slideRect","slideSize","startOffset","offset","minClamp","clamped","lastSnap","snap","index","getSwipeAmount","amount","computedAmount","updateLoopPoints","findClosestSnapIndex","currentOffset","isLoop","closestIndex","minDistance","distances","slideTo","newIndex","targetOffset","relevantLoopPoint","point","ascItems","_","descItems","tolerance","removeSlideSizes","indexes","from","a","slidesInGap","gap","findSlideBounds","findLoopPoints","isEndEdge","slideBounds","initial","altered","boundEdge","loopPoint","startPoints","endPoints","loopPoints","otherIndexes","shiftLocation","transformValue","addSlideRef","el","handlePrev","prevIndex","handleNext","nextIndex","handlePointerDown","event","time","handlePointerMove","prevDelta","totalOffset","handlePointerUp","elapsed","handleClick","deltaX","deltaY","significantMovement","tooLong","tooFar","_a","observer","entries","entry","prev","newSizes","slideEl"]}
|
|
1
|
+
{"version":3,"sources":["../../src/carousel/useCarousel.ts","../../src/carousel/useCarousel.props.ts"],"sourcesContent":["import { withHeadless } from '@primereact/core/headless';\nimport * as React from 'react';\nimport { defaultProps } from './useCarousel.props';\n\nconst ITEM_SELECTOR = '[data-item]';\n\nfunction areSetsEqual<T>(a: Set<T>, b: Set<T>) {\n if (a.size !== b.size) return false;\n\n for (const value of a) {\n if (!b.has(value)) return false;\n }\n\n return true;\n}\n\nexport const useCarousel = withHeadless({\n name: 'useCarousel',\n defaultProps,\n setup({ props }) {\n const [swiping, setSwiping] = React.useState(false);\n const [isNextDisabled, setIsNextDisabled] = React.useState(false);\n const [isPrevDisabled, setIsPrevDisabled] = React.useState(false);\n const [snapPoints, setSnapPoints] = React.useState<Set<number>>(new Set());\n const [pageState, setPageState] = React.useState(props.page ?? props.defaultPage ?? 0);\n\n const contentRef = React.useRef<HTMLDivElement>(null);\n const snapPointsRef = React.useRef<Set<number>>(new Set());\n const scrollSnapsRef = React.useRef<number[]>([]);\n const initialPageAppliedRef = React.useRef(false);\n\n const mutationObserverRef = React.useRef<MutationObserver>(null);\n const intersectionObserverRef = React.useRef<IntersectionObserver>(null);\n const resizeObserverRef = React.useRef<ResizeObserver>(null);\n const scrollTimeoutRef = React.useRef<NodeJS.Timeout | null>(null);\n const wheelTimeoutRef = React.useRef<NodeJS.Timeout | null>(null);\n\n const swipeStartPointRef = React.useRef<{ x: number; y: number }>({ x: 0, y: 0 });\n const isRealSwipeRef = React.useRef(false);\n\n function computeSnapPoints() {\n const content = contentRef.current;\n\n if (!content) return [];\n\n const isHorizontal = props.orientation !== 'vertical';\n const trackSize = isHorizontal ? content.clientWidth : content.clientHeight;\n const maxOffset = Math.max(0, isHorizontal ? content.scrollWidth - trackSize : content.scrollHeight - trackSize);\n const snaps: number[] = [];\n\n scrollSnapsRef.current = [];\n\n content.querySelectorAll<HTMLElement>(ITEM_SELECTOR).forEach((item) => {\n const offset = isHorizontal ? item.offsetLeft : item.offsetTop;\n const size = isHorizontal ? item.clientWidth : item.clientHeight;\n\n let snapPoint = offset;\n\n if (props.align === 'center') {\n snapPoint = offset - (trackSize - size) / 2;\n } else if (props.align === 'end') {\n snapPoint = offset - (trackSize - size);\n }\n\n const clamped = Math.max(0, Math.min(snapPoint, maxOffset));\n\n scrollSnapsRef.current.push(clamped);\n\n snaps.push(clamped);\n });\n\n const newSnapPoints = new Set(snaps.map(Number));\n\n if (areSetsEqual(snapPoints, newSnapPoints)) return;\n\n snapPointsRef.current = newSnapPoints;\n setSnapPoints(newSnapPoints);\n }\n\n function setPage(page: number) {\n if (!props.loop) {\n const size = snapPointsRef.current.size || snapPoints.size;\n let isNextDisabled = false;\n let isPrevDisabled = false;\n\n if (page === 0) {\n isPrevDisabled = true;\n }\n\n if (page === size - 1) {\n isNextDisabled = true;\n }\n\n setIsNextDisabled(isNextDisabled);\n setIsPrevDisabled(isPrevDisabled);\n }\n\n setPageState(page);\n\n props.onPageChange?.({ value: page });\n props.onSlideChange?.({ value: page });\n }\n\n function setToClosest() {\n const content = contentRef.current;\n\n const points = snapPointsRef.current;\n\n if (!content || points.size === 0) return;\n\n const scrollPos = props.orientation === 'horizontal' ? content.scrollLeft : content.scrollTop;\n\n const closestSnapPoint = Array.from(points).reduce((closest, point) => {\n return Math.abs(point - scrollPos) < Math.abs(closest - scrollPos) ? point : closest;\n }, Infinity);\n\n const index = Array.from(points).indexOf(closestSnapPoint);\n\n setPage(index);\n\n return index;\n }\n\n function scrollToPage(page?: number, instant = false) {\n const points = snapPointsRef.current;\n\n if (points.size === 0) return;\n\n const target = page ?? pageState;\n const clampedPage = props.loop ? (target + points.size) % points.size : Math.max(0, Math.min(target, points.size - 1));\n\n setPage(clampedPage);\n scrollTo(Array.from(points)[clampedPage], instant);\n }\n\n function next() {\n scrollToPage(pageState + 1);\n }\n\n function prev() {\n scrollToPage(pageState - 1);\n }\n\n function scrollTo(snapPoint: number, instant = false) {\n const content = contentRef.current;\n\n if (!content) return;\n\n content.scrollTo({\n [props.orientation === 'horizontal' ? 'left' : 'top']: snapPoint,\n behavior: instant ? 'instant' : 'smooth'\n });\n }\n\n function scrollToSlide(slide: number) {\n const points = snapPointsRef.current;\n const snaps = scrollSnapsRef.current;\n\n if (points.size === 0 || snaps.length === 0) return;\n\n const clampedSlide = Math.max(0, Math.min(slide, snaps.length - 1));\n\n const snap = snaps[clampedSlide];\n\n scrollTo(snap);\n\n const page = Array.from(points).indexOf(snap);\n\n setPage(page);\n }\n\n React.useLayoutEffect(() => {\n const content = contentRef.current;\n\n if (!content) return;\n\n resizeObserverRef.current = new ResizeObserver(() => {\n computeSnapPoints();\n const closest = setToClosest();\n\n scrollToPage(closest ?? pageState, true);\n });\n\n resizeObserverRef.current.observe(content);\n content.querySelectorAll<HTMLElement>(ITEM_SELECTOR).forEach((item) => resizeObserverRef.current?.observe(item));\n\n computeSnapPoints();\n\n return () => {\n resizeObserverRef.current?.disconnect();\n resizeObserverRef.current = null;\n };\n }, []);\n\n React.useLayoutEffect(() => {\n if (initialPageAppliedRef.current) return;\n\n const size = snapPointsRef.current.size || snapPoints.size;\n\n if (size === 0) return;\n\n initialPageAppliedRef.current = true;\n scrollToPage(props.defaultPage ?? 0, true);\n }, [snapPoints, props.page, props.defaultPage]);\n\n React.useEffect(() => {\n if (props.page === undefined || props.page === null || props.slide !== undefined || props.slide !== null) return;\n\n if (snapPointsRef.current.size === 0 && snapPoints.size === 0) return;\n\n scrollToPage(props.page);\n }, [props.page, snapPoints]);\n\n React.useEffect(() => {\n if (props.slide === undefined || props.slide === null) return;\n\n if (snapPointsRef.current.size === 0 && snapPoints.size === 0) return;\n\n scrollToSlide(props.slide);\n }, [props.slide]);\n\n React.useEffect(() => {\n const content = contentRef.current;\n\n if (!content) return;\n\n mutationObserverRef.current = new MutationObserver((mutations) => {\n mutations.forEach(() => {\n computeSnapPoints();\n requestAnimationFrame(() => {\n const closest = setToClosest();\n\n scrollToPage(closest ?? pageState, true);\n });\n });\n });\n\n mutationObserverRef.current.observe(content, { childList: true, subtree: true });\n\n return () => {\n mutationObserverRef.current?.disconnect();\n mutationObserverRef.current = null;\n };\n }, []);\n\n React.useEffect(() => {\n const content = contentRef.current;\n\n if (!content) return;\n\n intersectionObserverRef.current = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) entry.target.setAttribute('data-inview', 'true');\n else entry.target.setAttribute('data-inview', 'false');\n });\n },\n {\n root: contentRef.current,\n threshold: 0.6\n }\n );\n\n content.querySelectorAll<HTMLElement>(ITEM_SELECTOR).forEach((item) => intersectionObserverRef.current?.observe(item));\n\n return () => {\n intersectionObserverRef.current?.disconnect();\n intersectionObserverRef.current = null;\n };\n }, []);\n\n React.useEffect(() => {\n const content = contentRef.current;\n\n if (!content) return;\n\n const onScroll = () => {\n if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);\n\n scrollTimeoutRef.current = setTimeout(() => {\n setToClosest();\n }, 80);\n };\n\n onScroll();\n\n content.addEventListener('scroll', onScroll, { passive: true });\n\n return () => {\n if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);\n\n scrollTimeoutRef.current = null;\n\n content.removeEventListener('scroll', onScroll);\n };\n }, []);\n\n function onContentPointerDown(e: React.PointerEvent<HTMLDivElement>) {\n if (e.button !== 0) return;\n\n if (e.pointerType === 'touch') return;\n\n setSwiping(true);\n swipeStartPointRef.current = { x: e.clientX, y: e.clientY };\n isRealSwipeRef.current = false;\n }\n\n function onContentPointerMove(e: React.PointerEvent<HTMLDivElement>) {\n const content = contentRef.current;\n\n if (!swiping || !content || e.pointerType === 'touch') return;\n\n const deltaX = e.clientX - swipeStartPointRef.current.x;\n const deltaY = e.clientY - swipeStartPointRef.current.y;\n const distance = Math.abs(deltaX) + Math.abs(deltaY);\n\n if (distance < 6) return;\n\n if ((window.getSelection()?.toString().length ?? 0) > 0) return;\n\n e.currentTarget.setPointerCapture(e.pointerId);\n\n content.style.userSelect = 'none';\n isRealSwipeRef.current = true;\n content.style.scrollSnapType = 'none';\n content.scrollBy({\n left: -e.movementX,\n top: -e.movementY,\n behavior: 'instant'\n });\n\n e.preventDefault();\n }\n\n function onContentPointerUp(e: React.PointerEvent<HTMLDivElement>) {\n setSwiping(false);\n e.currentTarget.releasePointerCapture(e.pointerId);\n\n if (!isRealSwipeRef.current) return;\n\n const content = contentRef.current;\n\n if (!content) return;\n\n content.style.userSelect = '';\n\n const scrollPos = props.orientation === 'horizontal' ? content.scrollLeft : content.scrollTop;\n const snapPoints = snapPointsRef.current;\n\n const closestSnapPoint = Array.from(snapPoints).reduce((closest, point) => {\n return Math.abs(point - scrollPos) < Math.abs(closest - scrollPos) ? point : closest;\n }, Infinity);\n\n const index = Array.from(snapPoints).indexOf(closestSnapPoint);\n\n requestAnimationFrame(() => {\n if (closestSnapPoint !== undefined) scrollToPage(index);\n\n requestAnimationFrame(() => {\n content.style.scrollSnapType = resolveSnapType();\n });\n });\n }\n\n function onContentWheel(e: React.WheelEvent<HTMLDivElement>) {\n if (wheelTimeoutRef.current) clearTimeout(wheelTimeoutRef.current);\n\n wheelTimeoutRef.current = setTimeout(() => {\n const primaryDelta = props.orientation === 'horizontal' ? e.deltaX || e.deltaY : e.deltaY || e.deltaX;\n\n if (primaryDelta > 0 && isNextDisabled) {\n return;\n }\n\n if (primaryDelta < 0 && isPrevDisabled) {\n return;\n }\n\n setToClosest();\n }, 80);\n }\n\n const resolveSnapType = () => {\n const axis = props.orientation === 'vertical' ? 'y' : 'x';\n\n return `${axis} ${props.snapType ?? 'mandatory'}`;\n };\n\n const contentStyles = {\n position: 'relative',\n scrollSnapType: resolveSnapType(),\n overflowX: props.orientation === 'vertical' ? '' : 'scroll',\n overflowY: props.orientation === 'horizontal' ? '' : 'scroll',\n scrollbarWidth: 'none',\n overscrollBehaviorX: props.orientation === 'vertical' ? '' : 'contain',\n overscrollBehaviorY: props.orientation === 'horizontal' ? '' : 'contain',\n display: 'flex',\n flexDirection: props.orientation === 'horizontal' ? '' : 'column',\n '--spacing': props.spacing + 'px',\n gap: 'var(--spacing)'\n } as React.CSSProperties;\n\n const slidesPerPage = props.slidesPerPage && props.slidesPerPage > 0 ? props.slidesPerPage : 1;\n const basis = props.autoSize ? 'auto' : `calc(100% /${slidesPerPage} - var(--spacing) * (${slidesPerPage} - 1) / ${slidesPerPage})`;\n\n const itemStyles = {\n scrollSnapAlign: props.align,\n flexGrow: 0,\n flexShrink: 0,\n minWidth: 0,\n flexBasis: basis\n } as React.CSSProperties;\n\n const state = {\n swiping,\n isNextDisabled,\n isPrevDisabled,\n snapPoints,\n page: pageState\n };\n\n return {\n state,\n contentStyles,\n itemStyles,\n contentRef,\n onContentPointerDown,\n onContentPointerMove,\n onContentPointerUp,\n onContentWheel,\n next,\n prev,\n scrollToPage,\n scrollTo,\n scrollToSlide,\n setToClosest\n };\n }\n});\n","import type { useCarouselProps } from '@primereact/types/shared/carousel';\n\nexport const defaultProps: useCarouselProps = {\n orientation: 'horizontal',\n align: 'start',\n loop: false,\n snapType: 'mandatory',\n spacing: 16,\n autoSize: false,\n slidesPerPage: 1,\n slide: undefined,\n onSlideChange: undefined,\n defaultPage: 0,\n page: undefined,\n onPageChange: undefined\n};\n"],"mappings":"AAAA,OAAS,gBAAAA,OAAoB,4BAC7B,UAAYC,MAAW,QCChB,IAAMC,EAAiC,CAC1C,YAAa,aACb,MAAO,QACP,KAAM,GACN,SAAU,YACV,QAAS,GACT,SAAU,GACV,cAAe,EACf,MAAO,OACP,cAAe,OACf,YAAa,EACb,KAAM,OACN,aAAc,MAClB,EDXA,IAAMC,EAAgB,cAEtB,SAASC,GAAgBC,EAAWC,EAAW,CAC3C,GAAID,EAAE,O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U,EACV,WAAY,EACZ,SAAU,EACV,UAAWuE,CACf,EAUA,MAAO,CACH,MATU,CACV,QAAApE,EACA,eAAAE,EACA,eAAAE,EACA,WAAAE,EACA,KAAME,CACV,EAII,cAAA0D,EACA,WAAAG,GACA,WAAA3D,EACA,qBAAA+C,EACA,qBAAAE,EACA,mBAAAG,EACA,eAAAE,EACA,KAAAjB,EACA,KAAAC,EACA,aAAAN,EACA,SAAAI,EACA,cAAAG,EACA,aAAAd,CACJ,CACJ,CACJ,CAAC","names":["withHeadless","React","defaultProps","ITEM_SELECTOR","areSetsEqual","a","b","value","useCarousel","withHeadless","defaultProps","props","_a","_b","swiping","setSwiping","isNextDisabled","setIsNextDisabled","isPrevDisabled","setIsPrevDisabled","snapPoints","setSnapPoints","pageState","setPageState","contentRef","snapPointsRef","scrollSnapsRef","initialPageAppliedRef","mutationObserverRef","intersectionObserverRef","resizeObserverRef","scrollTimeoutRef","wheelTimeoutRef","swipeStartPointRef","isRealSwipeRef","computeSnapPoints","content","isHorizontal","trackSize","maxOffset","snaps","item","offset","size","snapPoint","clamped","newSnapPoints","setPage","page","setToClosest","points","scrollPos","closestSnapPoint","closest","point","index","scrollToPage","instant","target","clampedPage","scrollTo","next","prev","scrollToSlide","slide","clampedSlide","snap","mutations","entries","entry","onScroll","onContentPointerDown","e","onContentPointerMove","deltaX","deltaY","onContentPointerUp","resolveSnapType","onContentWheel","primaryDelta","contentStyles","slidesPerPage","basis","itemStyles"]}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export declare const useCarousel: (inProps?: unknown) => import("@primereact/types/core").HeadlessInstance<import("@primereact/types/shared/carousel").useCarouselProps, unknown, {
|
|
3
3
|
state: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
activeIndex: number;
|
|
10
|
-
prevDisabled: boolean;
|
|
11
|
-
nextDisabled: boolean;
|
|
12
|
-
snapPoints: number[];
|
|
4
|
+
swiping: boolean;
|
|
5
|
+
isNextDisabled: boolean;
|
|
6
|
+
isPrevDisabled: boolean;
|
|
7
|
+
snapPoints: Set<number>;
|
|
8
|
+
page: number;
|
|
13
9
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
contentStyles: React.CSSProperties;
|
|
11
|
+
itemStyles: React.CSSProperties;
|
|
12
|
+
contentRef: React.RefObject<HTMLDivElement | null>;
|
|
13
|
+
onContentPointerDown: (e: React.PointerEvent<HTMLDivElement>) => void;
|
|
14
|
+
onContentPointerMove: (e: React.PointerEvent<HTMLDivElement>) => void;
|
|
15
|
+
onContentPointerUp: (e: React.PointerEvent<HTMLDivElement>) => void;
|
|
16
|
+
onContentWheel: (e: React.WheelEvent<HTMLDivElement>) => void;
|
|
17
|
+
next: () => void;
|
|
18
|
+
prev: () => void;
|
|
19
|
+
scrollToPage: (page?: number, instant?: boolean) => void;
|
|
20
|
+
scrollTo: (snapPoint: number, instant?: boolean) => void;
|
|
21
|
+
scrollToSlide: (slide: number) => void;
|
|
22
|
+
setToClosest: () => number | undefined;
|
|
23
23
|
}>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Color2DAxes, Color3DAxes, ColorChannel, ColorChannelRange, ColorInputChannel, ColorInstance, ColorOutput, ColorSliderChannel, ColorSpace } from '@primereact/types/shared/colorpicker';
|
|
2
|
+
export declare const isEqual: (a: unknown, b: unknown) => boolean;
|
|
3
|
+
declare abstract class Color {
|
|
4
|
+
abstract clone(): ColorInstance;
|
|
5
|
+
abstract toString(format: ColorOutput): string;
|
|
6
|
+
abstract toFormat(format: ColorSpace): ColorInstance;
|
|
7
|
+
abstract toJSON(): Record<string, number>;
|
|
8
|
+
abstract getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
9
|
+
abstract getFormat(): ColorSpace;
|
|
10
|
+
abstract getChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
11
|
+
getChannelValue(channel: ColorChannel): number;
|
|
12
|
+
withChannelValue(channel: ColorChannel, value: number): ColorInstance;
|
|
13
|
+
getSpaceAxes(xyChannels: Color2DAxes): Color3DAxes;
|
|
14
|
+
incChannelValue(channel: ColorChannel, step: number): ColorInstance;
|
|
15
|
+
decChannelValue(channel: ColorChannel, step: number): ColorInstance;
|
|
16
|
+
}
|
|
17
|
+
export declare class HSBColor extends Color {
|
|
18
|
+
private hue;
|
|
19
|
+
private saturation;
|
|
20
|
+
private brightness;
|
|
21
|
+
private alpha;
|
|
22
|
+
constructor(hue: number, saturation: number, brightness: number, alpha: number);
|
|
23
|
+
static parse(value: string): HSBColor | undefined;
|
|
24
|
+
private toRGB;
|
|
25
|
+
private toHSL;
|
|
26
|
+
toFormat(format: ColorSpace): ColorInstance;
|
|
27
|
+
toString(format: ColorOutput): string;
|
|
28
|
+
toJSON(): {
|
|
29
|
+
hue: number;
|
|
30
|
+
saturation: number;
|
|
31
|
+
brightness: number;
|
|
32
|
+
alpha: number;
|
|
33
|
+
};
|
|
34
|
+
clone(): ColorInstance;
|
|
35
|
+
getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
36
|
+
getFormat(): ColorSpace;
|
|
37
|
+
getChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
38
|
+
}
|
|
39
|
+
export declare class HSLColor extends Color {
|
|
40
|
+
private hue;
|
|
41
|
+
private saturation;
|
|
42
|
+
private lightness;
|
|
43
|
+
private alpha;
|
|
44
|
+
constructor(hue: number, saturation: number, lightness: number, alpha: number);
|
|
45
|
+
static parse(value: string): HSLColor | undefined;
|
|
46
|
+
private toRGB;
|
|
47
|
+
private toHSB;
|
|
48
|
+
toFormat(format: ColorSpace): ColorInstance;
|
|
49
|
+
toString(format: ColorOutput): string;
|
|
50
|
+
toJSON(): Record<string, number>;
|
|
51
|
+
clone(): ColorInstance;
|
|
52
|
+
getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
53
|
+
getFormat(): ColorSpace;
|
|
54
|
+
getChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
55
|
+
}
|
|
56
|
+
export declare class RGBColor extends Color {
|
|
57
|
+
private red;
|
|
58
|
+
private green;
|
|
59
|
+
private blue;
|
|
60
|
+
private alpha;
|
|
61
|
+
constructor(red: number, green: number, blue: number, alpha: number);
|
|
62
|
+
static parse(value: string): RGBColor | undefined;
|
|
63
|
+
private static parseHexColor;
|
|
64
|
+
private static parseRgbFunction;
|
|
65
|
+
private toHSB;
|
|
66
|
+
private toHSL;
|
|
67
|
+
private toOKLCH;
|
|
68
|
+
toHexInt(): number;
|
|
69
|
+
toFormat(format: ColorSpace): ColorInstance;
|
|
70
|
+
toString(format: ColorOutput): string;
|
|
71
|
+
toJSON(): Record<string, number>;
|
|
72
|
+
clone(): ColorInstance;
|
|
73
|
+
getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
74
|
+
getFormat(): ColorSpace;
|
|
75
|
+
getChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
76
|
+
}
|
|
77
|
+
export declare class OKLCHColor extends Color {
|
|
78
|
+
private L;
|
|
79
|
+
private C;
|
|
80
|
+
private H;
|
|
81
|
+
private alpha;
|
|
82
|
+
constructor(L: number, C: number, H: number, alpha: number);
|
|
83
|
+
static parse(value: string): OKLCHColor | undefined;
|
|
84
|
+
private toRGB;
|
|
85
|
+
toJSON(): Record<string, number>;
|
|
86
|
+
clone(): ColorInstance;
|
|
87
|
+
toFormat(format: ColorSpace): ColorInstance;
|
|
88
|
+
toString(format: ColorOutput): string;
|
|
89
|
+
getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
90
|
+
getFormat(): ColorSpace;
|
|
91
|
+
getChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
92
|
+
}
|
|
93
|
+
export declare const parseColor: (color: string) => ColorInstance;
|
|
94
|
+
export declare function getChannelGradient(channel: ColorSliderChannel, value: ColorInstance, orientation: 'horizontal' | 'vertical'): string;
|
|
95
|
+
export declare function getChannelColor(color: ColorInstance, channel: ColorChannel): ColorInstance;
|
|
96
|
+
export declare function getAreaGradient(color: ColorInstance, axes: Color2DAxes): {
|
|
97
|
+
'--area-gradient': string;
|
|
98
|
+
};
|
|
99
|
+
export declare function getInputChannelValue(color: ColorInstance, channel: ColorInputChannel, format?: ColorSpace): string;
|
|
100
|
+
export declare function getInputChannelRange(color: ColorInstance, channel?: ColorInputChannel): ColorChannelRange | undefined;
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var it=Object.defineProperty,ht=Object.defineProperties;var lt=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var ut=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var T=(n,t,e)=>t in n?it(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,X=(n,t)=>{for(var e in t||(t={}))ut.call(t,e)&&T(n,e,t[e]);if(O)for(var e of O(t))ct.call(t,e)&&T(n,e,t[e]);return n},U=(n,t)=>ht(n,lt(t));var gt=/hsb\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsba\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/,mt=/hsl\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsla\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/,Ct=/^#?([a-fA-F0-9]{3,8})$/,bt=/^rgba?\(\s*([^)]+)\s*\)$/,dt=/oklch\(\s*([\d.]+)%?\s+([\d.]+)\s+([\d.]+)(deg)?(?:\s*\/\s*([\d.]+))?\)/i;function C(n,t,e){return Math.min(Math.max(n,t),e)}var Rt=(n,t)=>JSON.stringify(n)===JSON.stringify(t),N=(n,t)=>[n[0]*t[0]+n[1]*t[1]+n[2]*t[2],n[3]*t[0]+n[4]*t[1]+n[5]*t[2],n[6]*t[0]+n[7]*t[1]+n[8]*t[2]];function pt(n,t,e,r){let s=C(n,t,e)-t,h=Math.round(s/r),o=t+h*r,l=(r.toString().split(".")[1]||"").length;return parseFloat(o.toFixed(l))}var M=class{getChannelValue(t){if(t in this)return this[t];throw new Error(`Channel ${t} not found`)}withChannelValue(t,e){let{min:r,max:a}=this.getChannelRange(t);if(t in this){let s=this.clone();return s[t]=C(e,r,a),s}throw new Error(`Channel ${t} not found`)}getSpaceAxes(t){let{xChannel:e,yChannel:r}=t;if(e===r)throw new Error("xChannel and yChannel cannot be the same");let a=this.getChannels().find(s=>s!==e&&s!==r);if(!a)throw new Error("zChannel not found");return{xChannel:e,yChannel:r,zChannel:a}}incChannelValue(t,e){let{min:r,max:a,step:s}=this.getChannelRange(t),h=pt(C(this.getChannelValue(t)+e,r,a),r,a,s);return this.withChannelValue(t,h)}decChannelValue(t,e){return this.incChannelValue(t,-e)}},$=class n extends M{constructor(t,e,r,a){super(),this.hue=t,this.saturation=e,this.brightness=r,this.alpha=a}static parse(t){var o;let e=t.match(gt);if(!e)return;let[r,a,s,h]=((o=e[1])!=null?o:e[2]).split(",").map(l=>Number(l.trim().replace("%","")));return new n(r%360,C(a,0,100),C(s,0,100),C(h!=null?h:1,0,1))}toRGB(){let t=this.hue,e=this.saturation/100,r=this.brightness/100;function a(h){let o=(h+t/60)%6;return r-r*e*Math.max(0,Math.min(o,4-o,1))}let s=255;return new H(Math.round(a(5)*s),Math.round(a(3)*s),Math.round(a(1)*s),Number(this.alpha.toFixed(2)))}toHSL(){let t=this.hue,e=this.saturation/100,r=this.brightness/100,a=r*(1-e/2);return a===0||a===1?e=0:e=(r-a)/Math.min(a,1-a),new k(Number(t.toFixed(2)),Number((e*100).toFixed(2)),Number((a*100).toFixed(2)),Number(this.alpha.toFixed(2)))}toFormat(t){switch(t){case"hsba":return this;case"rgba":return this.toRGB();case"hsla":return this.toHSL();case"oklcha":return this.toRGB().toFormat("oklcha");default:throw new Error(`Invalid format: ${t}`)}}toString(t){switch(t){case"css":return this.toHSL().toString("css");case"hex":return this.toRGB().toString("hex");case"hexa":return this.toRGB().toString("hexa");case"hsb":return`hsb(${this.hue}, ${this.saturation.toFixed(2)}%, ${this.brightness.toFixed(2)}%)`;case"hsba":return`hsba(${this.hue}, ${this.saturation.toFixed(2)}%, ${this.brightness.toFixed(2)}%, ${this.alpha})`;case"hsl":return this.toHSL().toString("hsl");case"rgb":return this.toRGB().toString("rgb");case"oklch":return this.toRGB().toFormat("oklcha").toString("oklch");default:return this.toFormat(t).toString(t)}}toJSON(){return{hue:this.hue,saturation:this.saturation,brightness:this.brightness,alpha:this.alpha}}clone(){return new n(this.hue,this.saturation,this.brightness,this.alpha)}getChannelRange(t){switch(t){case"hue":return{min:0,max:360,step:1};case"saturation":case"brightness":return{min:0,max:100,step:1};case"alpha":return{min:0,max:1,step:.01};default:throw new Error("Unknown color channel: "+t)}}getFormat(){return"hsba"}getChannels(){return["hue","saturation","brightness"]}},k=class n extends M{constructor(t,e,r,a){super(),this.hue=t,this.saturation=e,this.lightness=r,this.alpha=a}static parse(t){var o,l;let e=t.match(mt);if(!e)return;let[r,a,s,h]=(l=(o=e[1]||e[2])==null?void 0:o.split(",").map(c=>Number(c.trim().replace("%",""))))!=null?l:[];return new n(r%360,C(a,0,100),C(s,0,100),C(h!=null?h:1,0,1))}toRGB(){let t=this.hue,e=this.saturation/100,r=this.lightness/100;function a(h){let o=(h+t/30)%12,l=e*Math.min(r,1-r);return r-l*Math.max(-1,Math.min(o-3,9-o,1))}let s=255;return new H(Math.round(a(0)*s),Math.round(a(8)*s),Math.round(a(4)*s),Number(this.alpha.toFixed(2)))}toHSB(){let t=this.hue,e=this.saturation/100,r=this.lightness/100,a=r+e*Math.min(r,1-r);return a===0?e=0:e=2*(1-r/a),new $(Number(t.toFixed(2)),Number((e*100).toFixed(2)),Number((a*100).toFixed(2)),Number(this.alpha.toFixed(2)))}toFormat(t){switch(t){case"hsla":return this;case"rgba":return this.toRGB();case"hsba":return this.toHSB();case"oklcha":return this.toRGB().toFormat("oklcha");default:throw new Error(`Invalid format: ${t}`)}}toString(t){switch(t){case"hex":return this.toRGB().toString("hex");case"hexa":return this.toRGB().toString("hexa");case"hsl":return`hsl(${this.hue}, ${this.saturation.toFixed(2)}%, ${this.lightness.toFixed(2)}%)`;case"css":case"hsla":return`hsla(${this.hue}, ${this.saturation.toFixed(2)}%, ${this.lightness.toFixed(2)}%, ${this.alpha})`;case"rgb":return this.toRGB().toString("rgb");case"hsb":return this.toHSB().toString("hsb");case"oklch":return this.toRGB().toFormat("oklcha").toString("oklch");default:return this.toFormat(t).toString(t)}}toJSON(){return{hue:this.hue,saturation:this.saturation,lightness:this.lightness,alpha:this.alpha}}clone(){return new n(this.hue,this.saturation,this.lightness,this.alpha)}getChannelRange(t){switch(t){case"hue":return{min:0,max:360,step:1};case"saturation":case"lightness":return{min:0,max:100,step:1};case"alpha":return{min:0,max:1,step:.01};default:throw new Error("Unknown color channel: "+t)}}getFormat(){return"hsla"}getChannels(){return["hue","saturation","lightness"]}},H=class n extends M{constructor(t,e,r,a){super(),this.red=t,this.green=e,this.blue=r,this.alpha=a}static parse(t){var r;if(!t)return;let e=t.trim();return(r=this.parseHexColor(e))!=null?r:this.parseRgbFunction(e)}static parseHexColor(t){let e=t.match(Ct);if(!e)return;let r=e[1];if(r.length<=4&&(r=r.split("").map(l=>l+l).join("")),![6,8].includes(r.length))return;let a=parseInt(r.slice(0,2),16),s=parseInt(r.slice(2,4),16),h=parseInt(r.slice(4,6),16),o=r.length===8?parseInt(r.slice(6,8),16)/255:1;return new n(a,s,h,o)}static parseRgbFunction(t){let e=t.match(bt);if(!(e!=null&&e[1]))return;let[r,a,s,h]=e[1].split(",").map(b=>b.trim()),o=C(Number(r),0,255),l=C(Number(a),0,255),c=C(Number(s),0,255),i=h!==void 0?C(Number(h),0,1):1;if(![o,l,c,i].some(b=>Number.isNaN(b)))return new n(o,l,c,i)}toHSB(){let[e,r,a]=[this.red/255,this.green/255,this.blue/255],s=Math.max(e,r,a),h=Math.min(e,r,a),o=s-h,l=s,c=s===0?0:o/s,i=0;if(o!==0){switch(s){case e:i=(r-a)/o%6;break;case r:i=(a-e)/o+2;break;case a:i=(e-r)/o+4;break}i*=60,i<0&&(i+=360)}return new $(Number(i.toFixed(2)),Number((c*100).toFixed(2)),Number((l*100).toFixed(2)),Number(this.alpha.toFixed(2)))}toHSL(){let[e,r,a]=[this.red/255,this.green/255,this.blue/255],s=Math.max(e,r,a),h=Math.min(e,r,a),o=(s+h)/2,l=s-h,c=0,i=-1;if(l!==0){switch(s){case e:c=(r-a)/l%6;break;case r:c=(a-e)/l+2;break;case a:c=(e-r)/l+4;break}c*=60,c<0&&(c+=360)}return o===0||o===1?i=0:i=l/(1-Math.abs(2*s-l-1)),new k(Number(c.toFixed(2)),Number((i*100).toFixed(2)),Number((o*100).toFixed(2)),Number(this.alpha.toFixed(2)))}toOKLCH(){let e=[this.red/255,this.green/255,this.blue/255].map(S=>Math.abs(S)<=.04045?S/12.92:(S<0?-1:1)*((Math.abs(S)+.055)/1.055)**2.4),r=N([.41239079926595934,.357584339383878,.1804807884018343,.21263900587151027,.715168678767756,.07219231536073371,.01933081871559182,.11919477979462598,.9505321522496607],e),s=N([.819022437996703,.3619062600528904,-.1288737815209879,.0329836539323885,.9292868615863434,.0361446663506424,.0481771893596242,.2642395317527308,.6335478284694309],r).map(S=>Math.cbrt(S)),[h,o,l]=N([.210454268309314,.7936177747023054,-.0040720430116193,1.9779985324311684,-2.42859224204858,.450593709617411,.0259040424655478,.7827717124575296,-.8086757549230774],s),c=Math.sqrt(o**2+l**2),i=Math.abs(o)<2e-4&&Math.abs(l)<2e-4?NaN:(Math.atan2(l,o)*180/Math.PI%360+360)%360,b=Number(Math.min(1,Math.max(0,h)).toFixed(4)),V=Number(c.toFixed(4)),E=Number.isNaN(i)?NaN:Number(i.toFixed(2));return new P(b,V,E,Number(this.alpha.toFixed(2)))}toHexInt(){return this.red<<16|this.green<<8|this.blue}toFormat(t){switch(t){case"rgba":return this;case"hsla":return this.toHSL();case"hsba":return this.toHSB();case"oklcha":return this.toOKLCH();default:throw new Error(`Invalid format: ${t}`)}}toString(t){switch(t){case"hex":return`#${this.red.toString(16).padStart(2,"0")}${this.green.toString(16).padStart(2,"0")}${this.blue.toString(16).padStart(2,"0")}`;case"hexa":return`#${this.red.toString(16).padStart(2,"0")}${this.green.toString(16).padStart(2,"0")}${this.blue.toString(16).padStart(2,"0")}${Math.round(this.alpha*255).toString(16).padStart(2,"0")}`;case"rgb":return`rgb(${this.red}, ${this.green}, ${this.blue})`;case"rgba":case"css":return`rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;case"hsl":return this.toHSL().toString("hsl");case"hsb":return this.toHSB().toString("hsb");case"oklch":return this.toOKLCH().toString("oklch");default:return this.toFormat(t).toString(t)}}toJSON(){return{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}}clone(){return new n(this.red,this.green,this.blue,this.alpha)}getChannelRange(t){switch(t){case"red":case"green":case"blue":return{min:0,max:255,step:1};case"alpha":return{min:0,max:1,step:.01};default:throw new Error("Unknown color channel: "+t)}}getFormat(){return"rgba"}getChannels(){return["red","green","blue"]}},P=class n extends M{constructor(t,e,r,a){super(),this.L=t,this.C=e,this.H=r,this.alpha=a}static parse(t){if(!t)return;let e=t.trim().match(dt);if(!e)return;let r=Number(e[1])/100,a=Number(e[2]),s=Number(e[3]),h=e[5]!==void 0?Number(e[5]):1;return new n(r,a,s,h)}toRGB(){let t=this.L,e=Number.isNaN(this.H)?0:this.C*Math.cos(this.H*Math.PI/180),r=Number.isNaN(this.H)?0:this.C*Math.sin(this.H*Math.PI/180),s=N([1,.3963377774,.2158037573,1,-.1055613458,-.0638541728,1,-.0894841775,-1.291485548],[t,e,r]).map(i=>i**3),h=N([1.2268798758,-.5578149945,.2813910457,-.0405757452,1.1122868033,-.0717110581,-.0763729367,-.4214933324,1.5869240198],s),[o,l,c]=N([3.240969942,-1.537383178,-.49861076,-.969243636,1.875967502,.041555057,.05563008,-.203976959,1.056971514],h);return[o,l,c]=[o,l,c].map(i=>Math.abs(i)>.0031308?(i<0?-1:1)*(1.055*Math.abs(i)**(1/2.4)-.055):12.92*i),new H(Math.round(C(o,0,1)*255),Math.round(C(l,0,1)*255),Math.round(C(c,0,1)*255),Number(this.alpha.toFixed(2)))}toJSON(){return{L:this.L,C:this.C,H:this.H,alpha:this.alpha}}clone(){return new n(this.L,this.C,this.H,this.alpha)}toFormat(t){switch(t){case"oklcha":return this;case"rgba":return this.toRGB();case"hsla":return this.toRGB().toFormat("hsla");case"hsba":return this.toRGB().toFormat("hsba");default:throw new Error(`Invalid format: ${t}`)}}toString(t){switch(t){case"hex":return this.toRGB().toString("hex");case"hexa":return this.toRGB().toString("hexa");case"oklch":{let e=Number.isNaN(this.L)?0:Number((this.L*100).toFixed(2)),r=Number.isNaN(this.C)?0:Number(this.C.toFixed(4)),a=Number.isNaN(this.H)?0:Number(this.H.toFixed(2));return`oklch(${e}% ${r} ${a})`}case"oklcha":case"css":{let e=Number.isNaN(this.L)?0:Number((this.L*100).toFixed(2)),r=Number.isNaN(this.C)?0:Number(this.C.toFixed(4)),a=Number.isNaN(this.H)?0:Number(this.H.toFixed(2)),s=Number.isNaN(this.alpha)?1:Number(this.alpha.toFixed(2));return`oklch(${e}% ${r} ${a} / ${s})`}case"hsl":return this.toRGB().toString("hsl");case"hsb":return this.toRGB().toString("hsb");case"rgb":return this.toRGB().toString("rgb");default:return this.toFormat(t).toString(t)}}getChannelRange(t){switch(t){case"L":return{min:0,max:1,step:.01};case"C":return{min:0,max:.4,step:.01};case"H":return{min:0,max:360,step:1};case"alpha":return{min:0,max:1,step:.01};default:throw new Error("Unknown color channel: "+t)}}getFormat(){return"oklcha"}getChannels(){return["L","C","H"]}},f=n=>{var e,r,a;let t=(a=(r=(e=H.parse(n))!=null?e:k.parse(n))!=null?r:$.parse(n))!=null?a:void 0;if(!t)throw new Error(`Invalid color: ${n}`);return t};function Ft(n,t,e){let{min:r,max:a}=t.getChannelRange(n),s=e==="horizontal"?"right":"bottom";switch(n){case"hue":return`linear-gradient(to ${s}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;case"lightness":{let h=t.withChannelValue(n,r).toString("css"),o=t.withChannelValue(n,(a-r)/2).toString("css"),l=t.withChannelValue(n,a).toString("css");return`linear-gradient(to ${s}, ${h}, ${o}, ${l})`}case"red":case"green":case"blue":case"saturation":case"brightness":case"alpha":{let h=t.withChannelValue(n,r).toString("css"),o=t.withChannelValue(n,a).toString("css");return`linear-gradient(to ${s}, ${h}, ${o})`}default:throw new Error(`Unknown color channel: ${n}`)}}function Nt(n,t){switch(t){case"hue":return f(`hsl(${n.getChannelValue("hue")}, 100%, 50%)`);case"red":case"green":case"blue":case"lightness":case"brightness":case"saturation":return n.withChannelValue("alpha",1);case"alpha":return n;default:throw new Error("Unknown color channel: "+t)}}var xt={hue:n=>[0,60,120,180,240,300,360].map(t=>n.withChannelValue("hue",t).toString("css")).join(", "),saturation:n=>`${n.withChannelValue("saturation",0).toString("css")}, transparent`,lightness:()=>"black, transparent, white",brightness:()=>"black, transparent"};function z(n,t){let{xChannel:e,zChannel:r}=n.getSpaceAxes(t),a=n.getChannelValue(r),s=n.getFormat(),o=f((s==="rgba"||s==="oklcha"?"hsba":s)==="hsla"?"hsl(0, 100%, 50%)":"hsb(0, 100%, 100%)").withChannelValue(r,a),l=n.getChannels(),c=b=>b===e?"right":"top",i=l.filter(b=>b!==r).map(b=>`linear-gradient(to ${c(b)}, ${xt[b](o)})`).reverse();return r==="hue"&&i.push(o.toString("css")),{"--area-gradient":i.join(", ")}}function J(n,t,e="hsba"){let r=n.getFormat()==="hsla";switch(t){case"hex":return n.getChannelValue("alpha")<n.getChannelRange("alpha").max?n.toString("hexa"):n.toString("hex");case"css":return n.toFormat(e).toString("css");case"red":case"green":case"blue":return n.toFormat("rgba").getChannelValue(t).toString();case"hue":return n.toFormat(r?"hsla":"hsba").getChannelValue("hue").toString();case"saturation":return n.toFormat(r?"hsla":"hsba").getChannelValue("saturation").toString();case"lightness":return n.toFormat("hsla").getChannelValue("lightness").toString();case"brightness":return n.toFormat("hsba").getChannelValue("brightness").toString();case"C":return n.toFormat("oklcha").getChannelValue("C").toString();case"H":return n.toFormat("oklcha").getChannelValue("H").toString();case"L":return n.toFormat("oklcha").getChannelValue("L").toString();default:return n.getChannelValue(t).toString()}}function Mt(n,t="hex"){switch(t){case"hex":return{min:f("#000000").toHexInt(),max:f("#FFFFFF").toHexInt(),step:1};case"css":return;case"red":case"green":case"blue":return n.toFormat("rgba").getChannelRange(t);case"hue":case"lightness":case"saturation":return n.toFormat("hsla").getChannelRange(t);case"brightness":return n.toFormat("hsba").getChannelRange(t);case"L":case"C":case"H":return n.toFormat("oklcha").getChannelRange(t);default:return n.getChannelRange(t)}}import{withHeadless as ft}from"@primereact/core/headless";import{useControlledState as St}from"@primereact/hooks/use-controlled-state";import*as x from"react";var K={defaultValue:void 0,value:void 0,format:"hsba",disabled:!1,onValueChange:void 0};var Et=ft({name:"useColorPicker",defaultProps:K,setup({props:n}){let{format:t="hsba",disabled:e}=n,[r,a]=x.useState(!1),s=x.useRef([]),[h,o]=St({value:x.useMemo(()=>n.value,[n.value]),defaultValue:x.useMemo(()=>{var u;return(u=n.defaultValue)!=null?u:f("#ff0000").toFormat(n.format||"hsba")},[n.defaultValue]),onChange:n.onValueChange}),l=x.useMemo(()=>h!=null?h:f("#ff0000").toFormat(t),[h,t]),c=t.startsWith("hsl")?"hsla":"hsba",i=x.useMemo(()=>l.toFormat(c),[l,c]),b={value:l,isAreaDragging:r},V=(u,g,d)=>{if(!d||e)return;let p=d.getBoundingClientRect(),w=Math.max(0,Math.min(1,(u-p.left)/p.width)),F=Math.max(0,Math.min(1,(g-p.top)/p.height)),{xChannel:m,yChannel:y}=G(),B=i.getChannelRange(m),v=i.getChannelRange(y),rt=w*(B.max-B.min)+B.min,at=(1-F)*(v.max-v.min)+v.min,st=rt-i.getChannelValue(m),ot=at-i.getChannelValue(y),L=i.incChannelValue(m,st).incChannelValue(y,ot);o([L,{color:L.toString(t),value:L}]),I(L)},E=u=>{let g=u.currentTarget;!g||u.button!==0||(g.setPointerCapture(u.pointerId),a(!0),V(u.clientX,u.clientY,g))},S=u=>{r&&V(u.clientX,u.clientY,u.currentTarget)},Y=u=>{let g=u.currentTarget;g&&(g.releasePointerCapture(u.pointerId),a(!1))},j=u=>{if(e)return;let g=u.key;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown"].includes(g))return;u.preventDefault();let{xChannel:d,yChannel:p}=G(),{step:w}=i.getChannelRange(d),{step:F}=i.getChannelRange(p),m=i;g==="ArrowRight"&&(m=m.incChannelValue(d,w)),g==="ArrowLeft"&&(m=m.decChannelValue(d,w)),g==="ArrowUp"&&(m=m.incChannelValue(p,F)),g==="ArrowDown"&&(m=m.decChannelValue(p,F)),o([m,{color:m.toString(t),value:m}]),I(m)},G=()=>{let u=i.getChannels();return{xChannel:u[1],yChannel:u[2]}},q=()=>{if(typeof window!="undefined"&&!window.EyeDropper||e)return;new window.EyeDropper().open().then(g=>{let d=f(g.sRGBHex);o([d,{color:d.toString(t),value:d}]),I(d)}).catch(g=>{console.error("Error opening eyedropper",g)})},R=G(),{min:A,max:W}=i.getChannelRange(R.xChannel),{min:D,max:Q}=i.getChannelRange(R.yChannel),Z=i.getChannelValue(R.xChannel),_=i.getChannelValue(R.yChannel),tt=U(X({},z(i,R)),{"--thumb-background":i.withChannelValue("alpha",1).toString("css"),"--thumb-position-left":(Z-A)/(W-A)*100+"%","--thumb-position-top":(1-(_-D)/(Q-D))*100+"%"}),et={"--swatch-background":l.toString("css")},nt=u=>{let g=u.elementRef.current;s.current.includes(g)||s.current.push(g)},I=u=>{requestAnimationFrame(()=>{let g=u||l;s.current.forEach(p=>{let w=p.getAttribute("data-channel");if(w){let F=J(g,w,t);p.value=String(F)}})})};return x.useEffect(()=>{I()},[t]),{state:b,value:h,areaValue:i,areaChannels:R,setValue:o,handleAreaPointerDown:E,handleAreaPointerMove:S,handleAreaPointerUp:Y,handleAreaKeyDown:j,areaStyles:tt,swatchStyles:et,openEyeDropper:q,syncChannelInputs:I,registerInputEl:nt}}});export{$ as HSBColor,k as HSLColor,P as OKLCHColor,H as RGBColor,K as defaultProps,z as getAreaGradient,Nt as getChannelColor,Ft as getChannelGradient,Mt as getInputChannelRange,J as getInputChannelValue,Rt as isEqual,f as parseColor,Et as useColorPicker};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|