@scrolia/react
Version:
A headless scrollbar component
1 lines • 2.23 kB
Source Map (JSON)
{"version":3,"file":"y.mjs","names":["props: ThumbYProps","p: ThumbYProps","event: React.PointerEvent<HTMLDivElement>","thumbStyle: React.CSSProperties"],"sources":["../../../src/components/thumb/y.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { useScrollCore } from \"#/contexts/scrollcore\";\nimport { getComponentProps } from \"#/functions/props\";\nimport { useThumbYHandler } from \"#/hooks/thumb\";\n\n/** Props for the `ThumbY` component. */\ntype ThumbYProps = React.ComponentProps<\"div\">;\n\n/** Vertical thumb component. */\nconst ThumbY = (props: ThumbYProps): React.JSX.Element => {\n const {\n options: { plugins },\n y: { setHvThumb, scrollbarLength, scrollbarOffset },\n } = useScrollCore();\n\n const p: ThumbYProps = getComponentProps({\n name: \"thumbY\",\n props,\n plugins,\n });\n\n React.useEffect((): void => {\n setHvThumb(true);\n }, [\n setHvThumb,\n ]);\n\n const { onPointerDown } = useThumbYHandler();\n\n const handlePointerDown = (\n event: React.PointerEvent<HTMLDivElement>,\n ): void => {\n onPointerDown(event);\n p.onPointerDown?.(event);\n };\n\n const thumbStyle: React.CSSProperties = {\n ...p.style,\n height: Number.isNaN(scrollbarLength) ? 0 : scrollbarLength,\n top: Number.isNaN(scrollbarOffset) ? 0 : scrollbarOffset,\n };\n\n return (\n <div\n {...p}\n style={thumbStyle}\n onPointerDown={handlePointerDown}\n >\n {p.children}\n </div>\n );\n};\n\nexport type { ThumbYProps };\nexport { ThumbY };\n"],"mappings":";;;;;;;;;;AAYA,MAAM,SAAS,CAACA,UAA0C;CACtD,MAAM,EACF,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,YAAY,iBAAiB,iBAAiB,EACtD,GAAG,eAAe;CAEnB,MAAMC,IAAiB,kBAAkB;EACrC,MAAM;EACN;EACA;CACH,EAAC;AAEF,OAAM,UAAU,MAAY;AACxB,aAAW,KAAK;CACnB,GAAE,CACC,UACH,EAAC;CAEF,MAAM,EAAE,eAAe,GAAG,kBAAkB;CAE5C,MAAM,oBAAoB,CACtBC,UACO;AACP,gBAAc,MAAM;AACpB,IAAE,gBAAgB,MAAM;CAC3B;CAED,MAAMC,aAAkC;EACpC,GAAG,EAAE;EACL,QAAQ,OAAO,MAAM,gBAAgB,GAAG,IAAI;EAC5C,KAAK,OAAO,MAAM,gBAAgB,GAAG,IAAI;CAC5C;AAED,wBACI,IAAC;EACG,GAAI;EACJ,OAAO;EACP,eAAe;YAEd,EAAE;GACD;AAEb"}