patiya 3.0.0 → 3.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patiya",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/patiya.cjs",
@@ -7,7 +7,7 @@
7
7
  "files": [
8
8
  {
9
9
  "name": "dock.tsx",
10
- "content": "import React, { useRef, useState, useEffect } from 'react';\nimport { cn } from '../../utils/cn';\n\nexport interface DockProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n magnification?: number;\n distance?: number;\n direction?: 'top' | 'bottom' | 'middle';\n}\n\nexport const Dock = React.forwardRef<HTMLDivElement, DockProps>(\n ({ className, children, magnification = 60, distance = 140, direction = 'bottom', ...props }, ref) => {\n const mouseX = useRef<number | null>(null);\n const [_, setRender] = useState(0); // to force re-renders on mouse move\n\n const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {\n mouseX.current = e.pageX;\n setRender(prev => prev + 1);\n };\n\n const handleMouseLeave = () => {\n mouseX.current = null;\n setRender(prev => prev + 1);\n };\n\n return (\n <div\n ref={ref}\n onMouseMove={handleMouseMove}\n onMouseLeave={handleMouseLeave}\n className={cn(\n \"flex gap-4 p-4 rounded-2xl bg-white/10 dark:bg-black/10 border border-white/20 dark:border-black/20 backdrop-blur-lg items-end\",\n className\n )}\n {...props}\n >\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return React.cloneElement(child, {\n // @ts-ignore\n mouseX,\n magnification,\n distance\n });\n }\n return child;\n })}\n </div>\n );\n }\n);\nDock.displayName = 'Dock';\n\nexport interface DockItemProps extends React.HTMLAttributes<HTMLDivElement> {\n mouseX?: React.MutableRefObject<number | null>;\n magnification?: number;\n distance?: number;\n baseSize?: number;\n}\n\nexport const DockItem = React.forwardRef<HTMLDivElement, DockItemProps>(\n ({ className, children, mouseX, magnification = 60, distance = 140, baseSize = 40, ...props }, ref) => {\n const itemRef = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(baseSize);\n\n useEffect(() => {\n if (!itemRef.current || !mouseX || mouseX.current === null) {\n setWidth(baseSize);\n return;\n }\n\n const rect = itemRef.current.getBoundingClientRect();\n const itemCenterX = rect.left + rect.width / 2;\n \n const dist = Math.abs(mouseX.current - itemCenterX);\n \n if (dist < distance) {\n // Linear scaling based on distance\n const scale = 1 - dist / distance;\n const newWidth = baseSize + (magnification - baseSize) * scale;\n setWidth(newWidth);\n } else {\n setWidth(baseSize);\n }\n }, [mouseX?.current, baseSize, magnification, distance]);\n\n return (\n <div\n ref={(node) => {\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n // @ts-ignore\n itemRef.current = node;\n }}\n style={{ width: `${width}px`, height: `${width}px` }}\n className={cn(\n \"flex items-center justify-center rounded-full bg-white dark:bg-black shadow-sm transition-all duration-150 ease-out\",\n className\n )}\n {...props}\n >\n {children}\n </div>\n );\n }\n);\nDockItem.displayName = 'DockItem';\n",
10
+ "content": "\"use client\";\nimport React, { createContext, useContext, useRef, useState, useCallback, useEffect } from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type DockDirection = 'top' | 'bottom' | 'middle';\n\nexport type DockProps = React.HTMLAttributes<HTMLDivElement> & {\n children: React.ReactNode;\n magnification?: number;\n distance?: number;\n direction?: DockDirection;\n baseSize?: number;\n};\n\ntype DockContextValue = {\n mouseX: number | null;\n magnification: number;\n distance: number;\n baseSize: number;\n};\n\nconst DockContext = createContext<DockContextValue>({\n mouseX: null,\n magnification: 64,\n distance: 140,\n baseSize: 40,\n});\n\nexport const Dock = React.forwardRef<HTMLDivElement, DockProps>(\n (\n {\n className,\n children,\n magnification = 64,\n distance = 140,\n direction = 'bottom',\n baseSize = 40,\n ...props\n },\n ref\n ) => {\n const [mouseX, setMouseX] = useState<number | null>(null);\n\n const handleMouseMove = useCallback((e: React.MouseEvent<HTMLDivElement>) => {\n setMouseX(e.clientX);\n }, []);\n\n const handleMouseLeave = useCallback(() => {\n setMouseX(null);\n }, []);\n\n const directionClasses: Record<DockDirection, string> = {\n top: 'items-start',\n middle: 'items-center',\n bottom: 'items-end',\n };\n\n return (\n <DockContext.Provider value={{ mouseX, magnification, distance, baseSize }}>\n <div\n ref={ref}\n onMouseMove={handleMouseMove}\n onMouseLeave={handleMouseLeave}\n className={cn(\n 'inline-flex gap-3 p-3 rounded-2xl bg-black/5 dark:bg-neutral-900/80 border border-black/10 dark:border-white/15 shadow-xl backdrop-blur-2xl transition-all',\n directionClasses[direction],\n className\n )}\n {...props}\n >\n {children}\n </div>\n </DockContext.Provider>\n );\n }\n);\nDock.displayName = 'Dock';\n\nexport type DockItemProps = React.HTMLAttributes<HTMLDivElement> & {\n magnification?: number;\n distance?: number;\n baseSize?: number;\n label?: string;\n active?: boolean;\n};\n\nexport const DockItem = React.forwardRef<HTMLDivElement, DockItemProps>(\n (\n {\n className,\n children,\n magnification: propMag,\n distance: propDist,\n baseSize: propBase,\n label,\n active = false,\n ...props\n },\n ref\n ) => {\n const context = useContext(DockContext);\n const itemRef = useRef<HTMLDivElement>(null);\n\n const base = propBase ?? context.baseSize ?? 40;\n const mag = propMag ?? context.magnification ?? 64;\n const dist = propDist ?? context.distance ?? 140;\n const mouseX = context.mouseX;\n\n const [size, setSize] = useState(base);\n\n useEffect(() => {\n if (!itemRef.current || mouseX === null) {\n setSize(base);\n return;\n }\n\n const rect = itemRef.current.getBoundingClientRect();\n const itemCenterX = rect.left + rect.width / 2;\n const d = Math.abs(mouseX - itemCenterX);\n\n if (d < dist) {\n const factor = Math.cos((d / dist) * (Math.PI / 2));\n const newSize = base + (mag - base) * factor;\n setSize(Math.round(newSize * 10) / 10);\n } else {\n setSize(base);\n }\n }, [mouseX, base, mag, dist]);\n\n return (\n <div className=\"relative group inline-flex flex-col items-center\">\n {label && (\n <div className=\"absolute -top-8 px-2 py-0.5 rounded-md text-[11px] font-medium bg-[var(--patiya-color-foreground)] text-[var(--patiya-color-background)] shadow-md pointer-events-none transition-all duration-150 opacity-0 -translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 whitespace-nowrap z-30\">\n {label}\n </div>\n )}\n <div\n ref={(node) => {\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n (itemRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }}\n style={{ width: `${size}px`, height: `${size}px` }}\n className={cn(\n 'flex items-center justify-center rounded-2xl bg-white dark:bg-neutral-800 text-[var(--patiya-color-foreground)] border border-black/10 dark:border-white/15 shadow-sm hover:shadow-md hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-all duration-75 ease-out cursor-pointer select-none active:scale-95',\n className\n )}\n {...props}\n >\n {children}\n </div>\n {active && (\n <span className=\"w-1 h-1 rounded-full bg-[var(--patiya-color-primary)] mt-1 absolute -bottom-2\" />\n )}\n </div>\n );\n }\n);\nDockItem.displayName = 'DockItem';\n",
11
11
  "path": "ui/dock.tsx"
12
12
  }
13
13
  ]
@@ -519,7 +519,7 @@
519
519
  "files": [
520
520
  {
521
521
  "name": "dock.tsx",
522
- "content": "import React, { useRef, useState, useEffect } from 'react';\nimport { cn } from '../../utils/cn';\n\nexport interface DockProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n magnification?: number;\n distance?: number;\n direction?: 'top' | 'bottom' | 'middle';\n}\n\nexport const Dock = React.forwardRef<HTMLDivElement, DockProps>(\n ({ className, children, magnification = 60, distance = 140, direction = 'bottom', ...props }, ref) => {\n const mouseX = useRef<number | null>(null);\n const [_, setRender] = useState(0); // to force re-renders on mouse move\n\n const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {\n mouseX.current = e.pageX;\n setRender(prev => prev + 1);\n };\n\n const handleMouseLeave = () => {\n mouseX.current = null;\n setRender(prev => prev + 1);\n };\n\n return (\n <div\n ref={ref}\n onMouseMove={handleMouseMove}\n onMouseLeave={handleMouseLeave}\n className={cn(\n \"flex gap-4 p-4 rounded-2xl bg-white/10 dark:bg-black/10 border border-white/20 dark:border-black/20 backdrop-blur-lg items-end\",\n className\n )}\n {...props}\n >\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return React.cloneElement(child, {\n // @ts-ignore\n mouseX,\n magnification,\n distance\n });\n }\n return child;\n })}\n </div>\n );\n }\n);\nDock.displayName = 'Dock';\n\nexport interface DockItemProps extends React.HTMLAttributes<HTMLDivElement> {\n mouseX?: React.MutableRefObject<number | null>;\n magnification?: number;\n distance?: number;\n baseSize?: number;\n}\n\nexport const DockItem = React.forwardRef<HTMLDivElement, DockItemProps>(\n ({ className, children, mouseX, magnification = 60, distance = 140, baseSize = 40, ...props }, ref) => {\n const itemRef = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(baseSize);\n\n useEffect(() => {\n if (!itemRef.current || !mouseX || mouseX.current === null) {\n setWidth(baseSize);\n return;\n }\n\n const rect = itemRef.current.getBoundingClientRect();\n const itemCenterX = rect.left + rect.width / 2;\n \n const dist = Math.abs(mouseX.current - itemCenterX);\n \n if (dist < distance) {\n // Linear scaling based on distance\n const scale = 1 - dist / distance;\n const newWidth = baseSize + (magnification - baseSize) * scale;\n setWidth(newWidth);\n } else {\n setWidth(baseSize);\n }\n }, [mouseX?.current, baseSize, magnification, distance]);\n\n return (\n <div\n ref={(node) => {\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n // @ts-ignore\n itemRef.current = node;\n }}\n style={{ width: `${width}px`, height: `${width}px` }}\n className={cn(\n \"flex items-center justify-center rounded-full bg-white dark:bg-black shadow-sm transition-all duration-150 ease-out\",\n className\n )}\n {...props}\n >\n {children}\n </div>\n );\n }\n);\nDockItem.displayName = 'DockItem';\n",
522
+ "content": "\"use client\";\nimport React, { createContext, useContext, useRef, useState, useCallback, useEffect } from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type DockDirection = 'top' | 'bottom' | 'middle';\n\nexport type DockProps = React.HTMLAttributes<HTMLDivElement> & {\n children: React.ReactNode;\n magnification?: number;\n distance?: number;\n direction?: DockDirection;\n baseSize?: number;\n};\n\ntype DockContextValue = {\n mouseX: number | null;\n magnification: number;\n distance: number;\n baseSize: number;\n};\n\nconst DockContext = createContext<DockContextValue>({\n mouseX: null,\n magnification: 64,\n distance: 140,\n baseSize: 40,\n});\n\nexport const Dock = React.forwardRef<HTMLDivElement, DockProps>(\n (\n {\n className,\n children,\n magnification = 64,\n distance = 140,\n direction = 'bottom',\n baseSize = 40,\n ...props\n },\n ref\n ) => {\n const [mouseX, setMouseX] = useState<number | null>(null);\n\n const handleMouseMove = useCallback((e: React.MouseEvent<HTMLDivElement>) => {\n setMouseX(e.clientX);\n }, []);\n\n const handleMouseLeave = useCallback(() => {\n setMouseX(null);\n }, []);\n\n const directionClasses: Record<DockDirection, string> = {\n top: 'items-start',\n middle: 'items-center',\n bottom: 'items-end',\n };\n\n return (\n <DockContext.Provider value={{ mouseX, magnification, distance, baseSize }}>\n <div\n ref={ref}\n onMouseMove={handleMouseMove}\n onMouseLeave={handleMouseLeave}\n className={cn(\n 'inline-flex gap-3 p-3 rounded-2xl bg-black/5 dark:bg-neutral-900/80 border border-black/10 dark:border-white/15 shadow-xl backdrop-blur-2xl transition-all',\n directionClasses[direction],\n className\n )}\n {...props}\n >\n {children}\n </div>\n </DockContext.Provider>\n );\n }\n);\nDock.displayName = 'Dock';\n\nexport type DockItemProps = React.HTMLAttributes<HTMLDivElement> & {\n magnification?: number;\n distance?: number;\n baseSize?: number;\n label?: string;\n active?: boolean;\n};\n\nexport const DockItem = React.forwardRef<HTMLDivElement, DockItemProps>(\n (\n {\n className,\n children,\n magnification: propMag,\n distance: propDist,\n baseSize: propBase,\n label,\n active = false,\n ...props\n },\n ref\n ) => {\n const context = useContext(DockContext);\n const itemRef = useRef<HTMLDivElement>(null);\n\n const base = propBase ?? context.baseSize ?? 40;\n const mag = propMag ?? context.magnification ?? 64;\n const dist = propDist ?? context.distance ?? 140;\n const mouseX = context.mouseX;\n\n const [size, setSize] = useState(base);\n\n useEffect(() => {\n if (!itemRef.current || mouseX === null) {\n setSize(base);\n return;\n }\n\n const rect = itemRef.current.getBoundingClientRect();\n const itemCenterX = rect.left + rect.width / 2;\n const d = Math.abs(mouseX - itemCenterX);\n\n if (d < dist) {\n const factor = Math.cos((d / dist) * (Math.PI / 2));\n const newSize = base + (mag - base) * factor;\n setSize(Math.round(newSize * 10) / 10);\n } else {\n setSize(base);\n }\n }, [mouseX, base, mag, dist]);\n\n return (\n <div className=\"relative group inline-flex flex-col items-center\">\n {label && (\n <div className=\"absolute -top-8 px-2 py-0.5 rounded-md text-[11px] font-medium bg-[var(--patiya-color-foreground)] text-[var(--patiya-color-background)] shadow-md pointer-events-none transition-all duration-150 opacity-0 -translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 whitespace-nowrap z-30\">\n {label}\n </div>\n )}\n <div\n ref={(node) => {\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n (itemRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }}\n style={{ width: `${size}px`, height: `${size}px` }}\n className={cn(\n 'flex items-center justify-center rounded-2xl bg-white dark:bg-neutral-800 text-[var(--patiya-color-foreground)] border border-black/10 dark:border-white/15 shadow-sm hover:shadow-md hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-all duration-75 ease-out cursor-pointer select-none active:scale-95',\n className\n )}\n {...props}\n >\n {children}\n </div>\n {active && (\n <span className=\"w-1 h-1 rounded-full bg-[var(--patiya-color-primary)] mt-1 absolute -bottom-2\" />\n )}\n </div>\n );\n }\n);\nDockItem.displayName = 'DockItem';\n",
523
523
  "path": "ui/dock.tsx"
524
524
  }
525
525
  ]